diff --git a/LTTP_RND_GeneralBugfixes.asm b/LTTP_RND_GeneralBugfixes.asm index 69de78c..7ece3aa 100644 --- a/LTTP_RND_GeneralBugfixes.asm +++ b/LTTP_RND_GeneralBugfixes.asm @@ -44,7 +44,10 @@ dw !ROM_VERSION_HIGH !MS_GOT = "$7F5031" -!REDRAW = "$7F5000" +;!REDRAW = "$7F5000" +!SPRITE_REDRAW = "$7E0790" ; 16 bytes +!SPRITE_OAM = "$7EC025" ; 16 bytes +!SPRITE_DYNAMIC_OAM = "$7EC035" ; 16 bytes !GANON_WARP_CHAIN = "$7F5032"; !TILE_UPLOAD_BUFFER = "$7EA180"; diff --git a/bookofmudora.asm b/bookofmudora.asm index 0e2f335..412b9b7 100644 --- a/bookofmudora.asm +++ b/bookofmudora.asm @@ -5,13 +5,12 @@ LoadLibraryItemGFX: LDA.l LibraryItem_Player : STA !MULTIWORLD_SPRITEITEM_PLAYER_ID %GetPossiblyEncryptedItem(LibraryItem, SpriteItemValues) STA $0E80, X ; Store item type - JSL.l PrepDynamicTile -RTL + JML RequestSlottedTile ;-------------------------------------------------------------------------------- DrawLibraryItemGFX: PHA LDA $0E80, X ; Retrieve stored item type - JSL.l DrawDynamicTile + JSL.l DrawSlottedTile PLA RTL ;-------------------------------------------------------------------------------- @@ -25,27 +24,22 @@ RTL ;================================================================================ ; Randomize Bonk Keys ;-------------------------------------------------------------------------------- -!REDRAW = "$7F5000" -;-------------------------------------------------------------------------------- LoadBonkItemGFX: LDA.b #$08 : STA $0F50, X ; thing we wrote over LoadBonkItemGFX_inner: - LDA.b #$00 : STA !REDRAW JSR LoadBonkItem_Player : STA !MULTIWORLD_SPRITEITEM_PLAYER_ID JSR LoadBonkItem - JSL.l PrepDynamicTile -RTL + JML RequestSlottedTile ;-------------------------------------------------------------------------------- DrawBonkItemGFX: PHA - LDA !REDRAW : BEQ .skipInit ; skip init if already ready - JSL.l LoadBonkItemGFX_inner - BRA .done ; don't draw on the init frame + LDA.w !SPRITE_REDRAW, X : BEQ .skipInit ; skip init if already ready + JSL.l LoadBonkItemGFX_inner + BRA .done ; don't draw on the init frame .skipInit - - JSR LoadBonkItem - JSL.l DrawDynamicTileNoShadow + JSR LoadBonkItem + JSL DrawSlottedTile .done PLA diff --git a/bugfixes.asm b/bugfixes.asm index 8555c5e..32764e2 100644 --- a/bugfixes.asm +++ b/bugfixes.asm @@ -200,6 +200,27 @@ LDA $1B : BNE + + RTL +;-------------------------------------------------------------------------------- +; Fix losing VRAM gfx when using quake +PostNMIUpdateBGCharHalf: + STA.w $420B : SEP #$10 ; what we wrote over + LDA.w $0116 : CMP.b #$46 : BNE .return ; checks to see if this is the last VRAM write + LDA.b $5D : CMP.b #$08 : BCC + : CMP.b #$0A+1 : BCS + ; skip if we're mid-medallion + RTL + + JSL HeartPieceSetRedraw ; set redraw flag for items +.return +RTL + +; Force redraws of items following map checks +PostOverworldGfxLoad: + INC.b $11 : STZ.b $13 ; what we wrote over + JSL HeartPieceSetRedraw +RTL +PostUnderworldMap: + JSL HeartPieceSetRedraw + LDA.l $7EC229 ; what we wrote over +RTL + ;-------------------------------------------------------------------------------- FixJingleGlitch: LDA.b $11 diff --git a/catfish.asm b/catfish.asm index ee55c48..30351fb 100644 --- a/catfish.asm +++ b/catfish.asm @@ -1,25 +1,23 @@ ;================================================================================ ; Randomize Catfish ;-------------------------------------------------------------------------------- -!HEART_REDRAW = "$7F5000" LoadCatfishItemGFX: LDA.l CatfishItem_Player : STA !MULTIWORLD_SPRITEITEM_PLAYER_ID - LDA.l $1DE185 ; location randomizer writes catfish item to - JML PrepDynamicTile + LDA.l $1DE185 ; location randomizer writes catfish item to + JML RequestSlottedTile ;-------------------------------------------------------------------------------- DrawThrownItem: LDA $8A : CMP.b #$81 : BNE .catfish .zora - LDA.b #$01 : STA !HEART_REDRAW - LDA.l $1DE1C3 ; location randomizer writes zora item to + LDA.l $1DE1C3 ; location randomizer writes zora item to BRA .draw .catfish - LDA.l $1DE185 ; location randomizer writes catfish item to + LDA.l $1DE185 ; location randomizer writes catfish item to .draw - JML DrawDynamicTile + JML DrawSlottedTile ;-------------------------------------------------------------------------------- MarkThrownItem: PHA diff --git a/flute.asm b/flute.asm index 7128602..33f9985 100644 --- a/flute.asm +++ b/flute.asm @@ -7,12 +7,13 @@ SpawnHauntedGroveItem: LDA.l HauntedGroveItem_Player : STA !MULTIWORLD_SPRITEITEM_PLAYER_ID %GetPossiblyEncryptedItem(HauntedGroveItem, HeartPieceOutdoorValues) - JSL.l PrepDynamicTile - + LDA.b #$EB STA $7FFE00 JSL Sprite_SpawnDynamically + LDA.b #$01 : STA.w !SPRITE_REDRAW, Y + LDX.b #$00 LDA $2F : CMP.b #$04 : BEQ + : INX : + diff --git a/heartpieces.asm b/heartpieces.asm index fbb8759..1996177 100644 --- a/heartpieces.asm +++ b/heartpieces.asm @@ -49,28 +49,26 @@ HeartContainerGet: BRA HeartPieceGet_skipLoad ;-------------------------------------------------------------------------------- -!REDRAW = "$7F5000" DrawHeartPieceGFX: PHP JSL.l Sprite_IsOnscreen : BCC .offscreen PHA : PHY - LDA !REDRAW : BEQ .skipInit ; skip init if already ready - JSL.l HeartPieceSpritePrep - JMP .done ; don't draw on the init frame + LDA.w !SPRITE_REDRAW, X : BEQ .skipInit ; skip init if already ready + JSL.l HeartPieceSpritePrep + BRA .done ; don't draw on the init frame .skipInit LDA $0E80, X ; Retrieve stored item type - + .skipLoad - - JSL.l DrawDynamicTile - - CMP #$03 : BNE + - PHA : LDA $0E60, X : ORA.b #$20 : STA $0E60, X : PLA - + - - JSL.l Sprite_DrawShadowLong + JSL DrawSlottedTile : BCS .done + ; draw shadow + CMP #$03 : BNE + + INC.b $00 : INC.b $00 : INC.b $00 : INC.b $00 ; move narrow sprite shadow over 4 pixels + PHA : LDA $0E60, X : ORA.b #$20 : STA $0E60, X : PLA + + + JSL.l Sprite_DrawShadowLong .done PLY : PLA @@ -78,20 +76,17 @@ DrawHeartPieceGFX: PLP RTL ;-------------------------------------------------------------------------------- -!REDRAW = "$7F5000" DrawHeartContainerGFX: PHP JSL.l Sprite_IsOnscreen : BCC DrawHeartPieceGFX_offscreen PHA : PHY - LDA !REDRAW : BEQ .skipInit ; skip init if already ready - JSL.l HeartContainerSpritePrep - BRA DrawHeartPieceGFX_done ; don't draw on the init frame + LDA.w !SPRITE_REDRAW, X : BEQ .skipInit ; skip init if already ready + JSL.l HeartContainerSpritePrep + BRA DrawHeartPieceGFX_done ; don't draw on the init frame .skipInit - LDA $0E80, X ; Retrieve stored item type - - BRA DrawHeartPieceGFX_skipLoad + BRA DrawHeartPieceGFX_skipInit ;-------------------------------------------------------------------------------- HeartContainerSound: LDA !MULTIWORLD_ITEM_PLAYER_ID : BNE + @@ -160,34 +155,28 @@ RTL LDA OverworldEventDataWRAM, X : ORA.b #$40 : STA OverworldEventDataWRAM, X RTL ;-------------------------------------------------------------------------------- -!REDRAW = "$7F5000" HeartPieceSpritePrep: PHA LDA ServerRequestMode : BEQ + : : + - LDA #$01 : STA !REDRAW - LDA $5D : CMP #$14 : BEQ .skip ; skip if we're mid-mirror - - LDA #$00 : STA !REDRAW + LDA.b #$01 : STA.w !SPRITE_REDRAW, X JSL.l HeartPieceGetPlayer : STA !MULTIWORLD_SPRITEITEM_PLAYER_ID JSL.l LoadHeartPieceRoomValue ; load item type STA $0E80, X ; Store item type - JSL.l PrepDynamicTile + JSL.l RequestSlottedTile .skip PLA RTL ;-------------------------------------------------------------------------------- -!REDRAW = "$7F5000" HeartContainerSpritePrep: PHA - LDA #$00 : STA !REDRAW JSL.l HeartPieceGetPlayer : STA !MULTIWORLD_SPRITEITEM_PLAYER_ID JSL.l LoadHeartContainerRoomValue ; load item type STA $0E80, X ; Store item type - JSL.l PrepDynamicTile + JSL.l RequestSlottedTile PLA RTL @@ -202,7 +191,6 @@ LoadHeartPieceRoomValue: .done RTL ;-------------------------------------------------------------------------------- -!REDRAW = "$7F5000" HPItemReset: PHA LDA !MULTIWORLD_ITEM_PLAYER_ID : BNE .skip @@ -212,7 +200,6 @@ HPItemReset: .skip PLA .done - PHA : LDA #$01 : STA !REDRAW : PLA RTL ;-------------------------------------------------------------------------------- MaybeMarkDigSpotCollected: @@ -857,3 +844,37 @@ HeartPieceGetPlayer: PLY RTL } +;-------------------------------------------------------------------------------- +HeartPieceSetRedraw: + PHY + LDY.b #$0F + .next + LDA.w $0DD0,Y : BEQ ++ + LDA.w $0E20,Y : CMP.b #$EB : BEQ + ; heart piece + CMP.b #$E4 : BEQ + ; enemy key drop + CMP.b #$3B : BEQ + ; bonk item (book/key) + CMP.b #$E5 : BEQ + ; enemy big key drop + CMP.b #$E7 : BEQ + ; mushroom item + CMP.b #$E9 : BEQ + ; powder item + BRA ++ + + LDA.b #$01 : STA.w !SPRITE_REDRAW,Y + ++ DEY : BPL .next + PLY +RTL +HeartPieceGetRedraw: + PHY + LDY.b #$0F + .next + LDA.w $0DD0,Y : BEQ ++ + LDA.w $0E20,Y : CMP.b #$EB : BEQ + ; heart piece + CMP.b #$E4 : BEQ + ; enemy key drop + CMP.b #$3B : BEQ + ; bonk item (book/key) + CMP.b #$E5 : BEQ + ; enemy big key drop + CMP.b #$E7 : BEQ + ; mushroom item + CMP.b #$E9 : BEQ + ; powder item + BRA ++ + + LDA.w !SPRITE_REDRAW,Y : BEQ ++ + PLY : SEC : RTL + ++ DEY : BPL .next + PLY +CLC : RTL diff --git a/hooks.asm b/hooks.asm index 9cd3bcb..ad32f79 100755 --- a/hooks.asm +++ b/hooks.asm @@ -36,6 +36,9 @@ org $00821B ; <- 21B - Bank00.asm : 329 (LDA $13 : STA $2100) JML.l PostNMIHookAction : NOP PostNMIHookReturn: ;-------------------------------------------------------------------------------- +org $008F6C +JSL PostNMIUpdateBGCharHalf : NOP +;-------------------------------------------------------------------------------- ;================================================================================ ; Anti-ZSNES Hook @@ -1069,6 +1072,10 @@ JSL HandleBombAbsorbtion ;org $09873F ; <- 04873F - ancilla_init.asm : 960 (ADC [$00] : STA [$00] ) ;JSL.l AddToStock ;-------------------------------------------------------------------------------- +org $02EB18 +JSL PostOverworldGfxLoad +org $18BD55 +JSL PostUnderworldMap ;================================================================================ ; Kholdstare Shell Fix @@ -1324,7 +1331,7 @@ NOP #5 ;-------------------------------------------------------------------------------- org $05EE5F ; <- 2EE5F - sprite_mushroom.asm : 30 JSL.l LoadMushroom -NOP +BRA + : NOP #7 : + ;-------------------------------------------------------------------------------- org $05EE78 ; <- 2EE78 - sprite_mushroom.asm : 58 JSL.l DrawMushroom @@ -1371,6 +1378,8 @@ org $07A303 ; 3A303 - Bank07.asm : 5622 org $07A3A2 ; 3A3A2 - Bank07.asm : 5720 - JSL DiggingGameGuy_AttemptPrizeSpawn JSL.l SpawnShovelItem BRA _Bank07_5726 +org $1DFDAC +JSL.l SpawnShovelGamePrize org $07A3AB ; 3A3AB - Bank07.asm : 5726 - LDA.b #$12 : JSR Player_DoSfx2 _Bank07_5726: ;org $07A381 ; 3A381 - Bank07.asm : 5693 - ORA $035B diff --git a/init.asm b/init.asm index 36bb4b5..888986f 100644 --- a/init.asm +++ b/init.asm @@ -10,6 +10,7 @@ Init_Primary: LDX #$00 ; initalize our ram - STA $7EC025, X + STA $7EC035, X STA $7F5000, X INX CPX #$10 : !BLT - diff --git a/inventory.asm b/inventory.asm index 82ec1de..0b60e6e 100644 --- a/inventory.asm +++ b/inventory.asm @@ -952,8 +952,7 @@ LoadPowder: LDA.l WitchItem_Player : STA !MULTIWORLD_SPRITEITEM_PLAYER_ID %GetPossiblyEncryptedItem(WitchItem, SpriteItemValues) STA $0DA0, Y ; Store item type - JSL.l PrepDynamicTile - STA $7F505E + LDA.b #$01 : STA.w !SPRITE_REDRAW, Y LDA #$00 STA $7F505F STA $7F5060 @@ -977,21 +976,16 @@ RTL ;-------------------------------------------------------------------------------- ; DrawPowder: ;-------------------------------------------------------------------------------- -!REDRAW = "$7F5000" -;-------------------------------------------------------------------------------- DrawPowder: LDA $02DA : BNE .defer ; defer if link is buying a potion - LDA.l !REDRAW : BEQ + + LDA.w !SPRITE_REDRAW, X : BEQ + LDA.l WitchItem_Player : STA !MULTIWORLD_SPRITEITEM_PLAYER_ID LDA $0DA0, X ; Retrieve stored item type - JSL.l PrepDynamicTile - LDA #$00 : STA.l !REDRAW ; reset redraw flag - BRA .defer + JML RequestSlottedTile + ; this fights with the shopkeep code, so had to move the powder draw there when potion shop is custom - LDA !SHOP_TYPE : CMP.b #$FF : BNE .defer - LDA $0DA0, X ; Retrieve stored item type - JSL.l DrawDynamicTile + LDA $0DA0, X ; Retrieve stored item type + JML DrawSlottedTile .defer RTL ;-------------------------------------------------------------------------------- @@ -1002,19 +996,12 @@ RTL LoadMushroom: LDA.b #$00 : STA $0DC0, X ; thing we wrote over .justGFX - ;LDA MushroomItem - ;JSL.l PrepDynamicTile - PHA - LDA #$01 : STA !REDRAW - LDA $5D : CMP #$14 : BEQ .skip ; skip if we're mid-mirror - - LDA #$00 : STA !REDRAW LDA.l MushroomItem_Player : STA !MULTIWORLD_SPRITEITEM_PLAYER_ID %GetPossiblyEncryptedItem(MushroomItem, SpriteItemValues) STA $0E80, X ; Store item type - JSL.l PrepDynamicTile + JSL.l RequestSlottedTile .skip PLA @@ -1024,19 +1011,17 @@ RTL ;-------------------------------------------------------------------------------- ; DrawMushroom: ;-------------------------------------------------------------------------------- -!REDRAW = "$7F5000" -;-------------------------------------------------------------------------------- DrawMushroom: PHA : PHY - LDA !REDRAW : BEQ .skipInit ; skip init if already ready - JSL.l LoadMushroom_justGFX - BRA .done ; don't draw on the init frame + LDA.w !SPRITE_REDRAW, X : BEQ .skipInit ; skip init if already ready + JSL.l LoadMushroom_justGFX + BRA .done ; don't draw on the init frame .skipInit LDA $0E80, X ; Retrieve stored item type - JSL.l DrawDynamicTile + JSL.l DrawSlottedTile - .done + .done PLY : PLA RTL ;-------------------------------------------------------------------------------- @@ -1130,11 +1115,13 @@ RTL ;-------------------------------------------------------------------------------- ; SpawnShovelItem: ;-------------------------------------------------------------------------------- -!REDRAW = "$7F5000" +SpawnShovelGamePrize: + JSL Sprite_SpawnDynamically ; thing we wrote over + LDA.b #$01 : STA.w !SPRITE_REDRAW, Y +RTL +;-------------------------------------------------------------------------------- SpawnShovelItem: - LDA.b #$01 : STA !REDRAW - - LDA $03FC : BEQ + + LDA $03FC : BEQ + JSL DiggingGameGuy_AttemptPrizeSpawn JMP .skip + diff --git a/keydrop/dynamic_si_vram.asm b/keydrop/dynamic_si_vram.asm index 3702c49..775c156 100644 --- a/keydrop/dynamic_si_vram.asm +++ b/keydrop/dynamic_si_vram.asm @@ -1,57 +1,117 @@ ; where we shove the decompressed graphics to send to WRAM -DynamicDropGFX = $7EF500 +DynamicDropGFX = $7ECC00 ; 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 -!DynamicDropGFXSlotCount = (FreeUWGraphics_end-FreeUWGraphics)>>1 +!DynamicDropGFXSlotCount_UW = (FreeUWGraphics_end-FreeUWGraphics)>>1 +!DynamicDropGFXSlotCount_OW = (FreeOWGraphics_end-FreeOWGraphics)>>1 ; this will keep track of the above for each item SprItemGFX = $7E0780 -; this is the item requested and a flag -DynamicDropRequest = $7E1E71 -DynamicDropQueue = $7E1E72 +; this is the item requested and a flag (we anticipate no more than 3 requests to be active, but built to support 8) +DynamicDropRequest = $7E1E71 ; bitfield indicating which request slot to process +DynamicDropQueue = $7E1E72 ; 0x08 bytes, occupies 1 byte for each slot in the request queue (loot id at first, but stores GFX index) ; Come in with ; A = item receipt ID ; X = slot -RequestStandingItemVRAMSlot: - CMP.b #$34 : BCC + - CMP.b #$37 : BCS + ; if rupees, use animated rupee OAM slot - LDA.b #!DynamicDropGFXSlotCount : STA.w SprItemGFX,X - RTL - + STA.w DynamicDropQueue - LDA.b #$01 - STA.w DynamicDropRequest +RequestSlottedTile: + PHX : PHY + + PHA + ; skip sending the request if busy with other + LDA.b $11 : CMP.b #$21 : BCS ++ ; skip if OW is loading Map16 GFX ; TODO: Figure out how to allow submodule 22, check DMA status instead + LDA.b $5D : CMP.b #$14 : BEQ ++ ; skip if we're mid-mirror + LDA.b $1B : BEQ + ; OW current doesn't occupy any slots that medallion gfx do + CMP.b #$08 : BCC + : CMP.b #$0A+1 : BCS + ; skip if we're mid-medallion + ++ PLA : JMP .return + + + + LDA.w $0E20, X : CMP.b #$C0 : BNE + ; if catfish + TYX + + CMP.b #$52 : BNE + ; if zora + TYX + + + + LDA 1,S : JSL.l GetSpritePalette : STA $0F50, X ; setup the palette + PLA + + ; gfx that are already present, use that instead of a new slot + CMP.b #$34 : BCC + : CMP.b #$36+1 : BCS + ; if rupees, use animated rupee OAM slot + LDA.b $1B : BEQ ++ + LDA.b #!DynamicDropGFXSlotCount_UW + BRA +++ + ++ LDA.b #!DynamicDropGFXSlotCount_OW + +++ STA.w SprItemGFX,X + JMP .success + + CMP.b #$A0 : BCC + : CMP.b #$AF+1 : BCS + ; if key, use key OAM slot + LDA.b $1B : BEQ ++ + LDA.b #!DynamicDropGFXSlotCount_UW + BRA +++ + ++ LDA.b #!DynamicDropGFXSlotCount_OW + +++ INC : STA.w SprItemGFX,X + JMP .success + + + + PHA : PHX + LDY.b #$00 + LDA.w DynamicDropRequest + - LSR : INY : BCS - + CPY.b #$08 : BCC + + ; all request slots occupied, exit without drawing + PLX : PLA + LDY.b #$FE ; indicate failure + BRA .return + + TYX + LDA.b #$00 : SEC + - ROL : DEX : BNE - + DEY ; y = slot index, a = new request bit flag + ORA.w DynamicDropRequest + STA.w DynamicDropRequest + PLX : PLA + STA.w DynamicDropQueue,Y LDA.w DynamicDropGFXIndex INC - CMP.b #!DynamicDropGFXSlotCount : BCC .fine + PHX + LDX.b $1B : BEQ + + CMP.b #!DynamicDropGFXSlotCount_UW : BCC .fine + BRA ++ + + CMP.b #!DynamicDropGFXSlotCount_OW : BCC .fine - LDA.b #$00 + ++ LDA.b #$00 .fine + PLX STA.w DynamicDropGFXIndex STA.w SprItemGFX,X ; decompress graphics - PHX - LDX.w DynamicDropQueue + PHX : PHY REP #$20 LDA.w #DynamicDropGFX-$7E9000 - STA.l !TILE_UPLOAD_OFFSET_OVERRIDE + TYX : BEQ + + - CLC : ADC.w #$0080 : DEX : BNE - + + STA.l !TILE_UPLOAD_OFFSET_OVERRIDE SEP #$20 - LDA.w DynamicDropQueue + LDA.w DynamicDropQueue,Y JSL.l GetSpriteID JSL.l GetAnimatedSpriteTile_variable SEP #$30 - PLX + PLY : PLX + LDA.w DynamicDropGFXIndex : STA.w DynamicDropQueue,Y + LDA.w DynamicDropQueue,Y ; we want A to return the loot id + .success + STZ.w !SPRITE_REDRAW, X + .return + PLY : PLX RTL ;=================================================================================================== @@ -59,22 +119,38 @@ RequestStandingItemVRAMSlot: TransferPotGFX: SEP #$10 REP #$20 - LDX.w DynamicDropRequest + LDA.w DynamicDropRequest : AND.w #$00FF BEQ .no - STZ.w DynamicDropRequest + .next + LDY.b #$00 + - INY : LSR : BCC - - LDA.w DynamicDropGFXIndex + PHY + LDA.w #$0000 + - ROL : DEY : BNE - + PLY + DEY ; y = slot index, a = request bit flag + + EOR.w DynamicDropRequest : STA.w DynamicDropRequest + + LDA.w DynamicDropQueue,Y ASL TAX - LDA.l FreeUWGraphics,X - STA.w $2116 + LDA.b $1B : AND.w #$00FF : BEQ + + LDA.l FreeUWGraphics,X + BRA ++ + + LDA.l FreeOWGraphics,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 + LDA.w #DynamicDropGFX + CPY.b #$00 : BEQ + + - CLC : ADC.w #$0080 : DEY : BNE - + + STA.w $4302 LDX.b #$80 : STX.w $2115 LDA.w #$1801 : STA.w $4300 @@ -89,6 +165,9 @@ TransferPotGFX: STA.w $2116 STY.w $420B + LDA.w DynamicDropRequest : AND.w #$00FF + BNE .next + .no RTL @@ -97,55 +176,99 @@ FreeUWGraphics: dw $8800>>1 dw $8840>>1 dw $8980>>1 -; dw $9960>>1 # Arghuss Splash apparently +; dw $9960>>1 ; Arghuss Splash apparently ; dw $9C00>>1 dw $9CA0>>1 dw $9DC0>>1 .end -;=================================================================================================== +FreeOWGraphics: + ;dw $8800>>1 ; Shovel Dirt + dw $9960>>1 ; Arghuss/Zora Splash + dw $9C00>>1 ; Heart Piece + dw $9CA0>>1 ; Apple + ;dw $9DC0>>1 ; Whirlpool +.end -DrawPotItem: +;=================================================================================================== +; Come in with +; A = item receipt ID +; X = sprite slot +; Returns with Carry flag set if gfx drawing was skipped +DrawSlottedTile: + PHA + ; TODO: allow drawing if gfx are not using a VRAM slot that changes during medallion + LDA.b $5D : CMP.b #$08 : BCC + : CMP.b #$0A+1 : BCS + ; skip if we're mid-medallion + PLA : SEC : RTL + + + PLA JSL.l IsNarrowSprite : BCS .narrow + ; TODO: Instead of loading the whole fixed 16 bytes from DynamicOAMTile**_** into !SPRITE_DYNAMIC_OAM + ; Do something more like how DrawDynamicTile does it + ; Then we won't need all the separate DynamicOAMTile**_** tables .full LDA.b #$01 : STA $06 LDA #$0C : JSL.l OAM_AllocateFromRegionC LDA #$02 : PHA REP #$20 - LDA.w #DynamicOAMTile_full - BRA .draw + LDA.b $1B : AND.w #$00FF : BEQ + + LDA.w #DynamicOAMTileUW_full + BRA .transfer + + LDA.w #DynamicOAMTileOW_full + BRA .transfer .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 - + REP #$20 + LDA.b $1B : AND.w #$00FF : BEQ + + LDA.w #DynamicOAMTileUW_thin + BRA .transfer + + LDA.w #DynamicOAMTileOW_thin + .transfer 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 + PHK : PLY : STY.b $0A + LDY #$7E : PHB : PHY : PLB - LDA.b #$00 : STA.l !SKIP_EOR - JSL Sprite_DrawMultiple_quantity_preset + ; transfer fixed table data into WRAM + LDY.b #$0E + - LDA.b [$08],Y : STA.w !SPRITE_DYNAMIC_OAM,Y + DEY : DEY : BPL - - LDA.b $90 : CLC : ADC.b #$08 : STA.b $90 - INC.b $92 - INC.b $92 + LDA.w SprItemFlags, X : AND.w #$00FF : BNE .draw + LDA.b $06 : LSR : BCC + + ; full + LDA.w #$0000 + STA.w !SPRITE_DYNAMIC_OAM : STA.w !SPRITE_DYNAMIC_OAM+2 + BRA .draw + + ; narrow + LDA.w $0E20, X : AND.w #$00FF : CMP.w #$003B : BEQ .draw ; bonk item + LDA.w #$0004 + STA.w !SPRITE_DYNAMIC_OAM : STA.w !SPRITE_DYNAMIC_OAM+8 + .draw + LDA.w #!SPRITE_DYNAMIC_OAM : STA.b $08 + SEP #$20 + STZ.b $07 + LDA.b #$00 : STA.l !SKIP_EOR + JSL Sprite_DrawMultiple_quantity_preset PLB + + LDA.b $90 : CLC : ADC.b #$08 : STA.b $90 + INC.b $92 : INC.b $92 + PLA + CLC RTL -DynamicOAMTile_thin: +DynamicOAMTileUW_thin: dw 0, 0 : db $40, $00, $20, $00 dw 0, 8 : db $50, $00, $20, $00 @@ -166,7 +289,10 @@ DynamicOAMTile_thin: dw 0, 0 : db $0B, $00, $20, $00 ; animated rupees slot dw 0, 8 : db $1B, $00, $20, $00 -DynamicOAMTile_full: + dw 0, 0 : db $6B, $00, $20, $00 ; key + dw 0, 8 : db $7B, $00, $20, $00 + +DynamicOAMTileUW_full: dw -4, -1 : db $40, $00, $20, $02 dd 0, 0 @@ -180,4 +306,45 @@ DynamicOAMTile_full: dd 0, 0 dw -4, -1 : db $EE, $00, $20, $02 - dd 0, 0 \ No newline at end of file + dd 0, 0 + +DynamicOAMTileOW_thin: + ; dw 0, 0 : db $40, $00, $20, $00 + ; dw 0, 8 : db $50, $00, $20, $00 + + dw 0, 0 : db $CB, $00, $20, $00 + dw 0, 8 : db $DB, $00, $20, $00 + + dw 0, 0 : db $E0, $00, $20, $00 + dw 0, 8 : db $F0, $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 + + ; add new slots above this line + + dw 0, 0 : db $0B, $00, $20, $00 ; animated rupees slot + dw 0, 8 : db $1B, $00, $20, $00 + + dw 0, 0 : db $6B, $00, $20, $00 ; key + dw 0, 8 : db $7B, $00, $20, $00 + +DynamicOAMTileOW_full: + ; dw 0, 0 : db $40, $00, $20, $02 + ; dd 0, 0 + + dw 0, 0 : db $CB, $00, $20, $02 + dd 0, 0 + + dw 0, 0 : db $E0, $00, $20, $02 + dd 0, 0 + + dw 0, 0 : db $E5, $00, $20, $02 + dd 0, 0 + + ;dw 0, 0 : db $EE, $00, $20, $02 + ;dd 0, 0 + diff --git a/keydrop/standing_items.asm b/keydrop/standing_items.asm index 971f2b6..2d5c02a 100644 --- a/keydrop/standing_items.asm +++ b/keydrop/standing_items.asm @@ -436,36 +436,40 @@ SpriteKeyPrep: 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 + ++ JSL RequestSlottedTile + 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 + JSL Sprite_DrawRippleIfInWater + PHA + LDA.w !SPRITE_REDRAW, X : BEQ + + LDA $0E80, X + JSL RequestSlottedTile + BRA .skipDraw + + 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 DrawSlottedTile : BCS .skipDraw + ; draw shadow + CMP #$03 : BNE + + PHA : LDA $0E60, X : ORA.b #$20 : STA $0E60, X : PLA + + JSL.l Sprite_DrawShadowLong + .skipDraw + PLA + RTL KeyGet: LDA CurrentSmallKeys ; what we wrote over diff --git a/owrando.asm b/owrando.asm index 55420da..ba37b0f 100644 --- a/owrando.asm +++ b/owrando.asm @@ -495,33 +495,35 @@ OWBonkGoodBeeDrop: ; spawn itemget item .spawn_item ; A = item id ; Y = bonk sprite slot ; S = Collected PLX : BEQ + : LDA.b #$00 : STA.w $0DD0,Y : BRA .return - + LDA.b #$01 : STA !REDRAW + + PHA LDA.b #$EB : STA.l $7FFE00 JSL Sprite_SpawnDynamically+15 ; +15 to skip finding a new slot, use existing sprite - TYX : STZ.w $0F20,X ; layer the sprite is on - + LDA.b #$01 : STA.w !SPRITE_REDRAW,Y + + PLA : STA.w $0E80,Y + ; affects the rate the item moves in the Y/X direction - STZ.w $0D40,X + LDA.b #$00 : STA.w $0D40,Y LDA.b #$0A : STA.w $0D50,Y LDA.b #$1A : STA.w $0F80,Y ; amount of force (gives height to the arch) LDA.b #$FF : STA.w $0B58,Y ; stun timer LDA.b #$30 : STA.w $0F10,Y ; aux delay timer 4 ?? dunno what that means + LDA.b #$00 : STA.w $0F20,Y ; layer the sprite is on + ; sets the tile type that is underneath the sprite, water - LDA.b #$09 : STA.l $7FF9C2,X ; TODO: Figure out how to get the game to set this + TYX : LDA.b #$09 : STA.l $7FF9C2,X ; TODO: Figure out how to get the game to set this ; sets OW event bitmask flag, uses free RAM LDA.l OWBonkPrizeTable[42].flag : STA.w $0ED0,Y - + ; determines the initial spawn point of item LDA.w $0D00,Y : SEC : SBC.l OWBonkPrizeTable[42].vert_offset : STA.w $0D00,Y LDA.w $0D20,Y : SBC #$00 : STA.w $0D20,Y - LDA.b #$01 : STA !REDRAW - .return PLY LDA #$08 ; makes original good bee not spawn @@ -618,13 +620,15 @@ OWBonkDrops: ; spawn itemget item .spawn_item ; A = item id ; Y = tree sprite slot ; S = Collected, FlagBitmask, X (row + 2) PLX : BEQ + : LDA.b #$00 : STA.w $0DD0,Y : JMP .return ; S = FlagBitmask, X (row + 2) - + LDA 2,S : TAX : INX - - LDA.b #$01 : STA !REDRAW + + PHA LDA.b #$EB : STA.l $7FFE00 JSL Sprite_SpawnDynamically+15 ; +15 to skip finding a new slot, use existing sprite + LDA.b #$01 : STA.w !SPRITE_REDRAW,Y + + PLA : STA.w $0E80,Y + ; affects the rate the item moves in the Y/X direction LDA.b #$00 : STA.w $0D40,Y LDA.b #$0A : STA.w $0D50,Y @@ -637,14 +641,12 @@ OWBonkDrops: ; sets OW event bitmask flag, uses free RAM PLA : STA.w $0ED0,Y ; S = X (row + 2) - + ; determines the initial spawn point of item PLX : INX : INX : INX LDA.w $0D00,Y : SEC : SBC.w OWBonkPrizeData,X : STA.w $0D00,Y LDA.w $0D20,Y : SBC #$00 : STA.w $0D20,Y - LDA.b #$01 : STA !REDRAW - PLB : RTL .return @@ -958,7 +960,9 @@ OWNewDestination: OWLoadSpecialArea: { LDA.l Overworld_LoadSpecialOverworld_RoomId,X : STA.b $A0 - JSL Overworld_LoadSpecialOverworld ; sets M and X flags + CMP.w #$0182 : BNE + + JSL ZoraSplashGfxFix + + JSL Overworld_LoadSpecialOverworld ; sets M and X flags TYX LDY.b #$00 CPX.b #$01 : BNE + ; check if going to water transition diff --git a/shopkeeper.asm b/shopkeeper.asm index e87c788..3dfb41a 100644 --- a/shopkeeper.asm +++ b/shopkeeper.asm @@ -4,7 +4,6 @@ ;-------------------------------------------------------------------------------- !BIGRAM = "$7EC900"; ;-------------------------------------------------------------------------------- -!SPRITE_OAM = "$7EC025" ; A = Tile ID macro UploadOAM(dest) PHA : PHP @@ -770,8 +769,6 @@ RTS ;-------------------------------------------------------------------------------- ;!SHOP_TYPE = "$7F5051" ;!SHOP_INVENTORY = "$7F5052" -!SPRITE_OAM = "$7EC025" -!REDRAW = "$7F5000" Shopkeeper_DrawItems: PHB : PHK : PLB PHX : PHY @@ -787,14 +784,6 @@ Shopkeeper_DrawItems: + CMP.b #$01 : BNE + : ++ JSR.w Shopkeeper_DrawNextItem + - LDA $A0 : CMP.b #$09 : BNE + ; render powder slot if potion shop - LDA !REDRAW : BNE + ; if not redrawing - LDA $02DA : BNE + ; if not buying item - LDA $7F505E : BEQ + ; if potion slot filled - LDA $0ABF : BEQ + ; haven't left the room - LDA NpcFlags+1 : AND.b #$20 : BNE + - LDX.b #$0C : LDY.b #$03 : JSR.w Shopkeeper_DrawNextItem - + PLY : PLX PLB RTS diff --git a/stats.asm b/stats.asm index db89a99..4b8f776 100644 --- a/stats.asm +++ b/stats.asm @@ -318,9 +318,7 @@ RTL IndoorTileTransitionCounter: JMP StatTransitionCounter ;-------------------------------------------------------------------------------- -!REDRAW = "$7F5000" IndoorSubtileTransitionCounter: - LDA.b #$01 : STA !REDRAW ; set redraw flag for items STZ $0646 ; stuff we wrote over STZ $0642 JMP StatTransitionCounter diff --git a/tables.asm b/tables.asm index 0ad13f9..360732e 100644 --- a/tables.asm +++ b/tables.asm @@ -1470,8 +1470,9 @@ dw #9999 ; Rupee Limit ; $2F8000 - $2F83FF - RNG Block ;================================================================================ ; $7EC025 - $7EC034 - Item OAM Table +; $7EC035 - $7EC044 - Dynamic Item OAM Table ;================================================================================ -; $7F5000 - Redraw Flag +; $7F5000 - FREE (Old Global Redraw Flag) ; $7F5001 - Flipper Softlock Possible ; $7F5002 - L/R Rotate ; $7F5003 - HexToDec 1st Digit diff --git a/tablets.asm b/tablets.asm index 3d49304..5c7929e 100644 --- a/tablets.asm +++ b/tablets.asm @@ -34,7 +34,6 @@ SpawnTabletItem: JSL.l HeartPieceGetPlayer : STA !MULTIWORLD_SPRITEITEM_PLAYER_ID JSL.l LoadOutdoorValue PHA - JSL.l PrepDynamicTile LDA.b #$01 : STA !FORCE_HEART_SPAWN : STA !SKIP_HEART_SAVE JSL.l SetTabletItem @@ -42,6 +41,8 @@ SpawnTabletItem: LDA.b #$EB STA $7FFE00 JSL Sprite_SpawnDynamically + + LDA.b #$01 : STA.w !SPRITE_REDRAW, Y PLA : STA $0E80, Y ; Store item type LDA $22 : STA $0D10, Y diff --git a/utilities.asm b/utilities.asm index a4aa35f..c1eaa80 100644 --- a/utilities.asm +++ b/utilities.asm @@ -411,8 +411,7 @@ PrepDynamicTile: + TXA JSR.w LoadDynamicTileOAMTable - CMP.b #$34 : BCC + - CMP.b #$36+1 : BCS + : BRA ++ ; if rupees, don't draw to OAM + CMP.b #$34 : BCC + : CMP.b #$36+1 : BCS + : BRA ++ ; if rupees, don't draw to OAM + JSL.l GetSpriteID ; convert loot id to sprite id JSL.l GetAnimatedSpriteTile_variable ++ LDA.b #$00 : STA !MULTIWORLD_SPRITEITEM_PLAYER_ID @@ -424,8 +423,6 @@ RTL ; LoadDynamicTileOAMTable ; in: A - Loot ID ;-------------------------------------------------------------------------------- 20/847B -!SPRITE_OAM = "$7EC025" -;-------------------------------------------------------------------------------- LoadDynamicTileOAMTable: PHA : PHP @@ -435,8 +432,8 @@ LoadDynamicTileOAMTable: STA.l !SPRITE_OAM+2 LDA.w #$0200 : STA.l !SPRITE_OAM+6 SEP #$20 ; set 8-bit accumulator - LDA $01,s : CMP.b #$34 : BCC + - CMP.b #$36+1 : BCS + ; if rupees, use animated gfx already in OAM + LDA $01,s + CMP.b #$34 : BCC + : CMP.b #$36+1 : BCS + ; if rupees, use animated gfx already in OAM LDA.b #$0B : BRA ++ + LDA.b #$24 ++ STA.l !SPRITE_OAM+4 @@ -451,8 +448,8 @@ LoadDynamicTileOAMTable: BRA .done .narrow - LDA $02,s : CMP.b #$34 : BCC + - CMP.b #$36+1 : BCS + ; if rupees, use animated gfx already in OAM + LDA $02,s + CMP.b #$34 : BCC + : CMP.b #$36+1 : BCS + ; if rupees, use animated gfx already in OAM REP #$20 LDA.w #$1B00 : BRA ++ + REP #$20 @@ -474,7 +471,6 @@ RTS ;-------------------------------------------------------------------------------- ; This wastes two OAM slots if you don't want a shadow - fix later - I wrote "fix later" over a year ago and it's still not fixed (Aug 6, 2017) - lol (May 25th, 2019) ;-------------------------------------------------------------------------------- 2084B8 -!SPRITE_OAM = "$7EC025" !SKIP_EOR = "$7F5008" ;-------------------------------------------------------------------------------- DrawDynamicTile: diff --git a/zoraking.asm b/zoraking.asm index 020d805..db39a42 100644 --- a/zoraking.asm +++ b/zoraking.asm @@ -4,7 +4,17 @@ LoadZoraKingItemGFX: LDA.l ZoraItem_Player : STA !MULTIWORLD_SPRITEITEM_PLAYER_ID LDA.l $1DE1C3 ; location randomizer writes zora item to - JML.l PrepDynamicTile + JML RequestSlottedTile +;-------------------------------------------------------------------------------- +ZoraSplashGfxFix: + PHA : PHX : PHY : SEP #$30 + ; below should be set to the index used for Arrghus/Zora Splash + ; FreeOWGraphics in dynamic_si_vram.asm, whatever index is $9960 + ; this makes it so the first gfx that is loading is AFTER the splash + LDA.b #$00 : STA.w DynamicDropGFXIndex + JSL LoadCommonSprites_long + REP #$30 : PLY : PLX : PLA + RTL ;-------------------------------------------------------------------------------- JumpToSplashItemTarget: LDA $0D90, X