src/mess/machine/beta.c
| r5610 | r5611 | |
| 8 | 8 | |
| 9 | 9 | *********************************************************************/ |
| 10 | 10 | #include "driver.h" |
| 11 | | #include "devices/basicdsk.h" |
| 11 | #include "devices/mflopimg.h" |
| 12 | #include "formats/trd_dsk.h" |
| 12 | 13 | #include "machine/wd17xx.h" |
| 13 | 14 | #include "machine/beta.h" |
| 14 | 15 | |
| 15 | | |
| 16 | | |
| 17 | 16 | /*************************************************************************** |
| 18 | 17 | TYPE DEFINITIONS |
| 19 | 18 | ***************************************************************************/ |
| r5610 | r5611 | |
| 212 | 211 | } |
| 213 | 212 | } |
| 214 | 213 | |
| 215 | | static 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 | | |
| 241 | 214 | void beta_floppy_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info) |
| 242 | 215 | { |
| 243 | 216 | /* floppy */ |
| r5610 | r5611 | |
| 247 | 220 | case MESS_DEVINFO_INT_COUNT: info->i = 4; break; |
| 248 | 221 | |
| 249 | 222 | /* --- 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; |
| 251 | 224 | |
| 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 | } |
| 257 | 227 | } |
| 258 | 228 | |
| 259 | 229 | static MACHINE_DRIVER_START( beta_disk ) |
src/mess/formats/trd_dsk.c
| r0 | r5611 | |
| 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 | |
| 16 | static FLOPPY_IDENTIFY(trd_dsk_identify) |
| 17 | { |
| 18 | *vote = 100; |
| 19 | return FLOPPY_ERROR_SUCCESS; |
| 20 | } |
| 21 | |
| 22 | static 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 | |
| 48 | FLOPPY_OPTIONS_START( trd ) |
| 49 | FLOPPY_OPTION( trd_dsk, "trd", "TRD floppy disk image", trd_dsk_identify, trd_dsk_construct, NULL) |
| 50 | FLOPPY_OPTIONS_END |
| 51 | |