Skip to content
Bruno Oliveira edited this page Oct 19, 2018 · 20 revisions
+-----------------------------------+
|           80K RAM LAYOUT          |
+-------+-------------------+-------+
| ADDR  | INFO              | SIZE  |
+-------+-------------------+-------+
| 00000 | SCREEN            | 16320 | 240x136 = 32640 4bit pixels
| 03FC0 | PALETTE           | 48    | 16 x 24bit RGB color values
V 03FF0 | PALETTE MAP       | 8     | 16 x 4bit color indexes
R 03FF8 | BORDER COLOR      | 1     | 4bit color value
A 03FF9 | SCREEN OFFSET     | 2     | horz/vert screen offset [-127...+127]
M 03FFB | MOUSE CURSOR      | 1     | index of mouse cursor in foreground tile set (system cursor if 0)
| 03FFC | ...               | 4     |
+-------+-------------------+-------+
| 04000 | BG SPRITES        | 8192  | 256 8x8 4bit bg sprites - #0 to #255
| 06000 | FG SPRITES (TILES)| 8192  | 256 8x8 4bit fg sprites (tiles) - #256 to #511
| 08000 | MAP               | 32640 | 8x8 240x136 map cells
| 0FF80 | GAMEPADS          | 4     | state for 4 gamepads
| 0FF84 | MOUSE             | 4     | mouse state X / Y / buttons
| 0FF88 | KEYBOARD          | 4     | keyboard state, codes for 4 pressed buttons
| 0FF8C | ...               | 16    |
| 0FF9C | SOUND REGISTERS   | 72    | ...
| 0FFE4 | WAVEFORMS         | 256   | 16 waveforms, each 32 x 4bit values
| 100E4 | SFX               | 4224  | ...
| 11164 | MUSIC PATTERNS    | 11520 | ...
| 13E64 | MUSIC TRACKS      | 408   | ...
| 13FFC | MUSIC POS         | 4     | ...
| 14000 | ...               | 0     |
+-------+-------------------+-------+

SPRITES: Each sprite/tile is laid out sequentially in memory. Each sprite/tile is
32 bytes long, so sprite #i starts at 0x4000+32*i. Each byte in the sprite
represents a pair of pixels (since each pixels is 4 bits). The low 4 bits are the
LEFT pixel, and the high 4 bits are the RIGHT pixel. Pixels are laid out from
left to right, row by row.

Example sprite          Representation
(each hex digit
represents a pixel)
   01234567             0x10 0x32 0x54 0x76
   89abcdef             0x98 0xba 0xdc 0xfe
   01234567             0x10 0x32 0x54 0x76
   89abcdef             0x98 0xba 0xdc 0xfe
   01234567             0x10 0x32 0x54 0x76
   89abcdef             0x98 0xba 0xdc 0xfe
   01234567             0x10 0x32 0x54 0x76
   89abcdef             0x98 0xba 0xdc 0xfe

Sprites 0 to 255 are "background sprites" that can be part of a map; 256 to
511 are "foreground sprites" that cannot be on the map (but can be drawn
programatically). Foreground sprites are also called "tiles".


+-----------------------+
|    SOUND REGISTER     |
+-----------+-----------+
| frequency | 12bit     | x 4 channels = 72 bytes
| volume    | 4bit      |
| waveform  | 32 x 4bit |
+-----------+-----------+

empty waveform generates noise by default
you can update Sound Registers every tick (60 times per second)

to read frequency and volume use the following code:
...
value = peek(0xFF9C+18*channel+1)<<8|peek(0xFF9C+18*channel)
frequency = (value&0x0fff)
volume = (value&0xf000)>>12
...


+--------------------------+
|           SFX            |
+--------------------------+
|                          |
| +----------+------+      |
| | volume   | 4bit |      |
| | wave     | 4bit | x 30 |
| | arpeggio | 4bit |      |
| | pitch    | 4bit |      |
| +----------+------+      |
|                          |
| +----------+------+      |
| | octave   | 3bit |      | x 64 = 4224 bytes
| | pitch16x | 1bit |      |
| | speed    | 3bit |      |
| | reverse  | 1bit |      |
| | note     | 4bit |      |
| | temp     | 4bit |      |
| +----------+------+      |
|                          |
| +--------------+         |
| |     LOOP     |         |
| +-------+------+ x 4     |
| | start | 4bit |         |
| | size  | 4bit |         |
| +-------+------+         |
|                          |
+--------------------------+


+------------------------+
|      MUSIC PATTERN     |
+------------------------+
|                        |
| +---------------+      |
| |  PATTERN ROW  |      |
| +--------+------+      |
| | note   | 4bit |      |
| | volume | 4bit |      |
| | param  | 4bit | x 64 | x 60 = 11520 bytes
| | effect | 3bit |      |
| | sfx    | 6bit |      |
| | octave | 3bit |      |
| +--------+------+      |
|                        |
+------------------------+
(Editor's note: Are effects really mapped in memory?)


+-----------------------------+
|        MUSIC TRACK          |
+-----------------------------+
|                             |
| +-------------+------+      |
| | pattern ch0 | 6bit |      |
| | pattern ch1 | 6bit | x 16 |
| | pattern ch2 | 6bit |      |
| | pattern ch3 | 6bit |      |
| +-------------+------+      | x 8 = 408 bytes
|                             |
| +-------+------+            |
| | tempo | 8bit |            |
| | rows  | 8bit |            |
| | speed | 8bit |            |
| +-------+------+            |
|                             |
+-----------------------------+

+-----------------+
|     MUSIC POS   |
+-------+---------+
| track | 8bit    |
| frame | 8bit    |
| row   | 8bit    |
+-------+---------+
|                 | = 4 bytes
| +-------------+ |
| |    FLAGS    | |
| +------+------+ |
| | loop | 1bit | |
| | ...  | 7bit | |
| +------+------+ |
|                 |
+-----------------+
(Editor's note: Are 8-bit values necessary? Track is 3-bit, frame is 4-bit, and row is 6-bit.)


You can’t perform that action at this time.