1 Commits

Author SHA1 Message Date
0263546e46 Fix mixing progressive/non-progressive swords and shields 2022-10-08 15:36:41 -07:00
6 changed files with 28 additions and 61 deletions

View File

@@ -151,13 +151,13 @@ org $30B414 ; PC 0x183414-0x183416
InitMapOverlay: dw $0000
org $30B417 ; PC 0x183417
InitHighestSword: db $00
InitProgressiveSwords: db $00
org $30B414 ; PC 0x183418-0x183419
InitGoalCounter: dw $0000
org $30B422 ; PC 0x183422
InitHighestShield: db $00
InitProgressiveShields: db $00
org $30B428 ; PC 0x183428
InitMapsCompasses: db $00

View File

@@ -326,33 +326,16 @@ AddInventory:
.itemCounts
CPY.b #$00 : BNE + ; Fighter's Sword & Fighter's Shield
LDX #$01
JSR .incrementSword
JSR .incrementShield
JSR .stampSword
JMP .done
+ CPY.b #$01 : BNE + ; Master Sword
LDX #$02
JSR .incrementSword
JSR .stampSword
JMP .done
+ CPY.b #$02 : BNE + ; Tempered Sword
LDX #$03
JSR .incrementSword
JSR .stampSword
JMP .done
+ CPY.b #$03 : BNE + ; Golden Sword
LDX #$04
JSR .incrementSword
JMP .done
+ CPY.b #$04 : BNE + ; Fighter's Shield
LDX #$01
JSR .incrementShield
JMP .done
+ CPY.b #$05 : BNE + ; Red Shield
LDX #$02
JSR .incrementShield
JMP .done
+ CPY.b #$06 : BNE + ; Mirror Shield
LDX #$03
JSR .incrementShield
JSR .stampSword
JMP .done
+ CPY.b #$07 : !BLT + ; Items $07 - $0D
CPY.b #$0E : !BGE +
@@ -452,8 +435,7 @@ AddInventory:
JSR .incrementY
JMP .done
+ CPY.b #$49 : BNE + ; Fighter's Sword
LDX #$01
JSR .incrementSword
JSR .stampSword
JMP .done
+ CPY.b #$4A : BNE + ; Flute (Active)
JSR .stampFlute
@@ -472,8 +454,7 @@ AddInventory:
JSR .incrementCapacity
JMP .done
+ CPY.b #$50 : BNE + ; Master Sword (Safe)
LDX #$02
JSR .incrementSword
JSR .stampSword
JMP .done
+ CPY.b #$51 : BNE + ; 5 Bomb Capacity Upgrade
LDX #$02
@@ -491,12 +472,11 @@ AddInventory:
JSR .incrementBow
JMP .done
+ CPY.b #$5E : BNE + ; Progressive Sword
LDA SwordEquipment : INC : TAX
JSR .incrementSword
JSR .stampSword
LDA.l ProgressiveSwords : INC : STA.l ProgressiveSwords
JMP .done
+ CPY.b #$5F : BNE + ; Progressive Shield
LDA ShieldEquipment : INC : TAX
JSR .incrementShield
LDA.l ProgressiveShields : INC : STA.l ProgressiveShields
JMP .done
+ CPY.b #$60 : BNE + ; Progressive Armor
LDA ArmorEquipment : INC : TAX
@@ -573,21 +553,6 @@ RTS
SEP #$20 ; set 8-bit accumulator
RTS
.incrementSword
JSR .stampSword
LDA HighestSword
INC : STA $04 : CPX $04 : !BLT + ; don't increment unless we're getting a better sword
TXA : STA HighestSword
+
RTS
.incrementShield
LDA HighestShield
INC : STA $04 : CPX $04 : !BLT + ; don't increment unless we're getting a better shield
TXA : STA HighestShield
+
RTS
.incrementBow
LDA BowEquipment : BNE .dontCount ; Don't increment Y item count for extra bows
.incrementY

View File

@@ -60,7 +60,7 @@ RTS
RTS
.isSword
PHA
LDA HighestSword : STA $04
LDA SwordEquipment : STA $04
TYA ; load sword item
CMP.b #$49 : BNE + : LDA.b #$00 : + ; convert extra fighter's sword to normal one
CMP.b #$50 : BNE + : LDA.b #$01 : + ; convert extra master sword to normal one
@@ -73,9 +73,11 @@ RTS
JMP .done
.isUncleSwordShield
PHA
LDA HighestSword : STA [$00] ; already set to 1 if we had no sword, always keep highest
; set sword to 1 if current sword is 0
LDA [$00] : BNE + : LDA.b #$01 : STA [$00] : +
INC $00
LDA HighestShield : STA [$00]
; set shield to 1 if current shield is 0
LDA [$00] : BNE + : LDA.b #$01 : STA [$00] : +
PLA
RTS
;================================================================================

View File

@@ -449,7 +449,7 @@ AddReceivedItemExpanded:
LDA.b #$4F : STA $02D8
+++ : JMP .done
++ : CMP.b #$5E : BNE ++ ; Progressive Sword
LDA SwordEquipment : CMP.l ProgressiveSwordLimit : !BLT +
LDA ProgressiveSwords : CMP.l ProgressiveSwordLimit : !BLT +
LDA.l ProgressiveSwordReplacement : STA $02D8 : JMP .done
+ : CMP.b #$00 : BNE + ; No Sword
LDA.b #$49 : STA $02D8 : JMP .done
@@ -460,7 +460,7 @@ AddReceivedItemExpanded:
+ ; Everything Else
LDA.b #$03 : STA $02D8 : JMP .done
++ : CMP.b #$5F : BNE ++ ; Progressive Shield
LDA ShieldEquipment : CMP.l ProgressiveShieldLimit : !BLT +
LDA ProgressiveShields : CMP.l ProgressiveShieldLimit : !BLT +
LDA.l ProgressiveShieldReplacement : STA $02D8 : JMP .done
+ : CMP.b #$00 : BNE + ; No Shield
LDA.b #$04 : STA $02D8 : JMP .done

View File

@@ -253,7 +253,7 @@ IgnoreFaeries: ;
HasGroveItem: ;
GeneralFlags: skip 1 ; - - h - - i - g (bitfield)
; h = HUD Flag | i = ignore faeries | g = has diggable grove item
HighestSword: skip 1 ; Highest sword level (integer)
ProgressiveSwords: skip 1 ; Number of Progressive Swords obatined (integer)
GoalCounter: skip 2 ; Goal items collected (16-bit integer)
ProgrammableItemOne: skip 2 ; \ Reserved for programmable items
ProgrammableItemTwo: skip 2 ; |
@@ -261,7 +261,7 @@ ProgrammableItemThree: skip 2 ; /
BonkCounter: skip 1 ; Number of times the player has bonked (integer)
YAItemCounter: skip 1 ; y y y y y a a a (packed integers)
; Number of Y and A items collected represented as packed integers
HighestShield: skip 1 ; Highest Shield level
ProgressiveShields: skip 1 ; Number of Progressive Shields obtained
TotalItemCounter: skip 2 ; Total items collected (integer)
SwordBossKills: skip 2 ; t t t t g g g g f f f f m m m m (packed integers)
; t = Tempered Sword boss kills | g = Gold Sword boss kills
@@ -547,14 +547,14 @@ endmacro
%assertSRAM(IgnoreFaeries, $7EF416)
%assertSRAM(HasGroveItem, $7EF416)
%assertSRAM(GeneralFlags, $7EF416)
%assertSRAM(HighestSword, $7EF417)
%assertSRAM(ProgressiveSwords, $7EF417)
%assertSRAM(GoalCounter, $7EF418)
%assertSRAM(ProgrammableItemOne, $7EF41A)
%assertSRAM(ProgrammableItemTwo, $7EF41C)
%assertSRAM(ProgrammableItemThree, $7EF41E)
%assertSRAM(BonkCounter, $7EF420)
%assertSRAM(YAItemCounter, $7EF421)
%assertSRAM(HighestShield, $7EF422)
%assertSRAM(ProgressiveShields, $7EF422)
%assertSRAM(TotalItemCounter, $7EF423)
%assertSRAM(SwordBossKills, $7EF425)
%assertSRAM(BigKeysBigChests, $7EF427)

View File

@@ -58,7 +58,7 @@ RTL
+
LDA.b #$04 : RTL
++ CMP.b #$FE : BNE ++ ; Progressive Sword
LDA HighestSword
LDA ProgressiveSwords
CMP.l ProgressiveSwordLimit : !BLT + ; Progressive Sword Limit
LDA.l ProgressiveSwordReplacement
JMP GetSpriteID
@@ -72,7 +72,7 @@ RTL
LDA.b #$46 : RTL
+
++ : CMP.b #$FF : BNE ++ ; Progressive Shield
LDA HighestShield
LDA ProgressiveShields
CMP.l ProgressiveShieldLimit : !BLT + ; Progressive Shield Limit
LDA.l ProgressiveShieldReplacement
JMP GetSpriteID
@@ -181,7 +181,7 @@ GetSpritePalette:
RTL
.specialHandling
CMP.b #$FD : BNE ++ ; Progressive Sword
LDA HighestSword
LDA ProgressiveSwords
CMP.l ProgressiveSwordLimit : !BLT + ; Progressive Sword Limit
LDA.l ProgressiveSwordReplacement
JMP GetSpritePalette
@@ -194,7 +194,7 @@ RTL
+ ; Everything Else
LDA.b #$08 : RTL
++ : CMP.b #$FE : BNE ++ ; Progressive Shield
LDA HighestShield
LDA ProgressiveShields
CMP.l ProgressiveShieldLimit : !BLT + ; Progressive Shield Limit
LDA.l ProgressiveShieldReplacement
JMP GetSpritePalette
@@ -306,13 +306,13 @@ IsNarrowSprite:
+ : JMP .continue
.notBottle
CMP.b #$5E : BNE ++ ; Progressive Sword
LDA HighestSword : CMP.l ProgressiveSwordLimit : !BLT + ; Progressive Sword Limit
LDA ProgressiveSwords : CMP.l ProgressiveSwordLimit : !BLT + ; Progressive Sword Limit
LDA.l ProgressiveSwordReplacement
JSL.l IsNarrowSprite
JMP .done
+ : JMP .continue
++ CMP.b #$5F : BNE ++ ; Progressive Shield
LDA HighestShield : BNE + : JMP .done ; No Shield
LDA ProgressiveShields : BNE + : JMP .done ; No Shield
+ : CMP.l ProgressiveShieldLimit : !BLT .continue
LDA.l ProgressiveShieldReplacement
JSL.l IsNarrowSprite