[Scummvm-cvs-logs] CVS: scummvm/graphics animation.cpp,1.5,1.6 animation.h,1.5,1.6
Torbj?rn Andersson
eriktorbjorn at users.sourceforge.net
Tue Mar 23 23:41:10 CET 2004
Update of /cvsroot/scummvm/scummvm/graphics
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21088/graphics
Modified Files:
animation.cpp animation.h
Log Message:
Use the binary .pal file format that was introduced for 0.6.0.
Invalidate the lookup table when the screen changes. (TODO: We also have to
invalidate it if the change happens between cutscenes, don't we?)
Some cleanup, particularly in the BS2 cutscene player. More needed, I
guess...
Index: animation.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/graphics/animation.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- animation.cpp 23 Mar 2004 00:10:17 -0000 1.5
+++ animation.cpp 24 Mar 2004 07:29:59 -0000 1.6
@@ -61,33 +61,27 @@
uint i, p;
// Load lookup palettes
- // TODO: Binary format so we can use File class
sprintf(tempFile, "%s.pal", name);
- FILE *f = fopen(tempFile, "r");
- if (!f) {
- warning("Cutscene: %s.pal palette missing", name);
+ File f;
+
+ if (!f.open(tempFile)) {
+ warning("Cutscene: %s palette missing", tempFile);
return false;
}
p = 0;
- while (!feof(f)) {
- int end, cnt;
+ while (1) {
+ palettes[p].end = f.readUint16LE();
+ palettes[p].cnt = f.readUint16LE();
- if (fscanf(f, "%i %i", &end, &cnt) != 2)
+ if (f.ioFailed())
break;
- palettes[p].end = (uint) end;
- palettes[p].cnt = (uint) cnt;
-
for (i = 0; i < palettes[p].cnt; i++) {
- int r, g, b;
- fscanf(f, "%i", &r);
- fscanf(f, "%i", &g);
- fscanf(f, "%i", &b);
- palettes[p].pal[4 * i] = r;
- palettes[p].pal[4 * i + 1] = g;
- palettes[p].pal[4 * i + 2] = b;
+ palettes[p].pal[4 * i] = f.readByte();
+ palettes[p].pal[4 * i + 1] = f.readByte();
+ palettes[p].pal[4 * i + 2] = f.readByte();
palettes[p].pal[4 * i + 3] = 0;
}
for (; i < 256; i++) {
@@ -96,9 +90,11 @@
palettes[p].pal[4 * i + 2] = 0;
palettes[p].pal[4 * i + 3] = 0;
}
+
p++;
}
- fclose(f);
+
+ f.close();
palnum = 0;
maxPalnum = p;
@@ -300,6 +296,25 @@
OverlayColor *BaseAnimationState::lookup = 0;
+/**
+ * This function should be called when the screen changes to invalidate and,
+ * optionally, rebuild the lookup table.
+ * @param rebuild If true, rebuild the table.
+ */
+
+// FIXME: We will need to call the function from the game's main event loop
+// as well, not just the cutscene players' ones.
+
+// FIXME: It would be nice with a heuristic to check if the table really does
+// need to be rebuilt.
+
+void BaseAnimationState::invalidateLookup(bool rebuild) {
+ free(lookup);
+ lookup = 0;
+ if (rebuild)
+ buildLookup();
+}
+
void BaseAnimationState::buildLookup() {
if (lookup)
return;
Index: animation.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/graphics/animation.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- animation.h 23 Mar 2004 00:10:17 -0000 1.5
+++ animation.h 24 Mar 2004 07:29:59 -0000 1.6
@@ -124,6 +124,9 @@
bool init(const char *name);
bool decodeFrame();
+#ifndef BACKEND_8BIT
+ void invalidateLookup(bool rebuild);
+#endif
protected:
bool checkPaletteSwitch();
More information about the Scummvm-git-logs
mailing list