You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.2 KiB

  1. use clap::{App, Arg};
  2. use chip8::Chip8;
  3. struct SdlEmulator {
  4. w: usize,
  5. h: usize,
  6. zoom: usize,
  7. chip8: Chip8,
  8. }
  9. impl SdlEmulator {
  10. fn new(w: usize, h: usize, zoom: usize) -> SdlEmulator {
  11. let mut c = Chip8::new();
  12. SdlEmulator {
  13. w,
  14. h,
  15. zoom,
  16. chip8: c,
  17. }
  18. }
  19. fn draw_graphics(&mut self) {
  20. // TODO
  21. }
  22. fn set_keys(&mut self) {
  23. // TODO
  24. }
  25. }
  26. fn main() {
  27. let matches = App::new("chip8-rs")
  28. .version("0.0.1")
  29. .about("chip8 emulator")
  30. .arg(
  31. Arg::with_name("file")
  32. .short("f")
  33. .long("file")
  34. .takes_value(true)
  35. .help("File path of the rom to load"),
  36. )
  37. .get_matches();
  38. let file = matches.value_of("file");
  39. let file = match file {
  40. Some(file) => file,
  41. _ => panic!("Please specify file path of the rom to load"),
  42. };
  43. println!("{:?}", file);
  44. let mut e = SdlEmulator::new(64, 32, 8);
  45. loop {
  46. e.chip8.emulate_cycle();
  47. if e.chip8.draw_flag {
  48. e.draw_graphics();
  49. }
  50. e.set_keys();
  51. // delay
  52. }
  53. }