2014-10-06 12:50:05 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This code is based on Labyrinth of Time code with assistance of
|
|
|
|
*
|
|
|
|
* Copyright (c) 1993 Terra Nova Development
|
|
|
|
* Copyright (c) 2004 The Wyrmkeep Entertainment Co.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2014-12-25 18:13:52 +00:00
|
|
|
#include "lab/lab.h"
|
2015-12-08 20:10:54 +00:00
|
|
|
|
|
|
|
#include "lab/image.h"
|
2015-12-08 20:00:50 +00:00
|
|
|
#include "lab/labsets.h"
|
2015-12-08 19:36:05 +00:00
|
|
|
#include "lab/music.h"
|
2015-12-08 20:10:54 +00:00
|
|
|
#include "lab/resource.h"
|
2015-12-08 20:00:50 +00:00
|
|
|
#include "lab/utils.h"
|
2014-10-06 12:50:05 +00:00
|
|
|
|
|
|
|
namespace Lab {
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
/*------------------------------ The Map stuff ------------------------------*/
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
static Image *Map, *Room, *UpArrowRoom, *DownArrowRoom, *Bridge,
|
|
|
|
*HRoom, *VRoom, *Maze, *HugeMaze, *Path, *MapNorth,
|
2015-12-03 13:23:40 +00:00
|
|
|
*MapEast, *MapSouth, *MapWest, *XMark;
|
2014-10-06 12:50:05 +00:00
|
|
|
|
|
|
|
static uint16 MaxRooms;
|
|
|
|
static MapData *Maps;
|
|
|
|
|
2015-12-08 15:08:04 +00:00
|
|
|
enum MapFloor {
|
|
|
|
kFloorNone,
|
|
|
|
kFloorLower,
|
|
|
|
kFloorMiddle,
|
|
|
|
kFloorUpper,
|
|
|
|
kFloorMedMaze,
|
|
|
|
kFloorHedgeMaze,
|
|
|
|
kFloorSurMaze,
|
|
|
|
kFloorCarnival
|
|
|
|
};
|
2014-10-06 12:50:05 +00:00
|
|
|
|
|
|
|
static uint16 mapScaleX(uint16 x) {
|
2015-11-29 23:12:01 +00:00
|
|
|
if (g_lab->_isHiRes)
|
2014-10-06 12:50:05 +00:00
|
|
|
return (x - 45);
|
|
|
|
else
|
|
|
|
return ((x - 45) >> 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint16 mapScaleY(uint16 y) {
|
2015-11-29 23:12:01 +00:00
|
|
|
if (g_lab->_isHiRes)
|
2014-10-06 12:50:05 +00:00
|
|
|
return y;
|
|
|
|
else
|
|
|
|
return ((y - 35) >> 1) - (y >> 6);
|
|
|
|
}
|
|
|
|
|
2015-12-08 08:46:54 +00:00
|
|
|
/**
|
|
|
|
* Loads in the map data.
|
|
|
|
*/
|
2015-12-08 14:53:30 +00:00
|
|
|
void LabEngine::loadMapData() {
|
|
|
|
Utils *utils = g_lab->_utils;
|
2015-12-03 13:06:45 +00:00
|
|
|
Common::File *mapImages = g_lab->_resource->openDataFile("P:MapImage");
|
2014-10-06 12:50:05 +00:00
|
|
|
|
2015-12-03 13:06:45 +00:00
|
|
|
Map = new Image(mapImages);
|
2014-10-06 12:50:05 +00:00
|
|
|
|
2015-12-03 13:06:45 +00:00
|
|
|
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);
|
2014-10-06 12:50:05 +00:00
|
|
|
|
2015-12-03 13:06:45 +00:00
|
|
|
MapNorth = new Image(mapImages);
|
|
|
|
MapEast = new Image(mapImages);
|
|
|
|
MapSouth = new Image(mapImages);
|
|
|
|
MapWest = new Image(mapImages);
|
2014-10-06 12:50:05 +00:00
|
|
|
|
2015-12-03 13:06:45 +00:00
|
|
|
Path = new Image(mapImages);
|
|
|
|
Bridge = new Image(mapImages);
|
2014-10-06 12:50:05 +00:00
|
|
|
|
2015-12-08 14:53:30 +00:00
|
|
|
_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
|
2014-10-06 12:50:05 +00:00
|
|
|
|
2015-12-03 13:06:45 +00:00
|
|
|
delete mapImages;
|
2014-10-06 12:50:05 +00:00
|
|
|
|
2015-11-29 23:34:43 +00:00
|
|
|
Common::File *mapFile = g_lab->_resource->openDataFile("Lab:Maps", MKTAG('M', 'A', 'P', '0'));
|
2015-11-30 00:17:05 +00:00
|
|
|
g_lab->_music->updateMusic();
|
|
|
|
if (!g_lab->_music->_doNotFilestopSoundEffect)
|
|
|
|
g_lab->_music->stopSoundEffect();
|
2015-10-13 22:51:18 +00:00
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
2014-10-06 12:50:05 +00:00
|
|
|
|
2015-10-13 22:51:18 +00:00
|
|
|
delete mapFile;
|
2014-10-06 12:50:05 +00:00
|
|
|
}
|
|
|
|
|
2015-12-08 14:53:30 +00:00
|
|
|
void LabEngine::freeMapData() {
|
|
|
|
freeButtonList(&_mapGadgetList);
|
2015-12-06 20:50:41 +00:00
|
|
|
|
2015-10-13 22:51:18 +00:00
|
|
|
delete[] Maps;
|
|
|
|
Maps = NULL;
|
|
|
|
}
|
2014-10-06 12:50:05 +00:00
|
|
|
|
2015-12-08 08:46:54 +00:00
|
|
|
/**
|
|
|
|
* Figures out what a room's coordinates should be.
|
|
|
|
*/
|
2015-12-04 00:10:55 +00:00
|
|
|
static void roomCoords(uint16 CurRoom, uint16 *x1, uint16 *y1, uint16 *x2, uint16 *y2) {
|
2015-12-03 12:30:32 +00:00
|
|
|
Image *curRoomImg = NULL;
|
2014-10-06 12:50:05 +00:00
|
|
|
|
|
|
|
switch (Maps[CurRoom].SpecialID) {
|
|
|
|
case NORMAL:
|
|
|
|
case UPARROWROOM:
|
|
|
|
case DOWNARROWROOM:
|
2015-12-03 12:30:32 +00:00
|
|
|
curRoomImg = Room;
|
2014-10-06 12:50:05 +00:00
|
|
|
break;
|
|
|
|
case BRIDGEROOM:
|
2015-12-03 12:30:32 +00:00
|
|
|
curRoomImg = Bridge;
|
2014-10-06 12:50:05 +00:00
|
|
|
break;
|
|
|
|
case VCORRIDOR:
|
2015-12-03 12:30:32 +00:00
|
|
|
curRoomImg = VRoom;
|
2014-10-06 12:50:05 +00:00
|
|
|
break;
|
|
|
|
case HCORRIDOR:
|
2015-12-03 12:30:32 +00:00
|
|
|
curRoomImg = HRoom;
|
2014-10-06 12:50:05 +00:00
|
|
|
break;
|
2015-12-04 20:52:55 +00:00
|
|
|
default:
|
|
|
|
// Some rooms (like the map) do not have an image
|
|
|
|
break;
|
2014-10-06 12:50:05 +00:00
|
|
|
}
|
2015-12-03 12:30:32 +00:00
|
|
|
|
|
|
|
*x1 = mapScaleX(Maps[CurRoom].x);
|
|
|
|
*y1 = mapScaleY(Maps[CurRoom].y);
|
2015-12-04 20:52:55 +00:00
|
|
|
*x2 = *x1;
|
|
|
|
*y2 = *y1;
|
|
|
|
|
|
|
|
if (curRoomImg) {
|
|
|
|
*x2 += curRoomImg->_width;
|
|
|
|
*y2 += curRoomImg->_height;
|
|
|
|
}
|
2014-10-06 12:50:05 +00:00
|
|
|
}
|
|
|
|
|
2015-12-08 08:46:54 +00:00
|
|
|
/**
|
2015-12-08 15:08:04 +00:00
|
|
|
* Draws a room map.
|
2015-12-08 08:46:54 +00:00
|
|
|
*/
|
2015-12-08 15:08:04 +00:00
|
|
|
static void drawRoomMap(uint16 CurRoom, bool drawx) {
|
2014-10-06 12:50:05 +00:00
|
|
|
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)
|
2015-12-01 20:42:44 +00:00
|
|
|
Room->drawImage(x, y);
|
2014-10-06 12:50:05 +00:00
|
|
|
else if (Maps[CurRoom].SpecialID == DOWNARROWROOM)
|
2015-12-01 20:42:44 +00:00
|
|
|
DownArrowRoom->drawImage(x, y);
|
2014-10-06 12:50:05 +00:00
|
|
|
else
|
2015-12-01 20:42:44 +00:00
|
|
|
UpArrowRoom->drawImage(x, y);
|
2014-10-06 12:50:05 +00:00
|
|
|
|
2015-12-02 10:49:01 +00:00
|
|
|
offset = (Room->_width - Path->_width) / 2;
|
2014-10-06 12:50:05 +00:00
|
|
|
|
2015-12-02 10:49:01 +00:00
|
|
|
if ((NORTHDOOR & flags) && (y >= Path->_height))
|
|
|
|
Path->drawImage(x + offset, y - Path->_height);
|
2014-10-06 12:50:05 +00:00
|
|
|
|
|
|
|
if (SOUTHDOOR & flags)
|
2015-12-02 10:49:01 +00:00
|
|
|
Path->drawImage(x + offset, y + Room->_height);
|
2014-10-06 12:50:05 +00:00
|
|
|
|
2015-12-02 10:49:01 +00:00
|
|
|
offset = (Room->_height - Path->_height) / 2;
|
2014-10-06 12:50:05 +00:00
|
|
|
|
|
|
|
if (EASTDOOR & flags)
|
2015-12-02 10:49:01 +00:00
|
|
|
Path->drawImage(x + Room->_width, y + offset);
|
2014-10-06 12:50:05 +00:00
|
|
|
|
|
|
|
if (WESTDOOR & flags)
|
2015-12-02 10:49:01 +00:00
|
|
|
Path->drawImage(x - Path->_width, y + offset);
|
2014-10-06 12:50:05 +00:00
|
|
|
|
2015-12-02 10:49:01 +00:00
|
|
|
xx = x + (Room->_width - XMark->_width) / 2;
|
|
|
|
xy = y + (Room->_height - XMark->_height) / 2;
|
2014-10-06 12:50:05 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BRIDGEROOM:
|
2015-12-01 20:42:44 +00:00
|
|
|
Bridge->drawImage(x, y);
|
2014-10-06 12:50:05 +00:00
|
|
|
|
2015-12-02 10:49:01 +00:00
|
|
|
xx = x + (Bridge->_width - XMark->_width) / 2;
|
|
|
|
xy = y + (Bridge->_height - XMark->_height) / 2;
|
2014-10-06 12:50:05 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VCORRIDOR:
|
2015-12-01 20:42:44 +00:00
|
|
|
VRoom->drawImage(x, y);
|
2014-10-06 12:50:05 +00:00
|
|
|
|
2015-12-02 10:49:01 +00:00
|
|
|
offset = (VRoom->_width - Path->_width) / 2;
|
2014-10-06 12:50:05 +00:00
|
|
|
|
|
|
|
if (NORTHDOOR & flags)
|
2015-12-02 10:49:01 +00:00
|
|
|
Path->drawImage(x + offset, y - Path->_height);
|
2014-10-06 12:50:05 +00:00
|
|
|
|
|
|
|
if (SOUTHDOOR & flags)
|
2015-12-02 10:49:01 +00:00
|
|
|
Path->drawImage(x + offset, y + VRoom->_height);
|
2014-10-06 12:50:05 +00:00
|
|
|
|
2015-12-02 10:49:01 +00:00
|
|
|
offset = (Room->_height - Path->_height) / 2;
|
2014-10-06 12:50:05 +00:00
|
|
|
|
|
|
|
if (EASTDOOR & flags)
|
2015-12-02 10:49:01 +00:00
|
|
|
Path->drawImage(x + VRoom->_width, y + offset);
|
2014-10-06 12:50:05 +00:00
|
|
|
|
|
|
|
if (WESTDOOR & flags)
|
2015-12-02 10:49:01 +00:00
|
|
|
Path->drawImage(x - Path->_width, y + offset);
|
2014-10-06 12:50:05 +00:00
|
|
|
|
|
|
|
if (EASTBDOOR & flags)
|
2015-12-02 10:49:01 +00:00
|
|
|
Path->drawImage(x + VRoom->_width, y - offset - Path->_height + VRoom->_height);
|
2014-10-06 12:50:05 +00:00
|
|
|
|
|
|
|
if (WESTBDOOR & flags)
|
2015-12-02 10:49:01 +00:00
|
|
|
Path->drawImage(x - Path->_width, y - offset - Path->_height + VRoom->_height);
|
2014-10-06 12:50:05 +00:00
|
|
|
|
2015-12-02 10:49:01 +00:00
|
|
|
offset = (VRoom->_height - Path->_height) / 2;
|
2014-10-06 12:50:05 +00:00
|
|
|
|
|
|
|
if (EASTMDOOR & flags)
|
2015-12-02 10:49:01 +00:00
|
|
|
Path->drawImage(x + VRoom->_width, y - offset - Path->_height + VRoom->_height);
|
2014-10-06 12:50:05 +00:00
|
|
|
|
|
|
|
if (WESTMDOOR & flags)
|
2015-12-02 10:49:01 +00:00
|
|
|
Path->drawImage(x - Path->_width, y - offset - Path->_height + VRoom->_height);
|
2014-10-06 12:50:05 +00:00
|
|
|
|
2015-12-02 10:49:01 +00:00
|
|
|
xx = x + (VRoom->_width - XMark->_width) / 2;
|
|
|
|
xy = y + (VRoom->_height - XMark->_height) / 2;
|
2014-10-06 12:50:05 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HCORRIDOR:
|
2015-12-01 20:42:44 +00:00
|
|
|
HRoom->drawImage(x, y);
|
2014-10-06 12:50:05 +00:00
|
|
|
|
2015-12-02 10:49:01 +00:00
|
|
|
offset = (Room->_width - Path->_width) / 2;
|
2014-10-06 12:50:05 +00:00
|
|
|
|
|
|
|
if (NORTHDOOR & flags)
|
2015-12-02 10:49:01 +00:00
|
|
|
Path->drawImage(x + offset, y - Path->_height);
|
2014-10-06 12:50:05 +00:00
|
|
|
|
|
|
|
if (SOUTHDOOR & flags)
|
2015-12-02 10:49:01 +00:00
|
|
|
Path->drawImage(x + offset, y + Room->_height);
|
2014-10-06 12:50:05 +00:00
|
|
|
|
|
|
|
if (NORTHRDOOR & flags)
|
2015-12-02 10:49:01 +00:00
|
|
|
Path->drawImage(x - offset - Path->_width + HRoom->_width, y - Path->_height);
|
2014-10-06 12:50:05 +00:00
|
|
|
|
|
|
|
if (SOUTHRDOOR & flags)
|
2015-12-02 10:49:01 +00:00
|
|
|
Path->drawImage(x - offset - Path->_width + HRoom->_width, y + Room->_height);
|
2014-10-06 12:50:05 +00:00
|
|
|
|
2015-12-02 10:49:01 +00:00
|
|
|
offset = (HRoom->_width - Path->_width) / 2;
|
2014-10-06 12:50:05 +00:00
|
|
|
|
|
|
|
if (NORTHMDOOR & flags)
|
2015-12-02 10:49:01 +00:00
|
|
|
Path->drawImage(x - offset - Path->_width + HRoom->_width, y - Path->_height);
|
2014-10-06 12:50:05 +00:00
|
|
|
|
|
|
|
if (SOUTHMDOOR & flags)
|
2015-12-02 10:49:01 +00:00
|
|
|
Path->drawImage(x - offset - Path->_width + HRoom->_width, y + Room->_height);
|
2014-10-06 12:50:05 +00:00
|
|
|
|
2015-12-02 10:49:01 +00:00
|
|
|
offset = (Room->_height - Path->_height) / 2;
|
2014-10-06 12:50:05 +00:00
|
|
|
|
|
|
|
if (EASTDOOR & flags)
|
2015-12-02 10:49:01 +00:00
|
|
|
Path->drawImage(x + HRoom->_width, y + offset);
|
2014-10-06 12:50:05 +00:00
|
|
|
|
|
|
|
if (WESTDOOR & flags)
|
2015-12-02 10:49:01 +00:00
|
|
|
Path->drawImage(x - Path->_width, y + offset);
|
2014-10-06 12:50:05 +00:00
|
|
|
|
2015-12-02 10:49:01 +00:00
|
|
|
xx = x + (HRoom->_width - XMark->_width) / 2;
|
|
|
|
xy = y + (HRoom->_height - XMark->_height) / 2;
|
2014-10-06 12:50:05 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (drawx)
|
2015-12-01 20:42:44 +00:00
|
|
|
XMark->drawImage(xx, xy);
|
2014-10-06 12:50:05 +00:00
|
|
|
}
|
|
|
|
|
2015-12-08 08:46:54 +00:00
|
|
|
/**
|
|
|
|
* Checks if a floor has been visitted.
|
|
|
|
*/
|
2014-12-25 11:36:47 +00:00
|
|
|
static bool onFloor(uint16 Floor) {
|
2015-11-27 22:18:15 +00:00
|
|
|
for (uint16 i = 1; i <= MaxRooms; i++) {
|
|
|
|
if ((Maps[i].PageNumber == Floor) && g_lab->_roomsFound->in(i) && Maps[i].x)
|
2014-10-06 12:50:05 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-12-08 08:46:54 +00:00
|
|
|
/**
|
|
|
|
* Figures out which floor, if any, should be gone to if the up arrow is hit
|
|
|
|
*/
|
2014-12-25 18:13:52 +00:00
|
|
|
static void getUpFloor(uint16 *Floor, bool *isfloor) {
|
2014-10-06 12:50:05 +00:00
|
|
|
do {
|
|
|
|
*isfloor = true;
|
|
|
|
|
2015-12-08 15:08:04 +00:00
|
|
|
if (*Floor < kFloorUpper)
|
2014-10-06 12:50:05 +00:00
|
|
|
(*Floor)++;
|
|
|
|
else {
|
2015-12-08 15:08:04 +00:00
|
|
|
*Floor = kFloorCarnival + 1;
|
2014-10-06 12:50:05 +00:00
|
|
|
*isfloor = false;
|
|
|
|
return;
|
|
|
|
}
|
2015-12-08 15:08:04 +00:00
|
|
|
} while ((!onFloor(*Floor)) && (*Floor <= kFloorCarnival));
|
2014-10-06 12:50:05 +00:00
|
|
|
}
|
|
|
|
|
2015-12-08 08:46:54 +00:00
|
|
|
/**
|
|
|
|
* Figures out which floor, if any, should be gone to if the down arrow is
|
|
|
|
* hit.
|
|
|
|
*/
|
2014-12-25 18:13:52 +00:00
|
|
|
static void getDownFloor(uint16 *Floor, bool *isfloor) {
|
2014-10-06 12:50:05 +00:00
|
|
|
do {
|
|
|
|
*isfloor = true;
|
|
|
|
|
2015-12-08 15:08:04 +00:00
|
|
|
if ((*Floor == kFloorLower) || (*Floor == 0)) {
|
2014-10-06 12:50:05 +00:00
|
|
|
*Floor = 0;
|
|
|
|
*isfloor = false;
|
|
|
|
return;
|
2015-12-08 15:08:04 +00:00
|
|
|
} else if (*Floor > kFloorUpper) {
|
2015-10-13 22:51:18 +00:00
|
|
|
// Labyrinth specific code
|
2015-12-08 15:08:04 +00:00
|
|
|
if (*Floor == kFloorHedgeMaze)
|
|
|
|
*Floor = kFloorUpper;
|
|
|
|
else if ((*Floor == kFloorCarnival) || (*Floor == kFloorMedMaze))
|
|
|
|
*Floor = kFloorMiddle;
|
|
|
|
else if (*Floor == kFloorSurMaze)
|
|
|
|
*Floor = kFloorLower;
|
2014-10-06 12:50:05 +00:00
|
|
|
else {
|
|
|
|
*Floor = 0;
|
|
|
|
*isfloor = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
(*Floor)--;
|
|
|
|
|
2014-12-25 18:13:52 +00:00
|
|
|
} while ((!onFloor(*Floor)) && *Floor);
|
2014-10-06 12:50:05 +00:00
|
|
|
}
|
|
|
|
|
2015-12-08 08:46:54 +00:00
|
|
|
/**
|
|
|
|
* Draws the map
|
|
|
|
*/
|
2015-11-29 17:10:06 +00:00
|
|
|
void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, bool fadein) {
|
2014-10-06 12:50:05 +00:00
|
|
|
char *sptr;
|
|
|
|
|
|
|
|
uint16 tempfloor;
|
2015-12-03 12:22:04 +00:00
|
|
|
bool noOverlay;
|
2014-10-06 12:50:05 +00:00
|
|
|
|
2015-11-29 17:10:06 +00:00
|
|
|
_event->mouseHide();
|
2014-10-06 12:50:05 +00:00
|
|
|
|
|
|
|
if (fadeout)
|
2015-12-06 17:16:26 +00:00
|
|
|
_graphics->fade(false, 0);
|
2014-10-06 12:50:05 +00:00
|
|
|
|
2015-12-04 12:32:08 +00:00
|
|
|
_graphics->setAPen(0);
|
2015-12-06 13:36:49 +00:00
|
|
|
_graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1);
|
2014-10-06 12:50:05 +00:00
|
|
|
|
2015-12-01 20:42:44 +00:00
|
|
|
Map->drawImage(0, 0);
|
2015-12-08 14:53:30 +00:00
|
|
|
drawGadgetList(&_mapGadgetList);
|
2014-10-06 12:50:05 +00:00
|
|
|
|
2015-11-27 22:18:15 +00:00
|
|
|
for (uint16 i = 1; i <= MaxRooms; i++) {
|
2015-11-29 22:34:35 +00:00
|
|
|
if ((Maps[i].PageNumber == Floor) && _roomsFound->in(i) && Maps[i].x) {
|
2015-12-08 15:08:04 +00:00
|
|
|
drawRoomMap(i, (bool)(i == CurRoom));
|
2015-11-30 00:17:05 +00:00
|
|
|
_music->updateMusic();
|
2014-10-06 12:50:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-08 10:27:34 +00:00
|
|
|
// 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
|
2015-12-08 08:19:00 +00:00
|
|
|
if ((Maps[CurRoom].PageNumber == Floor) && _roomsFound->in(CurRoom) && Maps[CurRoom].x)
|
2015-12-08 15:08:04 +00:00
|
|
|
drawRoomMap(CurRoom, true);
|
2014-10-06 12:50:05 +00:00
|
|
|
|
|
|
|
tempfloor = Floor;
|
2015-12-03 12:22:04 +00:00
|
|
|
getUpFloor(&tempfloor, &noOverlay);
|
2014-10-06 12:50:05 +00:00
|
|
|
|
2015-12-08 14:53:30 +00:00
|
|
|
Gadget *upGadget = _event->getGadget(1);
|
|
|
|
Gadget *downGadget = _event->getGadget(2);
|
|
|
|
|
2015-12-03 12:22:04 +00:00
|
|
|
if (noOverlay)
|
2015-12-08 14:53:30 +00:00
|
|
|
enableGadget(upGadget);
|
2014-10-06 12:50:05 +00:00
|
|
|
else
|
2015-12-08 14:53:30 +00:00
|
|
|
disableGadget(upGadget, 12);
|
2014-10-06 12:50:05 +00:00
|
|
|
|
|
|
|
tempfloor = Floor;
|
2015-12-03 12:22:04 +00:00
|
|
|
getDownFloor(&tempfloor, &noOverlay);
|
2014-10-06 12:50:05 +00:00
|
|
|
|
2015-12-03 12:22:04 +00:00
|
|
|
if (noOverlay)
|
2015-12-08 14:53:30 +00:00
|
|
|
enableGadget(downGadget);
|
2014-10-06 12:50:05 +00:00
|
|
|
else
|
2015-12-08 14:53:30 +00:00
|
|
|
disableGadget(downGadget, 12);
|
2014-10-06 12:50:05 +00:00
|
|
|
|
2015-10-13 22:51:18 +00:00
|
|
|
// Labyrinth specific code
|
2015-12-08 15:08:04 +00:00
|
|
|
if (Floor == kFloorLower) {
|
|
|
|
if (onFloor(kFloorSurMaze))
|
2015-12-01 20:42:44 +00:00
|
|
|
Maze->drawImage(mapScaleX(538), mapScaleY(277));
|
2015-12-08 15:08:04 +00:00
|
|
|
} else if (Floor == kFloorMiddle) {
|
|
|
|
if (onFloor(kFloorCarnival))
|
2015-12-01 20:42:44 +00:00
|
|
|
Maze->drawImage(mapScaleX(358), mapScaleY(72));
|
2014-10-06 12:50:05 +00:00
|
|
|
|
2015-12-08 15:08:04 +00:00
|
|
|
if (onFloor(kFloorMedMaze))
|
2015-12-01 20:42:44 +00:00
|
|
|
Maze->drawImage(mapScaleX(557), mapScaleY(325));
|
2015-12-08 15:08:04 +00:00
|
|
|
} else if (Floor == kFloorUpper) {
|
|
|
|
if (onFloor(kFloorHedgeMaze))
|
2015-12-01 20:42:44 +00:00
|
|
|
HugeMaze->drawImage(mapScaleX(524), mapScaleY(97));
|
2015-12-08 15:08:04 +00:00
|
|
|
} else if (Floor == kFloorSurMaze) {
|
2015-11-29 23:34:43 +00:00
|
|
|
sptr = (char *)_resource->getStaticText(kTextSurmazeMessage).c_str();
|
2015-12-04 12:32:08 +00:00
|
|
|
_graphics->flowText(_msgFont, 0, 7, 0, true, true, true, true, mapScaleX(360), 0, mapScaleX(660), mapScaleY(450), sptr);
|
2014-10-06 12:50:05 +00:00
|
|
|
}
|
|
|
|
|
2015-12-08 15:08:04 +00:00
|
|
|
if (Floor >= kFloorLower && Floor <= kFloorCarnival) {
|
2015-12-05 20:35:38 +00:00
|
|
|
sptr = (char *)_resource->getStaticText(Floor - 1).c_str();
|
2015-12-05 20:20:26 +00:00
|
|
|
_graphics->flowTextScaled(_msgFont, 0, 5, 3, true, true, true, true, 14, 75, 134, 97, sptr);
|
2015-12-05 20:35:38 +00:00
|
|
|
}
|
2014-10-06 12:50:05 +00:00
|
|
|
|
2015-11-28 01:27:02 +00:00
|
|
|
if ((sptr = _rooms[CurMsg]._roomMsg))
|
2015-12-05 20:20:26 +00:00
|
|
|
_graphics->flowTextScaled(_msgFont, 0, 5, 3, true, true, true, true, 14, 148, 134, 186, sptr);
|
2014-10-06 12:50:05 +00:00
|
|
|
|
|
|
|
if (fadein)
|
2015-12-06 17:16:26 +00:00
|
|
|
_graphics->fade(true, 0);
|
2014-10-06 12:50:05 +00:00
|
|
|
|
2015-11-29 17:10:06 +00:00
|
|
|
_event->mouseShow();
|
2014-10-06 12:50:05 +00:00
|
|
|
}
|
|
|
|
|
2015-12-08 08:46:54 +00:00
|
|
|
/**
|
|
|
|
* Processes the map.
|
|
|
|
*/
|
2015-11-29 17:10:06 +00:00
|
|
|
void LabEngine::processMap(uint16 CurRoom) {
|
2014-10-06 12:50:05 +00:00
|
|
|
uint32 Class, place = 1;
|
2015-11-27 22:18:15 +00:00
|
|
|
uint16 Code, Qualifier, MouseX, MouseY, GadgetID, CurFloor, OldFloor, OldMsg, CurMsg, x1, y1, x2, y2;
|
2014-12-14 16:46:40 +00:00
|
|
|
char *sptr;
|
|
|
|
byte newcolor[3];
|
2014-10-06 12:50:05 +00:00
|
|
|
bool drawmap;
|
2014-12-25 23:32:42 +00:00
|
|
|
IntuiMessage *Msg;
|
2014-10-06 12:50:05 +00:00
|
|
|
|
|
|
|
CurMsg = CurRoom;
|
|
|
|
CurFloor = Maps[CurRoom].PageNumber;
|
|
|
|
|
|
|
|
while (1) {
|
2015-12-08 10:27:34 +00:00
|
|
|
// Make sure we check the music at least after every message
|
|
|
|
_music->updateMusic();
|
2014-10-06 12:50:05 +00:00
|
|
|
Msg = getMsg();
|
|
|
|
|
|
|
|
if (Msg == NULL) {
|
2015-11-30 00:17:05 +00:00
|
|
|
_music->updateMusic();
|
2014-10-06 12:50:05 +00:00
|
|
|
|
|
|
|
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];
|
|
|
|
}
|
|
|
|
|
2015-11-29 22:34:35 +00:00
|
|
|
waitTOF();
|
2015-12-06 13:36:49 +00:00
|
|
|
_graphics->writeColorRegs(newcolor, 1, 1);
|
2015-11-29 17:10:06 +00:00
|
|
|
_event->updateMouse();
|
2015-11-29 22:34:35 +00:00
|
|
|
waitTOF();
|
2015-11-29 17:10:06 +00:00
|
|
|
_event->updateMouse();
|
2015-11-29 22:34:35 +00:00
|
|
|
waitTOF();
|
2015-11-29 17:10:06 +00:00
|
|
|
_event->updateMouse();
|
2015-11-29 22:34:35 +00:00
|
|
|
waitTOF();
|
2015-11-29 17:10:06 +00:00
|
|
|
_event->updateMouse();
|
2014-10-06 12:50:05 +00:00
|
|
|
|
|
|
|
place++;
|
|
|
|
|
|
|
|
if (place >= 28)
|
|
|
|
place = 1;
|
|
|
|
|
|
|
|
} else {
|
2015-12-07 06:18:16 +00:00
|
|
|
Class = Msg->_msgClass;
|
|
|
|
Code = Msg->_code;
|
|
|
|
GadgetID = Msg->_gadgetID;
|
|
|
|
Qualifier = Msg->_qualifier;
|
|
|
|
MouseX = Msg->_mouseX;
|
|
|
|
MouseY = Msg->_mouseY;
|
2014-10-06 12:50:05 +00:00
|
|
|
|
2015-12-08 08:19:00 +00:00
|
|
|
if (((Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) || ((Class == RAWKEY) && (Code == 27)))
|
2014-10-06 12:50:05 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (Class == GADGETUP) {
|
2015-12-08 10:27:34 +00:00
|
|
|
if (GadgetID == 0) {
|
|
|
|
// Quit menu button
|
2014-10-06 12:50:05 +00:00
|
|
|
return;
|
2015-12-08 10:27:34 +00:00
|
|
|
} else if (GadgetID == 1) {
|
|
|
|
// Up arrow
|
2014-10-06 12:50:05 +00:00
|
|
|
OldFloor = CurFloor;
|
2014-12-25 18:13:52 +00:00
|
|
|
getUpFloor(&CurFloor, &drawmap);
|
2014-10-06 12:50:05 +00:00
|
|
|
|
|
|
|
if (drawmap) {
|
2015-12-06 17:16:26 +00:00
|
|
|
_graphics->fade(false, 0);
|
2014-12-25 18:13:52 +00:00
|
|
|
drawMap(CurRoom, CurMsg, CurFloor, false, false);
|
2015-12-06 17:16:26 +00:00
|
|
|
_graphics->fade(true, 0);
|
2014-10-06 12:50:05 +00:00
|
|
|
} else
|
|
|
|
CurFloor = OldFloor;
|
2015-12-08 10:27:34 +00:00
|
|
|
} else if (GadgetID == 2) {
|
|
|
|
// Down arrow
|
2014-10-06 12:50:05 +00:00
|
|
|
OldFloor = CurFloor;
|
2014-12-25 18:13:52 +00:00
|
|
|
getDownFloor(&CurFloor, &drawmap);
|
2014-10-06 12:50:05 +00:00
|
|
|
|
|
|
|
if (drawmap) {
|
2015-12-06 17:16:26 +00:00
|
|
|
_graphics->fade(false, 0);
|
2014-12-25 18:13:52 +00:00
|
|
|
drawMap(CurRoom, CurMsg, CurFloor, false, false);
|
2015-12-06 17:16:26 +00:00
|
|
|
_graphics->fade(true, 0);
|
2014-10-06 12:50:05 +00:00
|
|
|
} else
|
|
|
|
CurFloor = OldFloor;
|
|
|
|
}
|
2015-12-08 08:19:00 +00:00
|
|
|
} else if ((Class == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & Qualifier)) {
|
2015-12-08 15:08:04 +00:00
|
|
|
if ((CurFloor == kFloorLower) && (MouseX >= mapScaleX(538)) && (MouseY >= mapScaleY(277))
|
2015-12-08 08:19:00 +00:00
|
|
|
&& (MouseX <= mapScaleX(633)) && (MouseY <= mapScaleY(352))
|
2015-12-08 15:08:04 +00:00
|
|
|
&& onFloor(kFloorSurMaze)) {
|
|
|
|
CurFloor = kFloorSurMaze;
|
2014-10-06 12:50:05 +00:00
|
|
|
|
2015-12-06 17:16:26 +00:00
|
|
|
_graphics->fade(false, 0);
|
2014-12-25 18:13:52 +00:00
|
|
|
drawMap(CurRoom, CurMsg, CurFloor, false, false);
|
2015-12-06 17:16:26 +00:00
|
|
|
_graphics->fade(true, 0);
|
2015-12-08 15:08:04 +00:00
|
|
|
} else if ((CurFloor == kFloorMiddle) && (MouseX >= mapScaleX(358)) && (MouseY >= mapScaleY(71))
|
2015-12-08 08:19:00 +00:00
|
|
|
&& (MouseX <= mapScaleX(452)) && (MouseY <= mapScaleY(147))
|
2015-12-08 15:08:04 +00:00
|
|
|
&& onFloor(kFloorCarnival)) {
|
|
|
|
CurFloor = kFloorCarnival;
|
2014-10-06 12:50:05 +00:00
|
|
|
|
2015-12-06 17:16:26 +00:00
|
|
|
_graphics->fade(false, 0);
|
2014-12-25 18:13:52 +00:00
|
|
|
drawMap(CurRoom, CurMsg, CurFloor, false, false);
|
2015-12-06 17:16:26 +00:00
|
|
|
_graphics->fade(true, 0);
|
2015-12-08 15:08:04 +00:00
|
|
|
} else if ((CurFloor == kFloorMiddle) && (MouseX >= mapScaleX(557)) && (MouseY >= mapScaleY(325))
|
2015-12-08 08:19:00 +00:00
|
|
|
&& (MouseX <= mapScaleX(653)) && (MouseY <= mapScaleY(401))
|
2015-12-08 15:08:04 +00:00
|
|
|
&& onFloor(kFloorMedMaze)) {
|
|
|
|
CurFloor = kFloorMedMaze;
|
2014-10-06 12:50:05 +00:00
|
|
|
|
2015-12-06 17:16:26 +00:00
|
|
|
_graphics->fade(false, 0);
|
2014-12-25 18:13:52 +00:00
|
|
|
drawMap(CurRoom, CurMsg, CurFloor, false, false);
|
2015-12-06 17:16:26 +00:00
|
|
|
_graphics->fade(true, 0);
|
2015-12-08 15:08:04 +00:00
|
|
|
} else if ((CurFloor == kFloorUpper) && (MouseX >= mapScaleX(524)) && (MouseY >= mapScaleY(97))
|
2015-12-08 08:19:00 +00:00
|
|
|
&& (MouseX <= mapScaleX(645)) && (MouseY <= mapScaleY(207))
|
2015-12-08 15:08:04 +00:00
|
|
|
&& onFloor(kFloorHedgeMaze)) {
|
|
|
|
CurFloor = kFloorHedgeMaze;
|
2014-10-06 12:50:05 +00:00
|
|
|
|
2015-12-06 17:16:26 +00:00
|
|
|
_graphics->fade(false, 0);
|
2014-12-25 18:13:52 +00:00
|
|
|
drawMap(CurRoom, CurMsg, CurFloor, false, false);
|
2015-12-06 17:16:26 +00:00
|
|
|
_graphics->fade(true, 0);
|
2015-12-08 08:19:00 +00:00
|
|
|
} else if (MouseX > mapScaleX(314)) {
|
2014-10-06 12:50:05 +00:00
|
|
|
OldMsg = CurMsg;
|
|
|
|
|
2015-11-27 22:18:15 +00:00
|
|
|
for (uint16 i = 1; i <= MaxRooms; i++) {
|
2015-12-04 00:10:55 +00:00
|
|
|
roomCoords(i, &x1, &y1, &x2, &y2);
|
2014-10-06 12:50:05 +00:00
|
|
|
|
2015-11-27 22:18:15 +00:00
|
|
|
if ((Maps[i].PageNumber == CurFloor)
|
2015-12-08 08:19:00 +00:00
|
|
|
&& _roomsFound->in(i)
|
|
|
|
&& (MouseX >= x1) && (MouseX <= x2)
|
|
|
|
&& (MouseY >= y1) && (MouseY <= y2)) {
|
2015-11-27 22:18:15 +00:00
|
|
|
CurMsg = i;
|
2014-10-06 12:50:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (OldMsg != CurMsg) {
|
2015-11-28 01:27:02 +00:00
|
|
|
if (_rooms[CurMsg]._roomMsg == nullptr)
|
2015-11-29 23:34:43 +00:00
|
|
|
_resource->readViews(CurMsg);
|
2014-10-06 12:50:05 +00:00
|
|
|
|
2015-11-28 01:27:02 +00:00
|
|
|
if ((sptr = _rooms[CurMsg]._roomMsg)) {
|
2015-11-29 17:10:06 +00:00
|
|
|
_event->mouseHide();
|
2015-12-04 12:32:08 +00:00
|
|
|
_graphics->setAPen(3);
|
2015-12-05 20:20:26 +00:00
|
|
|
_graphics->rectFillScaled(13, 148, 135, 186);
|
|
|
|
_graphics->flowTextScaled(_msgFont, 0, 5, 3, true, true, true, true, 14, 148, 134, 186, sptr);
|
2014-10-06 12:50:05 +00:00
|
|
|
|
|
|
|
if (Maps[OldMsg].PageNumber == CurFloor)
|
2015-12-08 15:08:04 +00:00
|
|
|
drawRoomMap(OldMsg, (bool)(OldMsg == CurRoom));
|
2014-10-06 12:50:05 +00:00
|
|
|
|
2015-12-04 00:10:55 +00:00
|
|
|
roomCoords(CurMsg, &x1, &y1, &x2, &y2);
|
2014-10-06 12:50:05 +00:00
|
|
|
x1 = (x1 + x2) / 2;
|
|
|
|
y1 = (y1 + y2) / 2;
|
|
|
|
|
|
|
|
if ((CurMsg != CurRoom) && (Maps[CurMsg].PageNumber == CurFloor)) {
|
2015-12-04 12:32:08 +00:00
|
|
|
_graphics->setAPen(1);
|
|
|
|
_graphics->rectFill(x1 - 1, y1, x1, y1);
|
2014-10-06 12:50:05 +00:00
|
|
|
}
|
|
|
|
|
2015-11-29 17:10:06 +00:00
|
|
|
_event->mouseShow();
|
2014-10-06 12:50:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-04 12:32:08 +00:00
|
|
|
_graphics->screenUpdate();
|
2014-10-06 12:50:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-08 08:46:54 +00:00
|
|
|
/**
|
|
|
|
* Does the map processing.
|
|
|
|
*/
|
2015-11-29 17:10:06 +00:00
|
|
|
void LabEngine::doMap(uint16 CurRoom) {
|
2015-12-06 17:16:26 +00:00
|
|
|
static uint16 AmigaMapPalette[] = {
|
|
|
|
0x0BA8, 0x0C11, 0x0A74, 0x0076,
|
|
|
|
0x0A96, 0x0DCB, 0x0CCA, 0x0222,
|
|
|
|
0x0444, 0x0555, 0x0777, 0x0999,
|
|
|
|
0x0AAA, 0x0ED0, 0x0EEE, 0x0694
|
|
|
|
};
|
|
|
|
|
|
|
|
_graphics->FadePalette = AmigaMapPalette;
|
2014-10-06 12:50:05 +00:00
|
|
|
|
2015-11-30 00:17:05 +00:00
|
|
|
_music->updateMusic();
|
2014-10-06 12:50:05 +00:00
|
|
|
loadMapData();
|
2015-12-04 12:32:08 +00:00
|
|
|
_graphics->blackAllScreen();
|
2014-10-06 12:50:05 +00:00
|
|
|
|
2015-12-06 16:24:25 +00:00
|
|
|
if (_direction == NORTH)
|
2014-10-06 12:50:05 +00:00
|
|
|
XMark = MapNorth;
|
2015-12-06 16:24:25 +00:00
|
|
|
else if (_direction == SOUTH)
|
2014-10-06 12:50:05 +00:00
|
|
|
XMark = MapSouth;
|
2015-12-06 16:24:25 +00:00
|
|
|
else if (_direction == EAST)
|
2014-10-06 12:50:05 +00:00
|
|
|
XMark = MapEast;
|
2015-12-06 16:24:25 +00:00
|
|
|
else if (_direction == WEST)
|
2014-10-06 12:50:05 +00:00
|
|
|
XMark = MapWest;
|
|
|
|
|
2015-12-08 14:53:30 +00:00
|
|
|
_event->attachGadgetList(&_mapGadgetList);
|
2014-12-25 18:13:52 +00:00
|
|
|
drawMap(CurRoom, CurRoom, Maps[CurRoom].PageNumber, false, true);
|
2015-11-29 17:10:06 +00:00
|
|
|
_event->mouseShow();
|
2015-12-04 12:32:08 +00:00
|
|
|
_graphics->screenUpdate();
|
2014-12-25 18:13:52 +00:00
|
|
|
processMap(CurRoom);
|
2015-11-29 17:10:06 +00:00
|
|
|
_event->attachGadgetList(NULL);
|
2015-12-06 17:16:26 +00:00
|
|
|
_graphics->fade(false, 0);
|
2015-12-04 12:32:08 +00:00
|
|
|
_graphics->blackAllScreen();
|
2015-11-29 17:10:06 +00:00
|
|
|
_event->mouseHide();
|
2015-12-04 12:32:08 +00:00
|
|
|
_graphics->setAPen(0);
|
2015-12-06 13:36:49 +00:00
|
|
|
_graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1);
|
2015-10-13 22:51:18 +00:00
|
|
|
freeMapData();
|
2015-12-04 12:32:08 +00:00
|
|
|
_graphics->blackAllScreen();
|
2015-11-29 17:10:06 +00:00
|
|
|
_event->mouseShow();
|
2015-12-04 12:32:08 +00:00
|
|
|
_graphics->screenUpdate();
|
2014-10-06 12:50:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // End of namespace Lab
|