Author Topic: FDC floppy t80ds detection  (Read 3529 times)

0 Members and 1 Guest are viewing this topic.

Offline freemac

  • CPC6128
  • ****
  • Posts: 255
  • Country: 00
  • Liked: 191
FDC floppy t80ds detection
« on: 13:59, 14 September 15 »


I'm currently refactoring my FDC instruction set (CoreAmstrad/MiST-board), and I have some littles questions :  ::)
* for detecting a double sided 80 track data dsk, I have just to do a cat ? I currently succeed that with PARADOS only...
* then what can I do to validate drive |B ? (as PARADOS does manage only drive |A with multiple dsk format...)
* A read-ID called several times quickly does give sector ID in order ? EndOfCylinder flag is usefull ?
* MT (multi track) option does change track as listed in dsk format : track 0 side 0, track 0 side 1, track 1 side 0, ... ?
* MT (multi track) option does apply only on READ_ID command ?
* To detect a double sided disk, what have I to implement : Head (with US0 US1), H of CHRN or TS (two side (zero seem YES)) ?


And somes more, about protection disk : :D
* ST0 and ST1 in dsk format are valid both for READ_ID and READ_DATA commands ?
* And not existing Track returns a certain CHRN value ?
* Command reading DELETED TRACK does effect as reading DATA TRACK ? (it seems not having difference in dsk file format definition)
« Last Edit: 15:04, 14 September 15 by freemac »

Offline arnoldemu

  • Supporter
  • 6128 Plus
  • *
  • Posts: 5.273
  • Country: gb
    • Unofficial Amstrad WWW Resource
  • Liked: 2152
Re: FDC floppy t80ds detection
« Reply #1 on: 16:01, 14 September 15 »
For FDC read the documentation ;)

http://www.classiccmp.org/dunfield/r/765.pdf

Read about the IBM system 34 disc format, the structure of the mfm data ;)

This tells you about end of cylinder, and multi track.

For detecting double sided: Why? The dsk format describes if disc is double sided or not.
If you need to use fdc there is no conclusive method. You could try the "two side" state of st3, you can read an id on both sides (no id on side 2 could mean it's single sided, but also that the track you tested is not formatted on side 2), you could read a sector on both sides and compare the data.

For drive B, you can check if it becomes ready or not when motor is on (but same if no disc in the drive). For 3" drives there is a special combination of st3 that means no drive (CPM uses this), but not true for 3.5" drives.

Multiple read ids do give the ids in order, but doesn't start on first id of track. End of cylinder is not used here.
How can you know the number and start? You could see if they repeat. Or you could do a read sector on an id that doesn't exist in the track to sync to the index, then do read ids, but they you don't know the number. Use read track with a large number to read some of the mfm data and interpret it.

st0/st1 in dsk is used for read data/read deleted data. the data error in id field is valid for read_id.
not existing track sometimes returns the same value, best to try and read id and look for an error (missing address mark).

read data and read deleted data: read the pdf. It describes it.

EDIT: Best way. Test on real hardware!
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

Offline freemac

  • CPC6128
  • ****
  • Posts: 255
  • Country: 00
  • Liked: 191
Re: FDC floppy t80ds detection
« Reply #2 on: 17:47, 14 September 15 »

For detecting double sided: Why? The dsk format describes if disc is double sided or not.
I think I'll try something like
Quote
|DIRDOS,"A0"
|DIRDOS,"A1"


Thanks a lot  8)

Offline freemac

  • CPC6128
  • ****
  • Posts: 255
  • Country: 00
  • Liked: 191
Re: FDC floppy t80ds detection
« Reply #3 on: 10:24, 15 September 15 »


I did some tests and found my own test-bench about testing double-side/80track disks (currently failing in my project CoreAmstrad r004.2)

I do use ROMDOS rdosxl48.rom in x06, and PROTEXT in x01

I tested several disks :
* 80tds (DATA, 80 tracks double sided) do not display 750KB during a CAT but works everywhere (it is a standard running in original Amstrad ROMs, cat does list 40tss, but running a file using certain code you access 80tds fully)
* DOS D2 : does run in |B
* IBM 80tds : does run in |B
* simple 40tss : does run in |A and |B

ROMDOS is really cool

My test-bench is :
* do insert 40tss in |A, IBM 80tds in |B
* do run PROTEXT : |cp
* Write a file.txt (ESC, write, ESC), and save it on |A [/size](s file.txt)
* reset
* load file.txt in PROTEXT (l file.txt)
* B (equals |B command but in PROTEXT console)
* cat
* s file.txt
* reset
* |B
* |cp
* l file.txt
* FAIL in CoreAmstrad r004.2
I'll retry this test-bench after my next evolve.

Offline freemac

  • CPC6128
  • ****
  • Posts: 255
  • Country: 00
  • Liked: 191
Re: FDC floppy t80ds detection
« Reply #4 on: 11:44, 21 September 15 »

ROMDOS test passed using DOS D2 dsk in |B (t80ds (750KB)) in CoreAmstrad r004.3 8)
- HD is physical head, H is logical head, I turn TS (two sides) into 1 with a dsk is double-sided (not certain)
- I do increment readID SectorID, using MultiTrack when enabled.
- I now read ST1 and ST2 coming from dsk file format, and apply them when I'm not in a "wait state".
- I remark that ROMDOS does make 4KB files when saving a little .bas file instead of 1KB (with original Amstrad ROM), that's correct with DOS D2, but it is strange with simple t40ss DATA dsk.
- IBM dsk has problems using ROMDOS, they cat as t80ds (750KB), but does write simple .bas file in 2KB, so one file on two does run fine only (the others does display "Line Too Long" message), perhaps ROMDOS does not support my IBM dsk.
- FutureOS does now detect somes dsk format but does not list file content at each times...


I found a protected dsk called "Macadam ERE", it has a missing track (a track of size zero), what flag shall have to enable in this case ? and what shall I return as CHRN in command part ? What about sector not found ?


Using MultiTrack enabled, and specially a End of Track (final sector number (not id ?)), how does it works ? Have I to expect a command same relaunch for each sector of the set wanted ?
« Last Edit: 14:58, 21 September 15 by freemac »

Offline TFM

  • Visit the mysteries of the CPC at www.futureos.de
  • Supporter
  • 6128 Plus
  • *
  • Posts: 9.899
  • Country: aq
  • Space Chicken for FutureOS is free!
    • index.php?action=treasury
    • FutureOS - The revolution on CPC!
  • Liked: 1971
Re: FDC floppy t80ds detection
« Reply #5 on: 19:42, 21 September 15 »
- FutureOS does now detect somes dsk format but does not list file content at each times...


Currently it does detect: System, IBM, Data (all 40 Track, single sided) and Vortex (80 tracks, double sided). Which drive (A-H) you use doesn't matter.


Great to see your project advancing.  :)
TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

Offline freemac

  • CPC6128
  • ****
  • Posts: 255
  • Country: 00
  • Liked: 191
Re: FDC floppy t80ds detection
« Reply #6 on: 10:45, 22 September 15 »
Currently it does detect: System, IBM, Data (all 40 Track, single sided) and Vortex (80 tracks, double sided). Which drive (A-H) you use doesn't matter.
Can I have a virgin Vortex (80tds) dsk image ?  ;)

Offline TFM

  • Visit the mysteries of the CPC at www.futureos.de
  • Supporter
  • 6128 Plus
  • *
  • Posts: 9.899
  • Country: aq
  • Space Chicken for FutureOS is free!
    • index.php?action=treasury
    • FutureOS - The revolution on CPC!
  • Liked: 1971
Re: FDC floppy t80ds detection
« Reply #7 on: 19:18, 23 September 15 »
Can I have a virgin Vortex (80tds) dsk image ?  ;)


Try this please...



TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

Offline freemac

  • CPC6128
  • ****
  • Posts: 255
  • Country: 00
  • Liked: 191
Re: FDC floppy t80ds detection
« Reply #8 on: 13:02, 28 September 15 »


r004.4 commited : using ROMDOS all is fine now  8)


But I still have an empty calatog using FutureOS...
Vortex dsk is detected also, but cat as 154KB and writing a simple file (save "hello"), this last one is not listed in FutureOS catalog  :picard:


Offline freemac

  • CPC6128
  • ****
  • Posts: 255
  • Country: 00
  • Liked: 191
Re: FDC floppy t80ds detection
« Reply #9 on: 11:52, 29 September 15 »

Yeah, I found something around that.
Here a test sequence :
Quote
do not insert dsk
|a
|ucpm
crash (somes drives access instead of nothing)
Result in several FDC command, somes being x08,
x08 does consume sometimes two results, sometimes one result only.
That case was not implemented in my project ^^'




So here some questions :
- what do you know about optionnal FDC command not totaly consumed ?
- what do you know about parallel FDC commands (I think here only seek can be done in same times cross two drives...)

Offline arnoldemu

  • Supporter
  • 6128 Plus
  • *
  • Posts: 5.273
  • Country: gb
    • Unofficial Amstrad WWW Resource
  • Liked: 2152
Re: FDC floppy t80ds detection
« Reply #10 on: 16:00, 29 September 15 »
Seek and recalibrate are parallel commands.
These are the only ones.

command 08: is sense interrupt status.

FDC can generate an interrupt. On CPC it's not connected.

Sense interrupt status checks this interrupt and if there is one, it will return 2 bytes. ST0 and the current "cylinder"/track of the drive that finished the seek. To see which drive it was, bits 1,0 of ST0 will tell you.

If there is no interrupt, it returns 1 byte. (always 0x080). It is almost like it is telling you "no results available".

The interrupt is triggered within the fdc when any seek has finished.

So it is possible to use sense interrupt status to look at all the finished seeks. The FDC will return 0x080 until interrupt is set, then you can read it as many times as you want. It will give you the status of each drive (if it's done), starting with drive 0.

Example:

Recalibrate all drives, seek all drives to the same track. If all are the same, then you can use sense interrupt status to read the current track of each drive.

If you recalibrate and seek drives to different tracks then you can use sense interrupt status to see the result when each finishes.

My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

Offline arnoldemu

  • Supporter
  • 6128 Plus
  • *
  • Posts: 5.273
  • Country: gb
    • Unofficial Amstrad WWW Resource
  • Liked: 2152
Re: FDC floppy t80ds detection
« Reply #11 on: 16:01, 29 September 15 »
For FDC you must always send ALL command bytes, read ALL execution data and read ALL result data.
FDC will tell you if there are more bytes in result, so you can then know if sense interrupt status returns 1 or 2 bytes.
After first byte, FDC will either finish command and tell you no more bytes, or it will tell you there are more bytes to read.
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

Offline freemac

  • CPC6128
  • ****
  • Posts: 255
  • Country: 00
  • Liked: 191
Re: FDC floppy t80ds detection
« Reply #12 on: 12:18, 05 October 15 »


I have to implement several blocks transmit (EOT>R)
If I understood correctly :
* DTL is taken into account only if N==0 (or else full block is transmitted)
* DTL is really a lengh (so between 0 and 511, so 511 doesn't transmit full block but only 511 bytes, and 0 does transmit 0 bytes...)
* DTL does apply only on last transmit block (EOT)


I have not yet implemented it completly, but I start to show cool things in FutureOS :)


I found another test bench, about "Command Issue".
Quote
insert a DATA dsk
ùcpm
It is running a failing read FDC command, followed by a special "sense interrupt" command returning a CommandIssue result (x80)
I show also sometime a "abnormal ReadySignalHasChanged" returned by several "sense interrupt" command, before this CommandIssue result (x80) conclusion.


In original CPC, does this test bench show several question messages ? or only the first one ? or nothing in screen ?


Offline freemac

  • CPC6128
  • ****
  • Posts: 255
  • Country: 00
  • Liked: 191
Re: FDC floppy t80ds detection
« Reply #13 on: 10:56, 06 October 15 »
r004.7 is out : "R-Typeee" game unlocked  8)


I don't succeed yet in copying files in FutureOS, but now file list seems ok.
Perhaps a problem on my state-machine around multi-bloc+DTL write operation, I'll check that  :-X

Offline freemac

  • CPC6128
  • ****
  • Posts: 255
  • Country: 00
  • Liked: 191
Re: FDC floppy t80ds detection
« Reply #14 on: 14:48, 15 October 15 »

r004.7.2 is out : it is my final version for this r004 fork.

It contains a debug of my state-machine around multi-bloc+DTL write operation, and also an more logical "command issue".

I personally decided to implement "command issue" (x80 response on "sense interrupt status" FDC command) like this :
* I turn on is_issue boolean when I leave the normal state machine way, for sample writing while a result read operation, that does "reset" the state-machine, and permit executing a normal command.
* This is_issue boolean is back to false when I execute another next command (except "sense interrupt status" cmd)
* context of is_issue is "each FDC", not "each drive".

On this version I can copy a disk content from |a to |b using FutureOS, but I have problem copying some files from |b to |a.

r004.7.2 is a final version because I can't insert more line of program in my current FDC component (problem of general FPGA performance), next time I shall refactor this component using a big "switch case" instruction, that is better than "if - elsif - elsif" in electronical language. I prefer showing large test before refactoring, it is why r004.7.2 became a final version of CoreAmstrad, ready to be over-tested by end-users.

Spoiler: show
Next version of CoreAmstrad (r005) shall be here in January 2016, it will add an original SCART output mode, that's will my next step for this project.



Have fun !

Offline TFM

  • Visit the mysteries of the CPC at www.futureos.de
  • Supporter
  • 6128 Plus
  • *
  • Posts: 9.899
  • Country: aq
  • Space Chicken for FutureOS is free!
    • index.php?action=treasury
    • FutureOS - The revolution on CPC!
  • Liked: 1971
Re: FDC floppy t80ds detection
« Reply #15 on: 23:54, 15 October 15 »
Sounds like you got quite some work done! Hats off! Great work! :) :) :)
TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus