The new disk IO interface uses only 3 ports.

0xC8 	Disk Register Low 	(added 1.0.18)
0xC9 	Disk Register High 	(added 1.0.18)
0xCA 	Disk IO Register Select	(added 1.0.18)
 	

To select any disk IO Register, you first write a value to the Disk IO Register Select port, 0xCA.

Values for Disk IO Registers (all Read/Write)

	0x00=0	Command 		(8 bit)

	0x08-8	Status 			(8 bit)
	0x09-9	ExtStatus1 		(8 bit)
	0x0A-10	ExtStatus2 		(8 bit)

	0x10-16	DMA Transfer Address 	(16 bit)
	0x11-17 DMA Request Bank	(8 bit)

	0x18-24	Drive select 		(8 bit)
	0x19-25	Clock Select HD/8/5/3  	(8 bit)
	
	0x20-32	Cylinder Select 	(16 bit)
	0x21-33	Head Select 		(8 bit)
	0x22-34	Track Select 		(16 bit)
	0x23-35	Density Select  	(8 bit)
	0x24-36	Sector Select 		(16 bit)
	
8 bit values can be accessed at either port 0xC8 or port 0xC9
16 bit values can be found, Low value at port 0xC8 and High value at port 0xC9
16 bit values should be written low byte first, as writting the low byte clears the high byte
	this allows single 8 bit writes to initialize all 16 bits.

Writing Status registers places the written value in the register.

Writing the Command Register causes Disk IO

 Command Values ---	
	   7    6    5    4    3    2    1    0
	  CHS   FB             EI        W    R

	(if bit7=1 then CHS used, if bit7=0 then Track/sector used)
	(if bit6=1 then Fixed Bank, if bit6=0 then Common Memory boundary in effect)
	(if bit3=1 then Interrupts for command completion are enabled))

   clear status registers
   set disk configuration parameters, 
   test disk configuration parameters, 
   test IO Request Parameters and report Errors

	   7    6    5    4    3    2    1    0
	  CHS   0    0    0    0    0    0    0   null
	  CHS   0    0    0    EI   0    0    1   read  (does not ignore common memory start)
	  CHS   0    0    0    EI   0    1    0	  write (does not ignore common memory start)	
	  CHS   1    0    0    EI   0    0    1	  read  (ignores common memory start)
	  CHS   1    0    0    EI   0    1    0	  write (ignores common memory start)

  set disk configuration parameters only (no status or errors reported)
	  CHS   1    1    1    1    1    1    1    null  (does NOT clear status registers)


 Status Values ---	
	0	ok - no error 
	1	read error 
	2	write error/read only     
	3	ill drive 
	4	ill track/cyl/head 
	5	ill sector
	6	seek error (not implemented) 
	7	ill cmd
	8	Config Error (see config status below)
	9	sector > 4096 or not 2^x

	ff	media changed (not implemented)


       Extra Status1		      Extra Status2
	Bit 7	not ready
	Bit 6	Write Protect
	Bit 5	Write Fault		Density error
	Bit 4	RNF/seek error		Disk HD/8/5/3 error
	Bit 3				Track - error
	Bit 2				Cylinder - error
	Bit 1                   	Head - error
	Bit 0				Sector - error


Disk configuration

	TO properly WRITE configuration for a drive, before selecting a new drive you must..

First, ensure that any new configuration data written has been applied to previously selected drive. This is accomplished by executing any disk IO command (use NULL command if you dont want to actually do IO)

After executing a disk IO command, all newly written data has been applied and all data is fresh. When a disk IO command is executed, only freshly written config data will be applied. Config data that has not been written since the last disk IO command will not be used to set new cofiguration and can be stale if you have changed the selected drive without issuing a disk IO command.

After selecting the new drive, you should then write all the configuration for that drive, then execute a disk IO command to apply the new config data. (again, NULL command if you do not want to do IO)

If you write any configuration data, then you must execute a disk IO command before changing the selected drive, or the config data will be applied to the drive that IS selected when a disk IO command IS executed.

	To properly READ the configuration of a drive

Ensure that all newly written configuration data has been applied to previously selected drive, by executing a disk IO command. 

After selecting the drive, the disk drive's data is stale until a command is executed. You MUST execute any disk IO command to retrieve the newly selected drive's data. 

At this point, you can read and write configuration data. 

There is an exception to this.  HEADs/Cylinders is used to calculate a new Tracks per disk... also Tracks per disk is used to calculate new Cylinders based on Heads. If you change Heads, Cylinders, or Tracks, you must execute a disk IO command before reading them. The calculations are done during IO command.


Values for Disk Configuration

    0x80-128+0	DiskOrder	(8 bit)	0,1,2
    0x81-128+1	DiskHomoHetero	(8 bit)	0=homogenous 1-three areas
    0x82-128+2	DiskUsePrePost	(8 bit)	0=dont use 1-use
	skip	2-7
    0x88-128+8	DiskCfgSts	(8 bit)
    	skip 	9-15
	skip	16
	skip	17-23
    0x98-128+24	MaxDrives		(8 bit)		1-16
    0x99-128+25	HD/8/5/3		(8 bit)	0-Don't Care, 1=HD,2=8",3=5.25",4=3.5"
    0x9A-128+26	Flags			(16 bit)Bit1=USE IDM Side Flag, All others 0
	skip 27-31
    0xA0-128+32	Number of Cylinders	(16 bit)
    0xA1-128+33	Number of Heads		(8 bit)

    0xA2-128+34	Number of Tracks	(16 bit)
    0xA3-128+35	Density Data		(8 bit)	0-Don't Care, 1=Single, 2=Double
    0xA4-128+36	Sectors per Track	(16 bit)
    0xA5-128+37	Sector Size Data	(8 bit)	0-128,1-256,2-512,3-1024,4-2048,5-4096
    0xA6-128+38	HD/8/5/3(added 1.0.21)	(8 bit)	0-Don't Care, 1=HD,2=8",3=5.25",4=3.5"
    0xA7-128+39	Sector Size Data	(16 bit)	
    0xA8-128+40	PhySector Size Data	(8 bit)	0-128,1-256,2-512,3-1024,4-2048,5-4096
    0xA9-128+41	PhySector Size Data	(16 bit)	
	skip 42,47
	skip 48,49
    0xB2-128+50	Number of Track0	(16 bit)
    0xB3-128+51	Density Track0s		(8 bit)	0-Don't Care, 1=Single, 2=Double
    0xB4-128+52	Sectors per Track0	(16 bit)
    0xB5-128+53	Sector Size Track0	(8 bit)	0-128,1-256,2-512,3-1024,4-2048,5-4096
    0xB6-128+54	HD/8/5/3(added 1.0.21)	(8 bit)	0-Don't Care, 1=HD,2=8",3=5.25",4=3.5"
    0xb7-128+55	Sector Size T0	(16 bit)	
    0xB8-128+56	PhySector Size Track0	(8 bit)	0-128,1-256,2-512,3-1024,4-2048,5-4096
    0xb9-128+57	PhySector Size T0	(16 bit)	
	skip	58,63
	skip	64,65
    0xC2-128+66	Number of System Tracks (16 bit)
    0xC3-128+67	Density System Tracks	(8 bit)	0-Don't Care, 1=Single, 2=Double
    0xC4-128+68	Sectors per System Track(16 bit)
    0xC5-128+69	Sector Size SystemTrack	(8 bit)	0-128,1-256,2-512,3-1024,4-2048,5-4096
    0xC6-128+70 HD/8/5/3(added 1.0.21)	(8 bit)	0-Don't Care, 1=HD,2=8",3=5.25",4=3.5"
    0xc7-128+71	Sector Size sys	(16 bit)	
    0xC8-128+72	PhySector Size SystemTrack	(8 bit)	0-128,1-256,2-512,3-1024,4-2048,5-4096
    0xc9-128+73	PhySector Size sys	(16 bit)	


    0xd0-128+80	DiskPreamble(added 1.0.21)	(8 bit)	
    0xd1-128+81	DiskPostamble(added 1.0.21)	(8 bit)	

    0xd2-128+82	TrackPreamble(added 1.0.21)	(8 bit)	
    0xd3-128+83	TrackPostamble(added 1.0.21)	(8 bit)	
    0xd4-128+84	TrackPreambleT0(added 1.0.21)	(8 bit)	
    0xd5-128+85	TrackPostambleT0(added 1.0.21)	(8 bit)	
    0xd6-128+86	TrackPreambleSYS(added 1.0.21)	(8 bit)	
    0xd7-128+87	TrackPostambleSYS(added 1.0.21)	(8 bit)	

    0xd8-128+88	SectorPreamble(added 1.0.21)	(8 bit)	
    0xd9-128+89	SectorPostamble(added 1.0.21)	(8 bit)	
    0xda-128+90	SectorPreambleT0(added 1.0.21)	(8 bit)	
    0xdb-128+91	SectorPostambleT0(added 1.0.21)	(8 bit)	
    0xdc-128+92	SectorPreambleSYS(added 1.0.21)	(8 bit)	
    0xdd-128+93	SectorPostambleSYS(added 1.0.21)(8 bit)	

      Config Status
	Bit 7 - Tpd >16bits
	Bit 6 - Tpd not mod HDS
	Bit 5 - T0+TS >TPD 
	Bit 4 - size >2gb
	Bit 3 - 
	Bit 2 - sect >4096 or sect not 2^x
	Bit 1 - 
	Bit 0 -

NOTES---(for compatibility)
	writing a 3 to disk order causes disk order to be set to 0, homogeneous, and dont use pre/post
	writing a value of 0 or 1 to HomoHetero sets DONT use pre/post, so you must write to 
		Use Pre/Post after writing to HomoHetero, if you want to use pre/post


---------------------------------
OLD Disk IO Interface(do NOT use)

	(disk drive controller is ports CF-DF and F0-FA)
		Drive definiton (Number of Heads added 1.0.12)
CF:	Number of Heads 
		Disk controller
D0: 	cmd/sts
	cmd ---	0=null
		1=read, 2=write (does not ignore common memory start)	
		&h10=read, &h20=write (ignores common memory start)
		(if bit7=1 then CHS used, if bit7=0 then Track/sector used)
		0x7f=parse and set disk parameters (sts=0)

	sts ---	0=ok - 1=read error, 2= write error/read only     
 	  	3=ill drive, 4=ill track/cyl/head, 5=ill sector
		6=seek error(not implemented) 7=ill cmd
		8=>Config Error, 9=sector > 4096

		ff=media changed(not implemented)

D1: 	Drive select 		0-15
D2: 	Track select - Low
D3: 	Track select - High
D4: 	Sector select - Low
D5:	Sector select - High
D6: 	DMA select - Low
D7: 	DMA select - High
D8: 	SPT - Low (Drive definiton)
D9: 	SPT - High (Drive definiton)
DA: 	DMA select bank	(0-15, FF=currently active bank)

		Drive definition
DB: 	DiskOrder	0=sides, 1=cyl, 2= cyl, 3=sides(hetro-sectors)
	(NOTE setting order to 3 causes HomoHetero to be set to Hetero, order to 0, and DONT use pre/post)
	(NOTE reading order returns 3, if conditions are met) 
DC: 	Tracks per disk - Low
DD: 	Tracks per disk - High
DE: 	Disk LogSecSize - Low	 (can be any value between 1 and 16384)
DF: 	Disk LogSecSize - High	 (can also use port 0xFA to set via SIZE CODE)

NOTE-writing to any Drive Definition (for old interface)causes DONT USE pre/post to be set DONT use.

		Drive definition (added 1.0.17)
F0: 	SPT Track0 - Low
F1: 	SPT Track0 - High
F2: 	SPT System Track - Low
F3: 	SPT System Track - High
F4: 	Tracks per Track0 area - Low
F5: 	Tracks per Track0 area - High
F6: 	Tracks per System Track area - Low
F7: 	Tracks per System Track area - High
F8: 	LogSecSize Track 0s   		0=128,1=256,2=512,3=1024,4=2048,5=4096,6-8192,7-16384
F9: 	LogSecSize System Tracks 	0=128,1=256,2=512,3=1024,4=2048,5=4096,6-8192,7-16384
FA: 	LogSecSize System Data Tracks 	0=128,1=256,2=512,3=1024,4=2048,5=4096,6-8192,7-16384
FB:	
FC:	
FD:
FE:
FF:
