2019-06-01 15:11:25 +00:00
|
|
|
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"
|
2019-06-01 15:11:25 +00:00
|
|
|
"os"
|
2019-04-13 18:29:31 +00:00
|
|
|
)
|
2019-02-16 19:15:41 +00:00
|
|
|
|
2019-06-01 15:11:25 +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",
|
2019-06-01 18:06:44 +00:00
|
|
|
"<internal>/Apple2_Plus.rom",
|
2019-04-15 21:13:05 +00:00
|
|
|
"main rom file")
|
|
|
|
disk2RomFile := flag.String(
|
|
|
|
"diskRom",
|
2019-06-01 18:06:44 +00:00
|
|
|
"<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,
|
2019-05-17 21:28:20 +00:00
|
|
|
"slot for the disk driver. -1 for none.")
|
2019-04-15 21:13:05 +00:00
|
|
|
diskImage := flag.String(
|
|
|
|
"disk",
|
2019-06-01 18:06:44 +00:00
|
|
|
"<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",
|
2019-06-01 15:11:25 +00:00
|
|
|
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",
|
2019-06-01 18:06:44 +00:00
|
|
|
"<internal>/Apple2rev7CharGen.rom",
|
2019-06-02 21:18:35 +00:00
|
|
|
"rom file for the character generator")
|
2019-05-17 21:28:20 +00:00
|
|
|
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")
|
2019-09-28 11:37:42 +00:00
|
|
|
thunderClockCardSlot := flag.Int(
|
|
|
|
"thunderClockCardSlot",
|
2019-10-05 13:26:24 +00:00
|
|
|
4,
|
2019-09-28 11:37:42 +00:00
|
|
|
"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.",
|
|
|
|
)
|
2019-05-10 16:07:36 +00:00
|
|
|
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,
|
2019-09-24 21:32:03 +00:00
|
|
|
"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",
|
|
|
|
)
|
2019-06-09 15:36:29 +00:00
|
|
|
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)
|
2019-09-24 21:32:03 +00:00
|
|
|
|
|
|
|
a.cpu.SetTrace(*traceCPU)
|
|
|
|
a.io.setTrace(*traceSS)
|
|
|
|
a.io.setPanicNotImplemented(*panicSS)
|
2019-10-19 18:31:18 +00:00
|
|
|
a.setProfile(*profile)
|
2019-09-24 21:32:03 +00:00
|
|
|
|
2019-10-05 23:26:00 +00:00
|
|
|
if *charRomFile != "" {
|
|
|
|
cg, err := NewCharacterGenerator(*charRomFile)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
a.cg = cg
|
|
|
|
}
|
|
|
|
|
2019-06-09 15:36:29 +00:00
|
|
|
if *base64a {
|
|
|
|
NewBase64a(a)
|
|
|
|
} else {
|
2019-10-05 23:26:00 +00:00
|
|
|
err := a.LoadRom(*romFile)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2019-06-09 15:36:29 +00:00
|
|
|
}
|
2019-05-17 21:28:20 +00:00
|
|
|
if *languageCardSlot >= 0 {
|
|
|
|
a.AddLanguageCard(*languageCardSlot)
|
|
|
|
}
|
|
|
|
if *saturnCardSlot >= 0 {
|
|
|
|
a.AddSaturnCard(*saturnCardSlot)
|
|
|
|
}
|
2019-09-28 11:37:42 +00:00
|
|
|
if *thunderClockCardSlot > 0 {
|
2019-10-05 23:26:00 +00:00
|
|
|
err := a.AddThunderClockPlusCard(*thunderClockCardSlot, "<internal>/ThunderclockPlusROM.bin")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2019-09-28 11:37:42 +00:00
|
|
|
}
|
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)
|
|
|
|
|
2019-06-09 21:54:27 +00:00
|
|
|
if *dumpChars {
|
|
|
|
a.cg.Dump()
|
|
|
|
os.Exit(0)
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-06-01 15:11:25 +00:00
|
|
|
return a
|
2019-01-26 17:57:03 +00:00
|
|
|
}
|