From 590f89e90e547076f27c25dfb2c1058f7f95bbbf Mon Sep 17 00:00:00 2001 From: uruk Date: Wed, 3 Jul 2013 17:06:36 +0200 Subject: AVALANCHE: Celer: Implement file handling. --- engines/avalanche/celer2.cpp | 51 ++++++++++++++++++++++++++++++++++++++++++-- engines/avalanche/celer2.h | 8 +++++-- 2 files changed, 55 insertions(+), 4 deletions(-) (limited to 'engines/avalanche') diff --git a/engines/avalanche/celer2.cpp b/engines/avalanche/celer2.cpp index c02a82f6f0..6bacde735d 100644 --- a/engines/avalanche/celer2.cpp +++ b/engines/avalanche/celer2.cpp @@ -268,8 +268,55 @@ void Celer::pics_link() { } } -void Celer::load_chunks(Common::String xx) { - warning("STUB: Celer::load_chunks()"); +void Celer::load_chunks(char *xx) { + chunkblocktype ch; + byte fv; + + Common::String filename; + filename = filename.format("chunk%s.avd", xx); + if (!f.open(filename)) { + warning("AVALANCHE: Celer: File not found: %s", filename.c_str()); + return; + } + + f.seek(44); + num_chunks = f.readByte(); + for (int i = 0; i < num_chunks; i++) + offsets[i] = f.readSint32LE(); + + for (fv = 0; fv < num_chunks; fv++) { + f.seek(offsets[fv]); + + ch.flavour = flavourtype(f.readByte()); + ch.x = f.readSint16LE(); + ch.y = f.readSint16LE(); + ch.xl = f.readSint16LE(); + ch.yl = f.readSint16LE(); + ch.size = f.readSint32LE(); + ch.natural = f.readByte(); + ch.memorise = f.readByte(); + + if (ch.memorise) { + + memos[fv].x = ch.x; + memos[fv].xl = ch.xl; + memos[fv].y = ch.y; + memos[fv].yl = ch.yl; + memos[fv].flavour = ch.flavour; + memos[fv].size = ch.size; + + memory[fv] = malloc(ch.size); // Celer::forget_chunks() deallocates it. + + /*if (ch.natural) { + getimage(ch.x * 8, ch.y, (ch.x + ch.xl) * 8, ch.y + ch.yl, memory[fv]); + } else + blockread(f, memory[fv], ch.size);*/ + } else + memos[fv].x = on_disk; + + } + + f.close(); } void Celer::forget_chunks() { diff --git a/engines/avalanche/celer2.h b/engines/avalanche/celer2.h index e71dec5f19..aa32bf58a2 100644 --- a/engines/avalanche/celer2.h +++ b/engines/avalanche/celer2.h @@ -31,6 +31,7 @@ #define CELER2_H #include "common/scummsys.h" +#include "common/file.h" #include "common/str.h" namespace Avalanche { @@ -38,7 +39,7 @@ class AvalancheEngine; class Celer { public: - enum flavourtype {ch_ega, ch_bgi, last_flavourtype}; + enum flavourtype {ch_ega, ch_bgi}; struct chunkblocktype { flavourtype flavour; @@ -62,6 +63,9 @@ public: memotype memos[40]; void *memory[40]; + Common::File f; + + Celer(); @@ -69,7 +73,7 @@ public: void pics_link(); - void load_chunks(Common::String xx); + void load_chunks(char *xx); void forget_chunks(); -- cgit v1.2.3