Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ablakey committed May 31, 2020
1 parent ca632fb commit e31674c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/chip8.rs
Expand Up @@ -565,7 +565,7 @@ mod tests {
#[test]
fn test_load_rom() {
let mut machine = Chip8::init();
machine.load_rom(&String::from("roms/maze.c8")).unwrap();
machine.load_rom(&String::from("roms/MAZE")).unwrap();
let start = Chip8::ADDRESS_ROM;
let end = start + TEST_ROM_BYTES.len();
assert_eq!(&machine.memory[start..end], TEST_ROM_BYTES);
Expand Down
24 changes: 5 additions & 19 deletions src/main.rs
Expand Up @@ -22,15 +22,18 @@ struct Emulator {
}

impl Emulator {
const SCREEN_ZOOM: u32 = 20; // Multiple to zoom screen by.
const TONE: u32 = 440; // Pitch for beep sound.

fn init(path: &String) -> Result<Self, String> {
// CLI debugging.
let debugger = Debugger::init();

// SDL-based I/O.
let sdl_context = sdl2::init()?;
let input = Input::init(&sdl_context)?;
let screen = Screen::create(&sdl_context, 20)?;
let audio = Audio::init(440); // tone Hz.
let screen = Screen::create(&sdl_context, Emulator::SCREEN_ZOOM)?;
let audio = Audio::init(Emulator::TONE);

// The emulated Chip8 state. This includes memory, registers, counters, timers, etc.
let mut state = Chip8::init();
Expand Down Expand Up @@ -63,13 +66,6 @@ impl Emulator {
/// Loop forever at 500Hz.
/// Handles input, ticks the Chip8 CPU, draws graphics and plays audio.
pub fn run_forever(&mut self) {
// let device = rodio::default_output_device().unwrap();
// let sink = Sink::new(&device);

// // Add a dummy source of the sake of the example.
// let source = SineWave::new(440);
// sink.append(source);

'program: loop {
// Emulator and Chip8 I/O.
match self.input.get_event() {
Expand Down Expand Up @@ -132,16 +128,6 @@ impl Debugger {
}

fn main() {
// let device = rodio::default_output_device().unwrap();
// let _ = play_sound(&device);

// let device = rodio::default_output_device().unwrap();
// let file = std::fs::File::open("./src/beep.wav").unwrap();
// let beep1 = rodio::play_once(&device, BufReader::new(file)).unwrap();
// beep1.set_volume(0.2);
// println!("Started beep1");

// Get arguments.
let args: Vec<String> = env::args().collect();
let filename = &args[1];

Expand Down

0 comments on commit e31674c

Please sign in to comment.