-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
59 lines (48 loc) · 1.07 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package main
import (
"flag"
"log"
"os"
"runtime/pprof"
"github.com/bovarysme/bmo/beemo"
"github.com/bovarysme/bmo/debug"
)
var debugFlag bool
var screenScale int
var cpuprofile string
var bootromPath string
var romPath string
func init() {
flag.BoolVar(&debugFlag, "debug", false, "run the emulator in debug mode")
flag.IntVar(&screenScale, "scale", 2, "screen scale factor")
flag.StringVar(&cpuprofile, "cpuprofile", "", "write a CPU profile")
flag.StringVar(&romPath, "rom", "", "path to the ROM file")
flag.StringVar(&bootromPath, "bootrom", "roms/bootrom.gb", "path to the bootrom file")
flag.Parse()
}
func main() {
if cpuprofile != "" {
file, err := os.Create(cpuprofile)
if err != nil {
log.Fatal(err)
}
err = pprof.StartCPUProfile(file)
if err != nil {
log.Fatal(err)
}
defer pprof.StopCPUProfile()
}
bmo, err := beemo.NewBMO(bootromPath, romPath, screenScale)
if err != nil {
log.Fatal(err)
}
if debugFlag {
debugger := debug.NewDebugger(bmo)
err = debugger.Run()
} else {
err = bmo.Run()
}
if err != nil {
log.Fatal(err)
}
}