Skip to content

Commit

Permalink
Train and fadeout fixes (#77)
Browse files Browse the repository at this point in the history
* Potential fix for unhandled fades-to-silence.

Currently untested. Potential fix for #73, #38, part of #74, and maybe #32.

* Merged new version of Phantom Train fix.
  • Loading branch information
Dizzy611 authored May 1, 2018
1 parent 6b81b9d commit ed74bb1
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 7 deletions.
82 changes: 75 additions & 7 deletions patch/ff3msu.asm
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
.DEFINE SPCCommandTemp $1E23
.DEFINE SPCVolumeTemp $1E24
.DEFINE DancingFlag $1E25
.DEFINE TrainFlag $1E26
.DEFINE MSULastTrackSet $7EF001


Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand Down
Binary file modified patch/ff3msu.ips
Binary file not shown.

0 comments on commit ed74bb1

Please sign in to comment.