[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Shape Table Problem Solved... Or Not
Jon Bettencourt <jonINTERNETrelayCHAT@napaVALLEYnet.CLARInet> wrote:
> I finally have my shape table working. It will let me draw all 4 shapes. I
> moved it from the "free space" area, where it was being overwritten with
> string data, into HiRes page 2.
Here is a little table which should come in handy:
Address Description
Hex Decimal
$0800 2048 Applesoft program starts here
$2000 8192 Hi-res page 1 starts here
$4000 16384 Hi-res page 2 starts here
$6000 24576 Potentially free memory
$9600 38400 Maximum end of available RAM for strings
The default is for LOMEM to be set to the end of the Applesoft program,
with variables being allocated in ascending memory locations from there.
String data starts at HIMEM (normally set to the start of memory used by
DOS 3.3 or BASIC.SYSTEM) and build down. If the variables and strings
meet, garbage collection is required to free up unused string space. If
that fails, you get an OUT OF MEMORY error.
With DOS 3.3, you can modify HIMEM to reserve memory between the string
space and DOS's buffers. This is not recommended with ProDOS, since
BASIC.SYSTEM adjusts HIMEM itself whenever you do any file operations.
BASIC.SYSTEM provides some calls for reserving memory above its buffers,
but these are slightly tricky to use from Applesoft.
For both operating systems, a much better option is to use the LOMEM
command to reserve space at the end of your Applesoft program.
As long as your program is smaller than 6KB, it is safe to use hi-res
page 1. (If your program is larger than this, you need to do some extra
work to move your program elsewhere in memory, up to either $4000 or
$6000, depending on whether you also need hi-res page 2.)
Every program which uses hi-res page 1 should start with a LOMEM:16384
statement, to ensure that variables will never run into the hi-res
graphics page. If you also use page 2, then you need to use
LOMEM:24576.
(If the program has been moved higher up in memory, then there is no
need to use the LOMEM statement, and all of $0800 to $1FFF is available
for shape tables or other binary data and/or code.)
Given that you should already be protecting your variables from the
hi-res page, it is easy to POKE or BLOAD your shape tables into memory
starting at 16384 if you only need to use hi-res page 1, or 24576 if you
need both pages. LOMEM should be set to a high enough address to allow
space for your shape table.
Note that the LOMEM statement must be used before any variables are
defined, because it clears all the variables.
Here is an example. Assume this Applesoft program is loaded at the
normal address ($0801) and is less than 6K. Also assume that the
program is using hi-res page 1 only, and wants to leave enough space for
1KB worth of shape tables.
We therefore need to set LOMEM to 16384 + 1024 = 17408. Any shape
tables can be POKEd or BLOADed starting at 16384, as long as they finish
before 17408. (If this turns out to be insufficient, then modify the
program to increase LOMEM accordingly.)
Here are the first few lines of the program.
5 LOMEM:17408
10 D$=CHR$(4)
20 PRINT D$,"BLOAD MYSHAPES,A16384"
30 [do the POKEs to tell Applesoft about your shape table]
40 HGR
50 XDRAW 1 AT 100,100
60 [etc]
> Does anybody know of a program that will create shape tables for me? It
> might just be easier to use that.
There is a Beagle Bros program called "Shape Mechanic". I'm not sure
whether it is among the ones which changed status to Freeware.
--
David Empson
dempson@actrix.gen.nz
Snail mail: P O Box 27-103, Wellington, New Zealand