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.
|
|
|
|
|
2013-08-29 23:40:33 +00:00
|
|
|
|
2014-02-02 01:26:39 +00:00
|
|
|
VBlank:: ; 283
|
2013-02-05 20:33:57 +00:00
|
|
|
push af
|
|
|
|
push bc
|
|
|
|
push de
|
|
|
|
push hl
|
2015-01-20 05:31:29 +00:00
|
|
|
|
|
|
|
ld a, [hVBlank]
|
|
|
|
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
|
2015-07-21 02:18:18 +00:00
|
|
|
rept 2
|
2013-02-05 20:33:57 +00:00
|
|
|
add hl, de
|
2015-07-21 02:18:18 +00:00
|
|
|
endr
|
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
|
|
|
|
; 2a1
|
|
|
|
|
|
|
|
.VBlanks ; 2a1
|
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
|
|
|
; 2b1
|
|
|
|
|
|
|
|
|
2014-02-02 01:26:39 +00:00
|
|
|
VBlank0:: ; 2b1
|
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
|
2013-02-20 07:46:40 +00:00
|
|
|
ld a, [rDIV]
|
2013-02-05 20:33:57 +00:00
|
|
|
ld b, a
|
2013-08-20 00:49:16 +00:00
|
|
|
ld a, [hRandomAdd]
|
2013-02-05 20:33:57 +00:00
|
|
|
adc b
|
2013-08-20 00:49:16 +00:00
|
|
|
ld [hRandomAdd], a
|
2015-01-20 05:31:29 +00:00
|
|
|
|
2013-02-20 07:46:40 +00:00
|
|
|
ld a, [rDIV]
|
2013-02-05 20:33:57 +00:00
|
|
|
ld b, a
|
2013-08-20 00:49:16 +00:00
|
|
|
ld a, [hRandomSub]
|
2013-02-05 20:33:57 +00:00
|
|
|
sbc b
|
2013-08-20 00:49:16 +00:00
|
|
|
ld [hRandomSub], a
|
2015-01-20 05:31:29 +00:00
|
|
|
|
|
|
|
ld a, [hROMBank]
|
|
|
|
ld [hROMBankBackup], a
|
|
|
|
|
2013-08-19 22:46:56 +00:00
|
|
|
ld a, [hSCX]
|
2013-02-20 07:46:40 +00:00
|
|
|
ld [rSCX], a
|
2013-08-19 22:46:56 +00:00
|
|
|
ld a, [hSCY]
|
2013-02-20 07:46:40 +00:00
|
|
|
ld [rSCY], a
|
2013-08-19 22:42:26 +00:00
|
|
|
ld a, [hWY]
|
2013-02-20 07:46:40 +00:00
|
|
|
ld [rWY], a
|
2013-08-19 22:42:26 +00:00
|
|
|
ld a, [hWX]
|
2013-02-20 07:46:40 +00:00
|
|
|
ld [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
|
|
|
|
|
2013-08-20 00:49:16 +00:00
|
|
|
ld a, [hOAMUpdate]
|
2013-02-05 20:33:57 +00:00
|
|
|
and a
|
2015-01-20 05:31:29 +00:00
|
|
|
jr nz, .done_oam
|
2013-03-21 02:55:09 +00:00
|
|
|
call hPushOAM
|
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
|
|
|
|
ld [VBlankOccurred], a
|
2015-01-20 05:31:29 +00:00
|
|
|
|
2013-07-20 05:25:20 +00:00
|
|
|
ld a, [OverworldDelay]
|
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
|
2013-07-20 05:25:20 +00:00
|
|
|
ld [OverworldDelay], a
|
2015-01-20 05:31:29 +00:00
|
|
|
.ok
|
|
|
|
|
2013-02-05 20:33:57 +00:00
|
|
|
ld a, [TextDelayFrames]
|
|
|
|
and a
|
2015-01-20 05:31:29 +00:00
|
|
|
jr z, .ok2
|
2013-02-05 20:33:57 +00:00
|
|
|
dec a
|
|
|
|
ld [TextDelayFrames], a
|
2015-01-20 05:31:29 +00:00
|
|
|
.ok2
|
|
|
|
|
2013-02-05 20:33:57 +00:00
|
|
|
call Joypad
|
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
|
|
|
ld a, [hROMBankBackup]
|
|
|
|
rst Bankswitch
|
|
|
|
|
2013-08-20 00:49:16 +00:00
|
|
|
ld a, [hSeconds]
|
2015-10-16 17:35:43 +00:00
|
|
|
ld [hSecondsBackup], a
|
2015-01-20 05:31:29 +00:00
|
|
|
|
2013-02-05 20:33:57 +00:00
|
|
|
ret
|
|
|
|
; 325
|
|
|
|
|
|
|
|
|
2014-02-02 01:26:39 +00:00
|
|
|
VBlank2:: ; 325
|
2013-02-05 20:33:57 +00:00
|
|
|
; sound only
|
|
|
|
|
2013-08-20 00:49:16 +00:00
|
|
|
ld a, [hROMBank]
|
2015-01-20 05:31:29 +00:00
|
|
|
ld [hROMBankBackup], a
|
|
|
|
|
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
|
|
|
|
|
|
|
ld 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
|
|
|
|
ld [VBlankOccurred], a
|
|
|
|
ret
|
|
|
|
; 337
|
|
|
|
|
|
|
|
|
2014-02-02 01:26:39 +00:00
|
|
|
VBlank1:: ; 337
|
2013-02-05 20:33:57 +00:00
|
|
|
; scx, scy
|
|
|
|
; palettes
|
|
|
|
; bg map
|
|
|
|
; tiles
|
|
|
|
; oam
|
|
|
|
; sound / lcd stat
|
|
|
|
|
2013-08-20 00:49:16 +00:00
|
|
|
ld a, [hROMBank]
|
2015-01-20 05:31:29 +00:00
|
|
|
ld [hROMBankBackup], a
|
|
|
|
|
2013-08-19 22:46:56 +00:00
|
|
|
ld a, [hSCX]
|
2013-02-20 07:46:40 +00:00
|
|
|
ld [rSCX], a
|
2013-08-19 22:46:56 +00:00
|
|
|
ld a, [hSCY]
|
2013-02-20 07:46:40 +00:00
|
|
|
ld [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
|
2013-09-01 04:02:35 +00:00
|
|
|
call Serve2bppRequest@VBlank
|
2015-01-20 05:31:29 +00:00
|
|
|
|
2013-03-21 02:55:09 +00:00
|
|
|
call hPushOAM
|
2015-01-20 05:31:29 +00:00
|
|
|
.done
|
|
|
|
|
2013-02-05 20:33:57 +00:00
|
|
|
xor a
|
|
|
|
ld [VBlankOccurred], a
|
2015-01-20 05:31:29 +00:00
|
|
|
|
|
|
|
; get requested ints
|
2013-02-20 07:46:40 +00:00
|
|
|
ld 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
|
2013-02-20 07:46:40 +00:00
|
|
|
ld [rIF], a
|
2015-01-20 05:31:29 +00:00
|
|
|
; enable lcd stat
|
2013-02-05 20:33:57 +00:00
|
|
|
ld a, %10 ; lcd stat
|
2013-02-20 07:46:40 +00:00
|
|
|
ld [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
|
|
|
|
and %1000 ; serial
|
|
|
|
or %10 ; lcd stat
|
2013-02-20 07:46:40 +00:00
|
|
|
ld [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
|
2015-01-20 05:31:29 +00:00
|
|
|
ld a, [hROMBankBackup]
|
2013-02-05 20:33:57 +00:00
|
|
|
rst Bankswitch
|
|
|
|
di
|
2015-01-20 05:31:29 +00:00
|
|
|
|
|
|
|
; get requested ints
|
2013-02-20 07:46:40 +00:00
|
|
|
ld 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
|
2013-02-20 07:46:40 +00:00
|
|
|
ld [rIF], a
|
2015-01-20 05:31:29 +00:00
|
|
|
; enable ints besides joypad
|
2013-02-05 20:33:57 +00:00
|
|
|
ld a, %1111 ; serial timer lcdstat vblank
|
2013-02-20 07:46:40 +00:00
|
|
|
ld [rIE], a
|
2015-01-20 05:31:29 +00:00
|
|
|
; rerequest ints
|
2013-02-05 20:33:57 +00:00
|
|
|
ld a, b
|
2013-02-20 07:46:40 +00:00
|
|
|
ld [rIF], a
|
2013-02-05 20:33:57 +00:00
|
|
|
ret
|
|
|
|
; 37f
|
|
|
|
|
|
|
|
|
2014-02-02 01:26:39 +00:00
|
|
|
UpdatePals:: ; 37f
|
2013-02-05 20:33:57 +00:00
|
|
|
; update pals for either dmg or cgb
|
|
|
|
|
2013-08-20 00:49:16 +00:00
|
|
|
ld 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-02-10 23:14:41 +00:00
|
|
|
ld a, [wcfc7]
|
2013-02-20 07:46:40 +00:00
|
|
|
ld [rBGP], a
|
2015-02-10 23:14:41 +00:00
|
|
|
ld a, [wcfc8]
|
2013-02-20 07:46:40 +00:00
|
|
|
ld [rOBP0], a
|
2015-02-10 23:14:41 +00:00
|
|
|
ld a, [wcfc9]
|
2013-02-20 07:46:40 +00:00
|
|
|
ld [rOBP1], a
|
2015-01-20 05:31:29 +00:00
|
|
|
|
2013-02-05 20:33:57 +00:00
|
|
|
and a
|
|
|
|
ret
|
|
|
|
; 396
|
|
|
|
|
|
|
|
|
2014-02-02 01:26:39 +00:00
|
|
|
VBlank3:: ; 396
|
2013-02-05 20:33:57 +00:00
|
|
|
; scx, scy
|
|
|
|
; palettes
|
|
|
|
; bg map
|
|
|
|
; tiles
|
|
|
|
; oam
|
|
|
|
; sound / lcd stat
|
|
|
|
|
2013-08-20 00:49:16 +00:00
|
|
|
ld a, [hROMBank]
|
2015-01-20 05:31:29 +00:00
|
|
|
ld [hROMBankBackup], a
|
|
|
|
|
2013-08-19 22:46:56 +00:00
|
|
|
ld a, [hSCX]
|
2013-02-20 07:46:40 +00:00
|
|
|
ld [rSCX], a
|
2013-08-19 22:46:56 +00:00
|
|
|
ld a, [hSCY]
|
2013-02-20 07:46:40 +00:00
|
|
|
ld [rSCY], a
|
2015-01-20 05:31:29 +00:00
|
|
|
|
2013-08-20 00:49:16 +00:00
|
|
|
ld 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
|
2013-09-01 04:02:35 +00:00
|
|
|
call Serve2bppRequest@VBlank
|
2015-01-20 05:31:29 +00:00
|
|
|
|
2013-03-21 02:55:09 +00:00
|
|
|
call hPushOAM
|
2015-01-20 05:31:29 +00:00
|
|
|
.done
|
|
|
|
|
2013-02-05 20:33:57 +00:00
|
|
|
xor a
|
|
|
|
ld [VBlankOccurred], a
|
2015-01-20 05:31:29 +00:00
|
|
|
|
2013-02-20 07:46:40 +00:00
|
|
|
ld a, [rIF]
|
2013-02-05 20:33:57 +00:00
|
|
|
push af
|
|
|
|
xor a
|
2013-02-20 07:46:40 +00:00
|
|
|
ld [rIF], a
|
2013-02-05 20:33:57 +00:00
|
|
|
ld a, %10 ; lcd stat
|
2013-02-20 07:46:40 +00:00
|
|
|
ld [rIE], a
|
|
|
|
ld [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
|
2015-01-20 05:31:29 +00:00
|
|
|
ld a, [hROMBankBackup]
|
2013-02-05 20:33:57 +00:00
|
|
|
rst Bankswitch
|
|
|
|
di
|
2015-01-20 05:31:29 +00:00
|
|
|
|
|
|
|
; request lcdstat
|
2013-02-20 07:46:40 +00:00
|
|
|
ld 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
|
2013-02-20 07:46:40 +00:00
|
|
|
ld [rIF], a
|
2015-01-20 05:31:29 +00:00
|
|
|
; enable ints besides joypad
|
2013-02-05 20:33:57 +00:00
|
|
|
ld a, %1111 ; serial timer lcdstat vblank
|
2013-02-20 07:46:40 +00:00
|
|
|
ld [rIE], a
|
2015-01-20 05:31:29 +00:00
|
|
|
; request ints
|
2013-02-05 20:33:57 +00:00
|
|
|
ld a, b
|
2013-02-20 07:46:40 +00:00
|
|
|
ld [rIF], a
|
2013-02-05 20:33:57 +00:00
|
|
|
ret
|
|
|
|
; 3df
|
|
|
|
|
|
|
|
|
2014-02-02 01:26:39 +00:00
|
|
|
VBlank4:: ; 3df
|
2013-02-05 20:33:57 +00:00
|
|
|
; bg map
|
|
|
|
; tiles
|
|
|
|
; oam
|
|
|
|
; joypad
|
|
|
|
; serial
|
|
|
|
; sound
|
|
|
|
|
2013-08-20 00:49:16 +00:00
|
|
|
ld a, [hROMBank]
|
2015-01-20 05:31:29 +00:00
|
|
|
ld [hROMBankBackup], a
|
|
|
|
|
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
|
|
|
|
2013-03-21 02:55:09 +00:00
|
|
|
call hPushOAM
|
2015-01-20 05:31:29 +00:00
|
|
|
|
2013-02-05 20:33:57 +00:00
|
|
|
call Joypad
|
2015-01-20 05:31:29 +00:00
|
|
|
|
2013-02-05 20:33:57 +00:00
|
|
|
xor a
|
|
|
|
ld [VBlankOccurred], 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
|
|
|
|
|
|
|
ld a, [hROMBankBackup]
|
2013-02-05 20:33:57 +00:00
|
|
|
rst Bankswitch
|
|
|
|
ret
|
|
|
|
; 400
|
|
|
|
|
|
|
|
|
2014-02-02 01:26:39 +00:00
|
|
|
VBlank5:: ; 400
|
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
|
|
|
|
2013-08-20 00:49:16 +00:00
|
|
|
ld a, [hROMBank]
|
2015-01-20 05:31:29 +00:00
|
|
|
ld [hROMBankBackup], a
|
|
|
|
|
2013-08-19 22:46:56 +00:00
|
|
|
ld a, [hSCX]
|
2013-02-20 07:46:40 +00:00
|
|
|
ld [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
|
|
|
|
ld [VBlankOccurred], a
|
2015-01-20 05:31:29 +00:00
|
|
|
|
2013-02-05 20:33:57 +00:00
|
|
|
call Joypad
|
2015-01-20 05:31:29 +00:00
|
|
|
|
2013-02-05 20:33:57 +00:00
|
|
|
xor a
|
2013-02-20 07:46:40 +00:00
|
|
|
ld [rIF], a
|
2013-02-05 20:33:57 +00:00
|
|
|
ld a, %10 ; lcd stat
|
2013-02-20 07:46:40 +00:00
|
|
|
ld [rIE], a
|
2015-01-20 05:31:29 +00:00
|
|
|
; request lcd stat
|
2013-02-20 07:46:40 +00:00
|
|
|
ld [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
|
2015-01-20 05:31:29 +00:00
|
|
|
ld 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
|
2013-02-20 07:46:40 +00:00
|
|
|
ld [rIF], a
|
2015-01-20 05:31:29 +00:00
|
|
|
; enable ints besides joypad
|
2013-02-05 20:33:57 +00:00
|
|
|
ld a, %1111 ; serial timer lcdstat vblank
|
2013-02-20 07:46:40 +00:00
|
|
|
ld [rIE], a
|
2013-02-05 20:33:57 +00:00
|
|
|
ret
|
|
|
|
; 436
|
|
|
|
|
|
|
|
|
2014-02-02 01:26:39 +00:00
|
|
|
VBlank6:: ; 436
|
2013-02-05 20:33:57 +00:00
|
|
|
; palettes
|
|
|
|
; tiles
|
|
|
|
; dma transfer
|
|
|
|
; sound
|
|
|
|
|
2013-08-20 00:49:16 +00:00
|
|
|
ld a, [hROMBank]
|
2015-01-20 05:31:29 +00:00
|
|
|
ld [hROMBankBackup], a
|
|
|
|
|
|
|
|
; 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
|
|
|
|
ld [VBlankOccurred], 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
|
|
|
|
|
|
|
ld a, [hROMBankBackup]
|
2013-02-05 20:33:57 +00:00
|
|
|
rst Bankswitch
|
|
|
|
ret
|
|
|
|
; 45a
|