src/mess/machine/trs80.c
| r4448 | r4449 | |
| 35 | 35 | |
| 36 | 36 | static UINT8 trs80_int=0; /* interrupting devices */ |
| 37 | 37 | static UINT8 trs80_mask= 0; /* interrupt mask */ |
| 38 | static UINT8 trs80_nmi_mask= 0; /* nmi mask */ |
| 38 | 39 | static UINT8 trs80_port_ec=0; /* bit d6..d1 of port EC to be read by port FF */ |
| 40 | static UINT8 trs80_tape_unit=1; /* selected cassette unit (trs80l2 and sys80 only) (not implemented yet) */ |
| 41 | static UINT8 trs80_reg_load=1; /* Controls what port EA will do */ |
| 42 | static UINT8 trs80_nmi_data=0; /* Passes FDC int to NMI handler */ |
| 39 | 43 | UINT8 trs80_mode = 0; /* Control bits passed to video output routine */ |
| 40 | 44 | |
| 41 | 45 | #define IRQ_M1_RTC 0x80 /* RTC on Model I */ |
| r4448 | r4449 | |
| 56 | 60 | static UINT8 sector[4] = {0, }; /* current sector per drive */ |
| 57 | 61 | #endif |
| 58 | 62 | |
| 59 | | static UINT8 trs80_reg_load=1; |
| 60 | | |
| 61 | 63 | #define MODEL4_MASTER_CLOCK 20275200 |
| 62 | 64 | |
| 63 | 65 | static UINT8 cassette_data; |
| r4448 | r4449 | |
| 70 | 72 | |
| 71 | 73 | static TIMER_CALLBACK( cassette_data_callback ) |
| 72 | 74 | { |
| 75 | /* This does all baud rates. 250 baud (trs80), and 500 baud (all others) set bit 7 of "cassette_data". |
| 76 | 1500 baud (trs80m3, trs80m4) is interrupt-driven and uses bit 0 of "cassette_data" */ |
| 77 | |
| 73 | 78 | static double old_cassette_val; |
| 74 | 79 | double new_val = cassette_input(trs80_cass); |
| 75 | 80 | |
| 76 | 81 | /* Check for HI-LO transition */ |
| 77 | 82 | if ( old_cassette_val > -0.2 && new_val < -0.2 ) |
| 78 | 83 | { |
| 79 | | cassette_data |= 0x80; |
| 80 | | if (trs80_mask & CASS_FALL) |
| 84 | cassette_data |= 0x80; /* 500 baud */ |
| 85 | if (trs80_mask & CASS_FALL) /* see if 1500 baud */ |
| 81 | 86 | { |
| 82 | 87 | cassette_data = 0; |
| 83 | 88 | trs80_int |= CASS_FALL; |
| r4448 | r4449 | |
| 87 | 92 | else |
| 88 | 93 | if ( old_cassette_val < -0.2 && new_val > -0.2 ) |
| 89 | 94 | { |
| 90 | | if (trs80_mask & CASS_RISE) |
| 95 | if (trs80_mask & CASS_RISE) /* 1500 baud */ |
| 91 | 96 | { |
| 92 | 97 | cassette_data = 1; |
| 93 | 98 | trs80_int |= CASS_RISE; |
| r4448 | r4449 | |
| 176 | 181 | int dir_length; /* length of directory in sectors (aka DDGA) */ |
| 177 | 182 | int id = image_index_in_device(image); |
| 178 | 183 | |
| 179 | | if (device_load_basicdsk_floppy(image) != INIT_PASS) |
| 184 | if (device_load_basicdsk_floppy(image) != INIT_PASS) |
| 180 | 185 | return INIT_FAIL; |
| 181 | 186 | |
| 182 | | if (image_index_in_device(image) == 0) /* first floppy? */ |
| 187 | if (image_index_in_device(image) == 0) /* first floppy? */ |
| 183 | 188 | { |
| 184 | 189 | image_fseek(image, 0, SEEK_SET); |
| 185 | 190 | image_fread(image, pdrive, 2); |
| r4448 | r4449 | |
| 254 | 259 | |
| 255 | 260 | READ8_HANDLER( trs80m4_e0_r ) |
| 256 | 261 | { |
| 257 | | /* Indicates which devices are interrupting - d2..d0 are emulated |
| 262 | /* Indicates which devices are interrupting - d6..d3 not emulated. |
| 258 | 263 | Whenever an interrupt occurs, this port is immediately read |
| 259 | 264 | to find out which device requires service. Lowest-numbered |
| 260 | 265 | bit takes precedence. We take this opportunity to clear the |
| r4448 | r4449 | |
| 274 | 279 | |
| 275 | 280 | READ8_HANDLER( trs80m4_e4_r ) |
| 276 | 281 | { |
| 277 | | /* NMI status bits from the FDC - not emulated |
| 282 | /* Indicates which devices are interrupting - not emulated. |
| 283 | Whenever an NMI occurs, this port is immediately read |
| 284 | to find out which device requires service. Lowest-numbered |
| 285 | bit takes precedence. We take this opportunity to clear the |
| 286 | cpu NMI line. |
| 287 | |
| 278 | 288 | d7 status of FDC INTREQ (0=true) |
| 279 | 289 | d6 status of Motor Timeout (0=true) |
| 280 | | d5 status of Reset signal (0=true) */ |
| 290 | d5 status of Reset signal (0=true - this will reboot the computer) */ |
| 281 | 291 | |
| 282 | | return 0xff; |
| 292 | cpu_set_input_line(space->machine->cpu[0], INPUT_LINE_NMI, CLEAR_LINE); |
| 293 | |
| 294 | return ~(trs80_nmi_mask & trs80_nmi_data); |
| 295 | |
| 296 | // return 0xff; |
| 283 | 297 | } |
| 284 | 298 | |
| 285 | 299 | READ8_HANDLER( trs80m4_e8_r ) |
| 286 | 300 | { |
| 287 | | /* These bits directly read pins on the RS-232 socket, and are not emulated |
| 301 | /* not emulated |
| 288 | 302 | d7 Clear-to-Send (CTS), Pin 5 |
| 289 | 303 | d6 Data-Set-Ready (DSR), pin 6 |
| 290 | 304 | d5 Carrier Detect (CD), pin 8 |
| r4448 | r4449 | |
| 335 | 349 | |
| 336 | 350 | READ8_HANDLER( sys80_f9_r ) |
| 337 | 351 | { |
| 338 | | /* UART Status Register (d4..d6 not emulated) |
| 352 | /* UART Status Register - d6..d4 not emulated |
| 339 | 353 | d7 Transmit buffer empty (inverted) |
| 340 | 354 | d6 CTS pin |
| 341 | 355 | d5 DSR pin |
| r4448 | r4449 | |
| 372 | 386 | /* Return of cassette data stream from tape |
| 373 | 387 | d7 Low-speed data |
| 374 | 388 | d6..d1 info from write of port EC |
| 375 | | d0 High-speed data (not emulated yet) */ |
| 389 | d0 High-speed data */ |
| 376 | 390 | |
| 377 | 391 | trs80_int &= 0xfc; /* clear cassette interrupts */ |
| 378 | 392 | |
| r4448 | r4449 | |
| 382 | 396 | |
| 383 | 397 | WRITE8_HANDLER( trs80m4_84_w ) |
| 384 | 398 | { |
| 385 | | /* Hi-res graphics control (only d2,d3,d7 are emulated) |
| 399 | /* Hi-res graphics control - d6..d4,d1..d0 not emulated |
| 386 | 400 | d7 Page Control |
| 387 | 401 | d6 Fix upper memory |
| 388 | 402 | d5 Memory bit 1 |
| 389 | 403 | d4 Memory bit 0 |
| 390 | | d3 Invert Video (whole screen) |
| 404 | d3 Invert Video |
| 391 | 405 | d2 80/64 width |
| 392 | 406 | d1 Select bit 1 |
| 393 | 407 | d0 Select bit 0 */ |
| r4448 | r4449 | |
| 416 | 430 | |
| 417 | 431 | WRITE8_HANDLER( trs80m4_e4_w ) |
| 418 | 432 | { |
| 419 | | /* Disk to NMI interface (not emulated) |
| 433 | /* Disk to NMI interface - not emulated |
| 420 | 434 | d7 1=enable disk INTRQ to generate NMI |
| 421 | 435 | d6 1=enable disk Motor Timeout to generate NMI */ |
| 436 | |
| 437 | trs80_nmi_mask = data; |
| 422 | 438 | } |
| 423 | 439 | |
| 424 | 440 | WRITE8_HANDLER( trs80m4_e8_w ) |
| r4448 | r4449 | |
| 457 | 473 | { |
| 458 | 474 | if (trs80_reg_load) |
| 459 | 475 | |
| 460 | | /* bits d7..d3 are UART control; d2..d0 directly adjust levels at the RS-232 socket - we emulate UART control only |
| 476 | /* d2..d0 not emulated |
| 461 | 477 | d7 Even Parity Enable ('1'=even, '0'=odd) |
| 462 | 478 | d6='1',d5='1' for 8 bits |
| 463 | 479 | d6='0',d5='1' for 7 bits |
| r4448 | r4449 | |
| 481 | 497 | else |
| 482 | 498 | { |
| 483 | 499 | |
| 484 | | /* These directly adjust levels at the RS-232 socket - not emulated |
| 500 | /* not emulated |
| 485 | 501 | d7,d6 Not used |
| 486 | 502 | d5 Secondary Unassigned, pin 18 |
| 487 | 503 | d4 Secondary Transmit Data, pin 14 |
| r4448 | r4449 | |
| 525 | 541 | |
| 526 | 542 | WRITE8_HANDLER( trs80m4_f4_w ) |
| 527 | 543 | { |
| 528 | | /* Selection of drive and parameters - not emulated. |
| 544 | /* Selection of drive and parameters - d7..d5 not emulated. |
| 529 | 545 | A write also causes the selected drive motor to turn on for about 3 seconds. |
| 530 | 546 | When the motor turns off, the drive is deselected. |
| 531 | 547 | d7 1=MFM, 0=FM |
| r4448 | r4449 | |
| 562 | 578 | |
| 563 | 579 | WRITE8_HANDLER( sys80_f8_w ) |
| 564 | 580 | { |
| 565 | | /* These adjust levels at the socket pins - not emulated |
| 581 | /* not emulated |
| 566 | 582 | d2 reset UART (XR pin) |
| 567 | 583 | d1 DTR |
| 568 | 584 | d0 RTS */ |
| r4448 | r4449 | |
| 572 | 588 | { |
| 573 | 589 | /* not emulated |
| 574 | 590 | d4 select internal or external cassette player */ |
| 591 | |
| 592 | trs80_tape_unit = (data & 0x10) ? 2 : 1; |
| 575 | 593 | } |
| 576 | 594 | |
| 577 | 595 | WRITE8_HANDLER( lnw80_fe_w ) |
| 578 | 596 | { |
| 579 | | /* not emulated |
| 597 | /* d3..d2 not emulated |
| 580 | 598 | d3 bankswitch lower 16k between roms and hires ram |
| 581 | 599 | d2 enable colour |
| 582 | | d0 inverse video (whole screen) */ |
| 600 | d0 inverse video */ |
| 583 | 601 | |
| 584 | 602 | trs80_mode = (trs80_mode & 0xf7) | ((data & 1) ? 8 : 0); |
| 585 | 603 | } |
| r4448 | r4449 | |
| 618 | 636 | |
| 619 | 637 | INTERRUPT_GEN( trs80_rtc_interrupt ) |
| 620 | 638 | { |
| 621 | | if (trs80_mask & IRQ_M1_RTC) |
| 639 | /* This enables the processing of interrupts for the clock and the flashing cursor. |
| 640 | The OS counts one tick for each interrupt. The Model I has 40 ticks per |
| 641 | second, while the Model III/4 has 30. */ |
| 642 | |
| 643 | UINT8 system = (device->machine->gamedrv->flags >> 25) & 1; |
| 644 | |
| 645 | if (system) // Model 4 |
| 622 | 646 | { |
| 647 | if (trs80_mask & IRQ_M4_RTC) |
| 648 | { |
| 649 | trs80_int |= IRQ_M4_RTC; |
| 650 | cpu_set_input_line(device, 0, HOLD_LINE); |
| 651 | } |
| 652 | } |
| 653 | else // Model 1 |
| 654 | { |
| 623 | 655 | trs80_int |= IRQ_M1_RTC; |
| 624 | 656 | cpu_set_input_line(device, 0, HOLD_LINE); |
| 625 | 657 | } |
| 626 | 658 | } |
| 627 | 659 | |
| 628 | | INTERRUPT_GEN( trs80m4_rtc_interrupt ) |
| 660 | static void trs80_fdc_interrupt_internal(running_machine *machine) |
| 629 | 661 | { |
| 630 | | /* This enables the processing of interrupts for the clock and the flashing cursor. |
| 631 | | The OS counts one tick for each interrupt. There are 30 ticks per second. */ |
| 662 | UINT8 system = (machine->gamedrv->flags >> 25) & 1; |
| 632 | 663 | |
| 633 | | if (trs80_mask & IRQ_M4_RTC) |
| 664 | if (system) // Model 4 does a NMI |
| 634 | 665 | { |
| 635 | | trs80_int |= IRQ_M4_RTC; |
| 636 | | cpu_set_input_line(device, 0, HOLD_LINE); |
| 666 | trs80_nmi_data = 0x80; |
| 667 | // cpu_set_input_line(machine->cpu[0], INPUT_LINE_NMI, HOLD_LINE); |
| 637 | 668 | } |
| 638 | | } |
| 639 | | |
| 640 | | static void trs80_fdc_interrupt_internal(running_machine *machine) |
| 641 | | { |
| 642 | | if (trs80_mask & IRQ_M1_FDC) |
| 669 | else // Model 1 does a IRQ |
| 643 | 670 | { |
| 644 | 671 | trs80_int |= IRQ_M1_FDC; |
| 645 | 672 | cpu_set_input_line(machine->cpu[0], 0, HOLD_LINE); |
| 646 | 673 | } |
| 647 | 674 | } |
| 648 | 675 | |
| 649 | | INTERRUPT_GEN( trs80_fdc_interrupt ) |
| 676 | INTERRUPT_GEN( trs80_fdc_interrupt ) /* not used - should it be? */ |
| 650 | 677 | { |
| 651 | 678 | trs80_fdc_interrupt_internal(device->machine); |
| 652 | 679 | } |
| 653 | 680 | |
| 654 | 681 | static WD17XX_CALLBACK( trs80_fdc_callback ) |
| 655 | 682 | { |
| 683 | UINT8 system = (device->machine->gamedrv->flags >> 25) & 1; |
| 684 | |
| 656 | 685 | switch (state) |
| 657 | 686 | { |
| 658 | 687 | case WD17XX_IRQ_CLR: |
| 659 | | trs80_int &= ~IRQ_M1_FDC; |
| 688 | if (system) trs80_int &= ~IRQ_M1_FDC; |
| 660 | 689 | break; |
| 661 | 690 | case WD17XX_IRQ_SET: |
| 662 | 691 | trs80_fdc_interrupt_internal(device->machine); |
| r4448 | r4449 | |
| 700 | 729 | /* not emulated |
| 701 | 730 | 01 for unit 1 (default |
| 702 | 731 | 02 for unit 2 */ |
| 732 | |
| 733 | trs80_tape_unit = data; |
| 703 | 734 | } |
| 704 | 735 | |
| 705 | 736 | READ8_HANDLER( trs80_irq_status_r ) |
| 706 | 737 | { |
| 738 | /* (trs80l2) Whenever an interrupt occurs, 37E0 is read to see what devices require service. |
| 739 | d7 = RTC |
| 740 | d6 = FDC |
| 741 | d2 = Communications (not emulated) |
| 742 | All interrupting devices are serviced in a single interrupt. There is a mask byte, |
| 743 | which is dealt with by the DOS. We take the opportunity to reset the cpu INT line. */ |
| 744 | |
| 707 | 745 | int result = trs80_int; |
| 708 | | trs80_int &= ~(IRQ_M1_RTC | IRQ_M1_FDC); |
| 746 | cpu_set_input_line(space->machine->cpu[0], 0, CLEAR_LINE); |
| 747 | trs80_int = 0; |
| 709 | 748 | return result; |
| 710 | 749 | } |
| 711 | 750 | |
| r4448 | r4449 | |
| 734 | 773 | drive = 3; |
| 735 | 774 | head = 0; |
| 736 | 775 | break; |
| 776 | /* These 3 combinations aren't documented */ |
| 737 | 777 | case 9: |
| 738 | 778 | drive = 0; |
| 739 | 779 | head = 1; |
| r4448 | r4449 | |
| 761 | 801 | *************************************/ |
| 762 | 802 | READ8_HANDLER( trs80_keyboard_r ) |
| 763 | 803 | { |
| 764 | | int result = 0; |
| 804 | UINT8 result = 0; |
| 765 | 805 | |
| 766 | 806 | if (offset & 1) |
| 767 | 807 | result |= input_port_read(space->machine, "LINE0"); |
src/mess/drivers/trs80.c
| r4448 | r4449 | |
| 447 | 447 | MDRV_CPU_MODIFY( "maincpu" ) |
| 448 | 448 | MDRV_CPU_PROGRAM_MAP( model3_map, 0 ) |
| 449 | 449 | MDRV_CPU_IO_MAP( model3_io, 0 ) |
| 450 | | MDRV_CPU_PERIODIC_INT(trs80m4_rtc_interrupt, 30) |
| 450 | MDRV_CPU_PERIODIC_INT(trs80_rtc_interrupt, 30) |
| 451 | 451 | MDRV_VIDEO_UPDATE( trs80m4 ) |
| 452 | 452 | MDRV_SCREEN_MODIFY("screen") |
| 453 | 453 | MDRV_SCREEN_SIZE(80*FW, 240) |
| r4448 | r4449 | |
| 619 | 619 | CONFIG_DEVICE(trs8012_floppy_getinfo) |
| 620 | 620 | SYSTEM_CONFIG_END |
| 621 | 621 | |
| 622 | | |
| 622 | /* Note - "1<<24" = needs 7-bit video; "1<<25" = Uses Model 4 IRQ system */ |
| 623 | 623 | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT CONFIG COMPANY FULLNAME */ |
| 624 | 624 | COMP( 1977, trs80, 0, 0, trs80, trs80, 0, 0, "Tandy Radio Shack", "TRS-80 Model I (Level I Basic)" , 0) |
| 625 | 625 | COMP( 1978, trs80l2, trs80, 0, model1, trs80, 0, trs8012, "Tandy Radio Shack", "TRS-80 Model I (Level II Basic)" , 1<<24) |
| 626 | 626 | COMP( 1983, radionic, trs80, 0, radionic, trs80, 0, trs8012, "Komtek", "Radionic" , 0) |
| 627 | 627 | COMP( 1980, sys80, trs80, 0, sys80, trs80, 0, trs8012, "EACA Computers Ltd.","System-80" , 1<<24) |
| 628 | 628 | COMP( 1981, lnw80, trs80, 0, lnw80, trs80m3, 0, trs8012, "LNW Research","LNW-80", 0 ) |
| 629 | | COMP( 1980, trs80m3, trs80, 0, model3, trs80m3, 0, trs8012, "Tandy Radio Shack", "TRS-80 Model III", 0 ) |
| 630 | | COMP( 1980, trs80m4, trs80, 0, model3, trs80m3, 0, trs8012, "Tandy Radio Shack", "TRS-80 Model 4", 0 ) |
| 631 | | COMP( 1980, trs80m4p, trs80, 0, model3, trs80m3, 0, trs8012, "Tandy Radio Shack", "TRS-80 Model 4P", GAME_NOT_WORKING ) |
| 629 | COMP( 1980, trs80m3, trs80, 0, model3, trs80m3, 0, trs8012, "Tandy Radio Shack", "TRS-80 Model III", 1<<25 ) |
| 630 | COMP( 1980, trs80m4, trs80, 0, model3, trs80m3, 0, trs8012, "Tandy Radio Shack", "TRS-80 Model 4", 1<<25 ) |
| 631 | COMP( 1980, trs80m4p, trs80, 0, model3, trs80m3, 0, trs8012, "Tandy Radio Shack", "TRS-80 Model 4P", GAME_NOT_WORKING | 1<<25) |
| 632 | 632 | COMP( 1983, ht1080z, trs80, 0, ht1080z, trs80, 0, trs8012, "Hiradastechnika Szovetkezet", "HT-1080Z Series I" , 1<<24) |
| 633 | 633 | COMP( 1984, ht1080z2, trs80, 0, ht1080z, trs80, 0, trs8012, "Hiradastechnika Szovetkezet", "HT-1080Z Series II" , 1<<24) |
| 634 | 634 | COMP( 1985, ht108064, trs80, 0, ht1080z, trs80, 0, trs8012, "Hiradastechnika Szovetkezet", "HT-1080Z/64" , 0) |