mirror of
https://github.com/pret/pokecrystal.git
synced 2024-11-26 23:00:32 +00:00
Use constants for VBlank handlers
This commit is contained in:
parent
4432df05cb
commit
b81e339f33
@ -324,3 +324,16 @@ DEF DAYCARELADY_ACTIVE_F EQU 7
|
||||
const UNLOCKED_UNOWNS_S_TO_W_F
|
||||
const UNLOCKED_UNOWNS_X_TO_Z_F
|
||||
DEF NUM_UNLOCKED_UNOWN_SETS EQU const_value
|
||||
|
||||
; hVBlank::
|
||||
; VBlankHandlers indexes (see home/vblank.asm)
|
||||
const_def
|
||||
const VBLANK_NORMAL ; 0
|
||||
const VBLANK_CUTSCENE ; 1
|
||||
const VBLANK_SOUND_ONLY ; 2
|
||||
const VBLANK_CUTSCENE_CGB ; 3
|
||||
const VBLANK_SERIAL ; 4
|
||||
const VBLANK_CREDITS ; 5
|
||||
const VBLANK_DMA_TRANSFER ; 6
|
||||
const VBLANK_UNUSED ; 7
|
||||
DEF NUM_VBLANK_HANDLERS EQU const_value
|
||||
|
@ -1556,7 +1556,7 @@ To select a move in battle, you have to press and release the Up or Down buttons
|
||||
-; BUG: Credits sequence changes move selection menu behavior (see docs/bugs_and_glitches.md)
|
||||
ldh a, [hVBlank]
|
||||
push af
|
||||
ld a, $5
|
||||
ld a, VBLANK_CREDITS
|
||||
ldh [hVBlank], a
|
||||
+ ldh a, [hInMenu]
|
||||
+ push af
|
||||
|
@ -22,7 +22,7 @@ DoBattleTransition:
|
||||
ld a, [hl]
|
||||
push af
|
||||
vc_hook Reduce_battle_transition_flashing
|
||||
ld [hl], $1
|
||||
ld [hl], VBLANK_CUTSCENE
|
||||
|
||||
.loop
|
||||
ld a, [wJumptableIndex]
|
||||
|
@ -24,11 +24,11 @@ _PlayBattleAnim:
|
||||
call BattleAnimRequestPals
|
||||
call BattleAnimDelayFrame
|
||||
|
||||
ld c, 1
|
||||
ld c, VBLANK_CUTSCENE
|
||||
ldh a, [rKEY1]
|
||||
bit 7, a ; check CGB double speed mode
|
||||
jr nz, .got_speed
|
||||
ld c, 3
|
||||
ld c, VBLANK_CUTSCENE_CGB
|
||||
|
||||
.got_speed
|
||||
ld hl, hVBlank
|
||||
|
@ -38,7 +38,7 @@ MagnetTrain:
|
||||
ld hl, hVBlank
|
||||
ld a, [hl]
|
||||
push af
|
||||
ld [hl], 1
|
||||
ld [hl], VBLANK_CUTSCENE
|
||||
.loop
|
||||
ld a, [wJumptableIndex]
|
||||
and a
|
||||
|
@ -537,6 +537,7 @@ LinkTimeout:
|
||||
xor a
|
||||
ld [hld], a
|
||||
ld [hl], a
|
||||
assert VBLANK_NORMAL == 0
|
||||
ldh [hVBlank], a
|
||||
push de
|
||||
hlcoord 0, 12
|
||||
@ -2380,7 +2381,7 @@ CheckLinkTimeout_Receptionist:
|
||||
xor a
|
||||
ld [hl], a
|
||||
call WaitBGMap
|
||||
ld a, $2
|
||||
ld a, VBLANK_SOUND_ONLY
|
||||
ldh [hVBlank], a
|
||||
call DelayFrame
|
||||
call DelayFrame
|
||||
@ -2402,7 +2403,7 @@ CheckLinkTimeout_Gen2:
|
||||
xor a
|
||||
ld [hl], a
|
||||
call WaitBGMap
|
||||
ld a, $2
|
||||
ld a, VBLANK_SOUND_ONLY
|
||||
ldh [hVBlank], a
|
||||
call DelayFrame
|
||||
call DelayFrame
|
||||
@ -2630,7 +2631,7 @@ Link_EnsureSync:
|
||||
add $d0
|
||||
ld [wLinkPlayerSyncBuffer], a
|
||||
ld [wLinkPlayerSyncBuffer + 1], a
|
||||
ld a, $2
|
||||
ld a, VBLANK_SOUND_ONLY
|
||||
ldh [hVBlank], a
|
||||
call DelayFrame
|
||||
call DelayFrame
|
||||
|
@ -76,7 +76,7 @@ Credits::
|
||||
; BUG: Credits sequence changes move selection menu behavior (see docs/bugs_and_glitches.md)
|
||||
ldh a, [hVBlank]
|
||||
push af
|
||||
ld a, $5
|
||||
ld a, VBLANK_CREDITS
|
||||
ldh [hVBlank], a
|
||||
ld a, TRUE
|
||||
ldh [hInMenu], a
|
||||
|
@ -45,9 +45,10 @@ CrystalIntro:
|
||||
ret
|
||||
|
||||
.InitRAMAddrs:
|
||||
assert VBLANK_NORMAL == 0
|
||||
xor a
|
||||
ldh [hVBlank], a
|
||||
ld a, $1
|
||||
ld a, TRUE
|
||||
ldh [hInMenu], a
|
||||
xor a
|
||||
ldh [hMapAnims], a
|
||||
|
@ -71,7 +71,7 @@ PrintDexEntry:
|
||||
ld hl, hVBlank
|
||||
ld a, [hl]
|
||||
push af
|
||||
ld [hl], 4 ; vblank mode that calls AskSerial
|
||||
ld [hl], VBLANK_SERIAL
|
||||
|
||||
ld a, 8 ; 16 rows
|
||||
ld [wPrinterQueueLength], a
|
||||
@ -146,7 +146,7 @@ PrintPCBox:
|
||||
ld hl, hVBlank
|
||||
ld a, [hl]
|
||||
push af
|
||||
ld [hl], 4 ; vblank mode that calls AskSerial
|
||||
ld [hl], VBLANK_SERIAL
|
||||
|
||||
xor a
|
||||
ldh [hBGMapMode], a
|
||||
@ -227,7 +227,7 @@ PrintUnownStamp:
|
||||
ld hl, hVBlank
|
||||
ld a, [hl]
|
||||
push af
|
||||
ld [hl], 4 ; vblank mode that calls AskSerial
|
||||
ld [hl], VBLANK_SERIAL
|
||||
|
||||
xor a
|
||||
ldh [hBGMapMode], a
|
||||
@ -302,7 +302,7 @@ PrintMail:
|
||||
ld hl, hVBlank
|
||||
ld a, [hl]
|
||||
push af
|
||||
ld [hl], 4 ; vblank mode that calls AskSerial
|
||||
ld [hl], VBLANK_SERIAL
|
||||
|
||||
ld a, 18 / 2
|
||||
ld [wPrinterQueueLength], a
|
||||
@ -345,7 +345,7 @@ PrintPartymon:
|
||||
ld hl, hVBlank
|
||||
ld a, [hl]
|
||||
push af
|
||||
ld [hl], 4 ; vblank mode that calls AskSerial
|
||||
ld [hl], VBLANK_SERIAL
|
||||
|
||||
ld a, 16 / 2
|
||||
ld [wPrinterQueueLength], a
|
||||
@ -403,7 +403,7 @@ _PrintDiploma:
|
||||
ld hl, hVBlank
|
||||
ld a, [hl]
|
||||
push af
|
||||
ld [hl], 4 ; vblank mode that calls AskSerial
|
||||
ld [hl], VBLANK_SERIAL
|
||||
|
||||
ln a, 1, 0 ; to be loaded to wPrinterMargins
|
||||
call Printer_PrepareTilemapForPrint
|
||||
|
@ -13,11 +13,11 @@ VBlank::
|
||||
push hl
|
||||
|
||||
ldh a, [hVBlank]
|
||||
and 7
|
||||
maskbits NUM_VBLANK_HANDLERS
|
||||
|
||||
ld e, a
|
||||
ld d, 0
|
||||
ld hl, .VBlanks
|
||||
ld hl, VBlankHandlers
|
||||
add hl, de
|
||||
add hl, de
|
||||
ld a, [hli]
|
||||
@ -34,17 +34,20 @@ VBlank::
|
||||
pop af
|
||||
reti
|
||||
|
||||
.VBlanks:
|
||||
dw VBlank0
|
||||
dw VBlank1
|
||||
dw VBlank2
|
||||
dw VBlank3
|
||||
dw VBlank4
|
||||
dw VBlank5
|
||||
dw VBlank6
|
||||
dw VBlank0 ; just in case
|
||||
VBlankHandlers:
|
||||
; entries correspond to VBLANK_* constants (see constants/wram_constants.asm)
|
||||
table_width 2, VBlankHandlers
|
||||
dw VBlank_Normal
|
||||
dw VBlank_Cutscene
|
||||
dw VBlank_SoundOnly
|
||||
dw VBlank_CutsceneCGB
|
||||
dw VBlank_Serial
|
||||
dw VBlank_Credits
|
||||
dw VBlank_DMATransfer
|
||||
dw VBlank_Normal ; unused
|
||||
assert_table_length NUM_VBLANK_HANDLERS
|
||||
|
||||
VBlank0::
|
||||
VBlank_Normal::
|
||||
; normal operation
|
||||
|
||||
; rng
|
||||
@ -144,7 +147,7 @@ VBlank0::
|
||||
|
||||
ret
|
||||
|
||||
VBlank2::
|
||||
VBlank_SoundOnly::
|
||||
; sound only
|
||||
|
||||
ldh a, [hROMBank]
|
||||
@ -161,7 +164,7 @@ VBlank2::
|
||||
ld [wVBlankOccurred], a
|
||||
ret
|
||||
|
||||
VBlank1::
|
||||
VBlank_Cutscene::
|
||||
; scx, scy
|
||||
; palettes
|
||||
; bg map
|
||||
@ -245,7 +248,7 @@ UpdatePals::
|
||||
and a
|
||||
ret
|
||||
|
||||
VBlank3::
|
||||
VBlank_CutsceneCGB::
|
||||
; scx, scy
|
||||
; palettes
|
||||
; bg map
|
||||
@ -309,7 +312,7 @@ VBlank3::
|
||||
ldh [rIF], a
|
||||
ret
|
||||
|
||||
VBlank4::
|
||||
VBlank_Serial::
|
||||
; bg map
|
||||
; tiles
|
||||
; oam
|
||||
@ -340,13 +343,12 @@ VBlank4::
|
||||
rst Bankswitch
|
||||
ret
|
||||
|
||||
VBlank5::
|
||||
VBlank_Credits::
|
||||
; scx
|
||||
; palettes
|
||||
; bg map
|
||||
; tiles
|
||||
; joypad
|
||||
;
|
||||
|
||||
ldh a, [hROMBank]
|
||||
ldh [hROMBankBackup], a
|
||||
@ -388,7 +390,7 @@ VBlank5::
|
||||
ldh [rIE], a
|
||||
ret
|
||||
|
||||
VBlank6::
|
||||
VBlank_DMATransfer::
|
||||
; palettes
|
||||
; tiles
|
||||
; dma transfer
|
||||
|
@ -94,6 +94,7 @@ DisableMobile:
|
||||
xor a
|
||||
ldh [hMobileReceive], a
|
||||
ldh [hMobile], a
|
||||
assert VBLANK_NORMAL == 0
|
||||
xor a
|
||||
ldh [hVBlank], a
|
||||
call NormalSpeed
|
||||
@ -1378,7 +1379,7 @@ Function1008e0:
|
||||
push bc
|
||||
xor a
|
||||
ldh [hBGMapMode], a
|
||||
ld a, $03
|
||||
ld a, VBLANK_CUTSCENE_CGB
|
||||
ldh [hVBlank], a
|
||||
call Function100970
|
||||
call Function100902
|
||||
|
Loading…
Reference in New Issue
Block a user