LAB: Some refactoring, remove dead code and a useless return value

This commit is contained in:
Strangerke 2015-12-07 08:21:27 +01:00 committed by Willem Jan Palenstijn
parent 5636181b78
commit f3a24ff593
6 changed files with 62 additions and 72 deletions

View File

@ -33,9 +33,7 @@
namespace Lab {
extern BitMap *DrawBitMap;
extern byte **startoffile;
extern BitMap *DispBitMap;
Anim::Anim(LabEngine *vm) : _vm(vm) {
_header = 0;
@ -71,12 +69,11 @@ Anim::Anim(LabEngine *vm) : _vm(vm) {
_doBlack = false;
_diffWidth = 0;
_diffHeight = 0;
_stopSound = false;
_dataBytesPerRow = 0;
DrawBitMap = &bit2;
for (int i = 0; i < 3 * 256; i++)
_diffPalette[i] = 0;
}
/*------------------------ unDiff Horizontal Memory -------------------------*/
@ -85,7 +82,7 @@ Anim::Anim(LabEngine *vm) : _vm(vm) {
/* Undiffs a piece of memory when header size is a byte, and copy/skip size */
/* is also a byte. */
/*****************************************************************************/
void Anim::unDIFFByteByte(byte *dest, byte *diff) {
void Anim::unDiffByteByte(byte *dest, byte *diff) {
uint16 skip, copy;
while (1) {
@ -115,7 +112,7 @@ void Anim::unDIFFByteByte(byte *dest, byte *diff) {
/* Undiffs a piece of memory when header size is a byte, and copy/skip size */
/* is a word. */
/*****************************************************************************/
void Anim::unDIFFByteWord(uint16 *dest, uint16 *diff) {
void Anim::unDiffByteWord(uint16 *dest, uint16 *diff) {
uint16 skip, copy;
while (1) {
@ -168,13 +165,13 @@ void Anim::unDIFFByteWord(uint16 *dest, uint16 *diff) {
/*****************************************************************************/
/* UnDiffs a coded DIFF string onto an already initialized piece of memory. */
/*****************************************************************************/
bool Anim::unDIFFMemory(byte *dest, byte *diff, uint16 headerSize, uint16 copySize) {
bool Anim::unDiffMemory(byte *dest, byte *diff, uint16 headerSize, uint16 copySize) {
if (headerSize == 1) {
if (copySize == 1)
unDIFFByteByte(dest, diff);
unDiffByteByte(dest, diff);
else if (copySize == 2)
unDIFFByteWord((uint16 *)dest, (uint16 *)diff);
unDiffByteWord((uint16 *)dest, (uint16 *)diff);
else
return false;
@ -190,7 +187,7 @@ bool Anim::unDIFFMemory(byte *dest, byte *diff, uint16 headerSize, uint16 copySi
/* Undiffs a piece of memory when header size is a byte, and copy/skip size */
/* is a byte. */
/*****************************************************************************/
void Anim::VUnDIFFByteByte(byte *dest, byte *diff, uint16 bytesPerRow) {
void Anim::VUnDiffByteByte(byte *dest, byte *diff, uint16 bytesPerRow) {
byte *curPtr;
uint16 skip, copy;
uint16 counter = 0;
@ -228,7 +225,7 @@ void Anim::VUnDIFFByteByte(byte *dest, byte *diff, uint16 bytesPerRow) {
/* Undiffs a piece of memory when header size is a byte, and copy/skip size */
/* is a word. */
/*****************************************************************************/
void Anim::VUnDIFFByteWord(uint16 *dest, uint16 *diff, uint16 bytesPerRow) {
void Anim::VUnDiffByteWord(uint16 *dest, uint16 *diff, uint16 bytesPerRow) {
uint16 *curPtr;
uint16 skip, copy;
uint16 counter = 0;
@ -268,7 +265,7 @@ void Anim::VUnDIFFByteWord(uint16 *dest, uint16 *diff, uint16 bytesPerRow) {
/* Undiffs a piece of memory when header size is a byte, and copy/skip size */
/* is a long. */
/*****************************************************************************/
void Anim::VUnDIFFByteLong(uint32 *dest, uint32 *diff, uint16 bytesPerRow) {
void Anim::VUnDiffByteLong(uint32 *dest, uint32 *diff, uint16 bytesPerRow) {
uint32 *_curPtr;
uint16 skip, copy;
@ -310,14 +307,14 @@ void Anim::VUnDIFFByteLong(uint32 *dest, uint32 *diff, uint16 bytesPerRow) {
/*****************************************************************************/
/* UnDiffs a coded DIFF string onto an already initialized piece of memory. */
/*****************************************************************************/
bool Anim::VUnDIFFMemory(byte *dest, byte *diff, uint16 headerSize, uint16 copySize, uint16 bytesPerRow) {
bool Anim::VUnDiffMemory(byte *dest, byte *diff, uint16 headerSize, uint16 copySize, uint16 bytesPerRow) {
if (headerSize == 1) {
if (copySize == 1)
VUnDIFFByteByte(dest, diff, bytesPerRow);
VUnDiffByteByte(dest, diff, bytesPerRow);
else if (copySize == 2)
VUnDIFFByteWord((uint16 *)dest, (uint16 *)diff, bytesPerRow);
VUnDiffByteWord((uint16 *)dest, (uint16 *)diff, bytesPerRow);
else if (copySize == 4)
VUnDIFFByteLong((uint32 *)dest, (uint32 *)diff, bytesPerRow);
VUnDiffByteLong((uint32 *)dest, (uint32 *)diff, bytesPerRow);
else
return false;
} else
@ -407,9 +404,9 @@ void Anim::unDiff(byte *newBuf, byte *oldBuf, byte *diffData, uint16 bytesPerRow
diffData++;
if (isV)
VUnDIFFMemory(newBuf, diffData, 1, bufType + 1, bytesPerRow);
VUnDiffMemory(newBuf, diffData, 1, bufType + 1, bytesPerRow);
else
unDIFFMemory(newBuf, diffData, 1, bufType + 1);
unDiffMemory(newBuf, diffData, 1, bufType + 1);
}
void Anim::readBlock(void *Buffer, uint32 Size, byte **File) {
@ -421,12 +418,12 @@ void Anim::diffNextFrame() {
if (_header == 65535) /* Already done. */
return;
if (DispBitMap->_flags & BITMAPF_VIDEO) {
DispBitMap->_planes[0] = _vm->_graphics->getCurrentDrawingBuffer();
DispBitMap->_planes[1] = DispBitMap->_planes[0] + 0x10000;
DispBitMap->_planes[2] = DispBitMap->_planes[1] + 0x10000;
DispBitMap->_planes[3] = DispBitMap->_planes[2] + 0x10000;
DispBitMap->_planes[4] = DispBitMap->_planes[3] + 0x10000;
if (_vm->_graphics->_dispBitMap->_flags & BITMAPF_VIDEO) {
_vm->_graphics->_dispBitMap->_planes[0] = _vm->_graphics->getCurrentDrawingBuffer();
_vm->_graphics->_dispBitMap->_planes[1] = _vm->_graphics->_dispBitMap->_planes[0] + 0x10000;
_vm->_graphics->_dispBitMap->_planes[2] = _vm->_graphics->_dispBitMap->_planes[1] + 0x10000;
_vm->_graphics->_dispBitMap->_planes[3] = _vm->_graphics->_dispBitMap->_planes[2] + 0x10000;
_vm->_graphics->_dispBitMap->_planes[4] = _vm->_graphics->_dispBitMap->_planes[3] + 0x10000;
}
_vm->_event->mouseHide();
@ -464,7 +461,7 @@ void Anim::diffNextFrame() {
_isAnim = (_frameNum >= 3) && (!_playOnce);
_curBit = 0;
if (DispBitMap->_flags & BITMAPF_VIDEO)
if (_vm->_graphics->_dispBitMap->_flags & BITMAPF_VIDEO)
_vm->_graphics->screenUpdate();
return; /* done with the next frame. */
@ -510,13 +507,13 @@ void Anim::diffNextFrame() {
break;
case 20L:
unDiff(DrawBitMap->_planes[_curBit], DispBitMap->_planes[_curBit], _diffFile, DrawBitMap->_bytesPerRow, false);
unDiff(DrawBitMap->_planes[_curBit], _vm->_graphics->_dispBitMap->_planes[_curBit], _diffFile, DrawBitMap->_bytesPerRow, false);
_curBit++;
_diffFile += _size;
break;
case 21L:
unDiff(DrawBitMap->_planes[_curBit], DispBitMap->_planes[_curBit], _diffFile, DrawBitMap->_bytesPerRow, true);
unDiff(DrawBitMap->_planes[_curBit], _vm->_graphics->_dispBitMap->_planes[_curBit], _diffFile, DrawBitMap->_bytesPerRow, true);
_curBit++;
_diffFile += _size;
break;
@ -550,15 +547,15 @@ void Anim::diffNextFrame() {
break;
case 65535L:
if ((_frameNum == 1) || _playOnce || _stopPlayingEnd) {
int didTOF = 0;
bool didTOF = false;
if (_waitForEffect) {
while (_vm->_music->isSoundEffectActive()) {
_vm->_music->updateMusic();
_vm->waitTOF();
if (DispBitMap->_flags & BITMAPF_VIDEO)
didTOF = 1;
if (_vm->_graphics->_dispBitMap->_flags & BITMAPF_VIDEO)
didTOF = true;
}
}
@ -691,13 +688,6 @@ void Anim::stopDiffEnd() {
}
}
/*****************************************************************************/
/* Stops the continuous sound from playing. */
/*****************************************************************************/
void Anim::stopSound() {
_stopSound = true;
}
/*****************************************************************************/
/* Reads in a DIFF file. */
/*****************************************************************************/

View File

@ -83,15 +83,25 @@ private:
uint16 _sampleSpeed;
uint32 _diffWidth;
uint32 _diffHeight;
bool _stopSound;
uint16 _dataBytesPerRow;
BitMap bit2;
BitMap *DrawBitMap;
void unDIFFByteByte(byte *dest, byte *diff);
void unDIFFByteWord(uint16 *dest, uint16 *diff);
void VUnDIFFByteByte(byte *Dest, byte *diff, uint16 bytesperrow);
void VUnDIFFByteWord(uint16 *Dest, uint16 *diff, uint16 bytesperrow);
void VUnDIFFByteLong(uint32 *Dest, uint32 *diff, uint16 bytesperrow);
bool unDiffMemory(byte *dest, /* Where to Un-DIFF */
byte *diff, /* The DIFFed code. */
uint16 headerSize, /* Size of header (1, 2 or 4 bytes) (only supports 1 currently */
uint16 copySize); /* Size of minimum copy or skip. (1, 2 or 4 bytes) */
void runLengthDecode(byte *dest, byte *source);
void VRunLengthDecode(byte *dest, byte *source, uint16 bytesPerRow);
void unDiffByteByte(byte *dest, byte *diff);
void unDiffByteWord(uint16 *dest, uint16 *diff);
bool VUnDiffMemory(byte *dest, byte *diff, uint16 headerSize, uint16 copySize, uint16 bytesPerRow);
void VUnDiffByteByte(byte *Dest, byte *diff, uint16 bytesperrow);
void VUnDiffByteWord(uint16 *Dest, uint16 *diff, uint16 bytesperrow);
void VUnDiffByteLong(uint32 *Dest, uint32 *diff, uint16 bytesperrow);
void readBlock(void *Buffer, uint32 Size, byte **File);
void playDiff(byte *buffer);
public:
Anim(LabEngine *vm);
@ -105,21 +115,11 @@ public:
BitMap _rawDiffBM;
void unDiff(byte *newBuf, byte *oldBuf, byte *diffData, uint16 bytesperrow, bool isV);
bool unDIFFMemory(byte *dest, /* Where to Un-DIFF */
byte *diff, /* The DIFFed code. */
uint16 headerSize, /* Size of header (1, 2 or 4 bytes) (only supports 1 currently */
uint16 copySize); /* Size of minimum copy or skip. (1, 2 or 4 bytes) */
bool VUnDIFFMemory(byte *dest, byte *diff, uint16 headerSize, uint16 copySize, uint16 bytesPerRow);
void runLengthDecode(byte *dest, byte *source);
void VRunLengthDecode(byte *dest, byte *source, uint16 bytesPerRow);
bool readDiff(byte *buffer, bool playOnce);
void playDiff(byte *buffer);
void diffNextFrame();
void readSound(bool waitTillFinished, Common::File *file);
void stopDiff();
void stopDiffEnd();
void stopSound();
};
} // End of namespace Lab

View File

@ -39,8 +39,6 @@
namespace Lab {
BitMap bit1, bit2, *DispBitMap = &bit1, *DrawBitMap = &bit1;
DisplayMan::DisplayMan(LabEngine *vm) : _vm(vm) {
_longWinInFront = false;
_lastMessageLong = false;
@ -57,6 +55,8 @@ DisplayMan::DisplayMan(LabEngine *vm) : _vm(vm) {
_screenWidth = 0;
_screenHeight = 0;
_dispBitMap = &bit1;
for (int i = 0; i < 256 * 3; i++)
_curvgapal[i] = 0;
}
@ -129,7 +129,7 @@ void DisplayMan::loadPict(const char *filename) {
/*****************************************************************************/
/* Reads in a picture into the dest bitmap. */
/*****************************************************************************/
bool DisplayMan::readPict(const char *filename, bool playOnce) {
void DisplayMan::readPict(const char *filename, bool playOnce) {
_vm->_anim->stopDiff();
loadPict(filename);
@ -139,13 +139,11 @@ bool DisplayMan::readPict(const char *filename, bool playOnce) {
if (!_vm->_music->_doNotFilestopSoundEffect)
_vm->_music->stopSoundEffect();
DispBitMap->_bytesPerRow = _screenWidth;
DispBitMap->_rows = _screenHeight;
DispBitMap->_flags = BITMAPF_VIDEO;
_dispBitMap->_bytesPerRow = _screenWidth;
_dispBitMap->_rows = _screenHeight;
_dispBitMap->_flags = BITMAPF_VIDEO;
_vm->_anim->readDiff(_curBitmap, playOnce);
return true;
}
/*****************************************************************************/
@ -161,14 +159,14 @@ byte *DisplayMan::readPictToMem(const char *filename, uint16 x, uint16 y) {
if (!_vm->_music->_doNotFilestopSoundEffect)
_vm->_music->stopSoundEffect();
DispBitMap->_bytesPerRow = x;
DispBitMap->_rows = y;
DispBitMap->_flags = BITMAPF_NONE;
DispBitMap->_planes[0] = _curBitmap;
DispBitMap->_planes[1] = DispBitMap->_planes[0] + 0x10000;
DispBitMap->_planes[2] = DispBitMap->_planes[1] + 0x10000;
DispBitMap->_planes[3] = DispBitMap->_planes[2] + 0x10000;
DispBitMap->_planes[4] = DispBitMap->_planes[3] + 0x10000;
_dispBitMap->_bytesPerRow = x;
_dispBitMap->_rows = y;
_dispBitMap->_flags = BITMAPF_NONE;
_dispBitMap->_planes[0] = _curBitmap;
_dispBitMap->_planes[1] = _dispBitMap->_planes[0] + 0x10000;
_dispBitMap->_planes[2] = _dispBitMap->_planes[1] + 0x10000;
_dispBitMap->_planes[3] = _dispBitMap->_planes[2] + 0x10000;
_dispBitMap->_planes[4] = _dispBitMap->_planes[3] + 0x10000;
_vm->_anim->readDiff(_curBitmap, true);

View File

@ -32,6 +32,7 @@
#define LAB_GRAPHICS_H
#include "graphics/palette.h"
#include "lab/anim.h"
namespace Lab {
@ -67,7 +68,7 @@ public:
int16 VGAScaleY(int16 y);
uint16 SVGACord(uint16 cord);
void loadPict(const char *filename);
bool readPict(const char *filename, bool playOnce);
void readPict(const char *filename, bool playOnce);
void freePict();
byte *readPictToMem(const char *filename, uint16 x, uint16 y);
void doScrollBlack();
@ -152,6 +153,8 @@ public:
byte *_currentDisplayBuffer;
bool _doNotDrawMessage;
uint16 *FadePalette;
BitMap bit1;
BitMap *_dispBitMap;
};
} // End of namespace Lab

View File

@ -59,7 +59,6 @@ static uint16 monitorPage;
static const char *TextFileName;
Image *MonButton;
extern BitMap *DispBitMap, *DrawBitMap;
#define INCL(BITSET,BIT) ((BITSET) |= (BIT))
#define SETBIT(BITSET,BITNUM) INCL(BITSET, (1 << (BITNUM)))

View File

@ -163,7 +163,7 @@ void LabEngine::changeTile(uint16 col, uint16 row) {
if (check) {
_conditions->inclElement(BRICKOPEN); /* unlocked combination */
_anim->_doBlack = true;
check = _graphics->readPict("p:Up/BDOpen", true);
_graphics->readPict("p:Up/BDOpen", true);
}
}
}