src/mess/devices/mflopimg.c
| r5625 | r5626 | |
| 31 | 31 | { |
| 32 | 32 | floppy_image *floppy; |
| 33 | 33 | int track; |
| 34 | void (*load_proc)(const device_config *image); |
| 34 | 35 | void (*unload_proc)(const device_config *image); |
| 35 | 36 | int (*tracktranslate_proc)(const device_config *image, floppy_image *floppy, int physical_track); |
| 36 | 37 | }; |
| r5625 | r5626 | |
| 334 | 335 | |
| 335 | 336 | static DEVICE_IMAGE_LOAD( floppy ) |
| 336 | 337 | { |
| 337 | | return internal_floppy_device_load(image, -1, NULL); |
| 338 | mess_flopimg *flopimg; |
| 339 | int retVal = internal_floppy_device_load(image, -1, NULL); |
| 340 | flopimg = image_lookuptag(image, FLOPPY_TAG); |
| 341 | if (retVal==INIT_PASS) { |
| 342 | /* if we have one of our hacky unload procs, call it */ |
| 343 | if (flopimg->load_proc) |
| 344 | flopimg->load_proc(image); |
| 345 | } |
| 346 | return retVal; |
| 338 | 347 | } |
| 339 | 348 | |
| 340 | 349 | |
| 341 | 350 | |
| 342 | 351 | static DEVICE_IMAGE_CREATE( floppy ) |
| 343 | 352 | { |
| 344 | | return internal_floppy_device_load(image, create_format, create_args); |
| 353 | return internal_floppy_device_load(image, create_format, create_args); |
| 345 | 354 | } |
| 346 | 355 | |
| 347 | 356 | |
| r5625 | r5626 | |
| 367 | 376 | * |
| 368 | 377 | *************************************/ |
| 369 | 378 | |
| 379 | void floppy_install_load_proc(const device_config *image, void (*proc)(const device_config *image)) |
| 380 | { |
| 381 | mess_flopimg *flopimg; |
| 382 | flopimg = image_lookuptag(image, FLOPPY_TAG); |
| 383 | flopimg->load_proc = proc; |
| 384 | } |
| 385 | |
| 370 | 386 | void floppy_install_unload_proc(const device_config *image, void (*proc)(const device_config *image)) |
| 371 | 387 | { |
| 372 | 388 | mess_flopimg *flopimg; |
src/mess/formats/dim_dsk.c
| r0 | r5626 | |
| 1 | /********************************************************************* |
| 2 | |
| 3 | formats/dim_dsk.c |
| 4 | |
| 5 | DIM disk images |
| 6 | |
| 7 | *********************************************************************/ |
| 8 | |
| 9 | #include <string.h> |
| 10 | |
| 11 | #include "formats/dim_dsk.h" |
| 12 | #include "formats/basicdsk.h" |
| 13 | #include "driver.h" |
| 14 | |
| 15 | FLOPPY_IDENTIFY(dim_dsk_identify) |
| 16 | { |
| 17 | *vote = 100; |
| 18 | return FLOPPY_ERROR_SUCCESS; |
| 19 | } |
| 20 | |
| 21 | FLOPPY_CONSTRUCT(dim_dsk_construct) |
| 22 | { |
| 23 | struct basicdsk_geometry geometry; |
| 24 | // DIM disk image header, most of this is guesswork |
| 25 | int tracks = 77; |
| 26 | int heads = 2; |
| 27 | int sectors = 8; // per track |
| 28 | int sectorlen = 1024; |
| 29 | int firstsector = 0x01; |
| 30 | UINT8 format_tmp; |
| 31 | int x; |
| 32 | UINT16 temp; |
| 33 | |
| 34 | if(params) |
| 35 | { |
| 36 | // create |
| 37 | return FLOPPY_ERROR_UNSUPPORTED; |
| 38 | } |
| 39 | |
| 40 | // Offset + 0 : disk format type (1 byte): |
| 41 | // 0 = 2HD / 2HDA (8 sector/track, 1024 bytes/sector, GAP#3 = 0x74) |
| 42 | // 1 = 2HS (9 sector/track, 1024 bytes/sector, GAP#3 = 0x39) |
| 43 | // 2 = 2HC (15 sector/track, 512 bytes/sector, GAP#3 = 0x54) |
| 44 | // 3 = 2HDE(68) (9 sector/track, 1024 bytes/sector, GAP#3 = 0x39) |
| 45 | // 9 = 2HQ (18 sector/track, 512 bytes/sector, GAP#3 = 0x54) |
| 46 | // 17 = N88-BASIC (26 sector/track, 256 bytes/sector, GAP#3 = 0x33) |
| 47 | // or (26 sector/track, 128 bytes/sector, GAP#3 = 0x1a) |
| 48 | // |
| 49 | floppy_image_read(floppy, &format_tmp,0,1); |
| 50 | |
| 51 | switch(format_tmp) |
| 52 | { |
| 53 | case 0x00: |
| 54 | sectors = 8; |
| 55 | sectorlen = 1024; |
| 56 | break; |
| 57 | case 0x01: |
| 58 | case 0x03: |
| 59 | sectors = 9; |
| 60 | sectorlen = 1024; |
| 61 | break; |
| 62 | case 0x02: |
| 63 | sectors = 15; |
| 64 | sectorlen = 512; |
| 65 | break; |
| 66 | case 0x09: |
| 67 | sectors = 18; |
| 68 | sectorlen = 512; |
| 69 | break; |
| 70 | case 0x11: |
| 71 | sectors = 26; |
| 72 | sectorlen = 256; |
| 73 | break; |
| 74 | } |
| 75 | tracks = 0; |
| 76 | for (x=0;x<86;x++) |
| 77 | { |
| 78 | floppy_image_read(floppy,&temp,(x*2)+1,2); |
| 79 | if(temp == 0x0101) |
| 80 | tracks++; |
| 81 | } |
| 82 | // TODO: expand on this basic implementation |
| 83 | |
| 84 | logerror("FDD: DIM image loaded - type %i, %i tracks, %i sectors per track, %i bytes per sector\n", format_tmp,tracks, sectors,sectorlen); |
| 85 | |
| 86 | memset(&geometry, 0, sizeof(geometry)); |
| 87 | geometry.heads = heads; |
| 88 | geometry.first_sector_id = firstsector; |
| 89 | geometry.sector_length = sectorlen; |
| 90 | geometry.tracks = tracks+1; |
| 91 | geometry.sectors = sectors; |
| 92 | geometry.offset = 0x100; |
| 93 | return basicdsk_construct(floppy, &geometry); |
| 94 | } |
| 95 | |
src/mess/drivers/x68k.c
| r5625 | r5626 | |
| 128 | 128 | #include "machine/8530scc.h" |
| 129 | 129 | #include "machine/hd63450.h" |
| 130 | 130 | #include "machine/rp5c15.h" |
| 131 | | #include "devices/basicdsk.h" |
| 131 | #include "devices/mflopimg.h" |
| 132 | #include "formats/basicdsk.h" |
| 133 | #include "formats/dim_dsk.h" |
| 132 | 134 | #include "devices/harddriv.h" |
| 133 | 135 | #include "machine/x68k_hdc.h" |
| 134 | 136 | #include "includes/x68k.h" |
| r5625 | r5626 | |
| 2227 | 2229 | |
| 2228 | 2230 | INPUT_PORTS_END |
| 2229 | 2231 | |
| 2230 | | static void dimdsk_set_geometry(const device_config* image) |
| 2231 | | { |
| 2232 | | // DIM disk image header, most of this is guesswork |
| 2233 | | int tracks = 77; |
| 2234 | | int heads = 2; |
| 2235 | | int sectors = 8; // per track |
| 2236 | | int sectorlen = 1024; |
| 2237 | | int firstsector = 0x01; |
| 2238 | | unsigned char format; |
| 2239 | | int x; |
| 2240 | | unsigned short temp; |
| 2241 | | |
| 2242 | | /* Offset + 0 : disk format type (1 byte): |
| 2243 | | * 0 = 2HD / 2HDA (8 sector/track, 1024 bytes/sector, GAP#3 = 0x74) |
| 2244 | | * 1 = 2HS (9 sector/track, 1024 bytes/sector, GAP#3 = 0x39) |
| 2245 | | * 2 = 2HC (15 sector/track, 512 bytes/sector, GAP#3 = 0x54) |
| 2246 | | * 3 = 2HDE(68) (9 sector/track, 1024 bytes/sector, GAP#3 = 0x39) |
| 2247 | | * 9 = 2HQ (18 sector/track, 512 bytes/sector, GAP#3 = 0x54) |
| 2248 | | * 17 = N88-BASIC (26 sector/track, 256 bytes/sector, GAP#3 = 0x33) |
| 2249 | | * or (26 sector/track, 128 bytes/sector, GAP#3 = 0x1a) |
| 2250 | | */ |
| 2251 | | image_fread(image,&format,1); |
| 2252 | | |
| 2253 | | switch(format) |
| 2232 | static void x68k_load_proc(const device_config *image) |
| 2233 | { |
| 2234 | if(x68k_sys.ioc.irqstatus & 0x02) |
| 2254 | 2235 | { |
| 2255 | | case 0x00: |
| 2256 | | sectors = 8; |
| 2257 | | sectorlen = 1024; |
| 2258 | | break; |
| 2259 | | case 0x01: |
| 2260 | | case 0x03: |
| 2261 | | sectors = 9; |
| 2262 | | sectorlen = 1024; |
| 2263 | | break; |
| 2264 | | case 0x02: |
| 2265 | | sectors = 15; |
| 2266 | | sectorlen = 512; |
| 2267 | | break; |
| 2268 | | case 0x09: |
| 2269 | | sectors = 18; |
| 2270 | | sectorlen = 512; |
| 2271 | | break; |
| 2272 | | case 0x11: |
| 2273 | | sectors = 26; |
| 2274 | | sectorlen = 256; |
| 2275 | | break; |
| 2236 | current_vector[1] = 0x61; |
| 2237 | x68k_sys.ioc.irqstatus |= 0x40; |
| 2238 | current_irq_line = 1; |
| 2239 | cputag_set_input_line_and_vector(image->machine, "maincpu",1,ASSERT_LINE,current_vector[1]); // Disk insert/eject interrupt |
| 2240 | logerror("IOC: Disk image inserted\n"); |
| 2276 | 2241 | } |
| 2277 | | tracks = 0; |
| 2278 | | for (x=0;x<86;x++) |
| 2279 | | { |
| 2280 | | image_fread(image,&temp,2); |
| 2281 | | if(temp == 0x0101) |
| 2282 | | tracks++; |
| 2283 | | } |
| 2284 | | // TODO: expand on this basic implementation |
| 2285 | | |
| 2286 | | logerror("FDD: DIM image loaded - type %i, %i tracks, %i sectors per track, %i bytes per sector\n", format,tracks, sectors,sectorlen); |
| 2287 | | basicdsk_set_geometry(image, tracks+1, heads, sectors, sectorlen, firstsector, 0x100, FALSE); |
| 2242 | x68k_sys.fdc.disk_inserted[image_index_in_device(image)] = 1; |
| 2288 | 2243 | } |
| 2289 | 2244 | |
| 2290 | | static DEVICE_IMAGE_LOAD( x68k_floppy ) |
| 2245 | static void x68k_unload_proc(const device_config *image) |
| 2291 | 2246 | { |
| 2292 | | if (device_load_basicdsk_floppy(image)==INIT_PASS) |
| 2293 | | { |
| 2294 | | /* sector id's 01-08 */ |
| 2295 | | /* drive, tracks, heads, sectors per track, sector length, first sector id */ |
| 2296 | | if(strcmp(image_filetype(image),"dim") == 0) |
| 2297 | | dimdsk_set_geometry(image); |
| 2298 | | else |
| 2299 | | basicdsk_set_geometry(image, 77, 2, 8, 1024, 0x01, 0, FALSE); |
| 2300 | | if(x68k_sys.ioc.irqstatus & 0x02) |
| 2301 | | { |
| 2302 | | current_vector[1] = 0x61; |
| 2303 | | x68k_sys.ioc.irqstatus |= 0x40; |
| 2304 | | current_irq_line = 1; |
| 2305 | | cputag_set_input_line_and_vector(image->machine, "maincpu",1,ASSERT_LINE,current_vector[1]); // Disk insert/eject interrupt |
| 2306 | | logerror("IOC: Disk image inserted\n"); |
| 2307 | | } |
| 2308 | | x68k_sys.fdc.disk_inserted[image_index_in_device(image)] = 1; |
| 2309 | | return INIT_PASS; |
| 2310 | | } |
| 2311 | | |
| 2312 | | return INIT_FAIL; |
| 2313 | | } |
| 2314 | | |
| 2315 | | static DEVICE_IMAGE_UNLOAD( x68k_floppy ) |
| 2316 | | { |
| 2317 | 2247 | if(x68k_sys.ioc.irqstatus & 0x02) |
| 2318 | 2248 | { |
| 2319 | 2249 | current_vector[1] = 0x61; |
| r5625 | r5626 | |
| 2324 | 2254 | x68k_sys.fdc.disk_inserted[image_index_in_device(image)] = 0; |
| 2325 | 2255 | } |
| 2326 | 2256 | |
| 2257 | FLOPPY_OPTIONS_START( x68k ) |
| 2258 | FLOPPY_OPTION( dim, "dim", "DIM floppy disk image", dim_dsk_identify, dim_dsk_construct, NULL) |
| 2259 | FLOPPY_OPTION( img2d, "xdf,hdm,2hd", "XDF disk image", basicdsk_identify_default, basicdsk_construct_default, |
| 2260 | HEADS([2]) |
| 2261 | TRACKS([77]) |
| 2262 | SECTORS([8]) |
| 2263 | SECTOR_LENGTH([1024]) |
| 2264 | FIRST_SECTOR_ID([1])) |
| 2265 | FLOPPY_OPTIONS_END |
| 2266 | |
| 2267 | |
| 2327 | 2268 | static void x68k_floppy_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info) |
| 2328 | 2269 | { |
| 2270 | /* floppy */ |
| 2329 | 2271 | switch(state) |
| 2330 | 2272 | { |
| 2331 | | case MESS_DEVINFO_INT_READABLE: |
| 2332 | | info->i = 1; |
| 2333 | | break; |
| 2334 | | case MESS_DEVINFO_INT_WRITEABLE: |
| 2335 | | info->i = 1; |
| 2336 | | break; |
| 2337 | | case MESS_DEVINFO_INT_CREATABLE: |
| 2338 | | info->i = 0; |
| 2339 | | break; |
| 2340 | | case MESS_DEVINFO_INT_COUNT: |
| 2341 | | info->i = 4; |
| 2342 | | break; |
| 2343 | | case MESS_DEVINFO_PTR_LOAD: |
| 2344 | | info->load = DEVICE_IMAGE_LOAD_NAME(x68k_floppy); |
| 2345 | | break; |
| 2346 | | case MESS_DEVINFO_PTR_UNLOAD: |
| 2347 | | info->unload = DEVICE_IMAGE_UNLOAD_NAME(x68k_floppy); |
| 2348 | | break; |
| 2349 | | case MESS_DEVINFO_STR_FILE_EXTENSIONS: |
| 2350 | | strcpy(info->s = device_temp_str(), "xdf,hdm,2hd,dim"); |
| 2351 | | break; |
| 2352 | | default: |
| 2353 | | legacybasicdsk_device_getinfo(devclass, state, info); |
| 2354 | | break; |
| 2273 | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 2274 | case MESS_DEVINFO_INT_COUNT: info->i = 4; break; |
| 2275 | |
| 2276 | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 2277 | case MESS_DEVINFO_PTR_FLOPPY_OPTIONS: info->p = (void *) floppyoptions_x68k; break; |
| 2278 | |
| 2279 | default: floppy_device_getinfo(devclass, state, info); break; |
| 2355 | 2280 | } |
| 2356 | 2281 | } |
| 2357 | 2282 | |
| r5625 | r5626 | |
| 2419 | 2344 | output_set_indexed_value("eject_drv",drive,1); |
| 2420 | 2345 | output_set_indexed_value("ctrl_drv",drive,1); |
| 2421 | 2346 | output_set_indexed_value("access_drv",drive,1); |
| 2347 | floppy_install_unload_proc(image_from_devtype_and_index(machine, IO_FLOPPY, drive), x68k_unload_proc); |
| 2348 | floppy_install_load_proc(image_from_devtype_and_index(machine, IO_FLOPPY, drive), x68k_load_proc); |
| 2422 | 2349 | } |
| 2423 | 2350 | |
| 2424 | 2351 | // reset CPU |