예제 #1
0
파일: texty.go 프로젝트: sbinet/goapple2
// Run the emulator
func RunEmulator() {
	rom := util.ReadRomOrDie("../data/roms/apple2+.rom")
	charRom := util.ReadSmallCharacterRomOrDie("../data/roms/apple2-chars.rom")
	plotter := TextPlotter(0)
	a2 := goapple2.NewApple2(plotter, rom, charRom)
	if err := termbox.Init(); err != nil {
		panic(err)
	}
	events := make(chan termbox.Event)
	go func() {
		for {
			events <- termbox.PollEvent()
		}
	}()
	for !ProcessEvents(events, a2) {
		err := a2.Step()
		if err != nil {
			fmt.Println(err)
			break
		}
		time.Sleep(1 * time.Nanosecond) // So the keyboard-reading goroutines can run
	}
	termbox.Close()
}
예제 #2
0
파일: sdl.go 프로젝트: sbinet/goapple2
// Run the emulator
func RunEmulator() {
	rom := util.ReadRomOrDie("../data/roms/apple2+.rom")
	// charRom = util.ReadFullCharacterRomOrDie("../data/roms/apple2char.rom")
	charRom := util.ReadSmallCharacterRomOrDie("../data/roms/apple2-chars.rom")
	screen, err := Init()
	if err != nil {
		panic(err)
	}
	var a2 *goapple2.Apple2
	oncePerFrame := func() {
		a2.Done = a2.Done || ProcessEvents(sdl.Events, a2)
		runtime.Gosched()
	}
	plotter := SdlPlotter{screen, oncePerFrame}
	a2 = goapple2.NewApple2(plotter, rom, charRom)

	intBasicRom := util.ReadRomOrDie("../data/roms/apple2.rom")
	firmwareCard, err := cards.NewFirmwareCard(intBasicRom, "Intbasic Firmware Card", 0, a2)
	if err != nil {
		panic(err)
	}
	if err := a2.AddCard(firmwareCard); err != nil {
		log.Fatal(err)
	}

	diskCardRom := util.ReadRomOrDie("../data/roms/Apple Disk II 16 Sector Interface Card ROM P5 - 341-0027.bin")
	diskCard, err := cards.NewDiskCard(diskCardRom, 6, a2)
	if err != nil {
		panic(err)
	}
	if err := a2.AddCard(diskCard); err != nil {
		log.Fatal(err)
	}
	// disk1, err := disk.DiskFromFile("../data/disks/spedtest.dsk", 0)
	// disk1, err := disk.DiskFromFile("../data/disks/dung_beetles.dsk", 0)
	disk1, err := disk.DiskFromFile("../data/disks/chivalry.dsk", 0)
	if err != nil {
		log.Fatal(err)
	}
	diskCard.LoadDisk(disk1, 0)

	steps := *steplimit

	if *cpuprofile != "" {
		f, err := os.Create(*cpuprofile)
		if err != nil {
			log.Fatal(err)
		}
		pprof.StartCPUProfile(f)
		defer pprof.StopCPUProfile()
	}

	/*
			a2.AddPCAction(
				0xB940, goapple2.PCAction{Type: goapple2.ActionDumpMem, String: "0xB940-goa2.bin",
					Mask: cpu.FLAG_Z, Masked: cpu.FLAG_Z, Delay: 68})
		a2.AddPCAction(0xB7B5, goapple2.PCAction{Type: goapple2.ActionHere, String: "ENTER.RWTS"})
		a2.AddPCAction(0xB7BE, goapple2.PCAction{Type: goapple2.ActionHere, String: "ENTER.RWTS - Success"})
		a2.AddPCAction(0xB7C1, goapple2.PCAction{Type: goapple2.ActionHere, String: "ENTER.RWTS - Fail"})
		a2.AddPCAction(0xBD00, goapple2.PCAction{Type: goapple2.ActionHere, String: "RWTS"})
		a2.AddPCAction(0xBDAF, goapple2.PCAction{Type: goapple2.ActionHere, String: "RWTS Command"})
		// a2.AddPCAction(0xBE35, goapple2.PCAction{Type: goapple2.ActionHere, String: "RWTS READ.SECTOR call"})
		// a2.AddPCAction(0xBE38, goapple2.PCAction{Type: goapple2.ActionHere, String: "RWTS READ.SECTOR success"})

		a2.AddPCAction(0xBE46, goapple2.PCAction{Type: goapple2.ActionHere, String: "RWTS Success"})
		a2.AddPCAction(0xBE48, goapple2.PCAction{Type: goapple2.ActionHere, String: "RWTS Error"})

		a2.AddPCAction(0xBDAF, goapple2.PCAction{Type: goapple2.ActionDiskStatus})

		a2.AddPCAction(0xBDAF, goapple2.PCAction{Type: goapple2.ActionTrace, String: "on",
			Delay: 70})

		a2.AddPCAction(
			0xBE48, goapple2.PCAction{Type: goapple2.ActionSetLimit, String: "1"})

		a2.AddPCAction(
			0xBDAF, goapple2.PCAction{Type: goapple2.ActionDumpMem, String: "0xBDAF-goa2.bin", Delay: 68})
	*/
	_ = cpu.FLAG_Z

	// go typeProgram(a2)

	for !a2.Done {
		err := a2.Step()
		if err != nil {
			fmt.Println(err)
			break
		}
		// runtime.Gosched() // So the keyboard-reading goroutines can run
		if steps > 0 {
			steps--
			if steps == 0 {
				a2.Quit()
			}
		}
	}
	a2.Quit()
	sdl.Quit()
}