aboutsummaryrefslogtreecommitdiff
path: root/engines/m4/scene.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/m4/scene.cpp')
-rw-r--r--engines/m4/scene.cpp559
1 files changed, 0 insertions, 559 deletions
diff --git a/engines/m4/scene.cpp b/engines/m4/scene.cpp
index 673a375fa2..a9905f5b2f 100644
--- a/engines/m4/scene.cpp
+++ b/engines/m4/scene.cpp
@@ -406,563 +406,4 @@ void Scene::showMADSV2TextBox(char *text, int x, int y, char *faceName) {
boxSprites->getFrame(bottomRight)->copyTo(_backgroundSurface, curX, curY + 1);
}
-/*--------------------------------------------------------------------------*/
-
-M4Scene::M4Scene(M4Engine *vm): Scene(vm) {
- _vm = vm;
- _sceneSprites = NULL;
- _interfaceSurface = new M4InterfaceView(vm);
-}
-
-M4Scene::~M4Scene() {
- delete _sceneSprites;
-}
-
-void M4Scene::loadSceneSprites(int sceneNumber) {
- char filename[kM4MaxFilenameSize];
- sprintf(filename, "%i.ssb", sceneNumber);
-
- Common::SeekableReadStream *sceneS = _vm->res()->get(filename);
- _sceneSprites = new SpriteAsset(_vm, sceneS, sceneS->size(), filename);
- _vm->res()->toss(filename);
-
- printf("Scene has %d sprites, each one having %d colors\n", _sceneSprites->getCount(), _sceneSprites->getColorCount());
-}
-
-void M4Scene::loadScene(int sceneNumber) {
- Scene::loadScene(sceneNumber);
-
- _backgroundSurface->loadBackground(sceneNumber);
- _palData = NULL;
-
- if (_vm->getGameType() == GType_Burger &&
- sceneNumber != TITLE_SCENE_BURGER && sceneNumber != MAINMENU_SCENE_BURGER)
- setStatusText("");
-
- // Load scene def file (*.CHK)
- loadSceneResources(sceneNumber);
- loadSceneInverseColorTable(sceneNumber);
-
- // TODO: set walker scaling
- // TODO: destroy woodscript buffer
-
- // Load scene walk path file (*.COD/*.WW?)
- loadSceneCodes(sceneNumber);
-
- // Load inverse color table file (*.IPL)
- loadSceneInverseColorTable(sceneNumber);
-
- if (_vm->getGameType() != GType_Burger) {
- // Load scene sprites file (*.SSB)
- loadSceneSprites(sceneNumber);
-
- // Load scene sprite codes file (*.SSC)
- loadSceneSpriteCodes(sceneNumber);
- }
-
-
- if (sceneNumber != TITLE_SCENE_BURGER && sceneNumber != MAINMENU_SCENE_BURGER) {
- _m4Vm->scene()->getInterface()->show();
- showSprites();
- }
-
- // Purge resources
- _vm->res()->purge();
-}
-
-void M4Scene::loadSceneCodes(int sceneNumber, int index) {
- char filename[kM4MaxFilenameSize];
- Common::SeekableReadStream *sceneS;
-
- sprintf(filename, "%i.cod", sceneNumber);
- sceneS = _vm->res()->openFile(filename);
- _walkSurface->loadCodesM4(sceneS);
- _vm->res()->toss(filename);
-}
-
-void M4Scene::show() {
- Scene::show();
- _vm->_viewManager->addView(_interfaceSurface);
-}
-
-void M4Scene::checkHotspotAtMousePos(int x, int y) {
- if (_vm->getGameType() == GType_Riddle)
- return;
-
- // TODO: loads of things to do here, only the mouse cursor and the status
- // text is changed for now
-
- // Only scene hotspots are checked for now, not parallax/props, as the
- // latter ones are not used by Orion Burger
- HotSpot *currentHotSpot = _sceneResources.hotspots->findByXY(x, y);
- if (currentHotSpot != NULL && currentHotSpot->getActive()) {
- if (_vm->_mouse->getCursorNum() != CURSOR_LOOK &&
- _vm->_mouse->getCursorNum() != CURSOR_TAKE &&
- _vm->_mouse->getCursorNum() != CURSOR_USE &&
- _m4Vm->scene()->getInterface()->_inventory.getSelectedIndex() == -1) {
- _vm->_mouse->setCursorNum(currentHotSpot->getCursor());
- }
- _m4Vm->scene()->getInterface()->setStatusText(currentHotSpot->getPrep());
- } else {
- if (_vm->_mouse->getCursorNum() != CURSOR_LOOK &&
- _vm->_mouse->getCursorNum() != CURSOR_TAKE &&
- _vm->_mouse->getCursorNum() != CURSOR_USE &&
- _m4Vm->scene()->getInterface()->_inventory.getSelectedIndex() == -1) {
- _vm->_mouse->setCursorNum(0);
- } else {
-
- }
- }
-}
-
-void M4Scene::leftClick(int x, int y) {
- if (_vm->getGameType() == GType_Burger) {
- // Place a Wilbur sprite with the correct facing
- HotSpot *currentHotSpot = _sceneResources.hotspots->findByXY(x, y);
- if (currentHotSpot != NULL && currentHotSpot->getActive()) {
- update();
- _vm->_actor->setWalkerDirection(currentHotSpot->getFacing());
- /*
- int posX = currentHotSpot->getFeetX();
- int posY = currentHotSpot->getFeetY() -
- scaleValue(_vm->_actor->getWalkerHeight(), _vm->_actor->getWalkerScaling(), 0);
- //_vm->_actor->placeWalkerSpriteAt(0, posX, posY);
- */
-
- // Player said.... (for scene scripts)
- printf("Player said: %s %s\n", currentHotSpot->getVerb(), currentHotSpot->getVocab());
-
- // FIXME: This should be moved somewhere else, and is incomplete
- if (_m4Vm->scene()->getInterface()->_inventory.getSelectedIndex() == -1) {
- if (_vm->_mouse->getVerb() == NULL) {
- strcpy(_vm->_player->verb, currentHotSpot->getVerb());
- } else {
- strcpy(_vm->_player->verb, _vm->_mouse->getVerb());
- }
- } else {
- strcpy(_vm->_player->verb, _m4Vm->scene()->getInterface()->_inventory.getSelectedObjectName());
- }
- strcpy(_vm->_player->noun, currentHotSpot->getVocab());
- strcpy(_vm->_player->object, "");
- _vm->_player->commandReady = true;
-
- printf("## Player said: %s %s\n", _vm->_player->verb, _vm->_player->noun);
-
- }
- }
-}
-
-void M4Scene::rightClick(int x, int y) {
- if (_vm->getGameType() == GType_Burger) {
- nextCommonCursor();
- _m4Vm->scene()->getInterface()->_inventory.clearSelected();
- }
-}
-
-void M4Scene::setAction(int action, int objectId) {
-}
-
-void M4Scene::setStatusText(const char *text) {
- getInterface()->setStatusText(text);
-}
-
-void M4Scene::update() {
-
-}
-
-void M4Scene::nextCommonCursor() {
- int cursorIndex = _vm->_mouse->getCursorNum();
-
- switch (cursorIndex) {
- case CURSOR_ARROW:
- cursorIndex = CURSOR_LOOK;
- break;
- case CURSOR_LOOK:
- cursorIndex = CURSOR_TAKE;
- break;
- case CURSOR_TAKE:
- cursorIndex = CURSOR_USE;
- break;
- case CURSOR_USE:
- cursorIndex = CURSOR_ARROW;
- break;
- default:
- cursorIndex = CURSOR_ARROW;
- }
-
- _vm->_mouse->setCursorNum(cursorIndex);
-}
-
-/*--------------------------------------------------------------------------*/
-
-MadsScene::MadsScene(MadsEngine *vm): Scene(vm) {
- _vm = vm;
-
- strcpy(_statusText, "");
- _interfaceSurface = new MadsInterfaceView(vm);
- _currentAction = kVerbNone;
- _spriteSlotsStart = 0;
-}
-
-/**
- * Secondary scene loading code
- */
-void MadsScene::loadScene2(const char *aaName) {
- // Load up the properties for the scene
- _sceneInfo.load(_currentScene);
-
- // Load scene walk paths
- loadSceneCodes(_currentScene);
-}
-
-/**
- * Existing ScummVM code that needs to be eventually replaced with MADS code
- */
-void MadsScene::loadSceneTemporary() {
- /* Existing code that eventually needs to be replaced with the proper MADS code */
- // Set system palette entries
- _vm->_palette->blockRange(0, 7);
- RGB8 sysColors[3] = { {0x1f<<2, 0x2d<<2, 0x31<<2, 0}, {0x24<<2, 0x37<<2, 0x3a<<2, 0},
- {0x00<<2, 0x10<<2, 0x16<<2, 0}};
- _vm->_palette->setPalette(&sysColors[0], 4, 3);
-
- _backgroundSurface->loadBackground(_currentScene, &_palData);
- _vm->_palette->addRange(_palData);
- _backgroundSurface->translate(_palData);
-
- if (_currentScene < 900) {
- /*_backgroundSurface->fillRect(Common::Rect(0, MADS_SURFACE_HEIGHT,
- _backgroundSurface->width(), _backgroundSurface->height()),
- _vm->_palette->BLACK);*/
- // TODO: interface palette
- _interfaceSurface->madsloadInterface(0, &_interfacePal);
- _vm->_palette->addRange(_interfacePal);
- _interfaceSurface->translate(_interfacePal);
- _backgroundSurface->copyFrom(_interfaceSurface, Common::Rect(0, 0, 320, 44), 0, 200 - 44);
-
- _interfaceSurface->initialise();
- }
-
- // Don't load other screen resources for system screens
- if (_currentScene >= 900)
- return;
-
- loadSceneHotSpotsMads(_currentScene);
-
- // TODO: set walker scaling
- // TODO: destroy woodscript buffer
-
- // Load inverse color table file (*.IPL)
- loadSceneInverseColorTable(_currentScene);
-}
-
-void MadsScene::loadScene(int sceneNumber) {
- // Close the menu if it's active
- View *mainMenu = _vm->_viewManager->getView(VIEWID_MAINMENU);
- if (mainMenu != NULL) {
- _vm->_viewManager->deleteView(mainMenu);
- }
-
- // Handle common scene setting
- Scene::loadScene(sceneNumber);
-
- // Signal the script engine what scene is to be active
- _sceneLogic.selectScene(sceneNumber);
- _sceneLogic.setupScene();
-
- // Add the scene if necessary to the list of scenes that have been visited
- _vm->globals()->addVisitedScene(sceneNumber);
-
- // Secondary scene load routine
- loadScene2("*I0.AA");
-
- // Do any scene specific setup
- _sceneLogic.enterScene();
-
- // Existing ScummVM code that needs to be eventually replaced with MADS code
- loadSceneTemporary();
-
- // Purge resources
- _vm->res()->purge();
-}
-
-void MadsScene::leaveScene() {
- _sceneResources.hotspots->clear();
- _sceneResources.parallax->clear();
- _sceneResources.props->clear();
-
- delete _sceneResources.hotspots;
- delete _sceneResources.parallax;
- delete _sceneResources.props;
-
- // Delete the sprites
- for (uint i = 0; i <_sceneSprites.size(); ++i) delete _sceneSprites[i];
- _sceneSprites.clear();
-
- delete _backgroundSurface;
- delete _walkSurface;
-
- Scene::leaveScene();
-}
-
-void MadsScene::show() {
- Scene::show();
- _vm->_viewManager->addView(_interfaceSurface);
-}
-
-void MadsScene::loadSceneCodes(int sceneNumber, int index) {
- char filename[kM4MaxFilenameSize];
- Common::SeekableReadStream *sceneS;
-
- if (_vm->getGameType() == GType_Phantom || _vm->getGameType() == GType_DragonSphere) {
- sprintf(filename, "rm%i.ww%i", sceneNumber, index);
- MadsPack walkData(filename, _vm);
- sceneS = walkData.getItemStream(0);
- _walkSurface->loadCodesMads(sceneS);
- _vm->res()->toss(filename);
- } else if (_vm->getGameType() == GType_RexNebular) {
- // For Rex Nebular, the walk areas are part of the scene info
- byte *destP = _walkSurface->getBasePtr(0, 0);
- const byte *srcP = _sceneInfo.walkData;
- byte runLength;
- while ((runLength = *srcP++) != 0) {
- Common::set_to(destP, destP + runLength, *srcP++);
- destP += runLength;
- }
- }
-}
-
-void MadsScene::checkHotspotAtMousePos(int x, int y) {
- HotSpot *currentHotSpot = _sceneResources.hotspots->findByXY(x, y);
- if (currentHotSpot != NULL) {
- _vm->_mouse->setCursorNum(currentHotSpot->getCursor());
-
- // This is the "easy" interface, which updates the status text when the mouse is moved
- // TODO: toggle this code for easy/normal interface mode
- char statusText[50];
- int verbId = _currentAction;
- if (verbId == kVerbNone)
- verbId = currentHotSpot->getVerbID();
- if (verbId == kVerbNone)
- verbId = kVerbWalkTo;
-
- sprintf(statusText, "%s %s\n", _madsVm->globals()->getVocab(verbId), currentHotSpot->getVocab());
-
- statusText[0] = toupper(statusText[0]); // capitalize first letter
- setStatusText(statusText);
- } else {
- _vm->_mouse->setCursorNum(0);
- setStatusText("");
- }
-}
-
-void MadsScene::leftClick(int x, int y) {
- HotSpot *currentHotSpot = _sceneResources.hotspots->findByXY(x, y);
- if (currentHotSpot != NULL) {
- char statusText[50];
- if (currentHotSpot->getVerbID() != 0) {
- sprintf(statusText, "%s %s\n", currentHotSpot->getVerb(), currentHotSpot->getVocab());
- } else {
- sprintf(statusText, "%s %s\n", _madsVm->globals()->getVocab(kVerbWalkTo), currentHotSpot->getVocab());
- }
-
- statusText[0] = toupper(statusText[0]); // capitalize first letter
- setStatusText(statusText);
- }
-}
-
-void MadsScene::rightClick(int x, int y) {
- // ***DEBUG*** - sample dialog display
- 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);
-}
-
-void MadsScene::setAction(int action, int objectId) {
- VALIDATE_MADS;
- char statusText[50];
-
- // TODO: Actually executing actions directly for objects. Also, some object actions are special in that
- // a second object can be selected, as in 'use gun to shoot person', with requires a target
-
- // Set up the new action
- strcpy(statusText, _madsVm->globals()->getVocab(action));
- statusText[0] = toupper(statusText[0]); // capitalize first letter
-
- if (objectId != -1) {
- MadsObject *obj = _madsVm->globals()->getObject(objectId);
- sprintf(statusText + strlen(statusText), " %s", _madsVm->globals()->getVocab(obj->descId));
- } else {
- _currentAction = action;
- }
-
- setStatusText(statusText);
-}
-
-void MadsScene::setStatusText(const char *text) {
- strcpy(_statusText, text);
-}
-
-/**
- * Draws all the elements of the scene
- */
-void MadsScene::drawElements() {
-
- // Display animations
- for (int idx = 0; idx < _spriteSlotsStart; ++idx) {
-
- }
-
-
- // Text display loop
- for (int idx = 0; idx < TEXT_DISPLAY_SIZE; ++idx) {
- if (_textDisplay[idx].active && (_textDisplay[idx].field_A >= 0)) {
- _textDisplay[idx].font->setColours(0xFF, (_textDisplay[idx].colour2 == 0) ?
- _textDisplay[idx].colour1 : _textDisplay[idx].colour2, _textDisplay[idx].colour1);
- _textDisplay[idx].font->writeString(this, _textDisplay[idx].message,
- _textDisplay[idx].bounds.left, _textDisplay[idx].bounds.top,
- width() - _textDisplay[idx].bounds.left, _textDisplay[idx].spacing);
- }
- }
-
- // Copy the user interface surface onto the surface
- _interfaceSurface->copyTo(this, 0, this->height() - _interfaceSurface->height());
-
-/*
- // At this point, in the original engine, the dirty/changed areas were copied to the screen. At the moment,
- // the current M4 engine framework doesn't support dirty areas, but this is being kept in case that ever changes
- for (int idx = 0; idx < DIRTY_AREA_SIZE; ++idx) {
- if (_dirtyAreas[idx].active && _dirtyAreas[idx].active2 &&
- (_dirtyAreas[idx].bounds.width() > 0) && (_dirtyAreas[idx].bounds.height() > 0)) {
- // Copy changed area to screen
-
- }
- }
-*/
-
- // Some kind of copying over of slot entries
- for (int idx = 0, idx2 = 0; idx < _spriteSlotsStart; ++idx) {
- if (_spriteSlots[idx].spriteId >= 0) {
- if (idx != idx2) {
- // Copy over the slot entry
- _spriteSlots[idx2] = _spriteSlots[idx];
- }
- ++idx2;
- }
- }
-
- // Clear up any now inactive text display entries
- for (int idx = 0; idx < TEXT_DISPLAY_SIZE; ++idx) {
- if (_textDisplay[idx].field_A < 0) {
- _textDisplay[idx].active = false;
- _textDisplay[idx].field_A = 0;
- }
- }
-}
-
-
-void MadsScene::update() {
- // Copy the bare scene in
- _backgroundSurface->copyTo(this);
-
- // Draw all the various elements
- drawElements();
-
- // Handle display of any status text
- if (_statusText[0]) {
- // Text colors are inverted in Dragonsphere
- if (_vm->getGameType() == GType_DragonSphere)
- _vm->_font->setColors(_vm->_palette->BLACK, _vm->_palette->WHITE, _vm->_palette->BLACK);
- else
- _vm->_font->setColors(_vm->_palette->WHITE, _vm->_palette->BLACK, _vm->_palette->BLACK);
-
- _vm->_font->setFont(FONT_MAIN_MADS);
- _vm->_font->writeString(this, _statusText, (width() - _vm->_font->getWidth(_statusText)) / 2, 142, 0);
- }
-
- //***DEBUG***
- _sceneSprites[0]->getFrame(1)->copyTo(this, 120, 90, 0);
-}
-
-int MadsScene::loadSceneSpriteSet(const char *setName) {
- char resName[100];
- strcpy(resName, setName);
-
- // Append a '.SS' if it doesn't alreayd have an extension
- if (!strchr(resName, '.'))
- strcat(resName, ".SS");
-
- Common::SeekableReadStream *data = _vm->res()->get(resName);
- SpriteAsset *spriteSet = new SpriteAsset(_vm, data, data->size(), resName);
- spriteSet->translate(_vm->_palette);
- _vm->res()->toss(resName);
-
- _sceneSprites.push_back(spriteSet);
- return _sceneSprites.size() - 1;
-}
-
-void MadsScene::loadPlayerSprites(const char *prefix) {
- const char suffixList[8] = { '8', '9', '6', '3', '2', '7', '4', '1' };
- char setName[80];
-
- strcpy(setName, "*");
- strcat(setName, prefix);
- strcat(setName, "_0.SS");
- char *digitP = strchr(setName, '_') + 1;
-
- for (int idx = 0; idx < 8; ++idx) {
- *digitP = suffixList[idx];
-
- if (_vm->res()->resourceExists(setName)) {
- loadSceneSpriteSet(setName);
- return;
- }
- }
-
- error("Couldn't find player sprites");
-}
-
-/*--------------------------------------------------------------------------*/
-
-void MadsSceneInfo::load(int sId) {
- const char *sceneInfoStr = MADSResourceManager::getResourceName(RESPREFIX_RM, sId, ".DAT");
- Common::SeekableReadStream *rawStream = _vm->_resourceManager->get(sceneInfoStr);
- MadsPack sceneInfo(rawStream);
-
- // Basic scene info
- Common::SeekableReadStream *stream = sceneInfo.getItemStream(0);
-
- int resSceneId = stream->readUint16LE();
- assert(resSceneId == sId);
-
- artFileNum = stream->readUint16LE();
- field_4 = stream->readUint16LE();
- width = stream->readUint16LE();
- height = stream->readUint16LE();
- assert((width == 320) && (height == 156));
-
- stream->skip(24);
-
- objectCount = stream->readUint16LE();
-
- stream->skip(40);
-
- for (int i = 0; i < objectCount; ++i) {
- objects[i].load(stream);
- }
-
- // For Rex Nebular, read in the scene's compressed walk surface information
- if (_vm->getGameType() == GType_RexNebular) {
- delete walkData;
-
- stream = sceneInfo.getItemStream(1);
- walkData = (byte *)malloc(stream->size());
- stream->read(walkData, stream->size());
- }
-
- _vm->_resourceManager->toss(sceneInfoStr);
-}
-
} // End of namespace M4