[Scummvm-git-logs] scummvm branch-2-8 -> 0ba98e8f643049958497b3c5cba3d471cd89fe22
sluicebox
noreply at scummvm.org
Sat Mar 2 20:30:07 UTC 2024
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
0ba98e8f64 AGI: Restrict AGIMOUSE feature to AGIMOUSE games
Commit: 0ba98e8f643049958497b3c5cba3d471cd89fe22
https://github.com/scummvm/scummvm/commit/0ba98e8f643049958497b3c5cba3d471cd89fe22
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2024-03-02T13:29:04-07:00
Commit Message:
AGI: Restrict AGIMOUSE feature to AGIMOUSE games
Fixes bug #12747 where fan game Phil's Quest immediately ends, but this
also affects early KQ2 and other games.
Changed paths:
engines/agi/agi.h
engines/agi/cycle.cpp
engines/agi/op_cmd.cpp
engines/agi/opcodes.cpp
engines/agi/opcodes.h
diff --git a/engines/agi/agi.h b/engines/agi/agi.h
index 24606adb150..57c170cb660 100644
--- a/engines/agi/agi.h
+++ b/engines/agi/agi.h
@@ -116,7 +116,7 @@ enum AgiGameType {
};
enum AgiGameFeatures {
- GF_AGIMOUSE = (1 << 0), // this disables "Click-to-walk mouse interface"
+ GF_AGIMOUSE = (1 << 0), // marks games created with AGIMOUSE, disables "Click-to-walk mouse interface"
GF_AGDS = (1 << 1), // marks games created with AGDS - all using AGI version 2.440
GF_AGI256 = (1 << 2), // marks fanmade AGI-256 games
GF_FANMADE = (1 << 3), // marks fanmade games
diff --git a/engines/agi/cycle.cpp b/engines/agi/cycle.cpp
index 78a72beca8e..30b1e4232e8 100644
--- a/engines/agi/cycle.cpp
+++ b/engines/agi/cycle.cpp
@@ -183,10 +183,10 @@ uint16 AgiEngine::processAGIEvents() {
// In AGI Mouse emulation mode we must update the mouse-related
// vars in every interpreter cycle.
- //
- // We run AGIMOUSE always as a side effect
- setVar(VM_VAR_MOUSE_X, _mouse.pos.x / 2);
- setVar(VM_VAR_MOUSE_Y, _mouse.pos.y);
+ if (getFeatures() & GF_AGIMOUSE) {
+ setVar(VM_VAR_MOUSE_X, _mouse.pos.x / 2);
+ setVar(VM_VAR_MOUSE_Y, _mouse.pos.y);
+ }
if (!cycleInnerLoopIsActive()) {
// Click-to-walk mouse interface
diff --git a/engines/agi/op_cmd.cpp b/engines/agi/op_cmd.cpp
index 01211ca3d6f..b809c92bcdf 100644
--- a/engines/agi/op_cmd.cpp
+++ b/engines/agi/op_cmd.cpp
@@ -1003,7 +1003,7 @@ void cmdSetSimple(AgiGame *state, AgiEngine *vm, uint8 *parameter) {
}
}
-// push.script was not available until 2.425, and also not available in 2.440
+// pop.script was not available until 2.425, and also not available in 2.440
void cmdPopScript(AgiGame *state, AgiEngine *vm, uint8 *parameter) {
if ((vm->getVersion() < 0x2425) || (vm->getVersion() == 0x2440)) {
// was not available before 2.2425, but also not available in 2.440
@@ -2245,7 +2245,17 @@ void cmdPrintAtV(AgiGame *state, AgiEngine *vm, uint8 *parameter) {
// push.script was not available until 2.425, and also not available in 2.440
void cmdPushScript(AgiGame *state, AgiEngine *vm, uint8 *parameter) {
- // We run AGIMOUSE always as a side effect
+ if ((vm->getVersion() < 0x2425) || (vm->getVersion() == 0x2440)) {
+ // was not available before 2.2425, but also not available in 2.440
+ warning("push.script called, although not available for current AGI version");
+ return;
+ }
+
+ debug(0, "push.script");
+}
+
+// The AGIMOUSE interpreter modified push.script to set variables 27-29 to mouse state
+void cmdAgiMousePushScript(AgiGame *state, AgiEngine *vm, uint8 *parameter) {
vm->setVar(VM_VAR_MOUSE_BUTTONSTATE, state->_vm->_mouse.button);
vm->setVar(VM_VAR_MOUSE_X, vm->_mouse.pos.x / 2);
vm->setVar(VM_VAR_MOUSE_Y, vm->_mouse.pos.y);
diff --git a/engines/agi/opcodes.cpp b/engines/agi/opcodes.cpp
index 805a1444200..641d970af18 100644
--- a/engines/agi/opcodes.cpp
+++ b/engines/agi/opcodes.cpp
@@ -452,6 +452,11 @@ void AgiEngine::setupOpCodes(uint16 version) {
}
}
+ // AGIMOUSE games use a modified push.script that updates mouse state
+ if (getFeatures() & GF_AGIMOUSE) {
+ _opCodes[0xab].functionPtr = &cmdAgiMousePushScript;
+ }
+
// add invalid entries for every opcode, that is not defined at all
for (int opCodeNr = opCodesTableSize; opCodeNr < ARRAYSIZE(_opCodes); opCodeNr++) {
_opCodes[opCodeNr].name = "illegal";
diff --git a/engines/agi/opcodes.h b/engines/agi/opcodes.h
index af1d616e1a8..a52e5d2bdc5 100644
--- a/engines/agi/opcodes.h
+++ b/engines/agi/opcodes.h
@@ -208,6 +208,7 @@ void cmdDivV(AgiGame *state, AgiEngine *vm, uint8 *p); // 0xa8
void cmdCloseWindow(AgiGame *state, AgiEngine *vm, uint8 *p);
void cmdSetSimple(AgiGame *state, AgiEngine *vm, uint8 *p);
void cmdPushScript(AgiGame *state, AgiEngine *vm, uint8 *p);
+void cmdAgiMousePushScript(AgiGame *state, AgiEngine *vm, uint8 *p); // modified 0xab
void cmdPopScript(AgiGame *state, AgiEngine *vm, uint8 *p);
void cmdHoldKey(AgiGame *state, AgiEngine *vm, uint8 *p);
void cmdSetPriBase(AgiGame *state, AgiEngine *vm, uint8 *p);
More information about the Scummvm-git-logs
mailing list