fix: respect background palette in world view

This commit is contained in:
Simon Gellis 2025-02-24 22:02:38 -05:00
parent 54edfbc111
commit 25c7f29735
1 changed files with 13 additions and 2 deletions

View File

@ -643,6 +643,15 @@ impl WorldRenderer {
shades.map(|s| shade(s, params.right_color)),
]
};
let palettes = {
let palettes = self.palettes.borrow().read::<[u8; 8]>(0);
[
utils::parse_palette(palettes[0]),
utils::parse_palette(palettes[2]),
utils::parse_palette(palettes[4]),
utils::parse_palette(palettes[6]),
]
};
let chardata = self.chardata.borrow();
let bgmaps = self.bgmaps.borrow();
@ -667,7 +676,8 @@ impl WorldRenderer {
let row = (sy & 0x7) as usize;
let col = (sx & 0x7) as usize;
let pixel = utils::read_char_pixel(char, cell.hflip, cell.vflip, row, col);
image.add((dx as usize, dy as usize), colors[0][pixel as usize]);
let shade = palettes[cell.palette_index][pixel as usize];
image.add((dx as usize, dy as usize), colors[0][shade as usize]);
}
let dx = x + world.dst_x + world.dst_parallax;
@ -680,7 +690,8 @@ impl WorldRenderer {
let row = (sy & 0x7) as usize;
let col = (sx & 0x7) as usize;
let pixel = utils::read_char_pixel(char, cell.hflip, cell.vflip, row, col);
image.add((dx as usize, dy as usize), colors[1][pixel as usize]);
let shade = palettes[cell.palette_index][pixel as usize];
image.add((dx as usize, dy as usize), colors[1][shade as usize]);
}
}
}