src/mess/machine/c2040.c
| r7217 | r7218 | |
| 11 | 11 | |
| 12 | 12 | TODO: |
| 13 | 13 | |
| 14 | | - e21t18s00 |
| 15 | | - read from disk |
| 16 | 14 | - 8050 clock generator |
| 17 | 15 | - write to disk |
| 18 | 16 | - save state |
| r7217 | r7218 | |
| 111 | 109 | int ready; /* byte ready */ |
| 112 | 110 | int mode; /* mode select */ |
| 113 | 111 | int rw; /* read/write select */ |
| 112 | int miot_irq; /* MIOT interrupt */ |
| 114 | 113 | |
| 115 | 114 | /* devices */ |
| 116 | 115 | running_device *cpu_dos; |
| r7217 | r7218 | |
| 219 | 218 | int ready = !(c2040->bit_count==9); |
| 220 | 219 | int error = !(ready | BIT(c2040->e, 3)); |
| 221 | 220 | |
| 222 | | logerror("offs %04x G64 %02x READY %u PA %02x DATA %03x GCR %02x SYNC %u ERROR %u I %04x\n", c2040->unit[c2040->drive].buffer_pos, |
| 221 | logerror("offs %04x/%04x G64 %02x READY %u PA %02x DATA %03x GCR %02x SYNC %u ERROR %u I %04x\n", c2040->unit[c2040->drive].buffer_pos-1, c2040->unit[c2040->drive].track_len, |
| 223 | 222 | c2040->unit[c2040->drive].track_buffer[c2040->unit[c2040->drive].buffer_pos], |
| 224 | 223 | ready, pa, c2040->sr & 0x3ff, c2040->e, SYNC, error, c2040->i); |
| 225 | 224 | } |
| r7217 | r7218 | |
| 255 | 254 | c2040->unit[c2040->drive].bit_pos = 7; |
| 256 | 255 | c2040->unit[c2040->drive].buffer_pos++; |
| 257 | 256 | |
| 258 | | if (c2040->unit[c2040->drive].buffer_pos > c2040->unit[c2040->drive].track_len + 1) |
| 257 | if (c2040->unit[c2040->drive].buffer_pos == c2040->unit[c2040->drive].track_len + 2) |
| 259 | 258 | { |
| 260 | 259 | /* loop to the start of the track */ |
| 261 | 260 | c2040->unit[c2040->drive].buffer_pos = TRACK_DATA_START; |
| r7217 | r7218 | |
| 279 | 278 | { |
| 280 | 279 | /* set byte ready flag */ |
| 281 | 280 | c2040->ready = ready; |
| 282 | | via_ca1_w(c2040->via, ready); |
| 283 | 281 | } |
| 284 | 282 | |
| 283 | via_ca1_w(c2040->via, ready); |
| 285 | 284 | via_cb1_w(c2040->via, ERROR); |
| 286 | 285 | } |
| 287 | 286 | |
| r7217 | r7218 | |
| 670 | 669 | |
| 671 | 670 | UINT16 i = c2040->i; |
| 672 | 671 | UINT8 e = c2040->e; |
| 672 | UINT8 data = (BIT(e, 6) << 7) | (BIT(i, 7) << 6) | (e & 0x33) | (BIT(e, 2) << 3) | (i & 0x04); |
| 673 | 673 | |
| 674 | | return (BIT(e, 6) << 7) | (BIT(i, 7) << 6) | (e & 0x33) | (BIT(e, 2) << 3) | (i & 0x04); |
| 674 | return data; |
| 675 | 675 | } |
| 676 | 676 | |
| 677 | 677 | static READ8_DEVICE_HANDLER( via_pb_r ) |
| r7217 | r7218 | |
| 722 | 722 | floppy_drive_read_track_data_info_buffer(c2040->unit[unit].image, c2040->side, c2040->unit[unit].track_buffer, &c2040->unit[unit].track_len); |
| 723 | 723 | |
| 724 | 724 | /* extract track length */ |
| 725 | | c2040->unit[unit].track_len = (c2040->unit[unit].track_buffer[1] << 8) | c2040->unit[unit].track_buffer[0]; |
| 725 | c2040->unit[unit].track_len = 2 + ((c2040->unit[unit].track_buffer[1] << 8) | c2040->unit[unit].track_buffer[0]); |
| 726 | 726 | } |
| 727 | 727 | |
| 728 | 728 | c2040->unit[unit].stp = stp; |
| r7217 | r7218 | |
| 1004 | 1004 | } |
| 1005 | 1005 | |
| 1006 | 1006 | /* interrupt */ |
| 1007 | | cpu_set_input_line(c2040->cpu_fdc, M6502_IRQ_LINE, BIT(newdata, 7) ? CLEAR_LINE : ASSERT_LINE); |
| 1007 | if (c2040->miot_irq != BIT(newdata, 7)) |
| 1008 | { |
| 1009 | cpu_set_input_line(c2040->cpu_fdc, M6502_IRQ_LINE, BIT(newdata, 7) ? CLEAR_LINE : ASSERT_LINE); |
| 1010 | c2040->miot_irq = BIT(newdata, 7); |
| 1011 | } |
| 1008 | 1012 | } |
| 1009 | 1013 | |
| 1010 | 1014 | static const miot6530_interface miot_intf = |
| r7217 | r7218 | |
| 1417 | 1421 | c2040->unit[1].image = device->subdevice(FLOPPY_1); |
| 1418 | 1422 | |
| 1419 | 1423 | /* find GCR ROM */ |
| 1420 | | running_device *region_dev = NULL; |
| 1421 | | |
| 1422 | 1424 | if ((device->type == C2040) || (device->type == C3040)) |
| 1423 | 1425 | { |
| 1424 | | region_dev = device->subdevice(C2040_REGION); |
| 1426 | astring region_name(device->tag, ":", C2040_REGION); |
| 1427 | c2040->gcr = memory_region(device->machine, region_name.cstr()) + |
| 1428 | memory_region_length(device->machine, region_name.cstr()) - 0x800; |
| 1425 | 1429 | } |
| 1426 | 1430 | else if (device->type == C4040) |
| 1427 | 1431 | { |
| 1428 | | region_dev = device->subdevice(C4040_REGION); |
| 1432 | astring region_name(device->tag, ":", C4040_REGION); |
| 1433 | c2040->gcr = memory_region(device->machine, region_name.cstr()) + |
| 1434 | memory_region_length(device->machine, region_name.cstr()) - 0x800; |
| 1429 | 1435 | } |
| 1430 | 1436 | else if ((device->type == C8050) || (device->type == C8250)) |
| 1431 | 1437 | { |
| 1432 | | region_dev = device->subdevice(C8050_REGION); |
| 1438 | astring region_name(device->tag, ":", C8050_REGION); |
| 1439 | c2040->gcr = memory_region(device->machine, region_name.cstr()) + |
| 1440 | memory_region_length(device->machine, region_name.cstr()) - 0x800; |
| 1433 | 1441 | } |
| 1434 | 1442 | else if (device->type == SFD1001) |
| 1435 | 1443 | { |
| 1436 | | region_dev = device->subdevice(SFD1001_REGION); |
| 1444 | astring region_name(device->tag, ":", SFD1001_REGION); |
| 1445 | c2040->gcr = memory_region(device->machine, region_name.cstr()) + |
| 1446 | memory_region_length(device->machine, region_name.cstr()) - 0x800; |
| 1437 | 1447 | } |
| 1438 | 1448 | |
| 1439 | | c2040->gcr = memory_region(device->machine, region_dev->tag.cstr()) + |
| 1440 | | memory_region_length(device->machine, region_dev->tag.cstr()) - 0x800; |
| 1441 | | |
| 1442 | 1449 | /* allocate data timer */ |
| 1443 | 1450 | c2040->bit_timer = timer_alloc(device->machine, bit_tick, (void *)device); |
| 1444 | 1451 | |
src/mess/formats/g64_dsk.c
| r7217 | r7218 | |
| 42 | 42 | |
| 43 | 43 | #define LOG 0 |
| 44 | 44 | |
| 45 | | #define HEADER_LENGTH 0x2ac /* standard length for 84 half tracks */ |
| 46 | | #define HALF_TRACKS 84 |
| 45 | #define HEADER_LENGTH 0x2ac /* standard length for 84 half tracks */ |
| 46 | #define MAX_TRACKS 84 |
| 47 | 47 | |
| 48 | 48 | struct g64dsk_tag |
| 49 | 49 | { |
| 50 | 50 | int version; |
| 51 | | int tracks; |
| 52 | | UINT16 track_size; |
| 53 | | UINT32 track_offset[HALF_TRACKS]; /* offset within data for each half track */ |
| 54 | | UINT32 speed_zone_offset[HALF_TRACKS]; /* offset within data for each half track */ |
| 51 | int tracks; /* number of physical tracks */ |
| 52 | UINT16 track_size; /* size of each track */ |
| 53 | UINT32 track_offset[MAX_TRACKS]; /* offset within data for each track */ |
| 54 | UINT32 speed_zone_offset[MAX_TRACKS]; /* offset within data for each track */ |
| 55 | 55 | }; |
| 56 | 56 | |
| 57 | | INLINE float get_track_index(int track) |
| 57 | INLINE float get_dos_track(int track) |
| 58 | 58 | { |
| 59 | 59 | return ((float)track / 2) + 1; |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | static struct g64dsk_tag *get_tag(floppy_image *floppy) |
| 63 | 63 | { |
| 64 | | struct g64dsk_tag *tag; |
| 65 | | tag = (g64dsk_tag *)floppy_tag(floppy); |
| 64 | struct g64dsk_tag *tag = (g64dsk_tag *)floppy_tag(floppy); |
| 66 | 65 | return tag; |
| 67 | 66 | } |
| 68 | 67 | |
| r7217 | r7218 | |
| 94 | 93 | |
| 95 | 94 | static floperr_t g64_read_track(floppy_image *floppy, int head, int track, UINT64 offset, void *buffer, size_t buflen) |
| 96 | 95 | { |
| 96 | struct g64dsk_tag *tag = get_tag(floppy); |
| 97 | 97 | floperr_t err; |
| 98 | 98 | UINT64 track_offset; |
| 99 | | UINT8 header[2]; |
| 100 | 99 | UINT16 track_length = 0; |
| 101 | 100 | |
| 102 | 101 | /* get track offset */ |
| r7217 | r7218 | |
| 107 | 106 | |
| 108 | 107 | if (track_offset) |
| 109 | 108 | { |
| 110 | | /* get track length */ |
| 111 | | floppy_image_read(floppy, header, track_offset, 2); |
| 112 | | track_length = (header[1] << 8) | header[0]; |
| 109 | if (buflen < (tag->track_size + 2)) fatalerror("G64 track buffer too small: %u!\n", (UINT32)buflen); |
| 113 | 110 | |
| 114 | | if (buflen < track_length) fatalerror("G64 track buffer too small: %u!\n", (UINT32)buflen); |
| 115 | | |
| 116 | | if (track_length) |
| 117 | | { |
| 118 | | /* read track */ |
| 119 | | floppy_image_read(floppy, buffer, track_offset, track_length); |
| 120 | | } |
| 111 | /* read track */ |
| 112 | floppy_image_read(floppy, buffer, track_offset, tag->track_size + 2); |
| 121 | 113 | } |
| 122 | 114 | else |
| 123 | 115 | { |
| r7217 | r7218 | |
| 125 | 117 | memset(buffer, 0, buflen); |
| 126 | 118 | } |
| 127 | 119 | |
| 128 | | if (LOG) logerror("G64 track %.1f length %u\n", get_track_index(track), track_length); |
| 120 | if (LOG) logerror("G64 track %.1f length %u\n", get_dos_track(track), track_length); |
| 129 | 121 | |
| 130 | 122 | return FLOPPY_ERROR_SUCCESS; |
| 131 | 123 | } |
| r7217 | r7218 | |
| 190 | 182 | floppy_image_read(floppy, header, pos, 4); pos += 4; |
| 191 | 183 | tag->track_offset[i] = (header[3] << 24) | (header[2] << 16) | (header[1] << 8) | header[0]; |
| 192 | 184 | |
| 193 | | if (LOG) logerror("G64 track %.1f data offset: %04x\n", get_track_index(i), tag->track_offset[i]); |
| 185 | if (LOG) logerror("G64 track %.1f data offset: %04x\n", get_dos_track(i), tag->track_offset[i]); |
| 194 | 186 | } |
| 195 | 187 | |
| 196 | 188 | /* speed zone offsets */ |
| r7217 | r7218 | |
| 202 | 194 | if (LOG) |
| 203 | 195 | { |
| 204 | 196 | if (tag->speed_zone_offset[i] < 4) |
| 205 | | logerror("G64 track %.1f speed zone: %u\n", get_track_index(i), tag->speed_zone_offset[i]); |
| 197 | logerror("G64 track %.1f speed zone: %u\n", get_dos_track(i), tag->speed_zone_offset[i]); |
| 206 | 198 | else |
| 207 | | logerror("G64 track %.1f speed zone offset: %04x\n", get_track_index(i), tag->speed_zone_offset[i]); |
| 199 | logerror("G64 track %.1f speed zone offset: %04x\n", get_dos_track(i), tag->speed_zone_offset[i]); |
| 208 | 200 | } |
| 209 | 201 | } |
| 210 | 202 | |
src/mess/drivers/pet.c
| r7217 | r7218 | |
| 388 | 388 | #include "machine/cbmipt.h" |
| 389 | 389 | #include "video/mc6845.h" |
| 390 | 390 | #include "devices/messram.h" |
| 391 | | #include "machine/c1541.h" |
| 391 | #include "machine/c2040.h" |
| 392 | 392 | |
| 393 | 393 | /* devices config */ |
| 394 | 394 | #include "includes/cbm.h" |
| r7217 | r7218 | |
| 648 | 648 | { "pia_0" }, |
| 649 | 649 | { "pia_1", DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_DEVICE_HANDLER("pia_1", pia6821_cb1_w), DEVCB_DEVICE_HANDLER("pia_1", pia6821_ca1_w), DEVCB_NULL }, |
| 650 | 650 | { "via6522_0" }, |
| 651 | | { C2031_IEEE488("c2031") }, |
| 651 | { C2040_IEEE488("c4040") }, |
| 652 | 652 | { NULL} |
| 653 | 653 | }; |
| 654 | 654 | |
| r7217 | r7218 | |
| 693 | 693 | |
| 694 | 694 | /* IEEE bus */ |
| 695 | 695 | MDRV_IEEE488_ADD("ieee_bus", ieee488_daisy) |
| 696 | | MDRV_C2031_ADD("c2031", "ieee_bus", 8) |
| 696 | MDRV_C4040_ADD("c4040", "ieee_bus", 8) |
| 697 | 697 | MACHINE_DRIVER_END |
| 698 | 698 | |
| 699 | 699 | |