[Scummvm-cvs-logs] SF.net SVN: scummvm: [26937] scummvm/trunk/engines/agos
Kirben at users.sourceforge.net
Kirben at users.sourceforge.net
Sat May 26 15:23:06 CEST 2007
Revision: 26937
http://scummvm.svn.sourceforge.net/scummvm/?rev=26937&view=rev
Author: Kirben
Date: 2007-05-26 06:23:06 -0700 (Sat, 26 May 2007)
Log Message:
-----------
Add code for opcodes 177/178 in Elvira 2.
Modified Paths:
--------------
scummvm/trunk/engines/agos/agos.cpp
scummvm/trunk/engines/agos/agos.h
scummvm/trunk/engines/agos/event.cpp
scummvm/trunk/engines/agos/gfx.cpp
scummvm/trunk/engines/agos/script_e2.cpp
scummvm/trunk/engines/agos/vga.cpp
scummvm/trunk/engines/agos/vga_s2.cpp
Modified: scummvm/trunk/engines/agos/agos.cpp
===================================================================
--- scummvm/trunk/engines/agos/agos.cpp 2007-05-26 12:01:33 UTC (rev 26936)
+++ scummvm/trunk/engines/agos/agos.cpp 2007-05-26 13:23:06 UTC (rev 26937)
@@ -381,6 +381,11 @@
_nextVgaTimerToProcess = 0;
+ _opcode177Var1 = 1;
+ _opcode177Var2 = 0;
+ _opcode178Var1 = 1;
+ _opcode178Var2 = 0;
+
_classLine = 0;
_classMask = 0;
_classMode1 = 0;
@@ -948,7 +953,7 @@
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 &&
Modified: scummvm/trunk/engines/agos/agos.h
===================================================================
--- scummvm/trunk/engines/agos/agos.h 2007-05-26 12:01:33 UTC (rev 26936)
+++ scummvm/trunk/engines/agos/agos.h 2007-05-26 13:23:06 UTC (rev 26937)
@@ -130,6 +130,14 @@
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 @@
byte _keyPressed;
- typedef enum {
- FORMAT_NONE,
- FORMAT_MP3,
- FORMAT_WAV,
- FORMAT_VOC
- } SoundFormat;
-
Common::File *_gameFile;
byte *_strippedTxtMem;
@@ -437,6 +438,9 @@
VgaTimerEntry *_nextVgaTimerToProcess;
+ uint8 _opcode177Var1, _opcode177Var2;
+ uint8 _opcode178Var1, _opcode178Var2;
+
Item *_objectArray[50];
Item *_itemStore[50];
@@ -1086,11 +1090,14 @@
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();
Modified: scummvm/trunk/engines/agos/event.cpp
===================================================================
--- scummvm/trunk/engines/agos/event.cpp 2007-05-26 12:01:33 UTC (rev 26936)
+++ scummvm/trunk/engines/agos/event.cpp 2007-05-26 13:23:06 UTC (rev 26937)
@@ -194,7 +194,7 @@
// 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 @@
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,10 +322,99 @@
}
}
- 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);
+ }
+}
+
void AGOSEngine::delay(uint amount) {
Common::Event event;
Modified: scummvm/trunk/engines/agos/gfx.cpp
===================================================================
--- scummvm/trunk/engines/agos/gfx.cpp 2007-05-26 12:01:33 UTC (rev 26936)
+++ scummvm/trunk/engines/agos/gfx.cpp 2007-05-26 13:23:06 UTC (rev 26937)
@@ -1101,11 +1101,11 @@
}
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);
}
}
Modified: scummvm/trunk/engines/agos/script_e2.cpp
===================================================================
--- scummvm/trunk/engines/agos/script_e2.cpp 2007-05-26 12:01:33 UTC (rev 26936)
+++ scummvm/trunk/engines/agos/script_e2.cpp 2007-05-26 13:23:06 UTC (rev 26937)
@@ -638,14 +638,26 @@
}
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);
}
Modified: scummvm/trunk/engines/agos/vga.cpp
===================================================================
--- scummvm/trunk/engines/agos/vga.cpp 2007-05-26 12:01:33 UTC (rev 26936)
+++ scummvm/trunk/engines/agos/vga.cpp 2007-05-26 13:23:06 UTC (rev 26937)
@@ -721,7 +721,7 @@
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 @@
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 @@
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 @@
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 @@
_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 @@
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;
}
}
Modified: scummvm/trunk/engines/agos/vga_s2.cpp
===================================================================
--- scummvm/trunk/engines/agos/vga_s2.cpp 2007-05-26 12:01:33 UTC (rev 26936)
+++ scummvm/trunk/engines/agos/vga_s2.cpp 2007-05-26 13:23:06 UTC (rev 26937)
@@ -50,7 +50,7 @@
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;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list