Cool AppleSoft BASIC trick I never thought of before

From: Pete Turnbull <pete_at_dunnington.u-net.com>
Date: Wed May 17 02:23:17 2000

On May 16, 21:03, Vintage Computer GAWD! wrote:

> As an experiment, I wrote two simple programs: one at $801 that simply
> prints "PROGRAM 1!" and then sets the start of the program to $4001 by
> POKEing a 64 into 104 then issues a RUN command, and another at $4001
> that simply prints "PROGRAM 2!" and then sets the start of the
> program to $801 by POKEing an 8 into 104 and issues a RUN.
>
> I run either of the programs and I get an endlessly alternating display
of
> "PROGRAM 1!" and "PROGRAM 2!". In other words, it works! Cool.
>
> 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.

I'm sure I've seen something similar, but I can't think what... it's a long
time since I actually used Apple ][s. Something with a menu system for a
set of disk programs, possibly.

If I remember correctly, Applesoft BASIC is one of those that searches from
the start of program every time it executes a GOTO or GOSUB. If I'm right,
the easy way to preserve variables (and all the rest of the program state,
including the GOSUB/FOR..NEXT stack) would be to POKE in the new start
address and then GOTO 10 instead of RUN.

If you do this, you better set LOMEM as well (but only once), or make sure
the highest-loaded program is the first one RUN, so the variables start in
a suitable place.

-- 
Pete						Peter Turnbull
						Dept. of Computer Science
						University of York
Received on Wed May 17 2000 - 02:23:17 BST

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