@@ -8,7 +8,7 @@ pub mod trace;
88pub mod frame;
99pub mod palette;
1010pub mod render;
11-
11+ pub mod controller ;
1212
1313use cpu:: * ;
1414
@@ -29,50 +29,52 @@ macro_rules! print_title {
2929 } ;
3030}
3131
32- pub fn run_nestest_and_capture ( ) -> Vec < String > {
33- let sdl_context = sdl2:: init ( ) . unwrap ( ) ;
34- let video_subsystem = sdl_context. video ( ) . unwrap ( ) ;
35- let window = video_subsystem
36- . window ( "Snake game" , ( 32.0 * 10.0 ) as u32 , ( 32.0 * 10.0 ) as u32 )
37- . position_centered ( )
38- . build ( )
39- . unwrap ( ) ;
4032
41- let mut canvas = window. into_canvas ( ) . present_vsync ( ) . build ( ) . unwrap ( ) ;
42- let mut event_pump = sdl_context. event_pump ( ) . unwrap ( ) ;
43- canvas. set_scale ( 3.0 , 3.0 ) . unwrap ( ) ;
33+ // Used with NES test, removing for now due to polishing state of ppu and controllers
34+ // pub fn run_nestest_and_capture() -> Vec<String> {
35+ // let sdl_context = sdl2::init().unwrap();
36+ // let video_subsystem = sdl_context.video().unwrap();
37+ // let window = video_subsystem
38+ // .window("Snake game", (32.0 * 10.0) as u32, (32.0 * 10.0) as u32)
39+ // .position_centered()
40+ // .build()
41+ // .unwrap();
4442
45- let creator = canvas. texture_creator ( ) ;
46- let mut texture = creator
47- . create_texture_target ( PixelFormatEnum :: RGB24 , 32 , 32 )
48- . unwrap ( ) ;
49- canvas. set_scale ( 3.0 , 3.0 ) . unwrap ( ) ;
50- let game_bytes = std:: fs:: read ( "nestest.nes" ) . unwrap ( ) ;
51- let rom = Rom :: new ( & game_bytes) . unwrap ( ) ;
52- let mut frame = Frame :: new ( ) ;
53- let bus = Bus :: new ( rom, move |ppu : & PPU |{
54- render:: render ( ppu, & mut frame) ;
55- texture. update ( None , & frame. data , 265 * 3 ) . unwrap ( ) ;
43+ // let mut canvas = window.into_canvas().present_vsync().build().unwrap();
44+ // let mut event_pump = sdl_context.event_pump().unwrap();
45+ // canvas.set_scale(3.0, 3.0).unwrap();
5646
57- canvas. copy ( & texture, None , None ) . unwrap ( ) ;
47+ // let creator = canvas.texture_creator();
48+ // let mut texture = creator
49+ // .create_texture_target(PixelFormatEnum::RGB24, 32, 32)
50+ // .unwrap();
51+ // canvas.set_scale(3.0, 3.0).unwrap();
52+ // let game_bytes = std::fs::read("nestest.nes").unwrap();
53+ // let rom = Rom::new(&game_bytes).unwrap();
54+ // let mut frame = Frame::new();
55+ // let bus = Bus::new(rom, move |ppu:&PPU|{
56+ // render::render(ppu, &mut frame);
57+ // texture.update(None, &frame.data, 265 * 3).unwrap();
5858
59- canvas. present ( ) ;
60- for event in event_pump. poll_iter ( ) {
61- match event {
62- Event :: Quit { .. }
63- | Event :: KeyDown {
64- keycode : Some ( Keycode :: Escape ) ,
65- ..
66- } => std:: process:: exit ( 0 ) ,
67- _ => { /* do nothing */ }
68- }
69- }
70- } ) ;
71- let mut cpu = CPU :: new ( bus) ;
72- cpu. reset ( ) ;
73- let mut output = Vec :: new ( ) ;
74- cpu. run_with_callback ( |cpu| {
75- output. push ( trace ( cpu) ) ;
76- } ) ;
77- output
78- }
59+ // canvas.copy(&texture, None, None).unwrap();
60+
61+ // canvas.present();
62+ // for event in event_pump.poll_iter() {
63+ // match event {
64+ // Event::Quit { .. }
65+ // | Event::KeyDown {
66+ // keycode: Some(Keycode::Escape),
67+ // ..
68+ // } => std::process::exit(0),
69+ // _ => { /* do nothing */ }
70+ // }
71+ // }
72+ // });
73+ // let mut cpu = CPU::new(bus);
74+ // cpu.reset();
75+ // let mut output = Vec::new();
76+ // cpu.run_with_callback(|cpu| {
77+ // output.push(trace(cpu));
78+ // });
79+ // output
80+ // }
0 commit comments