[Scummvm-cvs-logs] CVS: scummvm/scumm cursor.cpp,2.14,2.15 scumm.h,1.482,1.483 intern.h,2.257,2.258 scumm.cpp,1.210,1.211 resource_v7he.cpp,1.8,1.9 resource_v7he.h,1.6,1.7
Max Horn
fingolfin at users.sourceforge.net
Sat Sep 18 13:30:01 CEST 2004
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/scumm/smush smush_player.cpp,1.130,1.131 smush_player.h,1.32,1.33
- Next message: [Scummvm-cvs-logs] CVS: scummvm/scumm string.cpp,1.251,1.252 scumm.h,1.483,1.484 script_v5.cpp,1.261,1.262 script_v6.cpp,1.402,1.403 script_v6he.cpp,2.118,2.119 script_v72he.cpp,2.104,2.105 script_v8.cpp,2.271,2.272
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10292
Modified Files:
cursor.cpp scumm.h intern.h scumm.cpp resource_v7he.cpp
resource_v7he.h
Log Message:
Moved mouse cursor code into ScummEngine subclasses were possible -- this makes it much easier to see which cursor code is used in which SCUMM version; also changed cursor code to not overwrite default_cursor_* (which would cause problems when switching to another game)
Index: cursor.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/cursor.cpp,v
retrieving revision 2.14
retrieving revision 2.15
diff -u -d -r2.14 -r2.15
--- cursor.cpp 24 Aug 2004 06:36:12 -0000 2.14
+++ cursor.cpp 18 Sep 2004 20:29:13 -0000 2.15
@@ -41,8 +41,7 @@
};
-
-static uint16 default_cursor_images[5][16] = {
+static const uint16 default_cursor_images[5][16] = {
/* cross-hair */
{ 0x0080, 0x0080, 0x0080, 0x0080, 0x0080, 0x0080, 0x0000, 0x7e3f,
0x0000, 0x0080, 0x0080, 0x0080, 0x0080, 0x0080, 0x0080, 0x0000 },
@@ -64,16 +63,26 @@
0x1004, 0x2002, 0x0000, 0x0080, 0x01c0, 0x02a0, 0x0080, 0x0000 },
};
-static byte default_cursor_hotspots[10] = {
+static const byte default_cursor_hotspots[10] = {
8, 7, 8, 7, 1, 1, 5, 0,
8, 7, //zak256
};
+ScummEngine_v5::ScummEngine_v5(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs, uint8 md5sum[16])
+ : ScummEngine(detector, syst, gs, md5sum) {
+
+ for (int i = 0; i < 4; i++) {
+ memcpy(_cursorImages[i], default_cursor_images[i], 32);
+ }
+ memcpy(_cursorHotspots, default_cursor_hotspots, 8);
+}
+
+
void ScummEngine::setupCursor() {
_cursor.animate = 1;
}
-void ScummEngine::animateCursor() {
+void ScummEngine_v5::animateCursor() {
if (_cursor.animate) {
if (!(_cursor.animateIndex & 0x1)) {
setBuiltinCursor((_cursor.animateIndex >> 1) & 3);
@@ -82,12 +91,12 @@
}
}
-void ScummEngine::setCursorHotspot(int x, int y) {
+void ScummEngine_v6::setCursorHotspot(int x, int y) {
_cursor.hotspotX = x;
_cursor.hotspotY = y;
}
-void ScummEngine::setCursorTransparency(int a) {
+void ScummEngine_v6::setCursorTransparency(int a) {
int i, size;
size = _cursor.width * _cursor.height;
@@ -104,7 +113,7 @@
_cursor.hotspotX, _cursor.hotspotY);
}
-void ScummEngine::grabCursor(int x, int y, int w, int h) {
+void ScummEngine_v6::grabCursor(int x, int y, int w, int h) {
VirtScreen *vs = findVirtScreen(y);
if (vs == NULL) {
@@ -253,7 +262,7 @@
updateCursor();
}
-void ScummEngine::redefineBuiltinCursorFromChar(int index, int chr) {
+void ScummEngine_v5::redefineBuiltinCursorFromChar(int index, int chr) {
// Cursor image in both Looms are based on images from charset.
if (_gameId != GID_LOOM && _gameId != GID_LOOM256) {
// FIXME: Actually: is this opcode ever called by a non-Loom game?
@@ -261,7 +270,7 @@
warning("V3--V5 SO_CURSOR_IMAGE(%d,%d) called - tell Fingolfin where you saw this!", index, chr);
}
- assert(index >= 0 && index < 5);
+ assert(index >= 0 && index < 4);
// const int oldID = _charset->getCurID();
@@ -283,7 +292,7 @@
_charset->drawChar(chr, s, 0, 0);
- uint16 *ptr = default_cursor_images[index];
+ uint16 *ptr = _cursorImages[index];
memset(ptr, 0, 16 * sizeof(uint16));
for (int h = 0; h < s.h; h++) {
for (int w = 0; w < s.w; w++) {
@@ -296,7 +305,7 @@
// _charset->setCurID(oldID);
}
-void ScummEngine::redefineBuiltinCursorHotspot(int index, int x, int y) {
+void ScummEngine_v5::redefineBuiltinCursorHotspot(int index, int x, int y) {
// Cursor image in both Looms are based on images from charset.
if (_gameId != GID_LOOM && _gameId != GID_LOOM256) {
// FIXME: Actually: is this opcode ever called by a non-Loom game?
@@ -304,13 +313,13 @@
warning("V3--V5 SO_CURSOR_HOTSPOT(%d,%d,%d) called - tell Fingolfin where you saw this!", index, x, y);
}
- assert(index >= 0 && index < 5);
+ assert(index >= 0 && index < 4);
- default_cursor_hotspots[index * 2] = x;
- default_cursor_hotspots[index * 2 + 1] = y;
+ _cursorHotspots[index * 2] = x;
+ _cursorHotspots[index * 2 + 1] = y;
}
-void ScummEngine::setBuiltinCursor(int idx) {
+void ScummEngine_v5::setBuiltinCursor(int idx) {
int i, j;
byte color;
@@ -367,21 +376,26 @@
*(hotspot + (_cursor.width * 5) - 1) = color;
*(hotspot + (_cursor.width * 5) + 1) = color;
} else {
- byte currentCursor = _currentCursor;
+ const uint16 *src;
+
+ _cursor.hotspotX = _cursorHotspots[2 * _currentCursor];
+ _cursor.hotspotY = _cursorHotspots[2 * _currentCursor + 1];
+ src = _cursorImages[_currentCursor];
#ifdef __PALM_OS__
- if (_gameId == GID_ZAK256 && currentCursor == 0)
- currentCursor = 4;
+ if (_gameId == GID_ZAK256 && _currentCursor == 0) {
+ _cursor.hotspotX = default_cursor_hotspots[2 * 4];
+ _cursor.hotspotY = default_cursor_hotspots[2 * 4 + 1];
+ src = default_cursor_images[4];
+ }
#endif
_cursor.width = 16;
_cursor.height = 16;
- _cursor.hotspotX = default_cursor_hotspots[2 * currentCursor];
- _cursor.hotspotY = default_cursor_hotspots[2 * currentCursor + 1];
for (i = 0; i < 16; i++) {
for (j = 0; j < 16; j++) {
- if (default_cursor_images[currentCursor][i] & (1 << j))
+ if (src[i] & (1 << j))
_grabbedCursor[16 * i + 15 - j] = color;
}
}
Index: scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.h,v
retrieving revision 1.482
retrieving revision 1.483
diff -u -d -r1.482 -r1.483
--- scumm.h 18 Sep 2004 00:36:17 -0000 1.482
+++ scumm.h 18 Sep 2004 20:29:13 -0000 1.483
@@ -52,7 +52,6 @@
class ScummDebugger;
class Serializer;
class Sound;
-class Win32ResExtractor;
struct Box;
struct BoxCoords;
@@ -344,7 +343,6 @@
friend class SmushPlayer;
friend class Insane;
friend class CharsetRenderer;
- friend class Win32ResExtractor;
void errorString(const char *buf_input, char *buf_output);
public:
@@ -419,7 +417,7 @@
// Cursor/palette
void updateCursor();
- void animateCursor();
+ virtual void animateCursor() {}
void updatePalette();
/**
@@ -992,14 +990,8 @@
void darkenPalette(int redScale, int greenScale, int blueScale, int startColor, int endColor);
void desaturatePalette(int hueScale, int satScale, int lightScale, int startColor, int endColor);
- void setCursorHotspot(int x, int y);
- void setCursorTransparency(int a);
void setupCursor();
- void setBuiltinCursor(int index);
- void redefineBuiltinCursorFromChar(int index, int chr);
- void redefineBuiltinCursorHotspot(int index, int x, int y);
- void grabCursor(int x, int y, int w, int h);
void setCursorFromBuffer(byte *ptr, int width, int height, int pitch);
public:
Index: intern.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/intern.h,v
retrieving revision 2.257
retrieving revision 2.258
diff -u -d -r2.257 -r2.258
--- intern.h 18 Sep 2004 04:12:14 -0000 2.257
+++ intern.h 18 Sep 2004 20:29:13 -0000 2.258
@@ -40,10 +40,12 @@
};
const OpcodeEntryV5 *_opcodesV5;
+
+ uint16 _cursorImages[4][16];
+ byte _cursorHotspots[2 * 4];
public:
- ScummEngine_v5(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs, uint8 md5sum[16]) :
-ScummEngine(detector, syst, gs, md5sum) {}
+ ScummEngine_v5(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs, uint8 md5sum[16]);
protected:
virtual void setupOpcodes();
@@ -61,6 +63,12 @@
virtual int getVarOrDirectByte(byte mask);
virtual int getVarOrDirectWord(byte mask);
+ virtual void animateCursor();
+
+ void setBuiltinCursor(int index);
+ void redefineBuiltinCursorFromChar(int index, int chr);
+ void redefineBuiltinCursorHotspot(int index, int x, int y);
+
/* Version 5 script opcodes */
void o5_actorFollowCamera();
void o5_actorFromPos();
@@ -170,9 +178,6 @@
void o5_walkActorToObject();
};
-// FIXME - maybe we should move the opcodes from v5 to v3, and change the inheritance
-// accordingly - that would be more logical I guess. However, if you do so, take care
-// of preserving the right readIndexFile / loadCharset !!!
class ScummEngine_v3 : public ScummEngine_v5 {
public:
ScummEngine_v3(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs, uint8 md5sum[16]) : ScummEngine_v5(detector, syst, gs, md5sum) {}
@@ -356,9 +361,13 @@
void writeArray(int array, int index, int base, int value);
void shuffleArray(int num, int minIdx, int maxIdx);
+ void setCursorTransparency(int a);
+ void setCursorHotspot(int x, int y);
+
void setCursorFromImg(uint img, uint room, uint imgindex);
void useIm01Cursor(const byte *im, int w, int h);
void useBompCursor(const byte *im, int w, int h);
+ void grabCursor(int x, int y, int w, int h);
/* Version 6 script opcodes */
void o6_setBlastObjectWindow();
@@ -578,6 +587,7 @@
void swapObjects(int object1, int object2);
/* HE version 60 script opcodes */
+ // TODO: Rename all these methods to use prefix "o6he_" instead of "o6_"
void o6_setState();
void o6_roomOps();
void o6_actorOps();
@@ -598,6 +608,8 @@
};
class ScummEngine_v7he : public ScummEngine_v6he {
+ friend class Win32ResExtractor;
+
protected:
typedef void (ScummEngine_v7he::*OpcodeProcV7he)();
struct OpcodeEntryV7he {
@@ -625,6 +637,7 @@
int polygonHit(int id, int x, int y);
/* HE version 70 script opcodes */
+ // TODO: Rename all these methods to use prefix "o70he_" instead of "o7_"
void o7_cursorCommand();
void o7_startSound();
void o7_pickupObject();
Index: scumm.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.cpp,v
retrieving revision 1.210
retrieving revision 1.211
diff -u -d -r1.210 -r1.211
--- scumm.cpp 18 Sep 2004 05:00:38 -0000 1.210
+++ scumm.cpp 18 Sep 2004 20:29:13 -0000 1.211
@@ -1346,12 +1346,6 @@
_flashlight.buffer = NULL;
}
- // HACK cursor hotspot is wrong
- // Original games used
- // setCursorHotspot(8, 7);
- if (_gameId == GID_FUNPACK)
- setCursorHotspot(16, 16);
-
_mouse.x = 104;
_mouse.y = 56;
@@ -1422,6 +1416,12 @@
setCursorFromImg(697, 60, 1);
setCursorTransparency(1);
}
+
+ // HACK cursor hotspot is wrong
+ // Original games used
+ // setCursorHotspot(8, 7);
+ if (_gameId == GID_FUNPACK)
+ setCursorHotspot(16, 16);
}
void ScummEngine::initScummVars() {
@@ -2332,8 +2332,8 @@
for (int y = 0; y < vs->h; y++) {
memcpy(dst, src, vs->w);
- src += vs->w;
- dst += vs->pitch;
+ src += vs->pitch;
+ dst += vs->w;
}
}
Index: resource_v7he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/resource_v7he.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- resource_v7he.cpp 12 Sep 2004 18:21:20 -0000 1.8
+++ resource_v7he.cpp 18 Sep 2004 20:29:13 -0000 1.9
@@ -47,7 +47,7 @@
};
#define RES_TYPE_COUNT (sizeof(res_types)/sizeof(char *))
-Win32ResExtractor::Win32ResExtractor(ScummEngine *scumm) {
+Win32ResExtractor::Win32ResExtractor(ScummEngine_v7he *scumm) {
_vm = scumm;
snprintf(_fileName, 256, "%s.he3", _vm->getGameName());
Index: resource_v7he.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/resource_v7he.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- resource_v7he.h 27 Jun 2004 13:15:23 -0000 1.6
+++ resource_v7he.h 18 Sep 2004 20:29:13 -0000 1.7
@@ -116,7 +116,7 @@
class Win32ResExtractor {
public:
- Win32ResExtractor(ScummEngine *scumm);
+ Win32ResExtractor(ScummEngine_v7he *scumm);
~Win32ResExtractor();
int extractResource(const char *resType, char *resName, byte **data);
void setCursor(int id);
@@ -125,7 +125,7 @@
private:
bool _arg_raw;
- ScummEngine *_vm;
+ ScummEngine_v7he *_vm;
char _fileName[256];
typedef Common::MemoryReadStream MemoryReadStream;
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/scumm/smush smush_player.cpp,1.130,1.131 smush_player.h,1.32,1.33
- Next message: [Scummvm-cvs-logs] CVS: scummvm/scumm string.cpp,1.251,1.252 scumm.h,1.483,1.484 script_v5.cpp,1.261,1.262 script_v6.cpp,1.402,1.403 script_v6he.cpp,2.118,2.119 script_v72he.cpp,2.104,2.105 script_v8.cpp,2.271,2.272
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Scummvm-git-logs
mailing list