-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
81 lines (67 loc) · 1.97 KB
/
main.go
File metadata and controls
81 lines (67 loc) · 1.97 KB
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
80
81
package main
import (
"fmt"
"github.com/veandco/go-sdl2/sdl"
"github.com/go-gl/gl/v4.6-core/gl"
"github.com/Koops0/GPSXE/bios"
"github.com/Koops0/GPSXE/biosmap"
"github.com/Koops0/GPSXE/gpu"
)
func main() {
bios, err := bios.New("SCPH1001.bin") //will switch to SCPH7501.bin later
if err != nil {
fmt.Println("Error reading file")
return
}
if err := sdl.Init(sdl.INIT_VIDEO); err != nil {
fmt.Println("Error initializing SDL:", err)
return
}
defer sdl.Quit()
// Create an SDL renderer for the window
renderer := gpu.Renderer{}.New()
gpu := gpu.GPU{}.New(renderer)
inter := biosmap.Interconnect{}.New(bios, gpu)
cpu := &CPU{}
cpu.New(inter)
fmt.Println(cpu.reg[0])
for{
for i := 0; i < 1000000; i++ {
cpu.Run_next()
}
for event := sdl.PollEvent(); event != nil; event = sdl.PollEvent() {
switch event.(type) {
case *sdl.QuitEvent:
return
}
}
}
}
func CheckForErrors() {
fatal := false
for {
buffer := make([]byte, 4096)
severity := uint32(0)
source := uint32(0)
mSize := int32(0)
mtype := uint32(0)
id := uint32(0)
count := gl.GetDebugMessageLog(1, int32(len(buffer)), &source, &mtype, &id, &severity, &mSize, &buffer[0])
if count == 0 {
break
}
// Assuming mSize is the actual message length, trim the buffer to mSize
message := string(buffer[:mSize])
fmt.Printf("OpenGL [source: %d | type: %d | id: 0x%x | severity: %d] %s\n", source, mtype, id, severity, message)
// Example severity check (adjust according to your severity values)
if severity == gl.DEBUG_SEVERITY_HIGH {
fatal = true
fmt.Println("Fatal OpenGL error encountered.")
break // or handle fatal error as needed
}
}
if fatal {
// Handle fatal error, e.g., clean up and exit or throw panic
panic("Fatal OpenGL error encountered.")
}
}