Partial FASTChip emulation.

This commit is contained in:
Ivan Izaguirre 2019-11-12 23:47:48 +01:00
parent c91e9d43f4
commit 20d9b2ed10
5 changed files with 93 additions and 6 deletions

View File

@ -22,6 +22,7 @@ Portable emulator of an Apple II+ or //e. Written in Go.
- Bootable hard disk card
- Apple //e 80 columns with 64Kb extra RAM
- VidHd, limited to the ROM signature and SHR as used by Total Replay
- FASTChip, limited to what Total Replay needs to set and clear fast mode
- Graphic modes:
- Text 40 columns
- text 80 columns (Apple //e only)

View File

@ -137,6 +137,13 @@ func (a *Apple2) AddVidHD(slot int) {
a.insertCard(&c, slot)
}
// AddFastChip adds a card with the signature of VidHD
func (a *Apple2) AddFastChip(slot int) {
var c cardFastChip
c.loadRom(buildFastChipRom())
a.insertCard(&c, slot)
}
// AddLanguageCard inserts a 16Kb card
func (a *Apple2) AddLanguageCard(slot int) {
a.insertCard(&cardLanguage{}, slot)

View File

@ -49,14 +49,18 @@ func MainApple() *Apple2 {
"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")
vidHDCardSlot := flag.Int(
"vidHDSlot",
2,
"slot for the VidHD card, -1 for none")
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")
mono := flag.Bool(
"mono",
false,
@ -185,9 +189,12 @@ func MainApple() *Apple2 {
panic(err)
}
}
if *vidHDCardSlot > 0 {
if *vidHDCardSlot >= 0 {
a.AddVidHD(*vidHDCardSlot)
}
if *fastChipCardSlot >= 0 {
a.AddFastChip(*fastChipCardSlot)
}
if *disk2Slot > 0 {
err := a.AddDisk2(*disk2Slot, *disk2RomFile, *diskImage)
if err != nil {

72
cardFastChip.go Normal file
View File

@ -0,0 +1,72 @@
package apple2
/*
Simulates just what is needed to make Total Replay use fast mode. Can change
from controlled speed to max speed the emulator can do.
Note: It ends up not being useful for Total Replay as loading from HD is already
very fast. HD blocks are loaded directly on the emulated RAM.
See:
https://github.com/a2-4am/4cade/blob/master/src/hw.accel.a
http://www.a2heaven.com/webshop/resources/pdf_document/18/82/c.pdf
*/
type cardFastChip struct {
cardBase
unlocked bool
unlockCounter uint8
enabled bool
accelerated bool
}
func buildFastChipRom() []uint8 {
data := make([]uint8, 256)
return data
}
const (
fastChipUnlockToken = 0x6a
fastChipUnlockRepeats = 4
fastChipNormalSpeed = uint8(9)
)
func (c *cardFastChip) assign(a *Apple2, slot int) {
// The softswitches are outside the card reserved ss
// Only writes are implemented to avoid conflicts with the joysticks
a.io.addSoftSwitchW(0x6a, func(_ *ioC0Page, value uint8) {
if value == fastChipUnlockToken {
c.unlockCounter++
if c.unlockCounter >= fastChipUnlockRepeats {
c.unlocked = true
}
} else {
c.unlockCounter = 0
c.unlocked = false
}
}, "FASTCHIP-LOCK")
a.io.addSoftSwitchW(0x6b, func(_ *ioC0Page, _ uint8) {
if c.unlocked {
c.enabled = true
}
}, "FASTCHIP-ENABLE")
a.io.addSoftSwitchW(0x6d, func(_ *ioC0Page, value uint8) {
if c.unlocked && c.enabled {
newAccelerated := (value > fastChipNormalSpeed)
if newAccelerated == c.accelerated {
// No change requested
return
}
if newAccelerated {
a.requestFastMode()
} else {
a.releaseFastMode()
}
c.accelerated = newAccelerated
}
}, "FASTCHIP-SPEED")
c.cardBase.assign(a, slot)
}

View File

@ -27,7 +27,7 @@ const (
)
func (c *cardVidHD) assign(a *Apple2, slot int) {
// The softswitches are outside the card reverded ss
// The softswitches are outside the card reserved ss
a.io.addSoftSwitchR(0x22, notImplementedSoftSwitchR, "VIDHD-TBCOLOR")
a.io.addSoftSwitchW(0x22, notImplementedSoftSwitchW, "VIDHD-TBCOLOR")
a.io.addSoftSwitchR(0x29, getStatusSoftSwitch(ioDataNewVideo), "VIDHD-NEWVIDEO")