Merge pull request #184 from cassidoxa/map_counts

Add HUD map mode flag, "chest key" totals table, and seen-counter flags for tracking
This commit is contained in:
Lexi Rose
2023-02-24 16:08:37 -06:00
committed by GitHub
9 changed files with 125 additions and 35 deletions

View File

@@ -1,21 +1,23 @@
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
@@ -25,28 +27,54 @@ 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
RTL
PLX
RTS
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
dw $0080, $0040, $0020, $0010, $0008, $0004
;--------------------------------------------------------------------------------
InitCompassTotalsRAM:
LDX.b #$00
InitDungeonCounts:
LDX.b #$0F
-
LDA.l CompassTotalsROM, X : STA.l CompassTotalsWRAM, X
INX
CPX.b #$0F : !BLT -
DEX
BPL -
LDX.b #$0F
-
LDA.l ChestKeys, X : STA.l MapTotalsWRAM, X
DEX
BPL -
RTL

View File

@@ -16,7 +16,7 @@ JML.l ReturnFromOnDrawHud
;--------------------------------------------------------------------------------
OnDungeonEntrance:
STA.l PegColor ; thing we wrote over
JSL MaybeFlagCompassTotalEntrance
JSL MaybeFlagDungeonTotalsEntrance
RTL
;--------------------------------------------------------------------------------
OnPlayerDead:

View File

@@ -67,6 +67,6 @@ Init_PostRAMClear:
JSL MSUInit
JSL InitRNGPointerTable
JSL InitCompassTotalsRAM
JSL InitDungeonCounts
JML $00D463 ; The original target of the jump table that we hijacked

View File

@@ -408,6 +408,7 @@ AddInventory:
JSR .incrementBigKey
JMP .done
+ CPY.b #$33 : BNE + ; Map
JSL MaybeFlagMapTotalPickup
JSR .incrementMap
JMP .done
+ CPY.b #$37 : !BLT + ; Items $37 - $39 - Pendants
@@ -492,6 +493,7 @@ AddInventory:
JMP .done
+ CPY.b #$70 : !BLT + ; Items $70 - $7F - Free Maps
CPY.b #$80 : !BGE +
JSL MaybeFlagMapTotalPickup
JSR .incrementMap
JMP .done
+ CPY.b #$80 : !BLT + ; Items $80 - $8F - Free Compasses

View File

@@ -85,8 +85,8 @@ NewDrawHud:
;================================================================================
; Draw Dungeon Compass Counts
;================================================================================
LDA.l CompassMode : AND.w #$00FF : BEQ + ; skip if CompassMode is 0.
JSL.l DrawDungeonCompassCounts ; compasses.asm
LDA.l CompassMode : ORA.l MapHUDMode : BIT #$0003 : BEQ +
JSL.l DrawDungeonItemCounts ; compasses.asm
+
;================================================================================

View File

@@ -1087,14 +1087,23 @@ MaybeFlagCompassTotalPickup:
.done
RTL
;--------------------------------------------------------------------------------
; Set the compass count display flag if we're entering a dungeon and alerady have
; that compass
MaybeFlagCompassTotalEntrance:
; Set the dungeon item count display flags if we're entering a dungeon and have the
; corresponding dungeon item
MaybeFlagDungeonTotalsEntrance:
LDX.w DungeonID : CPX.b #$FF : BEQ .done ; Skip if we're not entering dungeon
LDA.l CompassMode : AND.w #$000F : BEQ .done ; Skip if we're not showing compass counts
CMP.w #$0002 : BEQ .countShown
LDA.l CompassMode : AND.w #$000F : BEQ .maps ; Skip if we're not showing compass counts
JSR.w FlagCompassCount
.maps
LDA.l MapHUDMode : AND.w #$000F : BEQ .done
LDX.w DungeonID
JSR.w FlagMapCount
.done
RTL
;--------------------------------------------------------------------------------
FlagCompassCount:
CMP.w #$0002 : BEQ .compassShown
LDA.l CompassField : AND.l DungeonItemMasks, X : BEQ .done ; skip if we don't have compass
.countShown
.compassShown
SEP #$20
TXA : LSR : STA.b Scrap04 : LDA.b #$0F : !SUB Scrap04 ; Compute flag index
CMP.b #$08 : !BGE ++
@@ -1109,5 +1118,46 @@ MaybeFlagCompassTotalEntrance:
ORA.l CompassCountDisplay+1 : STA.l CompassCountDisplay+1
REP #$20
.done
RTS
;--------------------------------------------------------------------------------
FlagMapCount:
CMP.w #$0002 : BEQ .mapShown
LDA.l MapField : AND.l DungeonItemMasks, X : BEQ .done ; skip if we don't have map
.mapShown
SEP #$20
TXA : LSR : STA.b Scrap04 : LDA.b #$0F : !SUB Scrap04 ; Compute flag index
CMP.b #$08 : !BGE ++
%ValueShift()
ORA.l MapCountDisplay : STA.l MapCountDisplay
REP #$20
BRA .done
++
!SUB #$08
%ValueShift()
BIT.b #$C0 : BEQ + : LDA.b #$C0 : + ; Make Hyrule Castle / Sewers Count for Both
ORA.l MapCountDisplay+1 : STA.l MapCountDisplay+1
REP #$20
.done
RTS
;--------------------------------------------------------------------------------
MaybeFlagMapTotalPickup:
LDA.l MapMode : AND.b #$0F : BEQ .done
LDA.w DungeonID : CMP.b #$FF : BEQ .done
LSR : STA.b Scrap04 : LDA.b #$0F : !SUB Scrap04 ; Compute flag "index"
CPY.b #$25 : BEQ .setFlag ; Set flag if it's a compass for this dungeon
STA.b Scrap04
TYA : AND.b #$0F : CMP.b Scrap04 : BNE .done ; Check if map is for this dungeon
.setFlag
CMP.b #$08 : !BGE ++
%ValueShift()
ORA.l MapCountDisplay : STA.l MapCountDisplay
BRA .done
++
!SUB #$08
%ValueShift()
BIT.b #$C0 : BEQ + : LDA.b #$C0 : + ; Make Hyrule Castle / Sewers Count for Both
ORA.l MapCountDisplay+1 : STA.l MapCountDisplay+1
.done
RTL
;--------------------------------------------------------------------------------

View File

@@ -544,8 +544,9 @@ RxStatus: skip 1 ;
TxBuffer: skip $7F ;
TxStatus: skip 1 ;
skip $10 ; Unused
CompassTotalsWRAM: skip $10 ; skip $10
skip $40 ; Reserved for general dungeon tracking data. May have over
CompassTotalsWRAM: skip $10 ; \ Compass and map dungeon HUD display totals. Placed in WRAM
MapTotalsWRAM: skip $10 ; / on boot for tracking.
skip $30 ; Reserved for general dungeon tracking data. May have over
; allocated here. Feel free to reassign.
skip $40 ; Unused
skip $260 ; Unused
@@ -913,6 +914,7 @@ endmacro
%assertRAM(TxBuffer, $7F5380)
%assertRAM(TxStatus, $7F53FF)
%assertRAM(CompassTotalsWRAM, $7F5410)
%assertRAM(MapTotalsWRAM, $7F5420)
%assertRAM(DialogBuffer, $7F5700)
%assertRAM(MiniGameTime, $7FFE00)
%assertRAM(MiniGameTimeFinal, $7FFE04)

View File

@@ -317,7 +317,8 @@ HeartPieceCounter: skip 1 ; Total Number of heartpieces collected (integer
CrystalCounter: skip 1 ; Total Number of crystals collected (integer)
DungeonsCompleted: skip 2 ; Bitfield indicating whether a dungeon's prize has been collected.
; This has the same shape as the dungeon item bitfields.
skip 44 ; Unused
MapCountDisplay: skip 2 ;
skip 42 ; Unused
ServiceSequence: ; See servicerequest.asm
ServiceSequenceRx: skip 8 ; Service sequence receive
ServiceSequenceTx: skip 8 ; Service sequence transmit
@@ -602,6 +603,7 @@ endmacro
%assertSRAM(HeartPieceCounter, $7EF470)
%assertSRAM(CrystalCounter, $7EF471)
%assertSRAM(DungeonsCompleted, $7EF472)
%assertSRAM(MapCountDisplay, $7EF474)
;--------------------------------------------------------------------------------
%assertSRAM(ServiceSequence, $7EF4A0)
%assertSRAM(ServiceSequenceRx, $7EF4A0)

View File

@@ -118,9 +118,11 @@ org $308038 ; PC 0x180038
LampConeSewers:
db #$01 ; #$00 = Off - #$01 = On (default)
;--------------------------------------------------------------------------------
; 0x180039 - 0x18003A (Unused)
; 0x180039 (Unused)
;--------------------------------------------------------------------------------
org $30803B ; PC 0x18003B - PC 0x18003C
org $30803A ; PC 0x18003B - PC 0x18003C
MapHUDMode:
db #$00 ; #$00 = Off (default) - #$01 = Display Dungeon Count w/Map - #$02 = Display Dungeon Count Always
MapMode:
db #$00 ; #$00 = Always On (default) - #$01 = Require Map Item
CompassMode:
@@ -2544,6 +2546,10 @@ org $30F000 ; PC 0x187000-0x18700F
CompassTotalsROM:
db $08, $08, $06, $06, $02, $0A, $0E, $08, $08, $08, $06, $08, $0C, $1B, $00, $00
org $30F010
ChestKeys: ; PC 0x187010-0x18701F
db $01, $01, $00, $01, $02, $01, $06, $03, $03, $02, $01, $01, $04, $04, $00, $00
;--------------------------------------------------------------------------------
; 0x187010 - 187FFF (unused)
;--------------------------------------------------------------------------------