Opened 22 years ago

Closed 22 years ago

Last modified 6 years ago

#8058 closed patch

RFC: Timer-based CD audio sync

Reported by: eriktorbjorn Owned by: Kirben
Priority: normal Component: Engine: SCUMM
Version: Keywords:
Cc: Game: Monkey Island 1

Description

This is an experimental patch that uses a real timer to update the "MI1 timer", i.e. the timer that is responsible for keeping the game in sync with CD audio.

My reasoning for this is that it's hard for scummLoop() to keep the time on its own, what with things like screen effects causing unpredictable delays while the CD track just keeps running in the background.

At first I wanted to use the current position in the CD/MP3 track, but that turned out to be tricky, and it would still need a fallback mechanism in case the sound fails to play for whatever reason.

It isn't flawless. For one thing, keeping in sync with the Loom CD isn't an exact science. Another problem is that the timer keeps running even when the game is paused, which completely screws up the sync when the game is resumed. (Hmm... it didn't occur to me until now, but could the timer handler check for that condition somehow?) Reloading a saved game in the middle of a timed sequence might be a bit off, too, but it should make a reasonably dignified recovery.

But aside from that bug, and regardless of how we implement it, I don't think we'll ever be able to get better sync than what this patch provides.

I've tested this patch with the Loom CD, and the MI1 intro, and they currently require slightly different timing, so I'd be grateful if someone could test it with whatever other games there are that use CD audio. (Zak 256?)

Ticket imported from: #611997. Ticket imported from: patches/163.

Attachments (4)

cd-timer.diff (4.5 KB ) - added by eriktorbjorn 22 years ago.
Patch against a September 19 CVS snapshot
cd-timer2.diff (4.8 KB ) - added by eriktorbjorn 22 years ago.
Updated patch against a September 20 CVS snapshot
emergency-patch.diff (1.7 KB ) - added by eriktorbjorn 22 years ago.
Completely untested patch for monkeyvga
emergency-patch2.diff (1.7 KB ) - added by eriktorbjorn 22 years ago.
Typo-fixed patch

Download all attachments as: .zip

Change History (15)

by eriktorbjorn, 22 years ago

Attachment: cd-timer.diff added

Patch against a September 19 CVS snapshot

by eriktorbjorn, 22 years ago

Attachment: cd-timer2.diff added

Updated patch against a September 20 CVS snapshot

comment:1 by eriktorbjorn, 22 years ago

I've cleaned the patch up slightly. Pausing the game seems to work properly now.

I'm still not very clear on what I can and cannot do from a timer handler. I didn't dare to manipulate _vars[] directly, but if it's ok to do that, then the code could be simplified a bit more. (If it's not, then I don't know if what I do currently is ok either, but at least it's easier to fix. :-)

comment:2 by Kirben, 22 years ago

Patch has been added to cvs

comment:3 by Kirben, 22 years ago

Status: newclosed

comment:4 by fingolfin, 22 years ago

Owner: set to Kirben

comment:5 by Kirben, 22 years ago

Status: closednew

by eriktorbjorn, 22 years ago

Attachment: emergency-patch.diff added

Completely untested patch for monkeyvga

comment:6 by eriktorbjorn, 22 years ago

If I understand things right, this patch may be needed for *some* versions of monkeyvga. It's completely untested. In fact, I don't even know if it compiles.

comment:7 by eriktorbjorn, 22 years ago

There was a slight typo in the previous patch, so here's a new one. Trin` has tested the patch and says it's working, so assuming this one compiles, it should be the final version.

comment:8 by SF/mnepomuk, 22 years ago

Yes looks good for german MI1 VGA floppy version (using "GID_MONKEY_VGA").

by eriktorbjorn, 22 years ago

Attachment: emergency-patch2.diff added

Typo-fixed patch

comment:9 by eriktorbjorn, 22 years ago

I could have sworn I attached a patch yesterday where I had fixed the typo. Oh well, let's try it again...

comment:10 by Kirben, 22 years ago

Status: newclosed

comment:11 by digitall, 6 years ago

Component: Engine: SCUMM
Game: Monkey Island 1
Note: See TracTickets for help on using tickets.