mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-24 05:01:43 +00:00
LAB: Get rid of sizeOfFile(), some cleanup
This commit is contained in:
parent
21e360b9b1
commit
a4bad804f6
@ -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 --------------------*/
|
||||
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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,20 +78,41 @@ 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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Gets a chunk of text and puts it into the graphics memory. */
|
||||
/*****************************************************************************/
|
||||
|
@ -35,40 +35,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. */
|
||||
/*****************************************************************************/
|
||||
@ -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) {
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user