Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!cs.utexas.edu!usc!snorkelwacker!ira.uka.de!smurf!gopnbg!tmpmbx!einoed!hase_1!hase From: hase@hase_1.UUCP (Hartmut Semken) Newsgroups: comp.sys.atari.st Subject: Re: Floppy drive 1.44 meg woes! Message-ID: <418@hase_1.UUCP> Date: 11 Feb 90 09:55:00 GMT References: <9002030029.AA23185@jade.berkeley.edu> <2103@ultb.isc.rit.edu> Organization: h.a.s.e., Berlin, West Germany Lines: 235 clf3678@ultb.isc.rit.edu (C.L. Freemesser) writes: >> I'm haveing a few problems hooking up my 1.44 meg teac. I was wondering > From what I know, you can't use HD on the ST. The controller chip >can't handle it. Just be glad it works in 720k mode. :^) Well, you can, if you hack the hardware. Here we go again: The trick is to double the clock frequency of the controller chip, so it will talk twice as fast to the drive: the bit stream has "high-density" format. A clock of 16 MHz is well behind specification (the WD1772 is rated to run at up to 10 MHz), but it will work most of the time. The hack consists of two parts: hardware and software and works with high density drives only! Now: the hardware. The clock pin of the WD1772 is pin 18. It is normally hooked to the 8 MHz clock. Cut this pin and connect it to the output of a simple circurit. feed the two inputs of this simple circurit with 8 MHz and 16 MHz clocks (16 MHz can be get at SHIFTER pin 39). The "simple circurit" mentioned above could be a simple, manual switch. Now You are able to select two clock frequencies and therfore two "modes" for the controller chip: double density and high density. The simple circurit could also be a multiplexer (74LS157, I think) controlled by the "I detected a HD-disk in me"-output of the floppy drive (the TEAC FD 235 HFN provides this outout on pin 2 if a jumper is set; the 235 HFN has a second jumper that enables internal detection of HD disks: this must be set, too). With the MUX, a disk inserted will select the appropriate mode of operation automatically. Do not worry about two drives in different modes: when copying from one drive to the other, the clock rate will be switched once to twice a second. This will not trouble the controller (remember the clock to be in the range of Megahertz...). If you want to connect one HD drive and one DD drive, you'll need two more TTL gates (one 74LS00 will do) to make sure, the controller is in DD mode for the DD only drive: invert the HD-detected-output (it is LOW for DD before, HIGH for DD behind the inverter) and feed it into a NAND together with drive select for the DD drive. Let a HIGH output of the NAND select DD-clock (8 MHz). Now "not-HD-detected OR DD-drive-select" will select DD mode, right? With two HD drives, there is no problem at all :-) Now for the software: The controller uses its clock as base for all timings. The pulse width and time between pulses for the step line are controller controlled. To make it short: with the doubled clock the controller will try to make the head step twice as fast: he will send a step pulse every 1.5 milliseconds if set to 3 milliseconds (which is TOS standard). Just set the step rate to 6 milliseconds to make the controller step 3 milliseconds in HD mode (well, the 6 milliseconds steps in DD mode will slow down floppy operation a bit, but not that much. Not stepping, reading and writing takes the time!). How to set the step rate? Well, there is a documented TOS variable for the step rate at 0x440 called seekrate. The step rate in this variable will be used by the BIOS after a call of the routine, pointed to by "hdv_init" (the hdv_init routine seems to initialize the BIOS parameter blocks for the floppies). The pointer to hdv_init can be found at 0x46A (this is a supported TOS variable, too). Look at the MWC-Assembler source below. The second thing is to get a formatter that will format 18 sectors per track. HYPERFORMAT by Claus Brodt is such a thing, but a simple formatter hacked from the example in the Mark Williams C Lexicon did the same. It's included below. For help try to write to hase@hase_1.mbx.sub.org, but it'll probably bounce; our mail service is fading fast... I'll try to reply to anything, I finally get. hase ------- cut for seek6.s ----------- / module name seek6 .shri .globl main_ main_: clr.l -(sp) move.w $0x20,-(sp) trap $1 addq.l $6,a7 move.l d0,_save_ssp move.w $0,0x440 / 0 => 6 ms lea 0x46a,a0 move.l (a0),d0 movea.l d0,a0 jsr (a0) move.l _save_ssp,-(sp) move.w $0x20,-(sp) trap $1 addq.l $6,a7 .even _save_ssp: .blkl 1 / seek rate codes are 0,1,2,3 for 6,12,2,3 milliseconds ------------ cut for formath.c ------------- /* formath.c Formatter fuer High Density Disketten */ /* nur fuer angepasste Hardware! Floppycontroller und Laufwerk */ /* muessen High-Density tauglich sein! */ /* Hartmut Semken, Lupsteiner Weg 67 1000 Berlin 37 */ /* hase@hase_1.mbx.sub.org or hase@netmbx.mbx.sub.org */ /* 03-SEP-89 */ #include #include #include #define SLEEPTIME 1 /* 1: Zeitschleife, 0: Taste */ #define BLANK (0xE5E5) #define MAGIC (0x87654321L) #define BUFSIZE (20*1024) /* Platz fuer mehr als 18 Sektoren... */ #define DEVICE 0 /* 0 = Floppy A, 1 = Floppy B */ #define SIDES 2 /* je */ #define SECTORS 18 /* nach */ #define TRACKS 80 /*Belieben */ #define TOTSEC (TRACKS * SIDES * SECTORS) extern int errno; main(){ int track; int side; int status; short *bf; register char reply; short *middle; char buffer[512]; printf("\033E\n"); printf("Public Domain High Density Mini Formatter\n"); printf("von H. Semken\nDer Autor garantiert in keiner Weise fr die Funktion\nDieses Programmes.\nBenutzung auf eigene Gefahr.\n"); printf("\n\n\n"); printf("\007\033pFormatiere Diskette in Drive %c\033q\n%d Seiten\n%d Sektoren pro Spur\n%d Spuren\n\n", (65+DEVICE), SIDES, SECTORS, TRACKS); printf("Wirklich formatieren? "); fflush(stdout); if ((reply = Crawcin()) != 'y' && reply != 'Y' && reply != 'j' && reply != 'J') { printf("Nein. Floppy nicht formatiert.\n"); sleep(1); Pterm0(); } printf("Ja.\n"); printf("Diskette einlegen; Taste drcken..."); fflush(stdout); Crawcin(); printf("\n"); bf = malloc(BUFSIZE); for (track = TRACKS-1; track >= 0; track--) { for (side = 0; side < SIDES; side++) { printf("Formatiere Spur %d, Seite %d", track, side); fflush(stdout); status = Flopfmt(bf, 0L, DEVICE, SECTORS, track, side, 1, MAGIC, BLANK); if (status) { middle = bf; printf("\t%d\n", status); while (*middle) { printf("\tDefekter Sektor %d\n", *middle++); } } else { printf("\tokay\r"); } } } printf("\n\nAlle Spuren formatiert\n"); printf("Initialisiere Directory\n"); for (track = 0; track < (BUFSIZE>>1); bf[track++] = 0); for (track = 0; track < 2;track++) { for (side = 0; side < SIDES; side++){ if (status = Flopwr(bf, 0L, DEVICE, 1, track, side, SECTORS)) { errno = -status; perror("Write Error"); } } } Protobt(buffer, (long)Random(),3,0); /* Prototyp Bootsector fr * 80 * 2 * 9 Sektoren */ /* Prototyp Bootsektor fr das neue Format anpassen */ /* Bytes 19 und 20 enthalten die Sektoren pro Disk */ /* unteres Byte von TOTSEC */ buffer[19] = (char)(((TOTSEC>>8)<<8)^TOTSEC); /* oberes Byte von TOTSEC; es lebe das Intel int-Format */ buffer[20] = (char)(TOTSEC>>8); buffer[24] = (char)SECTORS; /* Sektoren pro Spur */ status = Flopwr(buffer, 0L, DEVICE, 1, 0, 0, 1); if (status) { errno = -status; perror("Write Error (Bootsector)"); } status = Flopver(buffer, 0L, DEVICE, 1, 0, 0, 1); if (status) { errno = -status; perror("Verify Error (Bootsector)"); } printf("Diskette in Laufwerk %c formatiert\n", (65+DEVICE)); sleep(1); Pterm0(); } sleep(seconds) int seconds; #if SLEEPTIME { clock_t t; for(t = clock();clock() < (t + CLK_TCK*seconds);); } #else { printf("Taste druecken\n"); fflush(stdout); Crawcin(); } #endif -- Hartmut Semken, Lupsteiner Weg 67, 1000 Berlin 37 hase@hase_1.UUCP Dennis had stepped up into the top seat whet its founder had died of a lethal overdose of brick wall, taken while under the influence of a Ferrari and a bottle of tequila. (Douglas Adams; the long dark teatime...)