aboutsummaryrefslogtreecommitdiff
path: root/sky
diff options
context:
space:
mode:
authorJoost Peters2003-06-05 23:18:10 +0000
committerJoost Peters2003-06-05 23:18:10 +0000
commitba81aa9f769881176bf49cbd68e3813e40804b71 (patch)
treeed7298881890f78dccdb5875fd01566b1c21a2b3 /sky
parent1200d5997ed7b9611c1695ee46c5c828584ef22b (diff)
downloadscummvm-rg350-ba81aa9f769881176bf49cbd68e3813e40804b71.tar.gz
scummvm-rg350-ba81aa9f769881176bf49cbd68e3813e40804b71.tar.bz2
scummvm-rg350-ba81aa9f769881176bf49cbd68e3813e40804b71.zip
proper mouse transparancy fix, should work for all cursors now
svn-id: r8338
Diffstat (limited to 'sky')
-rw-r--r--sky/mouse.cpp26
-rw-r--r--sky/mouse.h2
2 files changed, 18 insertions, 10 deletions
diff --git a/sky/mouse.cpp b/sky/mouse.cpp
index 3be31a37dd..251d3fb44f 100644
--- a/sky/mouse.cpp
+++ b/sky/mouse.cpp
@@ -87,15 +87,16 @@ SkyMouse::SkyMouse(OSystem *system, SkyDisk *skyDisk) {
_maskHeight = 6;
_miceData = _skyDisk->loadFile(MICE_FILE, NULL);
+ fixMouseTransparency(_miceData, _skyDisk->_lastLoadedFileSize);
_mouseData2 = _miceData;
uint16 width = FROM_LE_16(((struct dataFileHeader *)_miceData)->s_width);
uint16 height = FROM_LE_16(((struct dataFileHeader *)_miceData)->s_height);
-
_savedData = (byte *)malloc((width * height) + sizeof(struct dataFileHeader));
//load in the object mouse file
_objectMouseData = _skyDisk->loadFile(MICE_FILE + 1, NULL);
+ fixMouseTransparency(_objectMouseData, _skyDisk->_lastLoadedFileSize);
_mouseWidth = 1;
_mouseHeight = 1;
//_systemFlags |= SF_MOUSE;;
@@ -109,6 +110,7 @@ SkyMouse::~SkyMouse( ){
void SkyMouse::replaceMouseCursors(uint16 fileNo) {
_skyDisk->loadFile(fileNo, _objectMouseData);
+ fixMouseTransparency(_objectMouseData, _skyDisk->_lastLoadedFileSize);
}
bool SkyMouse::fnAddHuman(void) {
@@ -170,13 +172,20 @@ void SkyMouse::drawNewMouse() {
//original sky uses different colors for transparency than our backends do,
//so we simply swap our "transparent"-white with another one.
-void SkyMouse::fixMouseTransparency(byte *mouseData) {
- for (int i = 0; i < (_mouseWidth * _mouseHeight); i++) {
- if (mouseData[i] == 255)
- mouseData[i] = 242;
- else
- if (mouseData[i] == 0)
- mouseData[i] = 255;
+void SkyMouse::fixMouseTransparency(byte *mouseData, uint32 size) {
+ uint32 curPos = sizeof(struct dataFileHeader);
+ uint32 cursorSize = ((struct dataFileHeader *)mouseData)->s_sp_size;
+
+ while (curPos < size) {
+ byte *cursor = mouseData + curPos;
+ for (uint32 i = 0; i < cursorSize; i++) {
+ if (cursor[i] == 255)
+ cursor[i] = 242;
+ else
+ if (cursor[i] == 0)
+ cursor[i] = 255;
+ }
+ curPos += cursorSize;
}
}
@@ -194,7 +203,6 @@ void SkyMouse::spriteMouse(uint16 frameNum, uint8 mouseX, uint8 mouseY) {
//_system->set_mouse_cursor(_mouseData2, _mouseWidth, _mouseHeight, mouseX, mouseY);
// there's something wrong about the mouse's hotspot. using 0/0 works fine.
- fixMouseTransparency(_mouseData2);
_system->set_mouse_cursor(_mouseData2, _mouseWidth, _mouseHeight, 0, 0);
if (frameNum == MOUSE_BLANK) _system->show_mouse(false);
else _system->show_mouse(true);
diff --git a/sky/mouse.h b/sky/mouse.h
index 5de4dc7dab..784b7f2908 100644
--- a/sky/mouse.h
+++ b/sky/mouse.h
@@ -54,7 +54,7 @@ protected:
void pointerEngine(void);
void buttonEngine1(void);
- void fixMouseTransparency(byte *mouseData);
+ void fixMouseTransparency(byte *mouseData, uint32 size);
uint16 _eMouseB;
uint16 _bMouseB;