Cool AppleSoft BASIC trick I never thought of before

From: Ethan Dicks <ethan_dicks_at_yahoo.com>
Date: Wed May 17 10:33:06 2000

--- Vintage Computer GAWD! <foo_at_siconic.com> wrote:
>
> Stop me if you've heard this one before...

STOP! :-)

> On the Apple ][, in AppleSoft BASIC, you can set what the start address
> of your BASIC program will be in memory by poking it into location 103-104
> ($68-$69 hex).

There are similar locations for the same pointers in all versions of M$
BASIC for PETs, etc.
 
> The default is 2049 ($801): 103=1 and 104=8 ($68=1, $69=8).

Typical. The PET uses $0401, and the C-64 uses $0801 (because the display
memory is at $0400 by default on a C-64)
 
> QUESTION: Does anyone know why the default is $801 instead of $800? I
> always wondered why that was. Anyway...

I'm not sure of the exact reason, but for PETBASIC, $0400 (or $0800) must
contain a null byte. I suspect the same for AppleSoft.

> It occured to me tonight as I was writing just such an application--the
> Nerd Trivia Challenge management program for the VCF, which loads a
> hi-resolution character generator at $1600, which would over-run my BASIC
> code, which is therefore relocated to $4001--that two or more BASIC
> programs could reside in memory at the same time! One would simply POKE
> the beginning address into 103-104 and then LOAD the new program, and
> repeat this for as many programs as is possible with the memory available.

There was a machine language program for the PET called "QuadraPET" published
way back when (I have a copy on a 1541-disk-image file), that moved all the
BASIC pointers around in zero page to create four 8K virtual PETs on a 32K PET.
The author suggested that in a family setting, each user could have their own
space and not clobber other people's work. I'm sure it would be trivial to
adapt to AppleSoft, presuming there's around 100 bytes of protected memory
to stuff it into - the trick on the PET was to use the second cassette buffer
since so few users ever had two cassette drives. It was a great learning
experience to have to fit useful programs into 192 bytes.

> The only problem here of course is that any variables in either program
> will be quashed when the alternate program is run. However, there are
> also pointers that point to the beginning of variable memory, and I'm sure
> there would be a way to preserve these pointers so that individual
> variables for either program stay intact between transitions. Something
> worth exploring just for the hack value.

cf. QuadraPET; I can send you a copy if you'd like to disassemble it. ISTR
it was published in COMPUTE! if you have a collection of them from the 1978-
1981 timeframe. I'm fairly sure that the source is printed in the magazine.

OTOH, I am not familiar with this sort of trick being done for AppleSoft,
probably because back in those days, people moved to M/L for the Apple
very early on because of the demands for speed on graphical programs.
 
-ethan


=====
Even though my old e-mail address is no longer going to
vanish, please note my new public address: erd_at_iname.com

The original webpage address is still going away. The
permanent home is: http://penguincentral.com/

See http://ohio.voyager.net/ for details.

__________________________________________________
Do You Yahoo!?
Send instant messages & get email alerts with Yahoo! Messenger.
http://im.yahoo.com/
Received on Wed May 17 2000 - 10:33:06 BST

This archive was generated by hypermail 2.3.0 : Fri Oct 10 2014 - 23:33:09 BST