mirror of
https://github.com/macocianradu/goboy.git
synced 2026-03-18 21:10:07 +00:00
basic memory and cpu
This commit is contained in:
39
gameboy.go
Normal file
39
gameboy.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"radu.macocian.me/goboy/cpu"
|
||||
"radu.macocian.me/goboy/errorHandling"
|
||||
"radu.macocian.me/goboy/memory"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func main() {
|
||||
if len(os.Args) < 2 {
|
||||
fmt.Println("Missing rom, please provide a rom")
|
||||
return
|
||||
}
|
||||
|
||||
checkExtension(os.Args[1])
|
||||
|
||||
data, err := os.ReadFile(os.Args[1])
|
||||
check(err)
|
||||
|
||||
startMem := 1000
|
||||
memory.WriteAll(startMem, data)
|
||||
cpu.Execute(startMem)
|
||||
}
|
||||
|
||||
func checkExtension(file string) {
|
||||
splits := strings.Split(file, ".")
|
||||
if splits[len(splits)-1] != "gb" {
|
||||
panic(errorHandling.InvalidRomError)
|
||||
}
|
||||
}
|
||||
|
||||
func check(e error) {
|
||||
if e != nil {
|
||||
panic(e)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user