Previous 15994 Revisions Next

r5611 Sunday 6th September, 2009 at 18:15:07 UTC by Miodrag Milanović
Moved TRD format definition to separate format file
[src/mess]mess.mak
[src/mess/formats]trd_dsk.c* trd_dsk.h*
[src/mess/machine]beta.c

src/mess/machine/beta.c
r5610r5611
88
99*********************************************************************/
1010#include "driver.h"
11#include "devices/basicdsk.h"
11#include "devices/mflopimg.h"
12#include "formats/trd_dsk.h"
1213#include "machine/wd17xx.h"
1314#include "machine/beta.h"
1415
15
16
1716/***************************************************************************
1817    TYPE DEFINITIONS
1918***************************************************************************/
r5610r5611
212211   }   
213212}
214213
215static DEVICE_IMAGE_LOAD( beta_floppy )
216{
217   UINT8 data[1];
218   int heads;
219   int cylinders;
220   
221   if (device_load_basicdsk_floppy (image) != INIT_PASS)
222      return INIT_FAIL;
223
224   image_fseek( image, 0x8e3 , SEEK_SET );
225   /* Read and verify the header */
226   if ( 1 != image_fread( image, data, 1 ) )
227   {
228      image_seterror( image, IMAGE_ERROR_UNSUPPORTED, "Unable to read header" );
229      return 1;
230   }
231   
232   image_fseek( image, 0 , SEEK_SET );
233     /* guess geometry of disk */
234     heads =  data[0] & 0x08 ? 1 : 2;
235     cylinders = data[0] & 0x01 ? 40 : 80;
236 
237   basicdsk_set_geometry (image, cylinders, heads, 16, 256, 1, 0, FALSE);
238   return INIT_PASS;
239}
240
241214void beta_floppy_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info)
242215{
243216   /* floppy */
r5610r5611
247220      case MESS_DEVINFO_INT_COUNT:                     info->i = 4; break;
248221
249222      /* --- the following bits of info are returned as pointers to data or functions --- */
250      case MESS_DEVINFO_PTR_LOAD:                     info->load = DEVICE_IMAGE_LOAD_NAME(beta_floppy); break;
223      case MESS_DEVINFO_PTR_FLOPPY_OPTIONS:            info->p = (void *) floppyoptions_trd; break;
251224
252      /* --- the following bits of info are returned as NULL-terminated strings --- */
253      case MESS_DEVINFO_STR_FILE_EXTENSIONS:            strcpy(info->s = device_temp_str(), "trd"); break;
254
255      default:                              legacybasicdsk_device_getinfo(devclass, state, info); break;
256   }   
225      default:                              floppy_device_getinfo(devclass, state, info); break;
226   }
257227}
258228
259229static MACHINE_DRIVER_START( beta_disk )
src/mess/mess.mak
r5610r5611
12331233   $(MESS_DRIVERS)/atm.o      \
12341234   $(MESS_DRIVERS)/pentagon.o   \
12351235   $(MESS_MACHINE)/spectrum.o   \
1236   $(MESS_FORMATS)/trd_dsk.o   \
12361237   $(MESS_MACHINE)/beta.o      \
12371238   $(MESS_FORMATS)/zx81_p.o   \
12381239   $(MESS_FORMATS)/tzx_cas.o   \
src/mess/formats/trd_dsk.c
r0r5611
1/*********************************************************************
2
3   formats/trd_dsk.c
4
5   TRD disk images
6
7*********************************************************************/
8
9#include <string.h>
10
11#include "formats/trd_dsk.h"
12#include "formats/basicdsk.h"
13#include "driver.h"
14
15
16static FLOPPY_IDENTIFY(trd_dsk_identify)
17{
18   *vote = 100;
19   return FLOPPY_ERROR_SUCCESS;
20}
21
22static FLOPPY_CONSTRUCT(trd_dsk_construct)
23{
24   struct basicdsk_geometry geometry;
25   UINT8 data[1];
26   int heads;
27   int cylinders;
28   
29   floppy_image_read( floppy, data, 0x8e3 , 1 );
30
31     /* guess geometry of disk */
32     heads =  data[0] & 0x08 ? 1 : 2;
33     cylinders = data[0] & 0x01 ? 40 : 80;
34
35   memset(&geometry, 0, sizeof(geometry));
36   geometry.heads = heads;
37   geometry.first_sector_id = 1;
38   geometry.sector_length = 256;
39   geometry.tracks = cylinders;
40   geometry.sectors = 16;
41   return basicdsk_construct(floppy, &geometry);   
42}
43
44
45
46/* ----------------------------------------------------------------------- */
47
48FLOPPY_OPTIONS_START( trd )
49   FLOPPY_OPTION( trd_dsk, "trd",      "TRD floppy disk image",   trd_dsk_identify, trd_dsk_construct, NULL)
50FLOPPY_OPTIONS_END
51
src/mess/formats/trd_dsk.h
r0r5611
1/*********************************************************************
2
3   formats/trd_dsk.h
4
5   TRD disk images
6
7*********************************************************************/
8
9#ifndef TRD_DSK_H
10#define TRD_DSK_H
11
12#include "formats/flopimg.h"
13
14/**************************************************************************/
15
16FLOPPY_OPTIONS_EXTERN(trd);
17
18#endif /* TRD_DSK_H */

Previous 15994 Revisions Next


© 1998-2018 The MESS Team