diff --git a/LTTP_RND_GeneralBugfixes.asm b/LTTP_RND_GeneralBugfixes.asm index 754ca76..2e5ae7d 100644 --- a/LTTP_RND_GeneralBugfixes.asm +++ b/LTTP_RND_GeneralBugfixes.asm @@ -9,7 +9,6 @@ lorom ;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) @@ -29,7 +28,7 @@ db #$20, #$19, #$08, #$31 ; year/month/day ;================================================================================ !ROM_VERSION_LOW ?= 1 ; ROM version (two 16-bit integers) -!ROM_VERSION_HIGH ?= 1 ; +!ROM_VERSION_HIGH ?= 2 ; org $00FFE0 ; Unused hardware vector RomVersion: @@ -43,38 +42,7 @@ dw !ROM_VERSION_HIGH !BLT = "BCC" !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] -!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 -;$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) - - !MS_GOT = "$7F5031" -!DARK_WORLD = "$7EF3CA" !REDRAW = "$7F5000" !GANON_WARP_CHAIN = "$7F5032"; @@ -115,6 +83,8 @@ incsrc treekid.asm incsrc spriteswap.asm incsrc hashalphabethooks.asm incsrc sharedplayerpalettefix.asm +incsrc ram.asm +incsrc sram.asm ;org $208000 ; bank #$20 org $A08000 ; bank #$A0 @@ -128,7 +98,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 @@ -198,7 +167,6 @@ org $A48000 ; code bank - PUT NEW CODE HERE incsrc glitched.asm incsrc hardmode.asm incsrc goalitem.asm -incsrc openmode.asm incsrc quickswap.asm incsrc endingsequence.asm incsrc cuccostorm.asm @@ -366,20 +334,21 @@ warnpc $B08000 ;$7E021B[0x1]: Used by race game instead of $0ABF to avoid witch item conflict ;$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 -;$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 @@ -629,6 +598,13 @@ OverworldMap_DarkWorldTilemap: org $0ABAB9 OverworldMap_LoadSprGfx: +org $0CD7D1 +NameFile_MakeScreenVisible: +org $0CDB3E +InitializeSaveFile: +org $0CDBC0 +InitializeSaveFile_build_checksum: + org $0DBA71 GetRandomInt: 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 d438755..85ff9d6 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 EquipmentWRAM, 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 @@ -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 @@ -214,7 +214,12 @@ FixJingleGlitch: .exit RTL - +;-------------------------------------------------------------------------------- +; Fix spawning with more hearts than capacity when less than 3 heart containers +pushpc + org $09F4AC ; <- module_death.asm:331 + db $08, $08, $10 +pullpc ;-------------------------------------------------------------------------------- SetOverworldTransitionFlags: LDA #$01 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 4308465..b691456 100644 --- a/compasses.asm +++ b/compasses.asm @@ -1,16 +1,6 @@ ;-------------------------------------------------------------------------------- ; $7F5010 - Scratch Space ;-------------------------------------------------------------------------------- -; The number of items in a dungeon never changes. use this macro instead of -; HexToDec when drawing the "??/XX" item counter -; %DrawConstantNumber(1,4) draws 14 -;-------------------------------------------------------------------------------- -macro DrawConstantNumber(digit1,digit2) - LDA.w #$2490+ : STA $7EC79A - LDA.w #$2490+ : STA $7EC79C - SEP #$20 -endmacro -;-------------------------------------------------------------------------------- DrawDungeonCompassCounts: LDX $1B : BNE + : RTL : + ; Skip if outdoors @@ -23,16 +13,27 @@ DrawDungeonCompassCounts: CPX.b #$1B : BCS .done ; Skip if not in a valid dungeon ID 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 ++ - JMP (CompassCountDungeonHandlers, X) : .return_spot - - ; we switch to 8-bit A in the jump before this + TXA : LSR : TAX + BNE + + INC + + + LDA.l CompassTotalsWRAM, X : AND #$00FF + SEP #$20 + JSR HudHexToDec2Digit + REP #$20 + PHX + LDX.b $06 : TXA : ORA #$2400 : STA $7EC79A + LDX.b $07 : TXA : ORA #$2400 : STA $7EC79C + PLX + + LDA DungeonLocationsChecked, X : AND #$00FF + SEP #$20 JSR HudHexToDec2Digit REP #$20 - LDX.b $06 : TXA : ORA #$2400 : STA $7EC794 ; Draw the item count LDX.b $07 : TXA : ORA #$2400 : STA $7EC796 @@ -44,103 +45,12 @@ RTL DungeonItemMasks: ; these are dungeon correlations to $7EF364 - $7EF369 so it knows where to store compasses, etc dw $8000, $4000, $2000, $1000, $0800, $0400, $0200, $0100 dw $0080, $0040, $0020, $0010, $0008, $0004 - -CompassCountDungeonHandlers: ; pointers to functions that handle dungeon-specific code - dw CompassCount_Escape, CompassCount_Escape ; (hyrule castle, sewers) - dw CompassCount_Eastern, CompassCount_Desert, CompassCount_Agah - dw CompassCount_Swamp, CompassCount_PoD, CompassCount_Mire - dw CompassCount_Skull, CompassCount_Ice, CompassCount_Hera - dw CompassCount_Thieves, CompassCount_Trock, CompassCount_Gt -} - -CompassCount_Escape: - %DrawConstantNumber(0,8) - LDA $7EF434 : LSR #4 - JMP DrawDungeonCompassCounts_return_spot - -CompassCount_Eastern: - %DrawConstantNumber(0,6) - LDA $7EF436 : AND.b #$07 - JMP DrawDungeonCompassCounts_return_spot - -CompassCount_Desert: - %DrawConstantNumber(0,6) - LDA $7EF435 : LSR #5 - JMP DrawDungeonCompassCounts_return_spot - -CompassCount_Agah: - %DrawConstantNumber(0,2) - LDA $7EF435 : AND.b #$03 - JMP DrawDungeonCompassCounts_return_spot - -CompassCount_Swamp: - %DrawConstantNumber(1,0) - LDA $7EF439 : AND.b #$0F - JMP DrawDungeonCompassCounts_return_spot - -CompassCount_PoD: - %DrawConstantNumber(1,4) - LDA $7EF434 : AND.b #$0F - JMP DrawDungeonCompassCounts_return_spot - -CompassCount_Mire: - %DrawConstantNumber(0,8) - LDA $7EF438 : AND.b #$0F - JMP DrawDungeonCompassCounts_return_spot - -CompassCount_Skull: - %DrawConstantNumber(0,8) - LDA $7EF437 : LSR #4 - JMP DrawDungeonCompassCounts_return_spot - -CompassCount_Ice: - %DrawConstantNumber(0,8) - LDA $7EF438 : LSR #4 - JMP DrawDungeonCompassCounts_return_spot - -CompassCount_Hera: - %DrawConstantNumber(0,6) - LDA $7EF435 : AND.b #$1C : LSR #2 - JMP DrawDungeonCompassCounts_return_spot - -CompassCount_Thieves: - %DrawConstantNumber(0,8) - LDA $7EF437 : AND.b #$0F - JMP DrawDungeonCompassCounts_return_spot - -CompassCount_Trock: - %DrawConstantNumber(1,2) - LDA $7EF439 : LSR #4 - JMP DrawDungeonCompassCounts_return_spot - -CompassCount_Gt: - %DrawConstantNumber(2,7) - LDA $7EF436 : LSR #3 - 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 -;-------------------------------------------------------------------------------- \ No newline at end of file +InitCompassTotalsRAM: + LDX #$00 + - + LDA CompassTotalsROM, X : STA CompassTotalsWRAM, X + INX + CPX #$0F : !BLT - +RTL + diff --git a/contrib.asm b/contrib.asm index 0fbf354..52adbcd 100644 --- a/contrib.asm +++ b/contrib.asm @@ -71,14 +71,13 @@ ; ; PLX ; -; LDA.b #$00 : STA $7EF3CC +; LDA.b #$00 : STA FollowerIndicator ; ; STZ $5E ; ; 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/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..67954aa 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 @@ -393,7 +394,7 @@ AgahnimAsksAboutPed: LDA.l InvincibleGanon CMP.b #$06 : BNE .vanilla - LDA.l $7EF300 ; check ped flag + LDA.l OverworldEventDataWRAM+$80 ; check ped flag AND.b #$40 BNE .vanilla diff --git a/elder.asm b/elder.asm index 00fc5e7..87f25a1 100644 --- a/elder.asm +++ b/elder.asm @@ -40,25 +40,30 @@ RTL Elder_Code: { - LDA GoalItemRequirement : BEQ .despawn - LDA InvincibleGanon : CMP #$05 : BEQ .despawn - LDA TurnInGoalItems : BNE + + REP #$20 + LDA.l GoalItemRequirement : BEQ .despawn + LDA.l InvincibleGanon : AND.w #$00FF : CMP.w #$0005 : BEQ .despawn + LDA.l TurnInGoalItems : AND.w #$00FF : BNE + .despawn + SEP #$20 STZ $0DD0, X ; despawn self RTS + - + SEP #$20 LDA.b #$96 LDY.b #$01 JSL Sprite_ShowSolicitedMessageIfPlayerFacing_PreserveMessage : BCC .dont_show - LDA !GOAL_COUNTER - CMP GoalItemRequirement : !BLT + + REP #$20 + LDA.l GoalCounter + CMP.l GoalItemRequirement : !BLT + + SEP #$20 JSL.l ActivateGoal + .dont_show .done - LDA $1A : LSR #5 : AND.b #$01 : STA $0DC0, X + SEP #$20 + LDA.b $1A : LSR #5 : AND.b #$01 : STA.w $0DC0, X RTS - } \ No newline at end of file + } diff --git a/entrances.asm b/entrances.asm index 7f993dc..e3e6bb0 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 @@ -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 OverworldEventDataWRAM+$43 : AND.w #$0020 : BNE .unlock ; Check if GT overlay is already on or not LDA $0308 : AND.w #$0080 : BEQ ++ ;If we are holding an item .locked @@ -44,7 +44,7 @@ RTL FlagAgahnimDoor: LDA.l InvertedMode : BEQ .vanilla - LDA $7EF2C3 : ORA #$20 : STA $7EF2C3 ; activate GT overlay + LDA OverworldEventDataWRAM+$43 : ORA #$20 : STA OverworldEventDataWRAM+$43 ; activate GT overlay .vanilla LDA.b #$28 : STA.b $72 @@ -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 LDA.l StartingAreaExitOffset, X @@ -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 @@ -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 OverworldEventDataWRAM+$47 : ORA.b #$20 : STA.l OverworldEventDataWRAM+$47 .done RTL ;-------------------------------------------------------------------------------- diff --git a/events.asm b/events.asm index d8ff634..1a729eb 100644 --- a/events.asm +++ b/events.asm @@ -2,7 +2,7 @@ ; OnLoadOW ;-------------------------------------------------------------------------------- ;OnLoadMap: -; LDA $7EF2DB ; thing we wrote over +; LDA OverworldEventDataWRAM+$5B ; thing we wrote over ;RTL ;-------------------------------------------------------------------------------- OnPrepFileSelect: @@ -21,9 +21,10 @@ OnDrawHud: JSL.l PollService JML.l ReturnFromOnDrawHud ;-------------------------------------------------------------------------------- -;OnDungeonEntrance: -; STA $7EC172 ; thing we wrote over -;RTL +OnDungeonEntrance: + STA $7EC172 ; thing we wrote over + JSL MaybeFlagCompassTotalEntrance +RTL ;-------------------------------------------------------------------------------- OnPlayerDead: PHA @@ -63,30 +64,60 @@ OnUncleItemGet: BIT.b #$01 : BEQ + : STA !INFINITE_ARROWS : + PLA - JSL Link_ReceiveItem + JSL.l Link_ReceiveItem - LDA.l UncleRefill : BIT.b #$04 : BEQ + : LDA.b #$80 : STA $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.l MagicFiller : + ; refill magic + LDA.l UncleRefill : BIT.b #$02 : BEQ + : LDA.b #50 : STA.l BombsFiller : + ; refill bombs LDA.l UncleRefill : BIT.b #$01 : BEQ + ; refill arrows - LDA.b #70 : STA $7EF376 + LDA.b #70 : STA.l ArrowsFiller LDA.l ArrowMode : BEQ + - LDA !INVENTORY_SWAP_2 : ORA #$80 : STA !INVENTORY_SWAP_2 ; enable bow toggle + LDA.l BowTracking : ORA.b #$80 : STA.l 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.l CurrentRupees : !ADD.l FreeUncleItemAmount : STA.l CurrentRupees ; rupee arrows, so also give the player some money to start SEP #$20 ; set 8-bit accumulator + + LDA.l ProgressIndicator : BNE + + LDA.b #$01 : STA.l ProgressIndicator ; handle rain state + + RTL ;-------------------------------------------------------------------------------- OnAga2Defeated: - JSL.l Dungeon_SaveRoomData_justKeys ; thing we wrote over, make sure this is first - JML.l IncrementAgahnim2Sword + JSL.l Dungeon_SaveRoomData_justKeys ; thing we wrote over, make sure this is first + LDA.b #$01 : STA.l Aga2Duck + JML.l IncrementAgahnim2Sword ;-------------------------------------------------------------------------------- OnFileCreation: - TAX ; what we wrote over - LDA StartingEquipment+$4C : STA $700340+$4C ; copy starting equipment swaps to file select screen - LDA StartingEquipment+$4E : STA $700340+$4E -RTL + ; Copy initial SRAM state from ROM to cart SRAM + PHB + LDA.w #$03D7 ; \ + LDX.w #$B000 ; | Copies from beginning of inital sram table up to file name + LDY.w #$0000 ; | (exclusively) + MVN $70, $30 ; / + ; Skip file name and validity value + LDA.w #$010C ; \ + LDX.w #$B3E3 ; | Rando-Specific Assignments & Game Stats block + LDY.w #$03E3 ; | + MVN $70, $30 ; / + PLB + + ; resolve instant post-aga if standard + SEP #$20 + LDA.l InitProgressIndicator : BIT #$80 : BEQ + + LDA.b #$00 : STA.l ProgressIndicatorSRAM ; set post-aga after zelda rescue + LDA.b #$00 : STA.l OverworldEventDataSRAM+$02 ; keep rain state vanilla + + + REP #$20 + + ; Set validity value and do some cleanup. Jump to checksum. + LDA.w #$55AA : STA.l $7003E1 + STZ $00 + STZ $01 + LDX.b $00 + LDY.w #$0000 + TYA + +JML.l InitializeSaveFile_build_checksum ;-------------------------------------------------------------------------------- !RNG_ITEM_LOCK_IN = "$7F5090" OnFileLoad: @@ -95,20 +126,19 @@ OnFileLoad: LDA.b #$07 : STA $210C ; Restore screen 3 to normal tile area - LDA !FRESH_FILE_MARKER : BNE + + LDA.l FileMarker : BNE + JSL.l OnNewFile - LDA.b #$FF : STA !FRESH_FILE_MARKER + LDA.b #$FF : STA.l FileMarker + LDA.w $010A : BNE + ; don't adjust the worlds for "continue" or "save-continue" LDA.l $7EC011 : BNE + ; don't adjust worlds if mosiac is enabled (Read: mirroring in dungeon) JSL.l DoWorldFix + JSL.l MasterSwordFollowerClear - JSL.l InitOpenMode - LDA #$FF : STA !RNG_ITEM_LOCK_IN ; reset rng item lock-in - LDA #$00 : STA $7F5001 ; mark fake flipper softlock as impossible + LDA.b #$FF : STA !RNG_ITEM_LOCK_IN ; reset rng item lock-in + LDA.b #$00 : STA $7F5001 ; mark fake flipper softlock as impossible LDA.l GenericKeys : BEQ + - LDA $7EF38B : STA $7EF36F ; copy generic keys to key counter + LDA.l CurrentGenericKeys : STA.l CurrentSmallKeys ; copy generic keys to key counter + JSL.l SetSilverBowMode @@ -124,39 +154,8 @@ RTL !RNG_ITEM_LOCK_IN = "$7F5090" OnNewFile: PHX : PHP - REP #$20 ; set 16-bit accumulator - LDA.l LinkStartingRupees : STA $7EF362 : STA $7EF360 - 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 - DEX : DEX - BPL - - - LDX #$000E : - - LDA $7EF37C, X : STA $7EF4E0, 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.l PreopenPyramid : BEQ + - LDA.b #$20 : STA $7EF2DB ; pyramid hole already open - + - - LDA.l PreopenGanonsTower : BEQ + - LDA.b #$20 : STA $7EF2C3 ; Ganons Tower already open - + - - LDA StartingSword : STA $7EF359 ; set starting sword type - ; reset some values on new file that are otherwise only reset on hard reset + SEP #$20 ; set 8-bit accumulator STZ $03C4 ; ancilla slot index STZ $047A ; EG STZ $0B08 : STZ $0B09 ; arc variable @@ -235,8 +234,8 @@ PreItemGet: RTL ;-------------------------------------------------------------------------------- PostItemGet: - JML.l MaybeWriteSRAMTrace +RTL ;-------------------------------------------------------------------------------- PostItemAnimation: LDA.b #$00 : STA !ITEM_BUSY ; mark item as finished diff --git a/fairyfixes.asm b/fairyfixes.asm index 5364376..2305cd7 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 MaximumHealth : 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/fileselect.asm b/fileselect.asm index a494226..4494ffc 100644 --- a/fileselect.asm +++ b/fileselect.asm @@ -1,10 +1,6 @@ -!ExtendedPlayerName = "$700500" !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" @@ -136,36 +132,36 @@ 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 ; Bow - LDA.l !FS_INVENTORY_SWAP_2 : AND.w #$0040 : BEQ + - LDA $700340 : AND.w #$00FF : BEQ ++ + LDA.l BowTrackingSRAM : AND.w #$0040 : BEQ + + LDA EquipmentSRAM+$00 : 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 EquipmentSRAM : AND.w #$00FF : BEQ + %fs_drawItem(3,12,FileSelectItems_bow) BRA .bow_end + @@ -173,15 +169,15 @@ DrawPlayerFileShared: .bow_end ; Boomerang - LDA.l !FS_INVENTORY_SWAP : AND.w #$00C0 : CMP.w #$00C0 : BNE + + LDA.l InventoryTrackingSRAM : 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 InventoryTrackingSRAM : 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 InventoryTrackingSRAM : AND.w #$0080 : BEQ + %fs_drawItem(3,14,FileSelectItems_blue_boomerang) BRA .boomerang_end + @@ -189,13 +185,13 @@ DrawPlayerFileShared: .boomerang_end ; Hookshot - %fs_drawItemBasic($700342,3,16,FileSelectItems_hookshot) + %fs_drawItemBasic(EquipmentSRAM+$02,3,16,FileSelectItems_hookshot) ; Bombs - ; %fs_drawItemBasic($700343,3,18,FileSelectItems_bombs) + ; %fs_drawItemBasic(EquipmentSRAM+$03,3,18,FileSelectItems_bombs) ; Powder - LDA.l !FS_INVENTORY_SWAP : AND.w #$0010 : BEQ + + LDA.l InventoryTrackingSRAM : AND.w #$0010 : BEQ + %fs_drawItem(3,20,FileSelectItems_powder) BRA ++ + @@ -203,7 +199,7 @@ DrawPlayerFileShared: ++ ; Mushroom - LDA.l !FS_INVENTORY_SWAP : AND.w #$0008 : BEQ + + LDA.l InventoryTrackingSRAM : AND.w #$0008 : BEQ + %fs_drawItem(3,18,FileSelectItems_mushroom) BRA ++ + @@ -211,7 +207,7 @@ DrawPlayerFileShared: ++ ; Flute - LDA.l !FS_INVENTORY_SWAP : AND.w #$0003 : BEQ + + LDA.l InventoryTrackingSRAM : AND.w #$0003 : BEQ + %fs_drawItem(7,16,FileSelectItems_flute) BRA ++ + @@ -219,7 +215,7 @@ DrawPlayerFileShared: ++ ; Shovel - LDA.l !FS_INVENTORY_SWAP : AND.w #$0004 : BEQ + + LDA.l InventoryTrackingSRAM : AND.w #$0004 : BEQ + %fs_drawItem(9,12,FileSelectItems_shovel) BRA ++ + @@ -227,52 +223,52 @@ DrawPlayerFileShared: ++ ; Fire Rod - %fs_drawItemBasic($700345,5,12,FileSelectItems_fire_rod) + %fs_drawItemBasic(EquipmentSRAM+$05,5,12,FileSelectItems_fire_rod) ; Ice Rod - %fs_drawItemBasic($700346,5,14,FileSelectItems_ice_rod) + %fs_drawItemBasic(EquipmentSRAM+$06,5,14,FileSelectItems_ice_rod) ; Bombos Medallion - %fs_drawItemBasic($700347,5,16,FileSelectItems_bombos) + %fs_drawItemBasic(EquipmentSRAM+$07,5,16,FileSelectItems_bombos) ; Ether Medallion - %fs_drawItemBasic($700348,5,18,FileSelectItems_ether) + %fs_drawItemBasic(EquipmentSRAM+$08,5,18,FileSelectItems_ether) ; Quake Medallion - %fs_drawItemBasic($700349,5,20,FileSelectItems_quake) + %fs_drawItemBasic(EquipmentSRAM+$09,5,20,FileSelectItems_quake) ; Lamp - %fs_drawItemBasic($70034A,7,12,FileSelectItems_lamp) + %fs_drawItemBasic(EquipmentSRAM+$0A,7,12,FileSelectItems_lamp) ; Hammer - %fs_drawItemBasic($70034B,7,14,FileSelectItems_hammer) + %fs_drawItemBasic(EquipmentSRAM+$0B,7,14,FileSelectItems_hammer) ; Bug Net - %fs_drawItemBasic($70034D,7,18,FileSelectItems_bugnet) + %fs_drawItemBasic(EquipmentSRAM+$0D,7,18,FileSelectItems_bugnet) ; Book of Mudora - %fs_drawItemBasic($70034E,7,20,FileSelectItems_book) + %fs_drawItemBasic(EquipmentSRAM+$0E,7,20,FileSelectItems_book) ; Red Cane - %fs_drawItemBasic($700350,9,14,FileSelectItems_redcane) + %fs_drawItemBasic(EquipmentSRAM+$10,9,14,FileSelectItems_redcane) ; Blue Cane - %fs_drawItemBasic($700351,9,16,FileSelectItems_bluecane) + %fs_drawItemBasic(EquipmentSRAM+$11,9,16,FileSelectItems_bluecane) ; Cape - %fs_drawItemBasic($700352,9,18,FileSelectItems_cape) + %fs_drawItemBasic(EquipmentSRAM+$12,9,18,FileSelectItems_cape) ; Mirror - %fs_drawItemBasic($700353,9,20,FileSelectItems_mirror) + %fs_drawItemBasic(EquipmentSRAM+$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(EquipmentSRAM+$1C,3,23) + %fs_drawBottle(EquipmentSRAM+$1D,5,23) + %fs_drawBottle(EquipmentSRAM+$1E,7,23) + %fs_drawBottle(EquipmentSRAM+$1F,9,23) ; Sword - LDA.l $700359 : AND.w #$00FF : BNE + + LDA.l EquipmentSRAM+$19 : AND.w #$00FF : BNE + %fs_drawItemGray(3,26,FileSelectItems_fighters_sword) BRA ++ + : DEC : BNE + @@ -293,7 +289,7 @@ DrawPlayerFileShared: ++ ; Shield - LDA.l $70035A : AND.w #$00FF : BNE + + LDA.l EquipmentSRAM+$1A : AND.w #$00FF : BNE + %fs_drawItemGray(5,26,FileSelectItems_fighters_shield) BRA ++ + : DEC : BNE + @@ -307,7 +303,7 @@ DrawPlayerFileShared: ++ ; Mail - LDA.l $70035B : AND.w #$00FF : BNE + + LDA.l EquipmentSRAM+$1B : AND.w #$00FF : BNE + %fs_drawItem(7,26,FileSelectItems_green_mail) BRA ++ + : DEC : BNE + @@ -318,7 +314,7 @@ DrawPlayerFileShared: ++ ; Heart Pieces - LDA.l $70036B : AND.w #$00FF : BNE + + LDA.l EquipmentSRAM+$2B : AND.w #$00FF : BNE + %fs_drawItem(9,26,FileSelectItems_heart_piece_0_of_4) BRA ++ + : DEC : BNE + @@ -331,16 +327,16 @@ DrawPlayerFileShared: %fs_drawItem(9,26,FileSelectItems_heart_piece_3_of_4) ++ - LDA $700448 : AND.w #$00FF + LDA EquipmentSRAM+$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(EquipmentSRAM+$15,3,28,FileSelectItems_boots) ; Gloves - LDA.l $700354 : AND.w #$00FF : BNE + + LDA.l EquipmentSRAM+$14 : AND.w #$00FF : BNE + %fs_drawItemGray(5,28,FileSelectItems_gloves) BRA ++ + : DEC : BNE + @@ -351,27 +347,27 @@ DrawPlayerFileShared: ++ ; Flippers - %fs_drawItemBasic($700356,7,28,FileSelectItems_flippers) + %fs_drawItemBasic(EquipmentSRAM+$16,7,28,FileSelectItems_flippers) ; Moon Pearl - %fs_drawItemBasic($700357,9,28,FileSelectItems_pearl) + %fs_drawItemBasic(EquipmentSRAM+$17,9,28,FileSelectItems_pearl) ; Pendants - LDA $700374 : AND.w #$0004 : BEQ + + LDA EquipmentSRAM+$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 EquipmentSRAM+$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 EquipmentSRAM+$34 : AND.w #$0001 : BEQ + %fs_drawItem(12,16,FileSelectItems_red_pendant) BRA ++ + @@ -379,49 +375,49 @@ DrawPlayerFileShared: ++ ; Crystals - LDA $70037A : AND.w #$0002 : BEQ + + LDA EquipmentSRAM+$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 EquipmentSRAM+$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 EquipmentSRAM+$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 EquipmentSRAM+$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 EquipmentSRAM+$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 EquipmentSRAM+$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 EquipmentSRAM+$3A : AND.w #$0008 : BEQ + LDA.w #$0297|!FS_COLOR_BLUE BRA ++ + @@ -563,7 +559,7 @@ FileSelectItems: ;-------------------------------------------------------------------------------- FileSelectDrawHudBar: LDA #$029B|!FS_COLOR_GREEN : %fs_draw16x8(0,10) - LDA $700362 + LDA EquipmentSRAM+$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) @@ -571,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 EquipmentSRAM+$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 BowTrackingSRAM : 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 EquipmentSRAM+$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) @@ -791,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 EquipmentSRAM+$99 : ORA.w #!FS_COLOR_BW %fs_draw8x16(3,5) - LDA $7003DB : ORA.w #!FS_COLOR_BW + LDA EquipmentSRAM+$9B : ORA.w #!FS_COLOR_BW %fs_draw8x16(3,6) - LDA $7003DD : ORA.w #!FS_COLOR_BW + LDA EquipmentSRAM+$9D : ORA.w #!FS_COLOR_BW %fs_draw8x16(3,7) - LDA $7003DF : ORA.w #!FS_COLOR_BW + LDA EquipmentSRAM+$9F : ORA.w #!FS_COLOR_BW %fs_draw8x16(3,8) - LDA $70036C : AND.w #$00FF : LSR #3 : STA $02 + LDA EquipmentSRAM+$2C : AND.w #$00FF : LSR #3 : STA $02 %fs_LDY_screenpos(0,20) LDA.w #$028F|!FS_COLOR_RED LDX.w #$000A @@ -870,3 +866,21 @@ JML FSSelectFile_continue LDA.b #$3C : STA $012E ; play error sound JML FSSelectFile_return ;-------------------------------------------------------------------------------- +MaybeForceFileName: + LDA.l ForceFileName : BEQ + + REP #$20 + LDX.b #$FE + - + INX : INX + LDA.l StaticFileName, X : STA.l ExtendedFileNameSRAM, X + CPX #$16 : BEQ .done + CPX #$08 : BCS - + STA.l FileNameVanillaSRAM, X + BRA - + .done + SEP #$20 + JML.l InitializeSaveFile + + + +JML.l NameFile_MakeScreenVisible +;-------------------------------------------------------------------------------- diff --git a/flipperkill.asm b/flipperkill.asm index 418a6e7..b7a9c53 100644 --- a/flipperkill.asm +++ b/flipperkill.asm @@ -4,23 +4,23 @@ 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 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 PLP - LDA $7EF36D ; thing we wrote over + LDA CurrentHealth ; thing we wrote over 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 @@ -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 diff --git a/floodgatesoftlock.asm b/floodgatesoftlock.asm index 043e422..e593344 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 OverworldEventDataWRAM+$3B : AND.b #$DF : STA OverworldEventDataWRAM+$3B ; reset water outside floodgate + LDA OverworldEventDataWRAM+$7B : AND.b #$DF : STA OverworldEventDataWRAM+$7B ; reset water outside swamp palace + LDA RoomDataWRAM[$010B].low : AND.b #$7F : STA RoomDataWRAM[$010B].low ; clear water inside floodgate + LDA RoomDataWRAM[$28].high : AND.b #$FE : STA RoomDataWRAM[$28].high ; clear water front room (room 40) + FloodGateResetInner: LDA.l Bugfix_SwampWaterLevel : BEQ +++ - LDA $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 RoomDataWRAM[$37].low : AND.b #$04 : BEQ + ; Check if key in room 55 has been collected. + LDA FlippersEquipment : AND.b #$01 : BNE ++ ; Check for flippers. This can otherwise softlock doors if flooded without flippers and no way to reset. + - LDA $7EF06E : AND.b #$7F : STA $7EF06E ; clear water room 55 - outer room you shouldn't be able to softlock except in major glitches + LDA RoomDataWRAM[$37].low : AND.b #$7F : STA RoomDataWRAM[$37].low ; clear water room 55 - outer room you shouldn't be able to softlock except in major glitches ++ - LDA $7EF06B : AND.b #$04 : BNE +++ ; Check if key in room 53 has been collected. + LDA RoomDataWRAM[$35].high : AND.b #$04 : BNE +++ ; Check if key in room 53 has been collected. ; no need to check for flippers on the inner room, as you can't get to the west door no matter what, without flippers. - LDA $7EF06A : AND.b #$7F : STA $7EF06A ; clear water room 53 - inner room with the easy key flood softlock + LDA RoomDataWRAM[$35].low : AND.b #$7F : STA RoomDataWRAM[$35].low ; clear water room 53 - inner room with the easy key flood softlock +++ RTL ;================================================================================ diff --git a/flute.asm b/flute.asm index 4de7eb1..fe88520 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 OverworldEventDataWRAM, X : AND.b #$40 : BNE + LDA.b #$1B : JSL Sound_SetSfx3PanLong + RTL @@ -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/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/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 8cd7502..9d112f8 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 @@ -62,18 +61,18 @@ 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 $7EF2DB : AND.b #$20 : BEQ .fail ; require aga2 defeated (pyramid hole open) + 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 OverworldEventDataWRAM+$5B : AND.b #$20 : BEQ .fail ; require aga2 defeated (pyramid hole open) BRA .success ; 03 = crystals and aga 2 .crystals_and_aga - LDA.l $7EF2DB : AND.b #$20 : BEQ .fail ; check aga2 first then bleed in + LDA.l OverworldEventDataWRAM+$5B : AND.b #$20 : BEQ .fail ; check aga2 first then bleed in ; 04 = crystals only .crystals @@ -82,7 +81,9 @@ CheckGanonVulnerability: ; 05 = require goal item .goal_item - LDA.l !GOAL_COUNTER : CMP GoalItemRequirement + REP #$20 + LDA.l GoalCounter : CMP.l GoalItemRequirement + SEP #$20 RTS ; 06 = light speed @@ -96,7 +97,6 @@ CheckGanonVulnerability: ; 08 = Crystal bosses but no crystals .bosses_only - ;LDA.l $7EF2DDB : AND.b #$20 : BEQ .fail ; check aga2 JMP CheckForCrystalBossesDefeated ;-------------------------------------------------------------------------------- @@ -125,12 +125,12 @@ GetRequiredCrystalsInX: RTL ;-------------------------------------------------------------------------------- CheckEnoughCrystalsForGanon: - LDA $7EF37A : JSL CountBits ; the comparison is against 1 less + LDA CrystalCounter CMP.l NumberOfCrystalsRequiredForGanon RTL ;-------------------------------------------------------------------------------- CheckEnoughCrystalsForTower: - LDA $7EF37A : JSL CountBits ; the comparison is against 1 less + LDA CrystalCounter CMP.l NumberOfCrystalsRequiredForTower RTL @@ -140,7 +140,7 @@ CheckAgaForPed: CMP.b #$06 : BNE .vanilla .light_speed - LDA.l $7EF300 ; check ped flag + LDA.l OverworldEventDataWRAM+$80 ; check ped flag AND.b #$40 BEQ .force_blue_ball @@ -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.l OverworldEventDataWRAM+$5B : ORA.b #$20 : STA.l OverworldEventDataWRAM+$5B ; pyramid hole + LDA.b #$08 : STA.l RoomDataWRAM[$00].high ; kill ganon + LDA.b #$02 : STA.l MoonPearlEquipment ; pearl but invisible in menu .exit RTL @@ -197,7 +197,7 @@ CheckForCrystalBossesDefeated: LDA.l DrawHUDDungeonItems_boss_room_ids-4,X TAX - LDA.l $7EF000,X + LDA.l RoomDataWRAM.l,X AND.w #$0800 BEQ ++ 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..08aaea2 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 @@ -130,7 +130,7 @@ HeartUpgradeSpawnDecision: ; this should return #$00 to make the hp spawn RTL .normal_behavior - LDA $7EF280, X + LDA OverworldEventDataWRAM, X RTL ;-------------------------------------------------------------------------------- SaveHeartCollectedStatus: @@ -140,7 +140,7 @@ SaveHeartCollectedStatus: RTL .normal_behavior - LDA $7EF280, X : ORA.b #$40 : STA $7EF280, X + LDA OverworldEventDataWRAM, X : ORA.b #$40 : STA OverworldEventDataWRAM, 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/hooks.asm b/hooks.asm index a3ade27..21c9b24 100755 --- a/hooks.asm +++ b/hooks.asm @@ -63,8 +63,8 @@ org $00FFF4 : dw SoftwareInterrupt ;================================================================================ ; Dungeon Entrance Hook (works, but not needed at the moment) ;-------------------------------------------------------------------------------- -;org $02D8C7 ; <- 158C7 - Bank02.asm : 10981 (STA $7EC172) -;JSL.l OnDungeonEntrance +org $02D8C7 ; <- 158C7 - Bank02.asm : 10981 (STA $7EC172) +JSL.l OnDungeonEntrance ;-------------------------------------------------------------------------------- ;================================================================================ @@ -236,6 +236,8 @@ LDA.l HeartCursorPositions, X org $0CDAEB ; <- 65AEB : Bank0C.asm : 3571-3575,3581-3587 (...) [LDA $0B12 : AND #$03] ; JP here is different. Indicated line number implement the US version of the same functionality JSL.l WrapCharacterPosition : NOP +org $0CD75E ; bank_0C.asm (dl NameFile_MakeScreenVisible) +dl MaybeForceFileName ;-------------------------------------------------------------------------------- org $0CE43A ; No assembly source. Makes name entry box wider db $2C @@ -330,9 +332,8 @@ org $0CCE85 ; <- Bank0C.asm : 1953 (LDA $C8 : ASL A : INC #2 : STA $701FFE) NOP #4 ;-------------------------------------------------------------------------------- org $0CDB4C ; <- Bank0C.asm : 3655 (LDA $C8 : ASL A : INC #2 : STA $701FFE : TAX) -JSL OnFileCreation +JML OnFileCreation NOP -;Additionally, display inventory swap starting equipment on file select ;-------------------------------------------------------------------------------- org $09F5EA ; <- module_death.asm : 510 (LDA $701FFE : TAX : DEX #2) LDA.w #$0002 : NOP @@ -556,17 +557,13 @@ JSL.l CheckGanonHammerDamage : NOP org $02B797 ; <- 13797 - Bank02.asm : 8712 (LDA.b #$19 : STA $10) JSL.l StatsFinalPrep ;-------------------------------------------------------------------------------- -org $07A95B ; <- 3A95B - Bank07.asm : 6565 (JSL Dungeon_SaveRoomData) +org $07A95B ; <- 3A95B - Bank07.asm : 6565 (JSL Dungeon_SaveRoomDataWRAM) JSL.l IncrementUWMirror ;-------------------------------------------------------------------------------- org $0288D1 ; <- 108D1 - Bank02.asm : 1690 (STZ $0646) 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 ;-------------------------------------------------------------------------------- @@ -734,7 +731,7 @@ JSL.l GetItemDamageValue ;================================================================================ ; Misc Stats ;-------------------------------------------------------------------------------- -org $029E2E ; <- 11E2E - module_ganon_emerges.asm : 59 (JSL Dungeon_SaveRoomData.justKeys) +org $029E2E ; <- 11E2E - module_ganon_emerges.asm : 59 (JSL Dungeon_SaveRoomDataWRAM.justKeys) JSL.l OnAga2Defeated ;-------------------------------------------------------------------------------- org $0DDBDE ; <- 6DBDE - headsup_display.asm : 105 (DEC A : BPL .subtractRupees) @@ -1700,7 +1697,7 @@ JSL.l FixAga2Bunny : NOP ; Open Mode Fixes ;-------------------------------------------------------------------------------- org $05DF65 ; <- 2DF65 - sprite_uncle_and_priest.asm:994 - (LDA.b #$01 : STA $7EF3C5) -JSL.l SetUncleRainState : RTS +NOP #6 ;-------------------------------------------------------------------------------- ;org $0280DD ; <- 100DD - Bank02.asm:298 - (LDA $7EF3C5 : CMP.b #$02 : BCC .indoors) ;JSL.l ForceLinksHouse @@ -2123,7 +2120,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 @@ -2420,15 +2417,13 @@ Overworld_Hole_End: ;-------------------------------------------------------------------------------- ;================================================================================ -; Disable pyramid hole check for killing aga2 +; Replace pyramid hole check for killing aga2 ; ; this check is intended to prevent getting fluted out a second time if you -; return to his room after already killing him once. But with a pre-opened -; pyramid hole, it can cause you to get stuck there on killing him the first -; time. So we change it, and accept the flute out if you return. +; return to his room after already killing him once. ;--------------------------------------------------------------------------------- -org $01C753 ; 0C753 = Bank01:10398 (LDA $7EF2DB : AND.b #$20 : BNE .return) -db $00 ; (originally $20) +org $01C74E ; 00C74E - bank_01.asm:13281 - (LDA.l $7EF2DB : AND.b #$20) +LDA.l Aga2Duck : NOP #2 ;================================================================================ ; Music fixes @@ -2494,7 +2489,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: ;================================================================================ @@ -2505,7 +2500,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/init.asm b/init.asm index 8fc9a65..36bb4b5 100644 --- a/init.asm +++ b/init.asm @@ -1,5 +1,3 @@ -RomVersionSRAM = $701FFC - ;-------------------------------------------------------------------------------- ; Init_Primary ;-------------------------------------------------------------------------------- @@ -24,7 +22,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 +36,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 @@ -69,5 +67,6 @@ Init_PostRAMClear: JSL MSUInit JSL InitRNGPointerTable + JSL InitCompassTotalsRAM JML $00D463 ; The original target of the jump table that we hijacked diff --git a/initsramtable.asm b/initsramtable.asm new file mode 100644 index 0000000..a93d0c1 --- /dev/null +++ b/initsramtable.asm @@ -0,0 +1,174 @@ +;================================================================================ +; Initial SRAM table. +;-------------------------------------------------------------------------------- +; The ROM copies blocks of bytes from here on save file init. This table has an +; identical layout to the first $500 bytes of SRAM, although some values such as +; the file validity value, file name, and inverse checksum are skipped. +; +; NOTE: Set InitProgressIndicator to $80 for standard mode with instant post-aga +; world state +; +; See sram.asm for further documentation on how to write to this table. +;-------------------------------------------------------------------------------- + +fillword $0000 ; Zero out the table +fill $500 ; + +org $30B000 ; PC 0x183000 +InitRoomDataWRAM: +org $30B060 ; PC 0x183060 +InitATAltarRoom: dw $0000 ; aga curtains +org $30B092 ; PC 0x183092 +InitSWBackEntryRoom: dw $0000 ; skull woods curtains (?) + +org $30B20C +dw $F000, $F000 ; Pre-open kak bomb hut & brewery + +org $30B280 ; PC 0x183280 - 0x1832FF +InitOverworldEvents: +org $30B282 ; PC 0x183282 - Lumberjacks +InitLumberjackOW: db $00 +org $30B29B ; PC 0x18329B - Open castle gate +InitHyruleCastleOW: db $20 +org $30B2DB ; PC 0x1832DB - Pyramid hole +InitPyramidOW: db $00 +org $30B2C3 ; PC 0x1832C3 - GT +InitDDMWestOW: db $00 + + +org $30B340 ; PC 0x183340 +StartingEquipment: +StartingBow: skip 1 ; PC 0x183340 +StartingBoomerang: skip 1 ; PC 0x183341 +StartingHookshot: skip 1 ; PC 0x183342 +StartingBombs: skip 1 ; PC 0x183343 +StartingPowder: skip 1 ; PC 0x183344 +StartingFireRod: skip 1 ; PC 0x183345 +StartingIceRod: skip 1 ; PC 0x183346 +StartingBombos: skip 1 ; PC 0x183347 +StartingEther: skip 1 ; PC 0x183348 +StartingQuake: skip 1 ; PC 0x183349 +StartingLamp: skip 1 ; PC 0x18334A +StartingHammer: skip 1 ; PC 0x18334B +StartingFlute: skip 1 ; PC 0x18334C +StartingBugNet: skip 1 ; PC 0x18334D +StartingBookOfMudora: skip 1 ; PC 0x18334E +StartingBottleIndex: skip 1 ; PC 0x18334F +StartingSomaria: skip 1 ; PC 0x183350 +StartingByrna: skip 1 ; PC 0x183351 +StartingCape: skip 1 ; PC 0x183352 +StartingMirror: skip 1 ; PC 0x183353 +StartingGlove: skip 1 ; PC 0x183354 +StartingBoots: skip 1 ; PC 0x183355 +StartingFlippers: skip 1 ; PC 0x183356 +StartingMoonPearl: skip 1 ; PC 0x183357 +skip 1 ; PC 0x183358 +StartingSword: skip 1 ; PC 0x183359 +StartingShield: skip 1 ; PC 0x18335A +StartingArmor: skip 1 ; PC 0x18335B +StartingBottleContentsOne: skip 1 ; PC 0x18335C +StartingBottleContentsTwo: skip 1 ; PC 0x18335D +StartingBottleContentsThree: skip 1 ; PC 0x18335E +StartingBottleContentsFour: skip 1 ; PC 0x18335F +StartingCurrentRupees: skip 2 ; PC 0x183360 \ Write same value to both +StartingDisplayRupees: skip 2 ; PC 0x183362 / of these +StartingCompasses: skip 2 ; PC 0x183364 +StartingBigKeys: skip 2 ; PC 0x183366 +StartingMaps: skip 2 ; PC 0x183368 +skip 1 ; PC 0x18336A +StartingQuarterHearts: skip 1 ; PC 0x18336B +StartingHealth: db $18 ; PC 0x18336C +StartingMaximumHealth: db $18 ; PC 0x18336D +StartingMagic: skip 1 ; PC 0x18336E +StartingSmallKeys: db $FF ; PC 0x18336F +StartingBombCapacityUpgrade: skip 1 ; PC 0x183370 +StartingArrowCapacityUpgrade: skip 1 ; PC 0x183371 +InitHeartsFiller: skip 1 ; PC 0x183372 +InitMagicFiller: skip 1 ; PC 0x183373 +StartingPendants: skip 1 ; PC 0x183374 +InitBombsFiller: skip 1 ; PC 0x183375 +InitArrowsFiller: skip 1 ; PC 0x183376 +StartingArrows: skip 1 ; PC 0x183377 +skip 1 ; PC 0x183378 +InitAbilityFlags: db $68 ; PC 0x183379 +StartingCrystals: skip 1 ; PC 0x18337A +StartingMagicConsumption: skip 1 ; PC 0x18337B +StartingDungeonKeys: ; +StartingSewerKeys: skip 1 ; PC 0x18337C +StartingHyruleCastleKeys: skip 1 ; PC 0x18337D +StartingEasternKeys: skip 1 ; PC 0x18337E +StartingDesertKeys: skip 1 ; PC 0x18337F +StartingCastleTowerKeys: skip 1 ; PC 0x183380 +StartingSwampKeys: skip 1 ; PC 0x183381 +StartingPalaceOfDarknessKeys: skip 1 ; PC 0x183382 +StartingMireKeys: skip 1 ; PC 0x183383 +StartingSkullWoodsKeys: skip 1 ; PC 0x183384 +StartingIcePalaceKeys: skip 1 ; PC 0x183385 +StartingHeraKeys: skip 1 ; PC 0x183386 +StartingThievesTownKeys: skip 1 ; PC 0x183387 +StartingTurtleRockKeys: skip 1 ; PC 0x183388 +StartingGanonsTowerKeys: skip 1 ; PC 0x183389 +skip 1 ; PC 0x18338A +StartingGenericKeys: skip 1 ; PC 0x18338B +InitInventoryTracking: skip 2 ; PC 0x18338C \ Need to set bits here for silver arrows, +InitBowTracking: skip 2 ; PC 0x18338E / boomerangs, powder/mushroom, etc +InitItemLimitCounts: skip 16 ; PC 0x183390 +skip 37 ; +InitProgressIndicator: db $02 ; PC 0x1833C5 - Set to $80 for instant post-aga with standard +InitProgressFlags: db $14 ; PC 0x1833C6 - Set to $00 for standard +InitMapIcons: skip 1 ; PC 0x1833C7 +InitStartingEntrance: db $01 ; PC 0x1833C8 - Set to $00 for standard +InitNpcFlagsVanilla: skip 1 ; PC 0x1833C9 +InitCurrentWorld: skip 1 ; PC 0x1833CA +skip 1 ; PC 0x1833CB +InitFollowerIndicator: skip 1 ; PC 0x1833CC +InitFollowerXCoord: skip 2 ; PC 0x1833CD +InitFollowerYCoord: skip 2 ; PC 0x1833CF +InitDroppedFollowerIndoors: skip 1 ; PC 0x1833D1 +InitDroppedFollowerLayer: skip 1 ; PC 0x1833D2 +InitFollowerDropped: skip 1 ; PC 0x1833D3 + +org $30B3D9 ; PC 0x1833D9 - 0x1833F0 +StaticFileName: ; The validity value ($55AA) must be written manually on SRAM init at $7003E1 +dw $0181, $0162, $0168, $018C +dw $0166, $014E, $0162, $018C +dw $0165, $0162, $0167, $018C + +org $30B401 ; PC 0x183401 +InitDeathCounter: +dw $FFFF + +;-------------------------------------------------------------------------------- +; The following labels and their addresses are provided for convenience. You +; may want to write, for example, to InitHighestSword in addition to setting +; StartingSword. But any value can be written to the whole block from +; $30B000-$30B4FF (PC 0x183000-0x18034FF) and it will be initialized +; excluding ~28 bytes (File name, validity value, and checksum.) +;-------------------------------------------------------------------------------- + +org $30B414 ; PC 0x183414-0x183416 +InitMapOverlay: dw $0000 + +org $30B417 ; PC 0x183417 +InitHighestSword: db $00 + +org $30B414 ; PC 0x183418-0x183419 +InitGoalCounter: dw $0000 + +org $30B422 ; PC 0x183422 +InitHighestShield: db $00 + +org $30B428 ; PC 0x183428 +InitMapsCompasses: db $00 + +org $30B429 ; PC 0x183429 +InitPendantCounter: db $00 + +org $30B454 ; PC 0x183454-0x183457 +InitChallengeTimer: dw $0000, $0000 + +org $30B46E ; PC 0x18346E +InitHighestMail: db $00 + +org $30B471 ; PC 0x183471 +InitCrystalCounter: db $00 diff --git a/inventory.asm b/inventory.asm index 08944f7..0e8b298 100644 --- a/inventory.asm +++ b/inventory.asm @@ -1,19 +1,18 @@ ;================================================================================ ; 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 ------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 ;-------------------------------------------------------------------------------- -!INVENTORY_SWAP_2 = "$7EF38E" +; BowTracking ; Item Tracking Slot #2 ; bsp----- ; b = bow @@ -23,20 +22,20 @@ ; - ; - ; - -; 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 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 @@ -57,12 +53,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 +68,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 +87,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 +100,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 +108,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 +123,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 @@ -178,8 +174,6 @@ RTL ;-------------------------------------------------------------------------------- ; AddInventory: ;-------------------------------------------------------------------------------- -!LOCK_STATS = "$7EF443" - macro TopHalf(address) LDA
: !ADD #$10 : STA
endmacro @@ -193,62 +187,61 @@ 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 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 - 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 @@ -259,7 +252,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 @@ -293,111 +285,73 @@ 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 #$FF : BEQ .fullItemCounts - CMP.b #$00 : BNE + ; Sewers (Escape) - BRA ++ - + CMP.b #$02 : BNE + ; Hyrule Castle (Escape) - ++ - CPY.b #$32 : BNE ++ : JMP .itemCounts : ++ ; Ball & Chain Guard's Big Key - %TopHalf($7EF434) - 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 - JMP .fullItemCounts - + CMP.b #$06 : BNE + ; Desert Palace - LDA $7EF435 : !ADD #$20 : STA $7EF435 - 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 - JMP .fullItemCounts - + CMP.b #$0A : BNE + ; Swamp Palace - %BottomHalf($7EF439) - JMP .fullItemCounts - + CMP.b #$0C : BNE + ; Palace of Darkness - %BottomHalf($7EF434) - JMP .fullItemCounts - + CMP.b #$0E : BNE + ; Misery Mire - %BottomHalf($7EF438) - JMP .fullItemCounts - + CMP.b #$10 : BNE + ; Skull Woods - %TopHalf($7EF437) - JMP .fullItemCounts - + CMP.b #$12 : BNE + ; Ice Palace - %TopHalf($7EF438) - 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 - JMP .fullItemCounts - + CMP.b #$16 : BNE + ; Thieves' Town - %BottomHalf($7EF437) - JMP .fullItemCounts - + CMP.b #$18 : BNE + ; Turtle Rock - %TopHalf($7EF439) - JMP .fullItemCounts - + CMP.b #$1A : BNE + ; Ganon's Tower - LDA $7EF436 : !ADD #$08 : STA $7EF436 - LDA $7EF366 : AND #$04 : BNE ++ + CMP.l BallNChainDungeon : BNE + + CPY.b #$32 : BNE + + JMP .done + + + CMP.b #$04 : BCS + + LDA SewersLocations : INC : STA SewersLocations + LDA HCLocations : INC : STA HCLocations + BRA .fullItemCounts + + LSR : TAX : LDA DungeonLocationsChecked, X : INC : STA DungeonLocationsChecked, X + ++ CPX.b #$0D : BNE + + 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 + - 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 + REP #$20 + LDA TotalItemCounter : INC : STA TotalItemCounter ; Increment Item Total + SEP #$20 .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 @@ -432,18 +386,22 @@ AddInventory: JMP .done + CPY.b #$20 : BNE + ; Crystal JSR .incrementCrystal + JSR .setDungeonCompletion JMP .done + 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 + CPY.b #$25 : BNE + ; Compass + JSL MaybeFlagCompassTotalPickup JSR .incrementCompass JMP .done + CPY.b #$26 : BNE + ; Liar Heart (Container) @@ -455,7 +413,7 @@ AddInventory: + CPY.b #$28 : BNE + ; 3 Bombs 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 @@ -474,6 +432,7 @@ AddInventory: + CPY.b #$37 : !BLT + ; Items $37 - $39 - Pendants CPY.b #$3A : !BGE + JSR .incrementPendant + JSR .setDungeonCompletion JMP .done + CPY.b #$3A : !BLT + ; Items $3A - $3B - Bow & Silver Arrows CPY.b #$3C : !BGE + @@ -493,6 +452,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) @@ -503,7 +463,7 @@ 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 JMP .done @@ -512,22 +472,34 @@ AddInventory: JSR .incrementCapacity JMP .done + CPY.b #$50 : BNE + ; Master Sword (Safe) + 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 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 : INC : TAX JSR .incrementSword JMP .done + CPY.b #$5F : BNE + ; Progressive Shield + LDA ShieldEquipment : INC : TAX JSR .incrementShield JMP .done + CPY.b #$60 : BNE + ; Progressive Armor + LDA ArmorEquipment : INC : TAX JSR .incrementMail JMP .done + CPY.b #$61 : BNE + ; Progressive Lifting Glove @@ -543,6 +515,7 @@ AddInventory: JMP .done + CPY.b #$80 : !BLT + ; Items $80 - $8F - Free Compasses CPY.b #$90 : !BGE + + JSL MaybeFlagCompassTotalPickup JSR .incrementCompass JMP .done + CPY.b #$90 : !BLT + ; Items $90 - $9F - Free Big Keys @@ -560,120 +533,99 @@ 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 .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 @@ -681,36 +633,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 + 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 @@ -718,31 +664,59 @@ RTS RTL .incrementBossSword - LDA $7EF359 + 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 + +.setDungeonCompletion + LDA $040C + CMP #$FF : BEQ + + LSR : AND #$0F : CMP #$08 : !BGE ++ + JSR .valueShift + ORA DungeonsCompleted : STA DungeonsCompleted + BRA + + ++ + !SUB #$08 + JSR .valueShift + BIT.b #$C0 : BEQ +++ : LDA.b #$C0 : +++ ; Make Hyrule Castle / Sewers Count for Both + ORA DungeonsCompleted+1 : STA DungeonsCompleted+1 + + +RTS + +.valueShift + PHX + TAX : LDA.b #$01 + - + CPX #$00 : BEQ + + ASL + DEX + BRA - + + + PLX +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 +728,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 +745,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 +805,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 +833,10 @@ RTL ;-------------------------------------------------------------------------------- LoadKeys: LDA.l GenericKeys : BEQ + - LDA $7EF38B + LDA CurrentGenericKeys RTL + - LDA $7EF37C, X + LDA DungeonKeys, X RTL ;-------------------------------------------------------------------------------- @@ -872,10 +846,10 @@ RTL SaveKeys: PHA LDA.l GenericKeys : BEQ + - PLA : STA $7EF38B + PLA : STA CurrentGenericKeys RTL + - PLA : STA $7EF37C, X + PLA : STA DungeonKeys, X RTL ;-------------------------------------------------------------------------------- @@ -889,10 +863,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 +929,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 +1021,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 +1034,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 +1052,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/inverted.asm b/inverted.asm index b60085d..1aeb772 100644 --- a/inverted.asm +++ b/inverted.asm @@ -71,7 +71,7 @@ Overworld_CreatePyramidHoleModified: SEP #$30 - LDA $7EF2DB : ORA.b #$20 : STA $7EF2DB + LDA OverworldEventDataWRAM+$5B : ORA.b #$20 : STA OverworldEventDataWRAM+$5B LDA.b #$03 : STA $012F @@ -131,9 +131,9 @@ db $02, $02, $02, $02, $02, $02, $02, $00, $00, $01, $01, $01, $02, $00, $08, $0 Electric_Barrier: LDA InvertedMode : BEQ .done - LDA $7EF280, X : ORA #$40 : STA $7EF280, X ;set barrier dead + LDA OverworldEventDataWRAM, X : ORA #$40 : STA OverworldEventDataWRAM, X ;set barrier dead .done - LDA $7EF280, X ; what we wrote over + LDA OverworldEventDataWRAM, X ; what we wrote over RTL @@ -187,7 +187,7 @@ RTL TurtleRockPegSolved: LDA.l InvertedMode : AND.w #$00FF : BNE + - LDA.l $7ef287 ; What we wrote over (reading flags for this screen) + LDA.l OverworldEventDataWRAM+07 ; What we wrote over (reading flags for this screen) RTL + LDA.w #$0020 ; We always treat puzzle as pre solved (overlay flag set) for inverted mode. diff --git a/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/itemdowngrade.asm b/itemdowngrade.asm index 9d08af2..a1f19f6 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,24 @@ 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 + INC $00 + LDA HighestShield : STA [$00] + PLA +RTS +;================================================================================ diff --git a/lampmantlecone.asm b/lampmantlecone.asm index c2dd7fd..1262087 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 @@ -26,20 +26,17 @@ RTL ; Output: 0 locked, 1 open ;-------------------------------------------------------------------------------- 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 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..b02ae1b 100644 --- a/maidencrystals.asm +++ b/maidencrystals.asm @@ -14,14 +14,12 @@ 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 - JML.l $1ECF35 ; <- F4F35 - sprite_crystal_maiden.asm : 426 ;-------------------------------------------------------------------------------- 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/medallions.asm b/medallions.asm index 56ed04f..c70a57c 100644 --- a/medallions.asm +++ b/medallions.asm @@ -6,7 +6,7 @@ TryOpenMire: LDA $8A : CMP.b #$70 : BNE .untriggered ; Checks whether the Misery Mire dungeon is already revealed. - LDA $7EF2F0 : AND.b #$20 : BNE .untriggered + LDA OverworldEventDataWRAM+$70 : AND.b #$20 : BNE .untriggered ; You have to be in the trigger window. LDY.b #$02 : JSL.l Ancilla_CheckIfEntranceTriggered : BCC .untriggered @@ -25,7 +25,7 @@ TryOpenTRock: LDA $8A : CMP.b #$47 : BNE .untriggered ; Checks whether the Turtle Rock dungeon is already revealed. - LDA $7EF2C7 : AND.b #$20 : BNE .untriggered + LDA OverworldEventDataWRAM+$47 : AND.b #$20 : BNE .untriggered ; You have to be in the trigger window. LDY.b #$03 : JSL.l Ancilla_CheckIfEntranceTriggered : BCC .untriggered @@ -73,4 +73,4 @@ MedallionTrigger_Quake: + PLA RTL -;-------------------------------------------------------------------------------- \ No newline at end of file +;-------------------------------------------------------------------------------- diff --git a/msu.asm b/msu.asm index 49b5904..c4d1318 100644 --- a/msu.asm +++ b/msu.asm @@ -250,20 +250,20 @@ CheckMusicLoadRequest: BRA .check_fallback-3 .lightworld PHA - LDA $7EF300 : AND.b #$40 : BEQ + + LDA OverworldEventDataWRAM+$80 : AND.b #$40 : BEQ + PLA LDA.b #60 : BRA .check_fallback-3 + -- : 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 @@ -344,10 +344,10 @@ CheckMusicLoadRequest: + CMP.b #$70 : BNE + ; Misery Mire - LDA $7EF2F0 : AND.b #$20 : BEQ .rain + LDA OverworldEventDataWRAM+$70 : 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 @@ -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 f418dde..746711c 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) ;+ @@ -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 OverworldEventDataWRAM+$80 : AND.b #$40 : BEQ + LDX.b #$02 ; Default light world theme + @@ -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 @@ -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 OverworldEventDataWRAM+$80 : AND.b #$40 : BNE .endOfLightWorldChecks LDX.b #$05 ; lost woods theme BRA .endOfLightWorldChecks + @@ -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) ;+ @@ -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 OverworldEventDataWRAM+$80 : AND.b #$40 : BEQ + ; LDX.b #$02 ; Default light world theme ;+ @@ -208,21 +208,21 @@ 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 LDA $8A ; Misery Mire rain SFX CMP.b #$70 : BNE ++ - LDA $7EF2F0 : AND.b #$20 : BNE ++ + LDA OverworldEventDataWRAM+$70 : AND.b #$20 : BNE ++ LDA.b #$01 : CMP $0131 : BEQ + STA $012D + : BRA .checkInverted @@ -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..6b78fa8 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 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 @@ -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 @@ -58,36 +58,30 @@ 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 GoalItemIcon : STA !GOAL_DRAW_ADDRESS ; draw star icon + LDA.l GoalItemRequirement : BNE + : JMP .done : + ; Star Meter + + LDA.l GoalCounter + JSR HudHexToDec4Digit + + LDA.l GoalItemIcon : STA.l !GOAL_DRAW_ADDRESS ; draw star icon LDX.b $05 : TXA : ORA.w #$2400 : STA !GOAL_DRAW_ADDRESS+2 ; draw 100's digit LDX.b $06 : TXA : ORA.w #$2400 : STA !GOAL_DRAW_ADDRESS+4 ; draw 10's digit LDX.b $07 : TXA : ORA.w #$2400 : STA !GOAL_DRAW_ADDRESS+6 ; draw 1's digit - SEP #$20 - LDA.l GoalItemRequirement : CMP.b #$FF : BEQ .skip - + LDA.l GoalItemRequirement : CMP.w #$FFFF : BEQ .skip LDA.l GoalItemRequirement - JSR HudHexToDec3Digit - REP #$20 + JSR HudHexToDec4Digit LDA.w #$2830 : STA !GOAL_DRAW_ADDRESS+8 ; draw slash LDX.b $05 : TXA : ORA.w #$2400 : STA !GOAL_DRAW_ADDRESS+10 ; draw 100's digit LDX.b $06 : TXA : ORA.w #$2400 : STA !GOAL_DRAW_ADDRESS+12 ; draw 10's digit LDX.b $07 : TXA : ORA.w #$2400 : STA !GOAL_DRAW_ADDRESS+14 ; draw 1's digit BRA .done .skip - REP #$20 LDA.w #$207F ; transparent tile STA !GOAL_DRAW_ADDRESS+8 STA !GOAL_DRAW_ADDRESS+10 @@ -97,19 +91,17 @@ SEP #$30 ;================================================================================ ; Draw Dungeon Compass Counts ;================================================================================ - REP #$20 LDA.l CompassMode : AND #$00FF : BEQ + ; skip if CompassMode is 0. JSL.l DrawDungeonCompassCounts ; compasses.asm + ;================================================================================ ; 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 +148,7 @@ SEP #$30 REP #$20 BEQ .drawprize - LDA.l $7EF368 + LDA.l MapField AND.l DungeonItemMasks,X BEQ .noprize @@ -184,13 +176,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 @@ -265,27 +257,27 @@ RTS ; in: A(b) - Byte to Convert ; out: $05 - $07 (high - low) ;================================================================================ -HudHexToDec3Digit: ; this may be overkill, could have used the 4 digit one... - LDY.b #$90 - - - CMP.b #100 : !BLT + - INY - SBC.b #100 : BRA - - + - STY $05 : LDY.b #$90 ; Store 100s digit and reset Y - - - CMP.b #10 : !BLT + - INY - SBC.b #10 : BRA - - + - STY $06 : LDY #$90 ; Store 10s digit and reset Y - CMP.b #1 : !BLT + - - - INY - DEC : BNE - - + - STY $07 ; Store 1s digit -RTS +;HudHexToDec3Digit: ; this may be overkill, could have used the 4 digit one... +; LDY.b #$90 +; - +; CMP.b #100 : !BLT + +; INY +; SBC.b #100 : BRA - +; + +; STY $05 : LDY.b #$90 ; Store 100s digit and reset Y +; - +; CMP.b #10 : !BLT + +; INY +; SBC.b #10 : BRA - +; + +; STY $06 : LDY #$90 ; Store 10s digit and reset Y +; CMP.b #1 : !BLT + +; - +; INY +; DEC : BNE - +; + +; STY $07 ; Store 1s digit +;RTS ;================================================================================ ; 8-bit registers diff --git a/newitems.asm b/newitems.asm index c8df278..2d8cc75 100755 --- a/newitems.asm +++ b/newitems.asm @@ -142,10 +142,6 @@ macro ValueShift() BRA ?start : ?end: endmacro ;-------------------------------------------------------------------------------- -!CHALLENGE_TIMER = "$7EF454" -!GOAL_COUNTER = "$7EF418" -!INVENTORY_SWAP_2 = "$7EF38E" -;-------------------------------------------------------------------------------- ;carry clear if pass ;carry set if caught ;incsrc eventdata.asm @@ -159,24 +155,24 @@ 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 - + REP #$20 ; set 16-bit accumulator LDA GoalItemRequirement : BEQ ++ - LDA !GOAL_COUNTER : INC : STA !GOAL_COUNTER + LDA GoalCounter : INC : STA GoalCounter CMP GoalItemRequirement : !BLT ++ - LDA TurnInGoalItems : BNE ++ + LDA TurnInGoalItems : AND.w #$00FF : BNE ++ JSL.l ActivateGoal ++ - + SEP #$20 ; set 8-bit accumulator LDX.b #$01 : BRA .done + LDX.b #$00 @@ -191,72 +187,65 @@ RTS AddReceivedItemExpandedGetItem: PHX - ;JSR.w ProcessEventItems : CPX.b #$00 : BEQ ++ - ; ;JSL.l Main_ShowTextMessage_Alt - ; LDA !GOAL_COUNTER : INC : STA !GOAL_COUNTER - ; LDA.b #$01 : STA $7F50XX - ; JMP .done - ;++ - ;STA $FFFFFF 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,34 +259,34 @@ 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 CurrentRupees : !SUB RupoorDeduction : STA CurrentRupees : SEP #$20 ; Take 1 rupee JMP .done + CMP.b #$5A : BNE + ; Null Item 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,12 +312,14 @@ AddReceivedItemExpandedGetItem: BRA .multi_collect + CMP.b #$6C : BNE + ; Goal Collectable (Multi/Power Star) Alternate Graphic .multi_collect - LDA GoalItemRequirement : BEQ ++ - LDA !GOAL_COUNTER : INC : STA !GOAL_COUNTER - CMP GoalItemRequirement : !BLT ++ - LDA TurnInGoalItems : BNE ++ + REP #$20 ; set 16-bit accumulator + LDA.l GoalItemRequirement : BEQ ++ + LDA.l GoalCounter : INC : STA.l GoalCounter + CMP.w GoalItemRequirement : !BLT ++ + LDA.l TurnInGoalItems : AND.w #$00FF : BNE ++ JSL.l ActivateGoal ++ + SEP #$20 ; set 8-bit accumulator JMP .done + CMP.b #$6D : BNE + ; Server Request F0 JSL.l ItemGetServiceRequest_F0 @@ -345,53 +336,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 DungeonKeys, X : INC : STA DungeonKeys, 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,8 +395,6 @@ RTL ; #$90 - Big Keys ; #$A0 - Small Keys ;-------------------------------------------------------------------------------- -!PROGRESSIVE_SHIELD = "$7EF416" ; ss-- ---- -!RNG_ITEM = "$7EF450" !SCRATCH_AREA = "$7F5020" !SINGLE_INDEX_TEMP = "$7F5020" !SINGLE_INDEX_OFFSET_TEMP = "$7F5021" @@ -458,11 +447,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 +462,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 +743,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 +903,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 +913,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 +933,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 @@ -974,7 +959,6 @@ RTL LDA.b #$24 : STA $7EC723 RTL ;-------------------------------------------------------------------------------- -!RNG_ITEM = "$7EF450" !SCRATCH_AREA = "$7F5020" !SINGLE_INDEX_TEMP = "$7F5020" !SINGLE_INDEX_OFFSET_TEMP = "$7F5021" @@ -1012,7 +996,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 @@ -1030,7 +1014,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 @@ -1045,7 +1029,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: @@ -1070,7 +1054,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 +1074,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 +1090,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 @@ -1122,6 +1106,7 @@ JML.l StatsFinalPrep ;-------------------------------------------------------------------------------- ChestPrep: LDA.b #$01 : STA $02E9 + JSL.l IncrementChestCounter LDA.l ServerRequestMode : BEQ + JSL.l ChestItemServiceRequest RTL @@ -1130,3 +1115,49 @@ ChestPrep: SEC RTL ;-------------------------------------------------------------------------------- +; Set a flag in SRAM if we pick up a compass in its own dungeon with HUD compass +; counts on +MaybeFlagCompassTotalPickup: + LDA CompassMode : BEQ .done + LDA $040C : CMP #$FF : BEQ .done + LSR : STA $04 : LDA #$0F : !SUB $04 ; Compute flag "index" + CPY #$25 : BEQ .setFlag ; Set flag if it's a compass for this dungeon + STA $04 + TYA : AND #$0F : CMP $04 : BNE .done ; Check if compass is for this dungeon + .setFlag + CMP #$08 : !BGE ++ + %ValueShift() + ORA CompassCountDisplay : STA CompassCountDisplay + BRA .done + ++ + !SUB #$08 + %ValueShift() + BIT.b #$C0 : BEQ + : LDA.b #$C0 : + ; Make Hyrule Castle / Sewers Count for Both + ORA CompassCountDisplay+1 : STA CompassCountDisplay+1 + .done +RTL +;-------------------------------------------------------------------------------- +; Set the compass count display flag if we're entering a dungeon and alerady have +; that compass +MaybeFlagCompassTotalEntrance: + LDX $040C : CPX #$FF : BEQ .done ; Skip if we're not entering dungeon + LDA CompassMode : BEQ .done ; Skip if we're not showing compass counts + CMP.w #$0002 : BEQ .countShown + LDA CompassField : AND.l DungeonItemMasks, X : BEQ .done ; skip if we don't have compass + .countShown + SEP #$20 + TXA : LSR : STA.b $04 : LDA.b #$0F : !SUB $04 ; Compute flag "index" + CMP #$08 : !BGE ++ + %ValueShift() + ORA CompassCountDisplay : STA CompassCountDisplay + REP #$20 + BRA .done + ++ + !SUB #$08 + %ValueShift() + BIT.b #$C0 : BEQ + : LDA.b #$C0 : + ; Make Hyrule Castle / Sewers Count for Both + ORA CompassCountDisplay+1 : STA CompassCountDisplay+1 + REP #$20 + .done +RTL +;-------------------------------------------------------------------------------- diff --git a/npcitems.asm b/npcitems.asm index db20ce6..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 $7EF34C + 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 $7EF34C : 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,14 +83,14 @@ ItemCheck_Mushroom: RTL ItemCheck_Powder: - LDA !NPC_FLAGS_2 : AND.b #$20 + LDA NpcFlags+1 : AND.b #$20 RTL ItemCheck_Catfish: ;LDA CatfishGoodItem : BEQ .junk ;PHX ; LDA CatfishGoodItem+1 : TAX - ; LDA $7EF340-1, X + ; LDA BowEquipment-1, X ;PLX ;-- ;CMP CatfishGoodItem : !BLT .oursNewer @@ -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 deleted file mode 100644 index 4bf907c..0000000 --- a/openmode.asm +++ /dev/null @@ -1,29 +0,0 @@ -;================================================================================ -; Open Mode Uncle Rain State Check -;================================================================================ -!INFINITE_ARROWS = "$7F50C8" -!INFINITE_BOMBS = "$7F50C9" -!INFINITE_MAGIC = "$7F50CA" -SetUncleRainState: - LDA.l OpenMode : BEQ + : RTL : + ; we're done if open mode is on - LDA.b #$01 : STA $7EF3C5 -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 $7EF29B : ORA.b #$20 : STA $7EF29B ; open castle gate - JSL MaybeSetPostAgaWorldState - + -RTL -;-------------------------------------------------------------------------------- -MaybeSetPostAgaWorldState: - LDA.l InstantPostAgaWorldState : BEQ + ; Skip if not enabled - LDA.b #$03 : STA $7EF3C5 ; 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/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/pendantcrystalhud.asm b/pendantcrystalhud.asm index 256b395..b9809a5 100644 --- a/pendantcrystalhud.asm +++ b/pendantcrystalhud.asm @@ -2,19 +2,19 @@ ; 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: 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,23 @@ 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 MapOverlay : 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 MapOverlay, X PLX AND.l .lw_map_masks, X : BNE +++ JMP .fail @@ -74,10 +72,10 @@ OverworldMap_CheckObject: + ;DW Map LDA.l MapMode : BEQ +++ - LDA !INVENTORY_MAP : 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 !INVENTORY_MAP, X : ORA !MAP_OVERLAY, X + LDA.l MapField, X : ORA MapOverlay, X PLX AND.l .dw_map_masks, X : BNE +++ JMP .fail @@ -92,11 +90,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 +119,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 + @@ -193,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,13 +203,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 DungeonKeys, 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 +283,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 @@ -366,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 @@ -386,7 +384,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 +408,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 +419,7 @@ DrawHUDDungeonItems: STA.w $16C6,Y ; reload - LDA.l $7EF366 + LDA.l BigKeyField ..skip_key INX : INX @@ -439,7 +437,7 @@ DrawHUDDungeonItems: .next_boss_kill LDX.w .boss_room_ids,Y - LDA.l $7EF000,X + LDA.l RoomDataWRAM.l,X AND.w #$0800 BEQ ..skip_boss_kill @@ -469,7 +467,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 +478,7 @@ DrawHUDDungeonItems: STA.w $1686,Y ; reload - LDA.l $7EF368 + LDA.l MapField ..skip_map INX : INX @@ -498,7 +496,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 +507,7 @@ DrawHUDDungeonItems: STA.w $16C6,Y ; reload - LDA.l $7EF364 + LDA.l CompassField ..skip_compass INX : INX @@ -542,7 +540,7 @@ DrawPendantCrystalDiagram: INX #2 : CPX.w #$0014 : BCC - ; pendants - LDA $7EF374 + LDA PendantsField LSR : BCC + ; pendant of wisdom (red) LDX.w #$252B @@ -569,7 +567,7 @@ DrawPendantCrystalDiagram: ; crystals - LDA $7EF37A + LDA CrystalsField LDX.w #$2D44 LDY.w #$2D45 @@ -675,4 +673,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..1eddb15 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 MaximumHealth : !BLT +++ : LDA MaximumHealth : +++ 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 MaximumHealth : BCC .refillAllHealth + LDA MaximumHealth : 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/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/quickswap.asm b/quickswap.asm index e73938c..1331614 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 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 !INVENTORY_SWAP_2 : AND #$FE : STA !INVENTORY_SWAP_2 + LDA InventoryTracking+1 : AND #$FE : STA InventoryTracking+1 BRA + ++ - LDA !INVENTORY_SWAP_2 : 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 !INVENTORY_SWAP_2 : AND #$FE : STA !INVENTORY_SWAP_2 + LDA InventoryTracking+1 : AND #$FE : STA InventoryTracking+1 BRA + ++ - LDA !INVENTORY_SWAP_2 : 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/ram.asm b/ram.asm new file mode 100644 index 0000000..3510b8f --- /dev/null +++ b/ram.asm @@ -0,0 +1,18 @@ +;================================================================================ +; RAM Labels & Assertions +;-------------------------------------------------------------------------------- +; Labels for values in WRAM and assertions that ensure they're correct and +; at the expected addresses. All values larger than one byte are little endian. +;-------------------------------------------------------------------------------- +; Placeholder and for compass item max count allocations, still WIP +;-------------------------------------------------------------------------------- +CompassTotalsWRAM = $7F5410 + +;================================================================================ +; RAM Assertions +;-------------------------------------------------------------------------------- +macro assertRAM(label, address) + assert