Created
September 13, 2013 00:52
-
-
Save scottferg/6545730 to your computer and use it in GitHub Desktop.
Revisions
-
scottferg created this gist
Sep 13, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,56 @@ package main import ( "flag" "fmt" "github.com/scottferg/Fergulator/nes" "os" "runtime" "runtime/pprof" ) var ( running = true videoOut Video audioOut *Audio cpuprofile = flag.String("cprof", "", "write cpu profile to file") ) func main() { flag.Parse() if *cpuprofile != "" { f, err := os.Create(*cpuprofile) if err != nil { fmt.Println(err) } pprof.StartCPUProfile(f) defer pprof.StopCPUProfile() } else if false { runtime.GOMAXPROCS(runtime.NumCPU()) } videoTick, gamename, err := nes.Init(GetKey) if err != nil { fmt.Println(err) } videoOut.Init(videoTick, gamename) audioOut = NewAudio() defer audioOut.Close() // Main runloop, in a separate goroutine so that // the video rendering can happen on this one go nes.RunSystem() // This needs to happen on the main thread for OSX runtime.LockOSThread() defer videoOut.Close() videoOut.Render() return }