src/mess/machine/ibmpc.c
| r2496 | r2497 | |
| 73 | 73 | */ |
| 74 | 74 | |
| 75 | 75 | |
| 76 | | /************************************************************************* |
| 77 | | * |
| 78 | | * PIO |
| 79 | | * parallel input output |
| 80 | | * |
| 81 | | *************************************************************************/ |
| 82 | | static READ8_HANDLER ( pc_ppi_porta_r ); |
| 83 | | static READ8_HANDLER ( pc_ppi_portb_r ); |
| 84 | | static READ8_HANDLER ( pc_ppi_portc_r ); |
| 85 | | static WRITE8_HANDLER ( pc_ppi_porta_w ); |
| 86 | | static WRITE8_HANDLER ( pc_ppi_portb_w ); |
| 87 | | static WRITE8_HANDLER ( pc_ppi_portc_w ); |
| 88 | | |
| 89 | | /* PC-XT has a 8255 which is connected to keyboard and other |
| 90 | | status information */ |
| 91 | | const ppi8255_interface pc_ppi8255_interface = |
| 92 | | { |
| 93 | | pc_ppi_porta_r, |
| 94 | | pc_ppi_portb_r, |
| 95 | | pc_ppi_portc_r, |
| 96 | | pc_ppi_porta_w, |
| 97 | | pc_ppi_portb_w, |
| 98 | | pc_ppi_portc_w |
| 99 | | }; |
| 100 | | |
| 101 | | static struct { |
| 102 | | int portc_switch_high; |
| 103 | | int speaker; |
| 104 | | int keyboard_disabled; |
| 105 | | UINT8 portb; |
| 106 | | } pc_ppi={ 0 }; |
| 107 | | |
| 108 | | READ8_HANDLER (pc_ppi_porta_r) |
| 109 | | { |
| 110 | | int data; |
| 111 | | |
| 112 | | /* KB port A */ |
| 113 | | if (pc_ppi.keyboard_disabled) |
| 114 | | { |
| 115 | | /* 0 0 - no floppy drives |
| 116 | | * 1 Not used |
| 117 | | * 2-3 The number of memory banks on the system board |
| 118 | | * 4-5 Display mode |
| 119 | | * 11 = monochrome |
| 120 | | * 10 - color 80x25 |
| 121 | | * 01 - color 40x25 |
| 122 | | * 6-7 The number of floppy disk drives |
| 123 | | */ |
| 124 | | data = input_port_read_indexed(machine, 1); |
| 125 | | } |
| 126 | | else |
| 127 | | { |
| 128 | | data = pc_keyb_read(); |
| 129 | | } |
| 130 | | PIO_LOG(1,"PIO_A_r",("$%02x\n", data)); |
| 131 | | return data; |
| 132 | | } |
| 133 | | |
| 134 | | READ8_HANDLER (pc_ppi_portb_r ) |
| 135 | | { |
| 136 | | int data; |
| 137 | | |
| 138 | | data = 0xff; |
| 139 | | PIO_LOG(1,"PIO_B_r",("$%02x\n", data)); |
| 140 | | return data; |
| 141 | | } |
| 142 | | |
| 143 | | READ8_HANDLER ( pc_ppi_portc_r ) |
| 144 | | { |
| 145 | | int timer2_output = pit8253_get_output( device_list_find_by_tag( machine->config->devicelist, PIT8253, "pit8253" ), 2 ); |
| 146 | | int data=0xff; |
| 147 | | |
| 148 | | data&=~0x80; // no parity error |
| 149 | | data&=~0x40; // no error on expansion board |
| 150 | | /* KB port C: equipment flags */ |
| 151 | | // if (pc_port[0x61] & 0x08) |
| 152 | | if (pc_ppi.portc_switch_high) |
| 153 | | { |
| 154 | | /* read hi nibble of S2 */ |
| 155 | | data = (data&0xf0)|((input_port_read_indexed(machine, 1) >> 4) & 0x0f); |
| 156 | | PIO_LOG(1,"PIO_C_r (hi)",("$%02x\n", data)); |
| 157 | | } |
| 158 | | else |
| 159 | | { |
| 160 | | /* read lo nibble of S2 */ |
| 161 | | data = (data&0xf0)|(input_port_read_indexed(machine, 1) & 0x0f); |
| 162 | | PIO_LOG(1,"PIO_C_r (lo)",("$%02x\n", data)); |
| 163 | | } |
| 164 | | |
| 165 | | if ( ! ( pc_ppi.portb & 0x08 ) ) { |
| 166 | | double tap_val = cassette_input( image_from_devtype_and_index( IO_CASSETTE, 0 ) ); |
| 167 | | |
| 168 | | if ( tap_val < 0 ) { |
| 169 | | data &= ~0x10; |
| 170 | | } else { |
| 171 | | data |= 0x10; |
| 172 | | } |
| 173 | | } else { |
| 174 | | if ( pc_ppi.portb & 0x01 ) { |
| 175 | | data = ( data & ~0x10 ) | ( timer2_output ? 0x10 : 0x00 ); |
| 176 | | } |
| 177 | | } |
| 178 | | data = ( data & ~0x20 ) | ( timer2_output ? 0x20 : 0x00 ); |
| 179 | | |
| 180 | | return data; |
| 181 | | } |
| 182 | | |
| 183 | | WRITE8_HANDLER ( pc_ppi_porta_w ) |
| 184 | | { |
| 185 | | /* KB controller port A */ |
| 186 | | PIO_LOG(1,"PIO_A_w",("$%02x\n", data)); |
| 187 | | } |
| 188 | | |
| 189 | | WRITE8_HANDLER ( pc_ppi_portb_w ) |
| 190 | | { |
| 191 | | /* KB controller port B */ |
| 192 | | pc_ppi.portb = data; |
| 193 | | pc_ppi.portc_switch_high = data & 0x08; |
| 194 | | pc_ppi.keyboard_disabled = data & 0x80; |
| 195 | | pit8253_gate_w( device_list_find_by_tag( machine->config->devicelist, PIT8253, "pit8253" ), 2, data & 1); |
| 196 | | pc_sh_speaker(machine, data & 0x03); |
| 197 | | pc_keyb_set_clock(data & 0x40); |
| 198 | | |
| 199 | | cassette_change_state( image_from_devtype_and_index( IO_CASSETTE, 0 ), ( data & 0x08 ) ? CASSETTE_MOTOR_DISABLED : CASSETTE_MOTOR_ENABLED, CASSETTE_MASK_MOTOR); |
| 200 | | |
| 201 | | if (data & 0x80) |
| 202 | | pc_keyb_clear(); |
| 203 | | } |
| 204 | | |
| 205 | | WRITE8_HANDLER ( pc_ppi_portc_w ) |
| 206 | | { |
| 207 | | /* KB controller port C */ |
| 208 | | PIO_LOG(1,"PIO_C_w",("$%02x\n", data)); |
| 209 | | } |
| 210 | | |
| 211 | 76 | // damned old checkit doesn't test at standard adresses |
| 212 | 77 | // will do more when I have a program supporting it |
| 213 | 78 | static struct { |
src/mess/machine/pc.c
| r2496 | r2497 | |
| 43 | 43 | #include "includes/europc.h" |
| 44 | 44 | #include "includes/ibmpc.h" |
| 45 | 45 | #include "machine/pcshare.h" |
| 46 | #include "devices/cassette.h" |
| 46 | 47 | #include "audio/pc.h" |
| 47 | 48 | |
| 48 | 49 | #include "machine/8237dma.h" |
| 49 | 50 | |
| 50 | 51 | |
| 52 | #define VERBOSE_PIO 0 /* PIO (keyboard controller) */ |
| 53 | |
| 54 | #define PIO_LOG(N,M,A) \ |
| 55 | if(VERBOSE_PIO>=N){ if( M )logerror("%11.6f: %-24s",attotime_to_double(timer_get_time()),(char*)M ); logerror A; } |
| 56 | |
| 51 | 57 | static struct { |
| 52 | 58 | const device_config *pic8259_master; |
| 53 | 59 | const device_config *pic8259_slave; |
| r2496 | r2497 | |
| 72 | 78 | |
| 73 | 79 | WRITE8_HANDLER(pc_page_w) |
| 74 | 80 | { |
| 75 | | switch(offset % 4) { |
| 81 | switch(offset % 4) |
| 82 | { |
| 76 | 83 | case 1: |
| 77 | 84 | dma_offset[0][2] = data; |
| 78 | 85 | break; |
| r2496 | r2497 | |
| 111 | 118 | } |
| 112 | 119 | |
| 113 | 120 | |
| 114 | | static DMA8237_CHANNEL_READ( pc_dma8237_fdc_dack_r ) { |
| 121 | static DMA8237_CHANNEL_READ( pc_dma8237_fdc_dack_r ) |
| 122 | { |
| 115 | 123 | return pc_fdc_dack_r(); |
| 116 | 124 | } |
| 117 | 125 | |
| 118 | 126 | |
| 119 | | static DMA8237_CHANNEL_READ( pc_dma8237_hdc_dack_r ) { |
| 127 | static DMA8237_CHANNEL_READ( pc_dma8237_hdc_dack_r ) |
| 128 | { |
| 120 | 129 | return pc_hdc_dack_r(); |
| 121 | 130 | } |
| 122 | 131 | |
| 123 | 132 | |
| 124 | | static DMA8237_CHANNEL_WRITE( pc_dma8237_fdc_dack_w ) { |
| 133 | static DMA8237_CHANNEL_WRITE( pc_dma8237_fdc_dack_w ) |
| 134 | { |
| 125 | 135 | pc_fdc_dack_w( data ); |
| 126 | 136 | } |
| 127 | 137 | |
| 128 | 138 | |
| 129 | | static DMA8237_CHANNEL_WRITE( pc_dma8237_hdc_dack_w ) { |
| 139 | static DMA8237_CHANNEL_WRITE( pc_dma8237_hdc_dack_w ) |
| 140 | { |
| 130 | 141 | pc_hdc_dack_w( data ); |
| 131 | 142 | } |
| 132 | 143 | |
| 133 | 144 | |
| 134 | | static DMA8237_OUT_EOP( pc_dma8237_out_eop ) { |
| 145 | static DMA8237_OUT_EOP( pc_dma8237_out_eop ) |
| 146 | { |
| 135 | 147 | pc_fdc_set_tc_state( state ); |
| 136 | 148 | } |
| 137 | 149 | |
| r2496 | r2497 | |
| 158 | 170 | |
| 159 | 171 | static emu_timer *pc_int_delay_timer; |
| 160 | 172 | |
| 161 | | static TIMER_CALLBACK( pc_delayed_pic8259_irq ) { |
| 173 | static TIMER_CALLBACK( pc_delayed_pic8259_irq ) |
| 174 | { |
| 162 | 175 | cpunum_set_input_line(pc_devices.pic8259_master->machine, 0, 0, param ? HOLD_LINE : CLEAR_LINE); |
| 163 | 176 | } |
| 164 | 177 | |
| 165 | | static PIC8259_SET_INT_LINE( pc_pic8259_master_set_int_line ) { |
| 178 | static PIC8259_SET_INT_LINE( pc_pic8259_master_set_int_line ) |
| 179 | { |
| 166 | 180 | timer_adjust_oneshot( pc_int_delay_timer, ATTOTIME_IN_CYCLES(1,0), interrupt ); |
| 167 | 181 | // cpunum_set_input_line(device->machine, 0, 0, interrupt ? HOLD_LINE : CLEAR_LINE); |
| 168 | 182 | } |
| 169 | 183 | |
| 170 | 184 | |
| 171 | | static PIC8259_SET_INT_LINE( pc_pic8259_slave_set_int_line ) { |
| 185 | static PIC8259_SET_INT_LINE( pc_pic8259_slave_set_int_line ) |
| 186 | { |
| 172 | 187 | pic8259_set_irq_line( pc_devices.pic8259_master, 2, interrupt); |
| 173 | 188 | } |
| 174 | 189 | |
| 175 | 190 | |
| 176 | | const struct pic8259_interface pc_pic8259_master_config = { |
| 191 | const struct pic8259_interface pc_pic8259_master_config = |
| 192 | { |
| 177 | 193 | pc_pic8259_master_set_int_line |
| 178 | 194 | }; |
| 179 | 195 | |
| 180 | 196 | |
| 181 | | const struct pic8259_interface pc_pic8259_slave_config = { |
| 197 | const struct pic8259_interface pc_pic8259_slave_config = |
| 198 | { |
| 182 | 199 | pc_pic8259_slave_set_int_line |
| 183 | 200 | }; |
| 184 | 201 | |
| r2496 | r2497 | |
| 312 | 329 | * |
| 313 | 330 | **********************************************************/ |
| 314 | 331 | |
| 315 | | static const PC_LPT_CONFIG lpt_config[3]={ |
| 332 | static const PC_LPT_CONFIG lpt_config[3]= |
| 333 | { |
| 316 | 334 | { |
| 317 | 335 | 1, |
| 318 | 336 | LPT_UNIDIRECTIONAL, |
| r2496 | r2497 | |
| 330 | 348 | } |
| 331 | 349 | }; |
| 332 | 350 | |
| 333 | | static const CENTRONICS_CONFIG cent_config[3]={ |
| 351 | static const CENTRONICS_CONFIG cent_config[3]= |
| 352 | { |
| 334 | 353 | { |
| 335 | 354 | PRINTER_IBM, |
| 336 | 355 | pc_lpt_handshake_in |
| r2496 | r2497 | |
| 355 | 374 | |
| 356 | 375 | static UINT8 nmi_enabled; |
| 357 | 376 | |
| 358 | | WRITE8_HANDLER( pc_nmi_enable_w ) { |
| 377 | WRITE8_HANDLER( pc_nmi_enable_w ) |
| 378 | { |
| 359 | 379 | logerror( "%08X: changing NMI state to %s\n", activecpu_get_pc(), data & 0x80 ? "enabled" : "disabled" ); |
| 360 | 380 | |
| 361 | 381 | nmi_enabled = data & 0x80; |
| 362 | 382 | } |
| 363 | 383 | |
| 384 | /************************************************************* |
| 385 | * |
| 386 | * NMI handling and |
| 387 | * PCJR raw keybaord handling |
| 388 | * |
| 389 | *************************************************************/ |
| 390 | |
| 391 | static struct { |
| 392 | UINT8 transferring; |
| 393 | UINT8 latch; |
| 394 | UINT32 raw_keyb_data; |
| 395 | int signal_count; |
| 396 | emu_timer *keyb_signal_timer; |
| 397 | } pcjr_keyb; |
| 398 | |
| 399 | |
| 400 | READ8_HANDLER( pcjr_nmi_enable_r ) |
| 401 | { |
| 402 | pcjr_keyb.latch = 0; |
| 403 | |
| 404 | return nmi_enabled; |
| 405 | } |
| 406 | |
| 407 | |
| 408 | static TIMER_CALLBACK( pcjr_keyb_signal_callback ) |
| 409 | { |
| 410 | pcjr_keyb.raw_keyb_data = pcjr_keyb.raw_keyb_data >> 1; |
| 411 | pcjr_keyb.signal_count--; |
| 412 | |
| 413 | if ( pcjr_keyb.signal_count <= 0 ) |
| 414 | { |
| 415 | timer_adjust_periodic( pcjr_keyb.keyb_signal_timer, attotime_never, 0, attotime_never ); |
| 416 | pcjr_keyb.transferring = 0; |
| 417 | } |
| 418 | } |
| 419 | |
| 420 | |
| 421 | static void pcjr_set_keyb_int(int state) |
| 422 | { |
| 423 | if ( state ) |
| 424 | { |
| 425 | UINT8 data = pc_keyb_read(); |
| 426 | UINT8 parity = 0; |
| 427 | int i; |
| 428 | |
| 429 | /* Calculate the raw data */ |
| 430 | for( i = 0; i < 8; i++ ) |
| 431 | { |
| 432 | if ( ( 1 << i ) & data ) |
| 433 | { |
| 434 | parity ^= 1; |
| 435 | } |
| 436 | } |
| 437 | pcjr_keyb.raw_keyb_data = 0; |
| 438 | pcjr_keyb.raw_keyb_data = ( pcjr_keyb.raw_keyb_data << 2 ) | ( parity ? 1 : 2 ); |
| 439 | for( i = 0; i < 8; i++ ) |
| 440 | { |
| 441 | pcjr_keyb.raw_keyb_data = ( pcjr_keyb.raw_keyb_data << 2 ) | ( ( data & 0x80 ) ? 1 : 2 ); |
| 442 | data <<= 1; |
| 443 | } |
| 444 | /* Insert start bit */ |
| 445 | pcjr_keyb.raw_keyb_data = ( pcjr_keyb.raw_keyb_data << 2 ) | 1; |
| 446 | pcjr_keyb.signal_count = 20 + 22; |
| 447 | |
| 448 | /* we are now transferring a byte of keyboard data */ |
| 449 | pcjr_keyb.transferring = 1; |
| 450 | |
| 451 | /* Set timer */ |
| 452 | timer_adjust_periodic( pcjr_keyb.keyb_signal_timer, ATTOTIME_IN_USEC(220), 0, ATTOTIME_IN_USEC(220) ); |
| 453 | |
| 454 | /* Trigger NMI */ |
| 455 | if ( ! pcjr_keyb.latch ) |
| 456 | { |
| 457 | pcjr_keyb.latch = 1; |
| 458 | if ( nmi_enabled & 0x80 ) |
| 459 | { |
| 460 | cpunum_set_input_line( Machine, 0, INPUT_LINE_NMI, PULSE_LINE ); |
| 461 | } |
| 462 | } |
| 463 | } |
| 464 | } |
| 465 | |
| 466 | |
| 467 | static void pcjr_keyb_init(void) |
| 468 | { |
| 469 | pcjr_keyb.transferring = 0; |
| 470 | pcjr_keyb.latch = 0; |
| 471 | pcjr_keyb.raw_keyb_data = 0; |
| 472 | pcjr_keyb.keyb_signal_timer = timer_alloc( pcjr_keyb_signal_callback, NULL ); |
| 473 | pc_keyb_set_clock( 1 ); |
| 474 | } |
| 475 | |
| 476 | |
| 477 | |
| 364 | 478 | /********************************************************** |
| 365 | 479 | * |
| 480 | * PPI8255 interface |
| 481 | * |
| 482 | **********************************************************/ |
| 483 | |
| 484 | static struct { |
| 485 | int portc_switch_high; |
| 486 | int speaker; |
| 487 | int keyboard_disabled; |
| 488 | UINT8 portb; |
| 489 | } pc_ppi={ 0 }; |
| 490 | |
| 491 | |
| 492 | static READ8_HANDLER (pc_ppi_porta_r) |
| 493 | { |
| 494 | int data; |
| 495 | |
| 496 | /* KB port A */ |
| 497 | if (pc_ppi.keyboard_disabled) |
| 498 | { |
| 499 | /* 0 0 - no floppy drives |
| 500 | * 1 Not used |
| 501 | * 2-3 The number of memory banks on the system board |
| 502 | * 4-5 Display mode |
| 503 | * 11 = monochrome |
| 504 | * 10 - color 80x25 |
| 505 | * 01 - color 40x25 |
| 506 | * 6-7 The number of floppy disk drives |
| 507 | */ |
| 508 | data = input_port_read_indexed(machine, 1); |
| 509 | } |
| 510 | else |
| 511 | { |
| 512 | data = pc_keyb_read(); |
| 513 | } |
| 514 | PIO_LOG(1,"PIO_A_r",("$%02x\n", data)); |
| 515 | return data; |
| 516 | } |
| 517 | |
| 518 | |
| 519 | static READ8_HANDLER (pc_ppi_portb_r ) |
| 520 | { |
| 521 | int data; |
| 522 | |
| 523 | data = 0xff; |
| 524 | PIO_LOG(1,"PIO_B_r",("$%02x\n", data)); |
| 525 | return data; |
| 526 | } |
| 527 | |
| 528 | |
| 529 | static READ8_HANDLER ( pc_ppi_portc_r ) |
| 530 | { |
| 531 | int timer2_output = pit8253_get_output( device_list_find_by_tag( machine->config->devicelist, PIT8253, "pit8253" ), 2 ); |
| 532 | int data=0xff; |
| 533 | |
| 534 | data&=~0x80; // no parity error |
| 535 | data&=~0x40; // no error on expansion board |
| 536 | /* KB port C: equipment flags */ |
| 537 | // if (pc_port[0x61] & 0x08) |
| 538 | if (pc_ppi.portc_switch_high) |
| 539 | { |
| 540 | /* read hi nibble of S2 */ |
| 541 | data = (data&0xf0)|((input_port_read_indexed(machine, 1) >> 4) & 0x0f); |
| 542 | PIO_LOG(1,"PIO_C_r (hi)",("$%02x\n", data)); |
| 543 | } |
| 544 | else |
| 545 | { |
| 546 | /* read lo nibble of S2 */ |
| 547 | data = (data&0xf0)|(input_port_read_indexed(machine, 1) & 0x0f); |
| 548 | PIO_LOG(1,"PIO_C_r (lo)",("$%02x\n", data)); |
| 549 | } |
| 550 | |
| 551 | if ( ! ( pc_ppi.portb & 0x08 ) ) |
| 552 | { |
| 553 | double tap_val = cassette_input( image_from_devtype_and_index( IO_CASSETTE, 0 ) ); |
| 554 | |
| 555 | if ( tap_val < 0 ) |
| 556 | { |
| 557 | data &= ~0x10; |
| 558 | } |
| 559 | else |
| 560 | { |
| 561 | data |= 0x10; |
| 562 | } |
| 563 | } |
| 564 | else |
| 565 | { |
| 566 | if ( pc_ppi.portb & 0x01 ) |
| 567 | { |
| 568 | data = ( data & ~0x10 ) | ( timer2_output ? 0x10 : 0x00 ); |
| 569 | } |
| 570 | } |
| 571 | data = ( data & ~0x20 ) | ( timer2_output ? 0x20 : 0x00 ); |
| 572 | |
| 573 | return data; |
| 574 | } |
| 575 | |
| 576 | |
| 577 | static WRITE8_HANDLER ( pc_ppi_porta_w ) |
| 578 | { |
| 579 | /* KB controller port A */ |
| 580 | PIO_LOG(1,"PIO_A_w",("$%02x\n", data)); |
| 581 | } |
| 582 | |
| 583 | |
| 584 | static WRITE8_HANDLER ( pc_ppi_portb_w ) |
| 585 | { |
| 586 | /* KB controller port B */ |
| 587 | pc_ppi.portb = data; |
| 588 | pc_ppi.portc_switch_high = data & 0x08; |
| 589 | pc_ppi.keyboard_disabled = data & 0x80; |
| 590 | pit8253_gate_w( device_list_find_by_tag( machine->config->devicelist, PIT8253, "pit8253" ), 2, data & 1); |
| 591 | pc_sh_speaker(machine, data & 0x03); |
| 592 | pc_keyb_set_clock(data & 0x40); |
| 593 | |
| 594 | cassette_change_state( image_from_devtype_and_index( IO_CASSETTE, 0 ), ( data & 0x08 ) ? CASSETTE_MOTOR_DISABLED : CASSETTE_MOTOR_ENABLED, CASSETTE_MASK_MOTOR); |
| 595 | |
| 596 | if (data & 0x80) |
| 597 | pc_keyb_clear(); |
| 598 | } |
| 599 | |
| 600 | |
| 601 | static WRITE8_HANDLER ( pc_ppi_portc_w ) |
| 602 | { |
| 603 | /* KB controller port C */ |
| 604 | PIO_LOG(1,"PIO_C_w",("$%02x\n", data)); |
| 605 | } |
| 606 | |
| 607 | |
| 608 | /* PC-XT has a 8255 which is connected to keyboard and other |
| 609 | status information */ |
| 610 | const ppi8255_interface pc_ppi8255_interface = |
| 611 | { |
| 612 | pc_ppi_porta_r, |
| 613 | pc_ppi_portb_r, |
| 614 | pc_ppi_portc_r, |
| 615 | pc_ppi_porta_w, |
| 616 | pc_ppi_portb_w, |
| 617 | pc_ppi_portc_w |
| 618 | }; |
| 619 | |
| 620 | |
| 621 | static WRITE8_HANDLER ( pcjr_ppi_portb_w ) |
| 622 | { |
| 623 | /* KB controller port B */ |
| 624 | pc_ppi.portb = data; |
| 625 | pc_ppi.portc_switch_high = data & 0x08; |
| 626 | pit8253_gate_w( device_list_find_by_tag( machine->config->devicelist, PIT8253, "pit8253" ), 2, data & 1); |
| 627 | pc_sh_speaker(machine, data & 0x03); |
| 628 | |
| 629 | cassette_change_state( image_from_devtype_and_index( IO_CASSETTE, 0 ), ( data & 0x08 ) ? CASSETTE_MOTOR_DISABLED : CASSETTE_MOTOR_ENABLED, CASSETTE_MASK_MOTOR); |
| 630 | } |
| 631 | |
| 632 | |
| 633 | /* |
| 634 | * On a PCJR none of the port A bits are connected. |
| 635 | */ |
| 636 | static READ8_HANDLER (pcjr_ppi_porta_r ) |
| 637 | { |
| 638 | int data; |
| 639 | |
| 640 | data = 0xff; |
| 641 | PIO_LOG(1,"PIO_A_r",("$%02x\n", data)); |
| 642 | return data; |
| 643 | } |
| 644 | |
| 645 | |
| 646 | /* |
| 647 | * Port C connections on a PCJR (notes from schematics): |
| 648 | * PC0 - KYBD LATCH |
| 649 | * PC1 - MODEM CD INSTALLED |
| 650 | * PC2 - DISKETTE CD INSTALLED |
| 651 | * PC3 - ATR CD IN |
| 652 | * PC4 - cassette audio |
| 653 | * PC5 - OUT2 from 8253 |
| 654 | * PC6 - KYBD IN |
| 655 | * PC7 - (keyboard) CABLE CONNECTED |
| 656 | */ |
| 657 | static READ8_HANDLER ( pcjr_ppi_portc_r ) |
| 658 | { |
| 659 | int timer2_output = pit8253_get_output( device_list_find_by_tag( machine->config->devicelist, PIT8253, "pit8253" ), 2 ); |
| 660 | int data=0xff; |
| 661 | |
| 662 | data&=~0x80; |
| 663 | data = ( data & ~0x01 ) | ( pcjr_keyb.latch ? 0x01: 0x00 ); |
| 664 | if ( ! ( pc_ppi.portb & 0x08 ) ) |
| 665 | { |
| 666 | double tap_val = cassette_input( image_from_devtype_and_index( IO_CASSETTE, 0 ) ); |
| 667 | |
| 668 | if ( tap_val < 0 ) |
| 669 | { |
| 670 | data &= ~0x10; |
| 671 | } |
| 672 | else |
| 673 | { |
| 674 | data |= 0x10; |
| 675 | } |
| 676 | } |
| 677 | else |
| 678 | { |
| 679 | if ( pc_ppi.portb & 0x01 ) |
| 680 | { |
| 681 | data = ( data & ~0x10 ) | ( timer2_output ? 0x10 : 0x00 ); |
| 682 | } |
| 683 | } |
| 684 | data = ( data & ~0x20 ) | ( timer2_output ? 0x20 : 0x00 ); |
| 685 | data = ( data & ~0x40 ) | ( ( pcjr_keyb.raw_keyb_data & 0x01 ) ? 0x40 : 0x00 ); |
| 686 | |
| 687 | return data; |
| 688 | } |
| 689 | |
| 690 | |
| 691 | const ppi8255_interface pcjr_ppi8255_interface = |
| 692 | { |
| 693 | pcjr_ppi_porta_r, |
| 694 | pc_ppi_portb_r, |
| 695 | pcjr_ppi_portc_r, |
| 696 | pc_ppi_porta_w, |
| 697 | pcjr_ppi_portb_w, |
| 698 | pc_ppi_portc_w |
| 699 | }; |
| 700 | |
| 701 | |
| 702 | /********************************************************** |
| 703 | * |
| 366 | 704 | * NEC uPD765 floppy interface |
| 367 | 705 | * |
| 368 | 706 | **********************************************************/ |
| r2496 | r2497 | |
| 470 | 808 | |
| 471 | 809 | DRIVER_INIT( t1000hx ) |
| 472 | 810 | { |
| 473 | | UINT8 *gfx = &memory_region(REGION_GFX1)[0x1000]; |
| 474 | | int i; |
| 475 | | /* just a plain bit pattern for graphics data generation */ |
| 476 | | for (i = 0; i < 256; i++) |
| 477 | | gfx[i] = i; |
| 478 | 811 | mess_init_pc_common(PCCOMMON_KEYBOARD_PC, pc_set_keyb_int, pc_set_irq_line); |
| 479 | 812 | pc_turbo_setup(0, 3, 0x02, 4.77/12, 1); |
| 480 | 813 | } |
| r2496 | r2497 | |
| 520 | 853 | } |
| 521 | 854 | |
| 522 | 855 | |
| 856 | DRIVER_INIT( pcjr ) |
| 857 | { |
| 858 | mess_init_pc_common(PCCOMMON_KEYBOARD_PC, pcjr_set_keyb_int, pc_set_irq_line); |
| 859 | } |
| 523 | 860 | |
| 861 | |
| 862 | |
| 524 | 863 | static void pc_map_vga_memory(offs_t begin, offs_t end, read8_machine_func rh, write8_machine_func wh) |
| 525 | 864 | { |
| 526 | 865 | int buswidth; |
| r2496 | r2497 | |
| 596 | 935 | } |
| 597 | 936 | |
| 598 | 937 | |
| 599 | | MACHINE_START( pc ) { |
| 938 | MACHINE_START( pc ) |
| 939 | { |
| 600 | 940 | pc_fdc_init( &fdc_interface_nc ); |
| 601 | 941 | } |
| 602 | 942 | |
| r2496 | r2497 | |
| 615 | 955 | } |
| 616 | 956 | |
| 617 | 957 | |
| 958 | MACHINE_RESET( pcjr ) |
| 959 | { |
| 960 | MACHINE_RESET_CALL( pc ); |
| 961 | pcjr_keyb_init(); |
| 962 | } |
| 963 | |
| 964 | |
| 618 | 965 | /************************************************************************** |
| 619 | 966 | * |
| 620 | 967 | * Interrupt handlers. |
| r2496 | r2497 | |
| 634 | 981 | |
| 635 | 982 | INTERRUPT_GEN( pcjr_frame_interrupt ) |
| 636 | 983 | { |
| 637 | | pc_keyboard(); |
| 984 | if ( pcjr_keyb.transferring == 0 ) |
| 985 | { |
| 986 | pc_keyboard(); |
| 987 | } |
| 638 | 988 | } |
| 639 | 989 | |
src/mess/drivers/pc.c
| r2496 | r2497 | |
| 297 | 297 | AM_RANGE(0x0040, 0x0043) AM_DEVREADWRITE(PIT8253, "pit8253", pit8253_r, pit8253_w) |
| 298 | 298 | AM_RANGE(0x0060, 0x0063) AM_DEVREADWRITE(PPI8255, "ppi8255", ppi8255_r, ppi8255_w) |
| 299 | 299 | AM_RANGE(0x0080, 0x0087) AM_READWRITE(pc_page_r, pc_page_w) |
| 300 | | AM_RANGE(0x00a0, 0x00a0) AM_WRITE( pc_nmi_enable_w ) |
| 300 | AM_RANGE(0x00a0, 0x00a0) AM_READWRITE( pcjr_nmi_enable_r, pc_nmi_enable_w ) |
| 301 | 301 | AM_RANGE(0x00c0, 0x00c0) AM_WRITE( SN76496_0_w) |
| 302 | 302 | AM_RANGE(0x00f0, 0x00f7) AM_READWRITE(pc_fdc_r, pcjr_fdc_w) |
| 303 | 303 | AM_RANGE(0x0200, 0x0207) AM_READWRITE(pc_JOY_r, pc_JOY_w) |
| r2496 | r2497 | |
| 1734 | 1734 | MDRV_CPU_PC(tandy1000, ibmpcjr, I8088, 4900000, pcjr_frame_interrupt) /* TODO: Get correct cpu frequency, probably XTAL_14_31818MHz/3 */ |
| 1735 | 1735 | |
| 1736 | 1736 | MDRV_MACHINE_START(pc) |
| 1737 | | MDRV_MACHINE_RESET(pc) |
| 1737 | MDRV_MACHINE_RESET(pcjr) |
| 1738 | 1738 | |
| 1739 | 1739 | MDRV_DEVICE_ADD( "pit8253", PIT8253 ) |
| 1740 | 1740 | MDRV_DEVICE_CONFIG( pcjr_pit8253_config ) |
| r2496 | r2497 | |
| 1749 | 1749 | MDRV_DEVICE_CONFIG( pc_pic8259_slave_config ) |
| 1750 | 1750 | |
| 1751 | 1751 | MDRV_DEVICE_ADD( "ppi8255", PPI8255 ) |
| 1752 | | MDRV_DEVICE_CONFIG( pc_ppi8255_interface ) |
| 1752 | MDRV_DEVICE_CONFIG( pcjr_ppi8255_interface ) |
| 1753 | 1753 | |
| 1754 | 1754 | MDRV_DEVICE_ADD( "ins8250_0", INS8250 ) /* TODO: Verify model */ |
| 1755 | 1755 | MDRV_DEVICE_CONFIG( ibmpc_com_interface[0] ) |
| r2496 | r2497 | |
| 2223 | 2223 | COMP( 1988, europc, ibm5150, 0, europc, europc, europc, ibmpc, "Schneider Rdf. AG", "EURO PC", 0) |
| 2224 | 2224 | |
| 2225 | 2225 | // pcjr (better graphics, better sound) |
| 2226 | | COMP( 1983, ibmpcjr, ibm5150, 0, ibmpcjr, tandy1t, t1000hx, ibmpc, "International Business Machines", "IBM PC Jr", GAME_NOT_WORKING|GAME_IMPERFECT_COLORS ) |
| 2226 | COMP( 1983, ibmpcjr, ibm5150, 0, ibmpcjr, tandy1t, pcjr, ibmpc, "International Business Machines", "IBM PC Jr", GAME_NOT_WORKING|GAME_IMPERFECT_COLORS ) |
| 2227 | 2227 | COMP( 1987, t1000hx, ibm5150, 0, t1000hx, tandy1t, t1000hx, ibmpc, "Tandy Radio Shack", "Tandy 1000HX", 0) |
| 2228 | 2228 | COMP( 1987, t1000sx, ibm5150, 0, t1000hx, tandy1t, t1000hx, ibmpc, "Tandy Radio Shack", "Tandy 1000SX", 0) |
| 2229 | 2229 | |