From 068d4c244915a819cf374d91885986822608bc94 Mon Sep 17 00:00:00 2001 From: cassidoxa Date: Thu, 23 Feb 2023 21:46:27 -0500 Subject: [PATCH] Port map key counter on HUD from DR --- compasses.asm | 51 +++++++++++++++++++++++++++++++++++++-------------- newhud.asm | 4 +--- tables.asm | 2 +- 3 files changed, 39 insertions(+), 18 deletions(-) diff --git a/compasses.asm b/compasses.asm index e55fafa..0dbc4ac 100644 --- a/compasses.asm +++ b/compasses.asm @@ -1,22 +1,24 @@ -DrawDungeonCompassCounts: +DrawDungeonItemCounts: LDX.b IndoorsFlag : BNE + : RTL : + ; Skip if outdoors - ; extra hard safeties for getting dungeon ID to prevent crashes PHA LDA.w DungeonID : AND.w #$00FE : TAX ; force dungeon ID to be multiple of 2 PLA - CPX.b #$1B : BCS .done ; Skip if not in a valid dungeon ID + TXA : LSR : TAX : BNE + + INC ; Count sewer as Hyrule Castle + + + JSR.w DrawCompassCounts + JSR.w DrawMapCounts + .done +RTL - BIT.w #$0002 : BNE ++ ; if CompassMode==2, we don't check for the compass +DrawCompassCounts: + PHX + LDA.l CompassMode : BIT.w #$0002 : BNE + ; if CompassMode==2, we don't check for the compass LDA.l CompassField : AND.l DungeonItemMasks, X ; Load compass values to A, mask with dungeon item masks BEQ .done ; skip if we don't have compass - ++ - - TXA : LSR : TAX - BNE + - INC - + + + LDA.l CompassTotalsWRAM, X : AND.w #$00FF SEP #$20 JSR HudHexToDec2Digit @@ -25,18 +27,39 @@ DrawDungeonCompassCounts: LDX.b Scrap06 : TXA : ORA.w #$2400 : STA.l HUDTileMapBuffer+$9A LDX.b Scrap07 : TXA : ORA.w #$2400 : STA.l HUDTileMapBuffer+$9C PLX - LDA.l DungeonLocationsChecked, X : AND.w #$00FF SEP #$20 JSR HudHexToDec2Digit REP #$20 LDX.b Scrap06 : TXA : ORA.w #$2400 : STA.l HUDTileMapBuffer+$94 ; Draw the item count LDX.b Scrap07 : TXA : ORA.w #$2400 : STA.l HUDTileMapBuffer+$96 - LDA.w #$2830 : STA.l HUDTileMapBuffer+$98 ; draw the slash + .done + PLX +RTS - .done -RTL +DrawMapCounts: + PHX + LDA.l MapHUDMode : BIT.w #$0002 : BNE + ; if MapHUDMode==2, we don't check for map + LDA.l MapField : AND.l DungeonItemMasks, X ; Load map values to A, mask with dungeon item masks + BEQ .done ; skip if we don't have map + + + LDA.l MapTotalsWRAM, X : AND.w #$00FF + SEP #$20 + JSR HudHexToDec2Digit + REP #$20 + PHX + LDX.b Scrap07 : TXA : ORA.w #$2400 : STA.l HUDTileMapBuffer+$A6 + PLX + LDA.l DungeonCollectedKeys, X : AND.w #$00FF + SEP #$20 + JSR HudHexToDec2Digit + REP #$20 + LDX.b Scrap07 : TXA : ORA.w #$2400 : STA.l HUDTileMapBuffer+$A2 + LDA.w #$2830 : STA.l HUDTileMapBuffer+$A4 ; draw the slash + .done + PLX +RTS DungeonItemMasks: ; these are dungeon correlations to $7EF364 - $7EF369 so it knows where to store compasses, etc dw $8000, $4000, $2000, $1000, $0800, $0400, $0200, $0100 diff --git a/newhud.asm b/newhud.asm index 68a0b12..5bcfef0 100644 --- a/newhud.asm +++ b/newhud.asm @@ -85,9 +85,7 @@ NewDrawHud: ;================================================================================ ; Draw Dungeon Compass Counts ;================================================================================ - LDA.l CompassMode : AND.w #$00FF : BEQ + ; skip if CompassMode is 0. - JSL.l DrawDungeonCompassCounts ; compasses.asm - + + JSL.l DrawDungeonItemCounts ; compasses.asm ;================================================================================ ; Draw key count diff --git a/tables.asm b/tables.asm index c3f80f0..556b7bc 100644 --- a/tables.asm +++ b/tables.asm @@ -118,7 +118,7 @@ org $308038 ; PC 0x180038 LampConeSewers: db #$01 ; #$00 = Off - #$01 = On (default) ;-------------------------------------------------------------------------------- -; 0x180039 - 0x180039 (Unused) +; 0x180039 (Unused) ;-------------------------------------------------------------------------------- org $30803A ; PC 0x18003B - PC 0x18003C MapHUDMode: