diff options
-rw-r--r-- | queen/cutaway.cpp | 29 | ||||
-rw-r--r-- | queen/cutaway.h | 1 | ||||
-rw-r--r-- | queen/defs.h | 3 | ||||
-rw-r--r-- | queen/display.cpp | 41 | ||||
-rw-r--r-- | queen/display.h | 3 | ||||
-rw-r--r-- | queen/graphics.cpp | 11 | ||||
-rw-r--r-- | queen/graphics.h | 8 | ||||
-rw-r--r-- | queen/journal.cpp | 8 | ||||
-rw-r--r-- | queen/logic.cpp | 178 | ||||
-rw-r--r-- | queen/logic.h | 20 | ||||
-rw-r--r-- | queen/queen.cpp | 59 | ||||
-rw-r--r-- | queen/queen.h | 12 | ||||
-rw-r--r-- | queen/talk.cpp | 22 | ||||
-rw-r--r-- | queen/walk.cpp | 6 | ||||
-rw-r--r-- | queen/walk.h | 4 | ||||
-rw-r--r-- | queen/xref.txt | 10 |
16 files changed, 203 insertions, 212 deletions
diff --git a/queen/cutaway.cpp b/queen/cutaway.cpp index 1138a7bed6..939baa2130 100644 --- a/queen/cutaway.cpp +++ b/queen/cutaway.cpp @@ -696,7 +696,7 @@ byte *Cutaway::handleAnimation(byte *ptr, CutawayObject &object) { if (object.animType == 2 || object.animType == 0) { // Unpack animation, but do not unpack moving people - if (!((objAnim[i].mx > 0 || objAnim[i].my > 0) && InRange(objAnim[i].object, 1, 3))) { + if (!((objAnim[i].mx > 0 || objAnim[i].my > 0) && inRange(objAnim[i].object, 1, 3))) { /*debug(6, "Animation - bankUnpack(%i, %i, %i);", objAnim[i].unpackFrame, objAnim[i].originalFrame, @@ -730,7 +730,7 @@ byte *Cutaway::handleAnimation(byte *ptr, CutawayObject &object) { int j; for (j = 0; j < objAnim[i].speed; j++) - _vm->logic()->update(); + _vm->update(); } if (_vm->input()->cutawayQuit()) @@ -753,7 +753,7 @@ byte *Cutaway::handleAnimation(byte *ptr, CutawayObject &object) { while (moving) { moving = false; - _vm->logic()->update(); + _vm->update(); for (i = 0; i < frameCount; i++) { BobSlot *bob = _vm->graphics()->bob(objAnim[i].object); @@ -951,7 +951,7 @@ void Cutaway::run(char *nextFilename) { break; if (_roomFade) { - _vm->logic()->update(); + _vm->update(); int end = 223; if (IS_CD_INTRO_ROOM(_vm->logic()->currentRoom())) { end = 255; @@ -1028,18 +1028,7 @@ void Cutaway::run(char *nextFilename) { } } - // function CUTAWAY_SPECIAL(), lines 885-896 in cutaway.c - if (_vm->logic()->currentRoom() == 1 && _vm->logic()->gameState(3) == 0) { - // XXX hard-coded room and inventory items - _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(); - } + _vm->logic()->removeHotelItemsFromInventory(); } joeBob->animating = 0; @@ -1147,7 +1136,7 @@ void Cutaway::stop() { if (x || y) { pbs->x = x; pbs->y = y; - if (InRange(object->image, -4, -3)) + if (inRange(object->image, -4, -3)) pbs->scale = _vm->logic()->findScale(x, y); } @@ -1373,7 +1362,7 @@ void Cutaway::handleText( int i; for (i = 0; i < spaces; i++) { - _vm->logic()->update(); + _vm->update(); if (OBJECT_TYPE_TEXT_SPEAK == type || OBJECT_TYPE_TEXT_DISPLAY_AND_SPEAK == type) { // XXX: see if speaking is finished @@ -1389,7 +1378,7 @@ void Cutaway::handleText( } _vm->graphics()->textClear(0,198); - _vm->logic()->update(); + _vm->update(); } int Cutaway::countSpaces(ObjectType type, const char *segment) { @@ -1404,7 +1393,7 @@ int Cutaway::countSpaces(ObjectType type, const char *segment) { if (OBJECT_TYPE_TEXT_DISPLAY == type) tmp *= 3; - return (tmp * 2) / (_vm->logic()->talkSpeed() / 3); + return (tmp * 2) / (_vm->talkSpeed() / 3); } diff --git a/queen/cutaway.h b/queen/cutaway.h index 3739ab4b23..005d43094f 100644 --- a/queen/cutaway.h +++ b/queen/cutaway.h @@ -270,6 +270,7 @@ class Cutaway { //! Dump CutawayAnum data with debug() static void dumpCutawayAnim(CutawayAnim &anim); + bool inRange(int16 x, int16 l, int16 h) const { return (x <= h && x >= l); } }; } // End of namespace Queen diff --git a/queen/defs.h b/queen/defs.h index 7aff4094b7..58ce4abb12 100644 --- a/queen/defs.h +++ b/queen/defs.h @@ -24,9 +24,6 @@ namespace Queen { -// Maybe should be an inlined function somwhere else, feel free to change -#define InRange(x,l,h) ((x)<=(h) && (x)>=(l)) /* X in [l..h] */ - #define SAVEGAME_SIZE 24622 enum { diff --git a/queen/display.cpp b/queen/display.cpp index d2a34fded5..c1d4ee4fc7 100644 --- a/queen/display.cpp +++ b/queen/display.cpp @@ -177,7 +177,7 @@ void Display::palSetJoeNormal() { void Display::palSetPanel() { - warning("Display::palSetPanel()"); + memcpy(_pal.room + 144 * 3, _pal.panel, (256 - 144) * 3); } @@ -636,15 +636,31 @@ void Display::update(bool dynalum, int16 dynaX, int16 dynaY) { } +void Display::setupPanel() { + uint8 *pcxBuf = _vm->resource()->loadFile("panel.pcx"); + uint32 size = _vm->resource()->fileSize("panel.pcx"); + uint8 *dst = _panelBuf + PANEL_W * 10; + readPCX(dst, PANEL_W, pcxBuf + 128, PANEL_W, PANEL_H - 10); + const uint8 *pal = pcxBuf + size - 768 + 144 * 3; + memcpy(_pal.panel, pal, (256 - 144) * 3); + delete[] pcxBuf; + + palSetPanel(); +} + + void Display::setupNewRoom(const char *name, uint16 room) { dynalumInit(name, room); char filename[20]; sprintf(filename, "%s.PCX", name); - uint8 *pcxbuf = _vm->resource()->loadFile(filename); + uint8 *pcxBuf = _vm->resource()->loadFile(filename); uint32 size = _vm->resource()->fileSize(filename); - readPCXBackdrop(pcxbuf, size, room > 114); - delete[] pcxbuf; + _bdWidth = READ_LE_UINT16(pcxBuf + 12); + _bdHeight = READ_LE_UINT16(pcxBuf + 14); + readPCX(_backdropBuf, BACKDROP_W, pcxBuf + 128, _bdWidth, _bdHeight); + memcpy(_pal.room, pcxBuf + size - 768, IS_CD_INTRO_ROOM(room) ? 256 * 3 : 144 * 3); + delete[] pcxBuf; palCustomColors(room); @@ -738,23 +754,6 @@ void Display::readPCX(uint8 *dst, uint16 dstPitch, const uint8 *src, uint16 w, u } -void Display::readPCXBackdrop(const uint8 *pcxBuf, uint32 size, bool useFullPal) { - _bdWidth = READ_LE_UINT16(pcxBuf + 12); - _bdHeight = READ_LE_UINT16(pcxBuf + 14); - readPCX(_backdropBuf, BACKDROP_W, pcxBuf + 128, _bdWidth, _bdHeight); - memcpy(_pal.room, pcxBuf + size - 768, useFullPal ? 256 * 3 : 144 * 3); -} - - -void Display::readPCXPanel(const uint8 *pcxBuf, uint32 size) { - uint8 *dst = _panelBuf + PANEL_W * 10; - readPCX(dst, PANEL_W, pcxBuf + 128, PANEL_W, PANEL_H - 10); - const uint8 *pal = pcxBuf + size - 768 + 144 * 3; - memcpy(_pal.room + 144 * 3, pal, (256 - 144) * 3); - memcpy(_pal.panel, pal, (256 - 144) * 3); -} - - void Display::horizontalScrollUpdate(int16 xCamera) { debug(9, "Display::horizontalScrollUpdate(%d)", xCamera); int16 hs = _horizontalScroll; diff --git a/queen/display.h b/queen/display.h index 37dd09ef26..aef8b0db72 100644 --- a/queen/display.h +++ b/queen/display.h @@ -59,6 +59,7 @@ public: void prepareUpdate(); void update(bool dynalum = false, int16 dynaX = 0, int16 dynaY = 0); + void setupPanel(); void setupNewRoom(const char *name, uint16 room); void drawBobSprite(const uint8 *data, uint16 x, uint16 y, uint16 w, uint16 h, uint16 pitch, bool xflip); @@ -69,8 +70,6 @@ public: void fill(uint8 *dstBuf, uint16 dstPitch, uint16 x, uint16 y, uint16 w, uint16 h, uint8 color); void readPCX(uint8 *dst, uint16 dstPitch, const uint8 *src, uint16 w, uint16 h); - void readPCXBackdrop(const uint8 *pcxBuf, uint32 size, bool useFullPal); - void readPCXPanel(const uint8 *pcxBuf, uint32 size); void horizontalScrollUpdate(int16 xCamera); void horizontalScroll(int16 scroll) { _fullRefresh = true; _horizontalScroll = scroll; } diff --git a/queen/graphics.cpp b/queen/graphics.cpp index 178bb5cbb1..10b5c0dee2 100644 --- a/queen/graphics.cpp +++ b/queen/graphics.cpp @@ -844,17 +844,6 @@ void Graphics::eraseAllAnims() { } -void Graphics::loadPanel() { - uint8 *pcxbuf = _vm->resource()->loadFile("panel.pcx"); - if (pcxbuf == NULL) { - error("Unable to open panel file"); - } - uint32 size = _vm->resource()->fileSize("panel.pcx"); - _vm->display()->readPCXPanel(pcxbuf, size); - delete[] pcxbuf; -} - - void BamScene::updateCarAnimation() { if (_flag != F_STOP) { const BamDataBlock *bdb = &_carData[_index]; diff --git a/queen/graphics.h b/queen/graphics.h index 5f52acf7ee..c374bd7cfc 100644 --- a/queen/graphics.h +++ b/queen/graphics.h @@ -119,9 +119,9 @@ public: void eraseAllFrames(bool joe); enum { - MAX_BANK_SIZE = 110, - MAX_FRAMES_NUMBER = 256, - MAX_BANKS_NUMBER = 18 + MAX_BANK_SIZE = 110, + MAX_FRAMES_NUMBER = 256, + MAX_BANKS_NUMBER = 18 }; @@ -187,8 +187,6 @@ public: void erasePersonAnim(uint16 bobNum); void eraseAllAnims(); - void loadPanel(); - void putCameraOnBob(int bobNum) { _cameraBob = bobNum; } void update(uint16 room); diff --git a/queen/journal.cpp b/queen/journal.cpp index 650d41b114..74c7f30558 100644 --- a/queen/journal.cpp +++ b/queen/journal.cpp @@ -253,7 +253,7 @@ void Journal::handleNormalMode(int16 zoneNum, int x) { enterYesNoMode(zoneNum, TXT_GIVE_UP); } if (zoneNum == ZN_TEXT_SPEED) { - _vm->logic()->talkSpeed((x - 136) * 100 / 130); + _vm->talkSpeed((x - 136) * 100 / 130); drawConfigPanel(); } else if (zoneNum == ZN_SFX_TOGGLE) { _vm->sound()->toggleSfx(); @@ -283,7 +283,7 @@ void Journal::handleNormalMode(int16 zoneNum, int x) { _vm->sound()->toggleSpeech(); drawConfigPanel(); } else if (zoneNum == ZN_TEXT_TOGGLE) { - _vm->logic()->subtitles(!_vm->logic()->subtitles()); + _vm->subtitles(!_vm->subtitles()); drawConfigPanel(); } } @@ -453,13 +453,13 @@ void Journal::drawYesNoPanel(int titleNum) { void Journal::drawConfigPanel() { _vm->checkOptionSettings(); - drawSlideBar(_vm->logic()->talkSpeed(), 130, 100, BOB_TALK_SPEED, 136 - 4, 164, FRAME_BLUE_PIN); + drawSlideBar(_vm->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(_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->subtitles(), BOB_TEXT_TOGGLE, 125, 167, FRAME_CHECK_BOX); drawCheckBox(_vm->sound()->musicOn(), BOB_MUSIC_TOGGLE, 125, 181, FRAME_CHECK_BOX); } diff --git a/queen/logic.cpp b/queen/logic.cpp index 7a9b94bc5e..c93c033b9c 100644 --- a/queen/logic.cpp +++ b/queen/logic.cpp @@ -43,16 +43,18 @@ namespace Queen { Logic::Logic(QueenEngine *vm) - : _queen2jas(NULL), _vm(vm), _credits(NULL) { + : _queen2jas(NULL), _credits(NULL), _vm(vm) { _joe.x = _joe.y = 0; _joe.scale = 100; memset(_gameState, 0, sizeof(_gameState)); memset(_talkSelected, 0, sizeof(_talkSelected)); _puzzleAttemptCount = 0; initialise(); + _journal = new Journal(vm); } Logic::~Logic() { + delete _journal; delete _credits; delete _queen2jas; } @@ -258,7 +260,7 @@ void Logic::initialise() { _vm->command()->clear(false); _scene = 0; memset(_gameState, 0, sizeof(_gameState)); - _vm->graphics()->loadPanel(); + _vm->display()->setupPanel(); _vm->graphics()->bobSetupControl(); setupJoe(); zoneSetupPanel(); @@ -974,7 +976,7 @@ void Logic::roomDisplay(uint16 room, RoomDisplayMode mode, uint16 scale, int com pod = setupJoeInRoom(mode != RDM_FADE_JOE_XY, scale); } if (mode != RDM_NOFADE_JOE) { - update(); + _vm->update(); BobSlot *joe = _vm->graphics()->bob(0); if (IS_CD_INTRO_ROOM(_currentRoom)) { _vm->display()->palFadeIn(0, 255, _currentRoom, joe->active, joe->x, joe->y); @@ -1225,24 +1227,24 @@ uint16 Logic::joeFace() { if (joeFacing() == DIR_FRONT) { if (joePrevFacing() == DIR_BACK) { pbs->frameNum = 33 + FRAMES_JOE_XTRA; - update(); + _vm->update(); } frame = 34; } else if (joeFacing() == DIR_BACK) { if (joePrevFacing() == DIR_FRONT) { pbs->frameNum = 33 + FRAMES_JOE_XTRA; - update(); + _vm->update(); } frame = 35; } else if ((joeFacing() == DIR_LEFT && joePrevFacing() == DIR_RIGHT) || (joeFacing() == DIR_RIGHT && joePrevFacing() == DIR_LEFT)) { pbs->frameNum = 34 + FRAMES_JOE_XTRA; - update(); + _vm->update(); } pbs->frameNum = frame + FRAMES_JOE_XTRA; pbs->scale = joeScale(); pbs->xflip = (joeFacing() == DIR_LEFT); - update(); + _vm->update(); joePrevFacing(joeFacing()); switch (frame) { case 33: @@ -1293,12 +1295,12 @@ void Logic::joeGrab(int16 grabState) { _vm->bankMan()->unpack(5, 29 + FRAMES_JOE_XTRA, 7); bobJoe->xflip = (joeFacing() == DIR_LEFT); bobJoe->scale = joeScale(); - update(); + _vm->update(); // grab up _vm->bankMan()->unpack(7, 29 + FRAMES_JOE_XTRA, 7); bobJoe->xflip = (joeFacing() == DIR_LEFT); bobJoe->scale = joeScale(); - update(); + _vm->update(); // turn back frame = 7; break; @@ -1308,12 +1310,12 @@ void Logic::joeGrab(int16 grabState) { _vm->bankMan()->unpack(frame, 29 + FRAMES_JOE_XTRA, 7); bobJoe->xflip = (joeFacing() == DIR_LEFT); bobJoe->scale = joeScale(); - update(); + _vm->update(); // extra delay for grab down if (grabState == STATE_GRAB_DOWN) { - update(); - update(); + _vm->update(); + _vm->update(); } } } @@ -1492,7 +1494,7 @@ void Logic::inventoryRefresh() { x += 35; } // XXX OLDVERB=VERB; - update(); + _vm->update(); } int16 Logic::previousInventoryItem(int16 start) const { @@ -1581,6 +1583,20 @@ void Logic::inventoryScroll(uint16 count, bool up) { } +void Logic::removeHotelItemsFromInventory() { + if (currentRoom() == 1 && gameState(3) == 0) { + inventoryDeleteItem(ITEM_CROWBAR, false); + inventoryDeleteItem(ITEM_DRESS, false); + inventoryDeleteItem(ITEM_CLOTHES, false); + inventoryDeleteItem(ITEM_HAY, false); + inventoryDeleteItem(ITEM_OIL, false); + inventoryDeleteItem(ITEM_CHICKEN, false); + gameState(3, 1); + inventoryRefresh(); + } +} + + void Logic::objectCopy(int dummyObjectIndex, int realObjectIndex) { // P3_COPY_FROM function in cutaway.c /* Copy data from Dummy (D) object to object (K) @@ -1640,17 +1656,9 @@ void Logic::objectCopy(int dummyObjectIndex, int realObjectIndex) { } -void Logic::checkPlayer() { - update(); - if (!_vm->input()->cutawayRunning()) { - _vm->command()->updatePlayer(); - } -} - - -void Logic::customMoveJoe(int facing, uint16 areaNum, uint16 walkDataNum) { +void Logic::handleSpecialArea(int facing, uint16 areaNum, uint16 walkDataNum) { // queen.c l.2838-2911 - debug(9, "customMoveJoe(%d, %d, %d)\n", facing, areaNum, walkDataNum); + debug(9, "handleSpecialArea(%d, %d, %d)\n", facing, areaNum, walkDataNum); // Stop animating Joe _vm->graphics()->bob(0)->animating = false; @@ -1785,7 +1793,7 @@ void Logic::handlePinnacleRoom() { // to animate anymore ; so turn animating off joe->animating = piton->animating = false; - update(); + _vm->update(); _vm->display()->palFadeIn(0, 223, ROOM_JUNGLE_PINNACLE, joe->active, joe->x, joe->y); _vm->graphics()->textCurrentColor(INK_PINNACLE_ROOM); @@ -1793,7 +1801,7 @@ void Logic::handlePinnacleRoom() { uint16 prevObj = 0; while (_vm->input()->mouseButton() == 0 || _entryObj == 0) { - update(); + _vm->update(); int mx = _vm->input()->mousePosX(); int my = _vm->input()->mousePosY(); @@ -1845,7 +1853,7 @@ void Logic::handlePinnacleRoom() { { 0x2F, 6 }, { 0x2C, 7 }, { 0x2B, 3 }, - { 0x30, 3 }, + { 0x30, 3 } }; for (int i = 0; i < ARRAYSIZE(songs); ++i) { if (songs[i].obj == prevObj) { @@ -1864,19 +1872,9 @@ void Logic::handlePinnacleRoom() { void Logic::update() { - if (_vm->debugger()->isAttached()) { - _vm->debugger()->onFrame(); - } - - _vm->graphics()->update(_currentRoom); if (_credits) _credits->update(); - _vm->input()->delay(); - - if (!_vm->resource()->isInterview()) { - _vm->display()->palCustomScroll(_currentRoom); - } if (_vm->debugger()->_drawAreas) { for(int i = 1; i < MAX_ZONES_NUMBER; ++i) { const ZoneSlot *pzs = &_zones[ZONE_ROOM][i]; @@ -1886,29 +1884,9 @@ void Logic::update() { } } } - BobSlot *joe = _vm->graphics()->bob(0); - _vm->display()->update(joe->active, joe->x, joe->y); - - _vm->input()->checkKeys(); - if (_vm->input()->debugger()) { - _vm->input()->debuggerReset(); - _vm->debugger()->attach(); - } - if (!_vm->input()->cutawayRunning()) { - if (_vm->input()->quickSave()) { - _vm->input()->quickSaveReset(); - gameSave(0, "Quicksave"); - } - if (_vm->input()->quickLoad()) { - _vm->input()->quickLoadReset(); - gameLoad(0); - } - if (_vm->input()->idleTime() >= Input::DELAY_SCREEN_BLANKER) { - _vm->display()->blankScreen(); - } - } } + bool Logic::gameSave(uint16 slot, const char *desc) { if (!desc) //no description entered return false; @@ -1925,12 +1903,12 @@ bool Logic::gameSave(uint16 slot, const char *desc) { memcpy(ptr, buf, 32); ptr += 32; delete[] buf; - WRITE_BE_UINT16(ptr, _talkSpeed); ptr += 2; + WRITE_BE_UINT16(ptr, _vm->talkSpeed()); ptr += 2; WRITE_BE_UINT16(ptr, 0 /*_settings.musicVolume*/); 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; + WRITE_BE_UINT16(ptr, _vm->subtitles() ? 1 : 0); ptr += 2; for (i = 0; i < 4; i++) { WRITE_BE_UINT16(ptr, _inventoryItem[i]); ptr += 2; @@ -2000,7 +1978,7 @@ bool Logic::gameLoad(uint16 slot) { _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; + _vm->subtitles(READ_BE_UINT16(ptr) != 0); ptr += 2; for (i = 0; i < 4; i++) { _inventoryItem[i] = (int16)READ_BE_UINT16(ptr); ptr += 2; @@ -2086,7 +2064,7 @@ void Logic::sceneStart() { _vm->display()->palFadePanel(); } - update(); + _vm->update(); } void Logic::sceneStop() { @@ -2114,8 +2092,7 @@ void Logic::useJournal() { makePersonSpeak("This is a demo, so I can't load or save games*14", NULL, ""); } else if (!_vm->resource()->isInterview()) { _vm->command()->clear(false); - Journal j(_vm); - j.use(); + _journal->use(); _vm->walk()->stopJoe(); // XXX TALKQUIT=CUTQUIT=0; Make sure that we turn off cut stuff in case we use Journal during cutaways } @@ -2177,7 +2154,7 @@ void Logic::asmStartFightAnimation() { void Logic::asmWaitForFrankPosition() { _vm->bam()->_flag = BamScene::F_REQ_STOP; while (_vm->bam()->_flag != BamScene::F_STOP) { - update(); + _vm->update(); } } @@ -2192,10 +2169,10 @@ void Logic::asmMakeFrankGrowing() { int i; for (i = 10; i <= 100; i += 4) { bobFrank->scale = i; - update(); + _vm->update(); } for (i = 0; i <= 20; ++i) { - update(); + _vm->update(); } objectData(521)->name = ABS(objectData(521)->name); // Dinoray @@ -2217,10 +2194,10 @@ void Logic::asmMakeRobotGrowing() { int i; for (i = 10; i <= 100; i += 4) { bobRobot->scale = i; - update(); + _vm->update(); } for (i = 0; i <= 20; ++i) { - update(); + _vm->update(); } objectData(524)->name = -ABS(objectData(524)->name); // Azura object off @@ -2233,7 +2210,7 @@ void Logic::asmShrinkRobot() { BobSlot *robot = _vm->graphics()->bob(6); for (i = 100; i >= 35; i -= 5) { robot->scale = i; - update(); + _vm->update(); } } @@ -2241,7 +2218,7 @@ void Logic::asmShrinkRobot() { void Logic::asmEndGame() { int i; for (i = 0; i < 40; ++i) { - update(); + _vm->update(); } debug(0, "Game completed."); OSystem::instance()->quit(); @@ -2257,7 +2234,7 @@ void Logic::asmPutCameraOnDino() { scrollx = 320; } _vm->display()->horizontalScroll(scrollx); - update(); + _vm->update(); } _vm->graphics()->putCameraOnBob(1); } @@ -2271,7 +2248,7 @@ void Logic::asmPutCameraOnJoe() { void Logic::asmAltIntroPanRight() { _vm->graphics()->putCameraOnBob(-1); _vm->input()->fastMode(true); - update(); + _vm->update(); int16 scrollx = _vm->display()->horizontalScroll(); while (scrollx < 285 && !_vm->input()->cutawayQuit()) { ++scrollx; @@ -2279,7 +2256,7 @@ void Logic::asmAltIntroPanRight() { scrollx = 285; } _vm->display()->horizontalScroll(scrollx); - update(); + _vm->update(); } _vm->input()->fastMode(false); } @@ -2295,7 +2272,7 @@ void Logic::asmAltIntroPanLeft() { scrollx = 0; } _vm->display()->horizontalScroll(scrollx); - update(); + _vm->update(); } _vm->input()->fastMode(false); } @@ -2315,7 +2292,7 @@ void Logic::asmPanRightFromJoe() { scrollx = 320; } _vm->display()->horizontalScroll(scrollx); - update(); + _vm->update(); } } @@ -2352,7 +2329,7 @@ void Logic::asmPanToJoe() { scrollx = i; } _vm->display()->horizontalScroll(scrollx); - update(); + _vm->update(); } } else { while (scrollx < i) { @@ -2361,9 +2338,9 @@ void Logic::asmPanToJoe() { scrollx = i; } _vm->display()->horizontalScroll(scrollx); - update(); + _vm->update(); } - update(); + _vm->update(); } _vm->graphics()->putCameraOnBob(0); } @@ -2383,7 +2360,7 @@ void Logic::asmPanLeft320To144() { scrollx = 144; } _vm->display()->horizontalScroll(scrollx); - update(); + _vm->update(); } } @@ -2403,7 +2380,7 @@ void Logic::asmSmooch() { bobAzura->x += 8; bobJoe->x += 8; } - update(); + _vm->update(); } } @@ -2436,7 +2413,7 @@ void Logic::asmMakeLightningHitPlane() { if (scrollX > 320) scrollX = 320; _vm->display()->horizontalScroll(scrollX); - update(); + _vm->update(); } planeBob->scale = 100; @@ -2462,7 +2439,7 @@ void Logic::asmMakeLightningHitPlane() { fireBob->y = planeBob->y + 10; _vm->bankMan()->unpack(19, fireBob->frameNum, 15); - update(); + _vm->update(); k = 20; j = 1; @@ -2482,7 +2459,7 @@ void Logic::asmMakeLightningHitPlane() { j = 1; } - update(); + _vm->update(); } _vm->graphics()->putCameraOnBob(0); @@ -2504,7 +2481,7 @@ void Logic::asmScaleBlimp() { --x; } - update(); + _vm->update(); } } @@ -2517,10 +2494,10 @@ void Logic::asmScaleEnding() { int i; for (i = 5; i <= 100; i += 5) { b->scale = i; - update(); + _vm->update(); } for (i = 0; i < 50; ++i) { - update(); + _vm->update(); } _vm->display()->palFadeOut(0, 255, currentRoom()); } @@ -2529,16 +2506,16 @@ void Logic::asmScaleEnding() { void Logic::asmWaitForCarPosition() { // Wait for car to reach correct position before pouring oil while (_vm->bam()->_index != 60) { - update(); + _vm->update(); } } void Logic::asmShakeScreen() { OSystem::instance()->set_shake_pos(3); - update(); + _vm->update(); OSystem::instance()->set_shake_pos(0); - update(); + _vm->update(); } @@ -2562,7 +2539,7 @@ void Logic::asmScaleTitle() { for (i = 5; i <= 100; i +=5) { bob->scale = i; bob->y -= 4; - update(); + _vm->update(); } } @@ -2579,7 +2556,7 @@ void Logic::asmPanRightToHugh() { _vm->graphics()->putCameraOnBob(-1); _vm->input()->fastMode(true); - update(); + _vm->update(); int i = 4, k = 160; @@ -2622,7 +2599,7 @@ void Logic::asmPanRightToHugh() { bob_thugB1->x -= i * 4; bob_thugB2->x -= i * 4; - update(); + _vm->update(); } _vm->input()->fastMode(false); @@ -2644,7 +2621,7 @@ void Logic::asmPanRightToJoeAndRita() { // cdint.cut _vm->graphics()->putCameraOnBob(-1); _vm->input()->fastMode(true); - update(); + _vm->update(); bob_box ->x += 280 * 2; bob_beam ->x += 30; @@ -2667,7 +2644,7 @@ void Logic::asmPanRightToJoeAndRita() { // cdint.cut bob_clock->x -= i * 2; bob_hands->x -= i * 2; - update(); + _vm->update(); } _vm->input()->fastMode(false); } @@ -2696,7 +2673,7 @@ void Logic::asmPanLeftToBomb() { bob22->x += i; - update(); + _vm->update(); } _vm->input()->fastMode(false); @@ -2724,7 +2701,7 @@ void Logic::asmInterviewIntro() { if (scale < 256) { scale = 256; } - update(); + _vm->update(); } bas->scale = 90; @@ -2732,17 +2709,17 @@ void Logic::asmInterviewIntro() { bas->move(560, 25, 4); while (bas->moving && !_vm->input()->cutawayQuit()) { - update(); + _vm->update(); } bas->move(545, 65, 2); while (bas->moving && !_vm->input()->cutawayQuit()) { - update(); + _vm->update(); } bas->move(540, 75, 2); while (bas->moving && !_vm->input()->cutawayQuit()) { - update(); + _vm->update(); } // put camera on Joe @@ -2814,11 +2791,10 @@ bool LogicGame::preChangeRoom() { // XXX enable talking for talkie version if (ConfMan.getBool("alt_intro")) { - _vm->graphics()->loadPanel(); playCutaway("cintr.cut"); } else { playCutaway("cdint.cut"); - _vm->graphics()->loadPanel(); + _vm->display()->palSetPanel(); } playCutaway("cred.cut"); diff --git a/queen/logic.h b/queen/logic.h index 38fd8d90d6..55344f5a34 100644 --- a/queen/logic.h +++ b/queen/logic.h @@ -53,8 +53,10 @@ struct ZoneSlot { Box box; }; -class QueenEngine; + class Credits; +class Journal; +class QueenEngine; class Logic { @@ -208,13 +210,12 @@ public: void inventoryInsertItem(uint16 itemNum, bool refresh = true); void inventoryDeleteItem(uint16 itemNum, bool refresh = true); void inventoryScroll(uint16 count, bool up); + void removeHotelItemsFromInventory(); //! Copy data from dummy object to object void objectCopy(int dummyObjectIndex, int objectIndex); - void checkPlayer(); - - void customMoveJoe(int facing, uint16 areaNum, uint16 walkDataNum); + void handleSpecialArea(int facing, uint16 areaNum, uint16 walkDataNum); void handlePinnacleRoom(); @@ -236,11 +237,6 @@ public: void useJournal(); - int talkSpeed() const { return _talkSpeed; } - void talkSpeed(int speed) { _talkSpeed = speed; } - bool subtitles() const { return _subtitles; } - void subtitles(bool enable) { _subtitles = enable; } - void executeSpecialMove(uint16 sm); void asmMakeJoeUseDress(); @@ -423,12 +419,10 @@ protected: //! scene counter int _scene; - int _talkSpeed; - - bool _subtitles; + Credits *_credits; + Journal *_journal; QueenEngine *_vm; - Credits *_credits; }; class LogicDemo : public Logic { diff --git a/queen/queen.cpp b/queen/queen.cpp index e0c04ffc9f..f9bf8fc407 100644 --- a/queen/queen.cpp +++ b/queen/queen.cpp @@ -128,10 +128,10 @@ void QueenEngine::registerDefaultSettings() { void QueenEngine::checkOptionSettings() { // check talkspeed value - if (_logic->talkSpeed() < 4) { - _logic->talkSpeed(4); - } else if (_logic->talkSpeed() > 95) { - _logic->talkSpeed(100); + if (_talkSpeed < 4) { + _talkSpeed = 4; + } else if (_talkSpeed > 95) { + _talkSpeed = 100; } // XXX check master_volume value @@ -143,7 +143,7 @@ void QueenEngine::checkOptionSettings() { // ensure text is always on when voice is off if (!_sound->speechOn()) { - _logic->subtitles(true); + _subtitles = true; } } @@ -152,9 +152,9 @@ void QueenEngine::readOptionSettings() { // XXX master_volume _sound->musicToggle(!ConfMan.getBool("music_mute")); _sound->sfxToggle(!ConfMan.getBool("sfx_mute")); - _logic->talkSpeed(ConfMan.getInt("talkspeed")); + _talkSpeed = ConfMan.getInt("talkspeed"); _sound->speechToggle(!ConfMan.getBool("speech_mute")); - _logic->subtitles(ConfMan.getBool("subtitles")); + _subtitles = ConfMan.getBool("subtitles"); checkOptionSettings(); } @@ -163,13 +163,52 @@ void QueenEngine::writeOptionSettings() { // XXX master_volume ConfMan.set("music_mute", !_sound->musicOn()); ConfMan.set("sfx_mute", !_sound->sfxOn()); - ConfMan.set("talkspeed", _logic->talkSpeed()); + ConfMan.set("talkspeed", _talkSpeed); ConfMan.set("speech_mute", !_sound->speechOn()); - ConfMan.set("subtitles", _logic->subtitles()); + ConfMan.set("subtitles", _subtitles); ConfMan.flushToDisk(); } +void QueenEngine::update(bool checkPlayerInput) { + if (_debugger->isAttached()) { + _debugger->onFrame(); + } + + _graphics->update(_logic->currentRoom()); + _logic->update(); + + _input->delay(); + + if (!_resource->isInterview()) { + _display->palCustomScroll(_logic->currentRoom()); + } + BobSlot *joe = _graphics->bob(0); + _display->update(joe->active, joe->x, joe->y); + + _input->checkKeys(); + if (_input->debugger()) { + _input->debuggerReset(); + _debugger->attach(); + } + if (!_input->cutawayRunning()) { + if (_input->quickSave()) { + _input->quickSaveReset(); + _logic->gameSave(0, "Quicksave"); + } + if (_input->quickLoad()) { + _input->quickLoadReset(); + _logic->gameLoad(0); + } + if (checkPlayerInput) { + _command->updatePlayer(); + } + if (_input->idleTime() >= Input::DELAY_SCREEN_BLANKER) { + _display->blankScreen(); + } + } +} + void QueenEngine::errorString(const char *buf1, char *buf2) { strcpy(buf2, buf1); if (_debugger && !_debugger->isAttached()) { @@ -209,7 +248,7 @@ void QueenEngine::go() { // _command->clear(true); // } _logic->joeWalk(JWM_NORMAL); - _logic->checkPlayer(); + update(true); } } } diff --git a/queen/queen.h b/queen/queen.h index f305e296b1..a2f659940b 100644 --- a/queen/queen.h +++ b/queen/queen.h @@ -67,6 +67,13 @@ public: void readOptionSettings(); void writeOptionSettings(); + int talkSpeed() const { return _talkSpeed; } + void talkSpeed(int speed) { _talkSpeed = speed; } + bool subtitles() const { return _subtitles; } + void subtitles(bool enable) { _subtitles = enable; } + + void update(bool checkPlayerInput = false); + protected: void errorString(const char *buf_input, char *buf_output); @@ -75,10 +82,13 @@ protected: void initialise(); - static void timerHandler(void *ptr); void gotTimerTick(); + + int _talkSpeed; + bool _subtitles; + BamScene *_bam; BankManager *_bankMan; Command *_command; diff --git a/queen/talk.cpp b/queen/talk.cpp index 1b561322e2..b80612c908 100644 --- a/queen/talk.cpp +++ b/queen/talk.cpp @@ -711,7 +711,7 @@ int Talk::countSpaces(const char *segment) { if (tmp < 10) tmp = 10; - return (tmp * 2) / (_vm->logic()->talkSpeed() / 3); + return (tmp * 2) / (_vm->talkSpeed() / 3); } void Talk::headStringAnimation(const SpeechParameters *parameters, int bobNum, int bankNum) { @@ -743,7 +743,7 @@ void Talk::headStringAnimation(const SpeechParameters *parameters, int bobNum, i bob2->x = x; bob2->y = y; - _vm->logic()->update(); + _vm->update(); } } else @@ -795,7 +795,7 @@ void Talk::stringAnimation(const SpeechParameters *parameters, int startFrame, i // XXX bobs[BNUM].scale=SF; } - _vm->logic()->update(); + _vm->update(); } // XXX #ifdef __DOS__ @@ -881,23 +881,23 @@ void Talk::defaultAnimation( } if (!_talkHead) - _vm->logic()->update(); + _vm->update(); } else { // (_talkHead && isJoe) - _vm->logic()->update(); + _vm->update(); } if (_vm->logic()->joeWalk() == JWM_SPEAK) { if (_vm->input()->talkQuit()) break; - _vm->logic()->update(); + _vm->update(); } else { if (_vm->input()->talkQuit()) break; - _vm->logic()->checkPlayer(); + _vm->update(true); if (_vm->logic()->joeWalk() == JWM_EXECUTE) // Selected a command, so exit break; @@ -951,7 +951,7 @@ void Talk::speakSegment( for (i = 0; i < 10; i++) { if (_vm->input()->talkQuit()) break; - _vm->logic()->update(); + _vm->update(); } return; @@ -1074,7 +1074,7 @@ void Talk::speakSegment( if (length == 0 && !isJoe && parameters->bf > 0) { _vm->bankMan()->overpack(parameters->bf, startFrame, bankNum); - _vm->logic()->update(); + _vm->update(); } /* A12 = the frame pointer for the full body frame, well use this */ @@ -1147,7 +1147,7 @@ void Talk::speakSegment( } } - _vm->logic()->update(); + _vm->update(); } const Talk::SpeechParameters *Talk::findSpeechParameters( @@ -1334,7 +1334,7 @@ int16 Talk::selectSentence() { if (_vm->input()->talkQuit()) break; - _vm->logic()->update(); + _vm->update(); zone = _vm->logic()->zoneIn(ZONE_PANEL, _vm->input()->mousePosX(), _vm->input()->mousePosY()); diff --git a/queen/walk.cpp b/queen/walk.cpp index 1712d46c23..4ff4bd44fd 100644 --- a/queen/walk.cpp +++ b/queen/walk.cpp @@ -114,7 +114,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 - _vm->logic()->customMoveJoe(pwd->anim.facing, pwd->areaNum, i); + _vm->logic()->handleSpecialArea(pwd->anim.facing, pwd->areaNum, i); _joeMoveBlock = true; return; } @@ -137,7 +137,7 @@ void Walk::animateJoe() { if (pbs->speed == 0) { pbs->speed = 1; } - _vm->logic()->checkPlayer(); + _vm->update(true); // FIXME it would nice to be able to get rid of these 3 lines // as stopJoe() should be do the same... if (_vm->logic()->joeWalk() == JWM_EXECUTE) { // XXX || cutQuit @@ -259,7 +259,7 @@ void Walk::animatePerson(const MovePersonData *mpd, uint16 image, uint16 bobNum, } while (pbs->moving) { - _vm->logic()->update(); + _vm->update(); uint16 scale = pwd->area->calcScale(pbs->y); pbs->scale = scale; if (pbs->xmajor) { diff --git a/queen/walk.h b/queen/walk.h index 09a8168a03..16c64e1b67 100644 --- a/queen/walk.h +++ b/queen/walk.h @@ -44,7 +44,7 @@ struct MovePersonAnim { struct WalkData { int16 dx, dy; const Area *area; - uint16 areaNum; // extra stuff for customMoveJoe + uint16 areaNum; MovePersonAnim anim; }; @@ -125,7 +125,7 @@ private: //! set if stopJoe() is called bool _joeInterrupted; - //! set if customMoveJoe() is called + //! set if handleSpecialArea() is called bool _joeMoveBlock; QueenEngine *_vm; diff --git a/queen/xref.txt b/queen/xref.txt index 6e5bbe7e07..48c287d614 100644 --- a/queen/xref.txt +++ b/queen/xref.txt @@ -127,7 +127,7 @@ clearbob() Graphics::bobClear drawbobs() Graphics::bobDrawAll invbob() Graphics::bobDrawInventoryItem loadbackdrop() *included in Display::setupNewRoom* -loadpanel() Graphics::loadPanel +loadpanel() Display::setupPanel MAKE_SPEAK_BOB() Graphics::bobSetText makeanim() BobSlot::animNormal movebob() BobSlot::move @@ -204,8 +204,8 @@ walkgameload *not needed ?* LOGIC ===== -CHECK_PLAYER() Logic::checkPlayer -CUTAWAY_SPECIAL() +CHECK_PLAYER() QueenEngine::update +CUTAWAY_SPECIAL() Logic::removeHotelItemsFromInventory DISP_OBJECTS() Logic::roomSetupObjects DISP_ROOM() Logic::roomDisplay FIND_BOB() Logic::findBob @@ -220,9 +220,9 @@ restart_game() SETUP_BOBS() Graphics::bobSetupControl SETUP_FURNITURE() Logic::roomSetupFurniture SETUP_ROOM() Logic::changeRoom -SETUP_SCREENS() *not needed* (only calls Graphics::loadPanel) +SETUP_SCREENS() *not needed* (only calls Display::setupPanel) SETUP_VARS() *not needed* (equivalent to Command::clear(), SCENE=0, clear(gamestate)) -update() Logic::update +update() QueenEngine::update - A_ANIMstr Logic::_aAnim A_ANIM_MAX Logic::_numAAnim |