diff --git a/LTTP_RND_GeneralBugfixes.asm b/LTTP_RND_GeneralBugfixes.asm index 586527a..9d66240 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" @@ -361,8 +370,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 diff --git a/bugfixes.asm b/bugfixes.asm index ff550b2..e4bd117 100644 --- a/bugfixes.asm +++ b/bugfixes.asm @@ -127,12 +127,12 @@ RTL ;-------------------------------------------------------------------------------- ;-------------------------------------------------------------------------------- -;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: diff --git a/compasses.asm b/compasses.asm index 223f5fa..7f27cd8 100644 --- a/compasses.asm +++ b/compasses.asm @@ -4,7 +4,13 @@ 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 diff --git a/drhooks.asm b/drhooks.asm index 1d3b485..a5815d9 100644 --- a/drhooks.asm +++ b/drhooks.asm @@ -76,6 +76,9 @@ nop : jsl OverridePaletteHeader org $02817e ; Bank02.asm : 414 (LDA $02811E, X) jsl FixAnimatedTiles +org $0aef43 ; UnderworldMap_RecoverGFX +jsl FixCloseDungeonMap + org $028a06 ; Bank02.asm : 1941 Dungeon_ResetTorchBackgroundAndPlayer JSL FixWallmasterLamp @@ -186,9 +189,9 @@ Main_ShowTextMessage: ; Conditionally disable UW music changes in Door Rando org $028ADB ; <- Bank02.asm:2088-2095 (LDX.b #$14 : LDA $A0 ...) -JSL.l Underworld_DoorDown_Entry : CPX #$10 -db $B0, $21 ; BCS $028B04 -BRA + : NOP #6 : + +JSL.l Underworld_DoorDown_Entry : CPX #$FF +BEQ + : db $80, $1C ; BRA $028B04 +NOP #6 : + org $02C3F2 ; <- Bank02.asm:10521 Unused call Underworld_DoorDown_Call: diff --git a/events.asm b/events.asm index 913818f..cad6942 100644 --- a/events.asm +++ b/events.asm @@ -185,7 +185,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..418a6e7 100644 --- a/flipperkill.asm +++ b/flipperkill.asm @@ -68,3 +68,70 @@ 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 + STZ.b $67 + + 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 diff --git a/gfx.asm b/gfx.asm index b22fba6..94cb884 100644 --- a/gfx.asm +++ b/gfx.asm @@ -45,6 +45,16 @@ FixAnimatedTiles: + LDA $02802E, X ; what we wrote over RTL +FixCloseDungeonMap: + LDA.l DRMode : CMP #$02 : BNE .vanilla + LDA $040C : BMI .vanilla + LSR : TAX + LDA.l DungeonTilesets,x + RTL + .vanilla + LDA $7EC20E + RTL + FixWallmasterLamp: ORA $0458 STY $1C : STA $1D : RTL ; what we wrote over diff --git a/hooks.asm b/hooks.asm index e2195c3..5faa6f5 100755 --- a/hooks.asm +++ b/hooks.asm @@ -2324,8 +2324,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 @@ -2591,13 +2601,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/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 diff --git a/music.asm b/music.asm index 7160ed1..38f5b56 100644 --- a/music.asm +++ b/music.asm @@ -289,14 +289,16 @@ Overworld_MosaicDarkWorldChecks: ; ; On entry, A=16bit XY=8bit, A & X safe to mod, Y unknown Underworld_DoorDown_Entry: - LDA.l DRMode : TAX : LDA $A0 : CPX #0 : BNE .done + LDX #$FF ; some junk value to be used later to determine if the below lines will change the track + LDA.l $7EF3C5 : AND.w #$00FF : CMP.w #2 : !BLT .vanilla + LDA.l DRMode : BNE .done .vanilla ; thing we wrote over - CMP.w #$0012 : BNE + + LDA $A0 : CMP.w #$0012 : BNE + LDX.b #$14 ; value for Sanc music BRA .done - + CMP.w #$0002 : BNE .done + + LDA $A2 : CMP.w #$0012 : BNE .done LDX.b #$10 ; value for Hyrule Castle music .done - RTL + LDA $A0 : RTL ;-------------------------------------------------------------------------------- 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 diff --git a/stats/creditsnew.asm b/stats/creditsnew.asm index 46173d0..94b4f05 100644 --- a/stats/creditsnew.asm +++ b/stats/creditsnew.asm @@ -536,6 +536,10 @@ CreditsLineBlank: %blankline() +%bigcredits("PINKUS YUZUHARA") + +%blankline() + %bigcredits("SAKURATSUBASA") %blankline() @@ -576,9 +580,6 @@ CreditsLineBlank: %emptyline() %emptyline() %emptyline() -%emptyline() -%emptyline() -%emptyline() ;=================================================================================================== diff --git a/tables.asm b/tables.asm index e158516..2b70345 100644 --- a/tables.asm +++ b/tables.asm @@ -1882,7 +1882,7 @@ Enable_TerrorPin_AI_Fix: db #$00 ;Shop slot count as check -org $30E560 ; PC 0x18650 +org $30E560 ; PC 0x186560 EnableShopItemCount: db #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00 db #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00 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