From aee5fe506a47bb10ae8b8478d23e14303b271af0 Mon Sep 17 00:00:00 2001 From: aerinon Date: Thu, 21 Oct 2021 14:11:57 -0600 Subject: [PATCH 01/96] Standing items start --- keydrop/potsanity.asm | 209 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 209 insertions(+) create mode 100644 keydrop/potsanity.asm diff --git a/keydrop/potsanity.asm b/keydrop/potsanity.asm new file mode 100644 index 0000000..e684193 --- /dev/null +++ b/keydrop/potsanity.asm @@ -0,0 +1,209 @@ +; hooks +; todo: look up this hook in jpdasm +org $01E6B0 + JSL RevealPotItem + RTS + +org $06926e ; <- 3126e - sprite_prep.asm : 2664 (LDA $0B9B : STA $0CBA, X) +JSL SpriteKeyPrep : NOP #2 + +org $06d049 ; <- 35049 sprite_absorbable : 31-32 (JSL Sprite_DrawRippleIfInWater : JSR Sprite_DrawAbsorbable) +JSL SpriteKeyDrawGFX : BRA + : NOP : + + +org $06d180 +JSL BigKeyGet : BCS $07 : NOP #5 + +org $06d18d ; <- 3518D - sprite_absorbable.asm : 274 (LDA $7EF36F : INC A : STA $7EF36F) +JSL KeyGet + +org $06f9f3 ; bank06.asm : 6732 (JSL Sprite_LoadProperties) +JSL LoadProperties_PreserveItemMaybe + + +; refs to other functions +org $06d23a +Sprite_DrawAbsorbable: +org $1eff81 +Sprite_DrawRippleIfInWater: +org $0db818 +Sprite_LoadProperties: + +; defines +SpawnedItemID = $7E0720 ; 0x02 +SpawnedItemPotIndex = $7E0722 ; 0x02 +SpawnedItemIsMultiWorld = $7E0724 ; 0x02 +SpawnedItemFlag = $7E0726 ; 0x02 +PotItems = $01DDE7 ;original secret table? + +RoomData_PotItems_Pointers = $01DB67 + +org $AA8000 +;tables: +MultiWorldTable: +; Reserve $200 256 * 2 + +org $A98200 +RevealPotItem: + STA.b $04 ; save tilemap coordinates + STZ.w SpawnedItemFlag + LDA.w $0B9C : AND.w #$FF00 : STA.w $0B9C + + LDA.b $A0 : ASL : TAX + + LDA.l RoomData_PotItems_Pointers,X : STA.b $00 ; we may move this + LDA.w #RoomData_PotItems_Pointers>>16 : STA.b $02 + + LDY.w #$FFFD : LDX.w #$FFFF + +.next_pot + INY : INY : INY + + LDA.b [$00],Y + CMP.w #$FFFF : BEQ .exit + + INX + + STA.w $06 ; remember the exact value + AND.w #$3FFF + CMP.b $04 : BNE .next_pot ; not the correct value + + STZ.w SpawnedItemIsMultiWorld + BIT.b $06 + BVS LoadMultiWorldPotItem + BMI LoadMajorPotItem + +.normal_secret + PLX ; remove the JSL return lower 16 bits + PEA.w $01E6E2-1 ; change return address to go back to the vanilla routine +.exit + RTL + +LoadMultiWorldPotItem: + INY : INY + LDA.b [$00],Y : AND.w #$00FF + + INC.w SpawnedItemIsMultiWorld + PHX + ASL : TAX + + LDA.l MultiWorldTable+1,X : AND.w #$00FF : STA.w !MULTIWORLD_SPRITEITEM_PLAYER_ID + + LDA.l MultiWorldTable+0,X : AND.w #$00FF + + PLX + + BRA SaveMajorItemDrop + +LoadMajorPotItem: + INY : INY + LDA.b [$00],Y : AND.w #$00FF + +SaveMajorItemDrop: + ; A currently holds the item receipt ID + ; X currently holds the pot item index + STA.w SpawnedItemID + STX.w SpawnedItemPotIndex + INC SpawnedItemFlag + LDA.w #$0008 : STA $0B9C ; indicates we should use the key routines + RTL + + +SpriteKeyPrep: + LDA.w $0B9B : STA.w $0CBA, x ; what we wrote over + PHA + LDA.l SpawnedItemFlag : BEQ + + LDA.l SpawnedItemID : STA $0E80, X + CMP #$24 : BNE ++ ; todo: check how the big key drop flows through this + LDA $A0 : CMP.b #$80 : BNE + + LDA SpawnedItemFlag : BNE + + LDA #$24 ; it's the big key drop? + ++ JSL PrepDynamicTile + + PLA + RTL + +SpriteKeyDrawGFX: + JSL Sprite_DrawRippleIfInWater + PHA + BRA + + - + + LDA $0E80, X + CMP.b #$24 : BNE + + LDA $A0 : CMP #$80 : BNE ++ + LDA SpawnedItemFlag : BNE ++ + LDA #$24 : BRA + + ++ PLA + PHK : PEA.w .jslrtsreturn-1 + PEA.w $068014 ; an rtl address - 1 in Bank06 + JML Sprite_DrawAbsorbable + .jslrtsreturn + RTL + + JSL DrawDynamicTile ; see DrawHeartPieceGFX if problems + CMP #$03 : BNE + + PHA : LDA $0E60, X : ORA.b #$20 : STA $0E60, X : PLA + + JSL.l Sprite_DrawShadowLong + PLA : RTL + +KeyGet: + LDA $7EF36F ; what we wrote over + PHA + LDY $0E80, X + ; todo: may need to check if we are in a dungeon or not $FF + LDA $A0 : CMP #$87 : BNE + ;check for hera cage + LDA SpawnedItemFlag : BNE + ; if it came from a pot, it's fine + JSR ShouldKeyBeCountedForDungeon : BCC ++ + JSL CountChestKeyLong + ++ PLA : RTL + + STY $00 + LDA !MULTIWORLD_ITEM_PLAYER_ID : BNE .receive + PHX + ; todo: may need to check if we are in a dungeon or not $FF + LDA $040C : LSR : TAX + LDA $00 : CMP.l KeyTable, X : BNE + + - JSL.l FullInventoryExternal : JSL CountChestKeyLong : PLX : PLA : RTL + + CMP.b #$AF : beq - ; universal key + CMP.b #$24 : beq - ; small key for this dungeon + PLX + .receive + JSL $0791b3 ; Player_HaltDashAttackLong + JSL.l Link_ReceiveItem + PLA : DEC : RTL + +KeyTable: +db $A0, $A0, $A2, $A3, $A4, $A5, $A6, $A7, $A8, $A9, $AA, $AB, $AC, $AD + +; Input Y - the item type +ShouldKeyBeCountedForDungeon: + PHX + ; todo: may need to check if we are in a dungeon or not $FF + LDA $040C : LSR : TAX + TYA : cmp KeyTable, X : BNE + + - PLX : SEC : RTS + + CMP.B #$24 : BEQ - + PLX : CLC : RTS + + +BigKeyGet: + LDY $0E80, X + CPY #$32 : BNE + + STZ $02E9 : LDY.b #$32 ; what we wrote over + PHX : JSL Link_ReceiveItem : PLX ; what we wrote over + CLC : RTL + + SEC : RTL + +LoadProperties_PreserveItemMaybe: + LDA $0E80, X : PHA + JSL Sprite_LoadProperties + PLA : STA $0e80, X + RTL + +org $01E676 +db $14, $14, $07 ; Blue rupee xyz:{ 0x050, 0x140, U } +db $28, $94, $08 ; Blue rupee xyz:{ 0x0A0, 0x140, U } +db $24, $95, $1F ; Blue rupee xyz:{ 0x050, 0x150, U } +db $28, $95, $4E ; Blue rupee xyz:{ 0x0A0, 0x150, U } +db $14, $96, $5E ; Blue rupee xyz:{ 0x050, 0x160, U } +db $28, $96, $64 ; Blue rupee xyz:{ 0x0A0, 0x160, U } +db $18, $98, $4B ; Blue rupee xyz:{ 0x060, 0x180, U } +db $1C, $98, $44 ; Blue rupee xyz:{ 0x070, 0x180, U } +db $20, $98, $07 ; Blue rupee xyz:{ 0x080, 0x180, U } +db $24, $98, $11 ; Blue rupee xyz:{ 0x090, 0x180, U } \ No newline at end of file From fcd9b949e8b3637726bf94ac95a7f73545115191 Mon Sep 17 00:00:00 2001 From: cassidy Date: Wed, 1 Dec 2021 19:48:18 -0500 Subject: [PATCH 02/96] Initial SRAM module check in Changes to save.asm and fileselect.asm to account for new WRAM buffer at $7F6000 saved at $700500, length $1000. Moves and additions noted at bottom of sram.asm, to be removed later. --- fileselect.asm | 17 +- save.asm | 25 ++- sram.asm | 569 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 592 insertions(+), 19 deletions(-) create mode 100644 sram.asm diff --git a/fileselect.asm b/fileselect.asm index a494226..8aed309 100644 --- a/fileselect.asm +++ b/fileselect.asm @@ -1,4 +1,3 @@ -!ExtendedPlayerName = "$700500" !ValidKeyLoaded = "$7F509E" ;FS prefix means file_select, since these defines and macros are specific to this screen @@ -136,22 +135,22 @@ DrawPlayerFileShared: LDA.b #FileSelectItems>>16 : PHA : PLB REP #$20 ; restore 16 bit accumulator - LDA !ExtendedPlayerName+$00 : ORA.w #!FS_COLOR_BW + LDA ExtendedFileNameSRAM+$08 : ORA.w #!FS_COLOR_BW %fs_draw8x16(6,5) - LDA !ExtendedPlayerName+$02 : ORA.w #!FS_COLOR_BW + LDA ExtendedFileNameSRAM+$0A : ORA.w #!FS_COLOR_BW %fs_draw8x16(6,6) - LDA !ExtendedPlayerName+$04 : ORA.w #!FS_COLOR_BW + LDA ExtendedFileNameSRAM+$0C : ORA.w #!FS_COLOR_BW %fs_draw8x16(6,7) - LDA !ExtendedPlayerName+$06 : ORA.w #!FS_COLOR_BW + LDA ExtendedFileNameSRAM+$0E : ORA.w #!FS_COLOR_BW %fs_draw8x16(6,8) - LDA !ExtendedPlayerName+$08 : ORA.w #!FS_COLOR_BW + LDA ExtendedFileNameSRAM+$10 : ORA.w #!FS_COLOR_BW %fs_draw8x16(9,5) - LDA !ExtendedPlayerName+$0A : ORA.w #!FS_COLOR_BW + LDA ExtendedFileNameSRAM+$12 : ORA.w #!FS_COLOR_BW %fs_draw8x16(9,6) - LDA !ExtendedPlayerName+$0C : ORA.w #!FS_COLOR_BW + LDA ExtendedFileNameSRAM+$14 : ORA.w #!FS_COLOR_BW %fs_draw8x16(9,7) - LDA !ExtendedPlayerName+$0E : ORA.w #!FS_COLOR_BW + LDA ExtendedFileNameSRAM+$16 : ORA.w #!FS_COLOR_BW %fs_draw8x16(9,8) JSR FileSelectDrawHudBar diff --git a/save.asm b/save.asm index 1b41061..da75292 100644 --- a/save.asm +++ b/save.asm @@ -27,6 +27,11 @@ 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 @@ -55,16 +60,16 @@ CopyExtendedSaveFileToWRAM: LDA #$80 : STA $4301 ; set bus B source to WRAM register - LDA #$00 : STA $2181 ; set WRAM register source address - LDA #$65 : STA $2182 - LDA #$7F : STA $2183 + LDA #$00 : STA $2181 ; set WRAM register source address + LDA #$60 : STA $2182 + LDA #$7F : STA $2183 STZ $4302 ; set bus A destination address to SRAM - LDA #$05 : STA $4303 - LDA #$70 : STA $4304 + LDA #$05 : STA $4303 + LDA #$70 : STA $4304 LDA #$00 : STA $4305 ; set transfer size to 0xB00 - LDA #$0B : STA $4306 ; STZ $4307 + LDA #$10 : STA $4306 ; STZ $4307 LDA #$01 : STA $420B ; begin DMA transfer ;-------------------------------------------------------------------------------- @@ -97,15 +102,15 @@ CopyExtendedWRAMSaveFileToSRAM: STA $4301 ; set bus B source to WRAM register - LDA #$00 : STA $2181 ; set WRAM register source address - LDA #$65 : STA $2182 - LDA #$7F : STA $2183 + LDA #$00 : STA $2181 ; set WRAM register source address + LDA #$60 : STA $2182 + LDA #$7F : STA $2183 STZ $4302 ; set bus A destination address to SRAM LDA #$05 : STA $4303 LDA #$70 : STA $4304 - LDA #$00 : STA $4305 ; set transfer size to 0xB00 + LDA #$10 : STA $4305 ; set transfer size to 0xB00 LDA #$0B : STA $4306 ; STZ $4307 LDA #$01 : STA $420B ; begin DMA transfer diff --git a/sram.asm b/sram.asm new file mode 100644 index 0000000..d7bea70 --- /dev/null +++ b/sram.asm @@ -0,0 +1,569 @@ +;================================================================================ +; SRAM Labels & Assertions +;-------------------------------------------------------------------------------- +; Labels for values in SRAM and assertions that ensure they're correct and +; at the expected addresses. All values larger than one byte are little endian. +;-------------------------------------------------------------------------------- +; $7EF000 - $7EF4FF in WRAM maps to the first $4FF bytes in SRAM (Bank $70) +; $7F6000 - $7F6FFF in WRAM maps to the next 4k bytes, occupying the 2nd and 3rd vanilla +; save file locations. ($700500 - $701500) +;-------------------------------------------------------------------------------- + +;================================================================================ +; Room Data ($7EF000 - $7EF27F +;-------------------------------------------------------------------------------- +; Each room has two bytes. There are 296 ($128) rooms in the ROM. The data beyond +; $7EF24F is unused. The current room index is located at $A0 in WRAM (16-bits.) +; +; The quadrant bits from left to right correspond to quadrants +; 4 (northwest), 3 (northeast), 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].Low to read or write the pot key in the first +; floodable room in Swamp Palace ($04) +;-------------------------------------------------------------------------------- +; Low Byte: d d d d b k u r +; High Byte: c c c c q q q q +; +; d = Door opened (key, bomb wall, etc) +; b = Boss kill / Heart Piece +; k = Key +; u = Second key +; t = Chest 4 / Rupee floor / Swamp drains +; s = Chest 3 / Bomable floor / PoD or Desert wall +; e = Chest 2 +; h = Chest 1 +; c = Chest 0 +; q = Quadrant visits +;-------------------------------------------------------------------------------- +struct RoomData $7EF000 + .Low: skip 1 + .High: skip 1 +endstruct align 2 + +;================================================================================ +; Overworld Event Data ($7EF280 - $7EF33F) +;-------------------------------------------------------------------------------- +; Each overworld area has one byte. The overworld screen index is located at $8A +; in WRAM (16-bits.) +; +; This label can be indexed with a plus symbol (e.g. The Hyrule Castle screen would +; be OverworldData+$1B or OverworldData+27) +;-------------------------------------------------------------------------------- +; - i o - - - b - +; +; i = Free-standing item collected. Also used for sprites like the castle tower barrier +; o = Overlay active +; b = Secondary overlay active +;-------------------------------------------------------------------------------- +OverworldData = $7EF280 + +;================================================================================ +; Items & Equipment ($7EF340 - $7EF38B) +;-------------------------------------------------------------------------------- +; Current equipment labels & values +; Values will represent current menu selection in cases where player can switch +; items (e.g. holding powder and mushroom at the same time.) +; +; $00 = None +;-------------------------------------------------------------------------------- +base $7EF340 +SRAMEquipment: ; +BowEquipment: skip 1 ; $01 = Bow | $02 = Bow & Arrows + ; $03 = Silver Arrow Bow | $04 = Bow & Silver Arrows +BoomerangEquipment: skip 1 ; $01 = Blue | $02 = Red +HookshotEquipment: skip 1 ; $01 = Hookshot +BombsEquipment: skip 1 ; Number of bombs currently held (8-bit integer) +PowderEquipment: skip 1 ; $01 = Mushroom | $02 = Powder +FireRodEquipment: skip 1 ; $01 = Fire Rod +IceRodEquipment: skip 1 ; $01 = Ice Rod +BombosEquipment: skip 1 ; $01 = Bombos Medallion +EtherEquipment: skip 1 ; $01 = Ether Medallion +QuakeEquipment: skip 1 ; $01 = Quake Medallion +LampEquipment: skip 1 ; $01 = Lamp +HammerEquipment: skip 1 ; $01 = Hammer +FluteEquipment: skip 1 ; $01 = Shovel | $02 = Inactive Flute | $03 = Active Flute +BugNetEquipment: skip 1 ; $01 = Bug Net +BookOfMudoraEquipment: skip 1 ; $01 = Book of Mudora +BottleIndex: skip 1 ; Current bottle in menu. 1-based index into BottleContents below +SomariaEquipment: skip 1 ; $01 = Cane of Somaria +ByrnaEquipment: skip 1 ; $01 = Cane of Byrna +CapeEquipment: skip 1 ; $01 = Magic Cape +MirrorEquipment: skip 1 ; $01 = Scroll (graphic only) | $02 = Mirror +GloveEquipment: skip 1 ; $01 = Power Gloves | $02 = Titan's Mitts +BootsEquipment: skip 1 ; \ $01 = Boots/Flippers | These only show menu item +FlippersEquipment: skip 1 ; / Correct bits must be set in AbilityFlags to dash/swim +MoonPearlEquipment: skip 1 ; $01 = Moon Pearl +skip 1 ; Not used +SwordEquipment: skip 1 ; $01 = Fighter | $02 = Master | $03 = Tempered | $04 = Gold +ShieldEquipment: skip 1 ; $01 = Fighter | $02 = Red | $03 = Mirror +ArmorEquipment: skip 1 ; $00 = Green | $01 = Blue | $02 = Red +BottleContentsOne: skip 1 ; \ Bottle Contents +BottleContentsTwo: skip 1 ; | $00 = No Bottle | $01 = Mushroom | $02 = Empty Bottle +BottleContentsThree: skip 1 ; | $03 = Red Potion | $04 = Green Potion | $05 = Blue Potion +BottleContentsFour: skip 1 ; / $06 = Fairy | $07 = Bee | $08 = Good Bee +TargetRupees: skip 2 ; \ CurrentRupees will always increment or decrement to match +CurrentRupees: skip 2 ; / TargetRupees if not equal (16-bit integer) +;-------------------------------------------------------------------------------- + ; Dungeon item bitfields +CompassFieldOne: skip 2 ; \ - - g r t h i s +BigKeyFieldOne: skip 2 ; | g = Ganon's Tower | r = Turtle Rock | t = Thieves' Town +MapFieldOne: skip -3 ; / h = Tower of Hera | i = Ice Palace | s = Skull Woods +CompassFieldTwo: skip 2 ; \ m d s a t e h p +BigKeyFieldTwo: skip 2 ; | m = Misery Mire | d = Palace of Darkness | s = Swamp Palace +MapFieldTwo: skip 1 ; | a = Aga Tower | t = Desert Palace | e = Eastern Palace + ; / h = Hyrule Castle | s = Sewer Passage +;-------------------------------------------------------------------------------- + ; HUD & other equipment +skip 1 ; Wishing Pond Rupee (Unused) +HeartPieceFraction: skip 1 ; Heart pieces of four for upgrade. Wraps around to $00 after $03. +HealthCapacity: skip 1 ; \ Health Capacity & Current Health +CurrentHealth: skip 1 ; / Max value 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) +HeartFiller: 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) + ; g = Green (Courage) | b = Blue (Power) | r = Red (Wisdom) +BombFiller: skip 1 ; Bombs collected yet to be filled (integer) +ArrowFiller: skip 1 ; Arrows collected yet to be filled (integer) +CurrentArrows: skip 1 ; Current arrows (integer) +skip 1 ; Unknown +AbilityFlags: skip 1 ; - r t - p d s - (bitfield) + ; r = Read | t = Talk | p = Pull | d = Dash + ; s = Swim +CurrentCrystals: skip 1 ; - 3 4 2 7 5 1 6 (bitfield) +MagicConsumption: skip 1 ; $00 = Normal | $01 = Half Magic | $02 = Quarter Magic +;-------------------------------------------------------------------------------- + ; Small keys earned per dungeon (integers) +SewerKeys: skip 1 ; \ Hyrule Castle and Sewer keys typically increment +HyruleCastleKeys: skip 1 ; / and decrement together +EasternKeys: skip 1 ; Eastern Palace small keys +DesertKeys: skip 1 ; Desert Palace small keys +CastleTowerKeys: skip 1 ; Agahnim's Tower small keys +SwampKeys: skip 1 ; Swamp Palace small keys +PalaceOfDarknessKeys: skip 1 ; Palace of Darkness small keys +MireKeys: skip 1 ; Misery Mire small keys +SkullWoodsKeys: skip 1 ; Skull Woods small keys +IcePalaceKeys: skip 1 ; Ice Palace small keys +HeraKeys: skip 1 ; Tower of Hera small keys +ThievesTownKeys: skip 1 ; Thieves' Town small keys +TurtleRockKeys: skip 1 ; Turtle Rock small keys +GanonsTowerKeys: skip 1 ; Ganon's Tower small keys +skip 2 ; Unused + +;================================================================================ +; Tracking & Indicators ($7EF38C - $7EF3F0) +;-------------------------------------------------------------------------------- +InventoryTracking: skip 2 ; b r m p n s k f (bitfield) + ; b = Blue Boomerang | r = Red Boomerang | m = Mushroom Current + ; p = Magic Powder | n = Mushroom Past | s = Shovel + ; k = Inactive Flute | f = Active Flute +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 + ; the first +ItemLimitCounts: skip 3 ; Keeps track of limited non-progressive items such as lamp. + ; See: ItemSubstitutionRules in tables.asm +skip 50 ; +ProgressIndicator: skip 1 ; $00 = Pre-Uncle | $01 = Post-Uncle item | $02 = Zelda Rescued + ; $03 = Agahnim 1 defeated + ; $04 and above don't do anything. $00-$02 used in standard mode +ProgressFlags: skip 1 ; - - - u - z - s (bitfield) + ; u = Uncle left house | z = Mantle | s = Uncle item obtained +MapIcons: skip 1 ; Used for deciding which icons to display on OW map + ; $03 = Pendants | $04 = Master Sword | $05 = Skull at Hyrule Castle + ; $06 = Crystal 1 | $07 = All Crystals | $08 = Skull at Ganon's Tower +StartingEntrance: skip 1 ; Starting entrance to use + ; $00 = Link's House | $01 = Menu or Pyramid w/ Aga dead & mirror + ; $02 = Zelda's Cell | $03 = Secret Passage or HC if entered (escape) + ; $04 = Throne Room (escape) | $05 = Old Man Cave w/ Old Man +NpcFlagsVanilla: skip 1 ; - - b p s - m h (bitfield) + ; b = Frog rescued | p = Purple Chest | s = Stumpy (tree kid) + ; m = Bottle Merchant | h = Hobo +CurrentWorld: skip 1 ; $00 = Light World | $40 = Dark World +skip 1 ; Unused +FollowerIndicator: skip 1 ; $00 = No Follower | $01 = Zelda | $04 = Old Man + ; $06 = Blind Maiden | $07 = Frog | $08 = Dwarf + ; $09 = Locksmith | $0A = Kiki | $0C = Purple Chest + ; $0D = Big Bomb +FollowerXCoord: skip 2 ; \ Cached X and Y overworld coordinates of dropped follower +FollowerYCoord: skip 2 ; / (16-bit integers) +DroppedFollowerIndoors: skip 1 ; $00 = Dropped follower outdoors | $01 = Dropped follower indoors +DroppedFollowerLayer: skip 1 ; $00 = Upper layer | $01 = Lower layer +FollowerDropped: skip 1 ; Set to $80 when a follower exists and has been dropped somewhere + ; $00 otherwise +skip 5 ; Unused +skip 8 ; Unused +FileValidity: skip 2 ; Always $55AA. Don't write. + +;================================================================================ +; Rando-Specific Assignments & Game Stats ($7EF3F1 - $7EF4FF) +;-------------------------------------------------------------------------------- +skip 28 ; Unused +GameCounter: skip 2 ; Number of deaths and save + quits (16-bit integer) +PostGameCounter: skip 2 ; Initialized to $FFFF, replaced with GameCounter on goal completion + ; Number is displayed on file select when not $FFFF. Max 999 (16-bit integer) +skip 13 ; +NpcFlagsOne: skip 1 ; l - c s t k z o (bitfield) + ; l = Library | c = Catfish | s = Sahasrahla | t = Stumpy + ; k = Sick Kid | z = King Zora | o = Old Man +NpcFlagsTwo: skip 1 ; b - p m f s b e (bitfield) + ; b = Magic Bat | p = Potion Shop (Powder) | m = Lost Woods (Mushroom) + ; f = Fairy (unused) | s = Smith | b = Bombos Tablet + ; e = Ether Tablet +skip 2 ; Unused +MapOverlay: skip 2 ; Used to reveal dungeon prizes on the map in modes where maps, + ; Saha, and the bomb shop guy reveal dungeon prizes (bitfield) + ; \ - - g r t h i s + ; | g = Ganon's Tower | r = Turtle Rock | t = Thieves' Town + ; / h = Tower of Hera | i = Ice Palace | s = Skull Woods + ; \ m d s a t e h p + ; | m = Misery Mire | d = Palace of Darkness | s = Swamp Palace + ; | a = Aga Tower | t = Desert Palace | e = Eastern Palace + ; / h = Hyrule Castle | s = Sewer Passage +GeneralFlags: skip 1 ; - - h - p i - g (bitfield) + ; h = HUD Flag | p = Force pyramid + ; i = Ignore faeries | g = Has diggable grove item +HighestSword: skip 1 ; Highest sword level (integer) +GoalCounter: skip 2 ; Goal items collected (16-bit integer) +ProgrammableItemOne: skip 2 ; \ Reserved for programmable items +ProgrammableItemTwo: skip 2 ; | +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 +TotalItemCounter: skip 2 ; Total items collected (integer) +TemperedGoldBosses: skip 1 ; t t t t g g g g (packed integers) + ; t = Tempered Sword boss kills | g = Gold Sword boss kills +FighterMasterBosses: skip 1 ; f f f f m m m m (packed integers) + ; f = Fighter Sword boss kills | m = Master Sword boss kills +BigKeysBigChests: skip 1 ; k k k k c c c c (packed integers) + ; k = Big Keys collected | c = Big Chests opened +MapsCompasses: skip 1 ; m m m m c c c c (packed integers) + ; m = Maps collected | c = Compasses collected +HeartPiecesPendants: skip 1 ; h h h h - - p p (packed integers) + ; h = Heart Pieces collected | p = Pendants collected +PreGTBKLocations: skip 1 ; Locations checked in GT before finding the big key + ; b = Big Bomb Acquired | s = Silver Arrows Acquired + ; c = GT locations collected before big key +RupeesSpent: skip 2 ; Rupees spent (16-bit integer) +SaveQuits: skip 1 ; Number of times player has saved and quit (integer) +LoopFrames: skip 4 ; Frame counter incremented during frame hook (32-bit integer) +PreBootsLocations: skip 2 ; Number of locations checked before getting boots (integer) +PreMirrorLocations: skip 2 ; Number of locations checked before getting mirror (integer) +PreFluteLocations: skip 2 ; Number of locations checked before getting flute (integer) +skip 2 ; Unused +OverworldMirrors: skip 1 ; Number of times mirror used on overworld (integer) +UnderworldMirrors: skip 1 ; Number of times mirror used in underworld (integer) +ScreenTransitions: skip 2 ; Number of screen transitions (16-bit integer) +NMIFrames: skip 4 ; Frame counter incremented during NMI hook (32-bit integer) +ChestsOpened: skip 1 ; Number of chests opened. Doesn't count NPC, free standing items etc (integer) +StatsLocked: skip 1 ; Set to $01 when goal is completed; game stops counting stats. +MenuTime: skip 4 ; Total menu time in frames (32-bit integer) +HeartPieces: skip 1 ; Total number of heart pieces collected (integer) +DeathCounter: skip 1 ; Number of deaths (integer) +skip 1 ; Reserved +FluteCounter: skip 1 ; Number of times fluted (integer) +skip 6 ; +SwordlessBosses: skip 1 ; Number of bosses killed without a sword (integer) +FaerieRevivalCounter: skip 1 ; Number of faerie revivals (integer) +ChallengeTimer: skip 4 ; Timer used for OHKO etc +SwordTime: skip 4 ; Time first sword found in frames (32-bit integer) +BootsTime: skip 4 ; Time boots found in frames (32-bit integer) +FluteTime: skip 4 ; Time flute found in frames (32-bit integer) +MirrorTime: skip 4 ; Time mirror found in frames (32-bit integer) +ChestTurnCounter: skip 1 ; Number of chest turns (integer) +CapacityUpgrades: skip 1 ; Number of capacity upgrades collected (integer) +DamageCounter: skip 2 ; Damage taken by player (16-bit integer) +MagicCounter: skip 2 ; Magic used by player (16-bit integer) +HighestMail: skip 1 ; Highest mail level +SmallKeyCounter: skip 1 ; Total Number of small keys collected (integer) +skip 48 ; Unused +ServiceSequence: skip 1 ; Service sequence value. See servicerequest.asL +skip 49 ; Unused + ; \ Dungeon locations checked counters (integers) +HCLocations: skip 1 ; | Hyrule Castle +SewerLocations: skip 1 ; | Sewer Passage +EPLocations: skip 1 ; | Eastern Palace +DPLocations: skip 1 ; | Desert Palace +CTLocations: skip 1 ; | Agahnim's Tower +SPLocations: skip 1 ; | Swamp Palace +PDLocations: skip 1 ; | Palace of Darkness +MMLocations: skip 1 ; | Misery Mire +SWLocations: skip 1 ; | Skull Woods +IPLocations: skip 1 ; | Ice Palace +THLocations: skip 1 ; | Tower of Hera +TTLocations: skip 1 ; | Thieves' Town +TRLocations: skip 1 ; | Turtle Rock +GTLocations: skip 1 ; / Ganon's Tower + ; \ Chest Key Counters. Only counts keys placed in chests. (integers) +HCChestKeys: skip 1 ; | Hyrule Castle +SewerChestKeys: skip 1 ; | Sewer Passage +EPChestKeys: skip 1 ; | Eastern Palace +DPChestKeys: skip 1 ; | Desert Palace +CTChestKeys: skip 1 ; | Agahnim's Tower +SPChestKeys: skip 1 ; | Swamp Palace +PDChestKeys: skip 1 ; | Palace of Darkness +MMChestKeys: skip 1 ; | Misery Mire +SWChestKeys: skip 1 ; | Skull Woods +IPChestKeys: skip 1 ; | Ice Palace +THChestKeys: skip 1 ; | Tower of Hera +TTChestKeys: skip 1 ; | Thieves' Town +TRChestKeys: skip 1 ; | Turtle Rock +GTChestKeys: skip 1 ; / Ganon's Tower +skip 2 ; Unused +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. + +;================================================================================ +; Expanded SRAM ($7F6000 - $7F6FFF) +;-------------------------------------------------------------------------------- +; This $1000 byte segment is saved beginning where the second save file was in SRAM +; beginning at $700500 +;-------------------------------------------------------------------------------- +base $7F6000 ; $1000 byte buffer we place beginning at second save file +ExtendedFileNameSRAM = $706000 ; We read and write the file name directly from and to SRAM +ExtendedFileNameWRAM: skip 24 ; File name, 12 word-length characters. +VERSION: skip 4 ; $0000 = Default TODO +RoomPotData: skip 592 ; Table for expanded pot shuffle +PurchaseCounts: skip 96 ; Keeps track of shop purchases +DummyValue: skip 1 ; $01 if you're a real dummy +;-------------------------------------------------------------------------------- +base $7F1000 ; +RomName: ; ROM name from $FFC0, burned in during init (21 bytes) + ; If value in the ROM doesn't match SRAM, save is cleared. + +base off + +;================================================================================ +; Vanilla Assertions +;-------------------------------------------------------------------------------- +; All of these need to pass for the base rom to build or something is probably +; very wrong. +;-------------------------------------------------------------------------------- +assert SRAMEquipment = $7EF340, "SRAMEquipment labeled at incorrect address" +assert BowEquipment = $7EF340, "BowEquipment labeled at incorrect address" +assert BoomerangEquipment = $7EF341, "BoomerangEquipment labeled at incorrect address" +assert HookshotEquipment = $7EF342, "HookshotEquipment labeled at incorrect address" +assert BombsEquipment = $7EF343, "BombsEquipment labeled at incorrect address" +assert PowderEquipment = $7EF344, "PowderEquipment labeled at incorrect address" +assert FireRodEquipment = $7EF345, "FireRodEquipment labeled at incorrect address" +assert IceRodEquipment = $7EF346, "IceRodEquipment labeled at incorrect address" +assert BombosEquipment = $7EF347, "BombosEquipment labeled at incorrect address" +assert EtherEquipment = $7EF348, "EtherEquipment labeled at incorrect address" +assert QuakeEquipment = $7EF349, "QuakeEquipment labeled at incorrect address" +assert LampEquipment = $7EF34A, "LampEquipment labeled at incorrect address" +assert HammerEquipment = $7EF34B, "HammerEquipment labeled at incorrect address" +assert FluteEquipment = $7EF34C, "FluteEquipment labeled at incorrect address" +assert BugNetEquipment = $7EF34D, "BugNetEquipment labeled at incorrect address" +assert BookOfMudoraEquipment = $7EF34E, "BookOfMudoraEquipment labeled at incorrect address" +assert BottleIndex = $7EF34F, "BottleIndex labeled at incorrect address" +assert SomariaEquipment = $7EF350, "SomariaEquipment labeled at incorrect address" +assert ByrnaEquipment = $7EF351, "ByrnaEquipment labeled at incorrect address" +assert CapeEquipment = $7EF352, "CapeEquipment labeled at incorrect address" +assert MirrorEquipment = $7EF353, "MirrorEquipment labeled at incorrect address" +assert GloveEquipment = $7EF354, "GloveEquipment labeled at incorrect address" +assert BootsEquipment = $7EF355, "BootsEquipment labeled at incorrect address" +assert FlippersEquipment = $7EF356, "FlippersEquipment labeled at incorrect address" +assert MoonPearlEquipment = $7EF357, "MoonPearlEquipment labeled at incorrect address" +assert SwordEquipment = $7EF359, "SwordEquipment labeled at incorrect address" +assert ShieldEquipment = $7EF35A, "ShieldEquipment labeled at incorrect address" +assert ArmorEquipment = $7EF35B, "ArmorEquipment labeled at incorrect address" +assert BottleContentsOne = $7EF35C, "BottleContentsOne labeled at incorrect address" +assert BottleContentsTwo = $7EF35D, "BottleContentsTwo labeled at incorrect address" +assert BottleContentsThree = $7EF35E, "BottleContentsThree labeled at incorrect address" +assert BottleContentsFour = $7EF35F, "BottleContentsFour labeled at incorrect address" +assert TargetRupees = $7EF360, "TargetRupees labeled at incorrect address" +assert CurrentRupees = $7EF362, "CurrentRupees labeled at incorrect address" +;-------------------------------------------------------------------------------- +assert CompassFieldOne = $7EF364, "Compass bitfield labeled at incorrect address" +assert CompassFieldTwo = $7EF365, "Compass bitfield labeled at incorrect address" +assert BigKeyFieldOne = $7EF366, "Big Key item bitfield labeled at incorrect address" +assert BigKeyFieldTwo = $7EF367, "Big Key item bitfield labeled at incorrect address" +assert MapFieldOne = $7EF368, "Map item bitfield labeled at incorrect address" +assert MapFieldTwo = $7EF369, "Map item bitfield labeled at incorrect address" +;-------------------------------------------------------------------------------- +assert HeartPieceFraction = $7EF36B, "HeartPieceFraction labeled at incorrect address" +assert HealthCapacity = $7EF36C, "HealthCapacity labeled at incorrect address" +assert CurrentHealth = $7EF36D, "CurrentHealth labeled at incorrect address" +assert CurrentMagic = $7EF36E, "CurrentMagic labeled at incorrect address" +assert CurrentSmallKeys = $7EF36F, "CurrentSmallKeys labeled at incorrect address" +assert BombCapacityUpgrades = $7EF370, "BombCapacityUpgrades labeled at incorrect address" +assert ArrowCapacityUpgrades = $7EF371, "ArrowCapacityUpgrades labeled at incorrect address" +assert HeartFiller = $7EF372, "HeartFiller labeled at incorrect address" +assert MagicFiller = $7EF373, "MagicFiller labeled at incorrect address" +assert PendantsField = $7EF374, "PendantsField labeled at incorrect address" +assert BombFiller = $7EF375, "BombFiller labeled at incorrect address" +assert ArrowFiller = $7EF376, "ArrowFiller labeled at incorrect address" +assert CurrentArrows = $7EF377, "CurrentArrows labeled at incorrect address" +assert AbilityFlags = $7EF379, "AbilityFlags labeled at incorrect address" +assert CurrentCrystals = $7EF37A, "CurrentCrystals labeled at incorrect address" +assert MagicConsumption = $7EF37B, "MagicConsumption labeled at incorrect address" +;-------------------------------------------------------------------------------- +assert SewerKeys = $7EF37C, "SewerKeys labeled at incorrect address" +assert HyruleCastleKeys = $7EF37D, "HyruleCastleKeys labeled at incorrect address" +assert EasternKeys = $7EF37E, "EasternKeys labeled at incorrect address" +assert DesertKeys = $7EF37F, "DesertKeys labeled at incorrect address" +assert CastleTowerKeys = $7EF380, "CastleTowerKeys labeled at incorrect address" +assert SwampKeys = $7EF381, "SwampKeys labeled at incorrect address" +assert PalaceOfDarknessKeys = $7EF382, "PalaceOfDarknessKeys labeled at incorrect address" +assert MireKeys = $7EF383, "MireKeys labeled at incorrect address" +assert SkullWoodsKeys = $7EF384, "SkullWoodsKeys labeled at incorrect address" +assert IcePalaceKeys = $7EF385, "IcePalaceKeys labeled at incorrect address" +assert HeraKeys = $7EF386, "HeraKeys labeled at incorrect address" +assert ThievesTownKeys = $7EF387, "ThievesTownKeys labeled at incorrect address" +assert TurtleRockKeys = $7EF388, "TurtleRockKeys labeled at incorrect address" +assert GanonsTowerKeys = $7EF389, "GanonsTowerKeys labeled at incorrect address" +;-------------------------------------------------------------------------------- +assert ProgressIndicator = $7EF3C5, "ProgressIndicator labeled at incorrect address" +assert ProgressFlags = $7EF3C6, "ProgressFlags labeled at incorrect address" +assert MapIcons = $7EF3C7, "MapIcons labeled at incorrect address" +assert StartingEntrance = $7EF3C8, "StartingEntrance labeled at incorrect address" +assert NpcFlagsVanilla = $7EF3C9, "NpcFlagsVanilla labeled at incorrect address" +assert CurrentWorld = $7EF3CA, "CurrentWorld labeled at incorrect address" +assert FollowerIndicator = $7EF3CC, "FollowerIndicator labeled at incorrect address" +assert FollowerXCoord = $7EF3CD, "FollowerXCoord labeled at incorrect address" +assert FollowerYCoord = $7EF3CF, "FollowerYCoord labeled at incorrect address" +assert DroppedFollowerIndoors = $7EF3D1, "DroppedFollowerIndoors labeled at incorrect address" +assert DroppedFollowerLayer = $7EF3D2, "DroppedFollowerLayer labeled at incorrect address" +assert FollowerDropped = $7EF3D3, "FollowerDropped labeled at incorrect address" +assert FileValidity = $7EF3E1, "FileValidity labeled at incorrect address" +assert InverseChecksum = $7EF4FE, "InverseChecksum labeled at incorrect address" + +;================================================================================ +; Randomizer Assertions +;-------------------------------------------------------------------------------- +; Trackers and other third party consumers may depend on these values +;-------------------------------------------------------------------------------- +assert InventoryTracking = $7EF38C, "InventoryTracking labeled at incorrect address" +assert BowTracking = $7EF38E, "BowTracking labeled at incorrect address" +assert ItemLimitCounts = $7EF390, "ItemLimitCounts labeled at incorrect address" +;-------------------------------------------------------------------------------- +assert GameCounter = $7EF3FF, "GameCounter labeled at incorrect address" +assert PostGameCounter = $7EF401, "PostGameCounter labeled at incorrect address" +assert NpcFlagsOne = $7EF410, "NPCFlagsOne labeled at incorrect address" +assert NpcFlagsTwo = $7EF411, "NPCFlagsTwo labeled at incorrect address" +assert MapOverlay = $7EF414, "MapOverlay labeled at incorrect address" +assert GeneralFlags = $7EF416, "GeneralFlags labeled at incorrect address" +assert HighestSword = $7EF417, "HighestSword labeled at incorrect address" +assert GoalCounter = $7EF418, "GoalCounter labeled at incorrect address" +assert ProgrammableItemOne = $7EF41A, "ProgrammableItemOne labeled at incorrect address" +assert ProgrammableItemTwo = $7EF41C, "ProgrammableItemTwo labeled at incorrect address" +assert ProgrammableItemThree = $7EF41E, "ProgrammableItemThree labeled at incorrect address" +assert BonkCounter = $7EF420, "BonkCounter labeled at incorrect address" +assert YAItemCounter = $7EF421, "YAItemCounter labeled at incorrect address" +assert HighestShield = $7EF422, "SwordsShields labeled at incorrect address" +assert TotalItemCounter = $7EF423, "TotalItemCounter labeled at incorrect address" +assert TemperedGoldBosses = $7EF425, "TemperedGoldBosses labeled at incorrect address" +assert FighterMasterBosses = $7EF426, "FighterMasterBosses labeled at incorrect address" +assert BigKeysBigChests = $7EF427, "BigKeysBigChests labeled at incorrect address" +assert MapsCompasses = $7EF428, "MapsCompasses labeled at incorrect address" +assert HeartPiecesPendants = $7EF429, "HeartPiecesPendants labeled at incorrect address" +assert PreGTBKLocations = $7EF42A, "PreGTBKLocations labeled at incorrect address" +assert RupeesSpent = $7EF42B, "RupeesSpent labeled at incorrect address" +assert SaveQuits = $7EF42D, "SaveQuits labeled at incorrect address" +assert LoopFrames = $7EF42E, "LoopFrames labeled at incorrect address" +assert PreBootsLocations = $7EF432, "PreBootsLocations labeled at incorrect address" +assert PreMirrorLocations = $7EF434, "PreMirrorLocations labeled at incorrect address" +assert PreFluteLocations = $7EF436, "PreFluteLocations labeled at incorrect address" +assert OverworldMirrors = $7EF43A, "OverworldMirrors labeled at incorrect address" +assert UnderworldMirrors = $7EF43B, "UnderworldMirrors labeled at incorrect address" +assert ScreenTransitions = $7EF43C, "ScreenTransitions labeled at incorrect address" +assert NMIFrames = $7EF43E, "NMIFrames labeled at incorrect address" +assert ChestsOpened = $7EF442, "ChestsOpened labeled at incorrect address" +assert StatsLocked = $7EF443, "StatsLocked labeled at incorrect address" +assert MenuTime = $7EF444, "MenuTime labeled at incorrect address" +assert HeartPieces = $7EF448, "HeartPieces labeled at incorrect address" +assert DeathCounter = $7EF449, "DeathCounter labeled at incorrect address" +assert FluteCounter = $7EF44B, "FluteCounter labeled at incorrect address" +assert SwordlessBosses = $7EF452, "SwordlessBosses labeled at incorrect address" +assert FaerieRevivalCounter = $7EF453, "FaerieRevivalCounter labeled at incorrect address" +assert ChallengeTimer = $7EF454, "ChallengeTimer labeled at incorrect address" +assert SwordTime = $7EF458, "SwordTime labeled at incorrect address" +assert BootsTime = $7EF45C, "BootsTime labeled at incorrect address" +assert FluteTime = $7EF460, "FluteTime labeled at incorrect address" +assert MirrorTime = $7EF464, "MirrorTime labeled at incorrect address" +assert ChestTurnCounter = $7EF468, "ChestTurnCounter labeled at incorrect address" +assert DamageCounter = $7EF46A, "DamageCounter labeled at incorrect address" +assert MagicCounter = $7EF46C, "MagicCounter labeled at incorrect address" +assert HighestMail = $7EF46E, "HighestMail labeled at incorrect address" +assert SmallKeyCounter = $7EF46F, "SmallKeyCounter labeled at incorrect address" +;-------------------------------------------------------------------------------- +assert ServiceSequence = $7EF4A0, "ServiceSequence labeled at incorrect address" +;-------------------------------------------------------------------------------- +assert HCLocations = $7EF4D2, "HCLocations labeled at incorrect address" +assert SewerLocations = $7EF4D3, "SewersLocations labeled at incorrect address" +assert EPLocations = $7EF4D4, "EPLocations labeled at incorrect address" +assert DPLocations = $7EF4D5, "DPLocations labeled at incorrect address" +assert CTLocations = $7EF4D6, "CTLocations labeled at incorrect address" +assert SPLocations = $7EF4D7, "SPLocations labeled at incorrect address" +assert PDLocations = $7EF4D8, "PDLocations labeled at incorrect address" +assert MMLocations = $7EF4D9, "MMLocations labeled at incorrect address" +assert SWLocations = $7EF4DA, "SWLocations labeled at incorrect address" +assert IPLocations = $7EF4DB, "IPLocations labeled at incorrect address" +assert THLocations = $7EF4DC, "THLocations labeled at incorrect address" +assert TTLocations = $7EF4DD, "TTLocations labeled at incorrect address" +assert TRLocations = $7EF4DE, "TRLocations labeled at incorrect address" +assert GTLocations = $7EF4DF, "GTLocations labeled at incorrect address" +assert HCChestKeys = $7EF4E0, "HCChestKeys labeled at incorrect address" +assert SewerChestKeys = $7EF4E1, "SewerChestKeys labeled at incorrect address" +assert EPChestKeys = $7EF4E2, "EPChestKeys labeled at incorrect address" +assert DPChestKeys = $7EF4E3, "DPChestKeys labeled at incorrect address" +assert CTChestKeys = $7EF4E4, "ATChestKeys labeled at incorrect address" +assert SPChestKeys = $7EF4E5, "SPChestKeys labeled at incorrect address" +assert PDChestKeys = $7EF4E6, "PDChestKeys labeled at incorrect address" +assert MMChestKeys = $7EF4E7, "MMChestKeys labeled at incorrect address" +assert SWChestKeys = $7EF4E8, "SWChestKeys labeled at incorrect address" +assert IPChestKeys = $7EF4E9, "IPChestKeys labeled at incorrect address" +assert THChestKeys = $7EF4EA, "THChestKeys labeled at incorrect address" +assert TTChestKeys = $7EF4EB, "TTChestKeys labeled at incorrect address" +assert TRChestKeys = $7EF4EC, "TRChestKeys labeled at incorrect address" +assert GTChestKeys = $7EF4ED, "GChestKeys labeled at incorrect address" +assert FileMarker = $7EF4F0, "FileMarker labeled at incorrect address" +;-------------------------------------------------------------------------------- +assert ExtendedFileNameWRAM = $7F6000, "Filename labeled at incorrect address" +assert VERSION = $7F6018, "VERSION labeled at incorrect address" +assert RoomPotData = $7F601C, "RoomPotData labeled at incorrect address" +assert PurchaseCounts = $7F626C, "PurchaseCounts labeled at incorrect address" +assert DummyValue = $7F62CC, "DummyValue labeled at incorrect address" +;-------------------------------------------------------------------------------- +assert RomName = $7F1000, "RomName at incorrect address" + +;-------------------------------------------------------------------------------- +; MOVED TODO +;-------------------------------------------------------------------------------- +; CapacityUpgrades: 7ef452 -> 7ef469 +; file name: 3e3-3f0, -> 7ef500 +; shop purchase counts: 7ef302 -> 7ef51a - 7ef579 +; GoalCounter: 7ef418 -> 7ef418 (2 bytes) +; HighestMail: 7ef424 -> 7ef470 +; HighestShield: 7ef422 -> swords using HighestSword, shields removed from general flags +; SmallKeyCounter: 7ef424 -> 7ef471 +; ServiceSequence: 7ef419 -> 7ef418 (two bytes reserved) +; SwordsShields: 7ef422 -> swords using HighestSword +; PreMirrorLocations: 7ef432 -> 7ef434, PreBoots and PreMirror now 2 bytes +; +; DungeonLocations values and labels moved to block right before ChestKeys block +; starting at address 7ef472 +; +; bombs (?), silvers, and pre gtbk at $7ef42a now just pre gtbk +; +; whole file name now at $7F6000/706000, first four still at vanilla location +;-------------------------------------------------------------------------------- +; ADDED +;-------------------------------------------------------------------------------- +; +; PreFluteLocations = $7EF436 +; VERSION = $7F6018 +; RoomPotData = $7F601C +; PurchaseCounts = $7F601C +; DummyValue = $7F607C +; +;-------------------------------------------------------------------------------- + From 14b899d47afe4b04873098ecb4d49be2365b8157 Mon Sep 17 00:00:00 2001 From: cassidy Date: Wed, 1 Dec 2021 23:06:28 -0500 Subject: [PATCH 03/96] First pass-through adding labels Added items, equipment, and tracking/indicators Added playername changes Removed some defines --- LTTP_RND_GeneralBugfixes.asm | 14 +--- bookofmudora.asm | 4 +- boots.asm | 20 ++--- bugfixes.asm | 26 +++---- capacityupgrades.asm | 28 +++---- compasses.asm | 4 +- contrib.asm | 2 +- darkworldspawn.asm | 62 +++++++-------- dialog.asm | 19 ++--- entrances.asm | 6 +- events.asm | 24 +++--- fairyfixes.asm | 18 ++--- fastcredits.asm | 2 +- flipperkill.asm | 26 +++---- flute.asm | 2 +- goalitem.asm | 16 ++-- halfmagicbat.asm | 4 +- hardmode.asm | 2 +- heartpieces.asm | 2 +- hooks.asm | 2 +- inverted.asm | 2 +- invertedmaps.asm | 2 +- lampmantlecone.asm | 12 +-- maidencrystals.asm | 6 +- mantle.asm | 4 +- msu.asm | 10 +-- music.asm | 32 ++++---- newhud.asm | 15 ++-- newitems.asm | 147 +++++++++++++++++------------------ npcitems.asm | 6 +- openmode.asm | 14 ++-- pendantcrystalhud.asm | 85 ++++++++++---------- playername.asm | 39 ++++++---- potions.asm | 28 +++---- quickswap.asm | 10 +-- retro.asm | 26 +++---- rngfixes.asm | 2 +- roomloading.asm | 4 +- rupeelimit.asm | 4 +- shopkeeper.asm | 22 +++--- spriteswap.asm | 2 +- sram.asm | 64 +++++++-------- stats.asm | 53 +++++-------- swordswap.asm | 30 +++---- timer.asm | 4 +- treekid.asm | 6 +- utilities.asm | 22 +++--- zelda.asm | 6 +- 48 files changed, 454 insertions(+), 486 deletions(-) diff --git a/LTTP_RND_GeneralBugfixes.asm b/LTTP_RND_GeneralBugfixes.asm index 20030f6..b66ba93 100644 --- a/LTTP_RND_GeneralBugfixes.asm +++ b/LTTP_RND_GeneralBugfixes.asm @@ -2,14 +2,12 @@ ; The Legend of Zelda, A Link to the Past - Randomizer General Development & Bugfixes ;================================================================================ lorom - ;================================================================================ ;org $00FFC0 ; <- 7FC0 - Bank00.asm : 9173 (db "THE LEGEND OF ZELDA " ; 21 bytes) ;db #$23, $4E org $00FFD5 ; <- 7FD5 - Bank00.asm : 9175 (db $20 ; rom layout) -;db #$35 ; set fast exhirom db #$30 ; set fast lorom ;org $00FFD6 ; <- 7FD6 - Bank00.asm : 9176 (db $02 ; cartridge type) @@ -44,10 +42,6 @@ dw !ROM_VERSION_HIGH !BGE = "BCS" ; Rando Specific SRAM assignments -!SHOP_PURCHASE_COUNTS = "$7EF302" ;$7EF302 - $7EF33F (temporary home) -!INVENTORY_SWAP = "$7EF38C" ; [w] -!INVENTORY_SWAP_2 = "$7EF38E" ; [w] -!ITEM_LIMIT_COUNTS = "$7EF390" ; $7EF390 - ???? !NPC_FLAGS = "$7EF410" !NPC_FLAGS_2 = "$7EF411" !MAP_OVERLAY = "$7EF414" ; [w] @@ -58,16 +52,10 @@ dw !ROM_VERSION_HIGH !SHAME_CHEST = "$7EF416" ; ---s ---- !HAS_GROVE_ITEM = "$7EF416" ; ---- ---g general flags, don't waste these !HIGHEST_SWORD_LEVEL = "$7EF417" ; --- -sss -;$7EF41A[w] - Programmable Item #1 -;$7EF41C[w] - Programmable Item #2 -;$7EF41E[w] - Programmable Item #3 -!SRAM_SINK = "$7EF41E" ; <- change this (conflicts with Programmable item 3) ;$7EF418 - Goal Item Counter ;$7EF419 - Service Sequence ;$7EF420 - $7EF46D - Stat Tracking Bank 1 (overlaps with RNG Item Flags) -;$7EF450 - $7EF45F - RNG Item (Single) Flags ;$7EF4A0 - $7EF4A7 - Service Request Block -!FRESH_FILE_MARKER = "$7EF4F0" ; zero if fresh file ;$700500 - $70050F - Extended File Name ;$701000 - $70100F - Password (incorporate into log header) ;$702000 - $702014 - Rom title copy (incorporate into log header) @@ -112,6 +100,7 @@ incsrc treekid.asm incsrc spriteswap.asm incsrc hashalphabethooks.asm incsrc sharedplayerpalettefix.asm +incsrc sram.asm ;org $208000 ; bank #$20 org $A08000 ; bank #$A0 @@ -349,6 +338,7 @@ warnpc $B08000 ;$7F5000[0x800]: Rando's main free ram region ; See tables.asm for specific assignments ;$7F6000[0x500]: Free RAM (reclaimed from damage table) Not allocated yet +;$7F6000[0x500]: SRAM buffer save 2 0x500 ;$7F6500[0xB00]: SRAM mirror for last 0xB00 bytes of SRAM (extended sram) ;$7F7667[0x6719] - free ram ;================================================================================ diff --git a/bookofmudora.asm b/bookofmudora.asm index e26c7fa..6149763 100644 --- a/bookofmudora.asm +++ b/bookofmudora.asm @@ -54,7 +54,7 @@ GiveBonkItem: CMP #$24 : BNE .notKey .key PHY : LDY.b #$24 : JSL.l AddInventory : PLY ; do inventory processing for a small key - LDA $7EF36F : INC A : STA $7EF36F + LDA CurrentSmallKeys : INC A : STA CurrentSmallKeys LDA.b #$2F : JSL.l Sound_SetSfx3PanLong JSL CountBonkItem RTL @@ -74,4 +74,4 @@ LoadBonkItem: + LDA.b #$24 ; default to small key ++ -RTS \ No newline at end of file +RTS diff --git a/boots.asm b/boots.asm index 555fcb8..219c445 100644 --- a/boots.asm +++ b/boots.asm @@ -5,15 +5,15 @@ ModifyBoots: PHA LDA !BOOTS_MODIFIER : CMP.b #$01 : BNE + - PLA : AND $7EF379 : ORA.b #$04 : RTL ; yes boots + PLA : AND AbilityFlags : ORA.b #$04 : RTL ; yes boots + : CMP.b #$02 : BNE + - PLA : AND $7EF379 : AND.b #$FB : RTL ; no boots + PLA : AND AbilityFlags : AND.b #$FB : RTL ; no boots + : LDA FakeBoots : CMP.b #$01 : BNE + LDA $5B : BEQ ++ : LDA $59 : BNE + ; hover check - ++ : PLA : AND $7EF379 : ORA.b #$04 : RTL ; yes boots, not hovering + ++ : PLA : AND AbilityFlags : ORA.b #$04 : RTL ; yes boots, not hovering + PLA - AND $7EF379 ; regular boots + AND AbilityFlags ; regular boots RTL ;-------------------------------------------------------------------------------- AddBonkTremors: @@ -22,7 +22,7 @@ AddBonkTremors: JSL.l IncrementBonkCounter + LDA !BOOTS_MODIFIER : CMP.b #$01 : BEQ + - LDA $7EF355 : BNE + ; Check for Boots + LDA BootsEquipment : BNE + ; Check for Boots PLA : RTL + PLA @@ -33,7 +33,7 @@ BonkBreakableWall: PHX : PHP SEP #$30 ; set 8-bit accumulator and index registers LDA !BOOTS_MODIFIER : CMP.b #$01 : BEQ + - LDA $7EF355 : BNE + ; Check for Boots + LDA BootsEquipment : BNE + ; Check for Boots PLP : PLX : LDA.w #$0000 : RTL + PLP : PLX @@ -42,7 +42,7 @@ RTL ;-------------------------------------------------------------------------------- BonkRockPile: LDA !BOOTS_MODIFIER : CMP.b #$01 : BEQ + - LDA $7EF355 : BNE + ; Check for Boots + LDA BootsEquipment : BNE + ; Check for Boots LDA.b #$00 : RTL + LDA $02EF : AND.b #$70 ; things we wrote over @@ -50,7 +50,7 @@ RTL ;-------------------------------------------------------------------------------- GravestoneHook: LDA !BOOTS_MODIFIER : CMP.b #$01 : BEQ + - LDA $7EF355 : BEQ .done ; Check for Boots + LDA BootsEquipment : BEQ .done ; Check for Boots + LDA $0372 : BEQ .done ; things we wrote over JML.l moveGravestone @@ -59,7 +59,7 @@ GravestoneHook: ;-------------------------------------------------------------------------------- JumpDownLedge: LDA !BOOTS_MODIFIER : CMP.b #$01 : BEQ + - LDA $7EF355 : BNE + ; Check for Boots + LDA BootsEquipment : BNE + ; Check for Boots ; Disarm Waterwalk LDA $5B : CMP.b #$01 : BNE + STZ $5B @@ -70,7 +70,7 @@ RTL ;-------------------------------------------------------------------------------- BonkRecoil: LDA !BOOTS_MODIFIER : CMP.b #$01 : BEQ + - LDA $7EF355 : BNE + ; Check for Boots + LDA BootsEquipment : BNE + ; Check for Boots LDA.b #$16 : STA $29 : RTL + LDA.b #$24 : STA $29 ; things we wrote over diff --git a/bugfixes.asm b/bugfixes.asm index b5ee34b..b1d29b3 100644 --- a/bugfixes.asm +++ b/bugfixes.asm @@ -2,8 +2,8 @@ ;-------------------------------------------------------------------------------- AssignKiki: - LDA.b #$00 : STA $7EF3D3 ; defuse bomb - LDA.b #$0A : STA $7EF3CC ; assign kiki as follower + LDA.b #$00 : STA FollowerDropped ; defuse bomb + LDA.b #$0A : STA FollowerIndicator ; assign kiki as follower RTL ;-------------------------------------------------------------------------------- @@ -13,7 +13,7 @@ RTL ;-------------------------------------------------------------------------------- !ITEM_BUSY = "$7F5091" AllowSQ: - LDA $7EF3C5 : BEQ .done ; thing we overwrote - check if link is in his bed + LDA ProgressIndicator : BEQ .done ; thing we overwrote - check if link is in his bed LDA !ITEM_BUSY : EOR #$01 .done RTL @@ -32,8 +32,8 @@ RTL ;-------------------------------------------------------------------------------- ;0 = Become (Perma)bunny DecideIfBunny: - LDA $7EF357 : BNE .done - LDA $7EF3CA : AND.b #$40 + LDA MoonPearlEquipment : BNE .done + LDA CurrentWorld : AND.b #$40 PHA : LDA.l InvertedMode : BNE .inverted .normal PLA : EOR #$40 @@ -48,7 +48,7 @@ DecideIfBunnyByScreenIndex: ; If indoors we don't have a screen index. Return non-bunny to make mirror-based ; superbunny work LDA $1B : BNE .done - LDA $7EF357 : BNE .done + LDA MoonPearlEquipment : BNE .done LDA $8A : AND.b #$40 : PHA LDA.l InvertedMode : BNE .inverted .normal @@ -63,7 +63,7 @@ RTL ;-------------------------------------------------------------------------------- ;ReadInventoryPond: ; CPX.b #$1B : BNE + : LDA.b #$01 : RTL : + -; LDA $7EF340, X +; LDA SRAMEquipment, X ;RTL ;-------------------------------------------------------------------------------- @@ -112,15 +112,15 @@ RTS ; fix issue where cross world caves (in Entrance randomizer) don't cause ; frog to become smith or vice versa. FixFrogSmith: - LDA.l $7EF3CA : BNE .darkWorld - LDA.l $7EF3CC : CMP.b #$07 : BNE .done + LDA.l CurrentWorld : BNE .darkWorld + LDA.l FollowerIndicator : CMP.b #$07 : BNE .done LDA.b #$08 ; make frog into smith in light world BRA .loadgfx .darkWorld - LDA.l $7EF3CC : CMP.b #$08 : BNE .done + LDA.l FollowerIndicator : CMP.b #$08 : BNE .done LDA.b #$07 ; make smith into frog in dark world .loadgfx - STA.l $7EF3CC + STA.l FollowerIndicator JSL Tagalong_LoadGfx .done RTS @@ -158,8 +158,8 @@ WallmasterCameraFix: ; Fix losing glove colors LoadActualGearPalettesWithGloves: REP #$20 -LDA $7EF359 : STA $0C -LDA $7EF35B : AND.w #$00FF +LDA SwordEquipment : STA $0C +LDA ArmorEquipment : AND.w #$00FF JSL LoadGearPalettes_variable JSL SpriteSwap_Palette_ArmorAndGloves_part_two RTL diff --git a/capacityupgrades.asm b/capacityupgrades.asm index cdd343f..73b3c26 100644 --- a/capacityupgrades.asm +++ b/capacityupgrades.asm @@ -1,43 +1,37 @@ ;================================================================================ ; Capacity Logic ;================================================================================ -!BOMB_UPGRADES = "$7EF370" -!BOMB_CURRENT = "$7EF343" -;-------------------------------------------------------------------------------- IncrementBombs: - LDA !BOMB_UPGRADES ; get bomb upgrades + LDA BombCapacityUpgrades ; get bomb upgrades !ADD.l StartingMaxBombs : BEQ + ; Skip if we can't have bombs DEC - CMP !BOMB_CURRENT + CMP BombsEquipment !BLT + - LDA !BOMB_CURRENT + LDA BombsEquipment CMP.b #99 : !BGE + - INC : STA !BOMB_CURRENT + INC : STA BombsEquipment + RTL ;-------------------------------------------------------------------------------- -!ARROW_UPGRADES = "$7EF371" -!ARROW_CURRENT = "$7EF377" -;-------------------------------------------------------------------------------- IncrementArrows: - LDA !ARROW_UPGRADES ; get arrow upgrades + LDA ArrowCapacityUpgrades ; get arrow upgrades !ADD.l StartingMaxArrows : DEC - CMP !ARROW_CURRENT + CMP CurrentArrows !BLT + - LDA !ARROW_CURRENT + LDA CurrentArrows CMP.b #99 : !BGE + - INC : STA !ARROW_CURRENT + INC : STA CurrentArrows + RTL ;-------------------------------------------------------------------------------- CompareBombsToMax: - LDA !BOMB_UPGRADES ; get bomb upgrades + LDA BombCapacityUpgrades ; get bomb upgrades !ADD.l StartingMaxBombs - CMP !BOMB_CURRENT + CMP BombsEquipment RTL -;-------------------------------------------------------------------------------- \ No newline at end of file +;-------------------------------------------------------------------------------- diff --git a/compasses.asm b/compasses.asm index 37295c2..50d1807 100644 --- a/compasses.asm +++ b/compasses.asm @@ -17,7 +17,7 @@ DrawDungeonCompassCounts: LDX $040C : CPX.b #$FF : BEQ .done ; Skip if not in a dungeon CMP.w #$0002 : BEQ ++ ; if CompassMode==2, we don't check for the compass - LDA $7EF364 : AND.l DungeonItemMasks, X ; Load compass values to A, mask with dungeon item masks + LDA CompassField : AND.l DungeonItemMasks, X ; Load compass values to A, mask with dungeon item masks BEQ .done ; skip if we don't have compass ++ @@ -137,4 +137,4 @@ CompassCount_Gt: ; $7EF439 - ttttssss - item locations checked ; t - turtle rock ; s - swamp palace -;-------------------------------------------------------------------------------- \ No newline at end of file +;-------------------------------------------------------------------------------- diff --git a/contrib.asm b/contrib.asm index 0fbf354..644082f 100644 --- a/contrib.asm +++ b/contrib.asm @@ -71,7 +71,7 @@ ; ; PLX ; -; LDA.b #$00 : STA $7EF3CC +; LDA.b #$00 : STA FollowerIndicator ; ; STZ $5E ; diff --git a/darkworldspawn.asm b/darkworldspawn.asm index 2b3696b..637dd52 100644 --- a/darkworldspawn.asm +++ b/darkworldspawn.asm @@ -11,14 +11,14 @@ DoWorldFix: JMP DoWorldFix_Inverted + LDA.l Bugfix_MirrorlessSQToLW : BEQ .skip_mirror_check - LDA $7EF353 : BEQ .noMirror ; check if we have the mirror + LDA MirrorEquipment : BEQ .noMirror ; check if we have the mirror .skip_mirror_check ; alt entrance point - LDA $7EF3C5 : CMP.b #$03 : BCS .done ; check if agahnim 1 is alive + LDA ProgressIndicator : CMP.b #$03 : BCS .done ; check if agahnim 1 is alive .aga1Alive LDA #$00 .noMirror - STA $7EF3CA ; set flag to light world - LDA $7EF3CC : CMP #$07 : BNE .done : INC : STA $7EF3CC ; convert frog to dwarf + STA CurrentWorld ; set flag to light world + LDA FollowerIndicator : CMP #$07 : BNE .done : INC : STA FollowerIndicator ; convert frog to dwarf .done RTL ;-------------------------------------------------------------------------------- @@ -39,25 +39,25 @@ JMP DoWorldFix JMP DoWorldFix_skip_mirror_check .pyramid - LDA #$40 : STA $7EF3CA ; set flag to dark world - LDA $7EF3CC : CMP #$08 : BNE .done : DEC : STA $7EF3CC : + ; convert dwarf to frog + LDA #$40 : STA CurrentWorld ; set flag to dark world + LDA FollowerIndicator : CMP #$08 : BNE .done : DEC : STA FollowerIndicator : + ; convert dwarf to frog .done RTL ;================================================================================ DoWorldFix_Inverted: LDA.l Bugfix_MirrorlessSQToLW : BEQ .skip_mirror_check - LDA $7EF353 : BEQ .noMirror ; check if we have the mirror + LDA MirrorEquipment : BEQ .noMirror ; check if we have the mirror .skip_mirror_check ; alt entrance point - LDA $7EF3C5 : CMP.b #$03 : BCS .done ; check if agahnim 1 is alive + LDA ProgressIndicator : CMP.b #$03 : BCS .done ; check if agahnim 1 is alive .noMirror .aga1Alive - LDA #$40 : STA $7EF3CA ; set flag to dark world - LDA $7EF3CC + LDA #$40 : STA CurrentWorld ; set flag to dark world + LDA FollowerIndicator CMP #$07 : BEQ .clear ; clear frog CMP #$08 : BEQ .clear ; clear dwarf - consider flute implications BRA .done .clear - LDA.b #$00 : STA $7EF3CC ; clear follower + LDA.b #$00 : STA FollowerIndicator ; clear follower .done RTL ;-------------------------------------------------------------------------------- @@ -75,8 +75,8 @@ JMP DoWorldFix JMP DoWorldFix_Inverted_skip_mirror_check .castle - LDA #$00 : STA $7EF3CA ; set flag to dark world - LDA $7EF3CC : CMP #$07 : BNE + : LDA.b #$08 : STA $7EF3CC : + ; convert frog to dwarf + LDA #$00 : STA CurrentWorld ; set flag to dark world + LDA FollowerIndicator : CMP #$07 : BNE + : LDA.b #$08 : STA FollowerIndicator : + ; convert frog to dwarf .done RTL ;================================================================================ @@ -85,19 +85,19 @@ RTL ;-------------------------------------------------------------------------------- FakeWorldFix: LDA FixFakeWorld : BEQ + - LDA $8A : AND.b #$40 : STA $7EF3CA + LDA $8A : AND.b #$40 : STA CurrentWorld + RTL ;-------------------------------------------------------------------------------- MasterSwordFollowerClear: - LDA $7EF3CC + LDA FollowerIndicator CMP #$0E : BNE .exit ; clear master sword follower - LDA.b #$00 : STA $7EF3CC ; clear follower + LDA.b #$00 : STA FollowerIndicator ; clear follower .exit RTL ;-------------------------------------------------------------------------------- FixAgahnimFollowers: - LDA.b #$00 : STA $7EF3CC ; clear follower + LDA.b #$00 : STA FollowerIndicator ; clear follower JML PrepDungeonExit ; thing we wrote over ;-------------------------------------------------------------------------------- @@ -107,24 +107,24 @@ macro SetMinimum(base,filler,compare) ?done: endmacro RefreshRainAmmo: - LDA $7EF3C5 : CMP.b #$01 : BEQ .rain ; check if we're in rain state + LDA ProgressIndicator : CMP.b #$01 : BEQ .rain ; check if we're in rain state RTL .rain - LDA $7EF3C8 + LDA StartingEntrance + CMP.b #$03 : BNE + ; Uncle - %SetMinimum($7EF36E,$7EF373,RainDeathRefillMagic_Uncle) - %SetMinimum($7EF343,$7EF375,RainDeathRefillBombs_Uncle) - %SetMinimum($7EF377,$7EF376,RainDeathRefillArrows_Uncle) + %SetMinimum(CurrentMagic,MagicFiller,RainDeathRefillMagic_Uncle) + %SetMinimum(BombsEquipment,BombsFiller,RainDeathRefillBombs_Uncle) + %SetMinimum(CurrentArrows,ArrowsFiller,RainDeathRefillArrows_Uncle) BRA .done + CMP.b #$02 : BNE + ; Cell - %SetMinimum($7EF36E,$7EF373,RainDeathRefillMagic_Cell) - %SetMinimum($7EF343,$7EF375,RainDeathRefillBombs_Cell) - %SetMinimum($7EF377,$7EF376,RainDeathRefillArrows_Cell) + %SetMinimum(CurrentMagic,MagicFiller,RainDeathRefillMagic_Cell) + %SetMinimum(BombsEquipment,BombsFiller,RainDeathRefillBombs_Cell) + %SetMinimum(CurrentArrows,ArrowsFiller,RainDeathRefillArrows_Cell) BRA .done + CMP.b #$04 : BNE + ; Mantle - %SetMinimum($7EF36E,$7EF373,RainDeathRefillMagic_Mantle) - %SetMinimum($7EF343,$7EF375,RainDeathRefillBombs_Mantle) - %SetMinimum($7EF377,$7EF376,RainDeathRefillArrows_Mantle) + %SetMinimum(CurrentMagic,MagicFiller,RainDeathRefillMagic_Mantle) + %SetMinimum(BombsEquipment,BombsFiller,RainDeathRefillBombs_Mantle) + %SetMinimum(CurrentArrows,ArrowsFiller,RainDeathRefillArrows_Mantle) + .done RTL @@ -133,7 +133,7 @@ RTL !INFINITE_BOMBS = "$7F50C9" !INFINITE_MAGIC = "$7F50CA" SetEscapeAssist: - LDA $7EF3C5 : CMP.b #$01 : BNE .no_train ; check if we're in rain state + LDA ProgressIndicator : CMP.b #$01 : BNE .no_train ; check if we're in rain state .rain LDA.l EscapeAssist BIT.b #$04 : BEQ + : STA !INFINITE_MAGIC : + @@ -149,8 +149,8 @@ RTL ;-------------------------------------------------------------------------------- SetSilverBowMode: LDA SilverArrowsUseRestriction : BEQ + ; fix bow type for restricted arrow mode - LDA $7EF340 : CMP.b #$3 : BCC + - SBC.b #$02 : STA $7EF340 + LDA BowEquipment : CMP.b #$3 : BCC + + SBC.b #$02 : STA BowEquipment + RTL ;================================================================================ diff --git a/dialog.asm b/dialog.asm index 28962ba..1416d67 100644 --- a/dialog.asm +++ b/dialog.asm @@ -267,7 +267,8 @@ RTL ;-------------------------------------------------------------------------------- DialogFairyThrow: LDA.l Restrict_Ponds : BEQ .normal - LDA $7EF35C : ORA $7EF35D : ORA $7EF35E : ORA $7EF35F : BNE .normal + LDA BottleContentsOne + ORA BottleContentsTwo : ORA BottleContentsThree : ORA BottleContentsFour : BNE .normal .noInventory LDA $0D80, X : !ADD #$08 : STA $0D80, X @@ -294,7 +295,7 @@ RTL ; #$0193 - no silvers alternate ; #$0194 - no silvers ; #$0195 - silvers -; $7EF38E - bsp-- --- +; BowTracking - bsp-- --- ; b = bow ; s = silver arrow bow ; p = 2nd progressive bow @@ -305,7 +306,7 @@ DialogGanon2: BCS + LDA.w #$018D : BRA ++ + - LDA.l $7EF38E + LDA.l BowTracking BIT.w #$0080 : BNE + ; branch if bow LDA.w #$0192 : BRA ++ @@ -334,9 +335,9 @@ DialogEtherTablet: + BIT $F4 : BVC - ; Show normal text if Y is not pressed LDA.l AllowHammerTablets : BEQ ++ - LDA $7EF34B : BEQ .yesText : BRA .noText + LDA HammerEquipment : BEQ .yesText : BRA .noText ++ - LDA $7EF359 : CMP.b #$FF : BEQ .yesText : CMP.b #$02 : BCS .noText + LDA SwordEquipment : CMP.b #$FF : BEQ .yesText : CMP.b #$02 : BCS .noText ;++ .yesText PLA @@ -356,9 +357,9 @@ DialogBombosTablet: + BIT $F4 : BVC - ; Show normal text if Y is not pressed LDA.l AllowHammerTablets : BEQ ++ - LDA $7EF34B : BEQ .yesText : BRA .noText + LDA HammerEquipment : BEQ .yesText : BRA .noText ++ - LDA $7EF359 : CMP.b #$FF : BEQ .yesText : CMP.b #$02 : !BGE .noText + LDA SwordEquipment : CMP.b #$FF : BEQ .yesText : CMP.b #$02 : !BGE .noText ;++ .yesText PLA @@ -371,7 +372,7 @@ DialogBombosTablet: RTL ;-------------------------------------------------------------------------------- DialogSahasrahla: - LDA.l $7EF374 : AND #$04 : BEQ + ;Check if player has green pendant + LDA.l PendantsField : AND #$04 : BEQ + ;Check if player has green pendant LDA.b #$2F LDY.b #$00 JML Sprite_ShowMessageUnconditional @@ -380,7 +381,7 @@ RTL ;-------------------------------------------------------------------------------- DialogBombShopGuy: LDY.b #$15 - LDA.l $7EF37A : AND #$05 : CMP #$05 : BNE + ;Check if player has crystals 5 & 6 + LDA.l CrystalsField : AND #$05 : CMP #$05 : BNE + ;Check if player has crystals 5 & 6 INY ; from 15 to 16 + TYA diff --git a/entrances.asm b/entrances.asm index 35db47e..c174505 100644 --- a/entrances.asm +++ b/entrances.asm @@ -8,7 +8,7 @@ LockAgahnimDoors: ;#$0 = Never Locked LDA.w #$0000 : RTL + : CMP.w #$0001 : BNE + - LDA $7EF3C5 : AND.w #$000F : CMP.w #$0002 : !BGE .unlock ; if we rescued zelda, skip + LDA ProgressIndicator : AND.w #$000F : CMP.w #$0002 : !BGE .unlock ; if we rescued zelda, skip JSR.w LockAgahnimDoorsCore : RTL + : CMP.w #$0002 : BNE + JSR.w LockAgahnimDoorsCore : BEQ .unlock @@ -77,7 +77,7 @@ JML.l Overworld_Entrance_BRANCH_RHO AllowStartFromSingleEntranceCave: ; 16 Bit A, 16 bit XY ; do not need to preserve A or X or Y - LDA $7EF3C8 : AND.w #$00FF ; What we wrote over + LDA StartingEntrance : AND.w #$00FF ; What we wrote over PHA TAX @@ -138,7 +138,7 @@ AllowStartFromExit: LDX $1CE8 LDA.l ShouldStartatExit, X : BNE .doStart - LDA.l $7EF3C8 ; what we wrote over + LDA.l StartingEntrance ; what we wrote over JML.l AllowStartFromExitReturn .doStart diff --git a/events.asm b/events.asm index d8ff634..96f96a4 100644 --- a/events.asm +++ b/events.asm @@ -65,15 +65,15 @@ OnUncleItemGet: PLA JSL Link_ReceiveItem - LDA.l UncleRefill : BIT.b #$04 : BEQ + : LDA.b #$80 : STA $7EF373 : + ; refill magic - LDA.l UncleRefill : BIT.b #$02 : BEQ + : LDA.b #50 : STA $7EF375 : + ; refill bombs + 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 #$01 : BEQ + ; refill arrows - LDA.b #70 : STA $7EF376 + LDA.b #70 : STA ArrowsFiller LDA.l ArrowMode : BEQ + - LDA !INVENTORY_SWAP_2 : ORA #$80 : STA !INVENTORY_SWAP_2 ; enable bow toggle + LDA BowTracking : ORA #$80 : STA BowTracking ; enable bow toggle REP #$20 ; set 16-bit accumulator - LDA $7EF360 : !ADD.l FreeUncleItemAmount : STA $7EF360 ; rupee arrows, so also give the player some money to start + LDA TargetRupees : !ADD.l FreeUncleItemAmount : STA TargetRupees ; rupee arrows, so also give the player some money to start SEP #$20 ; set 8-bit accumulator + RTL @@ -95,9 +95,9 @@ OnFileLoad: LDA.b #$07 : STA $210C ; Restore screen 3 to normal tile area - LDA !FRESH_FILE_MARKER : BNE + + LDA FileMarker : BNE + JSL.l OnNewFile - LDA.b #$FF : STA !FRESH_FILE_MARKER + LDA.b #$FF : STA 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) @@ -108,7 +108,7 @@ OnFileLoad: LDA #$FF : STA !RNG_ITEM_LOCK_IN ; reset rng item lock-in LDA #$00 : STA $7F5001 ; mark fake flipper softlock as impossible LDA.l GenericKeys : BEQ + - LDA $7EF38B : STA $7EF36F ; copy generic keys to key counter + LDA CurrentGenericKeys : STA CurrentSmallKeys ; copy generic keys to key counter + JSL.l SetSilverBowMode @@ -125,17 +125,17 @@ RTL OnNewFile: PHX : PHP REP #$20 ; set 16-bit accumulator - LDA.l LinkStartingRupees : STA $7EF362 : STA $7EF360 + LDA.l LinkStartingRupees : STA CurrentRupees : STA TargetRupees LDA.l StartingTime : STA $7EF454 LDA.l StartingTime+2 : STA $7EF454+2 LDX.w #$004E : - ; copy over starting equipment - LDA StartingEquipment, X : STA $7EF340, X + LDA StartingEquipment, X : STA SRAMEquipment, X DEX : DEX BPL - LDX #$000E : - - LDA $7EF37C, X : STA $7EF4E0, X + LDA SewerKeys, X : STA $7EF4E0, X DEX : DEX BPL - @@ -154,7 +154,7 @@ OnNewFile: LDA.b #$20 : STA $7EF2C3 ; Ganons Tower already open + - LDA StartingSword : STA $7EF359 ; set starting sword type + LDA StartingSword : STA SwordEquipment ; set starting sword type ; reset some values on new file that are otherwise only reset on hard reset STZ $03C4 ; ancilla slot index diff --git a/fairyfixes.asm b/fairyfixes.asm index 5364376..9dec2b8 100644 --- a/fairyfixes.asm +++ b/fairyfixes.asm @@ -2,20 +2,20 @@ ; Fairy Changes & Fixes ;-------------------------------------------------------------------------------- RefillHealthPlusMagic: - LDA BigFairyHealth : STA $7EF372 + LDA BigFairyHealth : STA HeartsFiller RTL ;-------------------------------------------------------------------------------- RefillHealthPlusMagic8bit: - LDA BigFairyHealth : STA $7EF372 - LDA BigFairyMagic : STA $7EF373 + LDA BigFairyHealth : STA HeartsFiller + LDA BigFairyMagic : STA MagicFiller RTL ;-------------------------------------------------------------------------------- CheckFullHealth: LDA BigFairyHealth : BEQ + - LDA $7EF36D : CMP $7EF36C : BNE .player_hp_not_full_yet + LDA CurrentHealth : CMP HealthCapacity : BNE .player_hp_not_full_yet + LDA BigFairyMagic : BEQ + - LDA $7EF36E : CMP.b #$80 : BNE .player_mp_not_full_yet + LDA CurrentMagic : CMP.b #$80 : BNE .player_mp_not_full_yet + LDA.b #$00 RTL @@ -30,10 +30,10 @@ FairyPond_Init: JML.l Sprite_ShowMessageFromPlayerContact + PHY : JSL.l Sprite_CheckDamageToPlayerSameLayerLong : BCC + - LDA $7EF35C : CMP.b #$02 : BNE ++ : LDA.b #$1C : PHA : BRA .emptyBottle : ++ - LDA $7EF35D : CMP.b #$02 : BNE ++ : LDA.b #$1D : PHA : BRA .emptyBottle : ++ - LDA $7EF35E : CMP.b #$02 : BNE ++ : LDA.b #$1E : PHA : BRA .emptyBottle : ++ - LDA $7EF35F : CMP.b #$02 : BNE ++ : LDA.b #$1F : PHA : BRA .emptyBottle : ++ + LDA BottleContentsOne : CMP.b #$02 : BNE ++ : LDA.b #$1C : PHA : BRA .emptyBottle : ++ + LDA BottleContentsTwo : CMP.b #$02 : BNE ++ : LDA.b #$1D : PHA : BRA .emptyBottle : ++ + LDA BottleContentsThree : CMP.b #$02 : BNE ++ : LDA.b #$1E : PHA : BRA .emptyBottle : ++ + LDA BottleContentsFour : CMP.b #$02 : BNE ++ : LDA.b #$1F : PHA : BRA .emptyBottle : ++ .noInventory LDA.b #$0A : STA $0D80, X LDA.b #$51 diff --git a/fastcredits.asm b/fastcredits.asm index 97f23a6..82702f3 100644 --- a/fastcredits.asm +++ b/fastcredits.asm @@ -117,7 +117,7 @@ FastTextScroll: RTL DumbFlagForMSU: - STA.l $7EF3CA + STA.l CurrentWorld STZ.b $50 RTL diff --git a/flipperkill.asm b/flipperkill.asm index 6f8c420..648927b 100644 --- a/flipperkill.asm +++ b/flipperkill.asm @@ -4,16 +4,16 @@ FlipperKill: PHP LDA $5D : CMP #$04 : BNE .done ; skip if we're not swimming - LDA $7EF356 : BNE .done ; skip if we have the flippers + LDA FlippersEquipment : BNE .done ; skip if we have the flippers LDA $7F5001 : BEQ .done ; skip if we're not marked in danger for softlock LDA $8A : CMP $7F5098 : BEQ .done ; skip if we're on the same screen we entered the water on ;JSL.l KillFairies ; take away fairies LDA !IGNORE_FAIRIES : ORA.b #$04 : STA !IGNORE_FAIRIES - LDA.b #$00 : STA $7EF36D ; kill link + LDA.b #$00 : STA CurrentHealth ; kill link LDA.b #$00 : STA $7F5001 ; mark fake flipper softlock as impossible .done PLP - LDA $7EF36D ; thing we wrote over + LDA CurrentHealth ; thing we wrote over RTL ;-------------------------------------------------------------------------------- IgnoreFairyCheck: @@ -28,14 +28,14 @@ RTL RTL ;-------------------------------------------------------------------------------- ;KillFairies: -; LDA $7EF35C : CMP #$06 : BNE + -; LDA #$02 : STA $7EF35C -; + LDA $7EF35D : CMP #$06 : BNE + -; LDA #$02 : STA $7EF35D -; + LDA $7EF35E : CMP #$06 : BNE + -; LDA #$02 : STA $7EF35E -; + LDA $7EF35F : CMP #$06 : BNE + -; LDA #$02 : STA $7EF35F +; LDA BottleContentsOne : CMP #$06 : BNE + +; LDA #$02 : STA BottleContentsOne +; + LDA BottleContentsTwo : CMP #$06 : BNE + +; LDA #$02 : STA BottleContentsTwo +; + LDA BottleContentsThree : CMP #$06 : BNE + +; LDA #$02 : STA BottleContentsThree +; + LDA BottleContentsFour : CMP #$06 : BNE + +; LDA #$02 : STA BottleContentsFour ; + ;RTL ;-------------------------------------------------------------------------------- @@ -47,7 +47,7 @@ RTL ;-------------------------------------------------------------------------------- FlipperFlag: LDA $5D : CMP #$04 : BNE .done ; skip if we're not swimming - LDA $7EF356 : BNE .safe ; skip if we have the flippers + LDA FlippersEquipment : BNE .safe ; skip if we have the flippers LDA #$01 : STA $7F5001 ; mark fake flipper softlock as possible BRA .done .safe @@ -134,4 +134,4 @@ protectff: .spow db $80, $81, $81, $FF, $FF, $FF, $FF, $FF - db $FF, $81, $81, $FF, $FF, $FF, $FF, $FF \ No newline at end of file + db $FF, $81, $81, $FF, $FF, $FF, $FF, $FF diff --git a/flute.asm b/flute.asm index 4de7eb1..06b9edf 100644 --- a/flute.asm +++ b/flute.asm @@ -61,7 +61,7 @@ JML.l FluteBoy_Continue ;-------------------------------------------------------------------------------- FreeDuckCheck: LDA.l InvertedMode : BEQ .done - LDA $7EF34C : CMP.b #$03 : BEQ .done ; flute is already active + LDA FluteEquipment : CMP.b #$03 : BEQ .done ; flute is already active ; check the area, is it #$18 = 30? LDA $8A : CMP.b #$18 : BNE .done diff --git a/goalitem.asm b/goalitem.asm index 8cd7502..9c7e900 100644 --- a/goalitem.asm +++ b/goalitem.asm @@ -62,12 +62,12 @@ CheckGanonVulnerability: ; 02 = All dungeons .all_dungeons - LDA.l $7EF3C5 : CMP.b #$03 : BCC .fail ; require post-aga world state + LDA.l ProgressIndicator : CMP.b #$03 : BCC .fail ; require post-aga world state ; 09 = All dungeons except agahnim .all_dungeons_no_agahnim - LDA.l $7EF374 : AND.b #$07 : CMP.b #$07 : BNE .fail ; require all pendants - LDA.l $7EF37A : AND.b #$7F : CMP.b #$7F : BNE .fail ; require all crystals + 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 $7EF2DB : AND.b #$20 : BEQ .fail ; require aga2 defeated (pyramid hole open) BRA .success @@ -125,12 +125,12 @@ GetRequiredCrystalsInX: RTL ;-------------------------------------------------------------------------------- CheckEnoughCrystalsForGanon: - LDA $7EF37A : JSL CountBits ; the comparison is against 1 less + LDA CrystalsField : JSL CountBits ; the comparison is against 1 less CMP.l NumberOfCrystalsRequiredForGanon RTL ;-------------------------------------------------------------------------------- CheckEnoughCrystalsForTower: - LDA $7EF37A : JSL CountBits ; the comparison is against 1 less + LDA CrystalsField : JSL CountBits ; the comparison is against 1 less CMP.l NumberOfCrystalsRequiredForTower RTL @@ -158,15 +158,15 @@ CheckAgaForPed: ;--------------------------------------------------------------------------------------------------- KillGanon: - STA.l $7EF3C5 ; vanilla game state stuff we overwrote + STA.l ProgressIndicator ; vanilla game state stuff we overwrote LDA.l InvincibleGanon CMP.b #$06 : BNE .exit .light_speed LDA.l $7EF2DB : ORA.b #$20 : STA.l $7EF2DB ; pyramid hole - LDA.b #$08 : STA.l $7EF001 ; kill ganon - LDA.b #$02 : STA.l $7EF357 ; pearl but invisible in menu + LDA.b #$08 : STA.l RoomData[$00].Low ; kill ganon + LDA.b #$02 : STA.l MoonPearlEquipment ; pearl but invisible in menu .exit RTL diff --git a/halfmagicbat.asm b/halfmagicbat.asm index 56ba087..19772fc 100644 --- a/halfmagicbat.asm +++ b/halfmagicbat.asm @@ -10,6 +10,6 @@ GetMagicBatItem: JML.l Link_ReceiveItem .normalLogic LDA HalfMagic - STA $7EF37B + STA MagicConsumption RTL -;-------------------------------------------------------------------------------- \ No newline at end of file +;-------------------------------------------------------------------------------- diff --git a/hardmode.asm b/hardmode.asm index 1b7fe8b..65c934a 100644 --- a/hardmode.asm +++ b/hardmode.asm @@ -32,7 +32,7 @@ CalculateByrnaUsage: LDA.l HardModeExclusionCaneOfByrnaUsage, X : STA $00 PLX ++ - LDA $7EF36E ; thing we wrote over + LDA CurrentMagic ; thing we wrote over JML IncrementMagicUseCounterByrna ;-------------------------------------------------------------------------------- CalculateCapeUsage: diff --git a/heartpieces.asm b/heartpieces.asm index 6a4c3fe..4732c84 100644 --- a/heartpieces.asm +++ b/heartpieces.asm @@ -15,7 +15,7 @@ HeartPieceGet: STZ $02E9 ; 0 = Receiving item from an NPC or message CPY.b #$26 : BNE .notHeart ; don't add a 1/4 heart if it's not a heart piece - LDA $7EF36B : INC A : AND.b #$03 : STA $7EF36B : BNE .unfinished_heart ; add up heart quarters + LDA HeartPieceQuarter : INC A : AND.b #$03 : STA HeartPieceQuarter : BNE .unfinished_heart ; add up heart quarters BRA .giveItem .notHeart diff --git a/hooks.asm b/hooks.asm index f0534dd..74b0adc 100755 --- a/hooks.asm +++ b/hooks.asm @@ -2483,7 +2483,7 @@ org $07A055 ; <- Bank07.asm:5205 (LDA $0B99 : BEQ BRANCH_DELTA) JSL.l ArrowGame : NOP #14 org $07A06C ; <- Bank07.asm:5215 (LDA $7EF377 : BEQ BRANCH_EPSILON) -JSL.l DecrementArrows : SKIP 2 : NOP : LDA $7EF377 +JSL.l DecrementArrows : SKIP 2 : NOP : LDA CurrentArrows ;================================================================================ ;================================================================================ diff --git a/inverted.asm b/inverted.asm index b60085d..92c57ed 100644 --- a/inverted.asm +++ b/inverted.asm @@ -131,7 +131,7 @@ db $02, $02, $02, $02, $02, $02, $02, $00, $00, $01, $01, $01, $02, $00, $08, $0 Electric_Barrier: LDA InvertedMode : BEQ .done - LDA $7EF280, X : ORA #$40 : STA $7EF280, X ;set barrier dead + LDA OverworldData, X : ORA #$40 : STA $7EF280, X ;set barrier dead .done LDA $7EF280, X ; what we wrote over RTL diff --git a/invertedmaps.asm b/invertedmaps.asm index d60cdcc..7ff1fdb 100644 --- a/invertedmaps.asm +++ b/invertedmaps.asm @@ -1007,7 +1007,7 @@ LDA #$0108 : STA $3C38 ;Warp Tile agah defeated LDA #$0034 : STA $3BBE ;Tile when no warp -LDA $7EF3C5 : AND #$00FF : CMP #$0003 : BNE .agahnimAlive +LDA ProgressIndicator : AND #$00FF : CMP #$0003 : BNE .agahnimAlive LDA #$0212 : STA $3BBE ;warp .agahnimAlive diff --git a/lampmantlecone.asm b/lampmantlecone.asm index c2dd7fd..07d5fea 100644 --- a/lampmantlecone.asm +++ b/lampmantlecone.asm @@ -7,9 +7,9 @@ LampCheck: LDA $7F50C4 : CMP.b #$01 : BNE + : RTL : + CMP.b #$FF : BNE + : INC : RTL : + - LDA $7EF34A : BNE .done ; skip if we already have lantern + LDA LampEquipment : BNE .done ; skip if we already have lantern - LDA $7EF3CA : BNE + + LDA CurrentWorld : BNE + .lightWorld LDA $040C : BNE ++ ; check if we're in sewers LDA LampConeSewers : BRA .done @@ -28,18 +28,18 @@ RTL CheckForZelda: ;LDA.l OpenMode : BEQ + ; Skip if not open mode ;LDA $FFFFFF - LDA.l $7EF3C5 : CMP.b #$02 : !BLT + ; Skip if rain is falling + LDA.l ProgressIndicator : CMP.b #$02 : !BLT + ; Skip if rain is falling LDA.b #$01 ; pretend we have zelda anyway RTL + - LDA $7EF3CC + LDA FollowerIndicator RTL ;================================================================================ ;-------------------------------------------------------------------------------- SetOverlayIfLamp: - ;LDA $7EF34A ; check if lamp + ;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 ;================================================================================ -;LDA $7EF3CA : EOR #$40 : LSR #6 : AND #$01 ; return the same result as having the lantern in the light world \ No newline at end of file +;LDA CurrentWorld : EOR #$40 : LSR #6 : AND #$01 ; return the same result as having the lantern in the light world diff --git a/maidencrystals.asm b/maidencrystals.asm index cab0c24..e435836 100644 --- a/maidencrystals.asm +++ b/maidencrystals.asm @@ -14,11 +14,11 @@ MaidenCrystalScript: ; Load the dungeon index. Is it the Dark Palace? ;LDA $040C : !SUB.b #$0A : TAY : CPY.b #$02 : BNE + - ; LDA $7EF3C7 : CMP.b #$07 : BCS ++ : LDA.b #$07 : STA $7EF3C7 : ++ + ; LDA MapIcons : CMP.b #$07 : BCS ++ : LDA.b #$07 : STA MapIcons : ++ ;+ - LDA $7EF37A : AND.b #$7F : CMP.b #$7F : BNE + ; check if we have all crystals - LDA.b #$08 : STA $7EF3C7 ; Update the map icon to just be Ganon's Tower + LDA CrystalsField : AND.b #$7F : CMP.b #$7F : BNE + ; check if we have all crystals + LDA.b #$08 : STA MapIcons ; Update the map icon to just be Ganon's Tower + JSL.l MaybeWriteSRAMTrace diff --git a/mantle.asm b/mantle.asm index fd5d1cd..5b60c1b 100644 --- a/mantle.asm +++ b/mantle.asm @@ -2,11 +2,11 @@ ; Mantle Object Changes ;-------------------------------------------------------------------------------- Mantle_CorrectPosition: - LDA $7EF3C6 : AND.b #$04 : BEQ + + LDA ProgressFlags : AND.b #$04 : BEQ + LDA.b #$0A : STA $0D10, X ; just spawn it off to the side where we know it should be LDA.b #$03 : STA $0D30, X LDA.b #$90 : STA $0ED0, X + LDA $0D00, X : !ADD.b #$03 ; thing we did originally RTL -;-------------------------------------------------------------------------------- \ No newline at end of file +;-------------------------------------------------------------------------------- diff --git a/msu.asm b/msu.asm index 49b5904..16259be 100644 --- a/msu.asm +++ b/msu.asm @@ -257,13 +257,13 @@ CheckMusicLoadRequest: -- : PLA : BRA .check_fallback-3 .darkworld PHA - LDA $7EF37A : CMP.b #$7F : BNE -- + LDA CrystalsField : CMP.b #$7F : BNE -- - : PLA LDA.b #61 : BRA .check_fallback-3 .darkwoods PHA - LDA $7EF37A : CMP.b #$7F : BEQ - - LDA $7EF3CA : BEQ -- + LDA CrystalsField : CMP.b #$7F : BEQ - + LDA CurrentWorld : BEQ -- LDA $8A : CMP #$40 : BNE -- PLA LDA.b #15 : BRA .check_fallback-3 @@ -347,7 +347,7 @@ CheckMusicLoadRequest: LDA $7EF2F0 : AND.b #$20 : BEQ .rain + - LDA $7EF3C5 : CMP.b #$02 : BCS + + LDA ProgressIndicator : CMP.b #$02 : BCS + .rain LDX.b #$01 + @@ -385,7 +385,7 @@ SpiralStairsPreCheck: LDA !REG_MSU_ID_45 : CMP !VAL_MSU_ID_45 : BNE .done + - LDA $7EF366 : AND.w #$0004 : BEQ .done ; Check that we have the GT big key + LDA BigKeyField : AND.w #$0004 : BEQ .done ; Check that we have the GT big key LDA !REG_MSU_FALLBACK_TABLE+7 : AND.w #$0004 : BEQ .done ; Check that we have the extended track .fade diff --git a/music.asm b/music.asm index 7973a49..86895e7 100644 --- a/music.asm +++ b/music.asm @@ -22,7 +22,7 @@ PreOverworld_LoadProperties_ChooseMusic: LDX.b #$07 ; Default village theme ; Check what phase we're in - ;LDA $7EF3C5 : CMP.b #$03 : !BLT + + ;LDA ProgressIndicator : CMP.b #$03 : !BLT + ; LDX.b #$02 ; Default light world theme (phase >=3) ;+ @@ -45,14 +45,14 @@ PreOverworld_LoadProperties_ChooseMusic: LDX.b #$02 ; Check phase ; In phase >= 2 - LDA $7EF3C5 : CMP.b #$02 : !BGE + + LDA ProgressIndicator : CMP.b #$02 : !BGE + ; If phase < 2, play the legend music LDX.b #$03 + .endOfLightWorldChecks ; if we are in the light world go ahead and set chosen selection - LDA $7EF3CA : BEQ .checkInverted+4 + LDA CurrentWorld : BEQ .checkInverted+4 LDX.b #$0F ; dark woods theme @@ -68,10 +68,10 @@ PreOverworld_LoadProperties_ChooseMusic: ; if not inverted and light world, or inverted and dark world, skip moon pearl check .checkInverted - LDA $7EF3CA : CLC : ROL #$03 : CMP InvertedMode : BEQ .lastCheck + LDA CurrentWorld : CLC : ROL #$03 : CMP InvertedMode : BEQ .lastCheck ; Does Link have a moon pearl? - LDA $7EF357 : BNE + + LDA MoonPearlEquipment : BNE + LDX.b #$04 ; bunny theme + @@ -117,8 +117,8 @@ Overworld_FinishMirrorWarp: LDX.b #$04 ; bunny theme ; if not inverted and light world, or inverted and dark world, skip moon pearl check - LDA $7EF3CA : CLC : ROL #$03 : CMP InvertedMode : BEQ + - LDA $7EF357 : BEQ .endOfLightWorldChecks + LDA CurrentWorld : CLC : ROL #$03 : CMP InvertedMode : BEQ + + LDA MoonPearlEquipment : BEQ .endOfLightWorldChecks + LDX.b #$09 ; default dark world theme @@ -138,7 +138,7 @@ Overworld_FinishMirrorWarp: CMP.b #$18 : BNE .endOfLightWorldChecks ; Check what phase we're in - ; LDA $7EF3C5 : CMP.b #$03 : !BGE .endOfLightWorldChecks + ; LDA ProgressIndicator : CMP.b #$03 : !BGE .endOfLightWorldChecks LDX.b #$07 ; Default village theme (phase <3) .endOfLightWorldChecks @@ -158,7 +158,7 @@ Overworld_FinishMirrorWarp: LDX.b #$0D ; dark mountain theme .bunny - LDA $7EF357 : ORA InvertedMode : BNE + + LDA MoonPearlEquipment : ORA InvertedMode : BNE + LDX #$04 ; bunny theme + @@ -185,7 +185,7 @@ BirdTravel_LoadTargetAreaMusic: LDX.b #$07 ; Default village theme ; Check what phase we're in - ;LDA $7EF3C5 : CMP.b #$03 : !BLT + + ;LDA ProgressIndicator : CMP.b #$03 : !BLT + ; LDX.b #$02 ; Default light world theme (phase >=3) ;+ @@ -208,14 +208,14 @@ BirdTravel_LoadTargetAreaMusic: LDX.b #$02 ; Check phase ; In phase >= 2 - LDA $7EF3C5 : CMP.b #$02 : !BGE + + LDA ProgressIndicator : CMP.b #$02 : !BGE + ; If phase < 2, play the legend music LDX.b #$03 + .endOfLightWorldChecks ; if we are in the light world go ahead and set chosen selection - LDA $7EF3CA : BEQ .checkInverted+4 + LDA CurrentWorld : BEQ .checkInverted+4 LDX.b #$09 ; dark overworld theme @@ -236,16 +236,16 @@ BirdTravel_LoadTargetAreaMusic: BRA .checkInverted .darkMountain - LDA $7EF37A : CMP.b #$7F : BEQ + + LDA CrystalsField : CMP.b #$7F : BEQ + LDX.b #$0D ; dark death mountain theme + : LDA.b #$09 : STA $012D ; if not inverted and light world, or inverted and dark world, skip moon pearl check .checkInverted - LDA $7EF3CA : CLC : ROL #$03 : CMP InvertedMode : BEQ .lastCheck + LDA CurrentWorld : CLC : ROL #$03 : CMP InvertedMode : BEQ .lastCheck ; Does Link have a moon pearl? - LDA $7EF357 : BNE + + LDA MoonPearlEquipment : BNE + LDX.b #$04 ; bunny theme + @@ -275,7 +275,7 @@ Overworld_MosaicDarkWorldChecks: CMP.b #$51 : bne .doFade .checkCrystals - LDA $7EF37A : CMP.b #$7F : BEQ .done + LDA CrystalsField : CMP.b #$7F : BEQ .done .doFade LDA.b #$F1 : STA $012C ; thing we wrote over, fade out music diff --git a/newhud.asm b/newhud.asm index bb1db93..2265023 100644 --- a/newhud.asm +++ b/newhud.asm @@ -8,7 +8,7 @@ SEP #$30 LDA !INFINITE_BOMBS : BNE .infinite_bombs .finite_bombs - LDA.l $7EF343 ; bombs + LDA.l BombsEquipment ; bombs JSR HudHexToDec2Digit ;requires 8 bit registers! REP #$20 LDX.b $06 : TXA : ORA.w #$2400 : STA !BOMBCOUNT_DRAW_ADDRESS ; Draw bombs 10 digit @@ -26,7 +26,7 @@ SEP #$30 !RUPEE_DRAW_ADDRESS = "$7EC750" ;================================================================================ - LDA.l $7EF362 ; Drawing bombs (above) always ends with 16-bit A, so, no need to REP here + LDA.l CurrentRupees ; Drawing bombs (above) always ends with 16-bit A, so, no need to REP here JSR HudHexToDec4Digit LDX.b $04 : TXA : ORA.w #$2400 : STA !RUPEE_DRAW_ADDRESS ; 1000s LDX.b $05 : TXA : ORA.w #$2400 : STA !RUPEE_DRAW_ADDRESS+2 ; 100s @@ -43,7 +43,7 @@ SEP #$30 LDA.l ArrowMode : BNE + LDA !INFINITE_ARROWS : BNE .infinite_arrows .finite_arrows - LDA.l $7EF377 ; arrows + LDA.l CurrentArrows ; arrows JSR HudHexToDec2Digit REP #$20 LDX.b $06 : TXA : ORA.w #$2400 : STA !ARROWCOUNT_DRAW_ADDRESS ; Draw arrows 10 digit @@ -104,12 +104,11 @@ SEP #$30 ;================================================================================ ; Draw key count -!KEYS = "$7EF36F" !KEY_DIGITS_ADDRESS = "$7EC764" !KEY_ICON_ADDRESS = "$7EC726" ;================================================================================ SEP #$20 - LDA.l !KEYS : CMP.b #$FF : BEQ .not_in_dungeon + LDA.l CurrentSmallKeys : CMP.b #$FF : BEQ .not_in_dungeon .in_dungeon JSR HudHexToDec2Digit : REP #$20 @@ -156,7 +155,7 @@ SEP #$30 REP #$20 BEQ .drawprize - LDA.l $7EF368 + LDA.l MapField AND.l DungeonItemMasks,X BEQ .noprize @@ -184,13 +183,13 @@ SEP #$30 !INFINITE_MAGIC = "$7F50CA" !DrawMagicMeter_mp_tilemap = "$0DFE0F" ;-------------------------------------------------------------------------------- - LDA $7EF36E : AND #$00FF ; crap we wrote over when placing the hook for OnDrawHud + LDA CurrentMagic : AND #$00FF ; crap we wrote over when placing the hook for OnDrawHud !ADD #$0007 AND #$FFF8 TAX ; end of crap LDA !INFINITE_MAGIC : AND.w #$00FF : BNE + : JMP .green : + - SEP #$20 : LDA.b #$80 : STA $7EF36E : REP #$30 ; set magic to max + SEP #$20 : LDA.b #$80 : STA CurrentMagic : REP #$30 ; set magic to max LDX.w #$0080 ; load full magic meter graphics LDA $1A : AND.w #$000C : LSR #2 BEQ .red diff --git a/newitems.asm b/newitems.asm index c8df278..f9fbb3c 100755 --- a/newitems.asm +++ b/newitems.asm @@ -144,7 +144,6 @@ endmacro ;-------------------------------------------------------------------------------- !CHALLENGE_TIMER = "$7EF454" !GOAL_COUNTER = "$7EF418" -!INVENTORY_SWAP_2 = "$7EF38E" ;-------------------------------------------------------------------------------- ;carry clear if pass ;carry set if caught @@ -201,62 +200,62 @@ AddReceivedItemExpandedGetItem: LDA $02D8 ; check inventory JSL.l FreeDungeonItemNotice CMP.b #$0B : BNE + ; Bow - LDA !INVENTORY_SWAP_2 : AND.b #$40 : BEQ ++ + LDA BowTracking : AND.b #$40 : BEQ ++ LDA.l SilverArrowsUseRestriction : BNE ++ - LDA.b #03 : STA $7EF340 ; set bow to silver + LDA.b #03 : STA BowEquipment ; set bow to silver ++ JMP .done + CMP.b #$3B : BNE + ; Silver Bow LDA.l SilverArrowsUseRestriction : BNE .noequip LDA.l SilverArrowsAutoEquip : AND.b #$01 : BEQ .noequip - LDA $7EF376 : BNE ++ ; check arrows + LDA ArrowsFiller : BNE ++ ; check arrows LDA.b #$03 : BRA +++ ; bow without arrow ++ LDA.b #$04 ; bow with arrow +++ - STA $7EF340 + STA BowEquipment .noequip - LDA !INVENTORY_SWAP_2 : ORA #$40 : STA !INVENTORY_SWAP_2 ; mark silver bow on y-toggle + LDA BowTracking : ORA #$40 : STA BowTracking ; mark silver bow on y-toggle JMP .done + CMP.b #$4C : BNE + ; 50 bombs - ;LDA.b #$07 : STA $7EF370 ; upgrade bombs - LDA.b #50 : !SUB.l StartingMaxBombs : STA $7EF370 ; upgrade bombs - LDA.b #50 : STA $7EF375 ; fill bombs + ;LDA.b #$07 : STA BombCapacityUpgrades ; upgrade bombs + LDA.b #50 : !SUB.l StartingMaxBombs : STA BombCapacityUpgrades ; upgrade bombs + LDA.b #50 : STA BombsFiller ; fill bombs JMP .done + CMP.b #$4D : BNE + ; 70 arrows - ;LDA #$07 : STA $7EF371 ; upgrade arrows - LDA.b #70 : !SUB.l StartingMaxArrows : STA $7EF371 ; upgrade arrows - LDA.b #70 : STA $7EF376 ; fill arrows + ;LDA #$07 : STA ArrowCapacityUpgrades ; upgrade arrows + LDA.b #70 : !SUB.l StartingMaxArrows : STA ArrowCapacityUpgrades ; upgrade arrows + LDA.b #70 : STA ArrowsFiller ; fill arrows JMP .done + CMP.b #$4E : BNE + ; 1/2 magic - LDA $7EF37B : CMP #$02 : !BGE ++ - INC : STA $7EF37B ; upgrade magic + LDA MagicConsumption : CMP #$02 : !BGE ++ + INC : STA MagicConsumption ; upgrade magic ++ - LDA.b #$80 : STA $7EF373 ; fill magic + LDA.b #$80 : STA MagicFiller ; fill magic JMP .done + CMP.b #$4F : BNE + ; 1/4 magic - LDA.b #$02 : STA $7EF37B ; upgrade magic - LDA.b #$80 : STA $7EF373 ; fill magic + LDA.b #$02 : STA MagicConsumption ; upgrade magic + LDA.b #$80 : STA MagicFiller ; fill magic JMP .done + CMP.b #$50 : BNE + ; Master Sword (Safe) - LDA $7EF359 : CMP.b #$02 : !BGE + ; skip if we have a better sword - LDA.b #$02 : STA $7EF359 ; set master sword + LDA SwordEquipment : CMP.b #$02 : !BGE + ; skip if we have a better sword + LDA.b #$02 : STA SwordEquipment ; set master sword JMP .done + CMP.b #$51 : BNE + ; +5 Bombs - LDA $7EF370 : !ADD.b #$05 : STA $7EF370 ; upgrade bombs +5 - LDA.l Upgrade5BombsRefill : STA $7EF375 ; fill bombs + LDA BombCapacityUpgrades : !ADD.b #$05 : STA BombCapacityUpgrades ; upgrade bombs +5 + LDA.l Upgrade5BombsRefill : STA BombsFiller ; fill bombs JMP .done + CMP.b #$52 : BNE + ; +10 Bombs - LDA $7EF370 : !ADD.b #$0A : STA $7EF370 ; upgrade bombs +10 - LDA.l Upgrade10BombsRefill : STA $7EF375 ; fill bombs + LDA BombCapacityUpgrades : !ADD.b #$0A : STA BombCapacityUpgrades ; upgrade bombs +10 + LDA.l Upgrade10BombsRefill : STA BombsFiller ; fill bombs JMP .done + CMP.b #$53 : BNE + ; +5 Arrows - LDA $7EF371 : !ADD.b #$05 : STA $7EF371 ; upgrade arrows +5 - LDA.l Upgrade5ArrowsRefill : STA $7EF376 ; fill arrows + LDA ArrowCapacityUpgrades : !ADD.b #$05 : STA ArrowCapacityUpgrades ; upgrade arrows +5 + LDA.l Upgrade5ArrowsRefill : STA ArrowsFiller ; fill arrows JMP .done + CMP.b #$54 : BNE + ; +10 Arrows - LDA $7EF371 : !ADD.b #$0A : STA $7EF371 ; upgrade arrows +10 - LDA.l Upgrade10ArrowsRefill : STA $7EF376 ; fill arrows + LDA ArrowCapacityUpgrades : !ADD.b #$0A : STA ArrowCapacityUpgrades ; upgrade arrows +10 + LDA.l Upgrade10ArrowsRefill : STA ArrowsFiller ; fill arrows JMP .done + CMP.b #$55 : BNE + ; Programmable Object 1 %ProgrammableItemLogic(1) @@ -270,15 +269,15 @@ AddReceivedItemExpandedGetItem: + CMP.b #$58 : BNE + ; Upgrade-Only Sivler Arrows LDA.l SilverArrowsUseRestriction : BNE +++ LDA.l SilverArrowsAutoEquip : AND.b #$01 : BEQ +++ - LDA $7EF340 : BEQ ++ : CMP.b #$03 : !BGE ++ - !ADD.b #$02 : STA $7EF340 ; switch to silver bow + LDA BowEquipment : BEQ ++ : CMP.b #$03 : !BGE ++ + !ADD.b #$02 : STA BowEquipment ; switch to silver bow ++ +++ LDA.l ArrowMode : BEQ ++ - LDA.b #$01 : STA $7EF376 + LDA.b #$01 : STA ArrowsFiller ++ + CMP.b #$59 : BNE + ; 1 Rupoor - REP #$20 : LDA $7EF360 : !SUB RupoorDeduction : STA $7EF360 : SEP #$20 ; Take 1 rupee + REP #$20 : LDA TargetRupees : !SUB RupoorDeduction : STA TargetRupees : SEP #$20 ; Take 1 rupee JMP .done + CMP.b #$5A : BNE + ; Null Item JMP .done @@ -345,53 +344,53 @@ AddReceivedItemExpandedGetItem: + CMP.b #$70 : !BLT + : CMP.b #$80 : !BGE + ; Free Map AND #$0F : CMP #$08 : !BGE ++ %ValueShift() - ORA $7EF368 : STA $7EF368 ; Map 1 + ORA MapField : STA MapField ; Map 1 JMP .done ++ !SUB #$08 %ValueShift() BIT.b #$C0 : BEQ +++ : LDA.b #$C0 : +++ ; Make Hyrule Castle / Sewers Count for Both - ORA $7EF369 : STA $7EF369 ; Map 2 + ORA MapField+1 : STA MapField+1 ; Map 2 JMP .done + CMP.b #$80 : !BLT + : CMP.b #$90 : !BGE + ; Free Compass AND #$0F : CMP #$08 : !BGE ++ %ValueShift() - ORA $7EF364 : STA $7EF364 ; Compass 1 + ORA CompassField : STA CompassField ; Compass 1 JMP .done ++ !SUB #$08 %ValueShift() BIT.b #$C0 : BEQ +++ : LDA.b #$C0 : +++ ; Make Hyrule Castle / Sewers Count for Both - ORA $7EF365 : STA $7EF365 ; Compass 2 + ORA CompassField+1 : STA CompassField+1 ; Compass 2 JMP .done + CMP.b #$90 : !BLT + : CMP.b #$A0 : !BGE + ; Free Big Key AND #$0F : CMP #$08 : !BGE ++ %ValueShift() - ORA $7EF366 : STA $7EF366 ; Big Key 1 + ORA BigKeyField : STA BigKeyField ; Big Key 1 JMP .done ++ !SUB #$08 %ValueShift() BIT.b #$C0 : BEQ +++ : LDA.b #$C0 : +++ ; Make Hyrule Castle / Sewers Count for Both - ORA $7EF367 : STA $7EF367 ; Big Key 2 + ORA BigKeyField+1 : STA BigKeyField+1 ; Big Key 2 JMP .done + CMP.b #$A0 : !BLT + : CMP.b #$B0 : !BGE + ; Free Small Key AND #$0F : TAX - LDA $7EF37C, X : INC : STA $7EF37C, X ; Increment Key Count + LDA SewerKeys, X : INC : STA SewerKeys, X ; Increment Key Count CPX.b #$00 : BNE ++ - STA $7EF37D ; copy HC to sewers + STA HyruleCastleKeys ; copy HC to sewers ++ : CPX.b #$01 : BNE ++ - STA $7EF37C ; copy sewers to HC + STA SewerKeys ; copy sewers to HC ++ LDA.l GenericKeys : BEQ + .generic - LDA $7EF36F : INC : STA $7EF36F + LDA CurrentSmallKeys : INC : STA CurrentSmallKeys JMP .done .normal TXA : ASL : CMP $040C : BNE ++ - LDA $7EF36F : INC : STA $7EF36F + LDA CurrentSmallKeys : INC : STA CurrentSmallKeys ++ JMP .done + @@ -404,7 +403,7 @@ RTL ; #$90 - Big Keys ; #$A0 - Small Keys ;-------------------------------------------------------------------------------- -!PROGRESSIVE_SHIELD = "$7EF416" ; ss-- ---- +!HIGHEST_ARMOR_SHIELD_SWORD = "$7EF416" ; ss-- ---- !RNG_ITEM = "$7EF450" !SCRATCH_AREA = "$7F5020" !SINGLE_INDEX_TEMP = "$7F5020" @@ -458,11 +457,11 @@ AddReceivedItemExpanded: LDA.l BottleLimitReplacement : STA $02D8 +++ : JMP .done ++ : CMP.b #$4E : BNE ++ ; Progressive Magic - LDA $7EF37B : BEQ +++ + LDA MagicConsumption : BEQ +++ LDA.b #$4F : STA $02D8 +++ : JMP .done ++ : CMP.b #$5E : BNE ++ ; Progressive Sword - LDA $7EF359 : CMP.l ProgressiveSwordLimit : !BLT + + LDA SwordEquipment : CMP.l ProgressiveSwordLimit : !BLT + LDA.l ProgressiveSwordReplacement : STA $02D8 : JMP .done + : CMP.b #$00 : BNE + ; No Sword LDA.b #$49 : STA $02D8 : JMP .done @@ -473,39 +472,35 @@ AddReceivedItemExpanded: + ; Everything Else LDA.b #$03 : STA $02D8 : JMP .done ++ : CMP.b #$5F : BNE ++ ; Progressive Shield - LDA !PROGRESSIVE_SHIELD : LSR #6 : CMP.l ProgressiveShieldLimit : !BLT + + LDA ShieldEquipment : CMP.l ProgressiveShieldLimit : !BLT + LDA.l ProgressiveShieldReplacement : STA $02D8 : JMP .done - + - LDA !PROGRESSIVE_SHIELD : AND.b #$C0 : BNE + ; No Shield - LDA.b #$04 : STA $02D8 - LDA !PROGRESSIVE_SHIELD : !ADD.b #$40 : STA !PROGRESSIVE_SHIELD : JMP .done - + : CMP.b #$40 : BNE + ; Fighter Shield - LDA.b #$05 : STA $02D8 - LDA !PROGRESSIVE_SHIELD : !ADD.b #$40 : STA !PROGRESSIVE_SHIELD : JMP .done + + : CMP.b #$00 : BNE + ; No Shield + LDA.b #$04 : STA $02D8 : JMP .done + + : CMP.b #$01 : BNE + ; Fighter Shield + LDA.b #$05 : STA $02D8 : JMP .done + ; Everything Else - LDA.b #$06 : STA $02D8 - LDA !PROGRESSIVE_SHIELD : !ADD.b #$40 : STA !PROGRESSIVE_SHIELD : JMP .done + LDA.b #$06 : STA $02D8 : JMP .done ++ : CMP.b #$60 : BNE ++ ; Progressive Armor - LDA $7EF35B : CMP.l ProgressiveArmorLimit : !BLT + + LDA ArmorEquipment : CMP.l ProgressiveArmorLimit : !BLT + LDA.l ProgressiveArmorReplacement : STA $02D8 : JMP .done + : CMP.b #$00 : BNE + ; No Armor LDA.b #$22 : STA $02D8 : JMP .done + ; Everything Else LDA.b #$23 : STA $02D8 : JMP .done ++ : CMP.b #$61 : BNE ++ ; Progressive Lifting Glove - LDA $7EF354 : BNE + ; No Lift + LDA GloveEquipment : BNE + ; No Lift LDA.b #$1B : STA $02D8 : BRA .done + ; Everything Else LDA.b #$1C : STA $02D8 : BRA .done ++ : CMP.b #$64 : BNE ++ : -- ; Progressive Bow - LDA $7EF340 : INC : LSR : CMP.l ProgressiveBowLimit : !BLT + + LDA BowEquipment : INC : LSR : CMP.l ProgressiveBowLimit : !BLT + LDA.l ProgressiveBowReplacement : STA $02D8 : JMP .done + : CMP.b #$00 : BNE + ; No Bow LDA.b #$3A : STA $02D8 : BRA .done + ; Any Bow LDA.b #$3B : STA $02D8 : BRA .done ++ : CMP.b #$65 : BNE ++ ; Progressive Bow 2 - LDA.l !INVENTORY_SWAP_2 : ORA #$20 : STA.l !INVENTORY_SWAP_2 + LDA.l BowTracking : ORA #$20 : STA.l BowTracking BRA -- ; ++ : CMP.b #$FE : BNE ++ ; Server Request (Null Chest) ; JSL ChestItemServiceRequest @@ -758,7 +753,7 @@ org $A08800 dw $F359 ; Master Sword (Safe) dw $F375, $F375, $F376, $F376 ; +5/+10 Bomb Arrows dw $F41A, $F41C, $F41E ; 3x Programmable Item - dw $F340 ; Upgrade-Only Sivler Arrows + dw $F340 ; Upgrade-Only Silver Arrows dw $F360 ; 1 Rupoor dw $F36A ; Null Item dw $F454, $F454, $F454 ; Red, Blue & Green Clocks @@ -918,8 +913,8 @@ Link_ReceiveItemAlternatesExpanded: RTL ;-------------------------------------------------------------------------------- ;DrawHUDSilverArrows: -; LDA $7EF340 : AND.w #$00FF : BNE + -; LDA !INVENTORY_SWAP_2 : AND.w #$0040 : BEQ + +; LDA BowEquipment : AND.w #$00FF : BNE + +; LDA BowTracking : AND.w #$0040 : BEQ + ; LDA.w #$2810 : STA $11C8 ; LDA.w #$2811 : STA $11CA ; LDA.w #$2820 : STA $1208 @@ -928,19 +923,19 @@ RTL ; LDA.w #$11CE : STA $00 ; thing we wrote over ;RTL ;-------------------------------------------------------------------------------- -;Return $7EF340 but also draw silver arrows if you have the upgrade even if you don't have the bow +;Return BowEquipment but also draw silver arrows if you have the upgrade even if you don't have the bow CheckHUDSilverArrows: LDA.l ArrowMode : BEQ .normal .rupee_arrows JSL.l DrawHUDArrows - LDA $7EF340 + LDA BowEquipment RTL .normal - LDA $7EF340 : BNE + - LDA !INVENTORY_SWAP_2 : AND.b #$40 : BEQ ++ + LDA BowEquipment : BNE + + LDA BowTracking : AND.b #$40 : BEQ ++ JSL.l DrawHUDArrows ++ - LDA $7EF340 + LDA BowEquipment + RTL ;-------------------------------------------------------------------------------- @@ -948,9 +943,9 @@ DrawHUDArrows: LDA.l ArrowMode : BEQ .normal .rupee_arrows - LDA $7EF377 : BEQ .none ; assuming silvers will increment this. if we go with something else, reorder these checks - LDA $7EF340 : BNE + - LDA !INVENTORY_SWAP_2 : AND.b #$40 : BNE .silver + LDA CurrentArrows : BEQ .none ; assuming silvers will increment this. if we go with something else, reorder these checks + LDA BowEquipment : BNE + + LDA BowTracking : AND.b #$40 : BNE .silver BRA .wooden + CMP.b #03 : !BGE .silver @@ -1070,7 +1065,7 @@ IncrementItemCounters: .match PHX TXA : LSR #2 : TAX - LDA !ITEM_LIMIT_COUNTS, X : INC : STA !ITEM_LIMIT_COUNTS, X + LDA ItemLimitCounts, X : INC : STA ItemLimitCounts, X PLX BEQ .exit .noMatch @@ -1090,7 +1085,7 @@ AttemptItemSubstitution: .match PHX TXA : LSR #2 : TAX - LDA !ITEM_LIMIT_COUNTS, X + LDA ItemLimitCounts, X PLX CMP.l ItemSubstitutionRules+1, X : !BLT + LDA.l ItemSubstitutionRules+2, X : STA 1,s @@ -1106,10 +1101,10 @@ RTS CountBottles: PHX LDX.b #$00 - LDA $7EF35C : BEQ ++ : INX - ++ : LDA $7EF35D : BEQ ++ : INX - ++ : LDA $7EF35E : BEQ ++ : INX - ++ : LDA $7EF35F : BEQ ++ : INX + LDA BottleContentsOne : BEQ ++ : INX + ++ : LDA BottleContentsTwo : BEQ ++ : INX + ++ : LDA BottleContentsThree : BEQ ++ : INX + ++ : LDA BottleContentsFour : BEQ ++ : INX ++ TXA PLX diff --git a/npcitems.asm b/npcitems.asm index db20ce6..c1a546f 100644 --- a/npcitems.asm +++ b/npcitems.asm @@ -49,11 +49,11 @@ ItemCheck_SickKid: RTL ItemCheck_TreeKid: - LDA !NPC_FLAGS : AND.b #$08 ; FluteBoy_Chillin - 73: LDA $7EF34C + LDA !NPC_FLAGS : AND.b #$08 ; FluteBoy_Chillin - 73: LDA FluteEquipment RTL ItemCheck_TreeKid2: - LDA !NPC_FLAGS : AND.b #$08 : LSR #$02 ; FluteAardvark_InitialStateFromFluteState - 225: LDA $7EF34C : AND.b #$03 + LDA !NPC_FLAGS : AND.b #$08 : LSR #$02 ; FluteAardvark_InitialStateFromFluteState - 225: LDA FluteEquipment : AND.b #$03 RTL ItemCheck_TreeKid3: @@ -92,7 +92,7 @@ ItemCheck_Catfish: ;LDA CatfishGoodItem : BEQ .junk ;PHX ; LDA CatfishGoodItem+1 : TAX - ; LDA $7EF340-1, X + ; LDA BowEquipment-1, X ;PLX ;-- ;CMP CatfishGoodItem : !BLT .oursNewer diff --git a/openmode.asm b/openmode.asm index 4bf907c..c5ddfff 100644 --- a/openmode.asm +++ b/openmode.asm @@ -6,15 +6,15 @@ !INFINITE_MAGIC = "$7F50CA" SetUncleRainState: LDA.l OpenMode : BEQ + : RTL : + ; we're done if open mode is on - LDA.b #$01 : STA $7EF3C5 + LDA.b #$01 : STA ProgressIndicator RTL ;-------------------------------------------------------------------------------- InitOpenMode: LDA.l OpenMode : BEQ + ; Skip if not open mode - LDA $7EF3C5 : CMP #$02 : !BGE + ; Skip if already past escape - LDA.b #$02 : STA $7EF3C5 ; Go to post-escape phase (pre aga1) - LDA $7EF3C6 : ORA #$14 : STA $7EF3C6 ; remove uncle - LDA $7EF3C8 : CMP #$05 : BEQ ++ : LDA.b #$01 : ++ : STA $7EF3C8 ; set spawn points to house+sanc unless already house+sanc+mountain + 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 $7EF29B : ORA.b #$20 : STA $7EF29B ; open castle gate JSL MaybeSetPostAgaWorldState + @@ -22,8 +22,8 @@ RTL ;-------------------------------------------------------------------------------- MaybeSetPostAgaWorldState: LDA.l InstantPostAgaWorldState : BEQ + ; Skip if not enabled - LDA.b #$03 : STA $7EF3C5 ; Go to post-aga phase + LDA.b #$03 : STA ProgressIndicator ; Go to post-aga phase LDA $7EF282 : ORA.b #$20 : STA $7EF282 ; make lumberjack tree accessible + RTL -;-------------------------------------------------------------------------------- \ No newline at end of file +;-------------------------------------------------------------------------------- diff --git a/pendantcrystalhud.asm b/pendantcrystalhud.asm index 256b395..e0fe5a9 100644 --- a/pendantcrystalhud.asm +++ b/pendantcrystalhud.asm @@ -8,13 +8,13 @@ FlipLWDWFlag: PHP SEP #$20 ; set 8-bit accumulator - LDA $7EF3CA : EOR.b #$40 : STA $7EF3CA + LDA CurrentWorld : EOR.b #$40 : STA CurrentWorld BEQ + LDA.b #07 : BRA ++ ; dark world - crystals + LDA.b #03 ; light world - pendants ++ - STA $7EF3C7 + STA MapIcons PLP RTL ;================================================================================ @@ -23,7 +23,7 @@ HUDRebuildIndoorHole: LDA.l GenericKeys : BEQ .normal .generic PLA - LDA $7EF38B ; generic key count + LDA CurrentGenericKeys ; generic key count JSL.l HUD_RebuildIndoor_Palace RTL .normal @@ -35,7 +35,7 @@ HUDRebuildIndoor: LDA.l GenericKeys : BEQ .normal .generic LDA.b #$00 : STA $7EC017 - LDA $7EF38B ; generic key count + LDA CurrentGenericKeys ; generic key count RTL .normal LDA.b #$00 : STA $7EC017 @@ -45,25 +45,24 @@ RTL GetCrystalNumber: PHX TXA : ASL : TAX - LDA $7EF3CA : EOR.b #$40 : BNE + + LDA CurrentWorld : EOR.b #$40 : BNE + INX + LDA.l CrystalNumberTable-16, X PLX RTL ;================================================================================ -!INVENTORY_MAP = "$7EF368" !MAP_OVERLAY = "$7EF414" ; [2] OverworldMap_CheckObject: PHX ;CPX.b #$01 : BNE + : JMP ++ : + : JMP .fail - LDA $7EF3CA : AND.b #$40 : BNE + + LDA CurrentWorld : AND.b #$40 : BNE + ;LW Map LDA.l MapMode : BEQ +++ - LDA !INVENTORY_MAP : ORA !MAP_OVERLAY : AND.b #$01 : BNE +++ + LDA MapField : ORA !MAP_OVERLAY : AND.b #$01 : BNE +++ PHX LDA.l .lw_map_offsets, X : TAX ; put map offset into X - LDA !INVENTORY_MAP, X : ORA !MAP_OVERLAY, X + LDA MapField, X : ORA !MAP_OVERLAY, X PLX AND.l .lw_map_masks, X : BNE +++ JMP .fail @@ -74,10 +73,10 @@ OverworldMap_CheckObject: + ;DW Map LDA.l MapMode : BEQ +++ - LDA !INVENTORY_MAP : ORA !MAP_OVERLAY : AND.b #$02 : BNE +++ + LDA MapField : ORA !MAP_OVERLAY : AND.b #$02 : BNE +++ PHX LDA.l .dw_map_offsets, X : TAX ; put map offset into X - LDA.l !INVENTORY_MAP, X : ORA !MAP_OVERLAY, X + LDA.l MapField, X : ORA !MAP_OVERLAY, X PLX AND.l .dw_map_masks, X : BNE +++ JMP .fail @@ -92,11 +91,11 @@ RTL AND.b #$40 : BNE .checkCrystal .checkPendant - LDA $7EF374 : AND.l CrystalPendantFlags, X : BNE .fail + LDA PendantsField : AND.l CrystalPendantFlags, X : BNE .fail CLC : BRA .done .checkCrystal - LDA $7EF37A : AND.l CrystalPendantFlags, X : BNE .fail + LDA CrystalsField : AND.l CrystalPendantFlags, X : BNE .fail CLC : BRA .done .fail @@ -121,18 +120,18 @@ db $02, $80, $08, $10, $01, $40, $04 SetLWDWMap: PHP SEP #$20 ; set 8-bit accumulator - LDA $7EF3CA : EOR.b #$40 + LDA CurrentWorld : EOR.b #$40 BNE + LDA.b #07 : BRA ++ ; dark world - crystals + LDA.b #03 ; light world - pendants ++ - STA $7EF3C7 + STA MapIcons PLP RTL ;================================================================================ GetMapMode: - LDA $7EF3CA : AND.b #$40 : BEQ + + LDA CurrentWorld : AND.b #$40 : BEQ + LDA.b #07 ; dark world - crystals RTL + @@ -205,13 +204,13 @@ UpdateKeys: LSR : TAX ; get dungeon index and store to X - LDA $7EF36F ; load current key count - STA $7EF37C, X ; save to main counts + LDA CurrentSmallKeys ; load current key count + STA SewerKeys, X ; save to main counts CPX.b #$00 : BNE + - STA $7EF37D ; copy HC to sewers + STA HyruleCastleKeys ; copy HC to sewers + : CPX.b #$01 : BNE + - STA $7EF37C ; copy sewers to HC + STA SewerKeys ; copy sewers to HC + .skip JSL.l PostItemGet @@ -285,19 +284,19 @@ DrawHUDDungeonItems: dw 30 ; Ganon's Tower .small_key_x_offset - dw $7EF37D-$7EF37D ; Hyrule Castle - dw $7EF37E-$7EF37D ; Eastern - dw $7EF37F-$7EF37D ; Desert - dw $7EF386-$7EF37D ; Hera - dw $7EF380-$7EF37D ; Agahnims Tower - dw $7EF382-$7EF37D ; PoD - dw $7EF381-$7EF37D ; Swamp - dw $7EF384-$7EF37D ; Skull Woods - dw $7EF387-$7EF37D ; Thieves Town - dw $7EF385-$7EF37D ; Ice - dw $7EF383-$7EF37D ; Mire - dw $7EF388-$7EF37D ; Turtle Rock - dw $7EF389-$7EF37D ; Ganon's Tower + dw HyruleCastleKeys-DungeonKeys ; Hyrule Castle + dw EasternKeys-DungeonKeys ; Eastern + dw DesertKeys-DungeonKeys ; Desert + dw HeraKeys-DungeonKeys ; Hera + dw CastleTowerKeys-DungeonKeys ; Agahnims Tower + dw PalaceOfDarknessKeys-DungeonKeys ; PoD + dw SwampKeys-DungeonKeys ; Swamp + dw SkullWoodsKeys-DungeonKeys ; Skull Woods + dw ThievesTownKeys-DungeonKeys ; Thieves Town + dw IcePalaceKeys-DungeonKeys ; Ice + dw MireKeys-DungeonKeys ; Mire + dw TurtleRockKeys-DungeonKeys ; Turtle Rock + dw GanonsTowerKeys-DungeonKeys ; Ganon's Tower .dungeon_bitmasks @@ -386,7 +385,7 @@ DrawHUDDungeonItems: .next_small_key LDX.w .small_key_x_offset,Y - LDA.l $7EF37D,X + LDA.l DungeonKeys,X AND.w #$00FF LDX.w .dungeon_positions,Y @@ -410,7 +409,7 @@ DrawHUDDungeonItems: LDX.w #0 ; load once and test multiple times - LDA.l $7EF366 + LDA.l BigKeyField .next_big_key BIT.w .dungeon_bitmasks,X @@ -421,7 +420,7 @@ DrawHUDDungeonItems: STA.w $16C6,Y ; reload - LDA.l $7EF366 + LDA.l BigKeyField ..skip_key INX : INX @@ -469,7 +468,7 @@ DrawHUDDungeonItems: LDX.w #0 ; load once and test multiple times - LDA.l $7EF368 + LDA.l MapField .next_map BIT.w .dungeon_bitmasks,X @@ -480,7 +479,7 @@ DrawHUDDungeonItems: STA.w $1686,Y ; reload - LDA.l $7EF368 + LDA.l MapField ..skip_map INX : INX @@ -498,7 +497,7 @@ DrawHUDDungeonItems: LDX.w #0 ; load once and test multiple times - LDA.l $7EF364 + LDA.l CompassField .next_compass BIT.w .dungeon_bitmasks,X @@ -509,7 +508,7 @@ DrawHUDDungeonItems: STA.w $16C6,Y ; reload - LDA.l $7EF364 + LDA.l CompassField ..skip_compass INX : INX @@ -542,7 +541,7 @@ DrawPendantCrystalDiagram: INX #2 : CPX.w #$0014 : BCC - ; pendants - LDA $7EF374 + LDA PendantsField LSR : BCC + ; pendant of wisdom (red) LDX.w #$252B @@ -569,7 +568,7 @@ DrawPendantCrystalDiagram: ; crystals - LDA $7EF37A + LDA CrystalsField LDX.w #$2D44 LDY.w #$2D45 @@ -675,4 +674,4 @@ dw $A8FB, $A8F9, $A8F9, $A8F9, $A8F9, $A8F9, $A8F9, $A8F9, $A8F9, $E8FB ;0x1A - Ganon's Tower ;0x1C - ??? possibly unused. (Were they planning two extra dungeons perhaps?) ;0x1E - ??? possibly unused. -;================================================================================ \ No newline at end of file +;================================================================================ diff --git a/playername.asm b/playername.asm index 68dbb8f..2a820b6 100644 --- a/playername.asm +++ b/playername.asm @@ -1,30 +1,35 @@ ; Note shortly before this we have a blank-the-sram slot code that we might want to hook WriteBlanksToPlayerName: - STA.l !ExtendedPlayerName - STA.l !ExtendedPlayerName+2 - STA.l !ExtendedPlayerName+4 - STA.l !ExtendedPlayerName+6 + STA.l ExtendedFileNameSRAM + STA.l ExtendedFileNameSRAM+2 + STA.l ExtendedFileNameSRAM+4 + STA.l ExtendedFileNameSRAM+6 - STA.l !ExtendedPlayerName+8 - STA.l !ExtendedPlayerName+10 - STA.l !ExtendedPlayerName+12 - STA.l !ExtendedPlayerName+14 + STA.l ExtendedFileNameSRAM+8 + STA.l ExtendedFileNameSRAM+10 + STA.l ExtendedFileNameSRAM+12 + STA.l ExtendedFileNameSRAM+14 - STA.l $7003D9, X ;What we wrote over (clear first byte of vanilla name slot) + STA.l ExtendedFileNameSRAM+16 + STA.l ExtendedFileNameSRAM+18 + STA.l ExtendedFileNameSRAM+20 + STA.l ExtendedFileNameSRAM+22 + + STA.l $7003D9, X ;What we wrote over (clear first byte of vanilla name slot) RTL WriteCharacterToPlayerName: - CPX.w #$0008 : !BLT .orig - STA !ExtendedPlayerName-8, X - .orig - STA $7003D9, X ;what we wrote over + STA ExtendedFileNameSRAM, X + CPX.w #$0008 : !BGE + + STA $7003D9, X ;what we wrote over + + RTL ReadCharacterFromPlayerName: ;Only for use on Name Screen - CPX.w #$0008 : !BLT .orig - LDA !ExtendedPlayerName-8, X - .orig - LDA $7003D9, X ;what we wrote over + LDA ExtendedFileNameSRAM, X + CPX.w #$0008 : !BGE + + LDA $7003D9, X ;what we wrote over + + RTL GetCharacterPosition: diff --git a/potions.asm b/potions.asm index f5985c0..5e9b4c6 100644 --- a/potions.asm +++ b/potions.asm @@ -15,19 +15,19 @@ RefillHealth: LDA.l PotionHealthRefill : CMP.b #$A0 : !BGE .done LDA !BUSY_HEALTH : BNE ++ LDA.l PotionHealthRefill ; load refill amount - !ADD $7EF36D ; add to current health - CMP $7EF36C : !BLT +++ : LDA $7EF36C : +++ + !ADD CurrentHealth ; add to current health + CMP HealthCapacity : !BLT +++ : LDA HealthCapacity : +++ STA !BUSY_HEALTH ++ - LDA $7EF36D : CMP.l !BUSY_HEALTH : !BLT ++ - LDA.b #$00 : STA $7EF372 + LDA CurrentHealth : CMP.l !BUSY_HEALTH : !BLT ++ + LDA.b #$00 : STA HeartsFiller LDA $020A : BNE .notDone LDA.b #$00 : STA !BUSY_HEALTH SEC RTL ++ - LDA.b #$08 : STA $7EF372 ; refill some health + LDA.b #$08 : STA HeartsFiller ; refill some health .notDone CLC RTL @@ -35,16 +35,16 @@ RefillHealth: ; Check goal health versus actual health. ; if(actual < goal) then branch. - LDA $7EF36D : CMP $7EF36C : BCC .refillAllHealth - LDA $7EF36C : STA $7EF36D - LDA.b #$00 : STA $7EF372 + LDA CurrentHealth : CMP HealthCapacity : BCC .refillAllHealth + LDA HealthCapacity : STA CurrentHealth + LDA.b #$00 : STA HeartsFiller ; ??? not sure what purpose this branch serves. LDA $020A : BNE .beta SEC RTL .refillAllHealth ; Fill up ze health. - LDA.b #$A0 : STA $7EF372 + LDA.b #$A0 : STA HeartsFiller .beta CLC RTL @@ -62,27 +62,27 @@ RefillMagic: LDA.l PotionMagicRefill : CMP.b #$80 : !BGE .done LDA !BUSY_MAGIC : BNE ++ LDA.l PotionMagicRefill ; load refill amount - !ADD $7EF36E ; add to current magic + !ADD CurrentMagic ; add to current magic CMP.b #$80 : !BLT +++ : LDA.b #$80 : +++ STA !BUSY_MAGIC ++ - LDA $7EF36E : CMP.l !BUSY_MAGIC : !BLT ++ + LDA CurrentMagic : CMP.l !BUSY_MAGIC : !BLT ++ LDA.b #$00 : STA !BUSY_MAGIC SEC RTL ++ - LDA.b #$01 : STA $7EF373 ; refill some magic + LDA.b #$01 : STA MagicFiller ; refill some magic CLC RTL .done SEP #$30 ; Check if Link's magic meter is full - LDA $7EF36E : CMP.b #$80 + LDA CurrentMagic : CMP.b #$80 BCS .itsFull ; Tell the magic meter to fill up until it's full. - LDA.b #$80 : STA $7EF373 + LDA.b #$80 : STA MagicFiller SEP #$30 RTL .itsFull diff --git a/quickswap.asm b/quickswap.asm index e73938c..d23bddd 100644 --- a/quickswap.asm +++ b/quickswap.asm @@ -28,7 +28,7 @@ QuickSwap: BRA .store .special_swap - LDA !INVENTORY_SWAP_2 : ORA #$01 : STA !INVENTORY_SWAP_2 + LDA BowTracking : ORA #$01 : STA BowTracking CPX.b #$02 : BEQ + ; boomerang CPX.b #$01 : BEQ + ; bow CPX.b #$05 : BEQ + ; powder @@ -50,10 +50,10 @@ RTL RCode: LDX.w $0202 LDA.b $F2 : BIT #$20 : BNE ++ ; Still holding L from a previous frame - LDA !INVENTORY_SWAP_2 : AND #$FE : STA !INVENTORY_SWAP_2 + LDA BowTracking : AND #$FE : STA BowTracking BRA + ++ - LDA !INVENTORY_SWAP_2 : BIT #$01 : BEQ + + LDA BowTracking : BIT #$01 : BEQ + RTS - + CPX.b #$14 : BNE + : LDX.b #$00 ;will wrap around to 1 @@ -65,10 +65,10 @@ RTS LCode: LDX.w $0202 LDA.b $F2 : BIT #$10 : BNE ++ ; Still holding R from a previous frame - LDA !INVENTORY_SWAP_2 : AND #$FE : STA !INVENTORY_SWAP_2 + LDA BowTracking : AND #$FE : STA BowTracking BRA + ++ - LDA !INVENTORY_SWAP_2 : BIT #$01 : BEQ + + LDA BowTracking : BIT #$01 : BEQ + RTS - + CPX.b #$01 : BNE + : LDX.b #$15 ; will wrap around to $14 diff --git a/retro.asm b/retro.asm index d073cc4..477f4a8 100644 --- a/retro.asm +++ b/retro.asm @@ -10,13 +10,13 @@ RTL LoadBombCount: LDA !INFINITE_BOMBS : BNE .infinite .finite - LDA $7EF343 + LDA BombsEquipment .infinite RTL LoadBombCount16: LDA !INFINITE_BOMBS : AND.w #$00FF : BNE .infinite .finite - LDA $7EF343 + LDA BombsEquipment .infinite RTL StoreBombCount: @@ -24,13 +24,13 @@ StoreBombCount: .infinite PLA : LDA.b #$01 : RTL .finite - PLA : STA $7EF343 + PLA : STA BombsEquipment RTL SearchForEquippedItem: LDA !INFINITE_BOMBS : BEQ + LDA.b #$01 : LDX.b #$00 : RTL + - LDA $7EF340 ; thing we wrote over + LDA BowEquipment ; thing we wrote over RTL !INFINITE_ARROWS = "$7F50C8" @@ -40,8 +40,8 @@ DecrementArrows: .infinite LDA.b #$01 : RTL .normal - LDA $7EF377 : BEQ .done - DEC : STA $7EF377 : INC + LDA CurrentArrows : BEQ .done + DEC : STA CurrentArrows : INC BRA .done .rupees REP #$20 @@ -51,17 +51,17 @@ DecrementArrows: LDA.b #$00 : BRA .done .not_archery_game - LDA.l $7EF377 : BNE .shoot_arrow ; check if we have arrows + LDA.l CurrentArrows : BNE .shoot_arrow ; check if we have arrows BRA .done .shoot_arrow PHX REP #$20 - LDA $7EF360 : BEQ + - PHA : LDA $7EF340 : DEC : AND #$0002 : TAX : PLA + LDA TargetRupees : BEQ + + PHA : LDA BowEquipment : DEC : AND #$0002 : TAX : PLA !SUB.l ArrowModeWoodArrowCost, X ; CMP.w #$0000 BMI .not_enough_money - STA $7EF360 : LDA.w #$0001 : BRA + + STA TargetRupees : LDA.w #$0001 : BRA + .not_enough_money LDA.w #$0000 + @@ -76,13 +76,13 @@ ArrowGame: DEC $0B99 ; reduce minigame arrow count LDA.l ArrowMode : BNE .rupees .normal - LDA $7EF377 : INC #2 : STA $7EF377 ; increment arrow count (by 2 for some reason) + LDA CurrentArrows : INC #2 : STA CurrentArrows ; increment arrow count (by 2 for some reason) RTL .rupees PHX REP #$20 ; set 16-bit accumulator - LDA $7EF340 : DEC : AND #$0002 : TAX - LDA $7EF360 : !ADD.l ArrowModeWoodArrowCost, X : STA $7EF360 + LDA BowEquipment : DEC : AND #$0002 : TAX + LDA TargetRupees : !ADD.l ArrowModeWoodArrowCost, X : STA TargetRupees SEP #$20 ; set 8-bit accumulator PLX + diff --git a/rngfixes.asm b/rngfixes.asm index 33cddff..adb3d1c 100644 --- a/rngfixes.asm +++ b/rngfixes.asm @@ -97,7 +97,7 @@ RNG_Ganon_Extra_Warp: PLA RTL RNG_Enemy_Drops: - LDA.l $7EF3C5 : CMP #$01 : BEQ + ; drops are static after uncle pickup & before rescuing zelda + LDA.l ProgressIndicator : CMP #$01 : BEQ + ; drops are static after uncle pickup & before rescuing zelda JML GetRandomInt + LDA.b #$0F diff --git a/roomloading.asm b/roomloading.asm index d545b29..2e07057 100644 --- a/roomloading.asm +++ b/roomloading.asm @@ -84,7 +84,7 @@ IcePalaceBombosNE: RTL CastleEastEntrance: - LDA $7EF3C5 : CMP.b #$02 : !BLT + : RTL : + ; only apply in rain states (0 or 1) + LDA ProgressIndicator : CMP.b #$02 : !BLT + : RTL : + ; only apply in rain states (0 or 1) LDA.l BlockCastleDoorsInRain : BNE + : RTL : + REP #$20 ; 16 A @@ -115,7 +115,7 @@ CastleEastEntrance: RTL CastleWestEntrance: - LDA $7EF3C5 : CMP.b #$02 : !BLT + : RTL : + ; only apply in rain states (0 or 1) + LDA ProgressIndicator : CMP.b #$02 : !BLT + : RTL : + ; only apply in rain states (0 or 1) LDA.l BlockCastleDoorsInRain : BNE + : RTL : + REP #$20 ; 16 A diff --git a/rupeelimit.asm b/rupeelimit.asm index b17f56b..8c573d0 100644 --- a/rupeelimit.asm +++ b/rupeelimit.asm @@ -11,7 +11,7 @@ Draw4DigitRupees: BRA .print .outdoors .normal - LDA $7EF362 + LDA CurrentRupees .print JSL.l HexToDec LDA $7F5004 : AND.w #$00FF : ORA.w #$2400 : STA $7EC750 @@ -19,4 +19,4 @@ Draw4DigitRupees: LDA $7F5006 : AND.w #$00FF : ORA.w #$2400 : STA $7EC754 LDA $7F5007 : AND.w #$00FF : ORA.w #$2400 : STA $7EC756 RTL -;================================================================================ \ No newline at end of file +;================================================================================ diff --git a/shopkeeper.asm b/shopkeeper.asm index 4132011..8b29c55 100644 --- a/shopkeeper.asm +++ b/shopkeeper.asm @@ -168,7 +168,7 @@ SpritePrep_ShopKeeper: PHY PHX LDA.b #$00 : XBA : TYA : LSR #2 : !ADD !SHOP_SRAM_INDEX : TAX - LDA !SHOP_PURCHASE_COUNTS, X : TYX : STA.l !SHOP_INVENTORY+3, X : TAY + LDA PurchaseCounts, X : TYX : STA.l !SHOP_INVENTORY+3, X : TAY PLX LDA.l ShopContentsTable+4, X : BEQ ++ @@ -214,7 +214,7 @@ SpritePrep_ShopKeeper: .takeAll LDA.b #$00 : XBA : LDA !SHOP_SRAM_INDEX : TAX - LDA.l !SHOP_PURCHASE_COUNTS, X + LDA.l PurchaseCounts, X BRA ++ .notTakeAll LDA.b #$00 @@ -266,7 +266,7 @@ RTS ;!SHOP_INVENTORY, X ;[id][$lo][$hi][purchase_counter] ;-------------------------------------------------------------------------------- -;!SHOP_PURCHASE_COUNTS = "$7EF302" +;PurchaseCounts = "$7EF51A" ;-------------------------------------------------------------------------------- Shopkeeper_UploadVRAMTilesLong: JSR.w Shopkeeper_UploadVRAMTiles @@ -390,13 +390,13 @@ Sprite_ShopKeeper: BIT.b #$20 : BNE + ; Not A Take-All PHX LDA !SHOP_SRAM_INDEX : TAX - LDA !SHOP_PURCHASE_COUNTS, X : BEQ ++ : PLX : BRA .done : ++ + LDA PurchaseCounts, X : BEQ ++ : PLX : BRA .done : ++ PLX BRA .normal + ; Take-All ;PHX ; LDA !SHOP_SRAM_INDEX : TAX - ; LDA.w !SHOP_PURCHASE_COUNTS, X : STA.l !SHOP_STATE + ; LDA.w PurchaseCounts, X : STA.l !SHOP_STATE ;PLX .normal @@ -539,7 +539,7 @@ Shopkeeper_BuyItem: + LDA !SHOP_TYPE : AND.b #$80 : BNE .buy ; don't charge if this is a take-any - REP #$20 : LDA $7EF360 : CMP.l !SHOP_INVENTORY+1, X : SEP #$20 : !BGE .buy + REP #$20 : LDA TargetRupees : CMP.l !SHOP_INVENTORY+1, X : SEP #$20 : !BGE .buy .cant_afford LDA.b #$7A @@ -555,7 +555,7 @@ Shopkeeper_BuyItem: JMP .done .buy LDA !SHOP_TYPE : AND.b #$80 : BNE ++ ; don't charge if this is a take-any - REP #$20 : LDA $7EF360 : !SUB !SHOP_INVENTORY+1, X : STA $7EF360 : SEP #$20 ; Take price away + REP #$20 : LDA TargetRupees : !SUB !SHOP_INVENTORY+1, X : STA TargetRupees : SEP #$20 ; Take price away ++ LDA.l !SHOP_INVENTORY, X : TAY : JSL.l Link_ReceiveItem LDA.l !SHOP_INVENTORY+3, X : INC : STA.l !SHOP_INVENTORY+3, X @@ -565,7 +565,7 @@ Shopkeeper_BuyItem: LDA.l !SHOP_STATE : ORA.w Shopkeeper_ItemMasks, X : STA.l !SHOP_STATE PHX TXA : !ADD !SHOP_SRAM_INDEX : TAX - LDA !SHOP_PURCHASE_COUNTS, X : INC : BEQ +++ : STA !SHOP_PURCHASE_COUNTS, X : +++ + LDA PurchaseCounts, X : INC : BEQ +++ : STA PurchaseCounts, X : +++ PLX BRA ++ + ; Take-any @@ -573,11 +573,11 @@ Shopkeeper_BuyItem: BIT.b #$20 : BNE .takeAll .takeAny LDA.l !SHOP_STATE : ORA.b #$07 : STA.l !SHOP_STATE - PHX : LDA.l !SHOP_SRAM_INDEX : TAX : LDA.b #$01 : STA.l !SHOP_PURCHASE_COUNTS, X : PLX + PHX : LDA.l !SHOP_SRAM_INDEX : TAX : LDA.b #$01 : STA.l PurchaseCounts, X : PLX BRA ++ .takeAll LDA.l !SHOP_STATE : ORA.w Shopkeeper_ItemMasks, X : STA.l !SHOP_STATE - PHX : LDA.l !SHOP_SRAM_INDEX : TAX : LDA.l !SHOP_STATE : STA.l !SHOP_PURCHASE_COUNTS, X : PLX + PHX : LDA.l !SHOP_SRAM_INDEX : TAX : LDA.l !SHOP_STATE : STA.l PurchaseCounts, X : PLX ++ .done PLY : PLX @@ -587,7 +587,7 @@ db #$01, #$02, #$04 ;-------------------- ;!SHOP_ID = "$7F5050" ;!SHOP_SRAM_INDEX = "$7F5062" -;!SHOP_PURCHASE_COUNTS = "$7EF302" +;PurchaseCounts = "$7EF51A" ;-------------------- Setup_ShopItemCollisionHitbox: ;The complications with XBA are to handle the fact that nintendo likes to store diff --git a/spriteswap.asm b/spriteswap.asm index ab5e82c..def5ead 100644 --- a/spriteswap.asm +++ b/spriteswap.asm @@ -39,7 +39,7 @@ SpriteSwap_Palette_ArmorAndGloves: SEP #$30 LDA !SPRITE_SWAP : BNE .continue REP #$30 - LDA $7EF354 + LDA GloveEquipment JSL $1BEE21 ; Read Original Palette Code RTL diff --git a/sram.asm b/sram.asm index d7bea70..cc30c26 100644 --- a/sram.asm +++ b/sram.asm @@ -98,48 +98,51 @@ skip 1 ; Not used SwordEquipment: skip 1 ; $01 = Fighter | $02 = Master | $03 = Tempered | $04 = Gold ShieldEquipment: skip 1 ; $01 = Fighter | $02 = Red | $03 = Mirror ArmorEquipment: skip 1 ; $00 = Green | $01 = Blue | $02 = Red -BottleContentsOne: skip 1 ; \ Bottle Contents +BottleContents: ; \ Bottle Contents +BottleContentsOne: skip 1 ; | BottleContentsTwo: skip 1 ; | $00 = No Bottle | $01 = Mushroom | $02 = Empty Bottle BottleContentsThree: skip 1 ; | $03 = Red Potion | $04 = Green Potion | $05 = Blue Potion BottleContentsFour: skip 1 ; / $06 = Fairy | $07 = Bee | $08 = Good Bee TargetRupees: skip 2 ; \ CurrentRupees will always increment or decrement to match CurrentRupees: skip 2 ; / TargetRupees if not equal (16-bit integer) ;-------------------------------------------------------------------------------- - ; Dungeon item bitfields -CompassFieldOne: skip 2 ; \ - - g r t h i s -BigKeyFieldOne: skip 2 ; | g = Ganon's Tower | r = Turtle Rock | t = Thieves' Town -MapFieldOne: skip -3 ; / h = Tower of Hera | i = Ice Palace | s = Skull Woods -CompassFieldTwo: skip 2 ; \ m d s a t e h p -BigKeyFieldTwo: skip 2 ; | m = Misery Mire | d = Palace of Darkness | s = Swamp Palace -MapFieldTwo: skip 1 ; | a = Aga Tower | t = Desert Palace | e = Eastern Palace - ; / h = Hyrule Castle | s = Sewer Passage +CompassField: skip 2 ; Dungeon item bitfields +BigKeyField: skip 2 ; Low byte: - - g r t h i s +MapField: skip 2 ; g = Ganon's Tower | r = Turtle Rock | t = Thieves' Town + ; h = Tower of Hera | i = Ice Palace | s = Skull Woods + ;------------------------------------------------ + ; High Byte: m d s a t e h p + ; m = Misery Mire | d = Palace of Darkness | s = Swamp Palace + ; a = Aga Tower | t = Desert Palace | e = Eastern Palace + ; h = Hyrule Castle | s = Sewer Passage ;-------------------------------------------------------------------------------- ; HUD & other equipment skip 1 ; Wishing Pond Rupee (Unused) -HeartPieceFraction: skip 1 ; Heart pieces of four for upgrade. Wraps around to $00 after $03. +HeartPieceQuarter: skip 1 ; Heart pieces of four for health upgrade. Wraps around to $00 after $03. HealthCapacity: skip 1 ; \ Health Capacity & Current Health CurrentHealth: skip 1 ; / Max value 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) -HeartFiller: skip 1 ; Hearts collected yet to be filled. Write in multiples of $08 +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) +PendantsField: skip 1 ; - - - - - g b r (bitfield) ; g = Green (Courage) | b = Blue (Power) | r = Red (Wisdom) -BombFiller: skip 1 ; Bombs collected yet to be filled (integer) -ArrowFiller: skip 1 ; Arrows collected yet to be filled (integer) +BombsFiller: skip 1 ; Bombs collected yet to be filled (integer) +ArrowsFiller: skip 1 ; Arrows collected yet to be filled (integer) CurrentArrows: skip 1 ; Current arrows (integer) skip 1 ; Unknown AbilityFlags: skip 1 ; - r t - p d s - (bitfield) ; r = Read | t = Talk | p = Pull | d = Dash ; s = Swim -CurrentCrystals: skip 1 ; - 3 4 2 7 5 1 6 (bitfield) +CrystalsField: skip 1 ; - 3 4 2 7 5 1 6 (bitfield) MagicConsumption: skip 1 ; $00 = Normal | $01 = Half Magic | $02 = Quarter Magic ;-------------------------------------------------------------------------------- ; Small keys earned per dungeon (integers) -SewerKeys: skip 1 ; \ Hyrule Castle and Sewer keys typically increment -HyruleCastleKeys: skip 1 ; / and decrement together +SewerKeys: skip 1 ; \ Hyrule Castle and Sewer keys typically increment +DungeonKeys: ; | and decrement together +HyruleCastleKeys: skip 1 ; / EasternKeys: skip 1 ; Eastern Palace small keys DesertKeys: skip 1 ; Desert Palace small keys CastleTowerKeys: skip 1 ; Agahnim's Tower small keys @@ -152,7 +155,8 @@ HeraKeys: skip 1 ; Tower of Hera small keys ThievesTownKeys: skip 1 ; Thieves' Town small keys TurtleRockKeys: skip 1 ; Turtle Rock small keys GanonsTowerKeys: skip 1 ; Ganon's Tower small keys -skip 2 ; Unused +skip 1 ; Unused +CurrentGenericKeys: skip 1 ; Generic small keys ;================================================================================ ; Tracking & Indicators ($7EF38C - $7EF3F0) @@ -166,9 +170,9 @@ BowTracking: skip 2 ; b s p - - - - - (bitfield) ; The front end writes two distinct progressive bow items. p ; indicates whether the "second" has been found independent of ; the first -ItemLimitCounts: skip 3 ; Keeps track of limited non-progressive items such as lamp. +ItemLimitCounts: skip 10 ; Keeps track of limited non-progressive items such as lamp. ; See: ItemSubstitutionRules in tables.asm -skip 50 ; +skip 43 ; ProgressIndicator: skip 1 ; $00 = Pre-Uncle | $01 = Post-Uncle item | $02 = Zelda Rescued ; $03 = Agahnim 1 defeated ; $04 and above don't do anything. $00-$02 used in standard mode @@ -382,28 +386,25 @@ assert BottleContentsFour = $7EF35F, "BottleContentsFour labeled at incorrec assert TargetRupees = $7EF360, "TargetRupees labeled at incorrect address" assert CurrentRupees = $7EF362, "CurrentRupees labeled at incorrect address" ;-------------------------------------------------------------------------------- -assert CompassFieldOne = $7EF364, "Compass bitfield labeled at incorrect address" -assert CompassFieldTwo = $7EF365, "Compass bitfield labeled at incorrect address" -assert BigKeyFieldOne = $7EF366, "Big Key item bitfield labeled at incorrect address" -assert BigKeyFieldTwo = $7EF367, "Big Key item bitfield labeled at incorrect address" -assert MapFieldOne = $7EF368, "Map item bitfield labeled at incorrect address" -assert MapFieldTwo = $7EF369, "Map item bitfield labeled at incorrect address" +assert CompassField = $7EF364, "Compass bitfield labeled at incorrect address" +assert BigKeyField = $7EF366, "Big Key item bitfield labeled at incorrect address" +assert MapField = $7EF368, "Map item bitfield labeled at incorrect address" ;-------------------------------------------------------------------------------- -assert HeartPieceFraction = $7EF36B, "HeartPieceFraction labeled at incorrect address" +assert HeartPieceQuarter = $7EF36B, "HeartPieceQuarter labeled at incorrect address" assert HealthCapacity = $7EF36C, "HealthCapacity labeled at incorrect address" assert CurrentHealth = $7EF36D, "CurrentHealth labeled at incorrect address" assert CurrentMagic = $7EF36E, "CurrentMagic labeled at incorrect address" assert CurrentSmallKeys = $7EF36F, "CurrentSmallKeys labeled at incorrect address" assert BombCapacityUpgrades = $7EF370, "BombCapacityUpgrades labeled at incorrect address" assert ArrowCapacityUpgrades = $7EF371, "ArrowCapacityUpgrades labeled at incorrect address" -assert HeartFiller = $7EF372, "HeartFiller labeled at incorrect address" +assert HeartsFiller = $7EF372, "HeartsFiller labeled at incorrect address" assert MagicFiller = $7EF373, "MagicFiller labeled at incorrect address" assert PendantsField = $7EF374, "PendantsField labeled at incorrect address" -assert BombFiller = $7EF375, "BombFiller labeled at incorrect address" -assert ArrowFiller = $7EF376, "ArrowFiller labeled at incorrect address" +assert BombsFiller = $7EF375, "BombsFiller labeled at incorrect address" +assert ArrowsFiller = $7EF376, "ArrowsFiller labeled at incorrect address" assert CurrentArrows = $7EF377, "CurrentArrows labeled at incorrect address" assert AbilityFlags = $7EF379, "AbilityFlags labeled at incorrect address" -assert CurrentCrystals = $7EF37A, "CurrentCrystals labeled at incorrect address" +assert CrystalsField = $7EF37A, "CrystalsField labeled at incorrect address" assert MagicConsumption = $7EF37B, "MagicConsumption labeled at incorrect address" ;-------------------------------------------------------------------------------- assert SewerKeys = $7EF37C, "SewerKeys labeled at incorrect address" @@ -420,6 +421,7 @@ assert HeraKeys = $7EF386, "HeraKeys labeled at incorrect address" assert ThievesTownKeys = $7EF387, "ThievesTownKeys labeled at incorrect address" assert TurtleRockKeys = $7EF388, "TurtleRockKeys labeled at incorrect address" assert GanonsTowerKeys = $7EF389, "GanonsTowerKeys labeled at incorrect address" +assert CurrentGenericKeys = $7EF38B, "CurrentGenericKeys labeled at incorrect address" ;-------------------------------------------------------------------------------- assert ProgressIndicator = $7EF3C5, "ProgressIndicator labeled at incorrect address" assert ProgressFlags = $7EF3C6, "ProgressFlags labeled at incorrect address" diff --git a/stats.asm b/stats.asm index 40df03a..30f6cb7 100644 --- a/stats.asm +++ b/stats.asm @@ -107,9 +107,9 @@ ;-------------------------------------------------------------------------------- ; $7EF44B - flute counter ;-------------------------------------------------------------------------------- -; $7EF44Cl[3] - RTA-Timestamp (Start) +; $7EF44Cl[3] - Unused ;-------------------------------------------------------------------------------- -; $7EF44Fl[3] - RTA-Timestamp (End) +; $7EF44Fl[3] - Unused ;-------------------------------------------------------------------------------- ; $7EF452 - sssscccc ; s - swordless bosses @@ -182,10 +182,10 @@ DungeonHoleEntranceTransition: LDA.l SilverArrowsAutoEquip : AND.b #$02 : BEQ + LDA $010E : CMP.b #$7B : BNE + ; skip unless falling to ganon's room - LDA !INVENTORY_SWAP_2 : AND.b #$40 : BEQ + ; skip if we don't have silvers - LDA $7EF340 : BEQ + ; skip if we have no bow + LDA BowTracking : AND.b #$40 : BEQ + ; skip if we don't have silvers + LDA BowEquipment : BEQ + ; skip if we have no bow CMP.b #$03 : !BGE + ; skip if the bow is already silver - !ADD #$02 : STA $7EF340 ; increase bow to silver + !ADD #$02 : STA BowEquipment ; increase bow to silver + BRA StatTransitionCounter @@ -218,7 +218,7 @@ IncrementFlute: RTL ;-------------------------------------------------------------------------------- IncrementSmallKeys: - STA $7EF36F ; thing we wrote over, write small key count + STA CurrentSmallKeys ; thing we wrote over, write small key count PHX LDA !LOCK_STATS : BNE + JSL AddInventory_incrementKeyLong @@ -230,7 +230,7 @@ IncrementSmallKeys: RTL ;-------------------------------------------------------------------------------- IncrementSmallKeysNoPrimary: - STA $7EF36F ; thing we wrote over, write small key count + STA CurrentSmallKeys ; thing we wrote over, write small key count PHX LDA !LOCK_STATS : BNE + JSL AddInventory_incrementKeyLong @@ -249,7 +249,7 @@ IncrementSmallKeysNoPrimary: RTL ;-------------------------------------------------------------------------------- DecrementSmallKeys: - STA $7EF36F ; thing we wrote over, write small key count + STA CurrentSmallKeys ; thing we wrote over, write small key count JSL.l UpdateKeys RTL ;-------------------------------------------------------------------------------- @@ -302,7 +302,7 @@ RTL IncrementDeathCounter: PHA LDA !LOCK_STATS : BNE + - LDA $7EF36D : BNE + ; link is still alive, skip + LDA CurrentHealth : BNE + ; link is still alive, skip LDA !DEATH_COUNTER : INC : STA !DEATH_COUNTER ;JSL.l DecrementSaveCounter + @@ -311,7 +311,7 @@ RTL ;-------------------------------------------------------------------------------- !FAIRY_COUNTER = "$7EF453" IncrementFairyRevivalCounter: - STA $7EF35C, X ; thing we wrote over + STA BottleContents, X ; thing we wrote over PHA LDA !LOCK_STATS : BNE + LDA !FAIRY_COUNTER : INC : STA !FAIRY_COUNTER @@ -368,7 +368,7 @@ RTL !DAMAGE_COUNTER = $7EF46A !MAGIC_COUNTER = $7EF46C IncrementDamageTakenCounter_Eight: - STA.l $7EF36D + STA.l CurrentHealth PHA : PHP LDA !LOCK_STATS : BNE + REP #$21 @@ -393,11 +393,11 @@ IncrementDamageTakenCounter_Arb: ++ STA.l !DAMAGE_COUNTER + PLP - LDA.l $7EF36D + LDA.l CurrentHealth RTL IncrementMagicUseCounter: - STA.l $7EF36E + STA.l CurrentMagic IncrementMagicUseCounterByrna: PHA : PHP @@ -421,7 +421,7 @@ IncrementMagicUseCounterOne: BEQ ++ STA.l !MAGIC_COUNTER ++ SEP #$20 -+ LDA.l $7EF36E ++ LDA.l CurrentMagic RTL ;-------------------------------------------------------------------------------- @@ -429,7 +429,7 @@ IncrementMagicUseCounterOne: IncrementOWMirror: PHA LDA !LOCK_STATS : BNE + - LDA $7EF3CA : BEQ + ; only do this for DW->LW + LDA CurrentWorld : BEQ + ; only do this for DW->LW LDA !OW_MIRROR_COUNTER : INC : STA !OW_MIRROR_COUNTER + PLA @@ -451,7 +451,7 @@ RTL !SPENT_RUPEES = "$7EF42B" IncrementSpentRupees: DEC A : BPL .subtractRupees - LDA.w #$0000 : STA $7EF360 + LDA.w #$0000 : STA $7EF RTL .subtractRupees PHA : PHP @@ -490,7 +490,6 @@ JMP StatTransitionCounter !RUPEES_COLLECTED = "$7F503C" !ITEM_TOTAL = "$7EF423" -!RTA_END = "$7EF44F" StatsFinalPrep: PHA : PHX : PHP SEP #$30 ; set 8-bit accumulator and index registers @@ -517,27 +516,11 @@ StatsFinalPrep: LDA !NMI_COUNTER+2 : SBC !LOOP_COUNTER+2 : STA !LAG_TIME+2 LDA !NMI_COUNTER+3 : SBC !LOOP_COUNTER+3 : STA !LAG_TIME+3 - LDA !SPENT_RUPEES : !ADD $7EF362 : STA !RUPEES_COLLECTED + LDA !SPENT_RUPEES : !ADD CurrentRupees : STA !RUPEES_COLLECTED LDA !SPENT_RUPEES+1 : ADC $7EF363 : STA !RUPEES_COLLECTED+1 LDA !ITEM_TOTAL : !SUB !CHEST_COUNTER : STA !NONCHEST_COUNTER - - ;LDA $FFFFFF - ;JSL.l Clock_IsSupported - ;BRA + - ; REP #$20 ; set 16-bit accumulator - ; - ; LDA $00 : PHA - ; LDA $02 : PHA - ; - ; JSL.l Clock_QuickStamp - ; LDA $00 : STA !RTA_END - ; LDA $02 : STA !RTA_END+2 - ; - ; PLA : STA $02 - ; PLA : STA $00 - ;+ - + .done PLP : PLX : PLA LDA.b #$19 : STA $10 ; thing we wrote over, load triforce room diff --git a/swordswap.asm b/swordswap.asm index 7dbd635..3a04b02 100644 --- a/swordswap.asm +++ b/swordswap.asm @@ -20,7 +20,7 @@ ;JML.l Smithy_DoesntHaveSword ;================================================================================ ;LoadSwordForDamage: -; LDA $7EF359 : CMP #$04 : BNE .done ; skip if not gold sword +; LDA SwordEquipment : CMP #$04 : BNE .done ; skip if not gold sword ; LDA $1B : BEQ + ; skip if outdoors ; LDA $A0 : CMP #41 : BNE + ; decimal 41 ; skip if not in the mothula room ; LDA #$03 ; pretend we're using tempered @@ -62,20 +62,20 @@ RTL ; $7F50C0 - Sword Modifier LoadModifiedSwordLevel: ; returns short LDA $7F50C0 : BEQ + - !ADD $7EF359 ; add normal sword value to modifier + !ADD SwordEquipment ; add normal sword value to modifier BNE ++ : LDA.b #$01 : RTS : ++ CMP.b #$05 : !BLT ++ : LDA.b #$04 : RTS : ++ RTS + - LDA $7EF359 ; load normal sword value + LDA SwordEquipment ; load normal sword value RTS ;================================================================================ -; $7EF35B - Armor Inventory +; ArmorEquipment - Armor Inventory ; $7F50C2 - Armor Modifier ; $7F5020 - Scratch Space (Caller Preserved) LoadModifiedArmorLevel: PHA - LDA $7EF35B : !ADD $7F50C2 + LDA ArmorEquipment : !ADD $7F50C2 CMP.b #$FF : BNE + : LDA.b #$00 : + CMP.b #$03 : !BLT + : LDA.b #$02 : + STA $7F5020 @@ -83,16 +83,16 @@ LoadModifiedArmorLevel: !ADD $7F5020 RTL ;================================================================================ -; $7EF37B - Magic Inventory +; MagicConsumption - Magic Inventory ; $7F50C3 - Magic Modifier LoadModifiedMagicLevel: LDA $7F50C3 : BEQ + - !ADD $7EF37B ; add normal magic value to modifier + !ADD MagicConsumption ; add normal magic value to modifier CMP.b #$FF : BNE ++ : LDA.b #$00 : RTL : ++ CMP.b #$03 : !BLT ++ : LDA.b #$02 : ++ RTL + - LDA $7EF37B ; load normal magic value + LDA MagicConsumption ; load normal magic value RTL ;================================================================================ ; $7E0348 - Ice Value @@ -116,17 +116,17 @@ RTL ;================================================================================ CheckTabletSword: LDA.l AllowHammerTablets : BEQ + - LDA $7EF34B : BEQ + ; check for hammer + LDA HammerEquipment : BEQ + ; check for hammer LDA.b #$02 : RTL + - LDA $7EF359 ; get actual sword value + LDA SwordEquipment ; get actual sword value RTL ;================================================================================ GetSwordLevelForEvilBarrier: LDA.l AllowHammerEvilBarrierWithFighterSword : BEQ + LDA #$FF : RTL + - LDA $7EF359 + LDA SwordEquipment RTL ;================================================================================ CheckGanonHammerDamage: @@ -143,7 +143,7 @@ GetSmithSword: JML.l Smithy_DoesntHaveSword ; Classic Smithy + - REP #$20 : LDA $7EF360 : CMP #$000A : SEP #$20 : !BGE .buy + REP #$20 : LDA TargetRupees : CMP #$000A : SEP #$20 : !BGE .buy .cant_afford REP #$10 LDA.b #$7A @@ -158,7 +158,7 @@ GetSmithSword: STZ $02E9 ; Item from NPC PHX : JSL Link_ReceiveItem : PLX - REP #$20 : LDA $7EF360 : !SUB.w #$000A : STA $7EF360 : SEP #$20 ; Take 10 rupees + REP #$20 : LDA TargetRupees : !SUB.w #$000A : STA TargetRupees : SEP #$20 ; Take 10 rupees JSL ItemSet_SmithSword .done @@ -170,7 +170,7 @@ CheckMedallionSword: LDA.b #$02 ; Pretend we have master sword RTL .check_sword - LDA $7EF359 + LDA SwordEquipment RTL .check_pad PHB : PHX : PHY @@ -220,7 +220,7 @@ CheckMedallionSword: + .done PLY : PLX : PLB - LDA $7EF359 + LDA SwordEquipment RTL .permit SEP #$20 ; set 8-bit accumulator diff --git a/timer.asm b/timer.asm index 34eb56c..bff9bb2 100644 --- a/timer.asm +++ b/timer.asm @@ -182,8 +182,8 @@ OHKOTimer: LDA.l TimeoutBehavior : CMP #$02 : BNE + LDA !Status : AND.b #$02 : BEQ + .kill - LDA.b #$00 : STA $7EF36D ; kill link + LDA.b #$00 : STA CurrentHealth ; kill link + - LDA $7EF36D + LDA CurrentHealth RTL ;-------------------------------------------------------------------------------- diff --git a/treekid.asm b/treekid.asm index 07e853e..4b9f8bc 100644 --- a/treekid.asm +++ b/treekid.asm @@ -1,9 +1,9 @@ ;================================================================================ ; Tree Kid Fix ;-------------------------------------------------------------------------------- -org $06B12B ; <- 3312B - tree status set - 418 - LDA $7EF3C9 : ORA.b #$08 : STA $7EF3C9 -LDA $7EF3C9 : AND.b #$F7 : STA $7EF3C9 ; unset arboration instead of setting it +org $06B12B ; <- 3312B - tree status set - 418 - LDA NpcFlagsVanilla : ORA.b #$08 : STA NpcFlagsVanilla +LDA NpcFlagsVanilla : AND.b #$F7 : STA NpcFlagsVanilla ; unset arboration instead of setting it ;-------------------------------------------------------------------------------- org $06B072 ; <- 33072 - FluteAardvark_InitialStateFromFluteState - 418 : dw FluteAardvark_AlreadyArborated db #$8B -;================================================================================ \ No newline at end of file +;================================================================================ diff --git a/utilities.asm b/utilities.asm index 209cf58..abadf53 100644 --- a/utilities.asm +++ b/utilities.asm @@ -45,7 +45,7 @@ GetSpriteID: RTL .specialHandling CMP.b #$F9 : BNE ++ ; Progressive Magic - LDA.l $7EF37B : BNE +++ + LDA.l MagicConsumption : BNE +++ LDA.b #$3B : RTL ; Half Magic +++ LDA.b #$3C : RTL ; Quarter Magic @@ -54,13 +54,13 @@ RTL ++ CMP.b #$FB : BNE ++ ; RNG Item (Multi) JSL.l GetRNGItemMulti : JMP GetSpriteID ++ CMP.b #$FD : BNE ++ ; Progressive Armor - LDA $7EF35B : CMP.l ProgressiveArmorLimit : !BLT + ; Progressive Armor Limit + LDA ArmorEquipment : CMP.l ProgressiveArmorLimit : !BLT + ; Progressive Armor Limit LDA.l ProgressiveArmorReplacement JMP GetSpriteID + LDA.b #$04 : RTL ++ CMP.b #$FE : BNE ++ ; Progressive Sword - LDA $7EF359 + LDA SwordEquipment CMP.l ProgressiveSwordLimit : !BLT + ; Progressive Sword Limit LDA.l ProgressiveSwordReplacement JMP GetSpriteID @@ -85,7 +85,7 @@ RTL + ; Everything Else LDA.b #$2E : RTL ++ : CMP.b #$F8 : BNE ++ ; Progressive Bow - LDA $7EF340 : INC : LSR + LDA BowEquipment : INC : LSR CMP.l ProgressiveBowLimit : !BLT + LDA.l ProgressiveBowReplacement JMP GetSpriteID @@ -183,7 +183,7 @@ GetSpritePalette: RTL .specialHandling CMP.b #$FD : BNE ++ ; Progressive Sword - LDA $7EF359 + LDA SwordEquipment CMP.l ProgressiveSwordLimit : !BLT + ; Progressive Sword Limit LDA.l ProgressiveSwordReplacement JMP GetSpritePalette @@ -207,7 +207,7 @@ RTL + ; Everything Else LDA.b #$08 : RTL ++ : CMP.b #$FF : BNE ++ ; Progressive Armor - LDA $7EF35B : CMP.l ProgressiveArmorLimit : !BLT + ; Progressive Armor Limit + LDA ArmorEquipment : CMP.l ProgressiveArmorLimit : !BLT + ; Progressive Armor Limit LDA.l ProgressiveArmorReplacement JMP GetSpritePalette + : CMP.b #$00 : BNE + ; Green Tunic @@ -215,12 +215,12 @@ RTL + ; Everything Else LDA.b #$02 : RTL ++ : CMP.b #$FC : BNE ++ ; Progressive Gloves - LDA $7EF354 : BNE + ; No Gloves + LDA GloveEquipment : BNE + ; No Gloves LDA.b #$02 : RTL + ; Everything Else LDA.b #$08 : RTL ++ : CMP.b #$F8 : BNE ++ ; Progressive Bow - LDA $7EF340 : INC : LSR + LDA BowEquipment : INC : LSR CMP.l ProgressiveBowLimit : !BLT + LDA.l ProgressiveBowReplacement JMP GetSpritePalette @@ -307,7 +307,7 @@ IsNarrowSprite: + : JMP .continue .notBottle CMP.b #$5E : BNE ++ ; Progressive Sword - LDA $7EF359 : CMP.l ProgressiveSwordLimit : !BLT + ; Progressive Sword Limit + LDA SwordEquipment : CMP.l ProgressiveSwordLimit : !BLT + ; Progressive Sword Limit LDA.l ProgressiveSwordReplacement JSL.l IsNarrowSprite JMP .done @@ -319,7 +319,7 @@ IsNarrowSprite: JSL.l IsNarrowSprite JMP .done ++ CMP.b #$60 : BNE ++ ; Progressive Armor - LDA $7EF35B : CMP.l ProgressiveArmorLimit : !BLT .continue + LDA ArmorEquipment : CMP.l ProgressiveArmorLimit : !BLT .continue LDA.l ProgressiveArmorReplacement JSL.l IsNarrowSprite JMP .done @@ -330,7 +330,7 @@ IsNarrowSprite: JSL.l GetRNGItemMulti ++ CMP.b #$64 : BEQ + ; Progressive Bow CMP.b #$65 : BNE .continue ; Progressive Bow (alt) - + : LDA $7EF340 : INC : LSR + + : LDA BowEquipment : INC : LSR CMP.l ProgressiveBowLimit : !BLT + LDA.l ProgressiveBowReplacement JSL.l IsNarrowSprite diff --git a/zelda.asm b/zelda.asm index 358d7e8..1a11cc1 100644 --- a/zelda.asm +++ b/zelda.asm @@ -2,16 +2,16 @@ ; Spawn Zelda (or not) ;-------------------------------------------------------------------------------- SpawnZelda: - LDA.l $7EF3CC : CMP #$08 : BEQ + ; don't spawn if dwarf is present + 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 CLC + RTL ;-------------------------------------------------------------------------------- EndRainState: - LDA $7EF3C5 : CMP.b #$02 : !BGE + ; skip if past escape already + 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 $7EF3C5 ; end rain state + LDA.b #$02 : STA ProgressIndicator ; end rain state JSL MaybeSetPostAgaWorldState + RTL From 2e97329250cf2a61c21184bd8b85daed74e5e307 Mon Sep 17 00:00:00 2001 From: cassidy Date: Thu, 2 Dec 2021 01:37:27 -0500 Subject: [PATCH 04/96] Refactor inventory code and add more labels Refactored highest sword, shield, and mail counting Refactored how heart pieces, heart containers, and crystals are counted Moved quickswap lock bit to high byte of InventoryTracking Fixed sword and shield item downgrade Added PreFluteLocations counter --- goalitem.asm | 4 +- inventory.asm | 261 +++++++++++++++++++++++----------------------- itemdowngrade.asm | 36 ++++--- newitems.asm | 21 ++-- quickswap.asm | 10 +- sram.asm | 31 ++++-- utilities.asm | 26 ++--- 7 files changed, 205 insertions(+), 184 deletions(-) diff --git a/goalitem.asm b/goalitem.asm index 9c7e900..474e86e 100644 --- a/goalitem.asm +++ b/goalitem.asm @@ -125,12 +125,12 @@ GetRequiredCrystalsInX: RTL ;-------------------------------------------------------------------------------- CheckEnoughCrystalsForGanon: - LDA CrystalsField : JSL CountBits ; the comparison is against 1 less + LDA CrystalCounter CMP.l NumberOfCrystalsRequiredForGanon RTL ;-------------------------------------------------------------------------------- CheckEnoughCrystalsForTower: - LDA CrystalsField : JSL CountBits ; the comparison is against 1 less + LDA CrystalCounter CMP.l NumberOfCrystalsRequiredForTower RTL diff --git a/inventory.asm b/inventory.asm index 08944f7..322f0a4 100644 --- a/inventory.asm +++ b/inventory.asm @@ -1,19 +1,19 @@ ;================================================================================ ; Inventory Updates ;================================================================================ -!INVENTORY_SWAP = "$7EF38C" ; Item Tracking Slot -; brmpnskf -; b = blue boomerang -; r = red boomerang -; m = mushroom current -; p = magic powder -; n = mushroom past -; s = shovel -; k = fake flute -; f = working flute +; InventoryTracking +; brmpnskf -------q +; b = blue boomerang | +; r = red boomerang | +; m = mushroom current | +; p = magic powder | +; n = mushroom past | +; s = shovel | +; k = fake flute | +; f = working flute | ;-------------------------------------------------------------------------------- -!INVENTORY_SWAP_2 = "$7EF38E" +; BowTracking ; Item Tracking Slot #2 ; bsp----- ; b = bow @@ -23,13 +23,13 @@ ; - ; - ; - -; q = quickswap lock +; - ;-------------------------------------------------------------------------------- ; ProcessMenuButtons: ; out: Carry - 0 = No Button, 1 = Yes Button ;-------------------------------------------------------------------------------- ProcessMenuButtons: - ;LDA #$FD : STA !INVENTORY_SWAP ; DEBUG MODE + ;LDA #$FD : STA InventoryTracking ; DEBUG MODE ;LDA $F6 : BIT #$20 : BNE .l_pressed ; check for P1 L-button LDA $F4 : BIT #$40 : BNE .y_pressed ; check for P1 Y-button BIT #$20 : BNE .sel_pressed ; check for P1 Select button @@ -57,12 +57,12 @@ RTL LDA.b #$10 : STA $0207 LDA $0202 ; check selected item CMP #$02 : BNE + ; boomerang - LDA !INVENTORY_SWAP : AND #$C0 : CMP #$C0 : BNE .errorJump ; make sure we have both boomerangs - LDA $7EF341 : EOR #$03 : STA $7EF341 ; swap blue & red boomerang + LDA InventoryTracking : AND #$C0 : CMP #$C0 : BNE .errorJump ; make sure we have both boomerangs + LDA BoomerangEquipment : EOR #$03 : STA BoomerangEquipment ; swap blue & red boomerang LDA.b #$20 : STA $012F ; menu select sound JMP .captured + CMP #$01 : BNE + ; bow - LDA !INVENTORY_SWAP_2 : AND #$C0 : CMP #$C0 : BNE .errorJump ; make sure we have both bows + LDA BowTracking : AND #$C0 : CMP #$C0 : BNE .errorJump ; make sure we have both bows PHX : LDX.b #$00 ; scan ancilla table for arrows -- : CPX.b #$0A : !BGE ++ LDA $0C4A, X : CMP.b #$09 : BNE +++ @@ -72,18 +72,18 @@ RTL PLX LDA.l SilverArrowsUseRestriction : BEQ ++ LDA $A0 : ORA $A1 : BEQ ++ ; not in ganon's room in restricted mode - LDA $7EF340 : CMP.b #$03 : !BLT .errorJump : !SUB #$02 : STA $7EF340 + LDA BowEquipment : CMP.b #$03 : !BLT .errorJump : !SUB #$02 : STA BowEquipment BRA .errorJump2 ++ - LDA $7EF340 : !SUB #$01 : EOR #$02 : !ADD #$01 : STA $7EF340 ; swap bows + LDA BowEquipment : !SUB #$01 : EOR #$02 : !ADD #$01 : STA BowEquipment ; swap bows LDA.b #$20 : STA $012F ; menu select sound JMP .captured + BRA + .errorJump BRA .errorJump2 + CMP #$05 : BNE + ; powder - LDA !INVENTORY_SWAP : AND #$30 : CMP #$30 : BNE .errorJump ; make sure we have mushroom & magic powder - LDA $7EF344 : EOR #$03 : STA $7EF344 ; swap mushroom & magic powder + LDA InventoryTracking : AND #$30 : CMP #$30 : BNE .errorJump ; make sure we have mushroom & magic powder + LDA PowderEquipment : EOR #$03 : STA PowderEquipment ; swap mushroom & magic powder LDA.b #$20 : STA $012F ; menu select sound JMP .captured + BRA + @@ -91,11 +91,11 @@ RTL BRA .error + CMP #$0D : BNE + ; flute LDA $037A : CMP #$01 : BEQ .midShovel ; inside a shovel animation, force the shovel & make error sound - LDA !INVENTORY_SWAP : BIT #$04 : BEQ .error ; make sure we have shovel + LDA InventoryTracking : BIT #$04 : BEQ .error ; make sure we have shovel AND #$03 : BEQ .error ; make sure we have one of the flutes - LDA $7EF34C : CMP #01 : BNE .toShovel ; not shovel + LDA FluteEquipment : CMP #01 : BNE .toShovel ; not shovel - LDA !INVENTORY_SWAP : AND #$01 : BEQ .toFakeFlute ; check for real flute + LDA InventoryTracking : AND #$01 : BEQ .toFakeFlute ; check for real flute LDA #$03 ; set real flute BRA .fluteSuccess .toFakeFlute @@ -104,7 +104,7 @@ RTL .toShovel LDA #$01 ; set shovel .fluteSuccess - STA $7EF34C ; store set item + STA FluteEquipment ; store set item LDA.b #$20 : STA $012F ; menu select sound BRA .captured + @@ -112,7 +112,7 @@ RTL CLC RTL .midShovel - ; LDA #$01 : STA $7EF34C ; set shovel + ; LDA #$01 : STA FluteEquipment ; set shovel .error LDA.b #$3C : STA $012E ; error sound .captured @@ -127,13 +127,13 @@ ProcessBottleMenu: ; LDA $F6 : AND #$30 : CMP.b #$30 : BEQ .double_shoulder_pressed ; LDA $F4 : AND #$40 : BEQ .y_not_pressed ; skip if Y is not down ; .double_shoulder_pressed - LDA $7EF34F ; check bottle state + LDA BottleIndex ; check bottle state BEQ .no_bottles ; skip if we have no bottles PHX INC : CMP #$05 : !BLT + : LDA #$01 : + ;increment and wrap 1-4 - TAX : LDA $7EF35C-1, X ; check bottle + TAX : LDA BottleContents-1, X ; check bottle BNE + : LDX #$01 : + ; wrap if we reached the last bottle - TXA : STA $7EF34F ; set bottle index + TXA : STA BottleIndex ; set bottle index LDA.b #$20 : STA $012F ; menu select sound PLX .no_bottles @@ -204,47 +204,47 @@ FullInventoryExternal: AddInventory: PHA : PHX : PHP CPY.b #$0C : BNE + ; Blue Boomerang - LDA !INVENTORY_SWAP : ORA #$80 : STA !INVENTORY_SWAP + LDA InventoryTracking : ORA #$80 : STA InventoryTracking JMP .incrementCounts + CPY.b #$2A : BNE + ; Red Boomerang - LDA !INVENTORY_SWAP : ORA #$40 : STA !INVENTORY_SWAP + LDA InventoryTracking : ORA #$40 : STA InventoryTracking JMP .incrementCounts + CPY.b #$29 : BNE + ; Mushroom - LDA !INVENTORY_SWAP : ORA #$28 : STA !INVENTORY_SWAP + LDA InventoryTracking : ORA #$28 : STA InventoryTracking JMP .incrementCounts + CPY.b #$0D : BNE + ; Magic Powder - LDA !INVENTORY_SWAP : ORA #$10 : STA !INVENTORY_SWAP + LDA InventoryTracking : ORA #$10 : STA InventoryTracking JMP .incrementCounts + CPY.b #$13 : BNE + ; Shovel - LDA !INVENTORY_SWAP : ORA #$04 : STA !INVENTORY_SWAP + LDA InventoryTracking : ORA #$04 : STA InventoryTracking JMP .incrementCounts + CPY.b #$14 : BNE + ; Flute (Inactive) - LDA !INVENTORY_SWAP : ORA #$02 : STA !INVENTORY_SWAP + LDA InventoryTracking : ORA #$02 : STA InventoryTracking JMP .incrementCounts + CPY.b #$4A : BNE + ; Flute (Active) - LDA !INVENTORY_SWAP : ORA #$01 : STA !INVENTORY_SWAP + LDA InventoryTracking : ORA #$01 : STA InventoryTracking JMP .incrementCounts + CPY.b #$0B : BNE + ; Bow LDA ArrowMode : BNE +++ - LDA !INVENTORY_SWAP_2 : ORA #$80 : STA !INVENTORY_SWAP_2 + LDA BowTracking : ORA #$80 : STA BowTracking +++ JMP .incrementCounts + CPY.b #$3A : BNE + ; Bow & Arrows - LDA !INVENTORY_SWAP_2 : ORA #$80 : STA !INVENTORY_SWAP_2 + LDA BowTracking : ORA #$80 : STA BowTracking JMP .incrementCounts + CPY.b #$3B : BNE + ; Bow & Silver Arrows - LDA !INVENTORY_SWAP_2 : ORA #$40 : STA !INVENTORY_SWAP_2 + LDA BowTracking : ORA #$40 : STA BowTracking LDA ArrowMode : BNE +++ - LDA !INVENTORY_SWAP_2 : ORA #$80 : STA !INVENTORY_SWAP_2 ; activate wood arrows when not in rupee bow + LDA BowTracking : ORA #$80 : STA BowTracking ; activate wood arrows when not in rupee bow +++ JMP .incrementCounts + CPY.b #$43 : BNE + ; Single arrow LDA ArrowMode : BEQ +++ - LDA !INVENTORY_SWAP_2 : ORA #$80 : STA !INVENTORY_SWAP_2 ; activate wood arrows in quick-swap + LDA BowTracking : ORA #$80 : STA BowTracking ; activate wood arrows in quick-swap +++ JMP .incrementCounts + CPY.b #$58 : BNE + ; Upgrade-Only Silver Arrows - LDA !INVENTORY_SWAP_2 : ORA #$40 : STA !INVENTORY_SWAP_2 + LDA BowTracking : ORA #$40 : STA BowTracking + .incrementCounts @@ -259,7 +259,6 @@ AddInventory: CPY.b #$37 : BNE + : JMP .itemCounts : + ; Pendant CPY.b #$38 : BNE + : JMP .itemCounts : + ; Pendant CPY.b #$39 : BNE + : JMP .itemCounts : + ; Pendant - CPY.b #$00 : BNE + : JMP .itemCounts : + ; Uncle Sword & Shield CPY.b #$04 : !BLT .isSword ; Swords - Skip Shop/Fairy Check for Swords CPY.b #$49 : BEQ .isSword @@ -353,7 +352,7 @@ AddInventory: JMP .fullItemCounts + CMP.b #$1A : BNE + ; Ganon's Tower LDA $7EF436 : !ADD #$08 : STA $7EF436 - LDA $7EF366 : AND #$04 : BNE ++ + LDA BigKeyField : AND #$04 : BNE ++ JSR .incrementGTowerPreBigKey ++ ;JMP .fullItemCounts @@ -362,16 +361,20 @@ AddInventory: ; == END INDOOR-ONLY SECTION .fullItemCounts - CPY.b #$3B : BNE + ; Skip Total Counts for Repeat Silver Arrows - LDA $7EF42A : BIT #$20 : BEQ + : BRA .itemCounts + ;CPY.b #$3B : BNE + ; Skip Total Counts for Repeat Silver Arrows + ; LDA $7EF42A : BIT #$20 : BEQ + : BRA .itemCounts + ;+ + + LDA BootsEquipment : BNE + ; Check for Boots + LDA PreBootsLocations : INC : STA PreBootsLocations ; Increment Pre Boots Counter + - LDA $7EF355 : BNE + ; Check for Boots - LDA $7EF432 : INC : STA $7EF432 ; Increment Pre Boots Counter + LDA MirrorEquipment : BNE + ; Check for Mirror + LDA PreMirrorLocations : INC : STA PreMirrorLocations ; Increment Pre Mirror Counter + - LDA $7EF353 : BNE + ; Check for Mirror - LDA $7EF433 : INC : STA $7EF433 ; Increment Pre Mirror Counter + LDA FluteEquipment : BNE + ; Check for Flute + LDA PreFluteLocations : INC : STA PreFluteLocations ; Increment Pre Mirror Counter + LDA $7EF423 : INC : STA $7EF423 ; Increment Item Total @@ -379,25 +382,32 @@ AddInventory: .itemCounts CPY.b #$00 : BNE + ; Fighter's Sword & Fighter's Shield + LDX #$01 JSR .incrementSword JSR .incrementShield JMP .done + CPY.b #$01 : BNE + ; Master Sword + LDX #$02 JSR .incrementSword JMP .done + CPY.b #$02 : BNE + ; Tempered Sword + LDX #$03 JSR .incrementSword 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 JMP .done + CPY.b #$07 : !BLT + ; Items $07 - $0D @@ -436,10 +446,12 @@ AddInventory: + CPY.b #$21 : BNE + ; Bug Net JSR .incrementY JMP .done - + CPY.b #$22 : !BLT + ; Items $22 - $23 - CPY.b #$24 : !BGE + - JSR .incrementMail - JMP .done + + CPY.b #$22 : BNE + ; Blue Mail + LDX #$01 + JSR .incrementMail + + CPY.b #$23 : BNE + ; Red Mail + LDX #$02 + JSR .incrementMail + CPY.b #$24 : BNE + ; Small Key JSR .incrementKey JMP .done @@ -450,10 +462,10 @@ AddInventory: ;JSR .incrementHeartContainer JMP .done + CPY.b #$27 : BNE + ; 1 Bomb - JSR .maybeIncrementBombs + ;JSR .maybeIncrementBombs JMP .done + CPY.b #$28 : BNE + ; 3 Bombs - JSR .maybeIncrementBombs + ;JSR .maybeIncrementBombs JMP .done + CPY.b #$29 : BNE + ; Musoroom JSR .incrementY @@ -463,7 +475,7 @@ AddInventory: JSR .incrementY JMP .done + CPY.b #$31 : BNE + ; 10 Bombs - JSR .maybeIncrementBombs + ;JSR .maybeIncrementBombs JMP .done + CPY.b #$32 : BNE + ; Big Key JSR .incrementBigKey @@ -493,6 +505,7 @@ AddInventory: JSR .incrementY JMP .done + CPY.b #$49 : BNE + ; Fighter's Sword + LDX #$01 JSR .incrementSword JMP .done + CPY.b #$4A : BNE + ; Flute (Active) @@ -505,29 +518,33 @@ AddInventory: JMP .done + CPY.b #$4C : BNE + ; Bomb Capacity Upgrade JSR .incrementCapacity - JSR .maybeIncrementBombs + ;JSR .maybeIncrementBombs JMP .done + CPY.b #$4D : !BLT + ; Items $4D - $4F - Capacity Upgrades CPY.b #$50 : !BGE + JSR .incrementCapacity JMP .done + CPY.b #$50 : BNE + ; Master Sword (Safe) + LDX #$02 JSR .incrementSword JMP .done + CPY.b #$51 : !BLT + ; Items $51 - $54 - Capacity Upgrades CPY.b #$55 : !BGE + JSR .incrementCapacity JMP .done - + CPY.b #$58 : BNE + ; Upgrade-Only Sivler Arrows + + CPY.b #$58 : BNE + ; Upgrade-Only Silver Arrows JSR .incrementBow JMP .done + CPY.b #$5E : BNE + ; Progressive Sword + LDA SwordEquipment : TAX JSR .incrementSword JMP .done + CPY.b #$5F : BNE + ; Progressive Shield + LDA ShieldEquipment : TAX JSR .incrementShield JMP .done + CPY.b #$60 : BNE + ; Progressive Armor + LDA ArmorEquipment : TAX JSR .incrementMail JMP .done + CPY.b #$61 : BNE + ; Progressive Lifting Glove @@ -608,72 +625,58 @@ RTS RTS .incrementSword - ; CHECK FOR DUPLICATE SWORDS JSR .stampSword - TYA ; load sword item - CMP.b #$50 : BNE + : LDA.b #$01 : + ; convert extra master sword to normal one - CMP.b #$49 : BNE + : LDA.b #$00 : + ; convert extra fighter sword to normal one - INC : CMP !HIGHEST_SWORD_LEVEL : !BLT + ; skip if highest is higher - PHA - LDA !HIGHEST_SWORD_LEVEL : AND #$F8 : ORA 1,s : STA !HIGHEST_SWORD_LEVEL - PLA - + - - LDA $7EF422 : !ADD #$20 : STA $7EF422 ; increment sword counter + LDA HighestSword + INC : STA $04 : CPX $04 : !BLT + ; don't increment unless we're getting a better sword + TXA : STA HighestSword + + RTS .incrementShield - ; CHECK FOR DUPLICATE SHIELDS - LDA $7EF422 : !ADD #$08 : AND #$18 : TAX - LDA $7EF422 : AND #$E7 : STA $7EF422 - TXA : ORA $7EF422 : STA $7EF422 + LDA HighestShield + INC : STA $04 : CPX $04 : !BLT + ; don't increment unless we're getting a better shield + TXA : STA HighestShield + + RTS .incrementBow - CPY.b #$3B : BNE ++ - LDA $7EF42A : BIT #$20 : BEQ + : RTS : + - ORA #$20 : STA $7EF42A - ++ + LDA BowEquipment : BNE .dontCount ; Don't increment Y item count for extra bows .incrementY - LDA $7EF421 : !ADD #$08 : STA $7EF421 + LDA YAItemCounter : !ADD #$08 : STA YAItemCounter +.dontCount RTS .incrementA - LDA $7EF421 : INC : AND #$07 : TAX - LDA $7EF421 : AND #$F8 : STA $7EF421 - TXA : ORA $7EF421 : STA $7EF421 + LDA YAItemCounter : INC : AND #$07 : TAX + LDA YAItemCounter : AND #$F8 : STA YAItemCounter + TXA : ORA YAItemCounter : STA YAItemCounter RTS .incrementPendant - LDA $7EF429 : INC : AND #$03 : TAX - LDA $7EF429 : AND #$FC : STA $7EF429 - TXA : ORA $7EF429 : STA $7EF429 - ; JSR .incrementBossSword + LDA PendantCounter : INC : STA PendantCounter RTS .incrementCapacity - %BottomHalf($7EF452) + LDA CapacityUpgrades : INC : STA CapacityUpgrades RTS .incrementHeartPiece - LDA $7EF448 : INC : AND #$1F : TAX - LDA $7EF448 : AND #$E0 : STA $7EF448 - TXA : ORA $7EF448 : STA $7EF448 + LDA HeartPieceCounter : INC : STA HeartPieceCounter RTS .incrementHeartContainer - %TopHalf($7EF429) + LDA HeartContainerCounter : INC : STA HeartContainerCounter RTS .incrementCrystal - LDA $7EF422 : INC : AND #$07 : TAX - LDA $7EF422 : AND #$F8 : STA $7EF422 - TXA : ORA $7EF422 : STA $7EF422 - ; JSR .incrementBossSword + LDA CrystalCounter : INC : STA CrystalCounter RTS .incrementMail - LDA $7EF424 : !ADD #$40 : STA $7EF424 + LDA HighestMail + INC : STA $04 : CPX $04 : !BLT + ; don't increment unless we're getting a better mail + TXA : STA HighestMail + + RTS .incrementKeyLong @@ -702,12 +705,12 @@ RTS TXA : ORA $7EF42A : STA $7EF42A RTS -.maybeIncrementBombs - LDA $7EF42A : AND #$80 : BNE + - LDA $7EF42A : ORA #$80 : STA $7EF42A - JSR .incrementY - + -RTS +;.maybeIncrementBombs +; LDA $7EF42A : AND #$80 : BNE + +; LDA $7EF42A : ORA #$80 : STA $7EF42A +; JSR .incrementY +; + +;RTS .incrementMap LDA $7EF428 : !ADD #$10 : STA $7EF428 @@ -718,7 +721,7 @@ RTS RTL .incrementBossSword - LDA $7EF359 + LDA SwordEquipment BNE + : - %TopHalf($7EF452) : RTS + CMP #$FF : BEQ - @@ -738,11 +741,11 @@ RTS ; Link_ReceiveItem_HUDRefresh: ;-------------------------------------------------------------------------------- Link_ReceiveItem_HUDRefresh: - LDA $7EF343 : BNE + ; skip if we have bombs - LDA $7EF370 : !ADD.l StartingMaxBombs : BEQ + ; skip if we can't have bombs - LDA $7EF375 : BEQ + ; skip if we are filling no bombs - DEC : STA $7EF375 ; decrease bomb fill count - LDA.b #$01 : STA $7EF343 ; increase actual bomb count + LDA BombsEquipment : BNE + ; skip if we have bombs + LDA BombCapacityUpgrades : !ADD.l StartingMaxBombs : 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 + JSL.l HUD_RefreshIconLong ; thing we wrote over @@ -754,9 +757,9 @@ RTL ; HandleBombAbsorbtion: ;-------------------------------------------------------------------------------- HandleBombAbsorbtion: - STA $7EF375 ; thing we wrote over + STA BombsFiller ; thing we wrote over LDA $0303 : BNE + ; skip if we already have some item selected - LDA $7EF370 : !ADD.l StartingMaxBombs : BEQ + ; skip if we can't have bombs + LDA BombCapacityUpgrades : !ADD.l StartingMaxBombs : 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 @@ -771,13 +774,13 @@ RTL AddYMarker: LDA $0202 : AND.w #$FF ; load item value CMP.w #$02 : BNE + ; boomerang - LDA !INVENTORY_SWAP : AND.w #$C0 : CMP.w #$C0 : BEQ .drawYBubble : BRA .drawNormal + LDA InventoryTracking : AND.w #$C0 : CMP.w #$C0 : BEQ .drawYBubble : BRA .drawNormal + CMP.w #$01 : BNE + ; bow - LDA !INVENTORY_SWAP_2 : AND.w #$C0 : CMP.w #$C0 : BEQ .drawYBubble : BRA .drawNormal + LDA BowTracking : AND.w #$C0 : CMP.w #$C0 : BEQ .drawYBubble : BRA .drawNormal + CMP.w #$05 : BNE + ; powder - LDA !INVENTORY_SWAP : AND.w #$30 : CMP.w #$30 : BEQ .drawYBubble : BRA .drawNormal + LDA InventoryTracking : AND.w #$30 : CMP.w #$30 : BEQ .drawYBubble : BRA .drawNormal + CMP.w #$0D : BNE + ; flute - LDA !INVENTORY_SWAP : BIT.w #$04 : BEQ .drawNormal ; make sure we have shovel + LDA InventoryTracking : BIT.w #$04 : BEQ .drawNormal ; make sure we have shovel AND.w #$03 : BNE .drawYBubble ; make sure we have one of the flutes BRA .drawNormal + CMP.w #$10 : BEQ .drawJarMarker @@ -831,8 +834,8 @@ RTS ; UpgradeFlute: ;-------------------------------------------------------------------------------- UpgradeFlute: - LDA !INVENTORY_SWAP : AND #$FC : ORA #$01 : STA !INVENTORY_SWAP ; switch to the working flute - LDA.b #$03 : STA $7EF34C ; upgrade primary inventory + LDA InventoryTracking : AND #$FC : ORA #$01 : STA InventoryTracking ; switch to the working flute + LDA.b #$03 : STA FluteEquipment ; upgrade primary inventory RTL ;-------------------------------------------------------------------------------- @@ -859,10 +862,10 @@ RTL ;-------------------------------------------------------------------------------- LoadKeys: LDA.l GenericKeys : BEQ + - LDA $7EF38B + LDA CurrentGenericKeys RTL + - LDA $7EF37C, X + LDA SewerKeys, X RTL ;-------------------------------------------------------------------------------- @@ -872,10 +875,10 @@ RTL SaveKeys: PHA LDA.l GenericKeys : BEQ + - PLA : STA $7EF38B + PLA : STA CurrentGenericKeys RTL + - PLA : STA $7EF37C, X + PLA : STA SewerKeys, X RTL ;-------------------------------------------------------------------------------- @@ -889,10 +892,10 @@ ClearOWKeys: JSL.l FakeWorldFix JSR.w FixBunnyOnExitToLightWorld LDA.l GenericKeys : BEQ + - PLA : LDA $7EF38B : STA $7EF36F + PLA : LDA CurrentGenericKeys : STA CurrentSmallKeys RTL + - PLA : STA $7EF36F + PLA : STA CurrentSmallKeys RTL ;-------------------------------------------------------------------------------- @@ -955,10 +958,10 @@ RTL ; InitializeBottles: ;-------------------------------------------------------------------------------- InitializeBottles: - STA $7EF35C, X ; thing we wrote over + STA BottleContents, X ; thing we wrote over PHA - LDA $7EF34F : BNE + - TXA : INC : STA $7EF34F ; write bottle index to menu properly + LDA BottleIndex : BNE + + TXA : INC : STA BottleIndex ; write bottle index to menu properly + PLA RTL @@ -1047,12 +1050,12 @@ RTL ; RemoveMushroom: ;-------------------------------------------------------------------------------- RemoveMushroom: - LDA !INVENTORY_SWAP : AND #$DF : STA !INVENTORY_SWAP ; remove the mushroom + LDA InventoryTracking : AND #$DF : STA InventoryTracking ; remove the mushroom AND #$10 : BEQ .empty ; check if we have powder - LDA.b #$02 : STA $7EF344 ; give powder if we have it + LDA.b #$02 : STA PowderEquipment ; give powder if we have it RTL .empty - LDA.b #$00 : STA $7EF344 ; clear the inventory slot if we don't have powder + LDA.b #$00 : STA PowderEquipment ; clear the inventory slot if we don't have powder RTL ;-------------------------------------------------------------------------------- @@ -1060,7 +1063,7 @@ RTL ; DrawMagicHeader: ;-------------------------------------------------------------------------------- DrawMagicHeader: - LDA $7EF37B : AND.w #$00FF : CMP.w #$0002 : BEQ .quarterMagic + LDA MagicConsumption : AND.w #$00FF : CMP.w #$0002 : BEQ .quarterMagic .halfMagic LDA.w #$28F7 : STA $7EC704 LDA.w #$2851 : STA $7EC706 @@ -1078,7 +1081,7 @@ RTL ;-------------------------------------------------------------------------------- ;FixShovelLock: ; LDA $037A : CMP #$01 : BEQ + ; skip if link is shoveling -; LDA $7EF34C ; load shovel/flute item ID +; LDA FluteEquipment ; load shovel/flute item ID ; + ; CMP #$00 ;RTL diff --git a/itemdowngrade.asm b/itemdowngrade.asm index 9d08af2..ebea4bc 100644 --- a/itemdowngrade.asm +++ b/itemdowngrade.asm @@ -17,10 +17,10 @@ ItemDowngradeFixMain: CPY.b #$0B : BEQ .isBow ; Bow CPY.b #$3A : BEQ .isBowAndArrows ; Bow - CPY.b #$49 : BEQ .isFightersSword ; Fighter's Sword - CPY.b #$01 : BEQ .isMasterSword ; Master Sword - CPY.b #$50 : BEQ .isMasterSword ; Master Sword (Safe) - CPY.b #$02 : BEQ .isTemperedSword ; Tempered Sword + CPY.b #$49 : BEQ .isSword ; Fighter's Sword + CPY.b #$01 : BEQ .isSword ; Master Sword + CPY.b #$50 : BEQ .isSword ; Master Sword (Safe) + CPY.b #$02 : BEQ .isSword ; Tempered Sword CPY.b #$3B : BEQ .isSilverArrowBow ; Silver Arrow Bow CPY.b #$2A : BEQ .isRedBoomerang ; Red Boomerang @@ -29,7 +29,9 @@ ItemDowngradeFixMain: CPY.b #$13 : BEQ .isShovel ; Shovel CPY.b #$29 : BEQ .isMushroom ; Mushroom - .done + CPY.b #$00 : BEQ .isUncleSwordShield ; Fighter's Sword & Shield + + .done STA [$00] ; thing we wrote over part 2 .dontWrite RTS @@ -56,18 +58,28 @@ RTS + PLA RTS - .isFightersSword - .isMasterSword - .isTemperedSword + .isSword PHA + LDA HighestSword : 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 - INC : CMP !HIGHEST_SWORD_LEVEL : !BGE + ; skip if highest is lower (this is an upgrade) - LDA !HIGHEST_SWORD_LEVEL : DEC ; convert to item id - TAY : PLA : LDA !HIGHEST_SWORD_LEVEL ; put sword id into the thing to write + INC : CMP $04 : !BGE + ; skip if highest is lower (this is an upgrade) + LDA $04 : DEC ; convert to item id + TAY : PLA : LDA $04 ; put sword id into the thing to write JMP .done + PLA JMP .done -;================================================================================ \ No newline at end of file + .isUncleSwordShield + PHA + LDA HighestSword + STA [$00] ; already set to 1 if we had no sword, always keep highest + LDA ShieldEquipment : BNE + ; keep our shield unless we have no shield + INC $00 + INC A + STA [$00] + + + PLA +RTS +;================================================================================ diff --git a/newitems.asm b/newitems.asm index f9fbb3c..d27836f 100755 --- a/newitems.asm +++ b/newitems.asm @@ -142,9 +142,6 @@ macro ValueShift() BRA ?start : ?end: endmacro ;-------------------------------------------------------------------------------- -!CHALLENGE_TIMER = "$7EF454" -!GOAL_COUNTER = "$7EF418" -;-------------------------------------------------------------------------------- ;carry clear if pass ;carry set if caught ;incsrc eventdata.asm @@ -170,7 +167,7 @@ ProcessEventItems: SEP #$10 ; set 8-bit index registers LDA GoalItemRequirement : BEQ ++ - LDA !GOAL_COUNTER : INC : STA !GOAL_COUNTER + LDA GoalCounter : INC : STA GoalCounter CMP GoalItemRequirement : !BLT ++ LDA TurnInGoalItems : BNE ++ JSL.l ActivateGoal @@ -192,7 +189,7 @@ AddReceivedItemExpandedGetItem: ;JSR.w ProcessEventItems : CPX.b #$00 : BEQ ++ ; ;JSL.l Main_ShowTextMessage_Alt - ; LDA !GOAL_COUNTER : INC : STA !GOAL_COUNTER + ; LDA GoalCounter : INC : STA GoalCounter ; LDA.b #$01 : STA $7F50XX ; JMP .done ;++ @@ -283,20 +280,20 @@ AddReceivedItemExpandedGetItem: JMP .done + CMP.b #$5B : BNE + ; Red Clock REP #$20 ; set 16-bit accumulator - LDA !CHALLENGE_TIMER : !ADD.l RedClockAmount : STA !CHALLENGE_TIMER - LDA !CHALLENGE_TIMER+2 : ADC.l RedClockAmount+2 : STA !CHALLENGE_TIMER+2 + LDA ChallengeTimer : !ADD.l RedClockAmount : STA ChallengeTimer + LDA ChallengeTimer+2 : ADC.l RedClockAmount+2 : STA ChallengeTimer+2 SEP #$20 ; set 8-bit accumulator JMP .done + CMP.b #$5C : BNE + ; Blue Clock REP #$20 ; set 16-bit accumulator - LDA !CHALLENGE_TIMER : !ADD.l BlueClockAmount : STA !CHALLENGE_TIMER - LDA !CHALLENGE_TIMER+2 : ADC.l BlueClockAmount+2 : STA !CHALLENGE_TIMER+2 + LDA ChallengeTimer : !ADD.l BlueClockAmount : STA ChallengeTimer + LDA ChallengeTimer+2 : ADC.l BlueClockAmount+2 : STA ChallengeTimer+2 SEP #$20 ; set 8-bit accumulator JMP .done + CMP.b #$5D : BNE + ; Green Clock REP #$20 ; set 16-bit accumulator - LDA !CHALLENGE_TIMER : !ADD.l GreenClockAmount : STA !CHALLENGE_TIMER - LDA !CHALLENGE_TIMER+2 : ADC.l GreenClockAmount+2 : STA !CHALLENGE_TIMER+2 + LDA ChallengeTimer : !ADD.l GreenClockAmount : STA ChallengeTimer + LDA ChallengeTimer+2 : ADC.l GreenClockAmount+2 : STA ChallengeTimer+2 SEP #$20 ; set 8-bit accumulator JMP .done + CMP.b #$5E : BNE + ; Progressive Sword @@ -323,7 +320,7 @@ AddReceivedItemExpandedGetItem: + CMP.b #$6C : BNE + ; Goal Collectable (Multi/Power Star) Alternate Graphic .multi_collect LDA GoalItemRequirement : BEQ ++ - LDA !GOAL_COUNTER : INC : STA !GOAL_COUNTER + LDA GoalCounter : INC : STA GoalCounter CMP GoalItemRequirement : !BLT ++ LDA TurnInGoalItems : BNE ++ JSL.l ActivateGoal diff --git a/quickswap.asm b/quickswap.asm index d23bddd..1331614 100644 --- a/quickswap.asm +++ b/quickswap.asm @@ -28,7 +28,7 @@ QuickSwap: BRA .store .special_swap - LDA BowTracking : ORA #$01 : STA BowTracking + LDA InventoryTracking+1 : ORA #$01 : STA InventoryTracking+1 CPX.b #$02 : BEQ + ; boomerang CPX.b #$01 : BEQ + ; bow CPX.b #$05 : BEQ + ; powder @@ -50,10 +50,10 @@ RTL RCode: LDX.w $0202 LDA.b $F2 : BIT #$20 : BNE ++ ; Still holding L from a previous frame - LDA BowTracking : AND #$FE : STA BowTracking + LDA InventoryTracking+1 : AND #$FE : STA InventoryTracking+1 BRA + ++ - LDA BowTracking : BIT #$01 : BEQ + + LDA InventoryTracking+1 : BIT #$01 : BEQ + RTS - + CPX.b #$14 : BNE + : LDX.b #$00 ;will wrap around to 1 @@ -65,10 +65,10 @@ RTS LCode: LDX.w $0202 LDA.b $F2 : BIT #$10 : BNE ++ ; Still holding R from a previous frame - LDA BowTracking : AND #$FE : STA BowTracking + LDA InventoryTracking+1 : AND #$FE : STA InventoryTracking+1 BRA + ++ - LDA BowTracking : BIT #$01 : BEQ + + LDA InventoryTracking+1 : BIT #$01 : BEQ + RTS - + CPX.b #$01 : BNE + : LDX.b #$15 ; will wrap around to $14 diff --git a/sram.asm b/sram.asm index cc30c26..016cee5 100644 --- a/sram.asm +++ b/sram.asm @@ -161,10 +161,10 @@ CurrentGenericKeys: skip 1 ; Generic small keys ;================================================================================ ; Tracking & Indicators ($7EF38C - $7EF3F0) ;-------------------------------------------------------------------------------- -InventoryTracking: skip 2 ; b r m p n s k f (bitfield) - ; b = Blue Boomerang | r = Red Boomerang | m = Mushroom Current - ; p = Magic Powder | n = Mushroom Past | s = Shovel - ; k = Inactive Flute | f = Active Flute +InventoryTracking: skip 2 ; b r m p n s k f - - - - - - - q (bitfield) + ; b = Blue Boomerang | r = Red Boomerang | m = Mushroom Current + ; p = Magic Powder | n = Mushroom Past | s = Shovel + ; k = Inactive Flute | f = Active Flute | q = Quickswap locked 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 @@ -250,8 +250,7 @@ BigKeysBigChests: skip 1 ; k k k k c c c c (packed integers) ; k = Big Keys collected | c = Big Chests opened MapsCompasses: skip 1 ; m m m m c c c c (packed integers) ; m = Maps collected | c = Compasses collected -HeartPiecesPendants: skip 1 ; h h h h - - p p (packed integers) - ; h = Heart Pieces collected | p = Pendants collected +PendantCounter: skip 1 ; Number of pendants collected (integer) PreGTBKLocations: skip 1 ; Locations checked in GT before finding the big key ; b = Big Bomb Acquired | s = Silver Arrows Acquired ; c = GT locations collected before big key @@ -269,11 +268,12 @@ NMIFrames: skip 4 ; Frame counter incremented during NMI hook (32- ChestsOpened: skip 1 ; Number of chests opened. Doesn't count NPC, free standing items etc (integer) StatsLocked: skip 1 ; Set to $01 when goal is completed; game stops counting stats. MenuTime: skip 4 ; Total menu time in frames (32-bit integer) -HeartPieces: skip 1 ; Total number of heart pieces collected (integer) +HeartContainerCounter: skip 1 ; Total number of heart containers collected (integer) DeathCounter: skip 1 ; Number of deaths (integer) skip 1 ; Reserved FluteCounter: skip 1 ; Number of times fluted (integer) -skip 6 ; +skip 4 ; +RNGItem: skip 2 ; RNG Item SwordlessBosses: skip 1 ; Number of bosses killed without a sword (integer) FaerieRevivalCounter: skip 1 ; Number of faerie revivals (integer) ChallengeTimer: skip 4 ; Timer used for OHKO etc @@ -287,7 +287,9 @@ DamageCounter: skip 2 ; Damage taken by player (16-bit integer) MagicCounter: skip 2 ; Magic used by player (16-bit integer) HighestMail: skip 1 ; Highest mail level SmallKeyCounter: skip 1 ; Total Number of small keys collected (integer) -skip 48 ; Unused +HeartPieceCounter: skip 1 ; Total Number of heartpieces collected (integer) +CrystalCounter: skip 1 ; Total Number of crystals collected (integer) +skip 46 ; Unused ServiceSequence: skip 1 ; Service sequence value. See servicerequest.asL skip 49 ; Unused ; \ Dungeon locations checked counters (integers) @@ -466,7 +468,7 @@ assert TemperedGoldBosses = $7EF425, "TemperedGoldBosses labeled at incorrec assert FighterMasterBosses = $7EF426, "FighterMasterBosses labeled at incorrect address" assert BigKeysBigChests = $7EF427, "BigKeysBigChests labeled at incorrect address" assert MapsCompasses = $7EF428, "MapsCompasses labeled at incorrect address" -assert HeartPiecesPendants = $7EF429, "HeartPiecesPendants labeled at incorrect address" +assert PendantCounter = $7EF429, "PendantCounter labeled at incorrect address" assert PreGTBKLocations = $7EF42A, "PreGTBKLocations labeled at incorrect address" assert RupeesSpent = $7EF42B, "RupeesSpent labeled at incorrect address" assert SaveQuits = $7EF42D, "SaveQuits labeled at incorrect address" @@ -481,9 +483,10 @@ assert NMIFrames = $7EF43E, "NMIFrames labeled at incorrect address assert ChestsOpened = $7EF442, "ChestsOpened labeled at incorrect address" assert StatsLocked = $7EF443, "StatsLocked labeled at incorrect address" assert MenuTime = $7EF444, "MenuTime labeled at incorrect address" -assert HeartPieces = $7EF448, "HeartPieces labeled at incorrect address" +assert HeartContainerCounter = $7EF448, "HeartContainerCounter labeled at incorrect address" assert DeathCounter = $7EF449, "DeathCounter labeled at incorrect address" assert FluteCounter = $7EF44B, "FluteCounter labeled at incorrect address" +assert RNGItem = $7EF450, "FluteCounter labeled at incorrect address" assert SwordlessBosses = $7EF452, "SwordlessBosses labeled at incorrect address" assert FaerieRevivalCounter = $7EF453, "FaerieRevivalCounter labeled at incorrect address" assert ChallengeTimer = $7EF454, "ChallengeTimer labeled at incorrect address" @@ -492,10 +495,13 @@ assert BootsTime = $7EF45C, "BootsTime labeled at incorrect address assert FluteTime = $7EF460, "FluteTime labeled at incorrect address" assert MirrorTime = $7EF464, "MirrorTime labeled at incorrect address" assert ChestTurnCounter = $7EF468, "ChestTurnCounter labeled at incorrect address" +assert CapacityUpgrades = $7EF469, "CapacityUpgrades labeled at incorrect address" assert DamageCounter = $7EF46A, "DamageCounter labeled at incorrect address" assert MagicCounter = $7EF46C, "MagicCounter labeled at incorrect address" assert HighestMail = $7EF46E, "HighestMail labeled at incorrect address" assert SmallKeyCounter = $7EF46F, "SmallKeyCounter labeled at incorrect address" +assert HeartPieceCounter = $7EF470, "HeartPieceCounter labeled at incorrect address" +assert CrystalCounter = $7EF471, "CrystalCounter labeled at incorrect address" ;-------------------------------------------------------------------------------- assert ServiceSequence = $7EF4A0, "ServiceSequence labeled at incorrect address" ;-------------------------------------------------------------------------------- @@ -550,6 +556,9 @@ assert RomName = $7F1000, "RomName at incorrect address" ; ServiceSequence: 7ef419 -> 7ef418 (two bytes reserved) ; SwordsShields: 7ef422 -> swords using HighestSword ; PreMirrorLocations: 7ef432 -> 7ef434, PreBoots and PreMirror now 2 bytes +; Heart Pieces: 7ef429 -> 7ef470 +; Pendant counter: 7ef429, now an integer +; SwordlessBosses: 7ef452, now an integer ; ; DungeonLocations values and labels moved to block right before ChestKeys block ; starting at address 7ef472 diff --git a/utilities.asm b/utilities.asm index abadf53..349d317 100644 --- a/utilities.asm +++ b/utilities.asm @@ -627,19 +627,19 @@ RTL ; out: A(b) - sum of bits ; caller is responsible for setting 8-bit mode and preserving X and Y ;-------------------------------------------------------------------------------- -CountBits: - PHX - TAX ; Save a copy of value - LSR #4 ; Shift down hi nybble, Leave <3> in C - PHA ; And save <7:4> in Stack - TXA ; Recover value - AND.b #$07 ; Put out <2:0> in X - TAX ; And save in X - LDA.l NybbleBitCounts, X ; Fetch count for <2:0> - PLX ; get <7:4> - ADC.l NybbleBitCounts, X ; Add count for S & C - PLX -RTL +;CountBits: +; PHX +; TAX ; Save a copy of value +; LSR #4 ; Shift down hi nybble, Leave <3> in C +; PHA ; And save <7:4> in Stack +; TXA ; Recover value +; AND.b #$07 ; Put out <2:0> in X +; TAX ; And save in X +; LDA.l NybbleBitCounts, X ; Fetch count for <2:0> +; PLX ; get <7:4> +; ADC.l NybbleBitCounts, X ; Add count for S & C +; PLX +;RTL ; Look up table of bit counts in the values $00-$0F NybbleBitCounts: From d5c4834b1d762c9f43e8665b5dfaf59069291d24 Mon Sep 17 00:00:00 2001 From: cassidy Date: Mon, 6 Dec 2021 00:33:29 -0500 Subject: [PATCH 05/96] Next draft of sram.asm. Save/SRAM changes to save, init, and password Deleted previewdatacopy.asm which was for SRAM Trace which we no longer support. Password moved to $703000. 32-bits at $FFE0 in ROM (unused hardware vector) now burned into $702015 in SRAM with ROM name. --- init.asm | 4 +- password.asm | 12 ++- previewdatacopy.asm | 66 --------------- save.asm | 4 +- sram.asm | 199 ++++++++++++++++++++++++++------------------ 5 files changed, 128 insertions(+), 157 deletions(-) delete mode 100644 previewdatacopy.asm diff --git a/init.asm b/init.asm index 8fc9a65..cdd7d66 100644 --- a/init.asm +++ b/init.asm @@ -24,7 +24,7 @@ Init_Primary: LDX #$00 - - LDA $702000, X : CMP $00FFC0, X : BNE .clear + LDA RomNameSRAM, X : CMP $00FFC0, X : BNE .clear INX CPX #$15 : !BLT - BRA .done @@ -38,7 +38,7 @@ Init_Primary: SEP #$30 ; set 8-bit accumulator & index registers LDX #$00 - - LDA $00FFC0, X : STA $702000, X + LDA $00FFC0, X : STA RomNameSRAM, X INX CPX #$15 : !BLT - LDX #$00 diff --git a/password.asm b/password.asm index 595d1cd..4e71af0 100644 --- a/password.asm +++ b/password.asm @@ -1,7 +1,5 @@ !PASSWORD_CODE_POSITION = "$C8" !PASSWORD_SELECTION_POSITION = "$C9" -!PASSWORD_SRAM = "$701000" - Module_Password: LDA $11 @@ -39,7 +37,7 @@ Password_EndInit: LDX.b #$0F LDA.b #$00 - - STA.l !PASSWORD_SRAM, X + STA.l PasswordSRAM, X DEX : BPL - + @@ -108,7 +106,7 @@ Password_Main: BRA + ++ LDX !PASSWORD_CODE_POSITION - STA !PASSWORD_SRAM,X + STA PasswordSRAM,X TXA : INC A : AND.b #$0F : STA !PASSWORD_CODE_POSITION BNE ++ STZ $012E @@ -166,7 +164,7 @@ ValidatePassword: ;check for incomplete password LDX #$0F - - LDA.l !PASSWORD_SRAM, X : BNE + + LDA.l PasswordSRAM, X : BNE + JMP .incorrect + DEX : BPL - @@ -229,7 +227,7 @@ PasswordToKey: LDA.w #$000B : STA $04 - LDX $00 - LDA !PASSWORD_SRAM, X : DEC : AND #$001F + LDA PasswordSRAM, X : DEC : AND #$001F LDY $04 -- : BEQ + : ASL : DEY : BRA -- : + ; Shift left by Y XBA @@ -343,7 +341,7 @@ UpdatePasswordTiles: REP #$30 ; set 16-bit both LDX.w #$000F - - LDA.l !PASSWORD_SRAM, X : AND.w #$00FF : TXY + LDA.l PasswordSRAM, X : AND.w #$00FF : TXY ASL #3 : STA $00 TYA : ASL #4 : STA $03 LDX $00 : LDA.l HashAlphabetTilesWithBlank, X diff --git a/previewdatacopy.asm b/previewdatacopy.asm deleted file mode 100644 index 8bee1d7..0000000 --- a/previewdatacopy.asm +++ /dev/null @@ -1,66 +0,0 @@ -;================================================================================ -; RTPreview SRAM Hook -;-------------------------------------------------------------------------------- -MaybeWriteSRAMTrace: - LDA EnableSRAMTrace : AND.l TournamentSeedInverse : BEQ + - JSL.l WriteStatusPreview - + -RTL -;-------------------------------------------------------------------------------- -WriteStatusPreview: - PHA - 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 - - STA $4301 ; set bus B source to WRAM register - - LDA #$40 : STA $2181 ; set WRAM register source address - LDA #$F3 : STA $2182 - LDA #$7E : STA $2183 - - STZ $4302 ; set bus A destination address to SRAM - LDA #$1E : STA $4303 - LDA #$70 : STA $4304 - - LDA #$80 : STA $4305 ; set transfer size to 0x180 - LDA #$01 : STA $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 - PLA -RTL -;-------------------------------------------------------------------------------- -;WriteStatusPreview: -; PHA : PHX : PHP -; -; REP #$20 ; set 16-bit accumulator -; CLC -; LDX.b #$00 -; - -; LDA $7EF340, X : STA $701E00, X -; LDA $7EF340+2, X : STA $701E00+2, X -; LDA $7EF340+4, X : STA $701E00+4, X -; TXA : ADC.b #$06 : TAX -; CPX #$24 : !BLT - -; -; SEP #$20 ; set 8-bit accumulator -; LDA $7EF374 : STA $701E24 -; LDA $7EF37A : STA $701E25 -; -; PLP : PLX : PLA -;RTL -;-------------------------------------------------------------------------------- \ No newline at end of file diff --git a/save.asm b/save.asm index da75292..1aab65d 100644 --- a/save.asm +++ b/save.asm @@ -27,7 +27,7 @@ RTL ;-------------------------------------------------------------------------------- ClearExtendedWRAMSaveFile: STA $7EF400, X ; what we wrote over -; STA $7F6000, X + STA $7F6000, X STA $7F6100, X STA $7F6200, X STA $7F6300, X @@ -68,7 +68,7 @@ CopyExtendedSaveFileToWRAM: LDA #$05 : STA $4303 LDA #$70 : STA $4304 - LDA #$00 : STA $4305 ; set transfer size to 0xB00 + LDA #$00 : STA $4305 ; set transfer size to 0x1000 LDA #$10 : STA $4306 ; STZ $4307 LDA #$01 : STA $420B ; begin DMA transfer diff --git a/sram.asm b/sram.asm index 016cee5..12f7ee5 100644 --- a/sram.asm +++ b/sram.asm @@ -1,3 +1,4 @@ +org 0 ;================================================================================ ; SRAM Labels & Assertions ;-------------------------------------------------------------------------------- @@ -19,11 +20,11 @@ ; 4 (northwest), 3 (northeast), 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].Low to read or write the pot key in the first +; Example: We can use RoomData[$37].high to read or write the pot key in the first ; floodable room in Swamp Palace ($04) ;-------------------------------------------------------------------------------- -; Low Byte: d d d d b k u r -; High Byte: c c c c q q q q +; .high Byte: d d d d b k u r +; .low Byte: c c c c q q q q ; ; d = Door opened (key, bomb wall, etc) ; b = Boss kill / Heart Piece @@ -37,8 +38,9 @@ ; q = Quadrant visits ;-------------------------------------------------------------------------------- struct RoomData $7EF000 - .Low: skip 1 - .High: skip 1 + .l + .low: skip 1 + .high: skip 1 endstruct align 2 ;================================================================================ @@ -48,7 +50,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 OverworldData+$1B or OverworldData+27) +; be OverworldEventData+$1B or OverworldEventData+27) ;-------------------------------------------------------------------------------- ; - i o - - - b - ; @@ -56,7 +58,7 @@ endstruct align 2 ; o = Overlay active ; b = Secondary overlay active ;-------------------------------------------------------------------------------- -OverworldData = $7EF280 +OverworldEventData = $7EF280 ;================================================================================ ; Items & Equipment ($7EF340 - $7EF38B) @@ -68,7 +70,7 @@ OverworldData = $7EF280 ; $00 = None ;-------------------------------------------------------------------------------- base $7EF340 -SRAMEquipment: ; +WRAMEquipment: ; BowEquipment: skip 1 ; $01 = Bow | $02 = Bow & Arrows ; $03 = Silver Arrow Bow | $04 = Bow & Silver Arrows BoomerangEquipment: skip 1 ; $01 = Blue | $02 = Red @@ -107,14 +109,14 @@ TargetRupees: skip 2 ; \ CurrentRupees will always increment or decre CurrentRupees: skip 2 ; / TargetRupees if not equal (16-bit integer) ;-------------------------------------------------------------------------------- CompassField: skip 2 ; Dungeon item bitfields -BigKeyField: skip 2 ; Low byte: - - g r t h i s -MapField: skip 2 ; g = Ganon's Tower | r = Turtle Rock | t = Thieves' Town - ; h = Tower of Hera | i = Ice Palace | s = Skull Woods +BigKeyField: skip 2 ; High byte: - - g r t h i s +MapField: skip 2 ; g = Ganon's Tower | r = Turtle Rock | t = Thieves' Town + ; h = Tower of Hera | i = Ice Palace | s = Skull Woods ;------------------------------------------------ - ; High Byte: m d s a t e h p - ; m = Misery Mire | d = Palace of Darkness | s = Swamp Palace - ; a = Aga Tower | t = Desert Palace | e = Eastern Palace - ; h = Hyrule Castle | s = Sewer Passage + ; Low Byte: m d s a t e h p + ; m = Misery Mire | d = Palace of Darkness | s = Swamp Palace + ; a = Aga Tower | t = Desert Palace | e = Eastern Palace + ; h = Hyrule Castle | s = Sewer Passage ;-------------------------------------------------------------------------------- ; HUD & other equipment skip 1 ; Wishing Pond Rupee (Unused) @@ -140,9 +142,9 @@ CrystalsField: skip 1 ; - 3 4 2 7 5 1 6 (bitfield) MagicConsumption: skip 1 ; $00 = Normal | $01 = Half Magic | $02 = Quarter Magic ;-------------------------------------------------------------------------------- ; Small keys earned per dungeon (integers) -SewerKeys: skip 1 ; \ Hyrule Castle and Sewer keys typically increment -DungeonKeys: ; | and decrement together -HyruleCastleKeys: skip 1 ; / +DungeonKeys: ; +SewerKeys: skip 1 ; +HyruleCastleKeys: skip 1 ; EasternKeys: skip 1 ; Eastern Palace small keys DesertKeys: skip 1 ; Desert Palace small keys CastleTowerKeys: skip 1 ; Agahnim's Tower small keys @@ -161,18 +163,20 @@ CurrentGenericKeys: skip 1 ; Generic small keys ;================================================================================ ; Tracking & Indicators ($7EF38C - $7EF3F0) ;-------------------------------------------------------------------------------- -InventoryTracking: skip 2 ; b r m p n s k f - - - - - - - q (bitfield) - ; b = Blue Boomerang | r = Red Boomerang | m = Mushroom Current - ; p = Magic Powder | n = Mushroom Past | s = Shovel - ; k = Inactive Flute | f = Active Flute | q = Quickswap locked +InventoryTracking: skip 2 ; b r m p n s k f - - - - - - o q (bitfield) + ; b = Blue Boomerang | r = Red Boomerang | m = Mushroom Current + ; 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) ; 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 ; the first -ItemLimitCounts: skip 10 ; Keeps track of limited non-progressive items such as lamp. +ItemLimitCounts: skip 24 ; Keeps track of limited non-progressive items such as lamp. ; See: ItemSubstitutionRules in tables.asm -skip 43 ; + ; Right now this is only used for three items but extra space is +skip 29 ; reserved ProgressIndicator: skip 1 ; $00 = Pre-Uncle | $01 = Post-Uncle item | $02 = Zelda Rescued ; $03 = Agahnim 1 defeated ; $04 and above don't do anything. $00-$02 used in standard mode @@ -197,7 +201,7 @@ FollowerIndicator: skip 1 ; $00 = No Follower | $01 = Zelda | $04 = Ol FollowerXCoord: skip 2 ; \ Cached X and Y overworld coordinates of dropped follower FollowerYCoord: skip 2 ; / (16-bit integers) DroppedFollowerIndoors: skip 1 ; $00 = Dropped follower outdoors | $01 = Dropped follower indoors -DroppedFollowerLayer: skip 1 ; $00 = Upper layer | $01 = Lower layer +DroppedFollowerLayer: skip 1 ; $00 = Upper layer | $01 =.lower layer FollowerDropped: skip 1 ; Set to $80 when a follower exists and has been dropped somewhere ; $00 otherwise skip 5 ; Unused @@ -212,10 +216,11 @@ GameCounter: skip 2 ; Number of deaths and save + quits (16-bit inte PostGameCounter: skip 2 ; Initialized to $FFFF, replaced with GameCounter on goal completion ; Number is displayed on file select when not $FFFF. Max 999 (16-bit integer) skip 13 ; -NpcFlagsOne: skip 1 ; l - c s t k z o (bitfield) +NpcFlags: skip 2 ; l - c s t k z o (bitfield) ; l = Library | c = Catfish | s = Sahasrahla | t = Stumpy ; k = Sick Kid | z = King Zora | o = Old Man -NpcFlagsTwo: skip 1 ; b - p m f s b e (bitfield) + ; + ; b - p m f s b e (bitfield) ; b = Magic Bat | p = Potion Shop (Powder) | m = Lost Woods (Mushroom) ; f = Fairy (unused) | s = Smith | b = Bombos Tablet ; e = Ether Tablet @@ -229,9 +234,11 @@ MapOverlay: skip 2 ; Used to reveal dungeon prizes on the map in mo ; | m = Misery Mire | d = Palace of Darkness | s = Swamp Palace ; | a = Aga Tower | t = Desert Palace | e = Eastern Palace ; / h = Hyrule Castle | s = Sewer Passage -GeneralFlags: skip 1 ; - - h - p i - g (bitfield) - ; h = HUD Flag | p = Force pyramid - ; i = Ignore faeries | g = Has diggable grove item +HudFlag: ; +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) GoalCounter: skip 2 ; Goal items collected (16-bit integer) ProgrammableItemOne: skip 2 ; \ Reserved for programmable items @@ -242,10 +249,9 @@ 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 TotalItemCounter: skip 2 ; Total items collected (integer) -TemperedGoldBosses: skip 1 ; t t t t g g g g (packed integers) +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 -FighterMasterBosses: skip 1 ; f f f f m m m m (packed integers) - ; f = Fighter Sword boss kills | m = Master Sword boss kills + ; f = Fighter Sword boss kills | m = Master Sword boss kills BigKeysBigChests: skip 1 ; k k k k c c c c (packed integers) ; k = Big Keys collected | c = Big Chests opened MapsCompasses: skip 1 ; m m m m c c c c (packed integers) @@ -255,7 +261,7 @@ PreGTBKLocations: skip 1 ; Locations checked in GT before finding the big ; b = Big Bomb Acquired | s = Silver Arrows Acquired ; c = GT locations collected before big key RupeesSpent: skip 2 ; Rupees spent (16-bit integer) -SaveQuits: skip 1 ; Number of times player has saved and quit (integer) +SaveQuitCounter: skip 1 ; Number of times player has saved and quit (integer) LoopFrames: skip 4 ; Frame counter incremented during frame hook (32-bit integer) PreBootsLocations: skip 2 ; Number of locations checked before getting boots (integer) PreMirrorLocations: skip 2 ; Number of locations checked before getting mirror (integer) @@ -267,14 +273,14 @@ ScreenTransitions: skip 2 ; Number of screen transitions (16-bit integer) NMIFrames: skip 4 ; Frame counter incremented during NMI hook (32-bit integer) ChestsOpened: skip 1 ; Number of chests opened. Doesn't count NPC, free standing items etc (integer) StatsLocked: skip 1 ; Set to $01 when goal is completed; game stops counting stats. -MenuTime: skip 4 ; Total menu time in frames (32-bit integer) +MenuFrames: skip 4 ; Total menu time in frames (32-bit integer) HeartContainerCounter: skip 1 ; Total number of heart containers collected (integer) DeathCounter: skip 1 ; Number of deaths (integer) skip 1 ; Reserved FluteCounter: skip 1 ; Number of times fluted (integer) skip 4 ; RNGItem: skip 2 ; RNG Item -SwordlessBosses: skip 1 ; Number of bosses killed without a sword (integer) +SwordlessBossKills: skip 1 ; Number of bosses killed without a sword (integer) FaerieRevivalCounter: skip 1 ; Number of faerie revivals (integer) ChallengeTimer: skip 4 ; Timer used for OHKO etc SwordTime: skip 4 ; Time first sword found in frames (32-bit integer) @@ -288,13 +294,15 @@ MagicCounter: skip 2 ; Magic used by player (16-bit integer) HighestMail: skip 1 ; Highest mail level SmallKeyCounter: skip 1 ; Total Number of small keys collected (integer) HeartPieceCounter: skip 1 ; Total Number of heartpieces collected (integer) -CrystalCounter: skip 1 ; Total Number of crystals collected (integer) +CrystalCounter: skip 1 ; Total Number of crystals collected (integer) skip 46 ; Unused -ServiceSequence: skip 1 ; Service sequence value. See servicerequest.asL -skip 49 ; Unused +ServiceRequestReceive: ; +ServiceRequestTransmit: ; +ServiceRequest: skip 8 ; Service request block. See servicerequest.asm +skip 42 ; Unused ; \ Dungeon locations checked counters (integers) +SewersLocations: skip 1 ; | Sewer Passage HCLocations: skip 1 ; | Hyrule Castle -SewerLocations: skip 1 ; | Sewer Passage EPLocations: skip 1 ; | Eastern Palace DPLocations: skip 1 ; | Desert Palace CTLocations: skip 1 ; | Agahnim's Tower @@ -307,9 +315,9 @@ THLocations: skip 1 ; | Tower of Hera TTLocations: skip 1 ; | Thieves' Town TRLocations: skip 1 ; | Turtle Rock GTLocations: skip 1 ; / Ganon's Tower - ; \ Chest Key Counters. Only counts keys placed in chests. (integers) -HCChestKeys: skip 1 ; | Hyrule Castle +DungeonChestKeys: ; \ Chest Key Counters. Only counts keys placed in chests. (integers) SewerChestKeys: skip 1 ; | Sewer Passage +HCChestKeys: skip 1 ; | Hyrule Castle EPChestKeys: skip 1 ; | Eastern Palace DPChestKeys: skip 1 ; | Desert Palace CTChestKeys: skip 1 ; | Agahnim's Tower @@ -322,7 +330,7 @@ THChestKeys: skip 1 ; | Tower of Hera TTChestKeys: skip 1 ; | Thieves' Town TRChestKeys: skip 1 ; | Turtle Rock GTChestKeys: skip 1 ; / Ganon's Tower -skip 2 ; Unused +skip 2 ; Reserved, may be indexed into and have junk generic key data written 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. @@ -334,26 +342,44 @@ InverseChecksum: skip 2 ; Vanilla Inverse Checksum. Don't write unless c ; beginning at $700500 ;-------------------------------------------------------------------------------- base $7F6000 ; $1000 byte buffer we place beginning at second save file -ExtendedFileNameSRAM = $706000 ; We read and write the file name directly from and to SRAM ExtendedFileNameWRAM: skip 24 ; File name, 12 word-length characters. -VERSION: skip 4 ; $0000 = Default TODO -RoomPotData: skip 592 ; Table for expanded pot shuffle +RoomPotData: 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 + +;================================================================================ +; Direct SRAM Assignments ($700000 - $7080000) ;-------------------------------------------------------------------------------- -base $7F1000 ; -RomName: ; ROM name from $FFC0, burned in during init (21 bytes) +; Label assignments for the actual cartridge SRAM, expanded to 32k. Used mainly +; for burning in values such as the ROM name directly or when we only have to read +; a small amount of data which is not currently in the WRAM mirror. +;-------------------------------------------------------------------------------- +base $700000 ; +skip $0340 ; +SRAMEquipment: skip 76 ; +InventoryTrackingSRAM: skip 2 ; +BowTrackingSRAM: skip 2 ; +skip 368 ; +ExtendedFileNameSRAM: skip 24 ; We read and write the file name directly from and to SRAM (24 bytes) +skip $1AE8 ; +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. +VERSIONSRAM: skip 4 ; ALTTPR ROM version (32 bytes) +skip 4071 ; +PasswordSRAM: skip 16 ; Password value (16 bytes) base off +;================================================================================ +; Assertions ;================================================================================ ; Vanilla Assertions ;-------------------------------------------------------------------------------- ; All of these need to pass for the base rom to build or something is probably ; very wrong. ;-------------------------------------------------------------------------------- -assert SRAMEquipment = $7EF340, "SRAMEquipment labeled at incorrect address" +assert WRAMEquipment = $7EF340, "WRAMEquipment labeled at incorrect address" assert BowEquipment = $7EF340, "BowEquipment labeled at incorrect address" assert BoomerangEquipment = $7EF341, "BoomerangEquipment labeled at incorrect address" assert HookshotEquipment = $7EF342, "HookshotEquipment labeled at incorrect address" @@ -443,7 +469,7 @@ assert InverseChecksum = $7EF4FE, "InverseChecksum labeled at incorrect a ;================================================================================ ; Randomizer Assertions ;-------------------------------------------------------------------------------- -; Trackers and other third party consumers may depend on these values +; Trackers and other third party consumers may depend on these values. ;-------------------------------------------------------------------------------- assert InventoryTracking = $7EF38C, "InventoryTracking labeled at incorrect address" assert BowTracking = $7EF38E, "BowTracking labeled at incorrect address" @@ -451,8 +477,7 @@ assert ItemLimitCounts = $7EF390, "ItemLimitCounts labeled at incorrect a ;-------------------------------------------------------------------------------- assert GameCounter = $7EF3FF, "GameCounter labeled at incorrect address" assert PostGameCounter = $7EF401, "PostGameCounter labeled at incorrect address" -assert NpcFlagsOne = $7EF410, "NPCFlagsOne labeled at incorrect address" -assert NpcFlagsTwo = $7EF411, "NPCFlagsTwo labeled at incorrect address" +assert NpcFlags = $7EF410, "NPCFlags labeled at incorrect address" assert MapOverlay = $7EF414, "MapOverlay labeled at incorrect address" assert GeneralFlags = $7EF416, "GeneralFlags labeled at incorrect address" assert HighestSword = $7EF417, "HighestSword labeled at incorrect address" @@ -462,16 +487,15 @@ assert ProgrammableItemTwo = $7EF41C, "ProgrammableItemTwo labeled at incorre assert ProgrammableItemThree = $7EF41E, "ProgrammableItemThree labeled at incorrect address" assert BonkCounter = $7EF420, "BonkCounter labeled at incorrect address" assert YAItemCounter = $7EF421, "YAItemCounter labeled at incorrect address" -assert HighestShield = $7EF422, "SwordsShields labeled at incorrect address" +assert HighestShield = $7EF422, "HighestShield labeled at incorrect address" assert TotalItemCounter = $7EF423, "TotalItemCounter labeled at incorrect address" -assert TemperedGoldBosses = $7EF425, "TemperedGoldBosses labeled at incorrect address" -assert FighterMasterBosses = $7EF426, "FighterMasterBosses labeled at incorrect address" +assert SwordBossKills = $7EF425, "SwordBossKills labeled at incorrect address" assert BigKeysBigChests = $7EF427, "BigKeysBigChests labeled at incorrect address" assert MapsCompasses = $7EF428, "MapsCompasses labeled at incorrect address" assert PendantCounter = $7EF429, "PendantCounter labeled at incorrect address" assert PreGTBKLocations = $7EF42A, "PreGTBKLocations labeled at incorrect address" assert RupeesSpent = $7EF42B, "RupeesSpent labeled at incorrect address" -assert SaveQuits = $7EF42D, "SaveQuits labeled at incorrect address" +assert SaveQuitCounter = $7EF42D, "SaveQuitCounter labeled at incorrect address" assert LoopFrames = $7EF42E, "LoopFrames labeled at incorrect address" assert PreBootsLocations = $7EF432, "PreBootsLocations labeled at incorrect address" assert PreMirrorLocations = $7EF434, "PreMirrorLocations labeled at incorrect address" @@ -482,12 +506,12 @@ assert ScreenTransitions = $7EF43C, "ScreenTransitions labeled at incorrect assert NMIFrames = $7EF43E, "NMIFrames labeled at incorrect address" assert ChestsOpened = $7EF442, "ChestsOpened labeled at incorrect address" assert StatsLocked = $7EF443, "StatsLocked labeled at incorrect address" -assert MenuTime = $7EF444, "MenuTime labeled at incorrect address" +assert MenuFrames = $7EF444, "MenuFrames labeled at incorrect address" assert HeartContainerCounter = $7EF448, "HeartContainerCounter labeled at incorrect address" assert DeathCounter = $7EF449, "DeathCounter labeled at incorrect address" assert FluteCounter = $7EF44B, "FluteCounter labeled at incorrect address" -assert RNGItem = $7EF450, "FluteCounter labeled at incorrect address" -assert SwordlessBosses = $7EF452, "SwordlessBosses labeled at incorrect address" +assert RNGItem = $7EF450, "RNGItem labeled at incorrect address" +assert SwordlessBossKills = $7EF452, "SwordlessBossKills labeled at incorrect address" assert FaerieRevivalCounter = $7EF453, "FaerieRevivalCounter labeled at incorrect address" assert ChallengeTimer = $7EF454, "ChallengeTimer labeled at incorrect address" assert SwordTime = $7EF458, "SwordTime labeled at incorrect address" @@ -503,10 +527,10 @@ assert SmallKeyCounter = $7EF46F, "SmallKeyCounter labeled at incorrect a assert HeartPieceCounter = $7EF470, "HeartPieceCounter labeled at incorrect address" assert CrystalCounter = $7EF471, "CrystalCounter labeled at incorrect address" ;-------------------------------------------------------------------------------- -assert ServiceSequence = $7EF4A0, "ServiceSequence labeled at incorrect address" +assert ServiceRequest = $7EF4A0, "ServiceRequest labeled at incorrect address" ;-------------------------------------------------------------------------------- -assert HCLocations = $7EF4D2, "HCLocations labeled at incorrect address" -assert SewerLocations = $7EF4D3, "SewersLocations labeled at incorrect address" +assert SewersLocations = $7EF4D2, "SewersLocations labeled at incorrect address" +assert HCLocations = $7EF4D3, "HCLocations labeled at incorrect address" assert EPLocations = $7EF4D4, "EPLocations labeled at incorrect address" assert DPLocations = $7EF4D5, "DPLocations labeled at incorrect address" assert CTLocations = $7EF4D6, "CTLocations labeled at incorrect address" @@ -519,8 +543,8 @@ assert THLocations = $7EF4DC, "THLocations labeled at incorrect addre assert TTLocations = $7EF4DD, "TTLocations labeled at incorrect address" assert TRLocations = $7EF4DE, "TRLocations labeled at incorrect address" assert GTLocations = $7EF4DF, "GTLocations labeled at incorrect address" -assert HCChestKeys = $7EF4E0, "HCChestKeys labeled at incorrect address" -assert SewerChestKeys = $7EF4E1, "SewerChestKeys labeled at incorrect address" +assert SewerChestKeys = $7EF4E0, "SewerChestKeys labeled at incorrect address" +assert HCChestKeys = $7EF4E1, "HCChestKeys labeled at incorrect address" assert EPChestKeys = $7EF4E2, "EPChestKeys labeled at incorrect address" assert DPChestKeys = $7EF4E3, "DPChestKeys labeled at incorrect address" assert CTChestKeys = $7EF4E4, "ATChestKeys labeled at incorrect address" @@ -535,13 +559,22 @@ assert TRChestKeys = $7EF4EC, "TRChestKeys labeled at incorrect addre assert GTChestKeys = $7EF4ED, "GChestKeys labeled at incorrect address" assert FileMarker = $7EF4F0, "FileMarker labeled at incorrect address" ;-------------------------------------------------------------------------------- -assert ExtendedFileNameWRAM = $7F6000, "Filename labeled at incorrect address" -assert VERSION = $7F6018, "VERSION labeled at incorrect address" -assert RoomPotData = $7F601C, "RoomPotData labeled at incorrect address" -assert PurchaseCounts = $7F626C, "PurchaseCounts labeled at incorrect address" -assert DummyValue = $7F62CC, "DummyValue labeled at incorrect address" +assert ExtendedFileNameWRAM = $7F6000, "ExtendedFilenameWRAM labeled at incorrect address" +assert RoomPotData = $7F6018, "RoomPotData labeled at incorrect address" +assert PurchaseCounts = $7F6268, "PurchaseCounts labeled at incorrect address" +assert PrivateBlock = $7F62C8, "PrivateBlock labeled at incorrect address" +assert DummyValue = $7F64C8, "DummyValue labeled at incorrect address" + +;================================================================================ +; Direct SRAM Assertions ;-------------------------------------------------------------------------------- -assert RomName = $7F1000, "RomName at incorrect address" +assert SRAMEquipment = $700340, "SRAMEquipment labeled at incorrect address" +assert InventoryTrackingSRAM = $70038C, "InventoryTracking labeled at incorrect address" +assert BowTrackingSRAM = $70038E, "BowTracking labeled at incorrect address" +assert ExtendedFileNameSRAM = $700500, "ExtendedFilenameSRAM labeled at incorrect address" +assert RomNameSRAM = $702000, "RomNameSRAM at incorrect address" +assert VERSIONSRAM = $702015, "VERSIONSRAM at incorrect address" +assert PasswordSRAM = $703000, "PasswordSRAM at incorrect address" ;-------------------------------------------------------------------------------- ; MOVED TODO @@ -550,11 +583,11 @@ assert RomName = $7F1000, "RomName at incorrect address" ; file name: 3e3-3f0, -> 7ef500 ; shop purchase counts: 7ef302 -> 7ef51a - 7ef579 ; GoalCounter: 7ef418 -> 7ef418 (2 bytes) -; HighestMail: 7ef424 -> 7ef470 -; HighestShield: 7ef422 -> swords using HighestSword, shields removed from general flags +;HighestMail: 7ef424 -> 7ef470 +;HighestShield: 7ef422 -> swords usingHighestSword, shields removed from general flags ; SmallKeyCounter: 7ef424 -> 7ef471 -; ServiceSequence: 7ef419 -> 7ef418 (two bytes reserved) -; SwordsShields: 7ef422 -> swords using HighestSword +; ServiceSequence: removed +; SwordsShields: 7ef422 -> swords usingHighestSword ; PreMirrorLocations: 7ef432 -> 7ef434, PreBoots and PreMirror now 2 bytes ; Heart Pieces: 7ef429 -> 7ef470 ; Pendant counter: 7ef429, now an integer @@ -566,15 +599,21 @@ assert RomName = $7F1000, "RomName at incorrect address" ; bombs (?), silvers, and pre gtbk at $7ef42a now just pre gtbk ; ; whole file name now at $7F6000/706000, first four still at vanilla location +; +; password_sram: 701000 -> 703000 ;-------------------------------------------------------------------------------- ; ADDED ;-------------------------------------------------------------------------------- ; -; PreFluteLocations = $7EF436 -; VERSION = $7F6018 -; RoomPotData = $7F601C -; PurchaseCounts = $7F601C -; DummyValue = $7F607C +; PreFluteLocations = $7EF436[0x02] +; ServiceRequest = $7EF4A0[0x08] +; VERSION = $7F6018[0x04] +; RoomPotData = $7F601C[0x250] +; PurchaseCounts = $7F601C[0x60] +; DummyValue = $7F607C[0x02] ; ;-------------------------------------------------------------------------------- - +; TODO +;-------------------------------------------------------------------------------- +; figure out why ChestsOpened is wrong +; From c29de404843268de3467231a022aa176a75862a0 Mon Sep 17 00:00:00 2001 From: cassidy Date: Mon, 6 Dec 2021 00:41:55 -0500 Subject: [PATCH 06/96] Change addresses to labels and remove SRAM trace calls --- bugfixes.asm | 6 +- compasses.asm | 52 ++------ contrib.asm | 5 +- cuccostorm.asm | 4 +- dialog.asm | 2 +- elder.asm | 4 +- entrances.asm | 6 +- events.asm | 26 ++-- flipperkill.asm | 6 +- floodgatesoftlock.asm | 18 +-- flute.asm | 8 +- glitched.asm | 8 +- goalitem.asm | 16 +-- heartpieces.asm | 6 +- inverted.asm | 8 +- maidencrystals.asm | 2 - medallions.asm | 6 +- msu.asm | 16 +-- music.asm | 8 +- newhud.asm | 11 +- npcitems.asm | 56 ++++---- openmode.asm | 4 +- pendantcrystalhud.asm | 19 ++- retro.asm | 2 +- shopkeeper.asm | 3 - spriteswap.asm | 4 +- stats.asm | 301 +++++++++--------------------------------- stats/statConfig.asm | 36 ++--- swordswap.asm | 4 +- timer.asm | 14 +- 30 files changed, 226 insertions(+), 435 deletions(-) diff --git a/bugfixes.asm b/bugfixes.asm index b1d29b3..1dcaa05 100644 --- a/bugfixes.asm +++ b/bugfixes.asm @@ -63,7 +63,7 @@ RTL ;-------------------------------------------------------------------------------- ;ReadInventoryPond: ; CPX.b #$1B : BNE + : LDA.b #$01 : RTL : + -; LDA SRAMEquipment, X +; LDA WRAMEquipment, X ;RTL ;-------------------------------------------------------------------------------- @@ -83,10 +83,10 @@ RTS FixAga2Bunny: LDA.l FixFakeWorld : BEQ + ; Only use this fix is fakeworld fix is in use LDA.l InvertedMode : BEQ +++ - LDA.b #$00 : STA !DARK_WORLD ; Switch to light world + LDA.b #$00 : STA CurrentWorld ; Switch to light world BRA ++ +++ - LDA.b #$40 : STA !DARK_WORLD ; Switch to dark world + LDA.b #$40 : STA CurrentWorld ; Switch to dark world ++ JSL DecideIfBunny : BNE + JSR MakeBunny diff --git a/compasses.asm b/compasses.asm index 50d1807..77fed99 100644 --- a/compasses.asm +++ b/compasses.asm @@ -49,92 +49,66 @@ CompassCountDungeonHandlers: ; pointers to functions that handle dungeon-specifi CompassCount_Escape: %DrawConstantNumber(0,8) - LDA $7EF434 : LSR #4 + LDA SewersLocations JMP DrawDungeonCompassCounts_return_spot CompassCount_Eastern: %DrawConstantNumber(0,6) - LDA $7EF436 : AND.b #$07 + LDA EPLocations JMP DrawDungeonCompassCounts_return_spot CompassCount_Desert: %DrawConstantNumber(0,6) - LDA $7EF435 : LSR #5 + LDA DPLocations JMP DrawDungeonCompassCounts_return_spot CompassCount_Agah: %DrawConstantNumber(0,2) - LDA $7EF435 : AND.b #$03 + LDA CTLocations JMP DrawDungeonCompassCounts_return_spot CompassCount_Swamp: %DrawConstantNumber(1,0) - LDA $7EF439 : AND.b #$0F + LDA SPLocations JMP DrawDungeonCompassCounts_return_spot CompassCount_PoD: %DrawConstantNumber(1,4) - LDA $7EF434 : AND.b #$0F + LDA PDLocations JMP DrawDungeonCompassCounts_return_spot CompassCount_Mire: %DrawConstantNumber(0,8) - LDA $7EF438 : AND.b #$0F + LDA MMLocations JMP DrawDungeonCompassCounts_return_spot CompassCount_Skull: %DrawConstantNumber(0,8) - LDA $7EF437 : LSR #4 + LDA SWLocations JMP DrawDungeonCompassCounts_return_spot CompassCount_Ice: %DrawConstantNumber(0,8) - LDA $7EF438 : LSR #4 + LDA IPLocations JMP DrawDungeonCompassCounts_return_spot CompassCount_Hera: %DrawConstantNumber(0,6) - LDA $7EF435 : AND.b #$1C : LSR #2 + LDA THLocations JMP DrawDungeonCompassCounts_return_spot CompassCount_Thieves: %DrawConstantNumber(0,8) - LDA $7EF437 : AND.b #$0F + LDA TTLocations JMP DrawDungeonCompassCounts_return_spot CompassCount_Trock: %DrawConstantNumber(1,2) - LDA $7EF439 : LSR #4 + LDA TRLocations JMP DrawDungeonCompassCounts_return_spot CompassCount_Gt: %DrawConstantNumber(2,7) - LDA $7EF436 : LSR #3 + LDA GTLocations JMP DrawDungeonCompassCounts_return_spot -;-------------------------------------------------------------------------------- -; $7EF434 - hhhhdddd - item locations checked -; h - hyrule castle/sewers -; d - palace of darkness -;-------------------------------------------------------------------------------- -; $7EF435 - dddhhhaa - item locations checked -; d - desert palace -; h - tower of hera -; a - agahnim's tower -;-------------------------------------------------------------------------------- -; $7EF436 - gggggeee - item locations checked -; g - ganon's tower -; e - eastern palace -;-------------------------------------------------------------------------------- -; $7EF437 - sssstttt - item locations checked -; s - skull woods -; t - thieves town -;-------------------------------------------------------------------------------- -; $7EF438 - iiiimmmm - item locations checked -; i - ice palace -; m - misery mire -;-------------------------------------------------------------------------------- -; $7EF439 - ttttssss - item locations checked -; t - turtle rock -; s - swamp palace -;-------------------------------------------------------------------------------- diff --git a/contrib.asm b/contrib.asm index 644082f..52adbcd 100644 --- a/contrib.asm +++ b/contrib.asm @@ -78,7 +78,6 @@ ; JML $09A6B6 ; <- 4A6B6 tagalong.asm:1194 (SEP #$30 : RTS) ;} ;================================================================ -!MAP_OVERLAY = "$7EF414" ; [2] Sprite_ShowSolicitedMessageIfPlayerFacing_Alt: { STA $1CF0 @@ -108,11 +107,11 @@ Sprite_ShowSolicitedMessageIfPlayerFacing_Alt: BRA .SayNothing .SahasrahlaDialogs - REP #$20 : LDA.l MapReveal_Sahasrahla : ORA !MAP_OVERLAY : STA !MAP_OVERLAY : SEP #$20 + REP #$20 : LDA.l MapReveal_Sahasrahla : ORA MapOverlay : STA MapOverlay : SEP #$20 JSL DialogSahasrahla : BRA .SayNothing .BombShopGuyDialog - REP #$20 : LDA.l MapReveal_BombShop : ORA !MAP_OVERLAY : STA !MAP_OVERLAY : SEP #$20 + REP #$20 : LDA.l MapReveal_BombShop : ORA MapOverlay : STA MapOverlay : SEP #$20 JSL DialogBombShopGuy .SayNothing diff --git a/cuccostorm.asm b/cuccostorm.asm index b301748..2d40f39 100644 --- a/cuccostorm.asm +++ b/cuccostorm.asm @@ -24,7 +24,7 @@ CuccoStorm: SEP #$30 ; set 8-bit accumulator index registers LDA.l !CUCCO_STORM : BEQ + ; only if storm is on LDA.b $10 : CMP.b #$09 : BNE + ; only if outdoors - LDA.l !LOOP_FRAMES_LOW : AND.b #$7F : BNE + ; check every 128 frames + LDA.l LoopFrames : AND.b #$7F : BNE + ; check every 128 frames - ;==== Find a Cucco @@ -72,4 +72,4 @@ CuccoStorm: ;==== + RTL -;================================================================================ \ No newline at end of file +;================================================================================ diff --git a/dialog.asm b/dialog.asm index 1416d67..13ccc9b 100644 --- a/dialog.asm +++ b/dialog.asm @@ -394,7 +394,7 @@ AgahnimAsksAboutPed: LDA.l InvincibleGanon CMP.b #$06 : BNE .vanilla - LDA.l $7EF300 ; check ped flag + LDA.l OverworldEventData+$80 ; check ped flag AND.b #$40 BNE .vanilla diff --git a/elder.asm b/elder.asm index 00fc5e7..2066d57 100644 --- a/elder.asm +++ b/elder.asm @@ -52,7 +52,7 @@ RTL LDY.b #$01 JSL Sprite_ShowSolicitedMessageIfPlayerFacing_PreserveMessage : BCC .dont_show - LDA !GOAL_COUNTER + LDA GoalCounter CMP GoalItemRequirement : !BLT + JSL.l ActivateGoal + @@ -61,4 +61,4 @@ RTL .done LDA $1A : LSR #5 : AND.b #$01 : STA $0DC0, X RTS - } \ No newline at end of file + } diff --git a/entrances.asm b/entrances.asm index c174505..1ef50c7 100644 --- a/entrances.asm +++ b/entrances.asm @@ -22,7 +22,7 @@ LockAgahnimDoors: .crystalOrUnlock LDA InvertedMode : AND.w #$00FF : BEQ .unlock - LDA $7EF2C3 : AND.w #$0020 : BNE .unlock ; Check if GT overlay is already on or not + LDA OverworldEventData+$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 $7EF2C3 : ORA #$20 : STA $7EF2C3 ; activate GT overlay + LDA OverworldEventData+$43 : ORA #$20 : STA OverworldEventData+$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 $7EF2C7 : ORA.b #$20 : STA.l $7EF2C7 + LDA.l OverworldEventData+$47 : ORA.b #$20 : STA.l OverworldEventData+$47 .done RTL ;-------------------------------------------------------------------------------- diff --git a/events.asm b/events.asm index 96f96a4..dc24221 100644 --- a/events.asm +++ b/events.asm @@ -2,7 +2,7 @@ ; OnLoadOW ;-------------------------------------------------------------------------------- ;OnLoadMap: -; LDA $7EF2DB ; thing we wrote over +; LDA OverworldEventData+$5B ; thing we wrote over ;RTL ;-------------------------------------------------------------------------------- OnPrepFileSelect: @@ -84,8 +84,8 @@ OnAga2Defeated: ;-------------------------------------------------------------------------------- OnFileCreation: TAX ; what we wrote over - LDA StartingEquipment+$4C : STA $700340+$4C ; copy starting equipment swaps to file select screen - LDA StartingEquipment+$4E : STA $700340+$4E + LDA StartingEquipment+$4C : STA SRAMEquipment+$4C ; copy starting equipment swaps to file select screen + LDA StartingEquipment+$4E : STA SRAMEquipment+$4E RTL ;-------------------------------------------------------------------------------- !RNG_ITEM_LOCK_IN = "$7F5090" @@ -126,32 +126,32 @@ OnNewFile: PHX : PHP REP #$20 ; set 16-bit accumulator LDA.l LinkStartingRupees : STA CurrentRupees : STA TargetRupees - LDA.l StartingTime : STA $7EF454 - LDA.l StartingTime+2 : STA $7EF454+2 + LDA.l StartingTime : STA ChallengeTimer + LDA.l StartingTime+2 : STA ChallengeTimer+2 LDX.w #$004E : - ; copy over starting equipment - LDA StartingEquipment, X : STA SRAMEquipment, X + LDA StartingEquipment, X : STA WRAMEquipment, X DEX : DEX BPL - - LDX #$000E : - - LDA SewerKeys, X : STA $7EF4E0, X + LDX #$0008 : - ; copy starting keys to chest key counters in sram + LDA DungeonKeys, X : STA DungeonChestKeys, 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 $7EF061 ; open aga tower curtain - LDA.b #$80 : STA $7EF093 ; open skull woods curtain + 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 $7EF2DB ; pyramid hole already open + LDA.b #$20 : STA OverworldEventData+$5B ; pyramid hole already open + LDA.l PreopenGanonsTower : BEQ + - LDA.b #$20 : STA $7EF2C3 ; Ganons Tower already open + LDA.b #$20 : STA OverworldEventData+$43 ; Ganons Tower already open + LDA StartingSword : STA SwordEquipment ; set starting sword type @@ -235,8 +235,8 @@ PreItemGet: RTL ;-------------------------------------------------------------------------------- PostItemGet: - JML.l MaybeWriteSRAMTrace +RTL ;-------------------------------------------------------------------------------- PostItemAnimation: LDA.b #$00 : STA !ITEM_BUSY ; mark item as finished diff --git a/flipperkill.asm b/flipperkill.asm index 648927b..b7a9c53 100644 --- a/flipperkill.asm +++ b/flipperkill.asm @@ -8,7 +8,7 @@ FlipperKill: LDA $7F5001 : BEQ .done ; skip if we're not marked in danger for softlock LDA $8A : CMP $7F5098 : BEQ .done ; skip if we're on the same screen we entered the water on ;JSL.l KillFairies ; take away fairies - LDA !IGNORE_FAIRIES : ORA.b #$04 : STA !IGNORE_FAIRIES + LDA IgnoreFaeries : ORA.b #$04 : STA IgnoreFaeries LDA.b #$00 : STA CurrentHealth ; kill link LDA.b #$00 : STA $7F5001 ; mark fake flipper softlock as impossible .done @@ -18,9 +18,9 @@ RTL ;-------------------------------------------------------------------------------- IgnoreFairyCheck: LDX.b #$00 ; thing we wrote over - LDA !IGNORE_FAIRIES : BIT.b #$04 : BEQ .normal + LDA IgnoreFaeries : BIT.b #$04 : BEQ .normal - AND.b #$FB : STA !IGNORE_FAIRIES ; clear ignore fairy flag + AND.b #$FB : STA IgnoreFaeries ; clear ignore fairy flag LDA.b #$F0 ; set check to invalid entry RTL .normal diff --git a/floodgatesoftlock.asm b/floodgatesoftlock.asm index 043e422..18b6edf 100644 --- a/floodgatesoftlock.asm +++ b/floodgatesoftlock.asm @@ -5,21 +5,21 @@ FloodGateAndMasterSwordFollowerReset: JSL.l MasterSwordFollowerClear FloodGateReset: LDA.l PersistentFloodgate : BNE + - LDA $7EF2BB : AND.b #$DF : STA $7EF2BB ; reset water outside floodgate - LDA $7EF2FB : AND.b #$DF : STA $7EF2FB ; reset water outside swamp palace - LDA $7EF216 : AND.b #$7F : STA $7EF216 ; clear water inside floodgate - LDA $7EF051 : AND.b #$FE : STA $7EF051 ; clear water front room (room 40) + 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) + FloodGateResetInner: LDA.l Bugfix_SwampWaterLevel : BEQ +++ - LDA $7EF06F : AND.b #$04 : BEQ + ; Check if key in room 55 has been collected. - LDA $7EF356 : 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 #$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 $7EF06E : AND.b #$7F : STA $7EF06E ; clear water room 55 - outer room you shouldn't be able to softlock except in major glitches + 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 $7EF06B : AND.b #$04 : BNE +++ ; Check if key in room 53 has been collected. + LDA RoomData[$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 $7EF06A : AND.b #$7F : STA $7EF06A ; clear water room 53 - inner room with the easy key flood softlock + LDA RoomData[$35].low : AND.b #$7F : STA RoomData[$35].low ; clear water room 53 - inner room with the easy key flood softlock +++ RTL ;================================================================================ diff --git a/flute.asm b/flute.asm index 06b9edf..5e6e82b 100644 --- a/flute.asm +++ b/flute.asm @@ -23,17 +23,17 @@ SpawnHauntedGroveItem: LDA.b #$30 : STA $0F10, Y LDA $22 : !ADD.l .x_offsets, X - AND.b #$F0 : STA $0D10, Y - LDA $23 : ADC.b #$00 : STA $0D30, Y + AND.b #$F0 : STA $0D10, Y + LDA $23 : ADC.b #$00 : STA $0D30, Y LDA $20 : !ADD.b #$16 : AND.b #$F0 : STA $0D00, Y - LDA $21 : ADC.b #$00 : STA $0D20, Y + LDA $21 : ADC.b #$00 : STA $0D20, Y LDA.b #$00 : STA $0F20, Y TYX LDX $8A ; haunted grove (208D0A) - LDA $7EF280, X : AND.b #$40 : BNE + + LDA OverworldEventData, X : AND.b #$40 : BNE + LDA.b #$1B : JSL Sound_SetSfx3PanLong + RTL diff --git a/glitched.asm b/glitched.asm index 203a3cc..76901b2 100644 --- a/glitched.asm +++ b/glitched.asm @@ -16,20 +16,20 @@ GetAgahnimDeath: CMP.b #13 : BNE + ; Agahnim 2 room LDA.l Bugfix_SetWorldOnAgahnimDeath : BEQ ++ LDA.l InvertedMode : BEQ +++ - LDA.b #$00 : STA !DARK_WORLD ; Switch to light world + LDA.b #$00 : STA CurrentWorld ; Switch to light world BRA ++ +++ - LDA.b #$40 : STA !DARK_WORLD ; Switch to dark world + LDA.b #$40 : STA CurrentWorld ; Switch to dark world ++ LDA.b #$01 ; Use Agahnim 2 RTL + ; Elsewhere LDA.l Bugfix_SetWorldOnAgahnimDeath : BEQ ++ LDA.l InvertedMode : BEQ +++ - LDA.b #$40 : STA !DARK_WORLD ; Switch to dark world + LDA.b #$40 : STA CurrentWorld ; Switch to dark world BRA ++ +++ - LDA.b #$00 : STA !DARK_WORLD ; Switch to light world + LDA.b #$00 : STA CurrentWorld ; Switch to light world ; (This will later get flipped to DW when Agahnim 1 ; warps us to the pyramid) ++ diff --git a/goalitem.asm b/goalitem.asm index 474e86e..12287ce 100644 --- a/goalitem.asm +++ b/goalitem.asm @@ -1,7 +1,6 @@ ;-------------------------------------------------------------------------------- ; $7F5010 - Scratch Space (Callee Preserved) ;-------------------------------------------------------------------------------- -!GOAL_COUNTER = "$7EF418" !GOAL_DRAW_ADDRESS = "$7EC72A" ;-------------------------------------------------------------------------------- ; DrawGoalIndicator moved to newhud.asm @@ -68,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 $7EF2DB : AND.b #$20 : BEQ .fail ; require aga2 defeated (pyramid hole open) + LDA.l OverworldEventData+$5B : AND.b #$20 : BEQ .fail ; require aga2 defeated (pyramid hole open) BRA .success ; 03 = crystals and aga 2 .crystals_and_aga - LDA.l $7EF2DB : AND.b #$20 : BEQ .fail ; check aga2 first then bleed in + LDA.l OverworldEventData+$5B : AND.b #$20 : BEQ .fail ; check aga2 first then bleed in ; 04 = crystals only .crystals @@ -82,7 +81,7 @@ CheckGanonVulnerability: ; 05 = require goal item .goal_item - LDA.l !GOAL_COUNTER : CMP GoalItemRequirement + LDA.l GoalCounter : CMP GoalItemRequirement RTS ; 06 = light speed @@ -96,7 +95,6 @@ CheckGanonVulnerability: ; 08 = Crystal bosses but no crystals .bosses_only - ;LDA.l $7EF2DDB : AND.b #$20 : BEQ .fail ; check aga2 JMP CheckForCrystalBossesDefeated ;-------------------------------------------------------------------------------- @@ -140,7 +138,7 @@ CheckAgaForPed: CMP.b #$06 : BNE .vanilla .light_speed - LDA.l $7EF300 ; check ped flag + LDA.l OverworldEventData+$80 ; check ped flag AND.b #$40 BEQ .force_blue_ball @@ -164,8 +162,8 @@ KillGanon: CMP.b #$06 : BNE .exit .light_speed - LDA.l $7EF2DB : ORA.b #$20 : STA.l $7EF2DB ; pyramid hole - LDA.b #$08 : STA.l RoomData[$00].Low ; kill ganon + LDA.l OverworldEventData+$5B : ORA.b #$20 : STA.l OverworldEventData+$5B ; pyramid hole + LDA.b #$08 : STA.l RoomData[$00].high ; kill ganon LDA.b #$02 : STA.l MoonPearlEquipment ; pearl but invisible in menu .exit @@ -197,7 +195,7 @@ CheckForCrystalBossesDefeated: LDA.l DrawHUDDungeonItems_boss_room_ids-4,X TAX - LDA.l $7EF000,X + LDA.l RoomData.l,X AND.w #$0800 BEQ ++ diff --git a/heartpieces.asm b/heartpieces.asm index 4732c84..f7f898f 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 $7EF280, X + LDA OverworldEventData, X RTL ;-------------------------------------------------------------------------------- SaveHeartCollectedStatus: @@ -140,7 +140,7 @@ SaveHeartCollectedStatus: RTL .normal_behavior - LDA $7EF280, X : ORA.b #$40 : STA $7EF280, X + LDA OverworldEventData, X : ORA.b #$40 : STA OverworldEventData, X RTL ;-------------------------------------------------------------------------------- !REDRAW = "$7F5000" @@ -195,7 +195,7 @@ MaybeMarkDigSpotCollected: REP #$20 ; set 16-bit accumulator LDA $8A CMP.w #$2A : BNE + - LDA !HAS_GROVE_ITEM : ORA.w #$0001 : STA !HAS_GROVE_ITEM + LDA HasGroveItem : ORA.w #$0001 : STA HasGroveItem + PLP : PLA RTL diff --git a/inverted.asm b/inverted.asm index 92c57ed..a89d624 100644 --- a/inverted.asm +++ b/inverted.asm @@ -71,7 +71,7 @@ Overworld_CreatePyramidHoleModified: SEP #$30 - LDA $7EF2DB : ORA.b #$20 : STA $7EF2DB + LDA OverworldEventData+$5B : ORA.b #$20 : STA OverworldEventData+$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 OverworldData, X : ORA #$40 : STA $7EF280, X ;set barrier dead + LDA OverworldEventData, X : ORA #$40 : STA OverworldEventData, X ;set barrier dead .done - LDA $7EF280, X ; what we wrote over + LDA OverworldEventData, X ; what we wrote over RTL @@ -187,7 +187,7 @@ RTL TurtleRockPegSolved: LDA.l InvertedMode : AND.w #$00FF : BNE + - LDA.l $7ef287 ; What we wrote over (reading flags for this screen) + LDA.l OverworldEventData+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/maidencrystals.asm b/maidencrystals.asm index e435836..b02ae1b 100644 --- a/maidencrystals.asm +++ b/maidencrystals.asm @@ -21,7 +21,5 @@ MaidenCrystalScript: LDA.b #$08 : STA MapIcons ; Update the map icon to just be Ganon's Tower + - JSL.l MaybeWriteSRAMTrace - JML.l $1ECF35 ; <- F4F35 - sprite_crystal_maiden.asm : 426 ;-------------------------------------------------------------------------------- diff --git a/medallions.asm b/medallions.asm index 56ed04f..e5553e0 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 $7EF2F0 : AND.b #$20 : BNE .untriggered + LDA OverworldEventData+$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 $7EF2C7 : AND.b #$20 : BNE .untriggered + LDA OverworldEventData+$47 : AND.b #$20 : BNE .untriggered ; You have to be in the trigger window. LDY.b #$03 : JSL.l Ancilla_CheckIfEntranceTriggered : BCC .untriggered @@ -73,4 +73,4 @@ MedallionTrigger_Quake: + PLA RTL -;-------------------------------------------------------------------------------- \ No newline at end of file +;-------------------------------------------------------------------------------- diff --git a/msu.asm b/msu.asm index 16259be..5900be2 100644 --- a/msu.asm +++ b/msu.asm @@ -250,7 +250,7 @@ CheckMusicLoadRequest: BRA .check_fallback-3 .lightworld PHA - LDA $7EF300 : AND.b #$40 : BEQ + + LDA OverworldEventData+$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 $7EF2F0 : AND.b #$20 : BEQ .rain + LDA OverworldEventData+$70 : AND.b #$20 : BEQ .rain + LDA ProgressIndicator : CMP.b #$02 : BCS + @@ -517,16 +517,16 @@ PHA : XBA : PHA ; dont save if we already saved recently REP #$20 LDA !MSU_RESUME_TRACK : AND #$00FF : BEQ ++ - LDA !NMI_COUNTER : !SUB !MSU_RESUME_TIME : PHA - LDA !NMI_COUNTER+2 : SBC !MSU_RESUME_TIME+2 : BNE +++ + LDA NMIFrames : !SUB !MSU_RESUME_TIME : PHA + LDA NMIFrames+2 : SBC !MSU_RESUME_TIME+2 : BNE +++ PLA : CMP MSUResumeTimer : !BLT .too_early BRA ++ +++ PLA ++ ; saving - LDA !NMI_COUNTER : STA !MSU_RESUME_TIME - LDA !NMI_COUNTER+2 : STA !MSU_RESUME_TIME+2 + LDA NMIFrames : STA !MSU_RESUME_TIME + LDA NMIFrames+2 : STA !MSU_RESUME_TIME+2 SEP #$20 LDA !MSU_LOADED_TRACK : STA !MSU_RESUME_TRACK @@ -683,8 +683,8 @@ MSUMain: PLX TXA : CMP !MSU_RESUME_TRACK : BNE + ; dont resume if too late REP #$20 - LDA !NMI_COUNTER : !SUB !MSU_RESUME_TIME : PHA - LDA !NMI_COUNTER+2 : SBC !MSU_RESUME_TIME+2 : BNE ++ + LDA NMIFrames : !SUB !MSU_RESUME_TIME : PHA + LDA NMIFrames+2 : SBC !MSU_RESUME_TIME+2 : BNE ++ PLA : CMP MSUResumeTimer : !BGE +++ SEP #$20 LDA !FLAG_RESUME_FADEIN : BRA .done_resume diff --git a/music.asm b/music.asm index 86895e7..ebb5396 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 $7EF300 : AND.b #$40 : BEQ + + LDA OverworldEventData+$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 $7EF300 : AND.b #$40 : BNE .endOfLightWorldChecks + LDA OverworldEventData+$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 $7EF300 : AND.b #$40 : BEQ + + ;LDA OverworldEventData+$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 $7EF2F0 : AND.b #$20 : BNE ++ + LDA OverworldEventData+$70 : AND.b #$20 : BNE ++ LDA.b #$01 : CMP $0131 : BEQ + STA $012D + : BRA .checkInverted diff --git a/newhud.asm b/newhud.asm index 2265023..82c0afb 100644 --- a/newhud.asm +++ b/newhud.asm @@ -58,17 +58,16 @@ SEP #$30 ;================================================================================ ; Draw Goal Item Indicator -!GOAL_COUNTER = "$7EF418" !GOAL_DRAW_ADDRESS = "$7EC72A" ;================================================================================ SEP #$20 LDA.l GoalItemRequirement : BNE + : JMP .done : + ; Star Meter - - LDA.l !GOAL_COUNTER - JSR HudHexToDec3Digit - REP #$20 - + + LDA.l GoalCounter + JSR HudHexToDec3Digit + REP #$20 + LDA.l GoalItemIcon : STA !GOAL_DRAW_ADDRESS ; draw star icon LDX.b $05 : TXA : ORA.w #$2400 : STA !GOAL_DRAW_ADDRESS+2 ; draw 100's digit diff --git a/npcitems.asm b/npcitems.asm index c1a546f..8aa788a 100644 --- a/npcitems.asm +++ b/npcitems.asm @@ -21,44 +21,42 @@ ;UNUSED = "#$40" ;MAGIC_BAT = "#$80" ;-------------------------------------------------------------------------------- -!NPC_FLAGS = "$7EF410" -!NPC_FLAGS_2 = "$7EF411" ItemCheck_FairySword: - LDA !NPC_FLAGS_2 : AND.b #$08 + LDA NpcFlags+1 : AND.b #$08 RTL ItemCheck_SmithSword: - LDA !NPC_FLAGS_2 : AND.b #$04 + LDA NpcFlags+1 : AND.b #$04 RTL ItemCheck_MagicBat: - LDA !NPC_FLAGS_2 : AND.b #$80 + LDA NpcFlags+1 : AND.b #$80 RTL ItemCheck_OldMan: - LDA !NPC_FLAGS : AND.b #$01 : CMP #$01 + LDA NpcFlags : AND.b #$01 : CMP #$01 RTL ItemCheck_ZoraKing: - LDA !NPC_FLAGS : AND.b #$02 + LDA NpcFlags : AND.b #$02 RTL ItemCheck_SickKid: - LDA !NPC_FLAGS : AND.b #$04 + LDA NpcFlags : AND.b #$04 RTL ItemCheck_TreeKid: - LDA !NPC_FLAGS : AND.b #$08 ; FluteBoy_Chillin - 73: LDA FluteEquipment + LDA NpcFlags : AND.b #$08 ; FluteBoy_Chillin - 73: LDA FluteEquipment RTL ItemCheck_TreeKid2: - LDA !NPC_FLAGS : AND.b #$08 : LSR #$02 ; FluteAardvark_InitialStateFromFluteState - 225: LDA FluteEquipment : AND.b #$03 + LDA NpcFlags : AND.b #$08 : LSR #$02 ; FluteAardvark_InitialStateFromFluteState - 225: LDA FluteEquipment : AND.b #$03 RTL ItemCheck_TreeKid3: JSL $0DD030 ; FluteAardvark_Draw - thing we wrote over - LDA !NPC_FLAGS : AND.b #$08 + LDA NpcFlags : AND.b #$08 BEQ .normal BRA .done LDA.b #$05 @@ -68,16 +66,16 @@ ItemCheck_TreeKid3: RTL ItemCheck_Sahasrala: - LDA !NPC_FLAGS : AND.b #$10 + LDA NpcFlags : AND.b #$10 RTL ItemCheck_Library: - LDA !NPC_FLAGS : AND.b #$80 + LDA NpcFlags : AND.b #$80 RTL ItemCheck_Mushroom: - LDA !NPC_FLAGS_2 : ROL #4 ; does the same thing as below -; LDA !NPC_FLAGS_2 : AND.b #$10 : BEQ .clear + LDA NpcFlags+1 : ROL #4 ; does the same thing as below +; LDA NpcFlags+1 : AND.b #$10 : BEQ .clear ; SEC ;RTL ; .clear @@ -85,7 +83,7 @@ ItemCheck_Mushroom: RTL ItemCheck_Powder: - LDA !NPC_FLAGS_2 : AND.b #$20 + LDA NpcFlags+1 : AND.b #$20 RTL ItemCheck_Catfish: @@ -101,60 +99,60 @@ ItemCheck_Catfish: ;.oursNewers ;LDA #$00 : RTL ; give item ;.junk - LDA !NPC_FLAGS : AND.b #$20 + LDA NpcFlags : AND.b #$20 RTL ;-------------------------------------------------------------------------------- ItemSet_FairySword: - PHA : LDA !NPC_FLAGS_2 : ORA.b #$08 : STA !NPC_FLAGS_2 : PLA + PHA : LDA NpcFlags+1 : ORA.b #$08 : STA NpcFlags+1 : PLA RTL ItemSet_SmithSword: - PHA : LDA !NPC_FLAGS_2 : ORA.b #$04 : STA !NPC_FLAGS_2 : PLA + PHA : LDA NpcFlags+1 : ORA.b #$04 : STA NpcFlags+1 : PLA RTL ItemSet_MagicBat: - PHA : LDA !NPC_FLAGS_2 : ORA.b #$80 : STA !NPC_FLAGS_2 : PLA + PHA : LDA NpcFlags+1 : ORA.b #$80 : STA NpcFlags+1 : PLA RTL ItemSet_OldMan: JSL.l Link_ReceiveItem ; thing we wrote over - PHA : LDA !NPC_FLAGS : ORA.b #$01 : STA !NPC_FLAGS : PLA + PHA : LDA NpcFlags : ORA.b #$01 : STA NpcFlags : PLA RTL ItemSet_ZoraKing: ;JSL $1DE1AA ; Sprite_SpawnFlippersItem ; thing we wrote over - PHA : LDA !NPC_FLAGS : ORA.b #$02 : STA !NPC_FLAGS : PLA + PHA : LDA NpcFlags : ORA.b #$02 : STA NpcFlags : PLA RTL ItemSet_SickKid: JSL.l Link_ReceiveItem ; thing we wrote over - PHA : LDA !NPC_FLAGS : ORA.b #$04 : STA !NPC_FLAGS : PLA + PHA : LDA NpcFlags : ORA.b #$04 : STA NpcFlags : PLA RTL ItemSet_TreeKid: JSL.l Link_ReceiveItem ; thing we wrote over - PHA : LDA !NPC_FLAGS : ORA.b #$08 : STA !NPC_FLAGS : PLA + PHA : LDA NpcFlags : ORA.b #$08 : STA NpcFlags : PLA RTL ItemSet_Sahasrala: JSL.l Link_ReceiveItem ; thing we wrote over - PHA : LDA !NPC_FLAGS : ORA.b #$10 : STA !NPC_FLAGS : PLA + PHA : LDA NpcFlags : ORA.b #$10 : STA NpcFlags : PLA RTL ItemSet_Catfish: ;JSL $00D52D ; GetAnimatedSpriteTile.variable ; thing we wrote over ;JSL.l LoadCatfishItemGFX - PHA : LDA !NPC_FLAGS : ORA.b #$20 : STA !NPC_FLAGS : PLA + PHA : LDA NpcFlags : ORA.b #$20 : STA NpcFlags : PLA RTL ItemSet_Library: JSL.l Link_ReceiveItem ; thing we wrote over - PHA : LDA !NPC_FLAGS : ORA.b #$80 : STA !NPC_FLAGS : PLA + PHA : LDA NpcFlags : ORA.b #$80 : STA NpcFlags : PLA RTL ItemSet_Mushroom: PHA - LDA !NPC_FLAGS_2 : ORA.b #$10 : STA !NPC_FLAGS_2 + LDA NpcFlags+1 : ORA.b #$10 : STA NpcFlags+1 LDY $0E80, X ; Retrieve stored item type BNE + ; if for any reason the item value is 0 reload it, just in case @@ -166,7 +164,7 @@ ItemSet_Mushroom: RTL ItemSet_Powder: - PHA : LDA !NPC_FLAGS_2 : ORA.b #$20 : STA !NPC_FLAGS_2 : PLA + PHA : LDA NpcFlags+1 : ORA.b #$20 : STA NpcFlags+1 : PLA RTL ;================================================================================ diff --git a/openmode.asm b/openmode.asm index c5ddfff..94b0c55 100644 --- a/openmode.asm +++ b/openmode.asm @@ -15,7 +15,7 @@ InitOpenMode: 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 $7EF29B : ORA.b #$20 : STA $7EF29B ; open castle gate + LDA OverworldEventData+$1B : ORA.b #$20 : STA OverworldEventData+$1B ; open castle gate JSL MaybeSetPostAgaWorldState + RTL @@ -23,7 +23,7 @@ RTL MaybeSetPostAgaWorldState: LDA.l InstantPostAgaWorldState : BEQ + ; Skip if not enabled LDA.b #$03 : STA ProgressIndicator ; Go to post-aga phase - LDA $7EF282 : ORA.b #$20 : STA $7EF282 ; make lumberjack tree accessible + LDA OverworldEventData+$02 : ORA.b #$20 : STA OverworldEventData+$02 ; make lumberjack tree accessible + RTL ;-------------------------------------------------------------------------------- diff --git a/pendantcrystalhud.asm b/pendantcrystalhud.asm index e0fe5a9..a0407b7 100644 --- a/pendantcrystalhud.asm +++ b/pendantcrystalhud.asm @@ -2,7 +2,7 @@ ; Pendant / Crystal HUD Fix ;-------------------------------------------------------------------------------- ;CheckPendantHUD: -; LDA !HUD_FLAG : CMP.b #$40 ; check for hud flag instead +; LDA HudFlag : CMP.b #$40 ; check for hud flag instead ;RTL ;================================================================================ FlipLWDWFlag: @@ -52,17 +52,16 @@ GetCrystalNumber: PLX RTL ;================================================================================ -!MAP_OVERLAY = "$7EF414" ; [2] OverworldMap_CheckObject: PHX ;CPX.b #$01 : BNE + : JMP ++ : + : JMP .fail LDA CurrentWorld : AND.b #$40 : BNE + ;LW Map LDA.l MapMode : BEQ +++ - LDA MapField : ORA !MAP_OVERLAY : AND.b #$01 : BNE +++ + LDA MapField : ORA MapOverlay : AND.b #$01 : BNE +++ PHX LDA.l .lw_map_offsets, X : TAX ; put map offset into X - LDA MapField, X : ORA !MAP_OVERLAY, X + LDA MapField, X : ORA MapOverlay, X PLX AND.l .lw_map_masks, X : BNE +++ JMP .fail @@ -73,10 +72,10 @@ OverworldMap_CheckObject: + ;DW Map LDA.l MapMode : BEQ +++ - LDA MapField : ORA !MAP_OVERLAY : AND.b #$02 : BNE +++ + LDA MapField : ORA MapOverlay : AND.b #$02 : BNE +++ PHX LDA.l .dw_map_offsets, X : TAX ; put map offset into X - LDA.l MapField, X : ORA !MAP_OVERLAY, X + LDA.l MapField, X : ORA MapOverlay, X PLX AND.l .dw_map_masks, X : BNE +++ JMP .fail @@ -192,7 +191,7 @@ RTL ShowDungeonItems: LDA $040C : AND.w #$00FF : CMP.w #$00FF : BNE + : RTL : + ; return normal result if outdoors or in a cave ;LDA $F0 : AND.w #$0020 ; check for select - LDA !HUD_FLAG : AND.w #$0020 ; check hud flag + LDA HudFlag : AND.w #$0020 ; check hud flag BEQ + : LDA.w #$0000 : RTL : + ; if set, send the zero onwards LDA $040C : AND.w #$00FF : CMP.w #$00FF ; original logic RTL @@ -205,7 +204,7 @@ UpdateKeys: LSR : TAX ; get dungeon index and store to X LDA CurrentSmallKeys ; load current key count - STA SewerKeys, X ; save to main counts + STA DungeonKeys, X ; save to main counts CPX.b #$00 : BNE + STA HyruleCastleKeys ; copy HC to sewers @@ -365,7 +364,7 @@ DrawHUDDungeonItems: DEX : DEX : BPL -- - LDA.l !HUD_FLAG : AND.w #$0020 : BEQ + + LDA.l HudFlag : AND.w #$0020 : BEQ + JMP .maps_and_compasses @@ -438,7 +437,7 @@ DrawHUDDungeonItems: .next_boss_kill LDX.w .boss_room_ids,Y - LDA.l $7EF000,X + LDA.l RoomData.l,X AND.w #$0800 BEQ ..skip_boss_kill diff --git a/retro.asm b/retro.asm index 477f4a8..eca961f 100644 --- a/retro.asm +++ b/retro.asm @@ -5,7 +5,7 @@ IsItemAvailable: CPX.b #$04 : BNE .finite LDA.b #$01 : RTL .finite - LDA $7EF33F, X + LDA WRAMEquipment-1, X RTL LoadBombCount: LDA !INFINITE_BOMBS : BNE .infinite diff --git a/shopkeeper.asm b/shopkeeper.asm index 8b29c55..b73648c 100644 --- a/shopkeeper.asm +++ b/shopkeeper.asm @@ -266,8 +266,6 @@ RTS ;!SHOP_INVENTORY, X ;[id][$lo][$hi][purchase_counter] ;-------------------------------------------------------------------------------- -;PurchaseCounts = "$7EF51A" -;-------------------------------------------------------------------------------- Shopkeeper_UploadVRAMTilesLong: JSR.w Shopkeeper_UploadVRAMTiles RTL @@ -587,7 +585,6 @@ db #$01, #$02, #$04 ;-------------------- ;!SHOP_ID = "$7F5050" ;!SHOP_SRAM_INDEX = "$7F5062" -;PurchaseCounts = "$7EF51A" ;-------------------- Setup_ShopItemCollisionHitbox: ;The complications with XBA are to handle the fact that nintendo likes to store diff --git a/spriteswap.asm b/spriteswap.asm index def5ead..5075eac 100644 --- a/spriteswap.asm +++ b/spriteswap.asm @@ -32,7 +32,7 @@ SpriteSwap_Palette_ArmorAndGloves: LDA !SPRITE_SWAP : BNE .continue LDA.b #$10 : STA $BC ; Load Original Sprite Location REP #$21 - LDA $7EF35B + LDA ArmorEquipment JSL $1BEDFF ; Read Original Palette Code RTL .part_two @@ -51,7 +51,7 @@ SpriteSwap_Palette_ArmorAndGloves: REP #$20 ; set 16-bit accumulator ; Check what Link's armor value is. - LDA $7EF35B : AND.w #$00FF : TAX + LDA ArmorEquipment : AND.w #$00FF : TAX ; (DEC06, X) diff --git a/stats.asm b/stats.asm index 30f6cb7..5003cfb 100644 --- a/stats.asm +++ b/stats.asm @@ -2,178 +2,36 @@ ; Stat Tracking ;================================================================================ ; $7EF420 - $7EF468 - Stat Tracking +; +; See sram.asm for adresses and documentation of stat values ;-------------------------------------------------------------------------------- -; $7EF420 - bonk counter -;-------------------------------------------------------------------------------- -; $7EF421 yyyyyaaa -; y - y item counter -; a - a item counter -;-------------------------------------------------------------------------------- -; $7EF422 ssshhccc -; s - sword counter -; h - shield counter -; c - crystal counter -;-------------------------------------------------------------------------------- -; $7EF423 - item counter -;-------------------------------------------------------------------------------- -; $7EF424 mmkkkkkk -; m - mail counter -; k - small keys -;-------------------------------------------------------------------------------- -; $7EF425w[2] 1111 2222 3333 4444 -; 1 - lvl 1 sword bosses -; 2 - lvl 2 sword bosses -; 3 - lvl 3 sword bosses -; 4 - lvl 4 sword bosses -;-------------------------------------------------------------------------------- -; $7EF427 kkkkcccc -; k - big keys -; c - big chests -;-------------------------------------------------------------------------------- -; $7EF428 mmmmcccc -; k - maps -; c - compases -;-------------------------------------------------------------------------------- -; $7EF429 bbbb--pp -; b - heart containers -; p - pendant upgrades -;-------------------------------------------------------------------------------- -; $7EF42A b-sccccc -; b - bomb acquired -; s - silver arrow bow acquired -; c - chests before gtower big key -;-------------------------------------------------------------------------------- -; $7EF42Bw[2] - rupees spent -;-------------------------------------------------------------------------------- -; $7EF42D - s&q counter -;-------------------------------------------------------------------------------- -; $7EF42Ew[2] - loop frame counter (low) -;-------------------------------------------------------------------------------- -; $7EF430w[2] - loop frame counter (high) -;-------------------------------------------------------------------------------- -; $7EF432 - locations before boots -;-------------------------------------------------------------------------------- -; $7EF433 - locations before mirror -;-------------------------------------------------------------------------------- -; $7EF434 - hhhhdddd - item locations checked -; h - hyrule castle -; d - palace of darkness -;-------------------------------------------------------------------------------- -; $7EF435 - dddhhhaa - item locations checked -; d - desert palace -; h - tower of hera -; a - agahnim's tower -;-------------------------------------------------------------------------------- -; $7EF436 - gggggeee - item locations checked -; g - ganon's tower -; e - eastern palace -;-------------------------------------------------------------------------------- -; $7EF437 - sssstttt - item locations checked -; s - skull woods -; t - thieves town -;-------------------------------------------------------------------------------- -; $7EF438 - iiiimmmm - item locations checked -; i - ice palace -; m - misery mire -;-------------------------------------------------------------------------------- -; $7EF439 - ttttssss - item locations checked -; t - turtle rock -; s - swamp palace -;-------------------------------------------------------------------------------- -; $7EF43A - times mirrored outdoors -;-------------------------------------------------------------------------------- -; $7EF43B - times mirrored in dungeons -;-------------------------------------------------------------------------------- -; $7EF43Cw[2] - screen transition counter -;-------------------------------------------------------------------------------- -; $7EF43Ew[2] - nmi frame counter (low) -;-------------------------------------------------------------------------------- -; $7EF440w[2] - nmi frame counter (high) -;-------------------------------------------------------------------------------- -; $7EF442 - chest counter -;-------------------------------------------------------------------------------- -; $7EF443 - lock stats -;-------------------------------------------------------------------------------- -; $7EF444w[2] - item menu frame counter (low) -;-------------------------------------------------------------------------------- -; $7EF446w[2] - item menu frame counter (high) -;-------------------------------------------------------------------------------- -; $7EF448 - ---hhhhh -; h - heart pieces -;-------------------------------------------------------------------------------- -; $7EF449 - death counter -;-------------------------------------------------------------------------------- -; $7EF44A - reserved -;-------------------------------------------------------------------------------- -; $7EF44B - flute counter -;-------------------------------------------------------------------------------- -; $7EF44Cl[3] - Unused -;-------------------------------------------------------------------------------- -; $7EF44Fl[3] - Unused -;-------------------------------------------------------------------------------- -; $7EF452 - sssscccc -; s - swordless bosses -; c - capacity upgrades -;-------------------------------------------------------------------------------- -; $7EF453 - fairy revival counter -;-------------------------------------------------------------------------------- -; $7EF454w[2] - challenge timer (low) -;-------------------------------------------------------------------------------- -; $7EF456w[2] - challenge timer (high) -;-------------------------------------------------------------------------------- -; $7EF458w[2] - sword timestamp (low) -;-------------------------------------------------------------------------------- -; $7EF45Aw[2] - sword timestamp (high) -;-------------------------------------------------------------------------------- -; $7EF45Cw[2] - boots timestamp (low) -;-------------------------------------------------------------------------------- -; $7EF45Ew[2] - boots timestamp (high) -;-------------------------------------------------------------------------------- -; $7EF460w[2] - flute timestamp (low) -;-------------------------------------------------------------------------------- -; $7EF462w[2] - flute timestamp (high) -;-------------------------------------------------------------------------------- -; $7EF464w[2] - mirror timestamp (low) -;-------------------------------------------------------------------------------- -; $7EF466w[2] - mirror timestamp (high) -;-------------------------------------------------------------------------------- -; $7EF468 - chest turn counter -;-------------------------------------------------------------------------------- - -;-------------------------------------------------------------------------------- -!LOCK_STATS = "$7EF443" -;-------------------------------------------------------------------------------- -!BONK_COUNTER = "$7EF420" IncrementBonkCounter: - LDA !LOCK_STATS : BNE + - LDA !BONK_COUNTER : INC + LDA StatsLocked : BNE + + LDA BonkCounter : INC CMP.b #100 : BEQ + ; decimal 100 - STA !BONK_COUNTER + STA BonkCounter + RTL ;-------------------------------------------------------------------------------- -!SAVE_COUNTER = "$7EF42D" StatSaveCounter: PHA - LDA !LOCK_STATS : BNE + + LDA StatsLocked : BNE + LDA $10 : CMP.b #$17 : BNE + ; not a proper s&q, link probably died - LDA !SAVE_COUNTER : INC + LDA SaveQuitCounter : INC CMP.b #100 : BEQ + ; decimal 100 - STA !SAVE_COUNTER + STA SaveQuitCounter + PLA RTL ;-------------------------------------------------------------------------------- -!SAVE_COUNTER = "$7EF42D" DecrementSaveCounter: PHA - LDA !LOCK_STATS : BNE + - LDA !SAVE_COUNTER : DEC : STA !SAVE_COUNTER + LDA StatsLocked : BNE + + LDA SaveQuitCounter : DEC : STA SaveQuitCounter + PLA RTL ;-------------------------------------------------------------------------------- -!TRANSITION_COUNTER = "$7EF43C" DungeonHoleWarpTransition: LDA $01C31F, X BRA StatTransitionCounter @@ -200,19 +58,18 @@ DungeonExitTransition: LDA.b #$0F : STA $10 ; stop running through the transition StatTransitionCounter: PHA : PHP - LDA !LOCK_STATS : BNE + + LDA StatsLocked : BNE + REP #$20 ; set 16-bit accumulator - LDA !TRANSITION_COUNTER : INC + LDA ScreenTransitions : INC CMP.w #999 : BEQ + ; decimal 999 - STA !TRANSITION_COUNTER + STA ScreenTransitions + PLP : PLA RTL ;-------------------------------------------------------------------------------- -!FLUTE_COUNTER = "$7EF44B" IncrementFlute: - LDA !LOCK_STATS : BNE + - LDA !FLUTE_COUNTER : INC : STA !FLUTE_COUNTER + LDA StatsLocked : BNE + + LDA FluteCounter : INC : STA FluteCounter + JSL.l StatTransitionCounter ; also increment transition counter RTL @@ -220,7 +77,7 @@ RTL IncrementSmallKeys: STA CurrentSmallKeys ; thing we wrote over, write small key count PHX - LDA !LOCK_STATS : BNE + + LDA StatsLocked : BNE + JSL AddInventory_incrementKeyLong + JSL.l UpdateKeys @@ -232,7 +89,7 @@ RTL IncrementSmallKeysNoPrimary: STA CurrentSmallKeys ; thing we wrote over, write small key count PHX - LDA !LOCK_STATS : BNE + + LDA StatsLocked : BNE + JSL AddInventory_incrementKeyLong + JSL.l UpdateKeys @@ -270,7 +127,7 @@ CountChestKey: ; called by neighbor functions INC ; combines HC and Sewer counts + TAX .count - LDA $7EF4E0, X : INC : STA $7EF4E0, X + LDA DungeonChestKeys, X : INC : STA DungeonChestKeys, X .end PLX : PLA RTS @@ -292,66 +149,59 @@ RTL ;-------------------------------------------------------------------------------- IncrementAgahnim2Sword: PHA - LDA !LOCK_STATS : BNE + + LDA StatsLocked : BNE + JSL AddInventory_incrementBossSwordLong + PLA RTL ;-------------------------------------------------------------------------------- -!DEATH_COUNTER = "$7EF449" IncrementDeathCounter: PHA - LDA !LOCK_STATS : BNE + + LDA StatsLocked : BNE + LDA CurrentHealth : BNE + ; link is still alive, skip - LDA !DEATH_COUNTER : INC : STA !DEATH_COUNTER - ;JSL.l DecrementSaveCounter + LDA DeathCounter : INC : STA DeathCounter + PLA RTL ;-------------------------------------------------------------------------------- -!FAIRY_COUNTER = "$7EF453" IncrementFairyRevivalCounter: STA BottleContents, X ; thing we wrote over PHA - LDA !LOCK_STATS : BNE + - LDA !FAIRY_COUNTER : INC : STA !FAIRY_COUNTER + LDA StatsLocked : BNE + + LDA FaerieRevivalCounter : INC : STA FaerieRevivalCounter + PLA RTL ;-------------------------------------------------------------------------------- -!CHESTTURN_COUNTER = "$7EF468" IncrementChestTurnCounter: PHA - LDA !LOCK_STATS : BNE + - LDA !CHESTTURN_COUNTER : INC : STA !CHESTTURN_COUNTER + LDA StatsLocked : BNE + + LDA ChestTurnCounter : INC : STA ChestTurnCounter + PLA RTL ;-------------------------------------------------------------------------------- -!CHEST_COUNTER = "$7EF442" IncrementChestCounter: LDA.b #$01 : STA $02E9 ; thing we wrote over PHA - LDA !LOCK_STATS : BNE + - LDA !CHEST_COUNTER : INC : STA !CHEST_COUNTER + LDA StatsLocked : BNE + + LDA ChestsOpened : INC : STA ChestsOpened + PLA RTL ;-------------------------------------------------------------------------------- -!CHEST_COUNTER = "$7EF442" DecrementChestCounter: PHA - LDA !LOCK_STATS : BNE + - LDA !CHEST_COUNTER : DEC : STA !CHEST_COUNTER + LDA StatsLocked : BNE + + LDA ChestsOpened : DEC : STA ChestsOpened + PLA RTL ;-------------------------------------------------------------------------------- -!ITEM_TOTAL = "$7EF423" DecrementItemCounter: PHA - LDA !LOCK_STATS : BNE + - LDA !ITEM_TOTAL : DEC : STA !ITEM_TOTAL + LDA StatsLocked : BNE + + LDA TotalItemCounter : DEC : STA TotalItemCounter + PLA RTL @@ -359,38 +209,36 @@ RTL IncrementBigChestCounter: JSL.l Dungeon_SaveRoomQuadrantData ; thing we wrote over PHA - LDA !LOCK_STATS : BNE + - %BottomHalf($7EF427) + LDA StatsLocked : BNE + + %BottomHalf(BigKeysBigChests) + PLA RTL ;-------------------------------------------------------------------------------- -!DAMAGE_COUNTER = $7EF46A -!MAGIC_COUNTER = $7EF46C IncrementDamageTakenCounter_Eight: STA.l CurrentHealth PHA : PHP - LDA !LOCK_STATS : BNE + + LDA StatsLocked : BNE + REP #$21 - LDA.l !DAMAGE_COUNTER + LDA.l DamageCounter ADC.w #$0008 BCC ++ LDA.w #$FFFF -++ STA.l !DAMAGE_COUNTER +++ STA.l DamageCounter + PLP PLA RTL IncrementDamageTakenCounter_Arb: PHP - LDA !LOCK_STATS : BNE + + LDA StatsLocked : BNE + REP #$21 LDA.b $00 AND.w #$00FF - ADC.l !DAMAGE_COUNTER + ADC.l DamageCounter BCC ++ LDA.w #$FFFF -++ STA.l !DAMAGE_COUNTER +++ STA.l DamageCounter + PLP LDA.l CurrentHealth @@ -401,64 +249,61 @@ IncrementMagicUseCounter: IncrementMagicUseCounterByrna: PHA : PHP - LDA !LOCK_STATS : BNE + + LDA StatsLocked : BNE + REP #$21 LDA.b $00 AND.w #$00FF - ADC.l !MAGIC_COUNTER + ADC.l MagicCounter BCC ++ LDA.w #$FFFF -++ STA.l !MAGIC_COUNTER +++ STA.l MagicCounter + PLP : PLA RTL IncrementMagicUseCounterOne: - LDA !LOCK_STATS : BNE + + LDA StatsLocked : BNE + REP #$20 - LDA.l !MAGIC_COUNTER + LDA.l MagicCounter INC BEQ ++ - STA.l !MAGIC_COUNTER + STA.l MagicCounter ++ SEP #$20 + LDA.l CurrentMagic RTL ;-------------------------------------------------------------------------------- -!OW_MIRROR_COUNTER = "$7EF43A" IncrementOWMirror: PHA - LDA !LOCK_STATS : BNE + + LDA StatsLocked : BNE + LDA CurrentWorld : BEQ + ; only do this for DW->LW - LDA !OW_MIRROR_COUNTER : INC : STA !OW_MIRROR_COUNTER + LDA OverworldMirrors : INC : STA OverworldMirrors + PLA JMP StatTransitionCounter ;-------------------------------------------------------------------------------- -!UW_MIRROR_COUNTER = "$7EF43B" IncrementUWMirror: PHA LDA.b #$00 : STA $7F5035 ; bandaid patch bug with mirroring away from text - LDA !LOCK_STATS : BNE + + LDA StatsLocked : BNE + LDA $040C : CMP #$FF : BEQ + ; skip if we're in a cave or house - LDA !UW_MIRROR_COUNTER : INC : STA !UW_MIRROR_COUNTER + LDA UnderworldMirrors : INC : STA UnderworldMirrors JSL.l StatTransitionCounter + PLA JSL.l Dungeon_SaveRoomData ; thing we wrote over RTL ;-------------------------------------------------------------------------------- -!SPENT_RUPEES = "$7EF42B" IncrementSpentRupees: DEC A : BPL .subtractRupees - LDA.w #$0000 : STA $7EF + LDA.w #$0000 : STA TargetRupees RTL .subtractRupees PHA : PHP - LDA !LOCK_STATS : AND.w #$00FF : BNE + - LDA !SPENT_RUPEES : INC + LDA StatsLocked : AND.w #$00FF : BNE + + LDA RupeesSpent : INC CMP.w #9999 : BEQ + ; decimal 9999 - STA !SPENT_RUPEES + STA RupeesSpent + PLP : PLA RTL @@ -473,53 +318,39 @@ IndoorSubtileTransitionCounter: STZ $0642 JMP StatTransitionCounter ;-------------------------------------------------------------------------------- -!CHEST_COUNTER = "$7EF442" -!MAIL_COUNTER = "$7EF424" ; mmkkkkkk !BOSS_KILLS = "$7F5037" -!SWORD_KILLS_1 = "$7EF425" -!SWORD_KILLS_2 = "$7EF426" -!GTOWER_PRE_BIG_KEY = "$7EF42A" ; ---ccccc !NONCHEST_COUNTER = "$7F503E" -!SAVE_COUNTER = "$7EF42D" -!TRANSITION_COUNTER = "$7EF43C" -!NMI_COUNTER = "$7EF43E" -!LOOP_COUNTER = "$7EF42E" !LAG_TIME = "$7F5038" !RUPEES_COLLECTED = "$7F503C" -!ITEM_TOTAL = "$7EF423" StatsFinalPrep: PHA : PHX : PHP SEP #$30 ; set 8-bit accumulator and index registers - LDA !LOCK_STATS : BNE .ramPostOnly - INC : STA !LOCK_STATS + LDA StatsLocked : BNE .ramPostOnly + INC : STA StatsLocked JSL.l AddInventory_incrementBossSwordLong - LDA !MAIL_COUNTER : !ADD #$40 : STA !MAIL_COUNTER ; add green mail to mail count - - ;LDA !GTOWER_PRE_BIG_KEY : DEC : AND #$1F : TAX - ;LDA !GTOWER_PRE_BIG_KEY : AND #$E0 : STA !GTOWER_PRE_BIG_KEY - ;TXA : ORA !GTOWER_PRE_BIG_KEY : STA !GTOWER_PRE_BIG_KEY + LDA HighestMail : INC : STA HighestMail ; add green mail to mail count - LDA !TRANSITION_COUNTER : DEC : STA !TRANSITION_COUNTER ; remove extra transition from exiting gtower via duck + LDA ScreenTransitions : DEC : STA ScreenTransitions ; remove extra transition from exiting gtower via duck .ramPostOnly - LDA !SWORD_KILLS_1 : LSR #4 : !ADD !SWORD_KILLS_1 : STA !BOSS_KILLS - LDA !SWORD_KILLS_2 : LSR #4 : !ADD !SWORD_KILLS_2 : !ADD !BOSS_KILLS : AND #$0F : STA !BOSS_KILLS + LDA SwordBossKills : LSR #4 : !ADD SwordBossKills : STA !BOSS_KILLS + LDA SwordBossKills+1 : LSR #4 : !ADD SwordBossKills+1 : !ADD !BOSS_KILLS : AND #$0F : STA !BOSS_KILLS - LDA !NMI_COUNTER : !SUB !LOOP_COUNTER : STA !LAG_TIME - LDA !NMI_COUNTER+1 : SBC !LOOP_COUNTER+1 : STA !LAG_TIME+1 - LDA !NMI_COUNTER+2 : SBC !LOOP_COUNTER+2 : STA !LAG_TIME+2 - LDA !NMI_COUNTER+3 : SBC !LOOP_COUNTER+3 : STA !LAG_TIME+3 + LDA NMIFrames : !SUB LoopFrames : STA !LAG_TIME + LDA NMIFrames+1 : SBC LoopFrames+1 : STA !LAG_TIME+1 + LDA NMIFrames+2 : SBC LoopFrames+2 : STA !LAG_TIME+2 + LDA NMIFrames+3 : SBC LoopFrames+3 : STA !LAG_TIME+3 - LDA !SPENT_RUPEES : !ADD CurrentRupees : STA !RUPEES_COLLECTED - LDA !SPENT_RUPEES+1 : ADC $7EF363 : STA !RUPEES_COLLECTED+1 + LDA RupeesSpent : !ADD CurrentRupees : STA !RUPEES_COLLECTED + LDA RupeesSpent+1 : ADC CurrentRupees+1 : STA !RUPEES_COLLECTED+1 - LDA !ITEM_TOTAL : !SUB !CHEST_COUNTER : STA !NONCHEST_COUNTER + LDA TotalItemCounter : !SUB ChestsOpened : STA !NONCHEST_COUNTER .done PLP : PLX : PLA diff --git a/stats/statConfig.asm b/stats/statConfig.asm index d921b94..d3b8c29 100755 --- a/stats/statConfig.asm +++ b/stats/statConfig.asm @@ -1,21 +1,21 @@ ;(address, type, shiftRight, bits, digits, xPos, lineNumber) -%AddStat($7EF458, 1, 0, 32, 4, !FIRST_SWORD_X, !FIRST_SWORD_Y) -%AddStat($7EF45C, 1, 0, 32, 4, !PEGASUS_BOOTS_X, !PEGASUS_BOOTS_Y) -%AddStat($7EF460, 1, 0, 32, 4, !FLUTE_X, !FLUTE_Y) -%AddStat($7EF464, 1, 0, 32, 4, !MIRROR_X, !MIRROR_Y) -%AddStat($7EF452, 0, 4, 04, 2, !SWORDLESS_X, !SWORDLESS_Y) -%AddStat($7EF425, 0, 4, 04, 2, !FIGHTERS_SWORD_X, !FIGHTERS_SWORD_Y) -%AddStat($7EF425, 0, 0, 04, 2, !MASTER_SWORD_X, !MASTER_SWORD_Y) -%AddStat($7EF426, 0, 4, 04, 2, !TEMPERED_SWORD_X, !TEMPERED_SWORD_Y) -%AddStat($7EF426, 0, 0, 04, 2, !GOLD_SWORD_X, !GOLD_SWORD_Y) -%AddStat($7EF46A, 0, 0, 16, 5, !DAMAGETAKEN_X, !DAMAGETAKEN_Y) -%AddStat($7EF46C, 0, 0, 16, 5, !MAGICUSED_X, !MAGICUSED_Y) -%AddStat($7EF420, 0, 0, 08, 3, !BONKS_X, !BONKS_Y) -%AddStat($7EF42D, 0, 0, 08, 2, !SAVE_AND_QUITS_X, !SAVE_AND_QUITS_Y) -%AddStat($7EF449, 0, 0, 08, 2, !DEATHS_X, !DEATHS_Y) -%AddStat($7EF453, 0, 0, 08, 3, !FAERIE_REVIVALS_X, !FAERIE_REVIVALS_Y) -%AddStat($7EF444, 1, 8, 32, 4, !TOTAL_MENU_TIME_X, !TOTAL_MENU_TIME_Y) +%AddStat(SwordTime, 1, 0, 32, 4, !FIRST_SWORD_X, !FIRST_SWORD_Y) +%AddStat(BootsTime, 1, 0, 32, 4, !PEGASUS_BOOTS_X, !PEGASUS_BOOTS_Y) +%AddStat(FluteTime, 1, 0, 32, 4, !FLUTE_X, !FLUTE_Y) +%AddStat(MirrorTime, 1, 0, 32, 4, !MIRROR_X, !MIRROR_Y) +%AddStat(SwordlessBossKills, 0, 0, 08, 2, !SWORDLESS_X, !SWORDLESS_Y) +%AddStat(SwordBossKills, 0, 4, 04, 2, !FIGHTERS_SWORD_X, !FIGHTERS_SWORD_Y) +%AddStat(SwordBossKills, 0, 0, 04, 2, !MASTER_SWORD_X, !MASTER_SWORD_Y) +%AddStat(SwordBossKills+1, 0, 4, 04, 2, !TEMPERED_SWORD_X, !TEMPERED_SWORD_Y) +%AddStat(SwordBossKills+1, 0, 0, 04, 2, !GOLD_SWORD_X, !GOLD_SWORD_Y) +%AddStat(DamageCounter, 0, 0, 16, 5, !DAMAGETAKEN_X, !DAMAGETAKEN_Y) +%AddStat(MagicCounter, 0, 0, 16, 5, !MAGICUSED_X, !MAGICUSED_Y) +%AddStat(BonkCounter, 0, 0, 08, 3, !BONKS_X, !BONKS_Y) +%AddStat(SaveQuitCounter, 0, 0, 08, 2, !SAVE_AND_QUITS_X, !SAVE_AND_QUITS_Y) +%AddStat(DeathCounter, 0, 0, 08, 2, !DEATHS_X, !DEATHS_Y) +%AddStat(FaerieRevivalCounter, 0, 0, 08, 3, !FAERIE_REVIVALS_X, !FAERIE_REVIVALS_Y) +%AddStat(MenuFrames, 1, 8, 32, 4, !TOTAL_MENU_TIME_X, !TOTAL_MENU_TIME_Y) %AddStat($7F5038, 1, 0, 32, 4, !TOTAL_LAG_TIME_X, !TOTAL_LAG_TIME_Y) -%AddStat($7EF423, 0, 0, 08, 3, !COLLECTION_RATE_X, !COLLECTION_RATE_Y) -%AddStat($7EF43E, 1, 0, 32, 4, !TOTAL_TIME_X, !TOTAL_TIME_Y) +%AddStat(TotalItemCounter, 0, 0, 16, 3, !COLLECTION_RATE_X, !COLLECTION_RATE_Y) +%AddStat(NMIFrames, 1, 0, 32, 4, !TOTAL_TIME_X, !TOTAL_TIME_Y) diff --git a/swordswap.asm b/swordswap.asm index 3a04b02..0e16119 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 $7EF2F0 : AND.b #$20 : BNE .done + LDA OverworldEventData+$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 $7EF2C7 : AND.b #$20 : BNE .done + LDA OverworldEventData+$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/timer.asm b/timer.asm index bff9bb2..1623831 100644 --- a/timer.asm +++ b/timer.asm @@ -2,8 +2,6 @@ ; Challenge Timer ;================================================================================ !Temp = "$7F5020" -!BaseTimer = "$7EF43E" -!ChallengeTimer = "$7EF454" !TemporaryOHKO = "$7F50CC" ;-------------------------------------------------------------------------------- !CLOCK_HOURS = "$7F5080" ; $7F5080 - $7F5083 - Clock Hours @@ -58,17 +56,17 @@ CalculateTimer: STA.l !CLOCK_SECONDS+2 LDA.l TimerStyle : AND.w #$00FF : CMP.w #$0002 : BNE + ; Stopwatch Mode - %Sub32(!BaseTimer,!ChallengeTimer,!CLOCK_TEMPORARY) + %Sub32(NMIFrames,ChallengeTimer,!CLOCK_TEMPORARY) BRA ++ + CMP.w #$0001 : BNE ++ ; Countdown Mode - %Sub32(!ChallengeTimer,!BaseTimer,!CLOCK_TEMPORARY) + %Sub32(ChallengeTimer,NMIFrames,!CLOCK_TEMPORARY) ++ %Blt32(!CLOCK_TEMPORARY,.halfCycle) : !BLT + LDA.l TimeoutBehavior : AND.w #$00FF : BNE ++ ; DNF LDA.w #$0002 : STA.l !Status ; Set DNF Mode - LDA.l !BaseTimer : STA.l !ChallengeTimer - LDA.l !BaseTimer+2 : STA.l !ChallengeTimer+2 + LDA.l NMIFrames : STA.l ChallengeTimer + LDA.l NMIFrames+2 : STA.l ChallengeTimer+2 RTS ++ CMP.w #$0001 : BNE ++ ; Negative Time LDA.l !CLOCK_TEMPORARY : EOR.w #$FFFF : !ADD.w #$0001 : STA.l !CLOCK_TEMPORARY @@ -77,8 +75,8 @@ CalculateTimer: BRA .prepDigits ++ CMP.w #$0002 : BNE ++ ; OHKO LDA.w #$0002 : STA.l !Status ; Set DNF Mode - LDA.l !BaseTimer : STA.l !ChallengeTimer - LDA.l !BaseTimer+2 : STA.l !ChallengeTimer+2 + LDA.l NMIFrames : STA.l ChallengeTimer + LDA.l NMIFrames+2 : STA.l ChallengeTimer+2 RTS ++ ; End Game SEP #$30 From c1e4ca0053239ea5ca8dad65197f7a598fb16f0c Mon Sep 17 00:00:00 2001 From: cassidy Date: Mon, 6 Dec 2021 00:46:05 -0500 Subject: [PATCH 07/96] Replace more labels Removed mask from rupeelimit.asm as total item counter is now a 16-bit value Commented out CountBits in utilities.asm in previous commit as I've allocated a counter byte in SRAM --- framehook.asm | 42 +++++++++--------------------------------- rupeelimit.asm | 4 +--- tablets.asm | 10 +++++----- utilities.asm | 21 ++++++++++----------- 4 files changed, 25 insertions(+), 52 deletions(-) diff --git a/framehook.asm b/framehook.asm index db39bba..0da5dba 100644 --- a/framehook.asm +++ b/framehook.asm @@ -1,46 +1,22 @@ ;================================================================================ ; Frame Hook ;-------------------------------------------------------------------------------- -; $7EF42Ew[2] - loop frame counter (low) -!LOOP_FRAMES_LOW = "$7EF42E" -;-------------------------------------------------------------------------------- -; $7EF430w[2] - loop frame counter (high) -!LOOP_FRAMES_HIGH = "$7EF430" -;-------------------------------------------------------------------------------- -; $7EF43Ew[2] - nmi frame counter (low) -!NMI_FRAMES_LOW = "$7EF43E" -;-------------------------------------------------------------------------------- -; $7EF440w[2] - nmi frame counter (high) -!NMI_FRAMES_HIGH = "$7EF440" -;-------------------------------------------------------------------------------- -; $7EF444w[2] - item menu frame counter (low) -!ITEM_FRAMES_LOW = "$7EF444" -;-------------------------------------------------------------------------------- -; $7EF446w[2] - item menu frame counter (high) -!ITEM_FRAMES_HIGH = "$7EF446" -;-------------------------------------------------------------------------------- -!LOCK_STATS = "$7EF443" FrameHookAction: JSL $0080B5 ; Module_MainRouting JSL CheckMusicLoadRequest PHP : REP #$30 : PHA SEP #$20 - - ;LDA EnableSRAMTrace : AND.l TournamentSeedInverse : BEQ + - ; LDA $1A : BNE ++ : JSL.l WriteStatusPreview : ++ ; write every 256 frames - ;+ - LDA !LOCK_STATS : BNE ++ + LDA StatsLocked : BNE ++ REP #$20 ; set 16-bit accumulator - LDA !LOOP_FRAMES_LOW : INC : STA !LOOP_FRAMES_LOW : BNE + - LDA !LOOP_FRAMES_HIGH : INC : STA !LOOP_FRAMES_HIGH + LDA LoopFrames : INC : STA LoopFrames : BNE + + LDA LoopFrames+2 : INC : STA LoopFrames+2 + LDA $10 : CMP.w #$010E : BNE + ; move this to nmi hook? - LDA !ITEM_FRAMES_LOW : INC : STA !ITEM_FRAMES_LOW : BNE + - LDA !ITEM_FRAMES_HIGH : INC : STA !ITEM_FRAMES_HIGH + LDA MenuFrames : INC : STA MenuFrames : BNE + + LDA MenuFrames+2 : INC : STA MenuFrames+2 + - ;SEP #$20 ; set 8-bit accumulator ?? check this ++ REP #$30 : PLA : PLP RTL @@ -48,9 +24,9 @@ RTL NMIHookAction: PHA : PHX : PHY : PHD ; thing we wrote over, push stuff - LDA !LOCK_STATS : AND.w #$00FF : BNE ++ - LDA !NMI_FRAMES_LOW : INC : STA !NMI_FRAMES_LOW : BNE + - LDA !NMI_FRAMES_HIGH : INC : STA !NMI_FRAMES_HIGH + LDA StatsLocked : AND.w #$00FF : BNE ++ + LDA NMIFrames : INC : STA NMIFrames : BNE + + LDA NMIFrames+2 : INC : STA NMIFrames+2 + ++ @@ -80,4 +56,4 @@ PostNMIHookAction: LDA $13 : STA $2100 ; thing we wrote over, turn screen back on JML.l PostNMIHookReturn -;-------------------------------------------------------------------------------- \ No newline at end of file +;-------------------------------------------------------------------------------- diff --git a/rupeelimit.asm b/rupeelimit.asm index 8c573d0..f42d405 100644 --- a/rupeelimit.asm +++ b/rupeelimit.asm @@ -5,9 +5,7 @@ Draw4DigitRupees: LDA $1B : AND.w #$00FF : BEQ .outdoors ; skip if outdoors .indoors LDA $A0 : BNE .normal ; skip except for ganon's room - ;LDA #$246E : STA $7EC712 - ;LDA #$246F : STA $7EC714 - LDA $7EF423 : AND #$00FF + LDA TotalItemCounter BRA .print .outdoors .normal diff --git a/tablets.asm b/tablets.asm index 3e12429..0f299ef 100644 --- a/tablets.asm +++ b/tablets.asm @@ -2,19 +2,19 @@ ; Randomize Tablets ;-------------------------------------------------------------------------------- ItemSet_EtherTablet: - PHA : LDA !NPC_FLAGS_2 : ORA.b #$01 : STA !NPC_FLAGS_2 : PLA + PHA : LDA NpcFlags+1 : ORA.b #$01 : STA NpcFlags+1 : PLA RTL ;-------------------------------------------------------------------------------- ItemSet_BombosTablet: - PHA : LDA !NPC_FLAGS_2 : ORA.b #$02 : STA !NPC_FLAGS_2 : PLA + PHA : LDA NpcFlags+1 : ORA.b #$02 : STA NpcFlags+1 : PLA RTL ;-------------------------------------------------------------------------------- ItemCheck_EtherTablet: - LDA !NPC_FLAGS_2 : AND.b #$01 + LDA NpcFlags+1 : AND.b #$01 RTL ;-------------------------------------------------------------------------------- ItemCheck_BombosTablet: - LDA !NPC_FLAGS_2 : AND.b #$02 + LDA NpcFlags+1 : AND.b #$02 RTL ;-------------------------------------------------------------------------------- SetTabletItem: @@ -132,4 +132,4 @@ DrawNarrowDroppedObject: PLY .large_sprite RTL -;-------------------------------------------------------------------------------- \ No newline at end of file +;-------------------------------------------------------------------------------- diff --git a/utilities.asm b/utilities.asm index 349d317..87a69e4 100644 --- a/utilities.asm +++ b/utilities.asm @@ -1,8 +1,6 @@ ;================================================================================ ; Utility Functions ;================================================================================ -!PROGRESSIVE_SHIELD = "$7EF416" ; ss-- ---- -;-------------------------------------------------------------------------------- ; GetSpriteTile ; in: A - Loot ID ; out: A - Sprite GFX ID @@ -60,7 +58,7 @@ RTL + LDA.b #$04 : RTL ++ CMP.b #$FE : BNE ++ ; Progressive Sword - LDA SwordEquipment + LDA HighestSword CMP.l ProgressiveSwordLimit : !BLT + ; Progressive Sword Limit LDA.l ProgressiveSwordReplacement JMP GetSpriteID @@ -74,7 +72,7 @@ RTL LDA.b #$46 : RTL + ++ : CMP.b #$FF : BNE ++ ; Progressive Shield - LDA !PROGRESSIVE_SHIELD : AND #$C0 : LSR #6 + LDA HighestShield CMP.l ProgressiveShieldLimit : !BLT + ; Progressive Shield Limit LDA.l ProgressiveShieldReplacement JMP GetSpriteID @@ -183,7 +181,7 @@ GetSpritePalette: RTL .specialHandling CMP.b #$FD : BNE ++ ; Progressive Sword - LDA SwordEquipment + LDA HighestSword CMP.l ProgressiveSwordLimit : !BLT + ; Progressive Sword Limit LDA.l ProgressiveSwordReplacement JMP GetSpritePalette @@ -196,7 +194,7 @@ RTL + ; Everything Else LDA.b #$08 : RTL ++ : CMP.b #$FE : BNE ++ ; Progressive Shield - LDA !PROGRESSIVE_SHIELD : AND #$C0 : LSR #6 + LDA HighestShield CMP.l ProgressiveShieldLimit : !BLT + ; Progressive Shield Limit LDA.l ProgressiveShieldReplacement JMP GetSpritePalette @@ -207,7 +205,8 @@ RTL + ; Everything Else LDA.b #$08 : RTL ++ : CMP.b #$FF : BNE ++ ; Progressive Armor - LDA ArmorEquipment : CMP.l ProgressiveArmorLimit : !BLT + ; Progressive Armor Limit + LDA HighestMail + CMP.l ProgressiveArmorLimit : !BLT + ; Progressive Armor Limit LDA.l ProgressiveArmorReplacement JMP GetSpritePalette + : CMP.b #$00 : BNE + ; Green Tunic @@ -307,19 +306,19 @@ IsNarrowSprite: + : JMP .continue .notBottle CMP.b #$5E : BNE ++ ; Progressive Sword - LDA SwordEquipment : CMP.l ProgressiveSwordLimit : !BLT + ; Progressive Sword Limit + LDA HighestSword : CMP.l ProgressiveSwordLimit : !BLT + ; Progressive Sword Limit LDA.l ProgressiveSwordReplacement JSL.l IsNarrowSprite JMP .done + : JMP .continue ++ CMP.b #$5F : BNE ++ ; Progressive Shield - LDA !PROGRESSIVE_SHIELD : AND #$C0 : BNE + : SEC : JMP .done ; No Shield - + : LSR #6 : CMP.l ProgressiveShieldLimit : !BLT .continue + LDA HighestShield : BNE + : JMP .done ; No Shield + + : CMP.l ProgressiveShieldLimit : !BLT .continue LDA.l ProgressiveShieldReplacement JSL.l IsNarrowSprite JMP .done ++ CMP.b #$60 : BNE ++ ; Progressive Armor - LDA ArmorEquipment : CMP.l ProgressiveArmorLimit : !BLT .continue + LDA HighestMail : CMP.l ProgressiveArmorLimit : !BLT .continue LDA.l ProgressiveArmorReplacement JSL.l IsNarrowSprite JMP .done From db8df2a12b76a9520d7b57a3cb00e0596c703a23 Mon Sep 17 00:00:00 2001 From: cassidy Date: Mon, 6 Dec 2021 00:48:43 -0500 Subject: [PATCH 08/96] Replace labels in fileselect.asm Full file name has also been moved to the beginning of the new save space at $7F6000 in WRAM and $700500 in SRAM --- fileselect.asm | 117 ++++++++++++++++++++++++------------------------- 1 file changed, 57 insertions(+), 60 deletions(-) diff --git a/fileselect.asm b/fileselect.asm index 8aed309..4fb082e 100644 --- a/fileselect.asm +++ b/fileselect.asm @@ -1,9 +1,6 @@ !ValidKeyLoaded = "$7F509E" ;FS prefix means file_select, since these defines and macros are specific to this screen -!FS_INVENTORY_SWAP = "$70038C" -!FS_INVENTORY_SWAP_2 = "$70038E" - !FS_COLOR_BROWN = "$0000" ;(only used for: Shovel, hammer, powder) !FS_COLOR_RED = "$0400" @@ -156,15 +153,15 @@ DrawPlayerFileShared: JSR FileSelectDrawHudBar ; Bow - LDA.l !FS_INVENTORY_SWAP_2 : AND.w #$0040 : BEQ + - LDA $700340 : AND.w #$00FF : BEQ ++ + LDA.l BowTracking : AND.w #$0040 : BEQ + + LDA SRAMEquipment : AND.w #$00FF : BEQ ++ %fs_drawItem(3,12,FileSelectItems_silver_bow) BRA .bow_end ++ %fs_drawItem(3,12,FileSelectItems_silver_arrow) BRA .bow_end + - LDA.l $700340 : AND.w #$00FF : BEQ + + LDA.l SRAMEquipment : AND.w #$00FF : BEQ + %fs_drawItem(3,12,FileSelectItems_bow) BRA .bow_end + @@ -172,15 +169,15 @@ DrawPlayerFileShared: .bow_end ; Boomerang - LDA.l !FS_INVENTORY_SWAP : AND.w #$00C0 : CMP.w #$00C0 : BNE + + LDA.l InventoryTracking : AND.w #$00C0 : CMP.w #$00C0 : BNE + %fs_drawItem(3,14,FileSelectItems_both_boomerang) BRA .boomerang_end + - LDA.l !FS_INVENTORY_SWAP : AND.w #$0040 : BEQ + + LDA.l InventoryTracking : AND.w #$0040 : BEQ + %fs_drawItem(3,14,FileSelectItems_red_boomerang) BRA .boomerang_end + - LDA.l !FS_INVENTORY_SWAP : AND.w #$0080 : BEQ + + LDA.l InventoryTracking : AND.w #$0080 : BEQ + %fs_drawItem(3,14,FileSelectItems_blue_boomerang) BRA .boomerang_end + @@ -188,13 +185,13 @@ DrawPlayerFileShared: .boomerang_end ; Hookshot - %fs_drawItemBasic($700342,3,16,FileSelectItems_hookshot) + %fs_drawItemBasic(SRAMEquipment+$02,3,16,FileSelectItems_hookshot) ; Bombs - ; %fs_drawItemBasic($700343,3,18,FileSelectItems_bombs) + ; %fs_drawItemBasic(SRAMEquipment+$03,3,18,FileSelectItems_bombs) ; Powder - LDA.l !FS_INVENTORY_SWAP : AND.w #$0010 : BEQ + + LDA.l InventoryTracking : AND.w #$0010 : BEQ + %fs_drawItem(3,20,FileSelectItems_powder) BRA ++ + @@ -202,7 +199,7 @@ DrawPlayerFileShared: ++ ; Mushroom - LDA.l !FS_INVENTORY_SWAP : AND.w #$0008 : BEQ + + LDA.l InventoryTracking : AND.w #$0008 : BEQ + %fs_drawItem(3,18,FileSelectItems_mushroom) BRA ++ + @@ -210,7 +207,7 @@ DrawPlayerFileShared: ++ ; Flute - LDA.l !FS_INVENTORY_SWAP : AND.w #$0003 : BEQ + + LDA.l InventoryTracking : AND.w #$0003 : BEQ + %fs_drawItem(7,16,FileSelectItems_flute) BRA ++ + @@ -218,7 +215,7 @@ DrawPlayerFileShared: ++ ; Shovel - LDA.l !FS_INVENTORY_SWAP : AND.w #$0004 : BEQ + + LDA.l InventoryTracking : AND.w #$0004 : BEQ + %fs_drawItem(9,12,FileSelectItems_shovel) BRA ++ + @@ -226,52 +223,52 @@ DrawPlayerFileShared: ++ ; Fire Rod - %fs_drawItemBasic($700345,5,12,FileSelectItems_fire_rod) + %fs_drawItemBasic(SRAMEquipment+$05,5,12,FileSelectItems_fire_rod) ; Ice Rod - %fs_drawItemBasic($700346,5,14,FileSelectItems_ice_rod) + %fs_drawItemBasic(SRAMEquipment+$06,5,14,FileSelectItems_ice_rod) ; Bombos Medallion - %fs_drawItemBasic($700347,5,16,FileSelectItems_bombos) + %fs_drawItemBasic(SRAMEquipment+$07,5,16,FileSelectItems_bombos) ; Ether Medallion - %fs_drawItemBasic($700348,5,18,FileSelectItems_ether) + %fs_drawItemBasic(SRAMEquipment+$08,5,18,FileSelectItems_ether) ; Quake Medallion - %fs_drawItemBasic($700349,5,20,FileSelectItems_quake) + %fs_drawItemBasic(SRAMEquipment+$09,5,20,FileSelectItems_quake) ; Lamp - %fs_drawItemBasic($70034A,7,12,FileSelectItems_lamp) + %fs_drawItemBasic(SRAMEquipment+$0A,7,12,FileSelectItems_lamp) ; Hammer - %fs_drawItemBasic($70034B,7,14,FileSelectItems_hammer) + %fs_drawItemBasic(SRAMEquipment+$0B,7,14,FileSelectItems_hammer) ; Bug Net - %fs_drawItemBasic($70034D,7,18,FileSelectItems_bugnet) + %fs_drawItemBasic(SRAMEquipment+$0D,7,18,FileSelectItems_bugnet) ; Book of Mudora - %fs_drawItemBasic($70034E,7,20,FileSelectItems_book) + %fs_drawItemBasic(SRAMEquipment+$0E,7,20,FileSelectItems_book) ; Red Cane - %fs_drawItemBasic($700350,9,14,FileSelectItems_redcane) + %fs_drawItemBasic(SRAMEquipment+$10,9,14,FileSelectItems_redcane) ; Blue Cane - %fs_drawItemBasic($700351,9,16,FileSelectItems_bluecane) + %fs_drawItemBasic(SRAMEquipment+$11,9,16,FileSelectItems_bluecane) ; Cape - %fs_drawItemBasic($700352,9,18,FileSelectItems_cape) + %fs_drawItemBasic(SRAMEquipment+$12,9,18,FileSelectItems_cape) ; Mirror - %fs_drawItemBasic($700353,9,20,FileSelectItems_mirror) + %fs_drawItemBasic(SRAMEquipment+$13,9,20,FileSelectItems_mirror) ; Bottles - %fs_drawBottle($70035C,3,23) - %fs_drawBottle($70035D,5,23) - %fs_drawBottle($70035E,7,23) - %fs_drawBottle($70035F,9,23) + %fs_drawBottle(SRAMEquipment+$1C,3,23) + %fs_drawBottle(SRAMEquipment+$1D,5,23) + %fs_drawBottle(SRAMEquipment+$1E,7,23) + %fs_drawBottle(SRAMEquipment+$1F,9,23) ; Sword - LDA.l $700359 : AND.w #$00FF : BNE + + LDA.l SRAMEquipment+$19 : AND.w #$00FF : BNE + %fs_drawItemGray(3,26,FileSelectItems_fighters_sword) BRA ++ + : DEC : BNE + @@ -292,7 +289,7 @@ DrawPlayerFileShared: ++ ; Shield - LDA.l $70035A : AND.w #$00FF : BNE + + LDA.l SRAMEquipment+$1A : AND.w #$00FF : BNE + %fs_drawItemGray(5,26,FileSelectItems_fighters_shield) BRA ++ + : DEC : BNE + @@ -306,7 +303,7 @@ DrawPlayerFileShared: ++ ; Mail - LDA.l $70035B : AND.w #$00FF : BNE + + LDA.l SRAMEquipment+$1B : AND.w #$00FF : BNE + %fs_drawItem(7,26,FileSelectItems_green_mail) BRA ++ + : DEC : BNE + @@ -317,7 +314,7 @@ DrawPlayerFileShared: ++ ; Heart Pieces - LDA.l $70036B : AND.w #$00FF : BNE + + LDA.l SRAMEquipment+$2B : AND.w #$00FF : BNE + %fs_drawItem(9,26,FileSelectItems_heart_piece_0_of_4) BRA ++ + : DEC : BNE + @@ -330,16 +327,16 @@ DrawPlayerFileShared: %fs_drawItem(9,26,FileSelectItems_heart_piece_3_of_4) ++ - LDA $700448 : AND.w #$00FF + LDA SRAMEquipment+$0108 : AND.w #$00FF JSL.l HexToDec LDA $7F5006 : AND.w #$00FF : !ADD.w #$210+!FS_COLOR_BW : %fs_draw8x8(11,26) LDA $7F5007 : AND.w #$00FF : !ADD.w #$210+!FS_COLOR_BW : %fs_draw8x8(11,27) ; Boots - %fs_drawItemBasic($700355,3,28,FileSelectItems_boots) + %fs_drawItemBasic(SRAMEquipment+$15,3,28,FileSelectItems_boots) ; Gloves - LDA.l $700354 : AND.w #$00FF : BNE + + LDA.l SRAMEquipment+$14 : AND.w #$00FF : BNE + %fs_drawItemGray(5,28,FileSelectItems_gloves) BRA ++ + : DEC : BNE + @@ -350,27 +347,27 @@ DrawPlayerFileShared: ++ ; Flippers - %fs_drawItemBasic($700356,7,28,FileSelectItems_flippers) + %fs_drawItemBasic(SRAMEquipment+$16,7,28,FileSelectItems_flippers) ; Moon Pearl - %fs_drawItemBasic($700357,9,28,FileSelectItems_pearl) + %fs_drawItemBasic(SRAMEquipment+$17,9,28,FileSelectItems_pearl) ; Pendants - LDA $700374 : AND.w #$0004 : BEQ + + LDA SRAMEquipment+$34 : AND.w #$0004 : BEQ + %fs_drawItem(12,12,FileSelectItems_green_pendant) BRA ++ + %fs_drawItem(12,12,FileSelectItems_no_pendant) ++ - LDA $700374 : AND.w #$0002 : BEQ + + LDA SRAMEquipment+$34 : AND.w #$0002 : BEQ + %fs_drawItem(12,14,FileSelectItems_blue_pendant) BRA ++ + %fs_drawItem(12,14,FileSelectItems_no_pendant) ++ - LDA $700374 : AND.w #$0001 : BEQ + + LDA SRAMEquipment+$34 : AND.w #$0001 : BEQ + %fs_drawItem(12,16,FileSelectItems_red_pendant) BRA ++ + @@ -378,49 +375,49 @@ DrawPlayerFileShared: ++ ; Crystals - LDA $70037A : AND.w #$0002 : BEQ + + LDA SRAMEquipment+$3A : AND.w #$0002 : BEQ + LDA.w #$0297|!FS_COLOR_BLUE BRA ++ + LDA.w #$0287|!FS_COLOR_GRAY ++ : %fs_draw16x8(13,18) - LDA $70037A : AND.w #$0010 : BEQ + + LDA SRAMEquipment+$3A : AND.w #$0010 : BEQ + LDA.w #$0297|!FS_COLOR_BLUE BRA ++ + LDA.w #$0287|!FS_COLOR_GRAY ++ : %fs_draw16x8(12,19) - LDA $70037A : AND.w #$0040 : BEQ + + LDA SRAMEquipment+$3A : AND.w #$0040 : BEQ + LDA.w #$0297|!FS_COLOR_BLUE BRA ++ + LDA.w #$0287|!FS_COLOR_GRAY ++ : %fs_draw16x8(13,20) - LDA $70037A : AND.w #$0020 : BEQ + + LDA SRAMEquipment+$3A : AND.w #$0020 : BEQ + LDA.w #$0297|!FS_COLOR_BLUE BRA ++ + LDA.w #$0287|!FS_COLOR_GRAY ++ : %fs_draw16x8(12,21) - LDA $70037A : AND.w #$0004 : BEQ + + LDA SRAMEquipment+$3A : AND.w #$0004 : BEQ + LDA.w #$0297|!FS_COLOR_RED BRA ++ + LDA.w #$0287|!FS_COLOR_GRAY ++ : %fs_draw16x8(13,22) - LDA $70037A : AND.w #$0001 : BEQ + + LDA SRAMEquipment+$3A : AND.w #$0001 : BEQ + LDA.w #$0297|!FS_COLOR_RED BRA ++ + LDA.w #$0287|!FS_COLOR_GRAY ++ : %fs_draw16x8(12,23) - LDA $70037A : AND.w #$0008 : BEQ + + LDA SRAMEquipment+$3A : AND.w #$0008 : BEQ + LDA.w #$0297|!FS_COLOR_BLUE BRA ++ + @@ -562,7 +559,7 @@ FileSelectItems: ;-------------------------------------------------------------------------------- FileSelectDrawHudBar: LDA #$029B|!FS_COLOR_GREEN : %fs_draw16x8(0,10) - LDA $700362 + LDA SRAMEquipment+$22 JSL.l HexToDec LDA $7F5004 : AND.w #$00FF : !ADD.w #$210+!FS_COLOR_BW : %fs_draw8x8(1,9) LDA $7F5005 : AND.w #$00FF : !ADD.w #$210+!FS_COLOR_BW : %fs_draw8x8(1,10) @@ -570,18 +567,18 @@ FileSelectDrawHudBar: LDA $7F5007 : AND.w #$00FF : !ADD.w #$210+!FS_COLOR_BW : %fs_draw8x8(1,12) LDA #$028B|!FS_COLOR_BLUE : %fs_draw16x8(0,14) - LDA $700343 : AND.w #$00FF + LDA SRAMEquipment+$03 : AND.w #$00FF JSL.l HexToDec LDA $7F5006 : AND.w #$00FF : !ADD.w #$210+!FS_COLOR_BW : %fs_draw8x8(1,14) LDA $7F5007 : AND.w #$00FF : !ADD.w #$210+!FS_COLOR_BW : %fs_draw8x8(1,15) - LDA.l !FS_INVENTORY_SWAP_2 : AND.w #$0040 : BEQ + + LDA.l BowTracking : AND.w #$0040 : BEQ + LDA #$0299|!FS_COLOR_RED : %fs_draw16x8(0,17) BRA ++ + LDA #$0289|!FS_COLOR_BROWN : %fs_draw16x8(0,17) ++ - LDA $700377 : AND.w #$00FF + LDA SRAMEquipment+$37 : AND.w #$00FF JSL.l HexToDec LDA $7F5006 : AND.w #$00FF : !ADD.w #$210+!FS_COLOR_BW : %fs_draw8x8(1,17) LDA $7F5007 : AND.w #$00FF : !ADD.w #$210+!FS_COLOR_BW : %fs_draw8x8(1,18) @@ -790,16 +787,16 @@ DrawPlayerFile_credits: ; see $6563C for drawing first file name and hearts REP #$20 ; set 16 bit accumulator - LDA $7003D9 : ORA.w #!FS_COLOR_BW + LDA SRAMEquipment+$99 : ORA.w #!FS_COLOR_BW %fs_draw8x16(3,5) - LDA $7003DB : ORA.w #!FS_COLOR_BW + LDA SRAMEquipment+$9B : ORA.w #!FS_COLOR_BW %fs_draw8x16(3,6) - LDA $7003DD : ORA.w #!FS_COLOR_BW + LDA SRAMEquipment+$9D : ORA.w #!FS_COLOR_BW %fs_draw8x16(3,7) - LDA $7003DF : ORA.w #!FS_COLOR_BW + LDA SRAMEquipment+$9F : ORA.w #!FS_COLOR_BW %fs_draw8x16(3,8) - LDA $70036C : AND.w #$00FF : LSR #3 : STA $02 + LDA SRAMEquipment+$2C : AND.w #$00FF : LSR #3 : STA $02 %fs_LDY_screenpos(0,20) LDA.w #$028F|!FS_COLOR_RED LDX.w #$000A From 1b9734d1af96fb9a62fb1c5b5b24dba544f12f1c Mon Sep 17 00:00:00 2001 From: cassidy Date: Mon, 6 Dec 2021 00:52:20 -0500 Subject: [PATCH 09/96] Removed SRAM trace from tables.asm Fixed comments related to OpenMode, left open as default --- tables.asm | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/tables.asm b/tables.asm index 75efb96..e2a5509 100644 --- a/tables.asm +++ b/tables.asm @@ -98,11 +98,7 @@ db #$02 ; #$02 = Tempered Sword (default) ;org $05EBD4 ; PC 0x2EBD4 - sprite_zelda.asm:23 - (LDA $7EF359 : CMP.b #$02 : BCS .hasMasterSword) - Zelda Spawnpoint Sword Check ;db #$05 ; #$02 = Tempered Sword (default) - #$05 = All Swords ;-------------------------------------------------------------------------------- -; 0x18002B- 0x18002F (Unused) -;-------------------------------------------------------------------------------- -org $308030 ; PC 0x180030 -EnableSRAMTrace: -db #$00 ; #$00 = Off (default) - #$01 = On +; 0x18002B- 0x180030 (Unused) ;-------------------------------------------------------------------------------- org $308031 ; PC 0x180031 EnableEasterEggs: @@ -110,7 +106,7 @@ db #$00 ; #$00 = Off (default) - #$01 = On ;-------------------------------------------------------------------------------- org $308032 ; PC 0x180032 OpenMode: -db #$01 ; #$00 = Normal (default) - #$01 = Open +db #$01 ; #$01 = Standard (default) - #$01 = Open ;-------------------------------------------------------------------------------- org $308033 ; PC 0x180033 HeartBeep: @@ -1620,7 +1616,7 @@ dw $0000, $0000, $0000, $0000, $F800, $0000, $0000, $0000 dw $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000 dw $0000, $0000 ;-------------------------------------------------------------------------------- -; 0x182355 - 183FFF (unused) +; 0x183055 - 183FFF (unused) ;================================================================================ org $30C000 ; PC 0x184000 - 0x184007 ItemSubstitutionRules: From 190653d70ff3e63da844f1647baf4fba5c79722a Mon Sep 17 00:00:00 2001 From: cassidy Date: Mon, 6 Dec 2021 01:13:15 -0500 Subject: [PATCH 10/96] Remove defines from LTTP_RND_GeneralBugfixes Replace more labels Add ROM version and reserve extra 16 bytes in unused hardware vector in LTTP_RND_GeneralBugfixes Move IncrementChestCounter to ChestPrep in newitems.asm Remove IncrementChestCounter hook which was getting overwritten More revisions to sram.asm --- LTTP_RND_GeneralBugfixes.asm | 43 ++------ hooks.asm | 8 +- init.asm | 2 - inventory.asm | 190 +++++++++++++++-------------------- newitems.asm | 16 ++- sram.asm | 7 +- 6 files changed, 106 insertions(+), 160 deletions(-) diff --git a/LTTP_RND_GeneralBugfixes.asm b/LTTP_RND_GeneralBugfixes.asm index b66ba93..1c4bc96 100644 --- a/LTTP_RND_GeneralBugfixes.asm +++ b/LTTP_RND_GeneralBugfixes.asm @@ -2,6 +2,7 @@ ; The Legend of Zelda, A Link to the Past - Randomizer General Development & Bugfixes ;================================================================================ lorom + ;================================================================================ ;org $00FFC0 ; <- 7FC0 - Bank00.asm : 9173 (db "THE LEGEND OF ZELDA " ; 21 bytes) @@ -41,28 +42,7 @@ dw !ROM_VERSION_HIGH !BLT = "BCC" !BGE = "BCS" -; Rando Specific SRAM assignments -!NPC_FLAGS = "$7EF410" -!NPC_FLAGS_2 = "$7EF411" -!MAP_OVERLAY = "$7EF414" ; [w] -!PROGRESSIVE_SHIELD = "$7EF416" ; ss-- ---- -!HUD_FLAG = "$7EF416" ; --h- ---- -!FORCE_PYRAMID = "$7EF416" ; ---- p--- -!IGNORE_FAIRIES = "$7EF416" ; ---- -i-- -!SHAME_CHEST = "$7EF416" ; ---s ---- -!HAS_GROVE_ITEM = "$7EF416" ; ---- ---g general flags, don't waste these -!HIGHEST_SWORD_LEVEL = "$7EF417" ; --- -sss -;$7EF418 - Goal Item Counter -;$7EF419 - Service Sequence -;$7EF420 - $7EF46D - Stat Tracking Bank 1 (overlaps with RNG Item Flags) -;$7EF4A0 - $7EF4A7 - Service Request Block -;$700500 - $70050F - Extended File Name -;$701000 - $70100F - Password (incorporate into log header) -;$702000 - $702014 - Rom title copy (incorporate into log header) - - !MS_GOT = "$7F5031" -!DARK_WORLD = "$7EF3CA" !REDRAW = "$7F5000" !GANON_WARP_CHAIN = "$7F5032"; @@ -114,7 +94,6 @@ incsrc heartpieces.asm incsrc npcitems.asm incsrc utilities.asm incsrc flipperkill.asm -incsrc previewdatacopy.asm incsrc pendantcrystalhud.asm incsrc potions.asm incsrc shopkeeper.asm @@ -335,21 +314,21 @@ warnpc $B08000 ;RAM ;$7EC900[0x1F00]: BIGRAM buffer ;$7EF000[0x500]: SRAM mirror First 0x500 bytes of SRAM +; See sram.asm for labels and assignments ;$7F5000[0x800]: Rando's main free ram region ; See tables.asm for specific assignments -;$7F6000[0x500]: Free RAM (reclaimed from damage table) Not allocated yet -;$7F6000[0x500]: SRAM buffer save 2 0x500 -;$7F6500[0xB00]: SRAM mirror for last 0xB00 bytes of SRAM (extended sram) +;$7F6000[0x1000]: SRAM buffer mapped to vanilla save slots 1 and 2 +; See sram.asm for labels and assignments ;$7F7667[0x6719] - free ram ;================================================================================ ;SRAM Map -;$70:0000 ( 4K) Game state -; 0000-04FF Vanilla Slot 1 (mirrored at 0x7EF000) -; See earlier in this file for rando specific assignments -; 0500-0FFF Ext Slot 1 (not yet mirrored) -; See earlier in this file for rando specific assignments -;$70:1000 (20K) Log entries -;$70:6000 ( 8K) Scratch buffers +;See sram.asm for rando-specific assignments +;$70:0000 (5K) Game state +; 0000-04FF Vanilla Slot 1 (mirrored at $7EF000) +; 0500-14FF Ext Slot 1 (mirrored at $7F6000) +;$70:2000 (0x25) ROM Name and version number +;$70:3000 (0x16) Password +;$70:6000 (8K) Scratch buffers ;================================================================================ ;org $0080DC ; <- 0xDC - Bank00.asm:179 - Kill Music ;db #$A9, #$00, #$EA diff --git a/hooks.asm b/hooks.asm index 74b0adc..61caee3 100755 --- a/hooks.asm +++ b/hooks.asm @@ -541,10 +541,6 @@ org $0288D1 ; <- 108D1 - Bank02.asm : 1690 (STZ $0646) JSL.l IndoorSubtileTransitionCounter NOP #2 ;-------------------------------------------------------------------------------- -org $07B574 ; <- 3B574 - Bank07.asm : 8519 (LDA.b #$01 : STA $02E9) -JSL.l IncrementChestCounter -NOP -;-------------------------------------------------------------------------------- ;org $05FC7E ; <- 2FC7E - sprite_dash_item.asm : 118 (LDA $7EF36F : INC A : STA $7EF36F) ;JSL.l IncrementSmallKeys ;-------------------------------------------------------------------------------- @@ -2101,7 +2097,7 @@ JSL.l ItemCheck_TreeKid2 org $06AF9B ; <- 32F9B - FluteBoy_Chillin : 73 : LDA $7EF34C : CMP.b #$02 : BCS .player_has_flute ;NOP #8 -LDA !HAS_GROVE_ITEM : AND.b #$01 +LDA HasGroveItem : AND.b #$01 db #$D0 ; BNE org $06B062 ; <- 33062 - FluteAardvark_InitialStateFromFluteState : 225 : LDA $7EF34C : AND.b #$03 : !BGE #$05 @@ -2472,7 +2468,7 @@ org $00DF62 ; <- Bank00.asm:4672 (LDX.w #$0000 : LDY.w #$0040) JML ReloadingFloors NOP : NOP ReloadingFloorsResume: -org $00DF6E ; <- A few instructions later, right after JSR Do3To4High16Bit +org $00DF6E ; <- A few instructions later, right after JSR Do3To.high16Bit ReloadingFloorsCancel: ;================================================================================ diff --git a/init.asm b/init.asm index cdd7d66..b774183 100644 --- a/init.asm +++ b/init.asm @@ -1,5 +1,3 @@ -RomVersionSRAM = $701FFC - ;-------------------------------------------------------------------------------- ; Init_Primary ;-------------------------------------------------------------------------------- diff --git a/inventory.asm b/inventory.asm index 322f0a4..4851e73 100644 --- a/inventory.asm +++ b/inventory.asm @@ -1,17 +1,16 @@ ;================================================================================ ; Inventory Updates ;================================================================================ -; Item Tracking Slot ; InventoryTracking -; brmpnskf -------q -; b = blue boomerang | -; r = red boomerang | -; m = mushroom current | -; p = magic powder | -; n = mushroom past | -; s = shovel | -; k = fake flute | -; f = working flute | +; brmpnskf ------oq +; b = blue boomerang | - +; r = red boomerang | - +; m = mushroom current | - +; p = magic powder | - +; n = mushroom past | - +; s = shovel | - +; k = fake flute | o = any bomb acquired from item location +; f = working flute | q = quickswap locked ;-------------------------------------------------------------------------------- ; BowTracking ; Item Tracking Slot #2 @@ -35,8 +34,8 @@ ProcessMenuButtons: BIT #$20 : BNE .sel_pressed ; check for P1 Select button LDA $F0 : BIT #$20 : BNE .sel_held .sel_unheld - LDA !HUD_FLAG : AND #$20 : BEQ + - LDA !HUD_FLAG : AND #$DF : STA !HUD_FLAG ; select is released, unset hud flag + LDA HudFlag : AND #$20 : BEQ + + LDA HudFlag : AND #$DF : STA HudFlag ; select is released, unset hud flag LDA $1B : BEQ + ; skip if outdoors LDA.b #$20 : STA $012F ; menu select sound + @@ -45,11 +44,8 @@ ProcessMenuButtons: .sel_held CLC ; no buttons RTL - ;.l_pressed - ;JSL.l SpawnAngryCucco -;RTL .sel_pressed - LDA !HUD_FLAG : ORA #$20 : STA !HUD_FLAG ; set hud flag + LDA HudFlag : ORA #$20 : STA HudFlag ; set hud flag LDA.b #$20 : STA $012F ; menu select sound JSL.l ResetEquipment RTL @@ -178,8 +174,6 @@ RTL ;-------------------------------------------------------------------------------- ; AddInventory: ;-------------------------------------------------------------------------------- -!LOCK_STATS = "$7EF443" - macro TopHalf(address) LDA
: !ADD #$10 : STA
endmacro @@ -193,16 +187,16 @@ macro BottomHalf(address) endmacro ;-------------------------------------------------------------------------------- ;FullInventoryExternal: -; LDA !LOCK_STATS : BEQ + : RTL : + +; LDA StatsLocked : BEQ + : RTL : + ; PHA : PHX : PHP : JMP AddInventory_fullItemCounts ;-------------------------------------------------------------------------------- FullInventoryExternal: - LDA !LOCK_STATS : BEQ + : RTL : + + LDA StatsLocked : BEQ + : RTL : + PHA : PHX : PHP : JMP AddInventory_incrementCounts ;-------------------------------------------------------------------------------- -!SHAME_CHEST = "$7EF416" ; ---s ---- AddInventory: PHA : PHX : PHP + PHA : LDA DummyValue : PLA CPY.b #$0C : BNE + ; Blue Boomerang LDA InventoryTracking : ORA #$80 : STA InventoryTracking JMP .incrementCounts @@ -248,7 +242,7 @@ AddInventory: + .incrementCounts - LDA !LOCK_STATS : BEQ + : JMP .done : + + LDA StatsLocked : BEQ + : JMP .done : + ; don't count any of this stuff CPY.b #$20 : BNE + : JMP .itemCounts : + ; Crystal @@ -292,79 +286,63 @@ AddInventory: .dungeonCounts LDA $1B : BNE + : JMP .fullItemCounts : + - ; ==BEGIN INDOOR-ONLY SECTION - - ;REP #$20 ; Set 16-bit Accumulator - ;LDA $A0 ; load room ID - ;CMP.w #$0010 : BNE + ; Ganon Fall Room - I think this got taken out - ;!SHAME_CHEST = "$7EF416" ; ---s ---- - ;LDA !SHAME_CHEST : ORA.w #$0010 : STA !SHAME_CHEST - ;+ SEP #$20 ; Set 8-bit Accumulator LDA $040C ; get dungeon id CMP.b #$00 : BNE + ; Sewers (Escape) + LDA SewersLocations : INC : STA SewersLocations + LDA HCLocations : INC : STA HCLocations BRA ++ + CMP.b #$02 : BNE + ; Hyrule Castle (Escape) ++ CPY.b #$32 : BNE ++ : JMP .itemCounts : ++ ; Ball & Chain Guard's Big Key - %TopHalf($7EF434) + LDA HCLocations : INC : STA HCLocations + LDA SewersLocations : INC : STA SewersLocations JMP .fullItemCounts + CMP.b #$04 : BNE + ; Eastern Palace - LDA $7EF436 : INC : AND #$07 : TAX - LDA $7EF436 : AND #$F8 : STA $7EF436 - TXA : ORA $7EF436 : STA $7EF436 + LDA EPLocations : INC : STA EPLocations JMP .fullItemCounts + CMP.b #$06 : BNE + ; Desert Palace - LDA $7EF435 : !ADD #$20 : STA $7EF435 + LDA DPLocations : INC : STA DPLocations JMP .fullItemCounts + CMP.b #$08 : BNE + ; Agahnim's Tower - LDA $7EF435 : INC : AND #$03 : TAX - LDA $7EF435 : AND #$FC : STA $7EF435 - TXA : ORA $7EF435 : STA $7EF435 + LDA CTLocations : INC : STA CTLocations JMP .fullItemCounts + CMP.b #$0A : BNE + ; Swamp Palace - %BottomHalf($7EF439) + LDA SPLocations : INC : STA SPLocations JMP .fullItemCounts + CMP.b #$0C : BNE + ; Palace of Darkness - %BottomHalf($7EF434) + LDA PDLocations : INC : STA PDLocations JMP .fullItemCounts + CMP.b #$0E : BNE + ; Misery Mire - %BottomHalf($7EF438) + LDA MMLocations : INC : STA MMLocations JMP .fullItemCounts + CMP.b #$10 : BNE + ; Skull Woods - %TopHalf($7EF437) + LDA SWLocations : INC : STA SWLocations JMP .fullItemCounts + CMP.b #$12 : BNE + ; Ice Palace - %TopHalf($7EF438) + LDA IPLocations : INC : STA IPLocations JMP .fullItemCounts + CMP.b #$14 : BNE + ; Tower of Hera - LDA $7EF435 : !ADD #$04 : AND #$1C : TAX - LDA $7EF435 : AND #$E3 : STA $7EF435 - TXA : ORA $7EF435 : STA $7EF435 + LDA THLocations : INC : STA THLocations JMP .fullItemCounts + CMP.b #$16 : BNE + ; Thieves' Town - %BottomHalf($7EF437) + LDA TTLocations : INC : STA TTLocations JMP .fullItemCounts + CMP.b #$18 : BNE + ; Turtle Rock - %TopHalf($7EF439) + LDA TRLocations : INC : STA TRLocations JMP .fullItemCounts + CMP.b #$1A : BNE + ; Ganon's Tower - LDA $7EF436 : !ADD #$08 : STA $7EF436 + LDA GTLocations : INC : STA GTLocations LDA BigKeyField : AND #$04 : BNE ++ JSR .incrementGTowerPreBigKey ++ - ;JMP .fullItemCounts + ; == END INDOOR-ONLY SECTION .fullItemCounts - ;CPY.b #$3B : BNE + ; Skip Total Counts for Repeat Silver Arrows - ; LDA $7EF42A : BIT #$20 : BEQ + : BRA .itemCounts - ;+ - LDA BootsEquipment : BNE + ; Check for Boots LDA PreBootsLocations : INC : STA PreBootsLocations ; Increment Pre Boots Counter + @@ -377,7 +355,7 @@ AddInventory: LDA PreFluteLocations : INC : STA PreFluteLocations ; Increment Pre Mirror Counter + - LDA $7EF423 : INC : STA $7EF423 ; Increment Item Total + LDA TotalItemCounter : INC : STA TotalItemCounter ; Increment Item Total .itemCounts @@ -462,12 +440,12 @@ AddInventory: ;JSR .incrementHeartContainer JMP .done + CPY.b #$27 : BNE + ; 1 Bomb - ;JSR .maybeIncrementBombs + JSR .maybeIncrementBombs JMP .done + CPY.b #$28 : BNE + ; 3 Bombs - ;JSR .maybeIncrementBombs + JSR .maybeIncrementBombs JMP .done - + CPY.b #$29 : BNE + ; Musoroom + + CPY.b #$29 : BNE + ; Mushroom JSR .incrementY JMP .done + CPY.b #$2A : !BLT + ; Items $2A - $2D @@ -475,7 +453,7 @@ AddInventory: JSR .incrementY JMP .done + CPY.b #$31 : BNE + ; 10 Bombs - ;JSR .maybeIncrementBombs + JSR .maybeIncrementBombs JMP .done + CPY.b #$32 : BNE + ; Big Key JSR .incrementBigKey @@ -516,9 +494,9 @@ AddInventory: JSR .stampBoots JSR .incrementA JMP .done - + CPY.b #$4C : BNE + ; Bomb Capacity Upgrade + + CPY.b #$4C : BNE + ; 50 Bomb Capacity Upgrade JSR .incrementCapacity - ;JSR .maybeIncrementBombs + JSR .maybeIncrementBombs JMP .done + CPY.b #$4D : !BLT + ; Items $4D - $4F - Capacity Upgrades CPY.b #$50 : !BGE + @@ -528,6 +506,14 @@ AddInventory: LDX #$02 JSR .incrementSword JMP .done + + CPY.b #$51 : BNE + ; 5 Bomb Capacity Upgrade + LDX #$02 + JSR .maybeIncrementBombs + JMP .done + + CPY.b #$52 : BNE + ; 10 Bomb Capacity Upgrade + LDX #$02 + JSR .maybeIncrementBombs + JMP .done + CPY.b #$51 : !BLT + ; Items $51 - $54 - Capacity Upgrades CPY.b #$55 : !BGE + JSR .incrementCapacity @@ -577,49 +563,42 @@ RTL ; WHICH BEE IS BOTTLED? ; MAKE SURE FAIRY FOUNTAINS DON'T FUCK THE COUNTS UP -!NMI_TIME = "$7EF43E" - -!SWORD_TIME = "$7EF458" -!BOOTS_TIME = "$7EF45C" -!FLUTE_TIME = "$7EF460" -!MIRROR_TIME = "$7EF464" - .stampSword REP #$20 ; set 16-bit accumulator - LDA !SWORD_TIME : BNE + - LDA !SWORD_TIME+2 : BNE + - LDA !NMI_TIME : STA !SWORD_TIME - LDA !NMI_TIME+2 : STA !SWORD_TIME+2 + LDA SwordTime : BNE + + LDA SwordTime+2 : BNE + + LDA NMIFrames : STA SwordTime + LDA NMIFrames+2 : STA SwordTime+2 + SEP #$20 ; set 8-bit accumulator RTS .stampBoots REP #$20 ; set 16-bit accumulator - LDA !BOOTS_TIME : BNE + - LDA !BOOTS_TIME+2 : BNE + - LDA !NMI_TIME : STA !BOOTS_TIME - LDA !NMI_TIME+2 : STA !BOOTS_TIME+2 + LDA BootsTime : BNE + + LDA BootsTime+2 : BNE + + LDA NMIFrames : STA BootsTime + LDA NMIFrames+2 : STA BootsTime+2 + SEP #$20 ; set 8-bit accumulator RTS .stampFlute REP #$20 ; set 16-bit accumulator - LDA !FLUTE_TIME : BNE + - LDA !FLUTE_TIME+2 : BNE + - LDA !NMI_TIME : STA !FLUTE_TIME - LDA !NMI_TIME+2 : STA !FLUTE_TIME+2 + LDA FluteTime : BNE + + LDA FluteTime+2 : BNE + + LDA NMIFrames : STA FluteTime + LDA NMIFrames+2 : STA FluteTime+2 + SEP #$20 ; set 8-bit accumulator RTS .stampMirror REP #$20 ; set 16-bit accumulator - LDA !MIRROR_TIME : BNE + - LDA !MIRROR_TIME+2 : BNE + - LDA !NMI_TIME : STA !MIRROR_TIME - LDA !NMI_TIME+2 : STA !MIRROR_TIME+2 + LDA MirrorTime : BNE + + LDA MirrorTime+2 : BNE + + LDA NMIFrames : STA MirrorTime + LDA NMIFrames+2 : STA MirrorTime+2 + SEP #$20 ; set 8-bit accumulator RTS @@ -684,36 +663,30 @@ RTS RTL .incrementKey - PHA : PHX - LDA $7EF424 : INC : AND #$3F : TAX - LDA $7EF424 : AND #$C0 : STA $7EF424 - TXA : ORA $7EF424 : STA $7EF424 - PLX : PLA + LDA SmallKeyCounter : INC : STA SmallKeyCounter RTS .incrementCompass - %BottomHalf($7EF428) + %BottomHalf(MapsCompasses) RTS .incrementBigKey - LDA $7EF427 : !ADD #$10 : STA $7EF427 + %TopHalf(BigKeysBigChests) RTS .incrementGTowerPreBigKey - LDA $7EF42A : INC : AND #$1F : TAX - LDA $7EF42A : AND #$E0 : STA $7EF42A - TXA : ORA $7EF42A : STA $7EF42A + LDA PreGTBKLocations : INC : STA PreGTBKLocations RTS -;.maybeIncrementBombs -; LDA $7EF42A : AND #$80 : BNE + -; LDA $7EF42A : ORA #$80 : STA $7EF42A -; JSR .incrementY -; + -;RTS +.maybeIncrementBombs + LDA InventoryTracking+1 : AND #$02 : BNE + + LDA InventoryTracking+1 : ORA #$02 : STA InventoryTracking+1 + JSR .incrementY + + +RTS .incrementMap - LDA $7EF428 : !ADD #$10 : STA $7EF428 + %TopHalf(MapsCompasses) RTS .incrementBossSwordLong @@ -723,16 +696,17 @@ RTL .incrementBossSword LDA SwordEquipment BNE + : - - %TopHalf($7EF452) : RTS + LDA SwordlessBossKills : INC : STA SwordlessBossKills + RTS + CMP #$FF : BEQ - + CMP #$01 : BNE + - %TopHalf($7EF425) : RTS + %TopHalf(SwordBossKills) : RTS + CMP #$02 : BNE + - %BottomHalf($7EF425) : RTS + %BottomHalf(SwordBossKills) : RTS + CMP #$03 : BNE + - %TopHalf($7EF426) : RTS + %TopHalf(SwordBossKills+1) : RTS + CMP #$04 : BNE + - %BottomHalf($7EF426) + %BottomHalf(SwordBossKills+1) + RTS ;-------------------------------------------------------------------------------- @@ -865,7 +839,7 @@ LoadKeys: LDA CurrentGenericKeys RTL + - LDA SewerKeys, X + LDA DungeonKeys, X RTL ;-------------------------------------------------------------------------------- @@ -878,7 +852,7 @@ SaveKeys: PLA : STA CurrentGenericKeys RTL + - PLA : STA SewerKeys, X + PLA : STA DungeonKeys, X RTL ;-------------------------------------------------------------------------------- diff --git a/newitems.asm b/newitems.asm index d27836f..c66ceb2 100755 --- a/newitems.asm +++ b/newitems.asm @@ -155,14 +155,14 @@ ProcessEventItems: LDA $02D8 CMP.b #$E0 : BNE + REP #$30 ; set 16-bit accumulator & index registers - LDA $7EF450 : ASL : TAX + LDA RNGItem : ASL : TAX LDA.l EventDataOffsets, X : !ADD #EventDataTable : STA $00 SEP #$20 ; set 8-bit accumulator LDA.b #$AF : STA $02 JSL.l LoadDialogAddressIndirect - LDA $7EF450 : INC : STA $7EF450 + LDA RNGItem : INC : STA RNGItem SEP #$10 ; set 8-bit index registers @@ -373,7 +373,7 @@ AddReceivedItemExpandedGetItem: JMP .done + CMP.b #$A0 : !BLT + : CMP.b #$B0 : !BGE + ; Free Small Key AND #$0F : TAX - LDA SewerKeys, X : INC : STA SewerKeys, X ; Increment Key Count + LDA DungeonKeys, X : INC : STA DungeonKeys, X ; Increment Key Count CPX.b #$00 : BNE ++ STA HyruleCastleKeys ; copy HC to sewers @@ -400,8 +400,6 @@ RTL ; #$90 - Big Keys ; #$A0 - Small Keys ;-------------------------------------------------------------------------------- -!HIGHEST_ARMOR_SHIELD_SWORD = "$7EF416" ; ss-- ---- -!RNG_ITEM = "$7EF450" !SCRATCH_AREA = "$7F5020" !SINGLE_INDEX_TEMP = "$7F5020" !SINGLE_INDEX_OFFSET_TEMP = "$7F5021" @@ -966,7 +964,6 @@ RTL LDA.b #$24 : STA $7EC723 RTL ;-------------------------------------------------------------------------------- -!RNG_ITEM = "$7EF450" !SCRATCH_AREA = "$7F5020" !SINGLE_INDEX_TEMP = "$7F5020" !SINGLE_INDEX_OFFSET_TEMP = "$7F5021" @@ -1004,7 +1001,7 @@ RTL ;-------------------------------------------------------------------------------- CheckSingleItem: LSR #3 : TAX - LDA.l !RNG_ITEM, X : STA !SINGLE_INDEX_BITMASK_TEMP ; load value to temporary + LDA.l RNGItem, X : STA !SINGLE_INDEX_BITMASK_TEMP ; load value to temporary PHX LDA !SINGLE_INDEX_TEMP : AND #$07 : TAX ; load 0-7 part into X LDA !SINGLE_INDEX_BITMASK_TEMP @@ -1022,7 +1019,7 @@ MarkRNGItemSingle: ;STA !SINGLE_INDEX_TEMP LSR #3 : STA !SINGLE_INDEX_OFFSET_TEMP : TAX - LDA.l !RNG_ITEM, X + LDA.l RNGItem, X STA.l !SINGLE_INDEX_BITMASK_TEMP LDA.l !SINGLE_INDEX_TEMP : AND #$07 : TAX ; load 0-7 part into X LDA.b #01 @@ -1037,7 +1034,7 @@ MarkRNGItemSingle: LDA.l !SINGLE_INDEX_OFFSET_TEMP : TAX PLA ORA.l !SINGLE_INDEX_BITMASK_TEMP - STA.l !RNG_ITEM, X + STA.l RNGItem, X RTS ;-------------------------------------------------------------------------------- GetRNGItemMulti: @@ -1114,6 +1111,7 @@ JML.l StatsFinalPrep ;-------------------------------------------------------------------------------- ChestPrep: LDA.b #$01 : STA $02E9 + JSL.l IncrementChestCounter LDA.l ServerRequestMode : BEQ + JSL.l ChestItemServiceRequest RTL diff --git a/sram.asm b/sram.asm index 12f7ee5..48fa221 100644 --- a/sram.asm +++ b/sram.asm @@ -1,4 +1,3 @@ -org 0 ;================================================================================ ; SRAM Labels & Assertions ;-------------------------------------------------------------------------------- @@ -9,6 +8,7 @@ org 0 ; $7F6000 - $7F6FFF in WRAM maps to the next 4k bytes, occupying the 2nd and 3rd vanilla ; save file locations. ($700500 - $701500) ;-------------------------------------------------------------------------------- +org 0 ; This module writes no bytes. Asar gives bank cross errors without this. ;================================================================================ ; Room Data ($7EF000 - $7EF27F @@ -365,7 +365,8 @@ ExtendedFileNameSRAM: skip 24 ; We read and write the file name directly from skip $1AE8 ; 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. -VERSIONSRAM: skip 4 ; ALTTPR ROM version (32 bytes) +RomVersionSRAM: skip 4 ; ALTTPR ROM version. Low byte is the version, high byte writes + ; $01 for now (32-bits total) skip 4071 ; PasswordSRAM: skip 16 ; Password value (16 bytes) @@ -573,7 +574,7 @@ assert InventoryTrackingSRAM = $70038C, "InventoryTracking labeled at incorrect assert BowTrackingSRAM = $70038E, "BowTracking labeled at incorrect address" assert ExtendedFileNameSRAM = $700500, "ExtendedFilenameSRAM labeled at incorrect address" assert RomNameSRAM = $702000, "RomNameSRAM at incorrect address" -assert VERSIONSRAM = $702015, "VERSIONSRAM at incorrect address" +assert RomVersionSRAM = $702015, "RomVersionSRAM at incorrect address" assert PasswordSRAM = $703000, "PasswordSRAM at incorrect address" ;-------------------------------------------------------------------------------- From 7c6c5f4316bae369179f26ef1558ae69b696a305 Mon Sep 17 00:00:00 2001 From: cassidy Date: Mon, 6 Dec 2021 23:38:28 -0500 Subject: [PATCH 11/96] Add absorbed keys Adjust service request stuff Change chest keys to "collected" keys --- events.asm | 2 +- servicerequest.asm | 6 +-- sram.asm | 103 +++++++++++++++++++++++++++++---------------- stats.asm | 2 +- 4 files changed, 71 insertions(+), 42 deletions(-) diff --git a/events.asm b/events.asm index dc24221..5bfb979 100644 --- a/events.asm +++ b/events.asm @@ -135,7 +135,7 @@ OnNewFile: BPL - LDX #$0008 : - ; copy starting keys to chest key counters in sram - LDA DungeonKeys, X : STA DungeonChestKeys, X + LDA DungeonKeys, X : STA DungeonCollectedKeys, X DEX : DEX BPL - diff --git a/servicerequest.asm b/servicerequest.asm index a502de8..a5318c9 100644 --- a/servicerequest.asm +++ b/servicerequest.asm @@ -46,10 +46,10 @@ ; ;-------------------------------------------------------------------------------- !RX_BUFFER = "$7F5300" !RX_STATUS = "$7F537F" -!RX_SEQUENCE = "$7EF4A0" +;ServiceSequenceRx = $7EF4A0 !TX_BUFFER = "$7F5380" !TX_STATUS = "$7F53FF" -!TX_SEQUENCE = "$7EF4A0" +;ServiceSequenceTx = $7EF4A0 ;-------------------------------------------------------------------------------- macro ServiceRequestVersion() LDA !TX_STATUS : BEQ + : CLC : RTL : + ; return fail if we don't have the lock @@ -153,4 +153,4 @@ ItemGetServiceRequest_F1: ;-------------------------------------------------------------------------------- ItemGetServiceRequest_F2: %ServiceRequest(!SCM_GET, #$F2) -;-------------------------------------------------------------------------------- \ No newline at end of file +;-------------------------------------------------------------------------------- diff --git a/sram.asm b/sram.asm index 48fa221..29a329a 100644 --- a/sram.asm +++ b/sram.asm @@ -296,11 +296,26 @@ SmallKeyCounter: skip 1 ; Total Number of small keys collected (integer) HeartPieceCounter: skip 1 ; Total Number of heartpieces collected (integer) CrystalCounter: skip 1 ; Total Number of crystals collected (integer) skip 46 ; Unused -ServiceRequestReceive: ; -ServiceRequestTransmit: ; -ServiceRequest: skip 8 ; Service request block. See servicerequest.asm -skip 42 ; Unused - ; \ Dungeon locations checked counters (integers) +ServiceSequenceRx: ; Service sequence receive +ServiceSequenceTx: ; Service sequence transmit +ServiceSequence: skip 8 ; Service request block. See servicerequest.asm +skip 28 ; Unused +DungeonAbsorbedKeys: ; \ Absorbed key counters (integers) +SewerAbsorbedKeys: skip 1 ; | Sewer Passage +HCAbsorbedKeys: skip 1 ; | Hyrule Castle +EPAbsorbedKeys: skip 1 ; | Eastern Palace +DPAbsorbedKeys: skip 1 ; | Desert Palace +CTAbsorbedKeys: skip 1 ; | Agahnim's Tower +SPAbsorbedKeys: skip 1 ; | Swamp Palace +PDAbsorbedKeys: skip 1 ; | Palace of Darkness +MMAbsorbedKeys: skip 1 ; | Misery Mire +SWAbsorbedKeys: skip 1 ; | Skull Woods +IPAbsorbedKeys: skip 1 ; | Ice Palace +THAbsorbedKeys: skip 1 ; | Tower of Hera +TTAbsorbedKeys: skip 1 ; | Thieves' Town +TRAbsorbedKeys: skip 1 ; | Turtle Rock +GTAbsorbedKeys: skip 1 ; / Ganon's Tower +DungeonLocationsChecked: ; \ Dungeon locations checked counters (integers) SewersLocations: skip 1 ; | Sewer Passage HCLocations: skip 1 ; | Hyrule Castle EPLocations: skip 1 ; | Eastern Palace @@ -314,22 +329,22 @@ IPLocations: skip 1 ; | Ice Palace THLocations: skip 1 ; | Tower of Hera TTLocations: skip 1 ; | Thieves' Town TRLocations: skip 1 ; | Turtle Rock -GTLocations: skip 1 ; / Ganon's Tower -DungeonChestKeys: ; \ Chest Key Counters. Only counts keys placed in chests. (integers) -SewerChestKeys: skip 1 ; | Sewer Passage -HCChestKeys: skip 1 ; | Hyrule Castle -EPChestKeys: skip 1 ; | Eastern Palace -DPChestKeys: skip 1 ; | Desert Palace -CTChestKeys: skip 1 ; | Agahnim's Tower -SPChestKeys: skip 1 ; | Swamp Palace -PDChestKeys: skip 1 ; | Palace of Darkness -MMChestKeys: skip 1 ; | Misery Mire -SWChestKeys: skip 1 ; | Skull Woods -IPChestKeys: skip 1 ; | Ice Palace -THChestKeys: skip 1 ; | Tower of Hera -TTChestKeys: skip 1 ; | Thieves' Town -TRChestKeys: skip 1 ; | Turtle Rock -GTChestKeys: skip 1 ; / Ganon's Tower +GTLocations: skip 1 ; / Ganon's Tower: +DungeonCollectedKeys: ; \ Chest Key Counters. Only counts keys placed in chests. (integers) +SewerCollectedKeys: skip 1 ; | Sewer Passage +HCCollectedKeys: skip 1 ; | Hyrule Castle +EPCollectedKeys: skip 1 ; | Eastern Palace +DPCollectedKeys: skip 1 ; | Desert Palace +CTCollectedKeys: skip 1 ; | Agahnim's Tower +SPCollectedKeys: skip 1 ; | Swamp Palace +PDCollectedKeys: skip 1 ; | Palace of Darkness +MMCollectedKeys: skip 1 ; | Misery Mire +SWCollectedKeys: skip 1 ; | Skull Woods +IPCollectedKeys: skip 1 ; | Ice Palace +THCollectedKeys: skip 1 ; | Tower of Hera +TTCollectedKeys: skip 1 ; | Thieves' Town +TRCollectedKeys: skip 1 ; | Turtle Rock +GTCollectedKeys: skip 1 ; / Ganon's Tower skip 2 ; Reserved, may be indexed into and have junk generic key data written FileMarker: skip 1 ; $FF = Active save file | $00 = Inactive save file skip 13 ; Unused @@ -528,8 +543,22 @@ assert SmallKeyCounter = $7EF46F, "SmallKeyCounter labeled at incorrect a assert HeartPieceCounter = $7EF470, "HeartPieceCounter labeled at incorrect address" assert CrystalCounter = $7EF471, "CrystalCounter labeled at incorrect address" ;-------------------------------------------------------------------------------- -assert ServiceRequest = $7EF4A0, "ServiceRequest labeled at incorrect address" +assert ServiceSequence = $7EF4A0, "ServiceSequence labeled at incorrect address" ;-------------------------------------------------------------------------------- +assert SewerAbsorbedKeys = $7EF4E0, "SewerAbsorbedKeys labeled at incorrect address" +assert HCAbsorbedKeys = $7EF4E1, "HCAbsorbedKeys labeled at incorrect address" +assert EPAbsorbedKeys = $7EF4E2, "EPAbsorbedKeys labeled at incorrect address" +assert DPAbsorbedKeys = $7EF4E3, "DPAbsorbedKeys labeled at incorrect address" +assert CTAbsorbedKeys = $7EF4E4, "ATAbsorbedKeys labeled at incorrect address" +assert SPAbsorbedKeys = $7EF4E5, "SPAbsorbedKeys labeled at incorrect address" +assert PDAbsorbedKeys = $7EF4E6, "PDAbsorbedKeys labeled at incorrect address" +assert MMAbsorbedKeys = $7EF4E7, "MMAbsorbedKeys labeled at incorrect address" +assert SWAbsorbedKeys = $7EF4E8, "SWAbsorbedKeys labeled at incorrect address" +assert IPAbsorbedKeys = $7EF4E9, "IPAbsorbedKeys labeled at incorrect address" +assert THAbsorbedKeys = $7EF4EA, "THAbsorbedKeys labeled at incorrect address" +assert TTAbsorbedKeys = $7EF4EB, "TTAbsorbedKeys labeled at incorrect address" +assert TRAbsorbedKeys = $7EF4EC, "TRAbsorbedKeys labeled at incorrect address" +assert GTAbsorbedKeys = $7EF4ED, "GCAbsorbedKeys labeled at incorrect address" assert SewersLocations = $7EF4D2, "SewersLocations labeled at incorrect address" assert HCLocations = $7EF4D3, "HCLocations labeled at incorrect address" assert EPLocations = $7EF4D4, "EPLocations labeled at incorrect address" @@ -544,20 +573,20 @@ assert THLocations = $7EF4DC, "THLocations labeled at incorrect addre assert TTLocations = $7EF4DD, "TTLocations labeled at incorrect address" assert TRLocations = $7EF4DE, "TRLocations labeled at incorrect address" assert GTLocations = $7EF4DF, "GTLocations labeled at incorrect address" -assert SewerChestKeys = $7EF4E0, "SewerChestKeys labeled at incorrect address" -assert HCChestKeys = $7EF4E1, "HCChestKeys labeled at incorrect address" -assert EPChestKeys = $7EF4E2, "EPChestKeys labeled at incorrect address" -assert DPChestKeys = $7EF4E3, "DPChestKeys labeled at incorrect address" -assert CTChestKeys = $7EF4E4, "ATChestKeys labeled at incorrect address" -assert SPChestKeys = $7EF4E5, "SPChestKeys labeled at incorrect address" -assert PDChestKeys = $7EF4E6, "PDChestKeys labeled at incorrect address" -assert MMChestKeys = $7EF4E7, "MMChestKeys labeled at incorrect address" -assert SWChestKeys = $7EF4E8, "SWChestKeys labeled at incorrect address" -assert IPChestKeys = $7EF4E9, "IPChestKeys labeled at incorrect address" -assert THChestKeys = $7EF4EA, "THChestKeys labeled at incorrect address" -assert TTChestKeys = $7EF4EB, "TTChestKeys labeled at incorrect address" -assert TRChestKeys = $7EF4EC, "TRChestKeys labeled at incorrect address" -assert GTChestKeys = $7EF4ED, "GChestKeys labeled at incorrect address" +assert SewerCollectedKeys = $7EF4E0, "SewerCollectedKeys labeled at incorrect address" +assert HCCollectedKeys = $7EF4E1, "HCCollectedKeys labeled at incorrect address" +assert EPCollectedKeys = $7EF4E2, "EPCollectedKeys labeled at incorrect address" +assert DPCollectedKeys = $7EF4E3, "DPCollectedKeys labeled at incorrect address" +assert CTCollectedKeys = $7EF4E4, "ATCollectedKeys labeled at incorrect address" +assert SPCollectedKeys = $7EF4E5, "SPCollectedKeys labeled at incorrect address" +assert PDCollectedKeys = $7EF4E6, "PDCollectedKeys labeled at incorrect address" +assert MMCollectedKeys = $7EF4E7, "MMCollectedKeys labeled at incorrect address" +assert SWCollectedKeys = $7EF4E8, "SWCollectedKeys labeled at incorrect address" +assert IPCollectedKeys = $7EF4E9, "IPCollectedKeys labeled at incorrect address" +assert THCollectedKeys = $7EF4EA, "THCollectedKeys labeled at incorrect address" +assert TTCollectedKeys = $7EF4EB, "TTCollectedKeys labeled at incorrect address" +assert TRCollectedKeys = $7EF4EC, "TRCollectedKeys labeled at incorrect address" +assert GTCollectedKeys = $7EF4ED, "GTCollectedeys labeled at incorrect address" assert FileMarker = $7EF4F0, "FileMarker labeled at incorrect address" ;-------------------------------------------------------------------------------- assert ExtendedFileNameWRAM = $7F6000, "ExtendedFilenameWRAM labeled at incorrect address" @@ -587,7 +616,7 @@ assert PasswordSRAM = $703000, "PasswordSRAM at incorrect address" ;HighestMail: 7ef424 -> 7ef470 ;HighestShield: 7ef422 -> swords usingHighestSword, shields removed from general flags ; SmallKeyCounter: 7ef424 -> 7ef471 -; ServiceSequence: removed +; ServiceSequence: 7ef419 -> 7ef4a0 ; SwordsShields: 7ef422 -> swords usingHighestSword ; PreMirrorLocations: 7ef432 -> 7ef434, PreBoots and PreMirror now 2 bytes ; Heart Pieces: 7ef429 -> 7ef470 diff --git a/stats.asm b/stats.asm index 5003cfb..3c89446 100644 --- a/stats.asm +++ b/stats.asm @@ -127,7 +127,7 @@ CountChestKey: ; called by neighbor functions INC ; combines HC and Sewer counts + TAX .count - LDA DungeonChestKeys, X : INC : STA DungeonChestKeys, X + LDA DungeonCollectedKeys, X : INC : STA DungeonCollectedKeys, X .end PLX : PLA RTS From 046a98fdaf10d7ec91fd81e77c3abaa7b42c50ba Mon Sep 17 00:00:00 2001 From: cassidy Date: Mon, 6 Dec 2021 23:40:29 -0500 Subject: [PATCH 12/96] Fix asserts --- sram.asm | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/sram.asm b/sram.asm index 29a329a..b4af86b 100644 --- a/sram.asm +++ b/sram.asm @@ -545,20 +545,20 @@ assert CrystalCounter = $7EF471, "CrystalCounter labeled at incorrect ad ;-------------------------------------------------------------------------------- assert ServiceSequence = $7EF4A0, "ServiceSequence labeled at incorrect address" ;-------------------------------------------------------------------------------- -assert SewerAbsorbedKeys = $7EF4E0, "SewerAbsorbedKeys labeled at incorrect address" -assert HCAbsorbedKeys = $7EF4E1, "HCAbsorbedKeys labeled at incorrect address" -assert EPAbsorbedKeys = $7EF4E2, "EPAbsorbedKeys labeled at incorrect address" -assert DPAbsorbedKeys = $7EF4E3, "DPAbsorbedKeys labeled at incorrect address" -assert CTAbsorbedKeys = $7EF4E4, "ATAbsorbedKeys labeled at incorrect address" -assert SPAbsorbedKeys = $7EF4E5, "SPAbsorbedKeys labeled at incorrect address" -assert PDAbsorbedKeys = $7EF4E6, "PDAbsorbedKeys labeled at incorrect address" -assert MMAbsorbedKeys = $7EF4E7, "MMAbsorbedKeys labeled at incorrect address" -assert SWAbsorbedKeys = $7EF4E8, "SWAbsorbedKeys labeled at incorrect address" -assert IPAbsorbedKeys = $7EF4E9, "IPAbsorbedKeys labeled at incorrect address" -assert THAbsorbedKeys = $7EF4EA, "THAbsorbedKeys labeled at incorrect address" -assert TTAbsorbedKeys = $7EF4EB, "TTAbsorbedKeys labeled at incorrect address" -assert TRAbsorbedKeys = $7EF4EC, "TRAbsorbedKeys labeled at incorrect address" -assert GTAbsorbedKeys = $7EF4ED, "GCAbsorbedKeys labeled at incorrect address" +assert SewerAbsorbedKeys = $7EF4C4, "SewerAbsorbedKeys labeled at incorrect address" +assert HCAbsorbedKeys = $7EF4C5, "HCAbsorbedKeys labeled at incorrect address" +assert EPAbsorbedKeys = $7EF4C6, "EPAbsorbedKeys labeled at incorrect address" +assert DPAbsorbedKeys = $7EF4C7, "DPAbsorbedKeys labeled at incorrect address" +assert CTAbsorbedKeys = $7EF4C8, "ATAbsorbedKeys labeled at incorrect address" +assert SPAbsorbedKeys = $7EF4C9, "SPAbsorbedKeys labeled at incorrect address" +assert PDAbsorbedKeys = $7EF4CA, "PDAbsorbedKeys labeled at incorrect address" +assert MMAbsorbedKeys = $7EF4CB, "MMAbsorbedKeys labeled at incorrect address" +assert SWAbsorbedKeys = $7EF4CC, "SWAbsorbedKeys labeled at incorrect address" +assert IPAbsorbedKeys = $7EF4CD, "IPAbsorbedKeys labeled at incorrect address" +assert THAbsorbedKeys = $7EF4CE, "THAbsorbedKeys labeled at incorrect address" +assert TTAbsorbedKeys = $7EF4CF, "TTAbsorbedKeys labeled at incorrect address" +assert TRAbsorbedKeys = $7EF4D0, "TRAbsorbedKeys labeled at incorrect address" +assert GTAbsorbedKeys = $7EF4D1, "GCAbsorbedKeys labeled at incorrect address" assert SewersLocations = $7EF4D2, "SewersLocations labeled at incorrect address" assert HCLocations = $7EF4D3, "HCLocations labeled at incorrect address" assert EPLocations = $7EF4D4, "EPLocations labeled at incorrect address" From 7edaedf3f8c8146ade47dd3805cb188acbd67769 Mon Sep 17 00:00:00 2001 From: cassidy Date: Mon, 6 Dec 2021 23:54:24 -0500 Subject: [PATCH 13/96] Fix dungeon key and locations checked tables, reserve unused indices Swap locations checked with absorbed keys to match door rando --- sram.asm | 94 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 49 insertions(+), 45 deletions(-) diff --git a/sram.asm b/sram.asm index b4af86b..aff584d 100644 --- a/sram.asm +++ b/sram.asm @@ -299,22 +299,7 @@ skip 46 ; Unused ServiceSequenceRx: ; Service sequence receive ServiceSequenceTx: ; Service sequence transmit ServiceSequence: skip 8 ; Service request block. See servicerequest.asm -skip 28 ; Unused -DungeonAbsorbedKeys: ; \ Absorbed key counters (integers) -SewerAbsorbedKeys: skip 1 ; | Sewer Passage -HCAbsorbedKeys: skip 1 ; | Hyrule Castle -EPAbsorbedKeys: skip 1 ; | Eastern Palace -DPAbsorbedKeys: skip 1 ; | Desert Palace -CTAbsorbedKeys: skip 1 ; | Agahnim's Tower -SPAbsorbedKeys: skip 1 ; | Swamp Palace -PDAbsorbedKeys: skip 1 ; | Palace of Darkness -MMAbsorbedKeys: skip 1 ; | Misery Mire -SWAbsorbedKeys: skip 1 ; | Skull Woods -IPAbsorbedKeys: skip 1 ; | Ice Palace -THAbsorbedKeys: skip 1 ; | Tower of Hera -TTAbsorbedKeys: skip 1 ; | Thieves' Town -TRAbsorbedKeys: skip 1 ; | Turtle Rock -GTAbsorbedKeys: skip 1 ; / Ganon's Tower +skip 24 ; Unused DungeonLocationsChecked: ; \ Dungeon locations checked counters (integers) SewersLocations: skip 1 ; | Sewer Passage HCLocations: skip 1 ; | Hyrule Castle @@ -330,6 +315,23 @@ THLocations: skip 1 ; | Tower of Hera TTLocations: skip 1 ; | Thieves' Town TRLocations: skip 1 ; | Turtle Rock GTLocations: skip 1 ; / Ganon's Tower: +skip 2 ; Reserved for previous table +DungeonAbsorbedKeys: ; \ Absorbed key counters (integers) +SewerAbsorbedKeys: skip 1 ; | Sewer Passage +HCAbsorbedKeys: skip 1 ; | Hyrule Castle +EPAbsorbedKeys: skip 1 ; | Eastern Palace +DPAbsorbedKeys: skip 1 ; | Desert Palace +CTAbsorbedKeys: skip 1 ; | Agahnim's Tower +SPAbsorbedKeys: skip 1 ; | Swamp Palace +PDAbsorbedKeys: skip 1 ; | Palace of Darkness +MMAbsorbedKeys: skip 1 ; | Misery Mire +SWAbsorbedKeys: skip 1 ; | Skull Woods +IPAbsorbedKeys: skip 1 ; | Ice Palace +THAbsorbedKeys: skip 1 ; | Tower of Hera +TTAbsorbedKeys: skip 1 ; | Thieves' Town +TRAbsorbedKeys: skip 1 ; | Turtle Rock +GTAbsorbedKeys: skip 1 ; / Ganon's Tower +skip 2 ; Reserved for previous table DungeonCollectedKeys: ; \ Chest Key Counters. Only counts keys placed in chests. (integers) SewerCollectedKeys: skip 1 ; | Sewer Passage HCCollectedKeys: skip 1 ; | Hyrule Castle @@ -345,7 +347,7 @@ THCollectedKeys: skip 1 ; | Tower of Hera TTCollectedKeys: skip 1 ; | Thieves' Town TRCollectedKeys: skip 1 ; | Turtle Rock GTCollectedKeys: skip 1 ; / Ganon's Tower -skip 2 ; Reserved, may be indexed into and have junk generic key data written +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. @@ -544,35 +546,37 @@ assert HeartPieceCounter = $7EF470, "HeartPieceCounter labeled at incorrect assert CrystalCounter = $7EF471, "CrystalCounter labeled at incorrect address" ;-------------------------------------------------------------------------------- assert ServiceSequence = $7EF4A0, "ServiceSequence labeled at incorrect address" +assert ServiceSequenceRx = $7EF4A0, "ServiceSequenceRx labeled at incorrect address" +assert ServiceSequenceTx = $7EF4A0, "ServiceSequenceTx labeled at incorrect address" ;-------------------------------------------------------------------------------- -assert SewerAbsorbedKeys = $7EF4C4, "SewerAbsorbedKeys labeled at incorrect address" -assert HCAbsorbedKeys = $7EF4C5, "HCAbsorbedKeys labeled at incorrect address" -assert EPAbsorbedKeys = $7EF4C6, "EPAbsorbedKeys labeled at incorrect address" -assert DPAbsorbedKeys = $7EF4C7, "DPAbsorbedKeys labeled at incorrect address" -assert CTAbsorbedKeys = $7EF4C8, "ATAbsorbedKeys labeled at incorrect address" -assert SPAbsorbedKeys = $7EF4C9, "SPAbsorbedKeys labeled at incorrect address" -assert PDAbsorbedKeys = $7EF4CA, "PDAbsorbedKeys labeled at incorrect address" -assert MMAbsorbedKeys = $7EF4CB, "MMAbsorbedKeys labeled at incorrect address" -assert SWAbsorbedKeys = $7EF4CC, "SWAbsorbedKeys labeled at incorrect address" -assert IPAbsorbedKeys = $7EF4CD, "IPAbsorbedKeys labeled at incorrect address" -assert THAbsorbedKeys = $7EF4CE, "THAbsorbedKeys labeled at incorrect address" -assert TTAbsorbedKeys = $7EF4CF, "TTAbsorbedKeys labeled at incorrect address" -assert TRAbsorbedKeys = $7EF4D0, "TRAbsorbedKeys labeled at incorrect address" -assert GTAbsorbedKeys = $7EF4D1, "GCAbsorbedKeys labeled at incorrect address" -assert SewersLocations = $7EF4D2, "SewersLocations labeled at incorrect address" -assert HCLocations = $7EF4D3, "HCLocations labeled at incorrect address" -assert EPLocations = $7EF4D4, "EPLocations labeled at incorrect address" -assert DPLocations = $7EF4D5, "DPLocations labeled at incorrect address" -assert CTLocations = $7EF4D6, "CTLocations labeled at incorrect address" -assert SPLocations = $7EF4D7, "SPLocations labeled at incorrect address" -assert PDLocations = $7EF4D8, "PDLocations labeled at incorrect address" -assert MMLocations = $7EF4D9, "MMLocations labeled at incorrect address" -assert SWLocations = $7EF4DA, "SWLocations labeled at incorrect address" -assert IPLocations = $7EF4DB, "IPLocations labeled at incorrect address" -assert THLocations = $7EF4DC, "THLocations labeled at incorrect address" -assert TTLocations = $7EF4DD, "TTLocations labeled at incorrect address" -assert TRLocations = $7EF4DE, "TRLocations labeled at incorrect address" -assert GTLocations = $7EF4DF, "GTLocations labeled at incorrect address" +assert SewersLocations = $7EF4C0, "SewersLocations labeled at incorrect address" +assert HCLocations = $7EF4C1, "HCLocations labeled at incorrect address" +assert EPLocations = $7EF4C2, "EPLocations labeled at incorrect address" +assert DPLocations = $7EF4C3, "DPLocations labeled at incorrect address" +assert CTLocations = $7EF4C4, "CTLocations labeled at incorrect address" +assert SPLocations = $7EF4C5, "SPLocations labeled at incorrect address" +assert PDLocations = $7EF4C6, "PDLocations labeled at incorrect address" +assert MMLocations = $7EF4C7, "MMLocations labeled at incorrect address" +assert SWLocations = $7EF4C8, "SWLocations labeled at incorrect address" +assert IPLocations = $7EF4C9, "IPLocations labeled at incorrect address" +assert THLocations = $7EF4CA, "THLocations labeled at incorrect address" +assert TTLocations = $7EF4CB, "TTLocations labeled at incorrect address" +assert TRLocations = $7EF4CC, "TRLocations labeled at incorrect address" +assert GTLocations = $7EF4CD, "GTLocations labeled at incorrect address" +assert SewerAbsorbedKeys = $7EF4D0, "SewerAbsorbedKeys labeled at incorrect address" +assert HCAbsorbedKeys = $7EF4D1, "HCAbsorbedKeys labeled at incorrect address" +assert EPAbsorbedKeys = $7EF4D2, "EPAbsorbedKeys labeled at incorrect address" +assert DPAbsorbedKeys = $7EF4D3, "DPAbsorbedKeys labeled at incorrect address" +assert CTAbsorbedKeys = $7EF4D4, "ATAbsorbedKeys labeled at incorrect address" +assert SPAbsorbedKeys = $7EF4D5, "SPAbsorbedKeys labeled at incorrect address" +assert PDAbsorbedKeys = $7EF4D6, "PDAbsorbedKeys labeled at incorrect address" +assert MMAbsorbedKeys = $7EF4D7, "MMAbsorbedKeys labeled at incorrect address" +assert SWAbsorbedKeys = $7EF4D8, "SWAbsorbedKeys labeled at incorrect address" +assert IPAbsorbedKeys = $7EF4D9, "IPAbsorbedKeys labeled at incorrect address" +assert THAbsorbedKeys = $7EF4DA, "THAbsorbedKeys labeled at incorrect address" +assert TTAbsorbedKeys = $7EF4DB, "TTAbsorbedKeys labeled at incorrect address" +assert TRAbsorbedKeys = $7EF4DC, "TRAbsorbedKeys labeled at incorrect address" +assert GTAbsorbedKeys = $7EF4DD, "GCAbsorbedKeys labeled at incorrect address" assert SewerCollectedKeys = $7EF4E0, "SewerCollectedKeys labeled at incorrect address" assert HCCollectedKeys = $7EF4E1, "HCCollectedKeys labeled at incorrect address" assert EPCollectedKeys = $7EF4E2, "EPCollectedKeys labeled at incorrect address" From b943f86c15bf4f5087a64e4a6e63d5896e6e0098 Mon Sep 17 00:00:00 2001 From: cassidy Date: Tue, 14 Dec 2021 12:59:05 -0500 Subject: [PATCH 14/96] Write macro for SRAM assertions Change some label names to be clearer Fix some of the progress flags and dungeon bitfields --- events.asm | 4 +- fairyfixes.asm | 2 +- newhud.asm | 2 +- newitems.asm | 2 +- potions.asm | 6 +- retro.asm | 6 +- rupeelimit.asm | 2 +- shopkeeper.asm | 4 +- sram.asm | 445 +++++++++++++++++++++++++------------------------ stats.asm | 6 +- swordswap.asm | 4 +- 11 files changed, 243 insertions(+), 240 deletions(-) diff --git a/events.asm b/events.asm index 5bfb979..28afe9e 100644 --- a/events.asm +++ b/events.asm @@ -73,7 +73,7 @@ OnUncleItemGet: LDA.l ArrowMode : BEQ + LDA BowTracking : ORA #$80 : STA BowTracking ; enable bow toggle REP #$20 ; set 16-bit accumulator - LDA TargetRupees : !ADD.l FreeUncleItemAmount : STA TargetRupees ; rupee arrows, so also give the player some money to start + LDA CurrentRupees : !ADD.l FreeUncleItemAmount : STA CurrentRupees ; rupee arrows, so also give the player some money to start SEP #$20 ; set 8-bit accumulator + RTL @@ -125,7 +125,7 @@ RTL OnNewFile: PHX : PHP REP #$20 ; set 16-bit accumulator - LDA.l LinkStartingRupees : STA CurrentRupees : STA TargetRupees + LDA.l LinkStartingRupees : STA DisplayRupees : STA CurrentRupees LDA.l StartingTime : STA ChallengeTimer LDA.l StartingTime+2 : STA ChallengeTimer+2 diff --git a/fairyfixes.asm b/fairyfixes.asm index 9dec2b8..2305cd7 100644 --- a/fairyfixes.asm +++ b/fairyfixes.asm @@ -12,7 +12,7 @@ RTL ;-------------------------------------------------------------------------------- CheckFullHealth: LDA BigFairyHealth : BEQ + - LDA CurrentHealth : CMP HealthCapacity : BNE .player_hp_not_full_yet + LDA CurrentHealth : CMP MaximumHealth : BNE .player_hp_not_full_yet + LDA BigFairyMagic : BEQ + LDA CurrentMagic : CMP.b #$80 : BNE .player_mp_not_full_yet diff --git a/newhud.asm b/newhud.asm index 82c0afb..b6e5657 100644 --- a/newhud.asm +++ b/newhud.asm @@ -26,7 +26,7 @@ SEP #$30 !RUPEE_DRAW_ADDRESS = "$7EC750" ;================================================================================ - LDA.l CurrentRupees ; Drawing bombs (above) always ends with 16-bit A, so, no need to REP here + LDA.l DisplayRupees ; Drawing bombs (above) always ends with 16-bit A, so, no need to REP here JSR HudHexToDec4Digit LDX.b $04 : TXA : ORA.w #$2400 : STA !RUPEE_DRAW_ADDRESS ; 1000s LDX.b $05 : TXA : ORA.w #$2400 : STA !RUPEE_DRAW_ADDRESS+2 ; 100s diff --git a/newitems.asm b/newitems.asm index c66ceb2..b80f91d 100755 --- a/newitems.asm +++ b/newitems.asm @@ -274,7 +274,7 @@ AddReceivedItemExpandedGetItem: LDA.b #$01 : STA ArrowsFiller ++ + CMP.b #$59 : BNE + ; 1 Rupoor - REP #$20 : LDA TargetRupees : !SUB RupoorDeduction : STA TargetRupees : SEP #$20 ; Take 1 rupee + REP #$20 : LDA CurrentRupees : !SUB RupoorDeduction : STA CurrentRupees : SEP #$20 ; Take 1 rupee JMP .done + CMP.b #$5A : BNE + ; Null Item JMP .done diff --git a/potions.asm b/potions.asm index 5e9b4c6..1eddb15 100644 --- a/potions.asm +++ b/potions.asm @@ -16,7 +16,7 @@ RefillHealth: LDA !BUSY_HEALTH : BNE ++ LDA.l PotionHealthRefill ; load refill amount !ADD CurrentHealth ; add to current health - CMP HealthCapacity : !BLT +++ : LDA HealthCapacity : +++ + CMP MaximumHealth : !BLT +++ : LDA MaximumHealth : +++ STA !BUSY_HEALTH ++ @@ -35,8 +35,8 @@ RefillHealth: ; Check goal health versus actual health. ; if(actual < goal) then branch. - LDA CurrentHealth : CMP HealthCapacity : BCC .refillAllHealth - LDA HealthCapacity : STA CurrentHealth + LDA CurrentHealth : CMP MaximumHealth : BCC .refillAllHealth + LDA MaximumHealth : STA CurrentHealth LDA.b #$00 : STA HeartsFiller ; ??? not sure what purpose this branch serves. LDA $020A : BNE .beta diff --git a/retro.asm b/retro.asm index eca961f..8ccbac0 100644 --- a/retro.asm +++ b/retro.asm @@ -57,11 +57,11 @@ DecrementArrows: .shoot_arrow PHX REP #$20 - LDA TargetRupees : BEQ + + LDA CurrentRupees : BEQ + PHA : LDA BowEquipment : DEC : AND #$0002 : TAX : PLA !SUB.l ArrowModeWoodArrowCost, X ; CMP.w #$0000 BMI .not_enough_money - STA TargetRupees : LDA.w #$0001 : BRA + + STA CurrentRupees : LDA.w #$0001 : BRA + .not_enough_money LDA.w #$0000 + @@ -82,7 +82,7 @@ ArrowGame: PHX REP #$20 ; set 16-bit accumulator LDA BowEquipment : DEC : AND #$0002 : TAX - LDA TargetRupees : !ADD.l ArrowModeWoodArrowCost, X : STA TargetRupees + LDA CurrentRupees : !ADD.l ArrowModeWoodArrowCost, X : STA CurrentRupees SEP #$20 ; set 8-bit accumulator PLX + diff --git a/rupeelimit.asm b/rupeelimit.asm index f42d405..aa31845 100644 --- a/rupeelimit.asm +++ b/rupeelimit.asm @@ -9,7 +9,7 @@ Draw4DigitRupees: BRA .print .outdoors .normal - LDA CurrentRupees + LDA DisplayRupees .print JSL.l HexToDec LDA $7F5004 : AND.w #$00FF : ORA.w #$2400 : STA $7EC750 diff --git a/shopkeeper.asm b/shopkeeper.asm index b73648c..722ccf4 100644 --- a/shopkeeper.asm +++ b/shopkeeper.asm @@ -537,7 +537,7 @@ Shopkeeper_BuyItem: + LDA !SHOP_TYPE : AND.b #$80 : BNE .buy ; don't charge if this is a take-any - REP #$20 : LDA TargetRupees : CMP.l !SHOP_INVENTORY+1, X : SEP #$20 : !BGE .buy + REP #$20 : LDA CurrentRupees : CMP.l !SHOP_INVENTORY+1, X : SEP #$20 : !BGE .buy .cant_afford LDA.b #$7A @@ -553,7 +553,7 @@ Shopkeeper_BuyItem: JMP .done .buy LDA !SHOP_TYPE : AND.b #$80 : BNE ++ ; don't charge if this is a take-any - REP #$20 : LDA TargetRupees : !SUB !SHOP_INVENTORY+1, X : STA TargetRupees : SEP #$20 ; Take price away + REP #$20 : LDA CurrentRupees : !SUB !SHOP_INVENTORY+1, X : STA CurrentRupees : SEP #$20 ; Take price away ++ LDA.l !SHOP_INVENTORY, X : TAY : JSL.l Link_ReceiveItem LDA.l !SHOP_INVENTORY+3, X : INC : STA.l !SHOP_INVENTORY+3, X diff --git a/sram.asm b/sram.asm index aff584d..f1787aa 100644 --- a/sram.asm +++ b/sram.asm @@ -6,7 +6,7 @@ ;-------------------------------------------------------------------------------- ; $7EF000 - $7EF4FF in WRAM maps to the first $4FF bytes in SRAM (Bank $70) ; $7F6000 - $7F6FFF in WRAM maps to the next 4k bytes, occupying the 2nd and 3rd vanilla -; save file locations. ($700500 - $701500) +; save file locations. ($700500 - $701500) ;-------------------------------------------------------------------------------- org 0 ; This module writes no bytes. Asar gives bank cross errors without this. @@ -16,9 +16,9 @@ org 0 ; This module writes no bytes. Asar gives bank cross errors without this. ; Each room has two bytes. There are 296 ($128) rooms in the ROM. The data beyond ; $7EF24F is unused. The current room index is located at $A0 in WRAM (16-bits.) ; -; The quadrant bits from left to right correspond to quadrants -; 4 (northwest), 3 (northeast), 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 quadrant bits from left to right correspond to quadrants 4 (northwest), 3 (northeast), +; 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 ; floodable room in Swamp Palace ($04) @@ -27,10 +27,10 @@ org 0 ; This module writes no bytes. Asar gives bank cross errors without this. ; .low Byte: c c c c q q q q ; ; d = Door opened (key, bomb wall, etc) -; b = Boss kill / Heart Piece -; k = Key +; b = Boss kill / Heart Container +; k = Key / Heart Piece ; u = Second key -; t = Chest 4 / Rupee floor / Swamp drains +; t = Chest 4 / Rupee floor / Swamp drains / Bombable floor / Mire wall ; s = Chest 3 / Bomable floor / PoD or Desert wall ; e = Chest 2 ; h = Chest 1 @@ -56,7 +56,7 @@ endstruct align 2 ; ; i = Free-standing item collected. Also used for sprites like the castle tower barrier ; o = Overlay active -; b = Secondary overlay active +; b = Bomb wall opened ;-------------------------------------------------------------------------------- OverworldEventData = $7EF280 @@ -93,8 +93,8 @@ ByrnaEquipment: skip 1 ; $01 = Cane of Byrna CapeEquipment: skip 1 ; $01 = Magic Cape MirrorEquipment: skip 1 ; $01 = Scroll (graphic only) | $02 = Mirror GloveEquipment: skip 1 ; $01 = Power Gloves | $02 = Titan's Mitts -BootsEquipment: skip 1 ; \ $01 = Boots/Flippers | These only show menu item -FlippersEquipment: skip 1 ; / Correct bits must be set in AbilityFlags to dash/swim +BootsEquipment: skip 1 ; $01 = Boots | This only shows menu item, see: AbilityFlags +FlippersEquipment: skip 1 ; $01 = Flippers MoonPearlEquipment: skip 1 ; $01 = Moon Pearl skip 1 ; Not used SwordEquipment: skip 1 ; $01 = Fighter | $02 = Master | $03 = Tempered | $04 = Gold @@ -105,24 +105,23 @@ BottleContentsOne: skip 1 ; | BottleContentsTwo: skip 1 ; | $00 = No Bottle | $01 = Mushroom | $02 = Empty Bottle BottleContentsThree: skip 1 ; | $03 = Red Potion | $04 = Green Potion | $05 = Blue Potion BottleContentsFour: skip 1 ; / $06 = Fairy | $07 = Bee | $08 = Good Bee -TargetRupees: skip 2 ; \ CurrentRupees will always increment or decrement to match -CurrentRupees: skip 2 ; / TargetRupees if not equal (16-bit integer) +CurrentRupees: skip 2 ; \ DisplayRupees holds the number on the HUD. It will always +DisplayRupees: skip 2 ; / increment/decrement to match CurrentRupees if not equal (16-bit integers) ;-------------------------------------------------------------------------------- CompassField: skip 2 ; Dungeon item bitfields -BigKeyField: skip 2 ; High byte: - - g r t h i s -MapField: skip 2 ; g = Ganon's Tower | r = Turtle Rock | t = Thieves' Town - ; h = Tower of Hera | i = Ice Palace | s = Skull Woods +BigKeyField: skip 2 ; Low byte: w i h b t g - - +MapField: skip 2 ; w = Skull Woods | i = Ice Palace | h = Hera | b = Thieves' Town + ; t = Turtle Rock | g = Ganon's Tower ;------------------------------------------------ - ; Low Byte: m d s a t e h p - ; m = Misery Mire | d = Palace of Darkness | s = Swamp Palace - ; a = Aga Tower | t = Desert Palace | e = Eastern Palace - ; h = Hyrule Castle | s = Sewer Passage + ; High Byte: x c e d a s p m + ; x = Sewers | c = Hyrule Castle | e = Eastern Palace | d = Desert Palace + ; a = Castle Tower | s = Swamp Palace | p = PoD | m = Mire ;-------------------------------------------------------------------------------- ; HUD & other equipment skip 1 ; Wishing Pond Rupee (Unused) HeartPieceQuarter: skip 1 ; Heart pieces of four for health upgrade. Wraps around to $00 after $03. -HealthCapacity: skip 1 ; \ Health Capacity & Current Health -CurrentHealth: skip 1 ; / Max value is $A0 | $04 = half heart | $08 = heart +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 @@ -135,9 +134,9 @@ BombsFiller: skip 1 ; Bombs collected yet to be filled (integer) ArrowsFiller: skip 1 ; Arrows collected yet to be filled (integer) CurrentArrows: skip 1 ; Current arrows (integer) skip 1 ; Unknown -AbilityFlags: skip 1 ; - r t - p d s - (bitfield) - ; r = Read | t = Talk | p = Pull | d = Dash - ; s = Swim +AbilityFlags: skip 1 ; l r t u p d s h (bitfield) + ; l = Lift | r = Read | t = Talk | u = Unused but set by default + ; p = Pull | d = Dash | s = Swim | h = Pray (unused) CrystalsField: skip 1 ; - 3 4 2 7 5 1 6 (bitfield) MagicConsumption: skip 1 ; $00 = Normal | $01 = Half Magic | $02 = Quarter Magic ;-------------------------------------------------------------------------------- @@ -181,7 +180,7 @@ ProgressIndicator: skip 1 ; $00 = Pre-Uncle | $01 = Post-Uncle item | $02 ; $03 = Agahnim 1 defeated ; $04 and above don't do anything. $00-$02 used in standard mode ProgressFlags: skip 1 ; - - - u - z - s (bitfield) - ; u = Uncle left house | z = Mantle | s = Uncle item obtained + ; u = Uncle left house | z = Zelda rescued | s = Uncle item obtained MapIcons: skip 1 ; Used for deciding which icons to display on OW map ; $03 = Pendants | $04 = Master Sword | $05 = Skull at Hyrule Castle ; $06 = Crystal 1 | $07 = All Crystals | $08 = Skull at Ganon's Tower @@ -190,8 +189,8 @@ StartingEntrance: skip 1 ; Starting entrance to use ; $02 = Zelda's Cell | $03 = Secret Passage or HC if entered (escape) ; $04 = Throne Room (escape) | $05 = Old Man Cave w/ Old Man NpcFlagsVanilla: skip 1 ; - - b p s - m h (bitfield) - ; b = Frog rescued | p = Purple Chest | s = Stumpy (tree kid) - ; m = Bottle Merchant | h = Hobo + ; b = Frog rescued | p = Purple Chest | s = Tree Kid (unused) + ; m = Bottle Merchant item | h = Hobo item CurrentWorld: skip 1 ; $00 = Light World | $40 = Dark World skip 1 ; Unused FollowerIndicator: skip 1 ; $00 = No Follower | $01 = Zelda | $04 = Old Man @@ -397,218 +396,222 @@ base off ; All of these need to pass for the base rom to build or something is probably ; very wrong. ;-------------------------------------------------------------------------------- -assert WRAMEquipment = $7EF340, "WRAMEquipment labeled at incorrect address" -assert BowEquipment = $7EF340, "BowEquipment labeled at incorrect address" -assert BoomerangEquipment = $7EF341, "BoomerangEquipment labeled at incorrect address" -assert HookshotEquipment = $7EF342, "HookshotEquipment labeled at incorrect address" -assert BombsEquipment = $7EF343, "BombsEquipment labeled at incorrect address" -assert PowderEquipment = $7EF344, "PowderEquipment labeled at incorrect address" -assert FireRodEquipment = $7EF345, "FireRodEquipment labeled at incorrect address" -assert IceRodEquipment = $7EF346, "IceRodEquipment labeled at incorrect address" -assert BombosEquipment = $7EF347, "BombosEquipment labeled at incorrect address" -assert EtherEquipment = $7EF348, "EtherEquipment labeled at incorrect address" -assert QuakeEquipment = $7EF349, "QuakeEquipment labeled at incorrect address" -assert LampEquipment = $7EF34A, "LampEquipment labeled at incorrect address" -assert HammerEquipment = $7EF34B, "HammerEquipment labeled at incorrect address" -assert FluteEquipment = $7EF34C, "FluteEquipment labeled at incorrect address" -assert BugNetEquipment = $7EF34D, "BugNetEquipment labeled at incorrect address" -assert BookOfMudoraEquipment = $7EF34E, "BookOfMudoraEquipment labeled at incorrect address" -assert BottleIndex = $7EF34F, "BottleIndex labeled at incorrect address" -assert SomariaEquipment = $7EF350, "SomariaEquipment labeled at incorrect address" -assert ByrnaEquipment = $7EF351, "ByrnaEquipment labeled at incorrect address" -assert CapeEquipment = $7EF352, "CapeEquipment labeled at incorrect address" -assert MirrorEquipment = $7EF353, "MirrorEquipment labeled at incorrect address" -assert GloveEquipment = $7EF354, "GloveEquipment labeled at incorrect address" -assert BootsEquipment = $7EF355, "BootsEquipment labeled at incorrect address" -assert FlippersEquipment = $7EF356, "FlippersEquipment labeled at incorrect address" -assert MoonPearlEquipment = $7EF357, "MoonPearlEquipment labeled at incorrect address" -assert SwordEquipment = $7EF359, "SwordEquipment labeled at incorrect address" -assert ShieldEquipment = $7EF35A, "ShieldEquipment labeled at incorrect address" -assert ArmorEquipment = $7EF35B, "ArmorEquipment labeled at incorrect address" -assert BottleContentsOne = $7EF35C, "BottleContentsOne labeled at incorrect address" -assert BottleContentsTwo = $7EF35D, "BottleContentsTwo labeled at incorrect address" -assert BottleContentsThree = $7EF35E, "BottleContentsThree labeled at incorrect address" -assert BottleContentsFour = $7EF35F, "BottleContentsFour labeled at incorrect address" -assert TargetRupees = $7EF360, "TargetRupees labeled at incorrect address" -assert CurrentRupees = $7EF362, "CurrentRupees labeled at incorrect address" +macro assertSRAM(label, address) + assert