aboutsummaryrefslogtreecommitdiff
path: root/engines/agi/logic.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/logic.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/logic.cpp')
-rw-r--r--engines/agi/logic.cpp46
1 files changed, 23 insertions, 23 deletions
diff --git a/engines/agi/logic.cpp b/engines/agi/logic.cpp
index 7429b117c8..1aeb7cc3de 100644
--- a/engines/agi/logic.cpp
+++ b/engines/agi/logic.cpp
@@ -30,15 +30,16 @@ namespace Agi {
* into a message list.
* @param n The number of the logic resource to decode.
*/
-int AgiEngine::decodeLogic(int n) {
+int AgiEngine::decodeLogic(int16 logicNr) {
int ec = errOK;
int mstart, mend, mc;
uint8 *m0;
+ AgiLogic *curLogic = &_game.logics[logicNr];
// decrypt messages at end of logic + build message list
// report ("decoding logic #%d\n", n);
- m0 = _game.logics[n].data;
+ m0 = curLogic->data;
mstart = READ_LE_UINT16(m0) + 2;
mc = *(m0 + mstart);
@@ -48,38 +49,38 @@ int AgiEngine::decodeLogic(int n) {
// if the logic was not compressed, decrypt the text messages
// only if there are more than 0 messages
- if ((~_game.dirLogic[n].flags & RES_COMPRESSED) && mc > 0)
+ if ((~_game.dirLogic[logicNr].flags & RES_COMPRESSED) && mc > 0)
decrypt(m0 + mstart, mend - mstart); // decrypt messages
// build message list
- m0 = _game.logics[n].data;
+ m0 = curLogic->data;
mstart = READ_LE_UINT16(m0) + 2; // +2 covers pointer
- _game.logics[n].numTexts = *(m0 + mstart);
+ _game.logics[logicNr].numTexts = *(m0 + mstart);
// resetp logic pointers
- _game.logics[n].sIP = 2;
- _game.logics[n].cIP = 2;
- _game.logics[n].size = READ_LE_UINT16(m0) + 2; // logic end pointer
+ curLogic->sIP = 2;
+ curLogic->cIP = 2;
+ curLogic->size = READ_LE_UINT16(m0) + 2; // logic end pointer
// allocate list of pointers to point into our data
- _game.logics[n].texts = (const char **)calloc(1 + _game.logics[n].numTexts, sizeof(char *));
+ curLogic->texts = (const char **)calloc(1 + curLogic->numTexts, sizeof(char *));
// cover header info
m0 += mstart + 3;
- if (_game.logics[n].texts != NULL) {
+ if (curLogic->texts != NULL) {
// move list of strings into list to make real pointers
- for (mc = 0; mc < _game.logics[n].numTexts; mc++) {
+ for (mc = 0; mc < curLogic->numTexts; mc++) {
mend = READ_LE_UINT16(m0 + mc * 2);
- _game.logics[n].texts[mc] = mend ? (const char *)m0 + mend - 2 : (const char *)"";
+ _game.logics[logicNr].texts[mc] = mend ? (const char *)m0 + mend - 2 : (const char *)"";
}
// set loaded flag now its all completly loaded
- _game.dirLogic[n].flags |= RES_LOADED;
+ _game.dirLogic[logicNr].flags |= RES_LOADED;
} else {
// unload data
// Note that not every logic has text
- free(_game.logics[n].data);
+ free(curLogic->data);
ec = errNotEnoughMemory;
}
@@ -92,18 +93,17 @@ int AgiEngine::decodeLogic(int n) {
* memory chunks allocated for this resource.
* @param n The number of the logic resource to unload
*/
-void AgiEngine::unloadLogic(int n) {
- if (_game.dirLogic[n].flags & RES_LOADED) {
- free(_game.logics[n].data);
- if (_game.logics[n].numTexts)
- free(_game.logics[n].texts);
- _game.logics[n].numTexts = 0;
- _game.dirLogic[n].flags &= ~RES_LOADED;
+void AgiEngine::unloadLogic(int16 logicNr) {
+ if (_game.dirLogic[logicNr].flags & RES_LOADED) {
+ free(_game.logics[logicNr].data);
+ free(_game.logics[logicNr].texts);
+ _game.logics[logicNr].numTexts = 0;
+ _game.dirLogic[logicNr].flags &= ~RES_LOADED;
}
// if cached, we end up here
- _game.logics[n].sIP = 2;
- _game.logics[n].cIP = 2;
+ _game.logics[logicNr].sIP = 2;
+ _game.logics[logicNr].cIP = 2;
}
} // End of namespace Agi