diff --git a/src/Makefile b/src/Makefile index b683a8e1..c3c1fe9d 100644 --- a/src/Makefile +++ b/src/Makefile @@ -4,7 +4,7 @@ ui := ui_qt # compiler c := $(compiler) -std=gnu99 cpp := $(subst cc,++,$(compiler)) -std=gnu++0x -flags := -O3 -fomit-frame-pointer -fPIC -I. +flags := -O3 -fomit-frame-pointer -I. link := objects := diff --git a/src/snes/ppu/bppu/bppu.cpp b/src/snes/ppu/bppu/bppu.cpp index 9221507c..b20016ec 100644 --- a/src/snes/ppu/bppu/bppu.cpp +++ b/src/snes/ppu/bppu/bppu.cpp @@ -347,21 +347,23 @@ void bPPU::reset() { bPPU::bPPU() { alloc_tiledata_cache(); - for(int l = 0; l < 16; l++) { - for(int i = 0; i < 4096; i++) { + for(unsigned l = 0; l < 16; l++) { + for(unsigned i = 0; i < 4096; i++) { mosaic_table[l][i] = (i / (l + 1)) * (l + 1); } } - for(int l = 0; l < 16; l++) { - double m = (double)l / 15.0; - for(int i = 0; i < 32 * 32; i++) { - int r = (int)((double)((i) & 31) * m + 0.5); - int g = (int)((double)((i >> 5) & 31) * m + 0.5); - r = max(0, min(31, r)); - g = max(0, min(31, g)); - if(i < 32) light_table_b[l][i] = (r << 10); - light_table_gr[l][i] = (g << 5) | (r); + for(unsigned l = 0; l < 16; l++) { + 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); + light_table[l][(r << 10) + (g << 5) + b] = (ab << 10) + (ag << 5) + ar; + } + } } } } diff --git a/src/snes/ppu/bppu/bppu.hpp b/src/snes/ppu/bppu/bppu.hpp index 7a4860cf..33c9f7ec 100644 --- a/src/snes/ppu/bppu/bppu.hpp +++ b/src/snes/ppu/bppu/bppu.hpp @@ -36,8 +36,7 @@ public: alwaysinline bool overscan() const { return display.overscan; } alwaysinline bool hires() const { return (regs.pseudo_hires || regs.bg_mode == 5 || regs.bg_mode == 6); } - uint16 light_table_b[16][32]; - uint16 light_table_gr[16][32 * 32]; + uint16 light_table[16][32768]; uint16 mosaic_table[16][4096]; void render_line(); diff --git a/src/snes/ppu/bppu/render/line.cpp b/src/snes/ppu/bppu/render/line.cpp index 14a8c56d..d7f91aa1 100644 --- a/src/snes/ppu/bppu/render/line.cpp +++ b/src/snes/ppu/bppu/render/line.cpp @@ -85,47 +85,24 @@ inline uint16 bPPU::get_pixel_swap(uint32 x) { } inline void bPPU::render_line_output() { - uint16 *ptr = (uint16*)output + (line * 1024) + - ((interlace() && field()) ? 512 : 0); - uint16 *luma_b = light_table_b [regs.display_brightness]; - uint16 *luma_gr = light_table_gr[regs.display_brightness]; + uint16 *ptr = (uint16*)output + (line * 1024) + ((interlace() && field()) ? 512 : 0); + uint16 *luma = light_table[regs.display_brightness]; uint16 curr, prev; if(!regs.pseudo_hires && regs.bg_mode != 5 && regs.bg_mode != 6) { - if(regs.display_brightness == 15) { - for(unsigned x = 0; x < 256; x++) { - *ptr++ = get_pixel_normal(x); - } - } else { - for(unsigned x = 0; x < 256; x++) { - curr = get_pixel_normal(x); - *ptr++ = luma_b[curr >> 10] + luma_gr[curr & 0x3ff]; - } + for(unsigned x = 0; x < 256; x++) { + curr = luma[get_pixel_normal(x)]; + *ptr++ = curr; } } else { - if(regs.display_brightness == 15) { - for(unsigned x = 0, prev = 0; x < 256; x++) { - curr = get_pixel_swap(x); - *ptr++ = (prev + curr - ((prev ^ curr) & 0x0421)) >> 1; - prev = curr; + for(unsigned x = 0, prev = 0; x < 256; x++) { + curr = luma[get_pixel_swap(x)]; + *ptr++ = (prev + curr - ((prev ^ curr) & 0x0421)) >> 1; + prev = curr; - curr = get_pixel_normal(x); - *ptr++ = (prev + curr - ((prev ^ curr) & 0x0421)) >> 1; - prev = curr; - - } - } else { - for(unsigned x = 0, prev = 0; x < 256; x++) { - curr = get_pixel_swap(x); - curr = luma_b[curr >> 10] + luma_gr[curr & 0x3ff]; - *ptr++ = (prev + curr - ((prev ^ curr) & 0x0421)) >> 1; - prev = curr; - - curr = get_pixel_normal(x); - curr = luma_b[curr >> 10] + luma_gr[curr & 0x3ff]; - *ptr++ = (prev + curr - ((prev ^ curr) & 0x0421)) >> 1; - prev = curr; - } + curr = luma[get_pixel_normal(x)]; + *ptr++ = (prev + curr - ((prev ^ curr) & 0x0421)) >> 1; + prev = curr; } } } diff --git a/src/snes/ppu/sppu/screen/screen.cpp b/src/snes/ppu/sppu/screen/screen.cpp index ee7034f8..697d8913 100644 --- a/src/snes/ppu/sppu/screen/screen.cpp +++ b/src/snes/ppu/sppu/screen/screen.cpp @@ -209,7 +209,7 @@ sPPU::Screen::Screen(sPPU &self) : self(self) { unsigned ar = (luma * r + 0.5); unsigned ag = (luma * g + 0.5); unsigned ab = (luma * b + 0.5); - light_table[l][(b << 10) + (g << 5) + r] = (ab << 10) + (ag << 5) + ar; + light_table[l][(r << 10) + (g << 5) + b] = (ab << 10) + (ag << 5) + ar; } } } diff --git a/src/snes/snes.hpp b/src/snes/snes.hpp index dd6d96e4..8cc32ce5 100644 --- a/src/snes/snes.hpp +++ b/src/snes/snes.hpp @@ -1,4 +1,4 @@ -static const char bsnesVersion[] = "064.04"; +static const char bsnesVersion[] = "064.05"; static const char bsnesTitle[] = "bsnes"; static const unsigned bsnesSerializerVersion = 10; diff --git a/src/ui_qt/link/filter.cpp b/src/ui_qt/link/filter.cpp index 7470c76d..82e3f9cb 100644 --- a/src/ui_qt/link/filter.cpp +++ b/src/ui_qt/link/filter.cpp @@ -99,10 +99,10 @@ void Filter::colortable_update() { double kr = 0.2126, kb = 0.0722, kg = (1.0 - kr - kb); //luminance weights for(unsigned i = 0; i < 32768; i++) { - unsigned color //bgr555->rgb888 conversion - = ((i & 0x001f) << 19) | ((i & 0x001c) << 14) - | ((i & 0x03e0) << 6) | ((i & 0x0380) << 1) - | ((i & 0x7c00) >> 7) | ((i & 0x7000) >> 12); + unsigned color //rgb555->rgb888 conversion + = ((i & 0x7c00) << 9) + ((i & 0x7000) << 4) + + ((i & 0x03e0) << 6) + ((i & 0x0380) << 1) + + ((i & 0x001f) << 3) + ((i & 0x001c) >> 2); signed l; signed r = (color >> 16) & 0xff;