From 56cb17a0a396a968870c89f3e437e74c8bf2d5f3 Mon Sep 17 00:00:00 2001 From: cassidoxa Date: Tue, 8 Aug 2023 01:00:49 -0400 Subject: [PATCH] Small fixes --- events.asm | 26 ++++++++++++-------------- hooks.asm | 41 +++++++++++++---------------------------- inventory.asm | 5 ++++- itemdatatables.asm | 2 +- newitems.asm | 3 ++- npcitems.asm | 6 ++++-- overworldmap.asm | 2 +- ram.asm | 5 +++-- save.asm | 44 +++++++++++++------------------------------- shopkeeper.asm | 16 +++++++++++----- sram.asm | 9 --------- stats.asm | 1 + tables.asm | 4 ++-- textrenderer.asm | 2 +- vanillalabels.asm | 5 +++++ 15 files changed, 73 insertions(+), 98 deletions(-) diff --git a/events.asm b/events.asm index 370de67..df6d675 100644 --- a/events.asm +++ b/events.asm @@ -88,21 +88,19 @@ OnAga2Defeated: JML.l IncrementAgahnim2Sword ;-------------------------------------------------------------------------------- OnFileCreation: - ; Copy initial SRAM state from ROM to cart SRAM - ; If the inital SRAM table is move these addresses must be changed PHB - LDA.w #$03D7 ; \ - LDX.w #$B000 ; | Copies from beginning of inital sram table up to file name - LDY.w #$0000 ; | (exclusively) - MVN !SRAMBank, !SRAMTableBank ; / - ; Skip file name and validity value - LDA.w #$010C ; \ - LDX.w #$B3E3 ; | Rando-Specific Assignments & Game Stats block - LDY.w #$03E3 ; | - MVN !SRAMBank, !SRAMTableBank ; / + LDA.w #$03D7 + LDX.w #$B000 + LDY.w #$0000 + MVN CartridgeSRAM>>16, InitSRAMTable>>16 + ; Skip file name and validity value + LDA.w #$010C + LDX.w #$B3E3 + LDY.w #$03E3 + MVN CartridgeSRAM>>16, InitSRAMTable>>16 PLB - ; resolve instant post-aga if standard + ; Resolve instant post-aga if standard SEP #$20 LDA.l InitProgressIndicator : BIT #$80 : BEQ + LDA.b #$00 : STA.l ProgressIndicatorSRAM ; set post-aga after zelda rescue @@ -110,9 +108,9 @@ OnFileCreation: + REP #$20 - ; Set validity value and do some cleanup. Jump to checksum. + ; Set validity value and do some cleanup. Jump to checksum done. LDA.w #$55AA : STA.l FileValiditySRAM - JSL.l WriteSaveChecksumAndBackup_from_sram + JSL.l WriteSaveChecksumAndBackup STZ.b Scrap00 STZ.b Scrap01 diff --git a/hooks.asm b/hooks.asm index c17bc86..19f823e 100644 --- a/hooks.asm +++ b/hooks.asm @@ -886,7 +886,7 @@ org $80D557 ; 5557 - Bank00.asm:3486 (LDA $00 : ADC $D469, X) JSL GetAnimatedSpriteBufferPointer : NOP org $8799F7 ; 399F7 - Bank07.asm:4107 (JSL AddReceivedItem) -JSL AddReceivedItemLong +JSL AddReceivedItemExpanded org $898611 ; 48611 - ancilla_init.asm:720 (LDA .item_target_addr+0, X) LDA.w ItemReceipts_target+0, X @@ -2450,33 +2450,18 @@ JSL FixJingleGlitch ; Text Renderer ;-------------------------------------------------------------------------------- if !FEATURE_NEW_TEXT - org $8EF51B - JML RenderCharExtended - org $8EF520 - RenderCharExtended_returnOriginal: - org $8EF567 - RenderCharExtended_returnUncompressed: - - org $8EF356 - JSL RenderCharLookupWidth - org $8EF3BA - JSL RenderCharLookupWidth - org $8EF48E - JML RenderCharLookupWidthDraw - org $8EF499 - RenderCharLookupWidthDraw_return: - - org $8EF6AA - JML RenderCharToMapExtended - org $8EF6C2 - RenderCharToMapExtended_return: - - org $8EFA50 - JSL RenderCharSetColorExtended - org $8EEE5D - JSL RenderCharSetColorExtended_init - org $8EF285 - JSL RenderCharSetColorExtended_close : NOP + org $8EF51B : JML RenderCharExtended + org $8EF520 : RenderCharExtended_returnOriginal: + org $8EF567 : RenderCharExtended_returnUncompressed: + org $8EF356 : JSL RenderCharLookupWidth + org $8EF3BA : JSL RenderCharLookupWidth + org $8EF48E : JML RenderCharLookupWidthDraw + org $8EF499 : RenderCharLookupWidthDraw_return: + org $8EF6AA : JML RenderCharToMapExtended + org $8EF6C2 : RenderCharToMapExtended_return: + org $8EFA50 : JSL RenderCharSetColorExtended + org $8EEE5D : JSL RenderCharSetColorExtended_init + org $8EF285 : JSL RenderCharSetColorExtended_close : NOP endif ;================================================================================ diff --git a/inventory.asm b/inventory.asm index 199729c..1d414eb 100644 --- a/inventory.asm +++ b/inventory.asm @@ -142,6 +142,7 @@ AddInventory: PHA : PHX : PHY : PHP : PHB PHK : PLB LDA.l StatsLocked : BNE .done + LDA.w InventoryTable_properties,Y : BIT #$01 : BEQ .done JSR.w ShopCheck : BCS .done JSR.w DungeonIncrement : BCS .done LDA.b #$7E : STA.b Scrap0D @@ -149,7 +150,6 @@ AddInventory: JSR.w IncrementByOne SEP #$20 JSR.w IncrementYAItems - LDA.w InventoryTable_properties,Y : BIT #$01 : BEQ .done REP #$20 LDA.l TotalItemCounter : INC : TAY LDA.l BootsEquipment : BNE + @@ -211,6 +211,9 @@ DungeonIncrement: + .count CLC +RTS + .dont_count + SEC RTS .ballchain_bigkey LDA.l BigKeysBigChests diff --git a/itemdatatables.asm b/itemdatatables.asm index f9e72e2..39b1fd0 100644 --- a/itemdatatables.asm +++ b/itemdatatables.asm @@ -333,7 +333,7 @@ endmacro %SpriteProps($1D, 2, 2, $04, $04, PalettesVanilla_green_blue_guard+$0E) ; 1D - Book %SpriteProps($1E, 2, 2, $02, $02, PalettesVanilla_blue_ice+$0E) ; 1E - Flippers %SpriteProps($1F, 2, 2, $01, $01, PalettesVanilla_red_melon+$0E) ; 1F - Pearl -%SpriteProps($20, 2, 2, $06, $06, PalettesCustom_crystal) ; 20 - Crystal +%SpriteProps($20, 2, 2, $86, $86, PalettesCustom_crystal) ; 20 - Crystal %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 diff --git a/newitems.asm b/newitems.asm index 14ab4de..510ea11 100644 --- a/newitems.asm +++ b/newitems.asm @@ -117,7 +117,7 @@ ProcessEventItems: PLA : STA.b Scrap00 RTS ;-------------------------------------------------------------------------------- -AddReceivedItemLong: +AddReceivedItemExpanded: JSR.w ResolveReceipt PHB : PHK JML AddReceivedItem+2 @@ -699,6 +699,7 @@ ResolveLootID: LDA.l ProgressiveArmorReplacement JMP.w .get_item + + TAX LDA.w ResolveLootID_armor_ids,X JMP.w .have_item ..ids diff --git a/npcitems.asm b/npcitems.asm index 79f49fa..af5d87d 100644 --- a/npcitems.asm +++ b/npcitems.asm @@ -174,8 +174,10 @@ RTL ; Randomize Zora King ;-------------------------------------------------------------------------------- LoadZoraKingItemGFX: - LDA.l $9DE1C3 ; location randomizer writes zora item to - JML.l PrepDynamicTile + LDA.l $9DE1C3 ; location randomizer writes zora item to + JSL.l ResolveLootIDLong + STA.w SpriteID,X + JML.l PrepDynamicTile ;-------------------------------------------------------------------------------- JumpToSplashItemTarget: LDA.w SpriteMovement, X diff --git a/overworldmap.asm b/overworldmap.asm index 872a50b..e828790 100644 --- a/overworldmap.asm +++ b/overworldmap.asm @@ -80,7 +80,7 @@ PHX .checkIfObtained LDA.l MC_DungeonIdsForPrize, X BPL +++ : CLC : BRA .done : +++ ; non-prize flags - CMP.b #$03 : BCC .hyrule_castle + CMP.b #$02 : BCC .hyrule_castle ASL : TAX REP #$20 LDA.l DungeonsCompleted : AND.l DungeonItemMasks,X : BNE .fail diff --git a/ram.asm b/ram.asm index 884434b..9000afc 100644 --- a/ram.asm +++ b/ram.asm @@ -507,8 +507,9 @@ skip 9 ; ; Shop Block $7F5050 - $7F506F ShopId: skip 1 ; Shop ID. Used for indexing and loading inventory for custom shops ShopType: skip 1 ; Shop type. $FF = vanilla shop - ; t - - - - - - - - ; t = Take-any + ; t d a v - - q q + ; t = $01 - Take-any | d = $01 - Door check | a = $01 = Take-all + ; v = Use alt vram | q = Number of items ShopInventory: skip $0D ; For three possible shop items, row major: ; [Item ID][Price low][Price High][Purchase Count] ShopState: skip 1 ; - - - - - l c r | Bitfield that determines whether to draw an item diff --git a/save.asm b/save.asm index 2aa3c4e..c68c084 100644 --- a/save.asm +++ b/save.asm @@ -1,24 +1,5 @@ ;-------------------------------------------------------------------------------- WriteSaveChecksumAndBackup: - TDC - CLC - LDX.w #$004FC - - - ADC.l SaveDataWRAM, X - DEX #2 - BPL - - LDX.w #$0FFE - - - ADC.l ExtendedFileNameWRAM, X - DEX #2 - BPL - - STA.b Scrap00 - LDA.w #$5A5A - SEC : SBC.b Scrap00 - STA.l InverseChecksumSRAM - BRA .backup_save - - .from_sram TDC CLC LDX.w #$004FC @@ -38,10 +19,10 @@ WriteSaveChecksumAndBackup: .backup_save PHB - LDA.w #$14FF ; \ - LDX.w #CartridgeSRAM ; | Copies $1500 bytes from beginning of cart SRAM to - LDY.w #SaveBackupSRAM ; | $704000 - MVN !SRAMBank, !SRAMBank ; / + LDA.w #$14FF + LDX.w #CartridgeSRAM + LDY.w #SaveBackupSRAM + MVN CartridgeSRAM>>16, CartridgeSRAM>>16 PLB TDC TAX @@ -80,13 +61,14 @@ ValidateSRAM: LDA.w #$5A5A SEC : SBC.b Scrap00 CMP.l SaveBackupSRAM+$4FE : BEQ + - TDC : STA.l FileValiditySRAM ; Delete save by way of zeroing validity marker - BRA .goodchecksum : + + TDC : STA.l FileValiditySRAM ; Delete save + BRA .goodchecksum + + PHB - LDA.w #$14FF ; \ - LDX.w #SaveBackupSRAM ; | Copies $1500 bytes from backup on cart SRAM to - LDY.w #CartridgeSRAM ; | main save location at $700000 - MVN !SRAMBank, !SRAMBank ; / + LDA.w #$14FF + LDX.w #SaveBackupSRAM + LDY.w #CartridgeSRAM + MVN CartridgeSRAM>>16, CartridgeSRAM>>16 PLB .goodchecksum @@ -182,7 +164,7 @@ CopyExtendedSaveFileToWRAM: LDA.w #$0FFF LDX.w #ExtendedSaveDataSRAM LDY.w #ExtendedSaveDataWRAM - MVN $7F, !SRAMBank + MVN ExtendedSaveDataWRAM>>16, CartridgeSRAM>>16 PLB PLA STA.l $7EC00D ; What we wrote over. Keep this write last. @@ -193,7 +175,7 @@ CopyExtendedWRAMSaveFileToSRAM: LDA.w #$0FFF LDX.w #ExtendedSaveDataSRAM LDY.w #ExtendedSaveDataWRAM - MVN !SRAMBank, $7F + MVN CartridgeSRAM>>16, ExtendedSaveDataWRAM>>16 PLB TDC TAX diff --git a/shopkeeper.asm b/shopkeeper.asm index 5ffcdf6..54c1d6a 100644 --- a/shopkeeper.asm +++ b/shopkeeper.asm @@ -1,5 +1,6 @@ !FREE_TILE_BUFFER = $1180 -!FREE_TILE = $5A40 +!FREE_TILE = $5C60 +!FREE_TILE_ALT = $5A40 ;-------------------------------------------------------------------------------- ; $0A : Digit Offset @@ -185,14 +186,19 @@ dw $0100, $0000 ; X - Tile Buffer Offset ; Y - Item ID LoadTile: - TXA : LSR #2 : !ADD.w #!FREE_TILE : STA.w ItemGFXTarget ; load offset from X - ;SEP #$30 + LDA.l ShopType : BIT.w #$0010 : BNE .alt_vram + TXA : LSR #2 + CLC : ADC.w #!FREE_TILE + BRA .store_target + .alt_vram + TXA : LSR #2 + CLC : ADC.w #!FREE_TILE_ALT + .store_target + STA.w ItemGFXTarget TYA : ASL : TAX LDA.l StandingItemGraphicsOffsets,X : STA.w ItemGFXPtr JSL.l TransferItemToVRAM TDC - ;JSL.l GetSpriteID ; convert loot id to sprite id - ;JSL.l GetAnimatedSpriteTile_variable REP #$10 ; set 16-bit index registers SEP #$20 RTS diff --git a/sram.asm b/sram.asm index 48c10f4..2ff50d3 100644 --- a/sram.asm +++ b/sram.asm @@ -428,15 +428,6 @@ SaveBackupSRAM: ; Backup copy of save ram. Game will attempt to ; checksum on file select screen load fails. base off -;================================================================================ -; Bank Definitions -;-------------------------------------------------------------------------------- -; If these move (most likely by placing initsramtable.asm somewhere else) these -; bank definitions need to be changed as well. -;================================================================================ -!SRAMBank = $70 -!SRAMTableBank = $30|$80 - ;================================================================================ ; Assertions ;================================================================================ diff --git a/stats.asm b/stats.asm index acbb0f1..e1e5379 100644 --- a/stats.asm +++ b/stats.asm @@ -106,6 +106,7 @@ IncrementSmallKeysNoPrimary: ++ PLP + + INC.w UpdateHUD JSL.l HUD_RebuildLong PLX RTL diff --git a/tables.asm b/tables.asm index b676acd..f903739 100644 --- a/tables.asm +++ b/tables.asm @@ -2682,9 +2682,9 @@ db $34, $64 ; crystal db $34, $64 ; crystal db $34, $64 ; crystal db $34, $64 ; crystal -db $32, $64 ; crystal +db $34, $64 ; crystal -db $32, $64 ; crystal +db $34, $64 ; crystal db $34, $64 ; crystal db $32, $66 ; skull looking thing db $00, $00 ; red x diff --git a/textrenderer.asm b/textrenderer.asm index 0f0b8da..73d5c5e 100644 --- a/textrenderer.asm +++ b/textrenderer.asm @@ -1,6 +1,6 @@ RenderCharSetColorExtended_init: stz.b Scrap0C - jsl $80d84e + jsl Attract_DecompressStoryGfx rtl RenderCharSetColorExtended_close: diff --git a/vanillalabels.asm b/vanillalabels.asm index c1d88ca..7bddce4 100644 --- a/vanillalabels.asm +++ b/vanillalabels.asm @@ -24,6 +24,7 @@ Tagalong_LoadGfx = $80D463 GetAnimatedSpriteTile = $80D51B GetAnimatedSpriteTile_variable = $80D52D Attract_DecompressStoryGfx = $80D84E +InitializeTilesets = $80E1DB LoadSelectScreenGfx = $80E529 PrepDungeonExit = $80F945 Mirror_InitHdmaSettings = $80FDEE @@ -126,6 +127,7 @@ Sprite_PlayerCantPassThrough = $9EF4E7 ;=================================================================================================== ; Local routines (use JSR) ;=================================================================================================== +LoadBackgroundGraphics = $80E649 RoomTag_PrizeTriggerDoor_open = $81C529 RoomTag_PrizeTriggerDoor_exit = $81C529 RoomTag_GetHeartForPrize = $81C709 @@ -150,6 +152,9 @@ ItemMenu_DrawEquippedYItem = $8DEB3A ItemMenu_DrawEquippedYItem_exit = $8DECE6 ItemMenu_DrawEquipment_dungeonitems = $8DEDCC DrawEquipment = $8DED29 +DecompressFontGFX = $8EF572 +CopyDecompressedCharToTransferBuffer = $8EF5BC +CopyDecompressedToFullBuffer = $8EF6A8 ;=================================================================================================== ; Palettes