123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- VBlank::
- push af
- push bc
- push de
- push hl
- ld a, [H_LOADEDROMBANK]
- ld [wVBlankSavedROMBank], a
- ld a, [hSCX]
- ld [rSCX], a
- ld a, [hSCY]
- ld [rSCY], a
- ld a, [wDisableVBlankWYUpdate]
- and a
- jr nz, .ok
- ld a, [hWY]
- ld [rWY], a
- .ok
- call AutoBgMapTransfer
- call VBlankCopyBgMap
- call RedrawRowOrColumn
- call VBlankCopy
- call VBlankCopyDouble
- call UpdateMovingBgTiles
- call $ff80 ; hOAMDMA
- ld a, BANK(PrepareOAMData)
- ld [H_LOADEDROMBANK], a
- ld [MBC1RomBank], a
- call PrepareOAMData
- ; VBlank-sensitive operations end.
- call Random
- ld a, [H_VBLANKOCCURRED]
- and a
- jr z, .skipZeroing
- xor a
- ld [H_VBLANKOCCURRED], a
- .skipZeroing
- ld a, [H_FRAMECOUNTER]
- and a
- jr z, .skipDec
- dec a
- ld [H_FRAMECOUNTER], a
- .skipDec
- call FadeOutAudio
- ld a, [wAudioROMBank] ; music ROM bank
- ld [H_LOADEDROMBANK], a
- ld [MBC1RomBank], a
- cp BANK(Audio1_UpdateMusic)
- jr nz, .checkForAudio2
- .audio1
- call Audio1_UpdateMusic
- jr .afterMusic
- .checkForAudio2
- cp BANK(Audio2_UpdateMusic)
- jr nz, .audio3
- .audio2
- call Music_DoLowHealthAlarm
- call Audio2_UpdateMusic
- jr .afterMusic
- .audio3
- call Audio3_UpdateMusic
- .afterMusic
- callba TrackPlayTime ; keep track of time played
- ld a, [hDisableJoypadPolling]
- and a
- call z, ReadJoypad
- ld a, [wVBlankSavedROMBank]
- ld [H_LOADEDROMBANK], a
- ld [MBC1RomBank], a
- pop hl
- pop de
- pop bc
- pop af
- reti
- DelayFrame::
- ; Wait for the next vblank interrupt.
- ; As a bonus, this saves battery.
- NOT_VBLANKED EQU 1
- ld a, NOT_VBLANKED
- ld [H_VBLANKOCCURRED], a
- .halt
- halt
- ld a, [H_VBLANKOCCURRED]
- and a
- jr nz, .halt
- ret
|