Tinker with overworld HUD implementation in f386a63cf8 (#15)

This commit is contained in:
xCrystal 2023-08-30 19:23:51 +02:00
parent 236519fc55
commit 9f835560d7
4 changed files with 21 additions and 12 deletions

View File

@ -52,12 +52,13 @@
#### HUD
- **EnableWindowHUD**: Configure LCD interrupt in LYC=LY mode with corresponding LYC
- **EnableWindowHUD**: Configure LCD interrupt in LYC=LY mode with corresponding LYC.
- **DisableWindowHUD**: Configure LCD interrupt in hblank mode
- **LoadHUD**: Load the HUD at wWhichHUD to the top of wTilemap and wAttrmap
- **LoadWindowHUD**: Like LoadHUD, but for HUDs that require a Window overlay. Only does anything if hWindowHUDLY is non-0
- **ConstructOverworldHUDTilemap**: Draw the overworld HUD's tilemap into wOverworldHUDTiles
- **TransferOverworldHUDToBGMap**: Transfer overworld HUD to vBGMap1/vBGMap3 during v/hblank(s). Tilemap is read from wOverworldHUDTiles, attrmap is all PAL_BG_TEXT | PRIORITY.
- **RefreshOverworldHUD**: ConstructOverworldHUDTilemap + TransferOverworldHUDToBGMap
### Scripts

View File

@ -27,3 +27,15 @@ _LoadOverworldHUDAttrmap:
ld bc, SCREEN_WIDTH
ld a, PAL_BG_TEXT | PRIORITY
jp ByteFill
_ConstructOverworldHUDTilemap::
ld hl, .Tilemap
ld de, wOverworldHUDTiles
ld bc, .TilemapEnd - .Tilemap ; SCREEN_WIDTH
call CopyBytes
ret
.Tilemap:
db "▶- ▶- ▶ ▶ "
.TilemapEnd:
assert .TilemapEnd - .Tilemap == wOverworldHUDTilesEnd - wOverworldHUDTiles

View File

@ -127,7 +127,6 @@ EnterMap:
.dontresetpoison
call ConstructOverworldHUDTilemap
call TransferOverworldHUDToBGMap
call EnableOverworldHUD
xor a ; end map entry

View File

@ -3,10 +3,11 @@ OVERWORLD_HUD_HEIGHT EQU 8
EnableOverworldHUD::
ld a, HUD_OVERWORLD
ld [wWhichHUD], a
call TransferOverworldHUDToBGMap
ld a, OVERWORLD_HUD_HEIGHT - 1
; fallthrough
EnableWindowHUD:
EnableWindowHUD::
ldh [hWindowHUDLY], a
; configure LCD interrupt
ldh [rLYC], a
@ -54,18 +55,14 @@ LoadHUD::
ConstructOverworldHUDTilemap::
; draw the overworld HUD's tilemap into wOverworldHUDTiles
ld hl, .Tilemap
ld de, wOverworldHUDTiles
ld bc, .TilemapEnd - .Tilemap ; SCREEN_WIDTH
call CopyBytes
farcall _ConstructOverworldHUDTilemap
ret
.Tilemap:
db "▶- ▶- ▶ ▶ "
.TilemapEnd:
assert .TilemapEnd - .Tilemap == wOverworldHUDTilesEnd - wOverworldHUDTiles
RefreshOverworldHUD::
call ConstructOverworldHUDTilemap
; fallthrough
TransferOverworldHUDToBGMap::
TransferOverworldHUDToBGMap:
; transfer overworld HUD to vBGMap1/vBGMap3 during v/hblank(s)
; tilemap is read from wOverworldHUDTiles, attrmap is all PAL_BG_TEXT | PRIORITY
ldh a, [rVBK]