Re: [stella] Atari 2600 BASIC compiler

Subject: Re: [stella] Atari 2600 BASIC compiler
From: "Fred Quimby" <c9r@xxxxxxxxxxx>
Date: Sun, 10 Jul 2005 00:49:22 -0400
>Having the compiler analyze the code and autodetect that a value can
>be overwritten is just way beyond what I think Mr. Quimby wants to do.

Yes, most definitely... I've never written a compiler before.

>To a certain extent, Batari Basic is more of a mighty macro than
>anything else. Like all computer languages, its utility will be found
>in two main areas: the friendliness of its syntax (i.e. Basic-like
>being friendlier than ASM, and chunking frequent sets of ASM
>operations into single commands) and the richness of its libraries
>(like, right now it has a very good kernal for the players, missiles,
>and a score.)

Yes, it's pretty simple, and the compiler only handles one line at a time, 
and forgets everything it did before.  It seems initially that this wouldn't 
be possible, but I figured out that with a simple form of BASIC, it actually 
is.  Though to add for-next loops I will need it to remember a little bit.

>Fred, Getting back to the original question...
>
>If you had a syntax like
>10 dim monsterxpos as A
>20 dim monsterypos as B
>30 dim titlescreentimer as A : rem monster not on title screen!
>40 dim titlescreenmusicptr as B : rem monster not on title screen
>
>that would let them assign arbitrary names to RAM
>
>an overlay approach might look something like this
>
>10 variableset ingame : rem name for this group
>12 dim monsterxpos : rem would be assigned 'a'
>14 monsterypos : rem would be assigned to 'b'
>20 variableset titlescreen : rem name for this group
>30 dim titlescreentimer : rem would be assigned 'a'
>40 dim titlescreenmusicptr : rem would be assigned 'b'
>
>and then later on
>
>100 usevariableset titlescreen
>110 titlescreentimer = 0
>.
>.
>500 usevariableset ingame
>510 monsterxpos = 40
>
>and in this case a line like
>520 titlescreentimer = 100
>should throw an error at compile time, since it's not in the current
>variableset/overlapy
>
>actually, any variable declared before the first "variableset"
>declaration should probably be 'global', and available to any part of
>the program. and that way if they don't want to use variablesets at
>all, it just ducks out of the way and they don't have to think about
>it ('til they start running out of memory at least!)

Honestly, I'd rather just make all variables global - I mean, in 6502 ASM 
there is no such thing as a local variable.

Also, to solve the re-use problem, I'd be more inclined to still allow a-z 
as they want, but require a dim to use anything else, and require that "dim" 
maps to a-z.  Also, instead of making special syntax for dim, just use 
something really close to DASM syntax for equates and just have the compiler 
generate a .h file for the BASIC program.  This way I'd just need to pass 
the text directly to DASM with little translation.  This would also ease a 
transistion to assembly with DASM.

For instance, a BASIC program would just use:

dim monsterxpos = a
dim monsterypos = b
dim timer = c

and all the compiler would need to do is strip off the "dim" and stick it in 
a DASM header file, except for fixed point variables.  To make it clear that 
they must use two bytes, any "dim" with a dot would be declared as fixed 
point.

dim fixedpoint = c.d

that is, c as the integer component and d as the decimal.  Then the compiler 
would simply stick fixedpoint = c in the header file, but remember for the 
rest of compilation that "fixedpoint" will use fixed point math routines 
instead of integer routines, unless it's called as int(fixedpoint) or 
frac(fixedpoint).


Archives (includes files) at http://www.biglist.com/lists/stella/archives/
Unsub & more at http://stella.biglist.com

Current Thread