diff options
author | Strangerke | 2015-12-04 13:32:08 +0100 |
---|---|---|
committer | Willem Jan Palenstijn | 2015-12-23 21:33:50 +0100 |
commit | 733fbe4c62911adc478400ba5d0dcf220e1b45ee (patch) | |
tree | 44b98212dff065a1ef5bae3355192de80eb0861f /engines/lab/graphics.cpp | |
parent | c399536a07b6bf96ff311d4398f51e2d865a2027 (diff) | |
download | scummvm-rg350-733fbe4c62911adc478400ba5d0dcf220e1b45ee.tar.gz scummvm-rg350-733fbe4c62911adc478400ba5d0dcf220e1b45ee.tar.bz2 scummvm-rg350-733fbe4c62911adc478400ba5d0dcf220e1b45ee.zip |
LAB: Start working on a separate DisplayMan class
Diffstat (limited to 'engines/lab/graphics.cpp')
-rw-r--r-- | engines/lab/graphics.cpp | 480 |
1 files changed, 358 insertions, 122 deletions
diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp index 520828a8f4..80888d21e7 100644 --- a/engines/lab/graphics.cpp +++ b/engines/lab/graphics.cpp @@ -36,19 +36,26 @@ #include "lab/parsefun.h" #include "lab/text.h" #include "lab/resource.h" +#include "lab/graphics.h" namespace Lab { BitMap bit1, bit2, *DispBitMap = &bit1, *DrawBitMap = &bit1; -extern bool stopsound; +DisplayMan::DisplayMan(LabEngine *vm) : _vm(vm) { + _longWinInFront = false; + _lastMessageLong = false; + + _screenBytesPerPage = 65536; + _curapen = 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 scaleX(uint16 x) { - if (g_lab->_isHiRes) +uint16 DisplayMan::scaleX(uint16 x) { + if (_vm->_isHiRes) return (uint16)((x * 16) / 9); else return (uint16)((x * 8) / 9); @@ -58,7 +65,7 @@ uint16 scaleX(uint16 x) { /* 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 scaleY(uint16 y) { +uint16 DisplayMan::scaleY(uint16 y) { if (g_lab->_isHiRes) return (y + (y / 14)); else @@ -68,7 +75,7 @@ uint16 scaleY(uint16 y) { /*****************************************************************************/ /* Scales the VGA cords to SVGA if necessary; otherwise, returns VGA cords. */ /*****************************************************************************/ -int16 VGAScaleX(int16 x) { +int16 DisplayMan::VGAScaleX(int16 x) { if (g_lab->_isHiRes) return (x * 2); else @@ -78,14 +85,14 @@ int16 VGAScaleX(int16 x) { /*****************************************************************************/ /* Scales the VGA cords to SVGA if necessary; otherwise, returns VGA cords. */ /*****************************************************************************/ -int16 VGAScaleY(int16 y) { +int16 DisplayMan::VGAScaleY(int16 y) { if (g_lab->_isHiRes) return ((y * 12) / 5); else return y; } -uint16 SVGACord(uint16 cord) { +uint16 DisplayMan::SVGACord(uint16 cord) { if (g_lab->_isHiRes) return cord; else @@ -119,10 +126,10 @@ int VGAUnScaleY(int y) { /*****************************************************************************/ /* Reads in a picture into the dest bitmap. */ /*****************************************************************************/ -bool readPict(const char *filename, bool playOnce) { - g_lab->_anim->stopDiff(); +bool DisplayMan::readPict(const char *filename, bool playOnce) { + _vm->_anim->stopDiff(); - byte **file = g_lab->_music->newOpen(filename); + byte **file = _vm->_music->newOpen(filename); if (file == NULL) { if ((filename[0] == 'p') || (filename[0] == 'P')) @@ -131,11 +138,11 @@ bool readPict(const char *filename, bool playOnce) { return false; } - DispBitMap->_bytesPerRow = g_lab->_screenWidth; - DispBitMap->_rows = g_lab->_screenHeight; + DispBitMap->_bytesPerRow = _vm->_screenWidth; + DispBitMap->_rows = _vm->_screenHeight; DispBitMap->_flags = BITMAPF_VIDEO; - g_lab->_anim->readDiff(playOnce); + _vm->_anim->readDiff(playOnce); return true; } @@ -143,7 +150,7 @@ bool readPict(const char *filename, bool playOnce) { /*****************************************************************************/ /* Reads in a picture into buffer memory. */ /*****************************************************************************/ -byte *readPictToMem(const char *filename, uint16 x, uint16 y) { +byte *DisplayMan::readPictToMem(const char *filename, uint16 x, uint16 y) { byte *mem; g_lab->_anim->stopDiff(); @@ -252,7 +259,7 @@ static void getLine(TextFont *tf, char *lineBuffer, const char **mainBuffer, uin /* Note: Every individual word MUST be int16 enough to fit on a line, and */ /* each line less than 255 characters. */ /******************************************************************************/ -uint32 flowText(void *font, /* the TextAttr pointer */ +uint32 DisplayMan::flowText(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 */ @@ -269,14 +276,14 @@ uint32 flowText(void *font, /* the TextAttr pointer */ uint16 x, y; if (fillback) { - g_lab->setAPen(backpen); - g_lab->rectFill(x1, y1, x2, y2); + setAPen(backpen); + rectFill(x1, y1, x2, y2); } if (str == NULL) return 0L; - g_lab->setAPen(pencolor); + setAPen(pencolor); fontheight = textHeight(_msgFont) + spacing; numlines = (y2 - y1 + 1) / fontheight; @@ -319,7 +326,7 @@ uint32 flowText(void *font, /* the TextAttr pointer */ /******************************************************************************/ /* Calls flowText, but flows it to memory. Same restrictions as flowText. */ /******************************************************************************/ -uint32 flowTextToMem(Image *destIm, void *font, /* the TextAttr pointer */ +uint32 DisplayMan::flowTextToMem(Image *destIm, 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 */ @@ -329,41 +336,41 @@ uint32 flowTextToMem(Image *destIm, void *font, /* the TextAttr pointer */ bool output, /* Whether to output any text */ uint16 x1, /* Cords */ uint16 y1, uint16 x2, uint16 y2, const char *str) { /* The text itself */ - uint32 res, vgabyte = g_lab->_screenBytesPerPage; - byte *tmp = g_lab->_currentDisplayBuffer; + uint32 res, vgabyte = _screenBytesPerPage; + byte *tmp = _vm->_currentDisplayBuffer; - g_lab->_currentDisplayBuffer = destIm->_imageData; - g_lab->_screenBytesPerPage = (uint32)destIm->_width * (int32)destIm->_height; + _vm->_currentDisplayBuffer = destIm->_imageData; + _screenBytesPerPage = (uint32)destIm->_width * (int32)destIm->_height; - res = flowText(font, spacing, pencolor, backpen, fillback, centerh, centerv, output, x1, y1, x2, y2, str); + res = _vm->_graphics->flowText(font, spacing, pencolor, backpen, fillback, centerh, centerv, output, x1, y1, x2, y2, str); - g_lab->_screenBytesPerPage = vgabyte; - g_lab->_currentDisplayBuffer = tmp; + _screenBytesPerPage = vgabyte; + _vm->_currentDisplayBuffer = tmp; return res; } /*----- The control panel stuff -----*/ -void createBox(uint16 y2) { - g_lab->setAPen(7); /* Message box area */ - g_lab->rectFill(VGAScaleX(4), VGAScaleY(154), VGAScaleX(315), VGAScaleY(y2 - 2)); +void DisplayMan::createBox(uint16 y2) { + setAPen(7); /* Message box area */ + rectFill(VGAScaleX(4), VGAScaleY(154), VGAScaleX(315), VGAScaleY(y2 - 2)); - g_lab->setAPen(0); /* Box around message area */ - g_lab->drawHLine(VGAScaleX(2), VGAScaleY(152), VGAScaleX(317)); - g_lab->drawVLine(VGAScaleX(317), VGAScaleY(152), VGAScaleY(y2)); - g_lab->drawHLine(VGAScaleX(2), VGAScaleY(y2), VGAScaleX(317)); - g_lab->drawVLine(VGAScaleX(2), VGAScaleY(152), VGAScaleY(y2)); + 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)); } -int32 LabEngine::longDrawMessage(const char *str) { +int32 DisplayMan::longDrawMessage(const char *str) { char newText[512]; if (str == NULL) return 0; - _event->attachGadgetList(NULL); - _event->mouseHide(); + _vm->_event->attachGadgetList(NULL); + _vm->_event->mouseHide(); strcpy(newText, str); if (!_longWinInFront) { @@ -373,26 +380,26 @@ int32 LabEngine::longDrawMessage(const char *str) { } createBox(198); - _event->mouseShow(); + _vm->_event->mouseShow(); - return flowText(_msgFont, 0, 1, 7, false, true, true, true, VGAScaleX(6), VGAScaleY(155), VGAScaleX(313), VGAScaleY(195), str); + return flowText(_vm->_msgFont, 0, 1, 7, false, true, true, true, VGAScaleX(6), VGAScaleY(155), VGAScaleX(313), VGAScaleY(195), str); } void LabEngine::drawStaticMessage(byte index) { - drawMessage(_resource->getStaticText((StaticText)index).c_str()); + _graphics->drawMessage(_resource->getStaticText((StaticText)index).c_str()); } /******************************************************************************/ /* Draws a message to the message box. */ /******************************************************************************/ -void LabEngine::drawMessage(const char *str) { +void DisplayMan::drawMessage(const char *str) { if (DoNotDrawMessage) { DoNotDrawMessage = false; return; } if (str) { - if ((textLength(_msgFont, str, strlen(str)) > VGAScaleX(306))) { + if ((textLength(_vm->_msgFont, str, strlen(str)) > VGAScaleX(306))) { longDrawMessage(str); _lastMessageLong = true; } else { @@ -401,10 +408,10 @@ void LabEngine::drawMessage(const char *str) { drawPanel(); } - _event->mouseHide(); + _vm->_event->mouseHide(); createBox(168); - text(_msgFont, VGAScaleX(7), VGAScaleY(155) + SVGACord(2), 1, str, strlen(str)); - _event->mouseShow(); + text(_vm->_msgFont, VGAScaleX(7), VGAScaleY(155) + SVGACord(2), 1, str, strlen(str)); + _vm->_event->mouseShow(); _lastMessageLong = false; } } @@ -425,13 +432,13 @@ void LabEngine::drawMessage(const char *str) { /*****************************************************************************/ /* Scrolls the display to black. */ /*****************************************************************************/ -void LabEngine::doScrollBlack() { +void DisplayMan::doScrollBlack() { byte *mem, *tempmem; Image im; uint32 size, copysize; uint32 *baseAddr; - _event->mouseHide(); + _vm->_event->mouseHide(); uint16 width = VGAScaleX(320); uint16 height = VGAScaleY(149) + SVGACord(2); @@ -440,22 +447,22 @@ void LabEngine::doScrollBlack() { im._width = width; im._height = height; im._imageData = mem; - _music->updateMusic(); + _vm->_music->updateMusic(); im.readScreenImage(0, 0); - _music->updateMusic(); + _vm->_music->updateMusic(); - baseAddr = (uint32 *)getCurrentDrawingBuffer(); + baseAddr = (uint32 *)_vm->getCurrentDrawingBuffer(); uint16 by = VGAScaleX(4); uint16 nheight = height; while (nheight) { - _music->updateMusic(); + _vm->_music->updateMusic(); - if (!_isHiRes) - waitTOF(); + if (!_vm->_isHiRes) + _vm->waitTOF(); - baseAddr = (uint32 *)getCurrentDrawingBuffer(); + baseAddr = (uint32 *)_vm->getCurrentDrawingBuffer(); if (by > nheight) by = nheight; @@ -482,7 +489,7 @@ void LabEngine::doScrollBlack() { screenUpdate(); - if (!_isHiRes) { + if (!_vm->_isHiRes) { if (nheight <= (height / 8)) by = 1; else if (nheight <= (height / 4)) @@ -493,10 +500,10 @@ void LabEngine::doScrollBlack() { } freeAllStolenMem(); - _event->mouseShow(); + _vm->_event->mouseShow(); } -static void copyPage(uint16 width, uint16 height, uint16 nheight, uint16 startline, byte *mem) { +void DisplayMan::copyPage(uint16 width, uint16 height, uint16 nheight, uint16 startline, byte *mem) { uint32 size, offSet, copysize; uint16 curPage; uint32 *baseAddr; @@ -505,12 +512,12 @@ static void copyPage(uint16 width, uint16 height, uint16 nheight, uint16 startli size = (int32)(height - nheight) * (int32)width; mem += startline * width; - curPage = ((int32)nheight * (int32)width) / g_lab->_screenBytesPerPage; - offSet = ((int32)nheight * (int32)width) - (curPage * g_lab->_screenBytesPerPage); + curPage = ((int32)nheight * (int32)width) / g_lab->_graphics->_screenBytesPerPage; + offSet = ((int32)nheight * (int32)width) - (curPage * g_lab->_graphics->_screenBytesPerPage); while (size) { - if (size > (g_lab->_screenBytesPerPage - offSet)) - copysize = g_lab->_screenBytesPerPage - offSet; + if (size > (g_lab->_graphics->_screenBytesPerPage - offSet)) + copysize = g_lab->_graphics->_screenBytesPerPage - offSet; else copysize = size; @@ -526,35 +533,35 @@ static void copyPage(uint16 width, uint16 height, uint16 nheight, uint16 startli /*****************************************************************************/ /* Scrolls the display to a new picture from a black screen. */ /*****************************************************************************/ -void LabEngine::doScrollWipe(char *filename) { +void DisplayMan::doScrollWipe(char *filename) { uint16 startline = 0, onrow = 0; - _event->mouseHide(); + _vm->_event->mouseHide(); uint16 width = VGAScaleX(320); uint16 height = VGAScaleY(149) + SVGACord(2); - while (_music->isSoundEffectActive()) { - _music->updateMusic(); - waitTOF(); + while (_vm->_music->isSoundEffectActive()) { + _vm->_music->updateMusic(); + _vm->waitTOF(); } - _anim->_isBM = true; + _vm->_anim->_isBM = true; readPict(filename, true); - setPalette(_anim->_diffPalette, 256); - _anim->_isBM = false; - byte *mem = _anim->_rawDiffBM._planes[0]; + _vm->setPalette(_vm->_anim->_diffPalette, 256); + _vm->_anim->_isBM = false; + byte *mem = _vm->_anim->_rawDiffBM._planes[0]; - _music->updateMusic(); + _vm->_music->updateMusic(); uint16 by = VGAScaleX(3); uint16 nheight = height; - while (onrow < _anim->_headerdata._height) { - _music->updateMusic(); + while (onrow < _vm->_anim->_headerdata._height) { + _vm->_music->updateMusic(); if ((by > nheight) && nheight) by = nheight; - if ((startline + by) > (_anim->_headerdata._height - height - 1)) + if ((startline + by) > (_vm->_anim->_headerdata._height - height - 1)) break; if (nheight) @@ -577,19 +584,19 @@ void LabEngine::doScrollWipe(char *filename) { by = VGAScaleX(3); } - _event->mouseShow(); + _vm->_event->mouseShow(); } /*****************************************************************************/ /* Does the scroll bounce. Assumes bitmap already in memory. */ /*****************************************************************************/ -void LabEngine::doScrollBounce() { +void DisplayMan::doScrollBounce() { const uint16 *newby, *newby1; const uint16 newbyd[5] = {5, 4, 3, 2, 1}, newby1d[8] = {3, 3, 2, 2, 2, 1, 1, 1}; const uint16 newbyw[5] = {10, 8, 6, 4, 2}, newby1w[8] = {6, 6, 4, 4, 4, 2, 2, 2}; - if (getPlatform() != Common::kPlatformWindows) { + if (_vm->getPlatform() != Common::kPlatformWindows) { newby = newbyd; newby1 = newby1d; } else { @@ -597,44 +604,43 @@ void LabEngine::doScrollBounce() { newby1 = newby1w; } - _event->mouseHide(); + _vm->_event->mouseHide(); int width = VGAScaleX(320); int height = VGAScaleY(149) + SVGACord(2); - byte *mem = _anim->_rawDiffBM._planes[0]; + byte *mem = _vm->_anim->_rawDiffBM._planes[0]; - _music->updateMusic(); - int startline = _anim->_headerdata._height - height - 1; + _vm->_music->updateMusic(); + int startline = _vm->_anim->_headerdata._height - height - 1; for (int i = 0; i < 5; i++) { - _music->updateMusic(); + _vm->_music->updateMusic(); startline -= newby[i]; copyPage(width, height, 0, startline, mem); screenUpdate(); - waitTOF(); + _vm->waitTOF(); } for (int i = 8; i > 0; i--) { - _music->updateMusic(); + _vm->_music->updateMusic(); startline += newby1[i - 1]; copyPage(width, height, 0, startline, mem); screenUpdate(); - waitTOF(); - + _vm->waitTOF(); } - _event->mouseShow(); + _vm->_event->mouseShow(); } /*****************************************************************************/ /* Does the transporter wipe. */ /*****************************************************************************/ -void LabEngine::doTransWipe(CloseDataPtr *cPtr, char *filename) { +void DisplayMan::doTransWipe(CloseDataPtr *cPtr, char *filename) { uint16 lastY, curY, linesdone = 0, lineslast; Image imSource, imDest; - if (_isHiRes) { + if (_vm->_isHiRes) { lineslast = 3; lastY = 358; } else { @@ -647,12 +653,12 @@ void LabEngine::doTransWipe(CloseDataPtr *cPtr, char *filename) { while (curY < lastY) { if (linesdone >= lineslast) { - _music->updateMusic(); - waitTOF(); + _vm->_music->updateMusic(); + _vm->waitTOF(); linesdone = 0; } - overlayRect(0, 0, curY, _screenWidth - 1, curY + 1); + _vm->overlayRect(0, 0, curY, _vm->_screenWidth - 1, curY + 1); curY += 4; linesdone++; } @@ -665,50 +671,50 @@ void LabEngine::doTransWipe(CloseDataPtr *cPtr, char *filename) { while (curY <= lastY) { if (linesdone >= lineslast) { - _music->updateMusic(); - waitTOF(); + _vm->_music->updateMusic(); + _vm->waitTOF(); linesdone = 0; } - rectFill(0, curY, _screenWidth - 1, curY + 1); + rectFill(0, curY, _vm->_screenWidth - 1, curY + 1); curY += 4; linesdone++; } } if (filename == NULL) - g_lab->_curFileName = getPictName(cPtr); + _vm->_curFileName = getPictName(cPtr); else if (filename[0] > ' ') - g_lab->_curFileName = filename; + _vm->_curFileName = filename; else - g_lab->_curFileName = getPictName(cPtr); + _vm->_curFileName = getPictName(cPtr); - byte *BitMapMem = readPictToMem(g_lab->_curFileName, _screenWidth, lastY + 5); - setPalette(_anim->_diffPalette, 256); + byte *BitMapMem = readPictToMem(g_lab->_curFileName, _vm->_screenWidth, lastY + 5); + _vm->setPalette(_vm->_anim->_diffPalette, 256); if (BitMapMem) { - imSource._width = _screenWidth; + imSource._width = _vm->_screenWidth; imSource._height = lastY; imSource._imageData = BitMapMem; - imDest._width = _screenWidth; - imDest._height = _screenHeight; - imDest._imageData = getCurrentDrawingBuffer(); + imDest._width = _vm->_screenWidth; + imDest._height = _vm->_screenHeight; + imDest._imageData = _vm->getCurrentDrawingBuffer(); for (uint16 i = 0; i < 2; i++) { curY = i * 2; while (curY < lastY) { if (linesdone >= lineslast) { - _music->updateMusic(); - waitTOF(); + _vm->_music->updateMusic(); + _vm->waitTOF(); linesdone = 0; } - imDest._imageData = getCurrentDrawingBuffer(); + imDest._imageData = _vm->getCurrentDrawingBuffer(); - imSource.bltBitMap(0, curY, &imDest, 0, curY, _screenWidth, 2); - overlayRect(0, 0, curY, _screenWidth - 1, curY + 1); + imSource.bltBitMap(0, curY, &imDest, 0, curY, _vm->_screenWidth, 2); + _vm->overlayRect(0, 0, curY, _vm->_screenWidth - 1, curY + 1); curY += 4; linesdone++; } @@ -719,17 +725,17 @@ void LabEngine::doTransWipe(CloseDataPtr *cPtr, char *filename) { while (curY <= lastY) { if (linesdone >= lineslast) { - _music->updateMusic(); - waitTOF(); + _vm->_music->updateMusic(); + _vm->waitTOF(); linesdone = 0; } - imDest._imageData = getCurrentDrawingBuffer(); + imDest._imageData = _vm->getCurrentDrawingBuffer(); if (curY == lastY) - imSource.bltBitMap(0, curY, &imDest, 0, curY, _screenWidth, 1); + imSource.bltBitMap(0, curY, &imDest, 0, curY, _vm->_screenWidth, 1); else - imSource.bltBitMap(0, curY, &imDest, 0, curY, _screenWidth, 2); + imSource.bltBitMap(0, curY, &imDest, 0, curY, _vm->_screenWidth, 2); curY += 4; linesdone++; @@ -741,7 +747,7 @@ void LabEngine::doTransWipe(CloseDataPtr *cPtr, char *filename) { /*****************************************************************************/ /* Does a certain number of pre-programmed wipes. */ /*****************************************************************************/ -void LabEngine::doWipe(uint16 wipeType, CloseDataPtr *cPtr, char *filename) { +void DisplayMan::doWipe(uint16 wipeType, CloseDataPtr *cPtr, char *filename) { if ((wipeType == TRANSWIPE) || (wipeType == TRANSPORTER)) doTransWipe(cPtr, filename); else if (wipeType == SCROLLWIPE) @@ -753,16 +759,16 @@ void LabEngine::doWipe(uint16 wipeType, CloseDataPtr *cPtr, char *filename) { else if (wipeType == READFIRSTFRAME) readPict(filename, false); else if (wipeType == READNEXTFRAME) - _anim->diffNextFrame(); + _vm->_anim->diffNextFrame(); } /*****************************************************************************/ /* Changes the front screen to black. */ /*****************************************************************************/ -void blackScreen() { +void DisplayMan::blackScreen() { byte pal[256 * 3]; memset(pal, 0, 248 * 3); - g_lab->writeColorRegs(pal, 8, 248); + _vm->writeColorRegs(pal, 8, 248); g_system->delayMillis(32); } @@ -770,21 +776,251 @@ void blackScreen() { /*****************************************************************************/ /* Changes the front screen to white. */ /*****************************************************************************/ -void whiteScreen() { +void DisplayMan::whiteScreen() { byte pal[256 * 3]; memset(pal, 255, 248 * 3); - g_lab->writeColorRegs(pal, 8, 248); + _vm->writeColorRegs(pal, 8, 248); } /*****************************************************************************/ /* Changes the entire screen to black. */ /*****************************************************************************/ -void blackAllScreen() { +void DisplayMan::blackAllScreen() { byte pal[256 * 3]; memset(pal, 0, 256 * 3); - g_lab->writeColorRegs(pal, 0, 256); + _vm->writeColorRegs(pal, 0, 256); g_system->delayMillis(32); } +/******************************************************************************/ +/* Draws the control panel display. */ +/******************************************************************************/ +void DisplayMan::drawPanel() { + _vm->_event->mouseHide(); + + setAPen(3); /* Clear Area */ + rectFill(0, VGAScaleY(149) + SVGACord(2), VGAScaleX(319), VGAScaleY(199)); + + setAPen(0); /* First Line */ + drawHLine(0, VGAScaleY(149) + SVGACord(2), VGAScaleX(319)); + setAPen(5); /* Second Line */ + drawHLine(0, VGAScaleY(149) + 1 + SVGACord(2), VGAScaleX(319)); + + /* Gadget Separators */ + setAPen(0); + drawHLine(0, VGAScaleY(170), 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 */ + 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)); + } 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)); + } + + 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)); + + 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)); + } 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)); + } + + drawGadgetList(_vm->_invGadgetList); + } + + _vm->_event->mouseShow(); +} + +/******************************************************************************/ +/* Sets up the Labyrinth screens, and opens up the initial windows. */ +/******************************************************************************/ +bool DisplayMan::setUpScreens() { + if (!createScreen(_vm->_isHiRes)) + return false; + + Common::File *controlFile = g_lab->_resource->openDataFile("P:Control"); + for (uint16 i = 0; i < 20; i++) + _vm->_moveImages[i] = new Image(controlFile); + delete controlFile; + + /* Creates the gadgets for the movement control panel */ + uint16 y = VGAScaleY(173) - SVGACord(2); + + if (_vm->getPlatform() == Common::kPlatformWindows) { + _vm->_moveGadgetList = createButton(1, y, 0, 't', _vm->_moveImages[0], _vm->_moveImages[1]); + Gadget *curGadget = _vm->_moveGadgetList; + curGadget->NextGadget = createButton(33, y, 1, 'm', _vm->_moveImages[2], _vm->_moveImages[3]); + curGadget = curGadget->NextGadget; + curGadget->NextGadget = createButton(65, y, 2, 'o', _vm->_moveImages[4], _vm->_moveImages[5]); + curGadget = curGadget->NextGadget; + curGadget->NextGadget = createButton(97, y, 3, 'c', _vm->_moveImages[6], _vm->_moveImages[7]); + curGadget = curGadget->NextGadget; + curGadget->NextGadget = createButton(129, y, 4, 'l', _vm->_moveImages[8], _vm->_moveImages[9]); + curGadget = curGadget->NextGadget; + curGadget->NextGadget = createButton(161, y, 5, 'i', _vm->_moveImages[12], _vm->_moveImages[13]); + curGadget = curGadget->NextGadget; + curGadget->NextGadget = createButton(193, y, 6, VKEY_LTARROW, _vm->_moveImages[14], _vm->_moveImages[15]); + curGadget = curGadget->NextGadget; + curGadget->NextGadget = createButton(225, y, 7, VKEY_UPARROW, _vm->_moveImages[16], _vm->_moveImages[17]); + curGadget = curGadget->NextGadget; + curGadget->NextGadget = createButton(257, y, 8, VKEY_RTARROW, _vm->_moveImages[18], _vm->_moveImages[19]); + curGadget = curGadget->NextGadget; + curGadget->NextGadget = createButton(289, y, 9, 'p', _vm->_moveImages[10], _vm->_moveImages[11]); + } else { + _vm->_moveGadgetList = createButton(1, y, 0, 0, _vm->_moveImages[0], _vm->_moveImages[1]); + Gadget *curGadget = _vm->_moveGadgetList; + curGadget->NextGadget = createButton(33, y, 1, 0, _vm->_moveImages[2], _vm->_moveImages[3]); + curGadget = curGadget->NextGadget; + curGadget->NextGadget = createButton(65, y, 2, 0, _vm->_moveImages[4], _vm->_moveImages[5]); + curGadget = curGadget->NextGadget; + curGadget->NextGadget = createButton(97, y, 3, 0, _vm->_moveImages[6], _vm->_moveImages[7]); + curGadget = curGadget->NextGadget; + curGadget->NextGadget = createButton(129, y, 4, 0, _vm->_moveImages[8], _vm->_moveImages[9]); + curGadget = curGadget->NextGadget; + curGadget->NextGadget = createButton(161, y, 5, 0, _vm->_moveImages[12], _vm->_moveImages[13]); + curGadget = curGadget->NextGadget; + curGadget->NextGadget = createButton(193, y, 6, 0, _vm->_moveImages[14], _vm->_moveImages[15]); + curGadget = curGadget->NextGadget; + curGadget->NextGadget = createButton(225, y, 7, 0, _vm->_moveImages[16], _vm->_moveImages[17]); + curGadget = curGadget->NextGadget; + curGadget->NextGadget = createButton(257, y, 8, 0, _vm->_moveImages[18], _vm->_moveImages[19]); + curGadget = curGadget->NextGadget; + curGadget->NextGadget = createButton(289, y, 9, 0, _vm->_moveImages[10], _vm->_moveImages[11]); + } + + Common::File *invFile = g_lab->_resource->openDataFile("P:Inv"); + + if (_vm->getPlatform() == Common::kPlatformWindows) { + for (uint16 imgIdx = 0; imgIdx < 10; imgIdx++) + _vm->_invImages[imgIdx] = new Image(invFile); + + _vm->_invGadgetList = createButton(24, y, 0, 'm', _vm->_invImages[0], _vm->_invImages[1]); + Gadget *curGadget = _vm->_invGadgetList; + curGadget->NextGadget = createButton(56, y, 1, 'g', _vm->_invImages[2], _vm->_invImages[3]); + curGadget = curGadget->NextGadget; + curGadget->NextGadget = createButton(94, y, 2, 'u', _vm->_invImages[4], _vm->_invImages[5]); + curGadget = curGadget->NextGadget; + curGadget->NextGadget = createButton(126, y, 3, 'l', _vm->_moveImages[8], _vm->_moveImages[9]); + curGadget = curGadget->NextGadget; + curGadget->NextGadget = createButton(164, y, 4, VKEY_LTARROW, _vm->_moveImages[14], _vm->_moveImages[15]); + curGadget = curGadget->NextGadget; + curGadget->NextGadget = createButton(196, y, 5, VKEY_RTARROW, _vm->_moveImages[18], _vm->_moveImages[19]); + curGadget = curGadget->NextGadget; + curGadget->NextGadget = createButton(234, y, 6, 'b', _vm->_invImages[6], _vm->_invImages[7]); + curGadget = curGadget->NextGadget; + curGadget->NextGadget = createButton(266, y, 7, 'f', _vm->_invImages[8], _vm->_invImages[9]); + curGadget = curGadget->NextGadget; + } else { + for (uint16 imgIdx = 0; imgIdx < 6; imgIdx++) + _vm->_invImages[imgIdx] = new Image(invFile); + + _vm->_invGadgetList = createButton(58, y, 0, 0, _vm->_invImages[0], _vm->_invImages[1]); + Gadget *curGadget = _vm->_invGadgetList; + curGadget->NextGadget = createButton(90, y, 1, 0, _vm->_invImages[2], _vm->_invImages[3]); + curGadget = curGadget->NextGadget; + curGadget->NextGadget = createButton(128, y, 2, 0, _vm->_invImages[4], _vm->_invImages[5]); + curGadget = curGadget->NextGadget; + curGadget->NextGadget = createButton(160, y, 3, 0, _vm->_moveImages[8], _vm->_moveImages[9]); + curGadget = curGadget->NextGadget; + curGadget->NextGadget = createButton(198, y, 4, 0, _vm->_moveImages[14], _vm->_moveImages[15]); + curGadget = curGadget->NextGadget; + curGadget->NextGadget = createButton(230, y, 5, 0, _vm->_moveImages[18], _vm->_moveImages[19]); + curGadget = curGadget->NextGadget; + } + + delete invFile; + + return true; +} + +/*****************************************************************************/ +/* Sets the pen number to use on all the drawing operations. */ +/*****************************************************************************/ +void DisplayMan::setAPen(byte pennum) { + _curapen = pennum; +} + +/*****************************************************************************/ +/* Fills in a rectangle. */ +/*****************************************************************************/ +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 (y1 + h > _vm->_screenHeight) + h = _vm->_screenHeight - y1; + + if ((w > 0) && (h > 0)) { + char *d = (char *)_vm->getCurrentDrawingBuffer() + y1 * _vm->_screenWidth + x1; + + while (h-- > 0) { + char *dd = d; + int ww = w; + + while (ww-- > 0) { + *dd++ = _curapen; + } + + d += _vm->_screenWidth; + } + } +} + +/*****************************************************************************/ +/* Draws a horizontal line. */ +/*****************************************************************************/ +void DisplayMan::drawVLine(uint16 x, uint16 y1, uint16 y2) { + rectFill(x, y1, x, y2); +} + +/*****************************************************************************/ +/* Draws a vertical line. */ +/*****************************************************************************/ +void DisplayMan::drawHLine(uint16 x1, uint16 y, uint16 x2) { + rectFill(x1, y, x2, y); +} + +void DisplayMan::screenUpdate() { + g_system->copyRectToScreen(_vm->_displayBuffer, _vm->_screenWidth, 0, 0, _vm->_screenWidth, _vm->_screenHeight); + g_system->updateScreen(); + + _vm->_event->processInput(); +} + +/*****************************************************************************/ +/* Sets up either a low-res or a high-res 256 color screen. */ +/*****************************************************************************/ +bool DisplayMan::createScreen(bool hiRes) { + if (hiRes) { + _vm->_screenWidth = 640; + _vm->_screenHeight = 480; + } else { + _vm->_screenWidth = 320; + _vm->_screenHeight = 200; + } + _screenBytesPerPage = _vm->_screenWidth * _vm->_screenHeight; + + _vm->_displayBuffer = new byte[_screenBytesPerPage]; // FIXME: Memory leak! + + return true; +} + } // End of namespace Lab |