add ascii output

This commit is contained in:
kirjavascript 2023-03-11 02:40:51 +00:00
parent 5be8e11dbc
commit fc9a54122b
3 changed files with 21 additions and 5 deletions

View file

@ -22,6 +22,10 @@ impl ROM {
((self.read_word(addr) as u32) << 16) | self.read_word(addr + 2) as u32
}
pub fn size(&self) -> usize {
self.bytes.len()
}
pub fn read_string(&self, range: std::ops::Range<usize>) -> String {
if range.end >= self.bytes.len() {
return format!("end {} >= length {}", range.end, self.bytes.len())

View file

@ -36,7 +36,7 @@ impl App {
// fonts
// .families
// .entry(egui::FontFamily::Monospace)
// .entry(egui::FontFamily::Proportional)
// .or_default()
// .push("Hack".to_string());

View file

@ -22,12 +22,20 @@ impl Debug {
palette::palette_window(&ctx, &emu);
self.vram.render(&ctx, &emu);
const ASCII: &str = r##"................................ !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~................................. ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþ"##;
egui::Window::new("memory")
.show(ctx, |ui| {
// TODO: difference accessors
// let tabs = [
// (0xFFFF, &emu.core.mem.ram),
// ];
// emu.core.mem.ram
let bytes_row = 16;
let total_bytes = 0x10000;
let total_bytes = 0xFFFF;
let rows = total_bytes / bytes_row;
egui::ScrollArea::vertical()
@ -38,11 +46,15 @@ impl Debug {
let bytes = (offset..offset+bytes_row)
.enumerate()
.map(|(idx, offset)| {
format!(" {:02x}", emu.core.mem.ram[idx + offset])
format!(" {:02X}", emu.core.mem.ram[idx + offset])
}).collect::<String>();
ui.label(format!("{:02x} {}", i, bytes));
let ascii = (offset..offset+bytes_row)
.enumerate()
.map(|(idx, offset)| {
format!("{}", ASCII.chars().nth(emu.core.mem.ram[idx + offset] as _).unwrap_or('.'))
}).collect::<String>();
ui.monospace(format!("{:04X} {} {}", i, bytes, ascii));
}
});