diff options
author | Martin Kiewitz | 2016-01-29 13:13:40 +0100 |
---|---|---|
committer | Martin Kiewitz | 2016-01-29 13:22:22 +0100 |
commit | 8a595e7771aa89d06876e13d7ab6751e26da8982 (patch) | |
tree | dfc61e112c9f7e5b1d9e295fbb60edf4ae1b65f3 /engines/agi/op_test.cpp | |
parent | 1e73796bd0b17740ca4c35b9a7bd1882f9de6a37 (diff) | |
download | scummvm-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/op_test.cpp')
-rw-r--r-- | engines/agi/op_test.cpp | 74 |
1 files changed, 38 insertions, 36 deletions
diff --git a/engines/agi/op_test.cpp b/engines/agi/op_test.cpp index 9839f0ec90..afb1ddb820 100644 --- a/engines/agi/op_test.cpp +++ b/engines/agi/op_test.cpp @@ -23,6 +23,8 @@ #include "agi/agi.h" #include "agi/opcodes.h" +#include "agi/words.h" + #include "common/endian.h" namespace Agi { @@ -30,16 +32,14 @@ namespace Agi { #define ip (state->_curLogic->cIP) #define code (state->_curLogic->data) -#define getvar(a) state->_vm->getvar(a) -#define getflag(a) state->_vm->getflag(a) +#define getVar(a) state->_vm->getVar(a) -#define testEqual(v1, v2) (getvar(v1) == (v2)) -#define testLess(v1, v2) (getvar(v1) < (v2)) -#define testGreater(v1, v2) (getvar(v1) > (v2)) -#define testIsSet(flag) (getflag(flag)) +#define testEqual(v1, v2) (getVar(v1) == (v2)) +#define testLess(v1, v2) (getVar(v1) < (v2)) +#define testGreater(v1, v2) (getVar(v1) > (v2)) #define testHas(obj) (state->_vm->objectGetLocation(obj) == EGO_OWNED) #define testHasV1(obj) (state->_vm->objectGetLocation(obj) == EGO_OWNED_V1) -#define testObjInRoom(obj, v) (state->_vm->objectGetLocation(obj) == getvar(v)) +#define testObjInRoom(obj, v) (state->_vm->objectGetLocation(obj) == getVar(v)) void condEqual(AgiGame *state, uint8 *p) { if (p[0] == 11) @@ -50,7 +50,7 @@ void condEqual(AgiGame *state, uint8 *p) { void condEqualV(AgiGame *state, uint8 *p) { if (p[0] == 11 || p[1] == 11) state->_vm->_timerHack++; - state->testResult = testEqual(p[0], getvar(p[1])); + state->testResult = testEqual(p[0], getVar(p[1])); } void condLess(AgiGame *state, uint8 *p) { @@ -62,7 +62,7 @@ void condLess(AgiGame *state, uint8 *p) { void condLessV(AgiGame *state, uint8 *p) { if (p[0] == 11 || p[1] == 11) state->_vm->_timerHack++; - state->testResult = testLess(p[0], getvar(p[1])); + state->testResult = testLess(p[0], getVar(p[1])); } void condGreater(AgiGame *state, uint8 *p) { @@ -74,19 +74,19 @@ void condGreater(AgiGame *state, uint8 *p) { void condGreaterV(AgiGame *state, uint8 *p) { if (p[0] == 11 || p[1] == 11) state->_vm->_timerHack++; - state->testResult = testGreater(p[0], getvar(p[1])); + state->testResult = testGreater(p[0], getVar(p[1])); } void condIsSet(AgiGame *state, uint8 *p) { - state->testResult = testIsSet(p[0]); + state->testResult = state->_vm->getflag(p[0]); } void condIsSetV(AgiGame *state, uint8 *p) { - state->testResult = testIsSet(getvar(p[0])); + state->testResult = state->_vm->getflag(getVar(p[0])); } void condIsSetV1(AgiGame *state, uint8 *p) { - state->testResult = getvar(p[0]) > 0; + state->testResult = getVar(p[0]) > 0; } void condHas(AgiGame *state, uint8 *p) { @@ -121,47 +121,47 @@ void condSaid(AgiGame *state, uint8 *p) { void condSaid1(AgiGame *state, uint8 *p) { state->testResult = false; - if (!getflag(fEnteredCli)) + if (!state->_vm->getflag(VM_FLAG_ENTERED_CLI)) return; int id0 = READ_LE_UINT16(p); - if ((id0 == 1 || id0 == state->egoWords[0].id)) + if ((id0 == 1 || id0 == state->_vm->_words->getEgoWordId(0))) state->testResult = true; } void condSaid2(AgiGame *state, uint8 *p) { state->testResult = false; - if (!getflag(fEnteredCli)) + if (!state->_vm->getflag(VM_FLAG_ENTERED_CLI)) return; int id0 = READ_LE_UINT16(p); int id1 = READ_LE_UINT16(p + 2); - if ((id0 == 1 || id0 == state->egoWords[0].id) && - (id1 == 1 || id1 == state->egoWords[1].id)) + if ((id0 == 1 || id0 == state->_vm->_words->getEgoWordId(0)) && + (id1 == 1 || id1 == state->_vm->_words->getEgoWordId(1))) state->testResult = true; } void condSaid3(AgiGame *state, uint8 *p) { state->testResult = false; - if (!getflag(fEnteredCli)) + if (!state->_vm->getflag(VM_FLAG_ENTERED_CLI)) return; int id0 = READ_LE_UINT16(p); int id1 = READ_LE_UINT16(p + 2); int id2 = READ_LE_UINT16(p + 4); - if ((id0 == 1 || id0 == state->egoWords[0].id) && - (id1 == 1 || id1 == state->egoWords[1].id) && - (id2 == 1 || id2 == state->egoWords[2].id)) + if ((id0 == 1 || id0 == state->_vm->_words->getEgoWordId(0)) && + (id1 == 1 || id1 == state->_vm->_words->getEgoWordId(1)) && + (id2 == 1 || id2 == state->_vm->_words->getEgoWordId(2))) state->testResult = true; } void condBit(AgiGame *state, uint8 *p) { - state->testResult = (getvar(p[1]) >> p[0]) & 1; + state->testResult = (getVar(p[1]) >> p[0]) & 1; } void condCompareStrings(AgiGame *state, uint8 *p) { @@ -188,7 +188,7 @@ void condUnknown13(AgiGame *state, uint8 *p) { // This command is used at least in the Amiga version of Gold Rush! v2.05 1989-03-09 // (AGI 2.316) in logics 1, 3, 5, 6, 137 and 192 (Logic.192 revealed this command's nature). // TODO: Check this command's implementation using disassembly just to be sure. - int ec = state->viewTable[0].flags & fAdjEgoXY; + int ec = state->screenObjTable[SCREENOBJECTS_EGO_ENTRY].flags & fAdjEgoXY; debugC(7, kDebugLevelScripts, "op_test: in.motion.using.mouse = %s (Amiga-specific testcase 19)", ec ? "true" : "false"); state->testResult = ec; } @@ -221,7 +221,7 @@ uint8 AgiEngine::testCompareStrings(uint8 s1, uint8 s2) { break; default: - ms1[j++] = toupper(ms1[k]); + ms1[j++] = tolower(ms1[k]); break; } } @@ -242,7 +242,7 @@ uint8 AgiEngine::testCompareStrings(uint8 s1, uint8 s2) { break; default: - ms2[j++] = toupper(ms2[k]); + ms2[j++] = tolower(ms2[k]); break; } } @@ -258,7 +258,7 @@ uint8 AgiEngine::testKeypressed() { if (!x) { InputMode mode = _game.inputMode; - _game.inputMode = INPUT_NONE; + _game.inputMode = INPUTMODE_NONE; // Only check for events here, without updating the game cycle, // otherwise the animations in some games are drawn too quickly // like, for example, Manannan's lightnings in the intro of KQ3 @@ -275,11 +275,11 @@ uint8 AgiEngine::testKeypressed() { } uint8 AgiEngine::testController(uint8 cont) { - return (_game.controllerOccured[cont] ? 1 : 0); + return (_game.controllerOccured[cont] ? true : false); } uint8 AgiEngine::testPosn(uint8 n, uint8 x1, uint8 y1, uint8 x2, uint8 y2) { - VtEntry *v = &_game.viewTable[n]; + ScreenObjEntry *v = &_game.screenObjTable[n]; uint8 r; r = v->xPos >= x1 && v->yPos >= y1 && v->xPos <= x2 && v->yPos <= y2; @@ -290,7 +290,7 @@ uint8 AgiEngine::testPosn(uint8 n, uint8 x1, uint8 y1, uint8 x2, uint8 y2) { } uint8 AgiEngine::testObjInBox(uint8 n, uint8 x1, uint8 y1, uint8 x2, uint8 y2) { - VtEntry *v = &_game.viewTable[n]; + ScreenObjEntry *v = &_game.screenObjTable[n]; return v->xPos >= x1 && v->yPos >= y1 && v->xPos + v->xSize - 1 <= x2 && v->yPos <= y2; @@ -298,7 +298,7 @@ uint8 AgiEngine::testObjInBox(uint8 n, uint8 x1, uint8 y1, uint8 x2, uint8 y2) { // if n is in center of box uint8 AgiEngine::testObjCenter(uint8 n, uint8 x1, uint8 y1, uint8 x2, uint8 y2) { - VtEntry *v = &_game.viewTable[n]; + ScreenObjEntry *v = &_game.screenObjTable[n]; return v->xPos + v->xSize / 2 >= x1 && v->xPos + v->xSize / 2 <= x2 && v->yPos >= y1 && v->yPos <= y2; @@ -306,7 +306,7 @@ uint8 AgiEngine::testObjCenter(uint8 n, uint8 x1, uint8 y1, uint8 x2, uint8 y2) // if nect N is in right corner uint8 AgiEngine::testObjRight(uint8 n, uint8 x1, uint8 y1, uint8 x2, uint8 y2) { - VtEntry *v = &_game.viewTable[n]; + ScreenObjEntry *v = &_game.screenObjTable[n]; return v->xPos + v->xSize - 1 >= x1 && v->xPos + v->xSize - 1 <= x2 && v->yPos >= y1 && v->yPos <= y2; @@ -315,10 +315,12 @@ uint8 AgiEngine::testObjRight(uint8 n, uint8 x1, uint8 y1, uint8 x2, uint8 y2) { // When player has entered something, it is parsed elsewhere uint8 AgiEngine::testSaid(uint8 nwords, uint8 *cc) { AgiGame *state = &_game; - int c, n = _game.numEgoWords; + AgiEngine *vm = state->_vm; + Words *words = vm->_words; + int c, n = words->getEgoWordCount(); int z = 0; - if (getflag(fSaidAcceptedInput) || !getflag(fEnteredCli)) + if (vm->getflag(VM_FLAG_SAID_ACCEPTED_INPUT) || !vm->getflag(VM_FLAG_ENTERED_CLI)) return false; // FR: @@ -349,7 +351,7 @@ uint8 AgiEngine::testSaid(uint8 nwords, uint8 *cc) { case 1: // any word break; default: - if (_game.egoWords[c].id != z) + if (words->getEgoWordId(c) != z) return false; break; } @@ -364,7 +366,7 @@ uint8 AgiEngine::testSaid(uint8 nwords, uint8 *cc) { if (nwords != 0 && READ_LE_UINT16(cc) != 9999) return false; - setflag(fSaidAcceptedInput, true); + setflag(VM_FLAG_SAID_ACCEPTED_INPUT, true); return true; } |