diff --git a/docs/develop/index.md b/docs/develop/index.md index 6b5366646..58d15fea2 100755 --- a/docs/develop/index.md +++ b/docs/develop/index.md @@ -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 diff --git a/engine/gfx/hud.asm b/engine/gfx/hud.asm index 61fcbce52..a2327ef5d 100755 --- a/engine/gfx/hud.asm +++ b/engine/gfx/hud.asm @@ -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 diff --git a/engine/overworld/events.asm b/engine/overworld/events.asm index 8614bd18c..ff9c9e8cb 100644 --- a/engine/overworld/events.asm +++ b/engine/overworld/events.asm @@ -127,7 +127,6 @@ EnterMap: .dontresetpoison call ConstructOverworldHUDTilemap - call TransferOverworldHUDToBGMap call EnableOverworldHUD xor a ; end map entry diff --git a/home/hud.asm b/home/hud.asm index 0d55cca99..e36d7ffdd 100755 --- a/home/hud.asm +++ b/home/hud.asm @@ -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]