summaryrefslogtreecommitdiff
path: root/engine/select_gameboy_target_menu.asm
diff options
context:
space:
mode:
authorMarcus Huderle <huderlem@gmail.com>2017-06-19 13:26:28 -0700
committerMarcus Huderle <huderlem@gmail.com>2017-06-19 13:26:28 -0700
commitf4920d6387bc331c88de6a5be3acfbfa25f6afeb (patch)
tree0e7bcafabe34430221eccf5de43f9fc9e155faff /engine/select_gameboy_target_menu.asm
parent9fefcec47605aa232f520a38b915f8c24e2d1499 (diff)
Label debug menu
Diffstat (limited to 'engine/select_gameboy_target_menu.asm')
-rwxr-xr-xengine/select_gameboy_target_menu.asm238
1 files changed, 238 insertions, 0 deletions
diff --git a/engine/select_gameboy_target_menu.asm b/engine/select_gameboy_target_menu.asm
new file mode 100755
index 0000000..9ee76bb
--- /dev/null
+++ b/engine/select_gameboy_target_menu.asm
@@ -0,0 +1,238 @@
+HandleSelectGameboyTargetMenu: ; 0x8000
+; This is an unreachable debug menu, which allowed developers to choose to run the game
+; in either DMG or Game Boy Color mode.
+; If you want to access this menu, you must set the initial screen to
+; SCREEN_SELECT_GAMEBOY_TARGET, instead of SCREEN_ERASE_ALL_DATA.
+; Additionally, you must hold UP when booting the game.
+ ld a, [wScreenState]
+ rst JumpTable ; calls JumpToFuncInTable
+SelectGameboyTargetMenuFunctions: ; 0x8004
+ dw InitSelectGameboyTargetMenu
+ dw SelectCGBOrDMG
+ dw EndSelectGameboyTargetMenu
+
+InitSelectGameboyTargetMenu: ; 0x800a
+ xor a
+ ld [hFFC4], a
+ ld a, [hJoypadState]
+ cp D_UP
+ jr nz, .skipDebugMenu
+ ld a, [hGameBoyColorFlag]
+ and a
+ jr nz, .showMenu
+.skipDebugMenu
+ ld hl, wCurrentScreen
+ inc [hl] ; set to SCREEN_ERASE_ALL_DATA
+ xor a
+ ld [wScreenState], a
+ ret
+
+.showMenu
+ ld a, $45
+ ld [hLCDC], a
+ ld a, $e4
+ ld [wBGP], a
+ ld [wOBP0], a
+ ld [wOBP1], a
+ xor a
+ ld [hSCX], a
+ ld [hSCY], a
+ call LoadGameboyTargetMenuGfx
+ call ClearOAMBuffer
+ call Func_b66
+ call Func_588
+ call Func_bbe
+ ld hl, wScreenState
+ inc [hl]
+ ret
+
+LoadGameboyTargetMenuGfx: ; 0x8049
+ ld a, $1
+ ld [rVBK], a
+ ld c, $ff
+ call FillTilesVRAM
+ call FillBackgroundsVRAM
+ xor a
+ ld [rVBK], a
+ ld c, $0
+ call FillTilesVRAM
+ call FillBackgroundsVRAM
+ ; This code makes no sense.
+ ; It first fills 33 bytes at $ff68, then refills at rOBPI
+ ld a, $80
+ ld de, rBGPI
+ ld hl, Data_80e4
+ call Fill33Bytes
+ ld a, $80
+ ld de, rOBPI
+ ld hl, Data_80f4
+ call Fill33Bytes
+ ld hl, SelectGameboyTargetGfxPointers
+ xor a
+ call LoadVideoData
+ ld a, Bank(SelectGameboyTarget_TileData)
+ ld bc, SelectGameboyTarget_TileData
+ ld de, LoadTileLists
+ call Func_10c5
+ ret
+
+SelectGameboyTargetGfxPointers: ; 0x8089
+ dw SelectGameboyTarget_VideoData
+
+SelectGameboyTarget_VideoData: ; 0x808b
+ VIDEO_DATA_TILES SelectGameboyTargetTextGfx, vTilesSH + $200, $400
+ db $FF, $FF ; terminators
+
+SelectGameboyTarget_TileData: ; 0x8094
+ db $13
+ dbw $06, vBGMap + $a3
+ db $BC, $AF, $B6, $AF, $AD, $BD
+ dbw $06, $98AA
+ db $BD, $AB, $BB, $B1, $AF, $BD
+ dbw $04, $98E3
+ db $D0, $AD, $B1, $AC
+ dbw $03, $9924
+ db $AE, $B7, $B1
+ db $00 ; terminator
+
+FillBackgroundsVRAM: ; 0x80b5
+ ld hl, vBGMap
+.fillLoop
+ xor a
+ ld [hli], a
+ ld [hli], a
+ ld [hli], a
+ ld [hli], a
+ ld a, h
+ cp $a0 ; end of VRAM
+ jr nz, .fillLoop
+ ret
+
+FillTilesVRAM: ; 0x80c3
+ ld hl, vTilesOB
+.fillLoop
+ ld a, c
+ ld [hli], a
+ ld [hli], a
+ ld [hli], a
+ ld [hli], a
+ ld a, h
+ cp (vBGMap >> 8)
+ jr nz, .fillLoop
+ ret
+
+Fill33Bytes: ; 0x80d1
+; First places a in [de].
+; Then, reads 32 bytes from hl and places them in order at de + 1
+ ld [de], a
+ inc de
+ ld b, $4
+.outerLoop
+ ld c, $8
+ push hl
+.innerLoop
+ ld a, [hli]
+ ld [de], a
+ ld a, [hli]
+ ld [de], a
+ dec c
+ jr nz, .innerLoop
+ pop hl
+ dec b
+ jr nz, .outerLoop
+ ret
+
+Data_80e4: ; 0x80e4
+ db $FF
+ db $7F
+ db $B5
+ db $56
+ db $6B
+ db $2D
+ db $00
+ db $00
+ db $FF
+ db $7F
+ db $B5
+ db $56
+ db $6B
+ db $2D
+ db $00
+ db $00
+Data_80f4: ; 0x80f4
+ db $B5
+ db $56
+ db $FF
+ db $7F
+ db $6B
+ db $2D
+ db $00
+ db $00
+ db $FF
+ db $7F
+ db $B5
+ db $56
+ db $6B
+ db $2D
+ db $00
+ db $00
+
+SelectCGBOrDMG: ; 0x8104
+ ld a, [hNewlyPressedButtons]
+ ld b, a
+ and (D_DOWN | D_UP)
+ jr z, .directionNotPressed
+ ld a, [hGameBoyColorFlag]
+ ld [hFFC4], a
+ xor $1
+ ld [hGameBoyColorFlag], a
+ jr .moveCursor
+
+.directionNotPressed
+ bit BIT_A_BUTTON, b
+ ret z
+ ld hl, wScreenState
+ inc [hl]
+ ret
+
+.moveCursor
+ ld a, [hGameBoyColorFlag]
+ and a
+ jr nz, .cgb
+ ld a, Bank(DMGSelected_TileData)
+ ld bc, DMGSelected_TileData
+ ld de, LoadTileLists
+ call Func_10c5
+ ret
+
+.cgb
+ ld a, Bank(CGBSelected_TileData)
+ ld bc, CGBSelected_TileData
+ ld de, LoadTileLists
+ call Func_10c5
+ ret
+
+DMGSelected_TileData: ; 0x813a
+ db $02
+ dbw $01, $98E3
+ db $D1
+ dbw $01, $9923
+ db $D0
+ db $00 ; terminator
+
+CGBSelected_TileData: ; 0x8144
+ db $02
+ dbw $01, $98E3
+ db $D0
+ dbw $01, $9923
+ db $D1
+ db $00 ; terminator
+
+EndSelectGameboyTargetMenu: ; 0x414e
+ call Func_cb5
+ call Func_576
+ ld hl, wCurrentScreen
+ inc [hl] ; set to SCREEN_ERASE_ALL_DATA
+ xor a
+ ld [wScreenState], a
+ ret