LAB: Move more functions to DisplayMan

This commit is contained in:
Strangerke 2015-12-06 14:36:49 +01:00 committed by Willem Jan Palenstijn
parent d9d2383d93
commit ef99d82d13
17 changed files with 304 additions and 314 deletions

View file

@ -424,7 +424,7 @@ void Anim::diffNextFrame() {
return; return;
if (DispBitMap->_flags & BITMAPF_VIDEO) { if (DispBitMap->_flags & BITMAPF_VIDEO) {
DispBitMap->_planes[0] = _vm->getCurrentDrawingBuffer(); DispBitMap->_planes[0] = _vm->_graphics->getCurrentDrawingBuffer();
DispBitMap->_planes[1] = DispBitMap->_planes[0] + 0x10000; DispBitMap->_planes[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;
@ -444,7 +444,7 @@ void Anim::diffNextFrame() {
} }
if (_isPal && !_noPalChange) { if (_isPal && !_noPalChange) {
_vm->setPalette(_diffPalette, 256); _vm->_graphics->setPalette(_diffPalette, 256);
_isPal = false; _isPal = false;
} }
@ -452,7 +452,7 @@ void Anim::diffNextFrame() {
} }
if (_isPal && !_noPalChange && !_isBM && !_donePal) { if (_isPal && !_noPalChange && !_isBM && !_donePal) {
_vm->setPalette(_diffPalette, 256); _vm->_graphics->setPalette(_diffPalette, 256);
_isPal = false; _isPal = false;
} }

View file

@ -296,7 +296,7 @@ bool LabEngine::doUse(uint16 CurInv) {
_curFileName = " "; _curFileName = " ";
_cptr = NULL; _cptr = NULL;
doMap(_roomNum); doMap(_roomNum);
setPalette(initcolors, 8); _graphics->setPalette(initcolors, 8);
_graphics->drawMessage(NULL); _graphics->drawMessage(NULL);
_graphics->drawPanel(); _graphics->drawPanel();
} else if (CurInv == JOURNALNUM) { /* LAB: Labyrinth specific */ } else if (CurInv == JOURNALNUM) { /* LAB: Labyrinth specific */
@ -400,7 +400,7 @@ void LabEngine::mainGameLoop() {
bool forceDraw = false, GotMessage = true; bool forceDraw = false, GotMessage = true;
setPalette(initcolors, 8); _graphics->setPalette(initcolors, 8);
_cptr = NULL; _cptr = NULL;
_roomNum = 1; _roomNum = 1;
@ -843,14 +843,10 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
if (doit) { if (doit) {
_graphics->drawMessage("Disk operation failed."); _graphics->drawMessage("Disk operation failed.");
setPalette(initcolors, 8); _graphics->setPalette(initcolors, 8);
_graphics->screenUpdate();
g_system->delayMillis(1000); g_system->delayMillis(1000);
} else {
_graphics->screenUpdate();
} }
_graphics->screenUpdate();
} else if (gadgetId == 1) { } else if (gadgetId == 1) {
if (!doUse(curInv)) { if (!doUse(curInv)) {
Old = actionMode; Old = actionMode;

View file

@ -299,8 +299,9 @@ void EventManager::processInput(bool can_delay) {
_mousePos.x = 0; _mousePos.x = 0;
_mouseAtEdge = true; _mouseAtEdge = true;
} }
if (_mousePos.x > _vm->_screenWidth - 1) {
_mousePos.x = _vm->_screenWidth; if (_mousePos.x >= _vm->_graphics->_screenWidth) {
_mousePos.x = _vm->_graphics->_screenWidth;
_mouseAtEdge = true; _mouseAtEdge = true;
} }
@ -309,8 +310,9 @@ void EventManager::processInput(bool can_delay) {
_mousePos.y = 0; _mousePos.y = 0;
_mouseAtEdge = true; _mouseAtEdge = true;
} }
if (_mousePos.y > _vm->_screenHeight - 1) {
_mousePos.y = _vm->_screenHeight; if (_mousePos.y >= _vm->_graphics->_screenHeight) {
_mousePos.y = _vm->_graphics->_screenHeight;
_mouseAtEdge = true; _mouseAtEdge = true;
} }
@ -350,7 +352,7 @@ void EventManager::processInput(bool can_delay) {
break; break;
} }
g_system->copyRectToScreen(_vm->_displayBuffer, _vm->_screenWidth, 0, 0, _vm->_screenWidth, _vm->_screenHeight); g_system->copyRectToScreen(_vm->_graphics->_displayBuffer, _vm->_graphics->_screenWidth, 0, 0, _vm->_graphics->_screenWidth, _vm->_graphics->_screenHeight);
g_system->updateScreen(); g_system->updateScreen();
} }
} }

View file

@ -48,7 +48,16 @@ DisplayMan::DisplayMan(LabEngine *vm) : _vm(vm) {
_screenBytesPerPage = 65536; _screenBytesPerPage = 65536;
_curapen = 0; _curapen = 0;
_curBitmap = NULL; _curBitmap = nullptr;
_displayBuffer = nullptr;
_currentDisplayBuffer = nullptr;
_tempScrollData = nullptr;
_screenWidth = 0;
_screenHeight = 0;
for (int i = 0; i < 256 * 3; i++)
_curvgapal[i] = 0;
} }
DisplayMan::~DisplayMan() { DisplayMan::~DisplayMan() {
@ -129,8 +138,8 @@ bool DisplayMan::readPict(const char *filename, bool playOnce) {
if (!_vm->_music->_doNotFilestopSoundEffect) if (!_vm->_music->_doNotFilestopSoundEffect)
_vm->_music->stopSoundEffect(); _vm->_music->stopSoundEffect();
DispBitMap->_bytesPerRow = _vm->_screenWidth; DispBitMap->_bytesPerRow = _screenWidth;
DispBitMap->_rows = _vm->_screenHeight; DispBitMap->_rows = _screenHeight;
DispBitMap->_flags = BITMAPF_VIDEO; DispBitMap->_flags = BITMAPF_VIDEO;
_vm->_anim->readDiff(_curBitmap, playOnce); _vm->_anim->readDiff(_curBitmap, playOnce);
@ -343,15 +352,15 @@ uint32 DisplayMan::flowTextToMem(Image *destIm, void *font, /* the TextAttr
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 = _screenBytesPerPage; uint32 res, vgabyte = _screenBytesPerPage;
byte *tmp = _vm->_currentDisplayBuffer; byte *tmp = _currentDisplayBuffer;
_vm->_currentDisplayBuffer = destIm->_imageData; _currentDisplayBuffer = destIm->_imageData;
_screenBytesPerPage = (uint32)destIm->_width * (int32)destIm->_height; _screenBytesPerPage = (uint32)destIm->_width * (int32)destIm->_height;
res = _vm->_graphics->flowText(font, spacing, pencolor, backpen, fillback, centerh, centerv, output, x1, y1, x2, y2, str); res = flowText(font, spacing, pencolor, backpen, fillback, centerh, centerv, output, x1, y1, x2, y2, str);
_screenBytesPerPage = vgabyte; _screenBytesPerPage = vgabyte;
_vm->_currentDisplayBuffer = tmp; _currentDisplayBuffer = tmp;
return res; return res;
} }
@ -391,10 +400,6 @@ int32 DisplayMan::longDrawMessage(const char *str) {
return flowTextScaled(_vm->_msgFont, 0, 1, 7, false, true, true, true, 6, 155, 313, 195, str); return flowTextScaled(_vm->_msgFont, 0, 1, 7, false, true, true, true, 6, 155, 313, 195, str);
} }
void LabEngine::drawStaticMessage(byte index) {
_graphics->drawMessage(_resource->getStaticText((StaticText)index).c_str());
}
/******************************************************************************/ /******************************************************************************/
/* Draws a message to the message box. */ /* Draws a message to the message box. */
/******************************************************************************/ /******************************************************************************/
@ -442,7 +447,7 @@ void DisplayMan::doScrollBlack() {
byte *tempmem; byte *tempmem;
Image im; Image im;
uint32 size, copysize; uint32 size, copysize;
uint32 *baseAddr; byte *baseAddr;
uint16 width = VGAScaleX(320); uint16 width = VGAScaleX(320);
uint16 height = VGAScaleY(149) + SVGACord(2); uint16 height = VGAScaleY(149) + SVGACord(2);
byte *mem = new byte[width * height]; byte *mem = new byte[width * height];
@ -456,7 +461,7 @@ void DisplayMan::doScrollBlack() {
im.readScreenImage(0, 0); im.readScreenImage(0, 0);
_vm->_music->updateMusic(); _vm->_music->updateMusic();
baseAddr = (uint32 *)_vm->getCurrentDrawingBuffer(); baseAddr = getCurrentDrawingBuffer();
uint16 by = VGAScaleX(4); uint16 by = VGAScaleX(4);
uint16 nheight = height; uint16 nheight = height;
@ -467,7 +472,7 @@ void DisplayMan::doScrollBlack() {
if (!_vm->_isHiRes) if (!_vm->_isHiRes)
_vm->waitTOF(); _vm->waitTOF();
baseAddr = (uint32 *)_vm->getCurrentDrawingBuffer(); baseAddr = getCurrentDrawingBuffer();
if (by > nheight) if (by > nheight)
by = nheight; by = nheight;
@ -510,20 +515,17 @@ void DisplayMan::doScrollBlack() {
} }
void DisplayMan::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; byte *baseAddr = getCurrentDrawingBuffer();
uint16 curPage;
uint32 *baseAddr;
baseAddr = (uint32 *)_vm->getCurrentDrawingBuffer(); uint32 size = (int32)(height - nheight) * (int32)width;
size = (int32)(height - nheight) * (int32)width;
mem += startline * width; mem += startline * width;
curPage = ((int32)nheight * (int32)width) / _vm->_graphics->_screenBytesPerPage; uint16 curPage = ((int32)nheight * (int32)width) / _screenBytesPerPage;
offSet = ((int32)nheight * (int32)width) - (curPage * _vm->_graphics->_screenBytesPerPage); uint32 offSet = ((int32)nheight * (int32)width) - (curPage * _screenBytesPerPage);
while (size) { while (size) {
if (size > (_vm->_graphics->_screenBytesPerPage - offSet)) uint32 copysize;
copysize = _vm->_graphics->_screenBytesPerPage - offSet; if (size > (_screenBytesPerPage - offSet))
copysize = _screenBytesPerPage - offSet;
else else
copysize = size; copysize = size;
@ -553,7 +555,7 @@ void DisplayMan::doScrollWipe(char *filename) {
_vm->_anim->_isBM = true; _vm->_anim->_isBM = true;
readPict(filename, true); readPict(filename, true);
_vm->setPalette(_vm->_anim->_diffPalette, 256); setPalette(_vm->_anim->_diffPalette, 256);
_vm->_anim->_isBM = false; _vm->_anim->_isBM = false;
byte *mem = _vm->_anim->_rawDiffBM._planes[0]; byte *mem = _vm->_anim->_rawDiffBM._planes[0];
@ -664,7 +666,7 @@ void DisplayMan::doTransWipe(CloseDataPtr *cPtr, char *filename) {
linesdone = 0; linesdone = 0;
} }
_vm->overlayRect(0, 0, curY, _vm->_screenWidth - 1, curY + 1); overlayRect(0, 0, curY, _screenWidth - 1, curY + 1);
curY += 4; curY += 4;
linesdone++; linesdone++;
} }
@ -682,7 +684,7 @@ void DisplayMan::doTransWipe(CloseDataPtr *cPtr, char *filename) {
linesdone = 0; linesdone = 0;
} }
rectFill(0, curY, _vm->_screenWidth - 1, curY + 1); rectFill(0, curY, _screenWidth - 1, curY + 1);
curY += 4; curY += 4;
linesdone++; linesdone++;
} }
@ -695,17 +697,17 @@ void DisplayMan::doTransWipe(CloseDataPtr *cPtr, char *filename) {
else else
_vm->_curFileName = getPictName(cPtr); _vm->_curFileName = getPictName(cPtr);
byte *BitMapMem = readPictToMem(_vm->_curFileName, _vm->_screenWidth, lastY + 5); byte *BitMapMem = readPictToMem(_vm->_curFileName, _screenWidth, lastY + 5);
_vm->setPalette(_vm->_anim->_diffPalette, 256); setPalette(_vm->_anim->_diffPalette, 256);
if (BitMapMem) { if (BitMapMem) {
imSource._width = _vm->_screenWidth; imSource._width = _screenWidth;
imSource._height = lastY; imSource._height = lastY;
imSource._imageData = BitMapMem; imSource._imageData = BitMapMem;
imDest._width = _vm->_screenWidth; imDest._width = _screenWidth;
imDest._height = _vm->_screenHeight; imDest._height = _screenHeight;
imDest._imageData = _vm->getCurrentDrawingBuffer(); imDest._imageData = getCurrentDrawingBuffer();
for (uint16 i = 0; i < 2; i++) { for (uint16 i = 0; i < 2; i++) {
curY = i * 2; curY = i * 2;
@ -717,10 +719,10 @@ void DisplayMan::doTransWipe(CloseDataPtr *cPtr, char *filename) {
linesdone = 0; linesdone = 0;
} }
imDest._imageData = _vm->getCurrentDrawingBuffer(); imDest._imageData = getCurrentDrawingBuffer();
imSource.blitBitmap(0, curY, &imDest, 0, curY, _vm->_screenWidth, 2, false); imSource.blitBitmap(0, curY, &imDest, 0, curY, _screenWidth, 2, false);
_vm->overlayRect(0, 0, curY, _vm->_screenWidth - 1, curY + 1); overlayRect(0, 0, curY, _screenWidth - 1, curY + 1);
curY += 4; curY += 4;
linesdone++; linesdone++;
} }
@ -736,12 +738,12 @@ void DisplayMan::doTransWipe(CloseDataPtr *cPtr, char *filename) {
linesdone = 0; linesdone = 0;
} }
imDest._imageData = _vm->getCurrentDrawingBuffer(); imDest._imageData = getCurrentDrawingBuffer();
if (curY == lastY) if (curY == lastY)
imSource.blitBitmap(0, curY, &imDest, 0, curY, _vm->_screenWidth, 1, false); imSource.blitBitmap(0, curY, &imDest, 0, curY, _screenWidth, 1, false);
else else
imSource.blitBitmap(0, curY, &imDest, 0, curY, _vm->_screenWidth, 2, false); imSource.blitBitmap(0, curY, &imDest, 0, curY, _screenWidth, 2, false);
curY += 4; curY += 4;
linesdone++; linesdone++;
@ -774,7 +776,7 @@ void DisplayMan::doWipe(uint16 wipeType, CloseDataPtr *cPtr, char *filename) {
void DisplayMan::blackScreen() { void DisplayMan::blackScreen() {
byte pal[256 * 3]; byte pal[256 * 3];
memset(pal, 0, 248 * 3); memset(pal, 0, 248 * 3);
_vm->writeColorRegs(pal, 8, 248); writeColorRegs(pal, 8, 248);
g_system->delayMillis(32); g_system->delayMillis(32);
} }
@ -785,7 +787,7 @@ void DisplayMan::blackScreen() {
void DisplayMan::whiteScreen() { void DisplayMan::whiteScreen() {
byte pal[256 * 3]; byte pal[256 * 3];
memset(pal, 255, 248 * 3); memset(pal, 255, 248 * 3);
_vm->writeColorRegs(pal, 8, 248); writeColorRegs(pal, 8, 248);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -794,7 +796,7 @@ void DisplayMan::whiteScreen() {
void DisplayMan::blackAllScreen() { void DisplayMan::blackAllScreen() {
byte pal[256 * 3]; byte pal[256 * 3];
memset(pal, 0, 256 * 3); memset(pal, 0, 256 * 3);
_vm->writeColorRegs(pal, 0, 256); writeColorRegs(pal, 0, 256);
g_system->delayMillis(32); g_system->delayMillis(32);
} }
@ -938,14 +940,14 @@ void DisplayMan::rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
int w = x2 - x1 + 1; int w = x2 - x1 + 1;
int h = y2 - y1 + 1; int h = y2 - y1 + 1;
if (x1 + w > _vm->_screenWidth) if (x1 + w > _screenWidth)
w = _vm->_screenWidth - x1; w = _screenWidth - x1;
if (y1 + h > _vm->_screenHeight) if (y1 + h > _screenHeight)
h = _vm->_screenHeight - y1; h = _screenHeight - y1;
if ((w > 0) && (h > 0)) { if ((w > 0) && (h > 0)) {
char *d = (char *)_vm->getCurrentDrawingBuffer() + y1 * _vm->_screenWidth + x1; char *d = (char *)getCurrentDrawingBuffer() + y1 * _screenWidth + x1;
while (h-- > 0) { while (h-- > 0) {
char *dd = d; char *dd = d;
@ -955,7 +957,7 @@ void DisplayMan::rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
*dd++ = _curapen; *dd++ = _curapen;
} }
d += _vm->_screenWidth; d += _screenWidth;
} }
} }
} }
@ -979,7 +981,7 @@ void DisplayMan::drawHLine(uint16 x1, uint16 y, uint16 x2) {
} }
void DisplayMan::screenUpdate() { void DisplayMan::screenUpdate() {
g_system->copyRectToScreen(_vm->_displayBuffer, _vm->_screenWidth, 0, 0, _vm->_screenWidth, _vm->_screenHeight); g_system->copyRectToScreen(_displayBuffer, _screenWidth, 0, 0, _screenWidth, _screenHeight);
g_system->updateScreen(); g_system->updateScreen();
_vm->_event->processInput(); _vm->_event->processInput();
@ -990,17 +992,176 @@ void DisplayMan::screenUpdate() {
/*****************************************************************************/ /*****************************************************************************/
bool DisplayMan::createScreen(bool hiRes) { bool DisplayMan::createScreen(bool hiRes) {
if (hiRes) { if (hiRes) {
_vm->_screenWidth = 640; _screenWidth = 640;
_vm->_screenHeight = 480; _screenHeight = 480;
} else { } else {
_vm->_screenWidth = 320; _screenWidth = 320;
_vm->_screenHeight = 200; _screenHeight = 200;
} }
_screenBytesPerPage = _vm->_screenWidth * _vm->_screenHeight; _screenBytesPerPage = _screenWidth * _screenHeight;
_displayBuffer = new byte[_screenBytesPerPage]; // FIXME: Memory leak!
_vm->_displayBuffer = new byte[_screenBytesPerPage]; // FIXME: Memory leak!
return true; return true;
} }
/*****************************************************************************/
/* Converts an Amiga palette (up to 16 colors) to a VGA palette, then sets */
/* the VGA palette. */
/*****************************************************************************/
void DisplayMan::setAmigaPal(uint16 *pal, uint16 numColors) {
byte vgaPal[16 * 3];
uint16 vgaIdx = 0;
if (numColors > 16)
numColors = 16;
for (uint16 i = 0; i < numColors; i++) {
vgaPal[vgaIdx++] = (byte)(((pal[i] & 0xf00) >> 8) << 2);
vgaPal[vgaIdx++] = (byte)(((pal[i] & 0x0f0) >> 4) << 2);
vgaPal[vgaIdx++] = (byte)(((pal[i] & 0x00f)) << 2);
}
writeColorRegs(vgaPal, 0, 16);
_vm->waitTOF();
}
/*****************************************************************************/
/* Writes any number of the 256 color registers. */
/* first: the number of the first color register to write. */
/* numreg: the number of registers to write */
/* buf: a char pointer which contains the selected color registers. */
/* Each value representing a color register occupies 3 bytes in */
/* the array. The order is red, green then blue. The first byte */
/* in the array is the red component of the first element selected.*/
/* The length of the buffer is 3 times the number of registers */
/* selected. */
/*****************************************************************************/
void DisplayMan::writeColorRegs(byte *buf, uint16 first, uint16 numreg) {
byte tmp[256 * 3];
for (int i = 0; i < 256 * 3; i++) {
tmp[i] = buf[i] * 4;
}
g_system->getPaletteManager()->setPalette(tmp, first, numreg);
memcpy(&(_curvgapal[first * 3]), buf, numreg * 3);
}
void DisplayMan::setPalette(void *cmap, uint16 numcolors) {
if (memcmp(cmap, _curvgapal, numcolors * 3) != 0)
writeColorRegs((byte *)cmap, 0, numcolors);
}
/*****************************************************************************/
/* Returns the base address of the current VGA display. */
/*****************************************************************************/
byte *DisplayMan::getCurrentDrawingBuffer() {
if (_currentDisplayBuffer)
return _currentDisplayBuffer;
return _displayBuffer;
}
/*****************************************************************************/
/* Overlays a region on the screen using the desired pen color. */
/*****************************************************************************/
void DisplayMan::overlayRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
int w = x2 - x1 + 1;
int h = y2 - y1 + 1;
if (x1 + w > _screenWidth)
w = _screenWidth - x1;
if (y1 + h > _screenHeight)
h = _screenHeight - y1;
if ((w > 0) && (h > 0)) {
char *d = (char *)getCurrentDrawingBuffer() + y1 * _screenWidth + x1;
while (h-- > 0) {
char *dd = d;
int ww = w;
if (y1 & 1) {
dd++;
ww--;
}
while (ww > 0) {
*dd = pencolor;
dd += 2;
ww -= 2;
}
d += _screenWidth;
y1++;
}
}
}
/*****************************************************************************/
/* Scrolls the display in the x direction by blitting. */
/* The _tempScrollData variable must be initialized to some memory, or this */
/* function will fail. */
/*****************************************************************************/
void DisplayMan::scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
Image im;
uint16 temp;
im._imageData = _tempScrollData;
if (x1 > x2) {
temp = x2;
x2 = x1;
x1 = temp;
}
if (y1 > y2) {
temp = y2;
y2 = y1;
y1 = temp;
}
im._width = x2 - x1 + 1 - dx;
im._height = y2 - y1 + 1;
im.readScreenImage(x1, y1);
im.drawImage(x1 + dx, y1);
setAPen(0);
rectFill(x1, y1, x1 + dx - 1, y2);
}
/*****************************************************************************/
/* Scrolls the display in the y direction by blitting. */
/*****************************************************************************/
void DisplayMan::scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
Image im;
uint16 temp;
im._imageData = _tempScrollData;
if (x1 > x2) {
temp = x2;
x2 = x1;
x1 = temp;
}
if (y1 > y2) {
temp = y2;
y2 = y1;
y1 = temp;
}
im._width = x2 - x1 + 1;
im._height = y2 - y1 + 1 - dy;
im.readScreenImage(x1, y1);
im.drawImage(x1, y1 + dy);
setAPen(0);
rectFill(x1, y1, x2, y1 + dy - 1);
}
} // End of namespace Lab } // End of namespace Lab

View file

@ -31,6 +31,8 @@
#ifndef LAB_GRAPHICS_H #ifndef LAB_GRAPHICS_H
#define LAB_GRAPHICS_H #define LAB_GRAPHICS_H
#include "graphics/palette.h"
namespace Lab { namespace Lab {
class LabEngine; class LabEngine;
@ -41,6 +43,8 @@ private:
byte _curapen; byte _curapen;
byte *_curBitmap; byte *_curBitmap;
byte _curvgapal[256 * 3];
byte *_tempScrollData;
public: public:
DisplayMan(LabEngine *lab); DisplayMan(LabEngine *lab);
@ -114,10 +118,21 @@ public:
void drawVLine(uint16 x1, uint16 y, uint16 x2); void drawVLine(uint16 x1, uint16 y, uint16 x2);
void screenUpdate(); void screenUpdate();
bool createScreen(bool HiRes); bool createScreen(bool HiRes);
void setAmigaPal(uint16 *pal, uint16 numColors);
void writeColorRegs(byte *buf, uint16 first, uint16 numreg);
void setPalette(void *cmap, uint16 numcolors);
void overlayRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
byte *getCurrentDrawingBuffer();
void scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
void scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
bool _longWinInFront; bool _longWinInFront;
bool _lastMessageLong; bool _lastMessageLong;
uint32 _screenBytesPerPage; uint32 _screenBytesPerPage;
int _screenWidth;
int _screenHeight;
byte *_displayBuffer;
byte *_currentDisplayBuffer;
}; };
} // End of namespace Lab } // End of namespace Lab

View file

@ -56,9 +56,9 @@ void Image::blitBitmap(uint16 xs, uint16 ys, Image *imDest,
uint16 xd, uint16 yd, uint16 width, uint16 height, byte masked) { uint16 xd, uint16 yd, uint16 width, uint16 height, byte masked) {
int w = width; int w = width;
int h = height; int h = height;
int destWidth = (imDest) ? imDest->_width : g_lab->_screenWidth; int destWidth = (imDest) ? imDest->_width : g_lab->_graphics->_screenWidth;
int destHeight = (imDest) ? imDest->_height : g_lab->_screenHeight; int destHeight = (imDest) ? imDest->_height : g_lab->_graphics->_screenHeight;
byte *destBuffer = (imDest) ? imDest->_imageData : g_lab->getCurrentDrawingBuffer(); byte *destBuffer = (imDest) ? imDest->_imageData : g_lab->_graphics->getCurrentDrawingBuffer();
if (xd + w > destWidth) if (xd + w > destWidth)
w = destWidth - xd; w = destWidth - xd;
@ -117,20 +117,20 @@ void Image::readScreenImage(uint16 x, uint16 y) {
int w = _width; int w = _width;
int h = _height; int h = _height;
if (x + w > g_lab->_screenWidth) if (x + w > g_lab->_graphics->_screenWidth)
w = g_lab->_screenWidth - x; w = g_lab->_graphics->_screenWidth - x;
if (y + h > g_lab->_screenHeight) if (y + h > g_lab->_graphics->_screenHeight)
h = g_lab->_screenHeight - y; h = g_lab->_graphics->_screenHeight - y;
if ((w > 0) && (h > 0)) { if ((w > 0) && (h > 0)) {
byte *s = _imageData; byte *s = _imageData;
byte *d = g_lab->getCurrentDrawingBuffer() + y * g_lab->_screenWidth + x; byte *d = g_lab->_graphics->getCurrentDrawingBuffer() + y * g_lab->_graphics->_screenWidth + x;
while (h-- > 0) { while (h-- > 0) {
memcpy(s, d, w); memcpy(s, d, w);
s += _width; s += _width;
d += g_lab->_screenWidth; d += g_lab->_graphics->_screenWidth;
} }
} }
} }

View file

@ -95,7 +95,7 @@ void drawGadgetList(Gadget *gadlist) {
/* Dims a gadget, and makes it unavailable for using. */ /* Dims a gadget, and makes it unavailable for using. */
/*****************************************************************************/ /*****************************************************************************/
void disableGadget(Gadget *curgad, uint16 pencolor) { void disableGadget(Gadget *curgad, uint16 pencolor) {
g_lab->overlayRect(pencolor, curgad->x, curgad->y, curgad->x + curgad->_image->_width - 1, curgad->y + curgad->_image->_height - 1); g_lab->_graphics->overlayRect(pencolor, curgad->x, curgad->y, curgad->x + curgad->_image->_width - 1, curgad->y + curgad->_image->_height - 1);
curgad->GadgetFlags |= GADGETOFF; curgad->GadgetFlags |= GADGETOFF;
} }

View file

@ -299,7 +299,7 @@ void Intro::introSequence() {
palette[15] = temp; palette[15] = temp;
setAmigaPal(palette, 16); _vm->_graphics->setAmigaPal(palette, 16);
_vm->waitTOF(); _vm->waitTOF();
} }
@ -382,7 +382,7 @@ void Intro::introSequence() {
_vm->_music->updateMusic(); _vm->_music->updateMusic();
_vm->waitTOF(); _vm->waitTOF();
_vm->setPalette(_vm->_anim->_diffPalette, 256); _vm->_graphics->setPalette(_vm->_anim->_diffPalette, 256);
_vm->waitTOF(); _vm->waitTOF();
_vm->waitTOF(); _vm->waitTOF();
} }
@ -442,7 +442,7 @@ void Intro::introSequence() {
if (_quitIntro) { if (_quitIntro) {
_vm->_graphics->setAPen(0); _vm->_graphics->setAPen(0);
_vm->_graphics->rectFill(0, 0, _vm->_screenWidth - 1, _vm->_screenHeight - 1); _vm->_graphics->rectFill(0, 0, _vm->_graphics->_screenWidth - 1, _vm->_graphics->_screenHeight - 1);
_vm->_anim->_doBlack = true; _vm->_anim->_doBlack = true;
} }

View file

@ -55,12 +55,6 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
: Engine(syst), _gameDescription(gameDesc), _extraGameFeatures(0) { : Engine(syst), _gameDescription(gameDesc), _extraGameFeatures(0) {
g_lab = this; g_lab = this;
_screenWidth = 320;
_screenHeight = 200;
_currentDisplayBuffer = 0;
_displayBuffer = 0;
_lastWaitTOFTicks = 0; _lastWaitTOFTicks = 0;
_isHiRes = false; _isHiRes = false;
@ -185,4 +179,8 @@ Common::String LabEngine::generateSaveFileName(uint slot) {
return Common::String::format("%s.%03u", _targetName.c_str(), slot); return Common::String::format("%s.%03u", _targetName.c_str(), slot);
} }
void LabEngine::drawStaticMessage(byte index) {
_graphics->drawMessage(_resource->getStaticText((StaticText)index).c_str());
}
} // End of namespace Lab } // End of namespace Lab

View file

@ -75,13 +75,8 @@ public:
bool hasFeature(EngineFeature f) const; bool hasFeature(EngineFeature f) const;
Common::String generateSaveFileName(uint slot); Common::String generateSaveFileName(uint slot);
//void showMainMenu();
LargeSet *_conditions, *_roomsFound; LargeSet *_conditions, *_roomsFound;
int _screenWidth;
int _screenHeight;
// timing.cpp // timing.cpp
void getTime(uint32 *secs, uint32 *micros); void getTime(uint32 *secs, uint32 *micros);
void addCurTime(uint32 sec, uint32 micros, uint32 *timeSec, uint32 *timeMicros); void addCurTime(uint32 sec, uint32 micros, uint32 *timeSec, uint32 *timeMicros);
@ -96,9 +91,6 @@ private:
// timing.cpp // timing.cpp
void microDelay(uint32 secs, uint32 micros); void microDelay(uint32 secs, uint32 micros);
// vga.cpp
byte _curvgapal[256 * 3];
public: public:
EventManager *_event; EventManager *_event;
Resource *_resource; Resource *_resource;
@ -107,8 +99,6 @@ public:
DisplayMan *_graphics; DisplayMan *_graphics;
int _roomNum; int _roomNum;
byte *_currentDisplayBuffer;
CrumbData _breadCrumbs[MAX_CRUMBS]; CrumbData _breadCrumbs[MAX_CRUMBS];
uint16 _numCrumbs; uint16 _numCrumbs;
bool _droppingCrumbs; bool _droppingCrumbs;
@ -118,9 +108,7 @@ public:
uint32 _crumbSecs, _crumbMicros; uint32 _crumbSecs, _crumbMicros;
bool _isCrumbWaiting; bool _isCrumbWaiting;
bool _alternate; bool _alternate;
byte *_tempScrollData;
bool _isHiRes; bool _isHiRes;
byte *_displayBuffer;
const char *_curFileName; const char *_curFileName;
const char *_nextFileName; const char *_nextFileName;
const char *_newFileName; /* When ProcessRoom.c decides to change the filename const char *_newFileName; /* When ProcessRoom.c decides to change the filename
@ -146,13 +134,6 @@ private:
public: public:
void waitTOF(); void waitTOF();
void writeColorRegs(byte *buf, uint16 first, uint16 numreg);
byte *getCurrentDrawingBuffer();
void scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
void scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
void overlayRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
void setPalette(void *cmap, uint16 numcolors);
void drawRoomMessage(uint16 CurInv, CloseDataPtr cptr); void drawRoomMessage(uint16 CurInv, CloseDataPtr cptr);
void interfaceOff(); void interfaceOff();
void interfaceOn(); void interfaceOn();

View file

@ -120,7 +120,6 @@ public:
/*---------------------------*/ /*---------------------------*/
void fade(bool fadein, uint16 res); void fade(bool fadein, uint16 res);
void setAmigaPal(uint16 *pal, uint16 numcolors);
void doMap(uint16 CurRoom); void doMap(uint16 CurRoom);
void doJournal(); void doJournal();
void doNotes(); void doNotes();

View file

@ -43,27 +43,6 @@ namespace Lab {
extern uint16 Direction; extern uint16 Direction;
/*****************************************************************************/
/* Converts an Amiga palette (up to 16 colors) to a VGA palette, then sets */
/* the VGA palette. */
/*****************************************************************************/
void setAmigaPal(uint16 *pal, uint16 numcolors) {
byte vgapal[16 * 3];
uint16 vgacount = 0;
if (numcolors > 16)
numcolors = 16;
for (uint16 i = 0; i < numcolors; i++) {
vgapal[vgacount++] = (byte)(((pal[i] & 0xf00) >> 8) << 2);
vgapal[vgacount++] = (byte)(((pal[i] & 0x0f0) >> 4) << 2);
vgapal[vgacount++] = (byte)(((pal[i] & 0x00f)) << 2);
}
g_lab->writeColorRegs(vgapal, 0, 16);
g_lab->waitTOF();
}
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/*------------------------------ The Map stuff ------------------------------*/ /*------------------------------ The Map stuff ------------------------------*/
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
@ -226,7 +205,7 @@ void fade(bool fadein, uint16 res) {
(0xF00 & fadeNumOut(0xF00 & FadePalette[palIdx], 0xF00 & res, i)); (0xF00 & fadeNumOut(0xF00 & FadePalette[palIdx], 0xF00 & res, i));
} }
setAmigaPal(newpal, 16); g_lab->_graphics->setAmigaPal(newpal, 16);
g_lab->waitTOF(); g_lab->waitTOF();
g_lab->_music->updateMusic(); g_lab->_music->updateMusic();
} }
@ -486,7 +465,7 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou
fade(false, 0); fade(false, 0);
_graphics->setAPen(0); _graphics->setAPen(0);
_graphics->rectFill(0, 0, _screenWidth - 1, _screenHeight - 1); _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1);
Map->drawImage(0, 0); Map->drawImage(0, 0);
drawGadgetList(MapGadgetList); drawGadgetList(MapGadgetList);
@ -583,7 +562,7 @@ void LabEngine::processMap(uint16 CurRoom) {
} }
waitTOF(); waitTOF();
writeColorRegs(newcolor, 1, 1); _graphics->writeColorRegs(newcolor, 1, 1);
_event->updateMouse(); _event->updateMouse();
waitTOF(); waitTOF();
_event->updateMouse(); _event->updateMouse();
@ -753,7 +732,7 @@ void LabEngine::doMap(uint16 CurRoom) {
_graphics->blackAllScreen(); _graphics->blackAllScreen();
_event->mouseHide(); _event->mouseHide();
_graphics->setAPen(0); _graphics->setAPen(0);
_graphics->rectFill(0, 0, _screenWidth - 1, _screenHeight - 1); _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1);
freeMapData(); freeMapData();
_graphics->blackAllScreen(); _graphics->blackAllScreen();
_event->mouseShow(); _event->mouseShow();

View file

@ -532,7 +532,7 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) {
_anim->_diffPalette[idx] = 255 - _anim->_diffPalette[idx]; _anim->_diffPalette[idx] = 255 - _anim->_diffPalette[idx];
waitTOF(); waitTOF();
setPalette(_anim->_diffPalette, 256); _graphics->setPalette(_anim->_diffPalette, 256);
waitTOF(); waitTOF();
waitTOF(); waitTOF();
} else if (aptr->Param1 == 4) { /* white the palette */ } else if (aptr->Param1 == 4) { /* white the palette */
@ -541,7 +541,7 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) {
waitTOF(); waitTOF();
} else if (aptr->Param1 == 6) { /* Restore the palette */ } else if (aptr->Param1 == 6) { /* Restore the palette */
waitTOF(); waitTOF();
setPalette(_anim->_diffPalette, 256); _graphics->setPalette(_anim->_diffPalette, 256);
waitTOF(); waitTOF();
waitTOF(); waitTOF();
} else if (aptr->Param1 == 7) { /* Quick pause */ } else if (aptr->Param1 == 7) { /* Quick pause */

View file

@ -77,13 +77,13 @@ extern uint16 Direction;
static byte *loadBackPict(const char *fileName, bool tomem) { static byte *loadBackPict(const char *fileName, bool tomem) {
byte *res = NULL; byte *res = nullptr;
FadePalette = hipal; FadePalette = hipal;
g_lab->_anim->_noPalChange = true; g_lab->_anim->_noPalChange = true;
if (tomem) if (tomem)
res = g_lab->_graphics->readPictToMem(fileName, g_lab->_screenWidth, g_lab->_screenHeight); res = g_lab->_graphics->readPictToMem(fileName, g_lab->_graphics->_screenWidth, g_lab->_graphics->_screenHeight);
else else
g_lab->_graphics->readPict(fileName, true); g_lab->_graphics->readPict(fileName, true);
@ -106,7 +106,7 @@ void doNotes() {
char *ntext = g_lab->_resource->getText("Lab:Rooms/Notes"); char *ntext = g_lab->_resource->getText("Lab:Rooms/Notes");
g_lab->_graphics->flowText(noteFont, -2 + g_lab->_graphics->SVGACord(1), 0, 0, false, false, true, true, g_lab->_graphics->VGAScaleX(25) + g_lab->_graphics->SVGACord(15), g_lab->_graphics->VGAScaleY(50), g_lab->_graphics->VGAScaleX(295) - g_lab->_graphics->SVGACord(15), g_lab->_graphics->VGAScaleY(148), ntext); g_lab->_graphics->flowText(noteFont, -2 + g_lab->_graphics->SVGACord(1), 0, 0, false, false, true, true, g_lab->_graphics->VGAScaleX(25) + g_lab->_graphics->SVGACord(15), g_lab->_graphics->VGAScaleY(50), g_lab->_graphics->VGAScaleX(295) - g_lab->_graphics->SVGACord(15), g_lab->_graphics->VGAScaleY(148), ntext);
g_lab->setPalette(g_lab->_anim->_diffPalette, 256); g_lab->_graphics->setPalette(g_lab->_anim->_diffPalette, 256);
closeFont(noteFont); closeFont(noteFont);
delete[] ntext; delete[] ntext;
@ -150,7 +150,7 @@ void doWestPaper() {
delete[] ntext; delete[] ntext;
closeFont(paperFont); closeFont(paperFont);
g_lab->setPalette(g_lab->_anim->_diffPalette, 256); g_lab->_graphics->setPalette(g_lab->_anim->_diffPalette, 256);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -268,18 +268,18 @@ static void drawJournalText() {
/*****************************************************************************/ /*****************************************************************************/
static void turnPage(bool FromLeft) { static void turnPage(bool FromLeft) {
if (FromLeft) { if (FromLeft) {
for (int i = 0; i < g_lab->_screenWidth; i += 8) { for (int i = 0; i < g_lab->_graphics->_screenWidth; i += 8) {
g_lab->_music->updateMusic(); g_lab->_music->updateMusic();
g_lab->waitTOF(); g_lab->waitTOF();
ScreenImage._imageData = g_lab->getCurrentDrawingBuffer(); ScreenImage._imageData = g_lab->_graphics->getCurrentDrawingBuffer();
JBackImage.blitBitmap(i, 0, &ScreenImage, i, 0, 8, g_lab->_screenHeight, false); JBackImage.blitBitmap(i, 0, &ScreenImage, i, 0, 8, g_lab->_graphics->_screenHeight, false);
} }
} else { } else {
for (int i = (g_lab->_screenWidth - 8); i > 0; i -= 8) { for (int i = (g_lab->_graphics->_screenWidth - 8); i > 0; i -= 8) {
g_lab->_music->updateMusic(); g_lab->_music->updateMusic();
g_lab->waitTOF(); g_lab->waitTOF();
ScreenImage._imageData = g_lab->getCurrentDrawingBuffer(); ScreenImage._imageData = g_lab->_graphics->getCurrentDrawingBuffer();
JBackImage.blitBitmap(i, 0, &ScreenImage, i, 0, 8, g_lab->_screenHeight, false); JBackImage.blitBitmap(i, 0, &ScreenImage, i, 0, 8, g_lab->_graphics->_screenHeight, false);
} }
} }
} }
@ -298,10 +298,10 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) {
drawJournalText(); drawJournalText();
ScreenImage._imageData = getCurrentDrawingBuffer(); ScreenImage._imageData = _graphics->getCurrentDrawingBuffer();
if (wipenum == 0) if (wipenum == 0)
JBackImage.blitBitmap(0, 0, &ScreenImage, 0, 0, _screenWidth, _screenHeight, false); JBackImage.blitBitmap(0, 0, &ScreenImage, 0, 0, _graphics->_screenWidth, _graphics->_screenHeight, false);
else else
turnPage((bool)(wipenum == 1)); turnPage((bool)(wipenum == 1));
@ -320,7 +320,7 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) {
fade(true, 0); fade(true, 0);
g_lab->_anim->_noPalChange = true; g_lab->_anim->_noPalChange = true;
JBackImage._imageData = _graphics->readPictToMem("P:Journal.pic", _screenWidth, _screenHeight); JBackImage._imageData = _graphics->readPictToMem("P:Journal.pic", _graphics->_screenWidth, _graphics->_screenHeight);
GotBackImage = true; GotBackImage = true;
eatMessages(); eatMessages();
@ -380,15 +380,15 @@ void LabEngine::doJournal() {
lastpage = false; lastpage = false;
GotBackImage = false; GotBackImage = false;
JBackImage._width = _screenWidth; JBackImage._width = _graphics->_screenWidth;
JBackImage._height = _screenHeight; JBackImage._height = _graphics->_screenHeight;
JBackImage._imageData = NULL; JBackImage._imageData = NULL;
BackG.NextGadget = &CancelG; BackG.NextGadget = &CancelG;
CancelG.NextGadget = &ForwardG; CancelG.NextGadget = &ForwardG;
ScreenImage = JBackImage; ScreenImage = JBackImage;
ScreenImage._imageData = getCurrentDrawingBuffer(); ScreenImage._imageData = _graphics->getCurrentDrawingBuffer();
_music->updateMusic(); _music->updateMusic();
loadJournalData(); loadJournalData();
@ -402,10 +402,10 @@ void LabEngine::doJournal() {
fade(false, 0); fade(false, 0);
_event->mouseHide(); _event->mouseHide();
ScreenImage._imageData = getCurrentDrawingBuffer(); ScreenImage._imageData = _graphics->getCurrentDrawingBuffer();
_graphics->setAPen(0); _graphics->setAPen(0);
_graphics->rectFill(0, 0, _screenWidth - 1, _screenHeight - 1); _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1);
_graphics->blackScreen(); _graphics->blackScreen();
} }
@ -476,13 +476,13 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16
MonGadHeight = fheight; MonGadHeight = fheight;
_graphics->setAPen(0); _graphics->setAPen(0);
_graphics->rectFill(0, 0, _screenWidth - 1, y2); _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, y2);
for (uint16 i = 0; i < numlines; i++) for (uint16 i = 0; i < numlines; i++)
MonButton->drawImage(0, i * MonGadHeight); MonButton->drawImage(0, i * MonGadHeight);
} else if (isinteractive) { } else if (isinteractive) {
_graphics->setAPen(0); _graphics->setAPen(0);
_graphics->rectFill(0, 0, _screenWidth - 1, y2); _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, y2);
} else { } else {
_graphics->setAPen(0); _graphics->setAPen(0);
_graphics->rectFill(x1, y1, x2, y2); _graphics->rectFill(x1, y1, x2, y2);
@ -644,7 +644,7 @@ void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive,
closeFont(monitorFont); closeFont(monitorFont);
_graphics->setAPen(0); _graphics->setAPen(0);
_graphics->rectFill(0, 0, _screenWidth - 1, _screenHeight - 1); _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1);
_graphics->blackAllScreen(); _graphics->blackAllScreen();
_graphics->freePict(); _graphics->freePict();
} }

View file

@ -78,10 +78,10 @@ void text(TextFont *tf, uint16 x, uint16 y, uint16 color, const char *text, uint
int32 templeft, LeftInSegment; int32 templeft, LeftInSegment;
uint16 bwidth, mask, curpage, data; uint16 bwidth, mask, curpage, data;
VGATop = g_lab->getCurrentDrawingBuffer(); VGATop = g_lab->_graphics->getCurrentDrawingBuffer();
for (uint16 i = 0; i < numchars; i++) { for (uint16 i = 0; i < numchars; i++) {
RealOffset = (g_lab->_screenWidth * y) + x; RealOffset = (g_lab->_graphics->_screenWidth * y) + x;
curpage = RealOffset / g_lab->_graphics->_screenBytesPerPage; curpage = RealOffset / g_lab->_graphics->_screenBytesPerPage;
SegmentOffset = RealOffset - (curpage * g_lab->_graphics->_screenBytesPerPage); SegmentOffset = RealOffset - (curpage * g_lab->_graphics->_screenBytesPerPage);
LeftInSegment = g_lab->_graphics->_screenBytesPerPage - SegmentOffset; LeftInSegment = g_lab->_graphics->_screenBytesPerPage - SegmentOffset;
@ -137,8 +137,8 @@ void text(TextFont *tf, uint16 x, uint16 y, uint16 color, const char *text, uint
} }
} }
VGATempLine += g_lab->_screenWidth; VGATempLine += g_lab->_graphics->_screenWidth;
LeftInSegment -= g_lab->_screenWidth; LeftInSegment -= g_lab->_graphics->_screenWidth;
if (LeftInSegment <= 0) { if (LeftInSegment <= 0) {
curpage++; curpage++;

View file

@ -259,7 +259,7 @@ void LabEngine::showTile(const char *filename, bool showsolution) {
delete tileFile; delete tileFile;
doTile(showsolution); doTile(showsolution);
setPalette(_anim->_diffPalette, 256); _graphics->setPalette(_anim->_diffPalette, 256);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -319,9 +319,9 @@ void LabEngine::changeCombination(uint16 number) {
combnum = combination[number]; combnum = combination[number];
display._imageData = getCurrentDrawingBuffer(); display._imageData = _graphics->getCurrentDrawingBuffer();
display._width = _screenWidth; display._width = _graphics->_screenWidth;
display._height = _screenHeight; display._height = _graphics->_screenHeight;
for (uint16 i = 1; i <= (Images[combnum]->_height / 2); i++) { for (uint16 i = 1; i <= (Images[combnum]->_height / 2); i++) {
if (_isHiRes) { if (_isHiRes) {
@ -330,10 +330,8 @@ void LabEngine::changeCombination(uint16 number) {
} else } else
waitTOF(); waitTOF();
display._imageData = getCurrentDrawingBuffer(); display._imageData = _graphics->getCurrentDrawingBuffer();
_graphics->scrollDisplayY(2, _graphics->VGAScaleX(COMBINATION_X[number]), _graphics->VGAScaleY(65), _graphics->VGAScaleX(COMBINATION_X[number]) + (Images[combnum])->_width - 1, _graphics->VGAScaleY(65) + (Images[combnum])->_height);
scrollDisplayY(2, _graphics->VGAScaleX(COMBINATION_X[number]), _graphics->VGAScaleY(65), _graphics->VGAScaleX(COMBINATION_X[number]) + (Images[combnum])->_width - 1, _graphics->VGAScaleY(65) + (Images[combnum])->_height);
Images[combnum]->blitBitmap(0, (Images[combnum])->_height - (2 * i), &(display), _graphics->VGAScaleX(COMBINATION_X[number]), _graphics->VGAScaleY(65), (Images[combnum])->_width, 2, false); Images[combnum]->blitBitmap(0, (Images[combnum])->_height - (2 * i), &(display), _graphics->VGAScaleX(COMBINATION_X[number]), _graphics->VGAScaleY(65), (Images[combnum])->_width, 2, false);
} }
@ -348,10 +346,10 @@ void LabEngine::changeCombination(uint16 number) {
void LabEngine::scrollRaster(int16 dx, int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2) { void LabEngine::scrollRaster(int16 dx, int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
if (dx) if (dx)
scrollDisplayX(dx, x1, y1, x2, y2); _graphics->scrollDisplayX(dx, x1, y1, x2, y2);
if (dy) if (dy)
scrollDisplayY(dy, x1, y1, x2, y2); _graphics->scrollDisplayY(dy, x1, y1, x2, y2);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -382,7 +380,7 @@ void LabEngine::showCombination(const char *filename) {
doCombination(); doCombination();
setPalette(_anim->_diffPalette, 256); _graphics->setPalette(_anim->_diffPalette, 256);
} }
} // End of namespace Lab } // End of namespace Lab

View file

@ -45,7 +45,7 @@ void LabEngine::changeVolume(int delta) {
void LabEngine::waitTOF() { void LabEngine::waitTOF() {
g_system->copyRectToScreen(_displayBuffer, _screenWidth, 0, 0, _screenWidth, _screenHeight); g_system->copyRectToScreen(_graphics->_displayBuffer, _graphics->_screenWidth, 0, 0, _graphics->_screenWidth, _graphics->_screenHeight);
g_system->updateScreen(); g_system->updateScreen();
_event->processInput(); _event->processInput();
@ -58,143 +58,4 @@ void LabEngine::waitTOF() {
_lastWaitTOFTicks = now; _lastWaitTOFTicks = now;
} }
/*****************************************************************************/
/* Writes any number of the 256 color registers. */
/* first: the number of the first color register to write. */
/* numreg: the number of registers to write */
/* buf: a char pointer which contains the selected color registers. */
/* Each value representing a color register occupies 3 bytes in */
/* the array. The order is red, green then blue. The first byte */
/* in the array is the red component of the first element selected.*/
/* The length of the buffer is 3 times the number of registers */
/* selected. */
/*****************************************************************************/
void LabEngine::writeColorRegs(byte *buf, uint16 first, uint16 numreg) {
byte tmp[256 * 3];
for (int i = 0; i < 256 * 3; i++) {
tmp[i] = buf[i] * 4;
}
g_system->getPaletteManager()->setPalette(tmp, first, numreg);
memcpy(&(_curvgapal[first * 3]), buf, numreg * 3);
}
void LabEngine::setPalette(void *cmap, uint16 numcolors) {
if (memcmp(cmap, _curvgapal, numcolors * 3) != 0)
writeColorRegs((byte *)cmap, 0, numcolors);
}
/*****************************************************************************/
/* Returns the base address of the current VGA display. */
/*****************************************************************************/
byte *LabEngine::getCurrentDrawingBuffer() {
if (_currentDisplayBuffer)
return _currentDisplayBuffer;
return _displayBuffer;
}
/*****************************************************************************/
/* Scrolls the display in the x direction by blitting. */
/* The _tempScrollData variable must be initialized to some memory, or this */
/* function will fail. */
/*****************************************************************************/
void LabEngine::scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
Image im;
uint16 temp;
im._imageData = _tempScrollData;
if (x1 > x2) {
temp = x2;
x2 = x1;
x1 = temp;
}
if (y1 > y2) {
temp = y2;
y2 = y1;
y1 = temp;
}
im._width = x2 - x1 + 1 - dx;
im._height = y2 - y1 + 1;
im.readScreenImage(x1, y1);
im.drawImage(x1 + dx, y1);
_graphics->setAPen(0);
_graphics->rectFill(x1, y1, x1 + dx - 1, y2);
}
/*****************************************************************************/
/* Scrolls the display in the y direction by blitting. */
/*****************************************************************************/
void LabEngine::scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
Image im;
uint16 temp;
im._imageData = _tempScrollData;
if (x1 > x2) {
temp = x2;
x2 = x1;
x1 = temp;
}
if (y1 > y2) {
temp = y2;
y2 = y1;
y1 = temp;
}
im._width = x2 - x1 + 1;
im._height = y2 - y1 + 1 - dy;
im.readScreenImage(x1, y1);
im.drawImage(x1, y1 + dy);
_graphics->setAPen(0);
_graphics->rectFill(x1, y1, x2, y1 + dy - 1);
}
/*****************************************************************************/
/* Overlays a region on the screen using the desired pen color. */
/*****************************************************************************/
void LabEngine::overlayRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
int w = x2 - x1 + 1;
int h = y2 - y1 + 1;
if (x1 + w > _screenWidth)
w = _screenWidth - x1;
if (y1 + h > _screenHeight)
h = _screenHeight - y1;
if ((w > 0) && (h > 0)) {
char *d = (char *)getCurrentDrawingBuffer() + y1 * _screenWidth + x1;
while (h-- > 0) {
char *dd = d;
int ww = w;
if (y1 & 1) {
dd++;
ww--;
}
while (ww > 0) {
*dd = pencolor;
dd += 2;
ww -= 2;
}
d += _screenWidth;
y1++;
}
}
}
} // End of namespace Lab } // End of namespace Lab