aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2011-07-11 20:37:37 +1000
committerPaul Gilbert2011-07-11 20:37:37 +1000
commit18077762d738178795c99d38010052b95cb1cef5 (patch)
tree621ad180dfb152a6cda08b53b32bbba79f7f7e49 /engines
parent10ca53a00c3ae13c520dbf871bb7f6ec65318706 (diff)
downloadscummvm-rg350-18077762d738178795c99d38010052b95cb1cef5.tar.gz
scummvm-rg350-18077762d738178795c99d38010052b95cb1cef5.tar.bz2
scummvm-rg350-18077762d738178795c99d38010052b95cb1cef5.zip
CGE: Standardised Sprite::seq on always allocating/freeing data
Diffstat (limited to 'engines')
-rw-r--r--engines/cge/cge_main.cpp5
-rw-r--r--engines/cge/events.cpp14
-rw-r--r--engines/cge/talk.cpp7
-rw-r--r--engines/cge/vga13h.cpp29
-rw-r--r--engines/cge/vga13h.h2
5 files changed, 42 insertions, 15 deletions
diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp
index 4c20f31cac..76d1b7dbcd 100644
--- a/engines/cge/cge_main.cpp
+++ b/engines/cge/cge_main.cpp
@@ -1587,7 +1587,10 @@ void CGEEngine::runGame() {
{ 1, 6, 0, 0, 4 },
{ 0, 1, 0, 0, 16 },
};
- _pocLight->setSeq(pocSeq);
+ Seq *seq = (Seq *)malloc(7 * sizeof(Seq));
+ Common::copy(&pocSeq[0], &pocSeq[7], seq);
+ _pocLight->setSeq(seq);
+
_pocLight->_flags._tran = true;
_pocLight->_time = 1;
_pocLight->_z = 120;
diff --git a/engines/cge/events.cpp b/engines/cge/events.cpp
index 433f7c6db9..0bf5191530 100644
--- a/engines/cge/events.cpp
+++ b/engines/cge/events.cpp
@@ -142,11 +142,6 @@ void Keyboard::newKeyboard(Common::Event &event) {
/*----------------- MOUSE interface -----------------*/
Mouse::Mouse(CGEEngine *vm) : Sprite(vm, NULL), _busy(NULL), _hold(NULL), _hx(0), _vm(vm) {
- static Seq ms[] = {
- { 0, 0, 0, 0, 1 },
- { 1, 1, 0, 0, 1 }
- };
-
_hold = NULL;
_hx = 0;
_hy = 0;
@@ -155,7 +150,14 @@ Mouse::Mouse(CGEEngine *vm) : Sprite(vm, NULL), _busy(NULL), _hold(NULL), _hx(0)
_busy = NULL;
_active = false;
_flags._kill = false;
- setSeq(ms);
+
+ static Seq ms[] = {
+ { 0, 0, 0, 0, 1 },
+ { 1, 1, 0, 0, 1 }
+ };
+ Seq *seq = (Seq *)malloc(2 * sizeof(Seq));
+ Common::copy(&ms[0], &ms[2], seq);
+ setSeq(seq);
BMP_PTR *MC = new BMP_PTR[3];
MC[0] = new Bitmap("MOUSE", true);
diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp
index 146c720667..152f4a7123 100644
--- a/engines/cge/talk.cpp
+++ b/engines/cge/talk.cpp
@@ -310,7 +310,12 @@ void InfoLine::update(const char *tx) {
// clear whole rectangle
memset(v + 2, TEXT_BG, dsiz); // data bytes
- memmove(v + lsiz, v, psiz - lsiz);
+
+ for (byte *pDest = v + lsiz; pDest < (v + psiz); pDest += lsiz)
+ *pDest = 0;
+// Common::set_to(pDest, pDest + lsiz, 0);
+ //Common::copy(v, v + lsiz, pDest);
+
*(uint16 *)(v + psiz - 2) = EOI; // plane trailer uint16
memmove(v + psiz, v, 3 * psiz);
diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp
index d92b9e97f0..ff21f5cce8 100644
--- a/engines/cge/vga13h.cpp
+++ b/engines/cge/vga13h.cpp
@@ -60,8 +60,6 @@ static VgaRegBlk VideoMode[] = {
};
bool SpeedTest = false;
-Seq _seq1[] = { { 0, 0, 0, 0, 0 } };
-Seq _seq2[] = { { 0, 1, 0, 0, 0 }, { 1, 0, 0, 0, 0 } };
extern "C" void SNDMIDIPlay();
@@ -383,6 +381,23 @@ BMP_PTR Sprite::shp() {
return NULL;
}
+Seq *Sprite::getConstantSeq(bool seqFlag) {
+ Seq seq1[] = { { 0, 0, 0, 0, 0 } };
+ Seq seq2[] = { { 0, 1, 0, 0, 0 }, { 1, 0, 0, 0, 0 } };
+
+ // Make a copy of the given seq list and return it
+ Seq *seq;
+ if (seqFlag) {
+ seq = (Seq *)malloc(sizeof(Seq));
+ seq[0] = seq1[0];
+ } else {
+ seq = (Seq *)malloc(2 * sizeof(Seq));
+ seq[0] = seq2[0];
+ seq[1] = seq2[1];
+ }
+
+ return seq;
+}
BMP_PTR *Sprite::setShapeList(BMP_PTR *shpP) {
BMP_PTR *r = (_ext) ? _ext->_shpList : NULL;
@@ -405,7 +420,7 @@ BMP_PTR *Sprite::setShapeList(BMP_PTR *shpP) {
_ext->_shpList = shpP;
_flags._bDel = true;
if (!_ext->_seq)
- setSeq((_shpCnt < 2) ? _seq1 : _seq2);
+ setSeq(getConstantSeq(_shpCnt < 2));
}
return r;
}
@@ -590,7 +605,7 @@ Sprite *Sprite::expand() {
error("Bad JUMP in SEQ [%s]", fname);
setSeq(seq);
} else
- setSeq((_shpCnt == 1) ? _seq1 : _seq2);
+ setSeq(getConstantSeq(_shpCnt == 1));
//disable(); // disable interupt
setShapeList(shplist);
@@ -621,8 +636,8 @@ Sprite *Sprite::contract() {
delete e->_shpList[i];
delete[] e->_shpList;
}
- if (memType(e->_seq) == NEAR_MEM)
- free(e->_seq);
+ free(e->_seq);
+
if (e->_near)
free(e->_near);
if (e->_take)
@@ -1384,7 +1399,7 @@ CavLight::CavLight(CGEEngine *vm): Sprite(vm, NULL) {
Spike::Spike(CGEEngine *vm): Sprite(vm, NULL) {
// Set the sprite list
- BMP_PTR *SP = new BMP_PTR[2];
+ BMP_PTR *SP = new BMP_PTR[3];
SP[0] = new Bitmap("SPK_L", true);
SP[1] = new Bitmap("SPK_R", true);
SP[2] = NULL;
diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h
index 003be7c800..177165689e 100644
--- a/engines/cge/vga13h.h
+++ b/engines/cge/vga13h.h
@@ -166,6 +166,8 @@ public:
class Sprite {
+private:
+ Seq *getConstantSeq(bool seqFlag);
protected:
SprExt *_ext;
public: