mirror of
https://github.com/FranLMSP/snes.git
synced 2026-10-03 07:55:17 -04:00
Fix issues when displaying the background tiles
This commit is contained in:
@@ -103,6 +103,7 @@ pub struct PPUDebugControlOptions {
|
||||
pub show_registers: bool,
|
||||
pub show_vram: bool,
|
||||
pub vram_inputs: VramInputs,
|
||||
pub vram_inputs_result: VramInputs,
|
||||
pub backgrounds: [BgDebug; 4],
|
||||
}
|
||||
|
||||
@@ -113,6 +114,7 @@ impl PPUDebugControlOptions {
|
||||
show_registers: true,
|
||||
show_vram: true,
|
||||
vram_inputs: VramInputs::new(),
|
||||
vram_inputs_result: VramInputs::new(),
|
||||
backgrounds: [
|
||||
BgDebug::new(PPUBg::Bg1),
|
||||
BgDebug::new(PPUBg::Bg2),
|
||||
|
||||
@@ -164,13 +164,15 @@ fn build_vram_window(ctx: &egui::Context, ppu_debug_options: &mut PPUDebugContro
|
||||
if ui.button("Search").clicked() {
|
||||
sanitize_input(&mut ppu_debug_options.vram_inputs.address_start, false);
|
||||
sanitize_input(&mut ppu_debug_options.vram_inputs.address_end, false);
|
||||
ppu_debug_options.vram_inputs_result.address_start = ppu_debug_options.vram_inputs.address_start.to_string();
|
||||
ppu_debug_options.vram_inputs_result.address_end = ppu_debug_options.vram_inputs.address_end.to_string();
|
||||
}
|
||||
|
||||
ui.separator();
|
||||
|
||||
egui::ScrollArea::both().show(ui, |ui| {
|
||||
let address_start = u16::from_str_radix(&ppu_debug_options.vram_inputs.address_start, 16).unwrap();
|
||||
let address_end = u16::from_str_radix(&ppu_debug_options.vram_inputs.address_end, 16).unwrap();
|
||||
let address_start = u16::from_str_radix(&ppu_debug_options.vram_inputs_result.address_start, 16).unwrap();
|
||||
let address_end = u16::from_str_radix(&ppu_debug_options.vram_inputs_result.address_end, 16).unwrap();
|
||||
let mut header = String::from(" | ");
|
||||
for page in 0x00..=0x0F {
|
||||
header = format!("{} {:02X} ", header, page);
|
||||
|
||||
@@ -134,7 +134,8 @@ fn compute_2bpp_bg_background_framebuffer(background: Background, framebuffer: &
|
||||
for y in 0..height {
|
||||
for x in 0..width {
|
||||
let current_tile = (x / tile_size_width) + ((y / tile_size_height) * bg_size_width);
|
||||
let char_index = vram[(tileset_vram_base_address + current_tile) & 0x7FFF] & 0b11_11111111;
|
||||
let tile_byte = vram[tileset_vram_base_address + current_tile];
|
||||
let char_index = tile_byte & 0b11_11111111;
|
||||
let current_char_column = x.rem_euclid(tile_size_width);
|
||||
let current_char_row = y.rem_euclid(tile_size_height);
|
||||
// 8x8 pixels, 2 bitplanes, each word (16bit) holds 8 pixels
|
||||
@@ -225,7 +226,7 @@ fn paint_texture(ui: &mut Ui, texture: &mut Option<TextureHandle>, framebuffer:
|
||||
TextureOptions::default(),
|
||||
);
|
||||
let (whole_rect, _) =
|
||||
ui.allocate_exact_size(Vec2::from([width as f32, height as f32]), egui::Sense::focusable_noninteractive());
|
||||
ui.allocate_exact_size(Vec2::from([(width * 2) as f32, (height * 2) as f32]), egui::Sense::focusable_noninteractive());
|
||||
egui::Image::new((
|
||||
txt.id(),
|
||||
txt.size_vec2(),
|
||||
|
||||
Reference in New Issue
Block a user