Handle 16-bit GoalCounter and TotalItemCounter

Fix vanilla sword + shield item
Fix how progressive items handled
Clean up compasses.asm
This commit is contained in:
cassidoxa
2022-02-08 19:25:59 -05:00
parent 02932a2a9d
commit 905e897b52
9 changed files with 70 additions and 156 deletions

View File

@@ -1,16 +1,6 @@
;-------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------
; $7F5010 - Scratch Space ; $7F5010 - Scratch Space
;-------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------
; The number of items in a dungeon never changes. use this macro instead of
; HexToDec when drawing the "??/XX" item counter
; %DrawConstantNumber(1,4) draws 14
;--------------------------------------------------------------------------------
;macro DrawConstantNumber(digit1,digit2)
; LDA.w #$2490+<digit1> : STA $7EC79A
; LDA.w #$2490+<digit2> : STA $7EC79C
; SEP #$20
;endmacro
;--------------------------------------------------------------------------------
DrawDungeonCompassCounts: DrawDungeonCompassCounts:
LDX $1B : BNE + : RTL : + ; Skip if outdoors LDX $1B : BNE + : RTL : + ; Skip if outdoors
@@ -64,76 +54,3 @@ InitCompassTotalsRAM:
CPX #$0F : !BLT - CPX #$0F : !BLT -
RTL RTL
;CompassCountDungeonHandlers: ; pointers to functions that handle dungeon-specific code
; dw CompassCount_Escape, CompassCount_Escape ; (hyrule castle, sewers)
; dw CompassCount_Eastern, CompassCount_Desert, CompassCount_Agah
; dw CompassCount_Swamp, CompassCount_PoD, CompassCount_Mire
; dw CompassCount_Skull, CompassCount_Ice, CompassCount_Hera
; dw CompassCount_Thieves, CompassCount_Trock, CompassCount_Gt
;}
;
;CompassCount_Escape:
; %DrawConstantNumber(0,8)
; LDA SewersLocations
; JMP DrawDungeonCompassCounts_return_spot
;
;CompassCount_Eastern:
; %DrawConstantNumber(0,6)
; LDA EPLocations
; JMP DrawDungeonCompassCounts_return_spot
;
;CompassCount_Desert:
; %DrawConstantNumber(0,6)
; LDA DPLocations
; JMP DrawDungeonCompassCounts_return_spot
;
;CompassCount_Agah:
; %DrawConstantNumber(0,2)
; LDA CTLocations
; JMP DrawDungeonCompassCounts_return_spot
;
;CompassCount_Swamp:
; %DrawConstantNumber(1,0)
; LDA SPLocations
; JMP DrawDungeonCompassCounts_return_spot
;
;CompassCount_PoD:
; %DrawConstantNumber(1,4)
; LDA PDLocations
; JMP DrawDungeonCompassCounts_return_spot
;
;CompassCount_Mire:
; %DrawConstantNumber(0,8)
; LDA MMLocations
; JMP DrawDungeonCompassCounts_return_spot
;
;CompassCount_Skull:
; %DrawConstantNumber(0,8)
; LDA SWLocations
; JMP DrawDungeonCompassCounts_return_spot
;
;CompassCount_Ice:
; %DrawConstantNumber(0,8)
; LDA IPLocations
; JMP DrawDungeonCompassCounts_return_spot
;
;CompassCount_Hera:
; %DrawConstantNumber(0,6)
; LDA THLocations
; JMP DrawDungeonCompassCounts_return_spot
;
;CompassCount_Thieves:
; %DrawConstantNumber(0,8)
; LDA TTLocations
; JMP DrawDungeonCompassCounts_return_spot
;
;CompassCount_Trock:
; %DrawConstantNumber(1,2)
; LDA TRLocations
; JMP DrawDungeonCompassCounts_return_spot
;
;CompassCount_Gt:
; %DrawConstantNumber(2,7)
; LDA GTLocations
; JMP DrawDungeonCompassCounts_return_spot
;

View File

@@ -40,25 +40,30 @@ RTL
Elder_Code: Elder_Code:
{ {
LDA GoalItemRequirement : BEQ .despawn REP #$20
LDA InvincibleGanon : CMP #$05 : BEQ .despawn LDA.l GoalItemRequirement : BEQ .despawn
LDA TurnInGoalItems : BNE + LDA.l InvincibleGanon : AND.w #$00FF : CMP.w #$0005 : BEQ .despawn
LDA.l TurnInGoalItems : AND.w #$00FF : BNE +
.despawn .despawn
SEP #$20
STZ $0DD0, X ; despawn self STZ $0DD0, X ; despawn self
RTS RTS
+ +
SEP #$20
LDA.b #$96 LDA.b #$96
LDY.b #$01 LDY.b #$01
JSL Sprite_ShowSolicitedMessageIfPlayerFacing_PreserveMessage : BCC .dont_show JSL Sprite_ShowSolicitedMessageIfPlayerFacing_PreserveMessage : BCC .dont_show
LDA GoalCounter REP #$20
CMP GoalItemRequirement : !BLT + LDA.l GoalCounter
CMP.l GoalItemRequirement : !BLT +
SEP #$20
JSL.l ActivateGoal JSL.l ActivateGoal
+ +
.dont_show .dont_show
.done .done
LDA $1A : LSR #5 : AND.b #$01 : STA $0DC0, X SEP #$20
LDA.b $1A : LSR #5 : AND.b #$01 : STA.w $0DC0, X
RTS RTS
} }

View File

@@ -81,7 +81,9 @@ CheckGanonVulnerability:
; 05 = require goal item ; 05 = require goal item
.goal_item .goal_item
LDA.l GoalCounter : CMP GoalItemRequirement REP #$20
LDA.l GoalCounter : CMP.l GoalItemRequirement
SEP #$20
RTS RTS
; 06 = light speed ; 06 = light speed

View File

@@ -354,7 +354,9 @@ AddInventory:
LDA PreFluteLocations : INC : STA PreFluteLocations ; Increment Pre Mirror Counter LDA PreFluteLocations : INC : STA PreFluteLocations ; Increment Pre Mirror Counter
+ +
REP #$20
LDA TotalItemCounter : INC : STA TotalItemCounter ; Increment Item Total LDA TotalItemCounter : INC : STA TotalItemCounter ; Increment Item Total
SEP #$20
.itemCounts .itemCounts
@@ -522,15 +524,15 @@ AddInventory:
JSR .incrementBow JSR .incrementBow
JMP .done JMP .done
+ CPY.b #$5E : BNE + ; Progressive Sword + CPY.b #$5E : BNE + ; Progressive Sword
LDA SwordEquipment : TAX LDA SwordEquipment : INC : TAX
JSR .incrementSword JSR .incrementSword
JMP .done JMP .done
+ CPY.b #$5F : BNE + ; Progressive Shield + CPY.b #$5F : BNE + ; Progressive Shield
LDA ShieldEquipment : TAX LDA ShieldEquipment : INC : TAX
JSR .incrementShield JSR .incrementShield
JMP .done JMP .done
+ CPY.b #$60 : BNE + ; Progressive Armor + CPY.b #$60 : BNE + ; Progressive Armor
LDA ArmorEquipment : TAX LDA ArmorEquipment : INC : TAX
JSR .incrementMail JSR .incrementMail
JMP .done JMP .done
+ CPY.b #$61 : BNE + ; Progressive Lifting Glove + CPY.b #$61 : BNE + ; Progressive Lifting Glove

View File

@@ -73,13 +73,9 @@ RTS
JMP .done JMP .done
.isUncleSwordShield .isUncleSwordShield
PHA PHA
LDA HighestSword LDA HighestSword : STA [$00] ; already set to 1 if we had no sword, always keep highest
STA [$00] ; already set to 1 if we had no sword, always keep highest
INC $00 INC $00
LDA HighestShield : BNE + ; keep our shield unless we have no shield LDA HighestShield : STA [$00]
INC A
+
STA [$00]
PLA PLA
RTS RTS
;================================================================================ ;================================================================================

View File

@@ -61,32 +61,27 @@ SEP #$30
!GOAL_DRAW_ADDRESS = "$7EC72A" !GOAL_DRAW_ADDRESS = "$7EC72A"
;================================================================================ ;================================================================================
SEP #$20 REP #$20
LDA.l GoalItemRequirement : BNE + : JMP .done : + ; Star Meter LDA.l GoalItemRequirement : BNE + : JMP .done : + ; Star Meter
LDA.l GoalCounter LDA.l GoalCounter
JSR HudHexToDec3Digit JSR HudHexToDec4Digit
REP #$20
LDA.l GoalItemIcon : STA !GOAL_DRAW_ADDRESS ; draw star icon LDA.l GoalItemIcon : STA.l !GOAL_DRAW_ADDRESS ; draw star icon
LDX.b $05 : TXA : ORA.w #$2400 : STA !GOAL_DRAW_ADDRESS+2 ; draw 100's digit LDX.b $05 : TXA : ORA.w #$2400 : STA !GOAL_DRAW_ADDRESS+2 ; draw 100's digit
LDX.b $06 : TXA : ORA.w #$2400 : STA !GOAL_DRAW_ADDRESS+4 ; draw 10's digit LDX.b $06 : TXA : ORA.w #$2400 : STA !GOAL_DRAW_ADDRESS+4 ; draw 10's digit
LDX.b $07 : TXA : ORA.w #$2400 : STA !GOAL_DRAW_ADDRESS+6 ; draw 1's digit LDX.b $07 : TXA : ORA.w #$2400 : STA !GOAL_DRAW_ADDRESS+6 ; draw 1's digit
SEP #$20 LDA.l GoalItemRequirement : CMP.w #$FFFF : BEQ .skip
LDA.l GoalItemRequirement : CMP.b #$FF : BEQ .skip
LDA.l GoalItemRequirement LDA.l GoalItemRequirement
JSR HudHexToDec3Digit JSR HudHexToDec4Digit
REP #$20
LDA.w #$2830 : STA !GOAL_DRAW_ADDRESS+8 ; draw slash LDA.w #$2830 : STA !GOAL_DRAW_ADDRESS+8 ; draw slash
LDX.b $05 : TXA : ORA.w #$2400 : STA !GOAL_DRAW_ADDRESS+10 ; draw 100's digit LDX.b $05 : TXA : ORA.w #$2400 : STA !GOAL_DRAW_ADDRESS+10 ; draw 100's digit
LDX.b $06 : TXA : ORA.w #$2400 : STA !GOAL_DRAW_ADDRESS+12 ; draw 10's digit LDX.b $06 : TXA : ORA.w #$2400 : STA !GOAL_DRAW_ADDRESS+12 ; draw 10's digit
LDX.b $07 : TXA : ORA.w #$2400 : STA !GOAL_DRAW_ADDRESS+14 ; draw 1's digit LDX.b $07 : TXA : ORA.w #$2400 : STA !GOAL_DRAW_ADDRESS+14 ; draw 1's digit
BRA .done BRA .done
.skip .skip
REP #$20
LDA.w #$207F ; transparent tile LDA.w #$207F ; transparent tile
STA !GOAL_DRAW_ADDRESS+8 STA !GOAL_DRAW_ADDRESS+8
STA !GOAL_DRAW_ADDRESS+10 STA !GOAL_DRAW_ADDRESS+10
@@ -96,7 +91,6 @@ SEP #$30
;================================================================================ ;================================================================================
; Draw Dungeon Compass Counts ; Draw Dungeon Compass Counts
;================================================================================ ;================================================================================
REP #$20
LDA.l CompassMode : AND #$00FF : BEQ + ; skip if CompassMode is 0. LDA.l CompassMode : AND #$00FF : BEQ + ; skip if CompassMode is 0.
JSL.l DrawDungeonCompassCounts ; compasses.asm JSL.l DrawDungeonCompassCounts ; compasses.asm
+ +
@@ -263,27 +257,27 @@ RTS
; in: A(b) - Byte to Convert ; in: A(b) - Byte to Convert
; out: $05 - $07 (high - low) ; out: $05 - $07 (high - low)
;================================================================================ ;================================================================================
HudHexToDec3Digit: ; this may be overkill, could have used the 4 digit one... ;HudHexToDec3Digit: ; this may be overkill, could have used the 4 digit one...
LDY.b #$90 ; LDY.b #$90
- ; -
CMP.b #100 : !BLT + ; CMP.b #100 : !BLT +
INY ; INY
SBC.b #100 : BRA - ; SBC.b #100 : BRA -
+ ; +
STY $05 : LDY.b #$90 ; Store 100s digit and reset Y ; STY $05 : LDY.b #$90 ; Store 100s digit and reset Y
- ; -
CMP.b #10 : !BLT + ; CMP.b #10 : !BLT +
INY ; INY
SBC.b #10 : BRA - ; SBC.b #10 : BRA -
+ ; +
STY $06 : LDY #$90 ; Store 10s digit and reset Y ; STY $06 : LDY #$90 ; Store 10s digit and reset Y
CMP.b #1 : !BLT + ; CMP.b #1 : !BLT +
- ; -
INY ; INY
DEC : BNE - ; DEC : BNE -
+ ; +
STY $07 ; Store 1s digit ; STY $07 ; Store 1s digit
RTS ;RTS
;================================================================================ ;================================================================================
; 8-bit registers ; 8-bit registers

View File

@@ -165,14 +165,14 @@ ProcessEventItems:
LDA RNGItem : INC : STA RNGItem LDA RNGItem : INC : STA RNGItem
SEP #$10 ; set 8-bit index registers SEP #$10 ; set 8-bit index registers
REP #$20 ; set 16-bit accumulator
LDA GoalItemRequirement : BEQ ++ LDA GoalItemRequirement : BEQ ++
LDA GoalCounter : INC : STA GoalCounter LDA GoalCounter : INC : STA GoalCounter
CMP GoalItemRequirement : !BLT ++ CMP GoalItemRequirement : !BLT ++
LDA TurnInGoalItems : BNE ++ LDA TurnInGoalItems : AND.w #$00FF : BNE ++
JSL.l ActivateGoal JSL.l ActivateGoal
++ ++
SEP #$20 ; set 8-bit accumulator
LDX.b #$01 : BRA .done LDX.b #$01 : BRA .done
+ +
LDX.b #$00 LDX.b #$00
@@ -187,13 +187,6 @@ RTS
AddReceivedItemExpandedGetItem: AddReceivedItemExpandedGetItem:
PHX PHX
;JSR.w ProcessEventItems : CPX.b #$00 : BEQ ++
; ;JSL.l Main_ShowTextMessage_Alt
; LDA GoalCounter : INC : STA GoalCounter
; LDA.b #$01 : STA $7F50XX
; JMP .done
;++
;STA $FFFFFF
LDA $02D8 ; check inventory LDA $02D8 ; check inventory
JSL.l FreeDungeonItemNotice JSL.l FreeDungeonItemNotice
CMP.b #$0B : BNE + ; Bow CMP.b #$0B : BNE + ; Bow
@@ -319,12 +312,14 @@ AddReceivedItemExpandedGetItem:
BRA .multi_collect BRA .multi_collect
+ CMP.b #$6C : BNE + ; Goal Collectable (Multi/Power Star) Alternate Graphic + CMP.b #$6C : BNE + ; Goal Collectable (Multi/Power Star) Alternate Graphic
.multi_collect .multi_collect
LDA GoalItemRequirement : BEQ ++ REP #$20 ; set 16-bit accumulator
LDA GoalCounter : INC : STA GoalCounter LDA.l GoalItemRequirement : BEQ ++
CMP GoalItemRequirement : !BLT ++ LDA.l GoalCounter : INC : STA.l GoalCounter
LDA TurnInGoalItems : BNE ++ CMP.w GoalItemRequirement : !BLT ++
LDA.l TurnInGoalItems : AND.w #$00FF : BNE ++
JSL.l ActivateGoal JSL.l ActivateGoal
++ ++
SEP #$20 ; set 8-bit accumulator
JMP .done JMP .done
+ CMP.b #$6D : BNE + ; Server Request F0 + CMP.b #$6D : BNE + ; Server Request F0
JSL.l ItemGetServiceRequest_F0 JSL.l ItemGetServiceRequest_F0

View File

@@ -201,7 +201,9 @@ RTL
DecrementItemCounter: DecrementItemCounter:
PHA PHA
LDA StatsLocked : BNE + LDA StatsLocked : BNE +
REP #$20
LDA TotalItemCounter : DEC : STA TotalItemCounter LDA TotalItemCounter : DEC : STA TotalItemCounter
SEP #$20
+ +
PLA PLA
RTL RTL
@@ -350,14 +352,15 @@ StatsFinalPrep:
LDA RupeesSpent : !ADD DisplayRupees : STA !RUPEES_COLLECTED LDA RupeesSpent : !ADD DisplayRupees : STA !RUPEES_COLLECTED
LDA RupeesSpent+1 : ADC DisplayRupees+1 : STA !RUPEES_COLLECTED+1 LDA RupeesSpent+1 : ADC DisplayRupees+1 : STA !RUPEES_COLLECTED+1
REP #$20
LDA TotalItemCounter : !SUB ChestsOpened : STA !NONCHEST_COUNTER LDA TotalItemCounter : !SUB ChestsOpened : STA !NONCHEST_COUNTER
.done .done
PLP : PLX : PLA PLP : PLX : PLA
LDA.b #$19 : STA $10 ; thing we wrote over, load triforce room LDA.b #$19 : STA $10 ; thing we wrote over, load triforce room
STZ $11 STZ $11
STZ $B0 STZ $B0
RTL RTL
;-------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------
; Notes: ; Notes:

View File

@@ -805,13 +805,9 @@ org $308165 ; PC 0x180165
GoalItemIcon: GoalItemIcon:
dw #$280E ; #$280D = Star - #$280E = Triforce Piece (default) dw #$280E ; #$280D = Star - #$280E = Triforce Piece (default)
;================================================================================ ;================================================================================
org $308167 ; PC 0x180167 org $308167 ; PC 0x180167-0x180167
GoalItemRequirement: GoalItemRequirement:
db #$00 ; #$00 = Off (default) - #$XX = Require $XX Goal Items - #$FF = Counter-Only dw $0000 ; #$0000 = Off (default) - #$XXXX = Require $XX Goal Items - #$FFFF = Counter-Only
;================================================================================
org $308168 ; PC 0x180168
ByrnaCaveSpikeDamage:
db #$08 ; #$08 = 1 Heart (default) - #$02 = 1/4 Heart
;================================================================================ ;================================================================================
org $308169 ; PC 0x180169 org $308169 ; PC 0x180169
AgahnimDoorStyle: AgahnimDoorStyle:
@@ -934,7 +930,11 @@ org $308194 ; PC 0x180194
TurnInGoalItems: TurnInGoalItems:
db #$01 ; #$00 = Instant win if last goal item collected. $01 = (Default) must turn in goal items db #$01 ; #$00 = Instant win if last goal item collected. $01 = (Default) must turn in goal items
;-------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------
; 0x180195 - 0x1801FF (unused) org $308195 ; PC 0x180195
ByrnaCaveSpikeDamage:
db #$08 ; #$08 = 1 Heart (default) - #$02 = 1/4 Heart
;--------------------------------------------------------------------------------
; 0x180196 - 0x1801FF (unused)
;================================================================================ ;================================================================================
org $308200 ; PC 0x180200 - 0x18020B org $308200 ; PC 0x180200 - 0x18020B
RedClockAmount: RedClockAmount: