From 52ef7937593771ded213ebba8e6c3e471d1a07ed Mon Sep 17 00:00:00 2001 From: Michel Heily Date: Sun, 11 Aug 2019 22:28:27 +0300 Subject: [PATCH] Move gpu module to a separate folder, to allow for later cleanup. Also, get rid of "render" command Former-commit-id: 7dd004f3ff8f55686665adead497ebae4f873379 --- src/core/{gpu.rs => gpu/mod.rs} | 0 src/debugger/command.rs | 4 --- src/debugger/mod.rs | 1 - src/debugger/render_view.rs | 57 --------------------------------- 4 files changed, 62 deletions(-) rename src/core/{gpu.rs => gpu/mod.rs} (100%) delete mode 100644 src/debugger/render_view.rs diff --git a/src/core/gpu.rs b/src/core/gpu/mod.rs similarity index 100% rename from src/core/gpu.rs rename to src/core/gpu/mod.rs diff --git a/src/debugger/command.rs b/src/debugger/command.rs index 6cd2ca0..a6f537b 100644 --- a/src/debugger/command.rs +++ b/src/debugger/command.rs @@ -6,7 +6,6 @@ use crate::core::GBAError; use crate::disass::Disassembler; use super::palette_view::create_palette_view; -use super::render_view::create_render_view; use super::tile_view::create_tile_view; use super::{parser::Value, Debugger, DebuggerError, DebuggerResult}; @@ -28,7 +27,6 @@ pub enum Command { Step(usize), Continue, Frame(usize), - Render, HexDump(Addr, u32), Disass(DisassMode, Addr, u32), AddBreakpoint(Addr), @@ -113,7 +111,6 @@ impl Command { let end = PreciseTime::now(); println!("that took {} seconds", start.to(end)); } - Render => create_render_view(&debugger.gba), HexDump(addr, nbytes) => { let bytes = debugger.gba.sysbus.get_bytes(addr..addr + nbytes); hexdump::hexdump(&bytes); @@ -310,7 +307,6 @@ impl Debugger { "bl" => Ok(Command::ListBreakpoints), "q" | "quit" => Ok(Command::Quit), "r" | "reset" => Ok(Command::Reset), - "rd" | "render" => Ok(Command::Render), _ => Err(DebuggerError::InvalidCommand(command)), } } diff --git a/src/debugger/mod.rs b/src/debugger/mod.rs index 568298d..66a4694 100644 --- a/src/debugger/mod.rs +++ b/src/debugger/mod.rs @@ -13,7 +13,6 @@ mod command; use command::Command; mod palette_view; -mod render_view; mod tile_view; extern crate time; diff --git a/src/debugger/render_view.rs b/src/debugger/render_view.rs deleted file mode 100644 index b3ea2dd..0000000 --- a/src/debugger/render_view.rs +++ /dev/null @@ -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)); - } -}