wrapped loader routines into a new class named Disk. The new class is also responsible for handling Archives in place of the Parallaction engine.

svn-id: r25972
This commit is contained in:
Nicola Mettifogo 2007-03-04 13:27:29 +00:00
parent 826b16ef71
commit b440bc1a03
13 changed files with 154 additions and 128 deletions

View file

@ -128,7 +128,7 @@ Animation *Parallaction::parseAnimation(Script& script, Node *list, char *name)
} }
} }
loadFrames(vC8, &vD0->_cnv); _disk->loadFrames(vC8, &vD0->_cnv);
// int16 _ax = _vm->_graphics->loadCnv(vC8, &vD0->_cnv); // int16 _ax = _vm->_graphics->loadCnv(vC8, &vD0->_cnv);
// if (_ax == -1) exit(-1); // if (_ax == -1) exit(-1);
} }
@ -253,7 +253,7 @@ void Parallaction::loadProgram(Animation *a, char *filename) {
// the largest script in Nippon Safes is 3,668 bytes, so 4 kb is well enough // the largest script in Nippon Safes is 3,668 bytes, so 4 kb is well enough
char* src = (char*)malloc(0x1000); char* src = (char*)malloc(0x1000);
loadScript(filename, src); _disk->loadScript(filename, src);
_numLocals = 0; _numLocals = 0;

View file

@ -353,7 +353,6 @@ void _c_ridux(void *parm) {
void _c_testResult(void *parm) { void _c_testResult(void *parm) {
_vm->_graphics->swapBuffers(); _vm->_graphics->swapBuffers();
_vm->parseLocation("common"); _vm->parseLocation("common");
_vm->_archive.close();
_vm->_graphics->setFont("slide"); _vm->_graphics->setFont("slide");
_vm->_graphics->_proportionalFont = false; _vm->_graphics->_proportionalFont = false;

View file

@ -229,7 +229,7 @@ void runDialogue(SpeakData *data) {
debugC(1, kDebugDialogue, "runDialogue: special trick for 'museum' location"); debugC(1, kDebugDialogue, "runDialogue: special trick for 'museum' location");
} }
loadTalk(_vm->_characterName, &_characterFace); _vm->_disk->loadTalk(_vm->_characterName, &_characterFace);
_vm->_graphics->setFont("comic"); _vm->_graphics->setFont("comic");
@ -241,7 +241,7 @@ void runDialogue(SpeakData *data) {
debugC(1, kDebugDialogue, "runDialogue: using default character head"); debugC(1, kDebugDialogue, "runDialogue: using default character head");
} else { } else {
debugC(1, kDebugDialogue, "runDialogue: loading 2nd character head '%s'", _vm->_characterName); debugC(1, kDebugDialogue, "runDialogue: loading 2nd character head '%s'", _vm->_characterName);
loadTalk(data->_name, &v6E); _vm->_disk->loadTalk(data->_name, &v6E);
debugC(1, kDebugDialogue, "runDialogue: 2nd character head loaded"); debugC(1, kDebugDialogue, "runDialogue: 2nd character head loaded");
} }
@ -509,11 +509,8 @@ void runDialogue(SpeakData *data) {
debugC(1, kDebugDialogue, "runDialogue: exit dialogue ok"); debugC(1, kDebugDialogue, "runDialogue: exit dialogue ok");
if (!scumm_stricmp(_location, "museum")) { if (!scumm_stricmp(_location, "museum")) {
_vm->_disk->selectArchive("disk1");
_vm->_archive.close(); _vm->_disk->loadFrames("dino", &_tempFrames);
strcpy(_vm->_disk, "disk1");
_vm->_archive.open(_vm->_disk);
loadFrames("dino", &_tempFrames);
memcpy(&_yourself._cnv, &_tempFrames, sizeof(Cnv)); memcpy(&_yourself._cnv, &_tempFrames, sizeof(Cnv));

View file

@ -27,10 +27,19 @@
namespace Parallaction { namespace Parallaction {
Disk::Disk(Parallaction* vm) : _vm(vm) {
}
Disk::~Disk() {
_archive.close();
}
// //
// decompress a graphics block // decompress a graphics block
// //
uint16 decompressChunk(byte *src, byte *dst, uint16 size) { uint16 Disk::decompressChunk(byte *src, byte *dst, uint16 size) {
uint16 written = 0; uint16 written = 0;
uint16 read = 0; uint16 read = 0;
@ -66,7 +75,7 @@ uint16 decompressChunk(byte *src, byte *dst, uint16 size) {
// //
// loads a cnv from an external file // loads a cnv from an external file
// //
void loadExternalCnv(const char *filename, Cnv *cnv) { void Disk::loadExternalCnv(const char *filename, Cnv *cnv) {
// printf("Graphics::loadExternalCnv(%s)...", filename); // printf("Graphics::loadExternalCnv(%s)...", filename);
char path[PATH_LEN]; char path[PATH_LEN];
@ -98,7 +107,7 @@ void loadExternalCnv(const char *filename, Cnv *cnv) {
return; return;
} }
void loadExternalStaticCnv(const char *filename, StaticCnv *cnv) { void Disk::loadExternalStaticCnv(const char *filename, StaticCnv *cnv) {
char path[PATH_LEN]; char path[PATH_LEN];
@ -125,30 +134,30 @@ void loadExternalStaticCnv(const char *filename, StaticCnv *cnv) {
return; return;
} }
void loadCnv(const char *filename, Cnv *cnv) { void Disk::loadCnv(const char *filename, Cnv *cnv) {
// printf("Graphics::loadCnv(%s)\n", filename); // printf("Graphics::loadCnv(%s)\n", filename);
char path[PATH_LEN]; char path[PATH_LEN];
strcpy(path, filename); strcpy(path, filename);
if (!_vm->_archive.openArchivedFile(path)) { if (!_archive.openArchivedFile(path)) {
sprintf(path, "%s.pp", filename); sprintf(path, "%s.pp", filename);
if (!_vm->_archive.openArchivedFile(path)) if (!_archive.openArchivedFile(path))
errorFileNotFound(path); errorFileNotFound(path);
} }
cnv->_count = _vm->_archive.readByte(); cnv->_count = _archive.readByte();
cnv->_width = _vm->_archive.readByte(); cnv->_width = _archive.readByte();
cnv->_height = _vm->_archive.readByte(); cnv->_height = _archive.readByte();
uint16 framesize = cnv->_width*cnv->_height; uint16 framesize = cnv->_width*cnv->_height;
cnv->_array = (byte**)malloc(cnv->_count * sizeof(byte*)); cnv->_array = (byte**)malloc(cnv->_count * sizeof(byte*));
uint32 size = _vm->_archive.size() - 3; uint32 size = _archive.size() - 3;
byte *buf = (byte*)malloc(size); byte *buf = (byte*)malloc(size);
_vm->_archive.read(buf, size); _archive.read(buf, size);
byte *s = buf; byte *s = buf;
@ -161,14 +170,14 @@ void loadCnv(const char *filename, Cnv *cnv) {
s += read; s += read;
} }
_vm->_archive.closeArchivedFile(); _archive.closeArchivedFile();
free(buf); free(buf);
return; return;
} }
void loadTalk(const char *name, Cnv *cnv) { void Disk::loadTalk(const char *name, Cnv *cnv) {
char* ext = strstr(name, ".talk"); char* ext = strstr(name, ".talk");
if (ext != NULL) { if (ext != NULL) {
@ -196,7 +205,7 @@ void loadTalk(const char *name, Cnv *cnv) {
} }
void loadLocation(const char *name, char* script) { void Disk::loadLocation(const char *name, char* script) {
char archivefile[PATH_LEN]; char archivefile[PATH_LEN];
@ -211,44 +220,44 @@ void loadLocation(const char *name, char* script) {
strcat(archivefile, name); strcat(archivefile, name);
strcat(archivefile, ".loc"); strcat(archivefile, ".loc");
_vm->_archive.close(); _archive.close();
_vm->_languageDir[2] = '\0'; _vm->_languageDir[2] = '\0';
_vm->_archive.open(_vm->_languageDir); _archive.open(_vm->_languageDir);
_vm->_languageDir[2] = '/'; _vm->_languageDir[2] = '/';
if (!_vm->_archive.openArchivedFile(archivefile)) { if (!_archive.openArchivedFile(archivefile)) {
sprintf(archivefile, "%s%s.loc", _vm->_languageDir, name); sprintf(archivefile, "%s%s.loc", _vm->_languageDir, name);
if (!_vm->_archive.openArchivedFile(archivefile)) if (!_archive.openArchivedFile(archivefile))
error("can't find location file '%s'", name); error("can't find location file '%s'", name);
} }
uint32 count = _vm->_archive.size(); uint32 count = _archive.size();
_vm->_archive.read(script, count); _archive.read(script, count);
_vm->_archive.closeArchivedFile(); _archive.closeArchivedFile();
_vm->_archive.close(); _archive.close();
} }
void loadScript(const char* name, char *script) { void Disk::loadScript(const char* name, char *script) {
char vC8[PATH_LEN]; char vC8[PATH_LEN];
sprintf(vC8, "%s.script", name); sprintf(vC8, "%s.script", name);
if (!_vm->_archive.openArchivedFile(vC8)) if (!_archive.openArchivedFile(vC8))
errorFileNotFound(vC8); errorFileNotFound(vC8);
uint32 size = _vm->_archive.size(); uint32 size = _archive.size();
_vm->_archive.read(script, size); _archive.read(script, size);
script[size] = '\0'; script[size] = '\0';
_vm->_archive.closeArchivedFile(); _archive.closeArchivedFile();
} }
void loadHead(const char* name, StaticCnv* cnv) { void Disk::loadHead(const char* name, StaticCnv* cnv) {
char path[PATH_LEN]; char path[PATH_LEN];
@ -264,11 +273,11 @@ void loadHead(const char* name, StaticCnv* cnv) {
} }
void loadPointer(StaticCnv* cnv) { void Disk::loadPointer(StaticCnv* cnv) {
loadExternalStaticCnv("pointer", cnv); loadExternalStaticCnv("pointer", cnv);
} }
void loadFont(const char* name, Cnv* cnv) { void Disk::loadFont(const char* name, Cnv* cnv) {
char path[PATH_LEN]; char path[PATH_LEN];
sprintf(path, "%scnv", name); sprintf(path, "%scnv", name);
@ -277,7 +286,7 @@ void loadFont(const char* name, Cnv* cnv) {
// loads character's icons set // loads character's icons set
void loadObjects(const char *name, Cnv* cnv) { void Disk::loadObjects(const char *name, Cnv* cnv) {
if (!scumm_strnicmp("mini", name, 4)) { if (!scumm_strnicmp("mini", name, 4)) {
name += 4; name += 4;
@ -292,29 +301,29 @@ void loadObjects(const char *name, Cnv* cnv) {
} }
void loadStatic(const char* name, StaticCnv* cnv) { void Disk::loadStatic(const char* name, StaticCnv* cnv) {
char path[PATH_LEN]; char path[PATH_LEN];
strcpy(path, name); strcpy(path, name);
if (!_vm->_archive.openArchivedFile(path)) { if (!_archive.openArchivedFile(path)) {
sprintf(path, "%s.pp", name); sprintf(path, "%s.pp", name);
if (!_vm->_archive.openArchivedFile(path)) if (!_archive.openArchivedFile(path))
errorFileNotFound(path); errorFileNotFound(path);
} }
_vm->_archive.skip(1); _archive.skip(1);
cnv->_width = _vm->_archive.readByte(); cnv->_width = _archive.readByte();
cnv->_height = _vm->_archive.readByte(); cnv->_height = _archive.readByte();
uint16 compressedsize = _vm->_archive.size() - 3; uint16 compressedsize = _archive.size() - 3;
byte *compressed = (byte*)malloc(compressedsize); byte *compressed = (byte*)malloc(compressedsize);
uint16 size = cnv->_width*cnv->_height; uint16 size = cnv->_width*cnv->_height;
cnv->_data0 = (byte*)malloc(size); cnv->_data0 = (byte*)malloc(size);
_vm->_archive.read(compressed, compressedsize); _archive.read(compressed, compressedsize);
_vm->_archive.closeArchivedFile(); _archive.closeArchivedFile();
decompressChunk(compressed, cnv->_data0, size); decompressChunk(compressed, cnv->_data0, size);
free(compressed); free(compressed);
@ -322,7 +331,7 @@ void loadStatic(const char* name, StaticCnv* cnv) {
return; return;
} }
void loadFrames(const char* name, Cnv* cnv) { void Disk::loadFrames(const char* name, Cnv* cnv) {
loadCnv(name, cnv); loadCnv(name, cnv);
@ -339,7 +348,7 @@ void loadFrames(const char* name, Cnv* cnv) {
// //
void unpackBackgroundScanline(byte *src, byte *screen, byte *mask, byte *path) { void Disk::unpackBackgroundScanline(byte *src, byte *screen, byte *mask, byte *path) {
// update mask, path and screen // update mask, path and screen
for (uint16 i = 0; i < SCREEN_WIDTH; i++) { for (uint16 i = 0; i < SCREEN_WIDTH; i++) {
@ -351,20 +360,20 @@ void unpackBackgroundScanline(byte *src, byte *screen, byte *mask, byte *path) {
return; return;
} }
void loadBackground(const char *filename) { void Disk::loadBackground(const char *filename) {
// printf("Graphics::loadBackground(%s)\n", filename); // printf("Graphics::loadBackground(%s)\n", filename);
if (!_vm->_archive.openArchivedFile(filename)) if (!_archive.openArchivedFile(filename))
errorFileNotFound(filename); errorFileNotFound(filename);
_vm->_graphics->parseBackground(_vm->_archive); _vm->_graphics->parseBackground(_archive);
byte *bg = (byte*)calloc(1, SCREEN_WIDTH*SCREEN_HEIGHT); byte *bg = (byte*)calloc(1, SCREEN_WIDTH*SCREEN_HEIGHT);
byte *mask = (byte*)calloc(1, SCREENMASK_WIDTH*SCREEN_HEIGHT); byte *mask = (byte*)calloc(1, SCREENMASK_WIDTH*SCREEN_HEIGHT);
byte *path = (byte*)calloc(1, SCREENPATH_WIDTH*SCREEN_HEIGHT); byte *path = (byte*)calloc(1, SCREENPATH_WIDTH*SCREEN_HEIGHT);
byte *v4 = (byte*)malloc(SCREEN_SIZE); byte *v4 = (byte*)malloc(SCREEN_SIZE);
_vm->_archive.read(v4, SCREEN_SIZE); _archive.read(v4, SCREEN_SIZE);
byte v144[SCREEN_WIDTH]; byte v144[SCREEN_WIDTH];
@ -393,20 +402,20 @@ void loadBackground(const char *filename) {
// mask and path are normally combined (via OR) into the background picture itself // mask and path are normally combined (via OR) into the background picture itself
// read the comment on the top of this file for more // read the comment on the top of this file for more
// //
void loadMaskAndPath(const char *name) { void Disk::loadMaskAndPath(const char *name) {
char path[PATH_LEN]; char path[PATH_LEN];
sprintf(path, "%s.msk", name); sprintf(path, "%s.msk", name);
if (!_vm->_archive.openArchivedFile(path)) if (!_archive.openArchivedFile(path))
errorFileNotFound(name); errorFileNotFound(name);
byte *maskBuf = (byte*)calloc(1, SCREENMASK_WIDTH*SCREEN_HEIGHT); byte *maskBuf = (byte*)calloc(1, SCREENMASK_WIDTH*SCREEN_HEIGHT);
byte *pathBuf = (byte*)calloc(1, SCREENPATH_WIDTH*SCREEN_HEIGHT); byte *pathBuf = (byte*)calloc(1, SCREENPATH_WIDTH*SCREEN_HEIGHT);
_vm->_graphics->parseDepths(_vm->_archive); _vm->_graphics->parseDepths(_archive);
_vm->_archive.read(pathBuf, SCREENPATH_WIDTH*SCREEN_HEIGHT); _archive.read(pathBuf, SCREENPATH_WIDTH*SCREEN_HEIGHT);
_vm->_archive.read(maskBuf, SCREENMASK_WIDTH*SCREEN_HEIGHT); _archive.read(maskBuf, SCREENMASK_WIDTH*SCREEN_HEIGHT);
_vm->_graphics->setMask(maskBuf); _vm->_graphics->setMask(maskBuf);
_vm->_graphics->setPath(pathBuf); _vm->_graphics->setPath(pathBuf);
@ -414,13 +423,13 @@ void loadMaskAndPath(const char *name) {
return; return;
} }
void loadSlide(const char *filename) { void Disk::loadSlide(const char *filename) {
char path[PATH_LEN]; char path[PATH_LEN];
sprintf(path, "%s.slide", filename); sprintf(path, "%s.slide", filename);
loadBackground(path); loadBackground(path);
} }
void loadScenery(const char *name, const char *mask) { void Disk::loadScenery(const char *name, const char *mask) {
char path[PATH_LEN]; char path[PATH_LEN];
sprintf(path, "%s.dyn", name); sprintf(path, "%s.dyn", name);
loadBackground(path); loadBackground(path);
@ -432,4 +441,9 @@ void loadScenery(const char *name, const char *mask) {
} }
void Disk::selectArchive(const char *name) {
_archive.close();
_archive.open(name);
}
} // namespace Parallaction } // namespace Parallaction

View file

@ -37,6 +37,9 @@ namespace Parallaction {
#define DIRECTORY_OFFSET_IN_FILE 0x4000 #define DIRECTORY_OFFSET_IN_FILE 0x4000
class Parallaction;
class Graphics;
class Archive : public Common::SeekableReadStream { class Archive : public Common::SeekableReadStream {
protected: protected:
@ -72,17 +75,41 @@ public:
uint32 read(void *dataPtr, uint32 dataSize); uint32 read(void *dataPtr, uint32 dataSize);
}; };
void loadLocation(const char *name, char* script); class Disk {
void loadScript(const char* name, char *script);
void loadTalk(const char *name, Cnv *cnv); private:
void loadObjects(const char *name, Cnv *cnv); uint16 decompressChunk(byte *src, byte *dst, uint16 size);
void loadPointer(StaticCnv* cnv); void unpackBackgroundScanline(byte *src, byte *screen, byte *mask, byte *path);
void loadHead(const char* name, StaticCnv* cnv); void loadExternalCnv(const char *filename, Cnv *cnv);
void loadFont(const char* name, Cnv* cnv); void loadCnv(const char *filename, Cnv *cnv);
void loadStatic(const char* name, StaticCnv* cnv); void loadExternalStaticCnv(const char *filename, StaticCnv *cnv);
void loadFrames(const char* name, Cnv* cnv); void loadBackground(const char *filename);
void loadSlide(const char *filename); void loadMaskAndPath(const char *name);
void loadScenery(const char* background, const char* mask);
protected:
Archive _archive;
Parallaction *_vm;
Graphics *_gfx;
public:
Disk(Parallaction *vm);
virtual ~Disk();
void selectArchive(const char *name);
void loadLocation(const char *name, char* script);
void loadScript(const char* name, char *script);
void loadTalk(const char *name, Cnv *cnv);
void loadObjects(const char *name, Cnv *cnv);
void loadPointer(StaticCnv* cnv);
void loadHead(const char* name, StaticCnv* cnv);
void loadFont(const char* name, Cnv* cnv);
void loadStatic(const char* name, StaticCnv* cnv);
void loadFrames(const char* name, Cnv* cnv);
void loadSlide(const char *filename);
void loadScenery(const char* background, const char* mask);
};
} // namespace Parallaction } // namespace Parallaction

View file

@ -509,7 +509,7 @@ void jobEraseLabel(void *parm, Job *j) {
void Graphics::initMouse(uint16 arg_0) { void Graphics::initMouse(uint16 arg_0) {
loadPointer(&_mouseComposedArrow); _vm->_disk->loadPointer(&_mouseComposedArrow);
byte temp[16*16]; byte temp[16*16];
memcpy(temp, _mouseArrow, 16*16); memcpy(temp, _mouseArrow, 16*16);
@ -800,7 +800,7 @@ void Graphics::setFont(const char* name) {
if (_font._array != NULL) if (_font._array != NULL)
freeCnv(&_font); freeCnv(&_font);
loadFont(name, &_font); _vm->_disk->loadFont(name, &_font);
} }

View file

@ -372,7 +372,7 @@ void cleanInventory() {
void refreshInventory(const char *character) { void refreshInventory(const char *character) {
loadObjects(character, &_characterInventory); _vm->_disk->loadObjects(character, &_characterInventory);
redrawInventory(); redrawInventory();
_vm->_graphics->freeCnv(&_characterInventory); _vm->_graphics->freeCnv(&_characterInventory);
@ -381,7 +381,7 @@ void refreshInventory(const char *character) {
void refreshInventoryItem(const char *character, uint16 index) { void refreshInventoryItem(const char *character, uint16 index) {
loadObjects(character, &_characterInventory); _vm->_disk->loadObjects(character, &_characterInventory);
drawInventoryItem(index, &_inventory[index]); drawInventoryItem(index, &_inventory[index]);
_vm->_graphics->freeCnv(&_characterInventory); _vm->_graphics->freeCnv(&_characterInventory);

View file

@ -48,7 +48,7 @@ void Parallaction::parseLocation(const char *filename) {
_vm->_graphics->setFont("topaz"); _vm->_graphics->setFont("topaz");
location_src = (char*)malloc(0x4000); location_src = (char*)malloc(0x4000);
loadLocation(filename, location_src); _disk->loadLocation(filename, location_src);
_locationScript = new Script(location_src); _locationScript = new Script(location_src);
fillBuffers(*_locationScript, true); fillBuffers(*_locationScript, true);
@ -105,8 +105,7 @@ void Parallaction::parseLocation(const char *filename) {
} }
} }
if (!scumm_stricmp(_tokens[0], "DISK")) { if (!scumm_stricmp(_tokens[0], "DISK")) {
strcpy(_disk, _tokens[1]); _disk->selectArchive(_tokens[1]);
_archive.open(_disk);
} }
if (!scumm_stricmp(_tokens[0], "LOCALFLAGS")) { if (!scumm_stricmp(_tokens[0], "LOCALFLAGS")) {
_si = 1; // _localFlagNames[0] = 'visited' _si = 1; // _localFlagNames[0] = 'visited'
@ -277,7 +276,7 @@ void switchBackground(const char* background, const char* mask) {
_vm->_graphics->palUnk0(palette); _vm->_graphics->palUnk0(palette);
} }
loadScenery(background, mask); _vm->_disk->loadScenery(background, mask);
return; return;
} }
@ -355,19 +354,19 @@ void Parallaction::changeLocation(char *location) {
*tmp = '\0'; *tmp = '\0';
if (!scumm_strnicmp(tmp+1, "slide", 5)) { if (!scumm_strnicmp(tmp+1, "slide", 5)) {
loadSlide(_newLocation); _disk->loadSlide(_newLocation);
_vm->_graphics->palUnk0(_palette); _graphics->palUnk0(_palette);
_vm->_graphics->copyScreen(Graphics::kBitBack, Graphics::kBitFront); _graphics->copyScreen(Graphics::kBitBack, Graphics::kBitFront);
debugC(1, kDebugLocation, "changeLocation: new background set"); debugC(1, kDebugLocation, "changeLocation: new background set");
_vm->_graphics->_proportionalFont = false; _graphics->_proportionalFont = false;
_vm->_graphics->setFont("slide"); _graphics->setFont("slide");
uint16 _ax = strlen(_slideText[0]); uint16 _ax = strlen(_slideText[0]);
_ax <<= 3; // text width _ax <<= 3; // text width
uint16 _dx = (SCREEN_WIDTH - _ax) >> 1; // center text uint16 _dx = (SCREEN_WIDTH - _ax) >> 1; // center text
_vm->_graphics->displayString(_dx, 14, _slideText[0]); // displays text on screen _graphics->displayString(_dx, 14, _slideText[0]); // displays text on screen
waitUntilLeftClick(); waitUntilLeftClick();
@ -397,7 +396,7 @@ void Parallaction::changeLocation(char *location) {
strcpy(_saveData1, _newLocation); strcpy(_saveData1, _newLocation);
parseLocation(_newLocation); parseLocation(_newLocation);
_vm->_graphics->copyScreen(Graphics::kBitBack, Graphics::kBit2); _graphics->copyScreen(Graphics::kBitBack, Graphics::kBit2);
debugC(1, kDebugLocation, "changeLocation: new location '%s' parsed", _newLocation); debugC(1, kDebugLocation, "changeLocation: new location '%s' parsed", _newLocation);
_yourself._zone.pos._oldposition._x = -1000; _yourself._zone.pos._oldposition._x = -1000;
@ -416,14 +415,14 @@ void Parallaction::changeLocation(char *location) {
byte palette[PALETTE_SIZE]; byte palette[PALETTE_SIZE];
for (uint16 _si = 0; _si < PALETTE_SIZE; _si++) palette[_si] = 0; for (uint16 _si = 0; _si < PALETTE_SIZE; _si++) palette[_si] = 0;
_vm->_graphics->palUnk0(palette); _graphics->palUnk0(palette);
_vm->_graphics->copyScreen(Graphics::kBitBack, Graphics::kBitFront); _graphics->copyScreen(Graphics::kBitBack, Graphics::kBitFront);
if (_locationCommands) { if (_locationCommands) {
runCommands(_locationCommands); runCommands(_locationCommands);
runJobs(); runJobs();
_vm->_graphics->swapBuffers(); _graphics->swapBuffers();
runJobs(); runJobs();
_vm->_graphics->swapBuffers(); _graphics->swapBuffers();
} }
if (_locationComment) { if (_locationComment) {
@ -432,9 +431,9 @@ void Parallaction::changeLocation(char *location) {
} }
runJobs(); runJobs();
_vm->_graphics->swapBuffers(); _graphics->swapBuffers();
_vm->_graphics->palUnk0(_palette); _graphics->palUnk0(_palette);
if (_locationACommands) { if (_locationACommands) {
runCommands(_locationACommands); runCommands(_locationACommands);
debugC(1, kDebugLocation, "changeLocation: location acommands run"); debugC(1, kDebugLocation, "changeLocation: location acommands run");

View file

@ -101,24 +101,24 @@ Menu::~Menu() {
void Menu::start() { void Menu::start() {
_vm->_archive.open("disk1"); _vm->_disk->selectArchive("disk1");
_vm->_graphics->_proportionalFont = false; _vm->_graphics->_proportionalFont = false;
_vm->_graphics->setFont("slide"); _vm->_graphics->setFont("slide");
loadSlide("intro"); _vm->_disk->loadSlide("intro");
_vm->_graphics->palUnk0(_palette); _vm->_graphics->palUnk0(_palette);
_vm->_graphics->copyScreen(Graphics::kBitBack, Graphics::kBitFront); _vm->_graphics->copyScreen(Graphics::kBitBack, Graphics::kBitFront);
g_system->delayMillis(2000); g_system->delayMillis(2000);
loadSlide("minintro"); _vm->_disk->loadSlide("minintro");
_vm->_graphics->palUnk0(_palette); _vm->_graphics->palUnk0(_palette);
_vm->_graphics->copyScreen(Graphics::kBitBack, Graphics::kBitFront); _vm->_graphics->copyScreen(Graphics::kBitBack, Graphics::kBitFront);
g_system->delayMillis(2000); g_system->delayMillis(2000);
loadSlide("lingua"); _vm->_disk->loadSlide("lingua");
_vm->_graphics->palUnk0(_palette); _vm->_graphics->palUnk0(_palette);
_vm->_graphics->copyScreen(Graphics::kBitBack, Graphics::kBitFront); _vm->_graphics->copyScreen(Graphics::kBitBack, Graphics::kBitFront);
@ -146,7 +146,7 @@ void Menu::start() {
break; break;
} }
loadSlide("restore"); _vm->_disk->loadSlide("restore");
_vm->_graphics->palUnk0(_palette); _vm->_graphics->palUnk0(_palette);
_vm->_graphics->copyScreen(Graphics::kBitBack, Graphics::kBitFront); _vm->_graphics->copyScreen(Graphics::kBitBack, Graphics::kBitFront);
@ -157,8 +157,6 @@ void Menu::start() {
newGame(); newGame();
} }
_vm->_archive.close();
return; return;
} }
@ -167,7 +165,7 @@ void Menu::newGame() {
const char **v14 = introMsg3; const char **v14 = introMsg3;
loadScenery("test", NULL); _vm->_disk->loadScenery("test", NULL);
_vm->_graphics->palUnk0(_palette); _vm->_graphics->palUnk0(_palette);
_vm->_graphics->swapBuffers(); _vm->_graphics->swapBuffers();
@ -196,8 +194,6 @@ void Menu::newGame() {
if (_mouseButtons != kMouseRightUp) if (_mouseButtons != kMouseRightUp)
return; // show intro return; // show intro
_vm->_archive.close();
selectCharacter(); selectCharacter();
char *v4 = strchr(_location, '.') + 1; char *v4 = strchr(_location, '.') + 1;
@ -284,7 +280,6 @@ uint16 Menu::selectGame() {
strcpy(_engine->_characterName, "dough"); strcpy(_engine->_characterName, "dough");
_vm->loadGame(); _vm->loadGame();
_vm->_archive.close();
return 1; // load game return 1; // load game
} }
@ -315,9 +310,9 @@ void Menu::selectCharacter() {
_vm->_graphics->_proportionalFont = false; _vm->_graphics->_proportionalFont = false;
_vm->_graphics->setFont("slide"); _vm->_graphics->setFont("slide");
_vm->_archive.open("disk1"); _vm->_disk->selectArchive("disk1");
loadSlide("password"); _vm->_disk->loadSlide("password");
_vm->_graphics->copyScreen(Graphics::kBitBack, Graphics::kBit2); _vm->_graphics->copyScreen(Graphics::kBitBack, Graphics::kBit2);
_vm->_graphics->palUnk0(_palette); _vm->_graphics->palUnk0(_palette);
@ -411,7 +406,6 @@ void Menu::selectCharacter() {
_vm->_graphics->setPalette(palette); _vm->_graphics->setPalette(palette);
_engineFlags |= kEngineChangeLocation; _engineFlags |= kEngineChangeLocation;
_vm->_archive.close();
free(v14._data0); free(v14._data0);

View file

@ -162,6 +162,7 @@ Parallaction::Parallaction(OSystem *syst) :
// FIXME // FIXME
_vm = this; _vm = this;
_disk = new Disk(this);
_skipMenu = false; _skipMenu = false;
@ -203,6 +204,7 @@ Parallaction::Parallaction(OSystem *syst) :
Parallaction::~Parallaction() { Parallaction::~Parallaction() {
delete _midiPlayer; delete _midiPlayer;
delete _disk;
} }
@ -850,18 +852,15 @@ void Parallaction::changeCharacter(const char *name) {
freeCharacterFrames(); freeCharacterFrames();
} }
_archive.close(); _disk->selectArchive("disk1");
strcpy(_disk, "disk1");
_archive.open("disk1");
char path[PATH_LEN]; char path[PATH_LEN];
strcpy(path, v32); strcpy(path, v32);
loadFrames(path, &_tempFrames); _disk->loadFrames(path, &_tempFrames);
if (name[0] != 'D') { if (name[0] != 'D') {
sprintf(path, "mini%s", v32); sprintf(path, "mini%s", v32);
loadFrames(path, &_miniCharacterFrames); _disk->loadFrames(path, &_miniCharacterFrames);
sprintf(path, "%s.tab", name); sprintf(path, "%s.tab", name);
initTable(path, _objectsNames); initTable(path, _objectsNames);

View file

@ -264,7 +264,7 @@ public:
Menu* _menu; Menu* _menu;
char _characterName[30]; char _characterName[30];
char _languageDir[6]; char _languageDir[6];
char _disk[6]; Disk* _disk;
char _locationNames[120][32]; char _locationNames[120][32];
int16 _currentLocationIndex; int16 _currentLocationIndex;
@ -274,8 +274,6 @@ public:
Script *_locationScript; Script *_locationScript;
Archive _archive;
protected: // data protected: // data
struct InputData { struct InputData {

View file

@ -134,7 +134,6 @@ void Parallaction::doLoadGame(uint16 slot) {
refreshInventory(_vm->_characterName); refreshInventory(_vm->_characterName);
parseLocation("common"); parseLocation("common");
_archive.close();
strcat(_location, _vm->_characterName); strcat(_location, _vm->_characterName);
_engineFlags |= kEngineChangeLocation; _engineFlags |= kEngineChangeLocation;

View file

@ -279,7 +279,7 @@ void Parallaction::parseZoneTypeBlock(Script &script, Zone *z) {
strcpy(vC8, _tokens[1]); strcpy(vC8, _tokens[1]);
StaticCnv vE0; StaticCnv vE0;
loadFrames(vC8, doorcnv); _disk->loadFrames(vC8, doorcnv);
// printf("door width: %i, height: %i", doorcnv->_width, doorcnv->_height ); // printf("door width: %i, height: %i", doorcnv->_width, doorcnv->_height );
@ -293,9 +293,9 @@ void Parallaction::parseZoneTypeBlock(Script &script, Zone *z) {
// vE0._data1 = doorcnv->field_8[_ax]; // vE0._data1 = doorcnv->field_8[_ax];
vE0._data2 = u->door->_background = (byte*)malloc(vE0._width*vE0._height); vE0._data2 = u->door->_background = (byte*)malloc(vE0._width*vE0._height);
_vm->_graphics->backupCnvBackground(&vE0, z->_limits._left, z->_limits._top); _graphics->backupCnvBackground(&vE0, z->_limits._left, z->_limits._top);
_vm->_graphics->flatBlitCnv(&vE0, z->_limits._left, z->_limits._top, Graphics::kBitBack, vE0._data1); _graphics->flatBlitCnv(&vE0, z->_limits._left, z->_limits._top, Graphics::kBitBack, vE0._data1);
} }
if (!scumm_stricmp(_tokens[0], "startpos")) { if (!scumm_stricmp(_tokens[0], "startpos")) {
@ -309,12 +309,12 @@ void Parallaction::parseZoneTypeBlock(Script &script, Zone *z) {
if (!scumm_stricmp(_tokens[0], "file")) { if (!scumm_stricmp(_tokens[0], "file")) {
StaticCnv *vE4 = &u->get->_cnv; StaticCnv *vE4 = &u->get->_cnv;
strcpy(vC8, _tokens[1]); strcpy(vC8, _tokens[1]);
loadStatic(vC8, vE4); _disk->loadStatic(vC8, vE4);
vE4->_data2 = (byte*)malloc(vE4->_width*vE4->_height); vE4->_data2 = (byte*)malloc(vE4->_width*vE4->_height);
if ((z->_flags & kFlagsRemove) == 0) { if ((z->_flags & kFlagsRemove) == 0) {
_vm->_graphics->backupCnvBackgroundTransparent(vE4, z->_limits._left, z->_limits._top); _graphics->backupCnvBackgroundTransparent(vE4, z->_limits._left, z->_limits._top);
_vm->_graphics->flatBlitCnv(vE4, z->_limits._left, z->_limits._top, Graphics::kBitBack, vE4->_data1); _graphics->flatBlitCnv(vE4, z->_limits._left, z->_limits._top, Graphics::kBitBack, vE4->_data1);
} }
} }
@ -365,7 +365,7 @@ void Parallaction::parseZoneTypeBlock(Script &script, Zone *z) {
void displayCharacterComment(ExamineData *data) { void displayCharacterComment(ExamineData *data) {
if (data->_description == NULL) return; if (data->_description == NULL) return;
loadTalk(_vm->_characterName, &_characterFace); _vm->_disk->loadTalk(_vm->_characterName, &_characterFace);
StaticCnv v3C; StaticCnv v3C;
v3C._width = _characterFace._width; v3C._width = _characterFace._width;
@ -412,12 +412,12 @@ void displayItemComment(ExamineData *data) {
char v68[PATH_LEN]; char v68[PATH_LEN];
strcpy(v68, data->_filename); strcpy(v68, data->_filename);
loadStatic(v68, &data->_cnv); _vm->_disk->loadStatic(v68, &data->_cnv);
_vm->_graphics->flatBlitCnv(&data->_cnv, 140, (SCREEN_HEIGHT - data->_cnv._height)/2, Graphics::kBitFront, data->_cnv._data1); _vm->_graphics->flatBlitCnv(&data->_cnv, 140, (SCREEN_HEIGHT - data->_cnv._height)/2, Graphics::kBitFront, data->_cnv._data1);
_vm->_graphics->freeStaticCnv(&data->_cnv); _vm->_graphics->freeStaticCnv(&data->_cnv);
StaticCnv cnv; StaticCnv cnv;
loadHead(_vm->_characterName, &cnv); _vm->_disk->loadHead(_vm->_characterName, &cnv);
int16 v6A = 0, v6C = 0; int16 v6A = 0, v6C = 0;