2019-02-16 19:15:41 +00:00
|
|
|
package apple2
|
|
|
|
|
|
|
|
import "go6502/core6502"
|
|
|
|
|
|
|
|
// Run instantiates an apple2 and start emulation
|
|
|
|
func Run(romFile string, log bool) {
|
|
|
|
|
|
|
|
// Setup the Apple ][ address space
|
2019-02-22 17:00:53 +00:00
|
|
|
var m core6502.PagedMemory
|
|
|
|
m.InitWithRAM()
|
|
|
|
m.LoadRom(romFile)
|
2019-02-16 19:15:41 +00:00
|
|
|
var io ioC0Page
|
2019-02-22 17:00:53 +00:00
|
|
|
m.SetPage(0xc0, &io)
|
2019-02-16 19:15:41 +00:00
|
|
|
var t textPages
|
|
|
|
for j := 0; j < 4; j++ {
|
2019-02-22 17:00:53 +00:00
|
|
|
m.SetPage(uint8(4+j), &(t.pages[j]))
|
|
|
|
}
|
|
|
|
|
|
|
|
for j := uint8(0xc1); j < 0xd0; j++ {
|
|
|
|
var p tracePage
|
|
|
|
p.page = j
|
|
|
|
m.SetPage(j, &p)
|
2019-02-16 19:15:41 +00:00
|
|
|
}
|
|
|
|
|
2019-02-22 17:00:53 +00:00
|
|
|
var s core6502.State
|
|
|
|
s.Mem = &m
|
|
|
|
|
2019-02-20 22:51:47 +00:00
|
|
|
var fe ansiConsoleFrontend
|
|
|
|
io.setKeyboardProvider(&fe)
|
2019-02-21 23:21:17 +00:00
|
|
|
go fe.textModeGoRoutine(&t)
|
2019-02-20 22:51:47 +00:00
|
|
|
|
2019-02-16 19:15:41 +00:00
|
|
|
// Start the processor
|
|
|
|
core6502.Reset(&s)
|
2019-02-17 23:00:39 +00:00
|
|
|
for {
|
2019-02-16 19:15:41 +00:00
|
|
|
core6502.ExecuteInstruction(&s, log)
|
|
|
|
}
|
|
|
|
}
|