Skip to content

Commit

Permalink
Implement pseudo high-res
Browse files Browse the repository at this point in the history
  • Loading branch information
twvd committed Jun 8, 2024
1 parent 2a0d7bd commit ba02a92
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions src/snes/ppu/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,12 @@ impl PPUState {
scanline_sprites: usize,
) -> ArrayVec<Color, SCREEN_WIDTH> {
let brightness = (self.inidisp & 0x0F) as usize;
let scale = self.get_screen_mode_scale_bg();
let pseudo_highres = self.setini & (1 << 3) != 0;
let scale = if pseudo_highres {
1
} else {
self.get_screen_mode_scale_bg()
};
let mut out: ArrayVec<Color, SCREEN_WIDTH> = ArrayVec::new();

if brightness == 0 || self.inidisp & 0x80 != 0 {
Expand All @@ -528,7 +533,7 @@ impl PPUState {
let subscreen = self.render_scanline_screen(
scanline_bg,
scanline_sprites,
if self.cgwsel & (1 << 1) != 0 {
if pseudo_highres || self.cgwsel & (1 << 1) != 0 {
// Enable backdrop + bg + obj
self.ts & !self.dbg_layermask
} else {
Expand All @@ -542,7 +547,23 @@ impl PPUState {

// Send line to screen buffer
for x in 0..(SCREEN_WIDTH / scale) {
let pixel = if self.in_highres_h() {
let pixel = if pseudo_highres {
// Pseudo high-res
let x = x / 2;
self.apply_colormath(
if x % 2 == 0 {
// Left-most pixel is from subscreen
subscreen.paletted[x]
} else {
mainscreen.paletted[x]
},
self.coldata,
mainscreen.layer[x],
subscreen.layer[x],
mainscreen.window.math[x],
mainscreen.palette[x],
)
} else if self.in_highres_h() {
// Mode 5/6 do not support color math
mainscreen.paletted[x]
} else {
Expand Down

0 comments on commit ba02a92

Please sign in to comment.