From the SAP format specification on the ASAP site, read through a summarising fetch tool: “our words”.
Blocks
The binary part is an Atari executable: one or more blocks, each of
| Field | Size | Meaning |
|---|---|---|
| Marker | 2 | $FF $FF: required before the first block, optional before the others |
| Start address | 2 | Little-endian |
| End address | 2 | Little-endian, the address of the last byte (so the data holds end − start + 1 bytes) |
| Data | end − start + 1 | Loaded at the start address |
The addresses $02E0 to $02E3, which a DOS binary file uses as the run and init addresses (see XEX), are ordinary RAM in a SAP file: the tags say what to call. A file that ends in the middle of a block or of an address is malformed; some players accept it anyway, and the viewer shows what is there and lists the problem.
TYPE R
With TYPE R there are no blocks: the rest of the file is the register dump described on the header page.
What a player offers
A limited Atari: a 6502, POKEY (at least its audio part) and 64 KB of RAM. Some players also emulate parts of ANTIC and GTIA, and COVOX. A tune may run on real hardware, so it should put up with a PIA for bank switching.
| Addresses | Use |
|---|---|
$0000–$CFFF | RAM |
$D000–$D0FF | GTIA, mirrored 8 times. ASAP maps $D014 (PAL or NTSC) and $D01F (CONSOL, one-bit sound); the rest is RAM |
$D100–$D1FF | Reserved for parallel devices: do not use |
$D200–$D2FF | POKEY, mirrored 16 times, or two POKEYs (stereo) mirrored 8 times. AUDF1–4, AUDC1–4, AUDCTL and RANDOM are required; timer interrupts through IRQEN and IRQST are strongly recommended |
$D300–$D3FF | Reserved for the PIA: do not use |
$D400–$D4FF | ANTIC, mirrored 16 times. WSYNC ($D40A) and VCOUNT ($D40B) may be used; ASAP implements NMIST and NMIRES ($D40F) but not NMIEN ($D40E) |
$D500–$D5FF | Reserved for a cartridge: do not use |
$D600–$D6FF | COVOX if enabled (ASAP only): four unsigned 8-bit converters, 0 and 3 for the left channel, 1 and 2 for the right |
$D700–$D7FF | Reserved for hardware expansions: do not use |
$D800–$FFFF | RAM; $FFFE/$FFFF is the vector for POKEY timer interrupts |
Timing and the starting state
The PAL clock is 1,773,447 Hz and the NTSC clock 1,789,772.5 Hz; a scanline is 114 cycles, nine of them stalled for refresh. When a song starts, AUDF1–4, AUDC1–4, AUDCTL and IRQEN are 0 and SKCTL is 3. A tune must not assume other register values (not even that X is zero at INIT) nor that registers survive from one PLAYER call to the next.
Not described
Known, not yet covered
- How the CMC and SoftSynth players work inside.
Unknown
- Where exactly the binary part is meant to begin when a tag line is damaged (the page gives no terminator).