more v2 fixes; cleanup
svn-id: r7301
This commit is contained in:
parent
3b77249ab0
commit
488d5fe351
4 changed files with 47 additions and 43 deletions
|
@ -197,6 +197,8 @@ protected:
|
||||||
|
|
||||||
virtual void decodeParseString();
|
virtual void decodeParseString();
|
||||||
|
|
||||||
|
virtual int readVar(uint var);
|
||||||
|
|
||||||
virtual void ifStateCommon(byte type);
|
virtual void ifStateCommon(byte type);
|
||||||
virtual void ifNotStateCommon(byte type);
|
virtual void ifNotStateCommon(byte type);
|
||||||
virtual void setStateCommon(byte type);
|
virtual void setStateCommon(byte type);
|
||||||
|
|
|
@ -371,12 +371,8 @@ int Scumm::readVar(uint var) {
|
||||||
|
|
||||||
checkRange(_numVariables - 1, 0, var, "Variable %d out of range(r)");
|
checkRange(_numVariables - 1, 0, var, "Variable %d out of range(r)");
|
||||||
|
|
||||||
if ((_features & GF_AFTER_V2) && (var >= 14) && (var <= 16)) {
|
|
||||||
return _vars[_vars[var]];
|
|
||||||
} else {
|
|
||||||
return _vars[var];
|
return _vars[var];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (var & 0x2000 && !(_features & GF_NEW_OPCODES)) {
|
if (var & 0x2000 && !(_features & GF_NEW_OPCODES)) {
|
||||||
a = fetchScriptWord();
|
a = fetchScriptWord();
|
||||||
|
@ -387,9 +383,6 @@ int Scumm::readVar(uint var) {
|
||||||
var &= ~0x2000;
|
var &= ~0x2000;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(var & 0xF000))
|
|
||||||
return _vars[var];
|
|
||||||
|
|
||||||
if (var & 0x8000) {
|
if (var & 0x8000) {
|
||||||
if ((_gameId == GID_ZAK256) || (_features & GF_OLD_BUNDLE)) {
|
if ((_gameId == GID_ZAK256) || (_features & GF_OLD_BUNDLE)) {
|
||||||
// Emulate a wierd hack in Zak256 to read individual
|
// Emulate a wierd hack in Zak256 to read individual
|
||||||
|
|
|
@ -366,6 +366,42 @@ const char *Scumm_v2::getOpcodeDesc(int i) {
|
||||||
return _opcodesV2[i].desc;
|
return _opcodesV2[i].desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Scumm_v2::decodeParseString() {
|
||||||
|
byte buffer[256]; // FIXME
|
||||||
|
byte *ptr = buffer;
|
||||||
|
byte c;
|
||||||
|
while ((c = fetchScriptByte())) {
|
||||||
|
if (c & 0x80) {
|
||||||
|
*ptr++ = c & 0x7f;
|
||||||
|
*ptr++ = ' ';
|
||||||
|
} else if (c < 8) {
|
||||||
|
// Special codes as seen in CHARSET_1 etc. My guess is that they
|
||||||
|
// have a similar function as the corresponding embedded stuff in modern
|
||||||
|
// games. Hence for now we convert them to the modern format.
|
||||||
|
// This might allow us to reuse the existing code.
|
||||||
|
*ptr++ = 0xFF;
|
||||||
|
*ptr++ = c;
|
||||||
|
if (c > 3) {
|
||||||
|
*ptr++ = 0;
|
||||||
|
*ptr++ = fetchScriptByte();
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
*ptr++ = c;
|
||||||
|
}
|
||||||
|
*ptr = 0;
|
||||||
|
|
||||||
|
printf("TODO: Scumm_v2::decodeParseString(\"%s\")\n", buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
int Scumm_v2::readVar(uint var) {
|
||||||
|
debug(6, "readvar=%d", var);
|
||||||
|
if (var >= 14 && var <= 16)
|
||||||
|
var = _vars[var];
|
||||||
|
|
||||||
|
checkRange(_numVariables - 1, 0, var, "Variable %d out of range(r)");
|
||||||
|
return _vars[var];
|
||||||
|
}
|
||||||
|
|
||||||
void Scumm_v2::setStateCommon(byte type) {
|
void Scumm_v2::setStateCommon(byte type) {
|
||||||
int obj = getVarOrDirectWord(0x80);
|
int obj = getVarOrDirectWord(0x80);
|
||||||
putState(obj, getState(obj) | type);
|
putState(obj, getState(obj) | type);
|
||||||
|
@ -457,15 +493,15 @@ void Scumm_v2::o2_getObjY() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scumm_v2::o2_setBitVar() {
|
void Scumm_v2::o2_setBitVar() {
|
||||||
byte hi = fetchScriptByte();
|
|
||||||
byte lo = fetchScriptByte();
|
byte lo = fetchScriptByte();
|
||||||
|
byte hi = fetchScriptByte();
|
||||||
byte a = getVarOrDirectByte(0x80);
|
byte a = getVarOrDirectByte(0x80);
|
||||||
|
|
||||||
int bit_var = (hi << 8) + lo + a;
|
int bit_var = (hi << 8) + lo + a;
|
||||||
int bit_offset = bit_var & 0x0f;
|
int bit_offset = bit_var & 0x0f;
|
||||||
bit_var >>= 4;
|
bit_var >>= 4;
|
||||||
|
|
||||||
if (getVarOrDirectByte(0x80))
|
if (getVarOrDirectByte(0x40))
|
||||||
_vars[bit_var] |= (1 << bit_offset);
|
_vars[bit_var] |= (1 << bit_offset);
|
||||||
else
|
else
|
||||||
_vars[bit_var] &= ~(1 << bit_offset);
|
_vars[bit_var] &= ~(1 << bit_offset);
|
||||||
|
@ -473,8 +509,8 @@ void Scumm_v2::o2_setBitVar() {
|
||||||
|
|
||||||
void Scumm_v2::o2_getBitVar() {
|
void Scumm_v2::o2_getBitVar() {
|
||||||
getResultPos();
|
getResultPos();
|
||||||
byte hi = fetchScriptByte();
|
|
||||||
byte lo = fetchScriptByte();
|
byte lo = fetchScriptByte();
|
||||||
|
byte hi = fetchScriptByte();
|
||||||
byte a = getVarOrDirectByte(0x80);
|
byte a = getVarOrDirectByte(0x80);
|
||||||
|
|
||||||
int bit_var = (hi << 8) + lo + a;
|
int bit_var = (hi << 8) + lo + a;
|
||||||
|
@ -561,12 +597,12 @@ void Scumm_v2::o2_actorSet() {
|
||||||
Actor *a = derefActorSafe(act, "actorSet");
|
Actor *a = derefActorSafe(act, "actorSet");
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
_opcode = fetchScriptByte();
|
||||||
if (!a) {
|
if (!a) {
|
||||||
fetchScriptByte();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (fetchScriptByte()) {
|
switch (_opcode) {
|
||||||
case 1: // Actor Sound
|
case 1: // Actor Sound
|
||||||
a->sound[0] = arg;
|
a->sound[0] = arg;
|
||||||
break;
|
break;
|
||||||
|
@ -588,6 +624,8 @@ void Scumm_v2::o2_actorSet() {
|
||||||
case 5: // Talk Color
|
case 5: // Talk Color
|
||||||
a->talkColor = arg;
|
a->talkColor = arg;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
warning("o2_actorSet: opcode %d not yet supported", _opcode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -832,33 +870,6 @@ void Scumm_v2::o2_doSentence() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scumm_v2::decodeParseString() {
|
|
||||||
byte buffer[256]; // FIXME
|
|
||||||
byte *ptr = buffer;
|
|
||||||
byte c;
|
|
||||||
while ((c = fetchScriptByte())) {
|
|
||||||
if (c & 0x80) {
|
|
||||||
*ptr++ = c & 0x7f;
|
|
||||||
*ptr++ = ' ';
|
|
||||||
} else if (c < 8) {
|
|
||||||
// Special codes as seen in CHARSET_1 etc. My guess is that they
|
|
||||||
// have a similar function as the corresponding embedded stuff in modern
|
|
||||||
// games. Hence for now we convert them to the modern format.
|
|
||||||
// This might allow us to reuse the existing code.
|
|
||||||
*ptr++ = 0xFF;
|
|
||||||
*ptr++ = c;
|
|
||||||
if (c > 3) {
|
|
||||||
*ptr++ = 0;
|
|
||||||
*ptr++ = fetchScriptByte();
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
*ptr++ = c;
|
|
||||||
}
|
|
||||||
*ptr = 0;
|
|
||||||
|
|
||||||
printf("TODO: Scumm_v2::decodeParseString(\"%s\")\n", buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Scumm_v2::o2_ifClassOfIs() {
|
void Scumm_v2::o2_ifClassOfIs() {
|
||||||
int act = getVarOrDirectWord(0x80);
|
int act = getVarOrDirectWord(0x80);
|
||||||
int clsop = getVarOrDirectByte(0x40);
|
int clsop = getVarOrDirectByte(0x40);
|
||||||
|
|
|
@ -1746,9 +1746,7 @@ Actor *Scumm::derefActor(int id) {
|
||||||
|
|
||||||
Actor *Scumm::derefActorSafe(int id, const char *errmsg) {
|
Actor *Scumm::derefActorSafe(int id, const char *errmsg) {
|
||||||
if (id < 1 || id >= NUM_ACTORS) {
|
if (id < 1 || id >= NUM_ACTORS) {
|
||||||
if (_debugLevel > 1)
|
debug(2, "Invalid actor %d in %s (script %d, opcode 0x%x) - This is potentially a BIG problem.",
|
||||||
warning
|
|
||||||
("Invalid actor %d in %s (script %d, opcode 0x%x) - This is potentially a BIG problem.",
|
|
||||||
id, errmsg, vm.slot[_curExecScript].number, _opcode);
|
id, errmsg, vm.slot[_curExecScript].number, _opcode);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue