<commit_before>package main

import (
	"flag"
	"fmt"
	"github.com/scottferg/Fergulator/nes"
	"os"
	"runtime"
	"runtime/pprof"
)

var (
	running = true

	videoOut Video
	audioOut *Audio

	cpuprofile = flag.String("cprof", "", "write cpu profile to file")
)

func main() {
	flag.Parse()
	if *cpuprofile != "" {
		f, err := os.Create(*cpuprofile)
		if err != nil {
			fmt.Println(err)
		}

		pprof.StartCPUProfile(f)
		defer pprof.StopCPUProfile()
	} else if false {
		runtime.GOMAXPROCS(runtime.NumCPU())
	}

	audioOut = NewAudio()
	defer audioOut.Close()

	videoTick, gamename, err := nes.Init(audioOut.AppendSample, GetKey)
	if err != nil {
		fmt.Println(err)
	}<commit_msg>Refactor to load romfile from main()<commit_after>package main

import (
	"flag"
	"fmt"
	"github.com/scottferg/Fergulator/nes"
	"io/ioutil"
	"os"
	"runtime"
	"runtime/pprof"
)

var (
	running = true

	videoOut Video
	audioOut *Audio

	cpuprofile = flag.String("cprof", "", "write cpu profile to file")
)

func main() {
	if len(os.Args) < 2 {
		fmt.Println("Please specify a ROM file")
		return
	}

	flag.Parse()
	if *cpuprofile != "" {
		f, err := os.Create(*cpuprofile)
		if err != nil {
			fmt.Println(err)
		}

		pprof.StartCPUProfile(f)
		defer pprof.StopCPUProfile()
	} else if false {
		runtime.GOMAXPROCS(runtime.NumCPU())
	}

	contents, err := ioutil.ReadFile(os.Args[len(os.Args)-1])
	if err != nil {
		fmt.Println(err.Error())
		return
	}

	audioOut = NewAudio()
	defer audioOut.Close()

	videoTick, gamename, err := nes.Init(contents, audioOut.AppendSample, GetKey)
	if err != nil {
		fmt.Println(err)
	}
{'fraction_non_alphanumeric': 0.15229704216488357, 'fraction_numerical': 0.0012586532410320957, 'mean_word_length': 3.774774774774775, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4051768', 'n_tokens_mistral': 674, 'n_tokens_neox': 638, 'n_words': 134}