APF Imagination Machine BASIC tokenized file
The APF Imagination Machine was a late-1970s home computer platform. It was actually a game console with an add-on available to turn it into a full-fledged computer, with keyboard and tape drive. A floppy disk drive was also available. As with most computers of the time, it came with a version of the BASIC programming language built in.
APF BASIC programs are stored in a tokenized format. Byte values with the high bit set (#128-#255) are used to store tokens, with "high bit clear" values (#0-#127) used for literal ASCII characters. The token meanings actually get printed out when you use BASIC commands such as PRINT CHR$(137), which causes "GOTO" to be shown (but not executed!).
BASIC lines are separated by the carriage return (hex 0D). The first two bytes containa the line number; unlike most other BASICs which use binary integers for this, APF BASIC uses packed BCD code, where each "nybble" (half-byte) stands for one decimal digit. (Basically, if you read the hexadecimal dump of the bytes, interpret it as a decimal number with 0-9 standing for those digits and A-F never used.) Then the tokenized commands and literal characters of the program line follow.
A program is preceded by a two-byte address pointing at the first free memory location after the end of the program, stored as a big-endian unsigned integer, unlike the little-endian format used for addresses in most other personal computers.
As stored on cassette with the CSAVE command, a program will be preceded by a 512-byte block taken either from bytes 0-511 or 512-1023 of memory (depending on whether memory location 41452 was set to 255 or 0 respectively), which will be placed in screen memory when the cassette is loaded (allowing the display of a title screen or instructions while the program finishes loading). Then all used memory is saved, including the program and variable values. (However, the RUN command clears variables, so if you actually want to preserve the variables loaded from tape, you need to use the GOTO command to start running the program.)
On disk, saved BASIC program files appear to be type "S", whatever that means. (The other file type is "I", which is what data files opened by a program are.)
The manual shows both RND and LEN assigned to position 176 (decimal), apparently a misprint; some testing with an emulator shows that RND is actually 172, and LEN 176.
- APF Imagination Machine data cassette
- APF Imagination Machine floppy disk
- APF Imagination Machine disk file system