diff --git a/doorrando/hudadditions.asm b/doorrando/hudadditions.asm index 6149d9d..0f076b3 100644 --- a/doorrando/hudadditions.asm +++ b/doorrando/hudadditions.asm @@ -69,15 +69,21 @@ DRHUD_DrawCurrentDungeonIndicator: ; mX STY.w HUDCurrentDungeonWorld DRHUD_DrawKeyCounter: - LDA.l DRFlags : AND.b #$04 : BEQ DRHUD_Finished - REP #$20 - LDA.w MapField : AND.l DungeonMask, X : BEQ DRHUD_Finished - TXA : LSR : TAX - LDA.l GenericKeys : AND.w #$00FF : BNE .total_only - LDA.w DungeonCollectedKeys, X : JSR ConvertToDisplay : STA.w HUDKeysObtained + LDA.l DRFlags : AND.b #$04 : BEQ DRHUD_Finished + LDA.l CompassMode : BIT.b #$03 : BEQ DRHUD_Finished + REP #$20 + BIT.w #$0002 : BNE .skip_map_check + LDA.w MapField : AND.l DungeonMask, X : BEQ DRHUD_Finished +.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 .total_only - LDA.l ChestKeys, x : JSR ConvertToDisplay : STA.w HUDKeysTotal + LDA.l TotalKeys, x : JSR ConvertToDisplay : STA.w HUDKeysTotal JMP DRHUD_Finished OWRHUD_DrawWorldIndicator: @@ -152,16 +158,19 @@ DrHudDungeonItemsAdditions: jsr ConvertToDisplay2 : sta.w $1644, y + iny #2 : lda.w #$24f5 : sta.w $1644, y phx : ldx.b Scrap00 - lda.l MapField : and.l DungeonMask, x : beq + ; must have map - plx : sep #$30 : lda.l ChestKeys, x : sta.b Scrap02 - lda.l GenericKeys : bne +++ - lda.b Scrap02 : !SUB.l DungeonCollectedKeys, x : sta.b Scrap02 - +++ lda.b Scrap02 - rep #$30 - jsr ConvertToDisplay2 : sta.w $1644, y ; small key totals - bra .skipStack - + plx - .skipStack iny #2 + LDA.l CompassMode : BIT.w #$0002 : BNE .skip_map_check + LDA.l MapField : AND.l DungeonMask, x : BEQ .key_info_done ; must have map + .skip_map_check + plx : sep #$30 : lda.l ChestKeys, x : sta.b Scrap02 + lda.l GenericKeys : bne +++ + lda.b Scrap02 : !SUB.l DungeonCollectedKeys, x : sta.b Scrap02 + +++ lda.b Scrap02 + rep #$30 + jsr ConvertToDisplay2 : sta.w $1644, y ; small key totals + bra .skipStack + .key_info_done + plx + .skipStack iny #2 cpx.w #$000d : beq + lda.w #$24f5 : sta.w $1644, y + @@ -255,7 +264,13 @@ ConvertToDisplay2: ++ lda.w #$2827 : rts ; 0/O for 0 or placeholder digit ;2483 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 diff --git a/dungeondrops.asm b/dungeondrops.asm index 823a53d..d23154b 100644 --- a/dungeondrops.asm +++ b/dungeondrops.asm @@ -3,6 +3,16 @@ ;-------------------------------------------------------------------------------- SpawnDungeonPrize: 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 TAX LDA.b $06,S : STA.b ScrapBuffer72 ; Store current RoomTag index @@ -18,6 +28,10 @@ SpawnDungeonPrize: PLB : PLX RTL +.skip_prize_drop: + PLA : PLB : PLX +RTL + AddDungeonPrizeAncilla: LDY.w ItemReceiptID STZ.w AncillaVelocityY,X diff --git a/enemizer/hooks.asm b/enemizer/hooks.asm index 189b01e..6899310 100644 --- a/enemizer/hooks.asm +++ b/enemizer/hooks.asm @@ -14,4 +14,13 @@ incsrc hooks/damage_hooks.asm incsrc hooks/overworld_sprite_hooks.asm -incsrc hooks/underworld_sprite_hooks.asm \ No newline at end of file +incsrc hooks/underworld_sprite_hooks.asm + +org $85B8BA +JSL GeldmanDrawOverride + +org $9EAAAC +JSL StalfosKnightDrawOverride + +org $9EB209 +JSL BlobDrawOverride \ No newline at end of file diff --git a/enemizer/underworld_sprites.asm b/enemizer/underworld_sprites.asm index 237137a..f931db7 100644 --- a/enemizer/underworld_sprites.asm +++ b/enemizer/underworld_sprites.asm @@ -8,4 +8,40 @@ GetSpriteSlot16Bit: LDA.b Scrap03 : AND.w #$00FF ASL A TAY -RTL \ No newline at end of file +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 \ No newline at end of file diff --git a/heartpieces.asm b/heartpieces.asm index 58ad5af..4b2ac29 100644 --- a/heartpieces.asm +++ b/heartpieces.asm @@ -242,6 +242,12 @@ LoadOutdoorValue: PHP REP #$20 ; set 16-bit accumulator 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 + LDA.l OWBonkPrizeTable[$00].loot JMP .done diff --git a/inventory.asm b/inventory.asm index 97de1a5..a9374b2 100644 --- a/inventory.asm +++ b/inventory.asm @@ -220,7 +220,8 @@ DungeonIncrement: REP #$10 PHX 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 SEP #$10 diff --git a/keydrop/standing_items.asm b/keydrop/standing_items.asm index ed0ac3e..161203b 100644 --- a/keydrop/standing_items.asm +++ b/keydrop/standing_items.asm @@ -856,12 +856,61 @@ 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 + 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 - .specialpot ; zero flag already set, so gtg -RTL +.exit + RTL SetTheSceneFix: STZ.b $6C diff --git a/lampmantlecone.asm b/lampmantlecone.asm index b0f00e8..08175f0 100644 --- a/lampmantlecone.asm +++ b/lampmantlecone.asm @@ -5,9 +5,10 @@ ;-------------------------------------------------------------------------------- LampCheck: 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.w DungeonID : CMP.b #$04 : BCS + ; are we en HC? - LDA.l LampConeSewers : RTL + LDA.l LampCone : RTL + : TDC .lamp RTL diff --git a/sram.asm b/sram.asm index 0a2df8a..358fcc1 100644 --- a/sram.asm +++ b/sram.asm @@ -362,7 +362,21 @@ 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 +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. ;================================================================================ @@ -624,6 +638,7 @@ endmacro %assertSRAM(TRCollectedKeys, $7EF4EC) %assertSRAM(GTCollectedKeys, $7EF4ED) %assertSRAM(FileMarker, $7EF4F0) +%assertSRAM(DungeonAllCollectedKeys, $7EF4F1) ;-------------------------------------------------------------------------------- %assertSRAM(ExtendedSaveDataWRAM, $7F6000) %assertSRAM(ExtendedFileNameWRAM, $7F6000) diff --git a/stats.asm b/stats.asm index 458ec4e..6adca40 100644 --- a/stats.asm +++ b/stats.asm @@ -115,38 +115,42 @@ DecrementSmallKeys: STA.l CurrentSmallKeys ; thing we wrote over, write small key count JSL UpdateKeys RTL -;-------------------------------------------------------------------------------- -CountChestKeyLong: - PHX : PHP - SEP #$30 - JSR CountChestKey - PLP : PLX -RTL + ;-------------------------------------------------------------------------------- -CountChestKey: - PHA : PHX - LDA.l !MULTIWORLD_ITEM_PLAYER_ID : BNE .done - LDA.l StatsLocked : BNE .done - CPY.b #$24 : BEQ .this_dungeon - TYA - AND.b #$0F : CMP.b #$02 : BCC .hc_sewers - TAX - 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 +; Expects 16 bit index mode upon entering. 8-bit Acumulator +CountAllKey: + PHP : PHA : PHX + SEP #$10 + LDA.l !MULTIWORLD_ITEM_PLAYER_ID : BNE .done + CPY.b #$24 : BEQ .this_dungeon + TYA : AND.b #$0F : CMP.b #$02 : BCC .hc_sewers + BRA .all_dungoens - .hc_sewers - LDA.l SewerCollectedKeys : INC - STA.l SewerCollectedKeys : STA.l HCCollectedKeys +.this_dungeon + LDA.w DungeonID : CMP.b #$03 : BCC .hc_sewers + LSR - .done - PLX : PLA -RTS +.all_dungoens + STA.b Scrap00 : TAX ; store dungeon index in X, $00 + 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: diff --git a/tables.asm b/tables.asm index 6e1c47b..e7eddef 100644 --- a/tables.asm +++ b/tables.asm @@ -110,8 +110,8 @@ RupoorDeduction: dw $000A ; #$0A - Default (10 decimal) ;-------------------------------------------------------------------------------- org $B08038 ; PC 0x180038 -LampConeSewers: -db $01 ; #$00 = Off - #$01 = On (default) +LampCone: +db $01 ; #$00 = Off - #$01 = Sewers only (default) - #$11 = Always On ;-------------------------------------------------------------------------------- org $B08039 ; PC 0x180039 ItemCounterHUD: diff --git a/tablets.asm b/tablets.asm index 12761b2..518ed6a 100644 --- a/tablets.asm +++ b/tablets.asm @@ -19,7 +19,14 @@ RTL ;-------------------------------------------------------------------------------- SetTabletItemFlag: 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 JSR ItemSet_BombosTablet : BRA .done .ether @@ -69,6 +76,12 @@ RTL IsMedallion: REP #$20 ; set 16-bit accumulator 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 LDA.b LinkPosX : CMP.w #1890 : !BGE ++ SEC diff --git a/vanillalabels.asm b/vanillalabels.asm index b842fff..801b21a 100644 --- a/vanillalabels.asm +++ b/vanillalabels.asm @@ -79,6 +79,7 @@ Sprite_TransmuteToBomb = $86AD58 Sprite_PrepAndDrawSingleLargeLong = $86DBF8 Sprite_PrepAndDrawSingleSmallLong = $86DC00 Sprite_DrawShadowLong = $86DC5C +Sprite_DrawShadowCustomLong = $86DC64 DashKey_Draw = $86DD40 Sprite_PrepOAMCoordLong = $86E41C Sprite_CheckTileCollisionLong = $86E49C @@ -242,6 +243,16 @@ CrystalMaiden_KickOutOfDungeon = $9ECF35 GoldBee_Dormant_exit = $9EDE89 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 ;===================================================================================================