aboutsummaryrefslogtreecommitdiff
path: root/engines/agi
diff options
context:
space:
mode:
authorJohannes Schickel2007-03-29 16:50:06 +0000
committerJohannes Schickel2007-03-29 16:50:06 +0000
commit69639ea0bf28e3ca7526617304859d359b58063b (patch)
treeaf20971b64f4cdeb069a48767b2ee245f53018b9 /engines/agi
parent3903309af338a1cedab353367a459ecd5f0250d8 (diff)
downloadscummvm-rg350-69639ea0bf28e3ca7526617304859d359b58063b.tar.gz
scummvm-rg350-69639ea0bf28e3ca7526617304859d359b58063b.tar.bz2
scummvm-rg350-69639ea0bf28e3ca7526617304859d359b58063b.zip
cleanup.
svn-id: r26315
Diffstat (limited to 'engines/agi')
-rw-r--r--engines/agi/graphics.cpp35
1 files changed, 15 insertions, 20 deletions
diff --git a/engines/agi/graphics.cpp b/engines/agi/graphics.cpp
index c3ddde14f8..072fd8f714 100644
--- a/engines/agi/graphics.cpp
+++ b/engines/agi/graphics.cpp
@@ -388,41 +388,36 @@ void GfxMgr::setAGIPal(int p0) {
//If 0 from savefile, do not use
if (p0 == 0)
return;
-
- _agipalFileNum = p0;
-
- Common::File agipal;
char filename[15];
- uint32 fileSize;
sprintf(filename, "pal.%d", p0);
- agipal.open(filename);
- fileSize = agipal.size();
- byte *palData = (byte *)malloc(fileSize);
- agipal.read(palData, fileSize);
- agipal.close();
+
+ Common::File agipal;
+ if (!agipal.open(filename))
+ error("Couldn't open AGIPAL palette file '%s'", filename);
//Chunk0 holds colors 0-7
- for (int i = 0; i < 8 * 3; i++)
- _agipalPalette[i] = palData[i];
-
+ agipal.read(&_agipalPalette[0], 24);
//Chunk1 is the same as the chunk0
+
//Chunk2 chunk holds colors 8-15
- int pos = 8 * 3;
- for (int i = 24; i < 8 * 3 * 2; i++)
- _agipalPalette[i] = palData[pos + i];
+ agipal.seek(24, SEEK_CUR);
+ agipal.read(&_agipalPalette[24], 24);
//Chunk3 is the same as the chunk2
+
//Chunks4-7 are duplicates of chunks0-3
+ if (agipal.ioFailed())
+ error("Couldn't read AGIPAL palette from '%s'", filename);
+
+ _agipalFileNum = p0;
+
initPalette(_agipalPalette);
gfxSetPalette();
- debug(1, "Using AGIPAL palette from pal.%d", p0);
-
- free(palData);
- palData = 0;
+ debug(1, "Using AGIPAL palette from '%s'", filename);
}
int GfxMgr::getAGIPalFileNum() {