-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
79 lines (63 loc) · 1.6 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package main
import (
"flag"
"fmt"
"os"
"github.com/paulloz/ohboi/config"
"github.com/paulloz/ohboi/gameboy"
"github.com/paulloz/ohboi/gui"
"github.com/paulloz/ohboi/ppu/colors"
)
var (
romFilename string
vramViewer bool
gameBoy *gameboy.GameBoy
breakpoint string
)
func init() {
conf := config.Get()
// Audio options
flag.BoolVar(&conf.Audio.Enabled, "audio", conf.Audio.Enabled, "emulate audio")
// Emulation options
flag.BoolVar(&conf.Emulation.SkipBoot, "skipboot", conf.Emulation.SkipBoot, "skip boot")
flag.StringVar(&romFilename, "rom", "", "path to the rom file")
// Video options
var theme string
flag.Float64Var(&conf.Video.Scale, "scale", conf.Video.Scale, "scale")
flag.StringVar(&theme, "theme", "", "color theme (sgb, green)")
switch theme {
case "green":
conf.Video.ColorTheme = colors.Greens
case "sgb":
conf.Video.ColorTheme = colors.SuperGameboy
}
flag.BoolVar(&vramViewer, "vramviewer", false, "enable VRAM viewer")
flag.StringVar(&breakpoint, "breakpoint", "", "breakpoint")
flag.Parse()
if len(romFilename) <= 0 {
fmt.Println("No cardbridge inserted...")
}
}
type Const struct {
value uint8
}
func (c *Const) Get() uint8 {
return c.value
}
func main() {
quitChan := make(chan int)
gameBoy = gameboy.NewGameBoy()
if breakpoint != "" {
gameboy.AddBreakpoint(breakpoint)
gameboy.StepByStep(false)
}
go func() {
if len(romFilename) > 0 {
gameBoy.InsertCartridgeFromFile(romFilename)
gameBoy.PowerOn(quitChan)
}
quitChan <- 0
}()
guiOptions := gui.GUIOptions{VRAMViewer: vramViewer}
os.Exit(gui.GUIStart(guiOptions, gameBoy, quitChan))
}