aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/lab/anim.cpp5
-rw-r--r--engines/lab/anim.h1
-rw-r--r--engines/lab/labfile.cpp88
-rw-r--r--engines/lab/labfun.h6
-rw-r--r--engines/lab/module.mk1
-rw-r--r--engines/lab/resource.cpp47
-rw-r--r--engines/lab/resource.h1
7 files changed, 41 insertions, 108 deletions
diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp
index 5ecfa72402..f7770ade7b 100644
--- a/engines/lab/anim.cpp
+++ b/engines/lab/anim.cpp
@@ -414,6 +414,11 @@ void Anim::unDiff(byte *newBuf, byte *oldBuf, byte *diffData, uint16 bytesPerRow
unDIFFMemory(newBuf, diffData, 1, bufType + 1);
}
+void Anim::readBlock(void *Buffer, uint32 Size, byte **File) {
+ memcpy(Buffer, *File, (size_t)Size);
+ (*File) += Size;
+}
+
void Anim::diffNextFrame() {
if (_header == 65535) /* Already done. */
return;
diff --git a/engines/lab/anim.h b/engines/lab/anim.h
index 170e84d14b..6c4c8bed60 100644
--- a/engines/lab/anim.h
+++ b/engines/lab/anim.h
@@ -93,6 +93,7 @@ private:
void VUnDIFFByteByte(byte *Dest, byte *diff, uint16 bytesperrow);
void VUnDIFFByteWord(uint16 *Dest, uint16 *diff, uint16 bytesperrow);
void VUnDIFFByteLong(uint32 *Dest, uint32 *diff, uint16 bytesperrow);
+ void readBlock(void *Buffer, uint32 Size, byte **File);
public:
Anim(LabEngine *vm);
diff --git a/engines/lab/labfile.cpp b/engines/lab/labfile.cpp
deleted file mode 100644
index 579316c07c..0000000000
--- a/engines/lab/labfile.cpp
+++ /dev/null
@@ -1,88 +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/lab.h"
-#include "lab/labfun.h"
-#include "common/file.h"
-
-namespace Lab {
-
-
-/*****************************************************************************/
-/* Reads a block of memory. */
-/*****************************************************************************/
-void readBlock(void *Buffer, uint32 Size, byte **File) {
- memcpy(Buffer, *File, (size_t) Size);
- (*File) += Size;
-}
-
-static char NewFileName[255];
-
-/*****************************************************************************/
-/* Modifies the filename so that paths and stuff are correct. Should mostly */
-/* deal with assigns and the '/' instead of '\' on IBM systems. */
-/* */
-/* NOTE: Make a *copy* of the string, and modify that. It would be a real */
-/* *bad* idea to modify the original. Since Labyrinth only focuses its */
-/* attention to one file at a time, it would be fine to have one variable */
-/* not on the stack which is used to store the new filename. */
-/*****************************************************************************/
-char *translateFileName(const char *filename) {
- Common::String fileNameStr = filename;
- fileNameStr.toUppercase();
- Common::String fileNameStrFinal;
-
- if (fileNameStr.hasPrefix("P:")) {
- if (g_lab->_isHiRes)
- fileNameStrFinal = "GAME/SPICT/";
- else
- fileNameStrFinal = "GAME/PICT/";
- } else if (fileNameStr.hasPrefix("LAB:"))
- fileNameStrFinal = "GAME/";
- else if (fileNameStr.hasPrefix("MUSIC:"))
- fileNameStrFinal = "GAME/MUSIC/";
-
- if (fileNameStr.contains(':')) {
- while (fileNameStr[0] != ':') {
- fileNameStr.deleteChar(0);
- }
-
- fileNameStr.deleteChar(0);
- }
-
- fileNameStrFinal += fileNameStr;
-
- strcpy(NewFileName, fileNameStrFinal.c_str());
-
- return NewFileName;
-}
-
-
-} // End of namespace Lab
diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h
index 8d7c60930f..67200a8498 100644
--- a/engines/lab/labfun.h
+++ b/engines/lab/labfun.h
@@ -116,12 +116,6 @@ public:
};
/*---------------------------*/
-/*----- From Machine.c ------*/
-/*---------------------------*/
-
-char *translateFileName(const char *filename);
-
-/*---------------------------*/
/*-------- From Map.c -------*/
/*---------------------------*/
diff --git a/engines/lab/module.mk b/engines/lab/module.mk
index 18bb7e6916..5b8ac1aefd 100644
--- a/engines/lab/module.mk
+++ b/engines/lab/module.mk
@@ -10,7 +10,6 @@ MODULE_OBJS := \
interface.o \
intro.o \
lab.o \
- labfile.o \
labsets.o \
map.o \
music.o \
diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index 5be7aedea5..5b4c0c101e 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -43,21 +43,16 @@ Resource::Resource(LabEngine *vm) : _vm(vm) {
}
void Resource::readStaticText() {
- Common::File labTextFile;
- labTextFile.open(translateFileName("Lab:Rooms/LabText"));
- if (!labTextFile.isOpen())
- error("Unable to open file %s (Lab:Rooms/LabText)", translateFileName("Lab:Rooms/LabText"));
+ Common::File *labTextFile = openDataFile("Lab:Rooms/LabText");
for (int i = 0; i < 48; i++)
- _staticText[i] = labTextFile.readLine();
+ _staticText[i] = labTextFile->readLine();
- labTextFile.close();
+ delete labTextFile;
}
TextFont *Resource::getFont(const char *fileName) {
- Common::File *dataFile;
- if (!(dataFile = openDataFile(fileName, MKTAG('V', 'G', 'A', 'F'))))
- error("getFont: couldn't open %s (%s)", translateFileName(fileName), fileName);
+ Common::File *dataFile = openDataFile(fileName, MKTAG('V', 'G', 'A', 'F'));
uint32 headerSize = 4L + 2L + 256 * 3 + 4L;
uint32 fileSize = dataFile->size();
@@ -79,10 +74,7 @@ TextFont *Resource::getFont(const char *fileName) {
}
char *Resource::getText(const char *fileName) {
- Common::File *dataFile = new Common::File();
- dataFile->open(translateFileName(fileName));
- if (!dataFile->isOpen())
- error("getText: couldn't open %s (%s)", translateFileName(fileName), fileName);
+ Common::File *dataFile = openDataFile(fileName);
g_lab->_music->updateMusic();
@@ -94,6 +86,7 @@ char *Resource::getText(const char *fileName) {
while (text && *text != '\0')
*text++ -= (byte)95;
+ delete dataFile;
return (char *)buffer;
}
@@ -166,6 +159,34 @@ bool Resource::readViews(uint16 roomNum) {
return true;
}
+Common::String Resource::translateFileName(Common::String filename) {
+ filename.toUppercase();
+ Common::String fileNameStrFinal;
+
+ if (filename.hasPrefix("P:")) {
+ if (g_lab->_isHiRes)
+ fileNameStrFinal = "GAME/SPICT/";
+ else
+ fileNameStrFinal = "GAME/PICT/";
+ }
+ else if (filename.hasPrefix("LAB:"))
+ fileNameStrFinal = "GAME/";
+ else if (filename.hasPrefix("MUSIC:"))
+ fileNameStrFinal = "GAME/MUSIC/";
+
+ if (filename.contains(':')) {
+ while (filename[0] != ':') {
+ filename.deleteChar(0);
+ }
+
+ filename.deleteChar(0);
+ }
+
+ fileNameStrFinal += filename;
+
+ return fileNameStrFinal;
+}
+
Common::File *Resource::openDataFile(const char *fileName, uint32 fileHeader) {
Common::File *dataFile = new Common::File();
dataFile->open(translateFileName(fileName));
diff --git a/engines/lab/resource.h b/engines/lab/resource.h
index 2c7f9b75eb..99996a1475 100644
--- a/engines/lab/resource.h
+++ b/engines/lab/resource.h
@@ -115,6 +115,7 @@ private:
CloseData *readCloseUps(uint16 depth, Common::File *file);
ViewData *readView(Common::File *file);
void readStaticText();
+ Common::String translateFileName(Common::String filename);
Common::String _staticText[48];
};