diff options
author | Gregory Montoir | 2003-12-19 09:22:20 +0000 |
---|---|---|
committer | Gregory Montoir | 2003-12-19 09:22:20 +0000 |
commit | b7a5d9720791bd112730d1384c7c7cf94a40e381 (patch) | |
tree | b4a35d45270cc93533455f8d70f5d4b43047364b | |
parent | dae474e86da67330fa0d0fd7a4637d6bedff43e6 (diff) | |
download | scummvm-rg350-b7a5d9720791bd112730d1384c7c7cf94a40e381.tar.gz scummvm-rg350-b7a5d9720791bd112730d1384c7c7cf94a40e381.tar.bz2 scummvm-rg350-b7a5d9720791bd112730d1384c7c7cf94a40e381.zip |
put all 'bam' related stuff in a class and allow load/save during a 'bam' scene
svn-id: r11759
-rw-r--r-- | queen/graphics.cpp | 159 | ||||
-rw-r--r-- | queen/graphics.h | 89 | ||||
-rw-r--r-- | queen/logic.cpp | 50 | ||||
-rw-r--r-- | queen/queen.cpp | 2 | ||||
-rw-r--r-- | queen/queen.h | 3 | ||||
-rw-r--r-- | queen/xref.txt | 6 |
6 files changed, 158 insertions, 151 deletions
diff --git a/queen/graphics.cpp b/queen/graphics.cpp index c58abb482d..2cc14e3adc 100644 --- a/queen/graphics.cpp +++ b/queen/graphics.cpp @@ -26,6 +26,7 @@ #include "queen/logic.h" #include "queen/queen.h" #include "queen/resource.h" +#include "queen/sound.h" namespace Queen { @@ -598,10 +599,12 @@ void Graphics::bobCustomParallax(uint16 roomNum) { } break; case ROOM_CAR_CHASE: - updateCarBamScene(); + _vm->bam()->updateCarAnimation(); +// updateCarBamScene(); break; case ROOM_FINAL_FIGHT: - updateFightBamScene(); + _vm->bam()->updateFightAnimation(); +// updateFightBamScene(); break; case ROOM_INTRO_RITA_JOE_HEADS: // CR 2 - CD-Rom pan right while Rita talks... _cameraBob = -1; @@ -735,49 +738,32 @@ void Graphics::loadPanel() { } -void Graphics::initCarBamScene() { +void BamScene::updateCarAnimation() { - bobClear(5); - _bobs[5].active = true; - bobClear(6); - _bobs[6].active = true; - bobClear(7); - _bobs[7].active = true; - _bam.flag = 1; - _bam.index = 0; -} - - -void Graphics::updateCarBamScene() { - - if (_bam.flag) { - const BamDataBlock *bdb = &_bam._carData[_bam.index]; - BobSlot *pbob; + if (_flag != F_STOP) { + const BamDataBlock *bdb = &_carData[_index]; // Truck - pbob = &_bobs[5]; - pbob->curPos(bdb->obj1.x, bdb->obj1.y); - pbob->frameNum = 40 + bdb->obj1.frame; + _obj1->curPos(bdb->obj1.x, bdb->obj1.y); + _obj1->frameNum = 40 + bdb->obj1.frame; // Rico - pbob = &_bobs[6]; - pbob->curPos(bdb->obj2.x, bdb->obj2.y); - pbob->frameNum = 30 + bdb->obj2.frame; + _obj2->curPos(bdb->obj2.x, bdb->obj2.y); + _obj2->frameNum = 30 + bdb->obj2.frame; // FX - pbob = &_bobs[7]; - pbob->curPos(bdb->fx.x, bdb->fx.y); - pbob->frameNum = 41 + bdb->fx.frame; + _objfx->curPos(bdb->fx.x, bdb->fx.y); + _objfx->frameNum = 41 + bdb->fx.frame; if (bdb->sfx < 0) { - // XXX playsong(-bdb->sfx); + _vm->sound()->playSong(-bdb->sfx); } if (bdb->sfx == 99) { - _bam.index = 0; + _index = 0; } else { - ++_bam.index; + ++_index; } // Play BKG SFX // XXX if(bamsfx==2 && SFXTOGGLE) sfxplay(NULLstr); @@ -785,69 +771,41 @@ void Graphics::updateCarBamScene() { } -void Graphics::cleanupCarBamScene(uint16 oilBobNum) { - - _bam.flag = 0; - //CR 2 - Turn off big oil splat and gun shots! - _bobs[oilBobNum].active = false; - _bobs[7].active = false; -} - - -void Graphics::initFightBamScene() { - - bobClear(5); - _bobs[5].active = true; - bobClear(6); - _bobs[6].active = true; - bobClear(7); - _bobs[7].active = true; - _bam.flag = 1; - _bam.index = 0; - _bam._screenShaked = false; - _bam._fightData = _bam._fight1Data; -} - - -void Graphics::updateFightBamScene() { +void BamScene::updateFightAnimation() { - if (_bam.flag) { - const BamDataBlock *bdb = &_bam._fightData[_bam.index]; - BobSlot *pbob; + if (_flag != F_STOP) { + const BamDataBlock *bdb = &_fightData[_index]; // Frank - pbob = &_bobs[5]; - pbob->curPos(bdb->obj1.x, bdb->obj1.y); - pbob->frameNum = 40 + ABS(bdb->obj1.frame); - pbob->xflip = (bdb->obj1.frame < 0); + _obj1->curPos(bdb->obj1.x, bdb->obj1.y); + _obj1->frameNum = 40 + ABS(bdb->obj1.frame); + _obj1->xflip = (bdb->obj1.frame < 0); // Robot - pbob = &_bobs[6]; - pbob->curPos(bdb->obj2.x, bdb->obj2.y); - pbob->frameNum = 40 + ABS(bdb->obj2.frame); - pbob->xflip = (bdb->obj2.frame < 0); - + _obj2->curPos(bdb->obj2.x, bdb->obj2.y); + _obj2->frameNum = 40 + ABS(bdb->obj2.frame); + _obj2->xflip = (bdb->obj2.frame < 0); + // FX - pbob = &_bobs[7]; - pbob->curPos(bdb->fx.x, bdb->fx.y); - pbob->frameNum = 40 + ABS(bdb->fx.frame); - pbob->xflip = (bdb->fx.frame < 0); + _objfx->curPos(bdb->fx.x, bdb->fx.y); + _objfx->frameNum = 40 + ABS(bdb->fx.frame); + _objfx->xflip = (bdb->fx.frame < 0); if (bdb->sfx < 0) { - // XXX playsong(-bdb->sfx); + _vm->sound()->playSong(-bdb->sfx); } - ++_bam.index; + ++_index; switch (bdb->sfx) { case 0: // nothing, so reset shaked screen if necessary - if (_bam._screenShaked) { + if (_screenShaked) { OSystem::instance()->set_shake_pos(0); - _bam._screenShaked = false; + _screenShaked = false; } break; case 1: // shake screen OSystem::instance()->set_shake_pos(3); - _bam._screenShaked = true; + _screenShaked = true; break; case 2: // play background sfx // XXX if(SFXTOGGLE) sfxplay(NULLstr); @@ -855,18 +813,18 @@ void Graphics::updateFightBamScene() { case 3: // play background sfx and shake screen // XXX if(SFXTOGGLE) sfxplay(NULLstr); OSystem::instance()->set_shake_pos(3); - _bam._screenShaked = true; + _screenShaked = true; break; case 99: // end of BAM data - _bam.index = 0; + _index = 0; const BamDataBlock *data[] = { - _bam._fight1Data, - _bam._fight2Data, - _bam._fight3Data + _fight1Data, + _fight2Data, + _fight3Data }; - _bam._fightData = data[_vm->randomizer.getRandomNumber(2)]; - if (_bam.flag == 2) { - _bam.flag = 0; + _fightData = data[_vm->randomizer.getRandomNumber(2)]; + if (_flag == F_REQ_STOP) { + _flag = F_STOP; } break; } @@ -1008,7 +966,30 @@ int Graphics::textCenterX(const char *text) const { -const BamDataBlock BamData::_carData[] = { +BamScene::BamScene(QueenEngine *vm) + : _flag(F_STOP), _screenShaked(false), _fightData(_fight1Data), _vm(vm) { +} + + +void BamScene::prepareAnimation() { + + _obj1 = _vm->graphics()->bob(BOB_OBJ1); + _vm->graphics()->bobClear(BOB_OBJ1); + _obj1->active = true; + + _obj2 = _vm->graphics()->bob(BOB_OBJ2); + _vm->graphics()->bobClear(BOB_OBJ2); + _obj2->active = true; + + _objfx = _vm->graphics()->bob(BOB_FX); + _vm->graphics()->bobClear(BOB_FX); + _objfx->active = true; + + _index = 0; +} + + +const BamDataBlock BamScene::_carData[] = { { { 310, 105, 1 }, { 314, 106, 17 }, { 366, 101, 1 }, 0 }, { { 303, 105, 1 }, { 307, 106, 17 }, { 214, 0, 10 }, 0 }, { { 297, 104, 1 }, { 301, 105, 17 }, { 214, 0, 10 }, 0 }, @@ -1086,7 +1067,7 @@ const BamDataBlock BamData::_carData[] = { { { 310, 110, 1 }, { 314, 111, 17 }, { 214, 0, 10 }, 99 } }; -const BamDataBlock BamData::_fight1Data[] = { +const BamDataBlock BamScene::_fight1Data[] = { { { 75, 96, 1 }, { 187, 96, -23 }, { 58, 37, 46 }, 0 }, { { 75, 96, 2 }, { 187, 96, -23 }, { 58, 37, 46 }, 0 }, { { 75, 96, 3 }, { 187, 96, -23 }, { 58, 37, 46 }, 0 }, @@ -1135,7 +1116,7 @@ const BamDataBlock BamData::_fight1Data[] = { { { 75, 96, 1 }, { 187, 96, -23 }, { 0, 0, 0 }, 99 } }; -const BamDataBlock BamData::_fight2Data[] = { +const BamDataBlock BamScene::_fight2Data[] = { { { 75, 96, 1 }, { 187, 96, -23 }, { 150, 45, 35 }, 0 }, { { 78, 96, 2 }, { 187, 96, -23 }, { 150, 45, 35 }, 0 }, { { 81, 96, 3 }, { 189, 96, -18 }, { 150, 45, 35 }, 0 }, @@ -1193,7 +1174,7 @@ const BamDataBlock BamData::_fight2Data[] = { { { 75, 96, 5 }, { 187, 96, -23 }, { 224, 53, 53 }, 99 } }; -const BamDataBlock BamData::_fight3Data[] = { +const BamDataBlock BamScene::_fight3Data[] = { { { 75, 96, 1 }, { 187, 96, -23 }, { 150, 45, 35 }, 0 }, { { 77, 96, 2 }, { 187, 96, -22 }, { 150, 45, 35 }, 0 }, { { 80, 96, 3 }, { 185, 96, -17 }, { 150, 45, 35 }, 0 }, diff --git a/queen/graphics.h b/queen/graphics.h index 7227bcf6c3..116bc464c6 100644 --- a/queen/graphics.h +++ b/queen/graphics.h @@ -102,34 +102,6 @@ struct TextSlot { }; -struct BamDataObj { - int16 x, y; - int16 frame; -}; - -struct BamDataBlock { - BamDataObj obj1; // truck / Frank - BamDataObj obj2; // Rico / robot - BamDataObj fx; - int16 sfx; -}; - -struct BamData { - - BamData() : flag(0), index(0) {} - - int16 flag; - int16 index; - - bool _screenShaked; - const BamDataBlock *_fightData; - static const BamDataBlock _carData[]; - static const BamDataBlock _fight1Data[]; - static const BamDataBlock _fight2Data[]; - static const BamDataBlock _fight3Data[]; -}; - - class QueenEngine; class Graphics { @@ -182,15 +154,6 @@ public: void cameraBob(int bobNum) { _cameraBob = bobNum; } int cameraBob() const { return _cameraBob; } - BamData *bamData() { return &_bam; } - - void initCarBamScene(); - void updateCarBamScene(); - void cleanupCarBamScene(uint16 i); - - void initFightBamScene(); - void updateFightBamScene(); - void update(uint16 room); enum { @@ -233,9 +196,59 @@ private: int _cameraBob; - BamData _bam; + QueenEngine *_vm; +}; + + +struct BamDataObj { + int16 x, y; + int16 frame; +}; + +struct BamDataBlock { + BamDataObj obj1; // truck / Frank + BamDataObj obj2; // Rico / robot + BamDataObj fx; + int16 sfx; +}; + +class BamScene { +public: + + BamScene(QueenEngine *vm); + + void prepareAnimation(); + void updateCarAnimation(); + void updateFightAnimation(); + + enum { + BOB_OBJ1 = 5, + BOB_OBJ2 = 6, + BOB_FX = 7 + }; + + enum { + F_STOP = 0, + F_PLAY = 1, + F_REQ_STOP = 2 + }; + + uint16 _flag, _index; + +private: + + BobSlot *_obj1; + BobSlot *_obj2; + BobSlot *_objfx; + bool _screenShaked; + const BamDataBlock *_fightData; QueenEngine *_vm; + + static const BamDataBlock _carData[]; + static const BamDataBlock _fight1Data[]; + static const BamDataBlock _fight2Data[]; + static const BamDataBlock _fight3Data[]; }; } // End of namespace Queen diff --git a/queen/logic.cpp b/queen/logic.cpp index 0daa49a94b..729fc7af5f 100644 --- a/queen/logic.cpp +++ b/queen/logic.cpp @@ -2297,7 +2297,7 @@ bool Logic::gameSave(uint16 slot, const char *desc) { _walkOffData[i].writeTo(ptr); WRITE_BE_UINT16(ptr, _joe.facing); ptr += 2; - WRITE_BE_UINT16(ptr, 0); ptr += 2; //TODO: tmpbamflag + WRITE_BE_UINT16(ptr, _vm->bam()->_flag); ptr += 2; WRITE_BE_UINT16(ptr, 0); ptr += 2; //TODO: lastoverride //TODO: lastmerge, lastalter, altmrgpri @@ -2365,7 +2365,7 @@ bool Logic::gameLoad(uint16 slot) { _walkOffData[i].readFrom(ptr); joeFacing(READ_BE_UINT16(ptr)); ptr += 2; - READ_BE_UINT16(ptr); ptr += 2; //TODO: tmpbamflag + _vm->bam()->_flag = READ_BE_UINT16(ptr); ptr += 2; READ_BE_UINT16(ptr); ptr += 2; //TODO: lastoverride //_vm->sound()->playSound(_vm->sound()->lastOverride()) @@ -2379,6 +2379,10 @@ bool Logic::gameLoad(uint16 slot) { return false; } + if (_vm->bam()->_flag != BamScene::F_STOP) { + _vm->bam()->prepareAnimation(); + } + joeCutFacing(joeFacing()); joeFace(); @@ -2389,19 +2393,19 @@ bool Logic::gameLoad(uint16 slot) { _entryObj = 0; switch (gameState(VAR_DRESSING_MODE)) { - case 0: - joeUseClothes(false); - break; - case 1: - joeUseUnderwear(); - break; - case 2: - joeUseDress(false); - break; + case 0: + joeUseClothes(false); + break; + case 1: + joeUseUnderwear(); + break; + case 2: + joeUseDress(false); + break; } + inventoryRefresh(); - //bamflag = .. - + delete[] saveData; return true; } @@ -2680,21 +2684,25 @@ void Logic::asmSwitchToNormalPalette() { void Logic::asmStartCarAnimation() { // Carbam background animation - room 74 - _vm->graphics()->initCarBamScene(); + _vm->bam()->_flag = BamScene::F_PLAY; + _vm->bam()->prepareAnimation(); } void Logic::asmStopCarAnimation() { - // CR 2 - Turn off big oil splat and gun shots! - _vm->graphics()->cleanupCarBamScene(findBob(594)); // Oil object + _vm->bam()->_flag = BamScene::F_STOP; + //CR 2 - Turn off big oil splat and gun shots! + _vm->graphics()->bob(findBob(594))->active = false; // Oil object + _vm->graphics()->bob(7)->active = false; } void Logic::asmStartFightAnimation() { // Fight1 background animation - room 69 - _vm->graphics()->initFightBamScene(); + _vm->bam()->_flag = BamScene::F_PLAY; + _vm->bam()->prepareAnimation(); gameState(148, 1); } @@ -2702,8 +2710,8 @@ void Logic::asmStartFightAnimation() { void Logic::asmWaitForFrankPosition() { // c69e.cut - _vm->graphics()->bamData()->flag = 2; - while (_vm->graphics()->bamData()->flag) { + _vm->bam()->_flag = BamScene::F_REQ_STOP; + while (_vm->bam()->_flag != BamScene::F_STOP) { update(); } } @@ -2775,8 +2783,8 @@ void Logic::asmEndGame() { for (i = 0; i < 40; ++i) { update(); } - OSystem::instance()->quit(); debug(0, "Game completed"); + OSystem::instance()->quit(); } @@ -3032,7 +3040,7 @@ void Logic::asmScaleEnding() { void Logic::asmWaitForCarPosition() { // Wait for car to reach correct position before pouring oil - while (_vm->graphics()->bamData()->index != 60) { + while (_vm->bam()->_index != 60) { update(); } } diff --git a/queen/queen.cpp b/queen/queen.cpp index 3647379260..60a2f74c0d 100644 --- a/queen/queen.cpp +++ b/queen/queen.cpp @@ -102,6 +102,7 @@ QueenEngine::QueenEngine(GameDetector *detector, OSystem *syst) QueenEngine::~QueenEngine() { _timer->removeTimerProc(&timerHandler); + delete _bam; delete _resource; delete _command; delete _display; @@ -159,6 +160,7 @@ void QueenEngine::go() { void QueenEngine::initialise(void) { + _bam = new BamScene(this); _resource = new Resource(_gameDataPath, _system->get_savefile_manager(), getSavePath()); _command = new Command(this); _display = new Display(this, _resource->getLanguage(), _system); diff --git a/queen/queen.h b/queen/queen.h index f8317e1e3c..4cc9cb3fde 100644 --- a/queen/queen.h +++ b/queen/queen.h @@ -28,6 +28,7 @@ class GameDetector; namespace Queen { +class BamScene; class Command; class Display; class Graphics; @@ -44,6 +45,7 @@ public: QueenEngine(GameDetector *detector, OSystem *syst); virtual ~QueenEngine(); + BamScene *bam() const { return _bam; } Command *command() const { return _command; } Display *display() const { return _display; } Graphics *graphics() const { return _graphics; } @@ -67,6 +69,7 @@ protected: static void timerHandler(void *ptr); void gotTimerTick(); + BamScene *_bam; Command *_command; Display *_display; Graphics *_graphics; diff --git a/queen/xref.txt b/queen/xref.txt index 772cb07a8b..ed01e5b711 100644 --- a/queen/xref.txt +++ b/queen/xref.txt @@ -232,8 +232,8 @@ A_FILE_MAX Logic::_numAFile ACTOR_DATA_MAX Logic::_numActors AREA Logic::_area AREAMAX Logic::_areaMax -bamflag Graphics::_bam.flag -bamindex Graphics::_bam.index +bamflag BamScene::_flag +bamindex BamScene::_index DESCTOT Logic::_numDescriptions ENTRY_OBJ Logic::_entryObj FMAX Logic::_numFurnitureStatic @@ -343,7 +343,6 @@ oldsn Sound::_previousSongNum LASTSONG Sound::_previousSong CURRSONG Sound::_currentSong SFXNAME Sound::_sfxName -tmpbamflag VOLUME @@ -497,3 +496,4 @@ TEMPstr WORDstr JOE2str,PERSON2str // locals in Talk::initialTalk SUBJECT +tmpbamflag |