shortname: 'Micropolis'
comment: '100tpi MetaFloppy disks'
read_support_status: UNICORN
write_support_status: UNICORN

documentation:
<<<
Micropolis MetaFloppy disks use MFM and hard sectors. Mod I was 48 TPI and
stored 143k per side. Mod II was 100 TPI and stored 315k per side. Each of the
16 sectors contains 266 bytes of "user data," allowing 10 bytes of metadata for
use by the operating system. Micropolis DOS (MDOS) used the metadata bytes, but
CP/M did not.

Some later systems were Micropolis-compatible and so were also 100 TPI, like
the Vector Graphic Dual-Mode Disk Controller which was paired with a Tandon
drive.

**Important note:** You _cannot_ read these disks with a normal PC drive, as
these drives are 96tpi. The track spacing is determined by the physical geometry
of the drive and can't be changed in software. You'll need to get hold of a
100tpi Micropolis drive. Luckily these seem to use the same connector and
pinout as a 96tpi PC 5.25" drive. In use they should be identical.

While most operating systems use the standard Micropolis checksum, Vector
Graphic MZOS uses a unique checksum.  The decoder will automatically detect
the checksum type in use; however, a specific checksum type may be forced
using the `--decoder.micropolis.checksum_type=TYPE` where TYPE is one of:

| Checksum   | Description                             |
|------------|-----------------------------------------|
| AUTO       | Automatically detect                    |
| MICROPOLIS | Standard Micropolis (MDOS, CP/M, OASIS) |
| MZOS       | Vector Graphic MZOS                     |

Later versions of the Micropolis format supported ECC, especially in
controllers with HDD support. The ECC can detect and correct errors. However,
it is unclear what ECC algorithm was used by each vendor. ECC is disabled by
default, but available for checking and correcting using
`--decoder.micropolis.ecc_type=TYPE` and for writing from IMG files using
`--encoder.micropolis.ecc_type=TYPE`, where TYPE is one of:

| ECC    | Description                              |
|--------|------------------------------------------|
| NONE   | No ECC processing enabled                |
| VECTOR | Vector Graphic Dual-Mode Disk Controller |

The [CP/M BIOS](https://www.seasip.info/Cpm/bios.html) defined SELDSK, SETTRK,
and SETSEC, but no function to select the head/side. Double-sided floppies
could be represented as having either twice the number of sectors, for CHS, or
twice the number of tracks, HCS; the second side's tracks in opposite order
logically followed the first side (e.g., tracks 77-153). Micropolis disks
tended to be the latter. FluxEngine always emits CHS format disks, so you may
need to apply extra options to change the format if desired.
>>>

documentation:
<<<
## References

  - [Micropolis 1040/1050 S-100 Floppy Disk Subsystems User's Manual][micropolis1040/1050].
    Section 6, pages 261-266. Documents pre-ECC sector format. Note that the
    entire record, starting at the sync byte, is controlled by software

  - [Vector Graphic Dual-Mode Disk Controller Board Engineering Documentation][vectordualmode].
    Section 1.6.2. Documents ECC sector format

  - [AltairZ80 Simulator Usage Manual][altairz80]. Section 10.6. Documents ECC
    sector format and VGI file format

[micropolis1040/1050]: http://www.bitsavers.org/pdf/micropolis/metafloppy/1084-01_1040_1050_Users_Manual_Apr79.pdf
[vectordualmode]: http://bitsavers.org/pdf/vectorGraphic/hardware/7200-1200-02-1_Dual-Mode_Disk_Controller_Board_Engineering_Documentation_Feb81.pdf
[altairz80]: http://www.bitsavers.org/simh.trailing-edge.com_201206/pdf/altairz80_doc.pdf
>>>


drive {
	hard_sector_count: 16
}

image_reader {
	filename: "micropolis.img"
	type: IMAGETYPE_IMG
}

image_writer {
	filename: "micropolis.img"
	type: IMAGETYPE_IMG
}

layout {
	layoutdata {
		sector_size: 256
		physical {
			start_sector: 0
			count: 16
		}
	}
}

encoder {
	micropolis {}
}

decoder {
	micropolis {}
}

option {
	name: "vgi"
	comment: "Read/write VGI format images with 275 bytes per sector"

	config {
		image_reader {
			filename: "micropolis.vgi"
			type: IMAGETYPE_IMG
		}

		image_writer {
			filename: "micropolis.vgi"
			type: IMAGETYPE_IMG
		}

		layout {
			layoutdata {
				sector_size: 275
			}
			order: HCS
		}

		decoder {
			micropolis {
				sector_output_size: 275
			}
		}
	}
}

option_group {
	option {
		name: "143"
		comment: '143kB 5.25" SSDD hard-sectored; Micropolis MetaFloppy Mod I'
		
		config {
			layout {
				format_type: FORMATTYPE_40TRACK
				tracks: 35
				sides: 1
			}

		}
	}

	option {
		name: "287"
		comment: '287kB 5.25" DSDD hard-sectored; Micropolis MetaFloppy Mod I'
		
		config {
			layout {
				format_type: FORMATTYPE_40TRACK
				tracks: 35
				sides: 2
			}
		}
	}

	option {
		name: "315"
		comment: '315kB 5.25" SSDD hard-sectored; Micropolis MetaFloppy Mod II'
		
		config {
			layout {
				format_type: FORMATTYPE_80TRACK
				tracks: 77
				sides: 1
			}
		}
	}

	option {
		name: "630"
		comment: '630kB 5.25" DSDD hard-sectored; Micropolis MetaFloppy Mod II'
		
		config {
			layout {
				format_type: FORMATTYPE_80TRACK
				tracks: 77
				sides: 2
			}
		}
	}
}

