Move gpu module to a separate folder, to allow for later cleanup.

Also, get rid of "render" command


Former-commit-id: 7dd004f3ff8f55686665adead497ebae4f873379
This commit is contained in:
Michel Heily 2019-08-11 22:28:27 +03:00
parent edf2efcce5
commit 52ef793759
4 changed files with 0 additions and 62 deletions

View file

@ -6,7 +6,6 @@ use crate::core::GBAError;
use crate::disass::Disassembler; use crate::disass::Disassembler;
use super::palette_view::create_palette_view; use super::palette_view::create_palette_view;
use super::render_view::create_render_view;
use super::tile_view::create_tile_view; use super::tile_view::create_tile_view;
use super::{parser::Value, Debugger, DebuggerError, DebuggerResult}; use super::{parser::Value, Debugger, DebuggerError, DebuggerResult};
@ -28,7 +27,6 @@ pub enum Command {
Step(usize), Step(usize),
Continue, Continue,
Frame(usize), Frame(usize),
Render,
HexDump(Addr, u32), HexDump(Addr, u32),
Disass(DisassMode, Addr, u32), Disass(DisassMode, Addr, u32),
AddBreakpoint(Addr), AddBreakpoint(Addr),
@ -113,7 +111,6 @@ impl Command {
let end = PreciseTime::now(); let end = PreciseTime::now();
println!("that took {} seconds", start.to(end)); println!("that took {} seconds", start.to(end));
} }
Render => create_render_view(&debugger.gba),
HexDump(addr, nbytes) => { HexDump(addr, nbytes) => {
let bytes = debugger.gba.sysbus.get_bytes(addr..addr + nbytes); let bytes = debugger.gba.sysbus.get_bytes(addr..addr + nbytes);
hexdump::hexdump(&bytes); hexdump::hexdump(&bytes);
@ -310,7 +307,6 @@ impl Debugger {
"bl" => Ok(Command::ListBreakpoints), "bl" => Ok(Command::ListBreakpoints),
"q" | "quit" => Ok(Command::Quit), "q" | "quit" => Ok(Command::Quit),
"r" | "reset" => Ok(Command::Reset), "r" | "reset" => Ok(Command::Reset),
"rd" | "render" => Ok(Command::Render),
_ => Err(DebuggerError::InvalidCommand(command)), _ => Err(DebuggerError::InvalidCommand(command)),
} }
} }

View file

@ -13,7 +13,6 @@ mod command;
use command::Command; use command::Command;
mod palette_view; mod palette_view;
mod render_view;
mod tile_view; mod tile_view;
extern crate time; extern crate time;

View file

@ -1,57 +0,0 @@
use std::time::Duration;
use sdl2::event::Event;
use sdl2::pixels::Color;
use sdl2::rect::Point;
use crate::core::gba::GameBoyAdvance;
use crate::core::gpu::Gpu;
const SCREEN_WIDTH: u32 = Gpu::DISPLAY_WIDTH as u32;
const SCREEN_HEIGHT: u32 = Gpu::DISPLAY_HEIGHT as u32;
pub fn create_render_view(gba: &GameBoyAdvance) {
let sdl_context = sdl2::init().unwrap();
let video_subsystem = sdl_context.video().unwrap();
let window = video_subsystem
.window("RenderView", SCREEN_WIDTH, SCREEN_HEIGHT)
.position_centered()
.build()
.unwrap();
let mut canvas = window.into_canvas().build().unwrap();
let mut event_pump = sdl_context.event_pump().unwrap();
'running: loop {
for event in event_pump.poll_iter() {
match event {
Event::Quit { .. } => break 'running,
Event::MouseButtonDown { x, y, .. } => {
println!("({},{}) {:x}", x, y, x + y * (Gpu::DISPLAY_WIDTH as i32));
}
_ => {}
}
}
canvas.set_draw_color(Color::RGB(0xfa, 0xfa, 0xfa));
canvas.clear();
let io = gba.io.borrow();
for y in 0..Gpu::DISPLAY_HEIGHT {
for x in 0..Gpu::DISPLAY_WIDTH {
let index = (x as usize) + (y as usize) * (512 as usize);
let color = io.gpu.pixeldata[index];
let rgb24: Color = color.into();
canvas.set_draw_color(rgb24);
canvas
.draw_point(Point::from((x as i32, y as i32)))
.unwrap();
}
}
canvas.present();
::std::thread::sleep(Duration::new(0, 1_000_000_000u32 / 60));
}
}