2023-08-29 09:33:20 -07:00
|
|
|
OVERWORLD_HUD_HEIGHT EQU 8
|
|
|
|
|
|
|
|
EnableOverworldHUD::
|
|
|
|
ld a, HUD_OVERWORLD
|
|
|
|
ld [wWhichHUD], a
|
2023-08-30 10:23:51 -07:00
|
|
|
call TransferOverworldHUDToBGMap
|
2023-08-29 09:33:20 -07:00
|
|
|
ld a, OVERWORLD_HUD_HEIGHT - 1
|
|
|
|
; fallthrough
|
|
|
|
|
2023-08-30 10:23:51 -07:00
|
|
|
EnableWindowHUD::
|
2023-08-29 09:33:20 -07:00
|
|
|
ldh [hWindowHUDLY], a
|
|
|
|
; configure LCD interrupt
|
|
|
|
ldh [rLYC], a
|
|
|
|
; make window hidden this frame to prevent graphical glitches
|
|
|
|
ld a, $90
|
|
|
|
ldh [hWY], a
|
|
|
|
; configure LCD interrupt
|
2023-08-29 09:52:51 -07:00
|
|
|
ld a, 1 << rSTAT_INT_LYC ; LYC=LY
|
2023-08-29 09:33:20 -07:00
|
|
|
ldh [rSTAT], a
|
|
|
|
ret
|
|
|
|
|
|
|
|
DisableOverworldHUD::
|
|
|
|
xor a
|
|
|
|
ld [wWhichHUD], a
|
|
|
|
; fallthrough
|
|
|
|
|
|
|
|
DisableWindowHUD::
|
|
|
|
xor a
|
|
|
|
ldh [hWindowHUDLY], a
|
|
|
|
; configure LCD interrupt
|
|
|
|
xor a
|
|
|
|
ldh [rLYC], a
|
|
|
|
ld a, 1 << rSTAT_INT_HBLANK ; hblank (default)
|
|
|
|
ldh [rSTAT], a
|
|
|
|
; leave window in default state (hidden with WY=$90)
|
|
|
|
; rLCDC[rLCDC_WINDOW_ENABLE] will be set during next vblank
|
|
|
|
ld a, $90
|
|
|
|
ldh [hWY], a
|
|
|
|
ret
|
|
|
|
|
|
|
|
LoadWindowHUD::
|
|
|
|
; like LoadHUD, but for HUDs that require a Window overlay
|
|
|
|
ldh a, [hWindowHUDLY]
|
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
; fallthrough
|
|
|
|
|
|
|
|
LoadHUD::
|
|
|
|
; load the HUD at wWhichHUD to the top of wTilemap and wAttrmap
|
|
|
|
ld a, [wWhichHUD]
|
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
farcall _LoadHUD
|
|
|
|
ret
|
|
|
|
|
|
|
|
ConstructOverworldHUDTilemap::
|
|
|
|
; draw the overworld HUD's tilemap into wOverworldHUDTiles
|
2023-08-30 10:23:51 -07:00
|
|
|
farcall _ConstructOverworldHUDTilemap
|
2023-08-29 09:33:20 -07:00
|
|
|
ret
|
|
|
|
|
2023-08-30 10:23:51 -07:00
|
|
|
RefreshOverworldHUD::
|
|
|
|
call ConstructOverworldHUDTilemap
|
|
|
|
; fallthrough
|
2023-08-29 09:33:20 -07:00
|
|
|
|
2023-08-30 10:23:51 -07:00
|
|
|
TransferOverworldHUDToBGMap:
|
2023-08-29 09:33:20 -07:00
|
|
|
; 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]
|
|
|
|
push af
|
|
|
|
|
|
|
|
; Tilemap
|
|
|
|
ld a, BANK(vBGMap1)
|
|
|
|
ldh [rVBK], a
|
|
|
|
ld de, vBGMap1
|
|
|
|
ld hl, wOverworldHUDTiles
|
|
|
|
|
|
|
|
ld b, 1 << rSTAT_BUSY ; not in v/hblank
|
|
|
|
ld c, LOW(rSTAT)
|
|
|
|
|
|
|
|
rept SCREEN_WIDTH / 2
|
|
|
|
; if not in v/hblank, wait until in v/hblank
|
|
|
|
.loop\@
|
|
|
|
ldh a, [c]
|
|
|
|
and b
|
|
|
|
jr nz, .loop\@
|
|
|
|
; copy
|
|
|
|
; we have at least a margin of 16 cycles of Mode2 left
|
|
|
|
ld a, [hli]
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
ld a, [hli]
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
endr
|
|
|
|
|
|
|
|
; Attrmap
|
|
|
|
ld a, BANK(vBGMap3)
|
|
|
|
ldh [rVBK], a
|
|
|
|
ld hl, vBGMap3
|
|
|
|
|
|
|
|
rept SCREEN_WIDTH / 5
|
|
|
|
; if not in v/hblank, wait until in v/hblank
|
|
|
|
.loop\@
|
|
|
|
ldh a, [c]
|
|
|
|
and b
|
|
|
|
jr nz, .loop\@
|
|
|
|
; fill
|
|
|
|
; we have at least a margin of 16 cycles of Mode2 left
|
|
|
|
ld a, PAL_BG_TEXT | PRIORITY
|
|
|
|
ld [hli], a
|
|
|
|
ld [hli], a
|
|
|
|
ld [hli], a
|
|
|
|
ld [hli], a
|
|
|
|
ld [hli], a
|
|
|
|
endr
|
|
|
|
|
|
|
|
pop af
|
|
|
|
ld [rVBK], a
|
|
|
|
ret
|
2023-08-31 10:27:39 -07:00
|
|
|
|
|
|
|
ConstructAndEnableOverworldHUD::
|
|
|
|
; map setup command used by MAPSETUP_ENTERLEVEL and MAPSETUP_CONTINUE
|
|
|
|
ld hl, wTextboxFlags
|
|
|
|
set TEXT_2BPP_F, [hl]
|
|
|
|
call ConstructOverworldHUDTilemap
|
|
|
|
jp EnableOverworldHUD
|