8 Commits

Author SHA1 Message Date
0263546e46 Fix mixing progressive/non-progressive swords and shields 2022-10-08 15:36:41 -07:00
Lexi Rose
48ccf03ac8 Merge pull request #170 from cassidoxa/ammo_capacity
Combine starting max ammo and capacity upgrade in SRAM into single, flat ammo capacity values
2022-10-01 08:08:26 -05:00
cassidoxa
f8d9be201a tables.asm: Add GFX pointer to table in utilities.asm 2022-09-09 19:30:16 -04:00
cassidoxa
031e3965b2 Requires frontend changes
Change SRAM ammo capacity upgrades to flatly represent max capacity
2022-08-08 13:42:19 -04:00
Lexi Rose
aba3ec930d Merge pull request #169 from cassidoxa/validate_sram
Compute checksum for extended SRAM
2022-08-01 08:40:19 -05:00
cassidoxa
95ee31f7c9 Remove some hard coded addresses for MVN instructions 2022-07-29 22:04:13 -04:00
cassidoxa
d8846a4ba9 Add backup save that gets checked and loaded if main save is corrupt
Add suffixes to instructions in save.asm
Disable HDMA, NMI, and joypad during extended save DMA
2022-07-29 20:57:54 -04:00
cassidoxa
10079a539b Compute checksum for extended SRAM
Validate SRAM on file screen load and delete if checksum incorrect
2022-07-25 22:19:06 -04:00
11 changed files with 306 additions and 241 deletions

View File

@@ -2,36 +2,26 @@
; Capacity Logic
;================================================================================
IncrementBombs:
LDA BombCapacityUpgrades ; get bomb upgrades
!ADD.l StartingMaxBombs : BEQ + ; Skip if we can't have bombs
DEC
CMP BombsEquipment
!BLT +
LDA BombsEquipment
CMP.b #99 : !BGE +
INC : STA BombsEquipment
+
LDA.l BombCapacity : BEQ + ; Skip if we can't have bombs
DEC
CMP.l BombsEquipment : !BLT +
LDA.l BombsEquipment
CMP.b #99 : !BGE +
INC : STA.l BombsEquipment
+
RTL
;--------------------------------------------------------------------------------
IncrementArrows:
LDA ArrowCapacityUpgrades ; get arrow upgrades
!ADD.l StartingMaxArrows : DEC
CMP CurrentArrows
!BLT +
LDA CurrentArrows
CMP.b #99 : !BGE +
INC : STA CurrentArrows
+
LDA.l ArrowCapacity : DEC
CMP.l CurrentArrows : !BLT +
LDA.l CurrentArrows
CMP.b #99 : !BGE +
INC : STA.l CurrentArrows
+
RTL
;--------------------------------------------------------------------------------
CompareBombsToMax:
LDA BombCapacityUpgrades ; get bomb upgrades
!ADD.l StartingMaxBombs
CMP BombsEquipment
LDA.l BombCapacity
CMP.l BombsEquipment
RTL
;--------------------------------------------------------------------------------

View File

@@ -89,16 +89,17 @@ OnAga2Defeated:
;--------------------------------------------------------------------------------
OnFileCreation:
; Copy initial SRAM state from ROM to cart SRAM
; If the inital SRAM table is move these addresses must be changed
PHB
LDA.w #$03D7 ; \
LDX.w #$B000 ; | Copies from beginning of inital sram table up to file name
LDY.w #$0000 ; | (exclusively)
MVN $70, $30 ; /
; Skip file name and validity value
LDA.w #$010C ; \
LDX.w #$B3E3 ; | Rando-Specific Assignments & Game Stats block
LDY.w #$03E3 ; |
MVN $70, $30 ; /
LDA.w #$03D7 ; \
LDX.w #$B000 ; | Copies from beginning of inital sram table up to file name
LDY.w #$0000 ; | (exclusively)
MVN SRAMBank, SRAMTableBank ; /
; Skip file name and validity value
LDA.w #$010C ; \
LDX.w #$B3E3 ; | Rando-Specific Assignments & Game Stats block
LDY.w #$03E3 ; |
MVN SRAMBank, SRAMTableBank ; /
PLB
; resolve instant post-aga if standard

View File

@@ -188,7 +188,7 @@ JSL.l AltBufferTable : NOP #8 ; Delete screen
;--------------------------------------------------------------------------------
org $0CCCCC ;<- 64CCC - Bank0C.asm : 1628 (JSL Intro_ValidateSram) / Bank02.asm : 75 (REP #$30)
; Explanation: In JP 1.0 the code for Intro_ValidateSram was inline in Bank 0C
JML.l Validate_SRAM ;(Return via RTL. Original code JML'd to Intro_LoadSpriteStats which returns with RTL, but we want to skip that)
JML.l ValidateSRAM ;(Return via RTL. Original code JML'd to Intro_LoadSpriteStats which returns with RTL, but we want to skip that)
org $0CCD57 ;<- 64D57 - Bank0C.asm :
RTL ;Just in case anybody ever removes the previous hook
;--------------------------------------------------------------------------------
@@ -299,12 +299,17 @@ BRA +
;================================================================================
; Extended SRAM Save file
;--------------------------------------------------------------------------------
org $0ccf08 ; <- Bank0C.asm : 2036 (LDA.w #$0007 : STA $7EC00D : STA $7EC013)
org $0CCF08 ; <- Bank0C.asm : 2036 (LDA.w #$0007 : STA $7EC00D : STA $7EC013)
JSL CopyExtendedSaveFileToWRAM
;--------------------------------------------------------------------------------
org $008998 ; <- Bank00.asm : 1296 (LDX.w #$0000)
JSL CopyExtendedWRAMSaveFileToSRAM
;--------------------------------------------------------------------------------
org $00899C ; <- bank_00.asm : #_00899C (CLC)
JSL WriteSaveChecksumAndBackup
LDA.w #$01F3 : TCS : SEP #$30 : PLB : RTL ; Get the stack and data bank correct
padbyte $FF : pad $0089C2 ; Fill adjacent free rom forward. See bank_00.asm: #_0089C2
;--------------------------------------------------------------------------------
org $0CD7AB ; <- Bank0C.asm : 3342 (STA $700400, X)
JSL.l ClearExtendedSaveFile
;--------------------------------------------------------------------------------
@@ -2807,4 +2812,4 @@ if !FEATURE_NEW_TEXT
JSL RenderCharSetColorExtended_init
org $0EF285
JSL RenderCharSetColorExtended_close : NOP
endif
endif

View File

@@ -15,6 +15,7 @@ fillword $0000 ; Zero out the table
fill $500 ;
org $30B000 ; PC 0x183000
InitSRAMTable:
InitRoomDataWRAM:
org $30B060 ; PC 0x183060
InitATAltarRoom: dw $0000 ; aga curtains
@@ -81,8 +82,8 @@ StartingHealth: db $18 ; PC 0x18336C
StartingMaximumHealth: db $18 ; PC 0x18336D
StartingMagic: skip 1 ; PC 0x18336E
StartingSmallKeys: db $FF ; PC 0x18336F
StartingBombCapacityUpgrade: skip 1 ; PC 0x183370
StartingArrowCapacityUpgrade: skip 1 ; PC 0x183371
StartingBombCapacity: db $0A ; PC 0x183370
StartingArrowCapacity: db $1E ; PC 0x183371
InitHeartsFiller: skip 1 ; PC 0x183372
InitMagicFiller: skip 1 ; PC 0x183373
StartingPendants: skip 1 ; PC 0x183374
@@ -150,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
@@ -695,7 +660,7 @@ RTS
;--------------------------------------------------------------------------------
Link_ReceiveItem_HUDRefresh:
LDA BombsEquipment : BNE + ; skip if we have bombs
LDA BombCapacityUpgrades : !ADD.l StartingMaxBombs : BEQ + ; skip if we can't have bombs
LDA BombCapacity : BEQ + ; skip if we can't have bombs
LDA BombsFiller : BEQ + ; skip if we are filling no bombs
DEC : STA BombsFiller ; decrease bomb fill count
LDA.b #$01 : STA BombsEquipment ; increase actual bomb count
@@ -712,7 +677,7 @@ RTL
HandleBombAbsorbtion:
STA BombsFiller ; thing we wrote over
LDA $0303 : BNE + ; skip if we already have some item selected
LDA BombCapacityUpgrades : !ADD.l StartingMaxBombs : BEQ + ; skip if we can't have bombs
LDA BombCapacity : BEQ + ; skip if we can't have bombs
LDA.b #$04 : STA $0202 ; set selected item to bombs
LDA.b #$01 : STA $0303 ; set selected item to bombs
JSL.l HUD_RebuildLong

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

@@ -208,13 +208,11 @@ AddReceivedItemExpandedGetItem:
LDA BowTracking : ORA #$40 : STA BowTracking ; mark silver bow on y-toggle
JMP .done
+ CMP.b #$4C : BNE + ; 50 bombs
;LDA.b #$07 : STA BombCapacityUpgrades ; upgrade bombs
LDA.b #50 : !SUB.l StartingMaxBombs : STA BombCapacityUpgrades ; upgrade bombs
LDA.b #50 : STA BombCapacity ; upgrade bombs
LDA.b #50 : STA BombsFiller ; fill bombs
JMP .done
+ CMP.b #$4D : BNE + ; 70 arrows
;LDA #$07 : STA ArrowCapacityUpgrades ; upgrade arrows
LDA.b #70 : !SUB.l StartingMaxArrows : STA ArrowCapacityUpgrades ; upgrade arrows
LDA.b #70 : STA ArrowCapacity ; upgrade arrows
LDA.b #70 : STA ArrowsFiller ; fill arrows
JMP .done
+ CMP.b #$4E : BNE + ; 1/2 magic
@@ -232,19 +230,19 @@ AddReceivedItemExpandedGetItem:
LDA.b #$02 : STA SwordEquipment ; set master sword
JMP .done
+ CMP.b #$51 : BNE + ; +5 Bombs
LDA BombCapacityUpgrades : !ADD.b #$05 : STA BombCapacityUpgrades ; upgrade bombs +5
LDA BombCapacity : !ADD.b #$05 : STA BombCapacity ; upgrade bombs +5
LDA.l Upgrade5BombsRefill : STA BombsFiller ; fill bombs
JMP .done
+ CMP.b #$52 : BNE + ; +10 Bombs
LDA BombCapacityUpgrades : !ADD.b #$0A : STA BombCapacityUpgrades ; upgrade bombs +10
LDA BombCapacity : !ADD.b #$0A : STA BombCapacity ; upgrade bombs +10
LDA.l Upgrade10BombsRefill : STA BombsFiller ; fill bombs
JMP .done
+ CMP.b #$53 : BNE + ; +5 Arrows
LDA ArrowCapacityUpgrades : !ADD.b #$05 : STA ArrowCapacityUpgrades ; upgrade arrows +5
LDA ArrowCapacity : !ADD.b #$05 : STA ArrowCapacity ; upgrade arrows +5
LDA.l Upgrade5ArrowsRefill : STA ArrowsFiller ; fill arrows
JMP .done
+ CMP.b #$54 : BNE + ; +10 Arrows
LDA ArrowCapacityUpgrades : !ADD.b #$0A : STA ArrowCapacityUpgrades ; upgrade arrows +10
LDA ArrowCapacity : !ADD.b #$0A : STA ArrowCapacity ; upgrade arrows +10
LDA.l Upgrade10ArrowsRefill : STA ArrowsFiller ; fill arrows
JMP .done
+ CMP.b #$55 : BNE + ; Programmable Object 1
@@ -451,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
@@ -462,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

297
save.asm
View File

@@ -1,129 +1,218 @@
;--------------------------------------------------------------------------------
Validate_SRAM:
REP #$30 ; vanilla behavior from $0CCD45, includes prize pack reset after save and quit
LDX #$00FE : -
STZ $0D00, X
STZ $0E00, X
STZ $0F00, X
DEX #2
BPL -
WriteSaveChecksumAndBackup:
LDX.w #$0000 : TXA : - ; Checksum first $04FE bytes
CLC : ADC.l SaveDataWRAM, X
INX #2
CPX.w #$04FE : BNE -
LDX.w #$0000 : - ; Checksum extended save data
CLC : ADC.l ExtendedFileNameWRAM, X
INX #2
CPX.w #$0FFE : BNE -
STA.b $00
LDA.w #$5A5A
SEC : SBC.b $00
STA.l InverseChecksumSRAM
PHB
LDA.w #$14FF ; \
LDX.w #CartridgeSRAM&$FFFF ; | Copies $1500 bytes from beginning of cart SRAM to
LDY.w #SaveBackupSRAM&$FFFF ; | $704000
MVN SRAMBank, SRAMBank ; /
PLB
RTL
;--------------------------------------------------------------------------------
ValidateSRAM:
REP #$30
LDX.w #$0000 : TXA : - ; Checksum first $04FE bytes
CLC : ADC.l CartridgeSRAM, X
INX #2
CPX.w #$04FE : BNE -
LDX.w #$0000 : - ; Checksum extended save data
CLC : ADC.l ExtendedFileNameSRAM, X
INX #2
CPX.w #$0FFE : BNE -
STA.b $00
LDA.w #$5A5A
SEC : SBC.b $00
CMP.l InverseChecksumSRAM : BEQ .goodchecksum
LDX.w #$0000 : TXA : - ; Do the same for the backup save
CLC : ADC.l SaveBackupSRAM, X
INX #2
CPX.w #$04FE : BNE -
LDX.w #$0000 : -
CLC : ADC.l SaveBackupSRAM+$500, X
INX #2
CPX.w #$0FFE : BNE -
STA.b $00
LDA.w #$5A5A
SEC : SBC.b $00
CMP.l SaveBackupSRAM+$4FE : BEQ +
TDC : STA.l FileValiditySRAM ; Delete save by way of zeroing validity marker
BRA .goodchecksum : +
PHB
LDA.w #$14FF ; \
LDX.w #SaveBackupSRAM&$FFFF ; | Copies $1500 bytes from backup on cart SRAM to
LDY.w #CartridgeSRAM&$FFFF ; | main save location at $700000
MVN SRAMBank, SRAMBank ; /
PLB
.goodchecksum
LDX.w #$00FE : - ; includes prize pack reset after save and quit
STZ.w $0D00, X
STZ.w $0E00, X
STZ.w $0F00, X
DEX #2
BPL -
SEP #$30
RTL
;--------------------------------------------------------------------------------
ClearExtendedSaveFile:
STA $700400, X ; what we wrote over
STA $700500, X
STA $700600, X
STA $700700, X
STA $700800, X
STA $700900, X
STA $700A00, X
STA $700B00, X
STA $700C00, X
STA $700D00, X
STA $700E00, X
STA $700F00, X
STA.l $700400, X ; what we wrote over
STA.l $700500, X
STA.l $700600, X
STA.l $700700, X
STA.l $700800, X
STA.l $700900, X
STA.l $700A00, X
STA.l $700B00, X
STA.l $700C00, X
STA.l $700D00, X
STA.l $700E00, X
STA.l $700F00, X
STA.l $701000, X
STA.l $701100, X
STA.l $701200, X
STA.l $701300, X
STA.l $701400, X
; Clear backup save
STA.l $704000, X
STA.l $704100, X
STA.l $704200, X
STA.l $704300, X
STA.l $704400, X
STA.l $704500, X
STA.l $704600, X
STA.l $704700, X
STA.l $704800, X
STA.l $704900, X
STA.l $704A00, X
STA.l $704B00, X
STA.l $704C00, X
STA.l $704D00, X
STA.l $704E00, X
STA.l $704F00, X
STA.l $705000, X
STA.l $705100, X
STA.l $705200, X
STA.l $705300, X
STA.l $705400, X
RTL
;--------------------------------------------------------------------------------
ClearExtendedWRAMSaveFile:
STA $7EF400, X ; what we wrote over
STA $7F6000, X
STA $7F6100, X
STA $7F6200, X
STA $7F6300, X
STA $7F6400, X
STA $7F6500, X
STA $7F6600, X
STA $7F6700, X
STA $7F6800, X
STA $7F6900, X
STA $7F6A00, X
STA $7F6B00, X
STA $7F6C00, X
STA $7F6D00, X
STA $7F6E00, X
STA $7F6F00, X
STA.l $7EF400, X ; what we wrote over
STA.l $7F6000, X
STA.l $7F6100, X
STA.l $7F6200, X
STA.l $7F6300, X
STA.l $7F6400, X
STA.l $7F6500, X
STA.l $7F6600, X
STA.l $7F6700, X
STA.l $7F6800, X
STA.l $7F6900, X
STA.l $7F6A00, X
STA.l $7F6B00, X
STA.l $7F6C00, X
STA.l $7F6D00, X
STA.l $7F6E00, X
STA.l $7F6F00, X
RTL
;--------------------------------------------------------------------------------
CopyExtendedSaveFileToWRAM:
PHA
SEP #$30
LDA $4300 : PHA ; preserve DMA parameters
LDA $4301 : PHA ; preserve DMA parameters
LDA $4302 : PHA ; preserve DMA parameters
LDA $4303 : PHA ; preserve DMA parameters
LDA $4304 : PHA ; preserve DMA parameters
LDA $4305 : PHA ; preserve DMA parameters
LDA $4306 : PHA ; preserve DMA parameters
;--------------------------------------------------------------------------------
LDA #$00 : STA $4300 ; set DMA transfer direction A -> B, bus A auto increment, single-byte mode
PHA
SEP #$30
LDA.w $4300 : PHA ; preserve DMA parameters
LDA.w $4301 : PHA ; preserve DMA parameters
LDA.w $4302 : PHA ; preserve DMA parameters
LDA.w $4303 : PHA ; preserve DMA parameters
LDA.w $4304 : PHA ; preserve DMA parameters
LDA.w $4305 : PHA ; preserve DMA parameters
LDA.w $4306 : PHA ; preserve DMA parameters
;--------------------------------------------------------------------------------
STZ.w $4200 ; Disable NMI, V/H, joypad
STZ.w $420C ; Disable HDMA
LDA.b #$00 : STA.w $4300 ; set DMA transfer direction A -> B, bus A auto increment, single-byte mode
LDA #$80 : STA $4301 ; set bus B source to WRAM register
LDA.b #$80 : STA.w $4301 ; set bus B source to WRAM register
LDA #$00 : STA $2181 ; set WRAM register source address
LDA #$60 : STA $2182
LDA #$7F : STA $2183
LDA.b #$00 : STA.w $2181 ; set WRAM register source address
LDA.b #$60 : STA.w $2182
LDA.b #$7F : STA.w $2183
STZ $4302 ; set bus A destination address to SRAM
LDA #$05 : STA $4303
LDA #$70 : STA $4304
STZ.w $4302 ; set bus A destination address to SRAM
LDA.b #$05 : STA.w $4303
LDA.b #$70 : STA.w $4304
LDA #$00 : STA $4305 ; set transfer size to 0x1000
LDA #$10 : STA $4306 ; STZ $4307
LDA.b #$00 : STA.w $4305 ; set transfer size to 0x1000
LDA.b #$10 : STA.w $4306 ; STZ $4307
LDA #$01 : STA $420B ; begin DMA transfer
;--------------------------------------------------------------------------------
PLA : STA $4306 ; restore DMA parameters
PLA : STA $4305 ; restore DMA parameters
PLA : STA $4304 ; restore DMA parameters
PLA : STA $4303 ; restore DMA parameters
PLA : STA $4302 ; restore DMA parameters
PLA : STA $4301 ; restore DMA parameters
PLA : STA $4300 ; restore DMA parameters
REP #$30
PLA
STA $7EC00D ; what we wrote over
LDA.b #$01 : STA.w $420B ; begin DMA transfer
LDA.b #$81 : STA.w $4200 ; Re-enable NMI and joypad
;--------------------------------------------------------------------------------
PLA : STA.w $4306 ; restore DMA parameters
PLA : STA.w $4305 ; restore DMA parameters
PLA : STA.w $4304 ; restore DMA parameters
PLA : STA.w $4303 ; restore DMA parameters
PLA : STA.w $4302 ; restore DMA parameters
PLA : STA.w $4301 ; restore DMA parameters
PLA : STA.w $4300 ; restore DMA parameters
REP #$30
PLA
STA $7EC00D ; what we wrote over
RTL
;--------------------------------------------------------------------------------
CopyExtendedWRAMSaveFileToSRAM:
PHA
PHB
SEP #$30
LDA #$00 : PHA : PLB
LDA $4300 : PHA ; preserve DMA parameters
LDA $4301 : PHA ; preserve DMA parameters
LDA $4302 : PHA ; preserve DMA parameters
LDA $4303 : PHA ; preserve DMA parameters
LDA $4304 : PHA ; preserve DMA parameters
LDA $4305 : PHA ; preserve DMA parameters
LDA $4306 : PHA ; preserve DMA parameters
;--------------------------------------------------------------------------------
LDA #$80 : STA $4300 ; set DMA transfer direction B -> A, bus A auto increment, single-byte mode
PHA
PHB
SEP #$30
LDA #$00 : PHA : PLB
LDA.w $4300 : PHA ; preserve DMA parameters
LDA.w $4301 : PHA ; preserve DMA parameters
LDA.w $4302 : PHA ; preserve DMA parameters
LDA.w $4303 : PHA ; preserve DMA parameters
LDA.w $4304 : PHA ; preserve DMA parameters
LDA.w $4305 : PHA ; preserve DMA parameters
LDA.w $4306 : PHA ; preserve DMA parameters
;--------------------------------------------------------------------------------
STZ.w $4200 ; Disable NMI, V/H, joypad
STZ.w $420C ; Disable HDMA
LDA.b #$80 : STA.w $4300 ; set DMA transfer direction B -> A, bus A auto increment, single-byte mode
STA $4301 ; set bus B source to WRAM register
STA.w $4301 ; set bus B source to WRAM register
LDA #$00 : STA $2181 ; set WRAM register source address
LDA #$60 : STA $2182
LDA #$7F : STA $2183
LDA.b #$00 : STA.w $2181 ; set WRAM register source address
LDA.b #$60 : STA.w $2182
LDA.b #$7F : STA.w $2183
STZ $4302 ; set bus A destination address to SRAM
LDA #$05 : STA $4303
LDA #$70 : STA $4304
STZ.w $4302 ; set bus A destination address to SRAM
LDA.b #$05 : STA.w $4303
LDA.b #$70 : STA.w $4304
LDA #$10 : STA $4305 ; set transfer size to 0xB00
LDA #$0B : STA $4306 ; STZ $4307
LDA.b #$10 : STA.w $4305 ; set transfer size to 0xB00
LDA.b #$0B : STA.w $4306 ; STZ $4307
LDA #$01 : STA $420B ; begin DMA transfer
;--------------------------------------------------------------------------------
PLA : STA $4306 ; restore DMA parameters
PLA : STA $4305 ; restore DMA parameters
PLA : STA $4304 ; restore DMA parameters
PLA : STA $4303 ; restore DMA parameters
PLA : STA $4302 ; restore DMA parameters
PLA : STA $4301 ; restore DMA parameters
PLA : STA $4300 ; restore DMA parameters
REP #$30
PLB
PLA
LDX.w #$0000 : TXA ; what we wrote over
LDA.b #$01 : STA.w $420B ; begin DMA transfer
LDA.b #$81 : STA.w $4200 ; Re-enable NMI and joypad
;--------------------------------------------------------------------------------
PLA : STA.w $4306 ; restore DMA parameters
PLA : STA.w $4305 ; restore DMA parameters
PLA : STA.w $4304 ; restore DMA parameters
PLA : STA.w $4303 ; restore DMA parameters
PLA : STA.w $4302 ; restore DMA parameters
PLA : STA.w $4301 ; restore DMA parameters
PLA : STA.w $4300 ; restore DMA parameters
REP #$30
PLB
PLA
RTL

View File

@@ -10,6 +10,7 @@
;--------------------------------------------------------------------------------
pushpc
org 0 ; This module writes no bytes. Asar gives bank cross errors without this.
SaveDataWRAM = $7EF000
;================================================================================
; Room Data ($7EF000 - $7EF27F
@@ -125,8 +126,8 @@ MaximumHealth: skip 1 ; \ Max Health & Current Health
CurrentHealth: skip 1 ; / Max value for both is $A0 | $04 = half heart | $08 = heart
CurrentMagic: skip 1 ; Current magic | Max value is $80
CurrentSmallKeys: skip 1 ; Number of small keys held for current dungeon (integer)
BombCapacityUpgrades: skip 1 ; \ Bomb & Arrow Capacity Upgrades
ArrowCapacityUpgrades: skip 1 ; / Indicates flatly how many can be held above vanilla max (integers)
BombCapacity: skip 1 ; \ Bomb & Arrow Capacity Upgrades
ArrowCapacity: skip 1 ; / Indicates flatly how many can be held (integers)
HeartsFiller: skip 1 ; Hearts collected yet to be filled. Write in multiples of $08
MagicFiller: skip 1 ; Magic collected yet to be filled
PendantsField: skip 1 ; - - - - - g b r (bitfield)
@@ -252,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 ; |
@@ -260,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
@@ -366,7 +367,7 @@ GTCollectedKeys: skip 1 ; / Ganon's Tower
skip 2 ; Reserved for previous table
FileMarker: skip 1 ; $FF = Active save file | $00 = Inactive save file
skip 13 ; Unused
InverseChecksum: skip 2 ; Vanilla Inverse Checksum. Don't write unless computing checksum.
InverseChecksumWRAM: skip 2 ; Vanilla Inverse Checksum. Don't write unless computing checksum.
;================================================================================
; Expanded SRAM ($7F6000 - $7F6FFF)
@@ -379,8 +380,7 @@ ExtendedFileNameWRAM: skip 24 ; File name, 12 word-length characters.
RoomPotData: skip 592 ; Table for expanded pot shuffle. One word per room.
SpritePotData: skip 592 ; Table for expanded pot shuffle. One word per room.
PurchaseCounts: skip 96 ; Keeps track of shop purchases
PrivateBlock: skip 512 ; Reserved for 3rd party developers
DummyValue: skip 1 ; $01 if you're a real dummy
PrivateBlock: skip 513 ; Reserved for 3rd party developers
;================================================================================
; Direct SRAM Assignments ($700000 - $7080000)
@@ -403,18 +403,29 @@ ProgressIndicatorSRAM: skip 1 ;
skip 19 ;
FileNameVanillaSRAM: skip 8 ; First four characters of file name
FileValiditySRAM: skip 2 ;
skip 285 ;
skip 283 ;
InverseChecksumSRAM: skip 2 ;
ExtendedFileNameSRAM: skip 24 ; We read and write the file name directly from and to SRAM (24 bytes)
skip $1AE4 ;
RomVersionSRAM: skip 4 ; ALTTPR ROM version. Low byte is the version, high byte writes
; $01 for now (32-bits total)
RomNameSRAM: skip 21 ; ROM name from $FFC0, burned in during init (21 bytes)
; If value in the ROM doesn't match SRAM, save is cleared.
skip 4075 ;
PasswordSRAM: skip 16 ; Password value (16 bytes)
skip 8155 ;
SaveBackupSRAM: ; Backup copy of save ram. Game will attempt to use this if
; checksum on file select screen load fails.
base off
;================================================================================
; Bank Definitions
;--------------------------------------------------------------------------------
; If these move (most likely by placing initsramtable.asm somewhere else) these
; bank definitions need to be changed as well.
;================================================================================
SRAMBank = $70
SRAMTableBank = $30|$80
;================================================================================
; Assertions
;================================================================================
@@ -472,8 +483,8 @@ endmacro
%assertSRAM(CurrentHealth, $7EF36D)
%assertSRAM(CurrentMagic, $7EF36E)
%assertSRAM(CurrentSmallKeys, $7EF36F)
%assertSRAM(BombCapacityUpgrades, $7EF370)
%assertSRAM(ArrowCapacityUpgrades, $7EF371)
%assertSRAM(BombCapacity, $7EF370)
%assertSRAM(ArrowCapacity, $7EF371)
%assertSRAM(HeartsFiller, $7EF372)
%assertSRAM(MagicFiller, $7EF373)
%assertSRAM(PendantsField, $7EF374)
@@ -515,7 +526,7 @@ endmacro
%assertSRAM(FollowerDropped, $7EF3D3)
%assertSRAM(FileNameVanillaWRAM, $7EF3D9)
%assertSRAM(FileValidity, $7EF3E1)
%assertSRAM(InverseChecksum, $7EF4FE)
%assertSRAM(InverseChecksumWRAM, $7EF4FE)
;================================================================================
; Randomizer Assertions
@@ -536,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)
@@ -640,7 +651,6 @@ endmacro
%assertSRAM(SpritePotData, $7F6268)
%assertSRAM(PurchaseCounts, $7F64B8)
%assertSRAM(PrivateBlock, $7F6518)
%assertSRAM(DummyValue, $7F6718)
;================================================================================
; Direct SRAM Assertions
@@ -654,9 +664,11 @@ endmacro
%assertSRAM(ProgressIndicatorSRAM, $7003C5)
%assertSRAM(FileNameVanillaSRAM, $7003D9)
%assertSRAM(FileValiditySRAM, $7003E1)
%assertSRAM(InverseChecksumSRAM, $7004FE)
%assertSRAM(ExtendedFileNameSRAM, $700500)
%assertSRAM(RomNameSRAM, $702000)
%assertSRAM(RomVersionSRAM, $701FFC)
%assertSRAM(PasswordSRAM, $703000)
%assertSRAM(RomNameSRAM, $702000)
%assertSRAM(PasswordSRAM, $702015)
%assertSRAM(SaveBackupSRAM, $704000)
pullpc

View File

@@ -110,11 +110,7 @@ org $308033 ; PC 0x180033
HeartBeep:
db #$20 ; #$00 = Off - #$20 = Normal (default) - #$40 = Half Speed - #$80 = Quarter Speed
;--------------------------------------------------------------------------------
org $308034 ; PC 0x180034 - 0x180035
StartingMaxBombs:
db #10 ; #10 = Default (10 decimal)
StartingMaxArrows:
db #30 ; #30 = Default (30 decimal)
; 0x180034 - 0x180035 (Unused)
;--------------------------------------------------------------------------------
org $308036 ; PC 0x180036 - 0x180037
RupoorDeduction:
@@ -332,15 +328,15 @@ db $00 ;
;Warp BL : 7A
;Warp BR : 7B
;--------------------------------------------------------------------------------
org $308080 ; PC 0x180080 - 0x180083
org $308080 ; PC 0x180080 - 0x180083 ; Default to fill on upgrade. Can be set to 0 to not fill.
Upgrade5BombsRefill:
db #$00
db #$32
Upgrade10BombsRefill:
db #$00
db #$32
Upgrade5ArrowsRefill:
db #$00
db #$46
Upgrade10ArrowsRefill:
db #$00
db #$46
;--------------------------------------------------------------------------------
org $308084 ; PC 0x180084 - 0x180085
PotionHealthRefill:
@@ -1068,8 +1064,14 @@ db $00, $00, $00
org $308358
AllowAccidentalMajorGlitch:
db $00
;--------------------------------------------------------------------------------
; GFX pointer (0x180359 - 0x18035B)
; For 3rd party sprite stuff
;--------------------------------------------------------------------------------
org $308359
dl GfxPalettes
;================================================================================
; 0x180359 - 0x1814FF (unused)
; 0x18035C - 0x1814FF (unused)
;================================================================================
; $309500 (0x181500) - $309FFF (0x181FFF) original 0x39C bytes
; Replacement Ending Sequence Text Data

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
@@ -175,13 +175,13 @@ GetSpritePalette:
PHX
PHB : PHK : PLB
;--------
TAX : LDA.l .gfxPalettes, X ; look up item gfx
TAX : LDA.l GfxPalettes, X ; look up item gfx
PLB : PLX
CMP.b #$F8 : !BGE .specialHandling
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
@@ -236,7 +236,7 @@ RTL
;DATA - Loot Identifier to Sprite Palette
{
.gfxPalettes
GfxPalettes:
db $00, $04, $02, $08, $04, $02, $08, $02
db $04, $02, $02, $02, $04, $04, $04, $08
@@ -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