Add other miscellanii to register view

This commit is contained in:
Simon Gellis 2025-02-23 01:02:08 -05:00
parent 4a6288147d
commit d6957ecd09
1 changed files with 136 additions and 5 deletions

View File

@ -33,7 +33,7 @@ impl RegisterWindow {
}
fn show_interrupts(&mut self, ui: &mut Ui) {
let row_height = ui.spacing().interact_size.y;
let row_height = self.row_height(ui);
let [mut raw_intpnd, mut raw_intenb] = self.read_address(0x0005f800);
let mut intenb = InterruptReg::parse(raw_intenb);
let mut intpnd = InterruptReg::parse(raw_intpnd);
@ -126,7 +126,7 @@ impl RegisterWindow {
}
fn show_display_status(&mut self, ui: &mut Ui) {
let row_height = ui.spacing().interact_size.y;
let row_height = self.row_height(ui);
let mut raw_dpstts = self.read_address(0x0005f820);
let mut dpstts = DisplayReg::parse(raw_dpstts);
ui.section("Display", |ui| {
@ -208,7 +208,7 @@ impl RegisterWindow {
}
fn show_drawing_status(&mut self, ui: &mut Ui) {
let row_height = ui.spacing().interact_size.y;
let row_height = self.row_height(ui);
let [mut raw_xpstts, raw_xpctrl] = self.read_address(0x0005f840);
let mut xpstts = DrawingReg::parse(raw_xpstts);
ui.section("Drawing", |ui| {
@ -306,7 +306,7 @@ impl RegisterWindow {
}
fn show_colors(&mut self, ui: &mut Ui) {
let row_height = ui.spacing().interact_size.y;
let row_height = self.row_height(ui);
let registers = self.registers.borrow();
ui.section("Colors", |ui| {
TableBuilder::new(ui)
@ -476,6 +476,127 @@ impl RegisterWindow {
});
}
fn show_objects(&mut self, ui: &mut Ui) {
let row_height = self.row_height(ui);
ui.section("Objects", |ui| {
let width = ui.available_width();
TableBuilder::new(ui)
.column(Column::exact(width * 0.25))
.column(Column::exact(width * 0.25))
.column(Column::exact(width * 0.5))
.cell_layout(Layout::left_to_right(Align::Center).with_main_align(Align::RIGHT))
.body(|mut body| {
body.row(row_height, |mut row| {
row.col(|_ui| {});
row.col(|ui| {
ui.add_sized(ui.available_size(), Label::new("Start"));
});
row.col(|ui| {
ui.add_sized(ui.available_size(), Label::new("End"));
});
});
let mut spts = self.read_address::<[u16; 4]>(0x0005f848);
let prevs = std::iter::once(0u16).chain(spts.map(|i| (i + 1) & 0x03ff));
let mut changed = false;
for (index, (spt, prev)) in spts.iter_mut().zip(prevs).enumerate() {
body.row(row_height, |mut row| {
row.col(|ui| {
ui.label(format!("SPT{index}"));
});
row.col(|ui| {
ui.with_layout(Layout::right_to_left(Align::Center), |ui| {
ui.label(prev.to_string());
});
});
row.col(|ui| {
if ui.add(NumberEdit::new(spt).range(0..1024)).changed() {
changed = true;
}
});
});
}
if changed {
self.memory.write(self.sim_id, 0x0005f848, &spts);
}
});
ui.allocate_space(ui.available_size_before_wrap());
});
}
fn show_misc(&mut self, ui: &mut Ui) {
let row_height = self.row_height(ui);
let registers = self.registers.borrow();
ui.section("Misc.", |ui| {
let width = ui.available_width();
TableBuilder::new(ui)
.column(Column::exact(width * 0.5))
.column(Column::exact(width * 0.5))
.cell_layout(Layout::left_to_right(Align::Center).with_main_align(Align::RIGHT))
.body(|mut body| {
body.row(row_height, |mut row| {
row.col(|ui| {
ui.label("FRMCYC");
});
row.col(|ui| {
let mut frmcyc = read_address::<u16>(&registers, 0x0005f82e);
ui.with_layout(Layout::right_to_left(Align::Center), |ui| {
if ui.add(NumberEdit::new(&mut frmcyc).range(0..32)).changed() {
self.memory.write(self.sim_id, 0x0005f82e, &frmcyc);
}
});
});
});
let mut cta = read_address::<u16>(&registers, 0x0005f830);
body.row(row_height, |mut row| {
row.col(|ui| {
ui.label("CTA");
});
row.col(|ui| {
ui.with_layout(Layout::right_to_left(Align::Center), |ui| {
ui.add_enabled(
false,
NumberEdit::new(&mut cta).arrows(false).hex(true),
);
});
});
});
body.row(row_height, |mut row| {
row.col(|ui| {
ui.label("CTA_L");
});
row.col(|ui| {
let mut cta_l = cta & 0xff;
ui.with_layout(Layout::right_to_left(Align::Center), |ui| {
ui.add_enabled(
false,
NumberEdit::new(&mut cta_l).arrows(false).hex(true),
);
});
});
});
body.row(row_height, |mut row| {
row.col(|ui| {
ui.label("CTA_R");
});
row.col(|ui| {
let mut cta_r = (cta >> 8) & 0xff;
ui.with_layout(Layout::right_to_left(Align::Center), |ui| {
ui.add_enabled(
false,
NumberEdit::new(&mut cta_r).arrows(false).hex(true),
);
});
});
});
});
ui.allocate_space(ui.available_size_before_wrap());
});
}
fn row_height(&self, ui: &mut Ui) -> f32 {
ui.spacing().interact_size.y + ui.style().visuals.selection.stroke.width
}
fn read_address<T: MemoryValue>(&self, address: usize) -> T {
read_address(&self.registers.borrow(), address)
}
@ -505,7 +626,7 @@ impl AppWindow for RegisterWindow {
CentralPanel::default().show(ctx, |ui| {
ScrollArea::vertical().show(ui, |ui| {
ui.horizontal_top(|ui| {
let width = ui.available_width() - (ui.spacing().item_spacing.x * 6.0);
let width = ui.available_width() - (ui.spacing().item_spacing.x * 8.0);
StripBuilder::new(ui)
.size(Size::exact(width * 0.2))
.size(Size::exact(width * 0.2))
@ -528,6 +649,16 @@ impl AppWindow for RegisterWindow {
strip.cell(|ui| {
self.show_colors(ui);
});
strip.strip(|nested| {
nested.sizes(Size::remainder(), 2).vertical(|mut strip| {
strip.cell(|ui| {
self.show_objects(ui);
});
strip.cell(|ui| {
self.show_misc(ui);
});
});
});
});
});
});