aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/cge/bitmap.cpp12
-rw-r--r--engines/cge/bitmap.h16
-rw-r--r--engines/cge/cge.h6
-rw-r--r--engines/cge/cge_main.cpp15
-rw-r--r--engines/cge/cge_main.h3
-rw-r--r--engines/cge/events.cpp4
-rw-r--r--engines/cge/talk.cpp4
-rw-r--r--engines/cge/text.cpp4
-rw-r--r--engines/cge/vga13h.cpp48
-rw-r--r--engines/cge/vga13h.h4
-rw-r--r--engines/cge/vmenu.cpp6
-rw-r--r--engines/cge/walk.cpp2
12 files changed, 64 insertions, 60 deletions
diff --git a/engines/cge/bitmap.cpp b/engines/cge/bitmap.cpp
index 5028cbeb1a..2acc65c4fa 100644
--- a/engines/cge/bitmap.cpp
+++ b/engines/cge/bitmap.cpp
@@ -43,7 +43,7 @@ void Bitmap::init() {
void Bitmap::deinit() {
}
-Bitmap::Bitmap(const char *fname) : _m(NULL), _v(NULL), _map(0) {
+Bitmap::Bitmap(CGEEngine *vm, const char *fname) : _m(NULL), _v(NULL), _map(0), _vm(vm) {
debugC(1, kCGEDebugBitmap, "Bitmap::Bitmap(%s)", fname);
char pat[kMaxPath];
@@ -60,7 +60,7 @@ Bitmap::Bitmap(const char *fname) : _m(NULL), _v(NULL), _map(0) {
}
}
-Bitmap::Bitmap(uint16 w, uint16 h, uint8 *map) : _w(w), _h(h), _m(map), _v(NULL), _map(0) {
+Bitmap::Bitmap(CGEEngine *vm, uint16 w, uint16 h, uint8 *map) : _w(w), _h(h), _m(map), _v(NULL), _map(0), _vm(vm) {
debugC(1, kCGEDebugBitmap, "Bitmap::Bitmap(%d, %d, map)", w, h);
if (map)
code();
@@ -69,11 +69,9 @@ Bitmap::Bitmap(uint16 w, uint16 h, uint8 *map) : _w(w), _h(h), _m(map), _v(NULL)
// following routine creates filled rectangle
// immediately as VGA video chunks, in near memory as fast as possible,
// especially for text line real time display
-Bitmap::Bitmap(uint16 w, uint16 h, uint8 fill)
+Bitmap::Bitmap(CGEEngine *vm, uint16 w, uint16 h, uint8 fill)
: _w((w + 3) & ~3), // only full uint32 allowed!
- _h(h),
- _m(NULL),
- _map(0) {
+ _h(h), _m(NULL), _map(0), _vm(vm) {
debugC(1, kCGEDebugBitmap, "Bitmap::Bitmap(%d, %d, %d)", w, h, fill);
uint16 dsiz = _w >> 2; // data size (1 plane line size)
@@ -111,7 +109,7 @@ Bitmap::Bitmap(uint16 w, uint16 h, uint8 fill)
_b = b;
}
-Bitmap::Bitmap(const Bitmap &bmp) : _w(bmp._w), _h(bmp._h), _m(NULL), _v(NULL), _map(0) {
+Bitmap::Bitmap(CGEEngine *vm, const Bitmap &bmp) : _w(bmp._w), _h(bmp._h), _m(NULL), _v(NULL), _map(0), _vm(vm) {
debugC(1, kCGEDebugBitmap, "Bitmap::Bitmap(bmp)");
uint8 *v0 = bmp._v;
if (!v0)
diff --git a/engines/cge/bitmap.h b/engines/cge/bitmap.h
index 3e195fad14..bb935e7049 100644
--- a/engines/cge/bitmap.h
+++ b/engines/cge/bitmap.h
@@ -28,11 +28,14 @@
#ifndef CGE_BITMAP_H
#define CGE_BITMAP_H
-#include "cge/fileio.h"
-//#include "cge/general.h"
+#include "cge/general.h"
+#include "common/file.h"
namespace CGE {
+class CGEEngine;
+class EncryptedStream;
+
#define kMaxPath 128
enum {
kBmpEOI = 0x0000,
@@ -51,6 +54,7 @@ struct HideDesc {
#include "common/pack-end.h"
class Bitmap {
+ CGEEngine *_vm;
char *forceExt(char *buf, const char *name, const char *ext);
bool loadVBM(EncryptedStream *f);
public:
@@ -62,10 +66,10 @@ public:
int32 _map;
HideDesc *_b;
- Bitmap(const char *fname);
- Bitmap(uint16 w, uint16 h, uint8 *map);
- Bitmap(uint16 w, uint16 h, uint8 fill);
- Bitmap(const Bitmap &bmp);
+ Bitmap(CGEEngine *vm, const char *fname);
+ Bitmap(CGEEngine *vm, uint16 w, uint16 h, uint8 *map);
+ Bitmap(CGEEngine *vm, uint16 w, uint16 h, uint8 fill);
+ Bitmap(CGEEngine *vm, const Bitmap &bmp);
~Bitmap();
static void init();
diff --git a/engines/cge/cge.h b/engines/cge/cge.h
index af526742b3..ace5d66a22 100644
--- a/engines/cge/cge.h
+++ b/engines/cge/cge.h
@@ -41,6 +41,7 @@ namespace CGE {
class Console;
class Sprite;
class Cluster;
+class Vga;
#define kSavegameVersion 2
#define kSavegameStrSize 11
@@ -112,8 +113,8 @@ private:
uint32 _lastFrame, _lastTick;
void tick();
void syncHeader(Common::Serializer &s);
- static void writeSavegameHeader(Common::OutSaveFile *out, SavegameHeader &header);
- void syncGame(Common::SeekableReadStream *readStream, Common::WriteStream *writeStream, bool tiny = false);
+ void writeSavegameHeader(Common::OutSaveFile *out, SavegameHeader &header);
+ void syncGame(Common::SeekableReadStream *readStream, Common::WriteStream *writeStream, bool tiny);
bool savegameExists(int slotNumber);
Common::String generateSaveName(int slot);
public:
@@ -155,6 +156,7 @@ public:
Common::Point _heroXY[kSceneMax];
Bar _barriers[kSceneMax + 1];
Font *_font;
+ Vga *_vga;
Common::RandomSource _randomSource;
MusicPlayer _midiPlayer;
diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp
index 7d9acb462c..2311aa527b 100644
--- a/engines/cge/cge_main.cpp
+++ b/engines/cge/cge_main.cpp
@@ -34,17 +34,17 @@
#include "graphics/palette.h"
#include "graphics/scaler.h"
#include "graphics/thumbnail.h"
+#include "cge/vga13h.h"
+#include "cge/cge.h"
+#include "cge/cge_main.h"
#include "cge/general.h"
#include "cge/sound.h"
-#include "cge/vga13h.h"
#include "cge/snail.h"
#include "cge/text.h"
#include "cge/game.h"
#include "cge/events.h"
#include "cge/talk.h"
#include "cge/vmenu.h"
-#include "cge/cge_main.h"
-#include "cge/cge.h"
#include "cge/walk.h"
#include "cge/sound.h"
@@ -52,7 +52,6 @@ namespace CGE {
uint16 _stklen = (kStackSize * 2);
-Vga *_vga;
System *_sys;
Sprite *_pocLight;
EventManager *_eventManager;
@@ -532,7 +531,7 @@ Square::Square(CGEEngine *vm) : Sprite(vm, NULL), _vm(vm) {
_flags._bDel = false;
BitmapPtr *MB = new BitmapPtr[2];
- MB[0] = new Bitmap("BRICK");
+ MB[0] = new Bitmap(_vm, "BRICK");
MB[1] = NULL;
setShapeList(MB);
}
@@ -759,7 +758,7 @@ System::System(CGEEngine *vm) : Sprite(vm, NULL), _vm(vm) {
}
void System::setPal() {
- Dac *p = _vga->_sysPal + 256 - ARRAYSIZE(g_stdPal);
+ Dac *p = _vm->_vga->_sysPal + 256 - ARRAYSIZE(g_stdPal);
for (uint i = 0; i < ARRAYSIZE(g_stdPal); i++) {
p[i]._r = g_stdPal[i]._r >> 2;
p[i]._g = g_stdPal[i]._g >> 2;
@@ -1372,7 +1371,7 @@ void CGEEngine::runGame() {
if (_miniScene) {
_miniScene->_flags._kill = false;
_miniScene->_flags._hide = true;
- _miniShp[0] = new Bitmap(*_miniScene->shp());
+ _miniShp[0] = new Bitmap(this, *_miniScene->shp());
_miniShpList = _miniScene->setShapeList(_miniShp);
postMiniStep(-1);
}
@@ -1473,7 +1472,7 @@ bool CGEEngine::showTitle(const char *name) {
Bitmap::_pal = _vga->_sysPal;
BitmapPtr *LB = new BitmapPtr[2];
- LB[0] = new Bitmap(name);
+ LB[0] = new Bitmap(this, name);
LB[1] = NULL;
Bitmap::_pal = NULL;
diff --git a/engines/cge/cge_main.h b/engines/cge/cge_main.h
index a71a72e5a7..ba9d9a6cc9 100644
--- a/engines/cge/cge_main.h
+++ b/engines/cge/cge_main.h
@@ -28,9 +28,7 @@
#ifndef CGE_CGEMAIN_H
#define CGE_CGEMAIN_H
-#include "cge/vga13h.h"
#include "cge/events.h"
-#include "cge/sound.h"
namespace CGE {
@@ -111,7 +109,6 @@ private:
CGEEngine *_vm;
};
-extern Vga *_vga;
extern System *_sys;
extern Sprite *_pocLight;
extern Keyboard *_keyboard;
diff --git a/engines/cge/events.cpp b/engines/cge/events.cpp
index 59e0d5f87a..2f0a5ab170 100644
--- a/engines/cge/events.cpp
+++ b/engines/cge/events.cpp
@@ -200,8 +200,8 @@ Mouse::Mouse(CGEEngine *vm) : Sprite(vm, NULL), _busy(NULL), _hold(NULL), _hx(0)
setSeq(seq);
BitmapPtr *MC = new BitmapPtr[3];
- MC[0] = new Bitmap("MOUSE");
- MC[1] = new Bitmap("DUMMY");
+ MC[0] = new Bitmap(_vm, "MOUSE");
+ MC[1] = new Bitmap(_vm, "DUMMY");
MC[2] = NULL;
setShapeList(MC);
diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp
index 6cbeb6d940..a842e611ac 100644
--- a/engines/cge/talk.cpp
+++ b/engines/cge/talk.cpp
@@ -179,7 +179,7 @@ Bitmap *Talk::box(uint16 w, uint16 h) {
q -= w;
}
}
- return new Bitmap(w, h, b);
+ return new Bitmap(_vm, w, h, b);
}
void Talk::putLine(int line, const char *text) {
@@ -237,7 +237,7 @@ InfoLine::InfoLine(CGEEngine *vm, uint16 w) : Talk(vm), _oldText(NULL), _vm(vm)
_ts[1] = NULL;
}
- _ts[0] = new Bitmap(w, kFontHigh, kTextColBG);
+ _ts[0] = new Bitmap(_vm, w, kFontHigh, kTextColBG);
setShapeList(_ts);
}
diff --git a/engines/cge/text.cpp b/engines/cge/text.cpp
index c28e3ba70a..7eefc816c4 100644
--- a/engines/cge/text.cpp
+++ b/engines/cge/text.cpp
@@ -174,8 +174,8 @@ void Text::say(const char *text, Sprite *spr) {
spike->step(east);
spike->_ref = kSayRef;
- _vga->_showQ->insert(_talk, _vga->_showQ->last());
- _vga->_showQ->insert(spike, _vga->_showQ->last());
+ _vm->_vga->_showQ->insert(_talk, _vm->_vga->_showQ->last());
+ _vm->_vga->_showQ->insert(spike, _vm->_vga->_showQ->last());
}
void CGEEngine::inf(const char *text) {
diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp
index 3d092e755c..84c2329b79 100644
--- a/engines/cge/vga13h.cpp
+++ b/engines/cge/vga13h.cpp
@@ -239,7 +239,7 @@ Sprite *Sprite::expand() {
shplist.push_back(NULL);
++_shpCnt;
}
- shplist[shapeCount++] = new Bitmap(strtok(NULL, " \t,;/"));
+ shplist[shapeCount++] = new Bitmap(_vm, strtok(NULL, " \t,;/"));
break;
case 2:
// Seq
@@ -295,7 +295,7 @@ Sprite *Sprite::expand() {
}
} else {
// no sprite description: try to read immediately from .BMP
- shplist[shapeCount++] = new Bitmap(_file);
+ shplist[shapeCount++] = new Bitmap(_vm, _file);
}
shplist[shapeCount] = NULL;
@@ -447,10 +447,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 = _vm->_vga->_page[1];
+ _vm->_vga->_page[1] = _vm->_vga->_page[pg & 3];
shp()->show(_x, _y);
- _vga->_page[1] = a;
+ _vm->_vga->_page[1] = a;
}
void Sprite::hide() {
@@ -464,7 +464,7 @@ BitmapPtr Sprite::ghost() {
if (!e->_b1)
return NULL;
- BitmapPtr bmp = new Bitmap(0, 0, (uint8 *)NULL);
+ BitmapPtr bmp = new Bitmap(_vm, 0, 0, (uint8 *)NULL);
assert(bmp != NULL);
bmp->_w = e->_b1->_w;
bmp->_h = e->_b1->_h;
@@ -858,14 +858,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 *)_vm->_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 *)_vm->_vga->_page[1]->getBasePtr(x + planeCtr, y);
for (;;) {
uint16 v = READ_LE_UINT16(srcP);
@@ -911,13 +911,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 *)_vm->_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 *)_vm->_vga->_page[1]->getBasePtr(x + planeCtr, y);
for (;;) {
uint16 v = READ_LE_UINT16(srcP);
@@ -964,8 +964,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 *)_vm->_vga->_page[2]->getBasePtr(x, yp);
+ byte *destP = (byte *)_vm->_vga->_page[1]->getBasePtr(x, yp);
Common::copy(srcP, srcP + _w, destP);
}
@@ -973,41 +973,41 @@ void Bitmap::hide(int16 x, int16 y) {
/*--------------------------------------------------------------------------*/
-HorizLine::HorizLine(CGEEngine *vm): Sprite(vm, NULL) {
+HorizLine::HorizLine(CGEEngine *vm) : Sprite(vm, NULL), _vm(vm) {
// Set the sprite list
BitmapPtr *HL = new BitmapPtr[2];
- HL[0] = new Bitmap("HLINE");
+ HL[0] = new Bitmap(_vm, "HLINE");
HL[1] = NULL;
setShapeList(HL);
}
-SceneLight::SceneLight(CGEEngine *vm): Sprite(vm, NULL) {
+SceneLight::SceneLight(CGEEngine *vm) : Sprite(vm, NULL), _vm(vm) {
// Set the sprite list
BitmapPtr *PR = new BitmapPtr[2];
- PR[0] = new Bitmap("PRESS");
+ PR[0] = new Bitmap(_vm, "PRESS");
PR[1] = NULL;
setShapeList(PR);
}
-Spike::Spike(CGEEngine *vm): Sprite(vm, NULL) {
+Spike::Spike(CGEEngine *vm): Sprite(vm, NULL), _vm(vm) {
// Set the sprite list
BitmapPtr *SP = new BitmapPtr[3];
- SP[0] = new Bitmap("SPK_L");
- SP[1] = new Bitmap("SPK_R");
+ SP[0] = new Bitmap(_vm, "SPK_L");
+ SP[1] = new Bitmap(_vm, "SPK_R");
SP[2] = NULL;
setShapeList(SP);
}
-PocLight::PocLight(CGEEngine *vm): Sprite(vm, NULL) {
+PocLight::PocLight(CGEEngine *vm): Sprite(vm, NULL), _vm(vm) {
// Set the sprite list
BitmapPtr *LI = new BitmapPtr[5];
- LI[0] = new Bitmap("LITE0");
- LI[1] = new Bitmap("LITE1");
- LI[2] = new Bitmap("LITE2");
- LI[3] = new Bitmap("LITE3");
+ LI[0] = new Bitmap(_vm, "LITE0");
+ LI[1] = new Bitmap(_vm, "LITE1");
+ LI[2] = new Bitmap(_vm, "LITE2");
+ LI[3] = new Bitmap(_vm, "LITE3");
LI[4] = NULL;
setShapeList(LI);
diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h
index 04c786777d..88353f4d48 100644
--- a/engines/cge/vga13h.h
+++ b/engines/cge/vga13h.h
@@ -216,21 +216,25 @@ public:
};
class HorizLine: public Sprite {
+ CGEEngine *_vm;
public:
HorizLine(CGEEngine *vm);
};
class SceneLight: public Sprite {
+ CGEEngine *_vm;
public:
SceneLight(CGEEngine *vm);
};
class Spike: public Sprite {
+ CGEEngine *_vm;
public:
Spike(CGEEngine *vm);
};
class PocLight: public Sprite {
+ CGEEngine *_vm;
public:
PocLight(CGEEngine *vm);
};
diff --git a/engines/cge/vmenu.cpp b/engines/cge/vmenu.cpp
index c213b997a3..25510a62a2 100644
--- a/engines/cge/vmenu.cpp
+++ b/engines/cge/vmenu.cpp
@@ -49,7 +49,7 @@ MenuBar::MenuBar(CGEEngine *vm, uint16 w) : Talk(vm), _vm(vm) {
}
_ts = new BitmapPtr[2];
- _ts[0] = new Bitmap(w, h, p);
+ _ts[0] = new Bitmap(_vm, w, h, p);
_ts[1] = NULL;
setShapeList(_ts);
@@ -77,10 +77,10 @@ Vmenu::Vmenu(CGEEngine *vm, Choice *list, int x, int y)
center();
else
gotoxy(x - _w / 2, y - (kTextVMargin + kFontHigh / 2));
- _vga->_showQ->insert(this, _vga->_showQ->last());
+ _vm->_vga->_showQ->insert(this, _vm->_vga->_showQ->last());
_bar = new MenuBar(_vm, _w - 2 * kTextHMargin);
_bar->gotoxy(_x + kTextHMargin - kMenuBarHM, _y + kTextVMargin - kMenuBarVM);
- _vga->_showQ->insert(_bar, _vga->_showQ->last());
+ _vm->_vga->_showQ->insert(_bar, _vm->_vga->_showQ->last());
}
Vmenu::~Vmenu() {
diff --git a/engines/cge/walk.cpp b/engines/cge/walk.cpp
index 4de8bc779d..e8247090be 100644
--- a/engines/cge/walk.cpp
+++ b/engines/cge/walk.cpp
@@ -59,7 +59,7 @@ void Walk::tick() {
if (_dir != kDirNone) {
_sys->funTouch();
- for (Sprite *spr = _vga->_showQ->first(); spr; spr = spr->_next) {
+ for (Sprite *spr = _vm->_vga->_showQ->first(); spr; spr = spr->_next) {
if (distance(spr) < 2) {
if (!spr->_flags._near) {
_vm->feedSnail(spr, kNear);