LAB: Move utility functions to a separate class

This commit is contained in:
Strangerke 2015-12-07 17:46:37 +01:00 committed by Willem Jan Palenstijn
parent 320e658cb1
commit 5bc48cbbdd
15 changed files with 621 additions and 524 deletions

View file

@ -69,317 +69,12 @@ Anim::Anim(LabEngine *vm) : _vm(vm) {
_doBlack = false;
_diffWidth = 0;
_diffHeight = 0;
_dataBytesPerRow = 0;
DrawBitMap = &_vm->_graphics->_dispBitMap;
for (int i = 0; i < 3 * 256; i++)
_diffPalette[i] = 0;
}
/*------------------------ unDiff Horizontal Memory -------------------------*/
/*****************************************************************************/
/* 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) {
uint16 skip, copy;
while (1) {
skip = *diff;
diff++;
copy = *diff;
diff++;
if (skip == 255) {
if (copy == 0) {
skip = READ_LE_UINT16(diff);
diff += 2;
copy = READ_LE_UINT16(diff);
diff += 2;
} else if (copy == 255)
return;
}
dest += skip;
memcpy(dest, diff, copy);
dest += copy;
diff += copy;
}
}
/*****************************************************************************/
/* 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) {
uint16 skip, copy;
while (1) {
skip = ((byte *)diff)[0];
copy = ((byte *)diff)[1];
diff++;
if (skip == 255) {
if (copy == 0) {
skip = READ_LE_UINT16(diff);
diff++;
copy = READ_LE_UINT16(diff);
diff++;
} else if (copy == 255)
return;
}
dest += skip;
while (copy > 3) {
*dest = READ_LE_UINT16(diff);
dest++;
diff++;
*dest = READ_LE_UINT16(diff);
dest++;
diff++;
*dest = READ_LE_UINT16(diff);
dest++;
diff++;
*dest = READ_LE_UINT16(diff);
dest++;
diff++;
copy -= 4;
}
while (copy) {
*dest = READ_LE_UINT16(diff);
dest++;
diff++;
copy--;
}
}
}
/*------------------------- unDiff Vertical Memory --------------------------*/
/*****************************************************************************/
/* 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) {
byte *curPtr;
uint16 skip, copy;
uint16 counter = 0;
while (counter < _dataBytesPerRow) {
curPtr = dest + counter;
for (;;) {
skip = *diff;
diff++;
copy = *diff;
diff++;
if (skip == 255) {
counter += copy;
break;
}
else {
curPtr += (skip * bytesPerRow);
while (copy) {
copy--;
*curPtr = *diff;
curPtr += bytesPerRow;
diff++;
}
}
}
}
}
/*****************************************************************************/
/* 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) {
uint16 *curPtr;
uint16 skip, copy;
uint16 counter = 0;
uint16 wordsPerRow = bytesPerRow / 2;
while (counter < (_dataBytesPerRow >> 1)) {
curPtr = dest + counter;
for (;;) {
skip = ((byte *)diff)[0];
copy = ((byte *)diff)[1];
diff++;
if (skip == 255) {
counter += copy;
break;
}
else {
curPtr += (skip * wordsPerRow);
while (copy) {
*curPtr = *diff; //swapUShort(*diff);
curPtr += wordsPerRow;
diff++;
copy--;
}
}
}
}
}
/*****************************************************************************/
/* 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) {
uint32 *_curPtr;
uint16 skip, copy;
uint16 counter = 0;
byte *diff1 = (byte *)diff;
uint16 longsperrow = bytesPerRow / 4;
while (counter < (_dataBytesPerRow >> 2)) {
_curPtr = dest + counter;
for (;;) {
skip = *diff1;
diff1++;
copy = *diff1;
diff1++;
if (skip == 255) {
counter += copy;
break;
}
else {
_curPtr += (skip * longsperrow);
while (copy) {
*_curPtr = *(uint32 *)diff1; //swapULong(*diff);
_curPtr += longsperrow;
diff1 += 4;
copy--;
}
}
}
}
}
/*****************************************************************************/
/* Runlength decodes a chunk of memory. */
/*****************************************************************************/
void Anim::runLengthDecode(byte *dest, byte *source) {
int8 num;
int16 count;
while (1) {
num = (int8)*source;
source++;
if (num == 127) {
return;
} else if (num > '\0') {
memcpy(dest, source, num);
source += num;
dest += num;
} else {
count = (int16)(-num);
num = *source;
source++;
while (count) {
*dest = num;
dest++;
count--;
}
}
}
}
/*****************************************************************************/
/* Does a vertical run length decode. */
/*****************************************************************************/
void Anim::VRunLengthDecode(byte *dest, byte *source, uint16 bytesPerRow) {
int8 num;
int16 count;
byte *top = dest;
for (uint16 i = 0; i < _dataBytesPerRow; i++) {
dest = top;
dest += i;
num = (int8)*source;
source++;
while (num != 127) {
if (num > '\0') {
while (num) {
*dest = *source;
source++;
dest += bytesPerRow;
num--;
}
} else {
count = (int16)(-num);
num = (int8)*source;
source++;
while (count) {
*dest = num;
dest += bytesPerRow;
count--;
}
}
num = *source;
source++;
}
}
}
/*****************************************************************************/
/* Does the undiffing between the bitmaps. */
/*****************************************************************************/
void Anim::unDiff(byte *newBuf, byte *oldBuf, byte *diffData, uint16 bytesPerRow, bool isV) {
diffData++;
byte bufType = *diffData;
diffData++;
if (isV) {
if (bufType == 0)
VUnDiffByteByte(newBuf, diffData, bytesPerRow);
else if (bufType == 1)
VUnDiffByteWord((uint16 *)newBuf, (uint16 *)diffData, bytesPerRow);
else if (bufType == 3)
VUnDiffByteLong((uint32 *)newBuf, (uint32 *)diffData, bytesPerRow);
} else {
if (bufType == 0)
unDiffByteByte(newBuf, diffData);
else if (bufType == 1)
unDiffByteWord((uint16 *)newBuf, (uint16 *)diffData);
}
}
void Anim::readBlock(void *Buffer, uint32 Size, byte **File) {
memcpy(Buffer, *File, (size_t)Size);
(*File) += Size;
@ -465,26 +160,26 @@ void Anim::diffNextFrame() {
case 11L:
_diffFile += 4;
runLengthDecode(DrawBitMap->_planes[_curBit], _diffFile);
_vm->_utils->runLengthDecode(DrawBitMap->_planes[_curBit], _diffFile);
_curBit++;
_diffFile += _size - 4;
break;
case 12L:
_diffFile += 4;
VRunLengthDecode(DrawBitMap->_planes[_curBit], _diffFile, DrawBitMap->_bytesPerRow);
_vm->_utils->VRunLengthDecode(DrawBitMap->_planes[_curBit], _diffFile, DrawBitMap->_bytesPerRow);
_curBit++;
_diffFile += _size - 4;
break;
case 20L:
unDiff(DrawBitMap->_planes[_curBit], _vm->_graphics->_dispBitMap._planes[_curBit], _diffFile, DrawBitMap->_bytesPerRow, false);
_vm->_utils->unDiff(DrawBitMap->_planes[_curBit], _vm->_graphics->_dispBitMap._planes[_curBit], _diffFile, DrawBitMap->_bytesPerRow, false);
_curBit++;
_diffFile += _size;
break;
case 21L:
unDiff(DrawBitMap->_planes[_curBit], _vm->_graphics->_dispBitMap._planes[_curBit], _diffFile, DrawBitMap->_bytesPerRow, true);
_vm->_utils->unDiff(DrawBitMap->_planes[_curBit], _vm->_graphics->_dispBitMap._planes[_curBit], _diffFile, DrawBitMap->_bytesPerRow, true);
_curBit++;
_diffFile += _size;
break;
@ -615,7 +310,7 @@ void Anim::playDiff(byte *buffer) {
_continuous = CONTINUOUS & _headerdata._flags;
_diffWidth = _headerdata._width;
_diffHeight = _headerdata._height;
_dataBytesPerRow = _diffWidth;
_vm->_utils->setBytesPerRow(_diffWidth);
_numChunks = (((int32) _diffWidth) * _diffHeight) / 0x10000;

View file

@ -83,16 +83,8 @@ private:
uint16 _sampleSpeed;
uint32 _diffWidth;
uint32 _diffHeight;
uint16 _dataBytesPerRow;
BitMap *DrawBitMap;
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);
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);
@ -107,7 +99,6 @@ public:
bool _noPalChange; /* Don't change the palette. */
BitMap _rawDiffBM;
void unDiff(byte *newBuf, byte *oldBuf, byte *diffData, uint16 bytesperrow, bool isV);
bool readDiff(byte *buffer, bool playOnce);
void diffNextFrame();
void stopDiff();

View file

@ -941,7 +941,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
_curFileName = _newFileName;
else if (doActionRule(curPos, TAKE - 1, 0, &_cptr))
_curFileName = _newFileName;
else if (curPos.y < (_graphics->VGAScaleY(149) + _graphics->SVGACord(2)))
else if (curPos.y < (_utils->vgaScaleY(149) + _utils->svgaCord(2)))
drawStaticMessage(kTextNothing);
} else if ((actionMode == 1) /* Manipulate an object */ ||
(actionMode == 2) /* Open up a "door" */ ||
@ -949,7 +949,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
if (doActionRule(curPos, actionMode, _roomNum, &_cptr))
_curFileName = _newFileName;
else if (!doActionRule(curPos, actionMode, 0, &_cptr)) {
if (curPos.y < (_graphics->VGAScaleY(149) + _graphics->SVGACord(2)))
if (curPos.y < (_utils->vgaScaleY(149) + _utils->svgaCord(2)))
drawStaticMessage(kTextNothing);
}
} else if (actionMode == 4) { /* Look at closeups */
@ -957,15 +957,15 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
setCurClose(curPos, &tempcptr);
if (_cptr == tempcptr) {
if (curPos.y < (_graphics->VGAScaleY(149) + _graphics->SVGACord(2)))
if (curPos.y < (_utils->vgaScaleY(149) + _utils->svgaCord(2)))
drawStaticMessage(kTextNothing);
} else if (tempcptr->_graphicName) {
if (*(tempcptr->_graphicName)) {
_anim->_doBlack = true;
_cptr = tempcptr;
} else if (curPos.y < (_graphics->VGAScaleY(149) + _graphics->SVGACord(2)))
} else if (curPos.y < (_utils->vgaScaleY(149) + _utils->svgaCord(2)))
drawStaticMessage(kTextNothing);
} else if (curPos.y < (_graphics->VGAScaleY(149) + _graphics->SVGACord(2)))
} else if (curPos.y < (_utils->vgaScaleY(149) + _utils->svgaCord(2)))
drawStaticMessage(kTextNothing);
} else if ((actionMode == 5) &&
_conditions->in(curInv)) { /* Use an item on something else */
@ -974,7 +974,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
if (!_conditions->in(curInv))
decIncInv(&curInv, false);
} else if (curPos.y < (_graphics->VGAScaleY(149) + _graphics->SVGACord(2)))
} else if (curPos.y < (_utils->vgaScaleY(149) + _utils->svgaCord(2)))
drawStaticMessage(kTextNothing);
}
}
@ -1008,7 +1008,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
}
if (hcptr)
_event->setMousePos(Common::Point(_graphics->scaleX((hcptr->x1 + hcptr->x2) / 2), _graphics->scaleY((hcptr->y1 + hcptr->y2) / 2)));
_event->setMousePos(Common::Point(_utils->scaleX((hcptr->x1 + hcptr->x2) / 2), _utils->scaleY((hcptr->y1 + hcptr->y2) / 2)));
} else if ((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) {
eatMessages();
_alternate = !_alternate;

View file

@ -63,55 +63,6 @@ DisplayMan::~DisplayMan() {
freePict();
}
/*****************************************************************************/
/* Scales the x co-ordinates to that of the new display. In the room parser */
/* file, co-ordinates are set up on a 360x336 display. */
/*****************************************************************************/
uint16 DisplayMan::scaleX(uint16 x) {
if (_vm->_isHiRes)
return (uint16)((x * 16) / 9);
else
return (uint16)((x * 8) / 9);
}
/*****************************************************************************/
/* Scales the y co-ordinates to that of the new display. In the room parser */
/* file, co-ordinates are set up on a 368x336 display. */
/*****************************************************************************/
uint16 DisplayMan::scaleY(uint16 y) {
if (_vm->_isHiRes)
return (y + (y / 14));
else
return ((y * 10) / 24);
}
/*****************************************************************************/
/* Scales the VGA cords to SVGA if necessary; otherwise, returns VGA cords. */
/*****************************************************************************/
int16 DisplayMan::VGAScaleX(int16 x) {
if (_vm->_isHiRes)
return (x * 2);
else
return x;
}
/*****************************************************************************/
/* Scales the VGA cords to SVGA if necessary; otherwise, returns VGA cords. */
/*****************************************************************************/
int16 DisplayMan::VGAScaleY(int16 y) {
if (_vm->_isHiRes)
return ((y * 12) / 5);
else
return y;
}
uint16 DisplayMan::SVGACord(uint16 cord) {
if (_vm->_isHiRes)
return cord;
else
return 0;
}
/*---------------------------------------------------------------------------*/
/*------ From readPict.c. Reads in pictures and animations from disk. ------*/
/*---------------------------------------------------------------------------*/
@ -305,16 +256,18 @@ uint32 DisplayMan::flowText(void *font, /* the TextAttr pointer */
}
uint32 DisplayMan::flowTextScaled(void *font, /* the TextAttr pointer */
int16 spacing, /* How much vertical spacing between the lines */
byte pencolor, /* pen number to use for text */
byte backpen, /* the background color */
bool fillback, /* Whether to fill the background */
bool centerh, /* Whether to center the text horizontally */
bool centerv, /* Whether to center the text vertically */
int16 spacing, /* How much vertical spacing between the lines */
byte penColor, /* pen number to use for text */
byte backPen, /* the background color */
bool fillBack, /* Whether to fill the background */
bool centerX, /* Whether to center the text horizontally */
bool centerY, /* Whether to center the text vertically */
bool output, /* Whether to output any text */
uint16 x1, /* Cords */
uint16 y1, uint16 x2, uint16 y2, const char *str) {
return flowText(font, spacing, pencolor, backpen, fillback, centerh, centerv, output, VGAScaleX(x1), VGAScaleY(y1), VGAScaleX(x2), VGAScaleY(y2), str);
uint16 x1, uint16 y1, /* Cords */
uint16 x2, uint16 y2, const char *str) {
return flowText(font, spacing, penColor, backPen, fillBack, centerX, centerY, output,
_vm->_utils->vgaScaleX(x1), _vm->_utils->vgaScaleY(y1),
_vm->_utils->vgaScaleX(x2), _vm->_utils->vgaScaleY(y2), str);
}
/******************************************************************************/
@ -351,10 +304,10 @@ void DisplayMan::createBox(uint16 y2) {
rectFillScaled(4, 154, 315, y2 - 2);
setAPen(0); /* Box around message area */
drawHLine(VGAScaleX(2), VGAScaleY(152), VGAScaleX(317));
drawVLine(VGAScaleX(317), VGAScaleY(152), VGAScaleY(y2));
drawHLine(VGAScaleX(2), VGAScaleY(y2), VGAScaleX(317));
drawVLine(VGAScaleX(2), VGAScaleY(152), VGAScaleY(y2));
drawHLine(_vm->_utils->vgaScaleX(2), _vm->_utils->vgaScaleY(152), _vm->_utils->vgaScaleX(317));
drawVLine(_vm->_utils->vgaScaleX(317), _vm->_utils->vgaScaleY(152), _vm->_utils->vgaScaleY(y2));
drawHLine(_vm->_utils->vgaScaleX(2), _vm->_utils->vgaScaleY(y2), _vm->_utils->vgaScaleX(317));
drawVLine(_vm->_utils->vgaScaleX(2), _vm->_utils->vgaScaleY(152), _vm->_utils->vgaScaleY(y2));
}
int32 DisplayMan::longDrawMessage(const char *str) {
@ -370,7 +323,7 @@ int32 DisplayMan::longDrawMessage(const char *str) {
if (!_longWinInFront) {
_longWinInFront = true;
setAPen(3); /* Clear Area */
rectFill(0, VGAScaleY(149) + SVGACord(2), VGAScaleX(319), VGAScaleY(199));
rectFill(0, _vm->_utils->vgaScaleY(149) + _vm->_utils->svgaCord(2), _vm->_utils->vgaScaleX(319), _vm->_utils->vgaScaleY(199));
}
createBox(198);
@ -389,7 +342,7 @@ void DisplayMan::drawMessage(const char *str) {
}
if (str) {
if ((textLength(_vm->_msgFont, str, strlen(str)) > VGAScaleX(306))) {
if ((textLength(_vm->_msgFont, str, strlen(str)) > _vm->_utils->vgaScaleX(306))) {
longDrawMessage(str);
_lastMessageLong = true;
} else {
@ -400,7 +353,7 @@ void DisplayMan::drawMessage(const char *str) {
_vm->_event->mouseHide();
createBox(168);
text(_vm->_msgFont, VGAScaleX(7), VGAScaleY(155) + SVGACord(2), 1, str, strlen(str));
text(_vm->_msgFont, _vm->_utils->vgaScaleX(7), _vm->_utils->vgaScaleY(155) + _vm->_utils->svgaCord(2), 1, str, strlen(str));
_vm->_event->mouseShow();
_lastMessageLong = false;
}
@ -415,8 +368,8 @@ void DisplayMan::doScrollBlack() {
Image im;
uint32 size, copysize;
byte *baseAddr;
uint16 width = VGAScaleX(320);
uint16 height = VGAScaleY(149) + SVGACord(2);
uint16 width = _vm->_utils->vgaScaleX(320);
uint16 height = _vm->_utils->vgaScaleY(149) + _vm->_utils->svgaCord(2);
byte *mem = new byte[width * height];
_vm->_event->mouseHide();
@ -430,7 +383,7 @@ void DisplayMan::doScrollBlack() {
baseAddr = getCurrentDrawingBuffer();
uint16 by = VGAScaleX(4);
uint16 by = _vm->_utils->vgaScaleX(4);
uint16 nheight = height;
while (nheight) {
@ -512,8 +465,8 @@ void DisplayMan::doScrollWipe(char *filename) {
uint16 startline = 0, onrow = 0;
_vm->_event->mouseHide();
uint16 width = VGAScaleX(320);
uint16 height = VGAScaleY(149) + SVGACord(2);
uint16 width = _vm->_utils->vgaScaleX(320);
uint16 height = _vm->_utils->vgaScaleY(149) + _vm->_utils->svgaCord(2);
while (_vm->_music->isSoundEffectActive()) {
_vm->_music->updateMusic();
@ -527,7 +480,7 @@ void DisplayMan::doScrollWipe(char *filename) {
byte *mem = _vm->_anim->_rawDiffBM._planes[0];
_vm->_music->updateMusic();
uint16 by = VGAScaleX(3);
uint16 by = _vm->_utils->vgaScaleX(3);
uint16 nheight = height;
while (onrow < _vm->_anim->_headerdata._height) {
@ -552,11 +505,11 @@ void DisplayMan::doScrollWipe(char *filename) {
onrow += by;
if (nheight <= (height / 4))
by = VGAScaleX(5);
by = _vm->_utils->vgaScaleX(5);
else if (nheight <= (height / 3))
by = VGAScaleX(4);
by = _vm->_utils->vgaScaleX(4);
else if (nheight <= (height / 2))
by = VGAScaleX(3);
by = _vm->_utils->vgaScaleX(3);
}
_vm->_event->mouseShow();
@ -580,8 +533,8 @@ void DisplayMan::doScrollBounce() {
}
_vm->_event->mouseHide();
int width = VGAScaleX(320);
int height = VGAScaleY(149) + SVGACord(2);
int width = _vm->_utils->vgaScaleX(320);
int height = _vm->_utils->vgaScaleY(149) + _vm->_utils->svgaCord(2);
byte *mem = _vm->_anim->_rawDiffBM._planes[0];
_vm->_music->updateMusic();
@ -787,44 +740,44 @@ void DisplayMan::drawPanel() {
_vm->_event->mouseHide();
setAPen(3); /* Clear Area */
rectFill(0, VGAScaleY(149) + SVGACord(2), VGAScaleX(319), VGAScaleY(199));
rectFill(0, _vm->_utils->vgaScaleY(149) + _vm->_utils->svgaCord(2), _vm->_utils->vgaScaleX(319), _vm->_utils->vgaScaleY(199));
setAPen(0); /* First Line */
drawHLine(0, VGAScaleY(149) + SVGACord(2), VGAScaleX(319));
drawHLine(0, _vm->_utils->vgaScaleY(149) + _vm->_utils->svgaCord(2), _vm->_utils->vgaScaleX(319));
setAPen(5); /* Second Line */
drawHLine(0, VGAScaleY(149) + 1 + SVGACord(2), VGAScaleX(319));
drawHLine(0, _vm->_utils->vgaScaleY(149) + 1 + _vm->_utils->svgaCord(2), _vm->_utils->vgaScaleX(319));
/* Gadget Separators */
setAPen(0);
drawHLine(0, VGAScaleY(170), VGAScaleX(319)); /* First black line to separate buttons */
drawHLine(0, _vm->_utils->vgaScaleY(170), _vm->_utils->vgaScaleX(319)); /* First black line to separate buttons */
if (!_vm->_alternate) {
setAPen(4);
drawHLine(0, VGAScaleY(170) + 1, VGAScaleX(319)); /* The horizontal lines under the black one */
drawHLine(0, _vm->_utils->vgaScaleY(170) + 1, _vm->_utils->vgaScaleX(319)); /* The horizontal lines under the black one */
drawGadgetList(&_vm->_moveGadgetList);
} else {
if (_vm->getPlatform() != Common::kPlatformWindows) {
drawVLine(VGAScaleX(124), VGAScaleY(170) + 1, VGAScaleY(199)); /* Vertical Black lines */
drawVLine(VGAScaleX(194), VGAScaleY(170) + 1, VGAScaleY(199));
drawVLine(_vm->_utils->vgaScaleX(124), _vm->_utils->vgaScaleY(170) + 1, _vm->_utils->vgaScaleY(199)); /* Vertical Black lines */
drawVLine(_vm->_utils->vgaScaleX(194), _vm->_utils->vgaScaleY(170) + 1, _vm->_utils->vgaScaleY(199));
} else {
drawVLine(VGAScaleX(90), VGAScaleY(170) + 1, VGAScaleY(199)); /* Vertical Black lines */
drawVLine(VGAScaleX(160), VGAScaleY(170) + 1, VGAScaleY(199));
drawVLine(VGAScaleX(230), VGAScaleY(170) + 1, VGAScaleY(199));
drawVLine(_vm->_utils->vgaScaleX(90), _vm->_utils->vgaScaleY(170) + 1, _vm->_utils->vgaScaleY(199)); /* Vertical Black lines */
drawVLine(_vm->_utils->vgaScaleX(160), _vm->_utils->vgaScaleY(170) + 1, _vm->_utils->vgaScaleY(199));
drawVLine(_vm->_utils->vgaScaleX(230), _vm->_utils->vgaScaleY(170) + 1, _vm->_utils->vgaScaleY(199));
}
setAPen(4);
drawHLine(0, VGAScaleY(170) + 1, VGAScaleX(122)); /* The horizontal lines under the black one */
drawHLine(VGAScaleX(126), VGAScaleY(170) + 1, VGAScaleX(192));
drawHLine(VGAScaleX(196), VGAScaleY(170) + 1, VGAScaleX(319));
drawHLine(0, _vm->_utils->vgaScaleY(170) + 1, _vm->_utils->vgaScaleX(122)); /* The horizontal lines under the black one */
drawHLine(_vm->_utils->vgaScaleX(126), _vm->_utils->vgaScaleY(170) + 1, _vm->_utils->vgaScaleX(192));
drawHLine(_vm->_utils->vgaScaleX(196), _vm->_utils->vgaScaleY(170) + 1, _vm->_utils->vgaScaleX(319));
drawVLine(_vm->_utils->vgaScaleX(1), _vm->_utils->vgaScaleY(170) + 2, _vm->_utils->vgaScaleY(198)); /* The vertical high light lines */
drawVLine(VGAScaleX(1), VGAScaleY(170) + 2, VGAScaleY(198)); /* The vertical high light lines */
if (_vm->getPlatform() != Common::kPlatformWindows) {
drawVLine(VGAScaleX(126), VGAScaleY(170) + 2, VGAScaleY(198));
drawVLine(VGAScaleX(196), VGAScaleY(170) + 2, VGAScaleY(198));
drawVLine(_vm->_utils->vgaScaleX(126), _vm->_utils->vgaScaleY(170) + 2, _vm->_utils->vgaScaleY(198));
drawVLine(_vm->_utils->vgaScaleX(196), _vm->_utils->vgaScaleY(170) + 2, _vm->_utils->vgaScaleY(198));
} else {
drawVLine(VGAScaleX(92), VGAScaleY(170) + 2, VGAScaleY(198));
drawVLine(VGAScaleX(162), VGAScaleY(170) + 2, VGAScaleY(198));
drawVLine(VGAScaleX(232), VGAScaleY(170) + 2, VGAScaleY(198));
drawVLine(_vm->_utils->vgaScaleX(92), _vm->_utils->vgaScaleY(170) + 2, _vm->_utils->vgaScaleY(198));
drawVLine(_vm->_utils->vgaScaleX(162), _vm->_utils->vgaScaleY(170) + 2, _vm->_utils->vgaScaleY(198));
drawVLine(_vm->_utils->vgaScaleX(232), _vm->_utils->vgaScaleY(170) + 2, _vm->_utils->vgaScaleY(198));
}
drawGadgetList(&_vm->_invGadgetList);
@ -846,16 +799,16 @@ bool DisplayMan::setUpScreens() {
delete controlFile;
/* Creates the gadgets for the movement control panel */
uint16 y = VGAScaleY(173) - SVGACord(2);
uint16 y = _vm->_utils->vgaScaleY(173) - _vm->_utils->svgaCord(2);
// The key mapping was only set for the Windows version.
// It's very convenient to have those shortcut, so I added them
// for all versions. (Strangerke)
_vm->_moveGadgetList.push_back(createButton( 1, y, 0, 't', _vm->_moveImages[0], _vm->_moveImages[1]));
_vm->_moveGadgetList.push_back(createButton( 33, y, 1, 'm', _vm->_moveImages[2], _vm->_moveImages[3]));
_vm->_moveGadgetList.push_back(createButton( 65, y, 2, 'o', _vm->_moveImages[4], _vm->_moveImages[5]));
_vm->_moveGadgetList.push_back(createButton( 97, y, 3, 'c', _vm->_moveImages[6], _vm->_moveImages[7]));
_vm->_moveGadgetList.push_back(createButton(129, y, 4, 'l', _vm->_moveImages[8], _vm->_moveImages[9]));
_vm->_moveGadgetList.push_back(createButton( 1, y, 0, 't', _vm->_moveImages[0], _vm->_moveImages[1]));
_vm->_moveGadgetList.push_back(createButton( 33, y, 1, 'm', _vm->_moveImages[2], _vm->_moveImages[3]));
_vm->_moveGadgetList.push_back(createButton( 65, y, 2, 'o', _vm->_moveImages[4], _vm->_moveImages[5]));
_vm->_moveGadgetList.push_back(createButton( 97, y, 3, 'c', _vm->_moveImages[6], _vm->_moveImages[7]));
_vm->_moveGadgetList.push_back(createButton(129, y, 4, 'l', _vm->_moveImages[8], _vm->_moveImages[9]));
_vm->_moveGadgetList.push_back(createButton(161, y, 5, 'i', _vm->_moveImages[12], _vm->_moveImages[13]));
_vm->_moveGadgetList.push_back(createButton(193, y, 6, VKEY_LTARROW, _vm->_moveImages[14], _vm->_moveImages[15]));
_vm->_moveGadgetList.push_back(createButton(225, y, 7, VKEY_UPARROW, _vm->_moveImages[16], _vm->_moveImages[17]));
@ -870,10 +823,10 @@ bool DisplayMan::setUpScreens() {
for (uint16 imgIdx = 0; imgIdx < 6; imgIdx++)
_vm->_invImages[imgIdx] = new Image(invFile);
}
_vm->_invGadgetList.push_back(createButton( 24, y, 0, 'm', _vm->_invImages[0], _vm->_invImages[1]));
_vm->_invGadgetList.push_back(createButton( 56, y, 1, 'g', _vm->_invImages[2], _vm->_invImages[3]));
_vm->_invGadgetList.push_back(createButton( 94, y, 2, 'u', _vm->_invImages[4], _vm->_invImages[5]));
_vm->_invGadgetList.push_back(createButton(126, y, 3, 'l', _vm->_moveImages[8], _vm->_moveImages[9]));
_vm->_invGadgetList.push_back(createButton( 24, y, 0, 'm', _vm->_invImages[0], _vm->_invImages[1]));
_vm->_invGadgetList.push_back(createButton( 56, y, 1, 'g', _vm->_invImages[2], _vm->_invImages[3]));
_vm->_invGadgetList.push_back(createButton( 94, y, 2, 'u', _vm->_invImages[4], _vm->_invImages[5]));
_vm->_invGadgetList.push_back(createButton(126, y, 3, 'l', _vm->_moveImages[8], _vm->_moveImages[9]));
_vm->_invGadgetList.push_back(createButton(164, y, 4, VKEY_LTARROW, _vm->_moveImages[14], _vm->_moveImages[15]));
_vm->_invGadgetList.push_back(createButton(196, y, 5, VKEY_RTARROW, _vm->_moveImages[18], _vm->_moveImages[19]));
@ -926,7 +879,7 @@ void DisplayMan::rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
}
void DisplayMan::rectFillScaled(uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
rectFill(VGAScaleX(x1), VGAScaleY(y1), VGAScaleX(x2), VGAScaleY(y2));
rectFill(_vm->_utils->vgaScaleX(x1), _vm->_utils->vgaScaleY(y1), _vm->_utils->vgaScaleX(x2), _vm->_utils->vgaScaleY(y2));
}
/*****************************************************************************/

View file

@ -73,11 +73,6 @@ public:
DisplayMan(LabEngine *lab);
virtual ~DisplayMan();
uint16 scaleX(uint16 x);
uint16 scaleY(uint16 y);
int16 VGAScaleX(int16 x);
int16 VGAScaleY(int16 y);
uint16 SVGACord(uint16 cord);
void loadPict(const char *filename);
void readPict(const char *filename, bool playOnce);
void freePict();

View file

@ -43,7 +43,7 @@ Common::KeyState _keyPressed;
Gadget *createButton(uint16 x, uint16 y, uint16 id, uint16 key, Image *im, Image *imalt) {
Gadget *gptr;
x = g_lab->_graphics->VGAScaleX(x);
x = g_lab->_utils->vgaScaleX(x);
if ((gptr = new Gadget())) {
gptr->x = x;

View file

@ -87,6 +87,7 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
_anim = nullptr;
_graphics = nullptr;
_rooms = nullptr;
_utils = nullptr;
_lastTooLong = false;
_interfaceOff = false;
@ -130,6 +131,7 @@ LabEngine::~LabEngine() {
delete _anim;
delete _graphics;
delete[] _rooms;
delete _utils;
for (int i = 0; i < 16; i++)
delete _tiles[i];
@ -146,6 +148,7 @@ Common::Error LabEngine::run() {
_music = new Music(this);
_graphics = new DisplayMan(this);
_anim = new Anim(this);
_utils = new Utils(this);
if (getPlatform() == Common::kPlatformWindows) {
// Check if this is the Wyrmkeep trial

View file

@ -43,6 +43,7 @@
#include "lab/anim.h"
#include "lab/graphics.h"
#include "lab/labsets.h"
#include "lab/utils.h"
struct ADGameDescription;
@ -103,6 +104,7 @@ public:
Anim *_anim;
DisplayMan *_graphics;
RoomData *_rooms;
Utils *_utils;
int _roomNum;
CrumbData _breadCrumbs[MAX_CRUMBS];
@ -179,8 +181,6 @@ private:
void mayShowCrumbIndicator();
void mayShowCrumbIndicatorOff();
const char *getInvName(uint16 curInv);
int VGAUnScaleX(int x);
int VGAUnScaleY(int y);
void mouseTile(Common::Point pos);
void changeTile(uint16 col, uint16 row);
void mouseCombination(Common::Point pos);

View file

@ -124,8 +124,8 @@ static bool loadMapData() {
counter = 0;
for (GadgetList::iterator gadget = MapGadgetList->begin(); gadget != MapGadgetList->end(); ++gadget) {
(*gadget)->x = g_lab->_graphics->VGAScaleX(MapGadX[counter]);
(*gadget)->y = g_lab->_graphics->VGAScaleY(MapGadY[counter]);
(*gadget)->x = g_lab->_utils->vgaScaleX(MapGadX[counter]);
(*gadget)->y = g_lab->_utils->vgaScaleY(MapGadY[counter]);
counter++;
}

View file

@ -18,7 +18,8 @@ MODULE_OBJS := \
savegame.o \
special.o \
tilepuzzle.o \
timing.o
timing.o \
utils.o
# This module can be built as a plugin
ifeq ($(ENABLE_LAB), DYNAMIC_PLUGIN)

View file

@ -105,8 +105,8 @@ static CloseData *getObject(uint16 x, uint16 y, CloseDataPtr lcptr) {
}
while (lcptr != NULL) {
if ((x >= g_lab->_graphics->scaleX(lcptr->x1)) && (y >= g_lab->_graphics->scaleY(lcptr->y1)) &&
(x <= g_lab->_graphics->scaleX(lcptr->x2)) && (y <= g_lab->_graphics->scaleY(lcptr->y2)))
if ((x >= g_lab->_utils->scaleX(lcptr->x1)) && (y >= g_lab->_utils->scaleY(lcptr->y1)) &&
(x <= g_lab->_utils->scaleX(lcptr->x2)) && (y <= g_lab->_utils->scaleY(lcptr->y2)))
return lcptr;
lcptr = lcptr->_nextCloseUp;
@ -248,10 +248,10 @@ void setCurClose(Common::Point pos, CloseDataPtr *cptr, bool useAbsoluteCoords)
x2 = lcptr->x2;
y2 = lcptr->y2;
} else {
x1 = g_lab->_graphics->scaleX(lcptr->x1);
y1 = g_lab->_graphics->scaleY(lcptr->y1);
x2 = g_lab->_graphics->scaleX(lcptr->x2);
y2 = g_lab->_graphics->scaleY(lcptr->y2);
x1 = g_lab->_utils->scaleX(lcptr->x1);
y1 = g_lab->_utils->scaleY(lcptr->y1);
x2 = g_lab->_utils->scaleX(lcptr->x2);
y2 = g_lab->_utils->scaleY(lcptr->y2);
}
if (pos.x >= x1 && pos.y >= y1 && pos.x <= x2 && pos.y <= y2 && lcptr->_graphicName) {
@ -279,8 +279,8 @@ bool takeItem(uint16 x, uint16 y, CloseDataPtr *cptr) {
while (lcptr != NULL) {
if ((x >= g_lab->_graphics->scaleX(lcptr->x1)) && (y >= g_lab->_graphics->scaleY(lcptr->y1)) &&
(x <= g_lab->_graphics->scaleX(lcptr->x2)) && (y <= g_lab->_graphics->scaleY(lcptr->y2)) &&
if ((x >= g_lab->_utils->scaleX(lcptr->x1)) && (y >= g_lab->_utils->scaleY(lcptr->y1)) &&
(x <= g_lab->_utils->scaleX(lcptr->x2)) && (y <= g_lab->_utils->scaleY(lcptr->y2)) &&
(lcptr->_closeUpType < 0)) {
g_lab->_conditions->inclElement(abs(lcptr->_closeUpType));
return true;
@ -410,7 +410,7 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) {
break;
case SETCLOSEUP: {
CloseDataPtr tlcptr = getObject(g_lab->_graphics->scaleX(aptr->_param1), g_lab->_graphics->scaleY(aptr->_param2), *lcptr);
CloseDataPtr tlcptr = getObject(g_lab->_utils->scaleX(aptr->_param1), g_lab->_utils->scaleY(aptr->_param2), *lcptr);
if (tlcptr)
*lcptr = tlcptr;

View file

@ -100,7 +100,7 @@ void LabEngine::doNotes() {
TextFont *noteFont = g_lab->_resource->getFont("P:Note.fon");
char *ntext = g_lab->_resource->getText("Lab:Rooms/Notes");
g_lab->_graphics->flowText(noteFont, -2 + g_lab->_graphics->SVGACord(1), 0, 0, false, false, true, true, g_lab->_graphics->VGAScaleX(25) + g_lab->_graphics->SVGACord(15), g_lab->_graphics->VGAScaleY(50), g_lab->_graphics->VGAScaleX(295) - g_lab->_graphics->SVGACord(15), g_lab->_graphics->VGAScaleY(148), ntext);
g_lab->_graphics->flowText(noteFont, -2 + g_lab->_utils->svgaCord(1), 0, 0, false, false, true, true, g_lab->_utils->vgaScaleX(25) + g_lab->_utils->svgaCord(15), g_lab->_utils->vgaScaleY(50), g_lab->_utils->vgaScaleX(295) - g_lab->_utils->svgaCord(15), g_lab->_utils->vgaScaleY(148), ntext);
g_lab->_graphics->setPalette(g_lab->_anim->_diffPalette, 256);
g_lab->_graphics->closeFont(noteFont);
@ -120,19 +120,19 @@ void LabEngine::doWestPaper() {
paperFont = g_lab->_resource->getFont("P:News22.fon");
ntext = g_lab->_resource->getText("Lab:Rooms/Date");
g_lab->_graphics->flowText(paperFont, 0, 0, 0, false, true, false, true, g_lab->_graphics->VGAScaleX(57), g_lab->_graphics->VGAScaleY(77) + g_lab->_graphics->SVGACord(2), g_lab->_graphics->VGAScaleX(262), g_lab->_graphics->VGAScaleY(91), ntext);
g_lab->_graphics->flowText(paperFont, 0, 0, 0, false, true, false, true, g_lab->_utils->vgaScaleX(57), g_lab->_utils->vgaScaleY(77) + g_lab->_utils->svgaCord(2), g_lab->_utils->vgaScaleX(262), g_lab->_utils->vgaScaleY(91), ntext);
g_lab->_graphics->closeFont(paperFont);
delete[] ntext;
paperFont = g_lab->_resource->getFont("P:News32.fon");
ntext = g_lab->_resource->getText("Lab:Rooms/Headline");
FileLen = strlen(ntext) - 1;
CharsPrinted = g_lab->_graphics->flowText(paperFont, -8, 0, 0, false, true, false, true, g_lab->_graphics->VGAScaleX(57), g_lab->_graphics->VGAScaleY(86) - g_lab->_graphics->SVGACord(2), g_lab->_graphics->VGAScaleX(262), g_lab->_graphics->VGAScaleY(118), ntext);
CharsPrinted = g_lab->_graphics->flowText(paperFont, -8, 0, 0, false, true, false, true, g_lab->_utils->vgaScaleX(57), g_lab->_utils->vgaScaleY(86) - g_lab->_utils->svgaCord(2), g_lab->_utils->vgaScaleX(262), g_lab->_utils->vgaScaleY(118), ntext);
if (CharsPrinted < FileLen) {
y = 130 - g_lab->_graphics->SVGACord(5);
g_lab->_graphics->flowText(paperFont, -8 - g_lab->_graphics->SVGACord(1), 0, 0, false, true, false, true, g_lab->_graphics->VGAScaleX(57), g_lab->_graphics->VGAScaleY(86) - g_lab->_graphics->SVGACord(2), g_lab->_graphics->VGAScaleX(262), g_lab->_graphics->VGAScaleY(132), ntext);
y = 130 - g_lab->_utils->svgaCord(5);
g_lab->_graphics->flowText(paperFont, -8 - g_lab->_utils->svgaCord(1), 0, 0, false, true, false, true, g_lab->_utils->vgaScaleX(57), g_lab->_utils->vgaScaleY(86) - g_lab->_utils->svgaCord(2), g_lab->_utils->vgaScaleX(262), g_lab->_utils->vgaScaleY(132), ntext);
} else
y = 115 - g_lab->_graphics->SVGACord(5);
y = 115 - g_lab->_utils->svgaCord(5);
g_lab->_graphics->closeFont(paperFont);
delete[] ntext;
@ -210,12 +210,12 @@ static bool loadJournalData() {
for (GadgetList::iterator gadgetIter = journalGadgetList.begin(); gadgetIter != journalGadgetList.end(); ++gadgetIter) {
Gadget *gadget = *gadgetIter;
gadget->x = g_lab->_graphics->VGAScaleX(JGadX[counter]);
gadget->x = g_lab->_utils->vgaScaleX(JGadX[counter]);
if (counter == 1)
gadget->y = g_lab->_graphics->VGAScaleY(JGadY[counter]) + g_lab->_graphics->SVGACord(1);
gadget->y = g_lab->_utils->vgaScaleY(JGadY[counter]) + g_lab->_utils->svgaCord(1);
else
gadget->y = g_lab->_graphics->VGAScaleY(JGadY[counter]) - g_lab->_graphics->SVGACord(1);
gadget->y = g_lab->_utils->vgaScaleY(JGadY[counter]) - g_lab->_utils->svgaCord(1);
gadget->_gadgetID = counter;
counter++;
@ -247,16 +247,16 @@ static void drawJournalText() {
if (JPage <= 1) {
CurText = journaltexttitle;
g_lab->_graphics->flowTextToMem(&JBackImage, journalFont, -2, 2, 0, false, true, true, true, g_lab->_graphics->VGAScaleX(52), g_lab->_graphics->VGAScaleY(32), g_lab->_graphics->VGAScaleX(152), g_lab->_graphics->VGAScaleY(148), CurText);
g_lab->_graphics->flowTextToMem(&JBackImage, journalFont, -2, 2, 0, false, true, true, true, g_lab->_utils->vgaScaleX(52), g_lab->_utils->vgaScaleY(32), g_lab->_utils->vgaScaleX(152), g_lab->_utils->vgaScaleY(148), CurText);
} else {
CurText = (char *)(journaltext + CharsDrawn);
CharsDrawn += g_lab->_graphics->flowTextToMem(&JBackImage, journalFont, -2, 2, 0, false, false, false, true, g_lab->_graphics->VGAScaleX(52), g_lab->_graphics->VGAScaleY(32), g_lab->_graphics->VGAScaleX(152), g_lab->_graphics->VGAScaleY(148), CurText);
CharsDrawn += g_lab->_graphics->flowTextToMem(&JBackImage, journalFont, -2, 2, 0, false, false, false, true, g_lab->_utils->vgaScaleX(52), g_lab->_utils->vgaScaleY(32), g_lab->_utils->vgaScaleX(152), g_lab->_utils->vgaScaleY(148), CurText);
}
g_lab->_music->updateMusic();
CurText = (char *)(journaltext + CharsDrawn);
lastpage = (*CurText == 0);
g_lab->_graphics->flowTextToMem(&JBackImage, journalFont, -2, 2, 0, false, false, false, true, g_lab->_graphics->VGAScaleX(171), g_lab->_graphics->VGAScaleY(32), g_lab->_graphics->VGAScaleX(271), g_lab->_graphics->VGAScaleY(148), CurText);
g_lab->_graphics->flowTextToMem(&JBackImage, journalFont, -2, 2, 0, false, false, false, true, g_lab->_utils->vgaScaleX(171), g_lab->_utils->vgaScaleY(32), g_lab->_utils->vgaScaleX(271), g_lab->_utils->vgaScaleY(148), CurText);
CurText = (char *)(journaltext + CharsDrawn);
lastpage = lastpage || (*CurText == 0);
@ -469,8 +469,8 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16
text += 2;
fheight = g_lab->_graphics->textHeight(monitorFont);
x1 = MonButton->_width + _graphics->VGAScaleX(3);
MonGadHeight = MonButton->_height + _graphics->VGAScaleY(3);
x1 = MonButton->_width + _utils->vgaScaleX(3);
MonGadHeight = MonButton->_height + _utils->vgaScaleY(3);
if (MonGadHeight > fheight)
yspacing = MonGadHeight - fheight;
@ -563,20 +563,20 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isintera
return;
else if ((Class == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & Qualifier)) {
if ((MouseY >= g_lab->_graphics->VGAScaleY(171)) && (MouseY <= g_lab->_graphics->VGAScaleY(200))) {
if ((MouseX >= g_lab->_graphics->VGAScaleX(259)) && (MouseX <= g_lab->_graphics->VGAScaleX(289))) {
if ((MouseY >= g_lab->_utils->vgaScaleY(171)) && (MouseY <= g_lab->_utils->vgaScaleY(200))) {
if ((MouseX >= g_lab->_utils->vgaScaleX(259)) && (MouseX <= g_lab->_utils->vgaScaleX(289))) {
if (!lastpage) {
monitorPage += 1;
drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive);
}
} else if ((MouseX >= g_lab->_graphics->VGAScaleX(0)) && (MouseX <= g_lab->_graphics->VGAScaleX(31))) {
} else if ((MouseX >= g_lab->_utils->vgaScaleX(0)) && (MouseX <= g_lab->_utils->vgaScaleX(31))) {
return;
} else if ((MouseX >= g_lab->_graphics->VGAScaleX(290)) && (MouseX <= g_lab->_graphics->VGAScaleX(320))) {
} else if ((MouseX >= g_lab->_utils->vgaScaleX(290)) && (MouseX <= g_lab->_utils->vgaScaleX(320))) {
if (monitorPage >= 1) {
monitorPage -= 1;
drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive);
}
} else if ((MouseX >= g_lab->_graphics->VGAScaleX(31)) && (MouseX <= g_lab->_graphics->VGAScaleX(59))) {
} else if ((MouseX >= g_lab->_utils->vgaScaleX(31)) && (MouseX <= g_lab->_utils->vgaScaleX(59))) {
if (isinteractive) {
monitorPage = 0;
@ -611,10 +611,10 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isintera
void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
char *ntext;
x1 = _graphics->VGAScaleX(x1);
x2 = _graphics->VGAScaleX(x2);
y1 = _graphics->VGAScaleY(y1);
y2 = _graphics->VGAScaleY(y2);
x1 = _utils->vgaScaleX(x1);
x2 = _utils->vgaScaleX(x2);
y1 = _utils->vgaScaleY(y1);
y2 = _utils->vgaScaleY(y2);
TextFileName = textfile;

View file

@ -62,32 +62,12 @@ void LabEngine::initTilePuzzle() {
_combination[i] = 0;
}
/*****************************************************************************/
/* Converts SVGA cords to VGA if necessary, otherwise returns VGA cords. */
/*****************************************************************************/
int LabEngine::VGAUnScaleX(int x) {
if (_isHiRes)
return (x / 2);
else
return x;
}
/*****************************************************************************/
/* Converts SVGA cords to VGA if necessary, otherwise returns VGA cords. */
/*****************************************************************************/
int LabEngine::VGAUnScaleY(int y) {
if (_isHiRes)
return ((y * 5) / 12);
else
return y;
}
/*****************************************************************************/
/* Processes mouse clicks and changes the combination. */
/*****************************************************************************/
void LabEngine::mouseTile(Common::Point pos) {
int x = VGAUnScaleX(pos.x);
int y = VGAUnScaleY(pos.y);
int x = _utils->vgaUnscaleX(pos.x);
int y = _utils->vgaUnscaleY(pos.y);
if ((x < 101) || (y < 26))
return;
@ -174,8 +154,8 @@ void LabEngine::changeTile(uint16 col, uint16 row) {
void LabEngine::mouseCombination(Common::Point pos) {
uint16 number;
int x = VGAUnScaleX(pos.x);
int y = VGAUnScaleY(pos.y);
int x = _utils->vgaUnscaleX(pos.x);
int y = _utils->vgaUnscaleY(pos.y);
if ((y >= 63) && (y <= 99)) {
if ((x >= 44) && (x < 83))
@ -205,20 +185,20 @@ void LabEngine::doTile(bool showsolution) {
int16 rows, cols;
if (showsolution) {
rowm = _graphics->VGAScaleY(23);
colm = _graphics->VGAScaleX(27);
rowm = _utils->vgaScaleY(23);
colm = _utils->vgaScaleX(27);
rows = _graphics->VGAScaleY(31);
cols = _graphics->VGAScaleX(105);
rows = _utils->vgaScaleY(31);
cols = _utils->vgaScaleX(105);
} else {
_graphics->setAPen(0);
_graphics->rectFillScaled(97, 22, 220, 126);
rowm = _graphics->VGAScaleY(25);
colm = _graphics->VGAScaleX(30);
rowm = _utils->vgaScaleY(25);
colm = _utils->vgaScaleX(30);
rows = _graphics->VGAScaleY(25);
cols = _graphics->VGAScaleX(100);
rows = _utils->vgaScaleY(25);
cols = _utils->vgaScaleX(100);
}
while (row < 4) {
@ -270,33 +250,33 @@ void LabEngine::doTileScroll(uint16 col, uint16 row, uint16 scrolltype) {
uint16 last = 0, x1, y1;
if (scrolltype == LEFTSCROLL) {
dX = _graphics->VGAScaleX(5);
sx = _graphics->VGAScaleX(5);
dX = _utils->vgaScaleX(5);
sx = _utils->vgaScaleX(5);
last = 6;
} else if (scrolltype == RIGHTSCROLL) {
dX = _graphics->VGAScaleX(-5);
dx = _graphics->VGAScaleX(-5);
sx = _graphics->VGAScaleX(5);
dX = _utils->vgaScaleX(-5);
dx = _utils->vgaScaleX(-5);
sx = _utils->vgaScaleX(5);
last = 6;
} else if (scrolltype == UPSCROLL) {
dY = _graphics->VGAScaleY(5);
sy = _graphics->VGAScaleY(5);
dY = _utils->vgaScaleY(5);
sy = _utils->vgaScaleY(5);
last = 5;
} else if (scrolltype == DOWNSCROLL) {
dY = _graphics->VGAScaleY(-5);
dy = _graphics->VGAScaleY(-5);
sy = _graphics->VGAScaleY(5);
dY = _utils->vgaScaleY(-5);
dy = _utils->vgaScaleY(-5);
sy = _utils->vgaScaleY(5);
last = 5;
}
sx += _graphics->SVGACord(2);
sx += _utils->svgaCord(2);
x1 = _graphics->VGAScaleX(100) + (col * _graphics->VGAScaleX(30)) + dx;
y1 = _graphics->VGAScaleY(25) + (row * _graphics->VGAScaleY(25)) + dy;
x1 = _utils->vgaScaleX(100) + (col * _utils->vgaScaleX(30)) + dx;
y1 = _utils->vgaScaleY(25) + (row * _utils->vgaScaleY(25)) + dy;
for (uint16 i = 0; i < last; i++) {
waitTOF();
scrollRaster(dX, dY, x1, y1, x1 + _graphics->VGAScaleX(28) + sx, y1 + _graphics->VGAScaleY(23) + sy);
scrollRaster(dX, dY, x1, y1, x1 + _utils->vgaScaleX(28) + sx, y1 + _utils->vgaScaleY(23) + sy);
x1 += dX;
y1 += dY;
}
@ -331,8 +311,8 @@ void LabEngine::changeCombination(uint16 number) {
waitTOF();
display._imageData = _graphics->getCurrentDrawingBuffer();
_graphics->scrollDisplayY(2, _graphics->VGAScaleX(COMBINATION_X[number]), _graphics->VGAScaleY(65), _graphics->VGAScaleX(COMBINATION_X[number]) + (_numberImages[combnum])->_width - 1, _graphics->VGAScaleY(65) + (_numberImages[combnum])->_height);
_numberImages[combnum]->blitBitmap(0, (_numberImages[combnum])->_height - (2 * i), &(display), _graphics->VGAScaleX(COMBINATION_X[number]), _graphics->VGAScaleY(65), (_numberImages[combnum])->_width, 2, false);
_graphics->scrollDisplayY(2, _utils->vgaScaleX(COMBINATION_X[number]), _utils->vgaScaleY(65), _utils->vgaScaleX(COMBINATION_X[number]) + (_numberImages[combnum])->_width - 1, _utils->vgaScaleY(65) + (_numberImages[combnum])->_height);
_numberImages[combnum]->blitBitmap(0, (_numberImages[combnum])->_height - (2 * i), &(display), _utils->vgaScaleX(COMBINATION_X[number]), _utils->vgaScaleY(65), (_numberImages[combnum])->_width, 2, false);
}
for (uint16 i = 0; i < 6; i++)
@ -357,7 +337,7 @@ void LabEngine::scrollRaster(int16 dx, int16 dy, uint16 x1, uint16 y1, uint16 x2
/*****************************************************************************/
void LabEngine::doCombination() {
for (uint16 i = 0; i <= 5; i++)
_numberImages[_combination[i]]->drawImage(_graphics->VGAScaleX(COMBINATION_X[i]), _graphics->VGAScaleY(65));
_numberImages[_combination[i]]->drawImage(_utils->vgaScaleX(COMBINATION_X[i]), _utils->vgaScaleY(65));
}
/*****************************************************************************/

413
engines/lab/utils.cpp Normal file
View file

@ -0,0 +1,413 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
/*
* This code is based on Labyrinth of Time code with assistance of
*
* Copyright (c) 1993 Terra Nova Development
* Copyright (c) 2004 The Wyrmkeep Entertainment Co.
*
*/
#include "lab/lab.h"
#include "lab/utils.h"
namespace Lab {
Utils::Utils(LabEngine *vm) : _vm(vm) {
_dataBytesPerRow = 0;
}
/*****************************************************************************/
/* Scales the x co-ordinates to that of the new display. In the room parser */
/* file, co-ordinates are set up on a 360x336 display. */
/*****************************************************************************/
uint16 Utils::scaleX(uint16 x) {
if (_vm->_isHiRes)
return (uint16)((x * 16) / 9);
else
return (uint16)((x * 8) / 9);
}
/*****************************************************************************/
/* Scales the y co-ordinates to that of the new display. In the room parser */
/* file, co-ordinates are set up on a 368x336 display. */
/*****************************************************************************/
uint16 Utils::scaleY(uint16 y) {
if (_vm->_isHiRes)
return (y + (y / 14));
else
return ((y * 10) / 24);
}
/*****************************************************************************/
/* Scales the VGA cords to SVGA if necessary; otherwise, returns VGA cords. */
/*****************************************************************************/
int16 Utils::vgaScaleX(int16 x) {
if (_vm->_isHiRes)
return (x * 2);
else
return x;
}
/*****************************************************************************/
/* Scales the VGA cords to SVGA if necessary; otherwise, returns VGA cords. */
/*****************************************************************************/
int16 Utils::vgaScaleY(int16 y) {
if (_vm->_isHiRes)
return ((y * 12) / 5);
else
return y;
}
uint16 Utils::svgaCord(uint16 cord) {
if (_vm->_isHiRes)
return cord;
else
return 0;
}
/*****************************************************************************/
/* Converts SVGA cords to VGA if necessary, otherwise returns VGA cords. */
/*****************************************************************************/
int Utils::vgaUnscaleX(int x) {
if (_vm->_isHiRes)
return (x / 2);
else
return x;
}
/*****************************************************************************/
/* Converts SVGA cords to VGA if necessary, otherwise returns VGA cords. */
/*****************************************************************************/
int Utils::vgaUnscaleY(int y) {
if (_vm->_isHiRes)
return ((y * 5) / 12);
else
return y;
}
/*****************************************************************************/
/* Undiffs a piece of memory when header size is a byte, and copy/skip size */
/* is also a byte. */
/*****************************************************************************/
void Utils::unDiffByteByte(byte *dest, byte *diff) {
uint16 skip, copy;
while (1) {
skip = *diff;
diff++;
copy = *diff;
diff++;
if (skip == 255) {
if (copy == 0) {
skip = READ_LE_UINT16(diff);
diff += 2;
copy = READ_LE_UINT16(diff);
diff += 2;
} else if (copy == 255)
return;
}
dest += skip;
memcpy(dest, diff, copy);
dest += copy;
diff += copy;
}
}
/*****************************************************************************/
/* Undiffs a piece of memory when header size is a byte, and copy/skip size */
/* is a word. */
/*****************************************************************************/
void Utils::unDiffByteWord(uint16 *dest, uint16 *diff) {
uint16 skip, copy;
while (1) {
skip = ((byte *)diff)[0];
copy = ((byte *)diff)[1];
diff++;
if (skip == 255) {
if (copy == 0) {
skip = READ_LE_UINT16(diff);
diff++;
copy = READ_LE_UINT16(diff);
diff++;
} else if (copy == 255)
return;
}
dest += skip;
while (copy > 3) {
*dest = READ_LE_UINT16(diff);
dest++;
diff++;
*dest = READ_LE_UINT16(diff);
dest++;
diff++;
*dest = READ_LE_UINT16(diff);
dest++;
diff++;
*dest = READ_LE_UINT16(diff);
dest++;
diff++;
copy -= 4;
}
while (copy) {
*dest = READ_LE_UINT16(diff);
dest++;
diff++;
copy--;
}
}
}
/*------------------------- unDiff Vertical Memory --------------------------*/
/*****************************************************************************/
/* Undiffs a piece of memory when header size is a byte, and copy/skip size */
/* is a byte. */
/*****************************************************************************/
void Utils::VUnDiffByteByte(byte *dest, byte *diff, uint16 bytesPerRow) {
byte *curPtr;
uint16 skip, copy;
uint16 counter = 0;
while (counter < _dataBytesPerRow) {
curPtr = dest + counter;
for (;;) {
skip = *diff;
diff++;
copy = *diff;
diff++;
if (skip == 255) {
counter += copy;
break;
}
else {
curPtr += (skip * bytesPerRow);
while (copy) {
copy--;
*curPtr = *diff;
curPtr += bytesPerRow;
diff++;
}
}
}
}
}
/*****************************************************************************/
/* Undiffs a piece of memory when header size is a byte, and copy/skip size */
/* is a word. */
/*****************************************************************************/
void Utils::VUnDiffByteWord(uint16 *dest, uint16 *diff, uint16 bytesPerRow) {
uint16 *curPtr;
uint16 skip, copy;
uint16 counter = 0;
uint16 wordsPerRow = bytesPerRow / 2;
while (counter < (_dataBytesPerRow >> 1)) {
curPtr = dest + counter;
for (;;) {
skip = ((byte *)diff)[0];
copy = ((byte *)diff)[1];
diff++;
if (skip == 255) {
counter += copy;
break;
}
else {
curPtr += (skip * wordsPerRow);
while (copy) {
*curPtr = *diff; //swapUShort(*diff);
curPtr += wordsPerRow;
diff++;
copy--;
}
}
}
}
}
/*****************************************************************************/
/* Undiffs a piece of memory when header size is a byte, and copy/skip size */
/* is a long. */
/*****************************************************************************/
void Utils::VUnDiffByteLong(uint32 *dest, uint32 *diff, uint16 bytesPerRow) {
uint32 *_curPtr;
uint16 skip, copy;
uint16 counter = 0;
byte *diff1 = (byte *)diff;
uint16 longsperrow = bytesPerRow / 4;
while (counter < (_dataBytesPerRow >> 2)) {
_curPtr = dest + counter;
for (;;) {
skip = *diff1;
diff1++;
copy = *diff1;
diff1++;
if (skip == 255) {
counter += copy;
break;
}
else {
_curPtr += (skip * longsperrow);
while (copy) {
*_curPtr = *(uint32 *)diff1; //swapULong(*diff);
_curPtr += longsperrow;
diff1 += 4;
copy--;
}
}
}
}
}
/*****************************************************************************/
/* Runlength decodes a chunk of memory. */
/*****************************************************************************/
void Utils::runLengthDecode(byte *dest, byte *source) {
int8 num;
int16 count;
while (1) {
num = (int8)*source;
source++;
if (num == 127) {
return;
} else if (num > '\0') {
memcpy(dest, source, num);
source += num;
dest += num;
} else {
count = (int16)(-num);
num = *source;
source++;
while (count) {
*dest = num;
dest++;
count--;
}
}
}
}
/*****************************************************************************/
/* Does a vertical run length decode. */
/*****************************************************************************/
void Utils::VRunLengthDecode(byte *dest, byte *source, uint16 bytesPerRow) {
int8 num;
int16 count;
byte *top = dest;
for (uint16 i = 0; i < _dataBytesPerRow; i++) {
dest = top;
dest += i;
num = (int8)*source;
source++;
while (num != 127) {
if (num > '\0') {
while (num) {
*dest = *source;
source++;
dest += bytesPerRow;
num--;
}
} else {
count = (int16)(-num);
num = (int8)*source;
source++;
while (count) {
*dest = num;
dest += bytesPerRow;
count--;
}
}
num = *source;
source++;
}
}
}
/*****************************************************************************/
/* Does the undiffing between the bitmaps. */
/*****************************************************************************/
void Utils::unDiff(byte *newBuf, byte *oldBuf, byte *diffData, uint16 bytesPerRow, bool isV) {
diffData++;
byte bufType = *diffData;
diffData++;
if (isV) {
if (bufType == 0)
VUnDiffByteByte(newBuf, diffData, bytesPerRow);
else if (bufType == 1)
VUnDiffByteWord((uint16 *)newBuf, (uint16 *)diffData, bytesPerRow);
else if (bufType == 3)
VUnDiffByteLong((uint32 *)newBuf, (uint32 *)diffData, bytesPerRow);
} else {
if (bufType == 0)
unDiffByteByte(newBuf, diffData);
else if (bufType == 1)
unDiffByteWord((uint16 *)newBuf, (uint16 *)diffData);
}
}
void Utils::setBytesPerRow(int num) {
_dataBytesPerRow = num;
}
} // End of namespace Lab

66
engines/lab/utils.h Normal file
View file

@ -0,0 +1,66 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
/*
* This code is based on Labyrinth of Time code with assistance of
*
* Copyright (c) 1993 Terra Nova Development
* Copyright (c) 2004 The Wyrmkeep Entertainment Co.
*
*/
#ifndef LAB_UTILS_H
#define LAB_UTILS_H
namespace Lab {
class Utils {
private:
LabEngine *_vm;
uint16 _dataBytesPerRow;
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);
public:
Utils(LabEngine *vm);
uint16 scaleX(uint16 x);
uint16 scaleY(uint16 y);
int16 vgaScaleX(int16 x);
int16 vgaScaleY(int16 y);
uint16 svgaCord(uint16 cord);
int vgaUnscaleX(int x);
int vgaUnscaleY(int y);
void unDiff(byte *newBuf, byte *oldBuf, byte *diffData, uint16 bytesperrow, bool isV);
void runLengthDecode(byte *dest, byte *source);
void VRunLengthDecode(byte *dest, byte *source, uint16 bytesPerRow);
void setBytesPerRow(int num);
};
} // End of namespace Lab
#endif // LAB_UTILS_H