Merge branch 'sram_rework' into dr_sram
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
;================================================================================
|
||||
; Utility Functions
|
||||
;================================================================================
|
||||
!PROGRESSIVE_SHIELD = "$7EF416" ; ss-- ----
|
||||
;--------------------------------------------------------------------------------
|
||||
; GetSpriteTile
|
||||
; in: A - Loot ID
|
||||
; out: A - Sprite GFX ID
|
||||
@@ -46,7 +44,7 @@ GetSpriteID:
|
||||
RTL
|
||||
.specialHandling
|
||||
CMP.b #$F9 : BNE ++ ; Progressive Magic
|
||||
LDA.l $7EF37B : BNE +++
|
||||
LDA.l MagicConsumption : BNE +++
|
||||
LDA.b #$3B : RTL ; Half Magic
|
||||
+++
|
||||
LDA.b #$3C : RTL ; Quarter Magic
|
||||
@@ -56,18 +54,18 @@ RTL
|
||||
JSL.l GetRNGItemMulti : JMP GetSpriteID
|
||||
++ CMP.b #$FD : BNE ++ ; Progressive Armor
|
||||
LDA !MULTIWORLD_SPRITEITEM_PLAYER_ID : BNE +
|
||||
LDA $7EF35B : CMP.l ProgressiveArmorLimit : !BLT + ; Progressive Armor Limit
|
||||
LDA ArmorEquipment : CMP.l ProgressiveArmorLimit : !BLT + ; Progressive Armor Limit
|
||||
LDA.l ProgressiveArmorReplacement
|
||||
JMP GetSpriteID
|
||||
+
|
||||
LDA.b #$04 : RTL
|
||||
++ CMP.b #$FE : BNE ++ ; Progressive Sword
|
||||
LDA !MULTIWORLD_SPRITEITEM_PLAYER_ID : BNE .skipswordlimit
|
||||
LDA $7EF359
|
||||
LDA HighestSword
|
||||
CMP.l ProgressiveSwordLimit : !BLT + ; Progressive Sword Limit
|
||||
LDA.l ProgressiveSwordReplacement
|
||||
JMP GetSpriteID
|
||||
.skipswordlimit : LDA $7EF359
|
||||
.skipswordlimit : LDA SwordEquipment
|
||||
+ : CMP.b #$FF : BNE + ; Swordless
|
||||
LDA.b #$43 : RTL
|
||||
+ : CMP.b #$00 : BNE + ; No Sword
|
||||
@@ -81,11 +79,11 @@ RTL
|
||||
+
|
||||
++ : CMP.b #$FF : BNE ++ ; Progressive Shield
|
||||
LDA !MULTIWORLD_SPRITEITEM_PLAYER_ID : BNE .skipshieldlimit
|
||||
LDA !PROGRESSIVE_SHIELD : AND #$C0 : LSR #6
|
||||
LDA HighestShield
|
||||
CMP.l ProgressiveShieldLimit : !BLT + ; Progressive Shield Limit
|
||||
LDA.l ProgressiveShieldReplacement
|
||||
JMP GetSpriteID
|
||||
.skipshieldlimit : LDA !PROGRESSIVE_SHIELD : AND #$C0 : LSR #6
|
||||
.skipshieldlimit : LDA.l HighestShield
|
||||
+ : CMP.b #$00 : BNE + ; No Shield
|
||||
LDA.b #$2D : RTL
|
||||
+ : CMP.b #$01 : BNE + ; Fighter Shield
|
||||
@@ -94,11 +92,11 @@ RTL
|
||||
LDA.b #$2E : RTL
|
||||
++ : CMP.b #$F8 : BNE ++ ; Progressive Bow
|
||||
LDA !MULTIWORLD_SPRITEITEM_PLAYER_ID : BNE .skipbowlimit
|
||||
LDA $7EF340 : INC : LSR
|
||||
LDA BowEquipment : INC : LSR
|
||||
CMP.l ProgressiveBowLimit : !BLT +
|
||||
LDA.l ProgressiveBowReplacement
|
||||
JMP GetSpriteID
|
||||
.skipbowlimit : LDA $7EF340 : INC : LSR
|
||||
.skipbowlimit : LDA BowEquipment : INC : LSR
|
||||
+ : CMP.b #$00 : BNE + ; No Bow
|
||||
LDA.b #$29 : RTL
|
||||
+ ; Any Bow
|
||||
@@ -194,7 +192,7 @@ GetSpritePalette:
|
||||
RTL
|
||||
.specialHandling
|
||||
CMP.b #$FD : BNE ++ ; Progressive Sword
|
||||
LDA $7EF359
|
||||
LDA HighestSword
|
||||
CMP.l ProgressiveSwordLimit : !BLT + ; Progressive Sword Limit
|
||||
LDA.l ProgressiveSwordReplacement
|
||||
JMP GetSpritePalette
|
||||
@@ -207,7 +205,7 @@ RTL
|
||||
+ ; Everything Else
|
||||
LDA.b #$08 : RTL
|
||||
++ : CMP.b #$FE : BNE ++ ; Progressive Shield
|
||||
LDA !PROGRESSIVE_SHIELD : AND #$C0 : LSR #6
|
||||
LDA HighestShield
|
||||
CMP.l ProgressiveShieldLimit : !BLT + ; Progressive Shield Limit
|
||||
LDA.l ProgressiveShieldReplacement
|
||||
JMP GetSpritePalette
|
||||
@@ -218,7 +216,8 @@ RTL
|
||||
+ ; Everything Else
|
||||
LDA.b #$08 : RTL
|
||||
++ : CMP.b #$FF : BNE ++ ; Progressive Armor
|
||||
LDA $7EF35B : CMP.l ProgressiveArmorLimit : !BLT + ; Progressive Armor Limit
|
||||
LDA HighestMail
|
||||
CMP.l ProgressiveArmorLimit : !BLT + ; Progressive Armor Limit
|
||||
LDA.l ProgressiveArmorReplacement
|
||||
JMP GetSpritePalette
|
||||
+ : CMP.b #$00 : BNE + ; Green Tunic
|
||||
@@ -226,12 +225,12 @@ RTL
|
||||
+ ; Everything Else
|
||||
LDA.b #$02 : RTL
|
||||
++ : CMP.b #$FC : BNE ++ ; Progressive Gloves
|
||||
LDA $7EF354 : BNE + ; No Gloves
|
||||
LDA GloveEquipment : BNE + ; No Gloves
|
||||
LDA.b #$02 : RTL
|
||||
+ ; Everything Else
|
||||
LDA.b #$08 : RTL
|
||||
++ : CMP.b #$F8 : BNE ++ ; Progressive Bow
|
||||
LDA $7EF340 : INC : LSR
|
||||
LDA BowEquipment : INC : LSR
|
||||
CMP.l ProgressiveBowLimit : !BLT +
|
||||
LDA.l ProgressiveBowReplacement
|
||||
JMP GetSpritePalette
|
||||
@@ -319,19 +318,19 @@ IsNarrowSprite:
|
||||
+ : JMP .continue
|
||||
.notBottle
|
||||
CMP.b #$5E : BNE ++ ; Progressive Sword
|
||||
LDA $7EF359 : CMP.l ProgressiveSwordLimit : !BLT + ; Progressive Sword Limit
|
||||
LDA HighestSword : CMP.l ProgressiveSwordLimit : !BLT + ; Progressive Sword Limit
|
||||
LDA.l ProgressiveSwordReplacement
|
||||
JSL.l IsNarrowSprite
|
||||
JMP .done
|
||||
+ : JMP .continue
|
||||
++ CMP.b #$5F : BNE ++ ; Progressive Shield
|
||||
LDA !PROGRESSIVE_SHIELD : AND #$C0 : BNE + : SEC : JMP .done ; No Shield
|
||||
+ : LSR #6 : CMP.l ProgressiveShieldLimit : !BLT .continue
|
||||
LDA HighestShield : BNE + : JMP .done ; No Shield
|
||||
+ : CMP.l ProgressiveShieldLimit : !BLT .continue
|
||||
LDA.l ProgressiveShieldReplacement
|
||||
JSL.l IsNarrowSprite
|
||||
JMP .done
|
||||
++ CMP.b #$60 : BNE ++ ; Progressive Armor
|
||||
LDA $7EF35B : CMP.l ProgressiveArmorLimit : !BLT .continue
|
||||
LDA HighestMail : CMP.l ProgressiveArmorLimit : !BLT .continue
|
||||
LDA.l ProgressiveArmorReplacement
|
||||
JSL.l IsNarrowSprite
|
||||
JMP .done
|
||||
@@ -342,7 +341,7 @@ IsNarrowSprite:
|
||||
JSL.l GetRNGItemMulti
|
||||
++ CMP.b #$64 : BEQ + ; Progressive Bow
|
||||
CMP.b #$65 : BNE .continue ; Progressive Bow (alt)
|
||||
+ : LDA $7EF340 : INC : LSR
|
||||
+ : LDA BowEquipment : INC : LSR
|
||||
CMP.l ProgressiveBowLimit : !BLT +
|
||||
LDA.l ProgressiveBowReplacement
|
||||
JSL.l IsNarrowSprite
|
||||
@@ -682,19 +681,19 @@ RTL
|
||||
; out: A(b) - sum of bits
|
||||
; caller is responsible for setting 8-bit mode and preserving X and Y
|
||||
;--------------------------------------------------------------------------------
|
||||
CountBits:
|
||||
PHX
|
||||
TAX ; Save a copy of value
|
||||
LSR #4 ; Shift down hi nybble, Leave <3> in C
|
||||
PHA ; And save <7:4> in Stack
|
||||
TXA ; Recover value
|
||||
AND.b #$07 ; Put out <2:0> in X
|
||||
TAX ; And save in X
|
||||
LDA.l NybbleBitCounts, X ; Fetch count for <2:0>
|
||||
PLX ; get <7:4>
|
||||
ADC.l NybbleBitCounts, X ; Add count for S & C
|
||||
PLX
|
||||
RTL
|
||||
;CountBits:
|
||||
; PHX
|
||||
; TAX ; Save a copy of value
|
||||
; LSR #4 ; Shift down hi nybble, Leave <3> in C
|
||||
; PHA ; And save <7:4> in Stack
|
||||
; TXA ; Recover value
|
||||
; AND.b #$07 ; Put out <2:0> in X
|
||||
; TAX ; And save in X
|
||||
; LDA.l NybbleBitCounts, X ; Fetch count for <2:0>
|
||||
; PLX ; get <7:4>
|
||||
; ADC.l NybbleBitCounts, X ; Add count for S & C
|
||||
; PLX
|
||||
;RTL
|
||||
|
||||
; Look up table of bit counts in the values $00-$0F
|
||||
NybbleBitCounts:
|
||||
|
||||
Reference in New Issue
Block a user