diff --git a/LTTP_RND_GeneralBugfixes.asm b/LTTP_RND_GeneralBugfixes.asm index fdc3988..a8e260c 100644 --- a/LTTP_RND_GeneralBugfixes.asm +++ b/LTTP_RND_GeneralBugfixes.asm @@ -159,7 +159,6 @@ org $A48000 ; code bank - PUT NEW CODE HERE incsrc glitched.asm incsrc hardmode.asm incsrc goalitem.asm -incsrc openmode.asm incsrc quickswap.asm incsrc endingsequence.asm incsrc cuccostorm.asm @@ -446,10 +445,10 @@ org $028296 .setAmbientSfx org $02A0A8 -Dungeon_SaveRoomData: +Dungeon_SaveRoomDataWRAM: org $02A0BE -Dungeon_SaveRoomData_justKeys: +Dungeon_SaveRoomDataWRAM_justKeys: org $02B861 Dungeon_SaveRoomQuadrantData: @@ -584,7 +583,7 @@ org $0CD7D1 NameFile_MakeScreenVisible: org $0CDB3E InitializeSaveFile: -org $0CDB3E +org $0CDBC0 InitializeSaveFile_build_checksum: org $0DBA71 diff --git a/dialog.asm b/dialog.asm index 13ccc9b..67954aa 100644 --- a/dialog.asm +++ b/dialog.asm @@ -394,7 +394,7 @@ AgahnimAsksAboutPed: LDA.l InvincibleGanon CMP.b #$06 : BNE .vanilla - LDA.l OverworldEventData+$80 ; check ped flag + LDA.l OverworldEventDataWRAM+$80 ; check ped flag AND.b #$40 BNE .vanilla diff --git a/entrances.asm b/entrances.asm index 3aab52c..e3e6bb0 100644 --- a/entrances.asm +++ b/entrances.asm @@ -22,7 +22,7 @@ LockAgahnimDoors: .crystalOrUnlock LDA InvertedMode : AND.w #$00FF : BEQ .unlock - LDA OverworldEventData+$43 : AND.w #$0020 : BNE .unlock ; Check if GT overlay is already on or not + LDA OverworldEventDataWRAM+$43 : AND.w #$0020 : BNE .unlock ; Check if GT overlay is already on or not LDA $0308 : AND.w #$0080 : BEQ ++ ;If we are holding an item .locked @@ -44,7 +44,7 @@ RTL FlagAgahnimDoor: LDA.l InvertedMode : BEQ .vanilla - LDA OverworldEventData+$43 : ORA #$20 : STA OverworldEventData+$43 ; activate GT overlay + LDA OverworldEventDataWRAM+$43 : ORA #$20 : STA OverworldEventDataWRAM+$43 ; activate GT overlay .vanilla LDA.b #$28 : STA.b $72 @@ -209,7 +209,7 @@ TurtleRockEntranceFix: LDA TurtleRockAutoOpenFix : BEQ .done LDA $8A : CMP.b #$47 : BNE .done ;If exiting to turtle rock ensure the entrance is open - LDA.l OverworldEventData+$47 : ORA.b #$20 : STA.l OverworldEventData+$47 + LDA.l OverworldEventDataWRAM+$47 : ORA.b #$20 : STA.l OverworldEventDataWRAM+$47 .done RTL ;-------------------------------------------------------------------------------- diff --git a/events.asm b/events.asm index e94082d..0a1de87 100644 --- a/events.asm +++ b/events.asm @@ -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 diff --git a/floodgatesoftlock.asm b/floodgatesoftlock.asm index 18b6edf..e593344 100644 --- a/floodgatesoftlock.asm +++ b/floodgatesoftlock.asm @@ -5,21 +5,21 @@ FloodGateAndMasterSwordFollowerReset: JSL.l MasterSwordFollowerClear FloodGateReset: LDA.l PersistentFloodgate : BNE + - LDA OverworldEventData+$3B : AND.b #$DF : STA OverworldEventData+$3B ; reset water outside floodgate - LDA OverworldEventData+$7B : AND.b #$DF : STA OverworldEventData+$7B ; reset water outside swamp palace - LDA RoomData[$010B].low : AND.b #$7F : STA RoomData[$010B].low ; clear water inside floodgate - LDA RoomData[$28].high : AND.b #$FE : STA RoomData[$28].high ; clear water front room (room 40) + LDA OverworldEventDataWRAM+$3B : AND.b #$DF : STA OverworldEventDataWRAM+$3B ; reset water outside floodgate + LDA OverworldEventDataWRAM+$7B : AND.b #$DF : STA OverworldEventDataWRAM+$7B ; reset water outside swamp palace + LDA RoomDataWRAM[$010B].low : AND.b #$7F : STA RoomDataWRAM[$010B].low ; clear water inside floodgate + LDA RoomDataWRAM[$28].high : AND.b #$FE : STA RoomDataWRAM[$28].high ; clear water front room (room 40) + FloodGateResetInner: LDA.l Bugfix_SwampWaterLevel : BEQ +++ - LDA RoomData[$37].low : AND.b #$04 : BEQ + ; Check if key in room 55 has been collected. + LDA RoomDataWRAM[$37].low : AND.b #$04 : BEQ + ; Check if key in room 55 has been collected. LDA FlippersEquipment : AND.b #$01 : BNE ++ ; Check for flippers. This can otherwise softlock doors if flooded without flippers and no way to reset. + - LDA RoomData[$37].low : AND.b #$7F : STA RoomData[$37].low ; clear water room 55 - outer room you shouldn't be able to softlock except in major glitches + LDA RoomDataWRAM[$37].low : AND.b #$7F : STA RoomDataWRAM[$37].low ; clear water room 55 - outer room you shouldn't be able to softlock except in major glitches ++ - LDA RoomData[$35].high : AND.b #$04 : BNE +++ ; Check if key in room 53 has been collected. + LDA RoomDataWRAM[$35].high : AND.b #$04 : BNE +++ ; Check if key in room 53 has been collected. ; no need to check for flippers on the inner room, as you can't get to the west door no matter what, without flippers. - LDA RoomData[$35].low : AND.b #$7F : STA RoomData[$35].low ; clear water room 53 - inner room with the easy key flood softlock + LDA RoomDataWRAM[$35].low : AND.b #$7F : STA RoomDataWRAM[$35].low ; clear water room 53 - inner room with the easy key flood softlock +++ RTL ;================================================================================ diff --git a/flute.asm b/flute.asm index 5e6e82b..fe88520 100644 --- a/flute.asm +++ b/flute.asm @@ -33,7 +33,7 @@ SpawnHauntedGroveItem: TYX LDX $8A ; haunted grove (208D0A) - LDA OverworldEventData, X : AND.b #$40 : BNE + + LDA OverworldEventDataWRAM, X : AND.b #$40 : BNE + LDA.b #$1B : JSL Sound_SetSfx3PanLong + RTL diff --git a/goalitem.asm b/goalitem.asm index 12287ce..81420b0 100644 --- a/goalitem.asm +++ b/goalitem.asm @@ -67,12 +67,12 @@ CheckGanonVulnerability: .all_dungeons_no_agahnim LDA.l PendantsField : AND.b #$07 : CMP.b #$07 : BNE .fail ; require all pendants LDA.l CrystalsField : AND.b #$7F : CMP.b #$7F : BNE .fail ; require all crystals - LDA.l OverworldEventData+$5B : AND.b #$20 : BEQ .fail ; require aga2 defeated (pyramid hole open) + LDA.l OverworldEventDataWRAM+$5B : AND.b #$20 : BEQ .fail ; require aga2 defeated (pyramid hole open) BRA .success ; 03 = crystals and aga 2 .crystals_and_aga - LDA.l OverworldEventData+$5B : AND.b #$20 : BEQ .fail ; check aga2 first then bleed in + LDA.l OverworldEventDataWRAM+$5B : AND.b #$20 : BEQ .fail ; check aga2 first then bleed in ; 04 = crystals only .crystals @@ -138,7 +138,7 @@ CheckAgaForPed: CMP.b #$06 : BNE .vanilla .light_speed - LDA.l OverworldEventData+$80 ; check ped flag + LDA.l OverworldEventDataWRAM+$80 ; check ped flag AND.b #$40 BEQ .force_blue_ball @@ -162,8 +162,8 @@ KillGanon: CMP.b #$06 : BNE .exit .light_speed - LDA.l OverworldEventData+$5B : ORA.b #$20 : STA.l OverworldEventData+$5B ; pyramid hole - LDA.b #$08 : STA.l RoomData[$00].high ; kill ganon + LDA.l OverworldEventDataWRAM+$5B : ORA.b #$20 : STA.l OverworldEventDataWRAM+$5B ; pyramid hole + LDA.b #$08 : STA.l RoomDataWRAM[$00].high ; kill ganon LDA.b #$02 : STA.l MoonPearlEquipment ; pearl but invisible in menu .exit @@ -195,7 +195,7 @@ CheckForCrystalBossesDefeated: LDA.l DrawHUDDungeonItems_boss_room_ids-4,X TAX - LDA.l RoomData.l,X + LDA.l RoomDataWRAM.l,X AND.w #$0800 BEQ ++ diff --git a/heartpieces.asm b/heartpieces.asm index f7f898f..08aaea2 100644 --- a/heartpieces.asm +++ b/heartpieces.asm @@ -130,7 +130,7 @@ HeartUpgradeSpawnDecision: ; this should return #$00 to make the hp spawn RTL .normal_behavior - LDA OverworldEventData, X + LDA OverworldEventDataWRAM, X RTL ;-------------------------------------------------------------------------------- SaveHeartCollectedStatus: @@ -140,7 +140,7 @@ SaveHeartCollectedStatus: RTL .normal_behavior - LDA OverworldEventData, X : ORA.b #$40 : STA OverworldEventData, X + LDA OverworldEventDataWRAM, X : ORA.b #$40 : STA OverworldEventDataWRAM, X RTL ;-------------------------------------------------------------------------------- !REDRAW = "$7F5000" diff --git a/hooks.asm b/hooks.asm index 493fc3a..c55ce94 100755 --- a/hooks.asm +++ b/hooks.asm @@ -310,9 +310,8 @@ org $0CCE85 ; <- Bank0C.asm : 1953 (LDA $C8 : ASL A : INC #2 : STA $701FFE) NOP #4 ;-------------------------------------------------------------------------------- org $0CDB4C ; <- Bank0C.asm : 3655 (LDA $C8 : ASL A : INC #2 : STA $701FFE : TAX) -JSL OnFileCreation +JML OnFileCreation NOP -;Additionally, display inventory swap starting equipment on file select ;-------------------------------------------------------------------------------- org $09F5EA ; <- module_death.asm : 510 (LDA $701FFE : TAX : DEX #2) LDA.w #$0002 : NOP @@ -536,7 +535,7 @@ JSL.l CheckGanonHammerDamage : NOP org $02B797 ; <- 13797 - Bank02.asm : 8712 (LDA.b #$19 : STA $10) JSL.l StatsFinalPrep ;-------------------------------------------------------------------------------- -org $07A95B ; <- 3A95B - Bank07.asm : 6565 (JSL Dungeon_SaveRoomData) +org $07A95B ; <- 3A95B - Bank07.asm : 6565 (JSL Dungeon_SaveRoomDataWRAM) JSL.l IncrementUWMirror ;-------------------------------------------------------------------------------- org $0288D1 ; <- 108D1 - Bank02.asm : 1690 (STZ $0646) @@ -710,7 +709,7 @@ JSL.l GetItemDamageValue ;================================================================================ ; Misc Stats ;-------------------------------------------------------------------------------- -org $029E2E ; <- 11E2E - module_ganon_emerges.asm : 59 (JSL Dungeon_SaveRoomData.justKeys) +org $029E2E ; <- 11E2E - module_ganon_emerges.asm : 59 (JSL Dungeon_SaveRoomDataWRAM.justKeys) JSL.l OnAga2Defeated ;-------------------------------------------------------------------------------- org $0DDBDE ; <- 6DBDE - headsup_display.asm : 105 (DEC A : BPL .subtractRupees) @@ -1676,7 +1675,7 @@ JSL.l FixAga2Bunny : NOP ; Open Mode Fixes ;-------------------------------------------------------------------------------- org $05DF65 ; <- 2DF65 - sprite_uncle_and_priest.asm:994 - (LDA.b #$01 : STA $7EF3C5) -JSL.l SetUncleRainState : RTS +NOP #6 ;-------------------------------------------------------------------------------- ;org $0280DD ; <- 100DD - Bank02.asm:298 - (LDA $7EF3C5 : CMP.b #$02 : BCC .indoors) ;JSL.l ForceLinksHouse diff --git a/initsramtable.asm b/initsramtable.asm new file mode 100644 index 0000000..b2720b1 --- /dev/null +++ b/initsramtable.asm @@ -0,0 +1,174 @@ +;================================================================================ +; Initial SRAM table. +;-------------------------------------------------------------------------------- +; The ROM copies blocks of bytes from here on save file init. This table has an +; identical layout to the first $500 bytes of SRAM, although some values such as +; the file validity value, file name, and inverse checksum are skipped. +; +; NOTE: Set InitProgressIndicator to $80 for standard mode with instant post-aga +; world state +; +; See sram.asm for further documentation on how to write to this table. +;-------------------------------------------------------------------------------- + +fillword $0000 ; Zero out the table +fill $500 ; + +org $30B000 ; PC 0x183000 +InitRoomDataWRAM: +org $30B060 +InitATAltarRoom: dw $0000 ; aga curtains +org $30B092 +InitSWBackEntryRoom: dw $0000 ; skull woods curtains (?) + +org $30B20C +dw $F000, $F000 ; Pre-open kak bomb hut & brewery + +org $30B280 ; PC 0x183280 - 0x1832FF +InitOverworldEvents: +org $30B282 ; PC 0x183282 - Lumberjacks +InitLumberjackOW: db $00 +org $30B29B ; PC 0x18329B - Open castle gate +InitHyruleCastleOW: db $20 +org $30B2DB ; PC 0x18329B - Pyramid hole +InitPyramidOW: db $00 +org $30B2C3 ; PC 0x18329B - GT +InitDDMWestOW: db $00 + + +org $30B340 ; PC 0x183340 +StartingEquipment: +StartingBow: skip 1 ; PC 0x183340 +StartingBoomerang: skip 1 ; PC 0x183341 +StartingHookshot: skip 1 ; PC 0x183342 +StartingBombs: skip 1 ; PC 0x183343 +StartingPowder: skip 1 ; PC 0x183344 +StartingFireRod: skip 1 ; PC 0x183345 +StartingIceRod: skip 1 ; PC 0x183346 +StartingBombos: skip 1 ; PC 0x183347 +StartingEther: skip 1 ; PC 0x183348 +StartingQuake: skip 1 ; PC 0x183349 +StartingLamp: skip 1 ; PC 0x18334A +StartingHammer: skip 1 ; PC 0x18334B +StartingFlute: skip 1 ; PC 0x18334C +StartingBugNet: skip 1 ; PC 0x18334D +StartingBookOfMudora: skip 1 ; PC 0x18334E +StartingBottleIndex: skip 1 ; PC 0x18334F +StartingSomaria: skip 1 ; PC 0x183350 +StartingByrna: skip 1 ; PC 0x183351 +StartingCape: skip 1 ; PC 0x183352 +StartingMirror: skip 1 ; PC 0x183353 +StartingGlove: skip 1 ; PC 0x183354 +StartingBoots: skip 1 ; PC 0x183355 +StartingFlippers: skip 1 ; PC 0x183356 +StartingMoonPearl: skip 1 ; PC 0x183357 +skip 1 ; PC 0x183358 +StartingSword: skip 1 ; PC 0x183359 +StartingShield: skip 1 ; PC 0x18335A +StartingArmor: skip 1 ; PC 0x18335B +StartingBottleContentsOne: skip 1 ; PC 0x18335C +StartingBottleContentsTwo: skip 1 ; PC 0x18335D +StartingBottleContentsThree: skip 1 ; PC 0x18335E +StartingBottleContentsFour: skip 1 ; PC 0x18335F +StartingCurrentRupees: skip 2 ; PC 0x183360 \ Write same value to both +StartingDisplayRupees: skip 2 ; PC 0x183362 / of these +StartingCompasses: skip 2 ; PC 0x183364 +StartingBigKeys: skip 2 ; PC 0x183366 +StartingMaps: skip 2 ; PC 0x183368 +skip 1 ; PC 0x18336A +StartingQuarterHearts: skip 1 ; PC 0x18336B +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 +InitHeartsFiller: skip 1 ; PC 0x183372 +InitMagicFiller: skip 1 ; PC 0x183373 +StartingPendants: skip 1 ; PC 0x183374 +InitBombsFiller: skip 1 ; PC 0x183375 +InitArrowsFiller: skip 1 ; PC 0x183376 +StartingArrows: skip 1 ; PC 0x183377 +skip 1 ; PC 0x183378 +InitAbilityFlags: db $68 ; PC 0x183379 +StartingCrystals: skip 1 ; PC 0x18337A +StartingMagicConsumption: skip 1 ; PC 0x18337B +StartingDungeonKeys: ; +StartingSewerKeys: skip 1 ; PC 0x18337C +StartingHyruleCastleKeys: skip 1 ; PC 0x18337D +StartingEasternKeys: skip 1 ; PC 0x18337E +StartingDesertKeys: skip 1 ; PC 0x18337F +StartingCastleTowerKeys: skip 1 ; PC 0x183380 +StartingSwampKeys: skip 1 ; PC 0x183381 +StartingPalaceOfDarknessKeys: skip 1 ; PC 0x183382 +StartingMireKeys: skip 1 ; PC 0x183383 +StartingSkullWoodsKeys: skip 1 ; PC 0x183384 +StartingIcePalaceKeys: skip 1 ; PC 0x183385 +StartingHeraKeys: skip 1 ; PC 0x183386 +StartingThievesTownKeys: skip 1 ; PC 0x183387 +StartingTurtleRockKeys: skip 1 ; PC 0x183388 +StartingGanonsTowerKeys: skip 1 ; PC 0x183389 +skip 1 ; PC 0x18338A +StartingGenericKeys: skip 1 ; PC 0x18338B +InitInventoryTracking: skip 2 ; PC 0x18338C \ Need to set bits here for silver arrows, +InitBowTracking: skip 2 ; PC 0x18338E / boomerangs, powder/mushroom, etc +InitItemLimitCounts: skip 16 ; PC 0x183390 +skip 37 ; +InitProgressIndicator: db $02 ; PC 0x1833C5 - Set to $80 for instant post-aga with standard +InitProgressFlags: db $14 ; PC 0x1833C6 +InitMapIcons: skip 1 ; PC 0x1833C7 +InitStartingEntrance: db $01 ; PC 0x1833C8 +InitNpcFlagsVanilla: skip 1 ; PC 0x1833C9 +InitCurrentWorld: skip 1 ; PC 0x1833CA +skip 1 ; PC 0x1833CB +InitFollowerIndicator: skip 1 ; PC 0x1833CC +InitFollowerXCoord: skip 2 ; PC 0x1833CD +InitFollowerYCoord: skip 2 ; PC 0x1833CF +InitDroppedFollowerIndoors: skip 1 ; PC 0x1833D1 +InitDroppedFollowerLayer: skip 1 ; PC 0x1833D2 +InitFollowerDropped: skip 1 ; PC 0x1833D3 + +org $30B3D9 ; PC 0x1833D9 - 0x1833F0 +StaticFileName: ; The validity value ($55AA) must be written manually on SRAM init at $7003E1 +dw $0181, $0162, $0168, $018C +dw $0166, $014E, $0162, $018C +dw $0165, $0162, $0167, $018C + +org $30B401 ; PC 0x183401 +InitDeathCounter: +dw $FFFF + +;-------------------------------------------------------------------------------- +; The following labels and their addresses are provided for convenience. You +; may want to write, for example, to InitHighestSword in addition to setting +; StartingSword. But any value can be written to the whole block from +; $30B000-$30B4FF (PC 0x183000-0x18034FF) and it will be initialized +; excluding ~28 bytes (File name, validity value, and checksum.) +;-------------------------------------------------------------------------------- + +org $30B414 ; PC 0x183414-0x183416 +InitMapOverlay: dw $0000 + +org $30B417 ; PC 0x183417 +InitHighestSword: db $00 + +org $30B414 ; PC 0x183418-0x183419 +InitGoalCounter: dw $0000 + +org $30B422 ; PC 0x183422 +InitHighestShield: db $00 + +org $30B428 ; PC 0x183428 +InitMapsCompasses: db $00 + +org $30B429 ; PC 0x183429 +InitPendantCounter: db $00 + +org $30B454 ; PC 0x183454-0x183457 +InitChallengeTimer: dw $0000, $0000 + +org $30B46E ; PC 0x18346E +InitHighestMail: db $00 + +org $30B471 ; PC 0x183471 +InitCrystalCounter: db $00 diff --git a/inverted.asm b/inverted.asm index a89d624..1aeb772 100644 --- a/inverted.asm +++ b/inverted.asm @@ -71,7 +71,7 @@ Overworld_CreatePyramidHoleModified: SEP #$30 - LDA OverworldEventData+$5B : ORA.b #$20 : STA OverworldEventData+$5B + LDA OverworldEventDataWRAM+$5B : ORA.b #$20 : STA OverworldEventDataWRAM+$5B LDA.b #$03 : STA $012F @@ -131,9 +131,9 @@ db $02, $02, $02, $02, $02, $02, $02, $00, $00, $01, $01, $01, $02, $00, $08, $0 Electric_Barrier: LDA InvertedMode : BEQ .done - LDA OverworldEventData, X : ORA #$40 : STA OverworldEventData, X ;set barrier dead + LDA OverworldEventDataWRAM, X : ORA #$40 : STA OverworldEventDataWRAM, X ;set barrier dead .done - LDA OverworldEventData, X ; what we wrote over + LDA OverworldEventDataWRAM, X ; what we wrote over RTL @@ -187,7 +187,7 @@ RTL TurtleRockPegSolved: LDA.l InvertedMode : AND.w #$00FF : BNE + - LDA.l OverworldEventData+07 ; What we wrote over (reading flags for this screen) + LDA.l OverworldEventDataWRAM+07 ; What we wrote over (reading flags for this screen) RTL + LDA.w #$0020 ; We always treat puzzle as pre solved (overlay flag set) for inverted mode. diff --git a/lampmantlecone.asm b/lampmantlecone.asm index 07d5fea..1262087 100644 --- a/lampmantlecone.asm +++ b/lampmantlecone.asm @@ -26,8 +26,6 @@ RTL ; Output: 0 locked, 1 open ;-------------------------------------------------------------------------------- CheckForZelda: - ;LDA.l OpenMode : BEQ + ; Skip if not open mode - ;LDA $FFFFFF LDA.l ProgressIndicator : CMP.b #$02 : !BLT + ; Skip if rain is falling LDA.b #$01 ; pretend we have zelda anyway RTL @@ -37,7 +35,6 @@ RTL ;================================================================================ ;-------------------------------------------------------------------------------- SetOverlayIfLamp: - ;LDA LampEquipment ; check if lamp JSL.l LampCheck STA $1D ; write it directly to the overlay, this isn't a terrible idea at all RTL diff --git a/medallions.asm b/medallions.asm index e5553e0..c70a57c 100644 --- a/medallions.asm +++ b/medallions.asm @@ -6,7 +6,7 @@ TryOpenMire: LDA $8A : CMP.b #$70 : BNE .untriggered ; Checks whether the Misery Mire dungeon is already revealed. - LDA OverworldEventData+$70 : AND.b #$20 : BNE .untriggered + LDA OverworldEventDataWRAM+$70 : AND.b #$20 : BNE .untriggered ; You have to be in the trigger window. LDY.b #$02 : JSL.l Ancilla_CheckIfEntranceTriggered : BCC .untriggered @@ -25,7 +25,7 @@ TryOpenTRock: LDA $8A : CMP.b #$47 : BNE .untriggered ; Checks whether the Turtle Rock dungeon is already revealed. - LDA OverworldEventData+$47 : AND.b #$20 : BNE .untriggered + LDA OverworldEventDataWRAM+$47 : AND.b #$20 : BNE .untriggered ; You have to be in the trigger window. LDY.b #$03 : JSL.l Ancilla_CheckIfEntranceTriggered : BCC .untriggered diff --git a/msu.asm b/msu.asm index 5900be2..c4d1318 100644 --- a/msu.asm +++ b/msu.asm @@ -250,7 +250,7 @@ CheckMusicLoadRequest: BRA .check_fallback-3 .lightworld PHA - LDA OverworldEventData+$80 : AND.b #$40 : BEQ + + LDA OverworldEventDataWRAM+$80 : AND.b #$40 : BEQ + PLA LDA.b #60 : BRA .check_fallback-3 + @@ -344,7 +344,7 @@ CheckMusicLoadRequest: + CMP.b #$70 : BNE + ; Misery Mire - LDA OverworldEventData+$70 : AND.b #$20 : BEQ .rain + LDA OverworldEventDataWRAM+$70 : AND.b #$20 : BEQ .rain + LDA ProgressIndicator : CMP.b #$02 : BCS + diff --git a/music.asm b/music.asm index 03d50ae..746711c 100644 --- a/music.asm +++ b/music.asm @@ -33,7 +33,7 @@ PreOverworld_LoadProperties_ChooseMusic: LDX.b #$05 ; Lost woods theme ; check if we've pulled from the master sword pedestal - LDA OverworldEventData+$80 : AND.b #$40 : BEQ + + LDA OverworldEventDataWRAM+$80 : AND.b #$40 : BEQ + LDX.b #$02 ; Default light world theme + @@ -129,7 +129,7 @@ Overworld_FinishMirrorWarp: ; Check if we're entering the lost woods CMP.b #$00 : BNE + - LDA OverworldEventData+$80 : AND.b #$40 : BNE .endOfLightWorldChecks + LDA OverworldEventDataWRAM+$80 : AND.b #$40 : BNE .endOfLightWorldChecks LDX.b #$05 ; lost woods theme BRA .endOfLightWorldChecks + @@ -196,7 +196,7 @@ BirdTravel_LoadTargetAreaMusic: ;LDX.b #$05 ; Lost woods theme ; check if we've pulled from the master sword pedestal - ;LDA OverworldEventData+$80 : AND.b #$40 : BEQ + + ;LDA OverworldEventDataWRAM+$80 : AND.b #$40 : BEQ + ; LDX.b #$02 ; Default light world theme ;+ @@ -222,7 +222,7 @@ BirdTravel_LoadTargetAreaMusic: LDA $8A ; Misery Mire rain SFX CMP.b #$70 : BNE ++ - LDA OverworldEventData+$70 : AND.b #$20 : BNE ++ + LDA OverworldEventDataWRAM+$70 : AND.b #$20 : BNE ++ LDA.b #$01 : CMP $0131 : BEQ + STA $012D + : BRA .checkInverted diff --git a/openmode.asm b/openmode.asm deleted file mode 100644 index 94b0c55..0000000 --- a/openmode.asm +++ /dev/null @@ -1,29 +0,0 @@ -;================================================================================ -; Open Mode Uncle Rain State Check -;================================================================================ -!INFINITE_ARROWS = "$7F50C8" -!INFINITE_BOMBS = "$7F50C9" -!INFINITE_MAGIC = "$7F50CA" -SetUncleRainState: - LDA.l OpenMode : BEQ + : RTL : + ; we're done if open mode is on - LDA.b #$01 : STA ProgressIndicator -RTL -;-------------------------------------------------------------------------------- -InitOpenMode: - LDA.l OpenMode : BEQ + ; Skip if not open mode - LDA ProgressIndicator : CMP #$02 : !BGE + ; Skip if already past escape - LDA.b #$02 : STA ProgressIndicator ; Go to post-escape phase (pre aga1) - LDA ProgressFlags : ORA #$14 : STA ProgressFlags ; remove uncle - LDA StartingEntrance : CMP #$05 : BEQ ++ : LDA.b #$01 : ++ : STA StartingEntrance ; set spawn points to house+sanc unless already house+sanc+mountain - LDA OverworldEventData+$1B : ORA.b #$20 : STA OverworldEventData+$1B ; open castle gate - JSL MaybeSetPostAgaWorldState - + -RTL -;-------------------------------------------------------------------------------- -MaybeSetPostAgaWorldState: - LDA.l InstantPostAgaWorldState : BEQ + ; Skip if not enabled - LDA.b #$03 : STA ProgressIndicator ; Go to post-aga phase - LDA OverworldEventData+$02 : ORA.b #$20 : STA OverworldEventData+$02 ; make lumberjack tree accessible - + -RTL -;-------------------------------------------------------------------------------- diff --git a/pendantcrystalhud.asm b/pendantcrystalhud.asm index a0407b7..b9809a5 100644 --- a/pendantcrystalhud.asm +++ b/pendantcrystalhud.asm @@ -437,7 +437,7 @@ DrawHUDDungeonItems: .next_boss_kill LDX.w .boss_room_ids,Y - LDA.l RoomData.l,X + LDA.l RoomDataWRAM.l,X AND.w #$0800 BEQ ..skip_boss_kill diff --git a/sram.asm b/sram.asm index 5b4ce1e..2f2de53 100644 --- a/sram.asm +++ b/sram.asm @@ -21,7 +21,7 @@ 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. ; -; Example: We can use RoomData[$37].high to read or write the pot key in the first +; Example: We can use RoomDataWRAM[$37].high to read or write the pot key in the first ; floodable room in Swamp Palace ($04) ;-------------------------------------------------------------------------------- ; .high Byte: d d d d b k u r @@ -38,7 +38,7 @@ org 0 ; This module writes no bytes. Asar gives bank cross errors without this. ; c = Chest 0 ; q = Quadrant visits ;-------------------------------------------------------------------------------- -struct RoomData $7EF000 +struct RoomDataWRAM $7EF000 .l .low: skip 1 .high: skip 1 @@ -51,7 +51,7 @@ endstruct align 2 ; in WRAM (16-bits.) ; ; This label can be indexed with a plus symbol (e.g. The Hyrule Castle screen would -; be OverworldEventData+$1B or OverworldEventData+27) +; be OverworldEventDataWRAM+$1B or OverworldEventDataWRAM+27) ;-------------------------------------------------------------------------------- ; - i o - - - b - ; @@ -59,7 +59,7 @@ endstruct align 2 ; o = Overlay active ; b = Bomb wall opened ;-------------------------------------------------------------------------------- -OverworldEventData = $7EF280 +OverworldEventDataWRAM = $7EF280 ;================================================================================ ; Items & Equipment ($7EF340 - $7EF38B) @@ -170,7 +170,7 @@ InventoryTracking: skip 2 ; b r m p n s k f - - - - - - o q (bitfield) ; p = Magic Powder | n = Mushroom Past | s = Shovel ; k = Inactive Flute | f = Active Flute | o = Any bomb acquired ; q = Quickswap locked -BowTracking: skip 2 ; b s p - - - - - (bitfield) +BowTracking: skip 2 ; - - - - b s p - (bitfield) ; b = Bow | s = Silver Arrows Upgrade | p = Second Progressive Bow ; The front end writes two distinct progressive bow items. p ; indicates whether the "second" has been found independent of @@ -389,13 +389,19 @@ DummyValue: skip 1 ; $01 if you're a real dummy ;-------------------------------------------------------------------------------- base $700000 ; CartridgeSRAM: ; -skip $0340 ; +RoomDataWRAMSRAM: ; +skip $280 ; +OverworldEventDataSRAM: ; +skip $C0 ; EquipmentSRAM: skip 76 ; InventoryTrackingSRAM: skip 2 ; BowTrackingSRAM: skip 2 ; -skip 73 ; +skip 53 ; +ProgressIndicatorSRAM: skip 1 ; +skip 19 ; FileNameVanillaSRAM: skip 8 ; First four characters of file name -skip 287 +FileValiditySRAM: skip 2 ; +skip 285 ; 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 @@ -637,10 +643,14 @@ endmacro ; Direct SRAM Assertions ;-------------------------------------------------------------------------------- %assertSRAM(CartridgeSRAM, $700000) +%assertSRAM(RoomDataWRAMSRAM, $700000) +%assertSRAM(OverworldEventDataSRAM, $700280) %assertSRAM(EquipmentSRAM, $700340) %assertSRAM(InventoryTrackingSRAM, $70038C) %assertSRAM(BowTrackingSRAM, $70038E) +%assertSRAM(ProgressIndicatorSRAM, $7003C5) %assertSRAM(FileNameVanillaSRAM, $7003D9) +%assertSRAM(FileValiditySRAM, $7003E1) %assertSRAM(ExtendedFileNameSRAM, $700500) %assertSRAM(RomNameSRAM, $702000) %assertSRAM(RomVersionSRAM, $701FFC) diff --git a/stats.asm b/stats.asm index 1fef8ae..e38ae31 100644 --- a/stats.asm +++ b/stats.asm @@ -292,7 +292,7 @@ IncrementUWMirror: JSL.l StatTransitionCounter + PLA - JSL.l Dungeon_SaveRoomData ; thing we wrote over + JSL.l Dungeon_SaveRoomDataWRAM ; thing we wrote over RTL ;-------------------------------------------------------------------------------- IncrementSpentRupees: diff --git a/swordswap.asm b/swordswap.asm index b31da6a..f28e6d9 100644 --- a/swordswap.asm +++ b/swordswap.asm @@ -208,13 +208,13 @@ CheckMedallionSword: .outdoors LDA $8A : CMP.b #$70 : BNE + LDA.l MireRequiredMedallion : TAX : LDA.l .medallion_type, X : CMP $0303 : BNE .done - LDA OverworldEventData+$70 : AND.b #$20 : BNE .done + LDA OverworldEventDataWRAM+$70 : AND.b #$20 : BNE .done LDA.b #$08 : PHA : PLB ; set data bank to $08 LDY.b #$02 : JSL.l Ancilla_CheckIfEntranceTriggered : BCS .permit ; misery mire BRA .done + : CMP.b #$47 : BNE + LDA.l TRockRequiredMedallion : TAX : LDA.l .medallion_type, X : CMP $0303 : BNE .done - LDA OverworldEventData+$47 : AND.b #$20 : BNE .done + LDA OverworldEventDataWRAM+$47 : AND.b #$20 : BNE .done LDA.b #$08 : PHA : PLB ; set data bank to $08 LDY.b #$03 : JSL.l Ancilla_CheckIfEntranceTriggered : BCS .permit ; turtle rock + diff --git a/tables.asm b/tables.asm index d9c76a9..88cfcc3 100644 --- a/tables.asm +++ b/tables.asm @@ -104,9 +104,7 @@ org $308031 ; PC 0x180031 EnableEasterEggs: db #$00 ; #$00 = Off (default) - #$01 = On ;-------------------------------------------------------------------------------- -org $308032 ; PC 0x180032 -OpenMode: -db #$01 ; #$01 = Standard (default) - #$01 = Open +; 0x180032 (unused) ;-------------------------------------------------------------------------------- org $308033 ; PC 0x180033 HeartBeep: @@ -157,9 +155,7 @@ org $30803F ; PC 0x18003F HammerableGanon: db #$00 ; #$00 = Off (default) - #$01 = On ;-------------------------------------------------------------------------------- -org $308040 ; PC 0x180040 -PreopenCurtains: -db #$00 ; #$00 = Off (default) - #$01 = On +; 0x180040 - (unused) ;-------------------------------------------------------------------------------- org $308041 ; PC 0x180041 AllowSwordlessMedallionUse: @@ -169,9 +165,7 @@ org $308042 ; PC 0x180042 PermitSQFromBosses: db #$00 ; #$00 = Off (default) - #$01 = On ;-------------------------------------------------------------------------------- -org $308043 ; PC 0x180043 -StartingSword: -db #$00 ; #$00 = No Sword (default) - #$FF = Non-Sword +; 0x180043 (unused) ;-------------------------------------------------------------------------------- org $308044 ; PC 0x180044 AllowHammerTablets: @@ -186,9 +180,7 @@ HUDDungeonItems: ; display ---edcba a: Small Keys, b: Big Key, c: Map, d: Compass, e: Bosses db #$00 ;-------------------------------------------------------------------------------- -org $308046 ; PC 0x180046 Link's starting equipment -LinkStartingRupees: -dw #$0000 +; 0x180046 (unused) ;-------------------------------------------------------------------------------- org $308048 ; PC 0x180048 MenuSpeed: @@ -372,17 +364,7 @@ org $30808A ; PC 0x18008A BlockCastleDoorsInRain: db #$00 ; #$00 - Normal, $01 - Block them (Used by Entrance Rando in Standard Mode) ;-------------------------------------------------------------------------------- -org $30808B ; PC 0x18008B -PreopenPyramid: -db $00 ; #$00 = Off (default) - #$01 = On -;-------------------------------------------------------------------------------- -org $30808C ; PC 0x18008C -PreopenGanonsTower: -db $00 ; #$00 = Off (default) - #$01 = On -;-------------------------------------------------------------------------------- -org $30808D ; PC 0x18008D -InstantPostAgaWorldState: -db $00 ; #$00 = Off (default) - #$01 = On +; 0x18008B-0x18008D (unused) ;-------------------------------------------------------------------------------- org $30808E ; PC 0x18008E FakeBoots: @@ -954,15 +936,16 @@ db #$01 ; #$00 = Instant win if last goal item collected. $01 = (Default) must t ;-------------------------------------------------------------------------------- ; 0x180195 - 0x1801FF (unused) ;================================================================================ -org $308200 ; PC 0x180200 - 0x18020F +org $308200 ; PC 0x180200 - 0x18020B RedClockAmount: dw #$4650, #$0000 ; $00004650 = +5 minutes BlueClockAmount: dw #$B9B0, #$FFFF ; $FFFFB9B0 = -5 minutes GreenClockAmount: dw #$0000, #$0000 -StartingTime: -dw #$0000, #$0000 ; #$A5E0, #$0001 = 30 minutes +;-------------------------------------------------------------------------------- +; 0x18020C-0x18020F (unused) +;-------------------------------------------------------------------------------- ;================================================================================ org $09E3BB ; PC 0x4E3BB db $E4 ; Hera Basement Key (Set to programmable HP $EB) (set to $E4 for original hookable/boomable key behavior) @@ -1607,16 +1590,11 @@ dw $0000 ;-------------------------------------------------------------------------------- ; 0x182305 - 182FFF (unused) ;================================================================================ -org $30B000 ; PC 0x183000 - 0x183054 -StartingEquipment: -dw $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000 -dw $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000 -dw $0000, $0000, $0000, $0000, $0000, $0000, $1818, $FF00 -dw $0000, $0000, $0000, $0000, $F800, $0000, $0000, $0000 -dw $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000 -dw $0000, $0000 +org $30B000 ; PC 0x183000 - 0x1834FF +incsrc initsramtable.asm + ;-------------------------------------------------------------------------------- -; 0x183055 - 183FFF (unused) +; 0x183500 - 183FFF (unused) ;================================================================================ org $30C000 ; PC 0x184000 - 0x184040 ItemSubstitutionRules: @@ -1626,16 +1604,10 @@ db $51, $06, $52, $FF db $53, $06, $54, $FF db $FF, $FF, $FF, $FF - org $30C041 ; PC 0x184041 ForceFileName: -db $00 ; $00 = Player picks name (default) - $01 = Use StaticFileName +db $00 ; $00 = Player picks name (default) - $01 = Use StaticFileName (initsramtable.asm) -org $30C042 ; PC 0x184042 - 0x18405A -StaticFileName: -dw $0181, $0162, $0168, $018C -dw $0166, $014E, $0162, $018C -dw $0165, $0162, $0167, $018C ;-------------------------------------------------------------------------------- ; 0x18405B - 0x1847FF (unused) ;================================================================================ diff --git a/zelda.asm b/zelda.asm index 1a11cc1..df4508c 100644 --- a/zelda.asm +++ b/zelda.asm @@ -2,17 +2,18 @@ ; Spawn Zelda (or not) ;-------------------------------------------------------------------------------- SpawnZelda: - LDA.l FollowerIndicator : CMP #$08 : BEQ + ; don't spawn if dwarf is present - CMP #$07 : BEQ + ; don't spawn if frog is present - CMP #$0C : BEQ + ; don't spawn if purple chest is present + LDA.l FollowerIndicator : CMP.b #$08 : BEQ + ; don't spawn if dwarf is present + CMP.b #$07 : BEQ + ; don't spawn if frog is present + CMP.b #$0C : BEQ + ; don't spawn if purple chest is present CLC + RTL ;-------------------------------------------------------------------------------- EndRainState: - LDA ProgressIndicator : CMP.b #$02 : !BGE + ; skip if past escape already - LDA.b #$00 : STA !INFINITE_ARROWS : STA !INFINITE_BOMBS : STA !INFINITE_MAGIC - LDA.b #$02 : STA ProgressIndicator ; end rain state - JSL MaybeSetPostAgaWorldState + LDA.l InitProgressIndicator : BIT.b #$80 : BNE + ; check for instant post-aga + LDA.b #$02 : STA.l ProgressIndicator + RTL + + LDA.b #$03 : STA.l ProgressIndicator + LDA.l InitLumberjackOW : STA.l OverworldEventDataWRAM+$02 RTL ;--------------------------------------------------------------------------------