aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2003-09-11 10:32:15 +0000
committerMax Horn2003-09-11 10:32:15 +0000
commit81f10baa68d36f42f4988b971dff312439906a2f (patch)
treea58d9b322203713d9bc8a0de0531dfcab7c85904
parenta3bb9f81e0502f66e368b5e58861ffbb5cfdcd41 (diff)
downloadscummvm-rg350-81f10baa68d36f42f4988b971dff312439906a2f.tar.gz
scummvm-rg350-81f10baa68d36f42f4988b971dff312439906a2f.tar.bz2
scummvm-rg350-81f10baa68d36f42f4988b971dff312439906a2f.zip
cleanup
svn-id: r10169
-rw-r--r--scumm/actor.cpp2
-rw-r--r--scumm/boxes.cpp2
-rw-r--r--scumm/debugger.cpp19
-rw-r--r--scumm/object.h16
-rw-r--r--scumm/resource.cpp22
-rw-r--r--scumm/resource.h9
-rw-r--r--scumm/saveload.cpp25
-rw-r--r--scumm/script.cpp40
-rw-r--r--scumm/script.h74
-rw-r--r--scumm/script_v2.cpp13
-rw-r--r--scumm/script_v5.cpp19
-rw-r--r--scumm/script_v6.cpp71
-rw-r--r--scumm/script_v8.cpp21
-rw-r--r--scumm/scumm.h68
-rw-r--r--scumm/scummvm.cpp88
-rw-r--r--scumm/smush/smush_player.h7
-rw-r--r--scumm/string.cpp5
17 files changed, 273 insertions, 228 deletions
diff --git a/scumm/actor.cpp b/scumm/actor.cpp
index fe3798054e..51894b187b 100644
--- a/scumm/actor.cpp
+++ b/scumm/actor.cpp
@@ -32,8 +32,6 @@
#include "sound.h"
#include "usage_bits.h"
-#include <math.h>
-
byte Actor::kInvalidBox = 0;
Scumm *Actor::_vm = 0;
diff --git a/scumm/boxes.cpp b/scumm/boxes.cpp
index 325d66d364..dbf7d1c177 100644
--- a/scumm/boxes.cpp
+++ b/scumm/boxes.cpp
@@ -26,8 +26,6 @@
#include "boxes.h"
#include "common/util.h"
-#include <math.h>
-
#if !defined(__GNUC__)
#pragma START_PACK_STRUCTS
#endif
diff --git a/scumm/debugger.cpp b/scumm/debugger.cpp
index 8b9703b6cf..012dfbfae5 100644
--- a/scumm/debugger.cpp
+++ b/scumm/debugger.cpp
@@ -19,15 +19,18 @@
*
*/
#include "stdafx.h"
-#include "scumm.h"
-#include "sound.h"
-#include "actor.h"
-#include "boxes.h"
-#include "imuse.h"
-#include "player_v2.h"
-#include "debugger.h"
-#include "common/util.h"
+
#include "common/file.h"
+#include "common/util.h"
+
+#include "scumm/actor.h"
+#include "scumm/boxes.h"
+#include "scumm/debugger.h"
+#include "scumm/imuse.h"
+#include "scumm/object.h"
+#include "scumm/player_v2.h"
+#include "scumm/scumm.h"
+#include "scumm/sound.h"
#if USE_CONSOLE
#include "gui/console.h"
diff --git a/scumm/object.h b/scumm/object.h
index 1689799d05..19089abf29 100644
--- a/scumm/object.h
+++ b/scumm/object.h
@@ -21,6 +21,22 @@
#ifndef OBJECT_H
#define OBJECT_H
+struct ObjectData {
+ uint32 OBIMoffset;
+ uint32 OBCDoffset;
+ int16 walk_x, walk_y;
+ uint16 obj_nr;
+ int16 x_pos;
+ int16 y_pos;
+ uint16 width;
+ uint16 height;
+ byte actordir;
+ byte parent;
+ byte parentstate;
+ byte state;
+ byte fl_object_index;
+};
+
#if !defined(__GNUC__)
#pragma START_PACK_STRUCTS
#endif
diff --git a/scumm/resource.cpp b/scumm/resource.cpp
index 2115408987..7ee887df98 100644
--- a/scumm/resource.cpp
+++ b/scumm/resource.cpp
@@ -21,17 +21,18 @@
*/
#include "stdafx.h"
-#include "imuse.h"
-#include "scumm.h"
-#include "resource.h"
-#include "bundle.h"
-#include "verbs.h"
-#include "scumm/sound.h"
#include "common/map.h"
#include "common/str.h"
-#include "sound/mididrv.h" // Need MD_ enum values
#include "gui/message.h"
-#include "dialogs.h"
+#include "scumm/bundle.h"
+#include "scumm/dialogs.h"
+#include "scumm/imuse.h"
+#include "scumm/object.h"
+#include "scumm/resource.h"
+#include "scumm/scumm.h"
+#include "scumm/sound.h"
+#include "scumm/verbs.h"
+#include "sound/mididrv.h" // Need MD_ enum values
static uint16 newTag2Old(uint32 oldTag);
static const char *resTypeFromId(int id);
@@ -238,9 +239,8 @@ void Scumm::askForDisk(const char *filename, int disknum) {
error("Cannot find file: '%s'", filename);
} else {
sprintf(buf, "Cannot find file: '%s'", filename);
- InfoDialog* dialog = new InfoDialog(_newgui, this, (char*)buf);
- runDialog (dialog);
- delete dialog;
+ InfoDialog dialog(_newgui, this, (char*)buf);
+ runDialog(dialog);
error("Cannot find file: '%s'", filename);
}
}
diff --git a/scumm/resource.h b/scumm/resource.h
index d89c5266cf..b6ca35dc71 100644
--- a/scumm/resource.h
+++ b/scumm/resource.h
@@ -50,6 +50,15 @@ enum {
};
+#define ARRAY_HDR_SIZE 6
+struct ArrayHeader {
+ int16 dim1_size;
+ int16 type;
+ int16 dim2_size;
+ byte data[1];
+};
+
+
const byte *findResource(uint32 tag, const byte *searchin);
const byte *findResourceSmall(uint32 tag, const byte *searchin);
diff --git a/scumm/saveload.cpp b/scumm/saveload.cpp
index 89be05d0db..7d7b4775a3 100644
--- a/scumm/saveload.cpp
+++ b/scumm/saveload.cpp
@@ -21,18 +21,23 @@
*/
#include "stdafx.h"
-#include "actor.h"
-#include "charset.h"
-#include "imuse.h"
-#include "imuse_digi.h"
-#include "resource.h"
-#include "saveload.h"
-#include "scumm.h"
-#include "sound.h"
-#include "verbs.h"
+
#include "common/config-file.h"
+
+#include "scumm/actor.h"
+#include "scumm/charset.h"
+#include "scumm/imuse_digi.h"
+#include "scumm/imuse.h"
+#include "scumm/object.h"
+#include "scumm/resource.h"
+#include "scumm/saveload.h"
+#include "scumm/scumm.h"
+#include "scumm/sound.h"
+#include "scumm/verbs.h"
+
#include "sound/mixer.h"
+
struct SaveGameHeader {
uint32 type;
uint32 size;
@@ -394,7 +399,7 @@ void Scumm::saveOrLoad(Serializer *s, uint32 savegameVersion) {
MKARRAY(Scumm, vm.cutSceneData[0], sleInt16, 5, VER(8)),
MKLINE(Scumm, vm.cutSceneScriptIndex, sleInt16, VER(8)),
- MKLINE(Scumm, _numNestedScripts, sleByte, VER(8)),
+ MKLINE(Scumm, vm.numNestedScripts, sleByte, VER(8)),
MKLINE(Scumm, _userPut, sleByte, VER(8)),
MKLINE(Scumm, _userState, sleUint16, VER(17)),
MKLINE(Scumm, _cursor.state, sleByte, VER(8)),
diff --git a/scumm/script.cpp b/scumm/script.cpp
index d3fb2f72e0..6d75bbd151 100644
--- a/scumm/script.cpp
+++ b/scumm/script.cpp
@@ -21,18 +21,13 @@
*/
#include "stdafx.h"
-#include "scumm.h"
-#include "actor.h"
-#include "resource.h"
-#include "common/util.h"
-/* Script status type (slot.status) */
-enum {
- ssDead = 0,
- ssPaused = 1,
- ssRunning = 2
-};
+#include "common/util.h"
+#include "scumm/actor.h"
+#include "scumm/object.h"
+#include "scumm/resource.h"
+#include "scumm/scumm.h"
/* Start executing script 'script' with the given parameters */
void Scumm::runScript(int script, bool freezeResistant, bool recursive, int *lvarptr) {
@@ -221,7 +216,7 @@ void Scumm::stopScript(int script) {
}
nest = vm.nest;
- num = _numNestedScripts;
+ num = vm.numNestedScripts;
while (num > 0) {
if (nest->number == script &&
@@ -258,7 +253,7 @@ void Scumm::stopObjectScript(int script) {
}
nest = vm.nest;
- num = _numNestedScripts;
+ num = vm.numNestedScripts;
while (num > 0) {
if (nest->number == script &&
@@ -293,7 +288,7 @@ void Scumm::runScriptNested(int script) {
updateScriptPtr();
- nest = &vm.nest[_numNestedScripts];
+ nest = &vm.nest[vm.numNestedScripts];
if (_currentScript == 0xFF) {
nest->number = 0xFF;
@@ -306,9 +301,9 @@ void Scumm::runScriptNested(int script) {
nest->slot = _currentScript;
}
- _numNestedScripts++;
+ vm.numNestedScripts++;
- if (_numNestedScripts > ARRAYSIZE(vm.nest))
+ if (vm.numNestedScripts > ARRAYSIZE(vm.nest))
error("Too many nested scripts");
_currentScript = script;
@@ -316,7 +311,7 @@ void Scumm::runScriptNested(int script) {
getScriptEntryPoint();
executeScript();
- _numNestedScripts--;
+ vm.numNestedScripts--;
if (nest->number != 0xFF) {
// Try to resume the script which called us, if its status has not changed
@@ -360,7 +355,7 @@ void Scumm::getScriptBaseAddress() {
_lastCodePtr = &_baseInventoryItems[idx];
break;
- case 3:
+ case WIO_LOCAL:
case WIO_ROOM: /* room script */
if (_version == 8) {
_scriptOrgPointer = getResourceAddress(rtRoomScripts, _roomResource);
@@ -865,6 +860,7 @@ void Scumm::doSentence(int verb, int objectA, int objectB) {
void Scumm::checkAndRunSentenceScript() {
int i;
+ int localParamList[16];
const ScriptSlot *ss;
int sentenceScript;
if (_version <= 2)
@@ -872,7 +868,7 @@ void Scumm::checkAndRunSentenceScript() {
else
sentenceScript = VAR(VAR_SENTENCE_SCRIPT);
- memset(_localParamList, 0, sizeof(_localParamList));
+ memset(localParamList, 0, sizeof(localParamList));
if (isScriptInUse(sentenceScript)) {
ss = vm.slot;
for (i = 0; i < NUM_SCRIPT_SLOT; i++, ss++)
@@ -895,13 +891,13 @@ void Scumm::checkAndRunSentenceScript() {
_scummVars[VAR_ACTIVE_OBJECT2] = _sentence[_sentenceNum].objectB;
_scummVars[VAR_VERB_ALLOWED] = (0 != getVerbEntrypoint(_sentence[_sentenceNum].objectA, _sentence[_sentenceNum].verb));
} else {
- _localParamList[0] = _sentence[_sentenceNum].verb;
- _localParamList[1] = _sentence[_sentenceNum].objectA;
- _localParamList[2] = _sentence[_sentenceNum].objectB;
+ localParamList[0] = _sentence[_sentenceNum].verb;
+ localParamList[1] = _sentence[_sentenceNum].objectA;
+ localParamList[2] = _sentence[_sentenceNum].objectB;
}
_currentScript = 0xFF;
if (sentenceScript)
- runScript(sentenceScript, 0, 0, _localParamList);
+ runScript(sentenceScript, 0, 0, localParamList);
}
void Scumm::runInputScript(int a, int cmd, int mode) {
diff --git a/scumm/script.h b/scumm/script.h
new file mode 100644
index 0000000000..9957566dfd
--- /dev/null
+++ b/scumm/script.h
@@ -0,0 +1,74 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2001 Ludvig Strigeus
+ * Copyright (C) 2001-2003 The ScummVM project
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Header$
+ *
+ */
+
+#ifndef SCRIPT_H
+#define SCRIPT_H
+
+#include "common/engine.h"
+
+
+/* System Wide Constants */
+enum {
+ NUM_SCRIPT_SLOT = 80
+};
+
+/* Script status type (slot.status) */
+enum {
+ ssDead = 0,
+ ssPaused = 1,
+ ssRunning = 2
+};
+
+struct ScriptSlot {
+ uint32 offs;
+ int32 delay;
+ uint16 number;
+ uint16 delayFrameCount;
+ bool freezeResistant, recursive;
+ bool didexec;
+ byte status;
+ byte where;
+ byte freezeCount;
+ byte cutsceneOverride;
+};
+
+struct NestedScript {
+ uint16 number;
+ uint8 where;
+ uint8 slot;
+};
+
+struct VirtualMachineState {
+ uint32 cutScenePtr[5];
+ byte cutSceneScript[5];
+ int16 cutSceneData[5];
+ int16 cutSceneScriptIndex;
+ byte cutSceneStackPointer;
+ ScriptSlot slot[NUM_SCRIPT_SLOT];
+ int32 localvar[NUM_SCRIPT_SLOT][26];
+
+ NestedScript nest[15];
+ byte numNestedScripts;
+};
+
+
+#endif
diff --git a/scumm/script_v2.cpp b/scumm/script_v2.cpp
index 04e13b83b9..3d0989e077 100644
--- a/scumm/script_v2.cpp
+++ b/scumm/script_v2.cpp
@@ -21,12 +21,13 @@
*/
#include "stdafx.h"
-#include "scumm.h"
-#include "actor.h"
-#include "charset.h"
-#include "intern.h"
-#include "sound.h"
-#include "verbs.h"
+#include "scumm/actor.h"
+#include "scumm/charset.h"
+#include "scumm/intern.h"
+#include "scumm/object.h"
+#include "scumm/scumm.h"
+#include "scumm/sound.h"
+#include "scumm/verbs.h"
#define OPCODE(x) { &Scumm_v2::x, #x }
diff --git a/scumm/script_v5.cpp b/scumm/script_v5.cpp
index 6f831e854a..5f1395f40a 100644
--- a/scumm/script_v5.cpp
+++ b/scumm/script_v5.cpp
@@ -21,12 +21,13 @@
*/
#include "stdafx.h"
-#include "scumm.h"
-#include "actor.h"
-#include "charset.h"
-#include "intern.h"
-#include "sound.h"
-#include "verbs.h"
+#include "scumm/actor.h"
+#include "scumm/charset.h"
+#include "scumm/intern.h"
+#include "scumm/object.h"
+#include "scumm/scumm.h"
+#include "scumm/sound.h"
+#include "scumm/verbs.h"
#define OPCODE(x) { &Scumm_v5::x, #x }
@@ -623,7 +624,7 @@ void Scumm_v5::o5_chainScript() {
}
vm.slot[cur].number = 0;
- vm.slot[cur].status = 0;
+ vm.slot[cur].status = ssDead;
_currentScript = 0xFF;
runScript(script, vm.slot[cur].freezeResistant, vm.slot[cur].recursive, vars);
@@ -731,13 +732,13 @@ void Scumm_v5::o5_delay() {
delay |= fetchScriptByte() << 8;
delay |= fetchScriptByte() << 16;
vm.slot[_currentScript].delay = delay;
- vm.slot[_currentScript].status = 1;
+ vm.slot[_currentScript].status = ssPaused;
o5_breakHere();
}
void Scumm_v5::o5_delayVariable() {
vm.slot[_currentScript].delay = getVar();
- vm.slot[_currentScript].status = 1;
+ vm.slot[_currentScript].status = ssPaused;
o5_breakHere();
}
diff --git a/scumm/script_v6.cpp b/scumm/script_v6.cpp
index a0cb3b2057..a4fe758721 100644
--- a/scumm/script_v6.cpp
+++ b/scumm/script_v6.cpp
@@ -22,20 +22,22 @@
#include "stdafx.h"
-#include <time.h>
-
-#include "actor.h"
-#include "charset.h"
-#include "imuse.h"
-#include "intern.h"
-#include "scumm.h"
-#include "sound.h"
-#include "verbs.h"
-#include "smush/smush_player.h"
+
+#include "scumm/actor.h"
+#include "scumm/charset.h"
+#include "scumm/imuse.h"
+#include "scumm/intern.h"
+#include "scumm/object.h"
+#include "scumm/resource.h"
+#include "scumm/scumm.h"
+#include "scumm/sound.h"
+#include "scumm/verbs.h"
+#include "scumm/smush/smush_player.h"
+
#include "sound/mididrv.h"
#include "sound/mixer.h"
-#include "dialogs.h" // FIXME: This is just for the FT-INSANE warning.
+#include "scumm/dialogs.h" // FIXME: This is just for the FT-INSANE warning.
// Remove when INSANE is implemented
#define OPCODE(x) { &Scumm_v6::x, #x }
@@ -2184,7 +2186,7 @@ void Scumm_v6::o6_delay() {
// CMI it would seem this should delay for 1/10th of a second...
uint32 delay = (uint16)pop();
vm.slot[_currentScript].delay = delay;
- vm.slot[_currentScript].status = 1;
+ vm.slot[_currentScript].status = ssPaused;
o6_breakHere();
}
@@ -2199,7 +2201,7 @@ void Scumm_v6::o6_delaySeconds() {
delay = delay * 90;
vm.slot[_currentScript].delay = delay;
- vm.slot[_currentScript].status = 1;
+ vm.slot[_currentScript].status = ssPaused;
o6_breakHere();
}
@@ -2207,7 +2209,7 @@ void Scumm_v6::o6_delayMinutes() {
// FIXME - are we really measuring minutes here?
uint32 delay = (uint16)pop() * 3600;
vm.slot[_currentScript].delay = delay;
- vm.slot[_currentScript].status = 1;
+ vm.slot[_currentScript].status = ssPaused;
o6_breakHere();
}
@@ -2422,29 +2424,26 @@ void Scumm_v6::o6_kernelSetFunctions() {
case 2:
sp->play("tovista1.san", getGameDataPath());
break;
- case 3: {
- if (readArray(233,0,50) == 0) {
- InfoDialog *dialog = new InfoDialog(_newgui, this,
- "Set MineRoad - You can now jump the gorge.");
- runDialog (dialog);
- delete dialog;
-
- writeArray(233, 0, 50, 1); // INSANE callback: Chain
- writeArray(233, 0, 51, 1); // INSANE callback: Chainsaw
- writeArray(233, 0, 52, 1); // INSANE callback: Mace
- writeArray(233, 0, 53, 1); // INSANE callback: 2x4
- writeArray(233, 0, 54, 1); // INSANE callback: Wrench
- writeArray(233, 0, 55, 1); // INSANE callback: Dust
-
- writeArray(233, 0, 8, 1); // INSANE callback: Give Googles
- writeArray(233, 0, 7, 1); // INSANE callback: Give nitro fuel
-
- putState(235, 1); // Cheat and activate Ramp
- writeVar(142 | 0x8000, 1); // Cheat and activate auto-booster (fan)
- }
-// smush->play("minefite.san", getGameDataPath());
+ case 3:
+ if (readArray(233,0,50) == 0) {
+ InfoDialog info(_newgui, this, "Set MineRoad - You can now jump the gorge.");
+ runDialog(info);
+
+ writeArray(233, 0, 50, 1); // INSANE callback: Chain
+ writeArray(233, 0, 51, 1); // INSANE callback: Chainsaw
+ writeArray(233, 0, 52, 1); // INSANE callback: Mace
+ writeArray(233, 0, 53, 1); // INSANE callback: 2x4
+ writeArray(233, 0, 54, 1); // INSANE callback: Wrench
+ writeArray(233, 0, 55, 1); // INSANE callback: Dust
+
+ writeArray(233, 0, 8, 1); // INSANE callback: Give Googles
+ writeArray(233, 0, 7, 1); // INSANE callback: Give nitro fuel
+
+ putState(235, 1); // Cheat and activate Ramp
+ writeVar(142 | 0x8000, 1); // Cheat and activate auto-booster (fan)
+ }
+// sp->play("minefite.san", getGameDataPath());
break;
- }
case 4:
sp->play("rottopen.san", getGameDataPath());
break;
diff --git a/scumm/script_v8.cpp b/scumm/script_v8.cpp
index c333c50848..9f442401f4 100644
--- a/scumm/script_v8.cpp
+++ b/scumm/script_v8.cpp
@@ -20,19 +20,18 @@
*/
#include "stdafx.h"
-#include "scumm.h"
-#include "actor.h"
-#include "akos.h"
-#include "charset.h"
-#include "intern.h"
-#include "sound.h"
-#include "verbs.h"
-#include "smush/smush_player.h"
-
+#include "scumm/actor.h"
+#include "scumm/akos.h"
+#include "scumm/charset.h"
+#include "scumm/intern.h"
+#include "scumm/object.h"
+#include "scumm/resource.h"
+#include "scumm/scumm.h"
+#include "scumm/sound.h"
+#include "scumm/verbs.h"
+#include "scumm/smush/smush_player.h"
#include "sound/mixer.h"
-#include <time.h>
-
#define OPCODE(x) { &Scumm_v8::x, #x }
diff --git a/scumm/scumm.h b/scumm/scumm.h
index 4fc2396023..c5869f4835 100644
--- a/scumm/scumm.h
+++ b/scumm/scumm.h
@@ -30,6 +30,7 @@
#include "common/str.h"
#include "scumm/gfx.h"
+#include "scumm/script.h"
class Actor;
class BaseCostumeRenderer;
@@ -59,7 +60,6 @@ extern Scumm *g_scumm;
/* System Wide Constants */
enum {
- NUM_SCRIPT_SLOT = 80,
NUM_LOCALSCRIPT = 60,
NUM_SENTENCE = 6,
NUM_SHADOW_PALETTE = 8,
@@ -110,41 +110,7 @@ struct MemBlkHeader {
};
struct VerbSlot;
-
-struct ObjectData {
- uint32 OBIMoffset;
- uint32 OBCDoffset;
- int16 walk_x, walk_y;
- uint16 obj_nr;
- int16 x_pos;
- int16 y_pos;
- uint16 width;
- uint16 height;
- byte actordir;
- byte parent;
- byte parentstate;
- byte state;
- byte fl_object_index;
-};
-
-struct ScriptSlot {
- uint32 offs;
- int32 delay;
- uint16 number;
- uint16 delayFrameCount;
- bool freezeResistant, recursive;
- bool didexec;
- byte status;
- byte where;
- byte freezeCount;
- byte cutsceneOverride;
-};
-
-struct NestedScript {
- uint16 number;
- uint8 where;
- uint8 slot;
-};
+struct ObjectData;
struct BlastText {
int16 xpos, ypos;
@@ -246,14 +212,6 @@ enum ScummGameId {
#define _roomFileOffsets res.roomoffs[rtRoom]
-#define ARRAY_HDR_SIZE 6
-struct ArrayHeader {
- int16 dim1_size;
- int16 type;
- int16 dim2_size;
- byte data[1];
-};
-
struct SentenceTab {
byte verb;
byte preposition;
@@ -286,11 +244,6 @@ enum WhereIsObject {
WIO_FLOBJECT = 4
};
-enum MouseButtonStatus {
- msDown = 1,
- msClicked = 2
-};
-
struct LangIndexNode {
char tag[12+1];
int32 offset;
@@ -332,16 +285,7 @@ public:
} res;
protected:
- struct {
- uint32 cutScenePtr[5];
- byte cutSceneScript[5];
- int16 cutSceneData[5];
- int16 cutSceneScriptIndex;
- byte cutSceneStackPointer;
- ScriptSlot slot[NUM_SCRIPT_SLOT];
- NestedScript nest[15];
- int32 localvar[NUM_SCRIPT_SLOT][26];
- } vm;
+ VirtualMachineState vm;
public:
// Constructor / Destructor
@@ -405,7 +349,7 @@ public:
ConsoleDialog *_debuggerDialog;
protected:
- int runDialog(Dialog *dialog);
+ int runDialog(Dialog &dialog);
void confirmexitDialog();
void pauseDialog();
void saveloadDialog();
@@ -540,11 +484,11 @@ protected:
/* Script VM - should be in Script class */
uint32 _localScriptList[NUM_LOCALSCRIPT];
const byte *_scriptPointer, *_scriptOrgPointer;
- byte _opcode, _numNestedScripts, _currentScript;
+ byte _opcode, _currentScript;
uint16 _curExecScript;
byte **_lastCodePtr;
int _resultVarNumber, _scummStackPos;
- int _localParamList[16], _scummStack[150];
+ int _scummStack[150];
int _keyScriptKey, _keyScriptNo;
virtual void setupOpcodes() = 0;
diff --git a/scumm/scummvm.cpp b/scumm/scummvm.cpp
index 966e499f96..8eef25aa52 100644
--- a/scumm/scummvm.cpp
+++ b/scumm/scummvm.cpp
@@ -21,33 +21,35 @@
*/
#include "stdafx.h"
-#include "scumm.h"
-#include "actor.h"
-#include "boxes.h"
-#include "charset.h"
-#include "debugger.h"
-#include "dialogs.h"
-#include "imuse.h"
-#include "imuse_digi.h"
-#include "intern.h"
-#include "object.h"
-#include "player_v3a.h"
-#include "player_v2.h"
-#include "player_v1.h"
-#include "resource.h"
-#include "sound.h"
-#include "string.h"
-#include "verbs.h"
-#include "common/gameDetector.h"
+
#include "common/config-file.h"
+#include "common/gameDetector.h"
+
#include "gui/console.h"
-#include "gui/newgui.h"
#include "gui/message.h"
-#include "sound/mixer.h"
-#include "sound/mididrv.h"
+#include "gui/newgui.h"
-#include "akos.h"
-#include "costume.h"
+#include "scumm/actor.h"
+#include "scumm/akos.h"
+#include "scumm/boxes.h"
+#include "scumm/charset.h"
+#include "scumm/costume.h"
+#include "scumm/debugger.h"
+#include "scumm/dialogs.h"
+#include "scumm/imuse_digi.h"
+#include "scumm/imuse.h"
+#include "scumm/intern.h"
+#include "scumm/object.h"
+#include "scumm/player_v1.h"
+#include "scumm/player_v2.h"
+#include "scumm/player_v3a.h"
+#include "scumm/resource.h"
+#include "scumm/scumm.h"
+#include "scumm/sound.h"
+#include "scumm/verbs.h"
+
+#include "sound/mididrv.h"
+#include "sound/mixer.h"
#ifdef MACOSX
#include <sys/types.h>
@@ -58,6 +60,11 @@
extern bool isSmartphone(void);
#endif
+enum MouseButtonStatus {
+ msDown = 1,
+ msClicked = 2
+};
+
// Use g_scumm from error() ONLY
Scumm *g_scumm = 0;
ScummDebugger *g_debugger;
@@ -368,13 +375,12 @@ Scumm::Scumm (GameDetector *detector, OSystem *syst)
_scriptPointer = NULL;
_scriptOrgPointer = NULL;
_opcode = 0;
- _numNestedScripts = 0;
+ vm.numNestedScripts = 0;
_currentScript = 0;
_curExecScript = 0;
_lastCodePtr = NULL;
_resultVarNumber = 0;
_scummStackPos = 0;
- memset(_localParamList, 0, sizeof(_localParamList));
memset(_scummStack, 0, sizeof(_scummStack));
_keyScriptKey = 0;
_keyScriptNo = 0;
@@ -1007,7 +1013,7 @@ void Scumm::scummInit() {
_actors[i].setActorCostume(i);
}
- _numNestedScripts = 0;
+ vm.numNestedScripts = 0;
vm.cutSceneStackPointer = 0;
memset(vm.cutScenePtr, 0, sizeof(vm.cutScenePtr));
@@ -1368,9 +1374,8 @@ load_game:
#endif
sprintf(buf, "Successfully saved game state in file:\n\n%s", filename);
- Dialog *dialog = new MessageDialog(_newgui, buf, 1500, false);
+ MessageDialog dialog(_newgui, buf, 1500, false);
runDialog(dialog);
- delete dialog;
}
if (success && _saveLoadFlag != 1)
clearClickedStatus();
@@ -2392,8 +2397,8 @@ void Scumm::restart() {
setShake(0);
_sound->stopAllSounds();
- // Empty variables
- for (i=0;i<255;i++)
+ // Clear the script variables
+ for (i = 0; i < 255; i++)
_scummVars[i] = 0;
// Empty inventory
@@ -2419,7 +2424,7 @@ void Scumm::startManiac() {
#pragma mark --- GUI ---
#pragma mark -
-int Scumm::runDialog(Dialog *dialog) {
+int Scumm::runDialog(Dialog &dialog) {
// Pause sound put
bool old_soundsPaused = _sound->_soundsPaused;
_sound->pauseSounds(true);
@@ -2429,7 +2434,7 @@ int Scumm::runDialog(Dialog *dialog) {
_smushPlay = false;
// Open & run the dialog
- int result = dialog->runModal();
+ int result = dialog.runModal();
// Restore old cursor
updateCursor();
@@ -2447,35 +2452,35 @@ int Scumm::runDialog(Dialog *dialog) {
void Scumm::pauseDialog() {
if (!_pauseDialog)
_pauseDialog = new PauseDialog(_newgui, this);
- runDialog(_pauseDialog);
+ runDialog(*_pauseDialog);
}
void Scumm::saveloadDialog() {
if (!_saveLoadDialog)
_saveLoadDialog = new SaveLoadDialog(_newgui, this);
- runDialog(_saveLoadDialog);
+ runDialog(*_saveLoadDialog);
}
void Scumm::optionsDialog() {
if (!_optionsDialog)
_optionsDialog = new OptionsDialog(_newgui, this);
- runDialog(_optionsDialog);
+ runDialog(*_optionsDialog);
}
void Scumm::confirmexitDialog() {
if (!_confirmExitDialog)
_confirmExitDialog = new ConfirmExitDialog(_newgui, this);
- if (runDialog(_confirmExitDialog)) {
+ if (runDialog(*_confirmExitDialog)) {
_quit = true;
}
}
char Scumm::displayError(bool showCancel, const char *message, ...) {
#ifdef __PALM_OS__
- char buf[256], result; // 1024 is too big overflow the stack
+ char buf[256]; // 1024 is too big overflow the stack
#else
- char buf[1024], result;
+ char buf[1024];
#endif
va_list va;
@@ -2483,11 +2488,8 @@ char Scumm::displayError(bool showCancel, const char *message, ...) {
vsprintf(buf, message, va);
va_end(va);
- Dialog *dialog = new MessageDialog(_newgui, buf, 0, true, showCancel);
- result = runDialog(dialog);
- delete dialog;
-
- return result;
+ MessageDialog dialog(_newgui, buf, 0, true, showCancel);
+ return runDialog(dialog);
}
#pragma mark -
diff --git a/scumm/smush/smush_player.h b/scumm/smush/smush_player.h
index b94114a44c..0289394d71 100644
--- a/scumm/smush/smush_player.h
+++ b/scumm/smush/smush_player.h
@@ -23,9 +23,10 @@
#define SMUSH_PLAYER_H
#include "common/util.h"
-#include "chunk.h"
-#include "codec37.h"
-#include "codec47.h"
+#include "scumm/smush/chunk.h"
+#include "scumm/smush/codec37.h"
+#include "scumm/smush/codec47.h"
+#include "sound/mixer.h"
class SmushFont;
class SmushMixer;
diff --git a/scumm/string.cpp b/scumm/string.cpp
index a7148b6644..74a57f7198 100644
--- a/scumm/string.cpp
+++ b/scumm/string.cpp
@@ -76,11 +76,10 @@ void Scumm::unkMessage2() {
if (_string[3].color == 0)
_string[3].color = 4;
- InfoDialog* dialog = new InfoDialog(_newgui, this, (char*)buf);
// FIXME: I know this is the right thing to do for MI1 and MI2. For
// all other games it's just a guess.
- VAR(VAR_KEYPRESS) = runDialog (dialog);
- delete dialog;
+ InfoDialog dialog(_newgui, this, (char*)buf);
+ VAR(VAR_KEYPRESS) = runDialog(dialog);
_messagePtr = tmp;
}