diff options
author | Paul Gilbert | 2018-11-18 22:32:27 -0800 |
---|---|---|
committer | Paul Gilbert | 2018-12-08 19:05:59 -0800 |
commit | 525c09ef38c00d71cf3037d61d221783d3b48cf3 (patch) | |
tree | fd0a4bea7984bef5e38d329cd3eddf1ee31da693 /engines/glk/frotz | |
parent | f7cb4170847373a84268479bd7487c20c58d5639 (diff) | |
download | scummvm-rg350-525c09ef38c00d71cf3037d61d221783d3b48cf3.tar.gz scummvm-rg350-525c09ef38c00d71cf3037d61d221783d3b48cf3.tar.bz2 scummvm-rg350-525c09ef38c00d71cf3037d61d221783d3b48cf3.zip |
GLK: In progress transforming Blorb code to be a Common::Archive
Diffstat (limited to 'engines/glk/frotz')
-rw-r--r-- | engines/glk/frotz/mem.cpp | 40 | ||||
-rw-r--r-- | engines/glk/frotz/mem.h | 1 | ||||
-rw-r--r-- | engines/glk/frotz/processor_streams.cpp | 4 |
3 files changed, 8 insertions, 37 deletions
diff --git a/engines/glk/frotz/mem.cpp b/engines/glk/frotz/mem.cpp index 12e860add2..bec30b00f7 100644 --- a/engines/glk/frotz/mem.cpp +++ b/engines/glk/frotz/mem.cpp @@ -28,10 +28,9 @@ namespace Glk { namespace Frotz { -Mem::Mem() : story_fp(nullptr), blorb_ofs(0), blorb_len(0), story_size(0), - first_undo(nullptr), last_undo(nullptr), curr_undo(nullptr), - undo_mem(nullptr), prev_zmp(nullptr), undo_diff(nullptr), - undo_count(0), reserve_mem(0) { +Mem::Mem() : story_fp(nullptr), story_size(0), first_undo(nullptr), last_undo(nullptr), + curr_undo(nullptr), undo_mem(nullptr), zmp(nullptr), prev_zmp(nullptr), + undo_diff(nullptr), undo_count(0), reserve_mem(0) { } void Mem::initialize() { @@ -60,32 +59,7 @@ void Mem::initialize() { } void Mem::initializeStoryFile() { - Common::SeekableReadStream *f = story_fp; - giblorb_map_t *map; - giblorb_result_t res; - uint32 magic; - - magic = f->readUint32BE(); - - if (magic == MKTAG('F', 'O', 'R', 'M')) { - if (g_vm->giblorb_set_resource_map(f)) - error("This Blorb file seems to be invalid."); - - map = g_vm->giblorb_get_resource_map(); - - if (g_vm->giblorb_load_resource(map, giblorb_method_FilePos, &res, giblorb_ID_Exec, 0)) - error("This Blorb file does not contain an executable chunk."); - if (res.chunktype != MKTAG('Z', 'C', 'O', 'D')) - error("This Blorb file contains an executable chunk, but it is not a Z-code file."); - - blorb_ofs = res.data.startpos; - blorb_len = res.length; - } else { - blorb_ofs = 0; - blorb_len = f->size(); - } - - if (blorb_len < 64) + if (story_fp->size() < 64) error("This file is too small to be a Z-code file."); } @@ -115,7 +89,7 @@ void Mem::initializeUndo() { void Mem::loadGameHeader() { // Load header zmp = new byte[64]; - story_fp->seek(blorb_ofs); + story_fp->seek(0); story_fp->read(zmp, 64); Common::MemoryReadStream h(zmp, 64); @@ -131,7 +105,7 @@ void Mem::loadGameHeader() { story_size *= 2; } else { // Some old games lack the file size entry - story_size = blorb_len; + story_size = story_fp->size(); } } @@ -254,8 +228,6 @@ void Mem::free_undo(int count) { void Mem::reset_memory() { story_fp = nullptr; - blorb_ofs = 0; - blorb_len = 0; if (undo_mem) { free_undo(undo_count); diff --git a/engines/glk/frotz/mem.h b/engines/glk/frotz/mem.h index d973890605..a632bc6e63 100644 --- a/engines/glk/frotz/mem.h +++ b/engines/glk/frotz/mem.h @@ -57,7 +57,6 @@ typedef undo_struct undo_t; class Mem : public Header, public virtual UserOptions { protected: Common::SeekableReadStream *story_fp; - uint blorb_ofs, blorb_len; uint story_size; byte *pcp; byte *zmp; diff --git a/engines/glk/frotz/processor_streams.cpp b/engines/glk/frotz/processor_streams.cpp index cbef38aaa6..095ef247fd 100644 --- a/engines/glk/frotz/processor_streams.cpp +++ b/engines/glk/frotz/processor_streams.cpp @@ -519,7 +519,7 @@ void Processor::z_restart() { seed_random(0); if (!first_restart) { - story_fp->seek(blorb_ofs); + story_fp->seek(0); if (story_fp->read(zmp, h_dynamic_size) != h_dynamic_size) error("Story file read error"); @@ -599,7 +599,7 @@ void Processor::z_verify() { zword checksum = 0; // Sum all bytes in story file except header bytes - story_fp->seek(blorb_ofs + 64); + story_fp->seek(64); for (uint i = 64; i < story_size; i++) checksum += story_fp->readByte(); |