aboutsummaryrefslogtreecommitdiff
path: root/engines/agi/loader_v2.cpp
diff options
context:
space:
mode:
authorMartin Kiewitz2016-01-29 13:13:40 +0100
committerMartin Kiewitz2016-01-29 13:22:22 +0100
commit8a595e7771aa89d06876e13d7ab6751e26da8982 (patch)
treedfc61e112c9f7e5b1d9e295fbb60edf4ae1b65f3 /engines/agi/loader_v2.cpp
parent1e73796bd0b17740ca4c35b9a7bd1882f9de6a37 (diff)
downloadscummvm-rg350-8a595e7771aa89d06876e13d7ab6751e26da8982.tar.gz
scummvm-rg350-8a595e7771aa89d06876e13d7ab6751e26da8982.tar.bz2
scummvm-rg350-8a595e7771aa89d06876e13d7ab6751e26da8982.zip
AGI: graphics rewrite + cleanup
- graphics code fully rewritten - Apple IIgs font support - Amiga Topaz support - Word parser rewritten - menu code rewritten - removed forced 2 second delay on all room changes replaced with heuristic to detect situations, where it's required - lots of naming cleanup - new console commands show_map, screenobj, vmvars and vmflags - all sorts of hacks/workarounds removed - added SCI wait mouse cursor - added Apple IIgs mouse cursor - added Atari ST mouse cursor - added Amiga/Apple IIgs transition - added Atari ST transition - user can select another render mode and use Apple IIgs palette + transition for PC versions - inventory screen rewritten - SetSimple command now properly implemented - PreAGI Mickey: Sierra logo now shown - saved games: now saving controller key mapping also saving automatic save data (SetSimple command) - fixed invalid memory access when saving games (31 bytes were saved using Common::String c_ptr() Special Thanks to: - fuzzie for helping out with the Apple IIgs font + valgrind - eriktorbjorn for helping out with valgrind - LordHoto for figuring out the code, that caused invalid memory access in the original code, when saving a game - sev for help out with reversing the Amiga transition currently missing: - mouse support for menu - mouse support for system dialogs - predictive dialog support
Diffstat (limited to 'engines/agi/loader_v2.cpp')
-rw-r--r--engines/agi/loader_v2.cpp95
1 files changed, 48 insertions, 47 deletions
diff --git a/engines/agi/loader_v2.cpp b/engines/agi/loader_v2.cpp
index 693c53c2bf..76f6900e44 100644
--- a/engines/agi/loader_v2.cpp
+++ b/engines/agi/loader_v2.cpp
@@ -23,6 +23,7 @@
#include "common/textconsole.h"
#include "agi/agi.h"
+#include "agi/words.h"
namespace Agi {
@@ -60,7 +61,7 @@ int AgiLoader_v2::loadDir(AgiDir *agid, const char *fname) {
fp.read(mem, flen);
// 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;
}
@@ -107,21 +108,21 @@ int AgiLoader_v2::deinit() {
return ec;
}
-int AgiLoader_v2::unloadResource(int t, int n) {
+int AgiLoader_v2::unloadResource(int16 resourceType, int16 resourceNr) {
debugC(3, kDebugLevelResources, "unload resource");
- switch (t) {
- case rLOGIC:
- _vm->unloadLogic(n);
+ 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;
}
@@ -129,7 +130,7 @@ int AgiLoader_v2::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. NULL is returned if unsucsessfull.
*/
@@ -173,84 +174,84 @@ uint8 *AgiLoader_v2::loadVolRes(struct AgiDir *agid) {
* Loads a resource into memory, a raw resource is loaded in
* with above routine, then further decoded here.
*/
-int AgiLoader_v2::loadResource(int t, int n) {
+int AgiLoader_v2::loadResource(int16 resourceType, int16 resourceNr) {
int ec = errOK;
uint8 *data = NULL;
- debugC(3, kDebugLevelResources, "(t = %d, n = %d)", t, n);
- if (n >= MAX_DIRS)
+ debugC(3, kDebugLevelResources, "(t = %d, n = %d)", resourceType, resourceNr);
+ if (resourceNr >= MAX_DIRECTORY_ENTRIES)
return errBadResource;
- switch (t) {
- case rLOGIC:
- if (~_vm->_game.dirLogic[n].flags & RES_LOADED) {
- debugC(3, kDebugLevelResources, "loading logic resource %d", n);
- unloadResource(rLOGIC, n);
+ switch (resourceType) {
+ case RESOURCETYPE_LOGIC:
+ if (~_vm->_game.dirLogic[resourceNr].flags & RES_LOADED) {
+ debugC(3, kDebugLevelResources, "loading logic resource %d", resourceNr);
+ unloadResource(RESOURCETYPE_LOGIC, resourceNr);
// load raw resource into data
- data = loadVolRes(&_vm->_game.dirLogic[n]);
+ data = loadVolRes(&_vm->_game.dirLogic[resourceNr]);
- _vm->_game.logics[n].data = data;
- ec = data ? _vm->decodeLogic(n) : errBadResource;
+ _vm->_game.logics[resourceNr].data = data;
+ ec = data ? _vm->decodeLogic(resourceNr) : errBadResource;
- _vm->_game.logics[n].sIP = 2;
+ _vm->_game.logics[resourceNr].sIP = 2;
}
// 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
- debugC(3, kDebugLevelResources, "loading picture resource %d", n);
- if (_vm->_game.dirPic[n].flags & RES_LOADED)
+ debugC(3, kDebugLevelResources, "loading picture resource %d", resourceNr);
+ if (_vm->_game.dirPic[resourceNr].flags & RES_LOADED)
break;
// if loaded but not cached, unload it
// if cached but not loaded, etc
- unloadResource(rPICTURE, n);
- data = loadVolRes(&_vm->_game.dirPic[n]);
+ 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:
- debugC(3, kDebugLevelResources, "loading sound resource %d", n);
- if (_vm->_game.dirSound[n].flags & RES_LOADED)
+ case RESOURCETYPE_SOUND:
+ debugC(3, kDebugLevelResources, "loading sound resource %d", resourceNr);
+ 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?
- if (_vm->_game.dirView[n].flags & RES_LOADED)
+ if (_vm->_game.dirView[resourceNr].flags & RES_LOADED)
break;
- debugC(3, kDebugLevelResources, "loading view resource %d", n);
- unloadResource(rVIEW, n);
- data = loadVolRes(&_vm->_game.dirView[n]);
+ debugC(3, kDebugLevelResources, "loading view resource %d", resourceNr);
+ unloadResource(RESOURCETYPE_VIEW, resourceNr);
+ data = loadVolRes(&_vm->_game.dirView[resourceNr]);
if (data) {
- _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;
}
@@ -268,7 +269,7 @@ int AgiLoader_v2::loadObjects(const char *fname) {
}
int AgiLoader_v2::loadWords(const char *fname) {
- return _vm->loadWords(fname);
+ return _vm->_words->loadDictionary(fname);
}
} // End of namespace Agi