src/mess/includes/vc1541.h
| r3312 | r3313 | |
| 30 | 30 | }; |
| 31 | 31 | |
| 32 | 32 | enum { |
| 33 | | format_d64 = 0, |
| 34 | | format_d64_err, |
| 35 | | format_d64_40t, |
| 36 | | format_d64_40t_err, |
| 37 | | format_d67, |
| 38 | | format_d71, |
| 39 | | format_d71_err, |
| 40 | | format_d81, |
| 41 | | format_d80, |
| 42 | | format_d82, |
| 43 | | format_g64, |
| 33 | format_d64 = 0, /* 1541 image, 35 tracks */ |
| 34 | format_d64_err, /* 1541 image, 35 tracks + error table */ |
| 35 | format_d64_40t, /* 1541 image, 40 tracks */ |
| 36 | format_d64_40t_err, /* 1541 image, 40 tracks + error table */ |
| 37 | format_d67, /* 2040 image, 35 tracks DOS1 format */ |
| 38 | format_d71, /* 1571 image, 70 tracks */ |
| 39 | format_d71_err, /* 1571 image, 70 tracks + error table */ |
| 40 | format_d81, /* 1581 image, 80 tracks */ |
| 41 | format_d80, /* 8050 image, 77 tracks */ |
| 42 | format_d82, /* 8250 image, 154 tracks (read as 77?) */ |
| 43 | format_g64, /* 1541 image in GCR format */ |
| 44 | 44 | }; |
| 45 | 45 | |
| 46 | 46 | |
| r3312 | r3313 | |
| 48 | 48 | void drive_reset(void); |
| 49 | 49 | |
| 50 | 50 | void vc1541_device_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info); |
| 51 | | void c2031_device_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info); |
| 52 | 51 | void c1551_device_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info); |
| 53 | 52 | void c1571_device_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info); |
| 53 | /* the ones below are still not used in any drivers */ |
| 54 | void c1581_device_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info); |
| 55 | void c2031_device_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info); |
| 56 | void c2040_device_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info); |
| 57 | void c8050_device_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info); |
| 58 | void c8250_device_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info); |
| 54 | 59 | |
| 60 | |
| 55 | 61 | MACHINE_DRIVER_EXTERN( cpu_vc1540 ); |
| 56 | 62 | MACHINE_DRIVER_EXTERN( cpu_vc1541 ); |
| 57 | 63 | MACHINE_DRIVER_EXTERN( cpu_c2031 ); |
src/mess/machine/vc1541.c
| r3312 | r3313 | |
| 97 | 97 | |
| 98 | 98 | */ |
| 99 | 99 | /* 2008-09 FP |
| 100 | | started some work on the floppy emulation code: |
| 100 | Started some work on the floppy emulation code: |
| 101 | 101 | + made the functions / structs less vc1541-centric & d64-centric |
| 102 | 102 | + unified config & reset functions, using type variable |
| 103 | 103 | to choose the actions to be done |
| 104 | 104 | + moved GCR encoding at loading time (wip untested code) |
| 105 | 105 | |
| 106 | | a limitation is clear: only a single occurrence of emulated drive |
| 106 | A limitation is clear: only a single occurrence of emulated drive |
| 107 | 107 | is expected. |
| 108 | | at a later stage, at least drive_config & drive_reset will need |
| 108 | At a later stage, at least drive_config & drive_reset will need |
| 109 | 109 | an index to choose between the drives |
| 110 | In the end, we could also split the floppy drives emulation from the |
| 111 | disk image handling... |
| 110 | 112 | |
| 111 | | current status: |
| 113 | Current status: |
| 112 | 114 | + preliminary vc1541 & c1551 implementation (seems very slow) |
| 113 | 115 | + no support for other drive types (even if now I list all |
| 114 | 116 | the variants supported by Vice in the enum) |
| 115 | 117 | + communications between the drive CPU and the computer CPU have |
| 116 | 118 | to be checked, debugged and improved |
| 117 | | + most functions / constants are d64 independent, even if other |
| 118 | | formats are not supported yet! |
| 119 | + all but .g64 images should be correctly encoded at loading time |
| 120 | (I actually have doubts about some .d82 details) |
| 121 | + error maps are not still used, even if their presence is |
| 122 | acknowledged |
| 119 | 123 | + the floppy handling still uses CBM_Drive_Emu struct instead of |
| 120 | 124 | functions similar to other floppy formats |
| 121 | 125 | */ |
| 126 | /* |
| 127 | Informations on the fileformats (which the code is based on) |
| 122 | 128 | |
| 129 | D64 - http://ist.uwaterloo.ca/~schepers/formats/D64.TXT |
| 130 | D71 - http://ist.uwaterloo.ca/~schepers/formats/D71.TXT |
| 131 | D81 - http://ist.uwaterloo.ca/~schepers/formats/D81.TXT |
| 132 | D80 & D82 - http://ist.uwaterloo.ca/~schepers/formats/D80-D82.TXT |
| 133 | G64 & GCR - http://ist.uwaterloo.ca/~schepers/formats/G64.TXT |
| 134 | GCR - http://www.baltissen.org/newhtm/1541c.htm |
| 135 | |
| 136 | */ |
| 137 | |
| 138 | |
| 123 | 139 | #include "driver.h" |
| 124 | 140 | #include "deprecat.h" |
| 125 | 141 | #include "image.h" |
| r3312 | r3313 | |
| 199 | 215 | |
| 200 | 216 | struct { |
| 201 | 217 | int sync; // active after > 9 '1's |
| 218 | int ones_count; |
| 202 | 219 | int ready; // needed for 1551 |
| 203 | | int ones_count; // still needed? |
| 204 | 220 | UINT8 data[0x500000]; // entire d64 image encoded at loading time |
| 205 | 221 | } gcr; |
| 206 | 222 | } CBM_Drive_Emu; |
| r3312 | r3313 | |
| 228 | 244 | 19, 19, 19, 19, 19, 19, 19, |
| 229 | 245 | 18, 18, 18, 18, 18, 18, |
| 230 | 246 | 17, 17, 17, 17, 17, |
| 231 | | 17, 17, 17, 17, 17 /* only for 40 tracks d64 */ |
| 247 | 17, 17, 17, 17, 17, /* only for 40 tracks d64 */ |
| 248 | 17, 17 /* in principle the drive could read 42 tracks */ |
| 232 | 249 | }; |
| 233 | 250 | |
| 234 | 251 | #define D71_MAX_TRACKS 70 |
| r3312 | r3313 | |
| 261 | 278 | }; |
| 262 | 279 | |
| 263 | 280 | |
| 281 | /* Still have to investigate if these are read as 154 or as 77 in the drive... */ |
| 282 | /* For now we assume it's 154, but I'm not sure */ |
| 264 | 283 | #define D82_MAX_TRACKS 154 |
| 265 | 284 | |
| 266 | 285 | static const int d82_sectors_per_track[] = |
| r3312 | r3313 | |
| 278 | 297 | }; |
| 279 | 298 | |
| 280 | 299 | |
| 300 | static const int max_tracks_per_format[] = |
| 301 | { |
| 302 | D64_MAX_TRACKS, |
| 303 | D64_MAX_TRACKS, |
| 304 | D64_40T_MAX_TRACKS, |
| 305 | D64_40T_MAX_TRACKS, |
| 306 | D64_MAX_TRACKS, |
| 307 | D71_MAX_TRACKS, |
| 308 | D71_MAX_TRACKS, |
| 309 | D81_MAX_TRACKS, |
| 310 | D80_MAX_TRACKS, |
| 311 | D82_MAX_TRACKS, |
| 312 | 0 /* Still to add support for .g64 */ |
| 313 | }; |
| 314 | |
| 281 | 315 | static int image_offset[IMAGE_MAX_TRACKS] = { 0 }; |
| 282 | 316 | |
| 283 | 317 | |
| r3312 | r3313 | |
| 299 | 333 | { |
| 300 | 334 | case format_d64: |
| 301 | 335 | case format_d64_err: |
| 336 | case format_d67: |
| 302 | 337 | for (i = 1; i <= D64_MAX_TRACKS; i++) |
| 303 | 338 | image_offset[i] = image_offset[i - 1] + d64_sectors_per_track[i - 1] * 256; |
| 304 | 339 | break; |
| r3312 | r3313 | |
| 331 | 366 | break; |
| 332 | 367 | |
| 333 | 368 | default: |
| 334 | | /* Still have to work on d67 & g64 images */ |
| 369 | /* Still have to work on g64 images */ |
| 335 | 370 | logerror("Unsupported format\n"); |
| 336 | 371 | break; |
| 337 | 372 | } |
| r3312 | r3313 | |
| 389 | 424 | case format_d64_err: |
| 390 | 425 | case format_d64_40t: |
| 391 | 426 | case format_d64_40t_err: |
| 427 | case format_d67: |
| 392 | 428 | case format_d71: |
| 393 | 429 | case format_d71_err: |
| 394 | 430 | id1 = image_tracksector2offset(18, 0) + 0xa2; |
| r3312 | r3313 | |
| 404 | 440 | break; |
| 405 | 441 | |
| 406 | 442 | default: |
| 407 | | /* Still have to work on d67 & g64 images */ |
| 443 | /* Still have to work on g64 images */ |
| 408 | 444 | logerror("Unsupported format\n"); |
| 409 | 445 | break; |
| 410 | 446 | } |
| r3312 | r3313 | |
| 423 | 459 | case format_d64_err: |
| 424 | 460 | case format_d64_40t: |
| 425 | 461 | case format_d64_40t_err: |
| 462 | case format_d67: |
| 426 | 463 | case format_d71: |
| 427 | 464 | case format_d71_err: |
| 428 | 465 | id2 = image_tracksector2offset(18, 0) + 0xa3; |
| r3312 | r3313 | |
| 438 | 475 | break; |
| 439 | 476 | |
| 440 | 477 | default: |
| 441 | | /* Still have to work on d67 & g64 images */ |
| 478 | /* Still have to work on g64 images */ |
| 442 | 479 | logerror("Unsupported format\n"); |
| 443 | 480 | break; |
| 444 | 481 | } |
| r3312 | r3313 | |
| 1450 | 1487 | return INIT_FAIL; |
| 1451 | 1488 | } |
| 1452 | 1489 | } |
| 1490 | else if (!mame_stricmp (filetype, "d67")) |
| 1491 | format = format_d67; |
| 1453 | 1492 | else if (!mame_stricmp (filetype, "d81")) |
| 1454 | 1493 | format = format_d81; |
| 1455 | 1494 | else if (!mame_stricmp (filetype, "d80")) |
| r3312 | r3313 | |
| 1458 | 1497 | format = format_d82; |
| 1459 | 1498 | else |
| 1460 | 1499 | { |
| 1461 | | /* Still have to work on d67 & g64 images */ |
| 1500 | /* Still have to work on g64 images */ |
| 1462 | 1501 | logerror("Unsupported format\n"); |
| 1463 | 1502 | return INIT_FAIL; |
| 1464 | 1503 | } |
| r3312 | r3313 | |
| 1476 | 1515 | format_id_1 = temp_copy[disk_id1(format)]; // can be modified by error code 29 -> ^ 0xff |
| 1477 | 1516 | format_id_2 = temp_copy[disk_id2(format)]; |
| 1478 | 1517 | |
| 1479 | | for (k = 1; k <= D64_MAX_TRACKS; k++) |
| 1518 | for (k = 1; k <= max_tracks_per_format[format]; k++) |
| 1480 | 1519 | { |
| 1481 | 1520 | /* logerror("decoding track %d offset %d %d %d %d %d\n", k, |
| 1482 | 1521 | image_tracksector2offset(k, 0) / (16*16*16*16), |
| r3312 | r3313 | |
| 1609 | 1648 | |
| 1610 | 1649 | void c1551_device_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info) |
| 1611 | 1650 | { |
| 1651 | vc1541_device_getinfo(devclass, state, info); |
| 1652 | } |
| 1653 | |
| 1654 | |
| 1655 | void c1571_device_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info) |
| 1656 | { |
| 1612 | 1657 | switch(state) |
| 1613 | 1658 | { |
| 1614 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 1615 | | case MESS_DEVINFO_PTR_DEV_SPECIFIC: info->f = (genf *) drive_config; break; |
| 1659 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 1660 | case MESS_DEVINFO_STR_FILE_EXTENSIONS: strcpy(info->s = device_temp_str(), "d71"); break; |
| 1616 | 1661 | |
| 1617 | | default: vc1541_device_getinfo(devclass, state, info); break; |
| 1662 | default: vc1541_device_getinfo(devclass, state, info); |
| 1618 | 1663 | } |
| 1619 | 1664 | } |
| 1620 | 1665 | |
| 1666 | void c1581_device_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info) |
| 1667 | { |
| 1668 | switch(state) |
| 1669 | { |
| 1670 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 1671 | case MESS_DEVINFO_STR_FILE_EXTENSIONS: strcpy(info->s = device_temp_str(), "d81"); break; |
| 1621 | 1672 | |
| 1622 | | void c1571_device_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info) |
| 1673 | default: vc1541_device_getinfo(devclass, state, info); |
| 1674 | } |
| 1675 | } |
| 1676 | |
| 1677 | void c8050_device_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info) |
| 1623 | 1678 | { |
| 1624 | | vc1541_device_getinfo(devclass, state, info); |
| 1679 | switch(state) |
| 1680 | { |
| 1681 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 1682 | case MESS_DEVINFO_STR_FILE_EXTENSIONS: strcpy(info->s = device_temp_str(), "d80"); break; |
| 1683 | |
| 1684 | default: vc1541_device_getinfo(devclass, state, info); |
| 1685 | } |
| 1625 | 1686 | } |
| 1687 | |
| 1688 | void c8250_device_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info) |
| 1689 | { |
| 1690 | switch(state) |
| 1691 | { |
| 1692 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 1693 | case MESS_DEVINFO_STR_FILE_EXTENSIONS: strcpy(info->s = device_temp_str(), "d82"); break; |
| 1694 | |
| 1695 | default: vc1541_device_getinfo(devclass, state, info); |
| 1696 | } |
| 1697 | } |
| 1698 | |
| 1699 | void c2040_device_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info) |
| 1700 | { |
| 1701 | switch(state) |
| 1702 | { |
| 1703 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 1704 | case MESS_DEVINFO_STR_FILE_EXTENSIONS: strcpy(info->s = device_temp_str(), "d67"); break; |
| 1705 | |
| 1706 | default: vc1541_device_getinfo(devclass, state, info); |
| 1707 | } |
| 1708 | } |