[cln] Remove check issues
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use crate::emu::graphics::GraphicsProcessor;
|
||||
use crate::emu::memory::{Memory, RamMemory};
|
||||
use crate::misc::endian::{read_big_endian_u24, write_big_endian_u24};
|
||||
use crate::misc::endian::{read_big_endian_u24};
|
||||
use crate::misc::result::EmulatorResult;
|
||||
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
use std::cell::{Ref, RefCell, RefMut};
|
||||
use std::cell::{Ref, RefCell};
|
||||
|
||||
use crate::misc::error::DeviceType::RAM;
|
||||
use crate::misc::error::EmulatorError;
|
||||
@@ -53,10 +53,6 @@ impl RamMemory {
|
||||
pub fn get_data_ref(&self) -> Ref<Box<[u8; MEM_LENGTH]>> {
|
||||
self.data.borrow()
|
||||
}
|
||||
pub fn get_data_ref_mut(&self) -> RefMut<Box<[u8; MEM_LENGTH]>> {
|
||||
self.data.borrow_mut()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
impl Memory for RamMemory {
|
||||
|
12
src/main.rs
12
src/main.rs
@@ -32,12 +32,12 @@ fn main() -> EmulatorResult<()> {
|
||||
let (file_bytes, x) = try_load_rom(&file_name)?;
|
||||
assert!(x < MEM_LENGTH);
|
||||
|
||||
let (mut canvas, mut event_pump, mut audio_queue) = initiate_sdl();
|
||||
let (mut canvas, mut event_pump, audio_queue) = initiate_sdl();
|
||||
|
||||
|
||||
let ram = RamMemory::try_from(file_bytes.as_slice())?;
|
||||
let graphics_processor = GraphicsProcessor::try_new(&ram)?;
|
||||
let mut audio_processor = AudioProcessor::try_new(&ram,&audio_queue)?;
|
||||
let mut audio_processor = AudioProcessor::try_new(&ram, &audio_queue)?;
|
||||
let mut keyboard = Keyboard::new(&ram);
|
||||
let cpu = Cpu::new(&ram, &graphics_processor);
|
||||
|
||||
@@ -109,10 +109,10 @@ fn get_key_index(p0: Keycode) -> Option<u8> {
|
||||
fn try_load_rom(file_name_option: &Option<String>) -> EmulatorResult<(Vec<u8>, usize)> {
|
||||
let mut file_bytes = vec![0u8; MEM_LENGTH];
|
||||
|
||||
let bytes_read = if let Some(file_name) = file_name_option{
|
||||
let bytes_read = if let Some(file_name) = file_name_option {
|
||||
let mut file_handle = File::open(file_name.as_str())?;
|
||||
file_handle.read(&mut file_bytes)?
|
||||
}else{
|
||||
} else {
|
||||
0
|
||||
};
|
||||
|
||||
@@ -126,12 +126,12 @@ fn initiate_sdl() -> (WindowCanvas, EventPump, AudioQueue<u8>) {
|
||||
let sdl_context = sdl2::init().unwrap();
|
||||
let video_subsystem = sdl_context.video().unwrap();
|
||||
let audio_subsystem = sdl_context.audio().unwrap();
|
||||
let wanted_spec = AudioSpecDesired{
|
||||
let wanted_spec = AudioSpecDesired {
|
||||
channels: Some(1),
|
||||
samples: Some(256),
|
||||
freq: Some(15360),
|
||||
};
|
||||
let audio_queue = audio_subsystem.open_queue::<u8,_>(None, &wanted_spec).unwrap();
|
||||
let audio_queue = audio_subsystem.open_queue::<u8, _>(None, &wanted_spec).unwrap();
|
||||
audio_queue.resume();
|
||||
|
||||
|
||||
|
@@ -7,10 +7,6 @@ pub fn read_big_endian_u24(input: &[u8; 3]) -> u32 {
|
||||
pub fn read_big_endian_u16(input: &[u8; 2]) -> u16 {
|
||||
BigEndian::read_u16(input)
|
||||
}
|
||||
/// Write 24-bit endian number into slice
|
||||
pub fn write_big_endian_u24(input: u32, output_slice: &mut [u8; 3]) {
|
||||
BigEndian::write_u24(output_slice, input);
|
||||
}
|
||||
|
||||
pub fn write_big_endian_u16(input: u16, output_slice: &mut [u8; 2]) {
|
||||
BigEndian::write_u16(output_slice, input);
|
||||
|
Reference in New Issue
Block a user