The disk continues turning for 1 second after the turn off command. Bouncing Kamungas now works.

This commit is contained in:
Ivan Izaguirre 2021-05-10 22:13:55 +02:00
parent fa7604800b
commit cab42e9a94
5 changed files with 17 additions and 21 deletions

View File

@ -124,9 +124,9 @@ func (c *cardBase) addCardSoftSwitches(sss softSwitches, name string) {
address := i address := i
c.addCardSoftSwitchR(address, func(io *ioC0Page) uint8 { c.addCardSoftSwitchR(address, func(io *ioC0Page) uint8 {
return sss(io, address, 0, false) return sss(io, address, 0, false)
}, fmt.Sprintf("%v%xR", name, address)) }, fmt.Sprintf("%v%XR", name, address))
c.addCardSoftSwitchW(address, func(io *ioC0Page, value uint8) { c.addCardSoftSwitchW(address, func(io *ioC0Page, value uint8) {
sss(io, address, value, true) sss(io, address, value, true)
}, fmt.Sprintf("%v%xW", name, address)) }, fmt.Sprintf("%v%XW", name, address))
} }
} }

View File

@ -1,10 +1,5 @@
package izapple2 package izapple2
import (
"fmt"
"strings"
)
/* /*
Stepper motor to position the track. Stepper motor to position the track.
@ -83,6 +78,6 @@ func moveDriveStepper(phases uint8, prevStep int) int {
} }
} }
fmt.Printf("[DiskII] 1/4 track: %03d %vO\n", nextStep, strings.Repeat(" ", nextStep)) //fmt.Printf("[DiskII] 1/4 track: %03d %vO\n", nextStep, strings.Repeat(" ", nextStep))
return nextStep return nextStep
} }

View File

@ -19,7 +19,7 @@ See:
*/ */
// CardDisk2Sequencer is a DiskII interface card // CardDisk2Sequencer is a DiskII interface card with the Woz state machine
type CardDisk2Sequencer struct { type CardDisk2Sequencer struct {
cardBase cardBase
@ -27,7 +27,7 @@ type CardDisk2Sequencer struct {
q [8]bool // 8-bit latch SN74LS259 q [8]bool // 8-bit latch SN74LS259
register uint8 // 8-bit shift/storage register SN74LS323 register uint8 // 8-bit shift/storage register SN74LS323
sequence uint8 // 4 bits stored in an hex flip-flop SN74LS174 sequence uint8 // 4 bits stored in an hex flip-flop SN74LS174
motorDelay uint8 // NE556 timer, used to delay motor off motorDelay uint64 // NE556 timer, used to delay motor off
drive [2]cardDisk2SequencerDrive drive [2]cardDisk2SequencerDrive
lastPulse bool lastPulse bool
@ -37,8 +37,8 @@ type CardDisk2Sequencer struct {
} }
const ( const (
disk2MotorOffDelay = uint8(20) // 2 Mhz cycles, TODO: how long? disk2MotorOffDelay = uint64(2 * 1000 * 1000) // 2 Mhz cycles. Total 1 second.
disk2PulseCcyles = uint8(8) // 8 cycles = 4ms * 2Mhz disk2PulseCyles = uint8(8) // 8 cycles = 4ms * 2Mhz
/* /*
We skip register calculations for long periods with the motor We skip register calculations for long periods with the motor
@ -89,6 +89,7 @@ func (c *CardDisk2Sequencer) assign(a *Apple2, slot int) {
// Advance the Disk2 state machine since the last call to softswitches // Advance the Disk2 state machine since the last call to softswitches
c.catchUp(data) c.catchUp(data)
/* /*
Slot card pins to SN74LS259 mapping: Slot card pins to SN74LS259 mapping:
slot_address[0] => latch_oe2_n slot_address[0] => latch_oe2_n
@ -185,7 +186,7 @@ func (c *CardDisk2Sequencer) step(data uint8, firstStep bool) bool {
*/ */
pulse := false pulse := false
c.lastPulseCycles++ c.lastPulseCycles++
if c.lastPulseCycles == disk2PulseCcyles { if c.lastPulseCycles == disk2PulseCyles {
pulse = c.drive[0].readPulse() || pulse = c.drive[0].readPulse() ||
c.drive[1].readPulse() c.drive[1].readPulse()
c.lastPulseCycles = 0 c.lastPulseCycles = 0
@ -207,9 +208,8 @@ func (c *CardDisk2Sequencer) step(data uint8, firstStep bool) bool {
A3 <= Q7 from 9334 A3 <= Q7 from 9334
A4 <= pulse transition A4 <= pulse transition
*/ */
seqBits := component.ByteToPins(c.sequence)
high := c.register >= 0x80 high := c.register >= 0x80
seqBits := component.ByteToPins(c.sequence)
romAddress := component.PinsToByte([8]bool{ romAddress := component.PinsToByte([8]bool{
seqBits[1], // seq1 seqBits[1], // seq1
high, high,
@ -255,7 +255,10 @@ func (c *CardDisk2Sequencer) step(data uint8, firstStep bool) bool {
c.register = data c.register = data
} }
} }
c.sequence = next
//fmt.Printf("[D2SEQ] Step. seq:%x inst:%x next:%x reg:%02x\n",
// c.sequence, inst, next, c.register)
c.sequence = next
return true return true
} }

View File

@ -41,8 +41,6 @@ func (d *cardDisk2SequencerDrive) insertDiskette(filename string) error {
d.data = f d.data = f
d.writeProtected = !writeable d.writeProtected = !writeable
d.mc3470Buffer = 0xf // Test with the buffer full REMOVE
return nil return nil
} }
@ -75,7 +73,7 @@ func (d *cardDisk2SequencerDrive) readPulse() bool {
d.currentQuarterTrack) d.currentQuarterTrack)
d.mc3470Buffer = (d.mc3470Buffer<<1 + fluxBit) & 0x0f d.mc3470Buffer = (d.mc3470Buffer<<1 + fluxBit) & 0x0f
bit := ((d.mc3470Buffer >> 1) & 0x1) != 0 // Use the previous to last bit to add latency bit := ((d.mc3470Buffer >> 1) & 0x1) != 0 // Use the previous to last bit to add latency
if d.mc3470Buffer == 0 && rand.Intn(100) < 3 { if d.mc3470Buffer == 0 && rand.Intn(100) < 30 {
// Four consecutive zeros. It'a a fake bit. // Four consecutive zeros. It'a a fake bit.
// Output a random value. 70% zero, 30% one // Output a random value. 70% zero, 30% one
bit = true bit = true

View File

@ -45,7 +45,7 @@ With the sequencer:
- DOS 3.3: Works - DOS 3.3: Works
- * DOS 3.2: Not working, 13 sector disks can't boot - * DOS 3.2: Not working, 13 sector disks can't boot
- Next choices - Next choices
- *** Bouncing Kamungas: Not working - Bouncing Kamungas: Working
- Commando: Working - Commando: Working
- Planetfall: Working - Planetfall: Working
- Rescue Raiders: Working - Rescue Raiders: Working