コード例 #1
0
ファイル: main.go プロジェクト: remogatto/sms
func main() {
	verbose := flag.Bool("verbose", false, "verbose mode")
	debug := flag.Bool("debug", false, "debug mode")
	fullScreen := flag.Bool("fullscreen", false, "go fullscreen")
	cpuProfile := flag.String("cpuprofile", "", "write cpu profile to file")
	help := flag.Bool("help", false, "Show usage")
	flag.Usage = usage
	flag.Parse()

	if *help {
		usage()
		return
	}

	if *cpuProfile != "" {
		f, err := os.Create(*cpuProfile)
		if err != nil {
			log.Fatal(err)
		}
		pprof.StartCPUProfile(f)
		defer pprof.StopCPUProfile()
	}

	application.Verbose = *verbose
	application.Debug = *debug

	if sdl.Init(sdl.INIT_EVERYTHING) != 0 {
		log.Fatal(sdl.GetError())
	}

	screen := sms.NewSDL2xScreen(*fullScreen)
	sdlLoop := sms.NewSDLLoop(screen)
	emulatorLoop := newEmulatorLoop(sdlLoop)
	if emulatorLoop == nil {
		usage()
		return
	}
	cpuProfiling := *cpuProfile != ""
	commandLoop := newCommandLoop(emulatorLoop, sdlLoop, cpuProfiling)
	inputLoop := sms.NewInputLoop(emulatorLoop.sms)

	application.Register("Emulator loop", emulatorLoop)
	application.Register("Command loop", commandLoop)
	application.Register("SDL render loop", sdlLoop)
	application.Register("SDL input loop", inputLoop)

	exitCh := make(chan bool)
	application.Run(exitCh)
	<-exitCh
	sdl.Quit()
}
コード例 #2
0
ファイル: main.go プロジェクト: remogatto/prettytest
func main() {
	verbose := flag.Bool("verbose", false, "Verbose mode")
	help := flag.Bool("help", false, "Show usage")
	flag.Usage = usage
	flag.Parse()

	initialPath := flag.Arg(0)
	if initialPath == "" {
		initialPath = "./"
	}

	if _, err := os.Stat(initialPath); err != nil {
		application.Fatal(err.Error())
	}

	application.Verbose = *verbose
	if *help {
		usage()
		return
	}
	watcherLoop := newWatcherLoop(initialPath)
	application.Register("Watcher Loop", watcherLoop)
	application.InstallSignalHandler(&sigterm{paths: watcherLoop.paths})
	exitCh := make(chan bool)
	application.Run()
	<-exitCh
}
コード例 #3
0
ファイル: main.go プロジェクト: Sas0ri/sms
func main() {
	verbose := flag.Bool("verbose", false, "verbose mode")
	debug := flag.Bool("debug", false, "debug mode")
	fullScreen := flag.Bool("fullscreen", false, "go fullscreen")
	help := flag.Bool("help", false, "Show usage")
	flag.Usage = usage
	flag.Parse()

	if *help {
		usage()
		return
	}

	application.Verbose = *verbose
	application.Debug = *debug

	if sdl.Init(sdl.INIT_EVERYTHING) != 0 {
		log.Fatal(sdl.GetError())
	}

	screen := newSDL2xScreen(*fullScreen)
	sdlLoop := newSDLLoop(screen)
	emulatorLoop := newEmulatorLoop(sdlLoop)
	if emulatorLoop == nil {
		usage()
		return
	}
	commandLoop := newCommandLoop(emulatorLoop, sdlLoop)
	inputLoop := newInputLoop(emulatorLoop.sms)

	application.Register("Emulator loop", emulatorLoop)
	application.Register("Command loop", commandLoop)
	application.Register("SDL render loop", sdlLoop)
	application.Register("SDL input loop", inputLoop)

	exitCh := make(chan bool)
	application.Run(exitCh)
	<-exitCh
	sdl.Quit()
}