izapple2/apple2main.go

226 lines
5.0 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
)
2019-10-12 19:37:37 +00:00
const defaultInternal = "<default>"
// 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-10-12 19:37:37 +00:00
defaultInternal,
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",
2019-11-07 22:20:14 +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-10-12 19:37:37 +00:00
defaultInternal,
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")
vidHDCardSlot := flag.Int(
"vidHDSlot",
2,
"slot for the VidHD card, -1 for none")
2019-11-12 22:47:48 +00:00
fastChipCardSlot := flag.Int(
"fastChipSlot",
3,
"slot for the FASTChip accelerator 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(
2019-11-01 17:48:39 +00:00
"panicSS",
2019-04-15 21:13:05 +00:00
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-11-01 17:48:39 +00:00
traceHD := flag.Bool(
"traceHD",
false,
"dump to the console the hd commands")
2019-04-21 16:18:43 +00:00
dumpChars := flag.Bool(
"dumpChars",
false,
"shows the character map")
2019-10-12 19:37:37 +00:00
model := flag.String(
"model",
2019-11-03 23:23:03 +00:00
"2enh",
"set base model. Models available 2plus, 2e, 2enh, base64a")
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-12 19:37:37 +00:00
var a *Apple2
var charGenMap charColumnMap
initialCharGenPage := 0
switch *model {
case "2plus":
a = newApple2plus()
if *romFile == defaultInternal {
*romFile = "<internal>/Apple2_Plus.rom"
}
if *charRomFile == defaultInternal {
*charRomFile = "<internal>/Apple2rev7CharGen.rom"
}
charGenMap = charGenColumnsMap2Plus
case "2e":
2019-10-20 22:06:28 +00:00
a = newApple2e()
if *romFile == defaultInternal {
*romFile = "<internal>/Apple2e.rom"
}
if *charRomFile == defaultInternal {
*charRomFile = "<internal>/Apple IIe Video Unenhanced - 342-0133-A - 2732.bin"
}
a.isApple2e = true
charGenMap = charGenColumnsMap2e
case "2enh":
2019-10-12 19:37:37 +00:00
a = newApple2eEnhanced()
if *romFile == defaultInternal {
*romFile = "<internal>/Apple2e_Enhanced.rom"
}
if *charRomFile == defaultInternal {
*charRomFile = "<internal>/Apple IIe Video Enhanced - 342-0265-A - 2732.bin"
}
a.isApple2e = true
charGenMap = charGenColumnsMap2e
case "base64a":
a = newBase64a()
if *romFile == defaultInternal {
err := loadBase64aRom(a)
if err != nil {
panic(err)
}
*romFile = ""
}
if *charRomFile == defaultInternal {
*charRomFile = "<internal>/BASE64A_ROM7_CharGen.BIN"
initialCharGenPage = 1
}
charGenMap = charGenColumnsMapBase64a
default:
panic("Model not supported")
}
2019-10-12 19:37:37 +00:00
a.setup(!*mono, *cpuClock, *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-12 19:37:37 +00:00
// Load ROM if not loaded already
if *romFile != "" {
err := a.LoadRom(*romFile)
2019-10-05 23:26:00 +00:00
if err != nil {
panic(err)
}
}
2019-10-12 19:37:37 +00:00
// Load character generator if it loaded already
cg, err := newCharacterGenerator(*charRomFile, charGenMap)
if err != nil {
panic(err)
}
2019-10-12 19:37:37 +00:00
cg.setPage(initialCharGenPage)
a.cg = cg
// Externsion cards
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-11-12 22:47:48 +00:00
if *vidHDCardSlot >= 0 {
a.AddVidHD(*vidHDCardSlot)
}
2019-11-12 22:47:48 +00:00
if *fastChipCardSlot >= 0 {
a.AddFastChip(*fastChipCardSlot)
}
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-11-01 17:48:39 +00:00
err := a.AddHardDisk(*hardDiskSlot, *hardDiskImage, *traceHD)
2019-10-05 23:26:00 +00:00
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
}