aboutsummaryrefslogtreecommitdiff
path: root/engines/agos
diff options
context:
space:
mode:
Diffstat (limited to 'engines/agos')
-rw-r--r--engines/agos/agos.h29
-rw-r--r--engines/agos/draw.cpp2
-rw-r--r--engines/agos/event.cpp2
-rw-r--r--engines/agos/pn.cpp10
-rw-r--r--engines/agos/res_snd.cpp2
-rw-r--r--engines/agos/script_pn.cpp248
-rw-r--r--engines/agos/string.cpp14
-rw-r--r--engines/agos/vga.cpp3
-rw-r--r--engines/agos/vga_e2.cpp22
-rw-r--r--engines/agos/vga_pn.cpp1
10 files changed, 183 insertions, 150 deletions
diff --git a/engines/agos/agos.h b/engines/agos/agos.h
index 093f7bb039..263811b78a 100644
--- a/engines/agos/agos.h
+++ b/engines/agos/agos.h
@@ -1265,8 +1265,8 @@ protected:
#ifdef ENABLE_PN
class AGOSEngine_PN : public AGOSEngine {
- struct stackframe {
- struct stackframe *nextframe;
+ struct StackFrame {
+ StackFrame *nextframe;
int16 flag[6];
int16 param[8];
int16 classnum;
@@ -1276,7 +1276,7 @@ class AGOSEngine_PN : public AGOSEngine {
int16 linenum;
int16 process;
jmp_buf *savearea;
- stackframe() { memset(this, 0, sizeof(*this)); }
+ StackFrame() { memset(this, 0, sizeof(*this)); }
};
@@ -1284,6 +1284,7 @@ class AGOSEngine_PN : public AGOSEngine {
void demoSeq();
void introSeq();
void setupBoxes();
+ int readfromline();
public:
AGOSEngine_PN(OSystem *system);
~AGOSEngine_PN();
@@ -1297,10 +1298,10 @@ public:
int actCallD(int n);
void opn_opcode00();
- void opn_opcode01();
- void opn_opcode02();
- void opn_opcode03();
- void opn_opcode04();
+ void opn_add();
+ void opn_sub();
+ void opn_mul();
+ void opn_div();
void opn_opcode05();
void opn_opcode06();
void opn_opcode07();
@@ -1313,10 +1314,10 @@ public:
void opn_opcode14();
void opn_opcode15();
void opn_opcode16();
- void opn_opcode17();
- void opn_opcode18();
- void opn_opcode19();
- void opn_opcode20();
+ void opn_lt();
+ void opn_gt();
+ void opn_eq();
+ void opn_neq();
void opn_opcode21();
void opn_opcode22();
void opn_opcode23();
@@ -1357,14 +1358,14 @@ public:
void opn_opcode62();
void opn_opcode63();
- stackframe *_stackbase;
+ StackFrame *_stackbase;
byte *_dataBase, *_textBase;
uint32 _dataBaseSize, _textBaseSize;
HitArea _invHitAreas[45];
- char _buffer[80];
+ char _buffer[80];
char _inputline[61];
char _saveFile[20];
char _sb[80];
@@ -1390,7 +1391,7 @@ public:
uint16 _objects;
int16 _objectCountS;
- int16 _bp;
+ int16 _bp;
int16 _xofs;
int16 _havinit;
uint16 _seed;
diff --git a/engines/agos/draw.cpp b/engines/agos/draw.cpp
index d09f02c76d..45443aa335 100644
--- a/engines/agos/draw.cpp
+++ b/engines/agos/draw.cpp
@@ -503,7 +503,7 @@ void AGOSEngine::saveBackGround(VgaSprite *vsp) {
animTable->y = y;
animTable->width = READ_BE_UINT16(ptr + 6) / 16;
- if (vsp->flags & 40) {
+ if (vsp->flags & 0x40) {
animTable->width++;
}
diff --git a/engines/agos/event.cpp b/engines/agos/event.cpp
index b9c16d3d86..cbb09e1ec7 100644
--- a/engines/agos/event.cpp
+++ b/engines/agos/event.cpp
@@ -484,7 +484,7 @@ void AGOSEngine::delay(uint amount) {
_fastMode ^= 1;
} else if (event.kbd.keycode == Common::KEYCODE_d) {
_debugger->attach();
- } else if (event.kbd.keycode == Common::KEYCODE_u) {
+ } else if (event.kbd.keycode == Common::KEYCODE_s) {
dumpAllSubroutines();
} else if (event.kbd.keycode == Common::KEYCODE_i) {
dumpAllVgaImageFiles();
diff --git a/engines/agos/pn.cpp b/engines/agos/pn.cpp
index fd88d63ec3..d92efa9077 100644
--- a/engines/agos/pn.cpp
+++ b/engines/agos/pn.cpp
@@ -269,16 +269,16 @@ void AGOSEngine_PN::processor() {
_variableArray[16] = _quickshort[6];
_variableArray[17] = _quickshort[7];
_variableArray[19] = getptr(55L);
+
+ // q indicates the process to run and is 0 the first time,
+ // but 1 later on (i.e., when we are "called" from badload()).
setposition(q, 0);
doline(0);
}
void AGOSEngine_PN::setqptrs() {
- int a = 0;
-
- while (a < 11) {
- _quickptr[a] = getlong(3L * a);
- a++;
+ for (int i = 0; i < 11; ++i) {
+ _quickptr[i] = getlong(3 * i);
}
_quickptr[11] = getlong(58L);
_quickptr[12] = getlong(61L);
diff --git a/engines/agos/res_snd.cpp b/engines/agos/res_snd.cpp
index 810f953bd7..e85440d8e1 100644
--- a/engines/agos/res_snd.cpp
+++ b/engines/agos/res_snd.cpp
@@ -332,7 +332,7 @@ void AGOSEngine::playSting(uint16 soundId) {
mus_file.seek(soundId * 2, SEEK_SET);
mus_offset = mus_file.readUint16LE();
- if (mus_file.ioFailed())
+ if (mus_file.err())
error("playSting: Can't read sting %d offset", soundId);
mus_file.seek(mus_offset, SEEK_SET);
diff --git a/engines/agos/script_pn.cpp b/engines/agos/script_pn.cpp
index 62ca94e387..4f9aab2965 100644
--- a/engines/agos/script_pn.cpp
+++ b/engines/agos/script_pn.cpp
@@ -30,17 +30,21 @@
namespace AGOS {
+enum {
+ kJmpClassNum = -1
+};
+
#define OPCODE(x) _OPCODE(AGOSEngine_PN, x)
void AGOSEngine_PN::setupOpcodes() {
static const OpcodeEntryPN opcodes[] = {
/* 00 */
OPCODE(opn_opcode00),
- OPCODE(opn_opcode01),
- OPCODE(opn_opcode02),
- OPCODE(opn_opcode03),
+ OPCODE(opn_add),
+ OPCODE(opn_sub),
+ OPCODE(opn_mul),
/* 04 */
- OPCODE(opn_opcode04),
+ OPCODE(opn_div),
OPCODE(opn_opcode05),
OPCODE(opn_opcode06),
OPCODE(opn_opcode07),
@@ -56,11 +60,11 @@ void AGOSEngine_PN::setupOpcodes() {
OPCODE(opn_opcode15),
/* 16 */
OPCODE(opn_opcode16),
- OPCODE(opn_opcode17),
- OPCODE(opn_opcode18),
- OPCODE(opn_opcode19),
+ OPCODE(opn_lt),
+ OPCODE(opn_gt),
+ OPCODE(opn_eq),
/* 20 */
- OPCODE(opn_opcode20),
+ OPCODE(opn_neq),
OPCODE(opn_opcode21),
OPCODE(opn_opcode22),
OPCODE(opn_opcode23),
@@ -122,13 +126,14 @@ void AGOSEngine_PN::setupOpcodes() {
void AGOSEngine_PN::executeOpcode(int opcode) {
OpcodeProcPN op = _opcodesPN[opcode].proc;
- (this->*op) ();
+ (this->*op)();
}
-#define readfromline() (_linct-- ? (int)*_workptr++ : readoverr())
-
-int readoverr() {
- error("readfromline: Internal Error - Line Over-run");
+int AGOSEngine_PN::readfromline() {
+ if (!_linct)
+ error("readfromline: Internal Error - Line Over-run");
+ _linct--;
+ return *_workptr++;
}
// -----------------------------------------------------------------------
@@ -142,30 +147,30 @@ void AGOSEngine_PN::opn_opcode00() {
setScriptReturn(true);
}
-void AGOSEngine_PN::opn_opcode01() {
+void AGOSEngine_PN::opn_add() {
uint8 *str = _workptr;
int32 sp = varval() + varval();
_variableArray[12] = sp % 65536;
_variableArray[13] = sp / 65536;
if (sp > 65535)
- sp=65535;
+ sp = 65535;
writeval(str, (int)sp);
setScriptReturn(true);
}
-void AGOSEngine_PN::opn_opcode02() {
+void AGOSEngine_PN::opn_sub() {
uint8 *str = _workptr;
int32 sp = varval();
sp -= varval();
_variableArray[12] = sp % 65536;
_variableArray[13] = sp / 65536;
- if(sp < 0)
+ if (sp < 0)
sp = 0;
writeval(str, (int)sp);
setScriptReturn(true);
}
-void AGOSEngine_PN::opn_opcode03() {
+void AGOSEngine_PN::opn_mul() {
uint8 *str = _workptr;
int32 sp = varval() * varval();
_variableArray[12] = sp % 65536;
@@ -176,12 +181,12 @@ void AGOSEngine_PN::opn_opcode03() {
setScriptReturn(true);
}
-void AGOSEngine_PN::opn_opcode04() {
+void AGOSEngine_PN::opn_div() {
uint8 *str = _workptr;
int32 sp = varval();
int32 sp2 = varval();
if (sp2 == 0)
- error("Division by 0");
+ error("opn_div: Division by 0");
sp = sp / sp2;
_variableArray[12] = sp % 65536;
_variableArray[13] = sp / 65536;
@@ -234,7 +239,7 @@ void AGOSEngine_PN::opn_opcode12() {
char bf[8];
int a = 0;
sprintf(bf,"%d", varval());
- while(bf[a])
+ while (bf[a])
pcf(bf[a++]);
setScriptReturn(true);
}
@@ -243,7 +248,7 @@ void AGOSEngine_PN::opn_opcode13() {
char bf[8];
int a = 0;
sprintf(bf,"%d", varval());
- while(bf[a])
+ while (bf[a])
pcf(bf[a++]);
pcf((uint8)'\n');
setScriptReturn(true);
@@ -271,25 +276,25 @@ void AGOSEngine_PN::opn_opcode16() {
setScriptReturn((sp >= 0 && sp <= 4));
}
-void AGOSEngine_PN::opn_opcode17() {
+void AGOSEngine_PN::opn_lt() {
int16 v1 = varval();
int16 v2 = varval();
setScriptReturn(v1 < v2);
}
-void AGOSEngine_PN::opn_opcode18() {
+void AGOSEngine_PN::opn_gt() {
int16 v1 = varval();
int16 v2 = varval();
setScriptReturn(v1 > v2);
}
-void AGOSEngine_PN::opn_opcode19() {
+void AGOSEngine_PN::opn_eq() {
int16 v1 = varval();
int16 v2 = varval();
setScriptReturn(v1 == v2);
}
-void AGOSEngine_PN::opn_opcode20() {
+void AGOSEngine_PN::opn_neq() {
int16 v1 = varval();
int16 v2 = varval();
setScriptReturn(v1 != v2);
@@ -302,11 +307,10 @@ void AGOSEngine_PN::opn_opcode21() {
void AGOSEngine_PN::opn_opcode22() {
int pf[8];
- int a;
- a = varval();
- funcentry(pf, a);
+ int n = varval();
+ funcentry(pf, n);
funccpy(pf);
- setposition(a, 0);
+ setposition(n, 0);
setScriptReturn(true);
}
@@ -315,19 +319,27 @@ void AGOSEngine_PN::opn_opcode23() {
}
void AGOSEngine_PN::opn_opcode24() {
- popstack(-1);
+ popstack(kJmpClassNum);
+ // Jump back to the last doline, which will return 2-1=1.
+ // That value then is returned to actCallD, which once again
+ // returns it. In the end, this amounts to a setScriptReturn(true)
+ // (but possibly in a different level than the current one).
longjmp(*(_stackbase->savearea), 2);
setScriptReturn(false);
}
void AGOSEngine_PN::opn_opcode25() {
- popstack(-1);
+ popstack(kJmpClassNum);
+ // Jump back to the last doline, which will return 1-1=0.
+ // That value then is returned to actCallD, which once again
+ // returns it. In the end, this amounts to a setScriptReturn(false)
+ // (but possibly in a different level than the current one).
longjmp(*(_stackbase->savearea), 1);
setScriptReturn(false);
}
void AGOSEngine_PN::opn_opcode26() {
- while ((_stackbase->classnum != -1) && (_stackbase != NULL))
+ while ((_stackbase != NULL) && (_stackbase->classnum != kJmpClassNum))
junkstack();
dumpstack();
setScriptReturn(true);
@@ -347,6 +359,8 @@ void AGOSEngine_PN::opn_opcode28() {
void AGOSEngine_PN::opn_opcode29() {
popstack(varval());
+ // Jump back to the last doline indicated by the top stackfram.
+ // The -1 tells it to simply go on with its business.
longjmp(*(_stackbase->savearea), -1);
setScriptReturn(false);
}
@@ -395,7 +409,8 @@ void AGOSEngine_PN::opn_opcode32() {
char bf[60];
int a, slot;
- if ((a = varval()) > 2) {
+ a = varval();
+ if (a > 2) {
setScriptReturn(true);
return;
}
@@ -451,10 +466,8 @@ void AGOSEngine_PN::opn_opcode35() {
}
void AGOSEngine_PN::opn_opcode36() {
- int ct = 0;
- while (ct < _dataBase[57] + 1)
- _wordcp[ct++] = 0;
- ct = 1;
+ for (int i = 0; i < _dataBase[57] + 1; ++i)
+ _wordcp[i] = 0;
if (isspace(*_inpp))
while ((*_inpp) && (isspace(*_inpp)))
_inpp++;
@@ -468,6 +481,8 @@ void AGOSEngine_PN::opn_opcode36() {
setScriptReturn(true);
return;
}
+
+ int ct = 1;
while ((*_inpp != '.') && (*_inpp != ',') && (!isspace(*_inpp)) && (*_inpp != '\0') &&
(*_inpp!='"')) {
if (ct < _dataBase[57])
@@ -734,37 +749,38 @@ int AGOSEngine_PN::varval() {
int a;
int b;
- if ((a = readfromline()) < 247) {
+ a = readfromline();
+ if (a < 247) {
return a;
}
switch (a) {
case 249:
b = readfromline();
- return((int)(b + 256 * readfromline()));
+ return (int)(b + 256 * readfromline());
break;
case 250:
- return(readfromline());
+ return readfromline();
case 251:
- return((int)_variableArray[varval()]);
+ return (int)_variableArray[varval()];
case 252:
b = varval();
- return((int)_dataBase[_quickptr[0] + b * _quickshort[0] + varval()]);
+ return (int)_dataBase[_quickptr[0] + b * _quickshort[0] + varval()];
case 254:
b = varval();
- return((int)_dataBase[_quickptr[3] + b * _quickshort[2] + varval()]);
+ return (int)_dataBase[_quickptr[3] + b * _quickshort[2] + varval()];
case 247:
b = varval();
- return((int)getptr(_quickptr[11] + (b * _quickshort[4]) + (2 * varval())));
+ return (int)getptr(_quickptr[11] + (b * _quickshort[4]) + (2 * varval()));
case 248:
b = varval();
- return((int)getptr(_quickptr[12] + (b * _quickshort[5]) + (2 * varval())));
+ return (int)getptr(_quickptr[12] + (b * _quickshort[5]) + (2 * varval()));
case 253:
b = varval();
- return(bitextract((int32)_quickptr[1] + b * _quickshort[1], varval()));
+ return bitextract((int32)_quickptr[1] + b * _quickshort[1], varval());
case 255:
b = varval();
- return(bitextract((int32)_quickptr[4] + b * _quickshort[3], varval()));
+ return bitextract((int32)_quickptr[4] + b * _quickshort[3], varval());
default:
error("VARVAL : Illegal code %d encountered", a);
}
@@ -834,10 +850,10 @@ void AGOSEngine_PN::setbitf(uint32 ptr, int offs, int val) {
int AGOSEngine_PN::actCallD(int n) {
int pf[8];
funcentry(pf, n);
- addstack(-1);
+ addstack(kJmpClassNum);
funccpy(pf);
setposition(n, 0);
- return(doline(1));
+ return doline(1);
}
int AGOSEngine_PN::doaction() {
@@ -859,47 +875,59 @@ int AGOSEngine_PN::doaction() {
int AGOSEngine_PN::doline(int needsave) {
int x;
- jmp_buf *ljmpbuff = NULL;
+ jmp_buf *old_jmpbuf = NULL;
jmp_buf *mybuf;
mybuf = (jmp_buf *)malloc(sizeof(jmp_buf));
if (mybuf == NULL)
error("doline: Out of memory - stack overflow");
- if ((x = setjmp(*mybuf)) > 0) {
+ x = setjmp(*mybuf);
+ // Looking at the longjmp calls below, x can be -1, 1 or 2
+ // (and of course 0 when it returns directly, as always).
+ if (x > 0) {
dumpstack();
- _cjmpbuff = ljmpbuff;
+ // Restore the active jmpbuf to its previous value,
+ // then return the longjmp value (will be 2-1=1 or 1-1=0).
+ _cjmpbuff = old_jmpbuf;
free((char *)mybuf);
return (x - 1);
}
if (x == -1) {
+ // Make this doline instance the active one (again).
+ // This is used to "return" over possibly multiple
+ // layers of nested script invocations.
+ // Kind of like throwing an exception.
_cjmpbuff = mybuf;
goto carryon;
}
- ljmpbuff = _cjmpbuff;
+
+ // Remember the previous active jmpbuf (gets restored
+ // above when a longjmp with a positive param occurs).
+ old_jmpbuf = _cjmpbuff;
_cjmpbuff = mybuf;
if (needsave)
_stackbase->savearea = mybuf;
-nln: _linct = ((*_linebase) & 127) - 1;
- _workptr = _linebase + 1;
- if (*_linebase > 127) {
- x = varval();
- if (x != (int)_variableArray[1])
- goto skipln;
- }
-
-carryon:
do {
- x = doaction();
- } while (x && !shouldQuit());
+ _linct = ((*_linebase) & 127) - 1;
+ _workptr = _linebase + 1;
+ if (*_linebase > 127) {
+ x = varval();
+ if (x != (int)_variableArray[1])
+ goto skipln;
+ }
-skipln: _linebase += 127 & *_linebase;
- _linembr++;
+carryon:
+ do {
+ x = doaction();
+ } while (x && !shouldQuit());
- if (!shouldQuit())
- goto nln;
+skipln:
+ _linebase += 127 & *_linebase;
+ _linembr++;
+ } while (!shouldQuit());
return 0;
}
@@ -951,23 +979,15 @@ int AGOSEngine_PN::findset() {
}
void AGOSEngine_PN::funccpy(int *store) {
- int a = 0;
- int b = 24;
-
- while (a < 8) {
- _variableArray[b++] = *store++;
- a++;
+ for (int i = 24; i < 32; ++i) {
+ _variableArray[i] = *store++;
}
}
void AGOSEngine_PN::funcentry(int *store, int procn) {
- int ct = 0;
- int nprm;
-
- nprm = _dataBase[getlong(_quickptr[6] + 3L * procn)];
- while (ct < nprm) {
+ int numParams = _dataBase[getlong(_quickptr[6] + 3 * procn)];
+ for (int i = 0; i < numParams; ++i) {
*store++ = varval();
- ct++;
}
}
@@ -990,23 +1010,28 @@ int AGOSEngine_PN::gvwrd(uint8 *wptr, int mask) {
int AGOSEngine_PN::setposition(int process, int line) {
uint8 *ourptr;
int np;
- int ct = 0;
- ourptr = _dataBase + getlong(_quickptr[6] + 3L * process);
+ int ct;
+
+ ourptr = _dataBase + getlong(_quickptr[6] + 3 * process);
np = *ourptr++;
- while (ct < line) {
+ for (ct = 0; ct < line; ++ct) {
ourptr += (127 & *ourptr);
- ct++;
}
-x1: _linebase = ourptr;
- _linct = (127 & (*ourptr)) - 1;
- if (*ourptr++ > 127) {
+
+ while (true) {
+ _linebase = ourptr;
+ _linct = (127 & *ourptr) - 1;
+ if (*ourptr++ <= 127)
+ break;
+
ct = varval();
- if (ct != (int)_variableArray[1]) {
- ourptr += _linct - 1;
- line++;
- goto x1;
- }
+ if (ct == (int)_variableArray[1])
+ break;
+
+ ourptr += _linct - 1;
+ line++;
}
+
_linembr = line;
_procnum = process;
_variableArray[0] = process;
@@ -1035,22 +1060,20 @@ int AGOSEngine_PN::wrdmatch(uint8 *word1, int mask1, uint8 *word2, int mask2) {
// -----------------------------------------------------------------------
void AGOSEngine_PN::addstack(int type) {
- struct stackframe *a;
- int pt, ct = 0;
+ StackFrame *a;
+ int i;
- a = (struct stackframe *)malloc(sizeof(struct stackframe));
+ a = (StackFrame *)malloc(sizeof(StackFrame));
if (a == NULL)
error("addstack: Out of memory - stack overflow");
a->nextframe = _stackbase;
_stackbase = a;
- pt = 0;
- while (ct < 6)
- a->flag[ct++] = _variableArray[pt++];
- ct = 0;
- pt = 24;
- while (ct < 8)
- a->param[ct++] = _variableArray[pt++];
+
+ for (i = 0; i < 6; ++i)
+ a->flag[i] = _variableArray[i];
+ for (i = 0; i < 8; ++i)
+ a->param[i] = _variableArray[24 + i];
a->classnum = type;
a->ll = _linct;
a->linenum = _linembr;
@@ -1060,7 +1083,7 @@ void AGOSEngine_PN::addstack(int type) {
}
void AGOSEngine_PN::dumpstack() {
- struct stackframe *a;
+ StackFrame *a;
if (_stackbase == NULL)
error("dumpstack: Stack underflow or unknown longjmp");
@@ -1071,20 +1094,20 @@ void AGOSEngine_PN::dumpstack() {
}
void AGOSEngine_PN::junkstack() {
- struct stackframe *a;
+ StackFrame *a;
if (_stackbase == NULL)
error("junkstack: Stack underflow or unknown longjmp");
a = _stackbase->nextframe;
- if (_stackbase->classnum == -1)
+ if (_stackbase->classnum == kJmpClassNum)
free((char *)_stackbase->savearea);
free((char *)_stackbase);
_stackbase = a;
}
void AGOSEngine_PN::popstack(int type) {
- int a = 0, b;
+ int i;
while ((_stackbase != NULL) && (_stackbase->classnum != type))
junkstack();
@@ -1097,13 +1120,10 @@ void AGOSEngine_PN::popstack(int type) {
_workptr = _stackbase->linpos;
_procnum = _stackbase->process;
_linembr = _stackbase->linenum;
- b = 0;
- while (a < 6)
- _variableArray[b++] = _stackbase->flag[a++];
- b = 24;
- a = 0;
- while (a < 8)
- _variableArray[b++] = _stackbase->param[a++];
+ for (i = 0; i < 6; ++i)
+ _variableArray[i] = _stackbase->flag[i];
+ for (i = 0; i < 8; ++i)
+ _variableArray[24 + i] = _stackbase->param[i];
}
} // End of namespace AGOS
diff --git a/engines/agos/string.cpp b/engines/agos/string.cpp
index a466be796f..3773b1fa10 100644
--- a/engines/agos/string.cpp
+++ b/engines/agos/string.cpp
@@ -136,6 +136,20 @@ const byte *AGOSEngine::getStringPtrByID(uint16 stringId, bool upperCase) {
strcpy((char *)dst, (const char *)stringPtr);
}
+ // WORKAROUND bug #1538873: The French version of Simon 1 and the
+ // Polish version of Simon 2 used excess spaces, at the end of many
+ // messages, so we strip off those excess spaces.
+ if ((getGameType() == GType_SIMON1 && _language == Common::FR_FRA) ||
+ (getGameType() == GType_SIMON2 && _language == Common::PL_POL)) {
+ uint16 len = strlen((const char *)dst) - 1;
+
+ while (len && dst[len] == 32) {
+ dst[len] = 0;
+ len--;
+ }
+
+ }
+
if (upperCase && *dst) {
if (islower(*dst))
*dst = toupper(*dst);
diff --git a/engines/agos/vga.cpp b/engines/agos/vga.cpp
index d2e620d86e..d37681508e 100644
--- a/engines/agos/vga.cpp
+++ b/engines/agos/vga.cpp
@@ -1186,7 +1186,8 @@ void AGOSEngine::vc32_saveScreen() {
byte *src = (byte *)screen->pixels;
for (int i = 0; i < _screenHeight; i++) {
memcpy(dst, src, _screenWidth);
- dst += screen->pitch;
+ dst += _backGroundBuf->pitch;
+ src += screen->pitch;
}
_system->unlockScreen();
} else {
diff --git a/engines/agos/vga_e2.cpp b/engines/agos/vga_e2.cpp
index 7f02398e13..f6e6630d43 100644
--- a/engines/agos/vga_e2.cpp
+++ b/engines/agos/vga_e2.cpp
@@ -207,6 +207,7 @@ void AGOSEngine::vc53_dissolveIn() {
uint16 speed = vcReadNextWord() + 1;
byte *src, *dst, *srcOffs, *srcOffs2, *dstOffs, *dstOffs2;
+ int16 xoffs, yoffs;
uint8 color = 0;
// Only uses Video Window 4
@@ -218,15 +219,13 @@ void AGOSEngine::vc53_dissolveIn() {
uint16 dissolveDelay = dissolveCheck * 2 / speed;
uint16 dissolveCount = dissolveCheck * 2 / speed;
- Graphics::Surface *screen = _system->lockScreen();
-
- int16 xoffs = _videoWindows[num * 4 + 0] * 16;
- int16 yoffs = _videoWindows[num * 4 + 1];
- int16 offs = xoffs + yoffs * screen->pitch;
+ int16 x = _videoWindows[num * 4 + 0] * 16;
+ int16 y = _videoWindows[num * 4 + 1];
uint16 count = dissolveCheck * 2;
while (count--) {
- byte *dstPtr = (byte *)screen->pixels + offs;
+ Graphics::Surface *screen = _system->lockScreen();
+ byte *dstPtr = (byte *)screen->pixels + x + y * screen->pitch;
yoffs = _rnd.getRandomNumber(dissolveY);
dst = dstPtr + yoffs * screen->pitch;
@@ -285,6 +284,7 @@ void AGOSEngine::vc54_dissolveOut() {
uint16 speed = vcReadNextWord() + 1;
byte *dst, *dstOffs;
+ int16 xoffs, yoffs;
uint16 dissolveX = _videoWindows[num * 4 + 2] * 8;
uint16 dissolveY = (_videoWindows[num * 4 + 3] + 1) / 2;
@@ -292,15 +292,13 @@ void AGOSEngine::vc54_dissolveOut() {
uint16 dissolveDelay = dissolveCheck * 2 / speed;
uint16 dissolveCount = dissolveCheck * 2 / speed;
- Graphics::Surface *screen = _system->lockScreen();
-
- int16 xoffs = _videoWindows[num * 4 + 0] * 16;
- int16 yoffs = _videoWindows[num * 4 + 1];
- int16 offs = xoffs + yoffs * screen->pitch;
+ int16 x = _videoWindows[num * 4 + 0] * 16;
+ int16 y = _videoWindows[num * 4 + 1];
uint16 count = dissolveCheck * 2;
while (count--) {
- byte *dstPtr = (byte *)screen->pixels + offs;
+ Graphics::Surface *screen = _system->lockScreen();
+ byte *dstPtr = (byte *)screen->pixels + x + y * screen->pitch;
color |= dstPtr[0] & 0xF0;
yoffs = _rnd.getRandomNumber(dissolveY);
diff --git a/engines/agos/vga_pn.cpp b/engines/agos/vga_pn.cpp
index 32c6e15f00..12846b08f1 100644
--- a/engines/agos/vga_pn.cpp
+++ b/engines/agos/vga_pn.cpp
@@ -129,7 +129,6 @@ void AGOSEngine::vc36_pause() {
_keyPressed.reset();
windowPutChar(_windowArray[2], 13);
- windowPutChar(_windowArray[2], 128);
_wiped = oldWiped;
_videoLockOut &= ~8;