====== Pocket Challenge V2 ====== Pocket Challenge V2 differs from the //mono// WonderSwan in two ways: * Most boot ROM execution is skipped and the code entry point is different. This is referred to as using the "pinstrap" entry point. * The input button layout is different. ===== Pinstrap entry point ===== "Pinstrap" refers to an alternate mode of execution where code is executed from ''4000:0000'' or ''4000:0010'' instead of executing the full boot ROM logic and jumping to ''FFFF:0000''. It is documented in more detail on [[https://ws.nesdev.org/wiki/Boot_ROM|the WSdev wiki]]. The Pocket Challenge V2 uses the same ASWAN SoC as the //mono// WonderSwan, but it repurposes the bit 1 pinstrap (code starts at ''4000:0010'') in order to bypass the Bandai splash screen, seeing as it is instead a Benesse product. This page documents how to use Wonderful to create a cartridge image that boots on the PCv2. ==== Adding the alternate start location ==== To add a stub at ''4000:0010'' which jumps to your program, replace ''%%$(WF_CRT0)%%'' in your Makefile with ''%%$(WF_CRT0) $(WF_CRT0_PINSTRAP1)%%''. For ''4000:0000'', append ''%%$(WF_CRT0_PINSTRAP0)%%'' instead of ''%%$(WF_CRT0_PINSTRAP1)%%''. You can also append both. ==== Adding missing hardware initialization ==== The pinstrap mode omits certain hardware initialization code that occurs in the boot ROM. In particular, the LCD display driver is never enabled. To solve this, add the following code to your program: outportb(WS_LCD_CTRL_PORT, inportb(WS_LCD_CTRL_PORT) | WS_LCD_CTRL_DISPLAY_ENABLE); ==== Optional: Preserving unlocked boot ROM ==== The default pinstrap stubs disable the boot ROM before jumping to user code, as the pinstrap mode starts with the boot ROM overlaid on top of the cartridge area at ''0xFF000'' - ''0xFFFFF''. If you'd like to instead access the boot ROM contents, you have to perform the following steps: * Replace ''%%$(WF_CRT0_PINSTRAP1)%%'' with ''%%$(WF_CRT0_PINSTRAP1_UNLOCKED)%%''. * Add ''%%rom_reserve_bootrom_area = true%%'' to the ''%%[cartridge]%%'' section of ''%%wfconfig.toml%%''. This will reserve the final 8 KiB of the cartridge space, preventing any data assigned to the linear ROM bank (but //not// assigned to ROM0 or ROM1 banks) from being placed there. ===== Input button layout ===== The input button layout of the Pocket Challenge V2 is [[https://ws.nesdev.org/wiki/Keypad#Pocket_Challenge_V2|distinct]]. libws provides separate key defines matching this layout: if (ws_system_get_model() == WS_MODEL_PCV2) { // use WS_KEY_PCV2_ defines... } else { // use WS_KEY_ defines... }