-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
main.go
56 lines (41 loc) · 1.01 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
package main
import (
"flag"
"fmt"
"github.com/drhelius/demo-emulator/gb/core"
"github.com/drhelius/demo-emulator/gb/util"
"github.com/drhelius/demo-emulator/glfw"
"github.com/drhelius/demo-emulator/opengl"
)
var colorFrameBuffer [util.GbWidth * util.GbHeight * 4]uint8
func main() {
// init windowing system
glfw.Setup()
// init rendering system
opengl.Setup(colorFrameBuffer[:])
loadROM()
loop()
opengl.Teardown()
glfw.Teardown()
}
func loadROM() {
// get the rom path from a command line argument
romPathPtr := flag.String("rom", "", "rom path")
flag.Parse()
// tell the emulator to load the rom from a path
core.LoadROM(*romPathPtr)
}
func loop() {
fmt.Println("starting loop...")
// while the user doesn't close the window
for !glfw.WindowClosed() {
// run the emulation one frame
// it should be called 60 times in a second
core.RunToVBlank(colorFrameBuffer[:])
// render de results
opengl.Render()
// present the rendering in a window
// and update input
glfw.Update()
}
}