Created
September 13, 2013 00:52
-
-
Save scottferg/6545730 to your computer and use it in GitHub Desktop.
This file contains 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 characters
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 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment