aboutsummaryrefslogtreecommitdiff
path: root/engines/tony
diff options
context:
space:
mode:
Diffstat (limited to 'engines/tony')
-rw-r--r--engines/tony/game.cpp16
-rw-r--r--engines/tony/game.h7
-rw-r--r--engines/tony/gfxcore.cpp35
-rw-r--r--engines/tony/gfxcore.h5
-rw-r--r--engines/tony/gfxengine.h3
-rw-r--r--engines/tony/window.cpp39
-rw-r--r--engines/tony/window.h2
7 files changed, 71 insertions, 36 deletions
diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp
index 4e9e2abc38..abc7f1a2e0 100644
--- a/engines/tony/game.cpp
+++ b/engines/tony/game.cpp
@@ -1596,8 +1596,22 @@ void RMPointer::updateCursor() {
draw(Common::nullContext, buf, &prim);
+ // Get a pointer to the cursor data
+ byte *cursorData = buf;
+
+ // If in black & white mode, convert the cursor
+ if (GLOBALS._bCfgAnni30) {
+ uint16 *src = (uint16 *)cursorData;
+ for (int i = 0; i < 64; i++) {
+ uint16 *lineP = src;
+ for (int j = 0; j < 64; j++, lineP) {
+ lineP[j] = RMGfxTargetBuffer::_precalcTable[lineP[j] & 0x7FFF];
+ }
+ src += 64;
+ }
+ }
+
// Get the raw pixel data and set the cursor to it
- const byte *cursorData = buf;
Graphics::PixelFormat pixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0);
CursorMan.replaceCursor(cursorData, 64, 64, _cursorHotspot._x, _cursorHotspot._y, 0, 1, &pixelFormat);
}
diff --git a/engines/tony/game.h b/engines/tony/game.h
index d8aceefc12..9804ac87fe 100644
--- a/engines/tony/game.h
+++ b/engines/tony/game.h
@@ -67,8 +67,6 @@ private:
RMGfxSourceBuffer8 *_nCurCustomPointer;
- void updateCursor();
-
public:
enum PointerType {
PTR_NONE = 0,
@@ -148,6 +146,11 @@ public:
int curAction();
/**
+ * Update the cursor
+ */
+ void updateCursor();
+
+ /**
* Show the cursor
*/
void showCursor();
diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp
index d91f5bab4e..119b730303 100644
--- a/engines/tony/gfxcore.cpp
+++ b/engines/tony/gfxcore.cpp
@@ -433,6 +433,41 @@ void RMGfxTargetBuffer::mergeDirtyRects() {
}
}
+uint16 *RMGfxTargetBuffer::_precalcTable = NULL;
+
+/**
+ * Set up the black & white precalculated mapping table. This is only
+ * called if the user selects the black & white option.
+ */
+void RMGfxTargetBuffer::createBWPrecalcTable() {
+ _precalcTable = new uint16[0x8000];
+
+ for (int i = 0; i < 0x8000; i++) {
+ int r = (i >> 10) & 0x1F;
+ int g = (i >> 5) & 0x1F;
+ int b = i & 0x1F;
+
+ int min = MIN(r, MIN(g, b));
+ int max = MAX(r, MAX(g, b));
+
+ min = (min + max) / 2;
+
+ r = CLIP(min + 8 - 8, 0, 31);
+ g = CLIP(min + 5 - 8, 0, 31);
+ b = CLIP(min + 0 - 8, 0, 31);
+
+ _precalcTable[i] = (r << 10) | (g << 5) | b;
+ }
+}
+
+/**
+ * Frees the black & white precalculated mapping table.
+ */
+void RMGfxTargetBuffer::freeBWPrecalcTable() {
+ delete[] _precalcTable;
+ _precalcTable = NULL;
+}
+
/****************************************************************************\
* RMGfxSourceBufferPal Methods
\****************************************************************************/
diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h
index 32e3c96881..78c4c9bc70 100644
--- a/engines/tony/gfxcore.h
+++ b/engines/tony/gfxcore.h
@@ -562,6 +562,7 @@ private:
Common::List<Common::Rect> _currentDirtyRects, _previousDirtyRects, _dirtyRects;
void mergeDirtyRects();
+
private:
// OSystem::MutexRef csModifyingOT;
@@ -573,6 +574,10 @@ public:
RMGfxTargetBuffer();
virtual ~RMGfxTargetBuffer();
+ static uint16 *_precalcTable;
+ static void createBWPrecalcTable();
+ static void freeBWPrecalcTable();
+
// management of the OT list
void clearOT();
void drawOT(CORO_PARAM);
diff --git a/engines/tony/gfxengine.h b/engines/tony/gfxengine.h
index 2c48612c4d..a69182d032 100644
--- a/engines/tony/gfxengine.h
+++ b/engines/tony/gfxengine.h
@@ -115,6 +115,9 @@ public:
RMInput &getInput() {
return _input;
}
+ RMPointer &getPointer() {
+ return _point;
+ }
// Link to the custom function list
void initCustomDll();
diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp
index 5c08ab1eec..c509a12f9e 100644
--- a/engines/tony/window.cpp
+++ b/engines/tony/window.cpp
@@ -47,6 +47,7 @@ RMWindow::RMWindow() {
RMWindow::~RMWindow() {
close();
RMText::unload();
+ RMGfxTargetBuffer::freeBWPrecalcTable();
}
/**
@@ -63,50 +64,28 @@ void RMWindow::init() {
_bGrabThumbnail = false;
_bGrabMovie = false;
_wiping = false;
-
- _precalcTable = 0;
-}
-
-void RMWindow::createBWPrecalcTable() {
- _precalcTable = new uint16[0x8000];
-
- for (int i = 0; i < 0x8000; i++) {
- int r = (i >> 10) & 0x1F;
- int g = (i >> 5) & 0x1F;
- int b = i & 0x1F;
-
- int min = MIN(r, MIN(g, b));
- int max = MAX(r, MAX(g, b));
-
- min = (min + max) / 2;
-
- r = CLIP(min + 8 - 8, 0, 31);
- g = CLIP(min + 5 - 8, 0, 31);
- b = CLIP(min + 0 - 8, 0, 31);
-
- _precalcTable[i] = (r << 10) | (g << 5) | b;
- }
}
void RMWindow::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) {
if (GLOBALS._bCfgAnni30) {
- if (!_precalcTable) {
- createBWPrecalcTable();
+ if (!RMGfxTargetBuffer::_precalcTable) {
+ RMGfxTargetBuffer::createBWPrecalcTable();
+ _vm->getEngine()->getPointer().updateCursor();
}
Graphics::Surface *screen = g_system->lockScreen();
const uint16 *src = (const uint16 *)buf;
for (int i = 0; i < h; i++) {
uint16 *dst = (uint16 *)screen->getBasePtr(x, y + i);
for (int j = 0; j < w; j++) {
- dst[j] = _precalcTable[src[j] & 0x7FFF];
+ dst[j] = RMGfxTargetBuffer::_precalcTable[src[j] & 0x7FFF];
}
src += (pitch / 2);
}
g_system->unlockScreen();
} else {
- if (_precalcTable) {
- delete[] _precalcTable;
- _precalcTable = 0;
+ if (RMGfxTargetBuffer::_precalcTable) {
+ RMGfxTargetBuffer::freeBWPrecalcTable();
+ _vm->getEngine()->getPointer().updateCursor();
}
g_system->copyRectToScreen(buf, pitch, x, y, w, h);
}
@@ -116,8 +95,6 @@ void RMWindow::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w,
* Close the window
*/
void RMWindow::close() {
- delete[] _precalcTable;
- _precalcTable = 0;
}
void RMWindow::grabThumbnail(uint16 *thumbmem) {
diff --git a/engines/tony/window.h b/engines/tony/window.h
index c72a3afd8e..6528060f17 100644
--- a/engines/tony/window.h
+++ b/engines/tony/window.h
@@ -70,9 +70,7 @@ protected:
bool _bGrabThumbnail;
bool _bGrabMovie;
uint16 *_wThumbBuf;
- uint16 *_precalcTable;
- void createBWPrecalcTable();
void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h);
void wipeEffect(Common::Rect &rcBoundEllipse);
void getNewFrameWipe(byte *lpBuf, Common::Rect &rcBoundEllipse);