The WonderSwan boot ROM is where the console begins execution on power on. * On the "mono" model, it occupies an area from $FF000 to $FFFFF, for a total of 4 KiB. * On the Color model, it occupies an area from $FE000 to $FFFFF, for a total of 8 KiB. == Boot flowchart == The boot ROM performs the following activities: * checks if the cartridge self-test passed; * If the color model, checks if the cartridge footer is valid; * if START is held when the console is turned on, enters the boot ROM menu; * updates telemetry/diagnostics information in the internal EEPROM; * displays the splash screen (optionally, a custom splash screen on Color models); * jumps to the cartridge. === Pin strapping === On startup, the boot ROM checks whether or not certain output rows are forced high when all input rows are disabled. This triggers a startup override early in the process: * Input row 0 forced high - jump to 4000:0000 before cartridge self-test, * Input row 1 forced high - jump to 4000:0010 after cartridge self-test. Note that this override is done before boot ROM lockout. In addition, the hardware is not yet fully initialized - for example, the display is disabled in [[Display/IO Ports#LCD Control|LCD Control]], which means nothing will be displayed on screen by default. == Startup state == === Console power-on === This is the state immediately after the console is turned on, before the boot ROM starts execution. ==== CPU registers ==== {| class="wikitable" ! Name ! Value |- | CS | $FFFF |- | DS | $0000 |- | ES | $0000 |- | SS | $0000 |- | IP | $0000 |- | FLAGS | $F002 |} ==== I/O ports ==== Special thanks to FluBBa for performing this research. ? means "random values"; value? means "only observed these values, but we're not sure". {| class="wikitable" ! Range ! Value |- | $00 | $00 |- | $01 | $00 |- | $02 | $00? |- | $03 | ? ($B9/$BB/$BD observed on SPHINX, $40 observed on ASWAN) |- | $04 | $00 |- | $05 | $00 |- | $06 | $00 |- | $07 - $13 | ? |- | $14 | $00 |- | $15 | $00 |- | $16 | $9E on SPHINX, $9C on ASWAN |- | $17 | $9B on SPHINX, $92 on ASWAN |- | $1A | $20 on SPHINX, $22 on ASWAN |- | $40 - $52 | $00 |- | $60 | $0A |- | $62 - $6A | $00 |- | $6B | $0F? |- | $70 - $77 | TODO on SPHINX2 |- | $80 - $8D | ? |- | $8E | $00? |- | $8F | ? |- | $90 - $92 | $00 |- | $94 | $00/$01/$0B/$0F? |- | $95 | $00 |- | $A0 | $06 on SPHINX, $04 on ASWAN (bit 7 set after cartridge self-test) |- | $A2 | $00 |- | $A3 | $00 |- | $A4 - $A7 | ? |- | $A8 - $B0 | $00 |- | $B1 | $25/$27/$A4/$A5? |- | $B2 - $B4 | $00 |- | $B5 | Cannot determine |- | $B6 - $BF | $00 |} ==== Memory ==== The work RAM memory area 0x0000 - 0xFDFF is filled with the value 0x00 at the end of the boot ROM's execution, except for a small area starting at 0x0400. (TODO) On Color models, the area 0xFE00 - 0xFFFF (color palette) is instead filled with the value 0xFF. === Cartridge execution start === This is the state after exiting the boot ROM, for non-pin-strapped modes. (Pin-strapped modes, including the PCv2, are much closer to the "console power-on" state.) Only differences relative to system power-on are listed. TODO: Tested on SPHINX2 with the default (in boot ROM) splash screen; more testing is required for ASWAN/SPHINX and for custom splash screens. ==== CPU registers ==== {| class="wikitable" ! Name ! Value (WS) ! Value (WSC/SC) ! Notes |- | AX | $FF85 | $FF87 | AL is equal to the value of I/O port $A0 |- | BX | $0040 | $0043 | |- | CX | colspan="2" | $0000 | |- | DX | colspan="2" | ? | [[Internal EEPROM]] system startup counter? |- | SI | $023D | $0457 | First byte after the boot stub in boot ROM (DS:SI) |- | DI | $040D | $040B | First byte after the boot stub in internal RAM (ES:DI) |- | SP | colspan="2" | $2000 | |- | BP | colspan="2" | $0000 | |- | CS | colspan="2" | $FFFF | |- | DS | $FF00 | $FE00 | Boot ROM segment |- | ES | colspan="2" | $0000 | Internal RAM segment |- | SS | colspan="2" | $0000 | |- | IP | colspan="2" | $0000 | |- | FLAGS | colspan="2" | $F082/$F086? | |} ==== I/O ports ==== This is a list only of those I/O ports whose values are changed compared to the initial execution state. {| class="wikitable" ! Port ! WSC/SC |- | $07 | $00 |- | $10 | $00 |- | $11 | $00 |- | $12 | $00 |- | $13 | $00 |- | $14 | $01/$03 |- | $60 | $0A |- | $70 - $77 | From EEPROM, SC only |- | $80 - $8C | $00 |- | $8F - $91 | $00 |- | $94 | $00 |- | $9E | $03 |- | $A0 | $87 |- | $B0 | $00 |- | $B2 | $00 |- | $B5 | $40 |- | $B6 | $FF |- | $BA - $BB | $00 |- | $BC | ? |- | $BD | ? |- | $BE | $80 |- | $C2 | $FF |- | $C3 | $FF |} ==== Memory ==== All memory is cleared except for memory locations $0400 - $040C (WS) or $0400 - $040A (WSC/SC), which contain a code stub which locks out the boot ROM by modifying the I/O port $A0 and jumps to $FFFF:$0000.