The Astrocade also included a
BASIC programming language cartridge, written by
Jamie Fenton, which was an expanded version of
Li-Chen Wang's
Palo Alto Tiny BASIC. First published as Bally BASIC in 1978. Developing a
BASIC interpreter on the system was difficult, because the display alone used up almost all the available RAM. The solution to this problem was to store the BASIC program code in the video RAM. This was accomplished by interleaving every
bit of the program along with the display itself; BASIC used all the even-numbered bits, and the display used the odd-numbered bits. The
interpreter would read out two bytes, drop all the odd-numbered bits, and assemble the results into a single
byte of code. This was rendered invisible by setting two of the colors to be the same as the other two, such that colors 01 and 11 would be the same (white), so the presence, or lack, of a bit for BASIC had no effect on the screen. Additional memory was scavenged by using fewer lines vertically, only 88 instead of the full 102. This managed to squeeze out 1760 bytes of RAM for BASIC programs. The downside was that most of the graphics system's power was unavailable. Programs were entered via the calculator keypad, with a plastic overlay displaying letters, symbols, and BASIC keywords. These were selected through a set of 4 colored shift keys. For example; typing "WORD"(gold) shift then the "+" key would result in GOTO. A simple line editor was supported. After typing the line number corresponding to an existing program, each press of the PAUSE key would load the next character from memory. An Astro BASIC program that later became commercialized is
Artillery Duel. John Perkins wrote the game first and submitted it to
The Arcadian fanzine, from which it was adapted for the Astro BASIC manual. Perkins subsequently developed the Astrocade cartridge of the game.
Language features Astro BASIC supported the following keywords: • Commands: LIST, RUN, STOP, TRACE • Statements: PRINT, INPUT • Structure: GOTO, GOSUB, RETURN, IF (but no THEN and no ELSE), FOR-TO-STEP/NEXT • Graphics: BOX, CLEAR, LINE • Tape Commands: :PRINT, :INPUT, :LIST, :RUN • Functions: ABS(), CALL(), JX() (specified joystick's horizontal position), JY() (joystick vertical position), KN() (knob status), PX(X,Y) (pixel on or off), RND(), TR() (trigger status) • Built-in variables • (read only): KP (key press), RM (remainder of last division), SZ (memory size), XY (last LINE position) • (write only): SM= (scroll mode), TV= (display ASCII character) • (read/write): BC (background color), CX CY (cursor position), FC (foreground color), NT (note time), • Math: + - × ÷ • Relational operators: = = # [not equal] [the language did not support <>] • Logical operators: × [AND] + [OR] A period . at the start of the line was equivalent to REM in other BASIC implementations. Certain commands were handled by the keypad instead of by keywords: the RESET button was equivalent to NEW in other interpreters. The language supported 26 integer variables A to Z, and two pre-defined
arrays, @() - which was stored starting after the program, ascending - and *() - which was stored from the top of memory, descending. The language lacked a DIM statement for dimensioning the arrays, the size of which was determined by available memory (SZ) not used by the program listing (2 bytes per item). Ports were accessed via the array &(), and memory was accessed via the array %(), rather than using
PEEK and POKE. While the language lacked strings, KP would provide the
ASCII value of a key press, which could be output to TV, meaning that characters could be read in from the keyboard, stored in an array, and then output. The character display was 11 lines of 26 characters across. The resolution for the graphic commands is 88x160, with X ranging from -80 to 79 and Y ranging from -44 to 43. Music could be produced in four ways: • The PRINT command, as a side effect, produced a unique tone for each character or keyword displayed. • The MU variable converted numbers into notes. • Ports 16 through 23 accessed a music synthesizer. • The sound-synthesizer variables MO (master oscillator), NM (Noise Mode), NV (Noise Volume), TA (Tone A), TB (Tone B), TC (Tone C), VA (Voice A volume), VB (Voice B volume), VC (Voice C volume), VF (Vibrato Frequency), VR (VibRato). (Added to Astro BASIC but not in Bally BASIC.)
Sample code The following sample program from the manual demonstrates the joystick input and graphics functions. "Try your skill... The first player's knob moves the phaser left or right and the trigger shoots... Player two controls the target while player one shoots." This listing illustrates how keywords, which were tokenized, were always displayed with a following space. == ZGRASS ==