Ejemplo n.º 1
0
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()
}
Ejemplo n.º 2
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()
}