Show bg buttons

This commit is contained in:
2023-12-25 19:41:58 -05:00
parent 9561aa7737
commit f896fa7018
2 changed files with 41 additions and 1 deletions

View File

@@ -1,3 +1,9 @@
use snes_core::ppu::registers::{
Background as PPUBg,
MAX_BG_WIDTH,
MAX_BG_HEIGHT,
};
pub struct DebugOptions {
pub enable_debugging: bool,
pub show_debug_options_window: bool,
@@ -64,11 +70,31 @@ impl CPUDebugControlOptions {
}
}
pub struct BgDebug {
pub is_enabled: bool,
pub background: PPUBg,
pub bg_framebuffer: Vec<u8>,
pub char_framebuffer: Vec<u8>,
}
impl BgDebug {
pub fn new(background: PPUBg) -> Self {
Self {
is_enabled: false,
background: background,
bg_framebuffer: vec![0x00; MAX_BG_WIDTH * MAX_BG_HEIGHT * 4],
// 8x8 pixels, 16x8 characters
char_framebuffer: vec![0x00; 8 * 8 * 16 * 8 * 4],
}
}
}
pub struct PPUDebugControlOptions {
pub is_enabled: bool,
pub show_registers: bool,
pub show_vram: bool,
pub vram_inputs: VramInputs,
pub backgrounds: [BgDebug; 4],
}
impl PPUDebugControlOptions {
@@ -78,6 +104,12 @@ impl PPUDebugControlOptions {
show_registers: true,
show_vram: true,
vram_inputs: VramInputs::new(),
backgrounds: [
BgDebug::new(PPUBg::Bg1),
BgDebug::new(PPUBg::Bg2),
BgDebug::new(PPUBg::Bg3),
BgDebug::new(PPUBg::Bg4),
],
}
}
}

View File

@@ -1,7 +1,7 @@
use eframe::egui;
use snes_core::ppu::registers::PPURegisters;
use crate::emu_state::debug_options::PPUDebugControlOptions;
use crate::emu_state::debug_options::{PPUDebugControlOptions, BgDebug};
use crate::emu_ui::debug::common::sanitize_input;
@@ -32,6 +32,14 @@ pub fn build_ppu_debug_controls(ctx: &egui::Context, ppu_debug_options: &mut PPU
});
ui.monospace("Backgrounds:");
ui.horizontal(|ui| {
for bgdebug in ppu_debug_options.backgrounds.iter_mut() {
if ui.selectable_label(
bgdebug.is_enabled,
format!("Show {:?}", bgdebug.background),
).clicked() {
bgdebug.is_enabled = !bgdebug.is_enabled;
}
}
});
});