From 4cb6c739a4cf75a0e072197845a54620db0b10b8 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 27 Aug 2011 19:09:13 +0200 Subject: CGE: Change a couple of static members to non static in Vga class --- engines/cge/cge.cpp | 2 -- engines/cge/cge_main.cpp | 16 ++++++------- engines/cge/snail.cpp | 8 +++---- engines/cge/vga13h.cpp | 59 +++++++++++++++++------------------------------- engines/cge/vga13h.h | 6 ++--- 5 files changed, 35 insertions(+), 56 deletions(-) (limited to 'engines') diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index 0dbc1c8696..f471b63866 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -117,7 +117,6 @@ void CGEEngine::setup() { _console = new CGEConsole(this); // Initialise classes that have static members - Vga::init(); VFile::init(); Bitmap::init(); Talk::init(); @@ -178,7 +177,6 @@ CGEEngine::~CGEEngine() { Talk::deinit(); Bitmap::deinit(); VFile::deinit(); - Vga::deinit(); Cluster::init(this); // Remove all of our debug levels here diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 8ac07b9f11..a784b10c1d 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -545,7 +545,7 @@ void CGEEngine::showBak(int ref) { if (!spr) return; - Bitmap::_pal = Vga::_sysPal; + Bitmap::_pal = _vga->_sysPal; spr->expand(); Bitmap::_pal = NULL; spr->show(2); @@ -600,7 +600,7 @@ void CGEEngine::caveUp() { if (_shadow) { _vga->_showQ->remove(_shadow); - _shadow->makeXlat(glass(Vga::_sysPal, 204, 204, 204)); + _shadow->makeXlat(glass(_vga->_sysPal, 204, 204, 204)); _vga->_showQ->insert(_shadow, _hero); _shadow->_z = _hero->_z; } @@ -608,7 +608,7 @@ void CGEEngine::caveUp() { _vga->show(); _vga->copyPage(1, 0); _vga->show(); - _vga->sunrise(Vga::_sysPal); + _vga->sunrise(_vga->_sysPal); _dark = false; if (!_startupMode) _mouse->on(); @@ -689,7 +689,7 @@ System::System(CGEEngine *vm) : Sprite(vm, NULL), _vm(vm) { } void System::setPal() { - Dac *p = Vga::_sysPal + 256 - ArrayCount(_stdPal); + Dac *p = _vga->_sysPal + 256 - ArrayCount(_stdPal); for (uint i = 0; i < ArrayCount(_stdPal); i++) { p[i]._r = _stdPal[i]._r >> 2; p[i]._g = _stdPal[i]._g >> 2; @@ -813,7 +813,7 @@ void CGEEngine::switchColorMode() { _snail_->addCom(kSnSeq, 121, _vga->_mono = !_vga->_mono, NULL); keyClick(); - _vga->setColors(Vga::_sysPal, 64); + _vga->setColors(_vga->_sysPal, 64); } void CGEEngine::switchMusic() { @@ -1419,7 +1419,7 @@ bool CGEEngine::showTitle(const char *name) { if (_eventManager->_quitFlag) return false; - Bitmap::_pal = Vga::_sysPal; + Bitmap::_pal = _vga->_sysPal; BitmapPtr *LB = new BitmapPtr[2]; LB[0] = new Bitmap(name); LB[1] = NULL; @@ -1440,7 +1440,7 @@ bool CGEEngine::showTitle(const char *name) { _vga->copyPage(1, 2); _vga->copyPage(0, 1); selectPocket(-1); - _vga->sunrise(Vga::_sysPal); + _vga->sunrise(_vga->_sysPal); if (_mode < 2 && !_soundOk) { _vga->copyPage(1, 2); @@ -1481,7 +1481,7 @@ bool CGEEngine::showTitle(const char *name) { if (savegameExists(0)) { // Load the savegame loadGame(0, NULL, true); // only system vars - _vga->setColors(Vga::_sysPal, 64); + _vga->setColors(_vga->_sysPal, 64); _vga->update(); if (_flag[3]) { //flag FINIS _mode++; diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index 756c2675aa..7893b9d539 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -565,7 +565,7 @@ void CGEEngine::snSend(Sprite *spr, int val) { spr->_flags._slav = false; } else { if (spr->_ref % 1000 == 0) - Bitmap::_pal = Vga::_sysPal; + Bitmap::_pal = _vga->_sysPal; if (spr->_flags._back) spr->backShow(true); else @@ -856,7 +856,7 @@ void CGEEngine::snFlash(bool on) { if (on) { Dac *pal = (Dac *) malloc(sizeof(Dac) * kPalCount); if (pal) { - memcpy(pal, Vga::_sysPal, kPalSize); + memcpy(pal, _vga->_sysPal, kPalSize); for (int i = 0; i < kPalCount; i++) { register int c; c = pal[i]._r << 1; @@ -869,7 +869,7 @@ void CGEEngine::snFlash(bool on) { _vga->setColors(pal, 64); } } else - _vga->setColors(Vga::_sysPal, 64); + _vga->setColors(_vga->_sysPal, 64); _dark = false; } @@ -877,7 +877,7 @@ void CGEEngine::snLight(bool in) { debugC(1, kCGEDebugEngine, "CGEEngine::snLight(%s)", in ? "true" : "false"); if (in) - _vga->sunrise(Vga::_sysPal); + _vga->sunrise(_vga->_sysPal); else _vga->sunset(); _dark = !in; diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 317cb415f8..d510b98f45 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -448,7 +448,6 @@ void Sprite::center() { void Sprite::show() { SprExt *e; -// asm cli // critic section... e = _ext; e->_x0 = e->_x1; e->_y0 = e->_y1; @@ -456,7 +455,6 @@ void Sprite::show() { e->_x1 = _x; e->_y1 = _y; e->_b1 = shp(); -// asm sti // ...done! if (!_flags._hide) { if (_flags._xlat) e->_b1->xShow(e->_x1, e->_y1); @@ -466,10 +464,10 @@ void Sprite::show() { } void Sprite::show(uint16 pg) { - Graphics::Surface *a = Vga::_page[1]; - Vga::_page[1] = Vga::_page[pg & 3]; + Graphics::Surface *a = _vga->_page[1]; + _vga->_page[1] = _vga->_page[pg & 3]; shp()->show(_x, _y); - Vga::_page[1] = a; + _vga->_page[1] = a; } void Sprite::hide() { @@ -673,45 +671,24 @@ Sprite *Queue::locate(int ref) { return NULL; } -//extern const char Copr[]; -Graphics::Surface *Vga::_page[4]; -Dac *Vga::_sysPal; +Vga::Vga() : _frmCnt(0), _msg(NULL), _name(NULL), _setPal(false), _mono(0) { + _oldColors = NULL; + _newColors = NULL; + _showQ = new Queue(true); + _spareQ = new Queue(false); + _sysPal = new Dac[kPalCount]; -void Vga::init() { for (int idx = 0; idx < 4; idx++) { _page[idx] = new Graphics::Surface(); _page[idx]->create(320, 200, Graphics::PixelFormat::createFormatCLUT8()); } - _sysPal = new Dac[kPalCount]; -} - -void Vga::deinit() { - for (int idx = 0; idx < 4; idx++) { - _page[idx]->free(); - delete _page[idx]; - } - delete[] _sysPal; -} - -Vga::Vga() - : _frmCnt(0), _msg(NULL), _name(NULL), _setPal(false), _mono(0) { - _oldColors = NULL; - _newColors = NULL; - _showQ = new Queue(true); - _spareQ = new Queue(false); - - bool std = true; for (int i = 10; i < 20; i++) { char *text = _text->getText(i); if (text) { debugN(1, "%s\n", text); - std = false; } } - if (std) -// warning(Copr); - warning("TODO: Fix Copr"); _oldColors = (Dac *) malloc(sizeof(Dac) * kPalCount); _newColors = (Dac *) malloc(sizeof(Dac) * kPalCount); @@ -743,6 +720,12 @@ Vga::~Vga() { delete _showQ; delete _spareQ; + delete[] _sysPal; + + for (int idx = 0; idx < 4; idx++) { + _page[idx]->free(); + delete _page[idx]; + } } void Vga::waitVR() { @@ -862,14 +845,14 @@ void Bitmap::xShow(int16 x, int16 y) { debugC(4, kCGEDebugBitmap, "Bitmap::xShow(%d, %d)", x, y); const byte *srcP = (const byte *)_v; - byte *destEndP = (byte *)Vga::_page[1]->pixels + (kScrWidth * kScrHeight); + byte *destEndP = (byte *)_vga->_page[1]->pixels + (kScrWidth * kScrHeight); byte *lookupTable = _m; // Loop through processing data for each plane. The game originally ran in plane mapped mode, where a // given plane holds each fourth pixel sequentially. So to handle an entire picture, each plane's data // must be decompressed and inserted into the surface for (int planeCtr = 0; planeCtr < 4; planeCtr++) { - byte *destP = (byte *)Vga::_page[1]->getBasePtr(x + planeCtr, y); + byte *destP = (byte *)_vga->_page[1]->getBasePtr(x + planeCtr, y); for (;;) { uint16 v = READ_LE_UINT16(srcP); @@ -915,13 +898,13 @@ void Bitmap::show(int16 x, int16 y) { debugC(5, kCGEDebugBitmap, "Bitmap::show(%d, %d)", x, y); const byte *srcP = (const byte *)_v; - byte *destEndP = (byte *)Vga::_page[1]->pixels + (kScrWidth * kScrHeight); + byte *destEndP = (byte *)_vga->_page[1]->pixels + (kScrWidth * kScrHeight); // Loop through processing data for each plane. The game originally ran in plane mapped mode, where a // given plane holds each fourth pixel sequentially. So to handle an entire picture, each plane's data // must be decompressed and inserted into the surface for (int planeCtr = 0; planeCtr < 4; planeCtr++) { - byte *destP = (byte *)Vga::_page[1]->getBasePtr(x + planeCtr, y); + byte *destP = (byte *)_vga->_page[1]->getBasePtr(x + planeCtr, y); for (;;) { uint16 v = READ_LE_UINT16(srcP); @@ -979,8 +962,8 @@ void Bitmap::hide(int16 x, int16 y) { debugC(5, kCGEDebugBitmap, "Bitmap::hide(%d, %d)", x, y); for (int yp = y; yp < y + _h; yp++) { - const byte *srcP = (const byte *)Vga::_page[2]->getBasePtr(x, yp); - byte *destP = (byte *)Vga::_page[1]->getBasePtr(x, yp); + const byte *srcP = (const byte *)_vga->_page[2]->getBasePtr(x, yp); + byte *destP = (byte *)_vga->_page[1]->getBasePtr(x, yp); Common::copy(srcP, srcP + _w, destP); } diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h index 9649201021..e917e86a32 100644 --- a/engines/cge/vga13h.h +++ b/engines/cge/vga13h.h @@ -196,13 +196,11 @@ public: Queue *_showQ; Queue *_spareQ; int _mono; - static Graphics::Surface *_page[4]; - static Dac *_sysPal; + Graphics::Surface *_page[4]; + Dac *_sysPal; Vga(); ~Vga(); - static void init(); - static void deinit(); void getColors(Dac *tab); void setColors(Dac *tab, int lum); -- cgit v1.2.3