extern mod rsfml;

use rsfml::window::{ContextSettings, VideoMode, event};
use rsfml::graphics::{RenderWindow, sfClose};

mod cpu;

#[cfg(target_os="macos")]
#[start]
fn start(argc: int, argv: **u8) -> int {
    std::rt::start_on_main_thread(argc, argv, main)
}

fn main() {
    // Create the window of the application
    let setting = ContextSettings::default();
    let mut window = match RenderWindow::new(VideoMode::new_init(320, 160, 32), ~"rustchip", sfClose, &setting) {
        Some(window) => window,
        None => fail!("Cannot create a new Render Window.")
    };
    window.set_framerate_limit(60);
	let mut system = ::cpu::Cpu::new();

	system.load("/Users/derekguenther/Downloads/c8games/TETRIS");
	//system.print_mem();

    while window.is_open() {
        loop {
            match window.poll_event() {
                event::Closed => { window.close()}
                event::NoEvent => { break }
                _ => {}
            }
        }
		system.cycle();
        system.draw(&mut window);
    }

}
extern mod rsfml;

use rsfml::window::{ContextSettings, VideoMode};
use rsfml::graphics::{RenderWindow, sfClose};

mod cpu;

#[cfg(target_os="macos")]
#[start]
fn start(argc: int, argv: **u8) -> int {
    std::rt::start_on_main_thread(argc, argv, main)
}

fn main() {
    // Create the window of the application
    let setting = ContextSettings::default();
    let mut window = match RenderWindow::new(VideoMode::new_init(320, 160, 32), ~"SFML Example", sfClose, &setting) {
        Some(window) => window,
        None => fail!("Cannot create a new Render Window.")
    };

	let mut system = ::cpu::Cpu::new();

	system.load("/Users/derekguenther/Downloads/c8games/TETRIS");
	//system.print_mem();

    loop {
		system.cycle();
        system.draw(&mut window);
	}

}
--- 
+++ 
@@ -1,6 +1,6 @@
 extern mod rsfml;
 
-use rsfml::window::{ContextSettings, VideoMode};
+use rsfml::window::{ContextSettings, VideoMode, event};
 use rsfml::graphics::{RenderWindow, sfClose};
 
 mod cpu;
@@ -14,19 +14,26 @@
 fn main() {
     // Create the window of the application
     let setting = ContextSettings::default();
-    let mut window = match RenderWindow::new(VideoMode::new_init(320, 160, 32), ~"SFML Example", sfClose, &setting) {
+    let mut window = match RenderWindow::new(VideoMode::new_init(320, 160, 32), ~"rustchip", sfClose, &setting) {
         Some(window) => window,
         None => fail!("Cannot create a new Render Window.")
     };
-
+    window.set_framerate_limit(60);
 	let mut system = ::cpu::Cpu::new();
 
 	system.load("/Users/derekguenther/Downloads/c8games/TETRIS");
 	//system.print_mem();
 
-    loop {
+    while window.is_open() {
+        loop {
+            match window.poll_event() {
+                event::Closed => { window.close()}
+                event::NoEvent => { break }
+                _ => {}
+            }
+        }
 		system.cycle();
         system.draw(&mut window);
-	}
+    }
 
 }
Check for window events so we don't lock up the program
