home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar 229
/
229.d81
/
t.buildaboot
< prev
next >
Wrap
Text File
|
2022-08-26
|
7KB
|
263 lines
u
BUILD A BOOT
by Dave Moorman
As you may have already read in
"Sprites Are Fun," the VIC II video
chip -- while marvelous in every way
-- only "sees" 16K of memory at a
time. Everything Video must be within
that 16K -- Text Screen, Bitmap
Screen, Font, and Sprites. (Color
memory and default fonts are not
normally a problem.)
If you want to use just 1 to 3
sprites, you are in luck. Sprite
Images 13, 14, and 15 are located in
the cassette buffer (832 - 1023) and
are handy. But if you want more sprite
images, you must make a place for
them.
One method is to move the screen
to a different Video Bank. This is
particularly appropriate when working
with a bitmap screen, since space in
V-Bank 0 is extremely limited. But I
have found that the text screen can be
a great graphics palette for games.
And the default screen at 1024 works
as well as anywhere.
The only problem then is that
V-Bank 0 is [full]. System data uses
locations 0 - 827. Locations 828 -
1023 is the cassette buffer, as
already mentioned. 1024 - 2047 is the
default screen memory. And BASIC
memory begins at 2048 and continues
beyond the top of V-Bank 0.
Now, one can certainly lower the
Top of BASIC memory, usually to Page
56. This is fine for very small BASIC
programs -- and does give 2K for video
data (a font or 32 sprites). But I
happen to be greedy! I [need] more
memory. I want 128 sprites [and] a
custom font!
For greedy people like me, the
only answer is to move the Bottom of
BASIC up to Page 64 -- completely
removing BASIC memory from V-Bank 0.
We even have a 4K chunk of memory
(beginning at Page 16) which cannot be
used for sprites or custom fonts (this
being where the VIC II sees the
default fonts) but is great for ML
code and data.
So, lets get to work. The very
first step is to create a work disk or
disk image. Copy "JOYSPRITE 1000" and
"JOY.SPR" to your work disk.
I begin every program by writing
the "scratch and save" routine. This
way, [every] program can be saved by
exactly the same GOTO command.
10000 D=PEEK(186):OPEN1,D,15,"IO"
:CLOSE1:N$="PROGNAME
10001 OPEN1,D,15,"S0:"+N$:CLOSE1
:SAVEN$,D:END
First off, D is set to the current
device number. Then an "I0" is sent to
the drive to make sure it is ready to
receive data. N$ holds the name of the
program. (Notice this is at the end of
the program line -- for easy editing
-- and you don't even need the closing
quotes!) The next line Scratches the
program file and saves it.
Not only is this easy to do [once]
per program, every save on every
program is the same. In immediate
mode, type and <ENTER>:
GOTO10000
You will get so used to typing
GOTO10000 to save your work, you won't
have to think about it.
(If you have not LOADed the program
from the disk, or you are unsure which
disk drive was last used, type and
<ENTER>:
POKE186,8
before doing the GOSUB10000.
So, do it -- save the program!
Now, change the program name to
"B.PROGNAME". This will create a
second program -- your Boot. (At the
LOADSTAR Tower, we always prefix the
file to be LOADed and RUN with "B.".)
Once you make the change, do the
GOTO10000.
The boot will have to LOAD and RUN
the main program. So we begin with
finding out which device we are using:
10 D=PEEK(186):IF D<8 THEN D=8
20 A$="PROGNAME"
The next step is called "using the
dynamic keyboard." The C-64 has a
10-character keyboard buffer (631-640)
which captures and queues keystrokes.
The number of keystrokes is in
location 198. With the dynamic
keyboard technique, we trick the
computer into thinking that characters
have been typed.
First, we place the LOAD and RUN
commands in the right places on the
screen:
30 PRINT"<CLR><DN><DN><DN>A$,D"
40 PRINT"<DN><DN><DN><DN>RUN<HM>"
The bracketed (or highlighted)
letters are keypresses:
<CLR> Clear Screen
<DN> Down Cursor
<HM> Home
(You may want to first turn the
screen background black and make the
characters black -- to hide the
prestadigitalization! But for now, you
can see what is going on.)
Once this is done, we can BLOAD
any files we will need -- which do not
interfere with our Boot program. We
will use "JOYSPRITE 1000" which will
reside at Page 16.
50 SYS57812"JOYSPRITE16.ML",D,0
51 POKE780,0:POKE781,0
52 POKE782,16:SYS65493
You will want to memorize this
code! Location 780 is the .A register,
781 is .X, and 782 is .Y. We POKE 0
into 780 to tell the routine that this
is a LOAD, not a VERIFY. The LOW/HIGH
bytes of the LOAD address go into
781/782. This is why I think of memory
in Pages -- 256 pages of 256 bytes
each. The Page number is the HIGH byte
of the address -- and goes into 782.
60 SYS57812"JOY.SPR",D,0
61 POKE780,0:POKE781,0
62 POKE782,32:SYS65493
This is the file of sprites
included in this issue that you copied
to your work disk -- didn't you?
We can also have a custom font
with this program, but it will be put
at Page 8 -- which is where BASIC
still is. So as not to mess up the
Boot, we will wait until the Main
program to BLOAD the font.
Now it is time to do the magic,
moving up the Bottom of BASIC. It is
really very simple:
70 Q=32:POKE44,Q:POKEQ*256,0
Simple, right? I use Q to hold the
Bottom of BASIC Page number so I don't
have to remember it twice. I am lazy
[and] greedy!
From this point on in your
program, you do [not] want to use any
form of jump -- GOTO, GOSUB, IF-THEN.
You have put the Bottom of BASIC
"above" your program, and the
interpreter will be quite confused
with any jumping up or down. Sort of
like Grandma around little kids.
We have only one thing left to do
-- enable that dynamic keyboard stuff
we printed in lines 20-40. We have set
up the screen so the LOAD and RUN
commands are in just the right places,
and the cursor will wind up on top of
the LOAD command. Now we need a couple
of <RETURN>s.
80 POKE198,2
81 POKE631,13:POKE632,13
90 END
[Before] you RUN this, do the
GOTO10000! This program will self-
destruct when RUN, and the Secretary
will disavow all knowledge of it.
Once you save the program, go
ahead and RUN it. You will see the
dynamic keyboard do its thing. When
the READY prompt appears, type and
<RETURN>:
LIST
There is your Main program, good old
"PROGNAME". You can now write, edit,
scratch and save PROGNAME all you
want. The ML code and data are all in
memory, ready to go.
Of course, when you want to use or
edit your program at another time,
LOAD and RUN "B.PROGNAME". In fact, I
often add this line at the top of my
Main program:
1 IF PEEK(44)<>64 THEN STOP
All this does is check to see that
the Boot has been used to LOAD and RUN
the program -- which is a great idea.
Of course, you won't want to use
the name "PROGNAME" -- you are
certainly more creative than that! But
now you have a shell ready to try out
all the bells and whistles of
JoySprite. See you in the Docs.
DMM