Welcome, Guest. Please login or register.


Author Topic: EP128emu (Read 487895 times)

Offline szipucsu

  • Global Moderator
  • EP addict
  • *
  • Posts: 10101
  • Country: hu
    • Támogató Támogató
    • Webnyelv.hu - Tanuljunk nyelveket!
Re: EP128emu
« Reply #1245 on: 2019.February.10. 17:51:50 »
én úgy csinálom hogy pgup gpdown vált két profil között.
Ááá, ott van a Quick config menüpont, most vettem észre, azért így eléggé könnyű. :D
100 SOUND SOURCE 2,STYLE 128,PITCH 25.2,SYNC 1
110 SOUND PITCH 25,SYNC 1
120 ! Videos

Offline Zozosoft

  • Global Moderator
  • EP addict
  • *
  • Posts: 14779
  • Country: hu
    • http://enterprise.iko.hu/
Re: EP128emu
« Reply #1246 on: 2019.March.19. 22:58:25 »
Ha már úgyis készül új verzió, lehetne még pár apró javítást kérni? :oops:

EXDOS 3 fejlesztése közben Bruce-szal találtunk pár apróbb bugot a floppy emulációban:
-11 szektor/sáv formátumú diskimage-ekre nem működik a formázás (WD sáv írás parancs, aminél megcsináltad, hogy a szektor adatterületeket a megfelelő szektorba írja be), talán a nagyon rövid GAP-eket nem ismeri fel? Vagy esetleg az interleave-s szektor számozás zavar be? FAFO-val és EPDOS-sal is próbáltam. (10 szektoros az megy)
EXDOS 3-ban a FORMAT-nak megadható lesz szektorszám paraméter, és így mindenféle formátumú lemezt tud a beépített parancs is formázni. Ennek tesztelése közben jött elő a dolog.

-Disk Change jel emulációja lemezkép cserénél. Itt rémlik nekem, hogy úgy tizenpár éve volt erről szó, de akkor nem tudtuk pontosan, hogyan működik, meg amúgy is alapértelmezetten le van tiltva az EXDOS-ban. Így aztán lehet, hogy nem is lett vele tovább foglalkozva...
Ez most tisztázva lett, EXDOS 3-nál már meghajtónként lehet beállítani, és tudja kezelni a hagyományos Shugart és az újabb PC szabvány szerinti megoldást is (2-es vagy 34-es lábon a DC).

-Ready jellel kapcsolatban talált olyat Bruce, hogy bizonyos körülmények között 1 másodperces várakozások lépnek fel lemezműveletek közben. Írás müveletnél egy bizonyos ponton motor felpörgetés után a Ready jel változására figyel a DISKIO, és mivel az ep128emu egyből adja a Ready-t, így nem kapja el a változást, és végig várja az 1 másodpercet. Ha jól értem kis késleltetéssel kéne a Ready a motor bekapcsolása után.
De megkérjük Bruce-t, hogy írja le pontosan a dolgot.

Új funkció kérése:
Az EXDOS 3 már használni fogja az órakártya tároló részét is bizonyos beállítások mentésére (ehhez raktam az óraprogramomba egy RTC: eszközt). Megoldható lenne "elemet rakni" az ep128emu-ba? :oops: Azaz az órakártya pár tucat tárolóbájtját elmenteni/betölteni emulátor kilépéskor/induláskor? Mondjuk egy RTC.BIN fájlba, vagy hex dumpban berakni a config fájlba, vagy ilyesmi.

Offline BruceTanner

  • EP lover
  • *
  • Posts: 609
  • Country: gb
Re: EP128emu
« Reply #1247 on: 2019.March.20. 10:35:33 »
(Please excuse English in Hungarian forum)

11 sector format: to fit 11 sectors on a track, it is necessary to make the gap between sectors very small. In fact smaller than the WD177x datasheet says in the minimum :oops:. But it seems to work! But I can see in the ep128emu source code (wd177x.cpp, WD177x::writeDataRegister() )  that it checks for a minimum gap size. These are my notes on track formats (will need fixed-spaced font and 80 columns to display properly):
Code: [Select]
;------------------------------------------------------------------------------
;
; NOTES ON TRACKS, SECTORS AND GAPS
; *********************************
;
; Disk spins at 300rpm = 5rps.
; Data rate is 250kb/s = 31,250 bytes/s.
; 31,250/5 = 6250 bytes/track
; (padding added to 6500 to allow for tolerances in disk speed).
;
; 9 sector format has an Index Address Mark (IAM) for PC compatibility but the
; WD177x doesn't need that for operation. So the PC-incompatible 10 and 11
; sector formats do not have this feature on the track to save track space for
; the extra sector(s).
;
;
; TRACK FORMATS
; ==============
;
; datasheet       9       10       11
; miniumum  sectors  sectors  sectors GAP    Description
; --------  -------  -------  ------  ------ ---------------
; TRACK HEAD:                 
;    32x4Eh  60x4Eh   60x4Eh  !10x4Eh Gap 1a Index postamble         \
;                                                |
;            12x00h                                                   |
;             3xC2h                          IAM preamble             |
;               FCh                          IAM                       > HEAD
;            60x4Eh                   Gap 1b IAM postamble            |
;           ---       --       --                                     |
;           136       60       10            BYTES IN TRACK HEAD     /
;                             
; EACH SECTOR:                                               
;     8x00h+ 12x00h+  12x00h+ ! 3x00h+                       \       \
;     3xA1h   3xA1h    3xA1h    3xA1h Gap 2  ID preamble      |       |
;               FEh      FEh      FEh        ID Mark          |       |
;             1xTRA    1xTRA    1xTRA          Track #        |       |
;             1xSID    1xSID    1xSID          Side #          > ADDR |
;             1xSEC    1xSEC    1xSEC          Sector #       |       |
;             1xLEN    1xLEN    1xLEN          Length #       |       |         
;             2xCRC    2xCRC    2xCRC                         |       | 
;    22x4Eh  22x4Eh   22x4Eh   22x4Eh Gap 3a ID postamble    /         > SECTOR
;    12x00h+ 12x00h+  12x00h+  12x00h+                       \        |    x n
;     3xA1h   3xA1h    3xA1h    3xA1h Gap 3b Data preamble    |       |
;               FBh      FBh      FBh        Data Mark        |       |
;           512xDAT  512xDAT  512xDAT          User data       > DATA |
;             2xCRC    2xCRC    2xCRC                         |       |
;    24x4Eh  84x4Eh   40x4Eh  ! 1x4Eh Gap 4  Data postamble  /        |
;           ---      ---       ---                                    |
;           658      614       566           BYTES PER SECTOR        /
;                             
; TRACK TAIL:                                           
;    16x4Eh 192x4Eh   50x4Eh  !14x4Eh Gap 5  Index preamble          \
;           ---      ---        --                                     > TAIL
;           192       50       14            BYTES IN TRACK TAIL     /
;                             ^
;                             ! = EXCEEDS DATASHEET MINIMUM !
;                             
;                             
;           136+      60+       10+
;         9*658+  10*614+   11*566+
;           192       50        14
;         =====     ====      ====
;          6250     6250      6250            BYTES ON DISK
;
;           136+      60+       10+
;         9*656+  10*612+   11*564+
;           192       50        14
;         =====     ====      ====
;          6232     6230      6228            BYTES IN BUFFER
;                                             different because CRC is 2 bytes
;                                             on disk but 1 byte (F7) in buffer
;
; Padding   250x4Eh  250x4Eh   250x4Eh
;            18x4Eh   20x4Eh    22x4Eh
;         =====     ====      ====
;          6500     6500      6500            BYTES IN BUFFER TOTAL
;
; The extra padding to bring the size up to 6500 is to allow for variation in
; disk speed - bytes from the padding will be written as long as the WD177x is
; requesting more bytes.
;
; So the differences between the images are:
;
; 11 sector format has a smaller Gap1a Index Preamble
; 9 sector format has the IAM and pre- and post-amble
; 11 sector format has a smaller Gap 2 ID Preamble
; all formats have a different Gap 4 Data Postamble
; All formats have a different Gap 5 Index Preamble

Sector interleaving: I have not tried it yet (work in progress!) so it might work anyway! Explanation: the gap between sectors with the 11 sector format is very small. If you are reading more than one sector, by the time you read the second sector it has already passed the head, so the WD177x has to wait for another disk revolution. This makes it slow. So to avoid this, on the 11 sector format, interleaving is used - instead of the obvious sector order of 1,2,3,4,5,6,7,8,9,10,11, the 11-sector format uses something like 1,7,2,8,3,9,4,10,5,11,6. Maybe it will work anyway in ep128emu, maybe not, I just thought I'd mention it...

Disk change: ep128emu provides the disk change signal initially, and the z80 can reset it. This all works, but if the "disk" is changed through the menus, it needs to set the disk change signal again.

/RDY problem: EXDOS 3 does not use /RDY so now avoids the problem! But it is a difference from real hardware. I was able to make EXDOS <= 1.4 show the problem: copy lots of files to A: (I used the IS-DOS help files \HELP\*.HLP) and then delete them all - it takes a long time. This is because the "motor" turns off, so the EXDOS notices this, and waits for /RDY to change state (ie back up to speed) with a 1s timeout, but in ep128emu /RDY is constant (last line of Ep128VM::exdosPortReadCallback() in ep128vm.cpp). You could say this is a bug in EXDOS waiting for /RDY to *change* rather than waiting for /RDY to be *low*, but it is a difference between ep128emu and real hardware.

But nobody else seems to have noticed the /RDY problem and EXDOS 3 does not use /RDY so maybe not the most urgent fix!

B.

Offline Zozosoft

  • Global Moderator
  • EP addict
  • *
  • Posts: 14779
  • Country: hu
    • http://enterprise.iko.hu/
Re: EP128emu
« Reply #1248 on: 2019.March.20. 11:23:47 »
Thanks Bruce for the more details!

Only little note:
So the PC-incompatible 10 and 11 sector formats
10 sector format are only incompatible with MS-DOS, but Windows least from the last 20 years :-) (2000, XP, Vista, 7, 8, 8.1, 10) can use it. (MS-DOS need a disk handler utility (800.COM, FDREAD.EXE, etc), but DR/Novell DOS can handle it). As I know the Linux also don't have a problem about it.
11 sectors format are really incompatible, because the PC controllers can't handle these minimized GAPs.
On 1.44 HD up to 21 sectors also can be used on PC, Microsoft also used it at the latest floppy released software packs (Win 95/98, Office 97), called it Distribution Media Format.
22 sectors also can't work on PC.

Offline BruceTanner

  • EP lover
  • *
  • Posts: 609
  • Country: gb
Re: EP128emu
« Reply #1249 on: 2019.March.20. 12:42:30 »
Thanks Zozo, I wasn't 100% sure - the 10 (and 11) sector formats do not have the Index Address Mark field. The WD177x doesn't need this according to the datasheet but I read something somewhere which suggested the IBM PC floppy controller might need it. Maybe that was just the original IBM PC? Or maybe just bad info? The rest of the 10 sector format is in-spec and very similar to the 9 sector format so I wonder why IBM/MS did not use the 10 sector format in the beginning, and get bigger floppys?

Offline Zozosoft

  • Global Moderator
  • EP addict
  • *
  • Posts: 14779
  • Country: hu
    • http://enterprise.iko.hu/
Re: EP128emu
« Reply #1250 on: 2019.March.20. 13:21:48 »
Thanks Zozo, I wasn't 100% sure - the 10 (and 11) sector formats do not have the Index Address Mark field. The WD177x doesn't need this according to the datasheet but I read something somewhere which suggested the IBM PC floppy controller might need it.
My FAFO still using it at all formats except the 11/22 sectors.

Quote
I wonder why IBM/MS did not use the 10 sector format in the beginning, and get bigger floppys?
i'm also :-) And at the beginnig used a 8 sectors format! Only at version 2.0 added the 9 sectors format. Probably because the first PCs have a belt driven drives, which need a more speed tolerance?

Offline BruceTanner

  • EP lover
  • *
  • Posts: 609
  • Country: gb
Re: EP128emu
« Reply #1251 on: 2019.March.20. 14:07:23 »
My FAFO still using it at all formats except the 11/22 sectors.
Can it show the track pattern, gaps etc? It would be interesting to see!

i'm also :-) And at the beginnig used a 8 sectors format! Only at version 2.0 added the 9 sectors format. Probably because the first PCs have a belt driven drives, which need a more speed tolerance?
And the 5 1/4" formats grew from 8" formats, which had to work with even older 1970s technology. I don't know what the IAM is for - it tells you where the start of the track is, but there is a little hole in the disk for that! I thought maybe that came from 8" disks too.

Offline IstvanV

  • EP addict
  • *
  • Posts: 4822
Re: EP128emu
« Reply #1252 on: 2019.March.20. 14:59:43 »
I have changed track writing in the Git source code, FAFO seems to work now with 11 sectors per track.

On the RDY and disk change signals, how are these expected to work exactly? I also tried to find where the EXDOS ROM is checking RDY, but I could not find it anywhere during simple usage like :DIR or saving a small BASIC program.

Can it show the track pattern, gaps etc? It would be interesting to see!

These are the first few sectors in "11a" mode:
Code: [Select]
00000000  4e 00 00 00 00 f5 f5 f5  fe 4f 00 06 02 f7 4e 4e  |N........O....NN|
00000010  4e 4e 4e 4e 4e 4e 4e 4e  4e 4e 4e 4e 4e 4e 4e 4e  |NNNNNNNNNNNNNNNN|
00000020  4e 4e 4e 4e 00 00 00 00  00 00 00 00 00 00 00 00  |NNNN............|
00000030  f5 f5 f5 fb d9 d9 d9 d9  d9 d9 d9 d9 d9 d9 d9 d9  |................|
00000040  d9 d9 d9 d9 d9 d9 d9 d9  d9 d9 d9 d9 d9 d9 d9 d9  |................|
*
00000230  d9 d9 d9 d9 f7 00 00 00  00 f5 f5 f5 fe 4f 00 01  |.............O..|
00000240  02 f7 4e 4e 4e 4e 4e 4e  4e 4e 4e 4e 4e 4e 4e 4e  |..NNNNNNNNNNNNNN|
00000250  4e 4e 4e 4e 4e 4e 4e 4e  00 00 00 00 00 00 00 00  |NNNNNNNN........|
00000260  00 00 00 00 f5 f5 f5 fb  d9 d9 d9 d9 d9 d9 d9 d9  |................|
00000270  d9 d9 d9 d9 d9 d9 d9 d9  d9 d9 d9 d9 d9 d9 d9 d9  |................|
*
00000460  d9 d9 d9 d9 d9 d9 d9 d9  f7 00 00 00 00 f5 f5 f5  |................|
00000470  fe 4f 00 07 02 f7 4e 4e  4e 4e 4e 4e 4e 4e 4e 4e  |.O....NNNNNNNNNN|
00000480  4e 4e 4e 4e 4e 4e 4e 4e  4e 4e 4e 4e 00 00 00 00  |NNNNNNNNNNNN....|
00000490  00 00 00 00 00 00 00 00  f5 f5 f5 fb d9 d9 d9 d9  |................|
000004a0  d9 d9 d9 d9 d9 d9 d9 d9  d9 d9 d9 d9 d9 d9 d9 d9  |................|
*
00000690  d9 d9 d9 d9 d9 d9 d9 d9  d9 d9 d9 d9 f7 00 00 00  |................|

And in "11b":
Code: [Select]
00000000  4e 00 00 00 00 00 00 00  00 f5 f5 f5 fe 4f 00 06  |N............O..|
00000010  02 f7 4e 4e 4e 4e 4e 4e  4e 4e 4e 4e 4e 4e 4e 4e  |..NNNNNNNNNNNNNN|
00000020  4e 4e 4e 00 00 00 00 00  00 00 00 00 00 00 00 f5  |NNN.............|
00000030  f5 f5 fb d9 d9 d9 d9 d9  d9 d9 d9 d9 d9 d9 d9 d9  |................|
00000040  d9 d9 d9 d9 d9 d9 d9 d9  d9 d9 d9 d9 d9 d9 d9 d9  |................|
*
00000230  d9 d9 d9 f7 00 00 00 00  00 00 00 00 f5 f5 f5 fe  |................|
00000240  4f 00 01 02 f7 4e 4e 4e  4e 4e 4e 4e 4e 4e 4e 4e  |O....NNNNNNNNNNN|
00000250  4e 4e 4e 4e 4e 4e 00 00  00 00 00 00 00 00 00 00  |NNNNNN..........|
00000260  00 00 f5 f5 f5 fb d9 d9  d9 d9 d9 d9 d9 d9 d9 d9  |................|
00000270  d9 d9 d9 d9 d9 d9 d9 d9  d9 d9 d9 d9 d9 d9 d9 d9  |................|
*
00000460  d9 d9 d9 d9 d9 d9 f7 00  00 00 00 00 00 00 00 f5  |................|
00000470  f5 f5 fe 4f 00 07 02 f7  4e 4e 4e 4e 4e 4e 4e 4e  |...O....NNNNNNNN|
00000480  4e 4e 4e 4e 4e 4e 4e 4e  4e 00 00 00 00 00 00 00  |NNNNNNNNN.......|
00000490  00 00 00 00 00 f5 f5 f5  fb d9 d9 d9 d9 d9 d9 d9  |................|
000004a0  d9 d9 d9 d9 d9 d9 d9 d9  d9 d9 d9 d9 d9 d9 d9 d9  |................|
*
00000690  d9 d9 d9 d9 d9 d9 d9 d9  d9 f7 00 00 00 00 00 00  |................|

Offline BruceTanner

  • EP lover
  • *
  • Posts: 609
  • Country: gb
Re: EP128emu
« Reply #1253 on: 2019.March.20. 16:29:56 »
I have changed track writing in the Git source code, FAFO seems to work now with 11 sectors per track.
These are the first few sectors in "11a" mode:
:ds_icon_cheesygrin: Thank you!

On the RDY and disk change signals, how are these expected to work exactly? I also tried to find where the EXDOS ROM is checking RDY, but I could not find it anywhere during simple usage like :DIR or saving a small BASIC program.
Disk change: it is working in ep128emu, all that is missing is to set it when a the disk image is changed. in ep128vm.cpp it is initialized during cold reset
Code: [Select]
      if (isColdReset)
        floppyDrives[i].setDiskChangeFlag(true);
and it is reset at the right time
Code: [Select]
      if (value & 0x40)
        vm.wd177x.getFloppyDrive().setDiskChangeFlag(false);
but it is never set from anywhere else - just need to set it when a new disk image is set so the z80 code knows there is a new disk.

RDY: it is difficult to make EXDOS use it! Probably why nobody has noticed it before!

When the motor is OFF and a WD command is given, the WD turns the motor on. It will take some time for the motor to get up to the correct speed. On read operations, EXDOS does not wait for the motor to speed up, it just keeps re-trying the read until it works. But on write operations it must wait for motor to spin up to speed before writing data, and it does this by looking at RDY.

But most of the time for write operations the motor will already be on because it will have been reading FATs and directories, so it does not need to wait. But if it *does* need to wait, it looks at RDY. Current EXDOS versions waits for it to change state but I think that might be a bug, it should just look for it to go low. This would work with ep128emu because ep128emu always says RDY.

RDY is set by a real drive when it has counted 6 disk rotations. The WD can do that instead and the new EXODOS 3 uses this so that it does not need to look at RDY (newer PC style drives do not even have a RDY signal).

I made EXDOS look at RDY by copying files to a nearly-full disk. Current EXDOS is very inefficient allocating disk space on a nearly-full disk, so it takes a long time, and the motor turns off before the write.

In EXDOS 1.3/1.4 the code that looks at RDY goes:
Code: [Select]
BIT 7,E ;Test if motor on delay is needed
JR NZ,NO_MOT ;If not then skip.
SET 7,E ;If it is then set motor on flag
;
SET 3,C ;Get current state of /RDY signal
IN B,(C) ; in order to test for a change.
;
LD HL,0E935h ; (E935h*67)/4 = 1000000us = 1s 
MOT_LP: IN A,(C) ;14T
XOR B ;5 T Test if /RDY line has changed
RRCA ;5 T
JR NC,NO_RDY ;13T Skip if not
IN B,(C) ; Get new /RDY state
LD A,00CH ; If timeout is more than 50ms
CP H ;   from its epiry then set it to
JR NC,NO_RDY ;   50 ms, otherwise leave it alone.
LD H,A
NO_RDY: DEC HL ;7 T Decrement timeout count
LD A,H ;5 T
OR L ;5 T
JR NZ,MOT_LP  ;13T Loop 'til expired.  67T per loop
;
NO_MOT: CODE LXI H ;Skip the next instruction.
;
;
NO_DLY: RES 2,E ;For read sectors and verfiy sectors,
; clear "settle delay" flag.
LD (IY+DELAY_FLAGS##),E ;Store new delay flags.

To emulate a real drive, it would have to go Not Ready when the motor goes off, and Ready *some time* after the motor is turned on by a WD command (in EXDOS this will be a seek command before the write). On a real drive *some time* is up to about 1s but usually a few 100 ms.

But nobody else has noticed this, and EXDOS 3 will not use RDY, so probably not worth spending a long time on this unless you particularly want to make the emulation more accurate.

B.

Offline Povi

  • EP addict
  • *
  • Posts: 2316
  • Country: hu
    • http://povi.fw.hu
Re: EP128emu
« Reply #1254 on: 2019.March.20. 17:06:35 »
EXDOS 3 fejlesztése közben

Már a 3 készül??? :shock:

Én még csak az Exdos 2.0-ról tudok, de az ügyben is nagy a titkolódzás! :-)
*** Speicherplatz zu klein

Offline BruceTanner

  • EP lover
  • *
  • Posts: 609
  • Country: gb
Re: EP128emu
« Reply #1255 on: 2019.March.20. 17:16:30 »
minél nagyobb a szám, annál jobb a szoftver :mrgreen:

Offline IstvanV

  • EP addict
  • *
  • Posts: 4822
Re: EP128emu
« Reply #1256 on: 2019.March.20. 17:32:03 »
Thanks for the information, so if I understand it right, it would work if I set RDY to 0 only when the motor is at full speed and there is a disk image opened, and 1 at any other time? Because of the LED display, there is already a timer that simulates spinning down, so it is not difficult to add a spin up period as well, but it would only affect RDY.

In theory, ep_fdd.cpp sets the disk change flag at line 269 whenever an image file is opened or closed, but maybe this is buggy for some reason?

Offline Zozosoft

  • Global Moderator
  • EP addict
  • *
  • Posts: 14779
  • Country: hu
    • http://enterprise.iko.hu/
Re: EP128emu
« Reply #1257 on: 2019.March.20. 19:27:28 »
Már a 3 készül??? :shock:

Én még csak az Exdos 2.0-ról tudok,
A prototípus Modell 911-hez készült a 2.0, ami csak DISKIO időzítésekben különbözött az 1.2-től. (Illetve fordítottam 1.3-nak megfelelő 2.1-et is).
Mivel így a 2.x sor már meg lett kezdve, az új generációval 3.x-re ugrottunk.

Quote
de az ügyben is nagy a titkolódzás! :-)
Akkora a titkolódzás, hogy még saját topicja is van :ds_icon_cheesygrin:

Offline BruceTanner

  • EP lover
  • *
  • Posts: 609
  • Country: gb
Re: EP128emu
« Reply #1258 on: 2019.March.20. 23:26:11 »
it would work if I set RDY to 0 only when the motor is at full speed and there is a disk image opened, and 1 at any other time? Because of the LED display, there is already a timer that simulates spinning down, so it is not difficult to add a spin up period as well, but it would only affect RDY.
Yes that sounds perfect.

In theory, ep_fdd.cpp sets the disk change flag at line 269 whenever an image file is opened or closed, but maybe this is buggy for some reason?
Yes I agree that looks right! I will see if I can reproduce my original problem, maybe it was an EXDOS problem after all.

Offline Povi

  • EP addict
  • *
  • Posts: 2316
  • Country: hu
    • http://povi.fw.hu
Re: EP128emu
« Reply #1259 on: 2019.March.21. 11:12:35 »
Akkora a titkolódzás, hogy még saját topicja is van :ds_icon_cheesygrin:

Á, ez valamiért elkerülte a figyelmemet :-)
*** Speicherplatz zu klein