diff options
-rw-r--r-- | engines/lab/anim.cpp | 6 | ||||
-rw-r--r-- | engines/lab/engine.cpp | 12 | ||||
-rw-r--r-- | engines/lab/eventman.cpp | 12 | ||||
-rw-r--r-- | engines/lab/graphics.cpp | 273 | ||||
-rw-r--r-- | engines/lab/graphics.h | 15 | ||||
-rw-r--r-- | engines/lab/image.cpp | 18 | ||||
-rw-r--r-- | engines/lab/interface.cpp | 2 | ||||
-rw-r--r-- | engines/lab/intro.cpp | 6 | ||||
-rw-r--r-- | engines/lab/lab.cpp | 10 | ||||
-rw-r--r-- | engines/lab/lab.h | 19 | ||||
-rw-r--r-- | engines/lab/labfun.h | 1 | ||||
-rw-r--r-- | engines/lab/map.cpp | 29 | ||||
-rw-r--r-- | engines/lab/processroom.cpp | 4 | ||||
-rw-r--r-- | engines/lab/special.cpp | 42 | ||||
-rw-r--r-- | engines/lab/text.cpp | 8 | ||||
-rw-r--r-- | engines/lab/tilepuzzle.cpp | 20 | ||||
-rw-r--r-- | engines/lab/vga.cpp | 141 |
17 files changed, 304 insertions, 314 deletions
diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp index f7770ade7b..edf677b670 100644 --- a/engines/lab/anim.cpp +++ b/engines/lab/anim.cpp @@ -424,7 +424,7 @@ void Anim::diffNextFrame() { return; if (DispBitMap->_flags & BITMAPF_VIDEO) { - DispBitMap->_planes[0] = _vm->getCurrentDrawingBuffer(); + 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; @@ -444,7 +444,7 @@ void Anim::diffNextFrame() { } if (_isPal && !_noPalChange) { - _vm->setPalette(_diffPalette, 256); + _vm->_graphics->setPalette(_diffPalette, 256); _isPal = false; } @@ -452,7 +452,7 @@ void Anim::diffNextFrame() { } if (_isPal && !_noPalChange && !_isBM && !_donePal) { - _vm->setPalette(_diffPalette, 256); + _vm->_graphics->setPalette(_diffPalette, 256); _isPal = false; } diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp index b6e6f7282b..a986807a1f 100644 --- a/engines/lab/engine.cpp +++ b/engines/lab/engine.cpp @@ -296,7 +296,7 @@ bool LabEngine::doUse(uint16 CurInv) { _curFileName = " "; _cptr = NULL; doMap(_roomNum); - setPalette(initcolors, 8); + _graphics->setPalette(initcolors, 8); _graphics->drawMessage(NULL); _graphics->drawPanel(); } else if (CurInv == JOURNALNUM) { /* LAB: Labyrinth specific */ @@ -400,7 +400,7 @@ void LabEngine::mainGameLoop() { bool forceDraw = false, GotMessage = true; - setPalette(initcolors, 8); + _graphics->setPalette(initcolors, 8); _cptr = NULL; _roomNum = 1; @@ -843,14 +843,10 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm if (doit) { _graphics->drawMessage("Disk operation failed."); - setPalette(initcolors, 8); - - _graphics->screenUpdate(); - + _graphics->setPalette(initcolors, 8); g_system->delayMillis(1000); - } else { - _graphics->screenUpdate(); } + _graphics->screenUpdate(); } else if (gadgetId == 1) { if (!doUse(curInv)) { Old = actionMode; diff --git a/engines/lab/eventman.cpp b/engines/lab/eventman.cpp index 6b73de79b5..0b3f71eb63 100644 --- a/engines/lab/eventman.cpp +++ b/engines/lab/eventman.cpp @@ -299,8 +299,9 @@ void EventManager::processInput(bool can_delay) { _mousePos.x = 0; _mouseAtEdge = true; } - if (_mousePos.x > _vm->_screenWidth - 1) { - _mousePos.x = _vm->_screenWidth; + + if (_mousePos.x >= _vm->_graphics->_screenWidth) { + _mousePos.x = _vm->_graphics->_screenWidth; _mouseAtEdge = true; } @@ -309,8 +310,9 @@ void EventManager::processInput(bool can_delay) { _mousePos.y = 0; _mouseAtEdge = true; } - if (_mousePos.y > _vm->_screenHeight - 1) { - _mousePos.y = _vm->_screenHeight; + + if (_mousePos.y >= _vm->_graphics->_screenHeight) { + _mousePos.y = _vm->_graphics->_screenHeight; _mouseAtEdge = true; } @@ -350,7 +352,7 @@ void EventManager::processInput(bool can_delay) { break; } - g_system->copyRectToScreen(_vm->_displayBuffer, _vm->_screenWidth, 0, 0, _vm->_screenWidth, _vm->_screenHeight); + g_system->copyRectToScreen(_vm->_graphics->_displayBuffer, _vm->_graphics->_screenWidth, 0, 0, _vm->_graphics->_screenWidth, _vm->_graphics->_screenHeight); g_system->updateScreen(); } } diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp index 3ed28d06f3..a10512df55 100644 --- a/engines/lab/graphics.cpp +++ b/engines/lab/graphics.cpp @@ -48,7 +48,16 @@ DisplayMan::DisplayMan(LabEngine *vm) : _vm(vm) { _screenBytesPerPage = 65536; _curapen = 0; - _curBitmap = NULL; + _curBitmap = nullptr; + _displayBuffer = nullptr; + _currentDisplayBuffer = nullptr; + _tempScrollData = nullptr; + + _screenWidth = 0; + _screenHeight = 0; + + for (int i = 0; i < 256 * 3; i++) + _curvgapal[i] = 0; } DisplayMan::~DisplayMan() { @@ -129,8 +138,8 @@ bool DisplayMan::readPict(const char *filename, bool playOnce) { if (!_vm->_music->_doNotFilestopSoundEffect) _vm->_music->stopSoundEffect(); - DispBitMap->_bytesPerRow = _vm->_screenWidth; - DispBitMap->_rows = _vm->_screenHeight; + DispBitMap->_bytesPerRow = _screenWidth; + DispBitMap->_rows = _screenHeight; DispBitMap->_flags = BITMAPF_VIDEO; _vm->_anim->readDiff(_curBitmap, playOnce); @@ -343,15 +352,15 @@ uint32 DisplayMan::flowTextToMem(Image *destIm, void *font, /* the TextAttr uint16 x1, /* Cords */ uint16 y1, uint16 x2, uint16 y2, const char *str) { /* The text itself */ uint32 res, vgabyte = _screenBytesPerPage; - byte *tmp = _vm->_currentDisplayBuffer; + byte *tmp = _currentDisplayBuffer; - _vm->_currentDisplayBuffer = destIm->_imageData; + _currentDisplayBuffer = destIm->_imageData; _screenBytesPerPage = (uint32)destIm->_width * (int32)destIm->_height; - res = _vm->_graphics->flowText(font, spacing, pencolor, backpen, fillback, centerh, centerv, output, x1, y1, x2, y2, str); + res = flowText(font, spacing, pencolor, backpen, fillback, centerh, centerv, output, x1, y1, x2, y2, str); _screenBytesPerPage = vgabyte; - _vm->_currentDisplayBuffer = tmp; + _currentDisplayBuffer = tmp; return res; } @@ -391,10 +400,6 @@ int32 DisplayMan::longDrawMessage(const char *str) { return flowTextScaled(_vm->_msgFont, 0, 1, 7, false, true, true, true, 6, 155, 313, 195, str); } -void LabEngine::drawStaticMessage(byte index) { - _graphics->drawMessage(_resource->getStaticText((StaticText)index).c_str()); -} - /******************************************************************************/ /* Draws a message to the message box. */ /******************************************************************************/ @@ -442,7 +447,7 @@ void DisplayMan::doScrollBlack() { byte *tempmem; Image im; uint32 size, copysize; - uint32 *baseAddr; + byte *baseAddr; uint16 width = VGAScaleX(320); uint16 height = VGAScaleY(149) + SVGACord(2); byte *mem = new byte[width * height]; @@ -456,7 +461,7 @@ void DisplayMan::doScrollBlack() { im.readScreenImage(0, 0); _vm->_music->updateMusic(); - baseAddr = (uint32 *)_vm->getCurrentDrawingBuffer(); + baseAddr = getCurrentDrawingBuffer(); uint16 by = VGAScaleX(4); uint16 nheight = height; @@ -467,7 +472,7 @@ void DisplayMan::doScrollBlack() { if (!_vm->_isHiRes) _vm->waitTOF(); - baseAddr = (uint32 *)_vm->getCurrentDrawingBuffer(); + baseAddr = getCurrentDrawingBuffer(); if (by > nheight) by = nheight; @@ -510,20 +515,17 @@ void DisplayMan::doScrollBlack() { } void DisplayMan::copyPage(uint16 width, uint16 height, uint16 nheight, uint16 startline, byte *mem) { - uint32 size, offSet, copysize; - uint16 curPage; - uint32 *baseAddr; + byte *baseAddr = getCurrentDrawingBuffer(); - baseAddr = (uint32 *)_vm->getCurrentDrawingBuffer(); - - size = (int32)(height - nheight) * (int32)width; + uint32 size = (int32)(height - nheight) * (int32)width; mem += startline * width; - curPage = ((int32)nheight * (int32)width) / _vm->_graphics->_screenBytesPerPage; - offSet = ((int32)nheight * (int32)width) - (curPage * _vm->_graphics->_screenBytesPerPage); + uint16 curPage = ((int32)nheight * (int32)width) / _screenBytesPerPage; + uint32 offSet = ((int32)nheight * (int32)width) - (curPage * _screenBytesPerPage); while (size) { - if (size > (_vm->_graphics->_screenBytesPerPage - offSet)) - copysize = _vm->_graphics->_screenBytesPerPage - offSet; + uint32 copysize; + if (size > (_screenBytesPerPage - offSet)) + copysize = _screenBytesPerPage - offSet; else copysize = size; @@ -553,7 +555,7 @@ void DisplayMan::doScrollWipe(char *filename) { _vm->_anim->_isBM = true; readPict(filename, true); - _vm->setPalette(_vm->_anim->_diffPalette, 256); + setPalette(_vm->_anim->_diffPalette, 256); _vm->_anim->_isBM = false; byte *mem = _vm->_anim->_rawDiffBM._planes[0]; @@ -664,7 +666,7 @@ void DisplayMan::doTransWipe(CloseDataPtr *cPtr, char *filename) { linesdone = 0; } - _vm->overlayRect(0, 0, curY, _vm->_screenWidth - 1, curY + 1); + overlayRect(0, 0, curY, _screenWidth - 1, curY + 1); curY += 4; linesdone++; } @@ -682,7 +684,7 @@ void DisplayMan::doTransWipe(CloseDataPtr *cPtr, char *filename) { linesdone = 0; } - rectFill(0, curY, _vm->_screenWidth - 1, curY + 1); + rectFill(0, curY, _screenWidth - 1, curY + 1); curY += 4; linesdone++; } @@ -695,17 +697,17 @@ void DisplayMan::doTransWipe(CloseDataPtr *cPtr, char *filename) { else _vm->_curFileName = getPictName(cPtr); - byte *BitMapMem = readPictToMem(_vm->_curFileName, _vm->_screenWidth, lastY + 5); - _vm->setPalette(_vm->_anim->_diffPalette, 256); + byte *BitMapMem = readPictToMem(_vm->_curFileName, _screenWidth, lastY + 5); + setPalette(_vm->_anim->_diffPalette, 256); if (BitMapMem) { - imSource._width = _vm->_screenWidth; + imSource._width = _screenWidth; imSource._height = lastY; imSource._imageData = BitMapMem; - imDest._width = _vm->_screenWidth; - imDest._height = _vm->_screenHeight; - imDest._imageData = _vm->getCurrentDrawingBuffer(); + imDest._width = _screenWidth; + imDest._height = _screenHeight; + imDest._imageData = getCurrentDrawingBuffer(); for (uint16 i = 0; i < 2; i++) { curY = i * 2; @@ -717,10 +719,10 @@ void DisplayMan::doTransWipe(CloseDataPtr *cPtr, char *filename) { linesdone = 0; } - imDest._imageData = _vm->getCurrentDrawingBuffer(); + imDest._imageData = getCurrentDrawingBuffer(); - imSource.blitBitmap(0, curY, &imDest, 0, curY, _vm->_screenWidth, 2, false); - _vm->overlayRect(0, 0, curY, _vm->_screenWidth - 1, curY + 1); + imSource.blitBitmap(0, curY, &imDest, 0, curY, _screenWidth, 2, false); + overlayRect(0, 0, curY, _screenWidth - 1, curY + 1); curY += 4; linesdone++; } @@ -736,12 +738,12 @@ void DisplayMan::doTransWipe(CloseDataPtr *cPtr, char *filename) { linesdone = 0; } - imDest._imageData = _vm->getCurrentDrawingBuffer(); + imDest._imageData = getCurrentDrawingBuffer(); if (curY == lastY) - imSource.blitBitmap(0, curY, &imDest, 0, curY, _vm->_screenWidth, 1, false); + imSource.blitBitmap(0, curY, &imDest, 0, curY, _screenWidth, 1, false); else - imSource.blitBitmap(0, curY, &imDest, 0, curY, _vm->_screenWidth, 2, false); + imSource.blitBitmap(0, curY, &imDest, 0, curY, _screenWidth, 2, false); curY += 4; linesdone++; @@ -774,7 +776,7 @@ void DisplayMan::doWipe(uint16 wipeType, CloseDataPtr *cPtr, char *filename) { void DisplayMan::blackScreen() { byte pal[256 * 3]; memset(pal, 0, 248 * 3); - _vm->writeColorRegs(pal, 8, 248); + writeColorRegs(pal, 8, 248); g_system->delayMillis(32); } @@ -785,7 +787,7 @@ void DisplayMan::blackScreen() { void DisplayMan::whiteScreen() { byte pal[256 * 3]; memset(pal, 255, 248 * 3); - _vm->writeColorRegs(pal, 8, 248); + writeColorRegs(pal, 8, 248); } /*****************************************************************************/ @@ -794,7 +796,7 @@ void DisplayMan::whiteScreen() { void DisplayMan::blackAllScreen() { byte pal[256 * 3]; memset(pal, 0, 256 * 3); - _vm->writeColorRegs(pal, 0, 256); + writeColorRegs(pal, 0, 256); g_system->delayMillis(32); } @@ -938,14 +940,14 @@ void DisplayMan::rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2) { int w = x2 - x1 + 1; int h = y2 - y1 + 1; - if (x1 + w > _vm->_screenWidth) - w = _vm->_screenWidth - x1; + if (x1 + w > _screenWidth) + w = _screenWidth - x1; - if (y1 + h > _vm->_screenHeight) - h = _vm->_screenHeight - y1; + if (y1 + h > _screenHeight) + h = _screenHeight - y1; if ((w > 0) && (h > 0)) { - char *d = (char *)_vm->getCurrentDrawingBuffer() + y1 * _vm->_screenWidth + x1; + char *d = (char *)getCurrentDrawingBuffer() + y1 * _screenWidth + x1; while (h-- > 0) { char *dd = d; @@ -955,7 +957,7 @@ void DisplayMan::rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2) { *dd++ = _curapen; } - d += _vm->_screenWidth; + d += _screenWidth; } } } @@ -979,7 +981,7 @@ void DisplayMan::drawHLine(uint16 x1, uint16 y, uint16 x2) { } void DisplayMan::screenUpdate() { - g_system->copyRectToScreen(_vm->_displayBuffer, _vm->_screenWidth, 0, 0, _vm->_screenWidth, _vm->_screenHeight); + g_system->copyRectToScreen(_displayBuffer, _screenWidth, 0, 0, _screenWidth, _screenHeight); g_system->updateScreen(); _vm->_event->processInput(); @@ -990,17 +992,176 @@ void DisplayMan::screenUpdate() { /*****************************************************************************/ bool DisplayMan::createScreen(bool hiRes) { if (hiRes) { - _vm->_screenWidth = 640; - _vm->_screenHeight = 480; + _screenWidth = 640; + _screenHeight = 480; } else { - _vm->_screenWidth = 320; - _vm->_screenHeight = 200; + _screenWidth = 320; + _screenHeight = 200; } - _screenBytesPerPage = _vm->_screenWidth * _vm->_screenHeight; - - _vm->_displayBuffer = new byte[_screenBytesPerPage]; // FIXME: Memory leak! + _screenBytesPerPage = _screenWidth * _screenHeight; + _displayBuffer = new byte[_screenBytesPerPage]; // FIXME: Memory leak! return true; } +/*****************************************************************************/ +/* Converts an Amiga palette (up to 16 colors) to a VGA palette, then sets */ +/* the VGA palette. */ +/*****************************************************************************/ +void DisplayMan::setAmigaPal(uint16 *pal, uint16 numColors) { + byte vgaPal[16 * 3]; + uint16 vgaIdx = 0; + + if (numColors > 16) + numColors = 16; + + for (uint16 i = 0; i < numColors; i++) { + vgaPal[vgaIdx++] = (byte)(((pal[i] & 0xf00) >> 8) << 2); + vgaPal[vgaIdx++] = (byte)(((pal[i] & 0x0f0) >> 4) << 2); + vgaPal[vgaIdx++] = (byte)(((pal[i] & 0x00f)) << 2); + } + + writeColorRegs(vgaPal, 0, 16); + _vm->waitTOF(); +} + +/*****************************************************************************/ +/* Writes any number of the 256 color registers. */ +/* first: the number of the first color register to write. */ +/* numreg: the number of registers to write */ +/* buf: a char pointer which contains the selected color registers. */ +/* Each value representing a color register occupies 3 bytes in */ +/* the array. The order is red, green then blue. The first byte */ +/* in the array is the red component of the first element selected.*/ +/* The length of the buffer is 3 times the number of registers */ +/* selected. */ +/*****************************************************************************/ +void DisplayMan::writeColorRegs(byte *buf, uint16 first, uint16 numreg) { + byte tmp[256 * 3]; + + for (int i = 0; i < 256 * 3; i++) { + tmp[i] = buf[i] * 4; + } + + g_system->getPaletteManager()->setPalette(tmp, first, numreg); + + memcpy(&(_curvgapal[first * 3]), buf, numreg * 3); +} + +void DisplayMan::setPalette(void *cmap, uint16 numcolors) { + if (memcmp(cmap, _curvgapal, numcolors * 3) != 0) + writeColorRegs((byte *)cmap, 0, numcolors); +} + +/*****************************************************************************/ +/* Returns the base address of the current VGA display. */ +/*****************************************************************************/ +byte *DisplayMan::getCurrentDrawingBuffer() { + if (_currentDisplayBuffer) + return _currentDisplayBuffer; + + return _displayBuffer; +} + +/*****************************************************************************/ +/* Overlays a region on the screen using the desired pen color. */ +/*****************************************************************************/ +void DisplayMan::overlayRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, uint16 y2) { + int w = x2 - x1 + 1; + int h = y2 - y1 + 1; + + if (x1 + w > _screenWidth) + w = _screenWidth - x1; + + if (y1 + h > _screenHeight) + h = _screenHeight - y1; + + if ((w > 0) && (h > 0)) { + char *d = (char *)getCurrentDrawingBuffer() + y1 * _screenWidth + x1; + + while (h-- > 0) { + char *dd = d; + int ww = w; + + if (y1 & 1) { + dd++; + ww--; + } + + while (ww > 0) { + *dd = pencolor; + dd += 2; + ww -= 2; + } + + d += _screenWidth; + y1++; + } + } +} + +/*****************************************************************************/ +/* Scrolls the display in the x direction by blitting. */ +/* The _tempScrollData variable must be initialized to some memory, or this */ +/* function will fail. */ +/*****************************************************************************/ +void DisplayMan::scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 y2) { + Image im; + uint16 temp; + + im._imageData = _tempScrollData; + + if (x1 > x2) { + temp = x2; + x2 = x1; + x1 = temp; + } + + if (y1 > y2) { + temp = y2; + y2 = y1; + y1 = temp; + } + + im._width = x2 - x1 + 1 - dx; + im._height = y2 - y1 + 1; + + im.readScreenImage(x1, y1); + im.drawImage(x1 + dx, y1); + + setAPen(0); + rectFill(x1, y1, x1 + dx - 1, y2); +} + +/*****************************************************************************/ +/* Scrolls the display in the y direction by blitting. */ +/*****************************************************************************/ +void DisplayMan::scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2) { + Image im; + uint16 temp; + + im._imageData = _tempScrollData; + + if (x1 > x2) { + temp = x2; + x2 = x1; + x1 = temp; + } + + if (y1 > y2) { + temp = y2; + y2 = y1; + y1 = temp; + } + + im._width = x2 - x1 + 1; + im._height = y2 - y1 + 1 - dy; + + im.readScreenImage(x1, y1); + im.drawImage(x1, y1 + dy); + + setAPen(0); + rectFill(x1, y1, x2, y1 + dy - 1); +} + } // End of namespace Lab diff --git a/engines/lab/graphics.h b/engines/lab/graphics.h index ba3e34c4e5..4a69a599dd 100644 --- a/engines/lab/graphics.h +++ b/engines/lab/graphics.h @@ -31,6 +31,8 @@ #ifndef LAB_GRAPHICS_H #define LAB_GRAPHICS_H +#include "graphics/palette.h" + namespace Lab { class LabEngine; @@ -41,6 +43,8 @@ private: byte _curapen; byte *_curBitmap; + byte _curvgapal[256 * 3]; + byte *_tempScrollData; public: DisplayMan(LabEngine *lab); @@ -114,10 +118,21 @@ public: void drawVLine(uint16 x1, uint16 y, uint16 x2); void screenUpdate(); bool createScreen(bool HiRes); + void setAmigaPal(uint16 *pal, uint16 numColors); + void writeColorRegs(byte *buf, uint16 first, uint16 numreg); + void setPalette(void *cmap, uint16 numcolors); + void overlayRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, uint16 y2); + byte *getCurrentDrawingBuffer(); + void scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 y2); + void scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2); bool _longWinInFront; bool _lastMessageLong; uint32 _screenBytesPerPage; + int _screenWidth; + int _screenHeight; + byte *_displayBuffer; + byte *_currentDisplayBuffer; }; } // End of namespace Lab diff --git a/engines/lab/image.cpp b/engines/lab/image.cpp index 45377aceda..ab63e96def 100644 --- a/engines/lab/image.cpp +++ b/engines/lab/image.cpp @@ -56,9 +56,9 @@ void Image::blitBitmap(uint16 xs, uint16 ys, Image *imDest, uint16 xd, uint16 yd, uint16 width, uint16 height, byte masked) { int w = width; int h = height; - int destWidth = (imDest) ? imDest->_width : g_lab->_screenWidth; - int destHeight = (imDest) ? imDest->_height : g_lab->_screenHeight; - byte *destBuffer = (imDest) ? imDest->_imageData : g_lab->getCurrentDrawingBuffer(); + int destWidth = (imDest) ? imDest->_width : g_lab->_graphics->_screenWidth; + int destHeight = (imDest) ? imDest->_height : g_lab->_graphics->_screenHeight; + byte *destBuffer = (imDest) ? imDest->_imageData : g_lab->_graphics->getCurrentDrawingBuffer(); if (xd + w > destWidth) w = destWidth - xd; @@ -117,20 +117,20 @@ void Image::readScreenImage(uint16 x, uint16 y) { int w = _width; int h = _height; - if (x + w > g_lab->_screenWidth) - w = g_lab->_screenWidth - x; + if (x + w > g_lab->_graphics->_screenWidth) + w = g_lab->_graphics->_screenWidth - x; - if (y + h > g_lab->_screenHeight) - h = g_lab->_screenHeight - y; + if (y + h > g_lab->_graphics->_screenHeight) + h = g_lab->_graphics->_screenHeight - y; if ((w > 0) && (h > 0)) { byte *s = _imageData; - byte *d = g_lab->getCurrentDrawingBuffer() + y * g_lab->_screenWidth + x; + byte *d = g_lab->_graphics->getCurrentDrawingBuffer() + y * g_lab->_graphics->_screenWidth + x; while (h-- > 0) { memcpy(s, d, w); s += _width; - d += g_lab->_screenWidth; + d += g_lab->_graphics->_screenWidth; } } } diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp index 30aa5472a1..61cfc6c365 100644 --- a/engines/lab/interface.cpp +++ b/engines/lab/interface.cpp @@ -95,7 +95,7 @@ void drawGadgetList(Gadget *gadlist) { /* Dims a gadget, and makes it unavailable for using. */ /*****************************************************************************/ void disableGadget(Gadget *curgad, uint16 pencolor) { - g_lab->overlayRect(pencolor, curgad->x, curgad->y, curgad->x + curgad->_image->_width - 1, curgad->y + curgad->_image->_height - 1); + g_lab->_graphics->overlayRect(pencolor, curgad->x, curgad->y, curgad->x + curgad->_image->_width - 1, curgad->y + curgad->_image->_height - 1); curgad->GadgetFlags |= GADGETOFF; } diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp index 47897a726f..0313733084 100644 --- a/engines/lab/intro.cpp +++ b/engines/lab/intro.cpp @@ -299,7 +299,7 @@ void Intro::introSequence() { palette[15] = temp; - setAmigaPal(palette, 16); + _vm->_graphics->setAmigaPal(palette, 16); _vm->waitTOF(); } @@ -382,7 +382,7 @@ void Intro::introSequence() { _vm->_music->updateMusic(); _vm->waitTOF(); - _vm->setPalette(_vm->_anim->_diffPalette, 256); + _vm->_graphics->setPalette(_vm->_anim->_diffPalette, 256); _vm->waitTOF(); _vm->waitTOF(); } @@ -442,7 +442,7 @@ void Intro::introSequence() { if (_quitIntro) { _vm->_graphics->setAPen(0); - _vm->_graphics->rectFill(0, 0, _vm->_screenWidth - 1, _vm->_screenHeight - 1); + _vm->_graphics->rectFill(0, 0, _vm->_graphics->_screenWidth - 1, _vm->_graphics->_screenHeight - 1); _vm->_anim->_doBlack = true; } diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp index acd1ea963d..1e15845201 100644 --- a/engines/lab/lab.cpp +++ b/engines/lab/lab.cpp @@ -55,12 +55,6 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc), _extraGameFeatures(0) { g_lab = this; - _screenWidth = 320; - _screenHeight = 200; - - _currentDisplayBuffer = 0; - _displayBuffer = 0; - _lastWaitTOFTicks = 0; _isHiRes = false; @@ -185,4 +179,8 @@ Common::String LabEngine::generateSaveFileName(uint slot) { return Common::String::format("%s.%03u", _targetName.c_str(), slot); } +void LabEngine::drawStaticMessage(byte index) { + _graphics->drawMessage(_resource->getStaticText((StaticText)index).c_str()); +} + } // End of namespace Lab diff --git a/engines/lab/lab.h b/engines/lab/lab.h index 01dcaa04b1..b917da7bce 100644 --- a/engines/lab/lab.h +++ b/engines/lab/lab.h @@ -75,13 +75,8 @@ public: bool hasFeature(EngineFeature f) const; Common::String generateSaveFileName(uint slot); - //void showMainMenu(); - LargeSet *_conditions, *_roomsFound; - int _screenWidth; - int _screenHeight; - // timing.cpp void getTime(uint32 *secs, uint32 *micros); void addCurTime(uint32 sec, uint32 micros, uint32 *timeSec, uint32 *timeMicros); @@ -96,9 +91,6 @@ private: // timing.cpp void microDelay(uint32 secs, uint32 micros); - // vga.cpp - byte _curvgapal[256 * 3]; - public: EventManager *_event; Resource *_resource; @@ -107,8 +99,6 @@ public: DisplayMan *_graphics; int _roomNum; - byte *_currentDisplayBuffer; - CrumbData _breadCrumbs[MAX_CRUMBS]; uint16 _numCrumbs; bool _droppingCrumbs; @@ -118,9 +108,7 @@ public: uint32 _crumbSecs, _crumbMicros; bool _isCrumbWaiting; bool _alternate; - byte *_tempScrollData; bool _isHiRes; - byte *_displayBuffer; const char *_curFileName; const char *_nextFileName; const char *_newFileName; /* When ProcessRoom.c decides to change the filename @@ -146,13 +134,6 @@ private: public: void waitTOF(); - void writeColorRegs(byte *buf, uint16 first, uint16 numreg); - byte *getCurrentDrawingBuffer(); - void scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 y2); - void scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2); - void overlayRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, uint16 y2); - void setPalette(void *cmap, uint16 numcolors); - void drawRoomMessage(uint16 CurInv, CloseDataPtr cptr); void interfaceOff(); void interfaceOn(); diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h index 67200a8498..20785f4f4d 100644 --- a/engines/lab/labfun.h +++ b/engines/lab/labfun.h @@ -120,7 +120,6 @@ public: /*---------------------------*/ void fade(bool fadein, uint16 res); -void setAmigaPal(uint16 *pal, uint16 numcolors); void doMap(uint16 CurRoom); void doJournal(); void doNotes(); diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index bef3dd1f4c..3f20feae8f 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -43,27 +43,6 @@ namespace Lab { extern uint16 Direction; -/*****************************************************************************/ -/* Converts an Amiga palette (up to 16 colors) to a VGA palette, then sets */ -/* the VGA palette. */ -/*****************************************************************************/ -void setAmigaPal(uint16 *pal, uint16 numcolors) { - byte vgapal[16 * 3]; - uint16 vgacount = 0; - - if (numcolors > 16) - numcolors = 16; - - for (uint16 i = 0; i < numcolors; i++) { - vgapal[vgacount++] = (byte)(((pal[i] & 0xf00) >> 8) << 2); - vgapal[vgacount++] = (byte)(((pal[i] & 0x0f0) >> 4) << 2); - vgapal[vgacount++] = (byte)(((pal[i] & 0x00f)) << 2); - } - - g_lab->writeColorRegs(vgapal, 0, 16); - g_lab->waitTOF(); -} - /*---------------------------------------------------------------------------*/ /*------------------------------ The Map stuff ------------------------------*/ /*---------------------------------------------------------------------------*/ @@ -226,7 +205,7 @@ void fade(bool fadein, uint16 res) { (0xF00 & fadeNumOut(0xF00 & FadePalette[palIdx], 0xF00 & res, i)); } - setAmigaPal(newpal, 16); + g_lab->_graphics->setAmigaPal(newpal, 16); g_lab->waitTOF(); g_lab->_music->updateMusic(); } @@ -486,7 +465,7 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou fade(false, 0); _graphics->setAPen(0); - _graphics->rectFill(0, 0, _screenWidth - 1, _screenHeight - 1); + _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1); Map->drawImage(0, 0); drawGadgetList(MapGadgetList); @@ -583,7 +562,7 @@ void LabEngine::processMap(uint16 CurRoom) { } waitTOF(); - writeColorRegs(newcolor, 1, 1); + _graphics->writeColorRegs(newcolor, 1, 1); _event->updateMouse(); waitTOF(); _event->updateMouse(); @@ -753,7 +732,7 @@ void LabEngine::doMap(uint16 CurRoom) { _graphics->blackAllScreen(); _event->mouseHide(); _graphics->setAPen(0); - _graphics->rectFill(0, 0, _screenWidth - 1, _screenHeight - 1); + _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1); freeMapData(); _graphics->blackAllScreen(); _event->mouseShow(); diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp index bc7fa2e8b5..45d5584f83 100644 --- a/engines/lab/processroom.cpp +++ b/engines/lab/processroom.cpp @@ -532,7 +532,7 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) { _anim->_diffPalette[idx] = 255 - _anim->_diffPalette[idx]; waitTOF(); - setPalette(_anim->_diffPalette, 256); + _graphics->setPalette(_anim->_diffPalette, 256); waitTOF(); waitTOF(); } else if (aptr->Param1 == 4) { /* white the palette */ @@ -541,7 +541,7 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) { waitTOF(); } else if (aptr->Param1 == 6) { /* Restore the palette */ waitTOF(); - setPalette(_anim->_diffPalette, 256); + _graphics->setPalette(_anim->_diffPalette, 256); waitTOF(); waitTOF(); } else if (aptr->Param1 == 7) { /* Quick pause */ diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 76f9c1576a..4143ad6d73 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -77,13 +77,13 @@ extern uint16 Direction; static byte *loadBackPict(const char *fileName, bool tomem) { - byte *res = NULL; + byte *res = nullptr; FadePalette = hipal; g_lab->_anim->_noPalChange = true; if (tomem) - res = g_lab->_graphics->readPictToMem(fileName, g_lab->_screenWidth, g_lab->_screenHeight); + res = g_lab->_graphics->readPictToMem(fileName, g_lab->_graphics->_screenWidth, g_lab->_graphics->_screenHeight); else g_lab->_graphics->readPict(fileName, true); @@ -106,7 +106,7 @@ void doNotes() { 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->setPalette(g_lab->_anim->_diffPalette, 256); + g_lab->_graphics->setPalette(g_lab->_anim->_diffPalette, 256); closeFont(noteFont); delete[] ntext; @@ -150,7 +150,7 @@ void doWestPaper() { delete[] ntext; closeFont(paperFont); - g_lab->setPalette(g_lab->_anim->_diffPalette, 256); + g_lab->_graphics->setPalette(g_lab->_anim->_diffPalette, 256); } /*****************************************************************************/ @@ -268,18 +268,18 @@ static void drawJournalText() { /*****************************************************************************/ static void turnPage(bool FromLeft) { if (FromLeft) { - for (int i = 0; i < g_lab->_screenWidth; i += 8) { + for (int i = 0; i < g_lab->_graphics->_screenWidth; i += 8) { g_lab->_music->updateMusic(); g_lab->waitTOF(); - ScreenImage._imageData = g_lab->getCurrentDrawingBuffer(); - JBackImage.blitBitmap(i, 0, &ScreenImage, i, 0, 8, g_lab->_screenHeight, false); + ScreenImage._imageData = g_lab->_graphics->getCurrentDrawingBuffer(); + JBackImage.blitBitmap(i, 0, &ScreenImage, i, 0, 8, g_lab->_graphics->_screenHeight, false); } } else { - for (int i = (g_lab->_screenWidth - 8); i > 0; i -= 8) { + for (int i = (g_lab->_graphics->_screenWidth - 8); i > 0; i -= 8) { g_lab->_music->updateMusic(); g_lab->waitTOF(); - ScreenImage._imageData = g_lab->getCurrentDrawingBuffer(); - JBackImage.blitBitmap(i, 0, &ScreenImage, i, 0, 8, g_lab->_screenHeight, false); + ScreenImage._imageData = g_lab->_graphics->getCurrentDrawingBuffer(); + JBackImage.blitBitmap(i, 0, &ScreenImage, i, 0, 8, g_lab->_graphics->_screenHeight, false); } } } @@ -298,10 +298,10 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) { drawJournalText(); - ScreenImage._imageData = getCurrentDrawingBuffer(); + ScreenImage._imageData = _graphics->getCurrentDrawingBuffer(); if (wipenum == 0) - JBackImage.blitBitmap(0, 0, &ScreenImage, 0, 0, _screenWidth, _screenHeight, false); + JBackImage.blitBitmap(0, 0, &ScreenImage, 0, 0, _graphics->_screenWidth, _graphics->_screenHeight, false); else turnPage((bool)(wipenum == 1)); @@ -320,7 +320,7 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) { fade(true, 0); g_lab->_anim->_noPalChange = true; - JBackImage._imageData = _graphics->readPictToMem("P:Journal.pic", _screenWidth, _screenHeight); + JBackImage._imageData = _graphics->readPictToMem("P:Journal.pic", _graphics->_screenWidth, _graphics->_screenHeight); GotBackImage = true; eatMessages(); @@ -380,15 +380,15 @@ void LabEngine::doJournal() { lastpage = false; GotBackImage = false; - JBackImage._width = _screenWidth; - JBackImage._height = _screenHeight; + JBackImage._width = _graphics->_screenWidth; + JBackImage._height = _graphics->_screenHeight; JBackImage._imageData = NULL; BackG.NextGadget = &CancelG; CancelG.NextGadget = &ForwardG; ScreenImage = JBackImage; - ScreenImage._imageData = getCurrentDrawingBuffer(); + ScreenImage._imageData = _graphics->getCurrentDrawingBuffer(); _music->updateMusic(); loadJournalData(); @@ -402,10 +402,10 @@ void LabEngine::doJournal() { fade(false, 0); _event->mouseHide(); - ScreenImage._imageData = getCurrentDrawingBuffer(); + ScreenImage._imageData = _graphics->getCurrentDrawingBuffer(); _graphics->setAPen(0); - _graphics->rectFill(0, 0, _screenWidth - 1, _screenHeight - 1); + _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1); _graphics->blackScreen(); } @@ -476,13 +476,13 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16 MonGadHeight = fheight; _graphics->setAPen(0); - _graphics->rectFill(0, 0, _screenWidth - 1, y2); + _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, y2); for (uint16 i = 0; i < numlines; i++) MonButton->drawImage(0, i * MonGadHeight); } else if (isinteractive) { _graphics->setAPen(0); - _graphics->rectFill(0, 0, _screenWidth - 1, y2); + _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, y2); } else { _graphics->setAPen(0); _graphics->rectFill(x1, y1, x2, y2); @@ -644,7 +644,7 @@ void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive, closeFont(monitorFont); _graphics->setAPen(0); - _graphics->rectFill(0, 0, _screenWidth - 1, _screenHeight - 1); + _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1); _graphics->blackAllScreen(); _graphics->freePict(); } diff --git a/engines/lab/text.cpp b/engines/lab/text.cpp index 1c1cacdac3..f784c2126d 100644 --- a/engines/lab/text.cpp +++ b/engines/lab/text.cpp @@ -78,10 +78,10 @@ void text(TextFont *tf, uint16 x, uint16 y, uint16 color, const char *text, uint int32 templeft, LeftInSegment; uint16 bwidth, mask, curpage, data; - VGATop = g_lab->getCurrentDrawingBuffer(); + VGATop = g_lab->_graphics->getCurrentDrawingBuffer(); for (uint16 i = 0; i < numchars; i++) { - RealOffset = (g_lab->_screenWidth * y) + x; + RealOffset = (g_lab->_graphics->_screenWidth * y) + x; curpage = RealOffset / g_lab->_graphics->_screenBytesPerPage; SegmentOffset = RealOffset - (curpage * g_lab->_graphics->_screenBytesPerPage); LeftInSegment = g_lab->_graphics->_screenBytesPerPage - SegmentOffset; @@ -137,8 +137,8 @@ void text(TextFont *tf, uint16 x, uint16 y, uint16 color, const char *text, uint } } - VGATempLine += g_lab->_screenWidth; - LeftInSegment -= g_lab->_screenWidth; + VGATempLine += g_lab->_graphics->_screenWidth; + LeftInSegment -= g_lab->_graphics->_screenWidth; if (LeftInSegment <= 0) { curpage++; diff --git a/engines/lab/tilepuzzle.cpp b/engines/lab/tilepuzzle.cpp index 137038fd75..1cee9d3fde 100644 --- a/engines/lab/tilepuzzle.cpp +++ b/engines/lab/tilepuzzle.cpp @@ -259,7 +259,7 @@ void LabEngine::showTile(const char *filename, bool showsolution) { delete tileFile; doTile(showsolution); - setPalette(_anim->_diffPalette, 256); + _graphics->setPalette(_anim->_diffPalette, 256); } /*****************************************************************************/ @@ -319,9 +319,9 @@ void LabEngine::changeCombination(uint16 number) { combnum = combination[number]; - display._imageData = getCurrentDrawingBuffer(); - display._width = _screenWidth; - display._height = _screenHeight; + display._imageData = _graphics->getCurrentDrawingBuffer(); + display._width = _graphics->_screenWidth; + display._height = _graphics->_screenHeight; for (uint16 i = 1; i <= (Images[combnum]->_height / 2); i++) { if (_isHiRes) { @@ -330,10 +330,8 @@ void LabEngine::changeCombination(uint16 number) { } else waitTOF(); - display._imageData = getCurrentDrawingBuffer(); - - scrollDisplayY(2, _graphics->VGAScaleX(COMBINATION_X[number]), _graphics->VGAScaleY(65), _graphics->VGAScaleX(COMBINATION_X[number]) + (Images[combnum])->_width - 1, _graphics->VGAScaleY(65) + (Images[combnum])->_height); - + display._imageData = _graphics->getCurrentDrawingBuffer(); + _graphics->scrollDisplayY(2, _graphics->VGAScaleX(COMBINATION_X[number]), _graphics->VGAScaleY(65), _graphics->VGAScaleX(COMBINATION_X[number]) + (Images[combnum])->_width - 1, _graphics->VGAScaleY(65) + (Images[combnum])->_height); Images[combnum]->blitBitmap(0, (Images[combnum])->_height - (2 * i), &(display), _graphics->VGAScaleX(COMBINATION_X[number]), _graphics->VGAScaleY(65), (Images[combnum])->_width, 2, false); } @@ -348,10 +346,10 @@ void LabEngine::changeCombination(uint16 number) { void LabEngine::scrollRaster(int16 dx, int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2) { if (dx) - scrollDisplayX(dx, x1, y1, x2, y2); + _graphics->scrollDisplayX(dx, x1, y1, x2, y2); if (dy) - scrollDisplayY(dy, x1, y1, x2, y2); + _graphics->scrollDisplayY(dy, x1, y1, x2, y2); } /*****************************************************************************/ @@ -382,7 +380,7 @@ void LabEngine::showCombination(const char *filename) { doCombination(); - setPalette(_anim->_diffPalette, 256); + _graphics->setPalette(_anim->_diffPalette, 256); } } // End of namespace Lab diff --git a/engines/lab/vga.cpp b/engines/lab/vga.cpp index 8ee0d3445e..95099dc0b7 100644 --- a/engines/lab/vga.cpp +++ b/engines/lab/vga.cpp @@ -45,7 +45,7 @@ void LabEngine::changeVolume(int delta) { void LabEngine::waitTOF() { - g_system->copyRectToScreen(_displayBuffer, _screenWidth, 0, 0, _screenWidth, _screenHeight); + g_system->copyRectToScreen(_graphics->_displayBuffer, _graphics->_screenWidth, 0, 0, _graphics->_screenWidth, _graphics->_screenHeight); g_system->updateScreen(); _event->processInput(); @@ -58,143 +58,4 @@ void LabEngine::waitTOF() { _lastWaitTOFTicks = now; } -/*****************************************************************************/ -/* Writes any number of the 256 color registers. */ -/* first: the number of the first color register to write. */ -/* numreg: the number of registers to write */ -/* buf: a char pointer which contains the selected color registers. */ -/* Each value representing a color register occupies 3 bytes in */ -/* the array. The order is red, green then blue. The first byte */ -/* in the array is the red component of the first element selected.*/ -/* The length of the buffer is 3 times the number of registers */ -/* selected. */ -/*****************************************************************************/ -void LabEngine::writeColorRegs(byte *buf, uint16 first, uint16 numreg) { - byte tmp[256 * 3]; - - for (int i = 0; i < 256 * 3; i++) { - tmp[i] = buf[i] * 4; - } - - g_system->getPaletteManager()->setPalette(tmp, first, numreg); - - memcpy(&(_curvgapal[first * 3]), buf, numreg * 3); -} - -void LabEngine::setPalette(void *cmap, uint16 numcolors) { - if (memcmp(cmap, _curvgapal, numcolors * 3) != 0) - writeColorRegs((byte *)cmap, 0, numcolors); -} - -/*****************************************************************************/ -/* Returns the base address of the current VGA display. */ -/*****************************************************************************/ -byte *LabEngine::getCurrentDrawingBuffer() { - if (_currentDisplayBuffer) - return _currentDisplayBuffer; - - return _displayBuffer; -} - -/*****************************************************************************/ -/* Scrolls the display in the x direction by blitting. */ -/* The _tempScrollData variable must be initialized to some memory, or this */ -/* function will fail. */ -/*****************************************************************************/ -void LabEngine::scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 y2) { - Image im; - uint16 temp; - - im._imageData = _tempScrollData; - - if (x1 > x2) { - temp = x2; - x2 = x1; - x1 = temp; - } - - if (y1 > y2) { - temp = y2; - y2 = y1; - y1 = temp; - } - - im._width = x2 - x1 + 1 - dx; - im._height = y2 - y1 + 1; - - im.readScreenImage(x1, y1); - im.drawImage(x1 + dx, y1); - - _graphics->setAPen(0); - _graphics->rectFill(x1, y1, x1 + dx - 1, y2); -} - -/*****************************************************************************/ -/* Scrolls the display in the y direction by blitting. */ -/*****************************************************************************/ -void LabEngine::scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2) { - Image im; - uint16 temp; - - im._imageData = _tempScrollData; - - if (x1 > x2) { - temp = x2; - x2 = x1; - x1 = temp; - } - - if (y1 > y2) { - temp = y2; - y2 = y1; - y1 = temp; - } - - im._width = x2 - x1 + 1; - im._height = y2 - y1 + 1 - dy; - - im.readScreenImage(x1, y1); - im.drawImage(x1, y1 + dy); - - _graphics->setAPen(0); - _graphics->rectFill(x1, y1, x2, y1 + dy - 1); -} - -/*****************************************************************************/ -/* Overlays a region on the screen using the desired pen color. */ -/*****************************************************************************/ -void LabEngine::overlayRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, uint16 y2) { - int w = x2 - x1 + 1; - int h = y2 - y1 + 1; - - if (x1 + w > _screenWidth) - w = _screenWidth - x1; - - if (y1 + h > _screenHeight) - h = _screenHeight - y1; - - if ((w > 0) && (h > 0)) { - char *d = (char *)getCurrentDrawingBuffer() + y1 * _screenWidth + x1; - - while (h-- > 0) { - char *dd = d; - int ww = w; - - if (y1 & 1) { - dd++; - ww--; - } - - while (ww > 0) { - *dd = pencolor; - dd += 2; - ww -= 2; - } - - d += _screenWidth; - y1++; - } - } -} - } // End of namespace Lab |