[ref] Cleanup

This commit is contained in:
2024-02-21 19:26:33 +05:30
parent b166e9c004
commit aff5103636
6 changed files with 12 additions and 7 deletions

View File

@@ -19,12 +19,12 @@ impl<'a> Keyboard<'a>{
pub fn key_down(&mut self,x:u8){ pub fn key_down(&mut self,x:u8){
self.bitflags |= 1<<x; self.bitflags |= 1<<x;
log::debug!("Key Down, keyboard state {}",self.bitflags); log::trace!("Key Down - state {}",self.bitflags);
self.dirty = true self.dirty = true
} }
pub fn key_up(&mut self,x:u8){ pub fn key_up(&mut self,x:u8){
self.bitflags &= !((1<<x) as u16); self.bitflags &= !((1<<x) as u16);
log::debug!("Key Up, keyboard state {}",self.bitflags); log::debug!("Key Up - state {}",self.bitflags);
self.dirty = true self.dirty = true
} }
pub fn flush_keyboard(&mut self)->EmulatorResult<()>{ pub fn flush_keyboard(&mut self)->EmulatorResult<()>{

View File

@@ -53,6 +53,7 @@ impl RamMemory {
pub fn get_data_ref(&self) -> Ref<Box<[u8; MEM_LENGTH]>> { pub fn get_data_ref(&self) -> Ref<Box<[u8; MEM_LENGTH]>> {
self.data.borrow() self.data.borrow()
} }
} }
impl Memory for RamMemory { impl Memory for RamMemory {

View File

@@ -21,7 +21,7 @@ impl<'a> Debug for SDLGraphicsAdapter<'a> {
impl<'a> SDLGraphicsAdapter<'a> { impl<'a> SDLGraphicsAdapter<'a> {
pub fn new(graphics_processor: &'a GraphicsProcessor) -> SDLGraphicsAdapter<'a> { pub fn new(graphics_processor: &'a GraphicsProcessor) -> SDLGraphicsAdapter<'a> {
let color_fb_vec = vec![0u8; DEVICE_FRAMEBUFFER_SIZE * 3].into_boxed_slice().try_into().expect("???"); let color_fb_vec = vec![0u8; DEVICE_FRAMEBUFFER_SIZE * 3].into_boxed_slice().try_into().expect("Failed conversion");
SDLGraphicsAdapter { SDLGraphicsAdapter {
color_fb: color_fb_vec, color_fb: color_fb_vec,
graphics_processor, graphics_processor,
@@ -37,8 +37,8 @@ impl<'a> SDLGraphicsAdapter<'a> {
let mut texture = texture_creator.create_texture(PixelFormatEnum::RGB24, TextureAccess::Streaming, 256, 256).expect("Failed to make texture"); let mut texture = texture_creator.create_texture(PixelFormatEnum::RGB24, TextureAccess::Streaming, 256, 256).expect("Failed to make texture");
texture.with_lock(None, |f, _i| { texture.with_lock(None, |f, _i| {
f.copy_from_slice(self.color_fb.as_ref()) f.copy_from_slice(self.color_fb.as_ref())
}).expect("TODO: panic message"); })?;
canvas.copy(&texture, None, None).expect("Failed to write texture"); canvas.copy(&texture, None, None)?;
Ok(()) Ok(())
} }

View File

@@ -29,7 +29,6 @@ fn main() -> EmulatorResult<()> {
let BytePusherArgs { file_name ,draw_scale} = BytePusherArgs::parse(); let BytePusherArgs { file_name ,draw_scale} = BytePusherArgs::parse();
SimpleLogger::new().with_level(LevelFilter::Info).env().init()?; SimpleLogger::new().with_level(LevelFilter::Info).env().init()?;
let (file_bytes, ..) = try_load_rom(&file_name)?; let (file_bytes, ..) = try_load_rom(&file_name)?;
let (mut canvas, mut event_pump, audio_queue) = initiate_sdl(draw_scale); let (mut canvas, mut event_pump, audio_queue) = initiate_sdl(draw_scale);

View File

@@ -36,6 +36,11 @@ impl From<SetLoggerError> for EmulatorError{
EmulatorError::OtherError(None,format!("Logger allocation failed! Error: {}",value)) EmulatorError::OtherError(None,format!("Logger allocation failed! Error: {}",value))
} }
} }
impl From<String> for EmulatorError{
fn from(value: String) -> Self {
EmulatorError::OtherError(None,value)
}
}