Merge branch 'main' into kara

This commit is contained in:
2022-11-16 14:52:02 -08:00
12 changed files with 296 additions and 191 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

@@ -11,10 +11,11 @@ DoWorldFix:
JMP DoWorldFix_Inverted
+
LDA.l Bugfix_MirrorlessSQToLW : BEQ .skip_mirror_check
LDA.l FollowerIndicator : CMP #$04 : BEQ .setLightWorld ; check if old man is following
LDA MirrorEquipment : BEQ .noMirror ; check if we have the mirror
.skip_mirror_check ; alt entrance point
LDA ProgressIndicator : CMP.b #$03 : BCS .done ; check if agahnim 1 is alive
.aga1Alive
.setLightWorld
LDA #$00
.noMirror
STA CurrentWorld ; set flag to light world
@@ -46,11 +47,11 @@ RTL
;================================================================================
DoWorldFix_Inverted:
LDA.l Bugfix_MirrorlessSQToLW : BEQ .skip_mirror_check
LDA MirrorEquipment : BEQ .noMirror ; check if we have the mirror
LDA.l FollowerIndicator : CMP #$04 : BEQ .setDarkWorld ; check if old man is following
LDA MirrorEquipment : BEQ .setDarkWorld ; check if we have the mirror
.skip_mirror_check ; alt entrance point
LDA ProgressIndicator : CMP.b #$03 : BCS .done ; check if agahnim 1 is alive
.noMirror
.aga1Alive
.setDarkWorld
LDA #$40 : STA CurrentWorld ; set flag to dark world
LDA FollowerIndicator
CMP #$07 : BEQ .clear ; clear frog

View File

@@ -88,18 +88,19 @@ OnAga2Defeated:
JML.l IncrementAgahnim2Sword
;--------------------------------------------------------------------------------
OnFileCreation:
; Copy initial SRAM state from ROM to cart SRAM
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 ; /
PLB
; 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 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
SEP #$20

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
;--------------------------------------------------------------------------------

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

View File

@@ -713,7 +713,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
@@ -730,7 +730,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

@@ -287,6 +287,6 @@ Overworld_MosaicDarkWorldChecks:
;--------------------------------------------------------------------------------
; Check if the boss in ToH has been defeated (16-bit accumulator)
CheckHeraBossDefeated:
LDA $7EF00F : AND #$00FF
LDA.l RoomDataWRAM[$07].l : AND #$FF00
RTL
;--------------------------------------------------------------------------------

View File

@@ -216,13 +216,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
@@ -240,19 +238,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
@@ -474,7 +472,7 @@ AddReceivedItemExpanded:
LDA.b #$4F : STA $02D8
+++ : JMP .done
++ : CMP.b #$5E : BNE ++ ; Progressive Sword
LDA SwordEquipment : CMP.l ProgressiveSwordLimit : !BLT +
LDA HighestSword : CMP.l ProgressiveSwordLimit : !BLT +
LDA.l ProgressiveSwordReplacement : STA $02D8 : JMP .done
+ : CMP.b #$00 : BNE + ; No Sword
LDA.b #$49 : STA $02D8 : JMP .done
@@ -485,7 +483,7 @@ AddReceivedItemExpanded:
+ ; Everything Else
LDA.b #$03 : STA $02D8 : JMP .done
++ : CMP.b #$5F : BNE ++ ; Progressive Shield
LDA ShieldEquipment : CMP.l ProgressiveShieldLimit : !BLT +
LDA HighestShield : CMP.l ProgressiveShieldLimit : !BLT +
LDA.l ProgressiveShieldReplacement : STA $02D8 : JMP .done
+ : CMP.b #$00 : BNE + ; No Shield
LDA.b #$04 : STA $02D8 : JMP .done
@@ -494,7 +492,7 @@ AddReceivedItemExpanded:
+ ; Everything Else
LDA.b #$06 : STA $02D8 : JMP .done
++ : CMP.b #$60 : BNE ++ ; Progressive Armor
LDA ArmorEquipment : CMP.l ProgressiveArmorLimit : !BLT +
LDA HighestMail : CMP.l ProgressiveArmorLimit : !BLT +
LDA.l ProgressiveArmorReplacement : STA $02D8 : JMP .done
+ : CMP.b #$00 : BNE + ; No Armor
LDA.b #$22 : 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
@@ -21,8 +22,14 @@ org 0 ; This module writes no bytes. Asar gives bank cross errors without this.
; 2 (southwest), and 1 (southeast), which is the same as they are laid out on the screen from
; left to right, top to bottom.
;
; The .l sub-label should be used when the accumulator is in 16-bit mode and we want to
; load both bytes or store to both bytes at once. The .high and .low sub-labels should be used
; when in 8-bit mode and we only want to load or store one byte
;
; Example: We can use RoomDataWRAM[$37].high to read or write the pot key in the first
; floodable room in Swamp Palace ($04)
; floodable room in Swamp Palace (bit $04). To check if a boss has been killed we can
; take the room index for a boss room (e.g. $07 for Tower of Hera) and bitmask $FF00
; like this: RoomDataWRAM[$07].l : AND #$FF00
;--------------------------------------------------------------------------------
; .high Byte: d d d d b k u t
; .low Byte: s e h c q q q q
@@ -125,8 +132,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)
@@ -368,7 +375,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.
;================================================================================
; Temporary Effects ($7F50C0 - $7F50CF)
@@ -401,8 +408,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)
@@ -425,18 +431,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
;================================================================================
@@ -494,8 +511,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)
@@ -537,7 +554,7 @@ endmacro
%assertSRAM(FollowerDropped, $7EF3D3)
%assertSRAM(FileNameVanillaWRAM, $7EF3D9)
%assertSRAM(FileValidity, $7EF3E1)
%assertSRAM(InverseChecksum, $7EF4FE)
%assertSRAM(InverseChecksumWRAM, $7EF4FE)
;================================================================================
; Randomizer Assertions
@@ -679,7 +696,6 @@ endmacro
%assertSRAM(SpritePotData, $7F6268)
%assertSRAM(PurchaseCounts, $7F64B8)
%assertSRAM(PrivateBlock, $7F6518)
%assertSRAM(DummyValue, $7F6718)
;================================================================================
; Direct SRAM Assertions
@@ -693,9 +709,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

@@ -136,11 +136,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:
@@ -361,15 +357,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:
@@ -1099,8 +1095,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

@@ -180,7 +180,7 @@ 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 #$F6 : !BGE .specialHandling
RTL
@@ -251,7 +251,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