all repos — mgba @ 6c470e3e5cbdf8a10e1cfa1ae091e25d795d55c3

mGBA Game Boy Advance Emulator

GBA Video, GB Video: Colors are now fully scaled
Jeffrey Pfau jeffrey@endrift.com
Fri, 21 Oct 2016 13:53:33 -0700
commit

6c470e3e5cbdf8a10e1cfa1ae091e25d795d55c3

parent

a86184df43bb8e0ab6ae3661d297cb12c5e91156

M CHANGESCHANGES

@@ -22,6 +22,7 @@ - GBA Video: Clean up unused timers

- Test: Add a basic test suite - GBA Video: Allow multiple handles into the same tile cache - VFS: Call msync when syncing mapped data + - GBA Video, GB Video: Colors are now fully scaled 0.5.1: (2016-10-05) Bugfixes:
M src/gb/renderers/software.csrc/gb/renderers/software.c

@@ -32,7 +32,7 @@ #else

color_t palette0 = 0x7FFF; #endif #else - color_t palette0 = 0xF8F8F8; + color_t palette0 = 0xFFFFFF; #endif int y;

@@ -121,6 +121,7 @@ color_t color = 0;

color |= (value << 3) & 0xF8; color |= (value << 6) & 0xF800; color |= (value << 9) & 0xF80000; + color |= (color >> 5) & 0x070707; #endif softwareRenderer->palette[index] = color; if (renderer->cache) {
M src/gba/renderers/software-bg.csrc/gba/renderers/software-bg.c

@@ -107,6 +107,7 @@ color32 = 0;

color32 |= (color << 3) & 0xF8; color32 |= (color << 6) & 0xF800; color32 |= (color << 9) & 0xF80000; + color32 |= (color32 >> 5) & 0x070707; color = color32; #elif COLOR_5_6_5 uint16_t color16 = 0;

@@ -196,6 +197,7 @@ unsigned color32 = 0;

color32 |= (color << 9) & 0xF80000; color32 |= (color << 3) & 0xF8; color32 |= (color << 6) & 0xF800; + color32 |= (color32 >> 5) & 0x070707; color = color32; #elif COLOR_5_6_5 uint16_t color16 = 0;
M src/gba/renderers/software-private.hsrc/gba/renderers/software-private.h

@@ -237,14 +237,14 @@ a = color & 0x7C00;

c |= (a + ((0x7C00 - a) * y) / 16) & 0x7C00; #endif #else - a = color & 0xF8; - c |= (a + ((0xF8 - a) * y) / 16) & 0xF8; + a = color & 0xFF; + c |= (a + ((0xFF - a) * y) / 16) & 0xFF; - a = color & 0xF800; - c |= (a + ((0xF800 - a) * y) / 16) & 0xF800; + a = color & 0xFF00; + c |= (a + ((0xFF00 - a) * y) / 16) & 0xFF00; - a = color & 0xF80000; - c |= (a + ((0xF80000 - a) * y) / 16) & 0xF80000; + a = color & 0xFF0000; + c |= (a + ((0xFF0000 - a) * y) / 16) & 0xFF0000; #endif return c; }

@@ -270,14 +270,14 @@ a = color & 0x7C00;

c |= (a - (a * y) / 16) & 0x7C00; #endif #else - a = color & 0xF8; - c |= (a - (a * y) / 16) & 0xF8; + a = color & 0xFF; + c |= (a - (a * y) / 16) & 0xFF; - a = color & 0xF800; - c |= (a - (a * y) / 16) & 0xF800; + a = color & 0xFF00; + c |= (a - (a * y) / 16) & 0xFF00; - a = color & 0xF80000; - c |= (a - (a * y) / 16) & 0xF80000; + a = color & 0xFF0000; + c |= (a - (a * y) / 16) & 0xFF0000; #endif return c; }

@@ -320,25 +320,25 @@ }

c = (c & 0x7C1F) | ((c >> 16) & 0x03E0); #endif #else - a = colorA & 0xF8; - b = colorB & 0xF8; - c |= ((a * weightA + b * weightB) / 16) & 0x1F8; + a = colorA & 0xFF; + b = colorB & 0xFF; + c |= ((a * weightA + b * weightB) / 16) & 0x1FF; if (c & 0x00000100) { - c = 0x000000F8; + c = 0x000000FF; } - a = colorA & 0xF800; - b = colorB & 0xF800; - c |= ((a * weightA + b * weightB) / 16) & 0x1F800; + a = colorA & 0xFF00; + b = colorB & 0xFF00; + c |= ((a * weightA + b * weightB) / 16) & 0x1FF00; if (c & 0x00010000) { - c = (c & 0x000000F8) | 0x0000F800; + c = (c & 0x000000FF) | 0x0000FF00; } - a = colorA & 0xF80000; - b = colorB & 0xF80000; - c |= ((a * weightA + b * weightB) / 16) & 0x1F80000; + a = colorA & 0xFF0000; + b = colorB & 0xFF0000; + c |= ((a * weightA + b * weightB) / 16) & 0x1FF0000; if (c & 0x01000000) { - c = (c & 0x0000F8F8) | 0x00F80000; + c = (c & 0x0000FFFF) | 0x00FF0000; } #endif return c;
M src/gba/renderers/video-software.csrc/gba/renderers/video-software.c

@@ -370,6 +370,7 @@ unsigned color = 0;

color |= (value << 3) & 0xF8; color |= (value << 6) & 0xF800; color |= (value << 9) & 0xF80000; + color |= (color >> 5) & 0x070707; #endif softwareRenderer->normalPalette[address >> 1] = color; if (softwareRenderer->blendEffect == BLEND_BRIGHTEN) {
M src/gba/video.hsrc/gba/video.h

@@ -15,9 +15,9 @@ #define GBA_R5(X) ((X) & 0x1F)

#define GBA_G5(X) (((X) >> 5) & 0x1F) #define GBA_B5(X) (((X) >> 10) & 0x1F) -#define GBA_R8(X) (((X) << 3) & 0xF8) -#define GBA_G8(X) (((X) >> 2) & 0xF8) -#define GBA_B8(X) (((X) >> 7) & 0xF8) +#define GBA_R8(X) (((((X) << 3) & 0xF8) * 0x21) >> 5) +#define GBA_G8(X) (((((X) >> 2) & 0xF8) * 0x21) >> 5) +#define GBA_B8(X) (((((X) >> 7) & 0xF8) * 0x21) >> 5) mLOG_DECLARE_CATEGORY(GBA_VIDEO);
M src/platform/qt/GameController.cppsrc/platform/qt/GameController.cpp

@@ -159,7 +159,7 @@ controller->m_resetActions.clear();

unsigned width, height; controller->m_threadContext.core->desiredVideoDimensions(controller->m_threadContext.core, &width, &height); - memset(controller->m_frontBuffer, 0xF8, width * height * BYTES_PER_PIXEL); + memset(controller->m_frontBuffer, 0xFF, width * height * BYTES_PER_PIXEL); QMetaObject::invokeMethod(controller, "frameAvailable", Q_ARG(const uint32_t*, controller->m_frontBuffer)); if (controller->m_pauseAfterFrame.testAndSetAcquire(true, false)) { mCoreThreadPauseFromThread(context);
M src/platform/qt/PaletteView.cppsrc/platform/qt/PaletteView.cpp

@@ -118,6 +118,7 @@ uint32_t r = GBA_R5(color);

uint32_t g = GBA_G5(color); uint32_t b = GBA_B5(color); uint32_t hexcode = (r << 19) | (g << 11) | (b << 3); + hexcode |= (hexcode >> 5) & 0x070707; m_ui.hexcode->setText(tr("#%0").arg(hexcode, 6, 16, QChar('0'))); m_ui.value->setText(tr("0x%0").arg(color, 4, 16, QChar('0'))); m_ui.index->setText(tr("%0").arg(index, 3, 10, QChar('0')));