bsnes/higan/gba/ppu/video.cpp
Tim Allen 344e63d928 Update to v097r02 release.
byuu says:

Note: balanced/performance profiles still broken, sorry.

Changelog:
- added nall/GNUmakefile unique() function; used on linking phase of
  higan
- added nall/unique_pointer
- target-tomoko and {System}::Video updated to use
  unique_pointer<ClassName> instead of ClassName* [1]
- locate() updated to search multiple paths [2]
- GB: pass gekkio's if_ie_registers and boot_hwio-G test ROMs
- FC, GB, GBA: merge video/ into the PPU cores
- ruby: fixed ~AudioXAudio2() typo

[1] I expected this to cause new crashes on exit due to changing the
order of destruction of objects (and deleting things that weren't
deleted before), but ... so far, so good. I guess we'll see what crops
up, especially on OS X (which is already crashing for unknown reasons on
exit.)

[2] right now, the search paths are: programpath(), {configpath(),
"higan/"}, {localpath(), "higan/"}; but we can add as many more as we
want, and we can also add platform-specific versions.
2016-01-25 22:27:18 +11:00

60 lines
1.8 KiB
C++

Video video;
Video::Video() {
output = new uint32[240 * 160];
paletteLiteral = new uint32[1 << 15];
paletteStandard = new uint32[1 << 15];
paletteEmulation = new uint32[1 << 15];
}
auto Video::power() -> void {
memory::fill(output(), 240 * 160 * sizeof(uint32));
for(auto color : range(1 << 15)) {
paletteLiteral[color] = color;
uint B = (uint5)(color >> 10);
uint G = (uint5)(color >> 5);
uint R = (uint5)(color >> 0);
uint b = image::normalize(B, 5, 16);
uint g = image::normalize(G, 5, 16);
uint r = image::normalize(R, 5, 16);
paletteStandard[color] = interface->videoColor(r, g, b);
double lcdGamma = 4.0, outGamma = 2.2;
double lb = pow(B / 31.0, lcdGamma);
double lg = pow(G / 31.0, lcdGamma);
double lr = pow(R / 31.0, lcdGamma);
b = pow((220 * lb + 10 * lg + 50 * lr) / 255, 1 / outGamma) * (0xffff * 255 / 280);
g = pow(( 30 * lb + 230 * lg + 10 * lr) / 255, 1 / outGamma) * (0xffff * 255 / 280);
r = pow(( 0 * lb + 50 * lg + 255 * lr) / 255, 1 / outGamma) * (0xffff * 255 / 280);
paletteEmulation[color] = interface->videoColor(r, g, b);
}
}
auto Video::refresh() -> void {
auto output = this->output();
auto& palette = settings.colorEmulation ? paletteEmulation : paletteStandard;
for(uint y = 0; y < 160; y++) {
auto source = ppu.output + y * 240;
auto target = output + y * 240;
if(settings.blurEmulation) {
for(uint x = 0; x < 240; x++) {
auto a = palette[*source++];
auto b = *target;
*target++ = (a + b - ((a ^ b) & 0x01010101)) >> 1;
}
} else {
for(uint x = 0; x < 240; x++) {
auto color = palette[*source++];
*target++ = color;
}
}
}
interface->videoRefresh(output, 240 * sizeof(uint32), 240, 160);
}