Fixed some more Sam and Max bugs. Is now playable to BumpusVille.
Added two new debug commands, one to read and set variables, the other to set a 'watch' on variables. svn-id: r3662
This commit is contained in:
parent
474c9e333b
commit
17270d2ccd
6 changed files with 44 additions and 8 deletions
|
@ -465,7 +465,7 @@ AdjustBoxResult Scumm::adjustXYToBeInBox(Actor *a, int x, int y, int pathfrom) {
|
||||||
AdjustBoxResult abr,tmp;
|
AdjustBoxResult abr,tmp;
|
||||||
uint threshold;
|
uint threshold;
|
||||||
uint best;
|
uint best;
|
||||||
int box;
|
int box, iterations; /* Use inerations for those odd times we get stuck in the loop */
|
||||||
byte flags, b;
|
byte flags, b;
|
||||||
|
|
||||||
abr.x = x;
|
abr.x = x;
|
||||||
|
@ -479,6 +479,8 @@ AdjustBoxResult Scumm::adjustXYToBeInBox(Actor *a, int x, int y, int pathfrom) {
|
||||||
return abr;
|
return abr;
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
|
iterations++;
|
||||||
|
if (iterations > 1000) return abr; /* Safety net */
|
||||||
box = getNumBoxes() - 1;
|
box = getNumBoxes() - 1;
|
||||||
best = (uint)0xFFFF;
|
best = (uint)0xFFFF;
|
||||||
b = 0;
|
b = 0;
|
||||||
|
|
33
debug.cpp
33
debug.cpp
|
@ -40,7 +40,9 @@ enum {
|
||||||
CMD_ACTOR,
|
CMD_ACTOR,
|
||||||
CMD_SCRIPTS,
|
CMD_SCRIPTS,
|
||||||
CMD_LOAD_ROOM,
|
CMD_LOAD_ROOM,
|
||||||
CMD_DUMPBOX,
|
CMD_DUMPBOX,
|
||||||
|
CMD_VAR,
|
||||||
|
CMD_WATCH,
|
||||||
CMD_EXIT
|
CMD_EXIT
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -117,6 +119,31 @@ bool ScummDebugger::do_command() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
case CMD_VAR:
|
||||||
|
if (!_parameters[0]) {
|
||||||
|
printf("Enter a variable\n");
|
||||||
|
} else {
|
||||||
|
char *tok = strtok(_parameters, " ");
|
||||||
|
int var = atoi(tok);
|
||||||
|
tok = strtok(NULL, "");
|
||||||
|
if (tok)
|
||||||
|
_s->writeVar(var, atoi(tok));
|
||||||
|
|
||||||
|
printf("Var[%d] = %d\n", var, _s->readVar(var));
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
case CMD_WATCH:
|
||||||
|
if (!_parameters[0]) {
|
||||||
|
printf("Clearing all watches..\n");
|
||||||
|
_s->_varwatch = -1;
|
||||||
|
} else {
|
||||||
|
_s->_varwatch = atoi(_parameters);
|
||||||
|
if (_s->_varwatch == 0)
|
||||||
|
printf("Watching all variables\n");
|
||||||
|
else
|
||||||
|
printf("Watching vars[%d]\n", _s->_varwatch);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
case CMD_EXIT:
|
case CMD_EXIT:
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
||||||
|
@ -161,7 +188,9 @@ static const DebuggerCommands debugger_commands[] = {
|
||||||
{ "a", 1, CMD_ACTOR },
|
{ "a", 1, CMD_ACTOR },
|
||||||
{ "s", 1, CMD_SCRIPTS },
|
{ "s", 1, CMD_SCRIPTS },
|
||||||
{ "r", 1, CMD_LOAD_ROOM },
|
{ "r", 1, CMD_LOAD_ROOM },
|
||||||
{ "b", 1, CMD_DUMPBOX},
|
{ "b", 1, CMD_DUMPBOX},
|
||||||
|
{ "v", 1, CMD_VAR},
|
||||||
|
{ "w", 1, CMD_WATCH},
|
||||||
{ "e", 1, CMD_EXIT },
|
{ "e", 1, CMD_EXIT },
|
||||||
{ 0, 0, 0 },
|
{ 0, 0, 0 },
|
||||||
};
|
};
|
||||||
|
|
|
@ -333,6 +333,9 @@ void Scumm::writeVar(uint var, int value) {
|
||||||
if (!(var&0xF000)) {
|
if (!(var&0xF000)) {
|
||||||
checkRange(_numVariables-1, 0, var, "Variable %d out of range(w)");
|
checkRange(_numVariables-1, 0, var, "Variable %d out of range(w)");
|
||||||
_vars[var] = value;
|
_vars[var] = value;
|
||||||
|
|
||||||
|
if ((_varwatch == var) || (_varwatch == 0))
|
||||||
|
printf("vars[%d] = %d (via script %d)\n", var, value, &vm.slot[_currentScript].number);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -729,12 +732,12 @@ int Scumm::getVerbEntrypoint(int obj, int entry) {
|
||||||
|
|
||||||
|
|
||||||
void Scumm::push(int a) {
|
void Scumm::push(int a) {
|
||||||
assert(_scummStackPos >=0 && _scummStackPos < ARRAYSIZE(_scummStack)-1);
|
assert(_scummStackPos >=0 && _scummStackPos <= ARRAYSIZE(_scummStack)-1);
|
||||||
_scummStack[_scummStackPos++] = a;
|
_scummStack[_scummStackPos++] = a;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Scumm::pop() {
|
int Scumm::pop() {
|
||||||
assert(_scummStackPos >0 && _scummStackPos < ARRAYSIZE(_scummStack));
|
assert(_scummStackPos >0 && _scummStackPos <= ARRAYSIZE(_scummStack));
|
||||||
return _scummStack[--_scummStackPos];
|
return _scummStack[--_scummStackPos];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -262,7 +262,7 @@ void Scumm::setupOpcodes2() {
|
||||||
&Scumm::o6_talkEgo,
|
&Scumm::o6_talkEgo,
|
||||||
/* BC */
|
/* BC */
|
||||||
&Scumm::o6_dim,
|
&Scumm::o6_dim,
|
||||||
&Scumm::o6_invalid,
|
&Scumm::o5_dummy,
|
||||||
&Scumm::o6_runVerbCodeQuick,
|
&Scumm::o6_runVerbCodeQuick,
|
||||||
&Scumm::o6_runScriptQuick,
|
&Scumm::o6_runScriptQuick,
|
||||||
/* C0 */
|
/* C0 */
|
||||||
|
@ -2365,7 +2365,7 @@ void Scumm::o6_dim() {
|
||||||
nukeArray(fetchScriptWord());
|
nukeArray(fetchScriptWord());
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
error("o6_dim: default case");
|
error("o6_dim : default case");
|
||||||
}
|
}
|
||||||
|
|
||||||
defineArray(fetchScriptWord(), data, 0, pop());
|
defineArray(fetchScriptWord(), data, 0, pop());
|
||||||
|
@ -2634,7 +2634,7 @@ void Scumm::o6_miscOps() {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 122:
|
case 122:
|
||||||
error("stub o6_miscOps_122(%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)",
|
warning("stub o6_miscOps_122(%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)",
|
||||||
args[1],args[2],args[3],args[4],
|
args[1],args[2],args[3],args[4],
|
||||||
args[5],args[6],args[7],args[8],
|
args[5],args[6],args[7],args[8],
|
||||||
args[9],args[10],args[11],args[12]);
|
args[9],args[10],args[11],args[12]);
|
||||||
|
|
1
scumm.h
1
scumm.h
|
@ -859,6 +859,7 @@ struct Scumm {
|
||||||
ObjectData *_objs;
|
ObjectData *_objs;
|
||||||
uint16 *_newNames;
|
uint16 *_newNames;
|
||||||
int16 *_vars;
|
int16 *_vars;
|
||||||
|
int16 _varwatch;
|
||||||
byte *_bitVars;
|
byte *_bitVars;
|
||||||
|
|
||||||
const OpcodeProc *_opcodes;
|
const OpcodeProc *_opcodes;
|
||||||
|
|
|
@ -119,6 +119,7 @@ void Scumm::scummInit() {
|
||||||
charset._bufPos = 0;
|
charset._bufPos = 0;
|
||||||
_haveMsg = 0;
|
_haveMsg = 0;
|
||||||
|
|
||||||
|
_varwatch = -1;
|
||||||
_screenStartStrip = 0;
|
_screenStartStrip = 0;
|
||||||
|
|
||||||
_vars[VAR_TALK_ACTOR] = 0;
|
_vars[VAR_TALK_ACTOR] = 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue