mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-15 06:08:35 +00:00
AGI: Rename _game.lognum to _game.curLogicNr
Also a bit of cleanup
This commit is contained in:
parent
264222ec29
commit
839ac0a6a4
@ -439,7 +439,7 @@ struct AgiGame {
|
||||
|
||||
uint16 specialMenuTriggerKey; /**< key to trigger menu for platforms except PC */
|
||||
|
||||
int lognum; /**< current logic number */
|
||||
int16 curLogicNr; /**< current logic number */
|
||||
Common::Array<ScriptPos> execStack;
|
||||
|
||||
// internal flags
|
||||
@ -866,7 +866,7 @@ private:
|
||||
public:
|
||||
int decodeLogic(int16 logicNr);
|
||||
void unloadLogic(int16 logicNr);
|
||||
int runLogic(int);
|
||||
int runLogic(int16 logicNr);
|
||||
void debugConsole(int, int, const char *);
|
||||
int testIfCode(int);
|
||||
void executeAgiCommand(uint8, uint8 *);
|
||||
|
@ -391,7 +391,7 @@ bool Console::Cmd_Room(int argc, const char **argv) {
|
||||
}
|
||||
|
||||
bool Console::Cmd_BT(int argc, const char **argv) {
|
||||
debugPrintf("Current script: %d\nStack depth: %d\n", _vm->_game.lognum, _vm->_game.execStack.size());
|
||||
debugPrintf("Current script: %d\nStack depth: %d\n", _vm->_game.curLogicNr, _vm->_game.execStack.size());
|
||||
|
||||
uint8 *code = NULL;
|
||||
uint8 op = 0;
|
||||
|
@ -1123,12 +1123,12 @@ void cmdCall(AgiGame *state, uint8 *parameter) {
|
||||
// CM: we don't save sIP because set.scan.start can be
|
||||
// used in a called script (fixes xmas demo)
|
||||
oldCIP = state->_curLogic->cIP;
|
||||
oldLognum = state->lognum;
|
||||
oldLognum = state->curLogicNr;
|
||||
|
||||
state->_vm->runLogic(logicNr);
|
||||
|
||||
state->lognum = oldLognum;
|
||||
state->_curLogic = &state->logics[state->lognum];
|
||||
state->curLogicNr = oldLognum;
|
||||
state->_curLogic = &state->logics[state->curLogicNr];
|
||||
state->_curLogic->cIP = oldCIP;
|
||||
}
|
||||
|
||||
@ -2355,7 +2355,7 @@ void cmdUnknown(AgiGame *state, uint8 *parameter) {
|
||||
* Execute a logic script
|
||||
* @param n Number of the logic resource to execute
|
||||
*/
|
||||
int AgiEngine::runLogic(int n) {
|
||||
int AgiEngine::runLogic(int16 logicNr) {
|
||||
AgiGame *state = &_game;
|
||||
uint8 op = 0;
|
||||
uint8 p[CMD_BSIZE] = { 0 };
|
||||
@ -2367,24 +2367,24 @@ int AgiEngine::runLogic(int n) {
|
||||
state->max_logics = 0;
|
||||
|
||||
debugC(2, kDebugLevelScripts, "=================");
|
||||
debugC(2, kDebugLevelScripts, "runLogic(%d)", n);
|
||||
debugC(2, kDebugLevelScripts, "runLogic(%d)", logicNr);
|
||||
|
||||
sp.script = n;
|
||||
sp.script = logicNr;
|
||||
sp.curIP = 0;
|
||||
_game.execStack.push_back(sp);
|
||||
|
||||
// If logic not loaded, load it
|
||||
if (~_game.dirLogic[n].flags & RES_LOADED) {
|
||||
debugC(4, kDebugLevelScripts, "logic %d not loaded!", n);
|
||||
agiLoadResource(RESOURCETYPE_LOGIC, n);
|
||||
if (~_game.dirLogic[logicNr].flags & RES_LOADED) {
|
||||
debugC(4, kDebugLevelScripts, "logic %d not loaded!", logicNr);
|
||||
agiLoadResource(RESOURCETYPE_LOGIC, logicNr);
|
||||
}
|
||||
|
||||
_game.lognum = n;
|
||||
_game._curLogic = &_game.logics[_game.lognum];
|
||||
_game.curLogicNr = logicNr;
|
||||
_game._curLogic = &_game.logics[_game.curLogicNr];
|
||||
|
||||
_game._curLogic->cIP = _game._curLogic->sIP;
|
||||
|
||||
while (state->_curLogic->cIP < _game.logics[n].size && !(shouldQuit() || _restartGame)) {
|
||||
while (state->_curLogic->cIP < _game.logics[logicNr].size && !(shouldQuit() || _restartGame)) {
|
||||
// TODO: old code, needs to be adjusted
|
||||
#if 0
|
||||
if (_debug.enabled) {
|
||||
@ -2413,14 +2413,14 @@ int AgiEngine::runLogic(int n) {
|
||||
|
||||
switch (op = *(state->_curLogic->data + state->_curLogic->cIP++)) {
|
||||
case 0xff: // if (open/close)
|
||||
testIfCode(n);
|
||||
testIfCode(logicNr);
|
||||
break;
|
||||
case 0xfe: // goto
|
||||
// +2 covers goto size
|
||||
state->_curLogic->cIP += 2 + ((int16)READ_LE_UINT16(state->_curLogic->data + state->_curLogic->cIP));
|
||||
break;
|
||||
case 0x00: // return
|
||||
debugC(2, kDebugLevelScripts, "%sreturn() // Logic %d", st, n);
|
||||
debugC(2, kDebugLevelScripts, "%sreturn() // Logic %d", st, logicNr);
|
||||
debugC(2, kDebugLevelScripts, "=================");
|
||||
|
||||
// if (getVersion() < 0x2000) {
|
||||
|
@ -148,7 +148,7 @@ int AgiEngine::saveGame(const Common::String &fileName, const Common::String &de
|
||||
out->writeSint16BE((int16)_text->getWindowRowMin());
|
||||
|
||||
out->writeSint16BE((int16)_game.inputMode);
|
||||
out->writeSint16BE((int16)_game.lognum);
|
||||
out->writeSint16BE((int16)_game.curLogicNr);
|
||||
|
||||
out->writeSint16BE((int16)_game.playerControl);
|
||||
out->writeSint16BE((int16)shouldQuit());
|
||||
@ -473,7 +473,7 @@ int AgiEngine::loadGame(const Common::String &fileName, bool checkId) {
|
||||
_game.inputMode = INPUTMODE_NORMAL;
|
||||
}
|
||||
|
||||
_game.lognum = in->readSint16BE();
|
||||
_game.curLogicNr = in->readSint16BE();
|
||||
|
||||
_game.playerControl = in->readSint16BE();
|
||||
if (in->readSint16BE())
|
||||
|
@ -976,7 +976,7 @@ char *TextMgr::stringPrintf(const char *originalText) {
|
||||
Common::String resultString;
|
||||
char z[16];
|
||||
|
||||
debugC(3, kDebugLevelText, "logic %d, '%s'", _vm->_game.lognum, originalText);
|
||||
debugC(3, kDebugLevelText, "logic %d, '%s'", _vm->_game.curLogicNr, originalText);
|
||||
|
||||
while (*originalText) {
|
||||
switch (*originalText) {
|
||||
@ -1026,8 +1026,8 @@ char *TextMgr::stringPrintf(const char *originalText) {
|
||||
break;
|
||||
case 'm':
|
||||
i = strtoul(originalText, NULL, 10) - 1;
|
||||
if (_vm->_game.logics[_vm->_game.lognum].numTexts > i)
|
||||
safeStrcat(resultString, stringPrintf(_vm->_game.logics[_vm->_game.lognum].texts[i]));
|
||||
if (_vm->_game.logics[_vm->_game.curLogicNr].numTexts > i)
|
||||
safeStrcat(resultString, stringPrintf(_vm->_game.logics[_vm->_game.curLogicNr].texts[i]));
|
||||
break;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user