Skip to content

Commit

Permalink
[SMS/GG] when display is disabled, render the backdrop color instead …
Browse files Browse the repository at this point in the history
…of black
  • Loading branch information
jsgroth committed Sep 30, 2024
1 parent ae65ac8 commit ea794bc
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions backend/smsgg-core/src/vdp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -774,9 +774,7 @@ impl Vdp {
(u16::from(self.registers.x_scroll >> 3), u16::from(self.registers.x_scroll & 0x07))
};

// Backdrop color always reads from the second half of CRAM
let backdrop_color = self.read_color_ram_word(0x10 | self.registers.backdrop_color);

let backdrop_color = self.backdrop_color();
for dot in 0..fine_x_scroll {
self.frame_buffer.set(frame_buffer_row, dot, backdrop_color);
}
Expand Down Expand Up @@ -890,11 +888,11 @@ impl Vdp {
}

fn clear_scanline(&mut self) {
const BLACK: u16 = 0;

let frame_buffer_row = self.frame_buffer_row();
let backdrop_color = self.backdrop_color();

for pixel in 0..SCREEN_WIDTH {
self.frame_buffer.set(frame_buffer_row, pixel, BLACK);
self.frame_buffer.set(frame_buffer_row, pixel, backdrop_color);
}
}

Expand All @@ -903,6 +901,11 @@ impl Vdp {
- self.registers.mode.vertical_border_offset()
}

fn backdrop_color(&self) -> u16 {
// Backdrop color always reads from the second half of CRAM (sprite colors)
self.read_color_ram_word(0x10 | self.registers.backdrop_color)
}

fn debug_log(&self) {
log::trace!("Registers: {:04X?}", self.registers);

Expand Down Expand Up @@ -992,9 +995,7 @@ impl Vdp {

fn fill_vertical_border(&mut self) {
let backdrop_color = match self.registers.mode {
Mode::Four | Mode::Four224Line => {
self.read_color_ram_word(0x10 | self.registers.backdrop_color)
}
Mode::Four | Mode::Four224Line => self.backdrop_color(),
Mode::GraphicsII => {
tms9918::TMS9918_COLOR_TO_SMS_COLOR[self.registers.backdrop_color as usize].into()
}
Expand Down

0 comments on commit ea794bc

Please sign in to comment.