LAB: Put vga.cpp into LabEngine class

This commit is contained in:
Eugene Sandulenko 2015-11-24 23:59:30 +01:00 committed by Willem Jan Palenstijn
parent 4b65faaa63
commit 93e3ba9edd
18 changed files with 342 additions and 382 deletions

View file

@ -32,7 +32,6 @@
#include "lab/stddefines.h" #include "lab/stddefines.h"
#include "lab/labfun.h" #include "lab/labfun.h"
#include "lab/diff.h" #include "lab/diff.h"
#include "lab/vga.h"
#include "lab/text.h" #include "lab/text.h"
#include "lab/intro.h" #include "lab/intro.h"
#include "lab/parsefun.h" #include "lab/parsefun.h"
@ -132,7 +131,7 @@ static char initcolors[] = { '\x00', '\x00', '\x00', '\x30',
/******************************************************************************/ /******************************************************************************/
/* Draws the control panel display. */ /* Draws the control panel display. */
/******************************************************************************/ /******************************************************************************/
void drawPanel() { void LabEngine::drawPanel() {
mouseHide(); mouseHide();
setAPen(3); /* Clear Area */ setAPen(3); /* Clear Area */
@ -219,7 +218,7 @@ static void drawRoomMessage(uint16 CurInv, CloseDataPtr cptr) {
/******************************************************************************/ /******************************************************************************/
/* Sets up the Labyrinth screens, and opens up the initial windows. */ /* Sets up the Labyrinth screens, and opens up the initial windows. */
/******************************************************************************/ /******************************************************************************/
bool setUpScreens() { bool LabEngine::setUpScreens() {
uint16 counter; uint16 counter;
byte *buffer; byte *buffer;
byte *MovePanelBuffer, *InvPanelBuffer; byte *MovePanelBuffer, *InvPanelBuffer;
@ -349,7 +348,7 @@ bool setUpScreens() {
/******************************************************************************/ /******************************************************************************/
/* Permanently flips the imagry of a gadget. */ /* Permanently flips the imagry of a gadget. */
/******************************************************************************/ /******************************************************************************/
static void perFlipGadget(uint16 GadID) { void LabEngine::perFlipGadget(uint16 GadID) {
Image *Temp; Image *Temp;
Gadget *TopGad; Gadget *TopGad;
@ -391,7 +390,7 @@ void eatMessages() {
/******************************************************************************/ /******************************************************************************/
/* Checks whether the close up is one of the special case closeups. */ /* Checks whether the close up is one of the special case closeups. */
/******************************************************************************/ /******************************************************************************/
static bool doCloseUp(CloseDataPtr cptr) { bool LabEngine::doCloseUp(CloseDataPtr cptr) {
if (cptr == NULL) if (cptr == NULL)
return false; return false;
@ -527,8 +526,7 @@ static const char *Test;
/******************************************************************************/ /******************************************************************************/
/* If the user hits the "Use" gadget; things that can get used on themselves. */ /* If the user hits the "Use" gadget; things that can get used on themselves. */
/******************************************************************************/ /******************************************************************************/
static bool doUse(uint16 CurInv) { bool LabEngine::doUse(uint16 CurInv) {
if (CurInv == MAPNUM) { /* LAB: Labyrinth specific */ if (CurInv == MAPNUM) { /* LAB: Labyrinth specific */
drawStaticMessage(kTextUseMap); drawStaticMessage(kTextUseMap);
interfaceOff(); interfaceOff();
@ -539,9 +537,7 @@ static bool doUse(uint16 CurInv) {
VGASetPal(initcolors, 8); VGASetPal(initcolors, 8);
drawMessage(NULL); drawMessage(NULL);
drawPanel(); drawPanel();
} } else if (CurInv == JOURNALNUM) { /* LAB: Labyrinth specific */
else if (CurInv == JOURNALNUM) { /* LAB: Labyrinth specific */
drawStaticMessage(kTextUseJournal); drawStaticMessage(kTextUseJournal);
interfaceOff(); interfaceOff();
stopDiff(); stopDiff();
@ -550,17 +546,15 @@ static bool doUse(uint16 CurInv) {
doJournal(); doJournal();
drawPanel(); drawPanel();
drawMessage(NULL); drawMessage(NULL);
} } else if (CurInv == LAMPNUM) { /* LAB: Labyrinth specific */
else if (CurInv == LAMPNUM) { /* LAB: Labyrinth specific */
interfaceOff(); interfaceOff();
if (g_lab->_conditions->in(LAMPON)) { if (_conditions->in(LAMPON)) {
drawStaticMessage(kTextTurnLampOff); drawStaticMessage(kTextTurnLampOff);
g_lab->_conditions->exclElement(LAMPON); _conditions->exclElement(LAMPON);
} else { } else {
drawStaticMessage(kTextTurnLampOn); drawStaticMessage(kTextTurnLampOn);
g_lab->_conditions->inclElement(LAMPON); _conditions->inclElement(LAMPON);
} }
DoBlack = false; DoBlack = false;
@ -570,32 +564,22 @@ static bool doUse(uint16 CurInv) {
DoBlack = false; DoBlack = false;
Test = getInvName(CurInv); Test = getInvName(CurInv);
} } else if (CurInv == BELTNUM) { /* LAB: Labyrinth specific */
if (!_conditions->in(BELTGLOW))
else if (CurInv == BELTNUM) { /* LAB: Labyrinth specific */ _conditions->inclElement(BELTGLOW);
if (!g_lab->_conditions->in(BELTGLOW))
g_lab->_conditions->inclElement(BELTGLOW);
DoBlack = false; DoBlack = false;
Test = getInvName(CurInv); Test = getInvName(CurInv);
} } else if (CurInv == WHISKEYNUM) { /* LAB: Labyrinth specific */
_conditions->inclElement(USEDHELMET);
else if (CurInv == WHISKEYNUM) { /* LAB: Labyrinth specific */
g_lab->_conditions->inclElement(USEDHELMET);
drawStaticMessage(kTextUseWhiskey); drawStaticMessage(kTextUseWhiskey);
} } else if (CurInv == PITHHELMETNUM) { /* LAB: Labyrinth specific */
_conditions->inclElement(USEDHELMET);
else if (CurInv == PITHHELMETNUM) { /* LAB: Labyrinth specific */
g_lab->_conditions->inclElement(USEDHELMET);
drawStaticMessage(kTextUsePith); drawStaticMessage(kTextUsePith);
} } else if (CurInv == HELMETNUM) { /* LAB: Labyrinth specific */
_conditions->inclElement(USEDHELMET);
else if (CurInv == HELMETNUM) { /* LAB: Labyrinth specific */
g_lab->_conditions->inclElement(USEDHELMET);
drawStaticMessage(kTextUseHelmet); drawStaticMessage(kTextUseHelmet);
} } else
else
return false; return false;
return true; return true;
@ -651,7 +635,7 @@ static void decIncInv(uint16 *CurInv, bool dec) {
/******************************************************************************/ /******************************************************************************/
/* The main game loop */ /* The main game loop */
/******************************************************************************/ /******************************************************************************/
static void mainGameLoop() { void LabEngine::mainGameLoop() {
IntuiMessage *Msg; IntuiMessage *Msg;
uint32 Class; uint32 Class;
@ -1474,8 +1458,8 @@ byte dropCrumbsOff[] = { 0x00 };
Image DropCrumbsImage = { 24, 24, dropCrumbs }; Image DropCrumbsImage = { 24, 24, dropCrumbs };
Image DropCrumbsOffImage = { 24, 24, dropCrumbsOff }; Image DropCrumbsOffImage = { 24, 24, dropCrumbsOff };
void mayShowCrumbIndicator() { void LabEngine::mayShowCrumbIndicator() {
if (g_lab->getPlatform() != Common::kPlatformWindows) if (getPlatform() != Common::kPlatformWindows)
return; return;
if (DroppingCrumbs && MainDisplay) { if (DroppingCrumbs && MainDisplay) {
@ -1485,8 +1469,8 @@ void mayShowCrumbIndicator() {
} }
} }
void mayShowCrumbIndicatorOff() { void LabEngine::mayShowCrumbIndicatorOff() {
if (g_lab->getPlatform() != Common::kPlatformWindows) if (getPlatform() != Common::kPlatformWindows)
return; return;
if (MainDisplay) { if (MainDisplay) {

View file

@ -35,7 +35,6 @@
#include "lab/labfun.h" #include "lab/labfun.h"
#include "lab/parsefun.h" #include "lab/parsefun.h"
#include "lab/mouse.h" #include "lab/mouse.h"
#include "lab/vga.h"
#include "lab/text.h" #include "lab/text.h"
#include "lab/resource.h" #include "lab/resource.h"
@ -242,14 +241,14 @@ uint32 flowText(void *font, /* the TextAttr pointer */
uint16 x, y; uint16 x, y;
if (fillback) { if (fillback) {
setAPen(backpen); g_lab->setAPen(backpen);
rectFill(x1, y1, x2, y2); g_lab->rectFill(x1, y1, x2, y2);
} }
if (str == NULL) if (str == NULL)
return 0L; return 0L;
setAPen(pencolor); g_lab->setAPen(pencolor);
fontheight = textHeight(msgfont) + spacing; fontheight = textHeight(msgfont) + spacing;
numlines = (y2 - y1 + 1) / fontheight; numlines = (y2 - y1 + 1) / fontheight;
@ -289,10 +288,6 @@ uint32 flowText(void *font, /* the TextAttr pointer */
return (str - temp); return (str - temp);
} }
extern byte *_currentDsplayBuffer;
/******************************************************************************/ /******************************************************************************/
/* Calls flowText, but flows it to memory. Same restrictions as flowText. */ /* Calls flowText, but flows it to memory. Same restrictions as flowText. */
/******************************************************************************/ /******************************************************************************/
@ -307,15 +302,15 @@ uint32 flowTextToMem(Image *DestIm, void *font, /* the TextAttr pointer */
uint16 x1, /* Cords */ uint16 x1, /* Cords */
uint16 y1, uint16 x2, uint16 y2, const char *str) { /* The text itself */ uint16 y1, uint16 x2, uint16 y2, const char *str) { /* The text itself */
uint32 res, vgabyte = g_lab->_screenBytesPerPage; uint32 res, vgabyte = g_lab->_screenBytesPerPage;
byte *tmp = _currentDsplayBuffer; byte *tmp = g_lab->_currentDsplayBuffer;
_currentDsplayBuffer = DestIm->ImageData; g_lab->_currentDsplayBuffer = DestIm->ImageData;
g_lab->_screenBytesPerPage = (uint32) DestIm->Width * (int32) DestIm->Height; g_lab->_screenBytesPerPage = (uint32) DestIm->Width * (int32) DestIm->Height;
res = flowText(font, spacing, pencolor, backpen, fillback, centerh, centerv, output, x1, y1, x2, y2, str); res = flowText(font, spacing, pencolor, backpen, fillback, centerh, centerv, output, x1, y1, x2, y2, str);
g_lab->_screenBytesPerPage = vgabyte; g_lab->_screenBytesPerPage = vgabyte;
_currentDsplayBuffer = tmp; g_lab->_currentDsplayBuffer = tmp;
return res; return res;
} }
@ -328,14 +323,14 @@ uint32 flowTextToMem(Image *DestIm, void *font, /* the TextAttr pointer */
void createBox(uint16 y2) { void createBox(uint16 y2) {
setAPen(7); /* Message box area */ g_lab->setAPen(7); /* Message box area */
rectFill(VGAScaleX(4), VGAScaleY(154), VGAScaleX(315), VGAScaleY(y2 - 2)); g_lab->rectFill(VGAScaleX(4), VGAScaleY(154), VGAScaleX(315), VGAScaleY(y2 - 2));
setAPen(0); /* Box around message area */ g_lab->setAPen(0); /* Box around message area */
drawHLine(VGAScaleX(2), VGAScaleY(152), VGAScaleX(317)); g_lab->drawHLine(VGAScaleX(2), VGAScaleY(152), VGAScaleX(317));
drawVLine(VGAScaleX(317), VGAScaleY(152), VGAScaleY(y2)); g_lab->drawVLine(VGAScaleX(317), VGAScaleY(152), VGAScaleY(y2));
drawHLine(VGAScaleX(2), VGAScaleY(y2), VGAScaleX(317)); g_lab->drawHLine(VGAScaleX(2), VGAScaleY(y2), VGAScaleX(317));
drawVLine(VGAScaleX(2), VGAScaleY(152), VGAScaleY(y2)); g_lab->drawVLine(VGAScaleX(2), VGAScaleY(152), VGAScaleY(y2));
} }
@ -355,8 +350,8 @@ int32 longDrawMessage(const char *str) {
if (!LongWinInFront) { if (!LongWinInFront) {
LongWinInFront = true; LongWinInFront = true;
setAPen(3); /* Clear Area */ g_lab->setAPen(3); /* Clear Area */
rectFill(0, VGAScaleY(149) + SVGACord(2), VGAScaleX(319), VGAScaleY(199)); g_lab->rectFill(0, VGAScaleY(149) + SVGACord(2), VGAScaleX(319), VGAScaleY(199));
} }
createBox(198); createBox(198);
@ -387,7 +382,7 @@ void drawMessage(const char *str) {
} else { } else {
if (LongWinInFront) { if (LongWinInFront) {
LongWinInFront = false; LongWinInFront = false;
drawPanel(); g_lab->drawPanel();
} }
mouseHide(); mouseHide();
@ -434,10 +429,10 @@ static void doScrollBlack() {
Im.Height = height; Im.Height = height;
Im.ImageData = mem; Im.ImageData = mem;
g_music->updateMusic(); g_music->updateMusic();
readScreenImage(&Im, 0, 0); g_lab->readScreenImage(&Im, 0, 0);
g_music->updateMusic(); g_music->updateMusic();
BaseAddr = (uint32 *) getVGABaseAddr(); BaseAddr = (uint32 *)g_lab->getVGABaseAddr();
by = VGAScaleX(4); by = VGAScaleX(4);
nheight = height; nheight = height;
@ -446,9 +441,9 @@ static void doScrollBlack() {
g_music->updateMusic(); g_music->updateMusic();
if (!IsHiRes) if (!IsHiRes)
waitTOF(); g_lab->waitTOF();
BaseAddr = (uint32 *) getVGABaseAddr(); BaseAddr = (uint32 *)g_lab->getVGABaseAddr();
if (by > nheight) if (by > nheight)
by = nheight; by = nheight;
@ -470,10 +465,10 @@ static void doScrollBlack() {
tempmem += copysize; tempmem += copysize;
} }
setAPen(0); g_lab->setAPen(0);
rectFill(0, nheight, width - 1, nheight + by - 1); g_lab->rectFill(0, nheight, width - 1, nheight + by - 1);
WSDL_UpdateScreen(); g_lab->WSDL_UpdateScreen();
if (!IsHiRes) { if (!IsHiRes) {
if (nheight <= (height / 8)) if (nheight <= (height / 8))
@ -503,7 +498,7 @@ static void copyPage(uint16 width, uint16 height, uint16 nheight, uint16 startli
uint16 CurPage; uint16 CurPage;
uint32 *BaseAddr; uint32 *BaseAddr;
BaseAddr = (uint32 *)getVGABaseAddr(); BaseAddr = (uint32 *)g_lab->getVGABaseAddr();
size = (int32)(height - nheight) * (int32) width; size = (int32)(height - nheight) * (int32) width;
mem += startline * width; mem += startline * width;
@ -539,12 +534,12 @@ static void doScrollWipe(char *filename) {
while (g_music->isSoundEffectActive()) { while (g_music->isSoundEffectActive()) {
g_music->updateMusic(); g_music->updateMusic();
waitTOF(); g_lab->waitTOF();
} }
IsBM = true; IsBM = true;
readPict(filename, true); readPict(filename, true);
VGASetPal(diffcmap, 256); g_lab->VGASetPal(diffcmap, 256);
IsBM = false; IsBM = false;
mem = RawDiffBM.Planes[0]; mem = RawDiffBM.Planes[0];
@ -566,7 +561,7 @@ static void doScrollWipe(char *filename) {
copyPage(width, height, nheight, startline, mem); copyPage(width, height, nheight, startline, mem);
WSDL_UpdateScreen(); g_lab->WSDL_UpdateScreen();
if (!nheight) if (!nheight)
startline += by; startline += by;
@ -618,8 +613,8 @@ static void doScrollBounce() {
startline -= newby[counter]; startline -= newby[counter];
copyPage(width, height, 0, startline, mem); copyPage(width, height, 0, startline, mem);
WSDL_UpdateScreen(); g_lab->WSDL_UpdateScreen();
waitTOF(); g_lab->waitTOF();
} }
for (int counter = 8; counter > 0; counter--) { for (int counter = 8; counter > 0; counter--) {
@ -627,8 +622,8 @@ static void doScrollBounce() {
startline += newby1[counter - 1]; startline += newby1[counter - 1];
copyPage(width, height, 0, startline, mem); copyPage(width, height, 0, startline, mem);
WSDL_UpdateScreen(); g_lab->WSDL_UpdateScreen();
waitTOF(); g_lab->waitTOF();
} }
@ -658,17 +653,17 @@ static void doTransWipe(CloseDataPtr *CPtr, char *filename) {
while (CurY < LastY) { while (CurY < LastY) {
if (linesdone >= lineslast) { if (linesdone >= lineslast) {
g_music->updateMusic(); g_music->updateMusic();
waitTOF(); g_lab->waitTOF();
linesdone = 0; linesdone = 0;
} }
ghoastRect(0, 0, CurY, g_lab->_screenWidth - 1, CurY + 1); g_lab->ghoastRect(0, 0, CurY, g_lab->_screenWidth - 1, CurY + 1);
CurY += 4; CurY += 4;
linesdone++; linesdone++;
} }
} }
setAPen(0); g_lab->setAPen(0);
for (counter = 0; counter < 2; counter++) { for (counter = 0; counter < 2; counter++) {
CurY = counter * 2; CurY = counter * 2;
@ -676,11 +671,11 @@ static void doTransWipe(CloseDataPtr *CPtr, char *filename) {
while (CurY <= LastY) { while (CurY <= LastY) {
if (linesdone >= lineslast) { if (linesdone >= lineslast) {
g_music->updateMusic(); g_music->updateMusic();
waitTOF(); g_lab->waitTOF();
linesdone = 0; linesdone = 0;
} }
rectFill(0, CurY, g_lab->_screenWidth - 1, CurY + 1); g_lab->rectFill(0, CurY, g_lab->_screenWidth - 1, CurY + 1);
CurY += 4; CurY += 4;
linesdone++; linesdone++;
} }
@ -694,7 +689,7 @@ static void doTransWipe(CloseDataPtr *CPtr, char *filename) {
CurFileName = getPictName(CPtr); CurFileName = getPictName(CPtr);
byte *BitMapMem = readPictToMem(CurFileName, g_lab->_screenWidth, LastY + 5); byte *BitMapMem = readPictToMem(CurFileName, g_lab->_screenWidth, LastY + 5);
VGASetPal(diffcmap, 256); g_lab->VGASetPal(diffcmap, 256);
if (BitMapMem) { if (BitMapMem) {
ImSource.Width = g_lab->_screenWidth; ImSource.Width = g_lab->_screenWidth;
@ -703,7 +698,7 @@ static void doTransWipe(CloseDataPtr *CPtr, char *filename) {
ImDest.Width = g_lab->_screenWidth; ImDest.Width = g_lab->_screenWidth;
ImDest.Height = g_lab->_screenHeight; ImDest.Height = g_lab->_screenHeight;
ImDest.ImageData = getVGABaseAddr(); ImDest.ImageData = g_lab->getVGABaseAddr();
for (counter = 0; counter < 2; counter++) { for (counter = 0; counter < 2; counter++) {
CurY = counter * 2; CurY = counter * 2;
@ -711,14 +706,14 @@ static void doTransWipe(CloseDataPtr *CPtr, char *filename) {
while (CurY < LastY) { while (CurY < LastY) {
if (linesdone >= lineslast) { if (linesdone >= lineslast) {
g_music->updateMusic(); g_music->updateMusic();
waitTOF(); g_lab->waitTOF();
linesdone = 0; linesdone = 0;
} }
ImDest.ImageData = getVGABaseAddr(); ImDest.ImageData = g_lab->getVGABaseAddr();
bltBitMap(&ImSource, 0, CurY, &ImDest, 0, CurY, g_lab->_screenWidth, 2); g_lab->bltBitMap(&ImSource, 0, CurY, &ImDest, 0, CurY, g_lab->_screenWidth, 2);
ghoastRect(0, 0, CurY, g_lab->_screenWidth - 1, CurY + 1); g_lab->ghoastRect(0, 0, CurY, g_lab->_screenWidth - 1, CurY + 1);
CurY += 4; CurY += 4;
linesdone++; linesdone++;
} }
@ -730,16 +725,16 @@ static void doTransWipe(CloseDataPtr *CPtr, char *filename) {
while (CurY <= LastY) { while (CurY <= LastY) {
if (linesdone >= lineslast) { if (linesdone >= lineslast) {
g_music->updateMusic(); g_music->updateMusic();
waitTOF(); g_lab->waitTOF();
linesdone = 0; linesdone = 0;
} }
ImDest.ImageData = getVGABaseAddr(); ImDest.ImageData = g_lab->getVGABaseAddr();
if (CurY == LastY) if (CurY == LastY)
bltBitMap(&ImSource, 0, CurY, &ImDest, 0, CurY, g_lab->_screenWidth, 1); g_lab->bltBitMap(&ImSource, 0, CurY, &ImDest, 0, CurY, g_lab->_screenWidth, 1);
else else
bltBitMap(&ImSource, 0, CurY, &ImDest, 0, CurY, g_lab->_screenWidth, 2); g_lab->bltBitMap(&ImSource, 0, CurY, &ImDest, 0, CurY, g_lab->_screenWidth, 2);
CurY += 4; CurY += 4;
linesdone++; linesdone++;

View file

@ -28,11 +28,11 @@
* *
*/ */
#include "lab/lab.h"
#include "lab/labfun.h" #include "lab/labfun.h"
#include "lab/stddefines.h" #include "lab/stddefines.h"
#include "lab/interface.h" #include "lab/interface.h"
#include "lab/mouse.h" #include "lab/mouse.h"
#include "lab/vga.h"
#include "common/util.h" #include "common/util.h"
namespace Lab { namespace Lab {
@ -82,7 +82,7 @@ void freeButtonList(Gadget *gptrlist) {
/*****************************************************************************/ /*****************************************************************************/
void drawGadgetList(Gadget *gadlist) { void drawGadgetList(Gadget *gadlist) {
while (gadlist) { while (gadlist) {
drawImage(gadlist->Im, gadlist->x, gadlist->y); g_lab->drawImage(gadlist->Im, gadlist->x, gadlist->y);
if (GADGETOFF & gadlist->GadgetFlags) if (GADGETOFF & gadlist->GadgetFlags)
ghoastGadget(gadlist, 1); ghoastGadget(gadlist, 1);
@ -96,7 +96,7 @@ void drawGadgetList(Gadget *gadlist) {
/* Ghoasts a gadget, and makes it unavailable for using. */ /* Ghoasts a gadget, and makes it unavailable for using. */
/*****************************************************************************/ /*****************************************************************************/
void ghoastGadget(Gadget *curgad, uint16 pencolor) { void ghoastGadget(Gadget *curgad, uint16 pencolor) {
ghoastRect(pencolor, curgad->x, curgad->y, curgad->x + curgad->Im->Width - 1, curgad->y + curgad->Im->Height - 1); g_lab->ghoastRect(pencolor, curgad->x, curgad->y, curgad->x + curgad->Im->Width - 1, curgad->y + curgad->Im->Height - 1);
curgad->GadgetFlags |= GADGETOFF; curgad->GadgetFlags |= GADGETOFF;
} }
@ -106,7 +106,7 @@ void ghoastGadget(Gadget *curgad, uint16 pencolor) {
/* Unghoasts a gadget, and makes it available again. */ /* Unghoasts a gadget, and makes it available again. */
/*****************************************************************************/ /*****************************************************************************/
void unGhoastGadget(Gadget *curgad) { void unGhoastGadget(Gadget *curgad) {
drawImage(curgad->Im, curgad->x, curgad->y); g_lab->drawImage(curgad->Im, curgad->x, curgad->y);
curgad->GadgetFlags &= !(GADGETOFF); curgad->GadgetFlags &= !(GADGETOFF);
} }
@ -133,11 +133,11 @@ static Gadget *checkNumGadgetHit(Gadget *gadlist, uint16 key) {
(gadlist->KeyEquiv != 0 && makeGadgetKeyEquiv(key) == gadlist->KeyEquiv)) (gadlist->KeyEquiv != 0 && makeGadgetKeyEquiv(key) == gadlist->KeyEquiv))
&& !(GADGETOFF & gadlist->GadgetFlags)) { && !(GADGETOFF & gadlist->GadgetFlags)) {
mouseHide(); mouseHide();
drawImage(gadlist->ImAlt, gadlist->x, gadlist->y); g_lab->drawImage(gadlist->ImAlt, gadlist->x, gadlist->y);
mouseShow(); mouseShow();
g_system->delayMillis(80); g_system->delayMillis(80);
mouseHide(); mouseHide();
drawImage(gadlist->Im, gadlist->x, gadlist->y); g_lab->drawImage(gadlist->Im, gadlist->x, gadlist->y);
mouseShow(); mouseShow();
return gadlist; return gadlist;
@ -155,8 +155,8 @@ static Gadget *checkNumGadgetHit(Gadget *gadlist, uint16 key) {
/* Checks whether or not a key has been pressed. */ /* Checks whether or not a key has been pressed. */
/*****************************************************************************/ /*****************************************************************************/
static bool keyPress(uint16 *KeyCode) { static bool keyPress(uint16 *KeyCode) {
if (WSDL_HasNextChar()) { if (g_lab->WSDL_HasNextChar()) {
*KeyCode = WSDL_GetNextChar(); *KeyCode = g_lab->WSDL_GetNextChar();
return true; return true;
} }

View file

@ -28,7 +28,6 @@
* *
*/ */
#include "lab/vga.h"
#include "common/keyboard.h" #include "common/keyboard.h"
#ifndef LAB_INTEFACE_H #ifndef LAB_INTEFACE_H

View file

@ -115,8 +115,8 @@ void Intro::doPictText(const char *filename, bool isscreen) {
fade(false, 0); fade(false, 0);
if (isscreen) { if (isscreen) {
setAPen(7L); g_lab->setAPen(7L);
rectFill(VGAScaleX(10), VGAScaleY(10), VGAScaleX(310), VGAScaleY(190)); g_lab->rectFill(VGAScaleX(10), VGAScaleY(10), VGAScaleX(310), VGAScaleY(190));
Drawn = flowText(_msgfont, (!IsHiRes) * -1, 5, 7, false, false, true, true, VGAScaleX(14), VGAScaleY(11), VGAScaleX(306), VGAScaleY(189), (char *)curplace); Drawn = flowText(_msgfont, (!IsHiRes) * -1, 5, 7, false, false, true, true, VGAScaleX(14), VGAScaleY(11), VGAScaleX(306), VGAScaleY(189), (char *)curplace);
fade(true, 0); fade(true, 0);
@ -161,7 +161,7 @@ void Intro::doPictText(const char *filename, bool isscreen) {
} }
} }
waitTOF(); g_lab->waitTOF();
} else { } else {
cls = msg->msgClass; cls = msg->msgClass;
qualifier = msg->qualifier; qualifier = msg->qualifier;
@ -226,9 +226,9 @@ void Intro::musicDelay() {
for (counter = 0; counter < 20; counter++) { for (counter = 0; counter < 20; counter++) {
g_music->updateMusic(); g_music->updateMusic();
waitTOF(); g_lab->waitTOF();
waitTOF(); g_lab->waitTOF();
waitTOF(); g_lab->waitTOF();
} }
} }
@ -318,7 +318,7 @@ void Intro::introSequence() {
palette[15] = temp; palette[15] = temp;
setAmigaPal(palette, 16); setAmigaPal(palette, 16);
waitTOF(); g_lab->waitTOF();
} }
fade(false, 0); fade(false, 0);
@ -404,10 +404,10 @@ void Intro::introSequence() {
diffcmap[counter1] = 255 - diffcmap[counter1]; diffcmap[counter1] = 255 - diffcmap[counter1];
g_music->updateMusic(); g_music->updateMusic();
waitTOF(); g_lab->waitTOF();
VGASetPal(diffcmap, 256); g_lab->VGASetPal(diffcmap, 256);
waitTOF(); g_lab-> waitTOF();
waitTOF(); g_lab->waitTOF();
} }
doPictText("i.12", false); doPictText("i.12", false);
@ -464,8 +464,8 @@ void Intro::introSequence() {
nReadPict("SubX", true); nReadPict("SubX", true);
if (_quitIntro) { if (_quitIntro) {
setAPen(0); g_lab->setAPen(0);
rectFill(0, 0, g_lab->_screenWidth - 1, g_lab->_screenHeight - 1); g_lab->rectFill(0, 0, g_lab->_screenWidth - 1, g_lab->_screenHeight - 1);
DoBlack = true; DoBlack = true;
} }
} }

View file

@ -59,6 +59,20 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
_screenHeight = 200; _screenHeight = 200;
_screenBytesPerPage = 65536; _screenBytesPerPage = 65536;
_curapen = 0;
_currentDsplayBuffer = 0;
_displayBuffer = 0;
_lastWaitTOFTicks = 0;
_mouseX = 0;
_mouseY = 0;
_nextKeyIn = 0;
_nextKeyOut = 0;
_mouseAtEdge = false;
//const Common::FSNode gameDataDir(ConfMan.get("path")); //const Common::FSNode gameDataDir(ConfMan.get("path"));
//SearchMan.addSubDirectoryMatching(gameDataDir, "game"); //SearchMan.addSubDirectoryMatching(gameDataDir, "game");
//SearchMan.addSubDirectoryMatching(gameDataDir, "game/pict"); //SearchMan.addSubDirectoryMatching(gameDataDir, "game/pict");

View file

@ -45,6 +45,12 @@ enum GameFeatures {
GF_WINDOWS_TRIAL = 1 << 1 GF_WINDOWS_TRIAL = 1 << 1
}; };
struct Image {
uint16 Width;
uint16 Height;
byte *ImageData;
};
#define ONESECOND 1000 #define ONESECOND 1000
class LabEngine : public Engine { class LabEngine : public Engine {
@ -83,6 +89,74 @@ private:
// timing.cpp // timing.cpp
void microDelay(uint32 secs, uint32 micros); void microDelay(uint32 secs, uint32 micros);
// vga.cpp
byte _curvgapal[256 * 3];
byte _curapen;
public:
byte *_currentDsplayBuffer;
uint32 _mouseX;
uint32 _mouseY;
private:
byte *_displayBuffer;
int _lastWaitTOFTicks;
uint16 _nextKeyIn;
uint16 _keyBuf[64];
uint16 _nextKeyOut;
bool _mouseAtEdge;
public:
byte *_tempScrollData;
private:
bool createScreen(bool HiRes);
public:
void waitTOF();
void setAPen(uint16 pennum);
void writeColorRegs(byte *buf, uint16 first, uint16 numreg);
byte *getVGABaseAddr();
void readScreenImage(Image *Im, uint16 x, uint16 y);
void WSDL_UpdateScreen();
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 ghoastRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
void bltBitMap(Image *ImSource, uint16 xs, uint16 ys, Image *ImDest, uint16 xd, uint16 yd, uint16 width, uint16 height);
void VGASetPal(void *cmap, uint16 numcolors);
void drawHLine(uint16 x, uint16 y1, uint16 y2);
void drawVLine(uint16 x1, uint16 y, uint16 x2);
void drawImage(Image *Im, uint16 x, uint16 y);
bool WSDL_HasNextChar();
uint16 WSDL_GetNextChar();
void WSDL_ProcessInput(bool can_delay);
void writeColorReg(byte *buf, uint16 regnum);
void writeColorRegsSmooth(byte *buf, uint16 first, uint16 numreg);
void drawPanel();
private:
void quickWaitTOF();
/*---------- Drawing Routines ----------*/
void drawMaskImage(Image *Im, uint16 x, uint16 y);
void WSDL_GetMousePos(int *x, int *y);
void changeVolume(int delta);
void WSDL_SetColors(byte *buf, uint16 first, uint16 numreg, uint16 slow);
// engine.cpp
bool setUpScreens();
void perFlipGadget(uint16 gadID);
bool doCloseUp(CloseDataPtr cptr);
void mainGameLoop();
bool doUse(uint16 curInv);
void mayShowCrumbIndicator();
void mayShowCrumbIndicatorOff();
}; };
extern LabEngine *g_lab; extern LabEngine *g_lab;

View file

@ -122,8 +122,6 @@ void gadgetsOnOff(void *gptr, void *win, int32 num, bool on);
/*----------------------*/ /*----------------------*/
void eatMessages(); void eatMessages();
bool setUpScreens();
void drawPanel();
bool quitPlaying(); bool quitPlaying();
/*---------------------------*/ /*---------------------------*/

View file

@ -33,7 +33,6 @@
#include "lab/stddefines.h" #include "lab/stddefines.h"
#include "lab/labfun.h" #include "lab/labfun.h"
#include "lab/mouse.h" #include "lab/mouse.h"
#include "lab/vga.h"
#include "lab/lab.h" #include "lab/lab.h"
namespace Lab { namespace Lab {
@ -72,7 +71,7 @@ Music::Music() {
/* it from the Audio device. */ /* it from the Audio device. */
/*****************************************************************************/ /*****************************************************************************/
void Music::updateMusic() { void Music::updateMusic() {
WSDL_ProcessInput(0); g_lab->WSDL_ProcessInput(0);
updateMouse(); updateMouse();

View file

@ -32,7 +32,6 @@
#include "lab/stddefines.h" #include "lab/stddefines.h"
#include "lab/labfun.h" #include "lab/labfun.h"
#include "lab/diff.h" #include "lab/diff.h"
#include "lab/vga.h"
#include "lab/text.h" #include "lab/text.h"
#include "lab/mouse.h" #include "lab/mouse.h"
#include "lab/parsefun.h" #include "lab/parsefun.h"
@ -70,7 +69,7 @@ void setAmigaPal(uint16 *pal, uint16 numcolors) {
vgapal[vgacount++] = (byte)(((pal[counter] & 0x00f)) << 2); vgapal[vgacount++] = (byte)(((pal[counter] & 0x00f)) << 2);
} }
writeColorRegsSmooth(vgapal, 0, 16); g_lab->writeColorRegsSmooth(vgapal, 0, 16);
} }
void decrypt(byte *text) { void decrypt(byte *text) {
@ -310,7 +309,7 @@ void fade(bool fadein, uint16 res) {
} }
setAmigaPal(newpal, 16); setAmigaPal(newpal, 16);
waitTOF(); g_lab->waitTOF();
g_music->updateMusic(); g_music->updateMusic();
} }
} }
@ -371,27 +370,27 @@ static void drawRoom(uint16 CurRoom, bool drawx) {
case UPARROWROOM: case UPARROWROOM:
case DOWNARROWROOM: case DOWNARROWROOM:
if (Maps[CurRoom].SpecialID == NORMAL) if (Maps[CurRoom].SpecialID == NORMAL)
drawImage(Room, x, y); g_lab->drawImage(Room, x, y);
else if (Maps[CurRoom].SpecialID == DOWNARROWROOM) else if (Maps[CurRoom].SpecialID == DOWNARROWROOM)
drawImage(DownArrowRoom, x, y); g_lab->drawImage(DownArrowRoom, x, y);
else else
drawImage(UpArrowRoom, x, y); g_lab->drawImage(UpArrowRoom, x, y);
offset = (Room->Width - Path->Width) / 2; offset = (Room->Width - Path->Width) / 2;
if ((NORTHDOOR & flags) && (y >= Path->Height)) if ((NORTHDOOR & flags) && (y >= Path->Height))
drawImage(Path, x + offset, y - Path->Height); g_lab->drawImage(Path, x + offset, y - Path->Height);
if (SOUTHDOOR & flags) if (SOUTHDOOR & flags)
drawImage(Path, x + offset, y + Room->Height); g_lab->drawImage(Path, x + offset, y + Room->Height);
offset = (Room->Height - Path->Height) / 2; offset = (Room->Height - Path->Height) / 2;
if (EASTDOOR & flags) if (EASTDOOR & flags)
drawImage(Path, x + Room->Width, y + offset); g_lab->drawImage(Path, x + Room->Width, y + offset);
if (WESTDOOR & flags) if (WESTDOOR & flags)
drawImage(Path, x - Path->Width, y + offset); g_lab->drawImage(Path, x - Path->Width, y + offset);
xx = x + (Room->Width - XMark->Width) / 2; xx = x + (Room->Width - XMark->Width) / 2;
xy = y + (Room->Height - XMark->Height) / 2; xy = y + (Room->Height - XMark->Height) / 2;
@ -399,7 +398,7 @@ static void drawRoom(uint16 CurRoom, bool drawx) {
break; break;
case BRIDGEROOM: case BRIDGEROOM:
drawImage(Bridge, x, y); g_lab->drawImage(Bridge, x, y);
xx = x + (Bridge->Width - XMark->Width) / 2; xx = x + (Bridge->Width - XMark->Width) / 2;
xy = y + (Bridge->Height - XMark->Height) / 2; xy = y + (Bridge->Height - XMark->Height) / 2;
@ -407,37 +406,37 @@ static void drawRoom(uint16 CurRoom, bool drawx) {
break; break;
case VCORRIDOR: case VCORRIDOR:
drawImage(VRoom, x, y); g_lab->drawImage(VRoom, x, y);
offset = (VRoom->Width - Path->Width) / 2; offset = (VRoom->Width - Path->Width) / 2;
if (NORTHDOOR & flags) if (NORTHDOOR & flags)
drawImage(Path, x + offset, y - Path->Height); g_lab->drawImage(Path, x + offset, y - Path->Height);
if (SOUTHDOOR & flags) if (SOUTHDOOR & flags)
drawImage(Path, x + offset, y + VRoom->Height); g_lab->drawImage(Path, x + offset, y + VRoom->Height);
offset = (Room->Height - Path->Height) / 2; offset = (Room->Height - Path->Height) / 2;
if (EASTDOOR & flags) if (EASTDOOR & flags)
drawImage(Path, x + VRoom->Width, y + offset); g_lab->drawImage(Path, x + VRoom->Width, y + offset);
if (WESTDOOR & flags) if (WESTDOOR & flags)
drawImage(Path, x - Path->Width, y + offset); g_lab->drawImage(Path, x - Path->Width, y + offset);
if (EASTBDOOR & flags) if (EASTBDOOR & flags)
drawImage(Path, x + VRoom->Width, y - offset - Path->Height + VRoom->Height); g_lab->drawImage(Path, x + VRoom->Width, y - offset - Path->Height + VRoom->Height);
if (WESTBDOOR & flags) if (WESTBDOOR & flags)
drawImage(Path, x - Path->Width, y - offset - Path->Height + VRoom->Height); g_lab->drawImage(Path, x - Path->Width, y - offset - Path->Height + VRoom->Height);
offset = (VRoom->Height - Path->Height) / 2; offset = (VRoom->Height - Path->Height) / 2;
if (EASTMDOOR & flags) if (EASTMDOOR & flags)
drawImage(Path, x + VRoom->Width, y - offset - Path->Height + VRoom->Height); g_lab->drawImage(Path, x + VRoom->Width, y - offset - Path->Height + VRoom->Height);
if (WESTMDOOR & flags) if (WESTMDOOR & flags)
drawImage(Path, x - Path->Width, y - offset - Path->Height + VRoom->Height); g_lab->drawImage(Path, x - Path->Width, y - offset - Path->Height + VRoom->Height);
xx = x + (VRoom->Width - XMark->Width) / 2; xx = x + (VRoom->Width - XMark->Width) / 2;
xy = y + (VRoom->Height - XMark->Height) / 2; xy = y + (VRoom->Height - XMark->Height) / 2;
@ -445,37 +444,37 @@ static void drawRoom(uint16 CurRoom, bool drawx) {
break; break;
case HCORRIDOR: case HCORRIDOR:
drawImage(HRoom, x, y); g_lab->drawImage(HRoom, x, y);
offset = (Room->Width - Path->Width) / 2; offset = (Room->Width - Path->Width) / 2;
if (NORTHDOOR & flags) if (NORTHDOOR & flags)
drawImage(Path, x + offset, y - Path->Height); g_lab->drawImage(Path, x + offset, y - Path->Height);
if (SOUTHDOOR & flags) if (SOUTHDOOR & flags)
drawImage(Path, x + offset, y + Room->Height); g_lab->drawImage(Path, x + offset, y + Room->Height);
if (NORTHRDOOR & flags) if (NORTHRDOOR & flags)
drawImage(Path, x - offset - Path->Width + HRoom->Width, y - Path->Height); g_lab->drawImage(Path, x - offset - Path->Width + HRoom->Width, y - Path->Height);
if (SOUTHRDOOR & flags) if (SOUTHRDOOR & flags)
drawImage(Path, x - offset - Path->Width + HRoom->Width, y + Room->Height); g_lab->drawImage(Path, x - offset - Path->Width + HRoom->Width, y + Room->Height);
offset = (HRoom->Width - Path->Width) / 2; offset = (HRoom->Width - Path->Width) / 2;
if (NORTHMDOOR & flags) if (NORTHMDOOR & flags)
drawImage(Path, x - offset - Path->Width + HRoom->Width, y - Path->Height); g_lab->drawImage(Path, x - offset - Path->Width + HRoom->Width, y - Path->Height);
if (SOUTHMDOOR & flags) if (SOUTHMDOOR & flags)
drawImage(Path, x - offset - Path->Width + HRoom->Width, y + Room->Height); g_lab->drawImage(Path, x - offset - Path->Width + HRoom->Width, y + Room->Height);
offset = (Room->Height - Path->Height) / 2; offset = (Room->Height - Path->Height) / 2;
if (EASTDOOR & flags) if (EASTDOOR & flags)
drawImage(Path, x + HRoom->Width, y + offset); g_lab->drawImage(Path, x + HRoom->Width, y + offset);
if (WESTDOOR & flags) if (WESTDOOR & flags)
drawImage(Path, x - Path->Width, y + offset); g_lab->drawImage(Path, x - Path->Width, y + offset);
xx = x + (HRoom->Width - XMark->Width) / 2; xx = x + (HRoom->Width - XMark->Width) / 2;
xy = y + (HRoom->Height - XMark->Height) / 2; xy = y + (HRoom->Height - XMark->Height) / 2;
@ -487,7 +486,7 @@ static void drawRoom(uint16 CurRoom, bool drawx) {
} }
if (drawx) if (drawx)
drawImage(XMark, xx, xy); g_lab->drawImage(XMark, xx, xy);
} }
@ -582,10 +581,10 @@ static void drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, b
if (fadeout) if (fadeout)
fade(false, 0); fade(false, 0);
setAPen(0); g_lab->setAPen(0);
rectFill(0, 0, g_lab->_screenWidth - 1, g_lab->_screenHeight - 1); g_lab->rectFill(0, 0, g_lab->_screenWidth - 1, g_lab->_screenHeight - 1);
drawImage(Map, 0, 0); g_lab->drawImage(Map, 0, 0);
drawGadgetList(MapGadgetList); drawGadgetList(MapGadgetList);
for (drawroom = 1; drawroom <= MaxRooms; drawroom++) { for (drawroom = 1; drawroom <= MaxRooms; drawroom++) {
@ -621,16 +620,16 @@ static void drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, b
// Labyrinth specific code // Labyrinth specific code
if (Floor == LOWERFLOOR) { if (Floor == LOWERFLOOR) {
if (onFloor(SURMAZEFLOOR)) if (onFloor(SURMAZEFLOOR))
drawImage(Maze, mapScaleX(538), mapScaleY(277)); g_lab->drawImage(Maze, mapScaleX(538), mapScaleY(277));
} else if (Floor == MIDDLEFLOOR) { } else if (Floor == MIDDLEFLOOR) {
if (onFloor(CARNIVAL)) if (onFloor(CARNIVAL))
drawImage(Maze, mapScaleX(358), mapScaleY(72)); g_lab->drawImage(Maze, mapScaleX(358), mapScaleY(72));
if (onFloor(MEDMAZEFLOOR)) if (onFloor(MEDMAZEFLOOR))
drawImage(Maze, mapScaleX(557), mapScaleY(325)); g_lab->drawImage(Maze, mapScaleX(557), mapScaleY(325));
} else if (Floor == UPPERFLOOR) { } else if (Floor == UPPERFLOOR) {
if (onFloor(HEDGEMAZEFLOOR)) if (onFloor(HEDGEMAZEFLOOR))
drawImage(HugeMaze, mapScaleX(524), mapScaleY(97)); g_lab->drawImage(HugeMaze, mapScaleX(524), mapScaleY(97));
} else if (Floor == SURMAZEFLOOR) { } else if (Floor == SURMAZEFLOOR) {
sptr = (char *)g_resource->getStaticText(kTextSurmazeMessage).c_str(); sptr = (char *)g_resource->getStaticText(kTextSurmazeMessage).c_str();
flowText(MsgFont, 0, 7, 0, true, true, true, true, mapScaleX(360), 0, mapScaleX(660), mapScaleY(450), sptr); flowText(MsgFont, 0, 7, 0, true, true, true, true, mapScaleX(360), 0, mapScaleX(660), mapScaleY(450), sptr);
@ -708,14 +707,14 @@ void processMap(uint16 CurRoom) {
newcolor[2] = newcolor[1]; newcolor[2] = newcolor[1];
} }
waitTOF(); g_lab->waitTOF();
writeColorReg(newcolor, 1); g_lab->writeColorReg(newcolor, 1);
updateMouse(); updateMouse();
waitTOF(); g_lab->waitTOF();
updateMouse(); updateMouse();
waitTOF(); g_lab->waitTOF();
updateMouse(); updateMouse();
waitTOF(); g_lab->waitTOF();
updateMouse(); updateMouse();
place++; place++;
@ -822,8 +821,8 @@ void processMap(uint16 CurRoom) {
if ((sptr = Rooms[CurMsg].RoomMsg)) { if ((sptr = Rooms[CurMsg].RoomMsg)) {
mouseHide(); mouseHide();
setAPen(3); g_lab->setAPen(3);
rectFill(VGAScaleX(13), VGAScaleY(148), VGAScaleX(135), VGAScaleY(186)); g_lab->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); flowText(MsgFont, 0, 5, 3, true, true, true, true, VGAScaleX(14), VGAScaleY(148), VGAScaleX(134), VGAScaleY(186), sptr);
if (Maps[OldMsg].PageNumber == CurFloor) if (Maps[OldMsg].PageNumber == CurFloor)
@ -834,8 +833,8 @@ void processMap(uint16 CurRoom) {
y1 = (y1 + y2) / 2; y1 = (y1 + y2) / 2;
if ((CurMsg != CurRoom) && (Maps[CurMsg].PageNumber == CurFloor)) { if ((CurMsg != CurRoom) && (Maps[CurMsg].PageNumber == CurFloor)) {
setAPen(1); g_lab->setAPen(1);
rectFill(x1 - 1, y1, x1, y1); g_lab->rectFill(x1 - 1, y1, x1, y1);
} }
mouseShow(); mouseShow();
@ -844,7 +843,7 @@ void processMap(uint16 CurRoom) {
} }
} }
WSDL_UpdateScreen(); g_lab->WSDL_UpdateScreen();
} }
} }
} }
@ -872,18 +871,18 @@ void doMap(uint16 CurRoom) {
drawMap(CurRoom, CurRoom, Maps[CurRoom].PageNumber, false, true); drawMap(CurRoom, CurRoom, Maps[CurRoom].PageNumber, false, true);
mouseShow(); mouseShow();
attachGadgetList(MapGadgetList); attachGadgetList(MapGadgetList);
WSDL_UpdateScreen(); g_lab->WSDL_UpdateScreen();
processMap(CurRoom); processMap(CurRoom);
attachGadgetList(NULL); attachGadgetList(NULL);
fade(false, 0); fade(false, 0);
blackAllScreen(); blackAllScreen();
mouseHide(); mouseHide();
setAPen(0); g_lab->setAPen(0);
rectFill(0, 0, g_lab->_screenWidth - 1, g_lab->_screenHeight - 1); g_lab->rectFill(0, 0, g_lab->_screenWidth - 1, g_lab->_screenHeight - 1);
freeMapData(); freeMapData();
blackAllScreen(); blackAllScreen();
mouseShow(); mouseShow();
WSDL_UpdateScreen(); g_lab->WSDL_UpdateScreen();
} }
} // End of namespace Lab } // End of namespace Lab

View file

@ -28,8 +28,8 @@
* *
*/ */
#include "lab/lab.h"
#include "lab/mouse.h" #include "lab/mouse.h"
#include "lab/vga.h"
#include "lab/stddefines.h" #include "lab/stddefines.h"
#include "lab/interface.h" #include "lab/interface.h"
@ -81,14 +81,14 @@ static Gadget *checkGadgetHit(Gadget *gadlist, uint16 x, uint16 y) {
hitgad = gadlist; hitgad = gadlist;
} else { } else {
mouseHide(); mouseHide();
drawImage(gadlist->ImAlt, gadlist->x, gadlist->y); g_lab->drawImage(gadlist->ImAlt, gadlist->x, gadlist->y);
mouseShow(); mouseShow();
for (counter = 0; counter < 3; counter++) for (counter = 0; counter < 3; counter++)
waitTOF(); g_lab->waitTOF();
mouseHide(); mouseHide();
drawImage(gadlist->Im, gadlist->x, gadlist->y); g_lab->drawImage(gadlist->Im, gadlist->x, gadlist->y);
mouseShow(); mouseShow();
} }
@ -141,21 +141,21 @@ void updateMouse() {
if (hitgad) { if (hitgad) {
mouseHide(); mouseHide();
drawImage(hitgad->ImAlt, hitgad->x, hitgad->y); g_lab->drawImage(hitgad->ImAlt, hitgad->x, hitgad->y);
mouseShow(); mouseShow();
for (counter = 0; counter < 3; counter++) for (counter = 0; counter < 3; counter++)
waitTOF(); g_lab->waitTOF();
mouseHide(); mouseHide();
drawImage(hitgad->Im, hitgad->x, hitgad->y); g_lab->drawImage(hitgad->Im, hitgad->x, hitgad->y);
mouseShow(); mouseShow();
doUpdateDisplay = true; doUpdateDisplay = true;
hitgad = NULL; hitgad = NULL;
} }
if (doUpdateDisplay) if (doUpdateDisplay)
WSDL_UpdateScreen(); g_lab->WSDL_UpdateScreen();
} }
@ -178,7 +178,7 @@ void mouseShow() {
NumHidden--; NumHidden--;
if ((NumHidden == 0) && MouseHidden) { if ((NumHidden == 0) && MouseHidden) {
WSDL_ProcessInput(0); g_lab->WSDL_ProcessInput(0);
MouseHidden = false; MouseHidden = false;
} }
@ -198,17 +198,13 @@ void mouseHide() {
} }
} }
extern uint32 _mouseX;
extern uint32 _mouseY;
/*****************************************************************************/ /*****************************************************************************/
/* Gets the current mouse co-ordinates. NOTE: On IBM version, will scale */ /* Gets the current mouse co-ordinates. NOTE: On IBM version, will scale */
/* from virtual to screen co-ordinates automatically. */ /* from virtual to screen co-ordinates automatically. */
/*****************************************************************************/ /*****************************************************************************/
void mouseXY(uint16 *x, uint16 *y) { void mouseXY(uint16 *x, uint16 *y) {
*x = (uint16)_mouseX; *x = (uint16)g_lab->_mouseX;
*y = (uint16)_mouseY; *y = (uint16)g_lab->_mouseY;
if (!IsHiRes) if (!IsHiRes)
(*x) /= 2; (*x) /= 2;
@ -225,7 +221,7 @@ void mouseMove(uint16 x, uint16 y) {
g_system->warpMouse(x, y); g_system->warpMouse(x, y);
if (!MouseHidden) if (!MouseHidden)
WSDL_ProcessInput(0); g_lab->WSDL_ProcessInput(0);
} }
@ -237,15 +233,15 @@ void mouseMove(uint16 x, uint16 y) {
bool mouseButton(uint16 *x, uint16 *y, bool leftbutton) { bool mouseButton(uint16 *x, uint16 *y, bool leftbutton) {
if (leftbutton) { if (leftbutton) {
if (LeftClick) { if (LeftClick) {
*x = (!IsHiRes) ? (uint16)_mouseX / 2 : (uint16)_mouseX; *x = (!IsHiRes) ? (uint16)g_lab->_mouseX / 2 : (uint16)g_lab->_mouseX;
*y = (uint16)_mouseY; *y = (uint16)g_lab->_mouseY;
LeftClick = false; LeftClick = false;
return true; return true;
} }
} else { } else {
if (RightClick) { if (RightClick) {
*x = (!IsHiRes) ? (uint16)_mouseX / 2 : (uint16)_mouseX; *x = (!IsHiRes) ? (uint16)g_lab->_mouseX / 2 : (uint16)g_lab->_mouseX;
*y = (uint16)_mouseY; *y = (uint16)g_lab->_mouseY;
RightClick = false; RightClick = false;
return true; return true;
} }

View file

@ -37,7 +37,6 @@
#include "lab/parsefun.h" #include "lab/parsefun.h"
#include "lab/resource.h" #include "lab/resource.h"
#include "lab/diff.h" #include "lab/diff.h"
#include "lab/vga.h"
#include "lab/interface.h" #include "lab/interface.h"
namespace Lab { namespace Lab {
@ -484,7 +483,7 @@ static void doActions(Action * APtr, CloseDataPtr *LCPtr) {
case WAITSECS: case WAITSECS:
g_lab->addCurTime(APtr->Param1, 0, &StartSecs, &StartMicros); g_lab->addCurTime(APtr->Param1, 0, &StartSecs, &StartMicros);
WSDL_UpdateScreen(); g_lab->WSDL_UpdateScreen();
while (1) { while (1) {
g_music->updateMusic(); g_music->updateMusic();
@ -524,7 +523,7 @@ static void doActions(Action * APtr, CloseDataPtr *LCPtr) {
while (g_music->isSoundEffectActive()) { while (g_music->isSoundEffectActive()) {
g_music->updateMusic(); g_music->updateMusic();
diffNextFrame(); diffNextFrame();
waitTOF(); g_lab->waitTOF();
} }
break; break;
@ -567,23 +566,23 @@ static void doActions(Action * APtr, CloseDataPtr *LCPtr) {
for (counter = (8 * 3); counter < (255 * 3); counter++) for (counter = (8 * 3); counter < (255 * 3); counter++)
diffcmap[counter] = 255 - diffcmap[counter]; diffcmap[counter] = 255 - diffcmap[counter];
waitTOF(); g_lab->waitTOF();
VGASetPal(diffcmap, 256); g_lab->VGASetPal(diffcmap, 256);
waitTOF(); g_lab->waitTOF();
waitTOF(); g_lab->waitTOF();
} else if (APtr->Param1 == 4) { /* white the palette */ } else if (APtr->Param1 == 4) { /* white the palette */
whiteScreen(); whiteScreen();
waitTOF(); g_lab->waitTOF();
waitTOF(); g_lab->waitTOF();
} else if (APtr->Param1 == 6) { /* Restore the palette */ } else if (APtr->Param1 == 6) { /* Restore the palette */
waitTOF(); g_lab->waitTOF();
VGASetPal(diffcmap, 256); g_lab->VGASetPal(diffcmap, 256);
waitTOF(); g_lab->waitTOF();
waitTOF(); g_lab->waitTOF();
} else if (APtr->Param1 == 7) { /* Quick pause */ } else if (APtr->Param1 == 7) { /* Quick pause */
waitTOF(); g_lab->waitTOF();
waitTOF(); g_lab->waitTOF();
waitTOF(); g_lab->waitTOF();
} }
break; break;
@ -599,7 +598,7 @@ static void doActions(Action * APtr, CloseDataPtr *LCPtr) {
while (g_music->isSoundEffectActive()) { while (g_music->isSoundEffectActive()) {
g_music->updateMusic(); g_music->updateMusic();
diffNextFrame(); diffNextFrame();
waitTOF(); g_lab->waitTOF();
} }
} }

View file

@ -31,7 +31,6 @@
#include "lab/lab.h" #include "lab/lab.h"
#include "lab/diff.h" #include "lab/diff.h"
#include "lab/labfun.h" #include "lab/labfun.h"
#include "lab/vga.h"
#include "lab/mouse.h" #include "lab/mouse.h"
namespace Lab { namespace Lab {
@ -91,7 +90,7 @@ void unDiff(byte *NewBuf, byte *OldBuf, byte *DiffData, uint16 bytesperrow, bool
/*****************************************************************************/ /*****************************************************************************/
void blackScreen() { void blackScreen() {
memset(blackbuffer, 0, 248 * 3); memset(blackbuffer, 0, 248 * 3);
writeColorRegs(blackbuffer, 8, 248); g_lab->writeColorRegs(blackbuffer, 8, 248);
g_system->delayMillis(32); g_system->delayMillis(32);
} }
@ -101,7 +100,7 @@ void blackScreen() {
/*****************************************************************************/ /*****************************************************************************/
void whiteScreen() { void whiteScreen() {
memset(blackbuffer, 255, 248 * 3); memset(blackbuffer, 255, 248 * 3);
writeColorRegs(blackbuffer, 8, 248); g_lab->writeColorRegs(blackbuffer, 8, 248);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -109,7 +108,7 @@ void whiteScreen() {
/*****************************************************************************/ /*****************************************************************************/
void blackAllScreen() { void blackAllScreen() {
memset(blackbuffer, 0, 256 * 3); memset(blackbuffer, 0, 256 * 3);
writeColorRegs(blackbuffer, 0, 256); g_lab->writeColorRegs(blackbuffer, 0, 256);
g_system->delayMillis(32); g_system->delayMillis(32);
} }
@ -120,7 +119,7 @@ void diffNextFrame() {
return; return;
if (DispBitMap->Flags & BITMAPF_VIDEO) { if (DispBitMap->Flags & BITMAPF_VIDEO) {
DispBitMap->Planes[0] = getVGABaseAddr(); DispBitMap->Planes[0] = g_lab->getVGABaseAddr();
DispBitMap->Planes[1] = DispBitMap->Planes[0] + 0x10000; DispBitMap->Planes[1] = DispBitMap->Planes[0] + 0x10000;
DispBitMap->Planes[2] = DispBitMap->Planes[1] + 0x10000; DispBitMap->Planes[2] = DispBitMap->Planes[1] + 0x10000;
DispBitMap->Planes[3] = DispBitMap->Planes[2] + 0x10000; DispBitMap->Planes[3] = DispBitMap->Planes[2] + 0x10000;
@ -140,7 +139,7 @@ void diffNextFrame() {
} }
if (IsPal && !nopalchange) { if (IsPal && !nopalchange) {
VGASetPal(diffcmap, 256); g_lab->VGASetPal(diffcmap, 256);
IsPal = false; IsPal = false;
} }
@ -148,7 +147,7 @@ void diffNextFrame() {
} }
if (IsPal && !nopalchange && !IsBM && !donepal) { if (IsPal && !nopalchange && !IsBM && !donepal) {
VGASetPal(diffcmap, 256); g_lab->VGASetPal(diffcmap, 256);
IsPal = false; IsPal = false;
} }
@ -163,7 +162,7 @@ void diffNextFrame() {
CurBit = 0; CurBit = 0;
if (DispBitMap->Flags & BITMAPF_VIDEO) if (DispBitMap->Flags & BITMAPF_VIDEO)
WSDL_UpdateScreen(); g_lab->WSDL_UpdateScreen();
return; /* done with the next frame. */ return; /* done with the next frame. */
} }
@ -231,7 +230,7 @@ void diffNextFrame() {
if (waitForEffect) { if (waitForEffect) {
while (g_music->isSoundEffectActive()) { while (g_music->isSoundEffectActive()) {
g_music->updateMusic(); g_music->updateMusic();
waitTOF(); g_lab->waitTOF();
} }
} }
@ -257,7 +256,7 @@ void diffNextFrame() {
if (waitForEffect) { if (waitForEffect) {
while (g_music->isSoundEffectActive()) { while (g_music->isSoundEffectActive()) {
g_music->updateMusic(); g_music->updateMusic();
waitTOF(); g_lab->waitTOF();
if (DispBitMap->Flags & BITMAPF_VIDEO) if (DispBitMap->Flags & BITMAPF_VIDEO)
didTOF = 1; didTOF = 1;
@ -268,7 +267,7 @@ void diffNextFrame() {
mouseShow(); mouseShow();
if (!didTOF) if (!didTOF)
WSDL_UpdateScreen(); g_lab->WSDL_UpdateScreen();
return; return;
} }
@ -445,7 +444,7 @@ void readSound(bool waitTillFinished, Common::File *file) {
if (waitTillFinished) { if (waitTillFinished) {
while (g_music->isSoundEffectActive()) { while (g_music->isSoundEffectActive()) {
g_music->updateMusic(); g_music->updateMusic();
waitTOF(); g_lab->waitTOF();
} }
} }
@ -460,7 +459,7 @@ void readSound(bool waitTillFinished, Common::File *file) {
if (waitTillFinished) { if (waitTillFinished) {
while (g_music->isSoundEffectActive()) { while (g_music->isSoundEffectActive()) {
g_music->updateMusic(); g_music->updateMusic();
waitTOF(); g_lab->waitTOF();
} }
} }
} else } else

View file

@ -38,7 +38,6 @@
#include "lab/parsefun.h" #include "lab/parsefun.h"
#include "lab/interface.h" #include "lab/interface.h"
#include "lab/diff.h" #include "lab/diff.h"
#include "lab/vga.h"
#include "lab/text.h" #include "lab/text.h"
#include "lab/mouse.h" #include "lab/mouse.h"
#include "lab/stddefines.h" #include "lab/stddefines.h"
@ -89,7 +88,6 @@ extern uint16 *FadePalette;
extern bool nopalchange, DoBlack, IsHiRes; extern bool nopalchange, DoBlack, IsHiRes;
extern BitMap *DispBitMap, *DrawBitMap; extern BitMap *DispBitMap, *DrawBitMap;
extern char diffcmap[3 * 256]; extern char diffcmap[3 * 256];
extern byte *_tempScrollData;
extern CloseDataPtr CPtr; extern CloseDataPtr CPtr;
extern InventoryData *Inventory; extern InventoryData *Inventory;
extern uint16 RoomNum, Direction; extern uint16 RoomNum, Direction;
@ -141,7 +139,7 @@ static void doCombination() {
uint16 counter; uint16 counter;
for (counter = 0; counter <= 5; counter++) for (counter = 0; counter <= 5; counter++)
drawImage(Images[combination[counter]], VGAScaleX(combx[counter]), VGAScaleY(65)); g_lab->drawImage(Images[combination[counter]], VGAScaleX(combx[counter]), VGAScaleY(65));
} }
/*****************************************************************************/ /*****************************************************************************/
@ -164,11 +162,11 @@ void showCombination(const char *filename) {
for (CurBit = 0; CurBit < 10; CurBit++) for (CurBit = 0; CurBit < 10; CurBit++)
readImage(buffer, &(Images[CurBit])); readImage(buffer, &(Images[CurBit]));
allocFile((void **)&_tempScrollData, Images[0]->Width * Images[0]->Height * 2L, "tempdata"); allocFile((void **)&g_lab->_tempScrollData, Images[0]->Width * Images[0]->Height * 2L, "tempdata");
doCombination(); doCombination();
VGASetPal(diffcmap, 256); g_lab->VGASetPal(diffcmap, 256);
} }
@ -188,22 +186,22 @@ static void changeCombination(uint16 number) {
combnum = combination[number]; combnum = combination[number];
display.ImageData = getVGABaseAddr(); display.ImageData = g_lab->getVGABaseAddr();
display.Width = g_lab->_screenWidth; display.Width = g_lab->_screenWidth;
display.Height = g_lab->_screenHeight; display.Height = g_lab->_screenHeight;
for (counter = 1; counter <= (Images[combnum]->Height / 2); counter++) { for (counter = 1; counter <= (Images[combnum]->Height / 2); counter++) {
if (IsHiRes) { if (IsHiRes) {
if (counter & 1) if (counter & 1)
waitTOF(); g_lab->waitTOF();
} else } else
waitTOF(); g_lab->waitTOF();
display.ImageData = getVGABaseAddr(); display.ImageData = g_lab->getVGABaseAddr();
scrollDisplayY(2, VGAScaleX(combx[number]), VGAScaleY(65), VGAScaleX(combx[number]) + (Images[combnum])->Width - 1, VGAScaleY(65) + (Images[combnum])->Height); g_lab->scrollDisplayY(2, VGAScaleX(combx[number]), VGAScaleY(65), VGAScaleX(combx[number]) + (Images[combnum])->Width - 1, VGAScaleY(65) + (Images[combnum])->Height);
bltBitMap(Images[combnum], 0, (Images[combnum])->Height - (2 * counter), &(display), VGAScaleX(combx[number]), VGAScaleY(65), (Images[combnum])->Width, 2); g_lab->bltBitMap(Images[combnum], 0, (Images[combnum])->Height - (2 * counter), &(display), VGAScaleX(combx[number]), VGAScaleY(65), (Images[combnum])->Width, 2);
} }
for (counter = 0; counter < 6; counter++) for (counter = 0; counter < 6; counter++)
@ -259,8 +257,8 @@ static void doTile(bool showsolution) {
rows = VGAScaleY(31); rows = VGAScaleY(31);
cols = VGAScaleX(105); cols = VGAScaleX(105);
} else { } else {
setAPen(0); g_lab->setAPen(0);
rectFill(VGAScaleX(97), VGAScaleY(22), VGAScaleX(220), VGAScaleY(126)); g_lab->rectFill(VGAScaleX(97), VGAScaleY(22), VGAScaleX(220), VGAScaleY(126));
rowm = VGAScaleY(25); rowm = VGAScaleY(25);
colm = VGAScaleX(30); colm = VGAScaleX(30);
@ -277,7 +275,7 @@ static void doTile(bool showsolution) {
num = CurTile[col] [row]; num = CurTile[col] [row];
if (showsolution || num) if (showsolution || num)
drawImage(Tiles[num], cols + (col * colm), rows + (row * rowm)); g_lab->drawImage(Tiles[num], cols + (col * colm), rows + (row * rowm));
col++; col++;
} }
@ -315,19 +313,19 @@ void showTile(const char *filename, bool showsolution) {
for (CurBit = start; CurBit < 16; CurBit++) for (CurBit = start; CurBit < 16; CurBit++)
readImage(buffer, &(Tiles[CurBit])); readImage(buffer, &(Tiles[CurBit]));
allocFile((void **)&_tempScrollData, Tiles[1]->Width * Tiles[1]->Height * 2L, "tempdata"); allocFile((void **)&g_lab->_tempScrollData, Tiles[1]->Width * Tiles[1]->Height * 2L, "tempdata");
doTile(showsolution); doTile(showsolution);
VGASetPal(diffcmap, 256); g_lab->VGASetPal(diffcmap, 256);
} }
static void scrollRaster(int16 dx, int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2) { static void scrollRaster(int16 dx, int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
if (dx) if (dx)
scrollDisplayX(dx, x1, y1, x2, y2); g_lab->scrollDisplayX(dx, x1, y1, x2, y2);
if (dy) if (dy)
scrollDisplayY(dy, x1, y1, x2, y2); g_lab->scrollDisplayY(dy, x1, y1, x2, y2);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -364,7 +362,7 @@ static void doTileScroll(uint16 col, uint16 row, uint16 scrolltype) {
y1 = VGAScaleY(25) + (row * VGAScaleY(25)) + dy; y1 = VGAScaleY(25) + (row * VGAScaleY(25)) + dy;
for (counter = 0; counter < last; counter++) { for (counter = 0; counter < last; counter++) {
waitTOF(); g_lab->waitTOF();
scrollRaster(dX, dY, x1, y1, x1 + VGAScaleX(28) + sx, y1 + VGAScaleY(23) + sy); scrollRaster(dX, dY, x1, y1, x1 + VGAScaleX(28) + sx, y1 + VGAScaleY(23) + sy);
x1 += dX; x1 += dX;
y1 += dY; y1 += dY;
@ -479,7 +477,7 @@ void doNotes() {
flowText(BigMsgFont, -2 + SVGACord(1), 0, 0, false, false, true, true, VGAScaleX(25) + SVGACord(15), VGAScaleY(50), VGAScaleX(295) - SVGACord(15), VGAScaleY(148), ntext); flowText(BigMsgFont, -2 + SVGACord(1), 0, 0, false, false, true, true, VGAScaleX(25) + SVGACord(15), VGAScaleY(50), VGAScaleX(295) - SVGACord(15), VGAScaleY(148), ntext);
VGASetPal(diffcmap, 256); g_lab->VGASetPal(diffcmap, 256);
freeAllStolenMem(); freeAllStolenMem();
} }
@ -541,7 +539,7 @@ void doWestPaper() {
CharsPrinted = flowText(BigMsgFont, -4, 0, 0, false, false, false, true, VGAScaleX(162), VGAScaleY(y), VGAScaleX(275), VGAScaleY(148), ntext); CharsPrinted = flowText(BigMsgFont, -4, 0, 0, false, false, false, true, VGAScaleX(162), VGAScaleY(y), VGAScaleX(275), VGAScaleY(148), ntext);
VGASetPal(diffcmap, 256); g_lab->VGASetPal(diffcmap, 256);
freeAllStolenMem(); freeAllStolenMem();
} }
@ -675,16 +673,16 @@ static void turnPage(bool FromLeft) {
if (FromLeft) { if (FromLeft) {
for (counter = 0; counter < g_lab->_screenWidth; counter += 8) { for (counter = 0; counter < g_lab->_screenWidth; counter += 8) {
g_music->updateMusic(); g_music->updateMusic();
waitTOF(); g_lab->waitTOF();
ScreenImage.ImageData = getVGABaseAddr(); ScreenImage.ImageData = g_lab->getVGABaseAddr();
bltBitMap(&JBackImage, counter, 0, &ScreenImage, counter, 0, 8, g_lab->_screenHeight); g_lab->bltBitMap(&JBackImage, counter, 0, &ScreenImage, counter, 0, 8, g_lab->_screenHeight);
} }
} else { } else {
for (counter = (g_lab->_screenWidth - 8); counter > 0; counter -= 8) { for (counter = (g_lab->_screenWidth - 8); counter > 0; counter -= 8) {
g_music->updateMusic(); g_music->updateMusic();
waitTOF(); g_lab->waitTOF();
ScreenImage.ImageData = getVGABaseAddr(); ScreenImage.ImageData = g_lab->getVGABaseAddr();
bltBitMap(&JBackImage, counter, 0, &ScreenImage, counter, 0, 8, g_lab->_screenHeight); g_lab->bltBitMap(&JBackImage, counter, 0, &ScreenImage, counter, 0, 8, g_lab->_screenHeight);
} }
} }
} }
@ -703,10 +701,10 @@ static void drawJournal(uint16 wipenum, bool needFade) {
drawJournalText(); drawJournalText();
ScreenImage.ImageData = getVGABaseAddr(); ScreenImage.ImageData = g_lab->getVGABaseAddr();
if (wipenum == 0) if (wipenum == 0)
bltBitMap(&JBackImage, 0, 0, &ScreenImage, 0, 0, g_lab->_screenWidth, g_lab->_screenHeight); g_lab->bltBitMap(&JBackImage, 0, 0, &ScreenImage, 0, 0, g_lab->_screenWidth, g_lab->_screenHeight);
else else
turnPage((bool)(wipenum == 1)); turnPage((bool)(wipenum == 1));
@ -794,7 +792,7 @@ void doJournal() {
CancelG.NextGadget = &ForwardG; CancelG.NextGadget = &ForwardG;
ScreenImage = JBackImage; ScreenImage = JBackImage;
ScreenImage.ImageData = getVGABaseAddr(); ScreenImage.ImageData = g_lab->getVGABaseAddr();
g_music->updateMusic(); g_music->updateMusic();
loadJournalData(); loadJournalData();
@ -808,10 +806,10 @@ void doJournal() {
fade(false, 0); fade(false, 0);
mouseHide(); mouseHide();
ScreenImage.ImageData = getVGABaseAddr(); ScreenImage.ImageData = g_lab->getVGABaseAddr();
setAPen(0); g_lab->setAPen(0);
rectFill(0, 0, g_lab->_screenWidth - 1, g_lab->_screenHeight - 1); g_lab->rectFill(0, 0, g_lab->_screenWidth - 1, g_lab->_screenHeight - 1);
blackScreen(); blackScreen();
freeAllStolenMem(); freeAllStolenMem();
@ -852,7 +850,7 @@ bool saveRestoreGame() {
} }
} }
WSDL_UpdateScreen(); g_lab->WSDL_UpdateScreen();
return isOK; return isOK;
} }
@ -903,17 +901,17 @@ static void drawMonText(char *text, uint16 x1, uint16 y1, uint16 x2, uint16 y2,
else else
MonGadHeight = fheight; MonGadHeight = fheight;
setAPen(0); g_lab->setAPen(0);
rectFill(0, 0, g_lab->_screenWidth - 1, y2); g_lab->rectFill(0, 0, g_lab->_screenWidth - 1, y2);
for (counter = 0; counter < numlines; counter++) for (counter = 0; counter < numlines; counter++)
drawImage(MonButton, 0, counter * MonGadHeight); g_lab->drawImage(MonButton, 0, counter * MonGadHeight);
} else if (isinteractive) { } else if (isinteractive) {
setAPen(0); g_lab->setAPen(0);
rectFill(0, 0, g_lab->_screenWidth - 1, y2); g_lab->rectFill(0, 0, g_lab->_screenWidth - 1, y2);
} else { } else {
setAPen(0); g_lab->setAPen(0);
rectFill(x1, y1, x2, y2); g_lab->rectFill(x1, y1, x2, y2);
} }
while (DrawingToPage < monitorPage) { while (DrawingToPage < monitorPage) {
@ -1083,8 +1081,8 @@ void doMonitor(char *background, char *textfile, bool isinteractive, uint16 x1,
freeAllStolenMem(); freeAllStolenMem();
setAPen(0); g_lab->setAPen(0);
rectFill(0, 0, g_lab->_screenWidth - 1, g_lab->_screenHeight - 1); g_lab->rectFill(0, 0, g_lab->_screenWidth - 1, g_lab->_screenHeight - 1);
blackAllScreen(); blackAllScreen();
} }

View file

@ -32,7 +32,6 @@
#include "lab/stddefines.h" #include "lab/stddefines.h"
#include "lab/labfun.h" #include "lab/labfun.h"
#include "lab/text.h" #include "lab/text.h"
#include "lab/vga.h"
namespace Lab { namespace Lab {
@ -81,7 +80,7 @@ void text(struct TextFont *tf, uint16 x, uint16 y, uint16 color, const char *tex
int32 templeft, LeftInSegment; int32 templeft, LeftInSegment;
uint16 counter, counterb, bwidth, mask, curpage, rows, cols, data; uint16 counter, counterb, bwidth, mask, curpage, rows, cols, data;
VGATop = getVGABaseAddr(); VGATop = g_lab->getVGABaseAddr();
for (counter = 0; counter < numchars; counter++) { for (counter = 0; counter < numchars; counter++) {
RealOffset = (g_lab->_screenWidth * y) + x; RealOffset = (g_lab->_screenWidth * y) + x;

View file

@ -29,7 +29,6 @@
*/ */
#include "lab/lab.h" #include "lab/lab.h"
#include "lab/vga.h"
namespace Lab { namespace Lab {

View file

@ -29,7 +29,6 @@
*/ */
#include "lab/lab.h" #include "lab/lab.h"
#include "lab/vga.h"
#include "lab/stddefines.h" #include "lab/stddefines.h"
#include "lab/mouse.h" #include "lab/mouse.h"
@ -39,27 +38,10 @@
namespace Lab { namespace Lab {
static byte _curvgapal[256 * 3];
static unsigned char _curapen = 0;
byte *_currentDsplayBuffer = 0;
byte *_displayBuffer = 0;
int _lastWaitTOFTicks = 0;
uint32 _mouseX = 0;
uint32 _mouseY = 0;
uint16 _nextKeyIn = 0;
uint16 _keyBuf[64];
uint16 _nextKeyOut = 0;
bool _mouseAtEdge = false;
byte *_tempScrollData;
/*****************************************************************************/ /*****************************************************************************/
/* Sets up either a low-res or a high-res 256 color screen. */ /* Sets up either a low-res or a high-res 256 color screen. */
/*****************************************************************************/ /*****************************************************************************/
bool createScreen(bool HiRes) { bool LabEngine::createScreen(bool HiRes) {
if (HiRes) { if (HiRes) {
g_lab->_screenWidth = 640; g_lab->_screenWidth = 640;
g_lab->_screenHeight = 480; g_lab->_screenHeight = 480;
@ -77,11 +59,11 @@ bool createScreen(bool HiRes) {
/*****************************************************************************/ /*****************************************************************************/
/* Sets the current page on the VGA card. */ /* Sets the current page on the VGA card. */
/*****************************************************************************/ /*****************************************************************************/
void changeVolume(int delta) { void LabEngine::changeVolume(int delta) {
warning("STUB: changeVolume()"); warning("STUB: changeVolume()");
} }
uint16 WSDL_GetNextChar() { uint16 LabEngine::WSDL_GetNextChar() {
uint16 c = 0; uint16 c = 0;
WSDL_ProcessInput(0); WSDL_ProcessInput(0);
@ -94,12 +76,12 @@ uint16 WSDL_GetNextChar() {
return c; return c;
} }
bool WSDL_HasNextChar() { bool LabEngine::WSDL_HasNextChar() {
WSDL_ProcessInput(0); WSDL_ProcessInput(0);
return _nextKeyIn != _nextKeyOut; return _nextKeyIn != _nextKeyOut;
} }
void WSDL_ProcessInput(bool can_delay) { void LabEngine::WSDL_ProcessInput(bool can_delay) {
int n; int n;
int lastMouseAtEdge; int lastMouseAtEdge;
int flags = 0; int flags = 0;
@ -186,14 +168,14 @@ void WSDL_ProcessInput(bool can_delay) {
g_system->delayMillis(10); g_system->delayMillis(10);
} }
void WSDL_GetMousePos(int *x, int *y) { void LabEngine::WSDL_GetMousePos(int *x, int *y) {
WSDL_ProcessInput(0); WSDL_ProcessInput(0);
*x = _mouseX; *x = _mouseX;
*y = _mouseY; *y = _mouseY;
} }
void waitTOF() { void LabEngine::waitTOF() {
g_system->copyRectToScreen(_displayBuffer, g_lab->_screenWidth, 0, 0, g_lab->_screenWidth, g_lab->_screenHeight); g_system->copyRectToScreen(_displayBuffer, g_lab->_screenWidth, 0, 0, g_lab->_screenWidth, g_lab->_screenHeight);
g_system->updateScreen(); g_system->updateScreen();
@ -207,7 +189,7 @@ void waitTOF() {
_lastWaitTOFTicks = now; _lastWaitTOFTicks = now;
} }
void WSDL_SetColors(byte *buf, uint16 first, uint16 numreg, uint16 slow) { void LabEngine::WSDL_SetColors(byte *buf, uint16 first, uint16 numreg, uint16 slow) {
byte tmp[256 * 3]; byte tmp[256 * 3];
for (int i = 0; i < 256 * 3; i++) { for (int i = 0; i < 256 * 3; i++) {
@ -231,12 +213,12 @@ void WSDL_SetColors(byte *buf, uint16 first, uint16 numreg, uint16 slow) {
/* The length of the buffer is 3 times the number of registers */ /* The length of the buffer is 3 times the number of registers */
/* selected. */ /* selected. */
/*****************************************************************************/ /*****************************************************************************/
void writeColorRegs(byte *buf, uint16 first, uint16 numreg) { void LabEngine::writeColorRegs(byte *buf, uint16 first, uint16 numreg) {
WSDL_SetColors(buf, first, numreg, 0); WSDL_SetColors(buf, first, numreg, 0);
memcpy(&(_curvgapal[first * 3]), buf, numreg * 3); memcpy(&(_curvgapal[first * 3]), buf, numreg * 3);
} }
void writeColorRegsSmooth(byte *buf, uint16 first, uint16 numreg) { void LabEngine::writeColorRegsSmooth(byte *buf, uint16 first, uint16 numreg) {
WSDL_SetColors(buf, first, numreg, 1); WSDL_SetColors(buf, first, numreg, 1);
memcpy(&(_curvgapal[first * 3]), buf, numreg * 3); memcpy(&(_curvgapal[first * 3]), buf, numreg * 3);
} }
@ -246,16 +228,16 @@ void writeColorRegsSmooth(byte *buf, uint16 first, uint16 numreg) {
/* the first character in the string is the red value, then green, then */ /* the first character in the string is the red value, then green, then */
/* blue. Each color value is a 6 bit value. */ /* blue. Each color value is a 6 bit value. */
/*****************************************************************************/ /*****************************************************************************/
void writeColorReg(byte *buf, uint16 regnum) { void LabEngine::writeColorReg(byte *buf, uint16 regnum) {
writeColorRegs(buf, regnum, 1); writeColorRegs(buf, regnum, 1);
} }
void VGASetPal(void *cmap, uint16 numcolors) { void LabEngine::VGASetPal(void *cmap, uint16 numcolors) {
if (memcmp(cmap, _curvgapal, numcolors * 3) != 0) if (memcmp(cmap, _curvgapal, numcolors * 3) != 0)
writeColorRegs((byte *)cmap, 0, numcolors); writeColorRegs((byte *)cmap, 0, numcolors);
} }
void WSDL_UpdateScreen() { void LabEngine::WSDL_UpdateScreen() {
g_system->copyRectToScreen(_displayBuffer, g_lab->_screenWidth, 0, 0, g_lab->_screenWidth, g_lab->_screenHeight); g_system->copyRectToScreen(_displayBuffer, g_lab->_screenWidth, 0, 0, g_lab->_screenWidth, g_lab->_screenHeight);
g_system->updateScreen(); g_system->updateScreen();
@ -265,7 +247,7 @@ void WSDL_UpdateScreen() {
/*****************************************************************************/ /*****************************************************************************/
/* Returns the base address of the current VGA display. */ /* Returns the base address of the current VGA display. */
/*****************************************************************************/ /*****************************************************************************/
byte *getVGABaseAddr() { byte *LabEngine::getVGABaseAddr() {
if (_currentDsplayBuffer) if (_currentDsplayBuffer)
return _currentDsplayBuffer; return _currentDsplayBuffer;
@ -275,7 +257,7 @@ byte *getVGABaseAddr() {
/*****************************************************************************/ /*****************************************************************************/
/* Draws an image to the screen. */ /* Draws an image to the screen. */
/*****************************************************************************/ /*****************************************************************************/
void drawImage(Image *Im, uint16 x, uint16 y) { void LabEngine::drawImage(Image *Im, uint16 x, uint16 y) {
int sx, sy, dx, dy, w, h; int sx, sy, dx, dy, w, h;
sx = 0; sx = 0;
@ -318,7 +300,7 @@ void drawImage(Image *Im, uint16 x, uint16 y) {
/*****************************************************************************/ /*****************************************************************************/
/* Draws an image to the screen. */ /* Draws an image to the screen. */
/*****************************************************************************/ /*****************************************************************************/
void drawMaskImage(Image *Im, uint16 x, uint16 y) { void LabEngine::drawMaskImage(Image *Im, uint16 x, uint16 y) {
int sx, sy, dx, dy, w, h; int sx, sy, dx, dy, w, h;
sx = 0; sx = 0;
@ -371,7 +353,7 @@ void drawMaskImage(Image *Im, uint16 x, uint16 y) {
/*****************************************************************************/ /*****************************************************************************/
/* Reads an image from the screen. */ /* Reads an image from the screen. */
/*****************************************************************************/ /*****************************************************************************/
void readScreenImage(Image *Im, uint16 x, uint16 y) { void LabEngine::readScreenImage(Image *Im, uint16 x, uint16 y) {
int sx, sy, dx, dy, w, h; int sx, sy, dx, dy, w, h;
sx = 0; sx = 0;
@ -415,7 +397,7 @@ void readScreenImage(Image *Im, uint16 x, uint16 y) {
/* Blits a piece of one image to another. */ /* Blits a piece of one image to another. */
/* NOTE: for our purposes, assumes that ImDest is to be in VGA memory. */ /* NOTE: for our purposes, assumes that ImDest is to be in VGA memory. */
/*****************************************************************************/ /*****************************************************************************/
void bltBitMap(Image *ImSource, uint16 xs, uint16 ys, Image *ImDest, void LabEngine::bltBitMap(Image *ImSource, uint16 xs, uint16 ys, Image *ImDest,
uint16 xd, uint16 yd, uint16 width, uint16 height) { uint16 xd, uint16 yd, uint16 width, uint16 height) {
// I think the old code assumed that the source image data was valid for the given box. // I think the old code assumed that the source image data was valid for the given box.
// I will proceed on that assumption. // I will proceed on that assumption.
@ -461,7 +443,7 @@ void bltBitMap(Image *ImSource, uint16 xs, uint16 ys, Image *ImDest,
/* The _tempScrollData variable must be initialized to some memory, or this */ /* The _tempScrollData variable must be initialized to some memory, or this */
/* function will fail. */ /* function will fail. */
/*****************************************************************************/ /*****************************************************************************/
void scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 y2) { void LabEngine::scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
Image Im; Image Im;
uint16 temp; uint16 temp;
@ -503,7 +485,7 @@ void scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
/*****************************************************************************/ /*****************************************************************************/
/* Scrolls the display in the y direction by blitting. */ /* Scrolls the display in the y direction by blitting. */
/*****************************************************************************/ /*****************************************************************************/
void scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2) { void LabEngine::scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
Image Im; Image Im;
uint16 temp; uint16 temp;
@ -545,14 +527,14 @@ void scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
/*****************************************************************************/ /*****************************************************************************/
/* Sets the pen number to use on all the drawing operations. */ /* Sets the pen number to use on all the drawing operations. */
/*****************************************************************************/ /*****************************************************************************/
void setAPen(uint16 pennum) { void LabEngine::setAPen(uint16 pennum) {
_curapen = (unsigned char)pennum; _curapen = (unsigned char)pennum;
} }
/*****************************************************************************/ /*****************************************************************************/
/* Fills in a rectangle. */ /* Fills in a rectangle. */
/*****************************************************************************/ /*****************************************************************************/
void rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2) { void LabEngine::rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
int dx, dy, w, h; int dx, dy, w, h;
dx = x1; dx = x1;
@ -595,21 +577,21 @@ void rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
/*****************************************************************************/ /*****************************************************************************/
/* Draws a horizontal line. */ /* Draws a horizontal line. */
/*****************************************************************************/ /*****************************************************************************/
void drawVLine(uint16 x, uint16 y1, uint16 y2) { void LabEngine::drawVLine(uint16 x, uint16 y1, uint16 y2) {
rectFill(x, y1, x, y2); rectFill(x, y1, x, y2);
} }
/*****************************************************************************/ /*****************************************************************************/
/* Draws a vertical line. */ /* Draws a vertical line. */
/*****************************************************************************/ /*****************************************************************************/
void drawHLine(uint16 x1, uint16 y, uint16 x2) { void LabEngine::drawHLine(uint16 x1, uint16 y, uint16 x2) {
rectFill(x1, y, x2, y); rectFill(x1, y, x2, y);
} }
/*****************************************************************************/ /*****************************************************************************/
/* Ghoasts a region on the screen using the desired pen color. */ /* Ghoasts a region on the screen using the desired pen color. */
/*****************************************************************************/ /*****************************************************************************/
void ghoastRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, uint16 y2) { void LabEngine::ghoastRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
int dx, dy, w, h; int dx, dy, w, h;
dx = x1; dx = x1;

View file

@ -1,74 +0,0 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
/*
* This code is based on Labyrinth of Time code with assistance of
*
* Copyright (c) 1993 Terra Nova Development
* Copyright (c) 2004 The Wyrmkeep Entertainment Co.
*
*/
#include "lab/stddefines.h"
#ifndef LAB_VGA_H
#define LAB_VGA_H
namespace Lab {
struct Image {
uint16 Width;
uint16 Height;
byte *ImageData;
};
bool createScreen(bool HiRes);
void waitTOF();
void quickWaitTOF();
byte *getVGABaseAddr();
void writeColorReg(byte *buf, uint16 regnum);
void writeColorRegs(byte *buf, uint16 first, uint16 numreg);
void writeColorRegsSmooth(byte *buf, uint16 first, uint16 numreg);
void VGASetPal(void *cmap, uint16 numcolors);
/*---------- Drawing Routines ----------*/
void drawImage(Image *Im, uint16 x, uint16 y);
void drawMaskImage(Image *Im, uint16 x, uint16 y);
void readScreenImage(Image *Im, uint16 x, uint16 y);
void bltBitMap(Image *ImSource, uint16 xs, uint16 ys, Image *ImDest, uint16 xd, uint16 yd, uint16 width, uint16 height);
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 setAPen(uint16 pennum);
void drawHLine(uint16 x, uint16 y1, uint16 y2);
void drawVLine(uint16 x1, uint16 y, uint16 x2);
void rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2);
void ghoastRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
void WSDL_UpdateScreen();
void WSDL_GetMousePos(int *x, int *y);
uint16 WSDL_GetNextChar();
bool WSDL_HasNextChar();
void WSDL_ProcessInput(bool can_delay);
} // End of namespace Lab
#endif /* LAB_VGA_H */