src/mess/drivers/sord.c
| r3651 | r3652 | |
| 68 | 68 | /* stb and ack automatically set on read/write? */ |
| 69 | 69 | static WRITE8_HANDLER(fd5_communication_w) |
| 70 | 70 | { |
| 71 | | cpu_yield(); |
| 71 | cpu_yield(space->cpu); |
| 72 | 72 | |
| 73 | 73 | fd5_port_0x020_data = data; |
| 74 | | LOG(("fd5 0x020: %02x %04x\n",data,activecpu_get_pc())); |
| 74 | LOG(("fd5 0x020: %02x %04x\n",data,cpu_get_pc(space->cpu))); |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | static READ8_HANDLER(fd5_communication_r) |
| 78 | 78 | { |
| 79 | 79 | int data; |
| 80 | 80 | |
| 81 | | cpu_yield(); |
| 81 | cpu_yield(space->cpu); |
| 82 | 82 | |
| 83 | 83 | data = (obfa<<3)|(ibfa<<2)|2; |
| 84 | | LOG(("fd5 0x030: %02x %04x\n",data, activecpu_get_pc())); |
| 84 | LOG(("fd5 0x030: %02x %04x\n",data, cpu_get_pc(space->cpu))); |
| 85 | 85 | |
| 86 | 86 | return data; |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | static READ8_HANDLER(fd5_data_r) |
| 90 | 90 | { |
| 91 | | cpu_yield(); |
| 91 | cpu_yield(space->cpu); |
| 92 | 92 | |
| 93 | | LOG(("fd5 0x010 r: %02x %04x\n",fd5_databus,activecpu_get_pc())); |
| 93 | LOG(("fd5 0x010 r: %02x %04x\n",fd5_databus,cpu_get_pc(space->cpu))); |
| 94 | 94 | |
| 95 | | ppi8255_set_port_c((device_config*)device_list_find_by_tag( machine->config->devicelist, PPI8255, "ppi8255" ), 0x50); |
| 96 | | ppi8255_set_port_c((device_config*)device_list_find_by_tag( machine->config->devicelist, PPI8255, "ppi8255" ), 0x10); |
| 97 | | ppi8255_set_port_c((device_config*)device_list_find_by_tag( machine->config->devicelist, PPI8255, "ppi8255" ), 0x50); |
| 95 | ppi8255_set_port_c((device_config*)device_list_find_by_tag( space->machine->config->devicelist, PPI8255, "ppi8255" ), 0x50); |
| 96 | ppi8255_set_port_c((device_config*)device_list_find_by_tag( space->machine->config->devicelist, PPI8255, "ppi8255" ), 0x10); |
| 97 | ppi8255_set_port_c((device_config*)device_list_find_by_tag( space->machine->config->devicelist, PPI8255, "ppi8255" ), 0x50); |
| 98 | 98 | |
| 99 | 99 | return fd5_databus; |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | static WRITE8_HANDLER(fd5_data_w) |
| 103 | 103 | { |
| 104 | | LOG(("fd5 0x010 w: %02x %04x\n",data,activecpu_get_pc())); |
| 104 | LOG(("fd5 0x010 w: %02x %04x\n",data,cpu_get_pc(space->cpu))); |
| 105 | 105 | |
| 106 | 106 | fd5_databus = data; |
| 107 | 107 | |
| 108 | 108 | /* set stb on data write */ |
| 109 | | ppi8255_set_port_c((device_config*)device_list_find_by_tag( machine->config->devicelist, PPI8255, "ppi8255" ), 0x50); |
| 110 | | ppi8255_set_port_c((device_config*)device_list_find_by_tag( machine->config->devicelist, PPI8255, "ppi8255" ), 0x40); |
| 111 | | ppi8255_set_port_c((device_config*)device_list_find_by_tag( machine->config->devicelist, PPI8255, "ppi8255" ), 0x50); |
| 109 | ppi8255_set_port_c((device_config*)device_list_find_by_tag( space->machine->config->devicelist, PPI8255, "ppi8255" ), 0x50); |
| 110 | ppi8255_set_port_c((device_config*)device_list_find_by_tag( space->machine->config->devicelist, PPI8255, "ppi8255" ), 0x40); |
| 111 | ppi8255_set_port_c((device_config*)device_list_find_by_tag( space->machine->config->devicelist, PPI8255, "ppi8255" ), 0x50); |
| 112 | 112 | |
| 113 | | cpu_yield(); |
| 113 | cpu_yield(space->cpu); |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | static WRITE8_HANDLER(fd5_drive_control_w) |
| r3651 | r3652 | |
| 132 | 132 | |
| 133 | 133 | static WRITE8_HANDLER(fd5_tc_w) |
| 134 | 134 | { |
| 135 | | nec765_set_tc_state(machine, 1); |
| 136 | | nec765_set_tc_state(machine, 0); |
| 135 | nec765_set_tc_state(space->machine, 1); |
| 136 | nec765_set_tc_state(space->machine, 0); |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | /* 0x020 fd5 writes to this port to communicate with m5 */ |
| r3651 | r3652 | |
| 156 | 156 | { |
| 157 | 157 | if (state) |
| 158 | 158 | { |
| 159 | | cpunum_set_input_line(Machine, 1, 0, HOLD_LINE); |
| 159 | cpu_set_input_line(Machine->cpu[1], 0, HOLD_LINE); |
| 160 | 160 | } |
| 161 | 161 | else |
| 162 | 162 | { |
| 163 | | cpunum_set_input_line(Machine, 1, 0,CLEAR_LINE); |
| 163 | cpu_set_input_line(Machine->cpu[1], 0,CLEAR_LINE); |
| 164 | 164 | } |
| 165 | 165 | } |
| 166 | 166 | |
| r3651 | r3652 | |
| 195 | 195 | |
| 196 | 196 | static READ8_DEVICE_HANDLER(sord_ppi_porta_r) |
| 197 | 197 | { |
| 198 | | cpu_yield(); |
| 198 | cpu_yield(device->machine->cpu[0]); |
| 199 | 199 | |
| 200 | 200 | return fd5_databus; |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | static READ8_DEVICE_HANDLER(sord_ppi_portb_r) |
| 204 | 204 | { |
| 205 | | cpu_yield(); |
| 205 | cpu_yield(device->machine->cpu[0]); |
| 206 | 206 | |
| 207 | | LOG(("m5 read from pi5 port b %04x\n",activecpu_get_pc())); |
| 207 | LOG(("m5 read from pi5 port b %04x\n",cpu_get_pc(device->machine->cpu[0]))); |
| 208 | 208 | |
| 209 | 209 | return 0x0ff; |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | static READ8_DEVICE_HANDLER(sord_ppi_portc_r) |
| 213 | 213 | { |
| 214 | | cpu_yield(); |
| 214 | cpu_yield(device->machine->cpu[0]); |
| 215 | 215 | |
| 216 | | LOG(("m5 read from pi5 port c %04x\n",activecpu_get_pc())); |
| 216 | LOG(("m5 read from pi5 port c %04x\n",cpu_get_pc(device->machine->cpu[0]))); |
| 217 | 217 | |
| 218 | 218 | /* from fd5 */ |
| 219 | 219 | /* 00 = 0000 = write */ |
| r3651 | r3652 | |
| 242 | 242 | |
| 243 | 243 | static WRITE8_DEVICE_HANDLER(sord_ppi_porta_w) |
| 244 | 244 | { |
| 245 | | cpu_yield(); |
| 245 | cpu_yield(device->machine->cpu[0]); |
| 246 | 246 | |
| 247 | 247 | fd5_databus = data; |
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | static WRITE8_DEVICE_HANDLER(sord_ppi_portb_w) |
| 251 | 251 | { |
| 252 | | cpu_yield(); |
| 252 | cpu_yield(device->machine->cpu[0]); |
| 253 | 253 | |
| 254 | 254 | /* f0, 40 */ |
| 255 | 255 | /* 1111 */ |
| r3651 | r3652 | |
| 257 | 257 | |
| 258 | 258 | if (data==0x0f0) |
| 259 | 259 | { |
| 260 | | cpunum_set_input_line(device->machine, 1, INPUT_LINE_RESET, ASSERT_LINE); |
| 261 | | cpunum_set_input_line(device->machine, 1, INPUT_LINE_RESET, CLEAR_LINE); |
| 260 | cpu_set_input_line(device->machine->cpu[1], INPUT_LINE_RESET, ASSERT_LINE); |
| 261 | cpu_set_input_line(device->machine->cpu[1], INPUT_LINE_RESET, CLEAR_LINE); |
| 262 | 262 | } |
| 263 | | LOG(("m5 write to pi5 port b: %02x %04x\n",data,activecpu_get_pc())); |
| 263 | LOG(("m5 write to pi5 port b: %02x %04x\n",data,cpu_get_pc(device->machine->cpu[0]))); |
| 264 | 264 | } |
| 265 | 265 | |
| 266 | 266 | /* A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, */ |
| r3651 | r3652 | |
| 275 | 275 | intra = (data & 0x08) ? 1 : 0; |
| 276 | 276 | ibfa = (data & 0x20) ? 1 : 0; |
| 277 | 277 | |
| 278 | | cpu_yield(); |
| 279 | | LOG(("m5 write to pi5 port c: %02x %04x\n",data,activecpu_get_pc())); |
| 278 | cpu_yield(device->machine->cpu[0]); |
| 279 | LOG(("m5 write to pi5 port c: %02x %04x\n",data,cpu_get_pc(device->machine->cpu[0]))); |
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | static const ppi8255_interface sord_ppi8255_interface = |
| r3651 | r3652 | |
| 295 | 295 | static void sord_m5_ctc_interrupt(const device_config *device, int state) |
| 296 | 296 | { |
| 297 | 297 | //logerror("interrupting ctc %02x\r\n ",state); |
| 298 | | cpunum_set_input_line(device->machine, 0, 0, state); |
| 298 | cpu_set_input_line(device->machine->cpu[0], 0, state); |
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | static const z80ctc_interface sord_m5_ctc_intf = |
| r3651 | r3652 | |
| 315 | 315 | "LINE8", "LINE9", "LINE10", "LINE11", "LINE12", "LINE13", "LINE14", "LINE15", |
| 316 | 316 | "RESET"}; |
| 317 | 317 | |
| 318 | | return input_port_read(machine, keynames[offset]); |
| 318 | return input_port_read(space->machine, keynames[offset]); |
| 319 | 319 | } |
| 320 | 320 | |
| 321 | 321 | static ADDRESS_MAP_START( sord_m5_mem , ADDRESS_SPACE_PROGRAM, 8) |
| r3651 | r3652 | |
| 344 | 344 | z80ctc_w(device, offset & 0x03, data); |
| 345 | 345 | } |
| 346 | 346 | |
| 347 | | static READ8_HANDLER(sord_sys_r) |
| 347 | static READ8_HANDLER(sord_sys_r) |
| 348 | 348 | { |
| 349 | 349 | unsigned char data; |
| 350 | 350 | int printer_handshake; |
| r3651 | r3652 | |
| 352 | 352 | data = 0; |
| 353 | 353 | |
| 354 | 354 | /* cassette read */ |
| 355 | | if (cassette_input(cassette_device_image(machine)) >=0) |
| 355 | if (cassette_input(cassette_device_image(space->machine)) >=0) |
| 356 | 356 | data |=(1<<0); |
| 357 | 357 | |
| 358 | 358 | printer_handshake = centronics_read_handshake(0); |
| r3651 | r3652 | |
| 390 | 390 | |
| 391 | 391 | /* cassette remote */ |
| 392 | 392 | cassette_change_state( |
| 393 | | cassette_device_image(machine), |
| 393 | cassette_device_image(space->machine), |
| 394 | 394 | (data & 0x02) ? CASSETTE_MOTOR_ENABLED : CASSETTE_MOTOR_DISABLED, |
| 395 | 395 | CASSETTE_MASK_MOTOR); |
| 396 | 396 | |
| 397 | 397 | /* cassette data */ |
| 398 | | cassette_output(cassette_device_image(machine), (data & (1<<0)) ? -1.0 : 1.0); |
| 398 | cassette_output(cassette_device_image(space->machine), (data & (1<<0)) ? -1.0 : 1.0); |
| 399 | 399 | |
| 400 | 400 | /* assumption: select is tied low */ |
| 401 | 401 | centronics_write_handshake(0, CENTRONICS_SELECT | CENTRONICS_NO_RESET, CENTRONICS_SELECT| CENTRONICS_NO_RESET); |
| r3651 | r3652 | |
| 471 | 471 | TMS9928A_reset (); |
| 472 | 472 | |
| 473 | 473 | /* should be done in a special callback to work properly! */ |
| 474 | | memory_set_bankptr(1, memory_region(machine, "user1")); |
| 474 | memory_set_bankptr(machine, 1, memory_region(machine, "user1")); |
| 475 | 475 | |
| 476 | 476 | centronics_config(0, sordm5_cent_config); |
| 477 | 477 | /* assumption: select is tied low */ |
| r3651 | r3652 | |
| 611 | 611 | |
| 612 | 612 | static INTERRUPT_GEN( sord_interrupt ) |
| 613 | 613 | { |
| 614 | | if (TMS9928A_interrupt(machine)) |
| 615 | | cpunum_set_input_line(machine, 0, 0, HOLD_LINE); |
| 614 | if (TMS9928A_interrupt(device->machine)) |
| 615 | cpu_set_input_line(device->machine->cpu[0], 0, HOLD_LINE); |
| 616 | 616 | } |
| 617 | 617 | |
| 618 | 618 | static const cassette_config sordm5_cassette_config = |