N64: Adapt to setPalette/grabPalette RGBA->RGB change.

This change is not tested, but should hopefully work fine.
This commit is contained in:
Johannes Schickel 2011-02-16 00:02:48 +01:00
parent aafebe1389
commit a52b16ceb3
2 changed files with 10 additions and 10 deletions

View file

@ -93,7 +93,7 @@ protected:
uint16 *_screenPalette; // Array for palette entries (256 colors max) uint16 *_screenPalette; // Array for palette entries (256 colors max)
#ifndef N64_EXTREME_MEMORY_SAVING #ifndef N64_EXTREME_MEMORY_SAVING
uint32 *_screenExactPalette; // Array for palette entries, as received by setPalette(), no precision loss uint8 *_screenExactPalette; // Array for palette entries, as received by setPalette(), no precision loss
#endif #endif
uint16 _cursorPalette[256]; // Palette entries for the cursor uint16 _cursorPalette[256]; // Palette entries for the cursor

View file

@ -113,8 +113,8 @@ OSystem_N64::OSystem_N64() {
// Clear palette array // Clear palette array
_screenPalette = (uint16*)memalign(8, 256 * sizeof(uint16)); _screenPalette = (uint16*)memalign(8, 256 * sizeof(uint16));
#ifndef N64_EXTREME_MEMORY_SAVING #ifndef N64_EXTREME_MEMORY_SAVING
_screenExactPalette = (uint32*)memalign(8, 256 * sizeof(uint32)); _screenExactPalette = (uint8*)memalign(8, 256 * 3);
memset(_screenExactPalette, 0, 256 * sizeof(uint32)); memset(_screenExactPalette, 0, 256 * 3);
#endif #endif
memset(_screenPalette, 0, 256 * sizeof(uint16)); memset(_screenPalette, 0, 256 * sizeof(uint16));
memset(_cursorPalette, 0, 256 * sizeof(uint16)); memset(_cursorPalette, 0, 256 * sizeof(uint16));
@ -350,12 +350,13 @@ int16 OSystem_N64::getWidth() {
} }
void OSystem_N64::setPalette(const byte *colors, uint start, uint num) { void OSystem_N64::setPalette(const byte *colors, uint start, uint num) {
#ifndef N64_EXTREME_MEMORY_SAVING
memcpy(_screenExactPalette + start * 3, colors, num * 3);
#endif
for (uint i = 0; i < num; ++i) { for (uint i = 0; i < num; ++i) {
_screenPalette[start + i] = colRGB888toBGR555(colors[2], colors[1], colors[0]); _screenPalette[start + i] = colRGB888toBGR555(colors[2], colors[1], colors[0]);
#ifndef N64_EXTREME_MEMORY_SAVING colors += 3;
_screenExactPalette[start + i] = *((uint32*)(colors));
#endif
colors += 4;
} }
// If cursor uses the game palette, we need to rebuild the hicolor buffer // If cursor uses the game palette, we need to rebuild the hicolor buffer
@ -413,10 +414,9 @@ void OSystem_N64::grabPalette(byte *colors, uint start, uint num) {
*colors++ = ((color & 0x1F) << 3); *colors++ = ((color & 0x1F) << 3);
*colors++ = (((color >> 5) & 0x1F) << 3); *colors++ = (((color >> 5) & 0x1F) << 3);
*colors++ = (((color >> 10) & 0x1F) << 3); *colors++ = (((color >> 10) & 0x1F) << 3);
*colors++ = 0;
} }
#else #else
memcpy(colors, (uint8*)(_screenExactPalette + start), num * 4); memcpy(colors, _screenExactPalette + start * 3, num * 3);
#endif #endif
return; return;
@ -425,7 +425,7 @@ void OSystem_N64::grabPalette(byte *colors, uint start, uint num) {
void OSystem_N64::setCursorPalette(const byte *colors, uint start, uint num) { void OSystem_N64::setCursorPalette(const byte *colors, uint start, uint num) {
for (uint i = 0; i < num; ++i) { for (uint i = 0; i < num; ++i) {
_cursorPalette[start + i] = colRGB888toBGR555(colors[2], colors[1], colors[0]); _cursorPalette[start + i] = colRGB888toBGR555(colors[2], colors[1], colors[0]);
colors += 4; colors += 3;
} }
_cursorPaletteDisabled = false; _cursorPaletteDisabled = false;