Port SPC engine patches to ASAR
This commit is contained in:
@@ -207,6 +207,9 @@ incsrc stats/main.asm
|
||||
org $308000 ; bank #$30
|
||||
incsrc tables.asm
|
||||
|
||||
org $348000
|
||||
incsrc spc.asm
|
||||
|
||||
; uncomment for inverted adjustments
|
||||
;incsrc sandbox.asm
|
||||
|
||||
|
||||
180
spc.asm
180
spc.asm
@@ -1,106 +1,102 @@
|
||||
// Build with bass v15
|
||||
// This code apparently triggers a pathalogical edge case
|
||||
// which breaks forward labels, necessitating db-style branches
|
||||
// but the code is really only for documentation anyway, we're
|
||||
// using a compiled .bps patch for actual patch generation.
|
||||
; WARNING: THIS CODE IS EXTREMELY FRAGILE
|
||||
|
||||
architecture wdc65816
|
||||
macro copybin(source, length)
|
||||
!copycount #= 0
|
||||
while !copycount+3 < <length>
|
||||
dd read4(pctosnes(<source>+!copycount))
|
||||
!copycount #= !copycount+4
|
||||
endif
|
||||
|
||||
macro rom_seek(variable address) {
|
||||
origin ((address & $7F0000) >> 1) | (address & $7FFF)
|
||||
base address
|
||||
}
|
||||
while !copycount < <length>
|
||||
db read1(pctosnes(<source>+!copycount))
|
||||
!copycount #= !copycount+1
|
||||
endif
|
||||
endmacro
|
||||
|
||||
rom_seek($400000) // Pad ROM to 0x200000
|
||||
;@ pushpc
|
||||
org $008901
|
||||
LDA.b #SPCData : STA $00
|
||||
LDA.b #SPCData>>8 : STA $01
|
||||
LDA.b #SPCData>>16 : STA $02
|
||||
;@ pullpc
|
||||
|
||||
rom_seek($008901)
|
||||
lda.b #(SPC.IntroSongBank & 0xFF); sta $00
|
||||
lda.b #((SPC.IntroSongBank >> 8) & 0xFF); sta $01
|
||||
lda.b #((SPC.IntroSongBank >> 16) & 0xFF); sta $02
|
||||
SPCData:
|
||||
;@ check bankcross off
|
||||
%copybin($0C8000, $7BCA)
|
||||
|
||||
rom_seek($348000) // Seek to ROM offset 0x1A0000
|
||||
!SPCEngineStart = $0800
|
||||
!SPCCodeStart = $07A7
|
||||
|
||||
architecture spc700
|
||||
dw ($0F9E+(!SPCEngineStart-!SPCCodeStart))
|
||||
dw !SPCCodeStart
|
||||
|
||||
namespace SPC {
|
||||
constant ENGINE_ENTRYPOINT = $0800
|
||||
constant NEW_CODE_LENGTH = (EngineStart - NewCodeSection)
|
||||
constant CODE_START = (ENGINE_ENTRYPOINT - NEW_CODE_LENGTH)
|
||||
;@ pushpc
|
||||
;@ pushbase
|
||||
|
||||
macro spc_seek(variable address) {
|
||||
origin (address & $FFFF) + (((START & $7F0000) >> 1) | (START & $7FFF)) - CODE_START
|
||||
base address
|
||||
}
|
||||
|
||||
// Insert the original SPC transfer blocks up to the main engine code
|
||||
insert IntroSongBank, "alttp.sfc", 0x0C8000, 0x7BCA
|
||||
dw NEW_CODE_LENGTH + $0F9E // New code is prepended to the original upload
|
||||
dw CODE_START // of length $0F9E to destination $0800
|
||||
|
||||
|
||||
START:
|
||||
spc_seek(CODE_START)
|
||||
if pc() < $0700 {
|
||||
error "SPC code out of bounds (PC < $0700)"
|
||||
}
|
||||
|
||||
// Any new code goes here. DON'T DELETE THIS LABEL
|
||||
// Labels not forward-declared (e.g. '+/++') don't work here
|
||||
NewCodeSection:
|
||||
arch spc700
|
||||
base !SPCCodeStart
|
||||
org $34FBCE;-(!SPCEngineStart-!SPCCodeStart)
|
||||
NewSPCCode:
|
||||
|
||||
SpecialCommand_Mute:
|
||||
cmp #$F0 // The thing we overwrote
|
||||
// bne +
|
||||
db $D0, $03
|
||||
jmp $0A81 // SilenceSong
|
||||
+; cmp #$FA // New mute command $FA
|
||||
// bne +
|
||||
db $D0, $1C
|
||||
sta $F4
|
||||
lda #$00
|
||||
sta $0A4A // $0A49: lda #$70 -> lda #$00
|
||||
sta $0AF3 // $0AF2: MOV $059,#$C0 -> MOV $059,#$00
|
||||
sta $0C32 // $0C32: MOVW $058,YA -> NOP #2
|
||||
sta $0C33
|
||||
lda #$C4 // $0D19: MOVW $058,YA -> lda $058
|
||||
sta $0D19
|
||||
lda #$58
|
||||
sta $0D1A
|
||||
// bra ++
|
||||
db $2F, $23
|
||||
+; cmp #$FB // New unmute command $FB
|
||||
// beq +
|
||||
db $F0, $03
|
||||
jmp $0A9D // NewSongInput
|
||||
+; sta $F4
|
||||
lda #$70
|
||||
sta $0A4A // $0A49: lda #$70
|
||||
lda #$C0
|
||||
sta $0AF3 // $0AF2: MOV $059,#$C0
|
||||
lda #$DA
|
||||
sta $0C32 // $0C32: MOVW $058,YA
|
||||
sta $0D19 // $0D19: MOVW $058,YA
|
||||
lda #$58
|
||||
sta $0C33
|
||||
sta $0D1A
|
||||
+; jsr $0A81 // SilenceSong
|
||||
-; lda $F4
|
||||
bne -
|
||||
cmp $F4
|
||||
bne -
|
||||
str $F4=$00 // ACK the CPU
|
||||
rts
|
||||
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 $0A49,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
|
||||
|
||||
EngineStart:
|
||||
// Upload the main engine, along with the rest of the original transfer block
|
||||
insert "alttp.sfc", 0x0CFBCE, 0x57B2
|
||||
org !SPCEngineStart
|
||||
|
||||
// Hook to check for new special mute commands FA, FB
|
||||
spc_seek($0A73) // $0A73: CMP A,#$F0
|
||||
jmp SpecialCommand_Mute
|
||||
nop
|
||||
arch 65816
|
||||
SPCEngineStart:
|
||||
;@ pullbase
|
||||
;@ pullpc
|
||||
skip !SPCEngineStart-!SPCCodeStart
|
||||
%copybin($0CFBCE, $57B2)
|
||||
SPCEngineEnd:
|
||||
;@ check bankcross on
|
||||
|
||||
rom_seek($0C8000)
|
||||
fill 0xD380
|
||||
; Change track 15 (unused) to point to 13 (Death Mountain) so dark woods can be track 15
|
||||
org $359F6E ; PC 0x1A9F6E ; SPC $D01C
|
||||
dw #$2B00 ; Set track 15 pointer to track 13's data
|
||||
|
||||
} // namespace SPC
|
||||
arch spc700
|
||||
org $34FE9A ; PC 0x1A7E9A ; SPC $0A73
|
||||
JMP !SPCCodeStart : NOP
|
||||
arch 65816
|
||||
|
||||
@@ -731,10 +731,6 @@ org $06C93B ; PC 0x3493B
|
||||
PyramidPotion:
|
||||
db #$2C ; #$2C = Green Potion
|
||||
;--------------------------------------------------------------------------------
|
||||
; Change track 15 (unused) to point to 13 (Death Mountain) so dark woods can be track 15
|
||||
org $1A9F15 ; PC 0xD1F15
|
||||
dw #$2B00 ; Set track 15 pointer to track 13's data
|
||||
;--------------------------------------------------------------------------------
|
||||
org $308140 ; PC 0x180140 - 0x18014A [encrypted]
|
||||
HeartPieceOutdoorValues:
|
||||
HeartPiece_Spectacle:
|
||||
|
||||
Reference in New Issue
Block a user