Overworld HUD implementation (#15)

This commit is contained in:
xCrystal
2023-08-29 18:33:20 +02:00
parent b275d642cd
commit f386a63cf8
21 changed files with 214 additions and 98 deletions

View File

@@ -41,12 +41,12 @@ HDMATransferTilemapAndAttrmap_OverworldEffect::
call PadTilemapForHDMATransfer
call DelayFrame
ldh a, [hWindowHUD]
ldh a, [hWindowHUDLY]
and a
jr z, .go
; wait until LCD interrupt has ocurred this frame ([rLY] - [hWindowHUD] >= 0)
; wait until LCD interrupt has ocurred this frame ([rLY] - [hWindowHUDLY] >= 0)
.wait_lcd
; ldh a, [hWindowHUD]
; ldh a, [hWindowHUDLY]
ld b, a
ldh a, [rLY]
sub b
@@ -86,12 +86,12 @@ _HDMATransferTilemapAndAttrmap_OpenAndCloseMenu::
call PadTilemapForHDMATransfer
call DelayFrame
ldh a, [hWindowHUD]
ldh a, [hWindowHUDLY]
and a
jr z, .go
; wait until LCD interrupt has ocurred this frame ([rLY] - [hWindowHUD] >= 0)
; wait until LCD interrupt has ocurred this frame ([rLY] - [hWindowHUDLY] >= 0)
.wait_lcd
; ldh a, [hWindowHUD]
; ldh a, [hWindowHUDLY]
ld b, a
ldh a, [rLY]
sub b
@@ -276,12 +276,12 @@ _continue_HDMATransfer:
cp d
jr nc, .ly_loop
ldh a, [hWindowHUD]
ldh a, [hWindowHUDLY]
and a
jr z, .go
; wait until LCD interrupt has ocurred this frame ([rLY] - [hWindowHUD] >= 0)
; wait until LCD interrupt has ocurred this frame ([rLY] - [hWindowHUDLY] >= 0)
.wait_lcd
; ldh a, [hWindowHUD]
; ldh a, [hWindowHUDLY]
ld b, a
ldh a, [rLY]
sub b

29
engine/gfx/hud.asm Executable file
View File

@@ -0,0 +1,29 @@
_LoadHUD::
jumptable .Jumptable, wWhichHUD
.Jumptable:
; entries correspond to HUD_* constants (see constants/gfx_constants.asm)
table_width 2, _LoadHUD.Jumptable
dw .None
dw _LoadOverworldHUDTilemapAndAttrmap
assert_table_length NUM_HUD_TYPES + 1
.None:
ret
_LoadOverworldHUDTilemapAndAttrmap:
call _LoadOverworldHUDAttrmap
; fallthrough
_LoadOverworldHUDTilemap:
; overworld HUD reads SCREEN_WIDTH tiles from wOverworldHUDTiles
ld hl, wOverworldHUDTiles
decoord 0, 0, wTilemap
ld bc, wOverworldHUDTilesEnd - wOverworldHUDTiles ; SCREEN_WIDTH
jp CopyBytes
_LoadOverworldHUDAttrmap:
hlcoord 0, 0, wAttrmap
ld bc, SCREEN_WIDTH
ld a, PAL_BG_TEXT | PRIORITY
jp ByteFill

View File

@@ -126,7 +126,9 @@ EnterMap:
ld [wPoisonStepCount], a
.dontresetpoison
call EnableOverworldWindowHUD
call ConstructOverworldHUDTilemap
call TransferOverworldHUDToBGMap
call EnableOverworldHUD
xor a ; end map entry
ldh [hMapEntryMethod], a

View File

@@ -25,17 +25,20 @@ ReanchorBGMap_NoOAMUpdate::
xor a
ldh [hLCDCPointer], a
ldh [hBGMapMode], a
; prepare vBGMap1/vBGMap3 to be displayed while vBGMap0/vBGMap2 is reanchored.
; draw screen at wTilemap and wAttrmap and then transfer it.
ld a, $90
ldh [hWY], a
call LoadScreenTilemapAndAttrmapPals
call LoadWindowHUD
ld a, HIGH(vBGMap1)
call .LoadBGMapAddrIntoHRAM
call HDMATransferTilemapAndAttrmap_OpenAndCloseMenu
farcall ApplyPals
ld a, TRUE
ldh [hCGBPalUpdate], a
; display window while BG map is reanchored.
; disable LCD interrupt to prevent cropping the window due to hWindowHUD
; display window using vBGMap1/vBGMap3 while vBGMap0/vBGMap2 is reanchored.
; disable LCD interrupt to prevent cropping the window if window HUD is active
; (caller must re-enable when window is hidden again).
xor a
ldh [rSTAT], a

View File

@@ -33,4 +33,5 @@ _LoadScreenTilemap::
.carry
dec b
jr nz, .loop
ret

View File

@@ -1165,7 +1165,7 @@ Script_loadtrainer:
ret
Script_startbattle:
call DisableWindowHUD
call DisableOverworldHUD
call BufferScreen
predef StartBattle
ld a, [wBattleResult]

View File

@@ -1,5 +1,4 @@
HandleNewMap:
call ClearUnusedMapBuffer
call ResetMapBufferEventFlags
call ResetFlashIfOutOfCave
call GetCurrentMapSceneID

View File

@@ -547,7 +547,7 @@ Phone_StartRinging:
call PlaySFX
call Phone_CallerTextbox
call UpdateSprites
farcall PhoneRing_CopyTilemapAtOnce
call PhoneRing_CopyTilemapAtOnce
ret
HangUp_Wait20Frames:
@@ -556,7 +556,7 @@ HangUp_Wait20Frames:
Phone_Wait20Frames:
ld c, 20
call DelayFrames
farcall PhoneRing_CopyTilemapAtOnce
call PhoneRing_CopyTilemapAtOnce
ret
PhoneRing_CopyTilemapAtOnce: