From 8ca14d1d642fce2617513fdc0c3223af2ab4e7e7 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Mon, 6 Oct 2014 14:50:05 +0200 Subject: LAB: Initial code --- engines/lab/special.cpp | 2219 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 2219 insertions(+) create mode 100644 engines/lab/special.cpp (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp new file mode 100644 index 0000000000..5542b05716 --- /dev/null +++ b/engines/lab/special.cpp @@ -0,0 +1,2219 @@ +/* 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/labfun.h" +#include "lab/parsefun.h" +#include "lab/interface.h" +#include "lab/diff.h" +#include "lab/vga.h" +#include "lab/text.h" +#include "lab/mouse.h" +#include "lab/timing.h" +#include "lab/stddefines.h" +#include "lab/parsetypes.h" + +#define MODERNGAMESAVE 1 + +#if defined(MODERNGAMESAVE) +#include "lab/modernsavegame.h" +#endif + +namespace Lab { + +#ifdef GAME_TRIAL +int g_IsRegistered; +#endif + +extern bool nopalchange, DoBlack, IsHiRes; + +extern struct BitMap *DispBitMap, *DrawBitMap; +extern char diffcmap[3 * 256]; + +extern uint32 VGAScreenWidth, VGAScreenHeight; + + +#define COMBINATIONUNLOCKED 130 +#define BRICKOPEN 115 + + +static uint16 hipal[20]; +extern uint16 *FadePalette; + + +static byte *loadBackPict(const char *fileName, bool tomem) { + uint16 counter; + byte *res = NULL; + + FadePalette = hipal; + nopalchange = true; + + if (tomem) + res = readPictToMem(fileName, VGAScreenWidth, VGAScreenHeight); + else + readPict(fileName, true); + + for (counter = 0; counter < 16; counter++) { + hipal[counter] = ((diffcmap[counter * 3] >> 2) << 8) + + ((diffcmap[counter * 3 + 1] >> 2) << 4) + + ((diffcmap[counter * 3 + 2] >> 2)); + } + + nopalchange = false; + + return res; +} + + + +/*----------------------------------------------------------------------------*/ +/*-------------------------- Combination Lock Rules --------------------------*/ +/*----------------------------------------------------------------------------*/ + + + + +static struct Image *Images[10]; + + +uint16 combination[6] = {0, 0, 0, 0, 0, 0}, solution[] = {0, 4, 0, 8, 7, 2}; + +static uint16 combx[] = {45, 83, 129, 166, 211, 248}; + + + +/*****************************************************************************/ +/* Draws the images of the combination lock to the display bitmap. */ +/*****************************************************************************/ +static void doCombination(void) { + uint16 counter; + + for (counter = 0; counter <= 5; counter++) + drawImage(Images[combination[counter]], VGAScaleX(combx[counter]), VGAScaleY(65)); +} + + +extern char *TempScrollData; + +/*****************************************************************************/ +/* Reads in a backdrop picture. */ +/*****************************************************************************/ +void showCombination(const char *filename) { + uint16 CurBit; + byte **buffer; + + resetBuffer(); + DoBlack = true; + nopalchange = true; + readPict(filename, true); + nopalchange = false; + + blackScreen(); + + buffer = g_music->newOpen("P:Numbers"); + + for (CurBit = 0; CurBit < 10; CurBit++) + readImage(buffer, &(Images[CurBit])); + + allocFile((void **)&TempScrollData, Images[0]->Width * Images[0]->Height * 2L, "tempdata"); + + doCombination(); + + VGASetPal(diffcmap, 256); +} + + + +/*****************************************************************************/ +/* Changes the combination number of one of the slots */ +/*****************************************************************************/ +static void changeCombination(LargeSet Conditions, uint16 number) { + struct Image display; + uint16 counter, combnum; + bool unlocked = true; + + if (combination[number] < 9) + (combination[number])++; + else + combination[number] = 0; + + combnum = combination[number]; + + display.ImageData = getVGABaseAddr(); + display.Width = VGAScreenWidth; + display.Height = VGAScreenHeight; + + /* NYI: + readPict("Music:Thunk", true); + */ + + for (counter = 1; counter <= (Images[combnum]->Height / 2); counter++) { + if (IsHiRes) { + if (counter & 1) + waitTOF(); + } else + waitTOF(); + +#if !defined(DOSCODE) + display.ImageData = getVGABaseAddr(); +#endif + + 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); + } + + /* + if (memcmp(combination, solution, (size_t) 12) == 0) + inclElement(Conditions, COMBINATIONUNLOCKED); + else + exclElement(Conditions, COMBINATIONUNLOCKED); + */ + + for (counter = 0; counter < 6; counter++) + unlocked = (combination[counter] == solution[counter]) && unlocked; + + if (unlocked) + inclElement(Conditions, COMBINATIONUNLOCKED); + else + exclElement(Conditions, COMBINATIONUNLOCKED); + +#if !defined(DOSCODE) + ungetVGABaseAddr(); +#endif +} + + + + + +/*****************************************************************************/ +/* Processes mouse clicks and changes the combination. */ +/*****************************************************************************/ +void mouseCombination(LargeSet Conditions, uint16 x, uint16 y) { + uint16 number; + + x = VGAUnScaleX(x); + y = VGAUnScaleY(y); + + if ((y >= 63) && (y <= 99)) { + if ((x >= 44) && (x < 83)) + number = 0; + else if (x < 127) + number = 1; + else if (x < 165) + number = 2; + else if (x < 210) + number = 3; + else if (x < 245) + number = 4; + else if (x < 286) + number = 5; + else + return; + + changeCombination(Conditions, number); + } +} + + + +/*----------------------------------------------------------------------------*/ +/*----------------------------- Tile Puzzle Rules ----------------------------*/ +/*----------------------------------------------------------------------------*/ + + + + +struct Image *Tiles[16]; +int16 CurTile[4] [4] = { + { 1, 5, 9, 13 }, + { 2, 6, 10, 14 }, + { 3, 7, 11, 15 }, + { 4, 8, 12, 0 } +}, TileSolution[4] [4] = { + { 7, 1, 8, 3 }, + { 2, 11, 15, 4 }, + { 9, 5, 14, 6 }, + { 10, 13, 12, 0} +}; + + +/*****************************************************************************/ +/* Draws the images of the combination lock to the display bitmap. */ +/*****************************************************************************/ +static void doTile(bool showsolution) { + uint16 row = 0, col = 0, rowm, colm, num; + int16 rows, cols; + + if (showsolution) { + rowm = VGAScaleY(23); + colm = VGAScaleX(27); + + rows = VGAScaleY(31); + cols = VGAScaleX(105); + } else { + setAPen(0); + rectFill(VGAScaleX(97), VGAScaleY(22), VGAScaleX(220), VGAScaleY(126)); + + rowm = VGAScaleY(25); + colm = VGAScaleX(30); + + rows = VGAScaleY(25); + cols = VGAScaleX(100); + } + + while (row < 4) { + while (col < 4) { + if (showsolution) + num = TileSolution[col] [row]; + else + num = CurTile[col] [row]; + + if (showsolution || num) + drawImage(Tiles[num], cols + (col * colm), rows + (row * rowm)); + + col++; + } + + row++; + col = 0; + } +} + + + + +/*****************************************************************************/ +/* Reads in a backdrop picture. */ +/*****************************************************************************/ +void showTile(const char *filename, bool showsolution) { + uint16 CurBit, start; + byte **buffer; + + resetBuffer(); + DoBlack = true; + nopalchange = true; + readPict(filename, true); + nopalchange = false; + blackScreen(); + + if (showsolution) { + start = 0; + buffer = g_music->newOpen("P:TileSolution"); + } else { + start = 1; + buffer = g_music->newOpen("P:Tile"); + } + + if (!buffer) + return; + + for (CurBit = start; CurBit < 16; CurBit++) + readImage(buffer, &(Tiles[CurBit])); + + allocFile((void **)&TempScrollData, Tiles[1]->Width * Tiles[1]->Height * 2L, "tempdata"); + + doTile(showsolution); + + VGASetPal(diffcmap, 256); +} + + + +#define LEFTSCROLL 1 +#define RIGHTSCROLL 2 +#define UPSCROLL 3 +#define DOWNSCROLL 4 + + + + +static void scrollRaster(int16 dx, int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2) { + if (dx) + scrollDisplayX(dx, x1, y1, x2, y2); + + if (dy) + scrollDisplayY(dy, x1, y1, x2, y2); +} + + + + +/*****************************************************************************/ +/* Does the scrolling for the tiles on the tile puzzle. */ +/*****************************************************************************/ +static void doTileScroll(uint16 col, uint16 row, uint16 scrolltype) { + int16 dX = 0, dY = 0, dx = 0, dy = 0, sx = 0, sy = 0; + uint16 last = 0, x1, y1; + uint16 counter; + + if (scrolltype == LEFTSCROLL) { + dX = VGAScaleXs(5); + sx = VGAScaleXs(5); + last = 6; + } else if (scrolltype == RIGHTSCROLL) { + dX = VGAScaleXs(-5); + dx = VGAScaleXs(-5); + sx = VGAScaleX(5); + last = 6; + } else if (scrolltype == UPSCROLL) { + dY = VGAScaleYs(5); + sy = VGAScaleYs(5); + last = 5; + } else if (scrolltype == DOWNSCROLL) { + dY = VGAScaleYs(-5); + dy = VGAScaleYs(-5); + sy = VGAScaleYs(5); + last = 5; + } + + sx += SVGACord(2); + + x1 = VGAScaleX(100) + (col * VGAScaleX(30)) + dx; + y1 = VGAScaleY(25) + (row * VGAScaleY(25)) + dy; + + for (counter = 0; counter < last; counter++) { + waitTOF(); + scrollRaster(dX, dY, x1, y1, x1 + VGAScaleX(28) + sx, y1 + VGAScaleY(23) + sy); + x1 += dX; + y1 += dY; + } +} + + + +/*****************************************************************************/ +/* Changes the combination number of one of the slots */ +/*****************************************************************************/ +static void changeTile(LargeSet Conditions, uint16 col, uint16 row) { + bool check; + int16 scrolltype = -1; + + if (row > 0) { + if (CurTile[col] [row - 1] == 0) { + CurTile[col] [row - 1] = CurTile[col] [row]; + CurTile[col] [row] = 0; + scrolltype = DOWNSCROLL; + } + } + + if (col > 0) { + if (CurTile[col - 1] [row] == 0) { + CurTile[col - 1] [row] = CurTile[col] [row]; + CurTile[col] [row] = 0; + scrolltype = RIGHTSCROLL; + } + } + + if (row < 3) { + if (CurTile[col] [row + 1] == 0) { + CurTile[col] [row + 1] = CurTile[col] [row]; + CurTile[col] [row] = 0; + scrolltype = UPSCROLL; + } + } + + if (col < 3) { + if (CurTile[col + 1] [row] == 0) { + CurTile[col + 1] [row] = CurTile[col] [row]; + CurTile[col] [row] = 0; + scrolltype = LEFTSCROLL; + } + } + + if (scrolltype != -1) { + /* NYI: + readPict("Music:Click", true); + */ + doTileScroll(col, row, scrolltype); + +#if defined(LABDEMO) + return; +#endif + +#if defined(GAME_TRIAL) + + if (!g_IsRegistered) + return; + +#endif + + check = true; + row = 0; + col = 0; + + while (row < 4) { + while (col < 4) { + check = check && (CurTile[row] [col] == TileSolution[row] [col]); + col++; + } + + row++; + col = 0; + } + + if (check) { + inclElement(Conditions, BRICKOPEN); /* unlocked combination */ + DoBlack = true; + check = readPict("p:Up/BDOpen", true); + } + } +} + + + + + +/*****************************************************************************/ +/* Processes mouse clicks and changes the combination. */ +/*****************************************************************************/ +void mouseTile(LargeSet Conditions, uint16 x, uint16 y) { + x = VGAUnScaleX(x); + y = VGAUnScaleY(y); + + if ((x < 101) || (y < 26)) + return; + + x = (x - 101) / 30; + y = (y - 26) / 25; + + if ((x < 4) && (y < 4)) + changeTile(Conditions, x, y); +} + + +/*---------------------------------------------------------------------------*/ +/*------------------------ Does the detective notes. ------------------------*/ +/*---------------------------------------------------------------------------*/ + +extern struct TextFont *MsgFont; +static struct TextFont *BigMsgFont; +static struct TextFont bmfont; + + +/*****************************************************************************/ +/* Does the things to properly set up the detective notes. */ +/*****************************************************************************/ +void doNotes(void) { + char *ntext; + + /* Load in the data */ + BigMsgFont = &bmfont; + + if (!getFont("P:Note.fon", BigMsgFont)) { + BigMsgFont = NULL; + return; + } + + if ((ntext = getText("Lab:Rooms/Notes")) == NULL) + return; + + 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); + freeAllStolenMem(); +} + + + + +/*---------------------------------------------------------------------------*/ +/*---------------------- Does the Old West newspaper. ----------------------*/ +/*---------------------------------------------------------------------------*/ + + + +/*****************************************************************************/ +/* Does the things to properly set up the old west newspaper. Assumes that */ +/* OpenHiRes already called. */ +/*****************************************************************************/ +void doWestPaper(void) { + char *ntext; + int32 FileLen, CharsPrinted; + uint16 y = 268; + + BigMsgFont = &bmfont; + + if (!getFont("P:News22.fon", BigMsgFont)) { + BigMsgFont = NULL; + return; + } + + if ((ntext = getText("Lab:Rooms/Date")) == NULL) + return; + + flowText(BigMsgFont, 0, 0, 0, false, true, false, true, VGAScaleX(57), VGAScaleY(77) + SVGACord(2), VGAScaleX(262), VGAScaleY(91), ntext); + + BigMsgFont = &bmfont; + + if (!getFont("P:News32.fon", BigMsgFont)) { + BigMsgFont = NULL; + return; + } + + if ((ntext = getText("Lab:Rooms/Headline")) == NULL) + return; + + FileLen = strlen(ntext) - 1; + CharsPrinted = flowText(BigMsgFont, -8, 0, 0, false, true, false, true, VGAScaleX(57), VGAScaleY(86) - SVGACord(2), VGAScaleX(262), VGAScaleY(118), ntext); + + if (CharsPrinted < FileLen) { + y = 130 - SVGACord(5); + flowText(BigMsgFont, -8 - SVGACord(1), 0, 0, false, true, false, true, VGAScaleX(57), VGAScaleY(86) - SVGACord(2), VGAScaleX(262), VGAScaleY(132), ntext); + } else + y = 115 - SVGACord(5); + + BigMsgFont = &bmfont; + + if (!getFont("P:Note.fon", BigMsgFont)) { + BigMsgFont = NULL; + return; + } + + if ((ntext = getText("Lab:Rooms/Col1")) == NULL) + return; + + CharsPrinted = flowText(BigMsgFont, -4, 0, 0, false, false, false, true, VGAScaleX(45), VGAScaleY(y), VGAScaleX(158), VGAScaleY(148), ntext); + + if ((ntext = getText("Lab:Rooms/Col2")) == NULL) + return; + + CharsPrinted = flowText(BigMsgFont, -4, 0, 0, false, false, false, true, VGAScaleX(162), VGAScaleY(y), VGAScaleX(275), VGAScaleY(148), ntext); + + VGASetPal(diffcmap, 256); + freeAllStolenMem(); +} + + + + +/*---------------------------------------------------------------------------*/ +/*---------------------------- The Journal stuff ----------------------------*/ +/*---------------------------------------------------------------------------*/ + + +#define BRIDGE0 148 +#define BRIDGE1 104 +#define DIRTY 175 +#define NONEWS 135 +#define NOCLEAN 152 + + +static char *journaltext, *journaltexttitle; +static uint16 JPage = 0; + +static bool lastpage = false; + +static struct Image *JCancel, *JCancelAlt, *JLeft, *JLeftAlt, *JRight, *JRightAlt, JBackImage, ScreenImage; + +static uint16 JGadX[3] = {80, 144, 194}, JGadY[3] = {162, 164, 162}; +static struct Gadget ForwardG, CancelG, BackG; + + + + +/*****************************************************************************/ +/* Loads in the data for the journal. */ +/*****************************************************************************/ +static bool loadJournalData(LargeSet Conditions) { + byte **buffer; + char filename[20]; + struct Gadget *TopGadget = &BackG; + uint16 counter; + bool bridge, dirty, news, clean; + + BigMsgFont = &bmfont; + + if (!getFont("P:Journal.fon", BigMsgFont)) { + BigMsgFont = NULL; + return false; + } + + g_music->checkMusic(); + + strcpy(filename, "Lab:Rooms/j0"); + bridge = In(Conditions, BRIDGE0) || In(Conditions, BRIDGE1); + dirty = In(Conditions, DIRTY); + news = !In(Conditions, NONEWS); + clean = !In(Conditions, NOCLEAN); + + if (bridge && clean && news) + filename[11] = '8'; + else if (clean && news) + filename[11] = '9'; + else if (bridge && clean) + filename[11] = '6'; + else if (clean) + filename[11] = '7'; + else if (bridge && dirty && news) + filename[11] = '4'; + else if (dirty && news) + filename[11] = '5'; + else if (bridge && dirty) + filename[11] = '2'; + else if (dirty) + filename[11] = '3'; + else if (bridge) + filename[11] = '1'; + + if ((journaltext = getText(filename)) == NULL) + return false; + + if ((journaltexttitle = getText("Lab:Rooms/jt")) == NULL) + return false; + + buffer = g_music->newOpen("P:JImage"); + + if (!buffer) + return false; + + readImage(buffer, &JLeft); + readImage(buffer, &JLeftAlt); + readImage(buffer, &JRight); + readImage(buffer, &JRightAlt); + readImage(buffer, &JCancel); + readImage(buffer, &JCancelAlt); + + BackG.Im = JLeft; + BackG.ImAlt = JLeftAlt; +#if !defined(DOSCODE) + BackG.KeyEquiv = VKEY_LTARROW; +#endif + ForwardG.Im = JRight; + ForwardG.ImAlt = JRightAlt; +#if !defined(DOSCODE) + ForwardG.KeyEquiv = VKEY_RTARROW; +#endif + CancelG.Im = JCancel; + CancelG.ImAlt = JCancelAlt; + + counter = 0; + + while (TopGadget) { + TopGadget->x = VGAScaleX(JGadX[counter]); + + if (counter == 1) + TopGadget->y = VGAScaleY(JGadY[counter]) + SVGACord(1); + else + TopGadget->y = VGAScaleY(JGadY[counter]) - SVGACord(1); + + TopGadget->GadgetID = counter; + TopGadget = TopGadget->NextGadget; + counter++; + } + + return true; +} + + + +/*****************************************************************************/ +/* Draws the text to the back journal screen to the appropriate Page number */ +/*****************************************************************************/ +static void drawJournalText(void) { + uint16 DrawingToPage = 1; + int32 CharsDrawn = 0L; + char *CurText = journaltext; + + while (DrawingToPage < JPage) { + g_music->newCheckMusic(); + CurText = (char *)(journaltext + CharsDrawn); + CharsDrawn += flowText(BigMsgFont, -2, 2, 0, false, false, false, false, VGAScaleX(52), VGAScaleY(32), VGAScaleX(152), VGAScaleY(148), CurText); + + lastpage = (*CurText == 0); + + if (lastpage) + JPage = (DrawingToPage / 2) * 2; + else + DrawingToPage++; + } + + if (JPage <= 1) { + CurText = journaltexttitle; + flowTextToMem(&JBackImage, BigMsgFont, -2, 2, 0, false, true, true, true, VGAScaleX(52), VGAScaleY(32), VGAScaleX(152), VGAScaleY(148), CurText); + } else { + CurText = (char *)(journaltext + CharsDrawn); + CharsDrawn += flowTextToMem(&JBackImage, BigMsgFont, -2, 2, 0, false, false, false, true, VGAScaleX(52), VGAScaleY(32), VGAScaleX(152), VGAScaleY(148), CurText); + } + + g_music->checkMusic(); + CurText = (char *)(journaltext + CharsDrawn); + lastpage = (*CurText == 0); + flowTextToMem(&JBackImage, BigMsgFont, -2, 2, 0, false, false, false, true, VGAScaleX(171), VGAScaleY(32), VGAScaleX(271), VGAScaleY(148), CurText); + + CurText = (char *)(journaltext + CharsDrawn); + lastpage = lastpage || (*CurText == 0); +} + + + + +/*****************************************************************************/ +/* Does the turn page wipe. */ +/*****************************************************************************/ +static void turnPage(bool FromLeft) { + uint16 counter; + + if (FromLeft) { + for (counter = 0; counter < VGAScreenWidth; counter += 8) { + g_music->updateMusic(); + waitTOF(); +#if !defined(DOSCODE) + ScreenImage.ImageData = getVGABaseAddr(); +#endif + bltBitMap(&JBackImage, counter, 0, &ScreenImage, counter, 0, 8, VGAScreenHeight); + } + } else { + for (counter = (VGAScreenWidth - 8); counter > 0; counter -= 8) { + g_music->updateMusic(); + waitTOF(); +#if !defined(DOSCODE) + ScreenImage.ImageData = getVGABaseAddr(); +#endif + bltBitMap(&JBackImage, counter, 0, &ScreenImage, counter, 0, 8, VGAScreenHeight); + } + } +} + + + +static bool GotBackImage = false; + +/*****************************************************************************/ +/* Draws the journal from page x. */ +/*****************************************************************************/ +static void drawJournal(uint16 wipenum, bool needFade) { + mouseHide(); + + g_music->checkMusic(); + + if (!GotBackImage) + JBackImage.ImageData = loadBackPict("P:Journal.pic", true); + + drawJournalText(); + +#if !defined(DOSCODE) + ScreenImage.ImageData = getVGABaseAddr(); +#endif + + if (wipenum == 0) + bltBitMap(&JBackImage, 0, 0, &ScreenImage, 0, 0, VGAScreenWidth, VGAScreenHeight); + else + turnPage((bool)(wipenum == 1)); + + if (JPage == 0) + ghoastGadget(&BackG, 15); + else + unGhoastGadget(&BackG); + + if (lastpage) + ghoastGadget(&ForwardG, 15); + else + unGhoastGadget(&ForwardG); + +#if !defined(DOSCODE) + ungetVGABaseAddr(); +#endif + + + if (needFade) + fade(true, 0); + + nopalchange = true; + JBackImage.ImageData = readPictToMem("P:Journal.pic", VGAScreenWidth, VGAScreenHeight); + GotBackImage = true; + + eatMessages(); + mouseShow(); + + nopalchange = false; +} + + + + +/*****************************************************************************/ +/* Processes user input. */ +/*****************************************************************************/ +static void processJournal() { + struct IntuiMessage *Msg; + uint32 Class; + uint16 Qualifier, GadID; + + while (1) { + g_music->checkMusic(); /* Make sure we check the music at least after every message */ + Msg = (struct IntuiMessage *) getMsg(); + + if (Msg == NULL) { + g_music->newCheckMusic(); + } else { + Class = Msg->Class; + Qualifier = Msg->Qualifier; + GadID = Msg->Code; + + replyMsg((void *) Msg); + + if (((Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) || + ((Class == RAWKEY) && (GadID == 27))) + return; + + else if (Class == GADGETUP) { + if (GadID == 0) { + if (JPage >= 2) { + JPage -= 2; + drawJournal(1, false); + } + } else if (GadID == 1) { + return; + } else if (GadID == 2) { + if (!lastpage) { + JPage += 2; + drawJournal(2, false); + } + } + } + } + } +} + + + +/*****************************************************************************/ +/* Cleans up behind all memory allocations. */ +/*****************************************************************************/ +static void journalCleanUp(void) { + freeAllStolenMem(); +} + + + + + +/*****************************************************************************/ +/* Does the journal processing. */ +/*****************************************************************************/ +void doJournal(LargeSet Conditions) { + resetBuffer(); + blackAllScreen(); + + lastpage = false; + GotBackImage = false; + + JBackImage.Width = VGAScreenWidth; + JBackImage.Height = VGAScreenHeight; + JBackImage.ImageData = NULL; + + BackG.NextGadget = &CancelG; + CancelG.NextGadget = &ForwardG; + + ScreenImage = JBackImage; + ScreenImage.ImageData = getVGABaseAddr(); + + g_music->checkMusic(); + loadJournalData(Conditions); + + drawJournal(0, true); + + attachGadgetList(&BackG); + mouseShow(); + processJournal(); + attachGadgetList(NULL); + fade(false, 0); + mouseHide(); + +#if !defined(DOSCODE) + ScreenImage.ImageData = getVGABaseAddr(); +#endif + + setAPen(0); + rectFill(0, 0, VGAScreenWidth - 1, VGAScreenHeight - 1); + blackScreen(); + + journalCleanUp(); + +#if !defined(DOSCODE) + ungetVGABaseAddr(); +#endif +} + + + +/*---------------------------------------------------------------------------*/ +/*------------------------- The Save/Restore stuff --------------------------*/ +/*---------------------------------------------------------------------------*/ + + +struct Image *Arrow1, *NoArrow1, *DriveButton; + + +extern InventoryData *Inventory; +extern uint16 RoomNum, Direction; +extern LargeSet Conditions, RoomsFound; + + + +extern char *SAVETEXT, *LOADTEXT, *BOOKMARKTEXT, *PERSONALTEXT, *DISKTEXT, *SAVEBOOK, *RESTOREBOOK, *SAVEFLASH, *RESTOREFLASH, *SAVEDISK, *RESTOREDISK, *SELECTDISK, *NODISKINDRIVE, *WRITEPROTECTED, *FORMATFLOPPY, *FORMATTING; + +static uint16 device; + +#define MAXDEVNAMES 5 + +static char DriveName[5] [MAXDEVNAMES]; + + + + + + +/*----- Gets the devices -----*/ + +/*****************************************************************************/ +/* Finds all the disk drives, puts them in an array of strings, sorts them, */ +/* and returned the number of drives that it found. */ +/*****************************************************************************/ +uint16 doDisks(void) { +#if defined(DOSCODE) + uint16 many = 0, counter = 2; + union REGS regs; + char str[5]; + + if (manydisks) + return manydisks; + + while ((counter < 7) && (many < MAXDEVNAMES)) { + memset(®s, 0, sizeof(regs)); + /* + regs.h.ah = 0x32; + regs.h.dl = counter+1; + int386(0x21, ®s, ®s); + if (regs.h.al == 0) + { + */ + regs.h.ah = 0x36; + regs.h.dl = counter + 1; + int386(0x21, ®s, ®s); + + if (regs.w.ax != 0xFFFF) { + str[0] = counter + 'A'; + str[1] = ':'; + str[2] = '\\'; + str[3] = 0; + strcpy(DriveName[many], str); + many++; + } + + counter++; + } + + return many; +#elif defined(WIN32) + extern void winGetDriveLetters(char cdLetters[], int size); + char letters[28]; + char str[5]; + uint16 many = 0, counter = 2; + + if (manydisks) + return manydisks; + + winGetDriveLetters(letters, 28); + + while ((counter < 7) && (many < MAXDEVNAMES) && letters[many] != 0) { + str[0] = letters[many]; + str[1] = ':'; + str[2] = '\\'; + str[3] = 0; + strcpy(DriveName[many], str); + many++; + counter++; + } + + return many; +#else + // !!!!goofy test code + char str[5]; + str[0] = 'C'; + str[1] = ':'; + str[2] = '\\'; + str[3] = 0; + strcpy(DriveName[0], str); + return 1; +#endif +} + + + + + +/*****************************************************************************/ +/* Does the user interface to save or restore a game position */ +/*****************************************************************************/ +#if defined(MODERNGAMESAVE) + +extern const byte ThePalMap[]; + +void getRoomMessage(int MyRoomNum, int MyDirection, char *msg); + +#define QUARTERNUM 30 + +#define NEXTEMPTYSLOTTEXT "Next Empty Slot" + +extern char g_SaveGamePath[512]; +extern char g_PathSeperator[4]; + +struct SaveGameInfo g_SaveGameInfo[MAX_SAVED_GAMES]; +int g_TotalSavedGames; +char g_CommonPalette[3 * 256]; +int g_LastSaveGameNumber = 0; +int g_CurSaveGameNumber = 0; +int g_CurSaveSet = 0; +int g_PendingNewSave = 0; + +enum UI_Ident { + ID_SAVE, ID_LOAD, ID_NEWSLOT, ID_1_TO_5, ID_6_TO_10, ID_11_TO_15, ID_SLOT_A, ID_SLOT_B, ID_SLOT_C, ID_SLOT_D, ID_SLOT_E, ID_CANCEL, ID_LAST +}; + +struct ModernUI { + int id; + int x, y, w, h; +}; + +struct ModernUI theUI[ID_LAST] = { + { ID_LOAD, 491, 182, 128, 54 }, { ID_SAVE, 491, 255, 128, 54 }, { ID_NEWSLOT, 491, 328, 128, 54 }, { ID_1_TO_5, 27, 40, 146, 25 }, { ID_6_TO_10, 175, 40, 146, 25 }, { ID_11_TO_15, 323, 40, 146, 25 }, { ID_SLOT_A, 27, 67, 442, 72 }, { ID_SLOT_B, 27, 142, 442, 72 }, { ID_SLOT_C, 27, 217, 442, 72 }, { ID_SLOT_D, 27, 292, 442, 72 }, { ID_SLOT_E, 27, 367, 442, 72 }, { ID_CANCEL, 531, 405, 52, 52 } +}; + +enum { + SG_BLACK = 1, SG_TAN = 14, SG_DKTAN = 38, SG_WHITE = 105, SG_YELLOW = 118 +}; + +/*****************************************************************************/ +/* Draw display */ +/*****************************************************************************/ +static void flowTextBold(void *font, /* the TextAttr pointer */ + uint16 spacing, /* How much vertical spacing between the lines */ + uint16 pencolor, /* pen number to use for text */ + uint16 backpen, /* the background color */ + bool outline, /* Whether to outline in background color */ + bool centerh, /* Whether to center the text horizontally */ + bool centerv, /* Whether to center the text vertically */ + bool output, /* Whether to output any text */ + uint16 x1, /* Cords */ + uint16 y1, uint16 x2, uint16 y2, const char *text) { /* The text itself */ + + if (outline) { + flowText(font, spacing, backpen, 0, false, centerh, centerv, output, x1 - 1, y1, x2 - 1, y2, text); + flowText(font, spacing, backpen, 0, false, centerh, centerv, output, x1 - 1, y1 - 1, x2 - 1, y2 - 1, text); + flowText(font, spacing, backpen, 0, false, centerh, centerv, output, x1, y1 + 2, x2, y2 + 2, text); + flowText(font, spacing, backpen, 0, false, centerh, centerv, output, x1 - 1, y1 + 2, x2 - 1, y2 + 2, text); + flowText(font, spacing, backpen, 0, false, centerh, centerv, output, x1 + 2, y1, x2 + 2, y2, text); + flowText(font, spacing, backpen, 0, false, centerh, centerv, output, x1 + 2, y1 + 2, x2 + 2, y2 + 2, text); + flowText(font, spacing, backpen, 0, false, centerh, centerv, output, x1, y1 - 1, x2, y2 - 1, text); + flowText(font, spacing, backpen, 0, false, centerh, centerv, output, x1 + 2, y1 - 1, x2 + 2, y2 - 1, text); + } + + flowText(font, spacing, pencolor, 0, false, centerh, centerv, output, x1, y1, x2, y2, text); + flowText(font, spacing, pencolor, 0, false, centerh, centerv, output, x1 + 1, y1, x2 + 1, y2, text); + flowText(font, spacing, pencolor, 0, false, centerh, centerv, output, x1, y1 + 1, x2, y2 + 1, text); + flowText(font, spacing, pencolor, 0, false, centerh, centerv, output, x1 + 1, y1 + 1, x2 + 1, y2 + 1, text); +} + +/*****************************************************************************/ +/* Draw display */ +/*****************************************************************************/ +static void flowTextShadow(void *font, /* the TextAttr pointer */ + uint16 spacing, /* How much vertical spacing between the lines */ + uint16 pencolor, /* pen number to use for text */ + uint16 backpen, /* the background color */ + bool outline, /* Whether to outline in background color */ + 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, char *text) { /* The text itself */ + + if (outline) { + flowText(font, spacing, backpen, 0, false, centerh, centerv, output, x1 - 1, y1 - 1, x2 - 1, y2 - 1, text); + flowText(font, spacing, backpen, 0, false, centerh, centerv, output, x1 - 1, y1 + 1, x2 - 1, y2 + 1, text); + flowText(font, spacing, backpen, 0, false, centerh, centerv, output, x1 + 1, y1 + 1, x2 + 1, y2 + 1, text); + flowText(font, spacing, backpen, 0, false, centerh, centerv, output, x1 + 1, y1 - 1, x2 + 1, y2 - 1, text); + } + + flowText(font, spacing, pencolor, 0, false, centerh, centerv, output, x1, y1, x2, y2, text); +} + +static void drawSaveLoad() { + int i, j; + + flowTextBold(MsgFont, 0, g_CurSaveGameNumber < g_TotalSavedGames ? SG_YELLOW : SG_DKTAN, SG_BLACK, true, true, true, true, 491 + 3, 182, 619 + 3, 236, LOADTEXT); + flowTextBold(MsgFont, 0, g_TotalSavedGames + g_PendingNewSave > 0 ? SG_YELLOW : SG_DKTAN, SG_BLACK, true, true, true, true, 491 + 3, 255, 619 + 3, 309, SAVETEXT); + flowTextBold(MsgFont, 0, g_PendingNewSave ? SG_DKTAN : SG_YELLOW, SG_BLACK, true, true, true, true, 491 + 3, 328, 619 + 3, 382, NEXTEMPTYSLOTTEXT); + + flowTextBold(MsgFont, 0, (g_CurSaveSet == 0 ? SG_YELLOW : SG_WHITE), SG_BLACK, true, true, true, true, 27 + 3, 40, 175 + 3, 65, "Saves 1-5"); + flowTextBold(MsgFont, 0, (g_CurSaveSet == 1 ? SG_YELLOW : SG_WHITE), SG_BLACK, true, true, true, true, 175 + 3, 40, 321 + 3, 65, "Saves 6-10"); + flowTextBold(MsgFont, 0, (g_CurSaveSet == 2 ? SG_YELLOW : SG_WHITE), SG_BLACK, true, true, true, true, 323 + 3, 40, 469 + 3, 65, "Saves 11-15"); + + for (i = 0, j = 5 * g_CurSaveSet; i < 5; i++, j++) { + uint16 hue, y; + char num_text[4]; + struct Image thumbnail, screen; + + if (j < g_TotalSavedGames + g_PendingNewSave) { + char msg[256]; + + getRoomMessage(g_SaveGameInfo[j].RoomNumber, g_SaveGameInfo[j].Direction, msg); + + hue = (j == g_CurSaveGameNumber ? SG_YELLOW : SG_WHITE); + y = 67 + 2 + i * 75; + flowText(MsgFont, 0, hue, 0, false, false, false, true, 202 + 2, y, 469 - 2, y + 48, msg); + y += 46; + flowText(MsgFont, 0, hue, 0, false, false, false, true, 202 + 2, y, 469 - 2, y + 24, g_SaveGameInfo[j].SaveGameDate); + + // blast image + thumbnail.Width = 128; + thumbnail.Height = 72; + thumbnail.ImageData = g_SaveGameInfo[j].SaveGameImage; + screen.Width = 640; + screen.Height = 480; + screen.ImageData = getVGABaseAddr(); + bltBitMap(&thumbnail, 0, 0, &screen, 72, 67 + i * 75, 128, 72); + ungetVGABaseAddr(); + + hue = (j == g_CurSaveGameNumber ? SG_YELLOW : SG_WHITE); + } else { + y = 67 + 2 + i * 75; + flowText(MsgFont, 0, SG_TAN, 0, false, true, true, true, 202 + 2, y, 469 - 2, y + 70, "[Empty Slot]"); + + hue = SG_DKTAN; + } + + y = 67 + i * 75; + sprintf(num_text, "%d", j + 1); + flowTextShadow(BigMsgFont, 0, hue, SG_BLACK, true, true, true, true, 27 + 4, y, 72 + 4, y + 72, num_text); + } + + // Add ".1" to version number + setAPen(SG_WHITE); + rectFill(271, 454, 271, 454); + rectFill(275, 449, 275, 454); + rectFill(274, 450, 274, 450); + rectFill(274, 454, 276, 454); + + g_system->updateScreen(); +} + +static void makeThumbnail(struct SaveGameInfo *info) { + char *pictName; + CloseDataPtr CPtr = NULL; + byte *BitMapMem; + int x, y, u, v; + + // load pict + pictName = getPictName(&CPtr); + nopalchange = true; + BitMapMem = readPictToMem(pictName, VGAScreenWidth, VGAScreenHeight); + nopalchange = false; + + for (y = 0; y < 72; y++) { + for (x = 0; x < 128; x++) { + unsigned int r = 0, g = 0, b = 0; + + for (v = 5 * y; v < 5 * y + 5; v++) { + for (u = 5 * x; u < 5 * x + 5; u++) { + byte n = (byte)BitMapMem[u + v * VGAScreenWidth]; + // 6-bit color (VGA) + r += (unsigned int)diffcmap[3 * n + 0]; + g += (unsigned int)diffcmap[3 * n + 1]; + b += (unsigned int)diffcmap[3 * n + 2]; + } + } + + r = (r / 25) >> 1; + g = (g / 25) >> 1; + b = (b / 25) >> 1; + warning("STUB: makeThumbnail"); + info->SaveGameImage[x + 128 * y] = ThePalMap[(r << 10) | (g << 5) | b]; + } + } +} + +static void addSaveSlot() { + struct SaveGameInfo *info; + + if (g_PendingNewSave || g_TotalSavedGames == MAX_SAVED_GAMES) + return; + + g_PendingNewSave = 1; + g_CurSaveGameNumber = g_TotalSavedGames; + g_CurSaveSet = g_CurSaveGameNumber / 5; + + // set-up saved game + info = &g_SaveGameInfo[g_CurSaveGameNumber]; + info->RoomNumber = RoomNum; + info->Direction = Direction; + + // not really a date yet + strcpy(info->SaveGameDate, "Click SAVE GAME to Confirm"); + + info->SaveGameImage = (byte *)malloc(SAVED_IMAGE_SIZE); + makeThumbnail(info); + + mouseHide(); + warning("STUB: addSaveSlot()"); + //SDL_IgnoreUpdateDisplay(1); + loadBackPict("P:ModSave", false); + //SDL_IgnoreUpdateDisplay(0); + drawSaveLoad(); + mouseShow(); +} + +static void selectSave(int n) { + if (g_CurSaveGameNumber == n || n >= g_TotalSavedGames + g_PendingNewSave) + return; + + g_CurSaveGameNumber = n; + + mouseHide(); + warning("STUB: selectSave()"); + //SDL_IgnoreUpdateDisplay(1); + loadBackPict("P:ModSave", false); + //SDL_IgnoreUpdateDisplay(0); + drawSaveLoad(); + mouseShow(); +} + +static void selectSaveSet(int n) { + if (g_CurSaveSet != n) { + g_CurSaveSet = n; + + mouseHide(); + warning("STUB: selectSaveSet"); + //SDL_IgnoreUpdateDisplay(1); + loadBackPict("P:ModSave", false); + //SDL_IgnoreUpdateDisplay(0); + drawSaveLoad(); + mouseShow(); + } +} + +/*****************************************************************************/ +/* Do modern save. */ +/*****************************************************************************/ +static bool doSaveGame() { + bool isok; + char DrivePath[260]; + + if (g_CurSaveGameNumber != g_TotalSavedGames) { + makeThumbnail(&g_SaveGameInfo[g_CurSaveGameNumber]); + } else { + // set time of save for new saved game + //struct tm *create_date; + //time_t ticks; + + warning("STUB: doSaveGame"); + //ticks = time(NULL); + //create_date = localtime(&ticks); + //strcpy(g_SaveGameInfo[g_CurSaveGameNumber].SaveGameDate, asctime(create_date)); + } + + memcpy(g_SaveGameImage, g_SaveGameInfo[g_CurSaveGameNumber].SaveGameImage, SAVED_IMAGE_SIZE); + + sprintf(DrivePath, "%s%s%d", g_SaveGamePath, g_PathSeperator, g_CurSaveGameNumber); + + isok = saveFloppy(DrivePath, RoomNum, Direction, Inventory[QUARTERNUM].Many, Conditions, RoomsFound, g_CurSaveGameNumber, device); + g_music->resetMusic(); + + if (isok) + g_LastSaveGameNumber = g_CurSaveGameNumber; + + return isok; +} + +/*****************************************************************************/ +/* Do modern load. */ +/*****************************************************************************/ +static bool doLoadGame() { + bool isok; + char drivePath[260]; + + snprintf(drivePath, 260, "%s%s%d", g_SaveGamePath, g_PathSeperator, g_CurSaveGameNumber); + + isok = readFloppy(drivePath, &RoomNum, &Direction, &(Inventory[QUARTERNUM].Many), Conditions, RoomsFound, g_CurSaveGameNumber, device); + g_music->resetMusic(); + + if (isok) + g_LastSaveGameNumber = g_CurSaveGameNumber; + + return isok; +} + +/*****************************************************************************/ +/* Processes user input. */ +/*****************************************************************************/ +static bool processSaveLoad() { + struct IntuiMessage *Msg; + + uint32 Class; + uint16 Qualifier, MouseX, MouseY, Code; + int i; + + drawSaveLoad(); + + while (1) { + g_music->checkMusic(); /* Make sure we check the music at least after every message */ + Msg = getMsg(); + + if (Msg == NULL) { + g_music->newCheckMusic(); + } else { + Class = Msg->Class; + Qualifier = Msg->Qualifier; + MouseX = Msg->MouseX; + MouseY = Msg->MouseY; + Code = Msg->Code; + + replyMsg(Msg); + + if (((Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) || + ((Class == RAWKEY) && (Code == 27))) + return -1; + + if (Class == RAWKEY) { + if (Code == 'l' || Code == 'L') { + if (g_CurSaveGameNumber < g_TotalSavedGames) + return doLoadGame(); + } else if (Code == 's' || Code == 'S') { + if (g_TotalSavedGames + g_PendingNewSave > 0) + return doSaveGame(); + } else if (Code == 'n' || Code == 'N') { + addSaveSlot(); + } else if (Code == VKEY_LTARROW) { + i = g_CurSaveSet - 1; + + if (i < 0) i = 2; + + selectSaveSet(i); + } else if (Code == VKEY_RTARROW) { + i = g_CurSaveSet + 1; + + if (i > 2) i = 0; + + selectSaveSet(i); + } else if (Code == VKEY_UPARROW) { + if (g_TotalSavedGames + g_PendingNewSave > 0) { + i = g_CurSaveGameNumber - 1; + + if (i < 0) + i = g_TotalSavedGames + g_PendingNewSave - 1; + + if (i / 5 != g_CurSaveSet) + selectSaveSet(i / 5); + + selectSave(i); + } + } else if (Code == VKEY_DNARROW) { + if (g_TotalSavedGames + g_PendingNewSave > 0) { + i = g_CurSaveGameNumber + 1; + + if (i >= g_TotalSavedGames + g_PendingNewSave) + i = 0; + + if (i / 5 != g_CurSaveSet) + selectSaveSet(i / 5); + + selectSave(i); + } + } + } else if ((Class == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & Qualifier)) { + for (i = 0; i < ID_LAST; i++) { + if (MouseX >= theUI[i].x && MouseY >= theUI[i].y && + MouseX < theUI[i].x + theUI[i].w && MouseY < theUI[i].y + theUI[i].h) { + switch (theUI[i].id) { + case ID_SAVE: + if (g_TotalSavedGames + g_PendingNewSave > 0) + return doSaveGame(); + + break; + + case ID_LOAD: + if (g_CurSaveGameNumber < g_TotalSavedGames) + return doLoadGame(); + + break; + + case ID_NEWSLOT: + addSaveSlot(); + break; + + case ID_1_TO_5: + case ID_6_TO_10: + case ID_11_TO_15: + selectSaveSet(theUI[i].id - ID_1_TO_5); + break; + + case ID_SLOT_A: + case ID_SLOT_B: + case ID_SLOT_C: + case ID_SLOT_D: + case ID_SLOT_E: + selectSave(5 * g_CurSaveSet + theUI[i].id - ID_SLOT_A); + break; + + case ID_CANCEL: + return -1; + } + } + } + } + } + } +} + +bool saveRestoreGame(void) { + byte **buffer; + bool isok = true; + + blackAllScreen(); + + BigMsgFont = &bmfont; + + if (!getFont("P:Map.fon", BigMsgFont)) { + BigMsgFont = NULL; + return false; + } + + buffer = g_music->newOpen("P:ModSave"); + + if (!buffer) { + freeAllStolenMem(); + return false; + } + + g_TotalSavedGames = getSaveGameList(g_SaveGameInfo, MAX_SAVED_GAMES); + g_CurSaveGameNumber = g_LastSaveGameNumber; + g_CurSaveSet = g_CurSaveGameNumber / 5; + g_PendingNewSave = 0; + + loadBackPict("P:ModSave", false); + + mouseShow(); + + VGASetPal(diffcmap, 256); + memcpy(g_CommonPalette, diffcmap, 3 * 256); + + isok = processSaveLoad(); + eatMessages(); + + mouseHide(); + memset(diffcmap, 0, 3 * 256); + VGASetPal(diffcmap, 256); + setAPen(0); + rectFill(0, 0, VGAScreenWidth - 1, VGAScreenHeight - 1); + blackScreen(); + g_system->updateScreen(); + + journalCleanUp(); + + freeAllStolenMem(); + + freeSaveGameList(g_SaveGameInfo, g_TotalSavedGames); + + return isok; +} +#else + +static uint16 manydisks = 0; + +static uint16 issave, ghoast, arrow, ManyDrives, DriveInitX, DriveNum = -1, FileNum = -1; + +/*****************************************************************************/ +/* Draws the number arrows. */ +/*****************************************************************************/ +static void doNumArrows(void) { + uint16 counterx, countery, curnum, cordx[3], cordy[3]; + + cordx[0] = VGAScaleX(53) + SVGACord(3); + cordx[1] = VGAScaleX(126) + SVGACord(1); + cordx[2] = VGAScaleX(197) + SVGACord(3); + + cordy[0] = VGAScaleY(58) + SVGACord(2); + cordy[1] = VGAScaleY(86) + SVGACord(3); + cordy[2] = VGAScaleY(114) + SVGACord(3); + + mouseHide(); + + for (countery = 0; countery < 3; countery++) { + for (counterx = 0; counterx < 3; counterx++) { + curnum = countery + counterx * 3; + + if INBIT(arrow, curnum) + drawImage(Arrow1, cordx[counterx], cordy[countery]); + else + drawImage(NoArrow1, cordx[counterx], (int32) cordy[countery]); + + if INBIT(ghoast, curnum) + ghoastRect(0, cordx[counterx], cordy[countery], cordx[counterx] + VGAScaleX(69), cordy[countery] + NoArrow1->Height); + } + } + + mouseShow(); +} + +/*****************************************************************************/ +/* Does the drive buttons for the final save/restore screen. */ +/*****************************************************************************/ +static void doDriveButtons(void) { + uint16 curx, counter; + + if (ManyDrives > 5) + ManyDrives = 5; + + DriveInitX = (VGAScreenWidth / 2) - ((ManyDrives * DriveButton->Width) / 2); + curx = DriveInitX; + + mouseHide(); + + for (counter = 0; counter < ManyDrives; counter++) { + drawImage(DriveButton, curx, VGAScaleY(153)); + + flowText(BigMsgFont, 0, 1, 0, false, true, true, true, curx + VGAScaleX(5), VGAScaleY(158), curx + DriveButton->Width - VGAScaleX(5), VGAScaleY(148) + DriveButton->Height, DriveName[counter]); + + curx += DriveButton->Width; + } + + mouseShow(); +} + + +static void drawSRMessage(char *rtext) { + mouseHide(); + flowText(BigMsgFont, 0, 1, 10, true, true, true, true, VGAScaleX(22), VGAScaleY(21), VGAScaleX(289), VGAScaleY(48), rtext); + mouseShow(); +} + +/*****************************************************************************/ +/* Draws the correct message to the message box. */ +/*****************************************************************************/ +static void doSaveRestoreText(void) { + char *rtext, text[100]; + + if (DriveNum >= ManyDrives) { + rtext = SELECTDISK; + } else if (issave) { + strcpy(text, SAVEDISK); + strcat(text, " "); + strcat(text, DriveName[DriveNum]); + rtext = text; + } else { + strcpy(text, RESTOREDISK); + strcat(text, " "); + strcat(text, DriveName[DriveNum]); + rtext = text; + } + + drawSRMessage(rtext); +} + +static uint16 processSaveRestore(uint16 type); + +static char DrivePath[50]; + +/*****************************************************************************/ +/* Checks for the existence of previous saved game positions on disk. */ +/*****************************************************************************/ +static void floppyCheckFiles(void) { + char temp[7], *name, len; + int fl; + uint16 counter; + + doSaveRestoreText(); + + arrow = 0; + ghoast = 0; + + strcpy(DrivePath, DriveName[DriveNum]); + strcat(DrivePath, "LabSaves"); + + warning("STUB: floppyCheckFiles"); + +#if 0 +#if defined(WIN32) + mkdir(DrivePath); +#else + mkdir(DrivePath, 0x644); +#endif + strcat(DrivePath, "\\"); + + len = strlen(DrivePath); + + for (counter = 0; counter < 9; counter++) { + name = numtostr(temp, counter); + strcat(DrivePath, name); + + if ((fl = open(DrivePath, O_RDONLY)) != -1) { + close(fl); + SETBIT(arrow, counter); + } else + SETBIT(ghoast, counter); + + DrivePath[len] = 0; + } +#endif +} + +/*****************************************************************************/ +/* Checks for the existence of previously saved game positions. */ +/*****************************************************************************/ +static void checkFiles(void) { + ghoast = -1; + arrow = 0; + + g_music->fillUpMusic(true); + + /* NYI: check for empty drive */ + floppyCheckFiles(); + + if (issave) + ghoast = 0; +} + +/*****************************************************************************/ +/* Processes user input. */ +/*****************************************************************************/ +static uint16 processSaveRestore(uint16 type) { + struct IntuiMessage *Msg; + + uint32 Class; + uint16 Qualifier, MouseX, MouseY, Code, Temp; + + while (1) { + g_music->checkMusic(); /* Make sure we check the music at least after every message */ + Msg = getMsg(); + + if (Msg == NULL) { + g_music->newCheckMusic(); + } else { + Class = Msg->Class; + Qualifier = Msg->Qualifier; + MouseX = Msg->MouseX; + MouseY = Msg->MouseY; + Code = Msg->Code; + + replyMsg(Msg); + + if (((Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) || + ((Class == RAWKEY) && (Code == 27))) + return -1; + + else if ((Class == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & Qualifier)) { + if (type == 0) { /* The save or restore screen */ + if ((MouseX >= VGAScaleX(64)) && (MouseX <= VGAScaleX(257))) { + if ((MouseY >= VGAScaleY(57)) && (MouseY <= VGAScaleY(92))) + return true; + else if ((MouseY >= VGAScaleY(108)) && (MouseY <= VGAScaleY(142))) + return false; + } + } + + else if (type == 2) { /* The files screen */ + if ((MouseY >= VGAScaleY(153)) && (MouseY <= VGAScaleY(180))) { /* the drive buttons */ + Temp = ((MouseX - DriveInitX) / DriveButton->Width); + + if (Temp < ManyDrives) { + DriveNum = Temp; + + fade(false, 0); + checkFiles(); + + loadBackPict("P:Disk/Nums.pic", false); + doNumArrows(); + doDriveButtons(); + doSaveRestoreText(); + + fade(true, 0); + } + } + + else if ((MouseX >= VGAScaleX(53)) && (MouseY >= VGAScaleY(58)) && + (MouseX <= VGAScaleX(266)) && (MouseY <= VGAScaleY(142))) { + MouseX = (MouseX - VGAScaleX(53)) / VGAScaleX(71); + MouseY = (MouseY - VGAScaleY(58)) / VGAScaleY(28); + + Temp = MouseY + (MouseX * 3); + + if (!(INBIT(ghoast, Temp))) { + + SETBIT(arrow, Temp); + doNumArrows(); + + FileNum = Temp; + return FileNum; + } + } + } + } + } + } +} + + + + +/*****************************************************************************/ +/* Sets up the Save or Restore screen. */ +/*****************************************************************************/ +static uint16 saveOrRestore(void) { + uint16 res; + + mouseHide(); + loadBackPict("P:Disk/Choose.pic", false); + + flowText(BigMsgFont, 0, 1, 4, false, true, true, true, VGAScaleX(74), VGAScaleY(65), VGAScaleX(247), VGAScaleY(84), SAVETEXT); + flowText(BigMsgFont, 0, 1, 4, false, true, true, true, VGAScaleX(74), VGAScaleY(116), VGAScaleX(247), VGAScaleY(135), LOADTEXT); + mouseShow(); + + fade(true, 0); + res = processSaveRestore(0); + fade(false, 0); + eatMessages(); + + return res; +} + + + + + +/*****************************************************************************/ +/* Sets up the final save/restore screen. */ +/*****************************************************************************/ +static uint16 saveRestore(void) { + uint16 res; + + loadBackPict("P:Disk/Nums.pic", false); + + if ((DriveNum < ManyDrives)) { + checkFiles(); + } else { + ghoast = -1; + arrow = 0; + } + + doNumArrows(); + doDriveButtons(); + doSaveRestoreText(); + g_music->newCheckMusic(); + + eatMessages(); + fade(true, 0); + res = processSaveRestore(2); + fade(false, 0); + + return res; +} + + +#define QUARTERNUM 30 + + +bool saveRestoreGame(void) { + uint16 filenum; + byte **buffer; + char temp[10], *name; + bool isok = true; + + blackAllScreen(); + + ManyDrives = doDisks(); + + FadePalette = hipal; + memset(&(hipal[0]), 0, 32L); + + BigMsgFont = &bmfont; + + if (!getFont("P:Map.fon", BigMsgFont)) { + BigMsgFont = NULL; + return false; + } + + buffer = g_music->newOpen("P:SaveImage"); + + if (!buffer) { + freeAllStolenMem(); + return false; + } + + readImage(buffer, &Arrow1); + readImage(buffer, &NoArrow1); + readImage(buffer, &DriveButton); + + mouseShow(); + + if ((issave = saveOrRestore()) != (uint16) - 1) { + eatMessages(); + + if ((filenum = saveRestore()) != (uint16) - 1) { + name = numtostr(temp, filenum); + strcat(DrivePath, name); + + eatMessages(); + + if (issave) + isok = saveFloppy(DrivePath, RoomNum, Direction, Inventory[QUARTERNUM].Many, Conditions, RoomsFound, filenum, device); + else { + isok = readFloppy(DrivePath, &RoomNum, &Direction, &(Inventory[QUARTERNUM].Many), Conditions, RoomsFound, filenum, device); + g_music->resetMusic(); + } + } + } + + mouseHide(); + setAPen(0); + rectFill(0, 0, VGAScreenWidth - 1, VGAScreenHeight - 1); + blackScreen(); + + journalCleanUp(); + + freeAllStolenMem(); + + return isok; +} + +#endif + + + +/*---------------------------------------------------------------------------*/ +/*--------------------------- The Monitors stuff ----------------------------*/ +/*---------------------------------------------------------------------------*/ + + +extern CloseDataPtr CPtr; + +static uint16 monpage; +static const char *TextFileName; + + +struct Image *MonButton, *AltMonButton, *MonQuit, *AltMonQuit, *MonBack, *AltMonBack, *MonDown, *AltMonDown, *MonUp, *AltMonUp; + + + + +/*****************************************************************************/ +/* Makes sure that the buttons are in memory. */ +/*****************************************************************************/ +static void getMonImages(void) { + byte **buffer; + + resetBuffer(); + + buffer = g_music->newOpen("P:MonImage"); + + if (!buffer) + return; + + readImage(buffer, &MonButton); + + stealBufMem(sizeOfFile("P:MonImage")); /* Trick: protects the memory where the buttons are so they won't be over-written */ +} + + +static uint16 MonGadHeight = 1; + + +/*****************************************************************************/ +/* Draws the text for the monitor. */ +/*****************************************************************************/ +static void drawMonText(char *text, uint16 x1, uint16 y1, uint16 x2, uint16 y2, bool isinteractive) { + uint16 DrawingToPage = 0, yspacing = 0, numlines, fheight, counter; + int32 CharsDrawn = 0L; + char *CurText = text; + + mouseHide(); + + if (*text == '%') { + text++; + numlines = (*text - '0') * 10; + text++; + numlines += (*text - '0'); + text += 2; + + fheight = textHeight(BigMsgFont); + x1 = MonButton->Width + VGAScaleX(3); + MonGadHeight = MonButton->Height + VGAScaleY(3); + + if (MonGadHeight > fheight) + yspacing = MonGadHeight - fheight; + else + MonGadHeight = fheight; + + setAPen(0); + rectFill(0, 0, VGAScreenWidth - 1, y2); + + for (counter = 0; counter < numlines; counter++) + drawImage(MonButton, 0, counter * MonGadHeight); + } else if (isinteractive) { + setAPen(0); + rectFill(0, 0, VGAScreenWidth - 1, y2); + } else { + setAPen(0); + rectFill(x1, y1, x2, y2); + } + + while (DrawingToPage < monpage) { + g_music->newCheckMusic(); + CurText = (char *)(text + CharsDrawn); + CharsDrawn += flowText(BigMsgFont, yspacing, 0, 0, false, false, false, false, x1, y1, x2, y2, CurText); + lastpage = (*CurText == 0); + + if (lastpage) + monpage = DrawingToPage; + else + DrawingToPage++; + } + + CurText = (char *)(text + CharsDrawn); + lastpage = (*CurText == 0); + CharsDrawn = flowText(BigMsgFont, yspacing, 2, 0, false, false, false, true, x1, y1, x2, y2, CurText); + CurText += CharsDrawn; + lastpage = lastpage || (*CurText == 0); + + mouseShow(); +} + +/*****************************************************************************/ +/* Processes user input. */ +/*****************************************************************************/ +static void processMonitor(char *ntext, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2) { + struct IntuiMessage *Msg; + uint32 Class; + uint16 Qualifier, Code, MouseX, MouseY; + const char *Test = " ", *StartFileName = TextFileName; + CloseDataPtr StartCPtr = CPtr, TestCPtr, LastCPtr[10]; + uint16 depth = 0; + + LastCPtr[0] = CPtr; + + while (1) { + if (isinteractive) { + if (CPtr == NULL) + CPtr = StartCPtr; + + if (CPtr == StartCPtr) + Test = StartFileName; + else + Test = CPtr->GraphicName; + + if (strcmp(Test, TextFileName)) { + monpage = 0; + TextFileName = Test; + + ntext = getText(TextFileName); + fade(false, 0); + drawMonText(ntext, x1, y1, x2, y2, isinteractive); + fade(true, 0); + } + } + + g_music->checkMusic(); /* Make sure we check the music at least after every message */ + Msg = getMsg(); + + if (Msg == NULL) { + g_music->newCheckMusic(); + } else { + Class = Msg->Class; + Qualifier = Msg->Qualifier; + MouseX = Msg->MouseX; + MouseY = Msg->MouseY; + Code = Msg->Code; + + replyMsg(Msg); + + if (((Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) || + ((Class == RAWKEY) && (Code == 27))) + return; + + else if ((Class == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & Qualifier)) { + if ((MouseY >= VGAScaleY(171)) && (MouseY <= VGAScaleY(200))) { + if ((MouseX >= VGAScaleX(259)) && (MouseX <= VGAScaleX(289))) { + if (!lastpage) { + monpage += 1; + drawMonText(ntext, x1, y1, x2, y2, isinteractive); + } + } else if ((MouseX >= VGAScaleX(0)) && (MouseX <= VGAScaleX(31))) { + return; + } else if ((MouseX >= VGAScaleX(290)) && (MouseX <= VGAScaleX(320))) { + if (monpage >= 1) { + monpage -= 1; + drawMonText(ntext, x1, y1, x2, y2, isinteractive); + } + } else if ((MouseX >= VGAScaleX(31)) && (MouseX <= VGAScaleX(59))) { + if (isinteractive) { + monpage = 0; + + if (depth) { + depth--; + CPtr = LastCPtr[depth]; + } + } else if (monpage > 0) { + monpage = 0; + drawMonText(ntext, x1, y1, x2, y2, isinteractive); + } + } + } else if (isinteractive) { + TestCPtr = CPtr; + MouseY = 64 + (MouseY / MonGadHeight) * 42; + MouseX = 101; + setCurCloseAbs(MouseX, MouseY, &CPtr); + + if (TestCPtr != CPtr) { + LastCPtr[depth] = TestCPtr; + depth++; + } + } + } + } + } +} + + + + +/*****************************************************************************/ +/* Does what's necessary for the monitor. */ +/*****************************************************************************/ +void doMonitor(char *background, char *textfile, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2) { + char *ntext; + + x1 = VGAScaleX(x1); + x2 = VGAScaleX(x2); + y1 = VGAScaleY(y1); + y2 = VGAScaleY(y2); + + TextFileName = textfile; + + blackAllScreen(); + + readPict("P:Mon/Monitor.1", true); + readPict("P:Mon/NWD1", true); + readPict("P:Mon/NWD2", true); + readPict("P:Mon/NWD3", true); + blackAllScreen(); + + resetBuffer(); + monpage = 0; + lastpage = false; + FadePalette = hipal; + + BigMsgFont = &bmfont; + + if (!getFont("P:Map.font", BigMsgFont)) { + freeAllStolenMem(); + BigMsgFont = NULL; + return; + } + + getMonImages(); + + if ((ntext = getText(textfile)) == NULL) { + freeAllStolenMem(); + return; + } + + loadBackPict(background, false); + + drawMonText(ntext, x1, y1, x2, y2, isinteractive); + + mouseShow(); + fade(true, 0); + processMonitor(ntext, isinteractive, x1, y1, x2, y2); + fade(false, 0); + mouseHide(); + + freeAllStolenMem(); + + setAPen(0); + rectFill(0, 0, VGAScreenWidth - 1, VGAScreenHeight - 1); + blackAllScreen(); +} + +#if defined(LABDEMO) +void doTrialBlock() { + struct IntuiMessage *Msg; + + uint32 Class; + uint16 Qualifier, MouseX, MouseY, Code, Temp; + int i; + + loadBackPict("P:Warning", false); + mouseShow(); + + VGASetPal(diffcmap, 256); + memcpy(g_CommonPalette, diffcmap, 3 * 256); + + while (1) { + g_music->checkMusic(); /* Make sure we check the music at least after every message */ + Msg = getMsg(); + + if (Msg == NULL) { + g_music->newCheckMusic(); + } else { + Class = Msg->Class; + Qualifier = Msg->Qualifier; + MouseX = Msg->MouseX; + MouseY = Msg->MouseY; + Code = Msg->Code; + + replyMsg(Msg); + + if (((Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) || + ((Class == RAWKEY) && (Code == 27))) + return; + + if ((Class == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & Qualifier)) { + if (MouseY > 399) { + // click on control panel, exit + break; + } + + if (MouseX >= 0 && MouseX <= 319 && MouseY >= 0 && MouseY <= 399) { + extern void getItNow(); + getItNow(); + } else if (MouseX >= 320 && MouseX <= 639 && MouseY >= 0 && MouseY <= 399) { + break; + } + } + } + } + + eatMessages(); + mouseHide(); +} +#endif + +} // End of namespace Lab -- cgit v1.2.3 From 11a7ffaabe89920b6481e0efeb744b5efc222996 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 14 Dec 2014 16:42:44 +0100 Subject: LAB: Started rendering pipeline --- engines/lab/special.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 5542b05716..8275517f47 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -1224,7 +1224,7 @@ static void drawSaveLoad() { rectFill(274, 450, 274, 450); rectFill(274, 454, 276, 454); - g_system->updateScreen(); + WSDL_UpdateScreen(); } static void makeThumbnail(struct SaveGameInfo *info) { @@ -1535,7 +1535,7 @@ bool saveRestoreGame(void) { setAPen(0); rectFill(0, 0, VGAScreenWidth - 1, VGAScreenHeight - 1); blackScreen(); - g_system->updateScreen(); + WSDL_UpdateScreen(); journalCleanUp(); -- cgit v1.2.3 From bbddd32d38a03544ddab6e36e6853ddc128d0254 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 14 Dec 2014 17:46:40 +0100 Subject: LAB: Further rendering pipeline fixes --- engines/lab/special.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 8275517f47..4e842a1de0 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -1284,10 +1284,9 @@ static void addSaveSlot() { makeThumbnail(info); mouseHide(); - warning("STUB: addSaveSlot()"); - //SDL_IgnoreUpdateDisplay(1); + WSDL_IgnoreUpdateDisplay(1); loadBackPict("P:ModSave", false); - //SDL_IgnoreUpdateDisplay(0); + WSDL_IgnoreUpdateDisplay(0); drawSaveLoad(); mouseShow(); } @@ -1299,10 +1298,9 @@ static void selectSave(int n) { g_CurSaveGameNumber = n; mouseHide(); - warning("STUB: selectSave()"); - //SDL_IgnoreUpdateDisplay(1); + WSDL_IgnoreUpdateDisplay(1); loadBackPict("P:ModSave", false); - //SDL_IgnoreUpdateDisplay(0); + WSDL_IgnoreUpdateDisplay(0); drawSaveLoad(); mouseShow(); } @@ -1312,10 +1310,9 @@ static void selectSaveSet(int n) { g_CurSaveSet = n; mouseHide(); - warning("STUB: selectSaveSet"); - //SDL_IgnoreUpdateDisplay(1); + WSDL_IgnoreUpdateDisplay(1); loadBackPict("P:ModSave", false); - //SDL_IgnoreUpdateDisplay(0); + WSDL_IgnoreUpdateDisplay(0); drawSaveLoad(); mouseShow(); } -- cgit v1.2.3 From abded17657503419a12a4831094bc8d9d8005c95 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Mon, 22 Dec 2014 10:03:05 +0100 Subject: LAB: Simplify stddefines.h --- engines/lab/special.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 4e842a1de0..50589ed941 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -66,6 +66,12 @@ extern uint32 VGAScreenWidth, VGAScreenHeight; static uint16 hipal[20]; extern uint16 *FadePalette; +#define INCL(BITSET,BIT) ((BITSET) |= (BIT)) + +#define SETBIT(BITSET,BITNUM) INCL(BITSET, (1 << (BITNUM))) + +#define INBIT(BITSET,BITNUM) ( ((1 << (BITNUM)) & (BITSET)) > 0 ) + static byte *loadBackPict(const char *fileName, bool tomem) { uint16 counter; -- cgit v1.2.3 From 471dbaa758f0ebea9f3d76caa7fd769c6809d395 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Thu, 25 Dec 2014 12:36:47 +0100 Subject: LAB: Started objectifying LargeSets --- engines/lab/special.cpp | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 50589ed941..022f203f52 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -195,20 +195,13 @@ static void changeCombination(LargeSet Conditions, uint16 number) { bltBitMap(Images[combnum], 0, (Images[combnum])->Height - (2 * counter), &(display), VGAScaleX(combx[number]), VGAScaleY(65), (Images[combnum])->Width, 2); } - /* - if (memcmp(combination, solution, (size_t) 12) == 0) - inclElement(Conditions, COMBINATIONUNLOCKED); - else - exclElement(Conditions, COMBINATIONUNLOCKED); - */ - for (counter = 0; counter < 6; counter++) unlocked = (combination[counter] == solution[counter]) && unlocked; if (unlocked) - inclElement(Conditions, COMBINATIONUNLOCKED); + g_engine->_conditions->inclElement(COMBINATIONUNLOCKED); else - exclElement(Conditions, COMBINATIONUNLOCKED); + g_engine->_conditions->exclElement(COMBINATIONUNLOCKED); #if !defined(DOSCODE) ungetVGABaseAddr(); @@ -486,7 +479,7 @@ static void changeTile(LargeSet Conditions, uint16 col, uint16 row) { } if (check) { - inclElement(Conditions, BRICKOPEN); /* unlocked combination */ + g_engine->_conditions->inclElement(BRICKOPEN); /* unlocked combination */ DoBlack = true; check = readPict("p:Up/BDOpen", true); } @@ -665,10 +658,10 @@ static bool loadJournalData(LargeSet Conditions) { g_music->checkMusic(); strcpy(filename, "Lab:Rooms/j0"); - bridge = In(Conditions, BRIDGE0) || In(Conditions, BRIDGE1); - dirty = In(Conditions, DIRTY); - news = !In(Conditions, NONEWS); - clean = !In(Conditions, NOCLEAN); + bridge = g_engine->_conditions->in(BRIDGE0) || g_engine->_conditions->in(BRIDGE1); + dirty = g_engine->_conditions->in(DIRTY); + news = !g_engine->_conditions->in(NONEWS); + clean = !g_engine->_conditions->in(NOCLEAN); if (bridge && clean && news) filename[11] = '8'; @@ -981,9 +974,6 @@ struct Image *Arrow1, *NoArrow1, *DriveButton; extern InventoryData *Inventory; extern uint16 RoomNum, Direction; -extern LargeSet Conditions, RoomsFound; - - extern char *SAVETEXT, *LOADTEXT, *BOOKMARKTEXT, *PERSONALTEXT, *DISKTEXT, *SAVEBOOK, *RESTOREBOOK, *SAVEFLASH, *RESTOREFLASH, *SAVEDISK, *RESTOREDISK, *SELECTDISK, *NODISKINDRIVE, *WRITEPROTECTED, *FORMATFLOPPY, *FORMATTING; -- cgit v1.2.3 From cb8f8432966ccee632bf4e79e367d6d941dfdedb Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Thu, 25 Dec 2014 19:13:52 +0100 Subject: LAB: Objectify LabSets --- engines/lab/special.cpp | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 022f203f52..b033386f38 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -28,6 +28,7 @@ * */ +#include "lab/lab.h" #include "lab/labfun.h" #include "lab/parsefun.h" #include "lab/interface.h" @@ -159,7 +160,7 @@ void showCombination(const char *filename) { /*****************************************************************************/ /* Changes the combination number of one of the slots */ /*****************************************************************************/ -static void changeCombination(LargeSet Conditions, uint16 number) { +static void changeCombination(uint16 number) { struct Image display; uint16 counter, combnum; bool unlocked = true; @@ -199,9 +200,9 @@ static void changeCombination(LargeSet Conditions, uint16 number) { unlocked = (combination[counter] == solution[counter]) && unlocked; if (unlocked) - g_engine->_conditions->inclElement(COMBINATIONUNLOCKED); + g_lab->_conditions->inclElement(COMBINATIONUNLOCKED); else - g_engine->_conditions->exclElement(COMBINATIONUNLOCKED); + g_lab->_conditions->exclElement(COMBINATIONUNLOCKED); #if !defined(DOSCODE) ungetVGABaseAddr(); @@ -215,7 +216,7 @@ static void changeCombination(LargeSet Conditions, uint16 number) { /*****************************************************************************/ /* Processes mouse clicks and changes the combination. */ /*****************************************************************************/ -void mouseCombination(LargeSet Conditions, uint16 x, uint16 y) { +void mouseCombination(uint16 x, uint16 y) { uint16 number; x = VGAUnScaleX(x); @@ -237,7 +238,7 @@ void mouseCombination(LargeSet Conditions, uint16 x, uint16 y) { else return; - changeCombination(Conditions, number); + changeCombination(number); } } @@ -411,7 +412,7 @@ static void doTileScroll(uint16 col, uint16 row, uint16 scrolltype) { /*****************************************************************************/ /* Changes the combination number of one of the slots */ /*****************************************************************************/ -static void changeTile(LargeSet Conditions, uint16 col, uint16 row) { +static void changeTile(uint16 col, uint16 row) { bool check; int16 scrolltype = -1; @@ -479,7 +480,7 @@ static void changeTile(LargeSet Conditions, uint16 col, uint16 row) { } if (check) { - g_engine->_conditions->inclElement(BRICKOPEN); /* unlocked combination */ + g_lab->_conditions->inclElement(BRICKOPEN); /* unlocked combination */ DoBlack = true; check = readPict("p:Up/BDOpen", true); } @@ -493,7 +494,7 @@ static void changeTile(LargeSet Conditions, uint16 col, uint16 row) { /*****************************************************************************/ /* Processes mouse clicks and changes the combination. */ /*****************************************************************************/ -void mouseTile(LargeSet Conditions, uint16 x, uint16 y) { +void mouseTile(uint16 x, uint16 y) { x = VGAUnScaleX(x); y = VGAUnScaleY(y); @@ -504,7 +505,7 @@ void mouseTile(LargeSet Conditions, uint16 x, uint16 y) { y = (y - 26) / 25; if ((x < 4) && (y < 4)) - changeTile(Conditions, x, y); + changeTile(x, y); } @@ -641,7 +642,7 @@ static struct Gadget ForwardG, CancelG, BackG; /*****************************************************************************/ /* Loads in the data for the journal. */ /*****************************************************************************/ -static bool loadJournalData(LargeSet Conditions) { +static bool loadJournalData() { byte **buffer; char filename[20]; struct Gadget *TopGadget = &BackG; @@ -658,10 +659,10 @@ static bool loadJournalData(LargeSet Conditions) { g_music->checkMusic(); strcpy(filename, "Lab:Rooms/j0"); - bridge = g_engine->_conditions->in(BRIDGE0) || g_engine->_conditions->in(BRIDGE1); - dirty = g_engine->_conditions->in(DIRTY); - news = !g_engine->_conditions->in(NONEWS); - clean = !g_engine->_conditions->in(NOCLEAN); + bridge = g_lab->_conditions->in(BRIDGE0) || g_lab->_conditions->in(BRIDGE1); + dirty = g_lab->_conditions->in(DIRTY); + news = !g_lab->_conditions->in(NONEWS); + clean = !g_lab->_conditions->in(NOCLEAN); if (bridge && clean && news) filename[11] = '8'; @@ -918,7 +919,7 @@ static void journalCleanUp(void) { /*****************************************************************************/ /* Does the journal processing. */ /*****************************************************************************/ -void doJournal(LargeSet Conditions) { +void doJournal() { resetBuffer(); blackAllScreen(); @@ -936,7 +937,7 @@ void doJournal(LargeSet Conditions) { ScreenImage.ImageData = getVGABaseAddr(); g_music->checkMusic(); - loadJournalData(Conditions); + loadJournalData(); drawJournal(0, true); @@ -1338,7 +1339,7 @@ static bool doSaveGame() { sprintf(DrivePath, "%s%s%d", g_SaveGamePath, g_PathSeperator, g_CurSaveGameNumber); - isok = saveFloppy(DrivePath, RoomNum, Direction, Inventory[QUARTERNUM].Many, Conditions, RoomsFound, g_CurSaveGameNumber, device); + isok = saveFloppy(DrivePath, RoomNum, Direction, Inventory[QUARTERNUM].Many, g_CurSaveGameNumber, device); g_music->resetMusic(); if (isok) @@ -1356,7 +1357,7 @@ static bool doLoadGame() { snprintf(drivePath, 260, "%s%s%d", g_SaveGamePath, g_PathSeperator, g_CurSaveGameNumber); - isok = readFloppy(drivePath, &RoomNum, &Direction, &(Inventory[QUARTERNUM].Many), Conditions, RoomsFound, g_CurSaveGameNumber, device); + isok = readFloppy(drivePath, &RoomNum, &Direction, &(Inventory[QUARTERNUM].Many), g_CurSaveGameNumber, device); g_music->resetMusic(); if (isok) @@ -1877,9 +1878,9 @@ bool saveRestoreGame(void) { eatMessages(); if (issave) - isok = saveFloppy(DrivePath, RoomNum, Direction, Inventory[QUARTERNUM].Many, Conditions, RoomsFound, filenum, device); + isok = saveFloppy(DrivePath, RoomNum, Direction, Inventory[QUARTERNUM].Many, filenum, device); else { - isok = readFloppy(DrivePath, &RoomNum, &Direction, &(Inventory[QUARTERNUM].Many), Conditions, RoomsFound, filenum, device); + isok = readFloppy(DrivePath, &RoomNum, &Direction, &(Inventory[QUARTERNUM].Many), filenum, device); g_music->resetMusic(); } } -- cgit v1.2.3 From 58182bd77af8433e00b7b7475633bd1d6ddf13b0 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Fri, 26 Dec 2014 00:32:42 +0100 Subject: LAB: Cleanup --- engines/lab/special.cpp | 80 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 54 insertions(+), 26 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index b033386f38..3ab548a82e 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -54,7 +54,7 @@ int g_IsRegistered; extern bool nopalchange, DoBlack, IsHiRes; -extern struct BitMap *DispBitMap, *DrawBitMap; +extern BitMap *DispBitMap, *DrawBitMap; extern char diffcmap[3 * 256]; extern uint32 VGAScreenWidth, VGAScreenHeight; @@ -106,7 +106,7 @@ static byte *loadBackPict(const char *fileName, bool tomem) { -static struct Image *Images[10]; +static Image *Images[10]; uint16 combination[6] = {0, 0, 0, 0, 0, 0}, solution[] = {0, 4, 0, 8, 7, 2}; @@ -161,7 +161,7 @@ void showCombination(const char *filename) { /* Changes the combination number of one of the slots */ /*****************************************************************************/ static void changeCombination(uint16 number) { - struct Image display; + Image display; uint16 counter, combnum; bool unlocked = true; @@ -251,7 +251,7 @@ void mouseCombination(uint16 x, uint16 y) { -struct Image *Tiles[16]; +Image *Tiles[16]; int16 CurTile[4] [4] = { { 1, 5, 9, 13 }, { 2, 6, 10, 14 }, @@ -513,9 +513,9 @@ void mouseTile(uint16 x, uint16 y) { /*------------------------ Does the detective notes. ------------------------*/ /*---------------------------------------------------------------------------*/ -extern struct TextFont *MsgFont; -static struct TextFont *BigMsgFont; -static struct TextFont bmfont; +extern TextFont *MsgFont; +static TextFont *BigMsgFont; +static TextFont bmfont; /*****************************************************************************/ @@ -631,10 +631,10 @@ static uint16 JPage = 0; static bool lastpage = false; -static struct Image *JCancel, *JCancelAlt, *JLeft, *JLeftAlt, *JRight, *JRightAlt, JBackImage, ScreenImage; +static Image *JCancel, *JCancelAlt, *JLeft, *JLeftAlt, *JRight, *JRightAlt, JBackImage, ScreenImage; static uint16 JGadX[3] = {80, 144, 194}, JGadY[3] = {162, 164, 162}; -static struct Gadget ForwardG, CancelG, BackG; +static Gadget ForwardG, CancelG, BackG; @@ -645,7 +645,7 @@ static struct Gadget ForwardG, CancelG, BackG; static bool loadJournalData() { byte **buffer; char filename[20]; - struct Gadget *TopGadget = &BackG; + Gadget *TopGadget = &BackG; uint16 counter; bool bridge, dirty, news, clean; @@ -863,13 +863,13 @@ static void drawJournal(uint16 wipenum, bool needFade) { /* Processes user input. */ /*****************************************************************************/ static void processJournal() { - struct IntuiMessage *Msg; + IntuiMessage *Msg; uint32 Class; uint16 Qualifier, GadID; while (1) { g_music->checkMusic(); /* Make sure we check the music at least after every message */ - Msg = (struct IntuiMessage *) getMsg(); + Msg = (IntuiMessage *) getMsg(); if (Msg == NULL) { g_music->newCheckMusic(); @@ -970,7 +970,7 @@ void doJournal() { /*---------------------------------------------------------------------------*/ -struct Image *Arrow1, *NoArrow1, *DriveButton; +Image *Arrow1, *NoArrow1, *DriveButton; extern InventoryData *Inventory; @@ -1084,7 +1084,7 @@ void getRoomMessage(int MyRoomNum, int MyDirection, char *msg); extern char g_SaveGamePath[512]; extern char g_PathSeperator[4]; -struct SaveGameInfo g_SaveGameInfo[MAX_SAVED_GAMES]; +SaveGameInfo g_SaveGameInfo[MAX_SAVED_GAMES]; int g_TotalSavedGames; char g_CommonPalette[3 * 256]; int g_LastSaveGameNumber = 0; @@ -1093,7 +1093,19 @@ int g_CurSaveSet = 0; int g_PendingNewSave = 0; enum UI_Ident { - ID_SAVE, ID_LOAD, ID_NEWSLOT, ID_1_TO_5, ID_6_TO_10, ID_11_TO_15, ID_SLOT_A, ID_SLOT_B, ID_SLOT_C, ID_SLOT_D, ID_SLOT_E, ID_CANCEL, ID_LAST + ID_SAVE, + ID_LOAD, + ID_NEWSLOT, + ID_1_TO_5, + ID_6_TO_10, + ID_11_TO_15, + ID_SLOT_A, + ID_SLOT_B, + ID_SLOT_C, + ID_SLOT_D, + ID_SLOT_E, + ID_CANCEL, + ID_LAST }; struct ModernUI { @@ -1101,12 +1113,27 @@ struct ModernUI { int x, y, w, h; }; -struct ModernUI theUI[ID_LAST] = { - { ID_LOAD, 491, 182, 128, 54 }, { ID_SAVE, 491, 255, 128, 54 }, { ID_NEWSLOT, 491, 328, 128, 54 }, { ID_1_TO_5, 27, 40, 146, 25 }, { ID_6_TO_10, 175, 40, 146, 25 }, { ID_11_TO_15, 323, 40, 146, 25 }, { ID_SLOT_A, 27, 67, 442, 72 }, { ID_SLOT_B, 27, 142, 442, 72 }, { ID_SLOT_C, 27, 217, 442, 72 }, { ID_SLOT_D, 27, 292, 442, 72 }, { ID_SLOT_E, 27, 367, 442, 72 }, { ID_CANCEL, 531, 405, 52, 52 } +ModernUI theUI[ID_LAST] = { + { ID_LOAD, 491, 182, 128, 54 }, + { ID_SAVE, 491, 255, 128, 54 }, + { ID_NEWSLOT, 491, 328, 128, 54 }, + { ID_1_TO_5, 27, 40, 146, 25 }, + { ID_6_TO_10, 175, 40, 146, 25 }, + { ID_11_TO_15, 323, 40, 146, 25 }, + { ID_SLOT_A, 27, 67, 442, 72 }, + { ID_SLOT_B, 27, 142, 442, 72 }, + { ID_SLOT_C, 27, 217, 442, 72 }, + { ID_SLOT_D, 27, 292, 442, 72 }, + { ID_SLOT_E, 27, 367, 442, 72 }, + { ID_CANCEL, 531, 405, 52, 52 } }; enum { - SG_BLACK = 1, SG_TAN = 14, SG_DKTAN = 38, SG_WHITE = 105, SG_YELLOW = 118 + SG_BLACK = 1, + SG_TAN = 14, + SG_DKTAN = 38, + SG_WHITE = 105, + SG_YELLOW = 118 }; /*****************************************************************************/ @@ -1178,7 +1205,7 @@ static void drawSaveLoad() { for (i = 0, j = 5 * g_CurSaveSet; i < 5; i++, j++) { uint16 hue, y; char num_text[4]; - struct Image thumbnail, screen; + Image thumbnail, screen; if (j < g_TotalSavedGames + g_PendingNewSave) { char msg[256]; @@ -1224,7 +1251,7 @@ static void drawSaveLoad() { WSDL_UpdateScreen(); } -static void makeThumbnail(struct SaveGameInfo *info) { +static void makeThumbnail(SaveGameInfo *info) { char *pictName; CloseDataPtr CPtr = NULL; byte *BitMapMem; @@ -1260,7 +1287,7 @@ static void makeThumbnail(struct SaveGameInfo *info) { } static void addSaveSlot() { - struct SaveGameInfo *info; + SaveGameInfo *info; if (g_PendingNewSave || g_TotalSavedGames == MAX_SAVED_GAMES) return; @@ -1370,7 +1397,7 @@ static bool doLoadGame() { /* Processes user input. */ /*****************************************************************************/ static bool processSaveLoad() { - struct IntuiMessage *Msg; + IntuiMessage *Msg; uint32 Class; uint16 Qualifier, MouseX, MouseY, Code; @@ -1700,7 +1727,7 @@ static void checkFiles(void) { /* Processes user input. */ /*****************************************************************************/ static uint16 processSaveRestore(uint16 type) { - struct IntuiMessage *Msg; + IntuiMessage *Msg; uint32 Class; uint16 Qualifier, MouseX, MouseY, Code, Temp; @@ -1913,7 +1940,8 @@ static uint16 monpage; static const char *TextFileName; -struct Image *MonButton, *AltMonButton, *MonQuit, *AltMonQuit, *MonBack, *AltMonBack, *MonDown, *AltMonDown, *MonUp, *AltMonUp; +Image *MonButton, *AltMonButton, *MonQuit, *AltMonQuit, *MonBack, *AltMonBack, + *MonDown, *AltMonDown, *MonUp, *AltMonUp; @@ -2004,7 +2032,7 @@ static void drawMonText(char *text, uint16 x1, uint16 y1, uint16 x2, uint16 y2, /* Processes user input. */ /*****************************************************************************/ static void processMonitor(char *ntext, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2) { - struct IntuiMessage *Msg; + IntuiMessage *Msg; uint32 Class; uint16 Qualifier, Code, MouseX, MouseY; const char *Test = " ", *StartFileName = TextFileName; @@ -2158,7 +2186,7 @@ void doMonitor(char *background, char *textfile, bool isinteractive, uint16 x1, #if defined(LABDEMO) void doTrialBlock() { - struct IntuiMessage *Msg; + IntuiMessage *Msg; uint32 Class; uint16 Qualifier, MouseX, MouseY, Code, Temp; -- cgit v1.2.3 From 60d4f0a0695f8eaf5aced2df7dfe3c191e37ae25 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sat, 27 Dec 2014 14:18:40 +0100 Subject: LAB: Initial support for lowres mode --- engines/lab/special.cpp | 92 +++---------------------------------------------- 1 file changed, 4 insertions(+), 88 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 3ab548a82e..038f8b88b6 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -187,9 +187,7 @@ static void changeCombination(uint16 number) { } else waitTOF(); -#if !defined(DOSCODE) display.ImageData = getVGABaseAddr(); -#endif scrollDisplayY(2, VGAScaleX(combx[number]), VGAScaleY(65), VGAScaleX(combx[number]) + (Images[combnum])->Width - 1, VGAScaleY(65) + (Images[combnum])->Height); @@ -204,9 +202,7 @@ static void changeCombination(uint16 number) { else g_lab->_conditions->exclElement(COMBINATIONUNLOCKED); -#if !defined(DOSCODE) ungetVGABaseAddr(); -#endif } @@ -248,9 +244,6 @@ void mouseCombination(uint16 x, uint16 y) { /*----------------------------- Tile Puzzle Rules ----------------------------*/ /*----------------------------------------------------------------------------*/ - - - Image *Tiles[16]; int16 CurTile[4] [4] = { { 1, 5, 9, 13 }, @@ -703,14 +696,12 @@ static bool loadJournalData() { BackG.Im = JLeft; BackG.ImAlt = JLeftAlt; -#if !defined(DOSCODE) BackG.KeyEquiv = VKEY_LTARROW; -#endif + ForwardG.Im = JRight; ForwardG.ImAlt = JRightAlt; -#if !defined(DOSCODE) ForwardG.KeyEquiv = VKEY_RTARROW; -#endif + CancelG.Im = JCancel; CancelG.ImAlt = JCancelAlt; @@ -785,18 +776,14 @@ static void turnPage(bool FromLeft) { for (counter = 0; counter < VGAScreenWidth; counter += 8) { g_music->updateMusic(); waitTOF(); -#if !defined(DOSCODE) ScreenImage.ImageData = getVGABaseAddr(); -#endif bltBitMap(&JBackImage, counter, 0, &ScreenImage, counter, 0, 8, VGAScreenHeight); } } else { for (counter = (VGAScreenWidth - 8); counter > 0; counter -= 8) { g_music->updateMusic(); waitTOF(); -#if !defined(DOSCODE) ScreenImage.ImageData = getVGABaseAddr(); -#endif bltBitMap(&JBackImage, counter, 0, &ScreenImage, counter, 0, 8, VGAScreenHeight); } } @@ -819,9 +806,7 @@ static void drawJournal(uint16 wipenum, bool needFade) { drawJournalText(); -#if !defined(DOSCODE) ScreenImage.ImageData = getVGABaseAddr(); -#endif if (wipenum == 0) bltBitMap(&JBackImage, 0, 0, &ScreenImage, 0, 0, VGAScreenWidth, VGAScreenHeight); @@ -838,9 +823,7 @@ static void drawJournal(uint16 wipenum, bool needFade) { else unGhoastGadget(&ForwardG); -#if !defined(DOSCODE) ungetVGABaseAddr(); -#endif if (needFade) @@ -948,9 +931,7 @@ void doJournal() { fade(false, 0); mouseHide(); -#if !defined(DOSCODE) ScreenImage.ImageData = getVGABaseAddr(); -#endif setAPen(0); rectFill(0, 0, VGAScreenWidth - 1, VGAScreenHeight - 1); @@ -958,9 +939,7 @@ void doJournal() { journalCleanUp(); -#if !defined(DOSCODE) ungetVGABaseAddr(); -#endif } @@ -996,64 +975,6 @@ static char DriveName[5] [MAXDEVNAMES]; /* and returned the number of drives that it found. */ /*****************************************************************************/ uint16 doDisks(void) { -#if defined(DOSCODE) - uint16 many = 0, counter = 2; - union REGS regs; - char str[5]; - - if (manydisks) - return manydisks; - - while ((counter < 7) && (many < MAXDEVNAMES)) { - memset(®s, 0, sizeof(regs)); - /* - regs.h.ah = 0x32; - regs.h.dl = counter+1; - int386(0x21, ®s, ®s); - if (regs.h.al == 0) - { - */ - regs.h.ah = 0x36; - regs.h.dl = counter + 1; - int386(0x21, ®s, ®s); - - if (regs.w.ax != 0xFFFF) { - str[0] = counter + 'A'; - str[1] = ':'; - str[2] = '\\'; - str[3] = 0; - strcpy(DriveName[many], str); - many++; - } - - counter++; - } - - return many; -#elif defined(WIN32) - extern void winGetDriveLetters(char cdLetters[], int size); - char letters[28]; - char str[5]; - uint16 many = 0, counter = 2; - - if (manydisks) - return manydisks; - - winGetDriveLetters(letters, 28); - - while ((counter < 7) && (many < MAXDEVNAMES) && letters[many] != 0) { - str[0] = letters[many]; - str[1] = ':'; - str[2] = '\\'; - str[3] = 0; - strcpy(DriveName[many], str); - many++; - counter++; - } - - return many; -#else - // !!!!goofy test code char str[5]; str[0] = 'C'; str[1] = ':'; @@ -1061,13 +982,8 @@ uint16 doDisks(void) { str[3] = 0; strcpy(DriveName[0], str); return 1; -#endif } - - - - /*****************************************************************************/ /* Does the user interface to save or restore a game position */ /*****************************************************************************/ @@ -1222,8 +1138,8 @@ static void drawSaveLoad() { thumbnail.Width = 128; thumbnail.Height = 72; thumbnail.ImageData = g_SaveGameInfo[j].SaveGameImage; - screen.Width = 640; - screen.Height = 480; + screen.Width = VGAScreenWidth; + screen.Height = VGAScreenHeight; screen.ImageData = getVGABaseAddr(); bltBitMap(&thumbnail, 0, 0, &screen, 72, 67 + i * 75, 128, 72); ungetVGABaseAddr(); -- cgit v1.2.3 From 4f185f7dd6f82c86ab9b66fc10209fa966654806 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 17 Feb 2015 11:23:22 +0200 Subject: LAB: Further fixes to signed/unsigned comparisons and bool assignments --- engines/lab/special.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 038f8b88b6..abdbc735d3 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -126,7 +126,7 @@ static void doCombination(void) { } -extern char *TempScrollData; +extern byte *TempScrollData; /*****************************************************************************/ /* Reads in a backdrop picture. */ @@ -245,7 +245,7 @@ void mouseCombination(uint16 x, uint16 y) { /*----------------------------------------------------------------------------*/ Image *Tiles[16]; -int16 CurTile[4] [4] = { +uint16 CurTile[4] [4] = { { 1, 5, 9, 13 }, { 2, 6, 10, 14 }, { 3, 7, 11, 15 }, @@ -1338,7 +1338,7 @@ static bool processSaveLoad() { if (((Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) || ((Class == RAWKEY) && (Code == 27))) - return -1; + return true; if (Class == RAWKEY) { if (Code == 'l' || Code == 'L') { @@ -1422,7 +1422,7 @@ static bool processSaveLoad() { break; case ID_CANCEL: - return -1; + return true; } } } -- cgit v1.2.3 From 0a71969018bf773cde8092df47f58ecea99f3f79 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 19 Feb 2015 15:41:15 +0200 Subject: LAB: Rewrite the save/load system The two different save/load dialogs from the original have been dropped and replaced with the ScummVM save/load dialogs. The whole save/load code has been rewritten to be endian safe and use our common code. The original save format has not been preserved. The current implementation crashes when loading, but it's a good start --- engines/lab/special.cpp | 922 +++--------------------------------------------- 1 file changed, 43 insertions(+), 879 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index abdbc735d3..495fe455c4 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -28,6 +28,11 @@ * */ +#include "common/translation.h" + +#include "gui/message.h" +#include "gui/saveload.h" + #include "lab/lab.h" #include "lab/labfun.h" #include "lab/parsefun.h" @@ -40,12 +45,6 @@ #include "lab/stddefines.h" #include "lab/parsetypes.h" -#define MODERNGAMESAVE 1 - -#if defined(MODERNGAMESAVE) -#include "lab/modernsavegame.h" -#endif - namespace Lab { #ifdef GAME_TRIAL @@ -109,7 +108,7 @@ static byte *loadBackPict(const char *fileName, bool tomem) { static Image *Images[10]; -uint16 combination[6] = {0, 0, 0, 0, 0, 0}, solution[] = {0, 4, 0, 8, 7, 2}; +byte combination[6] = {0, 0, 0, 0, 0, 0}, solution[] = {0, 4, 0, 8, 7, 2}; static uint16 combx[] = {45, 83, 129, 166, 211, 248}; @@ -942,528 +941,57 @@ void doJournal() { ungetVGABaseAddr(); } +/* +struct SaveGameInfo { + unsigned short RoomNumber; + unsigned short Direction; + byte *SaveGameImage; + char SaveGameDate[128]; +}; +int getSaveGameList(SaveGameInfo *info, int maxNum); +*/ -/*---------------------------------------------------------------------------*/ -/*------------------------- The Save/Restore stuff --------------------------*/ -/*---------------------------------------------------------------------------*/ - - -Image *Arrow1, *NoArrow1, *DriveButton; - +#define QUARTERNUM 30 extern InventoryData *Inventory; extern uint16 RoomNum, Direction; -extern char *SAVETEXT, *LOADTEXT, *BOOKMARKTEXT, *PERSONALTEXT, *DISKTEXT, *SAVEBOOK, *RESTOREBOOK, *SAVEFLASH, *RESTOREFLASH, *SAVEDISK, *RESTOREDISK, *SELECTDISK, *NODISKINDRIVE, *WRITEPROTECTED, *FORMATFLOPPY, *FORMATTING; - -static uint16 device; - -#define MAXDEVNAMES 5 - -static char DriveName[5] [MAXDEVNAMES]; - - - - - - -/*----- Gets the devices -----*/ - -/*****************************************************************************/ -/* Finds all the disk drives, puts them in an array of strings, sorts them, */ -/* and returned the number of drives that it found. */ -/*****************************************************************************/ -uint16 doDisks(void) { - char str[5]; - str[0] = 'C'; - str[1] = ':'; - str[2] = '\\'; - str[3] = 0; - strcpy(DriveName[0], str); - return 1; -} - -/*****************************************************************************/ -/* Does the user interface to save or restore a game position */ -/*****************************************************************************/ -#if defined(MODERNGAMESAVE) - -extern const byte ThePalMap[]; - -void getRoomMessage(int MyRoomNum, int MyDirection, char *msg); - -#define QUARTERNUM 30 - -#define NEXTEMPTYSLOTTEXT "Next Empty Slot" - -extern char g_SaveGamePath[512]; -extern char g_PathSeperator[4]; - -SaveGameInfo g_SaveGameInfo[MAX_SAVED_GAMES]; -int g_TotalSavedGames; -char g_CommonPalette[3 * 256]; -int g_LastSaveGameNumber = 0; -int g_CurSaveGameNumber = 0; -int g_CurSaveSet = 0; -int g_PendingNewSave = 0; - -enum UI_Ident { - ID_SAVE, - ID_LOAD, - ID_NEWSLOT, - ID_1_TO_5, - ID_6_TO_10, - ID_11_TO_15, - ID_SLOT_A, - ID_SLOT_B, - ID_SLOT_C, - ID_SLOT_D, - ID_SLOT_E, - ID_CANCEL, - ID_LAST -}; - -struct ModernUI { - int id; - int x, y, w, h; -}; - -ModernUI theUI[ID_LAST] = { - { ID_LOAD, 491, 182, 128, 54 }, - { ID_SAVE, 491, 255, 128, 54 }, - { ID_NEWSLOT, 491, 328, 128, 54 }, - { ID_1_TO_5, 27, 40, 146, 25 }, - { ID_6_TO_10, 175, 40, 146, 25 }, - { ID_11_TO_15, 323, 40, 146, 25 }, - { ID_SLOT_A, 27, 67, 442, 72 }, - { ID_SLOT_B, 27, 142, 442, 72 }, - { ID_SLOT_C, 27, 217, 442, 72 }, - { ID_SLOT_D, 27, 292, 442, 72 }, - { ID_SLOT_E, 27, 367, 442, 72 }, - { ID_CANCEL, 531, 405, 52, 52 } -}; - -enum { - SG_BLACK = 1, - SG_TAN = 14, - SG_DKTAN = 38, - SG_WHITE = 105, - SG_YELLOW = 118 -}; - -/*****************************************************************************/ -/* Draw display */ -/*****************************************************************************/ -static void flowTextBold(void *font, /* the TextAttr pointer */ - uint16 spacing, /* How much vertical spacing between the lines */ - uint16 pencolor, /* pen number to use for text */ - uint16 backpen, /* the background color */ - bool outline, /* Whether to outline in background color */ - bool centerh, /* Whether to center the text horizontally */ - bool centerv, /* Whether to center the text vertically */ - bool output, /* Whether to output any text */ - uint16 x1, /* Cords */ - uint16 y1, uint16 x2, uint16 y2, const char *text) { /* The text itself */ - - if (outline) { - flowText(font, spacing, backpen, 0, false, centerh, centerv, output, x1 - 1, y1, x2 - 1, y2, text); - flowText(font, spacing, backpen, 0, false, centerh, centerv, output, x1 - 1, y1 - 1, x2 - 1, y2 - 1, text); - flowText(font, spacing, backpen, 0, false, centerh, centerv, output, x1, y1 + 2, x2, y2 + 2, text); - flowText(font, spacing, backpen, 0, false, centerh, centerv, output, x1 - 1, y1 + 2, x2 - 1, y2 + 2, text); - flowText(font, spacing, backpen, 0, false, centerh, centerv, output, x1 + 2, y1, x2 + 2, y2, text); - flowText(font, spacing, backpen, 0, false, centerh, centerv, output, x1 + 2, y1 + 2, x2 + 2, y2 + 2, text); - flowText(font, spacing, backpen, 0, false, centerh, centerv, output, x1, y1 - 1, x2, y2 - 1, text); - flowText(font, spacing, backpen, 0, false, centerh, centerv, output, x1 + 2, y1 - 1, x2 + 2, y2 - 1, text); - } - - flowText(font, spacing, pencolor, 0, false, centerh, centerv, output, x1, y1, x2, y2, text); - flowText(font, spacing, pencolor, 0, false, centerh, centerv, output, x1 + 1, y1, x2 + 1, y2, text); - flowText(font, spacing, pencolor, 0, false, centerh, centerv, output, x1, y1 + 1, x2, y2 + 1, text); - flowText(font, spacing, pencolor, 0, false, centerh, centerv, output, x1 + 1, y1 + 1, x2 + 1, y2 + 1, text); -} - -/*****************************************************************************/ -/* Draw display */ -/*****************************************************************************/ -static void flowTextShadow(void *font, /* the TextAttr pointer */ - uint16 spacing, /* How much vertical spacing between the lines */ - uint16 pencolor, /* pen number to use for text */ - uint16 backpen, /* the background color */ - bool outline, /* Whether to outline in background color */ - 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, char *text) { /* The text itself */ - - if (outline) { - flowText(font, spacing, backpen, 0, false, centerh, centerv, output, x1 - 1, y1 - 1, x2 - 1, y2 - 1, text); - flowText(font, spacing, backpen, 0, false, centerh, centerv, output, x1 - 1, y1 + 1, x2 - 1, y2 + 1, text); - flowText(font, spacing, backpen, 0, false, centerh, centerv, output, x1 + 1, y1 + 1, x2 + 1, y2 + 1, text); - flowText(font, spacing, backpen, 0, false, centerh, centerv, output, x1 + 1, y1 - 1, x2 + 1, y2 - 1, text); - } - - flowText(font, spacing, pencolor, 0, false, centerh, centerv, output, x1, y1, x2, y2, text); -} - -static void drawSaveLoad() { - int i, j; - - flowTextBold(MsgFont, 0, g_CurSaveGameNumber < g_TotalSavedGames ? SG_YELLOW : SG_DKTAN, SG_BLACK, true, true, true, true, 491 + 3, 182, 619 + 3, 236, LOADTEXT); - flowTextBold(MsgFont, 0, g_TotalSavedGames + g_PendingNewSave > 0 ? SG_YELLOW : SG_DKTAN, SG_BLACK, true, true, true, true, 491 + 3, 255, 619 + 3, 309, SAVETEXT); - flowTextBold(MsgFont, 0, g_PendingNewSave ? SG_DKTAN : SG_YELLOW, SG_BLACK, true, true, true, true, 491 + 3, 328, 619 + 3, 382, NEXTEMPTYSLOTTEXT); - - flowTextBold(MsgFont, 0, (g_CurSaveSet == 0 ? SG_YELLOW : SG_WHITE), SG_BLACK, true, true, true, true, 27 + 3, 40, 175 + 3, 65, "Saves 1-5"); - flowTextBold(MsgFont, 0, (g_CurSaveSet == 1 ? SG_YELLOW : SG_WHITE), SG_BLACK, true, true, true, true, 175 + 3, 40, 321 + 3, 65, "Saves 6-10"); - flowTextBold(MsgFont, 0, (g_CurSaveSet == 2 ? SG_YELLOW : SG_WHITE), SG_BLACK, true, true, true, true, 323 + 3, 40, 469 + 3, 65, "Saves 11-15"); - - for (i = 0, j = 5 * g_CurSaveSet; i < 5; i++, j++) { - uint16 hue, y; - char num_text[4]; - Image thumbnail, screen; - - if (j < g_TotalSavedGames + g_PendingNewSave) { - char msg[256]; - - getRoomMessage(g_SaveGameInfo[j].RoomNumber, g_SaveGameInfo[j].Direction, msg); - - hue = (j == g_CurSaveGameNumber ? SG_YELLOW : SG_WHITE); - y = 67 + 2 + i * 75; - flowText(MsgFont, 0, hue, 0, false, false, false, true, 202 + 2, y, 469 - 2, y + 48, msg); - y += 46; - flowText(MsgFont, 0, hue, 0, false, false, false, true, 202 + 2, y, 469 - 2, y + 24, g_SaveGameInfo[j].SaveGameDate); - - // blast image - thumbnail.Width = 128; - thumbnail.Height = 72; - thumbnail.ImageData = g_SaveGameInfo[j].SaveGameImage; - screen.Width = VGAScreenWidth; - screen.Height = VGAScreenHeight; - screen.ImageData = getVGABaseAddr(); - bltBitMap(&thumbnail, 0, 0, &screen, 72, 67 + i * 75, 128, 72); - ungetVGABaseAddr(); - - hue = (j == g_CurSaveGameNumber ? SG_YELLOW : SG_WHITE); - } else { - y = 67 + 2 + i * 75; - flowText(MsgFont, 0, SG_TAN, 0, false, true, true, true, 202 + 2, y, 469 - 2, y + 70, "[Empty Slot]"); - - hue = SG_DKTAN; - } - - y = 67 + i * 75; - sprintf(num_text, "%d", j + 1); - flowTextShadow(BigMsgFont, 0, hue, SG_BLACK, true, true, true, true, 27 + 4, y, 72 + 4, y + 72, num_text); - } - - // Add ".1" to version number - setAPen(SG_WHITE); - rectFill(271, 454, 271, 454); - rectFill(275, 449, 275, 454); - rectFill(274, 450, 274, 450); - rectFill(274, 454, 276, 454); - - WSDL_UpdateScreen(); -} - -static void makeThumbnail(SaveGameInfo *info) { - char *pictName; - CloseDataPtr CPtr = NULL; - byte *BitMapMem; - int x, y, u, v; - - // load pict - pictName = getPictName(&CPtr); - nopalchange = true; - BitMapMem = readPictToMem(pictName, VGAScreenWidth, VGAScreenHeight); - nopalchange = false; - - for (y = 0; y < 72; y++) { - for (x = 0; x < 128; x++) { - unsigned int r = 0, g = 0, b = 0; - - for (v = 5 * y; v < 5 * y + 5; v++) { - for (u = 5 * x; u < 5 * x + 5; u++) { - byte n = (byte)BitMapMem[u + v * VGAScreenWidth]; - // 6-bit color (VGA) - r += (unsigned int)diffcmap[3 * n + 0]; - g += (unsigned int)diffcmap[3 * n + 1]; - b += (unsigned int)diffcmap[3 * n + 2]; - } +bool saveRestoreGame(void) { + bool isOK = false; + + // The original had one screen for saving/loading. We have two. + // Ask the user which screen to use. + GUI::MessageDialog saveOrLoad(_("Would you like to save or restore a game?"), _("Save"), _("Restore")); + + int choice = saveOrLoad.runModal(); + if (choice == GUI::kMessageOK) { + // Save + GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save"), true); + int slot = dialog->runModalWithCurrentTarget(); + if (slot >= 0) { + Common::String desc = dialog->getResultString(); + + if (desc.empty()) { + // create our own description for the saved game, the user didn't enter it + desc = dialog->createDefaultSaveDescription(slot); } - r = (r / 25) >> 1; - g = (g / 25) >> 1; - b = (b / 25) >> 1; - warning("STUB: makeThumbnail"); - info->SaveGameImage[x + 128 * y] = ThePalMap[(r << 10) | (g << 5) | b]; + isOK = saveGame(RoomNum, Direction, Inventory[QUARTERNUM].Many, slot, desc); } - } -} - -static void addSaveSlot() { - SaveGameInfo *info; - - if (g_PendingNewSave || g_TotalSavedGames == MAX_SAVED_GAMES) - return; - - g_PendingNewSave = 1; - g_CurSaveGameNumber = g_TotalSavedGames; - g_CurSaveSet = g_CurSaveGameNumber / 5; - - // set-up saved game - info = &g_SaveGameInfo[g_CurSaveGameNumber]; - info->RoomNumber = RoomNum; - info->Direction = Direction; - - // not really a date yet - strcpy(info->SaveGameDate, "Click SAVE GAME to Confirm"); - - info->SaveGameImage = (byte *)malloc(SAVED_IMAGE_SIZE); - makeThumbnail(info); - - mouseHide(); - WSDL_IgnoreUpdateDisplay(1); - loadBackPict("P:ModSave", false); - WSDL_IgnoreUpdateDisplay(0); - drawSaveLoad(); - mouseShow(); -} - -static void selectSave(int n) { - if (g_CurSaveGameNumber == n || n >= g_TotalSavedGames + g_PendingNewSave) - return; - - g_CurSaveGameNumber = n; - - mouseHide(); - WSDL_IgnoreUpdateDisplay(1); - loadBackPict("P:ModSave", false); - WSDL_IgnoreUpdateDisplay(0); - drawSaveLoad(); - mouseShow(); -} - -static void selectSaveSet(int n) { - if (g_CurSaveSet != n) { - g_CurSaveSet = n; - - mouseHide(); - WSDL_IgnoreUpdateDisplay(1); - loadBackPict("P:ModSave", false); - WSDL_IgnoreUpdateDisplay(0); - drawSaveLoad(); - mouseShow(); - } -} - -/*****************************************************************************/ -/* Do modern save. */ -/*****************************************************************************/ -static bool doSaveGame() { - bool isok; - char DrivePath[260]; - - if (g_CurSaveGameNumber != g_TotalSavedGames) { - makeThumbnail(&g_SaveGameInfo[g_CurSaveGameNumber]); } else { - // set time of save for new saved game - //struct tm *create_date; - //time_t ticks; - - warning("STUB: doSaveGame"); - //ticks = time(NULL); - //create_date = localtime(&ticks); - //strcpy(g_SaveGameInfo[g_CurSaveGameNumber].SaveGameDate, asctime(create_date)); + // Restore + GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Restore game:"), _("Restore"), false); + int slot = dialog->runModalWithCurrentTarget(); + if (slot >= 0) + isOK = loadGame(&RoomNum, &Direction, &(Inventory[QUARTERNUM].Many), slot); } - memcpy(g_SaveGameImage, g_SaveGameInfo[g_CurSaveGameNumber].SaveGameImage, SAVED_IMAGE_SIZE); - - sprintf(DrivePath, "%s%s%d", g_SaveGamePath, g_PathSeperator, g_CurSaveGameNumber); - - isok = saveFloppy(DrivePath, RoomNum, Direction, Inventory[QUARTERNUM].Many, g_CurSaveGameNumber, device); - g_music->resetMusic(); - - if (isok) - g_LastSaveGameNumber = g_CurSaveGameNumber; - - return isok; -} - -/*****************************************************************************/ -/* Do modern load. */ -/*****************************************************************************/ -static bool doLoadGame() { - bool isok; - char drivePath[260]; - - snprintf(drivePath, 260, "%s%s%d", g_SaveGamePath, g_PathSeperator, g_CurSaveGameNumber); - - isok = readFloppy(drivePath, &RoomNum, &Direction, &(Inventory[QUARTERNUM].Many), g_CurSaveGameNumber, device); - g_music->resetMusic(); - - if (isok) - g_LastSaveGameNumber = g_CurSaveGameNumber; - - return isok; -} - -/*****************************************************************************/ -/* Processes user input. */ -/*****************************************************************************/ -static bool processSaveLoad() { - IntuiMessage *Msg; - - uint32 Class; - uint16 Qualifier, MouseX, MouseY, Code; - int i; - - drawSaveLoad(); - - while (1) { - g_music->checkMusic(); /* Make sure we check the music at least after every message */ - Msg = getMsg(); - - if (Msg == NULL) { - g_music->newCheckMusic(); - } else { - Class = Msg->Class; - Qualifier = Msg->Qualifier; - MouseX = Msg->MouseX; - MouseY = Msg->MouseY; - Code = Msg->Code; - - replyMsg(Msg); - - if (((Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) || - ((Class == RAWKEY) && (Code == 27))) - return true; - - if (Class == RAWKEY) { - if (Code == 'l' || Code == 'L') { - if (g_CurSaveGameNumber < g_TotalSavedGames) - return doLoadGame(); - } else if (Code == 's' || Code == 'S') { - if (g_TotalSavedGames + g_PendingNewSave > 0) - return doSaveGame(); - } else if (Code == 'n' || Code == 'N') { - addSaveSlot(); - } else if (Code == VKEY_LTARROW) { - i = g_CurSaveSet - 1; - - if (i < 0) i = 2; - - selectSaveSet(i); - } else if (Code == VKEY_RTARROW) { - i = g_CurSaveSet + 1; - - if (i > 2) i = 0; - - selectSaveSet(i); - } else if (Code == VKEY_UPARROW) { - if (g_TotalSavedGames + g_PendingNewSave > 0) { - i = g_CurSaveGameNumber - 1; - - if (i < 0) - i = g_TotalSavedGames + g_PendingNewSave - 1; - - if (i / 5 != g_CurSaveSet) - selectSaveSet(i / 5); - - selectSave(i); - } - } else if (Code == VKEY_DNARROW) { - if (g_TotalSavedGames + g_PendingNewSave > 0) { - i = g_CurSaveGameNumber + 1; - - if (i >= g_TotalSavedGames + g_PendingNewSave) - i = 0; - - if (i / 5 != g_CurSaveSet) - selectSaveSet(i / 5); - - selectSave(i); - } - } - } else if ((Class == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & Qualifier)) { - for (i = 0; i < ID_LAST; i++) { - if (MouseX >= theUI[i].x && MouseY >= theUI[i].y && - MouseX < theUI[i].x + theUI[i].w && MouseY < theUI[i].y + theUI[i].h) { - switch (theUI[i].id) { - case ID_SAVE: - if (g_TotalSavedGames + g_PendingNewSave > 0) - return doSaveGame(); - - break; - - case ID_LOAD: - if (g_CurSaveGameNumber < g_TotalSavedGames) - return doLoadGame(); - - break; - - case ID_NEWSLOT: - addSaveSlot(); - break; - - case ID_1_TO_5: - case ID_6_TO_10: - case ID_11_TO_15: - selectSaveSet(theUI[i].id - ID_1_TO_5); - break; - - case ID_SLOT_A: - case ID_SLOT_B: - case ID_SLOT_C: - case ID_SLOT_D: - case ID_SLOT_E: - selectSave(5 * g_CurSaveSet + theUI[i].id - ID_SLOT_A); - break; - - case ID_CANCEL: - return true; - } - } - } - } - } - } -} - -bool saveRestoreGame(void) { - byte **buffer; - bool isok = true; - - blackAllScreen(); - - BigMsgFont = &bmfont; - - if (!getFont("P:Map.fon", BigMsgFont)) { - BigMsgFont = NULL; - return false; - } - - buffer = g_music->newOpen("P:ModSave"); - - if (!buffer) { - freeAllStolenMem(); + if (!isOK) return false; - } - - g_TotalSavedGames = getSaveGameList(g_SaveGameInfo, MAX_SAVED_GAMES); - g_CurSaveGameNumber = g_LastSaveGameNumber; - g_CurSaveSet = g_CurSaveGameNumber / 5; - g_PendingNewSave = 0; - - loadBackPict("P:ModSave", false); - - mouseShow(); - VGASetPal(diffcmap, 256); - memcpy(g_CommonPalette, diffcmap, 3 * 256); + g_music->resetMusic(); - isok = processSaveLoad(); eatMessages(); mouseHide(); @@ -1478,373 +1006,9 @@ bool saveRestoreGame(void) { freeAllStolenMem(); - freeSaveGameList(g_SaveGameInfo, g_TotalSavedGames); - - return isok; -} -#else - -static uint16 manydisks = 0; - -static uint16 issave, ghoast, arrow, ManyDrives, DriveInitX, DriveNum = -1, FileNum = -1; - -/*****************************************************************************/ -/* Draws the number arrows. */ -/*****************************************************************************/ -static void doNumArrows(void) { - uint16 counterx, countery, curnum, cordx[3], cordy[3]; - - cordx[0] = VGAScaleX(53) + SVGACord(3); - cordx[1] = VGAScaleX(126) + SVGACord(1); - cordx[2] = VGAScaleX(197) + SVGACord(3); - - cordy[0] = VGAScaleY(58) + SVGACord(2); - cordy[1] = VGAScaleY(86) + SVGACord(3); - cordy[2] = VGAScaleY(114) + SVGACord(3); - - mouseHide(); - - for (countery = 0; countery < 3; countery++) { - for (counterx = 0; counterx < 3; counterx++) { - curnum = countery + counterx * 3; - - if INBIT(arrow, curnum) - drawImage(Arrow1, cordx[counterx], cordy[countery]); - else - drawImage(NoArrow1, cordx[counterx], (int32) cordy[countery]); - - if INBIT(ghoast, curnum) - ghoastRect(0, cordx[counterx], cordy[countery], cordx[counterx] + VGAScaleX(69), cordy[countery] + NoArrow1->Height); - } - } - - mouseShow(); -} - -/*****************************************************************************/ -/* Does the drive buttons for the final save/restore screen. */ -/*****************************************************************************/ -static void doDriveButtons(void) { - uint16 curx, counter; - - if (ManyDrives > 5) - ManyDrives = 5; - - DriveInitX = (VGAScreenWidth / 2) - ((ManyDrives * DriveButton->Width) / 2); - curx = DriveInitX; - - mouseHide(); - - for (counter = 0; counter < ManyDrives; counter++) { - drawImage(DriveButton, curx, VGAScaleY(153)); - - flowText(BigMsgFont, 0, 1, 0, false, true, true, true, curx + VGAScaleX(5), VGAScaleY(158), curx + DriveButton->Width - VGAScaleX(5), VGAScaleY(148) + DriveButton->Height, DriveName[counter]); - - curx += DriveButton->Width; - } - - mouseShow(); -} - - -static void drawSRMessage(char *rtext) { - mouseHide(); - flowText(BigMsgFont, 0, 1, 10, true, true, true, true, VGAScaleX(22), VGAScaleY(21), VGAScaleX(289), VGAScaleY(48), rtext); - mouseShow(); -} - -/*****************************************************************************/ -/* Draws the correct message to the message box. */ -/*****************************************************************************/ -static void doSaveRestoreText(void) { - char *rtext, text[100]; - - if (DriveNum >= ManyDrives) { - rtext = SELECTDISK; - } else if (issave) { - strcpy(text, SAVEDISK); - strcat(text, " "); - strcat(text, DriveName[DriveNum]); - rtext = text; - } else { - strcpy(text, RESTOREDISK); - strcat(text, " "); - strcat(text, DriveName[DriveNum]); - rtext = text; - } - - drawSRMessage(rtext); -} - -static uint16 processSaveRestore(uint16 type); - -static char DrivePath[50]; - -/*****************************************************************************/ -/* Checks for the existence of previous saved game positions on disk. */ -/*****************************************************************************/ -static void floppyCheckFiles(void) { - char temp[7], *name, len; - int fl; - uint16 counter; - - doSaveRestoreText(); - - arrow = 0; - ghoast = 0; - - strcpy(DrivePath, DriveName[DriveNum]); - strcat(DrivePath, "LabSaves"); - - warning("STUB: floppyCheckFiles"); - -#if 0 -#if defined(WIN32) - mkdir(DrivePath); -#else - mkdir(DrivePath, 0x644); -#endif - strcat(DrivePath, "\\"); - - len = strlen(DrivePath); - - for (counter = 0; counter < 9; counter++) { - name = numtostr(temp, counter); - strcat(DrivePath, name); - - if ((fl = open(DrivePath, O_RDONLY)) != -1) { - close(fl); - SETBIT(arrow, counter); - } else - SETBIT(ghoast, counter); - - DrivePath[len] = 0; - } -#endif -} - -/*****************************************************************************/ -/* Checks for the existence of previously saved game positions. */ -/*****************************************************************************/ -static void checkFiles(void) { - ghoast = -1; - arrow = 0; - - g_music->fillUpMusic(true); - - /* NYI: check for empty drive */ - floppyCheckFiles(); - - if (issave) - ghoast = 0; -} - -/*****************************************************************************/ -/* Processes user input. */ -/*****************************************************************************/ -static uint16 processSaveRestore(uint16 type) { - IntuiMessage *Msg; - - uint32 Class; - uint16 Qualifier, MouseX, MouseY, Code, Temp; - - while (1) { - g_music->checkMusic(); /* Make sure we check the music at least after every message */ - Msg = getMsg(); - - if (Msg == NULL) { - g_music->newCheckMusic(); - } else { - Class = Msg->Class; - Qualifier = Msg->Qualifier; - MouseX = Msg->MouseX; - MouseY = Msg->MouseY; - Code = Msg->Code; - - replyMsg(Msg); - - if (((Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) || - ((Class == RAWKEY) && (Code == 27))) - return -1; - - else if ((Class == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & Qualifier)) { - if (type == 0) { /* The save or restore screen */ - if ((MouseX >= VGAScaleX(64)) && (MouseX <= VGAScaleX(257))) { - if ((MouseY >= VGAScaleY(57)) && (MouseY <= VGAScaleY(92))) - return true; - else if ((MouseY >= VGAScaleY(108)) && (MouseY <= VGAScaleY(142))) - return false; - } - } - - else if (type == 2) { /* The files screen */ - if ((MouseY >= VGAScaleY(153)) && (MouseY <= VGAScaleY(180))) { /* the drive buttons */ - Temp = ((MouseX - DriveInitX) / DriveButton->Width); - - if (Temp < ManyDrives) { - DriveNum = Temp; - - fade(false, 0); - checkFiles(); - - loadBackPict("P:Disk/Nums.pic", false); - doNumArrows(); - doDriveButtons(); - doSaveRestoreText(); - - fade(true, 0); - } - } - - else if ((MouseX >= VGAScaleX(53)) && (MouseY >= VGAScaleY(58)) && - (MouseX <= VGAScaleX(266)) && (MouseY <= VGAScaleY(142))) { - MouseX = (MouseX - VGAScaleX(53)) / VGAScaleX(71); - MouseY = (MouseY - VGAScaleY(58)) / VGAScaleY(28); - - Temp = MouseY + (MouseX * 3); - - if (!(INBIT(ghoast, Temp))) { - - SETBIT(arrow, Temp); - doNumArrows(); - - FileNum = Temp; - return FileNum; - } - } - } - } - } - } -} - - - - -/*****************************************************************************/ -/* Sets up the Save or Restore screen. */ -/*****************************************************************************/ -static uint16 saveOrRestore(void) { - uint16 res; - - mouseHide(); - loadBackPict("P:Disk/Choose.pic", false); - - flowText(BigMsgFont, 0, 1, 4, false, true, true, true, VGAScaleX(74), VGAScaleY(65), VGAScaleX(247), VGAScaleY(84), SAVETEXT); - flowText(BigMsgFont, 0, 1, 4, false, true, true, true, VGAScaleX(74), VGAScaleY(116), VGAScaleX(247), VGAScaleY(135), LOADTEXT); - mouseShow(); - - fade(true, 0); - res = processSaveRestore(0); - fade(false, 0); - eatMessages(); - - return res; -} - - - - - -/*****************************************************************************/ -/* Sets up the final save/restore screen. */ -/*****************************************************************************/ -static uint16 saveRestore(void) { - uint16 res; - - loadBackPict("P:Disk/Nums.pic", false); - - if ((DriveNum < ManyDrives)) { - checkFiles(); - } else { - ghoast = -1; - arrow = 0; - } - - doNumArrows(); - doDriveButtons(); - doSaveRestoreText(); - g_music->newCheckMusic(); - - eatMessages(); - fade(true, 0); - res = processSaveRestore(2); - fade(false, 0); - - return res; -} - - -#define QUARTERNUM 30 - - -bool saveRestoreGame(void) { - uint16 filenum; - byte **buffer; - char temp[10], *name; - bool isok = true; - - blackAllScreen(); - - ManyDrives = doDisks(); - - FadePalette = hipal; - memset(&(hipal[0]), 0, 32L); - - BigMsgFont = &bmfont; - - if (!getFont("P:Map.fon", BigMsgFont)) { - BigMsgFont = NULL; - return false; - } - - buffer = g_music->newOpen("P:SaveImage"); - - if (!buffer) { - freeAllStolenMem(); - return false; - } - - readImage(buffer, &Arrow1); - readImage(buffer, &NoArrow1); - readImage(buffer, &DriveButton); - - mouseShow(); - - if ((issave = saveOrRestore()) != (uint16) - 1) { - eatMessages(); - - if ((filenum = saveRestore()) != (uint16) - 1) { - name = numtostr(temp, filenum); - strcat(DrivePath, name); - - eatMessages(); - - if (issave) - isok = saveFloppy(DrivePath, RoomNum, Direction, Inventory[QUARTERNUM].Many, filenum, device); - else { - isok = readFloppy(DrivePath, &RoomNum, &Direction, &(Inventory[QUARTERNUM].Many), filenum, device); - g_music->resetMusic(); - } - } - } - - mouseHide(); - setAPen(0); - rectFill(0, 0, VGAScreenWidth - 1, VGAScreenHeight - 1); - blackScreen(); - - journalCleanUp(); - - freeAllStolenMem(); - - return isok; + return true; } -#endif - - - /*---------------------------------------------------------------------------*/ /*--------------------------- The Monitors stuff ----------------------------*/ /*---------------------------------------------------------------------------*/ -- cgit v1.2.3 From 95461c91616eda80b33cfec3597f8c3243748a89 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 19 Feb 2015 15:46:34 +0200 Subject: LAB: Remove the journalCleanUp() wrapper --- engines/lab/special.cpp | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 495fe455c4..3909d974b0 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -887,17 +887,6 @@ static void processJournal() { -/*****************************************************************************/ -/* Cleans up behind all memory allocations. */ -/*****************************************************************************/ -static void journalCleanUp(void) { - freeAllStolenMem(); -} - - - - - /*****************************************************************************/ /* Does the journal processing. */ /*****************************************************************************/ @@ -936,7 +925,7 @@ void doJournal() { rectFill(0, 0, VGAScreenWidth - 1, VGAScreenHeight - 1); blackScreen(); - journalCleanUp(); + freeAllStolenMem(); ungetVGABaseAddr(); } @@ -1002,8 +991,6 @@ bool saveRestoreGame(void) { blackScreen(); WSDL_UpdateScreen(); - journalCleanUp(); - freeAllStolenMem(); return true; -- cgit v1.2.3 From 5bc37fd878e89dbcf3312dedcb0b4cfcd89cda7f Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 19 Feb 2015 19:03:45 +0200 Subject: LAB: Fix loading of saved games --- engines/lab/special.cpp | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 3909d974b0..ae9eb02a37 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -972,28 +972,16 @@ bool saveRestoreGame(void) { // Restore GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Restore game:"), _("Restore"), false); int slot = dialog->runModalWithCurrentTarget(); - if (slot >= 0) + if (slot >= 0) { isOK = loadGame(&RoomNum, &Direction, &(Inventory[QUARTERNUM].Many), slot); + if (isOK) + g_music->resetMusic(); + } } - if (!isOK) - return false; - - g_music->resetMusic(); - - eatMessages(); - - mouseHide(); - memset(diffcmap, 0, 3 * 256); - VGASetPal(diffcmap, 256); - setAPen(0); - rectFill(0, 0, VGAScreenWidth - 1, VGAScreenHeight - 1); - blackScreen(); WSDL_UpdateScreen(); - - freeAllStolenMem(); - - return true; + + return isOK; } /*---------------------------------------------------------------------------*/ -- cgit v1.2.3 From d25d74ef2033835514242584562f7433deeb52c8 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 19 Feb 2015 19:06:35 +0200 Subject: LAB: Remove leftover debug code --- engines/lab/special.cpp | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index ae9eb02a37..f9c793c8e3 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -930,17 +930,6 @@ void doJournal() { ungetVGABaseAddr(); } -/* -struct SaveGameInfo { - unsigned short RoomNumber; - unsigned short Direction; - byte *SaveGameImage; - char SaveGameDate[128]; -}; - -int getSaveGameList(SaveGameInfo *info, int maxNum); -*/ - #define QUARTERNUM 30 extern InventoryData *Inventory; -- cgit v1.2.3 From 6ff7c480af11939feb9546985577c092c4f7074d Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 24 Feb 2015 00:31:26 +0200 Subject: LAB: Remove superfluous void function parameters --- engines/lab/special.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index f9c793c8e3..7d2212138b 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -117,7 +117,7 @@ static uint16 combx[] = {45, 83, 129, 166, 211, 248}; /*****************************************************************************/ /* Draws the images of the combination lock to the display bitmap. */ /*****************************************************************************/ -static void doCombination(void) { +static void doCombination() { uint16 counter; for (counter = 0; counter <= 5; counter++) @@ -513,7 +513,7 @@ static TextFont bmfont; /*****************************************************************************/ /* Does the things to properly set up the detective notes. */ /*****************************************************************************/ -void doNotes(void) { +void doNotes() { char *ntext; /* Load in the data */ @@ -546,7 +546,7 @@ void doNotes(void) { /* Does the things to properly set up the old west newspaper. Assumes that */ /* OpenHiRes already called. */ /*****************************************************************************/ -void doWestPaper(void) { +void doWestPaper() { char *ntext; int32 FileLen, CharsPrinted; uint16 y = 268; @@ -727,7 +727,7 @@ static bool loadJournalData() { /*****************************************************************************/ /* Draws the text to the back journal screen to the appropriate Page number */ /*****************************************************************************/ -static void drawJournalText(void) { +static void drawJournalText() { uint16 DrawingToPage = 1; int32 CharsDrawn = 0L; char *CurText = journaltext; @@ -935,7 +935,7 @@ void doJournal() { extern InventoryData *Inventory; extern uint16 RoomNum, Direction; -bool saveRestoreGame(void) { +bool saveRestoreGame() { bool isOK = false; // The original had one screen for saving/loading. We have two. @@ -993,7 +993,7 @@ Image *MonButton, *AltMonButton, *MonQuit, *AltMonQuit, *MonBack, *AltMonBack, /*****************************************************************************/ /* Makes sure that the buttons are in memory. */ /*****************************************************************************/ -static void getMonImages(void) { +static void getMonImages() { byte **buffer; resetBuffer(); -- cgit v1.2.3 From 219811feaa9fcf23266d97423d013244280cf9f3 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 25 Feb 2015 03:13:26 +0200 Subject: LAB: Add support for the Wyrmkeep Windows trial version Only the trial part of this version can be played in ScummVM, since we can't check for game payment status --- engines/lab/special.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 7d2212138b..74625a63f4 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -47,10 +47,6 @@ namespace Lab { -#ifdef GAME_TRIAL -int g_IsRegistered; -#endif - extern bool nopalchange, DoBlack, IsHiRes; extern BitMap *DispBitMap, *DrawBitMap; @@ -450,12 +446,11 @@ static void changeTile(uint16 col, uint16 row) { return; #endif -#if defined(GAME_TRIAL) - - if (!g_IsRegistered) + if (g_lab->getFeatures() & GF_WINDOWS_TRIAL) { + GUI::MessageDialog trialMessage("This puzzle is not available in the trial version of the game"); + trialMessage.runModal(); return; - -#endif + } check = true; row = 0; -- cgit v1.2.3 From 9a12f6be3fc48f4fa4cc3dc45fce7a0b406bff9b Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 17 Jul 2015 10:45:26 +0300 Subject: LAB: Simplify translateFileName() --- engines/lab/special.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 74625a63f4..603dfbe348 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -1193,7 +1193,7 @@ void doMonitor(char *background, char *textfile, bool isinteractive, uint16 x1, BigMsgFont = &bmfont; - if (!getFont("P:Map.font", BigMsgFont)) { + if (!getFont("P:Map.fon", BigMsgFont)) { freeAllStolenMem(); BigMsgFont = NULL; return; -- cgit v1.2.3 From 4f0c63c0f89aedad21ab41f4b440d0a8b7ae8b6b Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 17 Jul 2015 10:50:04 +0300 Subject: LAB: Merge the VGAScale and setCurClose functions --- engines/lab/special.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 603dfbe348..b8e66626d2 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -363,22 +363,22 @@ static void doTileScroll(uint16 col, uint16 row, uint16 scrolltype) { uint16 counter; if (scrolltype == LEFTSCROLL) { - dX = VGAScaleXs(5); - sx = VGAScaleXs(5); + dX = VGAScaleX(5); + sx = VGAScaleX(5); last = 6; } else if (scrolltype == RIGHTSCROLL) { - dX = VGAScaleXs(-5); - dx = VGAScaleXs(-5); + dX = VGAScaleX(-5); + dx = VGAScaleX(-5); sx = VGAScaleX(5); last = 6; } else if (scrolltype == UPSCROLL) { - dY = VGAScaleYs(5); - sy = VGAScaleYs(5); + dY = VGAScaleY(5); + sy = VGAScaleY(5); last = 5; } else if (scrolltype == DOWNSCROLL) { - dY = VGAScaleYs(-5); - dy = VGAScaleYs(-5); - sy = VGAScaleYs(5); + dY = VGAScaleY(-5); + dy = VGAScaleY(-5); + sy = VGAScaleY(5); last = 5; } @@ -437,9 +437,6 @@ static void changeTile(uint16 col, uint16 row) { } if (scrolltype != -1) { - /* NYI: - readPict("Music:Click", true); - */ doTileScroll(col, row, scrolltype); #if defined(LABDEMO) @@ -933,6 +930,8 @@ extern uint16 RoomNum, Direction; bool saveRestoreGame() { bool isOK = false; + //g_lab->showMainMenu(); + // The original had one screen for saving/loading. We have two. // Ask the user which screen to use. GUI::MessageDialog saveOrLoad(_("Would you like to save or restore a game?"), _("Save"), _("Restore")); @@ -990,17 +989,18 @@ Image *MonButton, *AltMonButton, *MonQuit, *AltMonQuit, *MonBack, *AltMonBack, /*****************************************************************************/ static void getMonImages() { byte **buffer; + uint32 bufferSize; resetBuffer(); - buffer = g_music->newOpen("P:MonImage"); + buffer = g_music->newOpen("P:MonImage", bufferSize); if (!buffer) return; readImage(buffer, &MonButton); - stealBufMem(sizeOfFile("P:MonImage")); /* Trick: protects the memory where the buttons are so they won't be over-written */ + stealBufMem(bufferSize); /* Trick: protects the memory where the buttons are so they won't be over-written */ } @@ -1150,7 +1150,7 @@ static void processMonitor(char *ntext, bool isinteractive, uint16 x1, uint16 y1 TestCPtr = CPtr; MouseY = 64 + (MouseY / MonGadHeight) * 42; MouseX = 101; - setCurCloseAbs(MouseX, MouseY, &CPtr); + setCurClose(MouseX, MouseY, &CPtr, true); if (TestCPtr != CPtr) { LastCPtr[depth] = TestCPtr; -- cgit v1.2.3 From 21e360b9b18e887bb35efaf21a16bf7f97338a35 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 18 Jul 2015 15:28:10 +0300 Subject: LAB: Remove dead/superfluous code, and remove the newCheckMusic() wrapper --- engines/lab/special.cpp | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index b8e66626d2..57f328451d 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -171,10 +171,6 @@ static void changeCombination(uint16 number) { display.Width = VGAScreenWidth; display.Height = VGAScreenHeight; - /* NYI: - readPict("Music:Thunk", true); - */ - for (counter = 1; counter <= (Images[combnum]->Height / 2); counter++) { if (IsHiRes) { if (counter & 1) @@ -725,7 +721,7 @@ static void drawJournalText() { char *CurText = journaltext; while (DrawingToPage < JPage) { - g_music->newCheckMusic(); + g_music->checkMusic(); CurText = (char *)(journaltext + CharsDrawn); CharsDrawn += flowText(BigMsgFont, -2, 2, 0, false, false, false, false, VGAScaleX(52), VGAScaleY(32), VGAScaleX(152), VGAScaleY(148), CurText); @@ -846,14 +842,12 @@ static void processJournal() { Msg = (IntuiMessage *) getMsg(); if (Msg == NULL) { - g_music->newCheckMusic(); + g_music->checkMusic(); } else { Class = Msg->Class; Qualifier = Msg->Qualifier; GadID = Msg->Code; - replyMsg((void *) Msg); - if (((Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) || ((Class == RAWKEY) && (GadID == 27))) return; @@ -1047,7 +1041,7 @@ static void drawMonText(char *text, uint16 x1, uint16 y1, uint16 x2, uint16 y2, } while (DrawingToPage < monpage) { - g_music->newCheckMusic(); + g_music->checkMusic(); CurText = (char *)(text + CharsDrawn); CharsDrawn += flowText(BigMsgFont, yspacing, 0, 0, false, false, false, false, x1, y1, x2, y2, CurText); lastpage = (*CurText == 0); @@ -1105,7 +1099,7 @@ static void processMonitor(char *ntext, bool isinteractive, uint16 x1, uint16 y1 Msg = getMsg(); if (Msg == NULL) { - g_music->newCheckMusic(); + g_music->checkMusic(); } else { Class = Msg->Class; Qualifier = Msg->Qualifier; @@ -1113,8 +1107,6 @@ static void processMonitor(char *ntext, bool isinteractive, uint16 x1, uint16 y1 MouseY = Msg->MouseY; Code = Msg->Code; - replyMsg(Msg); - if (((Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) || ((Class == RAWKEY) && (Code == 27))) return; @@ -1242,7 +1234,7 @@ void doTrialBlock() { Msg = getMsg(); if (Msg == NULL) { - g_music->newCheckMusic(); + g_music->checkMusic(); } else { Class = Msg->Class; Qualifier = Msg->Qualifier; @@ -1250,8 +1242,6 @@ void doTrialBlock() { MouseY = Msg->MouseY; Code = Msg->Code; - replyMsg(Msg); - if (((Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) || ((Class == RAWKEY) && (Code == 27))) return; -- cgit v1.2.3 From eae0773b41143bd0bca7280d62e98c4baf78ab0d Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 21 Jul 2015 22:09:00 +0300 Subject: LAB: Move more static variables to the top --- engines/lab/special.cpp | 214 ++++++++++++------------------------------------ 1 file changed, 53 insertions(+), 161 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 57f328451d..2cd383d03d 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -47,26 +47,69 @@ namespace Lab { -extern bool nopalchange, DoBlack, IsHiRes; - -extern BitMap *DispBitMap, *DrawBitMap; -extern char diffcmap[3 * 256]; +static uint16 MonGadHeight = 1; +static uint16 hipal[20]; -extern uint32 VGAScreenWidth, VGAScreenHeight; +// Combination lock rules +static Image *Images[10]; +byte combination[6] = { 0, 0, 0, 0, 0, 0 }, solution[] = { 0, 4, 0, 8, 7, 2 }; +static uint16 combx[] = { 45, 83, 129, 166, 211, 248 }; +static TextFont *BigMsgFont; +static TextFont bmfont; +static char *journaltext, *journaltexttitle; +static uint16 JPage = 0; +static bool lastpage = false; +static Image *JCancel, *JCancelAlt, *JLeft, *JLeftAlt, *JRight, *JRightAlt, JBackImage, ScreenImage; +static uint16 JGadX[3] = { 80, 144, 194 }, JGadY[3] = { 162, 164, 162 }; +static Gadget ForwardG, CancelG, BackG; +static bool GotBackImage = false; +static uint16 monpage; +static const char *TextFileName; -#define COMBINATIONUNLOCKED 130 -#define BRICKOPEN 115 +Image *MonButton, *AltMonButton, *MonQuit, *AltMonQuit, *MonBack, *AltMonBack, +*MonDown, *AltMonDown, *MonUp, *AltMonUp; +// Tile puzzle rules +Image *Tiles[16]; +uint16 CurTile[4][4] = { + { 1, 5, 9, 13 }, + { 2, 6, 10, 14 }, + { 3, 7, 11, 15 }, + { 4, 8, 12, 0 } +}, TileSolution[4][4] = { + { 7, 1, 8, 3 }, + { 2, 11, 15, 4 }, + { 9, 5, 14, 6 }, + { 10, 13, 12, 0 } +}; -static uint16 hipal[20]; +extern TextFont *MsgFont; extern uint16 *FadePalette; +extern bool nopalchange, DoBlack, IsHiRes; +extern BitMap *DispBitMap, *DrawBitMap; +extern char diffcmap[3 * 256]; +extern uint32 VGAScreenWidth, VGAScreenHeight; +extern byte *TempScrollData; +extern CloseDataPtr CPtr; +extern InventoryData *Inventory; +extern uint16 RoomNum, Direction; +#define COMBINATIONUNLOCKED 130 +#define BRICKOPEN 115 #define INCL(BITSET,BIT) ((BITSET) |= (BIT)) - #define SETBIT(BITSET,BITNUM) INCL(BITSET, (1 << (BITNUM))) - #define INBIT(BITSET,BITNUM) ( ((1 << (BITNUM)) & (BITSET)) > 0 ) +#define LEFTSCROLL 1 +#define RIGHTSCROLL 2 +#define UPSCROLL 3 +#define DOWNSCROLL 4 +#define BRIDGE0 148 +#define BRIDGE1 104 +#define DIRTY 175 +#define NONEWS 135 +#define NOCLEAN 152 +#define QUARTERNUM 30 static byte *loadBackPict(const char *fileName, bool tomem) { @@ -92,24 +135,6 @@ static byte *loadBackPict(const char *fileName, bool tomem) { return res; } - - -/*----------------------------------------------------------------------------*/ -/*-------------------------- Combination Lock Rules --------------------------*/ -/*----------------------------------------------------------------------------*/ - - - - -static Image *Images[10]; - - -byte combination[6] = {0, 0, 0, 0, 0, 0}, solution[] = {0, 4, 0, 8, 7, 2}; - -static uint16 combx[] = {45, 83, 129, 166, 211, 248}; - - - /*****************************************************************************/ /* Draws the images of the combination lock to the display bitmap. */ /*****************************************************************************/ @@ -120,9 +145,6 @@ static void doCombination() { drawImage(Images[combination[counter]], VGAScaleX(combx[counter]), VGAScaleY(65)); } - -extern byte *TempScrollData; - /*****************************************************************************/ /* Reads in a backdrop picture. */ /*****************************************************************************/ @@ -197,9 +219,6 @@ static void changeCombination(uint16 number) { } - - - /*****************************************************************************/ /* Processes mouse clicks and changes the combination. */ /*****************************************************************************/ @@ -229,26 +248,6 @@ void mouseCombination(uint16 x, uint16 y) { } } - - -/*----------------------------------------------------------------------------*/ -/*----------------------------- Tile Puzzle Rules ----------------------------*/ -/*----------------------------------------------------------------------------*/ - -Image *Tiles[16]; -uint16 CurTile[4] [4] = { - { 1, 5, 9, 13 }, - { 2, 6, 10, 14 }, - { 3, 7, 11, 15 }, - { 4, 8, 12, 0 } -}, TileSolution[4] [4] = { - { 7, 1, 8, 3 }, - { 2, 11, 15, 4 }, - { 9, 5, 14, 6 }, - { 10, 13, 12, 0} -}; - - /*****************************************************************************/ /* Draws the images of the combination lock to the display bitmap. */ /*****************************************************************************/ @@ -291,9 +290,6 @@ static void doTile(bool showsolution) { } } - - - /*****************************************************************************/ /* Reads in a backdrop picture. */ /*****************************************************************************/ @@ -329,16 +325,6 @@ void showTile(const char *filename, bool showsolution) { VGASetPal(diffcmap, 256); } - - -#define LEFTSCROLL 1 -#define RIGHTSCROLL 2 -#define UPSCROLL 3 -#define DOWNSCROLL 4 - - - - static void scrollRaster(int16 dx, int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2) { if (dx) scrollDisplayX(dx, x1, y1, x2, y2); @@ -347,9 +333,6 @@ static void scrollRaster(int16 dx, int16 dy, uint16 x1, uint16 y1, uint16 x2, ui scrollDisplayY(dy, x1, y1, x2, y2); } - - - /*****************************************************************************/ /* Does the scrolling for the tiles on the tile puzzle. */ /*****************************************************************************/ @@ -391,8 +374,6 @@ static void doTileScroll(uint16 col, uint16 row, uint16 scrolltype) { } } - - /*****************************************************************************/ /* Changes the combination number of one of the slots */ /*****************************************************************************/ @@ -468,9 +449,6 @@ static void changeTile(uint16 col, uint16 row) { } - - - /*****************************************************************************/ /* Processes mouse clicks and changes the combination. */ /*****************************************************************************/ @@ -489,15 +467,6 @@ void mouseTile(uint16 x, uint16 y) { } -/*---------------------------------------------------------------------------*/ -/*------------------------ Does the detective notes. ------------------------*/ -/*---------------------------------------------------------------------------*/ - -extern TextFont *MsgFont; -static TextFont *BigMsgFont; -static TextFont bmfont; - - /*****************************************************************************/ /* Does the things to properly set up the detective notes. */ /*****************************************************************************/ @@ -522,14 +491,6 @@ void doNotes() { } - - -/*---------------------------------------------------------------------------*/ -/*---------------------- Does the Old West newspaper. ----------------------*/ -/*---------------------------------------------------------------------------*/ - - - /*****************************************************************************/ /* Does the things to properly set up the old west newspaper. Assumes that */ /* OpenHiRes already called. */ @@ -591,34 +552,6 @@ void doWestPaper() { freeAllStolenMem(); } - - - -/*---------------------------------------------------------------------------*/ -/*---------------------------- The Journal stuff ----------------------------*/ -/*---------------------------------------------------------------------------*/ - - -#define BRIDGE0 148 -#define BRIDGE1 104 -#define DIRTY 175 -#define NONEWS 135 -#define NOCLEAN 152 - - -static char *journaltext, *journaltexttitle; -static uint16 JPage = 0; - -static bool lastpage = false; - -static Image *JCancel, *JCancelAlt, *JLeft, *JLeftAlt, *JRight, *JRightAlt, JBackImage, ScreenImage; - -static uint16 JGadX[3] = {80, 144, 194}, JGadY[3] = {162, 164, 162}; -static Gadget ForwardG, CancelG, BackG; - - - - /*****************************************************************************/ /* Loads in the data for the journal. */ /*****************************************************************************/ @@ -710,8 +643,6 @@ static bool loadJournalData() { return true; } - - /*****************************************************************************/ /* Draws the text to the back journal screen to the appropriate Page number */ /*****************************************************************************/ @@ -750,9 +681,6 @@ static void drawJournalText() { lastpage = lastpage || (*CurText == 0); } - - - /*****************************************************************************/ /* Does the turn page wipe. */ /*****************************************************************************/ @@ -777,9 +705,6 @@ static void turnPage(bool FromLeft) { } - -static bool GotBackImage = false; - /*****************************************************************************/ /* Draws the journal from page x. */ /*****************************************************************************/ @@ -826,9 +751,6 @@ static void drawJournal(uint16 wipenum, bool needFade) { nopalchange = false; } - - - /*****************************************************************************/ /* Processes user input. */ /*****************************************************************************/ @@ -871,8 +793,6 @@ static void processJournal() { } } - - /*****************************************************************************/ /* Does the journal processing. */ /*****************************************************************************/ @@ -916,11 +836,6 @@ void doJournal() { ungetVGABaseAddr(); } -#define QUARTERNUM 30 - -extern InventoryData *Inventory; -extern uint16 RoomNum, Direction; - bool saveRestoreGame() { bool isOK = false; @@ -961,23 +876,6 @@ bool saveRestoreGame() { return isOK; } -/*---------------------------------------------------------------------------*/ -/*--------------------------- The Monitors stuff ----------------------------*/ -/*---------------------------------------------------------------------------*/ - - -extern CloseDataPtr CPtr; - -static uint16 monpage; -static const char *TextFileName; - - -Image *MonButton, *AltMonButton, *MonQuit, *AltMonQuit, *MonBack, *AltMonBack, - *MonDown, *AltMonDown, *MonUp, *AltMonUp; - - - - /*****************************************************************************/ /* Makes sure that the buttons are in memory. */ /*****************************************************************************/ @@ -998,9 +896,6 @@ static void getMonImages() { } -static uint16 MonGadHeight = 1; - - /*****************************************************************************/ /* Draws the text for the monitor. */ /*****************************************************************************/ @@ -1154,9 +1049,6 @@ static void processMonitor(char *ntext, bool isinteractive, uint16 x1, uint16 y1 } } - - - /*****************************************************************************/ /* Does what's necessary for the monitor. */ /*****************************************************************************/ -- cgit v1.2.3 From 8bf15cbe4bfda68dd38dbb4ed44a269f57f93b5a Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 21 Jul 2015 22:09:43 +0300 Subject: LAB: Replace more calls to checkMusic() --- engines/lab/special.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 2cd383d03d..4d64dd3914 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -569,7 +569,7 @@ static bool loadJournalData() { return false; } - g_music->checkMusic(); + g_music->updateMusic(); strcpy(filename, "Lab:Rooms/j0"); bridge = g_lab->_conditions->in(BRIDGE0) || g_lab->_conditions->in(BRIDGE1); @@ -652,7 +652,7 @@ static void drawJournalText() { char *CurText = journaltext; while (DrawingToPage < JPage) { - g_music->checkMusic(); + g_music->updateMusic(); CurText = (char *)(journaltext + CharsDrawn); CharsDrawn += flowText(BigMsgFont, -2, 2, 0, false, false, false, false, VGAScaleX(52), VGAScaleY(32), VGAScaleX(152), VGAScaleY(148), CurText); @@ -672,7 +672,7 @@ static void drawJournalText() { CharsDrawn += flowTextToMem(&JBackImage, BigMsgFont, -2, 2, 0, false, false, false, true, VGAScaleX(52), VGAScaleY(32), VGAScaleX(152), VGAScaleY(148), CurText); } - g_music->checkMusic(); + g_music->updateMusic(); CurText = (char *)(journaltext + CharsDrawn); lastpage = (*CurText == 0); flowTextToMem(&JBackImage, BigMsgFont, -2, 2, 0, false, false, false, true, VGAScaleX(171), VGAScaleY(32), VGAScaleX(271), VGAScaleY(148), CurText); @@ -711,7 +711,7 @@ static void turnPage(bool FromLeft) { static void drawJournal(uint16 wipenum, bool needFade) { mouseHide(); - g_music->checkMusic(); + g_music->updateMusic(); if (!GotBackImage) JBackImage.ImageData = loadBackPict("P:Journal.pic", true); @@ -760,11 +760,11 @@ static void processJournal() { uint16 Qualifier, GadID; while (1) { - g_music->checkMusic(); /* Make sure we check the music at least after every message */ + g_music->updateMusic(); /* Make sure we check the music at least after every message */ Msg = (IntuiMessage *) getMsg(); if (Msg == NULL) { - g_music->checkMusic(); + g_music->updateMusic(); } else { Class = Msg->Class; Qualifier = Msg->Qualifier; @@ -813,7 +813,7 @@ void doJournal() { ScreenImage = JBackImage; ScreenImage.ImageData = getVGABaseAddr(); - g_music->checkMusic(); + g_music->updateMusic(); loadJournalData(); drawJournal(0, true); @@ -936,7 +936,7 @@ static void drawMonText(char *text, uint16 x1, uint16 y1, uint16 x2, uint16 y2, } while (DrawingToPage < monpage) { - g_music->checkMusic(); + g_music->updateMusic(); CurText = (char *)(text + CharsDrawn); CharsDrawn += flowText(BigMsgFont, yspacing, 0, 0, false, false, false, false, x1, y1, x2, y2, CurText); lastpage = (*CurText == 0); @@ -990,11 +990,11 @@ static void processMonitor(char *ntext, bool isinteractive, uint16 x1, uint16 y1 } } - g_music->checkMusic(); /* Make sure we check the music at least after every message */ + g_music->updateMusic(); /* Make sure we check the music at least after every message */ Msg = getMsg(); if (Msg == NULL) { - g_music->checkMusic(); + g_music->updateMusic(); } else { Class = Msg->Class; Qualifier = Msg->Qualifier; @@ -1122,11 +1122,11 @@ void doTrialBlock() { memcpy(g_CommonPalette, diffcmap, 3 * 256); while (1) { - g_music->checkMusic(); /* Make sure we check the music at least after every message */ + g_music->updateMusic(); /* Make sure we check the music at least after every message */ Msg = getMsg(); if (Msg == NULL) { - g_music->checkMusic(); + g_music->updateMusic(); } else { Class = Msg->Class; Qualifier = Msg->Qualifier; -- cgit v1.2.3 From 76b66de8b673b878efe4ef5159a0dec20bd94890 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 8 Oct 2015 04:36:15 +0300 Subject: LAB: Remove dead code --- engines/lab/special.cpp | 6 ------ 1 file changed, 6 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 4d64dd3914..bedf7215d0 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -214,8 +214,6 @@ static void changeCombination(uint16 number) { g_lab->_conditions->inclElement(COMBINATIONUNLOCKED); else g_lab->_conditions->exclElement(COMBINATIONUNLOCKED); - - ungetVGABaseAddr(); } @@ -735,8 +733,6 @@ static void drawJournal(uint16 wipenum, bool needFade) { else unGhoastGadget(&ForwardG); - ungetVGABaseAddr(); - if (needFade) fade(true, 0); @@ -832,8 +828,6 @@ void doJournal() { blackScreen(); freeAllStolenMem(); - - ungetVGABaseAddr(); } bool saveRestoreGame() { -- cgit v1.2.3 From d565b10384dd771fdae7f8fedb793e87c05c022d Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 8 Oct 2015 06:15:36 +0300 Subject: LAB: Move the font loading code into the Resource class --- engines/lab/special.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index bedf7215d0..b7f14729a9 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -44,6 +44,7 @@ #include "lab/timing.h" #include "lab/stddefines.h" #include "lab/parsetypes.h" +#include "lab/resource.h" namespace Lab { @@ -474,7 +475,7 @@ void doNotes() { /* Load in the data */ BigMsgFont = &bmfont; - if (!getFont("P:Note.fon", BigMsgFont)) { + if (!(BigMsgFont = g_resource->getFont("P:Note.fon"))) { BigMsgFont = NULL; return; } @@ -500,7 +501,7 @@ void doWestPaper() { BigMsgFont = &bmfont; - if (!getFont("P:News22.fon", BigMsgFont)) { + if (!(BigMsgFont = g_resource->getFont("P:News22.fon"))) { BigMsgFont = NULL; return; } @@ -512,7 +513,7 @@ void doWestPaper() { BigMsgFont = &bmfont; - if (!getFont("P:News32.fon", BigMsgFont)) { + if (!(BigMsgFont = g_resource->getFont("P:News32.fon"))) { BigMsgFont = NULL; return; } @@ -531,7 +532,7 @@ void doWestPaper() { BigMsgFont = &bmfont; - if (!getFont("P:Note.fon", BigMsgFont)) { + if (!(BigMsgFont = g_resource->getFont("P:Note.fon"))) { BigMsgFont = NULL; return; } @@ -562,7 +563,7 @@ static bool loadJournalData() { BigMsgFont = &bmfont; - if (!getFont("P:Journal.fon", BigMsgFont)) { + if (!(BigMsgFont = g_resource->getFont("P:Journal.fon"))) { BigMsgFont = NULL; return false; } @@ -1071,7 +1072,7 @@ void doMonitor(char *background, char *textfile, bool isinteractive, uint16 x1, BigMsgFont = &bmfont; - if (!getFont("P:Map.fon", BigMsgFont)) { + if (!(BigMsgFont = g_resource->getFont("P:Map.fon"))) { freeAllStolenMem(); BigMsgFont = NULL; return; -- cgit v1.2.3 From 9676165436e1e3e7ee4db16c2cb905e0b2aeb1ff Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 12 Oct 2015 00:43:45 +0300 Subject: LAB: Remove unused code for the demo version The two places where the game stops in the demo versions should already be handled by the current code --- engines/lab/special.cpp | 56 ------------------------------------------------- 1 file changed, 56 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index b7f14729a9..2c0a488003 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -415,10 +415,6 @@ static void changeTile(uint16 col, uint16 row) { if (scrolltype != -1) { doTileScroll(col, row, scrolltype); -#if defined(LABDEMO) - return; -#endif - if (g_lab->getFeatures() & GF_WINDOWS_TRIAL) { GUI::MessageDialog trialMessage("This puzzle is not available in the trial version of the game"); trialMessage.runModal(); @@ -1102,56 +1098,4 @@ void doMonitor(char *background, char *textfile, bool isinteractive, uint16 x1, blackAllScreen(); } -#if defined(LABDEMO) -void doTrialBlock() { - IntuiMessage *Msg; - - uint32 Class; - uint16 Qualifier, MouseX, MouseY, Code, Temp; - int i; - - loadBackPict("P:Warning", false); - mouseShow(); - - VGASetPal(diffcmap, 256); - memcpy(g_CommonPalette, diffcmap, 3 * 256); - - while (1) { - g_music->updateMusic(); /* Make sure we check the music at least after every message */ - Msg = getMsg(); - - if (Msg == NULL) { - g_music->updateMusic(); - } else { - Class = Msg->Class; - Qualifier = Msg->Qualifier; - MouseX = Msg->MouseX; - MouseY = Msg->MouseY; - Code = Msg->Code; - - if (((Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) || - ((Class == RAWKEY) && (Code == 27))) - return; - - if ((Class == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & Qualifier)) { - if (MouseY > 399) { - // click on control panel, exit - break; - } - - if (MouseX >= 0 && MouseX <= 319 && MouseY >= 0 && MouseY <= 399) { - extern void getItNow(); - getItNow(); - } else if (MouseX >= 320 && MouseX <= 639 && MouseY >= 0 && MouseY <= 399) { - break; - } - } - } - } - - eatMessages(); - mouseHide(); -} -#endif - } // End of namespace Lab -- cgit v1.2.3 From 5cc3d3b682a69fee4ed76e2892a946711ec23926 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 12 Oct 2015 17:13:42 +0300 Subject: LAB: Remove superfluous image buffers --- engines/lab/special.cpp | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 2c0a488003..7e8bc96c88 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -61,7 +61,7 @@ static TextFont bmfont; static char *journaltext, *journaltexttitle; static uint16 JPage = 0; static bool lastpage = false; -static Image *JCancel, *JCancelAlt, *JLeft, *JLeftAlt, *JRight, *JRightAlt, JBackImage, ScreenImage; +static Image JBackImage, ScreenImage; static uint16 JGadX[3] = { 80, 144, 194 }, JGadY[3] = { 162, 164, 162 }; static Gadget ForwardG, CancelG, BackG; static bool GotBackImage = false; @@ -602,24 +602,16 @@ static bool loadJournalData() { if (!buffer) return false; - readImage(buffer, &JLeft); - readImage(buffer, &JLeftAlt); - readImage(buffer, &JRight); - readImage(buffer, &JRightAlt); - readImage(buffer, &JCancel); - readImage(buffer, &JCancelAlt); + readImage(buffer, &(BackG.Im)); + readImage(buffer, &(BackG.ImAlt)); + readImage(buffer, &(ForwardG.Im)); + readImage(buffer, &(ForwardG.ImAlt)); + readImage(buffer, &(CancelG.Im)); + readImage(buffer, &(CancelG.ImAlt)); - BackG.Im = JLeft; - BackG.ImAlt = JLeftAlt; BackG.KeyEquiv = VKEY_LTARROW; - - ForwardG.Im = JRight; - ForwardG.ImAlt = JRightAlt; ForwardG.KeyEquiv = VKEY_RTARROW; - CancelG.Im = JCancel; - CancelG.ImAlt = JCancelAlt; - counter = 0; while (TopGadget) { -- cgit v1.2.3 From 1feb0e4c2ce5d83701f4aff469d99b33ba1953dc Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 16 Oct 2015 01:52:53 +0300 Subject: LAB: Rename monpage -> monitorPage --- engines/lab/special.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 7e8bc96c88..978ce11c98 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -65,7 +65,7 @@ static Image JBackImage, ScreenImage; static uint16 JGadX[3] = { 80, 144, 194 }, JGadY[3] = { 162, 164, 162 }; static Gadget ForwardG, CancelG, BackG; static bool GotBackImage = false; -static uint16 monpage; +static uint16 monitorPage; static const char *TextFileName; Image *MonButton, *AltMonButton, *MonQuit, *AltMonQuit, *MonBack, *AltMonBack, @@ -918,14 +918,14 @@ static void drawMonText(char *text, uint16 x1, uint16 y1, uint16 x2, uint16 y2, rectFill(x1, y1, x2, y2); } - while (DrawingToPage < monpage) { + while (DrawingToPage < monitorPage) { g_music->updateMusic(); CurText = (char *)(text + CharsDrawn); CharsDrawn += flowText(BigMsgFont, yspacing, 0, 0, false, false, false, false, x1, y1, x2, y2, CurText); lastpage = (*CurText == 0); if (lastpage) - monpage = DrawingToPage; + monitorPage = DrawingToPage; else DrawingToPage++; } @@ -963,7 +963,7 @@ static void processMonitor(char *ntext, bool isinteractive, uint16 x1, uint16 y1 Test = CPtr->GraphicName; if (strcmp(Test, TextFileName)) { - monpage = 0; + monitorPage = 0; TextFileName = Test; ntext = getText(TextFileName); @@ -993,26 +993,26 @@ static void processMonitor(char *ntext, bool isinteractive, uint16 x1, uint16 y1 if ((MouseY >= VGAScaleY(171)) && (MouseY <= VGAScaleY(200))) { if ((MouseX >= VGAScaleX(259)) && (MouseX <= VGAScaleX(289))) { if (!lastpage) { - monpage += 1; + monitorPage += 1; drawMonText(ntext, x1, y1, x2, y2, isinteractive); } } else if ((MouseX >= VGAScaleX(0)) && (MouseX <= VGAScaleX(31))) { return; } else if ((MouseX >= VGAScaleX(290)) && (MouseX <= VGAScaleX(320))) { - if (monpage >= 1) { - monpage -= 1; + if (monitorPage >= 1) { + monitorPage -= 1; drawMonText(ntext, x1, y1, x2, y2, isinteractive); } } else if ((MouseX >= VGAScaleX(31)) && (MouseX <= VGAScaleX(59))) { if (isinteractive) { - monpage = 0; + monitorPage = 0; if (depth) { depth--; CPtr = LastCPtr[depth]; } - } else if (monpage > 0) { - monpage = 0; + } else if (monitorPage > 0) { + monitorPage = 0; drawMonText(ntext, x1, y1, x2, y2, isinteractive); } } @@ -1054,7 +1054,7 @@ void doMonitor(char *background, char *textfile, bool isinteractive, uint16 x1, blackAllScreen(); resetBuffer(); - monpage = 0; + monitorPage = 0; lastpage = false; FadePalette = hipal; -- cgit v1.2.3 From 36684eb1bab5b20c4052d89047b17c2f625666d1 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Fri, 20 Nov 2015 19:45:07 +0100 Subject: LAB: get rid of timing.h --- engines/lab/special.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 978ce11c98..377f8dbece 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -41,7 +41,6 @@ #include "lab/vga.h" #include "lab/text.h" #include "lab/mouse.h" -#include "lab/timing.h" #include "lab/stddefines.h" #include "lab/parsetypes.h" #include "lab/resource.h" @@ -855,7 +854,7 @@ bool saveRestoreGame() { } WSDL_UpdateScreen(); - + return isOK; } -- cgit v1.2.3 From 158f623db8778ae8511bd94b7f5c6989230d4da5 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Fri, 20 Nov 2015 20:26:00 +0100 Subject: LAB: Rename IntuiMessage struct members --- engines/lab/special.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 377f8dbece..9d9ccc7241 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -745,14 +745,14 @@ static void processJournal() { while (1) { g_music->updateMusic(); /* Make sure we check the music at least after every message */ - Msg = (IntuiMessage *) getMsg(); + Msg = (IntuiMessage *)getMsg(); if (Msg == NULL) { g_music->updateMusic(); } else { - Class = Msg->Class; - Qualifier = Msg->Qualifier; - GadID = Msg->Code; + Class = Msg->msgClass; + Qualifier = Msg->qualifier; + GadID = Msg->code; if (((Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) || ((Class == RAWKEY) && (GadID == 27))) @@ -978,11 +978,11 @@ static void processMonitor(char *ntext, bool isinteractive, uint16 x1, uint16 y1 if (Msg == NULL) { g_music->updateMusic(); } else { - Class = Msg->Class; - Qualifier = Msg->Qualifier; - MouseX = Msg->MouseX; - MouseY = Msg->MouseY; - Code = Msg->Code; + Class = Msg->msgClass; + Qualifier = Msg->qualifier; + MouseX = Msg->mouseX; + MouseY = Msg->mouseY; + Code = Msg->code; if (((Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) || ((Class == RAWKEY) && (Code == 27))) -- cgit v1.2.3 From f56f2effb419533b7652d7a2152b832e29ebea09 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Mon, 23 Nov 2015 17:34:02 +0100 Subject: LAB: Started vga code refactoring --- engines/lab/special.cpp | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 9d9ccc7241..41d938bdb8 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -89,7 +89,6 @@ extern uint16 *FadePalette; extern bool nopalchange, DoBlack, IsHiRes; extern BitMap *DispBitMap, *DrawBitMap; extern char diffcmap[3 * 256]; -extern uint32 VGAScreenWidth, VGAScreenHeight; extern byte *TempScrollData; extern CloseDataPtr CPtr; extern InventoryData *Inventory; @@ -120,7 +119,7 @@ static byte *loadBackPict(const char *fileName, bool tomem) { nopalchange = true; if (tomem) - res = readPictToMem(fileName, VGAScreenWidth, VGAScreenHeight); + res = readPictToMem(fileName, g_lab->_screenWidth, g_lab->_screenHeight); else readPict(fileName, true); @@ -190,8 +189,8 @@ static void changeCombination(uint16 number) { combnum = combination[number]; display.ImageData = getVGABaseAddr(); - display.Width = VGAScreenWidth; - display.Height = VGAScreenHeight; + display.Width = g_lab->_screenWidth; + display.Height = g_lab->_screenHeight; for (counter = 1; counter <= (Images[combnum]->Height / 2); counter++) { if (IsHiRes) { @@ -674,18 +673,18 @@ static void turnPage(bool FromLeft) { uint16 counter; if (FromLeft) { - for (counter = 0; counter < VGAScreenWidth; counter += 8) { + for (counter = 0; counter < g_lab->_screenWidth; counter += 8) { g_music->updateMusic(); waitTOF(); ScreenImage.ImageData = getVGABaseAddr(); - bltBitMap(&JBackImage, counter, 0, &ScreenImage, counter, 0, 8, VGAScreenHeight); + bltBitMap(&JBackImage, counter, 0, &ScreenImage, counter, 0, 8, g_lab->_screenHeight); } } else { - for (counter = (VGAScreenWidth - 8); counter > 0; counter -= 8) { + for (counter = (g_lab->_screenWidth - 8); counter > 0; counter -= 8) { g_music->updateMusic(); waitTOF(); ScreenImage.ImageData = getVGABaseAddr(); - bltBitMap(&JBackImage, counter, 0, &ScreenImage, counter, 0, 8, VGAScreenHeight); + bltBitMap(&JBackImage, counter, 0, &ScreenImage, counter, 0, 8, g_lab->_screenHeight); } } } @@ -707,7 +706,7 @@ static void drawJournal(uint16 wipenum, bool needFade) { ScreenImage.ImageData = getVGABaseAddr(); if (wipenum == 0) - bltBitMap(&JBackImage, 0, 0, &ScreenImage, 0, 0, VGAScreenWidth, VGAScreenHeight); + bltBitMap(&JBackImage, 0, 0, &ScreenImage, 0, 0, g_lab->_screenWidth, g_lab->_screenHeight); else turnPage((bool)(wipenum == 1)); @@ -726,7 +725,7 @@ static void drawJournal(uint16 wipenum, bool needFade) { fade(true, 0); nopalchange = true; - JBackImage.ImageData = readPictToMem("P:Journal.pic", VGAScreenWidth, VGAScreenHeight); + JBackImage.ImageData = readPictToMem("P:Journal.pic", g_lab->_screenWidth, g_lab->_screenHeight); GotBackImage = true; eatMessages(); @@ -787,8 +786,8 @@ void doJournal() { lastpage = false; GotBackImage = false; - JBackImage.Width = VGAScreenWidth; - JBackImage.Height = VGAScreenHeight; + JBackImage.Width = g_lab->_screenWidth; + JBackImage.Height = g_lab->_screenHeight; JBackImage.ImageData = NULL; BackG.NextGadget = &CancelG; @@ -812,7 +811,7 @@ void doJournal() { ScreenImage.ImageData = getVGABaseAddr(); setAPen(0); - rectFill(0, 0, VGAScreenWidth - 1, VGAScreenHeight - 1); + rectFill(0, 0, g_lab->_screenWidth - 1, g_lab->_screenHeight - 1); blackScreen(); freeAllStolenMem(); @@ -905,13 +904,13 @@ static void drawMonText(char *text, uint16 x1, uint16 y1, uint16 x2, uint16 y2, MonGadHeight = fheight; setAPen(0); - rectFill(0, 0, VGAScreenWidth - 1, y2); + rectFill(0, 0, g_lab->_screenWidth - 1, y2); for (counter = 0; counter < numlines; counter++) drawImage(MonButton, 0, counter * MonGadHeight); } else if (isinteractive) { setAPen(0); - rectFill(0, 0, VGAScreenWidth - 1, y2); + rectFill(0, 0, g_lab->_screenWidth - 1, y2); } else { setAPen(0); rectFill(x1, y1, x2, y2); @@ -1085,7 +1084,7 @@ void doMonitor(char *background, char *textfile, bool isinteractive, uint16 x1, freeAllStolenMem(); setAPen(0); - rectFill(0, 0, VGAScreenWidth - 1, VGAScreenHeight - 1); + rectFill(0, 0, g_lab->_screenWidth - 1, g_lab->_screenHeight - 1); blackAllScreen(); } -- cgit v1.2.3 From 4b65faaa632d309f02f6c25d38d9b6afc0648cbd Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Tue, 24 Nov 2015 10:40:35 +0100 Subject: LAB: More renames in vga.cpp --- engines/lab/special.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 41d938bdb8..0104e3ee3f 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -89,7 +89,7 @@ extern uint16 *FadePalette; extern bool nopalchange, DoBlack, IsHiRes; extern BitMap *DispBitMap, *DrawBitMap; extern char diffcmap[3 * 256]; -extern byte *TempScrollData; +extern byte *_tempScrollData; extern CloseDataPtr CPtr; extern InventoryData *Inventory; extern uint16 RoomNum, Direction; @@ -164,7 +164,7 @@ void showCombination(const char *filename) { for (CurBit = 0; CurBit < 10; CurBit++) readImage(buffer, &(Images[CurBit])); - allocFile((void **)&TempScrollData, Images[0]->Width * Images[0]->Height * 2L, "tempdata"); + allocFile((void **)&_tempScrollData, Images[0]->Width * Images[0]->Height * 2L, "tempdata"); doCombination(); @@ -315,7 +315,7 @@ void showTile(const char *filename, bool showsolution) { for (CurBit = start; CurBit < 16; CurBit++) readImage(buffer, &(Tiles[CurBit])); - allocFile((void **)&TempScrollData, Tiles[1]->Width * Tiles[1]->Height * 2L, "tempdata"); + allocFile((void **)&_tempScrollData, Tiles[1]->Width * Tiles[1]->Height * 2L, "tempdata"); doTile(showsolution); -- cgit v1.2.3 From 93e3ba9eddc7c50db7f6475305a24cd30f2893fa Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Tue, 24 Nov 2015 23:59:30 +0100 Subject: LAB: Put vga.cpp into LabEngine class --- engines/lab/special.cpp | 84 ++++++++++++++++++++++++------------------------- 1 file changed, 41 insertions(+), 43 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 0104e3ee3f..16940e1cbc 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -38,7 +38,6 @@ #include "lab/parsefun.h" #include "lab/interface.h" #include "lab/diff.h" -#include "lab/vga.h" #include "lab/text.h" #include "lab/mouse.h" #include "lab/stddefines.h" @@ -89,7 +88,6 @@ extern uint16 *FadePalette; extern bool nopalchange, DoBlack, IsHiRes; extern BitMap *DispBitMap, *DrawBitMap; extern char diffcmap[3 * 256]; -extern byte *_tempScrollData; extern CloseDataPtr CPtr; extern InventoryData *Inventory; extern uint16 RoomNum, Direction; @@ -141,7 +139,7 @@ static void doCombination() { uint16 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++) 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(); - VGASetPal(diffcmap, 256); + g_lab->VGASetPal(diffcmap, 256); } @@ -188,22 +186,22 @@ static void changeCombination(uint16 number) { combnum = combination[number]; - display.ImageData = getVGABaseAddr(); + display.ImageData = g_lab->getVGABaseAddr(); display.Width = g_lab->_screenWidth; display.Height = g_lab->_screenHeight; for (counter = 1; counter <= (Images[combnum]->Height / 2); counter++) { if (IsHiRes) { if (counter & 1) - waitTOF(); + g_lab->waitTOF(); } 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++) @@ -259,8 +257,8 @@ static void doTile(bool showsolution) { rows = VGAScaleY(31); cols = VGAScaleX(105); } else { - setAPen(0); - rectFill(VGAScaleX(97), VGAScaleY(22), VGAScaleX(220), VGAScaleY(126)); + g_lab->setAPen(0); + g_lab->rectFill(VGAScaleX(97), VGAScaleY(22), VGAScaleX(220), VGAScaleY(126)); rowm = VGAScaleY(25); colm = VGAScaleX(30); @@ -277,7 +275,7 @@ static void doTile(bool showsolution) { num = CurTile[col] [row]; if (showsolution || num) - drawImage(Tiles[num], cols + (col * colm), rows + (row * rowm)); + g_lab->drawImage(Tiles[num], cols + (col * colm), rows + (row * rowm)); col++; } @@ -315,19 +313,19 @@ void showTile(const char *filename, bool showsolution) { for (CurBit = start; CurBit < 16; 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); - VGASetPal(diffcmap, 256); + g_lab->VGASetPal(diffcmap, 256); } static void scrollRaster(int16 dx, int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2) { if (dx) - scrollDisplayX(dx, x1, y1, x2, y2); + g_lab->scrollDisplayX(dx, x1, y1, x2, y2); 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; for (counter = 0; counter < last; counter++) { - waitTOF(); + g_lab->waitTOF(); scrollRaster(dX, dY, x1, y1, x1 + VGAScaleX(28) + sx, y1 + VGAScaleY(23) + sy); x1 += dX; 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); - VGASetPal(diffcmap, 256); + g_lab->VGASetPal(diffcmap, 256); 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); - VGASetPal(diffcmap, 256); + g_lab->VGASetPal(diffcmap, 256); freeAllStolenMem(); } @@ -675,16 +673,16 @@ static void turnPage(bool FromLeft) { if (FromLeft) { for (counter = 0; counter < g_lab->_screenWidth; counter += 8) { g_music->updateMusic(); - waitTOF(); - ScreenImage.ImageData = getVGABaseAddr(); - bltBitMap(&JBackImage, counter, 0, &ScreenImage, counter, 0, 8, g_lab->_screenHeight); + g_lab->waitTOF(); + ScreenImage.ImageData = g_lab->getVGABaseAddr(); + g_lab->bltBitMap(&JBackImage, counter, 0, &ScreenImage, counter, 0, 8, g_lab->_screenHeight); } } else { for (counter = (g_lab->_screenWidth - 8); counter > 0; counter -= 8) { g_music->updateMusic(); - waitTOF(); - ScreenImage.ImageData = getVGABaseAddr(); - bltBitMap(&JBackImage, counter, 0, &ScreenImage, counter, 0, 8, g_lab->_screenHeight); + g_lab->waitTOF(); + ScreenImage.ImageData = g_lab->getVGABaseAddr(); + 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(); - ScreenImage.ImageData = getVGABaseAddr(); + ScreenImage.ImageData = g_lab->getVGABaseAddr(); 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 turnPage((bool)(wipenum == 1)); @@ -794,7 +792,7 @@ void doJournal() { CancelG.NextGadget = &ForwardG; ScreenImage = JBackImage; - ScreenImage.ImageData = getVGABaseAddr(); + ScreenImage.ImageData = g_lab->getVGABaseAddr(); g_music->updateMusic(); loadJournalData(); @@ -808,10 +806,10 @@ void doJournal() { fade(false, 0); mouseHide(); - ScreenImage.ImageData = getVGABaseAddr(); + ScreenImage.ImageData = g_lab->getVGABaseAddr(); - setAPen(0); - rectFill(0, 0, g_lab->_screenWidth - 1, g_lab->_screenHeight - 1); + g_lab->setAPen(0); + g_lab->rectFill(0, 0, g_lab->_screenWidth - 1, g_lab->_screenHeight - 1); blackScreen(); freeAllStolenMem(); @@ -852,7 +850,7 @@ bool saveRestoreGame() { } } - WSDL_UpdateScreen(); + g_lab->WSDL_UpdateScreen(); return isOK; } @@ -903,17 +901,17 @@ static void drawMonText(char *text, uint16 x1, uint16 y1, uint16 x2, uint16 y2, else MonGadHeight = fheight; - setAPen(0); - rectFill(0, 0, g_lab->_screenWidth - 1, y2); + g_lab->setAPen(0); + g_lab->rectFill(0, 0, g_lab->_screenWidth - 1, y2); for (counter = 0; counter < numlines; counter++) - drawImage(MonButton, 0, counter * MonGadHeight); + g_lab->drawImage(MonButton, 0, counter * MonGadHeight); } else if (isinteractive) { - setAPen(0); - rectFill(0, 0, g_lab->_screenWidth - 1, y2); + g_lab->setAPen(0); + g_lab->rectFill(0, 0, g_lab->_screenWidth - 1, y2); } else { - setAPen(0); - rectFill(x1, y1, x2, y2); + g_lab->setAPen(0); + g_lab->rectFill(x1, y1, x2, y2); } while (DrawingToPage < monitorPage) { @@ -1083,8 +1081,8 @@ void doMonitor(char *background, char *textfile, bool isinteractive, uint16 x1, freeAllStolenMem(); - setAPen(0); - rectFill(0, 0, g_lab->_screenWidth - 1, g_lab->_screenHeight - 1); + g_lab->setAPen(0); + g_lab->rectFill(0, 0, g_lab->_screenWidth - 1, g_lab->_screenHeight - 1); blackAllScreen(); } -- cgit v1.2.3 From b76a624c9ae59aac7df11ad5df7d39879d3344c8 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 27 Nov 2015 21:52:31 +0100 Subject: LAB: Fix several cppcheck errors --- engines/lab/special.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 16940e1cbc..1ee539f20b 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -373,7 +373,6 @@ static void doTileScroll(uint16 col, uint16 row, uint16 scrolltype) { /* Changes the combination number of one of the slots */ /*****************************************************************************/ static void changeTile(uint16 col, uint16 row) { - bool check; int16 scrolltype = -1; if (row > 0) { @@ -417,7 +416,7 @@ static void changeTile(uint16 col, uint16 row) { return; } - check = true; + bool check = true; row = 0; col = 0; -- cgit v1.2.3 From ff2def7da187c5160443fc6166728f1fc59ff66e Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 27 Nov 2015 23:18:15 +0100 Subject: LAB: Check all the 'for' loops, reduce the scope of variable accordingly --- engines/lab/special.cpp | 58 +++++++++++++++++++++---------------------------- 1 file changed, 25 insertions(+), 33 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 1ee539f20b..ea9df4fc13 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -110,7 +110,6 @@ extern uint16 RoomNum, Direction; static byte *loadBackPict(const char *fileName, bool tomem) { - uint16 counter; byte *res = NULL; FadePalette = hipal; @@ -121,10 +120,10 @@ static byte *loadBackPict(const char *fileName, bool tomem) { else readPict(fileName, true); - for (counter = 0; counter < 16; counter++) { - hipal[counter] = ((diffcmap[counter * 3] >> 2) << 8) + - ((diffcmap[counter * 3 + 1] >> 2) << 4) + - ((diffcmap[counter * 3 + 2] >> 2)); + for (uint16 i = 0; i < 16; i++) { + hipal[i] = ((diffcmap[i * 3] >> 2) << 8) + + ((diffcmap[i * 3 + 1] >> 2) << 4) + + ((diffcmap[i * 3 + 2] >> 2)); } nopalchange = false; @@ -136,17 +135,14 @@ static byte *loadBackPict(const char *fileName, bool tomem) { /* Draws the images of the combination lock to the display bitmap. */ /*****************************************************************************/ static void doCombination() { - uint16 counter; - - for (counter = 0; counter <= 5; counter++) - g_lab->drawImage(Images[combination[counter]], VGAScaleX(combx[counter]), VGAScaleY(65)); + for (uint16 i = 0; i <= 5; i++) + g_lab->drawImage(Images[combination[i]], VGAScaleX(combx[i]), VGAScaleY(65)); } /*****************************************************************************/ /* Reads in a backdrop picture. */ /*****************************************************************************/ void showCombination(const char *filename) { - uint16 CurBit; byte **buffer; resetBuffer(); @@ -159,7 +155,7 @@ void showCombination(const char *filename) { buffer = g_music->newOpen("P:Numbers"); - for (CurBit = 0; CurBit < 10; CurBit++) + for (uint16 CurBit = 0; CurBit < 10; CurBit++) readImage(buffer, &(Images[CurBit])); allocFile((void **)&g_lab->_tempScrollData, Images[0]->Width * Images[0]->Height * 2L, "tempdata"); @@ -176,7 +172,7 @@ void showCombination(const char *filename) { /*****************************************************************************/ static void changeCombination(uint16 number) { Image display; - uint16 counter, combnum; + uint16 combnum; bool unlocked = true; if (combination[number] < 9) @@ -190,9 +186,9 @@ static void changeCombination(uint16 number) { display.Width = g_lab->_screenWidth; display.Height = g_lab->_screenHeight; - for (counter = 1; counter <= (Images[combnum]->Height / 2); counter++) { + for (uint16 i = 1; i <= (Images[combnum]->Height / 2); i++) { if (IsHiRes) { - if (counter & 1) + if (i & 1) g_lab->waitTOF(); } else g_lab->waitTOF(); @@ -201,11 +197,11 @@ static void changeCombination(uint16 number) { g_lab->scrollDisplayY(2, VGAScaleX(combx[number]), VGAScaleY(65), VGAScaleX(combx[number]) + (Images[combnum])->Width - 1, VGAScaleY(65) + (Images[combnum])->Height); - g_lab->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 * i), &(display), VGAScaleX(combx[number]), VGAScaleY(65), (Images[combnum])->Width, 2); } - for (counter = 0; counter < 6; counter++) - unlocked = (combination[counter] == solution[counter]) && unlocked; + for (uint16 i = 0; i < 6; i++) + unlocked = (combination[i] == solution[i]) && unlocked; if (unlocked) g_lab->_conditions->inclElement(COMBINATIONUNLOCKED); @@ -289,7 +285,7 @@ static void doTile(bool showsolution) { /* Reads in a backdrop picture. */ /*****************************************************************************/ void showTile(const char *filename, bool showsolution) { - uint16 CurBit, start; + uint16 start; byte **buffer; resetBuffer(); @@ -310,8 +306,8 @@ void showTile(const char *filename, bool showsolution) { if (!buffer) return; - for (CurBit = start; CurBit < 16; CurBit++) - readImage(buffer, &(Tiles[CurBit])); + for (uint16 curBit = start; curBit < 16; curBit++) + readImage(buffer, &(Tiles[curBit])); allocFile((void **)&g_lab->_tempScrollData, Tiles[1]->Width * Tiles[1]->Height * 2L, "tempdata"); @@ -334,7 +330,6 @@ static void scrollRaster(int16 dx, int16 dy, uint16 x1, uint16 y1, uint16 x2, ui static void doTileScroll(uint16 col, uint16 row, uint16 scrolltype) { int16 dX = 0, dY = 0, dx = 0, dy = 0, sx = 0, sy = 0; uint16 last = 0, x1, y1; - uint16 counter; if (scrolltype == LEFTSCROLL) { dX = VGAScaleX(5); @@ -361,7 +356,7 @@ static void doTileScroll(uint16 col, uint16 row, uint16 scrolltype) { x1 = VGAScaleX(100) + (col * VGAScaleX(30)) + dx; y1 = VGAScaleY(25) + (row * VGAScaleY(25)) + dy; - for (counter = 0; counter < last; counter++) { + for (uint16 i = 0; i < last; i++) { g_lab->waitTOF(); scrollRaster(dX, dY, x1, y1, x1 + VGAScaleX(28) + sx, y1 + VGAScaleY(23) + sy); x1 += dX; @@ -549,7 +544,6 @@ static bool loadJournalData() { byte **buffer; char filename[20]; Gadget *TopGadget = &BackG; - uint16 counter; bool bridge, dirty, news, clean; BigMsgFont = &bmfont; @@ -607,7 +601,7 @@ static bool loadJournalData() { BackG.KeyEquiv = VKEY_LTARROW; ForwardG.KeyEquiv = VKEY_RTARROW; - counter = 0; + uint16 counter = 0; while (TopGadget) { TopGadget->x = VGAScaleX(JGadX[counter]); @@ -667,21 +661,19 @@ static void drawJournalText() { /* Does the turn page wipe. */ /*****************************************************************************/ static void turnPage(bool FromLeft) { - uint16 counter; - if (FromLeft) { - for (counter = 0; counter < g_lab->_screenWidth; counter += 8) { + for (int i = 0; i < g_lab->_screenWidth; i += 8) { g_music->updateMusic(); g_lab->waitTOF(); ScreenImage.ImageData = g_lab->getVGABaseAddr(); - g_lab->bltBitMap(&JBackImage, counter, 0, &ScreenImage, counter, 0, 8, g_lab->_screenHeight); + g_lab->bltBitMap(&JBackImage, i, 0, &ScreenImage, i, 0, 8, g_lab->_screenHeight); } } else { - for (counter = (g_lab->_screenWidth - 8); counter > 0; counter -= 8) { + for (int i = (g_lab->_screenWidth - 8); i > 0; i -= 8) { g_music->updateMusic(); g_lab->waitTOF(); ScreenImage.ImageData = g_lab->getVGABaseAddr(); - g_lab->bltBitMap(&JBackImage, counter, 0, &ScreenImage, counter, 0, 8, g_lab->_screenHeight); + g_lab->bltBitMap(&JBackImage, i, 0, &ScreenImage, i, 0, 8, g_lab->_screenHeight); } } } @@ -878,7 +870,7 @@ static void getMonImages() { /* Draws the text for the monitor. */ /*****************************************************************************/ static void drawMonText(char *text, uint16 x1, uint16 y1, uint16 x2, uint16 y2, bool isinteractive) { - uint16 DrawingToPage = 0, yspacing = 0, numlines, fheight, counter; + uint16 DrawingToPage = 0, yspacing = 0, numlines, fheight; int32 CharsDrawn = 0L; char *CurText = text; @@ -903,8 +895,8 @@ static void drawMonText(char *text, uint16 x1, uint16 y1, uint16 x2, uint16 y2, g_lab->setAPen(0); g_lab->rectFill(0, 0, g_lab->_screenWidth - 1, y2); - for (counter = 0; counter < numlines; counter++) - g_lab->drawImage(MonButton, 0, counter * MonGadHeight); + for (uint16 i = 0; i < numlines; i++) + g_lab->drawImage(MonButton, 0, i * MonGadHeight); } else if (isinteractive) { g_lab->setAPen(0); g_lab->rectFill(0, 0, g_lab->_screenWidth - 1, y2); -- cgit v1.2.3 From c485d9e8a616d475f9155de084012062fe9e5dc8 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 28 Nov 2015 02:17:05 +0100 Subject: LAB: Some rework related to the mouse code --- engines/lab/special.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index ea9df4fc13..00ac19f279 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -213,11 +213,11 @@ static void changeCombination(uint16 number) { /*****************************************************************************/ /* Processes mouse clicks and changes the combination. */ /*****************************************************************************/ -void mouseCombination(uint16 x, uint16 y) { +void mouseCombination(Common::Point pos) { uint16 number; - x = VGAUnScaleX(x); - y = VGAUnScaleY(y); + int x = VGAUnScaleX(pos.x); + int y = VGAUnScaleY(pos.y); if ((y >= 63) && (y <= 99)) { if ((x >= 44) && (x < 83)) @@ -437,9 +437,9 @@ static void changeTile(uint16 col, uint16 row) { /*****************************************************************************/ /* Processes mouse clicks and changes the combination. */ /*****************************************************************************/ -void mouseTile(uint16 x, uint16 y) { - x = VGAUnScaleX(x); - y = VGAUnScaleY(y); +void mouseTile(Common::Point pos) { + int x = VGAUnScaleX(pos.x); + int y = VGAUnScaleY(pos.y); if ((x < 101) || (y < 26)) return; @@ -1007,7 +1007,7 @@ static void processMonitor(char *ntext, bool isinteractive, uint16 x1, uint16 y1 TestCPtr = CPtr; MouseY = 64 + (MouseY / MonGadHeight) * 42; MouseX = 101; - setCurClose(MouseX, MouseY, &CPtr, true); + setCurClose(Common::Point(MouseX, MouseY), &CPtr, true); if (TestCPtr != CPtr) { LastCPtr[depth] = TestCPtr; -- cgit v1.2.3 From d96484d81c2645b7b714845a9176ba264f52bbc0 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 29 Nov 2015 18:10:06 +0100 Subject: LAB: Move mouse code in separate class, move some functions to LabEngine. (WIP) --- engines/lab/special.cpp | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 00ac19f279..4e61b3c8cd 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -682,8 +682,8 @@ static void turnPage(bool FromLeft) { /*****************************************************************************/ /* Draws the journal from page x. */ /*****************************************************************************/ -static void drawJournal(uint16 wipenum, bool needFade) { - mouseHide(); +void LabEngine::drawJournal(uint16 wipenum, bool needFade) { + _event->mouseHide(); g_music->updateMusic(); @@ -718,7 +718,7 @@ static void drawJournal(uint16 wipenum, bool needFade) { GotBackImage = true; eatMessages(); - mouseShow(); + _event->mouseShow(); nopalchange = false; } @@ -726,14 +726,14 @@ static void drawJournal(uint16 wipenum, bool needFade) { /*****************************************************************************/ /* Processes user input. */ /*****************************************************************************/ -static void processJournal() { +void LabEngine::processJournal() { IntuiMessage *Msg; uint32 Class; uint16 Qualifier, GadID; while (1) { g_music->updateMusic(); /* Make sure we check the music at least after every message */ - Msg = (IntuiMessage *)getMsg(); + Msg = getMsg(); if (Msg == NULL) { g_music->updateMusic(); @@ -768,7 +768,7 @@ static void processJournal() { /*****************************************************************************/ /* Does the journal processing. */ /*****************************************************************************/ -void doJournal() { +void LabEngine::doJournal() { resetBuffer(); blackAllScreen(); @@ -790,12 +790,12 @@ void doJournal() { drawJournal(0, true); - attachGadgetList(&BackG); - mouseShow(); + _event->attachGadgetList(&BackG); + _event->mouseShow(); processJournal(); - attachGadgetList(NULL); + _event->attachGadgetList(NULL); fade(false, 0); - mouseHide(); + _event->mouseHide(); ScreenImage.ImageData = g_lab->getVGABaseAddr(); @@ -869,12 +869,12 @@ static void getMonImages() { /*****************************************************************************/ /* Draws the text for the monitor. */ /*****************************************************************************/ -static void drawMonText(char *text, uint16 x1, uint16 y1, uint16 x2, uint16 y2, bool isinteractive) { +void LabEngine::drawMonText(char *text, uint16 x1, uint16 y1, uint16 x2, uint16 y2, bool isinteractive) { uint16 DrawingToPage = 0, yspacing = 0, numlines, fheight; int32 CharsDrawn = 0L; char *CurText = text; - mouseHide(); + _event->mouseHide(); if (*text == '%') { text++; @@ -923,13 +923,13 @@ static void drawMonText(char *text, uint16 x1, uint16 y1, uint16 x2, uint16 y2, CurText += CharsDrawn; lastpage = lastpage || (*CurText == 0); - mouseShow(); + _event->mouseShow(); } /*****************************************************************************/ /* Processes user input. */ /*****************************************************************************/ -static void processMonitor(char *ntext, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2) { +void LabEngine::processMonitor(char *ntext, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2) { IntuiMessage *Msg; uint32 Class; uint16 Qualifier, Code, MouseX, MouseY; @@ -1022,7 +1022,7 @@ static void processMonitor(char *ntext, bool isinteractive, uint16 x1, uint16 y1 /*****************************************************************************/ /* Does what's necessary for the monitor. */ /*****************************************************************************/ -void doMonitor(char *background, char *textfile, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2) { +void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2) { char *ntext; x1 = VGAScaleX(x1); @@ -1064,11 +1064,11 @@ void doMonitor(char *background, char *textfile, bool isinteractive, uint16 x1, drawMonText(ntext, x1, y1, x2, y2, isinteractive); - mouseShow(); + _event->mouseShow(); fade(true, 0); processMonitor(ntext, isinteractive, x1, y1, x2, y2); fade(false, 0); - mouseHide(); + _event->mouseHide(); freeAllStolenMem(); -- cgit v1.2.3 From db773d92b7f035244538316a02d109671cdf8944 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 29 Nov 2015 23:34:35 +0100 Subject: LAB: Remove useless redirections --- engines/lab/special.cpp | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 4e61b3c8cd..9b0ed4217f 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -692,10 +692,10 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) { drawJournalText(); - ScreenImage.ImageData = g_lab->getVGABaseAddr(); + ScreenImage.ImageData = getVGABaseAddr(); if (wipenum == 0) - g_lab->bltBitMap(&JBackImage, 0, 0, &ScreenImage, 0, 0, g_lab->_screenWidth, g_lab->_screenHeight); + bltBitMap(&JBackImage, 0, 0, &ScreenImage, 0, 0, _screenWidth, _screenHeight); else turnPage((bool)(wipenum == 1)); @@ -714,7 +714,7 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) { fade(true, 0); nopalchange = true; - JBackImage.ImageData = readPictToMem("P:Journal.pic", g_lab->_screenWidth, g_lab->_screenHeight); + JBackImage.ImageData = readPictToMem("P:Journal.pic", _screenWidth, _screenHeight); GotBackImage = true; eatMessages(); @@ -775,15 +775,15 @@ void LabEngine::doJournal() { lastpage = false; GotBackImage = false; - JBackImage.Width = g_lab->_screenWidth; - JBackImage.Height = g_lab->_screenHeight; + JBackImage.Width = _screenWidth; + JBackImage.Height = _screenHeight; JBackImage.ImageData = NULL; BackG.NextGadget = &CancelG; CancelG.NextGadget = &ForwardG; ScreenImage = JBackImage; - ScreenImage.ImageData = g_lab->getVGABaseAddr(); + ScreenImage.ImageData = getVGABaseAddr(); g_music->updateMusic(); loadJournalData(); @@ -797,10 +797,10 @@ void LabEngine::doJournal() { fade(false, 0); _event->mouseHide(); - ScreenImage.ImageData = g_lab->getVGABaseAddr(); + ScreenImage.ImageData = getVGABaseAddr(); - g_lab->setAPen(0); - g_lab->rectFill(0, 0, g_lab->_screenWidth - 1, g_lab->_screenHeight - 1); + setAPen(0); + rectFill(0, 0, _screenWidth - 1, _screenHeight - 1); blackScreen(); freeAllStolenMem(); @@ -892,17 +892,17 @@ void LabEngine::drawMonText(char *text, uint16 x1, uint16 y1, uint16 x2, uint16 else MonGadHeight = fheight; - g_lab->setAPen(0); - g_lab->rectFill(0, 0, g_lab->_screenWidth - 1, y2); + setAPen(0); + rectFill(0, 0, _screenWidth - 1, y2); for (uint16 i = 0; i < numlines; i++) - g_lab->drawImage(MonButton, 0, i * MonGadHeight); + drawImage(MonButton, 0, i * MonGadHeight); } else if (isinteractive) { - g_lab->setAPen(0); - g_lab->rectFill(0, 0, g_lab->_screenWidth - 1, y2); + setAPen(0); + rectFill(0, 0, _screenWidth - 1, y2); } else { - g_lab->setAPen(0); - g_lab->rectFill(x1, y1, x2, y2); + setAPen(0); + rectFill(x1, y1, x2, y2); } while (DrawingToPage < monitorPage) { @@ -1072,8 +1072,8 @@ void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive, freeAllStolenMem(); - g_lab->setAPen(0); - g_lab->rectFill(0, 0, g_lab->_screenWidth - 1, g_lab->_screenHeight - 1); + setAPen(0); + rectFill(0, 0, _screenWidth - 1, _screenHeight - 1); blackAllScreen(); } -- cgit v1.2.3 From 0c84355f4ae5651e7667b9aa0d2d3c6c28f21496 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 30 Nov 2015 00:12:01 +0100 Subject: LAB: Move IsHiRes to main engine class --- engines/lab/special.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 9b0ed4217f..96f7bfd1ac 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -85,7 +85,7 @@ uint16 CurTile[4][4] = { extern TextFont *MsgFont; extern uint16 *FadePalette; -extern bool nopalchange, DoBlack, IsHiRes; +extern bool nopalchange, DoBlack; extern BitMap *DispBitMap, *DrawBitMap; extern char diffcmap[3 * 256]; extern CloseDataPtr CPtr; @@ -187,7 +187,7 @@ static void changeCombination(uint16 number) { display.Height = g_lab->_screenHeight; for (uint16 i = 1; i <= (Images[combnum]->Height / 2); i++) { - if (IsHiRes) { + if (g_lab->_isHiRes) { if (i & 1) g_lab->waitTOF(); } else -- cgit v1.2.3 From 771e558d905ee467280482d62697dc66d969ed2b Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 30 Nov 2015 00:34:43 +0100 Subject: LAB: Move the global variable g_resource to the main engine class --- engines/lab/special.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 96f7bfd1ac..eaa9ef2755 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -461,7 +461,7 @@ void doNotes() { /* Load in the data */ BigMsgFont = &bmfont; - if (!(BigMsgFont = g_resource->getFont("P:Note.fon"))) { + if (!(BigMsgFont = g_lab->_resource->getFont("P:Note.fon"))) { BigMsgFont = NULL; return; } @@ -487,7 +487,7 @@ void doWestPaper() { BigMsgFont = &bmfont; - if (!(BigMsgFont = g_resource->getFont("P:News22.fon"))) { + if (!(BigMsgFont = g_lab->_resource->getFont("P:News22.fon"))) { BigMsgFont = NULL; return; } @@ -499,7 +499,7 @@ void doWestPaper() { BigMsgFont = &bmfont; - if (!(BigMsgFont = g_resource->getFont("P:News32.fon"))) { + if (!(BigMsgFont = g_lab->_resource->getFont("P:News32.fon"))) { BigMsgFont = NULL; return; } @@ -518,7 +518,7 @@ void doWestPaper() { BigMsgFont = &bmfont; - if (!(BigMsgFont = g_resource->getFont("P:Note.fon"))) { + if (!(BigMsgFont = g_lab->_resource->getFont("P:Note.fon"))) { BigMsgFont = NULL; return; } @@ -548,7 +548,7 @@ static bool loadJournalData() { BigMsgFont = &bmfont; - if (!(BigMsgFont = g_resource->getFont("P:Journal.fon"))) { + if (!(BigMsgFont = g_lab->_resource->getFont("P:Journal.fon"))) { BigMsgFont = NULL; return false; } @@ -1047,7 +1047,7 @@ void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive, BigMsgFont = &bmfont; - if (!(BigMsgFont = g_resource->getFont("P:Map.fon"))) { + if (!(BigMsgFont = _resource->getFont("P:Map.fon"))) { freeAllStolenMem(); BigMsgFont = NULL; return; -- cgit v1.2.3 From 05f54b7fe0a0fbdfc731404b77b149f10ad5679b Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 30 Nov 2015 01:03:14 +0100 Subject: LAB: Make _music a member of LabEngine instead of a global --- engines/lab/special.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index eaa9ef2755..417f854b84 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -153,7 +153,7 @@ void showCombination(const char *filename) { blackScreen(); - buffer = g_music->newOpen("P:Numbers"); + buffer = g_lab->g_music->newOpen("P:Numbers"); for (uint16 CurBit = 0; CurBit < 10; CurBit++) readImage(buffer, &(Images[CurBit])); @@ -297,10 +297,10 @@ void showTile(const char *filename, bool showsolution) { if (showsolution) { start = 0; - buffer = g_music->newOpen("P:TileSolution"); + buffer = g_lab->g_music->newOpen("P:TileSolution"); } else { start = 1; - buffer = g_music->newOpen("P:Tile"); + buffer = g_lab->g_music->newOpen("P:Tile"); } if (!buffer) @@ -553,7 +553,7 @@ static bool loadJournalData() { return false; } - g_music->updateMusic(); + g_lab->g_music->updateMusic(); strcpy(filename, "Lab:Rooms/j0"); bridge = g_lab->_conditions->in(BRIDGE0) || g_lab->_conditions->in(BRIDGE1); @@ -586,7 +586,7 @@ static bool loadJournalData() { if ((journaltexttitle = getText("Lab:Rooms/jt")) == NULL) return false; - buffer = g_music->newOpen("P:JImage"); + buffer = g_lab->g_music->newOpen("P:JImage"); if (!buffer) return false; @@ -628,7 +628,7 @@ static void drawJournalText() { char *CurText = journaltext; while (DrawingToPage < JPage) { - g_music->updateMusic(); + g_lab->g_music->updateMusic(); CurText = (char *)(journaltext + CharsDrawn); CharsDrawn += flowText(BigMsgFont, -2, 2, 0, false, false, false, false, VGAScaleX(52), VGAScaleY(32), VGAScaleX(152), VGAScaleY(148), CurText); @@ -648,7 +648,7 @@ static void drawJournalText() { CharsDrawn += flowTextToMem(&JBackImage, BigMsgFont, -2, 2, 0, false, false, false, true, VGAScaleX(52), VGAScaleY(32), VGAScaleX(152), VGAScaleY(148), CurText); } - g_music->updateMusic(); + g_lab->g_music->updateMusic(); CurText = (char *)(journaltext + CharsDrawn); lastpage = (*CurText == 0); flowTextToMem(&JBackImage, BigMsgFont, -2, 2, 0, false, false, false, true, VGAScaleX(171), VGAScaleY(32), VGAScaleX(271), VGAScaleY(148), CurText); @@ -663,14 +663,14 @@ static void drawJournalText() { static void turnPage(bool FromLeft) { if (FromLeft) { for (int i = 0; i < g_lab->_screenWidth; i += 8) { - g_music->updateMusic(); + g_lab->g_music->updateMusic(); g_lab->waitTOF(); ScreenImage.ImageData = g_lab->getVGABaseAddr(); g_lab->bltBitMap(&JBackImage, i, 0, &ScreenImage, i, 0, 8, g_lab->_screenHeight); } } else { for (int i = (g_lab->_screenWidth - 8); i > 0; i -= 8) { - g_music->updateMusic(); + g_lab->g_music->updateMusic(); g_lab->waitTOF(); ScreenImage.ImageData = g_lab->getVGABaseAddr(); g_lab->bltBitMap(&JBackImage, i, 0, &ScreenImage, i, 0, 8, g_lab->_screenHeight); @@ -837,7 +837,7 @@ bool saveRestoreGame() { if (slot >= 0) { isOK = loadGame(&RoomNum, &Direction, &(Inventory[QUARTERNUM].Many), slot); if (isOK) - g_music->resetMusic(); + g_lab->g_music->resetMusic(); } } @@ -855,7 +855,7 @@ static void getMonImages() { resetBuffer(); - buffer = g_music->newOpen("P:MonImage", bufferSize); + buffer = g_lab->g_music->newOpen("P:MonImage", bufferSize); if (!buffer) return; -- cgit v1.2.3 From d0c6c730365764668567f19e07b6971974c649fb Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 30 Nov 2015 01:17:05 +0100 Subject: LAB: Rename _music, delete it in engine destructor --- engines/lab/special.cpp | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 417f854b84..7519ad1988 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -153,7 +153,7 @@ void showCombination(const char *filename) { blackScreen(); - buffer = g_lab->g_music->newOpen("P:Numbers"); + buffer = g_lab->_music->newOpen("P:Numbers"); for (uint16 CurBit = 0; CurBit < 10; CurBit++) readImage(buffer, &(Images[CurBit])); @@ -297,10 +297,10 @@ void showTile(const char *filename, bool showsolution) { if (showsolution) { start = 0; - buffer = g_lab->g_music->newOpen("P:TileSolution"); + buffer = g_lab->_music->newOpen("P:TileSolution"); } else { start = 1; - buffer = g_lab->g_music->newOpen("P:Tile"); + buffer = g_lab->_music->newOpen("P:Tile"); } if (!buffer) @@ -553,7 +553,7 @@ static bool loadJournalData() { return false; } - g_lab->g_music->updateMusic(); + g_lab->_music->updateMusic(); strcpy(filename, "Lab:Rooms/j0"); bridge = g_lab->_conditions->in(BRIDGE0) || g_lab->_conditions->in(BRIDGE1); @@ -586,7 +586,7 @@ static bool loadJournalData() { if ((journaltexttitle = getText("Lab:Rooms/jt")) == NULL) return false; - buffer = g_lab->g_music->newOpen("P:JImage"); + buffer = g_lab->_music->newOpen("P:JImage"); if (!buffer) return false; @@ -628,7 +628,7 @@ static void drawJournalText() { char *CurText = journaltext; while (DrawingToPage < JPage) { - g_lab->g_music->updateMusic(); + g_lab->_music->updateMusic(); CurText = (char *)(journaltext + CharsDrawn); CharsDrawn += flowText(BigMsgFont, -2, 2, 0, false, false, false, false, VGAScaleX(52), VGAScaleY(32), VGAScaleX(152), VGAScaleY(148), CurText); @@ -648,7 +648,7 @@ static void drawJournalText() { CharsDrawn += flowTextToMem(&JBackImage, BigMsgFont, -2, 2, 0, false, false, false, true, VGAScaleX(52), VGAScaleY(32), VGAScaleX(152), VGAScaleY(148), CurText); } - g_lab->g_music->updateMusic(); + g_lab->_music->updateMusic(); CurText = (char *)(journaltext + CharsDrawn); lastpage = (*CurText == 0); flowTextToMem(&JBackImage, BigMsgFont, -2, 2, 0, false, false, false, true, VGAScaleX(171), VGAScaleY(32), VGAScaleX(271), VGAScaleY(148), CurText); @@ -663,14 +663,14 @@ static void drawJournalText() { static void turnPage(bool FromLeft) { if (FromLeft) { for (int i = 0; i < g_lab->_screenWidth; i += 8) { - g_lab->g_music->updateMusic(); + g_lab->_music->updateMusic(); g_lab->waitTOF(); ScreenImage.ImageData = g_lab->getVGABaseAddr(); g_lab->bltBitMap(&JBackImage, i, 0, &ScreenImage, i, 0, 8, g_lab->_screenHeight); } } else { for (int i = (g_lab->_screenWidth - 8); i > 0; i -= 8) { - g_lab->g_music->updateMusic(); + g_lab->_music->updateMusic(); g_lab->waitTOF(); ScreenImage.ImageData = g_lab->getVGABaseAddr(); g_lab->bltBitMap(&JBackImage, i, 0, &ScreenImage, i, 0, 8, g_lab->_screenHeight); @@ -685,7 +685,7 @@ static void turnPage(bool FromLeft) { void LabEngine::drawJournal(uint16 wipenum, bool needFade) { _event->mouseHide(); - g_music->updateMusic(); + _music->updateMusic(); if (!GotBackImage) JBackImage.ImageData = loadBackPict("P:Journal.pic", true); @@ -732,11 +732,11 @@ void LabEngine::processJournal() { uint16 Qualifier, GadID; while (1) { - g_music->updateMusic(); /* Make sure we check the music at least after every message */ + _music->updateMusic(); /* Make sure we check the music at least after every message */ Msg = getMsg(); if (Msg == NULL) { - g_music->updateMusic(); + _music->updateMusic(); } else { Class = Msg->msgClass; Qualifier = Msg->qualifier; @@ -785,7 +785,7 @@ void LabEngine::doJournal() { ScreenImage = JBackImage; ScreenImage.ImageData = getVGABaseAddr(); - g_music->updateMusic(); + _music->updateMusic(); loadJournalData(); drawJournal(0, true); @@ -837,7 +837,7 @@ bool saveRestoreGame() { if (slot >= 0) { isOK = loadGame(&RoomNum, &Direction, &(Inventory[QUARTERNUM].Many), slot); if (isOK) - g_lab->g_music->resetMusic(); + g_lab->_music->resetMusic(); } } @@ -855,7 +855,7 @@ static void getMonImages() { resetBuffer(); - buffer = g_lab->g_music->newOpen("P:MonImage", bufferSize); + buffer = g_lab->_music->newOpen("P:MonImage", bufferSize); if (!buffer) return; @@ -906,7 +906,7 @@ void LabEngine::drawMonText(char *text, uint16 x1, uint16 y1, uint16 x2, uint16 } while (DrawingToPage < monitorPage) { - g_music->updateMusic(); + _music->updateMusic(); CurText = (char *)(text + CharsDrawn); CharsDrawn += flowText(BigMsgFont, yspacing, 0, 0, false, false, false, false, x1, y1, x2, y2, CurText); lastpage = (*CurText == 0); @@ -960,11 +960,11 @@ void LabEngine::processMonitor(char *ntext, bool isinteractive, uint16 x1, uint1 } } - g_music->updateMusic(); /* Make sure we check the music at least after every message */ + _music->updateMusic(); /* Make sure we check the music at least after every message */ Msg = getMsg(); if (Msg == NULL) { - g_music->updateMusic(); + _music->updateMusic(); } else { Class = Msg->msgClass; Qualifier = Msg->qualifier; -- cgit v1.2.3 From 6cee2eb2be4e6977d659a47809a91454532c0f11 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 30 Nov 2015 01:42:12 +0100 Subject: LAB: Move RoomNum to main engine class --- engines/lab/special.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 7519ad1988..e3d1541814 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -90,7 +90,7 @@ extern BitMap *DispBitMap, *DrawBitMap; extern char diffcmap[3 * 256]; extern CloseDataPtr CPtr; extern InventoryData *Inventory; -extern uint16 RoomNum, Direction; +extern uint16 Direction; #define COMBINATIONUNLOCKED 130 #define BRICKOPEN 115 @@ -828,14 +828,14 @@ bool saveRestoreGame() { desc = dialog->createDefaultSaveDescription(slot); } - isOK = saveGame(RoomNum, Direction, Inventory[QUARTERNUM].Many, slot, desc); + isOK = saveGame(Direction, Inventory[QUARTERNUM].Many, slot, desc); } } else { // Restore GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Restore game:"), _("Restore"), false); int slot = dialog->runModalWithCurrentTarget(); if (slot >= 0) { - isOK = loadGame(&RoomNum, &Direction, &(Inventory[QUARTERNUM].Many), slot); + isOK = loadGame(&Direction, &(Inventory[QUARTERNUM].Many), slot); if (isOK) g_lab->_music->resetMusic(); } -- cgit v1.2.3 From 6d4b71e2ce21aa9843aa90522e972a95f3966bd6 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Mon, 30 Nov 2015 20:07:23 +0100 Subject: LAB: Renames in vga.cpp --- engines/lab/special.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index e3d1541814..f350a5cea0 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -162,7 +162,7 @@ void showCombination(const char *filename) { doCombination(); - g_lab->VGASetPal(diffcmap, 256); + g_lab->setPalette(diffcmap, 256); } @@ -313,7 +313,7 @@ void showTile(const char *filename, bool showsolution) { doTile(showsolution); - g_lab->VGASetPal(diffcmap, 256); + g_lab->setPalette(diffcmap, 256); } static void scrollRaster(int16 dx, int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2) { @@ -471,7 +471,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); - g_lab->VGASetPal(diffcmap, 256); + g_lab->setPalette(diffcmap, 256); freeAllStolenMem(); } @@ -533,7 +533,7 @@ void doWestPaper() { CharsPrinted = flowText(BigMsgFont, -4, 0, 0, false, false, false, true, VGAScaleX(162), VGAScaleY(y), VGAScaleX(275), VGAScaleY(148), ntext); - g_lab->VGASetPal(diffcmap, 256); + g_lab->setPalette(diffcmap, 256); freeAllStolenMem(); } @@ -841,7 +841,7 @@ bool saveRestoreGame() { } } - g_lab->WSDL_UpdateScreen(); + g_lab->screenUpdate(); return isOK; } -- cgit v1.2.3 From 24684fe321f337caf96af917a3b7e647e8fd113b Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 1 Dec 2015 02:05:29 +0200 Subject: LAB: Move getText to the Resource class Also, make getFont() error out when it can't find a font, and get rid of BigMsgFont --- engines/lab/special.cpp | 158 +++++++++++++++++------------------------------- 1 file changed, 57 insertions(+), 101 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index f350a5cea0..6be525dd30 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -54,8 +54,7 @@ static Image *Images[10]; byte combination[6] = { 0, 0, 0, 0, 0, 0 }, solution[] = { 0, 4, 0, 8, 7, 2 }; static uint16 combx[] = { 45, 83, 129, 166, 211, 248 }; -static TextFont *BigMsgFont; -static TextFont bmfont; +static TextFont *journalFont; static char *journaltext, *journaltexttitle; static uint16 JPage = 0; static bool lastpage = false; @@ -456,23 +455,15 @@ void mouseTile(Common::Point pos) { /* Does the things to properly set up the detective notes. */ /*****************************************************************************/ void doNotes() { - char *ntext; - - /* Load in the data */ - BigMsgFont = &bmfont; - - if (!(BigMsgFont = g_lab->_resource->getFont("P:Note.fon"))) { - BigMsgFont = NULL; - return; - } - - if ((ntext = getText("Lab:Rooms/Notes")) == NULL) - return; - - flowText(BigMsgFont, -2 + SVGACord(1), 0, 0, false, false, true, true, VGAScaleX(25) + SVGACord(15), VGAScaleY(50), VGAScaleX(295) - SVGACord(15), VGAScaleY(148), ntext); + TextFont *noteFont = g_lab->_resource->getFont("P:Note.fon"); + char *ntext = g_lab->_resource->getText("Lab:Rooms/Notes"); + flowText(noteFont, -2 + SVGACord(1), 0, 0, false, false, true, true, VGAScaleX(25) + SVGACord(15), VGAScaleY(50), VGAScaleX(295) - SVGACord(15), VGAScaleY(148), ntext); g_lab->setPalette(diffcmap, 256); - freeAllStolenMem(); + + delete[] noteFont->data; + free(noteFont); + delete[] ntext; } @@ -482,56 +473,39 @@ void doNotes() { /*****************************************************************************/ void doWestPaper() { char *ntext; + TextFont *paperFont; int32 FileLen, CharsPrinted; uint16 y = 268; - BigMsgFont = &bmfont; - - if (!(BigMsgFont = g_lab->_resource->getFont("P:News22.fon"))) { - BigMsgFont = NULL; - return; - } - - if ((ntext = getText("Lab:Rooms/Date")) == NULL) - return; - - flowText(BigMsgFont, 0, 0, 0, false, true, false, true, VGAScaleX(57), VGAScaleY(77) + SVGACord(2), VGAScaleX(262), VGAScaleY(91), ntext); - - BigMsgFont = &bmfont; - - if (!(BigMsgFont = g_lab->_resource->getFont("P:News32.fon"))) { - BigMsgFont = NULL; - return; - } - - if ((ntext = getText("Lab:Rooms/Headline")) == NULL) - return; + paperFont = g_lab->_resource->getFont("P:News22.fon"); + ntext = g_lab->_resource->getText("Lab:Rooms/Date"); + flowText(paperFont, 0, 0, 0, false, true, false, true, VGAScaleX(57), VGAScaleY(77) + SVGACord(2), VGAScaleX(262), VGAScaleY(91), ntext); + delete[] paperFont->data; + free(paperFont); + delete[] ntext; + paperFont = g_lab->_resource->getFont("P:News32.fon"); + ntext = g_lab->_resource->getText("Lab:Rooms/Headline"); FileLen = strlen(ntext) - 1; - CharsPrinted = flowText(BigMsgFont, -8, 0, 0, false, true, false, true, VGAScaleX(57), VGAScaleY(86) - SVGACord(2), VGAScaleX(262), VGAScaleY(118), ntext); - + CharsPrinted = flowText(paperFont, -8, 0, 0, false, true, false, true, VGAScaleX(57), VGAScaleY(86) - SVGACord(2), VGAScaleX(262), VGAScaleY(118), ntext); if (CharsPrinted < FileLen) { y = 130 - SVGACord(5); - flowText(BigMsgFont, -8 - SVGACord(1), 0, 0, false, true, false, true, VGAScaleX(57), VGAScaleY(86) - SVGACord(2), VGAScaleX(262), VGAScaleY(132), ntext); + flowText(paperFont, -8 - SVGACord(1), 0, 0, false, true, false, true, VGAScaleX(57), VGAScaleY(86) - SVGACord(2), VGAScaleX(262), VGAScaleY(132), ntext); } else y = 115 - SVGACord(5); - - BigMsgFont = &bmfont; - - if (!(BigMsgFont = g_lab->_resource->getFont("P:Note.fon"))) { - BigMsgFont = NULL; - return; - } - - if ((ntext = getText("Lab:Rooms/Col1")) == NULL) - return; - - CharsPrinted = flowText(BigMsgFont, -4, 0, 0, false, false, false, true, VGAScaleX(45), VGAScaleY(y), VGAScaleX(158), VGAScaleY(148), ntext); - - if ((ntext = getText("Lab:Rooms/Col2")) == NULL) - return; - - CharsPrinted = flowText(BigMsgFont, -4, 0, 0, false, false, false, true, VGAScaleX(162), VGAScaleY(y), VGAScaleX(275), VGAScaleY(148), ntext); + delete[] paperFont->data; + free(paperFont); + delete[] ntext; + + paperFont = g_lab->_resource->getFont("P:Note.fon"); + ntext = g_lab->_resource->getText("Lab:Rooms/Col1"); + CharsPrinted = flowText(paperFont, -4, 0, 0, false, false, false, true, VGAScaleX(45), VGAScaleY(y), VGAScaleX(158), VGAScaleY(148), ntext); + delete[] ntext; + ntext = g_lab->_resource->getText("Lab:Rooms/Col2"); + CharsPrinted = flowText(paperFont, -4, 0, 0, false, false, false, true, VGAScaleX(162), VGAScaleY(y), VGAScaleX(275), VGAScaleY(148), ntext); + delete[] ntext; + delete[] paperFont->data; + free(paperFont); g_lab->setPalette(diffcmap, 256); freeAllStolenMem(); @@ -546,12 +520,7 @@ static bool loadJournalData() { Gadget *TopGadget = &BackG; bool bridge, dirty, news, clean; - BigMsgFont = &bmfont; - - if (!(BigMsgFont = g_lab->_resource->getFont("P:Journal.fon"))) { - BigMsgFont = NULL; - return false; - } + journalFont = g_lab->_resource->getFont("P:Journal.fon"); g_lab->_music->updateMusic(); @@ -580,11 +549,8 @@ static bool loadJournalData() { else if (bridge) filename[11] = '1'; - if ((journaltext = getText(filename)) == NULL) - return false; - - if ((journaltexttitle = getText("Lab:Rooms/jt")) == NULL) - return false; + journaltext = g_lab->_resource->getText(filename); + journaltexttitle = g_lab->_resource->getText("Lab:Rooms/jt"); buffer = g_lab->_music->newOpen("P:JImage"); @@ -630,7 +596,7 @@ static void drawJournalText() { while (DrawingToPage < JPage) { g_lab->_music->updateMusic(); CurText = (char *)(journaltext + CharsDrawn); - CharsDrawn += flowText(BigMsgFont, -2, 2, 0, false, false, false, false, VGAScaleX(52), VGAScaleY(32), VGAScaleX(152), VGAScaleY(148), CurText); + CharsDrawn += flowText(journalFont, -2, 2, 0, false, false, false, false, VGAScaleX(52), VGAScaleY(32), VGAScaleX(152), VGAScaleY(148), CurText); lastpage = (*CurText == 0); @@ -642,16 +608,16 @@ static void drawJournalText() { if (JPage <= 1) { CurText = journaltexttitle; - flowTextToMem(&JBackImage, BigMsgFont, -2, 2, 0, false, true, true, true, VGAScaleX(52), VGAScaleY(32), VGAScaleX(152), VGAScaleY(148), CurText); + flowTextToMem(&JBackImage, journalFont, -2, 2, 0, false, true, true, true, VGAScaleX(52), VGAScaleY(32), VGAScaleX(152), VGAScaleY(148), CurText); } else { CurText = (char *)(journaltext + CharsDrawn); - CharsDrawn += flowTextToMem(&JBackImage, BigMsgFont, -2, 2, 0, false, false, false, true, VGAScaleX(52), VGAScaleY(32), VGAScaleX(152), VGAScaleY(148), CurText); + CharsDrawn += flowTextToMem(&JBackImage, journalFont, -2, 2, 0, false, false, false, true, VGAScaleX(52), VGAScaleY(32), VGAScaleX(152), VGAScaleY(148), CurText); } g_lab->_music->updateMusic(); CurText = (char *)(journaltext + CharsDrawn); lastpage = (*CurText == 0); - flowTextToMem(&JBackImage, BigMsgFont, -2, 2, 0, false, false, false, true, VGAScaleX(171), VGAScaleY(32), VGAScaleX(271), VGAScaleY(148), CurText); + flowTextToMem(&JBackImage, journalFont, -2, 2, 0, false, false, false, true, VGAScaleX(171), VGAScaleY(32), VGAScaleX(271), VGAScaleY(148), CurText); CurText = (char *)(journaltext + CharsDrawn); lastpage = lastpage || (*CurText == 0); @@ -869,7 +835,7 @@ static void getMonImages() { /*****************************************************************************/ /* Draws the text for the monitor. */ /*****************************************************************************/ -void LabEngine::drawMonText(char *text, uint16 x1, uint16 y1, uint16 x2, uint16 y2, bool isinteractive) { +void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16 y1, uint16 x2, uint16 y2, bool isinteractive) { uint16 DrawingToPage = 0, yspacing = 0, numlines, fheight; int32 CharsDrawn = 0L; char *CurText = text; @@ -883,7 +849,7 @@ void LabEngine::drawMonText(char *text, uint16 x1, uint16 y1, uint16 x2, uint16 numlines += (*text - '0'); text += 2; - fheight = textHeight(BigMsgFont); + fheight = textHeight(monitorFont); x1 = MonButton->Width + VGAScaleX(3); MonGadHeight = MonButton->Height + VGAScaleY(3); @@ -908,7 +874,7 @@ void LabEngine::drawMonText(char *text, uint16 x1, uint16 y1, uint16 x2, uint16 while (DrawingToPage < monitorPage) { _music->updateMusic(); CurText = (char *)(text + CharsDrawn); - CharsDrawn += flowText(BigMsgFont, yspacing, 0, 0, false, false, false, false, x1, y1, x2, y2, CurText); + CharsDrawn += flowText(monitorFont, yspacing, 0, 0, false, false, false, false, x1, y1, x2, y2, CurText); lastpage = (*CurText == 0); if (lastpage) @@ -919,7 +885,7 @@ void LabEngine::drawMonText(char *text, uint16 x1, uint16 y1, uint16 x2, uint16 CurText = (char *)(text + CharsDrawn); lastpage = (*CurText == 0); - CharsDrawn = flowText(BigMsgFont, yspacing, 2, 0, false, false, false, true, x1, y1, x2, y2, CurText); + CharsDrawn = flowText(monitorFont, yspacing, 2, 0, false, false, false, true, x1, y1, x2, y2, CurText); CurText += CharsDrawn; lastpage = lastpage || (*CurText == 0); @@ -929,7 +895,7 @@ void LabEngine::drawMonText(char *text, uint16 x1, uint16 y1, uint16 x2, uint16 /*****************************************************************************/ /* Processes user input. */ /*****************************************************************************/ -void LabEngine::processMonitor(char *ntext, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2) { +void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2) { IntuiMessage *Msg; uint32 Class; uint16 Qualifier, Code, MouseX, MouseY; @@ -953,10 +919,11 @@ void LabEngine::processMonitor(char *ntext, bool isinteractive, uint16 x1, uint1 monitorPage = 0; TextFileName = Test; - ntext = getText(TextFileName); + ntext = g_lab->_resource->getText(TextFileName); fade(false, 0); - drawMonText(ntext, x1, y1, x2, y2, isinteractive); + drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive); fade(true, 0); + delete[] ntext; } } @@ -981,14 +948,14 @@ void LabEngine::processMonitor(char *ntext, bool isinteractive, uint16 x1, uint1 if ((MouseX >= VGAScaleX(259)) && (MouseX <= VGAScaleX(289))) { if (!lastpage) { monitorPage += 1; - drawMonText(ntext, x1, y1, x2, y2, isinteractive); + drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive); } } else if ((MouseX >= VGAScaleX(0)) && (MouseX <= VGAScaleX(31))) { return; } else if ((MouseX >= VGAScaleX(290)) && (MouseX <= VGAScaleX(320))) { if (monitorPage >= 1) { monitorPage -= 1; - drawMonText(ntext, x1, y1, x2, y2, isinteractive); + drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive); } } else if ((MouseX >= VGAScaleX(31)) && (MouseX <= VGAScaleX(59))) { if (isinteractive) { @@ -1000,7 +967,7 @@ void LabEngine::processMonitor(char *ntext, bool isinteractive, uint16 x1, uint1 } } else if (monitorPage > 0) { monitorPage = 0; - drawMonText(ntext, x1, y1, x2, y2, isinteractive); + drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive); } } } else if (isinteractive) { @@ -1045,31 +1012,20 @@ void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive, lastpage = false; FadePalette = hipal; - BigMsgFont = &bmfont; - - if (!(BigMsgFont = _resource->getFont("P:Map.fon"))) { - freeAllStolenMem(); - BigMsgFont = NULL; - return; - } - + TextFont *monitorFont = _resource->getFont("P:Map.fon"); getMonImages(); - if ((ntext = getText(textfile)) == NULL) { - freeAllStolenMem(); - return; - } - + ntext = _resource->getText(textfile); loadBackPict(background, false); - - drawMonText(ntext, x1, y1, x2, y2, isinteractive); - + drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive); _event->mouseShow(); fade(true, 0); - processMonitor(ntext, isinteractive, x1, y1, x2, y2); + processMonitor(ntext, monitorFont, isinteractive, x1, y1, x2, y2); fade(false, 0); _event->mouseHide(); - + delete[] ntext; + delete[] monitorFont->data; + free(monitorFont); freeAllStolenMem(); setAPen(0); -- cgit v1.2.3 From 0fbf62f7f0115a0ad04b594f834e41cb7f719072 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 1 Dec 2015 02:17:26 +0200 Subject: LAB: Plug several font-related memory leaks. Some cleanup --- engines/lab/special.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 6be525dd30..70ec15af06 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -461,8 +461,7 @@ void doNotes() { flowText(noteFont, -2 + SVGACord(1), 0, 0, false, false, true, true, VGAScaleX(25) + SVGACord(15), VGAScaleY(50), VGAScaleX(295) - SVGACord(15), VGAScaleY(148), ntext); g_lab->setPalette(diffcmap, 256); - delete[] noteFont->data; - free(noteFont); + closeFont(noteFont); delete[] ntext; } @@ -480,8 +479,7 @@ void doWestPaper() { paperFont = g_lab->_resource->getFont("P:News22.fon"); ntext = g_lab->_resource->getText("Lab:Rooms/Date"); flowText(paperFont, 0, 0, 0, false, true, false, true, VGAScaleX(57), VGAScaleY(77) + SVGACord(2), VGAScaleX(262), VGAScaleY(91), ntext); - delete[] paperFont->data; - free(paperFont); + closeFont(paperFont); delete[] ntext; paperFont = g_lab->_resource->getFont("P:News32.fon"); @@ -493,8 +491,7 @@ void doWestPaper() { flowText(paperFont, -8 - SVGACord(1), 0, 0, false, true, false, true, VGAScaleX(57), VGAScaleY(86) - SVGACord(2), VGAScaleX(262), VGAScaleY(132), ntext); } else y = 115 - SVGACord(5); - delete[] paperFont->data; - free(paperFont); + closeFont(paperFont); delete[] ntext; paperFont = g_lab->_resource->getFont("P:Note.fon"); @@ -504,8 +501,7 @@ void doWestPaper() { ntext = g_lab->_resource->getText("Lab:Rooms/Col2"); CharsPrinted = flowText(paperFont, -4, 0, 0, false, false, false, true, VGAScaleX(162), VGAScaleY(y), VGAScaleX(275), VGAScaleY(148), ntext); delete[] ntext; - delete[] paperFont->data; - free(paperFont); + closeFont(paperFont); g_lab->setPalette(diffcmap, 256); freeAllStolenMem(); @@ -520,7 +516,7 @@ static bool loadJournalData() { Gadget *TopGadget = &BackG; bool bridge, dirty, news, clean; - journalFont = g_lab->_resource->getFont("P:Journal.fon"); + journalFont = g_lab->_resource->getFont("P:Journal.fon"); // FIXME: memory leak g_lab->_music->updateMusic(); @@ -1024,8 +1020,7 @@ void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive, fade(false, 0); _event->mouseHide(); delete[] ntext; - delete[] monitorFont->data; - free(monitorFont); + closeFont(monitorFont); freeAllStolenMem(); setAPen(0); -- cgit v1.2.3 From f817c1de2e96da59362ea4e5cbdffe40fffa4dbb Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 1 Dec 2015 01:16:15 +0100 Subject: LAB: Get rid of stddefines --- engines/lab/special.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 70ec15af06..59cf2d166e 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -40,7 +40,6 @@ #include "lab/diff.h" #include "lab/text.h" #include "lab/mouse.h" -#include "lab/stddefines.h" #include "lab/parsetypes.h" #include "lab/resource.h" -- cgit v1.2.3 From 3f33ad277dc42526fb56845f522adad0064ee033 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Tue, 1 Dec 2015 10:35:31 +0100 Subject: LAB: More renames --- engines/lab/special.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 59cf2d166e..e23ea7035b 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -180,7 +180,7 @@ static void changeCombination(uint16 number) { combnum = combination[number]; - display.ImageData = g_lab->getVGABaseAddr(); + display.ImageData = g_lab->getCurrentDrawingBuffer(); display.Width = g_lab->_screenWidth; display.Height = g_lab->_screenHeight; @@ -191,7 +191,7 @@ static void changeCombination(uint16 number) { } else g_lab->waitTOF(); - display.ImageData = g_lab->getVGABaseAddr(); + display.ImageData = g_lab->getCurrentDrawingBuffer(); g_lab->scrollDisplayY(2, VGAScaleX(combx[number]), VGAScaleY(65), VGAScaleX(combx[number]) + (Images[combnum])->Width - 1, VGAScaleY(65) + (Images[combnum])->Height); @@ -626,14 +626,14 @@ static void turnPage(bool FromLeft) { for (int i = 0; i < g_lab->_screenWidth; i += 8) { g_lab->_music->updateMusic(); g_lab->waitTOF(); - ScreenImage.ImageData = g_lab->getVGABaseAddr(); + ScreenImage.ImageData = g_lab->getCurrentDrawingBuffer(); g_lab->bltBitMap(&JBackImage, i, 0, &ScreenImage, i, 0, 8, g_lab->_screenHeight); } } else { for (int i = (g_lab->_screenWidth - 8); i > 0; i -= 8) { g_lab->_music->updateMusic(); g_lab->waitTOF(); - ScreenImage.ImageData = g_lab->getVGABaseAddr(); + ScreenImage.ImageData = g_lab->getCurrentDrawingBuffer(); g_lab->bltBitMap(&JBackImage, i, 0, &ScreenImage, i, 0, 8, g_lab->_screenHeight); } } @@ -653,7 +653,7 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) { drawJournalText(); - ScreenImage.ImageData = getVGABaseAddr(); + ScreenImage.ImageData = getCurrentDrawingBuffer(); if (wipenum == 0) bltBitMap(&JBackImage, 0, 0, &ScreenImage, 0, 0, _screenWidth, _screenHeight); @@ -744,7 +744,7 @@ void LabEngine::doJournal() { CancelG.NextGadget = &ForwardG; ScreenImage = JBackImage; - ScreenImage.ImageData = getVGABaseAddr(); + ScreenImage.ImageData = getCurrentDrawingBuffer(); _music->updateMusic(); loadJournalData(); @@ -758,7 +758,7 @@ void LabEngine::doJournal() { fade(false, 0); _event->mouseHide(); - ScreenImage.ImageData = getVGABaseAddr(); + ScreenImage.ImageData = getCurrentDrawingBuffer(); setAPen(0); rectFill(0, 0, _screenWidth - 1, _screenHeight - 1); -- cgit v1.2.3 From d656aa4859352e3d08e15346a482c943c1868502 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 1 Dec 2015 20:10:42 +0100 Subject: LAB: Introduce the Anim class (WIP) --- engines/lab/special.cpp | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index e23ea7035b..afe3efb64f 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -37,7 +37,7 @@ #include "lab/labfun.h" #include "lab/parsefun.h" #include "lab/interface.h" -#include "lab/diff.h" +#include "lab/anim.h" #include "lab/text.h" #include "lab/mouse.h" #include "lab/parsetypes.h" @@ -83,9 +83,7 @@ uint16 CurTile[4][4] = { extern TextFont *MsgFont; extern uint16 *FadePalette; -extern bool nopalchange, DoBlack; extern BitMap *DispBitMap, *DrawBitMap; -extern char diffcmap[3 * 256]; extern CloseDataPtr CPtr; extern InventoryData *Inventory; extern uint16 Direction; @@ -111,7 +109,7 @@ static byte *loadBackPict(const char *fileName, bool tomem) { byte *res = NULL; FadePalette = hipal; - nopalchange = true; + g_lab->_anim->nopalchange = true; if (tomem) res = readPictToMem(fileName, g_lab->_screenWidth, g_lab->_screenHeight); @@ -119,12 +117,12 @@ static byte *loadBackPict(const char *fileName, bool tomem) { readPict(fileName, true); for (uint16 i = 0; i < 16; i++) { - hipal[i] = ((diffcmap[i * 3] >> 2) << 8) + - ((diffcmap[i * 3 + 1] >> 2) << 4) + - ((diffcmap[i * 3 + 2] >> 2)); + hipal[i] = ((g_lab->_anim->diffcmap[i * 3] >> 2) << 8) + + ((g_lab->_anim->diffcmap[i * 3 + 1] >> 2) << 4) + + ((g_lab->_anim->diffcmap[i * 3 + 2] >> 2)); } - nopalchange = false; + g_lab->_anim->nopalchange = false; return res; } @@ -144,10 +142,10 @@ void showCombination(const char *filename) { byte **buffer; resetBuffer(); - DoBlack = true; - nopalchange = true; + g_lab->_anim->DoBlack = true; + g_lab->_anim->nopalchange = true; readPict(filename, true); - nopalchange = false; + g_lab->_anim->nopalchange = false; blackScreen(); @@ -160,7 +158,7 @@ void showCombination(const char *filename) { doCombination(); - g_lab->setPalette(diffcmap, 256); + g_lab->setPalette(g_lab->_anim->diffcmap, 256); } @@ -287,10 +285,10 @@ void showTile(const char *filename, bool showsolution) { byte **buffer; resetBuffer(); - DoBlack = true; - nopalchange = true; + g_lab->_anim->DoBlack = true; + g_lab->_anim->nopalchange = true; readPict(filename, true); - nopalchange = false; + g_lab->_anim->nopalchange = false; blackScreen(); if (showsolution) { @@ -311,7 +309,7 @@ void showTile(const char *filename, bool showsolution) { doTile(showsolution); - g_lab->setPalette(diffcmap, 256); + g_lab->setPalette(g_lab->_anim->diffcmap, 256); } static void scrollRaster(int16 dx, int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2) { @@ -425,7 +423,7 @@ static void changeTile(uint16 col, uint16 row) { if (check) { g_lab->_conditions->inclElement(BRICKOPEN); /* unlocked combination */ - DoBlack = true; + g_lab->_anim->DoBlack = true; check = readPict("p:Up/BDOpen", true); } } @@ -458,7 +456,7 @@ void doNotes() { char *ntext = g_lab->_resource->getText("Lab:Rooms/Notes"); flowText(noteFont, -2 + SVGACord(1), 0, 0, false, false, true, true, VGAScaleX(25) + SVGACord(15), VGAScaleY(50), VGAScaleX(295) - SVGACord(15), VGAScaleY(148), ntext); - g_lab->setPalette(diffcmap, 256); + g_lab->setPalette(g_lab->_anim->diffcmap, 256); closeFont(noteFont); delete[] ntext; @@ -502,7 +500,7 @@ void doWestPaper() { delete[] ntext; closeFont(paperFont); - g_lab->setPalette(diffcmap, 256); + g_lab->setPalette(g_lab->_anim->diffcmap, 256); freeAllStolenMem(); } @@ -674,14 +672,14 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) { if (needFade) fade(true, 0); - nopalchange = true; + g_lab->_anim->nopalchange = true; JBackImage.ImageData = readPictToMem("P:Journal.pic", _screenWidth, _screenHeight); GotBackImage = true; eatMessages(); _event->mouseShow(); - nopalchange = false; + g_lab->_anim->nopalchange = false; } /*****************************************************************************/ -- cgit v1.2.3 From 148d64eceb86e6756f0ff77b664bd6592a7dc016 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Tue, 1 Dec 2015 21:42:44 +0100 Subject: LAB: Put Image into a separate class. Leaks memory for now --- engines/lab/special.cpp | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index afe3efb64f..6f70cb0f1a 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -35,6 +35,7 @@ #include "lab/lab.h" #include "lab/labfun.h" +#include "lab/image.h" #include "lab/parsefun.h" #include "lab/interface.h" #include "lab/anim.h" @@ -132,7 +133,7 @@ static byte *loadBackPict(const char *fileName, bool tomem) { /*****************************************************************************/ static void doCombination() { for (uint16 i = 0; i <= 5; i++) - g_lab->drawImage(Images[combination[i]], VGAScaleX(combx[i]), VGAScaleY(65)); + Images[combination[i]]->drawImage(VGAScaleX(combx[i]), VGAScaleY(65)); } /*****************************************************************************/ @@ -152,7 +153,7 @@ void showCombination(const char *filename) { buffer = g_lab->_music->newOpen("P:Numbers"); for (uint16 CurBit = 0; CurBit < 10; CurBit++) - readImage(buffer, &(Images[CurBit])); + Images[CurBit] = new Image(buffer); allocFile((void **)&g_lab->_tempScrollData, Images[0]->Width * Images[0]->Height * 2L, "tempdata"); @@ -267,7 +268,7 @@ static void doTile(bool showsolution) { num = CurTile[col] [row]; if (showsolution || num) - g_lab->drawImage(Tiles[num], cols + (col * colm), rows + (row * rowm)); + Tiles[num]->drawImage(cols + (col * colm), rows + (row * rowm)); col++; } @@ -303,7 +304,7 @@ void showTile(const char *filename, bool showsolution) { return; for (uint16 curBit = start; curBit < 16; curBit++) - readImage(buffer, &(Tiles[curBit])); + Tiles[curBit] = new Image(buffer); allocFile((void **)&g_lab->_tempScrollData, Tiles[1]->Width * Tiles[1]->Height * 2L, "tempdata"); @@ -550,12 +551,12 @@ static bool loadJournalData() { if (!buffer) return false; - readImage(buffer, &(BackG.Im)); - readImage(buffer, &(BackG.ImAlt)); - readImage(buffer, &(ForwardG.Im)); - readImage(buffer, &(ForwardG.ImAlt)); - readImage(buffer, &(CancelG.Im)); - readImage(buffer, &(CancelG.ImAlt)); + BackG.Im = new Image(buffer); + BackG.ImAlt = new Image(buffer); + ForwardG.Im = new Image(buffer); + ForwardG.ImAlt = new Image(buffer); + CancelG.Im = new Image(buffer); + CancelG.ImAlt = new Image(buffer); BackG.KeyEquiv = VKEY_LTARROW; ForwardG.KeyEquiv = VKEY_RTARROW; @@ -819,7 +820,7 @@ static void getMonImages() { if (!buffer) return; - readImage(buffer, &MonButton); + MonButton = new Image(buffer); stealBufMem(bufferSize); /* Trick: protects the memory where the buttons are so they won't be over-written */ } @@ -855,7 +856,7 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16 rectFill(0, 0, _screenWidth - 1, y2); for (uint16 i = 0; i < numlines; i++) - drawImage(MonButton, 0, i * MonGadHeight); + MonButton->drawImage(0, i * MonGadHeight); } else if (isinteractive) { setAPen(0); rectFill(0, 0, _screenWidth - 1, y2); -- cgit v1.2.3 From 2fb0250e0c26ff7ee24a9b05b22c6d8b177131af Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 2 Dec 2015 00:34:51 +0100 Subject: LAB: Renaming of Anim --- engines/lab/special.cpp | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 6f70cb0f1a..2744d3de32 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -110,7 +110,7 @@ static byte *loadBackPict(const char *fileName, bool tomem) { byte *res = NULL; FadePalette = hipal; - g_lab->_anim->nopalchange = true; + g_lab->_anim->_noPalChange = true; if (tomem) res = readPictToMem(fileName, g_lab->_screenWidth, g_lab->_screenHeight); @@ -118,12 +118,12 @@ static byte *loadBackPict(const char *fileName, bool tomem) { readPict(fileName, true); for (uint16 i = 0; i < 16; i++) { - hipal[i] = ((g_lab->_anim->diffcmap[i * 3] >> 2) << 8) + - ((g_lab->_anim->diffcmap[i * 3 + 1] >> 2) << 4) + - ((g_lab->_anim->diffcmap[i * 3 + 2] >> 2)); + hipal[i] = ((g_lab->_anim->_diffPalette[i * 3] >> 2) << 8) + + ((g_lab->_anim->_diffPalette[i * 3 + 1] >> 2) << 4) + + ((g_lab->_anim->_diffPalette[i * 3 + 2] >> 2)); } - g_lab->_anim->nopalchange = false; + g_lab->_anim->_noPalChange = false; return res; } @@ -143,10 +143,10 @@ void showCombination(const char *filename) { byte **buffer; resetBuffer(); - g_lab->_anim->DoBlack = true; - g_lab->_anim->nopalchange = true; + g_lab->_anim->_doBlack = true; + g_lab->_anim->_noPalChange = true; readPict(filename, true); - g_lab->_anim->nopalchange = false; + g_lab->_anim->_noPalChange = false; blackScreen(); @@ -159,7 +159,7 @@ void showCombination(const char *filename) { doCombination(); - g_lab->setPalette(g_lab->_anim->diffcmap, 256); + g_lab->setPalette(g_lab->_anim->_diffPalette, 256); } @@ -286,10 +286,10 @@ void showTile(const char *filename, bool showsolution) { byte **buffer; resetBuffer(); - g_lab->_anim->DoBlack = true; - g_lab->_anim->nopalchange = true; + g_lab->_anim->_doBlack = true; + g_lab->_anim->_noPalChange = true; readPict(filename, true); - g_lab->_anim->nopalchange = false; + g_lab->_anim->_noPalChange = false; blackScreen(); if (showsolution) { @@ -310,7 +310,7 @@ void showTile(const char *filename, bool showsolution) { doTile(showsolution); - g_lab->setPalette(g_lab->_anim->diffcmap, 256); + g_lab->setPalette(g_lab->_anim->_diffPalette, 256); } static void scrollRaster(int16 dx, int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2) { @@ -424,7 +424,7 @@ static void changeTile(uint16 col, uint16 row) { if (check) { g_lab->_conditions->inclElement(BRICKOPEN); /* unlocked combination */ - g_lab->_anim->DoBlack = true; + g_lab->_anim->_doBlack = true; check = readPict("p:Up/BDOpen", true); } } @@ -457,7 +457,7 @@ void doNotes() { char *ntext = g_lab->_resource->getText("Lab:Rooms/Notes"); flowText(noteFont, -2 + SVGACord(1), 0, 0, false, false, true, true, VGAScaleX(25) + SVGACord(15), VGAScaleY(50), VGAScaleX(295) - SVGACord(15), VGAScaleY(148), ntext); - g_lab->setPalette(g_lab->_anim->diffcmap, 256); + g_lab->setPalette(g_lab->_anim->_diffPalette, 256); closeFont(noteFont); delete[] ntext; @@ -501,7 +501,7 @@ void doWestPaper() { delete[] ntext; closeFont(paperFont); - g_lab->setPalette(g_lab->_anim->diffcmap, 256); + g_lab->setPalette(g_lab->_anim->_diffPalette, 256); freeAllStolenMem(); } @@ -673,14 +673,14 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) { if (needFade) fade(true, 0); - g_lab->_anim->nopalchange = true; + g_lab->_anim->_noPalChange = true; JBackImage.ImageData = readPictToMem("P:Journal.pic", _screenWidth, _screenHeight); GotBackImage = true; eatMessages(); _event->mouseShow(); - g_lab->_anim->nopalchange = false; + g_lab->_anim->_noPalChange = false; } /*****************************************************************************/ -- cgit v1.2.3 From 8fa64824a2dc1b5b2470f2ae4830f5573f5d01df Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 3 Dec 2015 01:06:04 +0100 Subject: LAB: Some renaming, move a couple of variables to game engine --- engines/lab/special.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 2744d3de32..6c5ff021a8 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -551,12 +551,12 @@ static bool loadJournalData() { if (!buffer) return false; - BackG.Im = new Image(buffer); - BackG.ImAlt = new Image(buffer); - ForwardG.Im = new Image(buffer); - ForwardG.ImAlt = new Image(buffer); - CancelG.Im = new Image(buffer); - CancelG.ImAlt = new Image(buffer); + BackG._image = new Image(buffer); + BackG._altImage = new Image(buffer); + ForwardG._image = new Image(buffer); + ForwardG._altImage = new Image(buffer); + CancelG._image = new Image(buffer); + CancelG._altImage = new Image(buffer); BackG.KeyEquiv = VKEY_LTARROW; ForwardG.KeyEquiv = VKEY_RTARROW; -- cgit v1.2.3 From 88ede5d2d5865f88db1f77f127089574ec2a5e1c Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Wed, 2 Dec 2015 11:49:01 +0100 Subject: LAB: Rename Image class members --- engines/lab/special.cpp | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 6c5ff021a8..4d71b443e1 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -155,7 +155,7 @@ void showCombination(const char *filename) { for (uint16 CurBit = 0; CurBit < 10; CurBit++) Images[CurBit] = new Image(buffer); - allocFile((void **)&g_lab->_tempScrollData, Images[0]->Width * Images[0]->Height * 2L, "tempdata"); + allocFile((void **)&g_lab->_tempScrollData, Images[0]->_width * Images[0]->_height * 2L, "tempdata"); doCombination(); @@ -179,22 +179,22 @@ static void changeCombination(uint16 number) { combnum = combination[number]; - display.ImageData = g_lab->getCurrentDrawingBuffer(); - display.Width = g_lab->_screenWidth; - display.Height = g_lab->_screenHeight; + display._imageData = g_lab->getCurrentDrawingBuffer(); + display._width = g_lab->_screenWidth; + display._height = g_lab->_screenHeight; - for (uint16 i = 1; i <= (Images[combnum]->Height / 2); i++) { + for (uint16 i = 1; i <= (Images[combnum]->_height / 2); i++) { if (g_lab->_isHiRes) { if (i & 1) g_lab->waitTOF(); } else g_lab->waitTOF(); - display.ImageData = g_lab->getCurrentDrawingBuffer(); + display._imageData = g_lab->getCurrentDrawingBuffer(); - g_lab->scrollDisplayY(2, VGAScaleX(combx[number]), VGAScaleY(65), VGAScaleX(combx[number]) + (Images[combnum])->Width - 1, VGAScaleY(65) + (Images[combnum])->Height); + g_lab->scrollDisplayY(2, VGAScaleX(combx[number]), VGAScaleY(65), VGAScaleX(combx[number]) + (Images[combnum])->_width - 1, VGAScaleY(65) + (Images[combnum])->_height); - g_lab->bltBitMap(Images[combnum], 0, (Images[combnum])->Height - (2 * i), &(display), VGAScaleX(combx[number]), VGAScaleY(65), (Images[combnum])->Width, 2); + g_lab->bltBitMap(Images[combnum], 0, (Images[combnum])->_height - (2 * i), &(display), VGAScaleX(combx[number]), VGAScaleY(65), (Images[combnum])->_width, 2); } for (uint16 i = 0; i < 6; i++) @@ -306,7 +306,7 @@ void showTile(const char *filename, bool showsolution) { for (uint16 curBit = start; curBit < 16; curBit++) Tiles[curBit] = new Image(buffer); - allocFile((void **)&g_lab->_tempScrollData, Tiles[1]->Width * Tiles[1]->Height * 2L, "tempdata"); + allocFile((void **)&g_lab->_tempScrollData, Tiles[1]->_width * Tiles[1]->_height * 2L, "tempdata"); doTile(showsolution); @@ -625,14 +625,14 @@ static void turnPage(bool FromLeft) { for (int i = 0; i < g_lab->_screenWidth; i += 8) { g_lab->_music->updateMusic(); g_lab->waitTOF(); - ScreenImage.ImageData = g_lab->getCurrentDrawingBuffer(); + ScreenImage._imageData = g_lab->getCurrentDrawingBuffer(); g_lab->bltBitMap(&JBackImage, i, 0, &ScreenImage, i, 0, 8, g_lab->_screenHeight); } } else { for (int i = (g_lab->_screenWidth - 8); i > 0; i -= 8) { g_lab->_music->updateMusic(); g_lab->waitTOF(); - ScreenImage.ImageData = g_lab->getCurrentDrawingBuffer(); + ScreenImage._imageData = g_lab->getCurrentDrawingBuffer(); g_lab->bltBitMap(&JBackImage, i, 0, &ScreenImage, i, 0, 8, g_lab->_screenHeight); } } @@ -648,11 +648,11 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) { _music->updateMusic(); if (!GotBackImage) - JBackImage.ImageData = loadBackPict("P:Journal.pic", true); + JBackImage._imageData = loadBackPict("P:Journal.pic", true); drawJournalText(); - ScreenImage.ImageData = getCurrentDrawingBuffer(); + ScreenImage._imageData = getCurrentDrawingBuffer(); if (wipenum == 0) bltBitMap(&JBackImage, 0, 0, &ScreenImage, 0, 0, _screenWidth, _screenHeight); @@ -674,7 +674,7 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) { fade(true, 0); g_lab->_anim->_noPalChange = true; - JBackImage.ImageData = readPictToMem("P:Journal.pic", _screenWidth, _screenHeight); + JBackImage._imageData = readPictToMem("P:Journal.pic", _screenWidth, _screenHeight); GotBackImage = true; eatMessages(); @@ -735,15 +735,15 @@ void LabEngine::doJournal() { lastpage = false; GotBackImage = false; - JBackImage.Width = _screenWidth; - JBackImage.Height = _screenHeight; - JBackImage.ImageData = NULL; + JBackImage._width = _screenWidth; + JBackImage._height = _screenHeight; + JBackImage._imageData = NULL; BackG.NextGadget = &CancelG; CancelG.NextGadget = &ForwardG; ScreenImage = JBackImage; - ScreenImage.ImageData = getCurrentDrawingBuffer(); + ScreenImage._imageData = getCurrentDrawingBuffer(); _music->updateMusic(); loadJournalData(); @@ -757,7 +757,7 @@ void LabEngine::doJournal() { fade(false, 0); _event->mouseHide(); - ScreenImage.ImageData = getCurrentDrawingBuffer(); + ScreenImage._imageData = getCurrentDrawingBuffer(); setAPen(0); rectFill(0, 0, _screenWidth - 1, _screenHeight - 1); @@ -844,8 +844,8 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16 text += 2; fheight = textHeight(monitorFont); - x1 = MonButton->Width + VGAScaleX(3); - MonGadHeight = MonButton->Height + VGAScaleY(3); + x1 = MonButton->_width + VGAScaleX(3); + MonGadHeight = MonButton->_height + VGAScaleY(3); if (MonGadHeight > fheight) yspacing = MonGadHeight - fheight; -- cgit v1.2.3 From 17d6e5e8608dfbf70fb08507da1ac196e04c0654 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Wed, 2 Dec 2015 11:54:42 +0100 Subject: LAB: Moved bltBitMap to Image class --- engines/lab/special.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 4d71b443e1..419e0d3a05 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -194,7 +194,7 @@ static void changeCombination(uint16 number) { g_lab->scrollDisplayY(2, VGAScaleX(combx[number]), VGAScaleY(65), VGAScaleX(combx[number]) + (Images[combnum])->_width - 1, VGAScaleY(65) + (Images[combnum])->_height); - g_lab->bltBitMap(Images[combnum], 0, (Images[combnum])->_height - (2 * i), &(display), VGAScaleX(combx[number]), VGAScaleY(65), (Images[combnum])->_width, 2); + Images[combnum]->bltBitMap(0, (Images[combnum])->_height - (2 * i), &(display), VGAScaleX(combx[number]), VGAScaleY(65), (Images[combnum])->_width, 2); } for (uint16 i = 0; i < 6; i++) @@ -626,14 +626,14 @@ static void turnPage(bool FromLeft) { g_lab->_music->updateMusic(); g_lab->waitTOF(); ScreenImage._imageData = g_lab->getCurrentDrawingBuffer(); - g_lab->bltBitMap(&JBackImage, i, 0, &ScreenImage, i, 0, 8, g_lab->_screenHeight); + JBackImage.bltBitMap(i, 0, &ScreenImage, i, 0, 8, g_lab->_screenHeight); } } else { for (int i = (g_lab->_screenWidth - 8); i > 0; i -= 8) { g_lab->_music->updateMusic(); g_lab->waitTOF(); ScreenImage._imageData = g_lab->getCurrentDrawingBuffer(); - g_lab->bltBitMap(&JBackImage, i, 0, &ScreenImage, i, 0, 8, g_lab->_screenHeight); + JBackImage.bltBitMap(i, 0, &ScreenImage, i, 0, 8, g_lab->_screenHeight); } } } @@ -655,7 +655,7 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) { ScreenImage._imageData = getCurrentDrawingBuffer(); if (wipenum == 0) - bltBitMap(&JBackImage, 0, 0, &ScreenImage, 0, 0, _screenWidth, _screenHeight); + JBackImage.bltBitMap(0, 0, &ScreenImage, 0, 0, _screenWidth, _screenHeight); else turnPage((bool)(wipenum == 1)); -- cgit v1.2.3 From adbb0ce0c52e2a9f0f6c52adf1d83bf351e8e1fb Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Wed, 2 Dec 2015 12:04:31 +0100 Subject: LAB: Renamed mouse.* to eventman.* --- engines/lab/special.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 419e0d3a05..401d89766c 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -40,7 +40,6 @@ #include "lab/interface.h" #include "lab/anim.h" #include "lab/text.h" -#include "lab/mouse.h" #include "lab/parsetypes.h" #include "lab/resource.h" -- cgit v1.2.3 From 646c29d5a34fa85c7dd6915de31c28465e7797a1 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Thu, 3 Dec 2015 11:01:50 +0100 Subject: LAB: Renames and moved vars to classes --- engines/lab/special.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 401d89766c..8e63d36ee5 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -81,7 +81,6 @@ uint16 CurTile[4][4] = { { 10, 13, 12, 0 } }; -extern TextFont *MsgFont; extern uint16 *FadePalette; extern BitMap *DispBitMap, *DrawBitMap; extern CloseDataPtr CPtr; -- cgit v1.2.3 From c67a9e867c2f40edcdecbc5077dfc2a6edcb443e Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Thu, 3 Dec 2015 11:02:58 +0100 Subject: LAB: More renames --- engines/lab/special.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 8e63d36ee5..946c8af9a8 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -892,17 +892,17 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isintera uint32 Class; uint16 Qualifier, Code, MouseX, MouseY; const char *Test = " ", *StartFileName = TextFileName; - CloseDataPtr StartCPtr = CPtr, TestCPtr, LastCPtr[10]; + CloseDataPtr startcptr = CPtr, testcptr, lastcptr[10]; uint16 depth = 0; - LastCPtr[0] = CPtr; + lastcptr[0] = CPtr; while (1) { if (isinteractive) { if (CPtr == NULL) - CPtr = StartCPtr; + CPtr = startcptr; - if (CPtr == StartCPtr) + if (CPtr == startcptr) Test = StartFileName; else Test = CPtr->GraphicName; @@ -955,7 +955,7 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isintera if (depth) { depth--; - CPtr = LastCPtr[depth]; + CPtr = lastcptr[depth]; } } else if (monitorPage > 0) { monitorPage = 0; @@ -963,13 +963,13 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isintera } } } else if (isinteractive) { - TestCPtr = CPtr; + testcptr = CPtr; MouseY = 64 + (MouseY / MonGadHeight) * 42; MouseX = 101; setCurClose(Common::Point(MouseX, MouseY), &CPtr, true); - if (TestCPtr != CPtr) { - LastCPtr[depth] = TestCPtr; + if (testcptr != CPtr) { + lastcptr[depth] = testcptr; depth++; } } -- cgit v1.2.3 From 4424463f0618b8ae4a8416cf76024644497a79ad Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Thu, 3 Dec 2015 11:10:58 +0100 Subject: LAB: Moved CPtr to engine class --- engines/lab/special.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 946c8af9a8..18810566bf 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -83,7 +83,6 @@ uint16 CurTile[4][4] = { extern uint16 *FadePalette; extern BitMap *DispBitMap, *DrawBitMap; -extern CloseDataPtr CPtr; extern InventoryData *Inventory; extern uint16 Direction; @@ -892,20 +891,20 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isintera uint32 Class; uint16 Qualifier, Code, MouseX, MouseY; const char *Test = " ", *StartFileName = TextFileName; - CloseDataPtr startcptr = CPtr, testcptr, lastcptr[10]; + CloseDataPtr startcptr = _cptr, testcptr, lastcptr[10]; uint16 depth = 0; - lastcptr[0] = CPtr; + lastcptr[0] = _cptr; while (1) { if (isinteractive) { - if (CPtr == NULL) - CPtr = startcptr; + if (_cptr == NULL) + _cptr = startcptr; - if (CPtr == startcptr) + if (_cptr == startcptr) Test = StartFileName; else - Test = CPtr->GraphicName; + Test = _cptr->GraphicName; if (strcmp(Test, TextFileName)) { monitorPage = 0; @@ -955,7 +954,7 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isintera if (depth) { depth--; - CPtr = lastcptr[depth]; + _cptr = lastcptr[depth]; } } else if (monitorPage > 0) { monitorPage = 0; @@ -963,12 +962,12 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isintera } } } else if (isinteractive) { - testcptr = CPtr; + testcptr = _cptr; MouseY = 64 + (MouseY / MonGadHeight) * 42; MouseX = 101; - setCurClose(Common::Point(MouseX, MouseY), &CPtr, true); + setCurClose(Common::Point(MouseX, MouseY), &_cptr, true); - if (testcptr != CPtr) { + if (testcptr != _cptr) { lastcptr[depth] = testcptr; depth++; } -- cgit v1.2.3 From 1913a61f30f4200c044f11268ab6fca40f0af510 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 3 Dec 2015 14:22:04 +0200 Subject: LAB: Some renaming and cleanup --- engines/lab/special.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 18810566bf..50cf0fe259 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -657,14 +657,14 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) { turnPage((bool)(wipenum == 1)); if (JPage == 0) - ghoastGadget(&BackG, 15); + disableGadget(&BackG, 15); else - unGhoastGadget(&BackG); + enableGadget(&BackG); if (lastpage) - ghoastGadget(&ForwardG, 15); + disableGadget(&ForwardG, 15); else - unGhoastGadget(&ForwardG); + enableGadget(&ForwardG); if (needFade) -- cgit v1.2.3 From 8f4d9c9c05e71036e80b47db380eff7922087fd5 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 3 Dec 2015 15:06:45 +0200 Subject: LAB: Image accepts a Common::File now --- engines/lab/special.cpp | 60 +++++++++++++++++-------------------------------- 1 file changed, 20 insertions(+), 40 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 50cf0fe259..f8b0c2091e 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -137,8 +137,6 @@ static void doCombination() { /* Reads in a backdrop picture. */ /*****************************************************************************/ void showCombination(const char *filename) { - byte **buffer; - resetBuffer(); g_lab->_anim->_doBlack = true; g_lab->_anim->_noPalChange = true; @@ -147,10 +145,12 @@ void showCombination(const char *filename) { blackScreen(); - buffer = g_lab->_music->newOpen("P:Numbers"); + Common::File *numFile = g_lab->_resource->openDataFile("P:Numbers"); for (uint16 CurBit = 0; CurBit < 10; CurBit++) - Images[CurBit] = new Image(buffer); + Images[CurBit] = new Image(numFile); + + delete numFile; allocFile((void **)&g_lab->_tempScrollData, Images[0]->_width * Images[0]->_height * 2L, "tempdata"); @@ -279,8 +279,7 @@ static void doTile(bool showsolution) { /* Reads in a backdrop picture. */ /*****************************************************************************/ void showTile(const char *filename, bool showsolution) { - uint16 start; - byte **buffer; + uint16 start = showsolution ? 0 : 1; resetBuffer(); g_lab->_anim->_doBlack = true; @@ -289,19 +288,12 @@ void showTile(const char *filename, bool showsolution) { g_lab->_anim->_noPalChange = false; blackScreen(); - if (showsolution) { - start = 0; - buffer = g_lab->_music->newOpen("P:TileSolution"); - } else { - start = 1; - buffer = g_lab->_music->newOpen("P:Tile"); - } - - if (!buffer) - return; + Common::File *tileFile = tileFile = g_lab->_resource->openDataFile(showsolution ? "P:TileSolution" : "P:Tile"); for (uint16 curBit = start; curBit < 16; curBit++) - Tiles[curBit] = new Image(buffer); + Tiles[curBit] = new Image(tileFile); + + delete tileFile; allocFile((void **)&g_lab->_tempScrollData, Tiles[1]->_width * Tiles[1]->_height * 2L, "tempdata"); @@ -506,7 +498,6 @@ void doWestPaper() { /* Loads in the data for the journal. */ /*****************************************************************************/ static bool loadJournalData() { - byte **buffer; char filename[20]; Gadget *TopGadget = &BackG; bool bridge, dirty, news, clean; @@ -543,17 +534,16 @@ static bool loadJournalData() { journaltext = g_lab->_resource->getText(filename); journaltexttitle = g_lab->_resource->getText("Lab:Rooms/jt"); - buffer = g_lab->_music->newOpen("P:JImage"); + Common::File *journalFile = g_lab->_resource->openDataFile("P:JImage"); - if (!buffer) - return false; + BackG._image = new Image(journalFile); + BackG._altImage = new Image(journalFile); + ForwardG._image = new Image(journalFile); + ForwardG._altImage = new Image(journalFile); + CancelG._image = new Image(journalFile); + CancelG._altImage = new Image(journalFile); - BackG._image = new Image(buffer); - BackG._altImage = new Image(buffer); - ForwardG._image = new Image(buffer); - ForwardG._altImage = new Image(buffer); - CancelG._image = new Image(buffer); - CancelG._altImage = new Image(buffer); + delete journalFile; BackG.KeyEquiv = VKEY_LTARROW; ForwardG.KeyEquiv = VKEY_RTARROW; @@ -807,19 +797,9 @@ bool saveRestoreGame() { /* Makes sure that the buttons are in memory. */ /*****************************************************************************/ static void getMonImages() { - byte **buffer; - uint32 bufferSize; - - resetBuffer(); - - buffer = g_lab->_music->newOpen("P:MonImage", bufferSize); - - if (!buffer) - return; - - MonButton = new Image(buffer); - - stealBufMem(bufferSize); /* Trick: protects the memory where the buttons are so they won't be over-written */ + Common::File *buttonFile = g_lab->_resource->openDataFile("P:MonImage"); + MonButton = new Image(buttonFile); + delete buttonFile; } -- cgit v1.2.3 From c320e6d0aea4a70f8fe1df691432f5900a4f6625 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Thu, 3 Dec 2015 19:49:55 +0100 Subject: LAB: Move inventory to LabEngine class --- engines/lab/special.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index f8b0c2091e..9f36303a1d 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -83,7 +83,6 @@ uint16 CurTile[4][4] = { extern uint16 *FadePalette; extern BitMap *DispBitMap, *DrawBitMap; -extern InventoryData *Inventory; extern uint16 Direction; #define COMBINATIONUNLOCKED 130 @@ -753,7 +752,7 @@ void LabEngine::doJournal() { freeAllStolenMem(); } -bool saveRestoreGame() { +bool LabEngine::saveRestoreGame() { bool isOK = false; //g_lab->showMainMenu(); @@ -775,14 +774,14 @@ bool saveRestoreGame() { desc = dialog->createDefaultSaveDescription(slot); } - isOK = saveGame(Direction, Inventory[QUARTERNUM].Many, slot, desc); + isOK = saveGame(Direction, _inventory[QUARTERNUM].Many, slot, desc); } } else { // Restore GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Restore game:"), _("Restore"), false); int slot = dialog->runModalWithCurrentTarget(); if (slot >= 0) { - isOK = loadGame(&Direction, &(Inventory[QUARTERNUM].Many), slot); + isOK = loadGame(&Direction, &(_inventory[QUARTERNUM].Many), slot); if (isOK) g_lab->_music->resetMusic(); } -- cgit v1.2.3 From 733fbe4c62911adc478400ba5d0dcf220e1b45ee Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 4 Dec 2015 13:32:08 +0100 Subject: LAB: Start working on a separate DisplayMan class --- engines/lab/special.cpp | 169 ++++++++++++++++++++++++------------------------ 1 file changed, 84 insertions(+), 85 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 9f36303a1d..3be558b8af 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -109,9 +109,9 @@ static byte *loadBackPict(const char *fileName, bool tomem) { g_lab->_anim->_noPalChange = true; if (tomem) - res = readPictToMem(fileName, g_lab->_screenWidth, g_lab->_screenHeight); + res = g_lab->_graphics->readPictToMem(fileName, g_lab->_screenWidth, g_lab->_screenHeight); else - readPict(fileName, true); + g_lab->_graphics->readPict(fileName, true); for (uint16 i = 0; i < 16; i++) { hipal[i] = ((g_lab->_anim->_diffPalette[i * 3] >> 2) << 8) + @@ -129,7 +129,7 @@ static byte *loadBackPict(const char *fileName, bool tomem) { /*****************************************************************************/ static void doCombination() { for (uint16 i = 0; i <= 5; i++) - Images[combination[i]]->drawImage(VGAScaleX(combx[i]), VGAScaleY(65)); + Images[combination[i]]->drawImage(g_lab->_graphics->VGAScaleX(combx[i]), g_lab->_graphics->VGAScaleY(65)); } /*****************************************************************************/ @@ -139,10 +139,10 @@ void showCombination(const char *filename) { resetBuffer(); g_lab->_anim->_doBlack = true; g_lab->_anim->_noPalChange = true; - readPict(filename, true); + g_lab->_graphics->readPict(filename, true); g_lab->_anim->_noPalChange = false; - blackScreen(); + g_lab->_graphics->blackScreen(); Common::File *numFile = g_lab->_resource->openDataFile("P:Numbers"); @@ -188,9 +188,9 @@ static void changeCombination(uint16 number) { display._imageData = g_lab->getCurrentDrawingBuffer(); - g_lab->scrollDisplayY(2, VGAScaleX(combx[number]), VGAScaleY(65), VGAScaleX(combx[number]) + (Images[combnum])->_width - 1, VGAScaleY(65) + (Images[combnum])->_height); + g_lab->scrollDisplayY(2, g_lab->_graphics->VGAScaleX(combx[number]), g_lab->_graphics->VGAScaleY(65), g_lab->_graphics->VGAScaleX(combx[number]) + (Images[combnum])->_width - 1, g_lab->_graphics->VGAScaleY(65) + (Images[combnum])->_height); - Images[combnum]->bltBitMap(0, (Images[combnum])->_height - (2 * i), &(display), VGAScaleX(combx[number]), VGAScaleY(65), (Images[combnum])->_width, 2); + Images[combnum]->bltBitMap(0, (Images[combnum])->_height - (2 * i), &(display), g_lab->_graphics->VGAScaleX(combx[number]), g_lab->_graphics->VGAScaleY(65), (Images[combnum])->_width, 2); } for (uint16 i = 0; i < 6; i++) @@ -240,20 +240,20 @@ static void doTile(bool showsolution) { int16 rows, cols; if (showsolution) { - rowm = VGAScaleY(23); - colm = VGAScaleX(27); + rowm = g_lab->_graphics->VGAScaleY(23); + colm = g_lab->_graphics->VGAScaleX(27); - rows = VGAScaleY(31); - cols = VGAScaleX(105); + rows = g_lab->_graphics->VGAScaleY(31); + cols = g_lab->_graphics->VGAScaleX(105); } else { - g_lab->setAPen(0); - g_lab->rectFill(VGAScaleX(97), VGAScaleY(22), VGAScaleX(220), VGAScaleY(126)); + g_lab->_graphics->setAPen(0); + g_lab->_graphics->rectFill(g_lab->_graphics->VGAScaleX(97), g_lab->_graphics->VGAScaleY(22), g_lab->_graphics->VGAScaleX(220), g_lab->_graphics->VGAScaleY(126)); - rowm = VGAScaleY(25); - colm = VGAScaleX(30); + rowm = g_lab->_graphics->VGAScaleY(25); + colm = g_lab->_graphics->VGAScaleX(30); - rows = VGAScaleY(25); - cols = VGAScaleX(100); + rows = g_lab->_graphics->VGAScaleY(25); + cols = g_lab->_graphics->VGAScaleX(100); } while (row < 4) { @@ -283,9 +283,9 @@ void showTile(const char *filename, bool showsolution) { resetBuffer(); g_lab->_anim->_doBlack = true; g_lab->_anim->_noPalChange = true; - readPict(filename, true); + g_lab->_graphics->readPict(filename, true); g_lab->_anim->_noPalChange = false; - blackScreen(); + g_lab->_graphics->blackScreen(); Common::File *tileFile = tileFile = g_lab->_resource->openDataFile(showsolution ? "P:TileSolution" : "P:Tile"); @@ -317,33 +317,33 @@ static void doTileScroll(uint16 col, uint16 row, uint16 scrolltype) { uint16 last = 0, x1, y1; if (scrolltype == LEFTSCROLL) { - dX = VGAScaleX(5); - sx = VGAScaleX(5); + dX = g_lab->_graphics->VGAScaleX(5); + sx = g_lab->_graphics->VGAScaleX(5); last = 6; } else if (scrolltype == RIGHTSCROLL) { - dX = VGAScaleX(-5); - dx = VGAScaleX(-5); - sx = VGAScaleX(5); + dX = g_lab->_graphics->VGAScaleX(-5); + dx = g_lab->_graphics->VGAScaleX(-5); + sx = g_lab->_graphics->VGAScaleX(5); last = 6; } else if (scrolltype == UPSCROLL) { - dY = VGAScaleY(5); - sy = VGAScaleY(5); + dY = g_lab->_graphics->VGAScaleY(5); + sy = g_lab->_graphics->VGAScaleY(5); last = 5; } else if (scrolltype == DOWNSCROLL) { - dY = VGAScaleY(-5); - dy = VGAScaleY(-5); - sy = VGAScaleY(5); + dY = g_lab->_graphics->VGAScaleY(-5); + dy = g_lab->_graphics->VGAScaleY(-5); + sy = g_lab->_graphics->VGAScaleY(5); last = 5; } - sx += SVGACord(2); + sx += g_lab->_graphics->SVGACord(2); - x1 = VGAScaleX(100) + (col * VGAScaleX(30)) + dx; - y1 = VGAScaleY(25) + (row * VGAScaleY(25)) + dy; + x1 = g_lab->_graphics->VGAScaleX(100) + (col * g_lab->_graphics->VGAScaleX(30)) + dx; + y1 = g_lab->_graphics->VGAScaleY(25) + (row * g_lab->_graphics->VGAScaleY(25)) + dy; for (uint16 i = 0; i < last; i++) { g_lab->waitTOF(); - scrollRaster(dX, dY, x1, y1, x1 + VGAScaleX(28) + sx, y1 + VGAScaleY(23) + sy); + scrollRaster(dX, dY, x1, y1, x1 + g_lab->_graphics->VGAScaleX(28) + sx, y1 + g_lab->_graphics->VGAScaleY(23) + sy); x1 += dX; y1 += dY; } @@ -413,7 +413,7 @@ static void changeTile(uint16 col, uint16 row) { if (check) { g_lab->_conditions->inclElement(BRICKOPEN); /* unlocked combination */ g_lab->_anim->_doBlack = true; - check = readPict("p:Up/BDOpen", true); + check = g_lab->_graphics->readPict("p:Up/BDOpen", true); } } } @@ -444,7 +444,7 @@ void doNotes() { TextFont *noteFont = g_lab->_resource->getFont("P:Note.fon"); char *ntext = g_lab->_resource->getText("Lab:Rooms/Notes"); - flowText(noteFont, -2 + SVGACord(1), 0, 0, false, false, true, true, VGAScaleX(25) + SVGACord(15), VGAScaleY(50), VGAScaleX(295) - SVGACord(15), VGAScaleY(148), ntext); + g_lab->_graphics->flowText(noteFont, -2 + g_lab->_graphics->SVGACord(1), 0, 0, false, false, true, true, g_lab->_graphics->VGAScaleX(25) + g_lab->_graphics->SVGACord(15), g_lab->_graphics->VGAScaleY(50), g_lab->_graphics->VGAScaleX(295) - g_lab->_graphics->SVGACord(15), g_lab->_graphics->VGAScaleY(148), ntext); g_lab->setPalette(g_lab->_anim->_diffPalette, 256); closeFont(noteFont); @@ -464,28 +464,28 @@ void doWestPaper() { paperFont = g_lab->_resource->getFont("P:News22.fon"); ntext = g_lab->_resource->getText("Lab:Rooms/Date"); - flowText(paperFont, 0, 0, 0, false, true, false, true, VGAScaleX(57), VGAScaleY(77) + SVGACord(2), VGAScaleX(262), VGAScaleY(91), ntext); + g_lab->_graphics->flowText(paperFont, 0, 0, 0, false, true, false, true, g_lab->_graphics->VGAScaleX(57), g_lab->_graphics->VGAScaleY(77) + g_lab->_graphics->SVGACord(2), g_lab->_graphics->VGAScaleX(262), g_lab->_graphics->VGAScaleY(91), ntext); closeFont(paperFont); delete[] ntext; paperFont = g_lab->_resource->getFont("P:News32.fon"); ntext = g_lab->_resource->getText("Lab:Rooms/Headline"); FileLen = strlen(ntext) - 1; - CharsPrinted = flowText(paperFont, -8, 0, 0, false, true, false, true, VGAScaleX(57), VGAScaleY(86) - SVGACord(2), VGAScaleX(262), VGAScaleY(118), ntext); + CharsPrinted = g_lab->_graphics->flowText(paperFont, -8, 0, 0, false, true, false, true, g_lab->_graphics->VGAScaleX(57), g_lab->_graphics->VGAScaleY(86) - g_lab->_graphics->SVGACord(2), g_lab->_graphics->VGAScaleX(262), g_lab->_graphics->VGAScaleY(118), ntext); if (CharsPrinted < FileLen) { - y = 130 - SVGACord(5); - flowText(paperFont, -8 - SVGACord(1), 0, 0, false, true, false, true, VGAScaleX(57), VGAScaleY(86) - SVGACord(2), VGAScaleX(262), VGAScaleY(132), ntext); + y = 130 - g_lab->_graphics->SVGACord(5); + g_lab->_graphics->flowText(paperFont, -8 - g_lab->_graphics->SVGACord(1), 0, 0, false, true, false, true, g_lab->_graphics->VGAScaleX(57), g_lab->_graphics->VGAScaleY(86) - g_lab->_graphics->SVGACord(2), g_lab->_graphics->VGAScaleX(262), g_lab->_graphics->VGAScaleY(132), ntext); } else - y = 115 - SVGACord(5); + y = 115 - g_lab->_graphics->SVGACord(5); closeFont(paperFont); delete[] ntext; paperFont = g_lab->_resource->getFont("P:Note.fon"); ntext = g_lab->_resource->getText("Lab:Rooms/Col1"); - CharsPrinted = flowText(paperFont, -4, 0, 0, false, false, false, true, VGAScaleX(45), VGAScaleY(y), VGAScaleX(158), VGAScaleY(148), ntext); + CharsPrinted = g_lab->_graphics->flowText(paperFont, -4, 0, 0, false, false, false, true, g_lab->_graphics->VGAScaleX(45), g_lab->_graphics->VGAScaleY(y), g_lab->_graphics->VGAScaleX(158), g_lab->_graphics->VGAScaleY(148), ntext); delete[] ntext; ntext = g_lab->_resource->getText("Lab:Rooms/Col2"); - CharsPrinted = flowText(paperFont, -4, 0, 0, false, false, false, true, VGAScaleX(162), VGAScaleY(y), VGAScaleX(275), VGAScaleY(148), ntext); + CharsPrinted = g_lab->_graphics->flowText(paperFont, -4, 0, 0, false, false, false, true, g_lab->_graphics->VGAScaleX(162), g_lab->_graphics->VGAScaleY(y), g_lab->_graphics->VGAScaleX(275), g_lab->_graphics->VGAScaleY(148), ntext); delete[] ntext; closeFont(paperFont); @@ -550,12 +550,12 @@ static bool loadJournalData() { uint16 counter = 0; while (TopGadget) { - TopGadget->x = VGAScaleX(JGadX[counter]); + TopGadget->x = g_lab->_graphics->VGAScaleX(JGadX[counter]); if (counter == 1) - TopGadget->y = VGAScaleY(JGadY[counter]) + SVGACord(1); + TopGadget->y = g_lab->_graphics->VGAScaleY(JGadY[counter]) + g_lab->_graphics->SVGACord(1); else - TopGadget->y = VGAScaleY(JGadY[counter]) - SVGACord(1); + TopGadget->y = g_lab->_graphics->VGAScaleY(JGadY[counter]) - g_lab->_graphics->SVGACord(1); TopGadget->GadgetID = counter; TopGadget = TopGadget->NextGadget; @@ -576,7 +576,7 @@ static void drawJournalText() { while (DrawingToPage < JPage) { g_lab->_music->updateMusic(); CurText = (char *)(journaltext + CharsDrawn); - CharsDrawn += flowText(journalFont, -2, 2, 0, false, false, false, false, VGAScaleX(52), VGAScaleY(32), VGAScaleX(152), VGAScaleY(148), CurText); + CharsDrawn += g_lab->_graphics->flowText(journalFont, -2, 2, 0, false, false, false, false, g_lab->_graphics->VGAScaleX(52), g_lab->_graphics->VGAScaleY(32), g_lab->_graphics->VGAScaleX(152), g_lab->_graphics->VGAScaleY(148), CurText); lastpage = (*CurText == 0); @@ -588,16 +588,16 @@ static void drawJournalText() { if (JPage <= 1) { CurText = journaltexttitle; - flowTextToMem(&JBackImage, journalFont, -2, 2, 0, false, true, true, true, VGAScaleX(52), VGAScaleY(32), VGAScaleX(152), VGAScaleY(148), CurText); + g_lab->_graphics->flowTextToMem(&JBackImage, journalFont, -2, 2, 0, false, true, true, true, g_lab->_graphics->VGAScaleX(52), g_lab->_graphics->VGAScaleY(32), g_lab->_graphics->VGAScaleX(152), g_lab->_graphics->VGAScaleY(148), CurText); } else { CurText = (char *)(journaltext + CharsDrawn); - CharsDrawn += flowTextToMem(&JBackImage, journalFont, -2, 2, 0, false, false, false, true, VGAScaleX(52), VGAScaleY(32), VGAScaleX(152), VGAScaleY(148), CurText); + CharsDrawn += g_lab->_graphics->flowTextToMem(&JBackImage, journalFont, -2, 2, 0, false, false, false, true, g_lab->_graphics->VGAScaleX(52), g_lab->_graphics->VGAScaleY(32), g_lab->_graphics->VGAScaleX(152), g_lab->_graphics->VGAScaleY(148), CurText); } g_lab->_music->updateMusic(); CurText = (char *)(journaltext + CharsDrawn); lastpage = (*CurText == 0); - flowTextToMem(&JBackImage, journalFont, -2, 2, 0, false, false, false, true, VGAScaleX(171), VGAScaleY(32), VGAScaleX(271), VGAScaleY(148), CurText); + g_lab->_graphics->flowTextToMem(&JBackImage, journalFont, -2, 2, 0, false, false, false, true, g_lab->_graphics->VGAScaleX(171), g_lab->_graphics->VGAScaleY(32), g_lab->_graphics->VGAScaleX(271), g_lab->_graphics->VGAScaleY(148), CurText); CurText = (char *)(journaltext + CharsDrawn); lastpage = lastpage || (*CurText == 0); @@ -660,7 +660,7 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) { fade(true, 0); g_lab->_anim->_noPalChange = true; - JBackImage._imageData = readPictToMem("P:Journal.pic", _screenWidth, _screenHeight); + JBackImage._imageData = _graphics->readPictToMem("P:Journal.pic", _screenWidth, _screenHeight); GotBackImage = true; eatMessages(); @@ -716,7 +716,7 @@ void LabEngine::processJournal() { /*****************************************************************************/ void LabEngine::doJournal() { resetBuffer(); - blackAllScreen(); + _graphics->blackAllScreen(); lastpage = false; GotBackImage = false; @@ -745,9 +745,9 @@ void LabEngine::doJournal() { ScreenImage._imageData = getCurrentDrawingBuffer(); - setAPen(0); - rectFill(0, 0, _screenWidth - 1, _screenHeight - 1); - blackScreen(); + _graphics->setAPen(0); + _graphics->rectFill(0, 0, _screenWidth - 1, _screenHeight - 1); + _graphics->blackScreen(); freeAllStolenMem(); } @@ -783,11 +783,11 @@ bool LabEngine::saveRestoreGame() { if (slot >= 0) { isOK = loadGame(&Direction, &(_inventory[QUARTERNUM].Many), slot); if (isOK) - g_lab->_music->resetMusic(); + _music->resetMusic(); } } - g_lab->screenUpdate(); + _graphics->screenUpdate(); return isOK; } @@ -820,31 +820,31 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16 text += 2; fheight = textHeight(monitorFont); - x1 = MonButton->_width + VGAScaleX(3); - MonGadHeight = MonButton->_height + VGAScaleY(3); + x1 = MonButton->_width + _graphics->VGAScaleX(3); + MonGadHeight = MonButton->_height + _graphics->VGAScaleY(3); if (MonGadHeight > fheight) yspacing = MonGadHeight - fheight; else MonGadHeight = fheight; - setAPen(0); - rectFill(0, 0, _screenWidth - 1, y2); + _graphics->setAPen(0); + _graphics->rectFill(0, 0, _screenWidth - 1, y2); for (uint16 i = 0; i < numlines; i++) MonButton->drawImage(0, i * MonGadHeight); } else if (isinteractive) { - setAPen(0); - rectFill(0, 0, _screenWidth - 1, y2); + _graphics->setAPen(0); + _graphics->rectFill(0, 0, _screenWidth - 1, y2); } else { - setAPen(0); - rectFill(x1, y1, x2, y2); + _graphics->setAPen(0); + _graphics->rectFill(x1, y1, x2, y2); } while (DrawingToPage < monitorPage) { _music->updateMusic(); CurText = (char *)(text + CharsDrawn); - CharsDrawn += flowText(monitorFont, yspacing, 0, 0, false, false, false, false, x1, y1, x2, y2, CurText); + CharsDrawn += _graphics->flowText(monitorFont, yspacing, 0, 0, false, false, false, false, x1, y1, x2, y2, CurText); lastpage = (*CurText == 0); if (lastpage) @@ -855,7 +855,7 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16 CurText = (char *)(text + CharsDrawn); lastpage = (*CurText == 0); - CharsDrawn = flowText(monitorFont, yspacing, 2, 0, false, false, false, true, x1, y1, x2, y2, CurText); + CharsDrawn = _graphics->flowText(monitorFont, yspacing, 2, 0, false, false, false, true, x1, y1, x2, y2, CurText); CurText += CharsDrawn; lastpage = lastpage || (*CurText == 0); @@ -914,20 +914,20 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isintera return; else if ((Class == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & Qualifier)) { - if ((MouseY >= VGAScaleY(171)) && (MouseY <= VGAScaleY(200))) { - if ((MouseX >= VGAScaleX(259)) && (MouseX <= VGAScaleX(289))) { + if ((MouseY >= g_lab->_graphics->VGAScaleY(171)) && (MouseY <= g_lab->_graphics->VGAScaleY(200))) { + if ((MouseX >= g_lab->_graphics->VGAScaleX(259)) && (MouseX <= g_lab->_graphics->VGAScaleX(289))) { if (!lastpage) { monitorPage += 1; drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive); } - } else if ((MouseX >= VGAScaleX(0)) && (MouseX <= VGAScaleX(31))) { + } else if ((MouseX >= g_lab->_graphics->VGAScaleX(0)) && (MouseX <= g_lab->_graphics->VGAScaleX(31))) { return; - } else if ((MouseX >= VGAScaleX(290)) && (MouseX <= VGAScaleX(320))) { + } else if ((MouseX >= g_lab->_graphics->VGAScaleX(290)) && (MouseX <= g_lab->_graphics->VGAScaleX(320))) { if (monitorPage >= 1) { monitorPage -= 1; drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive); } - } else if ((MouseX >= VGAScaleX(31)) && (MouseX <= VGAScaleX(59))) { + } else if ((MouseX >= g_lab->_graphics->VGAScaleX(31)) && (MouseX <= g_lab->_graphics->VGAScaleX(59))) { if (isinteractive) { monitorPage = 0; @@ -962,20 +962,19 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isintera void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2) { char *ntext; - x1 = VGAScaleX(x1); - x2 = VGAScaleX(x2); - y1 = VGAScaleY(y1); - y2 = VGAScaleY(y2); + x1 = _graphics->VGAScaleX(x1); + x2 = _graphics->VGAScaleX(x2); + y1 = _graphics->VGAScaleY(y1); + y2 = _graphics->VGAScaleY(y2); TextFileName = textfile; - blackAllScreen(); - - readPict("P:Mon/Monitor.1", true); - readPict("P:Mon/NWD1", true); - readPict("P:Mon/NWD2", true); - readPict("P:Mon/NWD3", true); - blackAllScreen(); + _graphics->blackAllScreen(); + _graphics->readPict("P:Mon/Monitor.1", true); + _graphics->readPict("P:Mon/NWD1", true); + _graphics->readPict("P:Mon/NWD2", true); + _graphics->readPict("P:Mon/NWD3", true); + _graphics->blackAllScreen(); resetBuffer(); monitorPage = 0; @@ -997,9 +996,9 @@ void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive, closeFont(monitorFont); freeAllStolenMem(); - setAPen(0); - rectFill(0, 0, _screenWidth - 1, _screenHeight - 1); - blackAllScreen(); + _graphics->setAPen(0); + _graphics->rectFill(0, 0, _screenWidth - 1, _screenHeight - 1); + _graphics->blackAllScreen(); } } // End of namespace Lab -- cgit v1.2.3 From f7321fa278efd93b0ed97fdaa0e902cd4105bb57 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 4 Dec 2015 16:52:13 +0100 Subject: LAB: Make more functions member of LabEngine class --- engines/lab/special.cpp | 338 ------------------------------------------------ 1 file changed, 338 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 3be558b8af..3f26fbcbae 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -48,11 +48,6 @@ namespace Lab { static uint16 MonGadHeight = 1; static uint16 hipal[20]; -// Combination lock rules -static Image *Images[10]; -byte combination[6] = { 0, 0, 0, 0, 0, 0 }, solution[] = { 0, 4, 0, 8, 7, 2 }; -static uint16 combx[] = { 45, 83, 129, 166, 211, 248 }; - static TextFont *journalFont; static char *journaltext, *journaltexttitle; static uint16 JPage = 0; @@ -67,33 +62,13 @@ static const char *TextFileName; Image *MonButton, *AltMonButton, *MonQuit, *AltMonQuit, *MonBack, *AltMonBack, *MonDown, *AltMonDown, *MonUp, *AltMonUp; -// Tile puzzle rules -Image *Tiles[16]; -uint16 CurTile[4][4] = { - { 1, 5, 9, 13 }, - { 2, 6, 10, 14 }, - { 3, 7, 11, 15 }, - { 4, 8, 12, 0 } -}, TileSolution[4][4] = { - { 7, 1, 8, 3 }, - { 2, 11, 15, 4 }, - { 9, 5, 14, 6 }, - { 10, 13, 12, 0 } -}; - extern uint16 *FadePalette; extern BitMap *DispBitMap, *DrawBitMap; extern uint16 Direction; -#define COMBINATIONUNLOCKED 130 -#define BRICKOPEN 115 #define INCL(BITSET,BIT) ((BITSET) |= (BIT)) #define SETBIT(BITSET,BITNUM) INCL(BITSET, (1 << (BITNUM))) #define INBIT(BITSET,BITNUM) ( ((1 << (BITNUM)) & (BITSET)) > 0 ) -#define LEFTSCROLL 1 -#define RIGHTSCROLL 2 -#define UPSCROLL 3 -#define DOWNSCROLL 4 #define BRIDGE0 148 #define BRIDGE1 104 #define DIRTY 175 @@ -124,319 +99,6 @@ static byte *loadBackPict(const char *fileName, bool tomem) { return res; } -/*****************************************************************************/ -/* Draws the images of the combination lock to the display bitmap. */ -/*****************************************************************************/ -static void doCombination() { - for (uint16 i = 0; i <= 5; i++) - Images[combination[i]]->drawImage(g_lab->_graphics->VGAScaleX(combx[i]), g_lab->_graphics->VGAScaleY(65)); -} - -/*****************************************************************************/ -/* Reads in a backdrop picture. */ -/*****************************************************************************/ -void showCombination(const char *filename) { - resetBuffer(); - g_lab->_anim->_doBlack = true; - g_lab->_anim->_noPalChange = true; - g_lab->_graphics->readPict(filename, true); - g_lab->_anim->_noPalChange = false; - - g_lab->_graphics->blackScreen(); - - Common::File *numFile = g_lab->_resource->openDataFile("P:Numbers"); - - for (uint16 CurBit = 0; CurBit < 10; CurBit++) - Images[CurBit] = new Image(numFile); - - delete numFile; - - allocFile((void **)&g_lab->_tempScrollData, Images[0]->_width * Images[0]->_height * 2L, "tempdata"); - - doCombination(); - - g_lab->setPalette(g_lab->_anim->_diffPalette, 256); -} - - - -/*****************************************************************************/ -/* Changes the combination number of one of the slots */ -/*****************************************************************************/ -static void changeCombination(uint16 number) { - Image display; - uint16 combnum; - bool unlocked = true; - - if (combination[number] < 9) - (combination[number])++; - else - combination[number] = 0; - - combnum = combination[number]; - - display._imageData = g_lab->getCurrentDrawingBuffer(); - display._width = g_lab->_screenWidth; - display._height = g_lab->_screenHeight; - - for (uint16 i = 1; i <= (Images[combnum]->_height / 2); i++) { - if (g_lab->_isHiRes) { - if (i & 1) - g_lab->waitTOF(); - } else - g_lab->waitTOF(); - - display._imageData = g_lab->getCurrentDrawingBuffer(); - - g_lab->scrollDisplayY(2, g_lab->_graphics->VGAScaleX(combx[number]), g_lab->_graphics->VGAScaleY(65), g_lab->_graphics->VGAScaleX(combx[number]) + (Images[combnum])->_width - 1, g_lab->_graphics->VGAScaleY(65) + (Images[combnum])->_height); - - Images[combnum]->bltBitMap(0, (Images[combnum])->_height - (2 * i), &(display), g_lab->_graphics->VGAScaleX(combx[number]), g_lab->_graphics->VGAScaleY(65), (Images[combnum])->_width, 2); - } - - for (uint16 i = 0; i < 6; i++) - unlocked = (combination[i] == solution[i]) && unlocked; - - if (unlocked) - g_lab->_conditions->inclElement(COMBINATIONUNLOCKED); - else - g_lab->_conditions->exclElement(COMBINATIONUNLOCKED); -} - - -/*****************************************************************************/ -/* Processes mouse clicks and changes the combination. */ -/*****************************************************************************/ -void mouseCombination(Common::Point pos) { - uint16 number; - - int x = VGAUnScaleX(pos.x); - int y = VGAUnScaleY(pos.y); - - if ((y >= 63) && (y <= 99)) { - if ((x >= 44) && (x < 83)) - number = 0; - else if (x < 127) - number = 1; - else if (x < 165) - number = 2; - else if (x < 210) - number = 3; - else if (x < 245) - number = 4; - else if (x < 286) - number = 5; - else - return; - - changeCombination(number); - } -} - -/*****************************************************************************/ -/* Draws the images of the combination lock to the display bitmap. */ -/*****************************************************************************/ -static void doTile(bool showsolution) { - uint16 row = 0, col = 0, rowm, colm, num; - int16 rows, cols; - - if (showsolution) { - rowm = g_lab->_graphics->VGAScaleY(23); - colm = g_lab->_graphics->VGAScaleX(27); - - rows = g_lab->_graphics->VGAScaleY(31); - cols = g_lab->_graphics->VGAScaleX(105); - } else { - g_lab->_graphics->setAPen(0); - g_lab->_graphics->rectFill(g_lab->_graphics->VGAScaleX(97), g_lab->_graphics->VGAScaleY(22), g_lab->_graphics->VGAScaleX(220), g_lab->_graphics->VGAScaleY(126)); - - rowm = g_lab->_graphics->VGAScaleY(25); - colm = g_lab->_graphics->VGAScaleX(30); - - rows = g_lab->_graphics->VGAScaleY(25); - cols = g_lab->_graphics->VGAScaleX(100); - } - - while (row < 4) { - while (col < 4) { - if (showsolution) - num = TileSolution[col] [row]; - else - num = CurTile[col] [row]; - - if (showsolution || num) - Tiles[num]->drawImage(cols + (col * colm), rows + (row * rowm)); - - col++; - } - - row++; - col = 0; - } -} - -/*****************************************************************************/ -/* Reads in a backdrop picture. */ -/*****************************************************************************/ -void showTile(const char *filename, bool showsolution) { - uint16 start = showsolution ? 0 : 1; - - resetBuffer(); - g_lab->_anim->_doBlack = true; - g_lab->_anim->_noPalChange = true; - g_lab->_graphics->readPict(filename, true); - g_lab->_anim->_noPalChange = false; - g_lab->_graphics->blackScreen(); - - Common::File *tileFile = tileFile = g_lab->_resource->openDataFile(showsolution ? "P:TileSolution" : "P:Tile"); - - for (uint16 curBit = start; curBit < 16; curBit++) - Tiles[curBit] = new Image(tileFile); - - delete tileFile; - - allocFile((void **)&g_lab->_tempScrollData, Tiles[1]->_width * Tiles[1]->_height * 2L, "tempdata"); - - doTile(showsolution); - - g_lab->setPalette(g_lab->_anim->_diffPalette, 256); -} - -static void scrollRaster(int16 dx, int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2) { - if (dx) - g_lab->scrollDisplayX(dx, x1, y1, x2, y2); - - if (dy) - g_lab->scrollDisplayY(dy, x1, y1, x2, y2); -} - -/*****************************************************************************/ -/* Does the scrolling for the tiles on the tile puzzle. */ -/*****************************************************************************/ -static void doTileScroll(uint16 col, uint16 row, uint16 scrolltype) { - int16 dX = 0, dY = 0, dx = 0, dy = 0, sx = 0, sy = 0; - uint16 last = 0, x1, y1; - - if (scrolltype == LEFTSCROLL) { - dX = g_lab->_graphics->VGAScaleX(5); - sx = g_lab->_graphics->VGAScaleX(5); - last = 6; - } else if (scrolltype == RIGHTSCROLL) { - dX = g_lab->_graphics->VGAScaleX(-5); - dx = g_lab->_graphics->VGAScaleX(-5); - sx = g_lab->_graphics->VGAScaleX(5); - last = 6; - } else if (scrolltype == UPSCROLL) { - dY = g_lab->_graphics->VGAScaleY(5); - sy = g_lab->_graphics->VGAScaleY(5); - last = 5; - } else if (scrolltype == DOWNSCROLL) { - dY = g_lab->_graphics->VGAScaleY(-5); - dy = g_lab->_graphics->VGAScaleY(-5); - sy = g_lab->_graphics->VGAScaleY(5); - last = 5; - } - - sx += g_lab->_graphics->SVGACord(2); - - x1 = g_lab->_graphics->VGAScaleX(100) + (col * g_lab->_graphics->VGAScaleX(30)) + dx; - y1 = g_lab->_graphics->VGAScaleY(25) + (row * g_lab->_graphics->VGAScaleY(25)) + dy; - - for (uint16 i = 0; i < last; i++) { - g_lab->waitTOF(); - scrollRaster(dX, dY, x1, y1, x1 + g_lab->_graphics->VGAScaleX(28) + sx, y1 + g_lab->_graphics->VGAScaleY(23) + sy); - x1 += dX; - y1 += dY; - } -} - -/*****************************************************************************/ -/* Changes the combination number of one of the slots */ -/*****************************************************************************/ -static void changeTile(uint16 col, uint16 row) { - int16 scrolltype = -1; - - if (row > 0) { - if (CurTile[col] [row - 1] == 0) { - CurTile[col] [row - 1] = CurTile[col] [row]; - CurTile[col] [row] = 0; - scrolltype = DOWNSCROLL; - } - } - - if (col > 0) { - if (CurTile[col - 1] [row] == 0) { - CurTile[col - 1] [row] = CurTile[col] [row]; - CurTile[col] [row] = 0; - scrolltype = RIGHTSCROLL; - } - } - - if (row < 3) { - if (CurTile[col] [row + 1] == 0) { - CurTile[col] [row + 1] = CurTile[col] [row]; - CurTile[col] [row] = 0; - scrolltype = UPSCROLL; - } - } - - if (col < 3) { - if (CurTile[col + 1] [row] == 0) { - CurTile[col + 1] [row] = CurTile[col] [row]; - CurTile[col] [row] = 0; - scrolltype = LEFTSCROLL; - } - } - - if (scrolltype != -1) { - doTileScroll(col, row, scrolltype); - - if (g_lab->getFeatures() & GF_WINDOWS_TRIAL) { - GUI::MessageDialog trialMessage("This puzzle is not available in the trial version of the game"); - trialMessage.runModal(); - return; - } - - bool check = true; - row = 0; - col = 0; - - while (row < 4) { - while (col < 4) { - check = check && (CurTile[row] [col] == TileSolution[row] [col]); - col++; - } - - row++; - col = 0; - } - - if (check) { - g_lab->_conditions->inclElement(BRICKOPEN); /* unlocked combination */ - g_lab->_anim->_doBlack = true; - check = g_lab->_graphics->readPict("p:Up/BDOpen", true); - } - } -} - - -/*****************************************************************************/ -/* Processes mouse clicks and changes the combination. */ -/*****************************************************************************/ -void mouseTile(Common::Point pos) { - int x = VGAUnScaleX(pos.x); - int y = VGAUnScaleY(pos.y); - - if ((x < 101) || (y < 26)) - return; - - x = (x - 101) / 30; - y = (y - 26) / 25; - - if ((x < 4) && (y < 4)) - changeTile(x, y); -} - - /*****************************************************************************/ /* Does the things to properly set up the detective notes. */ /*****************************************************************************/ -- cgit v1.2.3 From a182a6af1a71a3140c7cb40d2df3595ea3ad0a90 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 4 Dec 2015 21:18:41 +0200 Subject: LAB: Rewrite picture handling and get rid of the memory manager --- engines/lab/special.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 3f26fbcbae..855093edec 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -152,7 +152,6 @@ void doWestPaper() { closeFont(paperFont); g_lab->setPalette(g_lab->_anim->_diffPalette, 256); - freeAllStolenMem(); } /*****************************************************************************/ @@ -377,7 +376,6 @@ void LabEngine::processJournal() { /* Does the journal processing. */ /*****************************************************************************/ void LabEngine::doJournal() { - resetBuffer(); _graphics->blackAllScreen(); lastpage = false; @@ -410,8 +408,6 @@ void LabEngine::doJournal() { _graphics->setAPen(0); _graphics->rectFill(0, 0, _screenWidth - 1, _screenHeight - 1); _graphics->blackScreen(); - - freeAllStolenMem(); } bool LabEngine::saveRestoreGame() { @@ -638,7 +634,6 @@ void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive, _graphics->readPict("P:Mon/NWD3", true); _graphics->blackAllScreen(); - resetBuffer(); monitorPage = 0; lastpage = false; FadePalette = hipal; @@ -656,11 +651,11 @@ void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive, _event->mouseHide(); delete[] ntext; closeFont(monitorFont); - freeAllStolenMem(); _graphics->setAPen(0); _graphics->rectFill(0, 0, _screenWidth - 1, _screenHeight - 1); _graphics->blackAllScreen(); + _graphics->freePict(); } } // End of namespace Lab -- cgit v1.2.3 From ea6d4579e284e10778c1703ff6a1638505697cea Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 4 Dec 2015 22:53:31 +0200 Subject: LAB: Merge all of the different image drawing functions --- engines/lab/special.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 855093edec..69a8aaedaf 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -273,14 +273,14 @@ static void turnPage(bool FromLeft) { g_lab->_music->updateMusic(); g_lab->waitTOF(); ScreenImage._imageData = g_lab->getCurrentDrawingBuffer(); - JBackImage.bltBitMap(i, 0, &ScreenImage, i, 0, 8, g_lab->_screenHeight); + JBackImage.blitBitmap(i, 0, &ScreenImage, i, 0, 8, g_lab->_screenHeight, false); } } else { for (int i = (g_lab->_screenWidth - 8); i > 0; i -= 8) { g_lab->_music->updateMusic(); g_lab->waitTOF(); ScreenImage._imageData = g_lab->getCurrentDrawingBuffer(); - JBackImage.bltBitMap(i, 0, &ScreenImage, i, 0, 8, g_lab->_screenHeight); + JBackImage.blitBitmap(i, 0, &ScreenImage, i, 0, 8, g_lab->_screenHeight, false); } } } @@ -302,7 +302,7 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) { ScreenImage._imageData = getCurrentDrawingBuffer(); if (wipenum == 0) - JBackImage.bltBitMap(0, 0, &ScreenImage, 0, 0, _screenWidth, _screenHeight); + JBackImage.blitBitmap(0, 0, &ScreenImage, 0, 0, _screenWidth, _screenHeight, false); else turnPage((bool)(wipenum == 1)); -- cgit v1.2.3 From ab1d9771d28cd70659505b900a07574e70113735 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 5 Dec 2015 18:14:50 +0200 Subject: LAB: Some cleanup of the monitor code --- engines/lab/special.cpp | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 69a8aaedaf..6c96d18213 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -59,8 +59,7 @@ static bool GotBackImage = false; static uint16 monitorPage; static const char *TextFileName; -Image *MonButton, *AltMonButton, *MonQuit, *AltMonQuit, *MonBack, *AltMonBack, -*MonDown, *AltMonDown, *MonUp, *AltMonUp; +Image *MonButton; extern uint16 *FadePalette; extern BitMap *DispBitMap, *DrawBitMap; @@ -450,16 +449,6 @@ bool LabEngine::saveRestoreGame() { return isOK; } -/*****************************************************************************/ -/* Makes sure that the buttons are in memory. */ -/*****************************************************************************/ -static void getMonImages() { - Common::File *buttonFile = g_lab->_resource->openDataFile("P:MonImage"); - MonButton = new Image(buttonFile); - delete buttonFile; -} - - /*****************************************************************************/ /* Draws the text for the monitor. */ /*****************************************************************************/ @@ -639,7 +628,9 @@ void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive, FadePalette = hipal; TextFont *monitorFont = _resource->getFont("P:Map.fon"); - getMonImages(); + Common::File *buttonFile = g_lab->_resource->openDataFile("P:MonImage"); + MonButton = new Image(buttonFile); + delete buttonFile; ntext = _resource->getText(textfile); loadBackPict(background, false); -- cgit v1.2.3 From 525db01913605f899107bc115fcde418023e700f Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 5 Dec 2015 22:20:26 +0200 Subject: LAB: Simplify several calls to flowText() and rectFill() --- engines/lab/special.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 6c96d18213..76f9c1576a 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -143,10 +143,10 @@ void doWestPaper() { paperFont = g_lab->_resource->getFont("P:Note.fon"); ntext = g_lab->_resource->getText("Lab:Rooms/Col1"); - CharsPrinted = g_lab->_graphics->flowText(paperFont, -4, 0, 0, false, false, false, true, g_lab->_graphics->VGAScaleX(45), g_lab->_graphics->VGAScaleY(y), g_lab->_graphics->VGAScaleX(158), g_lab->_graphics->VGAScaleY(148), ntext); + CharsPrinted = g_lab->_graphics->flowTextScaled(paperFont, -4, 0, 0, false, false, false, true, 45, y, 158, 148, ntext); delete[] ntext; ntext = g_lab->_resource->getText("Lab:Rooms/Col2"); - CharsPrinted = g_lab->_graphics->flowText(paperFont, -4, 0, 0, false, false, false, true, g_lab->_graphics->VGAScaleX(162), g_lab->_graphics->VGAScaleY(y), g_lab->_graphics->VGAScaleX(275), g_lab->_graphics->VGAScaleY(148), ntext); + CharsPrinted = g_lab->_graphics->flowTextScaled(paperFont, -4, 0, 0, false, false, false, true, 162, y, 275, 148, ntext); delete[] ntext; closeFont(paperFont); @@ -236,7 +236,7 @@ static void drawJournalText() { while (DrawingToPage < JPage) { g_lab->_music->updateMusic(); CurText = (char *)(journaltext + CharsDrawn); - CharsDrawn += g_lab->_graphics->flowText(journalFont, -2, 2, 0, false, false, false, false, g_lab->_graphics->VGAScaleX(52), g_lab->_graphics->VGAScaleY(32), g_lab->_graphics->VGAScaleX(152), g_lab->_graphics->VGAScaleY(148), CurText); + CharsDrawn += g_lab->_graphics->flowTextScaled(journalFont, -2, 2, 0, false, false, false, false, 52, 32, 152, 148, CurText); lastpage = (*CurText == 0); -- cgit v1.2.3 From ef99d82d13fdbfcaedd8e5fdea243ba3740c5185 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 6 Dec 2015 14:36:49 +0100 Subject: LAB: Move more functions to DisplayMan --- engines/lab/special.cpp | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 76f9c1576a..4143ad6d73 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -77,13 +77,13 @@ extern uint16 Direction; static byte *loadBackPict(const char *fileName, bool tomem) { - byte *res = NULL; + byte *res = nullptr; FadePalette = hipal; g_lab->_anim->_noPalChange = true; 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 g_lab->_graphics->readPict(fileName, true); @@ -106,7 +106,7 @@ void doNotes() { 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->setPalette(g_lab->_anim->_diffPalette, 256); + g_lab->_graphics->setPalette(g_lab->_anim->_diffPalette, 256); closeFont(noteFont); delete[] ntext; @@ -150,7 +150,7 @@ void doWestPaper() { delete[] ntext; 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) { 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->waitTOF(); - ScreenImage._imageData = g_lab->getCurrentDrawingBuffer(); - JBackImage.blitBitmap(i, 0, &ScreenImage, i, 0, 8, g_lab->_screenHeight, false); + ScreenImage._imageData = g_lab->_graphics->getCurrentDrawingBuffer(); + JBackImage.blitBitmap(i, 0, &ScreenImage, i, 0, 8, g_lab->_graphics->_screenHeight, false); } } 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->waitTOF(); - ScreenImage._imageData = g_lab->getCurrentDrawingBuffer(); - JBackImage.blitBitmap(i, 0, &ScreenImage, i, 0, 8, g_lab->_screenHeight, false); + ScreenImage._imageData = g_lab->_graphics->getCurrentDrawingBuffer(); + 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(); - ScreenImage._imageData = getCurrentDrawingBuffer(); + ScreenImage._imageData = _graphics->getCurrentDrawingBuffer(); 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 turnPage((bool)(wipenum == 1)); @@ -320,7 +320,7 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) { fade(true, 0); 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; eatMessages(); @@ -380,15 +380,15 @@ void LabEngine::doJournal() { lastpage = false; GotBackImage = false; - JBackImage._width = _screenWidth; - JBackImage._height = _screenHeight; + JBackImage._width = _graphics->_screenWidth; + JBackImage._height = _graphics->_screenHeight; JBackImage._imageData = NULL; BackG.NextGadget = &CancelG; CancelG.NextGadget = &ForwardG; ScreenImage = JBackImage; - ScreenImage._imageData = getCurrentDrawingBuffer(); + ScreenImage._imageData = _graphics->getCurrentDrawingBuffer(); _music->updateMusic(); loadJournalData(); @@ -402,10 +402,10 @@ void LabEngine::doJournal() { fade(false, 0); _event->mouseHide(); - ScreenImage._imageData = getCurrentDrawingBuffer(); + ScreenImage._imageData = _graphics->getCurrentDrawingBuffer(); _graphics->setAPen(0); - _graphics->rectFill(0, 0, _screenWidth - 1, _screenHeight - 1); + _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1); _graphics->blackScreen(); } @@ -476,13 +476,13 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16 MonGadHeight = fheight; _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++) MonButton->drawImage(0, i * MonGadHeight); } else if (isinteractive) { _graphics->setAPen(0); - _graphics->rectFill(0, 0, _screenWidth - 1, y2); + _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, y2); } else { _graphics->setAPen(0); _graphics->rectFill(x1, y1, x2, y2); @@ -644,7 +644,7 @@ void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive, closeFont(monitorFont); _graphics->setAPen(0); - _graphics->rectFill(0, 0, _screenWidth - 1, _screenHeight - 1); + _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1); _graphics->blackAllScreen(); _graphics->freePict(); } -- cgit v1.2.3 From f48cf343c2761b7918924cc4af923f9503de102c Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 6 Dec 2015 16:03:34 +0100 Subject: LAB: Move doNotes and doWestPaper to LabEngine, remove some useless defines --- engines/lab/special.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 4143ad6d73..7c7dcb1477 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -101,7 +101,7 @@ static byte *loadBackPict(const char *fileName, bool tomem) { /*****************************************************************************/ /* Does the things to properly set up the detective notes. */ /*****************************************************************************/ -void doNotes() { +void LabEngine::doNotes() { TextFont *noteFont = g_lab->_resource->getFont("P:Note.fon"); char *ntext = g_lab->_resource->getText("Lab:Rooms/Notes"); @@ -117,7 +117,7 @@ void doNotes() { /* Does the things to properly set up the old west newspaper. Assumes that */ /* OpenHiRes already called. */ /*****************************************************************************/ -void doWestPaper() { +void LabEngine::doWestPaper() { char *ntext; TextFont *paperFont; int32 FileLen, CharsPrinted; -- cgit v1.2.3 From 438e7a24f5f362c383269cca41ced901a98f284e Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 6 Dec 2015 17:24:25 +0100 Subject: LAB: Get rid of some global variables --- engines/lab/special.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 7c7dcb1477..01b114fede 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -63,7 +63,6 @@ Image *MonButton; extern uint16 *FadePalette; extern BitMap *DispBitMap, *DrawBitMap; -extern uint16 Direction; #define INCL(BITSET,BIT) ((BITSET) |= (BIT)) #define SETBIT(BITSET,BITNUM) INCL(BITSET, (1 << (BITNUM))) @@ -431,14 +430,14 @@ bool LabEngine::saveRestoreGame() { desc = dialog->createDefaultSaveDescription(slot); } - isOK = saveGame(Direction, _inventory[QUARTERNUM].Many, slot, desc); + isOK = saveGame(_direction, _inventory[QUARTERNUM].Many, slot, desc); } } else { // Restore GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Restore game:"), _("Restore"), false); int slot = dialog->runModalWithCurrentTarget(); if (slot >= 0) { - isOK = loadGame(&Direction, &(_inventory[QUARTERNUM].Many), slot); + isOK = loadGame(&_direction, &(_inventory[QUARTERNUM].Many), slot); if (isOK) _music->resetMusic(); } -- cgit v1.2.3 From 785772e86f2f1a15a0f5154e25203b5b94e5087a Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 6 Dec 2015 18:16:26 +0100 Subject: LAB: Move fade functions to DisplayMan, some renaming --- engines/lab/special.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 01b114fede..c4751ce9b6 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -60,8 +60,6 @@ static uint16 monitorPage; static const char *TextFileName; Image *MonButton; - -extern uint16 *FadePalette; extern BitMap *DispBitMap, *DrawBitMap; #define INCL(BITSET,BIT) ((BITSET) |= (BIT)) @@ -78,7 +76,7 @@ extern BitMap *DispBitMap, *DrawBitMap; static byte *loadBackPict(const char *fileName, bool tomem) { byte *res = nullptr; - FadePalette = hipal; + g_lab->_graphics->FadePalette = hipal; g_lab->_anim->_noPalChange = true; if (tomem) @@ -316,7 +314,7 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) { if (needFade) - fade(true, 0); + _graphics->fade(true, 0); g_lab->_anim->_noPalChange = true; JBackImage._imageData = _graphics->readPictToMem("P:Journal.pic", _graphics->_screenWidth, _graphics->_screenHeight); @@ -398,7 +396,7 @@ void LabEngine::doJournal() { _event->mouseShow(); processJournal(); _event->attachGadgetList(NULL); - fade(false, 0); + _graphics->fade(false, 0); _event->mouseHide(); ScreenImage._imageData = _graphics->getCurrentDrawingBuffer(); @@ -536,9 +534,9 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isintera TextFileName = Test; ntext = g_lab->_resource->getText(TextFileName); - fade(false, 0); + _graphics->fade(false, 0); drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive); - fade(true, 0); + _graphics->fade(true, 0); delete[] ntext; } } @@ -624,7 +622,7 @@ void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive, monitorPage = 0; lastpage = false; - FadePalette = hipal; + _graphics->FadePalette = hipal; TextFont *monitorFont = _resource->getFont("P:Map.fon"); Common::File *buttonFile = g_lab->_resource->openDataFile("P:MonImage"); @@ -635,9 +633,9 @@ void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive, loadBackPict(background, false); drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive); _event->mouseShow(); - fade(true, 0); + _graphics->fade(true, 0); processMonitor(ntext, monitorFont, isinteractive, x1, y1, x2, y2); - fade(false, 0); + _graphics->fade(false, 0); _event->mouseHide(); delete[] ntext; closeFont(monitorFont); -- cgit v1.2.3 From 62c4acc6b36639ebcbd2d9161af9b563e0c561f1 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sun, 6 Dec 2015 22:50:41 +0200 Subject: LAB: Change the gadget lists to use Common::List --- engines/lab/special.cpp | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index c4751ce9b6..8afeeeadc6 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -155,7 +155,6 @@ void LabEngine::doWestPaper() { /*****************************************************************************/ static bool loadJournalData() { char filename[20]; - Gadget *TopGadget = &BackG; bool bridge, dirty, news, clean; journalFont = g_lab->_resource->getFont("P:Journal.fon"); // FIXME: memory leak @@ -206,16 +205,21 @@ static bool loadJournalData() { uint16 counter = 0; - while (TopGadget) { - TopGadget->x = g_lab->_graphics->VGAScaleX(JGadX[counter]); + GadgetList journalGadgetList; + journalGadgetList.push_back(&BackG); + journalGadgetList.push_back(&CancelG); + journalGadgetList.push_back(&ForwardG); + + for (GadgetList::iterator gadgetIter = journalGadgetList.begin(); gadgetIter != journalGadgetList.end(); ++gadgetIter) { + Gadget *gadget = *gadgetIter; + gadget->x = g_lab->_graphics->VGAScaleX(JGadX[counter]); if (counter == 1) - TopGadget->y = g_lab->_graphics->VGAScaleY(JGadY[counter]) + g_lab->_graphics->SVGACord(1); + gadget->y = g_lab->_graphics->VGAScaleY(JGadY[counter]) + g_lab->_graphics->SVGACord(1); else - TopGadget->y = g_lab->_graphics->VGAScaleY(JGadY[counter]) - g_lab->_graphics->SVGACord(1); + gadget->y = g_lab->_graphics->VGAScaleY(JGadY[counter]) - g_lab->_graphics->SVGACord(1); - TopGadget->GadgetID = counter; - TopGadget = TopGadget->NextGadget; + gadget->GadgetID = counter; counter++; } @@ -372,6 +376,11 @@ void LabEngine::processJournal() { /* Does the journal processing. */ /*****************************************************************************/ void LabEngine::doJournal() { + GadgetList journalGadgetList; + journalGadgetList.push_back(&BackG); + journalGadgetList.push_back(&CancelG); + journalGadgetList.push_back(&ForwardG); + _graphics->blackAllScreen(); lastpage = false; @@ -381,9 +390,6 @@ void LabEngine::doJournal() { JBackImage._height = _graphics->_screenHeight; JBackImage._imageData = NULL; - BackG.NextGadget = &CancelG; - CancelG.NextGadget = &ForwardG; - ScreenImage = JBackImage; ScreenImage._imageData = _graphics->getCurrentDrawingBuffer(); @@ -392,12 +398,13 @@ void LabEngine::doJournal() { drawJournal(0, true); - _event->attachGadgetList(&BackG); + _event->attachGadgetList(&journalGadgetList); _event->mouseShow(); processJournal(); _event->attachGadgetList(NULL); _graphics->fade(false, 0); _event->mouseHide(); + journalGadgetList.clear(); ScreenImage._imageData = _graphics->getCurrentDrawingBuffer(); -- cgit v1.2.3 From 2611b62d5ec07868d52b8a014932c937eddfceea Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 6 Dec 2015 21:53:57 +0100 Subject: LAB: Rename parse types --- engines/lab/special.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 8afeeeadc6..f4c8439a57 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -435,14 +435,14 @@ bool LabEngine::saveRestoreGame() { desc = dialog->createDefaultSaveDescription(slot); } - isOK = saveGame(_direction, _inventory[QUARTERNUM].Many, slot, desc); + isOK = saveGame(_direction, _inventory[QUARTERNUM]._many, slot, desc); } } else { // Restore GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Restore game:"), _("Restore"), false); int slot = dialog->runModalWithCurrentTarget(); if (slot >= 0) { - isOK = loadGame(&_direction, &(_inventory[QUARTERNUM].Many), slot); + isOK = loadGame(&_direction, &(_inventory[QUARTERNUM]._many), slot); if (isOK) _music->resetMusic(); } @@ -534,7 +534,7 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isintera if (_cptr == startcptr) Test = StartFileName; else - Test = _cptr->GraphicName; + Test = _cptr->_graphicName; if (strcmp(Test, TextFileName)) { monitorPage = 0; -- cgit v1.2.3 From 895d29c1ae411d6a28135451e91e88eba1693f99 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 7 Dec 2015 07:18:16 +0100 Subject: LAB: Some more renaming, remove useless variables --- engines/lab/special.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index f4c8439a57..0bed4181dd 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -200,8 +200,8 @@ static bool loadJournalData() { delete journalFile; - BackG.KeyEquiv = VKEY_LTARROW; - ForwardG.KeyEquiv = VKEY_RTARROW; + BackG._keyEquiv = VKEY_LTARROW; + ForwardG._keyEquiv = VKEY_RTARROW; uint16 counter = 0; @@ -219,7 +219,7 @@ static bool loadJournalData() { else gadget->y = g_lab->_graphics->VGAScaleY(JGadY[counter]) - g_lab->_graphics->SVGACord(1); - gadget->GadgetID = counter; + gadget->_gadgetID = counter; counter++; } @@ -345,9 +345,9 @@ void LabEngine::processJournal() { if (Msg == NULL) { _music->updateMusic(); } else { - Class = Msg->msgClass; - Qualifier = Msg->qualifier; - GadID = Msg->code; + Class = Msg->_msgClass; + Qualifier = Msg->_qualifier; + GadID = Msg->_code; if (((Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) || ((Class == RAWKEY) && (GadID == 27))) @@ -554,11 +554,11 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isintera if (Msg == NULL) { _music->updateMusic(); } else { - Class = Msg->msgClass; - Qualifier = Msg->qualifier; - MouseX = Msg->mouseX; - MouseY = Msg->mouseY; - Code = Msg->code; + Class = Msg->_msgClass; + Qualifier = Msg->_qualifier; + MouseX = Msg->_mouseX; + MouseY = Msg->_mouseY; + Code = Msg->_code; if (((Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) || ((Class == RAWKEY) && (Code == 27))) -- cgit v1.2.3 From 5636181b78bcffa934cb00b14edb68c2d3319139 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 7 Dec 2015 07:48:54 +0100 Subject: LAB: Move text functions to DisplayMan, some renaming --- engines/lab/special.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 0bed4181dd..6642865cda 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -39,7 +39,6 @@ #include "lab/parsefun.h" #include "lab/interface.h" #include "lab/anim.h" -#include "lab/text.h" #include "lab/parsetypes.h" #include "lab/resource.h" @@ -105,7 +104,7 @@ void LabEngine::doNotes() { 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->setPalette(g_lab->_anim->_diffPalette, 256); - closeFont(noteFont); + g_lab->_graphics->closeFont(noteFont); delete[] ntext; } @@ -123,7 +122,7 @@ void LabEngine::doWestPaper() { paperFont = g_lab->_resource->getFont("P:News22.fon"); ntext = g_lab->_resource->getText("Lab:Rooms/Date"); g_lab->_graphics->flowText(paperFont, 0, 0, 0, false, true, false, true, g_lab->_graphics->VGAScaleX(57), g_lab->_graphics->VGAScaleY(77) + g_lab->_graphics->SVGACord(2), g_lab->_graphics->VGAScaleX(262), g_lab->_graphics->VGAScaleY(91), ntext); - closeFont(paperFont); + g_lab->_graphics->closeFont(paperFont); delete[] ntext; paperFont = g_lab->_resource->getFont("P:News32.fon"); @@ -135,7 +134,7 @@ void LabEngine::doWestPaper() { g_lab->_graphics->flowText(paperFont, -8 - g_lab->_graphics->SVGACord(1), 0, 0, false, true, false, true, g_lab->_graphics->VGAScaleX(57), g_lab->_graphics->VGAScaleY(86) - g_lab->_graphics->SVGACord(2), g_lab->_graphics->VGAScaleX(262), g_lab->_graphics->VGAScaleY(132), ntext); } else y = 115 - g_lab->_graphics->SVGACord(5); - closeFont(paperFont); + g_lab->_graphics->closeFont(paperFont); delete[] ntext; paperFont = g_lab->_resource->getFont("P:Note.fon"); @@ -145,7 +144,7 @@ void LabEngine::doWestPaper() { ntext = g_lab->_resource->getText("Lab:Rooms/Col2"); CharsPrinted = g_lab->_graphics->flowTextScaled(paperFont, -4, 0, 0, false, false, false, true, 162, y, 275, 148, ntext); delete[] ntext; - closeFont(paperFont); + g_lab->_graphics->closeFont(paperFont); g_lab->_graphics->setPalette(g_lab->_anim->_diffPalette, 256); } @@ -470,7 +469,7 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16 numlines += (*text - '0'); text += 2; - fheight = textHeight(monitorFont); + fheight = g_lab->_graphics->textHeight(monitorFont); x1 = MonButton->_width + _graphics->VGAScaleX(3); MonGadHeight = MonButton->_height + _graphics->VGAScaleY(3); @@ -645,7 +644,7 @@ void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive, _graphics->fade(false, 0); _event->mouseHide(); delete[] ntext; - closeFont(monitorFont); + g_lab->_graphics->closeFont(monitorFont); _graphics->setAPen(0); _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1); -- cgit v1.2.3 From f3a24ff593024e3a997ed1a9160d32a84eb42d74 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 7 Dec 2015 08:21:27 +0100 Subject: LAB: Some refactoring, remove dead code and a useless return value --- engines/lab/special.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 6642865cda..e49119634a 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -59,7 +59,6 @@ static uint16 monitorPage; static const char *TextFileName; Image *MonButton; -extern BitMap *DispBitMap, *DrawBitMap; #define INCL(BITSET,BIT) ((BITSET) |= (BIT)) #define SETBIT(BITSET,BITNUM) INCL(BITSET, (1 << (BITNUM))) -- cgit v1.2.3 From 5bc48cbbddc47ba3d1893776178c19bd33dbee4c Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 7 Dec 2015 17:46:37 +0100 Subject: LAB: Move utility functions to a separate class --- engines/lab/special.cpp | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index e49119634a..41fcad7a86 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -100,7 +100,7 @@ void LabEngine::doNotes() { TextFont *noteFont = g_lab->_resource->getFont("P:Note.fon"); 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->_utils->svgaCord(1), 0, 0, false, false, true, true, g_lab->_utils->vgaScaleX(25) + g_lab->_utils->svgaCord(15), g_lab->_utils->vgaScaleY(50), g_lab->_utils->vgaScaleX(295) - g_lab->_utils->svgaCord(15), g_lab->_utils->vgaScaleY(148), ntext); g_lab->_graphics->setPalette(g_lab->_anim->_diffPalette, 256); g_lab->_graphics->closeFont(noteFont); @@ -120,19 +120,19 @@ void LabEngine::doWestPaper() { paperFont = g_lab->_resource->getFont("P:News22.fon"); ntext = g_lab->_resource->getText("Lab:Rooms/Date"); - g_lab->_graphics->flowText(paperFont, 0, 0, 0, false, true, false, true, g_lab->_graphics->VGAScaleX(57), g_lab->_graphics->VGAScaleY(77) + g_lab->_graphics->SVGACord(2), g_lab->_graphics->VGAScaleX(262), g_lab->_graphics->VGAScaleY(91), ntext); + g_lab->_graphics->flowText(paperFont, 0, 0, 0, false, true, false, true, g_lab->_utils->vgaScaleX(57), g_lab->_utils->vgaScaleY(77) + g_lab->_utils->svgaCord(2), g_lab->_utils->vgaScaleX(262), g_lab->_utils->vgaScaleY(91), ntext); g_lab->_graphics->closeFont(paperFont); delete[] ntext; paperFont = g_lab->_resource->getFont("P:News32.fon"); ntext = g_lab->_resource->getText("Lab:Rooms/Headline"); FileLen = strlen(ntext) - 1; - CharsPrinted = g_lab->_graphics->flowText(paperFont, -8, 0, 0, false, true, false, true, g_lab->_graphics->VGAScaleX(57), g_lab->_graphics->VGAScaleY(86) - g_lab->_graphics->SVGACord(2), g_lab->_graphics->VGAScaleX(262), g_lab->_graphics->VGAScaleY(118), ntext); + CharsPrinted = g_lab->_graphics->flowText(paperFont, -8, 0, 0, false, true, false, true, g_lab->_utils->vgaScaleX(57), g_lab->_utils->vgaScaleY(86) - g_lab->_utils->svgaCord(2), g_lab->_utils->vgaScaleX(262), g_lab->_utils->vgaScaleY(118), ntext); if (CharsPrinted < FileLen) { - y = 130 - g_lab->_graphics->SVGACord(5); - g_lab->_graphics->flowText(paperFont, -8 - g_lab->_graphics->SVGACord(1), 0, 0, false, true, false, true, g_lab->_graphics->VGAScaleX(57), g_lab->_graphics->VGAScaleY(86) - g_lab->_graphics->SVGACord(2), g_lab->_graphics->VGAScaleX(262), g_lab->_graphics->VGAScaleY(132), ntext); + y = 130 - g_lab->_utils->svgaCord(5); + g_lab->_graphics->flowText(paperFont, -8 - g_lab->_utils->svgaCord(1), 0, 0, false, true, false, true, g_lab->_utils->vgaScaleX(57), g_lab->_utils->vgaScaleY(86) - g_lab->_utils->svgaCord(2), g_lab->_utils->vgaScaleX(262), g_lab->_utils->vgaScaleY(132), ntext); } else - y = 115 - g_lab->_graphics->SVGACord(5); + y = 115 - g_lab->_utils->svgaCord(5); g_lab->_graphics->closeFont(paperFont); delete[] ntext; @@ -210,12 +210,12 @@ static bool loadJournalData() { for (GadgetList::iterator gadgetIter = journalGadgetList.begin(); gadgetIter != journalGadgetList.end(); ++gadgetIter) { Gadget *gadget = *gadgetIter; - gadget->x = g_lab->_graphics->VGAScaleX(JGadX[counter]); + gadget->x = g_lab->_utils->vgaScaleX(JGadX[counter]); if (counter == 1) - gadget->y = g_lab->_graphics->VGAScaleY(JGadY[counter]) + g_lab->_graphics->SVGACord(1); + gadget->y = g_lab->_utils->vgaScaleY(JGadY[counter]) + g_lab->_utils->svgaCord(1); else - gadget->y = g_lab->_graphics->VGAScaleY(JGadY[counter]) - g_lab->_graphics->SVGACord(1); + gadget->y = g_lab->_utils->vgaScaleY(JGadY[counter]) - g_lab->_utils->svgaCord(1); gadget->_gadgetID = counter; counter++; @@ -247,16 +247,16 @@ static void drawJournalText() { if (JPage <= 1) { CurText = journaltexttitle; - g_lab->_graphics->flowTextToMem(&JBackImage, journalFont, -2, 2, 0, false, true, true, true, g_lab->_graphics->VGAScaleX(52), g_lab->_graphics->VGAScaleY(32), g_lab->_graphics->VGAScaleX(152), g_lab->_graphics->VGAScaleY(148), CurText); + g_lab->_graphics->flowTextToMem(&JBackImage, journalFont, -2, 2, 0, false, true, true, true, g_lab->_utils->vgaScaleX(52), g_lab->_utils->vgaScaleY(32), g_lab->_utils->vgaScaleX(152), g_lab->_utils->vgaScaleY(148), CurText); } else { CurText = (char *)(journaltext + CharsDrawn); - CharsDrawn += g_lab->_graphics->flowTextToMem(&JBackImage, journalFont, -2, 2, 0, false, false, false, true, g_lab->_graphics->VGAScaleX(52), g_lab->_graphics->VGAScaleY(32), g_lab->_graphics->VGAScaleX(152), g_lab->_graphics->VGAScaleY(148), CurText); + CharsDrawn += g_lab->_graphics->flowTextToMem(&JBackImage, journalFont, -2, 2, 0, false, false, false, true, g_lab->_utils->vgaScaleX(52), g_lab->_utils->vgaScaleY(32), g_lab->_utils->vgaScaleX(152), g_lab->_utils->vgaScaleY(148), CurText); } g_lab->_music->updateMusic(); CurText = (char *)(journaltext + CharsDrawn); lastpage = (*CurText == 0); - g_lab->_graphics->flowTextToMem(&JBackImage, journalFont, -2, 2, 0, false, false, false, true, g_lab->_graphics->VGAScaleX(171), g_lab->_graphics->VGAScaleY(32), g_lab->_graphics->VGAScaleX(271), g_lab->_graphics->VGAScaleY(148), CurText); + g_lab->_graphics->flowTextToMem(&JBackImage, journalFont, -2, 2, 0, false, false, false, true, g_lab->_utils->vgaScaleX(171), g_lab->_utils->vgaScaleY(32), g_lab->_utils->vgaScaleX(271), g_lab->_utils->vgaScaleY(148), CurText); CurText = (char *)(journaltext + CharsDrawn); lastpage = lastpage || (*CurText == 0); @@ -469,8 +469,8 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16 text += 2; fheight = g_lab->_graphics->textHeight(monitorFont); - x1 = MonButton->_width + _graphics->VGAScaleX(3); - MonGadHeight = MonButton->_height + _graphics->VGAScaleY(3); + x1 = MonButton->_width + _utils->vgaScaleX(3); + MonGadHeight = MonButton->_height + _utils->vgaScaleY(3); if (MonGadHeight > fheight) yspacing = MonGadHeight - fheight; @@ -563,20 +563,20 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isintera return; else if ((Class == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & Qualifier)) { - if ((MouseY >= g_lab->_graphics->VGAScaleY(171)) && (MouseY <= g_lab->_graphics->VGAScaleY(200))) { - if ((MouseX >= g_lab->_graphics->VGAScaleX(259)) && (MouseX <= g_lab->_graphics->VGAScaleX(289))) { + if ((MouseY >= g_lab->_utils->vgaScaleY(171)) && (MouseY <= g_lab->_utils->vgaScaleY(200))) { + if ((MouseX >= g_lab->_utils->vgaScaleX(259)) && (MouseX <= g_lab->_utils->vgaScaleX(289))) { if (!lastpage) { monitorPage += 1; drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive); } - } else if ((MouseX >= g_lab->_graphics->VGAScaleX(0)) && (MouseX <= g_lab->_graphics->VGAScaleX(31))) { + } else if ((MouseX >= g_lab->_utils->vgaScaleX(0)) && (MouseX <= g_lab->_utils->vgaScaleX(31))) { return; - } else if ((MouseX >= g_lab->_graphics->VGAScaleX(290)) && (MouseX <= g_lab->_graphics->VGAScaleX(320))) { + } else if ((MouseX >= g_lab->_utils->vgaScaleX(290)) && (MouseX <= g_lab->_utils->vgaScaleX(320))) { if (monitorPage >= 1) { monitorPage -= 1; drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive); } - } else if ((MouseX >= g_lab->_graphics->VGAScaleX(31)) && (MouseX <= g_lab->_graphics->VGAScaleX(59))) { + } else if ((MouseX >= g_lab->_utils->vgaScaleX(31)) && (MouseX <= g_lab->_utils->vgaScaleX(59))) { if (isinteractive) { monitorPage = 0; @@ -611,10 +611,10 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isintera void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2) { char *ntext; - x1 = _graphics->VGAScaleX(x1); - x2 = _graphics->VGAScaleX(x2); - y1 = _graphics->VGAScaleY(y1); - y2 = _graphics->VGAScaleY(y2); + x1 = _utils->vgaScaleX(x1); + x2 = _utils->vgaScaleX(x2); + y1 = _utils->vgaScaleY(y1); + y2 = _utils->vgaScaleY(y2); TextFileName = textfile; -- cgit v1.2.3 From 00d61638ac02f54de21664303af3a726bc921860 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 8 Dec 2015 01:36:16 +0200 Subject: LAB: Merge parsetypes.h and parsefun.h into processroom.h --- engines/lab/special.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 41fcad7a86..469d8ab9d8 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -36,10 +36,9 @@ #include "lab/lab.h" #include "lab/labfun.h" #include "lab/image.h" -#include "lab/parsefun.h" +#include "lab/processroom.h" #include "lab/interface.h" #include "lab/anim.h" -#include "lab/parsetypes.h" #include "lab/resource.h" namespace Lab { -- cgit v1.2.3 From 3a1ee647610efa61a053d7f2fc0951e6248cb915 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 8 Dec 2015 09:19:00 +0100 Subject: LAB: Review spacing --- engines/lab/special.cpp | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 469d8ab9d8..0d92772a39 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -62,12 +62,12 @@ Image *MonButton; #define INCL(BITSET,BIT) ((BITSET) |= (BIT)) #define SETBIT(BITSET,BITNUM) INCL(BITSET, (1 << (BITNUM))) #define INBIT(BITSET,BITNUM) ( ((1 << (BITNUM)) & (BITSET)) > 0 ) -#define BRIDGE0 148 -#define BRIDGE1 104 -#define DIRTY 175 -#define NONEWS 135 -#define NOCLEAN 152 -#define QUARTERNUM 30 +#define BRIDGE0 148 +#define BRIDGE1 104 +#define DIRTY 175 +#define NONEWS 135 +#define NOCLEAN 152 +#define QUARTERNUM 30 static byte *loadBackPict(const char *fileName, bool tomem) { @@ -83,8 +83,8 @@ static byte *loadBackPict(const char *fileName, bool tomem) { for (uint16 i = 0; i < 16; i++) { hipal[i] = ((g_lab->_anim->_diffPalette[i * 3] >> 2) << 8) + - ((g_lab->_anim->_diffPalette[i * 3 + 1] >> 2) << 4) + - ((g_lab->_anim->_diffPalette[i * 3 + 2] >> 2)); + ((g_lab->_anim->_diffPalette[i * 3 + 1] >> 2) << 4) + + ((g_lab->_anim->_diffPalette[i * 3 + 2] >> 2)); } g_lab->_anim->_noPalChange = false; @@ -282,7 +282,6 @@ static void turnPage(bool FromLeft) { } } - /*****************************************************************************/ /* Draws the journal from page x. */ /*****************************************************************************/ @@ -347,7 +346,7 @@ void LabEngine::processJournal() { GadID = Msg->_code; if (((Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) || - ((Class == RAWKEY) && (GadID == 27))) + ((Class == RAWKEY) && (GadID == 27))) return; else if (Class == GADGETUP) { @@ -385,7 +384,7 @@ void LabEngine::doJournal() { JBackImage._width = _graphics->_screenWidth; JBackImage._height = _graphics->_screenHeight; - JBackImage._imageData = NULL; + JBackImage._imageData = NULL; ScreenImage = JBackImage; ScreenImage._imageData = _graphics->getCurrentDrawingBuffer(); @@ -558,7 +557,7 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isintera Code = Msg->_code; if (((Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) || - ((Class == RAWKEY) && (Code == 27))) + ((Class == RAWKEY) && (Code == 27))) return; else if ((Class == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & Qualifier)) { -- cgit v1.2.3 From ae056a767ba8c983b7d38afd2532ba18fd3cb724 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 8 Dec 2015 09:46:54 +0100 Subject: LAB: Use doxygen format for function comments --- engines/lab/special.cpp | 68 ++++++++++++++++++++++++------------------------- 1 file changed, 34 insertions(+), 34 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 0d92772a39..62d45d12b3 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -92,9 +92,9 @@ static byte *loadBackPict(const char *fileName, bool tomem) { return res; } -/*****************************************************************************/ -/* Does the things to properly set up the detective notes. */ -/*****************************************************************************/ +/** + * Does the things to properly set up the detective notes. + */ void LabEngine::doNotes() { TextFont *noteFont = g_lab->_resource->getFont("P:Note.fon"); char *ntext = g_lab->_resource->getText("Lab:Rooms/Notes"); @@ -107,10 +107,10 @@ void LabEngine::doNotes() { } -/*****************************************************************************/ -/* Does the things to properly set up the old west newspaper. Assumes that */ -/* OpenHiRes already called. */ -/*****************************************************************************/ +/** + * Does the things to properly set up the old west newspaper. Assumes that + * OpenHiRes already called. + */ void LabEngine::doWestPaper() { char *ntext; TextFont *paperFont; @@ -147,9 +147,9 @@ void LabEngine::doWestPaper() { g_lab->_graphics->setPalette(g_lab->_anim->_diffPalette, 256); } -/*****************************************************************************/ -/* Loads in the data for the journal. */ -/*****************************************************************************/ +/** + * Loads in the data for the journal. + */ static bool loadJournalData() { char filename[20]; bool bridge, dirty, news, clean; @@ -223,9 +223,9 @@ static bool loadJournalData() { return true; } -/*****************************************************************************/ -/* Draws the text to the back journal screen to the appropriate Page number */ -/*****************************************************************************/ +/** + * Draws the text to the back journal screen to the appropriate Page number + */ static void drawJournalText() { uint16 DrawingToPage = 1; int32 CharsDrawn = 0L; @@ -261,9 +261,9 @@ static void drawJournalText() { lastpage = lastpage || (*CurText == 0); } -/*****************************************************************************/ -/* Does the turn page wipe. */ -/*****************************************************************************/ +/** + * Does the turn page wipe. + */ static void turnPage(bool FromLeft) { if (FromLeft) { for (int i = 0; i < g_lab->_graphics->_screenWidth; i += 8) { @@ -282,9 +282,9 @@ static void turnPage(bool FromLeft) { } } -/*****************************************************************************/ -/* Draws the journal from page x. */ -/*****************************************************************************/ +/** + * Draws the journal from page x. + */ void LabEngine::drawJournal(uint16 wipenum, bool needFade) { _event->mouseHide(); @@ -326,9 +326,9 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) { g_lab->_anim->_noPalChange = false; } -/*****************************************************************************/ -/* Processes user input. */ -/*****************************************************************************/ +/** + * Processes user input. + */ void LabEngine::processJournal() { IntuiMessage *Msg; uint32 Class; @@ -368,9 +368,9 @@ void LabEngine::processJournal() { } } -/*****************************************************************************/ -/* Does the journal processing. */ -/*****************************************************************************/ +/** + * Does the journal processing. + */ void LabEngine::doJournal() { GadgetList journalGadgetList; journalGadgetList.push_back(&BackG); @@ -449,9 +449,9 @@ bool LabEngine::saveRestoreGame() { return isOK; } -/*****************************************************************************/ -/* Draws the text for the monitor. */ -/*****************************************************************************/ +/** + * Draws the text for the monitor. + */ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16 y1, uint16 x2, uint16 y2, bool isinteractive) { uint16 DrawingToPage = 0, yspacing = 0, numlines, fheight; int32 CharsDrawn = 0L; @@ -509,9 +509,9 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16 _event->mouseShow(); } -/*****************************************************************************/ -/* Processes user input. */ -/*****************************************************************************/ +/** + * Processes user input. + */ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2) { IntuiMessage *Msg; uint32 Class; @@ -603,9 +603,9 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isintera } } -/*****************************************************************************/ -/* Does what's necessary for the monitor. */ -/*****************************************************************************/ +/** + * Does what's necessary for the monitor. + */ void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2) { char *ntext; -- cgit v1.2.3 From 2d0fab7f4c1e4c7f8e88aee6a867a98a8917de86 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 8 Dec 2015 11:27:34 +0100 Subject: LAB: Use // for comments --- engines/lab/special.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 62d45d12b3..6395ee9a7c 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -335,7 +335,8 @@ void LabEngine::processJournal() { uint16 Qualifier, GadID; while (1) { - _music->updateMusic(); /* Make sure we check the music at least after every message */ + // Make sure we check the music at least after every message + _music->updateMusic(); Msg = getMsg(); if (Msg == NULL) { @@ -544,7 +545,8 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isintera } } - _music->updateMusic(); /* Make sure we check the music at least after every message */ + // Make sure we check the music at least after every message + _music->updateMusic(); Msg = getMsg(); if (Msg == NULL) { -- cgit v1.2.3 From 6230fcbeb9e19c1db8bf50dd06fc02ffee925c01 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 8 Dec 2015 16:53:30 +0200 Subject: LAB: Simplify the journal and map gadget handling --- engines/lab/special.cpp | 62 ++++++++++++------------------------------------- 1 file changed, 15 insertions(+), 47 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 6395ee9a7c..5aa8db5181 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -51,8 +51,6 @@ static char *journaltext, *journaltexttitle; static uint16 JPage = 0; static bool lastpage = false; static Image JBackImage, ScreenImage; -static uint16 JGadX[3] = { 80, 144, 194 }, JGadY[3] = { 162, 164, 162 }; -static Gadget ForwardG, CancelG, BackG; static bool GotBackImage = false; static uint16 monitorPage; static const char *TextFileName; @@ -150,7 +148,7 @@ void LabEngine::doWestPaper() { /** * Loads in the data for the journal. */ -static bool loadJournalData() { +void LabEngine::loadJournalData() { char filename[20]; bool bridge, dirty, news, clean; @@ -187,40 +185,11 @@ static bool loadJournalData() { journaltexttitle = g_lab->_resource->getText("Lab:Rooms/jt"); Common::File *journalFile = g_lab->_resource->openDataFile("P:JImage"); - - BackG._image = new Image(journalFile); - BackG._altImage = new Image(journalFile); - ForwardG._image = new Image(journalFile); - ForwardG._altImage = new Image(journalFile); - CancelG._image = new Image(journalFile); - CancelG._altImage = new Image(journalFile); - + Utils *utils = g_lab->_utils; + _journalGadgetList.push_back(createButton( 80, utils->vgaScaleY(162) + utils->svgaCord(1), 0, VKEY_LTARROW, new Image(journalFile), new Image(journalFile))); // back + _journalGadgetList.push_back(createButton(144, utils->vgaScaleY(164) - utils->svgaCord(1), 1, VKEY_RTARROW, new Image(journalFile), new Image(journalFile))); // foward + _journalGadgetList.push_back(createButton(194, utils->vgaScaleY(162) + utils->svgaCord(1), 2, 0, new Image(journalFile), new Image(journalFile))); // cancel delete journalFile; - - BackG._keyEquiv = VKEY_LTARROW; - ForwardG._keyEquiv = VKEY_RTARROW; - - uint16 counter = 0; - - GadgetList journalGadgetList; - journalGadgetList.push_back(&BackG); - journalGadgetList.push_back(&CancelG); - journalGadgetList.push_back(&ForwardG); - - for (GadgetList::iterator gadgetIter = journalGadgetList.begin(); gadgetIter != journalGadgetList.end(); ++gadgetIter) { - Gadget *gadget = *gadgetIter; - gadget->x = g_lab->_utils->vgaScaleX(JGadX[counter]); - - if (counter == 1) - gadget->y = g_lab->_utils->vgaScaleY(JGadY[counter]) + g_lab->_utils->svgaCord(1); - else - gadget->y = g_lab->_utils->vgaScaleY(JGadY[counter]) - g_lab->_utils->svgaCord(1); - - gadget->_gadgetID = counter; - counter++; - } - - return true; } /** @@ -302,15 +271,18 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) { else turnPage((bool)(wipenum == 1)); + Gadget *backGadget = _event->getGadget(0); + Gadget *forwardGadget = _event->getGadget(1); + if (JPage == 0) - disableGadget(&BackG, 15); + disableGadget(backGadget, 15); else - enableGadget(&BackG); + enableGadget(backGadget); if (lastpage) - disableGadget(&ForwardG, 15); + disableGadget(forwardGadget, 15); else - enableGadget(&ForwardG); + enableGadget(forwardGadget); if (needFade) @@ -373,11 +345,6 @@ void LabEngine::processJournal() { * Does the journal processing. */ void LabEngine::doJournal() { - GadgetList journalGadgetList; - journalGadgetList.push_back(&BackG); - journalGadgetList.push_back(&CancelG); - journalGadgetList.push_back(&ForwardG); - _graphics->blackAllScreen(); lastpage = false; @@ -395,13 +362,13 @@ void LabEngine::doJournal() { drawJournal(0, true); - _event->attachGadgetList(&journalGadgetList); + _event->attachGadgetList(&_journalGadgetList); _event->mouseShow(); processJournal(); _event->attachGadgetList(NULL); _graphics->fade(false, 0); _event->mouseHide(); - journalGadgetList.clear(); + freeButtonList(&_journalGadgetList); ScreenImage._imageData = _graphics->getCurrentDrawingBuffer(); @@ -445,6 +412,7 @@ bool LabEngine::saveRestoreGame() { } } + //_event->attachGadgetList(&_moveGadgetList); _graphics->screenUpdate(); return isOK; -- cgit v1.2.3 From ff6dfee221ac017caeb3c10389766129b0339e5e Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 8 Dec 2015 17:14:27 +0200 Subject: LAB: Initialize the game interface correctly after saving/loading --- engines/lab/special.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 5aa8db5181..502520a588 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -412,7 +412,8 @@ bool LabEngine::saveRestoreGame() { } } - //_event->attachGadgetList(&_moveGadgetList); + _alternate = false; + _mainDisplay = true; _graphics->screenUpdate(); return isOK; -- cgit v1.2.3 From 90e221a570bf684dee016a0aaa5e8ca968465390 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 8 Dec 2015 17:34:12 +0200 Subject: LAB: Plug a memory leak --- engines/lab/special.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 502520a588..cce06e69dc 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -152,7 +152,7 @@ void LabEngine::loadJournalData() { char filename[20]; bool bridge, dirty, news, clean; - journalFont = g_lab->_resource->getFont("P:Journal.fon"); // FIXME: memory leak + journalFont = g_lab->_resource->getFont("P:Journal.fon"); g_lab->_music->updateMusic(); @@ -368,7 +368,9 @@ void LabEngine::doJournal() { _event->attachGadgetList(NULL); _graphics->fade(false, 0); _event->mouseHide(); + freeButtonList(&_journalGadgetList); + g_lab->_graphics->closeFont(journalFont); ScreenImage._imageData = _graphics->getCurrentDrawingBuffer(); -- cgit v1.2.3 From 151e27f4b1d5a98a3867c46d770b9b2a41f8905c Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 8 Dec 2015 18:24:44 +0200 Subject: LAB: Fix regression in setCurClose(). Fixes closeups A regression from 78e8896ce7583fbd1feee8e3e9c1aca0f11c2392 --- engines/lab/special.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index cce06e69dc..5a0348c2ca 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -564,7 +564,7 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isintera testcptr = _cptr; MouseY = 64 + (MouseY / MonGadHeight) * 42; MouseX = 101; - setCurClose(Common::Point(MouseX, MouseY), &_cptr, true); + setCurClose(Common::Point(MouseX, MouseY), &_cptr, false); if (testcptr != _cptr) { lastcptr[depth] = testcptr; -- cgit v1.2.3 From eccb8527497e7f50d2de9c026e1c4c194096bc5f Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Tue, 8 Dec 2015 20:31:21 +0100 Subject: LAB: Removed unnecessary includes --- engines/lab/special.cpp | 6 ------ 1 file changed, 6 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 5a0348c2ca..ee454bf70c 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -34,12 +34,6 @@ #include "gui/saveload.h" #include "lab/lab.h" -#include "lab/labfun.h" -#include "lab/image.h" -#include "lab/processroom.h" -#include "lab/interface.h" -#include "lab/anim.h" -#include "lab/resource.h" namespace Lab { -- cgit v1.2.3 From d8e01fe23a569e60e9cacf7b29fa69e7cab03eb5 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Tue, 8 Dec 2015 20:36:05 +0100 Subject: LAB: Reduce header dependency from music.h --- engines/lab/special.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index ee454bf70c..f9eb0db87c 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -34,6 +34,7 @@ #include "gui/saveload.h" #include "lab/lab.h" +#include "lab/music.h" namespace Lab { -- cgit v1.2.3 From 8e9798a0bce3fb6fac55a85c7f9e54176d4cbc85 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Tue, 8 Dec 2015 20:46:13 +0100 Subject: LAB: Reduce header intra-dependency. Reduced image.h dependency --- engines/lab/special.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index f9eb0db87c..8b1e426de2 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -35,6 +35,7 @@ #include "lab/lab.h" #include "lab/music.h" +#include "lab/image.h" namespace Lab { -- cgit v1.2.3 From b1585b2c62c1d45ef22e5f08a1a434ec78c2fd3e Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Tue, 8 Dec 2015 20:53:44 +0100 Subject: LAB: Reduced header dependency: savegame.h --- engines/lab/special.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 8b1e426de2..11af40a609 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -36,6 +36,7 @@ #include "lab/lab.h" #include "lab/music.h" #include "lab/image.h" +#include "lab/savegame.h" namespace Lab { -- cgit v1.2.3 From 5fad5cece3704f8e4267da4610a014017d32db1d Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Tue, 8 Dec 2015 21:00:50 +0100 Subject: LAB: Reduced header dependency: labsets.h, utils.h --- engines/lab/special.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 11af40a609..274e9870d4 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -34,9 +34,11 @@ #include "gui/saveload.h" #include "lab/lab.h" +#include "lab/labsets.h" #include "lab/music.h" #include "lab/image.h" #include "lab/savegame.h" +#include "lab/utils.h" namespace Lab { -- cgit v1.2.3 From 9a9b752c0e0e14d35e99cd5475bfa2138fff4d4a Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Tue, 8 Dec 2015 21:10:54 +0100 Subject: LAB: More header dependency redux --- engines/lab/special.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 274e9870d4..55825a734a 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -34,9 +34,11 @@ #include "gui/saveload.h" #include "lab/lab.h" + +#include "lab/image.h" #include "lab/labsets.h" #include "lab/music.h" -#include "lab/image.h" +#include "lab/resource.h" #include "lab/savegame.h" #include "lab/utils.h" -- cgit v1.2.3 From 66f2935a2282521f77062ad42d3308699f087cb5 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Tue, 8 Dec 2015 21:19:41 +0100 Subject: LAB: Reduced header dependency: dispman.h, eventman.h --- engines/lab/special.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 55825a734a..690dc293a3 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -35,6 +35,8 @@ #include "lab/lab.h" +#include "lab/dispman.h" +#include "lab/eventman.h" #include "lab/image.h" #include "lab/labsets.h" #include "lab/music.h" -- cgit v1.2.3 From 9015cf72a326e5bac2eeb311b257690a01d4bc26 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Tue, 8 Dec 2015 21:28:45 +0100 Subject: LAB: Reduced header dependency: interface.h --- engines/lab/special.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 690dc293a3..24db6ce076 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -38,6 +38,7 @@ #include "lab/dispman.h" #include "lab/eventman.h" #include "lab/image.h" +#include "lab/interface.h" #include "lab/labsets.h" #include "lab/music.h" #include "lab/resource.h" -- cgit v1.2.3 From 9af853b6ab7c998910d2212206fab1a14c8b5818 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Tue, 8 Dec 2015 21:35:31 +0100 Subject: LAB: Reduced last reducable header: anim.h --- engines/lab/special.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 24db6ce076..3578a650b6 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -35,6 +35,7 @@ #include "lab/lab.h" +#include "lab/anim.h" #include "lab/dispman.h" #include "lab/eventman.h" #include "lab/image.h" -- cgit v1.2.3 From e5f753749fc55beb0d48180d1d649fc81412182c Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Tue, 8 Dec 2015 21:47:36 +0100 Subject: LAB: Reduced dependency on processroom.h. Yay! --- engines/lab/special.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 3578a650b6..8bb57adfed 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -42,6 +42,7 @@ #include "lab/interface.h" #include "lab/labsets.h" #include "lab/music.h" +#include "lab/processroom.h" #include "lab/resource.h" #include "lab/savegame.h" #include "lab/utils.h" -- cgit v1.2.3 From 0af299d3c78d59de20fe5ad41169f755fda297f4 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Wed, 9 Dec 2015 06:17:16 +0100 Subject: LAB: Move saveRestoreGame() to saveload.cpp --- engines/lab/special.cpp | 49 ------------------------------------------------- 1 file changed, 49 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 8bb57adfed..63b8109e2f 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -28,11 +28,6 @@ * */ -#include "common/translation.h" - -#include "gui/message.h" -#include "gui/saveload.h" - #include "lab/lab.h" #include "lab/anim.h" @@ -44,7 +39,6 @@ #include "lab/music.h" #include "lab/processroom.h" #include "lab/resource.h" -#include "lab/savegame.h" #include "lab/utils.h" namespace Lab { @@ -71,7 +65,6 @@ Image *MonButton; #define DIRTY 175 #define NONEWS 135 #define NOCLEAN 152 -#define QUARTERNUM 30 static byte *loadBackPict(const char *fileName, bool tomem) { @@ -385,48 +378,6 @@ void LabEngine::doJournal() { _graphics->blackScreen(); } -bool LabEngine::saveRestoreGame() { - bool isOK = false; - - //g_lab->showMainMenu(); - - // The original had one screen for saving/loading. We have two. - // Ask the user which screen to use. - GUI::MessageDialog saveOrLoad(_("Would you like to save or restore a game?"), _("Save"), _("Restore")); - - int choice = saveOrLoad.runModal(); - if (choice == GUI::kMessageOK) { - // Save - GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save"), true); - int slot = dialog->runModalWithCurrentTarget(); - if (slot >= 0) { - Common::String desc = dialog->getResultString(); - - if (desc.empty()) { - // create our own description for the saved game, the user didn't enter it - desc = dialog->createDefaultSaveDescription(slot); - } - - isOK = saveGame(_direction, _inventory[QUARTERNUM]._many, slot, desc); - } - } else { - // Restore - GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Restore game:"), _("Restore"), false); - int slot = dialog->runModalWithCurrentTarget(); - if (slot >= 0) { - isOK = loadGame(&_direction, &(_inventory[QUARTERNUM]._many), slot); - if (isOK) - _music->resetMusic(); - } - } - - _alternate = false; - _mainDisplay = true; - _graphics->screenUpdate(); - - return isOK; -} - /** * Draws the text for the monitor. */ -- cgit v1.2.3 From 199fa254f9be4d7cb4395b871755557024926b9d Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 9 Dec 2015 11:22:41 +0100 Subject: LAB: Rename CloseDataPtr pointers, some refactoring --- engines/lab/special.cpp | 64 ++++++++++++++++++++++++------------------------- 1 file changed, 32 insertions(+), 32 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 63b8109e2f..d015c4e263 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -442,24 +442,24 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16 * Processes user input. */ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2) { - IntuiMessage *Msg; - uint32 Class; - uint16 Qualifier, Code, MouseX, MouseY; + IntuiMessage *msg; + uint32 msgClass; + uint16 qualifier, code, mouseX, mouseY; const char *Test = " ", *StartFileName = TextFileName; - CloseDataPtr startcptr = _cptr, testcptr, lastcptr[10]; + CloseDataPtr startClosePtr = _closeDataPtr, lastClosePtr[10]; uint16 depth = 0; - lastcptr[0] = _cptr; + lastClosePtr[0] = _closeDataPtr; while (1) { if (isinteractive) { - if (_cptr == NULL) - _cptr = startcptr; + if (_closeDataPtr == NULL) + _closeDataPtr = startClosePtr; - if (_cptr == startcptr) + if (_closeDataPtr == startClosePtr) Test = StartFileName; else - Test = _cptr->_graphicName; + Test = _closeDataPtr->_graphicName; if (strcmp(Test, TextFileName)) { monitorPage = 0; @@ -475,42 +475,42 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isintera // Make sure we check the music at least after every message _music->updateMusic(); - Msg = getMsg(); + msg = getMsg(); - if (Msg == NULL) { + if (msg == NULL) { _music->updateMusic(); } else { - Class = Msg->_msgClass; - Qualifier = Msg->_qualifier; - MouseX = Msg->_mouseX; - MouseY = Msg->_mouseY; - Code = Msg->_code; - - if (((Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) || - ((Class == RAWKEY) && (Code == 27))) + msgClass = msg->_msgClass; + qualifier = msg->_qualifier; + mouseX = msg->_mouseX; + mouseY = msg->_mouseY; + code = msg->_code; + + if (((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & qualifier)) || + ((msgClass == RAWKEY) && (code == 27))) return; - else if ((Class == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & Qualifier)) { - if ((MouseY >= g_lab->_utils->vgaScaleY(171)) && (MouseY <= g_lab->_utils->vgaScaleY(200))) { - if ((MouseX >= g_lab->_utils->vgaScaleX(259)) && (MouseX <= g_lab->_utils->vgaScaleX(289))) { + else if ((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & qualifier)) { + if ((mouseY >= g_lab->_utils->vgaScaleY(171)) && (mouseY <= g_lab->_utils->vgaScaleY(200))) { + if ((mouseX >= g_lab->_utils->vgaScaleX(259)) && (mouseX <= g_lab->_utils->vgaScaleX(289))) { if (!lastpage) { monitorPage += 1; drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive); } - } else if ((MouseX >= g_lab->_utils->vgaScaleX(0)) && (MouseX <= g_lab->_utils->vgaScaleX(31))) { + } else if ((mouseX >= g_lab->_utils->vgaScaleX(0)) && (mouseX <= g_lab->_utils->vgaScaleX(31))) { return; - } else if ((MouseX >= g_lab->_utils->vgaScaleX(290)) && (MouseX <= g_lab->_utils->vgaScaleX(320))) { + } else if ((mouseX >= g_lab->_utils->vgaScaleX(290)) && (mouseX <= g_lab->_utils->vgaScaleX(320))) { if (monitorPage >= 1) { monitorPage -= 1; drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive); } - } else if ((MouseX >= g_lab->_utils->vgaScaleX(31)) && (MouseX <= g_lab->_utils->vgaScaleX(59))) { + } else if ((mouseX >= g_lab->_utils->vgaScaleX(31)) && (mouseX <= g_lab->_utils->vgaScaleX(59))) { if (isinteractive) { monitorPage = 0; if (depth) { depth--; - _cptr = lastcptr[depth]; + _closeDataPtr = lastClosePtr[depth]; } } else if (monitorPage > 0) { monitorPage = 0; @@ -518,13 +518,13 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isintera } } } else if (isinteractive) { - testcptr = _cptr; - MouseY = 64 + (MouseY / MonGadHeight) * 42; - MouseX = 101; - setCurClose(Common::Point(MouseX, MouseY), &_cptr, false); + CloseDataPtr tmpClosePtr = _closeDataPtr; + mouseY = 64 + (mouseY / MonGadHeight) * 42; + mouseX = 101; + setCurrentClose(Common::Point(mouseX, mouseY), &_closeDataPtr, false); - if (testcptr != _cptr) { - lastcptr[depth] = testcptr; + if (tmpClosePtr != _closeDataPtr) { + lastClosePtr[depth] = tmpClosePtr; depth++; } } -- cgit v1.2.3 From 67b3960968b71d529236ab667bad0de5632fa5ea Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 10 Dec 2015 07:04:59 +0100 Subject: LAB: Remove some useless use of g_lab --- engines/lab/special.cpp | 90 ++++++++++++++++++++++++------------------------- 1 file changed, 45 insertions(+), 45 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index d015c4e263..f100cba4cd 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -93,13 +93,13 @@ static byte *loadBackPict(const char *fileName, bool tomem) { * Does the things to properly set up the detective notes. */ void LabEngine::doNotes() { - TextFont *noteFont = g_lab->_resource->getFont("P:Note.fon"); - char *ntext = g_lab->_resource->getText("Lab:Rooms/Notes"); + TextFont *noteFont = _resource->getFont("P:Note.fon"); + char *ntext = _resource->getText("Lab:Rooms/Notes"); - g_lab->_graphics->flowText(noteFont, -2 + g_lab->_utils->svgaCord(1), 0, 0, false, false, true, true, g_lab->_utils->vgaScaleX(25) + g_lab->_utils->svgaCord(15), g_lab->_utils->vgaScaleY(50), g_lab->_utils->vgaScaleX(295) - g_lab->_utils->svgaCord(15), g_lab->_utils->vgaScaleY(148), ntext); - g_lab->_graphics->setPalette(g_lab->_anim->_diffPalette, 256); + _graphics->flowText(noteFont, -2 + _utils->svgaCord(1), 0, 0, false, false, true, true, _utils->vgaScaleX(25) + _utils->svgaCord(15), _utils->vgaScaleY(50), _utils->vgaScaleX(295) - _utils->svgaCord(15), _utils->vgaScaleY(148), ntext); + _graphics->setPalette(_anim->_diffPalette, 256); - g_lab->_graphics->closeFont(noteFont); + _graphics->closeFont(noteFont); delete[] ntext; } @@ -114,34 +114,34 @@ void LabEngine::doWestPaper() { int32 FileLen, CharsPrinted; uint16 y = 268; - paperFont = g_lab->_resource->getFont("P:News22.fon"); - ntext = g_lab->_resource->getText("Lab:Rooms/Date"); - g_lab->_graphics->flowText(paperFont, 0, 0, 0, false, true, false, true, g_lab->_utils->vgaScaleX(57), g_lab->_utils->vgaScaleY(77) + g_lab->_utils->svgaCord(2), g_lab->_utils->vgaScaleX(262), g_lab->_utils->vgaScaleY(91), ntext); - g_lab->_graphics->closeFont(paperFont); + paperFont = _resource->getFont("P:News22.fon"); + ntext = _resource->getText("Lab:Rooms/Date"); + _graphics->flowText(paperFont, 0, 0, 0, false, true, false, true, _utils->vgaScaleX(57), _utils->vgaScaleY(77) + _utils->svgaCord(2), _utils->vgaScaleX(262), _utils->vgaScaleY(91), ntext); + _graphics->closeFont(paperFont); delete[] ntext; - paperFont = g_lab->_resource->getFont("P:News32.fon"); - ntext = g_lab->_resource->getText("Lab:Rooms/Headline"); + paperFont = _resource->getFont("P:News32.fon"); + ntext = _resource->getText("Lab:Rooms/Headline"); FileLen = strlen(ntext) - 1; - CharsPrinted = g_lab->_graphics->flowText(paperFont, -8, 0, 0, false, true, false, true, g_lab->_utils->vgaScaleX(57), g_lab->_utils->vgaScaleY(86) - g_lab->_utils->svgaCord(2), g_lab->_utils->vgaScaleX(262), g_lab->_utils->vgaScaleY(118), ntext); + CharsPrinted = _graphics->flowText(paperFont, -8, 0, 0, false, true, false, true, _utils->vgaScaleX(57), _utils->vgaScaleY(86) - _utils->svgaCord(2), _utils->vgaScaleX(262), _utils->vgaScaleY(118), ntext); if (CharsPrinted < FileLen) { - y = 130 - g_lab->_utils->svgaCord(5); - g_lab->_graphics->flowText(paperFont, -8 - g_lab->_utils->svgaCord(1), 0, 0, false, true, false, true, g_lab->_utils->vgaScaleX(57), g_lab->_utils->vgaScaleY(86) - g_lab->_utils->svgaCord(2), g_lab->_utils->vgaScaleX(262), g_lab->_utils->vgaScaleY(132), ntext); + y = 130 - _utils->svgaCord(5); + _graphics->flowText(paperFont, -8 - _utils->svgaCord(1), 0, 0, false, true, false, true, _utils->vgaScaleX(57), _utils->vgaScaleY(86) - _utils->svgaCord(2), _utils->vgaScaleX(262), _utils->vgaScaleY(132), ntext); } else - y = 115 - g_lab->_utils->svgaCord(5); - g_lab->_graphics->closeFont(paperFont); + y = 115 - _utils->svgaCord(5); + _graphics->closeFont(paperFont); delete[] ntext; - paperFont = g_lab->_resource->getFont("P:Note.fon"); - ntext = g_lab->_resource->getText("Lab:Rooms/Col1"); - CharsPrinted = g_lab->_graphics->flowTextScaled(paperFont, -4, 0, 0, false, false, false, true, 45, y, 158, 148, ntext); + paperFont = _resource->getFont("P:Note.fon"); + ntext = _resource->getText("Lab:Rooms/Col1"); + CharsPrinted = _graphics->flowTextScaled(paperFont, -4, 0, 0, false, false, false, true, 45, y, 158, 148, ntext); delete[] ntext; - ntext = g_lab->_resource->getText("Lab:Rooms/Col2"); - CharsPrinted = g_lab->_graphics->flowTextScaled(paperFont, -4, 0, 0, false, false, false, true, 162, y, 275, 148, ntext); + ntext = _resource->getText("Lab:Rooms/Col2"); + CharsPrinted = _graphics->flowTextScaled(paperFont, -4, 0, 0, false, false, false, true, 162, y, 275, 148, ntext); delete[] ntext; - g_lab->_graphics->closeFont(paperFont); + _graphics->closeFont(paperFont); - g_lab->_graphics->setPalette(g_lab->_anim->_diffPalette, 256); + _graphics->setPalette(_anim->_diffPalette, 256); } /** @@ -151,15 +151,15 @@ void LabEngine::loadJournalData() { char filename[20]; bool bridge, dirty, news, clean; - journalFont = g_lab->_resource->getFont("P:Journal.fon"); + journalFont = _resource->getFont("P:Journal.fon"); - g_lab->_music->updateMusic(); + _music->updateMusic(); strcpy(filename, "Lab:Rooms/j0"); - bridge = g_lab->_conditions->in(BRIDGE0) || g_lab->_conditions->in(BRIDGE1); - dirty = g_lab->_conditions->in(DIRTY); - news = !g_lab->_conditions->in(NONEWS); - clean = !g_lab->_conditions->in(NOCLEAN); + bridge = _conditions->in(BRIDGE0) || _conditions->in(BRIDGE1); + dirty = _conditions->in(DIRTY); + news = !_conditions->in(NONEWS); + clean = !_conditions->in(NOCLEAN); if (bridge && clean && news) filename[11] = '8'; @@ -180,11 +180,11 @@ void LabEngine::loadJournalData() { else if (bridge) filename[11] = '1'; - journaltext = g_lab->_resource->getText(filename); - journaltexttitle = g_lab->_resource->getText("Lab:Rooms/jt"); + journaltext = _resource->getText(filename); + journaltexttitle = _resource->getText("Lab:Rooms/jt"); - Common::File *journalFile = g_lab->_resource->openDataFile("P:JImage"); - Utils *utils = g_lab->_utils; + Common::File *journalFile = _resource->openDataFile("P:JImage"); + Utils *utils = _utils; _journalGadgetList.push_back(createButton( 80, utils->vgaScaleY(162) + utils->svgaCord(1), 0, VKEY_LTARROW, new Image(journalFile), new Image(journalFile))); // back _journalGadgetList.push_back(createButton(144, utils->vgaScaleY(164) - utils->svgaCord(1), 1, VKEY_RTARROW, new Image(journalFile), new Image(journalFile))); // foward _journalGadgetList.push_back(createButton(194, utils->vgaScaleY(162) + utils->svgaCord(1), 2, 0, new Image(journalFile), new Image(journalFile))); // cancel @@ -287,14 +287,14 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) { if (needFade) _graphics->fade(true, 0); - g_lab->_anim->_noPalChange = true; + _anim->_noPalChange = true; JBackImage._imageData = _graphics->readPictToMem("P:Journal.pic", _graphics->_screenWidth, _graphics->_screenHeight); GotBackImage = true; eatMessages(); _event->mouseShow(); - g_lab->_anim->_noPalChange = false; + _anim->_noPalChange = false; } /** @@ -369,7 +369,7 @@ void LabEngine::doJournal() { _event->mouseHide(); freeButtonList(&_journalGadgetList); - g_lab->_graphics->closeFont(journalFont); + _graphics->closeFont(journalFont); ScreenImage._imageData = _graphics->getCurrentDrawingBuffer(); @@ -395,7 +395,7 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16 numlines += (*text - '0'); text += 2; - fheight = g_lab->_graphics->textHeight(monitorFont); + fheight = _graphics->textHeight(monitorFont); x1 = MonButton->_width + _utils->vgaScaleX(3); MonGadHeight = MonButton->_height + _utils->vgaScaleY(3); @@ -465,7 +465,7 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isintera monitorPage = 0; TextFileName = Test; - ntext = g_lab->_resource->getText(TextFileName); + ntext = _resource->getText(TextFileName); _graphics->fade(false, 0); drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive); _graphics->fade(true, 0); @@ -491,20 +491,20 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isintera return; else if ((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & qualifier)) { - if ((mouseY >= g_lab->_utils->vgaScaleY(171)) && (mouseY <= g_lab->_utils->vgaScaleY(200))) { - if ((mouseX >= g_lab->_utils->vgaScaleX(259)) && (mouseX <= g_lab->_utils->vgaScaleX(289))) { + if ((mouseY >= _utils->vgaScaleY(171)) && (mouseY <= _utils->vgaScaleY(200))) { + if ((mouseX >= _utils->vgaScaleX(259)) && (mouseX <= _utils->vgaScaleX(289))) { if (!lastpage) { monitorPage += 1; drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive); } - } else if ((mouseX >= g_lab->_utils->vgaScaleX(0)) && (mouseX <= g_lab->_utils->vgaScaleX(31))) { + } else if ((mouseX >= _utils->vgaScaleX(0)) && (mouseX <= _utils->vgaScaleX(31))) { return; - } else if ((mouseX >= g_lab->_utils->vgaScaleX(290)) && (mouseX <= g_lab->_utils->vgaScaleX(320))) { + } else if ((mouseX >= _utils->vgaScaleX(290)) && (mouseX <= _utils->vgaScaleX(320))) { if (monitorPage >= 1) { monitorPage -= 1; drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive); } - } else if ((mouseX >= g_lab->_utils->vgaScaleX(31)) && (mouseX <= g_lab->_utils->vgaScaleX(59))) { + } else if ((mouseX >= _utils->vgaScaleX(31)) && (mouseX <= _utils->vgaScaleX(59))) { if (isinteractive) { monitorPage = 0; @@ -558,7 +558,7 @@ void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive, _graphics->FadePalette = hipal; TextFont *monitorFont = _resource->getFont("P:Map.fon"); - Common::File *buttonFile = g_lab->_resource->openDataFile("P:MonImage"); + Common::File *buttonFile = _resource->openDataFile("P:MonImage"); MonButton = new Image(buttonFile); delete buttonFile; @@ -571,7 +571,7 @@ void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive, _graphics->fade(false, 0); _event->mouseHide(); delete[] ntext; - g_lab->_graphics->closeFont(monitorFont); + _graphics->closeFont(monitorFont); _graphics->setAPen(0); _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1); -- cgit v1.2.3 From 165c0b3b49dbbe5b5758b1ba34667a6f8dd44987 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Thu, 10 Dec 2015 10:51:02 +0100 Subject: LAB: More vars renaming --- engines/lab/special.cpp | 159 +++++++++++++++++++++++------------------------- 1 file changed, 76 insertions(+), 83 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index f100cba4cd..f0b8152a34 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -109,35 +109,35 @@ void LabEngine::doNotes() { * OpenHiRes already called. */ void LabEngine::doWestPaper() { - char *ntext; - TextFont *paperFont; - int32 FileLen, CharsPrinted; - uint16 y = 268; - - paperFont = _resource->getFont("P:News22.fon"); - ntext = _resource->getText("Lab:Rooms/Date"); + TextFont *paperFont = _resource->getFont("P:News22.fon"); + char *ntext = _resource->getText("Lab:Rooms/Date"); _graphics->flowText(paperFont, 0, 0, 0, false, true, false, true, _utils->vgaScaleX(57), _utils->vgaScaleY(77) + _utils->svgaCord(2), _utils->vgaScaleX(262), _utils->vgaScaleY(91), ntext); _graphics->closeFont(paperFont); delete[] ntext; paperFont = _resource->getFont("P:News32.fon"); ntext = _resource->getText("Lab:Rooms/Headline"); - FileLen = strlen(ntext) - 1; - CharsPrinted = _graphics->flowText(paperFont, -8, 0, 0, false, true, false, true, _utils->vgaScaleX(57), _utils->vgaScaleY(86) - _utils->svgaCord(2), _utils->vgaScaleX(262), _utils->vgaScaleY(118), ntext); - if (CharsPrinted < FileLen) { + + int fileLen = strlen(ntext) - 1; + int charsPrinted = _graphics->flowText(paperFont, -8, 0, 0, false, true, false, true, _utils->vgaScaleX(57), _utils->vgaScaleY(86) - _utils->svgaCord(2), _utils->vgaScaleX(262), _utils->vgaScaleY(118), ntext); + + uint16 y; + + if (charsPrinted < fileLen) { y = 130 - _utils->svgaCord(5); _graphics->flowText(paperFont, -8 - _utils->svgaCord(1), 0, 0, false, true, false, true, _utils->vgaScaleX(57), _utils->vgaScaleY(86) - _utils->svgaCord(2), _utils->vgaScaleX(262), _utils->vgaScaleY(132), ntext); } else y = 115 - _utils->svgaCord(5); + _graphics->closeFont(paperFont); delete[] ntext; paperFont = _resource->getFont("P:Note.fon"); ntext = _resource->getText("Lab:Rooms/Col1"); - CharsPrinted = _graphics->flowTextScaled(paperFont, -4, 0, 0, false, false, false, true, 45, y, 158, 148, ntext); + charsPrinted = _graphics->flowTextScaled(paperFont, -4, 0, 0, false, false, false, true, 45, y, 158, 148, ntext); delete[] ntext; ntext = _resource->getText("Lab:Rooms/Col2"); - CharsPrinted = _graphics->flowTextScaled(paperFont, -4, 0, 0, false, false, false, true, 162, y, 275, 148, ntext); + charsPrinted = _graphics->flowTextScaled(paperFont, -4, 0, 0, false, false, false, true, 162, y, 275, 148, ntext); delete[] ntext; _graphics->closeFont(paperFont); @@ -148,18 +148,17 @@ void LabEngine::doWestPaper() { * Loads in the data for the journal. */ void LabEngine::loadJournalData() { - char filename[20]; - bool bridge, dirty, news, clean; - journalFont = _resource->getFont("P:Journal.fon"); _music->updateMusic(); + char filename[20]; strcpy(filename, "Lab:Rooms/j0"); - bridge = _conditions->in(BRIDGE0) || _conditions->in(BRIDGE1); - dirty = _conditions->in(DIRTY); - news = !_conditions->in(NONEWS); - clean = !_conditions->in(NOCLEAN); + + bool bridge = _conditions->in(BRIDGE0) || _conditions->in(BRIDGE1); + bool dirty = _conditions->in(DIRTY); + bool news = !_conditions->in(NONEWS); + bool clean = !_conditions->in(NOCLEAN); if (bridge && clean && news) filename[11] = '8'; @@ -185,9 +184,11 @@ void LabEngine::loadJournalData() { Common::File *journalFile = _resource->openDataFile("P:JImage"); Utils *utils = _utils; + _journalGadgetList.push_back(createButton( 80, utils->vgaScaleY(162) + utils->svgaCord(1), 0, VKEY_LTARROW, new Image(journalFile), new Image(journalFile))); // back _journalGadgetList.push_back(createButton(144, utils->vgaScaleY(164) - utils->svgaCord(1), 1, VKEY_RTARROW, new Image(journalFile), new Image(journalFile))); // foward _journalGadgetList.push_back(createButton(194, utils->vgaScaleY(162) + utils->svgaCord(1), 2, 0, new Image(journalFile), new Image(journalFile))); // cancel + delete journalFile; } @@ -195,45 +196,45 @@ void LabEngine::loadJournalData() { * Draws the text to the back journal screen to the appropriate Page number */ static void drawJournalText() { - uint16 DrawingToPage = 1; - int32 CharsDrawn = 0L; - char *CurText = journaltext; + uint16 drawingToPage = 1; + int32 charsDrawn = 0L; + char *curText = journaltext; - while (DrawingToPage < JPage) { + while (drawingToPage < JPage) { g_lab->_music->updateMusic(); - CurText = (char *)(journaltext + CharsDrawn); - CharsDrawn += g_lab->_graphics->flowTextScaled(journalFont, -2, 2, 0, false, false, false, false, 52, 32, 152, 148, CurText); + curText = (char *)(journaltext + charsDrawn); + charsDrawn += g_lab->_graphics->flowTextScaled(journalFont, -2, 2, 0, false, false, false, false, 52, 32, 152, 148, curText); - lastpage = (*CurText == 0); + lastpage = (*curText == 0); if (lastpage) - JPage = (DrawingToPage / 2) * 2; + JPage = (drawingToPage / 2) * 2; else - DrawingToPage++; + drawingToPage++; } if (JPage <= 1) { - CurText = journaltexttitle; - g_lab->_graphics->flowTextToMem(&JBackImage, journalFont, -2, 2, 0, false, true, true, true, g_lab->_utils->vgaScaleX(52), g_lab->_utils->vgaScaleY(32), g_lab->_utils->vgaScaleX(152), g_lab->_utils->vgaScaleY(148), CurText); + curText = journaltexttitle; + g_lab->_graphics->flowTextToMem(&JBackImage, journalFont, -2, 2, 0, false, true, true, true, g_lab->_utils->vgaScaleX(52), g_lab->_utils->vgaScaleY(32), g_lab->_utils->vgaScaleX(152), g_lab->_utils->vgaScaleY(148), curText); } else { - CurText = (char *)(journaltext + CharsDrawn); - CharsDrawn += g_lab->_graphics->flowTextToMem(&JBackImage, journalFont, -2, 2, 0, false, false, false, true, g_lab->_utils->vgaScaleX(52), g_lab->_utils->vgaScaleY(32), g_lab->_utils->vgaScaleX(152), g_lab->_utils->vgaScaleY(148), CurText); + curText = (char *)(journaltext + charsDrawn); + charsDrawn += g_lab->_graphics->flowTextToMem(&JBackImage, journalFont, -2, 2, 0, false, false, false, true, g_lab->_utils->vgaScaleX(52), g_lab->_utils->vgaScaleY(32), g_lab->_utils->vgaScaleX(152), g_lab->_utils->vgaScaleY(148), curText); } g_lab->_music->updateMusic(); - CurText = (char *)(journaltext + CharsDrawn); - lastpage = (*CurText == 0); - g_lab->_graphics->flowTextToMem(&JBackImage, journalFont, -2, 2, 0, false, false, false, true, g_lab->_utils->vgaScaleX(171), g_lab->_utils->vgaScaleY(32), g_lab->_utils->vgaScaleX(271), g_lab->_utils->vgaScaleY(148), CurText); + curText = (char *)(journaltext + charsDrawn); + lastpage = (*curText == 0); + g_lab->_graphics->flowTextToMem(&JBackImage, journalFont, -2, 2, 0, false, false, false, true, g_lab->_utils->vgaScaleX(171), g_lab->_utils->vgaScaleY(32), g_lab->_utils->vgaScaleX(271), g_lab->_utils->vgaScaleY(148), curText); - CurText = (char *)(journaltext + CharsDrawn); - lastpage = lastpage || (*CurText == 0); + curText = (char *)(journaltext + charsDrawn); + lastpage = lastpage || (*curText == 0); } /** * Does the turn page wipe. */ -static void turnPage(bool FromLeft) { - if (FromLeft) { +static void turnPage(bool fromLeft) { + if (fromLeft) { for (int i = 0; i < g_lab->_graphics->_screenWidth; i += 8) { g_lab->_music->updateMusic(); g_lab->waitTOF(); @@ -301,35 +302,30 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) { * Processes user input. */ void LabEngine::processJournal() { - IntuiMessage *Msg; - uint32 Class; - uint16 Qualifier, GadID; - while (1) { // Make sure we check the music at least after every message _music->updateMusic(); - Msg = getMsg(); + IntuiMessage *msg = getMsg(); - if (Msg == NULL) { + if (msg == NULL) { _music->updateMusic(); } else { - Class = Msg->_msgClass; - Qualifier = Msg->_qualifier; - GadID = Msg->_code; + uint32 msgClass = msg->_msgClass; + uint16 qualifier = msg->_qualifier; + uint16 gadID = msg->_code; - if (((Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) || - ((Class == RAWKEY) && (GadID == 27))) + if (((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & qualifier)) || + ((msgClass == RAWKEY) && (gadID == 27))) return; - - else if (Class == GADGETUP) { - if (GadID == 0) { + else if (msgClass == GADGETUP) { + if (gadID == 0) { if (JPage >= 2) { JPage -= 2; drawJournal(1, false); } - } else if (GadID == 1) { + } else if (gadID == 1) { return; - } else if (GadID == 2) { + } else if (gadID == 2) { if (!lastpage) { JPage += 2; drawJournal(2, false); @@ -382,9 +378,9 @@ void LabEngine::doJournal() { * Draws the text for the monitor. */ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16 y1, uint16 x2, uint16 y2, bool isinteractive) { - uint16 DrawingToPage = 0, yspacing = 0, numlines, fheight; - int32 CharsDrawn = 0L; - char *CurText = text; + uint16 drawingToPage = 0, yspacing = 0, numlines, fheight; + int32 charsDrawn = 0L; + char *curText = text; _event->mouseHide(); @@ -417,23 +413,23 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16 _graphics->rectFill(x1, y1, x2, y2); } - while (DrawingToPage < monitorPage) { + while (drawingToPage < monitorPage) { _music->updateMusic(); - CurText = (char *)(text + CharsDrawn); - CharsDrawn += _graphics->flowText(monitorFont, yspacing, 0, 0, false, false, false, false, x1, y1, x2, y2, CurText); - lastpage = (*CurText == 0); + curText = (char *)(text + charsDrawn); + charsDrawn += _graphics->flowText(monitorFont, yspacing, 0, 0, false, false, false, false, x1, y1, x2, y2, curText); + lastpage = (*curText == 0); if (lastpage) - monitorPage = DrawingToPage; + monitorPage = drawingToPage; else - DrawingToPage++; + drawingToPage++; } - CurText = (char *)(text + CharsDrawn); - lastpage = (*CurText == 0); - CharsDrawn = _graphics->flowText(monitorFont, yspacing, 2, 0, false, false, false, true, x1, y1, x2, y2, CurText); - CurText += CharsDrawn; - lastpage = lastpage || (*CurText == 0); + curText = (char *)(text + charsDrawn); + lastpage = (*curText == 0); + charsDrawn = _graphics->flowText(monitorFont, yspacing, 2, 0, false, false, false, true, x1, y1, x2, y2, curText); + curText += charsDrawn; + lastpage = lastpage || (*curText == 0); _event->mouseShow(); } @@ -442,10 +438,7 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16 * Processes user input. */ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2) { - IntuiMessage *msg; - uint32 msgClass; - uint16 qualifier, code, mouseX, mouseY; - const char *Test = " ", *StartFileName = TextFileName; + const char *test = " ", *startFileName = TextFileName; CloseDataPtr startClosePtr = _closeDataPtr, lastClosePtr[10]; uint16 depth = 0; @@ -457,13 +450,13 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isintera _closeDataPtr = startClosePtr; if (_closeDataPtr == startClosePtr) - Test = StartFileName; + test = startFileName; else - Test = _closeDataPtr->_graphicName; + test = _closeDataPtr->_graphicName; - if (strcmp(Test, TextFileName)) { + if (strcmp(test, TextFileName)) { monitorPage = 0; - TextFileName = Test; + TextFileName = test; ntext = _resource->getText(TextFileName); _graphics->fade(false, 0); @@ -475,16 +468,16 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isintera // Make sure we check the music at least after every message _music->updateMusic(); - msg = getMsg(); + IntuiMessage *msg = getMsg(); if (msg == NULL) { _music->updateMusic(); } else { - msgClass = msg->_msgClass; - qualifier = msg->_qualifier; - mouseX = msg->_mouseX; - mouseY = msg->_mouseY; - code = msg->_code; + uint32 msgClass = msg->_msgClass; + uint16 qualifier = msg->_qualifier; + uint16 mouseX = msg->_mouseX; + uint16 mouseY = msg->_mouseY; + uint16 code = msg->_code; if (((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & qualifier)) || ((msgClass == RAWKEY) && (code == 27))) -- cgit v1.2.3 From aa7ec3654dfc8a01c734c41946db5d8e79f3cf9b Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 10 Dec 2015 12:45:21 +0200 Subject: LAB: Refactor readPictToMem() This fixes crashes in the teleporter and the journal, and plugs several memory leaks --- engines/lab/special.cpp | 56 ++++++++++++++++++++++--------------------------- 1 file changed, 25 insertions(+), 31 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index f0b8152a34..6289cf2583 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -51,7 +51,7 @@ static char *journaltext, *journaltexttitle; static uint16 JPage = 0; static bool lastpage = false; static Image JBackImage, ScreenImage; -static bool GotBackImage = false; +static byte *_blankJournal; static uint16 monitorPage; static const char *TextFileName; @@ -67,16 +67,11 @@ Image *MonButton; #define NOCLEAN 152 -static byte *loadBackPict(const char *fileName, bool tomem) { - byte *res = nullptr; - +static void loadBackPict(const char *fileName) { g_lab->_graphics->FadePalette = hipal; - g_lab->_anim->_noPalChange = true; - if (tomem) - res = g_lab->_graphics->readPictToMem(fileName, g_lab->_graphics->_screenWidth, g_lab->_graphics->_screenHeight); - else - g_lab->_graphics->readPict(fileName, true); + g_lab->_anim->_noPalChange = true; + g_lab->_graphics->readPict(fileName, true); for (uint16 i = 0; i < 16; i++) { hipal[i] = ((g_lab->_anim->_diffPalette[i * 3] >> 2) << 8) + @@ -85,8 +80,6 @@ static byte *loadBackPict(const char *fileName, bool tomem) { } g_lab->_anim->_noPalChange = false; - - return res; } /** @@ -184,12 +177,21 @@ void LabEngine::loadJournalData() { Common::File *journalFile = _resource->openDataFile("P:JImage"); Utils *utils = _utils; - _journalGadgetList.push_back(createButton( 80, utils->vgaScaleY(162) + utils->svgaCord(1), 0, VKEY_LTARROW, new Image(journalFile), new Image(journalFile))); // back - _journalGadgetList.push_back(createButton(144, utils->vgaScaleY(164) - utils->svgaCord(1), 1, VKEY_RTARROW, new Image(journalFile), new Image(journalFile))); // foward _journalGadgetList.push_back(createButton(194, utils->vgaScaleY(162) + utils->svgaCord(1), 2, 0, new Image(journalFile), new Image(journalFile))); // cancel - + _journalGadgetList.push_back(createButton(144, utils->vgaScaleY(164) - utils->svgaCord(1), 1, VKEY_RTARROW, new Image(journalFile), new Image(journalFile))); // forward delete journalFile; + + _anim->_noPalChange = true; + JBackImage._imageData = new byte[_graphics->_screenWidth * _graphics->_screenHeight]; + _graphics->readPict("P:Journal.pic", true, false, JBackImage._imageData); + _anim->_noPalChange = false; + + // Keep a copy of the blank journal + _blankJournal = new byte[_graphics->_screenWidth * _graphics->_screenHeight]; + memcpy(_blankJournal, JBackImage._imageData, _graphics->_screenWidth * _graphics->_screenHeight); + + ScreenImage._imageData = _graphics->getCurrentDrawingBuffer(); } /** @@ -256,15 +258,11 @@ static void turnPage(bool fromLeft) { */ void LabEngine::drawJournal(uint16 wipenum, bool needFade) { _event->mouseHide(); - _music->updateMusic(); - - if (!GotBackImage) - JBackImage._imageData = loadBackPict("P:Journal.pic", true); - drawJournalText(); - ScreenImage._imageData = _graphics->getCurrentDrawingBuffer(); + // TODO: This is only called to set the palette correctly. Refactor, if possible + loadBackPict("P:Journal.pic"); if (wipenum == 0) JBackImage.blitBitmap(0, 0, &ScreenImage, 0, 0, _graphics->_screenWidth, _graphics->_screenHeight, false); @@ -272,7 +270,7 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) { turnPage((bool)(wipenum == 1)); Gadget *backGadget = _event->getGadget(0); - Gadget *forwardGadget = _event->getGadget(1); + Gadget *forwardGadget = _event->getGadget(2); if (JPage == 0) disableGadget(backGadget, 15); @@ -284,18 +282,14 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) { else enableGadget(forwardGadget); - if (needFade) _graphics->fade(true, 0); - _anim->_noPalChange = true; - JBackImage._imageData = _graphics->readPictToMem("P:Journal.pic", _graphics->_screenWidth, _graphics->_screenHeight); - GotBackImage = true; + // Reset the journal background, so that all the text that has been blitted on it is erased + memcpy(JBackImage._imageData, _blankJournal, _graphics->_screenWidth * _graphics->_screenHeight); eatMessages(); _event->mouseShow(); - - _anim->_noPalChange = false; } /** @@ -343,7 +337,6 @@ void LabEngine::doJournal() { _graphics->blackAllScreen(); lastpage = false; - GotBackImage = false; JBackImage._width = _graphics->_screenWidth; JBackImage._height = _graphics->_screenHeight; @@ -355,15 +348,16 @@ void LabEngine::doJournal() { _music->updateMusic(); loadJournalData(); - drawJournal(0, true); - _event->attachGadgetList(&_journalGadgetList); + drawJournal(0, true); _event->mouseShow(); processJournal(); _event->attachGadgetList(NULL); _graphics->fade(false, 0); _event->mouseHide(); + delete[] _blankJournal; + delete[] JBackImage._imageData; freeButtonList(&_journalGadgetList); _graphics->closeFont(journalFont); @@ -556,7 +550,7 @@ void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive, delete buttonFile; ntext = _resource->getText(textfile); - loadBackPict(background, false); + loadBackPict(background); drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive); _event->mouseShow(); _graphics->fade(true, 0); -- cgit v1.2.3 From aef304a83b15f5e829341f53b7af02099b2b32d3 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 13 Dec 2015 11:55:49 +0100 Subject: LAB: Some renaming and refactoring in special.cpp --- engines/lab/special.cpp | 207 ++++++++++++++++++++---------------------------- 1 file changed, 85 insertions(+), 122 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 6289cf2583..90f20b720a 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -42,46 +42,12 @@ #include "lab/utils.h" namespace Lab { - -static uint16 MonGadHeight = 1; -static uint16 hipal[20]; - -static TextFont *journalFont; -static char *journaltext, *journaltexttitle; -static uint16 JPage = 0; -static bool lastpage = false; -static Image JBackImage, ScreenImage; -static byte *_blankJournal; -static uint16 monitorPage; -static const char *TextFileName; - -Image *MonButton; - -#define INCL(BITSET,BIT) ((BITSET) |= (BIT)) -#define SETBIT(BITSET,BITNUM) INCL(BITSET, (1 << (BITNUM))) -#define INBIT(BITSET,BITNUM) ( ((1 << (BITNUM)) & (BITSET)) > 0 ) #define BRIDGE0 148 #define BRIDGE1 104 #define DIRTY 175 #define NONEWS 135 #define NOCLEAN 152 - -static void loadBackPict(const char *fileName) { - g_lab->_graphics->FadePalette = hipal; - - g_lab->_anim->_noPalChange = true; - g_lab->_graphics->readPict(fileName, true); - - for (uint16 i = 0; i < 16; i++) { - hipal[i] = ((g_lab->_anim->_diffPalette[i * 3] >> 2) << 8) + - ((g_lab->_anim->_diffPalette[i * 3 + 1] >> 2) << 4) + - ((g_lab->_anim->_diffPalette[i * 3 + 2] >> 2)); - } - - g_lab->_anim->_noPalChange = false; -} - /** * Does the things to properly set up the detective notes. */ @@ -96,7 +62,6 @@ void LabEngine::doNotes() { delete[] ntext; } - /** * Does the things to properly set up the old west newspaper. Assumes that * OpenHiRes already called. @@ -141,7 +106,7 @@ void LabEngine::doWestPaper() { * Loads in the data for the journal. */ void LabEngine::loadJournalData() { - journalFont = _resource->getFont("P:Journal.fon"); + _journalFont = _resource->getFont("P:Journal.fon"); _music->updateMusic(); @@ -172,8 +137,8 @@ void LabEngine::loadJournalData() { else if (bridge) filename[11] = '1'; - journaltext = _resource->getText(filename); - journaltexttitle = _resource->getText("Lab:Rooms/jt"); + _journalText = _resource->getText(filename); + _journalTextTitle = _resource->getText("Lab:Rooms/jt"); Common::File *journalFile = _resource->openDataFile("P:JImage"); Utils *utils = _utils; @@ -183,13 +148,13 @@ void LabEngine::loadJournalData() { delete journalFile; _anim->_noPalChange = true; - JBackImage._imageData = new byte[_graphics->_screenWidth * _graphics->_screenHeight]; - _graphics->readPict("P:Journal.pic", true, false, JBackImage._imageData); + journalBackImage._imageData = new byte[_graphics->_screenWidth * _graphics->_screenHeight]; + _graphics->readPict("P:Journal.pic", true, false, journalBackImage._imageData); _anim->_noPalChange = false; // Keep a copy of the blank journal _blankJournal = new byte[_graphics->_screenWidth * _graphics->_screenHeight]; - memcpy(_blankJournal, JBackImage._imageData, _graphics->_screenWidth * _graphics->_screenHeight); + memcpy(_blankJournal, journalBackImage._imageData, _graphics->_screenWidth * _graphics->_screenHeight); ScreenImage._imageData = _graphics->getCurrentDrawingBuffer(); } @@ -197,58 +162,58 @@ void LabEngine::loadJournalData() { /** * Draws the text to the back journal screen to the appropriate Page number */ -static void drawJournalText() { +void LabEngine::drawJournalText() { uint16 drawingToPage = 1; - int32 charsDrawn = 0L; - char *curText = journaltext; + int32 charsDrawn = 0; + char *curText = _journalText; - while (drawingToPage < JPage) { - g_lab->_music->updateMusic(); - curText = (char *)(journaltext + charsDrawn); - charsDrawn += g_lab->_graphics->flowTextScaled(journalFont, -2, 2, 0, false, false, false, false, 52, 32, 152, 148, curText); + while (drawingToPage < _journalPage) { + _music->updateMusic(); + curText = (char *)(_journalText + charsDrawn); + charsDrawn += _graphics->flowTextScaled(_journalFont, -2, 2, 0, false, false, false, false, 52, 32, 152, 148, curText); - lastpage = (*curText == 0); + _lastPage = (*curText == 0); - if (lastpage) - JPage = (drawingToPage / 2) * 2; + if (_lastPage) + _journalPage = (drawingToPage / 2) * 2; else drawingToPage++; } - if (JPage <= 1) { - curText = journaltexttitle; - g_lab->_graphics->flowTextToMem(&JBackImage, journalFont, -2, 2, 0, false, true, true, true, g_lab->_utils->vgaScaleX(52), g_lab->_utils->vgaScaleY(32), g_lab->_utils->vgaScaleX(152), g_lab->_utils->vgaScaleY(148), curText); + if (_journalPage <= 1) { + curText = _journalTextTitle; + _graphics->flowTextToMem(&journalBackImage, _journalFont, -2, 2, 0, false, true, true, true, _utils->vgaScaleX(52), _utils->vgaScaleY(32), _utils->vgaScaleX(152), _utils->vgaScaleY(148), curText); } else { - curText = (char *)(journaltext + charsDrawn); - charsDrawn += g_lab->_graphics->flowTextToMem(&JBackImage, journalFont, -2, 2, 0, false, false, false, true, g_lab->_utils->vgaScaleX(52), g_lab->_utils->vgaScaleY(32), g_lab->_utils->vgaScaleX(152), g_lab->_utils->vgaScaleY(148), curText); + curText = (char *)(_journalText + charsDrawn); + charsDrawn += g_lab->_graphics->flowTextToMem(&journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaScaleX(52), _utils->vgaScaleY(32), _utils->vgaScaleX(152), _utils->vgaScaleY(148), curText); } - g_lab->_music->updateMusic(); - curText = (char *)(journaltext + charsDrawn); - lastpage = (*curText == 0); - g_lab->_graphics->flowTextToMem(&JBackImage, journalFont, -2, 2, 0, false, false, false, true, g_lab->_utils->vgaScaleX(171), g_lab->_utils->vgaScaleY(32), g_lab->_utils->vgaScaleX(271), g_lab->_utils->vgaScaleY(148), curText); + _music->updateMusic(); + curText = (char *)(_journalText + charsDrawn); + _lastPage = (*curText == 0); + _graphics->flowTextToMem(&journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaScaleX(171), _utils->vgaScaleY(32), _utils->vgaScaleX(271), _utils->vgaScaleY(148), curText); - curText = (char *)(journaltext + charsDrawn); - lastpage = lastpage || (*curText == 0); + curText = (char *)(_journalText + charsDrawn); + _lastPage = _lastPage || (*curText == 0); } /** * Does the turn page wipe. */ -static void turnPage(bool fromLeft) { +void LabEngine::turnPage(bool fromLeft) { if (fromLeft) { - for (int i = 0; i < g_lab->_graphics->_screenWidth; i += 8) { - g_lab->_music->updateMusic(); - g_lab->waitTOF(); - ScreenImage._imageData = g_lab->_graphics->getCurrentDrawingBuffer(); - JBackImage.blitBitmap(i, 0, &ScreenImage, i, 0, 8, g_lab->_graphics->_screenHeight, false); + for (int i = 0; i < _graphics->_screenWidth; i += 8) { + _music->updateMusic(); + waitTOF(); + ScreenImage._imageData = _graphics->getCurrentDrawingBuffer(); + journalBackImage.blitBitmap(i, 0, &ScreenImage, i, 0, 8, _graphics->_screenHeight, false); } } else { - for (int i = (g_lab->_graphics->_screenWidth - 8); i > 0; i -= 8) { - g_lab->_music->updateMusic(); - g_lab->waitTOF(); - ScreenImage._imageData = g_lab->_graphics->getCurrentDrawingBuffer(); - JBackImage.blitBitmap(i, 0, &ScreenImage, i, 0, 8, g_lab->_graphics->_screenHeight, false); + for (int i = (_graphics->_screenWidth - 8); i > 0; i -= 8) { + _music->updateMusic(); + waitTOF(); + ScreenImage._imageData = _graphics->getCurrentDrawingBuffer(); + journalBackImage.blitBitmap(i, 0, &ScreenImage, i, 0, 8, _graphics->_screenHeight, false); } } } @@ -260,24 +225,22 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) { _event->mouseHide(); _music->updateMusic(); drawJournalText(); - - // TODO: This is only called to set the palette correctly. Refactor, if possible - loadBackPict("P:Journal.pic"); + _graphics->loadBackPict("P:Journal.pic", _highPalette); if (wipenum == 0) - JBackImage.blitBitmap(0, 0, &ScreenImage, 0, 0, _graphics->_screenWidth, _graphics->_screenHeight, false); + journalBackImage.blitBitmap(0, 0, &ScreenImage, 0, 0, _graphics->_screenWidth, _graphics->_screenHeight, false); else turnPage((bool)(wipenum == 1)); Gadget *backGadget = _event->getGadget(0); Gadget *forwardGadget = _event->getGadget(2); - if (JPage == 0) + if (_journalPage == 0) disableGadget(backGadget, 15); else enableGadget(backGadget); - if (lastpage) + if (_lastPage) disableGadget(forwardGadget, 15); else enableGadget(forwardGadget); @@ -286,7 +249,7 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) { _graphics->fade(true, 0); // Reset the journal background, so that all the text that has been blitted on it is erased - memcpy(JBackImage._imageData, _blankJournal, _graphics->_screenWidth * _graphics->_screenHeight); + memcpy(journalBackImage._imageData, _blankJournal, _graphics->_screenWidth * _graphics->_screenHeight); eatMessages(); _event->mouseShow(); @@ -313,15 +276,15 @@ void LabEngine::processJournal() { return; else if (msgClass == GADGETUP) { if (gadID == 0) { - if (JPage >= 2) { - JPage -= 2; + if (_journalPage >= 2) { + _journalPage -= 2; drawJournal(1, false); } } else if (gadID == 1) { return; } else if (gadID == 2) { - if (!lastpage) { - JPage += 2; + if (!_lastPage) { + _journalPage += 2; drawJournal(2, false); } } @@ -336,13 +299,13 @@ void LabEngine::processJournal() { void LabEngine::doJournal() { _graphics->blackAllScreen(); - lastpage = false; + _lastPage = false; - JBackImage._width = _graphics->_screenWidth; - JBackImage._height = _graphics->_screenHeight; - JBackImage._imageData = NULL; + journalBackImage._width = _graphics->_screenWidth; + journalBackImage._height = _graphics->_screenHeight; + journalBackImage._imageData = NULL; - ScreenImage = JBackImage; + ScreenImage = journalBackImage; ScreenImage._imageData = _graphics->getCurrentDrawingBuffer(); _music->updateMusic(); @@ -357,9 +320,9 @@ void LabEngine::doJournal() { _event->mouseHide(); delete[] _blankJournal; - delete[] JBackImage._imageData; + delete[] journalBackImage._imageData; freeButtonList(&_journalGadgetList); - _graphics->closeFont(journalFont); + _graphics->closeFont(_journalFont); ScreenImage._imageData = _graphics->getCurrentDrawingBuffer(); @@ -386,19 +349,19 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16 text += 2; fheight = _graphics->textHeight(monitorFont); - x1 = MonButton->_width + _utils->vgaScaleX(3); - MonGadHeight = MonButton->_height + _utils->vgaScaleY(3); + x1 = _monitorButton->_width + _utils->vgaScaleX(3); + _monitorGadgetHeight = _monitorButton->_height + _utils->vgaScaleY(3); - if (MonGadHeight > fheight) - yspacing = MonGadHeight - fheight; + if (_monitorGadgetHeight > fheight) + yspacing = _monitorGadgetHeight - fheight; else - MonGadHeight = fheight; + _monitorGadgetHeight = fheight; _graphics->setAPen(0); _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, y2); for (uint16 i = 0; i < numlines; i++) - MonButton->drawImage(0, i * MonGadHeight); + _monitorButton->drawImage(0, i * _monitorGadgetHeight); } else if (isinteractive) { _graphics->setAPen(0); _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, y2); @@ -407,23 +370,23 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16 _graphics->rectFill(x1, y1, x2, y2); } - while (drawingToPage < monitorPage) { + while (drawingToPage < _monitorPage) { _music->updateMusic(); curText = (char *)(text + charsDrawn); charsDrawn += _graphics->flowText(monitorFont, yspacing, 0, 0, false, false, false, false, x1, y1, x2, y2, curText); - lastpage = (*curText == 0); + _lastPage = (*curText == 0); - if (lastpage) - monitorPage = drawingToPage; + if (_lastPage) + _monitorPage = drawingToPage; else drawingToPage++; } curText = (char *)(text + charsDrawn); - lastpage = (*curText == 0); + _lastPage = (*curText == 0); charsDrawn = _graphics->flowText(monitorFont, yspacing, 2, 0, false, false, false, true, x1, y1, x2, y2, curText); curText += charsDrawn; - lastpage = lastpage || (*curText == 0); + _lastPage = _lastPage || (*curText == 0); _event->mouseShow(); } @@ -432,7 +395,7 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16 * Processes user input. */ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2) { - const char *test = " ", *startFileName = TextFileName; + const char *test = " ", *startFileName = _monitorTextFilename; CloseDataPtr startClosePtr = _closeDataPtr, lastClosePtr[10]; uint16 depth = 0; @@ -448,11 +411,11 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isintera else test = _closeDataPtr->_graphicName; - if (strcmp(test, TextFileName)) { - monitorPage = 0; - TextFileName = test; + if (strcmp(test, _monitorTextFilename)) { + _monitorPage = 0; + _monitorTextFilename = test; - ntext = _resource->getText(TextFileName); + ntext = _resource->getText(_monitorTextFilename); _graphics->fade(false, 0); drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive); _graphics->fade(true, 0); @@ -480,33 +443,33 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isintera else if ((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & qualifier)) { if ((mouseY >= _utils->vgaScaleY(171)) && (mouseY <= _utils->vgaScaleY(200))) { if ((mouseX >= _utils->vgaScaleX(259)) && (mouseX <= _utils->vgaScaleX(289))) { - if (!lastpage) { - monitorPage += 1; + if (!_lastPage) { + _monitorPage += 1; drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive); } } else if ((mouseX >= _utils->vgaScaleX(0)) && (mouseX <= _utils->vgaScaleX(31))) { return; } else if ((mouseX >= _utils->vgaScaleX(290)) && (mouseX <= _utils->vgaScaleX(320))) { - if (monitorPage >= 1) { - monitorPage -= 1; + if (_monitorPage >= 1) { + _monitorPage -= 1; drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive); } } else if ((mouseX >= _utils->vgaScaleX(31)) && (mouseX <= _utils->vgaScaleX(59))) { if (isinteractive) { - monitorPage = 0; + _monitorPage = 0; if (depth) { depth--; _closeDataPtr = lastClosePtr[depth]; } - } else if (monitorPage > 0) { - monitorPage = 0; + } else if (_monitorPage > 0) { + _monitorPage = 0; drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive); } } } else if (isinteractive) { CloseDataPtr tmpClosePtr = _closeDataPtr; - mouseY = 64 + (mouseY / MonGadHeight) * 42; + mouseY = 64 + (mouseY / _monitorGadgetHeight) * 42; mouseX = 101; setCurrentClose(Common::Point(mouseX, mouseY), &_closeDataPtr, false); @@ -531,7 +494,7 @@ void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive, y1 = _utils->vgaScaleY(y1); y2 = _utils->vgaScaleY(y2); - TextFileName = textfile; + _monitorTextFilename = textfile; _graphics->blackAllScreen(); _graphics->readPict("P:Mon/Monitor.1", true); @@ -540,17 +503,17 @@ void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive, _graphics->readPict("P:Mon/NWD3", true); _graphics->blackAllScreen(); - monitorPage = 0; - lastpage = false; - _graphics->FadePalette = hipal; + _monitorPage = 0; + _lastPage = false; + _graphics->FadePalette = _highPalette; TextFont *monitorFont = _resource->getFont("P:Map.fon"); Common::File *buttonFile = _resource->openDataFile("P:MonImage"); - MonButton = new Image(buttonFile); + _monitorButton = new Image(buttonFile); delete buttonFile; ntext = _resource->getText(textfile); - loadBackPict(background); + _graphics->loadBackPict(background, _highPalette); drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive); _event->mouseShow(); _graphics->fade(true, 0); -- cgit v1.2.3 From ac346869f759475ad00751159a6bad5064f235a2 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 13 Dec 2015 11:59:05 +0100 Subject: LAB: Remove a useless use of g_lab --- engines/lab/special.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 90f20b720a..f043d0ae62 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -185,7 +185,7 @@ void LabEngine::drawJournalText() { _graphics->flowTextToMem(&journalBackImage, _journalFont, -2, 2, 0, false, true, true, true, _utils->vgaScaleX(52), _utils->vgaScaleY(32), _utils->vgaScaleX(152), _utils->vgaScaleY(148), curText); } else { curText = (char *)(_journalText + charsDrawn); - charsDrawn += g_lab->_graphics->flowTextToMem(&journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaScaleX(52), _utils->vgaScaleY(32), _utils->vgaScaleX(152), _utils->vgaScaleY(148), curText); + charsDrawn += _graphics->flowTextToMem(&journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaScaleX(52), _utils->vgaScaleY(32), _utils->vgaScaleX(152), _utils->vgaScaleY(148), curText); } _music->updateMusic(); -- cgit v1.2.3 From 7efd471a92ca6a8d9f7e2c9acdd17be847b7ef73 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 13 Dec 2015 13:34:37 +0100 Subject: LAB: check header define names, rename a parameter of processMonitor() --- engines/lab/special.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index f043d0ae62..5b2da2a3be 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -394,7 +394,7 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16 /** * Processes user input. */ -void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2) { +void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isInteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2) { const char *test = " ", *startFileName = _monitorTextFilename; CloseDataPtr startClosePtr = _closeDataPtr, lastClosePtr[10]; uint16 depth = 0; @@ -402,7 +402,7 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isintera lastClosePtr[0] = _closeDataPtr; while (1) { - if (isinteractive) { + if (isInteractive) { if (_closeDataPtr == NULL) _closeDataPtr = startClosePtr; @@ -417,7 +417,7 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isintera ntext = _resource->getText(_monitorTextFilename); _graphics->fade(false, 0); - drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive); + drawMonText(ntext, monitorFont, x1, y1, x2, y2, isInteractive); _graphics->fade(true, 0); delete[] ntext; } @@ -445,17 +445,17 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isintera if ((mouseX >= _utils->vgaScaleX(259)) && (mouseX <= _utils->vgaScaleX(289))) { if (!_lastPage) { _monitorPage += 1; - drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive); + drawMonText(ntext, monitorFont, x1, y1, x2, y2, isInteractive); } } else if ((mouseX >= _utils->vgaScaleX(0)) && (mouseX <= _utils->vgaScaleX(31))) { return; } else if ((mouseX >= _utils->vgaScaleX(290)) && (mouseX <= _utils->vgaScaleX(320))) { if (_monitorPage >= 1) { _monitorPage -= 1; - drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive); + drawMonText(ntext, monitorFont, x1, y1, x2, y2, isInteractive); } } else if ((mouseX >= _utils->vgaScaleX(31)) && (mouseX <= _utils->vgaScaleX(59))) { - if (isinteractive) { + if (isInteractive) { _monitorPage = 0; if (depth) { @@ -464,10 +464,10 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isintera } } else if (_monitorPage > 0) { _monitorPage = 0; - drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive); + drawMonText(ntext, monitorFont, x1, y1, x2, y2, isInteractive); } } - } else if (isinteractive) { + } else if (isInteractive) { CloseDataPtr tmpClosePtr = _closeDataPtr; mouseY = 64 + (mouseY / _monitorGadgetHeight) * 42; mouseX = 101; -- cgit v1.2.3 From c837e67070913166177a19b2d0d6d925d4569c83 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 13 Dec 2015 14:04:00 +0100 Subject: LAB: Move interface functions to EventMan --- engines/lab/special.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 5b2da2a3be..0024adbc80 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -142,9 +142,9 @@ void LabEngine::loadJournalData() { Common::File *journalFile = _resource->openDataFile("P:JImage"); Utils *utils = _utils; - _journalGadgetList.push_back(createButton( 80, utils->vgaScaleY(162) + utils->svgaCord(1), 0, VKEY_LTARROW, new Image(journalFile), new Image(journalFile))); // back - _journalGadgetList.push_back(createButton(194, utils->vgaScaleY(162) + utils->svgaCord(1), 2, 0, new Image(journalFile), new Image(journalFile))); // cancel - _journalGadgetList.push_back(createButton(144, utils->vgaScaleY(164) - utils->svgaCord(1), 1, VKEY_RTARROW, new Image(journalFile), new Image(journalFile))); // forward + _journalGadgetList.push_back(_event->createButton( 80, utils->vgaScaleY(162) + utils->svgaCord(1), 0, VKEY_LTARROW, new Image(journalFile), new Image(journalFile))); // back + _journalGadgetList.push_back(_event->createButton(194, utils->vgaScaleY(162) + utils->svgaCord(1), 2, 0, new Image(journalFile), new Image(journalFile))); // cancel + _journalGadgetList.push_back(_event->createButton(144, utils->vgaScaleY(164) - utils->svgaCord(1), 1, VKEY_RTARROW, new Image(journalFile), new Image(journalFile))); // forward delete journalFile; _anim->_noPalChange = true; @@ -236,14 +236,14 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) { Gadget *forwardGadget = _event->getGadget(2); if (_journalPage == 0) - disableGadget(backGadget, 15); + _event->disableGadget(backGadget, 15); else - enableGadget(backGadget); + _event->enableGadget(backGadget); if (_lastPage) - disableGadget(forwardGadget, 15); + _event->disableGadget(forwardGadget, 15); else - enableGadget(forwardGadget); + _event->enableGadget(forwardGadget); if (needFade) _graphics->fade(true, 0); @@ -321,7 +321,7 @@ void LabEngine::doJournal() { delete[] _blankJournal; delete[] journalBackImage._imageData; - freeButtonList(&_journalGadgetList); + _event->freeButtonList(&_journalGadgetList); _graphics->closeFont(_journalFont); ScreenImage._imageData = _graphics->getCurrentDrawingBuffer(); -- cgit v1.2.3 From 7c1401264ca0da173dfe4de09ca4884d63feeb55 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 13 Dec 2015 14:12:18 +0100 Subject: LAB: Remove interface.h, get rid of a lot of useless defines --- engines/lab/special.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 0024adbc80..b68963706f 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -34,7 +34,6 @@ #include "lab/dispman.h" #include "lab/eventman.h" #include "lab/image.h" -#include "lab/interface.h" #include "lab/labsets.h" #include "lab/music.h" #include "lab/processroom.h" @@ -271,7 +270,7 @@ void LabEngine::processJournal() { uint16 qualifier = msg->_qualifier; uint16 gadID = msg->_code; - if (((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & qualifier)) || + if (((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RIGHTBUTTON & qualifier)) || ((msgClass == RAWKEY) && (gadID == 27))) return; else if (msgClass == GADGETUP) { @@ -436,7 +435,7 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isIntera uint16 mouseY = msg->_mouseY; uint16 code = msg->_code; - if (((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & qualifier)) || + if (((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RIGHTBUTTON & qualifier)) || ((msgClass == RAWKEY) && (code == 27))) return; -- cgit v1.2.3 From 577b60d7853156851894430ad8032ed14b353e33 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sun, 13 Dec 2015 15:37:39 +0200 Subject: LAB: Move getMsg to the event manager --- engines/lab/special.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index b68963706f..1fc5c67efd 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -261,7 +261,7 @@ void LabEngine::processJournal() { while (1) { // Make sure we check the music at least after every message _music->updateMusic(); - IntuiMessage *msg = getMsg(); + IntuiMessage *msg = _event->getMsg(); if (msg == NULL) { _music->updateMusic(); @@ -424,7 +424,7 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isIntera // Make sure we check the music at least after every message _music->updateMusic(); - IntuiMessage *msg = getMsg(); + IntuiMessage *msg = _event->getMsg(); if (msg == NULL) { _music->updateMusic(); -- cgit v1.2.3 From 2332fb617c0c26da563cb60625b24d824ad4630b Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sun, 13 Dec 2015 19:36:56 +0200 Subject: LAB: Rename gadget to button --- engines/lab/special.cpp | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 1fc5c67efd..0f5e00b3e2 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -141,9 +141,9 @@ void LabEngine::loadJournalData() { Common::File *journalFile = _resource->openDataFile("P:JImage"); Utils *utils = _utils; - _journalGadgetList.push_back(_event->createButton( 80, utils->vgaScaleY(162) + utils->svgaCord(1), 0, VKEY_LTARROW, new Image(journalFile), new Image(journalFile))); // back - _journalGadgetList.push_back(_event->createButton(194, utils->vgaScaleY(162) + utils->svgaCord(1), 2, 0, new Image(journalFile), new Image(journalFile))); // cancel - _journalGadgetList.push_back(_event->createButton(144, utils->vgaScaleY(164) - utils->svgaCord(1), 1, VKEY_RTARROW, new Image(journalFile), new Image(journalFile))); // forward + _journalButtonList.push_back(_event->createButton( 80, utils->vgaScaleY(162) + utils->svgaCord(1), 0, VKEY_LTARROW, new Image(journalFile), new Image(journalFile))); // back + _journalButtonList.push_back(_event->createButton(194, utils->vgaScaleY(162) + utils->svgaCord(1), 2, 0, new Image(journalFile), new Image(journalFile))); // cancel + _journalButtonList.push_back(_event->createButton(144, utils->vgaScaleY(164) - utils->svgaCord(1), 1, VKEY_RTARROW, new Image(journalFile), new Image(journalFile))); // forward delete journalFile; _anim->_noPalChange = true; @@ -231,18 +231,18 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) { else turnPage((bool)(wipenum == 1)); - Gadget *backGadget = _event->getGadget(0); - Gadget *forwardGadget = _event->getGadget(2); + Button *backButton = _event->getButton(0); + Button *forwardButton = _event->getButton(2); if (_journalPage == 0) - _event->disableGadget(backGadget, 15); + _event->disableButton(backButton, 15); else - _event->enableGadget(backGadget); + _event->enableButton(backButton); if (_lastPage) - _event->disableGadget(forwardGadget, 15); + _event->disableButton(forwardButton, 15); else - _event->enableGadget(forwardGadget); + _event->enableButton(forwardButton); if (needFade) _graphics->fade(true, 0); @@ -273,7 +273,7 @@ void LabEngine::processJournal() { if (((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RIGHTBUTTON & qualifier)) || ((msgClass == RAWKEY) && (gadID == 27))) return; - else if (msgClass == GADGETUP) { + else if (msgClass == BUTTONUP) { if (gadID == 0) { if (_journalPage >= 2) { _journalPage -= 2; @@ -310,17 +310,17 @@ void LabEngine::doJournal() { _music->updateMusic(); loadJournalData(); - _event->attachGadgetList(&_journalGadgetList); + _event->attachButtonList(&_journalButtonList); drawJournal(0, true); _event->mouseShow(); processJournal(); - _event->attachGadgetList(NULL); + _event->attachButtonList(NULL); _graphics->fade(false, 0); _event->mouseHide(); delete[] _blankJournal; delete[] journalBackImage._imageData; - _event->freeButtonList(&_journalGadgetList); + _event->freeButtonList(&_journalButtonList); _graphics->closeFont(_journalFont); ScreenImage._imageData = _graphics->getCurrentDrawingBuffer(); @@ -349,18 +349,18 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16 fheight = _graphics->textHeight(monitorFont); x1 = _monitorButton->_width + _utils->vgaScaleX(3); - _monitorGadgetHeight = _monitorButton->_height + _utils->vgaScaleY(3); + _monitorButtonHeight = _monitorButton->_height + _utils->vgaScaleY(3); - if (_monitorGadgetHeight > fheight) - yspacing = _monitorGadgetHeight - fheight; + if (_monitorButtonHeight > fheight) + yspacing = _monitorButtonHeight - fheight; else - _monitorGadgetHeight = fheight; + _monitorButtonHeight = fheight; _graphics->setAPen(0); _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, y2); for (uint16 i = 0; i < numlines; i++) - _monitorButton->drawImage(0, i * _monitorGadgetHeight); + _monitorButton->drawImage(0, i * _monitorButtonHeight); } else if (isinteractive) { _graphics->setAPen(0); _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, y2); @@ -468,7 +468,7 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isIntera } } else if (isInteractive) { CloseDataPtr tmpClosePtr = _closeDataPtr; - mouseY = 64 + (mouseY / _monitorGadgetHeight) * 42; + mouseY = 64 + (mouseY / _monitorButtonHeight) * 42; mouseX = 101; setCurrentClose(Common::Point(mouseX, mouseY), &_closeDataPtr, false); -- cgit v1.2.3 From ad54a75b853ada2c4ae4b99368ac3038dcd92d33 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 13 Dec 2015 22:51:23 +0100 Subject: LAB: Add _vm to Image class --- engines/lab/special.cpp | 53 ++++++++++++++++++++++--------------------------- 1 file changed, 24 insertions(+), 29 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 0f5e00b3e2..a629fd94ab 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -106,7 +106,6 @@ void LabEngine::doWestPaper() { */ void LabEngine::loadJournalData() { _journalFont = _resource->getFont("P:Journal.fon"); - _music->updateMusic(); char filename[20]; @@ -141,21 +140,21 @@ void LabEngine::loadJournalData() { Common::File *journalFile = _resource->openDataFile("P:JImage"); Utils *utils = _utils; - _journalButtonList.push_back(_event->createButton( 80, utils->vgaScaleY(162) + utils->svgaCord(1), 0, VKEY_LTARROW, new Image(journalFile), new Image(journalFile))); // back - _journalButtonList.push_back(_event->createButton(194, utils->vgaScaleY(162) + utils->svgaCord(1), 2, 0, new Image(journalFile), new Image(journalFile))); // cancel - _journalButtonList.push_back(_event->createButton(144, utils->vgaScaleY(164) - utils->svgaCord(1), 1, VKEY_RTARROW, new Image(journalFile), new Image(journalFile))); // forward + _journalButtonList.push_back(_event->createButton( 80, utils->vgaScaleY(162) + utils->svgaCord(1), 0, VKEY_LTARROW, new Image(journalFile, this), new Image(journalFile, this))); // back + _journalButtonList.push_back(_event->createButton(194, utils->vgaScaleY(162) + utils->svgaCord(1), 2, 0, new Image(journalFile, this), new Image(journalFile, this))); // cancel + _journalButtonList.push_back(_event->createButton(144, utils->vgaScaleY(164) - utils->svgaCord(1), 1, VKEY_RTARROW, new Image(journalFile, this), new Image(journalFile, this))); // forward delete journalFile; _anim->_noPalChange = true; - journalBackImage._imageData = new byte[_graphics->_screenWidth * _graphics->_screenHeight]; - _graphics->readPict("P:Journal.pic", true, false, journalBackImage._imageData); + journalBackImage->_imageData = new byte[_graphics->_screenWidth * _graphics->_screenHeight]; + _graphics->readPict("P:Journal.pic", true, false, journalBackImage->_imageData); _anim->_noPalChange = false; // Keep a copy of the blank journal _blankJournal = new byte[_graphics->_screenWidth * _graphics->_screenHeight]; - memcpy(_blankJournal, journalBackImage._imageData, _graphics->_screenWidth * _graphics->_screenHeight); + memcpy(_blankJournal, journalBackImage->_imageData, _graphics->_screenWidth * _graphics->_screenHeight); - ScreenImage._imageData = _graphics->getCurrentDrawingBuffer(); + ScreenImage->_imageData = _graphics->getCurrentDrawingBuffer(); } /** @@ -181,16 +180,16 @@ void LabEngine::drawJournalText() { if (_journalPage <= 1) { curText = _journalTextTitle; - _graphics->flowTextToMem(&journalBackImage, _journalFont, -2, 2, 0, false, true, true, true, _utils->vgaScaleX(52), _utils->vgaScaleY(32), _utils->vgaScaleX(152), _utils->vgaScaleY(148), curText); + _graphics->flowTextToMem(journalBackImage, _journalFont, -2, 2, 0, false, true, true, true, _utils->vgaScaleX(52), _utils->vgaScaleY(32), _utils->vgaScaleX(152), _utils->vgaScaleY(148), curText); } else { curText = (char *)(_journalText + charsDrawn); - charsDrawn += _graphics->flowTextToMem(&journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaScaleX(52), _utils->vgaScaleY(32), _utils->vgaScaleX(152), _utils->vgaScaleY(148), curText); + charsDrawn += _graphics->flowTextToMem(journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaScaleX(52), _utils->vgaScaleY(32), _utils->vgaScaleX(152), _utils->vgaScaleY(148), curText); } _music->updateMusic(); curText = (char *)(_journalText + charsDrawn); _lastPage = (*curText == 0); - _graphics->flowTextToMem(&journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaScaleX(171), _utils->vgaScaleY(32), _utils->vgaScaleX(271), _utils->vgaScaleY(148), curText); + _graphics->flowTextToMem(journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaScaleX(171), _utils->vgaScaleY(32), _utils->vgaScaleX(271), _utils->vgaScaleY(148), curText); curText = (char *)(_journalText + charsDrawn); _lastPage = _lastPage || (*curText == 0); @@ -204,15 +203,15 @@ void LabEngine::turnPage(bool fromLeft) { for (int i = 0; i < _graphics->_screenWidth; i += 8) { _music->updateMusic(); waitTOF(); - ScreenImage._imageData = _graphics->getCurrentDrawingBuffer(); - journalBackImage.blitBitmap(i, 0, &ScreenImage, i, 0, 8, _graphics->_screenHeight, false); + ScreenImage->_imageData = _graphics->getCurrentDrawingBuffer(); + journalBackImage->blitBitmap(i, 0, ScreenImage, i, 0, 8, _graphics->_screenHeight, false); } } else { for (int i = (_graphics->_screenWidth - 8); i > 0; i -= 8) { _music->updateMusic(); waitTOF(); - ScreenImage._imageData = _graphics->getCurrentDrawingBuffer(); - journalBackImage.blitBitmap(i, 0, &ScreenImage, i, 0, 8, _graphics->_screenHeight, false); + ScreenImage->_imageData = _graphics->getCurrentDrawingBuffer(); + journalBackImage->blitBitmap(i, 0, ScreenImage, i, 0, 8, _graphics->_screenHeight, false); } } } @@ -227,7 +226,7 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) { _graphics->loadBackPict("P:Journal.pic", _highPalette); if (wipenum == 0) - journalBackImage.blitBitmap(0, 0, &ScreenImage, 0, 0, _graphics->_screenWidth, _graphics->_screenHeight, false); + journalBackImage->blitBitmap(0, 0, ScreenImage, 0, 0, _graphics->_screenWidth, _graphics->_screenHeight, false); else turnPage((bool)(wipenum == 1)); @@ -248,7 +247,7 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) { _graphics->fade(true, 0); // Reset the journal background, so that all the text that has been blitted on it is erased - memcpy(journalBackImage._imageData, _blankJournal, _graphics->_screenWidth * _graphics->_screenHeight); + memcpy(journalBackImage->_imageData, _blankJournal, _graphics->_screenWidth * _graphics->_screenHeight); eatMessages(); _event->mouseShow(); @@ -297,19 +296,15 @@ void LabEngine::processJournal() { */ void LabEngine::doJournal() { _graphics->blackAllScreen(); + _lastPage = false; - _lastPage = false; - - journalBackImage._width = _graphics->_screenWidth; - journalBackImage._height = _graphics->_screenHeight; - journalBackImage._imageData = NULL; - - ScreenImage = journalBackImage; - ScreenImage._imageData = _graphics->getCurrentDrawingBuffer(); + ScreenImage->_width = journalBackImage->_width = _graphics->_screenWidth; + ScreenImage->_height = journalBackImage->_height = _graphics->_screenHeight; + journalBackImage->_imageData = nullptr; + ScreenImage->_imageData = _graphics->getCurrentDrawingBuffer(); _music->updateMusic(); loadJournalData(); - _event->attachButtonList(&_journalButtonList); drawJournal(0, true); _event->mouseShow(); @@ -319,11 +314,11 @@ void LabEngine::doJournal() { _event->mouseHide(); delete[] _blankJournal; - delete[] journalBackImage._imageData; + delete[] journalBackImage->_imageData; _event->freeButtonList(&_journalButtonList); _graphics->closeFont(_journalFont); - ScreenImage._imageData = _graphics->getCurrentDrawingBuffer(); + ScreenImage->_imageData = _graphics->getCurrentDrawingBuffer(); _graphics->setAPen(0); _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1); @@ -508,7 +503,7 @@ void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive, TextFont *monitorFont = _resource->getFont("P:Map.fon"); Common::File *buttonFile = _resource->openDataFile("P:MonImage"); - _monitorButton = new Image(buttonFile); + _monitorButton = new Image(buttonFile, this); delete buttonFile; ntext = _resource->getText(textfile); -- cgit v1.2.3 From 974740d3076984535f941afb18e0adfa7132aab7 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 13 Dec 2015 22:55:10 +0100 Subject: LAB: Some renaming in LabEngine --- engines/lab/special.cpp | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index a629fd94ab..5bb9b17be3 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -146,15 +146,15 @@ void LabEngine::loadJournalData() { delete journalFile; _anim->_noPalChange = true; - journalBackImage->_imageData = new byte[_graphics->_screenWidth * _graphics->_screenHeight]; - _graphics->readPict("P:Journal.pic", true, false, journalBackImage->_imageData); + _journalBackImage->_imageData = new byte[_graphics->_screenWidth * _graphics->_screenHeight]; + _graphics->readPict("P:Journal.pic", true, false, _journalBackImage->_imageData); _anim->_noPalChange = false; // Keep a copy of the blank journal _blankJournal = new byte[_graphics->_screenWidth * _graphics->_screenHeight]; - memcpy(_blankJournal, journalBackImage->_imageData, _graphics->_screenWidth * _graphics->_screenHeight); + memcpy(_blankJournal, _journalBackImage->_imageData, _graphics->_screenWidth * _graphics->_screenHeight); - ScreenImage->_imageData = _graphics->getCurrentDrawingBuffer(); + _screenImage->_imageData = _graphics->getCurrentDrawingBuffer(); } /** @@ -180,16 +180,16 @@ void LabEngine::drawJournalText() { if (_journalPage <= 1) { curText = _journalTextTitle; - _graphics->flowTextToMem(journalBackImage, _journalFont, -2, 2, 0, false, true, true, true, _utils->vgaScaleX(52), _utils->vgaScaleY(32), _utils->vgaScaleX(152), _utils->vgaScaleY(148), curText); + _graphics->flowTextToMem(_journalBackImage, _journalFont, -2, 2, 0, false, true, true, true, _utils->vgaScaleX(52), _utils->vgaScaleY(32), _utils->vgaScaleX(152), _utils->vgaScaleY(148), curText); } else { curText = (char *)(_journalText + charsDrawn); - charsDrawn += _graphics->flowTextToMem(journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaScaleX(52), _utils->vgaScaleY(32), _utils->vgaScaleX(152), _utils->vgaScaleY(148), curText); + charsDrawn += _graphics->flowTextToMem(_journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaScaleX(52), _utils->vgaScaleY(32), _utils->vgaScaleX(152), _utils->vgaScaleY(148), curText); } _music->updateMusic(); curText = (char *)(_journalText + charsDrawn); _lastPage = (*curText == 0); - _graphics->flowTextToMem(journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaScaleX(171), _utils->vgaScaleY(32), _utils->vgaScaleX(271), _utils->vgaScaleY(148), curText); + _graphics->flowTextToMem(_journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaScaleX(171), _utils->vgaScaleY(32), _utils->vgaScaleX(271), _utils->vgaScaleY(148), curText); curText = (char *)(_journalText + charsDrawn); _lastPage = _lastPage || (*curText == 0); @@ -203,15 +203,15 @@ void LabEngine::turnPage(bool fromLeft) { for (int i = 0; i < _graphics->_screenWidth; i += 8) { _music->updateMusic(); waitTOF(); - ScreenImage->_imageData = _graphics->getCurrentDrawingBuffer(); - journalBackImage->blitBitmap(i, 0, ScreenImage, i, 0, 8, _graphics->_screenHeight, false); + _screenImage->_imageData = _graphics->getCurrentDrawingBuffer(); + _journalBackImage->blitBitmap(i, 0, _screenImage, i, 0, 8, _graphics->_screenHeight, false); } } else { for (int i = (_graphics->_screenWidth - 8); i > 0; i -= 8) { _music->updateMusic(); waitTOF(); - ScreenImage->_imageData = _graphics->getCurrentDrawingBuffer(); - journalBackImage->blitBitmap(i, 0, ScreenImage, i, 0, 8, _graphics->_screenHeight, false); + _screenImage->_imageData = _graphics->getCurrentDrawingBuffer(); + _journalBackImage->blitBitmap(i, 0, _screenImage, i, 0, 8, _graphics->_screenHeight, false); } } } @@ -226,7 +226,7 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) { _graphics->loadBackPict("P:Journal.pic", _highPalette); if (wipenum == 0) - journalBackImage->blitBitmap(0, 0, ScreenImage, 0, 0, _graphics->_screenWidth, _graphics->_screenHeight, false); + _journalBackImage->blitBitmap(0, 0, _screenImage, 0, 0, _graphics->_screenWidth, _graphics->_screenHeight, false); else turnPage((bool)(wipenum == 1)); @@ -247,7 +247,7 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) { _graphics->fade(true, 0); // Reset the journal background, so that all the text that has been blitted on it is erased - memcpy(journalBackImage->_imageData, _blankJournal, _graphics->_screenWidth * _graphics->_screenHeight); + memcpy(_journalBackImage->_imageData, _blankJournal, _graphics->_screenWidth * _graphics->_screenHeight); eatMessages(); _event->mouseShow(); @@ -298,10 +298,10 @@ void LabEngine::doJournal() { _graphics->blackAllScreen(); _lastPage = false; - ScreenImage->_width = journalBackImage->_width = _graphics->_screenWidth; - ScreenImage->_height = journalBackImage->_height = _graphics->_screenHeight; - journalBackImage->_imageData = nullptr; - ScreenImage->_imageData = _graphics->getCurrentDrawingBuffer(); + _screenImage->_width = _journalBackImage->_width = _graphics->_screenWidth; + _screenImage->_height = _journalBackImage->_height = _graphics->_screenHeight; + _journalBackImage->_imageData = nullptr; + _screenImage->_imageData = _graphics->getCurrentDrawingBuffer(); _music->updateMusic(); loadJournalData(); @@ -314,11 +314,11 @@ void LabEngine::doJournal() { _event->mouseHide(); delete[] _blankJournal; - delete[] journalBackImage->_imageData; + delete[] _journalBackImage->_imageData; _event->freeButtonList(&_journalButtonList); _graphics->closeFont(_journalFont); - ScreenImage->_imageData = _graphics->getCurrentDrawingBuffer(); + _screenImage->_imageData = _graphics->getCurrentDrawingBuffer(); _graphics->setAPen(0); _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1); -- cgit v1.2.3 From aa718e4c842722e76d035d7ed63e5e08ff6b67cf Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Mon, 14 Dec 2015 08:59:16 +0100 Subject: LAB: Variable rename --- engines/lab/special.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 5bb9b17be3..65a4a9d566 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -499,7 +499,7 @@ void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive, _monitorPage = 0; _lastPage = false; - _graphics->FadePalette = _highPalette; + _graphics->_fadePalette = _highPalette; TextFont *monitorFont = _resource->getFont("P:Map.fon"); Common::File *buttonFile = _resource->openDataFile("P:MonImage"); -- cgit v1.2.3 From 167d9c48a3d72c923616f18759b1ab7860e59a7d Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Mon, 14 Dec 2015 14:20:22 +0100 Subject: LAB: Reduced scope of a few more variables --- engines/lab/special.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 65a4a9d566..6fc8636037 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -228,7 +228,7 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) { if (wipenum == 0) _journalBackImage->blitBitmap(0, 0, _screenImage, 0, 0, _graphics->_screenWidth, _graphics->_screenHeight, false); else - turnPage((bool)(wipenum == 1)); + turnPage((wipenum == 1)); Button *backButton = _event->getButton(0); Button *forwardButton = _event->getButton(2); @@ -329,7 +329,7 @@ void LabEngine::doJournal() { * Draws the text for the monitor. */ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16 y1, uint16 x2, uint16 y2, bool isinteractive) { - uint16 drawingToPage = 0, yspacing = 0, numlines, fheight; + uint16 drawingToPage = 0, yspacing = 0; int32 charsDrawn = 0L; char *curText = text; @@ -337,12 +337,12 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16 if (*text == '%') { text++; - numlines = (*text - '0') * 10; + uint16 numlines = (*text - '0') * 10; text++; numlines += (*text - '0'); text += 2; - fheight = _graphics->textHeight(monitorFont); + uint16 fheight = _graphics->textHeight(monitorFont); x1 = _monitorButton->_width + _utils->vgaScaleX(3); _monitorButtonHeight = _monitorButton->_height + _utils->vgaScaleY(3); @@ -389,7 +389,7 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16 * Processes user input. */ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isInteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2) { - const char *test = " ", *startFileName = _monitorTextFilename; + const char *startFileName = _monitorTextFilename; CloseDataPtr startClosePtr = _closeDataPtr, lastClosePtr[10]; uint16 depth = 0; @@ -400,6 +400,7 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isIntera if (_closeDataPtr == NULL) _closeDataPtr = startClosePtr; + const char *test; if (_closeDataPtr == startClosePtr) test = startFileName; else @@ -433,7 +434,6 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isIntera if (((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RIGHTBUTTON & qualifier)) || ((msgClass == RAWKEY) && (code == 27))) return; - else if ((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & qualifier)) { if ((mouseY >= _utils->vgaScaleY(171)) && (mouseY <= _utils->vgaScaleY(200))) { if ((mouseX >= _utils->vgaScaleX(259)) && (mouseX <= _utils->vgaScaleX(289))) { @@ -481,8 +481,6 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isIntera * Does what's necessary for the monitor. */ void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2) { - char *ntext; - x1 = _utils->vgaScaleX(x1); x2 = _utils->vgaScaleX(x2); y1 = _utils->vgaScaleY(y1); @@ -506,7 +504,7 @@ void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive, _monitorButton = new Image(buttonFile, this); delete buttonFile; - ntext = _resource->getText(textfile); + char *ntext = _resource->getText(textfile); _graphics->loadBackPict(background, _highPalette); drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive); _event->mouseShow(); -- cgit v1.2.3 From e0de03463e0c8145bd7700cd2f4955dfc0676967 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 14 Dec 2015 21:44:06 +0100 Subject: LAB: Use strlen to compute text length instead of a difference between start and end address. Some refactoring. --- engines/lab/special.cpp | 43 +++++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 22 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 6fc8636037..c2c52b2c4f 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -52,13 +52,12 @@ namespace Lab { */ void LabEngine::doNotes() { TextFont *noteFont = _resource->getFont("P:Note.fon"); - char *ntext = _resource->getText("Lab:Rooms/Notes"); + char *noteText = _resource->getText("Lab:Rooms/Notes"); - _graphics->flowText(noteFont, -2 + _utils->svgaCord(1), 0, 0, false, false, true, true, _utils->vgaScaleX(25) + _utils->svgaCord(15), _utils->vgaScaleY(50), _utils->vgaScaleX(295) - _utils->svgaCord(15), _utils->vgaScaleY(148), ntext); + _graphics->flowText(noteFont, -2 + _utils->svgaCord(1), 0, 0, false, false, true, true, _utils->vgaScaleX(25) + _utils->svgaCord(15), _utils->vgaScaleY(50), _utils->vgaScaleX(295) - _utils->svgaCord(15), _utils->vgaScaleY(148), noteText); _graphics->setPalette(_anim->_diffPalette, 256); - _graphics->closeFont(noteFont); - delete[] ntext; + delete[] noteText; } /** @@ -67,35 +66,35 @@ void LabEngine::doNotes() { */ void LabEngine::doWestPaper() { TextFont *paperFont = _resource->getFont("P:News22.fon"); - char *ntext = _resource->getText("Lab:Rooms/Date"); - _graphics->flowText(paperFont, 0, 0, 0, false, true, false, true, _utils->vgaScaleX(57), _utils->vgaScaleY(77) + _utils->svgaCord(2), _utils->vgaScaleX(262), _utils->vgaScaleY(91), ntext); + char *paperText = _resource->getText("Lab:Rooms/Date"); + _graphics->flowText(paperFont, 0, 0, 0, false, true, false, true, _utils->vgaScaleX(57), _utils->vgaScaleY(77) + _utils->svgaCord(2), _utils->vgaScaleX(262), _utils->vgaScaleY(91), paperText); _graphics->closeFont(paperFont); - delete[] ntext; + delete[] paperText; paperFont = _resource->getFont("P:News32.fon"); - ntext = _resource->getText("Lab:Rooms/Headline"); + paperText = _resource->getText("Lab:Rooms/Headline"); - int fileLen = strlen(ntext) - 1; - int charsPrinted = _graphics->flowText(paperFont, -8, 0, 0, false, true, false, true, _utils->vgaScaleX(57), _utils->vgaScaleY(86) - _utils->svgaCord(2), _utils->vgaScaleX(262), _utils->vgaScaleY(118), ntext); + int fileLen = strlen(paperText) - 1; + int charsPrinted = _graphics->flowText(paperFont, -8, 0, 0, false, true, false, true, _utils->vgaScaleX(57), _utils->vgaScaleY(86) - _utils->svgaCord(2), _utils->vgaScaleX(262), _utils->vgaScaleY(118), paperText); uint16 y; if (charsPrinted < fileLen) { y = 130 - _utils->svgaCord(5); - _graphics->flowText(paperFont, -8 - _utils->svgaCord(1), 0, 0, false, true, false, true, _utils->vgaScaleX(57), _utils->vgaScaleY(86) - _utils->svgaCord(2), _utils->vgaScaleX(262), _utils->vgaScaleY(132), ntext); + _graphics->flowText(paperFont, -8 - _utils->svgaCord(1), 0, 0, false, true, false, true, _utils->vgaScaleX(57), _utils->vgaScaleY(86) - _utils->svgaCord(2), _utils->vgaScaleX(262), _utils->vgaScaleY(132), paperText); } else y = 115 - _utils->svgaCord(5); _graphics->closeFont(paperFont); - delete[] ntext; + delete[] paperText; paperFont = _resource->getFont("P:Note.fon"); - ntext = _resource->getText("Lab:Rooms/Col1"); - charsPrinted = _graphics->flowTextScaled(paperFont, -4, 0, 0, false, false, false, true, 45, y, 158, 148, ntext); - delete[] ntext; - ntext = _resource->getText("Lab:Rooms/Col2"); - charsPrinted = _graphics->flowTextScaled(paperFont, -4, 0, 0, false, false, false, true, 162, y, 275, 148, ntext); - delete[] ntext; + paperText = _resource->getText("Lab:Rooms/Col1"); + charsPrinted = _graphics->flowTextScaled(paperFont, -4, 0, 0, false, false, false, true, 45, y, 158, 148, paperText); + delete[] paperText; + paperText = _resource->getText("Lab:Rooms/Col2"); + charsPrinted = _graphics->flowTextScaled(paperFont, -4, 0, 0, false, false, false, true, 162, y, 275, 148, paperText); + delete[] paperText; _graphics->closeFont(paperFont); _graphics->setPalette(_anim->_diffPalette, 256); @@ -162,7 +161,7 @@ void LabEngine::loadJournalData() { */ void LabEngine::drawJournalText() { uint16 drawingToPage = 1; - int32 charsDrawn = 0; + int charsDrawn = 0; char *curText = _journalText; while (drawingToPage < _journalPage) { @@ -192,7 +191,7 @@ void LabEngine::drawJournalText() { _graphics->flowTextToMem(_journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaScaleX(171), _utils->vgaScaleY(32), _utils->vgaScaleX(271), _utils->vgaScaleY(148), curText); curText = (char *)(_journalText + charsDrawn); - _lastPage = _lastPage || (*curText == 0); + _lastPage |= (*curText == 0); } /** @@ -330,7 +329,7 @@ void LabEngine::doJournal() { */ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16 y1, uint16 x2, uint16 y2, bool isinteractive) { uint16 drawingToPage = 0, yspacing = 0; - int32 charsDrawn = 0L; + int charsDrawn = 0; char *curText = text; _event->mouseHide(); @@ -380,7 +379,7 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16 _lastPage = (*curText == 0); charsDrawn = _graphics->flowText(monitorFont, yspacing, 2, 0, false, false, false, true, x1, y1, x2, y2, curText); curText += charsDrawn; - _lastPage = _lastPage || (*curText == 0); + _lastPage |= (*curText == 0); _event->mouseShow(); } -- cgit v1.2.3 From 69294eccb0636439157b60ee4b85bf3b985acb63 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 14 Dec 2015 22:50:09 +0100 Subject: LAB: Some renaming in DisplayMan --- engines/lab/special.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index c2c52b2c4f..3cad962c29 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -319,7 +319,7 @@ void LabEngine::doJournal() { _screenImage->_imageData = _graphics->getCurrentDrawingBuffer(); - _graphics->setAPen(0); + _graphics->setPen(0); _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1); _graphics->blackScreen(); } @@ -350,16 +350,16 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16 else _monitorButtonHeight = fheight; - _graphics->setAPen(0); + _graphics->setPen(0); _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, y2); for (uint16 i = 0; i < numlines; i++) _monitorButton->drawImage(0, i * _monitorButtonHeight); } else if (isinteractive) { - _graphics->setAPen(0); + _graphics->setPen(0); _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, y2); } else { - _graphics->setAPen(0); + _graphics->setPen(0); _graphics->rectFill(x1, y1, x2, y2); } @@ -514,7 +514,7 @@ void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive, delete[] ntext; _graphics->closeFont(monitorFont); - _graphics->setAPen(0); + _graphics->setPen(0); _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1); _graphics->blackAllScreen(); _graphics->freePict(); -- cgit v1.2.3 From e71f28d0ba319bca35056b7e88d8ebfe0ea92017 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 15 Dec 2015 16:18:32 +0100 Subject: LAB: Reorder mouse position check in processMonitor in order to avoid duplicate checks --- engines/lab/special.cpp | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 3cad962c29..38921ea650 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -435,19 +435,9 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isIntera return; else if ((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & qualifier)) { if ((mouseY >= _utils->vgaScaleY(171)) && (mouseY <= _utils->vgaScaleY(200))) { - if ((mouseX >= _utils->vgaScaleX(259)) && (mouseX <= _utils->vgaScaleX(289))) { - if (!_lastPage) { - _monitorPage += 1; - drawMonText(ntext, monitorFont, x1, y1, x2, y2, isInteractive); - } - } else if ((mouseX >= _utils->vgaScaleX(0)) && (mouseX <= _utils->vgaScaleX(31))) { + if (mouseX <= _utils->vgaScaleX(31)) { return; - } else if ((mouseX >= _utils->vgaScaleX(290)) && (mouseX <= _utils->vgaScaleX(320))) { - if (_monitorPage >= 1) { - _monitorPage -= 1; - drawMonText(ntext, monitorFont, x1, y1, x2, y2, isInteractive); - } - } else if ((mouseX >= _utils->vgaScaleX(31)) && (mouseX <= _utils->vgaScaleX(59))) { + } else if (mouseX <= _utils->vgaScaleX(59)) { if (isInteractive) { _monitorPage = 0; @@ -459,6 +449,17 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isIntera _monitorPage = 0; drawMonText(ntext, monitorFont, x1, y1, x2, y2, isInteractive); } + } else if (mouseX < _utils->vgaScaleX(259)) { + return; + } else if (mouseX <= _utils->vgaScaleX(289)) { + if (!_lastPage) { + _monitorPage += 1; + drawMonText(ntext, monitorFont, x1, y1, x2, y2, isInteractive); + } + } else if (_monitorPage >= 1) { + // mouseX between 290 and 320 (scaled) + _monitorPage -= 1; + drawMonText(ntext, monitorFont, x1, y1, x2, y2, isInteractive); } } else if (isInteractive) { CloseDataPtr tmpClosePtr = _closeDataPtr; -- cgit v1.2.3 From eab6682929d47d09c0ac81921f479e46a06e93bd Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 16 Dec 2015 00:07:31 +0100 Subject: LAB: Add some checks to quit the game quickly when closing ScummVM --- engines/lab/special.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 38921ea650..02bbdf4c07 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -260,10 +260,14 @@ void LabEngine::processJournal() { // Make sure we check the music at least after every message _music->updateMusic(); IntuiMessage *msg = _event->getMsg(); + if (g_engine->shouldQuit()) { + _quitLab = true; + return; + } - if (msg == NULL) { + if (!msg) _music->updateMusic(); - } else { + else { uint32 msgClass = msg->_msgClass; uint16 qualifier = msg->_qualifier; uint16 gadID = msg->_code; @@ -420,8 +424,12 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isIntera // Make sure we check the music at least after every message _music->updateMusic(); IntuiMessage *msg = _event->getMsg(); + if (g_engine->shouldQuit()) { + _quitLab = true; + return; + } - if (msg == NULL) { + if (!msg) { _music->updateMusic(); } else { uint32 msgClass = msg->_msgClass; -- cgit v1.2.3 From 83126e84eefc2493732bb2a158c6c41cae15ece4 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 16 Dec 2015 16:11:06 +0100 Subject: LAB: Make the use of nullptr consistent through the engine --- engines/lab/special.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 02bbdf4c07..1008314d4c 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -312,7 +312,7 @@ void LabEngine::doJournal() { drawJournal(0, true); _event->mouseShow(); processJournal(); - _event->attachButtonList(NULL); + _event->attachButtonList(nullptr); _graphics->fade(false, 0); _event->mouseHide(); @@ -400,7 +400,7 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isIntera while (1) { if (isInteractive) { - if (_closeDataPtr == NULL) + if (!_closeDataPtr) _closeDataPtr = startClosePtr; const char *test; @@ -410,7 +410,7 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isIntera test = _closeDataPtr->_graphicName; if (strcmp(test, _monitorTextFilename)) { - _monitorPage = 0; + _monitorPage = 0; _monitorTextFilename = test; ntext = _resource->getText(_monitorTextFilename); -- cgit v1.2.3 From 005e077551fd3d324b99a37a27a37646864b2188 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 16 Dec 2015 23:27:32 +0200 Subject: LAB: Some renames --- engines/lab/special.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 1008314d4c..d61ddcb26e 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -270,20 +270,20 @@ void LabEngine::processJournal() { else { uint32 msgClass = msg->_msgClass; uint16 qualifier = msg->_qualifier; - uint16 gadID = msg->_code; + uint16 buttonId = msg->_code; if (((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RIGHTBUTTON & qualifier)) || - ((msgClass == RAWKEY) && (gadID == 27))) + ((msgClass == RAWKEY) && (buttonId == 27))) return; else if (msgClass == BUTTONUP) { - if (gadID == 0) { + if (buttonId == 0) { if (_journalPage >= 2) { _journalPage -= 2; drawJournal(1, false); } - } else if (gadID == 1) { + } else if (buttonId == 1) { return; - } else if (gadID == 2) { + } else if (buttonId == 2) { if (!_lastPage) { _journalPage += 2; drawJournal(2, false); -- cgit v1.2.3 From 605c2e553bd9b8421af643491a7855d8c2cd4710 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 17 Dec 2015 00:36:02 +0200 Subject: LAB: Use common keycodes instead of direct keycode values --- engines/lab/special.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index d61ddcb26e..2f071dab35 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -273,7 +273,7 @@ void LabEngine::processJournal() { uint16 buttonId = msg->_code; if (((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RIGHTBUTTON & qualifier)) || - ((msgClass == RAWKEY) && (buttonId == 27))) + ((msgClass == RAWKEY) && (buttonId == Common::KEYCODE_ESCAPE))) return; else if (msgClass == BUTTONUP) { if (buttonId == 0) { @@ -439,7 +439,7 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isIntera uint16 code = msg->_code; if (((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RIGHTBUTTON & qualifier)) || - ((msgClass == RAWKEY) && (code == 27))) + ((msgClass == RAWKEY) && (code == Common::KEYCODE_ESCAPE))) return; else if ((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & qualifier)) { if ((mouseY >= _utils->vgaScaleY(171)) && (mouseY <= _utils->vgaScaleY(200))) { -- cgit v1.2.3 From 054a7a1e19ffb3d5f5d298c0af3e0e33435d5ed7 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 17 Dec 2015 18:35:53 +0100 Subject: LAB: Use Common::Rect in functions related to flowText (WIP) --- engines/lab/special.cpp | 61 +++++++++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 30 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 2f071dab35..c8cc616d30 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -54,7 +54,8 @@ void LabEngine::doNotes() { TextFont *noteFont = _resource->getFont("P:Note.fon"); char *noteText = _resource->getText("Lab:Rooms/Notes"); - _graphics->flowText(noteFont, -2 + _utils->svgaCord(1), 0, 0, false, false, true, true, _utils->vgaScaleX(25) + _utils->svgaCord(15), _utils->vgaScaleY(50), _utils->vgaScaleX(295) - _utils->svgaCord(15), _utils->vgaScaleY(148), noteText); + Common::Rect textRect = Common::Rect(_utils->vgaScaleX(25) + _utils->svgaCord(15), _utils->vgaScaleY(50), _utils->vgaScaleX(295) - _utils->svgaCord(15), _utils->vgaScaleY(148)); + _graphics->flowText(noteFont, -2 + _utils->svgaCord(1), 0, 0, false, false, true, true, textRect, noteText); _graphics->setPalette(_anim->_diffPalette, 256); _graphics->closeFont(noteFont); delete[] noteText; @@ -67,7 +68,9 @@ void LabEngine::doNotes() { void LabEngine::doWestPaper() { TextFont *paperFont = _resource->getFont("P:News22.fon"); char *paperText = _resource->getText("Lab:Rooms/Date"); - _graphics->flowText(paperFont, 0, 0, 0, false, true, false, true, _utils->vgaScaleX(57), _utils->vgaScaleY(77) + _utils->svgaCord(2), _utils->vgaScaleX(262), _utils->vgaScaleY(91), paperText); + + Common::Rect textRect = Common::Rect(_utils->vgaScaleX(57), _utils->vgaScaleY(77) + _utils->svgaCord(2), _utils->vgaScaleX(262), _utils->vgaScaleY(91)); + _graphics->flowText(paperFont, 0, 0, 0, false, true, false, true, textRect, paperText); _graphics->closeFont(paperFont); delete[] paperText; @@ -75,13 +78,15 @@ void LabEngine::doWestPaper() { paperText = _resource->getText("Lab:Rooms/Headline"); int fileLen = strlen(paperText) - 1; - int charsPrinted = _graphics->flowText(paperFont, -8, 0, 0, false, true, false, true, _utils->vgaScaleX(57), _utils->vgaScaleY(86) - _utils->svgaCord(2), _utils->vgaScaleX(262), _utils->vgaScaleY(118), paperText); + textRect = Common::Rect(_utils->vgaScaleX(57), _utils->vgaScaleY(86) - _utils->svgaCord(2), _utils->vgaScaleX(262), _utils->vgaScaleY(118)); + int charsPrinted = _graphics->flowText(paperFont, -8, 0, 0, false, true, false, true, textRect, paperText); uint16 y; if (charsPrinted < fileLen) { y = 130 - _utils->svgaCord(5); - _graphics->flowText(paperFont, -8 - _utils->svgaCord(1), 0, 0, false, true, false, true, _utils->vgaScaleX(57), _utils->vgaScaleY(86) - _utils->svgaCord(2), _utils->vgaScaleX(262), _utils->vgaScaleY(132), paperText); + textRect = Common::Rect(_utils->vgaScaleX(57), _utils->vgaScaleY(86) - _utils->svgaCord(2), _utils->vgaScaleX(262), _utils->vgaScaleY(132)); + _graphics->flowText(paperFont, -8 - _utils->svgaCord(1), 0, 0, false, true, false, true, textRect, paperText); } else y = 115 - _utils->svgaCord(5); @@ -90,10 +95,10 @@ void LabEngine::doWestPaper() { paperFont = _resource->getFont("P:Note.fon"); paperText = _resource->getText("Lab:Rooms/Col1"); - charsPrinted = _graphics->flowTextScaled(paperFont, -4, 0, 0, false, false, false, true, 45, y, 158, 148, paperText); + charsPrinted = _graphics->flowTextScaled(paperFont, -4, 0, 0, false, false, false, true, Common::Rect(45, y, 158, 148), paperText); delete[] paperText; paperText = _resource->getText("Lab:Rooms/Col2"); - charsPrinted = _graphics->flowTextScaled(paperFont, -4, 0, 0, false, false, false, true, 162, y, 275, 148, paperText); + charsPrinted = _graphics->flowTextScaled(paperFont, -4, 0, 0, false, false, false, true, Common::Rect(162, y, 275, 148), paperText); delete[] paperText; _graphics->closeFont(paperFont); @@ -167,7 +172,7 @@ void LabEngine::drawJournalText() { while (drawingToPage < _journalPage) { _music->updateMusic(); curText = (char *)(_journalText + charsDrawn); - charsDrawn += _graphics->flowTextScaled(_journalFont, -2, 2, 0, false, false, false, false, 52, 32, 152, 148, curText); + charsDrawn += _graphics->flowTextScaled(_journalFont, -2, 2, 0, false, false, false, false, Common::Rect(52, 32, 152, 148), curText); _lastPage = (*curText == 0); @@ -179,16 +184,16 @@ void LabEngine::drawJournalText() { if (_journalPage <= 1) { curText = _journalTextTitle; - _graphics->flowTextToMem(_journalBackImage, _journalFont, -2, 2, 0, false, true, true, true, _utils->vgaScaleX(52), _utils->vgaScaleY(32), _utils->vgaScaleX(152), _utils->vgaScaleY(148), curText); + _graphics->flowTextToMem(_journalBackImage, _journalFont, -2, 2, 0, false, true, true, true, _utils->vgaRectScale(52, 32, 152, 148), curText); } else { curText = (char *)(_journalText + charsDrawn); - charsDrawn += _graphics->flowTextToMem(_journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaScaleX(52), _utils->vgaScaleY(32), _utils->vgaScaleX(152), _utils->vgaScaleY(148), curText); + charsDrawn += _graphics->flowTextToMem(_journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaRectScale(52, 32, 152, 148), curText); } _music->updateMusic(); curText = (char *)(_journalText + charsDrawn); _lastPage = (*curText == 0); - _graphics->flowTextToMem(_journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaScaleX(171), _utils->vgaScaleY(32), _utils->vgaScaleX(271), _utils->vgaScaleY(148), curText); + _graphics->flowTextToMem(_journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaRectScale(171, 32, 271, 148), curText); curText = (char *)(_journalText + charsDrawn); _lastPage |= (*curText == 0); @@ -331,7 +336,7 @@ void LabEngine::doJournal() { /** * Draws the text for the monitor. */ -void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16 y1, uint16 x2, uint16 y2, bool isinteractive) { +void LabEngine::drawMonText(char *text, TextFont *monitorFont, Common::Rect textRect, bool isinteractive) { uint16 drawingToPage = 0, yspacing = 0; int charsDrawn = 0; char *curText = text; @@ -346,7 +351,7 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16 text += 2; uint16 fheight = _graphics->textHeight(monitorFont); - x1 = _monitorButton->_width + _utils->vgaScaleX(3); + textRect.left = _monitorButton->_width + _utils->vgaScaleX(3); _monitorButtonHeight = _monitorButton->_height + _utils->vgaScaleY(3); if (_monitorButtonHeight > fheight) @@ -355,22 +360,22 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16 _monitorButtonHeight = fheight; _graphics->setPen(0); - _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, y2); + _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, textRect.bottom); for (uint16 i = 0; i < numlines; i++) _monitorButton->drawImage(0, i * _monitorButtonHeight); } else if (isinteractive) { _graphics->setPen(0); - _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, y2); + _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, textRect.bottom); } else { _graphics->setPen(0); - _graphics->rectFill(x1, y1, x2, y2); + _graphics->rectFill(textRect); } while (drawingToPage < _monitorPage) { _music->updateMusic(); curText = (char *)(text + charsDrawn); - charsDrawn += _graphics->flowText(monitorFont, yspacing, 0, 0, false, false, false, false, x1, y1, x2, y2, curText); + charsDrawn += _graphics->flowText(monitorFont, yspacing, 0, 0, false, false, false, false, textRect, curText); _lastPage = (*curText == 0); if (_lastPage) @@ -381,7 +386,7 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16 curText = (char *)(text + charsDrawn); _lastPage = (*curText == 0); - charsDrawn = _graphics->flowText(monitorFont, yspacing, 2, 0, false, false, false, true, x1, y1, x2, y2, curText); + charsDrawn = _graphics->flowText(monitorFont, yspacing, 2, 0, false, false, false, true, textRect, curText); curText += charsDrawn; _lastPage |= (*curText == 0); @@ -391,7 +396,7 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16 /** * Processes user input. */ -void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isInteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2) { +void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isInteractive, Common::Rect textRect) { const char *startFileName = _monitorTextFilename; CloseDataPtr startClosePtr = _closeDataPtr, lastClosePtr[10]; uint16 depth = 0; @@ -415,7 +420,7 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isIntera ntext = _resource->getText(_monitorTextFilename); _graphics->fade(false, 0); - drawMonText(ntext, monitorFont, x1, y1, x2, y2, isInteractive); + drawMonText(ntext, monitorFont, textRect, isInteractive); _graphics->fade(true, 0); delete[] ntext; } @@ -455,19 +460,19 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isIntera } } else if (_monitorPage > 0) { _monitorPage = 0; - drawMonText(ntext, monitorFont, x1, y1, x2, y2, isInteractive); + drawMonText(ntext, monitorFont, textRect, isInteractive); } } else if (mouseX < _utils->vgaScaleX(259)) { return; } else if (mouseX <= _utils->vgaScaleX(289)) { if (!_lastPage) { _monitorPage += 1; - drawMonText(ntext, monitorFont, x1, y1, x2, y2, isInteractive); + drawMonText(ntext, monitorFont, textRect, isInteractive); } } else if (_monitorPage >= 1) { // mouseX between 290 and 320 (scaled) _monitorPage -= 1; - drawMonText(ntext, monitorFont, x1, y1, x2, y2, isInteractive); + drawMonText(ntext, monitorFont, textRect, isInteractive); } } else if (isInteractive) { CloseDataPtr tmpClosePtr = _closeDataPtr; @@ -488,12 +493,8 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isIntera /** * Does what's necessary for the monitor. */ -void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2) { - x1 = _utils->vgaScaleX(x1); - x2 = _utils->vgaScaleX(x2); - y1 = _utils->vgaScaleY(y1); - y2 = _utils->vgaScaleY(y2); - +void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive, Common::Rect textRect) { + Common::Rect scaledRect = _utils->vgaRectScale(textRect.left, textRect.top, textRect.right, textRect.bottom); _monitorTextFilename = textfile; _graphics->blackAllScreen(); @@ -514,10 +515,10 @@ void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive, char *ntext = _resource->getText(textfile); _graphics->loadBackPict(background, _highPalette); - drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive); + drawMonText(ntext, monitorFont, scaledRect, isinteractive); _event->mouseShow(); _graphics->fade(true, 0); - processMonitor(ntext, monitorFont, isinteractive, x1, y1, x2, y2); + processMonitor(ntext, monitorFont, isinteractive, scaledRect); _graphics->fade(false, 0); _event->mouseHide(); delete[] ntext; -- cgit v1.2.3 From 25509777aa1770c07ab66729c371d28c825894ea Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 17 Dec 2015 18:46:46 +0100 Subject: LAB: Get rid of flowTextScaled --- engines/lab/special.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index c8cc616d30..5ed0919e82 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -95,10 +95,10 @@ void LabEngine::doWestPaper() { paperFont = _resource->getFont("P:Note.fon"); paperText = _resource->getText("Lab:Rooms/Col1"); - charsPrinted = _graphics->flowTextScaled(paperFont, -4, 0, 0, false, false, false, true, Common::Rect(45, y, 158, 148), paperText); + charsPrinted = _graphics->flowText(paperFont, -4, 0, 0, false, false, false, true, _utils->vgaRectScale(45, y, 158, 148), paperText); delete[] paperText; paperText = _resource->getText("Lab:Rooms/Col2"); - charsPrinted = _graphics->flowTextScaled(paperFont, -4, 0, 0, false, false, false, true, Common::Rect(162, y, 275, 148), paperText); + charsPrinted = _graphics->flowText(paperFont, -4, 0, 0, false, false, false, true, _utils->vgaRectScale(162, y, 275, 148), paperText); delete[] paperText; _graphics->closeFont(paperFont); @@ -172,7 +172,7 @@ void LabEngine::drawJournalText() { while (drawingToPage < _journalPage) { _music->updateMusic(); curText = (char *)(_journalText + charsDrawn); - charsDrawn += _graphics->flowTextScaled(_journalFont, -2, 2, 0, false, false, false, false, Common::Rect(52, 32, 152, 148), curText); + charsDrawn += _graphics->flowText(_journalFont, -2, 2, 0, false, false, false, false, _utils->vgaRectScale(52, 32, 152, 148), curText); _lastPage = (*curText == 0); -- cgit v1.2.3 From b6bed0aed72bb45e88dd363a9a34a26ad9f03f6d Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 18 Dec 2015 00:41:24 +0200 Subject: LAB: Simplify mouse button handling --- engines/lab/special.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 5ed0919e82..820455a433 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -277,10 +277,10 @@ void LabEngine::processJournal() { uint16 qualifier = msg->_qualifier; uint16 buttonId = msg->_code; - if (((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RIGHTBUTTON & qualifier)) || - ((msgClass == RAWKEY) && (buttonId == Common::KEYCODE_ESCAPE))) + if ((msgClass == kMessageRightClick) || + ((msgClass == kMessageRawKey) && (buttonId == Common::KEYCODE_ESCAPE))) return; - else if (msgClass == BUTTONUP) { + else if (msgClass == kMessageButtonUp) { if (buttonId == 0) { if (_journalPage >= 2) { _journalPage -= 2; @@ -443,10 +443,10 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isIntera uint16 mouseY = msg->_mouseY; uint16 code = msg->_code; - if (((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RIGHTBUTTON & qualifier)) || - ((msgClass == RAWKEY) && (code == Common::KEYCODE_ESCAPE))) + if ((msgClass == kMessageRightClick) || + ((msgClass == kMessageRawKey) && (code == Common::KEYCODE_ESCAPE))) return; - else if ((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & qualifier)) { + else if (msgClass == kMessageLeftClick) { if ((mouseY >= _utils->vgaScaleY(171)) && (mouseY <= _utils->vgaScaleY(200))) { if (mouseX <= _utils->vgaScaleX(31)) { return; -- cgit v1.2.3 From 832d87e0bf1cb7dbfd2d3e7217b5d8fe0fefa8b7 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 18 Dec 2015 00:58:36 +0200 Subject: LAB: Use Common::Point in IntuiMessage --- engines/lab/special.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 820455a433..68fbcd47ae 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -274,7 +274,6 @@ void LabEngine::processJournal() { _music->updateMusic(); else { uint32 msgClass = msg->_msgClass; - uint16 qualifier = msg->_qualifier; uint16 buttonId = msg->_code; if ((msgClass == kMessageRightClick) || @@ -439,8 +438,8 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isIntera } else { uint32 msgClass = msg->_msgClass; uint16 qualifier = msg->_qualifier; - uint16 mouseX = msg->_mouseX; - uint16 mouseY = msg->_mouseY; + uint16 mouseX = msg->_mouse.x; + uint16 mouseY = msg->_mouse.y; uint16 code = msg->_code; if ((msgClass == kMessageRightClick) || -- cgit v1.2.3 From 69680808d0acb9583f7e60f259f9c70b9e7ed6c5 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 18 Dec 2015 02:39:46 +0200 Subject: LAB: Remove unused variable --- engines/lab/special.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 68fbcd47ae..194564c891 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -437,7 +437,6 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isIntera _music->updateMusic(); } else { uint32 msgClass = msg->_msgClass; - uint16 qualifier = msg->_qualifier; uint16 mouseX = msg->_mouse.x; uint16 mouseY = msg->_mouse.y; uint16 code = msg->_code; -- cgit v1.2.3 From 12572a9c4b503e6c9e947301d4610626c152f902 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 18 Dec 2015 03:31:07 +0200 Subject: LAB: Merge enableButton() and disableButton() --- engines/lab/special.cpp | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 194564c891..bf0938b45c 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -234,18 +234,8 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) { else turnPage((wipenum == 1)); - Button *backButton = _event->getButton(0); - Button *forwardButton = _event->getButton(2); - - if (_journalPage == 0) - _event->disableButton(backButton, 15); - else - _event->enableButton(backButton); - - if (_lastPage) - _event->disableButton(forwardButton, 15); - else - _event->enableButton(forwardButton); + _event->toggleButton(_event->getButton(0), 15, (_journalPage > 0)); // back button + _event->toggleButton(_event->getButton(2), 15, (!_lastPage)); // forward button if (needFade) _graphics->fade(true, 0); -- cgit v1.2.3 From c5528a631d63e47b830c89258507ebb681d5b261 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 18 Dec 2015 05:42:26 +0200 Subject: LAB: Handle some differences of the Amiga version The Amiga version is still not working, as the CONTROL and INV files are missing, and the format of the font files is different --- engines/lab/special.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index bf0938b45c..6e69578444 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -51,7 +51,7 @@ namespace Lab { * Does the things to properly set up the detective notes. */ void LabEngine::doNotes() { - TextFont *noteFont = _resource->getFont("P:Note.fon"); + TextFont *noteFont = _resource->getFont("F:Note.fon"); char *noteText = _resource->getText("Lab:Rooms/Notes"); Common::Rect textRect = Common::Rect(_utils->vgaScaleX(25) + _utils->svgaCord(15), _utils->vgaScaleY(50), _utils->vgaScaleX(295) - _utils->svgaCord(15), _utils->vgaScaleY(148)); @@ -66,7 +66,7 @@ void LabEngine::doNotes() { * OpenHiRes already called. */ void LabEngine::doWestPaper() { - TextFont *paperFont = _resource->getFont("P:News22.fon"); + TextFont *paperFont = _resource->getFont("F:News22.fon"); char *paperText = _resource->getText("Lab:Rooms/Date"); Common::Rect textRect = Common::Rect(_utils->vgaScaleX(57), _utils->vgaScaleY(77) + _utils->svgaCord(2), _utils->vgaScaleX(262), _utils->vgaScaleY(91)); @@ -74,7 +74,7 @@ void LabEngine::doWestPaper() { _graphics->closeFont(paperFont); delete[] paperText; - paperFont = _resource->getFont("P:News32.fon"); + paperFont = _resource->getFont("F:News32.fon"); paperText = _resource->getText("Lab:Rooms/Headline"); int fileLen = strlen(paperText) - 1; @@ -93,7 +93,7 @@ void LabEngine::doWestPaper() { _graphics->closeFont(paperFont); delete[] paperText; - paperFont = _resource->getFont("P:Note.fon"); + paperFont = _resource->getFont("F:Note.fon"); paperText = _resource->getText("Lab:Rooms/Col1"); charsPrinted = _graphics->flowText(paperFont, -4, 0, 0, false, false, false, true, _utils->vgaRectScale(45, y, 158, 148), paperText); delete[] paperText; @@ -109,7 +109,7 @@ void LabEngine::doWestPaper() { * Loads in the data for the journal. */ void LabEngine::loadJournalData() { - _journalFont = _resource->getFont("P:Journal.fon"); + _journalFont = _resource->getFont("F:Journal.fon"); _music->updateMusic(); char filename[20]; @@ -496,7 +496,7 @@ void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive, _lastPage = false; _graphics->_fadePalette = _highPalette; - TextFont *monitorFont = _resource->getFont("P:Map.fon"); + TextFont *monitorFont = _resource->getFont("F:Map.fon"); Common::File *buttonFile = _resource->openDataFile("P:MonImage"); _monitorButton = new Image(buttonFile, this); delete buttonFile; -- cgit v1.2.3 From 3e8eaa2c3552df625c2654b7d76e9b1f35bc9e92 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 19 Dec 2015 02:12:42 +0200 Subject: LAB: Use Common::String for strings, removing a ton of memory leaks Also, add a method to properly free room views --- engines/lab/special.cpp | 59 ++++++++++++++++++++++--------------------------- 1 file changed, 26 insertions(+), 33 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 6e69578444..4ea6843d98 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -52,13 +52,12 @@ namespace Lab { */ void LabEngine::doNotes() { TextFont *noteFont = _resource->getFont("F:Note.fon"); - char *noteText = _resource->getText("Lab:Rooms/Notes"); + Common::String noteText = _resource->getText("Lab:Rooms/Notes"); Common::Rect textRect = Common::Rect(_utils->vgaScaleX(25) + _utils->svgaCord(15), _utils->vgaScaleY(50), _utils->vgaScaleX(295) - _utils->svgaCord(15), _utils->vgaScaleY(148)); - _graphics->flowText(noteFont, -2 + _utils->svgaCord(1), 0, 0, false, false, true, true, textRect, noteText); + _graphics->flowText(noteFont, -2 + _utils->svgaCord(1), 0, 0, false, false, true, true, textRect, noteText.c_str()); _graphics->setPalette(_anim->_diffPalette, 256); _graphics->closeFont(noteFont); - delete[] noteText; } /** @@ -67,39 +66,35 @@ void LabEngine::doNotes() { */ void LabEngine::doWestPaper() { TextFont *paperFont = _resource->getFont("F:News22.fon"); - char *paperText = _resource->getText("Lab:Rooms/Date"); + Common::String paperText = _resource->getText("Lab:Rooms/Date"); Common::Rect textRect = Common::Rect(_utils->vgaScaleX(57), _utils->vgaScaleY(77) + _utils->svgaCord(2), _utils->vgaScaleX(262), _utils->vgaScaleY(91)); - _graphics->flowText(paperFont, 0, 0, 0, false, true, false, true, textRect, paperText); + _graphics->flowText(paperFont, 0, 0, 0, false, true, false, true, textRect, paperText.c_str()); _graphics->closeFont(paperFont); - delete[] paperText; paperFont = _resource->getFont("F:News32.fon"); paperText = _resource->getText("Lab:Rooms/Headline"); - int fileLen = strlen(paperText) - 1; + int fileLen = paperText.size() - 1; textRect = Common::Rect(_utils->vgaScaleX(57), _utils->vgaScaleY(86) - _utils->svgaCord(2), _utils->vgaScaleX(262), _utils->vgaScaleY(118)); - int charsPrinted = _graphics->flowText(paperFont, -8, 0, 0, false, true, false, true, textRect, paperText); + int charsPrinted = _graphics->flowText(paperFont, -8, 0, 0, false, true, false, true, textRect, paperText.c_str()); uint16 y; if (charsPrinted < fileLen) { y = 130 - _utils->svgaCord(5); textRect = Common::Rect(_utils->vgaScaleX(57), _utils->vgaScaleY(86) - _utils->svgaCord(2), _utils->vgaScaleX(262), _utils->vgaScaleY(132)); - _graphics->flowText(paperFont, -8 - _utils->svgaCord(1), 0, 0, false, true, false, true, textRect, paperText); + _graphics->flowText(paperFont, -8 - _utils->svgaCord(1), 0, 0, false, true, false, true, textRect, paperText.c_str()); } else y = 115 - _utils->svgaCord(5); _graphics->closeFont(paperFont); - delete[] paperText; paperFont = _resource->getFont("F:Note.fon"); paperText = _resource->getText("Lab:Rooms/Col1"); - charsPrinted = _graphics->flowText(paperFont, -4, 0, 0, false, false, false, true, _utils->vgaRectScale(45, y, 158, 148), paperText); - delete[] paperText; + charsPrinted = _graphics->flowText(paperFont, -4, 0, 0, false, false, false, true, _utils->vgaRectScale(45, y, 158, 148), paperText.c_str()); paperText = _resource->getText("Lab:Rooms/Col2"); - charsPrinted = _graphics->flowText(paperFont, -4, 0, 0, false, false, false, true, _utils->vgaRectScale(162, y, 275, 148), paperText); - delete[] paperText; + charsPrinted = _graphics->flowText(paperFont, -4, 0, 0, false, false, false, true, _utils->vgaRectScale(162, y, 275, 148), paperText.c_str()); _graphics->closeFont(paperFont); _graphics->setPalette(_anim->_diffPalette, 256); @@ -167,11 +162,11 @@ void LabEngine::loadJournalData() { void LabEngine::drawJournalText() { uint16 drawingToPage = 1; int charsDrawn = 0; - char *curText = _journalText; + const char *curText = _journalText.c_str(); while (drawingToPage < _journalPage) { _music->updateMusic(); - curText = (char *)(_journalText + charsDrawn); + curText = (char *)(_journalText.c_str() + charsDrawn); charsDrawn += _graphics->flowText(_journalFont, -2, 2, 0, false, false, false, false, _utils->vgaRectScale(52, 32, 152, 148), curText); _lastPage = (*curText == 0); @@ -183,20 +178,20 @@ void LabEngine::drawJournalText() { } if (_journalPage <= 1) { - curText = _journalTextTitle; + curText = _journalTextTitle.c_str(); _graphics->flowTextToMem(_journalBackImage, _journalFont, -2, 2, 0, false, true, true, true, _utils->vgaRectScale(52, 32, 152, 148), curText); } else { - curText = (char *)(_journalText + charsDrawn); + curText = (char *)(_journalText.c_str() + charsDrawn); charsDrawn += _graphics->flowTextToMem(_journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaRectScale(52, 32, 152, 148), curText); } _music->updateMusic(); - curText = (char *)(_journalText + charsDrawn); + curText = (char *)(_journalText.c_str() + charsDrawn); _lastPage = (*curText == 0); _graphics->flowTextToMem(_journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaRectScale(171, 32, 271, 148), curText); - curText = (char *)(_journalText + charsDrawn); - _lastPage |= (*curText == 0); + curText = (char *)(_journalText.c_str() + charsDrawn); + _lastPage = (*curText == 0); } /** @@ -386,7 +381,7 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, Common::Rect text * Processes user input. */ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isInteractive, Common::Rect textRect) { - const char *startFileName = _monitorTextFilename; + Common::String startFileName = _monitorTextFilename; CloseDataPtr startClosePtr = _closeDataPtr, lastClosePtr[10]; uint16 depth = 0; @@ -397,21 +392,20 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isIntera if (!_closeDataPtr) _closeDataPtr = startClosePtr; - const char *test; + Common::String test; if (_closeDataPtr == startClosePtr) test = startFileName; else test = _closeDataPtr->_graphicName; - if (strcmp(test, _monitorTextFilename)) { + if (test != _monitorTextFilename) { _monitorPage = 0; _monitorTextFilename = test; - ntext = _resource->getText(_monitorTextFilename); + Common::String text = _resource->getText(_monitorTextFilename.c_str()); _graphics->fade(false, 0); - drawMonText(ntext, monitorFont, textRect, isInteractive); + drawMonText((char *)text.c_str(), monitorFont, textRect, isInteractive); _graphics->fade(true, 0); - delete[] ntext; } } @@ -481,7 +475,7 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isIntera /** * Does what's necessary for the monitor. */ -void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive, Common::Rect textRect) { +void LabEngine::doMonitor(Common::String background, Common::String textfile, bool isinteractive, Common::Rect textRect) { Common::Rect scaledRect = _utils->vgaRectScale(textRect.left, textRect.top, textRect.right, textRect.bottom); _monitorTextFilename = textfile; @@ -501,15 +495,14 @@ void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive, _monitorButton = new Image(buttonFile, this); delete buttonFile; - char *ntext = _resource->getText(textfile); - _graphics->loadBackPict(background, _highPalette); - drawMonText(ntext, monitorFont, scaledRect, isinteractive); + Common::String ntext = _resource->getText(textfile.c_str()); + _graphics->loadBackPict(background.c_str(), _highPalette); + drawMonText((char *)ntext.c_str(), monitorFont, scaledRect, isinteractive); _event->mouseShow(); _graphics->fade(true, 0); - processMonitor(ntext, monitorFont, isinteractive, scaledRect); + processMonitor((char *)ntext.c_str(), monitorFont, isinteractive, scaledRect); _graphics->fade(false, 0); _event->mouseHide(); - delete[] ntext; _graphics->closeFont(monitorFont); _graphics->setPen(0); -- cgit v1.2.3 From 3fcd3c15262adb1b4ac9f69475df2a4145c450d3 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 19 Dec 2015 13:08:54 +0100 Subject: LAB: Avoid memory leaks with fonts --- engines/lab/special.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 4ea6843d98..7bb09e6a91 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -57,7 +57,7 @@ void LabEngine::doNotes() { Common::Rect textRect = Common::Rect(_utils->vgaScaleX(25) + _utils->svgaCord(15), _utils->vgaScaleY(50), _utils->vgaScaleX(295) - _utils->svgaCord(15), _utils->vgaScaleY(148)); _graphics->flowText(noteFont, -2 + _utils->svgaCord(1), 0, 0, false, false, true, true, textRect, noteText.c_str()); _graphics->setPalette(_anim->_diffPalette, 256); - _graphics->closeFont(noteFont); + _graphics->closeFont(¬eFont); } /** @@ -70,7 +70,7 @@ void LabEngine::doWestPaper() { Common::Rect textRect = Common::Rect(_utils->vgaScaleX(57), _utils->vgaScaleY(77) + _utils->svgaCord(2), _utils->vgaScaleX(262), _utils->vgaScaleY(91)); _graphics->flowText(paperFont, 0, 0, 0, false, true, false, true, textRect, paperText.c_str()); - _graphics->closeFont(paperFont); + _graphics->closeFont(&paperFont); paperFont = _resource->getFont("F:News32.fon"); paperText = _resource->getText("Lab:Rooms/Headline"); @@ -88,14 +88,14 @@ void LabEngine::doWestPaper() { } else y = 115 - _utils->svgaCord(5); - _graphics->closeFont(paperFont); + _graphics->closeFont(&paperFont); paperFont = _resource->getFont("F:Note.fon"); paperText = _resource->getText("Lab:Rooms/Col1"); charsPrinted = _graphics->flowText(paperFont, -4, 0, 0, false, false, false, true, _utils->vgaRectScale(45, y, 158, 148), paperText.c_str()); paperText = _resource->getText("Lab:Rooms/Col2"); charsPrinted = _graphics->flowText(paperFont, -4, 0, 0, false, false, false, true, _utils->vgaRectScale(162, y, 275, 148), paperText.c_str()); - _graphics->closeFont(paperFont); + _graphics->closeFont(&paperFont); _graphics->setPalette(_anim->_diffPalette, 256); } @@ -104,6 +104,9 @@ void LabEngine::doWestPaper() { * Loads in the data for the journal. */ void LabEngine::loadJournalData() { + if (_journalFont) + _graphics->closeFont(&_journalFont); + _journalFont = _resource->getFont("F:Journal.fon"); _music->updateMusic(); @@ -308,7 +311,7 @@ void LabEngine::doJournal() { delete[] _blankJournal; delete[] _journalBackImage->_imageData; _event->freeButtonList(&_journalButtonList); - _graphics->closeFont(_journalFont); + _graphics->closeFont(&_journalFont); _screenImage->_imageData = _graphics->getCurrentDrawingBuffer(); @@ -503,7 +506,7 @@ void LabEngine::doMonitor(Common::String background, Common::String textfile, bo processMonitor((char *)ntext.c_str(), monitorFont, isinteractive, scaledRect); _graphics->fade(false, 0); _event->mouseHide(); - _graphics->closeFont(monitorFont); + _graphics->closeFont(&monitorFont); _graphics->setPen(0); _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1); -- cgit v1.2.3 From 2981ccc24384aef44ff34a00ab547462735d6632 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 19 Dec 2015 14:14:11 +0100 Subject: LAB: get rid of the last strcpy --- engines/lab/special.cpp | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 7bb09e6a91..fa08fdc40b 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -110,8 +110,7 @@ void LabEngine::loadJournalData() { _journalFont = _resource->getFont("F:Journal.fon"); _music->updateMusic(); - char filename[20]; - strcpy(filename, "Lab:Rooms/j0"); + Common::String filename = "Lab:Rooms/j0"; bool bridge = _conditions->in(BRIDGE0) || _conditions->in(BRIDGE1); bool dirty = _conditions->in(DIRTY); @@ -119,25 +118,25 @@ void LabEngine::loadJournalData() { bool clean = !_conditions->in(NOCLEAN); if (bridge && clean && news) - filename[11] = '8'; + filename += '8'; else if (clean && news) - filename[11] = '9'; + filename += '9'; else if (bridge && clean) - filename[11] = '6'; + filename += '6'; else if (clean) - filename[11] = '7'; + filename += '7'; else if (bridge && dirty && news) - filename[11] = '4'; + filename += '4'; else if (dirty && news) - filename[11] = '5'; + filename += '5'; else if (bridge && dirty) - filename[11] = '2'; + filename += '2'; else if (dirty) - filename[11] = '3'; + filename += '3'; else if (bridge) - filename[11] = '1'; + filename += '1'; - _journalText = _resource->getText(filename); + _journalText = _resource->getText(filename.c_str()); _journalTextTitle = _resource->getText("Lab:Rooms/jt"); Common::File *journalFile = _resource->openDataFile("P:JImage"); -- cgit v1.2.3 From 28c74aed05e6b7ea127bb521ea8c456075608b07 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 20 Dec 2015 02:42:52 +0100 Subject: LAB: More work on the comments --- engines/lab/special.cpp | 34 ---------------------------------- 1 file changed, 34 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index fa08fdc40b..9f33d9626d 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -47,9 +47,6 @@ namespace Lab { #define NONEWS 135 #define NOCLEAN 152 -/** - * Does the things to properly set up the detective notes. - */ void LabEngine::doNotes() { TextFont *noteFont = _resource->getFont("F:Note.fon"); Common::String noteText = _resource->getText("Lab:Rooms/Notes"); @@ -60,10 +57,6 @@ void LabEngine::doNotes() { _graphics->closeFont(¬eFont); } -/** - * Does the things to properly set up the old west newspaper. Assumes that - * OpenHiRes already called. - */ void LabEngine::doWestPaper() { TextFont *paperFont = _resource->getFont("F:News22.fon"); Common::String paperText = _resource->getText("Lab:Rooms/Date"); @@ -100,9 +93,6 @@ void LabEngine::doWestPaper() { _graphics->setPalette(_anim->_diffPalette, 256); } -/** - * Loads in the data for the journal. - */ void LabEngine::loadJournalData() { if (_journalFont) _graphics->closeFont(&_journalFont); @@ -158,9 +148,6 @@ void LabEngine::loadJournalData() { _screenImage->_imageData = _graphics->getCurrentDrawingBuffer(); } -/** - * Draws the text to the back journal screen to the appropriate Page number - */ void LabEngine::drawJournalText() { uint16 drawingToPage = 1; int charsDrawn = 0; @@ -196,9 +183,6 @@ void LabEngine::drawJournalText() { _lastPage = (*curText == 0); } -/** - * Does the turn page wipe. - */ void LabEngine::turnPage(bool fromLeft) { if (fromLeft) { for (int i = 0; i < _graphics->_screenWidth; i += 8) { @@ -217,9 +201,6 @@ void LabEngine::turnPage(bool fromLeft) { } } -/** - * Draws the journal from page x. - */ void LabEngine::drawJournal(uint16 wipenum, bool needFade) { _event->mouseHide(); _music->updateMusic(); @@ -244,9 +225,6 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) { _event->mouseShow(); } -/** - * Processes user input. - */ void LabEngine::processJournal() { while (1) { // Make sure we check the music at least after every message @@ -285,9 +263,6 @@ void LabEngine::processJournal() { } } -/** - * Does the journal processing. - */ void LabEngine::doJournal() { _graphics->blackAllScreen(); _lastPage = false; @@ -319,9 +294,6 @@ void LabEngine::doJournal() { _graphics->blackScreen(); } -/** - * Draws the text for the monitor. - */ void LabEngine::drawMonText(char *text, TextFont *monitorFont, Common::Rect textRect, bool isinteractive) { uint16 drawingToPage = 0, yspacing = 0; int charsDrawn = 0; @@ -379,9 +351,6 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, Common::Rect text _event->mouseShow(); } -/** - * Processes user input. - */ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isInteractive, Common::Rect textRect) { Common::String startFileName = _monitorTextFilename; CloseDataPtr startClosePtr = _closeDataPtr, lastClosePtr[10]; @@ -474,9 +443,6 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isIntera } } -/** - * Does what's necessary for the monitor. - */ void LabEngine::doMonitor(Common::String background, Common::String textfile, bool isinteractive, Common::Rect textRect) { Common::Rect scaledRect = _utils->vgaRectScale(textRect.left, textRect.top, textRect.right, textRect.bottom); _monitorTextFilename = textfile; -- cgit v1.2.3 From ae9c2fea51adb1e5b713683e1fadfbb11558c267 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 20 Dec 2015 16:02:35 +0100 Subject: LAB: Replace char* by Common::String in several functions --- engines/lab/special.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 9f33d9626d..a45a8fa840 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -126,7 +126,7 @@ void LabEngine::loadJournalData() { else if (bridge) filename += '1'; - _journalText = _resource->getText(filename.c_str()); + _journalText = _resource->getText(filename); _journalTextTitle = _resource->getText("Lab:Rooms/jt"); Common::File *journalFile = _resource->openDataFile("P:JImage"); @@ -463,8 +463,8 @@ void LabEngine::doMonitor(Common::String background, Common::String textfile, bo _monitorButton = new Image(buttonFile, this); delete buttonFile; - Common::String ntext = _resource->getText(textfile.c_str()); - _graphics->loadBackPict(background.c_str(), _highPalette); + Common::String ntext = _resource->getText(textfile); + _graphics->loadBackPict(background, _highPalette); drawMonText((char *)ntext.c_str(), monitorFont, scaledRect, isinteractive); _event->mouseShow(); _graphics->fade(true, 0); -- cgit v1.2.3 From baa638fe2ecb8a6dbde0a8fd6d5af20f80aa0676 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 20 Dec 2015 16:04:20 +0100 Subject: LAB: Remove useless call to c_str --- engines/lab/special.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index a45a8fa840..3f5a3d09bf 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -373,7 +373,7 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isIntera _monitorPage = 0; _monitorTextFilename = test; - Common::String text = _resource->getText(_monitorTextFilename.c_str()); + Common::String text = _resource->getText(_monitorTextFilename); _graphics->fade(false, 0); drawMonText((char *)text.c_str(), monitorFont, textRect, isInteractive); _graphics->fade(true, 0); -- cgit v1.2.3 From cff1f99b26e64b03a8c7d6f456b48b333e8bf882 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 20 Dec 2015 16:52:49 +0100 Subject: LAB: Set a default to the second parameter of readPict --- engines/lab/special.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 3f5a3d09bf..ddc7ea49e4 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -448,10 +448,10 @@ void LabEngine::doMonitor(Common::String background, Common::String textfile, bo _monitorTextFilename = textfile; _graphics->blackAllScreen(); - _graphics->readPict("P:Mon/Monitor.1", true); - _graphics->readPict("P:Mon/NWD1", true); - _graphics->readPict("P:Mon/NWD2", true); - _graphics->readPict("P:Mon/NWD3", true); + _graphics->readPict("P:Mon/Monitor.1"); + _graphics->readPict("P:Mon/NWD1"); + _graphics->readPict("P:Mon/NWD2"); + _graphics->readPict("P:Mon/NWD3"); _graphics->blackAllScreen(); _monitorPage = 0; -- cgit v1.2.3 From b53735ba064012b3c981d5ef497d5f8c2e974291 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 20 Dec 2015 17:21:55 +0100 Subject: LAB: Constify some parameters --- engines/lab/special.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index ddc7ea49e4..946277b8f0 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -443,7 +443,7 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isIntera } } -void LabEngine::doMonitor(Common::String background, Common::String textfile, bool isinteractive, Common::Rect textRect) { +void LabEngine::doMonitor(const Common::String background, const Common::String textfile, bool isinteractive, Common::Rect textRect) { Common::Rect scaledRect = _utils->vgaRectScale(textRect.left, textRect.top, textRect.right, textRect.bottom); _monitorTextFilename = textfile; -- cgit v1.2.3 From 26c48305b58b054bc81c1de37b7af9e79eb231bf Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 22 Dec 2015 00:12:12 +0100 Subject: LAB: Add a couple of safeguards --- engines/lab/special.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 946277b8f0..32abde2cb0 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -284,6 +284,8 @@ void LabEngine::doJournal() { delete[] _blankJournal; delete[] _journalBackImage->_imageData; + _blankJournal = _journalBackImage->_imageData = nullptr; + _event->freeButtonList(&_journalButtonList); _graphics->closeFont(&_journalFont); -- cgit v1.2.3 From 108cbce3b5b8d4c5613e92c53e041972afcdc869 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 22 Dec 2015 00:43:53 +0100 Subject: LAB: Remove useless assignments --- engines/lab/special.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 32abde2cb0..900c2b354b 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -85,9 +85,9 @@ void LabEngine::doWestPaper() { paperFont = _resource->getFont("F:Note.fon"); paperText = _resource->getText("Lab:Rooms/Col1"); - charsPrinted = _graphics->flowText(paperFont, -4, 0, 0, false, false, false, true, _utils->vgaRectScale(45, y, 158, 148), paperText.c_str()); + _graphics->flowText(paperFont, -4, 0, 0, false, false, false, true, _utils->vgaRectScale(45, y, 158, 148), paperText.c_str()); paperText = _resource->getText("Lab:Rooms/Col2"); - charsPrinted = _graphics->flowText(paperFont, -4, 0, 0, false, false, false, true, _utils->vgaRectScale(162, y, 275, 148), paperText.c_str()); + _graphics->flowText(paperFont, -4, 0, 0, false, false, false, true, _utils->vgaRectScale(162, y, 275, 148), paperText.c_str()); _graphics->closeFont(&paperFont); _graphics->setPalette(_anim->_diffPalette, 256); -- cgit v1.2.3 From 503b63386628257ab79374afe4f7cca2b72b2527 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 22 Dec 2015 01:37:41 +0100 Subject: LAB: Remove useless casts and dead code --- engines/lab/special.cpp | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 900c2b354b..9a21ee786a 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -86,10 +86,11 @@ void LabEngine::doWestPaper() { paperFont = _resource->getFont("F:Note.fon"); paperText = _resource->getText("Lab:Rooms/Col1"); _graphics->flowText(paperFont, -4, 0, 0, false, false, false, true, _utils->vgaRectScale(45, y, 158, 148), paperText.c_str()); + paperText = _resource->getText("Lab:Rooms/Col2"); _graphics->flowText(paperFont, -4, 0, 0, false, false, false, true, _utils->vgaRectScale(162, y, 275, 148), paperText.c_str()); - _graphics->closeFont(&paperFont); + _graphics->closeFont(&paperFont); _graphics->setPalette(_anim->_diffPalette, 256); } @@ -130,10 +131,9 @@ void LabEngine::loadJournalData() { _journalTextTitle = _resource->getText("Lab:Rooms/jt"); Common::File *journalFile = _resource->openDataFile("P:JImage"); - Utils *utils = _utils; - _journalButtonList.push_back(_event->createButton( 80, utils->vgaScaleY(162) + utils->svgaCord(1), 0, VKEY_LTARROW, new Image(journalFile, this), new Image(journalFile, this))); // back - _journalButtonList.push_back(_event->createButton(194, utils->vgaScaleY(162) + utils->svgaCord(1), 2, 0, new Image(journalFile, this), new Image(journalFile, this))); // cancel - _journalButtonList.push_back(_event->createButton(144, utils->vgaScaleY(164) - utils->svgaCord(1), 1, VKEY_RTARROW, new Image(journalFile, this), new Image(journalFile, this))); // forward + _journalButtonList.push_back(_event->createButton( 80, _utils->vgaScaleY(162) + _utils->svgaCord(1), 0, VKEY_LTARROW, new Image(journalFile, this), new Image(journalFile, this))); // back + _journalButtonList.push_back(_event->createButton(194, _utils->vgaScaleY(162) + _utils->svgaCord(1), 2, 0, new Image(journalFile, this), new Image(journalFile, this))); // cancel + _journalButtonList.push_back(_event->createButton(144, _utils->vgaScaleY(164) - _utils->svgaCord(1), 1, VKEY_RTARROW, new Image(journalFile, this), new Image(journalFile, this))); // forward delete journalFile; _anim->_noPalChange = true; @@ -155,7 +155,7 @@ void LabEngine::drawJournalText() { while (drawingToPage < _journalPage) { _music->updateMusic(); - curText = (char *)(_journalText.c_str() + charsDrawn); + curText = _journalText.c_str() + charsDrawn; charsDrawn += _graphics->flowText(_journalFont, -2, 2, 0, false, false, false, false, _utils->vgaRectScale(52, 32, 152, 148), curText); _lastPage = (*curText == 0); @@ -170,17 +170,14 @@ void LabEngine::drawJournalText() { curText = _journalTextTitle.c_str(); _graphics->flowTextToMem(_journalBackImage, _journalFont, -2, 2, 0, false, true, true, true, _utils->vgaRectScale(52, 32, 152, 148), curText); } else { - curText = (char *)(_journalText.c_str() + charsDrawn); + curText = _journalText.c_str() + charsDrawn; charsDrawn += _graphics->flowTextToMem(_journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaRectScale(52, 32, 152, 148), curText); } _music->updateMusic(); - curText = (char *)(_journalText.c_str() + charsDrawn); + curText = _journalText.c_str() + charsDrawn; _lastPage = (*curText == 0); _graphics->flowTextToMem(_journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaRectScale(171, 32, 271, 148), curText); - - curText = (char *)(_journalText.c_str() + charsDrawn); - _lastPage = (*curText == 0); } void LabEngine::turnPage(bool fromLeft) { @@ -334,7 +331,7 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, Common::Rect text while (drawingToPage < _monitorPage) { _music->updateMusic(); - curText = (char *)(text + charsDrawn); + curText = text + charsDrawn; charsDrawn += _graphics->flowText(monitorFont, yspacing, 0, 0, false, false, false, false, textRect, curText); _lastPage = (*curText == 0); @@ -344,12 +341,9 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, Common::Rect text drawingToPage++; } - curText = (char *)(text + charsDrawn); + curText = text + charsDrawn; _lastPage = (*curText == 0); charsDrawn = _graphics->flowText(monitorFont, yspacing, 2, 0, false, false, false, true, textRect, curText); - curText += charsDrawn; - _lastPage |= (*curText == 0); - _event->mouseShow(); } -- cgit v1.2.3 From be4c436dcaa960bceedd6d526041df06919bc225 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 22 Dec 2015 19:40:34 +0100 Subject: LAB: Move event update functions out of updateMusic --- engines/lab/special.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 9a21ee786a..7615c2d073 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -99,7 +99,7 @@ void LabEngine::loadJournalData() { _graphics->closeFont(&_journalFont); _journalFont = _resource->getFont("F:Journal.fon"); - _music->updateMusic(); + updateMusicAndEvents(); Common::String filename = "Lab:Rooms/j0"; @@ -154,7 +154,7 @@ void LabEngine::drawJournalText() { const char *curText = _journalText.c_str(); while (drawingToPage < _journalPage) { - _music->updateMusic(); + updateMusicAndEvents(); curText = _journalText.c_str() + charsDrawn; charsDrawn += _graphics->flowText(_journalFont, -2, 2, 0, false, false, false, false, _utils->vgaRectScale(52, 32, 152, 148), curText); @@ -174,7 +174,7 @@ void LabEngine::drawJournalText() { charsDrawn += _graphics->flowTextToMem(_journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaRectScale(52, 32, 152, 148), curText); } - _music->updateMusic(); + updateMusicAndEvents(); curText = _journalText.c_str() + charsDrawn; _lastPage = (*curText == 0); _graphics->flowTextToMem(_journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaRectScale(171, 32, 271, 148), curText); @@ -183,14 +183,14 @@ void LabEngine::drawJournalText() { void LabEngine::turnPage(bool fromLeft) { if (fromLeft) { for (int i = 0; i < _graphics->_screenWidth; i += 8) { - _music->updateMusic(); + updateMusicAndEvents(); waitTOF(); _screenImage->_imageData = _graphics->getCurrentDrawingBuffer(); _journalBackImage->blitBitmap(i, 0, _screenImage, i, 0, 8, _graphics->_screenHeight, false); } } else { for (int i = (_graphics->_screenWidth - 8); i > 0; i -= 8) { - _music->updateMusic(); + updateMusicAndEvents(); waitTOF(); _screenImage->_imageData = _graphics->getCurrentDrawingBuffer(); _journalBackImage->blitBitmap(i, 0, _screenImage, i, 0, 8, _graphics->_screenHeight, false); @@ -200,7 +200,7 @@ void LabEngine::turnPage(bool fromLeft) { void LabEngine::drawJournal(uint16 wipenum, bool needFade) { _event->mouseHide(); - _music->updateMusic(); + updateMusicAndEvents(); drawJournalText(); _graphics->loadBackPict("P:Journal.pic", _highPalette); @@ -225,7 +225,7 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) { void LabEngine::processJournal() { while (1) { // Make sure we check the music at least after every message - _music->updateMusic(); + updateMusicAndEvents(); IntuiMessage *msg = _event->getMsg(); if (g_engine->shouldQuit()) { _quitLab = true; @@ -233,7 +233,7 @@ void LabEngine::processJournal() { } if (!msg) - _music->updateMusic(); + updateMusicAndEvents(); else { uint32 msgClass = msg->_msgClass; uint16 buttonId = msg->_code; @@ -269,7 +269,7 @@ void LabEngine::doJournal() { _journalBackImage->_imageData = nullptr; _screenImage->_imageData = _graphics->getCurrentDrawingBuffer(); - _music->updateMusic(); + updateMusicAndEvents(); loadJournalData(); _event->attachButtonList(&_journalButtonList); drawJournal(0, true); @@ -330,7 +330,7 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, Common::Rect text } while (drawingToPage < _monitorPage) { - _music->updateMusic(); + updateMusicAndEvents(); curText = text + charsDrawn; charsDrawn += _graphics->flowText(monitorFont, yspacing, 0, 0, false, false, false, false, textRect, curText); _lastPage = (*curText == 0); @@ -377,7 +377,7 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isIntera } // Make sure we check the music at least after every message - _music->updateMusic(); + updateMusicAndEvents(); IntuiMessage *msg = _event->getMsg(); if (g_engine->shouldQuit()) { _quitLab = true; @@ -385,7 +385,7 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isIntera } if (!msg) { - _music->updateMusic(); + updateMusicAndEvents(); } else { uint32 msgClass = msg->_msgClass; uint16 mouseX = msg->_mouse.x; -- cgit v1.2.3 From 29d85c8d50967df907f2a12e87ad78abfa707be4 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 23 Dec 2015 21:44:48 +0200 Subject: LAB: Use int in for loops, instead of uint16 --- engines/lab/special.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 7615c2d073..649c725102 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -319,7 +319,7 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, Common::Rect text _graphics->setPen(0); _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, textRect.bottom); - for (uint16 i = 0; i < numlines; i++) + for (int i = 0; i < numlines; i++) _monitorButton->drawImage(0, i * _monitorButtonHeight); } else if (isinteractive) { _graphics->setPen(0); -- cgit v1.2.3 From 10d9d8dee5104736da53a2807f3367b13731ad8f Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Wed, 23 Dec 2015 21:51:39 +0100 Subject: LAB: Fix warnings by adding consts --- engines/lab/special.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 649c725102..7dd42dcf9b 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -293,10 +293,10 @@ void LabEngine::doJournal() { _graphics->blackScreen(); } -void LabEngine::drawMonText(char *text, TextFont *monitorFont, Common::Rect textRect, bool isinteractive) { +void LabEngine::drawMonText(const char *text, TextFont *monitorFont, Common::Rect textRect, bool isinteractive) { uint16 drawingToPage = 0, yspacing = 0; int charsDrawn = 0; - char *curText = text; + const char *curText = text; _event->mouseHide(); @@ -347,7 +347,7 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, Common::Rect text _event->mouseShow(); } -void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isInteractive, Common::Rect textRect) { +void LabEngine::processMonitor(const char *ntext, TextFont *monitorFont, bool isInteractive, Common::Rect textRect) { Common::String startFileName = _monitorTextFilename; CloseDataPtr startClosePtr = _closeDataPtr, lastClosePtr[10]; uint16 depth = 0; @@ -371,7 +371,7 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isIntera Common::String text = _resource->getText(_monitorTextFilename); _graphics->fade(false, 0); - drawMonText((char *)text.c_str(), monitorFont, textRect, isInteractive); + drawMonText(text.c_str(), monitorFont, textRect, isInteractive); _graphics->fade(true, 0); } } @@ -461,10 +461,10 @@ void LabEngine::doMonitor(const Common::String background, const Common::String Common::String ntext = _resource->getText(textfile); _graphics->loadBackPict(background, _highPalette); - drawMonText((char *)ntext.c_str(), monitorFont, scaledRect, isinteractive); + drawMonText(ntext.c_str(), monitorFont, scaledRect, isinteractive); _event->mouseShow(); _graphics->fade(true, 0); - processMonitor((char *)ntext.c_str(), monitorFont, isinteractive, scaledRect); + processMonitor(ntext.c_str(), monitorFont, isinteractive, scaledRect); _graphics->fade(false, 0); _event->mouseHide(); _graphics->closeFont(&monitorFont); -- cgit v1.2.3 From 7c33862a099ffe9cfe308183ca6cd8e16f23b804 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 24 Dec 2015 00:41:53 +0200 Subject: LAB: The second parameter of fade() is always 0 --- engines/lab/special.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 7dd42dcf9b..cdbaa7b5bc 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -213,7 +213,7 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) { _event->toggleButton(_event->getButton(2), 15, (!_lastPage)); // forward button if (needFade) - _graphics->fade(true, 0); + _graphics->fade(true); // Reset the journal background, so that all the text that has been blitted on it is erased memcpy(_journalBackImage->_imageData, _blankJournal, _graphics->_screenWidth * _graphics->_screenHeight); @@ -276,7 +276,7 @@ void LabEngine::doJournal() { _event->mouseShow(); processJournal(); _event->attachButtonList(nullptr); - _graphics->fade(false, 0); + _graphics->fade(false); _event->mouseHide(); delete[] _blankJournal; @@ -370,9 +370,9 @@ void LabEngine::processMonitor(const char *ntext, TextFont *monitorFont, bool is _monitorTextFilename = test; Common::String text = _resource->getText(_monitorTextFilename); - _graphics->fade(false, 0); + _graphics->fade(false); drawMonText(text.c_str(), monitorFont, textRect, isInteractive); - _graphics->fade(true, 0); + _graphics->fade(true); } } @@ -463,9 +463,9 @@ void LabEngine::doMonitor(const Common::String background, const Common::String _graphics->loadBackPict(background, _highPalette); drawMonText(ntext.c_str(), monitorFont, scaledRect, isinteractive); _event->mouseShow(); - _graphics->fade(true, 0); + _graphics->fade(true); processMonitor(ntext.c_str(), monitorFont, isinteractive, scaledRect); - _graphics->fade(false, 0); + _graphics->fade(false); _event->mouseHide(); _graphics->closeFont(&monitorFont); -- cgit v1.2.3 From 997150e76e562438f0d939f54fd1e3fb89b1e005 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 24 Dec 2015 01:12:39 +0100 Subject: LAB: Change the initial valueof _screenBytesPerPage, use it in Journal functions --- engines/lab/special.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index cdbaa7b5bc..857b604f01 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -137,13 +137,13 @@ void LabEngine::loadJournalData() { delete journalFile; _anim->_noPalChange = true; - _journalBackImage->_imageData = new byte[_graphics->_screenWidth * _graphics->_screenHeight]; + _journalBackImage->_imageData = new byte[_graphics->_screenBytesPerPage]; _graphics->readPict("P:Journal.pic", true, false, _journalBackImage->_imageData); _anim->_noPalChange = false; // Keep a copy of the blank journal - _blankJournal = new byte[_graphics->_screenWidth * _graphics->_screenHeight]; - memcpy(_blankJournal, _journalBackImage->_imageData, _graphics->_screenWidth * _graphics->_screenHeight); + _blankJournal = new byte[_graphics->_screenBytesPerPage]; + memcpy(_blankJournal, _journalBackImage->_imageData, _graphics->_screenBytesPerPage); _screenImage->_imageData = _graphics->getCurrentDrawingBuffer(); } @@ -216,7 +216,7 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) { _graphics->fade(true); // Reset the journal background, so that all the text that has been blitted on it is erased - memcpy(_journalBackImage->_imageData, _blankJournal, _graphics->_screenWidth * _graphics->_screenHeight); + memcpy(_journalBackImage->_imageData, _blankJournal, _graphics->_screenBytesPerPage); eatMessages(); _event->mouseShow(); -- cgit v1.2.3 From 0bf89c1eecee3df0e50010124522349ccdf8b641 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 24 Dec 2015 01:21:40 +0100 Subject: LAB: Cleanup the way shouldQuit is called --- engines/lab/special.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 857b604f01..716628661c 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -227,7 +227,7 @@ void LabEngine::processJournal() { // Make sure we check the music at least after every message updateMusicAndEvents(); IntuiMessage *msg = _event->getMsg(); - if (g_engine->shouldQuit()) { + if (shouldQuit()) { _quitLab = true; return; } @@ -379,7 +379,7 @@ void LabEngine::processMonitor(const char *ntext, TextFont *monitorFont, bool is // Make sure we check the music at least after every message updateMusicAndEvents(); IntuiMessage *msg = _event->getMsg(); - if (g_engine->shouldQuit()) { + if (shouldQuit()) { _quitLab = true; return; } -- cgit v1.2.3 From 7216bddd56d48a4e0ec1f92d9a261943eb8ea072 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 24 Dec 2015 12:08:51 +0200 Subject: LAB: Merge setPen() into rectFill() --- engines/lab/special.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 716628661c..301ed59065 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -288,8 +288,7 @@ void LabEngine::doJournal() { _screenImage->_imageData = _graphics->getCurrentDrawingBuffer(); - _graphics->setPen(0); - _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1); + _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1, 0); _graphics->blackScreen(); } @@ -316,17 +315,14 @@ void LabEngine::drawMonText(const char *text, TextFont *monitorFont, Common::Rec else _monitorButtonHeight = fheight; - _graphics->setPen(0); - _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, textRect.bottom); + _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, textRect.bottom, 0); for (int i = 0; i < numlines; i++) _monitorButton->drawImage(0, i * _monitorButtonHeight); } else if (isinteractive) { - _graphics->setPen(0); - _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, textRect.bottom); + _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, textRect.bottom, 0); } else { - _graphics->setPen(0); - _graphics->rectFill(textRect); + _graphics->rectFill(textRect, 0); } while (drawingToPage < _monitorPage) { @@ -469,8 +465,7 @@ void LabEngine::doMonitor(const Common::String background, const Common::String _event->mouseHide(); _graphics->closeFont(&monitorFont); - _graphics->setPen(0); - _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1); + _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1, 0); _graphics->blackAllScreen(); _graphics->freePict(); } -- cgit v1.2.3 From 4b3e671de564b447eae23bfcdb3ce365ba5dd9a0 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 24 Dec 2015 12:27:56 +0200 Subject: LAB: Merge flowTextToMem() inside flowText() --- engines/lab/special.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 301ed59065..be371c6e3c 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -168,16 +168,16 @@ void LabEngine::drawJournalText() { if (_journalPage <= 1) { curText = _journalTextTitle.c_str(); - _graphics->flowTextToMem(_journalBackImage, _journalFont, -2, 2, 0, false, true, true, true, _utils->vgaRectScale(52, 32, 152, 148), curText); + _graphics->flowText(_journalFont, -2, 2, 0, false, true, true, true, _utils->vgaRectScale(52, 32, 152, 148), curText, _journalBackImage); } else { curText = _journalText.c_str() + charsDrawn; - charsDrawn += _graphics->flowTextToMem(_journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaRectScale(52, 32, 152, 148), curText); + charsDrawn += _graphics->flowText(_journalFont, -2, 2, 0, false, false, false, true, _utils->vgaRectScale(52, 32, 152, 148), curText, _journalBackImage); } updateMusicAndEvents(); curText = _journalText.c_str() + charsDrawn; _lastPage = (*curText == 0); - _graphics->flowTextToMem(_journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaRectScale(171, 32, 271, 148), curText); + _graphics->flowText(_journalFont, -2, 2, 0, false, false, false, true, _utils->vgaRectScale(171, 32, 271, 148), curText, _journalBackImage); } void LabEngine::turnPage(bool fromLeft) { -- cgit v1.2.3 From f018b44ff869cc774923818caccf203ff9c56e0b Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 24 Dec 2015 12:29:23 +0200 Subject: LAB: Fix loading of journal text --- engines/lab/special.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index be371c6e3c..8c69fb4034 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -101,7 +101,7 @@ void LabEngine::loadJournalData() { _journalFont = _resource->getFont("F:Journal.fon"); updateMusicAndEvents(); - Common::String filename = "Lab:Rooms/j0"; + Common::String filename = "Lab:Rooms/j"; bool bridge = _conditions->in(BRIDGE0) || _conditions->in(BRIDGE1); bool dirty = _conditions->in(DIRTY); @@ -126,6 +126,8 @@ void LabEngine::loadJournalData() { filename += '3'; else if (bridge) filename += '1'; + else + filename += '0'; _journalText = _resource->getText(filename); _journalTextTitle = _resource->getText("Lab:Rooms/jt"); -- cgit v1.2.3 From 3097ac8f1e336193755b2386506842ef76951b13 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 24 Dec 2015 12:36:26 +0200 Subject: LAB: Change condition defines into an enum --- engines/lab/special.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 8c69fb4034..de9f1d9786 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -41,11 +41,6 @@ #include "lab/utils.h" namespace Lab { -#define BRIDGE0 148 -#define BRIDGE1 104 -#define DIRTY 175 -#define NONEWS 135 -#define NOCLEAN 152 void LabEngine::doNotes() { TextFont *noteFont = _resource->getFont("F:Note.fon"); @@ -103,10 +98,10 @@ void LabEngine::loadJournalData() { Common::String filename = "Lab:Rooms/j"; - bool bridge = _conditions->in(BRIDGE0) || _conditions->in(BRIDGE1); - bool dirty = _conditions->in(DIRTY); - bool news = !_conditions->in(NONEWS); - bool clean = !_conditions->in(NOCLEAN); + bool bridge = _conditions->in(kCondBridge0) || _conditions->in(kCondBridge1); + bool dirty = _conditions->in(kCondDirty); + bool news = !_conditions->in(kCondNoNews); + bool clean = !_conditions->in(kCondNoClean); if (bridge && clean && news) filename += '8'; -- cgit v1.2.3 From 8b45875e245f8eba2403987cdb4ba128720048a9 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 24 Dec 2015 13:00:10 +0200 Subject: LAB: Get rid of _screenImage Thanks to wjp for finding this --- engines/lab/special.cpp | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index de9f1d9786..9a631e4980 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -141,8 +141,6 @@ void LabEngine::loadJournalData() { // Keep a copy of the blank journal _blankJournal = new byte[_graphics->_screenBytesPerPage]; memcpy(_blankJournal, _journalBackImage->_imageData, _graphics->_screenBytesPerPage); - - _screenImage->_imageData = _graphics->getCurrentDrawingBuffer(); } void LabEngine::drawJournalText() { @@ -182,15 +180,13 @@ void LabEngine::turnPage(bool fromLeft) { for (int i = 0; i < _graphics->_screenWidth; i += 8) { updateMusicAndEvents(); waitTOF(); - _screenImage->_imageData = _graphics->getCurrentDrawingBuffer(); - _journalBackImage->blitBitmap(i, 0, _screenImage, i, 0, 8, _graphics->_screenHeight, false); + _journalBackImage->blitBitmap(i, 0, nullptr, i, 0, 8, _graphics->_screenHeight, false); } } else { for (int i = (_graphics->_screenWidth - 8); i > 0; i -= 8) { updateMusicAndEvents(); waitTOF(); - _screenImage->_imageData = _graphics->getCurrentDrawingBuffer(); - _journalBackImage->blitBitmap(i, 0, _screenImage, i, 0, 8, _graphics->_screenHeight, false); + _journalBackImage->blitBitmap(i, 0, nullptr, i, 0, 8, _graphics->_screenHeight, false); } } } @@ -202,7 +198,7 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) { _graphics->loadBackPict("P:Journal.pic", _highPalette); if (wipenum == 0) - _journalBackImage->blitBitmap(0, 0, _screenImage, 0, 0, _graphics->_screenWidth, _graphics->_screenHeight, false); + _journalBackImage->blitBitmap(0, 0, nullptr, 0, 0, _graphics->_screenWidth, _graphics->_screenHeight, false); else turnPage((wipenum == 1)); @@ -261,10 +257,9 @@ void LabEngine::doJournal() { _graphics->blackAllScreen(); _lastPage = false; - _screenImage->_width = _journalBackImage->_width = _graphics->_screenWidth; - _screenImage->_height = _journalBackImage->_height = _graphics->_screenHeight; + _journalBackImage->_width = _graphics->_screenWidth; + _journalBackImage->_height = _graphics->_screenHeight; _journalBackImage->_imageData = nullptr; - _screenImage->_imageData = _graphics->getCurrentDrawingBuffer(); updateMusicAndEvents(); loadJournalData(); @@ -283,8 +278,6 @@ void LabEngine::doJournal() { _event->freeButtonList(&_journalButtonList); _graphics->closeFont(&_journalFont); - _screenImage->_imageData = _graphics->getCurrentDrawingBuffer(); - _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1, 0); _graphics->blackScreen(); } -- cgit v1.2.3 From 6ace70a625b76f0b2471b73d702649fbf0cfe7a0 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Thu, 24 Dec 2015 15:26:17 +0100 Subject: LAB: Clarify and clean up drawJournalText --- engines/lab/special.cpp | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 9a631e4980..dd2ee1cf4e 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -145,34 +145,38 @@ void LabEngine::loadJournalData() { void LabEngine::drawJournalText() { uint16 drawingToPage = 1; - int charsDrawn = 0; const char *curText = _journalText.c_str(); + assert((_journalPage & 1) == 0); + while (drawingToPage < _journalPage) { updateMusicAndEvents(); - curText = _journalText.c_str() + charsDrawn; - charsDrawn += _graphics->flowText(_journalFont, -2, 2, 0, false, false, false, false, _utils->vgaRectScale(52, 32, 152, 148), curText); + + // flowText without output + curText += _graphics->flowText(_journalFont, -2, 2, 0, false, false, false, false, _utils->vgaRectScale(52, 32, 152, 148), curText); _lastPage = (*curText == 0); - if (_lastPage) + if (_lastPage) { + // Reset _journalPage to this page, in case it was set too high _journalPage = (drawingToPage / 2) * 2; - else - drawingToPage++; + break; + } + + drawingToPage++; } - if (_journalPage <= 1) { - curText = _journalTextTitle.c_str(); - _graphics->flowText(_journalFont, -2, 2, 0, false, true, true, true, _utils->vgaRectScale(52, 32, 152, 148), curText, _journalBackImage); + if (_journalPage == 0) { + // draw title page centered + _graphics->flowText(_journalFont, -2, 2, 0, false, true, true, true, _utils->vgaRectScale(52, 32, 152, 148), _journalTextTitle.c_str(), _journalBackImage); } else { - curText = _journalText.c_str() + charsDrawn; - charsDrawn += _graphics->flowText(_journalFont, -2, 2, 0, false, false, false, true, _utils->vgaRectScale(52, 32, 152, 148), curText, _journalBackImage); + curText += _graphics->flowText(_journalFont, -2, 2, 0, false, false, false, true, _utils->vgaRectScale(52, 32, 152, 148), curText, _journalBackImage); } updateMusicAndEvents(); - curText = _journalText.c_str() + charsDrawn; + curText += _graphics->flowText(_journalFont, -2, 2, 0, false, false, false, true, _utils->vgaRectScale(171, 32, 271, 148), curText, _journalBackImage); + _lastPage = (*curText == 0); - _graphics->flowText(_journalFont, -2, 2, 0, false, false, false, true, _utils->vgaRectScale(171, 32, 271, 148), curText, _journalBackImage); } void LabEngine::turnPage(bool fromLeft) { -- cgit v1.2.3 From 19303c49cf8284a7c56f08f0902a8c4cf71f8f32 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 24 Dec 2015 18:30:54 +0200 Subject: LAB: Rename closeFont() to freeFont() --- engines/lab/special.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index dd2ee1cf4e..81d6bead84 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -49,7 +49,7 @@ void LabEngine::doNotes() { Common::Rect textRect = Common::Rect(_utils->vgaScaleX(25) + _utils->svgaCord(15), _utils->vgaScaleY(50), _utils->vgaScaleX(295) - _utils->svgaCord(15), _utils->vgaScaleY(148)); _graphics->flowText(noteFont, -2 + _utils->svgaCord(1), 0, 0, false, false, true, true, textRect, noteText.c_str()); _graphics->setPalette(_anim->_diffPalette, 256); - _graphics->closeFont(¬eFont); + _graphics->freeFont(¬eFont); } void LabEngine::doWestPaper() { @@ -58,7 +58,7 @@ void LabEngine::doWestPaper() { Common::Rect textRect = Common::Rect(_utils->vgaScaleX(57), _utils->vgaScaleY(77) + _utils->svgaCord(2), _utils->vgaScaleX(262), _utils->vgaScaleY(91)); _graphics->flowText(paperFont, 0, 0, 0, false, true, false, true, textRect, paperText.c_str()); - _graphics->closeFont(&paperFont); + _graphics->freeFont(&paperFont); paperFont = _resource->getFont("F:News32.fon"); paperText = _resource->getText("Lab:Rooms/Headline"); @@ -76,7 +76,7 @@ void LabEngine::doWestPaper() { } else y = 115 - _utils->svgaCord(5); - _graphics->closeFont(&paperFont); + _graphics->freeFont(&paperFont); paperFont = _resource->getFont("F:Note.fon"); paperText = _resource->getText("Lab:Rooms/Col1"); @@ -85,13 +85,13 @@ void LabEngine::doWestPaper() { paperText = _resource->getText("Lab:Rooms/Col2"); _graphics->flowText(paperFont, -4, 0, 0, false, false, false, true, _utils->vgaRectScale(162, y, 275, 148), paperText.c_str()); - _graphics->closeFont(&paperFont); + _graphics->freeFont(&paperFont); _graphics->setPalette(_anim->_diffPalette, 256); } void LabEngine::loadJournalData() { if (_journalFont) - _graphics->closeFont(&_journalFont); + _graphics->freeFont(&_journalFont); _journalFont = _resource->getFont("F:Journal.fon"); updateMusicAndEvents(); @@ -280,7 +280,7 @@ void LabEngine::doJournal() { _blankJournal = _journalBackImage->_imageData = nullptr; _event->freeButtonList(&_journalButtonList); - _graphics->closeFont(&_journalFont); + _graphics->freeFont(&_journalFont); _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1, 0); _graphics->blackScreen(); @@ -457,7 +457,7 @@ void LabEngine::doMonitor(const Common::String background, const Common::String processMonitor(ntext.c_str(), monitorFont, isinteractive, scaledRect); _graphics->fade(false); _event->mouseHide(); - _graphics->closeFont(&monitorFont); + _graphics->freeFont(&monitorFont); _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1, 0); _graphics->blackAllScreen(); -- cgit v1.2.3 From a5553b319706e2421202fecd44d3a771ebc22ebf Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 24 Dec 2015 19:12:02 +0200 Subject: Use Common::Keycode and enums in interface buttons --- engines/lab/special.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 81d6bead84..e15561d9fb 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -128,9 +128,9 @@ void LabEngine::loadJournalData() { _journalTextTitle = _resource->getText("Lab:Rooms/jt"); Common::File *journalFile = _resource->openDataFile("P:JImage"); - _journalButtonList.push_back(_event->createButton( 80, _utils->vgaScaleY(162) + _utils->svgaCord(1), 0, VKEY_LTARROW, new Image(journalFile, this), new Image(journalFile, this))); // back - _journalButtonList.push_back(_event->createButton(194, _utils->vgaScaleY(162) + _utils->svgaCord(1), 2, 0, new Image(journalFile, this), new Image(journalFile, this))); // cancel - _journalButtonList.push_back(_event->createButton(144, _utils->vgaScaleY(164) - _utils->svgaCord(1), 1, VKEY_RTARROW, new Image(journalFile, this), new Image(journalFile, this))); // forward + _journalButtonList.push_back(_event->createButton( 80, _utils->vgaScaleY(162) + _utils->svgaCord(1), 0, Common::KEYCODE_LEFT, new Image(journalFile, this), new Image(journalFile, this))); // back + _journalButtonList.push_back(_event->createButton(194, _utils->vgaScaleY(162) + _utils->svgaCord(1), 2, Common::KEYCODE_ESCAPE, new Image(journalFile, this), new Image(journalFile, this))); // cancel + _journalButtonList.push_back(_event->createButton(144, _utils->vgaScaleY(164) - _utils->svgaCord(1), 1, Common::KEYCODE_RIGHT, new Image(journalFile, this), new Image(journalFile, this))); // forward delete journalFile; _anim->_noPalChange = true; -- cgit v1.2.3 From 33ed5af212d5cfb878559d1736fab91a4762f46b Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Sat, 26 Dec 2015 15:14:37 +0100 Subject: LAB: Remove type ConstDataPtr, add consts --- engines/lab/special.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index e15561d9fb..e99c4dffa3 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -339,7 +339,7 @@ void LabEngine::drawMonText(const char *text, TextFont *monitorFont, Common::Rec void LabEngine::processMonitor(const char *ntext, TextFont *monitorFont, bool isInteractive, Common::Rect textRect) { Common::String startFileName = _monitorTextFilename; - CloseDataPtr startClosePtr = _closeDataPtr, lastClosePtr[10]; + const CloseData *startClosePtr = _closeDataPtr, *lastClosePtr[10]; uint16 depth = 0; lastClosePtr[0] = _closeDataPtr; @@ -414,7 +414,7 @@ void LabEngine::processMonitor(const char *ntext, TextFont *monitorFont, bool is drawMonText(ntext, monitorFont, textRect, isInteractive); } } else if (isInteractive) { - CloseDataPtr tmpClosePtr = _closeDataPtr; + const CloseData *tmpClosePtr = _closeDataPtr; mouseY = 64 + (mouseY / _monitorButtonHeight) * 42; mouseX = 101; setCurrentClose(Common::Point(mouseX, mouseY), &_closeDataPtr, false); -- cgit v1.2.3 From 90ac7a2bcb620eb29194eb94458f45d48e794c59 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Sat, 26 Dec 2015 21:59:10 +0100 Subject: LAB: Clean up Image._imageData memory handling --- engines/lab/special.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index e99c4dffa3..62eeb75bb3 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -134,7 +134,7 @@ void LabEngine::loadJournalData() { delete journalFile; _anim->_noPalChange = true; - _journalBackImage->_imageData = new byte[_graphics->_screenBytesPerPage]; + _journalBackImage->setData(new byte[_graphics->_screenBytesPerPage]); _graphics->readPict("P:Journal.pic", true, false, _journalBackImage->_imageData); _anim->_noPalChange = false; @@ -263,7 +263,7 @@ void LabEngine::doJournal() { _journalBackImage->_width = _graphics->_screenWidth; _journalBackImage->_height = _graphics->_screenHeight; - _journalBackImage->_imageData = nullptr; + _journalBackImage->setData(nullptr, true); updateMusicAndEvents(); loadJournalData(); @@ -276,8 +276,8 @@ void LabEngine::doJournal() { _event->mouseHide(); delete[] _blankJournal; - delete[] _journalBackImage->_imageData; - _blankJournal = _journalBackImage->_imageData = nullptr; + _blankJournal = nullptr; + _journalBackImage->setData(nullptr, true); _event->freeButtonList(&_journalButtonList); _graphics->freeFont(&_journalFont); -- cgit v1.2.3 From 9bc8d25b024693434835c6f9012719c2f2f4bbe3 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 27 Dec 2015 11:00:05 +0100 Subject: LAB: Remove a useless assignment --- engines/lab/special.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 62eeb75bb3..5f5b523fb0 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -333,7 +333,7 @@ void LabEngine::drawMonText(const char *text, TextFont *monitorFont, Common::Rec curText = text + charsDrawn; _lastPage = (*curText == 0); - charsDrawn = _graphics->flowText(monitorFont, yspacing, 2, 0, false, false, false, true, textRect, curText); + _graphics->flowText(monitorFont, yspacing, 2, 0, false, false, false, true, textRect, curText); _event->mouseShow(); } -- cgit v1.2.3 From c0e64a091a68cfd4a8764204d99a3e0a04c19ebd Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 27 Dec 2015 11:20:54 +0100 Subject: LAB: Review the variable types used in Special, reduce the scope of some variables --- engines/lab/special.cpp | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 5f5b523fb0..8e503665c7 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -232,13 +232,13 @@ void LabEngine::processJournal() { if (!msg) updateMusicAndEvents(); else { - uint32 msgClass = msg->_msgClass; - uint16 buttonId = msg->_code; + MessageClass msgClass = msg->_msgClass; if ((msgClass == kMessageRightClick) || - ((msgClass == kMessageRawKey) && (buttonId == Common::KEYCODE_ESCAPE))) + ((msgClass == kMessageRawKey) && (msg->_code == Common::KEYCODE_ESCAPE))) return; else if (msgClass == kMessageButtonUp) { + uint16 buttonId = msg->_code; if (buttonId == 0) { if (_journalPage >= 2) { _journalPage -= 2; @@ -349,15 +349,15 @@ void LabEngine::processMonitor(const char *ntext, TextFont *monitorFont, bool is if (!_closeDataPtr) _closeDataPtr = startClosePtr; - Common::String test; + Common::String filename; if (_closeDataPtr == startClosePtr) - test = startFileName; + filename = startFileName; else - test = _closeDataPtr->_graphicName; + filename = _closeDataPtr->_graphicName; - if (test != _monitorTextFilename) { + if (filename != _monitorTextFilename) { _monitorPage = 0; - _monitorTextFilename = test; + _monitorTextFilename = filename; Common::String text = _resource->getText(_monitorTextFilename); _graphics->fade(false); @@ -374,22 +374,24 @@ void LabEngine::processMonitor(const char *ntext, TextFont *monitorFont, bool is return; } - if (!msg) { + if (!msg) updateMusicAndEvents(); - } else { - uint32 msgClass = msg->_msgClass; - uint16 mouseX = msg->_mouse.x; - uint16 mouseY = msg->_mouse.y; - uint16 code = msg->_code; + else { + MessageClass msgClass = msg->_msgClass; if ((msgClass == kMessageRightClick) || - ((msgClass == kMessageRawKey) && (code == Common::KEYCODE_ESCAPE))) + ((msgClass == kMessageRawKey) && (msg->_code == Common::KEYCODE_ESCAPE))) return; - else if (msgClass == kMessageLeftClick) { + + if (msgClass == kMessageLeftClick) { + int16 mouseX = msg->_mouse.x; + int16 mouseY = msg->_mouse.y; + if ((mouseY >= _utils->vgaScaleY(171)) && (mouseY <= _utils->vgaScaleY(200))) { - if (mouseX <= _utils->vgaScaleX(31)) { + if (mouseX <= _utils->vgaScaleX(31)) return; - } else if (mouseX <= _utils->vgaScaleX(59)) { + + if (mouseX <= _utils->vgaScaleX(59)) { if (isInteractive) { _monitorPage = 0; @@ -409,7 +411,7 @@ void LabEngine::processMonitor(const char *ntext, TextFont *monitorFont, bool is drawMonText(ntext, monitorFont, textRect, isInteractive); } } else if (_monitorPage >= 1) { - // mouseX between 290 and 320 (scaled) + // mouseX is greater than 290 (scaled) _monitorPage -= 1; drawMonText(ntext, monitorFont, textRect, isInteractive); } -- cgit v1.2.3 From c5f5fbc208d473d87d42edd64113728bf26153b1 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sun, 27 Dec 2015 21:12:41 +0200 Subject: LAB: Refactor the music code --- engines/lab/special.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 8e503665c7..76b6cbbd1e 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -94,7 +94,7 @@ void LabEngine::loadJournalData() { _graphics->freeFont(&_journalFont); _journalFont = _resource->getFont("F:Journal.fon"); - updateMusicAndEvents(); + updateEvents(); Common::String filename = "Lab:Rooms/j"; @@ -150,7 +150,7 @@ void LabEngine::drawJournalText() { assert((_journalPage & 1) == 0); while (drawingToPage < _journalPage) { - updateMusicAndEvents(); + updateEvents(); // flowText without output curText += _graphics->flowText(_journalFont, -2, 2, 0, false, false, false, false, _utils->vgaRectScale(52, 32, 152, 148), curText); @@ -173,7 +173,7 @@ void LabEngine::drawJournalText() { curText += _graphics->flowText(_journalFont, -2, 2, 0, false, false, false, true, _utils->vgaRectScale(52, 32, 152, 148), curText, _journalBackImage); } - updateMusicAndEvents(); + updateEvents(); curText += _graphics->flowText(_journalFont, -2, 2, 0, false, false, false, true, _utils->vgaRectScale(171, 32, 271, 148), curText, _journalBackImage); _lastPage = (*curText == 0); @@ -182,13 +182,13 @@ void LabEngine::drawJournalText() { void LabEngine::turnPage(bool fromLeft) { if (fromLeft) { for (int i = 0; i < _graphics->_screenWidth; i += 8) { - updateMusicAndEvents(); + updateEvents(); waitTOF(); _journalBackImage->blitBitmap(i, 0, nullptr, i, 0, 8, _graphics->_screenHeight, false); } } else { for (int i = (_graphics->_screenWidth - 8); i > 0; i -= 8) { - updateMusicAndEvents(); + updateEvents(); waitTOF(); _journalBackImage->blitBitmap(i, 0, nullptr, i, 0, 8, _graphics->_screenHeight, false); } @@ -197,7 +197,7 @@ void LabEngine::turnPage(bool fromLeft) { void LabEngine::drawJournal(uint16 wipenum, bool needFade) { _event->mouseHide(); - updateMusicAndEvents(); + updateEvents(); drawJournalText(); _graphics->loadBackPict("P:Journal.pic", _highPalette); @@ -222,7 +222,7 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) { void LabEngine::processJournal() { while (1) { // Make sure we check the music at least after every message - updateMusicAndEvents(); + updateEvents(); IntuiMessage *msg = _event->getMsg(); if (shouldQuit()) { _quitLab = true; @@ -230,7 +230,7 @@ void LabEngine::processJournal() { } if (!msg) - updateMusicAndEvents(); + updateEvents(); else { MessageClass msgClass = msg->_msgClass; @@ -265,7 +265,7 @@ void LabEngine::doJournal() { _journalBackImage->_height = _graphics->_screenHeight; _journalBackImage->setData(nullptr, true); - updateMusicAndEvents(); + updateEvents(); loadJournalData(); _event->attachButtonList(&_journalButtonList); drawJournal(0, true); @@ -320,7 +320,7 @@ void LabEngine::drawMonText(const char *text, TextFont *monitorFont, Common::Rec } while (drawingToPage < _monitorPage) { - updateMusicAndEvents(); + updateEvents(); curText = text + charsDrawn; charsDrawn += _graphics->flowText(monitorFont, yspacing, 0, 0, false, false, false, false, textRect, curText); _lastPage = (*curText == 0); @@ -367,7 +367,7 @@ void LabEngine::processMonitor(const char *ntext, TextFont *monitorFont, bool is } // Make sure we check the music at least after every message - updateMusicAndEvents(); + updateEvents(); IntuiMessage *msg = _event->getMsg(); if (shouldQuit()) { _quitLab = true; @@ -375,7 +375,7 @@ void LabEngine::processMonitor(const char *ntext, TextFont *monitorFont, bool is } if (!msg) - updateMusicAndEvents(); + updateEvents(); else { MessageClass msgClass = msg->_msgClass; -- cgit v1.2.3 From bb34bc94eca65b3e5119dc278a250d5bc4744ad0 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sun, 27 Dec 2015 22:55:38 +0200 Subject: LAB: Fix the shortcut keys for the journal buttons --- engines/lab/special.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/lab/special.cpp') diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 76b6cbbd1e..43d6056125 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -128,9 +128,9 @@ void LabEngine::loadJournalData() { _journalTextTitle = _resource->getText("Lab:Rooms/jt"); Common::File *journalFile = _resource->openDataFile("P:JImage"); - _journalButtonList.push_back(_event->createButton( 80, _utils->vgaScaleY(162) + _utils->svgaCord(1), 0, Common::KEYCODE_LEFT, new Image(journalFile, this), new Image(journalFile, this))); // back - _journalButtonList.push_back(_event->createButton(194, _utils->vgaScaleY(162) + _utils->svgaCord(1), 2, Common::KEYCODE_ESCAPE, new Image(journalFile, this), new Image(journalFile, this))); // cancel - _journalButtonList.push_back(_event->createButton(144, _utils->vgaScaleY(164) - _utils->svgaCord(1), 1, Common::KEYCODE_RIGHT, new Image(journalFile, this), new Image(journalFile, this))); // forward + _journalButtonList.push_back(_event->createButton( 80, _utils->vgaScaleY(162) + _utils->svgaCord(1), 0, Common::KEYCODE_LEFT, new Image(journalFile, this), new Image(journalFile, this))); // back + _journalButtonList.push_back(_event->createButton(194, _utils->vgaScaleY(162) + _utils->svgaCord(1), 2, Common::KEYCODE_RIGHT, new Image(journalFile, this), new Image(journalFile, this))); // forward + _journalButtonList.push_back(_event->createButton(144, _utils->vgaScaleY(164) - _utils->svgaCord(1), 1, Common::KEYCODE_ESCAPE, new Image(journalFile, this), new Image(journalFile, this))); // cancel delete journalFile; _anim->_noPalChange = true; -- cgit v1.2.3