Label debug menu

This commit is contained in:
Marcus Huderle 2017-06-19 13:26:28 -07:00
parent 9fefcec476
commit f4920d6387
5 changed files with 246 additions and 237 deletions

View File

@ -1,5 +1,8 @@
; See wCurrentScreen in wram.asm
; unreachable debug menu, which allows selecting DMG or Game Boy Color during boot
SCREEN_SELECT_GAMEBOY_TARGET EQU $0
SCREEN_ERASE_ALL_DATA EQU $1
SCREEN_COPYRIGHT EQU $2
SCREEN_TITLESCREEN EQU $3

View File

@ -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

View File

Before

Width:  |  Height:  |  Size: 357 B

After

Width:  |  Height:  |  Size: 357 B

View File

@ -3947,7 +3947,8 @@ CallTable_2049: ; 0x2049
; First two bytes is function pointer.
; Third byte is bank of function.
; Fourth byte seems to be unused.
padded_dab Func_8000
; SCREEN_SELECT_GAMEBOY_TARGET
padded_dab HandleSelectGameboyTargetMenu
; SCREEN_ERASE_ALL_DATA
padded_dab HandleEraseAllDataMenu

239
main.asm
View File

@ -9,240 +9,7 @@ INCLUDE "data/oam_frames.asm"
SECTION "bank2", ROMX, BANK[$2]
Func_8000: ; 0x8000
ld a, [wScreenState]
rst JumpTable ; calls JumpToFuncInTable
CallTable_8004: ; 0x8004
dw Func_800a
dw Func_8104
dw Func_814e
Func_800a: ; 0x800a
xor a
ld [hFFC4], a
ld a, [hJoypadState]
cp D_UP
jr nz, .asm_8018
ld a, [hGameBoyColorFlag]
and a
jr nz, .asm_8021
.asm_8018
ld hl, wCurrentScreen
inc [hl]
xor a
ld [wScreenState], a
ret
.asm_8021
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 Func_8049
call ClearOAMBuffer
call Func_b66
call Func_588
call Func_bbe
ld hl, wScreenState
inc [hl]
ret
Func_8049: ; 0x8049
; This function is unused?
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, PointerTable_8089
xor a
call LoadVideoData
ld a, Bank(UnusedTileListData_8094)
ld bc, UnusedTileListData_8094
ld de, LoadTileLists
call Func_10c5
ret
PointerTable_8089: ; 0x8089
dw UnusedTextVideoData
UnusedTextVideoData: ; 0x808b
VIDEO_DATA_TILES UnusedTextGfx, vTilesSH + $200, $400
db $FF, $FF ; terminators
UnusedTileListData_8094: ; 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
Func_8104: ; 0x8104
ld a, [hNewlyPressedButtons]
ld b, a
and (D_DOWN | D_UP)
jr z, .asm_8115
ld a, [hGameBoyColorFlag]
ld [hFFC4], a
xor $1
ld [hGameBoyColorFlag], a
jr .asm_811d
.asm_8115
bit BIT_A_BUTTON, b
ret z
ld hl, wScreenState
inc [hl]
ret
.asm_811d
ld a, [hGameBoyColorFlag]
and a
jr nz, .asm_812e
ld a, Bank(Data_813a)
ld bc, Data_813a
ld de, LoadTileLists
call Func_10c5
ret
.asm_812e
ld a, Bank(Data_8144)
ld bc, Data_8144
ld de, LoadTileLists
call Func_10c5
ret
Data_813a: ; 0x813a
db $02
dbw $01, $98E3
db $D1
dbw $01, $9923
db $D0
db $00 ; terminator
Data_8144: ; 0x8144
db $02
dbw $01, $98E3
db $D0
dbw $01, $9923
db $D1
db $00 ; terminator
Func_814e: ; 0x414e
call Func_cb5
call Func_576
ld hl, wCurrentScreen
inc [hl]
xor a
ld [wScreenState], a
ret
INCLUDE "engine/select_gameboy_target_menu.asm"
HandleEraseAllDataMenu: ; 0x815d
ld a, [wScreenState]
@ -53729,8 +53496,8 @@ StageRedFieldBottomCollisionMasks: ; 0xd9000
INCLUDE "data/mon_gfx/mon_billboard_palette_maps_3.asm"
UnusedTextGfx: ; 0xd9c00
INCBIN "gfx/unused_text.2bpp"
SelectGameboyTargetTextGfx: ; 0xd9c00
INCBIN "gfx/select_gb_target_text.2bpp"
CopyrightTextGfx: ; 0xda000
INCBIN "gfx/copyright_text.2bpp"