bsnes-libretro/bsnes/filter/scanlines-dark.cpp
Tim Allen d87a0f633d Update to bsnes v107r4 beta release.
byuu says:

  - bsnes: added video filters from bsnes v082
  - bsnes: added ZSNES snow effect option when games paused or unloaded
    (no, I'm not joking)
  - bsnes: added 7-zip support (LZMA 19.00 SDK)

[Recent higan WIPs have also mentioned bsnes changes, although the higan code
no longer includes the bsnes code. These changes include:

  - higan, bsnes: added EXLOROM, EXLOROM-RAM, EXHIROM mappings
  - higan, bsnes: focus the viewport after leaving fullscreen exclusive
    mode
  - bsnes: re-added mightymo's cheat code database
  - bsnes: improved make install rules for the game and cheat code
    databases
  - bsnes: delayed construction of hiro::Window objects to properly show
    bsnes window icons

- Ed.]
2019-07-07 19:44:09 +10:00

49 lines
1.0 KiB
C++

namespace Filter::ScanlinesDark {
uint16_t adjust[32768];
void initialize() {
static bool initialized = false;
if(initialized == true) return;
initialized = true;
for(unsigned i = 0; i < 32768; i++) {
uint8_t r = (i >> 10) & 31;
uint8_t g = (i >> 5) & 31;
uint8_t b = (i >> 0) & 31;
r *= 0.333;
g *= 0.333;
b *= 0.333;
adjust[i] = (r << 10) + (g << 5) + (b << 0);
}
}
auto size(uint& width, uint& height) -> void {
width = width;
height = height * 2;
}
auto render(
uint32_t* palette, uint32_t* output, uint outpitch,
const uint16_t* input, uint pitch, uint width, uint height
) -> void {
initialize();
pitch >>= 1;
outpitch >>= 2;
for(unsigned y = 0; y < height; y++) {
const uint16_t *in = input + y * pitch;
uint32_t *out0 = output + y * outpitch * 2;
uint32_t *out1 = output + y * outpitch * 2 + outpitch;
for(unsigned x = 0; x < width; x++) {
uint16_t color = *in++;
*out0++ = palette[color];
*out1++ = palette[adjust[color]];
}
}
}
}