diff options
-rw-r--r-- | engines/parallaction/archive.cpp | 47 | ||||
-rw-r--r-- | engines/parallaction/disk.cpp | 124 | ||||
-rw-r--r-- | engines/parallaction/disk.h | 61 | ||||
-rw-r--r-- | engines/parallaction/parallaction.cpp | 38 |
4 files changed, 206 insertions, 64 deletions
diff --git a/engines/parallaction/archive.cpp b/engines/parallaction/archive.cpp index 09db346323..e515ada645 100644 --- a/engines/parallaction/archive.cpp +++ b/engines/parallaction/archive.cpp @@ -27,6 +27,24 @@ namespace Parallaction { +// this PSEUDOID is used here to tell ONE archive from the others, namely the 'fr' archive in the +// amiga demo of Nippon Safes. It's the only archive using different internal offsets. +// +#define PSEUDOID_OFS 5 + +#define ID_SMALL_ARCHIVE 5 // marks the aforementioned 'fr' archive + +#define ARCHIVE_FILENAMES_OFS 0x16 + +#define NORMAL_ARCHIVE_FILES_NUM 384 +#define SMALL_ARCHIVE_FILES_NUM 180 + +#define NORMAL_ARCHIVE_SIZES_OFS 0x3016 +#define SMALL_ARCHIVE_SIZES_OFS 0x1696 + +#define NORMAL_ARCHIVE_DATA_OFS 0x4000 +#define SMALL_ARCHIVE_DATA_OFS 0x1966 + Archive::Archive() { resetArchivedFile(); } @@ -37,29 +55,28 @@ void Archive::open(const char *file) { if (_archive.isOpen()) close(); - uint32 offset = DIRECTORY_OFFSET_IN_FILE; char path[PATH_LEN]; strcpy(path, file); if (!_archive.open(path)) error("archive '%s' not found", path); - _archive.skip(22); - _archive.read(_archiveDir, MAX_ARCHIVE_ENTRIES*32); + _archive.seek(PSEUDOID_OFS); + uint32 pseudoid = _archive.readByte(); - uint16 i; - for (i = 0; i < MAX_ARCHIVE_ENTRIES; i++) { - _archiveOffsets[i] = offset; + _numFiles = (pseudoid == ID_SMALL_ARCHIVE) ? SMALL_ARCHIVE_FILES_NUM : NORMAL_ARCHIVE_FILES_NUM; - uint32 len = _archive.readUint32BE(); -// if (len>0) printf("%i) %s - [%i bytes]\n", i, _archiveDir[i], len); + _archive.seek(ARCHIVE_FILENAMES_OFS); + _archive.read(_archiveDir, _numFiles*32); - _archiveLenghts[i] = len; - offset += len; - } + _archive.seek((pseudoid == ID_SMALL_ARCHIVE) ? SMALL_ARCHIVE_SIZES_OFS : NORMAL_ARCHIVE_SIZES_OFS); -// printf("%i entries found\n", i); -// printf("%i bytes of data\n", offset); + uint32 dataOffset = (pseudoid == ID_SMALL_ARCHIVE) ? SMALL_ARCHIVE_DATA_OFS : NORMAL_ARCHIVE_DATA_OFS; + for (uint16 i = 0; i < _numFiles; i++) { + _archiveOffsets[i] = dataOffset; + _archiveLenghts[i] = _archive.readUint32BE(); + dataOffset += _archiveLenghts[i]; + } return; } @@ -80,10 +97,10 @@ bool Archive::openArchivedFile(const char *filename) { resetArchivedFile(); uint16 i = 0; - for ( ; i < MAX_ARCHIVE_ENTRIES; i++) { + for ( ; i < _numFiles; i++) { if (!scumm_stricmp(_archiveDir[i], filename)) break; } - if (i == MAX_ARCHIVE_ENTRIES) return false; + if (i == _numFiles) return false; debugC(1, kDebugDisk, "file '%s' found in slot %i", filename, i); diff --git a/engines/parallaction/disk.cpp b/engines/parallaction/disk.cpp index d5701f179e..052a218071 100644 --- a/engines/parallaction/disk.cpp +++ b/engines/parallaction/disk.cpp @@ -28,11 +28,17 @@ namespace Parallaction { -Disk::Disk(Parallaction* vm) : _vm(vm) { + +Disk::Disk(Parallaction *vm) : _vm(vm) { } Disk::~Disk() { + +} + +void Disk::selectArchive(const char *name) { + _archive.open(name); } void Disk::setLanguage(uint16 language) { @@ -62,10 +68,24 @@ void Disk::setLanguage(uint16 language) { return; } + + +#pragma mark - + + + +DosDisk::DosDisk(Parallaction* vm) : Disk(vm) { + +} + +DosDisk::~DosDisk() { +} + + // // decompress a graphics block // -uint16 Disk::decompressChunk(byte *src, byte *dst, uint16 size) { +uint16 DosDisk::decompressChunk(byte *src, byte *dst, uint16 size) { uint16 written = 0; uint16 read = 0; @@ -101,7 +121,7 @@ uint16 Disk::decompressChunk(byte *src, byte *dst, uint16 size) { // // loads a cnv from an external file // -void Disk::loadExternalCnv(const char *filename, Cnv *cnv) { +void DosDisk::loadExternalCnv(const char *filename, Cnv *cnv) { // printf("Gfx::loadExternalCnv(%s)...", filename); char path[PATH_LEN]; @@ -131,7 +151,7 @@ void Disk::loadExternalCnv(const char *filename, Cnv *cnv) { return; } -void Disk::loadExternalStaticCnv(const char *filename, StaticCnv *cnv) { +void DosDisk::loadExternalStaticCnv(const char *filename, StaticCnv *cnv) { char path[PATH_LEN]; @@ -156,7 +176,7 @@ void Disk::loadExternalStaticCnv(const char *filename, StaticCnv *cnv) { return; } -void Disk::loadCnv(const char *filename, Cnv *cnv) { +void DosDisk::loadCnv(const char *filename, Cnv *cnv) { // printf("Gfx::loadCnv(%s)\n", filename); char path[PATH_LEN]; @@ -197,7 +217,7 @@ void Disk::loadCnv(const char *filename, Cnv *cnv) { return; } -Cnv* Disk::loadTalk(const char *name) { +Cnv* DosDisk::loadTalk(const char *name) { Cnv *cnv = new Cnv; @@ -233,7 +253,7 @@ Cnv* Disk::loadTalk(const char *name) { return cnv; } -Script* Disk::loadLocation(const char *name) { +Script* DosDisk::loadLocation(const char *name) { char archivefile[PATH_LEN]; @@ -267,7 +287,7 @@ Script* Disk::loadLocation(const char *name) { } -Script* Disk::loadScript(const char* name) { +Script* DosDisk::loadScript(const char* name) { char vC8[PATH_LEN]; @@ -284,7 +304,7 @@ Script* Disk::loadScript(const char* name) { return new Script(buf, true); } -StaticCnv* Disk::loadHead(const char* name) { +StaticCnv* DosDisk::loadHead(const char* name) { char path[PATH_LEN]; /* @@ -307,13 +327,13 @@ StaticCnv* Disk::loadHead(const char* name) { } -StaticCnv* Disk::loadPointer() { +StaticCnv* DosDisk::loadPointer() { StaticCnv* cnv = new StaticCnv; loadExternalStaticCnv("pointer", cnv); return cnv; } -Cnv* Disk::loadFont(const char* name) { +Cnv* DosDisk::loadFont(const char* name) { char path[PATH_LEN]; sprintf(path, "%scnv", name); @@ -325,7 +345,7 @@ Cnv* Disk::loadFont(const char* name) { // loads character's icons set -Cnv* Disk::loadObjects(const char *name) { +Cnv* DosDisk::loadObjects(const char *name) { if (IS_MINI_CHARACTER(name)) { name += 4; @@ -340,7 +360,7 @@ Cnv* Disk::loadObjects(const char *name) { } -StaticCnv* Disk::loadStatic(const char* name) { +StaticCnv* DosDisk::loadStatic(const char* name) { char path[PATH_LEN]; @@ -371,7 +391,7 @@ StaticCnv* Disk::loadStatic(const char* name) { return cnv; } -Cnv* Disk::loadFrames(const char* name) { +Cnv* DosDisk::loadFrames(const char* name) { Cnv* cnv = new Cnv; loadCnv(name, cnv); return cnv; @@ -387,7 +407,7 @@ Cnv* Disk::loadFrames(const char* name) { // -void Disk::unpackBackgroundScanline(byte *src, byte *screen, byte *mask, byte *path) { +void DosDisk::unpackBackgroundScanline(byte *src, byte *screen, byte *mask, byte *path) { // update mask, path and screen for (uint16 i = 0; i < SCREEN_WIDTH; i++) { @@ -399,7 +419,7 @@ void Disk::unpackBackgroundScanline(byte *src, byte *screen, byte *mask, byte *p return; } -void Disk::parseDepths(Common::SeekableReadStream &stream) { +void DosDisk::parseDepths(Common::SeekableReadStream &stream) { _vm->_gfx->_bgLayers[0] = stream.readByte(); _vm->_gfx->_bgLayers[1] = stream.readByte(); _vm->_gfx->_bgLayers[2] = stream.readByte(); @@ -407,7 +427,7 @@ void Disk::parseDepths(Common::SeekableReadStream &stream) { } -void Disk::parseBackground(Common::SeekableReadStream &stream) { +void DosDisk::parseBackground(Common::SeekableReadStream &stream) { stream.read(_vm->_gfx->_palette, PALETTE_SIZE); @@ -431,7 +451,7 @@ void Disk::parseBackground(Common::SeekableReadStream &stream) { } -void Disk::loadBackground(const char *filename) { +void DosDisk::loadBackground(const char *filename) { // printf("Gfx::loadBackground(%s)\n", filename); if (!_archive.openArchivedFile(filename)) @@ -473,7 +493,7 @@ void Disk::loadBackground(const char *filename) { // mask and path are normally combined (via OR) into the background picture itself // read the comment on the top of this file for more // -void Disk::loadMaskAndPath(const char *name) { +void DosDisk::loadMaskAndPath(const char *name) { char path[PATH_LEN]; sprintf(path, "%s.msk", name); @@ -494,13 +514,13 @@ void Disk::loadMaskAndPath(const char *name) { return; } -void Disk::loadSlide(const char *filename) { +void DosDisk::loadSlide(const char *filename) { char path[PATH_LEN]; sprintf(path, "%s.slide", filename); loadBackground(path); } -void Disk::loadScenery(const char *name, const char *mask) { +void DosDisk::loadScenery(const char *name, const char *mask) { char path[PATH_LEN]; sprintf(path, "%s.dyn", name); loadBackground(path); @@ -512,8 +532,66 @@ void Disk::loadScenery(const char *name, const char *mask) { } -void Disk::selectArchive(const char *name) { - _archive.open(name); + + +#pragma mark - + + + +AmigaDisk::AmigaDisk(Parallaction *vm) : Disk(vm) { + +} + + +AmigaDisk::~AmigaDisk() { + +} + +Script* AmigaDisk::loadLocation(const char *name) { + return NULL; +} + +Script* AmigaDisk::loadScript(const char* name) { + return NULL; +} + +Cnv* AmigaDisk::loadTalk(const char *name) { + return NULL; +} + +Cnv* AmigaDisk::loadObjects(const char *name) { + return NULL; +} + +StaticCnv* AmigaDisk::loadPointer() { + return NULL; +} + +StaticCnv* AmigaDisk::loadHead(const char* name) { + return NULL; +} + +Cnv* AmigaDisk::loadFont(const char* name) { + return NULL; +} + +StaticCnv* AmigaDisk::loadStatic(const char* name) { + return NULL; +} + +Cnv* AmigaDisk::loadFrames(const char* name) { + return NULL; +} + +void AmigaDisk::loadSlide(const char *filename) { + return; +} + +void AmigaDisk::loadScenery(const char* background, const char* mask) { + return; } + + + } // namespace Parallaction diff --git a/engines/parallaction/disk.h b/engines/parallaction/disk.h index ea342fa190..552a68b907 100644 --- a/engines/parallaction/disk.h +++ b/engines/parallaction/disk.h @@ -35,8 +35,6 @@ namespace Parallaction { #define MAX_ARCHIVE_ENTRIES 384 -#define DIRECTORY_OFFSET_IN_FILE 0x4000 - class Parallaction; class Gfx; class Script; @@ -56,6 +54,8 @@ protected: Common::File _archive; + uint32 _numFiles; + protected: void resetArchivedFile(); @@ -78,6 +78,35 @@ public: class Disk { +protected: + Archive _archive; + char _languageDir[3]; + Parallaction *_vm; + +public: + Disk(Parallaction *vm); + virtual ~Disk(); + + void selectArchive(const char *name); + void setLanguage(uint16 language); + + virtual Script* loadLocation(const char *name) = 0; + virtual Script* loadScript(const char* name) = 0; + virtual Cnv* loadTalk(const char *name) = 0; + virtual Cnv* loadObjects(const char *name) = 0; + virtual StaticCnv* loadPointer() = 0; + virtual StaticCnv* loadHead(const char* name) = 0; + virtual Cnv* loadFont(const char* name) = 0; + virtual StaticCnv* loadStatic(const char* name) = 0; + virtual Cnv* loadFrames(const char* name) = 0; + virtual void loadSlide(const char *filename) = 0; + virtual void loadScenery(const char* background, const char* mask) = 0; + + +}; + +class DosDisk : public Disk { + private: uint16 decompressChunk(byte *src, byte *dst, uint16 size); void unpackBackgroundScanline(byte *src, byte *screen, byte *mask, byte *path); @@ -90,18 +119,30 @@ private: void parseBackground(Common::SeekableReadStream &stream); protected: - Archive _archive; - char _languageDir[3]; - - Parallaction *_vm; Gfx *_gfx; public: - Disk(Parallaction *vm); - virtual ~Disk(); + DosDisk(Parallaction *vm); + virtual ~DosDisk(); - void selectArchive(const char *name); - void setLanguage(uint16 language); + Script* loadLocation(const char *name); + Script* loadScript(const char* name); + Cnv* loadTalk(const char *name); + Cnv* loadObjects(const char *name); + StaticCnv* loadPointer(); + StaticCnv* loadHead(const char* name); + Cnv* loadFont(const char* name); + StaticCnv* loadStatic(const char* name); + Cnv* loadFrames(const char* name); + void loadSlide(const char *filename); + void loadScenery(const char* background, const char* mask); +}; + +class AmigaDisk : public Disk { + +public: + AmigaDisk(Parallaction *vm); + virtual ~AmigaDisk(); Script* loadLocation(const char *name); Script* loadScript(const char* name); diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp index 5fc12a0820..5c2c94f1b4 100644 --- a/engines/parallaction/parallaction.cpp +++ b/engines/parallaction/parallaction.cpp @@ -148,24 +148,8 @@ Parallaction::Parallaction(OSystem *syst) : // FIXME _vm = this; - _disk = new Disk(this); - _skipMenu = false; - _transCurrentHoverItem = 0; - _actionAfterWalk = false; // actived when the character needs to move before taking an action - _activeItem._index = 0; - _activeItem._id = 0; - _procCurrentHoverItem = -1; - - _locationScript = NULL; - - _musicData1 = 0; - strcpy(_characterName1, "null"); - - _midiPlayer = 0; - - _baseTime = 0; Common::File::addDefaultDirectory( _gameDataPath ); @@ -194,6 +178,28 @@ int Parallaction::init() { return -1; } + _skipMenu = false; + + _transCurrentHoverItem = 0; + _actionAfterWalk = false; // actived when the character needs to move before taking an action + _activeItem._index = 0; + _activeItem._id = 0; + _procCurrentHoverItem = -1; + + _locationScript = NULL; + + _musicData1 = 0; + strcpy(_characterName1, "null"); + + _midiPlayer = 0; + + _baseTime = 0; + + if (getPlatform() == Common::kPlatformPC) + _disk = new DosDisk(this); + else + _disk = new AmigaDisk(this); + _engineFlags = 0; strcpy(_characterName, "dough"); |