New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phantom Train music plays in the scene after you get off the train #74

Closed
edale2 opened this Issue Mar 21, 2018 · 16 comments

Comments

Projects
None yet
2 participants
@edale2

edale2 commented Mar 21, 2018

As reported by F-Bomb on Quimm:
http://forums.qhimm.com/index.php?topic=16077.msg256337#msg256337

After some testing, I'm 75% certain this is a fading issue.

It might be related to a call to one of the 2 or 3 specially handled phantom train tracks, I think a different track may be called for the "train pulling away from the station" effect.

@Insidious611

This comment has been minimized.

Owner

Insidious611 commented Mar 22, 2018

@edale2

This comment has been minimized.

edale2 commented Mar 22, 2018

The reason I think there's a chance it might not be a fading issue, is when watching the scene in the vanilla ROM, you have (from the train's defeat):

track effects (no music)
into
silence, with the train pulling into the station/stopping effect
into
train whistle, Caves of Narshe
into
train pulling off effect (no music)
fade to world-map.

MSU mod:

Phantom Train music
into
silence, with the train pulling into the station/stopping effect
into
train whistle, Caves of Narshe
into
Phantom Train music
fade to world-map.

I'd think if it was purely a fading issue, the switch to Caves of Narshe would fix it, because Phantom Train doesn't play at all after that.

What I think might be happening, is the train pulling off effect is linking to the Phantom Train track, rather than the SPC sound effect, causing the song to play when it should be silence with an SFX.

Also noticed while testing, when you get to the engine of the train, before initiating the fight, there's no music, just the track moving effect (I think this starts when the ghost leaves you, but might be from when you exit the engine's switch room), in the MSU-1 mod, Phantom Train track continues until the boss fight starts. This one's not too much of an issue, in my mind, compared to the other one, which is one of the more emotional scenes in the game.

@edale2

This comment has been minimized.

edale2 commented Mar 22, 2018

I'm guessing the track pulling off effect is the same one used at the beginning of the phantom train section of the game, which is where you probably did something to the coding for special handling, and this is a byproduct.

Then again, not sure you did anything to the coding for it, other than the track being listed as special handling in your notes, and not sure if that means by your mod, or by FFVI...

@Insidious611

This comment has been minimized.

Owner

Insidious611 commented Mar 26, 2018

I just listed that one as potentially problematic in my notes, treat it like any other track, and was waiting to find out how/if it'd break. Kind of surprised I didn't notice this inconsistency myself during my earlier test playthrough. I'm not 100% sure how I'm going to handle this one. This, #73, and good old #38 are likely all going to need me to figure out workarounds for the moment while I try to dive deeper into the games coding as far as subsongs, fading, and volume change.

It is possible, however, that this particular case might be solved with a similar workaround to how dancing mad (the song) works, triggering on the subsong switch command. I would at the very least need PCMs for the train noises in order to set that up though.

@edale2

This comment has been minimized.

edale2 commented Mar 26, 2018

Do you know what track number the different train noises are on? If I get the track numbers, I might be able to rip the SPC train sounds to convert them for testing.

@edale2

This comment has been minimized.

edale2 commented Mar 28, 2018

https://mega.nz/#!PZYzSJ4B!6uOjSFyWoDX76hQDGYtpYgp5au6EwSdusJ_jhd2Rutg

Train pulling away from station effect non-looping, SPC converted to PCM. I normalized it to -6dB, so it should be considerably louder than the actual SPC audio, letting you tell the difference for testing.

Insidious611 added a commit that referenced this issue Apr 17, 2018

Initial work on a fix to bug #74. Untested.
May actually work backwards from intended result (playing first the phantom train track and then switching to the train noise) depending on how $82 is being called here. If so, that's fixable. Can't test right now, and the patch hasn't been rebuilt with these changes so neither can anyone else unless they build it themselves :P. Will try to test soon.

Also requires track 104 (hex 68) to be the train sound effect.

Insidious611 added a commit that referenced this issue Apr 17, 2018

Potential fix for unhandled fades-to-silence.
Currently untested. Potential fix for #73, #38, part of #74, and maybe #32.
@Insidious611

This comment has been minimized.

Owner

Insidious611 commented Apr 19, 2018

So to answer your earlier question, the train noises are on the same track number as Phantom Train, that's the whole point. :P

They're both hex track 20, decimal track 32. If track $20 is loaded, and SPC command $89 is not called, it plays the train sound on a loop (thus your non-looped version is actually not all that useful except for testing, because it needs to be a loop of just the 'click-clack click-clack'. To see what I mean, go to the save room in the car to the right after you first enter the train, save, reload your save, and don't leave the room. You'll get an infinite loop of the noise.)

Fixing this is going to be much messier than I thought it was going to be

@Insidious611

This comment has been minimized.

Owner

Insidious611 commented Apr 19, 2018

Okay so, current fix that I'm testing atm is as follows:

Given a memory address labelled "TrainFlag" that starts out set as 0:

When the Phantom Train track is called, default to letting the SPC handle it, unless TrainFlag is 1, in which case we play our MSU-based song.

If SPC command $89 is called with the Phantom Train playing, set TrainFlag to 1, then jump into the MSU code as if we were playing a new track.

From that point onwards, keep TrainFlag at 1 unless another track is called. Not setting it to 0 immediately prevents the game from continually playing SPC train noises due to the fact a "new track" is called on every scene switch. If another track is called for (such as silence, caves of narshe, you name it, anything other than Phantom Train), the MSU code immediately before doing anything else sets TrainFlag to 0, resetting the routine so it can be called again.

Basically, tl;dr, if this works it should replicate Vanilla behavior. I've got it working for resuming a saved game on the train, I'm testing to see how it behaves for the scene after you beat the train.

EDIT: I also need to make it so that TrainFlag isn't cleared if the battle or victory themes are called, otherwise we get infinite train noise after battles.

@Insidious611

This comment has been minimized.

Owner

Insidious611 commented Apr 19, 2018

HAHA! That worked. I somehow guessed at how to perfectly replicate proper behavior. I was worried it might screw up after the boss battle, but then I realized calling the boss theme is not a normal battle theme, so that clears the flag properly... It now behaves exactly like you described, in chronological order starting from right before hitting the final button to trigger the battle with the train:

MSU Phantom Train (pre-battle)
into
MSU Decisive Battle (during battle)
into
MSU Victory theme (battle won)
into
SPC train noise (talking with train after battle)
into
silence, train pulling into station/stopping
into
train whistle, MSU Caves of Narshe
into
SPC train noise
into
complete silence
fades to world map

Sadly this fix involved changing around my "random SPC command" handling code significantly, so I now need to also test Dancing Mad for regressions to its subsong handling. But the bug itself has now been fixed, afaict!

I don't think we should seek to replace the train noise loop with an MSU-1 track as I had originally intended with the first version of this fix, though I could figure out a way to do so. The reason I say that is that the game appears to slow down and speed up the loop procedurally to produce the necessary "train speeding up/slowing down" effect. IOW, it'd be impossible to synthesize this effect with the MSU-1.

@edale2

This comment has been minimized.

edale2 commented Apr 20, 2018

There's a bit of SPC train noise/PCM audio playing at the same time right when the PCM starts at the beginning of the Phantom Train section.
I only really noticed because I'm using the OTH one that I added train sounds to, and it's noticeable that 2 different sets of train sounds are playing.

Other than that, works great.

@edale2

This comment has been minimized.

edale2 commented Apr 20, 2018

This branch has the new fadeout routines in it?

@Insidious611

This comment has been minimized.

Owner

Insidious611 commented Apr 20, 2018

@edale2

This comment has been minimized.

edale2 commented Apr 20, 2018

Ah, thought it might have had Madsiur's new fading code added in.

I'll get around to testing Dancing Mad probably tomorrow. Someone released a Ys III MSU-1 mod a few days ago, and I've been working on making a PCM pack out of the TGCD soundtrack (they used the Oath in Felghana soundtrack) pretty much all of today.

Finally mostly finished, and need to do a playthrough with just the TGCD tracks, and find out the guy doesn't have any SPC fallback code (not all the TGCD tracks are CD audio)...

@edale2 edale2 closed this Apr 20, 2018

@edale2 edale2 reopened this Apr 20, 2018

@edale2

This comment has been minimized.

edale2 commented Apr 23, 2018

OK, tested Dancing Mad with this version of the patch.

After the 3rd segment ends, the music abruptly cuts off and there's a second or two of silence before the 4th and final part of Dancing Mad starts up.

I'm guessing this is from the fadeout = volume 0 code.

Everything else seems to be working perfectly.

@Insidious611

This comment has been minimized.

Owner

Insidious611 commented Apr 23, 2018

That's the kind of thing I was expecting from the fadeout workaround, yeah. It's a very heavy-handed "fix".

That said good to see everything else is working.

@Insidious611

This comment has been minimized.

Owner

Insidious611 commented Apr 30, 2018

I'm going to mark this bug closed for now, as I've confirmed this one is fixed with the current code, and doesn't bother any of the other special case code. If it doesn't fix it for F-Bomb after release, I'll re-open it.

Insidious611 added a commit that referenced this issue May 1, 2018

Train and fadeout fixes (#77)
* 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment