diff --git a/patch/ff3msu.asm b/patch/ff3msu.asm index 915434d..e969f37 100644 --- a/patch/ff3msu.asm +++ b/patch/ff3msu.asm @@ -41,6 +41,7 @@ .DEFINE SPCCommandTemp $1E23 .DEFINE SPCVolumeTemp $1E24 .DEFINE DancingFlag $1E25 +.DEFINE TrainFlag $1E26 .DEFINE MSULastTrackSet $7EF001 @@ -68,6 +69,14 @@ .DEFINE MSUControl_PlayLoop %00000011 .DEFINE MSUControl_Stop %00000000 +; SPC Commands +.DEFINE SPCSubSong $82 +.DEFINE SPCFade $81 +.DEFINE SPCPlaySong $10 +.DEFINE SPCInterrupt $14 ; TODO: Find out what this actually does. Is it a pause? A stop? Something else? +.DEFINE SPC89 $89 +.DEFINE SPCSFX $18 + ; Subroutine hooks .BANK 0 @@ -152,12 +161,24 @@ done\@: ; Main Code CommandHandle: - ; Are we being given command 82? (which appears to be switch subsong) + ; Check for specific commands lda PlayCommand - cmp #$82 - beq + - jmp OriginalCommand + cmp #SPCSubSong + bne + + jmp SubSongHandle + + cmp #SPCFade + bne + + jmp FadeHandle ++ + cmp #SPC89 + bne + + jmp SPC89Handle ++ + jmp OriginalCommand + + +SubSongHandle: ; Handle subsong changes, primarily used during Dancing Mad ; Are we currently playing a Dancing Mad part? lda MSULastTrackSet cmp #$65 @@ -179,6 +200,27 @@ setflag: sta DancingFlag jmp OriginalCommand +FadeHandle: + ; We'll be doing a lot more here later, but for now, check for fades to volume 00, and silence the MSU-1 if found. + lda $1302 + cmp #$00 + bne + + stz MSUVolume ++ + jmp OriginalCommand + +SPC89Handle: ; Seems to be a different subsong change, used during Phantom Train to switch to the music from the sound effects. + lda PlayTrack + cmp #$20 + bne + + lda #$01 + sta TrainFlag + lda #$ff + sta PlayVolume + jsl MSUMain ++ + jmp OriginalCommand + DancingMadPart2: ; Play Part 2 of Dancing Mad lda #$66 @@ -217,6 +259,18 @@ MSUMain: ; If not found, do the original SPC code jmp OriginalCode MSUFound: +TFCheck: ; Phantom train flag clearing. Clears the phantom train flag if any track other than the phantom train is played. + lda TrainFlag + cmp #$01 + bne BattleCheck + lda PlayTrack + cmp #$20 + beq BattleCheck + cmp #$24 ; Avoid clearing the flag during battle/victory sequence. + beq BattleCheck + cmp #$2f + beq BattleCheck + stz TrainFlag BattleCheck: lda PlayTrack ; Special track handling section @@ -233,13 +287,17 @@ Kefka1Check: lda #$65 ; Play part 1. sta PlayTrack Ending1Check: ; Ending Part 1 - cmp #$53 ; + cmp #$53 bne Ending2Check jml Ending1 Ending2Check: ; Ending Part 2 - cmp #$54 ; - bne SilenceCheck + cmp #$54 + bne TrainCheck jml Ending2 +TrainCheck: ; Phantom Train + cmp #$20 + bne SilenceCheck + jml PhantomTrain SilenceCheck: cmp #$00 ; Silence (FF6 does a *lot* of track 0 requests, we're specifically masking this one to reduce calls to the MSU.) bne RePlayCheck @@ -425,6 +483,16 @@ Kefka5: + jml SpecialHandlingBack +; Phantom train handling. + +PhantomTrain: + lda TrainFlag ; If the train flag is on, play the song, otherwise, let the SPC handle it. + cmp #$01 + bne + + jml SpecialHandlingBack ++ + jml ShutUpAndLetMeTalk + ; Ending part 2 handling. Ending2: ; We don't use this track, instead piggybacking onto the end of Ending Part 1, so just silence and return. diff --git a/patch/ff3msu.ips b/patch/ff3msu.ips index 75b574b..ef8818d 100644 Binary files a/patch/ff3msu.ips and b/patch/ff3msu.ips differ