aboutsummaryrefslogtreecommitdiff
path: root/engines/m4
diff options
context:
space:
mode:
Diffstat (limited to 'engines/m4')
-rw-r--r--engines/m4/actor.cpp4
-rw-r--r--engines/m4/actor.h8
-rw-r--r--engines/m4/animation.cpp2
-rw-r--r--engines/m4/animation.h4
-rw-r--r--engines/m4/assets.cpp16
-rw-r--r--engines/m4/assets.h22
-rw-r--r--engines/m4/compression.cpp2
-rw-r--r--engines/m4/compression.h2
-rw-r--r--engines/m4/console.cpp21
-rw-r--r--engines/m4/console.h31
-rw-r--r--engines/m4/converse.cpp2
-rw-r--r--engines/m4/converse.h6
-rw-r--r--engines/m4/detection.cpp15
-rw-r--r--engines/m4/dialogs.cpp115
-rw-r--r--engines/m4/dialogs.h10
-rw-r--r--engines/m4/events.cpp10
-rw-r--r--engines/m4/events.h8
-rw-r--r--engines/m4/font.cpp2
-rw-r--r--engines/m4/font.h4
-rw-r--r--engines/m4/globals.cpp22
-rw-r--r--engines/m4/globals.h18
-rw-r--r--engines/m4/graphics.cpp4
-rw-r--r--engines/m4/graphics.h4
-rw-r--r--engines/m4/gui.cpp2
-rw-r--r--engines/m4/gui.h6
-rw-r--r--engines/m4/hotspot.cpp4
-rw-r--r--engines/m4/m4.cpp276
-rw-r--r--engines/m4/m4.h31
-rw-r--r--engines/m4/m4_menus.cpp4
-rw-r--r--engines/m4/m4_menus.h2
-rw-r--r--engines/m4/m4_views.cpp4
-rw-r--r--engines/m4/m4_views.h6
-rw-r--r--engines/m4/mads_anim.cpp10
-rw-r--r--engines/m4/mads_anim.h10
-rw-r--r--engines/m4/mads_menus.cpp10
-rw-r--r--engines/m4/mads_menus.h6
-rw-r--r--engines/m4/midi.cpp2
-rw-r--r--engines/m4/midi.h4
-rw-r--r--engines/m4/resource.cpp2
-rw-r--r--engines/m4/resource.h8
-rw-r--r--engines/m4/saveload.cpp2
-rw-r--r--engines/m4/saveload.h4
-rw-r--r--engines/m4/scene.cpp36
-rw-r--r--engines/m4/scene.h4
-rw-r--r--engines/m4/script.cpp2
-rw-r--r--engines/m4/script.h4
-rw-r--r--engines/m4/sound.cpp2
-rw-r--r--engines/m4/sound.h6
-rw-r--r--engines/m4/sprite.h4
-rw-r--r--engines/m4/viewmgr.cpp8
-rw-r--r--engines/m4/viewmgr.h12
-rw-r--r--engines/m4/woodscript.cpp2
-rw-r--r--engines/m4/woodscript.h6
53 files changed, 465 insertions, 346 deletions
diff --git a/engines/m4/actor.cpp b/engines/m4/actor.cpp
index 82f7361cca..e80bcac6ca 100644
--- a/engines/m4/actor.cpp
+++ b/engines/m4/actor.cpp
@@ -33,7 +33,7 @@ namespace M4 {
#define WALKER_BURGER "Wilbur0%i" // wilbur, with a number denoting his current direction
-Actor::Actor(M4Engine *vm) : _vm(vm) {
+Actor::Actor(MadsM4Engine *vm) : _vm(vm) {
_scaling = 100;
_direction = 5;
_walkerSprites.resize(10);
@@ -104,7 +104,7 @@ void Actor::setWalkerPalette() {
_walkerSprites[kFacingSouthEast]->getColorCount());
}
-Inventory::Inventory(M4Engine *vm) : _vm(vm) {
+Inventory::Inventory(MadsM4Engine *vm) : _vm(vm) {
}
Inventory::~Inventory() {
diff --git a/engines/m4/actor.h b/engines/m4/actor.h
index 4bf212b2cc..96299ab629 100644
--- a/engines/m4/actor.h
+++ b/engines/m4/actor.h
@@ -61,7 +61,7 @@ enum WalkerDirection {
class Actor {
public:
- Actor(M4Engine *vm);
+ Actor(MadsM4Engine *vm);
~Actor();
void placeWalkerSpriteAt(int spriteNum, int x, int y);
void setWalkerScaling(int scaling) { _scaling = scaling; }
@@ -72,7 +72,7 @@ public:
int getWalkerWidth();
int getWalkerHeight();
private:
- M4Engine *_vm;
+ MadsM4Engine *_vm;
int _scaling;
uint8 _direction;
Common::Array<SpriteAsset*> _walkerSprites;
@@ -90,7 +90,7 @@ private:
// the normal strcmp method instead
class Inventory {
public:
- Inventory(M4Engine *vm);
+ Inventory(MadsM4Engine *vm);
~Inventory();
void clear();
void registerObject(char* name, int32 scene, int32 icon);
@@ -107,7 +107,7 @@ public:
int getTotalItems() { return _inventory.size(); }
private:
- M4Engine *_vm;
+ MadsM4Engine *_vm;
Common::Array<InventoryObject *> _inventory;
};
diff --git a/engines/m4/animation.cpp b/engines/m4/animation.cpp
index 836334a305..fe46e121f0 100644
--- a/engines/m4/animation.cpp
+++ b/engines/m4/animation.cpp
@@ -31,7 +31,7 @@ namespace M4 {
// TODO: this code needs cleanup
-Animation::Animation(M4Engine *vm) {
+Animation::Animation(MadsM4Engine *vm) {
_vm = vm;
_playing = false;
}
diff --git a/engines/m4/animation.h b/engines/m4/animation.h
index d11765facf..c8be7f5cb3 100644
--- a/engines/m4/animation.h
+++ b/engines/m4/animation.h
@@ -43,7 +43,7 @@ struct AnimationFrame {
class Animation {
public:
- Animation(M4Engine *vm);
+ Animation(MadsM4Engine *vm);
~Animation();
void load(const char *filename);
@@ -54,7 +54,7 @@ class Animation {
private:
bool _playing;
- M4Engine *_vm;
+ MadsM4Engine *_vm;
int _seriesCount;
int _frameCount;
int _frameEntryCount;
diff --git a/engines/m4/assets.cpp b/engines/m4/assets.cpp
index 66a3629fe9..de65c8b782 100644
--- a/engines/m4/assets.cpp
+++ b/engines/m4/assets.cpp
@@ -29,13 +29,13 @@
namespace M4 {
-BaseAsset::BaseAsset(M4Engine *vm, Common::SeekableReadStream* stream, int size, const char *name) : _vm(vm) {
+BaseAsset::BaseAsset(MadsM4Engine *vm, Common::SeekableReadStream* stream, int size, const char *name) : _vm(vm) {
}
BaseAsset::~BaseAsset() {
}
-MachineAsset::MachineAsset(M4Engine *vm, Common::SeekableReadStream* stream, int size, const char *name) : BaseAsset(vm, stream, size, name) {
+MachineAsset::MachineAsset(MadsM4Engine *vm, Common::SeekableReadStream* stream, int size, const char *name) : BaseAsset(vm, stream, size, name) {
uint32 stateCount = stream->readUint32LE();
for (uint32 curState = 0; curState < stateCount; curState++) {
uint32 stateOffset = stream->readUint32LE();
@@ -60,7 +60,7 @@ uint32 MachineAsset::getStateOffset(uint32 state) {
return _stateTable[state];
}
-SequenceAsset::SequenceAsset(M4Engine *vm, Common::SeekableReadStream* stream, int size, const char *name) : BaseAsset(vm, stream, size, name) {
+SequenceAsset::SequenceAsset(MadsM4Engine *vm, Common::SeekableReadStream* stream, int size, const char *name) : BaseAsset(vm, stream, size, name) {
_localVarCount = stream->readUint32LE();
_codeSize = size - 4;
_code = new byte[_codeSize];
@@ -77,7 +77,7 @@ void SequenceAsset::getCode(byte *&code, uint32 &codeSize) {
}
-DataAsset::DataAsset(M4Engine *vm, Common::SeekableReadStream* stream, int size, const char *name) : BaseAsset(vm, stream, size, name) {
+DataAsset::DataAsset(MadsM4Engine *vm, Common::SeekableReadStream* stream, int size, const char *name) : BaseAsset(vm, stream, size, name) {
_recCount = stream->readUint32LE();
_recSize = stream->readUint32LE();
@@ -97,7 +97,7 @@ long *DataAsset::getRow(int index) {
return &_data[_recSize * index];
}
-SpriteAsset::SpriteAsset(M4Engine *vm, Common::SeekableReadStream* stream, int size, const char *name, bool asStream) : BaseAsset(vm, stream, size, name) {
+SpriteAsset::SpriteAsset(MadsM4Engine *vm, Common::SeekableReadStream* stream, int size, const char *name, bool asStream) : BaseAsset(vm, stream, size, name) {
_stream = stream;
if (_vm->isM4()) {
@@ -107,7 +107,7 @@ SpriteAsset::SpriteAsset(M4Engine *vm, Common::SeekableReadStream* stream, int s
}
}
-void SpriteAsset::loadM4SpriteAsset(M4Engine *vm, Common::SeekableReadStream* stream, bool asStream) {
+void SpriteAsset::loadM4SpriteAsset(MadsM4Engine *vm, Common::SeekableReadStream* stream, bool asStream) {
bool isBigEndian = false;
uint32 frameOffset;
@@ -169,7 +169,7 @@ void SpriteAsset::loadM4SpriteAsset(M4Engine *vm, Common::SeekableReadStream* st
}
-void SpriteAsset::loadMadsSpriteAsset(M4Engine *vm, Common::SeekableReadStream* stream) {
+void SpriteAsset::loadMadsSpriteAsset(MadsM4Engine *vm, Common::SeekableReadStream* stream) {
int curFrame = 0;
uint32 frameOffset = 0;
MadsPack sprite(stream);
@@ -335,7 +335,7 @@ int32 SpriteAsset::getFrameSize(int index) {
return _frameOffsets[index + 1] - _frameOffsets[index];
}
-AssetManager::AssetManager(M4Engine *vm) {
+AssetManager::AssetManager(MadsM4Engine *vm) {
_vm = vm;
diff --git a/engines/m4/assets.h b/engines/m4/assets.h
index a1d5d2b0c3..af630514eb 100644
--- a/engines/m4/assets.h
+++ b/engines/m4/assets.h
@@ -44,21 +44,21 @@ namespace M4 {
#define CELS__PAL MKID_BE(' PAL') //' PAL'
#define CELS___SS MKID_BE(' SS') //' SS'
-class M4Engine;
+class MadsM4Engine;
class BaseAsset {
public:
- BaseAsset(M4Engine *vm, Common::SeekableReadStream* stream, int size, const char *name);
+ BaseAsset(MadsM4Engine *vm, Common::SeekableReadStream* stream, int size, const char *name);
~BaseAsset();
const Common::String getName() const { return _name; }
protected:
- M4Engine *_vm;
+ MadsM4Engine *_vm;
Common::String _name;
};
class MachineAsset : public BaseAsset {
public:
- MachineAsset(M4Engine *vm, Common::SeekableReadStream* stream, int size, const char *name);
+ MachineAsset(MadsM4Engine *vm, Common::SeekableReadStream* stream, int size, const char *name);
~MachineAsset();
void getCode(byte *&code, uint32 &codeSize);
uint32 getStateOffset(uint32 state);
@@ -70,7 +70,7 @@ protected:
class SequenceAsset : public BaseAsset {
public:
- SequenceAsset(M4Engine *vm, Common::SeekableReadStream* stream, int size, const char *name);
+ SequenceAsset(MadsM4Engine *vm, Common::SeekableReadStream* stream, int size, const char *name);
~SequenceAsset();
void getCode(byte *&code, uint32 &codeSize);
int localVarCount() const { return _localVarCount; }
@@ -82,7 +82,7 @@ protected:
class DataAsset : public BaseAsset {
public:
- DataAsset(M4Engine *vm, Common::SeekableReadStream* stream, int size, const char *name);
+ DataAsset(MadsM4Engine *vm, Common::SeekableReadStream* stream, int size, const char *name);
~DataAsset();
int getCount() const { return _recCount; }
long *getRow(int index);
@@ -101,10 +101,10 @@ struct SpriteAssetFrame {
class SpriteAsset : public BaseAsset {
public:
- SpriteAsset(M4Engine *vm, Common::SeekableReadStream* stream, int size, const char *name, bool asStream = false);
+ SpriteAsset(MadsM4Engine *vm, Common::SeekableReadStream* stream, int size, const char *name, bool asStream = false);
~SpriteAsset();
- void loadM4SpriteAsset(M4Engine *vm, Common::SeekableReadStream* stream, bool asStream);
- void loadMadsSpriteAsset(M4Engine *vm, Common::SeekableReadStream* stream);
+ void loadM4SpriteAsset(MadsM4Engine *vm, Common::SeekableReadStream* stream, bool asStream);
+ void loadMadsSpriteAsset(MadsM4Engine *vm, Common::SeekableReadStream* stream);
int32 getCount() { return _frameCount; }
int32 getFrameRate() const { return _frameRate; }
int32 getPixelSpeed() const { return _pixelSpeed; }
@@ -149,7 +149,7 @@ enum CallbackHandlers {
class AssetManager {
public:
- AssetManager(M4Engine *vm);
+ AssetManager(MadsM4Engine *vm);
~AssetManager();
bool clearAssets(AssetType assetType, int32 minHash, int32 maxHash);
@@ -168,7 +168,7 @@ public:
protected:
// TODO: Check if we need _vm
- M4Engine *_vm;
+ MadsM4Engine *_vm;
MachineAsset *_MACH[256];
SequenceAsset *_SEQU[256];
diff --git a/engines/m4/compression.cpp b/engines/m4/compression.cpp
index 543fbd1fef..2b3f4e1388 100644
--- a/engines/m4/compression.cpp
+++ b/engines/m4/compression.cpp
@@ -47,7 +47,7 @@ MadsPack::MadsPack(Common::SeekableReadStream *stream) {
initialise(stream);
}
-MadsPack::MadsPack(const char *resourceName, M4Engine* vm) {
+MadsPack::MadsPack(const char *resourceName, MadsM4Engine* vm) {
Common::SeekableReadStream *stream = vm->_resourceManager->get(resourceName);
initialise(stream);
vm->_resourceManager->toss(resourceName);
diff --git a/engines/m4/compression.h b/engines/m4/compression.h
index ddafaa3440..74fed357ff 100644
--- a/engines/m4/compression.h
+++ b/engines/m4/compression.h
@@ -52,7 +52,7 @@ private:
public:
static bool isCompressed(Common::SeekableReadStream *stream);
MadsPack(Common::SeekableReadStream *stream);
- MadsPack(const char *resourceName, M4Engine *vm);
+ MadsPack(const char *resourceName, MadsM4Engine *vm);
~MadsPack();
int getCount() const { return _count; }
diff --git a/engines/m4/console.cpp b/engines/m4/console.cpp
index c8fa316533..b4cdaaf86c 100644
--- a/engines/m4/console.cpp
+++ b/engines/m4/console.cpp
@@ -31,7 +31,7 @@
namespace M4 {
-Console::Console(M4Engine *vm) : GUI::Debugger() {
+Console::Console(MadsM4Engine *vm) : GUI::Debugger() {
_vm = vm;
DCmd_Register("scene", WRAP_METHOD(Console, cmdLoadScene));
@@ -49,8 +49,6 @@ Console::Console(M4Engine *vm) : GUI::Debugger() {
DCmd_Register("textview", WRAP_METHOD(Console, cmdShowTextview));
DCmd_Register("animview", WRAP_METHOD(Console, cmdShowAnimview));
DCmd_Register("anim", WRAP_METHOD(Console, cmdPlayAnimation));
- DCmd_Register("object", WRAP_METHOD(Console, cmdObject));
- DCmd_Register("message", WRAP_METHOD(Console, cmdMessage));
}
Console::~Console() {
@@ -299,10 +297,17 @@ bool Console::cmdPlayAnimation(int argc, const char **argv) {
return true;
}
-bool Console::cmdObject(int argc, const char **argv) {
- if (_vm->isM4()) {
- DebugPrintf("Command not implemented for M4 games\n");
- } else if (argc == 1) {
+/*--------------------------------------------------------------------------*/
+
+MadsConsole::MadsConsole(MadsEngine *vm): Console(vm) {
+ _vm = vm;
+
+ DCmd_Register("object", WRAP_METHOD(MadsConsole, cmdObject));
+ DCmd_Register("message", WRAP_METHOD(MadsConsole, cmdMessage));
+}
+
+bool MadsConsole::cmdObject(int argc, const char **argv) {
+ if (argc == 1) {
DebugPrintf("Usage: object ['list' | '#objnum' | 'add #objnum']\n");
} else if (!strcmp(argv[1], "list")) {
// List of objects
@@ -358,7 +363,7 @@ bool Console::cmdObject(int argc, const char **argv) {
return true;
}
-bool Console::cmdMessage(int argc, const char **argv) {
+bool MadsConsole::cmdMessage(int argc, const char **argv) {
VALIDATE_MADS;
if (argc == 1)
diff --git a/engines/m4/console.h b/engines/m4/console.h
index 4d9d008b2f..5724f8a985 100644
--- a/engines/m4/console.h
+++ b/engines/m4/console.h
@@ -30,14 +30,13 @@
namespace M4 {
-class M4Engine;
-
-class Console : public GUI::Debugger {
-public:
- Console(M4Engine *vm);
- virtual ~Console();
+class MadsM4Engine;
+class MadsEngine;
+class Console: public GUI::Debugger {
private:
+ MadsM4Engine *_vm;
+
bool cmdLoadScene(int argc, const char **argv);
bool cmdStartingScene(int argc, const char **argv);
bool cmdSceneInfo(int argc, const char **argv);
@@ -53,11 +52,27 @@ private:
bool cmdShowTextview(int argc, const char **argv);
bool cmdShowAnimview(int argc, const char **argv);
bool cmdPlayAnimation(int argc, const char **argv);
+
+public:
+ Console(MadsM4Engine *vm);
+ virtual ~Console();
+};
+
+class MadsConsole: public Console {
+private:
+ MadsEngine *_vm;
+
bool cmdObject(int argc, const char **argv);
bool cmdMessage(int argc, const char **argv);
+public:
+ MadsConsole(MadsEngine *vm);
+ virtual ~MadsConsole() {};
+};
-private:
- M4Engine *_vm;
+class M4Console: public Console {
+public:
+ M4Console(MadsM4Engine *vm): Console(vm) {};
+ virtual ~M4Console() {};
};
} // End of namespace M4
diff --git a/engines/m4/converse.cpp b/engines/m4/converse.cpp
index 63c56c09fa..7bdc289742 100644
--- a/engines/m4/converse.cpp
+++ b/engines/m4/converse.cpp
@@ -75,7 +75,7 @@ namespace M4 {
#define CHUNK_WPRL MKID_BE('WPRL') // weighted preply chunk
-ConversationView::ConversationView(M4Engine *vm): View(vm, Common::Rect(0,
+ConversationView::ConversationView(MadsM4Engine *vm): View(vm, Common::Rect(0,
vm->_screen->height() - INTERFACE_HEIGHT, vm->_screen->width(), vm->_screen->height())) {
_screenType = VIEWID_CONVERSATION;
diff --git a/engines/m4/converse.h b/engines/m4/converse.h
index 791497b403..a71de24492 100644
--- a/engines/m4/converse.h
+++ b/engines/m4/converse.h
@@ -137,7 +137,7 @@ typedef Common::HashMap<Common::String,int32,Common::IgnoreCase_Hash,Common::Ign
class ConversationView: public View {
public:
- ConversationView(M4Engine *vm);
+ ConversationView(MadsM4Engine *vm);
~ConversationView();
void setNode(int32 nodeIndex);
@@ -162,7 +162,7 @@ private:
class Converse {
public:
- Converse(M4Engine *vm) : _vm(vm) {}
+ Converse(MadsM4Engine *vm) : _vm(vm) {}
~Converse() {}
void startConversation(const char *convName, bool showConversebox = true, ConverseStyle style = CONVSTYLE_EARTH );
@@ -179,7 +179,7 @@ public:
void play();
*/
private:
- M4Engine *_vm;
+ MadsM4Engine *_vm;
Common::Array<ConvEntry*>_convNodes;
Common::Array<MessageEntry*>_madsMessageList;
Common::Array<char *>_convStrings;
diff --git a/engines/m4/detection.cpp b/engines/m4/detection.cpp
index 9781823136..9493226c1a 100644
--- a/engines/m4/detection.cpp
+++ b/engines/m4/detection.cpp
@@ -39,10 +39,10 @@ struct M4GameDescription {
uint32 features;
};
-int M4Engine::getGameType() const { return _gameDescription->gameType; }
-uint32 M4Engine::getFeatures() const { return _gameDescription->features; }
-Common::Language M4Engine::getLanguage() const { return _gameDescription->desc.language; }
-Common::Platform M4Engine::getPlatform() const { return _gameDescription->desc.platform; }
+int MadsM4Engine::getGameType() const { return _gameDescription->gameType; }
+uint32 MadsM4Engine::getFeatures() const { return _gameDescription->features; }
+Common::Language MadsM4Engine::getLanguage() const { return _gameDescription->desc.language; }
+Common::Platform MadsM4Engine::getPlatform() const { return _gameDescription->desc.platform; }
}
@@ -60,7 +60,7 @@ static const PlainGameDescriptor m4Games[] = {
namespace M4 {
-const char *M4Engine::getGameFile(int fileType) {
+const char *MadsM4Engine::getGameFile(int fileType) {
for (int i = 0; _gameDescription->desc.filesDescriptions[i].fileName; i++) {
if (_gameDescription->desc.filesDescriptions[i].fileType == fileType)
return _gameDescription->desc.filesDescriptions[i].fileName;
@@ -421,7 +421,10 @@ public:
bool M4MetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
const M4::M4GameDescription *gd = (const M4::M4GameDescription *)desc;
if (gd) {
- *engine = new M4::M4Engine(syst, gd);
+ if ((gd->gameType == M4::GType_Burger) || (gd->gameType == M4::GType_Riddle))
+ *engine = new M4::M4Engine(syst, gd);
+ else
+ *engine = new M4::MadsEngine(syst, gd);
}
return gd != 0;
}
diff --git a/engines/m4/dialogs.cpp b/engines/m4/dialogs.cpp
index 5e85c6a8df..0919039fbc 100644
--- a/engines/m4/dialogs.cpp
+++ b/engines/m4/dialogs.cpp
@@ -191,7 +191,7 @@ void Dialog::addBarLine() {
*/
void Dialog::getVocab(int vocabId, char **line) {
assert(vocabId > 0);
- const char *vocabStr = _vm->_globals->getVocab(vocabId);
+ const char *vocabStr = _madsVm->_globals->getVocab(vocabId);
strcpy(*line, vocabStr);
if (_commandCase)
@@ -253,6 +253,16 @@ bool Dialog::handleNounSuffix(char *destP, int nounNum, const char *srcP) {
}
/**
+ * Sets up an area within the dialog for textual input
+ */
+void Dialog::setupInputArea() {
+ _askPosition.x = _lineX + 1;
+ _askPosition.y = _lines.size();
+
+ incLine();
+}
+
+/**
* Checks whether the start of an extracted command matches a specified given command constant
*/
bool Dialog::matchCommand(const char *s1, const char *s2) {
@@ -261,7 +271,7 @@ bool Dialog::matchCommand(const char *s1, const char *s2) {
return result;
}
-Dialog::Dialog(M4Engine *vm, const char *msgData, const char *title): View(vm, Common::Rect(0, 0, 0, 0)) {
+Dialog::Dialog(MadsM4Engine *vm, const char *msgData, const char *title): View(vm, Common::Rect(0, 0, 0, 0)) {
assert(msgData);
_vm->_font->setFont(FONT_INTERFACE_MADS);
@@ -325,23 +335,8 @@ Dialog::Dialog(M4Engine *vm, const char *msgData, const char *title): View(vm, C
cmdFlag = false;
strToUpper(cmdText);
- if (matchCommand(cmdText, "TITLE")) {
- // Title command - specifies the dialog width in number of characters
- skipLine = true;
- crFlag = true;
- underline = true;
-
- int id = atoi(cmdText + 5);
- if (id > 0) {
- // Suffix provided - specifies the dialog width in number of chars
- _widthChars = id * 2;
- _dialogWidth = id * (_vm->_font->getMaxWidth() + DIALOG_SPACING) + 10;
- }
- } else if (matchCommand(cmdText, "SENTENCE")) {
- // Sentence command - loads the title into the line buffer
- strcpy(dialogLine, title);
- strToUpper(dialogLine);
- lineP += strlen(dialogLine) + 1;
+ if (matchCommand(cmdText, "ASK")) {
+ setupInputArea();
} else if (matchCommand(cmdText, "BAR")) {
// Adds a full-width line instead of normal text
@@ -368,10 +363,29 @@ Dialog::Dialog(M4Engine *vm, const char *msgData, const char *title): View(vm, C
// Noun command 2
handleNounSuffix(lineP, 2, cmdText + 5);
+ } else if (matchCommand(cmdText, "SENTENCE")) {
+ // Sentence command - loads the title into the line buffer
+ strcpy(dialogLine, title);
+ strToUpper(dialogLine);
+ lineP += strlen(dialogLine) + 1;
+
} else if (matchCommand(cmdText, "TAB")) {
// Specifies the X offset for the current line
_lines[_lines.size() - 1].xp = atoi(cmdText + 3);
+ } else if (matchCommand(cmdText, "TITLE")) {
+ // Title command - specifies the dialog width in number of characters
+ skipLine = true;
+ crFlag = true;
+ underline = true;
+
+ int id = atoi(cmdText + 5);
+ if (id > 0) {
+ // Suffix provided - specifies the dialog width in number of chars
+ _widthChars = id * 2;
+ _dialogWidth = id * (_vm->_font->getMaxWidth() + DIALOG_SPACING) + 10;
+ }
+
} else if (matchCommand(cmdText, "UNDER")) {
// Underline command
underline = true;
@@ -382,9 +396,6 @@ Dialog::Dialog(M4Engine *vm, const char *msgData, const char *title): View(vm, C
getVocab(verbId, &lineP);
-
- } else if (matchCommand(cmdText, "ASK")) {
- // doAsk();
} else if (matchCommand(cmdText, "INDEX")) {
// Index command
_dialogIndex = atoi(cmdText + 5);
@@ -402,25 +413,15 @@ Dialog::Dialog(M4Engine *vm, const char *msgData, const char *title): View(vm, C
draw();
}
-Dialog::Dialog(M4Engine *vm, int widthChars, const char **descEntries): View(vm, Common::Rect(0, 0, 0, 0)) {
+Dialog::Dialog(MadsM4Engine *vm, int widthChars): View(vm, Common::Rect(0, 0, 0, 0)) {
_vm->_font->setFont(FONT_INTERFACE_MADS);
_widthChars = widthChars * 2;
_dialogWidth = widthChars * (_vm->_font->getMaxWidth() + DIALOG_SPACING) + 10;
_screenType = LAYER_DIALOG;
_lineX = 0;
_widthX = 0;
-
- while (*descEntries != NULL) {
- incLine();
- writeChars(*descEntries);
-
- int lineWidth = _vm->_font->getWidth(*descEntries, DIALOG_SPACING);
- _lines[_lines.size() - 1].xp = (_dialogWidth - 10 - lineWidth) / 2;
- ++descEntries;
- }
-
- _lines[0].underline = true;
- draw();
+ _askPosition.x = 0;
+ _askPosition.y = 0;
}
Dialog::~Dialog() {
@@ -449,9 +450,6 @@ void Dialog::draw() {
_coords.right = dialogX + dlgWidth + 1;
_coords.bottom = dialogY + dlgHeight + 1;
- // Ask position
- //int askY = (_vm->_font->getHeight() + 1) * _askPosition.y + 3;
-
// Set up the dialog
fillRect(Common::Rect(0, 0, width(), height()), 3);
setColour(2);
@@ -476,6 +474,11 @@ void Dialog::draw() {
}
}
+ // If an ask position is set, create the input area frame
+ if (_askPosition.y > 0) {
+
+ }
+
// Handle drawing the text contents
_vm->_font->setColours(7, 7, 7);
setColour(7);
@@ -518,10 +521,42 @@ bool Dialog::onEvent(M4EventType eventType, int32 param1, int x, int y, bool &ca
return true;
}
-void Dialog::display(M4Engine *vm, int widthChars, const char **descEntries) {
- Dialog *dlg = new Dialog(vm, widthChars, descEntries);
+void Dialog::display(MadsM4Engine *vm, int widthChars, const char **descEntries) {
+ Dialog *dlg = new Dialog(vm, widthChars);
+
+ while (*descEntries != NULL) {
+ dlg->incLine();
+ dlg->writeChars(*descEntries);
+
+ int lineWidth = vm->_font->getWidth(*descEntries, DIALOG_SPACING);
+ dlg->_lines[dlg->_lines.size() - 1].xp = (dlg->_dialogWidth - 10 - lineWidth) / 2;
+ ++descEntries;
+ }
+
+ dlg->_lines[0].underline = true;
+
+ dlg->draw();
vm->_viewManager->addView(dlg);
vm->_viewManager->moveToFront(dlg);
}
+void Dialog::getValue(MadsM4Engine *vm, const char *title, const char *text, int numChars, int currentValue) {
+ int titleLen = strlen(title);
+ Dialog *dlg = new Dialog(vm, titleLen + 4);
+
+ dlg->addLine(title, true);
+ dlg->writeChars("\n");
+
+ dlg->writeChars(text);
+ dlg->setupInputArea();
+ dlg->writeChars("\n");
+
+ dlg->draw();
+ vm->_viewManager->addView(dlg);
+ vm->_viewManager->moveToFront(dlg);
+
+ // TODO: How to wait until the dialog is closed
+
+}
+
} // End of namespace M4
diff --git a/engines/m4/dialogs.h b/engines/m4/dialogs.h
index 057164fe62..190a06c267 100644
--- a/engines/m4/dialogs.h
+++ b/engines/m4/dialogs.h
@@ -42,6 +42,8 @@ public:
DialogLine() { data[0] = '\0'; xp = 0; underline = barLine = false; }
};
+typedef void (*GetValueFn)(MadsM4Engine *vm, int result);
+
class Dialog: public View {
private:
Common::Array<DialogLine> _lines;
@@ -63,13 +65,15 @@ private:
void addBarLine();
void getVocab(int vocabId, char **line);
bool handleNounSuffix(char *destP, int nounNum, const char *srcP);
+ void setupInputArea();
void draw();
public:
- Dialog(M4Engine *vm, const char *msgData, const char *title = NULL);
- Dialog(M4Engine *vm, int widthChars, const char **descEntries);
+ Dialog(MadsM4Engine *vm, const char *msgData, const char *title = NULL);
+ Dialog(MadsM4Engine *vm, int widthChars);
virtual ~Dialog();
- static void display(M4Engine *vm, int widthChars, const char **descEntries);
+ static void display(MadsM4Engine *vm, int widthChars, const char **descEntries);
+ static void getValue(MadsM4Engine *vm, const char *title, const char *text, int numChars, int currentValue);
bool onEvent(M4EventType eventType, int32 param1, int x, int y, bool &captureEvents);
};
diff --git a/engines/m4/events.cpp b/engines/m4/events.cpp
index 2c8dd20708..4b14401de4 100644
--- a/engines/m4/events.cpp
+++ b/engines/m4/events.cpp
@@ -44,13 +44,17 @@ bool please_hyperwalk = false;
* Implements an interface to the event system *
*--------------------------------------------------------------------------*/
-Events::Events(M4Engine *vm) : _vm(vm) {
+Events::Events(MadsM4Engine *vm) : _vm(vm) {
_mouseState = MSTATE_NO_EVENT;
quitFlag = false;
_keyCode = 0;
- _console = new Console(_vm);
_mouseButtons = 0;
_ctrlFlag = false;
+
+ if (_vm->isM4())
+ _console = new M4Console(_vm);
+ else
+ _console = new MadsConsole(_madsVm);
}
M4EventType Events::handleEvents() {
@@ -177,7 +181,7 @@ bool Events::kbdCheck(uint32 &keyCode) {
* Implements an interface to the mouse *
*--------------------------------------------------------------------------*/
-Mouse::Mouse(M4Engine *vm) : _vm(vm) {
+Mouse::Mouse(MadsM4Engine *vm) : _vm(vm) {
_locked = false;
_cursorOn = false;
_cursor = NULL;
diff --git a/engines/m4/events.h b/engines/m4/events.h
index b6b05137cb..43b61c8f0d 100644
--- a/engines/m4/events.h
+++ b/engines/m4/events.h
@@ -68,7 +68,7 @@ class SpriteAsset;
class Events {
private:
- M4Engine *_vm;
+ MadsM4Engine *_vm;
Common::Event _event;
M4MouseState _mouseState;
int32 _keyCode;
@@ -77,7 +77,7 @@ private:
bool _ctrlFlag;
public:
bool quitFlag;
- Events(M4Engine *vm);
+ Events(MadsM4Engine *vm);
Common::Event &event() { return _event; }
Common::EventType type() { return _event.type; }
@@ -92,7 +92,7 @@ public:
class Mouse {
private:
- M4Engine *_vm;
+ MadsM4Engine *_vm;
int _currentCursor, _lockedCursor;
bool _locked;
bool _cursorOn;
@@ -105,7 +105,7 @@ private:
bool inHideArea();
friend class Events;
public:
- Mouse(M4Engine *vm);
+ Mouse(MadsM4Engine *vm);
~Mouse();
bool init(const char *seriesName, RGB8 *palette);
diff --git a/engines/m4/font.cpp b/engines/m4/font.cpp
index a6ddeca830..edc904f928 100644
--- a/engines/m4/font.cpp
+++ b/engines/m4/font.cpp
@@ -29,7 +29,7 @@
namespace M4 {
-Font::Font(M4Engine *vm) : _vm(vm) {
+Font::Font(MadsM4Engine *vm) : _vm(vm) {
_sysFont = true;
_filename = NULL;
//TODO: System font
diff --git a/engines/m4/font.h b/engines/m4/font.h
index 5e4f8b8644..d675cb6d47 100644
--- a/engines/m4/font.h
+++ b/engines/m4/font.h
@@ -59,7 +59,7 @@ namespace M4 {
class Font {
public:
- Font(M4Engine *vm);
+ Font(MadsM4Engine *vm);
~Font();
void setFont(const char *filename);
void setColor(uint8 color);
@@ -79,7 +79,7 @@ private:
void setFontM4(const char *filename);
void setFontMads(const char *filename);
- M4Engine *_vm;
+ MadsM4Engine *_vm;
uint8 _maxWidth, _maxHeight;
uint8 *_charWidths;
uint16 *_charOffs;
diff --git a/engines/m4/globals.cpp b/engines/m4/globals.cpp
index 6461025165..d110b67d93 100644
--- a/engines/m4/globals.cpp
+++ b/engines/m4/globals.cpp
@@ -34,7 +34,7 @@
namespace M4 {
-Kernel::Kernel(M4Engine *vm) : _vm(vm) {
+Kernel::Kernel(MadsM4Engine *vm) : _vm(vm) {
daemonTriggerAvailable = true;
firstFadeColorIndex = 0;
paused = false;
@@ -267,10 +267,10 @@ void Kernel::unpauseEngines() {
//--------------------------------------------------------------------------
-Globals::Globals(M4Engine *vm): _vm(vm) {
+MadsGlobals::MadsGlobals(MadsM4Engine *vm): _vm(vm) {
}
-Globals::~Globals() {
+MadsGlobals::~MadsGlobals() {
uint32 i;
for (i = 0; i < _madsVocab.size(); i++)
@@ -284,11 +284,11 @@ Globals::~Globals() {
_madsMessages.clear();
}
-bool Globals::isInterfaceVisible() {
+bool MadsGlobals::isInterfaceVisible() {
return _vm->_interfaceView->isVisible();
}
-void Globals::loadMadsVocab() {
+void MadsGlobals::loadMadsVocab() {
Common::SeekableReadStream *vocabS = _vm->res()->get("vocab.dat");
int curPos = 0;
@@ -311,7 +311,7 @@ void Globals::loadMadsVocab() {
_vm->res()->toss("vocab.dat");
}
-void Globals::loadMadsQuotes() {
+void MadsGlobals::loadMadsQuotes() {
Common::SeekableReadStream *quoteS = _vm->res()->get("quotes.dat");
int curPos = 0;
@@ -334,7 +334,7 @@ void Globals::loadMadsQuotes() {
_vm->res()->toss("quotes.dat");
}
-void Globals::loadMadsMessagesInfo() {
+void MadsGlobals::loadMadsMessagesInfo() {
Common::SeekableReadStream *messageS = _vm->res()->get("messages.dat");
int16 count = messageS->readUint16LE();
@@ -359,7 +359,7 @@ void Globals::loadMadsMessagesInfo() {
_vm->res()->toss("messages.dat");
}
-void Globals::loadMadsObjects() {
+void MadsGlobals::loadMadsObjects() {
Common::SeekableReadStream *objList = _vm->res()->get("objects.dat");
int numObjects = objList->readUint16LE();
@@ -369,7 +369,7 @@ void Globals::loadMadsObjects() {
_vm->res()->toss("objects.dat");
}
-int Globals::messageIndexOf(uint32 messageId) {
+int MadsGlobals::messageIndexOf(uint32 messageId) {
for (uint i = 0; i < _madsMessages.size(); ++i)
{
if (_madsMessages[i]->id == messageId)
@@ -378,7 +378,7 @@ int Globals::messageIndexOf(uint32 messageId) {
return -1;
}
-const char *Globals::loadMessage(uint index) {
+const char *MadsGlobals::loadMessage(uint index) {
if (index > _madsMessages.size() - 1) {
warning("Invalid message index: %i", index);
return NULL;
@@ -404,7 +404,7 @@ const char *Globals::loadMessage(uint index) {
//--------------------------------------------------------------------------
-Player::Player(M4Engine *vm) : _vm(vm) {
+Player::Player(MadsM4Engine *vm) : _vm(vm) {
commandsAllowed = true;
needToWalk = false;
readyToWalk = false;
diff --git a/engines/m4/globals.h b/engines/m4/globals.h
index 5a1d108658..7e78d2d3a3 100644
--- a/engines/m4/globals.h
+++ b/engines/m4/globals.h
@@ -35,7 +35,7 @@
namespace M4 {
-class M4Engine;
+class MadsM4Engine;
class ScriptInterpreter;
class ScriptFunction;
@@ -100,14 +100,14 @@ enum KernelTriggerType {
class Kernel {
private:
- M4Engine *_vm;
+ MadsM4Engine *_vm;
ScriptFunction *_globalDaemonFn, *_globalParserFn;
ScriptFunction *_sectionInitFn, *_sectionDaemonFn, *_sectionParserFn;
ScriptFunction *_roomInitFn, *_roomDaemonFn, *_roomPreParserFn, *_roomParserFn;
void pauseEngines();
void unpauseEngines();
public:
- Kernel(M4Engine *vm);
+ Kernel(MadsM4Engine *vm);
// TODO: Move to some palette/fading class
int fadeUpDuration, firstFadeColorIndex;
@@ -183,7 +183,7 @@ public:
typedef Common::Array<Common::SharedPtr<MadsObject> > MadsObjectArray;
-class Globals {
+class MadsGlobals {
private:
struct MessageItem {
uint32 id;
@@ -192,14 +192,14 @@ private:
uint16 compSize;
};
- M4Engine *_vm;
+ MadsM4Engine *_vm;
Common::Array<char* > _madsVocab;
Common::Array<char* > _madsQuotes;
Common::Array<MessageItem* > _madsMessages;
MadsObjectArray _madsObjects;
public:
- Globals(M4Engine *vm);
- ~Globals();
+ MadsGlobals(MadsM4Engine *vm);
+ ~MadsGlobals();
bool isInterfaceVisible();
// M4 variables
@@ -236,7 +236,7 @@ public:
class Player {
public:
- Player(M4Engine *vm);
+ Player(MadsM4Engine *vm);
void setCommandsAllowed(bool value);
// Variables
@@ -265,7 +265,7 @@ public:
const char *word8, const char *word9, const char *word10);
private:
- M4Engine *_vm;
+ MadsM4Engine *_vm;
};
} // End of namespace M4
diff --git a/engines/m4/graphics.cpp b/engines/m4/graphics.cpp
index b8e0761031..da288cc3bc 100644
--- a/engines/m4/graphics.cpp
+++ b/engines/m4/graphics.cpp
@@ -718,7 +718,7 @@ static void makeTranslationList(RGB8 *palData, byte transList[NUM_GREENS]) {
// Support function for fading in or out
-static void fadeRange(M4Engine *vm, RGB8 *srcPal, RGB8 *destPal, int startIndex, int endIndex,
+static void fadeRange(MadsM4Engine *vm, RGB8 *srcPal, RGB8 *destPal, int startIndex, int endIndex,
int numSteps, uint delayAmount) {
RGB8 tempPal[256];
@@ -746,7 +746,7 @@ static void fadeRange(M4Engine *vm, RGB8 *srcPal, RGB8 *destPal, int startIndex
vm->_palette->setPalette(&destPal[startIndex], startIndex, endIndex - startIndex + 1);
}
-Palette::Palette(M4Engine *vm) : _vm(vm) {
+Palette::Palette(MadsM4Engine *vm) : _vm(vm) {
reset();
_fading_in_progress = false;
Common::set_to(&_usageCount[0], &_usageCount[256], 0);
diff --git a/engines/m4/graphics.h b/engines/m4/graphics.h
index 47253c4ed0..b88e9f3616 100644
--- a/engines/m4/graphics.h
+++ b/engines/m4/graphics.h
@@ -173,7 +173,7 @@ enum FadeType {FT_TO_GREY, FT_TO_COLOR, FT_TO_BLOCK};
class Palette {
private:
- M4Engine *_vm;
+ MadsM4Engine *_vm;
bool _colorsChanged;
bool _fading_in_progress;
byte _originalPalette[256 * 4];
@@ -182,7 +182,7 @@ private:
void reset();
public:
- Palette(M4Engine *vm);
+ Palette(MadsM4Engine *vm);
void setPalette(const byte *colors, uint start, uint num);
void setPalette(const RGB8 *colors, uint start, uint num);
diff --git a/engines/m4/gui.cpp b/engines/m4/gui.cpp
index dc75b94fd7..abdf0c8e53 100644
--- a/engines/m4/gui.cpp
+++ b/engines/m4/gui.cpp
@@ -1191,7 +1191,7 @@ bool GUIButton::onEvent(M4EventType eventType, int32 param, int x, int y, GUIObj
_buttonState = BUTTON_PRESSED;
}
- _vm->_globals->invSuppressClickSound = false;
+ _madsVm->_globals->invSuppressClickSound = false;
} else {
// Button isn't pressed
if (_tracking)
diff --git a/engines/m4/gui.h b/engines/m4/gui.h
index 731824518d..d03c092602 100644
--- a/engines/m4/gui.h
+++ b/engines/m4/gui.h
@@ -212,12 +212,12 @@ enum MenuObjectState {OS_GREYED = 0, OS_NORMAL = 1, OS_MOUSEOVER = 2, OS_PRESSED
class DialogView: public View {
public:
- DialogView(M4Engine *Vm, const Common::Rect &viewBounds, bool transparent = false):
+ DialogView(MadsM4Engine *Vm, const Common::Rect &viewBounds, bool transparent = false):
View(Vm, viewBounds, transparent) {};
- DialogView(M4Engine *Vm, int x = 0, int y = 0, bool transparent = false):
+ DialogView(MadsM4Engine *Vm, int x = 0, int y = 0, bool transparent = false):
View(Vm, x, y, transparent) {};
- M4Engine *vm() { return _vm; }
+ MadsM4Engine *vm() { return _vm; }
virtual SpriteAsset *sprites() = 0;
virtual MenuType getMenuType() = 0;
virtual MenuObject *getItem(int objectId) { return NULL; }
diff --git a/engines/m4/hotspot.cpp b/engines/m4/hotspot.cpp
index 656d2300f4..af5b6b7574 100644
--- a/engines/m4/hotspot.cpp
+++ b/engines/m4/hotspot.cpp
@@ -274,10 +274,10 @@ void HotSpotList::loadHotSpots(Common::SeekableReadStream* hotspotStream, int ho
currentHotSpot->setVerb("");
if (currentHotSpot->getVocabID() > 0)
- currentHotSpot->setVocab(_vm->_globals->getVocab(currentHotSpot->getVocabID()));
+ currentHotSpot->setVocab(_madsVm->_globals->getVocab(currentHotSpot->getVocabID()));
if (currentHotSpot->getVerbID() > 0)
- currentHotSpot->setVerb(_vm->_globals->getVocab(currentHotSpot->getVerbID()));
+ currentHotSpot->setVerb(_madsVm->_globals->getVocab(currentHotSpot->getVerbID()));
}
}
}
diff --git a/engines/m4/m4.cpp b/engines/m4/m4.cpp
index 683aae2f46..090921da83 100644
--- a/engines/m4/m4.cpp
+++ b/engines/m4/m4.cpp
@@ -64,16 +64,18 @@
namespace M4 {
// FIXME: remove global
-M4Engine *_vm;
+MadsM4Engine *_vm;
+MadsEngine *_madsVm;
+M4Engine *_m4Vm;
-void escapeHotkeyHandler(M4Engine *vm, View *view, uint32 key) {
+void escapeHotkeyHandler(MadsM4Engine *vm, View *view, uint32 key) {
// For now, simply exit the game
vm->_events->quitFlag = true;
}
// Temporary hotkey handler for use in testing the TextviewView class
-void textviewHotkeyHandler(M4Engine *vm, View *view, uint32 key) {
+void textviewHotkeyHandler(MadsM4Engine *vm, View *view, uint32 key) {
// Deactivate the scene if it's currently active
View *sceneView = vm->_viewManager->getView(VIEWID_SCENE);
if (sceneView != NULL)
@@ -86,38 +88,40 @@ void textviewHotkeyHandler(M4Engine *vm, View *view, uint32 key) {
textView->setScript("quotes", NULL);
}
-void saveGameHotkeyHandler(M4Engine *vm, View *view, uint32 key) {
+void saveGameHotkeyHandler(MadsM4Engine *vm, View *view, uint32 key) {
// TODO: See CreateF2SaveMenu - save menu should only be activated when
// certain conditions are met, such as player_commands_allowed, and isInterfaceVisible
vm->loadMenu(SAVE_MENU, true);
}
-void loadGameHotkeyHandler(M4Engine *vm, View *view, uint32 key) {
+void loadGameHotkeyHandler(MadsM4Engine *vm, View *view, uint32 key) {
// TODO: See CreateF3LoadMenu - save menu should only be activated when
// certain conditions are met, such as player_commands_allowed, and isInterfaceVisible
vm->loadMenu(LOAD_MENU, true);
}
-void gameMenuHotkeyHandler(M4Engine *vm, View *view, uint32 key) {
+void gameMenuHotkeyHandler(MadsM4Engine *vm, View *view, uint32 key) {
vm->loadMenu(GAME_MENU);
}
-M4Engine::M4Engine(OSystem *syst, const M4GameDescription *gameDesc) :
+MadsM4Engine::MadsM4Engine(OSystem *syst, const M4GameDescription *gameDesc) :
Engine(syst), _gameDescription(gameDesc) {
// FIXME
_vm = this;
+ _madsVm = NULL;
SearchMan.addSubDirectoryMatching(_gameDataDir, "goodstuf");
SearchMan.addSubDirectoryMatching(_gameDataDir, "resource");
Common::addDebugChannel(kDebugScript, "script", "Script debug level");
Common::addDebugChannel(kDebugConversations, "conversations", "Conversations debugging");
+
+ _resourceManager = NULL;
}
-M4Engine::~M4Engine() {
- delete _globals;
+MadsM4Engine::~MadsM4Engine() {
delete _midi;
delete _saveLoad;
delete _kernel;
@@ -138,16 +142,10 @@ M4Engine::~M4Engine() {
delete _random;
delete _animation;
delete _palette;
- delete _resourceManager;
}
-Common::Error M4Engine::run() {
+Common::Error MadsM4Engine::run() {
// Initialize backend
- if (isM4())
- initGraphics(640, 480, true);
- else
- initGraphics(320, 200, false);
-
_screen = new M4Surface(true); // Special form for creating screen reference
MidiDriverType midiDriver = MidiDriver::detectMusicDriver(MDT_MIDI | MDT_ADLIB | MDT_PREFER_MIDI);
@@ -161,11 +159,6 @@ Common::Error M4Engine::run() {
_midi->setGM(true);
_midi->setNativeMT32(native_mt32);
- _globals = new Globals(this);
- if (isM4())
- _resourceManager = new M4ResourceManager(this);
- else
- _resourceManager = new MADSResourceManager(this);
_saveLoad = new SaveLoad(this);
_palette = new Palette(this);
_mouse = new Mouse(this);
@@ -194,13 +187,10 @@ Common::Error M4Engine::run() {
_random = new Common::RandomSource();
g_eventRec.registerRandomSource(*_random, "m4");
- if (isM4())
- return goM4();
- else
- return goMADS();
+ return Common::kNoError;
}
-void M4Engine::eventHandler() {
+void MadsM4Engine::eventHandler() {
M4EventType event;
uint32 keycode = 0;
@@ -213,7 +203,7 @@ void M4Engine::eventHandler() {
_viewManager->handleKeyboardEvents(keycode);
}
-bool M4Engine::delay(int duration, bool keyAborts, bool clickAborts) {
+bool MadsM4Engine::delay(int duration, bool keyAborts, bool clickAborts) {
uint32 endTime = g_system->getMillis() + duration;
M4EventType event;
uint32 keycode = 0;
@@ -234,7 +224,7 @@ bool M4Engine::delay(int duration, bool keyAborts, bool clickAborts) {
return false;
}
-void M4Engine::loadMenu(MenuType menuType, bool loadSaveFromHotkey, bool calledFromMainMenu) {
+void MadsM4Engine::loadMenu(MenuType menuType, bool loadSaveFromHotkey, bool calledFromMainMenu) {
if (isM4() && (menuType != MAIN_MENU)) {
bool menuActive = _viewManager->getView(VIEWID_MENU) != NULL;
@@ -272,87 +262,58 @@ void M4Engine::loadMenu(MenuType menuType, bool loadSaveFromHotkey, bool calledF
_viewManager->moveToFront(view);
}
-Common::Error M4Engine::goMADS() {
- _palette->setMadsSystemPalette();
-
- _mouse->init("cursor.ss", NULL);
- _mouse->setCursorNum(0);
-
- // Load MADS data files
- _globals->loadMadsVocab(); // vocab.dat
- _globals->loadMadsQuotes(); // quotes.dat
- _globals->loadMadsMessagesInfo(); // messages.dat
- _globals->loadMadsObjects();
-
- // Setup globals
- _vm->_globals->easyMouse = true;
- _vm->_globals->invObjectsStill = false;
- _vm->_globals->textWindowStill = false;
- _vm->_globals->storyMode = 0;
-
- // Test code to dump all messages to the console
- //for (int i = 0; i < _globals->getMessagesSize(); i++)
- //printf("%s\n----------\n", _globals->loadMessage(i));
-
- if ((getGameType() == GType_RexNebular) || (getGameType() == GType_DragonSphere)) {
- loadMenu(MAIN_MENU);
+void MadsM4Engine::dumpFile(const char* filename, bool uncompress) {
+ Common::SeekableReadStream *fileS = res()->get(filename);
+ byte buffer[256];
+ FILE *destFile = fopen(filename, "wb");
+ int bytesRead = 0;
+ printf("Dumping %s, size: %i\n", filename, fileS->size());
- } else {
- if (getGameType() == GType_DragonSphere) {
- _scene->loadScene(FIRST_SCENE);
- } else if (getGameType() == GType_Phantom) {
- //_scene->loadScene(FIRST_SCENE);
- _scene->loadScene(106); // a more interesting scene
+ if (!uncompress) {
+ while (!fileS->eos()) {
+ bytesRead = fileS->read(buffer, 256);
+ fwrite(buffer, bytesRead, 1, destFile);
}
-
- _scene->show();
-
- _font->setFont(FONT_MAIN_MADS);
- _font->setColors(2, 1, 3);
- _font->writeString(_scene->getBackgroundSurface(), "Testing the M4/MADS ScummVM engine", 5, 160, 310, 2);
- _font->writeString(_scene->getBackgroundSurface(), "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 5, 180, 310, 2);
-
- if (getGameType() == GType_DragonSphere) {
- //_scene->showMADSV2TextBox("Test", 10, 10, NULL);
+ } else {
+ MadsPack packData(fileS);
+ Common::MemoryReadStream *sourceUnc;
+ for (int i = 0; i < packData.getCount(); i++) {
+ sourceUnc = packData.getItemStream(i);
+ printf("Dumping compressed chunk %i of %i, size is %i\n", i + 1, packData.getCount(), sourceUnc->size());
+ while (!sourceUnc->eos()) {
+ bytesRead = sourceUnc->read(buffer, 256);
+ fwrite(buffer, bytesRead, 1, destFile);
+ }
+ delete sourceUnc;
}
-
- _mouse->cursorOn();
}
- _viewManager->systemHotkeys().add(Common::KEYCODE_ESCAPE, &escapeHotkeyHandler);
- _viewManager->systemHotkeys().add(Common::KEYCODE_KP_MULTIPLY, &textviewHotkeyHandler);
-
- // Load the general game SFX/voices
- if (getGameType() == GType_RexNebular) {
- _sound->loadDSRFile("rex009.dsr");
- } else if (getGameType() == GType_Phantom) {
- _sound->loadDSRFile("phan009.dsr");
- } else if (getGameType() == GType_DragonSphere) {
- _sound->loadDSRFile("drag009.dsr");
- }
-
- uint32 nextFrame = g_system->getMillis();
- while (!_events->quitFlag) {
- eventHandler();
+ fclose(destFile);
+ res()->toss(filename);
+ res()->purge();
+}
- _animation->updateAnim();
+/*--------------------------------------------------------------------------*/
- // Call the updateState method of all views
- _viewManager->updateState();
+M4Engine::M4Engine(OSystem *syst, const M4GameDescription *gameDesc): MadsM4Engine(syst, gameDesc) {
+ // FIXME
+ _m4Vm = this;
+}
- if (g_system->getMillis() >= nextFrame) {
+M4Engine::~M4Engine() {
+ delete _resourceManager;
+}
- _viewManager->refreshAll();
- nextFrame = g_system->getMillis();// + GAME_FRAME_DELAY;
- }
+Common::Error M4Engine::run() {
+ // Set up the graphics mode
+ initGraphics(640, 480, true);
- g_system->delayMillis(10);
- }
+ // Necessary pre-initialisation
+ _resourceManager = new M4ResourceManager(this);
- return Common::kNoError;
-}
+ // Set up needed common functionality
+ MadsM4Engine::run();
-Common::Error M4Engine::goM4() {
_script->open("m4.dat");
@@ -521,35 +482,108 @@ Common::Error M4Engine::goM4() {
return Common::kNoError;
}
-void M4Engine::dumpFile(const char* filename, bool uncompress) {
- Common::SeekableReadStream *fileS = res()->get(filename);
- byte buffer[256];
- FILE *destFile = fopen(filename, "wb");
- int bytesRead = 0;
- printf("Dumping %s, size: %i\n", filename, fileS->size());
+/*--------------------------------------------------------------------------*/
+
+MadsEngine::MadsEngine(OSystem *syst, const M4GameDescription *gameDesc): MadsM4Engine(syst, gameDesc) {
+ // FIXME
+ _madsVm = this;
+
+ _globals = new MadsGlobals(this);
+}
+
+MadsEngine::~MadsEngine() {
+ delete _globals;
+ delete _resourceManager;
+}
+
+Common::Error MadsEngine::run() {
+ // Set up the graphics mode
+ initGraphics(320, 200, false);
+
+ // Necessary pre-initialisation
+ _resourceManager = new MADSResourceManager(this);
+
+ // Set up needed common functionality
+ MadsM4Engine::run();
+
+ _palette->setMadsSystemPalette();
+
+ _mouse->init("cursor.ss", NULL);
+ _mouse->setCursorNum(0);
+
+ // Load MADS data files
+ _globals->loadMadsVocab(); // vocab.dat
+ _globals->loadMadsQuotes(); // quotes.dat
+ _globals->loadMadsMessagesInfo(); // messages.dat
+ _globals->loadMadsObjects();
+
+ // Setup globals
+ _madsVm->_globals->easyMouse = true;
+ _madsVm->_globals->invObjectsStill = false;
+ _madsVm->_globals->textWindowStill = false;
+ _madsVm->_globals->storyMode = 0;
+
+ // Test code to dump all messages to the console
+ //for (int i = 0; i < _globals->getMessagesSize(); i++)
+ //printf("%s\n----------\n", _globals->loadMessage(i));
+
+ if ((getGameType() == GType_RexNebular) || (getGameType() == GType_DragonSphere)) {
+ loadMenu(MAIN_MENU);
- if (!uncompress) {
- while (!fileS->eos()) {
- bytesRead = fileS->read(buffer, 256);
- fwrite(buffer, bytesRead, 1, destFile);
- }
} else {
- MadsPack packData(fileS);
- Common::MemoryReadStream *sourceUnc;
- for (int i = 0; i < packData.getCount(); i++) {
- sourceUnc = packData.getItemStream(i);
- printf("Dumping compressed chunk %i of %i, size is %i\n", i + 1, packData.getCount(), sourceUnc->size());
- while (!sourceUnc->eos()) {
- bytesRead = sourceUnc->read(buffer, 256);
- fwrite(buffer, bytesRead, 1, destFile);
- }
- delete sourceUnc;
+ if (getGameType() == GType_DragonSphere) {
+ _scene->loadScene(FIRST_SCENE);
+ } else if (getGameType() == GType_Phantom) {
+ //_scene->loadScene(FIRST_SCENE);
+ _scene->loadScene(106); // a more interesting scene
+ }
+
+ _scene->show();
+
+ _font->setFont(FONT_MAIN_MADS);
+ _font->setColors(2, 1, 3);
+ _font->writeString(_scene->getBackgroundSurface(), "Testing the M4/MADS ScummVM engine", 5, 160, 310, 2);
+ _font->writeString(_scene->getBackgroundSurface(), "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 5, 180, 310, 2);
+
+ if (getGameType() == GType_DragonSphere) {
+ //_scene->showMADSV2TextBox("Test", 10, 10, NULL);
}
+
+ _mouse->cursorOn();
}
- fclose(destFile);
- res()->toss(filename);
- res()->purge();
+ _viewManager->systemHotkeys().add(Common::KEYCODE_ESCAPE, &escapeHotkeyHandler);
+ _viewManager->systemHotkeys().add(Common::KEYCODE_KP_MULTIPLY, &textviewHotkeyHandler);
+
+ // Load the general game SFX/voices
+ if (getGameType() == GType_RexNebular) {
+ _sound->loadDSRFile("rex009.dsr");
+ } else if (getGameType() == GType_Phantom) {
+ _sound->loadDSRFile("phan009.dsr");
+ } else if (getGameType() == GType_DragonSphere) {
+ _sound->loadDSRFile("drag009.dsr");
+ }
+
+ uint32 nextFrame = g_system->getMillis();
+ while (!_events->quitFlag) {
+ eventHandler();
+
+ _animation->updateAnim();
+
+ // Call the updateState method of all views
+ _viewManager->updateState();
+
+ if (g_system->getMillis() >= nextFrame) {
+
+ _viewManager->refreshAll();
+ nextFrame = g_system->getMillis();// + GAME_FRAME_DELAY;
+ }
+
+ g_system->delayMillis(10);
+ }
+
+ return Common::kNoError;
}
+
} // End of namespace M4
diff --git a/engines/m4/m4.h b/engines/m4/m4.h
index 1709ffeca2..e8a73debe6 100644
--- a/engines/m4/m4.h
+++ b/engines/m4/m4.h
@@ -128,7 +128,7 @@ inline void str_upper(char *s) { while (*s) { *s = toupper(*s); s++; } }
inline long FixedMul(long a, long b) { return (long)(((float)a * (float)b) / 65536.0); }
inline long FixedDiv(long a, long b) { return (long)(((float)a / (float)b) * 65536.0); }
-class M4Engine : public Engine {
+class MadsM4Engine : public Engine {
private:
Common::Error goMADS();
Common::Error goM4();
@@ -142,8 +142,8 @@ protected:
MidiPlayer *_midi;
public:
- M4Engine(OSystem *syst, const M4GameDescription *gameDesc);
- virtual ~M4Engine();
+ MadsM4Engine(OSystem *syst, const M4GameDescription *gameDesc);
+ virtual ~MadsM4Engine();
int getGameType() const;
uint32 getFeatures() const;
@@ -179,7 +179,6 @@ public:
ViewManager *_viewManager;
Palette *_palette;
Kernel *_kernel;
- Globals *_globals;
Player *_player;
Mouse *_mouse;
Events *_events;
@@ -200,8 +199,28 @@ public:
Common::RandomSource *_random;
};
-// FIXME: remove global
-extern M4Engine *_vm;
+class MadsEngine: public MadsM4Engine {
+public:
+ MadsEngine(OSystem *syst, const M4GameDescription *gameDesc);
+ virtual ~MadsEngine();
+
+ virtual Common::Error run();
+
+ MadsGlobals *_globals;
+};
+
+class M4Engine: public MadsM4Engine {
+public:
+ M4Engine(OSystem *syst, const M4GameDescription *gameDesc);
+ virtual ~M4Engine();
+
+ virtual Common::Error run();
+};
+
+// FIXME: remove globals
+extern MadsM4Engine *_vm;
+extern MadsEngine *_madsVm;
+extern M4Engine *_m4Vm;
} // End of namespace M4
diff --git a/engines/m4/m4_menus.cpp b/engines/m4/m4_menus.cpp
index 827d1ac3f8..e48e076066 100644
--- a/engines/m4/m4_menus.cpp
+++ b/engines/m4/m4_menus.cpp
@@ -306,7 +306,7 @@ void OrionCallbacks::saveLoadReturnFn(OrionMenuView *view) {
//--------------------------------------------------------------------------
-OrionMenuView::OrionMenuView(M4Engine *Vm, int x, int y, MenuType menuType, bool calledFromMainMenu,
+OrionMenuView::OrionMenuView(MadsM4Engine *Vm, int x, int y, MenuType menuType, bool calledFromMainMenu,
bool loadSaveFromHotkey): DialogView(Vm, x, y, true) {
_menuType = menuType;
_screenType = VIEWID_MENU;
@@ -512,7 +512,7 @@ M4Surface *OrionMenuView::createThumbnail() {
}
void OrionMenuView::destroyView() {
- M4Engine *engine = _vm;
+ MadsM4Engine *engine = _vm;
bool interfaceVisible = _interfaceWasVisible;
engine->_viewManager->deleteView(this);
diff --git a/engines/m4/m4_menus.h b/engines/m4/m4_menus.h
index 25d5527957..fb237c2a3d 100644
--- a/engines/m4/m4_menus.h
+++ b/engines/m4/m4_menus.h
@@ -59,7 +59,7 @@ private:
M4Surface *createThumbnail();
void destroyView();
public:
- OrionMenuView(M4Engine *vm, int x, int y, MenuType menuType, bool calledFromMainMenu,
+ OrionMenuView(MadsM4Engine *vm, int x, int y, MenuType menuType, bool calledFromMainMenu,
bool loadSaveFromHotkey);
~OrionMenuView();
MenuType getMenuType() { return _menuType; }
diff --git a/engines/m4/m4_views.cpp b/engines/m4/m4_views.cpp
index f089207279..93ff74b879 100644
--- a/engines/m4/m4_views.cpp
+++ b/engines/m4/m4_views.cpp
@@ -31,7 +31,7 @@
namespace M4 {
-GUIInventory::GUIInventory(View *owner, M4Engine *vm, const Common::Rect &bounds, int horizCells,
+GUIInventory::GUIInventory(View *owner, MadsM4Engine *vm, const Common::Rect &bounds, int horizCells,
int vertCells, int cellWidth, int cellHeight, int tag): GUIRect(owner, bounds, tag) {
_vm = vm;
@@ -218,7 +218,7 @@ const char *INTERFACE_SERIES = "999intr";
#define SPR(x) _sprites->getFrame(x)
-GameInterfaceView::GameInterfaceView(M4Engine *vm):
+GameInterfaceView::GameInterfaceView(MadsM4Engine *vm):
View(vm, Common::Rect(0, vm->_screen->height() - INTERFACE_HEIGHT,
vm->_screen->width(), vm->_screen->height())),
_statusText(GUITextField(this, Common::Rect(200, 1, 450, 21))),
diff --git a/engines/m4/m4_views.h b/engines/m4/m4_views.h
index 577d00b0ec..02e34fead0 100644
--- a/engines/m4/m4_views.h
+++ b/engines/m4/m4_views.h
@@ -58,9 +58,9 @@ private:
int _scrollPosition;
int _highlightedIndex;
int _selectedIndex;
- M4Engine *_vm;
+ MadsM4Engine *_vm;
public:
- GUIInventory(View *owner, M4Engine *vm, const Common::Rect &bounds,
+ GUIInventory(View *owner, MadsM4Engine *vm, const Common::Rect &bounds,
int horizCells, int vertCells, int cellWidth, int cellHeight, int tag);
void onRefresh();
@@ -100,7 +100,7 @@ public:
private:
void setHighlightedButton(int index);
public:
- GameInterfaceView(M4Engine *vm);
+ GameInterfaceView(MadsM4Engine *vm);
~GameInterfaceView();
void onRefresh(RectList *rects, M4Surface *destSurface);
diff --git a/engines/m4/mads_anim.cpp b/engines/m4/mads_anim.cpp
index 6984308784..954916700c 100644
--- a/engines/m4/mads_anim.cpp
+++ b/engines/m4/mads_anim.cpp
@@ -34,7 +34,7 @@ namespace M4 {
#define TV_NUM_FADE_STEPS 40
#define TV_FADE_DELAY_MILLI 50
-TextviewView::TextviewView(M4Engine *vm):
+TextviewView::TextviewView(MadsM4Engine *vm):
View(vm, Common::Rect(0, 0, vm->_screen->width(), vm->_screen->height())),
_bgSurface(vm->_screen->width(), MADS_SURFACE_HEIGHT),
_textSurface(vm->_screen->width(), MADS_SURFACE_HEIGHT + vm->_font->getHeight() +
@@ -235,7 +235,7 @@ void TextviewView::updateState() {
void TextviewView::scriptDone() {
TextviewCallback fn = _callback;
- M4Engine *vm = _vm;
+ MadsM4Engine *vm = _vm;
// Remove this view from manager and destroy it
_vm->_viewManager->deleteView(this);
@@ -439,7 +439,7 @@ void TextviewView::processText() {
//--------------------------------------------------------------------------
-AnimviewView::AnimviewView(M4Engine *vm):
+AnimviewView::AnimviewView(MadsM4Engine *vm):
View(vm, Common::Rect(0, 0, vm->_screen->width(), vm->_screen->height())),
_bgSurface(vm->_screen->width(), MADS_SURFACE_HEIGHT) {
@@ -642,7 +642,7 @@ void AnimviewView::readNextCommand() {
void AnimviewView::scriptDone() {
AnimviewCallback fn = _callback;
- M4Engine *vm = _vm;
+ MadsM4Engine *vm = _vm;
// Remove this view from manager and destroy it
_vm->_viewManager->deleteView(this);
@@ -714,7 +714,7 @@ void AnimviewView::processCommand() {
}
}
-AAFile::AAFile(const char *resourceName, M4Engine* vm): MadsPack(resourceName, vm) {
+AAFile::AAFile(const char *resourceName, MadsM4Engine* vm): MadsPack(resourceName, vm) {
Common::MemoryReadStream stream1(*getItemStream(1));
Common::MemoryReadStream stream2(*getItemStream(2));
diff --git a/engines/m4/mads_anim.h b/engines/m4/mads_anim.h
index 825d9b8563..420e0af983 100644
--- a/engines/m4/mads_anim.h
+++ b/engines/m4/mads_anim.h
@@ -44,7 +44,7 @@ enum SceneTransition {
kTransitionCircleIn = 9
};
-typedef void (*TextviewCallback)(M4Engine *vm);
+typedef void (*TextviewCallback)(MadsM4Engine *vm);
class TextviewView: public View {
private:
@@ -74,7 +74,7 @@ private:
void processText();
int getParameter(char **paramP);
public:
- TextviewView(M4Engine *vm);
+ TextviewView(MadsM4Engine *vm);
~TextviewView();
void setScript(const char *resourceName, TextviewCallback callback);
@@ -85,11 +85,11 @@ public:
void updateState();
};
-typedef void (*AnimviewCallback)(M4Engine *vm);
+typedef void (*AnimviewCallback)(MadsM4Engine *vm);
class AAFile: public MadsPack {
public:
- AAFile(const char *resourceName, M4Engine* vm);
+ AAFile(const char *resourceName, MadsM4Engine* vm);
uint16 seriesCount;
uint16 frameCount;
@@ -122,7 +122,7 @@ private:
void readNextCommand();
void processCommand();
public:
- AnimviewView(M4Engine *vm);
+ AnimviewView(MadsM4Engine *vm);
~AnimviewView();
void setScript(const char *resourceName, AnimviewCallback callback);
diff --git a/engines/m4/mads_menus.cpp b/engines/m4/mads_menus.cpp
index 196f7ff7b0..5426edbf21 100644
--- a/engines/m4/mads_menus.cpp
+++ b/engines/m4/mads_menus.cpp
@@ -45,7 +45,7 @@ static Common::Point dragonMenuItemPosList[6] = {
#define DRAGON_MENU_BUTTON_W = 45
#define DRAGON_MENU_BUTTON_H = 11
-RexMainMenuView::RexMainMenuView(M4Engine *vm):
+RexMainMenuView::RexMainMenuView(MadsM4Engine *vm):
View(vm, Common::Rect(0, 0, vm->_screen->width(), vm->_screen->height())) {
_screenType = VIEWID_MAINMENU;
@@ -295,7 +295,7 @@ int RexMainMenuView::getHighlightedItem(int x, int y) {
}
void RexMainMenuView::handleAction(MadsGameAction action) {
- M4Engine *vm = _vm;
+ MadsM4Engine *vm = _vm;
vm->_mouse->cursorOff();
vm->_viewManager->deleteView(this);
@@ -344,7 +344,7 @@ void RexMainMenuView::handleAction(MadsGameAction action) {
//--------------------------------------------------------------------------
-MadsMainMenuView::MadsMainMenuView(M4Engine *vm):
+MadsMainMenuView::MadsMainMenuView(MadsM4Engine *vm):
View(vm, Common::Rect(0, 0, vm->_screen->width(), vm->_screen->height())) {
}
@@ -359,7 +359,7 @@ void MadsMainMenuView::updateState() {
//--------------------------------------------------------------------------
-DragonMainMenuView::DragonMainMenuView(M4Engine *vm):
+DragonMainMenuView::DragonMainMenuView(MadsM4Engine *vm):
View(vm, Common::Rect(0, 0, vm->_screen->width(), vm->_screen->height())) {
_screenType = VIEWID_MAINMENU;
@@ -548,7 +548,7 @@ int DragonMainMenuView::getHighlightedItem(int x, int y) {
}
void DragonMainMenuView::handleAction(MadsGameAction action) {
- M4Engine *vm = _vm;
+ MadsM4Engine *vm = _vm;
vm->_mouse->cursorOff();
vm->_viewManager->deleteView(this);
diff --git a/engines/m4/mads_menus.h b/engines/m4/mads_menus.h
index fade6ad5ab..f259a6a560 100644
--- a/engines/m4/mads_menus.h
+++ b/engines/m4/mads_menus.h
@@ -49,7 +49,7 @@ private:
int getHighlightedItem(int x, int y);
void handleAction(MadsGameAction action);
public:
- RexMainMenuView(M4Engine *vm);
+ RexMainMenuView(MadsM4Engine *vm);
~RexMainMenuView();
bool onEvent(M4EventType eventType, int32 param, int x, int y, bool &captureEvents);
@@ -71,7 +71,7 @@ private:
int getHighlightedItem(int x, int y);
void handleAction(MadsGameAction action);
public:
- DragonMainMenuView(M4Engine *vm);
+ DragonMainMenuView(MadsM4Engine *vm);
~DragonMainMenuView();
bool onEvent(M4EventType eventType, int32 param, int x, int y, bool &captureEvents);
@@ -80,7 +80,7 @@ public:
class MadsMainMenuView: public View {
public:
- MadsMainMenuView(M4Engine *vm);
+ MadsMainMenuView(MadsM4Engine *vm);
bool onEvent(M4EventType eventType, int32 param, int x, int y, bool &captureEvents);
void updateState();
diff --git a/engines/m4/midi.cpp b/engines/m4/midi.cpp
index e54fc19f46..78fe0d6bd6 100644
--- a/engines/m4/midi.cpp
+++ b/engines/m4/midi.cpp
@@ -32,7 +32,7 @@
namespace M4 {
-MidiPlayer::MidiPlayer(M4Engine *vm, MidiDriver *driver) : _vm(vm), _midiData(NULL), _driver(driver), _isPlaying(false), _passThrough(false), _isGM(false) {
+MidiPlayer::MidiPlayer(MadsM4Engine *vm, MidiDriver *driver) : _vm(vm), _midiData(NULL), _driver(driver), _isPlaying(false), _passThrough(false), _isGM(false) {
memset(_channel, 0, sizeof(_channel));
_masterVolume = 0;
_parser = MidiParser::createParser_SMF();
diff --git a/engines/m4/midi.h b/engines/m4/midi.h
index 6f99f1d868..45cf23b58d 100644
--- a/engines/m4/midi.h
+++ b/engines/m4/midi.h
@@ -36,7 +36,7 @@ namespace M4 {
class MidiPlayer : public MidiDriver {
public:
- MidiPlayer(M4Engine *vm, MidiDriver *driver);
+ MidiPlayer(MadsM4Engine *vm, MidiDriver *driver);
~MidiPlayer();
bool isPlaying() { return _isPlaying; }
@@ -69,7 +69,7 @@ public:
protected:
static void onTimer(void *data);
- M4Engine *_vm;
+ MadsM4Engine *_vm;
byte *_midiData;
MidiChannel *_channel[16];
diff --git a/engines/m4/resource.cpp b/engines/m4/resource.cpp
index a7e092f9e2..c8b71dd7ef 100644
--- a/engines/m4/resource.cpp
+++ b/engines/m4/resource.cpp
@@ -409,7 +409,7 @@ bool MADSResourceManager::resourceExists(const char *resourceName) {
//--------------------------------------------------------------------------
-M4ResourceManager::M4ResourceManager(M4Engine *vm): ResourceManager(vm) {
+M4ResourceManager::M4ResourceManager(MadsM4Engine *vm): ResourceManager(vm) {
_hfs = new FileSystem(_vm->getGameFile(kFileTypeHash));
}
diff --git a/engines/m4/resource.h b/engines/m4/resource.h
index dc099f2304..69431558b0 100644
--- a/engines/m4/resource.h
+++ b/engines/m4/resource.h
@@ -90,11 +90,11 @@ protected:
typedef Common::List<Common::SharedPtr<Resource> > ResourceList;
typedef ResourceList::iterator ResourceIterator;
ResourceList _resources;
- M4Engine *_vm;
+ MadsM4Engine *_vm;
virtual Common::SeekableReadStream *loadResource(const char *resourceName, bool loadFlag) = 0;
public:
- ResourceManager(M4Engine *vm): _vm(vm) {};
+ ResourceManager(MadsM4Engine *vm): _vm(vm) {};
virtual ~ResourceManager();
Common::SeekableReadStream *get(const char *resourceName, bool loadFlag = true);
@@ -119,7 +119,7 @@ private:
protected:
Common::SeekableReadStream *loadResource(const char *resourceName, bool loadFlag);
public:
- MADSResourceManager(M4Engine *vm): ResourceManager(vm) {};
+ MADSResourceManager(MadsM4Engine *vm): ResourceManager(vm) {};
bool resourceExists(const char *resourceName);
};
@@ -127,7 +127,7 @@ class M4ResourceManager: public ResourceManager {
protected:
Common::SeekableReadStream *loadResource(const char *resourceName, bool loadFlag);
public:
- M4ResourceManager(M4Engine *vm);
+ M4ResourceManager(MadsM4Engine *vm);
~M4ResourceManager();
bool resourceExists(const char *resourceName);
diff --git a/engines/m4/saveload.cpp b/engines/m4/saveload.cpp
index 9147cd0906..85f0ee9947 100644
--- a/engines/m4/saveload.cpp
+++ b/engines/m4/saveload.cpp
@@ -34,7 +34,7 @@ namespace M4 {
const char *orionSavesList = "saves.dir";
-SaveLoad::SaveLoad(M4Engine *vm) : _vm(vm) {
+SaveLoad::SaveLoad(MadsM4Engine *vm) : _vm(vm) {
// For Orion Burger, check the existance of a 'saves.dir' file to determine whether to
// act exactly like the original. Otherwise, we'll use the ScummVM standard, where we'll
// keep all the data for a savegame in a single file
diff --git a/engines/m4/saveload.h b/engines/m4/saveload.h
index 5218f7db84..132cb93f00 100644
--- a/engines/m4/saveload.h
+++ b/engines/m4/saveload.h
@@ -38,12 +38,12 @@ typedef SaveGameList::iterator SaveGameIterator;
class SaveLoad {
private:
- M4Engine *_vm;
+ MadsM4Engine *_vm;
bool _emulateOriginal;
const char *generateSaveName(int slotNumber);
public:
- SaveLoad(M4Engine *vm);
+ SaveLoad(MadsM4Engine *vm);
bool hasSaves();
SaveGameList *getSaves();
diff --git a/engines/m4/scene.cpp b/engines/m4/scene.cpp
index 7b5080e0bc..0d3e63b781 100644
--- a/engines/m4/scene.cpp
+++ b/engines/m4/scene.cpp
@@ -44,7 +44,7 @@ static const int INVENTORY_Y = 159;
static const int SCROLLER_DELAY = 200;
-Scene::Scene(M4Engine *vm): View(vm, Common::Rect(0, 0, vm->_screen->width(), vm->_screen->height())) {
+Scene::Scene(MadsM4Engine *vm): View(vm, Common::Rect(0, 0, vm->_screen->width(), vm->_screen->height())) {
_screenType = VIEWID_SCENE;
_sceneResources.hotspots = new HotSpotList();
@@ -393,7 +393,7 @@ void Scene::checkHotspotAtMousePosMads(int x, int y) {
if (verbId == kVerbNone)
verbId = kVerbWalkTo;
- sprintf(statusText, "%s %s\n", _vm->_globals->getVocab(verbId), currentHotSpot->getVocab());
+ sprintf(statusText, "%s %s\n", _madsVm->_globals->getVocab(verbId), currentHotSpot->getVocab());
statusText[0] = toupper(statusText[0]); // capitalize first letter
setMADSStatusText(statusText);
@@ -535,7 +535,7 @@ bool Scene::onEvent(M4EventType eventType, int32 param1, int x, int y, bool &cap
if (currentHotSpot->getVerbID() != 0) {
sprintf(statusText, "%s %s\n", currentHotSpot->getVerb(), currentHotSpot->getVocab());
} else {
- sprintf(statusText, "%s %s\n", _vm->_globals->getVocab(kVerbWalkTo), currentHotSpot->getVocab());
+ sprintf(statusText, "%s %s\n", _madsVm->_globals->getVocab(kVerbWalkTo), currentHotSpot->getVocab());
}
statusText[0] = toupper(statusText[0]); // capitalize first letter
@@ -550,8 +550,8 @@ bool Scene::onEvent(M4EventType eventType, int32 param1, int x, int y, bool &cap
_vm->_interfaceView->_inventory.clearSelected();
} else {
// ***DEBUG*** - sample dialog display
- int idx = 3; //_vm->_globals->messageIndexOf(0x277a);
- const char *msg = _vm->_globals->loadMessage(idx);
+ int idx = 3; //_madsVm->_globals->messageIndexOf(0x277a);
+ const char *msg = _madsVm->_globals->loadMessage(idx);
Dialog *dlg = new Dialog(_vm, msg, "TEST DIALOG");
_vm->_viewManager->addView(dlg);
_vm->_viewManager->moveToFront(dlg);
@@ -699,12 +699,12 @@ void Scene::setAction(int action, int objectId) {
// a second object can be selected, as in 'use gun to shoot person', with requires a target
// Set up the new action
- strcpy(statusText, _vm->_globals->getVocab(action));
+ strcpy(statusText, _madsVm->_globals->getVocab(action));
statusText[0] = toupper(statusText[0]); // capitalize first letter
if (objectId != -1) {
- MadsObject *obj = _vm->_globals->getObject(objectId);
- sprintf(statusText + strlen(statusText), " %s", _vm->_globals->getVocab(obj->descId));
+ MadsObject *obj = _madsVm->_globals->getObject(objectId);
+ sprintf(statusText + strlen(statusText), " %s", _madsVm->_globals->getVocab(obj->descId));
} else {
_currentAction = action;
}
@@ -719,7 +719,7 @@ void Scene::setAction(int action, int objectId) {
*--------------------------------------------------------------------------
*/
-MadsInterfaceView::MadsInterfaceView(M4Engine *vm): View(vm, Common::Rect(0, MADS_SURFACE_HEIGHT,
+MadsInterfaceView::MadsInterfaceView(MadsM4Engine *vm): View(vm, Common::Rect(0, MADS_SURFACE_HEIGHT,
vm->_screen->width(), vm->_screen->height())) {
_screenType = VIEWID_INTERFACE;
_highlightedElement = -1;
@@ -772,8 +772,8 @@ void MadsInterfaceView::initialise() {
// Build up the inventory list
_inventoryList.clear();
- for (uint i = 0; i < _vm->_globals->getObjectsSize(); ++i) {
- MadsObject *obj = _vm->_globals->getObject(i);
+ for (uint i = 0; i < _madsVm->_globals->getObjectsSize(); ++i) {
+ MadsObject *obj = _madsVm->_globals->getObject(i);
if (obj->roomNumber == PLAYER_INVENTORY)
_inventoryList.push_back(i);
}
@@ -823,7 +823,7 @@ void MadsInterfaceView::setSelectedObject(int objectNumber) {
void MadsInterfaceView::addObjectToInventory(int objectNumber) {
if (_inventoryList.indexOf(objectNumber) == -1) {
- _vm->_globals->getObject(objectNumber)->roomNumber = PLAYER_INVENTORY;
+ _madsVm->_globals->getObject(objectNumber)->roomNumber = PLAYER_INVENTORY;
_inventoryList.push_back(objectNumber);
}
@@ -847,7 +847,7 @@ void MadsInterfaceView::onRefresh(RectList *rects, M4Surface *destSurface) {
((actionIndex == 0) ? ITEM_SELECTED : ITEM_NORMAL));
// Get the verb action and capitalise it
- const char *verbStr = _vm->_globals->getVocab(kVerbLook + actionIndex);
+ const char *verbStr = _madsVm->_globals->getVocab(kVerbLook + actionIndex);
strcpy(buffer, verbStr);
if ((buffer[0] >= 'a') && (buffer[0] <= 'z')) buffer[0] -= 'a' - 'A';
@@ -875,7 +875,7 @@ void MadsInterfaceView::onRefresh(RectList *rects, M4Surface *destSurface) {
if ((_topIndex + i) >= _inventoryList.size())
break;
- const char *descStr = _vm->_globals->getVocab(_vm->_globals->getObject(
+ const char *descStr = _madsVm->_globals->getVocab(_madsVm->_globals->getObject(
_inventoryList[_topIndex + i])->descId);
strcpy(buffer, descStr);
if ((buffer[0] >= 'a') && (buffer[0] <= 'z')) buffer[0] -= 'a' - 'A';
@@ -898,21 +898,21 @@ void MadsInterfaceView::onRefresh(RectList *rects, M4Surface *destSurface) {
M4Sprite *spr = _objectSprites->getFrame(_objectFrameNumber / INV_ANIM_FRAME_SPEED);
spr->copyTo(destSurface, INVENTORY_X, INVENTORY_Y, 0);
- if (!_vm->_globals->invObjectsStill && !dialogVisible) {
+ if (!_madsVm->_globals->invObjectsStill && !dialogVisible) {
// If objetcs are to animated, move to the next frame
if (++_objectFrameNumber >= (_objectSprites->getCount() * INV_ANIM_FRAME_SPEED))
_objectFrameNumber = 0;
}
// List the vocab actions for the currently selected object
- MadsObject *obj = _vm->_globals->getObject(_selectedObject);
+ MadsObject *obj = _madsVm->_globals->getObject(_selectedObject);
int yIndex = MIN(_highlightedElement - VOCAB_START, obj->vocabCount - 1);
for (int i = 0; i < obj->vocabCount; ++i) {
const Common::Rect r(_screenObjects[VOCAB_START + i]);
// Get the vocab description and capitalise it
- const char *descStr = _vm->_globals->getVocab(obj->vocabList[i].vocabId);
+ const char *descStr = _madsVm->_globals->getVocab(obj->vocabList[i].vocabId);
strcpy(buffer, descStr);
if ((buffer[0] >= 'a') && (buffer[0] <= 'z')) buffer[0] -= 'a' - 'A';
@@ -958,7 +958,7 @@ bool MadsInterfaceView::onEvent(M4EventType eventType, int32 param1, int x, int
_vm->_scene->setAction(kVerbLook + (_highlightedElement - ACTIONS_START));
} else if ((_highlightedElement >= VOCAB_START) && (_highlightedElement < (VOCAB_START + 5))) {
// A vocab action was selected
- MadsObject *obj = _vm->_globals->getObject(_selectedObject);
+ MadsObject *obj = _madsVm->_globals->getObject(_selectedObject);
int vocabIndex = MIN(_highlightedElement - VOCAB_START, obj->vocabCount - 1);
if (vocabIndex >= 0)
_vm->_scene->setAction(obj->vocabList[vocabIndex].vocabId, _selectedObject);
diff --git a/engines/m4/scene.h b/engines/m4/scene.h
index 8896a8f5df..5f1269c973 100644
--- a/engines/m4/scene.h
+++ b/engines/m4/scene.h
@@ -79,7 +79,7 @@ class MadsInterfaceView;
class Scene: public View {
public:
- Scene(M4Engine *vm);
+ Scene(MadsM4Engine *vm);
~Scene();
// TODO: perhaps move playIntro() someplace else?
@@ -162,7 +162,7 @@ private:
bool handleCheatKey(int32 keycode);
bool handleKeypress(int32 keycode);
public:
- MadsInterfaceView(M4Engine *vm);
+ MadsInterfaceView(MadsM4Engine *vm);
~MadsInterfaceView();
void initialise();
diff --git a/engines/m4/script.cpp b/engines/m4/script.cpp
index 6a2841053c..62fade13d3 100644
--- a/engines/m4/script.cpp
+++ b/engines/m4/script.cpp
@@ -217,7 +217,7 @@ uint32 ScriptFunction::readUint32() {
}
-ScriptInterpreter::ScriptInterpreter(M4Engine *vm) : _scriptFile(NULL), _vm(vm) {
+ScriptInterpreter::ScriptInterpreter(MadsM4Engine *vm) : _scriptFile(NULL), _vm(vm) {
initScriptKernel();
_dataCache = new ScriptDataCache(this);
_runningFunction = NULL;
diff --git a/engines/m4/script.h b/engines/m4/script.h
index 2eb608ccbb..1aeebbe57a 100644
--- a/engines/m4/script.h
+++ b/engines/m4/script.h
@@ -276,7 +276,7 @@ enum ScriptKernelVariable {
class ScriptInterpreter {
public:
- ScriptInterpreter(M4Engine *vm);
+ ScriptInterpreter(MadsM4Engine *vm);
~ScriptInterpreter();
/* Opens a M4 program file */
void open(const char *filename);
@@ -322,7 +322,7 @@ public:
protected:
- M4Engine *_vm;
+ MadsM4Engine *_vm;
typedef Common::HashMap<Common::String, uint32, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> FunctionNameMap;
Common::File *_scriptFile;
diff --git a/engines/m4/sound.cpp b/engines/m4/sound.cpp
index 6f83c6b6d5..63956259b3 100644
--- a/engines/m4/sound.cpp
+++ b/engines/m4/sound.cpp
@@ -35,7 +35,7 @@
namespace M4 {
-Sound::Sound(M4Engine *vm, Audio::Mixer *mixer, int volume) :
+Sound::Sound(MadsM4Engine *vm, Audio::Mixer *mixer, int volume) :
_vm(vm), _mixer(mixer) {
for (int i = 0; i < SOUND_HANDLES; i++)
diff --git a/engines/m4/sound.h b/engines/m4/sound.h
index caa5cfcca3..7ae6103d26 100644
--- a/engines/m4/sound.h
+++ b/engines/m4/sound.h
@@ -68,12 +68,12 @@ struct DSRFile {
Common::Array<DSREntry *> dsrEntries;
};
-class M4Engine;
+class MadsM4Engine;
class Sound {
public:
- Sound(M4Engine *vm, Audio::Mixer *mixer, int volume);
+ Sound(MadsM4Engine *vm, Audio::Mixer *mixer, int volume);
~Sound();
void playSound(const char *soundName, int volume, bool loop, int channel = -1);
@@ -99,7 +99,7 @@ public:
private:
- M4Engine *_vm;
+ MadsM4Engine *_vm;
Audio::Mixer *_mixer;
SndHandle _handles[SOUND_HANDLES];
diff --git a/engines/m4/sprite.h b/engines/m4/sprite.h
index fbdd64bd29..1f39cc3c3e 100644
--- a/engines/m4/sprite.h
+++ b/engines/m4/sprite.h
@@ -106,8 +106,8 @@ public:
int xOffset, yOffset;
uint8 encoding;
- M4Sprite(M4Engine *vm): M4Surface() {}
- M4Sprite(M4Engine *vm, int widthVal, int heightVal): M4Surface(widthVal, heightVal), xOffset(0), yOffset(0) {}
+ M4Sprite(MadsM4Engine *vm): M4Surface() {}
+ M4Sprite(MadsM4Engine *vm, int widthVal, int heightVal): M4Surface(widthVal, heightVal), xOffset(0), yOffset(0) {}
// Loads a sprite from the given stream, and optionally decompresses the RLE-encoded data
M4Sprite(Common::SeekableReadStream* source, int xOfs, int yOfs, int widthVal, int heightVal, bool decodeRle = true, uint8 encodingVal = 0);
// Loads an RLE compressed sprite; the surface must have been created before
diff --git a/engines/m4/viewmgr.cpp b/engines/m4/viewmgr.cpp
index a259939617..1b70f8db21 100644
--- a/engines/m4/viewmgr.cpp
+++ b/engines/m4/viewmgr.cpp
@@ -31,7 +31,7 @@
namespace M4 {
-void returnToMainMenuFn(M4Engine *vm) {
+void returnToMainMenuFn(MadsM4Engine *vm) {
vm->_palette->resetColorCounts();
vm->_palette->setMadsSystemPalette();
@@ -105,14 +105,14 @@ bool HotkeyList::call(uint32 key) {
// View constructor
-View::View(M4Engine *vm, const Common::Rect &viewBounds, bool transparent)
+View::View(MadsM4Engine *vm, const Common::Rect &viewBounds, bool transparent)
: M4Surface(viewBounds.width(), viewBounds.height()), _hotkeys(this), _vm(vm) {
SCREEN_FLAGS_DEFAULT;
_coords = viewBounds;
_transparent = transparent;
}
-View::View(M4Engine *vm, int x, int y, bool transparent)
+View::View(MadsM4Engine *vm, int x, int y, bool transparent)
: M4Surface(), _hotkeys(this), _vm(vm) {
SCREEN_FLAGS_DEFAULT;
_coords.left = x;
@@ -194,7 +194,7 @@ void View::onRefresh(RectList *rects, M4Surface *destSurface) {
//--------------------------------------------------------------------------
-ViewManager::ViewManager(M4Engine *vm): _systemHotkeys(HotkeyList(NULL)), _vm(vm) {
+ViewManager::ViewManager(MadsM4Engine *vm): _systemHotkeys(HotkeyList(NULL)), _vm(vm) {
_captureScreen = NULL;
_captureEvents = false;
}
diff --git a/engines/m4/viewmgr.h b/engines/m4/viewmgr.h
index 0da41f1b5e..966b29084d 100644
--- a/engines/m4/viewmgr.h
+++ b/engines/m4/viewmgr.h
@@ -89,7 +89,7 @@ public:
struct Hotkey {
public:
- typedef void (*Callback)(M4Engine *vm, View *view, uint32 key);
+ typedef void (*Callback)(MadsM4Engine *vm, View *view, uint32 key);
Hotkey(uint32 keyVal, Hotkey::Callback callbackFn) : key(keyVal), callback(callbackFn) {};
uint32 key;
Hotkey::Callback callback;
@@ -109,8 +109,8 @@ private:
class View: public M4Surface {
public:
- View(M4Engine *vm, const Common::Rect &viewBounds, bool transparent = false);
- View(M4Engine *vm, int x = 0, int y = 0, bool transparent = false);
+ View(MadsM4Engine *vm, const Common::Rect &viewBounds, bool transparent = false);
+ View(MadsM4Engine *vm, int x = 0, int y = 0, bool transparent = false);
virtual ~View() {}
void getCoordinates(Common::Rect &rect);
@@ -139,7 +139,7 @@ public:
virtual void updateState() {};
protected:
- M4Engine *_vm;
+ MadsM4Engine *_vm;
Common::Rect _coords;
HotkeyList _hotkeys;
int _screenType;
@@ -149,7 +149,7 @@ protected:
class ViewManager {
private:
- M4Engine *_vm;
+ MadsM4Engine *_vm;
HotkeyList _systemHotkeys;
Common::List<View *> _views;
View *_captureScreen;
@@ -157,7 +157,7 @@ private:
public:
typedef Common::List<View *>::iterator ListIterator;
- ViewManager(M4Engine *vm);
+ ViewManager(MadsM4Engine *vm);
~ViewManager();
void addView(View *view);
diff --git a/engines/m4/woodscript.cpp b/engines/m4/woodscript.cpp
index 1bbc780a89..3ce0fa0f2f 100644
--- a/engines/m4/woodscript.cpp
+++ b/engines/m4/woodscript.cpp
@@ -153,7 +153,7 @@ bool Bytecode::decodeArgument(int32 format, int32 data, long *&arg, long &value)
return true;
}
-WoodScript::WoodScript(M4Engine *vm) {
+WoodScript::WoodScript(MadsM4Engine *vm) {
_vm = vm;
_machineId = 0;
_assets = new AssetManager(vm);
diff --git a/engines/m4/woodscript.h b/engines/m4/woodscript.h
index 4a135e29ad..1a238ce0e9 100644
--- a/engines/m4/woodscript.h
+++ b/engines/m4/woodscript.h
@@ -43,7 +43,7 @@
namespace M4 {
-class M4Engine;
+class MadsM4Engine;
class WoodScript;
class Machine;
class Sequence;
@@ -278,7 +278,7 @@ protected:
class WoodScript {
public:
- WoodScript(M4Engine *vm);
+ WoodScript(MadsM4Engine *vm);
~WoodScript();
Machine *createMachine(int32 machineHash, Sequence *parentSeq, int32 dataHash, int32 dataRowIndex, int callbackHandler, const char *machineName);
@@ -323,7 +323,7 @@ public:
byte *getInverseColorTable() const { return _inverseColorTable; }
protected:
- M4Engine *_vm;
+ MadsM4Engine *_vm;
AssetManager *_assets;
Common::Array<Sequence*> _sequences, _layers;