From 85d9e9238c4f34ef983e1e91230e937c0dccd017 Mon Sep 17 00:00:00 2001 From: uruk Date: Thu, 5 Jun 2014 00:45:33 +0200 Subject: [PATCH] CGE2: Remove _m and xShow() from Bitmap, makeXlat() and killXlat() from Sprite. They are not used in CGE2 at all (or used differently). --- engines/cge2/bitmap.cpp | 21 +++++------- engines/cge2/bitmap.h | 4 +-- engines/cge2/vga13h.cpp | 76 ----------------------------------------- engines/cge2/vga13h.h | 2 -- 4 files changed, 10 insertions(+), 93 deletions(-) diff --git a/engines/cge2/bitmap.cpp b/engines/cge2/bitmap.cpp index f42e2b205753..47714284d3c3 100644 --- a/engines/cge2/bitmap.cpp +++ b/engines/cge2/bitmap.cpp @@ -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"); @@ -57,9 +57,9 @@ 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 @@ -67,7 +67,7 @@ Bitmap::Bitmap(CGE2Engine *vm, uint16 w, uint16 h, uint8 *map) : _w(w), _h(h), _ // 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 @@ -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; @@ -122,9 +122,7 @@ Bitmap::~Bitmap() { } void Bitmap::release() { - free(_m); delete[] _v; - _m = nullptr; _v = nullptr; } @@ -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; @@ -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; @@ -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; diff --git a/engines/cge2/bitmap.h b/engines/cge2/bitmap.h index 88ab3d8bd8dd..bcc51d874f33 100644 --- a/engines/cge2/bitmap.h +++ b/engines/cge2/bitmap.h @@ -61,7 +61,6 @@ class Bitmap { public: uint16 _w; uint16 _h; - uint8 *_m; uint8 *_v; int32 _map; HideDesc *_b; @@ -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(); diff --git a/engines/cge2/vga13h.cpp b/engines/cge2/vga13h.cpp index 9fb2a47acad4..c7979f16684c 100644 --- a/engines/cge2/vga13h.cpp +++ b/engines/cge2/vga13h.cpp @@ -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)); } @@ -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); diff --git a/engines/cge2/vga13h.h b/engines/cge2/vga13h.h index 0c45ab84899b..914459505327 100644 --- a/engines/cge2/vga13h.h +++ b/engines/cge2/vga13h.h @@ -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);