aboutsummaryrefslogtreecommitdiff
path: root/engines/m4
diff options
context:
space:
mode:
authorPaul Gilbert2010-03-14 05:39:47 +0000
committerPaul Gilbert2010-03-14 05:39:47 +0000
commit77c821249e706875c45689ea8361773955cbd532 (patch)
treea3282deec3881470b39f546532c8e9da699fa594 /engines/m4
parentf4bf67cd217bec611cfa39b4d3c557a2413c2f15 (diff)
downloadscummvm-rg350-77c821249e706875c45689ea8361773955cbd532.tar.gz
scummvm-rg350-77c821249e706875c45689ea8361773955cbd532.tar.bz2
scummvm-rg350-77c821249e706875c45689ea8361773955cbd532.zip
Further work on separating M4 specific scene code into the m4_scene.cpp file
svn-id: r48256
Diffstat (limited to 'engines/m4')
-rw-r--r--engines/m4/actor.cpp2
-rw-r--r--engines/m4/graphics.cpp2
-rw-r--r--engines/m4/graphics.h2
-rw-r--r--engines/m4/hotspot.h1
-rw-r--r--engines/m4/m4.cpp2
-rw-r--r--engines/m4/m4_scene.cpp67
-rw-r--r--engines/m4/m4_scene.h6
-rw-r--r--engines/m4/mads_scene.cpp31
-rw-r--r--engines/m4/mads_scene.h1
-rw-r--r--engines/m4/scene.cpp87
-rw-r--r--engines/m4/scene.h5
-rw-r--r--engines/m4/woodscript.h6
-rw-r--r--engines/m4/ws_sequence.cpp2
13 files changed, 103 insertions, 111 deletions
diff --git a/engines/m4/actor.cpp b/engines/m4/actor.cpp
index 102001713f..f342ca6b46 100644
--- a/engines/m4/actor.cpp
+++ b/engines/m4/actor.cpp
@@ -59,7 +59,7 @@ void Actor::placeWalkerSpriteAt(int spriteNum, int x, int y) {
info.height = info.sprite->height();
info.scaleX = info.scaleY = _scaling;
info.palette = _walkerSprites[_direction]->getPalette();
- info.inverseColorTable = _vm->_scene->getInverseColorTable();
+ info.inverseColourTable = _m4Vm->scene()->getInverseColourTable();
_vm->_scene->drawSprite(x, y, info, Common::Rect(640, 400));
}
diff --git a/engines/m4/graphics.cpp b/engines/m4/graphics.cpp
index 9e663fcb05..09072036fd 100644
--- a/engines/m4/graphics.cpp
+++ b/engines/m4/graphics.cpp
@@ -282,7 +282,7 @@ void M4Surface::drawSprite(int x, int y, SpriteInfo &info, const Common::Rect &c
r = CLIP((info.palette[destPixel].r * pixel) >> 10, 0, 31);
g = CLIP((info.palette[destPixel].g * pixel) >> 10, 0, 31);
b = CLIP((info.palette[destPixel].b * pixel) >> 10, 0, 31);
- pixel = info.inverseColorTable[(b << 10) | (g << 5) | r];
+ pixel = info.inverseColourTable[(b << 10) | (g << 5) | r];
}
}
diff --git a/engines/m4/graphics.h b/engines/m4/graphics.h
index e286c6ae55..14c27c5f2d 100644
--- a/engines/m4/graphics.h
+++ b/engines/m4/graphics.h
@@ -81,7 +81,7 @@ struct SpriteInfo {
int width, height;
int scaleX, scaleY;
uint8 encoding;
- byte *inverseColorTable;
+ byte *inverseColourTable;
RGB8 *palette;
};
diff --git a/engines/m4/hotspot.h b/engines/m4/hotspot.h
index 6ef9d9916f..bd1bc480a7 100644
--- a/engines/m4/hotspot.h
+++ b/engines/m4/hotspot.h
@@ -96,6 +96,7 @@ public:
int add(HotSpot *hotspot, bool head = false);
HotSpot *get(int index) { return _hotspots[index]; }
+ HotSpot &operator[](int idx) { return *get(idx); }
void remove(HotSpot *hotspot);
void unlinkItem(HotSpot *hotspot);
void clear();
diff --git a/engines/m4/m4.cpp b/engines/m4/m4.cpp
index 5ce21b4a57..48a0cb7116 100644
--- a/engines/m4/m4.cpp
+++ b/engines/m4/m4.cpp
@@ -412,7 +412,7 @@ Common::Error M4Engine::run() {
_scene->loadScene(_kernel->currentRoom);
_ws->setBackgroundSurface(_scene->getBackgroundSurface());
- _ws->setInverseColorTable(_scene->getInverseColorTable());
+ _ws->setInverseColourTable(scene()->getInverseColourTable());
_kernel->loadSectionScriptFunctions();
_kernel->loadRoomScriptFunctions();
diff --git a/engines/m4/m4_scene.cpp b/engines/m4/m4_scene.cpp
index 8677a344b5..912ec45ceb 100644
--- a/engines/m4/m4_scene.cpp
+++ b/engines/m4/m4_scene.cpp
@@ -42,6 +42,7 @@ M4Scene::M4Scene(M4Engine *vm): _sceneResources(), Scene(vm, &_sceneResources) {
_vm = vm;
_sceneSprites = NULL;
_interfaceSurface = new M4InterfaceView(vm);
+ _inverseColourTable = NULL;
}
M4Scene::~M4Scene() {
@@ -59,6 +60,63 @@ void M4Scene::loadSceneSprites(int sceneNumber) {
printf("Scene has %d sprites, each one having %d colors\n", _sceneSprites->getCount(), _sceneSprites->getColorCount());
}
+void M4Scene::loadSceneResources(int sceneNumber) {
+ char filename[kM4MaxFilenameSize];
+ int i = 0, x = 0, y = 0;
+ sprintf(filename, "%i.chk", sceneNumber);
+
+ Common::SeekableReadStream *sceneS = _vm->res()->get(filename);
+
+ if (sceneS != NULL) {
+ sceneS->read(_sceneResources.artBase, MAX_CHK_FILENAME_SIZE);
+ sceneS->read(_sceneResources.pictureBase, MAX_CHK_FILENAME_SIZE);
+ _sceneResources.hotspotCount = sceneS->readUint32LE();
+ _sceneResources.parallaxCount = sceneS->readUint32LE();
+ _sceneResources.propsCount = sceneS->readUint32LE();
+ _sceneResources.frontY = sceneS->readUint32LE();
+ _sceneResources.backY = sceneS->readUint32LE();
+ _sceneResources.frontScale = sceneS->readUint32LE();
+ _sceneResources.backScale = sceneS->readUint32LE();
+ for (i = 0; i < 16; i++)
+ _sceneResources.depthTable[i] = sceneS->readUint16LE();
+ _sceneResources.railNodeCount = sceneS->readUint32LE();
+
+ // Clear rails from previous scene
+ _vm->_rails->clearRails();
+
+ for (i = 0; i < _sceneResources.railNodeCount; i++) {
+ x = sceneS->readUint32LE();
+ y = sceneS->readUint32LE();
+ if (_vm->_rails->addRailNode(x, y, true) < 0) {
+ warning("Too many rail nodes defined for scene");
+ }
+ }
+
+ // Clear current hotspot lists
+ _sceneResources.hotspots->clear();
+ _sceneResources.parallax->clear();
+ _sceneResources.props->clear();
+
+ _sceneResources.hotspots->loadHotSpots(sceneS, _sceneResources.hotspotCount);
+ _sceneResources.parallax->loadHotSpots(sceneS, _sceneResources.parallaxCount);
+ _sceneResources.props->loadHotSpots(sceneS, _sceneResources.propsCount);
+
+ // Note that toss() deletes the MemoryReadStream
+ _vm->res()->toss(filename);
+ }
+}
+
+void M4Scene::loadSceneInverseColourTable(int sceneNumber) {
+ char filename[kM4MaxFilenameSize];
+ Common::SeekableReadStream *iplS;
+
+ sprintf(filename, "%i.ipl", sceneNumber);
+ iplS = _vm->res()->openFile(filename);
+ delete[] _inverseColourTable;
+ _inverseColourTable = new byte[iplS->size()];
+ iplS->read(_inverseColourTable, iplS->size());
+ _vm->res()->toss(filename);
+}
void M4Scene::loadScene(int sceneNumber) {
Scene::loadScene(sceneNumber);
@@ -71,7 +129,6 @@ void M4Scene::loadScene(int sceneNumber) {
// Load scene def file (*.CHK)
loadSceneResources(sceneNumber);
- loadSceneInverseColorTable(sceneNumber);
// TODO: set walker scaling
// TODO: destroy woodscript buffer
@@ -80,7 +137,7 @@ void M4Scene::loadScene(int sceneNumber) {
loadSceneCodes(sceneNumber);
// Load inverse color table file (*.IPL)
- loadSceneInverseColorTable(sceneNumber);
+ loadSceneInverseColourTable(sceneNumber);
if (_vm->getGameType() != GType_Burger) {
// Load scene sprites file (*.SSB)
@@ -115,6 +172,12 @@ void M4Scene::show() {
_vm->_viewManager->addView(_interfaceSurface);
}
+void M4Scene::leaveScene() {
+ delete[] _inverseColourTable;
+
+ Scene::leaveScene();
+}
+
void M4Scene::checkHotspotAtMousePos(int x, int y) {
if (_vm->getGameType() == GType_Riddle)
return;
diff --git a/engines/m4/m4_scene.h b/engines/m4/m4_scene.h
index 8d55c3434c..c90bdbfeaa 100644
--- a/engines/m4/m4_scene.h
+++ b/engines/m4/m4_scene.h
@@ -50,8 +50,11 @@ private:
M4SceneResources _sceneResources;
SpriteAsset *_sceneSprites;
SpriteAsset *_walkerSprite;
+ byte *_inverseColourTable;
void loadSceneSprites(int sceneNumber);
+ void loadSceneResources(int sceneNumber);
+ void loadSceneInverseColourTable(int sceneNumber);
void nextCommonCursor();
public:
M4Scene(M4Engine *vm);
@@ -59,7 +62,7 @@ public:
// Methods that differ between engines
virtual void loadScene(int sceneNumber);
- virtual void leaveScene() {};
+ virtual void leaveScene();
virtual void loadSceneCodes(int sceneNumber, int index = 0);
virtual void show();
virtual void checkHotspotAtMousePos(int x, int y);
@@ -69,6 +72,7 @@ public:
virtual void setStatusText(const char *text);
virtual void update();
+ byte *getInverseColourTable() const { return _inverseColourTable; }
M4InterfaceView *getInterface() { return (M4InterfaceView *)_interfaceSurface; };
M4SceneResources &getSceneResources() { return _sceneResources; };
};
diff --git a/engines/m4/mads_scene.cpp b/engines/m4/mads_scene.cpp
index 284808af83..94ae83366b 100644
--- a/engines/m4/mads_scene.cpp
+++ b/engines/m4/mads_scene.cpp
@@ -93,13 +93,7 @@ void MadsScene::loadSceneTemporary() {
if (_currentScene >= 900)
return;
- loadSceneHotSpotsMads(_currentScene);
-
- // TODO: set walker scaling
- // TODO: destroy woodscript buffer
-
- // Load inverse color table file (*.IPL)
- loadSceneInverseColorTable(_currentScene);
+ loadSceneHotspots(_currentScene);
}
void MadsScene::loadScene(int sceneNumber) {
@@ -132,6 +126,27 @@ void MadsScene::loadScene(int sceneNumber) {
_vm->res()->purge();
}
+void MadsScene::loadSceneHotspots(int sceneNumber) {
+ char filename[kM4MaxFilenameSize];
+ sprintf(filename, "rm%i.hh", sceneNumber);
+ MadsPack hotSpotData(filename, _vm);
+ Common::SeekableReadStream *hotspotStream = hotSpotData.getItemStream(0);
+
+ int hotspotCount = hotspotStream->readUint16LE();
+ delete hotspotStream;
+
+ _sceneResources.hotspotCount = hotspotCount;
+
+ hotspotStream = hotSpotData.getItemStream(1);
+
+ // Clear current hotspot lists
+ _sceneResources.hotspots->clear();
+
+ _sceneResources.hotspots->loadHotSpots(hotspotStream, _sceneResources.hotspotCount);
+
+ delete hotspotStream;
+}
+
void MadsScene::leaveScene() {
_sceneResources.hotspots->clear();
_sceneResources.parallax->clear();
@@ -453,7 +468,7 @@ void MadsAction::set() {
if (_currentHotspot < hotspotCount) {
// Get the verb Id from the hotspot
- verbId = 0;//selected hotspot
+ verbId = (*_madsVm->scene()->getSceneResources().hotspots)[_currentHotspot].getVerbID();
} else {
// Get the verb Id from the scene object
verbId = 0;//Scene_object[_currentHotspot - _hotspotCount].verbId;
diff --git a/engines/m4/mads_scene.h b/engines/m4/mads_scene.h
index 767bfd1d95..e8b30b32ff 100644
--- a/engines/m4/mads_scene.h
+++ b/engines/m4/mads_scene.h
@@ -168,6 +168,7 @@ private:
void drawElements();
void loadScene2(const char *aaName);
void loadSceneTemporary();
+ void loadSceneHotspots(int sceneNumber);
void clearAction();
void appendActionVocab(int vocabId, bool capitalise);
void setAction();
diff --git a/engines/m4/scene.cpp b/engines/m4/scene.cpp
index af3a78f7c9..da0f0e42aa 100644
--- a/engines/m4/scene.cpp
+++ b/engines/m4/scene.cpp
@@ -51,7 +51,6 @@ Scene::Scene(MadsM4Engine *vm, SceneResources *res): View(vm, Common::Rect(0, 0,
_palData = NULL;
_interfacePal = NULL;
_interfaceSurface = NULL;
- _inverseColorTable = NULL;
_vm->_rails->setCodeSurface(_walkSurface);
}
@@ -78,7 +77,6 @@ void Scene::loadScene(int sceneNumber) {
void Scene::leaveScene() {
delete _palData;
delete _interfacePal;
- delete[] _inverseColorTable;
}
void Scene::show() {
@@ -93,91 +91,6 @@ void Scene::hideInterface() {
_vm->_viewManager->deleteView(_interfaceSurface);
}
-void Scene::loadSceneResources(int sceneNumber) {
- char filename[kM4MaxFilenameSize];
- int i = 0, x = 0, y = 0;
- sprintf(filename, "%i.chk", sceneNumber);
-
- Common::SeekableReadStream *sceneS = _vm->res()->get(filename);
-
- if (sceneS != NULL) {
- sceneS->read(_sceneResources->artBase, MAX_CHK_FILENAME_SIZE);
- sceneS->read(_sceneResources->pictureBase, MAX_CHK_FILENAME_SIZE);
- _sceneResources->hotspotCount = sceneS->readUint32LE();
- _sceneResources->parallaxCount = sceneS->readUint32LE();
- _sceneResources->propsCount = sceneS->readUint32LE();
- _sceneResources->frontY = sceneS->readUint32LE();
- _sceneResources->backY = sceneS->readUint32LE();
- _sceneResources->frontScale = sceneS->readUint32LE();
- _sceneResources->backScale = sceneS->readUint32LE();
- for (i = 0; i < 16; i++)
- _sceneResources->depthTable[i] = sceneS->readUint16LE();
- _sceneResources->railNodeCount = sceneS->readUint32LE();
-
- // Clear rails from previous scene
- _vm->_rails->clearRails();
-
- for (i = 0; i < _sceneResources->railNodeCount; i++) {
- x = sceneS->readUint32LE();
- y = sceneS->readUint32LE();
- if (_vm->_rails->addRailNode(x, y, true) < 0) {
- warning("Too many rail nodes defined for scene");
- }
- }
-
- // Clear current hotspot lists
- _sceneResources->hotspots->clear();
- _sceneResources->parallax->clear();
- _sceneResources->props->clear();
-
- _sceneResources->hotspots->loadHotSpots(sceneS, _sceneResources->hotspotCount);
- _sceneResources->parallax->loadHotSpots(sceneS, _sceneResources->parallaxCount);
- _sceneResources->props->loadHotSpots(sceneS, _sceneResources->propsCount);
-
- // Note that toss() deletes the MemoryReadStream
- _vm->res()->toss(filename);
- }
-}
-
-void Scene::loadSceneHotSpotsMads(int sceneNumber) {
- char filename[kM4MaxFilenameSize];
- sprintf(filename, "rm%i.hh", sceneNumber);
- MadsPack hotSpotData(filename, _vm);
- Common::SeekableReadStream *hotspotStream = hotSpotData.getItemStream(0);
-
- int hotspotCount = hotspotStream->readUint16LE();
- delete hotspotStream;
-
- _sceneResources->hotspotCount = hotspotCount;
-
- hotspotStream = hotSpotData.getItemStream(1);
-
- // Clear current hotspot lists
- _sceneResources->hotspots->clear();
-
- _sceneResources->hotspots->loadHotSpots(hotspotStream, _sceneResources->hotspotCount);
-
- delete hotspotStream;
-}
-
-void Scene::loadSceneInverseColorTable(int sceneNumber) {
- char filename[kM4MaxFilenameSize];
- Common::SeekableReadStream *iplS;
-
- if (_vm->isM4()) {
- sprintf(filename, "%i.ipl", sceneNumber);
- iplS = _vm->res()->openFile(filename);
- delete[] _inverseColorTable;
- _inverseColorTable = new byte[iplS->size()];
- iplS->read(_inverseColorTable, iplS->size());
- _vm->res()->toss(filename);
- } else {
- // TODO?
- return;
- }
-
-}
-
void Scene::loadSceneSpriteCodes(int sceneNumber) {
char filename[kM4MaxFilenameSize];
sprintf(filename, "%i.ssc", sceneNumber);
diff --git a/engines/m4/scene.h b/engines/m4/scene.h
index 59b822be12..d8349b541e 100644
--- a/engines/m4/scene.h
+++ b/engines/m4/scene.h
@@ -80,7 +80,6 @@ class InterfaceView;
class Scene : public View {
private:
- byte *_inverseColorTable;
HotSpotList _sceneHotspots;
protected:
int _currentScene;
@@ -109,16 +108,12 @@ public:
// TODO: perhaps move playIntro() someplace else?
void playIntro();
- void loadSceneResources(int sceneNumber);
- void loadSceneHotSpotsMads(int sceneNumber);
- void loadSceneInverseColorTable(int sceneNumber);
void loadSceneSpriteCodes(int sceneNumber);
void showSprites();
void showHotSpots();
void showCodes();
int getCurrentScene() { return _currentScene; }
M4Surface *getBackgroundSurface() const { return _backgroundSurface; }
- byte *getInverseColorTable() const { return _inverseColorTable; }
void showInterface();
void hideInterface();
void showMADSV2TextBox(char *text, int x, int y, char *faceName);
diff --git a/engines/m4/woodscript.h b/engines/m4/woodscript.h
index 1a238ce0e9..0f72935f8d 100644
--- a/engines/m4/woodscript.h
+++ b/engines/m4/woodscript.h
@@ -319,8 +319,8 @@ public:
RGB8 *getMainPalette() const;
- void setInverseColorTable(byte *inverseColorTable) { _inverseColorTable = inverseColorTable; }
- byte *getInverseColorTable() const { return _inverseColorTable; }
+ void setInverseColourTable(byte *inverseColourTable) { _inverseColourTable = inverseColourTable; }
+ byte *getInverseColourTable() const { return _inverseColourTable; }
protected:
MadsM4Engine *_vm;
@@ -338,7 +338,7 @@ protected:
/* Misc */
int16 *_depthTable;
- byte *_inverseColorTable;
+ byte *_inverseColourTable;
M4Surface *_backgroundSurface;
View *_surfaceView;
diff --git a/engines/m4/ws_sequence.cpp b/engines/m4/ws_sequence.cpp
index 0cbb94e307..1f3c977609 100644
--- a/engines/m4/ws_sequence.cpp
+++ b/engines/m4/ws_sequence.cpp
@@ -289,7 +289,7 @@ void Sequence::draw(M4Surface *surface, const Common::Rect &clipRect, Common::Re
info.hotX = _curFrame->xOffset;
info.hotY = _curFrame->yOffset;
info.encoding = _curFrame->encoding;
- info.inverseColorTable = _vm->_scene->getInverseColorTable();
+ info.inverseColourTable = _m4Vm->scene()->getInverseColourTable();
info.palette = _ws->getMainPalette();
info.width = _curFrame->width();
info.height = _curFrame->height();