8

How much control over the TRS-80 Model III's floppy drive controller can be effected via relatively simple commands, typed into its built-in Cassette BASIC?

My understanding is that general usage of the drives requires booting into Diskette BASIC. But the "Test Your Drives First" section (mirror) offers this "magic" command to turn the drives on:

OUT 244,1

The second number determines which drive turns on, 1-indexed. It looks like Ira Goldklang got the tip in this thread but no further details provided there either.

I'm left wondering what exactly that command does? Are there similar command(s) could I use to step to a particular track, and then access data coming off the read head?

Pointers to any official reference or later explanations for communicating with the floppy drive controller would also be appreciated.

(I am troubleshooting a a Model III that won't boot from disk. Using another controller, I have verified that the drive is working. My primary goal at this point is to determine whether the floppy drive controller itself is fully functional.)

| improve this question | | | | |
  • I believe it's possible to execute arbitrary machine-language code from BASIC, so there shouldn't be anything you can't do just because you're limited to BASIC. I think the technique was to write source code that had a string constant in it as a placeholder, then locate the string in memory and use POKE to put the machine code into the string. Can't remember how you executed the code after that. – Ben Crowell Jan 25 at 23:38
  • @BenCrowell: You hit the runtime stack with a POKE, but I never knew where it was. – Joshua Apr 8 at 17:25
7

ROM BASIC does not support any handling of floppies at all, but System ROM allows boot thru it's function table. Of course one could handle the disk controller 'manually' from BASIC - which is what the example does.

Routines

(All following values are according to TRS‑80 ROM Routines Documented)

The System ROM (3000h-37FFh) only supports booting a disk. There are eventually two entry points for boot in its function table:

  • Cold Start at 3015h, invoked by RST 0, which after some initialization continues into to warm boot.

  • Warm Boot at 3012h, invoked from entry point at 000Dh, which does the job of positioning and loading from track 0.

So calling warm boot from BASIC with X=USR(12306) should make the first drive spin, retract to track zero and try to load from there - much like pressing reset.

Hardware Access

The Model III uses a standard Western Digital FD1793 type controller. It's four registers are accessible at ports F0h..F3h (240..243), see the data sheet for details.

In addition a register at F4h (244) selects density, operation modes, drive and side. The later is done with the four lower bits, which is what your 'secret code' uses. Drives 0..3 are selected with values 1/2/4/8 (use only these, don't activate more than one drive at the same time).

Since the drive may issue an NMI for servicing, the interrupt control register at E4h (228) may als be used (although, I think not really from inside a BASIC program)

There is a short description of the ports on Ira Goldklang's TRS80 site.

Usage

Selecting a drive is done by F4h, and the drive should spin up as soon as it's selected, as well as stoping when deselected (OUT 244,0). Reseting, returning to track zero as well as stepping should be possible using BASIC OUT commands. Please refer to the data sheet for further details.

Except for selecting multiple drives, there isn't much to be damaged (except for a any disk data of course), so go ahead and learn to handle a classic WDC 177x FDC :)

| improve this answer | | | | |
  • Very helpful, thank you! – natevw Jan 26 at 5:19
1

I found one reference which exercises the floppy drives from the ROM-only BASIC, in just the ways I was looking for, the SAMS Photofact guide for the Model III.

The simplest "script" it provides is the basic one which only makes a drive active as already found.

The following Basic program will make Disk Drive 0 run continuously in the read mode. Change the number 1 in the program to number 2 to make Disk Drive 1 run continuously.

 10 OUT 244,1: GOTO 10

This script extends that (and changes to Drive 1) to seek track 0 and then constantly issues a read command while logging the result to the screen:

10 OUT 244,2: OUT 240,3
20 FOR T=1 TO 600: NEXT T
30 OUT 244,2: OUT 240,228: PRINT INP(243): GOTO 30

(It's unclear to me whether or not BASIC would actually keep up with the data, or if it's ± just getting random samples of the stream.)

And this will step the specified drive to track 0 and out to track 40 endlessly:

10 OUT 244,1: OUT 240,3
20 FOR T=1 TO 700: NEXT T
30 OUT 244,1: OUT 243,40: OUT 240,19
40 FOR T=1 TO 700: NEXT T: GOTO 10

The scripts have a bit of additional documentation in the context of drive/controller troubleshooting procedures, which are very helpful.

| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.