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 | |
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')
-rw-r--r-- | engines/lab/anim.cpp | 8 | ||||
-rw-r--r-- | engines/lab/engine.cpp | 307 | ||||
-rw-r--r-- | engines/lab/eventman.cpp | 2 | ||||
-rw-r--r-- | engines/lab/graphics.cpp | 480 | ||||
-rw-r--r-- | engines/lab/graphics.h | 110 | ||||
-rw-r--r-- | engines/lab/interface.cpp | 2 | ||||
-rw-r--r-- | engines/lab/intro.cpp | 24 | ||||
-rw-r--r-- | engines/lab/lab.cpp | 29 | ||||
-rw-r--r-- | engines/lab/lab.h | 34 | ||||
-rw-r--r-- | engines/lab/labfun.h | 42 | ||||
-rw-r--r-- | engines/lab/map.cpp | 40 | ||||
-rw-r--r-- | engines/lab/processroom.cpp | 46 | ||||
-rw-r--r-- | engines/lab/savegame.cpp | 2 | ||||
-rw-r--r-- | engines/lab/special.cpp | 169 | ||||
-rw-r--r-- | engines/lab/text.cpp | 16 | ||||
-rw-r--r-- | engines/lab/vga.cpp | 83 |
16 files changed, 722 insertions, 672 deletions
diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp index f4cae849f7..9402f9cd2a 100644 --- a/engines/lab/anim.cpp +++ b/engines/lab/anim.cpp @@ -462,7 +462,7 @@ void Anim::diffNextFrame() { _curBit = 0; if (DispBitMap->_flags & BITMAPF_VIDEO) - _vm->screenUpdate(); + _vm->_graphics->screenUpdate(); return; /* done with the next frame. */ } @@ -567,7 +567,7 @@ void Anim::diffNextFrame() { _vm->_event->mouseShow(); if (!didTOF) - _vm->screenUpdate(); + _vm->_graphics->screenUpdate(); return; } @@ -602,7 +602,7 @@ void Anim::playDiff() { if (_doBlack) { _doBlack = false; - blackScreen(); + _vm->_graphics->blackScreen(); } _start = *startoffile; /* Make a copy of the pointer to the start of the file */ @@ -683,7 +683,7 @@ void Anim::playDiff() { /*****************************************************************************/ void Anim::stopDiff() { if (_isPlaying && _isAnim) - blackScreen(); + _vm->_graphics->blackScreen(); } /*****************************************************************************/ diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp index d7d9f3b577..293c9452cd 100644 --- a/engines/lab/engine.cpp +++ b/engines/lab/engine.cpp @@ -40,7 +40,7 @@ namespace Lab { -extern bool stopsound, DoNotDrawMessage; +extern bool DoNotDrawMessage; /* Global parser data */ @@ -96,59 +96,6 @@ static char initcolors[] = { '\x00', '\x00', '\x00', '\x30', '\x2c', '\x08', '\x08', '\x08'}; /******************************************************************************/ -/* Draws the control panel display. */ -/******************************************************************************/ -void LabEngine::drawPanel() { - _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 (!_alternate) { - setAPen(4); - drawHLine(0, VGAScaleY(170) + 1, VGAScaleX(319)); /* The horizontal lines under the black one */ - drawGadgetList(_moveGadgetList); - } else { - if (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 (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(_invGadgetList); - } - - _event->mouseShow(); -} - -/******************************************************************************/ /* Draws the message for the room. */ /******************************************************************************/ void LabEngine::drawRoomMessage(uint16 curInv, CloseDataPtr closePtr) { @@ -163,116 +110,14 @@ void LabEngine::drawRoomMessage(uint16 curInv, CloseDataPtr closePtr) { drawStaticMessage(kTextLampOn); else if (_inventory[curInv].Many > 1) { Common::String roomMessage = Common::String(_inventory[curInv].name) + " (" + Common::String::format("%d", _inventory[curInv].Many) + ")"; - drawMessage(roomMessage.c_str()); + _graphics->drawMessage(roomMessage.c_str()); } else - drawMessage(_inventory[curInv].name); + _graphics->drawMessage(_inventory[curInv].name); } } else drawDirection(closePtr); - _lastTooLong = _lastMessageLong; -} - -/******************************************************************************/ -/* Sets up the Labyrinth screens, and opens up the initial windows. */ -/******************************************************************************/ -bool LabEngine::setUpScreens() { - if (!createScreen(_isHiRes)) - return false; - - Common::File *controlFile = g_lab->_resource->openDataFile("P:Control"); - for (uint16 i = 0; i < 20; i++) - _moveImages[i] = new Image(controlFile); - delete controlFile; - - /* Creates the gadgets for the movement control panel */ - uint16 y = VGAScaleY(173) - SVGACord(2); - - if (getPlatform() == Common::kPlatformWindows) { - _moveGadgetList = createButton(1, y, 0, 't', _moveImages[0], _moveImages[1]); - Gadget *curGadget = _moveGadgetList; - curGadget->NextGadget = createButton(33, y, 1, 'm', _moveImages[2], _moveImages[3]); - curGadget = curGadget->NextGadget; - curGadget->NextGadget = createButton(65, y, 2, 'o', _moveImages[4], _moveImages[5]); - curGadget = curGadget->NextGadget; - curGadget->NextGadget = createButton(97, y, 3, 'c', _moveImages[6], _moveImages[7]); - curGadget = curGadget->NextGadget; - curGadget->NextGadget = createButton(129, y, 4, 'l', _moveImages[8], _moveImages[9]); - curGadget = curGadget->NextGadget; - curGadget->NextGadget = createButton(161, y, 5, 'i', _moveImages[12], _moveImages[13]); - curGadget = curGadget->NextGadget; - curGadget->NextGadget = createButton(193, y, 6, VKEY_LTARROW, _moveImages[14], _moveImages[15]); - curGadget = curGadget->NextGadget; - curGadget->NextGadget = createButton(225, y, 7, VKEY_UPARROW, _moveImages[16], _moveImages[17]); - curGadget = curGadget->NextGadget; - curGadget->NextGadget = createButton(257, y, 8, VKEY_RTARROW, _moveImages[18], _moveImages[19]); - curGadget = curGadget->NextGadget; - curGadget->NextGadget = createButton(289, y, 9, 'p', _moveImages[10], _moveImages[11]); - } else { - _moveGadgetList = createButton(1, y, 0, 0, _moveImages[0], _moveImages[1]); - Gadget *curGadget = _moveGadgetList; - curGadget->NextGadget = createButton(33, y, 1, 0, _moveImages[2], _moveImages[3]); - curGadget = curGadget->NextGadget; - curGadget->NextGadget = createButton(65, y, 2, 0, _moveImages[4], _moveImages[5]); - curGadget = curGadget->NextGadget; - curGadget->NextGadget = createButton(97, y, 3, 0, _moveImages[6], _moveImages[7]); - curGadget = curGadget->NextGadget; - curGadget->NextGadget = createButton(129, y, 4, 0, _moveImages[8], _moveImages[9]); - curGadget = curGadget->NextGadget; - curGadget->NextGadget = createButton(161, y, 5, 0, _moveImages[12], _moveImages[13]); - curGadget = curGadget->NextGadget; - curGadget->NextGadget = createButton(193, y, 6, 0, _moveImages[14], _moveImages[15]); - curGadget = curGadget->NextGadget; - curGadget->NextGadget = createButton(225, y, 7, 0, _moveImages[16], _moveImages[17]); - curGadget = curGadget->NextGadget; - curGadget->NextGadget = createButton(257, y, 8, 0, _moveImages[18], _moveImages[19]); - curGadget = curGadget->NextGadget; - curGadget->NextGadget = createButton(289, y, 9, 0, _moveImages[10], _moveImages[11]); - } - - Common::File *invFile = g_lab->_resource->openDataFile("P:Inv"); - - if (getPlatform() == Common::kPlatformWindows) { - for (uint16 imgIdx = 0; imgIdx < 10; imgIdx++) - _invImages[imgIdx] = new Image(invFile); - - _invGadgetList = createButton(24, y, 0, 'm', _invImages[0], _invImages[1]); - Gadget *curGadget = _invGadgetList; - curGadget->NextGadget = createButton(56, y, 1, 'g', _invImages[2], _invImages[3]); - curGadget = curGadget->NextGadget; - curGadget->NextGadget = createButton(94, y, 2, 'u', _invImages[4], _invImages[5]); - curGadget = curGadget->NextGadget; - curGadget->NextGadget = createButton(126, y, 3, 'l', _moveImages[8], _moveImages[9]); - curGadget = curGadget->NextGadget; - curGadget->NextGadget = createButton(164, y, 4, VKEY_LTARROW, _moveImages[14], _moveImages[15]); - curGadget = curGadget->NextGadget; - curGadget->NextGadget = createButton(196, y, 5, VKEY_RTARROW, _moveImages[18], _moveImages[19]); - curGadget = curGadget->NextGadget; - curGadget->NextGadget = createButton(234, y, 6, 'b', _invImages[6], _invImages[7]); - curGadget = curGadget->NextGadget; - curGadget->NextGadget = createButton(266, y, 7, 'f', _invImages[8], _invImages[9]); - curGadget = curGadget->NextGadget; - } else { - for (uint16 imgIdx = 0; imgIdx < 6; imgIdx++) - _invImages[imgIdx] = new Image(invFile); - - _invGadgetList = createButton(58, y, 0, 0, _invImages[0], _invImages[1]); - Gadget *curGadget = _invGadgetList; - curGadget->NextGadget = createButton(90, y, 1, 0, _invImages[2], _invImages[3]); - curGadget = curGadget->NextGadget; - curGadget->NextGadget = createButton(128, y, 2, 0, _invImages[4], _invImages[5]); - curGadget = curGadget->NextGadget; - curGadget->NextGadget = createButton(160, y, 3, 0, _moveImages[8], _moveImages[9]); - curGadget = curGadget->NextGadget; - curGadget->NextGadget = createButton(198, y, 4, 0, _moveImages[14], _moveImages[15]); - curGadget = curGadget->NextGadget; - curGadget->NextGadget = createButton(230, y, 5, 0, _moveImages[18], _moveImages[19]); - curGadget = curGadget->NextGadget; - } - - delete invFile; - - return true; + _lastTooLong = _graphics->_lastMessageLong; } void LabEngine::freeScreens() { @@ -379,7 +224,7 @@ bool LabEngine::doCloseUp(CloseDataPtr closePtr) { } _curFileName = " "; - drawPanel(); + _graphics->drawPanel(); return true; } @@ -394,20 +239,20 @@ const char *LabEngine::getInvName(uint16 CurInv) { if ((CurInv == LAMPNUM) && _conditions->in(LAMPON)) return "P:Mines/120"; - if ((CurInv == BELTNUM) && g_lab->_conditions->in(BELTGLOW)) + if ((CurInv == BELTNUM) && _conditions->in(BELTGLOW)) return "P:Future/BeltGlow"; if (CurInv == WESTPAPERNUM) { - g_lab->_curFileName = _inventory[CurInv].BInvName; - g_lab->_anim->_noPalChange = true; - readPict(g_lab->_curFileName, false); - g_lab->_anim->_noPalChange = false; + _curFileName = _inventory[CurInv].BInvName; + _anim->_noPalChange = true; + _graphics->readPict(_curFileName, false); + _anim->_noPalChange = false; doWestPaper(); } else if (CurInv == NOTESNUM) { - g_lab->_curFileName = _inventory[CurInv].BInvName; - g_lab->_anim->_noPalChange = true; - readPict(g_lab->_curFileName, false); - g_lab->_anim->_noPalChange = false; + _curFileName = _inventory[CurInv].BInvName; + _anim->_noPalChange = true; + _graphics->readPict(_curFileName, false); + _anim->_noPalChange = false; doNotes(); } @@ -434,7 +279,7 @@ void LabEngine::interfaceOn() { _event->mouseShow(); } - if (_longWinInFront) + if (_graphics->_longWinInFront) _event->attachGadgetList(NULL); else if (_alternate) _event->attachGadgetList(_invGadgetList); @@ -454,8 +299,8 @@ bool LabEngine::doUse(uint16 CurInv) { _cptr = NULL; doMap(_roomNum); setPalette(initcolors, 8); - drawMessage(NULL); - drawPanel(); + _graphics->drawMessage(NULL); + _graphics->drawPanel(); } else if (CurInv == JOURNALNUM) { /* LAB: Labyrinth specific */ drawStaticMessage(kTextUseJournal); interfaceOff(); @@ -463,8 +308,8 @@ bool LabEngine::doUse(uint16 CurInv) { _curFileName = " "; _cptr = NULL; doJournal(); - drawPanel(); - drawMessage(NULL); + _graphics->drawPanel(); + _graphics->drawMessage(NULL); } else if (CurInv == LAMPNUM) { /* LAB: Labyrinth specific */ interfaceOff(); @@ -478,7 +323,7 @@ bool LabEngine::doUse(uint16 CurInv) { _anim->_doBlack = false; _anim->_waitForEffect = true; - readPict("Music:Click", true); + _graphics->readPict("Music:Click", true); _anim->_waitForEffect = false; _anim->_doBlack = false; @@ -575,8 +420,8 @@ void LabEngine::mainGameLoop() { _conditions->readInitialConditions("LAB:Conditio"); - _longWinInFront = false; - drawPanel(); + _graphics->_longWinInFront = false; + _graphics->drawPanel(); perFlipGadget(actionMode); @@ -598,7 +443,7 @@ void LabEngine::mainGameLoop() { _cptr = NULL; mayShowCrumbIndicator(); - screenUpdate(); + _graphics->screenUpdate(); } /* Sets the current picture properly on the screen */ @@ -624,15 +469,15 @@ void LabEngine::mainGameLoop() { MainDisplay) /* LAB: Labyrinth specific code */ showTile(_curFileName, (bool)(_cptr->CloseUpType == SPECIALBRICKNOMOUSE)); else - readPict(_curFileName, false); + _graphics->readPict(_curFileName, false); } else - readPict(_curFileName, false); + _graphics->readPict(_curFileName, false); drawRoomMessage(curInv, _cptr); forceDraw = false; mayShowCrumbIndicator(); - screenUpdate(); + _graphics->screenUpdate(); if (!_followingCrumbs) eatMessages(); @@ -641,7 +486,7 @@ void LabEngine::mainGameLoop() { if (forceDraw) { drawRoomMessage(curInv, _cptr); forceDraw = false; - screenUpdate(); + _graphics->screenUpdate(); } } @@ -669,14 +514,14 @@ void LabEngine::mainGameLoop() { GotMessage = true; mayShowCrumbIndicator(); - screenUpdate(); + _graphics->screenUpdate(); if (!from_crumbs(GADGETUP, code, 0, _event->updateAndGetMousePos(), curInv, curMsg, forceDraw, code, actionMode)) break; } } mayShowCrumbIndicator(); - screenUpdate(); + _graphics->screenUpdate(); } else { GotMessage = true; @@ -725,7 +570,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm _anim->_doBlack = false; - if ((msgClass == RAWKEY) && (!_longWinInFront)) { + if ((msgClass == RAWKEY) && (!_graphics->_longWinInFront)) { if (code == 13) { /* The return key */ msgClass = MOUSEBUTTONS; Qualifier = IEQUALIFIER_LEFTBUTTON; @@ -736,7 +581,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm _numCrumbs = 0; _droppingCrumbs = true; mayShowCrumbIndicator(); - screenUpdate(); + _graphics->screenUpdate(); } else if (code == 'f' || code == 'F' || code == 'r' || code == 'R') { /* Follow bread crumbs */ if (_droppingCrumbs) { @@ -755,9 +600,9 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm MainDisplay = true; interfaceOn(); /* Sets the correct gadget list */ - drawPanel(); + _graphics->drawPanel(); drawRoomMessage(curInv, _cptr); - screenUpdate(); + _graphics->screenUpdate(); } } else { _breadCrumbs[0]._roomNum = 0; @@ -765,13 +610,13 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm // Need to hide indicator!!!! mayShowCrumbIndicatorOff(); - screenUpdate(); + _graphics->screenUpdate(); } } } else if ((code == 315) || (code == 'x') || (code == 'X') || (code == 'q') || (code == 'Q')) { /* Quit? */ DoNotDrawMessage = false; - drawMessage("Do you want to quit? (Y/N)"); + _graphics->drawMessage("Do you want to quit? (Y/N)"); doit = false; eatMessages(); interfaceOff(); @@ -813,16 +658,16 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm eatMessages(); } - if (_longWinInFront) { + if (_graphics->_longWinInFront) { if ((msgClass == RAWKEY) || ((msgClass == MOUSEBUTTONS) && ((IEQUALIFIER_LEFTBUTTON & Qualifier) || (IEQUALIFIER_RBUTTON & Qualifier)))) { - _longWinInFront = false; + _graphics->_longWinInFront = false; DoNotDrawMessage = false; - drawPanel(); + _graphics->drawPanel(); drawRoomMessage(curInv, _cptr); - screenUpdate(); + _graphics->screenUpdate(); } } else if ((msgClass == GADGETUP) && !_alternate) { if (gadgetId <= 5) { @@ -833,7 +678,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm hcptr = NULL; _cptr = NULL; mayShowCrumbIndicator(); - screenUpdate(); + _graphics->screenUpdate(); } else if (gadgetId == 5) { eatMessages(); @@ -850,11 +695,11 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm } else decIncInv(&curInv, false); - drawPanel(); + _graphics->drawPanel(); drawRoomMessage(curInv, _cptr); mayShowCrumbIndicator(); - screenUpdate(); + _graphics->screenUpdate(); } else { Old = actionMode; actionMode = gadgetId; @@ -866,13 +711,13 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm if (gadgetId <= 4) drawStaticMessage(kTextTakeWhat + gadgetId); - screenUpdate(); + _graphics->screenUpdate(); } } else if (gadgetId == 9) { doUse(MAPNUM); mayShowCrumbIndicator(); - screenUpdate(); + _graphics->screenUpdate(); } else if (gadgetId >= 6) { /* Arrow Gadgets */ _cptr = NULL; hcptr = NULL; @@ -895,7 +740,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm forceDraw = true; mayShowCrumbIndicator(); - screenUpdate(); + _graphics->screenUpdate(); } else if (gadgetId == 7) { OldRoomNum = _roomNum; @@ -959,7 +804,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm } mayShowCrumbIndicator(); - screenUpdate(); + _graphics->screenUpdate(); } } } else if ((msgClass == GADGETUP) && _alternate) { @@ -973,10 +818,10 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm MainDisplay = true; interfaceOn(); /* Sets the correct gadget list */ - drawPanel(); + _graphics->drawPanel(); drawRoomMessage(curInv, _cptr); - screenUpdate(); + _graphics->screenUpdate(); } gadgetId--; @@ -996,17 +841,17 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm _nextFileName = getInvName(curInv); - drawPanel(); + _graphics->drawPanel(); if (doit) { - drawMessage("Disk operation failed."); + _graphics->drawMessage("Disk operation failed."); setPalette(initcolors, 8); - screenUpdate(); + _graphics->screenUpdate(); g_system->delayMillis(1000); } else { - screenUpdate(); + _graphics->screenUpdate(); } } else if (gadgetId == 1) { if (!doUse(curInv)) { @@ -1019,7 +864,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm drawStaticMessage(kTextUseOnWhat); MainDisplay = true; - screenUpdate(); + _graphics->screenUpdate(); } } else if (gadgetId == 2) { MainDisplay = !MainDisplay; @@ -1035,27 +880,27 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm _inventory[curInv].BInvName) _nextFileName = getInvName(curInv); - screenUpdate(); + _graphics->screenUpdate(); } else if (gadgetId == 3) { /* Left gadget */ decIncInv(&curInv, true); LastInv = curInv; DoNotDrawMessage = false; drawRoomMessage(curInv, _cptr); - screenUpdate(); + _graphics->screenUpdate(); } else if (gadgetId == 4) { /* Right gadget */ decIncInv(&curInv, false); LastInv = curInv; DoNotDrawMessage = false; drawRoomMessage(curInv, _cptr); - screenUpdate(); + _graphics->screenUpdate(); } else if (gadgetId == 5) { /* bread crumbs */ _breadCrumbs[0]._roomNum = 0; _numCrumbs = 0; _droppingCrumbs = true; mayShowCrumbIndicator(); - screenUpdate(); + _graphics->screenUpdate(); } else if (gadgetId == 6) { /* follow crumbs */ if (_droppingCrumbs) { if (_numCrumbs > 0) { @@ -1072,16 +917,16 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm MainDisplay = true; interfaceOn(); /* Sets the correct gadget list */ - drawPanel(); + _graphics->drawPanel(); drawRoomMessage(curInv, _cptr); - screenUpdate(); + _graphics->screenUpdate(); } else { _breadCrumbs[0]._roomNum = 0; _droppingCrumbs = false; // Need to hide indicator!!!! mayShowCrumbIndicatorOff(); - screenUpdate(); + _graphics->screenUpdate(); } } } @@ -1115,7 +960,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 < (VGAScaleY(149) + SVGACord(2))) + else if (curPos.y < (_graphics->VGAScaleY(149) + _graphics->SVGACord(2))) drawStaticMessage(kTextNothing); } else if ((actionMode == 1) /* Manipulate an object */ || (actionMode == 2) /* Open up a "door" */ || @@ -1123,7 +968,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 < (VGAScaleY(149) + SVGACord(2))) + if (curPos.y < (_graphics->VGAScaleY(149) + _graphics->SVGACord(2))) drawStaticMessage(kTextNothing); } } else if (actionMode == 4) { /* Look at closeups */ @@ -1131,15 +976,15 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm setCurClose(curPos, &tempcptr); if (_cptr == tempcptr) { - if (curPos.y < (VGAScaleY(149) + SVGACord(2))) + if (curPos.y < (_graphics->VGAScaleY(149) + _graphics->SVGACord(2))) drawStaticMessage(kTextNothing); } else if (tempcptr->GraphicName) { if (*(tempcptr->GraphicName)) { _anim->_doBlack = true; _cptr = tempcptr; - } else if (curPos.y < (VGAScaleY(149) + SVGACord(2))) + } else if (curPos.y < (_graphics->VGAScaleY(149) + _graphics->SVGACord(2))) drawStaticMessage(kTextNothing); - } else if (curPos.y < (VGAScaleY(149) + SVGACord(2))) + } else if (curPos.y < (_graphics->VGAScaleY(149) + _graphics->SVGACord(2))) drawStaticMessage(kTextNothing); } else if ((actionMode == 5) && _conditions->in(curInv)) { /* Use an item on something else */ @@ -1148,13 +993,13 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm if (!_conditions->in(curInv)) decIncInv(&curInv, false); - } else if (curPos.y < (VGAScaleY(149) + SVGACord(2))) + } else if (curPos.y < (_graphics->VGAScaleY(149) + _graphics->SVGACord(2))) drawStaticMessage(kTextNothing); } } mayShowCrumbIndicator(); - screenUpdate(); + _graphics->screenUpdate(); } else if (msgClass == DELTAMOVE) { VPtr = getViewData(_roomNum, Direction); oldcptr = VPtr->closeUps; @@ -1182,7 +1027,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm } if (hcptr) - _event->setMousePos(Common::Point(scaleX((hcptr->x1 + hcptr->x2) / 2), scaleY((hcptr->y1 + hcptr->y2) / 2))); + _event->setMousePos(Common::Point(_graphics->scaleX((hcptr->x1 + hcptr->x2) / 2), _graphics->scaleY((hcptr->y1 + hcptr->y2) / 2))); } else if ((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) { eatMessages(); _alternate = !_alternate; @@ -1198,11 +1043,11 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm decIncInv(&curInv, false); } - drawPanel(); + _graphics->drawPanel(); drawRoomMessage(curInv, _cptr); mayShowCrumbIndicator(); - screenUpdate(); + _graphics->screenUpdate(); } return true; } @@ -1220,9 +1065,9 @@ void LabEngine::go() { return; } - if (!setUpScreens()) { + if (!_graphics->setUpScreens()) { _isHiRes = false; - mem = mem && setUpScreens(); + mem = mem && _graphics->setUpScreens(); } _event->initMouse(); @@ -1250,16 +1095,16 @@ void LabEngine::go() { debug("\n\nNot enough memory to start game.\n\n"); if (QuitLab) { /* Won the game */ - blackAllScreen(); - readPict("P:End/L2In.1", true); + _graphics->blackAllScreen(); + _graphics->readPict("P:End/L2In.1", true); for (uint16 i = 0; i < 120; i++) { _music->updateMusic(); waitTOF(); } - readPict("P:End/L2In.9", true); - readPict("P:End/Lost", true); + _graphics->readPict("P:End/L2In.9", true); + _graphics->readPict("P:End/Lost", true); warning("STUB: waitForPress"); while (!1) { // 1 means ignore SDL_ProcessInput calls diff --git a/engines/lab/eventman.cpp b/engines/lab/eventman.cpp index 751f387e05..6b73de79b5 100644 --- a/engines/lab/eventman.cpp +++ b/engines/lab/eventman.cpp @@ -156,7 +156,7 @@ void EventManager::updateMouse() { } if (doUpdateDisplay) - _vm->screenUpdate(); + _vm->_graphics->screenUpdate(); } 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 diff --git a/engines/lab/graphics.h b/engines/lab/graphics.h new file mode 100644 index 0000000000..de2053a002 --- /dev/null +++ b/engines/lab/graphics.h @@ -0,0 +1,110 @@ +/* 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_GRAPHICS_H +#define LAB_GRAPHICS_H + +namespace Lab { + +class LabEngine; + +class DisplayMan { +private: + LabEngine *_vm; + + byte _curapen; + +public: + bool _longWinInFront; + bool _lastMessageLong; + uint32 _screenBytesPerPage; + + DisplayMan(LabEngine *lab); + + 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); + bool readPict(const char *filename, bool playOnce); + byte *readPictToMem(const char *filename, uint16 x, uint16 y); + void doScrollBlack(); + void copyPage(uint16 width, uint16 height, uint16 nheight, uint16 startline, byte *mem); + void doScrollWipe(char *filename); + void doScrollBounce(); + void doTransWipe(CloseDataPtr *cPtr, char *filename); + void doWipe(uint16 wipeType, CloseDataPtr *cPtr, char *filename); + void blackScreen(); + void whiteScreen(); + void blackAllScreen(); + void createBox(uint16 y2); + void drawPanel(); + bool setUpScreens(); + int32 longDrawMessage(const char *str); + void drawMessage(const char *str); + void setAPen(byte pennum); + void rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2); + /* Window text stuff */ + uint32 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 */ + bool fillback, /* Whether to fill the background */ + bool centerh, /* Whether to center the text horizontally */ + bool centerv, /* Whether to center the text vertically */ + bool output, /* Whether to output any text */ + uint16 x1, uint16 y1, /* Cords */ + uint16 x2, uint16 y2, + const char *text); /* The text itself */ + + uint32 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 */ + bool fillback, /* Whether to fill the background */ + bool centerh, /* Whether to center the text horizontally */ + bool centerv, /* Whether to center the text vertically */ + bool output, /* Whether to output any text */ + uint16 x1, uint16 y1, /* Cords */ + uint16 x2, uint16 y2, + const char *str); /* The text itself */ + + void drawHLine(uint16 x, uint16 y1, uint16 y2); + void drawVLine(uint16 x1, uint16 y, uint16 x2); + void screenUpdate(); + bool createScreen(bool HiRes); +}; + +} // End of namespace Lab + +#endif // LAB_GRAPHICS_H diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp index 7352b61017..30aa5472a1 100644 --- a/engines/lab/interface.cpp +++ b/engines/lab/interface.cpp @@ -43,7 +43,7 @@ Common::KeyState _keyPressed; Gadget *createButton(uint16 x, uint16 y, uint16 id, uint16 key, Image *im, Image *imalt) { Gadget *gptr; - x = VGAScaleX(x); + x = g_lab->_graphics->VGAScaleX(x); if ((gptr = new Gadget())) { gptr->x = x; diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp index 43cbed669b..aab50f49c7 100644 --- a/engines/lab/intro.cpp +++ b/engines/lab/intro.cpp @@ -106,13 +106,13 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) { fade(false, 0); if (isScreen) { - _vm->setAPen(7); - _vm->rectFill(VGAScaleX(10), VGAScaleY(10), VGAScaleX(310), VGAScaleY(190)); + _vm->_graphics->setAPen(7); + _vm->_graphics->rectFill(_vm->_graphics->VGAScaleX(10), _vm->_graphics->VGAScaleY(10), _vm->_graphics->VGAScaleX(310), _vm->_graphics->VGAScaleY(190)); - Drawn = flowText(msgFont, (!_vm->_isHiRes) * -1, 5, 7, false, false, true, true, VGAScaleX(14), VGAScaleY(11), VGAScaleX(306), VGAScaleY(189), (char *)curPlace); + Drawn = _vm->_graphics->flowText(msgFont, (!_vm->_isHiRes) * -1, 5, 7, false, false, true, true, _vm->_graphics->VGAScaleX(14), _vm->_graphics->VGAScaleY(11), _vm->_graphics->VGAScaleX(306), _vm->_graphics->VGAScaleY(189), (char *)curPlace); fade(true, 0); } else { - Drawn = _vm->longDrawMessage((char *)curPlace); + Drawn = _vm->_graphics->longDrawMessage((char *)curPlace); } curPlace += Drawn; @@ -227,7 +227,7 @@ void Intro::nReadPict(const char *filename, bool playOnce) { _vm->_anim->_doBlack = _introDoBlack; _vm->_anim->stopDiffEnd(); - readPict(finalFileName.c_str(), playOnce); + _vm->_graphics->readPict(finalFileName.c_str(), playOnce); } /*****************************************************************************/ @@ -259,8 +259,7 @@ void Intro::introSequence() { } } - blackAllScreen(); - + _vm->_graphics->blackAllScreen(); _vm->_music->initMusic(); _vm->_anim->_noPalChange = true; @@ -301,8 +300,7 @@ void Intro::introSequence() { } fade(false, 0); - blackAllScreen(); - + _vm->_graphics->blackAllScreen(); _vm->_music->updateMusic(); nReadPict("Title.A", true); @@ -328,7 +326,7 @@ void Intro::introSequence() { _vm->_music->newOpen("p:Intro/Intro.1"); /* load the picture into the buffer */ _vm->_music->updateMusic(); - blackAllScreen(); + _vm->_graphics->blackAllScreen(); _vm->_music->updateMusic(); TextFont *msgFont = _vm->_resource->getFont("P:Map.fon"); @@ -349,7 +347,7 @@ void Intro::introSequence() { freeAllStolenMem(); - blackAllScreen(); + _vm->_graphics->blackAllScreen(); _vm->_music->updateMusic(); _introDoBlack = true; @@ -443,8 +441,8 @@ void Intro::introSequence() { nReadPict("SubX", true); if (_quitIntro) { - _vm->setAPen(0); - _vm->rectFill(0, 0, _vm->_screenWidth - 1, _vm->_screenHeight - 1); + _vm->_graphics->setAPen(0); + _vm->_graphics->rectFill(0, 0, _vm->_screenWidth - 1, _vm->_screenHeight - 1); _vm->_anim->_doBlack = true; } diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp index 90c713135b..efa675299f 100644 --- a/engines/lab/lab.cpp +++ b/engines/lab/lab.cpp @@ -55,16 +55,13 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc), _extraGameFeatures(0) { g_lab = this; - _screenWidth = 320; + _screenWidth = 320; _screenHeight = 200; - _screenBytesPerPage = 65536; - _curapen = 0; + _currentDisplayBuffer = 0; + _displayBuffer = 0; - _currentDisplayBuffer = 0; - _displayBuffer = 0; - - _lastWaitTOFTicks = 0; + _lastWaitTOFTicks = 0; _isHiRes = false; _roomNum = -1; @@ -86,9 +83,9 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc) _resource = nullptr; _music = nullptr; _anim = nullptr; + _graphics = nullptr; - _lastMessageLong = false; - _lastTooLong = false; + _lastTooLong = false; _interfaceOff = false; _alternate = false; @@ -104,15 +101,13 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc) _nextFileName = nullptr; _newFileName = nullptr; - _moveGadgetList = 0; - _invGadgetList = 0; - - _curFileName = " "; + _moveGadgetList = 0; + _invGadgetList = 0; - _longWinInFront = false; - _msgFont = 0; + _curFileName = " "; + _msgFont = 0; - _inventory = 0; + _inventory = 0; //const Common::FSNode gameDataDir(ConfMan.get("path")); //SearchMan.addSubDirectoryMatching(gameDataDir, "game"); @@ -129,6 +124,7 @@ LabEngine::~LabEngine() { delete _resource; delete _music; delete _anim; + delete _graphics; } Common::Error LabEngine::run() { @@ -141,6 +137,7 @@ Common::Error LabEngine::run() { _resource = new Resource(this); _music = new Music(this); _anim = new Anim(this); + _graphics = new DisplayMan(this); if (getPlatform() == Common::kPlatformWindows) { // Check if this is the Wyrmkeep trial diff --git a/engines/lab/lab.h b/engines/lab/lab.h index d8b75cbc62..9cf28dfbc8 100644 --- a/engines/lab/lab.h +++ b/engines/lab/lab.h @@ -41,6 +41,7 @@ #include "lab/music.h" #include "lab/resource.h" #include "lab/anim.h" +#include "lab/graphics.h" struct ADGameDescription; @@ -74,8 +75,6 @@ public: int _screenWidth; int _screenHeight; - uint32 _screenBytesPerPage; - // timing.cpp void getTime(uint32 *secs, uint32 *micros); @@ -87,24 +86,19 @@ public: private: uint32 _extraGameFeatures; bool _interfaceOff; - bool _alternate; - Image *_moveImages[20]; - Image *_invImages[10]; - Gadget *_moveGadgetList; - Gadget *_invGadgetList; // timing.cpp void microDelay(uint32 secs, uint32 micros); // vga.cpp byte _curvgapal[256 * 3]; - byte _curapen; public: EventManager *_event; Resource *_resource; Music *_music; Anim *_anim; + DisplayMan *_graphics; int _roomNum; byte *_currentDisplayBuffer; @@ -117,6 +111,7 @@ public: bool _isCrumbTurning; uint32 _crumbSecs, _crumbMicros; bool _isCrumbWaiting; + bool _alternate; byte *_tempScrollData; bool _isHiRes; byte *_displayBuffer; @@ -124,46 +119,34 @@ public: const char *_nextFileName; const char *_newFileName; /* When ProcessRoom.c decides to change the filename of the current picture. */ + TextFont *_msgFont; + Gadget *_moveGadgetList; + Gadget *_invGadgetList; + Image *_moveImages[20]; + Image *_invImages[10]; private: int _lastWaitTOFTicks; - bool _lastMessageLong; bool _lastTooLong; - TextFont *_msgFont; - bool _longWinInFront; CloseDataPtr _cptr; InventoryData *_inventory; private: - bool createScreen(bool HiRes); bool from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Common::Point tmpPos, uint16 &curInv, IntuiMessage * curMsg, bool &forceDraw, uint16 gadgetId, uint16 &actionMode); public: void waitTOF(); - void setAPen(byte pennum); void writeColorRegs(byte *buf, uint16 first, uint16 numreg); byte *getCurrentDrawingBuffer(); - void screenUpdate(); - void rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2); 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 drawHLine(uint16 x, uint16 y1, uint16 y2); - void drawVLine(uint16 x1, uint16 y, uint16 x2); - void drawPanel(); void drawRoomMessage(uint16 CurInv, CloseDataPtr cptr); void interfaceOff(); void interfaceOn(); void decIncInv(uint16 *CurInv, bool dec); - int32 longDrawMessage(const char *str); - void drawMessage(const char *str); - void doScrollBlack(); - void doScrollWipe(char *filename); - void doScrollBounce(); - void doWipe(uint16 WipeType, CloseDataPtr *cPtr, char *filename); - void doTransWipe(CloseDataPtr *cPtr, char *filename); Gadget *checkNumGadgetHit(Gadget *gadlist, uint16 key); IntuiMessage *getMsg(); void drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, bool fadein); @@ -184,7 +167,6 @@ public: private: // engine.cpp - bool setUpScreens(); void freeScreens(); void perFlipGadget(uint16 gadID); bool doCloseUp(CloseDataPtr cptr); diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h index 987864b097..d81de5c4e5 100644 --- a/engines/lab/labfun.h +++ b/engines/lab/labfun.h @@ -71,41 +71,8 @@ struct SaveGameHeader { /* Reads in pictures */ -bool readPict(const char *filename, bool PlayOnce); bool readMusic(const char *filename, bool waitTillFinished); -byte *readPictToMem(const char *filename, uint16 x, uint16 y); - -/* Window text stuff */ - -uint32 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 */ - bool fillback, /* Whether to fill the background */ - bool centerh, /* Whether to center the text horizontally */ - bool centerv, /* Whether to center the text vertically */ - bool output, /* Whether to output any text */ - uint16 x1, /* Cords */ - uint16 y1, uint16 x2, uint16 y2, const char *text); /* The text itself */ - -uint32 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 */ - bool fillback, /* Whether to fill the background */ - bool centerh, /* Whether to center the text horizontally */ - bool centerv, /* Whether to center the text vertically */ - bool output, /* Whether to output any text */ - uint16 x1, /* Cords */ - uint16 y1, uint16 x2, uint16 y2, const char *text); /* The text itself */ - -void drawMessage(const char *text); void drawStaticMessage(byte index); -int32 longDrawMessage(const char *text); - -/* The Wipes */ - -void doWipe(uint16 WipeType, CloseDataPtr *cptr, char *filename); /* Double Buffer stuff */ @@ -173,11 +140,6 @@ public: /*----- From Machine.c ------*/ /*---------------------------*/ -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); char *translateFileName(const char *filename); @@ -211,10 +173,6 @@ void mouseCombination(Common::Point pos); void showTile(const char *filename, bool showsolution); void mouseTile(Common::Point pos); -void blackScreen(); -void blackAllScreen(); -void whiteScreen(); - } // End of namespace Lab #endif /* LAB_LABFUN_H */ diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 9ca57b0001..f5746baa42 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -164,8 +164,8 @@ static bool loadMapData() { gptr = MapGadgetList; while (gptr) { - gptr->x = VGAScaleX(MapGadX[counter]); - gptr->y = VGAScaleY(MapGadY[counter]); + gptr->x = g_lab->_graphics->VGAScaleX(MapGadX[counter]); + gptr->y = g_lab->_graphics->VGAScaleY(MapGadY[counter]); gptr = gptr->NextGadget; counter++; } @@ -479,8 +479,8 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou if (fadeout) fade(false, 0); - setAPen(0); - rectFill(0, 0, _screenWidth - 1, _screenHeight - 1); + _graphics->setAPen(0); + _graphics->rectFill(0, 0, _screenWidth - 1, _screenHeight - 1); Map->drawImage(0, 0); drawGadgetList(MapGadgetList); @@ -528,7 +528,7 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou HugeMaze->drawImage(mapScaleX(524), mapScaleY(97)); } else if (Floor == SURMAZEFLOOR) { sptr = (char *)_resource->getStaticText(kTextSurmazeMessage).c_str(); - flowText(_msgFont, 0, 7, 0, true, true, true, true, mapScaleX(360), 0, mapScaleX(660), mapScaleY(450), sptr); + _graphics->flowText(_msgFont, 0, 7, 0, true, true, true, true, mapScaleX(360), 0, mapScaleX(660), mapScaleY(450), sptr); } switch (Floor) { @@ -559,10 +559,10 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou } if (sptr) - flowText(_msgFont, 0, 5, 3, true, true, true, true, VGAScaleX(14), VGAScaleY(75), VGAScaleX(134), VGAScaleY(97), sptr); + _graphics->flowText(_msgFont, 0, 5, 3, true, true, true, true, _graphics->VGAScaleX(14), _graphics->VGAScaleY(75), _graphics->VGAScaleX(134), _graphics->VGAScaleY(97), sptr); if ((sptr = _rooms[CurMsg]._roomMsg)) - flowText(_msgFont, 0, 5, 3, true, true, true, true, VGAScaleX(14), VGAScaleY(148), VGAScaleX(134), VGAScaleY(186), sptr); + _graphics->flowText(_msgFont, 0, 5, 3, true, true, true, true, _graphics->VGAScaleX(14), _graphics->VGAScaleY(148), _graphics->VGAScaleX(134), _graphics->VGAScaleY(186), sptr); if (fadein) fade(true, 0); @@ -715,9 +715,9 @@ void LabEngine::processMap(uint16 CurRoom) { if ((sptr = _rooms[CurMsg]._roomMsg)) { _event->mouseHide(); - setAPen(3); - rectFill(VGAScaleX(13), VGAScaleY(148), VGAScaleX(135), VGAScaleY(186)); - flowText(_msgFont, 0, 5, 3, true, true, true, true, VGAScaleX(14), VGAScaleY(148), VGAScaleX(134), VGAScaleY(186), sptr); + _graphics->setAPen(3); + _graphics->rectFill(_graphics->VGAScaleX(13), _graphics->VGAScaleY(148), _graphics->VGAScaleX(135), _graphics->VGAScaleY(186)); + _graphics->flowText(_msgFont, 0, 5, 3, true, true, true, true, _graphics->VGAScaleX(14), _graphics->VGAScaleY(148), _graphics->VGAScaleX(134), _graphics->VGAScaleY(186), sptr); if (Maps[OldMsg].PageNumber == CurFloor) drawRoom(OldMsg, (bool)(OldMsg == CurRoom)); @@ -727,8 +727,8 @@ void LabEngine::processMap(uint16 CurRoom) { y1 = (y1 + y2) / 2; if ((CurMsg != CurRoom) && (Maps[CurMsg].PageNumber == CurFloor)) { - setAPen(1); - rectFill(x1 - 1, y1, x1, y1); + _graphics->setAPen(1); + _graphics->rectFill(x1 - 1, y1, x1, y1); } _event->mouseShow(); @@ -737,7 +737,7 @@ void LabEngine::processMap(uint16 CurRoom) { } } - screenUpdate(); + _graphics->screenUpdate(); } } } @@ -751,7 +751,7 @@ void LabEngine::doMap(uint16 CurRoom) { _music->updateMusic(); loadMapData(); - blackAllScreen(); + _graphics->blackAllScreen(); if (Direction == NORTH) XMark = MapNorth; @@ -765,18 +765,18 @@ void LabEngine::doMap(uint16 CurRoom) { drawMap(CurRoom, CurRoom, Maps[CurRoom].PageNumber, false, true); _event->mouseShow(); _event->attachGadgetList(MapGadgetList); - screenUpdate(); + _graphics->screenUpdate(); processMap(CurRoom); _event->attachGadgetList(NULL); fade(false, 0); - blackAllScreen(); + _graphics->blackAllScreen(); _event->mouseHide(); - setAPen(0); - rectFill(0, 0, _screenWidth - 1, _screenHeight - 1); + _graphics->setAPen(0); + _graphics->rectFill(0, 0, _screenWidth - 1, _screenHeight - 1); freeMapData(); - blackAllScreen(); + _graphics->blackAllScreen(); _event->mouseShow(); - screenUpdate(); + _graphics->screenUpdate(); } } // End of namespace Lab diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp index 954bf00f68..0b812556a8 100644 --- a/engines/lab/processroom.cpp +++ b/engines/lab/processroom.cpp @@ -110,8 +110,8 @@ static CloseData *getObject(uint16 x, uint16 y, CloseDataPtr lcptr) { } while (lcptr != NULL) { - if ((x >= scaleX(lcptr->x1)) && (y >= scaleY(lcptr->y1)) && - (x <= scaleX(lcptr->x2)) && (y <= scaleY(lcptr->y2))) + 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))) return lcptr; lcptr = lcptr->NextCloseUp; @@ -167,7 +167,7 @@ char *getPictName(CloseDataPtr *lcptr) { /*****************************************************************************/ void LabEngine::drawDirection(CloseDataPtr lcptr) { if (lcptr != NULL && lcptr->Message) { - drawMessage(lcptr->Message); + _graphics->drawMessage(lcptr->Message); return; } @@ -187,7 +187,7 @@ void LabEngine::drawDirection(CloseDataPtr lcptr) { else if (Direction == WEST) message += _resource->getStaticText(kTextFacingWest); - drawMessage(message.c_str()); + _graphics->drawMessage(message.c_str()); } /*****************************************************************************/ @@ -252,10 +252,10 @@ void setCurClose(Common::Point pos, CloseDataPtr *cptr, bool useAbsoluteCoords) x2 = lcptr->x2; y2 = lcptr->y2; } else { - x1 = scaleX(lcptr->x1); - y1 = scaleY(lcptr->y1); - x2 = scaleX(lcptr->x2); - y2 = scaleY(lcptr->y2); + 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); } if (pos.x >= x1 && pos.y >= y1 && pos.x <= x2 && pos.y <= y2 && lcptr->GraphicName) { @@ -283,8 +283,8 @@ bool takeItem(uint16 x, uint16 y, CloseDataPtr *cptr) { while (lcptr != NULL) { - if ((x >= scaleX(lcptr->x1)) && (y >= scaleY(lcptr->y1)) && - (x <= scaleX(lcptr->x2)) && (y <= scaleY(lcptr->y2)) && + 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)) && (lcptr->CloseUpType < 0)) { g_lab->_conditions->inclElement(abs(lcptr->CloseUpType)); return true; @@ -326,11 +326,11 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) { break; case SHOWDIFF: - readPict((char *)aptr->Data, true); + _graphics->readPict((char *)aptr->Data, true); break; case SHOWDIFFCONT: - readPict((char *)aptr->Data, false); + _graphics->readPict((char *)aptr->Data, false); break; case LOADDIFF: @@ -345,7 +345,7 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) { break; case WIPECMD: - doWipe(aptr->Param1, lcptr, (char *)aptr->Data); + _graphics->doWipe(aptr->Param1, lcptr, (char *)aptr->Data); break; case NOUPDATE: @@ -362,7 +362,7 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) { if (strcmp(test, _curFileName) != 0) { _curFileName = test; - readPict(_curFileName, true); + _graphics->readPict(_curFileName, true); } } break; @@ -378,10 +378,10 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) { case SHOWMESSAGE: DoNotDrawMessage = false; - if (_longWinInFront) - longDrawMessage((char *)aptr->Data); + if (_graphics->_longWinInFront) + _graphics->longDrawMessage((char *)aptr->Data); else - drawMessage((char *)aptr->Data); + _graphics->drawMessage((char *)aptr->Data); DoNotDrawMessage = true; break; @@ -389,7 +389,7 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) { case CSHOWMESSAGE: if (*lcptr == NULL) { DoNotDrawMessage = false; - drawMessage((char *)aptr->Data); + _graphics->drawMessage((char *)aptr->Data); DoNotDrawMessage = true; } @@ -398,7 +398,7 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) { case SHOWMESSAGES: { char **str = (char **)aptr->Data; DoNotDrawMessage = false; - drawMessage(str[getRandom(aptr->Param1)]); + _graphics->drawMessage(str[getRandom(aptr->Param1)]); DoNotDrawMessage = true; } break; @@ -407,7 +407,7 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) { if (aptr->Param1 & 0x8000) { // This is a Wyrmkeep Windows trial version, thus stop at this // point, since we can't check for game payment status - readPict(getPictName(lcptr), true); + _graphics->readPict(getPictName(lcptr), true); aptr = NULL; GUI::MessageDialog trialMessage("This is the end of the trial version. You can play the full game using the original interpreter from Wyrmkeep"); trialMessage.runModal(); @@ -421,7 +421,7 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) { break; case SETCLOSEUP: { - CloseDataPtr tlcptr = getObject(scaleX(aptr->Param1), scaleY(aptr->Param2), *lcptr); + CloseDataPtr tlcptr = getObject(g_lab->_graphics->scaleX(aptr->Param1), g_lab->_graphics->scaleY(aptr->Param2), *lcptr); if (tlcptr) *lcptr = tlcptr; @@ -455,7 +455,7 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) { addCurTime(aptr->Param1, 0, &startSecs, &startMicros); - screenUpdate(); + _graphics->screenUpdate(); while (1) { _music->updateMusic(); @@ -543,7 +543,7 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) { waitTOF(); waitTOF(); } else if (aptr->Param1 == 4) { /* white the palette */ - whiteScreen(); + _graphics->whiteScreen(); waitTOF(); waitTOF(); } else if (aptr->Param1 == 6) { /* Restore the palette */ diff --git a/engines/lab/savegame.cpp b/engines/lab/savegame.cpp index bfe089c96b..7f56c8e64e 100644 --- a/engines/lab/savegame.cpp +++ b/engines/lab/savegame.cpp @@ -138,7 +138,7 @@ bool saveGame(uint16 Direction, uint16 Quarters, int slot, Common::String desc) // Load scene pic CloseDataPtr cPtr = NULL; - readPict(getPictName(&cPtr), true); + g_lab->_graphics->readPict(getPictName(&cPtr), true); writeSaveGameHeader(file, desc); file->writeUint16LE(g_lab->_roomNum); diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 9f36303a1d..3be558b8af 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -109,9 +109,9 @@ static byte *loadBackPict(const char *fileName, bool tomem) { g_lab->_anim->_noPalChange = true; if (tomem) - res = readPictToMem(fileName, g_lab->_screenWidth, g_lab->_screenHeight); + res = g_lab->_graphics->readPictToMem(fileName, g_lab->_screenWidth, g_lab->_screenHeight); else - readPict(fileName, true); + g_lab->_graphics->readPict(fileName, true); for (uint16 i = 0; i < 16; i++) { hipal[i] = ((g_lab->_anim->_diffPalette[i * 3] >> 2) << 8) + @@ -129,7 +129,7 @@ static byte *loadBackPict(const char *fileName, bool tomem) { /*****************************************************************************/ static void doCombination() { for (uint16 i = 0; i <= 5; i++) - Images[combination[i]]->drawImage(VGAScaleX(combx[i]), VGAScaleY(65)); + Images[combination[i]]->drawImage(g_lab->_graphics->VGAScaleX(combx[i]), g_lab->_graphics->VGAScaleY(65)); } /*****************************************************************************/ @@ -139,10 +139,10 @@ void showCombination(const char *filename) { resetBuffer(); g_lab->_anim->_doBlack = true; g_lab->_anim->_noPalChange = true; - readPict(filename, true); + g_lab->_graphics->readPict(filename, true); g_lab->_anim->_noPalChange = false; - blackScreen(); + g_lab->_graphics->blackScreen(); Common::File *numFile = g_lab->_resource->openDataFile("P:Numbers"); @@ -188,9 +188,9 @@ static void changeCombination(uint16 number) { display._imageData = g_lab->getCurrentDrawingBuffer(); - g_lab->scrollDisplayY(2, VGAScaleX(combx[number]), VGAScaleY(65), VGAScaleX(combx[number]) + (Images[combnum])->_width - 1, VGAScaleY(65) + (Images[combnum])->_height); + g_lab->scrollDisplayY(2, g_lab->_graphics->VGAScaleX(combx[number]), g_lab->_graphics->VGAScaleY(65), g_lab->_graphics->VGAScaleX(combx[number]) + (Images[combnum])->_width - 1, g_lab->_graphics->VGAScaleY(65) + (Images[combnum])->_height); - Images[combnum]->bltBitMap(0, (Images[combnum])->_height - (2 * i), &(display), VGAScaleX(combx[number]), VGAScaleY(65), (Images[combnum])->_width, 2); + Images[combnum]->bltBitMap(0, (Images[combnum])->_height - (2 * i), &(display), g_lab->_graphics->VGAScaleX(combx[number]), g_lab->_graphics->VGAScaleY(65), (Images[combnum])->_width, 2); } for (uint16 i = 0; i < 6; i++) @@ -240,20 +240,20 @@ static void doTile(bool showsolution) { int16 rows, cols; if (showsolution) { - rowm = VGAScaleY(23); - colm = VGAScaleX(27); + rowm = g_lab->_graphics->VGAScaleY(23); + colm = g_lab->_graphics->VGAScaleX(27); - rows = VGAScaleY(31); - cols = VGAScaleX(105); + rows = g_lab->_graphics->VGAScaleY(31); + cols = g_lab->_graphics->VGAScaleX(105); } else { - g_lab->setAPen(0); - g_lab->rectFill(VGAScaleX(97), VGAScaleY(22), VGAScaleX(220), VGAScaleY(126)); + g_lab->_graphics->setAPen(0); + g_lab->_graphics->rectFill(g_lab->_graphics->VGAScaleX(97), g_lab->_graphics->VGAScaleY(22), g_lab->_graphics->VGAScaleX(220), g_lab->_graphics->VGAScaleY(126)); - rowm = VGAScaleY(25); - colm = VGAScaleX(30); + rowm = g_lab->_graphics->VGAScaleY(25); + colm = g_lab->_graphics->VGAScaleX(30); - rows = VGAScaleY(25); - cols = VGAScaleX(100); + rows = g_lab->_graphics->VGAScaleY(25); + cols = g_lab->_graphics->VGAScaleX(100); } while (row < 4) { @@ -283,9 +283,9 @@ void showTile(const char *filename, bool showsolution) { resetBuffer(); g_lab->_anim->_doBlack = true; g_lab->_anim->_noPalChange = true; - readPict(filename, true); + g_lab->_graphics->readPict(filename, true); g_lab->_anim->_noPalChange = false; - blackScreen(); + g_lab->_graphics->blackScreen(); Common::File *tileFile = tileFile = g_lab->_resource->openDataFile(showsolution ? "P:TileSolution" : "P:Tile"); @@ -317,33 +317,33 @@ static void doTileScroll(uint16 col, uint16 row, uint16 scrolltype) { uint16 last = 0, x1, y1; if (scrolltype == LEFTSCROLL) { - dX = VGAScaleX(5); - sx = VGAScaleX(5); + dX = g_lab->_graphics->VGAScaleX(5); + sx = g_lab->_graphics->VGAScaleX(5); last = 6; } else if (scrolltype == RIGHTSCROLL) { - dX = VGAScaleX(-5); - dx = VGAScaleX(-5); - sx = VGAScaleX(5); + dX = g_lab->_graphics->VGAScaleX(-5); + dx = g_lab->_graphics->VGAScaleX(-5); + sx = g_lab->_graphics->VGAScaleX(5); last = 6; } else if (scrolltype == UPSCROLL) { - dY = VGAScaleY(5); - sy = VGAScaleY(5); + dY = g_lab->_graphics->VGAScaleY(5); + sy = g_lab->_graphics->VGAScaleY(5); last = 5; } else if (scrolltype == DOWNSCROLL) { - dY = VGAScaleY(-5); - dy = VGAScaleY(-5); - sy = VGAScaleY(5); + dY = g_lab->_graphics->VGAScaleY(-5); + dy = g_lab->_graphics->VGAScaleY(-5); + sy = g_lab->_graphics->VGAScaleY(5); last = 5; } - sx += SVGACord(2); + sx += g_lab->_graphics->SVGACord(2); - x1 = VGAScaleX(100) + (col * VGAScaleX(30)) + dx; - y1 = VGAScaleY(25) + (row * VGAScaleY(25)) + dy; + x1 = g_lab->_graphics->VGAScaleX(100) + (col * g_lab->_graphics->VGAScaleX(30)) + dx; + y1 = g_lab->_graphics->VGAScaleY(25) + (row * g_lab->_graphics->VGAScaleY(25)) + dy; for (uint16 i = 0; i < last; i++) { g_lab->waitTOF(); - scrollRaster(dX, dY, x1, y1, x1 + VGAScaleX(28) + sx, y1 + VGAScaleY(23) + sy); + scrollRaster(dX, dY, x1, y1, x1 + g_lab->_graphics->VGAScaleX(28) + sx, y1 + g_lab->_graphics->VGAScaleY(23) + sy); x1 += dX; y1 += dY; } @@ -413,7 +413,7 @@ static void changeTile(uint16 col, uint16 row) { if (check) { g_lab->_conditions->inclElement(BRICKOPEN); /* unlocked combination */ g_lab->_anim->_doBlack = true; - check = readPict("p:Up/BDOpen", true); + check = g_lab->_graphics->readPict("p:Up/BDOpen", true); } } } @@ -444,7 +444,7 @@ void doNotes() { TextFont *noteFont = g_lab->_resource->getFont("P:Note.fon"); char *ntext = g_lab->_resource->getText("Lab:Rooms/Notes"); - flowText(noteFont, -2 + SVGACord(1), 0, 0, false, false, true, true, VGAScaleX(25) + SVGACord(15), VGAScaleY(50), VGAScaleX(295) - SVGACord(15), VGAScaleY(148), ntext); + 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); closeFont(noteFont); @@ -464,28 +464,28 @@ void doWestPaper() { paperFont = g_lab->_resource->getFont("P:News22.fon"); ntext = g_lab->_resource->getText("Lab:Rooms/Date"); - flowText(paperFont, 0, 0, 0, false, true, false, true, VGAScaleX(57), VGAScaleY(77) + SVGACord(2), VGAScaleX(262), VGAScaleY(91), ntext); + 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); 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 = flowText(paperFont, -8, 0, 0, false, true, false, true, VGAScaleX(57), VGAScaleY(86) - SVGACord(2), VGAScaleX(262), VGAScaleY(118), ntext); + 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); if (CharsPrinted < FileLen) { - y = 130 - SVGACord(5); - flowText(paperFont, -8 - SVGACord(1), 0, 0, false, true, false, true, VGAScaleX(57), VGAScaleY(86) - SVGACord(2), VGAScaleX(262), VGAScaleY(132), ntext); + 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); } else - y = 115 - SVGACord(5); + y = 115 - g_lab->_graphics->SVGACord(5); closeFont(paperFont); delete[] ntext; paperFont = g_lab->_resource->getFont("P:Note.fon"); ntext = g_lab->_resource->getText("Lab:Rooms/Col1"); - CharsPrinted = flowText(paperFont, -4, 0, 0, false, false, false, true, VGAScaleX(45), VGAScaleY(y), VGAScaleX(158), VGAScaleY(148), ntext); + CharsPrinted = g_lab->_graphics->flowText(paperFont, -4, 0, 0, false, false, false, true, g_lab->_graphics->VGAScaleX(45), g_lab->_graphics->VGAScaleY(y), g_lab->_graphics->VGAScaleX(158), g_lab->_graphics->VGAScaleY(148), ntext); delete[] ntext; ntext = g_lab->_resource->getText("Lab:Rooms/Col2"); - CharsPrinted = flowText(paperFont, -4, 0, 0, false, false, false, true, VGAScaleX(162), VGAScaleY(y), VGAScaleX(275), VGAScaleY(148), ntext); + CharsPrinted = g_lab->_graphics->flowText(paperFont, -4, 0, 0, false, false, false, true, g_lab->_graphics->VGAScaleX(162), g_lab->_graphics->VGAScaleY(y), g_lab->_graphics->VGAScaleX(275), g_lab->_graphics->VGAScaleY(148), ntext); delete[] ntext; closeFont(paperFont); @@ -550,12 +550,12 @@ static bool loadJournalData() { uint16 counter = 0; while (TopGadget) { - TopGadget->x = VGAScaleX(JGadX[counter]); + TopGadget->x = g_lab->_graphics->VGAScaleX(JGadX[counter]); if (counter == 1) - TopGadget->y = VGAScaleY(JGadY[counter]) + SVGACord(1); + TopGadget->y = g_lab->_graphics->VGAScaleY(JGadY[counter]) + g_lab->_graphics->SVGACord(1); else - TopGadget->y = VGAScaleY(JGadY[counter]) - SVGACord(1); + TopGadget->y = g_lab->_graphics->VGAScaleY(JGadY[counter]) - g_lab->_graphics->SVGACord(1); TopGadget->GadgetID = counter; TopGadget = TopGadget->NextGadget; @@ -576,7 +576,7 @@ static void drawJournalText() { while (DrawingToPage < JPage) { g_lab->_music->updateMusic(); CurText = (char *)(journaltext + CharsDrawn); - CharsDrawn += flowText(journalFont, -2, 2, 0, false, false, false, false, VGAScaleX(52), VGAScaleY(32), VGAScaleX(152), VGAScaleY(148), CurText); + CharsDrawn += g_lab->_graphics->flowText(journalFont, -2, 2, 0, false, false, false, false, g_lab->_graphics->VGAScaleX(52), g_lab->_graphics->VGAScaleY(32), g_lab->_graphics->VGAScaleX(152), g_lab->_graphics->VGAScaleY(148), CurText); lastpage = (*CurText == 0); @@ -588,16 +588,16 @@ static void drawJournalText() { if (JPage <= 1) { CurText = journaltexttitle; - flowTextToMem(&JBackImage, journalFont, -2, 2, 0, false, true, true, true, VGAScaleX(52), VGAScaleY(32), VGAScaleX(152), VGAScaleY(148), CurText); + 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); } else { CurText = (char *)(journaltext + CharsDrawn); - CharsDrawn += flowTextToMem(&JBackImage, journalFont, -2, 2, 0, false, false, false, true, VGAScaleX(52), VGAScaleY(32), VGAScaleX(152), VGAScaleY(148), CurText); + 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); } g_lab->_music->updateMusic(); CurText = (char *)(journaltext + CharsDrawn); lastpage = (*CurText == 0); - flowTextToMem(&JBackImage, journalFont, -2, 2, 0, false, false, false, true, VGAScaleX(171), VGAScaleY(32), VGAScaleX(271), VGAScaleY(148), CurText); + 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); CurText = (char *)(journaltext + CharsDrawn); lastpage = lastpage || (*CurText == 0); @@ -660,7 +660,7 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) { fade(true, 0); g_lab->_anim->_noPalChange = true; - JBackImage._imageData = readPictToMem("P:Journal.pic", _screenWidth, _screenHeight); + JBackImage._imageData = _graphics->readPictToMem("P:Journal.pic", _screenWidth, _screenHeight); GotBackImage = true; eatMessages(); @@ -716,7 +716,7 @@ void LabEngine::processJournal() { /*****************************************************************************/ void LabEngine::doJournal() { resetBuffer(); - blackAllScreen(); + _graphics->blackAllScreen(); lastpage = false; GotBackImage = false; @@ -745,9 +745,9 @@ void LabEngine::doJournal() { ScreenImage._imageData = getCurrentDrawingBuffer(); - setAPen(0); - rectFill(0, 0, _screenWidth - 1, _screenHeight - 1); - blackScreen(); + _graphics->setAPen(0); + _graphics->rectFill(0, 0, _screenWidth - 1, _screenHeight - 1); + _graphics->blackScreen(); freeAllStolenMem(); } @@ -783,11 +783,11 @@ bool LabEngine::saveRestoreGame() { if (slot >= 0) { isOK = loadGame(&Direction, &(_inventory[QUARTERNUM].Many), slot); if (isOK) - g_lab->_music->resetMusic(); + _music->resetMusic(); } } - g_lab->screenUpdate(); + _graphics->screenUpdate(); return isOK; } @@ -820,31 +820,31 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16 text += 2; fheight = textHeight(monitorFont); - x1 = MonButton->_width + VGAScaleX(3); - MonGadHeight = MonButton->_height + VGAScaleY(3); + x1 = MonButton->_width + _graphics->VGAScaleX(3); + MonGadHeight = MonButton->_height + _graphics->VGAScaleY(3); if (MonGadHeight > fheight) yspacing = MonGadHeight - fheight; else MonGadHeight = fheight; - setAPen(0); - rectFill(0, 0, _screenWidth - 1, y2); + _graphics->setAPen(0); + _graphics->rectFill(0, 0, _screenWidth - 1, y2); for (uint16 i = 0; i < numlines; i++) MonButton->drawImage(0, i * MonGadHeight); } else if (isinteractive) { - setAPen(0); - rectFill(0, 0, _screenWidth - 1, y2); + _graphics->setAPen(0); + _graphics->rectFill(0, 0, _screenWidth - 1, y2); } else { - setAPen(0); - rectFill(x1, y1, x2, y2); + _graphics->setAPen(0); + _graphics->rectFill(x1, y1, x2, y2); } while (DrawingToPage < monitorPage) { _music->updateMusic(); CurText = (char *)(text + CharsDrawn); - CharsDrawn += flowText(monitorFont, yspacing, 0, 0, false, false, false, false, x1, y1, x2, y2, CurText); + CharsDrawn += _graphics->flowText(monitorFont, yspacing, 0, 0, false, false, false, false, x1, y1, x2, y2, CurText); lastpage = (*CurText == 0); if (lastpage) @@ -855,7 +855,7 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16 CurText = (char *)(text + CharsDrawn); lastpage = (*CurText == 0); - CharsDrawn = flowText(monitorFont, yspacing, 2, 0, false, false, false, true, x1, y1, x2, y2, CurText); + CharsDrawn = _graphics->flowText(monitorFont, yspacing, 2, 0, false, false, false, true, x1, y1, x2, y2, CurText); CurText += CharsDrawn; lastpage = lastpage || (*CurText == 0); @@ -914,20 +914,20 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isintera return; else if ((Class == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & Qualifier)) { - if ((MouseY >= VGAScaleY(171)) && (MouseY <= VGAScaleY(200))) { - if ((MouseX >= VGAScaleX(259)) && (MouseX <= VGAScaleX(289))) { + 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 (!lastpage) { monitorPage += 1; drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive); } - } else if ((MouseX >= VGAScaleX(0)) && (MouseX <= VGAScaleX(31))) { + } else if ((MouseX >= g_lab->_graphics->VGAScaleX(0)) && (MouseX <= g_lab->_graphics->VGAScaleX(31))) { return; - } else if ((MouseX >= VGAScaleX(290)) && (MouseX <= VGAScaleX(320))) { + } else if ((MouseX >= g_lab->_graphics->VGAScaleX(290)) && (MouseX <= g_lab->_graphics->VGAScaleX(320))) { if (monitorPage >= 1) { monitorPage -= 1; drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive); } - } else if ((MouseX >= VGAScaleX(31)) && (MouseX <= VGAScaleX(59))) { + } else if ((MouseX >= g_lab->_graphics->VGAScaleX(31)) && (MouseX <= g_lab->_graphics->VGAScaleX(59))) { if (isinteractive) { monitorPage = 0; @@ -962,20 +962,19 @@ 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 = VGAScaleX(x1); - x2 = VGAScaleX(x2); - y1 = VGAScaleY(y1); - y2 = VGAScaleY(y2); + x1 = _graphics->VGAScaleX(x1); + x2 = _graphics->VGAScaleX(x2); + y1 = _graphics->VGAScaleY(y1); + y2 = _graphics->VGAScaleY(y2); TextFileName = textfile; - blackAllScreen(); - - readPict("P:Mon/Monitor.1", true); - readPict("P:Mon/NWD1", true); - readPict("P:Mon/NWD2", true); - readPict("P:Mon/NWD3", true); - blackAllScreen(); + _graphics->blackAllScreen(); + _graphics->readPict("P:Mon/Monitor.1", true); + _graphics->readPict("P:Mon/NWD1", true); + _graphics->readPict("P:Mon/NWD2", true); + _graphics->readPict("P:Mon/NWD3", true); + _graphics->blackAllScreen(); resetBuffer(); monitorPage = 0; @@ -997,9 +996,9 @@ void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive, closeFont(monitorFont); freeAllStolenMem(); - setAPen(0); - rectFill(0, 0, _screenWidth - 1, _screenHeight - 1); - blackAllScreen(); + _graphics->setAPen(0); + _graphics->rectFill(0, 0, _screenWidth - 1, _screenHeight - 1); + _graphics->blackAllScreen(); } } // End of namespace Lab diff --git a/engines/lab/text.cpp b/engines/lab/text.cpp index 63ec12bad0..1c1cacdac3 100644 --- a/engines/lab/text.cpp +++ b/engines/lab/text.cpp @@ -82,9 +82,9 @@ void text(TextFont *tf, uint16 x, uint16 y, uint16 color, const char *text, uint for (uint16 i = 0; i < numchars; i++) { RealOffset = (g_lab->_screenWidth * y) + x; - curpage = RealOffset / g_lab->_screenBytesPerPage; - SegmentOffset = RealOffset - (curpage * g_lab->_screenBytesPerPage); - LeftInSegment = g_lab->_screenBytesPerPage - SegmentOffset; + curpage = RealOffset / g_lab->_graphics->_screenBytesPerPage; + SegmentOffset = RealOffset - (curpage * g_lab->_graphics->_screenBytesPerPage); + LeftInSegment = g_lab->_graphics->_screenBytesPerPage - SegmentOffset; VGACur = VGATop + SegmentOffset; if (tf->Widths[(uint)*text]) { @@ -117,10 +117,10 @@ void text(TextFont *tf, uint16 x, uint16 y, uint16 color, const char *text, uint curpage++; VGATemp = (byte *)(VGATop - templeft); /* Set up VGATempLine for next line */ - VGATempLine -= g_lab->_screenBytesPerPage; + VGATempLine -= g_lab->_graphics->_screenBytesPerPage; /* Set up LeftInSegment for next line */ - LeftInSegment += g_lab->_screenBytesPerPage + templeft; - templeft += g_lab->_screenBytesPerPage; + LeftInSegment += g_lab->_graphics->_screenBytesPerPage + templeft; + templeft += g_lab->_graphics->_screenBytesPerPage; } if (mask & data) @@ -142,8 +142,8 @@ void text(TextFont *tf, uint16 x, uint16 y, uint16 color, const char *text, uint if (LeftInSegment <= 0) { curpage++; - VGATempLine -= g_lab->_screenBytesPerPage; - LeftInSegment += g_lab->_screenBytesPerPage; + VGATempLine -= g_lab->_graphics->_screenBytesPerPage; + LeftInSegment += g_lab->_graphics->_screenBytesPerPage; } } } diff --git a/engines/lab/vga.cpp b/engines/lab/vga.cpp index 727914025a..8ee0d3445e 100644 --- a/engines/lab/vga.cpp +++ b/engines/lab/vga.cpp @@ -37,24 +37,6 @@ namespace Lab { /*****************************************************************************/ -/* Sets up either a low-res or a high-res 256 color screen. */ -/*****************************************************************************/ -bool LabEngine::createScreen(bool hiRes) { - if (hiRes) { - _screenWidth = 640; - _screenHeight = 480; - } else { - _screenWidth = 320; - _screenHeight = 200; - } - _screenBytesPerPage = _screenWidth * _screenHeight; - - _displayBuffer = new byte[_screenBytesPerPage]; // FIXME: Memory leak! - - return true; -} - -/*****************************************************************************/ /* Sets the current page on the VGA card. */ /*****************************************************************************/ void LabEngine::changeVolume(int delta) { @@ -104,13 +86,6 @@ void LabEngine::setPalette(void *cmap, uint16 numcolors) { writeColorRegs((byte *)cmap, 0, numcolors); } -void LabEngine::screenUpdate() { - g_system->copyRectToScreen(_displayBuffer, _screenWidth, 0, 0, _screenWidth, _screenHeight); - g_system->updateScreen(); - - _event->processInput(); -} - /*****************************************************************************/ /* Returns the base address of the current VGA display. */ /*****************************************************************************/ @@ -150,8 +125,8 @@ void LabEngine::scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 im.readScreenImage(x1, y1); im.drawImage(x1 + dx, y1); - setAPen(0); - rectFill(x1, y1, x1 + dx - 1, y2); + _graphics->setAPen(0); + _graphics->rectFill(x1, y1, x1 + dx - 1, y2); } /*****************************************************************************/ @@ -181,58 +156,8 @@ void LabEngine::scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 im.readScreenImage(x1, y1); im.drawImage(x1, y1 + dy); - setAPen(0); - rectFill(x1, y1, x2, y1 + dy - 1); -} - -/*****************************************************************************/ -/* Sets the pen number to use on all the drawing operations. */ -/*****************************************************************************/ -void LabEngine::setAPen(byte pennum) { - _curapen = pennum; -} - -/*****************************************************************************/ -/* Fills in a rectangle. */ -/*****************************************************************************/ -void LabEngine::rectFill(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; - - while (ww-- > 0) { - *dd++ = _curapen; - } - - d += _screenWidth; - } - } -} - -/*****************************************************************************/ -/* Draws a horizontal line. */ -/*****************************************************************************/ -void LabEngine::drawVLine(uint16 x, uint16 y1, uint16 y2) { - rectFill(x, y1, x, y2); -} - -/*****************************************************************************/ -/* Draws a vertical line. */ -/*****************************************************************************/ -void LabEngine::drawHLine(uint16 x1, uint16 y, uint16 x2) { - rectFill(x1, y, x2, y); + _graphics->setAPen(0); + _graphics->rectFill(x1, y1, x2, y1 + dy - 1); } /*****************************************************************************/ |