2013-02-05 20:33:57 +00:00
|
|
|
; VBlank is the interrupt responsible for updating VRAM.
|
|
|
|
|
|
|
|
; In Pokemon Crystal, VBlank has been hijacked to act as the
|
|
|
|
; main loop. After time-sensitive graphics operations have been
|
|
|
|
; performed, joypad input and sound functions are executed.
|
|
|
|
|
|
|
|
; This prevents the display and audio output from lagging.
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
VBlank::
|
2013-02-05 20:33:57 +00:00
|
|
|
push af
|
|
|
|
push bc
|
|
|
|
push de
|
|
|
|
push hl
|
2015-01-20 05:31:29 +00:00
|
|
|
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh a, [hVBlank]
|
2015-01-20 05:31:29 +00:00
|
|
|
and 7
|
|
|
|
|
2013-02-05 20:33:57 +00:00
|
|
|
ld e, a
|
2015-01-20 05:31:29 +00:00
|
|
|
ld d, 0
|
2013-02-05 20:33:57 +00:00
|
|
|
ld hl, .VBlanks
|
|
|
|
add hl, de
|
2016-05-04 15:46:23 +00:00
|
|
|
add hl, de
|
2013-02-05 20:33:57 +00:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
2015-01-20 05:31:29 +00:00
|
|
|
|
2013-08-27 22:16:42 +00:00
|
|
|
call _hl_
|
2015-01-20 05:31:29 +00:00
|
|
|
|
2013-02-05 20:33:57 +00:00
|
|
|
call GameTimer
|
2015-01-20 05:31:29 +00:00
|
|
|
|
2013-02-05 20:33:57 +00:00
|
|
|
pop hl
|
|
|
|
pop de
|
|
|
|
pop bc
|
|
|
|
pop af
|
|
|
|
reti
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.VBlanks:
|
2015-01-20 05:31:29 +00:00
|
|
|
dw VBlank0
|
|
|
|
dw VBlank1
|
|
|
|
dw VBlank2
|
|
|
|
dw VBlank3
|
|
|
|
dw VBlank4
|
|
|
|
dw VBlank5
|
|
|
|
dw VBlank6
|
|
|
|
dw VBlank0 ; just in case
|
2013-02-05 20:33:57 +00:00
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
VBlank0::
|
2013-02-05 20:33:57 +00:00
|
|
|
; normal operation
|
|
|
|
|
|
|
|
; rng
|
|
|
|
; scx, scy, wy, wx
|
|
|
|
; bg map buffer
|
|
|
|
; palettes
|
|
|
|
; dma transfer
|
|
|
|
; bg map
|
|
|
|
; tiles
|
|
|
|
; oam
|
|
|
|
; joypad
|
|
|
|
; sound
|
|
|
|
|
2015-01-20 05:31:29 +00:00
|
|
|
; inc frame counter
|
2015-11-10 04:01:45 +00:00
|
|
|
ld hl, hVBlankCounter
|
2013-02-05 20:33:57 +00:00
|
|
|
inc [hl]
|
2015-01-20 05:31:29 +00:00
|
|
|
|
|
|
|
; advance random variables
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh a, [rDIV]
|
2013-02-05 20:33:57 +00:00
|
|
|
ld b, a
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh a, [hRandomAdd]
|
2013-02-05 20:33:57 +00:00
|
|
|
adc b
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [hRandomAdd], a
|
2015-01-20 05:31:29 +00:00
|
|
|
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh a, [rDIV]
|
2013-02-05 20:33:57 +00:00
|
|
|
ld b, a
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh a, [hRandomSub]
|
2013-02-05 20:33:57 +00:00
|
|
|
sbc b
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [hRandomSub], a
|
2015-01-20 05:31:29 +00:00
|
|
|
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh a, [hROMBank]
|
|
|
|
ldh [hROMBankBackup], a
|
2015-01-20 05:31:29 +00:00
|
|
|
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh a, [hSCX]
|
|
|
|
ldh [rSCX], a
|
|
|
|
ldh a, [hSCY]
|
|
|
|
ldh [rSCY], a
|
|
|
|
ldh a, [hWY]
|
|
|
|
ldh [rWY], a
|
|
|
|
ldh a, [hWX]
|
|
|
|
ldh [rWX], a
|
2015-01-20 05:31:29 +00:00
|
|
|
|
|
|
|
; There's only time to call one of these in one vblank.
|
|
|
|
; Calls are in order of priority.
|
|
|
|
|
2013-02-05 20:33:57 +00:00
|
|
|
call UpdateBGMapBuffer
|
2015-01-20 05:31:29 +00:00
|
|
|
jr c, .done
|
2013-02-05 20:33:57 +00:00
|
|
|
call UpdatePalsIfCGB
|
2015-01-20 05:31:29 +00:00
|
|
|
jr c, .done
|
2013-02-05 20:33:57 +00:00
|
|
|
call DMATransfer
|
2015-01-20 05:31:29 +00:00
|
|
|
jr c, .done
|
2013-02-05 20:33:57 +00:00
|
|
|
call UpdateBGMap
|
2015-01-20 05:31:29 +00:00
|
|
|
|
|
|
|
; These have their own timing checks.
|
|
|
|
|
2013-09-01 04:02:35 +00:00
|
|
|
call Serve2bppRequest
|
|
|
|
call Serve1bppRequest
|
2013-09-01 04:07:10 +00:00
|
|
|
call AnimateTileset
|
2015-01-20 05:31:29 +00:00
|
|
|
|
|
|
|
.done
|
|
|
|
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh a, [hOAMUpdate]
|
2013-02-05 20:33:57 +00:00
|
|
|
and a
|
2015-01-20 05:31:29 +00:00
|
|
|
jr nz, .done_oam
|
2022-07-09 21:18:22 +00:00
|
|
|
call hTransferShadowOAM
|
2015-01-20 05:31:29 +00:00
|
|
|
.done_oam
|
|
|
|
|
|
|
|
; vblank-sensitive operations are done
|
|
|
|
|
2013-02-05 20:33:57 +00:00
|
|
|
xor a
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wVBlankOccurred], a
|
2015-01-20 05:31:29 +00:00
|
|
|
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wOverworldDelay]
|
2013-02-05 20:33:57 +00:00
|
|
|
and a
|
2015-01-20 05:31:29 +00:00
|
|
|
jr z, .ok
|
2013-02-05 20:33:57 +00:00
|
|
|
dec a
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wOverworldDelay], a
|
2015-01-20 05:31:29 +00:00
|
|
|
.ok
|
|
|
|
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wTextDelayFrames]
|
2013-02-05 20:33:57 +00:00
|
|
|
and a
|
2015-01-20 05:31:29 +00:00
|
|
|
jr z, .ok2
|
2013-02-05 20:33:57 +00:00
|
|
|
dec a
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wTextDelayFrames], a
|
2015-01-20 05:31:29 +00:00
|
|
|
.ok2
|
|
|
|
|
2020-02-23 13:33:53 +00:00
|
|
|
call UpdateJoypad
|
2015-01-20 05:31:29 +00:00
|
|
|
|
2013-10-11 06:49:08 +00:00
|
|
|
ld a, BANK(_UpdateSound)
|
2015-01-20 05:31:29 +00:00
|
|
|
rst Bankswitch
|
2013-10-11 06:49:08 +00:00
|
|
|
call _UpdateSound
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh a, [hROMBankBackup]
|
2015-01-20 05:31:29 +00:00
|
|
|
rst Bankswitch
|
|
|
|
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh a, [hSeconds]
|
2020-04-04 19:38:44 +00:00
|
|
|
ldh [hUnusedBackup], a
|
2015-01-20 05:31:29 +00:00
|
|
|
|
2013-02-05 20:33:57 +00:00
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
VBlank2::
|
2013-02-05 20:33:57 +00:00
|
|
|
; sound only
|
|
|
|
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh a, [hROMBank]
|
|
|
|
ldh [hROMBankBackup], a
|
2015-01-20 05:31:29 +00:00
|
|
|
|
2013-10-11 06:49:08 +00:00
|
|
|
ld a, BANK(_UpdateSound)
|
2015-01-20 05:31:29 +00:00
|
|
|
rst Bankswitch
|
2013-10-11 06:49:08 +00:00
|
|
|
call _UpdateSound
|
2015-01-20 05:31:29 +00:00
|
|
|
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh a, [hROMBankBackup]
|
2013-02-05 20:33:57 +00:00
|
|
|
rst Bankswitch
|
2015-01-20 05:31:29 +00:00
|
|
|
|
2013-02-05 20:33:57 +00:00
|
|
|
xor a
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wVBlankOccurred], a
|
2013-02-05 20:33:57 +00:00
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
VBlank1::
|
2013-02-05 20:33:57 +00:00
|
|
|
; scx, scy
|
|
|
|
; palettes
|
|
|
|
; bg map
|
|
|
|
; tiles
|
|
|
|
; oam
|
|
|
|
; sound / lcd stat
|
|
|
|
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh a, [hROMBank]
|
|
|
|
ldh [hROMBankBackup], a
|
2015-01-20 05:31:29 +00:00
|
|
|
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh a, [hSCX]
|
|
|
|
ldh [rSCX], a
|
|
|
|
ldh a, [hSCY]
|
|
|
|
ldh [rSCY], a
|
2015-01-20 05:31:29 +00:00
|
|
|
|
2013-02-05 20:33:57 +00:00
|
|
|
call UpdatePals
|
2015-01-20 05:31:29 +00:00
|
|
|
jr c, .done
|
|
|
|
|
2013-02-05 20:33:57 +00:00
|
|
|
call UpdateBGMap
|
2018-01-03 20:28:13 +00:00
|
|
|
call Serve2bppRequest_VBlank
|
2015-01-20 05:31:29 +00:00
|
|
|
|
2022-07-09 21:18:22 +00:00
|
|
|
call hTransferShadowOAM
|
2015-01-20 05:31:29 +00:00
|
|
|
|
2020-06-16 19:49:32 +00:00
|
|
|
.done
|
2013-02-05 20:33:57 +00:00
|
|
|
xor a
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wVBlankOccurred], a
|
2015-01-20 05:31:29 +00:00
|
|
|
|
|
|
|
; get requested ints
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh a, [rIF]
|
2013-02-05 20:33:57 +00:00
|
|
|
ld b, a
|
2015-01-20 05:31:29 +00:00
|
|
|
; discard requested ints
|
2013-02-05 20:33:57 +00:00
|
|
|
xor a
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [rIF], a
|
2015-01-20 05:31:29 +00:00
|
|
|
; enable lcd stat
|
2019-05-05 16:14:46 +00:00
|
|
|
ld a, 1 << LCD_STAT
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [rIE], a
|
2015-01-20 05:31:29 +00:00
|
|
|
; rerequest serial int if applicable (still disabled)
|
|
|
|
; request lcd stat
|
2013-02-05 20:33:57 +00:00
|
|
|
ld a, b
|
2019-05-05 16:14:46 +00:00
|
|
|
and 1 << SERIAL
|
|
|
|
or 1 << LCD_STAT
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [rIF], a
|
2015-01-20 05:31:29 +00:00
|
|
|
|
2013-02-05 20:33:57 +00:00
|
|
|
ei
|
2013-10-11 06:49:08 +00:00
|
|
|
ld a, BANK(_UpdateSound)
|
2015-01-20 05:31:29 +00:00
|
|
|
rst Bankswitch
|
2013-10-11 06:49:08 +00:00
|
|
|
call _UpdateSound
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh a, [hROMBankBackup]
|
2013-02-05 20:33:57 +00:00
|
|
|
rst Bankswitch
|
|
|
|
di
|
2015-01-20 05:31:29 +00:00
|
|
|
|
|
|
|
; get requested ints
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh a, [rIF]
|
2013-02-05 20:33:57 +00:00
|
|
|
ld b, a
|
2015-01-20 05:31:29 +00:00
|
|
|
; discard requested ints
|
2013-02-05 20:33:57 +00:00
|
|
|
xor a
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [rIF], a
|
2015-01-20 05:31:29 +00:00
|
|
|
; enable ints besides joypad
|
2019-05-05 16:14:46 +00:00
|
|
|
ld a, IE_DEFAULT
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [rIE], a
|
2015-01-20 05:31:29 +00:00
|
|
|
; rerequest ints
|
2013-02-05 20:33:57 +00:00
|
|
|
ld a, b
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [rIF], a
|
2013-02-05 20:33:57 +00:00
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
UpdatePals::
|
2013-02-05 20:33:57 +00:00
|
|
|
; update pals for either dmg or cgb
|
|
|
|
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh a, [hCGB]
|
2013-02-05 20:33:57 +00:00
|
|
|
and a
|
|
|
|
jp nz, UpdateCGBPals
|
2015-01-20 05:31:29 +00:00
|
|
|
|
|
|
|
; update gb pals
|
2015-12-23 19:00:29 +00:00
|
|
|
ld a, [wBGP]
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [rBGP], a
|
2015-12-23 19:00:29 +00:00
|
|
|
ld a, [wOBP0]
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [rOBP0], a
|
2015-12-23 19:00:29 +00:00
|
|
|
ld a, [wOBP1]
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [rOBP1], a
|
2015-01-20 05:31:29 +00:00
|
|
|
|
2013-02-05 20:33:57 +00:00
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
VBlank3::
|
2013-02-05 20:33:57 +00:00
|
|
|
; scx, scy
|
|
|
|
; palettes
|
|
|
|
; bg map
|
|
|
|
; tiles
|
|
|
|
; oam
|
|
|
|
; sound / lcd stat
|
|
|
|
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh a, [hROMBank]
|
|
|
|
ldh [hROMBankBackup], a
|
2015-01-20 05:31:29 +00:00
|
|
|
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh a, [hSCX]
|
|
|
|
ldh [rSCX], a
|
|
|
|
ldh a, [hSCY]
|
|
|
|
ldh [rSCY], a
|
2015-01-20 05:31:29 +00:00
|
|
|
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh a, [hCGBPalUpdate]
|
2013-02-05 20:33:57 +00:00
|
|
|
and a
|
|
|
|
call nz, ForceUpdateCGBPals
|
2015-01-20 05:31:29 +00:00
|
|
|
jr c, .done
|
|
|
|
|
2013-02-05 20:33:57 +00:00
|
|
|
call UpdateBGMap
|
2018-01-03 20:28:13 +00:00
|
|
|
call Serve2bppRequest_VBlank
|
2015-01-20 05:31:29 +00:00
|
|
|
|
2022-07-09 21:18:22 +00:00
|
|
|
call hTransferShadowOAM
|
2015-01-20 05:31:29 +00:00
|
|
|
.done
|
|
|
|
|
2013-02-05 20:33:57 +00:00
|
|
|
xor a
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wVBlankOccurred], a
|
2015-01-20 05:31:29 +00:00
|
|
|
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh a, [rIF]
|
2013-02-05 20:33:57 +00:00
|
|
|
push af
|
|
|
|
xor a
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [rIF], a
|
2019-05-05 16:14:46 +00:00
|
|
|
ld a, 1 << LCD_STAT
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [rIE], a
|
|
|
|
ldh [rIF], a
|
2015-01-20 05:31:29 +00:00
|
|
|
|
2013-02-05 20:33:57 +00:00
|
|
|
ei
|
2013-10-11 06:49:08 +00:00
|
|
|
ld a, BANK(_UpdateSound)
|
2015-01-20 05:31:29 +00:00
|
|
|
rst Bankswitch
|
2013-10-11 06:49:08 +00:00
|
|
|
call _UpdateSound
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh a, [hROMBankBackup]
|
2013-02-05 20:33:57 +00:00
|
|
|
rst Bankswitch
|
|
|
|
di
|
2015-01-20 05:31:29 +00:00
|
|
|
|
|
|
|
; request lcdstat
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh a, [rIF]
|
2013-02-05 20:33:57 +00:00
|
|
|
ld b, a
|
2015-01-20 05:31:29 +00:00
|
|
|
; and any other ints
|
2013-02-05 20:33:57 +00:00
|
|
|
pop af
|
|
|
|
or b
|
|
|
|
ld b, a
|
2015-01-20 05:31:29 +00:00
|
|
|
; reset ints
|
2013-02-05 20:33:57 +00:00
|
|
|
xor a
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [rIF], a
|
2015-01-20 05:31:29 +00:00
|
|
|
; enable ints besides joypad
|
2019-05-05 16:14:46 +00:00
|
|
|
ld a, IE_DEFAULT
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [rIE], a
|
2015-01-20 05:31:29 +00:00
|
|
|
; request ints
|
2013-02-05 20:33:57 +00:00
|
|
|
ld a, b
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [rIF], a
|
2013-02-05 20:33:57 +00:00
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
VBlank4::
|
2013-02-05 20:33:57 +00:00
|
|
|
; bg map
|
|
|
|
; tiles
|
|
|
|
; oam
|
|
|
|
; joypad
|
|
|
|
; serial
|
|
|
|
; sound
|
|
|
|
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh a, [hROMBank]
|
|
|
|
ldh [hROMBankBackup], a
|
2015-01-20 05:31:29 +00:00
|
|
|
|
2013-02-05 20:33:57 +00:00
|
|
|
call UpdateBGMap
|
2013-09-01 04:02:35 +00:00
|
|
|
call Serve2bppRequest
|
2015-01-20 05:31:29 +00:00
|
|
|
|
2022-07-09 21:18:22 +00:00
|
|
|
call hTransferShadowOAM
|
2015-01-20 05:31:29 +00:00
|
|
|
|
2020-02-23 13:33:53 +00:00
|
|
|
call UpdateJoypad
|
2015-01-20 05:31:29 +00:00
|
|
|
|
2013-02-05 20:33:57 +00:00
|
|
|
xor a
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wVBlankOccurred], a
|
2015-01-20 05:31:29 +00:00
|
|
|
|
2013-02-05 20:33:57 +00:00
|
|
|
call AskSerial
|
2015-01-20 05:31:29 +00:00
|
|
|
|
2013-10-11 06:49:08 +00:00
|
|
|
ld a, BANK(_UpdateSound)
|
2015-01-20 05:31:29 +00:00
|
|
|
rst Bankswitch
|
2013-10-11 06:49:08 +00:00
|
|
|
call _UpdateSound
|
2015-01-20 05:31:29 +00:00
|
|
|
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh a, [hROMBankBackup]
|
2013-02-05 20:33:57 +00:00
|
|
|
rst Bankswitch
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
VBlank5::
|
2013-02-05 20:33:57 +00:00
|
|
|
; scx
|
|
|
|
; palettes
|
|
|
|
; bg map
|
|
|
|
; tiles
|
|
|
|
; joypad
|
2015-07-19 03:45:39 +00:00
|
|
|
;
|
2013-02-05 20:33:57 +00:00
|
|
|
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh a, [hROMBank]
|
|
|
|
ldh [hROMBankBackup], a
|
2015-01-20 05:31:29 +00:00
|
|
|
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh a, [hSCX]
|
|
|
|
ldh [rSCX], a
|
2015-01-20 05:31:29 +00:00
|
|
|
|
2013-02-05 20:33:57 +00:00
|
|
|
call UpdatePalsIfCGB
|
2015-01-20 05:31:29 +00:00
|
|
|
jr c, .done
|
|
|
|
|
2013-02-05 20:33:57 +00:00
|
|
|
call UpdateBGMap
|
2013-09-01 04:02:35 +00:00
|
|
|
call Serve2bppRequest
|
2015-01-20 05:31:29 +00:00
|
|
|
.done
|
|
|
|
|
2013-02-05 20:33:57 +00:00
|
|
|
xor a
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wVBlankOccurred], a
|
2015-01-20 05:31:29 +00:00
|
|
|
|
2020-02-23 13:33:53 +00:00
|
|
|
call UpdateJoypad
|
2015-01-20 05:31:29 +00:00
|
|
|
|
2013-02-05 20:33:57 +00:00
|
|
|
xor a
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [rIF], a
|
2019-05-05 16:14:46 +00:00
|
|
|
ld a, 1 << LCD_STAT
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [rIE], a
|
2015-01-20 05:31:29 +00:00
|
|
|
; request lcd stat
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [rIF], a
|
2015-01-20 05:31:29 +00:00
|
|
|
|
2013-02-05 20:33:57 +00:00
|
|
|
ei
|
2013-10-11 06:49:08 +00:00
|
|
|
ld a, BANK(_UpdateSound)
|
2015-01-20 05:31:29 +00:00
|
|
|
rst Bankswitch
|
2013-10-11 06:49:08 +00:00
|
|
|
call _UpdateSound
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh a, [hROMBankBackup]
|
2013-02-05 20:33:57 +00:00
|
|
|
rst Bankswitch
|
|
|
|
di
|
2015-01-20 05:31:29 +00:00
|
|
|
|
2013-02-05 20:33:57 +00:00
|
|
|
xor a
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [rIF], a
|
2015-01-20 05:31:29 +00:00
|
|
|
; enable ints besides joypad
|
2019-05-05 16:14:46 +00:00
|
|
|
ld a, IE_DEFAULT
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [rIE], a
|
2013-02-05 20:33:57 +00:00
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
VBlank6::
|
2013-02-05 20:33:57 +00:00
|
|
|
; palettes
|
|
|
|
; tiles
|
|
|
|
; dma transfer
|
|
|
|
; sound
|
|
|
|
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh a, [hROMBank]
|
|
|
|
ldh [hROMBankBackup], a
|
2015-01-20 05:31:29 +00:00
|
|
|
|
|
|
|
; inc frame counter
|
2015-11-10 04:01:45 +00:00
|
|
|
ld hl, hVBlankCounter
|
2013-02-05 20:33:57 +00:00
|
|
|
inc [hl]
|
2015-01-20 05:31:29 +00:00
|
|
|
|
2013-02-05 20:33:57 +00:00
|
|
|
call UpdateCGBPals
|
2015-01-20 05:31:29 +00:00
|
|
|
jr c, .done
|
|
|
|
|
2013-09-01 04:02:35 +00:00
|
|
|
call Serve2bppRequest
|
|
|
|
call Serve1bppRequest
|
2013-02-05 20:33:57 +00:00
|
|
|
call DMATransfer
|
2015-01-20 05:31:29 +00:00
|
|
|
.done
|
|
|
|
|
2013-02-05 20:33:57 +00:00
|
|
|
xor a
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wVBlankOccurred], a
|
2015-01-20 05:31:29 +00:00
|
|
|
|
2013-10-11 06:49:08 +00:00
|
|
|
ld a, BANK(_UpdateSound)
|
2015-01-20 05:31:29 +00:00
|
|
|
rst Bankswitch
|
2013-10-11 06:49:08 +00:00
|
|
|
call _UpdateSound
|
2015-01-20 05:31:29 +00:00
|
|
|
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh a, [hROMBankBackup]
|
2013-02-05 20:33:57 +00:00
|
|
|
rst Bankswitch
|
|
|
|
ret
|