Skip to content

Commit

Permalink
CGE2: Remove _m and xShow() from Bitmap, makeXlat() and killXlat() fr…
Browse files Browse the repository at this point in the history
…om Sprite.

They are not used in CGE2 at all (or used differently).
  • Loading branch information
uruk committed Jun 4, 2014
1 parent 7838852 commit 85d9e92
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 93 deletions.
21 changes: 9 additions & 12 deletions engines/cge2/bitmap.cpp
Expand Up @@ -35,14 +35,14 @@

namespace CGE2 {

Bitmap::Bitmap() : _w(0), _h(0), _v(nullptr), _b(nullptr), _m(nullptr), _map(0), _vm(nullptr) {
Bitmap::Bitmap() : _w(0), _h(0), _v(nullptr), _b(nullptr), _map(0), _vm(nullptr) {
}

void Bitmap::setVM(CGE2Engine *vm) {
_vm = vm;
}

Bitmap::Bitmap(CGE2Engine *vm, const char *fname) : _m(nullptr), _v(nullptr), _b(nullptr), _map(0), _vm(vm) {
Bitmap::Bitmap(CGE2Engine *vm, const char *fname) : _v(nullptr), _b(nullptr), _map(0), _vm(vm) {
char pat[kMaxPath];
forceExt(pat, fname, ".VBM");

Expand All @@ -57,17 +57,17 @@ Bitmap::Bitmap(CGE2Engine *vm, const char *fname) : _m(nullptr), _v(nullptr), _b
}
}

Bitmap::Bitmap(CGE2Engine *vm, uint16 w, uint16 h, uint8 *map) : _w(w), _h(h), _m(map), _v(nullptr), _map(0), _b(nullptr), _vm(vm) {
Bitmap::Bitmap(CGE2Engine *vm, uint16 w, uint16 h, uint8 *map) : _w(w), _h(h), _v(nullptr), _map(0), _b(nullptr), _vm(vm) {
if (map)
code();
code(map);
}

// 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(CGE2Engine *vm, uint16 w, uint16 h, uint8 fill)
: _w((w + 3) & ~3), // only full uint32 allowed!
_h(h), _m(nullptr), _map(0), _b(nullptr), _vm(vm) {
_h(h), _map(0), _b(nullptr), _vm(vm) {

uint16 dsiz = _w >> 2; // data size (1 plane line size)
uint16 lsiz = 2 + dsiz + 2; // uint16 for line header, uint16 for gap
Expand Down Expand Up @@ -104,7 +104,7 @@ Bitmap::Bitmap(CGE2Engine *vm, uint16 w, uint16 h, uint8 fill)
_b = b;
}

Bitmap::Bitmap(CGE2Engine *vm, const Bitmap &bmp) : _w(bmp._w), _h(bmp._h), _m(nullptr), _v(nullptr), _map(0), _b(nullptr), _vm(vm) {
Bitmap::Bitmap(CGE2Engine *vm, const Bitmap &bmp) : _w(bmp._w), _h(bmp._h), _v(nullptr), _map(0), _b(nullptr), _vm(vm) {
uint8 *v0 = bmp._v;
if (!v0)
return;
Expand All @@ -122,9 +122,7 @@ Bitmap::~Bitmap() {
}

void Bitmap::release() {
free(_m);
delete[] _v;
_m = nullptr;
_v = nullptr;
}

Expand All @@ -135,7 +133,6 @@ Bitmap &Bitmap::operator=(const Bitmap &bmp) {
uint8 *v0 = bmp._v;
_w = bmp._w;
_h = bmp._h;
_m = nullptr;
_map = 0;
_vm = bmp._vm;
delete[] _v;
Expand Down Expand Up @@ -164,8 +161,8 @@ char *Bitmap::forceExt(char *buf, const char *name, const char *ext) {
return buf;
}

BitmapPtr Bitmap::code() {
if (!_m)
BitmapPtr Bitmap::code(uint8 *map) {
if (!map)
return NULL;

uint16 cnt;
Expand All @@ -187,7 +184,7 @@ BitmapPtr Bitmap::code() {
}
}
for (bpl = 0; bpl < 4; bpl++) { // once per each bitplane
uint8 *bm = _m;
uint8 *bm = map;
bool skip = (bm[bpl] == kPixelTransp);
uint16 j;

Expand Down
4 changes: 1 addition & 3 deletions engines/cge2/bitmap.h
Expand Up @@ -61,7 +61,6 @@ class Bitmap {
public:
uint16 _w;
uint16 _h;
uint8 *_m;
uint8 *_v;
int32 _map;
HideDesc *_b;
Expand All @@ -74,12 +73,11 @@ class Bitmap {
~Bitmap();

void setVM(CGE2Engine *vm);
Bitmap *code();
Bitmap *code(uint8 *map);
Bitmap &operator=(const Bitmap &bmp);
void release();
void hide(int16 x, int16 y);
void show(int16 x, int16 y);
void xShow(int16 x, int16 y);
bool solidAt(int16 x, int16 y);
void xLatPos(V2D& p);
bool moveHi();
Expand Down
76 changes: 0 additions & 76 deletions engines/cge2/vga13h.cpp
Expand Up @@ -468,29 +468,6 @@ void Sprite::tick() {
step();
}

void Sprite::makeXlat(uint8 *x) {
if (!_ext)
return;

if (_flags._xlat)
killXlat();
for (BitmapPtr *b = _ext->_shpList; *b; b++)
(*b)->_m = x;
_flags._xlat = true;
}

void Sprite::killXlat() {
if (!_flags._xlat || !_ext)
return;

uint8 *m = (*_ext->_shpList)->_m;
free(m);

for (BitmapPtr *b = _ext->_shpList; *b; b++)
(*b)->_m = nullptr;
_flags._xlat = false;
}

void Sprite::gotoxyz(int x, int y, int z) {
gotoxyz(V3D(x, y, z));
}
Expand Down Expand Up @@ -1020,59 +997,6 @@ void Vga::copyPage(uint16 d, uint16 s) {
_page[d]->copyFrom(*_page[s]);
}

//--------------------------------------------------------------------------

void Bitmap::xShow(int16 x, int16 y) {
const byte *srcP = (const byte *)_v;
byte *destEndP = (byte *)_vm->_vga->_page[1]->getBasePtr(0, 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 *)_vm->_vga->_page[1]->getBasePtr(x + planeCtr, y);

for (;;) {
uint16 v = READ_LE_UINT16(srcP);
srcP += 2;
int cmd = v >> 14;
int count = v & 0x3FFF;

if (cmd == 0) {
// End of image
break;
}

assert(destP < destEndP);

if (cmd == 2)
srcP++;
else if (cmd == 3)
srcP += count;

// Handle a set of pixels
while (count-- > 0) {
// Transfer operation
switch (cmd) {
case 1:
// SKIP
break;
case 2:
case 3:
// TINT
*destP = lookupTable[*destP];
break;
}

// Move to next dest position
destP += 4;
}
}
}
}


void Bitmap::show(int16 x, int16 y) {
V2D pos(_vm, x, y);
xLatPos(pos);
Expand Down
2 changes: 0 additions & 2 deletions engines/cge2/vga13h.h
Expand Up @@ -196,8 +196,6 @@ class Sprite {
void show();
void hide();
BitmapPtr ghost();
void makeXlat(uint8 *x);
void killXlat();
void step(int nr = -1);
Seq *setSeq(Seq *seq);
CommandHandler::Command *snList(Action type);
Expand Down

0 comments on commit 85d9e92

Please sign in to comment.