Merged DR v1.0.1.0

This commit is contained in:
codemann8
2022-07-08 05:32:08 -05:00
98 changed files with 4643 additions and 2426 deletions

View File

@@ -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,19 +380,20 @@ 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
;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
@@ -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:

View File

@@ -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

View File

@@ -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

71
bsodencode.txt Normal file
View File

@@ -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

BIN
bsodfont.1bpp Normal file

Binary file not shown.

BIN
bsodhex.2bpp Normal file

Binary file not shown.

View File

@@ -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

View File

@@ -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
;--------------------------------------------------------------------------------

View File

@@ -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
;--------------------------------------------------------------------------------
InitCompassTotalsRAM:
LDX #$00
-
LDA CompassTotalsROM, X : STA CompassTotalsWRAM, X
INX
CPX #$0F : !BLT -
RTL

View File

@@ -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

View File

@@ -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

View File

@@ -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
;================================================================================

View File

@@ -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

View File

@@ -44,5 +44,4 @@ incsrc doortables.asm
warnpc $288000
; deals with own hooks
incsrc keydropshuffle.asm
incsrc owrando.asm

10
doorrando/dr_lobby.asm Normal file
View File

@@ -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

View File

@@ -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

View File

@@ -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
;================================================================================

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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
}

View File

@@ -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

View File

@@ -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
;--------------------------------------------------------------------------------

View File

@@ -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
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

565
failure.asm Normal file
View File

@@ -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

View File

@@ -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

View File

@@ -117,7 +117,7 @@ FastTextScroll:
RTL
DumbFlagForMSU:
STA.l $7EF3CA
STA.l CurrentWorld
STZ.b $50
RTL

View File

@@ -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
;--------------------------------------------------------------------------------

View File

@@ -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

View File

@@ -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 $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
;================================================================================

View File

@@ -34,7 +34,7 @@ SpawnHauntedGroveItem:
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

View File

@@ -1,25 +1,6 @@
;================================================================================
; 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
@@ -27,78 +8,68 @@ FrameHookAction:
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.l !NMI_AUX+2 : BEQ .return
LDA !NMI_AUX+2 : STA $02 ; set up jump pointer
LDA !NMI_AUX+1 : STA $01
LDA !NMI_AUX+0 : STA $00
PHK
PEA .return-1
PHK : PER .return-1 ; push stack for RTL return
JMP [$0000]
PHA
LDA.b #$00 : STA.l !NMI_AUX+2
REP #$20
LDA.l !NMI_AUX+0 : DEC : PHA
SEP #$20
RTL
.return
LDA.b #$00 : STA !NMI_AUX ; zero bank byte of NMI hook pointer
LDA.b $13 : STA.w $2100
PLA : STA $02
PLA : STA $01
PLA : STA $00
+
LDA $13 : STA $2100 ; thing we wrote over, turn screen back on
JML.l PostNMIHookReturn
;--------------------------------------------------------------------------------

View File

@@ -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)
++

View File

@@ -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 ++

View File

@@ -11,6 +11,6 @@ GetMagicBatItem:
JML.l Link_ReceiveItem
.normalLogic
LDA HalfMagic
STA $7EF37B
STA MagicConsumption
RTL
;--------------------------------------------------------------------------------

View File

@@ -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:

View File

@@ -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

View File

@@ -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

View File

@@ -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

174
initsramtable.asm Normal file
View File

@@ -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

View File

@@ -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 <address> : !ADD #$10 : STA <address>
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 +
+ CPY.b #$22 : BNE + ; Blue Mail
LDX #$01
JSR .incrementMail
+ CPY.b #$23 : BNE + ; Red Mail
LDX #$02
JSR .incrementMail
JMP .done
+ 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
@@ -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 HighestSword
INC : STA $04 : CPX $04 : !BLT + ; don't increment unless we're getting a better sword
TXA : STA HighestSword
+
LDA $7EF422 : !ADD #$20 : STA $7EF422 ; increment sword counter
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

View File

@@ -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.

View File

@@ -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

View File

@@ -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,6 +29,8 @@ ItemDowngradeFixMain:
CPY.b #$13 : BEQ .isShovel ; Shovel
CPY.b #$29 : BEQ .isMushroom ; Mushroom
CPY.b #$00 : BEQ .isUncleSwordShield ; Fighter's Sword & Shield
.done
STA [$00] ; thing we wrote over part 2
.dontWrite
@@ -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
.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
;================================================================================

180
keydrop/dynamic_si_vram.asm Normal file
View File

@@ -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

624
keydrop/standing_items.asm Normal file
View File

@@ -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 <item receipt ID>, <player ID>
;===================================================================================================
; 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 <receipt id>, $00, $F8 ; this denotes the previous sprite is given a major item (non MW)
; db <receipt id>, <player>, $F9 ; this denotes the previous sprite is given a MW item

View File

@@ -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

View File

@@ -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
;LDA CurrentWorld : EOR #$40 : LSR #6 : AND #$01 ; return the same result as having the lantern in the light world

View File

@@ -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
;--------------------------------------------------------------------------------

View File

@@ -2,7 +2,7 @@
; 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

View File

@@ -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

23
menu/hudalpha.asm Normal file
View File

@@ -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"

BIN
menu/menuonly.2bpp Normal file

Binary file not shown.

View File

@@ -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

28
msu.asm
View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -55,19 +55,15 @@ SEP #$30
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
REP #$20
LDA.l GoalItemRequirement : BNE + : JMP .done : + ; Star Meter
LDA.l !GOAL_COUNTER
JSR HudHexToDec3Digit
REP #$20
LDA.l GoalCounter
JSR HudHexToDec4Digit
LDA.l GoalItemIcon : STA !GOAL_DRAW_ADDRESS ; draw star icon
@@ -75,19 +71,15 @@ SEP #$30
LDX.b $06 : TXA : ORA.w #$2400 : STA !GOAL_DRAW_ADDRESS+4 ; draw 10's digit
LDX.b $07 : TXA : ORA.w #$2400 : STA !GOAL_DRAW_ADDRESS+6 ; draw 1's digit
SEP #$20
LDA.l GoalItemRequirement : CMP.b #$FF : BEQ .skip
LDA.l GoalItemRequirement : CMP.w #$FFFF : BEQ .skip
LDA.l GoalItemRequirement
JSR HudHexToDec3Digit
REP #$20
JSR HudHexToDec4Digit
LDA.w #$2830 : STA !GOAL_DRAW_ADDRESS+8 ; draw slash
LDX.b $05 : TXA : ORA.w #$2400 : STA !GOAL_DRAW_ADDRESS+10 ; draw 100's digit
LDX.b $06 : TXA : ORA.w #$2400 : STA !GOAL_DRAW_ADDRESS+12 ; draw 10's digit
LDX.b $07 : TXA : ORA.w #$2400 : STA !GOAL_DRAW_ADDRESS+14 ; draw 1's digit
BRA .done
.skip
REP #$20
LDA.w #$207F ; transparent tile
STA !GOAL_DRAW_ADDRESS+8
STA !GOAL_DRAW_ADDRESS+10
@@ -97,19 +89,17 @@ SEP #$30
;================================================================================
; 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

View File

@@ -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
;--------------------------------------------------------------------------------

View File

@@ -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
;================================================================================

View File

@@ -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
;--------------------------------------------------------------------------------

View File

@@ -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
}

View File

@@ -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

View File

@@ -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

View File

@@ -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 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 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 ExtendedFileNameSRAM, X
CPX.w #$0008 : !BGE +
LDA $7003D9, X ;what we wrote over
+
RTL
GetCharacterPosition:

View File

@@ -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

View File

@@ -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
;--------------------------------------------------------------------------------

View File

@@ -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

18
ram.asm Normal file
View File

@@ -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 <label> = <address>, "<label> labeled at incorrect address."
endmacro
%assertRAM(CompassTotalsWRAM, $7F5410)

View File

@@ -5,18 +5,18 @@ IsItemAvailable:
CPX.b #$04 : BNE .finite
LDA.b #$01 : RTL
.finite
LDA $7EF33F, X
LDA EquipmentWRAM-1, X
RTL
LoadBombCount:
LDA !INFINITE_BOMBS : BNE .infinite
.finite
LDA $7EF343
LDA BombsEquipment
.infinite
RTL
LoadBombCount16:
LDA !INFINITE_BOMBS : AND.w #$00FF : BNE .infinite
.finite
LDA $7EF343
LDA BombsEquipment
.infinite
RTL
StoreBombCount:
@@ -24,13 +24,13 @@ StoreBombCount:
.infinite
PLA : LDA.b #$01 : RTL
.finite
PLA : STA $7EF343
PLA : STA BombsEquipment
RTL
SearchForEquippedItem:
LDA !INFINITE_BOMBS : BEQ +
LDA.b #$01 : LDX.b #$00 : RTL
+
LDA $7EF340 ; thing we wrote over
LDA BowEquipment ; thing we wrote over
RTL
!INFINITE_ARROWS = "$7F50C8"
@@ -40,8 +40,8 @@ DecrementArrows:
.infinite
LDA.b #$01 : RTL
.normal
LDA $7EF377 : BEQ .done
DEC : STA $7EF377 : INC
LDA CurrentArrows : BEQ .done
DEC : STA CurrentArrows : INC
BRA .done
.rupees
REP #$20
@@ -51,17 +51,17 @@ DecrementArrows:
LDA.b #$00 : BRA .done
.not_archery_game
LDA.l $7EF377 : BNE .shoot_arrow ; check if we have arrows
LDA.l CurrentArrows : BNE .shoot_arrow ; check if we have arrows
BRA .done
.shoot_arrow
PHX
REP #$20
LDA $7EF360 : BEQ +
PHA : LDA $7EF340 : DEC : AND #$0002 : TAX : PLA
LDA CurrentRupees : BEQ +
PHA : LDA BowEquipment : DEC : AND #$0002 : TAX : PLA
!SUB.l ArrowModeWoodArrowCost, X ; CMP.w #$0000
BMI .not_enough_money
STA $7EF360 : LDA.w #$0001 : BRA +
STA CurrentRupees : LDA.w #$0001 : BRA +
.not_enough_money
LDA.w #$0000
+
@@ -76,13 +76,13 @@ ArrowGame:
DEC $0B99 ; reduce minigame arrow count
LDA.l ArrowMode : BNE .rupees
.normal
LDA $7EF377 : INC #2 : STA $7EF377 ; increment arrow count (by 2 for some reason)
LDA CurrentArrows : INC #2 : STA CurrentArrows ; increment arrow count (by 2 for some reason)
RTL
.rupees
PHX
REP #$20 ; set 16-bit accumulator
LDA $7EF340 : DEC : AND #$0002 : TAX
LDA $7EF360 : !ADD.l ArrowModeWoodArrowCost, X : STA $7EF360
LDA BowEquipment : DEC : AND #$0002 : TAX
LDA CurrentRupees : !ADD.l ArrowModeWoodArrowCost, X : STA CurrentRupees
SEP #$20 ; set 8-bit accumulator
PLX
+

View File

@@ -98,7 +98,7 @@ RNG_Ganon_Extra_Warp:
PLA
RTL
RNG_Enemy_Drops:
LDA.l $7EF3C5 : CMP #$01 : BEQ + ; drops are static after uncle pickup & before rescuing zelda
LDA.l ProgressIndicator : CMP #$01 : BEQ + ; drops are static after uncle pickup & before rescuing zelda
JML GetRandomInt
+
LDA.b #$0F

20
rupeelimit.asm Normal file
View File

@@ -0,0 +1,20 @@
;================================================================================
; Four Digit Rupees
;--------------------------------------------------------------------------------
Draw4DigitRupees:
LDA $1B : AND.w #$00FF : BEQ .outdoors ; skip if outdoors
.indoors
LDA $A0 : BNE .normal ; skip except for ganon's room
LDA TotalItemCounter
BRA .print
.outdoors
.normal
LDA DisplayRupees
.print
JSL.l HexToDec
LDA $7F5004 : AND.w #$00FF : ORA.w #$2400 : STA $7EC750
LDA $7F5005 : AND.w #$00FF : ORA.w #$2400 : STA $7EC752
LDA $7F5006 : AND.w #$00FF : ORA.w #$2400 : STA $7EC754
LDA $7F5007 : AND.w #$00FF : ORA.w #$2400 : STA $7EC756
RTL
;================================================================================

View File

@@ -27,6 +27,11 @@ RTL
;--------------------------------------------------------------------------------
ClearExtendedWRAMSaveFile:
STA $7EF400, X ; what we wrote over
STA $7F6000, X
STA $7F6100, X
STA $7F6200, X
STA $7F6300, X
STA $7F6400, X
STA $7F6500, X
STA $7F6600, X
STA $7F6700, X
@@ -56,15 +61,15 @@ CopyExtendedSaveFileToWRAM:
LDA #$80 : STA $4301 ; set bus B source to WRAM register
LDA #$00 : STA $2181 ; set WRAM register source address
LDA #$65 : STA $2182
LDA #$60 : STA $2182
LDA #$7F : STA $2183
STZ $4302 ; set bus A destination address to SRAM
LDA #$05 : STA $4303
LDA #$70 : STA $4304
LDA #$00 : STA $4305 ; set transfer size to 0xB00
LDA #$0B : STA $4306 ; STZ $4307
LDA #$00 : STA $4305 ; set transfer size to 0x1000
LDA #$10 : STA $4306 ; STZ $4307
LDA #$01 : STA $420B ; begin DMA transfer
;--------------------------------------------------------------------------------
@@ -98,14 +103,14 @@ CopyExtendedWRAMSaveFileToSRAM:
STA $4301 ; set bus B source to WRAM register
LDA #$00 : STA $2181 ; set WRAM register source address
LDA #$65 : STA $2182
LDA #$60 : STA $2182
LDA #$7F : STA $2183
STZ $4302 ; set bus A destination address to SRAM
LDA #$05 : STA $4303
LDA #$70 : STA $4304
LDA #$00 : STA $4305 ; set transfer size to 0xB00
LDA #$10 : STA $4305 ; set transfer size to 0xB00
LDA #$0B : STA $4306 ; STZ $4307
LDA #$01 : STA $420B ; begin DMA transfer

View File

@@ -46,10 +46,10 @@
; ;--------------------------------------------------------------------------------
!RX_BUFFER = "$7F5300"
!RX_STATUS = "$7F537F"
!RX_SEQUENCE = "$7EF4A0"
;ServiceSequenceRx = $7EF4A0
!TX_BUFFER = "$7F5380"
!TX_STATUS = "$7F53FF"
!TX_SEQUENCE = "$7EF4A0"
;ServiceSequenceTx = $7EF4A0
;--------------------------------------------------------------------------------
macro ServiceRequestVersion()
LDA !TX_STATUS : BEQ + : CLC : RTL : + ; return fail if we don't have the lock

View File

@@ -188,7 +188,7 @@ SpritePrep_ShopKeeper:
PHY
PHX
LDA.b #$00 : XBA : TYA : LSR #2 : !ADD !SHOP_SRAM_INDEX : TAX
LDA !SHOP_PURCHASE_COUNTS, X : TYX : STA.l !SHOP_INVENTORY+3, X : TAY
LDA PurchaseCounts, X : TYX : STA.l !SHOP_INVENTORY+3, X : TAY
PLX
LDA.l ShopContentsTable+4, X : BEQ +
@@ -244,7 +244,7 @@ SpritePrep_ShopKeeper:
.takeAll
LDA.b #$00 : XBA : LDA !SHOP_SRAM_INDEX : TAX
LDA.l !SHOP_PURCHASE_COUNTS, X
LDA.l PurchaseCounts, X
BRA ++
.notTakeAll
LDA.b #$00
@@ -298,8 +298,6 @@ RTS
;!SHOP_INVENTORY, X
;[id][$lo][$hi][purchase_counter]
;--------------------------------------------------------------------------------
;!SHOP_PURCHASE_COUNTS = "$7EF302"
;--------------------------------------------------------------------------------
Shopkeeper_UploadVRAMTilesLong:
JSR.w Shopkeeper_UploadVRAMTiles
RTL
@@ -457,13 +455,13 @@ Sprite_ShopKeeper:
BIT.b #$20 : BNE + ; Not A Take-All
PHX
LDA !SHOP_SRAM_INDEX : TAX
LDA !SHOP_PURCHASE_COUNTS, X : BEQ ++ : PLX : BRA .done : ++
LDA PurchaseCounts, X : BEQ ++ : PLX : BRA .done : ++
PLX
BRA .normal
+ ; Take-All
;PHX
; LDA !SHOP_SRAM_INDEX : TAX
; LDA.w !SHOP_PURCHASE_COUNTS, X : STA.l !SHOP_STATE
; LDA.w PurchaseCounts, X : STA.l !SHOP_STATE
;PLX
.normal
@@ -591,8 +589,6 @@ Shopkeeper_SetupHitboxes:
PLP : PLY : PLX
RTS
!LOCK_STATS = "$7EF443"
!ITEM_TOTAL = "$7EF423"
;--------------------
;!SHOP_STATE
Shopkeeper_BuyItem:
@@ -611,7 +607,7 @@ Shopkeeper_BuyItem:
+
LDA !SHOP_TYPE : AND.b #$80 : BNE .buy ; don't charge if this is a take-any
REP #$20 : LDA $7EF360 : CMP.l !SHOP_INVENTORY+1, X : SEP #$20 : !BGE .buy
REP #$20 : LDA CurrentRupees : CMP.l !SHOP_INVENTORY+1, X : SEP #$20 : !BGE .buy
.cant_afford
LDA.b #$7A
@@ -627,12 +623,12 @@ Shopkeeper_BuyItem:
JMP .done
.buy
LDA !SHOP_TYPE : AND.b #$80 : BNE ++ ; don't charge if this is a take-any
REP #$20 : LDA $7EF360 : !SUB !SHOP_INVENTORY+1, X : STA $7EF360 : SEP #$20 ; Take price away
REP #$20 : LDA CurrentRupees : !SUB !SHOP_INVENTORY+1, X : STA CurrentRupees : SEP #$20 ; Take price away
++
PHX
LDA #0 : XBA : TXA : LSR #2 : TAX : LDA.l !SHOP_INVENTORY_PLAYER, X : STA !MULTIWORLD_ITEM_PLAYER_ID
TXA : !ADD !SHOP_SRAM_INDEX : TAX
LDA.l !SHOP_PURCHASE_COUNTS, X : BNE +++ ;Is this the first time buying this slot?
LDA.l PurchaseCounts, X : BNE +++ ;Is this the first time buying this slot?
LDA.l EnableShopItemCount, X : STA.l !SHOP_ENABLE_COUNT ; If so, store the permission to count the item here.
+++
PLX
@@ -647,7 +643,7 @@ Shopkeeper_BuyItem:
+++
PHX
TXA : !ADD !SHOP_SRAM_INDEX : TAX
LDA !SHOP_PURCHASE_COUNTS, X : INC : BEQ +++ : STA !SHOP_PURCHASE_COUNTS, X : +++
LDA PurchaseCounts, X : INC : BEQ +++ : STA PurchaseCounts, X : +++
PLX
BRA ++
+ ; Take-any
@@ -656,14 +652,14 @@ Shopkeeper_BuyItem:
.takeAny
LDA.l !SHOP_STATE : ORA.b #$07 : STA.l !SHOP_STATE
PHX
LDA.l !SHOP_SRAM_INDEX : TAX : LDA.b #$01 : STA.l !SHOP_PURCHASE_COUNTS, X
LDA.l !SHOP_SRAM_INDEX : TAX : LDA.b #$01 : STA.l PurchaseCounts, X
LDA.l EnableShopItemCount, X : STA.l !SHOP_ENABLE_COUNT
PLX
BRA ++
.takeAll
LDA.l !SHOP_STATE : ORA.w Shopkeeper_ItemMasks, X : STA.l !SHOP_STATE
PHX
LDA.l !SHOP_SRAM_INDEX : TAX : LDA.l !SHOP_STATE : STA.l !SHOP_PURCHASE_COUNTS, X
LDA.l !SHOP_SRAM_INDEX : TAX : LDA.l !SHOP_STATE : STA.l PurchaseCounts, X
LDA.l EnableShopItemCount, X : STA.l !SHOP_ENABLE_COUNT
PLX
++
@@ -676,7 +672,6 @@ db #$01, #$02, #$04, #$08
;--------------------
;!SHOP_ID = "$7F5050"
;!SHOP_SRAM_INDEX = "$7F5062"
;!SHOP_PURCHASE_COUNTS = "$7EF302"
;--------------------
Setup_ShopItemCollisionHitbox:
;The complications with XBA are to handle the fact that nintendo likes to store
@@ -797,7 +792,7 @@ Shopkeeper_DrawItems:
LDA $02DA : BNE + ; if not buying item
LDA $7F505E : BEQ + ; if potion slot filled
LDA $0ABF : BEQ + ; haven't left the room
LDA !NPC_FLAGS_2 : AND.b #$20 : BNE +
LDA NpcFlags+1 : AND.b #$20 : BNE +
LDX.b #$0C : LDY.b #$03 : JSR.w Shopkeeper_DrawNextItem
+
PLY : PLX

View File

@@ -32,14 +32,14 @@ SpriteSwap_Palette_ArmorAndGloves:
LDA !SPRITE_SWAP : BNE .continue
LDA.b #$10 : STA $BC ; Load Original Sprite Location
REP #$21
LDA $7EF35B
LDA ArmorEquipment
JSL $1BEDFF ; Read Original Palette Code
RTL
.part_two
SEP #$30
LDA !SPRITE_SWAP : BNE .continue
REP #$30
LDA $7EF354
LDA GloveEquipment
JSL $1BEE21 ; Read Original Palette Code
RTL
@@ -51,7 +51,7 @@ SpriteSwap_Palette_ArmorAndGloves:
REP #$20 ; set 16-bit accumulator
; Check what Link's armor value is.
LDA $7EF35B : AND.w #$00FF : TAX
LDA ArmorEquipment : AND.w #$00FF : TAX
; (DEC06, X)

664
sram.asm Normal file
View File

@@ -0,0 +1,664 @@
;================================================================================
; SRAM Labels & Assertions
;--------------------------------------------------------------------------------
; Labels for values in SRAM and assertions that ensure they're correct and
; at the expected addresses. All values larger than one byte are little endian.
;--------------------------------------------------------------------------------
; $7EF000 - $7EF4FF in WRAM maps to the first $4FF bytes in SRAM (Bank $70)
; $7F6000 - $7F6FFF in WRAM maps to the next 4k bytes, occupying the 2nd and 3rd vanilla
; save file locations. ($700500 - $701500)
;--------------------------------------------------------------------------------
pushpc
org 0 ; This module writes no bytes. Asar gives bank cross errors without this.
;================================================================================
; Room Data ($7EF000 - $7EF27F
;--------------------------------------------------------------------------------
; Each room has two bytes. There are 296 ($128) rooms in the ROM. The data beyond
; $7EF24F is unused. The current room index is located at $A0 in WRAM (16-bits.)
;
; The quadrant bits from left to right correspond to quadrants 4 (northwest), 3 (northeast),
; 2 (southwest), and 1 (southeast), which is the same as they are laid out on the screen from
; left to right, top to bottom.
;
; Example: We can use RoomDataWRAM[$37].high to read or write the pot key in the first
; floodable room in Swamp Palace ($04)
;--------------------------------------------------------------------------------
; .high Byte: d d d d b k u t
; .low Byte: s e h c q q q q
;
; d = Door opened (key, bomb wall, etc)
; b = Boss kill / Heart Container
; k = Key / Heart Piece
; u = Second key
; t = Chest 4 / Rupee floor / Swamp drains / Bombable floor / Mire wall
; s = Chest 3 / Bomable floor / PoD or Desert wall
; e = Chest 2
; h = Chest 1
; c = Chest 0
; q = Quadrant visits
;--------------------------------------------------------------------------------
struct RoomDataWRAM $7EF000
.l
.low: skip 1
.high: skip 1
endstruct align 2
;================================================================================
; Overworld Event Data ($7EF280 - $7EF33F)
;--------------------------------------------------------------------------------
; Each overworld area has one byte. The overworld screen index is located at $8A
; in WRAM (16-bits.)
;
; This label can be indexed with a plus symbol (e.g. The Hyrule Castle screen would
; be OverworldEventDataWRAM+$1B or OverworldEventDataWRAM+27)
;--------------------------------------------------------------------------------
; - i o - - - b -
;
; i = Free-standing item collected. Also used for sprites like the castle tower barrier
; o = Overlay active
; b = Bomb wall opened
;--------------------------------------------------------------------------------
OverworldEventDataWRAM = $7EF280
; Temp location
MultiClientFlagsWRAM = $7EF33D
;================================================================================
; Items & Equipment ($7EF340 - $7EF38B)
;--------------------------------------------------------------------------------
; Current equipment labels & values
; Values will represent current menu selection in cases where player can switch
; items (e.g. holding powder and mushroom at the same time.)
;
; $00 = None
;--------------------------------------------------------------------------------
base $7EF340
EquipmentWRAM: ;
BowEquipment: skip 1 ; $01 = Bow | $02 = Bow & Arrows
; $03 = Silver Arrow Bow | $04 = Bow & Silver Arrows
BoomerangEquipment: skip 1 ; $01 = Blue | $02 = Red
HookshotEquipment: skip 1 ; $01 = Hookshot
BombsEquipment: skip 1 ; Number of bombs currently held (8-bit integer)
PowderEquipment: skip 1 ; $01 = Mushroom | $02 = Powder
FireRodEquipment: skip 1 ; $01 = Fire Rod
IceRodEquipment: skip 1 ; $01 = Ice Rod
BombosEquipment: skip 1 ; $01 = Bombos Medallion
EtherEquipment: skip 1 ; $01 = Ether Medallion
QuakeEquipment: skip 1 ; $01 = Quake Medallion
LampEquipment: skip 1 ; $01 = Lamp
HammerEquipment: skip 1 ; $01 = Hammer
FluteEquipment: skip 1 ; $01 = Shovel | $02 = Inactive Flute | $03 = Active Flute
BugNetEquipment: skip 1 ; $01 = Bug Net
BookOfMudoraEquipment: skip 1 ; $01 = Book of Mudora
BottleIndex: skip 1 ; Current bottle in menu. 1-based index into BottleContents below
SomariaEquipment: skip 1 ; $01 = Cane of Somaria
ByrnaEquipment: skip 1 ; $01 = Cane of Byrna
CapeEquipment: skip 1 ; $01 = Magic Cape
MirrorEquipment: skip 1 ; $01 = Scroll (graphic only) | $02 = Mirror
GloveEquipment: skip 1 ; $01 = Power Gloves | $02 = Titan's Mitts
BootsEquipment: skip 1 ; $01 = Boots | This only shows menu item, see: AbilityFlags
FlippersEquipment: skip 1 ; $01 = Flippers
MoonPearlEquipment: skip 1 ; $01 = Moon Pearl
skip 1 ; Not used
SwordEquipment: skip 1 ; $01 = Fighter | $02 = Master | $03 = Tempered | $04 = Gold
ShieldEquipment: skip 1 ; $01 = Fighter | $02 = Red | $03 = Mirror
ArmorEquipment: skip 1 ; $00 = Green | $01 = Blue | $02 = Red
BottleContents: ; \ Bottle Contents
BottleContentsOne: skip 1 ; |
BottleContentsTwo: skip 1 ; | $00 = No Bottle | $01 = Mushroom | $02 = Empty Bottle
BottleContentsThree: skip 1 ; | $03 = Red Potion | $04 = Green Potion | $05 = Blue Potion
BottleContentsFour: skip 1 ; / $06 = Fairy | $07 = Bee | $08 = Good Bee
CurrentRupees: skip 2 ; \ DisplayRupees holds the number on the HUD. It will always
DisplayRupees: skip 2 ; / increment/decrement to match CurrentRupees if not equal (16-bit integers)
;--------------------------------------------------------------------------------
CompassField: skip 2 ; Dungeon item bitfields
BigKeyField: skip 2 ; Low byte: w i h b t g - -
MapField: skip 2 ; w = Skull Woods | i = Ice Palace | h = Hera | b = Thieves' Town
; t = Turtle Rock | g = Ganon's Tower
;------------------------------------------------
; High Byte: x c e d a s p m
; x = Sewers | c = Hyrule Castle | e = Eastern Palace | d = Desert Palace
; a = Castle Tower | s = Swamp Palace | p = PoD | m = Mire
;--------------------------------------------------------------------------------
; HUD & other equipment
skip 1 ; Wishing Pond Rupee (Unused)
HeartPieceQuarter: skip 1 ; Heart pieces of four for health upgrade. Wraps around to $00 after $03.
MaximumHealth: skip 1 ; \ Max Health & Current Health
CurrentHealth: skip 1 ; / Max value for both is $A0 | $04 = half heart | $08 = heart
CurrentMagic: skip 1 ; Current magic | Max value is $80
CurrentSmallKeys: skip 1 ; Number of small keys held for current dungeon (integer)
BombCapacityUpgrades: skip 1 ; \ Bomb & Arrow Capacity Upgrades
ArrowCapacityUpgrades: skip 1 ; / Indicates flatly how many can be held above vanilla max (integers)
HeartsFiller: skip 1 ; Hearts collected yet to be filled. Write in multiples of $08
MagicFiller: skip 1 ; Magic collected yet to be filled
PendantsField: skip 1 ; - - - - - g b r (bitfield)
; g = Green (Courage) | b = Blue (Power) | r = Red (Wisdom)
BombsFiller: skip 1 ; Bombs collected yet to be filled (integer)
ArrowsFiller: skip 1 ; Arrows collected yet to be filled (integer)
CurrentArrows: skip 1 ; Current arrows (integer)
skip 1 ; Unknown
AbilityFlags: skip 1 ; l r t u p b s h (bitfield)
; l = Lift | r = Read | t = Talk | u = Unused but set by default
; p = Pull | b = Dash | s = Swim | h = Pray (unused)
CrystalsField: skip 1 ; - w b s t i p m (bitfield)
; w = Skull Woods | b = Thieves' Town | s = Swamp Palace | t = Turtle Rock
; i = Ice Palace | p = Palace of Darkness | m = Misery Mire
MagicConsumption: skip 1 ; $00 = Normal | $01 = Half Magic | $02 = Quarter Magic
;--------------------------------------------------------------------------------
; Small keys earned per dungeon (integers)
DungeonKeys: ;
SewerKeys: skip 1 ; \ HC and Sewers small keys increment together
HyruleCastleKeys: skip 1 ; /
EasternKeys: skip 1 ; Eastern Palace small keys
DesertKeys: skip 1 ; Desert Palace small keys
CastleTowerKeys: skip 1 ; Agahnim's Tower small keys
SwampKeys: skip 1 ; Swamp Palace small keys
PalaceOfDarknessKeys: skip 1 ; Palace of Darkness small keys
MireKeys: skip 1 ; Misery Mire small keys
SkullWoodsKeys: skip 1 ; Skull Woods small keys
IcePalaceKeys: skip 1 ; Ice Palace small keys
HeraKeys: skip 1 ; Tower of Hera small keys
ThievesTownKeys: skip 1 ; Thieves' Town small keys
TurtleRockKeys: skip 1 ; Turtle Rock small keys
GanonsTowerKeys: skip 1 ; Ganon's Tower small keys
skip 1 ; Unused
CurrentGenericKeys: skip 1 ; Generic small keys
;================================================================================
; Tracking & Indicators ($7EF38C - $7EF3F0)
;--------------------------------------------------------------------------------
InventoryTracking: skip 2 ; b r m p n s k f - - - - - - o q (bitfield)
; b = Blue Boomerang | r = Red Boomerang | m = Mushroom Current
; p = Magic Powder | n = Mushroom Past | s = Shovel
; k = Inactive Flute | f = Active Flute | o = Any bomb acquired
; q = Quickswap locked
BowTracking: skip 2 ; b s p - - - - - - - - - - - - - (bitfield)
; b = Bow | s = Silver Arrows Upgrade | p = Second Progressive Bow
; The front end writes two distinct progressive bow items. p
; indicates whether the "second" has been found independent of
; the first
ItemLimitCounts: skip 16 ; Keeps track of limited non-progressive items such as lamp.
; See: ItemSubstitutionRules in tables.asm
; Right now this is only used for three items but extra space is
; reserved
skip 37 ; Unused
ProgressIndicator: skip 1 ; $00 = Pre-Uncle | $01 = Post-Uncle item | $02 = Zelda Rescued
; $03 = Agahnim 1 defeated
; $04 and above don't do anything. $00-$02 used in standard mode
ProgressFlags: skip 1 ; - - - h - z - u (bitfield)
; h = Uncle left house | z = Zelda rescued | u = Uncle item obtained
MapIcons: skip 1 ; Used for deciding which icons to display on OW map
; $03 = Pendants | $04 = Master Sword | $05 = Skull at Hyrule Castle
; $06 = Crystal 1 | $07 = All Crystals | $08 = Skull at Ganon's Tower
StartingEntrance: skip 1 ; Starting entrance to use
; $00 = Link's House | $01 = Menu or Pyramid w/ Aga dead & mirror
; $02 = Zelda's Cell | $03 = Secret Passage or HC if entered (escape)
; $04 = Throne Room (escape) | $05 = Old Man Cave w/ Old Man
NpcFlagsVanilla: skip 1 ; - - d p s - b h (bitfield)
; d = Frog rescued | p = Purple Chest | s = Tree Kid (unused)
; b = Bottle Merchant item | h = Hobo item
CurrentWorld: skip 1 ; $00 = Light World | $40 = Dark World
skip 1 ; Unused
FollowerIndicator: skip 1 ; $00 = No Follower | $01 = Zelda | $04 = Old Man
; $06 = Blind Maiden | $07 = Frog | $08 = Dwarf
; $09 = Locksmith | $0A = Kiki | $0C = Purple Chest
; $0D = Big Bomb
FollowerXCoord: skip 2 ; \ Cached X and Y overworld coordinates of dropped follower
FollowerYCoord: skip 2 ; / (16-bit integers)
DroppedFollowerIndoors: skip 1 ; $00 = Dropped follower outdoors | $01 = Dropped follower indoors
DroppedFollowerLayer: skip 1 ; $00 = Upper layer | $01 =.lower layer
FollowerDropped: skip 1 ; Set to $80 when a follower exists and has been dropped somewhere
; $00 otherwise
skip 5 ; Unused
FileNameVanillaWRAM: skip 8 ; First four characters of file name
FileValidity: skip 2 ; Always $55AA. Don't write.
;================================================================================
; Rando-Specific Assignments & Game Stats ($7EF3F1 - $7EF4FF)
;--------------------------------------------------------------------------------
skip 28 ; Unused
GameCounter: skip 2 ; Number of deaths and save + quits (16-bit integer)
PostGameCounter: skip 2 ; Initialized to $FFFF, replaced with GameCounter on goal completion
; Number is displayed on file select when not $FFFF. Max 999 (16-bit integer)
CompassCountDisplay: skip 2 ; Compass count display flags (bitfield)
; Sets a flag if the total item count has been displayed on HUD
; Low byte: w i h b t g - -
; w = Skull Woods | i = Ice Palace | h = Hera | b = Thieves' Town
; t = Turtle Rock | g = Ganon's Tower
; High Byte: x c e d a s p m
; x = Sewers | c = Hyrule Castle | e = Eastern Palace | d = Desert Palace
; a = Castle Tower | s = Swamp Palace | p = PoD | m = Mire
skip 10 ;
Aga2Duck: skip 1 ; Used in lieu of pyramid hole for checking if the duck should come
; 0 = Haven't called post-Aga 2 bird | 1 = Have called post-Aga 2 bird
NpcFlags: skip 2 ; l - c s t k z o (bitfield)
; l = Library | c = Catfish | s = Sahasrahla | t = Stumpy
; k = Sick Kid | z = King Zora | o = Old Man
;
; b - p m f s b e (bitfield)
; b = Magic Bat | p = Potion Shop (Powder) | m = Lost Woods (Mushroom)
; f = Fairy (unused) | s = Smith | b = Bombos Tablet
; e = Ether Tablet
skip 2 ; Unused
MapOverlay: skip 2 ; Used to reveal dungeon prizes on the map in modes where maps,
; Saha, and the bomb shop guy reveal dungeon prizes (bitfield)
; \ - - g r t h i s
; | g = Ganon's Tower | r = Turtle Rock | t = Thieves' Town
; / h = Tower of Hera | i = Ice Palace | s = Skull Woods
; \ m d s a t e h p
; | m = Misery Mire | d = Palace of Darkness | s = Swamp Palace
; | a = Aga Tower | t = Desert Palace | e = Eastern Palace
; / h = Hyrule Castle | s = Sewer Passage
HudFlag: ;
IgnoreFaeries: ;
HasGroveItem: ;
GeneralFlags: skip 1 ; - - h - - i - g (bitfield)
; h = HUD Flag | i = ignore faeries | g = has diggable grove item
HighestSword: skip 1 ; Highest sword level (integer)
GoalCounter: skip 2 ; Goal items collected (16-bit integer)
ProgrammableItemOne: skip 2 ; \ Reserved for programmable items
ProgrammableItemTwo: skip 2 ; |
ProgrammableItemThree: skip 2 ; /
BonkCounter: skip 1 ; Number of times the player has bonked (integer)
YAItemCounter: skip 1 ; y y y y y a a a (packed integers)
; Number of Y and A items collected represented as packed integers
HighestShield: skip 1 ; Highest Shield level
TotalItemCounter: skip 2 ; Total items collected (integer)
SwordBossKills: skip 2 ; t t t t g g g g f f f f m m m m (packed integers)
; t = Tempered Sword boss kills | g = Gold Sword boss kills
; f = Fighter Sword boss kills | m = Master Sword boss kills
BigKeysBigChests: skip 1 ; k k k k c c c c (packed integers)
; k = Big Keys collected | c = Big Chests opened
MapsCompasses: skip 1 ; m m m m c c c c (packed integers)
; m = Maps collected | c = Compasses collected
PendantCounter: skip 1 ; Number of pendants collected (integer)
PreGTBKLocations: skip 1 ; Locations checked in GT before finding the big key
; b = Big Bomb Acquired | s = Silver Arrows Acquired
; c = GT locations collected before big key
RupeesSpent: skip 2 ; Rupees spent (16-bit integer)
SaveQuitCounter: skip 1 ; Number of times player has saved and quit (integer)
LoopFrames: skip 4 ; Frame counter incremented during frame hook (32-bit integer)
PreBootsLocations: skip 2 ; Number of locations checked before getting boots (integer)
PreMirrorLocations: skip 2 ; Number of locations checked before getting mirror (integer)
PreFluteLocations: skip 2 ; Number of locations checked before getting flute (integer)
skip 2 ; Unused
OverworldMirrors: skip 1 ; Number of times mirror used on overworld (integer)
UnderworldMirrors: skip 1 ; Number of times mirror used in underworld (integer)
ScreenTransitions: skip 2 ; Number of screen transitions (16-bit integer)
NMIFrames: skip 4 ; Frame counter incremented during NMI hook (32-bit integer)
ChestsOpened: skip 1 ; Number of chests opened. Doesn't count NPC, free standing items etc (integer)
StatsLocked: skip 1 ; Set to $01 when goal is completed; game stops counting stats.
MenuFrames: skip 4 ; Total menu time in frames (32-bit integer)
HeartContainerCounter: skip 1 ; Total number of heart containers collected (integer)
DeathCounter: skip 1 ; Number of deaths (integer)
skip 1 ; Reserved
FluteCounter: skip 1 ; Number of times fluted (integer)
skip 4 ;
RNGItem: skip 2 ; RNG Item
SwordlessBossKills: skip 1 ; Number of bosses killed without a sword (integer)
FaerieRevivalCounter: skip 1 ; Number of faerie revivals (integer)
ChallengeTimer: skip 4 ; Timer used for OHKO etc
SwordTime: skip 4 ; Time first sword found in frames (32-bit integer)
BootsTime: skip 4 ; Time boots found in frames (32-bit integer)
FluteTime: skip 4 ; Time flute found in frames (32-bit integer)
MirrorTime: skip 4 ; Time mirror found in frames (32-bit integer)
ChestTurnCounter: skip 1 ; Number of chest turns (integer)
CapacityUpgrades: skip 1 ; Number of capacity upgrades collected (integer)
DamageCounter: skip 2 ; Damage taken by player (16-bit integer)
MagicCounter: skip 2 ; Magic used by player (16-bit integer)
HighestMail: skip 1 ; Highest mail level
SmallKeyCounter: skip 1 ; Total Number of small keys collected (integer)
HeartPieceCounter: skip 1 ; Total Number of heartpieces collected (integer)
CrystalCounter: skip 1 ; Total Number of crystals collected (integer)
DungeonsCompleted: skip 2 ; Bitfield indicating whether a dungeon's prize has been collected.
; This has the same shape as the dungeon item bitfields.
skip 44 ; Unused
ServiceSequenceRx: ; Service sequence receive
ServiceSequenceTx: ; Service sequence transmit
ServiceSequence: skip 8 ; Service request block. See servicerequest.asm
skip 8 ; Unused
DungeonAbsorbedKeys: ; \ Absorbed key counters (integers)
SewerAbsorbedKeys: skip 1 ; | Sewer Passage
HCAbsorbedKeys: skip 1 ; | Hyrule Castle
EPAbsorbedKeys: skip 1 ; | Eastern Palace
DPAbsorbedKeys: skip 1 ; | Desert Palace
CTAbsorbedKeys: skip 1 ; | Agahnim's Tower
SPAbsorbedKeys: skip 1 ; | Swamp Palace
PDAbsorbedKeys: skip 1 ; | Palace of Darkness
MMAbsorbedKeys: skip 1 ; | Misery Mire
SWAbsorbedKeys: skip 1 ; | Skull Woods
IPAbsorbedKeys: skip 1 ; | Ice Palace
THAbsorbedKeys: skip 1 ; | Tower of Hera
TTAbsorbedKeys: skip 1 ; | Thieves' Town
TRAbsorbedKeys: skip 1 ; | Turtle Rock
GTAbsorbedKeys: skip 1 ; / Ganon's Tower
skip 2 ; Reserved for previous table
DungeonLocationsChecked: ; \ Dungeon locations checked counters (integers)
SewersLocations: skip 1 ; | Sewer Passage
HCLocations: skip 1 ; | Hyrule Castle
EPLocations: skip 1 ; | Eastern Palace
DPLocations: skip 1 ; | Desert Palace
CTLocations: skip 1 ; | Agahnim's Tower
SPLocations: skip 1 ; | Swamp Palace
PDLocations: skip 1 ; | Palace of Darkness
MMLocations: skip 1 ; | Misery Mire
SWLocations: skip 1 ; | Skull Woods
IPLocations: skip 1 ; | Ice Palace
THLocations: skip 1 ; | Tower of Hera
TTLocations: skip 1 ; | Thieves' Town
TRLocations: skip 1 ; | Turtle Rock
GTLocations: skip 1 ; / Ganon's Tower:
skip 2 ; Reserved for previous table
skip 16 ; Currently occupied by multiworld stuff in DR, can be reclaimed
DungeonCollectedKeys: ; \ Chest Key Counters. Only counts keys placed in chests. (integers)
SewerCollectedKeys: skip 1 ; | Sewer Passage
HCCollectedKeys: skip 1 ; | Hyrule Castle
EPCollectedKeys: skip 1 ; | Eastern Palace
DPCollectedKeys: skip 1 ; | Desert Palace
CTCollectedKeys: skip 1 ; | Agahnim's Tower
SPCollectedKeys: skip 1 ; | Swamp Palace
PDCollectedKeys: skip 1 ; | Palace of Darkness
MMCollectedKeys: skip 1 ; | Misery Mire
SWCollectedKeys: skip 1 ; | Skull Woods
IPCollectedKeys: skip 1 ; | Ice Palace
THCollectedKeys: skip 1 ; | Tower of Hera
TTCollectedKeys: skip 1 ; | Thieves' Town
TRCollectedKeys: skip 1 ; | Turtle Rock
GTCollectedKeys: skip 1 ; / Ganon's Tower
skip 2 ; Reserved for previous table
FileMarker: skip 1 ; $FF = Active save file | $00 = Inactive save file
skip 13 ; Unused
InverseChecksum: skip 2 ; Vanilla Inverse Checksum. Don't write unless computing checksum.
;================================================================================
; Expanded SRAM ($7F6000 - $7F6FFF)
;--------------------------------------------------------------------------------
; This $1000 byte segment is saved beginning where the second save file was in SRAM
; beginning at $700500
;--------------------------------------------------------------------------------
base $7F6000 ; $1000 byte buffer we place beginning at second save file
ExtendedFileNameWRAM: skip 24 ; File name, 12 word-length characters.
RoomPotData: skip 592 ; Table for expanded pot shuffle. One word per room.
SpritePotData: skip 592 ; Table for expanded pot shuffle. One word per room.
PurchaseCounts: skip 96 ; Keeps track of shop purchases
PrivateBlock: skip 512 ; Reserved for 3rd party developers
DummyValue: skip 1 ; $01 if you're a real dummy
;================================================================================
; Direct SRAM Assignments ($700000 - $7080000)
;--------------------------------------------------------------------------------
; Label assignments for the actual cartridge SRAM, expanded to 32k. Used mainly
; for burning in values such as the ROM name directly or when we only have to read
; a small amount of data which is not currently in the WRAM mirror.
;--------------------------------------------------------------------------------
base $700000 ;
CartridgeSRAM: ;
RoomDataSRAM: ;
skip $280 ;
OverworldEventDataSRAM: ;
skip $C0 ;
EquipmentSRAM: skip 76 ;
InventoryTrackingSRAM: skip 2 ;
BowTrackingSRAM: skip 2 ;
skip 53 ;
ProgressIndicatorSRAM: skip 1 ;
skip 19 ;
FileNameVanillaSRAM: skip 8 ; First four characters of file name
FileValiditySRAM: skip 2 ;
skip 285 ;
ExtendedFileNameSRAM: skip 24 ; We read and write the file name directly from and to SRAM (24 bytes)
skip $1AE4 ;
RomVersionSRAM: skip 4 ; ALTTPR ROM version. Low byte is the version, high byte writes
; $01 for now (32-bits total)
RomNameSRAM: skip 21 ; ROM name from $FFC0, burned in during init (21 bytes)
; If value in the ROM doesn't match SRAM, save is cleared.
skip 4075 ;
PasswordSRAM: skip 16 ; Password value (16 bytes)
base off
;================================================================================
; Assertions
;================================================================================
macro assertSRAM(label, address)
assert <label> = <address>, "<label> labeled at incorrect address."
endmacro
;================================================================================
; Vanilla Assertions
;--------------------------------------------------------------------------------
; All of these need to pass for the base rom to build or something is probably
; very wrong.
;--------------------------------------------------------------------------------
%assertSRAM(EquipmentWRAM, $7EF340)
%assertSRAM(BowEquipment, $7EF340)
%assertSRAM(BoomerangEquipment, $7EF341)
%assertSRAM(HookshotEquipment, $7EF342)
%assertSRAM(BombsEquipment, $7EF343)
%assertSRAM(PowderEquipment, $7EF344)
%assertSRAM(FireRodEquipment, $7EF345)
%assertSRAM(IceRodEquipment, $7EF346)
%assertSRAM(BombosEquipment, $7EF347)
%assertSRAM(EtherEquipment, $7EF348)
%assertSRAM(QuakeEquipment, $7EF349)
%assertSRAM(LampEquipment, $7EF34A)
%assertSRAM(HammerEquipment, $7EF34B)
%assertSRAM(FluteEquipment, $7EF34C)
%assertSRAM(BugNetEquipment, $7EF34D)
%assertSRAM(BookOfMudoraEquipment, $7EF34E)
%assertSRAM(BottleIndex, $7EF34F)
%assertSRAM(SomariaEquipment, $7EF350)
%assertSRAM(ByrnaEquipment, $7EF351)
%assertSRAM(CapeEquipment, $7EF352)
%assertSRAM(MirrorEquipment, $7EF353)
%assertSRAM(GloveEquipment, $7EF354)
%assertSRAM(BootsEquipment, $7EF355)
%assertSRAM(FlippersEquipment, $7EF356)
%assertSRAM(MoonPearlEquipment, $7EF357)
%assertSRAM(SwordEquipment, $7EF359)
%assertSRAM(ShieldEquipment, $7EF35A)
%assertSRAM(ArmorEquipment, $7EF35B)
%assertSRAM(BottleContentsOne, $7EF35C)
%assertSRAM(BottleContentsTwo, $7EF35D)
%assertSRAM(BottleContentsThree, $7EF35E)
%assertSRAM(BottleContentsFour, $7EF35F)
%assertSRAM(CurrentRupees, $7EF360)
%assertSRAM(DisplayRupees, $7EF362)
;--------------------------------------------------------------------------------
%assertSRAM(CompassField, $7EF364)
%assertSRAM(BigKeyField, $7EF366)
%assertSRAM(MapField, $7EF368)
;--------------------------------------------------------------------------------
%assertSRAM(HeartPieceQuarter, $7EF36B)
%assertSRAM(MaximumHealth, $7EF36C)
%assertSRAM(CurrentHealth, $7EF36D)
%assertSRAM(CurrentMagic, $7EF36E)
%assertSRAM(CurrentSmallKeys, $7EF36F)
%assertSRAM(BombCapacityUpgrades, $7EF370)
%assertSRAM(ArrowCapacityUpgrades, $7EF371)
%assertSRAM(HeartsFiller, $7EF372)
%assertSRAM(MagicFiller, $7EF373)
%assertSRAM(PendantsField, $7EF374)
%assertSRAM(BombsFiller, $7EF375)
%assertSRAM(ArrowsFiller, $7EF376)
%assertSRAM(CurrentArrows, $7EF377)
%assertSRAM(AbilityFlags, $7EF379)
%assertSRAM(CrystalsField, $7EF37A)
%assertSRAM(MagicConsumption, $7EF37B)
;--------------------------------------------------------------------------------
%assertSRAM(DungeonKeys, $7EF37C)
%assertSRAM(SewerKeys, $7EF37C)
%assertSRAM(HyruleCastleKeys, $7EF37D)
%assertSRAM(EasternKeys, $7EF37E)
%assertSRAM(DesertKeys, $7EF37F)
%assertSRAM(CastleTowerKeys, $7EF380)
%assertSRAM(SwampKeys, $7EF381)
%assertSRAM(PalaceOfDarknessKeys, $7EF382)
%assertSRAM(MireKeys, $7EF383)
%assertSRAM(SkullWoodsKeys, $7EF384)
%assertSRAM(IcePalaceKeys, $7EF385)
%assertSRAM(HeraKeys, $7EF386)
%assertSRAM(ThievesTownKeys, $7EF387)
%assertSRAM(TurtleRockKeys, $7EF388)
%assertSRAM(GanonsTowerKeys, $7EF389)
%assertSRAM(CurrentGenericKeys, $7EF38B)
;--------------------------------------------------------------------------------
%assertSRAM(ProgressIndicator, $7EF3C5)
%assertSRAM(ProgressFlags, $7EF3C6)
%assertSRAM(MapIcons, $7EF3C7)
%assertSRAM(StartingEntrance, $7EF3C8)
%assertSRAM(NpcFlagsVanilla, $7EF3C9)
%assertSRAM(CurrentWorld, $7EF3CA)
%assertSRAM(FollowerIndicator, $7EF3CC)
%assertSRAM(FollowerXCoord, $7EF3CD)
%assertSRAM(FollowerYCoord, $7EF3CF)
%assertSRAM(DroppedFollowerIndoors, $7EF3D1)
%assertSRAM(DroppedFollowerLayer, $7EF3D2)
%assertSRAM(FollowerDropped, $7EF3D3)
%assertSRAM(FileNameVanillaWRAM, $7EF3D9)
%assertSRAM(FileValidity, $7EF3E1)
%assertSRAM(InverseChecksum, $7EF4FE)
;================================================================================
; Randomizer Assertions
;--------------------------------------------------------------------------------
; Trackers and other third party consumers may depend on these values.
;--------------------------------------------------------------------------------
%assertSRAM(InventoryTracking, $7EF38C)
%assertSRAM(BowTracking, $7EF38E)
%assertSRAM(ItemLimitCounts, $7EF390)
;--------------------------------------------------------------------------------
%assertSRAM(GameCounter, $7EF3FF)
%assertSRAM(PostGameCounter, $7EF401)
%assertSRAM(CompassCountDisplay, $7EF403)
%assertSRAM(Aga2Duck, $7EF40F)
%assertSRAM(NpcFlags, $7EF410)
%assertSRAM(MapOverlay, $7EF414)
%assertSRAM(HudFlag, $7EF416)
%assertSRAM(IgnoreFaeries, $7EF416)
%assertSRAM(HasGroveItem, $7EF416)
%assertSRAM(GeneralFlags, $7EF416)
%assertSRAM(HighestSword, $7EF417)
%assertSRAM(GoalCounter, $7EF418)
%assertSRAM(ProgrammableItemOne, $7EF41A)
%assertSRAM(ProgrammableItemTwo, $7EF41C)
%assertSRAM(ProgrammableItemThree, $7EF41E)
%assertSRAM(BonkCounter, $7EF420)
%assertSRAM(YAItemCounter, $7EF421)
%assertSRAM(HighestShield, $7EF422)
%assertSRAM(TotalItemCounter, $7EF423)
%assertSRAM(SwordBossKills, $7EF425)
%assertSRAM(BigKeysBigChests, $7EF427)
%assertSRAM(MapsCompasses, $7EF428)
%assertSRAM(PendantCounter, $7EF429)
%assertSRAM(PreGTBKLocations, $7EF42A)
%assertSRAM(RupeesSpent, $7EF42B)
%assertSRAM(SaveQuitCounter, $7EF42D)
%assertSRAM(LoopFrames, $7EF42E)
%assertSRAM(PreBootsLocations, $7EF432)
%assertSRAM(PreMirrorLocations, $7EF434)
%assertSRAM(PreFluteLocations, $7EF436)
%assertSRAM(OverworldMirrors, $7EF43A)
%assertSRAM(UnderworldMirrors, $7EF43B)
%assertSRAM(ScreenTransitions, $7EF43C)
%assertSRAM(NMIFrames, $7EF43E)
%assertSRAM(ChestsOpened, $7EF442)
%assertSRAM(StatsLocked, $7EF443)
%assertSRAM(MenuFrames, $7EF444)
%assertSRAM(HeartContainerCounter, $7EF448)
%assertSRAM(DeathCounter, $7EF449)
%assertSRAM(FluteCounter, $7EF44B)
%assertSRAM(RNGItem, $7EF450)
%assertSRAM(SwordlessBossKills, $7EF452)
%assertSRAM(FaerieRevivalCounter, $7EF453)
%assertSRAM(ChallengeTimer, $7EF454)
%assertSRAM(SwordTime, $7EF458)
%assertSRAM(BootsTime, $7EF45C)
%assertSRAM(FluteTime, $7EF460)
%assertSRAM(MirrorTime, $7EF464)
%assertSRAM(ChestTurnCounter, $7EF468)
%assertSRAM(CapacityUpgrades, $7EF469)
%assertSRAM(DamageCounter, $7EF46A)
%assertSRAM(MagicCounter, $7EF46C)
%assertSRAM(HighestMail, $7EF46E)
%assertSRAM(SmallKeyCounter, $7EF46F)
%assertSRAM(HeartPieceCounter, $7EF470)
%assertSRAM(CrystalCounter, $7EF471)
%assertSRAM(DungeonsCompleted, $7EF472)
;--------------------------------------------------------------------------------
%assertSRAM(ServiceSequence, $7EF4A0)
%assertSRAM(ServiceSequenceRx, $7EF4A0)
%assertSRAM(ServiceSequenceTx, $7EF4A0)
;--------------------------------------------------------------------------------
%assertSRAM(DungeonAbsorbedKeys, $7EF4B0)
%assertSRAM(SewerAbsorbedKeys, $7EF4B0)
%assertSRAM(HCAbsorbedKeys, $7EF4B1)
%assertSRAM(EPAbsorbedKeys, $7EF4B2)
%assertSRAM(DPAbsorbedKeys, $7EF4B3)
%assertSRAM(CTAbsorbedKeys, $7EF4B4)
%assertSRAM(SPAbsorbedKeys, $7EF4B5)
%assertSRAM(PDAbsorbedKeys, $7EF4B6)
%assertSRAM(MMAbsorbedKeys, $7EF4B7)
%assertSRAM(SWAbsorbedKeys, $7EF4B8)
%assertSRAM(IPAbsorbedKeys, $7EF4B9)
%assertSRAM(THAbsorbedKeys, $7EF4BA)
%assertSRAM(TTAbsorbedKeys, $7EF4BB)
%assertSRAM(TRAbsorbedKeys, $7EF4BC)
%assertSRAM(GTAbsorbedKeys, $7EF4BD)
%assertSRAM(DungeonLocationsChecked, $7EF4C0)
%assertSRAM(SewersLocations, $7EF4C0)
%assertSRAM(HCLocations, $7EF4C1)
%assertSRAM(EPLocations, $7EF4C2)
%assertSRAM(DPLocations, $7EF4C3)
%assertSRAM(CTLocations, $7EF4C4)
%assertSRAM(SPLocations, $7EF4C5)
%assertSRAM(PDLocations, $7EF4C6)
%assertSRAM(MMLocations, $7EF4C7)
%assertSRAM(SWLocations, $7EF4C8)
%assertSRAM(IPLocations, $7EF4C9)
%assertSRAM(THLocations, $7EF4CA)
%assertSRAM(TTLocations, $7EF4CB)
%assertSRAM(TRLocations, $7EF4CC)
%assertSRAM(GTLocations, $7EF4CD)
%assertSRAM(DungeonCollectedKeys, $7EF4E0)
%assertSRAM(SewerCollectedKeys, $7EF4E0)
%assertSRAM(HCCollectedKeys, $7EF4E1)
%assertSRAM(EPCollectedKeys, $7EF4E2)
%assertSRAM(DPCollectedKeys, $7EF4E3)
%assertSRAM(CTCollectedKeys, $7EF4E4)
%assertSRAM(SPCollectedKeys, $7EF4E5)
%assertSRAM(PDCollectedKeys, $7EF4E6)
%assertSRAM(MMCollectedKeys, $7EF4E7)
%assertSRAM(SWCollectedKeys, $7EF4E8)
%assertSRAM(IPCollectedKeys, $7EF4E9)
%assertSRAM(THCollectedKeys, $7EF4EA)
%assertSRAM(TTCollectedKeys, $7EF4EB)
%assertSRAM(TRCollectedKeys, $7EF4EC)
%assertSRAM(GTCollectedKeys, $7EF4ED)
%assertSRAM(FileMarker, $7EF4F0)
;--------------------------------------------------------------------------------
%assertSRAM(ExtendedFileNameWRAM, $7F6000)
%assertSRAM(RoomPotData, $7F6018)
%assertSRAM(SpritePotData, $7F6268)
%assertSRAM(PurchaseCounts, $7F64B8)
%assertSRAM(PrivateBlock, $7F6518)
%assertSRAM(DummyValue, $7F6718)
;================================================================================
; Direct SRAM Assertions
;--------------------------------------------------------------------------------
%assertSRAM(CartridgeSRAM, $700000)
%assertSRAM(RoomDataSRAM, $700000)
%assertSRAM(OverworldEventDataSRAM, $700280)
%assertSRAM(EquipmentSRAM, $700340)
%assertSRAM(InventoryTrackingSRAM, $70038C)
%assertSRAM(BowTrackingSRAM, $70038E)
%assertSRAM(ProgressIndicatorSRAM, $7003C5)
%assertSRAM(FileNameVanillaSRAM, $7003D9)
%assertSRAM(FileValiditySRAM, $7003E1)
%assertSRAM(ExtendedFileNameSRAM, $700500)
%assertSRAM(RomNameSRAM, $702000)
%assertSRAM(RomVersionSRAM, $701FFC)
%assertSRAM(PasswordSRAM, $703000)
pullpc

361
stats.asm
View File

@@ -1,186 +1,37 @@
;================================================================================
; Stat Tracking
;================================================================================
; $7EF420 - $7EF46D - Stat Tracking
; $7EF420 - $7EF468 - Stat Tracking
;
; See sram.asm for adresses and documentation of stat values
;--------------------------------------------------------------------------------
; $7EF420 - bonk counter
;--------------------------------------------------------------------------------
; $7EF421 yyyyyaaa
; y - y item counter
; a - a item counter
;--------------------------------------------------------------------------------
; $7EF422 ssshhccc
; s - sword counter
; h - shield counter
; c - crystal counter
;--------------------------------------------------------------------------------
; $7EF423 - item counter
;--------------------------------------------------------------------------------
; $7EF425w[2] 1111 2222 3333 4444
; 1 - lvl 1 sword bosses
; 2 - lvl 2 sword bosses
; 3 - lvl 3 sword bosses
; 4 - lvl 4 sword bosses
;--------------------------------------------------------------------------------
; $7EF427 kkkkcccc
; k - big keys
; c - big chests
;--------------------------------------------------------------------------------
; $7EF428 mmmmcccc
; k - maps
; c - compases
;--------------------------------------------------------------------------------
; $7EF429 bbbb--pp
; b - heart containers
; p - pendant upgrades
;--------------------------------------------------------------------------------
; $7EF42A b-sccccc
; b - bomb acquired
; s - silver arrow bow acquired
; c - chests before gtower big key
;--------------------------------------------------------------------------------
; $7EF42Bw[2] - rupees spent
;--------------------------------------------------------------------------------
; $7EF42D - s&q counter
;--------------------------------------------------------------------------------
; $7EF42Ew[2] - loop frame counter (low)
;--------------------------------------------------------------------------------
; $7EF430w[2] - loop frame counter (high)
;--------------------------------------------------------------------------------
; $7EF432w[2] - locations before boots
;--------------------------------------------------------------------------------
; $7EF434-7EF439 - FORMER COMPASS COUNTERS. DO NOT REUSE.
;--------------------------------------------------------------------------------
; $7EF43A - times mirrored outdoors
;--------------------------------------------------------------------------------
; $7EF43B - times mirrored in dungeons
;--------------------------------------------------------------------------------
; $7EF43Cw[2] - screen transition counter
;--------------------------------------------------------------------------------
; $7EF43Ew[2] - nmi frame counter (low)
;--------------------------------------------------------------------------------
; $7EF440w[2] - nmi frame counter (high)
;--------------------------------------------------------------------------------
; $7EF442 - chest counter
;--------------------------------------------------------------------------------
; $7EF443 - lock stats
;--------------------------------------------------------------------------------
; $7EF444w[2] - item menu frame counter (low)
;--------------------------------------------------------------------------------
; $7EF446w[2] - item menu frame counter (high)
;--------------------------------------------------------------------------------
; $7EF448 - ---hhhhh
; h - heart pieces
;--------------------------------------------------------------------------------
; $7EF449 - death counter
;--------------------------------------------------------------------------------
; $7EF44A - reserved
;--------------------------------------------------------------------------------
; $7EF44B - flute counter
;--------------------------------------------------------------------------------
; $7EF44Cl[3] - RTA-Timestamp (Start)
;--------------------------------------------------------------------------------
; $7EF44Fl[3] - RTA-Timestamp (End)
;--------------------------------------------------------------------------------
; $7EF452 - sssscccc
; s - swordless bosses
; c - capacity upgrades
;--------------------------------------------------------------------------------
; $7EF453 - fairy revival counter
;--------------------------------------------------------------------------------
; $7EF454w[2] - challenge timer (low)
;--------------------------------------------------------------------------------
; $7EF456w[2] - challenge timer (high)
;--------------------------------------------------------------------------------
; $7EF458w[2] - sword timestamp (low)
;--------------------------------------------------------------------------------
; $7EF45Aw[2] - sword timestamp (high)
;--------------------------------------------------------------------------------
; $7EF45Cw[2] - boots timestamp (low)
;--------------------------------------------------------------------------------
; $7EF45Ew[2] - boots timestamp (high)
;--------------------------------------------------------------------------------
; $7EF460w[2] - flute timestamp (low)
;--------------------------------------------------------------------------------
; $7EF462w[2] - flute timestamp (high)
;--------------------------------------------------------------------------------
; $7EF464w[2] - mirror timestamp (low)
;--------------------------------------------------------------------------------
; $7EF466w[2] - mirror timestamp (high)
;--------------------------------------------------------------------------------
; $7EF468w[2] - locations before mirror
;--------------------------------------------------------------------------------
; $7EF46A mmkkkkkk
; m - mail counter
; k - small keys
;--------------------------------------------------------------------------------
; $7EF46Bw[2] - Dungeon prizes collected by dungeon location.
;--------------------------------------------------------------------------------
; $7EF46D - chest turns counter
;--------------------------------------------------------------------------------
; $7EF46E - 7EF49F - Free space
;--------------------------------------------------------------------------------
; $7EF4A0 - 7EF4A7 - Service Request
;--------------------------------------------------------------------------------
; $7EF4A8 - 7EF4A9 - Free space
;--------------------------------------------------------------------------------
; $7EF4AAw[2] - damage taken
;--------------------------------------------------------------------------------
; $7EF4ACw[2] - magic used
;--------------------------------------------------------------------------------
; $7EF4AE - 7EF4AF - Free space
;--------------------------------------------------------------------------------
; $7EF4B0 - 7EF4BF - Absorbed keys, indexed by 040C >> 1
;--------------------------------------------------------------------------------
; $7EF4C0 - 7EF4CF - locations checked, indexed by 040C >> 1
;--------------------------------------------------------------------------------
; $7EF4D0 - 7EF4DA - Multiworld controls
;--------------------------------------------------------------------------------
; $7EF4DB - 7EF4DF - Free space
;--------------------------------------------------------------------------------
; $7EF4E0 - 7EF4EF - Collected Keys, indexed by 040C >> 1
;--------------------------------------------------------------------------------
; $7EF4F0 - Fresh File Marker.
;--------------------------------------------------------------------------------
; $7EF4F1 - 7EF4FD - Free space
;--------------------------------------------------------------------------------
; 7EF4FEw[2] - Save Checksum
;--------------------------------------------------------------------------------
;--------------------------------------------------------------------------------
!LOCK_STATS = "$7EF443"
;--------------------------------------------------------------------------------
!BONK_COUNTER = "$7EF420"
IncrementBonkCounter:
LDA !LOCK_STATS : BNE +
LDA !BONK_COUNTER : INC
LDA StatsLocked : BNE +
LDA BonkCounter : INC
CMP.b #100 : BEQ + ; decimal 100
STA !BONK_COUNTER
STA BonkCounter
+
RTL
;--------------------------------------------------------------------------------
!SAVE_COUNTER = "$7EF42D"
StatSaveCounter:
PHA
LDA !LOCK_STATS : BNE +
LDA StatsLocked : BNE +
LDA $10 : CMP.b #$17 : BNE + ; not a proper s&q, link probably died
LDA !SAVE_COUNTER : INC
LDA SaveQuitCounter : INC
CMP.b #100 : BEQ + ; decimal 100
STA !SAVE_COUNTER
STA SaveQuitCounter
+
PLA
RTL
;--------------------------------------------------------------------------------
!SAVE_COUNTER = "$7EF42D"
DecrementSaveCounter:
PHA
LDA !LOCK_STATS : BNE +
LDA !SAVE_COUNTER : DEC : STA !SAVE_COUNTER
LDA StatsLocked : BNE +
LDA SaveQuitCounter : DEC : STA SaveQuitCounter
+
PLA
RTL
;--------------------------------------------------------------------------------
!TRANSITION_COUNTER = "$7EF43C"
DungeonHoleWarpTransition:
LDA $01C31F, X
BRA StatTransitionCounter
@@ -189,10 +40,10 @@ DungeonHoleEntranceTransition:
LDA.l SilverArrowsAutoEquip : AND.b #$02 : BEQ +
LDA $010E : CMP.b #$7B : BNE + ; skip unless falling to ganon's room
LDA !INVENTORY_SWAP_2 : AND.b #$40 : BEQ + ; skip if we don't have silvers
LDA $7EF340 : BEQ + ; skip if we have no bow
LDA BowTracking : AND.b #$40 : BEQ + ; skip if we don't have silvers
LDA BowEquipment : BEQ + ; skip if we have no bow
CMP.b #$03 : !BGE + ; skip if the bow is already silver
!ADD #$02 : STA $7EF340 ; increase bow to silver
!ADD #$02 : STA BowEquipment ; increase bow to silver
+
BRA StatTransitionCounter
@@ -207,27 +58,26 @@ DungeonExitTransition:
LDA.b #$0F : STA $10 ; stop running through the transition
StatTransitionCounter:
PHA : PHP
LDA !LOCK_STATS : BNE +
LDA StatsLocked : BNE +
REP #$20 ; set 16-bit accumulator
LDA !TRANSITION_COUNTER : INC
LDA ScreenTransitions : INC
CMP.w #999 : BEQ + ; decimal 999
STA !TRANSITION_COUNTER
STA ScreenTransitions
+
PLP : PLA
RTL
;--------------------------------------------------------------------------------
!FLUTE_COUNTER = "$7EF44B"
IncrementFlute:
LDA !LOCK_STATS : BNE +
LDA !FLUTE_COUNTER : INC : STA !FLUTE_COUNTER
LDA StatsLocked : BNE +
LDA FluteCounter : INC : STA FluteCounter
+
JSL.l StatTransitionCounter ; also increment transition counter
RTL
;--------------------------------------------------------------------------------
IncrementSmallKeys:
STA $7EF36F ; thing we wrote over, write small key count
STA CurrentSmallKeys ; thing we wrote over, write small key count
PHX
LDA !LOCK_STATS : BNE +
LDA StatsLocked : BNE +
JSL AddInventory_incrementKeyLong
+
JSL.l UpdateKeys
@@ -237,14 +87,18 @@ IncrementSmallKeys:
RTL
;--------------------------------------------------------------------------------
IncrementSmallKeysNoPrimary:
STA $7EF36F ; thing we wrote over, write small key count
STA CurrentSmallKeys ; thing we wrote over, write small key count
PHX
LDA StatsLocked : BNE +
JSL AddInventory_incrementKeyLong
+
JSL.l UpdateKeys
LDA $1B : BEQ + ; skip room check if outdoors
PHP : REP #$20 ; set 16-bit accumulator
LDA $048E : CMP.w #$0087 : BNE ++ ; hera basement
LDA $048E : CMP.w #$0087 : BNE ++ ; check for hera basement cage
LDA $A8 : AND #$0003 : CMP #$0002 : BNE ++ ; must be quadrant 2
PLP : PHY : LDY.b #$24 : JSL.l FullInventoryExternal
LDA ShuffleKeyDrops : BNE +++
LDA StandingItemsOn : BNE +++
JSR CountChestKey
+++ PLY : BRA +
++
@@ -255,7 +109,7 @@ IncrementSmallKeysNoPrimary:
RTL
;--------------------------------------------------------------------------------
DecrementSmallKeys:
STA $7EF36F ; thing we wrote over, write small key count
STA CurrentSmallKeys ; thing we wrote over, write small key count
JSL.l UpdateKeys
RTL
;--------------------------------------------------------------------------------
@@ -277,7 +131,7 @@ CountChestKey: ; called by neighbor functions
INC ; combines HC and Sewer counts
+ TAX
.count
LDA $7EF4E0, X : INC : STA $7EF4E0, X
LDA DungeonCollectedKeys, X : INC : STA DungeonCollectedKeys, X
.end
PLX : PLA
RTS
@@ -299,67 +153,60 @@ RTL
;--------------------------------------------------------------------------------
IncrementAgahnim2Sword:
PHA
LDA !LOCK_STATS : BNE +
LDA StatsLocked : BNE +
JSL AddInventory_incrementBossSwordLong
+
PLA
RTL
;--------------------------------------------------------------------------------
!DEATH_COUNTER = "$7EF449"
IncrementDeathCounter:
PHA
LDA !LOCK_STATS : BNE +
LDA $7EF36D : BNE + ; link is still alive, skip
LDA !DEATH_COUNTER : INC : STA !DEATH_COUNTER
;JSL.l DecrementSaveCounter
LDA StatsLocked : BNE +
LDA CurrentHealth : BNE + ; link is still alive, skip
LDA DeathCounter : INC : STA DeathCounter
+
PLA
RTL
;--------------------------------------------------------------------------------
!FAIRY_COUNTER = "$7EF453"
IncrementFairyRevivalCounter:
STA $7EF35C, X ; thing we wrote over
STA BottleContents, X ; thing we wrote over
PHA
LDA !LOCK_STATS : BNE +
LDA !FAIRY_COUNTER : INC : STA !FAIRY_COUNTER
LDA StatsLocked : BNE +
LDA FaerieRevivalCounter : INC : STA FaerieRevivalCounter
+
PLA
RTL
;--------------------------------------------------------------------------------
!CHESTTURN_COUNTER = "$7EF46D"
IncrementChestTurnCounter:
PHA
LDA !LOCK_STATS : BNE +
LDA !CHESTTURN_COUNTER : INC : STA !CHESTTURN_COUNTER
LDA StatsLocked : BNE +
LDA ChestTurnCounter : INC : STA ChestTurnCounter
+
PLA
RTL
;--------------------------------------------------------------------------------
!CHEST_COUNTER = "$7EF442"
IncrementChestCounter:
LDA.b #$01 : STA $02E9 ; thing we wrote over
PHA
LDA !LOCK_STATS : BNE +
LDA !CHEST_COUNTER : INC : STA !CHEST_COUNTER
LDA StatsLocked : BNE +
LDA ChestsOpened : INC : STA ChestsOpened
+
PLA
RTL
;--------------------------------------------------------------------------------
!CHEST_COUNTER = "$7EF442"
DecrementChestCounter:
PHA
LDA !LOCK_STATS : BNE +
LDA !CHEST_COUNTER : DEC : STA !CHEST_COUNTER
LDA StatsLocked : BNE +
LDA ChestsOpened : DEC : STA ChestsOpened
+
PLA
RTL
;--------------------------------------------------------------------------------
!ITEM_TOTAL = "$7EF423"
DecrementItemCounter:
PHA
LDA !LOCK_STATS : BNE +
LDA StatsLocked : BNE +
REP #$20
LDA !ITEM_TOTAL : DEC : STA !ITEM_TOTAL
LDA TotalItemCounter : DEC : STA TotalItemCounter
SEP #$20
+
PLA
@@ -368,107 +215,102 @@ RTL
IncrementBigChestCounter:
JSL.l Dungeon_SaveRoomQuadrantData ; thing we wrote over
PHA
LDA !LOCK_STATS : BNE +
%BottomHalf($7EF427)
LDA StatsLocked : BNE +
%BottomHalf(BigKeysBigChests)
+
PLA
RTL
;--------------------------------------------------------------------------------
!DAMAGE_COUNTER = $7EF4AA
!MAGIC_COUNTER = $7EF4AC
IncrementDamageTakenCounter_Eight:
STA.l $7EF36D
STA.l CurrentHealth
PHA : PHP
LDA !LOCK_STATS : BNE +
LDA StatsLocked : BNE +
REP #$21
LDA.l !DAMAGE_COUNTER
LDA.l DamageCounter
ADC.w #$0008
BCC ++
LDA.w #$FFFF
++ STA.l !DAMAGE_COUNTER
++ STA.l DamageCounter
+ PLP
PLA
RTL
IncrementDamageTakenCounter_Arb:
PHP
LDA !LOCK_STATS : BNE +
LDA StatsLocked : BNE +
REP #$21
LDA.b $00
AND.w #$00FF
ADC.l !DAMAGE_COUNTER
ADC.l DamageCounter
BCC ++
LDA.w #$FFFF
++ STA.l !DAMAGE_COUNTER
++ STA.l DamageCounter
+ PLP
LDA.l $7EF36D
LDA.l CurrentHealth
RTL
IncrementMagicUseCounter:
STA.l $7EF36E
STA.l CurrentMagic
IncrementMagicUseCounterByrna:
PHA : PHP
LDA !LOCK_STATS : BNE +
LDA StatsLocked : BNE +
REP #$21
LDA.b $00
AND.w #$00FF
ADC.l !MAGIC_COUNTER
ADC.l MagicCounter
BCC ++
LDA.w #$FFFF
++ STA.l !MAGIC_COUNTER
++ STA.l MagicCounter
+ PLP : PLA
RTL
IncrementMagicUseCounterOne:
LDA !LOCK_STATS : BNE +
LDA StatsLocked : BNE +
REP #$20
LDA.l !MAGIC_COUNTER
LDA.l MagicCounter
INC
BEQ ++
STA.l !MAGIC_COUNTER
STA.l MagicCounter
++ SEP #$20
+ LDA.l $7EF36E
+ LDA.l CurrentMagic
RTL
;--------------------------------------------------------------------------------
!OW_MIRROR_COUNTER = "$7EF43A"
IncrementOWMirror:
PHA
LDA #$08 : STA $021B ; fail race game
LDA !LOCK_STATS : BNE +
LDA $7EF3CA : BEQ + ; only do this for DW->LW
LDA !OW_MIRROR_COUNTER : INC : STA !OW_MIRROR_COUNTER
LDA StatsLocked : BNE +
LDA CurrentWorld : BEQ + ; only do this for DW->LW
LDA OverworldMirrors : INC : STA OverworldMirrors
+
PLA
JMP StatTransitionCounter
;--------------------------------------------------------------------------------
!UW_MIRROR_COUNTER = "$7EF43B"
IncrementUWMirror:
PHA
LDA.b #$00 : STA $7F5035 ; bandaid patch bug with mirroring away from text
LDA !LOCK_STATS : BNE +
LDA StatsLocked : BNE +
LDA $040C : CMP #$FF : BEQ + ; skip if we're in a cave or house
LDA !UW_MIRROR_COUNTER : INC : STA !UW_MIRROR_COUNTER
LDA UnderworldMirrors : INC : STA UnderworldMirrors
JSL.l StatTransitionCounter
+
PLA
JSL.l Dungeon_SaveRoomData ; thing we wrote over
RTL
;--------------------------------------------------------------------------------
!SPENT_RUPEES = "$7EF42B"
IncrementSpentRupees:
DEC A : BPL .subtractRupees
LDA.w #$0000 : STA $7EF360
LDA.w #$0000 : STA CurrentRupees
RTL
.subtractRupees
PHA : PHP
LDA !LOCK_STATS : AND.w #$00FF : BNE +
LDA !SPENT_RUPEES : INC
LDA StatsLocked : AND.w #$00FF : BNE +
LDA RupeesSpent : INC
CMP.w #9999 : BEQ + ; decimal 9999
STA !SPENT_RUPEES
STA RupeesSpent
+
PLP : PLA
RTL
@@ -483,71 +325,40 @@ IndoorSubtileTransitionCounter:
STZ $0642
JMP StatTransitionCounter
;--------------------------------------------------------------------------------
!DUNGEON_PRIZE_COLLECTED = "$7EF46B"
!CHEST_COUNTER = "$7EF442"
!MAIL_COUNTER = "$7EF46A" ; mmkkkkkk
!BOSS_KILLS = "$7F5037"
!SWORD_KILLS_1 = "$7EF425"
!SWORD_KILLS_2 = "$7EF426"
!GTOWER_PRE_BIG_KEY = "$7EF42A" ; ---ccccc
!NONCHEST_COUNTER = "$7F503E"
!SAVE_COUNTER = "$7EF42D"
!TRANSITION_COUNTER = "$7EF43C"
!NMI_COUNTER = "$7EF43E"
!LOOP_COUNTER = "$7EF42E"
!LAG_TIME = "$7F5038"
!RUPEES_COLLECTED = "$7F503C"
!ITEM_TOTAL = "$7EF423"
!RTA_END = "$7EF44F"
StatsFinalPrep:
PHA : PHX : PHP
SEP #$30 ; set 8-bit accumulator and index registers
LDA !LOCK_STATS : BNE .ramPostOnly
INC : STA !LOCK_STATS
LDA StatsLocked : BNE .ramPostOnly
INC : STA StatsLocked
JSL.l AddInventory_incrementBossSwordLong
LDA !MAIL_COUNTER : !ADD #$40 : STA !MAIL_COUNTER ; add green mail to mail count
LDA HighestMail : INC : STA HighestMail ; add green mail to mail count
;LDA !GTOWER_PRE_BIG_KEY : DEC : AND #$1F : TAX
;LDA !GTOWER_PRE_BIG_KEY : AND #$E0 : STA !GTOWER_PRE_BIG_KEY
;TXA : ORA !GTOWER_PRE_BIG_KEY : STA !GTOWER_PRE_BIG_KEY
LDA !TRANSITION_COUNTER : DEC : STA !TRANSITION_COUNTER ; remove extra transition from exiting gtower via duck
LDA ScreenTransitions : DEC : STA ScreenTransitions ; remove extra transition from exiting gtower via duck
.ramPostOnly
LDA !SWORD_KILLS_1 : LSR #4 : !ADD !SWORD_KILLS_1 : STA !BOSS_KILLS
LDA !SWORD_KILLS_2 : LSR #4 : !ADD !SWORD_KILLS_2 : !ADD !BOSS_KILLS : AND #$0F : STA !BOSS_KILLS
LDA SwordBossKills : LSR #4 : !ADD SwordBossKills : STA !BOSS_KILLS
LDA SwordBossKills+1 : LSR #4 : !ADD SwordBossKills+1 : !ADD !BOSS_KILLS : AND #$0F : STA !BOSS_KILLS
LDA !NMI_COUNTER : !SUB !LOOP_COUNTER : STA !LAG_TIME
LDA !NMI_COUNTER+1 : SBC !LOOP_COUNTER+1 : STA !LAG_TIME+1
LDA !NMI_COUNTER+2 : SBC !LOOP_COUNTER+2 : STA !LAG_TIME+2
LDA !NMI_COUNTER+3 : SBC !LOOP_COUNTER+3 : STA !LAG_TIME+3
LDA NMIFrames : !SUB LoopFrames : STA !LAG_TIME
LDA NMIFrames+1 : SBC LoopFrames+1 : STA !LAG_TIME+1
LDA NMIFrames+2 : SBC LoopFrames+2 : STA !LAG_TIME+2
LDA NMIFrames+3 : SBC LoopFrames+3 : STA !LAG_TIME+3
LDA !SPENT_RUPEES : !ADD $7EF362 : STA !RUPEES_COLLECTED
LDA !SPENT_RUPEES+1 : ADC $7EF363 : STA !RUPEES_COLLECTED+1
LDA RupeesSpent : !ADD DisplayRupees : STA !RUPEES_COLLECTED
LDA RupeesSpent+1 : ADC DisplayRupees+1 : STA !RUPEES_COLLECTED+1
LDA !ITEM_TOTAL : !SUB !CHEST_COUNTER : STA !NONCHEST_COUNTER
;LDA $FFFFFF
;JSL.l Clock_IsSupported
;BRA +
; REP #$20 ; set 16-bit accumulator
;
; LDA $00 : PHA
; LDA $02 : PHA
;
; JSL.l Clock_QuickStamp
; LDA $00 : STA !RTA_END
; LDA $02 : STA !RTA_END+2
;
; PLA : STA $02
; PLA : STA $00
;+
REP #$20
LDA TotalItemCounter : !SUB ChestsOpened : STA !NONCHEST_COUNTER
.done
PLP : PLX : PLA

View File

@@ -16,15 +16,17 @@ db " " ; $238020
CollectionRateHi:
db 2, 55
db $5F, $6B, $68, $68, $61, $5F, $70, $65, $6B, $6A, $9F, $6E, $5D, $70, $61 ; "Collection Rate"
db $9F, $9F, $9F, $9F, $9F, $9F, $9F, $9F, $9F, $A2 ; " /"
db $9F, $9F, $9F, $9F, $9F, $9F, $9F, $9F ; " " 8 spaces
print "Collection Rate High Start: ", pc
db $9F, $A2 ; " /"
db $55, $54, $59 ; 216
CollectionRateLo:
db 2, 55
db $85, $91, $8E, $8E, $87, $85, $96, $8B, $91, $90, $9F, $94, $83, $96, $87 ; "Collection Rate"
db $9F, $9F, $9F, $9F, $9F, $9F, $9F, $9F, $9F, $C2 ; " /"
db $9F, $9F, $9F, $9F, $9F, $9F, $9F, $9F ; " " 8 spaces
print "Collection Rate Low Start: ", pc
db $9F, $C2 ; " /"
db $7B, $7A, $7F ; 216
;===================================================================================================

View File

@@ -1,21 +1,21 @@
;(address, type, shiftRight, bits, digits, xPos, lineNumber)
%AddStat($7EF458, 1, 0, 32, 4, !FIRST_SWORD_X, !FIRST_SWORD_Y)
%AddStat($7EF45C, 1, 0, 32, 4, !PEGASUS_BOOTS_X, !PEGASUS_BOOTS_Y)
%AddStat($7EF460, 1, 0, 32, 4, !FLUTE_X, !FLUTE_Y)
%AddStat($7EF464, 1, 0, 32, 4, !MIRROR_X, !MIRROR_Y)
%AddStat($7EF452, 0, 4, 04, 2, !SWORDLESS_X, !SWORDLESS_Y)
%AddStat($7EF425, 0, 4, 04, 2, !FIGHTERS_SWORD_X, !FIGHTERS_SWORD_Y)
%AddStat($7EF425, 0, 0, 04, 2, !MASTER_SWORD_X, !MASTER_SWORD_Y)
%AddStat($7EF426, 0, 4, 04, 2, !TEMPERED_SWORD_X, !TEMPERED_SWORD_Y)
%AddStat($7EF426, 0, 0, 04, 2, !GOLD_SWORD_X, !GOLD_SWORD_Y)
%AddStat($7EF4AA, 0, 0, 16, 5, !DAMAGETAKEN_X, !DAMAGETAKEN_Y)
%AddStat($7EF4AC, 0, 0, 16, 5, !MAGICUSED_X, !MAGICUSED_Y)
%AddStat($7EF420, 0, 0, 08, 3, !BONKS_X, !BONKS_Y)
%AddStat($7EF42D, 0, 0, 08, 2, !SAVE_AND_QUITS_X, !SAVE_AND_QUITS_Y)
%AddStat($7EF449, 0, 0, 08, 2, !DEATHS_X, !DEATHS_Y)
%AddStat($7EF453, 0, 0, 08, 3, !FAERIE_REVIVALS_X, !FAERIE_REVIVALS_Y)
%AddStat($7EF444, 1, 8, 32, 4, !TOTAL_MENU_TIME_X, !TOTAL_MENU_TIME_Y)
%AddStat(SwordTime, 1, 0, 32, 4, !FIRST_SWORD_X, !FIRST_SWORD_Y)
%AddStat(BootsTime, 1, 0, 32, 4, !PEGASUS_BOOTS_X, !PEGASUS_BOOTS_Y)
%AddStat(FluteTime, 1, 0, 32, 4, !FLUTE_X, !FLUTE_Y)
%AddStat(MirrorTime, 1, 0, 32, 4, !MIRROR_X, !MIRROR_Y)
%AddStat(SwordlessBossKills, 0, 0, 08, 2, !SWORDLESS_X, !SWORDLESS_Y)
%AddStat(SwordBossKills, 0, 4, 04, 2, !FIGHTERS_SWORD_X, !FIGHTERS_SWORD_Y)
%AddStat(SwordBossKills, 0, 0, 04, 2, !MASTER_SWORD_X, !MASTER_SWORD_Y)
%AddStat(SwordBossKills+1, 0, 4, 04, 2, !TEMPERED_SWORD_X, !TEMPERED_SWORD_Y)
%AddStat(SwordBossKills+1, 0, 0, 04, 2, !GOLD_SWORD_X, !GOLD_SWORD_Y)
%AddStat(DamageCounter, 0, 0, 16, 5, !DAMAGETAKEN_X, !DAMAGETAKEN_Y)
%AddStat(MagicCounter, 0, 0, 16, 5, !MAGICUSED_X, !MAGICUSED_Y)
%AddStat(BonkCounter, 0, 0, 08, 3, !BONKS_X, !BONKS_Y)
%AddStat(SaveQuitCounter, 0, 0, 08, 2, !SAVE_AND_QUITS_X, !SAVE_AND_QUITS_Y)
%AddStat(DeathCounter, 0, 0, 08, 2, !DEATHS_X, !DEATHS_Y)
%AddStat(FaerieRevivalCounter, 0, 0, 08, 3, !FAERIE_REVIVALS_X, !FAERIE_REVIVALS_Y)
%AddStat(MenuFrames, 1, 8, 32, 4, !TOTAL_MENU_TIME_X, !TOTAL_MENU_TIME_Y)
%AddStat($7F5038, 1, 0, 32, 4, !TOTAL_LAG_TIME_X, !TOTAL_LAG_TIME_Y)
%AddStat($7EF423, 0, 0, 10, 3, !COLLECTION_RATE_X, !COLLECTION_RATE_Y)
%AddStat($7EF43E, 1, 0, 32, 4, !TOTAL_TIME_X, !TOTAL_TIME_Y)
%AddStat(TotalItemCounter, 0, 0, 16, 3, !COLLECTION_RATE_X, !COLLECTION_RATE_Y)
%AddStat(NMIFrames, 1, 0, 32, 4, !TOTAL_TIME_X, !TOTAL_TIME_Y)

View File

@@ -20,7 +20,7 @@
;JML.l Smithy_DoesntHaveSword
;================================================================================
;LoadSwordForDamage:
; LDA $7EF359 : CMP #$04 : BNE .done ; skip if not gold sword
; LDA SwordEquipment : CMP #$04 : BNE .done ; skip if not gold sword
; LDA $1B : BEQ + ; skip if outdoors
; LDA $A0 : CMP #41 : BNE + ; decimal 41 ; skip if not in the mothula room
; LDA #$03 ; pretend we're using tempered
@@ -62,20 +62,20 @@ RTL
; $7F50C0 - Sword Modifier
LoadModifiedSwordLevel: ; returns short
LDA $7F50C0 : BEQ +
!ADD $7EF359 ; add normal sword value to modifier
!ADD SwordEquipment ; add normal sword value to modifier
BNE ++ : LDA.b #$01 : RTS : ++
CMP.b #$05 : !BLT ++ : LDA.b #$04 : RTS : ++
RTS
+
LDA $7EF359 ; load normal sword value
LDA SwordEquipment ; load normal sword value
RTS
;================================================================================
; $7EF35B - Armor Inventory
; ArmorEquipment - Armor Inventory
; $7F50C2 - Armor Modifier
; $7F5020 - Scratch Space (Caller Preserved)
LoadModifiedArmorLevel:
PHA
LDA $7EF35B : !ADD $7F50C2
LDA ArmorEquipment : !ADD $7F50C2
CMP.b #$FF : BNE + : LDA.b #$00 : +
CMP.b #$03 : !BLT + : LDA.b #$02 : +
STA $7F5020
@@ -83,16 +83,16 @@ LoadModifiedArmorLevel:
!ADD $7F5020
RTL
;================================================================================
; $7EF37B - Magic Inventory
; MagicConsumption - Magic Inventory
; $7F50C3 - Magic Modifier
LoadModifiedMagicLevel:
LDA $7F50C3 : BEQ +
!ADD $7EF37B ; add normal magic value to modifier
!ADD MagicConsumption ; add normal magic value to modifier
CMP.b #$FF : BNE ++ : LDA.b #$00 : RTL : ++
CMP.b #$03 : !BLT ++ : LDA.b #$02 : ++
RTL
+
LDA $7EF37B ; load normal magic value
LDA MagicConsumption ; load normal magic value
RTL
;================================================================================
; $7E0348 - Ice Value
@@ -116,17 +116,17 @@ RTL
;================================================================================
CheckTabletSword:
LDA.l AllowHammerTablets : BEQ +
LDA $7EF34B : BEQ + ; check for hammer
LDA HammerEquipment : BEQ + ; check for hammer
LDA.b #$02 : RTL
+
LDA $7EF359 ; get actual sword value
LDA SwordEquipment ; get actual sword value
RTL
;================================================================================
GetSwordLevelForEvilBarrier:
LDA.l AllowHammerEvilBarrierWithFighterSword : BEQ +
LDA #$FF : RTL
+
LDA $7EF359
LDA SwordEquipment
RTL
;================================================================================
CheckGanonHammerDamage:
@@ -143,7 +143,7 @@ GetSmithSword:
JML.l Smithy_DoesntHaveSword ; Classic Smithy
+
REP #$20 : LDA $7EF360 : CMP #$000A : SEP #$20 : !BGE .buy
REP #$20 : LDA CurrentRupees : CMP #$000A : SEP #$20 : !BGE .buy
.cant_afford
REP #$10
LDA.b #$7A
@@ -159,7 +159,7 @@ GetSmithSword:
STZ $02E9 ; Item from NPC
PHX : JSL Link_ReceiveItem : PLX
REP #$20 : LDA $7EF360 : !SUB.w #$000A : STA $7EF360 : SEP #$20 ; Take 10 rupees
REP #$20 : LDA CurrentRupees : !SUB.w #$000A : STA CurrentRupees : SEP #$20 ; Take 10 rupees
JSL ItemSet_SmithSword
.done
@@ -171,7 +171,7 @@ CheckMedallionSword:
LDA.b #$02 ; Pretend we have master sword
RTL
.check_sword
LDA $7EF359
LDA SwordEquipment
RTL
.check_pad
PHB : PHX : PHY
@@ -209,19 +209,19 @@ CheckMedallionSword:
.outdoors
LDA $8A : CMP.b #$70 : BNE +
LDA.l MireRequiredMedallion : TAX : LDA.l .medallion_type, X : CMP $0303 : BNE .done
LDA $7EF2F0 : AND.b #$20 : BNE .done
LDA OverworldEventDataWRAM+$70 : AND.b #$20 : BNE .done
LDA.b #$08 : PHA : PLB ; set data bank to $08
LDY.b #$02 : JSL.l Ancilla_CheckIfEntranceTriggered : BCS .permit ; misery mire
BRA .done
+ : CMP.b #$47 : BNE +
LDA.l TRockRequiredMedallion : TAX : LDA.l .medallion_type, X : CMP $0303 : BNE .done
LDA $7EF2C7 : AND.b #$20 : BNE .done
LDA OverworldEventDataWRAM+$47 : AND.b #$20 : BNE .done
LDA.b #$08 : PHA : PLB ; set data bank to $08
LDY.b #$03 : JSL.l Ancilla_CheckIfEntranceTriggered : BCS .permit ; turtle rock
+
.done
PLY : PLX : PLB
LDA $7EF359
LDA SwordEquipment
RTL
.permit
SEP #$20 ; set 8-bit accumulator

View File

@@ -98,19 +98,13 @@ db #$02 ; #$02 = Tempered Sword (default)
;org $05EBD4 ; PC 0x2EBD4 - sprite_zelda.asm:23 - (LDA $7EF359 : CMP.b #$02 : BCS .hasMasterSword) - Zelda Spawnpoint Sword Check
;db #$05 ; #$02 = Tempered Sword (default) - #$05 = All Swords
;--------------------------------------------------------------------------------
; 0x18002B- 0x18002F (Unused)
;--------------------------------------------------------------------------------
org $308030 ; PC 0x180030
EnableSRAMTrace:
db #$00 ; #$00 = Off (default) - #$01 = On
; 0x18002B- 0x180030 (Unused)
;--------------------------------------------------------------------------------
org $308031 ; PC 0x180031
EnableEasterEggs:
db #$00 ; #$00 = Off (default) - #$01 = On
;--------------------------------------------------------------------------------
org $308032 ; PC 0x180032
OpenMode:
db #$01 ; #$00 = Normal (default) - #$01 = Open
; 0x180032 (unused)
;--------------------------------------------------------------------------------
org $308033 ; PC 0x180033
HeartBeep:
@@ -164,9 +158,7 @@ org $30803F ; PC 0x18003F
HammerableGanon:
db #$00 ; #$00 = Off (default) - #$01 = On
;--------------------------------------------------------------------------------
org $308040 ; PC 0x180040
PreopenCurtains:
db #$00 ; #$00 = Off (default) - #$01 = On
; 0x180040 - (unused)
;--------------------------------------------------------------------------------
org $308041 ; PC 0x180041
AllowSwordlessMedallionUse:
@@ -176,9 +168,7 @@ org $308042 ; PC 0x180042
PermitSQFromBosses:
db #$00 ; #$00 = Off (default) - #$01 = On
;--------------------------------------------------------------------------------
org $308043 ; PC 0x180043
StartingSword:
db #$00 ; #$00 = No Sword (default) - #$FF = Non-Sword
; 0x180043 (unused)
;--------------------------------------------------------------------------------
org $308044 ; PC 0x180044
AllowHammerTablets:
@@ -193,9 +183,7 @@ HUDDungeonItems:
; display ---edcba a: Small Keys, b: Big Key, c: Map, d: Compass, e: Bosses
db #$00
;--------------------------------------------------------------------------------
org $308046 ; PC 0x180046 Link's starting equipment
LinkStartingRupees:
dw #$0000
; 0x180046 (unused)
;--------------------------------------------------------------------------------
org $308048 ; PC 0x180048
MenuSpeed:
@@ -386,17 +374,7 @@ org $30808A ; PC 0x18008A
BlockCastleDoorsInRain:
db #$00 ; #$00 - Normal, $01 - Block them (Used by Entrance Rando in Standard Mode)
;--------------------------------------------------------------------------------
org $30808B ; PC 0x18008B
PreopenPyramid:
db $00 ; #$00 = Off (default) - #$01 = On
;--------------------------------------------------------------------------------
org $30808C ; PC 0x18008C
PreopenGanonsTower:
db $00 ; #$00 = Off (default) - #$01 = On
;--------------------------------------------------------------------------------
org $30808D ; PC 0x18008D
InstantPostAgaWorldState:
db $00 ; #$00 = Off (default) - #$01 = On
; 0x18008B-0x18008D (unused)
;--------------------------------------------------------------------------------
org $30808E ; PC 0x18008E
FakeBoots:
@@ -841,13 +819,9 @@ org $308165 ; PC 0x180165
GoalItemIcon:
dw #$280E ; #$280D = Star - #$280E = Triforce Piece (default)
;================================================================================
org $308167 ; PC 0x180167
org $308167 ; PC 0x180167-0x180167
GoalItemRequirement:
db #$00 ; #$00 = Off (default) - #$XX = Require $XX Goal Items - #$FF = Counter-Only
;================================================================================
org $308168 ; PC 0x180168
ByrnaCaveSpikeDamage:
db #$08 ; #$08 = 1 Heart (default) - #$02 = 1/4 Heart
dw $0000 ; #$0000 = Off (default) - #$XXXX = Require $XX Goal Items - #$FFFF = Counter-Only
;================================================================================
org $308169 ; PC 0x180169
AgahnimDoorStyle:
@@ -970,17 +944,22 @@ org $308194 ; PC 0x180194
TurnInGoalItems:
db #$01 ; #$00 = Instant win if last goal item collected. $01 = (Default) must turn in goal items
;--------------------------------------------------------------------------------
; 0x180195 - 0x1801FF (unused)
org $308195 ; PC 0x180195
ByrnaCaveSpikeDamage:
db #$08 ; #$08 = 1 Heart (default) - #$02 = 1/4 Heart
;--------------------------------------------------------------------------------
; 0x180196 - 0x1801FF (unused)
;================================================================================
org $308200 ; PC 0x180200 - 0x18020F
org $308200 ; PC 0x180200 - 0x18020B
RedClockAmount:
dw #$4650, #$0000 ; $00004650 = +5 minutes
BlueClockAmount:
dw #$B9B0, #$FFFF ; $FFFFB9B0 = -5 minutes
GreenClockAmount:
dw #$0000, #$0000
StartingTime:
dw #$0000, #$0000 ; #$A5E0, #$0001 = 30 minutes
;--------------------------------------------------------------------------------
; 0x18020C-0x18020F (unused)
;--------------------------------------------------------------------------------
;================================================================================
org $09E3BB ; PC 0x4E3BB
db $E4 ; Hera Basement Key (Set to programmable HP $EB) (set to $E4 for original hookable/boomable key behavior)
@@ -1520,7 +1499,8 @@ dw #9999 ; Rupee Limit
; $7F5042 - Tile Upload Offset Override (Low)
; $7F5043 - Tile Upload Offset Override (High)
; $7F5044 - $7F5046 - NMI Auxiliary Function
; $7F5047 - $7F504E - Unused
; $7F5047 - $7F5048 - Multiworld NMI Flags
; $7F5049 - $7F504E - Unused
; $7F504F - $7F506F - Shop Block
; $7F5070 - Reserved for OneMind
; $7F5071 - Reserved for OneMind
@@ -1575,9 +1555,9 @@ dw #9999 ; Rupee Limit
; $7F5300 - $7F53FF - Multiworld Block
; $7F5400 - $7F540F - MSU Block
; $7F5410 - $7F56FF - Unused
; $7F5420 - MapCompass flag - used during Overworld Map processing
; $7F5421 - $7F56FF - Unused
; $7F5410 - $7F545F - Dungeon Tracking Block
; $7F5460 - MapCompass flag - used during Overworld Map processing
; $7F5470 - $7F56FF - Unused
; $7F5700 - $7F57FF - Dialog Buffer
;
@@ -1627,41 +1607,26 @@ dw $0000
;--------------------------------------------------------------------------------
; 0x182305 - 182FFF (unused)
;================================================================================
org $30B000 ; PC 0x183000 - 0x1832FF
StartingRoomData:
; reserved for Room Data
org $30B000 ; PC 0x183000 - 0x1834FF
incsrc initsramtable.asm
org $30B280 ; PC 0x183280 - 0x1832FF
StartingOverworldEvents:
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
org $30B340 ; PC 0x183340 - 0x183393
StartingEquipment:
dw $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000
dw $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000
dw $0000, $0000, $0000, $0000, $0000, $0000, $1818, $FF00
dw $0000, $0000, $0000, $0000, $F800, $0000, $0000, $0000
dw $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000
dw $0000, $0000
;--------------------------------------------------------------------------------
; 0x183394 - 183FFF (unused)
; 0x183500 - 183FFF (unused)
;================================================================================
org $30C000 ; PC 0x184000 - 0x184007
org $30C000 ; PC 0x184000 - 0x184040
ItemSubstitutionRules:
;db [item][quantity][substitution][pad] - CURRENT LIMIT 16 ENTRIES
db $12, $01, $35, $FF
db $51, $06, $52, $FF
db $53, $06, $54, $FF
db $FF, $FF, $FF, $FF
org $30C041 ; PC 0x184041
ForceFileName:
db $00 ; $00 = Player picks name (default) - $01 = Use StaticFileName (initsramtable.asm)
;--------------------------------------------------------------------------------
; 0x184008 - 0x1847FF (unused)
; 0x18405B - 0x1847FF (unused)
;================================================================================
;shop_config - tdav --qq
; t - 0=Shop - 1=TakeAny
@@ -1686,11 +1651,6 @@ db $01, $51, $64, $00, $07, $FF, $00, $00, $00
db $01, $53, $64, $00, $07, $FF, $00, $00, $00
db $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF
; Fix spawning with more hearts than capacity when less than 3 heart containers
LowHeartFix:
org $09F4AC ; <- module_death.asm:331
db $08, $08, $10
;--------------------------------------------------------------------------------
; 0x185060 - 1850FF (unused)
;--------------------------------------------------------------------------------
@@ -1914,13 +1874,34 @@ db #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00,
db #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00
;--------------------------------------------------------------------------------
; 0x186380 - 187FFF (unused)
; 0x186C00 - 186FFE (unused)
;--------------------------------------------------------------------------------
org $30EFFF ; PC 0x186FFF
BallNChainDungeon:
db #$02
org $30EFE0 ; PC 0x186FE0-0x186FEF
CrystalPendantFlags_3:
db $00 ; Sewers
db $00 ; Hyrule Castle
db $08 ; Eastern Palace
db $09 ; Desert Palace
db $00 ; Agahnim's Tower
db $02 ; Swamp Palace
db $01 ; Palace of Darkness
db $06 ; Misery Mire
db $03 ; Skull Woods
db $05 ; Ice Palace
db $0A ; Tower of Hera
db $04 ; Thieves' Town
db $07 ; Turtle Rock
db $00 ; Ganons Tower
; 00 - No Prize. 01 - 07 Crystal Number 08 - Green Pendant 09 - Blue Pendant, 0A - Red Pendant
org $30F000 ; PC 0x187000-0x18700F
CompassTotal:
CompassTotalsROM:
db $08, $08, $06, $06, $02, $0A, $0E, $08, $08, $08, $06, $08, $0C, $1B, $00, $00
;--------------------------------------------------------------------------------
; 0x187010 - 187FFF (unused)
;--------------------------------------------------------------------------------

View File

@@ -2,19 +2,19 @@
; Randomize Tablets
;--------------------------------------------------------------------------------
ItemSet_EtherTablet:
PHA : LDA !NPC_FLAGS_2 : ORA.b #$01 : STA !NPC_FLAGS_2 : PLA
PHA : LDA NpcFlags+1 : ORA.b #$01 : STA NpcFlags+1 : PLA
RTL
;--------------------------------------------------------------------------------
ItemSet_BombosTablet:
PHA : LDA !NPC_FLAGS_2 : ORA.b #$02 : STA !NPC_FLAGS_2 : PLA
PHA : LDA NpcFlags+1 : ORA.b #$02 : STA NpcFlags+1 : PLA
RTL
;--------------------------------------------------------------------------------
ItemCheck_EtherTablet:
LDA !NPC_FLAGS_2 : AND.b #$01
LDA NpcFlags+1 : AND.b #$01
RTL
;--------------------------------------------------------------------------------
ItemCheck_BombosTablet:
LDA !NPC_FLAGS_2 : AND.b #$02
LDA NpcFlags+1 : AND.b #$02
RTL
;--------------------------------------------------------------------------------
SetTabletItem:

View File

@@ -2,8 +2,6 @@
; Challenge Timer
;================================================================================
!Temp = "$7F5020"
!BaseTimer = "$7EF43E"
!ChallengeTimer = "$7EF454"
!TemporaryOHKO = "$7F50CC"
;--------------------------------------------------------------------------------
!CLOCK_HOURS = "$7F5080" ; $7F5080 - $7F5083 - Clock Hours
@@ -58,17 +56,17 @@ CalculateTimer:
STA.l !CLOCK_SECONDS+2
LDA.l TimerStyle : AND.w #$00FF : CMP.w #$0002 : BNE + ; Stopwatch Mode
%Sub32(!BaseTimer,!ChallengeTimer,!CLOCK_TEMPORARY)
%Sub32(NMIFrames,ChallengeTimer,!CLOCK_TEMPORARY)
BRA ++
+ CMP.w #$0001 : BNE ++ ; Countdown Mode
%Sub32(!ChallengeTimer,!BaseTimer,!CLOCK_TEMPORARY)
%Sub32(ChallengeTimer,NMIFrames,!CLOCK_TEMPORARY)
++
%Blt32(!CLOCK_TEMPORARY,.halfCycle) : !BLT +
LDA.l TimeoutBehavior : AND.w #$00FF : BNE ++ ; DNF
LDA.w #$0002 : STA.l !Status ; Set DNF Mode
LDA.l !BaseTimer : STA.l !ChallengeTimer
LDA.l !BaseTimer+2 : STA.l !ChallengeTimer+2
LDA.l NMIFrames : STA.l ChallengeTimer
LDA.l NMIFrames+2 : STA.l ChallengeTimer+2
RTS
++ CMP.w #$0001 : BNE ++ ; Negative Time
LDA.l !CLOCK_TEMPORARY : EOR.w #$FFFF : !ADD.w #$0001 : STA.l !CLOCK_TEMPORARY
@@ -77,8 +75,8 @@ CalculateTimer:
BRA .prepDigits
++ CMP.w #$0002 : BNE ++ ; OHKO
LDA.w #$0002 : STA.l !Status ; Set DNF Mode
LDA.l !BaseTimer : STA.l !ChallengeTimer
LDA.l !BaseTimer+2 : STA.l !ChallengeTimer+2
LDA.l NMIFrames : STA.l ChallengeTimer
LDA.l NMIFrames+2 : STA.l ChallengeTimer+2
RTS
++ ; End Game
SEP #$30
@@ -182,8 +180,8 @@ OHKOTimer:
LDA.l TimeoutBehavior : CMP #$02 : BNE +
LDA !Status : AND.b #$02 : BEQ +
.kill
LDA.b #$00 : STA $7EF36D ; kill link
LDA.b #$00 : STA CurrentHealth ; kill link
+
LDA $7EF36D
LDA CurrentHealth
RTL
;--------------------------------------------------------------------------------

View File

@@ -1,8 +1,8 @@
;================================================================================
; Tree Kid Fix
;--------------------------------------------------------------------------------
org $06B12B ; <- 3312B - tree status set - 418 - LDA $7EF3C9 : ORA.b #$08 : STA $7EF3C9
LDA $7EF3C9 : AND.b #$F7 : STA $7EF3C9 ; unset arboration instead of setting it
org $06B12B ; <- 3312B - tree status set - 418 - LDA NpcFlagsVanilla : ORA.b #$08 : STA NpcFlagsVanilla
LDA NpcFlagsVanilla : AND.b #$F7 : STA NpcFlagsVanilla ; unset arboration instead of setting it
;--------------------------------------------------------------------------------
org $06B072 ; <- 33072 - FluteAardvark_InitialStateFromFluteState - 418 : dw FluteAardvark_AlreadyArborated
db #$8B

128
util/utils.asm Normal file
View File

@@ -0,0 +1,128 @@
HexToDec4Digit_fast:
LDY.b #$00
-
CMP.w #1000 : !BLT +
INY
SBC.w #1000 : BRA -
+
STY $04
JSR hex_to_dec_fast
RTL
HexToDec_fast:
JSR hex_to_dec_fast
RTL
hex_to_dec_fast:
PHP
REP #$30
ASL : TAX
LDA.l hex_to_dec_fast_table,X
TAY : XBA : AND.w #$000F : STA.b $05
TYA : AND.w #$00F0 : LSR #4 : STA.b $06
TYA : AND.w #$000F : STA.b $07
PLP
RTS
hex_to_dec_fast_table:
dw $000, $001, $002, $003, $004, $005, $006, $007, $008, $009
dw $010, $011, $012, $013, $014, $015, $016, $017, $018, $019
dw $020, $021, $022, $023, $024, $025, $026, $027, $028, $029
dw $030, $031, $032, $033, $034, $035, $036, $037, $038, $039
dw $040, $041, $042, $043, $044, $045, $046, $047, $048, $049
dw $050, $051, $052, $053, $054, $055, $056, $057, $058, $059
dw $060, $061, $062, $063, $064, $065, $066, $067, $068, $069
dw $070, $071, $072, $073, $074, $075, $076, $077, $078, $079
dw $080, $081, $082, $083, $084, $085, $086, $087, $088, $089
dw $090, $091, $092, $093, $094, $095, $096, $097, $098, $099
dw $100, $101, $102, $103, $104, $105, $106, $107, $108, $109
dw $110, $111, $112, $113, $114, $115, $116, $117, $118, $119
dw $120, $121, $122, $123, $124, $125, $126, $127, $128, $129
dw $130, $131, $132, $133, $134, $135, $136, $137, $138, $139
dw $140, $141, $142, $143, $144, $145, $146, $147, $148, $149
dw $150, $151, $152, $153, $154, $155, $156, $157, $158, $159
dw $160, $161, $162, $163, $164, $165, $166, $167, $168, $169
dw $170, $171, $172, $173, $174, $175, $176, $177, $178, $179
dw $180, $181, $182, $183, $184, $185, $186, $187, $188, $189
dw $190, $191, $192, $193, $194, $195, $196, $197, $198, $199
dw $200, $201, $202, $203, $204, $205, $206, $207, $208, $209
dw $210, $211, $212, $213, $214, $215, $216, $217, $218, $219
dw $220, $221, $222, $223, $224, $225, $226, $227, $228, $229
dw $230, $231, $232, $233, $234, $235, $236, $237, $238, $239
dw $240, $241, $242, $243, $244, $245, $246, $247, $248, $249
dw $250, $251, $252, $253, $254, $255, $256, $257, $258, $259
dw $260, $261, $262, $263, $264, $265, $266, $267, $268, $269
dw $270, $271, $272, $273, $274, $275, $276, $277, $278, $279
dw $280, $281, $282, $283, $284, $285, $286, $287, $288, $289
dw $290, $291, $292, $293, $294, $295, $296, $297, $298, $299
dw $300, $301, $302, $303, $304, $305, $306, $307, $308, $309
dw $310, $311, $312, $313, $314, $315, $316, $317, $318, $319
dw $320, $321, $322, $323, $324, $325, $326, $327, $328, $329
dw $330, $331, $332, $333, $334, $335, $336, $337, $338, $339
dw $340, $341, $342, $343, $344, $345, $346, $347, $348, $349
dw $350, $351, $352, $353, $354, $355, $356, $357, $358, $359
dw $360, $361, $362, $363, $364, $365, $366, $367, $368, $369
dw $370, $371, $372, $373, $374, $375, $376, $377, $378, $379
dw $380, $381, $382, $383, $384, $385, $386, $387, $388, $389
dw $390, $391, $392, $393, $394, $395, $396, $397, $398, $399
dw $400, $401, $402, $403, $404, $405, $406, $407, $408, $409
dw $410, $411, $412, $413, $414, $415, $416, $417, $418, $419
dw $420, $421, $422, $423, $424, $425, $426, $427, $428, $429
dw $430, $431, $432, $433, $434, $435, $436, $437, $438, $439
dw $440, $441, $442, $443, $444, $445, $446, $447, $448, $449
dw $450, $451, $452, $453, $454, $455, $456, $457, $458, $459
dw $460, $461, $462, $463, $464, $465, $466, $467, $468, $469
dw $470, $471, $472, $473, $474, $475, $476, $477, $478, $479
dw $480, $481, $482, $483, $484, $485, $486, $487, $488, $489
dw $490, $491, $492, $493, $494, $495, $496, $497, $498, $499
dw $500, $501, $502, $503, $504, $505, $506, $507, $508, $509
dw $510, $511, $512, $513, $514, $515, $516, $517, $518, $519
dw $520, $521, $522, $523, $524, $525, $526, $527, $528, $529
dw $530, $531, $532, $533, $534, $535, $536, $537, $538, $539
dw $540, $541, $542, $543, $544, $545, $546, $547, $548, $549
dw $550, $551, $552, $553, $554, $555, $556, $557, $558, $559
dw $560, $561, $562, $563, $564, $565, $566, $567, $568, $569
dw $570, $571, $572, $573, $574, $575, $576, $577, $578, $579
dw $580, $581, $582, $583, $584, $585, $586, $587, $588, $589
dw $590, $591, $592, $593, $594, $595, $596, $597, $598, $599
dw $600, $601, $602, $603, $604, $605, $606, $607, $608, $609
dw $610, $611, $612, $613, $614, $615, $616, $617, $618, $619
dw $620, $621, $622, $623, $624, $625, $626, $627, $628, $629
dw $630, $631, $632, $633, $634, $635, $636, $637, $638, $639
dw $640, $641, $642, $643, $644, $645, $646, $647, $648, $649
dw $650, $651, $652, $653, $654, $655, $656, $657, $658, $659
dw $660, $661, $662, $663, $664, $665, $666, $667, $668, $669
dw $670, $671, $672, $673, $674, $675, $676, $677, $678, $679
dw $680, $681, $682, $683, $684, $685, $686, $687, $688, $689
dw $690, $691, $692, $693, $694, $695, $696, $697, $698, $699
dw $700, $701, $702, $703, $704, $705, $706, $707, $708, $709
dw $710, $711, $712, $713, $714, $715, $716, $717, $718, $719
dw $720, $721, $722, $723, $724, $725, $726, $727, $728, $729
dw $730, $731, $732, $733, $734, $735, $736, $737, $738, $739
dw $740, $741, $742, $743, $744, $745, $746, $747, $748, $749
dw $750, $751, $752, $753, $754, $755, $756, $757, $758, $759
dw $760, $761, $762, $763, $764, $765, $766, $767, $768, $769
dw $770, $771, $772, $773, $774, $775, $776, $777, $778, $779
dw $780, $781, $782, $783, $784, $785, $786, $787, $788, $789
dw $790, $791, $792, $793, $794, $795, $796, $797, $798, $799
dw $800, $801, $802, $803, $804, $805, $806, $807, $808, $809
dw $810, $811, $812, $813, $814, $815, $816, $817, $818, $819
dw $820, $821, $822, $823, $824, $825, $826, $827, $828, $829
dw $830, $831, $832, $833, $834, $835, $836, $837, $838, $839
dw $840, $841, $842, $843, $844, $845, $846, $847, $848, $849
dw $850, $851, $852, $853, $854, $855, $856, $857, $858, $859
dw $860, $861, $862, $863, $864, $865, $866, $867, $868, $869
dw $870, $871, $872, $873, $874, $875, $876, $877, $878, $879
dw $880, $881, $882, $883, $884, $885, $886, $887, $888, $889
dw $890, $891, $892, $893, $894, $895, $896, $897, $898, $899
dw $900, $901, $902, $903, $904, $905, $906, $907, $908, $909
dw $910, $911, $912, $913, $914, $915, $916, $917, $918, $919
dw $920, $921, $922, $923, $924, $925, $926, $927, $928, $929
dw $930, $931, $932, $933, $934, $935, $936, $937, $938, $939
dw $940, $941, $942, $943, $944, $945, $946, $947, $948, $949
dw $950, $951, $952, $953, $954, $955, $956, $957, $958, $959
dw $960, $961, $962, $963, $964, $965, $966, $967, $968, $969
dw $970, $971, $972, $973, $974, $975, $976, $977, $978, $979
dw $980, $981, $982, $983, $984, $985, $986, $987, $988, $989
dw $990, $991, $992, $993, $994, $995, $996, $997, $998, $999

View File

@@ -1,8 +1,6 @@
;================================================================================
; Utility Functions
;================================================================================
!PROGRESSIVE_SHIELD = "$7EF416" ; ss-- ----
;--------------------------------------------------------------------------------
; GetSpriteTile
; in: A - Loot ID
; out: A - Sprite GFX ID
@@ -46,7 +44,7 @@ GetSpriteID:
RTL
.specialHandling
CMP.b #$F9 : BNE ++ ; Progressive Magic
LDA.l $7EF37B : BNE +++
LDA.l MagicConsumption : BNE +++
LDA.b #$3B : RTL ; Half Magic
+++
LDA.b #$3C : RTL ; Quarter Magic
@@ -56,18 +54,18 @@ RTL
JSL.l GetRNGItemMulti : JMP GetSpriteID
++ CMP.b #$FD : BNE ++ ; Progressive Armor
LDA !MULTIWORLD_SPRITEITEM_PLAYER_ID : BNE +
LDA $7EF35B : CMP.l ProgressiveArmorLimit : !BLT + ; Progressive Armor Limit
LDA ArmorEquipment : CMP.l ProgressiveArmorLimit : !BLT + ; Progressive Armor Limit
LDA.l ProgressiveArmorReplacement
JMP GetSpriteID
+
LDA.b #$04 : RTL
++ CMP.b #$FE : BNE ++ ; Progressive Sword
LDA !MULTIWORLD_SPRITEITEM_PLAYER_ID : BNE .skipswordlimit
LDA $7EF359
LDA HighestSword
CMP.l ProgressiveSwordLimit : !BLT + ; Progressive Sword Limit
LDA.l ProgressiveSwordReplacement
JMP GetSpriteID
.skipswordlimit : LDA $7EF359
.skipswordlimit : LDA SwordEquipment
+ : CMP.b #$FF : BNE + ; Swordless
LDA.b #$43 : RTL
+ : CMP.b #$00 : BNE + ; No Sword
@@ -81,11 +79,11 @@ RTL
+
++ : CMP.b #$FF : BNE ++ ; Progressive Shield
LDA !MULTIWORLD_SPRITEITEM_PLAYER_ID : BNE .skipshieldlimit
LDA !PROGRESSIVE_SHIELD : AND #$C0 : LSR #6
LDA HighestShield
CMP.l ProgressiveShieldLimit : !BLT + ; Progressive Shield Limit
LDA.l ProgressiveShieldReplacement
JMP GetSpriteID
.skipshieldlimit : LDA !PROGRESSIVE_SHIELD : AND #$C0 : LSR #6
.skipshieldlimit : LDA.l HighestShield
+ : CMP.b #$00 : BNE + ; No Shield
LDA.b #$2D : RTL
+ : CMP.b #$01 : BNE + ; Fighter Shield
@@ -94,11 +92,11 @@ RTL
LDA.b #$2E : RTL
++ : CMP.b #$F8 : BNE ++ ; Progressive Bow
LDA !MULTIWORLD_SPRITEITEM_PLAYER_ID : BNE .skipbowlimit
LDA $7EF340 : INC : LSR
LDA BowEquipment : INC : LSR
CMP.l ProgressiveBowLimit : !BLT +
LDA.l ProgressiveBowReplacement
JMP GetSpriteID
.skipbowlimit : LDA $7EF340 : INC : LSR
.skipbowlimit : LDA BowEquipment : INC : LSR
+ : CMP.b #$00 : BNE + ; No Bow
LDA.b #$29 : RTL
+ ; Any Bow
@@ -194,7 +192,7 @@ GetSpritePalette:
RTL
.specialHandling
CMP.b #$FD : BNE ++ ; Progressive Sword
LDA $7EF359
LDA HighestSword
CMP.l ProgressiveSwordLimit : !BLT + ; Progressive Sword Limit
LDA.l ProgressiveSwordReplacement
JMP GetSpritePalette
@@ -207,7 +205,7 @@ RTL
+ ; Everything Else
LDA.b #$08 : RTL
++ : CMP.b #$FE : BNE ++ ; Progressive Shield
LDA !PROGRESSIVE_SHIELD : AND #$C0 : LSR #6
LDA HighestShield
CMP.l ProgressiveShieldLimit : !BLT + ; Progressive Shield Limit
LDA.l ProgressiveShieldReplacement
JMP GetSpritePalette
@@ -218,7 +216,8 @@ RTL
+ ; Everything Else
LDA.b #$08 : RTL
++ : CMP.b #$FF : BNE ++ ; Progressive Armor
LDA $7EF35B : CMP.l ProgressiveArmorLimit : !BLT + ; Progressive Armor Limit
LDA HighestMail
CMP.l ProgressiveArmorLimit : !BLT + ; Progressive Armor Limit
LDA.l ProgressiveArmorReplacement
JMP GetSpritePalette
+ : CMP.b #$00 : BNE + ; Green Tunic
@@ -226,12 +225,12 @@ RTL
+ ; Everything Else
LDA.b #$02 : RTL
++ : CMP.b #$FC : BNE ++ ; Progressive Gloves
LDA $7EF354 : BNE + ; No Gloves
LDA GloveEquipment : BNE + ; No Gloves
LDA.b #$02 : RTL
+ ; Everything Else
LDA.b #$08 : RTL
++ : CMP.b #$F8 : BNE ++ ; Progressive Bow
LDA $7EF340 : INC : LSR
LDA BowEquipment : INC : LSR
CMP.l ProgressiveBowLimit : !BLT +
LDA.l ProgressiveBowReplacement
JMP GetSpritePalette
@@ -319,19 +318,19 @@ IsNarrowSprite:
+ : JMP .continue
.notBottle
CMP.b #$5E : BNE ++ ; Progressive Sword
LDA $7EF359 : CMP.l ProgressiveSwordLimit : !BLT + ; Progressive Sword Limit
LDA HighestSword : CMP.l ProgressiveSwordLimit : !BLT + ; Progressive Sword Limit
LDA.l ProgressiveSwordReplacement
JSL.l IsNarrowSprite
JMP .done
+ : JMP .continue
++ CMP.b #$5F : BNE ++ ; Progressive Shield
LDA !PROGRESSIVE_SHIELD : AND #$C0 : BNE + : SEC : JMP .done ; No Shield
+ : LSR #6 : CMP.l ProgressiveShieldLimit : !BLT .continue
LDA HighestShield : BNE + : JMP .done ; No Shield
+ : CMP.l ProgressiveShieldLimit : !BLT .continue
LDA.l ProgressiveShieldReplacement
JSL.l IsNarrowSprite
JMP .done
++ CMP.b #$60 : BNE ++ ; Progressive Armor
LDA $7EF35B : CMP.l ProgressiveArmorLimit : !BLT .continue
LDA HighestMail : CMP.l ProgressiveArmorLimit : !BLT .continue
LDA.l ProgressiveArmorReplacement
JSL.l IsNarrowSprite
JMP .done
@@ -342,7 +341,7 @@ IsNarrowSprite:
JSL.l GetRNGItemMulti
++ CMP.b #$64 : BEQ + ; Progressive Bow
CMP.b #$65 : BNE .continue ; Progressive Bow (alt)
+ : LDA $7EF340 : INC : LSR
+ : LDA BowEquipment : INC : LSR
CMP.l ProgressiveBowLimit : !BLT +
LDA.l ProgressiveBowReplacement
JSL.l IsNarrowSprite
@@ -682,19 +681,19 @@ RTL
; out: A(b) - sum of bits
; caller is responsible for setting 8-bit mode and preserving X and Y
;--------------------------------------------------------------------------------
CountBits:
PHX
TAX ; Save a copy of value
LSR #4 ; Shift down hi nybble, Leave <3> in C
PHA ; And save <7:4> in Stack
TXA ; Recover value
AND.b #$07 ; Put out <2:0> in X
TAX ; And save in X
LDA.l NybbleBitCounts, X ; Fetch count for <2:0>
PLX ; get <7:4>
ADC.l NybbleBitCounts, X ; Add count for S & C
PLX
RTL
;CountBits:
; PHX
; TAX ; Save a copy of value
; LSR #4 ; Shift down hi nybble, Leave <3> in C
; PHA ; And save <7:4> in Stack
; TXA ; Recover value
; AND.b #$07 ; Put out <2:0> in X
; TAX ; And save in X
; LDA.l NybbleBitCounts, X ; Fetch count for <2:0>
; PLX ; get <7:4>
; ADC.l NybbleBitCounts, X ; Add count for S & C
; PLX
;RTL
; Look up table of bit counts in the values $00-$0F
NybbleBitCounts:

View File

@@ -2,17 +2,18 @@
; Spawn Zelda (or not)
;--------------------------------------------------------------------------------
SpawnZelda:
LDA.l $7EF3CC : CMP #$08 : BEQ + ; don't spawn if dwarf is present
CMP #$07 : BEQ + ; don't spawn if frog is present
CMP #$0C : BEQ + ; don't spawn if purple chest is present
LDA.l FollowerIndicator : CMP.b #$08 : BEQ + ; don't spawn if dwarf is present
CMP.b #$07 : BEQ + ; don't spawn if frog is present
CMP.b #$0C : BEQ + ; don't spawn if purple chest is present
CLC
+ RTL
;--------------------------------------------------------------------------------
EndRainState:
LDA $7EF3C5 : CMP.b #$02 : !BGE + ; skip if past escape already
LDA.b #$00 : STA !INFINITE_ARROWS : STA !INFINITE_BOMBS : STA !INFINITE_MAGIC
LDA.b #$02 : STA $7EF3C5 ; end rain state
JSL MaybeSetPostAgaWorldState
LDA.l InitProgressIndicator : BIT.b #$80 : BNE + ; check for instant post-aga
LDA.b #$02 : STA.l ProgressIndicator
RTL
+
LDA.b #$03 : STA.l ProgressIndicator
LDA.l InitLumberjackOW : STA.l OverworldEventDataWRAM+$02
RTL
;--------------------------------------------------------------------------------

View File

@@ -11,6 +11,5 @@ CheckZSNES:
LDA #$01FF : TCS ; thing we wrote over - initialize stack
JML.l ReturnCheckZSNES
.zsnes
STP ; !
JML DontUseZSNES
;--------------------------------------------------------------------------------