Implement initial SRAM table

Data in initialsramtable.asm gets copied to SRAM on save file init
Frontend will be responsible for setting this, requires frontend changes
Changed some label names to disambiguate WRAM and SRAM labels
Deleted open mode
This commit is contained in:
cassidoxa
2022-02-03 20:25:32 -05:00
parent c048589c02
commit 3e2362b7ca
22 changed files with 306 additions and 186 deletions

View File

@@ -2,7 +2,7 @@
; OnLoadOW
;--------------------------------------------------------------------------------
;OnLoadMap:
; LDA OverworldEventData+$5B ; thing we wrote over
; LDA OverworldEventDataWRAM+$5B ; thing we wrote over
;RTL
;--------------------------------------------------------------------------------
OnPrepFileSelect:
@@ -64,31 +64,60 @@ OnUncleItemGet:
BIT.b #$01 : BEQ + : STA !INFINITE_ARROWS : +
PLA
JSL Link_ReceiveItem
JSL.l Link_ReceiveItem
LDA.l UncleRefill : BIT.b #$04 : BEQ + : LDA.b #$80 : STA MagicFiller : + ; refill magic
LDA.l UncleRefill : BIT.b #$02 : BEQ + : LDA.b #50 : STA BombsFiller : + ; refill bombs
LDA.l UncleRefill : BIT.b #$04 : BEQ + : LDA.b #$80 : STA.l MagicFiller : + ; refill magic
LDA.l UncleRefill : BIT.b #$02 : BEQ + : LDA.b #50 : STA.l BombsFiller : + ; refill bombs
LDA.l UncleRefill : BIT.b #$01 : BEQ + ; refill arrows
LDA.b #70 : STA ArrowsFiller
LDA.b #70 : STA.l ArrowsFiller
LDA.l ArrowMode : BEQ +
LDA BowTracking : ORA #$80 : STA BowTracking ; enable bow toggle
LDA.l BowTracking : ORA.b #$80 : STA.l BowTracking ; enable bow toggle
REP #$20 ; set 16-bit accumulator
LDA CurrentRupees : !ADD.l FreeUncleItemAmount : STA CurrentRupees ; rupee arrows, so also give the player some money to start
LDA.l CurrentRupees : !ADD.l FreeUncleItemAmount : STA.l CurrentRupees ; rupee arrows, so also give the player some money to start
SEP #$20 ; set 8-bit accumulator
+
LDA.l ProgressIndicator : BNE +
LDA.b #$01 : STA.l ProgressIndicator ; handle rain state
+
RTL
;--------------------------------------------------------------------------------
OnAga2Defeated:
JSL.l Dungeon_SaveRoomData_justKeys ; thing we wrote over, make sure this is first
LDA.b #$01 : STA Aga2Duck
JSL.l Dungeon_SaveRoomDataWRAM_justKeys ; thing we wrote over, make sure this is first
LDA.b #$01 : STA.l Aga2Duck
JML.l IncrementAgahnim2Sword
;--------------------------------------------------------------------------------
OnFileCreation:
TAX ; what we wrote over
LDA StartingEquipment+$4C : STA EquipmentSRAM+$4C ; copy starting equipment swaps to file select screen
LDA StartingEquipment+$4E : STA EquipmentSRAM+$4E
RTL
; 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
; resolve instant post-aga if standard
SEP #$20
LDA.l InitProgressIndicator : BIT #$80 : BEQ +
LDA.b #$00 : STA.l ProgressIndicatorSRAM ; set post-aga after zelda rescue
LDA.b #$00 : STA.l OverworldEventDataSRAM+$02 ; keep rain state vanilla
+
REP #$20
; Set validity value and do some cleanup. Jump to checksum.
LDA.w #$55AA : STA.l $7003E1
STZ $00
STZ $01
LDX.b $00
LDY.w #$0000
TYA
JML.l InitializeSaveFile_build_checksum
;--------------------------------------------------------------------------------
!RNG_ITEM_LOCK_IN = "$7F5090"
OnFileLoad:
@@ -97,20 +126,19 @@ OnFileLoad:
LDA.b #$07 : STA $210C ; Restore screen 3 to normal tile area
LDA FileMarker : BNE +
LDA.l FileMarker : BNE +
JSL.l OnNewFile
LDA.b #$FF : STA FileMarker
LDA.b #$FF : STA.l FileMarker
+
LDA.w $010A : BNE + ; don't adjust the worlds for "continue" or "save-continue"
LDA.l $7EC011 : BNE + ; don't adjust worlds if mosiac is enabled (Read: mirroring in dungeon)
JSL.l DoWorldFix
+
JSL.l MasterSwordFollowerClear
JSL.l InitOpenMode
LDA #$FF : STA !RNG_ITEM_LOCK_IN ; reset rng item lock-in
LDA #$00 : STA $7F5001 ; mark fake flipper softlock as impossible
LDA.b #$FF : STA !RNG_ITEM_LOCK_IN ; reset rng item lock-in
LDA.b #$00 : STA $7F5001 ; mark fake flipper softlock as impossible
LDA.l GenericKeys : BEQ +
LDA CurrentGenericKeys : STA CurrentSmallKeys ; copy generic keys to key counter
LDA.l CurrentGenericKeys : STA.l CurrentSmallKeys ; copy generic keys to key counter
+
JSL.l SetSilverBowMode
@@ -126,39 +154,8 @@ RTL
!RNG_ITEM_LOCK_IN = "$7F5090"
OnNewFile:
PHX : PHP
REP #$20 ; set 16-bit accumulator
LDA.l LinkStartingRupees : STA DisplayRupees : STA CurrentRupees
LDA.l StartingTime : STA ChallengeTimer
LDA.l StartingTime+2 : STA ChallengeTimer+2
LDX.w #$004E : - ; copy over starting equipment
LDA StartingEquipment, X : STA EquipmentWRAM, X
DEX : DEX
BPL -
LDX #$0008 : - ; copy starting keys to chest key counters in sram
LDA DungeonKeys, X : STA DungeonCollectedKeys, X
DEX : DEX
BPL -
SEP #$20 ; set 8-bit accumulator
;LDA #$FF : STA !RNG_ITEM_LOCK_IN ; reset rng item lock-in
LDA.l PreopenCurtains : BEQ +
LDA.b #$80 : STA RoomData[$30].high ; open aga tower curtain
LDA.b #$80 : STA RoomData[$49].high ; open skull woods curtain
+
LDA.l PreopenPyramid : BEQ +
LDA.b #$20 : STA OverworldEventData+$5B ; pyramid hole already open
+
LDA.l PreopenGanonsTower : BEQ +
LDA.b #$20 : STA OverworldEventData+$43 ; Ganons Tower already open
+
LDA StartingSword : STA SwordEquipment ; set starting sword type
; reset some values on new file that are otherwise only reset on hard reset
SEP #$20 ; set 8-bit accumulator
STZ $03C4 ; ancilla slot index
STZ $047A ; EG
STZ $0B08 : STZ $0B09 ; arc variable