diff --git a/bookofmudora.asm b/bookofmudora.asm index ad16bd1..dff9707 100644 --- a/bookofmudora.asm +++ b/bookofmudora.asm @@ -4,6 +4,7 @@ LoadLibraryItemGFX: LDA.l LibraryItem_Player : STA !MULTIWORLD_SPRITEITEM_PLAYER_ID %GetPossiblyEncryptedItem(LibraryItem, SpriteItemValues) + JSL.l AttemptItemSubstitution JSL.l ResolveLootIDLong STA.w SpriteID, X JSL.l PrepDynamicTile_loot_resolved @@ -32,9 +33,17 @@ LoadBonkItemGFX_inner: LDA.b #$00 : STA.l RedrawFlag JSR LoadBonkItem_Player : STA !MULTIWORLD_SPRITEITEM_PLAYER_ID JSR LoadBonkItem + JSL.l AttemptItemSubstitution + JSL.l ResolveLootIDLong STA.w SpriteItemType, X STA.w SpriteID, X JSL.l 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: @@ -44,7 +53,7 @@ DrawBonkItemGFX: BRA .done ; don't draw on the init frame .skipInit - JSR LoadBonkItem + LDA.w SpriteID,X JSL.l DrawDynamicTileNoShadow .done diff --git a/custompalettes.asm b/custompalettes.asm index 17a9cc4..cbe705a 100644 --- a/custompalettes.asm +++ b/custompalettes.asm @@ -10,7 +10,7 @@ dw $0000, $7FFF, $27FF, $5E2D, $7FFF, $1CE7, $7A10, $64A5 .red_shield dw $0000, $7FFF, $27FF, $5E2D, $4F5F, $1CE7, $2E9C, $14B6 .mirror_shield -dw $0000, $7FFF, $27FF, $5E2D, $7399, $1CE7, $02F9, $0233 +dw $0000, $7E4E, $6F44, $1CF5, $7399, $1CE7, $02F9, $0233 .crystal dw $7FFF, $7FFF, $0000, $5907, $6E0E, $0000, $7FBB, $7672 .off_black diff --git a/dungeondrops.asm b/dungeondrops.asm index 6a364e8..6abf178 100644 --- a/dungeondrops.asm +++ b/dungeondrops.asm @@ -3,6 +3,7 @@ ;-------------------------------------------------------------------------------- SpawnDungeonPrize: PHX : PHB + JSL.l AttemptItemSubstitution JSL.l ResolveLootIDLong STA.w ItemReceiptID TAX @@ -61,6 +62,7 @@ RTS PrepPrizeTile: PHA : PHX : PHY LDA.w AncillaGet, X + JSL.l AttemptItemSubstitution JSL.l ResolveLootIDLong STA.w SpriteID,X JSL.l TransferItemReceiptToBuffer_using_ReceiptID @@ -69,6 +71,7 @@ RTL SetItemPose: PHA + LDA.w DungeonID : BMI .one_handed LDA.w RoomItemsTaken : BIT.b #$80 : BNE + .one_handed PLA @@ -97,6 +100,7 @@ SetCutsceneFlag: ; Out: c - Cutscene flag $02 if set, $01 if unset. PHX LDY.b #$01 ; wrote over + LDA.w DungeonID : BMI .no_cutscene LDA.w RoomItemsTaken : BIT #$80 : BNE .dungeon_prize .no_cutscene PLX @@ -112,6 +116,7 @@ RTL AnimatePrizeCutscene: LDA.w ItemReceiptMethod : CMP.b #$03 : BNE + JSR.w CrystalOrPendantBehavior : BCC + + LDA.w DungeonID : BMI + LDA.w RoomItemsTaken : BIT #$80 : BEQ + SEC RTL @@ -148,7 +153,9 @@ RTL MaybeKeepLootID: PHA + LDA.w DungeonID : BMI .no_prize LDA.w RoomItemsTaken : BIT #$80 : BNE .prize + .no_prize STZ.w ItemReceiptID STZ.w ItemReceiptPose PLA diff --git a/events.asm b/events.asm index 80e24c2..11c6db7 100644 --- a/events.asm +++ b/events.asm @@ -240,6 +240,7 @@ PostItemGet: RTL ;-------------------------------------------------------------------------------- PostItemAnimation: + PHB LDA.b #$00 : STA.l BusyItem ; mark item as finished LDA.l TextBoxDefer : BEQ + STZ.w TextID : STZ.w TextID+1 ; reset decompression buffer @@ -263,29 +264,33 @@ PostItemAnimation: JSL.l IncrementChestTurnCounter + REP #$20 + PEA.w $7E00 + PLB : PLB LDA.w TransparencyFlag : BNE .SP05 - LDA.l PalettesCustom_off_black+$00 : STA.l PaletteBuffer+$0170 - LDA.l PalettesCustom_off_black+$02 : STA.l PaletteBuffer+$0172 - LDA.l PalettesCustom_off_black+$04 : STA.l PaletteBuffer+$0174 - LDA.l PalettesCustom_off_black+$06 : STA.l PaletteBuffer+$0176 - LDA.l PalettesCustom_off_black+$08 : STA.l PaletteBuffer+$0178 - LDA.l PalettesCustom_off_black+$0A : STA.l PaletteBuffer+$017A - LDA.l PalettesCustom_off_black+$0C : STA.l PaletteBuffer+$017C - LDA.l PalettesCustom_off_black+$0E : STA.l PaletteBuffer+$017E + LDA.l PalettesCustom_off_black+$00 : STA.w PaletteBuffer+$0170 : STA.w PaletteBufferAux+$0170 + LDA.l PalettesCustom_off_black+$02 : STA.w PaletteBuffer+$0172 : STA.w PaletteBufferAux+$0172 + STA.w PaletteBuffer+$0174 : STA.w PaletteBufferAux+$0174 + STA.w PaletteBuffer+$0176 : STA.w PaletteBufferAux+$0176 + STA.w PaletteBuffer+$0178 : STA.w PaletteBufferAux+$0178 + STA.w PaletteBuffer+$017A : STA.w PaletteBufferAux+$017A + STA.w PaletteBuffer+$017C : STA.w PaletteBufferAux+$017C + STA.w PaletteBuffer+$017E : STA.w PaletteBufferAux+$017E BRA .done .SP05 - LDA.l PalettesCustom_off_black+$00 : STA.l PaletteBuffer+$01B0 - LDA.l PalettesCustom_off_black+$02 : STA.l PaletteBuffer+$01B2 - LDA.l PalettesCustom_off_black+$04 : STA.l PaletteBuffer+$01B4 - LDA.l PalettesCustom_off_black+$06 : STA.l PaletteBuffer+$01B6 - LDA.l PalettesCustom_off_black+$08 : STA.l PaletteBuffer+$01B8 - LDA.l PalettesCustom_off_black+$0A : STA.l PaletteBuffer+$01BA - LDA.l PalettesCustom_off_black+$0C : STA.l PaletteBuffer+$01BC - LDA.l PalettesCustom_off_black+$0E : STA.l PaletteBuffer+$01BE + LDA.l PalettesCustom_off_black+$00 : STA.w PaletteBuffer+$01B0 : STA.w PaletteBufferAux+$01B0 + LDA.l PalettesCustom_off_black+$02 : STA.w PaletteBuffer+$01B2 : STA.w PaletteBufferAux+$01B2 + STA.w PaletteBuffer+$01B4 : STA.w PaletteBufferAux+$01B4 + STA.w PaletteBuffer+$01B6 : STA.w PaletteBufferAux+$01B6 + STA.w PaletteBuffer+$01B8 : STA.w PaletteBufferAux+$01B8 + STA.w PaletteBuffer+$01BA : STA.w PaletteBufferAux+$01BA + STA.w PaletteBuffer+$01BC : STA.w PaletteBufferAux+$01BC + STA.w PaletteBuffer+$01BE : STA.w PaletteBufferAux+$01BE .done INC.b NMICGRAM SEP #$20 STZ.w ItemReceiptMethod : LDA.w AncillaGet, X ; thing we wrote over to get here + PLB +RTL JML Ancilla_ReceiveItem_optimus+6 ;-------------------------------------------------------------------------------- diff --git a/framehook.asm b/framehook.asm index 320eda9..012639e 100644 --- a/framehook.asm +++ b/framehook.asm @@ -62,10 +62,12 @@ TransferItemGFX: ; Only used for shops now but could be used for anything. We should look at how door rando does this ; and try to unify one approach. REP #$30 - LDX.w ItemQueuePtr : BEQ .done + LDX.w ItemStackPtr : BEQ .done + TXA : BIT #$0040 : BNE .fail ; Crash if we have more than 16 queued (should never happen.) + DEX #2 - - LDA.w ItemGFXQueue,X : STA.w ItemGFXPtr - LDA.w ItemTargetQueue,X : STA.w ItemGFXTarget + LDA.l ItemGFXStack,X : STA.w ItemGFXPtr + LDA.l ItemTargetStack,X : STA.w ItemGFXTarget PHX JSL.l TransferItemToVRAM REP #$10 @@ -73,7 +75,9 @@ TransferItemGFX: DEX #2 BPL - - STZ.w ItemQueuePtr + STZ.w ItemStackPtr .done SEP #$30 RTS + .fail + BRK #$00 diff --git a/goalitem.asm b/goalitem.asm index 58bcb07..17ccb9b 100644 --- a/goalitem.asm +++ b/goalitem.asm @@ -188,10 +188,8 @@ CheckEnoughCrystalsForGanon: RTL ;-------------------------------------------------------------------------------- CheckTowerOpen: - REP #$30 LDA.l GanonsTowerOpenMode : ASL : TAX JSR.w (.tower_open_modes,X) - SEP #$30 RTL .tower_open_modes dw .vanilla @@ -199,13 +197,15 @@ RTL .vanilla LDA.l CrystalsField - AND.w #$007F : CMP.w #$007F + AND.b #$7F : CMP.b #$7F RTS .arbitrary_cmp + REP #$30 LDA.l GanonsTowerOpenAddress : TAX LDA.l $7E0000,X CMP.l GanonsTowerOpenTarget + SEP #$30 RTS ;--------------------------------------------------------------------------------------------------- @@ -241,10 +241,9 @@ KillGanon: CMP.b #$06 : BNE .exit .light_speed - 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 - + REP #$20 + LDA.w #$0019 : STA.b GameMode + SEP #$20 .exit RTL @@ -313,7 +312,9 @@ RTL RTS .arbitrary_cmp + REP #$30 LDA.l PedPullAddress : TAX - LDA.l $7E000,X + LDA.l $7E0000,X CMP.l PedPullTarget + SEP #$30 RTS diff --git a/heartpieces.asm b/heartpieces.asm index 5d7da30..acd23ba 100644 --- a/heartpieces.asm +++ b/heartpieces.asm @@ -4,6 +4,7 @@ HeartPieceGet: PHX : PHY JSL.l LoadHeartPieceRoomValue + JSL.l AttemptItemSubstitution JSL.l ResolveLootIDLong TAY JSL.l MaybeMarkDigSpotCollected @@ -117,6 +118,7 @@ HeartPieceSpritePrep: LDA.b #$00 : STA.l RedrawFlag JSL HeartPieceGetPlayer : STA.l !MULTIWORLD_SPRITEITEM_PLAYER_ID JSL.l LoadHeartPieceRoomValue + JSL.l AttemptItemSubstitution JSL.l ResolveLootIDLong STA.w SpriteID, X JSL.l PrepDynamicTile_loot_resolved @@ -131,6 +133,7 @@ HeartContainerSpritePrep: LDA.b #$00 : STA.l RedrawFlag JSL HeartPieceGetPlayer : STA.l !MULTIWORLD_SPRITEITEM_PLAYER_ID JSL.l LoadHeartContainerRoomValue ; load item type + JSL.l AttemptItemSubstitution JSL.l ResolveLootIDLong STA.w SpriteID, X JSL.l PrepDynamicTile_loot_resolved diff --git a/hooks.asm b/hooks.asm index cb4e17b..15588a9 100644 --- a/hooks.asm +++ b/hooks.asm @@ -66,10 +66,8 @@ org $00FFEA : dw NMIBounce org $00FFEE : dw IRQBounce org $8098AB - -NMIBounce: JML $8080C9 -IRQBounce: JML $8082D8 - +NMIBounce: JML.l $8080C9 +IRQBounce: JML.l $8082D8 warnpc $8098C0 ;================================================================================ @@ -1461,19 +1459,15 @@ MVN $A17E org $8DFB1F : JSL CheckHUDSilverArrows org $8DFB29 : BRA UpdateHUDBuffer_update_item_check_arrows ;-------------------------------------------------------------------------------- -org $8DF1AB -JSR.w RebuildHUD_update -org $8DDFC8 -JSR.w RebuildHUD_update +org $8DF1AB : JSR.w RebuildHUD_update +org $8DDFC8 : JSR.w RebuildHUD_update org $8DDB88 ; Don't rebuild HUD twice on icon refresh NOP #3 ; Not sure why this is here ;-------------------------------------------------------------------------------- -org $87A205 -JSL.l RebuildHUD_update_long -org $8AEF62 -JSL.l RebuildHUD_update_long -org $87A1CF -JSL.l RebuildHUD_update_long +org $87A205 : JSL.l RebuildHUD_update_long +org $8AEF62 : JSL.l RebuildHUD_update_long +org $87A1CF : JSL.l RebuildHUD_update_long +org $87A235 : JSL.l RebuildHUD_update_long ;-------------------------------------------------------------------------------- org $8DFFE1 RebuildHUD_update_long: diff --git a/init.asm b/init.asm index 59fadbc..fee19f9 100644 --- a/init.asm +++ b/init.asm @@ -48,11 +48,12 @@ Init_Primary: LDA.l OneMindTimerInit : STA.l OneMindTimerRAM SEP #$30 - LDA.b #$01 : STA.w MEMSEL ; enable fastrom access on upper banks - STA.l OneMindId + LDA.l RomSpeed : STA.w MEMSEL ; enable fastrom access on upper banks + LDA.b #$01 : STA.l OneMindId LDA.b #$10 : STA.b PlayerSpriteBank ; set default player sprite bank LDA.b #$81 : STA.w NMITIMEN ; thing we wrote over, turn on NMI & gamepad + LDA.b #(ReturnFromInit>>16)|$80 : PHA : PLB JML ReturnFromInit diff --git a/inventory.asm b/inventory.asm index 9ddbed3..2a188ac 100644 --- a/inventory.asm +++ b/inventory.asm @@ -531,6 +531,7 @@ LoadPowder: JSL.l Sprite_SpawnDynamically ; thing we wrote over LDA.l WitchItem_Player : STA !MULTIWORLD_SPRITEITEM_PLAYER_ID %GetPossiblyEncryptedItem(WitchItem, SpriteItemValues) + JSL.l AttemptItemSubstitution JSL.l ResolveLootIDLong STA.w SpriteID, Y STA.l PowderFlag @@ -588,6 +589,7 @@ LoadMushroom: LDA.b #$00 : STA.l RedrawFlag LDA.l MushroomItem_Player : STA !MULTIWORLD_SPRITEITEM_PLAYER_ID %GetPossiblyEncryptedItem(MushroomItem, SpriteItemValues) + JSL.l AttemptItemSubstitution JSR.w ResolveLootID STA.w SpriteID,X JSL.l PrepDynamicTile diff --git a/itemdatatables.asm b/itemdatatables.asm index 743def2..1f36c99 100644 --- a/itemdatatables.asm +++ b/itemdatatables.asm @@ -183,9 +183,9 @@ endmacro %ReceiptProps($2B, -4, 0, $1E, $F35C, $FF, skip, bottles) ; 2B - Full bottle (red) %ReceiptProps($2C, -4, 0, $1E, $F35C, $FF, skip, bottles) ; 2C - Full bottle (green) %ReceiptProps($2D, -4, 0, $1E, $F35C, $FF, skip, bottles) ; 2D - Full bottle (blue) -%ReceiptProps($2E, -4, 0, $1E, $F36D, $FF, skip, bottles) ; 2E - Potion refill (red) -%ReceiptProps($2F, -4, 0, $1E, $F36E, $FF, skip, bottles) ; 2F - Potion refill (green) -%ReceiptProps($30, -4, 0, $1E, $F36E, $FF, skip, bottles) ; 30 - Potion refill (blue) +%ReceiptProps($2E, -4, 0, $1E, $F36D, $FF, skip, skip) ; 2E - Potion refill (red) +%ReceiptProps($2F, -4, 0, $1E, $F36E, $FF, skip, skip) ; 2F - Potion refill (green) +%ReceiptProps($30, -4, 0, $1E, $F36E, $FF, skip, skip) ; 30 - Potion refill (blue) %ReceiptProps($31, -4, 0, $30, $F375, $FF, skip, skip) ; 31 - 10 bombs %ReceiptProps($32, -4, 0, $22, $F366, $FF, dungeon_bigkey, skip) ; 32 - Big key %ReceiptProps($33, -4, 0, $21, $F368, $FF, dungeon_map, skip) ; 33 - Map @@ -416,7 +416,7 @@ macro SpriteProps(id, chest_width, standing_width, chest_pal, standing_pal, addr pullpc endmacro -%SpriteProps($00, 2, 2, $02, $02, PalettesVanilla_blue_ice+$0E) ; 00 - Fighter sword & Shield +%SpriteProps($00, 0, 2, $05, $02, PalettesVanilla_blue_ice+$0E) ; 00 - Fighter sword & Shield %SpriteProps($01, 0, 2, $05, $05, PalettesCustom_master_sword) ; 01 - Master sword %SpriteProps($02, 0, 2, $05, $01, PalettesCustom_tempered_sword) ; 02 - Tempered sword %SpriteProps($03, 0, 2, $05, $04, PalettesCustom_golden_sword) ; 03 - Golden sword @@ -452,7 +452,7 @@ endmacro %SpriteProps($21, 2, 2, $01, $01, PalettesVanilla_red_melon+$0E) ; 21 - Net %SpriteProps($22, 2, 2, $02, $02, PalettesVanilla_blue_ice+$0E) ; 22 - Blue mail %SpriteProps($23, 2, 2, $01, $01, PalettesVanilla_red_melon+$0E) ; 23 - Red mail -%SpriteProps($24, 0, 0, $02, $02, PalettesVanilla_blue_ice+$0E) ; 24 - Small key +%SpriteProps($24, 0, 0, $04, $04, PalettesVanilla_blue_ice+$0E) ; 24 - Small key %SpriteProps($25, 2, 2, $02, $02, PalettesVanilla_blue_ice+$0E) ; 25 - Compass %SpriteProps($26, 2, 2, $01, $01, PalettesVanilla_red_melon+$0E) ; 26 - Heart container from 4/4 %SpriteProps($27, 2, 2, $02, $02, PalettesVanilla_blue_ice+$0E) ; 27 - Bomb @@ -590,7 +590,7 @@ endmacro %SpriteProps($AB, 0, 0, $04, $04, PalettesVanilla_blue_ice+$0E) ; AB - Small key of Thieves' Town %SpriteProps($AC, 0, 0, $04, $04, PalettesVanilla_blue_ice+$0E) ; AC - Small key of Turtle Rock %SpriteProps($AD, 0, 0, $04, $04, PalettesVanilla_blue_ice+$0E) ; AD - Small key of Ganon's Tower -%SpriteProps($AE, 2, 2, $04, $04, $0000) ; AE - Reserved +%SpriteProps($AE, 2, 2, $02, $02, $0000) ; AE - Reserved %SpriteProps($AF, 0, 0, $04, $04, PalettesVanilla_blue_ice+$0E) ; AF - Generic small key %SpriteProps($B0, 2, 2, $80, $80, PalettesCustom_crystal) ; B0 - Crystal 6 %SpriteProps($B1, 2, 2, $80, $80, PalettesCustom_crystal) ; B1 - Crystal 1 @@ -1032,7 +1032,7 @@ ItemReceiptGraphicsOffsets: dw $05A0 ; 4D - Arrow capacity (70) dw $01A0 ; 4E - 1/2 magic dw $01E0 ; 4F - 1/4 magic - dw $0 ; 50 - Safe master sword + dw $00E0 ; 50 - Safe master sword dw $0420 ; 51 - Bomb capacity (+5) dw $0460 ; 52 - Bomb capacity (+10) dw $0520 ; 53 - Arrow capacity (+5) diff --git a/keydrop/dynamic_si_vram.asm b/keydrop/dynamic_si_vram.asm index 7f4dbe9..a199eb0 100644 --- a/keydrop/dynamic_si_vram.asm +++ b/keydrop/dynamic_si_vram.asm @@ -35,19 +35,19 @@ RequestStandingItemVRAMSlot: PHX LDA.w DynamicDropQueue ; unsure about substitution rules here, because they aren't skipped properly for MW yet -; JSL AttemptItemSubstitutionLong + JSL AttemptItemSubstitution JSL ResolveLootIDLong ASL : TAX : LDA.l StandingItemGraphicsOffsets,X - LDX.w ItemQueuePtr - STA.w ItemGFXQueue,X + LDX.w ItemStackPtr + STA.w ItemGFXStack,X PLX : PHX REP #$20 LDA.l FreeUWGraphics,X - LDX.w ItemQueuePtr - STA.w ItemTargetQueue,X + LDX.w ItemStackPtr + STA.w ItemTargetStack,X SEP #$20 - TXA : INC #2 : STA.w ItemQueuePtr + TXA : INC #2 : STA.w ItemStackPtr SEP #$30 PLX diff --git a/newitems.asm b/newitems.asm index ff1e6e5..044f19d 100644 --- a/newitems.asm +++ b/newitems.asm @@ -449,7 +449,10 @@ ItemBehavior: RTS .single_arrow - INC.w UpdateHUD + LDA.l ArrowMode : BEQ + + LDA.l CurrentArrows : INC : STA.l CurrentArrows ; Should be sole write to this address + INC.w UpdateHUD ; in retro/rupee bow mode. + + RTS .rupoor @@ -641,7 +644,12 @@ ItemBehavior: .pendant SEP #$20 - LDA.l PendantCounter : INC : STA.l PendantCounter + LSR + SEC : SBC.b #$37 + TAX + LDA.w PendantMasks,X : AND.l PendantsField : BNE + + LDA.l PendantCounter : INC : STA.l PendantCounter + + RTS .dungeon_crystal @@ -660,9 +668,12 @@ ItemBehavior: DEX BPL - SEP #$20 - ORA.l CrystalsField : STA.l CrystalsField - LDA.l CrystalCounter : INC : STA.l CrystalCounter - + TAX + AND.l CrystalsField : BNE + + TXA + ORA.l CrystalsField : STA.l CrystalsField + LDA.l CrystalCounter : INC : STA.l CrystalCounter + + .done RTS @@ -673,7 +684,7 @@ ResolveReceipt: LDA.l !MULTIWORLD_ITEM_PLAYER_ID : BNE + LDA.w ItemReceiptID .get_item - JSR.w AttemptItemSubstitution + JSL.l AttemptItemSubstitution JSR.w HandleBowTracking + LDA.w ItemReceiptID @@ -1037,7 +1048,7 @@ AttemptItemSubstitution: BRA - .exit PLA : PLX -RTS +RTL ;-------------------------------------------------------------------------------- CountBottles: PHX @@ -1145,6 +1156,8 @@ dw $0004 ; EP dw $0002 ; HC dw $0000 ; Sewers +PendantMasks: +db $04, 01, 02 NewItemsChecks: CMP.b #$B2 : BNE + ; Fairy diff --git a/npcitems.asm b/npcitems.asm index a52c51b..2ab6da8 100644 --- a/npcitems.asm +++ b/npcitems.asm @@ -186,6 +186,7 @@ RTL ;-------------------------------------------------------------------------------- LoadZoraKingItemGFX: LDA.l $9DE1C3 ; location randomizer writes zora item to + JSL.l AttemptItemSubstitution JSL.l ResolveLootIDLong STA.w SpriteID,Y TYX @@ -202,6 +203,7 @@ JumpToSplashItemTarget: LoadCatfishItemGFX: LDA.l CatfishItem_Player : STA.l !MULTIWORLD_SPRITEITEM_PLAYER_ID LDA.l $9DE185 ; location randomizer writes catfish item to + JSL.l AttemptItemSubstitution JSL.l ResolveLootIDLong STA.w SpriteID, Y TYX diff --git a/ram.asm b/ram.asm index 3dbf48a..e7a73f4 100644 --- a/ram.asm +++ b/ram.asm @@ -190,10 +190,10 @@ MessageJunk = $7E0223 ; Zeroed but never used (?) ; ShopPurchaseFlag = $7E0224 ; $01 = Shop purchase item receipt. ;CoolScratch = $7E0224 ; 0x5C bytes of free ram -ItemQueuePtr = $7E0226 ; Pointer into Item GFX and VRAM target queues. Word length. +ItemStackPtr = $7E0226 ; Pointer into Item GFX and VRAM target queues. Word length. + ; If not zero, pointer should always be left pointing at the + ; next available slot in the stack during the frame. SpriteID = $7E0230 ; 0x0A bytes. Receipt ID for main loop sprite we're handling. -ItemGFXQueue = $7E0230 ; Pointers to decompressed item tiles deferred to NMI loading. $10 bytes -ItemTargetQueue = $7E0240 ; Pointers to VRAM targets for ItemGFXQueue. $10 bytes AncillaVelocityZ = $7E0294 ; 0x0A bytes AncillaZCoord = $7E029E ; 0x0A bytes ; @@ -476,7 +476,10 @@ HUDArrowCount = $7EC760 ; HUDKeyDigits = $7EC764 ; ; BigRAM = $7EC900 ; Big buffer of free ram (0x1F00) -TotalItemCountTiles = $7ECB00 ; Cached total item count tiles for HUD. Four words high to low. +ItemGFXStack = $7ECB00 ; Pointers to source of decompressed item tiles deferred to NMI loading. +ItemGFXSBankStack = $7ECB20 ; Source bank byte for above. +ItemTargetStack = $7ECB40 ; Pointers to VRAM targets for ItemGFXStack. +TotalItemCountTiles = $7ECF00 ; Cached total item count tiles for HUD. Four words high to low. ;================================================================================ ; Bank 7F @@ -485,7 +488,6 @@ DecompressionBuffer = $7F0000 ; Decompression Buffer. $2000 bytes. DecompBuffer2 = $7F4000 ; Another buffer - base $7F5000 RedrawFlag: skip 1 ; skip 2 ; Unused diff --git a/shopkeeper.asm b/shopkeeper.asm index 260108b..2a68d8f 100644 --- a/shopkeeper.asm +++ b/shopkeeper.asm @@ -120,8 +120,8 @@ SpritePrep_ShopKeeper: LDX.w #$0000 LDY.w #$0000 - - TYA : CMP.l ShopCapacity : !BLT ++ : JMP .stop : ++ - LDA.l ShopContentsTable+1, X : CMP.b #$FF : BNE ++ : JMP .stop : ++ + TYA : CMP.l ShopCapacity : !BLT ++ : JMP .done : ++ + LDA.l ShopContentsTable+1, X : CMP.b #$FF : BNE ++ : JMP .done : ++ LDA.l ShopContentsTable, X : CMP.l ShopId : BEQ ++ : JMP .next : ++ LDA.l ShopContentsTable+1, X : PHX : TYX : STA.l ShopInventory, X : PLX @@ -150,35 +150,29 @@ SpritePrep_ShopKeeper: ++ PLY : +++ - PHX : PHY + PHX : PHY PHX : TYX : LDA.l ShopInventory, X : PLX - SEP #$10 - JSL.l ResolveLootIDLong - ; todo: bee trap id - CMP.b #$C0 : BNE + - PHX : LDA.b #0 : XBA : TYA : LSR #2 : TAX ; This will convert the value back to the slot number (in 8-bit accumulator mode) + SEP #$10 + JSL.l AttemptItemSubstitution + JSL.l ResolveLootIDLong + ; todo: bee trap id + CMP.b #$C0 : BNE + + PHX : LDA.b #0 : XBA : TYA : LSR #2 : TAX ; This will convert the value back to the slot number (in 8-bit accumulator mode) JSL GetRandomInt : AND.b #$3F BNE ++ : LDA.b #$49 : ++ : CMP.b #$26 : BNE ++ : LDA.b #$6A : ++ ; if 0 (fighter's sword + shield), set to just sword, if filled container (bugged palette), switch to triforce piece STA.l ShopInventoryDisguise, X : PLX - + : TAY - REP #$30 + + : TAY + REP #$30 LDA.b 1,s : TAX : LDA.l .tile_offsets, X : TAX JSR.w SetupTileTransfer - PLY : PLX - INY #4 - + PLY : PLX + INY #4 .next INX #9 JMP - - .stop - REP #$20 - LDA.w ItemQueuePtr - DEC #2 - AND.w #$00E - STA.w ItemQueuePtr - SEP #$20 .done + SEP #$20 LDA.l ShopType : BIT.b #$20 : BEQ .notTakeAll ; Take-all .takeAll @@ -227,19 +221,19 @@ SetupTileTransfer: TXA : LSR #2 CLC : ADC.w #!FREE_TILE_ALT .store_target - LDX.w ItemQueuePtr - STA.w ItemTargetQueue,X + LDX.w ItemStackPtr + STA.l ItemTargetStack,X TYA : ASL : TAX LDA.l StandingItemGraphicsOffsets,X - LDX.w ItemQueuePtr - STA.w ItemGFXQueue,X + LDX.w ItemStackPtr + STA.l ItemGFXStack,X TXA INC #2 - AND.w #$000E - STA.w ItemQueuePtr - TDC + STA.l ItemStackPtr + + LDA.w #$0000 REP #$10 ; set 16-bit index registers SEP #$20 RTS @@ -653,7 +647,9 @@ Shopkeeper_DrawNextItem: CPX.b #$0C : BCC .not_powder LDA.l PowderFlag : BRA .resolve .not_powder LDA.l ShopInventory, X ; get item id - .resolve JSL.l ResolveLootIDLong + .resolve + JSL.l AttemptItemSubstitution + JSL.l ResolveLootIDLong STA.b Scrap0D ++ CMP.b #$2E : BNE + : BRA .potion diff --git a/tables.asm b/tables.asm index 9eb9555..5408f4b 100644 --- a/tables.asm +++ b/tables.asm @@ -87,7 +87,6 @@ SmithItemMode: db $01 ; #$00 = Classic Tempering Process - #$01 = Quick Item Get (default) SmithItem: db $02 ; #$02 = Tempered Sword (default) - org $86B55C ; PC 0x3355C ; sprite_smithy_bros.asm : 634 SmithSword: db $02 ; #$02 = Tempered Sword (default) @@ -2781,10 +2780,17 @@ dw #$0C00 ; Blue dw #$1800 ; Green dw #$0800 ; Yellow -org $B0F032 +org $B0F032 ; PC 0x187032 +RomSpeed: +db $01 ; $01 = FastROM (default) | $00 = SlowROM + +org $B0F033 ; PC 0x187033 + +;-------------------------------------------------------------------------------- +; 0x187033 - 187FFF (unused) +;-------------------------------------------------------------------------------- pushpc - ;-------------------------------------------------------------------------------- ; Overworld Map Tables ;-------------------------------------------------------------------------------- diff --git a/tablets.asm b/tablets.asm index 52bc01d..d2959af 100644 --- a/tablets.asm +++ b/tablets.asm @@ -31,6 +31,7 @@ RTS SpawnTabletItem: JSL HeartPieceGetPlayer : STA.l !MULTIWORLD_SPRITEITEM_PLAYER_ID JSL.l LoadOutdoorValue + JSL.l AttemptItemSubstitution JSL.l ResolveLootIDLong PHA LDA.b #$EB : STA.l MiniGameTime diff --git a/utilities.asm b/utilities.asm index 9c88a07..e031ad9 100644 --- a/utilities.asm +++ b/utilities.asm @@ -6,7 +6,7 @@ ; out: A - Sprite GFX ID ;-------------------------------------------------------------------------------- GetSpriteID: - JSR.w AttemptItemSubstitution + JSL.l AttemptItemSubstitution JSR.w ResolveLootID CMP.b #$6D : BEQ .server_F0 ; Server Request F0 CMP.b #$6E : BEQ .server_F1 ; Server Request F1 @@ -32,7 +32,7 @@ RTL ; out: A - Palette ;-------------------------------------------------------------------------------- GetSpritePalette: - JSR AttemptItemSubstitution + JSL.l AttemptItemSubstitution JSR.w ResolveLootID .resolved TAX @@ -81,6 +81,10 @@ RTL ;-------------------------------------------------------------------------------- 20/847B LoadDynamicTileOAMTable: PHP + REP #$20 + LDA.w #$0000 : STA.l SpriteOAM : STA.l SpriteOAM+2 + LDA.w #$0200 : STA.l SpriteOAM+6 + SEP #$20 LDA.b #$24 : STA.l SpriteOAM+4 LDA.w SpriteID,X @@ -88,27 +92,23 @@ LoadDynamicTileOAMTable: STA.l SpriteOAM+5 : STA.l SpriteOAM+13 PHX LDA.l SpriteProperties_standing_width,X : BEQ .narrow - REP #$20 - LDA.w #$0000 : STA.l SpriteOAM : STA.l SpriteOAM+2 - LDA.w #$0200 : STA.l SpriteOAM+6 BRA .done .narrow REP #$20 - LDA.w #$0004 : STA.l SpriteOAM - LDA.w #$0000 : STA.l SpriteOAM+2 - LDA.w #$0200 : STA.l SpriteOAM+6 - LDA.w #$0400 : STA.l SpriteOAM+7 : STA.l SpriteOAM+14 + LDA.w #$0000 : STA.l SpriteOAM+14 LDA.w #$0800 : STA.l SpriteOAM+9 LDA.w #$3400 : STA.l SpriteOAM+11 + SEP #$20 + LDA.b #$04 : STA.l SpriteOAM + .done TXA PLX PLP RTS - ;-------------------------------------------------------------------------------- ; DrawDynamicTile ; in: A - Loot ID @@ -399,23 +399,26 @@ LoadItemPalette: ; Out: A - Sprite palette index PHX : PHY : PHB LDA.b #PalettesVanillaBank>>16 : STA.b Scrap0C - LDA.b #$7E - PHA : PLB + PEA $7E00 + PLB : PLB REP #$30 TXA : ASL : TAX LDA.l SpriteProperties_palette_addr,X : STA.b Scrap0A LDY.w #$000E + LDA.w RoomIndex : CMP.w #$008C : BEQ .aux LDA.w TransparencyFlag : BNE .SP05 - - LDA.b [Scrap0A], Y : STA.w PaletteBuffer+$0170,Y + LDA.b [Scrap0A], Y + STA.w PaletteBuffer+$0170,Y DEY #2 BPL - LDA.w #$0003 BRA .done .SP05 - - LDA.b [Scrap0A], Y : STA.w PaletteBuffer+$01B0,Y + LDA.b [Scrap0A], Y + STA.w PaletteBuffer+$01B0,Y DEY #2 BPL - LDA.w #$0005 @@ -424,6 +427,23 @@ LoadItemPalette: PLB : PLY : PLX INC.b NMICGRAM RTL + .aux + LDA.w TransparencyFlag : BNE .SP05_aux + - + LDA.b [Scrap0A], Y + STA.w PaletteBufferAux+$0170,Y + DEY #2 + BPL - + LDA.w #$0003 + BRA .done + .SP05_aux + - + LDA.b [Scrap0A], Y + STA.w PaletteBufferAux+$01B0,Y + DEY #2 + BPL - + LDA.w #$0005 + BRA .done TransferVRAMStripes: JSL.l TransferNewNameStripes diff --git a/vanillalabels.asm b/vanillalabels.asm index 9943358..295e813 100644 --- a/vanillalabels.asm +++ b/vanillalabels.asm @@ -164,6 +164,8 @@ RenderText_DecompressAndDrawSingle = $8EF4FB DecompressFontGFX = $8EF572 CopyDecompressedCharToTransferBuffer = $8EF5BC CopyDecompressedToFullBuffer = $8EF6A8 +Trinexx_FinalPhase = $9DADB5 +Trinexx_PreFinalPhase = $9DB0D2 ;=================================================================================================== ; Palettes