The following documents the WonderWitch memory map. Note that you are not required to follow these rules to the letter; however, some amount of the beginning of memory is expected to be left to FreyaBIOS, FreyaOS, etc. === Internal RAM (0x00000 - 0x0FFFF) === {| class="wikitable" |+ WonderWitch memory map ! Address ! ASCII, 1 screen ! ASCII, 2 screens ! Shift-JIS, 1 screen ! Shift-JIS, 2 screens |- | style="text-align: center;" | 0x0000 | colspan="4" style="text-align: center;" | Interrupt vectors |- | style="text-align: center;" | 0x0100 | colspan="4" style="text-align: center;" | Internal BIOS area |- | style="text-align: center;" | 0x0290 | rowspan="8" style="text-align: center;" | Stack, user IRAM | rowspan="6" style="text-align: center;" | Stack, user IRAM | rowspan="3" style="text-align: center;" | Stack, user IRAM | style="text-align: center;" | Stack, User IRAM |- | style="text-align: center;" | 0x0E00 | style="text-align: center;" | Sprite table |- | style="text-align: center;" | 0x1000 | rowspan="2" style="text-align: center;" | Screen 1 |- | style="text-align: center;" | 0x1600 | style="text-align: center;" | Sprite table |- | style="text-align: center;" | 0x1800 | style="text-align: center;" | Screen 1 | style="text-align: center;" | Screen 2 |- | style="text-align: center;" | 0x2000 | rowspan="6" colspan="2" style="text-align: center;" | Tile data (512 tiles) |- | style="text-align: center;" | 0x2600 | style="text-align: center;" | Sprite table |- | style="text-align: center;" | 0x2800 | rowspan="2" style="text-align: center;" | Screen 2 |- | style="text-align: center;" | 0x2E00 | style="text-align: center;" | Sprite table |- | style="text-align: center;" | 0x3000 | colspan="2" style="text-align: center;" | Screen 1 |- | style="text-align: center;" | 0x3800 | colspan="2" style="text-align: center;" | Tile data (128 tiles) |- | style="text-align: center;" | 0x4000 | colspan="4" style="text-align: center;" | Color tile data; only restored with [[WonderWitch/IL/ResumeIL|ResumeIL]]. |- | style="text-align: center;" | 0xC000 | colspan="4" style="text-align: center;" | Unused; never restored on program suspend/resume. |- | style="text-align: center;" | 0xFE00 | colspan="4" style="text-align: center;" | Color palette data; only restored with [[WonderWitch/IL/ResumeIL|ResumeIL]]. |} In all modes, the stack is placed immediately before the sprite table. Note that the user IRAM area is shared between all users of FreyaBIOS - notably, FreyaOS puts ==== Interrupt vectors ==== {| class="wikitable" ! Start ! End ! Description |- | 0x00 | 0x07 | CPU interrupts |- | 0x08 | 0x0F | |- | 0x10 | 0x18 | [[WonderWitch/FreyaBIOS|FreyaBIOS]] interrupts |- | 0x19 | 0x27 | |- | 0x28 | 0x2F | SoC interrupts |} ==== Internal BIOS area ==== {| class="wikitable" ! Start ! Length ! Description |- | 0x100 | 128 | Temporary memory buffer. Used for XMODEM transfers by FreyaOS. |- | 0x180 | 64 | Wavetable memory location. |- | 0x204 | 2/4? | Written to by FreyaOS using ''sys_alloc_iram'' to point to its IRAM area. |- | 0x230 | 2 | Near pointer to temporary memory buffer (0x0100). |- | 0x232 | 2 | Near pointer to screen 1. |- | 0x234 | 2 | Near pointer to screen 2. |} === Cartridge SRAM (0x10000 - 0x1FFFF) === {| class="wikitable" ! Bank ! Offset ! Description |- | 0 | | [[WonderWitch/Filesystem|/ram0 file data]] |- | 1 | | Third process data |- | 2 | | Second process data |- | rowspan="6" | 3 | $0000 - ? | First process data; typically used by [[WonderWitch/FreyaOS|FreyaOS]] |- | $7E00 - $BEE7 | Resume slot 1 data |- | $BF00 - $FFE7 | Resume slot 0 data |- | $FFEC - $FFED | ? |- | $FFEE | Bit 0..6 - Initial sleep duration, in minutes. |- | $FFEF | Bit 0 - Initial baud rate - 0 = 9600, 1 = 38400. Bit 1..7 - resume flags |} === Cartridge flash (0x80000 - 0xFFFFF) === The 512KB of NOR flash memory is mapped and partitioned as follows: {| class="wikitable" ! Linear address ! Size ! Description |- | 0x8nnnn | rowspan="6" | 384 KB | rowspan="6" | [[WonderWitch/Filesystem|/rom0 file data]] |- | 0x9nnnn |- | 0xAnnnn |- | 0xBnnnn |- | 0xCnnnn |- | 0xDnnnn |- | 0xEnnnn | 64 KB | [[WonderWitch/FreyaOS|FreyaOS]] |- | 0xFnnnn | 64 KB | [[WonderWitch/FreyaBIOS|FreyaBIOS]] |}