From 0339e09b5dbce3c80529a855055bd3f484e8fe08 Mon Sep 17 00:00:00 2001 From: codemann8 Date: Fri, 5 Apr 2024 21:00:55 -0500 Subject: [PATCH] Formatting --- bookofmudora.asm | 157 +++++++++++++------------ heartpieces.asm | 233 ++++++++++++++++++------------------- inverted.asm | 84 ++++++------- keydrop/standing_items.asm | 2 +- npcitems.asm | 16 +-- 5 files changed, 245 insertions(+), 247 deletions(-) diff --git a/bookofmudora.asm b/bookofmudora.asm index d71ce12..bb63512 100644 --- a/bookofmudora.asm +++ b/bookofmudora.asm @@ -2,24 +2,24 @@ ; Randomize Book of Mudora ;-------------------------------------------------------------------------------- LoadLibraryItemGFX: - LDA.l LibraryItem_Player : STA.l !MULTIWORLD_SPRITEITEM_PLAYER_ID - %GetPossiblyEncryptedItem(LibraryItem, SpriteItemValues) - JSL AttemptItemSubstitution - JSL ResolveLootIDLong - STA.w SpriteID, X - JSL PrepDynamicTile_loot_resolved + LDA.l LibraryItem_Player : STA.l !MULTIWORLD_SPRITEITEM_PLAYER_ID + %GetPossiblyEncryptedItem(LibraryItem, SpriteItemValues) + JSL AttemptItemSubstitution + JSL ResolveLootIDLong + STA.w SpriteID, X + JSL PrepDynamicTile_loot_resolved RTL ;-------------------------------------------------------------------------------- DrawLibraryItemGFX: - PHA - LDA.w SpriteID, X - JSL DrawDynamicTile - PLA + PHA + LDA.w SpriteID, X + JSL DrawDynamicTile + PLA RTL ;-------------------------------------------------------------------------------- SetLibraryItem: - LDY.w SpriteID, X - JSL ItemSet_Library ; contains thing we wrote over + LDY.w SpriteID, X + JSL ItemSet_Library ; contains thing we wrote over RTL ;-------------------------------------------------------------------------------- @@ -28,90 +28,89 @@ RTL ; Randomize Bonk Keys ;-------------------------------------------------------------------------------- LoadBonkItemGFX: - LDA.b #$08 : STA.w SpriteOAMProp, X ; thing we wrote over + LDA.b #$08 : STA.w SpriteOAMProp, X ; thing we wrote over LoadBonkItemGFX_inner: - LDA.b #$00 : STA.l RedrawFlag - JSR LoadBonkItem_Player : STA.l !MULTIWORLD_SPRITEITEM_PLAYER_ID - JSR LoadBonkItem - JSL AttemptItemSubstitution - JSL ResolveLootIDLong - STA.w $0E80, X - STA.w SpriteID, X - JSL PrepDynamicTile - PHA : PHX - LDA.w SpriteID,X : TAX - LDA.l SpriteProperties_standing_width,X : BNE + - LDA.b #$00 : STA.l SpriteOAM : STA.l SpriteOAM+8 - + - PLX : PLA + LDA.b #$00 : STA.l RedrawFlag + JSR LoadBonkItem_Player : STA.l !MULTIWORLD_SPRITEITEM_PLAYER_ID + JSR LoadBonkItem + JSL AttemptItemSubstitution + JSL ResolveLootIDLong + STA.w $0E80, X + STA.w SpriteID, X + JSL PrepDynamicTile + PHA : PHX + LDA.w SpriteID,X : TAX + LDA.l SpriteProperties_standing_width,X : BNE + + LDA.b #$00 : STA.l SpriteOAM : STA.l SpriteOAM+8 + + + PLX : PLA RTL ;-------------------------------------------------------------------------------- DrawBonkItemGFX: - PHA - LDA.l RedrawFlag : BEQ .skipInit - JSL LoadBonkItemGFX_inner - BRA .done ; don't draw on the init frame + PHA + LDA.l RedrawFlag : BEQ .skipInit + JSL LoadBonkItemGFX_inner + BRA .done ; don't draw on the init frame - .skipInit - LDA.w SpriteID,X - JSL DrawDynamicTileNoShadow + .skipInit + LDA.w SpriteID,X + JSL DrawDynamicTileNoShadow - .done - PLA + .done + PLA RTL ;-------------------------------------------------------------------------------- GiveBonkItem: - JSR LoadBonkItem_Player : STA.l !MULTIWORLD_ITEM_PLAYER_ID - JSR LoadBonkItem - JSR AbsorbKeyCheck : BCC .notKey - .key - PHY : LDY.b #$24 : JSL AddInventory : PLY ; do inventory processing for a small key - LDA.l CurrentSmallKeys : INC A : STA.l CurrentSmallKeys - LDA.b #$2F : JSL Sound_SetSfx3PanLong - INC.w UpdateHUDFlag -RTL + JSR LoadBonkItem_Player : STA.l !MULTIWORLD_ITEM_PLAYER_ID + JSR LoadBonkItem + JSR AbsorbKeyCheck : BCC .notKey + PHY : LDY.b #$24 : JSL AddInventory : PLY ; do inventory processing for a small key + LDA.l CurrentSmallKeys : INC A : STA.l CurrentSmallKeys + LDA.b #$2F : JSL Sound_SetSfx3PanLong + INC.w UpdateHUDFlag + RTL .notKey - PHY : TAY : JSL Link_ReceiveItem : PLY + PHY : TAY : JSL Link_ReceiveItem : PLY RTL ;-------------------------------------------------------------------------------- LoadBonkItem: - LDA.b RoomIndex ; check room ID - only bonk keys in 2 rooms so we're just checking the lower byte - CMP.b #$73 : BNE + ; Desert Bonk Key - LDA.l BonkKey_Desert - BRA ++ - + : CMP.b #$8C : BNE + ; GTower Bonk Key - LDA.l BonkKey_GTower - BRA ++ - + - LDA.b #$24 ; default to small key - ++ + LDA.b RoomIndex ; check room ID - only bonk keys in 2 rooms so we're just checking the lower byte + CMP.b #$73 : BNE + ; Desert Bonk Key + LDA.l BonkKey_Desert + BRA ++ + + : CMP.b #$8C : BNE + ; GTower Bonk Key + LDA.l BonkKey_GTower + BRA ++ + + + LDA.b #$24 ; default to small key +++ RTS ;-------------------------------------------------------------------------------- LoadBonkItem_Player: - LDA.b RoomIndex ; check room ID - only bonk keys in 2 rooms so we're just checking the lower byte - CMP.b #$73 : BNE + ; Desert Bonk Key - LDA.l BonkKey_Desert_Player - BRA ++ - + : CMP.b #$8C : BNE + ; GTower Bonk Key - LDA.l BonkKey_GTower_Player - BRA ++ - + - LDA.b #$00 - ++ + LDA.b RoomIndex ; check room ID - only bonk keys in 2 rooms so we're just checking the lower byte + CMP.b #$73 : BNE + ; Desert Bonk Key + LDA.l BonkKey_Desert_Player + BRA ++ + + : CMP.b #$8C : BNE + ; GTower Bonk Key + LDA.l BonkKey_GTower_Player + BRA ++ + + + LDA.b #$00 +++ RTS ;-------------------------------------------------------------------------------- AbsorbKeyCheck: - PHA - CMP.b #$24 : BEQ .key - CMP.b #$A0 : BCC .not_key - CMP.b #$B0 : BCS .not_key - AND.b #$0F : ASL - CMP.w DungeonID : BNE .not_key - .key - PLA - SEC - RTS - .not_key - PLA - CLC + PHA + CMP.b #$24 : BEQ .key + CMP.b #$A0 : BCC .not_key + CMP.b #$B0 : BCS .not_key + AND.b #$0F : ASL + CMP.w DungeonID : BNE .not_key + .key + PLA + SEC + RTS + .not_key + PLA + CLC RTS diff --git a/heartpieces.asm b/heartpieces.asm index 0a23aa5..cd1e50e 100644 --- a/heartpieces.asm +++ b/heartpieces.asm @@ -2,65 +2,65 @@ ; Randomize Heart Pieces ;-------------------------------------------------------------------------------- HeartPieceGet: - PHX : PHY - TAY - .skipLoad - JSL HeartPieceGetPlayer : STA.l !MULTIWORLD_ITEM_PLAYER_ID - CPY.b #$26 : BNE .not_heart ; don't add a 1/4 heart if it's not a heart piece - LDA.l !MULTIWORLD_ITEM_PLAYER_ID : BNE .not_heart - LDA.l HeartPieceQuarter : INC A : AND.b #$03 : STA.l HeartPieceQuarter - .not_heart - STZ.w ItemReceiptMethod ; 0 = Receiving item from an NPC or message - JSL MaybeUnlockTabletAnimation + PHX : PHY JSL LoadHeartPieceRoomValue JSL AttemptItemSubstitution JSL ResolveLootIDLong + TAY JSL MaybeMarkDigSpotCollected + .skipLoad + JSL HeartPieceGetPlayer : STA.l !MULTIWORLD_ITEM_PLAYER_ID + CPY.b #$26 : BNE .not_heart ; don't add a 1/4 heart if it's not a heart piece + LDA.l !MULTIWORLD_ITEM_PLAYER_ID : BNE .not_heart + LDA.l HeartPieceQuarter : INC A : AND.b #$03 : STA.l HeartPieceQuarter + .not_heart JSL Player_HaltDashAttackLong + STZ.w ItemReceiptMethod ; 0 = Receiving item from an NPC or message JSL Link_ReceiveItem + JSL MaybeUnlockTabletAnimation - PLY : PLX + PLY : PLX RTL ;-------------------------------------------------------------------------------- HeartContainerGet: - PHX : PHY - LDY.w SpriteID, X : BNE + - + - BRA HeartPieceGet_skipLoad + PHX : PHY JSL IncrementBossSword + LDY.w SpriteID, X : BNE + JSL LoadHeartContainerRoomValue : TAY + + + BRA HeartPieceGet_skipLoad ;-------------------------------------------------------------------------------- DrawHeartPieceGFX: - PHP - PHA : PHY - LDA.l RedrawFlag : BEQ .skipInit ; skip init if already ready - JMP .done ; don't draw on the init frame - .skipInit - LDA.w SpriteID, X ; Retrieve stored item type - .skipLoad - PHA : PHX - TAX - LDA.l SpriteProperties_standing_width,X : BNE + - PLX - LDA.w SpriteControl, X : ORA.b #$20 : STA.w SpriteControl, X - PLA - LDA.b Scrap00 - CLC : ADC.b #$04 - STA.b Scrap00 - BRA .done - + - PLX - PLA - .done - PLY : PLA - .offscreen - PLP + PHP JSL Sprite_IsOnscreen : BCC .offscreen + PHA : PHY + LDA.l RedrawFlag : BEQ .skipInit ; skip init if already ready JSL HeartPieceSpritePrep + JMP .done ; don't draw on the init frame + .skipInit + LDA.w SpriteID, X ; Retrieve stored item type + .skipLoad + PHA : PHX + TAX + LDA.l SpriteProperties_standing_width,X : BNE + + PLX + LDA.w SpriteControl, X : ORA.b #$20 : STA.w SpriteControl, X + PLA JSL DrawDynamicTile + LDA.b Scrap00 + CLC : ADC.b #$04 + STA.b Scrap00 JSL Sprite_DrawShadowLong + BRA .done + + + PLX + PLA JSL DrawDynamicTile JSL Sprite_DrawShadowLong + .done + PLY : PLA + .offscreen + PLP RTL ;-------------------------------------------------------------------------------- DrawHeartContainerGFX: @@ -78,119 +78,118 @@ DrawHeartContainerGFX: BRA DrawHeartPieceGFX_skipLoad ;-------------------------------------------------------------------------------- HeartContainerSound: - LDA.l !MULTIWORLD_ITEM_PLAYER_ID : BNE + - LDA.w ItemReceiptMethod : CMP.b #$03 : BEQ + - LDA.b #$2E - SEC - RTL - + - CLC + LDA.l !MULTIWORLD_ITEM_PLAYER_ID : BNE + + LDA.w ItemReceiptMethod : CMP.b #$03 : BEQ + JSL CheckIfBossRoom : BCC + ; Skip if not in a boss room + LDA.b #$2E + SEC + RTL + + + CLC RTL ;-------------------------------------------------------------------------------- NormalItemSkipSound: ; Out: c - skip sounds if set - LDA.l !MULTIWORLD_ITEM_PLAYER_ID : BNE .skip - JSL.l CheckIfBossRoom : BCS .boss_room - TDC - CPY #$17 : BEQ .skip - CLC -RTL - .boss_room - LDA.w ItemReceiptMethod : CMP.b #$03 : BEQ + - .skip - SEC - RTL - + - LDA.b #$20 - .dont_skip + LDA.l !MULTIWORLD_ITEM_PLAYER_ID : BNE .skip + JSL CheckIfBossRoom : BCS .boss_room + TDC + CPY.b #$17 : BEQ .skip CLC +RTL + .boss_room + LDA.w ItemReceiptMethod : CMP.b #$03 : BEQ + + .skip + SEC + RTL + + + LDA.b #$20 + .dont_skip + CLC RTL ;-------------------------------------------------------------------------------- HeartPieceSpritePrep: - PHA + PHA - LDA.l ServerRequestMode : BEQ + : : + + LDA.l ServerRequestMode : BEQ + : : + - LDA.b #$01 : STA.l RedrawFlag - LDA.b LinkState : CMP.b #$14 : BEQ .skip ; skip if we're mid-mirror + LDA.b #$01 : STA.l RedrawFlag + LDA.b LinkState : CMP.b #$14 : BEQ .skip ; skip if we're mid-mirror - LDA.b #$00 : STA.l RedrawFlag - JSL HeartPieceGetPlayer : STA.l !MULTIWORLD_SPRITEITEM_PLAYER_ID - STA.w SpriteID, X + LDA.b #$00 : STA.l RedrawFlag + JSL HeartPieceGetPlayer : STA.l !MULTIWORLD_SPRITEITEM_PLAYER_ID JSL LoadHeartPieceRoomValue JSL AttemptItemSubstitution JSL ResolveLootIDLong + STA.w SpriteID, X JSL PrepDynamicTile_loot_resolved - .skip - PLA + .skip + PLA RTL ;-------------------------------------------------------------------------------- HeartContainerSpritePrep: - PHA + PHA - LDA.b #$00 : STA.l RedrawFlag - JSL HeartPieceGetPlayer : STA.l !MULTIWORLD_SPRITEITEM_PLAYER_ID - STA.w SpriteID, X + LDA.b #$00 : STA.l RedrawFlag + JSL HeartPieceGetPlayer : STA.l !MULTIWORLD_SPRITEITEM_PLAYER_ID JSL LoadHeartContainerRoomValue ; load item type JSL AttemptItemSubstitution JSL ResolveLootIDLong + STA.w SpriteID, X JSL PrepDynamicTile_loot_resolved - PLA + PLA RTL ;-------------------------------------------------------------------------------- LoadHeartPieceRoomValue: - LDA.b IndoorsFlag : BEQ .outdoors ; check if we're indoors or outdoors - .indoors - JMP .done - .outdoors - .done + LDA.b IndoorsFlag : BEQ .outdoors ; check if we're indoors or outdoors + .indoors JSL LoadIndoorValue + JMP .done + .outdoors JSL LoadOutdoorValue + .done RTL ;-------------------------------------------------------------------------------- HPItemReset: - PHA - LDA.l !MULTIWORLD_ITEM_PLAYER_ID : BNE .skip - PLA - BRA .done - .skip - PLA - .done - PHA : LDA.b #$01 : STA.l RedrawFlag : PLA + PHA + LDA.l !MULTIWORLD_ITEM_PLAYER_ID : BNE .skip + PLA JSL GiveRupeeGift ; thing we wrote over + BRA .done + .skip + PLA + .done + PHA : LDA.b #$01 : STA.l RedrawFlag : PLA RTL ;-------------------------------------------------------------------------------- MaybeMarkDigSpotCollected: - PHA : PHP - LDA.b IndoorsFlag : BNE + - REP #$20 ; set 16-bit accumulator - LDA.b OverworldIndex - CMP.w #$2A : BNE + - LDA.l HasGroveItem : ORA.w #$0001 : STA.l HasGroveItem - + - PLP : PLA + PHA : PHP + LDA.b IndoorsFlag : BNE + + REP #$20 ; set 16-bit accumulator + LDA.b OverworldIndex : CMP.w #$002A : BNE + + LDA.l HasGroveItem : ORA.w #$0001 : STA.l HasGroveItem + + + PLP : PLA RTL ;-------------------------------------------------------------------------------- macro GetPossiblyEncryptedItem(ItemLabel,TableLabel) - LDA.l IsEncrypted : BNE ?encrypted - LDA.l - BRA ?done - ?encrypted: - PHX : PHP - REP #$30 ; set 16-bit accumulator & index registers - LDA.b Scrap00 : PHA : LDA.b Scrap02 : PHA + LDA.l IsEncrypted : BNE ?encrypted + LDA.l + BRA ?done + ?encrypted: + PHX : PHP + REP #$30 ; set 16-bit accumulator & index registers + LDA.b Scrap00 : PHA : LDA.b Scrap02 : PHA - LDA.w # : STA.b Scrap00 - LDA.w #>>16 : STA.b Scrap02 - LDA.w #- - JSL RetrieveValueFromEncryptedTable + LDA.w # : STA.b Scrap00 + LDA.w #>>16 : STA.b Scrap02 + LDA.w #- + JSL RetrieveValueFromEncryptedTable - PLX : STX.b Scrap02 : PLX : STX.b Scrap01 - PLP : PLX - ?done: + PLX : STX.b Scrap02 : PLX : STX.b Scrap01 + PLP : PLX + ?done: endmacro LoadIndoorValue: @@ -224,10 +223,10 @@ LoadIndoorValue: LDA.l StandingKey_Hera JMP .done + - PHX - LDX.w CurrentSpriteSlot ; If we're on a different screen ID via glitches load the sprite - LDA.w SpriteID,X ; we can see and are interacting with - PLX + PHX + LDX.w CurrentSpriteSlot ; If we're on a different screen ID via glitches load the sprite + LDA.w SpriteID,X ; we can see and are interacting with + PLX .done AND.w #$00FF ; the loads are words but the values are 1-byte so we need to clear the top half of the accumulator - no guarantee it was 8-bit before PLP @@ -290,10 +289,10 @@ LoadOutdoorValue: %GetPossiblyEncryptedItem(HeartPiece_Zora, HeartPieceOutdoorValues) JMP .done + - PHX - LDX.w CurrentSpriteSlot ; If we're on a different screen ID via glitches load the sprite - LDA.w SpriteID,X ; we can see and are interacting with. - PLX + PHX + LDX.w CurrentSpriteSlot ; If we're on a different screen ID via glitches load the sprite + LDA.w SpriteID,X ; we can see and are interacting with. + PLX .done AND.w #$00FF ; the loads are words but the values are 1-byte so we need to clear the top half of the accumulator - no guarantee it was 8-bit before PLP diff --git a/inverted.asm b/inverted.asm index a9d4ea0..b667081 100644 --- a/inverted.asm +++ b/inverted.asm @@ -138,8 +138,8 @@ RTL GanonTowerAnimation: - LDA.l InvertedMode : BEQ .done - LDA.b #$1B : STA.w SFX3 + LDA.l InvertedMode : BEQ .done + LDA.b #$1B : STA.w SFX3 STZ.w OWEntranceCutscene STZ.b SubSubModule STZ.w SkipOAM @@ -155,10 +155,10 @@ GanonTowerAnimation: LDA.b #$09 : STA.w SFX1 RTL - .done - LDA.b #$05 : STA.w OWEntranceCutscene ; what we wrote over - STZ.b SubSubModule ; (continued) - STZ.b ScrapBufferBD+$0B ; (continued) + .done + LDA.b #$05 : STA.w OWEntranceCutscene ; what we wrote over + STZ.b SubSubModule ; (continued) + STZ.b ScrapBufferBD+$0B ; (continued) RTL GanonTowerInvertedCheck: @@ -195,44 +195,44 @@ TurtleRockPegSolved: RTL MirrorBonk: - ; must preserve X/Y, and must preserve $00-$0F - LDA.l InvertedMode : BEQ .normal + ; must preserve X/Y, and must preserve $00-$0F + LDA.l InvertedMode : BEQ .normal - ; Goal: use $20 and $22 to decide to force a bonk - ; if we want to bonk branch to .forceBonk - ; otherwise fall through to .normal - PHX : PHP - PHB : PHK : PLB - LDA.b OverworldIndex : AND.b #$40 : BEQ .endLoop ;World we're in? branch if we are in LW we don't want bonks - REP #$30 - LDX.w #$0000 - .loop - LDA.l .bonkRectanglesTable, X ;Load X1 - CMP.b LinkPosX : !BGE ++ - ;IF X > X1 - LDA.l .bonkRectanglesTable+2, X ; Load X2 - CMP.b LinkPosX : !BLT ++ - ;IF X < X2 - LDA.l .bonkRectanglesTable+4, X ;Load Y1 - CMP.b LinkPosY : !BGE ++ - ;IF Y > Y1 - LDA.l .bonkRectanglesTable+6, X ; Load Y2 - CMP.b LinkPosY : !BLT ++ - ;IF Y < Y2 - ;Bonk Here - PLB : PLP : PLX - BRA .forceBonk - ++ - TAX - BRA .loop - .endbonkRectanglesTable - - .endLoop - PLB : PLP : PLX -.normal - ;Not forcing a bonk, so the vanilla bonk detection run. - LDA.b Scrap0C : ORA.b Scrap0E + ; Goal: use $20 and $22 to decide to force a bonk + ; if we want to bonk branch to .forceBonk + ; otherwise fall through to .normal + PHX : PHP + PHB : PHK : PLB + LDA.b OverworldIndex : AND.b #$40 : BEQ .endLoop ;World we're in? branch if we are in LW we don't want bonks + REP #$30 + LDX.w #$0000 + .loop + LDA.l .bonkRectanglesTable, X ;Load X1 + CMP.b LinkPosX : !BGE ++ + ;IF X > X1 + LDA.l .bonkRectanglesTable+2, X ; Load X2 + CMP.b LinkPosX : !BLT ++ + ;IF X < X2 + LDA.l .bonkRectanglesTable+4, X ;Load Y1 + CMP.b LinkPosY : !BGE ++ + ;IF Y > Y1 + LDA.l .bonkRectanglesTable+6, X ; Load Y2 + CMP.b LinkPosY : !BLT ++ + ;IF Y < Y2 + ;Bonk Here + PLB : PLP : PLX + BRA .forceBonk + ++ TXA : !ADD.w #$0008 : CMP.w #.tableEnd-.bonkRectanglesTable : BEQ .endLoop + TAX + BRA .loop + .endbonkRectanglesTable + + .endLoop + PLB : PLP : PLX + .normal + ;Not forcing a bonk, so the vanilla bonk detection run. + LDA.b Scrap0C : ORA.b Scrap0E JML MirrorBonk_NormalReturn .forceBonk JML MirrorBonk_BranchGamma diff --git a/keydrop/standing_items.asm b/keydrop/standing_items.asm index 1025829..42fe8d1 100644 --- a/keydrop/standing_items.asm +++ b/keydrop/standing_items.asm @@ -23,7 +23,7 @@ org $86E3C4 JSL RevealSpriteDrop2 : NOP org $86F933 - JSL PikitOverride + JSL PikitOverride org $86926e ; <- 3126e - sprite_prep.asm : 2664 (LDA $0B9B : STA $0CBA, X) JSL SpriteKeyPrep : NOP #2 diff --git a/npcitems.asm b/npcitems.asm index ed800a0..576a821 100644 --- a/npcitems.asm +++ b/npcitems.asm @@ -211,14 +211,14 @@ LoadCatfishItemGFX: JML PrepDynamicTile_loot_resolved ;-------------------------------------------------------------------------------- DrawThrownItem: - LDA.b OverworldIndex : CMP.b #$81 : BNE .catfish - .zora - LDA.b #$01 : STA.l RedrawFlag - BRA .draw - .catfish - .draw - LDA.w SpriteID,X - JML DrawDynamicTile + LDA.b OverworldIndex : CMP.b #$81 : BNE .catfish + .zora + LDA.b #$01 : STA.l RedrawFlag + BRA .draw + .catfish + .draw + LDA.w SpriteID,X + JML DrawDynamicTile ;-------------------------------------------------------------------------------- MarkThrownItem: PHA