Merge branch 'DRUnstable' into OWMain

This commit is contained in:
codemann8
2025-12-03 09:37:31 -06:00
13 changed files with 232 additions and 58 deletions

View File

@@ -69,15 +69,21 @@ DRHUD_DrawCurrentDungeonIndicator: ; mX
STY.w HUDCurrentDungeonWorld STY.w HUDCurrentDungeonWorld
DRHUD_DrawKeyCounter: DRHUD_DrawKeyCounter:
LDA.l DRFlags : AND.b #$04 : BEQ DRHUD_Finished LDA.l DRFlags : AND.b #$04 : BEQ DRHUD_Finished
REP #$20 LDA.l CompassMode : BIT.b #$03 : BEQ DRHUD_Finished
LDA.w MapField : AND.l DungeonMask, X : BEQ DRHUD_Finished REP #$20
TXA : LSR : TAX BIT.w #$0002 : BNE .skip_map_check
LDA.l GenericKeys : AND.w #$00FF : BNE .total_only LDA.w MapField : AND.l DungeonMask, X : BEQ DRHUD_Finished
LDA.w DungeonCollectedKeys, X : JSR ConvertToDisplay : STA.w HUDKeysObtained .skip_map_check
TXA : LSR : BNE .dungeon_id
INC
.dungeon_id
TAX
LDA.l GenericKeys : LSR : BCS .total_only
LDA.w DungeonAllCollectedKeys-1, X : JSR ConvertToDisplay : STA.w HUDKeysObtained
LDA.w #!SlashTile : STA.w HUDKeysSlash LDA.w #!SlashTile : STA.w HUDKeysSlash
.total_only .total_only
LDA.l ChestKeys, x : JSR ConvertToDisplay : STA.w HUDKeysTotal LDA.l TotalKeys, x : JSR ConvertToDisplay : STA.w HUDKeysTotal
JMP DRHUD_Finished JMP DRHUD_Finished
OWRHUD_DrawWorldIndicator: OWRHUD_DrawWorldIndicator:
@@ -152,16 +158,19 @@ DrHudDungeonItemsAdditions:
jsr ConvertToDisplay2 : sta.w $1644, y jsr ConvertToDisplay2 : sta.w $1644, y
+ iny #2 : lda.w #$24f5 : sta.w $1644, y + iny #2 : lda.w #$24f5 : sta.w $1644, y
phx : ldx.b Scrap00 phx : ldx.b Scrap00
lda.l MapField : and.l DungeonMask, x : beq + ; must have map LDA.l CompassMode : BIT.w #$0002 : BNE .skip_map_check
plx : sep #$30 : lda.l ChestKeys, x : sta.b Scrap02 LDA.l MapField : AND.l DungeonMask, x : BEQ .key_info_done ; must have map
lda.l GenericKeys : bne +++ .skip_map_check
lda.b Scrap02 : !SUB.l DungeonCollectedKeys, x : sta.b Scrap02 plx : sep #$30 : lda.l ChestKeys, x : sta.b Scrap02
+++ lda.b Scrap02 lda.l GenericKeys : bne +++
rep #$30 lda.b Scrap02 : !SUB.l DungeonCollectedKeys, x : sta.b Scrap02
jsr ConvertToDisplay2 : sta.w $1644, y ; small key totals +++ lda.b Scrap02
bra .skipStack rep #$30
+ plx jsr ConvertToDisplay2 : sta.w $1644, y ; small key totals
.skipStack iny #2 bra .skipStack
.key_info_done
plx
.skipStack iny #2
cpx.w #$000d : beq + cpx.w #$000d : beq +
lda.w #$24f5 : sta.w $1644, y lda.w #$24f5 : sta.w $1644, y
+ +
@@ -255,7 +264,13 @@ ConvertToDisplay2:
++ lda.w #$2827 : rts ; 0/O for 0 or placeholder digit ;2483 ++ lda.w #$2827 : rts ; 0/O for 0 or placeholder digit ;2483
CountAbsorbedKeys: CountAbsorbedKeys:
JML IncrementSmallKeysNoPrimary CPY.b #$24 : BNE .done
PHA : PHX
LDA.b #$84 : TAX ; pretend this isn't a smallkey, but an absorbed object (small heart)
REP #$10 : JSL CountAllKey : SEP #$10
PLX : PLA
.done
JML IncrementSmallKeysNoPrimary
;================================================================================ ;================================================================================
; 8-bit registers ; 8-bit registers

View File

@@ -3,6 +3,16 @@
;-------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------
SpawnDungeonPrize: SpawnDungeonPrize:
PHX : PHB PHX : PHB
PHA
; Don't spawn prize in Cave state, Hyrule Castle, Escape, Castle Tower, or Ganon's Tower
LDA.w DungeonID : BMI .skip_prize_drop ; Cave state
CMP.b #$00 : BEQ .skip_prize_drop ; Escape
CMP.b #$02 : BEQ .skip_prize_drop ; Hyrule Castle
CMP.b #$1A : BEQ .skip_prize_drop ; Ganon's Tower
CMP.b #$08 : BEQ .skip_prize_drop ; Agahnim's Tower (Castle Tower)
PLA
STA.w ItemReceiptID STA.w ItemReceiptID
TAX TAX
LDA.b $06,S : STA.b ScrapBuffer72 ; Store current RoomTag index LDA.b $06,S : STA.b ScrapBuffer72 ; Store current RoomTag index
@@ -18,6 +28,10 @@ SpawnDungeonPrize:
PLB : PLX PLB : PLX
RTL RTL
.skip_prize_drop:
PLA : PLB : PLX
RTL
AddDungeonPrizeAncilla: AddDungeonPrizeAncilla:
LDY.w ItemReceiptID LDY.w ItemReceiptID
STZ.w AncillaVelocityY,X STZ.w AncillaVelocityY,X

View File

@@ -14,4 +14,13 @@ incsrc hooks/damage_hooks.asm
incsrc hooks/overworld_sprite_hooks.asm incsrc hooks/overworld_sprite_hooks.asm
incsrc hooks/underworld_sprite_hooks.asm incsrc hooks/underworld_sprite_hooks.asm
org $85B8BA
JSL GeldmanDrawOverride
org $9EAAAC
JSL StalfosKnightDrawOverride
org $9EB209
JSL BlobDrawOverride

View File

@@ -8,4 +8,40 @@ GetSpriteSlot16Bit:
LDA.b Scrap03 : AND.w #$00FF LDA.b Scrap03 : AND.w #$00FF
ASL A ASL A
TAY TAY
RTL RTL
GeldmanDrawOverride:
PLA : PLA : PLA ; fix the call stack
LDA.l DRFlags+1 : AND.b #$08 : BEQ .vanilla
LDA.b #$01
STA.w $0DC0,X
JML Sprite_4C_Geldman_do_indeed_draw
.vanilla
JSL Sprite_PrepOAMCoordLong
JML Sprite_4C_Geldman_continue
StalfosKnightDrawOverride:
LDA.l DRFlags+1 : AND.b #$08 : BEQ .vanilla
JSL Sprite_PrepOAMCoordLong
LDA.b #$12
JML Sprite_DrawShadowLong
.vanilla
JSL Sprite_PrepOAMCoordLong
RTL
BlobDrawOverride:
PLA : PLA : PLA ; fix the call stack
LDA.l DRFlags+1 : AND.b #$08 : BEQ .vanilla
LDA.b #$05
STA.w $0DC0,X
JML SpriteDraw_Blob_head_popping_out
.vanilla
JSL Sprite_PrepOAMCoordLong
JML SpriteDraw_Blob_bad_gfx

View File

@@ -242,6 +242,12 @@ LoadOutdoorValue:
PHP PHP
REP #$20 ; set 16-bit accumulator REP #$20 ; set 16-bit accumulator
LDA.b OverworldIndex LDA.b OverworldIndex
; Rain state fix: In rain state DW, use LW screen ID for item lookup
BIT.w #$0040 : BEQ +
LDA.l ProgressIndicator : AND.w #$00FF : CMP.w #$0002
LDA.b OverworldIndex : BCS ++ : AND.w #$00BF
++
+
CMP.w #$00 : BNE + CMP.w #$00 : BNE +
LDA.l OWBonkPrizeTable[$00].loot LDA.l OWBonkPrizeTable[$00].loot
JMP .done JMP .done

View File

@@ -220,7 +220,8 @@ DungeonIncrement:
REP #$10 REP #$10
PHX PHX
LDA.w InventoryTable_properties,X : BIT.b #$40 : BEQ + LDA.w InventoryTable_properties,X : BIT.b #$40 : BEQ +
JSL CountChestKeyLong CPY.w #$0024 : BEQ + ; keys for this dungeon are done elsewhere
JSL CountAllKey
+ +
LDA.l !MULTIWORLD_RECEIVING_ITEM : BNE .done LDA.l !MULTIWORLD_RECEIVING_ITEM : BNE .done
SEP #$10 SEP #$10

View File

@@ -856,12 +856,61 @@ RTL
CheckIfPotIsSpecial: CheckIfPotIsSpecial:
TXA ; give index to A so we can do a CMP.l 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 CMP.l $018550 ; see if our current index is that of object 230
BEQ .specialpot BNE .normal_pot
; Normal pot, so run the vanilla code .special_pot
PHX
; get pot index and cache room ID offset
LDA.b RoomIndex : ASL : STA.b Scrap0E
TAX
LDA.b $08
BIT.b $BF : BVC .upper ; if $BF has bit 14 set, it's upper layer
ORA.w #$2000 ; set the lower layer bit ($2000)
.upper
STA.b $90 ; cache tilemap offset
LDA.l UWPotsPointers,X : TAX
LDY.w #$0000
.next_pot
LDA.l UWPotsPointers&$FF0000, X ; read only the bank
CMP.w #$FFFF
BEQ .nothing
AND.w #$3FFF ; mask out the first three bits (used for item indicators and layer)
CMP.b $90 ; check against the tilemap offset
BEQ .get_flag
INX #3
INY #2
BRA .next_pot
.get_flag
TYX
LDA.l BitFieldMasks,X
LDX.b Scrap0E ; get room ID
STA.b Scrap0E
LDA.l RoomPotData,X
BRA .check_pot
.nothing
INC ; from FFFF, A is now 0000 so the AND always fails
.check_pot
LDY.b $08 : PLX
AND.b Scrap0E
BEQ .exit ; zero flag will be set, which is what we want
LDX.w #$0E82 ; the normal pot obj. See RoomDrawObjectData_#obj0E82
.normal_pot
; Normal pot, so run the vanilla code
LDA.l CurrentWorld ; check for dark world LDA.l CurrentWorld ; check for dark world
.specialpot ; zero flag already set, so gtg .exit
RTL RTL
SetTheSceneFix: SetTheSceneFix:
STZ.b $6C STZ.b $6C

View File

@@ -5,9 +5,10 @@
;-------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------
LampCheck: LampCheck:
LDA.l LightConeModifier : BNE .lamp LDA.l LightConeModifier : BNE .lamp
LDA.l LampCone : AND.b #$10 : BNE .lamp ; always on
LDA.l LampEquipment : BNE .lamp ; skip if we already have lantern LDA.l LampEquipment : BNE .lamp ; skip if we already have lantern
LDA.w DungeonID : CMP.b #$04 : BCS + ; are we en HC? LDA.w DungeonID : CMP.b #$04 : BCS + ; are we en HC?
LDA.l LampConeSewers : RTL LDA.l LampCone : RTL
+ : TDC + : TDC
.lamp .lamp
RTL RTL

View File

@@ -362,7 +362,21 @@ TRCollectedKeys: skip 1 ; | Turtle Rock
GTCollectedKeys: skip 1 ; / Ganon's Tower GTCollectedKeys: skip 1 ; / Ganon's Tower
skip 2 ; Reserved for previous table skip 2 ; Reserved for previous table
FileMarker: skip 1 ; $FF = Active save file | $00 = Inactive save file FileMarker: skip 1 ; $FF = Active save file | $00 = Inactive save file
skip 13 ; Unused DungeonAllCollectedKeys: ; \ Key Counters. Counts all keys for a dungeon. Chests and drops.
; | Note, this label is not indexed like others due to space. Sewers has no decicated entry.
HCAllCollectedKeys: skip 1 ; | Hyrule Castle
EPAllCollectedKeys: skip 1 ; | Eastern Palace
DPAllCollectedKeys: skip 1 ; | Desert Palace
CTAllCollectedKeys: skip 1 ; | Agahnim's Tower
SPAllCollectedKeys: skip 1 ; | Swamp Palace
PDAllCollectedKeys: skip 1 ; | Palace of Darkness
MMAllCollectedKeys: skip 1 ; | Misery Mire
SWAllCollectedKeys: skip 1 ; | Skull Woods
IPAllCollectedKeys: skip 1 ; | Ice Palace
THAllCollectedKeys: skip 1 ; | Tower of Hera
TTAllCollectedKeys: skip 1 ; | Thieves' Town
TRAllCollectedKeys: skip 1 ; | Turtle Rock
GTAllCollectedKeys: skip 1 ; / Ganon's Tower
InverseChecksumWRAM: skip 2 ; Vanilla Inverse Checksum. Don't write unless computing checksum. InverseChecksumWRAM: skip 2 ; Vanilla Inverse Checksum. Don't write unless computing checksum.
;================================================================================ ;================================================================================
@@ -624,6 +638,7 @@ endmacro
%assertSRAM(TRCollectedKeys, $7EF4EC) %assertSRAM(TRCollectedKeys, $7EF4EC)
%assertSRAM(GTCollectedKeys, $7EF4ED) %assertSRAM(GTCollectedKeys, $7EF4ED)
%assertSRAM(FileMarker, $7EF4F0) %assertSRAM(FileMarker, $7EF4F0)
%assertSRAM(DungeonAllCollectedKeys, $7EF4F1)
;-------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------
%assertSRAM(ExtendedSaveDataWRAM, $7F6000) %assertSRAM(ExtendedSaveDataWRAM, $7F6000)
%assertSRAM(ExtendedFileNameWRAM, $7F6000) %assertSRAM(ExtendedFileNameWRAM, $7F6000)

View File

@@ -115,38 +115,42 @@ DecrementSmallKeys:
STA.l CurrentSmallKeys ; thing we wrote over, write small key count STA.l CurrentSmallKeys ; thing we wrote over, write small key count
JSL UpdateKeys JSL UpdateKeys
RTL RTL
;--------------------------------------------------------------------------------
CountChestKeyLong:
PHX : PHP
SEP #$30
JSR CountChestKey
PLP : PLX
RTL
;-------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------
CountChestKey: ; Expects 16 bit index mode upon entering. 8-bit Acumulator
PHA : PHX CountAllKey:
LDA.l !MULTIWORLD_ITEM_PLAYER_ID : BNE .done PHP : PHA : PHX
LDA.l StatsLocked : BNE .done SEP #$10
CPY.b #$24 : BEQ .this_dungeon LDA.l !MULTIWORLD_ITEM_PLAYER_ID : BNE .done
TYA CPY.b #$24 : BEQ .this_dungeon
AND.b #$0F : CMP.b #$02 : BCC .hc_sewers TYA : AND.b #$0F : CMP.b #$02 : BCC .hc_sewers
TAX BRA .all_dungoens
LDA.l DungeonCollectedKeys,X : INC : STA.l DungeonCollectedKeys,X
BRA .done
.this_dungeon
LDA.w DungeonID : CMP.b #$03 : BCC .hc_sewers
LSR : TAX
LDA.l DungeonCollectedKeys,X : INC : STA.l DungeonCollectedKeys,X
BRA .done
.hc_sewers .this_dungeon
LDA.l SewerCollectedKeys : INC LDA.w DungeonID : CMP.b #$03 : BCC .hc_sewers
STA.l SewerCollectedKeys : STA.l HCCollectedKeys LSR
.done .all_dungoens
PLX : PLA STA.b Scrap00 : TAX ; store dungeon index in X, $00
RTS LDA.l DungeonAllCollectedKeys-1, X : INC : STA.l DungeonAllCollectedKeys-1, X
REP #$10 : PLX : PHX ; 16 bit index
LDA.l InventoryTable_properties, X : BIT.b #$40 : BEQ .done
SEP #$10 : LDX.b Scrap00
LDA.l DungeonCollectedKeys,X : INC : STA.l DungeonCollectedKeys,X
BRA .done
.hc_sewers
LDA.l HCAllCollectedKeys : INC : STA.l HCAllCollectedKeys
REP #$10 : PLX : PHX ; 16 bit index
LDA.l InventoryTable_properties, X : BIT.b #$40 : BEQ .done
LDA.l SewerCollectedKeys : INC
STA.l SewerCollectedKeys : STA.l HCCollectedKeys
.done
REP #$10
PLX : PLA : PLP
RTL
;-------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------
IncrementAgahnim2Sword: IncrementAgahnim2Sword:

View File

@@ -110,8 +110,8 @@ RupoorDeduction:
dw $000A ; #$0A - Default (10 decimal) dw $000A ; #$0A - Default (10 decimal)
;-------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------
org $B08038 ; PC 0x180038 org $B08038 ; PC 0x180038
LampConeSewers: LampCone:
db $01 ; #$00 = Off - #$01 = On (default) db $01 ; #$00 = Off - #$01 = Sewers only (default) - #$11 = Always On
;-------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------
org $B08039 ; PC 0x180039 org $B08039 ; PC 0x180039
ItemCounterHUD: ItemCounterHUD:

View File

@@ -19,7 +19,14 @@ RTL
;-------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------
SetTabletItemFlag: SetTabletItemFlag:
PHA PHA
LDA.b OverworldIndex : CMP.b #$03 : BEQ .ether ; if we're on the map where ether is, we're the ether tablet ; Rain state fix: convert DW screen ID to LW if in rain state
LDA.b OverworldIndex
BIT.b #$40 : BEQ +
LDA.l ProgressIndicator : CMP.b #$02
LDA.b OverworldIndex : BCS ++ : AND.b #$BF
++
+
CMP.b #$03 : BEQ .ether ; if we're on the map where ether is, we're the ether tablet
.bombos .bombos
JSR ItemSet_BombosTablet : BRA .done JSR ItemSet_BombosTablet : BRA .done
.ether .ether
@@ -69,6 +76,12 @@ RTL
IsMedallion: IsMedallion:
REP #$20 ; set 16-bit accumulator REP #$20 ; set 16-bit accumulator
LDA.b OverworldIndex LDA.b OverworldIndex
; Rain state fix: In rain state DW, use LW screen ID for tablet lookup
BIT.w #$0040 : BEQ +
LDA.l ProgressIndicator : AND.w #$00FF : CMP.w #$0002
LDA.b OverworldIndex : BCS ++ : AND.w #$00BF
++
+
CMP.w #$03 : BNE + ; Death Mountain CMP.w #$03 : BNE + ; Death Mountain
LDA.b LinkPosX : CMP.w #1890 : !BGE ++ LDA.b LinkPosX : CMP.w #1890 : !BGE ++
SEC SEC

View File

@@ -79,6 +79,7 @@ Sprite_TransmuteToBomb = $86AD58
Sprite_PrepAndDrawSingleLargeLong = $86DBF8 Sprite_PrepAndDrawSingleLargeLong = $86DBF8
Sprite_PrepAndDrawSingleSmallLong = $86DC00 Sprite_PrepAndDrawSingleSmallLong = $86DC00
Sprite_DrawShadowLong = $86DC5C Sprite_DrawShadowLong = $86DC5C
Sprite_DrawShadowCustomLong = $86DC64
DashKey_Draw = $86DD40 DashKey_Draw = $86DD40
Sprite_PrepOAMCoordLong = $86E41C Sprite_PrepOAMCoordLong = $86E41C
Sprite_CheckTileCollisionLong = $86E49C Sprite_CheckTileCollisionLong = $86E49C
@@ -242,6 +243,16 @@ CrystalMaiden_KickOutOfDungeon = $9ECF35
GoldBee_Dormant_exit = $9EDE89 GoldBee_Dormant_exit = $9EDE89
GoldBee_SpawnSelf = $9EDE8A GoldBee_SpawnSelf = $9EDE8A
;===================================================================================================
; Spliced routines (use JML directly since the hook left these methods)
;===================================================================================================
Sprite_4C_Geldman_do_indeed_draw = $85B8C0
Sprite_4C_Geldman_continue = $85B8C3
Sprite_91_StalfosKnight_continue = $9EAAB5
SpriteDraw_Blob_bad_gfx = $9EB20D
SpriteDraw_Blob_head_popping_out = $9EB24E
;=================================================================================================== ;===================================================================================================
; Palettes ; Palettes
;=================================================================================================== ;===================================================================================================