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 were stored in a tokenized format. Byte values with the high bit set (#128-#255) were used to store tokens, with "high bit clear" values (#0-#127) used for literal ASCII characters.

BASIC lines were separated by the carriage return (hex 0D). In memory and perhaps on tape, they started with a two-byte address of the next program line in memory (big-endian, unlike the little-endian format used for addresses in most other personal computers); this part was apparently skipped in the disk format. The next two bytes contained the line number; unlike most other BASICs which used binary integers for this, APF BASIC used packed BCD code, where each "nybble" (half-byte) stood 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 followed.

Tokens
Blank values indicate either that the token is unused or is used for something unknown. The manual shows both RND and LEN assigned to position 176 (decimal), apparently a misprint; 172 is skipped there, and is probably actually one of these.

Documentation

 * APF programming references
 * APF technical manual
 * APF BASIC manual

Software

 * APF Imagination Machine emulator for Windows (Zipped download)

Other links and references

 * Wikipedia article
 * Ad in old computer magazine
 * Page about APF Imagination Machine
 * Another page about APF Imagination Machine
 * Yahoo group devoted to APF