Command line arguments

This commit is contained in:
Ivan Izaguirre 2019-04-15 23:13:05 +02:00
parent 9ab4e449b8
commit 05355749f3
3 changed files with 40 additions and 11 deletions

View File

@ -13,16 +13,18 @@ type Apple2 struct {
io *ioC0Page
cards []cardBase
isApple2e bool
panicSS bool
activeSlot int // Slot that has the addressing 0xc800 to 0ccfff
}
// NewApple2 instantiates an apple2
func NewApple2(romFile string) *Apple2 {
func NewApple2(romFile string, panicSS bool) *Apple2 {
var a Apple2
a.mmu = newMemoryManager(&a)
a.cpu = core6502.NewNMOS6502(a.mmu)
a.loadRom(romFile)
a.mmu.resetPaging()
a.panicSS = panicSS
// Set the io in 0xc000
a.io = newIoC0Page(&a)

View File

@ -72,10 +72,11 @@ func (p *ioC0Page) Peek(address uint8) uint8 {
//fmt.Printf("Peek on $C0%02x ", address)
ss := p.softSwitchesR[address]
if ss == nil {
//panic(fmt.Sprintf("Unknown softswitch on read to 0xC0%02x", address))
if p.apple2.panicSS {
panic(fmt.Sprintf("Unknown softswitch on read to 0xC0%02x", address))
}
return 0
}
return ss(p)
}
@ -83,7 +84,9 @@ func (p *ioC0Page) Poke(address uint8, value uint8) {
//fmt.Printf("Poke on $C0%02x with %02x ", address, value)
ss := p.softSwitchesW[address]
if ss == nil {
//panic(fmt.Sprintf("Unknown softswitch on write to 0xC0%02x", address))
if p.apple2.panicSS {
panic(fmt.Sprintf("Unknown softswitch on write to 0xC0%02x", address))
}
return
}
ss(p, value)

38
main.go
View File

@ -1,22 +1,46 @@
package main
import (
"flag"
"go6502/apple2"
"go6502/apple2sdl"
)
func main() {
romFile := flag.String(
"rom",
"apple2/romdumps/Apple2_Plus.rom",
"main rom file")
disk2RomFile := flag.String(
"diskRom",
"apple2/romdumps/DISK2.rom",
"rom file for the disk drive controller")
diskImage := flag.String(
"disk",
"../dos33.dsk",
"file to load on the first disk drive")
useSdl := flag.Bool(
"sdl",
true,
"use SDL")
panicSS := flag.Bool(
"panicss",
false,
"panic if a not implemented softwtich is used")
flag.Parse()
//romFile := "apple2/romdumps/Apple2.rom"
romFile := "apple2/romdumps/Apple2_Plus.rom"
//romFile := "apple2/romdumps/Apple2_Plus.rom"
//romFile := "apple2/romdumps/Apple2e.rom"
disk2RomFile := "apple2/romdumps/DISK2.rom"
diskImage := "../dos33.dsk"
//disk2RomFile := "apple2/romdumps/DISK2.rom"
//diskImage := "../dos33.dsk"
//diskImage := "../Apex II - Apple II Diagnostic (v4.7-1986).DSK"
//diskImage := "../A2Diag.v4.1.SDK"
log := false
sdl := true
a := apple2.NewApple2(romFile)
a.AddDisk2(disk2RomFile, diskImage)
if sdl {
a := apple2.NewApple2(*romFile, *panicSS)
a.AddDisk2(*disk2RomFile, *diskImage)
if *useSdl {
apple2sdl.SDLRun(a)
} else {
a.Run(log, true)