src/mess/formats/atarist_dsk.c
| r0 | r5633 | |
| 1 | /********************************************************************* |
| 2 | |
| 3 | formats/atarist_dsk.c |
| 4 | |
| 5 | Atari ST disk images |
| 6 | |
| 7 | *********************************************************************/ |
| 8 | |
| 9 | #include <string.h> |
| 10 | |
| 11 | #include "formats/atarist_dsk.h" |
| 12 | #include "formats/basicdsk.h" |
| 13 | |
| 14 | static FLOPPY_IDENTIFY(atarist_dsk_identify) |
| 15 | { |
| 16 | *vote = 100; |
| 17 | return FLOPPY_ERROR_SUCCESS; |
| 18 | } |
| 19 | |
| 20 | static FLOPPY_CONSTRUCT(atarist_dsk_construct) |
| 21 | { |
| 22 | struct basicdsk_geometry geometry; |
| 23 | int heads = 0; |
| 24 | int tracks = 0; |
| 25 | int sectors = 0; |
| 26 | UINT8 bootsector[512]; |
| 27 | |
| 28 | floppy_image_read(floppy, bootsector, 0, 512); |
| 29 | sectors = bootsector[0x18]; |
| 30 | heads = bootsector[0x1a]; |
| 31 | tracks = (bootsector[0x13] | (bootsector[0x14] << 8)) / sectors / heads; |
| 32 | |
| 33 | memset(&geometry, 0, sizeof(geometry)); |
| 34 | geometry.heads = heads; |
| 35 | geometry.first_sector_id = 1; |
| 36 | geometry.sector_length = 512; |
| 37 | geometry.tracks = tracks; |
| 38 | geometry.sectors = sectors; |
| 39 | return basicdsk_construct(floppy, &geometry); |
| 40 | } |
| 41 | |
| 42 | /* ----------------------------------------------------------------------- */ |
| 43 | |
| 44 | FLOPPY_OPTIONS_START( atarist ) |
| 45 | FLOPPY_OPTION( atarist, "st", "Atari ST floppy disk image", atarist_dsk_identify, atarist_dsk_construct, NULL) |
| 46 | FLOPPY_OPTIONS_END |
| 47 | |
src/mess/drivers/atarist.c
| r5632 | r5633 | |
| 2 | 2 | #include "video/atarist.h" |
| 3 | 3 | #include "cpu/m68000/m68000.h" |
| 4 | 4 | #include "cpu/m6800/m6800.h" |
| 5 | | #include "devices/basicdsk.h" |
| 5 | #include "formats/atarist_dsk.h" |
| 6 | #include "devices/mflopimg.h" |
| 6 | 7 | #include "devices/cartslot.h" |
| 7 | 8 | #include "machine/ctronics.h" |
| 8 | 9 | #include "includes/serial.h" |
| r5632 | r5633 | |
| 2098 | 2099 | ROM_END |
| 2099 | 2100 | |
| 2100 | 2101 | /* System Configuration */ |
| 2101 | | |
| 2102 | | static DEVICE_IMAGE_LOAD( atarist_floppy ) |
| 2103 | | { |
| 2104 | | if (image_has_been_created(image)) |
| 2105 | | return INIT_FAIL; |
| 2106 | | |
| 2107 | | if (device_load_basicdsk_floppy(image) == INIT_PASS) |
| 2108 | | { |
| 2109 | | UINT8 bootsector[512]; |
| 2110 | | image_fseek(image, 0, SEEK_SET); |
| 2111 | | |
| 2112 | | if (image_fread(image, bootsector, 512)) |
| 2113 | | { |
| 2114 | | int sectors = bootsector[0x18]; |
| 2115 | | int heads = bootsector[0x1a]; |
| 2116 | | int tracks = (bootsector[0x13] | (bootsector[0x14] << 8)) / sectors / heads; |
| 2117 | | |
| 2118 | | /* drive, tracks, heads, sectors per track, sector length, first sector id, offset track zero, track skipping */ |
| 2119 | | basicdsk_set_geometry(image, tracks, heads, sectors, 512, 1, 0, FALSE); |
| 2120 | | |
| 2121 | | return INIT_PASS; |
| 2122 | | } |
| 2123 | | } |
| 2124 | | |
| 2125 | | return INIT_FAIL; |
| 2126 | | } |
| 2127 | | |
| 2128 | 2102 | static void atarist_floppy_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info) |
| 2129 | 2103 | { |
| 2130 | 2104 | /* floppy */ |
| 2131 | 2105 | switch(state) |
| 2132 | 2106 | { |
| 2133 | 2107 | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 2134 | | case MESS_DEVINFO_INT_COUNT: info->i = 2; break; |
| 2108 | case MESS_DEVINFO_INT_COUNT: info->i = 2; break; |
| 2135 | 2109 | |
| 2136 | 2110 | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 2137 | | case MESS_DEVINFO_PTR_LOAD: info->load = DEVICE_IMAGE_LOAD_NAME(atarist_floppy); break; |
| 2111 | case MESS_DEVINFO_PTR_FLOPPY_OPTIONS: info->p = (void *) floppyoptions_atarist; break; |
| 2138 | 2112 | |
| 2139 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 2140 | | case MESS_DEVINFO_STR_FILE_EXTENSIONS: strcpy(info->s = device_temp_str(), "st"); break; |
| 2141 | | |
| 2142 | | default: legacybasicdsk_device_getinfo(devclass, state, info); break; |
| 2113 | default: floppy_device_getinfo(devclass, state, info); break; |
| 2143 | 2114 | } |
| 2144 | 2115 | } |
| 2145 | | |
| 2146 | 2116 | static DEVICE_IMAGE_LOAD( atarist_serial ) |
| 2147 | 2117 | { |
| 2148 | 2118 | /* filename specified */ |