Window HUD: Prevent more Window flickering in blocks that disable interrupts (#15)

This commit is contained in:
xCrystal
2023-08-28 17:31:39 +02:00
parent fd6f02036e
commit f289d5621d
8 changed files with 71 additions and 185 deletions

View File

@@ -3,7 +3,7 @@ SaveMenu:
farcall DisplaySaveInfoOnSave
call SpeechTextbox2bpp
call UpdateSprites
farcall SaveMenu_CopyTilemapAtOnce
farcall CopyTilemapAtOnce
ld hl, WouldYouLikeToSaveTheGameText
call SaveTheGame_yesorno
jr nz, .refused
@@ -18,7 +18,7 @@ SaveMenu:
.refused
call ExitMenu
farcall SaveMenu_CopyTilemapAtOnce
farcall CopyTilemapAtOnce
scf
ret

View File

@@ -1,80 +0,0 @@
SaveMenu_CopyTilemapAtOnce:
; The following is a modified version of _CopyTilemapAtOnce
; that waits for [rLY] to be $60 instead of $80 - 1.
ldh a, [hBGMapMode]
push af
xor a
ldh [hBGMapMode], a
ldh a, [hMapAnims]
push af
xor a
ldh [hMapAnims], a
.wait
ldh a, [rLY]
cp $60
jr c, .wait
di
ld a, BANK(vBGMap2)
ldh [rVBK], a
hlcoord 0, 0, wAttrmap
call .CopyBGMapViaStack
ld a, BANK(vBGMap0)
ldh [rVBK], a
hlcoord 0, 0
call .CopyBGMapViaStack
.wait2
ldh a, [rLY]
cp $60
jr c, .wait2
ei
pop af
ldh [hMapAnims], a
pop af
ldh [hBGMapMode], a
ret
.CopyBGMapViaStack:
; Copy all tiles to vBGMap
ld [hSPBuffer], sp
ld sp, hl
ldh a, [hBGMapAddress + 1]
ld h, a
ld l, 0
ld a, SCREEN_HEIGHT
ldh [hTilesPerCycle], a
ld b, 1 << rSTAT_BUSY ; not in v/hblank
ld c, LOW(rSTAT)
.loop
rept SCREEN_WIDTH / 2
pop de
; if in v/hblank, wait until not in v/hblank
.loop\@
ldh a, [c]
and b
jr nz, .loop\@
; load vBGMap
ld [hl], e
inc l
ld [hl], d
inc l
endr
ld de, BG_MAP_WIDTH - SCREEN_WIDTH
add hl, de
ldh a, [hTilesPerCycle]
dec a
ldh [hTilesPerCycle], a
jr nz, .loop
ldh a, [hSPBuffer]
ld l, a
ldh a, [hSPBuffer + 1]
ld h, a
ld sp, hl
ret