[Scummvm-cvs-logs] CVS: scummvm/scumm intern.h,2.229,2.230 script_v72he.cpp,2.64,2.65 script_v80he.cpp,2.7,2.8 script_v90he.cpp,2.16,2.17
Eugene Sandulenko
sev at users.sourceforge.net
Wed Sep 8 18:54:44 CEST 2004
Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1468
Modified Files:
intern.h script_v72he.cpp script_v80he.cpp script_v90he.cpp
Log Message:
Implement HE 80+ wiz-based cursors. Current implementation is a dirty
hack because drawWizImage has much more code in these games comparably
to 72 games. Also they pass cursor parameters in a quite obscure way.
Index: intern.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/intern.h,v
retrieving revision 2.229
retrieving revision 2.230
diff -u -d -r2.229 -r2.230
--- intern.h 7 Sep 2004 13:30:25 -0000 2.229
+++ intern.h 9 Sep 2004 01:53:23 -0000 2.230
@@ -697,13 +697,15 @@
int readFileToArray(int slot, int32 size);
void writeFileFromArray(int slot, int resID);
- void drawWizImage(int restype, int resnum, int x1, int y1, int flags);
+ void drawWizImage(int restype, int resnum, int state, int x1, int y1, int flags);
void flushWizBuffer();
virtual void decodeParseString(int a, int b);
void decodeScriptString(byte *dst, bool scriptString = false);
int copyScriptString(byte *dst);
+ const byte *findWrappedBlock(uint32 tag, const byte *ptr, int state, bool flagError);
+
/* HE version 72 script opcodes */
void o72_pushDWord();
void o72_addMessageToStack();
@@ -777,10 +779,15 @@
virtual void setupOpcodes();
virtual void executeOpcode(byte i);
virtual const char *getOpcodeDesc(byte i);
+
+ void loadImgSpot(int resId, int state, Common::Point spot);
+ void loadWizCursor(int resId, int resType, bool state);
+
/* HE version 80 script opcodes */
void o80_unknown49();
void o80_unknown4D();
+ void o80_cursorCommand();
void o80_setState();
};
Index: script_v72he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v72he.cpp,v
retrieving revision 2.64
retrieving revision 2.65
diff -u -d -r2.64 -r2.65
--- script_v72he.cpp 8 Sep 2004 21:14:12 -0000 2.64
+++ script_v72he.cpp 9 Sep 2004 01:53:23 -0000 2.65
@@ -566,6 +566,14 @@
*dst = 0;
}
+const byte *ScummEngine_v72he::findWrappedBlock(uint32 tag, const byte *ptr, int state, bool errorFlag) {
+ if (READ_UINT32(ptr) == MKID('MULT')) {
+ error("findWrappedBlock: multi blocks aren't implemented");
+ } else {
+ return findResourceData(tag, ptr);
+ }
+}
+
void ScummEngine_v72he::o72_pushDWord() {
int a;
if (*_lastCodePtr + sizeof(MemBlkHeader) != _scriptOrgPointer) {
@@ -779,7 +787,7 @@
void ScummEngine_v72he::o72_printWizImage() {
int resnum = pop();
- drawWizImage(rtImage, resnum, 0, 0, 4);
+ drawWizImage(rtImage, resnum, 0, 0, 0, 4);
}
void ScummEngine_v72he::o72_getArrayDimSize() {
@@ -1261,10 +1269,10 @@
debug(1, "stub o72_unknownC1(%s)", string);
}
-void ScummEngine_v72he::drawWizImage(int restype, int resnum, int x1, int y1, int flags) {
+void ScummEngine_v72he::drawWizImage(int restype, int resnum, int state, int x1, int y1, int flags) {
const uint8 *dataPtr = getResourceAddress(restype, resnum);
if (dataPtr) {
- const uint8 *wizh = findResourceData(MKID('WIZH'), dataPtr);
+ const uint8 *wizh = findWrappedBlock(MKID('WIZH'), dataPtr, state, 0);
assert(wizh);
uint32 comp = READ_LE_UINT32(wizh + 0x0);
uint32 width = READ_LE_UINT32(wizh + 0x4);
@@ -1272,10 +1280,10 @@
if (comp != 1) {
warning("%d has invalid compression type %d", resnum, comp);
}
- const uint8 *wizd = findResourceData(MKID('WIZD'), dataPtr);
+ const uint8 *wizd = findWrappedBlock(MKID('WIZD'), dataPtr, state, 0);
assert(wizd);
if (flags & 1) {
- const uint8 *pal = findResourceData(MKID('RGBS'), dataPtr);
+ const uint8 *pal = findWrappedBlock(MKID('RGBS'), dataPtr, state, 0);
assert(pal);
setPaletteFromPtr(pal, 256);
}
@@ -1287,11 +1295,27 @@
return;
}
- uint8 *dst;
+ uint8 *dst = 0;
+ if (flags & 0x24) { // printing (0x4) or rendering to memory (0x20)
+ dst = (uint8 *)malloc(width * height);
+ memset(dst, 255, width * height); // make transparent
+
+ if (flags & 0x20) {
+ // copy width * height bytes from VAR_117 to dst
+
+ // FIXME: dirty hack until missing bits are implemented
+ Common::Rect rScreen(0, 0, width-1, height-1);
+ gdi.copyWizImage(dst, wizd, width, height, 0, 0, width, height, &rScreen);
+ setCursorFromBuffer(dst, width, height, width);
+ free(dst);
+ return;
+ }
+ }
+
VirtScreen *pvs = &virtscr[kMainVirtScreen];
if (flags & 0x10) {
dst = pvs->getPixels(0, pvs->topline);
- } else {
+ } else if (!(flags & 0x20)) {
dst = pvs->getBackPixels(0, pvs->topline);
}
Common::Rect rScreen(0, 0, pvs->w, pvs->h);
@@ -1324,7 +1348,7 @@
void ScummEngine_v72he::flushWizBuffer() {
for (int i = 0; i < _wizImagesNum; ++i) {
WizImage *pwi = &_wizImages[i];
- drawWizImage(rtImage, pwi->resnum, pwi->x1, pwi->y1, pwi->flags);
+ drawWizImage(rtImage, pwi->resnum, 0, pwi->x1, pwi->y1, pwi->flags);
}
_wizImagesNum = 0;
}
@@ -1343,7 +1367,7 @@
pwi->flags = flags;
++_wizImagesNum;
} else {
- drawWizImage(rtImage, resnum, x1, y1, flags);
+ drawWizImage(rtImage, resnum, 0, x1, y1, flags);
}
}
Index: script_v80he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v80he.cpp,v
retrieving revision 2.7
retrieving revision 2.8
diff -u -d -r2.7 -r2.8
--- script_v80he.cpp 8 Sep 2004 10:36:06 -0000 2.7
+++ script_v80he.cpp 9 Sep 2004 01:53:23 -0000 2.8
@@ -178,7 +178,7 @@
OPCODE(o6_cutscene),
OPCODE(o6_stopMusic),
OPCODE(o6_freezeUnfreeze),
- OPCODE(o7_cursorCommand),
+ OPCODE(o80_cursorCommand),
/* 6C */
OPCODE(o6_breakHere),
OPCODE(o6_ifClassOfIs),
@@ -413,6 +413,107 @@
debug(1, "o80_unknown4D (%d) %s %s %s", type, option, option2, option3);
}
+void ScummEngine_v80he::o80_cursorCommand() {
+ int a, i;
+ int args[16];
+ int subOp = fetchScriptByte();
+
+ switch (subOp) {
+ case 0x13: // Loads cursors from another resource
+ a = pop();
+ loadWizCursor(a, rtInventory, 0);
+ break;
+ case 0x14:
+ a = pop();
+ loadWizCursor(a, rtInventory, 1);
+ break;
+ case 0x90: // SO_CURSOR_ON Turn cursor on
+ _cursor.state = 1;
+ verbMouseOver(0);
+ break;
+ case 0x91: // SO_CURSOR_OFF Turn cursor off
+ _cursor.state = 0;
+ verbMouseOver(0);
+ break;
+ case 0x92: // SO_USERPUT_ON
+ _userPut = 1;
+ break;
+ case 0x93: // SO_USERPUT_OFF
+ _userPut = 0;
+ break;
+ case 0x94: // SO_CURSOR_SOFT_ON Turn soft cursor on
+ _cursor.state++;
+ if (_cursor.state > 1)
+ error("Cursor state greater than 1 in script");
+ break;
+ case 0x95: // SO_CURSOR_SOFT_OFF Turn soft cursor off
+ _cursor.state--;
+ break;
+ case 0x96: // SO_USERPUT_SOFT_ON
+ _userPut++;
+ break;
+ case 0x97: // SO_USERPUT_SOFT_OFF
+ _userPut--;
+ break;
+ case 0x99: // SO_CURSOR_IMAGE Set cursor image
+ warning("o80_cursorCommand: Can't set cursors to ID. Use images.");
+ break;
+ case 0x9A: // SO_CURSOR_HOTSPOT Set cursor hotspot
+ case 0x9B:
+ a = pop();
+ setCursorHotspot(pop(), a);
+ break;
+ case 0x9C: // SO_CHARSET_SET
+ initCharset(pop());
+ break;
+ case 0x9D: // SO_CHARSET_COLOR
+ getStackList(args, ARRAYSIZE(args));
+ for (i = 0; i < 16; i++)
+ _charsetColorMap[i] = _charsetData[_string[1]._default.charset][i] = (unsigned char)args[i];
+ break;
+ default:
+ error("o80_cursorCommand: default case %x", subOp);
+ }
+
+ VAR(VAR_CURSORSTATE) = _cursor.state;
+ VAR(VAR_USERPUT) = _userPut;
+}
+
+void ScummEngine_v80he::loadImgSpot(int resId, int state, Common::Point spot) {
+ const uint8 *dataPtr = getResourceAddress(rtImage, resId);
+ if (!dataPtr)
+ error("loadImgSpot: unknown Image %d", resId);
+
+ const uint8 *spotPtr = findWrappedBlock(MKID('SPOT'), dataPtr, state, 0);
+
+ if (!spotPtr) {
+ spot.x = spot.y = 0;
+ } else {
+ spot.x = (int16)READ_LE_UINT32(spotPtr + 8);
+ spot.y = (int16)READ_LE_UINT32(spotPtr + 12);
+ }
+}
+
+void ScummEngine_v80he::loadWizCursor(int resId, int resType, bool state) {
+ Common::Rect rc;
+ Common::Point spot;
+
+ loadImgSpot(resId, 0, spot);
+
+ rc.top = spot.x;
+ rc.right = spot.y;
+
+ rc.top = MAX((int)rc.top, 0);
+ rc.right = MAX((int)rc.right, 0);
+ rc.top = MIN((int)rc.top, 32);
+ rc.right = MIN((int)rc.right, 32);
+
+ // FIXME: dirty hack. Cursor is set in drawWizImage, though should be set from here
+ // it is unclear how height and width are passed from drawWizImage
+ drawWizImage(rtImage, resId, 0, 0, 0, 0x20);
+ setCursorHotspot(rc.top, rc.right);
+}
+
void ScummEngine_v80he::o80_setState() {
int state = pop();
int obj = pop();
Index: script_v90he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v90he.cpp,v
retrieving revision 2.16
retrieving revision 2.17
diff -u -d -r2.16 -r2.17
--- script_v90he.cpp 7 Sep 2004 14:16:08 -0000 2.16
+++ script_v90he.cpp 9 Sep 2004 01:53:23 -0000 2.17
@@ -178,7 +178,7 @@
OPCODE(o6_cutscene),
OPCODE(o6_stopMusic),
OPCODE(o6_freezeUnfreeze),
- OPCODE(o7_cursorCommand),
+ OPCODE(o80_cursorCommand),
/* 6C */
OPCODE(o6_breakHere),
OPCODE(o6_ifClassOfIs),
@@ -423,7 +423,7 @@
case 10:
{
int flags = pop();
- pop();
+ int state = pop();
int y1 = pop();
int x1 = pop();
int resnum = pop();
@@ -436,7 +436,7 @@
pwi->flags = flags;
++_wizImagesNum;
} else {
- drawWizImage(rtImage, resnum, x1, y1, flags);
+ drawWizImage(rtImage, resnum, state, x1, y1, flags);
}
}
break;
More information about the Scummvm-git-logs
mailing list