2015-12-05 05:44:49 +00:00
|
|
|
inline auto PPU::get_palette(uint8 index) -> uint16 {
|
|
|
|
const uint addr = index << 1;
|
Update to v074r11 release.
byuu says:
Changelog:
- debugger compiles on all three profiles
- libsnes compiles on all three platforms (no API changes to libsnes)
- memory.cpp : namespace memory removed (wram -> cpu, apuram -> smp,
vram, oam, cgram -> ppu)
- sa1.cpp : namespace memory removed (SA-1 specific functions merged
inline to SA1::bus_read,write)
- GameBoy: added serial link support with interrupts and proper 8192hz
timing, but obviously it acts as if no other GB is connected to it
- GameBoy: added STAT OAM interrupt, and better STAT d1,d0 mode values
- UI: since Qt is dead, I've renamed the config files back to bsnes.cfg
and bsnes-geometry.cfg
- SA1: IRAM was not syncing to CPU on SA-1 side
- PPU/Accuracy and PPU/Performance needed Sprite oam renamed to Sprite
sprite; so that I could add uint8 oam[544]
- makes more sense anyway, OAM = object attribute memory, obj or
sprite are better names for Sprite rendering class
- more cleanup
2011-01-24 09:03:17 +00:00
|
|
|
return cgram[addr] + (cgram[addr + 1] << 8);
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//p = 00000bgr <palette data>
|
|
|
|
//t = BBGGGRRR <tilemap data>
|
|
|
|
//r = 0BBb00GGGg0RRRr0 <return data>
|
2015-12-05 05:44:49 +00:00
|
|
|
inline auto PPU::get_direct_color(uint8 p, uint8 t) -> uint16 {
|
2010-08-09 13:28:56 +00:00
|
|
|
return ((t & 7) << 2) | ((p & 1) << 1) |
|
|
|
|
(((t >> 3) & 7) << 7) | (((p >> 1) & 1) << 6) |
|
|
|
|
((t >> 6) << 13) | ((p >> 2) << 12);
|
|
|
|
}
|
|
|
|
|
2015-12-05 05:44:49 +00:00
|
|
|
inline auto PPU::get_pixel_normal(uint32 x) -> uint16 {
|
2013-05-05 09:21:30 +00:00
|
|
|
pixel_t& p = pixel_cache[x];
|
2010-08-09 13:28:56 +00:00
|
|
|
uint16 src_main, src_sub;
|
2013-05-05 09:21:30 +00:00
|
|
|
uint8 bg_sub;
|
|
|
|
|
2010-08-09 13:28:56 +00:00
|
|
|
src_main = p.src_main;
|
|
|
|
|
|
|
|
if(!regs.addsub_mode) {
|
|
|
|
bg_sub = BACK;
|
|
|
|
src_sub = regs.color_rgb;
|
|
|
|
} else {
|
|
|
|
bg_sub = p.bg_sub;
|
|
|
|
src_sub = p.src_sub;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!window[COL].main[x]) {
|
|
|
|
if(!window[COL].sub[x]) {
|
|
|
|
return 0x0000;
|
|
|
|
}
|
|
|
|
src_main = 0x0000;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!p.ce_main && regs.color_enabled[p.bg_main] && window[COL].sub[x]) {
|
|
|
|
bool halve = false;
|
|
|
|
if(regs.color_halve && window[COL].main[x]) {
|
|
|
|
if(regs.addsub_mode && bg_sub == BACK);
|
|
|
|
else {
|
|
|
|
halve = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return addsub(src_main, src_sub, halve);
|
|
|
|
}
|
|
|
|
|
|
|
|
return src_main;
|
|
|
|
}
|
|
|
|
|
2015-12-05 05:44:49 +00:00
|
|
|
inline auto PPU::get_pixel_swap(uint32 x) -> uint16 {
|
2013-05-05 09:21:30 +00:00
|
|
|
pixel_t& p = pixel_cache[x];
|
2010-08-09 13:28:56 +00:00
|
|
|
uint16 src_main, src_sub;
|
2013-05-05 09:21:30 +00:00
|
|
|
uint8 bg_sub;
|
|
|
|
|
2010-08-09 13:28:56 +00:00
|
|
|
src_main = p.src_sub;
|
|
|
|
|
|
|
|
if(!regs.addsub_mode) {
|
|
|
|
bg_sub = BACK;
|
|
|
|
src_sub = regs.color_rgb;
|
|
|
|
} else {
|
|
|
|
bg_sub = p.bg_main;
|
|
|
|
src_sub = p.src_main;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!window[COL].main[x]) {
|
|
|
|
if(!window[COL].sub[x]) {
|
|
|
|
return 0x0000;
|
|
|
|
}
|
|
|
|
src_main = 0x0000;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!p.ce_sub && regs.color_enabled[p.bg_sub] && window[COL].sub[x]) {
|
|
|
|
bool halve = false;
|
|
|
|
if(regs.color_halve && window[COL].main[x]) {
|
|
|
|
if(regs.addsub_mode && bg_sub == BACK);
|
|
|
|
else {
|
|
|
|
halve = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return addsub(src_main, src_sub, halve);
|
|
|
|
}
|
|
|
|
|
|
|
|
return src_main;
|
|
|
|
}
|
|
|
|
|
2015-12-05 05:44:49 +00:00
|
|
|
inline auto PPU::render_line_output() -> void {
|
2016-01-15 10:28:51 +00:00
|
|
|
auto ptr = (uint32*)output + (line * 1024) + ((interlace() && field()) ? 512 : 0);
|
2010-08-09 13:28:56 +00:00
|
|
|
|
|
|
|
if(!regs.pseudo_hires && regs.bg_mode != 5 && regs.bg_mode != 6) {
|
2016-01-15 10:28:51 +00:00
|
|
|
for(uint x = 0; x < 256; x++) {
|
|
|
|
uint color = (regs.display_brightness << 15) | get_pixel_normal(x);
|
|
|
|
*ptr++ = color;
|
|
|
|
*ptr++ = color;
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|
|
|
|
} else {
|
2016-01-15 10:28:51 +00:00
|
|
|
for(uint x = 0; x < 256; x++) {
|
|
|
|
*ptr++ = (regs.display_brightness << 15) | get_pixel_swap(x);
|
|
|
|
*ptr++ = (regs.display_brightness << 15) | get_pixel_normal(x);
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-05 05:44:49 +00:00
|
|
|
inline auto PPU::render_line_clear() -> void {
|
2016-01-15 10:28:51 +00:00
|
|
|
auto ptr = (uint32*)output + (line * 1024) + ((interlace() && field()) ? 512 : 0);
|
|
|
|
memory::fill(ptr, 512 * sizeof(uint32));
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|