izapple2/apple2main.go

282 lines
6.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
)
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")
2020-04-12 23:29:04 +00:00
diskBImage := flag.String(
"diskb",
"",
"file to load on the second disk drive")
2019-12-15 23:36:34 +00:00
wozImage := flag.String(
"woz",
"",
2019-12-22 13:32:54 +00:00
"show WOZ file information")
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,
2019-11-22 22:27:25 +00:00
"slot for the VidHD card, only for //e models. -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")
memoryExpansionCardSlot := flag.Int(
"memoryExpSlot",
4,
"slot for the Memory Expansion card with 1GB. -1 for none")
ramWorksKb := flag.Int(
"ramworks",
8192,
"memory to use with RAMWorks card, 0 for no card, max is 16384")
2019-11-12 22:47:48 +00:00
thunderClockCardSlot := flag.Int(
"thunderClockCardSlot",
5,
2019-11-12 22:47:48 +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.")
rgbCard := flag.Bool(
"rgb",
true,
"emulate the RGB modes of the 80col RGB card for DHGR")
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")
profile := flag.Bool(
"profile",
false,
"generate profile trace to analyse with pprof")
2020-06-07 16:23:39 +00:00
traceMLI := flag.Bool(
"traceMLI",
false,
"dump to the console the calls to ProDOS machine language interface calls to $BF00")
2020-06-07 16:23:39 +00:00
2019-04-15 21:13:05 +00:00
flag.Parse()
2019-12-15 23:36:34 +00:00
if *wozImage != "" {
2019-12-21 10:16:07 +00:00
f, err := loadFileWoz(*wozImage)
2019-12-15 23:36:34 +00:00
if err != nil {
panic(err)
}
2019-12-21 10:16:07 +00:00
f.dump()
2019-12-22 13:32:54 +00:00
return nil
2019-12-15 23:36:34 +00:00
}
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
2019-11-22 22:27:25 +00:00
*vidHDCardSlot = -1
2019-10-12 19:37:37 +00:00
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
2019-11-22 22:27:25 +00:00
*vidHDCardSlot = -1
2019-10-12 19:37:37 +00:00
default:
panic("Model not supported")
}
2020-06-07 16:23:39 +00:00
a.setup(!*mono, *cpuClock, *fastDisk, *traceMLI)
a.cpu.SetTrace(*traceCPU)
a.io.setTrace(*traceSS)
a.io.setPanicNotImplemented(*panicSS)
a.setProfiling(*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 *memoryExpansionCardSlot >= 0 {
err := a.AddMemoryExpansionCard(*memoryExpansionCardSlot,
"<internal>/MemoryExpansionCard-341-0344a.bin")
if err != nil {
panic(err)
}
}
if *thunderClockCardSlot > 0 {
err := a.AddThunderClockPlusCard(*thunderClockCardSlot,
"<internal>/ThunderclockPlusROM.bin")
2019-10-05 23:26:00 +00:00
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 {
2020-04-12 23:29:04 +00:00
err := a.AddDisk2(*disk2Slot, *disk2RomFile, *diskImage, *diskBImage)
2019-10-05 23:26:00 +00:00
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
if *ramWorksKb != 0 {
if *ramWorksKb%64 != 0 {
panic("Ramworks size must be a multiple of 64")
}
a.AddRAMWorks(*ramWorksKb / 64)
}
if *rgbCard {
a.AddRGBCard()
}
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
}