diff --git a/BizHawk.Emulation/Consoles/Nintendo/SNES/LibsnesCore.cs b/BizHawk.Emulation/Consoles/Nintendo/SNES/LibsnesCore.cs index 97445fb99e..11fb4d9427 100644 --- a/BizHawk.Emulation/Consoles/Nintendo/SNES/LibsnesCore.cs +++ b/BizHawk.Emulation/Consoles/Nintendo/SNES/LibsnesCore.cs @@ -40,7 +40,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES int rom_size); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void snes_video_refresh_t(ushort *data, int width, int height); + public delegate void snes_video_refresh_t(int *data, int width, int height); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate void snes_input_poll_t(); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] @@ -222,7 +222,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES } GCHandle _gc_snes_video_refresh; - void snes_video_refresh(ushort* data, int width, int height) + void snes_video_refresh(int* data, int width, int height) { vidWidth = width; vidHeight = height; @@ -234,14 +234,15 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES { int si = y * 1024 + x; int di = y * vidWidth + x; - ushort rgb = data[si]; - int r = rgb >> 10; - int g = (rgb >> 5) & 0x1F; - int b = (rgb) & 0x1F; - r = r * 255 / 31; - g = g * 255 / 31; - b = b * 255 / 31; - vidBuffer[di] = (int)unchecked((int)0xFF000000 | (r << 16) | (g << 8) | b); + int rgb = data[si]; + vidBuffer[di] = rgb; + //int r = rgb >> 10; + //int g = (rgb >> 5) & 0x1F; + //int b = (rgb) & 0x1F; + //r = r * 255 / 31; + //g = g * 255 / 31; + //b = b * 255 / 31; + //vidBuffer[di] = (int)unchecked((int)0xFF000000 | (r << 16) | (g << 8) | b); } } diff --git a/BizHawk.MultiClient/output/snes.dll b/BizHawk.MultiClient/output/snes.dll index 8f09969672..8d6ee70979 100644 Binary files a/BizHawk.MultiClient/output/snes.dll and b/BizHawk.MultiClient/output/snes.dll differ diff --git a/libsnes/bsnes/target-libsnes/libsnes.cpp b/libsnes/bsnes/target-libsnes/libsnes.cpp index b6ea1e22a0..3d58598935 100644 --- a/libsnes/bsnes/target-libsnes/libsnes.cpp +++ b/libsnes/bsnes/target-libsnes/libsnes.cpp @@ -11,7 +11,7 @@ struct Interface : public SNES::Interface { snes_input_poll_t pinput_poll; snes_input_state_t pinput_state; string basename; - uint16_t *buffer; + uint32_t *buffer; uint32_t *palette; void videoRefresh(const uint32_t *data, bool hires, bool interlace, bool overscan) { @@ -23,7 +23,7 @@ struct Interface : public SNES::Interface { for(unsigned y = 0; y < height; y++) { const uint32_t *sp = data + y * pitch; - uint16_t *dp = buffer + y * pitch; + uint32_t *dp = buffer + y * pitch; for(unsigned x = 0; x < width; x++) { *dp++ = palette[*sp++]; } @@ -51,7 +51,7 @@ struct Interface : public SNES::Interface { } Interface() : pvideo_refresh(0), paudio_sample(0), pinput_poll(0), pinput_state(0) { - buffer = new uint16_t[512 * 480]; + buffer = new uint32_t[512 * 480]; palette = new uint32_t[16 * 32768]; //{llll bbbbb ggggg rrrrr} -> { rrrrr ggggg bbbbb } @@ -59,11 +59,22 @@ struct Interface : public SNES::Interface { for(unsigned r = 0; r < 32; r++) { for(unsigned g = 0; g < 32; g++) { for(unsigned b = 0; b < 32; b++) { + //double luma = (double)l / 15.0; + //unsigned ar = (luma * r + 0.5); + //unsigned ag = (luma * g + 0.5); + //unsigned ab = (luma * b + 0.5); + //palette[(l << 15) + (r << 10) + (g << 5) + (b << 0)] = (ab << 10) + (ag << 5) + (ar << 0); + + //zero 04-sep-2012 - go ahead and turn this into a pixel format we'll want double luma = (double)l / 15.0; unsigned ar = (luma * r + 0.5); unsigned ag = (luma * g + 0.5); unsigned ab = (luma * b + 0.5); - palette[(l << 15) + (r << 10) + (g << 5) + (b << 0)] = (ab << 10) + (ag << 5) + (ar << 0); + ar = ar * 255 / 31; + ag = ag * 255 / 31; + ab = ab * 255 / 31; + unsigned color = (ab << 16) + (ag << 8) + (ar << 0) | 0xFF000000; + palette[(l << 15) + (r << 10) + (g << 5) + (b << 0)] = color; } } } diff --git a/libsnes/bsnes/target-libsnes/libsnes.hpp b/libsnes/bsnes/target-libsnes/libsnes.hpp index bb83e19894..c2997b0ee9 100644 --- a/libsnes/bsnes/target-libsnes/libsnes.hpp +++ b/libsnes/bsnes/target-libsnes/libsnes.hpp @@ -67,7 +67,7 @@ extern "C" { #define SNES_MEMORY_OAM 103 #define SNES_MEMORY_CGRAM 104 -typedef void (*snes_video_refresh_t)(const uint16_t *data, unsigned width, unsigned height); +typedef void (*snes_video_refresh_t)(const uint32_t *data, unsigned width, unsigned height); typedef void (*snes_audio_sample_t)(uint16_t left, uint16_t right); typedef void (*snes_input_poll_t)(void); typedef int16_t (*snes_input_state_t)(unsigned port, unsigned device, unsigned index, unsigned id);