Introduce bound to QS loop to prevent infinite loop on last bomb loss

Move !INFINITE_BOMB define to ram.asm, replace with labels
This commit is contained in:
cassidoxa
2022-10-23 22:02:36 -04:00
parent 0e87fb3bc4
commit cafb0908a0
6 changed files with 38 additions and 33 deletions

View File

@@ -1,47 +1,38 @@
!INFINITE_BOMBS = "$7F50C9"
IsItemAvailable:
LDA !INFINITE_BOMBS : BEQ .finite
.infinite
CPX.b #$04 : BNE .finite
LDA.b #$01 : RTL
.finite
LDA EquipmentWRAM-1, X
RTL
LoadBombCount:
LDA !INFINITE_BOMBS : BNE .infinite
LDA.l InfiniteBombs : BNE .infinite
.finite
LDA BombsEquipment
LDA.l BombsEquipment
.infinite
RTL
LoadBombCount16:
LDA !INFINITE_BOMBS : AND.w #$00FF : BNE .infinite
LDA.l InfiniteBombs : AND.w #$00FF : BNE .infinite
.finite
LDA BombsEquipment
LDA.l BombsEquipment
.infinite
RTL
StoreBombCount:
PHA : LDA !INFINITE_BOMBS : BEQ .finite
PHA : LDA.l InfiniteBombs : BEQ .finite
.infinite
PLA : LDA.b #$01 : RTL
.finite
PLA : STA BombsEquipment
PLA : STA.l BombsEquipment
RTL
SearchForEquippedItem:
LDA !INFINITE_BOMBS : BEQ +
LDA.l InfiniteBombs : BEQ +
LDA.b #$01 : LDX.b #$00 : RTL
+
LDA BowEquipment ; thing we wrote over
LDA.l BowEquipment ; thing we wrote over
RTL
!INFINITE_ARROWS = "$7F50C8"
DecrementArrows:
LDA !INFINITE_ARROWS : BNE .infinite
LDA.l !INFINITE_ARROWS : BNE .infinite
LDA.l ArrowMode : BNE .rupees : BRA .normal
.infinite
LDA.b #$01 : RTL
.normal
LDA CurrentArrows : BEQ .done
DEC : STA CurrentArrows : INC
LDA.l CurrentArrows : BEQ .done
DEC : STA.l CurrentArrows : INC
BRA .done
.rupees
REP #$20
@@ -57,11 +48,11 @@ DecrementArrows:
.shoot_arrow
PHX
REP #$20
LDA CurrentRupees : BEQ +
PHA : LDA BowEquipment : DEC : AND #$0002 : TAX : PLA
LDA.l CurrentRupees : BEQ +
PHA : LDA.l BowEquipment : DEC : AND.w #$0002 : TAX : PLA
!SUB.l ArrowModeWoodArrowCost, X ; CMP.w #$0000
BMI .not_enough_money
STA CurrentRupees : LDA.w #$0001 : BRA +
STA.l CurrentRupees : LDA.w #$0001 : BRA +
.not_enough_money
LDA.w #$0000
+
@@ -72,17 +63,17 @@ DecrementArrows:
RTL
ArrowGame:
LDA $0B99 : BEQ +
LDA.w $0B99 : BEQ +
DEC $0B99 ; reduce minigame arrow count
LDA.l ArrowMode : BNE .rupees
.normal
LDA CurrentArrows : INC #2 : STA CurrentArrows ; increment arrow count (by 2 for some reason)
LDA.l CurrentArrows : INC #2 : STA.l CurrentArrows ; increment arrow count (by 2 for some reason)
RTL
.rupees
PHX
REP #$20 ; set 16-bit accumulator
LDA BowEquipment : DEC : AND #$0002 : TAX
LDA CurrentRupees : !ADD.l ArrowModeWoodArrowCost, X : STA CurrentRupees
LDA.l BowEquipment : DEC : AND #$0002 : TAX
LDA.l CurrentRupees : !ADD.l ArrowModeWoodArrowCost, X : STA.l CurrentRupees
SEP #$20 ; set 8-bit accumulator
PLX
+