aboutsummaryrefslogtreecommitdiff
path: root/backends/platform
diff options
context:
space:
mode:
authorFabio Battaglia2010-12-20 21:46:28 +0000
committerFabio Battaglia2010-12-20 21:46:28 +0000
commit5f6dfb2b6797592c965ceaa01eabe8b8a24f5e53 (patch)
tree225dff18f15b323bdd18f8db5c311fcf7f41dd16 /backends/platform
parentb87bc18d223ec42d797b3db0b42fa0c257041716 (diff)
downloadscummvm-rg350-5f6dfb2b6797592c965ceaa01eabe8b8a24f5e53.tar.gz
scummvm-rg350-5f6dfb2b6797592c965ceaa01eabe8b8a24f5e53.tar.bz2
scummvm-rg350-5f6dfb2b6797592c965ceaa01eabe8b8a24f5e53.zip
N64: save and return exact palette for grabPalette
Save the exact palette and return it when grabPalette is called, The less precise 16bit conversion is still used inside though. svn-id: r54981
Diffstat (limited to 'backends/platform')
-rw-r--r--backends/platform/n64/osys_n64.h4
-rw-r--r--backends/platform/n64/osys_n64_base.cpp11
2 files changed, 15 insertions, 0 deletions
diff --git a/backends/platform/n64/osys_n64.h b/backends/platform/n64/osys_n64.h
index 707bb1b7ae..11f71f5783 100644
--- a/backends/platform/n64/osys_n64.h
+++ b/backends/platform/n64/osys_n64.h
@@ -91,6 +91,10 @@ protected:
OverlayColor *_overlayBuffer; // Offscreen for the overlay (16 bit)
uint16 *_screenPalette; // Array for palette entries (256 colors max)
+
+#ifndef N64_EXTREME_MEMORY_SAVING
+ uint32 *_screenExactPalette; // Array for palette entries, as received by setPalette(), no precision loss
+#endif
uint16 _cursorPalette[256]; // Palette entries for the cursor
int _graphicMode; // Graphic mode
diff --git a/backends/platform/n64/osys_n64_base.cpp b/backends/platform/n64/osys_n64_base.cpp
index 8862693138..1b9c704225 100644
--- a/backends/platform/n64/osys_n64_base.cpp
+++ b/backends/platform/n64/osys_n64_base.cpp
@@ -112,6 +112,10 @@ OSystem_N64::OSystem_N64() {
// Clear palette array
_screenPalette = (uint16*)memalign(8, 256 * sizeof(uint16));
+#ifndef N64_EXTREME_MEMORY_SAVING
+ _screenExactPalette = (uint32*)memalign(8, 256 * sizeof(uint32));
+ memset(_screenExactPalette, 0, 256 * sizeof(uint32));
+#endif
memset(_screenPalette, 0, 256 * sizeof(uint16));
memset(_cursorPalette, 0, 256 * sizeof(uint16));
@@ -348,6 +352,9 @@ int16 OSystem_N64::getWidth() {
void OSystem_N64::setPalette(const byte *colors, uint start, uint num) {
for (uint i = 0; i < num; ++i) {
_screenPalette[start + i] = colRGB888toBGR555(colors[2], colors[1], colors[0]);
+#ifndef N64_EXTREME_MEMORY_SAVING
+ _screenExactPalette[start + i] = *((uint32*)(colors));
+#endif
colors += 4;
}
@@ -395,6 +402,7 @@ void OSystem_N64::rebuildOffscreenMouseBuffer(void) {
}
void OSystem_N64::grabPalette(byte *colors, uint start, uint num) {
+#ifdef N64_EXTREME_MEMORY_SAVING // This way loses precisions
uint32 i;
uint16 color;
@@ -407,6 +415,9 @@ void OSystem_N64::grabPalette(byte *colors, uint start, uint num) {
*colors++ = (((color >> 10) & 0x1F) << 3);
*colors++ = 0;
}
+#else
+ memcpy(colors, (uint8*)(_screenExactPalette + start), num * 4);
+#endif
return;
}