diff --git a/LTTP_RND_GeneralBugfixes.asm b/LTTP_RND_GeneralBugfixes.asm index 214543d..5ecd21c 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"; @@ -135,6 +103,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 @@ -148,7 +118,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 @@ -199,6 +168,11 @@ org $A1A000 ; static mapping area. Referenced by front end. Do not move. incsrc invertedstatic.asm warnpc $A1A100 +org $A1B000 +incsrc failure.asm +warnpc $A1FF00 + + org $A1FF00 ; static mapping area incsrc init.asm @@ -212,7 +186,6 @@ incsrc firebarlayer.asm incsrc glitched.asm incsrc hardmode.asm incsrc goalitem.asm -incsrc openmode.asm incsrc quickswap.asm incsrc endingsequence.asm incsrc cuccostorm.asm @@ -251,13 +224,15 @@ warnpc $A58000 ;org $228000 ; contrib area org $A28000 ; contrib area incsrc contrib.asm +warnpc $A38000 org $A38000 incsrc stats/main.asm incsrc menu/overworldmap.asm ; overwrites some code in bank 0A -incsrc doorrando.asm ; bank 27 likely A7 in the future -;bank 28/A8 for keydropshuffle +incsrc doorrando/doorrando.asm ; bank 27 likely A7 in the future +;bank 28/A8 for keydropshuffle / standing items +incsrc keydrop/standing_items.asm incsrc enemizer/main.asm ; this is originally in bank 36, but is currently in migratory status in bank 37 org $308000 ; bank #$30 @@ -345,7 +320,6 @@ if !FEATURE_NEW_TEXT incbin newfont.bin NewFontInverted: incbin newfont_inverted.bin - org $0CD7DF incbin text_unscramble1.bin org $0CE4D5 @@ -388,8 +362,9 @@ warnpc $B08000 ;$23 Stats & Credits ;$24 Code Bank ;$27 DR Code Bank -;$28 Keydrop Code bank +;$28 Keydrop / Standing Items Code bank ;$29 External hooks (rest of bank not used) +;$2A Room Data migration ;$2E Reserved for Tournament Use ;$2F Static RNG (rest is reserved for tournament use) ;$30 Main Configuration Table @@ -405,20 +380,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 @@ -498,6 +474,8 @@ org $00891D org $00893D EnableForceBlank: +DungeonMask = $0098C0 + org $00D308 DecompSwordGfx: @@ -539,9 +517,18 @@ Dungeon_SaveRoomData: org $02A0BE Dungeon_SaveRoomData_justKeys: +org $02A4E3 +Overworld_ActualScreenID: + org $02B861 Dungeon_SaveRoomQuadrantData: +org $02C176 +Overworld_FinalizeEntryOntoScreen_Data: + +org $02E99D +FluteMenu_LoadTransport: + org $02FD8A ; 17D8A - Bank0E.asm: 3732 Note: Different bank LoadGearPalettes_bunny: @@ -554,6 +541,9 @@ Filter_Majorly_Whiten_Color: org $04E780 Overworld_MemorizeMap16Change: +org $04E879 +Overworld_CheckForSpecialOverworldTrigger_Direction: + org $05A51D Sprite_SpawnFallingItem: @@ -683,6 +673,9 @@ Sprite_SetSpawnedCoords: org $09AD58 GiveRupeeGift: +org $0AB7BD +FluteMenu_HandleSelection_NoSelection: + org $0ABA4F OverworldMap_InitGfx: @@ -692,6 +685,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 d5ca495..0e2f335 100644 --- a/bookofmudora.asm +++ b/bookofmudora.asm @@ -57,7 +57,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 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/bsodencode.txt b/bsodencode.txt new file mode 100644 index 0000000..81e1890 --- /dev/null +++ b/bsodencode.txt @@ -0,0 +1,71 @@ + =00 +A=01 +a=01 +B=02 +b=02 +C=03 +c=03 +D=04 +d=04 +E=05 +e=05 +F=06 +f=06 +G=07 +g=07 +H=08 +h=08 +I=09 +i=09 +J=0A +j=0A +K=0B +k=0B +L=0C +l=0C +M=0D +m=0D +N=0E +n=0E +O=0F +o=0F +P=10 +p=10 +Q=11 +q=11 +R=12 +r=12 +S=13 +s=13 +T=14 +t=14 +U=15 +u=15 +V=16 +v=16 +W=17 +w=17 +X=18 +x=18 +Y=19 +y=19 +Z=1A +z=1A +0=1B +1=1C +2=1D +3=1E +4=1F +5=20 +6=21 +7=22 +8=23 +9=24 +.=25 +#=26 +?=27 +-=28 +/=29 +,=2A +'=2B +;=2C \ No newline at end of file diff --git a/bsodfont.1bpp b/bsodfont.1bpp new file mode 100644 index 0000000..2c8e2f8 Binary files /dev/null and b/bsodfont.1bpp differ diff --git a/bsodhex.2bpp b/bsodhex.2bpp new file mode 100644 index 0000000..fabf08e Binary files /dev/null and b/bsodhex.2bpp differ diff --git a/bugfixes.asm b/bugfixes.asm index 10df7ad..8555c5e 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 PHX : LDX $8A : LDA.l OWTileWorldAssoc, X : PLX : 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 RTL @@ -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 7f27cd8..d8493a7 100644 --- a/compasses.asm +++ b/compasses.asm @@ -3,6 +3,7 @@ ;-------------------------------------------------------------------------------- DrawDungeonCompassCounts: + SEP #$10 LDX $1B : BNE + : RTL : + ; Skip if outdoors ; extra hard safeties for getting dungeon ID to prevent crashes @@ -10,33 +11,42 @@ DrawDungeonCompassCounts: LDA.w $040C : AND.w #$00FE : TAX ; force dungeon ID to be multiple of 2 PLA - 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 - BEQ .done ; skip if we don't have compass + CPX.b #$1B : BCC + ; Skip if not in a valid dungeon ID + JMP .done + + + BIT.w #$0002 : BNE ++ ; if CompassMode==2, we don't check for the compass + TXY : TXA : LSR : TAX : LDA.l ExistsTransfer, X : TAX : LDA CompassExists, X : BEQ ++ + TYX : LDA CompassField : AND.l DungeonItemMasks, X ; Load compass values to A, mask with dungeon item masks + BNE ++ + JMP .done ; skip if we don't have compass ++ LDA $040C : LSR BNE + INC - + TAX : LDA.l CompassTotal, X : AND #$00FF - SEP #$20 - JSR HudHexToDec2Digit - REP #$20 + + TAX : LDA.l CompassTotalsWRAM, X : AND #$00FF PHX - LDX.b $06 : TXA : ORA #$2400 : STA $7EC79A - LDX.b $07 : TXA : ORA #$2400 : STA $7EC79C + PHA + JSL HexToDec_fast + PLA : CMP.w #100 : !BLT .two_digit + LDX.b $05 : TXA : ORA #$2490 : STA $7EC79A + LDX.b $06 : TXA : ORA #$2490 : STA $7EC79C + LDX.b $07 : TXA : ORA #$2490 : STA $7EC79E + BRA .end_total + .two_digit + LDX.b $06 : TXA : ORA #$2490 : STA $7EC79A + LDX.b $07 : TXA : ORA #$2490 : STA $7EC79C + .end_total PLX - LDA $7EF4BF, 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 - + LDA DungeonLocationsChecked, X : AND #$00FF + PHA + JSL HexToDec_fast + PLA : CMP.w #100 : !BLT + + LDX.b $05 : TXA : ORA #$2490 : STA $7EC792 ; Draw the 100's digit + + + LDX.b $06 : TXA : ORA #$2490 : STA $7EC794 ; Draw the item count + LDX.b $07 : TXA : ORA #$2490 : STA $7EC796 LDA.w #$2830 : STA $7EC798 ; draw the slash .done @@ -46,6 +56,17 @@ DungeonItemMasks: ; these are dungeon correlations to $7EF364 - $7EF369 so it kn dw $8000, $4000, $2000, $1000, $0800, $0400, $0200, $0100 dw $0080, $0040, $0020, $0010, $0008, $0004 +; maps from $040C to the odd order used in overworld map +ExistsTransfer: +db $0C, $0C, $00, $02, $0B, $09, $03, $07, $04, $08, $01, $06, $05, $0A + ;-------------------------------------------------------------------------------- ; $7EF4C0-7EF4CF - item locations checked indexed by $040C >> 1 -;-------------------------------------------------------------------------------- \ 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..72f8981 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 @@ -181,3 +180,6 @@ Sprite_ShowSolicitedMessageIfPlayerFacing_PreserveMessage: RTL } ;================================================================ + +incsrc menu/hudalpha.asm +incsrc util/utils.asm 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 1dc7a8a..6ebc59a 100644 --- a/darkworldspawn.asm +++ b/darkworldspawn.asm @@ -10,24 +10,24 @@ DoWorldFix: LDA InvertedMode : BEQ + JMP DoWorldFix_Inverted + - LDA $7EF3CC : CMP #$04 : BEQ .aga1Alive ; if old man following, skip mirror/aga check + LDA FollowerIndicator : CMP #$04 : BEQ .aga1Alive ; if old man following, skip mirror/aga check LDA.l Bugfix_MirrorlessSQToLW : BEQ .skip_mirror_check - LDA $7EF353 : AND #$02 : BEQ .noMirror ; check if we have the mirror + LDA MirrorEquipment : AND #$02 : 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 + STA CurrentWorld ; set flag to light world LDA.l SmithDeleteOnSave : BEQ .transform - LDA $7EF3CC + 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 : BRA .done ; clear follower + LDA.b #$00 : STA FollowerIndicator : BRA .done ; clear follower .transform - LDA $7EF3CC : CMP #$07 : BNE .done : INC : STA $7EF3CC ; convert frog to dwarf + LDA FollowerIndicator : CMP #$07 : BNE .done : INC : STA FollowerIndicator ; convert frog to dwarf .done RTL ;-------------------------------------------------------------------------------- @@ -48,29 +48,29 @@ 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 $7EF3CC : CMP #$04 : BEQ .aga1Alive ; if old man following, skip mirror/aga check + LDA FollowerIndicator : CMP #$04 : BEQ .aga1Alive ; if old man following, skip mirror/aga check LDA.l Bugfix_MirrorlessSQToLW : BEQ .skip_mirror_check - LDA $7EF353 : AND #$02 : BEQ .noMirror ; check if we have the mirror + LDA.l MirrorEquipment : AND #$02 : 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 #$40 : STA CurrentWorld ; set flag to dark world LDA.l SmithDeleteOnSave : BEQ .transform - LDA $7EF3CC + 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 : BRA .done ; clear follower + LDA.b #$00 : STA FollowerIndicator : BRA .done ; clear follower .transform - LDA $7EF3CC : CMP #$07 : BNE .done : INC : STA $7EF3CC ; convert frog to dwarf + LDA FollowerIndicator : CMP #$07 : BNE .done : INC : STA FollowerIndicator ; convert frog to dwarf .done RTL ;-------------------------------------------------------------------------------- @@ -88,8 +88,8 @@ JMP DoWorldFix_Inverted JMP DoWorldFix_Inverted_skip_mirror_check .castle - LDA #$00 : STA $7EF3CA ; set flag to light 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 ;================================================================================ @@ -99,20 +99,20 @@ RTL FakeWorldFix: LDA FixFakeWorld : BEQ + PHX - LDX $8A : LDA.l OWTileWorldAssoc, X : STA $7EF3CA + LDX $8A : LDA.l OWTileWorldAssoc, X : STA CurrentWorld PLX + 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 ;-------------------------------------------------------------------------------- @@ -122,24 +122,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 @@ -148,7 +148,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 : + @@ -164,8 +164,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/doorrando.asm b/doorrando/doorrando.asm similarity index 97% rename from doorrando.asm rename to doorrando/doorrando.asm index 7a6c926..346b943 100644 --- a/doorrando.asm +++ b/doorrando/doorrando.asm @@ -44,5 +44,4 @@ incsrc doortables.asm warnpc $288000 ; deals with own hooks -incsrc keydropshuffle.asm incsrc owrando.asm diff --git a/doortables.asm b/doorrando/doortables.asm similarity index 100% rename from doortables.asm rename to doorrando/doortables.asm diff --git a/doorrando/dr_lobby.asm b/doorrando/dr_lobby.asm new file mode 100644 index 0000000..6206a24 --- /dev/null +++ b/doorrando/dr_lobby.asm @@ -0,0 +1,10 @@ +CheckDarkWorldSpawn: + STA $A0 : STA $048E ; what we wrote over + LDA.l DRFlags : AND #$0200 : BEQ + ; skip if the flag isn't set + LDA.l MoonPearlEquipment : AND #$00FF : BNE + ; moon pearl? + LDA.l LinksHouseDarkWorld : CMP $A0 : BEQ ++ + LDA.l SanctuaryDarkWorld : CMP $A0 : BEQ ++ + LDA.l OldManDarkWorld : CMP $A0 : BNE + + ++ SEP #$30 : LDA #$17 : STA $5D + INC $02E0 : LDA.b #$40 : STA CurrentWorld : REP #$30 ++ RTL diff --git a/drhooks.asm b/doorrando/drhooks.asm similarity index 99% rename from drhooks.asm rename to doorrando/drhooks.asm index a5815d9..708bd11 100644 --- a/drhooks.asm +++ b/doorrando/drhooks.asm @@ -176,7 +176,7 @@ org $02d9ce ; <- Bank02.asm : Dungeon_LoadEntrance 10829 (STA $A0 : STA $048E) JSL CheckDarkWorldSpawn : NOP org $01891e ; <- Bank 01.asm : 991 Dungeon_LoadType2Object (LDA $00 : XBA : AND.w #$00FF) -JSL RainPrevention : NOP #2 +JSL RainPrevention : BCC + : RTS : NOP : + org $1edabf ; <- sprite_energy_ball.asm : 86-7 Sprite_EnergyBall (LDA.b #$10 : LDX.b #$00) JSL StandardAgaDmg @@ -210,7 +210,7 @@ dw $8AD9 ; address of Bank02.asm:2085 ;.done ;Enable south facing bk graphic -;org $4e24 +;org $00CE24 ;dw $2ac8 org $01b714 ; PC: b714 diff --git a/edges.asm b/doorrando/edges.asm similarity index 100% rename from edges.asm rename to doorrando/edges.asm diff --git a/gfx.asm b/doorrando/gfx.asm similarity index 100% rename from gfx.asm rename to doorrando/gfx.asm diff --git a/hudadditions.asm b/doorrando/hudadditions.asm similarity index 67% rename from hudadditions.asm rename to doorrando/hudadditions.asm index b21fa78..c77f411 100644 --- a/hudadditions.asm +++ b/doorrando/hudadditions.asm @@ -7,28 +7,43 @@ DrHudOverride: HudAdditions: { - lda.l DRFlags : and #$0008 : beq ++ -; LDA.w #$28A4 : STA !GOAL_DRAW_ADDRESS - lda $7EF423 - jsr HudHexToDec4DigitCopy - 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 #$10 + LDA.l DRFlags : AND #$0008 : BNE + : JMP .end_item_count : + + LDA.l TotalItemCounter : PHA : CMP #1000 : !BLT + + JSL HexToDec4Digit_fast + LDX.b $04 : TXA : ORA.w #$2490 : STA !GOAL_DRAW_ADDRESS ; draw 1000's digit + BRA .skip + + JSL HexToDec_fast + .skip + LDA #$207F : STA !GOAL_DRAW_ADDRESS+2 : STA !GOAL_DRAW_ADDRESS+4 + PLA : PHA : CMP.w #100 : !BLT + + LDX.b $05 : TXA : ORA.w #$2490 : STA !GOAL_DRAW_ADDRESS+2 ; draw 100's digit + + PLA : CMP.w #10 : !BLT + + LDX.b $06 : TXA : ORA.w #$2490 : STA !GOAL_DRAW_ADDRESS+4 ; draw 10's digit + + LDX.b $07 : TXA : ORA.w #$2490 : STA !GOAL_DRAW_ADDRESS+6 ; draw 1's digit LDA.w #$2830 : STA !GOAL_DRAW_ADDRESS+8 ; draw slash LDA.l DRFlags : AND #$0100 : BNE + - lda $7EF33E - jsr HudHexToDec4DigitCopy - 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 ++ - + LDA.w #$2405 : STA !GOAL_DRAW_ADDRESS+10 : STA !GOAL_DRAW_ADDRESS+12 : STA !GOAL_DRAW_ADDRESS+14 - ++ + LDA.l MultiClientFlagsWRAM+1 : CMP #1000 : !BLT .three_digit_goal + JSL HexToDec4Digit_fast + LDX.b $04 : TXA : ORA.w #$2490 : STA !GOAL_DRAW_ADDRESS+10 ; draw 1000's digit + LDX.b $05 : TXA : ORA.w #$2490 : STA !GOAL_DRAW_ADDRESS+12 ; draw 100's digit + LDX.b $06 : TXA : ORA.w #$2490 : STA !GOAL_DRAW_ADDRESS+14 ; draw 10's digit + LDX.b $07 : TXA : ORA.w #$2490 : STA !GOAL_DRAW_ADDRESS+16 ; draw 1's digit + BRA .end_item_count + .three_digit_goal + JSL HexToDec_fast + LDX.b $05 : TXA : ORA.w #$2490 : STA !GOAL_DRAW_ADDRESS+10 ; draw 100's digit + LDX.b $06 : TXA : ORA.w #$2490 : STA !GOAL_DRAW_ADDRESS+12 ; draw 10's digit + LDX.b $07 : TXA : ORA.w #$2490 : STA !GOAL_DRAW_ADDRESS+14 ; draw 1's digit + BRA .end_item_count + + LDA.w #$2405 : STA !GOAL_DRAW_ADDRESS+10 : STA !GOAL_DRAW_ADDRESS+12 + STA !GOAL_DRAW_ADDRESS+14 : STA !GOAL_DRAW_ADDRESS+16 + .end_item_count LDX $1B : BNE + ; if outdoors lda.l OWMode : and.w #((!FLAG_OW_CROSSED+!FLAG_OW_MIXED)<<8)+$ff : bne ++ : rts ; Skip if vanilla ow rando - ++ lda $7ef36d : and #$00ff : beq ++ - lda $7ef3ca : and #$00ff : beq +++ + ++ lda CurrentHealth : and #$00ff : beq ++ + lda CurrentWorld : and #$00ff : beq +++ lda #$2d60 : bra .owdisplay +++ lda #$2d68 : bra .owdisplay ++ lda #$207f @@ -36,22 +51,22 @@ HudAdditions: + ldx $040c : cpx #$ff : bne + : rts : + ; Skip if not in dungeon lda.l DRMode : bne + : rts : + ; Skip if not door rando phb : phk : plb - lda $7ef364 : and.l $0098c0, x : beq + + lda CompassField : and.l $0098c0, x : beq + lda.w CompassBossIndicator, x : and #$00ff : cmp $a0 : bne + lda $1a : and #$0010 : beq + lda #$345e : sta $7ec790 : bra .next + lda #$207f : sta $7ec790 .next lda.w DRMode : and #$0002 : bne + : plb : rts : + - lda $7ef36d : and #$00ff : beq + + lda CurrentHealth : and #$00ff : beq + lda.w DungeonReminderTable, x : bra .reminder + lda #$207f .reminder sta $7ec702 + lda.w DRFlags : and #$0004 : beq .restore - lda $7ef368 : and.l $0098c0, x : beq .restore + lda MapField : and.l $0098c0, x : beq .restore txa : lsr : tax lda.l GenericKeys : and #$00ff : bne + - lda $7ef4e0, x : jsr ConvertToDisplay : sta $7ec7a2 + lda DungeonCollectedKeys, x : jsr ConvertToDisplay : sta $7ec7a2 lda #$2830 : sta $7ec7a4 + lda.w ChestKeys, x : jsr ConvertToDisplay : sta $7ec7a6 @@ -89,7 +104,7 @@ DrHudDungeonItemsAdditions: - sta $1704, x : sta $170e, x : sta $1718, x inx #2 : cpx #$0008 : !blt - - lda !HUD_FLAG : and.w #$0020 : beq + : JMP ++ : + + lda HudFlag : and.w #$0020 : beq + : JMP ++ : + lda HUDDungeonItems : and.w #$0007 : bne + : JMP ++ : + ; bk symbols lda.w #$2811 : sta $1606 : sta $1610 : sta $161a : sta $1624 @@ -102,9 +117,9 @@ DrHudDungeonItemsAdditions: - lda #$0000 : !addl RowOffsets,x : !addl ColumnOffsets, x : tay lda.l DungeonReminderTable, x : sta $1644, y : iny #2 lda.w #$24f5 : sta $1644, y - lda $7ef368 : and.l $0098c0, x : beq + ; must have map + lda MapField : and.l $0098c0, x : beq + ; must have map jsr BkStatus : sta $1644, y : bra .smallKey ; big key status - + lda $7ef366 : and.l $0098c0, x : beq .smallKey + + lda BigKeyField : and.l $0098c0, x : beq .smallKey lda.w #$2826 : sta $1644, y .smallKey + iny #2 @@ -114,14 +129,14 @@ DrHudDungeonItemsAdditions: txa : lsr : tax lda.w #$24f5 : sta $1644, y lda.l GenericKeys : and #$00FF : bne + - lda.l $7ef37c, x : and #$00FF : beq + + lda.l DungeonKeys, x : and #$00FF : beq + jsr ConvertToDisplay2 : sta $1644, y + iny #2 : lda.w #$24f5 : sta $1644, y phx : ldx $00 - lda $7ef368 : and.l $0098c0, x : beq + ; must have map + lda MapField : and.l $0098c0, x : beq + ; must have map plx : sep #$30 : lda.l ChestKeys, x : sta $02 lda.l GenericKeys : bne +++ - lda $02 : !sub $7ef4e0, x : sta $02 + lda $02 : !sub DungeonCollectedKeys, x : sta $02 +++ lda $02 rep #$30 jsr ConvertToDisplay2 : sta $1644, y ; small key totals @@ -134,7 +149,7 @@ DrHudDungeonItemsAdditions: ldx $00 + inx #2 : cpx #$001b : bcs ++ : JMP - ++ - lda !HUD_FLAG : and.w #$0020 : bne + : JMP ++ : + + lda HudFlag : and.w #$0020 : bne + : JMP ++ : + lda HUDDungeonItems : and.w #$000c : bne + : JMP ++ : + ; map symbols (do I want these) ; note compass symbol is 2c20 lda.w #$2821 : sta $1606 : sta $1610 : sta $161a : sta $1624 @@ -147,16 +162,16 @@ DrHudDungeonItemsAdditions: lda.l DungeonReminderTable, x : sta $1644, y iny #2 lda.w #$24f5 : sta $1644, y ; blank out map spot - lda $7ef368 : and.l $0098c0, x : beq + ; must have map - lda #$2826 : sta $1644, y ; check mark + lda MapField : and.l $0098c0, x : beq + ; must have map + JSR MapIndicatorShort : STA $1644, Y + iny #2 cpx #$001a : bne + tya : !add #$003c : tay - + lda $7ef364 : and.l $0098c0, x : beq + ; must have compass + + lda CompassField : and.l $0098c0, x : beq + ; must have compass phx ; total chest counts txa : lsr : tax sep #$30 - lda.l TotalLocations, x : !sub $7EF4BF, x : JSR HudHexToDec2DigitCopy + lda.l TotalLocations, x : !sub DungeonLocationsChecked, x : JSR HudHexToDec2DigitCopy rep #$30 lda $06 : jsr ConvertToDisplay2 : sta $1644, y : iny #2 lda $07 : jsr ConvertToDisplay2 : sta $1644, y @@ -171,8 +186,36 @@ DrHudDungeonItemsAdditions: plp : ply : plx : rtl } +MapIndicatorLong: + PHX + LDA.l OldHudToNewHudTable, X : TAX + JSR MapIndicator + PLX +RTL + +MapIndicatorShort: + PHX + TXA : LSR : TAX + JSR MapIndicator + PLX +RTS + +OldHudToNewHudTable: + dw 1, 2, 3, 10, 4, 6, 5, 8, 11, 9, 7, 12, 13 + +IndicatorCharacters: + ; check 1 2 3 4 5 6 7 G B R + dw $2426, $2817, $2818, $2819, $281A, $281B, $281C, $281D, $2590, $258B, $259B + +MapIndicator: + LDA.l CrystalPendantFlags_3, X : AND #$00FF + PHX + ASL : TAX : LDA.l IndicatorCharacters, X + PLX +RTS + BkStatus: - lda $7ef366 : and.l $0098c0, x : bne +++ ; has the bk already + lda BigKeyField : and.l $0098c0, x : bne +++ ; has the bk already lda.l BigKeyStatus, x : bne ++ lda #$2827 : rts ; 0/O for no BK ++ cmp #$0002 : bne + @@ -188,7 +231,7 @@ ConvertToDisplay: ConvertToDisplay2: and.w #$00ff : beq ++ cmp #$000a : !blt + - !add #$2553 : rts + !add #$2553 : rts ; 2580 with 258A as "A" for non transparent digits + !add #$2816 : rts ++ lda #$2827 : rts ; 0/O for 0 or placeholder digit ;2483 @@ -196,7 +239,7 @@ CountAbsorbedKeys: jsl IncrementSmallKeysNoPrimary : phx lda $040c : cmp #$ff : beq + lsr : tax - lda $7ef4b0, x : inc : sta $7ef4b0, x + lda DungeonAbsorbedKeys, x : inc : sta DungeonAbsorbedKeys, x + plx : rtl ;================================================================================ @@ -253,4 +296,4 @@ HudHexToDec2DigitCopy: ; modified + STY $07 ; Store 1s digit PLY -RTS \ No newline at end of file +RTS diff --git a/keydoors.asm b/doorrando/keydoors.asm similarity index 94% rename from keydoors.asm rename to doorrando/keydoors.asm index 1ec10c3..3f6c051 100644 --- a/keydoors.asm +++ b/doorrando/keydoors.asm @@ -27,7 +27,7 @@ CheckIfDoorsOpen: { lda.w PairedDoorTable, x : beq .skipDoor sta $02 : and #$00ff : asl a : tax lda $02 : and #$ff00 : sta $03 - lda $7ef000, x : and #$f000 : and $03 : beq .skipDoor + lda RoomDataWRAM.l, X : and #$f000 : and $03 : beq .skipDoor tyx : lda $068c : ora $0098c0,x : sta $068c .skipDoor iny #2 : cpy $00 : bne .nextDoor @@ -39,4 +39,4 @@ CheckIfDoorsOpen: { ; Bank01 Door Register stores the 4 bits in 068c to 400 (depending on type) ; Key collision and others depend on F0-F3 attribute not sure if extendable to other numbers ; Dungeon_ProcessTorchAndDoorInteractives.isOpenableDoor is the likely culprit for collision problems -; Saving open status to other unused rooms is tricky -- Bank 2 13947 (line 8888) \ No newline at end of file +; Saving open status to other unused rooms is tricky -- Bank 2 13947 (line 8888) diff --git a/math.asm b/doorrando/math.asm similarity index 100% rename from math.asm rename to doorrando/math.asm diff --git a/normal.asm b/doorrando/normal.asm similarity index 100% rename from normal.asm rename to doorrando/normal.asm diff --git a/overrides.asm b/doorrando/overrides.asm similarity index 78% rename from overrides.asm rename to doorrando/overrides.asm index c4586c9..098c85b 100644 --- a/overrides.asm +++ b/doorrando/overrides.asm @@ -7,9 +7,9 @@ LampCheckOverride: 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 : CMP.b #$04 : !BGE ++ ; check if we're in HC LDA LampConeSewers : BRA .done @@ -36,13 +36,13 @@ rtl OnFileLoadOverride: jsl OnFileLoad ; what I wrote over + lda.l DRFlags : and #$02 : beq + ; Mirror Scroll - lda $7ef353 : bne + - lda #$01 : sta $7ef353 + lda MirrorEquipment : bne + + lda #$01 : sta MirrorEquipment + rtl MirrorCheckOverride: lda.l DRFlags : and #$02 : beq ++ - lda $7ef353 : cmp #$01 : beq + + lda MirrorEquipment : cmp #$01 : beq + ;++ lda $8A : and #$40 ; what I wrote over ++ phx : ldx $8A : lda.l OWTileWorldAssoc,x : plx : and.b #$ff rtl @@ -55,13 +55,13 @@ EGFixOnMirror: rtl BlockEraseFix: - lda $7ef353 : and #$02 : beq + + lda MirrorEquipment : and #$02 : beq + stz $05fc : stz $05fd + rtl FixShopCode: cpx #$300 : !bge + - sta $7ef000, x + sta RoomDataWRAM[$00].l, x + rtl VitreousKeyReset: @@ -78,7 +78,7 @@ GuruguruFix: BlindAtticFix: lda.l DRMode : beq + lda #$01 : rtl - + lda $7EF3CC : cmp.b #$06 + + lda FollowerIndicator : cmp.b #$06 rtl SuctionOverworldFix: @@ -119,27 +119,29 @@ RetrieveBunnyState: + RTL RainPrevention: - LDA $00 : XBA : AND #$00FF ; what we wrote over + LDA $00 : XBA : AND #$00FF : STA.b $0A ; what we wrote over PHA - LDA $7EF3C5 : AND #$00FF : CMP #$0002 : !BGE .done ; only in rain states (0 or 1) - LDA.l $7EF3C6 : AND #$0004 : BNE .done ; zelda's been rescued + LDA ProgressIndicator : AND #$00FF : CMP #$0002 : !BGE .done ; only in rain states (0 or 1) + LDA.l ProgressFlags : AND #$0004 : BNE .done ; zelda's been rescued LDA.l BlockSanctuaryDoorInRain : BEQ .done ;flagged LDA $A0 : CMP #$0012 : BNE + ;we're in the sanctuary - LDA.l $7EF3CC : AND #$00FF : CMP #$0001 : BEQ .done ; zelda is following + LDA.l FollowerIndicator : AND #$00FF : CMP #$0001 : BEQ .done ; zelda is following LDA $00 : AND #$00FF : CMP #$00A1 : BNE .done ; position is a1 PLA : LDA #$0008 : RTL + LDA.l BlockCastleDoorsInRain : AND #$00FF : BEQ .done ;flagged LDX #$FFFE - INX #2 : LDA.l RemoveRainDoorsRoom, X : CMP #$FFFF : BEQ .done CMP $A0 : BNE - - LDA.l RainDoorMatch, X : CMP $00 : BNE - - PLA : LDA #$0008 : RTL - .done PLA : RTL + SEP #$20 : LDA.l RainDoorMatch, X : CMP $00 : BNE .continue + REP #$20 : PLA : SEC : RTL + .continue + REP #$20 : BRA - + .done PLA : CLC : RTL ; A should be how much dmg to do to Aga when leaving this function StandardAgaDmg: LDX.b #$00 ; part of what we wrote over - LDA.l $7EF3C6 : AND #$04 : BEQ + ; zelda's not been rescued + LDA.l ProgressFlags : AND #$04 : BEQ + ; zelda's not been rescued LDA.b #$10 ; hurt him! + RTL ; A is zero if the AND results in zero and then Agahnim's invincible! @@ -147,7 +149,7 @@ StandardAgaDmg: BlindsAtticHint: REP #$20 CMP.w #$0122 : BNE + - LDA $7EF0CA : AND.w #$0100 : BEQ + + LDA RoomDataWRAM[$65].low : AND.w #$0100 : BEQ + SEP #$20 : RTL ; skip the dialog box if the hole is already open + SEP #$20 : JML Main_ShowTextMessage diff --git a/scroll.asm b/doorrando/scroll.asm similarity index 100% rename from scroll.asm rename to doorrando/scroll.asm diff --git a/spiral.asm b/doorrando/spiral.asm similarity index 100% rename from spiral.asm rename to doorrando/spiral.asm diff --git a/dr_lobby.asm b/dr_lobby.asm deleted file mode 100644 index 5f5b55c..0000000 --- a/dr_lobby.asm +++ /dev/null @@ -1,16 +0,0 @@ -CheckDarkWorldSpawn: - STA $A0 : STA $048E ; what we wrote over - LDA.l OldManDarkWorld : CMP $A0 : BNE + - SEP #$30 - LDA InvertedMode : BNE ++ - LDA.b #$40 : STA !DARK_WORLD : BRA +++ - ++ LDA.b #$00 : STA !DARK_WORLD - +++ REP #$30 - + LDA.l DRFlags : AND #$0200 : BEQ + ; skip if the flag isn't set - LDA.l $7EF357 : AND #$00FF : BNE + ; moon pearl? - LDA.l LinksHouseDarkWorld : CMP $A0 : BEQ ++ - LDA.l SanctuaryDarkWorld : CMP $A0 : BEQ ++ - LDA.l OldManDarkWorld : CMP $A0 : BNE + - ++ SEP #$30 : LDA #$17 : STA $5D - INC $02E0 : LDA.b #$40 : STA !DARK_WORLD : REP #$30 -+ RTL 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/enemizer/blindboss.asm b/enemizer/blindboss.asm index fee7b37..7e860b5 100644 --- a/enemizer/blindboss.asm +++ b/enemizer/blindboss.asm @@ -8,6 +8,6 @@ check_blind_boss_room: CMP #172 : BNE + ; Is is Thieve Town Boss Room LDA $09DE81 : BEQ + ; Blind maiden does not need rescuing - LDA $7EF3CC : JML Check_for_Blind_Fight + LDA FollowerIndicator : JML Check_for_Blind_Fight + JML Initialize_Blind_Fight diff --git a/entrances.asm b/entrances.asm index d90304c..5f67e2c 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 SwapAgaGanonsTower : 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 SwapAgaGanonsTower : 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 : AND.w #$00FF @@ -123,7 +123,7 @@ AllowStartFromSingleEntranceCave: STZ $0699 ;zero out door overlays in case starting overworld door is not set SEP #$20 ; set 8-bit accumulator - LDA $7EF3C8 : TAX + LDA StartingEntrance : TAX LDA.l StartingAreaOverworldDoor, X : STA.l $7F5099 ;Load overworld door REP #$20 ; reset 16-bit accumulator @@ -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 74fe90a..b9814d9 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: @@ -22,9 +22,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 @@ -64,54 +65,83 @@ OnUncleItemGet: LDA UncleItem_Player : STA !MULTIWORLD_ITEM_PLAYER_ID 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: REP #$10 ; set 16 bit index registers JSL.l EnableForceBlank ; what we wrote over - REP #$20 : LDA.l $30F010 : STA.l $7EF33E : SEP #$20 - LDA MultiClientFlags : STA.l $7EF33D + REP #$20 : LDA.l $30F010 : STA.l MultiClientFlagsWRAM+1 : SEP #$20 + LDA MultiClientFlagsROM : STA.l MultiClientFlagsWRAM 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 @@ -127,51 +157,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 - - - 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 - + - - LDX.w #$007F : - ; copy over starting overworld event data - LDA StartingOverworldEvents, X : STA $7EF280, X - DEX - BPL - - - ; below (indented) is obsoleted by StartingOverworldEvents table copy above - LDA.l PreopenPyramid : BEQ + - LDA.b #$20 : STA $7EF2DB ; pyramid hole already open - + - - LDA.l SwapAgaGanonsTower : BNE + - 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 @@ -250,8 +237,8 @@ PreItemGet: RTL ;-------------------------------------------------------------------------------- PostItemGet: - JML.l MaybeWriteSRAMTrace +RTL ;-------------------------------------------------------------------------------- PostItemAnimation: LDA.b #$00 : STA !ITEM_BUSY ; mark item as finished diff --git a/failure.asm b/failure.asm new file mode 100644 index 0000000..863c557 --- /dev/null +++ b/failure.asm @@ -0,0 +1,565 @@ +pushtable + +table "bsodencode.txt" + +; Uncomment this to force a crash to test message +;pushpc : org $008132 : db 0 : pullpc + +;=================================================================================================== + +DontUseZSNES: + SEP #$35 ; sets carry and I flag too + + LDA.b #$00 + STA.l $4200 ; disable NMI and IRQ + STA.l $420C ; disable HDMA + + ROR ; A = 0x80 from carry + STA.l $2100 + STA.l $2115 + + ; Empty VRAM + LDA.b #AllZeros>>16 : STA.l $4304 + + REP #$20 + + LDA.w #AllZeros + STA.l $4302 + + LDA.w #$1809 + STA.l $4300 + + LDA.w #$0000 + STA.l $4305 + + LDA.w #$0001 + STA.l $420B + + JSR ConfigurePPUForFailureReport + JSR ConfigureBSODVWF + + STZ.b VWFR + LDA.w #ZSNESMessage + JSR DrawVWFMessage + + LDA.w #$0F0F + STA.w $2100 + +-- BRA -- + +ZSNESMessage: + db "It has been detected that you are attempting to load", $80 + db "this ROM on a low-quality emulator.", $80 + db "The randomizer is designed to work on real hardware,", $80 + db "which this application cannot emulate properly;", $80 + db "as such, this ROM file refuses to boot.", $80 + db "Please upgrade to a more accurate emulator such as", $80 + db "SNES9X or BSNES/higan.", $80 + db $FF + +;=================================================================================================== + +AllZeros: + db $00 + +UselessStackTooFar: + dw $137 + +Crashed: +;=================================================================================================== +;=================================================================================================== +;=================================================================================================== +; !!!DO NOT TRY TO OPTIMIZE THIS CODE!!! +; IT IS INTENTIONALLY AVOIDING CHANGING CERTAIN REGISTERS, ESPECIALLY THE STACK. +;=================================================================================================== +;=================================================================================================== +;=================================================================================================== + SEP #$35 ; sets carry and I flag too + + LDA.b #$00 + STA.l $4200 ; disable NMI and IRQ + STA.l $420C ; disable HDMA + + ROR ; A = 0x80 from carry + STA.l $2100 + STA.l $2115 + + ; Empty VRAM + LDA.b #AllZeros>>16 : STA.l $4304 + + REP #$38 + + LDA.w #AllZeros + STA.l $4302 + + LDA.w #$1809 + STA.l $4300 + + LDA.w #$0000 + STA.l $4305 + + LDA.w #$0001 + STA.l $420B + +;=================================================================================================== + + ; Create report + LDA.w #$2100 + TCD + +;--------------------------------------------------------------------------------------------------- + + ; Report status + + ; stack pointer + LDA.w #$0C38>>1 + STA.b $2116 + + TSC + XBA + AND.w #$00FF + ORA.w #$0100 + STA.b $2118 + + TSC + AND.w #$00FF + ORA.w #$0100 + STA.l $2118 + + ; game module + LDA.w #$0C78>>1 + STA.b $2116 + + LDA.l $10 + AND.w #$00FF + ORA.w #$0100 + STA.b $2118 + + LDA.l $11 + AND.w #$00FF + ORA.w #$0100 + STA.b $2118 + +;--------------------------------------------------------------------------------------------------- + + ; Report stack + TSC + INC + STA.l $7F0100 + + LDA.l UselessStackTooFar + + ; For now, we can report as much of the stack as possible + ; If desired later on, uncomment the code below to keep the stack limited to + ; where it was last doing stuff +; TSC +; +; ; keep stack in a useful range +; CMP.w #$01FF ; this means we pulled too much and the stack is useless +; BCC .stack_fine +; +; JMP .skip_stack +; +;.stack_fine +; CMP.l UselessStackTooFar +; BCS .stack_adjusted +; +; ; this means we went too far in, and the stack contains little useful info +; LDA.l UselessStackTooFar +; +;.stack_adjusted + STA.l $7F0000 + + LDX.w #$01FF + + LDA.w #$0C04>>1 + +.next_row + STA.l $7F0004 + STA.b $2116 + + LDY.w #20 + + TXA + +.next_char + ; set carry to see if we should color this value as being in the stack + CMP.l $7F0100 + + LDA.l $000000,X + AND.w #$00FF + ORA.w #$0500 + BCS .in_stack + + AND.w #$01FF + +.in_stack + STA.b $2118 + + DEX + TXA + CMP.l $7F0000 + BEQ .skip_stack + + DEY + BNE .next_char + +.done_row + CLC + + LDA.l $7F0004 + ADC.w #32 + BRA .next_row + +;=================================================================================================== +;=================================================================================================== +;=================================================================================================== + ; once the stack is reported, we can start doing stuff that mucks with it +.skip_stack + LDA.w #$0000 + TCD + +; TSC +; STA.b $80 ; remember stack for later messages + + LDA.w #$01FF + TCS + + JSR ConfigurePPUForFailureReport + JSR ConfigureBSODVWF + JSR LoadBSODHexFont + + STZ.b VWFR + + LDA.w #BSODMessage + JSR DrawVWFMessage + + LDA.w #$0F0F + STA.w $2100 + +-- BRA -- + +; LDA.w #$0000 +; TCD +; +; TSC + + +BSODMessage: + db "A fatal error has occurred and resulted in an", $80 + db "unrecoverable crash. ?", $80 + db "If you believe this was the result of a bug caused by", $80 + db "the randomizer itself, please screenshot this message", $80 + db "and share it in the #bug-reports channel of the official", $80 + db "ALTTPR discord along with a detailed description of", $80 + db "what you were doing, including video if available.", $80 + db "Please also make a savestate now and include that in", $80 + db "your report.", $80 + db $FF + +;=================================================================================================== + +DrawVWFMessage: + STA.b $06 + +.next + LDA.b ($06) + INC.b $06 + AND.w #$00FF + CMP.w #$0080 + BEQ .done_row + + CMP.w #$00FF + BEQ .done_message + + JSR DrawFailureVWFChar + + BRA .next + +.done_message + RTS + +.done_row + LDA.b VWFR + ASL + TAX + LDA.w .row_offset,X + STA.w $2116 + + INC.b VWFR + + LDA.w #$1800 + STA.w $4300 + + LDA.w #20*16 + STA.w $4305 + + LDA.w #$1000 + STA.w $4302 + + SEP #$20 + + STZ.w $2115 + STZ.w $4304 + + LDA.b #$01 + STA.w $420B + + REP #$20 + + JSR ResetVFW + + BRA .next + + +.row_offset + dw $10F8 + dw $11E8 + dw $12D8 + dw $13C8 + dw $14B8 + dw $15A8 + dw $1698 + dw $1788 + dw $1878 + dw $1968 + dw $1A58 + + + +;=================================================================================================== + +VWFL = $40 +VWFX = $44 +VWFS = $46 +VWFP = $48 +VWFR = $4A + +;=================================================================================================== + +DrawFailureVWFChar: + AND.w #$00FF + STA.b VWFL + + TAX + + ASL + ASL + ASL + ADC.w #BSODFontGFX + STA.b $08 + + LDA.b VWFP + AND.w #$FFF8 + STA.w VWFX + + LDA.b VWFP + AND.w #$0007 + STA.w VWFS + + ; carry set on purpose to add letter spacing + SEC + LDA.w BSODCharWidths,X + AND.w #$00FF + ADC.b VWFP + STA.b VWFP + + LDY.w #$0000 + +.next_row + LDA.b ($08),Y + AND.w #$00FF + XBA + LDX.w VWFS + BEQ ++ + +-- LSR + DEX + BNE -- + +++ LDX.w VWFX + SEP #$20 + ORA.w $1008,X + STA.w $1008,X + + XBA + ORA.w $1000,X + STA.w $1000,X + + REP #$20 + INX + STX.w VWFX + + INY + CPY.w #$0008 + BCC .next_row + + RTS + +;=================================================================================================== + +LoadBSODHexFont: + REP #$20 + + LDA.w #BSODHex + STA.w $4302 + + LDA.w #$1801 + STA.w $4300 + + LDA.w #$1000 + STA.w $4305 + + LDA.w #$2800 + STA.w $2116 + + SEP #$20 + LDA.b #BSODHex>>16 + STA.w $4304 + + LDA.b #$01 + STA.w $420B + + REP #$30 + + RTS + +;=================================================================================================== + +ConfigureBSODVWF: + REP #$30 + + LDA.w #$2100 + TCD + + SEP #$30 + + LDX.b #$FF + LDY.b #$7F + + STZ.b $2121 + STZ.b $2122 : STZ.b $2122 + + STX.b $2122 : STY.b $2122 + + LDA.b #$05 + STA.b $2121 + + LDA.b #$11 : STA.b $2122 : STY.b $2122 + + LDA.b #$21 : STA.b $2121 + STX.b $2122 : STY.b $2122 + + LDA.b #$25 : STA.b $2121 + LDA.b #$11 : STA.b $2122 : STY.b $2122 + + REP #$30 + + PEA.w $0001 + + LDA.w #15 + STA.w $28 + + LDA.w #$0042>>1 + BRA .start + +.next_row + PHA + + LDA.w $20 + CLC + LDA.w $20 + ADC.w #32 + +.start + STA.w $20 + STA.b $2116 + + PLA + + LDY.w #30 + +.next_char + STA.b $2118 + INC + DEY + BNE .next_char + + DEC.w $28 + BNE .next_row + + LDA.w #$0000 + TCD + +ResetVFW: + REP #$30 + + LDX.w #$0400 + +-- STZ.w $1000,X + DEX + DEX + BPL -- + + STZ.b VWFL + STZ.b VWFX + STZ.b VWFS + STZ.b VWFP + + RTS + +;=================================================================================================== + +ConfigurePPUForFailureReport: + SEP #$30 + + PHK + PLB + + STZ.w $2105 ; BG mode 0 + STZ.w $2106 ; no mosaic + STZ.w $2107 ; BG1 tilemap to $0000 + STZ.w $212D + + STZ.w $210D : STZ.w $210D + STZ.w $210E : STZ.w $210E + STZ.w $210F : STZ.w $210F + STZ.w $2110 : STZ.w $2110 + + + STZ.w $2123 + STZ.w $2131 + STZ.w $2133 + + LDA.b #$04 + STA.w $2108 ; BG1 tilemap to $0800 + + LDA.b #$21 + STA.w $210B + + LDA.b #$03 + STA.w $212C + + RTS + +;=================================================================================================== + +BSODHex: +incbin "bsodhex.2bpp" + +BSODFontGFX: +incbin "bsodfont.1bpp" + +BSODCharWidths: + ; [space] + db 3 + + ; A B C D E F G H I J K L M N O P Q R S T U V W X Y Z + db 4, 4, 3, 4, 3, 3, 4, 3, 1, 4, 3, 3, 5, 4, 4, 4, 5, 4, 4, 3, 4, 5, 5, 3, 3, 3 + + ; 0 1 2 3 4 5 6 7 8 9 . # ? - / , ' + db 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 5, 8, 3, 3, 2, 1 + +;=================================================================================================== + +pulltable 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 986f3f4..61f0e38 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 7dfe0ca..69dd846 100644 --- a/floodgatesoftlock.asm +++ b/floodgatesoftlock.asm @@ -5,22 +5,25 @@ 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 .done - LDA $279004 : BEQ .check_room_53 ; Only do the check for room 55 if on door rando - LDA $7EF06F : AND.b #$04 : BEQ .drain_room_55 ; Check if key in room 55 has been collected. - LDA $7EF356 : AND.b #$01 : BNE .check_room_53 ; Check for flippers. This can otherwise softlock doors if flooded without flippers and no way to reset. - .drain_room_55 - LDA $7EF06E : AND.b #$7F : STA $7EF06E ; clear water room 55 - outer room you shouldn't be able to softlock except in major glitches - .check_room_53 - LDA $7EF06B : AND.b #$04 : BNE .done ; Check if key in room 53 has been collected. + LDA.l Bugfix_SwampWaterLevel : BEQ .done + LDA $279004 : BEQ .check_room_35; Only do the check for room 37 if on door rando + LDA.l SwampDrain1HasItem : BEQ .flipper_check + LDA $7F666F : AND.b #$80 : BEQ .drain_room_37 ; Check if key in room 37 has been collected. + .flipper_check + LDA FlippersEquipment : AND.b #$01 : BNE .check_room_35 ; Check for flippers. This can otherwise softlock doors if flooded without flippers and no way to reset. + .drain_room_37 + LDA RoomDataWRAM[$37].low : AND.b #$7F : STA RoomDataWRAM[$37].low ; clear water room 37 - outer room you shouldn't be able to softlock except in major glitches + .check_room_35 + LDA.l SwampDrain2HasItem : BEQ .done + LDA $7F666B : AND.b #$80 : BNE .done ; Check if key in room 35 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 35 - inner room with the easy key flood softlock .done RTL ;================================================================================ diff --git a/flute.asm b/flute.asm index 354b1d2..7128602 100644 --- a/flute.asm +++ b/flute.asm @@ -24,17 +24,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 @@ -65,7 +65,7 @@ FreeDuckCheck: LDA.l InvertedMode : BEQ .done .skipInvertedCheck - 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 92cc458..a97da8d 100644 --- a/framehook.asm +++ b/framehook.asm @@ -1,104 +1,75 @@ ;================================================================================ ; 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 + +!NMI_MW = "$7F5047" ;-------------------------------------------------------------------------------- NMIHookAction: PHA : PHX : PHY : PHD ; thing we wrote over, push stuff - LDA !NMI_AUX : BEQ ++ + LDA !NMI_MW : BEQ ++ PHP SEP #$30 - LDA #$00 : STA !NMI_AUX + LDA #$00 : STA !NMI_MW ; Multiworld text - LDA !NMI_AUX+1 : BEQ + - LDA #$00 : STA !NMI_AUX+1 + LDA !NMI_MW+1 : BEQ + + LDA #$00 : STA !NMI_MW+1 JSL.l WriteText + - - ; Shops - LDA !NMI_AUX+2 : BEQ + - LDA #$00 : STA !NMI_AUX+2 - JSL.l Shopkeeper_UploadVRAMTilesLong - + - PLP ++ - 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 + ++ JML.l NMIHookReturn ;-------------------------------------------------------------------------------- !NMI_AUX = "$7F5044" + PostNMIHookAction: - LDA !NMI_AUX : BEQ + - LDA $00 : PHA ; preserve DP ram - LDA $01 : PHA - LDA $02 : PHA - - LDA !NMI_AUX+2 : STA $02 ; set up jump pointer - LDA !NMI_AUX+1 : STA $01 - LDA !NMI_AUX+0 : STA $00 - - PHK : PER .return-1 ; push stack for RTL return - JMP [$0000] - - .return - LDA.b #$00 : STA !NMI_AUX ; zero bank byte of NMI hook pointer - - PLA : STA $02 - PLA : STA $01 - PLA : STA $00 - + - - LDA $13 : STA $2100 ; thing we wrote over, turn screen back on -JML.l PostNMIHookReturn -;-------------------------------------------------------------------------------- \ No newline at end of file + LDA.l !NMI_AUX+2 : BEQ .return + + PHK + PEA .return-1 + + PHA + + LDA.b #$00 : STA.l !NMI_AUX+2 + + REP #$20 + LDA.l !NMI_AUX+0 : DEC : PHA + SEP #$20 + + RTL + +.return + LDA.b $13 : STA.w $2100 + + JML.l PostNMIHookReturn + + +;-------------------------------------------------------------------------------- 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 0315582..a81d63f 100644 --- a/halfmagicbat.asm +++ b/halfmagicbat.asm @@ -11,6 +11,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 3aa9e79..6359c5e 100644 --- a/heartpieces.asm +++ b/heartpieces.asm @@ -18,7 +18,7 @@ HeartPieceGet: CPY.b #$26 : BNE .notHeart ; don't add a 1/4 heart if it's not a heart piece LDA !MULTIWORLD_ITEM_PLAYER_ID : BNE .notHeart - 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 @@ -136,7 +136,7 @@ HeartUpgradeSpawnDecision: ; this should return #$00 to make the hp spawn RTL .normal_behavior - LDA $7EF280, X + LDA OverworldEventDataWRAM, X RTL ;-------------------------------------------------------------------------------- SaveHeartCollectedStatus: @@ -146,7 +146,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" @@ -210,7 +210,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 7199692..7000607 100755 --- a/hooks.asm +++ b/hooks.asm @@ -45,11 +45,33 @@ JML.l CheckZSNES ReturnCheckZSNES: ;-------------------------------------------------------------------------------- +;================================================================================ +; Ok so basically, in rare cases, major glitches may try to read far into the +; A bus until they reach a value of $FFFF +; For maximum security of vanilla behavior, I am reserving this space +; that could otherwise be considered free ROM. +;-------------------------------------------------------------------------------- +org $0089C2 +dw $FFFF, $FFFF, $FFFF, $FFFF +dw $FFFF, $FFFF, $FFFF, $FFFF +dw $FFFF, $FFFF, $FFFF, $FFFF + +;================================================================================ +; BSOD for BRK and COP opcodes +;-------------------------------------------------------------------------------- +org $00FFB7 +SoftwareInterrupt: +JML Crashed + +org $00FFE4 : dw SoftwareInterrupt +org $00FFE6 : dw SoftwareInterrupt +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 ;-------------------------------------------------------------------------------- ;================================================================================ @@ -221,6 +243,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 @@ -315,9 +339,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 @@ -545,17 +568,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 ;-------------------------------------------------------------------------------- @@ -723,7 +742,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) @@ -1725,7 +1744,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 @@ -2166,7 +2185,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 @@ -2470,15 +2489,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 @@ -2548,7 +2565,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: ;================================================================================ @@ -2559,7 +2576,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 ;================================================================================ ;================================================================================ @@ -2835,6 +2852,14 @@ org $01C536 : JSL FixJingleGlitch org $01C592 : JSL FixJingleGlitch org $01C65F : JSL FixJingleGlitch +;================================================================================ +; Hooks for when submenu opens +;-------------------------------------------------------------------------------- +org $028818 + JSL OnMenuLoad +org $02A463 + JSL OnMenuLoad + ;================================================================================ ; Terrorpin AI fix ;-------------------------------------------------------------------------------- @@ -2843,8 +2868,6 @@ JSL FixTerrorpin ; 4 bytes NOP ; 1 byte ;-------------------------------------------------------------------------------- - -;================================================================================ ; Text Renderer ;-------------------------------------------------------------------------------- if !FEATURE_NEW_TEXT 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 5aab0e2..6a9beba 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,14 +187,13 @@ 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 @@ -209,51 +202,51 @@ AddInventory: + 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 : + LDA !MULTIWORLD_ITEM_PLAYER_ID : BEQ + BRL .dungeonCounts @@ -271,7 +264,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 @@ -283,7 +275,7 @@ AddInventory: + CPY.b #$3B : BNE + : JMP .dungeonCounts : + ; Silver Arrow Bow - Skip Shop/Fairy Check for Silver Arrow Bow - LDA $1B : BEQ ++ ; skip shop check if outdoors + LDA $1B : BNE + : JMP .dungeonCounts : + ; skip shop check if outdoors LDA $02E9 : CMP.b #$01 : BEQ ++ ; skip shop check for chests PHP : REP #$20 ; set 16-bit accumulator LDA $048E @@ -292,9 +284,12 @@ AddInventory: CMP.w #272 : BNE + : JMP .shop : + ; red shield shop CMP.w #284 : BNE + : JMP .shop : + ; bomb shop CMP.w #265 : BNE + : JMP .shop : + ; potion shop - commented this out because it's easier to just block potion refills because this one interferes with the powder item being counted - CMP.w #287 : BNE + : JMP .shop : + ; kakariko shop - CMP.w #255 : BNE + : JMP .shop : + ; light world death mountain shop - CMP.w #276 : BNE + : JMP .shop : + ; waterfall fairy + CMP.w #287 : BNE + : LDA.b $A9 : CMP.w #$0201 : BNE + ; kakariko shop + JMP .shop : + LDA.b $A0 + CMP.w #255 : BNE + : LDA.b $A9 : BNE + ; light world death mountain shop + JMP .shop : + LDA.b $A0 + CMP.w #276 : BNE + : LDA.b $A9 : CMP.w #$0200 : BNE + ; waterfall fairy + JMP .shop : + LDA.b $A0 CMP.w #277 : BNE + : JMP .shop : + ; upgrade fairy (shop) CMP.w #278 : BNE + : JMP .shop : + ; pyramid fairy PLP : BRA ++ @@ -311,14 +306,6 @@ AddInventory: + 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 @@ -329,35 +316,34 @@ AddInventory: CMP.l BallNChainDungeon : BNE + CPY.b #$32 : BNE + JMP .done - + LSR : TAX : LDA $7EF4BF, X : INC : STA $7EF4BF, X + + LSR : TAX : LDA DungeonLocationsChecked, X : INC : STA DungeonLocationsChecked, X CPX.b #$0D : BNE + - LDA $7EF366 : AND #$04 : BNE ++ + LDA BigKeyField : AND #$04 : BNE ++ JSR .incrementGTowerPreBigKey ++ + - ; == END INDOOR-ONLY SECTION .fullItemCounts - LDA !MULTIWORLD_ITEM_PLAYER_ID : BNE + - CPY.b #$3B : BNE + ; Skip Total Counts for Repeat Silver Arrows - LDA $7EF42A : BIT #$20 : BEQ + : BRA .itemCounts - + - LDA !MULTIWORLD_RECEIVING_ITEM : CMP #$01 : BEQ ++ - LDA $7EF355 : BNE + ; Check for Boots + LDA BootsEquipment : BNE + ; Check for Boots REP #$20 - LDA $7EF432 : INC : STA $7EF432 ; Increment Pre Boots Counter + LDA PreBootsLocations : INC : STA PreBootsLocations ; Increment Pre Boots Counter SEP #$20 + - LDA $7EF353 : BNE + ; Check for Mirror + LDA MirrorEquipment : BNE + ; Check for Mirror REP #$20 - LDA $7EF468 : INC : STA $7EF468 ; Increment Pre Mirror Counter + LDA PreMirrorLocations : INC : STA PreMirrorLocations ; Increment Pre Mirror Counter + SEP #$20 + + + LDA FluteEquipment : BNE + ; Check for Mirror + REP #$20 + LDA PreFluteLocations : INC : STA PreFluteLocations ; Increment Pre Mirror Counter SEP #$20 + REP #$20 - LDA $7EF423 : INC : STA $7EF423 ; Increment Item Total + LDA TotalItemCounter : INC : STA TotalItemCounter ; Increment Item Total SEP #$20 ++ @@ -368,25 +354,32 @@ AddInventory: + 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 @@ -426,14 +419,17 @@ AddInventory: + CPY.b #$21 : BNE + ; Bug Net JSR .incrementY JMP .done - + CPY.b #$22 : !BLT + ; Items $22 - $23 - CPY.b #$24 : !BGE + - JSR .incrementMail - JMP .done + + CPY.b #$22 : BNE + ; Blue Mail + LDX #$01 + JSR .incrementMail + + CPY.b #$23 : BNE + ; Red Mail + LDX #$02 + JSR .incrementMail + CPY.b #$24 : BNE + ; Small Key JSR .incrementKey JMP .done + CPY.b #$25 : BNE + ; Compass + JSL MaybeFlagCompassTotalPickup JSR .incrementCompass JMP .done + CPY.b #$26 : BNE + ; Liar Heart (Container) @@ -445,7 +441,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 @@ -464,7 +460,7 @@ AddInventory: + CPY.b #$37 : !BLT + ; Items $37 - $39 - Pendants CPY.b #$3A : !BGE + JSR .incrementPendant - JSR .setDungeonCompletion + JSR .setDungeonCompletion JMP .done + CPY.b #$3A : !BLT + ; Items $3A - $3B - Bow & Silver Arrows CPY.b #$3C : !BGE + @@ -484,6 +480,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) @@ -494,7 +491,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 @@ -503,22 +500,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 @@ -534,6 +543,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 @@ -551,120 +561,100 @@ 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 $7EF46A : !ADD #$40 : STA $7EF46A + + LDA HighestMail + INC : STA $04 : CPX $04 : !BLT + ; don't increment unless we're getting a better mail + TXA : STA HighestMail + + RTS .incrementKeyLong @@ -672,36 +662,30 @@ RTS RTL .incrementKey - PHA : PHX - LDA $7EF46A : INC : AND #$3F : TAX - LDA $7EF46A : AND #$C0 : STA $7EF46A - TXA : ORA $7EF46A : STA $7EF46A - 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 @@ -709,58 +693,41 @@ 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 $7EF46B : STA $7EF46B - BRA + - ++ - !SUB #$08 - JSR .valueShift - BIT.b #$C0 : BEQ +++ : LDA.b #$C0 : +++ ; Make Hyrule Castle / Sewers Count for Both - ORA $7EF46C : STA $7EF46C + LDX $040C : BMI + + REP #$20 ; 16 bit + LDA.l DungeonMask, X + ORA DungeonsCompleted : STA DungeonsCompleted + SEP #$20 ; 8 bit + 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 @@ -772,9 +739,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 @@ -789,13 +756,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 @@ -849,8 +816,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 ;-------------------------------------------------------------------------------- @@ -877,10 +844,10 @@ RTL ;-------------------------------------------------------------------------------- LoadKeys: LDA.l GenericKeys : BEQ + - LDA $7EF38B + LDA CurrentGenericKeys RTL + - LDA $7EF37C, X + LDA DungeonKeys, X RTL ;-------------------------------------------------------------------------------- @@ -890,10 +857,10 @@ RTL SaveKeys: PHA LDA.l GenericKeys : BEQ + - PLA : STA $7EF38B + PLA : STA CurrentGenericKeys RTL + - PLA : STA $7EF37C, X + PLA : STA DungeonKeys, X RTL ;-------------------------------------------------------------------------------- @@ -907,10 +874,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 ;-------------------------------------------------------------------------------- @@ -979,10 +946,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 @@ -1080,12 +1047,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 ;-------------------------------------------------------------------------------- @@ -1093,7 +1060,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 @@ -1111,7 +1078,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 64fadbe..e7b4019 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 SwapAgaGanonsTower : 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: PHX : LDA $8A : AND.w #$00FF : TAX : LDA.l OWTileMapAlt, X : PLX : AND.w #$0001 : 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 c5d8ef3..ebecf88 100644 --- a/invertedmaps.asm +++ b/invertedmaps.asm @@ -261,7 +261,7 @@ LDA #$0150 : STA $292A : STA $29A8 : STA $2A26 LDA #$014E : STA $299E : STA $29A0 : STA $29A2 : STA $29A4 ; remove ladder -LDA $7EF287 : CMP.w #$0010 : BNE .ladder +LDA OverworldEventDataWRAM+$07 : CMP.w #$0010 : BNE .ladder RTS .ladder LDA #$0152 : STA $2A20 : STA $2A22 @@ -424,7 +424,7 @@ LDA #$0466 : STA $21A0 LDA #$0101 : STA $2252 ; add sign for Goal at HC ; CHECK IF AGAHNIM 2 IS DEAD AND WE HAVE ALREADY LANDED -LDA $7EF2DB : AND #$0020 : BEQ .agahnim2Alive +LDA OverworldEventDataWRAM+$5B : AND #$0020 : BEQ .agahnim2Alive LDA #$0E3A : STA $24BC LDA #$0E3B : STA $24BE LDA #$0E3E : STA $253C @@ -1167,7 +1167,7 @@ LDA #$0108 : STA $3C38 + LDA.l OWTileMapAlt+$5B : AND #$0001 : BEQ + ;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/keydrop/dynamic_si_vram.asm b/keydrop/dynamic_si_vram.asm new file mode 100644 index 0000000..56edbce --- /dev/null +++ b/keydrop/dynamic_si_vram.asm @@ -0,0 +1,180 @@ +; where we shove the decompressed graphics to send to WRAM +DynamicDropGFX = $7EF500 + +; this will just count from 0 to 4 to determine which slot we're using +; we're expecting 5 items max per room, and order is irrelevant +; we just need to keep track of where they go +DynamicDropGFXIndex = $7E1E70 + +; this will keep track of the above for each item +SprItemGFX = $7E0780 + +; this is the item requested and a flag +DynamicDropRequest = $7E1E71 +DynamicDropQueue = $7E1E72 + +; Come in with +; A = item receipt ID +; X = slot +RequestStandingItemVRAMSlot: + STA.w DynamicDropQueue + LDA.b #$01 + STA.w DynamicDropRequest + + LDA.w DynamicDropGFXIndex + INC + CMP.b #$05 : BCC .fine + + LDA.b #$00 + +.fine + STA.w DynamicDropGFXIndex + STA.w SprItemGFX,X + + + ; decompress graphics + PHX + LDX.w DynamicDropQueue + + REP #$20 + LDA.w #DynamicDropGFX-$7E9000 + STA.l !TILE_UPLOAD_OFFSET_OVERRIDE + SEP #$20 + + LDA.w DynamicDropQueue + JSL.l GetSpriteID + JSL.l GetAnimatedSpriteTile_variable + + SEP #$30 + PLX + + RTL + + +;=================================================================================================== + +TransferPotGFX: + SEP #$10 + REP #$20 + LDX.w DynamicDropRequest + BEQ .no + + STZ.w DynamicDropRequest + + LDA.w DynamicDropGFXIndex + ASL + TAX + LDA.l FreeUWGraphics,X + STA.w $2116 + + ; calculate bottom row now + CLC : ADC.w #$0200>>1 : PHA + + LDX.b #$7E : STX.w $4314 + LDA.w #DynamicDropGFX : STA.w $4302 + + LDX.b #$80 : STX.w $2115 + LDA.w #$1801 : STA.w $4300 + + LDA.w #$0040 : STA.w $4305 + LDY.b #$01 + + STY.w $420B + STA.w $4305 + + PLA + STA.w $2116 + STY.w $420B + +.no + RTL + + +FreeUWGraphics: + dw $8800>>1 + dw $8840>>1 + dw $8980>>1 + dw $9CA0>>1 + dw $9DC0>>1 + +; dw $8800>>1 +; dw $8840>>1 +; dw $8980>>1 +; dw $9960>>1 # Arghuss Splash apparently +; dw $9C00>>1 +; dw $9CA0>>1 +; dw $9DC0>>1 + +;=================================================================================================== + +DrawPotItem: + JSL.l IsNarrowSprite : BCS .narrow + + .full + LDA.b #$01 : STA $06 + LDA #$0C : JSL.l OAM_AllocateFromRegionC + LDA #$02 : PHA + REP #$20 + LDA.w #DynamicOAMTile_full + BRA .draw + + .narrow + LDA.b #$02 : STA $06 + LDA #$10 : JSL.l OAM_AllocateFromRegionC + LDA #$03 : PHA + REP #$20 + LDA.w #DynamicOAMTile_thin + .draw + PHB : PHK : PLB + + STA.b $08 + LDA.w SprItemGFX,X + AND.w #$00FF + ASL : ASL : ASL : ASL + ADC.b $08 + STA.b $08 + SEP #$20 + STZ.b $07 + + LDA.b #$00 : STA.l !SKIP_EOR + JSL Sprite_DrawMultiple_quantity_preset + + LDA.b $90 : CLC : ADC.b #$08 : STA.b $90 + INC.b $92 + INC.b $92 + + PLB + PLA + RTL + +DynamicOAMTile_thin: + dw 0, 0 : db $40, $00, $20, $00 + dw 0, 8 : db $50, $00, $20, $00 + + dw 0, 0 : db $42, $00, $20, $00 + dw 0, 8 : db $52, $00, $20, $00 + + dw 0, 0 : db $4C, $00, $20, $00 + dw 0, 8 : db $5C, $00, $20, $00 + + dw 0, 0 : db $E5, $00, $20, $00 + dw 0, 8 : db $F5, $00, $20, $00 + + dw 0, 0 : db $EE, $00, $20, $00 + dw 0, 8 : db $FE, $00, $20, $00 + +DynamicOAMTile_full: + dw -4, -1 : db $40, $00, $20, $02 + dd 0, 0 + + dw -4, -1 : db $42, $00, $20, $02 + dd 0, 0 + + dw -4, -1 : db $4C, $00, $20, $02 + dd 0, 0 + + dw -4, -1 : db $E5, $00, $20, $02 + dd 0, 0 + + dw -4, -1 : db $EE, $00, $20, $02 + dd 0, 0 \ No newline at end of file diff --git a/keydrop/standing_items.asm b/keydrop/standing_items.asm new file mode 100644 index 0000000..989554b --- /dev/null +++ b/keydrop/standing_items.asm @@ -0,0 +1,624 @@ +; hooks +org $01E6B0 + JSL RevealPotItem + RTS + +org $09C2BB + JSL ClearSpriteData + +org $09C327 + JSL LoadSpriteData + +org $06F976 + JSL RevealSpriteDrop : NOP + +org $06E3C4 + JSL RevealSpriteDrop2 : NOP + +org $06926e ; <- 3126e - sprite_prep.asm : 2664 (LDA $0B9B : STA $0CBA, X) + JSL SpriteKeyPrep : NOP #2 + +org $06d049 ; <- 35049 sprite_absorbable : 31-32 (JSL Sprite_DrawRippleIfInWater : JSR Sprite_DrawAbsorbable) + JSL SpriteKeyDrawGFX : BRA + : NOP : + + +org $06d03d + JSL ShouldSpawnItem : NOP #2 + +org $06D19F + JSL MarkSRAMForItem : NOP #2 + +org $06d180 + JSL BigKeyGet : BCS $07 : NOP #5 + +org $06d18d ; <- 3518D - sprite_absorbable.asm : 274 (LDA $7EF36F : INC A : STA $7EF36F) + JSL KeyGet + +org $06f9f3 ; bank06.asm : 6732 (JSL Sprite_LoadProperties) + JSL LoadProperties_PreserveCertainProps + +org $008BAA ; NMI hook + JSL TransferPotGFX + +org $06828A + JSL CheckSprite_Spawn + +org $07B169 + JSL PreventPotSpawn : NOP + +org $07B17D + JSL PreventPotSpawn2 + +org $068275 + JSL SubstitionFlow + +org $00A9DC +dw $1928, $1938, $5928, $5938 ; change weird ugly black diagonal pot to blue-ish pot + +org $018650 +dw $B395 ; change tile type to normal pot + +org $01B3D5 +JSL CheckIfPotIsSpecial + + +; refs to other functions +org $0681F4 +Sprite_SpawnSecret_pool_ID: +org $068283 +Sprite_SpawnSecret_NotRandomBush: +org $06828A +Sprite_SpawnSecret_SpriteSpawnDynamically: +org $06d23a +Sprite_DrawAbsorbable: +org $1eff81 +Sprite_DrawRippleIfInWater: +org $0db818 +Sprite_LoadProperties: +org $06D038 +KeyRoomFlagMasks: + +; defines +; Ram usage +SpawnedItemID = $7E0720 ; 0x02 +SpawnedItemIndex = $7E0722 ; 0x02 +SpawnedItemIsMultiWorld = $7E0724 ; 0x02 +SpawnedItemFlag = $7E0726 ; 0x02 - one for pot, 2 for sprite drop +; (flag used as a bitmask in conjunction with StandingItemCounterMask) +SpawnedItemMWPlayer = $7E0728 ; 0x02 +; clear all of them in a loop during room load +SprDropsItem = $7E0730 ; 0x16 +SprItemReceipt = $7E0740 ; 0x16 +SprItemIndex = $7E0750 +SprItemMWPlayer = $7E0760 ; 0x16 +SprItemFlags = $7E0770 ; 0x16 (used for both pots and drops) (combine with SprDropsItem?) + +; todo: move sprites +;org $09D62E +;UWSpritesPointers ; 0x250 bytes for 0x128 rooms' 16-bit pointers + +;org $09D87E +;UWPotsPointers ; 0x250 bytes for 0x128 rooms' 16-bit pointers + +;org $09DACE +;UWPotsData ; variable number of bytes (max 0x11D1) for all pots data + +;org $A88000 +;UWSpritesData ; variable number of bytes (max 0x2800) for all sprites and sprite drop data +; First $2800 bytes of this bank (28) is reserved for the sprite tables + +;org $09C297 +;LDA.w UWSpritesPointers,Y +;org $01E6BF ; not sure this code is reachable anymore +;LDA.l UWPotsPointers,X +;STA.b $00 +;LDA.w #UWPotsPointers>>16 + +; $2800 bytes reserved for sprites + +; temporary pot table until sprites get moved: +org $A88000 +UWPotsPointers: ; 0x250 bytes for 0x128 rooms' 16-bit pointers + +org $A88250 +UWPotsData: + +org $A8A800 +;tables: +PotMultiWorldTable: +; Reserved $250 296 * 2 + +org $A8AA50 +StandingItemsOn: ; 142A50 +db 0 +MultiClientFlagsROM: ; 142A51-2 -> stored in SRAM at 7ef33d (for now) +dw 0 +SwampDrain1HasItem: ; 142A53 +db 1 +SwampDrain2HasItem: ; 142A54 +db 1 +StandingItemCounterMask: ; 142A55 +db 0 ; if 0x01 is set then pot should be counted, if 0x02 then sprite drops, 0x03 (both bits for both) +PotCountMode: ; 28AA56-7 +; 0 is don't count pots +; 1 for check PotCollectionRateTable +dw 0 + +org $A8AA60 +PotCollectionRateTable: +; Reserved $250 296 * 2 + +org $A8ACB0 + +RevealPotItem: + STA.b $04 ; save tilemap coordinates + STZ.w SpawnedItemFlag + STZ.w SpawnedItemMWPlayer + LDA.w $0B9C : AND.w #$FF00 : STA.w $0B9C + + LDA.b $A0 : ASL : TAX + + LDA.l UWPotsPointers,X : STA.b $00 ; we may move this + LDA.w #UWPotsPointers>>16 : STA.b $02 + + LDY.w #$FFFD : LDX.w #$FFFF + +.next_pot + INY : INY : INY + + LDA.b [$00],Y + CMP.w #$FFFF : BEQ .exit + + INX + + STA.w $08 ; remember the exact value + AND.w #$3FFF + CMP.b $04 : BNE .next_pot ; not the correct value + + STZ.w SpawnedItemIsMultiWorld + BIT.b $08 + BVS LoadMultiWorldPotItem + BMI LoadMajorPotItem + +.normal_secret + STA $08 + + PHX : PHY + ; set bit and count if first time lifting this pot + TXA : ASL : TAX : LDA.l BitFieldMasks, X : STA $0A + LDA.b $A0 : ASL : TAX + JSR ShouldCountNormalPot : BCC .obtained + LDA.l RoomPotData, X : BIT $0A : BNE .obtained + ORA $0A : STA RoomPotData, X + ; increment dungeon counts + SEP #$30 + LDA $040C : CMP #$FF : BEQ + + BNE ++ + INC #2 ; treat sewers as HC + ++ LSR : TAX : LDA DungeonLocationsChecked, X : INC : STA DungeonLocationsChecked, X + ; Could increment GT Tower Pre Big Key but we aren't showing that stat right now + + REP #$30 + LDA TotalItemCounter : INC : STA TotalItemCounter ; Increment Item Total + .obtained + PLY : PLX + + PLA ; remove the JSL return lower 16 bits + LDA $08 + PEA.w $01E6E2-1 ; change return address to go back to the vanilla routine +.exit + RTL + +LoadMultiWorldPotItem: + INY : INY + LDA.b [$00],Y : AND.w #$00FF + + INC.w SpawnedItemIsMultiWorld + PHX + ASL : TAX + + LDA.l PotMultiWorldTable+1,X : AND.w #$00FF : STA.w SpawnedItemMWPlayer + + LDA.l PotMultiWorldTable+0,X : AND.w #$00FF + + PLX + + BRA SaveMajorItemDrop + +LoadMajorPotItem: + INY : INY + LDA.b [$00],Y : AND.w #$00FF + +SaveMajorItemDrop: + ; A currently holds the item receipt ID + ; X currently holds the pot item index + STA.w SpawnedItemID + STX.w SpawnedItemIndex + INC.w SpawnedItemFlag + TAY : LDA.w #$0008 + CPY.w #$0036 : BNE + ; Red Rupee + LDA.w #$0016 : BRA .done + + CPY.w #$0044 : BNE + ; 10 pack arrows + LDA.w #$0017 : BRA .done + + CPY.w #$0028 : BNE + ; 3 pack bombs + LDA.w #$0018 : BRA .done + + CPY.w #$0031 : BNE .done ; 10 pack bombs + LDA.w #$0019 + .done STA $0B9C ; indicates we should use the key routines or a substitute + RTL + +ShouldCountNormalPot: + INY : INY : LDA [$00], Y : AND #$00FF : CMP #$0080 : BCS .clear + LDA.l PotCountMode : BEQ .clear + LDA.l PotCollectionRateTable, X : BIT $0A : BEQ .clear ; don't count if clear +.set + SEC +RTS +.clear + CLC +RTS + +IncrementCountsForSubstitute: + PHX : REP #$30 + LDA.w SpawnedItemIndex : ASL : TAX : LDA.l BitFieldMasks, X : STA $0A + LDA.b $A0 : ASL : TAX + LDA.l RoomPotData, X : BIT $0A : BNE .obtained + ORA $0A : STA RoomPotData, X + SEP #$30 + LDA $040C : CMP #$FF : BEQ + + BNE ++ + INC #2 ; treat sewers as HC + ++ LSR : TAX : LDA DungeonLocationsChecked, X : INC : STA DungeonLocationsChecked, X + ; Could increment GT Tower Pre Big Key but we aren't showing that stat right now + + REP #$30 + LDA TotalItemCounter : INC : STA TotalItemCounter ; Increment Item Total + .obtained + SEP #$30 : PLX +RTS + +ClearSpriteData: + STZ.b $02 : STZ.b $03 ; what we overrode + PHX + LDA #$00 : LDX #$00 + .loop + STA SprDropsItem, X : STA SprItemReceipt, X : STA SprItemIndex, X + STA SprItemMWPlayer, X : STA SprItemFlags, X + INX : CPX #$10 : BCC .loop + PLX + RTL + +; Runs during sprite load of the room +LoadSpriteData: + INY : INY + LDA.b ($00), Y + CMP #$F3 : BCC .normal + PHA + DEC.b $02 ; standing items shouldn't consume a sprite slot + LDX.b $02 + CMP #$F9 : BNE .not_multiworld + DEY : LDA.b ($00), Y : STA.l SprItemMWPlayer, X + LDA.b #$02 : STA.l SprDropsItem, X : BRA .common + .not_multiworld + LDA.b #$00 : STA.l SprItemMWPlayer, X + LDA.b #$01 : STA.l SprDropsItem, X + DEY + .common + DEY : LDA.b ($00), Y : STA.l SprItemReceipt, X + INY : INY + PLA + PLA : PLA ; remove the JSL return lower 16 bits + PEA.w $09C344-1 ; change return address to exit from Underworld_LoadSingleSprite + RTL + .normal + RTL + +; Run when a sprite dies ... Sets Flag to #$02 and Index to sprite slot for +RevealSpriteDrop: + LDA.l SprDropsItem, X : BEQ .normal + LDA #$02 : STA.l SpawnedItemFlag + STX.w SpawnedItemIndex + LDA.l SprItemReceipt, X : STA SpawnedItemID + LDA.l SprItemMWPlayer, X : STA SpawnedItemMWPlayer + LDY.b #$01 ; trigger the small key routines + LDA SpawnedItemID : CMP #$32 : BNE + + LDA.l StandingItemsOn : BNE + + INY ; big key routine + + RTL ; unstun if stunned + .normal + LDY.w $0CBA, X : BEQ .no_forced_drop + RTL + .no_forced_drop + PLA : PLA ; remove the JSL reswamturn lower 16 bits + PEA.w $06F996-1 ; change return address to .no_forced_drop of (Sprite_DoTheDeath) + RTL + +RevealSpriteDrop2: + LDY.w SprDropsItem, X : BEQ .normal + BRA .no_forced_drop + .normal + LDY.w $0CBA, X : BEQ .no_forced_drop + RTL + .no_forced_drop + PLA : PLA ; remove the JSL reswamturn lower 16 bits + PEA.w $06E3CE-1 ; change return address to .no_forced_drop of (Sprite_DoTheDeath) + RTL + +BitFieldMasks: +dw $8000, $4000, $2000, $1000, $0800, $0400, $0200, $0100 +dw $0080, $0040, $0020, $0010, $0008, $0004, $0002, $0001 + +; Runs during Sprite_E4_SmallKey and duning Sprite_E5_BigKey spawns +ShouldSpawnItem: + LDA $048E : CMP.b #$87 : BNE + ; check for hera basement cage + LDA $A8 : AND.b #$03 : CMP.b #$02 : BNE + ; we're not in that quadrant + LDA.w $0403 : AND.w KeyRoomFlagMasks,Y : RTL + + + ; checking our sram table + PHX : PHY + REP #$30 + LDA.b $A0 : ASL : TAY + LDA.w SprItemIndex, X : AND #$00FF : ASL + PHX + TAX : LDA.l BitFieldMasks, X : STA $00 + PLX ; restore X again + LDA.w SprItemFlags, X : AND #$00FF : CMP #$0001 : BEQ + + TYX : LDA.l SpritePotData, X : BIT $00 : BEQ .notObtained + BRA .obtained + + TYX : LDA.l RoomPotData, X : BIT $00 : BEQ .notObtained + .obtained + SEP #$30 : PLY : PLX : LDA #$01 : RTL ; already obtained + .notObtained + SEP #$30 : PLY : PLX + LDA #$00 + RTL + +MarkSRAMForItem: + LDA $048E : CMP.b #$87 : BNE + ; check for hera basement cage + LDA $A8 : AND.b #$03 : CMP.b #$02 : BNE + + LDA.w $0403 : ORA.w KeyRoomFlagMasks, Y : RTL + + PHX : PHY : REP #$30 + LDA.b $A0 : ASL : TAY + LDA.l SpawnedItemIndex : ASL + TAX : LDA.l BitFieldMasks, X : STA $00 + TYX + LDA.w SpawnedItemFlag : CMP #$0001 : BEQ + + LDA SpritePotData, X : ORA $00 : STA SpritePotData, X : BRA .end + + LDA RoomPotData, X : ORA $00 : STA RoomPotData, X + .end + SEP #$30 : PLY : PLX + LDA.w $0403 + RTL + +SpriteKeyPrep: + LDA.w $0B9B : STA.w $0CBA, X ; what we wrote over + PHA + LDA $A0 : CMP #$87 : BNE .continue + LDA $A9 : ORA $AA : AND #$03 : CMP #$02 : BNE .continue + LDA #$00 : STA.w SpawnedItemFlag : STA SprItemFlags, X + LDA #$24 : STA $0E80, X + BRA + + .continue + LDA.w SpawnedItemIndex : STA SprItemIndex, X + LDA.w SpawnedItemMWPlayer : STA SprItemMWPlayer, X + LDA.w SpawnedItemFlag : STA SprItemFlags, X : BEQ + + LDA.l SpawnedItemID : STA $0E80, X + PHA + JSL.l GetSpritePalette : STA $0F50, X ; setup the palette + PLA + CMP #$24 : BNE ++ ; + LDA $A0 : CMP.b #$80 : BNE + + LDA SpawnedItemFlag : BNE + + LDA #$24 ; it's the big key drop? + ++ JSL RequestStandingItemVRAMSlot + + PLA + RTL + +SpriteKeyDrawGFX: + JSL Sprite_DrawRippleIfInWater + PHA + LDA $0E80, X + CMP.b #$24 : BNE + + LDA $A0 : CMP #$80 : BNE ++ + LDA SpawnedItemFlag : BNE ++ + LDA #$24 : BRA + + ++ PLA + PHK : PEA.w .jslrtsreturn-1 + PEA.w $068014 ; an rtl address - 1 in Bank06 + JML Sprite_DrawAbsorbable + .jslrtsreturn + RTL + + JSL DrawPotItem + CMP #$03 : BNE + + PHA : LDA $0E60, X : ORA.b #$20 : STA $0E60, X : PLA + + JSL.l Sprite_DrawShadowLong + PLA : RTL + +KeyGet: + LDA CurrentSmallKeys ; what we wrote over + PHA + LDA.l StandingItemsOn : BNE + + PLA : RTL + + LDY $0E80, X + LDA SprItemIndex, X : STA SpawnedItemIndex + LDA SprItemFlags, X : STA SpawnedItemFlag + LDA $A0 : CMP #$87 : BNE + ;check for hera cage + LDA SpawnedItemFlag : BNE + ; if it came from a pot, it's fine + JSR ShouldKeyBeCountedForDungeon : BCC ++ + JSL CountChestKeyLong + ++ PLA : RTL + + STY $00 + LDA SprItemMWPlayer, X : STA !MULTIWORLD_ITEM_PLAYER_ID : BNE .receive + PHX + LDA $040C : CMP #$FF : BNE + + LDA $00 : CMP.b #$AF : BNE .skip + LDA CurrentGenericKeys : INC : STA CurrentGenericKeys + LDA $00 : BRA .countIt + + LSR : TAX + LDA $00 : CMP.l KeyTable, X : BNE + + .countIt + LDA.l StandingItemCounterMask : AND SpawnedItemFlag : BEQ ++ + JSL.l FullInventoryExternal : JSL CountChestKeyLong + ++ PLX : PLA : RTL + + CMP.b #$AF : beq .countIt ; universal key + CMP.b #$24 : beq .countIt ; small key for this dungeon + .skip PLX + .receive + JSL $0791b3 ; Player_HaltDashAttackLong + JSL.l Link_ReceiveItem + PLA : DEC : RTL + +KeyTable: +db $A0, $A0, $A2, $A3, $A4, $A5, $A6, $A7, $A8, $A9, $AA, $AB, $AC, $AD + +; Input Y - the item type +ShouldKeyBeCountedForDungeon: + PHX + LDA $040C : CMP #$FF : BEQ .done + LSR : TAX + TYA : cmp KeyTable, X : BNE + + - PLX : SEC : RTS + + CMP.B #$24 : BEQ - + .done + PLX : CLC : RTS + + +BigKeyGet: + LDY $0E80, X + CPY #$32 : BNE + + STZ $02E9 : LDY.b #$32 ; what we wrote over + PHX : JSL Link_ReceiveItem : PLX ; what we wrote over + CLC : RTL + + SEC : RTL + +LoadProperties_PreserveCertainProps: + LDA $0E20, X : CMP #$E4 : BEQ + + CMP #$E5 : BEQ + + JML Sprite_LoadProperties + + LDA $0F50, X : PHA + LDA $0E80, X : PHA + JSL Sprite_LoadProperties + PLA : STA $0E80, X + PLA : STA $0F50, X + RTL + +SubstitionFlow: + CPY.b #$04 : BNE + + RTL ; let enemizer/vanilla take care of it + + PLA : PLA ; remove JSL stuff + CPY.b #$16 : BCS + + PEA.w Sprite_SpawnSecret_NotRandomBush-1 : RTL ; jump to not_random_bush spot + ; jump directly to new code + + PEA.w Sprite_SpawnSecret_SpriteSpawnDynamically-1 +RTL + +SubstitionTable: + db $DB ; RED RUPEE - 0x16 + db $E2 ; ARROW REFILL 10 - 0x17 + db $DD ; BOMB REFILL 4 - 0x18 + db $DE ; BOMB REFILL 8 - 0x19 + + +SubstituteSpriteId: + CPY.b #$16 : BCS + + RTS + + LDA.b #$01 + CPY.b #$18 : BCC + + LDA.b #$05 + + STA.b $0D + JSR IncrementCountsForSubstitute + PHB : PHK : PLB + LDA.w SubstitionTable-$16, Y ; Do substitute + PLB +RTS + +CheckSprite_Spawn: + JSR SubstituteSpriteId + JSL Sprite_SpawnDynamically + BMI .check +RTL +.check + LDA $0D : CMP #$08 : BNE + + LDA $0372 : BNE .error + LDX #$0F + + ; loop looking for a Sprite with state 0A (carried by the player) + - LDA $0DD0, X : CMP #$0A : BEQ .foundIt + DEX : BMI .error : BRA - + + .foundIt + LDA #$00 : STZ $0DD0, X + LDA #$E4 : JSL Sprite_SpawnDynamically + BMI .error + LDA #$40 : TSB $0308 : RTL + + .error + LDA.b #$3C ; SFX2_3C - error beep + STA.w $012E + + LDA #$FF +RTL + +PreventPotSpawn: + LDA #$40 : BIT $0308 : BEQ + + STZ $0308 : RTL + + LDA.b #$80 : STA.w $0308 ; what we wrote over +RTL + +PreventPotSpawn2: + LDA $0308 : BEQ + + LDA.b #$01 : TSB.b $50 ; what we wrote over ++ RTL + +CheckIfPotIsSpecial: + TXA ; give index to A so we can do a CMP.l + CMP.l $018550 ; see if our current index is that of object 230 + BEQ .specialpot + + ; Normal pot, so run the vanilla code + LDA.l CurrentWorld ; check for dark world + .specialpot ; zero flag already set, so gtg +RTL + + +incsrc dynamic_si_vram.asm + +;=================================================================================================== +; Pot items +;=================================================================================================== +;Vanilla: +; Data starts at $01DDE7 formatted: +; dw aaaa : db i + +; aaaa is a 14 bit number: ..tt tttt tttt tttt indicating the tilemap ID +; i is the secrets ID + +;Drop shuffle changes: +; normal secrets stay vanilla + +; major items (anything not a secret) use the bits 14 and 15 to produce different behavior + +; aaaa is now a 16 bit number: +; imtt tttt tttt tttt + +; t - is still tilemap id (aaaa & #$3FFF) +; i - flag indicates a major item +; m - indicates a multiworld item + +; for major items (non multiworld), i indicates the item receipt ID + +; for multi world items, i indicates the multiworld id +; multiworld id indexes a new table of 256 entries of 2 bytes each + +; MultiWorldTable: +; db , + + + +;=================================================================================================== +; Sprite items +;=================================================================================================== +;Vanilla: +;If this value appears in the sprite table, then the sprite that preceded it is given a key drop +; db $FE, $00, $E4 + +;Drop shuffle changes: +; db , $00, $F8 ; this denotes the previous sprite is given a major item (non MW) + +; db , , $F9 ; this denotes the previous sprite is given a MW item diff --git a/keydropshuffle.asm b/keydropshuffle.asm index 253753a..e939d77 100644 --- a/keydropshuffle.asm +++ b/keydropshuffle.asm @@ -26,7 +26,7 @@ Sprite_LoadProperties: org $288000 ;140000 ShuffleKeyDrops: db 0 -MultiClientFlags: ; 140001 -> stored in SRAM at 7ef33d +MultiClientFlagsROM: ; 140001 -> stored in SRAM at 7ef33d db 0 LootTable: ;PC: 140002 @@ -113,7 +113,7 @@ SpriteKeyDrawGFX: KeyGet: { - lda $7ef36f ; what we wrote over + lda CurrentSmallKeys ; what we wrote over pha lda.l ShuffleKeyDrops : bne + - pla : rtl 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/menu/hudalpha.asm b/menu/hudalpha.asm new file mode 100644 index 0000000..c24b758 --- /dev/null +++ b/menu/hudalpha.asm @@ -0,0 +1,23 @@ +OnMenuLoad: + LDA.b #UploadMenuOnlyIcons>>0 : STA !NMI_AUX + LDA.b #UploadMenuOnlyIcons>>8 : STA !NMI_AUX+1 + LDA.b #UploadMenuOnlyIcons>>16 : STA !NMI_AUX+2 + LDA.b #$0E : STA.b $10 ; what we overwrote +RTL + +UploadMenuOnlyIcons: + REP #$20 + LDA.w #MenuOnlyIcons : STA.w $4342 + LDA.w #$1801 : STA.w $4340 + LDA.w #$0240 : STA.w $4345 + LDA.w #$0F800>>1 : STA.w $2116 + + SEP #$20 + LDA.b #MenuOnlyIcons>>16 : STA.w $4344 + LDA.b #$80 : STA.w $2118 + LDA.b #$10 : STA.w $420B + + RTL + +MenuOnlyIcons: +incbin "menuonly.2bpp" \ No newline at end of file diff --git a/menu/menuonly.2bpp b/menu/menuonly.2bpp new file mode 100644 index 0000000..f9be7f6 Binary files /dev/null and b/menu/menuonly.2bpp differ diff --git a/menu/overworldmap.asm b/menu/overworldmap.asm index d8f900d..cf2c246 100644 --- a/menu/overworldmap.asm +++ b/menu/overworldmap.asm @@ -1,8 +1,5 @@ ; adding support for up to 13 markers !MC_FLAG = "$7F5420" -!INVENTORY_MAP = "$7EF368" -!INVENTORY_COMPASS = "$7EF364" -!MAP_OVERLAY = "$7EF414" ; [2] ; tables org $0ABDF6 @@ -200,7 +197,7 @@ PHX JSR OverworldMap_CheckForCompass BCC + LDA.l !MC_FLAG : ORA #$01 : STA.l !MC_FLAG - LDA $7EF3CA : AND #$40 : BNE ++ ; is the compass position on LW or DW? + LDA CurrentWorld : AND #$40 : BNE ++ ; is the compass position on LW or DW? LDA.l WorldCompassMask, X : BEQ + : JMP .fail ++ LDA.l WorldCompassMask, X : BNE + : JMP .fail + JSR OverworldMap_CheckForMap @@ -209,7 +206,7 @@ PHX + LDA.l !MC_FLAG : BEQ .fail CMP #$02 : BNE .checkIfObtained - LDA $7EF3CA : AND #$40 : BNE + + LDA CurrentWorld : AND #$40 : BNE + CPX #3 : BCS .fail : BRA .checkIfObtained + CPX #10 : BCS .fail CPX #3 : BCC .fail @@ -224,23 +221,23 @@ PHX LDA.l CrystalPendantFlags_2, X : AND.b #$02 : BNE .checkAga2 ; see if hyrule castle has been completely cleared - LDA.l CompassTotal, X : SEC : SBC $7EF4BF, X : BEQ .fail + LDA.l CompassTotalsWRAM, X : SEC : SBC DungeonLocationsChecked, X : BEQ .fail CLC : BRA .done .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 .checkAga1 - LDA $7EF3C5 : CMP #$03 : BEQ .fail + LDA ProgressIndicator : CMP #$03 : BEQ .fail CLC : BRA .done .checkAga2 - LDA $7EF01B : AND #$80 : BNE .fail + LDA RoomDataWRAM[$0D].high : AND #$08 : BNE .fail CLC : BRA .done .fail @@ -260,7 +257,7 @@ OverworldMap_CheckForCompass: + LDA.l CompassExists, X : BEQ .set ; compass doesn't exist PHX LDA.l MC_SRAM_Offsets, X : TAX ; put compass offset into X - LDA !INVENTORY_COMPASS, X : ORA !MAP_OVERLAY, X + LDA CompassField, X : ORA MapOverlay, X PLX AND.l MC_Masks, X : BNE .set ; is the compass obtained .unset @@ -275,13 +272,13 @@ RTS ; SEC - yep should show exact prize OverworldMap_CheckForMap: LDA.l MapMode : BEQ .set ; obtaining map doesn't change anything - LDA $7EF3CA : AND #$40 : BNE + ; not really sure on this check - LDA !INVENTORY_MAP : ORA !MAP_OVERLAY : AND.b #$01 : BNE .set : BRA .continue - + LDA !INVENTORY_MAP : ORA !MAP_OVERLAY : AND.b #$02 : BNE .set + LDA CurrentWorld : AND #$40 : BNE + ; not really sure on this check + LDA MapField : ORA MapOverlay : AND.b #$01 : BNE .set : BRA .continue + + LDA MapField : ORA MapOverlay : AND.b #$02 : BNE .set .continue PHX LDA.l MC_SRAM_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 MC_Masks, X : BNE .set ; is the map obtained? .unset diff --git a/msu.asm b/msu.asm index b559830..423cd18 100644 --- a/msu.asm +++ b/msu.asm @@ -250,21 +250,21 @@ CheckMusicLoadRequest: BRA .check_fallback-3 .lightworld PHA - ;LDA $7EF300 : AND.b #$40 : BEQ + ; ped pull - LDA $7EF3C5 : CMP.b #03 : BNE + ; aga1 killed + ;LDA OverworldEventDataWRAM+$80 : AND.b #$40 : BEQ + ; ped pull + LDA ProgressIndicator : CMP.b #03 : BNE + ; aga1 killed 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 @@ -345,10 +345,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 + @@ -387,7 +387,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 @@ -520,16 +520,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 @@ -686,8 +686,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/multiworld.asm b/multiworld.asm index f1f6990..aeb3d65 100644 --- a/multiworld.asm +++ b/multiworld.asm @@ -37,7 +37,7 @@ PHX : PHY : PHP ++ SEP #$20 - LDA #$01 : STA !NMI_AUX+1 : STA !NMI_AUX + LDA #$01 : STA !NMI_MW+1 : STA !NMI_MW LDA !MULTIWORLD_HUD_DELAY STA !MULTIWORLD_HUD_TIMER .textdone @@ -113,7 +113,7 @@ GetMultiworldItem: BRA - ++ PLP - LDA #$01 : STA !NMI_AUX+1 : STA !NMI_AUX + LDA #$01 : STA !NMI_MW+1 : STA !NMI_MW .textend LDA $5D diff --git a/music.asm b/music.asm index ac77f53..a7b6e9b 100644 --- a/music.asm +++ b/music.asm @@ -15,7 +15,7 @@ PreOverworld_LoadProperties_ChooseMusic: LDY.b #$5A ; Main overworld animated tileset ; if we are in the light world go ahead and set chosen selection - ;LDA $7EF3CA : BEQ .checkInverted+4 + ;LDA CurrentWorld : BEQ .checkInverted+4 + JSL Overworld_DetermineMusic .lastCheck @@ -84,7 +84,7 @@ BirdTravel_LoadTargetAreaMusic: ;-------------------------------------------------------------------------------- ;X to be set to music track to load Overworld_DetermineMusic: - LDA $7EF3C5 : CMP.b #$02 : !BGE + + LDA ProgressIndicator : CMP.b #$02 : !BGE + LDX.b #$03 ; If phase < 2, play the rain music BRA .done @@ -94,19 +94,19 @@ Overworld_DetermineMusic: LDX.b #$02 ; hyrule field theme - LDA $7EF3CA : BEQ + + LDA CurrentWorld : BEQ + LDX.b #$09 ; default dark world theme ; Check if we're entering the village + LDA $8A : CMP.b #$18 : BNE + ; Check what phase we're in - ; LDA $7EF3C5 : CMP.b #$03 : !BGE .bunny + ; LDA ProgressIndicator : CMP.b #$03 : !BGE .bunny LDX.b #$07 ; Default village theme (phase <3) BRA .bunny ; Check if we're entering the lost woods + CMP.b #$00 : BNE + - LDA $7EF300 : AND.b #$40 : BNE .bunny + LDA OverworldEventDataWRAM+$80 : AND.b #$40 : BNE .bunny LDX.b #$05 ; lost woods theme BRA .bunny @@ -119,8 +119,8 @@ Overworld_DetermineMusic: .bunny ; if not inverted and light world, or inverted and dark world, skip moon pearl check - LDA $7EF3CA : CLC : ROL #$03 : CMP InvertedMode : BEQ .done - LDA $7EF357 : BNE .done + LDA CurrentWorld : CLC : ROL #$03 : CMP InvertedMode : BEQ .done + LDA MoonPearlEquipment : BNE .done LDX #$04 ; bunny theme .done @@ -130,7 +130,7 @@ Overworld_DetermineMusic: ;-------------------------------------------------------------------------------- ;$012D to be set to any ambient SFX for the area Overworld_DetermineAmbientSFX: - LDA $7EF3C5 : CMP.b #$02 : !BGE + + LDA ProgressIndicator : CMP.b #$02 : !BGE + BRA .done ; rain state sfx handled elsewhere + LDA $8A : CMP.b #$43 : BEQ .darkMountain @@ -142,7 +142,7 @@ Overworld_DetermineAmbientSFX: LDA.b #$05 : BRA .setSfx ; silence .mire - LDA $7EF2F0 : AND.b #$20 : BNE .done + LDA OverworldEventDataWRAM+$70 : AND.b #$20 : BNE .done LDA.b #$01 : BRA .setSfx ; Misery Mire rain SFX .darkMountain @@ -179,7 +179,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 @@ -194,7 +194,7 @@ Overworld_MosaicDarkWorldChecks: ; On entry, A=16bit XY=8bit, A & X safe to mod, Y unknown Underworld_DoorDown_Entry: LDX #$FF ; some junk value to be used later to determine if the below lines will change the track - LDA.l $7EF3C5 : AND.w #$00FF : CMP.w #2 : !BLT .vanilla + LDA.l ProgressIndicator : AND.w #$00FF : CMP.w #2 : !BLT .vanilla LDA.l DRMode : BNE .done .vanilla ; thing we wrote over @@ -210,6 +210,6 @@ Underworld_DoorDown_Entry: ; ; A=16bit XY=8bit CheckHeraBossDefeated: -LDA $7EF00F : AND.w #$00FF : BEQ + +LDA RoomDataWRAM[$08].high : AND.w #$00FF : BEQ + SEC : RTL + CLC : RTL diff --git a/newhud.asm b/newhud.asm index 40f0c11..924fd5e 100644 --- a/newhud.asm +++ b/newhud.asm @@ -1,5 +1,5 @@ NewDrawHud: -SEP #$30 + SEP #$30 ;================================================================================ ; Draw bomb count !BOMBCOUNT_DRAW_ADDRESS = "$7EC75A" @@ -25,14 +25,14 @@ SEP #$30 ; Draw rupee counter !RUPEE_DRAW_ADDRESS = "$7EC750" ;================================================================================ - + LDA.l $7EF362 ; 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 LDX.b $06 : TXA : ORA.w #$2400 : STA !RUPEE_DRAW_ADDRESS+4 ; 10s LDX.b $07 : TXA : ORA.w #$2400 : STA !RUPEE_DRAW_ADDRESS+6 ; 1s - + ;================================================================================ ; Draw arrow count !ARROWCOUNT_DRAW_ADDRESS = "$7EC760" @@ -49,67 +49,57 @@ SEP #$30 LDX.b $06 : TXA : ORA.w #$2400 : STA !ARROWCOUNT_DRAW_ADDRESS ; Draw arrows 10 digit LDX.b $07 : TXA : ORA.w #$2400 : STA !ARROWCOUNT_DRAW_ADDRESS+2 ; Draw arrows 1 digit BRA + - + .infinite_arrows REP #$20 LDA.w #$2431 : STA !ARROWCOUNT_DRAW_ADDRESS ; infinity (left half) INC A : STA !ARROWCOUNT_DRAW_ADDRESS+2 ; infinity (right half) + - ;================================================================================ ; 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 GoalItemRequirement : BNE + : JMP .done : + ; Star Meter + + LDA.l GoalCounter + JSR HudHexToDec4Digit + LDA.l GoalItemIcon : STA !GOAL_DRAW_ADDRESS ; draw star icon LDX.b $05 : TXA : ORA.w #$2400 : STA !GOAL_DRAW_ADDRESS+2 ; draw 100's digit 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 STA !GOAL_DRAW_ADDRESS+12 .done - + ;================================================================================ ; Draw Dungeon Compass Counts ;================================================================================ - REP #$20 LDA.l CompassMode : AND #$003F : 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 @@ -132,9 +122,6 @@ SEP #$30 .done_keys - - - ;-------------------------------------------------------------------------------- ; Draw pendant/crystal icon ;-------------------------------------------------------------------------------- @@ -156,7 +143,7 @@ SEP #$30 REP #$20 BEQ .drawprize - LDA.l $7EF368 + LDA.l MapField AND.l DungeonItemMasks,X BEQ .noprize @@ -184,13 +171,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 +252,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 e87f890..df62be5 100755 --- a/newitems.asm +++ b/newitems.asm @@ -143,10 +143,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 @@ -160,24 +156,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 @@ -192,13 +188,6 @@ 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 @@ -210,62 +199,62 @@ AddReceivedItemExpandedGetItem: PLA 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) @@ -279,34 +268,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 @@ -332,12 +321,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 @@ -354,53 +345,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 + CMP.b #$B0 : BNE + ; Bee Trap @@ -417,8 +408,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" @@ -473,15 +462,15 @@ AddReceivedItemExpanded: +++ : JMP .done .notBottle ++ : 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 !MULTIWORLD_ITEM_PLAYER_ID : BNE + - LDA $7EF359 : CMP.l ProgressiveSwordLimit : !BLT + + LDA HighestSword : CMP.l ProgressiveSwordLimit : !BLT + LDA.l ProgressiveSwordReplacement : STA $02D8 : JMP .done + - LDA $7EF359 : CMP.b #$FF : BNE + ; Swordless + LDA SwordEquipment : CMP.b #$FF : BNE + ; Swordless LDA.b #$49 : STA $02D8 : JMP .done + : CMP.b #$00 : BNE + ; No Sword LDA.b #$49 : STA $02D8 : JMP .done @@ -493,49 +482,49 @@ AddReceivedItemExpanded: LDA.b #$03 : STA $02D8 : JMP .done ++ : CMP.b #$5F : BNE ++ ; Progressive Shield LDA !MULTIWORLD_ITEM_PLAYER_ID : BEQ + - LDA !PROGRESSIVE_SHIELD : AND.b #$C0 : BNE +++ ; No Shield + LDA ShieldEquipment : BNE +++ ; No Shield LDA.b #$04 : STA $02D8 : JMP .done +++ : CMP.b #$40 : BNE +++ ; Fighter Shield LDA.b #$05 : STA $02D8 : JMP .done +++ ; Everything Else LDA.b #$06 : STA $02D8 : JMP .done + - LDA !PROGRESSIVE_SHIELD : LSR #6 : CMP.l ProgressiveShieldLimit : !BLT + + LDA HighestShield : CMP.l ProgressiveShieldLimit : !BLT + LDA.l ProgressiveShieldReplacement : STA $02D8 : JMP .done + - LDA !PROGRESSIVE_SHIELD : AND.b #$C0 : BNE + ; No Shield + LDA HighestShield : BNE + ; No Shield LDA.b #$04 : BRA .shielddone - + : CMP.b #$40 : BNE + ; Fighter Shield + + : CMP.b #$01 : BNE + ; Fighter Shield LDA.b #$05 : BRA .shielddone + ; Everything Else LDA.b #$06 .shielddone : STA $02D8 - LDA !PROGRESSIVE_SHIELD : !ADD.b #$40 : STA !PROGRESSIVE_SHIELD : JMP .done + JMP .done ++ : CMP.b #$60 : BNE ++ ; Progressive Armor LDA !MULTIWORLD_ITEM_PLAYER_ID : BNE + - LDA $7EF35B : CMP.l ProgressiveArmorLimit : !BLT + + LDA HighestMail : CMP.l ProgressiveArmorLimit : !BLT + LDA.l ProgressiveArmorReplacement : STA $02D8 : JMP .done + - LDA $7EF35B : CMP.b #$00 : BNE + ; No Armor + LDA ArmorEquipment : 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 : JMP .done + ; Everything Else LDA.b #$1C : STA $02D8 : JMP .done ++ : CMP.b #$64 : BNE ++ : -- ; Progressive Bow LDA !MULTIWORLD_ITEM_PLAYER_ID : BNE + - LDA $7EF340 : INC : LSR : CMP.l ProgressiveBowLimit : !BLT + + LDA BowEquipment : INC : LSR : CMP.l ProgressiveBowLimit : !BLT + LDA.l ProgressiveBowReplacement : STA $02D8 : JMP .done - + LDA $7EF340 : INC : LSR : CMP.b #$00 : BNE + ; No Bow + + LDA BowEquipment : INC : LSR : 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 !MULTIWORLD_ITEM_PLAYER_ID : BNE +++ - 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 @@ -797,7 +786,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 @@ -880,25 +869,24 @@ org $A08800 .item_masks ; these are dungeon correlations to $7EF364 - $7EF369 so it knows where to store compasses, etc ; sewers and castle get 2 bits active so that they can share their items elegantly dw $C000, $C000, $2000, $1000, $0800, $0400, $0200, $0100 - dw $0080, $0040, $0020, $0010, $0008, $0004, $0000, $0000 + dw $0080, $0040, $0020, $0010, $0008, $0004, $4B8B, $20AB ; last two can be re-used - dw $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000 - dw $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000 - dw $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000 - dw $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000 - dw $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000 - dw $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000 - - dw $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000 - dw $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000 - dw $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000 - dw $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000 - dw $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000 - dw $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000 - dw $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000 - dw $0000, $0000, $0000, $0000, $0000, $0000, $0000 - db $00 - dw $0000 ; Caves + ; caves + dw $9CCE, $0390, $2F82, $AD03, $02E9, $01C9, $06D0, $72A5 + dw $A548, $4873, $01A0, $D8AD, $C902, $D020, $A002, $9802 + dw $E48D, $DA02, $D8AC, $D002, $A215, $BD08, $84E2, $0085 + dw $E3BD, $8584, $A901, $857E, $B902, $857A, $0087, $0A98 + dw $BDAA, $84E2, $0085, $E3BD, $8584, $A901, $857E, $B902 + dw $857A, $0230, $0087, $1FC0, $02D0, $5664, $04A9, $4BC0 + dw $06F0, $1EC0, $0AD0, $02A9, $790F, $7EF3, $798F, $7EF3 + dw $1BC0, $04F0, $1CC0, $07D0, $1B22, $1BEE, $0182, $A201 + dw $C004, $F037, $A20C, $C001, $F038, $A206, $C002, $D039 + dw $8A14, $0007, $0087, $00EE, $2902, $C907, $D007, $A906 + dw $8F04, $F3C7, $C07E, $D022, $A70A, $D000, $A904, $8701 + dw $8000, $C0C9, $F025, $C008, $F032, $C004, $D033, $AE11 + dw $040C, $20C2, $C6BD, $0785, $8700, $E200, $8220, $00B0 + dw $3EC0, $0AD0, $082C, $1003, $A905, $8D02, $0309, $20C0 + dw $44D0 } ;-------------------------------------------------------------------------------- BottleListExpanded: @@ -967,8 +955,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 @@ -977,19 +965,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 ;-------------------------------------------------------------------------------- @@ -997,9 +985,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 @@ -1023,7 +1011,6 @@ RTL LDA.b #$24 : STA $7EC723 RTL ;-------------------------------------------------------------------------------- -!RNG_ITEM = "$7EF450" !SCRATCH_AREA = "$7F5020" !SINGLE_INDEX_TEMP = "$7F5020" !SINGLE_INDEX_OFFSET_TEMP = "$7F5021" @@ -1061,7 +1048,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 @@ -1079,7 +1066,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 @@ -1094,7 +1081,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: @@ -1119,7 +1106,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 @@ -1139,7 +1126,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 @@ -1155,10 +1142,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 @@ -1171,6 +1158,7 @@ JML.l StatsFinalPrep ;-------------------------------------------------------------------------------- ChestPrep: LDA.b #$01 : STA $02E9 + JSL.l IncrementChestCounter LDA.l ServerRequestMode : BEQ + JSL.l ChestItemServiceRequest RTL @@ -1179,3 +1167,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.l CompassMode : AND.b #$0F : 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.l CompassMode : AND.w #$000F : 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 5eb57c1..da52533 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,65 +99,65 @@ 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: PHA : LDA OldManItem_Player : STA !MULTIWORLD_ITEM_PLAYER_ID : PLA 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: PHA : LDA SickKidItem_Player : STA !MULTIWORLD_ITEM_PLAYER_ID : PLA 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: PHA : LDA TreeKidItem_Player : STA !MULTIWORLD_ITEM_PLAYER_ID : PLA 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: PHA : LDA SahasralaItem_Player : STA !MULTIWORLD_ITEM_PLAYER_ID : PLA 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: PHA : LDA LibraryItem_Player : STA !MULTIWORLD_ITEM_PLAYER_ID : PLA 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 @@ -172,7 +170,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/owrando.asm b/owrando.asm index 913b17d..2d0c1eb 100644 --- a/owrando.asm +++ b/owrando.asm @@ -223,9 +223,9 @@ OWPreserveMirrorSprite: .vanilla lda.l InvertedMode : beq + - lda.l $7ef3ca : beq .deleteMirror + lda.l CurrentWorld : beq .deleteMirror rtl - + lda.l $7ef3ca : bne .deleteMirror + + lda.l CurrentWorld : bne .deleteMirror rtl .deleteMirror @@ -254,9 +254,9 @@ OWMirrorSpriteRestore: { lda.l OWMode+1 : and.b #!FLAG_OW_CROSSED : beq .return lda.l InvertedMode : beq + - lda.l $7ef3ca : beq .return + lda.l CurrentWorld : beq .return bra .restorePortal - + lda.l $7ef3ca : bne .return + + lda.l CurrentWorld : bne .return .restorePortal lda.w $1acf : and.b #$0f : sta.w $1acf @@ -275,15 +275,15 @@ OWLightWorldOrCrossed: OWFluteCancel: { lda.l OWFlags+1 : and #$01 : bne + - jsl $02e99d : rtl + jsl FluteMenu_LoadTransport : rtl + lda $7f5006 : cmp #$01 : beq + - jsl $02e99d + jsl FluteMenu_LoadTransport + lda #$00 : sta $7f5006 : rtl } OWFluteCancel2: { lda $f2 : ora $f0 : and #$c0 : bne + - jml $0ab7bd + jml FluteMenu_HandleSelection_NoSelection + inc $0200 lda.l OWFlags+1 : and #$01 : beq + lda $f2 : cmp #$40 : bne + @@ -292,7 +292,7 @@ OWFluteCancel2: } OWSmithAccept: { - lda $7ef3cc : cmp #$07 : beq + + lda FollowerIndicator : cmp #$07 : beq + cmp #$08 : beq + clc : rtl + sec : rtl @@ -395,7 +395,7 @@ OWDetectSpecialTransition: LDA.l OWEdgeDataOffset,X : STA.w $06F8 PLA : SEP #$30 : PLA ; delete 3 bytes from stack JSL Link_CheckForEdgeScreenTransition : BCS .return ; Link_CheckForEdgeScreenTransition - LDA.l $04E879,X : STA.b $00 : CMP.b #$08 : BNE .hobo + LDA.l Overworld_CheckForSpecialOverworldTrigger_Direction,X : STA.b $00 : CMP.b #$08 : BNE .hobo LSR : STA.b $20 : STZ.b $E8 ; move Link and camera to edge LDA.b #$06 : STA.b $02 STZ.w $0418 @@ -437,7 +437,7 @@ OWEdgeTransition: SEP #$30 RTL .normal - LDA.l $02A4E3,X : ORA.l $7EF3CA ; what we wrote over + LDA.l Overworld_ActualScreenID,X : ORA.l CurrentWorld ; what we wrote over RTL } OWSpecialExit: @@ -628,8 +628,8 @@ OWLoadSpecialArea: } OWWorldUpdate: ; x = owid of destination screen { - lda.l OWTileWorldAssoc,x : cmp.l $7ef3ca : beq .return - sta.l $7ef3ca ; change world + lda.l OWTileWorldAssoc,x : cmp.l CurrentWorld : beq .return + sta.l CurrentWorld ; change world ; moving mirror portal off screen when in DW cmp #0 : beq + : lda #1 @@ -641,10 +641,10 @@ OWWorldUpdate: ; x = owid of destination screen lda #$38 : sta $012f ; play sfx - #$3b is an alternative ; toggle bunny mode - lda $7ef357 : bne .nobunny + lda MoonPearlEquipment : bne .nobunny lda.l InvertedMode : bne .inverted - lda $7ef3ca : and.b #$40 : bra + - .inverted lda $7ef3ca : and.b #$40 : eor #$40 + lda CurrentWorld : and.b #$40 : bra + + .inverted lda CurrentWorld : and.b #$40 : eor #$40 + cmp #$40 : bne .nobunny ; turn into bunny lda $5d : cmp #$04 : beq + ; if swimming, continue @@ -681,7 +681,7 @@ OWEndScrollTransition: CMP.w $06FC RTL .normal - CMP.l $02C176,X ; what we wrote over + CMP.l Overworld_FinalizeEntryOntoScreen_Data,X ; what we wrote over RTL } 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 3b11aaa..146d4bc 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,18 +45,18 @@ RTL 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 + @@ -117,7 +117,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 @@ -129,13 +129,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 @@ -209,19 +209,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 @@ -290,7 +290,7 @@ DrawHUDDungeonItems: DEX : DEX : BPL -- - LDA.l !HUD_FLAG : AND.w #$0020 : BEQ + + LDA.l HudFlag : AND.w #$0020 : BEQ + JMP .maps_and_compasses @@ -310,7 +310,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 @@ -334,7 +334,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 @@ -345,7 +345,7 @@ DrawHUDDungeonItems: STA.w $16C6,Y ; reload - LDA.l $7EF366 + LDA.l BigKeyField ..skip_key INX : INX @@ -363,7 +363,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 @@ -393,20 +393,22 @@ DrawHUDDungeonItems: LDX.w #0 ; load once and test multiple times - LDA.l $7EF368 + LDA.l MapField .next_map BIT.w .dungeon_bitmasks,X - BEQ ..skip_map + BNE ..draw_map + ; MapMode indicates if maps are needed for the info + LDA.l MapMode : AND #$00FF : BNE ..skip_map +..draw_map LDY.w .dungeon_positions,X - LDA.w #$2826 + JSL MapIndicatorLong STA.w $1686,Y - ; reload - LDA.l $7EF368 - ..skip_map + ; reload + LDA.l MapField INX : INX CPX.w #26 : BCC .next_map @@ -422,7 +424,7 @@ DrawHUDDungeonItems: LDX.w #0 ; load once and test multiple times - LDA.l $7EF364 + LDA.l CompassField .next_compass BIT.w .dungeon_bitmasks,X @@ -433,7 +435,7 @@ DrawHUDDungeonItems: STA.w $16C6,Y ; reload - LDA.l $7EF364 + LDA.l CompassField ..skip_compass INX : INX @@ -466,7 +468,7 @@ DrawPendantCrystalDiagram: INX #2 : CPX.w #$0014 : BCC - ; pendants - LDA $7EF374 + LDA PendantsField LSR : BCC + ; pendant of wisdom (red) LDX.w #$252B @@ -493,7 +495,7 @@ DrawPendantCrystalDiagram: ; crystals - LDA $7EF37A + LDA CrystalsField LDX.w #$2D44 LDY.w #$2D45 @@ -599,4 +601,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