예제 #1
0
파일: nestest.go 프로젝트: samfoo/gones
func main() {
	var file *os.File
	var err error
	if file, err = os.Open("assets/nestest.nes"); err != nil {
		log.Fatal(err)
		return
	}

	var rom *nes.ROM
	rom, err = nes.ReadROM(file)
	if err != nil {
		log.Fatal(err)
		return
	}

	var machine = nes.NewMachine()
	machine.Insert(rom)

	machine.CPU.Debug = true
	machine.CPU.Reset()
	machine.CPU.PC = 0xc000

	for i := 0; i < 9000; i++ {
		machine.CPU.Step()
	}
}
예제 #2
0
파일: blargg.go 프로젝트: samfoo/gones
func run(filename string) {
	var file *os.File
	var err error
	if file, err = os.Open(filename); err != nil {
		log.Fatal(err)
		return
	}

	var rom *nes.ROM
	rom, err = nes.ReadROM(file)
	if err != nil {
		log.Fatal(err)
		return
	}

	var machine = nes.NewMachine()
	machine.Insert(rom)

	machine.CPU.Debug = false
	machine.CPU.Reset()

	// First step until the tests start.
	for machine.CPU.Memory.Read(0x6000) != 0x80 {
		machine.CPU.Step()
	}

	machine.CPU.Cycle = func() {
		for i := 0; i < 3; i++ {
			machine.PPU.Step()
		}
	}

	parts := strings.Split(filename, string(filepath.Separator))
	fmt.Printf("Running %s tests...\n", parts[len(parts)-1])

	// Next step until the tests are finished.
	for machine.CPU.Memory.Read(0x6000) > 0x7f {
		machine.CPU.Step()

		if machine.CPU.Memory.Read(0x6000) == 0x81 {
			panic("Need to press reset, but isn't implemented")
		}
	}

	var output = ""
	for i := 0; machine.CPU.Memory.Read(cpu.Address(0x6004+i)) != 0x00; i++ {
		char := machine.CPU.Memory.Read(cpu.Address(0x6004 + i))
		output += fmt.Sprintf("%c", char)
	}

	if strings.Contains(output, "Passed") {
		fmt.Printf("Results: OK\n")
	} else {
		fmt.Printf("Results: FAIL\n")
		fmt.Printf("====\n%s====\n", output)
	}
}
예제 #3
0
파일: gones.go 프로젝트: samfoo/gones
func main() {
	path := os.Args[1]

	var file *os.File
	var err error
	if file, err = os.Open(path); err != nil {
		log.Fatal(err)
		return
	}

	var rom *nes.ROM
	rom, err = nes.ReadROM(file)
	if err != nil {
		log.Fatal(err)
		return
	}

	machine := nes.NewMachine()
	machine.Insert(rom)

	machine.CPU.Debug = false
	machine.CPU.Reset()

	machine.CPU.Cycle = func() {
		for i := 0; i < 3; i++ {
			machine.PPU.Step()
		}
	}

	screen := video.NewVideo()
	screen.Init(640, 600)

	go func() {
		for {
			machine.CPU.Step()

			frame := new(video.Frame)
			frame.Data = machine.PPU.Display
			frame.Width = 256
			frame.Height = 240

			screen.Frames <- frame
		}
	}()

	screen.Loop()
}
예제 #4
0
func main() {
	path := os.Args[1]

	var err error

	var bank int
	if bank, err = strconv.Atoi(os.Args[2]); err != nil {
		log.Fatal(err)
		return
	}

	var file *os.File
	if file, err = os.Open(path); err != nil {
		log.Fatal(err)
		return
	}

	var rom *nes.ROM
	rom, err = nes.ReadROM(file)
	if err != nil {
		log.Fatal(err)
		return
	}

	fmt.Printf("num chr banks: %d\n", len(rom.ChrBanks))

	screen := video.NewVideo()
	screen.Init(640, 160)

	go func() {
		buffer := RenderPatternTables(rom.ChrBanks[bank])

		frame := new(video.Frame)
		frame.Data = buffer
		frame.Width = 320
		frame.Height = 80

		screen.Frames <- frame
	}()

	screen.Loop()
}
예제 #5
0
파일: inesinfo.go 프로젝트: samfoo/gones
func main() {
	path := os.Args[1]

	var file *os.File
	var err error
	if file, err = os.Open(path); err != nil {
		log.Fatal(err)
		return
	}

	var rom *nes.ROM
	rom, err = nes.ReadROM(file)
	if err != nil {
		log.Fatal(err)
		return
	}

	fmt.Printf("Prg ROM (* 16KB) : %d\n", rom.Header.PrgRomSize)
	fmt.Printf("Chr ROM (* 8KB)  : %d\n", rom.Header.ChrRomSize)
	fmt.Printf("Mapper           : %s\n", nes.MapperNames[rom.Header.Mapper])
}