APF Imagination Machine BASIC tokenized file

From Just Solve the File Format Problem
(Difference between revisions)
Jump to: navigation, search
(Other links and references)
(Software)
Line 141: Line 141:
 
== Software ==
 
== Software ==
 
* [http://www.nausicaa.net/~lgreenf/apf0308.zip APF Imagination Machine emulator for Windows (Zipped download)]
 
* [http://www.nausicaa.net/~lgreenf/apf0308.zip APF Imagination Machine emulator for Windows (Zipped download)]
 +
* [https://archive.org/details/apfm1000_library APF gaming console cartridges (in-browser simulation)]
  
 
== Other links and references ==
 
== Other links and references ==

Revision as of 03:46, 6 May 2014

File Format
Name APF Imagination Machine BASIC tokenized file
Ontology
Released 1978

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 contain 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.)

Contents

Tokens

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.

Hex Dec Token meaning
80 128 GOSUB
81 129 LET
82 130 DATA
83 131 INPUT
84 132 DIM
85 133 FOR
86 134 RETURN
87 135 THEN
88 136 ON
89 137 GOTO
8A 138 TO
8B 139 RESTORE
8C 140 IF
8D 141 STEP
8E 142 STOP
8F 143 READ
90 144 NEXT
91 145 PRINT
92 146 END
93 147 LIST
94 148 REM
95 149 USING
96 150 CSAVE
97 151 CLOAD
98 152 POKE
99 153 PLOT
9A 154 HLIN
9B 155 VLIN
9C 156 COLOR
9D 157 SHAPE
9E 158 EDIT
9F 159 SAVE
A0 160 INIT
A1 161 RUN
A2 162 OPEN
A3 163 CLOSE
A4 164 MUSIC
A5 165 CALL
A6 166 DIR
A7 167 TAB
A8 168 SPC
A9 169 INT
AA 170 ABS
AB 171 SGN
AC 172 RND
AD 173 PEEK
AE 174 CHR$
AF 175 ASC
B0 176 LEN
B1 177 KEY$

See also

Documentation

Software

Other links and references

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox