Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#7026 closed defect (fixed)

AGI: IIgs AGI games (or just intros / cutscenes?) run too fast

Reported by: SF/darkmoor9 Owned by: m-kiewitz
Priority: normal Component: Engine: AGI
Keywords: Cc:
Game: Police Quest 1


This is apparently an old problem, but after searching I don't see any tickets about it, so... like I said in the title, at least the intros / cutscenes of the Apple IIgs versions of AGI games play too fast. This is easy to notice in places where a piece of music should play along with an animation, but on the IIgs version the animation finishes before the music, interrupting it.

Easy way to see the problem: run the IIgs version of Police Quest 1 under ScummVM. When you start the game, the title "Police Quest" appears, with a piece of music, then there's an animation where the title is pierced by several bullets, then a second piece of music, and the words "in pursuit of the death angel" appear one letter at a time underneath the title. Then the game switches to a picture of a police shield and starts playing a different music.

In the IIgs version under ScummVM, the "in pursuit..." letters appear so fast that the second piece of music is cut in the middle. The same doesn't happen with any other version I've tried (DOS, Amiga).

This is just an example; the problem seems to exist in all IIgs AGI games (e.g. in King's Quest 1 the credits start rolling a couple of seconds before the music, when it should happen at the same time. Gold Rush's intro runs so fast that some parts of it are almost impossible to watch. Etc..)

More information:

  • it doesn't happen under the KEGS32 IIgs emulator, everything is fine there;
  • like I said, it appears to be an old problem; I can reproduce it in the release version of ScummVM 1.7.0 (Windows) and also in today (February 10)'s latest snapshot (both 32- and 64-bit versions) on Linux;
  • I don't know if this is restricted to intros / cutscenes / animations, or if the entire IIgs games run too fast under ScummVM (maybe some operation that takes some time in other versions is instantaneous on the IIgs, and the original Sierra interpreters accounted for that, but ScummVM doesn't?)

Anything I can help with, please let me know.

Ticket imported from: bugs/7026.

Change History (28)

comment:1 Changed 3 years ago by m-kiewitz

When you switch KEGS32 IIgs to "Unlimited speed", then the same behavior happens.

The music is actually cut off, because the developers of PQ1 assumed that graphic loading would take a few seconds, which was true back then. There is basically no way for us to identify this situation. I have added code for situations, where text is shown right before a room change like for example Space Quest 2, when entering the hatch. Text will be shown, immediately followed by a room change. In this situation ScummVM shows a wait cursor and waits for around 2 seconds, so that the user is able to read the text.

In the PQ1 intro though I can't really know that we are supposed to wait for a few seconds. Before my major rewrite of the graphic system, ScummVM waited around 2 seconds on every room change. Back then this specific part would have worked better, but the user would be forced to wait for those few seconds all the time.

So actually the games themselves were just written in a way, that they assumed some longer loading would take place. And I'm not sure if adding back the 2 or 3 seconds wait on every room change etc. would be a good idea. This waiting also basically broke at least one fan game, that used background picture changes for a waterfall effect.

I'm not really sure what to do. I could of course start adding informations about this specific scene, so that ScummVM will add a slight pause although the heuristic didn't detect any. For this of course I would need information about all of those situations.

btw. Gold Rush on Apple IIgs even goes further. It actually SPEEDS UP the game, when larger sprites are on the screen. You will notice this almost immediately. I planned to patch this game code out. They did this probably because Apple IIgs was too slow to handle it, so if they hadn't added this game code, the game would have had major slowdown. In ScummVM it's of course the exact opposite. Larger sprites do not matter, so the game is actually really sped up.

comment:2 Changed 3 years ago by m-kiewitz

And I also just checked King's Quest 1.

Even when I switch KEGS to 2.8 Mhz (that's what the Apple IIgs had), the credits still start earlier than the music does. Maybe you have it at 1 Mhz? Same problem here basically. When I switch KEGS to 8 Mhz or Unlimited, the credits run way too fast, so in this case the original interpreter seems to be worse with the timing.

ScummVM AGI runs games at the rate that the games ask for. The highest speed, that is still somewhat controlled, is 20 cycles per second (so 20 updates per second). The games can also ask for basically no speed control at all, which will make most of them go crazy even in DOSBox, although it seems that this mode isn't possible on Apple IIgs, because the game timer isn't working the same as for the other platforms ("0" is uncontrolled for those platforms, on Apple IIgs "0" means 20 updates per second)..

Anyway, that's what PQ1+KQ1 ask for. 20 updates per second.

comment:3 Changed 3 years ago by m-kiewitz

Component: Engine: AGI
Game: Police Quest 1
Owner: set to m-kiewitz

comment:4 Changed 3 years ago by SF/darkmoor9

Thanks for the replies. I can confirm that I have KEGS32 (Windows version 0.91, apparently still the latest) with the default 2.5 Mhz set (that's what the button says, 2.5 Mhz, not 2.8; the other options are 1 Mhz, 8 Mhz and unlimited speed).

Other than that, I really don't know (and I hesitate to make suggestions, since you know what you're talking about and I don't). What I can tell is that this only happens in the IIgs versions; the DOS and Amiga versions run fine, with animations / cutscenes not finishing before (and interrupting) the music, and so on. Maybe (like the case you mentioned with Gold Rush and large sprites) the Sierra IIgs interpreters had to "cheat" in some ways on that system, as it was the slowest of them all (compared to DOS, Amiga and Atari ST) in terms of CPU speed, and those "cheats" are causing this problem now? It's a pity, as the IIgs versions of the games are otherwise typically the best to play (digitized sounds, and in KQ1's case, entirely new music througout the game).

comment:5 Changed 3 years ago by m-kiewitz

It could of course be, that Sierra actually removed code to wait for some time in the scripts, so that the games would run better on Apple IIgs with the loading involved. Otherwise the music would end, then game would then load for several seconds and then the intro would continue. So this would make sense. It's of course quite bad now, because like I said - I can't really figure out automatically if I'm supposed to wait and I wouldn't want to make the Apple IIgs versions worse by simply waiting for several seconds on every room change.

Could you try to for example play Police Quest 1 until the end and make notes about situations like the one above? It would be superb, if you could maybe even take note of room numbers in those cases, so that I wouldn't have to look for them. You can enter the ScummVM AGI console by pressing Ctrl-Shift-D. You will then get a command line, where you can enter special commands. Enter "room" and you should get the so called room number. After that press ESC to close the console. If you save a lot (which you should probably do anyways, it's Sierra games), you could then just redo such a scene, when you notice that the music is supposed to stop before the room change, and take note of the original room number and the room number after the room change. Maybe those situations don't happen that often anyway. I played through Larry 1 for Apple IIgs a few days ago and didn't encounter such issues at all. In Space Quest 2 for Apple IIgs the intro music also ends properly. So maybe such situations are indeed really rare.

comment:6 Changed 3 years ago by SF/darkmoor9

I'll try what you suggested, later, thanks (at work right now). But one thing: I don't think it's just a question of not having delays in room changes; I'm pretty sure the animations actually play faster on the IIgs, compared to other versions, which makes then end sooner than they should (and sometimes cuts the music in the middle, since the music plays at normal speed). For instance, like I mentioned in the ticket, after the "Police Quest" logo is pierced by bullets, there's an animation where each letter of "In Pursuit of the Death Angel" appears at a time, and it's noticeably faster on the IIgs version under ScummVM (compared to the DOS version under ScummVM, or to the IIgs version on KEGS, for instance).

comment:7 Changed 3 years ago by m-kiewitz

For PQ1 as I said just change KEGS to "unlimited speed". It will play even faster than ScummVM. It will also cut off the music.

I have to assume Sierra removed certain delays on Apple IIgs, because the hardware was simply that slow. It's not like the original interpreter did delay those animations. The hardware was just too slow.

In the PC version the "In Pursuit of the" line even scrolls upwards right under the logo. In the Apple IIgs version that text simply appears out of nowhere. So the intro is not even really the exact same and was changed by Sierra. As I said - ScummVM AGI just uses the speed, that the games ask for. When they ask for 20 updates per second, they get 20 updates per second. Even if I did delay them some more and wouldn't give them as many cycles as they ask for, the music for example would still get cut off.

I will probably add some code for the PQ1 title today, so that a loading delay is enforced for this situation, so that the music isn't cut off anymore. The games will have to be checked manually.

When you for example change Larry 1 PC DOS to "fast" speed, which is a value of 1 (so 20 updates per second), then that Larry 1 gets the same amount of cycles that the Apple IIgs version asks for on "normal" speed (effectively Larry 1 does not even have a speed setting!), which is value of 0 (20 updates per second). When you then look at the animations of Left's Bar, it's quite obvious that Sierra changed the speed of for example the animation of the cocktail glass. On Apple IIgs it plays way faster although the speed should be the same. Left's Bar sign is also not even animated on Apple IIgs. Larry himself walks as fast in both of those.

It gets even more complicated. Gold Rush for example does some sort of benchmark at the start of the game. When I don't give it as many cycles as it wants to get, the in game timer won't work correctly, which means the game will be basically broken.

comment:8 Changed 3 years ago by m-kiewitz

I just commited code, commit dbea55b36b48838879ebd5b5dc6a94d7aa7f0f2e

Police Quest 1 intro music issue is now solved

comment:9 Changed 3 years ago by SF/darkmoor9

Thanks! I'll sync and compile it later today, on my Ubuntu machine, when I get home, to test it.

As for the rest (faster cutscenes / animations in general), I understand that this isn't going to be easy to fix for all cases, if at all possible. The fact that the same problem happens if you set KEGS to a higher speed than the default suggests to me (again, please ignore me if I'm saying nonsense) that, in IIgs versions, something (some common instruction(s), some specific kind of animations, etc.) runs as fast as it can (because the programmers knew all IIgs machines have a constant, relatively slow speed, so it works there), unlike on other systems where those "somethings" run at a constant, predictable speed. And that difference might be in the IIgs interpreter, the IIgs game data files, or both, and I'm sure it's not something as simple as changing a setting...

Anyway, thanks for everything.

comment:10 Changed 3 years ago by m-kiewitz

Actually the game is still sync'd in some way, but some parts simply weren't able to work as fast as they were supposed to be. So I guess the developers removed delays for some part. On PC the highest speed setting is actually basically "unlimited" so it will do as many cycles as possible. In ScummVM even this setting is slightly delayed, so it won't run insanely fast. On Apple IIgs such a setting didn't really exist. The highest was 20 cycles per second.

As I said - Gold Rush on Apple IIgs tries to optimize itself and switches to a faster speed setting when larger sprites are on the screen, which means it effectively gets twice as many cycles as it normally does (well rather it could get that many cycles, I'm sure that on real hardware it didn't, at least didn't get that many more). That's probably because on real hardware, the game had issues keeping up, so they changed the speed setting, so that there won't be major slowdown.

I would surely be interested in how well Gold Rush performs on actual hardware. I would assume that you could probably still tell that the game ran a bit slower or a bit faster when larger sprites were on the screen. In the emulator the game actually SLOWS DOWN when larger sprites are on screen, although the game switches to the twice as fast mode.

comment:11 Changed 3 years ago by SF/darkmoor9

OK, the music in the PQ1 intro isn't interrupted any more. Thanks (and for the explanations, too)! If I find more situations with interrupted music, I'll open a new ticket.

Something unrelated (if you'd like to, I can open a new ticket, but this should be trivial, I think): the IIgs version of Space Quest 1 isn't trying to use the correct IIgs font, giving this message on the console:

User picked target 'sq1-2gs' (gameid 'agi')...
Looking for a plugin supporting this gameid... AGI preAGI + v2 + v3
Starting 'Sierra AGI game'
WARNING: Could not open file 'agifont' for Apple IIgs font!
AGI: Using PC-BIOS font
Emulating Sierra AGI v2.917

Space Quest 2 (IIgs) is fine:

User picked target 'sq2-2gs' (gameid 'agi')...
Looking for a plugin supporting this gameid... AGI preAGI + v2 + v3
Starting 'Sierra AGI game'
AGI: Using Apple IIgs font
Emulating Sierra AGI v2.936

as are the IIgs versions of PQ1, KQ1, KQ2, KQ3, Larry 1, and Gold Rush.


comment:12 Changed 3 years ago by m-kiewitz

It actually is. It's even complaining, that it can't find the file "agifont", which should be inside the game directory.

When ScummVM can't find that file, it will use the internal PC BIOS font instead. The font is inside that file. It's a Sierra font.

Can you check the floppies? And in case it's really not on there, start the game and enter "version" in the console command line. Maybe there was another version of that game. The file is on my floppies.

comment:13 Changed 3 years ago by SF/darkmoor9

Ah, I didn't notice that "agifont" was actually a file on the original disk. I'm using files extracted (using CiderPress) from images from the "What is the Apple IIgs" site.

Let's see...

$ find . | grep -i agifont
./King's Quest 3 (AppleIIGS)/DATA/AGIFONT
./Gold Rush! (AppleIIGS)/DATA/AGIFONT
./Space Quest 2 (AppleIIGS)/DATA/AGIFONT
./Police Quest 1 (AppleIIGS)/DATA/AGIFONT
./King's Quest 4 (AppleIIGS)/DATA/AGIFONT
./King's Quest 1 (AppleIIGS)/DATA/AGIFONT
./Larry 1 (AppleIIGS)/DATA/AGIFONT
./Black Cauldron (AppleIIGS)/DATA/AGIFONT
./King's Quest 2 (AppleIIGS)/DATA/AGIFONT
./Space Quest 1 (AppleIIGS)/AGIFONT

Apparently, all Sierra IIgs images from that site have AGIFONT inside the DATA/ subdirectory, except SQ1 which has it in the root directory. Copying the file to right place solved this in ScummVM. Makes sense, since for IIgs games it's the DATA/ subdirectory that you have to add as the game's "home" in ScummVM, not the root.

Oddly enough, on KEGS this same disk image works fine (and the font looks the same as it does in ScummVM now) with the file in the disk's root directory.

Thanks again!

comment:14 Changed 3 years ago by m-kiewitz

All the required data files are inside the data directory, which means if someone really extracted those files including directories and then chose the root directory instead of the data directory, the game would not even be found by ScummVM.

comment:15 Changed 3 years ago by SF/darkmoor9

Yes, makes sense. Just added the IIgs version of Manhunter: New York and there's a similar problem, the MH.SYS16 file is in the root directory, so before I added it to the DATA/ directory the game had no music (message "WARNING: Couldn't find Apple IIGS game executable (.SYS16 or .SYS), not loading instruments!").

By the way, Manhunter looks like it'll need a lot of screen change pauses like you added to PQ1... the game (which I haven't really played yet, only read a let's play of the DOS version some time ago, and just tried the IIgs version now under ScummVM) seems to be filled with cutscenes, many more than the usual for AGI, and they all run very fast in the IIgs version under ScummVM...

comment:16 Changed 3 years ago by m-kiewitz

The stuff that is running in MAD is actually working at the "right" speed, which means I have to assume it's effectively another performance issue and Sierra removed quite a few delays. Still the intro is quite different than the PC one. Some animations are even missing. This is not a case, where those forced delays would even work, because those are for situations, where a scene change is supposed to take place.

comment:17 Changed 3 years ago by m-kiewitz

I added some code today, so that the game speed is overwritten plenty of times.
It would be great, if you could please play through the games and try it out. Manhunter 1 is especially problematic, because the MAD parts are working properly when using the speed given by the scripts.

commit af9028355294ffe569e9100c2cac02eb843b1c11

comment:18 Changed 3 years ago by SF/darkmoor9

Thanks, I'll try it this weekend, I hope. If not, just a couple of days afterwards.

comment:19 Changed 3 years ago by m-kiewitz

In case you find a room/scene, that is running too slow/too fast, please enter console by pressing Ctrl-Shift-D and enter the command "room". Then write down that number and post it here including a description about it.

I have also added code, that will show you when the speed is overwritten and what the game actually asks for. That way it's pretty easy to tell if the game tried to slow itself down.

I will probably try to play through a few games myself like Space Quest. I have already completed Larry 1 and had no special speed issues. It was just running like "fast" on PC. Now it's running at "normal" speed.

comment:20 Changed 3 years ago by m-kiewitz

I have beaten Space Quest 1, speed is fine with that one.

comment:21 Changed 3 years ago by m-kiewitz

Summary: IIgs AGI games (or just intros / cutscenes?) run too fastAGI: IIgs AGI games (or just intros / cutscenes?) run too fast

comment:22 Changed 3 years ago by SF/darkmoor9

I've tried a couple of games (though not really "played" through them; I hope to have more time in the next few days) since your new changes. As far as I can see, ScummVM now overrides attempts from the player to change the game speed (normal, fast, etc.), and in the console I see messages like:

WARNING: AppleIIgs: time delay overwrite from 1 to 2!

... this in PQ1, twice in the intro (before the shield), and once more when the first actual game screen appears. Entering either of the "fastest", "fast" or "normal" commands also produces the message (and doesn't change the speed) (suggesting "fastest", "fast" and "normal" are the same in this version of the game: delay 1). The "slow" command produces:

WARNING: AppleIIgs: time delay overwrite from 3 to 2!

again, with no speed change. It seems the delay is now fixed at "2" for that game (and, from your commit, all others except Manhunter for now).

I think the IIgs problem is (IMO) more related to intros, cutscenes, and non-interactive scenes in general; if the player tries to switch to a faster speed inside the game, then that should ideally be allowed, and characters walking like they're on speed should be expected. On the other hand, maybe it's not possible to "fix" the former without locking the entire game's speed (to a slower setting than the default)?

Again, thanks for all the care you've been giving this issue.

comment:23 Changed 3 years ago by m-kiewitz

I assumed that Apple IIgs games had no speed setting at all, because it's not present in the menus at all and games like for example Larry really do not have a speed setting. Commands like "fast" etc. are simply ignored. Same is true for Space Quest 2 and King's Quest 2+3+4 and even Gold Rush.

Manhunter 1 has afaik no way to change the speed because there is also no command line.

It also seems Police Quest + King's Quest 1 actually set the internal speed to 0 for nomal and to 0 for fast. Which also means that on an actual Apple IIgs, there shouldn't have been a difference between those two.

For now I would rather like to know if the changes make the speed work properly w/o also taking this into account. And a speed setting is only available (afaik) for King's Quest 1, Police Quest, Space Quest 1. Those last 3 games seem to work properly with only one common change to the speed setting, which means i could change that one to be a relative change. But still that won't help with "fast" and "normal".

comment:24 Changed 3 years ago by m-kiewitz

I went through almost everything now except Gold Rush.

I guess one could even implement "fast"/"slow" etc. later into the games that didn't have it.

comment:25 Changed 3 years ago by SF/darkmoor9

That would be great, though it would really be "going above and beyond the call of duty". :) Sorry I haven't had time to test any games yet, this week has been crazy (being a sysadmin on call is never fun and games). Though apparently you ended up doing that.

From what little I've tested, everything "feels" a lot better now, though I wouldn't mind being able to set the speed -- only in game, and hopefully not affecting cutscenes and all that -- to a faster speed than was possible on a real IIgs. But even if that never happens, I feel that this problem is now "solved".

comment:26 Changed 3 years ago by m-kiewitz

Resolution: fixed
Status: newclosed

comment:27 Changed 3 years ago by m-kiewitz

I have now tested all the games. They all seem to be working properly now. In the worst case I missed a scene somewhere.

Speed support may get added at a later date, we will see. Even Gold Rush worked fine. Closing this now.
Last commit on this was:

comment:28 Changed 3 years ago by SF/darkmoor9

Thanks for everything! (BTW, I hope this doesn't open the ticket again.)

Note: See TracTickets for help on using tickets.