[Scummvm-git-logs] scummvm master -> 126c19855a9b4ef85f1ed697f39dca42335f84f7
sluicebox
noreply at scummvm.org
Sat Mar 2 20:22:41 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:
126c19855a AGI: Restrict AGIMOUSE feature to AGIMOUSE games
Commit: 126c19855a9b4ef85f1ed697f39dca42335f84f7
https://github.com/scummvm/scummvm/commit/126c19855a9b4ef85f1ed697f39dca42335f84f7
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2024-03-02T13:22:38-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 1cff3cfd815..1f3e0ae8db3 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 658429416fb..2edf5414673 100644
--- a/engines/agi/op_cmd.cpp
+++ b/engines/agi/op_cmd.cpp
@@ -992,7 +992,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
@@ -2224,7 +2224,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 a929c7beead..9f8735de5bd 100644
--- a/engines/agi/opcodes.cpp
+++ b/engines/agi/opcodes.cpp
@@ -462,6 +462,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