From b943f86c15bf4f5087a64e4a6e63d5896e6e0098 Mon Sep 17 00:00:00 2001 From: cassidy Date: Tue, 14 Dec 2021 12:59:05 -0500 Subject: [PATCH] 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