diff --git a/cardBase.go b/cardBase.go index c56061e..f33540c 100644 --- a/cardBase.go +++ b/cardBase.go @@ -124,9 +124,9 @@ func (c *cardBase) addCardSoftSwitches(sss softSwitches, name string) { address := i c.addCardSoftSwitchR(address, func(io *ioC0Page) uint8 { 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) { sss(io, address, value, true) - }, fmt.Sprintf("%v%xW", name, address)) + }, fmt.Sprintf("%v%XW", name, address)) } } diff --git a/cardDisk2DriveStepper.go b/cardDisk2DriveStepper.go index 9641a3f..48e3201 100644 --- a/cardDisk2DriveStepper.go +++ b/cardDisk2DriveStepper.go @@ -1,10 +1,5 @@ package izapple2 -import ( - "fmt" - "strings" -) - /* Stepper motor to position the track. @@ -14,7 +9,7 @@ magnets. The cog is attracted to the enabled magnets, and can stay aligned to a between two. Phases (magnets): 3 2 1 0 3 2 1 0 3 2 1 0 -Cog direction (step within a group): 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 +Cog direction (step within a group): 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 We will consider that the cog would go to the prefferred position if there is one. Independently of the previous position. The previous position is only used to know if it goes up or down @@ -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 } diff --git a/cardDisk2Sequencer.go b/cardDisk2Sequencer.go index 98e1400..6790759 100644 --- a/cardDisk2Sequencer.go +++ b/cardDisk2Sequencer.go @@ -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 { cardBase @@ -27,7 +27,7 @@ type CardDisk2Sequencer struct { q [8]bool // 8-bit latch SN74LS259 register uint8 // 8-bit shift/storage register SN74LS323 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 lastPulse bool @@ -37,8 +37,8 @@ type CardDisk2Sequencer struct { } const ( - disk2MotorOffDelay = uint8(20) // 2 Mhz cycles, TODO: how long? - disk2PulseCcyles = uint8(8) // 8 cycles = 4ms * 2Mhz + disk2MotorOffDelay = uint64(2 * 1000 * 1000) // 2 Mhz cycles. Total 1 second. + disk2PulseCyles = uint8(8) // 8 cycles = 4ms * 2Mhz /* 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 c.catchUp(data) + /* Slot card pins to SN74LS259 mapping: slot_address[0] => latch_oe2_n @@ -185,7 +186,7 @@ func (c *CardDisk2Sequencer) step(data uint8, firstStep bool) bool { */ pulse := false c.lastPulseCycles++ - if c.lastPulseCycles == disk2PulseCcyles { + if c.lastPulseCycles == disk2PulseCyles { pulse = c.drive[0].readPulse() || c.drive[1].readPulse() c.lastPulseCycles = 0 @@ -207,9 +208,8 @@ func (c *CardDisk2Sequencer) step(data uint8, firstStep bool) bool { A3 <= Q7 from 9334 A4 <= pulse transition */ - seqBits := component.ByteToPins(c.sequence) - high := c.register >= 0x80 + seqBits := component.ByteToPins(c.sequence) romAddress := component.PinsToByte([8]bool{ seqBits[1], // seq1 high, @@ -255,7 +255,10 @@ func (c *CardDisk2Sequencer) step(data uint8, firstStep bool) bool { 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 } diff --git a/cardDisk2SequencerDrive.go b/cardDisk2SequencerDrive.go index 1d5aac4..9939435 100644 --- a/cardDisk2SequencerDrive.go +++ b/cardDisk2SequencerDrive.go @@ -41,8 +41,6 @@ func (d *cardDisk2SequencerDrive) insertDiskette(filename string) error { d.data = f d.writeProtected = !writeable - d.mc3470Buffer = 0xf // Test with the buffer full REMOVE - return nil } @@ -75,7 +73,7 @@ func (d *cardDisk2SequencerDrive) readPulse() bool { d.currentQuarterTrack) d.mc3470Buffer = (d.mc3470Buffer<<1 + fluxBit) & 0x0f 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. // Output a random value. 70% zero, 30% one bit = true diff --git a/storage/disketteWoz.go b/storage/disketteWoz.go index 25cdb8d..271637b 100644 --- a/storage/disketteWoz.go +++ b/storage/disketteWoz.go @@ -45,7 +45,7 @@ With the sequencer: - DOS 3.3: Works - * DOS 3.2: Not working, 13 sector disks can't boot - Next choices - - *** Bouncing Kamungas: Not working + - Bouncing Kamungas: Working - Commando: Working - Planetfall: Working - Rescue Raiders: Working