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/map.cpp | 955 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 955 insertions(+) create mode 100644 engines/lab/map.cpp (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp new file mode 100644 index 0000000000..f6e94990b5 --- /dev/null +++ b/engines/lab/map.cpp @@ -0,0 +1,955 @@ +/* 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/storage.h" +#include "lab/labfun.h" +#include "lab/diff.h" +#include "lab/vga.h" +#include "lab/text.h" +#include "lab/mouse.h" +#include "lab/parsefun.h" +#include "lab/parsetypes.h" +#include "lab/interface.h" +#include "lab/text.h" +#include "lab/stddefines.h" + +namespace Lab { + +static struct TextFont *BigMsgFont; +static struct TextFont bmf; + + +extern uint16 Direction; +extern bool IsHiRes; +extern uint32 VGAScreenWidth, VGAScreenHeight; + +#if !defined(DOSCODE) +extern CloseDataPtr CPtr; +extern uint16 RoomNum; +#endif + +/*****************************************************************************/ +/* Converts an Amiga palette (up to 16 colors) to a VGA palette, then sets */ +/* the VGA palette. */ +/*****************************************************************************/ +void setAmigaPal(uint16 *pal, uint16 numcolors) { + char vgapal[16 * 3]; + uint16 counter, vgacount; + + if (numcolors > 16) + numcolors = 16; + + vgacount = 0; + + for (counter = 0; counter < numcolors; counter++) { + vgapal[vgacount] = (char)(((pal[counter] & 0xf00) >> 8) << 2); + vgacount++; + vgapal[vgacount] = (char)(((pal[counter] & 0x0f0) >> 4) << 2); + vgacount++; + vgapal[vgacount] = (char)(((pal[counter] & 0x00f)) << 2); + vgacount++; + } + + writeColorRegsSmooth(vgapal, 0, 16); +} + + +/*****************************************************************************/ +/* Gets a font from disk and puts it into temporary memory. */ +/*****************************************************************************/ +bool getFont(const char *filename, TextFont *textfont) { + byte *fontbuffer; + + fontbuffer = (byte *)stealBufMem(sizeOfFile(filename) - + (sizeof(struct TextFont) + 4)); + g_music->checkMusic(); + + if (fontbuffer == NULL) + return false; + + return openFontMem(filename, textfont, fontbuffer); +} + + + + +/*****************************************************************************/ +/* Gets a chunk of text and puts it into the graphics memory. */ +/*****************************************************************************/ +char *getText(const char *filename) { + bool dodecrypt; + byte **tfile; + + g_music->checkMusic(); + dodecrypt = (isBuffered(filename) == NULL); + tfile = g_music->newOpen(filename); + + if (!tfile) + return NULL; + + if (dodecrypt) + decrypt(*tfile); + + return (char *)*tfile; +} + + + +/*****************************************************************************/ +/* Reads in an image from disk. */ +/*****************************************************************************/ +void readImage(byte **buffer, Image **im) { + uint32 size; + + (*im) = (Image *)(*buffer); + + (*im)->Width = READ_LE_UINT16(*buffer); + (*im)->Height = READ_LE_UINT16(*buffer + 2); + + *buffer += 8; /* sizeof(struct Image); */ + + size = (*im)->Width * (*im)->Height; + + if (1L & size) + size++; + + (*im)->ImageData = (byte *)(*buffer); + (*buffer) += size; +} + + + + + + +/*---------------------------------------------------------------------------*/ +/*------------------------------ The Map stuff ------------------------------*/ +/*---------------------------------------------------------------------------*/ + + + +extern RoomData *Rooms; +extern char *ViewPath; + +static Image *Map, *Room, *UpArrowRoom, *DownArrowRoom, *Bridge, + *HRoom, *VRoom, *Maze, *HugeMaze, *Path, *MapNorth, + *MapEast, *MapSouth, *MapWest, *XMark, *Back, *BackAlt, + *Down, *DownAlt, *Up, *UpAlt; + +static uint16 MaxRooms; +static MapData *Maps; + +extern char *LOWERFLOORS, *MIDDLEFLOORS, *UPPERFLOORS, *MEDMAZEFLOORS, *HEDGEMAZEFLOORS, *SURMAZEFLOORS, *CARNIVALFLOOR, *SURMAZEMSG; + +extern TextFont *MsgFont; + +uint16 *FadePalette; + +static uint16 MapGadX[3] = {101, 55, 8}, MapGadY[3] = {105, 105, 105}; +#if !defined(DOSCODE) +static Gadget downgadget = { 101, 105, 2, VKEY_DNARROW, 0L, NULL, NULL, NULL }, + upgadget = { 55, 105, 1, VKEY_UPARROW, 0L, NULL, NULL, &downgadget }, + backgadget = { 8, 105, 0, 0, 0L, NULL, NULL, &upgadget }, +#else +static Gadget downgadget = { 101, 105, 2, 0L, NULL, NULL, NULL }, + upgadget = { 55, 105, 1, 0L, NULL, NULL, &downgadget }, + backgadget = { 8, 105, 0, 0L, NULL, NULL, &upgadget }, +#endif +*MapGadgetList = &backgadget; + +static uint16 AmigaMapPalette[] = { + 0x0BA8, 0x0C11, 0x0A74, 0x0076, + 0x0A96, 0x0DCB, 0x0CCA, 0x0222, + 0x0444, 0x0555, 0x0777, 0x0999, + 0x0AAA, 0x0ED0, 0x0EEE, 0x0694 +}; + + +#define LOWERFLOOR 1 +#define MIDDLEFLOOR 2 +#define UPPERFLOOR 3 +#define MEDMAZEFLOOR 4 +#define HEDGEMAZEFLOOR 5 +#define SURMAZEFLOOR 6 +#define CARNIVAL 7 + + + +static uint16 mapScaleX(uint16 x) { + if (IsHiRes) + return (x - 45); + else + return ((x - 45) >> 1); +} + + + +static uint16 mapScaleY(uint16 y) { + if (IsHiRes) + return y; + else + return ((y - 35) >> 1) - (y >> 6); +} + + + + +/*****************************************************************************/ +/* Loads in the map data. */ +/*****************************************************************************/ +static bool loadMapData(void) { + byte **buffer, Temp[5]; + int32 Size; + struct Gadget *gptr; + uint16 counter; + + BigMsgFont = &bmf; + + if (!getFont("P:Map.fon", BigMsgFont)) + BigMsgFont = MsgFont; + + Size = sizeOfFile("P:MapImage"); + resetBuffer(); /* Make images load into start of buffer */ + buffer = g_music->newOpen("P:MapImage"); + + if (!buffer) + return false; + + stealBufMem(Size); /* Now freeze that buffer from further use */ + + readImage(buffer, &Map); + + readImage(buffer, &Room); + readImage(buffer, &UpArrowRoom); + readImage(buffer, &DownArrowRoom); + readImage(buffer, &HRoom); + readImage(buffer, &VRoom); + readImage(buffer, &Maze); + readImage(buffer, &HugeMaze); + + readImage(buffer, &MapNorth); + readImage(buffer, &MapEast); + readImage(buffer, &MapSouth); + readImage(buffer, &MapWest); + + readImage(buffer, &Path); + readImage(buffer, &Bridge); + + readImage(buffer, &Back); + readImage(buffer, &BackAlt); + readImage(buffer, &Up); + readImage(buffer, &UpAlt); + readImage(buffer, &Down); + readImage(buffer, &DownAlt); + + backgadget.Im = Back; + backgadget.ImAlt = BackAlt; + upgadget.Im = Up; + upgadget.ImAlt = UpAlt; + downgadget.Im = Down; + downgadget.ImAlt = DownAlt; + + counter = 0; + gptr = MapGadgetList; + + while (gptr) { + gptr->x = VGAScaleX(MapGadX[counter]); + gptr->y = VGAScaleY(MapGadY[counter]); + gptr = gptr->NextGadget; + counter++; + } + + buffer = g_music->newOpen("Lab:Maps"); + stealBufMem(sizeOfFile("Lab:Maps")); /* Freeze the memory for the maps */ + readBlock(Temp, 4L, buffer); + Temp[4] = 0; + + if (strcmp((char *)Temp, "MAP0") == 0) { + readBlock(&MaxRooms, 2L, buffer); +#if !defined(DOSCODE) + swapUShortPtr(&MaxRooms, 1); +#endif + Maps = (MapData *)(*buffer); +#if !defined(DOSCODE) + + for (counter = 1; counter <= MaxRooms; counter++) { + swapUShortPtr(&Maps[counter].x, 4); + swapULongPtr(&Maps[counter].MapFlags, 1); + } + +#endif + } else + return false; + + return true; +} + + + + +static uint16 fadeNumIn(uint16 num, uint16 res, uint16 counter) { + return (num - ((((int32)(15 - counter)) * ((int32)(num - res))) / 15)); +} + + +static uint16 fadeNumOut(uint16 num, uint16 res, uint16 counter) { + return (num - ((((int32) counter) * ((int32)(num - res))) / 15)); +} + + + +/*****************************************************************************/ +/* Does the fading of the Palette on the screen. */ +/*****************************************************************************/ +void fade(bool fadein, uint16 res) { + uint16 pennum, counter, newpal[16]; + + for (counter = 0; counter < 16; counter++) { + for (pennum = 0; pennum < 16; pennum++) { + if (fadein) + newpal[pennum] = (0x00F & fadeNumIn(0x00F & FadePalette[pennum], 0x00F & res, counter)) + + (0x0F0 & fadeNumIn(0x0F0 & FadePalette[pennum], 0x0F0 & res, counter)) + + (0xF00 & fadeNumIn(0xF00 & FadePalette[pennum], 0xF00 & res, counter)); + else + newpal[pennum] = (0x00F & fadeNumOut(0x00F & FadePalette[pennum], 0x00F & res, counter)) + + (0x0F0 & fadeNumOut(0x0F0 & FadePalette[pennum], 0x0F0 & res, counter)) + + (0xF00 & fadeNumOut(0xF00 & FadePalette[pennum], 0xF00 & res, counter)); + } + + setAmigaPal(newpal, 16); + waitTOF(); + g_music->updateMusic(); + } +} + + + +/*****************************************************************************/ +/* Figures out what a room's coordinates should be. */ +/*****************************************************************************/ +static void roomCords(uint16 CurRoom, uint16 *x1, uint16 *y1, uint16 *x2, uint16 *y2) { + *x1 = mapScaleX(Maps[CurRoom].x); + *y1 = mapScaleY(Maps[CurRoom].y); + *x2 = *x1; + *y2 = *y1; + + switch (Maps[CurRoom].SpecialID) { + case NORMAL: + case UPARROWROOM: + case DOWNARROWROOM: + (*x2) += Room->Width; + (*y2) += Room->Height; + break; + + case BRIDGEROOM: + (*x2) += Bridge->Width; + (*y2) += Bridge->Height; + break; + + case VCORRIDOR: + (*x2) += VRoom->Width; + (*y2) += VRoom->Height; + break; + + case HCORRIDOR: + (*x2) += HRoom->Width; + (*y2) += HRoom->Height; + break; + } +} + + + + + +/*****************************************************************************/ +/* Draws a room to the bitmap. */ +/*****************************************************************************/ +static void drawRoom(uint16 CurRoom, bool drawx) { + uint16 x, y, xx, xy, offset; + uint32 flags; + + x = mapScaleX(Maps[CurRoom].x); + y = mapScaleY(Maps[CurRoom].y); + flags = Maps[CurRoom].MapFlags; + + switch (Maps[CurRoom].SpecialID) { + case NORMAL: + case UPARROWROOM: + case DOWNARROWROOM: + if (Maps[CurRoom].SpecialID == NORMAL) + drawImage(Room, x, y); + else if (Maps[CurRoom].SpecialID == DOWNARROWROOM) + drawImage(DownArrowRoom, x, y); + else + drawImage(UpArrowRoom, x, y); + + offset = (Room->Width - Path->Width) / 2; + + if ((NORTHDOOR & flags) && (y >= Path->Height)) + drawImage(Path, x + offset, y - Path->Height); + + if (SOUTHDOOR & flags) + drawImage(Path, x + offset, y + Room->Height); + + offset = (Room->Height - Path->Height) / 2; + + if (EASTDOOR & flags) + drawImage(Path, x + Room->Width, y + offset); + + if (WESTDOOR & flags) + drawImage(Path, x - Path->Width, y + offset); + + xx = x + (Room->Width - XMark->Width) / 2; + xy = y + (Room->Height - XMark->Height) / 2; + + break; + + case BRIDGEROOM: + drawImage(Bridge, x, y); + + xx = x + (Bridge->Width - XMark->Width) / 2; + xy = y + (Bridge->Height - XMark->Height) / 2; + + break; + + case VCORRIDOR: + drawImage(VRoom, x, y); + + offset = (VRoom->Width - Path->Width) / 2; + + if (NORTHDOOR & flags) + drawImage(Path, x + offset, y - Path->Height); + + if (SOUTHDOOR & flags) + drawImage(Path, x + offset, y + VRoom->Height); + + offset = (Room->Height - Path->Height) / 2; + + if (EASTDOOR & flags) + drawImage(Path, x + VRoom->Width, y + offset); + + if (WESTDOOR & flags) + drawImage(Path, x - Path->Width, y + offset); + + if (EASTBDOOR & flags) + drawImage(Path, x + VRoom->Width, y - offset - Path->Height + VRoom->Height); + + if (WESTBDOOR & flags) + drawImage(Path, x - Path->Width, y - offset - Path->Height + VRoom->Height); + + offset = (VRoom->Height - Path->Height) / 2; + + if (EASTMDOOR & flags) + drawImage(Path, x + VRoom->Width, y - offset - Path->Height + VRoom->Height); + + if (WESTMDOOR & flags) + drawImage(Path, x - Path->Width, y - offset - Path->Height + VRoom->Height); + + xx = x + (VRoom->Width - XMark->Width) / 2; + xy = y + (VRoom->Height - XMark->Height) / 2; + + break; + + case HCORRIDOR: + drawImage(HRoom, x, y); + + offset = (Room->Width - Path->Width) / 2; + + if (NORTHDOOR & flags) + drawImage(Path, x + offset, y - Path->Height); + + if (SOUTHDOOR & flags) + drawImage(Path, x + offset, y + Room->Height); + + if (NORTHRDOOR & flags) + drawImage(Path, x - offset - Path->Width + HRoom->Width, y - Path->Height); + + if (SOUTHRDOOR & flags) + drawImage(Path, x - offset - Path->Width + HRoom->Width, y + Room->Height); + + offset = (HRoom->Width - Path->Width) / 2; + + if (NORTHMDOOR & flags) + drawImage(Path, x - offset - Path->Width + HRoom->Width, y - Path->Height); + + if (SOUTHMDOOR & flags) + drawImage(Path, x - offset - Path->Width + HRoom->Width, y + Room->Height); + + offset = (Room->Height - Path->Height) / 2; + + if (EASTDOOR & flags) + drawImage(Path, x + HRoom->Width, y + offset); + + if (WESTDOOR & flags) + drawImage(Path, x - Path->Width, y + offset); + + xx = x + (HRoom->Width - XMark->Width) / 2; + xy = y + (HRoom->Height - XMark->Height) / 2; + + break; + + default: + return; + } + + if (drawx) + drawImage(XMark, xx, xy); +} + + + +/*****************************************************************************/ +/* Checks if a floor has been visitted. */ +/*****************************************************************************/ +static bool onFloor(LargeSet RoomsFound, uint16 Floor) { + uint16 drawroom; + + for (drawroom = 1; drawroom <= MaxRooms; drawroom++) { + if ((Maps[drawroom].PageNumber == Floor) + && In(RoomsFound, drawroom) + && Maps[drawroom].x) { + return true; + } + } + + return false; +} + + + + +/*****************************************************************************/ +/* Figures out which floor, if any, should be gone to if the up arrow is hit */ +/*****************************************************************************/ +static void getUpFloor(LargeSet RoomsFound, uint16 *Floor, bool *isfloor) { + do { + *isfloor = true; + + if (*Floor < UPPERFLOOR) + (*Floor)++; + else { + *Floor = CARNIVAL + 1; + *isfloor = false; + return; + } + } while ((!onFloor(RoomsFound, *Floor)) && (*Floor <= CARNIVAL)); +} + + + + +/*****************************************************************************/ +/* Figures out which floor, if any, should be gone to if the down arrow is */ +/* hit. */ +/*****************************************************************************/ +static void getDownFloor(LargeSet RoomsFound, uint16 *Floor, bool *isfloor) { + do { + *isfloor = true; + + if ((*Floor == LOWERFLOOR) || (*Floor == 0)) { + *Floor = 0; + *isfloor = false; + return; + } else if (*Floor > UPPERFLOOR) { + /* LAB: Labyrinth specific code */ + if (*Floor == HEDGEMAZEFLOOR) + *Floor = UPPERFLOOR; + else if ((*Floor == CARNIVAL) || (*Floor == MEDMAZEFLOOR)) + *Floor = MIDDLEFLOOR; + else if (*Floor == SURMAZEFLOOR) + *Floor = LOWERFLOOR; + else { + *Floor = 0; + *isfloor = false; + return; + } + } else + (*Floor)--; + + } while ((!onFloor(RoomsFound, *Floor)) && *Floor); +} + + + + + +/*****************************************************************************/ +/* Draws the map */ +/*****************************************************************************/ +static void drawMap(LargeSet RoomsFound, uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, bool fadein) { + uint16 drawroom; + char *sptr; + + uint16 tempfloor; + bool noghoast; + + mouseHide(); + + if (fadeout) + fade(false, 0); + + setAPen(0); + rectFill(0, 0, VGAScreenWidth - 1, VGAScreenHeight - 1); + + drawImage(Map, 0, 0); + drawGadgetList(MapGadgetList); + + for (drawroom = 1; drawroom <= MaxRooms; drawroom++) { + if ((Maps[drawroom].PageNumber == Floor) + && In(RoomsFound, drawroom) + && Maps[drawroom].x) { + drawRoom(drawroom, (bool)(drawroom == CurRoom)); + g_music->checkMusic(); + } + } + + if ((Maps[CurRoom].PageNumber == Floor) /* Makes sure the X is drawn in corridors */ + && In(RoomsFound, CurRoom) /* NOTE: this here on purpose just in case there's some wierd condition, like the surreal maze where there are no rooms */ + && Maps[CurRoom].x) + drawRoom(CurRoom, true); + + tempfloor = Floor; + getUpFloor(RoomsFound, &tempfloor, &noghoast); + + if (noghoast) + unGhoastGadget(&upgadget); + else + ghoastGadget(&upgadget, 12); + + tempfloor = Floor; + getDownFloor(RoomsFound, &tempfloor, &noghoast); + + if (noghoast) + unGhoastGadget(&downgadget); + else + ghoastGadget(&downgadget, 12); + + /* LAB: Labyrinth specific code */ + if (Floor == LOWERFLOOR) { + if (onFloor(RoomsFound, SURMAZEFLOOR)) + drawImage(Maze, mapScaleX(538), mapScaleY(277)); + } + + else if (Floor == MIDDLEFLOOR) { + if (onFloor(RoomsFound, CARNIVAL)) + drawImage(Maze, mapScaleX(358), mapScaleY(72)); + + if (onFloor(RoomsFound, MEDMAZEFLOOR)) + drawImage(Maze, mapScaleX(557), mapScaleY(325)); + } + + else if (Floor == UPPERFLOOR) { + if (onFloor(RoomsFound, HEDGEMAZEFLOOR)) + drawImage(HugeMaze, mapScaleX(524), mapScaleY(97)); + } + + else if (Floor == SURMAZEFLOOR) { + flowText(MsgFont, 0, 7, 0, true, true, true, true, mapScaleX(360), 0, mapScaleX(660), mapScaleY(450), SURMAZEMSG); + } + + + /* LAB: Labyrinth specific code */ + sptr = NULL; + + switch (Floor) { + case LOWERFLOOR: + sptr = LOWERFLOORS; + break; + + case MIDDLEFLOOR: + sptr = MIDDLEFLOORS; + break; + + case UPPERFLOOR: + sptr = UPPERFLOORS; + break; + + case MEDMAZEFLOOR: + sptr = MEDMAZEFLOORS; + break; + + case HEDGEMAZEFLOOR: + sptr = HEDGEMAZEFLOORS; + break; + + case SURMAZEFLOOR: + sptr = SURMAZEFLOORS; + break; + + case CARNIVAL: + sptr = CARNIVALFLOOR; + break; + + default: + sptr = NULL; + break; + } + + if (sptr) + flowText(MsgFont, 0, 5, 3, true, true, true, true, VGAScaleX(14), VGAScaleY(75), VGAScaleX(134), VGAScaleY(97), sptr); + + if ((sptr = Rooms[CurMsg].RoomMsg)) + flowText(MsgFont, 0, 5, 3, true, true, true, true, VGAScaleX(14), VGAScaleY(148), VGAScaleX(134), VGAScaleY(186), sptr); + + if (fadein) + fade(true, 0); + + mouseShow(); +} + + + +/*****************************************************************************/ +/* Processes the map. */ +/*****************************************************************************/ +void processMap(uint16 CurRoom, LargeSet RoomsFound) { + uint32 Class, place = 1; + uint16 Code, Qualifier, MouseX, MouseY, GadgetID, CurFloor, OldFloor, OldMsg, CurMsg, drawroom, x1, y1, x2, y2; + char *sptr, newcolor[3]; + bool drawmap; + struct IntuiMessage *Msg; + + CurMsg = CurRoom; + CurFloor = Maps[CurRoom].PageNumber; + + while (1) { + g_music->checkMusic(); /* Make sure we check the music at least after every message */ + Msg = getMsg(); + + if (Msg == NULL) { + g_music->newCheckMusic(); + + if (place <= 14) { + newcolor[0] = 14 << 2; + newcolor[1] = place << 2; + newcolor[2] = newcolor[1]; + } else { + newcolor[0] = 14 << 2; + newcolor[1] = (28 - place) << 2; + newcolor[2] = newcolor[1]; + } + + waitTOF(); + writeColorReg(newcolor, 1); + updateMouse(); + waitTOF(); + updateMouse(); + waitTOF(); + updateMouse(); + waitTOF(); + updateMouse(); + + place++; + + if (place >= 28) + place = 1; + + } else { + Class = Msg->Class; + Code = Msg->Code; + GadgetID = Msg->GadgetID; + Qualifier = Msg->Qualifier; + MouseX = Msg->MouseX; + MouseY = Msg->MouseY; + + if (((Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) || + ((Class == RAWKEY) && (Code == 27))) + return; + + if (Class == GADGETUP) { + if (GadgetID == 0) { /* Quit menu button */ + return; + } else if (GadgetID == 1) { /* Up arrow */ + OldFloor = CurFloor; + getUpFloor(RoomsFound, &CurFloor, &drawmap); + + if (drawmap) { + fade(false, 0); + drawMap(RoomsFound, CurRoom, CurMsg, CurFloor, false, false); + fade(true, 0); + } else + CurFloor = OldFloor; + } else if (GadgetID == 2) { /* Down arrow */ + OldFloor = CurFloor; + getDownFloor(RoomsFound, &CurFloor, &drawmap); + + if (drawmap) { + fade(false, 0); + drawMap(RoomsFound, CurRoom, CurMsg, CurFloor, false, false); + fade(true, 0); + } else + CurFloor = OldFloor; + } + } + + else if ((Class == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & Qualifier)) { + if ((CurFloor == LOWERFLOOR) && (MouseX >= mapScaleX(538)) && (MouseY >= mapScaleY(277)) + && (MouseX <= mapScaleX(633)) && (MouseY <= mapScaleY(352)) + && onFloor(RoomsFound, SURMAZEFLOOR)) { + CurFloor = SURMAZEFLOOR; + + fade(false, 0); + drawMap(RoomsFound, CurRoom, CurMsg, CurFloor, false, false); + fade(true, 0); + } + + else if ((CurFloor == MIDDLEFLOOR) && (MouseX >= mapScaleX(358)) && (MouseY >= mapScaleY(71)) + && (MouseX <= mapScaleX(452)) && (MouseY <= mapScaleY(147)) + && onFloor(RoomsFound, CARNIVAL)) { + CurFloor = CARNIVAL; + + fade(false, 0); + drawMap(RoomsFound, CurRoom, CurMsg, CurFloor, false, false); + fade(true, 0); + } + + else if ((CurFloor == MIDDLEFLOOR) && (MouseX >= mapScaleX(557)) && (MouseY >= mapScaleY(325)) + && (MouseX <= mapScaleX(653)) && (MouseY <= mapScaleY(401)) + && onFloor(RoomsFound, MEDMAZEFLOOR)) { + CurFloor = MEDMAZEFLOOR; + + fade(false, 0); + drawMap(RoomsFound, CurRoom, CurMsg, CurFloor, false, false); + fade(true, 0); + } + + else if ((CurFloor == UPPERFLOOR) && (MouseX >= mapScaleX(524)) && (MouseY >= mapScaleY(97)) + && (MouseX <= mapScaleX(645)) && (MouseY <= mapScaleY(207)) + && onFloor(RoomsFound, HEDGEMAZEFLOOR)) { + CurFloor = HEDGEMAZEFLOOR; + + fade(false, 0); + drawMap(RoomsFound, CurRoom, CurMsg, CurFloor, false, false); + fade(true, 0); + } + + else if (MouseX > mapScaleX(314)) { + OldMsg = CurMsg; + + for (drawroom = 1; drawroom <= MaxRooms; drawroom++) { + roomCords(drawroom, &x1, &y1, &x2, &y2); + + if ((Maps[drawroom].PageNumber == CurFloor) + && In(RoomsFound, drawroom) + && (MouseX >= x1) && (MouseX <= x2) + && (MouseY >= y1) && (MouseY <= y2)) { + CurMsg = drawroom; + } + } + + if (OldMsg != CurMsg) { + if (Rooms[CurMsg].RoomMsg == NULL) + readViews(CurMsg, ViewPath); + + if ((sptr = Rooms[CurMsg].RoomMsg)) { + mouseHide(); + setAPen(3); + rectFill(VGAScaleX(13), VGAScaleY(148), VGAScaleX(135), VGAScaleY(186)); + flowText(MsgFont, 0, 5, 3, true, true, true, true, VGAScaleX(14), VGAScaleY(148), VGAScaleX(134), VGAScaleY(186), sptr); + + if (Maps[OldMsg].PageNumber == CurFloor) + drawRoom(OldMsg, (bool)(OldMsg == CurRoom)); + + roomCords(CurMsg, &x1, &y1, &x2, &y2); + x1 = (x1 + x2) / 2; + y1 = (y1 + y2) / 2; + + if ((CurMsg != CurRoom) && (Maps[CurMsg].PageNumber == CurFloor)) { + setAPen(1); + rectFill(x1 - 1, y1, x1, y1); + } + + mouseShow(); + } + } + } + } + +#if !defined(DOSCODE) + g_system->updateScreen(); +#endif + } + } +} + + + +/*****************************************************************************/ +/* Cleans up behind itself. */ +/*****************************************************************************/ +void mapCleanUp(void) { + freeAllStolenMem(); +} + + + + +/*****************************************************************************/ +/* Does the map processing. */ +/*****************************************************************************/ +void doMap(LargeSet RoomsFound, uint16 CurRoom) { + FadePalette = AmigaMapPalette; + + g_music->checkMusic(); + loadMapData(); + blackAllScreen(); + + if (Direction == NORTH) + XMark = MapNorth; + else if (Direction == SOUTH) + XMark = MapSouth; + else if (Direction == EAST) + XMark = MapEast; + else if (Direction == WEST) + XMark = MapWest; + + drawMap(RoomsFound, CurRoom, CurRoom, Maps[CurRoom].PageNumber, false, true); + mouseShow(); + attachGadgetList(MapGadgetList); +#if !defined(DOSCODE) + g_system->updateScreen(); +#endif + processMap(CurRoom, RoomsFound); + attachGadgetList(NULL); + fade(false, 0); + blackAllScreen(); + mouseHide(); + setAPen(0); + rectFill(0, 0, VGAScreenWidth - 1, VGAScreenHeight - 1); + mapCleanUp(); + blackAllScreen(); + mouseShow(); +#if !defined(DOSCODE) + g_system->updateScreen(); +#endif +} + +} // End of namespace Lab -- 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/map.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index f6e94990b5..d32154e700 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -60,7 +60,7 @@ extern uint16 RoomNum; /* the VGA palette. */ /*****************************************************************************/ void setAmigaPal(uint16 *pal, uint16 numcolors) { - char vgapal[16 * 3]; + byte vgapal[16 * 3]; uint16 counter, vgacount; if (numcolors > 16) @@ -69,11 +69,11 @@ void setAmigaPal(uint16 *pal, uint16 numcolors) { vgacount = 0; for (counter = 0; counter < numcolors; counter++) { - vgapal[vgacount] = (char)(((pal[counter] & 0xf00) >> 8) << 2); + vgapal[vgacount] = (byte)(((pal[counter] & 0xf00) >> 8) << 2); vgacount++; - vgapal[vgacount] = (char)(((pal[counter] & 0x0f0) >> 4) << 2); + vgapal[vgacount] = (byte)(((pal[counter] & 0x0f0) >> 4) << 2); vgacount++; - vgapal[vgacount] = (char)(((pal[counter] & 0x00f)) << 2); + vgapal[vgacount] = (byte)(((pal[counter] & 0x00f)) << 2); vgacount++; } @@ -733,7 +733,8 @@ static void drawMap(LargeSet RoomsFound, uint16 CurRoom, uint16 CurMsg, uint16 F void processMap(uint16 CurRoom, LargeSet RoomsFound) { uint32 Class, place = 1; uint16 Code, Qualifier, MouseX, MouseY, GadgetID, CurFloor, OldFloor, OldMsg, CurMsg, drawroom, x1, y1, x2, y2; - char *sptr, newcolor[3]; + char *sptr; + byte newcolor[3]; bool drawmap; struct IntuiMessage *Msg; @@ -894,7 +895,7 @@ void processMap(uint16 CurRoom, LargeSet RoomsFound) { } #if !defined(DOSCODE) - g_system->updateScreen(); + WSDL_UpdateScreen(); #endif } } @@ -935,7 +936,7 @@ void doMap(LargeSet RoomsFound, uint16 CurRoom) { mouseShow(); attachGadgetList(MapGadgetList); #if !defined(DOSCODE) - g_system->updateScreen(); + WSDL_UpdateScreen(); #endif processMap(CurRoom, RoomsFound); attachGadgetList(NULL); @@ -948,7 +949,7 @@ void doMap(LargeSet RoomsFound, uint16 CurRoom) { blackAllScreen(); mouseShow(); #if !defined(DOSCODE) - g_system->updateScreen(); + WSDL_UpdateScreen(); #endif } -- cgit v1.2.3 From 3a8cafa41ec8a91fa7e5cc34d0307af52f141fcb Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 21 Dec 2014 09:11:59 +0100 Subject: LAB: Kill storage.h --- engines/lab/map.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index d32154e700..c56f699778 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -28,7 +28,7 @@ * */ -#include "lab/storage.h" +#include "lab/stddefines.h" #include "lab/labfun.h" #include "lab/diff.h" #include "lab/vga.h" @@ -38,7 +38,6 @@ #include "lab/parsetypes.h" #include "lab/interface.h" #include "lab/text.h" -#include "lab/stddefines.h" namespace Lab { -- 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/map.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index c56f699778..d3380b7ecb 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -528,12 +528,12 @@ static void drawRoom(uint16 CurRoom, bool drawx) { /*****************************************************************************/ /* Checks if a floor has been visitted. */ /*****************************************************************************/ -static bool onFloor(LargeSet RoomsFound, uint16 Floor) { +static bool onFloor(uint16 Floor) { uint16 drawroom; for (drawroom = 1; drawroom <= MaxRooms; drawroom++) { if ((Maps[drawroom].PageNumber == Floor) - && In(RoomsFound, drawroom) + && g_engine->_roomsFound->in(drawroom) && Maps[drawroom].x) { return true; } @@ -623,7 +623,7 @@ static void drawMap(LargeSet RoomsFound, uint16 CurRoom, uint16 CurMsg, uint16 F for (drawroom = 1; drawroom <= MaxRooms; drawroom++) { if ((Maps[drawroom].PageNumber == Floor) - && In(RoomsFound, drawroom) + && g_engine->_roomsFound->in(drawroom) && Maps[drawroom].x) { drawRoom(drawroom, (bool)(drawroom == CurRoom)); g_music->checkMusic(); @@ -631,7 +631,7 @@ static void drawMap(LargeSet RoomsFound, uint16 CurRoom, uint16 CurMsg, uint16 F } if ((Maps[CurRoom].PageNumber == Floor) /* Makes sure the X is drawn in corridors */ - && In(RoomsFound, CurRoom) /* NOTE: this here on purpose just in case there's some wierd condition, like the surreal maze where there are no rooms */ + && g_engine->_roomsFound->in(CurRoom) /* NOTE: this here on purpose just in case there's some wierd condition, like the surreal maze where there are no rooms */ && Maps[CurRoom].x) drawRoom(CurRoom, true); @@ -858,7 +858,7 @@ void processMap(uint16 CurRoom, LargeSet RoomsFound) { roomCords(drawroom, &x1, &y1, &x2, &y2); if ((Maps[drawroom].PageNumber == CurFloor) - && In(RoomsFound, drawroom) + && g_engine->_roomsFound->in(drawroom) && (MouseX >= x1) && (MouseX <= x2) && (MouseY >= y1) && (MouseY <= y2)) { CurMsg = drawroom; -- 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/map.cpp | 63 +++++++++++++++++++++++++++-------------------------- 1 file changed, 32 insertions(+), 31 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index d3380b7ecb..eac13648eb 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -28,6 +28,7 @@ * */ +#include "lab/lab.h" #include "lab/stddefines.h" #include "lab/labfun.h" #include "lab/diff.h" @@ -533,7 +534,7 @@ static bool onFloor(uint16 Floor) { for (drawroom = 1; drawroom <= MaxRooms; drawroom++) { if ((Maps[drawroom].PageNumber == Floor) - && g_engine->_roomsFound->in(drawroom) + && g_lab->_roomsFound->in(drawroom) && Maps[drawroom].x) { return true; } @@ -548,7 +549,7 @@ static bool onFloor(uint16 Floor) { /*****************************************************************************/ /* Figures out which floor, if any, should be gone to if the up arrow is hit */ /*****************************************************************************/ -static void getUpFloor(LargeSet RoomsFound, uint16 *Floor, bool *isfloor) { +static void getUpFloor(uint16 *Floor, bool *isfloor) { do { *isfloor = true; @@ -559,7 +560,7 @@ static void getUpFloor(LargeSet RoomsFound, uint16 *Floor, bool *isfloor) { *isfloor = false; return; } - } while ((!onFloor(RoomsFound, *Floor)) && (*Floor <= CARNIVAL)); + } while ((!onFloor(*Floor)) && (*Floor <= CARNIVAL)); } @@ -569,7 +570,7 @@ static void getUpFloor(LargeSet RoomsFound, uint16 *Floor, bool *isfloor) { /* Figures out which floor, if any, should be gone to if the down arrow is */ /* hit. */ /*****************************************************************************/ -static void getDownFloor(LargeSet RoomsFound, uint16 *Floor, bool *isfloor) { +static void getDownFloor(uint16 *Floor, bool *isfloor) { do { *isfloor = true; @@ -593,7 +594,7 @@ static void getDownFloor(LargeSet RoomsFound, uint16 *Floor, bool *isfloor) { } else (*Floor)--; - } while ((!onFloor(RoomsFound, *Floor)) && *Floor); + } while ((!onFloor(*Floor)) && *Floor); } @@ -603,7 +604,7 @@ static void getDownFloor(LargeSet RoomsFound, uint16 *Floor, bool *isfloor) { /*****************************************************************************/ /* Draws the map */ /*****************************************************************************/ -static void drawMap(LargeSet RoomsFound, uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, bool fadein) { +static void drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, bool fadein) { uint16 drawroom; char *sptr; @@ -623,7 +624,7 @@ static void drawMap(LargeSet RoomsFound, uint16 CurRoom, uint16 CurMsg, uint16 F for (drawroom = 1; drawroom <= MaxRooms; drawroom++) { if ((Maps[drawroom].PageNumber == Floor) - && g_engine->_roomsFound->in(drawroom) + && g_lab->_roomsFound->in(drawroom) && Maps[drawroom].x) { drawRoom(drawroom, (bool)(drawroom == CurRoom)); g_music->checkMusic(); @@ -631,12 +632,12 @@ static void drawMap(LargeSet RoomsFound, uint16 CurRoom, uint16 CurMsg, uint16 F } if ((Maps[CurRoom].PageNumber == Floor) /* Makes sure the X is drawn in corridors */ - && g_engine->_roomsFound->in(CurRoom) /* NOTE: this here on purpose just in case there's some wierd condition, like the surreal maze where there are no rooms */ + && g_lab->_roomsFound->in(CurRoom) /* NOTE: this here on purpose just in case there's some wierd condition, like the surreal maze where there are no rooms */ && Maps[CurRoom].x) drawRoom(CurRoom, true); tempfloor = Floor; - getUpFloor(RoomsFound, &tempfloor, &noghoast); + getUpFloor(&tempfloor, &noghoast); if (noghoast) unGhoastGadget(&upgadget); @@ -644,7 +645,7 @@ static void drawMap(LargeSet RoomsFound, uint16 CurRoom, uint16 CurMsg, uint16 F ghoastGadget(&upgadget, 12); tempfloor = Floor; - getDownFloor(RoomsFound, &tempfloor, &noghoast); + getDownFloor(&tempfloor, &noghoast); if (noghoast) unGhoastGadget(&downgadget); @@ -653,20 +654,20 @@ static void drawMap(LargeSet RoomsFound, uint16 CurRoom, uint16 CurMsg, uint16 F /* LAB: Labyrinth specific code */ if (Floor == LOWERFLOOR) { - if (onFloor(RoomsFound, SURMAZEFLOOR)) + if (onFloor(SURMAZEFLOOR)) drawImage(Maze, mapScaleX(538), mapScaleY(277)); } else if (Floor == MIDDLEFLOOR) { - if (onFloor(RoomsFound, CARNIVAL)) + if (onFloor(CARNIVAL)) drawImage(Maze, mapScaleX(358), mapScaleY(72)); - if (onFloor(RoomsFound, MEDMAZEFLOOR)) + if (onFloor(MEDMAZEFLOOR)) drawImage(Maze, mapScaleX(557), mapScaleY(325)); } else if (Floor == UPPERFLOOR) { - if (onFloor(RoomsFound, HEDGEMAZEFLOOR)) + if (onFloor(HEDGEMAZEFLOOR)) drawImage(HugeMaze, mapScaleX(524), mapScaleY(97)); } @@ -729,7 +730,7 @@ static void drawMap(LargeSet RoomsFound, uint16 CurRoom, uint16 CurMsg, uint16 F /*****************************************************************************/ /* Processes the map. */ /*****************************************************************************/ -void processMap(uint16 CurRoom, LargeSet RoomsFound) { +void processMap(uint16 CurRoom) { uint32 Class, place = 1; uint16 Code, Qualifier, MouseX, MouseY, GadgetID, CurFloor, OldFloor, OldMsg, CurMsg, drawroom, x1, y1, x2, y2; char *sptr; @@ -789,21 +790,21 @@ void processMap(uint16 CurRoom, LargeSet RoomsFound) { return; } else if (GadgetID == 1) { /* Up arrow */ OldFloor = CurFloor; - getUpFloor(RoomsFound, &CurFloor, &drawmap); + getUpFloor(&CurFloor, &drawmap); if (drawmap) { fade(false, 0); - drawMap(RoomsFound, CurRoom, CurMsg, CurFloor, false, false); + drawMap(CurRoom, CurMsg, CurFloor, false, false); fade(true, 0); } else CurFloor = OldFloor; } else if (GadgetID == 2) { /* Down arrow */ OldFloor = CurFloor; - getDownFloor(RoomsFound, &CurFloor, &drawmap); + getDownFloor(&CurFloor, &drawmap); if (drawmap) { fade(false, 0); - drawMap(RoomsFound, CurRoom, CurMsg, CurFloor, false, false); + drawMap(CurRoom, CurMsg, CurFloor, false, false); fade(true, 0); } else CurFloor = OldFloor; @@ -813,41 +814,41 @@ void processMap(uint16 CurRoom, LargeSet RoomsFound) { else if ((Class == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & Qualifier)) { if ((CurFloor == LOWERFLOOR) && (MouseX >= mapScaleX(538)) && (MouseY >= mapScaleY(277)) && (MouseX <= mapScaleX(633)) && (MouseY <= mapScaleY(352)) - && onFloor(RoomsFound, SURMAZEFLOOR)) { + && onFloor(SURMAZEFLOOR)) { CurFloor = SURMAZEFLOOR; fade(false, 0); - drawMap(RoomsFound, CurRoom, CurMsg, CurFloor, false, false); + drawMap(CurRoom, CurMsg, CurFloor, false, false); fade(true, 0); } else if ((CurFloor == MIDDLEFLOOR) && (MouseX >= mapScaleX(358)) && (MouseY >= mapScaleY(71)) && (MouseX <= mapScaleX(452)) && (MouseY <= mapScaleY(147)) - && onFloor(RoomsFound, CARNIVAL)) { + && onFloor(CARNIVAL)) { CurFloor = CARNIVAL; fade(false, 0); - drawMap(RoomsFound, CurRoom, CurMsg, CurFloor, false, false); + drawMap(CurRoom, CurMsg, CurFloor, false, false); fade(true, 0); } else if ((CurFloor == MIDDLEFLOOR) && (MouseX >= mapScaleX(557)) && (MouseY >= mapScaleY(325)) && (MouseX <= mapScaleX(653)) && (MouseY <= mapScaleY(401)) - && onFloor(RoomsFound, MEDMAZEFLOOR)) { + && onFloor(MEDMAZEFLOOR)) { CurFloor = MEDMAZEFLOOR; fade(false, 0); - drawMap(RoomsFound, CurRoom, CurMsg, CurFloor, false, false); + drawMap(CurRoom, CurMsg, CurFloor, false, false); fade(true, 0); } else if ((CurFloor == UPPERFLOOR) && (MouseX >= mapScaleX(524)) && (MouseY >= mapScaleY(97)) && (MouseX <= mapScaleX(645)) && (MouseY <= mapScaleY(207)) - && onFloor(RoomsFound, HEDGEMAZEFLOOR)) { + && onFloor(HEDGEMAZEFLOOR)) { CurFloor = HEDGEMAZEFLOOR; fade(false, 0); - drawMap(RoomsFound, CurRoom, CurMsg, CurFloor, false, false); + drawMap(CurRoom, CurMsg, CurFloor, false, false); fade(true, 0); } @@ -858,7 +859,7 @@ void processMap(uint16 CurRoom, LargeSet RoomsFound) { roomCords(drawroom, &x1, &y1, &x2, &y2); if ((Maps[drawroom].PageNumber == CurFloor) - && g_engine->_roomsFound->in(drawroom) + && g_lab->_roomsFound->in(drawroom) && (MouseX >= x1) && (MouseX <= x2) && (MouseY >= y1) && (MouseY <= y2)) { CurMsg = drawroom; @@ -915,7 +916,7 @@ void mapCleanUp(void) { /*****************************************************************************/ /* Does the map processing. */ /*****************************************************************************/ -void doMap(LargeSet RoomsFound, uint16 CurRoom) { +void doMap(uint16 CurRoom) { FadePalette = AmigaMapPalette; g_music->checkMusic(); @@ -931,13 +932,13 @@ void doMap(LargeSet RoomsFound, uint16 CurRoom) { else if (Direction == WEST) XMark = MapWest; - drawMap(RoomsFound, CurRoom, CurRoom, Maps[CurRoom].PageNumber, false, true); + drawMap(CurRoom, CurRoom, Maps[CurRoom].PageNumber, false, true); mouseShow(); attachGadgetList(MapGadgetList); #if !defined(DOSCODE) WSDL_UpdateScreen(); #endif - processMap(CurRoom, RoomsFound); + processMap(CurRoom); attachGadgetList(NULL); fade(false, 0); blackAllScreen(); -- 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/map.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index eac13648eb..5f2274651b 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -42,8 +42,8 @@ namespace Lab { -static struct TextFont *BigMsgFont; -static struct TextFont bmf; +static TextFont *BigMsgFont; +static TextFont bmf; extern uint16 Direction; @@ -87,8 +87,7 @@ void setAmigaPal(uint16 *pal, uint16 numcolors) { bool getFont(const char *filename, TextFont *textfont) { byte *fontbuffer; - fontbuffer = (byte *)stealBufMem(sizeOfFile(filename) - - (sizeof(struct TextFont) + 4)); + fontbuffer = (byte *)stealBufMem(sizeOfFile(filename) - (sizeof(TextFont) + 4)); g_music->checkMusic(); if (fontbuffer == NULL) @@ -227,7 +226,7 @@ static uint16 mapScaleY(uint16 y) { static bool loadMapData(void) { byte **buffer, Temp[5]; int32 Size; - struct Gadget *gptr; + Gadget *gptr; uint16 counter; BigMsgFont = &bmf; @@ -736,7 +735,7 @@ void processMap(uint16 CurRoom) { char *sptr; byte newcolor[3]; bool drawmap; - struct IntuiMessage *Msg; + IntuiMessage *Msg; CurMsg = CurRoom; CurFloor = Maps[CurRoom].PageNumber; -- cgit v1.2.3 From fdb4f3edf8882f8c9907aae990c3d376e68cea18 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 28 Dec 2014 00:09:24 +0100 Subject: LAB: Cleanup --- engines/lab/map.cpp | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 5f2274651b..95c12bd5d7 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -50,10 +50,8 @@ extern uint16 Direction; extern bool IsHiRes; extern uint32 VGAScreenWidth, VGAScreenHeight; -#if !defined(DOSCODE) extern CloseDataPtr CPtr; extern uint16 RoomNum; -#endif /*****************************************************************************/ /* Converts an Amiga palette (up to 16 colors) to a VGA palette, then sets */ @@ -172,16 +170,12 @@ extern TextFont *MsgFont; uint16 *FadePalette; static uint16 MapGadX[3] = {101, 55, 8}, MapGadY[3] = {105, 105, 105}; -#if !defined(DOSCODE) + static Gadget downgadget = { 101, 105, 2, VKEY_DNARROW, 0L, NULL, NULL, NULL }, upgadget = { 55, 105, 1, VKEY_UPARROW, 0L, NULL, NULL, &downgadget }, - backgadget = { 8, 105, 0, 0, 0L, NULL, NULL, &upgadget }, -#else -static Gadget downgadget = { 101, 105, 2, 0L, NULL, NULL, NULL }, - upgadget = { 55, 105, 1, 0L, NULL, NULL, &downgadget }, - backgadget = { 8, 105, 0, 0L, NULL, NULL, &upgadget }, -#endif -*MapGadgetList = &backgadget; + backgadget = { 8, 105, 0, 0, 0L, NULL, NULL, &upgadget }; + +static Gadget *MapGadgetList = &backgadget; static uint16 AmigaMapPalette[] = { 0x0BA8, 0x0C11, 0x0A74, 0x0076, @@ -292,18 +286,13 @@ static bool loadMapData(void) { if (strcmp((char *)Temp, "MAP0") == 0) { readBlock(&MaxRooms, 2L, buffer); -#if !defined(DOSCODE) swapUShortPtr(&MaxRooms, 1); -#endif Maps = (MapData *)(*buffer); -#if !defined(DOSCODE) for (counter = 1; counter <= MaxRooms; counter++) { swapUShortPtr(&Maps[counter].x, 4); swapULongPtr(&Maps[counter].MapFlags, 1); } - -#endif } else return false; @@ -893,9 +882,7 @@ void processMap(uint16 CurRoom) { } } -#if !defined(DOSCODE) WSDL_UpdateScreen(); -#endif } } } @@ -934,9 +921,7 @@ void doMap(uint16 CurRoom) { drawMap(CurRoom, CurRoom, Maps[CurRoom].PageNumber, false, true); mouseShow(); attachGadgetList(MapGadgetList); -#if !defined(DOSCODE) WSDL_UpdateScreen(); -#endif processMap(CurRoom); attachGadgetList(NULL); fade(false, 0); @@ -947,9 +932,7 @@ void doMap(uint16 CurRoom) { mapCleanUp(); blackAllScreen(); mouseShow(); -#if !defined(DOSCODE) WSDL_UpdateScreen(); -#endif } } // End of namespace Lab -- cgit v1.2.3 From 28bbcf5641d8d505b07bcc121c8b129f9fb1de43 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 17 Feb 2015 11:19:32 +0200 Subject: LAB: Add missing const qualifiers --- engines/lab/map.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 95c12bd5d7..77d520de16 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -153,7 +153,7 @@ void readImage(byte **buffer, Image **im) { extern RoomData *Rooms; -extern char *ViewPath; +extern const char *ViewPath; static Image *Map, *Room, *UpArrowRoom, *DownArrowRoom, *Bridge, *HRoom, *VRoom, *Maze, *HugeMaze, *Path, *MapNorth, -- 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/map.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 77d520de16..f51bf86716 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -217,7 +217,7 @@ static uint16 mapScaleY(uint16 y) { /*****************************************************************************/ /* Loads in the map data. */ /*****************************************************************************/ -static bool loadMapData(void) { +static bool loadMapData() { byte **buffer, Temp[5]; int32 Size; Gadget *gptr; @@ -892,7 +892,7 @@ void processMap(uint16 CurRoom) { /*****************************************************************************/ /* Cleans up behind itself. */ /*****************************************************************************/ -void mapCleanUp(void) { +void mapCleanUp() { freeAllStolenMem(); } -- cgit v1.2.3 From a83c50cf66e72d105ef64b29a10e3f9603e0141b Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 24 Feb 2015 13:09:52 +0200 Subject: LAB: Remove duplicate swap code and some unused defines --- engines/lab/map.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index f51bf86716..b6b4415b11 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -291,7 +291,7 @@ static bool loadMapData() { for (counter = 1; counter <= MaxRooms; counter++) { swapUShortPtr(&Maps[counter].x, 4); - swapULongPtr(&Maps[counter].MapFlags, 1); + swapULong(&Maps[counter].MapFlags); } } else return false; -- cgit v1.2.3 From 79ed1e1f05dc1537f666018bc7240a5d96835b5b Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 17 Jul 2015 10:36:20 +0300 Subject: LAB: Get rid of numtostr(), and simplify most uses of sizeOfFile() --- engines/lab/map.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index b6b4415b11..a0dffe04e9 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -219,7 +219,7 @@ static uint16 mapScaleY(uint16 y) { /*****************************************************************************/ static bool loadMapData() { byte **buffer, Temp[5]; - int32 Size; + uint32 Size; Gadget *gptr; uint16 counter; @@ -228,9 +228,8 @@ static bool loadMapData() { if (!getFont("P:Map.fon", BigMsgFont)) BigMsgFont = MsgFont; - Size = sizeOfFile("P:MapImage"); resetBuffer(); /* Make images load into start of buffer */ - buffer = g_music->newOpen("P:MapImage"); + buffer = g_music->newOpen("P:MapImage", Size); if (!buffer) return false; @@ -279,8 +278,9 @@ static bool loadMapData() { counter++; } - buffer = g_music->newOpen("Lab:Maps"); - stealBufMem(sizeOfFile("Lab:Maps")); /* Freeze the memory for the maps */ + uint32 bufferSize; + buffer = g_music->newOpen("Lab:Maps", bufferSize); + stealBufMem(bufferSize); /* Freeze the memory for the maps */ readBlock(Temp, 4L, buffer); Temp[4] = 0; -- 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/map.cpp | 33 +++------------------------------ 1 file changed, 3 insertions(+), 30 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index a0dffe04e9..458ff215df 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -142,16 +142,10 @@ void readImage(byte **buffer, Image **im) { } - - - - /*---------------------------------------------------------------------------*/ /*------------------------------ The Map stuff ------------------------------*/ /*---------------------------------------------------------------------------*/ - - extern RoomData *Rooms; extern const char *ViewPath; @@ -620,7 +614,7 @@ static void drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, b } if ((Maps[CurRoom].PageNumber == Floor) /* Makes sure the X is drawn in corridors */ - && g_lab->_roomsFound->in(CurRoom) /* NOTE: this here on purpose just in case there's some wierd condition, like the surreal maze where there are no rooms */ + && g_lab->_roomsFound->in(CurRoom) /* NOTE: this here on purpose just in case there's some weird condition, like the surreal maze where there are no rooms */ && Maps[CurRoom].x) drawRoom(CurRoom, true); @@ -664,38 +658,28 @@ static void drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, b } - /* LAB: Labyrinth specific code */ - sptr = NULL; - switch (Floor) { case LOWERFLOOR: sptr = LOWERFLOORS; break; - case MIDDLEFLOOR: sptr = MIDDLEFLOORS; break; - case UPPERFLOOR: sptr = UPPERFLOORS; break; - case MEDMAZEFLOOR: sptr = MEDMAZEFLOORS; break; - case HEDGEMAZEFLOOR: sptr = HEDGEMAZEFLOORS; break; - case SURMAZEFLOOR: sptr = SURMAZEFLOORS; break; - case CARNIVAL: sptr = CARNIVALFLOOR; break; - default: sptr = NULL; break; @@ -734,7 +718,7 @@ void processMap(uint16 CurRoom) { Msg = getMsg(); if (Msg == NULL) { - g_music->newCheckMusic(); + g_music->checkMusic(); if (place <= 14) { newcolor[0] = 14 << 2; @@ -888,17 +872,6 @@ void processMap(uint16 CurRoom) { } - -/*****************************************************************************/ -/* Cleans up behind itself. */ -/*****************************************************************************/ -void mapCleanUp() { - freeAllStolenMem(); -} - - - - /*****************************************************************************/ /* Does the map processing. */ /*****************************************************************************/ @@ -929,7 +902,7 @@ void doMap(uint16 CurRoom) { mouseHide(); setAPen(0); rectFill(0, 0, VGAScreenWidth - 1, VGAScreenHeight - 1); - mapCleanUp(); + freeAllStolenMem(); blackAllScreen(); mouseShow(); WSDL_UpdateScreen(); -- cgit v1.2.3 From a4bad804f61eb933532f9936e185c54ceaf2b285 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 18 Jul 2015 15:30:00 +0300 Subject: LAB: Get rid of sizeOfFile(), some cleanup --- engines/lab/map.cpp | 48 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 16 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 458ff215df..cb51a51fff 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -59,20 +59,15 @@ extern uint16 RoomNum; /*****************************************************************************/ void setAmigaPal(uint16 *pal, uint16 numcolors) { byte vgapal[16 * 3]; - uint16 counter, vgacount; + uint16 vgacount = 0; if (numcolors > 16) numcolors = 16; - vgacount = 0; - - for (counter = 0; counter < numcolors; counter++) { - vgapal[vgacount] = (byte)(((pal[counter] & 0xf00) >> 8) << 2); - vgacount++; - vgapal[vgacount] = (byte)(((pal[counter] & 0x0f0) >> 4) << 2); - vgacount++; - vgapal[vgacount] = (byte)(((pal[counter] & 0x00f)) << 2); - vgacount++; + for (uint16 counter = 0; counter < numcolors; counter++) { + vgapal[vgacount++] = (byte)(((pal[counter] & 0xf00) >> 8) << 2); + vgapal[vgacount++] = (byte)(((pal[counter] & 0x0f0) >> 4) << 2); + vgapal[vgacount++] = (byte)(((pal[counter] & 0x00f)) << 2); } writeColorRegsSmooth(vgapal, 0, 16); @@ -83,18 +78,39 @@ void setAmigaPal(uint16 *pal, uint16 numcolors) { /* Gets a font from disk and puts it into temporary memory. */ /*****************************************************************************/ bool getFont(const char *filename, TextFont *textfont) { - byte *fontbuffer; + byte **file = NULL; + char header[5]; + uint32 filesize, headersize = 4L + 2L + 256 * 3 + 4L; - fontbuffer = (byte *)stealBufMem(sizeOfFile(filename) - (sizeof(TextFont) + 4)); + file = g_music->newOpen(filename, filesize); g_music->checkMusic(); - if (fontbuffer == NULL) - return false; + if ((file != NULL) && (filesize > headersize)) { + byte *fontbuffer = (byte *)stealBufMem(filesize - (sizeof(TextFont) + 4)); + if (!fontbuffer) + return false; - return openFontMem(filename, textfont, fontbuffer); -} + header[4] = 0; + readBlock(&header, 4L, file); + + if (strcmp(header, "VGAF") == 0) { + textfont->DataLength = filesize - headersize; + readBlock(&(textfont->Height), 2L, file); + swapUShortPtr(&(textfont->Height), 1); + + readBlock(textfont->Widths, 256L, file); + readBlock(textfont->Offsets, 256L * 2L, file); + swapUShortPtr(textfont->Offsets, 256); + skip(file, 4L); + textfont->data = fontbuffer; + readBlock(textfont->data, textfont->DataLength, file); + return true; + } + } + return false; +} /*****************************************************************************/ -- cgit v1.2.3 From 77f4a10901d749b3e0f01c9ecde4948e8ceb65a5 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 21 Jul 2015 21:55:15 +0300 Subject: LAB: Remove dead code --- engines/lab/map.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index cb51a51fff..a3cae9b841 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -163,7 +163,6 @@ void readImage(byte **buffer, Image **im) { /*---------------------------------------------------------------------------*/ extern RoomData *Rooms; -extern const char *ViewPath; static Image *Map, *Room, *UpArrowRoom, *DownArrowRoom, *Bridge, *HRoom, *VRoom, *Maze, *HugeMaze, *Path, *MapNorth, -- cgit v1.2.3 From da0ee48ab941185749f639e884b79e9892dfca82 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 21 Jul 2015 22:01:50 +0300 Subject: LAB: Remove the fillUpMusic() and checkMusic() wrappers. Some cleanup --- engines/lab/map.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index a3cae9b841..3b2eaf67f5 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -83,7 +83,7 @@ bool getFont(const char *filename, TextFont *textfont) { uint32 filesize, headersize = 4L + 2L + 256 * 3 + 4L; file = g_music->newOpen(filename, filesize); - g_music->checkMusic(); + g_music->updateMusic(); if ((file != NULL) && (filesize > headersize)) { byte *fontbuffer = (byte *)stealBufMem(filesize - (sizeof(TextFont) + 4)); @@ -102,7 +102,7 @@ bool getFont(const char *filename, TextFont *textfont) { readBlock(textfont->Offsets, 256L * 2L, file); swapUShortPtr(textfont->Offsets, 256); - skip(file, 4L); + (*file) += 4; textfont->data = fontbuffer; readBlock(textfont->data, textfont->DataLength, file); return true; @@ -120,7 +120,7 @@ char *getText(const char *filename) { bool dodecrypt; byte **tfile; - g_music->checkMusic(); + g_music->updateMusic(); dodecrypt = (isBuffered(filename) == NULL); tfile = g_music->newOpen(filename); @@ -624,7 +624,7 @@ static void drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, b && g_lab->_roomsFound->in(drawroom) && Maps[drawroom].x) { drawRoom(drawroom, (bool)(drawroom == CurRoom)); - g_music->checkMusic(); + g_music->updateMusic(); } } @@ -729,11 +729,11 @@ void processMap(uint16 CurRoom) { CurFloor = Maps[CurRoom].PageNumber; 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(); if (place <= 14) { newcolor[0] = 14 << 2; @@ -893,7 +893,7 @@ void processMap(uint16 CurRoom) { void doMap(uint16 CurRoom) { FadePalette = AmigaMapPalette; - g_music->checkMusic(); + g_music->updateMusic(); loadMapData(); blackAllScreen(); -- cgit v1.2.3 From df3200ef0c0bc590f03888a26e49e52da51d53ce Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 21 Jul 2015 22:06:23 +0300 Subject: LAB: Simplify readViews() --- engines/lab/map.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 3b2eaf67f5..2e3dffc943 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -855,7 +855,7 @@ void processMap(uint16 CurRoom) { if (OldMsg != CurMsg) { if (Rooms[CurMsg].RoomMsg == NULL) - readViews(CurMsg, ViewPath); + readViews(CurMsg); if ((sptr = Rooms[CurMsg].RoomMsg)) { mouseHide(); -- 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/map.cpp | 41 ++--------------------------------------- 1 file changed, 2 insertions(+), 39 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 2e3dffc943..34eb018f94 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -37,6 +37,7 @@ #include "lab/mouse.h" #include "lab/parsefun.h" #include "lab/parsetypes.h" +#include "lab/resource.h" #include "lab/interface.h" #include "lab/text.h" @@ -74,44 +75,6 @@ void setAmigaPal(uint16 *pal, uint16 numcolors) { } -/*****************************************************************************/ -/* Gets a font from disk and puts it into temporary memory. */ -/*****************************************************************************/ -bool getFont(const char *filename, TextFont *textfont) { - byte **file = NULL; - char header[5]; - uint32 filesize, headersize = 4L + 2L + 256 * 3 + 4L; - - file = g_music->newOpen(filename, filesize); - g_music->updateMusic(); - - if ((file != NULL) && (filesize > headersize)) { - byte *fontbuffer = (byte *)stealBufMem(filesize - (sizeof(TextFont) + 4)); - if (!fontbuffer) - return false; - - header[4] = 0; - readBlock(&header, 4L, file); - - if (strcmp(header, "VGAF") == 0) { - textfont->DataLength = filesize - headersize; - readBlock(&(textfont->Height), 2L, file); - swapUShortPtr(&(textfont->Height), 1); - - readBlock(textfont->Widths, 256L, file); - readBlock(textfont->Offsets, 256L * 2L, file); - swapUShortPtr(textfont->Offsets, 256); - - (*file) += 4; - textfont->data = fontbuffer; - readBlock(textfont->data, textfont->DataLength, file); - return true; - } - } - - return false; -} - /*****************************************************************************/ /* Gets a chunk of text and puts it into the graphics memory. */ @@ -234,7 +197,7 @@ static bool loadMapData() { BigMsgFont = &bmf; - if (!getFont("P:Map.fon", BigMsgFont)) + if (!(BigMsgFont = g_resource->getFont("P:Map.fon"))) BigMsgFont = MsgFont; resetBuffer(); /* Make images load into start of buffer */ -- cgit v1.2.3 From 01dffc75a1fec635879f176f9a62a539269d9adf Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 8 Oct 2015 06:39:59 +0300 Subject: LAB: Move static text loading to the Resource class --- engines/lab/map.cpp | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 34eb018f94..06a0ac18d7 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -616,47 +616,42 @@ static void drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, b if (Floor == LOWERFLOOR) { if (onFloor(SURMAZEFLOOR)) drawImage(Maze, mapScaleX(538), mapScaleY(277)); - } - - else if (Floor == MIDDLEFLOOR) { + } else if (Floor == MIDDLEFLOOR) { if (onFloor(CARNIVAL)) drawImage(Maze, mapScaleX(358), mapScaleY(72)); if (onFloor(MEDMAZEFLOOR)) drawImage(Maze, mapScaleX(557), mapScaleY(325)); - } - - else if (Floor == UPPERFLOOR) { + } else if (Floor == UPPERFLOOR) { if (onFloor(HEDGEMAZEFLOOR)) drawImage(HugeMaze, mapScaleX(524), mapScaleY(97)); - } - - else if (Floor == SURMAZEFLOOR) { - flowText(MsgFont, 0, 7, 0, true, true, true, true, mapScaleX(360), 0, mapScaleX(660), mapScaleY(450), SURMAZEMSG); + } else if (Floor == SURMAZEFLOOR) { + sptr = (char *)g_resource->getStaticText(kTextSurmazeMessage).c_str(); + flowText(MsgFont, 0, 7, 0, true, true, true, true, mapScaleX(360), 0, mapScaleX(660), mapScaleY(450), sptr); } switch (Floor) { case LOWERFLOOR: - sptr = LOWERFLOORS; + sptr = (char *)g_resource->getStaticText(kTextLowerFloor).c_str(); break; case MIDDLEFLOOR: - sptr = MIDDLEFLOORS; + sptr = (char *)g_resource->getStaticText(kTextMiddleFloor).c_str(); break; case UPPERFLOOR: - sptr = UPPERFLOORS; + sptr = (char *)g_resource->getStaticText(kTextUpperFloor).c_str(); break; case MEDMAZEFLOOR: - sptr = MEDMAZEFLOORS; + sptr = (char *)g_resource->getStaticText(kTextMedMazeFloor).c_str(); break; case HEDGEMAZEFLOOR: - sptr = HEDGEMAZEFLOORS; + sptr = (char *)g_resource->getStaticText(kTextHedgeMazeFloor).c_str(); break; case SURMAZEFLOOR: - sptr = SURMAZEFLOORS; + sptr = (char *)g_resource->getStaticText(kTextSurMazeFloor).c_str(); break; case CARNIVAL: - sptr = CARNIVALFLOOR; + sptr = (char *)g_resource->getStaticText(kTextCarnivalFloor).c_str(); break; default: sptr = NULL; -- cgit v1.2.3 From 77608bfc66d3b8b8d7414d005fbde39b2af67658 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sun, 11 Oct 2015 02:14:28 +0300 Subject: LAB: Move more room reading functions to the Resource class --- engines/lab/map.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 06a0ac18d7..ceddc4bdf4 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -74,7 +74,11 @@ void setAmigaPal(uint16 *pal, uint16 numcolors) { writeColorRegsSmooth(vgapal, 0, 16); } - +void decrypt(byte *text) { + while (text && *text != '\0') { + *text++ -= (byte)95; + } +} /*****************************************************************************/ /* Gets a chunk of text and puts it into the graphics memory. */ @@ -813,7 +817,7 @@ void processMap(uint16 CurRoom) { if (OldMsg != CurMsg) { if (Rooms[CurMsg].RoomMsg == NULL) - readViews(CurMsg); + g_resource->readViews(CurMsg); if ((sptr = Rooms[CurMsg].RoomMsg)) { mouseHide(); -- cgit v1.2.3 From 09a7232daa00b5bcb039a3e3a06b3ee4d541460d Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 14 Oct 2015 01:51:18 +0300 Subject: LAB: Use Common::File to load map data --- engines/lab/map.cpp | 48 +++++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 23 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index ceddc4bdf4..a096d28326 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -188,13 +188,11 @@ static uint16 mapScaleY(uint16 y) { } - - /*****************************************************************************/ /* Loads in the map data. */ /*****************************************************************************/ static bool loadMapData() { - byte **buffer, Temp[5]; + byte **buffer; uint32 Size; Gadget *gptr; uint16 counter; @@ -254,28 +252,33 @@ static bool loadMapData() { counter++; } - uint32 bufferSize; - buffer = g_music->newOpen("Lab:Maps", bufferSize); - stealBufMem(bufferSize); /* Freeze the memory for the maps */ - readBlock(Temp, 4L, buffer); - Temp[4] = 0; + Common::File *mapFile = g_resource->openDataFile("Lab:Maps", MKTAG('M', 'A', 'P', '0')); + if (!mapFile) + error("Corrupt map file"); + g_music->updateMusic(); + if (!g_music->_doNotFilestopSoundEffect) + g_music->stopSoundEffect(); + + MaxRooms = mapFile->readUint16LE(); + Maps = new MapData[MaxRooms]; // will be freed when the user exits the map + for (int i = 0; i < MaxRooms; i++) { + Maps[i].x = mapFile->readUint16LE(); + Maps[i].y = mapFile->readUint16LE(); + Maps[i].PageNumber = mapFile->readUint16LE(); + Maps[i].SpecialID = mapFile->readUint16LE(); + Maps[i].MapFlags = mapFile->readUint32LE(); + } - if (strcmp((char *)Temp, "MAP0") == 0) { - readBlock(&MaxRooms, 2L, buffer); - swapUShortPtr(&MaxRooms, 1); - Maps = (MapData *)(*buffer); - - for (counter = 1; counter <= MaxRooms; counter++) { - swapUShortPtr(&Maps[counter].x, 4); - swapULong(&Maps[counter].MapFlags); - } - } else - return false; + delete mapFile; return true; } +static void freeMapData() { + delete[] Maps; + Maps = NULL; +} static uint16 fadeNumIn(uint16 num, uint16 res, uint16 counter) { @@ -543,7 +546,7 @@ static void getDownFloor(uint16 *Floor, bool *isfloor) { *isfloor = false; return; } else if (*Floor > UPPERFLOOR) { - /* LAB: Labyrinth specific code */ + // Labyrinth specific code if (*Floor == HEDGEMAZEFLOOR) *Floor = UPPERFLOOR; else if ((*Floor == CARNIVAL) || (*Floor == MEDMAZEFLOOR)) @@ -616,7 +619,7 @@ static void drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, b else ghoastGadget(&downgadget, 12); - /* LAB: Labyrinth specific code */ + // Labyrinth specific code if (Floor == LOWERFLOOR) { if (onFloor(SURMAZEFLOOR)) drawImage(Maze, mapScaleX(538), mapScaleY(277)); @@ -634,7 +637,6 @@ static void drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, b flowText(MsgFont, 0, 7, 0, true, true, true, true, mapScaleX(360), 0, mapScaleX(660), mapScaleY(450), sptr); } - switch (Floor) { case LOWERFLOOR: sptr = (char *)g_resource->getStaticText(kTextLowerFloor).c_str(); @@ -879,7 +881,7 @@ void doMap(uint16 CurRoom) { mouseHide(); setAPen(0); rectFill(0, 0, VGAScreenWidth - 1, VGAScreenHeight - 1); - freeAllStolenMem(); + freeMapData(); blackAllScreen(); mouseShow(); WSDL_UpdateScreen(); -- 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/map.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index a096d28326..f373fb8d9d 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -725,12 +725,12 @@ void processMap(uint16 CurRoom) { place = 1; } else { - Class = Msg->Class; - Code = Msg->Code; - GadgetID = Msg->GadgetID; - Qualifier = Msg->Qualifier; - MouseX = Msg->MouseX; - MouseY = Msg->MouseY; + Class = Msg->msgClass; + Code = Msg->code; + GadgetID = Msg->gadgetID; + Qualifier = Msg->qualifier; + MouseX = Msg->mouseX; + MouseY = Msg->mouseY; 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/map.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index f373fb8d9d..4ad9ba2511 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -49,7 +49,6 @@ static TextFont bmf; extern uint16 Direction; extern bool IsHiRes; -extern uint32 VGAScreenWidth, VGAScreenHeight; extern CloseDataPtr CPtr; extern uint16 RoomNum; @@ -584,7 +583,7 @@ static void drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, b fade(false, 0); setAPen(0); - rectFill(0, 0, VGAScreenWidth - 1, VGAScreenHeight - 1); + rectFill(0, 0, g_lab->_screenWidth - 1, g_lab->_screenHeight - 1); drawImage(Map, 0, 0); drawGadgetList(MapGadgetList); @@ -880,7 +879,7 @@ void doMap(uint16 CurRoom) { blackAllScreen(); mouseHide(); setAPen(0); - rectFill(0, 0, VGAScreenWidth - 1, VGAScreenHeight - 1); + rectFill(0, 0, g_lab->_screenWidth - 1, g_lab->_screenHeight - 1); freeMapData(); blackAllScreen(); mouseShow(); -- 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/map.cpp | 101 ++++++++++++++++++++++++++-------------------------- 1 file changed, 50 insertions(+), 51 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 4ad9ba2511..fdec095f1a 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -32,7 +32,6 @@ #include "lab/stddefines.h" #include "lab/labfun.h" #include "lab/diff.h" -#include "lab/vga.h" #include "lab/text.h" #include "lab/mouse.h" #include "lab/parsefun.h" @@ -70,7 +69,7 @@ void setAmigaPal(uint16 *pal, uint16 numcolors) { vgapal[vgacount++] = (byte)(((pal[counter] & 0x00f)) << 2); } - writeColorRegsSmooth(vgapal, 0, 16); + g_lab->writeColorRegsSmooth(vgapal, 0, 16); } void decrypt(byte *text) { @@ -310,7 +309,7 @@ void fade(bool fadein, uint16 res) { } setAmigaPal(newpal, 16); - waitTOF(); + g_lab->waitTOF(); g_music->updateMusic(); } } @@ -371,27 +370,27 @@ static void drawRoom(uint16 CurRoom, bool drawx) { case UPARROWROOM: case DOWNARROWROOM: if (Maps[CurRoom].SpecialID == NORMAL) - drawImage(Room, x, y); + g_lab->drawImage(Room, x, y); else if (Maps[CurRoom].SpecialID == DOWNARROWROOM) - drawImage(DownArrowRoom, x, y); + g_lab->drawImage(DownArrowRoom, x, y); else - drawImage(UpArrowRoom, x, y); + g_lab->drawImage(UpArrowRoom, x, y); offset = (Room->Width - Path->Width) / 2; if ((NORTHDOOR & flags) && (y >= Path->Height)) - drawImage(Path, x + offset, y - Path->Height); + g_lab->drawImage(Path, x + offset, y - Path->Height); if (SOUTHDOOR & flags) - drawImage(Path, x + offset, y + Room->Height); + g_lab->drawImage(Path, x + offset, y + Room->Height); offset = (Room->Height - Path->Height) / 2; if (EASTDOOR & flags) - drawImage(Path, x + Room->Width, y + offset); + g_lab->drawImage(Path, x + Room->Width, y + offset); if (WESTDOOR & flags) - drawImage(Path, x - Path->Width, y + offset); + g_lab->drawImage(Path, x - Path->Width, y + offset); xx = x + (Room->Width - XMark->Width) / 2; xy = y + (Room->Height - XMark->Height) / 2; @@ -399,7 +398,7 @@ static void drawRoom(uint16 CurRoom, bool drawx) { break; case BRIDGEROOM: - drawImage(Bridge, x, y); + g_lab->drawImage(Bridge, x, y); xx = x + (Bridge->Width - XMark->Width) / 2; xy = y + (Bridge->Height - XMark->Height) / 2; @@ -407,37 +406,37 @@ static void drawRoom(uint16 CurRoom, bool drawx) { break; case VCORRIDOR: - drawImage(VRoom, x, y); + g_lab->drawImage(VRoom, x, y); offset = (VRoom->Width - Path->Width) / 2; if (NORTHDOOR & flags) - drawImage(Path, x + offset, y - Path->Height); + g_lab->drawImage(Path, x + offset, y - Path->Height); if (SOUTHDOOR & flags) - drawImage(Path, x + offset, y + VRoom->Height); + g_lab->drawImage(Path, x + offset, y + VRoom->Height); offset = (Room->Height - Path->Height) / 2; if (EASTDOOR & flags) - drawImage(Path, x + VRoom->Width, y + offset); + g_lab->drawImage(Path, x + VRoom->Width, y + offset); if (WESTDOOR & flags) - drawImage(Path, x - Path->Width, y + offset); + g_lab->drawImage(Path, x - Path->Width, y + offset); if (EASTBDOOR & flags) - drawImage(Path, x + VRoom->Width, y - offset - Path->Height + VRoom->Height); + g_lab->drawImage(Path, x + VRoom->Width, y - offset - Path->Height + VRoom->Height); if (WESTBDOOR & flags) - drawImage(Path, x - Path->Width, y - offset - Path->Height + VRoom->Height); + g_lab->drawImage(Path, x - Path->Width, y - offset - Path->Height + VRoom->Height); offset = (VRoom->Height - Path->Height) / 2; if (EASTMDOOR & flags) - drawImage(Path, x + VRoom->Width, y - offset - Path->Height + VRoom->Height); + g_lab->drawImage(Path, x + VRoom->Width, y - offset - Path->Height + VRoom->Height); if (WESTMDOOR & flags) - drawImage(Path, x - Path->Width, y - offset - Path->Height + VRoom->Height); + g_lab->drawImage(Path, x - Path->Width, y - offset - Path->Height + VRoom->Height); xx = x + (VRoom->Width - XMark->Width) / 2; xy = y + (VRoom->Height - XMark->Height) / 2; @@ -445,37 +444,37 @@ static void drawRoom(uint16 CurRoom, bool drawx) { break; case HCORRIDOR: - drawImage(HRoom, x, y); + g_lab->drawImage(HRoom, x, y); offset = (Room->Width - Path->Width) / 2; if (NORTHDOOR & flags) - drawImage(Path, x + offset, y - Path->Height); + g_lab->drawImage(Path, x + offset, y - Path->Height); if (SOUTHDOOR & flags) - drawImage(Path, x + offset, y + Room->Height); + g_lab->drawImage(Path, x + offset, y + Room->Height); if (NORTHRDOOR & flags) - drawImage(Path, x - offset - Path->Width + HRoom->Width, y - Path->Height); + g_lab->drawImage(Path, x - offset - Path->Width + HRoom->Width, y - Path->Height); if (SOUTHRDOOR & flags) - drawImage(Path, x - offset - Path->Width + HRoom->Width, y + Room->Height); + g_lab->drawImage(Path, x - offset - Path->Width + HRoom->Width, y + Room->Height); offset = (HRoom->Width - Path->Width) / 2; if (NORTHMDOOR & flags) - drawImage(Path, x - offset - Path->Width + HRoom->Width, y - Path->Height); + g_lab->drawImage(Path, x - offset - Path->Width + HRoom->Width, y - Path->Height); if (SOUTHMDOOR & flags) - drawImage(Path, x - offset - Path->Width + HRoom->Width, y + Room->Height); + g_lab->drawImage(Path, x - offset - Path->Width + HRoom->Width, y + Room->Height); offset = (Room->Height - Path->Height) / 2; if (EASTDOOR & flags) - drawImage(Path, x + HRoom->Width, y + offset); + g_lab->drawImage(Path, x + HRoom->Width, y + offset); if (WESTDOOR & flags) - drawImage(Path, x - Path->Width, y + offset); + g_lab->drawImage(Path, x - Path->Width, y + offset); xx = x + (HRoom->Width - XMark->Width) / 2; xy = y + (HRoom->Height - XMark->Height) / 2; @@ -487,7 +486,7 @@ static void drawRoom(uint16 CurRoom, bool drawx) { } if (drawx) - drawImage(XMark, xx, xy); + g_lab->drawImage(XMark, xx, xy); } @@ -582,10 +581,10 @@ static void drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, b if (fadeout) fade(false, 0); - 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); - drawImage(Map, 0, 0); + g_lab->drawImage(Map, 0, 0); drawGadgetList(MapGadgetList); for (drawroom = 1; drawroom <= MaxRooms; drawroom++) { @@ -621,16 +620,16 @@ static void drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, b // Labyrinth specific code if (Floor == LOWERFLOOR) { if (onFloor(SURMAZEFLOOR)) - drawImage(Maze, mapScaleX(538), mapScaleY(277)); + g_lab->drawImage(Maze, mapScaleX(538), mapScaleY(277)); } else if (Floor == MIDDLEFLOOR) { if (onFloor(CARNIVAL)) - drawImage(Maze, mapScaleX(358), mapScaleY(72)); + g_lab->drawImage(Maze, mapScaleX(358), mapScaleY(72)); if (onFloor(MEDMAZEFLOOR)) - drawImage(Maze, mapScaleX(557), mapScaleY(325)); + g_lab->drawImage(Maze, mapScaleX(557), mapScaleY(325)); } else if (Floor == UPPERFLOOR) { if (onFloor(HEDGEMAZEFLOOR)) - drawImage(HugeMaze, mapScaleX(524), mapScaleY(97)); + g_lab->drawImage(HugeMaze, mapScaleX(524), mapScaleY(97)); } else if (Floor == SURMAZEFLOOR) { sptr = (char *)g_resource->getStaticText(kTextSurmazeMessage).c_str(); flowText(MsgFont, 0, 7, 0, true, true, true, true, mapScaleX(360), 0, mapScaleX(660), mapScaleY(450), sptr); @@ -708,14 +707,14 @@ void processMap(uint16 CurRoom) { newcolor[2] = newcolor[1]; } - waitTOF(); - writeColorReg(newcolor, 1); + g_lab->waitTOF(); + g_lab->writeColorReg(newcolor, 1); updateMouse(); - waitTOF(); + g_lab->waitTOF(); updateMouse(); - waitTOF(); + g_lab->waitTOF(); updateMouse(); - waitTOF(); + g_lab->waitTOF(); updateMouse(); place++; @@ -822,8 +821,8 @@ void processMap(uint16 CurRoom) { if ((sptr = Rooms[CurMsg].RoomMsg)) { mouseHide(); - setAPen(3); - rectFill(VGAScaleX(13), VGAScaleY(148), VGAScaleX(135), VGAScaleY(186)); + g_lab->setAPen(3); + g_lab->rectFill(VGAScaleX(13), VGAScaleY(148), VGAScaleX(135), VGAScaleY(186)); flowText(MsgFont, 0, 5, 3, true, true, true, true, VGAScaleX(14), VGAScaleY(148), VGAScaleX(134), VGAScaleY(186), sptr); if (Maps[OldMsg].PageNumber == CurFloor) @@ -834,8 +833,8 @@ void processMap(uint16 CurRoom) { y1 = (y1 + y2) / 2; if ((CurMsg != CurRoom) && (Maps[CurMsg].PageNumber == CurFloor)) { - setAPen(1); - rectFill(x1 - 1, y1, x1, y1); + g_lab->setAPen(1); + g_lab->rectFill(x1 - 1, y1, x1, y1); } mouseShow(); @@ -844,7 +843,7 @@ void processMap(uint16 CurRoom) { } } - WSDL_UpdateScreen(); + g_lab->WSDL_UpdateScreen(); } } } @@ -872,18 +871,18 @@ void doMap(uint16 CurRoom) { drawMap(CurRoom, CurRoom, Maps[CurRoom].PageNumber, false, true); mouseShow(); attachGadgetList(MapGadgetList); - WSDL_UpdateScreen(); + g_lab->WSDL_UpdateScreen(); processMap(CurRoom); attachGadgetList(NULL); fade(false, 0); blackAllScreen(); mouseHide(); - 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); freeMapData(); blackAllScreen(); mouseShow(); - WSDL_UpdateScreen(); + g_lab->WSDL_UpdateScreen(); } } // End of namespace Lab -- 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/map.cpp | 69 +++++++++++++++++++---------------------------------- 1 file changed, 24 insertions(+), 45 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index fdec095f1a..50a551473f 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -63,10 +63,10 @@ void setAmigaPal(uint16 *pal, uint16 numcolors) { if (numcolors > 16) numcolors = 16; - for (uint16 counter = 0; counter < numcolors; counter++) { - vgapal[vgacount++] = (byte)(((pal[counter] & 0xf00) >> 8) << 2); - vgapal[vgacount++] = (byte)(((pal[counter] & 0x0f0) >> 4) << 2); - vgapal[vgacount++] = (byte)(((pal[counter] & 0x00f)) << 2); + for (uint16 i = 0; i < numcolors; i++) { + vgapal[vgacount++] = (byte)(((pal[i] & 0xf00) >> 8) << 2); + vgapal[vgacount++] = (byte)(((pal[i] & 0x0f0) >> 4) << 2); + vgapal[vgacount++] = (byte)(((pal[i] & 0x00f)) << 2); } g_lab->writeColorRegsSmooth(vgapal, 0, 16); @@ -294,18 +294,18 @@ static uint16 fadeNumOut(uint16 num, uint16 res, uint16 counter) { /* Does the fading of the Palette on the screen. */ /*****************************************************************************/ void fade(bool fadein, uint16 res) { - uint16 pennum, counter, newpal[16]; + uint16 newpal[16]; - for (counter = 0; counter < 16; counter++) { - for (pennum = 0; pennum < 16; pennum++) { + for (uint16 i = 0; i < 16; i++) { + for (uint16 palIdx = 0; palIdx < 16; palIdx++) { if (fadein) - newpal[pennum] = (0x00F & fadeNumIn(0x00F & FadePalette[pennum], 0x00F & res, counter)) + - (0x0F0 & fadeNumIn(0x0F0 & FadePalette[pennum], 0x0F0 & res, counter)) + - (0xF00 & fadeNumIn(0xF00 & FadePalette[pennum], 0xF00 & res, counter)); + newpal[palIdx] = (0x00F & fadeNumIn(0x00F & FadePalette[palIdx], 0x00F & res, i)) + + (0x0F0 & fadeNumIn(0x0F0 & FadePalette[palIdx], 0x0F0 & res, i)) + + (0xF00 & fadeNumIn(0xF00 & FadePalette[palIdx], 0xF00 & res, i)); else - newpal[pennum] = (0x00F & fadeNumOut(0x00F & FadePalette[pennum], 0x00F & res, counter)) + - (0x0F0 & fadeNumOut(0x0F0 & FadePalette[pennum], 0x0F0 & res, counter)) + - (0xF00 & fadeNumOut(0xF00 & FadePalette[pennum], 0xF00 & res, counter)); + newpal[palIdx] = (0x00F & fadeNumOut(0x00F & FadePalette[palIdx], 0x00F & res, i)) + + (0x0F0 & fadeNumOut(0x0F0 & FadePalette[palIdx], 0x0F0 & res, i)) + + (0xF00 & fadeNumOut(0xF00 & FadePalette[palIdx], 0xF00 & res, i)); } setAmigaPal(newpal, 16); @@ -314,8 +314,6 @@ void fade(bool fadein, uint16 res) { } } - - /*****************************************************************************/ /* Figures out what a room's coordinates should be. */ /*****************************************************************************/ @@ -350,10 +348,6 @@ static void roomCords(uint16 CurRoom, uint16 *x1, uint16 *y1, uint16 *x2, uint16 } } - - - - /*****************************************************************************/ /* Draws a room to the bitmap. */ /*****************************************************************************/ @@ -489,28 +483,18 @@ static void drawRoom(uint16 CurRoom, bool drawx) { g_lab->drawImage(XMark, xx, xy); } - - /*****************************************************************************/ /* Checks if a floor has been visitted. */ /*****************************************************************************/ static bool onFloor(uint16 Floor) { - uint16 drawroom; - - for (drawroom = 1; drawroom <= MaxRooms; drawroom++) { - if ((Maps[drawroom].PageNumber == Floor) - && g_lab->_roomsFound->in(drawroom) - && Maps[drawroom].x) { + for (uint16 i = 1; i <= MaxRooms; i++) { + if ((Maps[i].PageNumber == Floor) && g_lab->_roomsFound->in(i) && Maps[i].x) return true; - } } return false; } - - - /*****************************************************************************/ /* Figures out which floor, if any, should be gone to if the up arrow is hit */ /*****************************************************************************/ @@ -570,7 +554,6 @@ static void getDownFloor(uint16 *Floor, bool *isfloor) { /* Draws the map */ /*****************************************************************************/ static void drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, bool fadein) { - uint16 drawroom; char *sptr; uint16 tempfloor; @@ -587,11 +570,9 @@ static void drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, b g_lab->drawImage(Map, 0, 0); drawGadgetList(MapGadgetList); - for (drawroom = 1; drawroom <= MaxRooms; drawroom++) { - if ((Maps[drawroom].PageNumber == Floor) - && g_lab->_roomsFound->in(drawroom) - && Maps[drawroom].x) { - drawRoom(drawroom, (bool)(drawroom == CurRoom)); + for (uint16 i = 1; i <= MaxRooms; i++) { + if ((Maps[i].PageNumber == Floor) && g_lab->_roomsFound->in(i) && Maps[i].x) { + drawRoom(i, (bool)(i == CurRoom)); g_music->updateMusic(); } } @@ -674,14 +655,12 @@ static void drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, b mouseShow(); } - - /*****************************************************************************/ /* Processes the map. */ /*****************************************************************************/ void processMap(uint16 CurRoom) { uint32 Class, place = 1; - uint16 Code, Qualifier, MouseX, MouseY, GadgetID, CurFloor, OldFloor, OldMsg, CurMsg, drawroom, x1, y1, x2, y2; + uint16 Code, Qualifier, MouseX, MouseY, GadgetID, CurFloor, OldFloor, OldMsg, CurMsg, x1, y1, x2, y2; char *sptr; byte newcolor[3]; bool drawmap; @@ -804,14 +783,14 @@ void processMap(uint16 CurRoom) { else if (MouseX > mapScaleX(314)) { OldMsg = CurMsg; - for (drawroom = 1; drawroom <= MaxRooms; drawroom++) { - roomCords(drawroom, &x1, &y1, &x2, &y2); + for (uint16 i = 1; i <= MaxRooms; i++) { + roomCords(i, &x1, &y1, &x2, &y2); - if ((Maps[drawroom].PageNumber == CurFloor) - && g_lab->_roomsFound->in(drawroom) + if ((Maps[i].PageNumber == CurFloor) + && g_lab->_roomsFound->in(i) && (MouseX >= x1) && (MouseX <= x2) && (MouseY >= y1) && (MouseY <= y2)) { - CurMsg = drawroom; + CurMsg = i; } } -- cgit v1.2.3 From 8d70f33efe09b01f6f3d48c83f7fbc5c6835d50e Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 28 Nov 2015 02:27:02 +0100 Subject: LAB: Rename RoomData members --- engines/lab/map.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 50a551473f..8cb1eaf189 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -127,7 +127,7 @@ void readImage(byte **buffer, Image **im) { /*------------------------------ The Map stuff ------------------------------*/ /*---------------------------------------------------------------------------*/ -extern RoomData *Rooms; +extern RoomData *_rooms; static Image *Map, *Room, *UpArrowRoom, *DownArrowRoom, *Bridge, *HRoom, *VRoom, *Maze, *HugeMaze, *Path, *MapNorth, @@ -646,7 +646,7 @@ static void drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, b if (sptr) flowText(MsgFont, 0, 5, 3, true, true, true, true, VGAScaleX(14), VGAScaleY(75), VGAScaleX(134), VGAScaleY(97), sptr); - if ((sptr = Rooms[CurMsg].RoomMsg)) + if ((sptr = _rooms[CurMsg]._roomMsg)) flowText(MsgFont, 0, 5, 3, true, true, true, true, VGAScaleX(14), VGAScaleY(148), VGAScaleX(134), VGAScaleY(186), sptr); if (fadein) @@ -795,10 +795,10 @@ void processMap(uint16 CurRoom) { } if (OldMsg != CurMsg) { - if (Rooms[CurMsg].RoomMsg == NULL) + if (_rooms[CurMsg]._roomMsg == nullptr) g_resource->readViews(CurMsg); - if ((sptr = Rooms[CurMsg].RoomMsg)) { + if ((sptr = _rooms[CurMsg]._roomMsg)) { mouseHide(); g_lab->setAPen(3); g_lab->rectFill(VGAScaleX(13), VGAScaleY(148), VGAScaleX(135), VGAScaleY(186)); -- 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/map.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 8cb1eaf189..98082b73f8 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -553,13 +553,13 @@ static void getDownFloor(uint16 *Floor, bool *isfloor) { /*****************************************************************************/ /* Draws the map */ /*****************************************************************************/ -static void drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, bool fadein) { +void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, bool fadein) { char *sptr; uint16 tempfloor; bool noghoast; - mouseHide(); + _event->mouseHide(); if (fadeout) fade(false, 0); @@ -652,13 +652,13 @@ static void drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, b if (fadein) fade(true, 0); - mouseShow(); + _event->mouseShow(); } /*****************************************************************************/ /* Processes the map. */ /*****************************************************************************/ -void processMap(uint16 CurRoom) { +void LabEngine::processMap(uint16 CurRoom) { uint32 Class, place = 1; uint16 Code, Qualifier, MouseX, MouseY, GadgetID, CurFloor, OldFloor, OldMsg, CurMsg, x1, y1, x2, y2; char *sptr; @@ -688,13 +688,13 @@ void processMap(uint16 CurRoom) { g_lab->waitTOF(); g_lab->writeColorReg(newcolor, 1); - updateMouse(); + _event->updateMouse(); g_lab->waitTOF(); - updateMouse(); + _event->updateMouse(); g_lab->waitTOF(); - updateMouse(); + _event->updateMouse(); g_lab->waitTOF(); - updateMouse(); + _event->updateMouse(); place++; @@ -799,7 +799,7 @@ void processMap(uint16 CurRoom) { g_resource->readViews(CurMsg); if ((sptr = _rooms[CurMsg]._roomMsg)) { - mouseHide(); + _event->mouseHide(); g_lab->setAPen(3); g_lab->rectFill(VGAScaleX(13), VGAScaleY(148), VGAScaleX(135), VGAScaleY(186)); flowText(MsgFont, 0, 5, 3, true, true, true, true, VGAScaleX(14), VGAScaleY(148), VGAScaleX(134), VGAScaleY(186), sptr); @@ -816,7 +816,7 @@ void processMap(uint16 CurRoom) { g_lab->rectFill(x1 - 1, y1, x1, y1); } - mouseShow(); + _event->mouseShow(); } } } @@ -831,7 +831,7 @@ void processMap(uint16 CurRoom) { /*****************************************************************************/ /* Does the map processing. */ /*****************************************************************************/ -void doMap(uint16 CurRoom) { +void LabEngine::doMap(uint16 CurRoom) { FadePalette = AmigaMapPalette; g_music->updateMusic(); @@ -848,19 +848,19 @@ void doMap(uint16 CurRoom) { XMark = MapWest; drawMap(CurRoom, CurRoom, Maps[CurRoom].PageNumber, false, true); - mouseShow(); - attachGadgetList(MapGadgetList); + _event->mouseShow(); + _event->attachGadgetList(MapGadgetList); g_lab->WSDL_UpdateScreen(); processMap(CurRoom); - attachGadgetList(NULL); + _event->attachGadgetList(NULL); fade(false, 0); blackAllScreen(); - mouseHide(); + _event->mouseHide(); g_lab->setAPen(0); g_lab->rectFill(0, 0, g_lab->_screenWidth - 1, g_lab->_screenHeight - 1); freeMapData(); blackAllScreen(); - mouseShow(); + _event->mouseShow(); g_lab->WSDL_UpdateScreen(); } -- 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/map.cpp | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 98082b73f8..d41322f426 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -564,21 +564,21 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou if (fadeout) fade(false, 0); - 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); - g_lab->drawImage(Map, 0, 0); + drawImage(Map, 0, 0); drawGadgetList(MapGadgetList); for (uint16 i = 1; i <= MaxRooms; i++) { - if ((Maps[i].PageNumber == Floor) && g_lab->_roomsFound->in(i) && Maps[i].x) { + if ((Maps[i].PageNumber == Floor) && _roomsFound->in(i) && Maps[i].x) { drawRoom(i, (bool)(i == CurRoom)); g_music->updateMusic(); } } if ((Maps[CurRoom].PageNumber == Floor) /* Makes sure the X is drawn in corridors */ - && g_lab->_roomsFound->in(CurRoom) /* NOTE: this here on purpose just in case there's some weird condition, like the surreal maze where there are no rooms */ + && _roomsFound->in(CurRoom) /* NOTE: this here on purpose just in case there's some weird condition, like the surreal maze where there are no rooms */ && Maps[CurRoom].x) drawRoom(CurRoom, true); @@ -601,16 +601,16 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou // Labyrinth specific code if (Floor == LOWERFLOOR) { if (onFloor(SURMAZEFLOOR)) - g_lab->drawImage(Maze, mapScaleX(538), mapScaleY(277)); + drawImage(Maze, mapScaleX(538), mapScaleY(277)); } else if (Floor == MIDDLEFLOOR) { if (onFloor(CARNIVAL)) - g_lab->drawImage(Maze, mapScaleX(358), mapScaleY(72)); + drawImage(Maze, mapScaleX(358), mapScaleY(72)); if (onFloor(MEDMAZEFLOOR)) - g_lab->drawImage(Maze, mapScaleX(557), mapScaleY(325)); + drawImage(Maze, mapScaleX(557), mapScaleY(325)); } else if (Floor == UPPERFLOOR) { if (onFloor(HEDGEMAZEFLOOR)) - g_lab->drawImage(HugeMaze, mapScaleX(524), mapScaleY(97)); + drawImage(HugeMaze, mapScaleX(524), mapScaleY(97)); } else if (Floor == SURMAZEFLOOR) { sptr = (char *)g_resource->getStaticText(kTextSurmazeMessage).c_str(); flowText(MsgFont, 0, 7, 0, true, true, true, true, mapScaleX(360), 0, mapScaleX(660), mapScaleY(450), sptr); @@ -686,14 +686,14 @@ void LabEngine::processMap(uint16 CurRoom) { newcolor[2] = newcolor[1]; } - g_lab->waitTOF(); - g_lab->writeColorReg(newcolor, 1); + waitTOF(); + writeColorReg(newcolor, 1); _event->updateMouse(); - g_lab->waitTOF(); + waitTOF(); _event->updateMouse(); - g_lab->waitTOF(); + waitTOF(); _event->updateMouse(); - g_lab->waitTOF(); + waitTOF(); _event->updateMouse(); place++; @@ -787,7 +787,7 @@ void LabEngine::processMap(uint16 CurRoom) { roomCords(i, &x1, &y1, &x2, &y2); if ((Maps[i].PageNumber == CurFloor) - && g_lab->_roomsFound->in(i) + && _roomsFound->in(i) && (MouseX >= x1) && (MouseX <= x2) && (MouseY >= y1) && (MouseY <= y2)) { CurMsg = i; @@ -800,8 +800,8 @@ void LabEngine::processMap(uint16 CurRoom) { if ((sptr = _rooms[CurMsg]._roomMsg)) { _event->mouseHide(); - g_lab->setAPen(3); - g_lab->rectFill(VGAScaleX(13), VGAScaleY(148), VGAScaleX(135), VGAScaleY(186)); + setAPen(3); + rectFill(VGAScaleX(13), VGAScaleY(148), VGAScaleX(135), VGAScaleY(186)); flowText(MsgFont, 0, 5, 3, true, true, true, true, VGAScaleX(14), VGAScaleY(148), VGAScaleX(134), VGAScaleY(186), sptr); if (Maps[OldMsg].PageNumber == CurFloor) @@ -812,8 +812,8 @@ void LabEngine::processMap(uint16 CurRoom) { y1 = (y1 + y2) / 2; if ((CurMsg != CurRoom) && (Maps[CurMsg].PageNumber == CurFloor)) { - g_lab->setAPen(1); - g_lab->rectFill(x1 - 1, y1, x1, y1); + setAPen(1); + rectFill(x1 - 1, y1, x1, y1); } _event->mouseShow(); @@ -822,7 +822,7 @@ void LabEngine::processMap(uint16 CurRoom) { } } - g_lab->WSDL_UpdateScreen(); + WSDL_UpdateScreen(); } } } @@ -850,18 +850,18 @@ void LabEngine::doMap(uint16 CurRoom) { drawMap(CurRoom, CurRoom, Maps[CurRoom].PageNumber, false, true); _event->mouseShow(); _event->attachGadgetList(MapGadgetList); - g_lab->WSDL_UpdateScreen(); + WSDL_UpdateScreen(); processMap(CurRoom); _event->attachGadgetList(NULL); fade(false, 0); blackAllScreen(); _event->mouseHide(); - 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); freeMapData(); blackAllScreen(); _event->mouseShow(); - g_lab->WSDL_UpdateScreen(); + WSDL_UpdateScreen(); } } // End of namespace Lab -- 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/map.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index d41322f426..e4b8b3258a 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -47,7 +47,6 @@ static TextFont bmf; extern uint16 Direction; -extern bool IsHiRes; extern CloseDataPtr CPtr; extern uint16 RoomNum; @@ -170,7 +169,7 @@ static uint16 AmigaMapPalette[] = { static uint16 mapScaleX(uint16 x) { - if (IsHiRes) + if (g_lab->_isHiRes) return (x - 45); else return ((x - 45) >> 1); @@ -179,7 +178,7 @@ static uint16 mapScaleX(uint16 x) { static uint16 mapScaleY(uint16 y) { - if (IsHiRes) + if (g_lab->_isHiRes) return y; else return ((y - 35) >> 1) - (y >> 6); -- 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/map.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index e4b8b3258a..e4a6f04c74 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -196,7 +196,7 @@ static bool loadMapData() { BigMsgFont = &bmf; - if (!(BigMsgFont = g_resource->getFont("P:Map.fon"))) + if (!(BigMsgFont = g_lab->_resource->getFont("P:Map.fon"))) BigMsgFont = MsgFont; resetBuffer(); /* Make images load into start of buffer */ @@ -249,7 +249,7 @@ static bool loadMapData() { counter++; } - Common::File *mapFile = g_resource->openDataFile("Lab:Maps", MKTAG('M', 'A', 'P', '0')); + Common::File *mapFile = g_lab->_resource->openDataFile("Lab:Maps", MKTAG('M', 'A', 'P', '0')); if (!mapFile) error("Corrupt map file"); g_music->updateMusic(); @@ -611,31 +611,31 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou if (onFloor(HEDGEMAZEFLOOR)) drawImage(HugeMaze, mapScaleX(524), mapScaleY(97)); } else if (Floor == SURMAZEFLOOR) { - sptr = (char *)g_resource->getStaticText(kTextSurmazeMessage).c_str(); + sptr = (char *)_resource->getStaticText(kTextSurmazeMessage).c_str(); flowText(MsgFont, 0, 7, 0, true, true, true, true, mapScaleX(360), 0, mapScaleX(660), mapScaleY(450), sptr); } switch (Floor) { case LOWERFLOOR: - sptr = (char *)g_resource->getStaticText(kTextLowerFloor).c_str(); + sptr = (char *)_resource->getStaticText(kTextLowerFloor).c_str(); break; case MIDDLEFLOOR: - sptr = (char *)g_resource->getStaticText(kTextMiddleFloor).c_str(); + sptr = (char *)_resource->getStaticText(kTextMiddleFloor).c_str(); break; case UPPERFLOOR: - sptr = (char *)g_resource->getStaticText(kTextUpperFloor).c_str(); + sptr = (char *)_resource->getStaticText(kTextUpperFloor).c_str(); break; case MEDMAZEFLOOR: - sptr = (char *)g_resource->getStaticText(kTextMedMazeFloor).c_str(); + sptr = (char *)_resource->getStaticText(kTextMedMazeFloor).c_str(); break; case HEDGEMAZEFLOOR: - sptr = (char *)g_resource->getStaticText(kTextHedgeMazeFloor).c_str(); + sptr = (char *)_resource->getStaticText(kTextHedgeMazeFloor).c_str(); break; case SURMAZEFLOOR: - sptr = (char *)g_resource->getStaticText(kTextSurMazeFloor).c_str(); + sptr = (char *)_resource->getStaticText(kTextSurMazeFloor).c_str(); break; case CARNIVAL: - sptr = (char *)g_resource->getStaticText(kTextCarnivalFloor).c_str(); + sptr = (char *)_resource->getStaticText(kTextCarnivalFloor).c_str(); break; default: sptr = NULL; @@ -795,7 +795,7 @@ void LabEngine::processMap(uint16 CurRoom) { if (OldMsg != CurMsg) { if (_rooms[CurMsg]._roomMsg == nullptr) - g_resource->readViews(CurMsg); + _resource->readViews(CurMsg); if ((sptr = _rooms[CurMsg]._roomMsg)) { _event->mouseHide(); -- 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/map.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index e4a6f04c74..6c2201608e 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -84,9 +84,9 @@ char *getText(const char *filename) { bool dodecrypt; byte **tfile; - g_music->updateMusic(); + g_lab->g_music->updateMusic(); dodecrypt = (isBuffered(filename) == NULL); - tfile = g_music->newOpen(filename); + tfile = g_lab->g_music->newOpen(filename); if (!tfile) return NULL; @@ -200,7 +200,7 @@ static bool loadMapData() { BigMsgFont = MsgFont; resetBuffer(); /* Make images load into start of buffer */ - buffer = g_music->newOpen("P:MapImage", Size); + buffer = g_lab->g_music->newOpen("P:MapImage", Size); if (!buffer) return false; @@ -252,9 +252,9 @@ static bool loadMapData() { Common::File *mapFile = g_lab->_resource->openDataFile("Lab:Maps", MKTAG('M', 'A', 'P', '0')); if (!mapFile) error("Corrupt map file"); - g_music->updateMusic(); - if (!g_music->_doNotFilestopSoundEffect) - g_music->stopSoundEffect(); + g_lab->g_music->updateMusic(); + if (!g_lab->g_music->_doNotFilestopSoundEffect) + g_lab->g_music->stopSoundEffect(); MaxRooms = mapFile->readUint16LE(); Maps = new MapData[MaxRooms]; // will be freed when the user exits the map @@ -309,7 +309,7 @@ void fade(bool fadein, uint16 res) { setAmigaPal(newpal, 16); g_lab->waitTOF(); - g_music->updateMusic(); + g_lab->g_music->updateMusic(); } } -- 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/map.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 6c2201608e..ac612fb881 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -84,9 +84,9 @@ char *getText(const char *filename) { bool dodecrypt; byte **tfile; - g_lab->g_music->updateMusic(); + g_lab->_music->updateMusic(); dodecrypt = (isBuffered(filename) == NULL); - tfile = g_lab->g_music->newOpen(filename); + tfile = g_lab->_music->newOpen(filename); if (!tfile) return NULL; @@ -200,7 +200,7 @@ static bool loadMapData() { BigMsgFont = MsgFont; resetBuffer(); /* Make images load into start of buffer */ - buffer = g_lab->g_music->newOpen("P:MapImage", Size); + buffer = g_lab->_music->newOpen("P:MapImage", Size); if (!buffer) return false; @@ -252,9 +252,9 @@ static bool loadMapData() { Common::File *mapFile = g_lab->_resource->openDataFile("Lab:Maps", MKTAG('M', 'A', 'P', '0')); if (!mapFile) error("Corrupt map file"); - g_lab->g_music->updateMusic(); - if (!g_lab->g_music->_doNotFilestopSoundEffect) - g_lab->g_music->stopSoundEffect(); + g_lab->_music->updateMusic(); + if (!g_lab->_music->_doNotFilestopSoundEffect) + g_lab->_music->stopSoundEffect(); MaxRooms = mapFile->readUint16LE(); Maps = new MapData[MaxRooms]; // will be freed when the user exits the map @@ -309,7 +309,7 @@ void fade(bool fadein, uint16 res) { setAmigaPal(newpal, 16); g_lab->waitTOF(); - g_lab->g_music->updateMusic(); + g_lab->_music->updateMusic(); } } @@ -572,7 +572,7 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou for (uint16 i = 1; i <= MaxRooms; i++) { if ((Maps[i].PageNumber == Floor) && _roomsFound->in(i) && Maps[i].x) { drawRoom(i, (bool)(i == CurRoom)); - g_music->updateMusic(); + _music->updateMusic(); } } @@ -669,11 +669,11 @@ void LabEngine::processMap(uint16 CurRoom) { CurFloor = Maps[CurRoom].PageNumber; 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(); if (place <= 14) { newcolor[0] = 14 << 2; @@ -833,7 +833,7 @@ void LabEngine::processMap(uint16 CurRoom) { void LabEngine::doMap(uint16 CurRoom) { FadePalette = AmigaMapPalette; - g_music->updateMusic(); + _music->updateMusic(); loadMapData(); blackAllScreen(); -- 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/map.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index ac612fb881..859d1ffa2f 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -49,7 +49,6 @@ static TextFont bmf; extern uint16 Direction; extern CloseDataPtr CPtr; -extern uint16 RoomNum; /*****************************************************************************/ /* Converts an Amiga palette (up to 16 colors) to a VGA palette, then sets */ -- 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/map.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 859d1ffa2f..2db36103b5 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -820,7 +820,7 @@ void LabEngine::processMap(uint16 CurRoom) { } } - WSDL_UpdateScreen(); + screenUpdate(); } } } @@ -848,7 +848,7 @@ void LabEngine::doMap(uint16 CurRoom) { drawMap(CurRoom, CurRoom, Maps[CurRoom].PageNumber, false, true); _event->mouseShow(); _event->attachGadgetList(MapGadgetList); - WSDL_UpdateScreen(); + screenUpdate(); processMap(CurRoom); _event->attachGadgetList(NULL); fade(false, 0); @@ -859,7 +859,7 @@ void LabEngine::doMap(uint16 CurRoom) { freeMapData(); blackAllScreen(); _event->mouseShow(); - WSDL_UpdateScreen(); + screenUpdate(); } } // End of namespace Lab -- 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/map.cpp | 36 ------------------------------------ 1 file changed, 36 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 2db36103b5..02cdbfb1ac 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -42,10 +42,6 @@ namespace Lab { -static TextFont *BigMsgFont; -static TextFont bmf; - - extern uint16 Direction; extern CloseDataPtr CPtr; @@ -70,33 +66,6 @@ void setAmigaPal(uint16 *pal, uint16 numcolors) { g_lab->writeColorRegsSmooth(vgapal, 0, 16); } -void decrypt(byte *text) { - while (text && *text != '\0') { - *text++ -= (byte)95; - } -} - -/*****************************************************************************/ -/* Gets a chunk of text and puts it into the graphics memory. */ -/*****************************************************************************/ -char *getText(const char *filename) { - bool dodecrypt; - byte **tfile; - - g_lab->_music->updateMusic(); - dodecrypt = (isBuffered(filename) == NULL); - tfile = g_lab->_music->newOpen(filename); - - if (!tfile) - return NULL; - - if (dodecrypt) - decrypt(*tfile); - - return (char *)*tfile; -} - - /*****************************************************************************/ /* Reads in an image from disk. */ @@ -193,11 +162,6 @@ static bool loadMapData() { Gadget *gptr; uint16 counter; - BigMsgFont = &bmf; - - if (!(BigMsgFont = g_lab->_resource->getFont("P:Map.fon"))) - BigMsgFont = MsgFont; - resetBuffer(); /* Make images load into start of buffer */ buffer = g_lab->_music->newOpen("P:MapImage", Size); -- 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/map.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 02cdbfb1ac..36b01d10f7 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -29,7 +29,6 @@ */ #include "lab/lab.h" -#include "lab/stddefines.h" #include "lab/labfun.h" #include "lab/diff.h" #include "lab/text.h" -- 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/map.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 36b01d10f7..1f4f0dbfe1 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -30,7 +30,7 @@ #include "lab/lab.h" #include "lab/labfun.h" -#include "lab/diff.h" +#include "lab/anim.h" #include "lab/text.h" #include "lab/mouse.h" #include "lab/parsefun.h" -- 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/map.cpp | 129 +++++++++++++++++++++------------------------------- 1 file changed, 53 insertions(+), 76 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 1f4f0dbfe1..d7a3e124ca 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -31,6 +31,7 @@ #include "lab/lab.h" #include "lab/labfun.h" #include "lab/anim.h" +#include "lab/image.h" #include "lab/text.h" #include "lab/mouse.h" #include "lab/parsefun.h" @@ -65,30 +66,6 @@ void setAmigaPal(uint16 *pal, uint16 numcolors) { g_lab->writeColorRegsSmooth(vgapal, 0, 16); } - -/*****************************************************************************/ -/* Reads in an image from disk. */ -/*****************************************************************************/ -void readImage(byte **buffer, Image **im) { - uint32 size; - - (*im) = (Image *)(*buffer); - - (*im)->Width = READ_LE_UINT16(*buffer); - (*im)->Height = READ_LE_UINT16(*buffer + 2); - - *buffer += 8; /* sizeof(struct Image); */ - - size = (*im)->Width * (*im)->Height; - - if (1L & size) - size++; - - (*im)->ImageData = (byte *)(*buffer); - (*buffer) += size; -} - - /*---------------------------------------------------------------------------*/ /*------------------------------ The Map stuff ------------------------------*/ /*---------------------------------------------------------------------------*/ @@ -169,30 +146,30 @@ static bool loadMapData() { stealBufMem(Size); /* Now freeze that buffer from further use */ - readImage(buffer, &Map); + Map = new Image(buffer); - readImage(buffer, &Room); - readImage(buffer, &UpArrowRoom); - readImage(buffer, &DownArrowRoom); - readImage(buffer, &HRoom); - readImage(buffer, &VRoom); - readImage(buffer, &Maze); - readImage(buffer, &HugeMaze); + Room = new Image(buffer); + UpArrowRoom = new Image(buffer); + DownArrowRoom = new Image(buffer); + HRoom = new Image(buffer); + VRoom = new Image(buffer); + Maze = new Image(buffer); + HugeMaze = new Image(buffer); - readImage(buffer, &MapNorth); - readImage(buffer, &MapEast); - readImage(buffer, &MapSouth); - readImage(buffer, &MapWest); + MapNorth = new Image(buffer); + MapEast = new Image(buffer); + MapSouth = new Image(buffer); + MapWest = new Image(buffer); - readImage(buffer, &Path); - readImage(buffer, &Bridge); + Path = new Image(buffer); + Bridge = new Image(buffer); - readImage(buffer, &Back); - readImage(buffer, &BackAlt); - readImage(buffer, &Up); - readImage(buffer, &UpAlt); - readImage(buffer, &Down); - readImage(buffer, &DownAlt); + Back = new Image(buffer); + BackAlt = new Image(buffer); + Up = new Image(buffer); + UpAlt = new Image(buffer); + Down = new Image(buffer); + DownAlt = new Image(buffer); backgadget.Im = Back; backgadget.ImAlt = BackAlt; @@ -325,27 +302,27 @@ static void drawRoom(uint16 CurRoom, bool drawx) { case UPARROWROOM: case DOWNARROWROOM: if (Maps[CurRoom].SpecialID == NORMAL) - g_lab->drawImage(Room, x, y); + Room->drawImage(x, y); else if (Maps[CurRoom].SpecialID == DOWNARROWROOM) - g_lab->drawImage(DownArrowRoom, x, y); + DownArrowRoom->drawImage(x, y); else - g_lab->drawImage(UpArrowRoom, x, y); + UpArrowRoom->drawImage(x, y); offset = (Room->Width - Path->Width) / 2; if ((NORTHDOOR & flags) && (y >= Path->Height)) - g_lab->drawImage(Path, x + offset, y - Path->Height); + Path->drawImage(x + offset, y - Path->Height); if (SOUTHDOOR & flags) - g_lab->drawImage(Path, x + offset, y + Room->Height); + Path->drawImage(x + offset, y + Room->Height); offset = (Room->Height - Path->Height) / 2; if (EASTDOOR & flags) - g_lab->drawImage(Path, x + Room->Width, y + offset); + Path->drawImage(x + Room->Width, y + offset); if (WESTDOOR & flags) - g_lab->drawImage(Path, x - Path->Width, y + offset); + Path->drawImage(x - Path->Width, y + offset); xx = x + (Room->Width - XMark->Width) / 2; xy = y + (Room->Height - XMark->Height) / 2; @@ -353,7 +330,7 @@ static void drawRoom(uint16 CurRoom, bool drawx) { break; case BRIDGEROOM: - g_lab->drawImage(Bridge, x, y); + Bridge->drawImage(x, y); xx = x + (Bridge->Width - XMark->Width) / 2; xy = y + (Bridge->Height - XMark->Height) / 2; @@ -361,37 +338,37 @@ static void drawRoom(uint16 CurRoom, bool drawx) { break; case VCORRIDOR: - g_lab->drawImage(VRoom, x, y); + VRoom->drawImage(x, y); offset = (VRoom->Width - Path->Width) / 2; if (NORTHDOOR & flags) - g_lab->drawImage(Path, x + offset, y - Path->Height); + Path->drawImage(x + offset, y - Path->Height); if (SOUTHDOOR & flags) - g_lab->drawImage(Path, x + offset, y + VRoom->Height); + Path->drawImage(x + offset, y + VRoom->Height); offset = (Room->Height - Path->Height) / 2; if (EASTDOOR & flags) - g_lab->drawImage(Path, x + VRoom->Width, y + offset); + Path->drawImage(x + VRoom->Width, y + offset); if (WESTDOOR & flags) - g_lab->drawImage(Path, x - Path->Width, y + offset); + Path->drawImage(x - Path->Width, y + offset); if (EASTBDOOR & flags) - g_lab->drawImage(Path, x + VRoom->Width, y - offset - Path->Height + VRoom->Height); + Path->drawImage(x + VRoom->Width, y - offset - Path->Height + VRoom->Height); if (WESTBDOOR & flags) - g_lab->drawImage(Path, x - Path->Width, y - offset - Path->Height + VRoom->Height); + Path->drawImage(x - Path->Width, y - offset - Path->Height + VRoom->Height); offset = (VRoom->Height - Path->Height) / 2; if (EASTMDOOR & flags) - g_lab->drawImage(Path, x + VRoom->Width, y - offset - Path->Height + VRoom->Height); + Path->drawImage(x + VRoom->Width, y - offset - Path->Height + VRoom->Height); if (WESTMDOOR & flags) - g_lab->drawImage(Path, x - Path->Width, y - offset - Path->Height + VRoom->Height); + Path->drawImage(x - Path->Width, y - offset - Path->Height + VRoom->Height); xx = x + (VRoom->Width - XMark->Width) / 2; xy = y + (VRoom->Height - XMark->Height) / 2; @@ -399,37 +376,37 @@ static void drawRoom(uint16 CurRoom, bool drawx) { break; case HCORRIDOR: - g_lab->drawImage(HRoom, x, y); + HRoom->drawImage(x, y); offset = (Room->Width - Path->Width) / 2; if (NORTHDOOR & flags) - g_lab->drawImage(Path, x + offset, y - Path->Height); + Path->drawImage(x + offset, y - Path->Height); if (SOUTHDOOR & flags) - g_lab->drawImage(Path, x + offset, y + Room->Height); + Path->drawImage(x + offset, y + Room->Height); if (NORTHRDOOR & flags) - g_lab->drawImage(Path, x - offset - Path->Width + HRoom->Width, y - Path->Height); + Path->drawImage(x - offset - Path->Width + HRoom->Width, y - Path->Height); if (SOUTHRDOOR & flags) - g_lab->drawImage(Path, x - offset - Path->Width + HRoom->Width, y + Room->Height); + Path->drawImage(x - offset - Path->Width + HRoom->Width, y + Room->Height); offset = (HRoom->Width - Path->Width) / 2; if (NORTHMDOOR & flags) - g_lab->drawImage(Path, x - offset - Path->Width + HRoom->Width, y - Path->Height); + Path->drawImage(x - offset - Path->Width + HRoom->Width, y - Path->Height); if (SOUTHMDOOR & flags) - g_lab->drawImage(Path, x - offset - Path->Width + HRoom->Width, y + Room->Height); + Path->drawImage(x - offset - Path->Width + HRoom->Width, y + Room->Height); offset = (Room->Height - Path->Height) / 2; if (EASTDOOR & flags) - g_lab->drawImage(Path, x + HRoom->Width, y + offset); + Path->drawImage(x + HRoom->Width, y + offset); if (WESTDOOR & flags) - g_lab->drawImage(Path, x - Path->Width, y + offset); + Path->drawImage(x - Path->Width, y + offset); xx = x + (HRoom->Width - XMark->Width) / 2; xy = y + (HRoom->Height - XMark->Height) / 2; @@ -441,7 +418,7 @@ static void drawRoom(uint16 CurRoom, bool drawx) { } if (drawx) - g_lab->drawImage(XMark, xx, xy); + XMark->drawImage(xx, xy); } /*****************************************************************************/ @@ -528,7 +505,7 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou setAPen(0); rectFill(0, 0, _screenWidth - 1, _screenHeight - 1); - drawImage(Map, 0, 0); + Map->drawImage(0, 0); drawGadgetList(MapGadgetList); for (uint16 i = 1; i <= MaxRooms; i++) { @@ -562,16 +539,16 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou // Labyrinth specific code if (Floor == LOWERFLOOR) { if (onFloor(SURMAZEFLOOR)) - drawImage(Maze, mapScaleX(538), mapScaleY(277)); + Maze->drawImage(mapScaleX(538), mapScaleY(277)); } else if (Floor == MIDDLEFLOOR) { if (onFloor(CARNIVAL)) - drawImage(Maze, mapScaleX(358), mapScaleY(72)); + Maze->drawImage(mapScaleX(358), mapScaleY(72)); if (onFloor(MEDMAZEFLOOR)) - drawImage(Maze, mapScaleX(557), mapScaleY(325)); + Maze->drawImage(mapScaleX(557), mapScaleY(325)); } else if (Floor == UPPERFLOOR) { if (onFloor(HEDGEMAZEFLOOR)) - drawImage(HugeMaze, mapScaleX(524), mapScaleY(97)); + HugeMaze->drawImage(mapScaleX(524), mapScaleY(97)); } else if (Floor == SURMAZEFLOOR) { sptr = (char *)_resource->getStaticText(kTextSurmazeMessage).c_str(); flowText(MsgFont, 0, 7, 0, true, true, true, true, mapScaleX(360), 0, mapScaleX(660), mapScaleY(450), sptr); -- 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/map.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index d7a3e124ca..43f8fd3267 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -171,12 +171,12 @@ static bool loadMapData() { Down = new Image(buffer); DownAlt = new Image(buffer); - backgadget.Im = Back; - backgadget.ImAlt = BackAlt; - upgadget.Im = Up; - upgadget.ImAlt = UpAlt; - downgadget.Im = Down; - downgadget.ImAlt = DownAlt; + backgadget._image = Back; + backgadget._altImage = BackAlt; + upgadget._image = Up; + upgadget._altImage = UpAlt; + downgadget._image = Down; + downgadget._altImage = DownAlt; counter = 0; gptr = MapGadgetList; -- 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/map.cpp | 90 ++++++++++++++++++++++++++--------------------------- 1 file changed, 45 insertions(+), 45 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 43f8fd3267..0690ed0fb9 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -265,23 +265,23 @@ static void roomCords(uint16 CurRoom, uint16 *x1, uint16 *y1, uint16 *x2, uint16 case NORMAL: case UPARROWROOM: case DOWNARROWROOM: - (*x2) += Room->Width; - (*y2) += Room->Height; + (*x2) += Room->_width; + (*y2) += Room->_height; break; case BRIDGEROOM: - (*x2) += Bridge->Width; - (*y2) += Bridge->Height; + (*x2) += Bridge->_width; + (*y2) += Bridge->_height; break; case VCORRIDOR: - (*x2) += VRoom->Width; - (*y2) += VRoom->Height; + (*x2) += VRoom->_width; + (*y2) += VRoom->_height; break; case HCORRIDOR: - (*x2) += HRoom->Width; - (*y2) += HRoom->Height; + (*x2) += HRoom->_width; + (*y2) += HRoom->_height; break; } } @@ -308,108 +308,108 @@ static void drawRoom(uint16 CurRoom, bool drawx) { else UpArrowRoom->drawImage(x, y); - offset = (Room->Width - Path->Width) / 2; + offset = (Room->_width - Path->_width) / 2; - if ((NORTHDOOR & flags) && (y >= Path->Height)) - Path->drawImage(x + offset, y - Path->Height); + if ((NORTHDOOR & flags) && (y >= Path->_height)) + Path->drawImage(x + offset, y - Path->_height); if (SOUTHDOOR & flags) - Path->drawImage(x + offset, y + Room->Height); + Path->drawImage(x + offset, y + Room->_height); - offset = (Room->Height - Path->Height) / 2; + offset = (Room->_height - Path->_height) / 2; if (EASTDOOR & flags) - Path->drawImage(x + Room->Width, y + offset); + Path->drawImage(x + Room->_width, y + offset); if (WESTDOOR & flags) - Path->drawImage(x - Path->Width, y + offset); + Path->drawImage(x - Path->_width, y + offset); - xx = x + (Room->Width - XMark->Width) / 2; - xy = y + (Room->Height - XMark->Height) / 2; + xx = x + (Room->_width - XMark->_width) / 2; + xy = y + (Room->_height - XMark->_height) / 2; break; case BRIDGEROOM: Bridge->drawImage(x, y); - xx = x + (Bridge->Width - XMark->Width) / 2; - xy = y + (Bridge->Height - XMark->Height) / 2; + xx = x + (Bridge->_width - XMark->_width) / 2; + xy = y + (Bridge->_height - XMark->_height) / 2; break; case VCORRIDOR: VRoom->drawImage(x, y); - offset = (VRoom->Width - Path->Width) / 2; + offset = (VRoom->_width - Path->_width) / 2; if (NORTHDOOR & flags) - Path->drawImage(x + offset, y - Path->Height); + Path->drawImage(x + offset, y - Path->_height); if (SOUTHDOOR & flags) - Path->drawImage(x + offset, y + VRoom->Height); + Path->drawImage(x + offset, y + VRoom->_height); - offset = (Room->Height - Path->Height) / 2; + offset = (Room->_height - Path->_height) / 2; if (EASTDOOR & flags) - Path->drawImage(x + VRoom->Width, y + offset); + Path->drawImage(x + VRoom->_width, y + offset); if (WESTDOOR & flags) - Path->drawImage(x - Path->Width, y + offset); + Path->drawImage(x - Path->_width, y + offset); if (EASTBDOOR & flags) - Path->drawImage(x + VRoom->Width, y - offset - Path->Height + VRoom->Height); + Path->drawImage(x + VRoom->_width, y - offset - Path->_height + VRoom->_height); if (WESTBDOOR & flags) - Path->drawImage(x - Path->Width, y - offset - Path->Height + VRoom->Height); + Path->drawImage(x - Path->_width, y - offset - Path->_height + VRoom->_height); - offset = (VRoom->Height - Path->Height) / 2; + offset = (VRoom->_height - Path->_height) / 2; if (EASTMDOOR & flags) - Path->drawImage(x + VRoom->Width, y - offset - Path->Height + VRoom->Height); + Path->drawImage(x + VRoom->_width, y - offset - Path->_height + VRoom->_height); if (WESTMDOOR & flags) - Path->drawImage(x - Path->Width, y - offset - Path->Height + VRoom->Height); + Path->drawImage(x - Path->_width, y - offset - Path->_height + VRoom->_height); - xx = x + (VRoom->Width - XMark->Width) / 2; - xy = y + (VRoom->Height - XMark->Height) / 2; + xx = x + (VRoom->_width - XMark->_width) / 2; + xy = y + (VRoom->_height - XMark->_height) / 2; break; case HCORRIDOR: HRoom->drawImage(x, y); - offset = (Room->Width - Path->Width) / 2; + offset = (Room->_width - Path->_width) / 2; if (NORTHDOOR & flags) - Path->drawImage(x + offset, y - Path->Height); + Path->drawImage(x + offset, y - Path->_height); if (SOUTHDOOR & flags) - Path->drawImage(x + offset, y + Room->Height); + Path->drawImage(x + offset, y + Room->_height); if (NORTHRDOOR & flags) - Path->drawImage(x - offset - Path->Width + HRoom->Width, y - Path->Height); + Path->drawImage(x - offset - Path->_width + HRoom->_width, y - Path->_height); if (SOUTHRDOOR & flags) - Path->drawImage(x - offset - Path->Width + HRoom->Width, y + Room->Height); + Path->drawImage(x - offset - Path->_width + HRoom->_width, y + Room->_height); - offset = (HRoom->Width - Path->Width) / 2; + offset = (HRoom->_width - Path->_width) / 2; if (NORTHMDOOR & flags) - Path->drawImage(x - offset - Path->Width + HRoom->Width, y - Path->Height); + Path->drawImage(x - offset - Path->_width + HRoom->_width, y - Path->_height); if (SOUTHMDOOR & flags) - Path->drawImage(x - offset - Path->Width + HRoom->Width, y + Room->Height); + Path->drawImage(x - offset - Path->_width + HRoom->_width, y + Room->_height); - offset = (Room->Height - Path->Height) / 2; + offset = (Room->_height - Path->_height) / 2; if (EASTDOOR & flags) - Path->drawImage(x + HRoom->Width, y + offset); + Path->drawImage(x + HRoom->_width, y + offset); if (WESTDOOR & flags) - Path->drawImage(x - Path->Width, y + offset); + Path->drawImage(x - Path->_width, y + offset); - xx = x + (HRoom->Width - XMark->Width) / 2; - xy = y + (HRoom->Height - XMark->Height) / 2; + xx = x + (HRoom->_width - XMark->_width) / 2; + xy = y + (HRoom->_height - XMark->_height) / 2; break; -- 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/map.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 0690ed0fb9..efc1825b4b 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -33,7 +33,6 @@ #include "lab/anim.h" #include "lab/image.h" #include "lab/text.h" -#include "lab/mouse.h" #include "lab/parsefun.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/map.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index efc1825b4b..05c60b1094 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -81,8 +81,6 @@ static MapData *Maps; extern char *LOWERFLOORS, *MIDDLEFLOORS, *UPPERFLOORS, *MEDMAZEFLOORS, *HEDGEMAZEFLOORS, *SURMAZEFLOORS, *CARNIVALFLOOR, *SURMAZEMSG; -extern TextFont *MsgFont; - uint16 *FadePalette; static uint16 MapGadX[3] = {101, 55, 8}, MapGadY[3] = {105, 105, 105}; @@ -550,7 +548,7 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou HugeMaze->drawImage(mapScaleX(524), mapScaleY(97)); } else if (Floor == SURMAZEFLOOR) { sptr = (char *)_resource->getStaticText(kTextSurmazeMessage).c_str(); - flowText(MsgFont, 0, 7, 0, true, true, true, true, mapScaleX(360), 0, mapScaleX(660), mapScaleY(450), sptr); + flowText(_msgFont, 0, 7, 0, true, true, true, true, mapScaleX(360), 0, mapScaleX(660), mapScaleY(450), sptr); } switch (Floor) { @@ -581,10 +579,10 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou } if (sptr) - flowText(MsgFont, 0, 5, 3, true, true, true, true, VGAScaleX(14), VGAScaleY(75), VGAScaleX(134), VGAScaleY(97), sptr); + flowText(_msgFont, 0, 5, 3, true, true, true, true, VGAScaleX(14), VGAScaleY(75), VGAScaleX(134), VGAScaleY(97), sptr); if ((sptr = _rooms[CurMsg]._roomMsg)) - flowText(MsgFont, 0, 5, 3, true, true, true, true, VGAScaleX(14), VGAScaleY(148), VGAScaleX(134), VGAScaleY(186), sptr); + flowText(_msgFont, 0, 5, 3, true, true, true, true, VGAScaleX(14), VGAScaleY(148), VGAScaleX(134), VGAScaleY(186), sptr); if (fadein) fade(true, 0); @@ -739,7 +737,7 @@ void LabEngine::processMap(uint16 CurRoom) { _event->mouseHide(); setAPen(3); rectFill(VGAScaleX(13), VGAScaleY(148), VGAScaleX(135), VGAScaleY(186)); - flowText(MsgFont, 0, 5, 3, true, true, true, true, VGAScaleX(14), VGAScaleY(148), VGAScaleX(134), VGAScaleY(186), sptr); + flowText(_msgFont, 0, 5, 3, true, true, true, true, VGAScaleX(14), VGAScaleY(148), VGAScaleX(134), VGAScaleY(186), sptr); if (Maps[OldMsg].PageNumber == CurFloor) drawRoom(OldMsg, (bool)(OldMsg == CurRoom)); -- 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/map.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 05c60b1094..b5855eaf58 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -43,8 +43,6 @@ namespace Lab { extern uint16 Direction; -extern CloseDataPtr CPtr; - /*****************************************************************************/ /* Converts an Amiga palette (up to 16 colors) to a VGA palette, then sets */ /* the VGA palette. */ -- cgit v1.2.3 From 23b70db958604649f5a324a09da56c5dc86a57c0 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 3 Dec 2015 14:12:31 +0200 Subject: LAB: Cleanup of palette code --- engines/lab/map.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index b5855eaf58..9ce9f0889b 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -60,7 +60,8 @@ void setAmigaPal(uint16 *pal, uint16 numcolors) { vgapal[vgacount++] = (byte)(((pal[i] & 0x00f)) << 2); } - g_lab->writeColorRegsSmooth(vgapal, 0, 16); + g_lab->writeColorRegs(vgapal, 0, 16); + g_lab->waitTOF(); } /*---------------------------------------------------------------------------*/ @@ -620,7 +621,7 @@ void LabEngine::processMap(uint16 CurRoom) { } waitTOF(); - writeColorReg(newcolor, 1); + writeColorRegs(newcolor, 1, 1); _event->updateMouse(); waitTOF(); _event->updateMouse(); -- 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/map.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 9ce9f0889b..7471b1f0ea 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -491,7 +491,7 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou char *sptr; uint16 tempfloor; - bool noghoast; + bool noOverlay; _event->mouseHide(); @@ -517,20 +517,20 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou drawRoom(CurRoom, true); tempfloor = Floor; - getUpFloor(&tempfloor, &noghoast); + getUpFloor(&tempfloor, &noOverlay); - if (noghoast) - unGhoastGadget(&upgadget); + if (noOverlay) + enableGadget(&upgadget); else - ghoastGadget(&upgadget, 12); + disableGadget(&upgadget, 12); tempfloor = Floor; - getDownFloor(&tempfloor, &noghoast); + getDownFloor(&tempfloor, &noOverlay); - if (noghoast) - unGhoastGadget(&downgadget); + if (noOverlay) + enableGadget(&downgadget); else - ghoastGadget(&downgadget, 12); + disableGadget(&downgadget, 12); // Labyrinth specific code if (Floor == LOWERFLOOR) { -- cgit v1.2.3 From 914bd262955c9da140d89dc6cf3fa03940a13c62 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 3 Dec 2015 14:30:32 +0200 Subject: LAB: Cleanup of roomCords() --- engines/lab/map.cpp | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 7471b1f0ea..a2a4ed3af7 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -252,34 +252,29 @@ void fade(bool fadein, uint16 res) { /* Figures out what a room's coordinates should be. */ /*****************************************************************************/ static void roomCords(uint16 CurRoom, uint16 *x1, uint16 *y1, uint16 *x2, uint16 *y2) { - *x1 = mapScaleX(Maps[CurRoom].x); - *y1 = mapScaleY(Maps[CurRoom].y); - *x2 = *x1; - *y2 = *y1; + Image *curRoomImg = NULL; switch (Maps[CurRoom].SpecialID) { case NORMAL: case UPARROWROOM: case DOWNARROWROOM: - (*x2) += Room->_width; - (*y2) += Room->_height; + curRoomImg = Room; break; - case BRIDGEROOM: - (*x2) += Bridge->_width; - (*y2) += Bridge->_height; + curRoomImg = Bridge; break; - case VCORRIDOR: - (*x2) += VRoom->_width; - (*y2) += VRoom->_height; + curRoomImg = VRoom; break; - case HCORRIDOR: - (*x2) += HRoom->_width; - (*y2) += HRoom->_height; + curRoomImg = HRoom; break; } + + *x1 = mapScaleX(Maps[CurRoom].x); + *y1 = mapScaleY(Maps[CurRoom].y); + *x2 = *x1 + curRoomImg->_width; + *y2 = *y1 + curRoomImg->_height; } /*****************************************************************************/ -- 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/map.cpp | 50 ++++++++++++++++++++++---------------------------- 1 file changed, 22 insertions(+), 28 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index a2a4ed3af7..b3312619c1 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -129,43 +129,37 @@ static uint16 mapScaleY(uint16 y) { /* Loads in the map data. */ /*****************************************************************************/ static bool loadMapData() { - byte **buffer; - uint32 Size; Gadget *gptr; uint16 counter; - resetBuffer(); /* Make images load into start of buffer */ - buffer = g_lab->_music->newOpen("P:MapImage", Size); + Common::File *mapImages = g_lab->_resource->openDataFile("P:MapImage"); - if (!buffer) - return false; + Map = new Image(mapImages); - stealBufMem(Size); /* Now freeze that buffer from further use */ + Room = new Image(mapImages); + UpArrowRoom = new Image(mapImages); + DownArrowRoom = new Image(mapImages); + HRoom = new Image(mapImages); + VRoom = new Image(mapImages); + Maze = new Image(mapImages); + HugeMaze = new Image(mapImages); - Map = new Image(buffer); + MapNorth = new Image(mapImages); + MapEast = new Image(mapImages); + MapSouth = new Image(mapImages); + MapWest = new Image(mapImages); - Room = new Image(buffer); - UpArrowRoom = new Image(buffer); - DownArrowRoom = new Image(buffer); - HRoom = new Image(buffer); - VRoom = new Image(buffer); - Maze = new Image(buffer); - HugeMaze = new Image(buffer); + Path = new Image(mapImages); + Bridge = new Image(mapImages); - MapNorth = new Image(buffer); - MapEast = new Image(buffer); - MapSouth = new Image(buffer); - MapWest = new Image(buffer); + Back = new Image(mapImages); + BackAlt = new Image(mapImages); + Up = new Image(mapImages); + UpAlt = new Image(mapImages); + Down = new Image(mapImages); + DownAlt = new Image(mapImages); - Path = new Image(buffer); - Bridge = new Image(buffer); - - Back = new Image(buffer); - BackAlt = new Image(buffer); - Up = new Image(buffer); - UpAlt = new Image(buffer); - Down = new Image(buffer); - DownAlt = new Image(buffer); + delete mapImages; backgadget._image = Back; backgadget._altImage = BackAlt; -- cgit v1.2.3 From 58e6627f1989b69a70358ec91ab54a0f180b56c9 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 3 Dec 2015 15:23:40 +0200 Subject: LAB: Remove superfluous image variables --- engines/lab/map.cpp | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index b3312619c1..9b7f3f3e40 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -72,8 +72,7 @@ extern RoomData *_rooms; static Image *Map, *Room, *UpArrowRoom, *DownArrowRoom, *Bridge, *HRoom, *VRoom, *Maze, *HugeMaze, *Path, *MapNorth, - *MapEast, *MapSouth, *MapWest, *XMark, *Back, *BackAlt, - *Down, *DownAlt, *Up, *UpAlt; + *MapEast, *MapSouth, *MapWest, *XMark; static uint16 MaxRooms; static MapData *Maps; @@ -152,22 +151,15 @@ static bool loadMapData() { Path = new Image(mapImages); Bridge = new Image(mapImages); - Back = new Image(mapImages); - BackAlt = new Image(mapImages); - Up = new Image(mapImages); - UpAlt = new Image(mapImages); - Down = new Image(mapImages); - DownAlt = new Image(mapImages); + backgadget._image = new Image(mapImages); + backgadget._altImage = new Image(mapImages); + upgadget._image = new Image(mapImages); + upgadget._altImage = new Image(mapImages); + downgadget._image = new Image(mapImages); + downgadget._altImage = new Image(mapImages); delete mapImages; - backgadget._image = Back; - backgadget._altImage = BackAlt; - upgadget._image = Up; - upgadget._altImage = UpAlt; - downgadget._image = Down; - downgadget._altImage = DownAlt; - counter = 0; gptr = MapGadgetList; -- cgit v1.2.3 From 021cb4c526b8dbe8b33b3ae03703be36893410da Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 4 Dec 2015 02:10:55 +0200 Subject: LAB: Rename roomCords to roomCoords --- engines/lab/map.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 9b7f3f3e40..9ca57b0001 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -237,7 +237,7 @@ void fade(bool fadein, uint16 res) { /*****************************************************************************/ /* Figures out what a room's coordinates should be. */ /*****************************************************************************/ -static void roomCords(uint16 CurRoom, uint16 *x1, uint16 *y1, uint16 *x2, uint16 *y2) { +static void roomCoords(uint16 CurRoom, uint16 *x1, uint16 *y1, uint16 *x2, uint16 *y2) { Image *curRoomImg = NULL; switch (Maps[CurRoom].SpecialID) { @@ -699,7 +699,7 @@ void LabEngine::processMap(uint16 CurRoom) { OldMsg = CurMsg; for (uint16 i = 1; i <= MaxRooms; i++) { - roomCords(i, &x1, &y1, &x2, &y2); + roomCoords(i, &x1, &y1, &x2, &y2); if ((Maps[i].PageNumber == CurFloor) && _roomsFound->in(i) @@ -722,7 +722,7 @@ void LabEngine::processMap(uint16 CurRoom) { if (Maps[OldMsg].PageNumber == CurFloor) drawRoom(OldMsg, (bool)(OldMsg == CurRoom)); - roomCords(CurMsg, &x1, &y1, &x2, &y2); + roomCoords(CurMsg, &x1, &y1, &x2, &y2); x1 = (x1 + x2) / 2; y1 = (y1 + y2) / 2; -- 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/map.cpp | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 9ca57b0001..f5746baa42 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -164,8 +164,8 @@ static bool loadMapData() { gptr = MapGadgetList; while (gptr) { - gptr->x = VGAScaleX(MapGadX[counter]); - gptr->y = VGAScaleY(MapGadY[counter]); + gptr->x = g_lab->_graphics->VGAScaleX(MapGadX[counter]); + gptr->y = g_lab->_graphics->VGAScaleY(MapGadY[counter]); gptr = gptr->NextGadget; counter++; } @@ -479,8 +479,8 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou if (fadeout) fade(false, 0); - setAPen(0); - rectFill(0, 0, _screenWidth - 1, _screenHeight - 1); + _graphics->setAPen(0); + _graphics->rectFill(0, 0, _screenWidth - 1, _screenHeight - 1); Map->drawImage(0, 0); drawGadgetList(MapGadgetList); @@ -528,7 +528,7 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou HugeMaze->drawImage(mapScaleX(524), mapScaleY(97)); } else if (Floor == SURMAZEFLOOR) { sptr = (char *)_resource->getStaticText(kTextSurmazeMessage).c_str(); - flowText(_msgFont, 0, 7, 0, true, true, true, true, mapScaleX(360), 0, mapScaleX(660), mapScaleY(450), sptr); + _graphics->flowText(_msgFont, 0, 7, 0, true, true, true, true, mapScaleX(360), 0, mapScaleX(660), mapScaleY(450), sptr); } switch (Floor) { @@ -559,10 +559,10 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou } if (sptr) - flowText(_msgFont, 0, 5, 3, true, true, true, true, VGAScaleX(14), VGAScaleY(75), VGAScaleX(134), VGAScaleY(97), sptr); + _graphics->flowText(_msgFont, 0, 5, 3, true, true, true, true, _graphics->VGAScaleX(14), _graphics->VGAScaleY(75), _graphics->VGAScaleX(134), _graphics->VGAScaleY(97), sptr); if ((sptr = _rooms[CurMsg]._roomMsg)) - flowText(_msgFont, 0, 5, 3, true, true, true, true, VGAScaleX(14), VGAScaleY(148), VGAScaleX(134), VGAScaleY(186), sptr); + _graphics->flowText(_msgFont, 0, 5, 3, true, true, true, true, _graphics->VGAScaleX(14), _graphics->VGAScaleY(148), _graphics->VGAScaleX(134), _graphics->VGAScaleY(186), sptr); if (fadein) fade(true, 0); @@ -715,9 +715,9 @@ void LabEngine::processMap(uint16 CurRoom) { if ((sptr = _rooms[CurMsg]._roomMsg)) { _event->mouseHide(); - setAPen(3); - rectFill(VGAScaleX(13), VGAScaleY(148), VGAScaleX(135), VGAScaleY(186)); - flowText(_msgFont, 0, 5, 3, true, true, true, true, VGAScaleX(14), VGAScaleY(148), VGAScaleX(134), VGAScaleY(186), sptr); + _graphics->setAPen(3); + _graphics->rectFill(_graphics->VGAScaleX(13), _graphics->VGAScaleY(148), _graphics->VGAScaleX(135), _graphics->VGAScaleY(186)); + _graphics->flowText(_msgFont, 0, 5, 3, true, true, true, true, _graphics->VGAScaleX(14), _graphics->VGAScaleY(148), _graphics->VGAScaleX(134), _graphics->VGAScaleY(186), sptr); if (Maps[OldMsg].PageNumber == CurFloor) drawRoom(OldMsg, (bool)(OldMsg == CurRoom)); @@ -727,8 +727,8 @@ void LabEngine::processMap(uint16 CurRoom) { y1 = (y1 + y2) / 2; if ((CurMsg != CurRoom) && (Maps[CurMsg].PageNumber == CurFloor)) { - setAPen(1); - rectFill(x1 - 1, y1, x1, y1); + _graphics->setAPen(1); + _graphics->rectFill(x1 - 1, y1, x1, y1); } _event->mouseShow(); @@ -737,7 +737,7 @@ void LabEngine::processMap(uint16 CurRoom) { } } - screenUpdate(); + _graphics->screenUpdate(); } } } @@ -751,7 +751,7 @@ void LabEngine::doMap(uint16 CurRoom) { _music->updateMusic(); loadMapData(); - blackAllScreen(); + _graphics->blackAllScreen(); if (Direction == NORTH) XMark = MapNorth; @@ -765,18 +765,18 @@ void LabEngine::doMap(uint16 CurRoom) { drawMap(CurRoom, CurRoom, Maps[CurRoom].PageNumber, false, true); _event->mouseShow(); _event->attachGadgetList(MapGadgetList); - screenUpdate(); + _graphics->screenUpdate(); processMap(CurRoom); _event->attachGadgetList(NULL); fade(false, 0); - blackAllScreen(); + _graphics->blackAllScreen(); _event->mouseHide(); - setAPen(0); - rectFill(0, 0, _screenWidth - 1, _screenHeight - 1); + _graphics->setAPen(0); + _graphics->rectFill(0, 0, _screenWidth - 1, _screenHeight - 1); freeMapData(); - blackAllScreen(); + _graphics->blackAllScreen(); _event->mouseShow(); - screenUpdate(); + _graphics->screenUpdate(); } } // End of namespace Lab -- cgit v1.2.3 From 3ac02c1196875ff28e4aa9d2804bef811f8decb6 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 4 Dec 2015 22:06:47 +0200 Subject: LAB: Simplify file handling code --- engines/lab/map.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index f5746baa42..36591d759b 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -171,8 +171,6 @@ static bool loadMapData() { } Common::File *mapFile = g_lab->_resource->openDataFile("Lab:Maps", MKTAG('M', 'A', 'P', '0')); - if (!mapFile) - error("Corrupt map file"); g_lab->_music->updateMusic(); if (!g_lab->_music->_doNotFilestopSoundEffect) g_lab->_music->stopSoundEffect(); -- cgit v1.2.3 From 6f3644f377cb298cb82d7a9235b9aec4cfa875ea Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 4 Dec 2015 22:52:55 +0200 Subject: LAB: Fix a regression in roomCoords() --- engines/lab/map.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 36591d759b..4df01eae36 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -253,12 +253,20 @@ static void roomCoords(uint16 CurRoom, uint16 *x1, uint16 *y1, uint16 *x2, uint1 case HCORRIDOR: curRoomImg = HRoom; break; + default: + // Some rooms (like the map) do not have an image + break; } *x1 = mapScaleX(Maps[CurRoom].x); *y1 = mapScaleY(Maps[CurRoom].y); - *x2 = *x1 + curRoomImg->_width; - *y2 = *y1 + curRoomImg->_height; + *x2 = *x1; + *y2 = *y1; + + if (curRoomImg) { + *x2 += curRoomImg->_width; + *y2 += curRoomImg->_height; + } } /*****************************************************************************/ -- 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/map.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 4df01eae36..51295a874d 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -565,10 +565,10 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou } if (sptr) - _graphics->flowText(_msgFont, 0, 5, 3, true, true, true, true, _graphics->VGAScaleX(14), _graphics->VGAScaleY(75), _graphics->VGAScaleX(134), _graphics->VGAScaleY(97), sptr); + _graphics->flowTextScaled(_msgFont, 0, 5, 3, true, true, true, true, 14, 75, 134, 97, sptr); if ((sptr = _rooms[CurMsg]._roomMsg)) - _graphics->flowText(_msgFont, 0, 5, 3, true, true, true, true, _graphics->VGAScaleX(14), _graphics->VGAScaleY(148), _graphics->VGAScaleX(134), _graphics->VGAScaleY(186), sptr); + _graphics->flowTextScaled(_msgFont, 0, 5, 3, true, true, true, true, 14, 148, 134, 186, sptr); if (fadein) fade(true, 0); @@ -722,8 +722,8 @@ void LabEngine::processMap(uint16 CurRoom) { if ((sptr = _rooms[CurMsg]._roomMsg)) { _event->mouseHide(); _graphics->setAPen(3); - _graphics->rectFill(_graphics->VGAScaleX(13), _graphics->VGAScaleY(148), _graphics->VGAScaleX(135), _graphics->VGAScaleY(186)); - _graphics->flowText(_msgFont, 0, 5, 3, true, true, true, true, _graphics->VGAScaleX(14), _graphics->VGAScaleY(148), _graphics->VGAScaleX(134), _graphics->VGAScaleY(186), sptr); + _graphics->rectFillScaled(13, 148, 135, 186); + _graphics->flowTextScaled(_msgFont, 0, 5, 3, true, true, true, true, 14, 148, 134, 186, sptr); if (Maps[OldMsg].PageNumber == CurFloor) drawRoom(OldMsg, (bool)(OldMsg == CurRoom)); -- cgit v1.2.3 From 61d89cb7448f747473cf6a0c474da1b322233fbe Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 5 Dec 2015 22:35:38 +0200 Subject: LAB: Small cleanup in drawMap() --- engines/lab/map.cpp | 31 +++---------------------------- 1 file changed, 3 insertions(+), 28 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 51295a874d..bef3dd1f4c 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -537,35 +537,10 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou _graphics->flowText(_msgFont, 0, 7, 0, true, true, true, true, mapScaleX(360), 0, mapScaleX(660), mapScaleY(450), sptr); } - switch (Floor) { - case LOWERFLOOR: - sptr = (char *)_resource->getStaticText(kTextLowerFloor).c_str(); - break; - case MIDDLEFLOOR: - sptr = (char *)_resource->getStaticText(kTextMiddleFloor).c_str(); - break; - case UPPERFLOOR: - sptr = (char *)_resource->getStaticText(kTextUpperFloor).c_str(); - break; - case MEDMAZEFLOOR: - sptr = (char *)_resource->getStaticText(kTextMedMazeFloor).c_str(); - break; - case HEDGEMAZEFLOOR: - sptr = (char *)_resource->getStaticText(kTextHedgeMazeFloor).c_str(); - break; - case SURMAZEFLOOR: - sptr = (char *)_resource->getStaticText(kTextSurMazeFloor).c_str(); - break; - case CARNIVAL: - sptr = (char *)_resource->getStaticText(kTextCarnivalFloor).c_str(); - break; - default: - sptr = NULL; - break; - } - - if (sptr) + if (Floor >= LOWERFLOOR && Floor <= CARNIVAL) { + sptr = (char *)_resource->getStaticText(Floor - 1).c_str(); _graphics->flowTextScaled(_msgFont, 0, 5, 3, true, true, true, true, 14, 75, 134, 97, sptr); + } if ((sptr = _rooms[CurMsg]._roomMsg)) _graphics->flowTextScaled(_msgFont, 0, 5, 3, true, true, true, true, 14, 148, 134, 186, sptr); -- 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/map.cpp | 29 ++++------------------------- 1 file changed, 4 insertions(+), 25 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index bef3dd1f4c..3f20feae8f 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -43,27 +43,6 @@ namespace Lab { extern uint16 Direction; -/*****************************************************************************/ -/* Converts an Amiga palette (up to 16 colors) to a VGA palette, then sets */ -/* the VGA palette. */ -/*****************************************************************************/ -void setAmigaPal(uint16 *pal, uint16 numcolors) { - byte vgapal[16 * 3]; - uint16 vgacount = 0; - - if (numcolors > 16) - numcolors = 16; - - for (uint16 i = 0; i < numcolors; i++) { - vgapal[vgacount++] = (byte)(((pal[i] & 0xf00) >> 8) << 2); - vgapal[vgacount++] = (byte)(((pal[i] & 0x0f0) >> 4) << 2); - vgapal[vgacount++] = (byte)(((pal[i] & 0x00f)) << 2); - } - - g_lab->writeColorRegs(vgapal, 0, 16); - g_lab->waitTOF(); -} - /*---------------------------------------------------------------------------*/ /*------------------------------ The Map stuff ------------------------------*/ /*---------------------------------------------------------------------------*/ @@ -226,7 +205,7 @@ void fade(bool fadein, uint16 res) { (0xF00 & fadeNumOut(0xF00 & FadePalette[palIdx], 0xF00 & res, i)); } - setAmigaPal(newpal, 16); + g_lab->_graphics->setAmigaPal(newpal, 16); g_lab->waitTOF(); g_lab->_music->updateMusic(); } @@ -486,7 +465,7 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou fade(false, 0); _graphics->setAPen(0); - _graphics->rectFill(0, 0, _screenWidth - 1, _screenHeight - 1); + _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1); Map->drawImage(0, 0); drawGadgetList(MapGadgetList); @@ -583,7 +562,7 @@ void LabEngine::processMap(uint16 CurRoom) { } waitTOF(); - writeColorRegs(newcolor, 1, 1); + _graphics->writeColorRegs(newcolor, 1, 1); _event->updateMouse(); waitTOF(); _event->updateMouse(); @@ -753,7 +732,7 @@ void LabEngine::doMap(uint16 CurRoom) { _graphics->blackAllScreen(); _event->mouseHide(); _graphics->setAPen(0); - _graphics->rectFill(0, 0, _screenWidth - 1, _screenHeight - 1); + _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1); freeMapData(); _graphics->blackAllScreen(); _event->mouseShow(); -- 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/map.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 3f20feae8f..8281a498d2 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -41,8 +41,6 @@ namespace Lab { -extern uint16 Direction; - /*---------------------------------------------------------------------------*/ /*------------------------------ The Map stuff ------------------------------*/ /*---------------------------------------------------------------------------*/ @@ -713,13 +711,13 @@ void LabEngine::doMap(uint16 CurRoom) { loadMapData(); _graphics->blackAllScreen(); - if (Direction == NORTH) + if (_direction == NORTH) XMark = MapNorth; - else if (Direction == SOUTH) + else if (_direction == SOUTH) XMark = MapSouth; - else if (Direction == EAST) + else if (_direction == EAST) XMark = MapEast; - else if (Direction == WEST) + else if (_direction == WEST) XMark = MapWest; drawMap(CurRoom, CurRoom, Maps[CurRoom].PageNumber, false, true); -- 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/map.cpp | 86 ++++++++++++++--------------------------------------- 1 file changed, 23 insertions(+), 63 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 8281a498d2..218aae4213 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -56,8 +56,6 @@ static MapData *Maps; extern char *LOWERFLOORS, *MIDDLEFLOORS, *UPPERFLOORS, *MEDMAZEFLOORS, *HEDGEMAZEFLOORS, *SURMAZEFLOORS, *CARNIVALFLOOR, *SURMAZEMSG; -uint16 *FadePalette; - static uint16 MapGadX[3] = {101, 55, 8}, MapGadY[3] = {105, 105, 105}; static Gadget downgadget = { 101, 105, 2, VKEY_DNARROW, 0L, NULL, NULL, NULL }, @@ -66,14 +64,6 @@ static Gadget downgadget = { 101, 105, 2, VKEY_DNARROW, 0L, NULL, NULL, NULL }, static Gadget *MapGadgetList = &backgadget; -static uint16 AmigaMapPalette[] = { - 0x0BA8, 0x0C11, 0x0A74, 0x0076, - 0x0A96, 0x0DCB, 0x0CCA, 0x0222, - 0x0444, 0x0555, 0x0777, 0x0999, - 0x0AAA, 0x0ED0, 0x0EEE, 0x0694 -}; - - #define LOWERFLOOR 1 #define MIDDLEFLOOR 2 #define UPPERFLOOR 3 @@ -167,48 +157,11 @@ static bool loadMapData() { return true; } - static void freeMapData() { delete[] Maps; Maps = NULL; } - -static uint16 fadeNumIn(uint16 num, uint16 res, uint16 counter) { - return (num - ((((int32)(15 - counter)) * ((int32)(num - res))) / 15)); -} - - -static uint16 fadeNumOut(uint16 num, uint16 res, uint16 counter) { - return (num - ((((int32) counter) * ((int32)(num - res))) / 15)); -} - - - -/*****************************************************************************/ -/* Does the fading of the Palette on the screen. */ -/*****************************************************************************/ -void fade(bool fadein, uint16 res) { - uint16 newpal[16]; - - for (uint16 i = 0; i < 16; i++) { - for (uint16 palIdx = 0; palIdx < 16; palIdx++) { - if (fadein) - newpal[palIdx] = (0x00F & fadeNumIn(0x00F & FadePalette[palIdx], 0x00F & res, i)) + - (0x0F0 & fadeNumIn(0x0F0 & FadePalette[palIdx], 0x0F0 & res, i)) + - (0xF00 & fadeNumIn(0xF00 & FadePalette[palIdx], 0xF00 & res, i)); - else - newpal[palIdx] = (0x00F & fadeNumOut(0x00F & FadePalette[palIdx], 0x00F & res, i)) + - (0x0F0 & fadeNumOut(0x0F0 & FadePalette[palIdx], 0x0F0 & res, i)) + - (0xF00 & fadeNumOut(0xF00 & FadePalette[palIdx], 0xF00 & res, i)); - } - - g_lab->_graphics->setAmigaPal(newpal, 16); - g_lab->waitTOF(); - g_lab->_music->updateMusic(); - } -} - /*****************************************************************************/ /* Figures out what a room's coordinates should be. */ /*****************************************************************************/ @@ -460,7 +413,7 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou _event->mouseHide(); if (fadeout) - fade(false, 0); + _graphics->fade(false, 0); _graphics->setAPen(0); _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1); @@ -523,7 +476,7 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou _graphics->flowTextScaled(_msgFont, 0, 5, 3, true, true, true, true, 14, 148, 134, 186, sptr); if (fadein) - fade(true, 0); + _graphics->fade(true, 0); _event->mouseShow(); } @@ -594,9 +547,9 @@ void LabEngine::processMap(uint16 CurRoom) { getUpFloor(&CurFloor, &drawmap); if (drawmap) { - fade(false, 0); + _graphics->fade(false, 0); drawMap(CurRoom, CurMsg, CurFloor, false, false); - fade(true, 0); + _graphics->fade(true, 0); } else CurFloor = OldFloor; } else if (GadgetID == 2) { /* Down arrow */ @@ -604,9 +557,9 @@ void LabEngine::processMap(uint16 CurRoom) { getDownFloor(&CurFloor, &drawmap); if (drawmap) { - fade(false, 0); + _graphics->fade(false, 0); drawMap(CurRoom, CurMsg, CurFloor, false, false); - fade(true, 0); + _graphics->fade(true, 0); } else CurFloor = OldFloor; } @@ -618,9 +571,9 @@ void LabEngine::processMap(uint16 CurRoom) { && onFloor(SURMAZEFLOOR)) { CurFloor = SURMAZEFLOOR; - fade(false, 0); + _graphics->fade(false, 0); drawMap(CurRoom, CurMsg, CurFloor, false, false); - fade(true, 0); + _graphics->fade(true, 0); } else if ((CurFloor == MIDDLEFLOOR) && (MouseX >= mapScaleX(358)) && (MouseY >= mapScaleY(71)) @@ -628,9 +581,9 @@ void LabEngine::processMap(uint16 CurRoom) { && onFloor(CARNIVAL)) { CurFloor = CARNIVAL; - fade(false, 0); + _graphics->fade(false, 0); drawMap(CurRoom, CurMsg, CurFloor, false, false); - fade(true, 0); + _graphics->fade(true, 0); } else if ((CurFloor == MIDDLEFLOOR) && (MouseX >= mapScaleX(557)) && (MouseY >= mapScaleY(325)) @@ -638,9 +591,9 @@ void LabEngine::processMap(uint16 CurRoom) { && onFloor(MEDMAZEFLOOR)) { CurFloor = MEDMAZEFLOOR; - fade(false, 0); + _graphics->fade(false, 0); drawMap(CurRoom, CurMsg, CurFloor, false, false); - fade(true, 0); + _graphics->fade(true, 0); } else if ((CurFloor == UPPERFLOOR) && (MouseX >= mapScaleX(524)) && (MouseY >= mapScaleY(97)) @@ -648,9 +601,9 @@ void LabEngine::processMap(uint16 CurRoom) { && onFloor(HEDGEMAZEFLOOR)) { CurFloor = HEDGEMAZEFLOOR; - fade(false, 0); + _graphics->fade(false, 0); drawMap(CurRoom, CurMsg, CurFloor, false, false); - fade(true, 0); + _graphics->fade(true, 0); } else if (MouseX > mapScaleX(314)) { @@ -705,7 +658,14 @@ void LabEngine::processMap(uint16 CurRoom) { /* Does the map processing. */ /*****************************************************************************/ void LabEngine::doMap(uint16 CurRoom) { - FadePalette = AmigaMapPalette; + static uint16 AmigaMapPalette[] = { + 0x0BA8, 0x0C11, 0x0A74, 0x0076, + 0x0A96, 0x0DCB, 0x0CCA, 0x0222, + 0x0444, 0x0555, 0x0777, 0x0999, + 0x0AAA, 0x0ED0, 0x0EEE, 0x0694 + }; + + _graphics->FadePalette = AmigaMapPalette; _music->updateMusic(); loadMapData(); @@ -726,7 +686,7 @@ void LabEngine::doMap(uint16 CurRoom) { _graphics->screenUpdate(); processMap(CurRoom); _event->attachGadgetList(NULL); - fade(false, 0); + _graphics->fade(false, 0); _graphics->blackAllScreen(); _event->mouseHide(); _graphics->setAPen(0); -- cgit v1.2.3 From 803dbcee90bad321532dea54219697aaec34608a Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 6 Dec 2015 21:39:41 +0100 Subject: LAB: Move _rooms to LabEngine, some renaming --- engines/lab/map.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 218aae4213..40e8eb9d49 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -45,8 +45,6 @@ namespace Lab { /*------------------------------ The Map stuff ------------------------------*/ /*---------------------------------------------------------------------------*/ -extern RoomData *_rooms; - static Image *Map, *Room, *UpArrowRoom, *DownArrowRoom, *Bridge, *HRoom, *VRoom, *Maze, *HugeMaze, *Path, *MapNorth, *MapEast, *MapSouth, *MapWest, *XMark; -- 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/map.cpp | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 40e8eb9d49..a565f31d06 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -56,11 +56,12 @@ extern char *LOWERFLOORS, *MIDDLEFLOORS, *UPPERFLOORS, *MEDMAZEFLOORS, *HEDGEMAZ static uint16 MapGadX[3] = {101, 55, 8}, MapGadY[3] = {105, 105, 105}; -static Gadget downgadget = { 101, 105, 2, VKEY_DNARROW, 0L, NULL, NULL, NULL }, - upgadget = { 55, 105, 1, VKEY_UPARROW, 0L, NULL, NULL, &downgadget }, - backgadget = { 8, 105, 0, 0, 0L, NULL, NULL, &upgadget }; +static Gadget + backgadget = { 8, 105, 0, 0, 0L, NULL, NULL }, + upgadget = { 55, 105, 1, VKEY_UPARROW, 0L, NULL, NULL }, + downgadget = { 101, 105, 2, VKEY_DNARROW, 0L, NULL, NULL }; -static Gadget *MapGadgetList = &backgadget; +static GadgetList *MapGadgetList; #define LOWERFLOOR 1 #define MIDDLEFLOOR 2 @@ -93,9 +94,13 @@ static uint16 mapScaleY(uint16 y) { /* Loads in the map data. */ /*****************************************************************************/ static bool loadMapData() { - Gadget *gptr; uint16 counter; + MapGadgetList = new GadgetList(); + MapGadgetList->push_back(&backgadget); + MapGadgetList->push_back(&upgadget); + MapGadgetList->push_back(&downgadget); + Common::File *mapImages = g_lab->_resource->openDataFile("P:MapImage"); Map = new Image(mapImages); @@ -126,12 +131,10 @@ static bool loadMapData() { delete mapImages; counter = 0; - gptr = MapGadgetList; - while (gptr) { - gptr->x = g_lab->_graphics->VGAScaleX(MapGadX[counter]); - gptr->y = g_lab->_graphics->VGAScaleY(MapGadY[counter]); - gptr = gptr->NextGadget; + for (GadgetList::iterator gadget = MapGadgetList->begin(); gadget != MapGadgetList->end(); ++gadget) { + (*gadget)->x = g_lab->_graphics->VGAScaleX(MapGadX[counter]); + (*gadget)->y = g_lab->_graphics->VGAScaleY(MapGadY[counter]); counter++; } @@ -156,6 +159,9 @@ static bool loadMapData() { } static void freeMapData() { + MapGadgetList->clear(); + delete MapGadgetList; + delete[] Maps; Maps = NULL; } -- 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/map.cpp | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index a565f31d06..7256562988 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -52,8 +52,6 @@ static Image *Map, *Room, *UpArrowRoom, *DownArrowRoom, *Bridge, static uint16 MaxRooms; static MapData *Maps; -extern char *LOWERFLOORS, *MIDDLEFLOORS, *UPPERFLOORS, *MEDMAZEFLOORS, *HEDGEMAZEFLOORS, *SURMAZEFLOORS, *CARNIVALFLOOR, *SURMAZEMSG; - static uint16 MapGadX[3] = {101, 55, 8}, MapGadY[3] = {105, 105, 105}; static Gadget @@ -71,8 +69,6 @@ static GadgetList *MapGadgetList; #define SURMAZEFLOOR 6 #define CARNIVAL 7 - - static uint16 mapScaleX(uint16 x) { if (g_lab->_isHiRes) return (x - 45); @@ -80,8 +76,6 @@ static uint16 mapScaleX(uint16 x) { return ((x - 45) >> 1); } - - static uint16 mapScaleY(uint16 y) { if (g_lab->_isHiRes) return y; @@ -89,7 +83,6 @@ static uint16 mapScaleY(uint16 y) { return ((y - 35) >> 1) - (y >> 6); } - /*****************************************************************************/ /* Loads in the map data. */ /*****************************************************************************/ @@ -532,12 +525,12 @@ void LabEngine::processMap(uint16 CurRoom) { place = 1; } else { - Class = Msg->msgClass; - Code = Msg->code; - GadgetID = Msg->gadgetID; - Qualifier = Msg->qualifier; - MouseX = Msg->mouseX; - MouseY = Msg->mouseY; + Class = Msg->_msgClass; + Code = Msg->_code; + GadgetID = Msg->_gadgetID; + Qualifier = Msg->_qualifier; + MouseX = Msg->_mouseX; + MouseY = Msg->_mouseY; 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/map.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 7256562988..b7006a3dc9 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -32,12 +32,10 @@ #include "lab/labfun.h" #include "lab/anim.h" #include "lab/image.h" -#include "lab/text.h" #include "lab/parsefun.h" #include "lab/parsetypes.h" #include "lab/resource.h" #include "lab/interface.h" -#include "lab/text.h" namespace Lab { -- 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/map.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index b7006a3dc9..4136b28bab 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -124,8 +124,8 @@ static bool loadMapData() { counter = 0; for (GadgetList::iterator gadget = MapGadgetList->begin(); gadget != MapGadgetList->end(); ++gadget) { - (*gadget)->x = g_lab->_graphics->VGAScaleX(MapGadX[counter]); - (*gadget)->y = g_lab->_graphics->VGAScaleY(MapGadY[counter]); + (*gadget)->x = g_lab->_utils->vgaScaleX(MapGadX[counter]); + (*gadget)->y = g_lab->_utils->vgaScaleY(MapGadY[counter]); counter++; } -- 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/map.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 4136b28bab..8c71d1a6a6 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -32,8 +32,7 @@ #include "lab/labfun.h" #include "lab/anim.h" #include "lab/image.h" -#include "lab/parsefun.h" -#include "lab/parsetypes.h" +#include "lab/processroom.h" #include "lab/resource.h" #include "lab/interface.h" -- 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/map.cpp | 59 ++++++++++++++++++----------------------------------- 1 file changed, 20 insertions(+), 39 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 8c71d1a6a6..405d7b82ea 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -357,9 +357,6 @@ static void getUpFloor(uint16 *Floor, bool *isfloor) { } while ((!onFloor(*Floor)) && (*Floor <= CARNIVAL)); } - - - /*****************************************************************************/ /* Figures out which floor, if any, should be gone to if the down arrow is */ /* hit. */ @@ -391,10 +388,6 @@ static void getDownFloor(uint16 *Floor, bool *isfloor) { } while ((!onFloor(*Floor)) && *Floor); } - - - - /*****************************************************************************/ /* Draws the map */ /*****************************************************************************/ @@ -422,9 +415,9 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou } } - if ((Maps[CurRoom].PageNumber == Floor) /* Makes sure the X is drawn in corridors */ - && _roomsFound->in(CurRoom) /* NOTE: this here on purpose just in case there's some weird condition, like the surreal maze where there are no rooms */ - && Maps[CurRoom].x) + /* Makes sure the X is drawn in corridors */ + /* NOTE: this here on purpose just in case there's some weird condition, like the surreal maze where there are no rooms */ + if ((Maps[CurRoom].PageNumber == Floor) && _roomsFound->in(CurRoom) && Maps[CurRoom].x) drawRoom(CurRoom, true); tempfloor = Floor; @@ -529,8 +522,7 @@ void LabEngine::processMap(uint16 CurRoom) { MouseX = Msg->_mouseX; MouseY = Msg->_mouseY; - if (((Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) || - ((Class == RAWKEY) && (Code == 27))) + if (((Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) || ((Class == RAWKEY) && (Code == 27))) return; if (Class == GADGETUP) { @@ -557,59 +549,49 @@ void LabEngine::processMap(uint16 CurRoom) { } else CurFloor = OldFloor; } - } - - else if ((Class == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & Qualifier)) { + } else if ((Class == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & Qualifier)) { if ((CurFloor == LOWERFLOOR) && (MouseX >= mapScaleX(538)) && (MouseY >= mapScaleY(277)) - && (MouseX <= mapScaleX(633)) && (MouseY <= mapScaleY(352)) - && onFloor(SURMAZEFLOOR)) { + && (MouseX <= mapScaleX(633)) && (MouseY <= mapScaleY(352)) + && onFloor(SURMAZEFLOOR)) { CurFloor = SURMAZEFLOOR; _graphics->fade(false, 0); drawMap(CurRoom, CurMsg, CurFloor, false, false); _graphics->fade(true, 0); - } - - else if ((CurFloor == MIDDLEFLOOR) && (MouseX >= mapScaleX(358)) && (MouseY >= mapScaleY(71)) - && (MouseX <= mapScaleX(452)) && (MouseY <= mapScaleY(147)) - && onFloor(CARNIVAL)) { + } else if ((CurFloor == MIDDLEFLOOR) && (MouseX >= mapScaleX(358)) && (MouseY >= mapScaleY(71)) + && (MouseX <= mapScaleX(452)) && (MouseY <= mapScaleY(147)) + && onFloor(CARNIVAL)) { CurFloor = CARNIVAL; _graphics->fade(false, 0); drawMap(CurRoom, CurMsg, CurFloor, false, false); _graphics->fade(true, 0); - } - - else if ((CurFloor == MIDDLEFLOOR) && (MouseX >= mapScaleX(557)) && (MouseY >= mapScaleY(325)) - && (MouseX <= mapScaleX(653)) && (MouseY <= mapScaleY(401)) - && onFloor(MEDMAZEFLOOR)) { + } else if ((CurFloor == MIDDLEFLOOR) && (MouseX >= mapScaleX(557)) && (MouseY >= mapScaleY(325)) + && (MouseX <= mapScaleX(653)) && (MouseY <= mapScaleY(401)) + && onFloor(MEDMAZEFLOOR)) { CurFloor = MEDMAZEFLOOR; _graphics->fade(false, 0); drawMap(CurRoom, CurMsg, CurFloor, false, false); _graphics->fade(true, 0); - } - - else if ((CurFloor == UPPERFLOOR) && (MouseX >= mapScaleX(524)) && (MouseY >= mapScaleY(97)) - && (MouseX <= mapScaleX(645)) && (MouseY <= mapScaleY(207)) - && onFloor(HEDGEMAZEFLOOR)) { + } else if ((CurFloor == UPPERFLOOR) && (MouseX >= mapScaleX(524)) && (MouseY >= mapScaleY(97)) + && (MouseX <= mapScaleX(645)) && (MouseY <= mapScaleY(207)) + && onFloor(HEDGEMAZEFLOOR)) { CurFloor = HEDGEMAZEFLOOR; _graphics->fade(false, 0); drawMap(CurRoom, CurMsg, CurFloor, false, false); _graphics->fade(true, 0); - } - - else if (MouseX > mapScaleX(314)) { + } else if (MouseX > mapScaleX(314)) { OldMsg = CurMsg; for (uint16 i = 1; i <= MaxRooms; i++) { roomCoords(i, &x1, &y1, &x2, &y2); if ((Maps[i].PageNumber == CurFloor) - && _roomsFound->in(i) - && (MouseX >= x1) && (MouseX <= x2) - && (MouseY >= y1) && (MouseY <= y2)) { + && _roomsFound->in(i) + && (MouseX >= x1) && (MouseX <= x2) + && (MouseY >= y1) && (MouseY <= y2)) { CurMsg = i; } } @@ -647,7 +629,6 @@ void LabEngine::processMap(uint16 CurRoom) { } } - /*****************************************************************************/ /* Does the map processing. */ /*****************************************************************************/ -- 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/map.cpp | 56 ++++++++++++++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 405d7b82ea..b86e2b6846 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -80,9 +80,9 @@ static uint16 mapScaleY(uint16 y) { return ((y - 35) >> 1) - (y >> 6); } -/*****************************************************************************/ -/* Loads in the map data. */ -/*****************************************************************************/ +/** + * Loads in the map data. + */ static bool loadMapData() { uint16 counter; @@ -156,9 +156,9 @@ static void freeMapData() { Maps = NULL; } -/*****************************************************************************/ -/* Figures out what a room's coordinates should be. */ -/*****************************************************************************/ +/** + * Figures out what a room's coordinates should be. + */ static void roomCoords(uint16 CurRoom, uint16 *x1, uint16 *y1, uint16 *x2, uint16 *y2) { Image *curRoomImg = NULL; @@ -193,9 +193,9 @@ static void roomCoords(uint16 CurRoom, uint16 *x1, uint16 *y1, uint16 *x2, uint1 } } -/*****************************************************************************/ -/* Draws a room to the bitmap. */ -/*****************************************************************************/ +/** + * Draws a room to the bitmap. + */ static void drawRoom(uint16 CurRoom, bool drawx) { uint16 x, y, xx, xy, offset; uint32 flags; @@ -328,9 +328,9 @@ static void drawRoom(uint16 CurRoom, bool drawx) { XMark->drawImage(xx, xy); } -/*****************************************************************************/ -/* Checks if a floor has been visitted. */ -/*****************************************************************************/ +/** + * Checks if a floor has been visitted. + */ static bool onFloor(uint16 Floor) { for (uint16 i = 1; i <= MaxRooms; i++) { if ((Maps[i].PageNumber == Floor) && g_lab->_roomsFound->in(i) && Maps[i].x) @@ -340,9 +340,9 @@ static bool onFloor(uint16 Floor) { return false; } -/*****************************************************************************/ -/* Figures out which floor, if any, should be gone to if the up arrow is hit */ -/*****************************************************************************/ +/** + * Figures out which floor, if any, should be gone to if the up arrow is hit + */ static void getUpFloor(uint16 *Floor, bool *isfloor) { do { *isfloor = true; @@ -357,10 +357,10 @@ static void getUpFloor(uint16 *Floor, bool *isfloor) { } while ((!onFloor(*Floor)) && (*Floor <= CARNIVAL)); } -/*****************************************************************************/ -/* Figures out which floor, if any, should be gone to if the down arrow is */ -/* hit. */ -/*****************************************************************************/ +/** + * Figures out which floor, if any, should be gone to if the down arrow is + * hit. + */ static void getDownFloor(uint16 *Floor, bool *isfloor) { do { *isfloor = true; @@ -388,9 +388,9 @@ static void getDownFloor(uint16 *Floor, bool *isfloor) { } while ((!onFloor(*Floor)) && *Floor); } -/*****************************************************************************/ -/* Draws the map */ -/*****************************************************************************/ +/** + * Draws the map + */ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, bool fadein) { char *sptr; @@ -468,9 +468,9 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou _event->mouseShow(); } -/*****************************************************************************/ -/* Processes the map. */ -/*****************************************************************************/ +/** + * Processes the map. + */ void LabEngine::processMap(uint16 CurRoom) { uint32 Class, place = 1; uint16 Code, Qualifier, MouseX, MouseY, GadgetID, CurFloor, OldFloor, OldMsg, CurMsg, x1, y1, x2, y2; @@ -629,9 +629,9 @@ void LabEngine::processMap(uint16 CurRoom) { } } -/*****************************************************************************/ -/* Does the map processing. */ -/*****************************************************************************/ +/** + * Does the map processing. + */ void LabEngine::doMap(uint16 CurRoom) { static uint16 AmigaMapPalette[] = { 0x0BA8, 0x0C11, 0x0A74, 0x0076, -- 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/map.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index b86e2b6846..b09ca506f2 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -415,8 +415,9 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou } } - /* Makes sure the X is drawn in corridors */ - /* NOTE: this here on purpose just in case there's some weird condition, like the surreal maze where there are no rooms */ + // Makes sure the X is drawn in corridors + // NOTE: this here on purpose just in case there's some weird + // condition, like the surreal maze where there are no rooms if ((Maps[CurRoom].PageNumber == Floor) && _roomsFound->in(CurRoom) && Maps[CurRoom].x) drawRoom(CurRoom, true); @@ -483,7 +484,8 @@ void LabEngine::processMap(uint16 CurRoom) { CurFloor = Maps[CurRoom].PageNumber; 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) { @@ -526,9 +528,11 @@ void LabEngine::processMap(uint16 CurRoom) { return; if (Class == GADGETUP) { - if (GadgetID == 0) { /* Quit menu button */ + if (GadgetID == 0) { + // Quit menu button return; - } else if (GadgetID == 1) { /* Up arrow */ + } else if (GadgetID == 1) { + // Up arrow OldFloor = CurFloor; getUpFloor(&CurFloor, &drawmap); @@ -538,7 +542,8 @@ void LabEngine::processMap(uint16 CurRoom) { _graphics->fade(true, 0); } else CurFloor = OldFloor; - } else if (GadgetID == 2) { /* Down arrow */ + } else if (GadgetID == 2) { + // Down arrow OldFloor = CurFloor; getDownFloor(&CurFloor, &drawmap); -- 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/map.cpp | 58 +++++++++++++++-------------------------------------- 1 file changed, 16 insertions(+), 42 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index b09ca506f2..b509039277 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -49,15 +49,6 @@ static Image *Map, *Room, *UpArrowRoom, *DownArrowRoom, *Bridge, static uint16 MaxRooms; static MapData *Maps; -static uint16 MapGadX[3] = {101, 55, 8}, MapGadY[3] = {105, 105, 105}; - -static Gadget - backgadget = { 8, 105, 0, 0, 0L, NULL, NULL }, - upgadget = { 55, 105, 1, VKEY_UPARROW, 0L, NULL, NULL }, - downgadget = { 101, 105, 2, VKEY_DNARROW, 0L, NULL, NULL }; - -static GadgetList *MapGadgetList; - #define LOWERFLOOR 1 #define MIDDLEFLOOR 2 #define UPPERFLOOR 3 @@ -83,14 +74,8 @@ static uint16 mapScaleY(uint16 y) { /** * Loads in the map data. */ -static bool loadMapData() { - uint16 counter; - - MapGadgetList = new GadgetList(); - MapGadgetList->push_back(&backgadget); - MapGadgetList->push_back(&upgadget); - MapGadgetList->push_back(&downgadget); - +void LabEngine::loadMapData() { + Utils *utils = g_lab->_utils; Common::File *mapImages = g_lab->_resource->openDataFile("P:MapImage"); Map = new Image(mapImages); @@ -111,23 +96,12 @@ static bool loadMapData() { Path = new Image(mapImages); Bridge = new Image(mapImages); - backgadget._image = new Image(mapImages); - backgadget._altImage = new Image(mapImages); - upgadget._image = new Image(mapImages); - upgadget._altImage = new Image(mapImages); - downgadget._image = new Image(mapImages); - downgadget._altImage = new Image(mapImages); + _mapGadgetList.push_back(createButton( 8, utils->vgaScaleY(105), 0, VKEY_LTARROW, new Image(mapImages), new Image(mapImages))); // back + _mapGadgetList.push_back(createButton( 55, utils->vgaScaleY(105), 1, VKEY_UPARROW, new Image(mapImages), new Image(mapImages))); // up + _mapGadgetList.push_back(createButton(101, utils->vgaScaleY(105), 2, VKEY_DNARROW, new Image(mapImages), new Image(mapImages))); // down delete mapImages; - counter = 0; - - for (GadgetList::iterator gadget = MapGadgetList->begin(); gadget != MapGadgetList->end(); ++gadget) { - (*gadget)->x = g_lab->_utils->vgaScaleX(MapGadX[counter]); - (*gadget)->y = g_lab->_utils->vgaScaleY(MapGadY[counter]); - counter++; - } - Common::File *mapFile = g_lab->_resource->openDataFile("Lab:Maps", MKTAG('M', 'A', 'P', '0')); g_lab->_music->updateMusic(); if (!g_lab->_music->_doNotFilestopSoundEffect) @@ -144,13 +118,10 @@ static bool loadMapData() { } delete mapFile; - - return true; } -static void freeMapData() { - MapGadgetList->clear(); - delete MapGadgetList; +void LabEngine::freeMapData() { + freeButtonList(&_mapGadgetList); delete[] Maps; Maps = NULL; @@ -406,7 +377,7 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1); Map->drawImage(0, 0); - drawGadgetList(MapGadgetList); + drawGadgetList(&_mapGadgetList); for (uint16 i = 1; i <= MaxRooms; i++) { if ((Maps[i].PageNumber == Floor) && _roomsFound->in(i) && Maps[i].x) { @@ -424,18 +395,21 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou tempfloor = Floor; getUpFloor(&tempfloor, &noOverlay); + Gadget *upGadget = _event->getGadget(1); + Gadget *downGadget = _event->getGadget(2); + if (noOverlay) - enableGadget(&upgadget); + enableGadget(upGadget); else - disableGadget(&upgadget, 12); + disableGadget(upGadget, 12); tempfloor = Floor; getDownFloor(&tempfloor, &noOverlay); if (noOverlay) - enableGadget(&downgadget); + enableGadget(downGadget); else - disableGadget(&downgadget, 12); + disableGadget(downGadget, 12); // Labyrinth specific code if (Floor == LOWERFLOOR) { @@ -660,9 +634,9 @@ void LabEngine::doMap(uint16 CurRoom) { else if (_direction == WEST) XMark = MapWest; + _event->attachGadgetList(&_mapGadgetList); drawMap(CurRoom, CurRoom, Maps[CurRoom].PageNumber, false, true); _event->mouseShow(); - _event->attachGadgetList(MapGadgetList); _graphics->screenUpdate(); processMap(CurRoom); _event->attachGadgetList(NULL); -- cgit v1.2.3 From 4340295fbfe767d5248390f9f1b154c22127e549 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 8 Dec 2015 17:08:04 +0200 Subject: LAB: Rename floor defines --- engines/lab/map.cpp | 91 +++++++++++++++++++++++++++-------------------------- 1 file changed, 47 insertions(+), 44 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index b509039277..8cd0ed93a7 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -49,13 +49,16 @@ static Image *Map, *Room, *UpArrowRoom, *DownArrowRoom, *Bridge, static uint16 MaxRooms; static MapData *Maps; -#define LOWERFLOOR 1 -#define MIDDLEFLOOR 2 -#define UPPERFLOOR 3 -#define MEDMAZEFLOOR 4 -#define HEDGEMAZEFLOOR 5 -#define SURMAZEFLOOR 6 -#define CARNIVAL 7 +enum MapFloor { + kFloorNone, + kFloorLower, + kFloorMiddle, + kFloorUpper, + kFloorMedMaze, + kFloorHedgeMaze, + kFloorSurMaze, + kFloorCarnival +}; static uint16 mapScaleX(uint16 x) { if (g_lab->_isHiRes) @@ -165,9 +168,9 @@ static void roomCoords(uint16 CurRoom, uint16 *x1, uint16 *y1, uint16 *x2, uint1 } /** - * Draws a room to the bitmap. + * Draws a room map. */ -static void drawRoom(uint16 CurRoom, bool drawx) { +static void drawRoomMap(uint16 CurRoom, bool drawx) { uint16 x, y, xx, xy, offset; uint32 flags; @@ -318,14 +321,14 @@ static void getUpFloor(uint16 *Floor, bool *isfloor) { do { *isfloor = true; - if (*Floor < UPPERFLOOR) + if (*Floor < kFloorUpper) (*Floor)++; else { - *Floor = CARNIVAL + 1; + *Floor = kFloorCarnival + 1; *isfloor = false; return; } - } while ((!onFloor(*Floor)) && (*Floor <= CARNIVAL)); + } while ((!onFloor(*Floor)) && (*Floor <= kFloorCarnival)); } /** @@ -336,18 +339,18 @@ static void getDownFloor(uint16 *Floor, bool *isfloor) { do { *isfloor = true; - if ((*Floor == LOWERFLOOR) || (*Floor == 0)) { + if ((*Floor == kFloorLower) || (*Floor == 0)) { *Floor = 0; *isfloor = false; return; - } else if (*Floor > UPPERFLOOR) { + } else if (*Floor > kFloorUpper) { // Labyrinth specific code - if (*Floor == HEDGEMAZEFLOOR) - *Floor = UPPERFLOOR; - else if ((*Floor == CARNIVAL) || (*Floor == MEDMAZEFLOOR)) - *Floor = MIDDLEFLOOR; - else if (*Floor == SURMAZEFLOOR) - *Floor = LOWERFLOOR; + if (*Floor == kFloorHedgeMaze) + *Floor = kFloorUpper; + else if ((*Floor == kFloorCarnival) || (*Floor == kFloorMedMaze)) + *Floor = kFloorMiddle; + else if (*Floor == kFloorSurMaze) + *Floor = kFloorLower; else { *Floor = 0; *isfloor = false; @@ -381,7 +384,7 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou for (uint16 i = 1; i <= MaxRooms; i++) { if ((Maps[i].PageNumber == Floor) && _roomsFound->in(i) && Maps[i].x) { - drawRoom(i, (bool)(i == CurRoom)); + drawRoomMap(i, (bool)(i == CurRoom)); _music->updateMusic(); } } @@ -390,7 +393,7 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou // NOTE: this here on purpose just in case there's some weird // condition, like the surreal maze where there are no rooms if ((Maps[CurRoom].PageNumber == Floor) && _roomsFound->in(CurRoom) && Maps[CurRoom].x) - drawRoom(CurRoom, true); + drawRoomMap(CurRoom, true); tempfloor = Floor; getUpFloor(&tempfloor, &noOverlay); @@ -412,24 +415,24 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou disableGadget(downGadget, 12); // Labyrinth specific code - if (Floor == LOWERFLOOR) { - if (onFloor(SURMAZEFLOOR)) + if (Floor == kFloorLower) { + if (onFloor(kFloorSurMaze)) Maze->drawImage(mapScaleX(538), mapScaleY(277)); - } else if (Floor == MIDDLEFLOOR) { - if (onFloor(CARNIVAL)) + } else if (Floor == kFloorMiddle) { + if (onFloor(kFloorCarnival)) Maze->drawImage(mapScaleX(358), mapScaleY(72)); - if (onFloor(MEDMAZEFLOOR)) + if (onFloor(kFloorMedMaze)) Maze->drawImage(mapScaleX(557), mapScaleY(325)); - } else if (Floor == UPPERFLOOR) { - if (onFloor(HEDGEMAZEFLOOR)) + } else if (Floor == kFloorUpper) { + if (onFloor(kFloorHedgeMaze)) HugeMaze->drawImage(mapScaleX(524), mapScaleY(97)); - } else if (Floor == SURMAZEFLOOR) { + } else if (Floor == kFloorSurMaze) { sptr = (char *)_resource->getStaticText(kTextSurmazeMessage).c_str(); _graphics->flowText(_msgFont, 0, 7, 0, true, true, true, true, mapScaleX(360), 0, mapScaleX(660), mapScaleY(450), sptr); } - if (Floor >= LOWERFLOOR && Floor <= CARNIVAL) { + if (Floor >= kFloorLower && Floor <= kFloorCarnival) { sptr = (char *)_resource->getStaticText(Floor - 1).c_str(); _graphics->flowTextScaled(_msgFont, 0, 5, 3, true, true, true, true, 14, 75, 134, 97, sptr); } @@ -529,34 +532,34 @@ void LabEngine::processMap(uint16 CurRoom) { CurFloor = OldFloor; } } else if ((Class == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & Qualifier)) { - if ((CurFloor == LOWERFLOOR) && (MouseX >= mapScaleX(538)) && (MouseY >= mapScaleY(277)) + if ((CurFloor == kFloorLower) && (MouseX >= mapScaleX(538)) && (MouseY >= mapScaleY(277)) && (MouseX <= mapScaleX(633)) && (MouseY <= mapScaleY(352)) - && onFloor(SURMAZEFLOOR)) { - CurFloor = SURMAZEFLOOR; + && onFloor(kFloorSurMaze)) { + CurFloor = kFloorSurMaze; _graphics->fade(false, 0); drawMap(CurRoom, CurMsg, CurFloor, false, false); _graphics->fade(true, 0); - } else if ((CurFloor == MIDDLEFLOOR) && (MouseX >= mapScaleX(358)) && (MouseY >= mapScaleY(71)) + } else if ((CurFloor == kFloorMiddle) && (MouseX >= mapScaleX(358)) && (MouseY >= mapScaleY(71)) && (MouseX <= mapScaleX(452)) && (MouseY <= mapScaleY(147)) - && onFloor(CARNIVAL)) { - CurFloor = CARNIVAL; + && onFloor(kFloorCarnival)) { + CurFloor = kFloorCarnival; _graphics->fade(false, 0); drawMap(CurRoom, CurMsg, CurFloor, false, false); _graphics->fade(true, 0); - } else if ((CurFloor == MIDDLEFLOOR) && (MouseX >= mapScaleX(557)) && (MouseY >= mapScaleY(325)) + } else if ((CurFloor == kFloorMiddle) && (MouseX >= mapScaleX(557)) && (MouseY >= mapScaleY(325)) && (MouseX <= mapScaleX(653)) && (MouseY <= mapScaleY(401)) - && onFloor(MEDMAZEFLOOR)) { - CurFloor = MEDMAZEFLOOR; + && onFloor(kFloorMedMaze)) { + CurFloor = kFloorMedMaze; _graphics->fade(false, 0); drawMap(CurRoom, CurMsg, CurFloor, false, false); _graphics->fade(true, 0); - } else if ((CurFloor == UPPERFLOOR) && (MouseX >= mapScaleX(524)) && (MouseY >= mapScaleY(97)) + } else if ((CurFloor == kFloorUpper) && (MouseX >= mapScaleX(524)) && (MouseY >= mapScaleY(97)) && (MouseX <= mapScaleX(645)) && (MouseY <= mapScaleY(207)) - && onFloor(HEDGEMAZEFLOOR)) { - CurFloor = HEDGEMAZEFLOOR; + && onFloor(kFloorHedgeMaze)) { + CurFloor = kFloorHedgeMaze; _graphics->fade(false, 0); drawMap(CurRoom, CurMsg, CurFloor, false, false); @@ -586,7 +589,7 @@ void LabEngine::processMap(uint16 CurRoom) { _graphics->flowTextScaled(_msgFont, 0, 5, 3, true, true, true, true, 14, 148, 134, 186, sptr); if (Maps[OldMsg].PageNumber == CurFloor) - drawRoom(OldMsg, (bool)(OldMsg == CurRoom)); + drawRoomMap(OldMsg, (bool)(OldMsg == CurRoom)); roomCoords(CurMsg, &x1, &y1, &x2, &y2); x1 = (x1 + x2) / 2; -- 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/map.cpp | 6 ------ 1 file changed, 6 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 8cd0ed93a7..4406fae2d0 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -29,12 +29,6 @@ */ #include "lab/lab.h" -#include "lab/labfun.h" -#include "lab/anim.h" -#include "lab/image.h" -#include "lab/processroom.h" -#include "lab/resource.h" -#include "lab/interface.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/map.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 4406fae2d0..6d09a99739 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -29,6 +29,7 @@ */ #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/map.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 6d09a99739..8a0bec42e5 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -30,6 +30,7 @@ #include "lab/lab.h" #include "lab/music.h" +#include "lab/image.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/map.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 8a0bec42e5..7bcfd80df7 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -29,8 +29,10 @@ */ #include "lab/lab.h" +#include "lab/labsets.h" #include "lab/music.h" #include "lab/image.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/map.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 7bcfd80df7..accd56d320 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -29,9 +29,11 @@ */ #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/utils.h" namespace Lab { -- 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/map.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index accd56d320..21763918ff 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -30,6 +30,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/map.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 21763918ff..cec9c4c334 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -33,6 +33,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 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/map.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index cec9c4c334..af61c85738 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -36,6 +36,7 @@ #include "lab/interface.h" #include "lab/labsets.h" #include "lab/music.h" +#include "lab/processroom.h" #include "lab/resource.h" #include "lab/utils.h" -- cgit v1.2.3 From c42629674bc58f46a27a91c3c8325f68ed9f222c Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Wed, 9 Dec 2015 06:07:34 +0100 Subject: LAB: Code naming, reduced variable scope --- engines/lab/map.cpp | 252 +++++++++++++++++++++++++--------------------------- 1 file changed, 123 insertions(+), 129 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index af61c85738..bc95304369 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -137,10 +137,10 @@ void LabEngine::freeMapData() { /** * Figures out what a room's coordinates should be. */ -static void roomCoords(uint16 CurRoom, uint16 *x1, uint16 *y1, uint16 *x2, uint16 *y2) { +static void roomCoords(uint16 curRoom, uint16 *x1, uint16 *y1, uint16 *x2, uint16 *y2) { Image *curRoomImg = NULL; - switch (Maps[CurRoom].SpecialID) { + switch (Maps[curRoom].SpecialID) { case NORMAL: case UPARROWROOM: case DOWNARROWROOM: @@ -160,8 +160,8 @@ static void roomCoords(uint16 CurRoom, uint16 *x1, uint16 *y1, uint16 *x2, uint1 break; } - *x1 = mapScaleX(Maps[CurRoom].x); - *y1 = mapScaleY(Maps[CurRoom].y); + *x1 = mapScaleX(Maps[curRoom].x); + *y1 = mapScaleY(Maps[curRoom].y); *x2 = *x1; *y2 = *y1; @@ -174,21 +174,21 @@ static void roomCoords(uint16 CurRoom, uint16 *x1, uint16 *y1, uint16 *x2, uint1 /** * Draws a room map. */ -static void drawRoomMap(uint16 CurRoom, bool drawx) { +static void drawRoomMap(uint16 curRoom, bool drawx) { uint16 x, y, xx, xy, offset; uint32 flags; - x = mapScaleX(Maps[CurRoom].x); - y = mapScaleY(Maps[CurRoom].y); - flags = Maps[CurRoom].MapFlags; + x = mapScaleX(Maps[curRoom].x); + y = mapScaleY(Maps[curRoom].y); + flags = Maps[curRoom].MapFlags; - switch (Maps[CurRoom].SpecialID) { + switch (Maps[curRoom].SpecialID) { case NORMAL: case UPARROWROOM: case DOWNARROWROOM: - if (Maps[CurRoom].SpecialID == NORMAL) + if (Maps[curRoom].SpecialID == NORMAL) Room->drawImage(x, y); - else if (Maps[CurRoom].SpecialID == DOWNARROWROOM) + else if (Maps[curRoom].SpecialID == DOWNARROWROOM) DownArrowRoom->drawImage(x, y); else UpArrowRoom->drawImage(x, y); @@ -309,9 +309,9 @@ static void drawRoomMap(uint16 CurRoom, bool drawx) { /** * Checks if a floor has been visitted. */ -static bool onFloor(uint16 Floor) { +static bool onFloor(uint16 flr) { for (uint16 i = 1; i <= MaxRooms; i++) { - if ((Maps[i].PageNumber == Floor) && g_lab->_roomsFound->in(i) && Maps[i].x) + if ((Maps[i].PageNumber == flr) && g_lab->_roomsFound->in(i) && Maps[i].x) return true; } @@ -321,60 +321,52 @@ static bool onFloor(uint16 Floor) { /** * Figures out which floor, if any, should be gone to if the up arrow is hit */ -static void getUpFloor(uint16 *Floor, bool *isfloor) { +static bool getUpFloor(uint16 *flr) { do { - *isfloor = true; - - if (*Floor < kFloorUpper) - (*Floor)++; + if (*flr < kFloorUpper) + (*flr)++; else { - *Floor = kFloorCarnival + 1; - *isfloor = false; - return; + *flr = kFloorCarnival + 1; + return false; } - } while ((!onFloor(*Floor)) && (*Floor <= kFloorCarnival)); + } while ((!onFloor(*flr)) && (*flr <= kFloorCarnival)); + + return true; } /** * Figures out which floor, if any, should be gone to if the down arrow is * hit. */ -static void getDownFloor(uint16 *Floor, bool *isfloor) { +static bool getDownFloor(uint16 *flr) { do { - *isfloor = true; - - if ((*Floor == kFloorLower) || (*Floor == 0)) { - *Floor = 0; - *isfloor = false; - return; - } else if (*Floor > kFloorUpper) { + if ((*flr == kFloorLower) || (*flr == 0)) { + *flr = 0; + return false; + } else if (*flr > kFloorUpper) { // Labyrinth specific code - if (*Floor == kFloorHedgeMaze) - *Floor = kFloorUpper; - else if ((*Floor == kFloorCarnival) || (*Floor == kFloorMedMaze)) - *Floor = kFloorMiddle; - else if (*Floor == kFloorSurMaze) - *Floor = kFloorLower; + if (*flr == kFloorHedgeMaze) + *flr = kFloorUpper; + else if ((*flr == kFloorCarnival) || (*flr == kFloorMedMaze)) + *flr = kFloorMiddle; + else if (*flr == kFloorSurMaze) + *flr = kFloorLower; else { - *Floor = 0; - *isfloor = false; - return; + *flr = 0; + return false; } } else - (*Floor)--; + (*flr)--; - } while ((!onFloor(*Floor)) && *Floor); + } while ((!onFloor(*flr)) && *flr); + + return true; } /** * Draws the map */ -void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, bool fadein) { - char *sptr; - - uint16 tempfloor; - bool noOverlay; - +void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 flr, bool fadeout, bool fadein) { _event->mouseHide(); if (fadeout) @@ -387,8 +379,8 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou drawGadgetList(&_mapGadgetList); for (uint16 i = 1; i <= MaxRooms; i++) { - if ((Maps[i].PageNumber == Floor) && _roomsFound->in(i) && Maps[i].x) { - drawRoomMap(i, (bool)(i == CurRoom)); + if ((Maps[i].PageNumber == flr) && _roomsFound->in(i) && Maps[i].x) { + drawRoomMap(i, (bool)(i == curRoom)); _music->updateMusic(); } } @@ -396,11 +388,12 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou // Makes sure the X is drawn in corridors // NOTE: this here on purpose just in case there's some weird // condition, like the surreal maze where there are no rooms - if ((Maps[CurRoom].PageNumber == Floor) && _roomsFound->in(CurRoom) && Maps[CurRoom].x) - drawRoomMap(CurRoom, true); + if ((Maps[curRoom].PageNumber == flr) && _roomsFound->in(curRoom) && Maps[curRoom].x) + drawRoomMap(curRoom, true); + + uint16 tempfloor = flr; - tempfloor = Floor; - getUpFloor(&tempfloor, &noOverlay); + bool noOverlay = getUpFloor(&tempfloor); Gadget *upGadget = _event->getGadget(1); Gadget *downGadget = _event->getGadget(2); @@ -410,38 +403,40 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou else disableGadget(upGadget, 12); - tempfloor = Floor; - getDownFloor(&tempfloor, &noOverlay); + tempfloor = flr; + noOverlay = getDownFloor(&tempfloor); if (noOverlay) enableGadget(downGadget); else disableGadget(downGadget, 12); + char *sptr; + // Labyrinth specific code - if (Floor == kFloorLower) { + if (flr == kFloorLower) { if (onFloor(kFloorSurMaze)) Maze->drawImage(mapScaleX(538), mapScaleY(277)); - } else if (Floor == kFloorMiddle) { + } else if (flr == kFloorMiddle) { if (onFloor(kFloorCarnival)) Maze->drawImage(mapScaleX(358), mapScaleY(72)); if (onFloor(kFloorMedMaze)) Maze->drawImage(mapScaleX(557), mapScaleY(325)); - } else if (Floor == kFloorUpper) { + } else if (flr == kFloorUpper) { if (onFloor(kFloorHedgeMaze)) HugeMaze->drawImage(mapScaleX(524), mapScaleY(97)); - } else if (Floor == kFloorSurMaze) { + } else if (flr == kFloorSurMaze) { sptr = (char *)_resource->getStaticText(kTextSurmazeMessage).c_str(); _graphics->flowText(_msgFont, 0, 7, 0, true, true, true, true, mapScaleX(360), 0, mapScaleX(660), mapScaleY(450), sptr); } - if (Floor >= kFloorLower && Floor <= kFloorCarnival) { - sptr = (char *)_resource->getStaticText(Floor - 1).c_str(); + if (flr >= kFloorLower && flr <= kFloorCarnival) { + sptr = (char *)_resource->getStaticText(flr - 1).c_str(); _graphics->flowTextScaled(_msgFont, 0, 5, 3, true, true, true, true, 14, 75, 134, 97, sptr); } - if ((sptr = _rooms[CurMsg]._roomMsg)) + if ((sptr = _rooms[curMsg]._roomMsg)) _graphics->flowTextScaled(_msgFont, 0, 5, 3, true, true, true, true, 14, 148, 134, 186, sptr); if (fadein) @@ -453,25 +448,22 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou /** * Processes the map. */ -void LabEngine::processMap(uint16 CurRoom) { - uint32 Class, place = 1; - uint16 Code, Qualifier, MouseX, MouseY, GadgetID, CurFloor, OldFloor, OldMsg, CurMsg, x1, y1, x2, y2; - char *sptr; - byte newcolor[3]; - bool drawmap; - IntuiMessage *Msg; +void LabEngine::processMap(uint16 curRoom) { + uint32 place = 1; - CurMsg = CurRoom; - CurFloor = Maps[CurRoom].PageNumber; + uint16 curMsg = curRoom; + uint16 curFloor = Maps[curRoom].PageNumber; 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(); + byte newcolor[3]; + if (place <= 14) { newcolor[0] = 14 << 2; newcolor[1] = place << 2; @@ -498,108 +490,110 @@ void LabEngine::processMap(uint16 CurRoom) { place = 1; } else { - Class = Msg->_msgClass; - Code = Msg->_code; - GadgetID = Msg->_gadgetID; - Qualifier = Msg->_qualifier; - MouseX = Msg->_mouseX; - MouseY = Msg->_mouseY; - - if (((Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) || ((Class == RAWKEY) && (Code == 27))) + uint32 msgClass = msg->_msgClass; + uint16 msgCode = msg->_code; + uint16 gadgetID = msg->_gadgetID; + uint16 qualifier = msg->_qualifier; + uint16 mouseX = msg->_mouseX; + uint16 mouseY = msg->_mouseY; + + if (((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & qualifier)) || ((msgClass == RAWKEY) && (msgCode == 27))) return; - if (Class == GADGETUP) { - if (GadgetID == 0) { + if (msgClass == GADGETUP) { + if (gadgetID == 0) { // Quit menu button return; - } else if (GadgetID == 1) { + } else if (gadgetID == 1) { // Up arrow - OldFloor = CurFloor; - getUpFloor(&CurFloor, &drawmap); + uint16 oldFloor = curFloor; + bool drawmap = getUpFloor(&curFloor); if (drawmap) { _graphics->fade(false, 0); - drawMap(CurRoom, CurMsg, CurFloor, false, false); + drawMap(curRoom, curMsg, curFloor, false, false); _graphics->fade(true, 0); } else - CurFloor = OldFloor; - } else if (GadgetID == 2) { + curFloor = oldFloor; + } else if (gadgetID == 2) { // Down arrow - OldFloor = CurFloor; - getDownFloor(&CurFloor, &drawmap); + uint16 oldFloor = curFloor; + bool drawmap = getDownFloor(&curFloor); if (drawmap) { _graphics->fade(false, 0); - drawMap(CurRoom, CurMsg, CurFloor, false, false); + drawMap(curRoom, curMsg, curFloor, false, false); _graphics->fade(true, 0); } else - CurFloor = OldFloor; + curFloor = oldFloor; } - } else if ((Class == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & Qualifier)) { - if ((CurFloor == kFloorLower) && (MouseX >= mapScaleX(538)) && (MouseY >= mapScaleY(277)) - && (MouseX <= mapScaleX(633)) && (MouseY <= mapScaleY(352)) + } else if ((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & qualifier)) { + if ((curFloor == kFloorLower) && (mouseX >= mapScaleX(538)) && (mouseY >= mapScaleY(277)) + && (mouseX <= mapScaleX(633)) && (mouseY <= mapScaleY(352)) && onFloor(kFloorSurMaze)) { - CurFloor = kFloorSurMaze; + curFloor = kFloorSurMaze; _graphics->fade(false, 0); - drawMap(CurRoom, CurMsg, CurFloor, false, false); + drawMap(curRoom, curMsg, curFloor, false, false); _graphics->fade(true, 0); - } else if ((CurFloor == kFloorMiddle) && (MouseX >= mapScaleX(358)) && (MouseY >= mapScaleY(71)) - && (MouseX <= mapScaleX(452)) && (MouseY <= mapScaleY(147)) + } else if ((curFloor == kFloorMiddle) && (mouseX >= mapScaleX(358)) && (mouseY >= mapScaleY(71)) + && (mouseX <= mapScaleX(452)) && (mouseY <= mapScaleY(147)) && onFloor(kFloorCarnival)) { - CurFloor = kFloorCarnival; + curFloor = kFloorCarnival; _graphics->fade(false, 0); - drawMap(CurRoom, CurMsg, CurFloor, false, false); + drawMap(curRoom, curMsg, curFloor, false, false); _graphics->fade(true, 0); - } else if ((CurFloor == kFloorMiddle) && (MouseX >= mapScaleX(557)) && (MouseY >= mapScaleY(325)) - && (MouseX <= mapScaleX(653)) && (MouseY <= mapScaleY(401)) + } else if ((curFloor == kFloorMiddle) && (mouseX >= mapScaleX(557)) && (mouseY >= mapScaleY(325)) + && (mouseX <= mapScaleX(653)) && (mouseY <= mapScaleY(401)) && onFloor(kFloorMedMaze)) { - CurFloor = kFloorMedMaze; + curFloor = kFloorMedMaze; _graphics->fade(false, 0); - drawMap(CurRoom, CurMsg, CurFloor, false, false); + drawMap(curRoom, curMsg, curFloor, false, false); _graphics->fade(true, 0); - } else if ((CurFloor == kFloorUpper) && (MouseX >= mapScaleX(524)) && (MouseY >= mapScaleY(97)) - && (MouseX <= mapScaleX(645)) && (MouseY <= mapScaleY(207)) + } else if ((curFloor == kFloorUpper) && (mouseX >= mapScaleX(524)) && (mouseY >= mapScaleY(97)) + && (mouseX <= mapScaleX(645)) && (mouseY <= mapScaleY(207)) && onFloor(kFloorHedgeMaze)) { - CurFloor = kFloorHedgeMaze; + curFloor = kFloorHedgeMaze; _graphics->fade(false, 0); - drawMap(CurRoom, CurMsg, CurFloor, false, false); + drawMap(curRoom, curMsg, curFloor, false, false); _graphics->fade(true, 0); - } else if (MouseX > mapScaleX(314)) { - OldMsg = CurMsg; + } else if (mouseX > mapScaleX(314)) { + uint16 oldMsg = curMsg; + uint16 x1, y1, x2, y2; for (uint16 i = 1; i <= MaxRooms; i++) { roomCoords(i, &x1, &y1, &x2, &y2); - if ((Maps[i].PageNumber == CurFloor) + if ((Maps[i].PageNumber == curFloor) && _roomsFound->in(i) - && (MouseX >= x1) && (MouseX <= x2) - && (MouseY >= y1) && (MouseY <= y2)) { - CurMsg = i; + && (mouseX >= x1) && (mouseX <= x2) + && (mouseY >= y1) && (mouseY <= y2)) { + curMsg = i; } } - if (OldMsg != CurMsg) { - if (_rooms[CurMsg]._roomMsg == nullptr) - _resource->readViews(CurMsg); + if (oldMsg != curMsg) { + if (_rooms[curMsg]._roomMsg == nullptr) + _resource->readViews(curMsg); - if ((sptr = _rooms[CurMsg]._roomMsg)) { + char *sptr; + if ((sptr = _rooms[curMsg]._roomMsg)) { _event->mouseHide(); _graphics->setAPen(3); _graphics->rectFillScaled(13, 148, 135, 186); _graphics->flowTextScaled(_msgFont, 0, 5, 3, true, true, true, true, 14, 148, 134, 186, sptr); - if (Maps[OldMsg].PageNumber == CurFloor) - drawRoomMap(OldMsg, (bool)(OldMsg == CurRoom)); + if (Maps[oldMsg].PageNumber == curFloor) + drawRoomMap(oldMsg, (bool)(oldMsg == curRoom)); - roomCoords(CurMsg, &x1, &y1, &x2, &y2); + roomCoords(curMsg, &x1, &y1, &x2, &y2); x1 = (x1 + x2) / 2; y1 = (y1 + y2) / 2; - if ((CurMsg != CurRoom) && (Maps[CurMsg].PageNumber == CurFloor)) { + if ((curMsg != curRoom) && (Maps[curMsg].PageNumber == curFloor)) { _graphics->setAPen(1); _graphics->rectFill(x1 - 1, y1, x1, y1); } @@ -618,15 +612,15 @@ void LabEngine::processMap(uint16 CurRoom) { /** * Does the map processing. */ -void LabEngine::doMap(uint16 CurRoom) { - static uint16 AmigaMapPalette[] = { +void LabEngine::doMap(uint16 curRoom) { + static uint16 amigaMapPalette[] = { 0x0BA8, 0x0C11, 0x0A74, 0x0076, 0x0A96, 0x0DCB, 0x0CCA, 0x0222, 0x0444, 0x0555, 0x0777, 0x0999, 0x0AAA, 0x0ED0, 0x0EEE, 0x0694 }; - _graphics->FadePalette = AmigaMapPalette; + _graphics->FadePalette = amigaMapPalette; _music->updateMusic(); loadMapData(); @@ -642,10 +636,10 @@ void LabEngine::doMap(uint16 CurRoom) { XMark = MapWest; _event->attachGadgetList(&_mapGadgetList); - drawMap(CurRoom, CurRoom, Maps[CurRoom].PageNumber, false, true); + drawMap(curRoom, curRoom, Maps[curRoom].PageNumber, false, true); _event->mouseShow(); _graphics->screenUpdate(); - processMap(CurRoom); + processMap(curRoom); _event->attachGadgetList(NULL); _graphics->fade(false, 0); _graphics->blackAllScreen(); -- 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/map.cpp | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index bc95304369..6bf77c48fe 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -117,11 +117,11 @@ void LabEngine::loadMapData() { MaxRooms = mapFile->readUint16LE(); Maps = new MapData[MaxRooms]; // will be freed when the user exits the map for (int i = 0; i < MaxRooms; i++) { - Maps[i].x = mapFile->readUint16LE(); - Maps[i].y = mapFile->readUint16LE(); - Maps[i].PageNumber = mapFile->readUint16LE(); - Maps[i].SpecialID = mapFile->readUint16LE(); - Maps[i].MapFlags = mapFile->readUint32LE(); + Maps[i]._x = mapFile->readUint16LE(); + Maps[i]._y = mapFile->readUint16LE(); + Maps[i]._pageNumber = mapFile->readUint16LE(); + Maps[i]._specialID = mapFile->readUint16LE(); + Maps[i]._mapFlags = mapFile->readUint32LE(); } delete mapFile; @@ -140,7 +140,7 @@ void LabEngine::freeMapData() { static void roomCoords(uint16 curRoom, uint16 *x1, uint16 *y1, uint16 *x2, uint16 *y2) { Image *curRoomImg = NULL; - switch (Maps[curRoom].SpecialID) { + switch (Maps[curRoom]._specialID) { case NORMAL: case UPARROWROOM: case DOWNARROWROOM: @@ -160,8 +160,8 @@ static void roomCoords(uint16 curRoom, uint16 *x1, uint16 *y1, uint16 *x2, uint1 break; } - *x1 = mapScaleX(Maps[curRoom].x); - *y1 = mapScaleY(Maps[curRoom].y); + *x1 = mapScaleX(Maps[curRoom]._x); + *y1 = mapScaleY(Maps[curRoom]._y); *x2 = *x1; *y2 = *y1; @@ -178,17 +178,17 @@ static void drawRoomMap(uint16 curRoom, bool drawx) { uint16 x, y, xx, xy, offset; uint32 flags; - x = mapScaleX(Maps[curRoom].x); - y = mapScaleY(Maps[curRoom].y); - flags = Maps[curRoom].MapFlags; + x = mapScaleX(Maps[curRoom]._x); + y = mapScaleY(Maps[curRoom]._y); + flags = Maps[curRoom]._mapFlags; - switch (Maps[curRoom].SpecialID) { + switch (Maps[curRoom]._specialID) { case NORMAL: case UPARROWROOM: case DOWNARROWROOM: - if (Maps[curRoom].SpecialID == NORMAL) + if (Maps[curRoom]._specialID == NORMAL) Room->drawImage(x, y); - else if (Maps[curRoom].SpecialID == DOWNARROWROOM) + else if (Maps[curRoom]._specialID == DOWNARROWROOM) DownArrowRoom->drawImage(x, y); else UpArrowRoom->drawImage(x, y); @@ -311,7 +311,7 @@ static void drawRoomMap(uint16 curRoom, bool drawx) { */ static bool onFloor(uint16 flr) { for (uint16 i = 1; i <= MaxRooms; i++) { - if ((Maps[i].PageNumber == flr) && g_lab->_roomsFound->in(i) && Maps[i].x) + if ((Maps[i]._pageNumber == flr) && g_lab->_roomsFound->in(i) && Maps[i]._x) return true; } @@ -379,7 +379,7 @@ void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 flr, bool fadeout, drawGadgetList(&_mapGadgetList); for (uint16 i = 1; i <= MaxRooms; i++) { - if ((Maps[i].PageNumber == flr) && _roomsFound->in(i) && Maps[i].x) { + if ((Maps[i]._pageNumber == flr) && _roomsFound->in(i) && Maps[i]._x) { drawRoomMap(i, (bool)(i == curRoom)); _music->updateMusic(); } @@ -388,7 +388,7 @@ void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 flr, bool fadeout, // Makes sure the X is drawn in corridors // NOTE: this here on purpose just in case there's some weird // condition, like the surreal maze where there are no rooms - if ((Maps[curRoom].PageNumber == flr) && _roomsFound->in(curRoom) && Maps[curRoom].x) + if ((Maps[curRoom]._pageNumber == flr) && _roomsFound->in(curRoom) && Maps[curRoom]._x) drawRoomMap(curRoom, true); uint16 tempfloor = flr; @@ -452,7 +452,7 @@ void LabEngine::processMap(uint16 curRoom) { uint32 place = 1; uint16 curMsg = curRoom; - uint16 curFloor = Maps[curRoom].PageNumber; + uint16 curFloor = Maps[curRoom]._pageNumber; while (1) { // Make sure we check the music at least after every message @@ -567,7 +567,7 @@ void LabEngine::processMap(uint16 curRoom) { for (uint16 i = 1; i <= MaxRooms; i++) { roomCoords(i, &x1, &y1, &x2, &y2); - if ((Maps[i].PageNumber == curFloor) + if ((Maps[i]._pageNumber == curFloor) && _roomsFound->in(i) && (mouseX >= x1) && (mouseX <= x2) && (mouseY >= y1) && (mouseY <= y2)) { @@ -586,14 +586,14 @@ void LabEngine::processMap(uint16 curRoom) { _graphics->rectFillScaled(13, 148, 135, 186); _graphics->flowTextScaled(_msgFont, 0, 5, 3, true, true, true, true, 14, 148, 134, 186, sptr); - if (Maps[oldMsg].PageNumber == curFloor) + if (Maps[oldMsg]._pageNumber == curFloor) drawRoomMap(oldMsg, (bool)(oldMsg == curRoom)); roomCoords(curMsg, &x1, &y1, &x2, &y2); x1 = (x1 + x2) / 2; y1 = (y1 + y2) / 2; - if ((curMsg != curRoom) && (Maps[curMsg].PageNumber == curFloor)) { + if ((curMsg != curRoom) && (Maps[curMsg]._pageNumber == curFloor)) { _graphics->setAPen(1); _graphics->rectFill(x1 - 1, y1, x1, y1); } @@ -636,7 +636,7 @@ void LabEngine::doMap(uint16 curRoom) { XMark = MapWest; _event->attachGadgetList(&_mapGadgetList); - drawMap(curRoom, curRoom, Maps[curRoom].PageNumber, false, true); + drawMap(curRoom, curRoom, Maps[curRoom]._pageNumber, false, true); _event->mouseShow(); _graphics->screenUpdate(); processMap(curRoom); -- cgit v1.2.3 From 72c08cfc8c3d9f19e21592206995578b90345f8a Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 9 Dec 2015 11:30:12 +0100 Subject: LAB: Move mapScale functions to the utility class --- engines/lab/map.cpp | 50 ++++++++++++++++++-------------------------------- 1 file changed, 18 insertions(+), 32 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 6bf77c48fe..544627cf55 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -64,20 +64,6 @@ enum MapFloor { kFloorCarnival }; -static uint16 mapScaleX(uint16 x) { - if (g_lab->_isHiRes) - return (x - 45); - else - return ((x - 45) >> 1); -} - -static uint16 mapScaleY(uint16 y) { - if (g_lab->_isHiRes) - return y; - else - return ((y - 35) >> 1) - (y >> 6); -} - /** * Loads in the map data. */ @@ -160,8 +146,8 @@ static void roomCoords(uint16 curRoom, uint16 *x1, uint16 *y1, uint16 *x2, uint1 break; } - *x1 = mapScaleX(Maps[curRoom]._x); - *y1 = mapScaleY(Maps[curRoom]._y); + *x1 = g_lab->_utils->mapScaleX(Maps[curRoom]._x); + *y1 = g_lab->_utils->mapScaleY(Maps[curRoom]._y); *x2 = *x1; *y2 = *y1; @@ -178,8 +164,8 @@ static void drawRoomMap(uint16 curRoom, bool drawx) { uint16 x, y, xx, xy, offset; uint32 flags; - x = mapScaleX(Maps[curRoom]._x); - y = mapScaleY(Maps[curRoom]._y); + x = g_lab->_utils->mapScaleX(Maps[curRoom]._x); + y = g_lab->_utils->mapScaleY(Maps[curRoom]._y); flags = Maps[curRoom]._mapFlags; switch (Maps[curRoom]._specialID) { @@ -416,19 +402,19 @@ void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 flr, bool fadeout, // Labyrinth specific code if (flr == kFloorLower) { if (onFloor(kFloorSurMaze)) - Maze->drawImage(mapScaleX(538), mapScaleY(277)); + Maze->drawImage(_utils->mapScaleX(538), _utils->mapScaleY(277)); } else if (flr == kFloorMiddle) { if (onFloor(kFloorCarnival)) - Maze->drawImage(mapScaleX(358), mapScaleY(72)); + Maze->drawImage(_utils->mapScaleX(358), _utils->mapScaleY(72)); if (onFloor(kFloorMedMaze)) - Maze->drawImage(mapScaleX(557), mapScaleY(325)); + Maze->drawImage(_utils->mapScaleX(557), _utils->mapScaleY(325)); } else if (flr == kFloorUpper) { if (onFloor(kFloorHedgeMaze)) - HugeMaze->drawImage(mapScaleX(524), mapScaleY(97)); + HugeMaze->drawImage(_utils->mapScaleX(524), _utils->mapScaleY(97)); } else if (flr == kFloorSurMaze) { sptr = (char *)_resource->getStaticText(kTextSurmazeMessage).c_str(); - _graphics->flowText(_msgFont, 0, 7, 0, true, true, true, true, mapScaleX(360), 0, mapScaleX(660), mapScaleY(450), sptr); + _graphics->flowText(_msgFont, 0, 7, 0, true, true, true, true, _utils->mapScaleX(360), 0, _utils->mapScaleX(660), _utils->mapScaleY(450), sptr); } if (flr >= kFloorLower && flr <= kFloorCarnival) { @@ -528,39 +514,39 @@ void LabEngine::processMap(uint16 curRoom) { curFloor = oldFloor; } } else if ((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & qualifier)) { - if ((curFloor == kFloorLower) && (mouseX >= mapScaleX(538)) && (mouseY >= mapScaleY(277)) - && (mouseX <= mapScaleX(633)) && (mouseY <= mapScaleY(352)) + if ((curFloor == kFloorLower) && (mouseX >= _utils->mapScaleX(538)) && (mouseY >= _utils->mapScaleY(277)) + && (mouseX <= _utils->mapScaleX(633)) && (mouseY <= _utils->mapScaleY(352)) && onFloor(kFloorSurMaze)) { curFloor = kFloorSurMaze; _graphics->fade(false, 0); drawMap(curRoom, curMsg, curFloor, false, false); _graphics->fade(true, 0); - } else if ((curFloor == kFloorMiddle) && (mouseX >= mapScaleX(358)) && (mouseY >= mapScaleY(71)) - && (mouseX <= mapScaleX(452)) && (mouseY <= mapScaleY(147)) + } else if ((curFloor == kFloorMiddle) && (mouseX >= _utils->mapScaleX(358)) && (mouseY >= _utils->mapScaleY(71)) + && (mouseX <= _utils->mapScaleX(452)) && (mouseY <= _utils->mapScaleY(147)) && onFloor(kFloorCarnival)) { curFloor = kFloorCarnival; _graphics->fade(false, 0); drawMap(curRoom, curMsg, curFloor, false, false); _graphics->fade(true, 0); - } else if ((curFloor == kFloorMiddle) && (mouseX >= mapScaleX(557)) && (mouseY >= mapScaleY(325)) - && (mouseX <= mapScaleX(653)) && (mouseY <= mapScaleY(401)) + } else if ((curFloor == kFloorMiddle) && (mouseX >= _utils->mapScaleX(557)) && (mouseY >= _utils->mapScaleY(325)) + && (mouseX <= _utils->mapScaleX(653)) && (mouseY <= _utils->mapScaleY(401)) && onFloor(kFloorMedMaze)) { curFloor = kFloorMedMaze; _graphics->fade(false, 0); drawMap(curRoom, curMsg, curFloor, false, false); _graphics->fade(true, 0); - } else if ((curFloor == kFloorUpper) && (mouseX >= mapScaleX(524)) && (mouseY >= mapScaleY(97)) - && (mouseX <= mapScaleX(645)) && (mouseY <= mapScaleY(207)) + } else if ((curFloor == kFloorUpper) && (mouseX >= _utils->mapScaleX(524)) && (mouseY >= _utils->mapScaleY(97)) + && (mouseX <= _utils->mapScaleX(645)) && (mouseY <= _utils->mapScaleY(207)) && onFloor(kFloorHedgeMaze)) { curFloor = kFloorHedgeMaze; _graphics->fade(false, 0); drawMap(curRoom, curMsg, curFloor, false, false); _graphics->fade(true, 0); - } else if (mouseX > mapScaleX(314)) { + } else if (mouseX > _utils->mapScaleX(314)) { uint16 oldMsg = curMsg; uint16 x1, y1, x2, y2; -- cgit v1.2.3 From 1e9ee6ef4a6fca9f268cf642a239f88a5cc1ec84 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 9 Dec 2015 11:49:10 +0100 Subject: LAB: Some refactoring and renaming in map.cpp --- engines/lab/map.cpp | 69 +++++++++++++++++++++++++++-------------------------- 1 file changed, 35 insertions(+), 34 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 544627cf55..2bf261da7a 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -123,8 +123,8 @@ void LabEngine::freeMapData() { /** * Figures out what a room's coordinates should be. */ -static void roomCoords(uint16 curRoom, uint16 *x1, uint16 *y1, uint16 *x2, uint16 *y2) { - Image *curRoomImg = NULL; +Common::Rect LabEngine::roomCoords(uint16 curRoom) { + Image *curRoomImg = nullptr; switch (Maps[curRoom]._specialID) { case NORMAL: @@ -146,27 +146,28 @@ static void roomCoords(uint16 curRoom, uint16 *x1, uint16 *y1, uint16 *x2, uint1 break; } - *x1 = g_lab->_utils->mapScaleX(Maps[curRoom]._x); - *y1 = g_lab->_utils->mapScaleY(Maps[curRoom]._y); - *x2 = *x1; - *y2 = *y1; + int x1 = _utils->mapScaleX(Maps[curRoom]._x); + int y1 = _utils->mapScaleY(Maps[curRoom]._y); + int x2 = x1; + int y2 = y1; if (curRoomImg) { - *x2 += curRoomImg->_width; - *y2 += curRoomImg->_height; + x2 += curRoomImg->_width; + y2 += curRoomImg->_height; } + + return Common::Rect(x1, y1, x2, y2); } /** * Draws a room map. */ -static void drawRoomMap(uint16 curRoom, bool drawx) { - uint16 x, y, xx, xy, offset; - uint32 flags; +static void drawRoomMap(uint16 curRoom, bool drawMarkFl) { + uint16 drawX, drawY, offset; - x = g_lab->_utils->mapScaleX(Maps[curRoom]._x); - y = g_lab->_utils->mapScaleY(Maps[curRoom]._y); - flags = Maps[curRoom]._mapFlags; + uint16 x = g_lab->_utils->mapScaleX(Maps[curRoom]._x); + uint16 y = g_lab->_utils->mapScaleY(Maps[curRoom]._y); + uint32 flags = Maps[curRoom]._mapFlags; switch (Maps[curRoom]._specialID) { case NORMAL: @@ -195,16 +196,16 @@ static void drawRoomMap(uint16 curRoom, bool drawx) { if (WESTDOOR & flags) Path->drawImage(x - Path->_width, y + offset); - xx = x + (Room->_width - XMark->_width) / 2; - xy = y + (Room->_height - XMark->_height) / 2; + drawX = x + (Room->_width - XMark->_width) / 2; + drawY = y + (Room->_height - XMark->_height) / 2; break; case BRIDGEROOM: Bridge->drawImage(x, y); - xx = x + (Bridge->_width - XMark->_width) / 2; - xy = y + (Bridge->_height - XMark->_height) / 2; + drawX = x + (Bridge->_width - XMark->_width) / 2; + drawY = y + (Bridge->_height - XMark->_height) / 2; break; @@ -241,8 +242,8 @@ static void drawRoomMap(uint16 curRoom, bool drawx) { if (WESTMDOOR & flags) Path->drawImage(x - Path->_width, y - offset - Path->_height + VRoom->_height); - xx = x + (VRoom->_width - XMark->_width) / 2; - xy = y + (VRoom->_height - XMark->_height) / 2; + drawX = x + (VRoom->_width - XMark->_width) / 2; + drawY = y + (VRoom->_height - XMark->_height) / 2; break; @@ -279,8 +280,8 @@ static void drawRoomMap(uint16 curRoom, bool drawx) { if (WESTDOOR & flags) Path->drawImage(x - Path->_width, y + offset); - xx = x + (HRoom->_width - XMark->_width) / 2; - xy = y + (HRoom->_height - XMark->_height) / 2; + drawX = x + (HRoom->_width - XMark->_width) / 2; + drawY = y + (HRoom->_height - XMark->_height) / 2; break; @@ -288,12 +289,12 @@ static void drawRoomMap(uint16 curRoom, bool drawx) { return; } - if (drawx) - XMark->drawImage(xx, xy); + if (drawMarkFl) + XMark->drawImage(drawX, drawY); } /** - * Checks if a floor has been visitted. + * Checks if a floor has been visited. */ static bool onFloor(uint16 flr) { for (uint16 i = 1; i <= MaxRooms; i++) { @@ -548,15 +549,13 @@ void LabEngine::processMap(uint16 curRoom) { _graphics->fade(true, 0); } else if (mouseX > _utils->mapScaleX(314)) { uint16 oldMsg = curMsg; - uint16 x1, y1, x2, y2; + Common::Rect curCoords; for (uint16 i = 1; i <= MaxRooms; i++) { - roomCoords(i, &x1, &y1, &x2, &y2); + curCoords = roomCoords(i); if ((Maps[i]._pageNumber == curFloor) - && _roomsFound->in(i) - && (mouseX >= x1) && (mouseX <= x2) - && (mouseY >= y1) && (mouseY <= y2)) { + && _roomsFound->in(i) && curCoords.contains(Common::Point(mouseX, mouseY))) { curMsg = i; } } @@ -575,13 +574,15 @@ void LabEngine::processMap(uint16 curRoom) { if (Maps[oldMsg]._pageNumber == curFloor) drawRoomMap(oldMsg, (bool)(oldMsg == curRoom)); - roomCoords(curMsg, &x1, &y1, &x2, &y2); - x1 = (x1 + x2) / 2; - y1 = (y1 + y2) / 2; + curCoords = roomCoords(curMsg); + int right = (curCoords.left + curCoords.right) / 2; + int left = right - 1; + int top, bottom; + top = bottom = (curCoords.top + curCoords.bottom) / 2; if ((curMsg != curRoom) && (Maps[curMsg]._pageNumber == curFloor)) { _graphics->setAPen(1); - _graphics->rectFill(x1 - 1, y1, x1, y1); + _graphics->rectFill(left, top, right, bottom); } _event->mouseShow(); -- cgit v1.2.3 From 2d90f8a08daf6a6b89ce2c4dd2ac11c03c4c4532 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 9 Dec 2015 18:09:46 +0100 Subject: LAB: Move map function to LabEngine class, some renaming --- engines/lab/map.cpp | 346 +++++++++++++++++++++++++++------------------------- 1 file changed, 182 insertions(+), 164 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 2bf261da7a..c6b2277280 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -46,13 +46,6 @@ namespace Lab { /*------------------------------ The Map stuff ------------------------------*/ /*---------------------------------------------------------------------------*/ -static Image *Map, *Room, *UpArrowRoom, *DownArrowRoom, *Bridge, - *HRoom, *VRoom, *Maze, *HugeMaze, *Path, *MapNorth, - *MapEast, *MapSouth, *MapWest, *XMark; - -static uint16 MaxRooms; -static MapData *Maps; - enum MapFloor { kFloorNone, kFloorLower, @@ -68,46 +61,43 @@ enum MapFloor { * Loads in the map data. */ void LabEngine::loadMapData() { - Utils *utils = g_lab->_utils; - Common::File *mapImages = g_lab->_resource->openDataFile("P:MapImage"); - - Map = new Image(mapImages); - - Room = new Image(mapImages); - UpArrowRoom = new Image(mapImages); - DownArrowRoom = new Image(mapImages); - HRoom = new Image(mapImages); - VRoom = new Image(mapImages); - Maze = new Image(mapImages); - HugeMaze = new Image(mapImages); - - MapNorth = new Image(mapImages); - MapEast = new Image(mapImages); - MapSouth = new Image(mapImages); - MapWest = new Image(mapImages); - - Path = new Image(mapImages); - Bridge = new Image(mapImages); - - _mapGadgetList.push_back(createButton( 8, utils->vgaScaleY(105), 0, VKEY_LTARROW, new Image(mapImages), new Image(mapImages))); // back - _mapGadgetList.push_back(createButton( 55, utils->vgaScaleY(105), 1, VKEY_UPARROW, new Image(mapImages), new Image(mapImages))); // up - _mapGadgetList.push_back(createButton(101, utils->vgaScaleY(105), 2, VKEY_DNARROW, new Image(mapImages), new Image(mapImages))); // down + Common::File *mapImages = _resource->openDataFile("P:MapImage"); + + _imgMap = new Image(mapImages); + _imgRoom = new Image(mapImages); + _imgUpArrowRoom = new Image(mapImages); + _imgDownArrowRoom = new Image(mapImages); + _imgHRoom = new Image(mapImages); + _imgVRoom = new Image(mapImages); + _imgMaze = new Image(mapImages); + _imgHugeMaze = new Image(mapImages); + + _imgMapNorth = new Image(mapImages); + _imgMapEast = new Image(mapImages); + _imgMapSouth = new Image(mapImages); + _imgMapWest = new Image(mapImages); + _imgPath = new Image(mapImages); + _imgBridge = new Image(mapImages); + + _mapGadgetList.push_back(createButton( 8, _utils->vgaScaleY(105), 0, VKEY_LTARROW, new Image(mapImages), new Image(mapImages))); // back + _mapGadgetList.push_back(createButton( 55, _utils->vgaScaleY(105), 1, VKEY_UPARROW, new Image(mapImages), new Image(mapImages))); // up + _mapGadgetList.push_back(createButton(101, _utils->vgaScaleY(105), 2, VKEY_DNARROW, new Image(mapImages), new Image(mapImages))); // down delete mapImages; - Common::File *mapFile = g_lab->_resource->openDataFile("Lab:Maps", MKTAG('M', 'A', 'P', '0')); - g_lab->_music->updateMusic(); - if (!g_lab->_music->_doNotFilestopSoundEffect) - g_lab->_music->stopSoundEffect(); - - MaxRooms = mapFile->readUint16LE(); - Maps = new MapData[MaxRooms]; // will be freed when the user exits the map - for (int i = 0; i < MaxRooms; i++) { - Maps[i]._x = mapFile->readUint16LE(); - Maps[i]._y = mapFile->readUint16LE(); - Maps[i]._pageNumber = mapFile->readUint16LE(); - Maps[i]._specialID = mapFile->readUint16LE(); - Maps[i]._mapFlags = mapFile->readUint32LE(); + Common::File *mapFile = _resource->openDataFile("Lab:Maps", MKTAG('M', 'A', 'P', '0')); + _music->updateMusic(); + if (!_music->_doNotFilestopSoundEffect) + _music->stopSoundEffect(); + + _maxRooms = mapFile->readUint16LE(); + _maps = new MapData[_maxRooms]; // will be freed when the user exits the map + for (int i = 0; i < _maxRooms; i++) { + _maps[i]._x = mapFile->readUint16LE(); + _maps[i]._y = mapFile->readUint16LE(); + _maps[i]._pageNumber = mapFile->readUint16LE(); + _maps[i]._specialID = mapFile->readUint16LE(); + _maps[i]._mapFlags = mapFile->readUint32LE(); } delete mapFile; @@ -116,8 +106,40 @@ void LabEngine::loadMapData() { void LabEngine::freeMapData() { freeButtonList(&_mapGadgetList); - delete[] Maps; - Maps = NULL; + delete[] _maps; + delete _imgMap; + delete _imgRoom; + delete _imgUpArrowRoom; + delete _imgDownArrowRoom; + delete _imgBridge; + delete _imgHRoom; + delete _imgVRoom; + delete _imgMaze; + delete _imgHugeMaze; + delete _imgPath; + delete _imgMapNorth; + delete _imgMapEast; + delete _imgMapSouth; + delete _imgMapWest; + delete _imgXMark; + delete _maps; + + _imgMap = nullptr; + _imgRoom = nullptr; + _imgUpArrowRoom = nullptr; + _imgDownArrowRoom = nullptr; + _imgBridge = nullptr; + _imgHRoom = nullptr; + _imgVRoom = nullptr; + _imgMaze = nullptr; + _imgHugeMaze = nullptr; + _imgPath = nullptr; + _imgMapNorth = nullptr; + _imgMapEast = nullptr; + _imgMapSouth = nullptr; + _imgMapWest = nullptr; + _imgXMark = nullptr; + _maps = nullptr; } /** @@ -126,28 +148,28 @@ void LabEngine::freeMapData() { Common::Rect LabEngine::roomCoords(uint16 curRoom) { Image *curRoomImg = nullptr; - switch (Maps[curRoom]._specialID) { + switch (_maps[curRoom]._specialID) { case NORMAL: case UPARROWROOM: case DOWNARROWROOM: - curRoomImg = Room; + curRoomImg = _imgRoom; break; case BRIDGEROOM: - curRoomImg = Bridge; + curRoomImg = _imgBridge; break; case VCORRIDOR: - curRoomImg = VRoom; + curRoomImg = _imgVRoom; break; case HCORRIDOR: - curRoomImg = HRoom; + curRoomImg = _imgHRoom; break; default: // Some rooms (like the map) do not have an image break; } - int x1 = _utils->mapScaleX(Maps[curRoom]._x); - int y1 = _utils->mapScaleY(Maps[curRoom]._y); + int x1 = _utils->mapScaleX(_maps[curRoom]._x); + int y1 = _utils->mapScaleY(_maps[curRoom]._y); int x2 = x1; int y2 = y1; @@ -162,126 +184,126 @@ Common::Rect LabEngine::roomCoords(uint16 curRoom) { /** * Draws a room map. */ -static void drawRoomMap(uint16 curRoom, bool drawMarkFl) { +void LabEngine::drawRoomMap(uint16 curRoom, bool drawMarkFl) { uint16 drawX, drawY, offset; - uint16 x = g_lab->_utils->mapScaleX(Maps[curRoom]._x); - uint16 y = g_lab->_utils->mapScaleY(Maps[curRoom]._y); - uint32 flags = Maps[curRoom]._mapFlags; + uint16 x = _utils->mapScaleX(_maps[curRoom]._x); + uint16 y = _utils->mapScaleY(_maps[curRoom]._y); + uint32 flags = _maps[curRoom]._mapFlags; - switch (Maps[curRoom]._specialID) { + switch (_maps[curRoom]._specialID) { case NORMAL: case UPARROWROOM: case DOWNARROWROOM: - if (Maps[curRoom]._specialID == NORMAL) - Room->drawImage(x, y); - else if (Maps[curRoom]._specialID == DOWNARROWROOM) - DownArrowRoom->drawImage(x, y); + if (_maps[curRoom]._specialID == NORMAL) + _imgRoom->drawImage(x, y); + else if (_maps[curRoom]._specialID == DOWNARROWROOM) + _imgDownArrowRoom->drawImage(x, y); else - UpArrowRoom->drawImage(x, y); + _imgUpArrowRoom->drawImage(x, y); - offset = (Room->_width - Path->_width) / 2; + offset = (_imgRoom->_width - _imgPath->_width) / 2; - if ((NORTHDOOR & flags) && (y >= Path->_height)) - Path->drawImage(x + offset, y - Path->_height); + if ((NORTHDOOR & flags) && (y >= _imgPath->_height)) + _imgPath->drawImage(x + offset, y - _imgPath->_height); if (SOUTHDOOR & flags) - Path->drawImage(x + offset, y + Room->_height); + _imgPath->drawImage(x + offset, y + _imgRoom->_height); - offset = (Room->_height - Path->_height) / 2; + offset = (_imgRoom->_height - _imgPath->_height) / 2; if (EASTDOOR & flags) - Path->drawImage(x + Room->_width, y + offset); + _imgPath->drawImage(x + _imgRoom->_width, y + offset); if (WESTDOOR & flags) - Path->drawImage(x - Path->_width, y + offset); + _imgPath->drawImage(x - _imgPath->_width, y + offset); - drawX = x + (Room->_width - XMark->_width) / 2; - drawY = y + (Room->_height - XMark->_height) / 2; + drawX = x + (_imgRoom->_width - _imgXMark->_width) / 2; + drawY = y + (_imgRoom->_height - _imgXMark->_height) / 2; break; case BRIDGEROOM: - Bridge->drawImage(x, y); + _imgBridge->drawImage(x, y); - drawX = x + (Bridge->_width - XMark->_width) / 2; - drawY = y + (Bridge->_height - XMark->_height) / 2; + drawX = x + (_imgBridge->_width - _imgXMark->_width) / 2; + drawY = y + (_imgBridge->_height - _imgXMark->_height) / 2; break; case VCORRIDOR: - VRoom->drawImage(x, y); + _imgVRoom->drawImage(x, y); - offset = (VRoom->_width - Path->_width) / 2; + offset = (_imgVRoom->_width - _imgPath->_width) / 2; if (NORTHDOOR & flags) - Path->drawImage(x + offset, y - Path->_height); + _imgPath->drawImage(x + offset, y - _imgPath->_height); if (SOUTHDOOR & flags) - Path->drawImage(x + offset, y + VRoom->_height); + _imgPath->drawImage(x + offset, y + _imgVRoom->_height); - offset = (Room->_height - Path->_height) / 2; + offset = (_imgRoom->_height - _imgPath->_height) / 2; if (EASTDOOR & flags) - Path->drawImage(x + VRoom->_width, y + offset); + _imgPath->drawImage(x + _imgVRoom->_width, y + offset); if (WESTDOOR & flags) - Path->drawImage(x - Path->_width, y + offset); + _imgPath->drawImage(x - _imgPath->_width, y + offset); if (EASTBDOOR & flags) - Path->drawImage(x + VRoom->_width, y - offset - Path->_height + VRoom->_height); + _imgPath->drawImage(x + _imgVRoom->_width, y - offset - _imgPath->_height + _imgVRoom->_height); if (WESTBDOOR & flags) - Path->drawImage(x - Path->_width, y - offset - Path->_height + VRoom->_height); + _imgPath->drawImage(x - _imgPath->_width, y - offset - _imgPath->_height + _imgVRoom->_height); - offset = (VRoom->_height - Path->_height) / 2; + offset = (_imgVRoom->_height - _imgPath->_height) / 2; if (EASTMDOOR & flags) - Path->drawImage(x + VRoom->_width, y - offset - Path->_height + VRoom->_height); + _imgPath->drawImage(x + _imgVRoom->_width, y - offset - _imgPath->_height + _imgVRoom->_height); if (WESTMDOOR & flags) - Path->drawImage(x - Path->_width, y - offset - Path->_height + VRoom->_height); + _imgPath->drawImage(x - _imgPath->_width, y - offset - _imgPath->_height + _imgVRoom->_height); - drawX = x + (VRoom->_width - XMark->_width) / 2; - drawY = y + (VRoom->_height - XMark->_height) / 2; + drawX = x + (_imgVRoom->_width - _imgXMark->_width) / 2; + drawY = y + (_imgVRoom->_height - _imgXMark->_height) / 2; break; case HCORRIDOR: - HRoom->drawImage(x, y); + _imgHRoom->drawImage(x, y); - offset = (Room->_width - Path->_width) / 2; + offset = (_imgRoom->_width - _imgPath->_width) / 2; if (NORTHDOOR & flags) - Path->drawImage(x + offset, y - Path->_height); + _imgPath->drawImage(x + offset, y - _imgPath->_height); if (SOUTHDOOR & flags) - Path->drawImage(x + offset, y + Room->_height); + _imgPath->drawImage(x + offset, y + _imgRoom->_height); if (NORTHRDOOR & flags) - Path->drawImage(x - offset - Path->_width + HRoom->_width, y - Path->_height); + _imgPath->drawImage(x - offset - _imgPath->_width + _imgHRoom->_width, y - _imgPath->_height); if (SOUTHRDOOR & flags) - Path->drawImage(x - offset - Path->_width + HRoom->_width, y + Room->_height); + _imgPath->drawImage(x - offset - _imgPath->_width + _imgHRoom->_width, y + _imgRoom->_height); - offset = (HRoom->_width - Path->_width) / 2; + offset = (_imgHRoom->_width - _imgPath->_width) / 2; if (NORTHMDOOR & flags) - Path->drawImage(x - offset - Path->_width + HRoom->_width, y - Path->_height); + _imgPath->drawImage(x - offset - _imgPath->_width + _imgHRoom->_width, y - _imgPath->_height); if (SOUTHMDOOR & flags) - Path->drawImage(x - offset - Path->_width + HRoom->_width, y + Room->_height); + _imgPath->drawImage(x - offset - _imgPath->_width + _imgHRoom->_width, y + _imgRoom->_height); - offset = (Room->_height - Path->_height) / 2; + offset = (_imgRoom->_height - _imgPath->_height) / 2; if (EASTDOOR & flags) - Path->drawImage(x + HRoom->_width, y + offset); + _imgPath->drawImage(x + _imgHRoom->_width, y + offset); if (WESTDOOR & flags) - Path->drawImage(x - Path->_width, y + offset); + _imgPath->drawImage(x - _imgPath->_width, y + offset); - drawX = x + (HRoom->_width - XMark->_width) / 2; - drawY = y + (HRoom->_height - XMark->_height) / 2; + drawX = x + (_imgHRoom->_width - _imgXMark->_width) / 2; + drawY = y + (_imgHRoom->_height - _imgXMark->_height) / 2; break; @@ -290,15 +312,15 @@ static void drawRoomMap(uint16 curRoom, bool drawMarkFl) { } if (drawMarkFl) - XMark->drawImage(drawX, drawY); + _imgXMark->drawImage(drawX, drawY); } /** * Checks if a floor has been visited. */ -static bool onFloor(uint16 flr) { - for (uint16 i = 1; i <= MaxRooms; i++) { - if ((Maps[i]._pageNumber == flr) && g_lab->_roomsFound->in(i) && Maps[i]._x) +bool LabEngine::onFloor(uint16 floorNum) { + for (uint16 i = 1; i <= _maxRooms; i++) { + if ((_maps[i]._pageNumber == floorNum) && _roomsFound->in(i) && _maps[i]._x) return true; } @@ -308,15 +330,15 @@ static bool onFloor(uint16 flr) { /** * Figures out which floor, if any, should be gone to if the up arrow is hit */ -static bool getUpFloor(uint16 *flr) { +bool LabEngine::getUpFloor(uint16 *floorNum) { do { - if (*flr < kFloorUpper) - (*flr)++; + if (*floorNum < kFloorUpper) + (*floorNum)++; else { - *flr = kFloorCarnival + 1; + *floorNum = kFloorCarnival + 1; return false; } - } while ((!onFloor(*flr)) && (*flr <= kFloorCarnival)); + } while ((!onFloor(*floorNum)) && (*floorNum <= kFloorCarnival)); return true; } @@ -325,27 +347,27 @@ static bool getUpFloor(uint16 *flr) { * Figures out which floor, if any, should be gone to if the down arrow is * hit. */ -static bool getDownFloor(uint16 *flr) { +bool LabEngine::getDownFloor(uint16 *floorNum) { do { - if ((*flr == kFloorLower) || (*flr == 0)) { - *flr = 0; + if ((*floorNum == kFloorLower) || (*floorNum == kFloorNone)) { + *floorNum = kFloorNone; return false; - } else if (*flr > kFloorUpper) { + } else if (*floorNum > kFloorUpper) { // Labyrinth specific code - if (*flr == kFloorHedgeMaze) - *flr = kFloorUpper; - else if ((*flr == kFloorCarnival) || (*flr == kFloorMedMaze)) - *flr = kFloorMiddle; - else if (*flr == kFloorSurMaze) - *flr = kFloorLower; + if (*floorNum == kFloorHedgeMaze) + *floorNum = kFloorUpper; + else if ((*floorNum == kFloorCarnival) || (*floorNum == kFloorMedMaze)) + *floorNum = kFloorMiddle; + else if (*floorNum == kFloorSurMaze) + *floorNum = kFloorLower; else { - *flr = 0; + *floorNum = kFloorNone; return false; } } else - (*flr)--; + (*floorNum)--; - } while ((!onFloor(*flr)) && *flr); + } while ((!onFloor(*floorNum)) && (*floorNum != kFloorNone)); return true; } @@ -353,20 +375,20 @@ static bool getDownFloor(uint16 *flr) { /** * Draws the map */ -void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 flr, bool fadeout, bool fadein) { +void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 floorNum, bool fadeOut, bool fadeIn) { _event->mouseHide(); - if (fadeout) + if (fadeOut) _graphics->fade(false, 0); _graphics->setAPen(0); _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1); - Map->drawImage(0, 0); + _imgMap->drawImage(0, 0); drawGadgetList(&_mapGadgetList); - for (uint16 i = 1; i <= MaxRooms; i++) { - if ((Maps[i]._pageNumber == flr) && _roomsFound->in(i) && Maps[i]._x) { + for (uint16 i = 1; i <= _maxRooms; i++) { + if ((_maps[i]._pageNumber == floorNum) && _roomsFound->in(i) && _maps[i]._x) { drawRoomMap(i, (bool)(i == curRoom)); _music->updateMusic(); } @@ -375,11 +397,10 @@ void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 flr, bool fadeout, // Makes sure the X is drawn in corridors // NOTE: this here on purpose just in case there's some weird // condition, like the surreal maze where there are no rooms - if ((Maps[curRoom]._pageNumber == flr) && _roomsFound->in(curRoom) && Maps[curRoom]._x) + if ((_maps[curRoom]._pageNumber == floorNum) && _roomsFound->in(curRoom) && _maps[curRoom]._x) drawRoomMap(curRoom, true); - uint16 tempfloor = flr; - + uint16 tempfloor = floorNum; bool noOverlay = getUpFloor(&tempfloor); Gadget *upGadget = _event->getGadget(1); @@ -390,7 +411,7 @@ void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 flr, bool fadeout, else disableGadget(upGadget, 12); - tempfloor = flr; + tempfloor = floorNum; noOverlay = getDownFloor(&tempfloor); if (noOverlay) @@ -398,35 +419,33 @@ void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 flr, bool fadeout, else disableGadget(downGadget, 12); - char *sptr; - // Labyrinth specific code - if (flr == kFloorLower) { + if (floorNum == kFloorLower) { if (onFloor(kFloorSurMaze)) - Maze->drawImage(_utils->mapScaleX(538), _utils->mapScaleY(277)); - } else if (flr == kFloorMiddle) { + _imgMaze->drawImage(_utils->mapScaleX(538), _utils->mapScaleY(277)); + } else if (floorNum == kFloorMiddle) { if (onFloor(kFloorCarnival)) - Maze->drawImage(_utils->mapScaleX(358), _utils->mapScaleY(72)); + _imgMaze->drawImage(_utils->mapScaleX(358), _utils->mapScaleY(72)); if (onFloor(kFloorMedMaze)) - Maze->drawImage(_utils->mapScaleX(557), _utils->mapScaleY(325)); - } else if (flr == kFloorUpper) { + _imgMaze->drawImage(_utils->mapScaleX(557), _utils->mapScaleY(325)); + } else if (floorNum == kFloorUpper) { if (onFloor(kFloorHedgeMaze)) - HugeMaze->drawImage(_utils->mapScaleX(524), _utils->mapScaleY(97)); - } else if (flr == kFloorSurMaze) { - sptr = (char *)_resource->getStaticText(kTextSurmazeMessage).c_str(); + _imgHugeMaze->drawImage(_utils->mapScaleX(524), _utils->mapScaleY(97)); + } else if (floorNum == kFloorSurMaze) { + char *sptr = (char *)_resource->getStaticText(kTextSurmazeMessage).c_str(); _graphics->flowText(_msgFont, 0, 7, 0, true, true, true, true, _utils->mapScaleX(360), 0, _utils->mapScaleX(660), _utils->mapScaleY(450), sptr); } - if (flr >= kFloorLower && flr <= kFloorCarnival) { - sptr = (char *)_resource->getStaticText(flr - 1).c_str(); + if ((floorNum >= kFloorLower) && (floorNum <= kFloorCarnival)) { + char *sptr = (char *)_resource->getStaticText(floorNum - 1).c_str(); _graphics->flowTextScaled(_msgFont, 0, 5, 3, true, true, true, true, 14, 75, 134, 97, sptr); } - if ((sptr = _rooms[curMsg]._roomMsg)) - _graphics->flowTextScaled(_msgFont, 0, 5, 3, true, true, true, true, 14, 148, 134, 186, sptr); + if (_rooms[curMsg]._roomMsg) + _graphics->flowTextScaled(_msgFont, 0, 5, 3, true, true, true, true, 14, 148, 134, 186, _rooms[curMsg]._roomMsg); - if (fadein) + if (fadeIn) _graphics->fade(true, 0); _event->mouseShow(); @@ -437,16 +456,15 @@ void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 flr, bool fadeout, */ void LabEngine::processMap(uint16 curRoom) { uint32 place = 1; - - uint16 curMsg = curRoom; - uint16 curFloor = Maps[curRoom]._pageNumber; + uint16 curMsg = curRoom; + uint16 curFloor = _maps[curRoom]._pageNumber; while (1) { // Make sure we check the music at least after every message _music->updateMusic(); IntuiMessage *msg = getMsg(); - if (msg == NULL) { + if (!msg) { _music->updateMusic(); byte newcolor[3]; @@ -551,10 +569,10 @@ void LabEngine::processMap(uint16 curRoom) { uint16 oldMsg = curMsg; Common::Rect curCoords; - for (uint16 i = 1; i <= MaxRooms; i++) { + for (uint16 i = 1; i <= _maxRooms; i++) { curCoords = roomCoords(i); - if ((Maps[i]._pageNumber == curFloor) + if ((_maps[i]._pageNumber == curFloor) && _roomsFound->in(i) && curCoords.contains(Common::Point(mouseX, mouseY))) { curMsg = i; } @@ -571,7 +589,7 @@ void LabEngine::processMap(uint16 curRoom) { _graphics->rectFillScaled(13, 148, 135, 186); _graphics->flowTextScaled(_msgFont, 0, 5, 3, true, true, true, true, 14, 148, 134, 186, sptr); - if (Maps[oldMsg]._pageNumber == curFloor) + if (_maps[oldMsg]._pageNumber == curFloor) drawRoomMap(oldMsg, (bool)(oldMsg == curRoom)); curCoords = roomCoords(curMsg); @@ -580,7 +598,7 @@ void LabEngine::processMap(uint16 curRoom) { int top, bottom; top = bottom = (curCoords.top + curCoords.bottom) / 2; - if ((curMsg != curRoom) && (Maps[curMsg]._pageNumber == curFloor)) { + if ((curMsg != curRoom) && (_maps[curMsg]._pageNumber == curFloor)) { _graphics->setAPen(1); _graphics->rectFill(left, top, right, bottom); } @@ -614,20 +632,20 @@ void LabEngine::doMap(uint16 curRoom) { _graphics->blackAllScreen(); if (_direction == NORTH) - XMark = MapNorth; + _imgXMark = _imgMapNorth; else if (_direction == SOUTH) - XMark = MapSouth; + _imgXMark = _imgMapSouth; else if (_direction == EAST) - XMark = MapEast; + _imgXMark = _imgMapEast; else if (_direction == WEST) - XMark = MapWest; + _imgXMark = _imgMapWest; _event->attachGadgetList(&_mapGadgetList); - drawMap(curRoom, curRoom, Maps[curRoom]._pageNumber, false, true); + drawMap(curRoom, curRoom, _maps[curRoom]._pageNumber, false, true); _event->mouseShow(); _graphics->screenUpdate(); processMap(curRoom); - _event->attachGadgetList(NULL); + _event->attachGadgetList(nullptr); _graphics->fade(false, 0); _graphics->blackAllScreen(); _event->mouseHide(); -- cgit v1.2.3 From 9f7ad4b5f25e3c9d6437f0ac0e5e26dba4cab330 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 10 Dec 2015 12:39:32 +0200 Subject: LAB: Fix crash when closing the map --- engines/lab/map.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index c6b2277280..b484a1e323 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -106,7 +106,6 @@ void LabEngine::loadMapData() { void LabEngine::freeMapData() { freeButtonList(&_mapGadgetList); - delete[] _maps; delete _imgMap; delete _imgRoom; delete _imgUpArrowRoom; @@ -121,8 +120,8 @@ void LabEngine::freeMapData() { delete _imgMapEast; delete _imgMapSouth; delete _imgMapWest; - delete _imgXMark; - delete _maps; + // _imgXMark is a pointer to one of the four buffers above + delete[] _maps; _imgMap = nullptr; _imgRoom = nullptr; -- cgit v1.2.3 From 7d4e71d29e9b97f3991b3264c509369ec8a91122 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 12 Dec 2015 18:24:47 +0200 Subject: LAB: Change the map floor showing code, when changing floors This greatly simplifies the code that shows a floor when an arrow is pressed. Also, it changes the behavior of the arrows to show all of the visited floors, instead of a specific subset. I believe that this makes the map better, more usable and less confusing than the original --- engines/lab/map.cpp | 101 ++++++++++++++++++++-------------------------------- 1 file changed, 38 insertions(+), 63 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index b484a1e323..db995504a2 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -317,7 +317,7 @@ void LabEngine::drawRoomMap(uint16 curRoom, bool drawMarkFl) { /** * Checks if a floor has been visited. */ -bool LabEngine::onFloor(uint16 floorNum) { +bool LabEngine::floorVisited(uint16 floorNum) { for (uint16 i = 1; i <= _maxRooms; i++) { if ((_maps[i]._pageNumber == floorNum) && _roomsFound->in(i) && _maps[i]._x) return true; @@ -327,48 +327,33 @@ bool LabEngine::onFloor(uint16 floorNum) { } /** - * Figures out which floor, if any, should be gone to if the up arrow is hit + * Returns the floor to show when the up arrow is pressed + * Note: The original did not show all the visited floors, but we do */ -bool LabEngine::getUpFloor(uint16 *floorNum) { - do { - if (*floorNum < kFloorUpper) - (*floorNum)++; - else { - *floorNum = kFloorCarnival + 1; - return false; - } - } while ((!onFloor(*floorNum)) && (*floorNum <= kFloorCarnival)); +uint16 LabEngine::getUpperFloor(uint16 floorNum) { + if (floorNum == kFloorCarnival || floorNum == kFloorNone) + return kFloorNone; + + for (uint16 i = floorNum; i < kFloorCarnival; i++) + if (floorVisited(i + 1)) + return i + 1; - return true; + return kFloorNone; } /** - * Figures out which floor, if any, should be gone to if the down arrow is - * hit. + * Returns the floor to show when the down arrow is pressed + * Note: The original did not show all the visited floors, but we do */ -bool LabEngine::getDownFloor(uint16 *floorNum) { - do { - if ((*floorNum == kFloorLower) || (*floorNum == kFloorNone)) { - *floorNum = kFloorNone; - return false; - } else if (*floorNum > kFloorUpper) { - // Labyrinth specific code - if (*floorNum == kFloorHedgeMaze) - *floorNum = kFloorUpper; - else if ((*floorNum == kFloorCarnival) || (*floorNum == kFloorMedMaze)) - *floorNum = kFloorMiddle; - else if (*floorNum == kFloorSurMaze) - *floorNum = kFloorLower; - else { - *floorNum = kFloorNone; - return false; - } - } else - (*floorNum)--; +uint16 LabEngine::getLowerFloor(uint16 floorNum) { + if (floorNum == kFloorLower || floorNum == kFloorNone) + return kFloorNone; - } while ((!onFloor(*floorNum)) && (*floorNum != kFloorNone)); + for (uint16 i = floorNum; i > kFloorLower; i--) + if (floorVisited(i - 1)) + return i - 1; - return true; + return kFloorNone; } /** @@ -399,37 +384,31 @@ void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 floorNum, bool fad if ((_maps[curRoom]._pageNumber == floorNum) && _roomsFound->in(curRoom) && _maps[curRoom]._x) drawRoomMap(curRoom, true); - uint16 tempfloor = floorNum; - bool noOverlay = getUpFloor(&tempfloor); - Gadget *upGadget = _event->getGadget(1); Gadget *downGadget = _event->getGadget(2); - if (noOverlay) + if (getUpperFloor(floorNum) != kFloorNone) enableGadget(upGadget); else disableGadget(upGadget, 12); - tempfloor = floorNum; - noOverlay = getDownFloor(&tempfloor); - - if (noOverlay) + if (getLowerFloor(floorNum) != kFloorNone) enableGadget(downGadget); else disableGadget(downGadget, 12); // Labyrinth specific code if (floorNum == kFloorLower) { - if (onFloor(kFloorSurMaze)) + if (floorVisited(kFloorSurMaze)) _imgMaze->drawImage(_utils->mapScaleX(538), _utils->mapScaleY(277)); } else if (floorNum == kFloorMiddle) { - if (onFloor(kFloorCarnival)) + if (floorVisited(kFloorCarnival)) _imgMaze->drawImage(_utils->mapScaleX(358), _utils->mapScaleY(72)); - if (onFloor(kFloorMedMaze)) + if (floorVisited(kFloorMedMaze)) _imgMaze->drawImage(_utils->mapScaleX(557), _utils->mapScaleY(325)); } else if (floorNum == kFloorUpper) { - if (onFloor(kFloorHedgeMaze)) + if (floorVisited(kFloorHedgeMaze)) _imgHugeMaze->drawImage(_utils->mapScaleX(524), _utils->mapScaleY(97)); } else if (floorNum == kFloorSurMaze) { char *sptr = (char *)_resource->getStaticText(kTextSurmazeMessage).c_str(); @@ -510,31 +489,27 @@ void LabEngine::processMap(uint16 curRoom) { return; } else if (gadgetID == 1) { // Up arrow - uint16 oldFloor = curFloor; - bool drawmap = getUpFloor(&curFloor); - - if (drawmap) { + uint16 upperFloor = getUpperFloor(curFloor); + if (upperFloor != kFloorNone) { + curFloor = upperFloor; _graphics->fade(false, 0); drawMap(curRoom, curMsg, curFloor, false, false); _graphics->fade(true, 0); - } else - curFloor = oldFloor; + } } else if (gadgetID == 2) { // Down arrow - uint16 oldFloor = curFloor; - bool drawmap = getDownFloor(&curFloor); - - if (drawmap) { + uint16 lowerFloor = getLowerFloor(curFloor); + if (lowerFloor != kFloorNone) { + curFloor = lowerFloor; _graphics->fade(false, 0); drawMap(curRoom, curMsg, curFloor, false, false); _graphics->fade(true, 0); - } else - curFloor = oldFloor; + } } } else if ((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & qualifier)) { if ((curFloor == kFloorLower) && (mouseX >= _utils->mapScaleX(538)) && (mouseY >= _utils->mapScaleY(277)) && (mouseX <= _utils->mapScaleX(633)) && (mouseY <= _utils->mapScaleY(352)) - && onFloor(kFloorSurMaze)) { + && floorVisited(kFloorSurMaze)) { curFloor = kFloorSurMaze; _graphics->fade(false, 0); @@ -542,7 +517,7 @@ void LabEngine::processMap(uint16 curRoom) { _graphics->fade(true, 0); } else if ((curFloor == kFloorMiddle) && (mouseX >= _utils->mapScaleX(358)) && (mouseY >= _utils->mapScaleY(71)) && (mouseX <= _utils->mapScaleX(452)) && (mouseY <= _utils->mapScaleY(147)) - && onFloor(kFloorCarnival)) { + && floorVisited(kFloorCarnival)) { curFloor = kFloorCarnival; _graphics->fade(false, 0); @@ -550,7 +525,7 @@ void LabEngine::processMap(uint16 curRoom) { _graphics->fade(true, 0); } else if ((curFloor == kFloorMiddle) && (mouseX >= _utils->mapScaleX(557)) && (mouseY >= _utils->mapScaleY(325)) && (mouseX <= _utils->mapScaleX(653)) && (mouseY <= _utils->mapScaleY(401)) - && onFloor(kFloorMedMaze)) { + && floorVisited(kFloorMedMaze)) { curFloor = kFloorMedMaze; _graphics->fade(false, 0); @@ -558,7 +533,7 @@ void LabEngine::processMap(uint16 curRoom) { _graphics->fade(true, 0); } else if ((curFloor == kFloorUpper) && (mouseX >= _utils->mapScaleX(524)) && (mouseY >= _utils->mapScaleY(97)) && (mouseX <= _utils->mapScaleX(645)) && (mouseY <= _utils->mapScaleY(207)) - && onFloor(kFloorHedgeMaze)) { + && floorVisited(kFloorHedgeMaze)) { curFloor = kFloorHedgeMaze; _graphics->fade(false, 0); -- cgit v1.2.3 From 47368c157ebf870248a61de4b81e181fa7713671 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 13 Dec 2015 13:22:54 +0100 Subject: LAB: Review Music declaration, some refactoring and renaming --- engines/lab/map.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index db995504a2..5d978b72fe 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -87,7 +87,7 @@ void LabEngine::loadMapData() { Common::File *mapFile = _resource->openDataFile("Lab:Maps", MKTAG('M', 'A', 'P', '0')); _music->updateMusic(); - if (!_music->_doNotFilestopSoundEffect) + if (!_music->_unstoppableSoundEffect) _music->stopSoundEffect(); _maxRooms = mapFile->readUint16LE(); -- 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/map.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 5d978b72fe..c76f3cb357 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -79,9 +79,9 @@ void LabEngine::loadMapData() { _imgPath = new Image(mapImages); _imgBridge = new Image(mapImages); - _mapGadgetList.push_back(createButton( 8, _utils->vgaScaleY(105), 0, VKEY_LTARROW, new Image(mapImages), new Image(mapImages))); // back - _mapGadgetList.push_back(createButton( 55, _utils->vgaScaleY(105), 1, VKEY_UPARROW, new Image(mapImages), new Image(mapImages))); // up - _mapGadgetList.push_back(createButton(101, _utils->vgaScaleY(105), 2, VKEY_DNARROW, new Image(mapImages), new Image(mapImages))); // down + _mapGadgetList.push_back(_event->createButton( 8, _utils->vgaScaleY(105), 0, VKEY_LTARROW, new Image(mapImages), new Image(mapImages))); // back + _mapGadgetList.push_back(_event->createButton( 55, _utils->vgaScaleY(105), 1, VKEY_UPARROW, new Image(mapImages), new Image(mapImages))); // up + _mapGadgetList.push_back(_event->createButton(101, _utils->vgaScaleY(105), 2, VKEY_DNARROW, new Image(mapImages), new Image(mapImages))); // down delete mapImages; @@ -104,7 +104,7 @@ void LabEngine::loadMapData() { } void LabEngine::freeMapData() { - freeButtonList(&_mapGadgetList); + _event->freeButtonList(&_mapGadgetList); delete _imgMap; delete _imgRoom; @@ -369,7 +369,7 @@ void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 floorNum, bool fad _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1); _imgMap->drawImage(0, 0); - drawGadgetList(&_mapGadgetList); + _event->drawGadgetList(&_mapGadgetList); for (uint16 i = 1; i <= _maxRooms; i++) { if ((_maps[i]._pageNumber == floorNum) && _roomsFound->in(i) && _maps[i]._x) { @@ -388,14 +388,14 @@ void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 floorNum, bool fad Gadget *downGadget = _event->getGadget(2); if (getUpperFloor(floorNum) != kFloorNone) - enableGadget(upGadget); + _event->enableGadget(upGadget); else - disableGadget(upGadget, 12); + _event->disableGadget(upGadget, 12); if (getLowerFloor(floorNum) != kFloorNone) - enableGadget(downGadget); + _event->enableGadget(downGadget); else - disableGadget(downGadget, 12); + _event->disableGadget(downGadget, 12); // Labyrinth specific code if (floorNum == kFloorLower) { -- 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/map.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index c76f3cb357..d0dce93388 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -33,7 +33,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" @@ -480,7 +479,7 @@ void LabEngine::processMap(uint16 curRoom) { uint16 mouseX = msg->_mouseX; uint16 mouseY = msg->_mouseY; - if (((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & qualifier)) || ((msgClass == RAWKEY) && (msgCode == 27))) + if (((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RIGHTBUTTON & qualifier)) || ((msgClass == RAWKEY) && (msgCode == 27))) return; if (msgClass == GADGETUP) { -- 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/map.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index d0dce93388..316334f70e 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -439,7 +439,7 @@ void LabEngine::processMap(uint16 curRoom) { while (1) { // Make sure we check the music at least after every message _music->updateMusic(); - IntuiMessage *msg = getMsg(); + IntuiMessage *msg = _event->getMsg(); if (!msg) { _music->updateMusic(); -- cgit v1.2.3 From 40b16afcab183189c32ee697e6e027e734d72542 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sun, 13 Dec 2015 17:47:16 +0200 Subject: LAB: Get rid of _unstoppableSoundEffect _loopSoundEffect is used for the exact same purpose --- engines/lab/map.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 316334f70e..179bba5581 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -86,7 +86,7 @@ void LabEngine::loadMapData() { Common::File *mapFile = _resource->openDataFile("Lab:Maps", MKTAG('M', 'A', 'P', '0')); _music->updateMusic(); - if (!_music->_unstoppableSoundEffect) + if (!_music->_loopSoundEffect) _music->stopSoundEffect(); _maxRooms = mapFile->readUint16LE(); -- 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/map.cpp | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 179bba5581..2258775c79 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -78,9 +78,9 @@ void LabEngine::loadMapData() { _imgPath = new Image(mapImages); _imgBridge = new Image(mapImages); - _mapGadgetList.push_back(_event->createButton( 8, _utils->vgaScaleY(105), 0, VKEY_LTARROW, new Image(mapImages), new Image(mapImages))); // back - _mapGadgetList.push_back(_event->createButton( 55, _utils->vgaScaleY(105), 1, VKEY_UPARROW, new Image(mapImages), new Image(mapImages))); // up - _mapGadgetList.push_back(_event->createButton(101, _utils->vgaScaleY(105), 2, VKEY_DNARROW, new Image(mapImages), new Image(mapImages))); // down + _mapButtonList.push_back(_event->createButton( 8, _utils->vgaScaleY(105), 0, VKEY_LTARROW, new Image(mapImages), new Image(mapImages))); // back + _mapButtonList.push_back(_event->createButton( 55, _utils->vgaScaleY(105), 1, VKEY_UPARROW, new Image(mapImages), new Image(mapImages))); // up + _mapButtonList.push_back(_event->createButton(101, _utils->vgaScaleY(105), 2, VKEY_DNARROW, new Image(mapImages), new Image(mapImages))); // down delete mapImages; @@ -103,7 +103,7 @@ void LabEngine::loadMapData() { } void LabEngine::freeMapData() { - _event->freeButtonList(&_mapGadgetList); + _event->freeButtonList(&_mapButtonList); delete _imgMap; delete _imgRoom; @@ -368,7 +368,7 @@ void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 floorNum, bool fad _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1); _imgMap->drawImage(0, 0); - _event->drawGadgetList(&_mapGadgetList); + _event->drawButtonList(&_mapButtonList); for (uint16 i = 1; i <= _maxRooms; i++) { if ((_maps[i]._pageNumber == floorNum) && _roomsFound->in(i) && _maps[i]._x) { @@ -383,18 +383,18 @@ void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 floorNum, bool fad if ((_maps[curRoom]._pageNumber == floorNum) && _roomsFound->in(curRoom) && _maps[curRoom]._x) drawRoomMap(curRoom, true); - Gadget *upGadget = _event->getGadget(1); - Gadget *downGadget = _event->getGadget(2); + Button *upButton = _event->getButton(1); + Button *downButton = _event->getButton(2); if (getUpperFloor(floorNum) != kFloorNone) - _event->enableGadget(upGadget); + _event->enableButton(upButton); else - _event->disableGadget(upGadget, 12); + _event->disableButton(upButton, 12); if (getLowerFloor(floorNum) != kFloorNone) - _event->enableGadget(downGadget); + _event->enableButton(downButton); else - _event->disableGadget(downGadget, 12); + _event->disableButton(downButton, 12); // Labyrinth specific code if (floorNum == kFloorLower) { @@ -474,7 +474,7 @@ void LabEngine::processMap(uint16 curRoom) { } else { uint32 msgClass = msg->_msgClass; uint16 msgCode = msg->_code; - uint16 gadgetID = msg->_gadgetID; + uint16 buttonID = msg->_buttonID; uint16 qualifier = msg->_qualifier; uint16 mouseX = msg->_mouseX; uint16 mouseY = msg->_mouseY; @@ -482,11 +482,11 @@ void LabEngine::processMap(uint16 curRoom) { if (((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RIGHTBUTTON & qualifier)) || ((msgClass == RAWKEY) && (msgCode == 27))) return; - if (msgClass == GADGETUP) { - if (gadgetID == 0) { + if (msgClass == BUTTONUP) { + if (buttonID == 0) { // Quit menu button return; - } else if (gadgetID == 1) { + } else if (buttonID == 1) { // Up arrow uint16 upperFloor = getUpperFloor(curFloor); if (upperFloor != kFloorNone) { @@ -495,7 +495,7 @@ void LabEngine::processMap(uint16 curRoom) { drawMap(curRoom, curMsg, curFloor, false, false); _graphics->fade(true, 0); } - } else if (gadgetID == 2) { + } else if (buttonID == 2) { // Down arrow uint16 lowerFloor = getLowerFloor(curFloor); if (lowerFloor != kFloorNone) { @@ -613,12 +613,12 @@ void LabEngine::doMap(uint16 curRoom) { else if (_direction == WEST) _imgXMark = _imgMapWest; - _event->attachGadgetList(&_mapGadgetList); + _event->attachButtonList(&_mapButtonList); drawMap(curRoom, curRoom, _maps[curRoom]._pageNumber, false, true); _event->mouseShow(); _graphics->screenUpdate(); processMap(curRoom); - _event->attachGadgetList(nullptr); + _event->attachButtonList(nullptr); _graphics->fade(false, 0); _graphics->blackAllScreen(); _event->mouseHide(); -- cgit v1.2.3 From 99e09b2ca2615d9f5bbb682eb17920c8205af405 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sun, 13 Dec 2015 20:29:58 +0200 Subject: LAB: Merge the different X image maps --- engines/lab/map.cpp | 50 +++++++++++++++++--------------------------------- 1 file changed, 17 insertions(+), 33 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 2258775c79..1861ccc6a0 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -71,10 +71,10 @@ void LabEngine::loadMapData() { _imgMaze = new Image(mapImages); _imgHugeMaze = new Image(mapImages); - _imgMapNorth = new Image(mapImages); - _imgMapEast = new Image(mapImages); - _imgMapSouth = new Image(mapImages); - _imgMapWest = new Image(mapImages); + _imgMapX[NORTH] = new Image(mapImages); + _imgMapX[EAST] = new Image(mapImages); + _imgMapX[SOUTH] = new Image(mapImages); + _imgMapX[WEST] = new Image(mapImages); _imgPath = new Image(mapImages); _imgBridge = new Image(mapImages); @@ -115,11 +115,8 @@ void LabEngine::freeMapData() { delete _imgMaze; delete _imgHugeMaze; delete _imgPath; - delete _imgMapNorth; - delete _imgMapEast; - delete _imgMapSouth; - delete _imgMapWest; - // _imgXMark is a pointer to one of the four buffers above + for (int i = 0; i < 4; i++) + delete _imgMapX[i]; delete[] _maps; _imgMap = nullptr; @@ -132,11 +129,8 @@ void LabEngine::freeMapData() { _imgMaze = nullptr; _imgHugeMaze = nullptr; _imgPath = nullptr; - _imgMapNorth = nullptr; - _imgMapEast = nullptr; - _imgMapSouth = nullptr; - _imgMapWest = nullptr; - _imgXMark = nullptr; + for (int i = 0; i < 4; i++) + _imgMapX[i] = nullptr; _maps = nullptr; } @@ -216,16 +210,16 @@ void LabEngine::drawRoomMap(uint16 curRoom, bool drawMarkFl) { if (WESTDOOR & flags) _imgPath->drawImage(x - _imgPath->_width, y + offset); - drawX = x + (_imgRoom->_width - _imgXMark->_width) / 2; - drawY = y + (_imgRoom->_height - _imgXMark->_height) / 2; + drawX = x + (_imgRoom->_width - _imgMapX[_direction]->_width) / 2; + drawY = y + (_imgRoom->_height - _imgMapX[_direction]->_height) / 2; break; case BRIDGEROOM: _imgBridge->drawImage(x, y); - drawX = x + (_imgBridge->_width - _imgXMark->_width) / 2; - drawY = y + (_imgBridge->_height - _imgXMark->_height) / 2; + drawX = x + (_imgBridge->_width - _imgMapX[_direction]->_width) / 2; + drawY = y + (_imgBridge->_height - _imgMapX[_direction]->_height) / 2; break; @@ -262,8 +256,8 @@ void LabEngine::drawRoomMap(uint16 curRoom, bool drawMarkFl) { if (WESTMDOOR & flags) _imgPath->drawImage(x - _imgPath->_width, y - offset - _imgPath->_height + _imgVRoom->_height); - drawX = x + (_imgVRoom->_width - _imgXMark->_width) / 2; - drawY = y + (_imgVRoom->_height - _imgXMark->_height) / 2; + drawX = x + (_imgVRoom->_width - _imgMapX[_direction]->_width) / 2; + drawY = y + (_imgVRoom->_height - _imgMapX[_direction]->_height) / 2; break; @@ -300,8 +294,8 @@ void LabEngine::drawRoomMap(uint16 curRoom, bool drawMarkFl) { if (WESTDOOR & flags) _imgPath->drawImage(x - _imgPath->_width, y + offset); - drawX = x + (_imgHRoom->_width - _imgXMark->_width) / 2; - drawY = y + (_imgHRoom->_height - _imgXMark->_height) / 2; + drawX = x + (_imgHRoom->_width - _imgMapX[_direction]->_width) / 2; + drawY = y + (_imgHRoom->_height - _imgMapX[_direction]->_height) / 2; break; @@ -310,7 +304,7 @@ void LabEngine::drawRoomMap(uint16 curRoom, bool drawMarkFl) { } if (drawMarkFl) - _imgXMark->drawImage(drawX, drawY); + _imgMapX[_direction]->drawImage(drawX, drawY); } /** @@ -603,16 +597,6 @@ void LabEngine::doMap(uint16 curRoom) { _music->updateMusic(); loadMapData(); _graphics->blackAllScreen(); - - if (_direction == NORTH) - _imgXMark = _imgMapNorth; - else if (_direction == SOUTH) - _imgXMark = _imgMapSouth; - else if (_direction == EAST) - _imgXMark = _imgMapEast; - else if (_direction == WEST) - _imgXMark = _imgMapWest; - _event->attachButtonList(&_mapButtonList); drawMap(curRoom, curRoom, _maps[curRoom]._pageNumber, false, true); _event->mouseShow(); -- 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/map.cpp | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 1861ccc6a0..f8207ad844 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -62,25 +62,25 @@ enum MapFloor { void LabEngine::loadMapData() { Common::File *mapImages = _resource->openDataFile("P:MapImage"); - _imgMap = new Image(mapImages); - _imgRoom = new Image(mapImages); - _imgUpArrowRoom = new Image(mapImages); - _imgDownArrowRoom = new Image(mapImages); - _imgHRoom = new Image(mapImages); - _imgVRoom = new Image(mapImages); - _imgMaze = new Image(mapImages); - _imgHugeMaze = new Image(mapImages); - - _imgMapX[NORTH] = new Image(mapImages); - _imgMapX[EAST] = new Image(mapImages); - _imgMapX[SOUTH] = new Image(mapImages); - _imgMapX[WEST] = new Image(mapImages); - _imgPath = new Image(mapImages); - _imgBridge = new Image(mapImages); - - _mapButtonList.push_back(_event->createButton( 8, _utils->vgaScaleY(105), 0, VKEY_LTARROW, new Image(mapImages), new Image(mapImages))); // back - _mapButtonList.push_back(_event->createButton( 55, _utils->vgaScaleY(105), 1, VKEY_UPARROW, new Image(mapImages), new Image(mapImages))); // up - _mapButtonList.push_back(_event->createButton(101, _utils->vgaScaleY(105), 2, VKEY_DNARROW, new Image(mapImages), new Image(mapImages))); // down + _imgMap = new Image(mapImages, this); + _imgRoom = new Image(mapImages, this); + _imgUpArrowRoom = new Image(mapImages, this); + _imgDownArrowRoom = new Image(mapImages, this); + _imgHRoom = new Image(mapImages, this); + _imgVRoom = new Image(mapImages, this); + _imgMaze = new Image(mapImages, this); + _imgHugeMaze = new Image(mapImages, this); + + _imgMapX[NORTH] = new Image(mapImages, this); + _imgMapX[EAST] = new Image(mapImages, this); + _imgMapX[SOUTH] = new Image(mapImages, this); + _imgMapX[WEST] = new Image(mapImages, this); + _imgPath = new Image(mapImages, this); + _imgBridge = new Image(mapImages, this); + + _mapButtonList.push_back(_event->createButton( 8, _utils->vgaScaleY(105), 0, VKEY_LTARROW, new Image(mapImages, this), new Image(mapImages, this))); // back + _mapButtonList.push_back(_event->createButton( 55, _utils->vgaScaleY(105), 1, VKEY_UPARROW, new Image(mapImages, this), new Image(mapImages, this))); // up + _mapButtonList.push_back(_event->createButton(101, _utils->vgaScaleY(105), 2, VKEY_DNARROW, new Image(mapImages, this), new Image(mapImages, this))); // down delete mapImages; -- 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/map.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index f8207ad844..cb222ba989 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -592,7 +592,7 @@ void LabEngine::doMap(uint16 curRoom) { 0x0AAA, 0x0ED0, 0x0EEE, 0x0694 }; - _graphics->FadePalette = amigaMapPalette; + _graphics->_fadePalette = amigaMapPalette; _music->updateMusic(); loadMapData(); -- 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/map.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index cb222ba989..a248544938 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -358,7 +358,7 @@ void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 floorNum, bool fad if (fadeOut) _graphics->fade(false, 0); - _graphics->setAPen(0); + _graphics->setPen(0); _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1); _imgMap->drawImage(0, 0); @@ -552,7 +552,7 @@ void LabEngine::processMap(uint16 curRoom) { char *sptr; if ((sptr = _rooms[curMsg]._roomMsg)) { _event->mouseHide(); - _graphics->setAPen(3); + _graphics->setPen(3); _graphics->rectFillScaled(13, 148, 135, 186); _graphics->flowTextScaled(_msgFont, 0, 5, 3, true, true, true, true, 14, 148, 134, 186, sptr); @@ -566,7 +566,7 @@ void LabEngine::processMap(uint16 curRoom) { top = bottom = (curCoords.top + curCoords.bottom) / 2; if ((curMsg != curRoom) && (_maps[curMsg]._pageNumber == curFloor)) { - _graphics->setAPen(1); + _graphics->setPen(1); _graphics->rectFill(left, top, right, bottom); } @@ -606,7 +606,7 @@ void LabEngine::doMap(uint16 curRoom) { _graphics->fade(false, 0); _graphics->blackAllScreen(); _event->mouseHide(); - _graphics->setAPen(0); + _graphics->setPen(0); _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1); freeMapData(); _graphics->blackAllScreen(); -- 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/map.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index a248544938..927bfd037a 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -426,7 +426,7 @@ void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 floorNum, bool fad * Processes the map. */ void LabEngine::processMap(uint16 curRoom) { - uint32 place = 1; + byte place = 1; uint16 curMsg = curRoom; uint16 curFloor = _maps[curRoom]._pageNumber; @@ -434,6 +434,10 @@ void LabEngine::processMap(uint16 curRoom) { // 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) { _music->updateMusic(); -- cgit v1.2.3 From 5ed11d721c170a762cea775580fef5eef175c53a Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 16 Dec 2015 17:03:42 +0100 Subject: LAB: Verify the appropriate use of parenthesis in if statements --- engines/lab/map.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 927bfd037a..1222e1ad8c 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -324,7 +324,7 @@ bool LabEngine::floorVisited(uint16 floorNum) { * Note: The original did not show all the visited floors, but we do */ uint16 LabEngine::getUpperFloor(uint16 floorNum) { - if (floorNum == kFloorCarnival || floorNum == kFloorNone) + if ((floorNum == kFloorCarnival) || (floorNum == kFloorNone)) return kFloorNone; for (uint16 i = floorNum; i < kFloorCarnival; i++) @@ -339,7 +339,7 @@ uint16 LabEngine::getUpperFloor(uint16 floorNum) { * Note: The original did not show all the visited floors, but we do */ uint16 LabEngine::getLowerFloor(uint16 floorNum) { - if (floorNum == kFloorLower || floorNum == kFloorNone) + if ((floorNum == kFloorLower) || (floorNum == kFloorNone)) return kFloorNone; for (uint16 i = floorNum; i > kFloorLower; i--) -- 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/map.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 1222e1ad8c..09d89883e1 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -472,7 +472,7 @@ void LabEngine::processMap(uint16 curRoom) { } else { uint32 msgClass = msg->_msgClass; uint16 msgCode = msg->_code; - uint16 buttonID = msg->_buttonID; + uint16 buttonId = msg->_buttonId; uint16 qualifier = msg->_qualifier; uint16 mouseX = msg->_mouseX; uint16 mouseY = msg->_mouseY; @@ -481,10 +481,10 @@ void LabEngine::processMap(uint16 curRoom) { return; if (msgClass == BUTTONUP) { - if (buttonID == 0) { + if (buttonId == 0) { // Quit menu button return; - } else if (buttonID == 1) { + } else if (buttonId == 1) { // Up arrow uint16 upperFloor = getUpperFloor(curFloor); if (upperFloor != kFloorNone) { @@ -493,7 +493,7 @@ void LabEngine::processMap(uint16 curRoom) { drawMap(curRoom, curMsg, curFloor, false, false); _graphics->fade(true, 0); } - } else if (buttonID == 2) { + } else if (buttonId == 2) { // Down arrow uint16 lowerFloor = getLowerFloor(curFloor); if (lowerFloor != kFloorNone) { -- 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/map.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 09d89883e1..63ea35398d 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -477,7 +477,7 @@ void LabEngine::processMap(uint16 curRoom) { uint16 mouseX = msg->_mouseX; uint16 mouseY = msg->_mouseY; - if (((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RIGHTBUTTON & qualifier)) || ((msgClass == RAWKEY) && (msgCode == 27))) + if (((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RIGHTBUTTON & qualifier)) || ((msgClass == RAWKEY) && (msgCode == Common::KEYCODE_ESCAPE))) return; if (msgClass == BUTTONUP) { -- 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/map.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 63ea35398d..cbd664e27e 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -405,16 +405,17 @@ void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 floorNum, bool fad _imgHugeMaze->drawImage(_utils->mapScaleX(524), _utils->mapScaleY(97)); } else if (floorNum == kFloorSurMaze) { char *sptr = (char *)_resource->getStaticText(kTextSurmazeMessage).c_str(); - _graphics->flowText(_msgFont, 0, 7, 0, true, true, true, true, _utils->mapScaleX(360), 0, _utils->mapScaleX(660), _utils->mapScaleY(450), sptr); + Common::Rect textRect = Common::Rect(_utils->mapScaleX(360), 0, _utils->mapScaleX(660), _utils->mapScaleY(450)); + _graphics->flowText(_msgFont, 0, 7, 0, true, true, true, true, textRect, sptr); } if ((floorNum >= kFloorLower) && (floorNum <= kFloorCarnival)) { char *sptr = (char *)_resource->getStaticText(floorNum - 1).c_str(); - _graphics->flowTextScaled(_msgFont, 0, 5, 3, true, true, true, true, 14, 75, 134, 97, sptr); + _graphics->flowTextScaled(_msgFont, 0, 5, 3, true, true, true, true, Common::Rect(14, 75, 134, 97), sptr); } if (_rooms[curMsg]._roomMsg) - _graphics->flowTextScaled(_msgFont, 0, 5, 3, true, true, true, true, 14, 148, 134, 186, _rooms[curMsg]._roomMsg); + _graphics->flowTextScaled(_msgFont, 0, 5, 3, true, true, true, true, Common::Rect(14, 148, 134, 186), _rooms[curMsg]._roomMsg); if (fadeIn) _graphics->fade(true, 0); @@ -558,7 +559,7 @@ void LabEngine::processMap(uint16 curRoom) { _event->mouseHide(); _graphics->setPen(3); _graphics->rectFillScaled(13, 148, 135, 186); - _graphics->flowTextScaled(_msgFont, 0, 5, 3, true, true, true, true, 14, 148, 134, 186, sptr); + _graphics->flowTextScaled(_msgFont, 0, 5, 3, true, true, true, true, Common::Rect(14, 148, 134, 186), sptr); if (_maps[oldMsg]._pageNumber == curFloor) drawRoomMap(oldMsg, (bool)(oldMsg == curRoom)); -- 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/map.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index cbd664e27e..78eaaf0d79 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -411,11 +411,11 @@ void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 floorNum, bool fad if ((floorNum >= kFloorLower) && (floorNum <= kFloorCarnival)) { char *sptr = (char *)_resource->getStaticText(floorNum - 1).c_str(); - _graphics->flowTextScaled(_msgFont, 0, 5, 3, true, true, true, true, Common::Rect(14, 75, 134, 97), sptr); + _graphics->flowText(_msgFont, 0, 5, 3, true, true, true, true, _utils->vgaRectScale(14, 75, 134, 97), sptr); } if (_rooms[curMsg]._roomMsg) - _graphics->flowTextScaled(_msgFont, 0, 5, 3, true, true, true, true, Common::Rect(14, 148, 134, 186), _rooms[curMsg]._roomMsg); + _graphics->flowText(_msgFont, 0, 5, 3, true, true, true, true, _utils->vgaRectScale(14, 148, 134, 186), _rooms[curMsg]._roomMsg); if (fadeIn) _graphics->fade(true, 0); @@ -559,7 +559,7 @@ void LabEngine::processMap(uint16 curRoom) { _event->mouseHide(); _graphics->setPen(3); _graphics->rectFillScaled(13, 148, 135, 186); - _graphics->flowTextScaled(_msgFont, 0, 5, 3, true, true, true, true, Common::Rect(14, 148, 134, 186), sptr); + _graphics->flowText(_msgFont, 0, 5, 3, true, true, true, true, _utils->vgaRectScale(14, 148, 134, 186), sptr); if (_maps[oldMsg]._pageNumber == curFloor) drawRoomMap(oldMsg, (bool)(oldMsg == curRoom)); -- cgit v1.2.3 From 540173de3693eb78b07fed6a1bac8db1f3049829 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 17 Dec 2015 19:05:02 +0100 Subject: LAB: constify 2 variables in drawMap --- engines/lab/map.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 78eaaf0d79..0136bf4f36 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -404,14 +404,14 @@ void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 floorNum, bool fad if (floorVisited(kFloorHedgeMaze)) _imgHugeMaze->drawImage(_utils->mapScaleX(524), _utils->mapScaleY(97)); } else if (floorNum == kFloorSurMaze) { - char *sptr = (char *)_resource->getStaticText(kTextSurmazeMessage).c_str(); Common::Rect textRect = Common::Rect(_utils->mapScaleX(360), 0, _utils->mapScaleX(660), _utils->mapScaleY(450)); - _graphics->flowText(_msgFont, 0, 7, 0, true, true, true, true, textRect, sptr); + const char *textPtr = _resource->getStaticText(kTextSurmazeMessage).c_str(); + _graphics->flowText(_msgFont, 0, 7, 0, true, true, true, true, textRect, textPtr); } if ((floorNum >= kFloorLower) && (floorNum <= kFloorCarnival)) { - char *sptr = (char *)_resource->getStaticText(floorNum - 1).c_str(); - _graphics->flowText(_msgFont, 0, 5, 3, true, true, true, true, _utils->vgaRectScale(14, 75, 134, 97), sptr); + const char *textPrt = _resource->getStaticText(floorNum - 1).c_str(); + _graphics->flowText(_msgFont, 0, 5, 3, true, true, true, true, _utils->vgaRectScale(14, 75, 134, 97), textPrt); } if (_rooms[curMsg]._roomMsg) -- 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/map.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 0136bf4f36..81068ed53e 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -473,19 +473,17 @@ void LabEngine::processMap(uint16 curRoom) { } else { uint32 msgClass = msg->_msgClass; uint16 msgCode = msg->_code; - uint16 buttonId = msg->_buttonId; - uint16 qualifier = msg->_qualifier; uint16 mouseX = msg->_mouseX; uint16 mouseY = msg->_mouseY; - if (((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RIGHTBUTTON & qualifier)) || ((msgClass == RAWKEY) && (msgCode == Common::KEYCODE_ESCAPE))) + if ((msgClass == kMessageRightClick) || ((msgClass == kMessageRawKey) && (msgCode == Common::KEYCODE_ESCAPE))) return; - if (msgClass == BUTTONUP) { - if (buttonId == 0) { + if (msgClass == kMessageButtonUp) { + if (msgCode == 0) { // Quit menu button return; - } else if (buttonId == 1) { + } else if (msgCode == 1) { // Up arrow uint16 upperFloor = getUpperFloor(curFloor); if (upperFloor != kFloorNone) { @@ -494,7 +492,7 @@ void LabEngine::processMap(uint16 curRoom) { drawMap(curRoom, curMsg, curFloor, false, false); _graphics->fade(true, 0); } - } else if (buttonId == 2) { + } else if (msgCode == 2) { // Down arrow uint16 lowerFloor = getLowerFloor(curFloor); if (lowerFloor != kFloorNone) { @@ -504,7 +502,7 @@ void LabEngine::processMap(uint16 curRoom) { _graphics->fade(true, 0); } } - } else if ((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & qualifier)) { + } else if (msgClass == kMessageLeftClick) { if ((curFloor == kFloorLower) && (mouseX >= _utils->mapScaleX(538)) && (mouseY >= _utils->mapScaleY(277)) && (mouseX <= _utils->mapScaleX(633)) && (mouseY <= _utils->mapScaleY(352)) && floorVisited(kFloorSurMaze)) { -- 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/map.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 81068ed53e..0d8b89a4f3 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -473,8 +473,8 @@ void LabEngine::processMap(uint16 curRoom) { } else { uint32 msgClass = msg->_msgClass; uint16 msgCode = msg->_code; - uint16 mouseX = msg->_mouseX; - uint16 mouseY = msg->_mouseY; + uint16 mouseX = msg->_mouse.x; + uint16 mouseY = msg->_mouse.y; if ((msgClass == kMessageRightClick) || ((msgClass == kMessageRawKey) && (msgCode == Common::KEYCODE_ESCAPE))) return; -- cgit v1.2.3 From 15889e6fd25dd0010dd2b5488cbabae46621954b Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 18 Dec 2015 02:15:44 +0100 Subject: LAB: Make processMap a bit more readable by using Rects --- engines/lab/map.cpp | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 0d8b89a4f3..bdd9eaf75f 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -503,33 +503,29 @@ void LabEngine::processMap(uint16 curRoom) { } } } else if (msgClass == kMessageLeftClick) { - if ((curFloor == kFloorLower) && (mouseX >= _utils->mapScaleX(538)) && (mouseY >= _utils->mapScaleY(277)) - && (mouseX <= _utils->mapScaleX(633)) && (mouseY <= _utils->mapScaleY(352)) + if ((curFloor == kFloorLower) && _utils->mapRectScale(538, 277, 633, 352).contains(mouseX, mouseY) && floorVisited(kFloorSurMaze)) { curFloor = kFloorSurMaze; _graphics->fade(false, 0); drawMap(curRoom, curMsg, curFloor, false, false); _graphics->fade(true, 0); - } else if ((curFloor == kFloorMiddle) && (mouseX >= _utils->mapScaleX(358)) && (mouseY >= _utils->mapScaleY(71)) - && (mouseX <= _utils->mapScaleX(452)) && (mouseY <= _utils->mapScaleY(147)) - && floorVisited(kFloorCarnival)) { + } else if ((curFloor == kFloorMiddle) && _utils->mapRectScale(358, 71, 452, 147).contains(mouseX, mouseY) + && floorVisited(kFloorCarnival)) { curFloor = kFloorCarnival; _graphics->fade(false, 0); drawMap(curRoom, curMsg, curFloor, false, false); _graphics->fade(true, 0); - } else if ((curFloor == kFloorMiddle) && (mouseX >= _utils->mapScaleX(557)) && (mouseY >= _utils->mapScaleY(325)) - && (mouseX <= _utils->mapScaleX(653)) && (mouseY <= _utils->mapScaleY(401)) - && floorVisited(kFloorMedMaze)) { + } else if ((curFloor == kFloorMiddle) && _utils->mapRectScale(557, 325, 653, 401).contains(mouseX, mouseY) + && floorVisited(kFloorMedMaze)) { curFloor = kFloorMedMaze; _graphics->fade(false, 0); drawMap(curRoom, curMsg, curFloor, false, false); _graphics->fade(true, 0); - } else if ((curFloor == kFloorUpper) && (mouseX >= _utils->mapScaleX(524)) && (mouseY >= _utils->mapScaleY(97)) - && (mouseX <= _utils->mapScaleX(645)) && (mouseY <= _utils->mapScaleY(207)) - && floorVisited(kFloorHedgeMaze)) { + } else if ((curFloor == kFloorUpper) && _utils->mapRectScale(524, 97, 645, 207).contains(mouseX, mouseY) + && floorVisited(kFloorHedgeMaze)) { curFloor = kFloorHedgeMaze; _graphics->fade(false, 0); -- 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/map.cpp | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index bdd9eaf75f..4c2bfe2cce 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -377,18 +377,8 @@ void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 floorNum, bool fad if ((_maps[curRoom]._pageNumber == floorNum) && _roomsFound->in(curRoom) && _maps[curRoom]._x) drawRoomMap(curRoom, true); - Button *upButton = _event->getButton(1); - Button *downButton = _event->getButton(2); - - if (getUpperFloor(floorNum) != kFloorNone) - _event->enableButton(upButton); - else - _event->disableButton(upButton, 12); - - if (getLowerFloor(floorNum) != kFloorNone) - _event->enableButton(downButton); - else - _event->disableButton(downButton, 12); + _event->toggleButton(_event->getButton(1), 12, (getUpperFloor(floorNum) != kFloorNone)); // up button + _event->toggleButton(_event->getButton(2), 12, (getLowerFloor(floorNum) != kFloorNone)); // down button // Labyrinth specific code if (floorNum == kFloorLower) { -- 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/map.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 4c2bfe2cce..f535cdf600 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -404,8 +404,8 @@ void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 floorNum, bool fad _graphics->flowText(_msgFont, 0, 5, 3, true, true, true, true, _utils->vgaRectScale(14, 75, 134, 97), textPrt); } - if (_rooms[curMsg]._roomMsg) - _graphics->flowText(_msgFont, 0, 5, 3, true, true, true, true, _utils->vgaRectScale(14, 148, 134, 186), _rooms[curMsg]._roomMsg); + if (_rooms[curMsg]._roomMsg != "") + _graphics->flowText(_msgFont, 0, 5, 3, true, true, true, true, _utils->vgaRectScale(14, 148, 134, 186), _rooms[curMsg]._roomMsg.c_str()); if (fadeIn) _graphics->fade(true, 0); @@ -535,11 +535,11 @@ void LabEngine::processMap(uint16 curRoom) { } if (oldMsg != curMsg) { - if (_rooms[curMsg]._roomMsg == nullptr) + if (_rooms[curMsg]._roomMsg != "") _resource->readViews(curMsg); - char *sptr; - if ((sptr = _rooms[curMsg]._roomMsg)) { + const char *sptr; + if ((sptr = _rooms[curMsg]._roomMsg.c_str())) { _event->mouseHide(); _graphics->setPen(3); _graphics->rectFillScaled(13, 148, 135, 186); -- 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/map.cpp | 29 ----------------------------- 1 file changed, 29 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index f535cdf600..05c36fc010 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -56,9 +56,6 @@ enum MapFloor { kFloorCarnival }; -/** - * Loads in the map data. - */ void LabEngine::loadMapData() { Common::File *mapImages = _resource->openDataFile("P:MapImage"); @@ -134,9 +131,6 @@ void LabEngine::freeMapData() { _maps = nullptr; } -/** - * Figures out what a room's coordinates should be. - */ Common::Rect LabEngine::roomCoords(uint16 curRoom) { Image *curRoomImg = nullptr; @@ -173,9 +167,6 @@ Common::Rect LabEngine::roomCoords(uint16 curRoom) { return Common::Rect(x1, y1, x2, y2); } -/** - * Draws a room map. - */ void LabEngine::drawRoomMap(uint16 curRoom, bool drawMarkFl) { uint16 drawX, drawY, offset; @@ -307,9 +298,6 @@ void LabEngine::drawRoomMap(uint16 curRoom, bool drawMarkFl) { _imgMapX[_direction]->drawImage(drawX, drawY); } -/** - * Checks if a floor has been visited. - */ bool LabEngine::floorVisited(uint16 floorNum) { for (uint16 i = 1; i <= _maxRooms; i++) { if ((_maps[i]._pageNumber == floorNum) && _roomsFound->in(i) && _maps[i]._x) @@ -319,10 +307,6 @@ bool LabEngine::floorVisited(uint16 floorNum) { return false; } -/** - * Returns the floor to show when the up arrow is pressed - * Note: The original did not show all the visited floors, but we do - */ uint16 LabEngine::getUpperFloor(uint16 floorNum) { if ((floorNum == kFloorCarnival) || (floorNum == kFloorNone)) return kFloorNone; @@ -334,10 +318,6 @@ uint16 LabEngine::getUpperFloor(uint16 floorNum) { return kFloorNone; } -/** - * Returns the floor to show when the down arrow is pressed - * Note: The original did not show all the visited floors, but we do - */ uint16 LabEngine::getLowerFloor(uint16 floorNum) { if ((floorNum == kFloorLower) || (floorNum == kFloorNone)) return kFloorNone; @@ -349,9 +329,6 @@ uint16 LabEngine::getLowerFloor(uint16 floorNum) { return kFloorNone; } -/** - * Draws the map - */ void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 floorNum, bool fadeOut, bool fadeIn) { _event->mouseHide(); @@ -413,9 +390,6 @@ void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 floorNum, bool fad _event->mouseShow(); } -/** - * Processes the map. - */ void LabEngine::processMap(uint16 curRoom) { byte place = 1; uint16 curMsg = curRoom; @@ -570,9 +544,6 @@ void LabEngine::processMap(uint16 curRoom) { } } -/** - * Does the map processing. - */ void LabEngine::doMap(uint16 curRoom) { static uint16 amigaMapPalette[] = { 0x0BA8, 0x0C11, 0x0A74, 0x0076, -- cgit v1.2.3 From 08a035f0e5d9fcab4c7f28817f8e344918b0250c Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 20 Dec 2015 14:59:13 +0100 Subject: LAB: Fix loop in flooVisited --- engines/lab/map.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 05c36fc010..84da3596e8 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -299,7 +299,7 @@ void LabEngine::drawRoomMap(uint16 curRoom, bool drawMarkFl) { } bool LabEngine::floorVisited(uint16 floorNum) { - for (uint16 i = 1; i <= _maxRooms; i++) { + for (uint16 i = 0; i < _maxRooms; i++) { if ((_maps[i]._pageNumber == floorNum) && _roomsFound->in(i) && _maps[i]._x) return true; } -- cgit v1.2.3 From fa222f0ca878b3bf55b439ccf0e1e0849cecfe63 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 21 Dec 2015 01:27:50 +0100 Subject: LAB: Make string check more readable, remove a useless c_str() --- engines/lab/map.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 84da3596e8..63e3571b8f 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -381,7 +381,7 @@ void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 floorNum, bool fad _graphics->flowText(_msgFont, 0, 5, 3, true, true, true, true, _utils->vgaRectScale(14, 75, 134, 97), textPrt); } - if (_rooms[curMsg]._roomMsg != "") + if (!_rooms[curMsg]._roomMsg.empty()) _graphics->flowText(_msgFont, 0, 5, 3, true, true, true, true, _utils->vgaRectScale(14, 148, 134, 186), _rooms[curMsg]._roomMsg.c_str()); if (fadeIn) @@ -509,7 +509,7 @@ void LabEngine::processMap(uint16 curRoom) { } if (oldMsg != curMsg) { - if (_rooms[curMsg]._roomMsg != "") + if (!_rooms[curMsg]._roomMsg.empty()) _resource->readViews(curMsg); const char *sptr; -- cgit v1.2.3 From be1fd471be362eff1d6e05bef8b8469655174b16 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 21 Dec 2015 01:49:41 +0100 Subject: LAB: better fix of loadMapData, taking into account the other loops on _maps --- engines/lab/map.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 63e3571b8f..db0ba206fe 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -87,8 +87,8 @@ void LabEngine::loadMapData() { _music->stopSoundEffect(); _maxRooms = mapFile->readUint16LE(); - _maps = new MapData[_maxRooms]; // will be freed when the user exits the map - for (int i = 0; i < _maxRooms; i++) { + _maps = new MapData[_maxRooms + 1]; // will be freed when the user exits the map + for (int i = 1; i <= _maxRooms; i++) { _maps[i]._x = mapFile->readUint16LE(); _maps[i]._y = mapFile->readUint16LE(); _maps[i]._pageNumber = mapFile->readUint16LE(); -- 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/map.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index db0ba206fe..b9f5703131 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -82,7 +82,7 @@ void LabEngine::loadMapData() { delete mapImages; Common::File *mapFile = _resource->openDataFile("Lab:Maps", MKTAG('M', 'A', 'P', '0')); - _music->updateMusic(); + updateMusicAndEvents(); if (!_music->_loopSoundEffect) _music->stopSoundEffect(); @@ -344,7 +344,7 @@ void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 floorNum, bool fad for (uint16 i = 1; i <= _maxRooms; i++) { if ((_maps[i]._pageNumber == floorNum) && _roomsFound->in(i) && _maps[i]._x) { drawRoomMap(i, (bool)(i == curRoom)); - _music->updateMusic(); + updateMusicAndEvents(); } } @@ -397,7 +397,7 @@ void LabEngine::processMap(uint16 curRoom) { 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; @@ -405,7 +405,7 @@ void LabEngine::processMap(uint16 curRoom) { } if (!msg) { - _music->updateMusic(); + updateMusicAndEvents(); byte newcolor[3]; @@ -554,7 +554,7 @@ void LabEngine::doMap(uint16 curRoom) { _graphics->_fadePalette = amigaMapPalette; - _music->updateMusic(); + updateMusicAndEvents(); loadMapData(); _graphics->blackAllScreen(); _event->attachButtonList(&_mapButtonList); -- 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/map.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index b9f5703131..e06fefdd92 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -299,7 +299,7 @@ void LabEngine::drawRoomMap(uint16 curRoom, bool drawMarkFl) { } bool LabEngine::floorVisited(uint16 floorNum) { - for (uint16 i = 0; i < _maxRooms; i++) { + for (int i = 0; i < _maxRooms; i++) { if ((_maps[i]._pageNumber == floorNum) && _roomsFound->in(i) && _maps[i]._x) return true; } @@ -311,7 +311,7 @@ uint16 LabEngine::getUpperFloor(uint16 floorNum) { if ((floorNum == kFloorCarnival) || (floorNum == kFloorNone)) return kFloorNone; - for (uint16 i = floorNum; i < kFloorCarnival; i++) + for (int i = floorNum; i < kFloorCarnival; i++) if (floorVisited(i + 1)) return i + 1; @@ -322,7 +322,7 @@ uint16 LabEngine::getLowerFloor(uint16 floorNum) { if ((floorNum == kFloorLower) || (floorNum == kFloorNone)) return kFloorNone; - for (uint16 i = floorNum; i > kFloorLower; i--) + for (int i = floorNum; i > kFloorLower; i--) if (floorVisited(i - 1)) return i - 1; @@ -341,7 +341,7 @@ void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 floorNum, bool fad _imgMap->drawImage(0, 0); _event->drawButtonList(&_mapButtonList); - for (uint16 i = 1; i <= _maxRooms; i++) { + for (int i = 1; i <= _maxRooms; i++) { if ((_maps[i]._pageNumber == floorNum) && _roomsFound->in(i) && _maps[i]._x) { drawRoomMap(i, (bool)(i == curRoom)); updateMusicAndEvents(); @@ -499,7 +499,7 @@ void LabEngine::processMap(uint16 curRoom) { uint16 oldMsg = curMsg; Common::Rect curCoords; - for (uint16 i = 1; i <= _maxRooms; i++) { + for (int i = 1; i <= _maxRooms; i++) { curCoords = roomCoords(i); if ((_maps[i]._pageNumber == curFloor) -- cgit v1.2.3 From 70ec11d260d2adcfaaaa12d19213a6f705dde773 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 23 Dec 2015 22:59:59 +0200 Subject: LAB: Change the direction and map door defines into enums --- engines/lab/map.cpp | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index e06fefdd92..082925a3fc 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -68,10 +68,10 @@ void LabEngine::loadMapData() { _imgMaze = new Image(mapImages, this); _imgHugeMaze = new Image(mapImages, this); - _imgMapX[NORTH] = new Image(mapImages, this); - _imgMapX[EAST] = new Image(mapImages, this); - _imgMapX[SOUTH] = new Image(mapImages, this); - _imgMapX[WEST] = new Image(mapImages, this); + _imgMapX[kDirectionNorth] = new Image(mapImages, this); + _imgMapX[kDirectionEast] = new Image(mapImages, this); + _imgMapX[kDirectionSouth] = new Image(mapImages, this); + _imgMapX[kDirectionWest] = new Image(mapImages, this); _imgPath = new Image(mapImages, this); _imgBridge = new Image(mapImages, this); @@ -187,18 +187,18 @@ void LabEngine::drawRoomMap(uint16 curRoom, bool drawMarkFl) { offset = (_imgRoom->_width - _imgPath->_width) / 2; - if ((NORTHDOOR & flags) && (y >= _imgPath->_height)) + if ((kDoorLeftNorth & flags) && (y >= _imgPath->_height)) _imgPath->drawImage(x + offset, y - _imgPath->_height); - if (SOUTHDOOR & flags) + if (kDoorLeftSouth & flags) _imgPath->drawImage(x + offset, y + _imgRoom->_height); offset = (_imgRoom->_height - _imgPath->_height) / 2; - if (EASTDOOR & flags) + if (kDoorLeftEast & flags) _imgPath->drawImage(x + _imgRoom->_width, y + offset); - if (WESTDOOR & flags) + if (kDoorLeftWest & flags) _imgPath->drawImage(x - _imgPath->_width, y + offset); drawX = x + (_imgRoom->_width - _imgMapX[_direction]->_width) / 2; @@ -219,32 +219,32 @@ void LabEngine::drawRoomMap(uint16 curRoom, bool drawMarkFl) { offset = (_imgVRoom->_width - _imgPath->_width) / 2; - if (NORTHDOOR & flags) + if (kDoorLeftNorth & flags) _imgPath->drawImage(x + offset, y - _imgPath->_height); - if (SOUTHDOOR & flags) + if (kDoorLeftSouth & flags) _imgPath->drawImage(x + offset, y + _imgVRoom->_height); offset = (_imgRoom->_height - _imgPath->_height) / 2; - if (EASTDOOR & flags) + if (kDoorLeftEast & flags) _imgPath->drawImage(x + _imgVRoom->_width, y + offset); - if (WESTDOOR & flags) + if (kDoorLeftWest & flags) _imgPath->drawImage(x - _imgPath->_width, y + offset); - if (EASTBDOOR & flags) + if (kDoorBottomEast & flags) _imgPath->drawImage(x + _imgVRoom->_width, y - offset - _imgPath->_height + _imgVRoom->_height); - if (WESTBDOOR & flags) + if (kDoorBottomWest & flags) _imgPath->drawImage(x - _imgPath->_width, y - offset - _imgPath->_height + _imgVRoom->_height); offset = (_imgVRoom->_height - _imgPath->_height) / 2; - if (EASTMDOOR & flags) + if (kDoorMiddleEast & flags) _imgPath->drawImage(x + _imgVRoom->_width, y - offset - _imgPath->_height + _imgVRoom->_height); - if (WESTMDOOR & flags) + if (kDoorMiddleWest & flags) _imgPath->drawImage(x - _imgPath->_width, y - offset - _imgPath->_height + _imgVRoom->_height); drawX = x + (_imgVRoom->_width - _imgMapX[_direction]->_width) / 2; @@ -257,32 +257,32 @@ void LabEngine::drawRoomMap(uint16 curRoom, bool drawMarkFl) { offset = (_imgRoom->_width - _imgPath->_width) / 2; - if (NORTHDOOR & flags) + if (kDoorLeftNorth & flags) _imgPath->drawImage(x + offset, y - _imgPath->_height); - if (SOUTHDOOR & flags) + if (kDoorLeftSouth & flags) _imgPath->drawImage(x + offset, y + _imgRoom->_height); - if (NORTHRDOOR & flags) + if (kDoorRightNorth & flags) _imgPath->drawImage(x - offset - _imgPath->_width + _imgHRoom->_width, y - _imgPath->_height); - if (SOUTHRDOOR & flags) + if (kDoorRightSouth & flags) _imgPath->drawImage(x - offset - _imgPath->_width + _imgHRoom->_width, y + _imgRoom->_height); offset = (_imgHRoom->_width - _imgPath->_width) / 2; - if (NORTHMDOOR & flags) + if (kDoorMiddleNorth & flags) _imgPath->drawImage(x - offset - _imgPath->_width + _imgHRoom->_width, y - _imgPath->_height); - if (SOUTHMDOOR & flags) + if (kDoorMiddleSouth & flags) _imgPath->drawImage(x - offset - _imgPath->_width + _imgHRoom->_width, y + _imgRoom->_height); offset = (_imgRoom->_height - _imgPath->_height) / 2; - if (EASTDOOR & flags) + if (kDoorLeftEast & flags) _imgPath->drawImage(x + _imgHRoom->_width, y + offset); - if (WESTDOOR & flags) + if (kDoorLeftWest & flags) _imgPath->drawImage(x - _imgPath->_width, y + offset); drawX = x + (_imgHRoom->_width - _imgMapX[_direction]->_width) / 2; -- 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/map.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 082925a3fc..21b0804e66 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -333,7 +333,7 @@ void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 floorNum, bool fad _event->mouseHide(); if (fadeOut) - _graphics->fade(false, 0); + _graphics->fade(false); _graphics->setPen(0); _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1); @@ -385,7 +385,7 @@ void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 floorNum, bool fad _graphics->flowText(_msgFont, 0, 5, 3, true, true, true, true, _utils->vgaRectScale(14, 148, 134, 186), _rooms[curMsg]._roomMsg.c_str()); if (fadeIn) - _graphics->fade(true, 0); + _graphics->fade(true); _event->mouseShow(); } @@ -452,18 +452,18 @@ void LabEngine::processMap(uint16 curRoom) { uint16 upperFloor = getUpperFloor(curFloor); if (upperFloor != kFloorNone) { curFloor = upperFloor; - _graphics->fade(false, 0); + _graphics->fade(false); drawMap(curRoom, curMsg, curFloor, false, false); - _graphics->fade(true, 0); + _graphics->fade(true); } } else if (msgCode == 2) { // Down arrow uint16 lowerFloor = getLowerFloor(curFloor); if (lowerFloor != kFloorNone) { curFloor = lowerFloor; - _graphics->fade(false, 0); + _graphics->fade(false); drawMap(curRoom, curMsg, curFloor, false, false); - _graphics->fade(true, 0); + _graphics->fade(true); } } } else if (msgClass == kMessageLeftClick) { @@ -471,30 +471,30 @@ void LabEngine::processMap(uint16 curRoom) { && floorVisited(kFloorSurMaze)) { curFloor = kFloorSurMaze; - _graphics->fade(false, 0); + _graphics->fade(false); drawMap(curRoom, curMsg, curFloor, false, false); - _graphics->fade(true, 0); + _graphics->fade(true); } else if ((curFloor == kFloorMiddle) && _utils->mapRectScale(358, 71, 452, 147).contains(mouseX, mouseY) && floorVisited(kFloorCarnival)) { curFloor = kFloorCarnival; - _graphics->fade(false, 0); + _graphics->fade(false); drawMap(curRoom, curMsg, curFloor, false, false); - _graphics->fade(true, 0); + _graphics->fade(true); } else if ((curFloor == kFloorMiddle) && _utils->mapRectScale(557, 325, 653, 401).contains(mouseX, mouseY) && floorVisited(kFloorMedMaze)) { curFloor = kFloorMedMaze; - _graphics->fade(false, 0); + _graphics->fade(false); drawMap(curRoom, curMsg, curFloor, false, false); - _graphics->fade(true, 0); + _graphics->fade(true); } else if ((curFloor == kFloorUpper) && _utils->mapRectScale(524, 97, 645, 207).contains(mouseX, mouseY) && floorVisited(kFloorHedgeMaze)) { curFloor = kFloorHedgeMaze; - _graphics->fade(false, 0); + _graphics->fade(false); drawMap(curRoom, curMsg, curFloor, false, false); - _graphics->fade(true, 0); + _graphics->fade(true); } else if (mouseX > _utils->mapScaleX(314)) { uint16 oldMsg = curMsg; Common::Rect curCoords; @@ -563,7 +563,7 @@ void LabEngine::doMap(uint16 curRoom) { _graphics->screenUpdate(); processMap(curRoom); _event->attachButtonList(nullptr); - _graphics->fade(false, 0); + _graphics->fade(false); _graphics->blackAllScreen(); _event->mouseHide(); _graphics->setPen(0); -- 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/map.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 21b0804e66..12df8ca4d7 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -399,7 +399,7 @@ void LabEngine::processMap(uint16 curRoom) { // 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/map.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 12df8ca4d7..fa657c0093 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -335,8 +335,7 @@ void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 floorNum, bool fad if (fadeOut) _graphics->fade(false); - _graphics->setPen(0); - _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1); + _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1, 0); _imgMap->drawImage(0, 0); _event->drawButtonList(&_mapButtonList); @@ -515,8 +514,7 @@ void LabEngine::processMap(uint16 curRoom) { const char *sptr; if ((sptr = _rooms[curMsg]._roomMsg.c_str())) { _event->mouseHide(); - _graphics->setPen(3); - _graphics->rectFillScaled(13, 148, 135, 186); + _graphics->rectFillScaled(13, 148, 135, 186, 3); _graphics->flowText(_msgFont, 0, 5, 3, true, true, true, true, _utils->vgaRectScale(14, 148, 134, 186), sptr); if (_maps[oldMsg]._pageNumber == curFloor) @@ -529,8 +527,7 @@ void LabEngine::processMap(uint16 curRoom) { top = bottom = (curCoords.top + curCoords.bottom) / 2; if ((curMsg != curRoom) && (_maps[curMsg]._pageNumber == curFloor)) { - _graphics->setPen(1); - _graphics->rectFill(left, top, right, bottom); + _graphics->rectFill(left, top, right, bottom, 1); } _event->mouseShow(); @@ -566,8 +563,7 @@ void LabEngine::doMap(uint16 curRoom) { _graphics->fade(false); _graphics->blackAllScreen(); _event->mouseHide(); - _graphics->setPen(0); - _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1); + _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1, 0); freeMapData(); _graphics->blackAllScreen(); _event->mouseShow(); -- cgit v1.2.3 From 6ad66320709973afd870cad10b0ef7f4155afa3a Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 24 Dec 2015 13:07:53 +0200 Subject: LAB: Remove excess delay in map --- engines/lab/map.cpp | 5 ----- 1 file changed, 5 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index fa657c0093..d84f8528d0 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -422,11 +422,6 @@ void LabEngine::processMap(uint16 curRoom) { _graphics->writeColorRegs(newcolor, 1, 1); _event->updateMouse(); waitTOF(); - _event->updateMouse(); - waitTOF(); - _event->updateMouse(); - waitTOF(); - _event->updateMouse(); place++; -- 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/map.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index d84f8528d0..bc766f4b3b 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -75,9 +75,9 @@ void LabEngine::loadMapData() { _imgPath = new Image(mapImages, this); _imgBridge = new Image(mapImages, this); - _mapButtonList.push_back(_event->createButton( 8, _utils->vgaScaleY(105), 0, VKEY_LTARROW, new Image(mapImages, this), new Image(mapImages, this))); // back - _mapButtonList.push_back(_event->createButton( 55, _utils->vgaScaleY(105), 1, VKEY_UPARROW, new Image(mapImages, this), new Image(mapImages, this))); // up - _mapButtonList.push_back(_event->createButton(101, _utils->vgaScaleY(105), 2, VKEY_DNARROW, new Image(mapImages, this), new Image(mapImages, this))); // down + _mapButtonList.push_back(_event->createButton( 8, _utils->vgaScaleY(105), 0, Common::KEYCODE_ESCAPE, new Image(mapImages, this), new Image(mapImages, this))); // back + _mapButtonList.push_back(_event->createButton( 55, _utils->vgaScaleY(105), 1, Common::KEYCODE_UP, new Image(mapImages, this), new Image(mapImages, this))); // up + _mapButtonList.push_back(_event->createButton(101, _utils->vgaScaleY(105), 2, Common::KEYCODE_DOWN, new Image(mapImages, this), new Image(mapImages, this))); // down delete mapImages; -- cgit v1.2.3 From c191efa62348c3f7950a0272ee816aa49c4dccce Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 24 Dec 2015 18:54:27 +0100 Subject: LAB: Remove the 3rd parameter of drawMap (always false) --- engines/lab/map.cpp | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index bc766f4b3b..21a0830913 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -329,14 +329,10 @@ uint16 LabEngine::getLowerFloor(uint16 floorNum) { return kFloorNone; } -void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 floorNum, bool fadeOut, bool fadeIn) { +void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 floorNum, bool fadeIn) { _event->mouseHide(); - if (fadeOut) - _graphics->fade(false); - _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1, 0); - _imgMap->drawImage(0, 0); _event->drawButtonList(&_mapButtonList); @@ -447,7 +443,7 @@ void LabEngine::processMap(uint16 curRoom) { if (upperFloor != kFloorNone) { curFloor = upperFloor; _graphics->fade(false); - drawMap(curRoom, curMsg, curFloor, false, false); + drawMap(curRoom, curMsg, curFloor, false); _graphics->fade(true); } } else if (msgCode == 2) { @@ -456,7 +452,7 @@ void LabEngine::processMap(uint16 curRoom) { if (lowerFloor != kFloorNone) { curFloor = lowerFloor; _graphics->fade(false); - drawMap(curRoom, curMsg, curFloor, false, false); + drawMap(curRoom, curMsg, curFloor, false); _graphics->fade(true); } } @@ -466,28 +462,28 @@ void LabEngine::processMap(uint16 curRoom) { curFloor = kFloorSurMaze; _graphics->fade(false); - drawMap(curRoom, curMsg, curFloor, false, false); + drawMap(curRoom, curMsg, curFloor, false); _graphics->fade(true); } else if ((curFloor == kFloorMiddle) && _utils->mapRectScale(358, 71, 452, 147).contains(mouseX, mouseY) && floorVisited(kFloorCarnival)) { curFloor = kFloorCarnival; _graphics->fade(false); - drawMap(curRoom, curMsg, curFloor, false, false); + drawMap(curRoom, curMsg, curFloor, false); _graphics->fade(true); } else if ((curFloor == kFloorMiddle) && _utils->mapRectScale(557, 325, 653, 401).contains(mouseX, mouseY) && floorVisited(kFloorMedMaze)) { curFloor = kFloorMedMaze; _graphics->fade(false); - drawMap(curRoom, curMsg, curFloor, false, false); + drawMap(curRoom, curMsg, curFloor, false); _graphics->fade(true); } else if ((curFloor == kFloorUpper) && _utils->mapRectScale(524, 97, 645, 207).contains(mouseX, mouseY) && floorVisited(kFloorHedgeMaze)) { curFloor = kFloorHedgeMaze; _graphics->fade(false); - drawMap(curRoom, curMsg, curFloor, false, false); + drawMap(curRoom, curMsg, curFloor, false); _graphics->fade(true); } else if (mouseX > _utils->mapScaleX(314)) { uint16 oldMsg = curMsg; @@ -550,7 +546,7 @@ void LabEngine::doMap(uint16 curRoom) { loadMapData(); _graphics->blackAllScreen(); _event->attachButtonList(&_mapButtonList); - drawMap(curRoom, curRoom, _maps[curRoom]._pageNumber, false, true); + drawMap(curRoom, curRoom, _maps[curRoom]._pageNumber, true); _event->mouseShow(); _graphics->screenUpdate(); processMap(curRoom); -- cgit v1.2.3 From 0b9126f7749a31541d491dc2e1f8af401766788e Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 26 Dec 2015 12:42:45 +0200 Subject: LAB: Remove superfluous sound effect stopping code --- engines/lab/map.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 21a0830913..7d1645f4fa 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -83,8 +83,6 @@ void LabEngine::loadMapData() { Common::File *mapFile = _resource->openDataFile("Lab:Maps", MKTAG('M', 'A', 'P', '0')); updateMusicAndEvents(); - if (!_music->_loopSoundEffect) - _music->stopSoundEffect(); _maxRooms = mapFile->readUint16LE(); _maps = new MapData[_maxRooms + 1]; // will be freed when the user exits the map -- cgit v1.2.3 From e231c6753bdc9ccdcae5497ef55af9afcd74edca Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 26 Dec 2015 12:43:18 +0200 Subject: LAB: Update music after drawing the map rooms --- engines/lab/map.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 7d1645f4fa..d96631f330 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -337,10 +337,11 @@ void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 floorNum, bool fad for (int i = 1; i <= _maxRooms; i++) { if ((_maps[i]._pageNumber == floorNum) && _roomsFound->in(i) && _maps[i]._x) { drawRoomMap(i, (bool)(i == curRoom)); - updateMusicAndEvents(); } } + updateMusicAndEvents(); + // Makes sure the X is drawn in corridors // NOTE: this here on purpose just in case there's some weird // condition, like the surreal maze where there are no rooms -- cgit v1.2.3 From e4fbcabbc96d10077c3bfd7af548d1d7ab6ca09e Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Sat, 26 Dec 2015 17:07:01 +0100 Subject: LAB: Fix map Regression from be1fd471be362eff1d6e05bef8b8469655174b16. --- engines/lab/map.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index d96631f330..6bd91c197d 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -86,7 +86,7 @@ void LabEngine::loadMapData() { _maxRooms = mapFile->readUint16LE(); _maps = new MapData[_maxRooms + 1]; // will be freed when the user exits the map - for (int i = 1; i <= _maxRooms; i++) { + for (int i = 0; i <= _maxRooms; i++) { _maps[i]._x = mapFile->readUint16LE(); _maps[i]._y = mapFile->readUint16LE(); _maps[i]._pageNumber = mapFile->readUint16LE(); -- cgit v1.2.3 From 2bad773046f530f3b58c44ba8879bd4f562c2078 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 27 Dec 2015 01:05:43 +0100 Subject: LAB: Use an enum for special room ids --- engines/lab/map.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index 6bd91c197d..f7b2cfe9ea 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -90,7 +90,7 @@ void LabEngine::loadMapData() { _maps[i]._x = mapFile->readUint16LE(); _maps[i]._y = mapFile->readUint16LE(); _maps[i]._pageNumber = mapFile->readUint16LE(); - _maps[i]._specialID = mapFile->readUint16LE(); + _maps[i]._specialID = (SpecialRoom) mapFile->readUint16LE(); _maps[i]._mapFlags = mapFile->readUint32LE(); } @@ -133,18 +133,18 @@ Common::Rect LabEngine::roomCoords(uint16 curRoom) { Image *curRoomImg = nullptr; switch (_maps[curRoom]._specialID) { - case NORMAL: - case UPARROWROOM: - case DOWNARROWROOM: + case kNormalRoom: + case kUpArrowRoom: + case kDownArrowRoom: curRoomImg = _imgRoom; break; - case BRIDGEROOM: + case kBridgeRoom: curRoomImg = _imgBridge; break; - case VCORRIDOR: + case kVerticalCorridor: curRoomImg = _imgVRoom; break; - case HCORRIDOR: + case kHorizontalCorridor: curRoomImg = _imgHRoom; break; default: @@ -173,12 +173,12 @@ void LabEngine::drawRoomMap(uint16 curRoom, bool drawMarkFl) { uint32 flags = _maps[curRoom]._mapFlags; switch (_maps[curRoom]._specialID) { - case NORMAL: - case UPARROWROOM: - case DOWNARROWROOM: - if (_maps[curRoom]._specialID == NORMAL) + case kNormalRoom: + case kUpArrowRoom: + case kDownArrowRoom: + if (_maps[curRoom]._specialID == kNormalRoom) _imgRoom->drawImage(x, y); - else if (_maps[curRoom]._specialID == DOWNARROWROOM) + else if (_maps[curRoom]._specialID == kDownArrowRoom) _imgDownArrowRoom->drawImage(x, y); else _imgUpArrowRoom->drawImage(x, y); @@ -204,7 +204,7 @@ void LabEngine::drawRoomMap(uint16 curRoom, bool drawMarkFl) { break; - case BRIDGEROOM: + case kBridgeRoom: _imgBridge->drawImage(x, y); drawX = x + (_imgBridge->_width - _imgMapX[_direction]->_width) / 2; @@ -212,7 +212,7 @@ void LabEngine::drawRoomMap(uint16 curRoom, bool drawMarkFl) { break; - case VCORRIDOR: + case kVerticalCorridor: _imgVRoom->drawImage(x, y); offset = (_imgVRoom->_width - _imgPath->_width) / 2; @@ -250,7 +250,7 @@ void LabEngine::drawRoomMap(uint16 curRoom, bool drawMarkFl) { break; - case HCORRIDOR: + case kHorizontalCorridor: _imgHRoom->drawImage(x, y); offset = (_imgRoom->_width - _imgPath->_width) / 2; -- 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/map.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index f7b2cfe9ea..ee47c2b14b 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -82,7 +82,7 @@ void LabEngine::loadMapData() { delete mapImages; Common::File *mapFile = _resource->openDataFile("Lab:Maps", MKTAG('M', 'A', 'P', '0')); - updateMusicAndEvents(); + updateEvents(); _maxRooms = mapFile->readUint16LE(); _maps = new MapData[_maxRooms + 1]; // will be freed when the user exits the map @@ -340,7 +340,7 @@ void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 floorNum, bool fad } } - updateMusicAndEvents(); + updateEvents(); // Makes sure the X is drawn in corridors // NOTE: this here on purpose just in case there's some weird @@ -391,7 +391,7 @@ void LabEngine::processMap(uint16 curRoom) { while (1) { // Make sure we check the music at least after every message - updateMusicAndEvents(); + updateEvents(); IntuiMessage *msg = _event->getMsg(); if (shouldQuit()) { _quitLab = true; @@ -399,7 +399,7 @@ void LabEngine::processMap(uint16 curRoom) { } if (!msg) { - updateMusicAndEvents(); + updateEvents(); byte newcolor[3]; @@ -541,7 +541,7 @@ void LabEngine::doMap(uint16 curRoom) { _graphics->_fadePalette = amigaMapPalette; - updateMusicAndEvents(); + updateEvents(); loadMapData(); _graphics->blackAllScreen(); _event->attachButtonList(&_mapButtonList); -- cgit v1.2.3 From a7959a4ed4132c4a4f5ce7af5de1a8d075038395 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sun, 27 Dec 2015 22:50:09 +0200 Subject: LAB: Remove superfluous mouse show/hide calls Our mouse cursor is drawn in a separate layer, so we can draw on the screen without needing to hide it beforehand --- engines/lab/map.cpp | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'engines/lab/map.cpp') diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index ee47c2b14b..2b283aec4a 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -328,8 +328,6 @@ uint16 LabEngine::getLowerFloor(uint16 floorNum) { } void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 floorNum, bool fadeIn) { - _event->mouseHide(); - _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1, 0); _imgMap->drawImage(0, 0); _event->drawButtonList(&_mapButtonList); @@ -380,8 +378,6 @@ void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 floorNum, bool fad if (fadeIn) _graphics->fade(true); - - _event->mouseShow(); } void LabEngine::processMap(uint16 curRoom) { @@ -503,7 +499,6 @@ void LabEngine::processMap(uint16 curRoom) { const char *sptr; if ((sptr = _rooms[curMsg]._roomMsg.c_str())) { - _event->mouseHide(); _graphics->rectFillScaled(13, 148, 135, 186, 3); _graphics->flowText(_msgFont, 0, 5, 3, true, true, true, true, _utils->vgaRectScale(14, 148, 134, 186), sptr); @@ -516,11 +511,8 @@ void LabEngine::processMap(uint16 curRoom) { int top, bottom; top = bottom = (curCoords.top + curCoords.bottom) / 2; - if ((curMsg != curRoom) && (_maps[curMsg]._pageNumber == curFloor)) { + if ((curMsg != curRoom) && (_maps[curMsg]._pageNumber == curFloor)) _graphics->rectFill(left, top, right, bottom, 1); - } - - _event->mouseShow(); } } } @@ -552,11 +544,9 @@ void LabEngine::doMap(uint16 curRoom) { _event->attachButtonList(nullptr); _graphics->fade(false); _graphics->blackAllScreen(); - _event->mouseHide(); _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1, 0); freeMapData(); _graphics->blackAllScreen(); - _event->mouseShow(); _graphics->screenUpdate(); } -- cgit v1.2.3