diff options
-rw-r--r-- | engines/avalanche/avalanche.cpp | 39 | ||||
-rw-r--r-- | engines/avalanche/avalanche.h | 6 | ||||
-rw-r--r-- | engines/avalanche/avalot.cpp | 4 | ||||
-rw-r--r-- | engines/avalanche/dropdown2.cpp | 6 | ||||
-rw-r--r-- | engines/avalanche/graphics.cpp | 2 | ||||
-rw-r--r-- | engines/avalanche/graphics.h | 2 | ||||
-rw-r--r-- | engines/avalanche/lucerna2.cpp | 20 | ||||
-rw-r--r-- | engines/avalanche/scrolls2.cpp | 2 | ||||
-rw-r--r-- | engines/avalanche/trip6.cpp | 2 |
9 files changed, 47 insertions, 36 deletions
diff --git a/engines/avalanche/avalanche.cpp b/engines/avalanche/avalanche.cpp index aa9fe9f627..4b51c8babd 100644 --- a/engines/avalanche/avalanche.cpp +++ b/engines/avalanche/avalanche.cpp @@ -45,12 +45,22 @@ AvalancheEngine *AvalancheEngine::s_Engine = 0; AvalancheEngine::AvalancheEngine(OSystem *syst, const AvalancheGameDescription *gd) : Engine(syst), _gameDescription(gd) { _system = syst; + s_Engine = this; _console = new AvalancheConsole(this); _rnd = new Common::RandomSource("avalanche"); _rnd->setSeed(42); +} + +AvalancheEngine::~AvalancheEngine() { + delete _console; + delete _rnd; + + delete _graphics; +} - _graph.setParent(this); +Common::ErrorCode AvalancheEngine::initialize() { + _graphics = new Graphics(this); _gyro.setParent(this); _enhanced.setParent(this); @@ -69,13 +79,19 @@ AvalancheEngine::AvalancheEngine(OSystem *syst, const AvalancheGameDescription * _dropdown.setParent(this); _closing.setParent(this); _avalot.setParent(this); -} -AvalancheEngine::~AvalancheEngine() { - delete _console; - delete _rnd; + _graphics->init(); + + _scrolls.init(); + _lucerna.init(); + _acci.init(); + _basher.init(); + + + return Common::kNoError; } + GUI::Debugger *AvalancheEngine::getDebugger() { return _console; } @@ -252,17 +268,10 @@ void AvalancheEngine::run_avalot() { Common::Error AvalancheEngine::run() { - s_Engine = this; + Common::ErrorCode err = initialize(); + if (err != Common::kNoError) + return err; - _console = new AvalancheConsole(this); - - _scrolls.init(); - _lucerna.init(); - _acci.init(); - _basher.init(); - _graph.init(); - - // From bootstrp: diff --git a/engines/avalanche/avalanche.h b/engines/avalanche/avalanche.h index 122959ee27..676f3f909a 100644 --- a/engines/avalanche/avalanche.h +++ b/engines/avalanche/avalanche.h @@ -65,7 +65,7 @@ static const int kSavegameVersion = 1; class AvalancheEngine : public Engine { public: - Graphics _graph; + Graphics *_graphics; Avalot _avalot; Gyro _gyro; @@ -86,11 +86,13 @@ public: Closing _closing; + OSystem *_system; + AvalancheEngine(OSystem *syst, const AvalancheGameDescription *gd); ~AvalancheEngine(); - OSystem *_system; + Common::ErrorCode initialize(); GUI::Debugger *getDebugger(); diff --git a/engines/avalanche/avalot.cpp b/engines/avalanche/avalot.cpp index 2f62dc1712..9e64ae4ab4 100644 --- a/engines/avalanche/avalot.cpp +++ b/engines/avalanche/avalot.cpp @@ -99,7 +99,7 @@ void Avalot::setup() { _vm->_gyro.enid_filename = ""; /* undefined. */ _vm->_lucerna.toolbar(); _vm->_scrolls.state(2); - _vm->_graph.refreshScreen(); //_vm->_pingo.copy03(); Replace it with refreshScreen() since they 'almost' have the same functionality. + _vm->_graphics->refreshScreen(); //_vm->_pingo.copy03(); Replace it with refreshScreen() since they 'almost' have the same functionality. for (byte i = 0; i < 3; i++) _vm->_gyro.lastscore[i] = -1; /* impossible digits */ @@ -206,7 +206,7 @@ void Avalot::run(Common::String arg) { _vm->updateEvents(); // The event handler. - _vm->_graph.refreshScreen(); // TODO: Maybe it'll have a better place later. Move it there when it's needed. + _vm->_graphics->refreshScreen(); // TODO: Maybe it'll have a better place later. Move it there when it's needed. } while (! _vm->_gyro.lmo); diff --git a/engines/avalanche/dropdown2.cpp b/engines/avalanche/dropdown2.cpp index 8828cb6c99..219df15fc2 100644 --- a/engines/avalanche/dropdown2.cpp +++ b/engines/avalanche/dropdown2.cpp @@ -197,7 +197,7 @@ void menuset::update() { /*setactivepage(3); setfillstyle(1, _dr->menu_b); bar(0, 0, 640, 9);*/ - _dr->_vm->_graph.drawBar(0, 0, 640, 10, _dr->menu_b); + _dr->_vm->_graphics->drawBar(0, 0, 640, 10, _dr->menu_b); savecp = _dr->_vm->_gyro.cp; _dr->_vm->_gyro.cp = 3; @@ -290,7 +290,7 @@ void Dropdown::chalk(int16 x, int16 y, char t, Common::String z, bool valid) { byte pixel = ~(_vm->_gyro.little[z[fv]][ff] & ander); // Note that it's the bitwise NOT operator! for (byte bit = 0; bit < 8; bit++) { byte pixelBit = (pixel >> bit) & 1; - *_vm->_graph.getPixel(x * 8 + fv * 8 + 7 - bit, y + ff) = pixelBit + (pixelBit << 1) + (pixelBit << 2); + *_vm->_graphics->getPixel(x * 8 + fv * 8 + 7 - bit, y + ff) = pixelBit + (pixelBit << 1) + (pixelBit << 2); // We don't have to bother with the planes, since they all have the same value. See the original. // Note that it's the bitwise OR operator! } @@ -306,7 +306,7 @@ void Dropdown::chalk(int16 x, int16 y, char t, Common::String z, bool valid) { byte pixel = ~ ander; for (byte bit = 0; bit < 8; bit++) { byte pixelBit = (pixel >> bit) & 1; - *_vm->_graph.getPixel(x * 8 + fv * 8 + 7 - bit, y + 8) = pixelBit | (pixelBit << 1) | (pixelBit << 2); + *_vm->_graphics->getPixel(x * 8 + fv * 8 + 7 - bit, y + 8) = pixelBit | (pixelBit << 1) | (pixelBit << 2); } } diff --git a/engines/avalanche/graphics.cpp b/engines/avalanche/graphics.cpp index aefaa49054..8035491bfb 100644 --- a/engines/avalanche/graphics.cpp +++ b/engines/avalanche/graphics.cpp @@ -43,7 +43,7 @@ const byte Graphics::_egaPaletteIndex[16] = {0, 1, 2, 3, 4, 5, 20, 7, 56, 57, 58 -void Graphics::setParent(AvalancheEngine *vm) { +Graphics::Graphics(AvalancheEngine *vm) { _vm = vm; } diff --git a/engines/avalanche/graphics.h b/engines/avalanche/graphics.h index 333cbddfca..1a580029d0 100644 --- a/engines/avalanche/graphics.h +++ b/engines/avalanche/graphics.h @@ -61,7 +61,7 @@ public: - void setParent(AvalancheEngine *vm); + Graphics(AvalancheEngine *vm); void init(); diff --git a/engines/avalanche/lucerna2.cpp b/engines/avalanche/lucerna2.cpp index 3b30451bed..aefa6bff97 100644 --- a/engines/avalanche/lucerna2.cpp +++ b/engines/avalanche/lucerna2.cpp @@ -217,7 +217,7 @@ void Lucerna::load(byte n) { /* Load2, actually */ _vm->_gyro.clear_vmc(); - _vm->_graph.flesh_colours(); + _vm->_graphics->flesh_colours(); xx = _vm->_gyro.strf(n); Common::String filename; @@ -245,8 +245,8 @@ void Lucerna::load(byte n) { /* Load2, actually */ ::Graphics::Surface background; - uint16 backgroundWidht = _vm->_graph.kScreenWidth; - byte backgroundHeight = 8 * 12080 / _vm->_graph.kScreenWidth; // With 640 width it's 151 + uint16 backgroundWidht = _vm->_graphics->kScreenWidth; + byte backgroundHeight = 8 * 12080 / _vm->_graphics->kScreenWidth; // With 640 width it's 151 // The 8 = number of bits in a byte, and 12080 comes from the original code (see above) background.create(backgroundWidht, backgroundHeight, ::Graphics::PixelFormat::createFormatCLUT8()); @@ -263,7 +263,7 @@ void Lucerna::load(byte n) { /* Load2, actually */ for (uint16 y = 0; y < backgroundHeight; y++) for (uint16 x = 0; x < backgroundWidht; x++) - *_vm->_graph.getPixel(x + 0, y + 10) = *(byte *)background.getBasePtr(x, y); + *_vm->_graphics->getPixel(x + 0, y + 10) = *(byte *)background.getBasePtr(x, y); background.free(); @@ -274,9 +274,9 @@ void Lucerna::load(byte n) { /* Load2, actually */ load_also(xx); _vm->_celer.load_chunks(xx); - _vm->_graph.refreshScreen(); // _vm->_pingo.copy03(); - See Avalot::setup() + _vm->_graphics->refreshScreen(); // _vm->_pingo.copy03(); - See Avalot::setup() - bit = *_vm->_graph.getPixel(0,0); + bit = *_vm->_graphics->getPixel(0,0); _vm->_logger.log_newroom(_vm->_gyro.roomname); @@ -766,7 +766,7 @@ void Lucerna::thinkabout(byte z, bool th) { /* Hey!!! Get it and put it!!! * f.read(buffer, picsize); - _vm->_graph.drawPicture(buffer, 205, 170); + _vm->_graphics->drawPicture(buffer, 205, 170); delete[] buffer; @@ -823,7 +823,7 @@ void Lucerna::toolbar() { f.read(buffer, bufferSize); - _vm->_graph.drawPicture(buffer, 5, 169); + _vm->_graphics->drawPicture(buffer, 5, 169); delete[] buffer; @@ -859,7 +859,7 @@ void Lucerna::showscore() { for (byte fv = 0; fv < 3; fv ++) if (_vm->_gyro.lastscore[fv] != numbers[fv]) - _vm->_graph.drawPicture(_vm->_gyro.digit[numbers[fv]], 250 + (fv + 1) * 15, 177); + _vm->_graphics->drawPicture(_vm->_gyro.digit[numbers[fv]], 250 + (fv + 1) * 15, 177); for (byte fv = 0; fv < 2; fv ++) _vm->_trip.getset[fv].remember(scorespace); @@ -1052,7 +1052,7 @@ void Lucerna::showrw() { // It's data is loaded in load_digits(). putimage(0, 161, rwlite[with.rw], 0); }*/ - _vm->_graph.drawPicture(_vm->_gyro.rwlite[_vm->_gyro.dna.rw], 0, 161); + _vm->_graphics->drawPicture(_vm->_gyro.rwlite[_vm->_gyro.dna.rw], 0, 161); _vm->_gyro.on(); //setactivepage(1 - cp); diff --git a/engines/avalanche/scrolls2.cpp b/engines/avalanche/scrolls2.cpp index e2288b2c01..35ae4fc401 100644 --- a/engines/avalanche/scrolls2.cpp +++ b/engines/avalanche/scrolls2.cpp @@ -92,7 +92,7 @@ void Scrolls::state(byte x) { /* Sets "Ready" light to whatever */ _vm->_gyro.super_off(); - _vm->_graph.drawBar(419, 195, 438, 197, color); + _vm->_graphics->drawBar(419, 195, 438, 197, color); _vm->_gyro.super_on(); _vm->_gyro.ledstatus = x; diff --git a/engines/avalanche/trip6.cpp b/engines/avalanche/trip6.cpp index 0f648cf400..f9e8faa1e2 100644 --- a/engines/avalanche/trip6.cpp +++ b/engines/avalanche/trip6.cpp @@ -153,7 +153,7 @@ void triptype::andexor() { return; byte picnum = face * a.seq + step; // There'll maybe problem because of the different array indexes in Pascal (starting from 1). - _tr->_vm->_graph.drawSprite(_info, picnum, x, y); + _tr->_vm->_graphics->drawSprite(_info, picnum, x, y); } void triptype::turn(byte whichway) { |