src/mess/machine/c128.c
| r7104 | r7105 | |
| 213 | 213 | #endif |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | | static void c128_iec_data_w(running_machine *machine) |
| 216 | static void c128_iec_data_out_w(running_machine *machine) |
| 217 | 217 | { |
| 218 | 218 | const device_config *cia_1 = devtag_get_device(machine, "cia_1"); |
| 219 | 219 | const device_config *iec = devtag_get_device(machine, "iec"); |
| 220 | 220 | int data = !c128_data_out; |
| 221 | 221 | |
| 222 | 222 | /* fast serial data */ |
| 223 | | // if (MMU_FSDIR) data &= c128_sp1; |
| 223 | if (MMU_FSDIR) data &= c128_sp1; |
| 224 | 224 | |
| 225 | 225 | cbm_iec_data_w(iec, cia_1, data); |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | | static void c128_iec_srq_w(running_machine *machine) |
| 228 | static void c128_iec_srq_out_w(running_machine *machine) |
| 229 | 229 | { |
| 230 | 230 | const device_config *cia_1 = devtag_get_device(machine, "cia_1"); |
| 231 | 231 | const device_config *iec = devtag_get_device(machine, "iec"); |
| 232 | 232 | int srq = 1; |
| 233 | 233 | |
| 234 | 234 | /* fast serial clock */ |
| 235 | | // if (MMU_FSDIR) srq &= c128_cnt1; |
| 235 | if (MMU_FSDIR) srq &= c128_cnt1; |
| 236 | 236 | |
| 237 | 237 | cbm_iec_srq_w(iec, cia_1, srq); |
| 238 | 238 | } |
| r7104 | r7105 | |
| 241 | 241 | { |
| 242 | 242 | /* fast clock out */ |
| 243 | 243 | c128_cnt1 = state; |
| 244 | | c128_iec_srq_w(device->machine); |
| 244 | c128_iec_srq_out_w(device->machine); |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | static WRITE_LINE_DEVICE_HANDLER( cia0_sp_w ) |
| 248 | 248 | { |
| 249 | 249 | /* fast data out */ |
| 250 | 250 | c128_sp1 = state; |
| 251 | | c128_iec_data_w(device->machine); |
| 251 | c128_iec_data_out_w(device->machine); |
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | const mos6526_interface c128_ntsc_cia0 = |
| r7104 | r7105 | |
| 337 | 337 | const device_config *serbus = devtag_get_device(device->machine, "iec"); |
| 338 | 338 | |
| 339 | 339 | c128_data_out = BIT(data, 5); |
| 340 | | c128_iec_data_w(device->machine); |
| 340 | c128_iec_data_out_w(device->machine); |
| 341 | 341 | |
| 342 | 342 | cbm_iec_clk_w(serbus, device, !BIT(data, 4)); |
| 343 | 343 | |
| r7104 | r7105 | |
| 861 | 861 | case 5: |
| 862 | 862 | c128_mmu[offset] = data; |
| 863 | 863 | c128_bankswitch (space->machine, 0); |
| 864 | | c128_iec_srq_w(space->machine); |
| 865 | | c128_iec_data_w(space->machine); |
| 864 | c128_iec_srq_out_w(space->machine); |
| 865 | c128_iec_data_out_w(space->machine); |
| 866 | 866 | break; |
| 867 | 867 | case 0: |
| 868 | 868 | case 6: |
src/mess/machine/c1571.c
| r7104 | r7105 | |
| 11 | 11 | |
| 12 | 12 | TODO: |
| 13 | 13 | |
| 14 | - 1541/1571 Alignment shows drive speed as 266 rpm, should be 310 |
| 14 | 15 | - toggle WPRT line on disk change |
| 15 | 16 | - save state |
| 16 | 17 | - D71 disks |
| r7104 | r7105 | |
| 37 | 38 | #define LOG 0 |
| 38 | 39 | |
| 39 | 40 | #define M6502_TAG "u1" |
| 40 | | #define M6522_0_TAG "u4" |
| 41 | | #define M6522_1_TAG "u9" |
| 41 | #define M6522_0_TAG "u9" |
| 42 | #define M6522_1_TAG "u4" |
| 42 | 43 | #define M6526_TAG "u20" |
| 43 | 44 | #define WD1770_TAG "u11" |
| 44 | 45 | |
| r7104 | r7105 | |
| 125 | 126 | |
| 126 | 127 | INLINE void iec_data_w(const device_config *device) |
| 127 | 128 | { |
| 128 | | c1571_t *c1571 = get_safe_token(device->owner); |
| 129 | c1571_t *c1571 = get_safe_token(device); |
| 129 | 130 | |
| 130 | 131 | int atn = cbm_iec_atn_r(c1571->serial_bus); |
| 131 | 132 | int data = !c1571->data_out & !(c1571->atn_ack ^ !atn); |
| r7104 | r7105 | |
| 133 | 134 | /* fast serial data */ |
| 134 | 135 | if (c1571->ser_dir) data &= c1571->sp_out; |
| 135 | 136 | |
| 136 | | cbm_iec_data_w(c1571->serial_bus, device->owner, data); |
| 137 | cbm_iec_data_w(c1571->serial_bus, device, data); |
| 137 | 138 | } |
| 138 | 139 | |
| 139 | 140 | INLINE void iec_srq_w(const device_config *device) |
| 140 | 141 | { |
| 141 | | c1571_t *c1571 = get_safe_token(device->owner); |
| 142 | c1571_t *c1571 = get_safe_token(device); |
| 142 | 143 | |
| 143 | 144 | int srq = 1; |
| 144 | 145 | |
| 145 | 146 | /* fast serial clock */ |
| 146 | 147 | if (c1571->ser_dir) srq &= c1571->cnt_out; |
| 147 | 148 | |
| 148 | | cbm_iec_srq_w(c1571->serial_bus, device->owner, srq); |
| 149 | cbm_iec_srq_w(c1571->serial_bus, device, srq); |
| 149 | 150 | } |
| 150 | 151 | |
| 151 | 152 | /*************************************************************************** |
| r7104 | r7105 | |
| 217 | 218 | WRITE_LINE_DEVICE_HANDLER( c1571_iec_atn_w ) |
| 218 | 219 | { |
| 219 | 220 | c1571_t *c1571 = get_safe_token(device); |
| 220 | | int data_out = !c1571->data_out && !(c1571->atn_ack ^ !state); |
| 221 | 221 | |
| 222 | 222 | via_ca1_w(c1571->via0, !state); |
| 223 | | |
| 224 | | cbm_iec_data_w(c1571->serial_bus, device, data_out); |
| 223 | iec_data_w(device); |
| 225 | 224 | } |
| 226 | 225 | |
| 227 | 226 | /*------------------------------------------------- |
| r7104 | r7105 | |
| 283 | 282 | |
| 284 | 283 | static ADDRESS_MAP_START( c1571_map, ADDRESS_SPACE_PROGRAM, 8 ) |
| 285 | 284 | AM_RANGE(0x0000, 0x07ff) AM_RAM |
| 286 | | AM_RANGE(0x1800, 0x180f) AM_DEVREADWRITE(M6522_0_TAG, via_r, via_w) |
| 287 | | AM_RANGE(0x1c00, 0x1c0f) AM_DEVREADWRITE(M6522_1_TAG, via_r, via_w) |
| 288 | | AM_RANGE(0x2000, 0x2003) AM_DEVREADWRITE(WD1770_TAG, wd17xx_r, wd17xx_w) |
| 289 | | AM_RANGE(0x4000, 0x400f) AM_DEVREADWRITE(M6526_TAG, mos6526_r, mos6526_w) |
| 285 | AM_RANGE(0x1800, 0x180f) AM_MIRROR(0x03f0) AM_DEVREADWRITE(M6522_0_TAG, via_r, via_w) |
| 286 | AM_RANGE(0x1c00, 0x1c0f) AM_MIRROR(0x03f0) AM_DEVREADWRITE(M6522_1_TAG, via_r, via_w) |
| 287 | AM_RANGE(0x2000, 0x2003) AM_MIRROR(0x1ffc) AM_DEVREADWRITE(WD1770_TAG, wd17xx_r, wd17xx_w) |
| 288 | AM_RANGE(0x4000, 0x400f) AM_MIRROR(0x3ff0) AM_DEVREADWRITE(M6526_TAG, mos6526_r, mos6526_w) |
| 290 | 289 | AM_RANGE(0x8000, 0xffff) AM_ROM AM_REGION("c1571", 0) |
| 291 | 290 | ADDRESS_MAP_END |
| 292 | 291 | |
| r7104 | r7105 | |
| 342 | 341 | data |= floppy_tk00_r(c1571->image); |
| 343 | 342 | |
| 344 | 343 | /* byte ready */ |
| 345 | | data |= c1571->byte << 7; |
| 344 | data |= !(c1571->byte && c1571->soe) << 7; |
| 346 | 345 | |
| 347 | 346 | return data; |
| 348 | 347 | } |
| r7104 | r7105 | |
| 376 | 375 | |
| 377 | 376 | /* fast serial direction */ |
| 378 | 377 | c1571->ser_dir = BIT(data, 1); |
| 379 | | iec_data_w(device); |
| 380 | | iec_srq_w(device); |
| 378 | iec_data_w(device->owner); |
| 379 | iec_srq_w(device->owner); |
| 381 | 380 | |
| 382 | 381 | /* side select */ |
| 383 | 382 | wd17xx_set_side(c1571->wd1770, BIT(data, 2)); |
| r7104 | r7105 | |
| 445 | 444 | |
| 446 | 445 | /* data out */ |
| 447 | 446 | c1571->data_out = BIT(data, 1); |
| 448 | | iec_data_w(device); |
| 447 | iec_data_w(device->owner); |
| 449 | 448 | |
| 450 | 449 | /* clock out */ |
| 451 | 450 | cbm_iec_clk_w(c1571->serial_bus, device->owner, !BIT(data, 3)); |
| r7104 | r7105 | |
| 621 | 620 | } |
| 622 | 621 | } |
| 623 | 622 | |
| 623 | static READ_LINE_DEVICE_HANDLER( byte_ready_r ) |
| 624 | { |
| 625 | c1571_t *c1571 = get_safe_token(device->owner); |
| 626 | |
| 627 | return !(c1571->byte && c1571->soe); |
| 628 | } |
| 629 | |
| 624 | 630 | static WRITE_LINE_DEVICE_HANDLER( soe_w ) |
| 625 | 631 | { |
| 626 | 632 | c1571_t *c1571 = get_safe_token(device->owner); |
| r7104 | r7105 | |
| 643 | 649 | { |
| 644 | 650 | DEVCB_HANDLER(yb_r), |
| 645 | 651 | DEVCB_HANDLER(via1_pb_r), |
| 652 | DEVCB_LINE(byte_ready_r), |
| 646 | 653 | DEVCB_NULL, |
| 647 | 654 | DEVCB_NULL, |
| 648 | 655 | DEVCB_NULL, |
| 649 | | DEVCB_NULL, |
| 650 | 656 | |
| 651 | 657 | DEVCB_HANDLER(yb_w), |
| 652 | 658 | DEVCB_HANDLER(via1_pb_w), |
| r7104 | r7105 | |
| 677 | 683 | |
| 678 | 684 | /* fast serial clock out */ |
| 679 | 685 | c1571->cnt_out = state; |
| 680 | | iec_srq_w(device); |
| 686 | iec_srq_w(device->owner); |
| 681 | 687 | } |
| 682 | 688 | |
| 683 | 689 | static WRITE_LINE_DEVICE_HANDLER( cia_sp_w ) |
| r7104 | r7105 | |
| 686 | 692 | |
| 687 | 693 | /* fast serial data out */ |
| 688 | 694 | c1571->sp_out = state; |
| 689 | | iec_data_w(device); |
| 695 | iec_data_w(device->owner); |
| 690 | 696 | } |
| 691 | 697 | |
| 692 | 698 | static MOS6526_INTERFACE( c1571_cia_intf ) |
| r7104 | r7105 | |
| 718 | 724 | -------------------------------------------------*/ |
| 719 | 725 | |
| 720 | 726 | static FLOPPY_OPTIONS_START( c1571 ) |
| 721 | | FLOPPY_OPTION( c1571, "g64", "Commodore 1571 GCR Disk Image", g64_dsk_identify, g64_dsk_construct, NULL ) |
| 722 | | // FLOPPY_OPTION( c1571, "d64", "Commodore 1571 Disk Image", d64_dsk_identify, d64_dsk_construct, NULL ) |
| 727 | FLOPPY_OPTION( c1571, "g64", "Commodore 1541 GCR Disk Image", g64_dsk_identify, g64_dsk_construct, NULL ) |
| 728 | // FLOPPY_OPTION( c1571, "d64", "Commodore 1541 Disk Image", d64_dsk_identify, d64_dsk_construct, NULL ) |
| 723 | 729 | // FLOPPY_OPTION( c1571, "d71", "Commodore 1571 Disk Image", d64_dsk_identify, d64_dsk_construct, NULL ) |
| 724 | 730 | FLOPPY_OPTIONS_END |
| 725 | 731 | |