aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/wii
diff options
context:
space:
mode:
authorAndre Heider2009-08-22 08:49:23 +0000
committerAndre Heider2009-08-22 08:49:23 +0000
commit5b2a1a766212d44ef4bc7329bd2e59f9f7f0b5ce (patch)
tree85fc99c6ace171a4057f752c325460f9cfe55e14 /backends/platform/wii
parent66d8adef9f875be8fc82e2fd305cbadc22ed02a6 (diff)
downloadscummvm-rg350-5b2a1a766212d44ef4bc7329bd2e59f9f7f0b5ce.tar.gz
scummvm-rg350-5b2a1a766212d44ef4bc7329bd2e59f9f7f0b5ce.tar.bz2
scummvm-rg350-5b2a1a766212d44ef4bc7329bd2e59f9f7f0b5ce.zip
16bit support for the Wii port
svn-id: r43631
Diffstat (limited to 'backends/platform/wii')
-rw-r--r--backends/platform/wii/osystem.cpp5
-rw-r--r--backends/platform/wii/osystem.h11
-rw-r--r--backends/platform/wii/osystem_gfx.cpp211
3 files changed, 177 insertions, 50 deletions
diff --git a/backends/platform/wii/osystem.cpp b/backends/platform/wii/osystem.cpp
index ae1eb11f4f..3f53605e85 100644
--- a/backends/platform/wii/osystem.cpp
+++ b/backends/platform/wii/osystem.cpp
@@ -52,6 +52,11 @@ OSystem_Wii::OSystem_Wii() :
_currentHeight(0),
_activeGraphicsMode(0),
+#ifdef USE_RGB_COLOR
+ _texturePF(Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0)),
+ _screenPF(Graphics::PixelFormat::createFormatCLUT8()),
+ _cursorPF(Graphics::PixelFormat::createFormatCLUT8()),
+#endif
_fullscreen(false),
diff --git a/backends/platform/wii/osystem.h b/backends/platform/wii/osystem.h
index 2eb53f26a3..72263af5a8 100644
--- a/backends/platform/wii/osystem.h
+++ b/backends/platform/wii/osystem.h
@@ -75,6 +75,11 @@ private:
u16 _currentWidth, _currentHeight;
s32 _activeGraphicsMode;
+#ifdef USE_RGB_COLOR
+ const Graphics::PixelFormat _texturePF;
+ Graphics::PixelFormat _screenPF;
+ Graphics::PixelFormat _cursorPF;
+#endif
bool _fullscreen;
@@ -82,7 +87,7 @@ private:
s32 _mouseX, _mouseY;
u32 _mouseWidth, _mouseHeight;
s32 _mouseHotspotX, _mouseHotspotY;
- u8 _mouseKeyColor;
+ u16 _mouseKeyColor;
u8 *_mouseCursor;
bool _kbd_active;
@@ -119,6 +124,10 @@ public:
virtual const GraphicsMode *getSupportedGraphicsModes() const;
virtual int getDefaultGraphicsMode() const;
virtual bool setGraphicsMode(int mode);
+#ifdef USE_RGB_COLOR
+ virtual Graphics::PixelFormat getScreenFormat() const;
+ virtual Common::List<Graphics::PixelFormat> getSupportedFormats();
+#endif
virtual int getGraphicsMode() const;
virtual void initSize(uint width, uint height,
const Graphics::PixelFormat *format);
diff --git a/backends/platform/wii/osystem_gfx.cpp b/backends/platform/wii/osystem_gfx.cpp
index 9c875eaa85..ed10a407dd 100644
--- a/backends/platform/wii/osystem_gfx.cpp
+++ b/backends/platform/wii/osystem_gfx.cpp
@@ -21,6 +21,8 @@
#include <malloc.h>
+#include "graphics/conversion.h"
+
#include "osystem.h"
#include "gx_supp.h"
@@ -143,22 +145,72 @@ int OSystem_Wii::getGraphicsMode() const {
return _activeGraphicsMode;
}
+#ifdef USE_RGB_COLOR
+Graphics::PixelFormat OSystem_Wii::getScreenFormat() const {
+ return _screenPF;
+}
+
+Common::List<Graphics::PixelFormat> OSystem_Wii::getSupportedFormats() {
+ Common::List<Graphics::PixelFormat> res;
+ res.push_back(_texturePF);
+ res.push_back(Graphics::PixelFormat::createFormatCLUT8());
+
+ return res;
+}
+#endif
+
void OSystem_Wii::initSize(uint width, uint height,
const Graphics::PixelFormat *format) {
- if (_gameWidth != width || _gameHeight != height) {
- printf("initSize %u %u\n", width, height);
+ bool update = false;
+
+#ifdef USE_RGB_COLOR
+ Graphics::PixelFormat newFormat;
+ if (format)
+ newFormat = *format;
+ else
+ newFormat = Graphics::PixelFormat::createFormatCLUT8();
+ if (newFormat.bytesPerPixel > 2)
+ newFormat = Graphics::PixelFormat::createFormatCLUT8();
+
+ if (_screenPF != newFormat) {
+ _screenPF = newFormat;
+ update = true;
+ }
+#endif
+
+ if (_gameWidth != width || _gameHeight != height) {
assert((width <= 640) && (height <= 480));
_gameWidth = width;
_gameHeight = height;
+ update = true;
+ }
+
+ if (update) {
+#ifdef USE_RGB_COLOR
+ printf("initSize %u*%u*%u (%u,%u,%u)\n",
+ _gameWidth, _gameHeight,
+ _screenPF.bytesPerPixel * 8,
+ _screenPF.rShift, _screenPF.gShift, _screenPF.bShift);
+#else
+ printf("initSize %u*%u\n", _gameWidth, _gameHeight);
+#endif
if(_gamePixels)
free(_gamePixels);
+ size_t bufsize;
+
+#ifdef USE_RGB_COLOR
+ _gamePixels = (u8 *) memalign(32, _gameWidth * _gameHeight *
+ _screenPF.bytesPerPixel);
+ memset(_gamePixels, 0, _gameWidth * _gameHeight *
+ _screenPF.bytesPerPixel);
+#else
_gamePixels = (u8 *) memalign(32, _gameWidth * _gameHeight);
memset(_gamePixels, 0, _gameWidth * _gameHeight);
-
+#endif
if (!_overlayVisible) {
_currentWidth = _gameWidth;
_currentHeight = _gameHeight;
@@ -178,6 +230,10 @@ int16 OSystem_Wii::getHeight() {
}
void OSystem_Wii::setPalette(const byte *colors, uint start, uint num) {
+#ifdef USE_RGB_COLOR
+ assert(_screenPF.bytesPerPixel == 1);
+#endif
+
const byte *p = colors;
for (uint i = 0; i < num; ++i) {
_palette[start + i] = Graphics::RGBToColor<Graphics::ColorMasks<565> >(p[0], p[1], p[2]);
@@ -214,37 +270,36 @@ void OSystem_Wii::disableCursorPalette(bool disable) {
void OSystem_Wii::copyRectToScreen(const byte *buf, int pitch, int x, int y,
int w, int h) {
- if (x < 0) {
- w += x;
- buf -= x;
- x = 0;
- }
-
- if (y < 0) {
- h += y;
- buf -= y * pitch;
- y = 0;
- }
-
- if (w > _gameWidth - x)
- w = _gameWidth - x;
-
- if (h > _gameHeight - y)
- h = _gameHeight - y;
-
- if (w <= 0 || h <= 0)
- return;
-
- byte *dst = _gamePixels + y * _gameWidth + x;
- if (_gameWidth == pitch && pitch == w) {
- memcpy(dst, buf, h * w);
+ assert(x >= 0 && x < _gameWidth);
+ assert(y >= 0 && y < _gameHeight);
+ assert(w > 0 && x + w <= _gameWidth);
+ assert(h > 0 && y + h <= _gameHeight);
+
+#ifdef USE_RGB_COLOR
+ if (_screenPF.bytesPerPixel > 1) {
+ if (!Graphics::crossBlit(_gamePixels +
+ y * _gameWidth * _screenPF.bytesPerPixel +
+ x * _screenPF.bytesPerPixel,
+ buf, _gameWidth * _screenPF.bytesPerPixel,
+ pitch, w, h, _texturePF, _screenPF)) {
+ printf("crossBlit failed\n");
+ ::abort();
+ }
} else {
- do {
- memcpy(dst, buf, w);
- buf += pitch;
- dst += _gameWidth;
- } while (--h);
+#endif
+ byte *dst = _gamePixels + y * _gameWidth + x;
+ if (_gameWidth == pitch && pitch == w) {
+ memcpy(dst, buf, h * w);
+ } else {
+ do {
+ memcpy(dst, buf, w);
+ buf += pitch;
+ dst += _gameWidth;
+ } while (--h);
+ }
+#ifdef USE_RGB_COLOR
}
+#endif
}
void OSystem_Wii::updateScreen() {
@@ -252,6 +307,9 @@ void OSystem_Wii::updateScreen() {
static s16 msx, msy, mox, moy, mskip;
static u16 mpx, mpy;
static u8 *s;
+#ifdef USE_RGB_COLOR
+ static u16 *s2;
+#endif
static u16 *d, *p;
u32 now = getMillis();
@@ -268,12 +326,21 @@ void OSystem_Wii::updateScreen() {
if (_overlayVisible) {
memcpy(_texture, _overlayPixels, _overlaySize);
} else {
- for (y = 0; y < _gameHeight; ++y) {
- for (x = 0; x < _gameWidth; ++x)
- _texture[h + x] = _palette[_gamePixels[h + x]];
+#ifdef USE_RGB_COLOR
+ if (_screenPF.bytesPerPixel > 1) {
+ memcpy(_texture, _gamePixels,
+ _gameWidth * _gameHeight * _screenPF.bytesPerPixel);
+ } else {
+#endif
+ for (y = 0; y < _gameHeight; ++y) {
+ for (x = 0; x < _gameWidth; ++x)
+ _texture[h + x] = _palette[_gamePixels[h + x]];
- h += _gameWidth;
+ h += _gameWidth;
+ }
+#ifdef USE_RGB_COLOR
}
+#endif
}
if (_mouseVisible) {
@@ -309,25 +376,51 @@ void OSystem_Wii::updateScreen() {
skip = _currentWidth - mpx;
mskip = _mouseWidth - mpx;
- s = _mouseCursor + moy * _mouseWidth + mox;
- d = _texture + (msy * _currentWidth + msx);
+#ifdef USE_RGB_COLOR
+ if (_cursorPF.bytesPerPixel > 1) {
+ s2 = (u16 *) _mouseCursor + moy * _mouseWidth + mox;
+ d = _texture + (msy * _currentWidth + msx);
- for (y = 0; y < mpy; ++y) {
- for (x = 0; x < mpx; ++x) {
- if (*s == _mouseKeyColor) {
- s++;
- d++;
+ for (y = 0; y < mpy; ++y) {
+ for (x = 0; x < mpx; ++x) {
+ if (*s2 == _mouseKeyColor) {
+ s2++;
+ d++;
- continue;
+ continue;
+ }
+
+ *d++ = *s2;
+ s2++;
}
- *d++ = p[*s];
- s++;
+ d += skip;
+ s2 += mskip;
}
+ } else {
+#endif
+ s = _mouseCursor + moy * _mouseWidth + mox;
+ d = _texture + (msy * _currentWidth + msx);
+
+ for (y = 0; y < mpy; ++y) {
+ for (x = 0; x < mpx; ++x) {
+ if (*s == _mouseKeyColor) {
+ s++;
+ d++;
+
+ continue;
+ }
+
+ *d++ = p[*s];
+ s++;
+ }
- d += skip;
- s += mskip;
+ d += skip;
+ s += mskip;
+ }
+#ifdef USE_RGB_COLOR
}
+#endif
}
GX_Render(_currentWidth, _currentHeight, (u8 *) _texture,
@@ -339,7 +432,11 @@ Graphics::Surface *OSystem_Wii::lockScreen() {
_surface.w = _gameWidth;
_surface.h = _gameHeight;
_surface.pitch = _gameWidth;
+#ifdef USE_RGB_COLOR
+ _surface.bytesPerPixel = _screenPF.bytesPerPixel;
+#else
_surface.bytesPerPixel = 1;
+#endif
return &_surface;
}
@@ -452,16 +549,32 @@ void OSystem_Wii::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX,
const Graphics::PixelFormat *format) {
(void) cursorTargetScale; // TODO
+#ifdef USE_RGB_COLOR
+ if (!format)
+ _cursorPF = Graphics::PixelFormat::createFormatCLUT8();
+ else
+ _cursorPF = *format;
+
+ if (_cursorPF.bytesPerPixel > 1)
+ _mouseKeyColor = keycolor & 0xffff;
+ else
+#endif
+ _mouseKeyColor = keycolor & 0xff;
+
_mouseWidth = w;
_mouseHeight = h;
_mouseHotspotX = hotspotX;
_mouseHotspotY = hotspotY;
- _mouseKeyColor = keycolor & 0xff;
if (_mouseCursor)
free(_mouseCursor);
+#ifdef USE_RGB_COLOR
+ _mouseCursor = (u8 *) memalign(32, w * h * _cursorPF.bytesPerPixel);
+ memcpy(_mouseCursor, buf, w * h * _cursorPF.bytesPerPixel);
+#else
_mouseCursor = (u8 *) memalign(32, w * h);
memcpy(_mouseCursor, buf, w * h);
+#endif
}