summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/formats/trd_dsk.c
blob: 0d9c757d715cc0525d2620b916b4d24cb3a6332d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*********************************************************************

    formats/trd_dsk.c

    TRD disk images

*********************************************************************/

#include <string.h>

#include "trd_dsk.h"
#include "basicdsk.h"


static FLOPPY_IDENTIFY(trd_dsk_identify)
{
	*vote = 100;
	return FLOPPY_ERROR_SUCCESS;
}

static FLOPPY_CONSTRUCT(trd_dsk_construct)
{
	struct basicdsk_geometry geometry;
	UINT8 data[1];
	int heads;
	int cylinders;

	floppy_image_read( floppy, data, 0x8e3 , 1 );

	/* guess geometry of disk */
	heads =  data[0] & 0x08 ? 1 : 2;
	cylinders = data[0] & 0x01 ? 40 : 80;

	memset(&geometry, 0, sizeof(geometry));
	geometry.heads = heads;
	geometry.first_sector_id = 1;
	geometry.sector_length = 256;
	geometry.tracks = cylinders;
	geometry.sectors = 16;
	return basicdsk_construct(floppy, &geometry);
}



/* ----------------------------------------------------------------------- */

LEGACY_FLOPPY_OPTIONS_START( trd )
	LEGACY_FLOPPY_OPTION( trd_dsk, "trd",		"TRD floppy disk image",	trd_dsk_identify, trd_dsk_construct, NULL, NULL)
LEGACY_FLOPPY_OPTIONS_END