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