From 4ec6acfae7e830b6a2282b07f6ade8db682a1847 Mon Sep 17 00:00:00 2001 From: Thomas Prescott Date: Tue, 5 Oct 2021 14:11:55 -0500 Subject: [PATCH 01/10] Remove ZSNES graphic This graphic takes up too much space. Instead if the check fails just do a STP and don't include any of the ZSNES graphics. If we want to add some other message here later we can, but it's more of a nice to have than a necessity. --- zsnes.asm | 98 ------------------------------------------------------- 1 file changed, 98 deletions(-) diff --git a/zsnes.asm b/zsnes.asm index e4cde9d..5c27ec6 100644 --- a/zsnes.asm +++ b/zsnes.asm @@ -11,104 +11,6 @@ CheckZSNES: LDA #$01FF : TCS ; thing we wrote over - initialize stack JML.l ReturnCheckZSNES .zsnes -; Set up video mode - SEP #$30 ; X,Y,A are 8 bit numbers - LDA #$80 ; screen off - STA $2100 ; brightness + screen enable register - LDA #$03 - STA $2105 ; video mode 3, 8x8 tiles, 256 color BG1, 16 color BG2 - STZ $2106 ; noplanes, no mosaic, = Mosaic register - LDA #$01 - STA $210B ; Set BG1 tile data offset to $2000 - STZ $210D ; Plane 0 scroll x (first 8 bits) - STZ $210D ; Plane 0 scroll x (last 3 bits) #$0 - #$07ff - LDA #$01 - STA $212C ; Enable BG1 - LDA #$FF - STA $210E ; Set BG1 scroll register - STA $210E - STZ $212E ; Window mask for Main Screen - STZ $212F ; Window mask for Sub Screen - LDA #$30 - STA $2130 ; Color addition & screen addition init setting - STZ $2131 ; Add/Sub sub designation for screen, sprite, color - LDA #$E0 - STA $2132 ; color data for addition/subtraction - STZ $2133 ; Screen setting (interlace x,y/enable SFX data) - STZ $4200 ; Disable V-blank, interrupt, Joypad register - - REP #$10 - - -; Load tilemap and tile data - STZ $2116 - LDA #$0C - STA $2107 ; Set BG1 tilemap offset to $1800 and size to 32x32 - STA $2117 ; VRAM write address $1800 - - LDA #$80 - STA $2115 ; VRAM single word transfer, word increment - LDX #$1801 - STX $4300 ; DMA destination: VMDATAL/VMDATAH, fixed source - LDX.w #ZSNES_TileMap - STX $4302 ; Low DMA source address - LDA.b #ZSNES_TileMap>>16 - STA $4304 ; High DMA source address - LDX.w #$800 - STX $4305 ; Transfer 2048 bytes - LDA #$01 - STA $420B ; Start DMA transfer - - LDX.w #ZSNES_Tiles - STX $4302 ; Low DMA source address - LDA.b #ZSNES_Tiles>>16 - STA $4304 ; High DMA source address - LDX.w #$8000 - STX $4305 ; Transfer 32768 bytes - LDA #$01 - STA $420B ; Start DMA transfer - - LDX.w #$8000 - STX $4302 ; Low DMA source address - LDA.b #$38 ; (ZSNES_Tiles>>16)+1 - STA $4304 ; High DMA source address - LDX.w #$6040 - STX $4305 ; Transfer 24640 bytes - LDA #$01 - STA $420B ; Start DMA transfer - -; Load CGRAM via DMA transfer - - STZ $2121 ; Start at color 0 - LDX #$2200 - STX $4300 ; DMA destination: CGDATA, byte increment - LDX.w #ZSNES_Palette - STX $4302 ; Low DMA source address - LDA.b #ZSNES_Palette>>16 - STA $4304 ; High DMA source address - LDX #$0200 - STX $4305 ; Transfer 512 bytes - LDA #$01 - STA $420B ; Start DMA transfer - - LDA #$0F ; screen on, full brightness - STA $2100 ; brightness + screen enable register STP ; ! ;-------------------------------------------------------------------------------- -;@ pushpc -;@ check bankcross off - -org $378000 - -ZSNES_Tiles: - incbin zsnes_tiles.bin - -ZSNES_TileMap: - incbin zsnes_tilemap.bin - -ZSNES_Palette: - incbin zsnes_pal.bin - -;@ check bankcross on -;@ pullpc \ No newline at end of file From 798af492154523a9927f52659616a97cddcddde1 Mon Sep 17 00:00:00 2001 From: Thomas Prescott Date: Tue, 5 Oct 2021 17:02:24 -0500 Subject: [PATCH 02/10] Update LTTP_RND_GeneralBugfixes.asm --- LTTP_RND_GeneralBugfixes.asm | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/LTTP_RND_GeneralBugfixes.asm b/LTTP_RND_GeneralBugfixes.asm index 83c20df..9960257 100644 --- a/LTTP_RND_GeneralBugfixes.asm +++ b/LTTP_RND_GeneralBugfixes.asm @@ -329,8 +329,7 @@ warnpc $B08000 ;$31 Graphics Bank ;$32 Text Bank ;$33 Graphics Bank -;$37 Don't Use ZSNES Graphics -;$38 Don't Use ZSNES Graphics (continued) +;$36 reserved for Enemizer ;$3A reserved for downstream use ;$3B reserved for downstream use ;$3F reserved for internal debugging From 2b1a3566d8d5d7b20eec7cc661ebe136ccff418f Mon Sep 17 00:00:00 2001 From: spannerisms <32842036+spannerisms@users.noreply.github.com> Date: Sun, 31 Oct 2021 10:38:38 -0400 Subject: [PATCH 03/10] flibber --- events.asm | 2 +- flipperkill.asm | 66 +++++++++++++++++++++++++++++++++++++++++++++++++ hooks.asm | 18 +++++++++++--- tables.asm | 1 + 4 files changed, 82 insertions(+), 5 deletions(-) diff --git a/events.asm b/events.asm index 7999bee..d8ff634 100644 --- a/events.asm +++ b/events.asm @@ -177,7 +177,7 @@ RTL ;-------------------------------------------------------------------------------- OnLinkDamaged: JSL.l IncrementDamageTakenCounter_Arb - JSL.l FlipperKill + ;JSL.l FlipperKill JML.l OHKOTimer ;-------------------------------------------------------------------------------- diff --git a/flipperkill.asm b/flipperkill.asm index ac782c2..1f8d04d 100644 --- a/flipperkill.asm +++ b/flipperkill.asm @@ -68,3 +68,69 @@ MysteryWaterFunction: ; *$3AE54 ALTERNATE ENTRY POINT STZ $0360 RTL ;-------------------------------------------------------------------------------- + + +;=================================================================================================== +; More elegant solution +;=================================================================================================== + +protectff: + LDA.l AllowAccidentalMajorGlitch + BEQ .yes_protect + + RTL + +.yes_protect + REP #$30 + + LDA.b $20 + AND.w #$1E00 + ASL + ASL + ASL + STA.b $06 + + LDA.b $22 + AND.w #$1E00 + ORA.b $06 + + XBA + LSR + TAX + + SEP #$30 + + ; Remove dark world bit + ; in game table that converts coordinates to actual screen ID + ; special case for other areas + LDA.b $8A + BMI .special_overworld + + AND.b #$3F + CMP.l $02A4E3,X + BEQ ++ + +.protect + LDA.b #$15 + STA.b $5D + + STZ.b $2E + + LDA.b #$02 + STA.b $2F + + STZ.w $0112 + STZ.w $02E4 + STZ.w $0FFC + +++ RTL + +.special_overworld + CMP.l .spow,X + BNE .protect + + RTL + +.spow + db $80, $81, $81, $FF, $FF, $FF, $FF, $FF + db $FF, $81, $81, $FF, $FF, $FF, $FF, $FF \ No newline at end of file diff --git a/hooks.asm b/hooks.asm index af2bfcf..f0534dd 100755 --- a/hooks.asm +++ b/hooks.asm @@ -2259,8 +2259,18 @@ JSL.l OnLinkDamagedFromPitOutdoors org $078F27 ; <- 38F27 JSL.l FlipperReset ;-------------------------------------------------------------------------------- -org $09F40B ; <- 4F40B - module_death.asm:222 (LDX.b #$00) -JSL.l IgnoreFairyCheck +org $02B468 + dw FakeFlipperProtection + +org $02FFC7 +FakeFlipperProtection: + JSR.w $029485 + JSL protectff + RTS + +;-------------------------------------------------------------------------------- +;org $09F40B ; <- 4F40B - module_death.asm:222 (LDX.b #$00) +;JSL.l IgnoreFairyCheck ;-------------------------------------------------------------------------------- org $078F51 ; <- 38F51 - Bank07.asm:2444 (JSR $AE54 ; $3AE54 IN ROM) JSL.l OnEnterWater : NOP @@ -2526,13 +2536,13 @@ org $0DA9C8 ; <- 06A9C8 - player_oam.asm: 1663 (AND.w #$00FF : CMP.w #$00F8 : BC LDA $02 ; always zero! (this replaces the BCC) ADC.w #0000 ; put the carry bit into the accumulator instead of a hardcoded 1. ;------------------------------------------------------------------------------- -org $02fd6f ; <- 017d6f - bank0E.asm: 3694 (LoadActualGearPalettes:) Note: Overflow of bank02 moved to 0e in US Rom +org $02FD6F ; <- 017d6f - bank0E.asm: 3694 (LoadActualGearPalettes:) Note: Overflow of bank02 moved to 0e in US Rom JSL LoadActualGearPalettesWithGloves RTL ;-------------------------------------------------------------------------------- ; Bunny Palette/Overworld Map Bugfix ;-------------------------------------------------------------------------------- -org $02fdf0 ; <- 017df0 - bank0E (LDA [$00] : STA $7EC300, X : STA $7EC500, X) +org $02FDF0 ; <- 017df0 - bank0E (LDA [$00] : STA $7EC300, X : STA $7EC500, X) JSL LoadGearPalette_safe_for_bunny RTS ;================================================================================ diff --git a/tables.asm b/tables.asm index d1eb4ec..75efb96 100644 --- a/tables.asm +++ b/tables.asm @@ -1746,6 +1746,7 @@ dw $0000 ; STAIRS3 ; STAIRS4 ;-------------------------------------------------------------------------------- +RoomHeaders: org $30DA00 : RoomHeader_0000: ; pc 0x185A00 db $41, $21, $13, $22, $07, $3D, $00, $00, $00, $10, $C0, $00, $00, $04 From 553821885f81d175b0bf5dbb5fd71b220f03f6de Mon Sep 17 00:00:00 2001 From: spannerisms <32842036+spannerisms@users.noreply.github.com> Date: Mon, 1 Nov 2021 06:58:30 -0400 Subject: [PATCH 04/10] prevent transition --- flipperkill.asm | 1 + 1 file changed, 1 insertion(+) diff --git a/flipperkill.asm b/flipperkill.asm index 1f8d04d..6f8c420 100644 --- a/flipperkill.asm +++ b/flipperkill.asm @@ -115,6 +115,7 @@ protectff: STA.b $5D STZ.b $2E + STZ.b $67 LDA.b #$02 STA.b $2F From 24f6a4d8a8878a754f9ecb6cca02ea1e90d58c0d Mon Sep 17 00:00:00 2001 From: spannerisms <32842036+spannerisms@users.noreply.github.com> Date: Fri, 12 Nov 2021 09:25:43 -0500 Subject: [PATCH 05/10] abcd --- flipperkill.asm | 2 +- spc.asm | 159 +++++++++++++++++++----------------------------- 2 files changed, 64 insertions(+), 97 deletions(-) diff --git a/flipperkill.asm b/flipperkill.asm index 6f8c420..418a6e7 100644 --- a/flipperkill.asm +++ b/flipperkill.asm @@ -134,4 +134,4 @@ protectff: .spow db $80, $81, $81, $FF, $FF, $FF, $FF, $FF - db $FF, $81, $81, $FF, $FF, $FF, $FF, $FF \ No newline at end of file + db $FF, $81, $81, $FF, $FF, $FF, $FF, $FF diff --git a/spc.asm b/spc.asm index e1c564b..8946463 100644 --- a/spc.asm +++ b/spc.asm @@ -1,107 +1,74 @@ -; WARNING: THIS CODE IS EXTREMELY FRAGILE - -macro copybin(source, length) - !copycount #= 0 - while !copycount+3 < - dd read4(pctosnes(+!copycount)) - !copycount #= !copycount+4 - endif - - while !copycount < - db read1(pctosnes(+!copycount)) - !copycount #= !copycount+1 - endif -endmacro +MSUCode = $00277E ;@ pushpc -org $008901 -LDA.b #SPCData : STA $00 -LDA.b #SPCData>>8 : STA $01 -LDA.b #SPCData>>16 : STA $02 -;@ pullpc -SPCData: -;@ check bankcross off -%copybin($0C8000, $7BCA) - -!SPCEngineStart = $0800 -!SPCCodeStart = $07A7 - -dw ($0F9E+(!SPCEngineStart-!SPCCodeStart)) -dw !SPCCodeStart - -;@ pushpc -;@ pushbase - -arch spc700 -base !SPCCodeStart -org $34FBCE;-(!SPCEngineStart-!SPCCodeStart) -NewSPCCode: - -SpecialCommand_Mute: -CMP A,#$F0 ; The thing we overwrote -BNE + - JMP $0A81 ; SilenceSong -+ -CMP A,#$FA ; New mute command $FA -BNE + - MOV $F4,A - MOV A,#$00 - MOV $0A4A,A ; $0A49: MOV A,#$70 -> MOV A,#$00 - MOV $0AF3,A ; $0AF2: MOV $059,#$C0 -> MOV $059,#$00 - MOV $0C32,A ; $0C32: MOVW $058,YA -> NOP #2 - MOV $0C33,A - MOV A,#$C4 ; $0D19: MOVW $058,YA -> MOV A,$058 - MOV $0D19,A - MOV A,#$58 - MOV $0D1A,A - BRA +++ -+ -CMP A,#$FB ; New unmute command $FB -BEQ + - JMP $0A9D ; NewSongInput -+ -MOV $F4,A -MOV A,#$70 -MOV $0A4A,A ; $0A49: MOV A,#$70 -MOV A,#$C0 -MOV $0AF3,A ; $0AF2: MOV $059,#$C0 -MOV A,#$DA -MOV $0C32,A ; $0C32: MOVW $058,YA -MOV $0D19,A ; $0D19: MOVW $058,YA -MOV A,#$58 -MOV $0C33,A -MOV $0D1A,A -+++ -CALL $0A81 ; SilenceSong -- : MOV A,$F4 - BNE - - CMP A,$F4 - BNE - -MOV $F4,$00 -RET - -org !SPCEngineStart - -arch 65816 -SPCEngineStart: -;@ pullbase -;@ pullpc -skip !SPCEngineStart-!SPCCodeStart -%copybin($0CFBCE, $57B2) -SPCEngineEnd: -;@ check bankcross on ; Change track 15 (unused) to point to 13 (Death Mountain) so dark woods can be track 15 ; Bank 1 org $1A9F15 ; PC 0x0D1F15 ; SPC $D01C - dw #$2B00 ; Set track 15 pointer to track 13's data + dw $2B00 ; Set track 15 pointer to track 13's data -; Bank 2 -org $359F6E ; PC 0x1A9F6E ; SPC $D01C - dw #$2B00 ; Set track 15 pointer to track 13's data +pullpc + +;--------------------------------------------------------------------------------------------------- arch spc700 -org $34FE9A ; PC 0x1A7E9A ; SPC $0A73 - JMP !SPCCodeStart : NOP + +;@ pushpc +;@ pushbase +org $19FE41 ; SPC 0A73 + JMP MSUCode + +; Hijack unreachable SFX data for globally available code +org $1A9B2E +base MSUCode + +SpecialCommand_Mute: + CMP A,#$F0 ; The thing we overwrote + BNE + + JMP $0A81 ; SilenceSong + + + CMP A,#$FA ; New mute command $FA + BNE + + MOV $F4,A + MOV A,#$00 + MOV $0A4A,A ; $0A49: MOV A,#$70 -> MOV A,#$00 + MOV $0AF3,A ; $0AF2: MOV $059,#$C0 -> MOV $059,#$00 + MOV $0C32,A ; $0C32: MOVW $058,YA -> NOP #2 + MOV $0C33,A + MOV A,#$C4 ; $0D19: MOVW $058,YA -> MOV A,$058 + MOV $0D19,A + MOV A,#$58 + MOV $0D1A,A + BRA +++ + + + CMP A,#$FB ; New unmute command $FB + BEQ + + JMP $0A9D ; NewSongInput + + + MOV $F4,A + MOV A,#$70 + MOV $0A4A,A ; $0A49: MOV A,#$70 + MOV A,#$C0 + MOV $0AF3,A ; $0AF2: MOV $059,#$C0 + MOV A,#$DA + MOV $0C32,A ; $0C32: MOVW $058,YA + MOV $0D19,A ; $0D19: MOVW $058,YA + MOV A,#$58 + MOV $0C33,A + MOV $0D1A,A + +++ + CALL $0A81 ; SilenceSong +- MOV A,$F4 + BNE - + CMP A,$F4 + BNE - + MOV $F4,$00 + RET + +warnpc $1A9B91 + +;@ pullbase +;@ pullpc + arch 65816 From 5fc5dc13b255e10139a600956eb46c4dc28bd04a Mon Sep 17 00:00:00 2001 From: cassidy Date: Tue, 7 Dec 2021 15:29:30 -0500 Subject: [PATCH 06/10] Add ROM version to unused hw vector and before filename in SRAM Two 16 bit ints located at $FFE0 (0x7FE0 PC) in ROM and burned into SRAM starting at $701FFC, just before the ROM name --- LTTP_RND_GeneralBugfixes.asm | 9 +++++++++ init.asm | 9 ++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/LTTP_RND_GeneralBugfixes.asm b/LTTP_RND_GeneralBugfixes.asm index 9960257..a9c3585 100644 --- a/LTTP_RND_GeneralBugfixes.asm +++ b/LTTP_RND_GeneralBugfixes.asm @@ -27,6 +27,15 @@ db #$00 ; expand file to 2mb org $1FFFF8 ; <- FFFF8 timestamp rom db #$20, #$19, #$08, #$31 ; year/month/day +;================================================================================ +!ROM_VERSION_LOW = 1 ; ROM version (two 16-bit integers) +!ROM_VERSION_HIGH = 1 ; + +org $00FFE0 ; Unused hardware vector +RomVersion: +dw !ROM_VERSION_LOW +dw !ROM_VERSION_HIGH + ;================================================================================ !ADD = "CLC : ADC" diff --git a/init.asm b/init.asm index 340c4a9..8fc9a65 100644 --- a/init.asm +++ b/init.asm @@ -1,3 +1,5 @@ +RomVersionSRAM = $701FFC + ;-------------------------------------------------------------------------------- ; Init_Primary ;-------------------------------------------------------------------------------- @@ -39,6 +41,11 @@ Init_Primary: LDA $00FFC0, X : STA $702000, X INX CPX #$15 : !BLT - + LDX #$00 + - + LDA RomVersion, X : STA RomVersionSRAM, X + INX + CPX #$04 : !BLT - .done REP #$20 @@ -63,4 +70,4 @@ Init_PostRAMClear: JSL MSUInit JSL InitRNGPointerTable -JML $00D463 ; The original target of the jump table that we hijacked \ No newline at end of file +JML $00D463 ; The original target of the jump table that we hijacked From c82edadadde0bd7fe8b04962773f834eaafd577b Mon Sep 17 00:00:00 2001 From: cassidy Date: Tue, 7 Dec 2021 15:45:22 -0500 Subject: [PATCH 07/10] Change version defines to use ?= operator Now these defines can be set via CLI, otherwise will be what they are in the file --- LTTP_RND_GeneralBugfixes.asm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/LTTP_RND_GeneralBugfixes.asm b/LTTP_RND_GeneralBugfixes.asm index a9c3585..20030f6 100644 --- a/LTTP_RND_GeneralBugfixes.asm +++ b/LTTP_RND_GeneralBugfixes.asm @@ -28,8 +28,8 @@ org $1FFFF8 ; <- FFFF8 timestamp rom db #$20, #$19, #$08, #$31 ; year/month/day ;================================================================================ -!ROM_VERSION_LOW = 1 ; ROM version (two 16-bit integers) -!ROM_VERSION_HIGH = 1 ; +!ROM_VERSION_LOW ?= 1 ; ROM version (two 16-bit integers) +!ROM_VERSION_HIGH ?= 1 ; org $00FFE0 ; Unused hardware vector RomVersion: From aa6aaffd2f7dfe30d725e395360534f07207b378 Mon Sep 17 00:00:00 2001 From: spannerisms <32842036+spannerisms@users.noreply.github.com> Date: Wed, 15 Dec 2021 01:11:26 -0500 Subject: [PATCH 08/10] prevent crashes --- compasses.asm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/compasses.asm b/compasses.asm index 37295c2..4308465 100644 --- a/compasses.asm +++ b/compasses.asm @@ -14,7 +14,13 @@ endmacro DrawDungeonCompassCounts: LDX $1B : BNE + : RTL : + ; Skip if outdoors - LDX $040C : CPX.b #$FF : BEQ .done ; Skip if not in a dungeon + + ; extra hard safeties for getting dungeon ID to prevent crashes + PHA + LDA.w $040C : AND.w #$00FE : TAX ; force dungeon ID to be multiple of 2 + PLA + + CPX.b #$1B : BCS .done ; Skip if not in a valid dungeon ID CMP.w #$0002 : BEQ ++ ; if CompassMode==2, we don't check for the compass LDA $7EF364 : AND.l DungeonItemMasks, X ; Load compass values to A, mask with dungeon item masks From 04fa0fc1a19339a42c92ef232a8c37fd7d9ae23b Mon Sep 17 00:00:00 2001 From: spannerisms <32842036+spannerisms@users.noreply.github.com> Date: Mon, 20 Dec 2021 16:42:56 -0500 Subject: [PATCH 09/10] match expected usage --- bugfixes.asm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bugfixes.asm b/bugfixes.asm index b5ee34b..0b50407 100644 --- a/bugfixes.asm +++ b/bugfixes.asm @@ -127,12 +127,12 @@ RTS ;-------------------------------------------------------------------------------- ;-------------------------------------------------------------------------------- -;Fix for SQ jumping causing accidental Exploration Glitch +; Fix for SQ jumping causing accidental Exploration Glitch SQEGFix: - LDA Bugfix_PodEG : BNE .done - STZ $047A ;disarm exploration glitch - .done -RTL + LDA.l Bugfix_PodEG : BEQ ++ + STZ.w $047A ; disarm exploration glitch +++ RTL + ;-------------------------------------------------------------------------------- ; Fix crystal not spawning when using somaria vs boss TryToSpawnCrystalUntilSuccess: From 2a3d6fae5824f4a3bdcc7c23ff8a3a123686ce08 Mon Sep 17 00:00:00 2001 From: Thomas Prescott Date: Mon, 3 Jan 2022 13:55:03 -0600 Subject: [PATCH 10/10] update credits --- stats/creditsnew.asm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/stats/creditsnew.asm b/stats/creditsnew.asm index 923c687..d57270b 100644 --- a/stats/creditsnew.asm +++ b/stats/creditsnew.asm @@ -522,6 +522,10 @@ CreditsLineBlank: %blankline() +%bigcredits("PINKUS YUZUHARA") + +%blankline() + %bigcredits("SAKURATSUBASA") %blankline() @@ -562,9 +566,6 @@ CreditsLineBlank: %emptyline() %emptyline() %emptyline() -%emptyline() -%emptyline() -%emptyline() ;===================================================================================================