aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scumm/cursor.cpp56
-rw-r--r--scumm/intern.h23
-rw-r--r--scumm/resource_v7he.cpp2
-rw-r--r--scumm/resource_v7he.h4
-rw-r--r--scumm/scumm.cpp16
-rw-r--r--scumm/scumm.h10
6 files changed, 65 insertions, 46 deletions
diff --git a/scumm/cursor.cpp b/scumm/cursor.cpp
index 07f39d9dd5..88bc532c63 100644
--- a/scumm/cursor.cpp
+++ b/scumm/cursor.cpp
@@ -41,8 +41,7 @@ static const byte default_cursor_colors[4] = {
};
-
-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 @@ static uint16 default_cursor_images[5][16] = {
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::animateCursor() {
}
}
-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 @@ void ScummEngine::updateCursor() {
_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 @@ void ScummEngine_v6::useBompCursor(const byte *im, int width, int height) {
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 @@ void ScummEngine::redefineBuiltinCursorFromChar(int index, int chr) {
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 @@ void ScummEngine::redefineBuiltinCursorFromChar(int index, int chr) {
_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 @@ void ScummEngine::redefineBuiltinCursorFromChar(int index, int chr) {
// _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 @@ void ScummEngine::redefineBuiltinCursorHotspot(int index, int x, int y) {
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 @@ void ScummEngine::setBuiltinCursor(int idx) {
*(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;
}
}
diff --git a/scumm/intern.h b/scumm/intern.h
index 292ff03fa2..e6757a1030 100644
--- a/scumm/intern.h
+++ b/scumm/intern.h
@@ -40,10 +40,12 @@ protected:
};
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 @@ protected:
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 @@ protected:
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 @@ protected:
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 @@ protected:
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 @@ protected:
};
class ScummEngine_v7he : public ScummEngine_v6he {
+ friend class Win32ResExtractor;
+
protected:
typedef void (ScummEngine_v7he::*OpcodeProcV7he)();
struct OpcodeEntryV7he {
@@ -625,6 +637,7 @@ protected:
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();
diff --git a/scumm/resource_v7he.cpp b/scumm/resource_v7he.cpp
index bf18d82658..456990aae4 100644
--- a/scumm/resource_v7he.cpp
+++ b/scumm/resource_v7he.cpp
@@ -47,7 +47,7 @@ const char *res_types[] = {
};
#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());
diff --git a/scumm/resource_v7he.h b/scumm/resource_v7he.h
index 84129bad10..0496a091ab 100644
--- a/scumm/resource_v7he.h
+++ b/scumm/resource_v7he.h
@@ -116,7 +116,7 @@ namespace Scumm {
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 @@ class Win32ResExtractor {
private:
bool _arg_raw;
- ScummEngine *_vm;
+ ScummEngine_v7he *_vm;
char _fileName[256];
typedef Common::MemoryReadStream MemoryReadStream;
diff --git a/scumm/scumm.cpp b/scumm/scumm.cpp
index 3094a215f4..fdb42985fd 100644
--- a/scumm/scumm.cpp
+++ b/scumm/scumm.cpp
@@ -1346,12 +1346,6 @@ void ScummEngine::scummInit() {
_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 @@ void ScummEngine_v6::scummInit() {
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 @@ void ScummEngine::startScene(int room, Actor *a, int objectNr) {
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;
}
}
diff --git a/scumm/scumm.h b/scumm/scumm.h
index aae2e11def..d151a71a13 100644
--- a/scumm/scumm.h
+++ b/scumm/scumm.h
@@ -52,7 +52,6 @@ class ScummEngine;
class ScummDebugger;
class Serializer;
class Sound;
-class Win32ResExtractor;
struct Box;
struct BoxCoords;
@@ -344,7 +343,6 @@ class ScummEngine : public Engine {
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 @@ public:
// Cursor/palette
void updateCursor();
- void animateCursor();
+ virtual void animateCursor() {}
void updatePalette();
/**
@@ -992,14 +990,8 @@ protected:
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: