aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/lab/labfun.h8
-rw-r--r--engines/lab/labtext.cpp49
-rw-r--r--engines/lab/map.cpp8
-rw-r--r--engines/lab/module.mk2
-rw-r--r--engines/lab/parsefun.h6
-rw-r--r--engines/lab/processroom.cpp6
-rw-r--r--engines/lab/readparse.cpp292
7 files changed, 9 insertions, 362 deletions
diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h
index 3a77855f17..c9fa307a84 100644
--- a/engines/lab/labfun.h
+++ b/engines/lab/labfun.h
@@ -155,14 +155,6 @@ Common::File *openPartial(const char *name);
void closePartial(int32 File);
/*---------------------------*/
-/*------ From LabText.c -----*/
-/*---------------------------*/
-
-bool initLabText();
-void freeLabText();
-void decrypt(byte *text);
-
-/*---------------------------*/
/*----- From LabMusic.c -----*/
/*---------------------------*/
diff --git a/engines/lab/labtext.cpp b/engines/lab/labtext.cpp
deleted file mode 100644
index 9955c43b70..0000000000
--- a/engines/lab/labtext.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-/* 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/stddefines.h"
-#include "lab/labfun.h"
-
-namespace Lab {
-
-static uint32 SizeOfMemChunk;
-static char *BeginOfMemChunk, *CurPlace;
-
-
-/*****************************************************************************/
-/* Decrypts a chunk of text. */
-/*****************************************************************************/
-void decrypt(byte *text) {
- while (text && *text != '\0') {
- *text++ -= (byte)95;
- }
-}
-
-} // End of namespace Lab
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();
diff --git a/engines/lab/module.mk b/engines/lab/module.mk
index 1520672573..f36871c8a5 100644
--- a/engines/lab/module.mk
+++ b/engines/lab/module.mk
@@ -11,13 +11,11 @@ MODULE_OBJS := \
labfile.o \
labmusic.o \
labsets.o \
- labtext.o \
machine.o \
map.o \
mouse.o \
processroom.o \
readdiff.o \
- readparse.o \
resource.o \
savegame.o \
special.o \
diff --git a/engines/lab/parsefun.h b/engines/lab/parsefun.h
index b75368d25d..b634e9c120 100644
--- a/engines/lab/parsefun.h
+++ b/engines/lab/parsefun.h
@@ -48,12 +48,6 @@ bool initRoomBuffer();
void freeRoomBuffer();
void allocRoom(void **Ptr, uint16 Size, uint16 RoomNum);
-/* From ReadParse.c */
-
-bool readRoomData(const char *fileName);
-bool readInventory(const char *fileName);
-bool readViews(uint16 RoomNum);
-
/* From ProcessRoom.c */
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 87f3e58549..19e958825d 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -108,7 +108,7 @@ ViewDataPtr getViewData(uint16 roomNum, uint16 direction) {
VPtr = &Rooms[roomNum].WestView;
if (*VPtr == NULL)
- readViews(roomNum);
+ g_resource->readViews(roomNum);
ViewPtr = *VPtr;
@@ -640,7 +640,7 @@ static bool doActionRuleSub(int16 action, int16 roomNum, CloseDataPtr LCPtr, Clo
RPtr = Rooms[roomNum].RuleList;
if ((RPtr == NULL) && (roomNum == 0)) {
- readViews(roomNum);
+ g_resource->readViews(roomNum);
RPtr = Rooms[roomNum].RuleList;
}
@@ -702,7 +702,7 @@ static bool doOperateRuleSub(int16 ItemNum, int16 roomNum, CloseDataPtr LCPtr, C
RPtr = Rooms[roomNum].RuleList;
if ((RPtr == NULL) && (roomNum == 0)) {
- readViews(roomNum);
+ g_resource->readViews(roomNum);
RPtr = Rooms[roomNum].RuleList;
}
diff --git a/engines/lab/readparse.cpp b/engines/lab/readparse.cpp
deleted file mode 100644
index 624f7a3b89..0000000000
--- a/engines/lab/readparse.cpp
+++ /dev/null
@@ -1,292 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-/*
- * This code is based on Labyrinth of Time code with assistance of
- *
- * Copyright (c) 1993 Terra Nova Development
- * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
- *
- */
-
-#include "lab/labfun.h"
-#include "lab/parsetypes.h"
-#include "lab/parsefun.h"
-#include "lab/stddefines.h"
-
-namespace Lab {
-
-/* Global parser data */
-
-#define MAXSTRINGLENGTH 250
-
-static bool UseMemory = false;
-static uint16 allocroom;
-
-extern RoomData *Rooms;
-extern InventoryData *Inventory;
-extern uint16 NumInv, ManyRooms, HighestCondition, Direction;
-
-static bool rallocate(void **Ptr, uint32 Size) {
- if (UseMemory)
- return ((*Ptr = calloc(Size, 1)) != 0);
- else {
- allocRoom(Ptr, (uint16) Size, allocroom);
- return true;
- }
-}
-
-
-
-/*****************************************************************************/
-/* Reads in a NULL terminated string, and allocates memory for it. */
-/*****************************************************************************/
-static bool readString(char **string, byte **file) {
- char len;
- uint32 counter = 0L;
-
-
- readBlock(&len, 1L, file);
-
- if (len) {
- counter = len;
-
- if (rallocate((void **) string, counter)) {
- readBlock(*string, counter, file);
- (*string)[counter - 1] = 0; /* Sanity modification */
- decrypt((byte *)*string);
- return true;
- }
- } else {
- *string = NULL;
- return true;
- }
-
- return false;
-}
-
-
-/*****************************************************************************/
-/* Reads in a list of conditions. */
-/*****************************************************************************/
-static int16 *readConditions(byte **file) {
- int16 Counter = 0, last, list[25], *ptr;
-
- do {
- readBlock(&last, 2L, file);
- swapUShortPtr((uint16 *)&last, 1);
-
- if (Counter < 25) {
- list[Counter] = last;
- Counter++;
- } else
- list[Counter] = 0;
- } while (last);
-
- if (!rallocate((void **) & (ptr), Counter * 2L))
- return NULL;
-
- memcpy(ptr, list, (size_t)(Counter * 2L));
-
- return ptr;
-}
-
-/*****************************************************************************/
-/* Reads in some CloseUp data. */
-/*****************************************************************************/
-static bool readCloseUps(CloseDataPtr *CPtr, uint16 depth, byte **file) {
- char c;
-
- while (1) {
- *CPtr = NULL;
-
- readBlock(&c, 1L, file);
-
- if (c != '\0') {
- if (rallocate((void **) CPtr, sizeof(CloseData))) {
- (*CPtr)->SubCloseUps = NULL;
- (*CPtr)->NextCloseUp = NULL;
- (*CPtr)->depth = depth;
-
- readBlock(*CPtr, 10L, file);
- swapUShortPtr((uint16 *)*CPtr, 5);
-
- if (!readString(&((*CPtr)->GraphicName), file))
- return false;
-
- if (!readString(&((*CPtr)->Message), file))
- return false;
-
- if (!readCloseUps(&((*CPtr)->SubCloseUps), depth + 1, file))
- return false;
-
- CPtr = &((*CPtr)->NextCloseUp);
- } else
- return false;
- } else
- return true;
- }
-}
-
-
-/*****************************************************************************/
-/* Reads in a View. */
-/*****************************************************************************/
-static bool readView(ViewDataPtr *VPtr, byte **file) {
- char c;
-
- while (1) {
- *VPtr = NULL;
-
- readBlock(&c, 1L, file);
-
- if (c == 1) {
- if (rallocate((void **)VPtr, sizeof(viewData))) {
- (*VPtr)->closeUps = NULL;
- (*VPtr)->NextCondition = NULL;
-
- (*VPtr)->Condition = readConditions(file);
-
- if (!(*VPtr)->Condition)
- return false;
-
- if (!readString(&((*VPtr)->GraphicName), file))
- return false;
-
- readCloseUps(&((*VPtr)->closeUps), 0, file);
-
- VPtr = &((*VPtr)->NextCondition);
- }
- else
- return false;
- }
- else
- return true;
- }
-}
-
-
-/*****************************************************************************/
-/* Reads in an Action. */
-/*****************************************************************************/
-static bool readAction(ActionPtr *APtr, byte **file) {
- char c;
- byte **ptrarray;
- uint16 counter;
-
- while (1) {
- *APtr = NULL;
-
- readBlock(&c, 1L, file);
-
- if (c == 1) {
- if (rallocate((void **) APtr, sizeof(Action))) {
- readBlock(*APtr, 8L, file);
- swapShortPtr((int16 *)*APtr, 4);
-
- if ((*APtr)->ActionType == SHOWMESSAGES) {
- if (!rallocate((void **) &ptrarray, 4L * (*APtr)->Param1))
- return false;
-
- for (counter = 0; counter < (*APtr)->Param1; counter++)
- readString((char **) & (ptrarray[counter]), file);
-
- (*APtr)->Data = (byte *)ptrarray;
- } else
- readString((char **) & ((*APtr)->Data), file);
-
- APtr = &((*APtr)->NextAction);
- } else
- return false;
- } else
- return true;
- }
-}
-
-
-/*****************************************************************************/
-/* Reads in a rule. */
-/*****************************************************************************/
-static bool readRule(RulePtr *RPtr, byte **file) {
- char c;
-
- while (1) {
- *RPtr = NULL;
- readBlock(&c, 1L, file);
-
- if (c == 1) {
- if (rallocate((void **) RPtr, sizeof(Rule))) {
- readBlock(*RPtr, 6L, file);
- swapShortPtr((int16 *)*RPtr, 3);
-
- (*RPtr)->Condition = readConditions(file);
-
- if (!(*RPtr)->Condition)
- return false;
-
- readAction(&((*RPtr)->ActionList), file);
- } else
- return false;
-
- RPtr = &((*RPtr)->NextRule);
- } else
- return true;
- }
-}
-
-
-/*****************************************************************************/
-/* Reads in the views of a room. */
-/*****************************************************************************/
-bool readViews(uint16 RoomNum) {
- Common::String fileName = "LAB:Rooms/" + Common::String::format("%d", RoomNum);
- char Temp[10];
- byte **file;
-
- allocroom = RoomNum;
-
- if ((file = g_music->newOpen(fileName.c_str())) != NULL) {
- readBlock(Temp, 4L, file);
- Temp[4] = '\0';
-
- if (strcmp(Temp, "ROM4") != 0)
- return false;
-
- readString(&(Rooms[RoomNum].RoomMsg), file);
-
- readView(&Rooms[RoomNum].NorthView, file);
- readView(&Rooms[RoomNum].SouthView, file);
- readView(&Rooms[RoomNum].EastView, file);
- readView(&Rooms[RoomNum].WestView, file);
-
- readRule(&Rooms[RoomNum].RuleList, file);
-
- g_music->updateMusic();
-
- return true;
- } else
- return false;
-
- return false;
-}
-
-} // End of namespace Lab