-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
63 lines (51 loc) · 1.17 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
60
61
62
63
package main
import (
"flag"
"log"
"os"
gbcore "github.com/briancain/gameboy-go/gbcore"
version "github.com/briancain/gameboy-go/version"
)
var (
CartridgePath string
Help bool
DebugOutput bool
)
func init() {
flag.BoolVar(&Help, "help", false, "Displays help")
flag.StringVar(&CartridgePath, "rom-file", "", "A path to a cartridge ROM file")
flag.BoolVar(&DebugOutput, "debug", false, "Displays debug output")
}
func startServer() error {
loadGBCore()
// TODO(briancain): spin up a server for display and accept inputs
return nil
}
func loadGBCore() error {
gb, err := gbcore.NewGameBoyCore(DebugOutput)
if err != nil {
log.Print("Failed to create new gbcore: ", err)
os.Exit(1)
}
if err := gb.Init(CartridgePath); err != nil {
log.Print("[ERROR] Failed to initialize new gbcore!\n", err)
os.Exit(1)
}
gb.Run()
return nil
}
func main() {
log.Print("Starting gameboy-go ... ")
version := version.Get()
log.Print("Version loaded: ", version)
flag.Parse()
if Help {
flag.Usage()
}
if CartridgePath == "" {
log.Println("! ERROR: You must define a cartridge ROM file path with '-rom-file'\n")
flag.Usage()
os.Exit(1)
}
startServer()
}