use GlyphBrush for more efficient rendering
This commit is contained in:
423
src/main.rs
423
src/main.rs
@@ -1,11 +1,11 @@
|
||||
#[macro_use] extern crate log;
|
||||
#[macro_use] extern crate failure;
|
||||
#[macro_use] extern crate lazy_static;
|
||||
extern crate simple_logger;
|
||||
extern crate phf;
|
||||
extern crate piston_window;
|
||||
|
||||
mod nes;
|
||||
mod render;
|
||||
|
||||
use std::path::Path;
|
||||
use piston_window::*;
|
||||
@@ -16,20 +16,19 @@ use nes::cartridge::*;
|
||||
use nes::disasm::*;
|
||||
use opengl_graphics::OpenGL;
|
||||
use log::Level;
|
||||
use piston_window::Text;
|
||||
use render::*;
|
||||
|
||||
use gfx_glyph::{Section, GlyphBrushBuilder,GlyphBrush};
|
||||
use gfx_device_gl::{Factory,Resources};
|
||||
|
||||
use gfx_glyph::{Section, GlyphBrushBuilder,GlyphBrush, Scale};
|
||||
use gfx_device_gl::{Resources,Factory};
|
||||
|
||||
// font options
|
||||
const FT_SIZE_PT: u32 = 6;
|
||||
const FT_SIZE_PX: f64 = 8.0;
|
||||
const FT_SIZE_PX: f32 = 11.0;
|
||||
const FT_COLOR_WHITE: [f32; 4] = [1.0; 4];
|
||||
const FT_COLOR_RED: [f32; 4] = [1.0, 0.0, 0.0, 1.0];
|
||||
const FT_COLOR_GREEN: [f32; 4] = [0.0, 1.0, 0.0, 1.0];
|
||||
const FT_LINE_DISTANCE: f64 = FT_SIZE_PX * 0.5;
|
||||
const FT_LINE_DISTANCE: f32 = FT_SIZE_PX * 0.5;
|
||||
lazy_static! {
|
||||
static ref FT_SCALE: Scale = Scale::uniform(FT_SIZE_PX);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
simple_logger::init_with_level(Level::Error).unwrap();
|
||||
@@ -39,7 +38,6 @@ fn main() {
|
||||
let cartridge = Cartridge::new(cartridge).unwrap();
|
||||
bus.insert_cartrige(cartridge);
|
||||
|
||||
|
||||
// Load little test program into ram
|
||||
// let test_prog: [Byte; 28] = [0xA2, 0x0A, 0x8E, 0x00, 0x00, 0xA2, 0x03, 0x8E, 0x01, 0x00, 0xAC, 0x00, 0x00, 0xA9,
|
||||
// 0x00, 0x18, 0x6D, 0x01, 0x00, 0x88, 0xD0, 0xFA, 0x8D, 0x02, 0x00, 0xEA, 0xEA, 0xEA];
|
||||
@@ -63,7 +61,6 @@ fn main() {
|
||||
// Create and reset CPU
|
||||
let mut cpu: CPU = CPU::new();
|
||||
cpu.find_pc_addr(&bus);
|
||||
|
||||
// cpu.reset(&bus);
|
||||
|
||||
// Prepare window and drawing resources
|
||||
@@ -73,27 +70,24 @@ fn main() {
|
||||
event_settings.max_fps = 60;
|
||||
event_settings.ups = 107400;
|
||||
let mut events = Events::new(event_settings);
|
||||
let ft: &[u8] = include_bytes!("../resources/fonts/PressStart2P.ttf");
|
||||
let mut glyphs = GlyphBrushBuilder::using_font_bytes(ft)
|
||||
.initial_cache_size((256, 256))
|
||||
// let mut glyphs = get_glyphs(&mut window);
|
||||
let font: &[u8] = include_bytes!("../resources/fonts/PressStart2P.ttf");
|
||||
let mut glyph_brush: GlyphBrush<Resources, Factory> = GlyphBrushBuilder::using_font_bytes(font)
|
||||
.initial_cache_size((1024, 1024))
|
||||
.build(window.factory.clone());
|
||||
let mut cpu_renderer = CPURenderer::new(&cpu);
|
||||
|
||||
|
||||
// Main loop
|
||||
let mut run = false;
|
||||
while let Some(event) = events.next(&mut window) {
|
||||
if let Some(_) = event.render_args() {
|
||||
cpu_renderer.update(&cpu);
|
||||
render(&mut window, &event, &mut glyphs, &mut cpu_renderer, &bus, &disasm);
|
||||
}
|
||||
if let Some(_) = event.update_args() {
|
||||
if run {
|
||||
cpu.clock(&mut bus);
|
||||
// while cpu.is_ahead() {
|
||||
// cpu.clock(&mut bus);
|
||||
// }
|
||||
}
|
||||
}
|
||||
if let Some(_) = event.render_args() {
|
||||
render(&mut window, &event, &mut glyph_brush, &cpu, &bus, &disasm);
|
||||
}
|
||||
if let Some(Button::Keyboard(key)) = event.press_args() {
|
||||
match key {
|
||||
Key::C => cpu.clock(&mut bus), // advance one clock
|
||||
@@ -123,231 +117,196 @@ fn main() {
|
||||
|
||||
fn render(window: &mut PistonWindow, event: &Event,
|
||||
glyphs: &mut GlyphBrush<Resources, Factory>,
|
||||
cpu_renderer: &mut CPURenderer, bus: &MemoryBus, disasm: &Disasm) {
|
||||
cpu: &CPU, bus: &MemoryBus, disasm: &Disasm) {
|
||||
window.draw_2d(event, |c, g, d| {
|
||||
clear([0.0, 0.0, 1.0, 1.0], g);
|
||||
|
||||
|
||||
// let debug_offset = [10.0, 10.0];
|
||||
// render_cpu(&c, g, glyphs, cpu, debug_offset);
|
||||
// render_disasm(&c, g, glyphs, disasm, cpu.regs.pc,
|
||||
// [debug_offset[0], debug_offset[1] + (7.0 * (FT_LINE_DISTANCE+FT_SIZE_PX))]);
|
||||
// render_memory(&c, g, glyphs, bus,
|
||||
// [debug_offset[0] + 300.0, debug_offset[1]]);
|
||||
let debug_offset = [10.0, 10.0];
|
||||
render_cpu(glyphs, cpu, debug_offset);
|
||||
render_disasm(glyphs, disasm, cpu.regs.pc,
|
||||
[debug_offset[0], debug_offset[1] + (7.0 * (FT_LINE_DISTANCE+FT_SIZE_PX))]);
|
||||
render_memory(glyphs, bus,
|
||||
[debug_offset[0] + 400.0, debug_offset[1]]);
|
||||
|
||||
|
||||
// glyphs.factory.encoder.flush(d);
|
||||
});
|
||||
cpu_renderer.draw(glyphs);
|
||||
glyphs.use_queue().draw(&mut window.encoder, &window.output_color);
|
||||
glyphs.use_queue().draw(&mut window.encoder, &window.output_color).unwrap();
|
||||
window.encoder.flush(&mut window.device);
|
||||
}
|
||||
|
||||
// fn render_cpu(c: &Context, g: &mut G2d, glyphs: &mut Glyphs, cpu: &CPU, offset: [f64; 2]) {
|
||||
// let mut transform = c.transform
|
||||
// .trans(offset[0], offset[1] + FT_SIZE_PX);
|
||||
// let text_white = Text::new_color(FT_COLOR_WHITE, FT_SIZE_PT);
|
||||
// let text_on = Text::new_color(FT_COLOR_GREEN, FT_SIZE_PT);
|
||||
// let text_off = Text::new_color(FT_COLOR_RED, FT_SIZE_PT);
|
||||
|
||||
// let mut text = text_white;
|
||||
// text.draw(
|
||||
// &"Flags:",
|
||||
// glyphs,
|
||||
// &c.draw_state,
|
||||
// transform,
|
||||
// g
|
||||
// ).unwrap();
|
||||
fn render_cpu(glyphs: &mut GlyphBrush<Resources, Factory>, cpu: &CPU, offset: [f32; 2]) {
|
||||
// draw flags
|
||||
let mut position = (offset[0], offset[1] + FT_SIZE_PX);
|
||||
glyphs.queue(Section {
|
||||
text: "Flags:",
|
||||
scale: *FT_SCALE,
|
||||
screen_position: position,
|
||||
color: FT_COLOR_WHITE,
|
||||
..Section::default()
|
||||
});
|
||||
|
||||
// transform = transform.trans(70.0, 0.0);
|
||||
// text = if cpu.get_flag(NEGATIVE) == 1 { text_on } else { text_off };
|
||||
// text.draw(
|
||||
// &"N",
|
||||
// glyphs,
|
||||
// &c.draw_state,
|
||||
// transform,
|
||||
// g
|
||||
// ).unwrap();
|
||||
// transform = transform.trans(16.0, 0.0);
|
||||
// text = if cpu.get_flag(OVERFLOW) == 1 { text_on } else { text_off };
|
||||
// text.draw(
|
||||
// &"V",
|
||||
// glyphs,
|
||||
// &c.draw_state,
|
||||
// transform,
|
||||
// g
|
||||
// ).unwrap();
|
||||
// transform = transform.trans(16.0, 0.0);
|
||||
// text_white.draw(
|
||||
// &"-",
|
||||
// glyphs,
|
||||
// &c.draw_state,
|
||||
// transform,
|
||||
// g
|
||||
// ).unwrap();
|
||||
// transform = transform.trans(16.0, 0.0);
|
||||
// text = if cpu.get_flag(BREAK) == 1 { text_on } else { text_off };
|
||||
// text.draw(
|
||||
// &"B",
|
||||
// glyphs,
|
||||
// &c.draw_state,
|
||||
// transform,
|
||||
// g
|
||||
// ).unwrap();
|
||||
// transform = transform.trans(16.0, 0.0);
|
||||
// text = if cpu.get_flag(DECIMAL) == 1 { text_on } else { text_off };
|
||||
// text.draw(
|
||||
// &"D",
|
||||
// glyphs,
|
||||
// &c.draw_state,
|
||||
// transform,
|
||||
// g
|
||||
// ).unwrap();
|
||||
// transform = transform.trans(16.0, 0.0);
|
||||
// text = if cpu.get_flag(IRQ) == 1 { text_on } else { text_off };
|
||||
// text.draw(
|
||||
// &"I",
|
||||
// glyphs,
|
||||
// &c.draw_state,
|
||||
// transform,
|
||||
// g
|
||||
// ).unwrap();
|
||||
// transform = transform.trans(16.0, 0.0);
|
||||
// text = if cpu.get_flag(ZERO) == 1 { text_on } else { text_off };
|
||||
// text.draw(
|
||||
// &"Z",
|
||||
// glyphs,
|
||||
// &c.draw_state,
|
||||
// transform,
|
||||
// g
|
||||
// ).unwrap();
|
||||
// transform = transform.trans(16.0, 0.0);
|
||||
// text = if cpu.get_flag(CARRY) == 1 { text_on } else { text_off };
|
||||
// text.draw(
|
||||
// &"C",
|
||||
// glyphs,
|
||||
// &c.draw_state,
|
||||
// transform,
|
||||
// g
|
||||
// ).unwrap();
|
||||
// transform = transform.trans(16.0, 0.0);
|
||||
// text_white.draw(
|
||||
// &format!("({:#4x})", cpu.regs.flags),
|
||||
// glyphs,
|
||||
// &c.draw_state,
|
||||
// transform,
|
||||
// g
|
||||
// ).unwrap();
|
||||
position.0 += 70.0;
|
||||
let color = if cpu.get_flag(NEGATIVE) == 1 { FT_COLOR_GREEN } else { FT_COLOR_RED };
|
||||
glyphs.queue(Section {
|
||||
text: "N",
|
||||
scale: *FT_SCALE,
|
||||
screen_position: position,
|
||||
color: color,
|
||||
..Section::default()
|
||||
});
|
||||
position.0 += 16.0;
|
||||
let color = if cpu.get_flag(OVERFLOW) == 1 { FT_COLOR_GREEN } else { FT_COLOR_RED };
|
||||
glyphs.queue(Section {
|
||||
text: "V",
|
||||
scale: *FT_SCALE,
|
||||
screen_position: position,
|
||||
color: color,
|
||||
..Section::default()
|
||||
});
|
||||
position.0 += 16.0;
|
||||
let color = FT_COLOR_WHITE;
|
||||
glyphs.queue(Section {
|
||||
text: "-",
|
||||
scale: *FT_SCALE,
|
||||
screen_position: position,
|
||||
color: color,
|
||||
..Section::default()
|
||||
});
|
||||
position.0 += 16.0;
|
||||
let color = if cpu.get_flag(BREAK) == 1 { FT_COLOR_GREEN } else { FT_COLOR_RED };
|
||||
glyphs.queue(Section {
|
||||
text: "B",
|
||||
scale: *FT_SCALE,
|
||||
screen_position: position,
|
||||
color: color,
|
||||
..Section::default()
|
||||
});
|
||||
position.0 += 16.0;
|
||||
let color = if cpu.get_flag(DECIMAL) == 1 { FT_COLOR_GREEN } else { FT_COLOR_RED };
|
||||
glyphs.queue(Section {
|
||||
text: "D",
|
||||
scale: *FT_SCALE,
|
||||
screen_position: position,
|
||||
color: color,
|
||||
..Section::default()
|
||||
});
|
||||
position.0 += 16.0;
|
||||
let color = if cpu.get_flag(IRQ) == 1 { FT_COLOR_GREEN } else { FT_COLOR_RED };
|
||||
glyphs.queue(Section {
|
||||
text: "I",
|
||||
scale: *FT_SCALE,
|
||||
screen_position: position,
|
||||
color: color,
|
||||
..Section::default()
|
||||
});
|
||||
position.0 += 16.0;
|
||||
let color = if cpu.get_flag(ZERO) == 1 { FT_COLOR_GREEN } else { FT_COLOR_RED };
|
||||
glyphs.queue(Section {
|
||||
text: "Z",
|
||||
scale: *FT_SCALE,
|
||||
screen_position: position,
|
||||
color: color,
|
||||
..Section::default()
|
||||
});
|
||||
position.0 += 16.0;
|
||||
let color = if cpu.get_flag(CARRY) == 1 { FT_COLOR_GREEN } else { FT_COLOR_RED };
|
||||
glyphs.queue(Section {
|
||||
text: "C",
|
||||
scale: *FT_SCALE,
|
||||
screen_position: position,
|
||||
color: color,
|
||||
..Section::default()
|
||||
});
|
||||
|
||||
let cpu_register_texts = [
|
||||
&format!("A: {0:#x} ({0})", cpu.regs.a),
|
||||
&format!("X: {0:#x} ({0})", cpu.regs.x),
|
||||
&format!("Y: {0:#x} ({0})", cpu.regs.y),
|
||||
&format!("Stack P: {0:#x} ({0})", cpu.regs.sp),
|
||||
&format!("Program P: {:#x}", cpu.regs.pc),
|
||||
];
|
||||
|
||||
// let cpu_register_texts = [
|
||||
// &format!("A: {0:#x} ({0})", cpu.regs.a),
|
||||
// &format!("X: {0:#x} ({0})", cpu.regs.x),
|
||||
// &format!("Y: {0:#x} ({0})", cpu.regs.y),
|
||||
// &format!("Stack P: {0:#x} ({0})", cpu.regs.sp),
|
||||
// &format!("Program P: {:#x}", cpu.regs.pc),
|
||||
// ];
|
||||
for (i, &text) in cpu_register_texts.iter().enumerate() {
|
||||
let y_offset = (i+2) as f32 * (FT_LINE_DISTANCE + FT_SIZE_PX);
|
||||
let position = (offset[0], offset[1] + y_offset);
|
||||
glyphs.queue(Section {
|
||||
text: text,
|
||||
scale: *FT_SCALE,
|
||||
screen_position: position,
|
||||
color: FT_COLOR_WHITE,
|
||||
..Section::default()
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// for (i, &text) in cpu_register_texts.iter().enumerate() {
|
||||
// let y_offset = (i+2) as f64 * (FT_LINE_DISTANCE + FT_SIZE_PX);
|
||||
// let transform = c.transform.trans(offset[0], offset[1] + y_offset);
|
||||
// text_white.draw(
|
||||
// &text,
|
||||
// glyphs,
|
||||
// &c.draw_state,
|
||||
// transform,
|
||||
// g
|
||||
// ).unwrap();
|
||||
// }
|
||||
// }
|
||||
fn render_disasm(glyphs: &mut GlyphBrush<Resources, Factory>,
|
||||
disasm: &Disasm, pc: Addr, offset: [f32; 2]) {
|
||||
let pc_position = disasm.addresses.iter().position(|&pos| pos == pc);
|
||||
if let None = pc_position {
|
||||
return;
|
||||
}
|
||||
let pc_position = pc_position.unwrap();
|
||||
let lines_above_below: usize = 12;
|
||||
|
||||
// fn render_disasm(c: &Context, g: &mut G2d, glyphs: &mut Glyphs, disasm: &Disasm, pc: Addr, offset: [f64; 2]) {
|
||||
// let pc_position = disasm.addresses.iter().position(|&pos| pos == pc);
|
||||
// if let None = pc_position {
|
||||
// return;
|
||||
// }
|
||||
// let pc_position = pc_position.unwrap();
|
||||
// let lines_above_below: usize = 12;
|
||||
let start = if (pc_position as i32 - lines_above_below as i32) < 0 {
|
||||
0
|
||||
} else {
|
||||
pc_position - lines_above_below
|
||||
};
|
||||
|
||||
// let start = if (pc_position as i32 - lines_above_below as i32) < 0 {
|
||||
// 0
|
||||
// } else {
|
||||
// pc_position - lines_above_below
|
||||
// };
|
||||
let text_position_x = offset[0];
|
||||
let mut text_position_y = offset[1];
|
||||
for i in (start..disasm.addresses.len()).take(lines_above_below*2+1) {
|
||||
let txt = &disasm.instructions[i];
|
||||
text_position_y += FT_LINE_DISTANCE + FT_SIZE_PX;
|
||||
let color = if i == pc_position {
|
||||
FT_COLOR_RED
|
||||
} else {
|
||||
FT_COLOR_WHITE
|
||||
};
|
||||
glyphs.queue(Section {
|
||||
text: txt,
|
||||
scale: *FT_SCALE,
|
||||
screen_position: (text_position_x, text_position_y),
|
||||
color: color,
|
||||
..Section::default()
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// let mut transform = c.transform.trans(offset[0], offset[1]);
|
||||
// let text_current = Text::new_color(FT_COLOR_RED, FT_SIZE_PT);
|
||||
// let text_other = Text::new_color(FT_COLOR_WHITE, FT_SIZE_PT);
|
||||
|
||||
// for i in (start..disasm.addresses.len()).take(lines_above_below*2+1) {
|
||||
// let addr = disasm.addresses[i];
|
||||
// let txt = &disasm.instructions[i];
|
||||
|
||||
// transform = transform.trans(0.0, FT_LINE_DISTANCE + FT_SIZE_PX);
|
||||
// let text = if addr == pc {
|
||||
// text_current
|
||||
// } else {
|
||||
// text_other
|
||||
// };
|
||||
// text.draw(
|
||||
// txt,
|
||||
// glyphs,
|
||||
// &c.draw_state,
|
||||
// transform,
|
||||
// g
|
||||
// ).unwrap();
|
||||
// }
|
||||
fn render_memory(glyphs: &mut GlyphBrush<Resources, Factory>, bus: &MemoryBus, offset: [f32; 2]) {
|
||||
let mut position_y = (offset[0], offset[1]);
|
||||
for page in (0x0100..0x01FF).step_by(16) {
|
||||
position_y.1 += FT_LINE_DISTANCE + FT_SIZE_PX;
|
||||
let mut line = format!("{:#06x}:", page);
|
||||
(0u16..16u16).map(|offset| offset + page)
|
||||
.map(|addr| bus.readb(addr))
|
||||
.map(|val| format!(" {:02x}", val))
|
||||
.for_each(|s| line.push_str(&s));
|
||||
glyphs.queue(Section {
|
||||
text: &line,
|
||||
scale: *FT_SCALE,
|
||||
screen_position: position_y,
|
||||
color: FT_COLOR_WHITE,
|
||||
..Section::default()
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// }
|
||||
|
||||
// fn render_memory(c: &Context, g: &mut G2d, glyphs: &mut Glyphs, bus: &MemoryBus, offset: [f64; 2]) {
|
||||
// let mut transform_y = c.transform.trans(offset[0], offset[1]);
|
||||
// let text = Text::new_color(FT_COLOR_WHITE, FT_SIZE_PT);
|
||||
// for page in (0x0000..0x01FF).step_by(16) {
|
||||
// transform_y = transform_y.trans(0.0, FT_LINE_DISTANCE+FT_SIZE_PX);
|
||||
// text.draw(
|
||||
// &format!("{:#06x}:", page),
|
||||
// glyphs,
|
||||
// &c.draw_state,
|
||||
// transform_y,
|
||||
// g
|
||||
// ).unwrap();
|
||||
// let mut transform_x = transform_y.trans(40.0, 0.0);
|
||||
// for offset in 0u16..16u16 {
|
||||
// transform_x = transform_x.trans(20.0, 0.0);
|
||||
// let addr = page + offset;
|
||||
// text.draw(
|
||||
// &format!("{:02x}", bus.readb(addr)),
|
||||
// glyphs,
|
||||
// &c.draw_state,
|
||||
// transform_x,
|
||||
// g
|
||||
// ).unwrap();
|
||||
// }
|
||||
// }
|
||||
|
||||
// transform_y = transform_y.trans(0.0, (FT_LINE_DISTANCE+FT_SIZE_PX) * 1.5);
|
||||
// for page in (0x6000..0x6030).step_by(16) {
|
||||
// transform_y = transform_y.trans(0.0, (FT_LINE_DISTANCE+FT_SIZE_PX));
|
||||
// text.draw(
|
||||
// &format!("{:#06x}:", page),
|
||||
// glyphs,
|
||||
// &c.draw_state,
|
||||
// transform_y,
|
||||
// g
|
||||
// ).unwrap();
|
||||
// let mut transform_x = transform_y.trans(40.0, 0.0);
|
||||
// for offset in 0u16..16u16 {
|
||||
// transform_x = transform_x.trans(20.0, 0.0);
|
||||
// let addr = page + offset;
|
||||
// text.draw(
|
||||
// &format!("{:02x}", bus.readb(addr)),
|
||||
// glyphs,
|
||||
// &c.draw_state,
|
||||
// transform_x,
|
||||
// g
|
||||
// ).unwrap();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
position_y.1 += FT_LINE_DISTANCE+FT_SIZE_PX * 1.5;
|
||||
for page in (0x6000..0x60FF).step_by(16) {
|
||||
position_y.1 += FT_LINE_DISTANCE + FT_SIZE_PX;
|
||||
let mut line = format!("{:#06x}:", page);
|
||||
(0u16..16u16).map(|offset| offset + page)
|
||||
.map(|addr| bus.readb(addr))
|
||||
.map(|val| format!(" {:02x}", val))
|
||||
.for_each(|s| line.push_str(&s));
|
||||
glyphs.queue(Section {
|
||||
text: &line,
|
||||
scale: *FT_SCALE,
|
||||
screen_position: position_y,
|
||||
color: FT_COLOR_WHITE,
|
||||
..Section::default()
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
use gfx_device_gl::Factory;
|
||||
use gfx_device_gl::Resources;
|
||||
use crate::nes::cpu::CPU;
|
||||
use gfx_glyph::{Section,GlyphBrush};
|
||||
|
||||
pub trait Draw {
|
||||
fn draw(&mut self, glyphs: &mut GlyphBrush<Resources,Factory>);
|
||||
}
|
||||
|
||||
pub struct CPURenderer<'a> {
|
||||
registers_text: String,
|
||||
registers_section: Section<'a>,
|
||||
}
|
||||
|
||||
impl<'a> CPURenderer<'a> {
|
||||
pub fn new(cpu: &CPU) -> Self {
|
||||
let registers_text = String::from("A: 0x00 (000)");
|
||||
let registers_section = Section {
|
||||
text: "xxx",
|
||||
screen_position: (100.0, 100.0),
|
||||
color: [1.0; 4],
|
||||
..Section::default()
|
||||
};
|
||||
CPURenderer {
|
||||
registers_text: registers_text,
|
||||
registers_section: registers_section,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> CPURenderer<'a> {
|
||||
pub fn update(&mut self, cpu: &CPU) {
|
||||
self.registers_text.replace_range(3..7, "txtx");
|
||||
// self.registers_section.text = &self.registers_text;
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Draw for CPURenderer<'a> {
|
||||
fn draw(&mut self, glyphs: &mut GlyphBrush<Resources,Factory>) {
|
||||
glyphs.queue(self.registers_section);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user