aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTravis Howell2007-05-26 13:23:06 +0000
committerTravis Howell2007-05-26 13:23:06 +0000
commitd6e0fe13b5ff266c87f2119f9d1c42b70cdea496 (patch)
treed02601bab4086332b3fd767dd3c318f89cd892af
parent0bd2a211fd01b08c97867747e786ebc908caa403 (diff)
downloadscummvm-rg350-d6e0fe13b5ff266c87f2119f9d1c42b70cdea496.tar.gz
scummvm-rg350-d6e0fe13b5ff266c87f2119f9d1c42b70cdea496.tar.bz2
scummvm-rg350-d6e0fe13b5ff266c87f2119f9d1c42b70cdea496.zip
Add code for opcodes 177/178 in Elvira 2.
svn-id: r26937
-rw-r--r--engines/agos/agos.cpp7
-rw-r--r--engines/agos/agos.h23
-rw-r--r--engines/agos/event.cpp124
-rw-r--r--engines/agos/gfx.cpp6
-rw-r--r--engines/agos/script_e2.cpp14
-rw-r--r--engines/agos/vga.cpp12
-rw-r--r--engines/agos/vga_s2.cpp2
7 files changed, 154 insertions, 34 deletions
diff --git a/engines/agos/agos.cpp b/engines/agos/agos.cpp
index e1071f5165..da9bccadc3 100644
--- a/engines/agos/agos.cpp
+++ b/engines/agos/agos.cpp
@@ -381,6 +381,11 @@ AGOSEngine::AGOSEngine(OSystem *syst)
_nextVgaTimerToProcess = 0;
+ _opcode177Var1 = 1;
+ _opcode177Var2 = 0;
+ _opcode178Var1 = 1;
+ _opcode178Var2 = 0;
+
_classLine = 0;
_classMask = 0;
_classMode1 = 0;
@@ -948,7 +953,7 @@ int AGOSEngine::go() {
if (getGameType() != GType_PP && getGameType() != GType_FF) {
uint16 count = (getGameType() == GType_SIMON2) ? 5 : _frameCount;
- addVgaEvent(count, NULL, 0, 0, 2);
+ addVgaEvent(count, ANIMATE_INT, NULL, 0, 0);
}
if (getGameType() == GType_ELVIRA1 && getPlatform() == Common::kPlatformAtariST &&
diff --git a/engines/agos/agos.h b/engines/agos/agos.h
index bc2e2e4b16..83e46f9723 100644
--- a/engines/agos/agos.h
+++ b/engines/agos/agos.h
@@ -130,6 +130,14 @@ enum SIMONGameType {
GType_PP = 7
};
+enum EventType {
+ ANIMATE_INT = 1 << 1,
+ ANIMATE_EVENT = 1 << 2,
+ SCROLL_EVENT = 1 << 3,
+ IMAGE_EVENT2 = 1 << 4,
+ IMAGE_EVENT3 = 1 << 5
+};
+
struct AGOSGameDescription;
struct GameSpecificSettings;
@@ -202,13 +210,6 @@ protected:
byte _keyPressed;
- typedef enum {
- FORMAT_NONE,
- FORMAT_MP3,
- FORMAT_WAV,
- FORMAT_VOC
- } SoundFormat;
-
Common::File *_gameFile;
byte *_strippedTxtMem;
@@ -437,6 +438,9 @@ protected:
VgaTimerEntry *_nextVgaTimerToProcess;
+ uint8 _opcode177Var1, _opcode177Var2;
+ uint8 _opcode178Var1, _opcode178Var2;
+
Item *_objectArray[50];
Item *_itemStore[50];
@@ -1086,11 +1090,14 @@ protected:
bool isVgaQueueEmpty();
void haltAnimation();
void restartAnimation();
- void addVgaEvent(uint16 num, const byte *code_ptr, uint16 cur_sprite, uint16 curZoneNum, uint8 type = 0);
+ void addVgaEvent(uint16 num, uint8 type, const byte *code_ptr, uint16 cur_sprite, uint16 curZoneNum);
void deleteVgaEvent(VgaTimerEntry * vte);
void processVgaEvents();
void animateEvent(const byte *code_ptr, uint16 curZoneNum, uint16 cur_sprite);
void scrollEvent();
+ void drawStuff(const byte *src, uint offs);
+ void imageEvent2(VgaTimerEntry * vte, uint dx);
+ void imageEvent3(VgaTimerEntry * vte, uint dx);
VgaSprite *findCurSprite();
diff --git a/engines/agos/event.cpp b/engines/agos/event.cpp
index 542cbc5266..9fc8cb72e5 100644
--- a/engines/agos/event.cpp
+++ b/engines/agos/event.cpp
@@ -194,7 +194,7 @@ void AGOSEngine::restartAnimation() {
// Check picture queue
}
-void AGOSEngine::addVgaEvent(uint16 num, const byte *code_ptr, uint16 cur_sprite, uint16 curZoneNum, uint8 type) {
+void AGOSEngine::addVgaEvent(uint16 num, uint8 type, const byte *code_ptr, uint16 cur_sprite, uint16 curZoneNum) {
VgaTimerEntry *vte;
_lockWord |= 1;
@@ -237,28 +237,35 @@ void AGOSEngine::processVgaEvents() {
uint16 curZoneNum = vte->cur_vga_file;
uint16 cur_sprite = vte->sprite_id;
const byte *script_ptr = vte->script_pointer;
- uint8 type = vte->type;
- if (type == 2) {
+ switch (vte->type) {
+ case ANIMATE_INT:
vte->delay = (getGameType() == GType_SIMON2) ? 5 : _frameCount;
-
animateSprites();
-
vte++;
- } else if (type == 1) {
+ break;
+ case ANIMATE_EVENT:
_nextVgaTimerToProcess = vte + 1;
deleteVgaEvent(vte);
-
- scrollEvent();
-
+ animateEvent(script_ptr, curZoneNum, cur_sprite);
vte = _nextVgaTimerToProcess;
- } else if (type == 0) {
+ break;
+ case SCROLL_EVENT:
_nextVgaTimerToProcess = vte + 1;
deleteVgaEvent(vte);
-
- animateEvent(script_ptr, curZoneNum, cur_sprite);
-
+ scrollEvent();
+ vte = _nextVgaTimerToProcess;
+ break;
+ case IMAGE_EVENT2:
+ imageEvent2(vte, curZoneNum);
vte = _nextVgaTimerToProcess;
+ break;
+ case IMAGE_EVENT3:
+ imageEvent3(vte, curZoneNum);
+ vte = _nextVgaTimerToProcess;
+ break;
+ default:
+ error("processVgaEvents: Unknown event type %d", vte->type);
}
} else {
vte++;
@@ -315,7 +322,96 @@ void AGOSEngine::scrollEvent() {
}
}
- addVgaEvent(6, NULL, 0, 0, 1); /* scroll event */
+ addVgaEvent(6, SCROLL_EVENT, NULL, 0, 0);
+ }
+}
+
+static const byte _image1[32] = {
+ 0x3A, 0x37, 0x3B, 0x37,
+ 0x3A, 0x3E, 0x3F, 0x3E,
+ 0x37, 0x3F, 0x31, 0x3F,
+ 0x37, 0x3F, 0x31, 0x3F,
+ 0x3A, 0x3E, 0x3F, 0x3E,
+ 0x3A, 0x37, 0x3B, 0x37,
+};
+
+static const byte _image2[32] = {
+ 0x3A, 0x3A, 0x3B, 0x3A,
+ 0x3A, 0x37, 0x3E, 0x37,
+ 0x3A, 0x37, 0x3E, 0x37,
+ 0x3A, 0x37, 0x3E, 0x37,
+ 0x3A, 0x37, 0x3E, 0x37,
+ 0x3A, 0x3A, 0x3B, 0x3A,
+};
+
+static const byte _image3[32] = {
+ 0x3A, 0x32, 0x3B, 0x32,
+ 0x3A, 0x39, 0x3F, 0x39,
+ 0x32, 0x3F, 0x31, 0x3F,
+ 0x32, 0x3F, 0x31, 0x3F,
+ 0x3A, 0x39, 0x3F, 0x39,
+ 0x3A, 0x32, 0x3B, 0x32,
+};
+
+static const byte _image4[32] = {
+ 0x3A, 0x3A, 0x3B, 0x3A,
+ 0x3A, 0x32, 0x39, 0x32,
+ 0x3A, 0x32, 0x38, 0x32,
+ 0x3A, 0x32, 0x38, 0x32,
+ 0x3A, 0x32, 0x39, 0x32,
+ 0x3A, 0x3A, 0x3B, 0x3A,
+};
+
+void AGOSEngine::drawStuff(const byte *src, uint offs) {
+ byte *dst = getFrontBuf() + offs;
+
+ for (uint y = 0; y < 6; y++) {
+ memcpy(dst, src, 4);
+ src += 4;
+ dst += _screenWidth;
+ }
+}
+
+void AGOSEngine::imageEvent2(VgaTimerEntry * vte, uint dx) {
+ // Draws damage indicator gauge
+ _nextVgaTimerToProcess = vte + 1;
+
+ if (!_opcode177Var1) {
+ drawStuff(_image1, 43204 + _opcode177Var2 * 4);
+ _opcode177Var2++;
+ if (_opcode177Var2 == dx) {
+ _opcode177Var1 = 1;
+ vte->delay = 16 - dx;
+ } else {
+ vte->delay = 1;
+ }
+ } else if (_opcode177Var2) {
+ _opcode177Var2--;
+ drawStuff(_image2, 43204 + _opcode177Var2 * 4);
+ vte->delay = 3;
+ } else {
+ deleteVgaEvent(vte);
+ }
+}
+
+void AGOSEngine::imageEvent3(VgaTimerEntry * vte, uint dx) {
+ _nextVgaTimerToProcess = vte + 1;
+
+ if (!_opcode178Var1) {
+ drawStuff(_image3, 43475 + _opcode178Var2 * 4);
+ _opcode178Var2++;
+ if (_opcode178Var2 >= 10 || _opcode178Var2 == dx) {
+ _opcode178Var1 = 1;
+ vte->delay = 16 - dx;
+ } else {
+ vte->delay = 1;
+ }
+ } else if (_opcode178Var2) {
+ _opcode178Var2--;
+ drawStuff(_image4, 43475 + _opcode178Var2 * 4);
+ vte->delay = 3;
+ } else {
+ deleteVgaEvent(vte);
}
}
diff --git a/engines/agos/gfx.cpp b/engines/agos/gfx.cpp
index 87f0fb2d88..68c405ba8c 100644
--- a/engines/agos/gfx.cpp
+++ b/engines/agos/gfx.cpp
@@ -1101,11 +1101,11 @@ void AGOSEngine::animate(uint16 windowNum, uint16 zoneNum, uint16 vgaSpriteId, i
}
if (getGameType() == GType_FF || getGameType() == GType_PP) {
- addVgaEvent(_vgaBaseDelay, _curVgaFile1 + READ_LE_UINT16(&((AnimationHeader_Feeble *) p)->scriptOffs), vgaSpriteId, zoneNum);
+ addVgaEvent(_vgaBaseDelay, ANIMATE_EVENT, _curVgaFile1 + READ_LE_UINT16(&((AnimationHeader_Feeble *) p)->scriptOffs), vgaSpriteId, zoneNum);
} else if (getGameType() == GType_SIMON1 || getGameType() == GType_SIMON2) {
- addVgaEvent(_vgaBaseDelay, _curVgaFile1 + READ_BE_UINT16(&((AnimationHeader_Simon *) p)->scriptOffs), vgaSpriteId, zoneNum);
+ addVgaEvent(_vgaBaseDelay, ANIMATE_EVENT, _curVgaFile1 + READ_BE_UINT16(&((AnimationHeader_Simon *) p)->scriptOffs), vgaSpriteId, zoneNum);
} else {
- addVgaEvent(_vgaBaseDelay, _curVgaFile1 + READ_BE_UINT16(&((AnimationHeader_WW *) p)->scriptOffs), vgaSpriteId, zoneNum);
+ addVgaEvent(_vgaBaseDelay, ANIMATE_EVENT, _curVgaFile1 + READ_BE_UINT16(&((AnimationHeader_WW *) p)->scriptOffs), vgaSpriteId, zoneNum);
}
}
diff --git a/engines/agos/script_e2.cpp b/engines/agos/script_e2.cpp
index bb492a30b9..3b2c1203df 100644
--- a/engines/agos/script_e2.cpp
+++ b/engines/agos/script_e2.cpp
@@ -638,14 +638,26 @@ void AGOSEngine_Elvira2::oe2_setSRExit() {
}
void AGOSEngine_Elvira2::oe2_unk177() {
- // 177: set unknown vga event
+ // 177: Set damage indicator event
uint a = getVarOrByte();
+ if (_opcode177Var1 && !_opcode177Var2 && a != 0 && a <= 10) {
+ addVgaEvent(_vgaBaseDelay, IMAGE_EVENT2, NULL, 0, a);
+ _opcode177Var2 = 0;
+ _opcode177Var1 = 0;
+ }
+
debug(0, "oe2_unk177: stub (%d)", a);
}
void AGOSEngine_Elvira2::oe2_unk178() {
// 178: set unknown vga event
uint a = getVarOrByte();
+ if (_opcode178Var1 && !_opcode178Var2 && a != 0 && a <= 10) {
+ addVgaEvent(_vgaBaseDelay, IMAGE_EVENT3, NULL, 0, a);
+ _opcode178Var2 = 0;
+ _opcode178Var1 = 0;
+ }
+
debug(0, "oe2_unk178: stub (%d)", a);
}
diff --git a/engines/agos/vga.cpp b/engines/agos/vga.cpp
index b3352ecafc..eb2d1391ce 100644
--- a/engines/agos/vga.cpp
+++ b/engines/agos/vga.cpp
@@ -721,7 +721,7 @@ void AGOSEngine::vc12_delay() {
num += _vgaBaseDelay;
- addVgaEvent(num, _vcPtr, _vgaCurSpriteId, _vgaCurZoneNum);
+ addVgaEvent(num, ANIMATE_EVENT, _vcPtr, _vgaCurSpriteId, _vgaCurZoneNum);
_vcPtr = (byte *)&_vc_get_out_of_code;
}
@@ -748,7 +748,7 @@ void AGOSEngine::vc15_sync() {
uint16 id = vcReadNextWord();
while (vfs->ident != 0) {
if (vfs->ident == id) {
- addVgaEvent(_vgaBaseDelay, vfs->code_ptr, vfs->sprite_id, vfs->cur_vga_file);
+ addVgaEvent(_vgaBaseDelay, ANIMATE_EVENT, vfs->code_ptr, vfs->sprite_id, vfs->cur_vga_file);
vfs_tmp = vfs;
do {
memcpy(vfs_tmp, vfs_tmp + 1, sizeof(VgaSleepStruct));
@@ -782,7 +782,7 @@ void AGOSEngine::checkWaitEndTable() {
VgaSleepStruct *vfs = _waitEndTable, *vfs_tmp;
while (vfs->ident != 0) {
if (vfs->ident == _vgaCurSpriteId) {
- addVgaEvent(_vgaBaseDelay, vfs->code_ptr, vfs->sprite_id, vfs->cur_vga_file);
+ addVgaEvent(_vgaBaseDelay, ANIMATE_EVENT, vfs->code_ptr, vfs->sprite_id, vfs->cur_vga_file);
vfs_tmp = vfs;
do {
memcpy(vfs_tmp, vfs_tmp + 1, sizeof(VgaSleepStruct));
@@ -1305,7 +1305,7 @@ void AGOSEngine::vc40() {
tmp = _scrollXMax - _scrollX;
if (tmp < 20)
_scrollCount = tmp;
- addVgaEvent(6, NULL, 0, 0, 1); /* scroll event */
+ addVgaEvent(6, SCROLL_EVENT, NULL, 0, 0);
}
}
no_scroll:;
@@ -1331,7 +1331,7 @@ void AGOSEngine::vc41() {
_scrollCount = -20;
if (_scrollX < 20)
_scrollCount = -_scrollX;
- addVgaEvent(6, NULL, 0, 0, 1); /* scroll event */
+ addVgaEvent(6, SCROLL_EVENT, NULL, 0, 0);
}
}
no_scroll:;
@@ -1343,7 +1343,7 @@ void AGOSEngine::vc42_delayIfNotEQ() {
uint16 val = vcReadVar(vcReadNextWord());
if (val != vcReadNextWord()) {
- addVgaEvent(_frameCount + 1, _vcPtr - 4, _vgaCurSpriteId, _vgaCurZoneNum);
+ addVgaEvent(_frameCount + 1, ANIMATE_EVENT, _vcPtr - 4, _vgaCurSpriteId, _vgaCurZoneNum);
_vcPtr = (byte *)&_vc_get_out_of_code;
}
}
diff --git a/engines/agos/vga_s2.cpp b/engines/agos/vga_s2.cpp
index b3010702ea..6989e26b46 100644
--- a/engines/agos/vga_s2.cpp
+++ b/engines/agos/vga_s2.cpp
@@ -50,7 +50,7 @@ void AGOSEngine_Simon2::setupVideoOpcodes(VgaOpcodeProc *op) {
void AGOSEngine::vc56_delayLong() {
uint16 num = vcReadVarOrWord() * _frameCount;
- addVgaEvent(num + _vgaBaseDelay, _vcPtr, _vgaCurSpriteId, _vgaCurZoneNum);
+ addVgaEvent(num + _vgaBaseDelay, ANIMATE_EVENT, _vcPtr, _vgaCurSpriteId, _vgaCurZoneNum);
_vcPtr = (byte *)&_vc_get_out_of_code;
}