aboutsummaryrefslogtreecommitdiff
path: root/engines/agi/loader_v3.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/agi/loader_v3.cpp')
-rw-r--r--engines/agi/loader_v3.cpp93
1 files changed, 49 insertions, 44 deletions
diff --git a/engines/agi/loader_v3.cpp b/engines/agi/loader_v3.cpp
index 39759b4649..d7abbac0bd 100644
--- a/engines/agi/loader_v3.cpp
+++ b/engines/agi/loader_v3.cpp
@@ -22,6 +22,7 @@
#include "agi/agi.h"
#include "agi/lzw.h"
+#include "agi/words.h"
#include "common/config-manager.h"
#include "common/fs.h"
@@ -76,7 +77,7 @@ int AgiLoader_v3::loadDir(struct AgiDir *agid, Common::File *fp,
fp->read(mem, len);
// set all directory resources to gone
- for (i = 0; i < MAX_DIRS; i++) {
+ for (i = 0; i < MAX_DIRECTORY_ENTRIES; i++) {
agid[i].volume = 0xff;
agid[i].offset = _EMPTY;
}
@@ -171,19 +172,19 @@ int AgiLoader_v3::deinit() {
return ec;
}
-int AgiLoader_v3::unloadResource(int t, int n) {
- switch (t) {
- case rLOGIC:
- _vm->unloadLogic(n);
+int AgiLoader_v3::unloadResource(int16 resourceType, int16 resourceNr) {
+ switch (resourceType) {
+ case RESOURCETYPE_LOGIC:
+ _vm->unloadLogic(resourceNr);
break;
- case rPICTURE:
- _vm->_picture->unloadPicture(n);
+ case RESOURCETYPE_PICTURE:
+ _vm->_picture->unloadPicture(resourceNr);
break;
- case rVIEW:
- _vm->unloadView(n);
+ case RESOURCETYPE_VIEW:
+ _vm->unloadView(resourceNr);
break;
- case rSOUND:
- _vm->_sound->unloadSound(n);
+ case RESOURCETYPE_SOUND:
+ _vm->_sound->unloadSound(resourceNr);
break;
}
@@ -191,7 +192,7 @@ int AgiLoader_v3::unloadResource(int t, int n) {
}
/**
- * This function does noting but load a raw resource into memory.
+ * This function loads a raw resource into memory.
* If further decoding is required, it must be done by another
* routine.
*
@@ -225,7 +226,11 @@ uint8 *AgiLoader_v3::loadVolRes(AgiDir *agid) {
fp.read(compBuffer, agid->clen);
if (x[2] & 0x80) { // compressed pic
- data = _vm->_picture->convertV3Pic(compBuffer, agid->clen);
+ // effectively uncompressed, but having only 4-bit parameters for F0 / F2 commands
+ // Manhunter 2 uses such pictures
+ data = compBuffer;
+ agid->flags |= RES_PICTURE_V3_NIBBLE_PARM;
+ //data = _vm->_picture->convertV3Pic(compBuffer, agid->clen);
// compBuffer has been freed inside convertV3Pic()
} else if (agid->len == agid->clen) {
// do not decompress
@@ -252,31 +257,31 @@ uint8 *AgiLoader_v3::loadVolRes(AgiDir *agid) {
* Loads a resource into memory, a raw resource is loaded in
* with above routine, then further decoded here.
*/
-int AgiLoader_v3::loadResource(int t, int n) {
+int AgiLoader_v3::loadResource(int16 resourceType, int16 resourceNr) {
int ec = errOK;
uint8 *data = NULL;
- if (n >= MAX_DIRS)
+ if (resourceNr >= MAX_DIRECTORY_ENTRIES)
return errBadResource;
- switch (t) {
- case rLOGIC:
+ switch (resourceType) {
+ case RESOURCETYPE_LOGIC:
// load resource into memory, decrypt messages at the end
// and build the message list (if logic is in memory)
- if (~_vm->_game.dirLogic[n].flags & RES_LOADED) {
+ if (~_vm->_game.dirLogic[resourceNr].flags & RES_LOADED) {
// if logic is already in memory, unload it
- unloadResource(rLOGIC, n);
+ unloadResource(RESOURCETYPE_LOGIC, resourceNr);
// load raw resource into data
- data = loadVolRes(&_vm->_game.dirLogic[n]);
- _vm->_game.logics[n].data = data;
+ data = loadVolRes(&_vm->_game.dirLogic[resourceNr]);
+ _vm->_game.logics[resourceNr].data = data;
// uncompressed logic files need to be decrypted
if (data != NULL) {
// resloaded flag gets set by decode logic
// needed to build string table
- ec = _vm->decodeLogic(n);
- _vm->_game.logics[n].sIP = 2;
+ ec = _vm->decodeLogic(resourceNr);
+ _vm->_game.logics[resourceNr].sIP = 2;
} else {
ec = errBadResource;
}
@@ -284,56 +289,56 @@ int AgiLoader_v3::loadResource(int t, int n) {
// logics[n].sIP=2; // saved IP = 2
// logics[n].cIP=2; // current IP = 2
- _vm->_game.logics[n].cIP = _vm->_game.logics[n].sIP;
+ _vm->_game.logics[resourceNr].cIP = _vm->_game.logics[resourceNr].sIP;
}
// if logic was cached, we get here
// reset code pointers incase it was cached
- _vm->_game.logics[n].cIP = _vm->_game.logics[n].sIP;
+ _vm->_game.logics[resourceNr].cIP = _vm->_game.logics[resourceNr].sIP;
break;
- case rPICTURE:
+ case RESOURCETYPE_PICTURE:
// if picture is currently NOT loaded *OR* cacheing is off,
// unload the resource (caching==off) and reload it
- if (~_vm->_game.dirPic[n].flags & RES_LOADED) {
- unloadResource(rPICTURE, n);
- data = loadVolRes(&_vm->_game.dirPic[n]);
+ if (~_vm->_game.dirPic[resourceNr].flags & RES_LOADED) {
+ unloadResource(RESOURCETYPE_PICTURE, resourceNr);
+ data = loadVolRes(&_vm->_game.dirPic[resourceNr]);
if (data != NULL) {
- _vm->_game.pictures[n].rdata = data;
- _vm->_game.dirPic[n].flags |= RES_LOADED;
+ _vm->_game.pictures[resourceNr].rdata = data;
+ _vm->_game.dirPic[resourceNr].flags |= RES_LOADED;
} else {
ec = errBadResource;
}
}
break;
- case rSOUND:
- if (_vm->_game.dirSound[n].flags & RES_LOADED)
+ case RESOURCETYPE_SOUND:
+ if (_vm->_game.dirSound[resourceNr].flags & RES_LOADED)
break;
- data = loadVolRes(&_vm->_game.dirSound[n]);
+ data = loadVolRes(&_vm->_game.dirSound[resourceNr]);
if (data != NULL) {
// Freeing of the raw resource from memory is delegated to the createFromRawResource-function
- _vm->_game.sounds[n] = AgiSound::createFromRawResource(data, _vm->_game.dirSound[n].len, n, _vm->_soundemu);
- _vm->_game.dirSound[n].flags |= RES_LOADED;
+ _vm->_game.sounds[resourceNr] = AgiSound::createFromRawResource(data, _vm->_game.dirSound[resourceNr].len, resourceNr, _vm->_soundemu);
+ _vm->_game.dirSound[resourceNr].flags |= RES_LOADED;
} else {
ec = errBadResource;
}
break;
- case rVIEW:
+ case RESOURCETYPE_VIEW:
// Load a VIEW resource into memory...
// Since VIEWS alter the view table ALL the time can we
// cache the view? or must we reload it all the time?
//
// load a raw view from a VOL file into data
- if (_vm->_game.dirView[n].flags & RES_LOADED)
+ if (_vm->_game.dirView[resourceNr].flags & RES_LOADED)
break;
- unloadResource(rVIEW, n);
- data = loadVolRes(&_vm->_game.dirView[n]);
+ unloadResource(RESOURCETYPE_VIEW, resourceNr);
+ data = loadVolRes(&_vm->_game.dirView[resourceNr]);
if (data != NULL) {
- _vm->_game.views[n].rdata = data;
- _vm->_game.dirView[n].flags |= RES_LOADED;
- ec = _vm->decodeView(n);
+ _vm->_game.dirView[resourceNr].flags |= RES_LOADED;
+ ec = _vm->decodeView(data, _vm->_game.dirView[resourceNr].len, resourceNr);
+ free(data);
} else {
ec = errBadResource;
}
@@ -351,7 +356,7 @@ int AgiLoader_v3::loadObjects(const char *fname) {
}
int AgiLoader_v3::loadWords(const char *fname) {
- return _vm->loadWords(fname);
+ return _vm->_words->loadDictionary(fname);
}
} // End of namespace Agi