diff options
| author | Torbjörn Andersson | 2004-03-24 07:29:59 +0000 |
|---|---|---|
| committer | Torbjörn Andersson | 2004-03-24 07:29:59 +0000 |
| commit | afefe7dcfa7bc3a360b77ecd67c3650b426438d5 (patch) | |
| tree | da04c0b2e2305029a14ebef5b7901fe8c77b558e /graphics | |
| parent | 1f1c929cae5883335030d8a112989cc8d38fb246 (diff) | |
| download | scummvm-rg350-afefe7dcfa7bc3a360b77ecd67c3650b426438d5.tar.gz scummvm-rg350-afefe7dcfa7bc3a360b77ecd67c3650b426438d5.tar.bz2 scummvm-rg350-afefe7dcfa7bc3a360b77ecd67c3650b426438d5.zip | |
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...
svn-id: r13377
Diffstat (limited to 'graphics')
| -rw-r--r-- | graphics/animation.cpp | 51 | ||||
| -rw-r--r-- | graphics/animation.h | 3 |
2 files changed, 36 insertions, 18 deletions
diff --git a/graphics/animation.cpp b/graphics/animation.cpp index 63bf92f42d..79a0aad0d2 100644 --- a/graphics/animation.cpp +++ b/graphics/animation.cpp @@ -61,33 +61,27 @@ bool BaseAnimationState::init(const char *name) { 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 @@ bool BaseAnimationState::init(const char *name) { 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 @@ void BaseAnimationState::buildLookup(int p, int lines) { 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; diff --git a/graphics/animation.h b/graphics/animation.h index e4a92a66fa..044bfbd069 100644 --- a/graphics/animation.h +++ b/graphics/animation.h @@ -124,6 +124,9 @@ public: bool init(const char *name); bool decodeFrame(); +#ifndef BACKEND_8BIT + void invalidateLookup(bool rebuild); +#endif protected: bool checkPaletteSwitch(); |
