aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Hamm2007-10-28 13:21:01 +0000
committerVincent Hamm2007-10-28 13:21:01 +0000
commit7860b90051bfb034874d5b5a3d574d718f89bc03 (patch)
tree96d2dad6627007cb0d902b56b9e471a4810eefcc
parentc664dbcca81291443a46a4a0cefbfa2fdc714866 (diff)
downloadscummvm-rg350-7860b90051bfb034874d5b5a3d574d718f89bc03.tar.gz
scummvm-rg350-7860b90051bfb034874d5b5a3d574d718f89bc03.tar.bz2
scummvm-rg350-7860b90051bfb034874d5b5a3d574d718f89bc03.zip
Implement cursors
svn-id: r29286
-rw-r--r--engines/cruise/cruise.cpp1
-rw-r--r--engines/cruise/cruise_main.cpp16
-rw-r--r--engines/cruise/cruise_main.h2
-rw-r--r--engines/cruise/function.cpp6
-rw-r--r--engines/cruise/mouse.cpp156
-rw-r--r--engines/cruise/mouse.h21
-rw-r--r--engines/cruise/saveload.cpp2
-rw-r--r--engines/cruise/vars.cpp2
-rw-r--r--engines/cruise/vars.h2
-rw-r--r--engines/cruise/volume.cpp2
10 files changed, 164 insertions, 46 deletions
diff --git a/engines/cruise/cruise.cpp b/engines/cruise/cruise.cpp
index 2ea94e79eb..3e7f42c3e4 100644
--- a/engines/cruise/cruise.cpp
+++ b/engines/cruise/cruise.cpp
@@ -92,6 +92,7 @@ int CruiseEngine::init() {
}
int CruiseEngine::go() {
+ Cruise::changeCursor(Cruise::CURSOR_NORMAL);
CursorMan.showMouse(true);
Cruise::mainLoop();
diff --git a/engines/cruise/cruise_main.cpp b/engines/cruise/cruise_main.cpp
index 09a6cd4732..2b1e74a369 100644
--- a/engines/cruise/cruise_main.cpp
+++ b/engines/cruise/cruise_main.cpp
@@ -71,12 +71,10 @@ void drawInfoStringSmallBlackBox(uint8 *string) {
}
void loadPakedFileToMem(int fileIdx, uint8 *buffer) {
- //changeCursor(1);
+ changeCursor(CURSOR_DISK);
- currentVolumeFile.seek(volumePtrToFileDescriptor[fileIdx].offset,
- SEEK_SET);
- currentVolumeFile.read(buffer,
- volumePtrToFileDescriptor[fileIdx].size);
+ currentVolumeFile.seek(volumePtrToFileDescriptor[fileIdx].offset, SEEK_SET);
+ currentVolumeFile.read(buffer, volumePtrToFileDescriptor[fileIdx].size);
}
int loadScriptSub1(int scriptIdx, int param) {
@@ -1078,7 +1076,7 @@ int processInput(void)
// test both buttons
if (((button & 3) == 3) || keyboardVar == 0x44 || keyboardVar == 0x53)
{
- changeCursor(0);
+ changeCursor(CURSOR_NORMAL);
keyboardVar = 0;
return (playerMenu(mouseX, mouseY));
}
@@ -1457,7 +1455,7 @@ void mainLoop(void) {
* }
* else */
{
- changeCursor(0);
+ changeCursor(CURSOR_NORMAL);
}
if (main7) {
@@ -1534,10 +1532,6 @@ int oldmain(int argc, char *argv[]) {
return (0);
}
-void changeCursor(uint16 cursorType) {
- //printf("changeCursor %d\n", cursorType);
-}
-
void *mallocAndZero(int32 size) {
void *ptr;
diff --git a/engines/cruise/cruise_main.h b/engines/cruise/cruise_main.h
index b5603ab740..8a126e0250 100644
--- a/engines/cruise/cruise_main.h
+++ b/engines/cruise/cruise_main.h
@@ -90,13 +90,13 @@ int32 prepareWordRender(int32 param, int32 var1, int16 * out2, uint8 * ptr3,
const uint8 * string);
void removeExtention(const char *name, char *buffer);
void resetRaster(uint8 * rasterPtr, int32 rasterSize);
-void changeCursor(uint16 cursorType);
void resetPtr2(scriptInstanceStruct * ptr);
void getFileExtention(const char *name, char *buffer);
void *allocAndZero(int size);
void freeStuff2(void);
char *getObjectName(int index, uint8 * string);
void mainLoop(void);
+void getMouseStatus(int16 *pMouseVar, int16 *pMouseX, int16 *pMouseButton, int16 *pMouseY);
} // End of namespace Cruise
diff --git a/engines/cruise/function.cpp b/engines/cruise/function.cpp
index 2614d30172..35c6e46737 100644
--- a/engines/cruise/function.cpp
+++ b/engines/cruise/function.cpp
@@ -436,7 +436,7 @@ int16 Op_LoadBackground(void) {
result = loadBackground((char *)bgName, bgIdx);
}
- changeCursor(0);
+ changeCursor(CURSOR_NORMAL);
return result;
}
@@ -485,7 +485,7 @@ int16 Op_loadFile(void) {
saveVar6[0] = 0;
}
- changeCursor(0);
+ changeCursor(CURSOR_NORMAL);
return 0;
}
@@ -512,7 +512,7 @@ int16 Op_LoadAbs(void) {
result = loadFullBundle(name, param1);
}
- changeCursor(0);
+ changeCursor(CURSOR_NORMAL);
return result;
}
diff --git a/engines/cruise/mouse.cpp b/engines/cruise/mouse.cpp
index 0dcd41fa9d..19d771229e 100644
--- a/engines/cruise/mouse.cpp
+++ b/engines/cruise/mouse.cpp
@@ -24,30 +24,144 @@
*/
#include "cruise/cruise_main.h"
+#include "graphics/cursorman.h"
namespace Cruise {
int16 main10;
-#if 0
-void getMouseStatus(int16 *pMouseVar, int16 *pMouseX, int16 *pMouseButton,
- int16 *pMouseY) {
- // mouseStatusStruct localStatus;
-
- // OSystem_GetMouseStatus(&localStatus);
-
- *pMouseX = 0;
- *pMouseY = 0;
-
- *pMouseButton = 0;
-/*
- if (localStatus.left)
- *pMouseButton |= 1;
- if (localStatus.right)
- *pMouseButton |= 2;
- if (localStatus.middle)
- *pMouseButton |= 4;
- */
-}
-#endif
+
+ static const byte mouseCursorNormal[] = {
+ 0x00, 0x00, 0x40, 0x00, 0x60, 0x00, 0x70, 0x00,
+ 0x78, 0x00, 0x7C, 0x00, 0x7E, 0x00, 0x7F, 0x00,
+ 0x7F, 0x80, 0x7C, 0x00, 0x6C, 0x00, 0x46, 0x00,
+ 0x06, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00,
+
+ 0xC0, 0x00, 0xE0, 0x00, 0xF0, 0x00, 0xF8, 0x00,
+ 0xFC, 0x00, 0xFE, 0x00, 0xFF, 0x00, 0xFF, 0x80,
+ 0xFF, 0xC0, 0xFF, 0xC0, 0xFE, 0x00, 0xFF, 0x00,
+ 0xCF, 0x00, 0x07, 0x80, 0x07, 0x80, 0x03, 0x80
+ };
+
+ static const byte mouseCursorDisk[] = {
+ 0x7F, 0xFC, 0x9F, 0x12, 0x9F, 0x12, 0x9F, 0x12,
+ 0x9F, 0x12, 0x9F, 0xE2, 0x80, 0x02, 0x9F, 0xF2,
+ 0xA0, 0x0A, 0xA0, 0x0A, 0xA0, 0x0A, 0xA0, 0x0A,
+ 0xA0, 0x0A, 0xA0, 0x0A, 0x7F, 0xFC, 0x00, 0x00,
+
+ 0x7F, 0xFC, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE,
+ 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE,
+ 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE,
+ 0xFF, 0xFE, 0xFF, 0xFE, 0x7F, 0xFC, 0x00, 0x00
+ };
+
+ static const byte mouseCursorCross[] = {
+ 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00,
+ 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x7C, 0x7C,
+ 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00,
+ 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
+
+ 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80,
+ 0x03, 0x80, 0x03, 0x80, 0xFF, 0xFE, 0xFE, 0xFE,
+ 0xFF, 0xFE, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80,
+ 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x00, 0x00
+ };
+
+ static const byte mouseCursorNoMouse[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+ };
+
+ static const byte mouseCursorWalk[] = {
+ 0x03, 0xC0, 0x03, 0xC0, 0x03, 0xC0, 0x01, 0xE0,
+ 0x3F, 0xF0, 0x03, 0x38, 0x1B, 0xDC, 0x1B, 0xCC,
+ 0x03, 0xCC, 0x03, 0x80, 0x07, 0x00, 0x0E, 0xC0,
+ 0x1C, 0xE0, 0x18, 0x70, 0x18, 0x38, 0x18, 0x18,
+
+ 0x07, 0xE0, 0x07, 0xE0, 0x07, 0xE0, 0x03, 0xF0,
+ 0x07, 0xF8, 0x07, 0xFC, 0x3F, 0xFE, 0x3F, 0xFE,
+ 0x07, 0xFE, 0x07, 0xC0, 0x0F, 0x80, 0x1F, 0xE0,
+ 0x3F, 0xF0, 0x3C, 0xF8, 0x3C, 0x7C, 0x3C, 0x3C
+ };
+
+ static const byte mouseCursorExit[] = {
+ 0x7f, 0xf8, 0x60, 0x18, 0x60, 0x18, 0x60, 0x18,
+ 0x60, 0x00, 0x60, 0x08, 0x60, 0x0c, 0x60, 0xfe,
+ 0x60, 0xfe, 0x60, 0x0c, 0x60, 0x08, 0x60, 0x00,
+ 0x60, 0x18, 0x60, 0x18, 0x60, 0x18, 0x7f, 0xf8,
+
+ 0xff, 0xfc, 0xf0, 0x3c, 0xf0, 0x3c, 0xf0, 0x3c,
+ 0xf0, 0x00, 0xf0, 0x1c, 0xf0, 0x1e, 0xf1, 0xff,
+ 0xf1, 0xff, 0xf0, 0x1e, 0xf0, 0x1c, 0xf0, 0x00,
+ 0xf0, 0x3c, 0xf0, 0x3c, 0xf0, 0x3c, 0xff, 0xfc
+ };
+
+ static const byte mouseCursorMagnifyingGlass[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x03, 0xfe, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x00, 0x22, 0x00, 0x02,
+ 0x07, 0x82, 0x03, 0x82, 0x07, 0x9e, 0xfe, 0x80,
+ 0xfc, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00,
+
+ 0x00, 0x00, 0x07, 0xff, 0x07, 0xff, 0x06, 0x03,
+ 0x06, 0x03, 0x06, 0x03, 0x00, 0x23, 0x0f, 0xc3,
+ 0x0f, 0xc3, 0x07, 0xc3, 0xff, 0xdf, 0xff, 0xdf,
+ 0xfe, 0xc0, 0xfc, 0x00, 0xf8, 0x00, 0x00, 0x00
+ };
+
+ struct MouseCursor {
+ int hotspotX;
+ int hotspotY;
+ const byte *bitmap;
+ };
+
+ static const MouseCursor mouseCursors[] = {
+ { 1, 1, mouseCursorNormal },
+ { 0, 0, mouseCursorDisk },
+ { 7, 7, mouseCursorCross },
+ { 0, 0, mouseCursorNoMouse },
+ { 10, 6, mouseCursorWalk },
+ { 10, 6, mouseCursorExit },
+ { 10, 6, mouseCursorMagnifyingGlass }
+ };
+
+ CursorType currentCursor = CURSOR_NOMOUSE;
+
+ static const byte cursorPalette[] = {
+ 0, 0, 0, 0xff,
+ 0xff, 0xff, 0xff, 0xff
+ };
+
+ void changeCursor(CursorType eType)
+ {
+ assert(eType >= 0 && eType < CURSOR_MAX);
+ if (currentCursor != eType) {
+ byte mouseCursor[16 * 16];
+ const MouseCursor *mc = &mouseCursors[eType];
+ const byte *src = mc->bitmap;
+ for (int i = 0; i < 32; ++i) {
+ int offs = i * 8;
+ for (byte mask = 0x80; mask != 0; mask >>= 1) {
+ if (src[0] & mask) {
+ mouseCursor[offs] = 1;
+ } else if (src[32] & mask) {
+ mouseCursor[offs] = 0;
+ } else {
+ mouseCursor[offs] = 0xFF;
+ }
+ ++offs;
+ }
+ ++src;
+ }
+ CursorMan.replaceCursor(mouseCursor, 16, 16, mc->hotspotX, mc->hotspotY);
+ CursorMan.replaceCursorPalette(cursorPalette, 0, 2);
+ currentCursor = eType;
+ }
+ }
} // End of namespace Cruise
diff --git a/engines/cruise/mouse.h b/engines/cruise/mouse.h
index a6911ce27e..7f0680acbb 100644
--- a/engines/cruise/mouse.h
+++ b/engines/cruise/mouse.h
@@ -28,10 +28,23 @@
namespace Cruise {
-extern int16 main10;
-
-void getMouseStatus(int16 * pMouseVar, int16 * pMouseX, int16 * pMouseButton,
- int16 * pMouseY);
+ extern int16 main10;
+
+ enum CursorType
+ {
+ CURSOR_NORMAL = 0,
+ CURSOR_DISK = 1,
+ CURSOR_CROSS = 2,
+ CURSOR_NOMOUSE = 3,
+ CURSOR_WALK = 4,
+ CURSOR_EXIT = 5,
+ CURSOR_MAGNIFYING_GLASS = 6,
+
+ CURSOR_MAX = 7,
+ };
+
+ void changeCursor(CursorType eType);
+ extern CursorType currentCursor;
} // End of namespace Cruise
diff --git a/engines/cruise/saveload.cpp b/engines/cruise/saveload.cpp
index b0ebc58453..d25bda5735 100644
--- a/engines/cruise/saveload.cpp
+++ b/engines/cruise/saveload.cpp
@@ -404,7 +404,7 @@ int loadSavegameData(int saveGameIdx) {
// to finish
- changeCursor(0);
+ changeCursor(CURSOR_NORMAL);
mainDraw(1);
flipScreen();
diff --git a/engines/cruise/vars.cpp b/engines/cruise/vars.cpp
index bdd46da022..b2029caab7 100644
--- a/engines/cruise/vars.cpp
+++ b/engines/cruise/vars.cpp
@@ -71,8 +71,6 @@ Common::File *_currentVolumeFile;
Common::File currentVolumeFile;
#endif
-int16 currentCursor;
-
int16 volumeNumEntry;
fileEntry *volumePtrToFileDescriptor = NULL;
diff --git a/engines/cruise/vars.h b/engines/cruise/vars.h
index 1d747d94b8..bb0f488e59 100644
--- a/engines/cruise/vars.h
+++ b/engines/cruise/vars.h
@@ -174,8 +174,6 @@ extern Common::File *_currentVolumeFile;
extern Common::File currentVolumeFile;
#endif
-extern int16 currentCursor;
-
extern int16 volumeNumEntry;
extern fileEntry *volumePtrToFileDescriptor;
diff --git a/engines/cruise/volume.cpp b/engines/cruise/volume.cpp
index 5170a945fe..7d2b34e71c 100644
--- a/engines/cruise/volume.cpp
+++ b/engines/cruise/volume.cpp
@@ -77,7 +77,7 @@ int getVolumeDataEntry(volumeDataStruct *entry) {
return (-14);
}
- changeCursor(1);
+ changeCursor(CURSOR_DISK);
currentVolumeFile.read(&volumeNumberOfEntry, 2);
currentVolumeFile.read(&volumeSizeOfEntry, 2);