[Scummvm-cvs-logs] SF.net SVN: scummvm: [25866] scummvm/trunk/engines/parallaction
peres001 at users.sourceforge.net
peres001 at users.sourceforge.net
Sun Feb 25 21:35:48 CET 2007
Revision: 25866
http://scummvm.svn.sourceforge.net/scummvm/?rev=25866&view=rev
Author: peres001
Date: 2007-02-25 12:35:47 -0800 (Sun, 25 Feb 2007)
Log Message:
-----------
wrapped archive routines into a new class named Archive. File-level static variables have been made members of the new class.
Modified Paths:
--------------
scummvm/trunk/engines/parallaction/animation.cpp
scummvm/trunk/engines/parallaction/archive.cpp
scummvm/trunk/engines/parallaction/callables.cpp
scummvm/trunk/engines/parallaction/dialogue.cpp
scummvm/trunk/engines/parallaction/disk.h
scummvm/trunk/engines/parallaction/graphics.cpp
scummvm/trunk/engines/parallaction/location.cpp
scummvm/trunk/engines/parallaction/menu.cpp
scummvm/trunk/engines/parallaction/parallaction.cpp
scummvm/trunk/engines/parallaction/parallaction.h
scummvm/trunk/engines/parallaction/saveload.cpp
Modified: scummvm/trunk/engines/parallaction/animation.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/animation.cpp 2007-02-25 20:18:11 UTC (rev 25865)
+++ scummvm/trunk/engines/parallaction/animation.cpp 2007-02-25 20:35:47 UTC (rev 25866)
@@ -256,16 +256,16 @@
sprintf(vC8, "%s.script", filename);
- if (!openArchivedFile(vC8))
+ if (!_archive.openArchivedFile(vC8))
errorFileNotFound(vC8);
- uint32 size = getArchivedFileLength(vC8);
+ uint32 size = _archive.getArchivedFileLength(vC8);
char* src = (char*)memAlloc(size+1);
- readArchivedFile(src, size);
+ _archive.readArchivedFile(src, size);
src[size] = '\0';
- closeArchivedFile();
+ _archive.closeArchivedFile();
_numLocals = 0;
Modified: scummvm/trunk/engines/parallaction/archive.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/archive.cpp 2007-02-25 20:18:11 UTC (rev 25865)
+++ scummvm/trunk/engines/parallaction/archive.cpp 2007-02-25 20:35:47 UTC (rev 25866)
@@ -27,42 +27,13 @@
namespace Parallaction {
-static bool _file = false;
-static uint16 _fileIndex = 0;
-static uint32 _fileOffset = 0;
-static uint32 _fileCursor = 0;
-static uint32 _fileEndOffset = 0;
-#define MAX_ARCHIVE_ENTRIES 384
-
-#define DIRECTORY_OFFSET_IN_FILE 0x4000
-
-#ifdef PALMOS_ARM
- static Common::File *_archiveP = NULL;
- #define _archive (*_archiveP)
-#else
- static Common::File _archive;
-#endif
-
-
-static char _archiveDir[MAX_ARCHIVE_ENTRIES][32];
-static uint32 _archiveLenghts[MAX_ARCHIVE_ENTRIES];
-static uint32 _archiveOffsets[MAX_ARCHIVE_ENTRIES];
-
-
-
-void openArchive(const char *file) {
+void Archive::open(const char *file) {
debugC(1, kDebugDisk, "open archive '%s'", file);
-#ifdef PALMOS_ARM
- if (!_archiveP)
- _archiveP = new Common::File();
-#endif
-
if (_archive.isOpen())
- closeArchive();
+ close();
-
uint32 offset = DIRECTORY_OFFSET_IN_FILE;
char path[PATH_LEN];
@@ -91,8 +62,7 @@
}
-
-void closeArchive() {
+void Archive::close() {
debugC(1, kDebugDisk, "close current archive");
if (!_archive.isOpen()) return;
@@ -101,7 +71,7 @@
}
-bool openArchivedFile(const char *name) {
+bool Archive::openArchivedFile(const char *name) {
uint16 i = 0;
for ( ; i < MAX_ARCHIVE_ENTRIES; i++) {
@@ -124,8 +94,7 @@
}
-
-void closeArchivedFile() {
+void Archive::closeArchivedFile() {
_file = false;
_fileIndex = 0;
_fileCursor = 0;
@@ -135,9 +104,7 @@
}
-
-
-uint16 getArchivedFileLength(const char *name) {
+uint16 Archive::getArchivedFileLength(const char *name) {
// printf("getArchivedFileLength(%s)\n", name);
for (uint16 i = 0; i < MAX_ARCHIVE_ENTRIES; i++) {
@@ -149,8 +116,7 @@
}
-
-int16 readArchivedFile(void *buffer, uint16 size) {
+int16 Archive::readArchivedFile(void *buffer, uint16 size) {
// printf("readArchivedFile(%i, %i)\n", file->_cursor, file->_endOffset);
if (_file == false)
error("readArchiveFile: no archived file is currently open");
@@ -167,22 +133,8 @@
return read;
}
-#if 0
-int16 readArchivedFile(ArchivedFile *file, void *buffer, uint16 size) {
- printf("readArchivedFile(%i, %i)\n", file->_cursor, file->_endOffset);
- if (file->_cursor == file->_endOffset) return -1;
-
- _archive.seek(file->_cursor);
- int16 read = _archive.read(buffer, size);
- file->_cursor += read;
-
- return read;
-}
-#endif
-
-
-char *readArchivedFileText(char *buf, uint16 size) {
+char *Archive::readArchivedFileText(char *buf, uint16 size) {
if (_file == false)
error("readArchiveFileText: no archived file is currently open");
Modified: scummvm/trunk/engines/parallaction/callables.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/callables.cpp 2007-02-25 20:18:11 UTC (rev 25865)
+++ scummvm/trunk/engines/parallaction/callables.cpp 2007-02-25 20:35:47 UTC (rev 25866)
@@ -355,7 +355,7 @@
void _c_testResult(void *parm) {
_vm->_graphics->swapBuffers();
_vm->parseLocation("common");
- closeArchive();
+ _vm->_archive.close();
_vm->_graphics->loadExternalCnv("slidecnv", &Graphics::_font);
_vm->_graphics->_proportionalFont = false;
Modified: scummvm/trunk/engines/parallaction/dialogue.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/dialogue.cpp 2007-02-25 20:18:11 UTC (rev 25865)
+++ scummvm/trunk/engines/parallaction/dialogue.cpp 2007-02-25 20:35:47 UTC (rev 25866)
@@ -526,9 +526,9 @@
if (!scumm_stricmp(_location, "museum")) {
- closeArchive();
+ _vm->_archive.close();
strcpy(_vm->_disk, "disk1");
- openArchive(_vm->_disk);
+ _vm->_archive.open(_vm->_disk);
_vm->_graphics->loadCnv("dino", &_tempFrames);
memcpy(&_yourself._cnv, &_tempFrames, sizeof(Cnv));
Modified: scummvm/trunk/engines/parallaction/disk.h
===================================================================
--- scummvm/trunk/engines/parallaction/disk.h 2007-02-25 20:18:11 UTC (rev 25865)
+++ scummvm/trunk/engines/parallaction/disk.h 2007-02-25 20:35:47 UTC (rev 25866)
@@ -24,6 +24,7 @@
#define PARALLACTION_DISK_H
#include "parallaction/defs.h"
+#include "common/file.h"
namespace Parallaction {
@@ -31,20 +32,50 @@
// ARCHIVE MANAGEMENT
//------------------------------------------------------
-void openArchive(const char *file);
-void closeArchive();
-bool openArchivedFile(const char *name);
-void closeArchivedFile();
+#define MAX_ARCHIVE_ENTRIES 384
-uint16 getArchivedFileLength(const char *name);
+#define DIRECTORY_OFFSET_IN_FILE 0x4000
-int16 readArchivedFile(void *buffer, uint16 size);
-char *readArchivedFileText(char *buf, uint16 size);
+class Archive {
+protected:
+ bool _file;
+ uint16 _fileIndex;
+ uint32 _fileOffset;
+ uint32 _fileCursor;
+ uint32 _fileEndOffset;
+ char _archiveDir[MAX_ARCHIVE_ENTRIES][32];
+ uint32 _archiveLenghts[MAX_ARCHIVE_ENTRIES];
+ uint32 _archiveOffsets[MAX_ARCHIVE_ENTRIES];
+ Common::File _archive;
+
+public:
+ Archive() {
+ _file = false;
+ _fileIndex = 0;
+ _fileOffset = 0;
+ _fileCursor = 0;
+ _fileEndOffset = 0;
+ }
+
+ void open(const char *file);
+ void close();
+
+ bool openArchivedFile(const char *name);
+ void closeArchivedFile();
+
+ uint16 getArchivedFileLength(const char *name);
+
+ int16 readArchivedFile(void *buffer, uint16 size);
+ char *readArchivedFileText(char *buf, uint16 size);
+};
+
+
+
} // namespace Parallaction
Modified: scummvm/trunk/engines/parallaction/graphics.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/graphics.cpp 2007-02-25 20:18:11 UTC (rev 25865)
+++ scummvm/trunk/engines/parallaction/graphics.cpp 2007-02-25 20:35:47 UTC (rev 25866)
@@ -1020,29 +1020,29 @@
char path[PATH_LEN];
strcpy(path, filename);
- if (!openArchivedFile(path)) {
+ if (!_vm->_archive.openArchivedFile(path)) {
sprintf(path, "%s.pp", filename);
- if (!openArchivedFile(path))
+ if (!_vm->_archive.openArchivedFile(path))
errorFileNotFound(path);
}
cnv->_width = cnv->_height = 0;
byte unk;
- readArchivedFile(&unk, 1);
- readArchivedFile(&unk, 1);
+ _vm->_archive.readArchivedFile(&unk, 1);
+ _vm->_archive.readArchivedFile(&unk, 1);
cnv->_width = unk;
- readArchivedFile(&unk, 1);
+ _vm->_archive.readArchivedFile(&unk, 1);
cnv->_height = unk;
- uint16 compressedsize = getArchivedFileLength(path) - 3;
+ uint16 compressedsize = _vm->_archive.getArchivedFileLength(path) - 3;
byte *compressed = (byte*)memAlloc(compressedsize);
uint16 size = cnv->_width*cnv->_height;
cnv->_data0 = (byte*)memAlloc(size);
- readArchivedFile(compressed, compressedsize);
- closeArchivedFile();
+ _vm->_archive.readArchivedFile(compressed, compressedsize);
+ _vm->_archive.closeArchivedFile();
decompressChunk(compressed, cnv->_data0, size);
memFree(compressed);
@@ -1059,9 +1059,9 @@
char path[PATH_LEN];
strcpy(path, filename);
- if (!openArchivedFile(path)) {
+ if (!_vm->_archive.openArchivedFile(path)) {
sprintf(path, "%s.pp", filename);
- if (!openArchivedFile(path))
+ if (!_vm->_archive.openArchivedFile(path))
errorFileNotFound(path);
}
@@ -1069,21 +1069,21 @@
byte unk;
- readArchivedFile(&unk, 1);
+ _vm->_archive.readArchivedFile(&unk, 1);
cnv->_count = unk;
- readArchivedFile(&unk, 1);
+ _vm->_archive.readArchivedFile(&unk, 1);
cnv->_width = unk;
- readArchivedFile(&unk, 1);
+ _vm->_archive.readArchivedFile(&unk, 1);
cnv->_height = unk;
uint16 framesize = cnv->_width*cnv->_height;
cnv->_array = (byte**)memAlloc(cnv->_count * sizeof(byte*));
- uint32 size = getArchivedFileLength(path) - 3;
+ uint32 size = _vm->_archive.getArchivedFileLength(path) - 3;
byte *buf = (byte*)memAlloc(size);
- readArchivedFile(buf, size);
+ _vm->_archive.readArchivedFile(buf, size);
byte *s = buf;
@@ -1096,7 +1096,7 @@
s += read;
}
- closeArchivedFile();
+ _vm->_archive.closeArchivedFile();
memFree(buf);
@@ -1165,16 +1165,16 @@
void Graphics::loadBackground(const char *filename, Graphics::Buffers buffer) {
// printf("Graphics::loadBackground(%s)\n", filename);
- if (!openArchivedFile(filename))
+ if (!_vm->_archive.openArchivedFile(filename))
errorFileNotFound(filename);
// byte palette[PALETTE_SIZE];
byte v150[4];
- readArchivedFile(_palette, PALETTE_SIZE);
- readArchivedFile(&v150, 4);
+ _vm->_archive.readArchivedFile(_palette, PALETTE_SIZE);
+ _vm->_archive.readArchivedFile(&v150, 4);
byte tempfx[sizeof(PaletteFxRange)*6];
- readArchivedFile(&tempfx, sizeof(PaletteFxRange)*6);
+ _vm->_archive.readArchivedFile(&tempfx, sizeof(PaletteFxRange)*6);
// setPalette(palette);
@@ -1205,7 +1205,7 @@
memset(_buffers[kMask0], 0, SCREENMASK_WIDTH*SCREEN_HEIGHT);
byte *v4 = (byte*)memAlloc(SCREEN_SIZE);
- readArchivedFile(v4, SCREEN_SIZE);
+ _vm->_archive.readArchivedFile(v4, SCREEN_SIZE);
byte v144[SCREEN_WIDTH];
@@ -1216,7 +1216,7 @@
}
memFree(v4);
- closeArchivedFile();
+ _vm->_archive.closeArchivedFile();
return;
}
@@ -1229,17 +1229,17 @@
//
void Graphics::loadMaskAndPath(const char *filename) {
- if (!openArchivedFile(filename))
+ if (!_vm->_archive.openArchivedFile(filename))
errorFileNotFound(filename);
byte v4[4];
- readArchivedFile(v4, 4);
- readArchivedFile(_buffers[kPath0], SCREENPATH_WIDTH*SCREEN_HEIGHT);
- readArchivedFile(_buffers[kMask0], SCREENMASK_WIDTH*SCREEN_HEIGHT);
+ _vm->_archive.readArchivedFile(v4, 4);
+ _vm->_archive.readArchivedFile(_buffers[kPath0], SCREENPATH_WIDTH*SCREEN_HEIGHT);
+ _vm->_archive.readArchivedFile(_buffers[kMask0], SCREENMASK_WIDTH*SCREEN_HEIGHT);
for (uint16 _si = 0; _si < 4; _si++) _bgLayers[_si] = v4[_si];
- closeArchivedFile();
+ _vm->_archive.closeArchivedFile();
return;
}
Modified: scummvm/trunk/engines/parallaction/location.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/location.cpp 2007-02-25 20:18:11 UTC (rev 25865)
+++ scummvm/trunk/engines/parallaction/location.cpp 2007-02-25 20:35:47 UTC (rev 25866)
@@ -61,26 +61,26 @@
strcat(archivefile, filename);
strcat(archivefile, ".loc");
- if (strcmp(_disk, "null")) closeArchive();
+ if (strcmp(_disk, "null")) _archive.close();
_languageDir[2] = '\0';
- openArchive(_languageDir);
+ _archive.open(_languageDir);
_languageDir[2] = '/';
- if (!openArchivedFile(archivefile)) {
+ if (!_archive.openArchivedFile(archivefile)) {
sprintf(archivefile, "%s%s.loc", _languageDir, filename);
- if (!openArchivedFile(archivefile))
+ if (!_archive.openArchivedFile(archivefile))
errorFileNotFound(filename);
}
- uint32 count = getArchivedFileLength(archivefile);
+ uint32 count = _archive.getArchivedFileLength(archivefile);
location_src = (char*)memAlloc(0x4000);
_locationScript = new Script(location_src);
- readArchivedFile(location_src, count);
- closeArchivedFile();
- closeArchive();
+ _archive.readArchivedFile(location_src, count);
+ _archive.closeArchivedFile();
+ _archive.close();
fillBuffers(*_locationScript, true);
while (scumm_stricmp(_tokens[0], "ENDLOCATION")) {
@@ -134,7 +134,7 @@
if (!scumm_stricmp(_tokens[0], "DISK")) {
strcpy(_disk, _tokens[1]);
strcpy(archivefile, _disk);
- openArchive(archivefile);
+ _archive.open(archivefile);
}
if (!scumm_stricmp(_tokens[0], "LOCALFLAGS")) {
_si = 1; // _localFlagNames[0] = 'visited'
Modified: scummvm/trunk/engines/parallaction/menu.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/menu.cpp 2007-02-25 20:18:11 UTC (rev 25865)
+++ scummvm/trunk/engines/parallaction/menu.cpp 2007-02-25 20:35:47 UTC (rev 25866)
@@ -101,7 +101,7 @@
void Menu::start() {
- openArchive("disk1");
+ _vm->_archive.open("disk1");
_vm->_graphics->_proportionalFont = false;
_vm->_graphics->loadExternalCnv("slidecnv", &Graphics::_font);
@@ -157,7 +157,7 @@
newGame();
}
- closeArchive();
+ _vm->_archive.close();
return;
}
@@ -197,7 +197,7 @@
return; // show intro
_vm->_graphics->freeCnv(&Graphics::_font);
- closeArchive();
+ _vm->_archive.close();
selectCharacter();
@@ -286,7 +286,7 @@
strcpy(_engine->_characterName, "dough");
_vm->loadGame();
- closeArchive();
+ _vm->_archive.close();
return 1; // load game
}
@@ -317,7 +317,7 @@
_vm->_graphics->_proportionalFont = false;
_vm->_graphics->loadExternalCnv("slidecnv", &Graphics::_font);
- openArchive("disk1");
+ _vm->_archive.open("disk1");
_vm->_graphics->loadBackground("password.slide", Graphics::kBitBack);
_vm->_graphics->copyScreen(Graphics::kBitBack, Graphics::kBit2);
@@ -413,7 +413,7 @@
_vm->_graphics->setPalette(palette);
_engineFlags |= kEngineChangeLocation;
- closeArchive();
+ _vm->_archive.close();
memFree(v14._data0);
_vm->_graphics->freeCnv(&Graphics::_font);
Modified: scummvm/trunk/engines/parallaction/parallaction.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.cpp 2007-02-25 20:18:11 UTC (rev 25865)
+++ scummvm/trunk/engines/parallaction/parallaction.cpp 2007-02-25 20:35:47 UTC (rev 25866)
@@ -850,10 +850,10 @@
freeCharacterFrames();
}
- closeArchive();
+ _archive.close();
strcpy(_disk, "disk1");
- openArchive("disk1");
+ _archive.open("disk1");
char path[PATH_LEN];
strcpy(path, v32);
Modified: scummvm/trunk/engines/parallaction/parallaction.h
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.h 2007-02-25 20:18:11 UTC (rev 25865)
+++ scummvm/trunk/engines/parallaction/parallaction.h 2007-02-25 20:35:47 UTC (rev 25866)
@@ -27,6 +27,7 @@
#include "parallaction/defs.h"
#include "parallaction/inventory.h"
#include "parallaction/parser.h"
+#include "parallaction/disk.h"
#include "common/str.h"
#include "gui/dialog.h"
#include "gui/widget.h"
@@ -273,6 +274,8 @@
Script *_locationScript;
+ Archive _archive;
+
protected: // data
struct InputData {
Modified: scummvm/trunk/engines/parallaction/saveload.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/saveload.cpp 2007-02-25 20:18:11 UTC (rev 25865)
+++ scummvm/trunk/engines/parallaction/saveload.cpp 2007-02-25 20:35:47 UTC (rev 25866)
@@ -134,7 +134,7 @@
refreshInventory(_vm->_characterName);
parseLocation("common");
- closeArchive();
+ _archive.close();
strcat(_location, _vm->_characterName);
_engineFlags |= kEngineChangeLocation;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list