From c2be8ed45dccc04528869bece0ef3f9ff6c9d743 Mon Sep 17 00:00:00 2001 From: Gregory Montoir Date: Thu, 11 Dec 2003 22:16:35 +0000 Subject: constructors cleanup svn-id: r11589 --- queen/command.cpp | 371 ++++++++++++++++++------------------ queen/command.h | 19 +- queen/cutaway.cpp | 359 +++++++++++++++++------------------ queen/cutaway.h | 30 +-- queen/debug.cpp | 88 ++++----- queen/debug.h | 11 +- queen/display.cpp | 23 ++- queen/display.h | 9 +- queen/graphics.cpp | 57 +++--- queen/graphics.h | 11 +- queen/journal.cpp | 172 ++++++++--------- queen/journal.h | 14 +- queen/logic.cpp | 545 ++++++++++++++++++++++++++--------------------------- queen/logic.h | 25 +-- queen/queen.cpp | 21 ++- queen/queen.h | 23 ++- queen/sound.cpp | 38 ++-- queen/sound.h | 17 +- queen/talk.cpp | 267 +++++++++++++------------- queen/talk.h | 27 +-- queen/walk.cpp | 98 +++++----- queen/walk.h | 9 +- 22 files changed, 1074 insertions(+), 1160 deletions(-) diff --git a/queen/command.cpp b/queen/command.cpp index 1c91ea940a..d08fd310fe 100644 --- a/queen/command.cpp +++ b/queen/command.cpp @@ -21,10 +21,12 @@ #include "stdafx.h" #include "queen/command.h" + #include "queen/display.h" #include "queen/input.h" #include "queen/graphics.h" #include "queen/logic.h" +#include "queen/queen.h" #include "queen/sound.h" #include "queen/state.h" #include "queen/talk.h" @@ -41,8 +43,8 @@ void CmdText::clear() { void CmdText::display(uint8 color) { - _graphics->textCurrentColor(color); - _graphics->textSetCentered(COMMAND_Y_POS, _command, false); + _vm->graphics()->textCurrentColor(color); + _vm->graphics()->textSetCentered(COMMAND_Y_POS, _command, false); } @@ -50,7 +52,7 @@ void CmdText::displayTemp(uint8 color, bool locked, const Verb& v, const char *n char temp[MAX_COMMAND_LEN]; if (locked) { - sprintf(temp, "%s%s", _logic->joeResponse(39), v.name()); + sprintf(temp, "%s%s", _vm->logic()->joeResponse(39), v.name()); } else { strcpy(temp, v.name()); @@ -59,8 +61,8 @@ void CmdText::displayTemp(uint8 color, bool locked, const Verb& v, const char *n strcat(temp, " "); strcat(temp, name); } - _graphics->textCurrentColor(color); - _graphics->textSetCentered(COMMAND_Y_POS, temp, false); + _vm->graphics()->textCurrentColor(color); + _vm->graphics()->textSetCentered(COMMAND_Y_POS, temp, false); } @@ -68,8 +70,8 @@ void CmdText::displayTemp(uint8 color, const char *name) { char temp[MAX_COMMAND_LEN]; sprintf(temp, "%s %s", _command, name); - _graphics->textCurrentColor(color); - _graphics->textSetCentered(COMMAND_Y_POS, temp, false); + _vm->graphics()->textCurrentColor(color); + _vm->graphics()->textSetCentered(COMMAND_Y_POS, temp, false); } @@ -126,10 +128,9 @@ void SelectedCmdState::init() { } -Command::Command(Logic *l, Graphics *g, Input *i, Walk *w, Sound *s) - : _logic(l), _graphics(g), _input(i), _sound(s), _walk(w) { - _cmdText._graphics = _graphics; - _cmdText._logic = _logic; +Command::Command(QueenEngine *vm) + : _vm(vm) { + _cmdText._vm = vm; } @@ -137,7 +138,7 @@ void Command::clear(bool clearTexts) { _cmdText.clear(); if (clearTexts) { - _graphics->textClear(CmdText::COMMAND_Y_POS, CmdText::COMMAND_Y_POS); + _vm->graphics()->textClear(CmdText::COMMAND_Y_POS, CmdText::COMMAND_Y_POS); } _parse = false; _curCmd.init(); @@ -149,7 +150,7 @@ void Command::clear(bool clearTexts) { // pinnacle room exactly like the original void Command::executeCurrentAction(bool walk) { - _logic->entryObj(0); + _vm->logic()->entryObj(0); if (_curCmd.commandLevel == 2 && _mouseKey == Input::MOUSE_RBUTTON) { _mouseKey = Input::MOUSE_LBUTTON; @@ -161,16 +162,16 @@ void Command::executeCurrentAction(bool walk) { // check to see if selecting default command for object/item if (_curCmd.subject1 > 0) { - int16 i = _logic->findObjectGlobalNumber(_curCmd.noun); + int16 i = _vm->logic()->findObjectGlobalNumber(_curCmd.noun); if (_curCmd.noun == 0 || - _curCmd.noun > _logic->currentRoomObjMax() || - _logic->objectData(i)->name <= 0) { + _curCmd.noun > _vm->logic()->currentRoomObjMax() || + _vm->logic()->objectData(i)->name <= 0) { cleanupCurrentAction(); return; } - uint16 obj = _logic->currentRoomData() + _curCmd.noun; + uint16 obj = _vm->logic()->currentRoomData() + _curCmd.noun; _curCmd.verb = findDefault(obj, false); if (_curCmd.verb.isNone()) { // no match made, so command not yet completed, redefine as WALK_TO @@ -181,7 +182,7 @@ void Command::executeCurrentAction(bool walk) { _cmdText.setVerb(_curCmd.verb); _selCmd.action = _curCmd.verb; } - _cmdText.addObject(_logic->objectName(_logic->objectData(obj)->name)); + _cmdText.addObject(_vm->logic()->objectName(_vm->logic()->objectData(obj)->name)); } } @@ -259,7 +260,7 @@ void Command::executeCurrentAction(bool walk) { else { // only play song if it's a PLAY AFTER type if (com->song < 0) { - _sound->playSong(-com->song); + _vm->sound()->playSong(-com->song); } clear(true); } @@ -269,19 +270,19 @@ void Command::executeCurrentAction(bool walk) { void Command::updatePlayer() { - if (_input->cutawayRunning()) return; + if (_vm->input()->cutawayRunning()) return; lookCurrentRoom(); lookCurrentIcon(); - if (!_input->keyVerb().isNone()) { + if (!_vm->input()->keyVerb().isNone()) { - if (_input->keyVerb().isJournal()) { - _input->clearKeyVerb(); - _logic->useJournal(); + if (_vm->input()->keyVerb().isJournal()) { + _vm->input()->clearKeyVerb(); + _vm->logic()->useJournal(); } - else if (!_input->keyVerb().isSkipText()) { - _curCmd.verb = _input->keyVerb(); + else if (!_vm->input()->keyVerb().isSkipText()) { + _curCmd.verb = _vm->input()->keyVerb(); if (_curCmd.verb.isInventory()) { _curCmd.noun = _selCmd.noun = 0; // Clear old noun and old verb in case we're pointing at an @@ -295,12 +296,12 @@ void Command::updatePlayer() { else { grabSelectedVerb(); } - _input->clearKeyVerb(); + _vm->input()->clearKeyVerb(); } } - _mouseKey = _input->mouseButton(); - _input->clearMouseButton(); + _mouseKey = _vm->input()->mouseButton(); + _vm->input()->clearMouseButton(); if (_mouseKey > 0) { grabCurrentSelection(); } @@ -362,10 +363,10 @@ int16 Command::executeCommand(uint16 comId, int16 condResult) { // Don't grab if action is TALK or WALK if (_selCmd.action.value() != VERB_TALK_TO && _selCmd.action.value() != VERB_WALK_TO) { if (_curCmd.subject1 > 0) { - _logic->joeGrab(State::findGrab(_logic->objectData(_curCmd.subject1)->state)); + _vm->logic()->joeGrab(State::findGrab(_vm->logic()->objectData(_curCmd.subject1)->state)); } if (_curCmd.subject2 > 0) { - _logic->joeGrab(State::findGrab(_logic->objectData(_curCmd.subject2)->state)); + _vm->logic()->joeGrab(State::findGrab(_vm->logic()->objectData(_curCmd.subject2)->state)); } } @@ -375,7 +376,7 @@ int16 Command::executeCommand(uint16 comId, int16 condResult) { // the hack described on l.334-339 in execute.c became useless // check for cutaway/dialogs before updating Objects - const char *desc = _logic->objectTextualDescription(condResult); + const char *desc = _vm->logic()->objectTextualDescription(condResult); if (executeIfCutaway(desc)) { condResult = 0; cutDone = true; @@ -388,7 +389,7 @@ int16 Command::executeCommand(uint16 comId, int16 condResult) { int16 oldImage = 0; if (_curCmd.subject1 > 0) { // an object (not an item) - oldImage = _logic->objectData(_curCmd.subject1)->image; + oldImage = _vm->logic()->objectData(_curCmd.subject1)->image; } if (com->setObjects) { @@ -400,7 +401,7 @@ int16 Command::executeCommand(uint16 comId, int16 condResult) { } if (com->imageOrder != 0) { - ObjectData *od = _logic->objectData(_curCmd.subject1); + ObjectData *od = _vm->logic()->objectData(_curCmd.subject1); // we must update the graphic image of the object if (com->imageOrder < 0) { // instead of setting to -1 or -2, flag as negative @@ -412,15 +413,15 @@ int16 Command::executeCommand(uint16 comId, int16 condResult) { else { od->image = com->imageOrder; } - _logic->roomRefreshObject(_curCmd.subject1); + _vm->logic()->roomRefreshObject(_curCmd.subject1); } else { // this object is not being updated by command list, see if // it has another image copied to it if (_curCmd.subject1 > 0) { // an object (not an item) - if (_logic->objectData(_curCmd.subject1)->image != oldImage) { - _logic->roomRefreshObject(_curCmd.subject1); + if (_vm->logic()->objectData(_curCmd.subject1)->image != oldImage) { + _vm->logic()->roomRefreshObject(_curCmd.subject1); } } } @@ -429,7 +430,7 @@ int16 Command::executeCommand(uint16 comId, int16 condResult) { if (_selCmd.action.value() != VERB_OPEN && _selCmd.action.value() != VERB_CLOSE) { // only play song if it's a PLAY BEFORE type if (com->song > 0) { - _sound->playSong(com->song); + _vm->sound()->playSong(com->song); } } @@ -437,16 +438,16 @@ int16 Command::executeCommand(uint16 comId, int16 condResult) { // l.419-452 execute.c switch (com->specialSection) { case 1: - _logic->useJournal(); + _vm->logic()->useJournal(); return condResult; case 2: - _logic->joeUseDress(true); + _vm->logic()->joeUseDress(true); break; case 3: - _logic->joeUseClothes(true); + _vm->logic()->joeUseClothes(true); break; case 4: - _logic->joeUseUnderwear(); + _vm->logic()->joeUseUnderwear(); break; } @@ -455,7 +456,7 @@ int16 Command::executeCommand(uint16 comId, int16 condResult) { // execute.c l.533-548 // FIXME: useless test, as .dog has already been played // if (_selCmd.action.value() == VERB_TALK_TO && cond > 0) { - // if (executeIfDialog(_logic->objectTextualDescription(cond))) { + // if (executeIfDialog(_vm->logic()->objectTextualDescription(cond))) { // cleanupCurrentAction(); // return; // } @@ -465,7 +466,7 @@ int16 Command::executeCommand(uint16 comId, int16 condResult) { // FIXME: the EXECUTE_EXIT1 stuff can be omitted as it is // more or less redundant code if (condResult > 0) { - _logic->joeSpeak(condResult, true); + _vm->logic()->joeSpeak(condResult, true); } return condResult; } @@ -475,19 +476,19 @@ int16 Command::makeJoeWalkTo(int16 x, int16 y, int16 objNum, const Verb &v, bool // Check to see if object is actually an exit to another // room. If so, then set up new room - ObjectData *objData = _logic->objectData(objNum); + ObjectData *objData = _vm->logic()->objectData(objNum); if (objData->x != 0 || objData->y != 0) { x = objData->x; y = objData->y; } if (v.value() == VERB_WALK_TO) { - _logic->entryObj(objData->entryObj); - if (_logic->entryObj() != 0) { - _logic->newRoom(_logic->objectData(_logic->entryObj())->room); + _vm->logic()->entryObj(objData->entryObj); + if (_vm->logic()->entryObj() != 0) { + _vm->logic()->newRoom(_vm->logic()->objectData(_vm->logic()->entryObj())->room); // because this is an exit object, see if there is // a walk off point and set (x,y) accordingly - WalkOffData *wod = _logic->walkOffPointForObject(objNum); + WalkOffData *wod = _vm->logic()->walkOffPointForObject(objNum); if (wod != NULL) { x = wod->x; y = wod->y; @@ -495,26 +496,26 @@ int16 Command::makeJoeWalkTo(int16 x, int16 y, int16 objNum, const Verb &v, bool } } else { - _logic->entryObj(0); - _logic->newRoom(0); + _vm->logic()->entryObj(0); + _vm->logic()->newRoom(0); } - debug(0, "Command::makeJoeWalkTo() - x=%d y=%d newRoom=%d", x, y, _logic->newRoom()); + debug(0, "Command::makeJoeWalkTo() - x=%d y=%d newRoom=%d", x, y, _vm->logic()->newRoom()); int16 p = 0; if (mustWalk) { // determine which way for Joe to face Object uint16 facing = State::findDirection(objData->state); - BobSlot *bobJoe = _graphics->bob(0); + BobSlot *bobJoe = _vm->graphics()->bob(0); if (x == bobJoe->x && y == bobJoe->y) { - _logic->joeFacing(facing); - _logic->joeFace(); + _vm->logic()->joeFacing(facing); + _vm->logic()->joeFace(); } else { - p = _walk->moveJoe(facing, x, y, false); // XXX inCutaway parameter + p = _vm->walk()->moveJoe(facing, x, y, false); // XXX inCutaway parameter if (p != 0) { - _logic->newRoom(0); // cancel makeJoeWalkTo, that should be equivalent to cr10 fix + _vm->logic()->newRoom(0); // cancel makeJoeWalkTo, that should be equivalent to cr10 fix // XXX if(P != 0) P = FIND_VERB } } @@ -525,14 +526,14 @@ int16 Command::makeJoeWalkTo(int16 x, int16 y, int16 objNum, const Verb &v, bool void Command::grabCurrentSelection() { - _selPosX = _input->mousePosX(); - _selPosY = _input->mousePosY(); + _selPosX = _vm->input()->mousePosX(); + _selPosY = _vm->input()->mousePosY(); - uint16 zone = _logic->findObjectUnderCursor(_selPosX, _selPosY); - _curCmd.noun = _logic->findObjectRoomNumber(zone); - _curCmd.verb = _logic->findVerbUnderCursor(_selPosX, _selPosY); + uint16 zone = _vm->logic()->findObjectUnderCursor(_selPosX, _selPosY); + _curCmd.noun = _vm->logic()->findObjectRoomNumber(zone); + _curCmd.verb = _vm->logic()->findVerbUnderCursor(_selPosX, _selPosY); - _selPosX += _logic->display()->horizontalScroll(); + _selPosX += _vm->display()->horizontalScroll(); if (_curCmd.verb.isAction()) { grabSelectedVerb(); @@ -540,13 +541,13 @@ void Command::grabCurrentSelection() { else if (_curCmd.verb.isInventory()) { grabSelectedItem(); } - else if (_curCmd.noun > 0 && _curCmd.noun <= _logic->currentRoomObjMax()) { + else if (_curCmd.noun > 0 && _curCmd.noun <= _vm->logic()->currentRoomObjMax()) { grabSelectedNoun(); } else if (_selPosY < ROOM_ZONE_HEIGHT && _curCmd.verb.isNone()) { // select without a command, do a WALK clear(true); - _logic->joeWalk(JWM_EXECUTE); + _vm->logic()->joeWalk(JWM_EXECUTE); } } @@ -554,7 +555,7 @@ void Command::grabCurrentSelection() { void Command::grabSelectedObject(int16 objNum, uint16 objState, uint16 objName) { if (!_curCmd.action.isNone()) { - _cmdText.addObject(_logic->objectName(objName)); + _cmdText.addObject(_vm->logic()->objectName(objName)); } _curCmd.addObject(objNum); @@ -588,8 +589,8 @@ void Command::grabSelectedObject(int16 objNum, uint16 objState, uint16 objName) if (_parse) { _curCmd.verb = Verb(VERB_NONE); - //_logic->newRoom(0); - _logic->joeWalk(JWM_EXECUTE); + //_vm->logic()->newRoom(0); + _vm->logic()->joeWalk(JWM_EXECUTE); _selCmd.action = _curCmd.action; _curCmd.action = Verb(VERB_NONE); } @@ -603,8 +604,8 @@ void Command::grabSelectedItem() { // Set PARSE to TRUE, default FALSE if command half complete _parse = true; - uint16 item = _logic->findInventoryItem(_curCmd.verb.inventoryItem()); - if (item == 0 || _logic->itemData(item)->name == 0) { + uint16 item = _vm->logic()->findInventoryItem(_curCmd.verb.inventoryItem()); + if (item == 0 || _vm->logic()->itemData(item)->name == 0) { return; } @@ -612,9 +613,9 @@ void Command::grabSelectedItem() { // the ITEMs default, otherwise keep constructing! if (_mouseKey == Input::MOUSE_LBUTTON || - (!_input->keyVerb().isNone() && !_curCmd.verb.isNone())) { + (!_vm->input()->keyVerb().isNone() && !_curCmd.verb.isNone())) { if (_curCmd.action.isNone()) { - if (!_input->keyVerb().isNone()) { + if (!_vm->input()->keyVerb().isNone()) { /* 2 - We've selected via the keyboard, no command is being */ /* constructed, so we shall find the item's default */ _curCmd.verb = findDefault(item, true); @@ -636,10 +637,10 @@ void Command::grabSelectedItem() { _curCmd.verb = Verb(VERB_NONE); } else { - if (_logic->joeWalk() == JWM_MOVE) { + if (_vm->logic()->joeWalk() == JWM_MOVE) { _cmdText.clear(); _curCmd.commandLevel = 1; - _logic->joeWalk(JWM_NORMAL); + _vm->logic()->joeWalk(JWM_NORMAL); _curCmd.action = Verb(VERB_NONE); lookCurrentIcon(); } @@ -675,7 +676,7 @@ void Command::grabSelectedItem() { } } - grabSelectedObject(-item, _logic->itemData(item)->state, _logic->itemData(item)->name); + grabSelectedObject(-item, _vm->logic()->itemData(item)->state, _vm->logic()->itemData(item)->name); } @@ -687,14 +688,14 @@ void Command::grabSelectedNoun() { // click object without a command, if DEFAULT then // do that, otherwise do a WALK! - uint16 objNum = _logic->currentRoomData() + _curCmd.noun; - int16 objName = _logic->objectData(objNum)->name; + uint16 objNum = _vm->logic()->currentRoomData() + _curCmd.noun; + int16 objName = _vm->logic()->objectData(objNum)->name; if (objName <= 0) { // selected a turned off object, so just walk clear(true); _curCmd.noun = 0; - //_logic->newRoom(0); - _logic->joeWalk(JWM_EXECUTE); + //_vm->logic()->newRoom(0); + _vm->logic()->joeWalk(JWM_EXECUTE); return; } @@ -731,7 +732,7 @@ void Command::grabSelectedNoun() { _selCmd.action = _curCmd.verb; } _cmdText.setVerb(_selCmd.action); - _cmdText.addObject(_logic->objectName(_logic->objectData(objNum)->name)); + _cmdText.addObject(_vm->logic()->objectName(_vm->logic()->objectData(objNum)->name)); } else { _curCmd.verb = Verb(VERB_NONE); @@ -756,7 +757,7 @@ void Command::grabSelectedNoun() { _selCmd.noun = 0; // XXX PARSE=1; // XXX if((ACTION==6 || ACTION==5) && CLEVEL==1) PARSE=0; - grabSelectedObject(objNum, _logic->objectData(objNum)->state, objName); + grabSelectedObject(objNum, _vm->logic()->objectData(objNum)->state, objName); } @@ -765,7 +766,7 @@ void Command::grabSelectedVerb() { if (_curCmd.verb.isScrollInventory()) { // move through inventory (by four if right mouse button) uint16 scroll = _mouseKey == Input::MOUSE_RBUTTON ? 4 : 1; - _logic->inventoryScroll(scroll, _curCmd.verb.value() == VERB_SCROLL_UP); + _vm->logic()->inventoryScroll(scroll, _curCmd.verb.value() == VERB_SCROLL_UP); } else if (_curCmd.verb.isPanelCommand() || _curCmd.verb.value() == VERB_WALK_TO) { _curCmd.action = _curCmd.verb; @@ -779,8 +780,8 @@ void Command::grabSelectedVerb() { } else { _selCmd.defaultVerb = Verb(VERB_NONE); - if (_logic->joeWalk() == JWM_MOVE && !_curCmd.verb.isNone()) { - _logic->joeWalk(JWM_NORMAL); + if (_vm->logic()->joeWalk() == JWM_MOVE && !_curCmd.verb.isNone()) { + _vm->logic()->joeWalk(JWM_NORMAL); } _curCmd.commandLevel = 1; _curCmd.oldVerb = Verb(VERB_NONE); @@ -797,13 +798,13 @@ bool Command::executeIfCutaway(const char *description) { if (strlen(description) > 4 && scumm_stricmp(description + strlen(description) - 4, ".cut") == 0) { - _graphics->textClear(CmdText::COMMAND_Y_POS, CmdText::COMMAND_Y_POS); + _vm->graphics()->textClear(CmdText::COMMAND_Y_POS, CmdText::COMMAND_Y_POS); char nextCutaway[20]; memset(nextCutaway, 0, sizeof(nextCutaway)); - _logic->playCutaway(description, nextCutaway); + _vm->logic()->playCutaway(description, nextCutaway); while (nextCutaway[0] != '\0') { - _logic->playCutaway(nextCutaway, nextCutaway); + _vm->logic()->playCutaway(nextCutaway, nextCutaway); } return true; } @@ -816,16 +817,16 @@ bool Command::executeIfDialog(const char *description) { if (strlen(description) > 4 && scumm_stricmp(description + strlen(description) - 4, ".dog") == 0) { - _graphics->textClear(CmdText::COMMAND_Y_POS, CmdText::COMMAND_Y_POS); + _vm->graphics()->textClear(CmdText::COMMAND_Y_POS, CmdText::COMMAND_Y_POS); char cutaway[20]; memset(cutaway, 0, sizeof(cutaway)); - _logic->dialogue(description, _selCmd.noun, cutaway); + _vm->logic()->dialogue(description, _selCmd.noun, cutaway); while (cutaway[0] != '\0') { char currentCutaway[20]; strcpy(currentCutaway, cutaway); - _logic->playCutaway(currentCutaway, cutaway); + _vm->logic()->playCutaway(currentCutaway, cutaway); } return true; @@ -837,37 +838,37 @@ bool Command::executeIfDialog(const char *description) { bool Command::handleDefaultCommand(bool walk) { // l.96-141 execute.c - uint16 objMax = _logic->currentRoomObjMax(); - uint16 roomData = _logic->currentRoomData(); + uint16 objMax = _vm->logic()->currentRoomObjMax(); + uint16 roomData = _vm->logic()->currentRoomData(); // select without a command or WALK TO ; do a WALK if ((_selCmd.action.value() == VERB_WALK_TO || _selCmd.action.isNone()) && (_selCmd.noun > objMax || _selCmd.noun == 0)) { if (_selCmd.action.isNone()) { - _graphics->textClear(CmdText::COMMAND_Y_POS, CmdText::COMMAND_Y_POS); + _vm->graphics()->textClear(CmdText::COMMAND_Y_POS, CmdText::COMMAND_Y_POS); } - _walk->moveJoe(0, _selPosX, _selPosY, false); // XXX inCutaway parameter + _vm->walk()->moveJoe(0, _selPosX, _selPosY, false); // XXX inCutaway parameter return true; } // check to see if one of the objects is hidden - if (_curCmd.subject1 > 0 && _logic->objectData(_curCmd.subject1)->name <= 0) { + if (_curCmd.subject1 > 0 && _vm->logic()->objectData(_curCmd.subject1)->name <= 0) { return true; } if (// _selCmd.action.value() == VERB_GIVE && // can be TALK_TO ! - _curCmd.subject2 > 0 && _logic->objectData(_curCmd.subject2)->name <= 0) { + _curCmd.subject2 > 0 && _vm->logic()->objectData(_curCmd.subject2)->name <= 0) { return true; } // check for USE command on exists if (_selCmd.action.value() == VERB_USE && - _curCmd.subject1 > 0 && _logic->objectData(_curCmd.subject1)->entryObj > 0) { + _curCmd.subject1 > 0 && _vm->logic()->objectData(_curCmd.subject1)->entryObj > 0) { _selCmd.action = Verb(VERB_WALK_TO); } if (_selCmd.noun > 0 && _selCmd.noun <= objMax) { - uint16 objNum = _logic->currentRoomData() + _selCmd.noun; + uint16 objNum = _vm->logic()->currentRoomData() + _selCmd.noun; if (makeJoeWalkTo(_selPosX, _selPosY, objNum, _selCmd.action, walk) != 0) { return true; } - if (_selCmd.action.value() == VERB_WALK_TO && _logic->objectData(roomData + _selCmd.noun)->entryObj < 0) { + if (_selCmd.action.value() == VERB_WALK_TO && _vm->logic()->objectData(roomData + _selCmd.noun)->entryObj < 0) { return true; } } @@ -888,45 +889,45 @@ void Command::executeStandardStuff(const Verb& action, int16 subj1, int16 subj2) case VERB_OPEN: // 'it doesn't seem to open' - _logic->joeSpeak(1); + _vm->logic()->joeSpeak(1); break; case VERB_USE: if (subj1 < 0) { - k = _logic->itemData(-subj1)->sfxDescription; + k = _vm->logic()->itemData(-subj1)->sfxDescription; if (k > 0) { - _logic->joeSpeak(k, true); + _vm->logic()->joeSpeak(k, true); } else { - _logic->joeSpeak(2); + _vm->logic()->joeSpeak(2); } } else { - _logic->joeSpeak(2); + _vm->logic()->joeSpeak(2); } break; case VERB_TALK_TO: - _logic->joeSpeak(24 + Logic::randomizer.getRandomNumber(2)); + _vm->logic()->joeSpeak(24 + _vm->randomizer.getRandomNumber(2)); break; case VERB_CLOSE: - _logic->joeSpeak(2); + _vm->logic()->joeSpeak(2); break; case VERB_MOVE: // 'I can't move it' if (subj1 > 0) { - int16 img = _logic->objectData(subj1)->image; + int16 img = _vm->logic()->objectData(subj1)->image; if (img == -4 || img == -3) { - _logic->joeSpeak(18); + _vm->logic()->joeSpeak(18); } else { - _logic->joeSpeak(3); + _vm->logic()->joeSpeak(3); } } else { - _logic->joeSpeak(3); + _vm->logic()->joeSpeak(3); } break; @@ -935,36 +936,36 @@ void Command::executeStandardStuff(const Verb& action, int16 subj1, int16 subj2) if (subj1 < 0) { k = 11; if (subj2 > 0) { - int16 img = _logic->objectData(subj2)->image; + int16 img = _vm->logic()->objectData(subj2)->image; if (img == -4 || img == -3) { - _logic->joeSpeak(27 + Logic::randomizer.getRandomNumber(2)); + _vm->logic()->joeSpeak(27 + _vm->randomizer.getRandomNumber(2)); } } else { - _logic->joeSpeak(11); + _vm->logic()->joeSpeak(11); } } else { - _logic->joeSpeak(12); + _vm->logic()->joeSpeak(12); } break; case VERB_PICK_UP: if (subj1 < 0) { - _logic->joeSpeak(14); + _vm->logic()->joeSpeak(14); } else { - int16 img = _logic->objectData(subj2)->image; + int16 img = _vm->logic()->objectData(subj2)->image; if (img == -4 || img == -3) { // Trying to get a person - _logic->joeSpeak(20); + _vm->logic()->joeSpeak(20); } else { // 5 : 'I can't pick that up' // 6 : 'I don't think I need that' // 7 : 'I'd rather leave it here' // 8 : 'I don't think I'd have any use for that' - _logic->joeSpeak(5 + Logic::randomizer.getRandomNumber(3)); + _vm->logic()->joeSpeak(5 + _vm->randomizer.getRandomNumber(3)); } } break; @@ -978,7 +979,7 @@ void Command::executeStandardStuff(const Verb& action, int16 subj1, int16 subj2) void Command::changeObjectState(const Verb& action, int16 obj, int16 song, bool cutDone) { // l.456-533 execute.c - ObjectData *objData = _logic->objectData(obj); + ObjectData *objData = _vm->logic()->objectData(obj); if (action.value() == VERB_OPEN && !cutDone) { if (State::findOn(objData->state) == STATE_ON_ON) { @@ -987,7 +988,7 @@ void Command::changeObjectState(const Verb& action, int16 obj, int16 song, bool // play music if it exists... (or SFX for open/close door) if (song != 0) { - _sound->playSong(ABS(song)); + _vm->sound()->playSong(ABS(song)); } if (objData->entryObj != 0) { @@ -998,7 +999,7 @@ void Command::changeObjectState(const Verb& action, int16 obj, int16 song, bool } else { // 'it's already open !' - _logic->joeSpeak(9); + _vm->logic()->joeSpeak(9); } } else if (action.value() == VERB_CLOSE && !cutDone) { @@ -1009,7 +1010,7 @@ void Command::changeObjectState(const Verb& action, int16 obj, int16 song, bool // play music if it exists... (or SFX for open/close door) if (song != 0) { - _sound->playSong(ABS(song)); + _vm->sound()->playSong(ABS(song)); } if (objData->entryObj != 0) { @@ -1020,7 +1021,7 @@ void Command::changeObjectState(const Verb& action, int16 obj, int16 song, bool } else { // 'it's already closed !' - _logic->joeSpeak(10); + _vm->logic()->joeSpeak(10); } } else if (action.value() == VERB_MOVE) { @@ -1031,7 +1032,7 @@ void Command::changeObjectState(const Verb& action, int16 obj, int16 song, bool void Command::cleanupCurrentAction() { // l.595-597 execute.c - _logic->joeFace(); + _vm->logic()->joeFace(); _curCmd.oldNoun = 0; _curCmd.oldVerb = Verb(VERB_NONE); } @@ -1039,7 +1040,7 @@ void Command::cleanupCurrentAction() { Verb Command::findDefault(uint16 obj, bool itemType) { - uint16 s = itemType ? _logic->itemData(obj)->state : _logic->objectData(obj)->state; + uint16 s = itemType ? _vm->logic()->itemData(obj)->state : _vm->logic()->objectData(obj)->state; return State::findDefaultVerb(s); } @@ -1049,27 +1050,27 @@ void Command::alterDefault(const Verb& def, bool itemType) { uint16 *newDefaultState = 0; const char *name = NULL; - _curCmd.noun = _logic->findObjectUnderCursor(_selPosX, _selPosY); + _curCmd.noun = _vm->logic()->findObjectUnderCursor(_selPosX, _selPosY); if (!itemType) { if (_curCmd.noun == 0) { return; } - uint16 i = _logic->findObjectGlobalNumber(_curCmd.noun); - ObjectData *od = _logic->objectData(i); + uint16 i = _vm->logic()->findObjectGlobalNumber(_curCmd.noun); + ObjectData *od = _vm->logic()->objectData(i); if (od->name < 0) { return; } newDefaultState = &od->state; - name = _logic->objectTextualDescription(od->name); + name = _vm->logic()->objectTextualDescription(od->name); } else { - uint16 item = _logic->findInventoryItem(_curCmd.verb.inventoryItem()); - if (item == 0 || _logic->itemData(item)->name == 0) { + uint16 item = _vm->logic()->findInventoryItem(_curCmd.verb.inventoryItem()); + if (item == 0 || _vm->logic()->itemData(item)->name == 0) { return; } - ItemData *id = _logic->itemData(item); + ItemData *id = _vm->logic()->itemData(item); newDefaultState = &id->state; - name = _logic->objectTextualDescription(id->name); + name = _vm->logic()->objectTextualDescription(id->name); } State::alterDefaultVerb(newDefaultState, def); @@ -1098,7 +1099,7 @@ void Command::openOrCloseAssociatedObject(const Verb& action, int16 otherObj) { for (j = 1; j <= _numCmdGameState; ++j) { if (cmdGs[j].id == i && cmdGs[i].gameStateSlot > 0) { // FIXME: weird, why using 'i' instead of 'j' ? - if (_logic->gameState(cmdGs[i].gameStateSlot) == cmdGs[i].gameStateValue) { + if (_vm->logic()->gameState(cmdGs[i].gameStateSlot) == cmdGs[i].gameStateValue) { com = i; break; } @@ -1117,7 +1118,7 @@ void Command::openOrCloseAssociatedObject(const Verb& action, int16 otherObj) { if (com != 0) { cmdList = &_cmdList[com]; - ObjectData *objData = _logic->objectData(otherObj); + ObjectData *objData = _vm->logic()->objectData(otherObj); if (cmdList->imageOrder != 0) { // update the graphic image of object @@ -1159,8 +1160,8 @@ int16 Command::setConditions(uint16 command, bool lastCmd) { for (i = 1; i <= _numCmdGameState; ++i, ++cmdGs) { if (cmdGs->id == command) { if (cmdGs->gameStateSlot > 0) { - if (_logic->gameState(cmdGs->gameStateSlot) != cmdGs->gameStateValue) { - debug(0, "Command::setConditions() - GS[%d] == %d (should be %d)", cmdGs->gameStateSlot, _logic->gameState(cmdGs->gameStateSlot), cmdGs->gameStateValue); + if (_vm->logic()->gameState(cmdGs->gameStateSlot) != cmdGs->gameStateValue) { + debug(0, "Command::setConditions() - GS[%d] == %d (should be %d)", cmdGs->gameStateSlot, _vm->logic()->gameState(cmdGs->gameStateSlot), cmdGs->gameStateValue); // failed test ret = i; break; @@ -1178,9 +1179,9 @@ int16 Command::setConditions(uint16 command, bool lastCmd) { cmdGs = &_cmdGameState[ret]; if (cmdGs->speakValue > 0 && lastCmd) { // check to see if fail state is in fact a cutaway - const char *objDesc = _logic->objectTextualDescription(cmdGs->speakValue); + const char *objDesc = _vm->logic()->objectTextualDescription(cmdGs->speakValue); if (!executeIfCutaway(objDesc) && !executeIfDialog(objDesc)) { - _logic->joeSpeak(cmdGs->speakValue, true); + _vm->logic()->joeSpeak(cmdGs->speakValue, true); } ret = -2; } @@ -1193,7 +1194,7 @@ int16 Command::setConditions(uint16 command, bool lastCmd) { // all tests were okay, now set gamestates for (i = 0; i < tempInd; ++i) { cmdGs = &_cmdGameState[temp[i]]; - _logic->gameState(ABS(cmdGs->gameStateSlot), cmdGs->gameStateValue); + _vm->logic()->gameState(ABS(cmdGs->gameStateSlot), cmdGs->gameStateValue); // set return value for Joe to say something ret = cmdGs->speakValue; } @@ -1211,7 +1212,7 @@ void Command::setAreas(uint16 command) { for (i = 1; i <= _numCmdArea; ++i, ++cmdArea) { if (cmdArea->id == command) { uint16 areaNum = ABS(cmdArea->area); - Area *area = _logic->area(cmdArea->room, areaNum); + Area *area = _vm->logic()->area(cmdArea->room, areaNum); if (cmdArea->area > 0) { // turn on area area->mapNeighbours = ABS(area->mapNeighbours); @@ -1236,7 +1237,7 @@ void Command::setObjects(uint16 command) { // found an object uint16 dstObj = ABS(cmdObj->dstObj); - ObjectData *objData = _logic->objectData(dstObj); + ObjectData *objData = _vm->logic()->objectData(dstObj); debug(0, "Command::setObjects() - dstObj=%X srcObj=%X _curCmd.subject1=%X", cmdObj->dstObj, cmdObj->srcObj, _curCmd.subject1); @@ -1249,7 +1250,7 @@ void Command::setObjects(uint16 command) { // delete object by setting its name to 0 and // turning off graphic image objData->name = 0; - if (objData->room == _logic->currentRoom()) { + if (objData->room == _vm->logic()->currentRoom()) { if (dstObj != _curCmd.subject1) { // if the new object we have updated is on screen and is not the // current object, then we can update. This is because we turn @@ -1261,20 +1262,20 @@ void Command::setObjects(uint16 command) { } } // invalidate object area - uint16 objZone = dstObj - _logic->currentRoomData(); - _logic->zoneSet(ZONE_ROOM, objZone, 0, 0, 1, 1); + uint16 objZone = dstObj - _vm->logic()->currentRoomData(); + _vm->logic()->zoneSet(ZONE_ROOM, objZone, 0, 0, 1, 1); } } if (cmdObj->srcObj > 0) { // copy data from dummy object to object int16 image1 = objData->image; - int16 image2 = _logic->objectData(cmdObj->srcObj)->image; - _logic->objectCopy(cmdObj->srcObj, dstObj); - if (image1 != 0 && image2 == 0 && objData->room == _logic->currentRoom()) { - uint16 bobNum = _logic->findBob(dstObj); + int16 image2 = _vm->logic()->objectData(cmdObj->srcObj)->image; + _vm->logic()->objectCopy(cmdObj->srcObj, dstObj); + if (image1 != 0 && image2 == 0 && objData->room == _vm->logic()->currentRoom()) { + uint16 bobNum = _vm->logic()->findBob(dstObj); if (bobNum != 0) { - _graphics->bobClear(bobNum); + _vm->graphics()->bobClear(bobNum); } } } @@ -1282,7 +1283,7 @@ void Command::setObjects(uint16 command) { if (dstObj != _curCmd.subject1) { // if the new object we have updated is on screen and // is not current object then update it - _logic->roomRefreshObject(dstObj); + _vm->logic()->roomRefreshObject(dstObj); } } else { @@ -1292,7 +1293,7 @@ void Command::setObjects(uint16 command) { // may need to turn BOBs off for objects to be hidden on current // screen ! if the new object we have updated is on screen and // is not current object then update it - _logic->roomRefreshObject(dstObj); + _vm->logic()->roomRefreshObject(dstObj); } } } @@ -1305,7 +1306,7 @@ void Command::setItems(uint16 command) { debug(9, "Command::setItems(%d)", command); CmdInventory *cmdInv = &_cmdInventory[1]; - ItemData *items = _logic->itemData(0); + ItemData *items = _vm->logic()->itemData(0); uint16 i; for (i = 1; i <= _numCmdInventory; ++i, ++cmdInv) { if (cmdInv->id == command) { @@ -1319,12 +1320,12 @@ void Command::setItems(uint16 command) { // enable it items[dstItem].name = ABS(items[dstItem].name); } - _logic->inventoryInsertItem(cmdInv->dstItem); + _vm->logic()->inventoryInsertItem(cmdInv->dstItem); } else { // delete item if (items[dstItem].name > 0) { - _logic->inventoryDeleteItem(dstItem); + _vm->logic()->inventoryDeleteItem(dstItem); } if (cmdInv->srcItem > 0) { // copy data from source item to item @@ -1355,7 +1356,7 @@ uint16 Command::nextObjectDescription(ObjectDescription* objDesc, uint16 firstDe // already displayed first, do a random i = objDesc->lastSeenNumber; while (i == objDesc->lastSeenNumber) { - i = firstDesc + Logic::randomizer.getRandomNumber(diff); + i = firstDesc + _vm->randomizer.getRandomNumber(diff); } objDesc->lastSeenNumber = i; } @@ -1363,7 +1364,7 @@ uint16 Command::nextObjectDescription(ObjectDescription* objDesc, uint16 firstDe case 1: i = objDesc->lastSeenNumber; while (i == objDesc->lastSeenNumber) { - i = firstDesc + Logic::randomizer.getRandomNumber(diff); + i = firstDesc + _vm->randomizer.getRandomNumber(diff); } objDesc->lastSeenNumber = i; break; @@ -1387,53 +1388,53 @@ uint16 Command::nextObjectDescription(ObjectDescription* objDesc, uint16 firstDe void Command::look() { - if (_selCmd.noun > 0 && _selCmd.noun <= _logic->currentRoomObjMax()) { - uint16 objNum = _logic->currentRoomData() + _selCmd.noun; - if (_logic->objectData(objNum)->entryObj == 0) { + if (_selCmd.noun > 0 && _selCmd.noun <= _vm->logic()->currentRoomObjMax()) { + uint16 objNum = _vm->logic()->currentRoomData() + _selCmd.noun; + if (_vm->logic()->objectData(objNum)->entryObj == 0) { if (makeJoeWalkTo(_selPosX, _selPosY, objNum, _selCmd.action, false) == -2) { // XXX inCutaway parameter // 'I can't get close enough to have a look.' - _logic->joeSpeak(13); + _vm->logic()->joeSpeak(13); } } } // if object type and disabled, don't look - if (_curCmd.subject1 > 0 && _logic->objectData(_curCmd.subject1)->name <= 0) { + if (_curCmd.subject1 > 0 && _vm->logic()->objectData(_curCmd.subject1)->name <= 0) { return; } uint16 desc; if (_curCmd.subject1 < 0) { - desc = _logic->itemData(-_curCmd.subject1)->description; + desc = _vm->logic()->itemData(-_curCmd.subject1)->description; } else { - desc = _logic->objectData(_curCmd.subject1)->description; + desc = _vm->logic()->objectData(_curCmd.subject1)->description; } debug(0, "Command::look() - desc = %X, _curCmd.subject1 = %X", desc, _curCmd.subject1); // check to see if the object/item has a series of description - ObjectDescription *objDesc = _logic->objectDescription(1); + ObjectDescription *objDesc = _vm->logic()->objectDescription(1); uint16 i; - for (i = 1; i <= _logic->objectDescriptionCount(); ++i, ++objDesc) { + for (i = 1; i <= _vm->logic()->objectDescriptionCount(); ++i, ++objDesc) { if (objDesc->object == _curCmd.subject1) { desc = nextObjectDescription(objDesc, desc); break; } } - _logic->joeSpeak(desc, true); - _logic->joeFace(); + _vm->logic()->joeSpeak(desc, true); + _vm->logic()->joeFace(); } void Command::lookCurrentItem() { if (_curCmd.verb.isInventory()) { - uint16 item = _logic->findInventoryItem(_curCmd.verb.inventoryItem()); + uint16 item = _vm->logic()->findInventoryItem(_curCmd.verb.inventoryItem()); if (item != 0) { - ItemData *itemData = _logic->itemData(item); - const char *name = _logic->objectName(itemData->name); + ItemData *itemData = _vm->logic()->itemData(item); + const char *name = _vm->logic()->objectName(itemData->name); if (_curCmd.action.isNone()) { Verb v = State::findDefaultVerb(itemData->state); _cmdText.setVerb(v.isNone() ? Verb(VERB_LOOK_AT) : v); @@ -1453,19 +1454,19 @@ void Command::lookCurrentItem() { void Command::lookCurrentRoom() { - _curCmd.noun = _logic->findObjectUnderCursor(_input->mousePosX(), _input->mousePosY()); + _curCmd.noun = _vm->logic()->findObjectUnderCursor(_vm->input()->mousePosX(), _vm->input()->mousePosY()); - if (_logic->joeWalk() == JWM_MOVE) { + if (_vm->logic()->joeWalk() == JWM_MOVE) { return; } int16 aObjName = 0; - uint16 k = _logic->currentRoomData(); + uint16 k = _vm->logic()->currentRoomData(); int16 i = 0; - if (_curCmd.noun > _logic->currentRoomObjMax()) { - uint16 obj = _logic->currentRoomArea(_curCmd.noun - _logic->currentRoomObjMax())->object; + if (_curCmd.noun > _vm->logic()->currentRoomObjMax()) { + uint16 obj = _vm->logic()->currentRoomArea(_curCmd.noun - _vm->logic()->currentRoomObjMax())->object; if (obj) { - aObjName = _logic->objectData(obj)->name; + aObjName = _vm->logic()->objectData(obj)->name; if (aObjName > 0) { i = aObjName; _curCmd.noun = obj - k; @@ -1473,7 +1474,7 @@ void Command::lookCurrentRoom() { } } else { - i = _logic->objectData(k + _curCmd.noun)->name; + i = _vm->logic()->objectData(k + _curCmd.noun)->name; } if (_curCmd.oldNoun == _curCmd.noun) { @@ -1484,7 +1485,7 @@ void Command::lookCurrentRoom() { // if the AREA is linked to an object, then dont exit. Find // the object its linked to && store in AOBJ - if (_curCmd.noun > _logic->currentRoomObjMax() && aObjName <= 0) { + if (_curCmd.noun > _vm->logic()->currentRoomObjMax() && aObjName <= 0) { if (_curCmd.oldNoun != 0) { if (!_selCmd.defaultVerb.isNone()) { _cmdText.displayTemp(INK_CMD_LOCK, true, _selCmd.defaultVerb); @@ -1499,7 +1500,7 @@ void Command::lookCurrentRoom() { if (i <= 0) { _curCmd.oldNoun = _curCmd.noun; - _graphics->textClear(CmdText::COMMAND_Y_POS, CmdText::COMMAND_Y_POS); + _vm->graphics()->textClear(CmdText::COMMAND_Y_POS, CmdText::COMMAND_Y_POS); if (!_selCmd.defaultVerb.isNone()) { _cmdText.displayTemp(INK_CMD_LOCK, true, _selCmd.defaultVerb); } @@ -1511,7 +1512,7 @@ void Command::lookCurrentRoom() { // if no command yet selected, then use DEFAULT command, if any if (_curCmd.action.isNone()) { - Verb v = State::findDefaultVerb(_logic->objectData(k + _curCmd.noun)->state); + Verb v = State::findDefaultVerb(_vm->logic()->objectData(k + _curCmd.noun)->state); _cmdText.setVerb(v.isNone() ? Verb(VERB_WALK_TO) : v); if (_curCmd.noun == 0) { _cmdText.clear(); @@ -1519,7 +1520,7 @@ void Command::lookCurrentRoom() { } const char *objName = ""; if (_curCmd.noun > 0) { - objName = _logic->objectName(i); + objName = _vm->logic()->objectName(i); } if (!_selCmd.defaultVerb.isNone()) { _cmdText.displayTemp(INK_CMD_LOCK, true, _selCmd.defaultVerb, objName); @@ -1533,13 +1534,13 @@ void Command::lookCurrentRoom() { void Command::lookCurrentIcon() { - _curCmd.verb = _logic->findVerbUnderCursor(_input->mousePosX(), _input->mousePosY()); - if (_curCmd.verb != _curCmd.oldVerb && _logic->joeWalk() != JWM_MOVE) { + _curCmd.verb = _vm->logic()->findVerbUnderCursor(_vm->input()->mousePosX(), _vm->input()->mousePosY()); + if (_curCmd.verb != _curCmd.oldVerb && _vm->logic()->joeWalk() != JWM_MOVE) { if (_curCmd.action.isNone()) { _cmdText.clear(); } - _graphics->textClear(CmdText::COMMAND_Y_POS, CmdText::COMMAND_Y_POS); + _vm->graphics()->textClear(CmdText::COMMAND_Y_POS, CmdText::COMMAND_Y_POS); lookCurrentItem(); // ensure that registers when move to top screen diff --git a/queen/command.h b/queen/command.h index bc4e256445..3c04451840 100644 --- a/queen/command.h +++ b/queen/command.h @@ -28,11 +28,7 @@ namespace Queen { -class Logic; -class Graphics; -class Input; -class Walk; -class Sound; +class QueenEngine; struct CmdText { @@ -51,8 +47,7 @@ struct CmdText { }; char _command[MAX_COMMAND_LEN]; - Graphics *_graphics; - Logic *_logic; + QueenEngine *_vm; }; @@ -81,11 +76,10 @@ struct SelectedCmdState { int16 noun; }; - class Command { public: - Command(Logic *, Graphics *, Input *, Walk *, Sound *); + Command(QueenEngine *vm); //! initialise command construction void clear(bool clearTexts); @@ -186,12 +180,7 @@ private: //! last user selection int _mouseKey, _selPosX, _selPosY; - Logic *_logic; - Graphics *_graphics; - Input *_input; - Sound *_sound; - Walk *_walk; - + QueenEngine *_vm; }; } // End of namespace Queen diff --git a/queen/cutaway.cpp b/queen/cutaway.cpp index bab72c2a4f..6b9467c6bd 100644 --- a/queen/cutaway.cpp +++ b/queen/cutaway.cpp @@ -21,10 +21,12 @@ #include "stdafx.h" #include "queen/cutaway.h" + #include "queen/display.h" #include "queen/graphics.h" #include "queen/input.h" #include "queen/logic.h" +#include "queen/queen.h" #include "queen/resource.h" #include "queen/sound.h" #include "queen/talk.h" @@ -48,27 +50,18 @@ namespace Queen { void Cutaway::run( const char *filename, char *nextFilename, - Graphics *graphics, - Input *input, - Logic *logic, - Resource *resource, - Sound *sound) { - Cutaway *cutaway = new Cutaway(filename, graphics, input, logic, resource, sound); + QueenEngine *vm) { + Cutaway *cutaway = new Cutaway(filename, vm); cutaway->run(nextFilename); delete cutaway; } Cutaway::Cutaway( const char *filename, - Graphics *graphics, - Input *input, - Logic *logic, - Resource *resource, - Sound *sound) -: _graphics(graphics), _input(input), _logic(logic), _resource(resource), _sound(sound), _walk(logic->walk()), - _personDataCount(0), _personFaceCount(0), _lastSong(0), _songBeforeComic(0) { + QueenEngine *vm) + : _vm(vm), _personDataCount(0), _personFaceCount(0), _lastSong(0), _songBeforeComic(0) { memset(&_bankNames, 0, sizeof(_bankNames)); - _input->cutawayQuitReset(); + _vm->input()->cutawayQuitReset(); load(filename); } @@ -81,7 +74,7 @@ void Cutaway::load(const char *filename) { debug(0, "----- Cutaway::load(\"%s\") -----", filename); - ptr = _fileData = _resource->loadFile(filename, 20); + ptr = _fileData = _vm->resource()->loadFile(filename, 20); if (!_fileData) { error("Failed to load resource data file '%s'", filename); } @@ -102,17 +95,17 @@ void Cutaway::load(const char *filename) { if (_cutawayObjectCount < 0) { _cutawayObjectCount = -_cutawayObjectCount; - _input->canQuit(false); + _vm->input()->canQuit(false); } else - _input->canQuit(true); + _vm->input()->canQuit(true); int16 flags1 = (int16)READ_BE_UINT16(ptr); ptr += 2; debug(0, "flags1 = %i", flags1); if (flags1 < 0) { - _logic->entryObj(0); + _vm->logic()->entryObj(0); _finalRoom = -flags1; } else @@ -143,31 +136,31 @@ void Cutaway::load(const char *filename) { if (_bankNames[0][0]) { debug(0, "Loading bank '%s'", _bankNames[0]); - _graphics->bankLoad(_bankNames[0], CUTAWAY_BANK); + _vm->graphics()->bankLoad(_bankNames[0], CUTAWAY_BANK); } char entryString[MAX_STRING_SIZE]; _nextSentence = Talk::getString(_nextSentence, entryString, MAX_STRING_LENGTH); debug(0, "Entry string = '%s'", entryString); - _logic->joeCutFacing(_logic->joeFacing()); - _logic->joeFace(); + _vm->logic()->joeCutFacing(_vm->logic()->joeFacing()); + _vm->logic()->joeFace(); if (entryString[0] == '*' && entryString[1] == 'F' && entryString[3] == '\0') { switch (entryString[2]) { case 'L': - _logic->joeCutFacing(DIR_LEFT); + _vm->logic()->joeCutFacing(DIR_LEFT); break; case 'R': - _logic->joeCutFacing(DIR_RIGHT); + _vm->logic()->joeCutFacing(DIR_RIGHT); break; case 'F': - _logic->joeCutFacing(DIR_FRONT); + _vm->logic()->joeCutFacing(DIR_FRONT); break; case 'B': - _logic->joeCutFacing(DIR_BACK); + _vm->logic()->joeCutFacing(DIR_BACK); break; } } @@ -254,7 +247,7 @@ void Cutaway::dumpCutawayObject(int index, CutawayObject &object) objectNumberStr = "Joe"; break; default: if (object.objectNumber > 0) - objectNumberStr = _logic->objectName(ABS(_logic->objectData(object.objectNumber)->name)); + objectNumberStr = _vm->logic()->objectName(ABS(_vm->logic()->objectData(object.objectNumber)->name)); else objectNumberStr = "Unknown!"; break; @@ -308,7 +301,7 @@ void Cutaway::limitBob(CutawayObject &object) { } BobSlot *bob = - _graphics->bob( _logic->findBob(object.objectNumber) ); + _vm->graphics()->bob( _vm->logic()->findBob(object.objectNumber) ); if (!bob) { warning("Failed to find bob"); @@ -325,7 +318,7 @@ void Cutaway::limitBob(CutawayObject &object) { void Cutaway::restorePersonData() { for (int i = 0; i < _personDataCount; i++) { int index = _personData[i].index; - ObjectData *objectData = _logic->objectData(index); + ObjectData *objectData = _vm->logic()->objectData(index); objectData->name = _personData[i].name; objectData->image = _personData[i].image; } @@ -342,11 +335,11 @@ void Cutaway::changeRooms(CutawayObject &object) { _personDataCount = 0; if (_finalRoom != object.room) { - int firstObjectInRoom = _logic->roomData(object.room) + 1; - int lastObjectInRoom = _logic->roomData(object.room) + _logic->objMax(object.room); + int firstObjectInRoom = _vm->logic()->roomData(object.room) + 1; + int lastObjectInRoom = _vm->logic()->roomData(object.room) + _vm->logic()->objMax(object.room); for (int i = firstObjectInRoom; i <= lastObjectInRoom; i++) { - ObjectData *objectData = _logic->objectData(i); + ObjectData *objectData = _vm->logic()->objectData(i); if (objectData->image == -3 || objectData->image == -4) { @@ -366,7 +359,7 @@ void Cutaway::changeRooms(CutawayObject &object) { } /*debug(0, "Person '%s' (%i) is %s", - _logic->objectName(objectData->name), + _vm->logic()->objectName(objectData->name), objectData->name, on ? "on" : "off");*/ @@ -385,17 +378,17 @@ void Cutaway::changeRooms(CutawayObject &object) { // set coordinates for Joe if he is on screen - _logic->joeX(0); - _logic->joeY(0); + _vm->logic()->joeX(0); + _vm->logic()->joeY(0); for (int i = 0; i < object.personCount; i++) { if (PERSON_JOE == object.person[i]) { - _logic->joeX(object.bobStartX); - _logic->joeY(object.bobStartY); + _vm->logic()->joeX(object.bobStartX); + _vm->logic()->joeY(object.bobStartY); } } - _logic->oldRoom(_initialRoom); + _vm->logic()->oldRoom(_initialRoom); // FIXME: this cutaway is played at the end of the command 0x178. This command // setups some persons and associates bob slots to them. They should be hidden @@ -414,7 +407,7 @@ void Cutaway::changeRooms(CutawayObject &object) { RoomDisplayMode mode; - if (!_logic->joeX() && !_logic->joeY()) { + if (!_vm->logic()->joeX() && !_vm->logic()->joeY()) { mode = RDM_FADE_NOJOE; } else { @@ -425,11 +418,11 @@ void Cutaway::changeRooms(CutawayObject &object) { mode = RDM_FADE_JOE_XY; } - _logic->roomDisplay(_logic->currentRoom(), mode, object.scale, comPanel, true); + _vm->logic()->roomDisplay(_vm->logic()->currentRoom(), mode, object.scale, comPanel, true); - _currentImage = _logic->numFrames(); + _currentImage = _vm->logic()->numFrames(); - _temporaryRoom = _logic->currentRoom(); + _temporaryRoom = _vm->logic()->currentRoom(); restorePersonData(); } @@ -442,7 +435,7 @@ Cutaway::ObjectType Cutaway::getObjectType(CutawayObject &object) { if (object.objectNumber > 0) { if (!object.animList) { // No anim frames, so treat as a PERSON, ie. allow to speak/walk - ObjectData *objectData = _logic->objectData(object.objectNumber); + ObjectData *objectData = _vm->logic()->objectData(object.objectNumber); if (objectData->image == -3 || objectData->image == -4) objectType = OBJECT_TYPE_PERSON; } @@ -459,15 +452,15 @@ Cutaway::ObjectType Cutaway::getObjectType(CutawayObject &object) { /* Copy FROM_OBJECT into OBJECT */ if(object.objectNumber != object.fromObject) { - _logic->objectCopy(object.fromObject, object.objectNumber); + _vm->logic()->objectCopy(object.fromObject, object.objectNumber); } else { // Same object, so just turn it on! - ObjectData *objectData = _logic->objectData(object.objectNumber); + ObjectData *objectData = _vm->logic()->objectData(object.objectNumber); objectData->name = ABS(objectData->name); } - _logic->roomRefreshObject(object.objectNumber); + _vm->logic()->roomRefreshObject(object.objectNumber); // Skip doing any anim stuff objectType = OBJECT_TYPE_NO_ANIMATION; @@ -512,20 +505,20 @@ byte *Cutaway::getCutawayAnim(byte *ptr, int header, CutawayAnim &anim) { anim.originalFrame = 29 + FRAMES_JOE_XTRA; // 21/9/94, Make sure that bobs are clipped on 150 screens - if (_logic->display()->fullscreen()) - _graphics->bob(0)->box.y2 = 199; + if (_vm->display()->fullscreen()) + _vm->graphics()->bob(0)->box.y2 = 199; } else { //warning("Stuff not yet implemented in Cutaway::getCutawayAnim()"); - anim.object = _logic->findBob(header); + anim.object = _vm->logic()->findBob(header); // If fullscreen cutaway then clip to 199 down // 21/9/94, Make sure that bobs are clipped on 150 screens // XXX if(COMPANEL==2 && OBJ_CUT[6]<=0 && BDyres==200) bobs[Param].y2=199; - anim.originalFrame = _logic->findFrame(header); + anim.originalFrame = _vm->logic()->findFrame(header); } anim.unpackFrame = (int16)READ_BE_UINT16(ptr); @@ -544,7 +537,7 @@ byte *Cutaway::getCutawayAnim(byte *ptr, int header, CutawayAnim &anim) { if (anim.bank != 13) { /* XXX if (OLDBANK != T) */ { //debug(0, "Loading bank '%s'", _bankNames[anim.bank-1]); - _graphics->bankLoad(_bankNames[anim.bank-1], CUTAWAY_BANK); + _vm->graphics()->bankLoad(_bankNames[anim.bank-1], CUTAWAY_BANK); // XXX OLDBANK=T; } @@ -571,7 +564,7 @@ byte *Cutaway::getCutawayAnim(byte *ptr, int header, CutawayAnim &anim) { anim.scale = (int16)READ_BE_UINT16(ptr); ptr += 2; - if (_resource->isDemo()) { + if (_vm->resource()->isDemo()) { anim.song = 0; } else { @@ -633,7 +626,7 @@ byte *Cutaway::handleAnimation(byte *ptr, CutawayObject &object) { frameCount++; - if (_input->cutawayQuit()) + if (_vm->input()->cutawayQuit()) return NULL; } @@ -642,17 +635,17 @@ byte *Cutaway::handleAnimation(byte *ptr, CutawayObject &object) { debug(0, "----- Complex cutaway animation (animType = %i) -----", object.animType); - if ((_logic->currentRoom() == 47 || _logic->currentRoom() == 63) && + if ((_vm->logic()->currentRoom() == 47 || _vm->logic()->currentRoom() == 63) && objAnim[0].object == 1) { //CR 2 - 3/3/95, Special harcoded section to make Oracle work... - makeComplexAnimation(_logic->personFrames(1) - 1, objAnim, frameCount); + makeComplexAnimation(_vm->logic()->personFrames(1) - 1, objAnim, frameCount); } else { _currentImage = makeComplexAnimation(_currentImage, objAnim, frameCount); } if (object.bobStartX || object.bobStartY) { - BobSlot *bob = _graphics->bob(objAnim[0].object); + BobSlot *bob = _vm->graphics()->bob(objAnim[0].object); bob->x = object.bobStartX; bob->y = object.bobStartY; } @@ -662,12 +655,12 @@ byte *Cutaway::handleAnimation(byte *ptr, CutawayObject &object) { for (i = 0; i < frameCount; i++) { if (objAnim[i].mx || objAnim[i].my) { - BobSlot *bob = _graphics->bob(objAnim[i].object); + BobSlot *bob = _vm->graphics()->bob(objAnim[i].object); bob->frameNum = objAnim[i].originalFrame; bob->move(objAnim[i].mx, objAnim[i].my, (object.specialMove > 0) ? object.specialMove : 4); // Boat room hard coded - if (_logic->currentRoom() == ROOM_TEMPLE_OUTSIDE) { - BobSlot *bobJoe = _graphics->bob(0); + if (_vm->logic()->currentRoom() == ROOM_TEMPLE_OUTSIDE) { + BobSlot *bobJoe = _vm->graphics()->bob(0); if (bobJoe->x < 320) { bobJoe->move(bobJoe->x + 346, bobJoe->y, 4); } @@ -686,7 +679,7 @@ byte *Cutaway::handleAnimation(byte *ptr, CutawayObject &object) { //debug(0, "===== Animating frame %i =====", i); //dumpCutawayAnim(objAnim[i]); - BobSlot *bob = _graphics->bob(objAnim[i].object); + BobSlot *bob = _vm->graphics()->bob(objAnim[i].object); bob->active = true; if (bob->animating) { bob->animating = false; @@ -709,7 +702,7 @@ byte *Cutaway::handleAnimation(byte *ptr, CutawayObject &object) { objAnim[i].unpackFrame, objAnim[i].originalFrame, objAnim[i].bank);*/ - _graphics->bankUnpack( + _vm->graphics()->bankUnpack( objAnim[i].unpackFrame, objAnim[i].originalFrame, objAnim[i].bank); @@ -738,14 +731,14 @@ byte *Cutaway::handleAnimation(byte *ptr, CutawayObject &object) { int j; for (j = 0; j < objAnim[i].speed; j++) - _logic->update(); + _vm->logic()->update(); } - if (_input->cutawayQuit()) + if (_vm->input()->cutawayQuit()) return NULL; if (objAnim[i].song > 0) - _sound->playSong(objAnim[i].song); + _vm->sound()->playSong(objAnim[i].song); // Load but don't play if(objAnim[i].song < 0) { @@ -761,17 +754,17 @@ byte *Cutaway::handleAnimation(byte *ptr, CutawayObject &object) { while (moving) { moving = false; - _logic->update(); + _vm->logic()->update(); for (i = 0; i < frameCount; i++) { - BobSlot *bob = _graphics->bob(objAnim[i].object); + BobSlot *bob = _vm->graphics()->bob(objAnim[i].object); if (bob->moving) { moving = true; break; } } - if (_input->cutawayQuit()) + if (_vm->input()->cutawayQuit()) return NULL; } @@ -800,31 +793,31 @@ void Cutaway::handlePersonRecord( if (object.objectNumber == OBJECT_JOE) { if (object.moveToX || object.moveToY) { - _walk->moveJoe(0, object.moveToX, object.moveToY, true); + _vm->walk()->moveJoe(0, object.moveToX, object.moveToY, true); } } else { - _logic->personSetData( - object.objectNumber - _logic->roomData(_logic->currentRoom()), + _vm->logic()->personSetData( + object.objectNumber - _vm->logic()->currentRoomData(), "", true, &p); if (object.bobStartX || object.bobStartY) { - BobSlot *bob = _graphics->bob(p.actor->bobNum); + BobSlot *bob = _vm->graphics()->bob(p.actor->bobNum); bob->scale = scale(object); bob->x = object.bobStartX; bob->y = object.bobStartY; } if (object.moveToX || object.moveToY) - _walk->movePerson( + _vm->walk()->movePerson( &p, object.moveToX, object.moveToY, _currentImage + 1, // XXX CI+1 - _logic->objectData(object.objectNumber)->image + _vm->logic()->objectData(object.objectNumber)->image ); } - if (_input->cutawayQuit()) + if (_vm->input()->cutawayQuit()) return; if (0 != strcmp(sentence, "*")) { @@ -846,18 +839,18 @@ void Cutaway::handlePersonRecord( if (!foundPerson) { _personFaceCount++; _personFace[_personFaceCount].index = object.objectNumber; - _personFace[_personFaceCount].image = _logic->objectData(object.objectNumber)->image; + _personFace[_personFaceCount].image = _vm->logic()->objectData(object.objectNumber)->image; } } char voiceFilePrefix[MAX_STRING_SIZE]; findCdCut(_basename, index, voiceFilePrefix); - _logic->makePersonSpeak(sentence, (object.objectNumber == OBJECT_JOE) ? NULL : &p, voiceFilePrefix); + _vm->logic()->makePersonSpeak(sentence, (object.objectNumber == OBJECT_JOE) ? NULL : &p, voiceFilePrefix); } } - if (_input->cutawayQuit()) + if (_vm->input()->cutawayQuit()) return; } @@ -865,21 +858,21 @@ void Cutaway::run(char *nextFilename) { int i; nextFilename[0] = '\0'; - _currentImage = _logic->numFrames(); + _currentImage = _vm->logic()->numFrames(); - BobSlot *joeBob = _graphics->bob(0); + BobSlot *joeBob = _vm->graphics()->bob(0); int initialJoeX = joeBob->x; int initialJoeY = joeBob->y; debug(0, "[Cutaway::run] Joe started at (%i, %i)", initialJoeX, initialJoeY); - _input->cutawayRunning(true); + _vm->input()->cutawayRunning(true); - _initialRoom = _temporaryRoom = _logic->currentRoom(); + _initialRoom = _temporaryRoom = _vm->logic()->currentRoom(); - _logic->display()->screenMode(_comPanel, true); + _vm->display()->screenMode(_comPanel, true); if (_comPanel == 0 || _comPanel == 2) { - _logic->sceneStart(); + _vm->logic()->sceneStart(); } byte *ptr = _objectData; @@ -893,17 +886,17 @@ void Cutaway::run(char *nextFilename) { !object.moveToY && object.specialMove && object.objectNumber >= 0) { - _logic->executeSpecialMove(object.specialMove); + _vm->logic()->executeSpecialMove(object.specialMove); object.specialMove = 0; } if (CURRENT_ROOM == object.room) { // Get current room - object.room = _logic->currentRoom(); + object.room = _vm->logic()->currentRoom(); } else { // Change current room - _logic->currentRoom(object.room); + _vm->logic()->currentRoom(object.room); } ptr = turnOnPeople(ptr, object); @@ -928,7 +921,7 @@ void Cutaway::run(char *nextFilename) { ObjectType objectType = getObjectType(object); if (object.song) - _sound->playSong(object.song); + _vm->sound()->playSong(object.song); switch (objectType) { case OBJECT_TYPE_ANIMATION: @@ -954,17 +947,17 @@ void Cutaway::run(char *nextFilename) { break; } - if (_input->cutawayQuit()) + if (_vm->input()->cutawayQuit()) break; if (_roomFade) { - _logic->update(); + _vm->logic()->update(); int end = 223; - if (IS_CD_INTRO_ROOM(_logic->currentRoom())) { + if (IS_CD_INTRO_ROOM(_vm->logic()->currentRoom())) { end = 255; } - BobSlot *j = _graphics->bob(0); - _logic->display()->palFadeIn(0, end, _logic->currentRoom(), j->active, j->x, j->y); + BobSlot *j = _vm->graphics()->bob(0); + _vm->display()->palFadeIn(0, end, _vm->logic()->currentRoom(), j->active, j->x, j->y); _roomFade = false; } @@ -972,26 +965,26 @@ void Cutaway::run(char *nextFilename) { stop(); - _input->cutawayQuitReset(); + _vm->input()->cutawayQuitReset(); updateGameState(); - _graphics->bankErase(CUTAWAY_BANK); + _vm->graphics()->bankErase(CUTAWAY_BANK); talk(nextFilename); if (_comPanel == 0 || (_comPanel == 2 && !_anotherCutaway)) { - _logic->sceneStop(); + _vm->logic()->sceneStop(); _comPanel = 0; } if (nextFilename[0] == '\0' && !_anotherCutaway) { - _logic->display()->fullscreen(false); + _vm->display()->fullscreen(false); // Lines 2138-2182 in cutaway.c if (_finalRoom) { - _logic->newRoom(0); - _logic->entryObj(0); + _vm->logic()->newRoom(0); + _vm->logic()->entryObj(0); } else { /// No need to stay in current room, so return to previous room @@ -999,55 +992,55 @@ void Cutaway::run(char *nextFilename) { restorePersonData(); - debug(0, "_logic->entryObj() = %i", _logic->entryObj()); - if (_logic->entryObj() > 0) { - _initialRoom = _logic->objectData(_logic->entryObj())->room; + debug(0, "_vm->logic()->entryObj() = %i", _vm->logic()->entryObj()); + if (_vm->logic()->entryObj() > 0) { + _initialRoom = _vm->logic()->objectData(_vm->logic()->entryObj())->room; } else { // We're not returning to new room, so return to old Joe X,Y coords debug(0, "[Cutaway::run] Moving joe to (%i, %i)", initialJoeX, initialJoeY); - _logic->joeX(initialJoeX); - _logic->joeY(initialJoeY); + _vm->logic()->joeX(initialJoeX); + _vm->logic()->joeY(initialJoeY); } - if (_logic->currentRoom() != _initialRoom) { - _logic->currentRoom(_initialRoom); - _logic->changeRoom(); - if (_logic->currentRoom() == _logic->newRoom()) { - _logic->newRoom(0); + if (_vm->logic()->currentRoom() != _initialRoom) { + _vm->logic()->currentRoom(_initialRoom); + _vm->logic()->changeRoom(); + if (_vm->logic()->currentRoom() == _vm->logic()->newRoom()) { + _vm->logic()->newRoom(0); } } - _logic->joeX(0); - _logic->joeY(0); + _vm->logic()->joeX(0); + _vm->logic()->joeY(0); } - _logic->joeCutFacing(0); + _vm->logic()->joeCutFacing(0); _comPanel = 0; int k = 0; - for (i = _logic->roomData(_logic->currentRoom()); - i <= _logic->roomData(_logic->currentRoom() + 1); i++) { + for (i = _vm->logic()->roomData(_vm->logic()->currentRoom()); + i <= _vm->logic()->roomData(_vm->logic()->currentRoom() + 1); i++) { - ObjectData *object = _logic->objectData(i); + ObjectData *object = _vm->logic()->objectData(i); if (object->image == -3 || object->image == -4) { k++; if (object->name > 0) { - _logic->animReset(k); + _vm->logic()->animReset(k); } } } // function CUTAWAY_SPECIAL(), lines 885-896 in cutaway.c - if (_logic->currentRoom() == 1 && _logic->gameState(3) == 0) { + if (_vm->logic()->currentRoom() == 1 && _vm->logic()->gameState(3) == 0) { // XXX hard-coded room and inventory items - _logic->inventoryDeleteItem(ITEM_CROWBAR, false); - _logic->inventoryDeleteItem(ITEM_DRESS, false); - _logic->inventoryDeleteItem(ITEM_CLOTHES, false); - _logic->inventoryDeleteItem(ITEM_HAY, false); - _logic->inventoryDeleteItem(ITEM_OIL, false); - _logic->inventoryDeleteItem(ITEM_CHICKEN, false); - _logic->gameState(3, 1); - _logic->inventoryRefresh(); + _vm->logic()->inventoryDeleteItem(ITEM_CROWBAR, false); + _vm->logic()->inventoryDeleteItem(ITEM_DRESS, false); + _vm->logic()->inventoryDeleteItem(ITEM_CLOTHES, false); + _vm->logic()->inventoryDeleteItem(ITEM_HAY, false); + _vm->logic()->inventoryDeleteItem(ITEM_OIL, false); + _vm->logic()->inventoryDeleteItem(ITEM_CHICKEN, false); + _vm->logic()->gameState(3, 1); + _vm->logic()->inventoryRefresh(); } } @@ -1057,13 +1050,13 @@ void Cutaway::run(char *nextFilename) { // Make sure Joe is clipped! joeBob->box.y2 = 149; - _input->cutawayRunning(false); - _input->cutawayQuitReset(); + _vm->input()->cutawayRunning(false); + _vm->input()->cutawayQuitReset(); if (_songBeforeComic > 0) - _sound->playSong(_songBeforeComic); + _vm->sound()->playSong(_songBeforeComic); else if (_lastSong > 0) - _sound->playSong(_lastSong); + _vm->sound()->playSong(_lastSong); } void Cutaway::stop() { @@ -1084,34 +1077,34 @@ void Cutaway::stop() { debug(0, "[Cutaway::stop] Final position is room %i and coordinates (%i, %i)", joeRoom, joeX, joeY); - if ((!_input->cutawayQuit() || (!_anotherCutaway && joeRoom == _finalRoom)) && + if ((!_vm->input()->cutawayQuit() || (!_anotherCutaway && joeRoom == _finalRoom)) && joeRoom != _temporaryRoom && joeRoom != 0) { debug(0, "[Cutaway::stop] Changing rooms and moving Joe"); - _logic->joeX(joeX); - _logic->joeY(joeY); - _logic->currentRoom(joeRoom); - _logic->oldRoom(_initialRoom); - _logic->roomDisplay(_logic->currentRoom(), RDM_FADE_JOE_XY, 0, _comPanel, true); + _vm->logic()->joeX(joeX); + _vm->logic()->joeY(joeY); + _vm->logic()->currentRoom(joeRoom); + _vm->logic()->oldRoom(_initialRoom); + _vm->logic()->roomDisplay(_vm->logic()->currentRoom(), RDM_FADE_JOE_XY, 0, _comPanel, true); } - if (_input->cutawayQuit()) { + if (_vm->input()->cutawayQuit()) { // Lines 1927-2032 in cutaway.c int i; // Stop the credits from running // XXX CFlag = 0; - _graphics->bobStopAll(); + _vm->graphics()->bobStopAll(); for (i = 1; i <= _personFaceCount; i++) { int index = _personFace[i].index; if (index > 0) { - _logic->objectData(_personFace[i].index)->image = _personFace[i].image; + _vm->logic()->objectData(_personFace[i].index)->image = _personFace[i].image; - _graphics->bob(_logic->findBob(index))->xflip = + _vm->graphics()->bob(_vm->logic()->findBob(index))->xflip = (_personFace[i].image != -4); } } @@ -1127,8 +1120,8 @@ void Cutaway::stop() { int16 frame = (int16)READ_BE_UINT16(ptr); ptr += 2; int16 bank = (int16)READ_BE_UINT16(ptr); ptr += 2; - int bobIndex = _logic->findBob(objectIndex); - ObjectData *object = _logic->objectData(objectIndex); + int bobIndex = _vm->logic()->findBob(objectIndex); + ObjectData *object = _vm->logic()->objectData(objectIndex); if (fromIndex > 0) { if (fromIndex == objectIndex) { @@ -1136,25 +1129,25 @@ void Cutaway::stop() { object->name = ABS(object->name); } else { - _logic->objectCopy(fromIndex, objectIndex); + _vm->logic()->objectCopy(fromIndex, objectIndex); - ObjectData *from = _logic->objectData(fromIndex); - if (object->image && !from->image && bobIndex && _logic->currentRoom() == object->room) - _graphics->bobClear(bobIndex); + ObjectData *from = _vm->logic()->objectData(fromIndex); + if (object->image && !from->image && bobIndex && _vm->logic()->currentRoom() == object->room) + _vm->graphics()->bobClear(bobIndex); } - if (_logic->currentRoom() == room) - _logic->roomRefreshObject(objectIndex); + if (_vm->logic()->currentRoom() == room) + _vm->logic()->roomRefreshObject(objectIndex); } - if (_logic->currentRoom() == object->room) { - BobSlot *pbs = _graphics->bob(bobIndex); + if (_vm->logic()->currentRoom() == object->room) { + BobSlot *pbs = _vm->graphics()->bob(bobIndex); if (x || y) { pbs->x = x; pbs->y = y; if (InRange(object->image, -4, -3)) - pbs->scale = _logic->findScale(x, y); + pbs->scale = _vm->logic()->findScale(x, y); } if (frame) { @@ -1162,19 +1155,19 @@ void Cutaway::stop() { bank = 15; else if (bank != 13) { // XXX if(bank != oldBank) { - _graphics->bankLoad(_bankNames[bank-1], CUTAWAY_BANK); + _vm->graphics()->bankLoad(_bankNames[bank-1], CUTAWAY_BANK); // XXX oldBank = bank; // XXX } bank = 8; } - int objectFrame = _logic->findFrame(objectIndex); + int objectFrame = _vm->logic()->findFrame(objectIndex); if (objectFrame == 1000) { - _graphics->bobClear(bobIndex); + _vm->graphics()->bobClear(bobIndex); } else if (objectFrame) { - _graphics->bankUnpack(ABS(frame), objectFrame, bank); + _vm->graphics()->bankUnpack(ABS(frame), objectFrame, bank); pbs->frameNum = objectFrame; if (frame < 0) pbs->xflip = true; @@ -1185,7 +1178,7 @@ void Cutaway::stop() { } // for() int16 specialMove = (int16)READ_BE_UINT16(ptr); ptr += 2; - _logic->executeSpecialMove(specialMove); + _vm->logic()->executeSpecialMove(specialMove); _lastSong = (int16)READ_BE_UINT16(ptr); ptr += 2; } @@ -1195,14 +1188,14 @@ void Cutaway::stop() { joeRoom != 105 && // XXX hard coded room number joeRoom != 106 && // XXX hard coded room number (joeX || joeY)) { - BobSlot *joeBob = _graphics->bob(0); + BobSlot *joeBob = _vm->graphics()->bob(0); debug(0, "[Cutaway::stop] Moving Joe"); joeBob->x = joeX; joeBob->y = joeY; - _logic->joeScale(_logic->findScale(joeX, joeY)); - _logic->joeFace(); + _vm->logic()->joeScale(_vm->logic()->findScale(joeX, joeY)); + _vm->logic()->joeFace(); } } @@ -1223,11 +1216,11 @@ void Cutaway::updateGameState() { bool update = false; if (stateIndex > 0) { - if(_logic->gameState(stateIndex) == stateValue) + if(_vm->logic()->gameState(stateIndex) == stateValue) update = true; } else { - _logic->gameState(ABS(stateIndex), stateValue); + _vm->logic()->gameState(ABS(stateIndex), stateValue); update = true; } @@ -1236,17 +1229,17 @@ void Cutaway::updateGameState() { // Show or hide an object if (objectIndex > 0) { // Show the object - ObjectData *objectData = _logic->objectData(objectIndex); + ObjectData *objectData = _vm->logic()->objectData(objectIndex); objectData->name = ABS(objectData->name); if (fromObject > 0) - _logic->objectCopy(fromObject, objectIndex); - _logic->roomRefreshObject(objectIndex); + _vm->logic()->objectCopy(fromObject, objectIndex); + _vm->logic()->roomRefreshObject(objectIndex); } else if (objectIndex < 0) { // Hide the object objectIndex = -objectIndex; - ObjectData *objectData = _logic->objectData(objectIndex); + ObjectData *objectData = _vm->logic()->objectData(objectIndex); objectData->name = -ABS(objectData->name); - _logic->roomRefreshObject(objectIndex); + _vm->logic()->roomRefreshObject(objectIndex); } if (areaIndex > 0) { @@ -1254,11 +1247,11 @@ void Cutaway::updateGameState() { // Turn area on or off if (areaSubIndex > 0) { - Area *area = _logic->area(areaIndex, areaSubIndex); + Area *area = _vm->logic()->area(areaIndex, areaSubIndex); area->mapNeighbours = ABS(area->mapNeighbours); } else { - Area *area = _logic->area(areaIndex, ABS(areaSubIndex)); + Area *area = _vm->logic()->area(areaIndex, ABS(areaSubIndex)); area->mapNeighbours = -ABS(area->mapNeighbours); } } @@ -1286,13 +1279,13 @@ void Cutaway::talk(char *nextFilename) { int personInRoom; if (_talkTo > 0) - personInRoom = _talkTo - _logic->roomData(_logic->currentRoom()); + personInRoom = _talkTo - _vm->logic()->roomData(_vm->logic()->currentRoom()); else { warning("_talkTo is 0!"); personInRoom = 0; // XXX is this correct? } - Talk::talk(_talkFile, personInRoom, nextFilename, _graphics, _input, _logic, _resource, _sound); + Talk::talk(_talkFile, personInRoom, nextFilename, _vm); } } @@ -1305,7 +1298,7 @@ int Cutaway::makeComplexAnimation(int16 currentImage, Cutaway::CutawayAnim *objA memset(frameIndex, 0, sizeof(frameIndex)); debug(0, "[Cutaway::makeComplexAnimation] currentImage = %i", currentImage); - BobSlot *bob = _graphics->bob(bobNum); + BobSlot *bob = _vm->graphics()->bob(bobNum); bob->xflip = objAnim[0].flip; for (i = 0; i < frameCount; i++) { @@ -1332,7 +1325,7 @@ int Cutaway::makeComplexAnimation(int16 currentImage, Cutaway::CutawayAnim *objA if (frameIndex[i]) { currentImage++; //debug(0, "bankUnpack(%i, %i, %i)", i, currentImage, objAnim[0].bank); - _graphics->bankUnpack(i, currentImage, objAnim[0].bank); + _vm->graphics()->bankUnpack(i, currentImage, objAnim[0].bank); } } @@ -1356,7 +1349,7 @@ void Cutaway::handleText( int flags; if (OBJECT_TYPE_TEXT_DISPLAY == type) { - x = _graphics->textCenterX(sentence); + x = _vm->graphics()->textCenterX(sentence); flags = 2; } else { @@ -1365,36 +1358,36 @@ void Cutaway::handleText( } BobSlot *bob = - _graphics->bob( _logic->findBob(ABS(object.objectNumber)) ); + _vm->graphics()->bob( _vm->logic()->findBob(ABS(object.objectNumber)) ); - _graphics->bobSetText(bob, sentence, x, object.bobStartY, object.specialMove, flags); + _vm->graphics()->bobSetText(bob, sentence, x, object.bobStartY, object.specialMove, flags); if (OBJECT_TYPE_TEXT_SPEAK == type || OBJECT_TYPE_TEXT_DISPLAY_AND_SPEAK == type) { char voiceFileName[MAX_STRING_SIZE]; findCdCut(_basename, index, voiceFileName); strcat(voiceFileName, "1"); - _sound->sfxPlay(voiceFileName); + _vm->sound()->sfxPlay(voiceFileName); } int i; for (i = 0; i < spaces; i++) { - _logic->update(); + _vm->logic()->update(); if (OBJECT_TYPE_TEXT_SPEAK == type || OBJECT_TYPE_TEXT_DISPLAY_AND_SPEAK == type) { // XXX: see if speaking is finished } - if (_input->cutawayQuit()) + if (_vm->input()->cutawayQuit()) return; - if (_input->keyVerb().isSkipText()) { - _input->clearKeyVerb(); + if (_vm->input()->keyVerb().isSkipText()) { + _vm->input()->clearKeyVerb(); break; } } - _graphics->textClear(0,198); - _logic->update(); + _vm->graphics()->textClear(0,198); + _vm->logic()->update(); } int Cutaway::countSpaces(ObjectType type, const char *segment) { @@ -1409,7 +1402,7 @@ int Cutaway::countSpaces(ObjectType type, const char *segment) { if (OBJECT_TYPE_TEXT_DISPLAY == type) tmp *= 3; - return (tmp * 2) / (_logic->talkSpeed() / 3); + return (tmp * 2) / (_vm->logic()->talkSpeed() / 3); } @@ -1427,14 +1420,14 @@ int Cutaway::scale(CutawayObject &object) { y = object.bobStartY; } else { - BobSlot *bob = _graphics->bob(0); + BobSlot *bob = _vm->graphics()->bob(0); x = bob->x; y = bob->y; } - int zone = _logic->zoneInArea(0, x, y); + int zone = _vm->logic()->zoneInArea(0, x, y); if (zone > 0) { - Area *area = _logic->area(_logic->currentRoom(), zone); + Area *area = _vm->logic()->area(_vm->logic()->currentRoom(), zone); scaling = area->calcScale(y); } } diff --git a/queen/cutaway.h b/queen/cutaway.h index c876b627c0..45dc1bfb47 100644 --- a/queen/cutaway.h +++ b/queen/cutaway.h @@ -27,13 +27,7 @@ namespace Queen { -class Graphics; -class Input; -class Logic; -class Resource; -class Sound; -class Walk; - +class QueenEngine; class Cutaway { public: @@ -41,11 +35,7 @@ class Cutaway { static void run( const char *filename, char *nextFilename, - Graphics *graphics, - Input *input, - Logic *logic, - Resource *resource, - Sound *sound); + QueenEngine *vm); public: //! Collection of constants used by QueenCutaway @@ -137,12 +127,7 @@ class Cutaway { int16 image; }; - Graphics *_graphics; - Input *_input; - Logic *_logic; - Resource *_resource; - Sound *_sound; - Walk *_walk; + QueenEngine *_vm; //! Raw .cut file data (without 20 byte header) byte *_fileData; @@ -211,13 +196,8 @@ class Cutaway { AnimFrame _cutAnim[17][30]; - Cutaway( - const char *filename, - Graphics *graphics, - Input *input, - Logic *logic, - Resource *resource, - Sound *sound); + Cutaway(const char *filename, + QueenEngine *vm); ~Cutaway(); //! Run this cutaway object diff --git a/queen/debug.cpp b/queen/debug.cpp index 820987b126..6b03eb06ff 100644 --- a/queen/debug.cpp +++ b/queen/debug.cpp @@ -21,17 +21,19 @@ #include "stdafx.h" #include "queen/debug.h" + #include "queen/defs.h" #include "queen/graphics.h" #include "queen/input.h" #include "queen/logic.h" +#include "queen/queen.h" #include "queen/resource.h" #include "queen/structs.h" namespace Queen { -Debug::Debug(Input *input, Logic *logic, Graphics *graphics) -: _passwordCharCount(0), _stubCount(0), _input(input), _logic(logic), _graphics(graphics) { +Debug::Debug(QueenEngine *vm) + : _passwordCharCount(0), _stubCount(0), _vm(vm) { memset(_password, 0, sizeof(_password)); @@ -82,18 +84,18 @@ void Debug::jumpToRoom() { debug(9, "Debug::jumpToRoom()"); - _graphics->textCurrentColor(INK_JOE); - _graphics->textSet(0, 142, "Enter new room"); - _logic->update(); + _vm->graphics()->textCurrentColor(INK_JOE); + _vm->graphics()->textSet(0, 142, "Enter new room"); + _vm->logic()->update(); int room; _digitTextCount = 0; - if (_input->waitForNumber(room, digitKeyPressed, this)) { - _logic->joeX(0); - _logic->joeY(0); - _logic->newRoom(room); - _logic->entryObj(_logic->roomData(room) + 1); - _graphics->textClear(0, 199); + if (_vm->input()->waitForNumber(room, digitKeyPressed, this)) { + _vm->logic()->joeX(0); + _vm->logic()->joeY(0); + _vm->logic()->newRoom(room); + _vm->logic()->entryObj(_vm->logic()->roomData(room) + 1); + _vm->graphics()->textClear(0, 199); } } @@ -101,7 +103,7 @@ void Debug::jumpToRoom() { void Debug::toggleFastMode() { debug(9, "Debug::toggleFastMode()"); - _input->fastMode(!_input->fastMode()); + _vm->input()->fastMode(!_vm->input()->fastMode()); } @@ -109,24 +111,24 @@ void Debug::printInfo() { debug(9, "Debug::printInfo()"); - _graphics->textClear(0, 199); - _graphics->textCurrentColor(INK_JOE); + _vm->graphics()->textClear(0, 199); + _vm->graphics()->textCurrentColor(INK_JOE); char buf[100]; - snprintf(buf, sizeof(buf), "Version : %s", _logic->resource()->JASVersion()); - _graphics->textSet(110, 20, buf); + snprintf(buf, sizeof(buf), "Version : %s", _vm->resource()->JASVersion()); + _vm->graphics()->textSet(110, 20, buf); - snprintf(buf, sizeof(buf), "Room number : %d", _logic->currentRoom()); - _graphics->textSet(110, 40, buf); + snprintf(buf, sizeof(buf), "Room number : %d", _vm->logic()->currentRoom()); + _vm->graphics()->textSet(110, 40, buf); - snprintf(buf, sizeof(buf), "Room name : %s", _logic->roomName(_logic->currentRoom())); - _graphics->textSet(110, 60, buf); + snprintf(buf, sizeof(buf), "Room name : %s", _vm->logic()->roomName(_vm->logic()->currentRoom())); + _vm->graphics()->textSet(110, 60, buf); - _logic->update(); + _vm->logic()->update(); char c; - if (_input->waitForCharacter(c)) { + if (_vm->input()->waitForCharacter(c)) { switch (c) { case 'a': toggleAreasDrawing(); @@ -142,7 +144,7 @@ void Debug::printInfo() { break; } } - _graphics->textClear(0, 199); + _vm->graphics()->textClear(0, 199); } @@ -156,17 +158,17 @@ void Debug::toggleAreasDrawing() { void Debug::changeGameState() { debug(9, "Debug::changeGameState()"); - _graphics->textSet(0, 142, "Set GAMESTATE"); - _logic->update(); + _vm->graphics()->textSet(0, 142, "Set GAMESTATE"); + _vm->logic()->update(); int slot, value; _digitTextCount = 0; - if (_input->waitForNumber(slot, digitKeyPressed, this)) { - _graphics->textClear(0, 199); - _graphics->textSet(0, 142, "to"); - _logic->update(); + if (_vm->input()->waitForNumber(slot, digitKeyPressed, this)) { + _vm->graphics()->textClear(0, 199); + _vm->graphics()->textSet(0, 142, "to"); + _vm->logic()->update(); _digitTextCount = 0; - if (_input->waitForNumber(value, digitKeyPressed, this)) { - _logic->gameState(slot, value); + if (_vm->input()->waitForNumber(value, digitKeyPressed, this)) { + _vm->logic()->gameState(slot, value); } } } @@ -175,18 +177,18 @@ void Debug::changeGameState() { void Debug::printGameState() { debug(9, "Debug::printGameState()"); - _graphics->textSet(0, 142, "Show GAMESTATE"); - _logic->update(); + _vm->graphics()->textSet(0, 142, "Show GAMESTATE"); + _vm->logic()->update(); int slot; _digitTextCount = 0; - if (_input->waitForNumber(slot, digitKeyPressed, this)) { - _graphics->textClear(0, 199); + if (_vm->input()->waitForNumber(slot, digitKeyPressed, this)) { + _vm->graphics()->textClear(0, 199); char buf[50]; - snprintf(buf, sizeof(buf), "Currently - %d", _logic->gameState(slot)); - _graphics->textSet(0, 142, buf); - _logic->update(); + snprintf(buf, sizeof(buf), "Currently - %d", _vm->logic()->gameState(slot)); + _vm->graphics()->textSet(0, 142, buf); + _vm->logic()->update(); char c; - _input->waitForCharacter(c); + _vm->input()->waitForCharacter(c); } } @@ -194,8 +196,8 @@ void Debug::printGameState() { void Debug::giveAllItems() { debug(9, "Debug::giveAllItems()"); - int n = _logic->itemDataCount(); - ItemData *item = _logic->itemData(1); + int n = _vm->logic()->itemDataCount(); + ItemData *item = _vm->logic()->itemData(1); while (n--) { item->name = ABS(item->name); ++item; @@ -214,8 +216,8 @@ void Debug::digitKeyPressed(void *refCon, int key) { --debug->_digitTextCount; } debug->_digitText[debug->_digitTextCount] = '\0'; - debug->_graphics->textSet(0, 151, debug->_digitText); - debug->_logic->update(); + debug->_vm->graphics()->textSet(0, 151, debug->_digitText); + debug->_vm->logic()->update(); } diff --git a/queen/debug.h b/queen/debug.h index 2d49a71be0..25cf02529d 100644 --- a/queen/debug.h +++ b/queen/debug.h @@ -26,15 +26,13 @@ namespace Queen { -class Input; -class Logic; -class Graphics; +class QueenEngine; class Debug { public: typedef void (Debug::*DebugFunc)(); - Debug(Input *, Logic *, Graphics *); + Debug(QueenEngine *vm); void registerStub(const char *password, DebugFunc debugFunc); @@ -71,10 +69,7 @@ private: DebugStub _stub[MAX_STUB]; uint _stubCount; - Input *_input; - Logic *_logic; - Graphics *_graphics; - + QueenEngine *_vm; }; diff --git a/queen/display.cpp b/queen/display.cpp index eeaaef9540..32464e67fb 100644 --- a/queen/display.cpp +++ b/queen/display.cpp @@ -21,15 +21,14 @@ #include "stdafx.h" #include "queen/display.h" + #include "queen/input.h" -#include "queen/logic.h" // For RandomSource +#include "queen/queen.h" #include "queen/resource.h" - namespace Queen { - void TextRenderer::init() { // calculate font justification sizes @@ -100,8 +99,8 @@ void TextRenderer::drawChar(uint8 *dstBuf, uint16 dstPitch, uint16 x, uint16 y, -Display::Display(Language language, OSystem *system, Input *input) - : _system(system), _input(input) { +Display::Display(QueenEngine *vm, Language language, OSystem *system) + : _system(system), _vm(vm) { _dynalum.prevColMask = 0xFF; _textRenderer._lang = language; @@ -140,7 +139,7 @@ Display::~Display() { } -void Display::dynalumInit(Resource *resource, const char *roomName, uint16 roomNum) { +void Display::dynalumInit(const char *roomName, uint16 roomNum) { debug(9, "Display::dynalumInit(%s, %d)", roomName, roomNum); memset(_dynalum.msk, 0, sizeof(_dynalum.msk)); @@ -151,14 +150,14 @@ void Display::dynalumInit(Resource *resource, const char *roomName, uint16 roomN char filename[20]; sprintf(filename, "%s.msk", roomName); - _dynalum.valid = resource->exists(filename); + _dynalum.valid = _vm->resource()->exists(filename); if (_dynalum.valid) - resource->loadFile(filename, 0, (uint8*)_dynalum.msk); + _vm->resource()->loadFile(filename, 0, (uint8*)_dynalum.msk); sprintf(filename, "%s.lum", roomName); - _dynalum.valid = resource->exists(filename); + _dynalum.valid = _vm->resource()->exists(filename); if (_dynalum.valid) - resource->loadFile(filename, 0, (uint8*)_dynalum.lum); + _vm->resource()->loadFile(filename, 0, (uint8*)_dynalum.lum); } } @@ -419,7 +418,7 @@ void Display::palCustomScroll(uint16 roomNum) { j += jdir; if(j <= 0 || j >= 14) { jdir = -jdir; - if (Logic::randomizer.getRandomNumber(1)) { + if (_vm->randomizer.getRandomNumber(1)) { if (ABS(jdir) == 1) { jdir *= 2; } @@ -837,7 +836,7 @@ void Display::waitForTimer() { _gotTick = false; while (!_gotTick) { - _input->delay(10); + _vm->input()->delay(10); } } diff --git a/queen/display.h b/queen/display.h index 998184fe48..da92cd2baf 100644 --- a/queen/display.h +++ b/queen/display.h @@ -58,16 +58,15 @@ struct TextRenderer { static const uint8 _font[]; }; -class Input; -class Resource; +class QueenEngine; class Display { public: - Display(Language language, OSystem *system, Input *input); + Display(QueenEngine *vm, Language language, OSystem *system); ~Display(); - void dynalumInit(Resource *resource, const char *roomName, uint16 roomNum); + void dynalumInit(const char *roomName, uint16 roomNum); void dynalumUpdate(int16 x, int16 y); void palConvert(uint8 *outPal, const uint8 *inPal, int start, int end); @@ -150,7 +149,7 @@ private: Dynalum _dynalum; OSystem *_system; - Input *_input; + QueenEngine *_vm; static const uint8 _palJoeClothes[]; static const uint8 _palJoeDress[]; diff --git a/queen/graphics.cpp b/queen/graphics.cpp index 55ea7b4ec8..c58abb482d 100644 --- a/queen/graphics.cpp +++ b/queen/graphics.cpp @@ -21,11 +21,12 @@ #include "stdafx.h" #include "queen/graphics.h" -#include "queen/logic.h" + #include "queen/display.h" +#include "queen/logic.h" +#include "queen/queen.h" #include "queen/resource.h" - namespace Queen { @@ -200,8 +201,8 @@ void BobSlot::clear() { } -Graphics::Graphics(Display *display, Input *input, Resource *resource) - : _cameraBob(0), _display(display), _input(input), _resource(resource) { +Graphics::Graphics(QueenEngine *vm) + : _cameraBob(0), _vm(vm) { memset(_frames, 0, sizeof(_frames)); memset(_banks, 0, sizeof(_banks)); @@ -226,7 +227,7 @@ Graphics::~Graphics() { void Graphics::bankLoad(const char *bankname, uint32 bankslot) { bankErase(bankslot); - _banks[bankslot].data = _resource->loadFile(bankname); + _banks[bankslot].data = _vm->resource()->loadFile(bankname); if (!_banks[bankslot].data) { error("Unable to open bank '%s'", bankname); } @@ -312,7 +313,7 @@ void Graphics::bobSetupControl() { bankErase(17); BobFrame *bf = &_frames[1]; - _display->setMouseCursor(bf->data, bf->width, bf->height, bf->xhotspot, bf->yhotspot); + _vm->display()->setMouseCursor(bf->data, bf->width, bf->height, bf->xhotspot, bf->yhotspot); } @@ -364,12 +365,12 @@ void Graphics::bobDraw(const BobSlot *bs, int16 x, int16 y) { src += w * y_skip; if (!bs->xflip) { src += x_skip; - _display->blit(RB_SCREEN, x, y, src, w_new, h_new, w, bs->xflip, true); + _vm->display()->blit(RB_SCREEN, x, y, src, w_new, h_new, w, bs->xflip, true); } else { src += w - w_new - x_skip; x += w_new - 1; - _display->blit(RB_SCREEN, x, y, src, w_new, h_new, w, bs->xflip, true); + _vm->display()->blit(RB_SCREEN, x, y, src, w_new, h_new, w, bs->xflip, true); } } @@ -380,11 +381,11 @@ void Graphics::bobDrawInventoryItem(uint32 bobnum, uint16 x, uint16 y) { if (bobnum == 0) { // clear panel area - _display->fill(RB_PANEL, x, y, 32, 32, INK_BG_PANEL); + _vm->display()->fill(RB_PANEL, x, y, 32, 32, INK_BG_PANEL); } else { BobFrame *pbf = &_frames[bobnum]; - _display->blit(RB_PANEL, x, y, pbf->data, pbf->width, pbf->height, pbf->width, false, false); + _vm->display()->blit(RB_PANEL, x, y, pbf->data, pbf->width, pbf->height, pbf->width, false, false); } } @@ -392,7 +393,7 @@ void Graphics::bobDrawInventoryItem(uint32 bobnum, uint16 x, uint16 y) { void Graphics::bobPaste(uint32 frameNum, int16 x, int16 y) { BobFrame *pbf = &_frames[frameNum]; - _display->blit(RB_BACKDROP, x, y, pbf->data, pbf->width, pbf->height, pbf->width, false, true); + _vm->display()->blit(RB_BACKDROP, x, y, pbf->data, pbf->width, pbf->height, pbf->width, false, true); frameErase(frameNum); } @@ -447,7 +448,7 @@ void Graphics::bobClear(uint32 bobnum) { BobSlot *pbs = &_bobs[bobnum]; pbs->clear(); - if (_display->fullscreen() || bobnum == 16) { // FIXME: does bob number 16 really used ? + if (_vm->display()->fullscreen() || bobnum == 16) { // FIXME: does bob number 16 really used ? pbs->box.y2 = GAME_SCREEN_HEIGHT - 1; } } @@ -517,7 +518,7 @@ void Graphics::bobDrawAll() { } // adjusts position to hot-spot and screen scroll - x = pbs->x - xh - _display->horizontalScroll(); + x = pbs->x - xh - _vm->display()->horizontalScroll(); y = pbs->y - yh; bobDraw(pbs, x, y); @@ -556,7 +557,7 @@ BobSlot *Graphics::bob(int index) { void Graphics::bobCustomParallax(uint16 roomNum) { int i; - uint16 screenScroll = _display->horizontalScroll(); + uint16 screenScroll = _vm->display()->horizontalScroll(); switch (roomNum) { case ROOM_AMAZON_HIDEOUT: _bobs[8].x = 250 - screenScroll / 2; @@ -575,7 +576,7 @@ void Graphics::bobCustomParallax(uint16 roomNum) { _bobs[5].x = 600 - screenScroll / 2; break; case ROOM_HOTEL_LOBBY: - if(_display->fullscreen()) { + if(_vm->display()->fullscreen()) { for(i = 1; i <= 3; ++i) { _bobs[i].box.y2 = 199; } @@ -606,7 +607,7 @@ void Graphics::bobCustomParallax(uint16 roomNum) { _cameraBob = -1; debug(9, "Graphics::bobCustomParallax() - %d", screenScroll); if (screenScroll < 80) { - _display->horizontalScroll(screenScroll + 4); + _vm->display()->horizontalScroll(screenScroll + 4); // Joe's body and head _bobs[ 1].x += 4; _bobs[20].x += 4; @@ -657,7 +658,7 @@ void Graphics::textDrawAll() { for (y = GAME_SCREEN_HEIGHT - 1; y > 0; --y) { const TextSlot *pts = &_texts[y]; if (!pts->text.isEmpty()) { - _display->textDraw(pts->x, y, pts->color, pts->text.c_str(), pts->outlined); + _vm->display()->textDraw(pts->x, y, pts->color, pts->text.c_str(), pts->outlined); } } } @@ -674,7 +675,7 @@ void Graphics::textClear(uint16 y1, uint16 y2) { uint16 Graphics::textWidth(const char* text) const { - return _display->textWidth(text); + return _vm->display()->textWidth(text); } @@ -706,14 +707,14 @@ void Graphics::loadBackdrop(const char* name, uint16 room) { char roomPrefix[20]; strcpy(roomPrefix, name); roomPrefix[ strlen(roomPrefix) - 4 ] = '\0'; - _display->dynalumInit(_resource, roomPrefix, room); + _vm->display()->dynalumInit(roomPrefix, room); - uint8 *pcxbuf = _resource->loadFile(name); + uint8 *pcxbuf = _vm->resource()->loadFile(name); if (pcxbuf == NULL) { error("Unable to load backdrop : '%s'", name); } - uint32 size = _resource->fileSize(name); - _display->pcxReadBackdrop(pcxbuf, size, room > 114); + uint32 size = _vm->resource()->fileSize(name); + _vm->display()->pcxReadBackdrop(pcxbuf, size, room > 114); delete[] pcxbuf; if (room >= 90) { @@ -724,12 +725,12 @@ void Graphics::loadBackdrop(const char* name, uint16 room) { void Graphics::loadPanel() { - uint8 *pcxbuf = _resource->loadFile("panel.pcx"); + uint8 *pcxbuf = _vm->resource()->loadFile("panel.pcx"); if (pcxbuf == NULL) { error("Unable to open panel file"); } - uint32 size = _resource->fileSize("panel.pcx"); - _display->pcxReadPanel(pcxbuf, size); + uint32 size = _vm->resource()->fileSize("panel.pcx"); + _vm->display()->pcxReadPanel(pcxbuf, size); delete[] pcxbuf; } @@ -863,7 +864,7 @@ void Graphics::updateFightBamScene() { _bam._fight2Data, _bam._fight3Data }; - _bam._fightData = data[Logic::randomizer.getRandomNumber(2)]; + _bam._fightData = data[_vm->randomizer.getRandomNumber(2)]; if (_bam.flag == 2) { _bam.flag = 0; } @@ -877,10 +878,10 @@ void Graphics::update(uint16 room) { bobSortAll(); if (_cameraBob >= 0) { - _display->horizontalScrollUpdate(_bobs[_cameraBob].x); + _vm->display()->horizontalScrollUpdate(_bobs[_cameraBob].x); } bobCustomParallax(room); - _display->prepareUpdate(); + _vm->display()->prepareUpdate(); bobDrawAll(); textDrawAll(); } diff --git a/queen/graphics.h b/queen/graphics.h index 20af746950..7227bcf6c3 100644 --- a/queen/graphics.h +++ b/queen/graphics.h @@ -130,14 +130,12 @@ struct BamData { }; -class Display; -class Input; -class Resource; +class QueenEngine; class Graphics { public: - Graphics(Display *display, Input *input, Resource *resource); + Graphics(QueenEngine *vm); ~Graphics(); void bankLoad(const char *bankname, uint32 bankslot); // loadbank() @@ -237,10 +235,7 @@ private: BamData _bam; - Display *_display; - Input *_input; - Resource *_resource; - + QueenEngine *_vm; }; } // End of namespace Queen diff --git a/queen/journal.cpp b/queen/journal.cpp index 28cfee8968..528d77789f 100644 --- a/queen/journal.cpp +++ b/queen/journal.cpp @@ -20,20 +20,20 @@ */ #include "stdafx.h" -#include "base/engine.h" // For g_engine #include "queen/journal.h" + #include "queen/display.h" #include "queen/graphics.h" #include "queen/logic.h" +#include "queen/queen.h" #include "queen/resource.h" #include "queen/sound.h" namespace Queen { -Journal::Journal(Logic *l, Graphics *g, Display *d, Sound *s) - : _logic(l), _graphics(g), _display(d), _sound(s) { - _savePath = g_engine->getSavePath(); +Journal::Journal(QueenEngine *vm) + : _vm(vm) { _currentSavePage = 0; _currentSaveSlot = 0; } @@ -41,7 +41,7 @@ Journal::Journal(Logic *l, Graphics *g, Display *d, Sound *s) void Journal::use() { - BobSlot *joe = _graphics->bob(0); + BobSlot *joe = _vm->graphics()->bob(0); _prevJoeX = joe->x; _prevJoeY = joe->y; @@ -51,11 +51,11 @@ void Journal::use() { findSaveDescriptions(); _panelTextCount = 0; - _display->palFadeOut(0, 255, JOURNAL_ROOM); + _vm->display()->palFadeOut(0, 255, JOURNAL_ROOM); prepare(); redraw(); update(); - _display->palFadeIn(0, 255, JOURNAL_ROOM); + _vm->display()->palFadeIn(0, 255, JOURNAL_ROOM); _quitCleanly = true; _quit = false; @@ -80,10 +80,10 @@ void Journal::use() { g_system->delay_msecs(20); } - _logic->writeOptionSettings(); + _vm->logic()->writeOptionSettings(); - _graphics->textClear(0, GAME_SCREEN_HEIGHT - 1); - _graphics->cameraBob(0); + _vm->graphics()->textClear(0, GAME_SCREEN_HEIGHT - 1); + _vm->graphics()->cameraBob(0); if (_quitCleanly) { restore(); } @@ -92,60 +92,60 @@ void Journal::use() { void Journal::prepare() { - _display->horizontalScroll(0); - _display->fullscreen(true); + _vm->display()->horizontalScroll(0); + _vm->display()->fullscreen(true); - _graphics->cameraBob(-1); - _graphics->bobClearAll(); - _graphics->textClear(0, GAME_SCREEN_HEIGHT - 1); - _graphics->frameEraseAll(false); + _vm->graphics()->cameraBob(-1); + _vm->graphics()->bobClearAll(); + _vm->graphics()->textClear(0, GAME_SCREEN_HEIGHT - 1); + _vm->graphics()->frameEraseAll(false); int i; - _logic->zoneClearAll(ZONE_ROOM); + _vm->logic()->zoneClearAll(ZONE_ROOM); for (i = 0; i < 4; ++i) { // left panel - _logic->zoneSet(ZONE_ROOM, i + 1, 32, 8 + i * 48, 96, 40 + i * 48); + _vm->logic()->zoneSet(ZONE_ROOM, i + 1, 32, 8 + i * 48, 96, 40 + i * 48); } - _logic->zoneSet(ZONE_ROOM, ZN_TEXT_SPEED, 136, 169, 265, 176); - _logic->zoneSet(ZONE_ROOM, ZN_SFX_TOGGLE, 221 - 24, 155, 231, 164); - _logic->zoneSet(ZONE_ROOM, ZN_MUSIC_VOLUME, 136, 182, 265, 189); + _vm->logic()->zoneSet(ZONE_ROOM, ZN_TEXT_SPEED, 136, 169, 265, 176); + _vm->logic()->zoneSet(ZONE_ROOM, ZN_SFX_TOGGLE, 221 - 24, 155, 231, 164); + _vm->logic()->zoneSet(ZONE_ROOM, ZN_MUSIC_VOLUME, 136, 182, 265, 189); for (i = 0; i < 10; ++i) { // right panel - _logic->zoneSet(ZONE_ROOM, ZN_DESC_FIRST + i, 131, 7 + i * 13, 290, 18 + i * 13); - _logic->zoneSet(ZONE_ROOM, ZN_PAGE_FIRST + i, 300, 4 + i * 15, 319, 17 + i * 15); + _vm->logic()->zoneSet(ZONE_ROOM, ZN_DESC_FIRST + i, 131, 7 + i * 13, 290, 18 + i * 13); + _vm->logic()->zoneSet(ZONE_ROOM, ZN_PAGE_FIRST + i, 300, 4 + i * 15, 319, 17 + i * 15); } - _logic->zoneSet(ZONE_ROOM, ZN_INFO_BOX, 273, 146, 295, 189); - _logic->zoneSet(ZONE_ROOM, ZN_MUSIC_TOGGLE, 125 - 16, 181, 135, 190); - _logic->zoneSet(ZONE_ROOM, ZN_VOICE_TOGGLE, 158 - 24, 155, 168, 164); - _logic->zoneSet(ZONE_ROOM, ZN_TEXT_TOGGLE, 125 - 16, 168, 135, 177); + _vm->logic()->zoneSet(ZONE_ROOM, ZN_INFO_BOX, 273, 146, 295, 189); + _vm->logic()->zoneSet(ZONE_ROOM, ZN_MUSIC_TOGGLE, 125 - 16, 181, 135, 190); + _vm->logic()->zoneSet(ZONE_ROOM, ZN_VOICE_TOGGLE, 158 - 24, 155, 168, 164); + _vm->logic()->zoneSet(ZONE_ROOM, ZN_TEXT_TOGGLE, 125 - 16, 168, 135, 177); - _graphics->loadBackdrop("journal.PCX", JOURNAL_ROOM); - _graphics->bankLoad("journal.BBK", JOURNAL_BANK); + _vm->graphics()->loadBackdrop("journal.PCX", JOURNAL_ROOM); + _vm->graphics()->bankLoad("journal.BBK", JOURNAL_BANK); for (i = 1; i <= 20; ++i) { int frameNum = JOURNAL_FRAMES + i; - _graphics->bankUnpack(i, frameNum, JOURNAL_BANK); - BobFrame *bf = _graphics->frame(frameNum); + _vm->graphics()->bankUnpack(i, frameNum, JOURNAL_BANK); + BobFrame *bf = _vm->graphics()->frame(frameNum); bf->xhotspot = 0; bf->yhotspot = 0; if (i == FRAME_INFO_BOX) { // adjust info box hot spot to put it on top always bf->yhotspot = 200; } } - _graphics->bankErase(JOURNAL_BANK); + _vm->graphics()->bankErase(JOURNAL_BANK); - _graphics->textCurrentColor(INK_JOURNAL); + _vm->graphics()->textCurrentColor(INK_JOURNAL); } void Journal::restore() { - _display->fullscreen(false); + _vm->display()->fullscreen(false); - _logic->joeX(_prevJoeX); - _logic->joeY(_prevJoeY); + _vm->logic()->joeX(_prevJoeX); + _vm->logic()->joeY(_prevJoeY); - _logic->joeCutFacing(_logic->joeFacing()); + _vm->logic()->joeCutFacing(_vm->logic()->joeFacing()); - _logic->oldRoom(_logic->currentRoom()); - _logic->roomDisplay(_logic->currentRoom(), RDM_FADE_JOE, 0, 0, false); + _vm->logic()->oldRoom(_vm->logic()->currentRoom()); + _vm->logic()->roomDisplay(_vm->logic()->currentRoom(), RDM_FADE_JOE, 0, 0, false); } @@ -160,19 +160,19 @@ void Journal::redraw() { void Journal::update() { - _graphics->update(JOURNAL_ROOM); + _vm->graphics()->update(JOURNAL_ROOM); if (_edit.enable) { int16 x = 136 + _edit.posCursor; int16 y = 9 + _currentSaveSlot * 13 + 8; - _display->drawBox(x, y, x + 6, y, INK_JOURNAL); + _vm->display()->drawBox(x, y, x + 6, y, INK_JOURNAL); } - _display->update(); + _vm->display()->update(); } void Journal::showBob(int bobNum, int16 x, int16 y, int frameNum) { - BobSlot *bob = _graphics->bob(bobNum); + BobSlot *bob = _vm->graphics()->bob(bobNum); bob->curPos(x, y); bob->frameNum = JOURNAL_FRAMES + frameNum; } @@ -180,7 +180,7 @@ void Journal::showBob(int bobNum, int16 x, int16 y, int frameNum) { void Journal::hideBob(int bobNum) { - _graphics->bob(bobNum)->active = false; + _vm->graphics()->bob(bobNum)->active = false; } @@ -190,14 +190,14 @@ void Journal::findSaveDescriptions() { char filename[256]; makeSavegameName(filename); bool marks[MAX_SAVE_DESC_NUM]; - mgr->list_savefiles(filename, _savePath, marks, MAX_SAVE_DESC_NUM); + mgr->list_savefiles(filename, _vm->getSavePath(), marks, MAX_SAVE_DESC_NUM); memset(_saveDescriptions, 0, sizeof(_saveDescriptions)); int i; for (i = 0; i < MAX_SAVE_DESC_NUM; ++i) { if (marks[i]) { makeSavegameName(filename, i); - SaveFile *f = mgr->open_savefile(filename, _savePath, false); + SaveFile *f = mgr->open_savefile(filename, _vm->getSavePath(), false); if (f) { f->read(_saveDescriptions[i], MAX_SAVE_DESC_LEN); delete f; @@ -216,8 +216,8 @@ void Journal::drawSaveDescriptions() { char nb[4]; sprintf(nb, "%d", n + 1); int y = 9 + i * 13; - _graphics->textSet(136, y, _saveDescriptions[n], false); - _graphics->textSet(109, y + 1, nb, false); + _vm->graphics()->textSet(136, y, _saveDescriptions[n], false); + _vm->graphics()->textSet(109, y + 1, nb, false); } // hightlight current page showBob(BOB_SAVE_PAGE, 300, 3 + _currentSavePage * 15, 6 + _currentSavePage); @@ -264,11 +264,11 @@ void Journal::handleNormalMode(int16 zoneNum, int x) { enterYesNoMode(zoneNum, TXT_GIVE_UP); } if (zoneNum == ZN_TEXT_SPEED) { - _logic->talkSpeed((x - 136) * 100 / 130); + _vm->logic()->talkSpeed((x - 136) * 100 / 130); drawConfigPanel(); } else if (zoneNum == ZN_SFX_TOGGLE) { - _sound->toggleSfx(); + _vm->sound()->toggleSfx(); drawConfigPanel(); } else if (zoneNum == ZN_MUSIC_VOLUME) { @@ -289,8 +289,8 @@ void Journal::handleNormalMode(int16 zoneNum, int x) { showInformationBox(); } else if (zoneNum == ZN_MUSIC_TOGGLE) { - _sound->toggleMusic(); - if (_sound->musicOn()) { + _vm->sound()->toggleMusic(); + if (_vm->sound()->musicOn()) { // XXX playsong(lastoverride); } else { @@ -299,11 +299,11 @@ void Journal::handleNormalMode(int16 zoneNum, int x) { drawConfigPanel(); } else if (zoneNum == ZN_VOICE_TOGGLE) { - _sound->toggleSpeech(); + _vm->sound()->toggleSpeech(); drawConfigPanel(); } else if (zoneNum == ZN_TEXT_TOGGLE) { - _logic->subtitles(!_logic->subtitles()); + _vm->logic()->subtitles(!_vm->logic()->subtitles()); drawConfigPanel(); } } @@ -324,9 +324,9 @@ void Journal::handleYesNoMode(int16 zoneNum) { switch (_prevZoneNum) { case ZN_REVIEW_ENTRY: if (_saveDescriptions[currentSlot][0]) { - _display->palFadeOut(0, 223, JOURNAL_ROOM); + _vm->display()->palFadeOut(0, 223, JOURNAL_ROOM); loadState(currentSlot); - _graphics->textClear(0, GAME_SCREEN_HEIGHT - 1); + _vm->graphics()->textClear(0, GAME_SCREEN_HEIGHT - 1); // XXX panelflag=1; // XXX walkgameload=1; _quit = true; @@ -358,7 +358,7 @@ void Journal::handleYesNoMode(int16 zoneNum) { void Journal::handleMouseDown(int x, int y) { - int16 zone = _logic->zoneIn(ZONE_ROOM, x, y); + int16 zone = _vm->logic()->zoneIn(ZONE_ROOM, x, y); if (_mode == M_INFO_BOX) { handleInfoBoxMode(_mode); } @@ -392,7 +392,7 @@ void Journal::clearPanelTexts() { int i; for (i = 0; i < _panelTextCount; ++i) { - _graphics->textClear(_panelTextY[i], _panelTextY[i]); + _vm->graphics()->textClear(_panelTextY[i], _panelTextY[i]); } } @@ -403,8 +403,8 @@ void Journal::drawPanelText(int y, const char *text) { strcpy(s, text); char *p = strchr(s, ' '); if (p == NULL) { - int x = (128 - _graphics->textWidth(s)) / 2; - _graphics->textSet(x, y, s, false); + int x = (128 - _vm->graphics()->textWidth(s)) / 2; + _vm->graphics()->textSet(x, y, s, false); _panelTextY[_panelTextCount++] = y; } else { @@ -440,7 +440,7 @@ void Journal::drawPanel(const int *frames, const int *titles, int n) { int y = 8; while (n--) { showBob(bobNum++, 32, y, *frames++); - drawPanelText(y + 12, _logic->joeResponse(*titles++)); + drawPanelText(y + 12, _vm->logic()->joeResponse(*titles++)); y += 48; } } @@ -472,65 +472,65 @@ void Journal::drawYesNoPanel(int titleNum) { void Journal::drawConfigPanel() { - _logic->checkOptionSettings(); + _vm->logic()->checkOptionSettings(); - drawSlideBar(_logic->talkSpeed(), 130, 100, BOB_TALK_SPEED, 136 - 4, 164, FRAME_BLUE_PIN); + drawSlideBar(_vm->logic()->talkSpeed(), 130, 100, BOB_TALK_SPEED, 136 - 4, 164, FRAME_BLUE_PIN); // XXX music_volume drawSlideBar(100, 130, 100, BOB_MUSIC_VOLUME, 136 - 4, 177, FRAME_GREEN_PIN); - drawCheckBox(_sound->sfxOn(), BOB_SFX_TOGGLE, 221, 155, FRAME_CHECK_BOX); - drawCheckBox(_sound->speechOn(), BOB_SPEECH_TOGGLE, 158, 155, FRAME_CHECK_BOX); - drawCheckBox(_logic->subtitles(), BOB_TEXT_TOGGLE, 125, 167, FRAME_CHECK_BOX); - drawCheckBox(_sound->musicOn(), BOB_MUSIC_TOGGLE, 125, 181, FRAME_CHECK_BOX); + drawCheckBox(_vm->sound()->sfxOn(), BOB_SFX_TOGGLE, 221, 155, FRAME_CHECK_BOX); + drawCheckBox(_vm->sound()->speechOn(), BOB_SPEECH_TOGGLE, 158, 155, FRAME_CHECK_BOX); + drawCheckBox(_vm->logic()->subtitles(), BOB_TEXT_TOGGLE, 125, 167, FRAME_CHECK_BOX); + drawCheckBox(_vm->sound()->musicOn(), BOB_MUSIC_TOGGLE, 125, 181, FRAME_CHECK_BOX); } void Journal::showInformationBox() { - _graphics->textClear(0, GAME_SCREEN_HEIGHT - 1); + _vm->graphics()->textClear(0, GAME_SCREEN_HEIGHT - 1); showBob(BOB_INFO_BOX, 72, 221, FRAME_INFO_BOX); - const char *ver = _logic->resource()->JASVersion(); + const char *ver = _vm->resource()->JASVersion(); switch (ver[0]) { case 'P': - _graphics->textSetCentered(132, "PC Hard Drive", false); + _vm->graphics()->textSetCentered(132, "PC Hard Drive", false); break; case 'C': - _graphics->textSetCentered(132, "PC CD-ROM", false); + _vm->graphics()->textSetCentered(132, "PC CD-ROM", false); break; case 'a': - _graphics->textSetCentered(132, "Amiga A500/600", false); + _vm->graphics()->textSetCentered(132, "Amiga A500/600", false); break; case 'A': - _graphics->textSetCentered(132, "Amiga A1200", false); + _vm->graphics()->textSetCentered(132, "Amiga A1200", false); break; case 'c': - _graphics->textSetCentered(132, "Amiga CD-32", false); + _vm->graphics()->textSetCentered(132, "Amiga CD-32", false); break; } switch (ver[1]) { case 'E': - _graphics->textSetCentered(144, "English", false); + _vm->graphics()->textSetCentered(144, "English", false); break; case 'G': - _graphics->textSetCentered(144, "Deutsch", false); + _vm->graphics()->textSetCentered(144, "Deutsch", false); break; case 'I': - _graphics->textSetCentered(144, "Italiano", false); + _vm->graphics()->textSetCentered(144, "Italiano", false); break; case 'F' : - _graphics->textSetCentered(144, "Fran\x87""ais", false); + _vm->graphics()->textSetCentered(144, "Fran\x87""ais", false); break; } char versionId[12]; sprintf(versionId, "Version %c.%c%c", ver[2], ver[3], ver[4]); - _graphics->textSetCentered(156, versionId, false); + _vm->graphics()->textSetCentered(156, versionId, false); } void Journal::hideInformationBox() { - _graphics->textClear(0, GAME_SCREEN_HEIGHT - 1); + _vm->graphics()->textClear(0, GAME_SCREEN_HEIGHT - 1); hideBob(BOB_INFO_BOX); redraw(); } @@ -539,7 +539,7 @@ void Journal::hideInformationBox() { void Journal::initEditBuffer(const char *desc) { _edit.enable = true; - _edit.posCursor = _graphics->textWidth(desc); + _edit.posCursor = _vm->graphics()->textWidth(desc); _edit.textCharsCount = strlen(desc); memset(_edit.text, 0, sizeof(_edit.text)); strcpy(_edit.text, desc); @@ -564,7 +564,7 @@ void Journal::updateEditBuffer(uint16 ascii, int keycode) { default: if (isprint((char)ascii) && _edit.textCharsCount < (sizeof(_edit.text) - 1) && - _graphics->textWidth(_edit.text) < 146) { + _vm->graphics()->textWidth(_edit.text) < 146) { _edit.text[_edit.textCharsCount] = (char)ascii; ++_edit.textCharsCount; dirty = true; @@ -572,8 +572,8 @@ void Journal::updateEditBuffer(uint16 ascii, int keycode) { break; } if (dirty) { - _graphics->textSet(136, 9 + _currentSaveSlot * 13, _edit.text, false); - _edit.posCursor = _graphics->textWidth(_edit.text); + _vm->graphics()->textSet(136, 9 + _currentSaveSlot * 13, _edit.text, false); + _edit.posCursor = _vm->graphics()->textWidth(_edit.text); update(); } } @@ -593,14 +593,14 @@ void Journal::makeSavegameName(char *buf, int slot) { void Journal::saveState(int slot, const char *desc) { warning("Journal::saveState(%d, %s)", slot, desc); - _logic->gameSave(slot, desc); + _vm->logic()->gameSave(slot, desc); } void Journal::loadState(int slot) { warning("Journal::loadState(%d)", slot); - _logic->gameLoad(slot); + _vm->logic()->gameLoad(slot); } diff --git a/queen/journal.h b/queen/journal.h index fbbf252820..ee20772c1d 100644 --- a/queen/journal.h +++ b/queen/journal.h @@ -26,16 +26,12 @@ namespace Queen { -class Logic; -class Graphics; -class Display; -class Sound; -struct GameConfig; +class QueenEngine; class Journal { public: - Journal(Logic *, Graphics *, Display *, Sound *); + Journal(QueenEngine *vm); void use(); enum { @@ -180,11 +176,7 @@ private: bool _quit; bool _quitCleanly; - Logic *_logic; - Graphics *_graphics; - Display *_display; - Sound *_sound; - const char *_savePath; + QueenEngine *_vm; }; diff --git a/queen/logic.cpp b/queen/logic.cpp index d38507fa29..498bff11cc 100644 --- a/queen/logic.cpp +++ b/queen/logic.cpp @@ -20,8 +20,9 @@ */ #include "stdafx.h" -#include "common/config-manager.h" #include "queen/logic.h" + +#include "common/config-manager.h" #include "queen/command.h" #include "queen/cutaway.h" #include "queen/defs.h" @@ -30,6 +31,7 @@ #include "queen/graphics.h" #include "queen/input.h" #include "queen/journal.h" +#include "queen/queen.h" #include "queen/resource.h" #include "queen/sound.h" #include "queen/state.h" @@ -60,25 +62,18 @@ const VerbEnum Logic::PANEL_VERBS[] = { char* Verb::_verbName[13]; -Common::RandomSource Logic::randomizer; - -Logic::Logic(Resource *theResource, Graphics *graphics, Display *theDisplay, Input *input, Sound *sound) - : _resource(theResource), _graphics(graphics), _display(theDisplay), - _input(input), _sound(sound) { +Logic::Logic(QueenEngine *vm) + : _vm(vm) { _joe.x = _joe.y = 0; _joe.scale = 100; - _walk = new Walk(this, _graphics); - _cmd = new Command(this, _graphics, _input, _walk, _sound); - _dbg = new Debug(_input, this, _graphics); + _dbg = new Debug(vm); memset(_gameState, 0, sizeof(_gameState)); memset(_talkSelected, 0, sizeof(_talkSelected)); initialise(); } Logic::~Logic() { - delete _walk; - delete _cmd; delete _dbg; } @@ -89,7 +84,7 @@ void Logic::initialise() { // Step 1 : read queen.jas file and 'unserialize' some arrays - uint8 *jas = _resource->loadFile("QUEEN.JAS", 20); + uint8 *jas = _vm->resource()->loadFile("QUEEN.JAS", 20); uint8 *ptr = jas; _numRooms = READ_BE_UINT16(ptr); ptr += 2; @@ -114,7 +109,7 @@ void Logic::initialise() { // SFX Name // the following table isn't available in demo version - if (_resource->isDemo()) { + if (_vm->resource()->isDemo()) { _sfxName = NULL; } else { @@ -184,7 +179,7 @@ void Logic::initialise() { _objectDescription[i].readFrom(ptr); } - _cmd->readCommandsFrom(ptr); + _vm->command()->readCommandsFrom(ptr); _entryObj = READ_BE_UINT16(ptr); ptr += 2; @@ -220,7 +215,7 @@ void Logic::initialise() { _currentRoom = _objectData[_entryObj].room; _entryObj = 0; - if(memcmp(ptr, _resource->JASVersion(), 5) != 0) { + if(memcmp(ptr, _vm->resource()->JASVersion(), 5) != 0) { warning("Unexpected queen.jas file format"); } @@ -232,10 +227,10 @@ void Logic::initialise() { _objDescription = new char*[_numDescriptions + 1]; _objDescription[0] = 0; for (i = 1; i <= _numDescriptions; i++) - _objDescription[i] = _resource->getJAS2Line(); + _objDescription[i] = _vm->resource()->getJAS2Line(); //Patch for German text bug - if (_resource->getLanguage() == GERMAN) { + if (_vm->resource()->getLanguage() == GERMAN) { char *txt = new char[48]; strcpy(txt, "Es bringt nicht viel, das festzubinden."); _objDescription[296] = txt; @@ -244,44 +239,44 @@ void Logic::initialise() { _objName = new char*[_numNames + 1]; _objName[0] = 0; for (i = 1; i <= _numNames; i++) - _objName[i] = _resource->getJAS2Line(); + _objName[i] = _vm->resource()->getJAS2Line(); _roomName = new char*[_numRooms + 1]; _roomName[0] = 0; for (i = 1; i <= _numRooms; i++) - _roomName[i] = _resource->getJAS2Line(); + _roomName[i] = _vm->resource()->getJAS2Line(); Verb::initName(0, NULL); for (i = 1; i <= 12; i++) - Verb::initName(i, _resource->getJAS2Line()); + Verb::initName(i, _vm->resource()->getJAS2Line()); _joeResponse[0] = 0; for (i = 1; i <= JOE_RESPONSE_MAX; i++) - _joeResponse[i] = _resource->getJAS2Line(); + _joeResponse[i] = _vm->resource()->getJAS2Line(); _aAnim = new char*[_numAAnim + 1]; _aAnim[0] = 0; for (i = 1; i <= _numAAnim; i++) - _aAnim[i] = _resource->getJAS2Line(); + _aAnim[i] = _vm->resource()->getJAS2Line(); _aName = new char*[_numAName + 1]; _aName[0] = 0; for (i = 1; i <= _numAName; i++) - _aName[i] = _resource->getJAS2Line(); + _aName[i] = _vm->resource()->getJAS2Line(); _aFile = new char*[_numAFile + 1]; _aFile[0] = 0; for (i = 1; i <= _numAFile; i++) - _aFile[i] = _resource->getJAS2Line(); + _aFile[i] = _vm->resource()->getJAS2Line(); // Step 3 : initialise game state / variables - _cmd->clear(false); + _vm->command()->clear(false); _scene = 0; memset(_gameState, 0, sizeof(_gameState)); - _graphics->loadPanel(); - _graphics->bobSetupControl(); + _vm->graphics()->loadPanel(); + _vm->graphics()->bobSetupControl(); joeSetup(); zoneSetupPanel(); @@ -564,7 +559,7 @@ void Logic::joeWalk(JoeWalkMode walking) { _joe.walk = walking; // Do this so that Input doesn't need to know the walk value - _input->dialogueRunning(JWM_SPEAK == walking); + _vm->input()->dialogueRunning(JWM_SPEAK == walking); } void Logic::joeScale(uint16 scale) { @@ -708,17 +703,17 @@ void Logic::zoneSetupPanel() { void Logic::roomErase() { - _graphics->frameEraseAll(false); - _graphics->bankErase(15); - _graphics->bankErase(11); - _graphics->bankErase(10); - _graphics->bankErase(12); + _vm->graphics()->frameEraseAll(false); + _vm->graphics()->bankErase(15); + _vm->graphics()->bankErase(11); + _vm->graphics()->bankErase(10); + _vm->graphics()->bankErase(12); if (_currentRoom >= 114) { - _display->palFadeOut(0, 255, _currentRoom); + _vm->display()->palFadeOut(0, 255, _currentRoom); } else { - _display->palFadeOut(0, 223, _currentRoom); + _vm->display()->palFadeOut(0, 223, _currentRoom); } // TODO: credits system @@ -790,9 +785,9 @@ void Logic::roomSetupFurniture() { if (pgd->lastFrame == 0) { ++_numFurnitureStatic; ++curImage; - _graphics->bankUnpack(pgd->firstFrame, curImage, 15); + _vm->graphics()->bankUnpack(pgd->firstFrame, curImage, 15); ++_numFrames; - BobSlot *pbs = _graphics->bob(19 + _numFurnitureStatic); + BobSlot *pbs = _vm->graphics()->bob(19 + _numFurnitureStatic); pbs->active = true; pbs->x = pgd->x; pbs->y = pgd->y; @@ -822,10 +817,10 @@ void Logic::roomSetupFurniture() { int k; for (k = pgd->firstFrame; k <= lastFrame; ++k) { ++curImage; - _graphics->bankUnpack(k, curImage, 15); + _vm->graphics()->bankUnpack(k, curImage, 15); ++_numFrames; } - BobSlot *pbs = _graphics->bob(5 + curBob); + BobSlot *pbs = _vm->graphics()->bob(5 + curBob); pbs->animNormal(image, curImage, pgd->speed / 4, rebound, false); pbs->x = pgd->x; pbs->y = pgd->y; @@ -841,8 +836,8 @@ void Logic::roomSetupFurniture() { if (obj > 5000) { obj -= 5000; GraphicData *pgd = &_graphicData[obj]; - _graphics->bankUnpack(pgd->firstFrame, curImage, 15); - _graphics->bobPaste(curImage, pgd->x, pgd->y); + _vm->graphics()->bankUnpack(pgd->firstFrame, curImage, 15); + _vm->graphics()->bobPaste(curImage, pgd->x, pgd->y); // no need to increment curImage here, as bobPaste() destroys the // unpacked frame after blitting it } @@ -864,7 +859,7 @@ void Logic::roomSetupObjects() { // invalidates all Bobs for persons (except Joe's one) for (i = 1; i <= 3; ++i) { - _graphics->bob(i)->active = false; + _vm->graphics()->bob(i)->active = false; } // static/animated Bobs @@ -906,12 +901,12 @@ void Logic::roomSetupObjects() { uint16 firstFrame = curImage + 1; for (j = pgd->firstFrame; j <= lastFrame; ++j) { ++curImage; - _graphics->bankUnpack(j, curImage, 15); + _vm->graphics()->bankUnpack(j, curImage, 15); ++_numFrames; } curBob = 5 + _numFurnitureAnimated + numObjectAnimated; if (pod->name > 0) { - BobSlot *pbs = _graphics->bob(curBob); + BobSlot *pbs = _vm->graphics()->bob(curBob); pbs->active = true; pbs->x = pgd->x; pbs->y = pgd->y; @@ -926,14 +921,14 @@ void Logic::roomSetupObjects() { // static objects curBob = 20 + _numFurnitureStatic + numObjectStatic; ++curImage; - _graphics->bobClear(curBob); + _vm->graphics()->bobClear(curBob); // FIXME: if((COMPANEL==2) && (FULLSCREEN==1)) bobs[CURRBOB].y2=199; - _graphics->bankUnpack(pgd->firstFrame, curImage, 15); + _vm->graphics()->bankUnpack(pgd->firstFrame, curImage, 15); ++_numFrames; if (pod->name > 0) { - BobSlot *pbs = _graphics->bob(curBob); + BobSlot *pbs = _vm->graphics()->bob(curBob); pbs->active = true; pbs->x = pgd->x; pbs->y = pgd->y; @@ -969,8 +964,8 @@ void Logic::roomSetupObjects() { if (obj > 5000) { obj -= 5000; GraphicData *pgd = &_graphicData[obj]; - _graphics->bankUnpack(pgd->firstFrame, curImage, 15); - _graphics->bobPaste(curImage, pgd->x, pgd->y); + _vm->graphics()->bankUnpack(pgd->firstFrame, curImage, 15); + _vm->graphics()->bobPaste(curImage, pgd->x, pgd->y); } } } @@ -1001,12 +996,12 @@ uint16 Logic::roomRefreshObject(uint16 obj) { // find bob for the object uint16 curBob = findBob(obj); - BobSlot *pbs = _graphics->bob(curBob); + BobSlot *pbs = _vm->graphics()->bob(curBob); if (pod->image == -3 || pod->image == -4) { // a person object if (pod->name <= 0) { - _graphics->bobClear(curBob); + _vm->graphics()->bobClear(curBob); } else { // find person number @@ -1033,7 +1028,7 @@ uint16 Logic::roomRefreshObject(uint16 obj) { if (pod->name < 0 || pod->image < 0) { // object is hidden or disabled - _graphics->bobClear(curBob); + _vm->graphics()->bobClear(curBob); return curImage; } @@ -1055,14 +1050,14 @@ uint16 Logic::roomRefreshObject(uint16 obj) { } else if (lastFrame != 0) { // turn on an animated bob - _graphics->bankUnpack(pgd->firstFrame, 2, 15); + _vm->graphics()->bankUnpack(pgd->firstFrame, 2, 15); pbs->animating = false; uint16 firstImage = curImage; --curImage; uint16 j; for (j = pgd->firstFrame; j <= lastFrame; ++j) { ++curImage; - _graphics->bankUnpack(j, curImage, 15); + _vm->graphics()->bankUnpack(j, curImage, 15); } pbs->active = true; pbs->x = pgd->x; @@ -1074,8 +1069,8 @@ uint16 Logic::roomRefreshObject(uint16 obj) { } else { // frame 2 is used as a buffer frame to prevent BOB flickering - _graphics->bankUnpack(pgd->firstFrame, 2, 15); - _graphics->bankUnpack(pgd->firstFrame, curImage, 15); + _vm->graphics()->bankUnpack(pgd->firstFrame, 2, 15); + _vm->graphics()->bankUnpack(pgd->firstFrame, curImage, 15); pbs->active = true; pbs->x = pgd->x; pbs->y = pgd->y; @@ -1092,20 +1087,20 @@ void Logic::roomSetup(const char *room, int comPanel, bool inCutaway) { // loads background image sprintf(filename, "%s.PCX", room); - _graphics->loadBackdrop(filename, _currentRoom); + _vm->graphics()->loadBackdrop(filename, _currentRoom); // custom colors - _display->palCustomColors(_currentRoom); + _vm->display()->palCustomColors(_currentRoom); // setup graphics to enter fullscreen/panel mode - _display->screenMode(comPanel, inCutaway); + _vm->display()->screenMode(comPanel, inCutaway); // reset sprites table (bounding box...) - _graphics->bobClearAll(); + _vm->graphics()->bobClearAll(); // load/setup objects associated to this room sprintf(filename, "%s.BBK", room); - _graphics->bankLoad(filename, 15); + _vm->graphics()->bankLoad(filename, 15); zoneSetup(); _numFrames = 37 + FRAMES_JOE_XTRA; @@ -1120,7 +1115,7 @@ void Logic::roomDisplay(uint16 room, RoomDisplayMode mode, uint16 scale, int com roomErase(); - // XXX _sound->loadSFX(SFXNAME[_currentRoom]); + // XXX _vm->sound()->loadSFX(SFXNAME[_currentRoom]); roomSetup(roomName(room), comPanel, inCutaway); ObjectData *pod = NULL; @@ -1129,16 +1124,16 @@ void Logic::roomDisplay(uint16 room, RoomDisplayMode mode, uint16 scale, int com } if (mode != RDM_NOFADE_JOE) { update(); - BobSlot *joe = _graphics->bob(0); + BobSlot *joe = _vm->graphics()->bob(0); if (IS_CD_INTRO_ROOM(_currentRoom)) { - _display->palFadeIn(0, 255, _currentRoom, joe->active, joe->x, joe->y); + _vm->display()->palFadeIn(0, 255, _currentRoom, joe->active, joe->x, joe->y); } else { - _display->palFadeIn(0, 223, _currentRoom, joe->active, joe->x, joe->y); + _vm->display()->palFadeIn(0, 223, _currentRoom, joe->active, joe->x, joe->y); } } if (pod != NULL) { - _walk->moveJoe(0, pod->x, pod->y, inCutaway); + _vm->walk()->moveJoe(0, pod->x, pod->y, inCutaway); } } @@ -1206,7 +1201,7 @@ void Logic::personSetData(int16 noun, const char *actorName, bool loadBank, Pers if (loadBank) { const char *actorFile = _aFile[pp->actor->actorFile]; if (actorFile) { - _graphics->bankLoad(actorFile, pp->actor->bankNum); + _vm->graphics()->bankLoad(actorFile, pp->actor->bankNum); } // if actorFile is null, the person data is already loaded as // it is contained in objects room bank (.bbk) @@ -1235,14 +1230,14 @@ uint16 Logic::personSetup(uint16 noun, uint16 curImage) { return curImage; } - _graphics->bankUnpack(pad->bobFrameStanding, p.bobFrame, p.actor->bankNum); + _vm->graphics()->bankUnpack(pad->bobFrameStanding, p.bobFrame, p.actor->bankNum); bool xflip = false; uint16 person = _roomData[_currentRoom] + noun; if (_objectData[person].image == -3) { // person is facing left xflip = true; } - BobSlot *pbs = _graphics->bob(pad->bobNum); + BobSlot *pbs = _vm->graphics()->bob(pad->bobNum); pbs->active = true; pbs->scale = scale; pbs->x = pad->x; @@ -1364,12 +1359,12 @@ uint16 Logic::animCreate(uint16 curImage, const Person *person) { for (i = 1; i <= 255; ++i) { if (allocatedFrames[i] != 0) { ++curImage; - _graphics->bankUnpack(i, curImage, person->actor->bankNum); + _vm->graphics()->bankUnpack(i, curImage, person->actor->bankNum); } } // start animation - _graphics->bob(person->actor->bobNum)->animString(animFrames); + _vm->graphics()->bob(person->actor->bobNum)->animString(animFrames); return curImage; } @@ -1378,7 +1373,7 @@ uint16 Logic::animCreate(uint16 curImage, const Person *person) { void Logic::animErase(uint16 bobNum) { _newAnim[bobNum][0].frame = 0; - BobSlot *pbs = _graphics->bob(bobNum); + BobSlot *pbs = _vm->graphics()->bob(bobNum); pbs->animating = false; pbs->anim.string.buffer = NULL; } @@ -1387,7 +1382,7 @@ void Logic::animErase(uint16 bobNum) { void Logic::animReset(uint16 bobNum) { if (_newAnim[bobNum][0].frame != 0) { - _graphics->bob(bobNum)->animString(_newAnim[bobNum]); + _vm->graphics()->bob(bobNum)->animString(_newAnim[bobNum]); } } @@ -1434,9 +1429,9 @@ void Logic::animSetup(const GraphicData *gd, uint16 firstImage, uint16 bobNum, b // queen.c l.962-980 / l.1269-1294 for (i = 0; i < gd->lastFrame; ++i) { - _graphics->bankUnpack(ABS(tempFrames[i]), firstImage + i, 15); + _vm->graphics()->bankUnpack(ABS(tempFrames[i]), firstImage + i, 15); } - BobSlot *pbs = _graphics->bob(bobNum); + BobSlot *pbs = _vm->graphics()->bob(bobNum); pbs->animating = false; if (visible) { pbs->x = gd->x; @@ -1474,16 +1469,16 @@ void Logic::animSetup(const GraphicData *gd, uint16 firstImage, uint16 bobNum, b void Logic::joeSetupFromBanks(const char *animBank, const char *standBank) { int i; - _graphics->bankLoad(animBank, 13); + _vm->graphics()->bankLoad(animBank, 13); for (i = 11; i <= 28 + FRAMES_JOE_XTRA; ++i) { - _graphics->bankUnpack(i - 10, i, 13); + _vm->graphics()->bankUnpack(i - 10, i, 13); } - _graphics->bankErase(13); + _vm->graphics()->bankErase(13); - _graphics->bankLoad(standBank, 7); - _graphics->bankUnpack(1, 33 + FRAMES_JOE_XTRA, 7); - _graphics->bankUnpack(3, 34 + FRAMES_JOE_XTRA, 7); - _graphics->bankUnpack(5, 35 + FRAMES_JOE_XTRA, 7); + _vm->graphics()->bankLoad(standBank, 7); + _vm->graphics()->bankUnpack(1, 33 + FRAMES_JOE_XTRA, 7); + _vm->graphics()->bankUnpack(3, 34 + FRAMES_JOE_XTRA, 7); + _vm->graphics()->bankUnpack(5, 35 + FRAMES_JOE_XTRA, 7); } @@ -1563,15 +1558,15 @@ ObjectData *Logic::joeSetupInRoom(bool autoPosition, uint16 scale) { } joePrevFacing(joeFacing()); - BobSlot *pbs = _graphics->bob(0); + BobSlot *pbs = _vm->graphics()->bob(0); pbs->scale = joeScale(); if (_currentRoom == 108) { - _graphics->cameraBob(-1); - _graphics->bankLoad("joe_e.act", 7); - _graphics->bankUnpack(2, 29 + FRAMES_JOE_XTRA, 7); + _vm->graphics()->cameraBob(-1); + _vm->graphics()->bankLoad("joe_e.act", 7); + _vm->graphics()->bankUnpack(2, 29 + FRAMES_JOE_XTRA, 7); - _display->horizontalScroll(320); + _vm->display()->horizontalScroll(320); joeFacing(DIR_RIGHT); joeCutFacing(DIR_RIGHT); @@ -1597,7 +1592,7 @@ ObjectData *Logic::joeSetupInRoom(bool autoPosition, uint16 scale) { uint16 Logic::joeFace() { debug(9, "Logic::joeFace() - curFace = %d, prevFace = %d", _joe.facing, _joe.prevFacing); - BobSlot *pbs = _graphics->bob(0); + BobSlot *pbs = _vm->graphics()->bob(0); uint16 frame; if (_currentRoom == 108) { frame = 1; @@ -1641,7 +1636,7 @@ uint16 Logic::joeFace() { } } pbs->frameNum = 29 + FRAMES_JOE_XTRA; - _graphics->bankUnpack(frame, pbs->frameNum, 7); + _vm->graphics()->bankUnpack(frame, pbs->frameNum, 7); return frame; } @@ -1649,7 +1644,7 @@ uint16 Logic::joeFace() { void Logic::joeGrab(int16 grabState) { uint16 frame = 0; - BobSlot *bobJoe = _graphics->bob(0); + BobSlot *bobJoe = _vm->graphics()->bob(0); switch (grabState) { case STATE_GRAB_NONE: @@ -1678,12 +1673,12 @@ void Logic::joeGrab(int16 grabState) { case STATE_GRAB_UP: // turn back - _graphics->bankUnpack(5, 29 + FRAMES_JOE_XTRA, 7); + _vm->graphics()->bankUnpack(5, 29 + FRAMES_JOE_XTRA, 7); bobJoe->xflip = (joeFacing() == DIR_LEFT); bobJoe->scale = joeScale(); update(); // grab up - _graphics->bankUnpack(7, 29 + FRAMES_JOE_XTRA, 7); + _vm->graphics()->bankUnpack(7, 29 + FRAMES_JOE_XTRA, 7); bobJoe->xflip = (joeFacing() == DIR_LEFT); bobJoe->scale = joeScale(); update(); @@ -1693,7 +1688,7 @@ void Logic::joeGrab(int16 grabState) { } if (frame != 0) { - _graphics->bankUnpack(frame, 29 + FRAMES_JOE_XTRA, 7); + _vm->graphics()->bankUnpack(frame, 29 + FRAMES_JOE_XTRA, 7); bobJoe->xflip = (joeFacing() == DIR_LEFT); bobJoe->scale = joeScale(); update(); @@ -1720,7 +1715,7 @@ void Logic::joeUseDress(bool showCut) { playCutaway("cudrs.CUT"); } } - _display->palSetJoe(JP_DRESS); + _vm->display()->palSetJoe(JP_DRESS); joeSetupFromBanks("JoeD_A.BBK", "JoeD_B.BBK"); inventoryDeleteItem(ITEM_DRESS); gameState(VAR_DRESSING_MODE, 2); @@ -1735,7 +1730,7 @@ void Logic::joeUseClothes(bool showCut) { playCutaway("cdclo.CUT"); inventoryInsertItem(ITEM_DRESS); } - _display->palSetJoe(JP_CLOTHES); + _vm->display()->palSetJoe(JP_CLOTHES); joeSetupFromBanks("Joe_A.BBK", "Joe_B.BBK"); inventoryDeleteItem(ITEM_CLOTHES); gameState(VAR_DRESSING_MODE, 0); @@ -1744,7 +1739,7 @@ void Logic::joeUseClothes(bool showCut) { void Logic::joeUseUnderwear() { - _display->palSetJoe(JP_CLOTHES); + _vm->display()->palSetJoe(JP_CLOTHES); joeSetupFromBanks("JoeU_A.BBK", "JoeU_B.BBK"); gameState(VAR_DRESSING_MODE, 1); } @@ -1752,8 +1747,8 @@ void Logic::joeUseUnderwear() { void Logic::makePersonSpeak(const char *sentence, Person *person, const char *voiceFilePrefix) { - _cmd->clear(false); - Talk::speak(sentence, person, voiceFilePrefix, _graphics, _input, this, _resource, _sound); + _vm->command()->clear(false); + Talk::speak(sentence, person, voiceFilePrefix, _vm); } @@ -1763,10 +1758,10 @@ void Logic::dialogue(const char *dlgFile, int personInRoom, char *cutaway) { if (cutaway == NULL) { cutaway = cutawayFile; } - _display->fullscreen(true); - Talk::talk(dlgFile, personInRoom, cutaway, _graphics, _input, this, _resource, _sound); + _vm->display()->fullscreen(true); + Talk::talk(dlgFile, personInRoom, cutaway, _vm); if (!cutaway[0]) { - _display->fullscreen(false); + _vm->display()->fullscreen(false); } } @@ -1777,8 +1772,8 @@ void Logic::playCutaway(const char *cutFile, char *next) { if (next == NULL) { next = nextFile; } - _graphics->textClear(CmdText::COMMAND_Y_POS, CmdText::COMMAND_Y_POS); - Cutaway::run(cutFile, next, _graphics, _input, this, _resource, _sound); + _vm->graphics()->textClear(CmdText::COMMAND_Y_POS, CmdText::COMMAND_Y_POS); + Cutaway::run(cutFile, next, _vm); } @@ -1806,7 +1801,7 @@ uint16 Logic::findObjectUnderCursor(int16 cursorx, int16 cursory) const { uint16 roomObj = 0; if (cursory < ROOM_ZONE_HEIGHT) { - int16 x = cursorx + _display->horizontalScroll(); + int16 x = cursorx + _vm->display()->horizontalScroll(); roomObj = zoneIn(ZONE_ROOM, x, cursory); } return roomObj; @@ -1848,7 +1843,7 @@ uint16 Logic::findInventoryItem(int invSlot) const { void Logic::inventorySetup() { - _graphics->bankLoad("objects.BBK", 14); + _vm->graphics()->bankLoad("objects.BBK", 14); _inventoryItem[0] = ITEM_BAT; _inventoryItem[1] = ITEM_JOURNAL; _inventoryItem[2] = ITEM_NONE; @@ -1866,12 +1861,12 @@ void Logic::inventoryRefresh() { // whereas 2nd, 3rd and 4th uses frame 9 uint16 dstFrame = (itemNum != 0) ? 8 : 9; // unpack frame for object and draw it - _graphics->bankUnpack(_itemData[itemNum].frame, dstFrame, 14); - _graphics->bobDrawInventoryItem(dstFrame, x, 14); + _vm->graphics()->bankUnpack(_itemData[itemNum].frame, dstFrame, 14); + _vm->graphics()->bobDrawInventoryItem(dstFrame, x, 14); } else { // no object, clear the panel - _graphics->bobDrawInventoryItem(0, x, 14); + _vm->graphics()->bobDrawInventoryItem(0, x, 14); } x += 35; } @@ -2027,7 +2022,7 @@ void Logic::objectCopy(int dummyObjectIndex, int realObjectIndex) { void Logic::checkPlayer() { update(); - _cmd->updatePlayer(); + _vm->command()->updatePlayer(); } @@ -2037,7 +2032,7 @@ void Logic::customMoveJoe(int facing, uint16 areaNum, uint16 walkDataNum) { debug(9, "customMoveJoe(%d, %d, %d)\n", facing, areaNum, walkDataNum); // Stop animating Joe - _graphics->bob(0)->animating = false; + _vm->graphics()->bob(0)->animating = false; // Make Joe face the right direction joeFacing(facing); @@ -2154,18 +2149,18 @@ void Logic::customMoveJoe(int facing, uint16 areaNum, uint16 walkDataNum) { void Logic::handlePinnacleRoom() { // camera does not follow Joe anymore - _graphics->cameraBob(-1); + _vm->graphics()->cameraBob(-1); roomDisplay(ROOM_JUNGLE_PINNACLE, RDM_NOFADE_JOE, 100, 2, true); - BobSlot *joe = _graphics->bob(6); - BobSlot *piton = _graphics->bob(7); + BobSlot *joe = _vm->graphics()->bob(6); + BobSlot *piton = _vm->graphics()->bob(7); // set scrolling value to mouse position to avoid glitch - _display->horizontalScroll(_input->mousePosX()); + _vm->display()->horizontalScroll(_vm->input()->mousePosX()); - joe->x = piton->x = 3 * _input->mousePosX() / 4 + 200; + joe->x = piton->x = 3 * _vm->input()->mousePosX() / 4 + 200; - joe->frameNum = _input->mousePosX() / 36 + 43 + FRAMES_JOE_XTRA; + joe->frameNum = _vm->input()->mousePosX() / 36 + 43 + FRAMES_JOE_XTRA; // adjust bounding box for fullscreen joe->box.y2 = piton->box.y2 = GAME_SCREEN_HEIGHT - 1; @@ -2175,18 +2170,18 @@ void Logic::handlePinnacleRoom() { joe->animating = piton->animating = false; update(); - _display->palFadeIn(0, 223, ROOM_JUNGLE_PINNACLE, joe->active, joe->x, joe->y); + _vm->display()->palFadeIn(0, 223, ROOM_JUNGLE_PINNACLE, joe->active, joe->x, joe->y); _entryObj = 0; uint16 prevObj = 0; - while (_input->mouseButton() == 0 || _entryObj == 0) { + while (_vm->input()->mouseButton() == 0 || _entryObj == 0) { update(); - int mx = _input->mousePosX(); - int my = _input->mousePosY(); + int mx = _vm->input()->mousePosX(); + int my = _vm->input()->mousePosY(); // update screen scrolling - _display->horizontalScroll(_input->mousePosX()); + _vm->display()->horizontalScroll(_vm->input()->mousePosX()); // update bobs position / frame joe->x = piton->x = 3 * mx / 4 + 200; @@ -2201,13 +2196,13 @@ void Logic::handlePinnacleRoom() { _entryObj = objData->entryObj; char textCmd[CmdText::MAX_COMMAND_LEN]; sprintf(textCmd, "%s %s", Verb(VERB_WALK_TO).name(), _objName[objData->name]); - _graphics->textCurrentColor(INK_PINNACLE_ROOM); - _graphics->textSetCentered(5, textCmd); + _vm->graphics()->textCurrentColor(INK_PINNACLE_ROOM); + _vm->graphics()->textSetCentered(5, textCmd); } prevObj = curObj; } } - _input->clearMouseButton(); + _vm->input()->clearMouseButton(); _newRoom = _objectData[_entryObj].room; @@ -2227,31 +2222,31 @@ void Logic::handlePinnacleRoom() { // XXX if (com->song > 0) { playsong(com->song); } joe->active = piton->active = false; - _graphics->textClear(5, 5); + _vm->graphics()->textClear(5, 5); // camera follows Joe again - _graphics->cameraBob(0); + _vm->graphics()->cameraBob(0); - _display->palFadeOut(0, 223, ROOM_JUNGLE_PINNACLE); + _vm->display()->palFadeOut(0, 223, ROOM_JUNGLE_PINNACLE); } void Logic::update() { - _graphics->update(_currentRoom); - _input->delay(); - _display->palCustomScroll(_currentRoom); - BobSlot *joe = _graphics->bob(0); - _display->update(joe->active, joe->x, joe->y); - _dbg->update(_input->checkKeys()); - - if (_input->quickSave()) - if (!_input->cutawayRunning()) { - _input->quickSaveReset(); + _vm->graphics()->update(_currentRoom); + _vm->input()->delay(); + _vm->display()->palCustomScroll(_currentRoom); + BobSlot *joe = _vm->graphics()->bob(0); + _vm->display()->update(joe->active, joe->x, joe->y); + _dbg->update(_vm->input()->checkKeys()); + + if (_vm->input()->quickSave()) + if (!_vm->input()->cutawayRunning()) { + _vm->input()->quickSaveReset(); gameSave(0, "Quicksave"); } - if (_input->quickLoad()) - if (!_input->cutawayRunning()) { - _input->quickLoadReset(); + if (_vm->input()->quickLoad()) + if (!_vm->input()->cutawayRunning()) { + _vm->input()->quickLoadReset(); gameLoad(0); } } @@ -2274,17 +2269,17 @@ bool Logic::gameSave(uint16 slot, const char *desc) { WRITE_BE_UINT16(ptr, _talkSpeed); ptr += 2; WRITE_BE_UINT16(ptr, 0 /*_settings.musicVolume*/); ptr += 2; - WRITE_BE_UINT16(ptr, _sound->sfxOn() ? 1 : 0); ptr += 2; - WRITE_BE_UINT16(ptr, _sound->speechOn() ? 1 : 0); ptr += 2; - WRITE_BE_UINT16(ptr, _sound->musicOn() ? 1 : 0); ptr += 2; + WRITE_BE_UINT16(ptr, _vm->sound()->sfxOn() ? 1 : 0); ptr += 2; + WRITE_BE_UINT16(ptr, _vm->sound()->speechOn() ? 1 : 0); ptr += 2; + WRITE_BE_UINT16(ptr, _vm->sound()->musicOn() ? 1 : 0); ptr += 2; WRITE_BE_UINT16(ptr, _subtitles ? 1 : 0); ptr += 2; for (i = 0; i < 4; i++) { WRITE_BE_UINT16(ptr, _inventoryItem[i]); ptr += 2; } - WRITE_BE_UINT16(ptr, _graphics->bob(0)->x); ptr += 2; - WRITE_BE_UINT16(ptr, _graphics->bob(0)->y); ptr += 2; + WRITE_BE_UINT16(ptr, _vm->graphics()->bob(0)->x); ptr += 2; + WRITE_BE_UINT16(ptr, _vm->graphics()->bob(0)->y); ptr += 2; WRITE_BE_UINT16(ptr, _currentRoom); ptr += 2; for (i = 1; i <= _numObjects; i++) @@ -2321,7 +2316,7 @@ bool Logic::gameSave(uint16 slot, const char *desc) { return false; } - bool result = _resource->writeSave(slot, saveData, SAVEGAME_SIZE); + bool result = _vm->resource()->writeSave(slot, saveData, SAVEGAME_SIZE); delete[] saveData; return result; @@ -2331,7 +2326,7 @@ bool Logic::gameLoad(uint16 slot) { int i, j; byte *saveData = new byte[SAVEGAME_SIZE]; byte *ptr = saveData; - if (!_resource->readSave(slot, saveData)) { + if (!_vm->resource()->readSave(slot, saveData)) { warning("Couldn't load savegame from slot %d", slot); delete[] saveData; return false; @@ -2339,11 +2334,11 @@ bool Logic::gameLoad(uint16 slot) { debug(3, "Loading game from slot %d", slot); ptr += 32; //skip description - _talkSpeed = (int16)READ_BE_UINT16(ptr); ptr += 2; + /*_talkSpeed = (int16)READ_BE_UINT16(ptr);*/ ptr += 2; /*_settings.musicVolume = (int16)READ_BE_UINT16(ptr);*/ ptr += 2; - _sound->sfxToggle(READ_BE_UINT16(ptr) != 0); ptr += 2; - _sound->speechToggle(READ_BE_UINT16(ptr) != 0); ptr += 2; - _sound->musicToggle(READ_BE_UINT16(ptr) != 0); ptr += 2; + _vm->sound()->sfxToggle(READ_BE_UINT16(ptr) != 0); ptr += 2; + _vm->sound()->speechToggle(READ_BE_UINT16(ptr) != 0); ptr += 2; + _vm->sound()->musicToggle(READ_BE_UINT16(ptr) != 0); ptr += 2; _subtitles = READ_BE_UINT16(ptr) != 0; ptr += 2; for (i = 0; i < 4; i++) { @@ -2378,7 +2373,7 @@ bool Logic::gameLoad(uint16 slot) { joeFacing(READ_BE_UINT16(ptr)); ptr += 2; READ_BE_UINT16(ptr); ptr += 2; //TODO: tmpbamflag READ_BE_UINT16(ptr); ptr += 2; //TODO: lastoverride - //_sound->playSound(_sound->lastOverride()) + //_vm->sound()->playSound(_vm->sound()->lastOverride()) //TODO: lastmerge, lastalter, altmrgpri for (i = 0; i < 3; i++) { @@ -2421,10 +2416,10 @@ void Logic::sceneStart() { debug(0, "[Logic::sceneStart] _scene = %i", _scene); _scene++; - _display->showMouseCursor(false); + _vm->display()->showMouseCursor(false); - if (1 == _scene) { // && _input->cutawayRunning()) { // sceneStart is always called when cutaway is running - _display->palFadePanel(); + if (1 == _scene) { // && _vm->input()->cutawayRunning()) { // sceneStart is always called when cutaway is running + _vm->display()->palFadePanel(); } update(); @@ -2437,8 +2432,8 @@ void Logic::sceneStop() { if (_scene > 0) return; - _display->palSetAllDirty(); - _display->showMouseCursor(true); + _vm->display()->palSetAllDirty(); + _vm->display()->showMouseCursor(true); zoneSetupPanel(); } @@ -2450,14 +2445,14 @@ void Logic::changeRoom() { } else if (currentRoom() == FOTAQ_LOGO && gameState(VAR_INTRO_PLAYED) == 0) { // FIXME: this should be rewritten in a more elegant way - bool pcGamesDemo = _resource->isDemo() && !_resource->exists("pclogo.cut"); + bool pcGamesDemo = _vm->resource()->isDemo() && !_vm->resource()->exists("pclogo.cut"); if (pcGamesDemo) { currentRoom(79); } roomDisplay(currentRoom(), RDM_FADE_NOJOE, 100, 2, true); - if (_resource->isDemo()) { + if (_vm->resource()->isDemo()) { if (pcGamesDemo) { playCutaway("clogo.cut"); } @@ -2474,7 +2469,7 @@ void Logic::changeRoom() { playCutaway("cdint.cut"); // restore palette colors ranging from 144 to 256 - _graphics->loadPanel(); + _vm->graphics()->loadPanel(); playCutaway("cred.cut"); } @@ -2496,13 +2491,13 @@ void Logic::changeRoom() { else { roomDisplay(currentRoom(), RDM_FADE_JOE, 100, 1, false); } - _display->showMouseCursor(true); // _drawMouseFlag = 1; + _vm->display()->showMouseCursor(true); // _drawMouseFlag = 1; } void Logic::useJournal() { - if (_resource->isDemo()) { + if (_vm->resource()->isDemo()) { makePersonSpeak("This is a demo, so I can't load or save games*14", NULL, ""); } else { @@ -2513,12 +2508,12 @@ void Logic::useJournal() { // XXX bamflag=0; // XXX in_journal=1; - _cmd->clear(false); + _vm->command()->clear(false); - Journal j(this, _graphics, _display, _sound); + Journal j(_vm); j.use(); - _walk->stopJoe(); + _vm->walk()->stopJoe(); // XXX restore vars // @@ -2536,7 +2531,7 @@ void Logic::registerDefaultSettings() { ConfMan.registerDefault("music_mute", false); ConfMan.registerDefault("sfx_mute", false); ConfMan.registerDefault("talkspeed", DEFAULT_TALK_SPEED); - ConfMan.registerDefault("speech_mute", _resource->isFloppy()); + ConfMan.registerDefault("speech_mute", _vm->resource()->isFloppy()); ConfMan.registerDefault("subtitles", true); } @@ -2554,12 +2549,12 @@ void Logic::checkOptionSettings() { // XXX check master_volume value // only CD-ROM version has speech - if (_resource->JASVersion()[0] != 'C' && _sound->speechOn()) { - _sound->speechToggle(false); + if (_vm->resource()->JASVersion()[0] != 'C' && _vm->sound()->speechOn()) { + _vm->sound()->speechToggle(false); } // ensure text is always on when voice is off - if (!_sound->speechOn()) { + if (!_vm->sound()->speechOn()) { _subtitles = true; } } @@ -2568,10 +2563,10 @@ void Logic::checkOptionSettings() { void Logic::readOptionSettings() { // XXX master_volume - _sound->musicToggle(!ConfMan.getBool("music_mute")); - _sound->sfxToggle(!ConfMan.getBool("sfx_mute")); + _vm->sound()->musicToggle(!ConfMan.getBool("music_mute")); + _vm->sound()->sfxToggle(!ConfMan.getBool("sfx_mute")); _talkSpeed = ConfMan.getInt("talkspeed"); - _sound->speechToggle(!ConfMan.getBool("speech_mute")); + _vm->sound()->speechToggle(!ConfMan.getBool("speech_mute")); _subtitles = ConfMan.getBool("subtitles"); checkOptionSettings(); @@ -2581,10 +2576,10 @@ void Logic::readOptionSettings() { void Logic::writeOptionSettings() { // XXX master_volume - ConfMan.set("music_mute", !_sound->musicOn()); - ConfMan.set("sfx_mute", !_sound->sfxOn()); + ConfMan.set("music_mute", !_vm->sound()->musicOn()); + ConfMan.set("sfx_mute", !_vm->sound()->sfxOn()); ConfMan.set("talkspeed", _talkSpeed); - ConfMan.set("speech_mute", !_sound->speechOn()); + ConfMan.set("speech_mute", !_vm->sound()->speechOn()); ConfMan.set("subtitles", _subtitles); ConfMan.flushToDisk(); @@ -2678,34 +2673,34 @@ void Logic::asmMakeJoeUseUnderwear() { void Logic::asmSwitchToDressPalette() { - _display->palSetJoe(JP_DRESS); + _vm->display()->palSetJoe(JP_DRESS); } void Logic::asmSwitchToNormalPalette() { - _display->palSetJoe(JP_CLOTHES); + _vm->display()->palSetJoe(JP_CLOTHES); } void Logic::asmStartCarAnimation() { // Carbam background animation - room 74 - _graphics->initCarBamScene(); + _vm->graphics()->initCarBamScene(); } void Logic::asmStopCarAnimation() { // CR 2 - Turn off big oil splat and gun shots! - _graphics->cleanupCarBamScene(findBob(594)); // Oil object + _vm->graphics()->cleanupCarBamScene(findBob(594)); // Oil object } void Logic::asmStartFightAnimation() { // Fight1 background animation - room 69 - _graphics->initFightBamScene(); + _vm->graphics()->initFightBamScene(); gameState(148, 1); } @@ -2713,8 +2708,8 @@ void Logic::asmStartFightAnimation() { void Logic::asmWaitForFrankPosition() { // c69e.cut - _graphics->bamData()->flag = 2; - while (_graphics->bamData()->flag) { + _vm->graphics()->bamData()->flag = 2; + while (_vm->graphics()->bamData()->flag) { update(); } } @@ -2723,8 +2718,8 @@ void Logic::asmWaitForFrankPosition() { void Logic::asmMakeFrankGrowing() { // c69z.cut - _graphics->bankUnpack(1, 38, 15); - BobSlot *bobFrank = _graphics->bob(5); + _vm->graphics()->bankUnpack(1, 38, 15); + BobSlot *bobFrank = _vm->graphics()->bob(5); bobFrank->frameNum = 38; bobFrank->curPos(160, 200); bobFrank->box.y2 = GAME_SCREEN_HEIGHT - 1; @@ -2750,8 +2745,8 @@ void Logic::asmMakeFrankGrowing() { void Logic::asmMakeRobotGrowing() { // c69z.cut - _graphics->bankUnpack(1, 38, 15); - BobSlot *bobRobot = _graphics->bob(5); + _vm->graphics()->bankUnpack(1, 38, 15); + BobSlot *bobRobot = _vm->graphics()->bob(5); bobRobot->frameNum = 38; bobRobot->curPos(160, 200); bobRobot->box.y2 = GAME_SCREEN_HEIGHT - 1; @@ -2774,7 +2769,7 @@ void Logic::asmShrinkRobot() { int i; for (i = 100; i >= 35; i -= 5) { - _graphics->bob(6)->scale = i; + _vm->graphics()->bob(6)->scale = i; update(); } } @@ -2793,21 +2788,21 @@ void Logic::asmEndGame() { void Logic::asmPutCameraOnDino() { - _graphics->cameraBob(-1); - while (_display->horizontalScroll() < 320) { - _display->horizontalScroll(_display->horizontalScroll() + 16); - if (_display->horizontalScroll() > 320) { - _display->horizontalScroll(320); + _vm->graphics()->cameraBob(-1); + while (_vm->display()->horizontalScroll() < 320) { + _vm->display()->horizontalScroll(_vm->display()->horizontalScroll() + 16); + if (_vm->display()->horizontalScroll() > 320) { + _vm->display()->horizontalScroll(320); } update(); } - _graphics->cameraBob(1); + _vm->graphics()->cameraBob(1); } void Logic::asmPutCameraOnJoe() { - _graphics->cameraBob(0); + _vm->graphics()->cameraBob(0); } @@ -2819,11 +2814,11 @@ void Logic::asmSetAzuraInLove() { void Logic::asmPanRightFromJoe() { - _graphics->cameraBob(-1); - while (_display->horizontalScroll() < 320) { - _display->horizontalScroll(_display->horizontalScroll() + 16); - if (_display->horizontalScroll() > 320) { - _display->horizontalScroll(320); + _vm->graphics()->cameraBob(-1); + while (_vm->display()->horizontalScroll() < 320) { + _vm->display()->horizontalScroll(_vm->display()->horizontalScroll() + 16); + if (_vm->display()->horizontalScroll() > 320) { + _vm->display()->horizontalScroll(320); } update(); } @@ -2832,13 +2827,13 @@ void Logic::asmPanRightFromJoe() { void Logic::asmSetLightsOff() { - _display->palCustomLightsOff(currentRoom()); + _vm->display()->palCustomLightsOff(currentRoom()); } void Logic::asmSetLightsOn() { - _display->palCustomLightsOn(currentRoom()); + _vm->display()->palCustomLightsOn(currentRoom()); } @@ -2850,33 +2845,33 @@ void Logic::asmSetManequinAreaOn() { void Logic::asmPanToJoe() { - int i = _graphics->bob(0)->x - 160; + int i = _vm->graphics()->bob(0)->x - 160; if (i < 0) { i = 0; } else if (i > 320) { i = 320; } - _graphics->cameraBob(-1); - if (i < _display->horizontalScroll()) { - while (_display->horizontalScroll() > i) { - _display->horizontalScroll(_display->horizontalScroll() - 16); - if (_display->horizontalScroll() < i) { - _display->horizontalScroll(i); + _vm->graphics()->cameraBob(-1); + if (i < _vm->display()->horizontalScroll()) { + while (_vm->display()->horizontalScroll() > i) { + _vm->display()->horizontalScroll(_vm->display()->horizontalScroll() - 16); + if (_vm->display()->horizontalScroll() < i) { + _vm->display()->horizontalScroll(i); } update(); } } else { - while (_display->horizontalScroll() < i) { - _display->horizontalScroll(_display->horizontalScroll() + 16); - if (_display->horizontalScroll() > i ) { - _display->horizontalScroll(i); + while (_vm->display()->horizontalScroll() < i) { + _vm->display()->horizontalScroll(_vm->display()->horizontalScroll() + 16); + if (_vm->display()->horizontalScroll() > i ) { + _vm->display()->horizontalScroll(i); } } update(); } - _graphics->cameraBob(0); + _vm->graphics()->cameraBob(0); } @@ -2888,11 +2883,11 @@ void Logic::asmTurnGuardOn() { void Logic::asmPanLeft320To144() { - _graphics->cameraBob(-1); - while (_display->horizontalScroll() > 144) { - _display->horizontalScroll(_display->horizontalScroll() - 8); - if (_display->horizontalScroll() < 144) { - _display->horizontalScroll(144); + _vm->graphics()->cameraBob(-1); + while (_vm->display()->horizontalScroll() > 144) { + _vm->display()->horizontalScroll(_vm->display()->horizontalScroll() - 8); + if (_vm->display()->horizontalScroll() < 144) { + _vm->display()->horizontalScroll(144); } update(); } @@ -2901,11 +2896,11 @@ void Logic::asmPanLeft320To144() { void Logic::asmSmooch() { - _graphics->cameraBob(-1); - BobSlot *bobAzura = _graphics->bob(5); - BobSlot *bobJoe = _graphics->bob(6); - while (_display->horizontalScroll() < 320) { - _display->horizontalScroll(_display->horizontalScroll() + 8); + _vm->graphics()->cameraBob(-1); + BobSlot *bobAzura = _vm->graphics()->bob(5); + BobSlot *bobJoe = _vm->graphics()->bob(6); + while (_vm->display()->horizontalScroll() < 320) { + _vm->display()->horizontalScroll(_vm->display()->horizontalScroll() + 8); if (bobJoe->x - bobAzura->x > 128) { bobAzura->x += 10; bobJoe->x += 6; @@ -2921,11 +2916,11 @@ void Logic::asmSmooch() { void Logic::asmMakeLightningHitPlane() { - _graphics->cameraBob(-1); + _vm->graphics()->cameraBob(-1); short iy = 0, x, ydir = -1, j, k; - BobSlot *planeBob = _graphics->bob(5); - BobSlot *lightningBob = _graphics->bob(20); + BobSlot *planeBob = _vm->graphics()->bob(5); + BobSlot *lightningBob = _vm->graphics()->bob(20); planeBob->box.y2 = lightningBob->box.y2 = 199; planeBob->y = 135; @@ -2947,12 +2942,12 @@ void Logic::asmMakeLightningHitPlane() { int scrollX = x - 163; if (scrollX > 320) scrollX = 320; - _display->horizontalScroll(scrollX); + _vm->display()->horizontalScroll(scrollX); update(); } planeBob->scale = 100; - _display->horizontalScroll(0); + _vm->display()->horizontalScroll(0); planeBob->x -= -8; planeBob->y += 6; @@ -2963,17 +2958,17 @@ void Logic::asmMakeLightningHitPlane() { // 23/2/95 - Play lightning SFX // XXX sfxplay(NULLstr); - _graphics->bankUnpack(18, lightningBob->frameNum, 15); - _graphics->bankUnpack(4, planeBob ->frameNum, 15); + _vm->graphics()->bankUnpack(18, lightningBob->frameNum, 15); + _vm->graphics()->bankUnpack(4, planeBob ->frameNum, 15); // Plane plunges into the jungle! - BobSlot *fireBob = _graphics->bob(6); + BobSlot *fireBob = _vm->graphics()->bob(6); fireBob->animating = true; fireBob->x = planeBob->x; fireBob->y = planeBob->y + 10; - _graphics->bankUnpack(19, fireBob->frameNum, 15); + _vm->graphics()->bankUnpack(19, fireBob->frameNum, 15); update(); k = 20; @@ -2985,8 +2980,8 @@ void Logic::asmMakeLightningHitPlane() { planeBob->x = fireBob->x = x; if (k < 40) { - _graphics->bankUnpack(j, planeBob->frameNum, 15); - _graphics->bankUnpack(k, fireBob ->frameNum, 15); + _vm->graphics()->bankUnpack(j, planeBob->frameNum, 15); + _vm->graphics()->bankUnpack(k, fireBob ->frameNum, 15); k++; j++; @@ -2997,14 +2992,14 @@ void Logic::asmMakeLightningHitPlane() { update(); } - _graphics->cameraBob(0); + _vm->graphics()->cameraBob(0); } void Logic::asmScaleBlimp() { int16 z = 256; - BobSlot *bob = _graphics->bob(7); + BobSlot *bob = _vm->graphics()->bob(7); int16 x = bob->x; int16 y = bob->y; while (bob->x > 150) { @@ -3024,8 +3019,8 @@ void Logic::asmScaleBlimp() { void Logic::asmScaleEnding() { - _graphics->bob(7)->active = false; // Turn off blimp - BobSlot *b = _graphics->bob(20); + _vm->graphics()->bob(7)->active = false; // Turn off blimp + BobSlot *b = _vm->graphics()->bob(20); b->x = 160; b->y = 100; int i; @@ -3036,14 +3031,14 @@ void Logic::asmScaleEnding() { for (i = 0; i < 50; ++i) { update(); } - _display->palFadeOut(0, 255, currentRoom()); + _vm->display()->palFadeOut(0, 255, currentRoom()); } void Logic::asmWaitForCarPosition() { // Wait for car to reach correct position before pouring oil - while (_graphics->bamData()->index != 60) { + while (_vm->graphics()->bamData()->index != 60) { update(); } } @@ -3070,7 +3065,7 @@ void Logic::asmAttemptPuzzle() { void Logic::asmScaleTitle() { - BobSlot *bob = _graphics->bob(5); + BobSlot *bob = _vm->graphics()->bob(5); bob->animating = false; bob->x = 161; bob->y = 200; @@ -3087,17 +3082,17 @@ void Logic::asmScaleTitle() { void Logic::asmPanRightToHugh() { - BobSlot *bob_thugA1 = _graphics->bob(20); - BobSlot *bob_thugA2 = _graphics->bob(21); - BobSlot *bob_thugA3 = _graphics->bob(22); - BobSlot *bob_hugh1 = _graphics->bob(1); - BobSlot *bob_hugh2 = _graphics->bob(23); - BobSlot *bob_hugh3 = _graphics->bob(24); - BobSlot *bob_thugB1 = _graphics->bob(25); - BobSlot *bob_thugB2 = _graphics->bob(26); - - _graphics->cameraBob(-1); - _input->fastMode(true); + BobSlot *bob_thugA1 = _vm->graphics()->bob(20); + BobSlot *bob_thugA2 = _vm->graphics()->bob(21); + BobSlot *bob_thugA3 = _vm->graphics()->bob(22); + BobSlot *bob_hugh1 = _vm->graphics()->bob(1); + BobSlot *bob_hugh2 = _vm->graphics()->bob(23); + BobSlot *bob_hugh3 = _vm->graphics()->bob(24); + BobSlot *bob_thugB1 = _vm->graphics()->bob(25); + BobSlot *bob_thugB2 = _vm->graphics()->bob(26); + + _vm->graphics()->cameraBob(-1); + _vm->input()->fastMode(true); update(); int i = 4, k = 160; @@ -3130,7 +3125,7 @@ void Logic::asmPanRightToHugh() { //debug(0, "horizontalScroll = %i", horizontalScroll); - _display->horizontalScroll(horizontalScroll); + _vm->display()->horizontalScroll(horizontalScroll); bob_thugA1->x -= i * 2; bob_thugA2->x -= i * 2; @@ -3145,30 +3140,30 @@ void Logic::asmPanRightToHugh() { update(); - if (_input->cutawayQuit()) + if (_vm->input()->cutawayQuit()) return; } - _input->fastMode(false); + _vm->input()->fastMode(false); } void Logic::asmMakeWhiteFlash() { - _display->palCustomFlash(); + _vm->display()->palCustomFlash(); } void Logic::asmPanRightToJoeAndRita() { // cdint.cut - BobSlot *bob_box = _graphics->bob(20); - BobSlot *bob_beam = _graphics->bob(21); - BobSlot *bob_crate = _graphics->bob(22); - BobSlot *bob_clock = _graphics->bob(23); - BobSlot *bob_hands = _graphics->bob(24); + BobSlot *bob_box = _vm->graphics()->bob(20); + BobSlot *bob_beam = _vm->graphics()->bob(21); + BobSlot *bob_crate = _vm->graphics()->bob(22); + BobSlot *bob_clock = _vm->graphics()->bob(23); + BobSlot *bob_hands = _vm->graphics()->bob(24); - _graphics->cameraBob(-1); - _input->fastMode(true); + _vm->graphics()->cameraBob(-1); + _vm->input()->fastMode(true); update(); @@ -3176,7 +3171,7 @@ void Logic::asmPanRightToJoeAndRita() { // cdint.cut bob_beam ->x += 30; bob_crate->x += 180 * 3; - int horizontalScroll = _display->horizontalScroll(); + int horizontalScroll = _vm->display()->horizontalScroll(); int i = 1; while (horizontalScroll < 290) { @@ -3187,7 +3182,7 @@ void Logic::asmPanRightToJoeAndRita() { // cdint.cut //debug(0, "horizontalScroll = %i", horizontalScroll); - _display->horizontalScroll(horizontalScroll); + _vm->display()->horizontalScroll(horizontalScroll); bob_box ->x -= i * 2; bob_beam ->x -= i; @@ -3197,22 +3192,22 @@ void Logic::asmPanRightToJoeAndRita() { // cdint.cut update(); - if (_input->cutawayQuit()) + if (_vm->input()->cutawayQuit()) return; } - _input->fastMode(false); + _vm->input()->fastMode(false); } void Logic::asmPanLeftToBomb() { // cdint.cut - BobSlot *bob21 = _graphics->bob(21); - BobSlot *bob22 = _graphics->bob(22); + BobSlot *bob21 = _vm->graphics()->bob(21); + BobSlot *bob22 = _vm->graphics()->bob(22); - _graphics->cameraBob(-1); - _input->fastMode(true); + _vm->graphics()->cameraBob(-1); + _vm->input()->fastMode(true); - int horizontalScroll = _display->horizontalScroll(); + int horizontalScroll = _vm->display()->horizontalScroll(); int i = 5; while (horizontalScroll > 0 || bob21->x < 136) { @@ -3222,7 +3217,7 @@ void Logic::asmPanLeftToBomb() { // cdint.cut horizontalScroll = 0; //debug(0, "horizontalScroll = %i", horizontalScroll); - _display->horizontalScroll(horizontalScroll); + _vm->display()->horizontalScroll(horizontalScroll); if (horizontalScroll < 272 && bob21->x < 136) bob21->x += (i/2); @@ -3231,11 +3226,11 @@ void Logic::asmPanLeftToBomb() { // cdint.cut update(); - if (_input->cutawayQuit()) + if (_vm->input()->cutawayQuit()) return; } - _input->fastMode(false); + _vm->input()->fastMode(false); } diff --git a/queen/logic.h b/queen/logic.h index 97110e6929..f0167d9c77 100644 --- a/queen/logic.h +++ b/queen/logic.h @@ -53,19 +53,13 @@ struct ZoneSlot { Box box; }; -class Command; class Debug; -class Display; -class Input; -class Graphics; -class Resource; -class Sound; -class Walk; +class QueenEngine; class Logic { public: - Logic(Resource *resource, Graphics *graphics, Display *display, Input *input, Sound *sound); + Logic(QueenEngine *vm); ~Logic(); uint16 currentRoom() const { return _currentRoom; } @@ -293,11 +287,6 @@ public: void asmPanRightToJoeAndRita(); void asmPanLeftToBomb(); - Walk *walk() const { return _walk; } - Display *display() const { return _display; } - Command *command() const { return _cmd; } - Resource *resource() const { return _resource; } - typedef void (Logic::*SpecialMoveProc)(); @@ -310,8 +299,6 @@ public: TALK_SELECTED_COUNT = 86 }; - static Common::RandomSource randomizer; - protected: void initialise(); @@ -436,14 +423,8 @@ protected: bool _subtitles; - Resource *_resource; - Graphics *_graphics; Debug *_dbg; - Display *_display; - Input *_input; - Sound *_sound; - Walk *_walk; - Command *_cmd; + QueenEngine *_vm; //! Verbs (in order) available in panel static const VerbEnum PANEL_VERBS[]; diff --git a/queen/queen.cpp b/queen/queen.cpp index f92abc8035..7003b8e5bc 100644 --- a/queen/queen.cpp +++ b/queen/queen.cpp @@ -112,10 +112,13 @@ QueenEngine::~QueenEngine() { _timer->removeTimerProc(&timerHandler); delete _resource; + delete _command; delete _display; - delete _logic; delete _graphics; delete _input; + delete _logic; + delete _sound; + delete _walk; } void QueenEngine::errorString(const char *buf1, char *buf2) { @@ -149,11 +152,11 @@ void QueenEngine::go() { else { if (_logic->joeWalk() == JWM_EXECUTE) { _logic->joeWalk(JWM_NORMAL); - _logic->command()->executeCurrentAction(true); + _command->executeCurrentAction(true); } else { - if (_logic->command()->parse()) { - _logic->command()->clear(true); + if (_command->parse()) { + _command->clear(true); } _logic->joeWalk(JWM_NORMAL); _logic->checkPlayer(); @@ -165,11 +168,13 @@ void QueenEngine::go() { void QueenEngine::initialise(void) { _resource = new Resource(_gameDataPath, _detectname, _system->get_savefile_manager(), getSavePath()); + _command = new Command(this); + _display = new Display(this, _resource->getLanguage(), _system); + _graphics = new Graphics(this); _input = new Input(_resource->getLanguage(), _system); - _display = new Display(_resource->getLanguage(), _system, _input); - _graphics = new Graphics(_display, _input, _resource); - _sound = Sound::giveSound(_mixer, _input, _resource, _resource->compression()); - _logic = new Logic(_resource, _graphics, _display, _input, _sound); + _logic = new Logic(this); + _sound = Sound::giveSound(_mixer, this, _resource->compression()); + _walk = new Walk(this); _timer->installTimerProc(&timerHandler, 1000000 / 50, this); //call 50 times per second } diff --git a/queen/queen.h b/queen/queen.h index ddd8def66f..a6bab365e5 100644 --- a/queen/queen.h +++ b/queen/queen.h @@ -28,12 +28,14 @@ class GameDetector; namespace Queen { +class Command; +class Display; class Graphics; class Input; -class Resource; class Logic; -class Display; +class Resource; class Sound; +class Walk; class QueenEngine : public Engine { public: @@ -41,6 +43,17 @@ public: QueenEngine(GameDetector *detector, OSystem *syst); virtual ~QueenEngine(); + Command *command() const { return _command; } + Display *display() const { return _display; } + Graphics *graphics() const { return _graphics; } + Input *input() const { return _input; } + Logic *logic() const { return _logic; } + Resource *resource() const { return _resource; } + Sound *sound() const { return _sound; } + Walk *walk() const { return _walk; } + + Common::RandomSource randomizer; + protected: void errorString(const char *buf_input, char *buf_output); @@ -52,12 +65,14 @@ protected: static void timerHandler(void *ptr); void gotTimerTick(); + Command *_command; + Display *_display; Graphics *_graphics; Input *_input; - Resource *_resource; Logic *_logic; - Display *_display; + Resource *_resource; Sound *_sound; + Walk *_walk; const char *_detectname; // necessary for music }; diff --git a/queen/sound.cpp b/queen/sound.cpp index 4926493ca4..fbc710a711 100644 --- a/queen/sound.cpp +++ b/queen/sound.cpp @@ -21,7 +21,9 @@ #include "stdafx.h" #include "queen/sound.h" + #include "queen/input.h" +#include "queen/queen.h" #include "queen/resource.h" #define SB_HEADER_SIZE 110 @@ -92,44 +94,44 @@ static ov_callbacks g_File_wrap = { }; #endif -Sound::Sound(SoundMixer *mixer, Input *input, Resource *resource) : - _mixer(mixer), _input(input), _resource(resource), _sfxToggle(true), _speechToggle(true), _musicToggle(true), _lastOverride(0), _currentSong(0), _sfxHandle(0) { +Sound::Sound(SoundMixer *mixer, QueenEngine *vm) : + _mixer(mixer), _vm(vm), _sfxToggle(true), _speechToggle(true), _musicToggle(true), _lastOverride(0), _currentSong(0), _sfxHandle(0) { } Sound::~Sound() { } -Sound *Sound::giveSound(SoundMixer *mixer, Input *input, Resource *resource, uint8 compression) { +Sound *Sound::giveSound(SoundMixer *mixer, QueenEngine *vm, uint8 compression) { switch(compression) { case COMPRESSION_NONE: - return new SBSound(mixer, input, resource); + return new SBSound(mixer, vm); break; case COMPRESSION_MP3: #ifndef USE_MAD warning("Using MP3 compressed datafile, but MP3 support not compiled in"); - return new SilentSound(mixer, input, resource); + return new SilentSound(mixer, vm); #else - return new MP3Sound(mixer, input, resource); + return new MP3Sound(mixer, vm); #endif break; case COMPRESSION_OGG: #ifndef USE_VORBIS warning("Using OGG compressed datafile, but OGG support not compiled in"); - return new SilentSound(mixer, input, resource); + return new SilentSound(mixer, vm); #else - return new OGGSound(mixer, input, resource); + return new OGGSound(mixer, vm); #endif break; default: warning("Unknown compression type"); - return new SilentSound(mixer, input, resource); + return new SilentSound(mixer, vm); } } void Sound::waitSfxFinished() { while(_sfxHandle != 0) - _input->delay(10); + _vm->input()->delay(10); } void Sound::playSong(int16 songNum) { @@ -157,8 +159,8 @@ void SBSound::sfxPlay(const char *base) { waitSfxFinished(); - if (_resource->exists(name)) - playSound(_resource->loadFileMalloc(name, SB_HEADER_SIZE), _resource->fileSize(name) - SB_HEADER_SIZE); + if (_vm->resource()->exists(name)) + playSound(_vm->resource()->loadFileMalloc(name, SB_HEADER_SIZE), _vm->resource()->fileSize(name) - SB_HEADER_SIZE); } #ifdef USE_MAD @@ -174,8 +176,8 @@ void MP3Sound::sfxPlay(const char *base) { waitSfxFinished(); - if (_resource->exists(name)) - _mixer->playMP3(&_sfxHandle, _resource->giveCompressedSound(name), _resource->fileSize(name)); + if (_vm->resource()->exists(name)) + _mixer->playMP3(&_sfxHandle, _vm->resource()->giveCompressedSound(name), _vm->resource()->fileSize(name)); } #endif @@ -192,13 +194,13 @@ void OGGSound::sfxPlay(const char *base) { waitSfxFinished(); - if (_resource->exists(name)) { + if (_vm->resource()->exists(name)) { OggVorbis_File *oggFile = new OggVorbis_File; file_info *f = new file_info; - f->file = _resource->giveCompressedSound(name); - f->start = _resource->fileOffset(name); - f->len = _resource->fileSize(name); + f->file = _vm->resource()->giveCompressedSound(name); + f->start = _vm->resource()->fileOffset(name); + f->len = _vm->resource()->fileSize(name); f->curr_pos = 0; if (ov_open_callbacks((void *)f, oggFile, NULL, 0, g_File_wrap) < 0) { diff --git a/queen/sound.h b/queen/sound.h index 5902857d69..14ae5796af 100644 --- a/queen/sound.h +++ b/queen/sound.h @@ -47,12 +47,14 @@ struct tuneData { int16 delay; }; +class QueenEngine; + class Sound { public: - Sound(SoundMixer *mixer, Input *input, Resource *resource); + Sound(SoundMixer *mixer, QueenEngine *vm); virtual ~Sound(); virtual void sfxPlay(const char *base) = 0; - static Sound *giveSound(SoundMixer *mixer, Input *input, Resource *resource, uint8 compression); + static Sound *giveSound(SoundMixer *mixer, QueenEngine *vm, uint8 compression); void waitSfxFinished(); void playSong(int16 songNum); @@ -70,8 +72,7 @@ public: protected: SoundMixer *_mixer; - Input *_input; - Resource *_resource; + QueenEngine *_vm; static const songData _song[]; static const tuneData _tune[]; @@ -92,13 +93,13 @@ protected: class SilentSound : public Sound { public: - SilentSound(SoundMixer *mixer, Input *input, Resource *resource) : Sound(mixer, input, resource) {}; + SilentSound(SoundMixer *mixer, QueenEngine *vm) : Sound(mixer, vm) {}; void sfxPlay(const char *base) { } }; class SBSound : public Sound { public: - SBSound(SoundMixer *mixer, Input *input, Resource *resource) : Sound(mixer, input, resource) {}; + SBSound(SoundMixer *mixer, QueenEngine *vm) : Sound(mixer, vm) {}; void sfxPlay(const char *base); protected: int playSound(byte *sound, uint32 size); @@ -107,7 +108,7 @@ protected: #ifdef USE_MAD class MP3Sound : public Sound { public: - MP3Sound(SoundMixer *mixer, Input *input, Resource *resource) : Sound(mixer, input, resource) {}; + MP3Sound(SoundMixer *mixer, QueenEngine *vm) : Sound(mixer, vm) {}; void sfxPlay(const char *base); }; #endif @@ -115,7 +116,7 @@ public: #ifdef USE_VORBIS class OGGSound : public Sound { public: - OGGSound(SoundMixer *mixer, Input *input, Resource *resource) : Sound(mixer, input, resource) {}; + OGGSound(SoundMixer *mixer, QueenEngine *vm) : Sound(mixer, vm) {}; void sfxPlay(const char *base); }; #endif diff --git a/queen/talk.cpp b/queen/talk.cpp index 368be4491c..78cb514adc 100644 --- a/queen/talk.cpp +++ b/queen/talk.cpp @@ -21,10 +21,12 @@ #include "stdafx.h" #include "queen/talk.h" + #include "queen/display.h" #include "queen/graphics.h" #include "queen/input.h" #include "queen/logic.h" +#include "queen/queen.h" #include "queen/resource.h" #include "queen/sound.h" #include "queen/state.h" @@ -42,12 +44,8 @@ void Talk::talk( const char *filename, int personInRoom, char *cutawayFilename, - Graphics *graphics, - Input *input, - Logic *logic, - Resource *resource, - Sound *sound) { - Talk *talk = new Talk(graphics, input, logic, resource, sound); + QueenEngine *vm) { + Talk *talk = new Talk(vm); talk->talk(filename, personInRoom, cutawayFilename); delete talk; } @@ -56,12 +54,8 @@ bool Talk::speak( const char *sentence, Person *person, const char *voiceFilePrefix, - Graphics *graphics, - Input *input, - Logic *logic, - Resource *resource, - Sound *sound) { - Talk *talk = new Talk(graphics, input, logic, resource, sound); + QueenEngine *vm) { + Talk *talk = new Talk(vm); bool result; if (sentence) result = talk->speak(sentence, person, voiceFilePrefix); @@ -71,16 +65,9 @@ bool Talk::speak( return result; } -Talk::Talk( - Graphics *graphics, - Input *input, - Logic *logic, - Resource *resource, - Sound *sound) : - _graphics(graphics), _input(input), _logic(logic), _resource(resource), - _sound(sound), _fileData(NULL) { - - _input->talkQuitReset(); +Talk::Talk(QueenEngine *vm) + : _vm(vm), _fileData(NULL) { + _vm->input()->talkQuitReset(); } Talk::~Talk() { @@ -98,8 +85,8 @@ void Talk::talk(const char *filename, int personInRoom, char *cutawayFilename) { // XXX S=SUBJECT[1]; - int roomStart = _logic->roomData(_logic->currentRoom()); - ObjectData *data = _logic->objectData(roomStart + personInRoom); + int roomStart = _vm->logic()->currentRoomData(); + ObjectData *data = _vm->logic()->objectData(roomStart + personInRoom); if (data->name <= 0) // disabled! return; @@ -109,7 +96,7 @@ void Talk::talk(const char *filename, int personInRoom, char *cutawayFilename) { if (State::findTalk(data->state) == STATE_TALK_MUTE) { // 'I can't talk to that' - _logic->joeSpeak(24 + Logic::randomizer.getRandomNumber(2)); + _vm->logic()->joeSpeak(24 + _vm->randomizer.getRandomNumber(2)); return; } @@ -117,7 +104,7 @@ void Talk::talk(const char *filename, int personInRoom, char *cutawayFilename) { Person person; memset(&person, 0, sizeof(Person)); - _logic->personSetData(personInRoom, "", false, &person); + _vm->logic()->personSetData(personInRoom, "", false, &person); if (NULL == person.name) { error("Invalid person object"); @@ -147,7 +134,7 @@ void Talk::talk(const char *filename, int personInRoom, char *cutawayFilename) { initialTalk(); // Lines 906-? in talk.c - _logic->display()->showMouseCursor(true); + _vm->display()->showMouseCursor(true); int16 level=1, retval=0; int16 head = _dialogueTree[level][0].head; @@ -182,7 +169,7 @@ void Talk::talk(const char *filename, int personInRoom, char *cutawayFilename) { int16 index = _dialogueTree[level][i].gameStateIndex; - if (index < 0 && _logic->gameState(ABS(index)) != _dialogueTree[level][i].gameStateValue) + if (index < 0 && _vm->logic()->gameState(ABS(index)) != _dialogueTree[level][i].gameStateValue) _talkString[i][0] = '\0'; sprintf(_joeVoiceFilePrefix[i], "%2d%4xJ", _talkKey, _dialogueTree[level][i].head); @@ -209,7 +196,7 @@ void Talk::talk(const char *filename, int personInRoom, char *cutawayFilename) { if (speak(_talkString[0], &person, otherVoiceFilePrefix)) personWalking = true; - if (_input->talkQuit()) + if (_vm->input()->talkQuit()) break; speak(_talkString[selectedSentence], NULL, _joeVoiceFilePrefix[selectedSentence]); @@ -225,7 +212,7 @@ void Talk::talk(const char *filename, int personInRoom, char *cutawayFilename) { } } - if (_input->talkQuit()) + if (_vm->input()->talkQuit()) break; retval = _dialogueTree[level][selectedSentence].dialogueNodeValue1; @@ -274,14 +261,14 @@ void Talk::talk(const char *filename, int personInRoom, char *cutawayFilename) { int16 index = _dialogueTree[level][0].gameStateIndex; if (index > 0) - _logic->gameState(index, _dialogueTree[level][0].gameStateValue); + _vm->logic()->gameState(index, _dialogueTree[level][0].gameStateValue); // if the selected dialogue line has a POSITIVE game state value // then set gamestate to Value = TALK(OLDLEVEL,S,3) index = _dialogueTree[oldLevel][selectedSentence].gameStateIndex; if (index > 0) - _logic->gameState(index, _dialogueTree[oldLevel][selectedSentence].gameStateValue); + _vm->logic()->gameState(index, _dialogueTree[oldLevel][selectedSentence].gameStateValue); // if(RETVAL = -1, then before we exit, check to see if(person @@ -303,55 +290,55 @@ void Talk::talk(const char *filename, int personInRoom, char *cutawayFilename) { for (i = 0; i < 2; i++) { if (_gameState[i] > 0) { - if (_logic->gameState(_gameState[i]) == _testValue[i]) { + if (_vm->logic()->gameState(_gameState[i]) == _testValue[i]) { if (_itemNumber[i] > 0) - _logic->inventoryInsertItem(_itemNumber[i]); + _vm->logic()->inventoryInsertItem(_itemNumber[i]); else - _logic->inventoryDeleteItem(ABS(_itemNumber[i])); + _vm->logic()->inventoryDeleteItem(ABS(_itemNumber[i])); } } } - _logic->zoneSetupPanel(); + _vm->logic()->zoneSetupPanel(); uint8 *ptr = _cutawayPtr; int16 cutawayGameState = (int16)READ_BE_UINT16(ptr); ptr += 2; int16 cutawayTestValue = (int16)READ_BE_UINT16(ptr); ptr += 2; - if (_logic->gameState(cutawayGameState) == cutawayTestValue) { + if (_vm->logic()->gameState(cutawayGameState) == cutawayTestValue) { getString(ptr, cutawayFilename, 20); //CR 2 - 7/3/95, If we're executing a cutaway scene, then make sure // Joe can talk, so set TALKQUIT to 0 just in case we exit on the // line that set's the cutaway game states. - _input->talkQuitReset(); + _vm->input()->talkQuitReset(); } - if (_input->talkQuit()) { + if (_vm->input()->talkQuit()) { if (_oldSelectedSentenceIndex > 0) selectedValue(_oldSelectedSentenceIndex, _oldSelectedSentenceValue); - _input->talkQuitReset(); - _graphics->textClear(0, 198); + _vm->input()->talkQuitReset(); + _vm->graphics()->textClear(0, 198); speak(_talkString[15], NULL, "JOE0015"); } else { setHasTalkedTo(); } - _logic->joeFace(); + _vm->logic()->joeFace(); if (cutawayFilename[0] == '\0') { - BobSlot *pbs = _graphics->bob(person.actor->bobNum); + BobSlot *pbs = _vm->graphics()->bob(person.actor->bobNum); pbs->x = person.actor->x; pbs->y = person.actor->y; // Better kick start the persons anim sequence - _logic->animReset(person.actor->bobNum); + _vm->logic()->animReset(person.actor->bobNum); } - _logic->joeWalk(JWM_NORMAL); + _vm->logic()->joeWalk(JWM_NORMAL); } void Talk::disableSentence(int oldLevel, int selectedSentence) { @@ -394,7 +381,7 @@ void Talk::findDialogueString(byte *ptr, int16 id, int16 max, char *str) { void Talk::load(const char *filename) { int i; - byte *ptr = _fileData = _resource->loadFile(filename, 20); + byte *ptr = _fileData = _vm->resource()->loadFile(filename, 20); if (!_fileData) { error("Failed to load resource data file '%s'", filename); } @@ -540,10 +527,10 @@ int Talk::getSpeakCommand(const char *sentence, unsigned &index) { case 'G': switch (sentence[index + 1]) { case 'D': - _logic->joeGrab(STATE_GRAB_DOWN); + _vm->logic()->joeGrab(STATE_GRAB_DOWN); break; case 'M': - _logic->joeGrab(STATE_GRAB_MID); + _vm->logic()->joeGrab(STATE_GRAB_MID); break; default: warning("Unknown command string: '%2s'", sentence + index); @@ -599,7 +586,7 @@ bool Talk::speak(const char *sentence, Person *person, const char *voiceFilePref Person joe_person; ActorData joe_actor; - _logic->joeWalk(JWM_SPEAK); + _vm->logic()->joeWalk(JWM_SPEAK); if (!person) { // Fill in values for use by speakSegment() etc. @@ -627,9 +614,9 @@ bool Talk::speak(const char *sentence, Person *person, const char *voiceFilePref 0 == strcmp(person->name, "FRANK-H") || 0 == strcmp(person->name, "AZURA-H") || 0 == strcmp(person->name, "X3_RITA") || - (0 == strcmp(person->name, "JOE") && _logic->currentRoom() == FAYE_HEAD ) || - (0 == strcmp(person->name, "JOE") && _logic->currentRoom() == AZURA_HEAD) || - (0 == strcmp(person->name, "JOE") && _logic->currentRoom() == FRANK_HEAD)) + (0 == strcmp(person->name, "JOE") && _vm->logic()->currentRoom() == FAYE_HEAD ) || + (0 == strcmp(person->name, "JOE") && _vm->logic()->currentRoom() == AZURA_HEAD) || + (0 == strcmp(person->name, "JOE") && _vm->logic()->currentRoom() == FRANK_HEAD)) _talkHead = true; else _talkHead = false; @@ -660,7 +647,7 @@ bool Talk::speak(const char *sentence, Person *person, const char *voiceFilePref else i++; - if (_input->cutawayQuit() || _input->talkQuit()) + if (_vm->input()->cutawayQuit() || _vm->input()->talkQuit()) goto exit; } @@ -688,17 +675,17 @@ int Talk::countSpaces(const char *segment) { if (tmp < 10) tmp = 10; - return (tmp * 2) / (_logic->talkSpeed() / 3); + return (tmp * 2) / (_vm->logic()->talkSpeed() / 3); } void Talk::headStringAnimation(const SpeechParameters *parameters, int bobNum, int bankNum) { // talk.c lines 1612-1635 - BobSlot *bob2 = _graphics->bob(2); + BobSlot *bob2 = _vm->graphics()->bob(2); if (parameters->animation[0] == 'E') { int offset = 1; - BobSlot *bob = _graphics->bob(bobNum); + BobSlot *bob = _vm->graphics()->bob(bobNum); int16 x = bob->x; int16 y = bob->y; @@ -712,15 +699,15 @@ void Talk::headStringAnimation(const SpeechParameters *parameters, int bobNum, i offset += 4; - _graphics->bankUnpack(frame, _logic->numFrames(), bankNum); + _vm->graphics()->bankUnpack(frame, _vm->logic()->numFrames(), bankNum); - bob2->frameNum = _logic->numFrames(); + bob2->frameNum = _vm->logic()->numFrames(); bob2->scale = 100; bob2->active = true; bob2->x = x; bob2->y = y; - _logic->update(); + _vm->logic()->update(); } } else @@ -736,7 +723,7 @@ void Talk::stringAnimation(const SpeechParameters *parameters, int startFrame, i if (parameters->animation[0] == 'T') { // Torso animation torso = true; - _graphics->bankOverpack(parameters->body, startFrame, bankNum); + _vm->graphics()->bankOverpack(parameters->body, startFrame, bankNum); offset++; } else if (parameters->animation[0] == 'E') { @@ -768,14 +755,14 @@ void Talk::stringAnimation(const SpeechParameters *parameters, int startFrame, i } if (torso) { - _graphics->bankOverpack(frame, startFrame, bankNum); + _vm->graphics()->bankOverpack(frame, startFrame, bankNum); } else { - _graphics->bankUnpack(frame, startFrame, bankNum); + _vm->graphics()->bankUnpack(frame, startFrame, bankNum); // XXX bobs[BNUM].scale=SF; } - _logic->update(); + _vm->logic()->update(); } // XXX #ifdef __DOS__ @@ -841,7 +828,7 @@ void Talk::defaultAnimation( int head; if (parameters->rf > 0) - head = bf + Logic::randomizer.getRandomNumber(parameters->rf); + head = bf + _vm->randomizer.getRandomNumber(parameters->rf); else head = bf; @@ -849,43 +836,43 @@ void Talk::defaultAnimation( // Make the head move qzx ^= 1; if (parameters->af && qzx) - _graphics->bankOverpack(parameters->af + head, startFrame, bankNum); + _vm->graphics()->bankOverpack(parameters->af + head, startFrame, bankNum); else { - _graphics->bankOverpack(head, startFrame, bankNum); + _vm->graphics()->bankOverpack(head, startFrame, bankNum); } } else { debug(0, "[Talk::defaultAnimation] Body action!"); // Just do a body action - _graphics->bankOverpack(parameters->body, startFrame, bankNum); + _vm->graphics()->bankOverpack(parameters->body, startFrame, bankNum); } if (!_talkHead) - _logic->update(); + _vm->logic()->update(); } else { // (_talkHead && isJoe) - _logic->update(); + _vm->logic()->update(); } - if (_logic->joeWalk() == JWM_SPEAK) { - if (_input->talkQuit()) + if (_vm->logic()->joeWalk() == JWM_SPEAK) { + if (_vm->input()->talkQuit()) break; - _logic->update(); + _vm->logic()->update(); } else { - if (_input->talkQuit()) + if (_vm->input()->talkQuit()) break; - _logic->checkPlayer(); - if (_logic->joeWalk() == JWM_EXECUTE) + _vm->logic()->checkPlayer(); + if (_vm->logic()->joeWalk() == JWM_EXECUTE) // Selected a command, so exit break; } // Skip through text more quickly - if (_input->keyVerb().isSkipText()) { - _input->clearKeyVerb(); + if (_vm->input()->keyVerb().isSkipText()) { + _vm->input()->clearKeyVerb(); break; } } @@ -893,7 +880,7 @@ void Talk::defaultAnimation( // Make sure that Person closes their mouths if (!isJoe && parameters->ff > 0) - _graphics->bankOverpack(parameters->ff, startFrame, bankNum); + _vm->graphics()->bankOverpack(parameters->ff, startFrame, bankNum); } @@ -918,7 +905,7 @@ void Talk::speakSegment( // debug(0, "Sentence segment '%*s' is said by person '%s' and voice file '%s' is played", // length, segment, person->name, voiceFileName); - _sound->sfxPlay(voiceFileName); + _vm->sound()->sfxPlay(voiceFileName); //debug(0, "Playing voice file '%s'", voiceFileName); int faceDirectionCommand = 0; @@ -926,9 +913,9 @@ void Talk::speakSegment( switch (command) { case SPEAK_PAUSE: for (i = 0; i < 10; i++) { - if (_input->talkQuit()) + if (_vm->input()->talkQuit()) break; - _logic->update(); + _vm->logic()->update(); } return; @@ -947,7 +934,7 @@ void Talk::speakSegment( uint16 color = person->actor->color; uint16 bankNum = person->actor->bankNum; - BobSlot *bob = _graphics->bob(bobNum); + BobSlot *bob = _vm->graphics()->bob(bobNum); bool oracle = false; int textX = 0; @@ -959,9 +946,9 @@ void Talk::speakSegment( // Dont turn AMAL animation off, and dont manually anim person command = SPEAK_ORACLE; oracle = true; - uint16 frameNum = _logic->personFrames(bobNum); + uint16 frameNum = _vm->logic()->personFrames(bobNum); for (i = 5; i <= 8; ++i) { - _graphics->bankUnpack(i, frameNum, bankNum); + _vm->graphics()->bankUnpack(i, frameNum, bankNum); ++frameNum; } } @@ -980,13 +967,13 @@ void Talk::speakSegment( textY = bob->y; } - //int SF = _logic->findScale(textX, textY); + //int SF = _vm->logic()->findScale(textX, textY); const SpeechParameters *parameters = NULL; int startFrame = 0; if (_talkHead && isJoe) { - _graphics->bobSetText(bob, segment, textX, textY, color, true); + _vm->graphics()->bobSetText(bob, segment, textX, textY, color, true); defaultAnimation(segment, isJoe, parameters, startFrame, bankNum); } else { @@ -994,10 +981,10 @@ void Talk::speakSegment( return; if (isJoe) { - if (_logic->currentRoom() == 108) + if (_vm->logic()->currentRoom() == 108) parameters = findSpeechParameters("JOE-E", command, 0); else - parameters = findSpeechParameters("JOE", command, _logic->joeFacing()); + parameters = findSpeechParameters("JOE", command, _vm->logic()->joeFacing()); } else parameters = findSpeechParameters(person->name, command, 0); @@ -1005,10 +992,10 @@ void Talk::speakSegment( startFrame = 29 + bobNum + FRAMES_JOE_XTRA; int faceDirection = 0; - if (isJoe && _logic->joeFacing() == DIR_LEFT) + if (isJoe && _vm->logic()->joeFacing() == DIR_LEFT) faceDirection = DIR_LEFT; else if (!isJoe) { - ObjectData *data = _logic->objectData(_logic->objectForPerson(bobNum)); + ObjectData *data = _vm->logic()->objectData(_vm->logic()->objectForPerson(bobNum)); if (data->image == -3) faceDirection = DIR_LEFT; @@ -1027,7 +1014,7 @@ void Talk::speakSegment( case SPEAK_FACE_BACK: faceDirection = DIR_BACK; break; } if (isJoe) - _logic->joeFacing(faceDirection); + _vm->logic()->joeFacing(faceDirection); } if (!isJoe) { @@ -1041,17 +1028,17 @@ void Talk::speakSegment( headStringAnimation(parameters, bobNum, bankNum); } - _graphics->bobSetText(bob, segment, textX, textY, color, _talkHead); + _vm->graphics()->bobSetText(bob, segment, textX, textY, color, _talkHead); if (parameters->animation[0] != '\0' && parameters->animation[0] != 'E') { stringAnimation(parameters, startFrame, bankNum); } else { - _graphics->bankUnpack(parameters->body, startFrame, bankNum); + _vm->graphics()->bankUnpack(parameters->body, startFrame, bankNum); if (length == 0 && !isJoe && parameters->bf > 0) { - _graphics->bankOverpack(parameters->bf, startFrame, bankNum); - _logic->update(); + _vm->graphics()->bankOverpack(parameters->bf, startFrame, bankNum); + _vm->logic()->update(); } /* A12 = the frame pointer for the full body frame, well use this */ @@ -1062,18 +1049,18 @@ void Talk::speakSegment( if (-1 == parameters->rf) { // Setup the Torso frames - _graphics->bankOverpack(parameters->bf, startFrame, bankNum); + _vm->graphics()->bankOverpack(parameters->bf, startFrame, bankNum); if (isJoe) - parameters = findSpeechParameters(person->name, 0, _logic->joeFacing()); + parameters = findSpeechParameters(person->name, 0, _vm->logic()->joeFacing()); else parameters = findSpeechParameters(person->name, 0, 0); } if (-2 == parameters->rf) { // Setup the Torso frames - _graphics->bankOverpack(parameters->bf, startFrame, bankNum); + _vm->graphics()->bankOverpack(parameters->bf, startFrame, bankNum); if (isJoe) - parameters = findSpeechParameters(person->name, 14, _logic->joeFacing()); + parameters = findSpeechParameters(person->name, 14, _vm->logic()->joeFacing()); else parameters = findSpeechParameters(person->name, 14, 0); } @@ -1083,12 +1070,12 @@ void Talk::speakSegment( } // Moved here so that Text is cleared when a Torso command done! - _graphics->textClear(0,198); + _vm->graphics()->textClear(0,198); if (oracle) { - uint16 frameNum = _logic->personFrames(bobNum); + uint16 frameNum = _vm->logic()->personFrames(bobNum); for (i = 1; i <= 4; ++i) { - _graphics->bankUnpack(i, frameNum, bankNum); + _vm->graphics()->bankUnpack(i, frameNum, bankNum); ++frameNum; } } @@ -1096,35 +1083,35 @@ void Talk::speakSegment( // Ensure that the correct buffer frame is selected if (isJoe && !_talkHead) { - if (_logic->joeFacing() == DIR_FRONT || - _logic->joeFacing() == DIR_BACK) { + if (_vm->logic()->joeFacing() == DIR_FRONT || + _vm->logic()->joeFacing() == DIR_BACK) { // Joe is facing either Front or Back! // - Don't FACE_JOE in room 69, because Joe is probably // holding the Dino Ray gun. - if (_logic->currentRoom() != 69) - _logic->joeFace(); + if (_vm->logic()->currentRoom() != 69) + _vm->logic()->joeFace(); } else { if (command == SPEAK_DEFAULT || command == 6 || command == 7) { - _logic->joeFace(); + _vm->logic()->joeFace(); } else if (command != 5) { // 7/11/94, Ensure that correct mouth closed frame is used! if (parameters->rf != -1) // XXX should really be just "bf", but it is not always calculated... :-( - _graphics->bankOverpack(parameters->bf, startFrame, bankNum); + _vm->graphics()->bankOverpack(parameters->bf, startFrame, bankNum); if (parameters->ff == 0) - _graphics->bankOverpack(10, startFrame, bankNum); + _vm->graphics()->bankOverpack(10, startFrame, bankNum); else - _graphics->bankOverpack(parameters->ff, startFrame, bankNum); + _vm->graphics()->bankOverpack(parameters->ff, startFrame, bankNum); } } } - _logic->update(); + _vm->logic()->update(); } const Talk::SpeechParameters *Talk::findSpeechParameters( @@ -1171,7 +1158,7 @@ byte *Talk::getString(byte *ptr, char *str, int maxLength, int align) { } TalkSelected *Talk::talkSelected() { - return _logic->talkSelected(_uniqueKey); + return _vm->logic()->talkSelected(_uniqueKey); } int Talk::splitOption(const char *str, char optionText[5][MAX_STRING_SIZE]) { @@ -1180,7 +1167,7 @@ int Talk::splitOption(const char *str, char optionText[5][MAX_STRING_SIZE]) { // Check to see if option fits on one line, and exit early - /* XXX if (_logic->language() == ENGLISH || textWidth(str) <= MAX_TEXT_WIDTH)*/ { + /* XXX if (_vm->logic()->language() == ENGLISH || textWidth(str) <= MAX_TEXT_WIDTH)*/ { strcpy(optionText[0], str); return 1; } @@ -1217,12 +1204,12 @@ int16 Talk::selectSentence() { // Change NORMAL_INK -> TALK_NORMAL_INK - _graphics->textCurrentColor(INK_TALK_NORMAL); + _vm->graphics()->textCurrentColor(INK_TALK_NORMAL); // These bobs are up and down arrows - BobSlot *arrowBobUp = _graphics->bob(ARROW_BOB_UP); - BobSlot *arrowBobDown = _graphics->bob(ARROW_BOB_DOWN); + BobSlot *arrowBobUp = _vm->graphics()->bob(ARROW_BOB_UP); + BobSlot *arrowBobDown = _vm->graphics()->bob(ARROW_BOB_DOWN); arrowBobUp->x = 303 + 8 + scrollX; arrowBobUp->y = 150 + 1; @@ -1243,14 +1230,14 @@ int16 Talk::selectSentence() { // Set zones for UP/DOWN text arrows when not English version - _logic->zoneClearAll(ZONE_PANEL); + _vm->logic()->zoneClearAll(ZONE_PANEL); - if (_logic->resource()->getLanguage() != ENGLISH) { - _logic->zoneSet(ZONE_PANEL, ARROW_ZONE_UP, MAX_TEXT_WIDTH + 1, 0, 319, 24); - _logic->zoneSet(ZONE_PANEL, ARROW_ZONE_DOWN, MAX_TEXT_WIDTH + 1, 25, 319, 49); + if (_vm->resource()->getLanguage() != ENGLISH) { + _vm->logic()->zoneSet(ZONE_PANEL, ARROW_ZONE_UP, MAX_TEXT_WIDTH + 1, 0, 319, 24); + _vm->logic()->zoneSet(ZONE_PANEL, ARROW_ZONE_DOWN, MAX_TEXT_WIDTH + 1, 25, 319, 49); } - _graphics->textClear(151,199); + _vm->graphics()->textClear(151,199); int sentenceCount = 0; int yOffset = 1; @@ -1266,12 +1253,12 @@ int16 Talk::selectSentence() { optionLines = splitOption(removeStar(temp), optionText); if (yOffset < 5) { - _logic->zoneSet( + _vm->logic()->zoneSet( ZONE_PANEL, i, 0, yOffset * LINE_HEIGHT - PUSHUP, - (_logic->resource()->getLanguage() == ENGLISH) ? 319 : MAX_TEXT_WIDTH, + (_vm->resource()->getLanguage() == ENGLISH) ? 319 : MAX_TEXT_WIDTH, (yOffset + optionLines) * LINE_HEIGHT - PUSHUP); } @@ -1279,7 +1266,7 @@ int16 Talk::selectSentence() { for (j = 0; j < optionLines; j++) { if (yOffset < 5) { //debug(0, "Draw text '%s'", optionText[j]); - _graphics->textSet( + _vm->graphics()->textSet( (j == 0) ? 0 : 24, 150 - PUSHUP + yOffset * LINE_HEIGHT, optionText[j]); @@ -1295,12 +1282,12 @@ int16 Talk::selectSentence() { // Up and down dialogue arrows - if (_logic->resource()->getLanguage() != ENGLISH) { + if (_vm->resource()->getLanguage() != ENGLISH) { arrowBobUp->active = (startOption > 1); arrowBobDown->active = (yOffset > 4); } - _input->clearKeyVerb(); + _vm->input()->clearKeyVerb(); if (sentenceCount > 0) { int zone = 0; @@ -1308,12 +1295,12 @@ int16 Talk::selectSentence() { while (0 == selectedSentence) { - if (_input->talkQuit()) + if (_vm->input()->talkQuit()) break; - _logic->update(); + _vm->logic()->update(); - zone = _logic->zoneIn(ZONE_PANEL, _input->mousePosX(), _input->mousePosY()); + zone = _vm->logic()->zoneIn(ZONE_PANEL, _vm->input()->mousePosX(), _vm->input()->mousePosY()); if (5 == zone || 6 == zone) { // XXX Arrow zones @@ -1328,13 +1315,13 @@ int16 Talk::selectSentence() { oldZone, zone);*/ if (zone > 0) { - for (y = _logic->zoneBox(ZONE_PANEL, zone).y1; y < _logic->zoneBox(ZONE_PANEL, zone).y2; y += 10) - _graphics->textColor(150 + y, INK_JOE); + for (y = _vm->logic()->zoneBox(ZONE_PANEL, zone).y1; y < _vm->logic()->zoneBox(ZONE_PANEL, zone).y2; y += 10) + _vm->graphics()->textColor(150 + y, INK_JOE); } if (oldZone > 0) { - for (y = _logic->zoneBox(ZONE_PANEL, oldZone).y1; y < _logic->zoneBox(ZONE_PANEL, oldZone).y2; y += 10) - _graphics->textColor(150 + y, INK_TALK_NORMAL); + for (y = _vm->logic()->zoneBox(ZONE_PANEL, oldZone).y1; y < _vm->logic()->zoneBox(ZONE_PANEL, oldZone).y2; y += 10) + _vm->graphics()->textColor(150 + y, INK_TALK_NORMAL); } oldZone = zone; @@ -1342,20 +1329,20 @@ int16 Talk::selectSentence() { } - int mouseButton = _input->mouseButton(); - _input->clearMouseButton(); + int mouseButton = _vm->input()->mouseButton(); + _vm->input()->clearMouseButton(); - if (_input->keyVerb().isDigit()) { + if (_vm->input()->keyVerb().isDigit()) { for (i = 1; i <= 4; i++) { - if (talkZone[i] == _input->keyVerb().digit()) + if (talkZone[i] == _vm->input()->keyVerb().digit()) { selectedSentence = i; break; } } - _input->clearKeyVerb(); + _vm->input()->clearKeyVerb(); } else if (mouseButton) { selectedSentence = zone; @@ -1385,12 +1372,12 @@ int16 Talk::selectSentence() { arrowBobDown->active = false; if (selectedSentence > 0) { - _graphics->textClear(0,198); + _vm->graphics()->textClear(0,198); speak(_talkString[selectedSentence], NULL, _joeVoiceFilePrefix[selectedSentence]); } - _graphics->textClear(151,151); + _vm->graphics()->textClear(151,151); return selectedSentence; } diff --git a/queen/talk.h b/queen/talk.h index 3c0887150a..6e3fc4c600 100644 --- a/queen/talk.h +++ b/queen/talk.h @@ -27,12 +27,7 @@ namespace Queen { -class Graphics; -class Input; -class Logic; -class Resource; -class Sound; -struct BobSlot; +class QueenEngine; class Talk { public: @@ -42,22 +37,14 @@ class Talk { const char *filename, int personInRoom, char *cutawayFilename, - Graphics *graphics, - Input *input, - Logic *logic, - Resource *resource, - Sound *sound); + QueenEngine *vm); //! Public interface to speak a sentence static bool speak( const char *sentence, Person *person, const char *voiceFilePrefix, - Graphics *graphics, - Input *input, - Logic *logic, - Resource *resource, - Sound *sound); + QueenEngine *vm); //! Read a string from ptr and return new ptr static byte *getString(byte *ptr, char *str, int maxLength, int align = 2); @@ -105,11 +92,7 @@ private: signed char ff; }; - Graphics *_graphics; - Input *_input; - Logic *_logic; - Resource *_resource; - Sound *_sound; + QueenEngine *_vm; bool _wasFullscren; @@ -164,7 +147,7 @@ private: static const SpeechParameters _speechParameters[]; - Talk(Graphics *graphics, Input *input, Logic *logic, Resource *resource, Sound *sound); + Talk(QueenEngine *vm); ~Talk(); //! Perform talk in file and return a cutaway filename diff --git a/queen/walk.cpp b/queen/walk.cpp index d5df70a5f1..4b16083cf9 100644 --- a/queen/walk.cpp +++ b/queen/walk.cpp @@ -21,9 +21,11 @@ #include "stdafx.h" #include "queen/walk.h" + +#include "queen/defs.h" #include "queen/logic.h" #include "queen/graphics.h" -#include "queen/defs.h" +#include "queen/queen.h" namespace Queen { @@ -54,8 +56,8 @@ const MovePersonData Walk::_moveData[] = { -Walk::Walk(Logic *logic, Graphics *graphics) - : _logic(logic), _graphics(graphics) { +Walk::Walk(QueenEngine *vm) + : _vm(vm) { } @@ -105,10 +107,10 @@ void Walk::animateJoe() { // queen.c l.2789-2835 uint16 lastDirection = 0; uint16 i; - BobSlot *pbs = _graphics->bob(0); - _logic->joeFacing(_walkData[1].anim.facing); - _logic->joeScale(_walkData[1].area->calcScale(pbs->y)); - _logic->joeFace(); + BobSlot *pbs = _vm->graphics()->bob(0); + _vm->logic()->joeFacing(_walkData[1].anim.facing); + _vm->logic()->joeScale(_walkData[1].area->calcScale(pbs->y)); + _vm->logic()->joeFace(); for (i = 1; i <= _walkDataCount && !_joeInterrupted; ++i) { WalkData *pwd = &_walkData[i]; @@ -116,7 +118,7 @@ void Walk::animateJoe() { // area has been turned off, see if we should execute a cutaway if (pwd->area->mapNeighbours < 0) { // queen.c l.2838-2911 - _logic->customMoveJoe(pwd->anim.facing, pwd->areaNum, i); + _vm->logic()->customMoveJoe(pwd->anim.facing, pwd->areaNum, i); _joeMoveBlock = true; return; } @@ -124,13 +126,13 @@ void Walk::animateJoe() { pbs->animNormal(pwd->anim.firstFrame, pwd->anim.lastFrame, 1, false, false); } - uint16 moveSpeed = _logic->findScale(pbs->x, pbs->y) * 6 / 100; + uint16 moveSpeed = _vm->logic()->findScale(pbs->x, pbs->y) * 6 / 100; pbs->move(pbs->x + pwd->dx, pbs->y + pwd->dy, moveSpeed); pbs->xflip = (pbs->xdir < 0); while (pbs->moving) { // adjust Joe's movespeed according to scale pbs->scale = pwd->area->calcScale(pbs->y); - _logic->joeScale(pbs->scale); + _vm->logic()->joeScale(pbs->scale); if (pbs->xmajor) { pbs->speed = pbs->scale * 6 / 100; } @@ -140,10 +142,10 @@ void Walk::animateJoe() { if (pbs->speed == 0) { pbs->speed = 1; } - _logic->checkPlayer(); + _vm->logic()->checkPlayer(); // FIXME it would nice to be able to get rid of these 3 lines // as stopJoe() should be do the same... - if (_logic->joeWalk() == JWM_EXECUTE) { // XXX || cutQuit + if (_vm->logic()->joeWalk() == JWM_EXECUTE) { // XXX || cutQuit // we are about to do something else, so stop walking _joeInterrupted = true; pbs->moving = false; @@ -151,7 +153,7 @@ void Walk::animateJoe() { } lastDirection = pwd->anim.facing; } - _logic->joeFacing(lastDirection); + _vm->logic()->joeFacing(lastDirection); } @@ -235,7 +237,7 @@ void Walk::animatePersonPrepare(const MovePersonData *mpd, int direction) { void Walk::animatePerson(const MovePersonData *mpd, uint16 image, uint16 bobNum, uint16 bankNum, int direction) { // queen.c l.2572-2651 - BobSlot *pbs = _graphics->bob(bobNum); + BobSlot *pbs = _vm->graphics()->bob(bobNum); // check to see which way person should be facing if (mpd->walkLeft1 == mpd->walkRight1) { @@ -254,7 +256,7 @@ void Walk::animatePerson(const MovePersonData *mpd, uint16 image, uint16 bobNum, uint16 dstFrame = image; uint16 srcFrame = ABS(pwd->anim.firstFrame); while (srcFrame <= ABS(pwd->anim.lastFrame)) { - _graphics->bankUnpack(srcFrame, dstFrame, bankNum); + _vm->graphics()->bankUnpack(srcFrame, dstFrame, bankNum); ++dstFrame; ++srcFrame; } @@ -267,7 +269,7 @@ void Walk::animatePerson(const MovePersonData *mpd, uint16 image, uint16 bobNum, } // move other actors at correct speed relative to scale - uint16 moveSpeed = _logic->findScale(pbs->x, pbs->y) * mpd->moveSpeed / 100; + uint16 moveSpeed = _vm->logic()->findScale(pbs->x, pbs->y) * mpd->moveSpeed / 100; pbs->move(pbs->x + pwd->dx, pbs->y + pwd->dy, moveSpeed); // flip if one set of frames for actor @@ -276,7 +278,7 @@ void Walk::animatePerson(const MovePersonData *mpd, uint16 image, uint16 bobNum, } while (pbs->moving) { - _logic->update(); + _vm->logic()->update(); uint16 scale = pwd->area->calcScale(pbs->y); pbs->scale = scale; if (pbs->xmajor) { @@ -302,13 +304,13 @@ int16 Walk::moveJoe(int direction, int16 endx, int16 endy, bool inCutaway) { _joeInterrupted = false; - uint16 oldx = _graphics->bob(0)->x; - uint16 oldy = _graphics->bob(0)->y; + uint16 oldx = _vm->graphics()->bob(0)->x; + uint16 oldy = _vm->graphics()->bob(0)->y; - _logic->joeWalk(JWM_MOVE); + _vm->logic()->joeWalk(JWM_MOVE); - uint16 oldPos = _logic->zoneInArea(ZONE_ROOM, oldx, oldy); - uint16 newPos = _logic->zoneInArea(ZONE_ROOM, endx, endy); + uint16 oldPos = _vm->logic()->zoneInArea(ZONE_ROOM, oldx, oldy); + uint16 newPos = _vm->logic()->zoneInArea(ZONE_ROOM, endx, endy); debug(9, "Walk::moveJoe(%d, %d, %d, %d, %d) - old = %d, new = %d", direction, oldx, oldy, endx, endy, oldPos, newPos); @@ -328,12 +330,12 @@ int16 Walk::moveJoe(int direction, int16 endx, int16 endy, bool inCutaway) { } else { // path has been blocked, make Joe say so - _logic->joeSpeak(4); + _vm->logic()->joeSpeak(4); can = -1; } } - _graphics->bob(0)->animating = false; + _vm->graphics()->bob(0)->animating = false; // cyx: the NEW_ROOM = 0 is done in Command::grabCurrentSelection() // XXX if ((CAN==-1) && (walkgameload==0)) NEW_ROOM=0; // XXX walkgameload=0; @@ -342,10 +344,10 @@ int16 Walk::moveJoe(int direction, int16 endx, int16 endy, bool inCutaway) { _joeMoveBlock = false; } else if (direction > 0) { - _logic->joeFacing(direction); + _vm->logic()->joeFacing(direction); } - _logic->joePrevFacing(_logic->joeFacing()); - _logic->joeFace(); + _vm->logic()->joePrevFacing(_vm->logic()->joeFacing()); + _vm->logic()->joeFace(); return can; } @@ -363,11 +365,11 @@ int16 Walk::movePerson(const Person *pp, int16 endx, int16 endy, uint16 curImage uint16 bobNum = pp->actor->bobNum; uint16 bankNum = pp->actor->bankNum; - uint16 oldx = _graphics->bob(bobNum)->x; - uint16 oldy = _graphics->bob(bobNum)->y; + uint16 oldx = _vm->graphics()->bob(bobNum)->x; + uint16 oldy = _vm->graphics()->bob(bobNum)->y; - uint16 oldPos = _logic->zoneInArea(ZONE_ROOM, oldx, oldy); - uint16 newPos = _logic->zoneInArea(ZONE_ROOM, endx, endy); + uint16 oldPos = _vm->logic()->zoneInArea(ZONE_ROOM, oldx, oldy); + uint16 newPos = _vm->logic()->zoneInArea(ZONE_ROOM, endx, endy); debug(9, "Walk::movePerson(%d, %d, %d, %d, %d) - old = %d, new = %d", direction, oldx, oldy, endx, endy, oldPos, newPos); @@ -393,24 +395,24 @@ int16 Walk::movePerson(const Person *pp, int16 endx, int16 endy, uint16 curImage uint16 standingFrame = 29 + FRAMES_JOE_XTRA + bobNum; // make other person face the right direction - BobSlot *pbs = _graphics->bob(bobNum); + BobSlot *pbs = _vm->graphics()->bob(bobNum); pbs->endx = endx; pbs->endy = endy; pbs->animating = false; pbs->scale = _walkData[_walkDataCount].area->calcScale(endy); if (_walkData[_walkDataCount].anim.facing == DIR_BACK) { - _graphics->bankUnpack(mpd->backStandingFrame, standingFrame, bankNum); + _vm->graphics()->bankUnpack(mpd->backStandingFrame, standingFrame, bankNum); } else { - _graphics->bankUnpack(mpd->frontStandingFrame, standingFrame, bankNum); + _vm->graphics()->bankUnpack(mpd->frontStandingFrame, standingFrame, bankNum); } - uint16 obj = _logic->objectForPerson(bobNum); + uint16 obj = _vm->logic()->objectForPerson(bobNum); if (_walkData[_walkDataCount].dx < 0) { - _logic->objectData(obj)->image = -3; + _vm->logic()->objectData(obj)->image = -3; pbs->xflip = true; } else { - _logic->objectData(obj)->image = -4; + _vm->logic()->objectData(obj)->image = -4; pbs->xflip = false; } pbs->frameNum = standingFrame; @@ -420,7 +422,7 @@ int16 Walk::movePerson(const Person *pp, int16 endx, int16 endy, uint16 curImage void Walk::stopJoe() { - _graphics->bob(0)->moving = false; + _vm->graphics()->bob(0)->moving = false; _joeInterrupted = true; } @@ -449,8 +451,8 @@ bool Walk::calc(uint16 oldPos, uint16 newPos, int16 oldx, int16 oldy, int16 x, i for (i = 2; i <= _areaListCount; ++i) { uint16 a1 = _areaList[i - 1]; uint16 a2 = _areaList[i]; - const Area *pa1 = _logic->currentRoomArea(a1); - const Area *pa2 = _logic->currentRoomArea(a2); + const Area *pa1 = _vm->logic()->currentRoomArea(a1); + const Area *pa2 = _vm->logic()->currentRoomArea(a2); uint16 x1 = calcC(pa1->box.x1, pa1->box.x2, pa2->box.x1, pa2->box.x2, px); uint16 y1 = calcC(pa1->box.y1, pa1->box.y2, pa2->box.y1, pa2->box.y2, py); incWalkData(px, py, x1, y1, a1); @@ -490,10 +492,10 @@ int16 Walk::findAreaPosition(int16 *x, int16 *y, bool recalibrate) { uint16 i; uint16 pos = 1; uint32 minDist = ~0; - const Box *b = &_logic->currentRoomArea(1)->box; - for (i = 1; i <= _logic->currentRoomAreaMax(); ++i) { + const Box *b = &_vm->logic()->currentRoomArea(1)->box; + for (i = 1; i <= _vm->logic()->currentRoomAreaMax(); ++i) { - b = &_logic->currentRoomArea(i)->box; + b = &_vm->logic()->currentRoomArea(i)->box; uint16 dx1 = ABS(b->x1 - *x); uint16 dx2 = ABS(b->x2 - *x); @@ -524,7 +526,7 @@ int16 Walk::findAreaPosition(int16 *x, int16 *y, bool recalibrate) { // we now have the closest area near X,Y, so we can recalibrate // the X,Y coord to be in this area if (recalibrate) { - b = &_logic->currentRoomArea(pos)->box; + b = &_vm->logic()->currentRoomArea(pos)->box; if(*x < b->x1) *x = b->x1; if(*x > b->x2) *x = b->x2; if(*y < b->y1) *y = b->y1; @@ -538,9 +540,9 @@ uint16 Walk::findFreeArea(uint16 area) const { uint16 testArea; uint16 freeArea = 0; - uint16 map = ABS(_logic->currentRoomArea(area)->mapNeighbours); - for (testArea = 1; testArea <= _logic->currentRoomAreaMax(); ++testArea) { - int b = _logic->currentRoomAreaMax() - testArea; + uint16 map = ABS(_vm->logic()->currentRoomArea(area)->mapNeighbours); + for (testArea = 1; testArea <= _vm->logic()->currentRoomAreaMax(); ++testArea) { + int b = _vm->logic()->currentRoomAreaMax() - testArea; if (map & (1 << b)) { // connecting area, check if it's been struck off if(!isAreaStruck(testArea)) { @@ -615,7 +617,7 @@ void Walk::incWalkData(int16 px, int16 py, int16 x, int16 y, uint16 areaNum) { WalkData *pwd = &_walkData[_walkDataCount]; pwd->dx = x - px; pwd->dy = y - py; - pwd->area = _logic->currentRoomArea(areaNum); + pwd->area = _vm->logic()->currentRoomArea(areaNum); pwd->areaNum = areaNum; // pwd->sign = ((pwd->dx < 0) ? -1 : ((pwd->dx > 0) ? 1 : 0)) ; } diff --git a/queen/walk.h b/queen/walk.h index 9c3c45f64e..3dfae9edd0 100644 --- a/queen/walk.h +++ b/queen/walk.h @@ -63,13 +63,12 @@ struct MovePersonData { }; -class Logic; -class Graphics; +class QueenEngine; class Walk { public: - Walk(Logic *logic, Graphics *graphics); + Walk(QueenEngine *vm); int16 moveJoe(int direction, int16 endx, int16 endy, bool inCutaway); int16 movePerson(const Person *pp, int16 endx, int16 endy, uint16 curImage, int direction); @@ -128,9 +127,7 @@ private: //! set if customMoveJoe() is called in joeAnimate() bool _joeMoveBlock; - Logic *_logic; - Graphics *_graphics; - + QueenEngine *_vm; static const MovePersonData _moveData[]; }; -- cgit v1.2.3