scummvm/engines/lab/graphics.cpp

725 lines
21 KiB
C++
Raw Normal View History

2014-10-06 14:50:05 +02:00
/* 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.
*
*/
2014-12-27 14:18:40 +01:00
#include "lab/lab.h"
2015-12-01 20:10:42 +01:00
#include "lab/anim.h"
2014-10-06 14:50:05 +02:00
#include "lab/parsetypes.h"
#include "lab/image.h"
2014-10-06 14:50:05 +02:00
#include "lab/labfun.h"
#include "lab/parsefun.h"
#include "lab/mouse.h"
#include "lab/text.h"
#include "lab/resource.h"
2014-10-06 14:50:05 +02:00
namespace Lab {
2014-12-26 00:32:42 +01:00
BitMap bit1, bit2, *DispBitMap = &bit1, *DrawBitMap = &bit1;
2014-10-06 14:50:05 +02:00
2015-12-01 20:10:42 +01:00
extern bool stopsound;
2014-12-26 00:32:42 +01:00
extern TextFont *MsgFont;
2014-10-06 14:50:05 +02:00
/*---------------------------------------------------------------------------*/
/*------ From readPict.c. Reads in pictures and animations from disk. ------*/
/*---------------------------------------------------------------------------*/
/*****************************************************************************/
/* Reads in a picture into the dest bitmap. */
/*****************************************************************************/
2015-12-01 10:35:31 +01:00
bool readPict(const char *filename, bool playOnce) {
2015-12-01 20:10:42 +01:00
g_lab->_anim->stopDiff();
2014-10-06 14:50:05 +02:00
2015-12-01 11:18:11 +01:00
byte **file = g_lab->_music->newOpen(filename);
2014-10-06 14:50:05 +02:00
if (file == NULL) {
if ((filename[0] == 'p') || (filename[0] == 'P'))
blackScreen();
return false;
}
DispBitMap->_bytesPerRow = g_lab->_screenWidth;
DispBitMap->_rows = g_lab->_screenHeight;
DispBitMap->_flags = BITMAPF_VIDEO;
2014-10-06 14:50:05 +02:00
2015-12-01 20:10:42 +01:00
g_lab->_anim->readDiff(playOnce);
2014-10-06 14:50:05 +02:00
return true;
}
/*****************************************************************************/
/* Reads in a music file. Ignores any graphics. */
/*****************************************************************************/
bool readMusic(const char *filename, bool waitTillFinished) {
Common::File *file = g_lab->_resource->openDataFile(filename, MKTAG('D', 'I', 'F', 'F'));
g_lab->_music->updateMusic();
if (!g_lab->_music->_doNotFilestopSoundEffect)
g_lab->_music->stopSoundEffect();
if (!file)
2014-10-06 14:50:05 +02:00
return false;
2015-12-02 00:34:51 +01:00
g_lab->_anim->_doBlack = false;
2015-12-01 20:10:42 +01:00
g_lab->_anim->readSound(waitTillFinished, file);
2014-10-06 14:50:05 +02:00
return true;
}
/*****************************************************************************/
/* Reads in a picture into buffer memory. */
/*****************************************************************************/
byte *readPictToMem(const char *filename, uint16 x, uint16 y) {
2015-12-01 11:18:11 +01:00
byte *mem;
2014-10-06 14:50:05 +02:00
2015-12-01 20:10:42 +01:00
g_lab->_anim->stopDiff();
2014-10-06 14:50:05 +02:00
2015-12-01 11:18:11 +01:00
allocFile((void **)&mem, (int32)x * (int32)y, "Bitmap");
byte *curMem = mem;
2014-10-06 14:50:05 +02:00
2015-12-01 11:18:11 +01:00
byte **file = g_lab->_music->newOpen(filename);
2014-10-06 14:50:05 +02:00
if (file == NULL)
return NULL;
DispBitMap->_bytesPerRow = x;
DispBitMap->_rows = y;
DispBitMap->_flags = BITMAPF_NONE;
DispBitMap->_planes[0] = curMem;
DispBitMap->_planes[1] = DispBitMap->_planes[0] + 0x10000;
DispBitMap->_planes[2] = DispBitMap->_planes[1] + 0x10000;
DispBitMap->_planes[3] = DispBitMap->_planes[2] + 0x10000;
DispBitMap->_planes[4] = DispBitMap->_planes[3] + 0x10000;
2014-10-06 14:50:05 +02:00
2015-12-01 20:10:42 +01:00
g_lab->_anim->readDiff(true);
2014-10-06 14:50:05 +02:00
2015-12-01 11:18:11 +01:00
return mem;
2014-10-06 14:50:05 +02:00
}
/*---------------------------------------------------------------------------*/
/*------------ Does all the text rendering to the message boxes. ------------*/
/*---------------------------------------------------------------------------*/
bool DoNotDrawMessage = false;
extern bool LongWinInFront, Alternate;
/*----- The flowText routines -----*/
/******************************************************************************/
/* Extracts the first word from a string. */
/******************************************************************************/
2015-12-01 10:35:31 +01:00
static void getWord(char *wordBuffer, const char *mainBuffer, uint16 *wordWidth) {
2014-10-06 14:50:05 +02:00
uint16 width = 0;
2015-12-01 10:35:31 +01:00
while ((mainBuffer[width] != ' ') && mainBuffer[width] &&
(mainBuffer[width] != '\n')) {
wordBuffer[width] = mainBuffer[width];
2014-10-06 14:50:05 +02:00
width++;
}
2015-12-01 10:35:31 +01:00
wordBuffer[width] = 0;
2014-10-06 14:50:05 +02:00
2015-12-01 10:35:31 +01:00
*wordWidth = width;
2014-10-06 14:50:05 +02:00
}
/******************************************************************************/
/* Gets a line of text for flowText; makes sure that its length is less than */
/* or equal to the maximum width. */
/******************************************************************************/
2015-12-01 10:35:31 +01:00
static void getLine(TextFont *tf, char *lineBuffer, const char **mainBuffer, uint16 lineWidth) {
uint16 curWidth = 0, wordWidth;
char wordBuffer[100];
2014-10-06 14:50:05 +02:00
bool doit = true;
2015-12-01 10:35:31 +01:00
lineWidth += textLength(tf, " ", 1);
2014-10-06 14:50:05 +02:00
2015-12-01 10:35:31 +01:00
lineBuffer[0] = 0;
2014-10-06 14:50:05 +02:00
2015-12-01 10:35:31 +01:00
while ((*mainBuffer)[0] && doit) {
getWord(wordBuffer, *mainBuffer, &wordWidth);
strcat(wordBuffer, " ");
2014-10-06 14:50:05 +02:00
2015-12-01 10:35:31 +01:00
if ((curWidth + textLength(tf, wordBuffer, wordWidth + 1)) <= lineWidth) {
strcat(lineBuffer, wordBuffer);
(*mainBuffer) += wordWidth;
2014-10-06 14:50:05 +02:00
2015-12-01 10:35:31 +01:00
if ((*mainBuffer)[0] == '\n')
2014-10-06 14:50:05 +02:00
doit = false;
2015-12-01 10:35:31 +01:00
if ((*mainBuffer)[0])
(*mainBuffer)++;
2014-10-06 14:50:05 +02:00
2015-12-01 10:35:31 +01:00
curWidth = textLength(tf, lineBuffer, strlen(lineBuffer));
2014-10-06 14:50:05 +02:00
} else
doit = false;
}
}
/******************************************************************************/
/* Dumps a chunk of text to an arbitrary box; flows it within that box and */
/* optionally centers it. Returns the number of characters that were */
/* processed. */
/* */
/* Note: Every individual word MUST be int16 enough to fit on a line, and */
/* each line less than 255 characters. */
/******************************************************************************/
uint32 flowText(void *font, /* the TextAttr pointer */
int16 spacing, /* How much vertical spacing between the lines */
byte pencolor, /* pen number to use for text */
byte backpen, /* the background color */
2014-10-06 14:50:05 +02:00
bool fillback, /* Whether to fill the background */
bool centerh, /* Whether to center the text horizontally */
bool centerv, /* Whether to center the text vertically */
bool output, /* Whether to output any text */
uint16 x1, /* Cords */
uint16 y1, uint16 x2, uint16 y2, const char *str) { /* The text itself */
2014-12-26 00:32:42 +01:00
TextFont *msgfont = (TextFont *)font;
2014-10-06 14:50:05 +02:00
char linebuffer[256];
const char *temp;
uint16 numlines, actlines, fontheight, width;
uint16 x, y;
if (fillback) {
2015-11-24 23:59:30 +01:00
g_lab->setAPen(backpen);
g_lab->rectFill(x1, y1, x2, y2);
2014-10-06 14:50:05 +02:00
}
if (str == NULL)
return 0L;
2015-11-24 23:59:30 +01:00
g_lab->setAPen(pencolor);
2014-10-06 14:50:05 +02:00
fontheight = textHeight(msgfont) + spacing;
numlines = (y2 - y1 + 1) / fontheight;
width = x2 - x1 + 1;
y = y1;
if (centerv && output) {
temp = str;
actlines = 0;
while (temp[0]) {
getLine(msgfont, linebuffer, &temp, width);
actlines++;
}
if (actlines <= numlines)
y += ((y2 - y1 + 1) - (actlines * fontheight)) / 2;
}
temp = str;
while (numlines && str[0]) {
getLine(msgfont, linebuffer, &str, width);
x = x1;
if (centerh)
x += (width - textLength(msgfont, linebuffer, strlen(linebuffer))) / 2;
if (output)
text(msgfont, x, y, pencolor, linebuffer, strlen(linebuffer));
numlines--;
y += fontheight;
}
return (str - temp);
}
/******************************************************************************/
/* Calls flowText, but flows it to memory. Same restrictions as flowText. */
/******************************************************************************/
2015-12-01 10:35:31 +01:00
uint32 flowTextToMem(Image *destIm, void *font, /* the TextAttr pointer */
int16 spacing, /* How much vertical spacing between the lines */
byte pencolor, /* pen number to use for text */
byte backpen, /* the background color */
2014-10-06 14:50:05 +02:00
bool fillback, /* Whether to fill the background */
bool centerh, /* Whether to center the text horizontally */
bool centerv, /* Whether to center the text vertically */
bool output, /* Whether to output any text */
uint16 x1, /* Cords */
uint16 y1, uint16 x2, uint16 y2, const char *str) { /* The text itself */
2015-11-23 17:34:02 +01:00
uint32 res, vgabyte = g_lab->_screenBytesPerPage;
2015-12-01 10:35:31 +01:00
byte *tmp = g_lab->_currentDisplayBuffer;
2014-10-06 14:50:05 +02:00
2015-12-02 11:49:01 +01:00
g_lab->_currentDisplayBuffer = destIm->_imageData;
g_lab->_screenBytesPerPage = (uint32)destIm->_width * (int32)destIm->_height;
2014-10-06 14:50:05 +02:00
res = flowText(font, spacing, pencolor, backpen, fillback, centerh, centerv, output, x1, y1, x2, y2, str);
2015-11-23 17:34:02 +01:00
g_lab->_screenBytesPerPage = vgabyte;
2015-12-01 10:35:31 +01:00
g_lab->_currentDisplayBuffer = tmp;
2014-10-06 14:50:05 +02:00
return res;
}
/*----- The control panel stuff -----*/
void createBox(uint16 y2) {
2015-11-24 23:59:30 +01:00
g_lab->setAPen(7); /* Message box area */
g_lab->rectFill(VGAScaleX(4), VGAScaleY(154), VGAScaleX(315), VGAScaleY(y2 - 2));
g_lab->setAPen(0); /* Box around message area */
g_lab->drawHLine(VGAScaleX(2), VGAScaleY(152), VGAScaleX(317));
g_lab->drawVLine(VGAScaleX(317), VGAScaleY(152), VGAScaleY(y2));
g_lab->drawHLine(VGAScaleX(2), VGAScaleY(y2), VGAScaleX(317));
g_lab->drawVLine(VGAScaleX(2), VGAScaleY(152), VGAScaleY(y2));
2014-10-06 14:50:05 +02:00
}
int32 LabEngine::longDrawMessage(const char *str) {
2015-12-01 10:35:31 +01:00
char newText[512];
2014-10-06 14:50:05 +02:00
if (str == NULL)
return 0;
2014-10-06 14:50:05 +02:00
_event->attachGadgetList(NULL);
_event->mouseHide();
2015-12-01 10:35:31 +01:00
strcpy(newText, str);
2014-10-06 14:50:05 +02:00
if (!LongWinInFront) {
LongWinInFront = true;
2015-12-01 11:18:11 +01:00
setAPen(3); /* Clear Area */
rectFill(0, VGAScaleY(149) + SVGACord(2), VGAScaleX(319), VGAScaleY(199));
2014-10-06 14:50:05 +02:00
}
createBox(198);
_event->mouseShow();
return flowText(MsgFont, 0, 1, 7, false, true, true, true, VGAScaleX(6), VGAScaleY(155), VGAScaleX(313), VGAScaleY(195), str);
2014-10-06 14:50:05 +02:00
}
void LabEngine::drawStaticMessage(byte index) {
drawMessage(_resource->getStaticText((StaticText)index).c_str());
}
2014-10-06 14:50:05 +02:00
/******************************************************************************/
/* Draws a message to the message box. */
/******************************************************************************/
void LabEngine::drawMessage(const char *str) {
2014-10-06 14:50:05 +02:00
if (DoNotDrawMessage) {
DoNotDrawMessage = false;
return;
}
if (str) {
if ((textLength(MsgFont, str, strlen(str)) > VGAScaleX(306))) {
longDrawMessage(str);
2015-12-01 10:35:31 +01:00
_lastMessageLong = true;
2014-10-06 14:50:05 +02:00
} else {
if (LongWinInFront) {
LongWinInFront = false;
2015-12-01 11:18:11 +01:00
drawPanel();
2014-10-06 14:50:05 +02:00
}
_event->mouseHide();
2014-10-06 14:50:05 +02:00
createBox(168);
text(MsgFont, VGAScaleX(7), VGAScaleY(155) + SVGACord(2), 1, str, strlen(str));
_event->mouseShow();
2015-12-01 10:35:31 +01:00
_lastMessageLong = false;
2014-10-06 14:50:05 +02:00
}
}
}
/*---------------------------------------------------------------------------*/
/*--------------------------- All the wipe stuff. ---------------------------*/
/*---------------------------------------------------------------------------*/
#define TRANSWIPE 1
#define SCROLLWIPE 2
#define SCROLLBLACK 3
#define SCROLLBOUNCE 4
#define TRANSPORTER 5
#define READFIRSTFRAME 6
#define READNEXTFRAME 7
/*****************************************************************************/
/* Scrolls the display to black. */
/*****************************************************************************/
void LabEngine::doScrollBlack() {
2014-10-06 14:50:05 +02:00
byte *mem, *tempmem;
2015-12-01 10:35:31 +01:00
Image im;
2014-10-06 14:50:05 +02:00
uint32 size, copysize;
2015-12-01 10:35:31 +01:00
uint32 *baseAddr;
2014-10-06 14:50:05 +02:00
_event->mouseHide();
2015-12-01 11:18:11 +01:00
uint16 width = VGAScaleX(320);
uint16 height = VGAScaleY(149) + SVGACord(2);
2014-10-06 14:50:05 +02:00
2015-12-01 10:35:31 +01:00
allocFile((void **)&mem, (int32)width * (int32)height, "Temp Mem");
2014-12-27 01:28:50 +01:00
2015-12-02 11:49:01 +01:00
im._width = width;
im._height = height;
im._imageData = mem;
_music->updateMusic();
im.readScreenImage(0, 0);
_music->updateMusic();
2014-10-06 14:50:05 +02:00
2015-12-01 11:18:11 +01:00
baseAddr = (uint32 *)getCurrentDrawingBuffer();
2014-10-06 14:50:05 +02:00
2015-12-01 11:18:11 +01:00
uint16 by = VGAScaleX(4);
uint16 nheight = height;
2014-10-06 14:50:05 +02:00
while (nheight) {
_music->updateMusic();
2014-10-06 14:50:05 +02:00
2015-11-30 00:12:01 +01:00
if (!_isHiRes)
2015-12-01 11:18:11 +01:00
waitTOF();
2014-10-06 14:50:05 +02:00
2015-12-01 11:18:11 +01:00
baseAddr = (uint32 *)getCurrentDrawingBuffer();
2014-10-06 14:50:05 +02:00
if (by > nheight)
by = nheight;
mem += by * width;
nheight -= by;
2015-12-01 10:35:31 +01:00
size = (int32)nheight * (int32)width;
2014-10-06 14:50:05 +02:00
tempmem = mem;
while (size) {
2015-12-01 11:18:11 +01:00
if (size > _screenBytesPerPage)
copysize = _screenBytesPerPage;
2014-10-06 14:50:05 +02:00
else
copysize = size;
size -= copysize;
2015-12-01 10:35:31 +01:00
memcpy(baseAddr, tempmem, copysize);
2014-10-06 14:50:05 +02:00
tempmem += copysize;
}
2015-12-01 11:18:11 +01:00
setAPen(0);
rectFill(0, nheight, width - 1, nheight + by - 1);
2014-10-06 14:50:05 +02:00
2015-12-01 11:18:11 +01:00
screenUpdate();
2014-10-06 14:50:05 +02:00
2015-11-30 00:12:01 +01:00
if (!_isHiRes) {
2014-10-06 14:50:05 +02:00
if (nheight <= (height / 8))
by = 1;
else if (nheight <= (height / 4))
by = 2;
else if (nheight <= (height / 2))
by = 3;
}
}
freeAllStolenMem();
_event->mouseShow();
2014-10-06 14:50:05 +02:00
}
static void copyPage(uint16 width, uint16 height, uint16 nheight, uint16 startline, byte *mem) {
2015-12-01 10:35:31 +01:00
uint32 size, offSet, copysize;
uint16 curPage;
uint32 *baseAddr;
2014-10-06 14:50:05 +02:00
2015-12-01 10:35:31 +01:00
baseAddr = (uint32 *)g_lab->getCurrentDrawingBuffer();
2014-10-06 14:50:05 +02:00
2015-12-01 10:35:31 +01:00
size = (int32)(height - nheight) * (int32)width;
2014-10-06 14:50:05 +02:00
mem += startline * width;
2015-12-01 10:35:31 +01:00
curPage = ((int32)nheight * (int32)width) / g_lab->_screenBytesPerPage;
offSet = ((int32)nheight * (int32)width) - (curPage * g_lab->_screenBytesPerPage);
2014-10-06 14:50:05 +02:00
while (size) {
2015-12-01 10:35:31 +01:00
if (size > (g_lab->_screenBytesPerPage - offSet))
copysize = g_lab->_screenBytesPerPage - offSet;
2014-10-06 14:50:05 +02:00
else
copysize = size;
size -= copysize;
2015-12-01 10:35:31 +01:00
memcpy(baseAddr + (offSet >> 2), mem, copysize);
2014-10-06 14:50:05 +02:00
mem += copysize;
2015-12-01 10:35:31 +01:00
curPage++;
offSet = 0;
2014-10-06 14:50:05 +02:00
}
}
/*****************************************************************************/
/* Scrolls the display to a new picture from a black screen. */
/*****************************************************************************/
void LabEngine::doScrollWipe(char *filename) {
2015-12-01 11:18:11 +01:00
uint16 startline = 0, onrow = 0;
2014-10-06 14:50:05 +02:00
_event->mouseHide();
2015-12-01 11:18:11 +01:00
uint16 width = VGAScaleX(320);
uint16 height = VGAScaleY(149) + SVGACord(2);
2014-10-06 14:50:05 +02:00
while (_music->isSoundEffectActive()) {
_music->updateMusic();
2015-12-01 11:18:11 +01:00
waitTOF();
2014-10-06 14:50:05 +02:00
}
2015-12-02 00:34:51 +01:00
_anim->_isBM = true;
2014-10-06 14:50:05 +02:00
readPict(filename, true);
2015-12-02 00:34:51 +01:00
setPalette(_anim->_diffPalette, 256);
_anim->_isBM = false;
byte *mem = _anim->_rawDiffBM._planes[0];
2014-10-06 14:50:05 +02:00
_music->updateMusic();
2015-12-01 11:18:11 +01:00
uint16 by = VGAScaleX(3);
uint16 nheight = height;
2014-10-06 14:50:05 +02:00
2015-12-02 00:34:51 +01:00
while (onrow < _anim->_headerdata._height) {
_music->updateMusic();
2014-10-06 14:50:05 +02:00
if ((by > nheight) && nheight)
by = nheight;
2015-12-02 00:34:51 +01:00
if ((startline + by) > (_anim->_headerdata._height - height - 1))
2014-10-06 14:50:05 +02:00
break;
if (nheight)
nheight -= by;
copyPage(width, height, nheight, startline, mem);
2015-12-01 11:18:11 +01:00
screenUpdate();
2014-10-06 14:50:05 +02:00
if (!nheight)
startline += by;
onrow += by;
if (nheight <= (height / 4))
by = VGAScaleX(5);
else if (nheight <= (height / 3))
by = VGAScaleX(4);
else if (nheight <= (height / 2))
by = VGAScaleX(3);
}
_event->mouseShow();
2014-10-06 14:50:05 +02:00
}
/*****************************************************************************/
/* Does the scroll bounce. Assumes bitmap already in memory. */
/*****************************************************************************/
void LabEngine::doScrollBounce() {
2014-12-27 14:18:40 +01:00
const uint16 *newby, *newby1;
const uint16 newbyd[5] = {5, 4, 3, 2, 1}, newby1d[8] = {3, 3, 2, 2, 2, 1, 1, 1};
const uint16 newbyw[5] = {10, 8, 6, 4, 2}, newby1w[8] = {6, 6, 4, 4, 4, 2, 2, 2};
2015-12-01 11:18:11 +01:00
if (getPlatform() != Common::kPlatformWindows) {
2014-12-27 14:18:40 +01:00
newby = newbyd;
newby1 = newby1d;
} else {
newby = newbyw;
newby1 = newby1w;
}
_event->mouseHide();
2014-12-27 14:18:40 +01:00
int width = VGAScaleX(320);
int height = VGAScaleY(149) + SVGACord(2);
2015-12-02 00:34:51 +01:00
byte *mem = _anim->_rawDiffBM._planes[0];
2014-10-06 14:50:05 +02:00
_music->updateMusic();
2015-12-02 00:34:51 +01:00
int startline = _anim->_headerdata._height - height - 1;
2014-10-06 14:50:05 +02:00
for (int i = 0; i < 5; i++) {
_music->updateMusic();
startline -= newby[i];
2014-10-06 14:50:05 +02:00
copyPage(width, height, 0, startline, mem);
2015-12-01 11:18:11 +01:00
screenUpdate();
waitTOF();
2014-10-06 14:50:05 +02:00
}
for (int i = 8; i > 0; i--) {
_music->updateMusic();
startline += newby1[i - 1];
2014-10-06 14:50:05 +02:00
copyPage(width, height, 0, startline, mem);
2015-12-01 11:18:11 +01:00
screenUpdate();
waitTOF();
2014-10-06 14:50:05 +02:00
}
_event->mouseShow();
2014-10-06 14:50:05 +02:00
}
/*****************************************************************************/
/* Does the transporter wipe. */
/*****************************************************************************/
2015-12-01 10:35:31 +01:00
void LabEngine::doTransWipe(CloseDataPtr *cPtr, char *filename) {
uint16 lastY, curY, linesdone = 0, lineslast;
Image imSource, imDest;
2014-10-06 14:50:05 +02:00
2015-11-30 00:12:01 +01:00
if (_isHiRes) {
2014-10-06 14:50:05 +02:00
lineslast = 3;
2015-12-01 10:35:31 +01:00
lastY = 358;
2014-10-06 14:50:05 +02:00
} else {
lineslast = 1;
2015-12-01 10:35:31 +01:00
lastY = 148;
2014-10-06 14:50:05 +02:00
}
for (uint16 i = 0; i < 2; i++) {
2015-12-01 10:35:31 +01:00
curY = i * 2;
2014-10-06 14:50:05 +02:00
2015-12-01 10:35:31 +01:00
while (curY < lastY) {
2014-10-06 14:50:05 +02:00
if (linesdone >= lineslast) {
_music->updateMusic();
2015-12-01 11:18:11 +01:00
waitTOF();
2014-10-06 14:50:05 +02:00
linesdone = 0;
}
2015-12-01 11:18:11 +01:00
ghoastRect(0, 0, curY, _screenWidth - 1, curY + 1);
2015-12-01 10:35:31 +01:00
curY += 4;
2014-10-06 14:50:05 +02:00
linesdone++;
}
}
2015-12-01 11:18:11 +01:00
setAPen(0);
2014-10-06 14:50:05 +02:00
for (uint16 i = 0; i < 2; i++) {
2015-12-01 10:35:31 +01:00
curY = i * 2;
2014-10-06 14:50:05 +02:00
2015-12-01 10:35:31 +01:00
while (curY <= lastY) {
2014-10-06 14:50:05 +02:00
if (linesdone >= lineslast) {
_music->updateMusic();
2015-12-01 11:18:11 +01:00
waitTOF();
2014-10-06 14:50:05 +02:00
linesdone = 0;
}
2015-12-01 11:18:11 +01:00
rectFill(0, curY, _screenWidth - 1, curY + 1);
2015-12-01 10:35:31 +01:00
curY += 4;
2014-10-06 14:50:05 +02:00
linesdone++;
}
}
if (filename == NULL)
g_lab->_curFileName = getPictName(cPtr);
2014-10-06 14:50:05 +02:00
else if (filename[0] > ' ')
g_lab->_curFileName = filename;
2014-10-06 14:50:05 +02:00
else
g_lab->_curFileName = getPictName(cPtr);
2014-10-06 14:50:05 +02:00
byte *BitMapMem = readPictToMem(g_lab->_curFileName, _screenWidth, lastY + 5);
2015-12-02 00:34:51 +01:00
setPalette(_anim->_diffPalette, 256);
2014-10-06 14:50:05 +02:00
if (BitMapMem) {
2015-12-02 11:49:01 +01:00
imSource._width = _screenWidth;
imSource._height = lastY;
imSource._imageData = BitMapMem;
2014-10-06 14:50:05 +02:00
2015-12-02 11:49:01 +01:00
imDest._width = _screenWidth;
imDest._height = _screenHeight;
imDest._imageData = getCurrentDrawingBuffer();
2014-10-06 14:50:05 +02:00
for (uint16 i = 0; i < 2; i++) {
2015-12-01 10:35:31 +01:00
curY = i * 2;
2014-10-06 14:50:05 +02:00
2015-12-01 10:35:31 +01:00
while (curY < lastY) {
2014-10-06 14:50:05 +02:00
if (linesdone >= lineslast) {
_music->updateMusic();
2015-12-01 11:18:11 +01:00
waitTOF();
2014-10-06 14:50:05 +02:00
linesdone = 0;
}
2015-12-02 11:49:01 +01:00
imDest._imageData = getCurrentDrawingBuffer();
2014-10-06 14:50:05 +02:00
2015-12-02 11:54:42 +01:00
imSource.bltBitMap(0, curY, &imDest, 0, curY, _screenWidth, 2);
2015-12-01 11:18:11 +01:00
ghoastRect(0, 0, curY, _screenWidth - 1, curY + 1);
2015-12-01 10:35:31 +01:00
curY += 4;
2014-10-06 14:50:05 +02:00
linesdone++;
}
}
for (uint16 i = 0; i < 2; i++) {
2015-12-01 10:35:31 +01:00
curY = i * 2;
2014-10-06 14:50:05 +02:00
2015-12-01 10:35:31 +01:00
while (curY <= lastY) {
2014-10-06 14:50:05 +02:00
if (linesdone >= lineslast) {
_music->updateMusic();
2015-12-01 11:18:11 +01:00
waitTOF();
2014-10-06 14:50:05 +02:00
linesdone = 0;
}
2015-12-02 11:49:01 +01:00
imDest._imageData = getCurrentDrawingBuffer();
2014-10-06 14:50:05 +02:00
2015-12-01 10:35:31 +01:00
if (curY == lastY)
2015-12-02 11:54:42 +01:00
imSource.bltBitMap(0, curY, &imDest, 0, curY, _screenWidth, 1);
2014-10-06 14:50:05 +02:00
else
2015-12-02 11:54:42 +01:00
imSource.bltBitMap(0, curY, &imDest, 0, curY, _screenWidth, 2);
2014-10-06 14:50:05 +02:00
2015-12-01 10:35:31 +01:00
curY += 4;
2014-10-06 14:50:05 +02:00
linesdone++;
}
}
}
}
/*****************************************************************************/
/* Does a certain number of pre-programmed wipes. */
/*****************************************************************************/
2015-12-01 10:35:31 +01:00
void LabEngine::doWipe(uint16 wipeType, CloseDataPtr *cPtr, char *filename) {
if ((wipeType == TRANSWIPE) || (wipeType == TRANSPORTER))
doTransWipe(cPtr, filename);
else if (wipeType == SCROLLWIPE)
2014-10-06 14:50:05 +02:00
doScrollWipe(filename);
2015-12-01 10:35:31 +01:00
else if (wipeType == SCROLLBLACK)
2014-10-06 14:50:05 +02:00
doScrollBlack();
2015-12-01 10:35:31 +01:00
else if (wipeType == SCROLLBOUNCE)
2014-10-06 14:50:05 +02:00
doScrollBounce();
2015-12-01 10:35:31 +01:00
else if (wipeType == READFIRSTFRAME)
2014-10-06 14:50:05 +02:00
readPict(filename, false);
2015-12-01 10:35:31 +01:00
else if (wipeType == READNEXTFRAME)
2015-12-01 20:10:42 +01:00
_anim->diffNextFrame();
}
static byte blackbuffer[256 * 3];
/*****************************************************************************/
/* Changes the front screen to black. */
/*****************************************************************************/
void blackScreen() {
memset(blackbuffer, 0, 248 * 3);
g_lab->writeColorRegs(blackbuffer, 8, 248);
g_system->delayMillis(32);
}
/*****************************************************************************/
/* Changes the front screen to white. */
/*****************************************************************************/
void whiteScreen() {
memset(blackbuffer, 255, 248 * 3);
g_lab->writeColorRegs(blackbuffer, 8, 248);
}
/*****************************************************************************/
/* Changes the entire screen to black. */
/*****************************************************************************/
void blackAllScreen() {
memset(blackbuffer, 0, 256 * 3);
g_lab->writeColorRegs(blackbuffer, 0, 256);
g_system->delayMillis(32);
2014-10-06 14:50:05 +02:00
}
} // End of namespace Lab