aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/lab/labfile.cpp23
-rw-r--r--engines/lab/labfun.h2
-rw-r--r--engines/lab/map.cpp48
-rw-r--r--engines/lab/text.cpp89
-rw-r--r--engines/lab/text.h1
5 files changed, 40 insertions, 123 deletions
diff --git a/engines/lab/labfile.cpp b/engines/lab/labfile.cpp
index 43825f018d..dfb72571b2 100644
--- a/engines/lab/labfile.cpp
+++ b/engines/lab/labfile.cpp
@@ -44,29 +44,6 @@ static byte *buffer = NULL, *realbufferstart = NULL, *startoffilestorage = NULL;
byte **startoffile = &startoffilestorage;
static uint32 buffersize, realbuffersize;
-int32 ReadSoFar;
-
-/*****************************************************************************/
-/* Returns the size of a file. */
-/*****************************************************************************/
-uint32 sizeOfFile(const char *name) {
- Common::File file;
-
- file.open(translateFileName(name));
- if (!file.isOpen()) {
- warning("Cannot open file %s", translateFileName(name));
-
- return 0;
- }
- uint32 size = file.size();
- file.close();
-
- return size;
-}
-
-
-
-
/*-------------------- Routines that buffer a whole file --------------------*/
diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h
index cd1e2df690..ea0d3c8c48 100644
--- a/engines/lab/labfun.h
+++ b/engines/lab/labfun.h
@@ -136,8 +136,6 @@ bool quitPlaying();
/*------ From LabFile.c -----*/
/*---------------------------*/
-uint32 sizeOfFile(const char *name);
-
/* Buffer a whole file */
byte **isBuffered(const char *fileName);
byte **openFile(const char *name, uint32 &size);
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;
+}
/*****************************************************************************/
diff --git a/engines/lab/text.cpp b/engines/lab/text.cpp
index 5056d24e63..5120a19a5c 100644
--- a/engines/lab/text.cpp
+++ b/engines/lab/text.cpp
@@ -36,40 +36,6 @@
namespace Lab {
/*****************************************************************************/
-/* Opens up a font from disk, but uses buffer memory to store it in. */
-/*****************************************************************************/
-bool openFontMem(const char *TextFontPath, struct TextFont *tf, byte *fontbuffer) {
- byte **file = NULL;
- char header[5];
- uint32 filesize, headersize = 4L + 2L + 256 * 3 + 4L;
-
- file = g_music->newOpen(TextFontPath, filesize);
-
- if ((file != NULL) && (filesize > headersize)) {
- header[4] = 0;
- readBlock(&header, 4L, file);
-
- if (strcmp(header, "VGAF") == 0) {
- tf->DataLength = filesize - headersize;
- readBlock(&(tf->Height), 2L, file);
- swapUShortPtr(&(tf->Height), 1);
-
- readBlock(tf->Widths, 256L, file);
- readBlock(tf->Offsets, 256L * 2L, file);
- swapUShortPtr(tf->Offsets, 256);
-
- skip(file, 4L);
- tf->data = fontbuffer;
- readBlock(tf->data, tf->DataLength, file);
- return true;
- }
- }
-
- return false;
-}
-
-
-/*****************************************************************************/
/* Opens up a font from disk. */
/*****************************************************************************/
bool openFont(const char *TextFontPath, struct TextFont **tf) {
@@ -145,10 +111,7 @@ uint16 textLength(struct TextFont *tf, const char *text, uint16 numchars) {
/* Returns the height of a specified font. */
/*****************************************************************************/
uint16 textHeight(struct TextFont *tf) {
- if (tf)
- return tf->Height;
- else
- return 0;
+ return (tf) ? tf->Height : 0;
}
@@ -177,8 +140,7 @@ void text(struct TextFont *tf, uint16 x, uint16 y, uint16 color, const char *tex
if (tf->Widths[(uint)*text]) {
cdata = tf->data + tf->Offsets[(uint)*text];
- bwidth = *cdata;
- cdata++;
+ bwidth = *cdata++;
VGATemp = VGACur;
VGATempLine = VGACur;
@@ -187,49 +149,14 @@ void text(struct TextFont *tf, uint16 x, uint16 y, uint16 color, const char *tex
templeft = LeftInSegment;
for (cols = 0; cols < bwidth; cols++) {
- data = *cdata;
- cdata++;
+ data = *cdata++;
if (data && (templeft >= 8)) {
- if (0x80 & data)
- *VGATemp = color;
-
- VGATemp++;
-
- if (0x40 & data)
- *VGATemp = color;
-
- VGATemp++;
-
- if (0x20 & data)
- *VGATemp = color;
-
- VGATemp++;
-
- if (0x10 & data)
- *VGATemp = color;
-
- VGATemp++;
-
- if (0x08 & data)
- *VGATemp = color;
-
- VGATemp++;
-
- if (0x04 & data)
- *VGATemp = color;
-
- VGATemp++;
-
- if (0x02 & data)
- *VGATemp = color;
-
- VGATemp++;
-
- if (0x01 & data)
- *VGATemp = color;
-
- VGATemp++;
+ for (int i = 7; i >= 0; i--) {
+ if ((1 << i) & data)
+ *VGATemp = color;
+ VGATemp++;
+ }
templeft -= 8;
} else if (data) {
diff --git a/engines/lab/text.h b/engines/lab/text.h
index 944b363357..333f449203 100644
--- a/engines/lab/text.h
+++ b/engines/lab/text.h
@@ -52,7 +52,6 @@ struct TextFont {
#pragma pack(pop)
#endif
-bool openFontMem(const char *TextFontPath, TextFont *tf, byte *fontbuffer);
bool openFont(const char *TextFontPath, TextFont **tf);
void closeFont(TextFont *tf);
uint16 textLength(TextFont *tf, const char *text, uint16 numchars);