Replacement for "What is" in the first generation of SCUMM

Ask for help with ScummVM problems

Moderator: ScummVM Team

Post Reply
Gunny
Posts: 4
Joined: Mon Jun 26, 2023 11:14 am

Replacement for "What is" in the first generation of SCUMM

Post by Gunny »

I tried to replay Zak McKracken several times but after a while I always got angry because of the interface of the first generation of SCUMM games.
The most annoying thing is that it does not automatically display the name of the object below mouse cursor and you have to use "What is" for that.
It was fine in 1988 but it already felt inconvenient in 1990. :oops:

Q1: Is there an easy way how to change it?
I dug through the source code of SCUMMVM and it seems it is handled somewhere in engines\scumm\input.cpp, but I have not found the exact spot yet.
Is there already a custom build that does that?

Q2: Would not it be nice to include an "official" option to SCUMMVM to change this behaviour in MM and Zak and make it work like in SoMI? I suppose any change of interface may sound like a sacrilege to some people but it would not make the game easier, it would be just more convenient.

Any suggestions or comments?
User avatar
eriktorbjorn
ScummVM Developer
Posts: 3525
Joined: Mon Oct 31, 2005 7:39 am

Re: Replacement for "What is" in the first generation of SCUMM

Post by eriktorbjorn »

Gunny wrote: Sun Jul 23, 2023 5:37 pm Q1: Is there an easy way how to change it?
I dug through the source code of SCUMMVM and it seems it is handled somewhere in engines\scumm\input.cpp, but I have not found the exact spot yet.
Is there already a custom build that does that?
If I understand things correctly the "what is" feature is a combination of the SCUMM engine telling the game scripts which verb was most recently clicked, and a game script acting on it. When I tested with Zak McKracken (v2), it was ScummEngine_v2::runInputScript() setting VAR_CLICK_VERB and script-4 acting on it, then checking which object the mouse is currently over.

I think the mouse position is tracked in ScummEngine::scummLoop_updateScummVars(). Maybe it'd be possible to bolt your own verb line updating function on top of that, but I don't know... The details may depend on the exact game.
Gunny
Posts: 4
Joined: Mon Jun 26, 2023 11:14 am

Re: Replacement for "What is" in the first generation of SCUMM

Post by Gunny »

eriktorbjorn wrote: Mon Jul 24, 2023 6:27 am If I understand things correctly the "what is" feature is a combination of the SCUMM engine telling the game scripts which verb was most recently clicked, and a game script acting on it.
Thanks for your reply but I am not quite sure we are on the same page..? I thing my subject is a bit misleading... :?

All post-SoMI SCUMM games automatically update "the sentence" with the name of the object below the mouse cursor while you are moving it. (i.e. I click on "Pick up", then move the mouse over an object (a knife) and the sentence immediately change to "Pick up knife". Clicking executes the action.)

The first generation of SCUMM games (MM/Zak/Indy3) works slightly differently. Moving the cursor does not change the sentence until you *click* on an existing object OR unless you set the verb to "What is". That means that (in a new room) you usually have to start with "What is", scan the whole screen to find the clickable objects and only then you can start to interact with them.
I would like to get rid of "What is" completely and make SCUMMVM handle the situation just like it was a second (or third?) generation SCUMM game - probably like a option.

I hoped to find something like this pseudo-code:

Code: Select all

MouseOver(object) {
if (SCUMMGame._version > 3 || verb=="What is")
  UpdateSentenceWith(object);
else
  // do nothing
}
(It would be probably a bit more complicated because of the possibility to "see" some things in darkness only with a flashlight.)

It seems to me like a good idea to slightly "update" the interface even if this feature was introduced in later SCUMM games.
fibs
Posts: 27
Joined: Mon Sep 26, 2022 10:38 pm

Re: Replacement for "What is" in the first generation of SCUMM

Post by fibs »

Gunny wrote: Mon Jul 24, 2023 2:05 pmThe first generation of SCUMM games (MM/Zak/Indy3) works slightly differently. Moving the cursor does not change the sentence until you *click* on an existing object OR unless you set the verb to "What is". That means that (in a new room) you usually have to start with "What is", scan the whole screen to find the clickable objects and only then you can start to interact with them.
If you find no solution, you can just press the hotkey "c" for the "What is" stuff if you want to see if you missed something, and until then just explore what objects are clickable based on what objects would logically be clickable.

I may be wrong but I don't see a ScummVM way to keybind "c" to the middle mouse button or something like that, which may be useful, but you can use other software for that. E.g. an AutoHotKey script (middle_mouse_c.ahk) like this:

Code: Select all

MButton::c
You can extend it to cycle all the actions via wheeldown and wheelup (zak.ahk):

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn   ; Enable warnings to assist with detecting common errors.
#MaxHotkeysPerInterval 300
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.

index := 1  ; Initialize the variable "index" to 1
keys := ["q", "a", "z", "w", "s", "x", "e", "d", "c", "r", "f", "v", "t", "g"]  ; Define an array "keys" containing the specified characters

; #IfWinActive directive to limit the script to scummvm.exe
#IfWinActive, ahk_exe scummvm.exe

WheelDown::  ; Define the WheelDown hotkey
    keyToPress := keys[index]  ; Assign the value of the element at the current index in "keys" to "keyToPress"
    SendInput, %keyToPress%  ; Send the character represented by "keyToPress"
    index := Mod(index, 14) + 1  ; Increment the index using modulo arithmetic to cycle through the "keys" array
return

WheelUp::  ; Define the WheelUp hotkey
    keyToPress := keys[index]  ; Assign the value of the element at the current index in "keys" to "keyToPress"
    SendInput, %keyToPress%  ; Send the character represented by "keyToPress"
    index := Mod(index, 14) - 1  ; Decrement the index using modulo arithmetic to cycle through the "keys" array in reverse order
return

MButton::c  ; Define the Middle Mouse Button hotkey to type the character "c"
User avatar
eriktorbjorn
ScummVM Developer
Posts: 3525
Joined: Mon Oct 31, 2005 7:39 am

Re: Replacement for "What is" in the first generation of SCUMM

Post by eriktorbjorn »

Gunny wrote: Mon Jul 24, 2023 2:05 pm I hoped to find something like this pseudo-code:

Code: Select all

MouseOver(object) {
if (SCUMMGame._version > 3 || verb=="What is")
  UpdateSentenceWith(object);
else
  // do nothing
}
The point I was trying to make was that you'd probably only find one small part of the puzzle in the ScummVM C++ code. The engine interprets the scripts that make up the logic of the game. The scripts are responsible for defining the verbs, and acting on them. The engine is responsible for telling the scripts where the mouse cursor is and which of the defined verbs the user has selected. So while ScummVM may know that the game defined a verb with id 15, and knows where and how to draw it, it doesn't know that this happens to be the "What is" verb.

Using the "descumm" tool to analyze script-4 of the game will not give us the original SCUMM source code, of course, but something vaguely readable. I'm guessing this is the fragment that is mainly responsible for the "What is" verb:

Code: Select all

[007F] (48)   if (VAR_CLICK_VERB == 15) {
[0085] (1A)     VAR_SENTENCE_VERB = 15;
[0089] (AC)     drawSentence();
[008A] (78)     if (VAR_VIRT_MOUSE_Y < 67) {
[0090] (F5)       VAR_CLICK_OBJECT = findObject(VAR_VIRT_MOUSE_X,VAR_VIRT_MOUSE_Y);
[0094] (88)       if (VAR_CLICK_OBJECT != VAR_SENTENCE_OBJECT1) {
[0099] (9A)         VAR_SENTENCE_OBJECT1 = VAR_CLICK_OBJECT;
[009C] (AC)         drawSentence();
[009D] (**)       }
[009D] (**)     }
[009D] (80)     breakHere();
[009E] (18)     goto 008A;
[00A1] (**)   }
But I don't think trying to patch the script is the way forward. The SCI engine has that down to a fine art, but the SCUMM engine does not. Rather, you'd probably have to add some equivalent code to ScummEngine::scummLoop(). With the caveat that different games, and even different versions of the same game, may not do the same thing. (And I'd be nervous the hack would interfer with the regular sentence line. So maybe I'd look into changing the mouse cursor instead, or something like that. But this is all speculation, as I have no such plans myself.)
Gunny
Posts: 4
Joined: Mon Jun 26, 2023 11:14 am

Re: Replacement for "What is" in the first generation of SCUMM

Post by Gunny »

fibs wrote: Mon Jul 24, 2023 4:20 pm If you find no solution, you can just press the hotkey "c" for the "What is" stuff if you want to see if you missed something, and until then just explore what objects are clickable based on what objects would logically be clickable.
I found the hotkey yesterday mentioned somewhere in the SCUMMVM code. =)
It's not perfect but it's a small improvement in the right direction...
Gunny
Posts: 4
Joined: Mon Jun 26, 2023 11:14 am

Re: Replacement for "What is" in the first generation of SCUMM

Post by Gunny »

eriktorbjorn wrote: Mon Jul 24, 2023 9:12 pm The engine interprets the scripts that make up the logic of the game.
Thanks - that's probably the most important thing to learn. I've always thought that SCUMMVM "replaces" a bit more stuff from the original engine.

The script is interesting except it seems it handles only the situation right when you change the verb to "What is" and I would like to handle the situation when it is not selected so maybe it will get more complicated.

Anyway, I suppose that it also means that a better way should be "patching" the scripts within each game - but I guess it's not that easy. :?
Post Reply