Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MFM floppy emulator #34

Open
wants to merge 31 commits into
base: main
Choose a base branch
from
Open

Add MFM floppy emulator #34

wants to merge 31 commits into from

Conversation

jepler
Copy link
Member

@jepler jepler commented Oct 17, 2024

Targeted feature list for this version

  • Basic flux output
  • read flux data from SD cards
  • select file from SD card
  • obey track changes
  • obey side changes
  • obey motor & select lines
  • handle density & RPM options by image file size detection

This PR will not encompass

  • flux writing from computer to floppsy
  • working with fm-coded data

Later, the RP2040 PIO peripheral will want to use this compact
flux representation.
though it's not mfm-flux
I used jumper wires between my metro & a genuine greaseweazle.

gw host software does display a warning twice for each track:
```
Unknown mark 4e
```

This is very proof of concept quality at the moment but hey it's there!
@jepler
Copy link
Member Author

jepler commented Oct 25, 2024

As a milestone, greasweazle can now grok the flux produced by the USB floppy sketch.

$ gw read  --tracks c=0:h=0 --format ibm.1440 bad.img
*** TEST/PRE-RELEASE: 1.16.4.dev4+g5b93ade.d20240619
*** Use these tools ONLY for test and development!!
Reading c=0:h=0 revs=2
Format ibm.1440
Unknown mark 4e
Unknown mark 4e
T0.0: IBM MFM (18/18 sectors) from Raw Flux (188840 flux in 400.52ms)
Cyl-> 0
H. S: 0
0. 0: .
0. 1: .
0. 2: .
0. 3: .
0. 4: .
0. 5: .
0. 6: .
0. 7: .
0. 8: .
0. 9: .
0.10: .
0.11: .
0.12: .
0.13: .
0.14: .
0.15: .
0.16: .
0.17: .
Found 18 sectors of 18 (100%)

dunno what's up with the unknown markers yet.

@jepler
Copy link
Member Author

jepler commented Oct 29, 2024

Now, real data from the SD card is returned. The side number is not used/checked yet.

@jepler jepler changed the title Add ability to encode flux "compactly" Add MFM floppy emulator Oct 29, 2024
this also enables working on the featherwing, with no defined PIN_CARD_CS;
in this case, test data is output instead of a real disk image.
Otherwise, we end up doing extra work: A sequential read will go from
e.g., track 0 side 1 to track 1 side 0. But there's a moment in there
where the inputs to floppsy are "track 1 side 1", so we flux-convert
T1.1 and then immediately have to convert T1.0. This would often make
GW report that it failed reading a track the first time (T70.0 in this
case):

```
T69.1: IBM MFM (18/18 sectors) from Raw Flux (156238 flux in 400.36ms)
T70.0: IBM MFM (0/18 sectors) from Raw Flux (78084 flux in 236.36ms)
T70.0: IBM MFM (18/18 sectors) from Raw Flux (311958 flux in 836.88ms) (Retry #1.1)
```

After this change, GW ripped a whole floppy without needing to retry and
without getting any weird transient failures.
@jepler jepler marked this pull request as ready for review October 31, 2024 19:07
@jepler
Copy link
Member Author

jepler commented Oct 31, 2024

@ladyada this is ready for review, though it still needs to be tested with a real PC host as well.

My setup:

  • feather rp2040
  • old revision floppy featherwing without level translators
  • adalogger featherwing modified to place SD_CS on pin D4
  • "change floppy" button hooked to RX pin
  • custom pinout in custom_pinout.h:
#pragma once
// old featherwing pinout
#define DENSITY_PIN A0 // IDC 2
#define INDEX_PIN A1   // IDC 8
#define SELECT_PIN A2  // IDC 12
#define MOTOR_PIN A3   // IDC 16
#define DIR_PIN 24     // IDC 18
#define STEP_PIN 25    // IDC 20
#define WRDATA_PIN 13  // IDC 22
#define WRGATE_PIN 12  // IDC 24
#define TRK0_PIN 11    // IDC 26
#define PROT_PIN 10    // IDC 28
#define READ_PIN 9     // IDC 30
#define SIDE_PIN D6    // IDC 32
#define READY_PIN D5   // IDC 34
#define PIN_CARD_CS D4 // modified adalogger featherwing
#define DISKCHANGE_PIN 1 // RX

the code should probably be polished up some (and then a lot more when we have floppsy with LCD & 4 buttons) but I think the functionality is there.

I tested all 4 common sizes (360, 1200, 720, 1440) with GW decoding them all just fine. These were basic images I created on my computer with a FAT image creator (mkfs.fat), no content on them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant