izapple2/apple2main.go

159 lines
3.2 KiB
Go
Raw Normal View History

package apple2
2019-01-26 17:57:03 +00:00
2019-04-13 18:29:31 +00:00
import (
2019-04-15 21:13:05 +00:00
"flag"
"os"
2019-04-13 18:29:31 +00:00
)
// MainApple is a device independant main. Video, keyboard and speaker won't be defined
func MainApple() *Apple2 {
2019-04-15 21:13:05 +00:00
romFile := flag.String(
"rom",
"<internal>/Apple2_Plus.rom",
2019-04-15 21:13:05 +00:00
"main rom file")
disk2RomFile := flag.String(
"diskRom",
"<internal>/DISK2.rom",
2019-04-15 21:13:05 +00:00
"rom file for the disk drive controller")
2019-05-09 22:09:15 +00:00
disk2Slot := flag.Int(
"disk2Slot",
6,
"slot for the disk driver. -1 for none.")
2019-04-15 21:13:05 +00:00
diskImage := flag.String(
"disk",
"<internal>/dos33.dsk",
2019-04-15 21:13:05 +00:00
"file to load on the first disk drive")
2019-10-02 21:39:39 +00:00
hardDiskImage := flag.String(
"hd",
"",
"file to load on the hard disk")
hardDiskSlot := flag.Int(
"hdSlot",
-1,
"slot for the hard drive if present. -1 for none.")
2019-05-04 17:49:11 +00:00
cpuClock := flag.Float64(
"mhz",
CpuClockMhz,
2019-05-05 11:25:45 +00:00
"cpu speed in Mhz, use 0 for full speed. Use F5 to toggle.")
2019-04-21 16:18:43 +00:00
charRomFile := flag.String(
"charRom",
"<internal>/Apple2rev7CharGen.rom",
2019-06-02 21:18:35 +00:00
"rom file for the character generator")
languageCardSlot := flag.Int(
"languageCardSlot",
0,
"slot for the 16kb language card. -1 for none")
saturnCardSlot := flag.Int(
"saturnCardSlot",
-1,
"slot for the 256kb Saturn card. -1 for none")
thunderClockCardSlot := flag.Int(
"thunderClockCardSlot",
4,
"slot for the ThunderClock Plus card. -1 for none")
2019-05-05 11:25:45 +00:00
mono := flag.Bool(
"mono",
false,
"emulate a green phosphor monitor instead of a NTSC color TV. Use F6 to toggle.",
)
fastDisk := flag.Bool(
"fastDisk",
true,
"set fast mode when the disks are spinning",
)
2019-04-15 21:13:05 +00:00
panicSS := flag.Bool(
"panicss",
false,
"panic if a not implemented softswitch is used",
)
traceCPU := flag.Bool(
"traceCpu",
false,
"dump to the console the CPU execution operations",
)
traceSS := flag.Bool(
"traceSS",
false,
"dump to the console the sofswitches calls",
)
2019-04-21 16:18:43 +00:00
dumpChars := flag.Bool(
"dumpChars",
false,
"shows the character map",
)
base64a := flag.Bool(
"base64a",
false,
"setup a Base64A clone",
)
2019-10-19 18:31:18 +00:00
profile := flag.Bool(
"profile",
false,
"generate profile trace to analyse with pprof",
)
2019-04-15 21:13:05 +00:00
flag.Parse()
2019-10-05 23:26:00 +00:00
a := NewApple2(*cpuClock, !*mono, *fastDisk)
a.cpu.SetTrace(*traceCPU)
a.io.setTrace(*traceSS)
a.io.setPanicNotImplemented(*panicSS)
2019-10-19 18:31:18 +00:00
a.setProfile(*profile)
2019-10-05 23:26:00 +00:00
if *charRomFile != "" {
cg, err := NewCharacterGenerator(*charRomFile)
if err != nil {
panic(err)
}
a.cg = cg
}
if *base64a {
NewBase64a(a)
} else {
2019-10-05 23:26:00 +00:00
err := a.LoadRom(*romFile)
if err != nil {
panic(err)
}
}
if *languageCardSlot >= 0 {
a.AddLanguageCard(*languageCardSlot)
}
if *saturnCardSlot >= 0 {
a.AddSaturnCard(*saturnCardSlot)
}
if *thunderClockCardSlot > 0 {
2019-10-05 23:26:00 +00:00
err := a.AddThunderClockPlusCard(*thunderClockCardSlot, "<internal>/ThunderclockPlusROM.bin")
if err != nil {
panic(err)
}
}
2019-10-02 21:39:39 +00:00
if *disk2Slot > 0 {
2019-10-05 23:26:00 +00:00
err := a.AddDisk2(*disk2Slot, *disk2RomFile, *diskImage)
if err != nil {
panic(err)
}
2019-05-09 22:09:15 +00:00
}
2019-10-02 21:39:39 +00:00
if *hardDiskImage != "" {
if *hardDiskSlot <= 0 {
// If there is a hard disk image, but no slot assigned, use slot 7.
*hardDiskSlot = 7
}
2019-10-05 23:26:00 +00:00
err := a.AddHardDisk(*hardDiskSlot, *hardDiskImage)
if err != nil {
panic(err)
}
2019-10-02 21:39:39 +00:00
}
2019-05-18 21:40:59 +00:00
//a.AddCardInOut(2)
//a.AddCardLogger(4)
if *dumpChars {
a.cg.Dump()
os.Exit(0)
return nil
}
return a
2019-01-26 17:57:03 +00:00
}