Opened 11 years ago

Closed 11 years ago

#6229 closed defect (fixed)

AGI FANMADE: function slowing down game

Reported by: SF/f100101ff Owned by: bluegr
Priority: normal Component: Engine: AGI
Version: Keywords: script
Cc: Game: AGI Fanmade

Description

ScummVM 1.5.0 - Windows 7 I'm going through the fanmade game "Hank's Quest: Victim of Society" at the moment and I came across the following issue: Having have.key() during a loop (the command that waits for the player to press any key during a cutscene (e.g.)) slows the game down considerably. It seems like the game speed is slowed down by 1 step (this is controlled with the variable v10), but this might be just the game itself slowing down. Thanks in advance.

Ticket imported from: #3600733. Ticket imported from: bugs/6229.

Change History (7)

comment:1 by SF/f100101ff, 11 years ago

Just some additional info: I notice it happening in other AGI games as well (fan and Sierra), so it's not an isolated problem. Hope that helps.

comment:2 by wjp, 11 years ago

Could you give an explicit example of a scene in a Sierra AGI game where this happens? (With a savegame ideally.)

comment:3 by SF/f100101ff, 11 years ago

Thanks for the reply!

I've tried several Sierra AGI games in both ScummVM and the NAGI interperter. I focused only on the introduction scenes of these games (so that's why I haven't attached any savegames for now).

Games that slowed down in ScummVM: - King's Quest 3 - Police Quest 1

Games that worked normal: - Space Quest 1 - Space Quest 2 - Gold Rush - King's Quest 1 - King's Quest 2 - Leisure Suit Larry 1 - Manhunter 1 : New York - Manhunter 2: San Fransisco

Sierra games I didn't/couldn't test: - Donald Duck's Playground - King's Quest 4 (AGI) - The Black Cauldron

I hope this helps!

(BTW: I could test a couple of fanmade games as well if you like)

comment:4 by bluegr, 11 years ago

AgiEngine::testKeypressed() is calling mainCycle(). This seems needlessly overcomplicated just for a testing function.

NAGI has a much simpler implementation of have.key which just checks for keyboard keypresses without invoking a game cycle.

NAGI is doing this:

u8 cmd_have_key() { u16 ax; ax = state.var[V19_KEYPRESSED]; if ( ax == 0) { do { ax = char_poll(); } while (ax == 0xFFFF); }

if ( ax != 0 ) { state.var[V19_KEYPRESSED] = ax; return 1; } else return 0; }

An equivalent in ScummVM would be something like: uint32 key = doPollKeyboard(); uint32 kascii = KEY_ASCII(key); if (kascii) setvar(vKey, kascii); handleController(key); if (key) _game.keypress = key;

This will need testing, though

comment:5 by bluegr, 11 years ago

And here's the full implementation of uint8 AgiEngine::testKeypressed():

uint8 AgiEngine::testKeypressed() { if (!_game.keypress) { uint32 key = doPollKeyboard(); uint32 kascii = KEY_ASCII(key); if (kascii) setvar(vKey, kascii); handleController(key);

if (key) { _game.keypress = key; return 1; }

}

return 0; }

Do note that the function is only supposed to return true/false according to NAGI, not the full scancode

comment:6 by bluegr, 11 years ago

Owner: set to bluegr
Resolution: fixed
Status: newclosed

comment:7 by bluegr, 11 years ago

Fixed in commit 5fadff5

We now only test for events in testKeypressed() without updating the game cycle at all (NAGI doesn't update the game cycle either). This fixes the slowdowns in some animations where have.key() is issued, like Manannan's lightnings in the intro of KQ3 and the bullets in the intro of PQ1

The fix will be available in the next daily version of ScummVM

Note: See TracTickets for help on using tickets.