This is an old revision of the document!
BASIC file format
BASIC sources aren't stored in plain ASCII. To allow faster loading and parsing, they are stored in bytecode format. The file is in standard DECB format, with a single block of type 0xFF. Since internal structures use absolute addresses, it is important to keep that header to know the loading address of the BASIC program.
|0||File type = 0xFF|
A BASIC program is a packed linked list of program lines.
|0||Address of next line|
|2||Line number in hex|
|4||NULL-terminated line data|
The end of the listing is marked with a NULL next line pointer.
The line data is a mix of tokens and ASCII characters. The tokens are used to encode all the keywords and functions, but everything else (numbers, strings, comments) is stored in ASCII.
Keyword and token list
|Draws a rectangle (the top left pixel is (0,0)|
|Fills a rectangle with the given color (optional, if not given use the current pen color). Negative colors lead to filling with the requested color as the background one.|
|Change pen colors (parameters are optional)|
|Ends program execution|
|FOR loop, incrementing v by n each time until it reaches e. The STEP is optional (default is 1) and can be negative.|
|Jump to program line|
|Conditions (the statement can be just a line number)|
|Set variables to user-entered values (comma separated). A
|Draws a line (first point is optional, current cursor position is used:
|List the program in memory (parameter is optional, if missing the whole program is listed)|
|Move the cursor|
|New program, remove current one from memory|
|Closes FOR loop.|
|Plays music. The string is made of notes DO,RE,MI,FA,SO,LA,SI (with # and b modifiers), octave changes (O1-O5), note duration changes (L1-L96), silences (P), tempo changes (T1-T256), attack settings (A0-A255). Spaces are ignored and can be used for readability|
|Prints a value (if the value is suffixed with a ; insert a tabulation after it. else goes to next line)|
|Set a pixel|
|Comments (REMark). Anything following this on the line is ignored.|
|run the program|
|Changecolors for whole screen|
|Integer part of value|
|Get a substring of the N first chars of S|
|Get length of string|
|Get a substring of the N last chars of S|
|Random value between 0 and 1|
|Addition, string concatenation|
Tips and tricks
The PLAY command can be used for accurate delays.