Skip to content

Commit

Permalink
Merge pull request #1 from daddyshortlegs/command-line-args
Browse files Browse the repository at this point in the history
Add ability to load ROM from command line
  • Loading branch information
daddyshortlegs authored Nov 2, 2023
2 parents 902552b + 989b2fa commit ac96b28
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion chip8.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,20 @@ package main

import (
"chip8"
"flag"
"io/ioutil"
"os"
)

func main() {
var romFile = flag.String("rom", "", "The filename of the Chip8 ROM you want to execute")
flag.Parse()

if *romFile == "" {
println("Please specify a ROM to load")
os.Exit(1)
}

chip8Display := Chip8Display{}
defer chip8Display.shutdown()
chip8Display.startUp()
Expand All @@ -14,7 +24,7 @@ func main() {

vm := chip8.NewVM(&chip8Display, random)

dat, _ := ioutil.ReadFile("test_opcode.ch8")
dat, _ := ioutil.ReadFile(*romFile)
//check(err)

vm.Load(dat)
Expand Down

0 comments on commit ac96b28

Please sign in to comment.