<commit_before>// Copyright 2011 <NAME>. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package gameboy

import (
	"fmt"
	"io"
	"⚛sdl"
	"os"
)

type Config struct {
	SaveDir string
	Verbose bool
	Debug   bool
	Scale   int
}

func Start(path string, cfg Config, quit chan int) (err interface{}) {
	var rom romImage
	rom, err = loadROM(path)
	if err != nil {
		return
	}

	if cfg.Verbose {
		rom.printInfo()
	}

	if sdl.Init(sdl.INIT_VIDEO) != 0 {
		err = sdl.GetError()
		return
	}

	var mem *memory
	mem, err = newMemory(rom, &cfg)
	if err != nil {
		return
	}

	if e := mem.load(cfg.SaveDir); e != nil {
		fmt.Fprintf(os.Stderr, "load failed: %v\n", e)
	}

	sys := newCPU(mem)
	lcd := newDisplay(mem)

	go mem.monitorEvents()
	go func() {
		run(&cfg, sys, lcd, quit)
		if e := mem.save(cfg.SaveDir); e != nil {
			fmt.Fprintf(os.Stderr, "save failed: %v\n", e)
		}
		quit <- 1
	}()
	return
}

func run(cfg *Config, sys *cpu, lcd *display, quit chan int) {
	defer sdl.Quit()<commit_msg>Hide load/save errors when not verbose<commit_after>// Copyright 2011 <NAME>. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package gameboy

import (
	"fmt"
	"io"
	"⚛sdl"
	"os"
)

type Config struct {
	SaveDir string
	Verbose bool
	Debug   bool
	Scale   int
}

func Start(path string, cfg Config, quit chan int) (err interface{}) {
	var rom romImage
	rom, err = loadROM(path)
	if err != nil {
		return
	}

	if cfg.Verbose {
		rom.printInfo()
	}

	if sdl.Init(sdl.INIT_VIDEO) != 0 {
		err = sdl.GetError()
		return
	}

	var mem *memory
	mem, err = newMemory(rom, &cfg)
	if err != nil {
		return
	}

	if e := mem.load(cfg.SaveDir); e != nil && cfg.Verbose {
		fmt.Fprintf(os.Stderr, "load failed: %v\n", e)
	}

	sys := newCPU(mem)
	lcd := newDisplay(mem)

	go mem.monitorEvents()
	go func() {
		run(&cfg, sys, lcd, quit)
		if e := mem.save(cfg.SaveDir); e != nil && cfg.Verbose {
			fmt.Fprintf(os.Stderr, "save failed: %v\n", e)
		}
		quit <- 1
	}()
	return
}

func run(cfg *Config, sys *cpu, lcd *display, quit chan int) {
	defer sdl.Quit()
{'fraction_non_alphanumeric': 0.1459954233409611, 'fraction_numerical': 0.005491990846681922, 'mean_word_length': 3.085981308411215, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '1944723', 'n_tokens_mistral': 925, 'n_tokens_neox': 865, 'n_words': 268}