src/mess/machine/ti99_4x.c
| r8296 | r8297 | |
| 88 | 88 | static void ti99_4p_mapper_init(running_machine *machine); |
| 89 | 89 | static void ti99_myarcxram_init(running_machine *machine); |
| 90 | 90 | static void ti99_evpc_reset(running_machine *machine); |
| 91 | static void ti99_evpc_load_novram(running_machine *machine, const char *filename); |
| 92 | static void ti99_evpc_save_novram(running_machine *machine, const char *filename); |
| 91 | 93 | |
| 92 | 94 | /* |
| 93 | 95 | pointer to extended RAM area |
| r8296 | r8297 | |
| 242 | 244 | /* Used to cache the switch settings. */ |
| 243 | 245 | static UINT8 gk_switch[8]; |
| 244 | 246 | |
| 245 | | /* true if 99/4p rom6 is enabled */ |
| 246 | | static int ti99_4p_internal_rom6_enable; |
| 247 | | /* pointer to the ROM6 data */ |
| 248 | | static UINT16 *ti99_4p_internal_ROM6; |
| 247 | /* DIP switches of EVPC */ |
| 248 | static UINT8 evpc_switch[4]; |
| 249 | 249 | |
| 250 | 250 | /* Pointer to the cartridge system for the 99/8 */ |
| 251 | 251 | static running_device *multicart8; |
| r8296 | r8297 | |
| 333 | 333 | create_grom_high2k(0x0000, 0x5fff); |
| 334 | 334 | } |
| 335 | 335 | |
| 336 | | DRIVER_INIT( ti99_8 ) |
| 337 | | { |
| 338 | | UINT8 *mem = memory_region(machine, "maincpu"); |
| 339 | | ti99_model = model_99_8; |
| 340 | | has_evpc = FALSE; |
| 341 | | |
| 342 | | /* set up memory pointers */ |
| 343 | | xRAM_ptr_8 = mem + offset_xram_8; |
| 344 | | ROM0_ptr_8 = mem + offset_rom0_8; |
| 345 | | ROM1_ptr_8 = ROM0_ptr_8 + 0x2000; |
| 346 | | ROM2_ptr_8 = ROM1_ptr_8 + 0x2000; |
| 347 | | ROM3_ptr_8 = ROM2_ptr_8 + 0x2000; |
| 348 | | sRAM_ptr_8 = mem + offset_sram_8; |
| 349 | | |
| 350 | | /* Pull this one up here. */ |
| 351 | | ti99_8_enable_rom_and_ports = 1; |
| 352 | | |
| 353 | | console_GROMs.data_ptr = memory_region(machine, region_grom); |
| 354 | | create_grom_high2k(0x0000, 0x5fff); |
| 355 | | |
| 356 | | multicart8 = devtag_get_device(machine, "ti99_multicart"); |
| 357 | | assert (multicart8 != NULL); |
| 358 | | } |
| 359 | | |
| 360 | | DRIVER_INIT( ti99_4p ) |
| 361 | | { |
| 362 | | ti99_model = model_99_4p; |
| 363 | | has_evpc = TRUE; |
| 364 | | |
| 365 | | /* set up memory pointers */ |
| 366 | | xRAM_ptr = (UINT16 *) (memory_region(machine, "maincpu") + offset_xram_4p); |
| 367 | | #if 0 |
| 368 | | console_GROMs.data_ptr = memory_region(machine, region_grom); |
| 369 | | create_grom_high2k(0x0000, 0x5fff); |
| 370 | | #endif |
| 371 | | } |
| 372 | | |
| 373 | 336 | static const TMS9928a_interface tms9918_interface = |
| 374 | 337 | { |
| 375 | 338 | TMS99x8, |
| r8296 | r8297 | |
| 406 | 369 | |
| 407 | 370 | MACHINE_START( ti99_4a_60hz ) |
| 408 | 371 | { |
| 409 | | ti99_common_init(machine, &tms9918a_interface); |
| 372 | ti99_common_init(machine, &tms9918a_interface); |
| 410 | 373 | } |
| 411 | 374 | |
| 412 | 375 | static const TMS9928a_interface tms9929a_interface = |
| r8296 | r8297 | |
| 424 | 387 | |
| 425 | 388 | MACHINE_START( ti99_4ev_60hz) |
| 426 | 389 | { |
| 427 | | /* has an own VDP, so skip initing the VDP */ |
| 428 | | ti99_common_init(machine, 0); |
| 390 | /* has an own VDP, so skip initing the VDP */ |
| 391 | ti99_common_init(machine, 0); |
| 429 | 392 | } |
| 430 | 393 | |
| 431 | | MACHINE_START( ti99_4p ) |
| 432 | | { |
| 433 | | UINT8* mem = memory_region(machine, "maincpu"); |
| 434 | | |
| 435 | | /* Set up system ROM and scratch pad pointers. Must be set up here */ |
| 436 | | /* so that the system can successfully reset (otherwise the reset */ |
| 437 | | /* vector would be missing in 0x0000). */ |
| 438 | | memory_set_bankptr(machine, "bank1", mem + offset_rom0_4p); /* system ROM */ |
| 439 | | memory_set_bankptr(machine, "bank2", mem + offset_sram_4p); /* scratch pad */ |
| 440 | | memory_set_bankptr(machine, "bank11", mem + offset_dram_4p); /* extra RAM for debugger */ |
| 441 | | |
| 442 | | ti99_peb_init(); |
| 443 | | ti99_floppy_controllers_init_all(machine); |
| 444 | | ti99_ide_init(machine); |
| 445 | | ti99_hsgpl_init(machine); |
| 446 | | ti99_usbsm_init(machine); |
| 447 | | } |
| 448 | | |
| 449 | 394 | void ti99_common_init(running_machine *machine, const TMS9928a_interface *gfxparm) |
| 450 | 395 | { |
| 451 | 396 | if (gfxparm != 0) |
| r8296 | r8297 | |
| 478 | 423 | console_GROMs.raddr_LSB = FALSE; |
| 479 | 424 | console_GROMs.waddr_LSB = FALSE; |
| 480 | 425 | |
| 481 | | if (ti99_model == model_99_8) |
| 482 | | { |
| 483 | | /* ... */ |
| 484 | | ti99_8_enable_rom_and_ports = 1; /* ??? maybe there is a pull-up */ |
| 485 | | /* MZ: already setting this in driver init, otherwise machine locks up */ |
| 486 | | } |
| 487 | | else if (ti99_model == model_99_4p) |
| 488 | | { |
| 489 | | UINT8* mem = memory_region(machine, "maincpu"); |
| 426 | /* set up scratch pad pointer */ |
| 427 | memory_set_bankptr(machine, "bank1", memory_region(machine, "maincpu") + offset_sram); |
| 490 | 428 | |
| 491 | | /* set up system ROM and scratch pad pointers */ |
| 492 | | memory_set_bankptr(machine, "bank1", mem + offset_rom0_4p); /* system ROM */ |
| 493 | | memory_set_bankptr(machine, "bank2", mem + offset_sram_4p); /* scratch pad */ |
| 494 | | memory_set_bankptr(machine, "bank11", mem + offset_dram_4p); /* extra RAM for debugger */ |
| 495 | | } |
| 496 | | else |
| 497 | | { |
| 498 | | /* set up scratch pad pointer */ |
| 499 | | memory_set_bankptr(machine, "bank1", memory_region(machine, "maincpu") + offset_sram); |
| 500 | | } |
| 501 | | |
| 502 | 429 | if (!has_evpc) TMS9928A_reset(); |
| 503 | 430 | else v9938_reset(0); |
| 504 | 431 | |
| r8296 | r8297 | |
| 514 | 441 | tms9901_set_single_int(devtag_get_device(machine, "tms9901"), 12, 0); |
| 515 | 442 | |
| 516 | 443 | /* read config */ |
| 517 | | if (ti99_model == model_99_8) |
| 518 | | xRAM_kind = RAM_99_8; |
| 519 | | else if (ti99_model == model_99_4p) |
| 520 | | xRAM_kind = RAM_99_4P; |
| 521 | | else |
| 522 | | xRAM_kind = input_port_read(machine, "RAM"); |
| 444 | xRAM_kind = input_port_read(machine, "RAM"); |
| 523 | 445 | |
| 524 | | if (ti99_model == model_99_8) |
| 525 | | has_speech = TRUE; |
| 526 | | else |
| 527 | | has_speech = input_port_read(machine, "SPEECH"); |
| 528 | | |
| 446 | has_speech = input_port_read(machine, "SPEECH"); |
| 529 | 447 | has_ide = input_port_read(machine, "HDCTRL") & HD_IDE; |
| 530 | 448 | has_rs232 = input_port_read(machine, "SERIAL") & SERIAL_TI; |
| 449 | has_handset = (ti99_model == model_99_4)? (input_port_read(machine, "HCI") & HCI_IR) : FALSE; |
| 450 | has_mecmouse = input_port_read(machine, "HCI") & HCI_MECMOUSE; |
| 451 | has_hsgpl = input_port_read(machine, "EXTCARD") & (EXT_HSGPL_ON | EXT_HSGPL_FLASH); |
| 452 | has_usb_sm = input_port_read(machine, "HDCTRL") & HD_USB; |
| 453 | has_pcode = input_port_read(machine, "EXTCARD") & EXT_PCODE; |
| 531 | 454 | |
| 532 | | if (ti99_model == model_99_4) |
| 533 | | has_handset = input_port_read(machine, "HCI") & HCI_IR; |
| 534 | | else |
| 535 | | has_handset = FALSE; |
| 536 | | |
| 537 | | if (ti99_model == model_99_4p) |
| 538 | | has_hsgpl = TRUE; |
| 539 | | else |
| 540 | | has_hsgpl = input_port_read(machine, "EXTCARD") & (EXT_HSGPL_ON | EXT_HSGPL_FLASH); |
| 541 | | |
| 542 | 455 | hsgpl_flash_mode = input_port_read(machine, "EXTCARD") & EXT_HSGPL_FLASH; |
| 543 | 456 | |
| 544 | | has_usb_sm = input_port_read(machine, "HDCTRL") & HD_USB; |
| 545 | | has_pcode = input_port_read(machine, "EXTCARD") & EXT_PCODE; |
| 546 | | |
| 547 | 457 | /* Get the GK settings once */ |
| 548 | | if (ti99_model != model_99_4p) |
| 549 | | { |
| 550 | | gk_switch[1] = input_port_read(machine, "GKSWITCH1"); |
| 551 | | gk_switch[2] = input_port_read(machine, "GKSWITCH2"); |
| 552 | | gk_switch[3] = input_port_read(machine, "GKSWITCH3"); |
| 553 | | gk_switch[4] = input_port_read(machine, "GKSWITCH4"); |
| 554 | | gk_switch[5] = input_port_read(machine, "GKSWITCH5"); |
| 555 | | } |
| 458 | gk_switch[1] = input_port_read(machine, "GKSWITCH1"); |
| 459 | gk_switch[2] = input_port_read(machine, "GKSWITCH2"); |
| 460 | gk_switch[3] = input_port_read(machine, "GKSWITCH3"); |
| 461 | gk_switch[4] = input_port_read(machine, "GKSWITCH4"); |
| 462 | gk_switch[5] = input_port_read(machine, "GKSWITCH5"); |
| 556 | 463 | |
| 557 | 464 | // Removes all card handlers |
| 558 | 465 | ti99_peb_init(); |
| 559 | 466 | |
| 560 | 467 | // set up optional expansion hardware |
| 561 | | ti99_peb_reset(ti99_model == model_99_4p, tms9901_set_int1, NULL); |
| 468 | ti99_peb_reset(FALSE, tms9901_set_int1, NULL); |
| 562 | 469 | |
| 563 | | if (ti99_model == model_99_8) |
| 564 | | ti99_8_internal_dsr_reset(machine); |
| 565 | | |
| 566 | | if (ti99_model == model_99_4p) |
| 567 | | ti99_4p_internal_dsr_reset(machine); |
| 568 | | |
| 569 | 470 | if (has_speech) |
| 570 | 471 | { |
| 571 | 472 | static const spchroms_interface speech_intf = { region_speech_rom }; |
| 572 | 473 | |
| 573 | 474 | spchroms_config(machine, &speech_intf); |
| 574 | 475 | |
| 575 | | if (ti99_model != model_99_8) |
| 576 | | { |
| 577 | | memory_install_read16_handler(space, 0x9000, 0x93ff, 0, 0, ti99_rspeech_r); |
| 578 | | memory_install_write16_handler(space, 0x9400, 0x97ff, 0, 0, ti99_wspeech_w); |
| 579 | | } |
| 476 | memory_install_read16_handler(space, 0x9000, 0x93ff, 0, 0, ti99_rspeech_r); |
| 477 | memory_install_write16_handler(space, 0x9400, 0x97ff, 0, 0, ti99_wspeech_w); |
| 580 | 478 | } |
| 581 | 479 | else |
| 582 | 480 | { |
| 583 | | /* which is never true for TI-99/8 */ |
| 584 | 481 | memory_install_read16_handler(space, 0x9000, 0x93ff, 0, 0, ti99_nop_8_r); |
| 585 | 482 | memory_install_write16_handler(space, 0x9400, 0x97ff, 0, 0, ti99_nop_8_w); |
| 586 | 483 | } |
| 587 | 484 | |
| 588 | 485 | switch (xRAM_kind) |
| 589 | 486 | { |
| 590 | | case RAM_NONE: |
| 591 | | default: |
| 592 | | memory_install_read16_handler(space, 0x2000, 0x3fff, 0, 0, ti99_nop_8_r); |
| 593 | | memory_install_write16_handler(space, 0x2000, 0x3fff, 0, 0, ti99_nop_8_w); |
| 594 | | memory_install_read16_handler(space, 0xa000, 0xffff, 0, 0, ti99_nop_8_r); |
| 595 | | memory_install_write16_handler(space, 0xa000, 0xffff, 0, 0, ti99_nop_8_w); |
| 596 | | break; |
| 597 | 487 | case RAM_TI32: |
| 598 | 488 | ti99_TIxram_init(machine); |
| 599 | 489 | break; |
| 600 | 490 | case RAM_SUPERAMS1024: |
| 601 | 491 | ti99_sAMSxram_init(machine); |
| 602 | 492 | break; |
| 603 | | case RAM_99_4P: |
| 604 | | ti99_4p_mapper_init(machine); |
| 605 | | break; |
| 606 | 493 | case RAM_FOUNDATION128: |
| 607 | 494 | case RAM_FOUNDATION512: |
| 608 | 495 | case RAM_MYARC128: |
| 609 | 496 | case RAM_MYARC512: |
| 610 | 497 | ti99_myarcxram_init(machine); |
| 611 | 498 | break; |
| 612 | | case RAM_99_8: |
| 499 | case RAM_NONE: |
| 500 | default: |
| 501 | memory_install_read16_handler(space, 0x2000, 0x3fff, 0, 0, ti99_nop_8_r); |
| 502 | memory_install_write16_handler(space, 0x2000, 0x3fff, 0, 0, ti99_nop_8_w); |
| 503 | memory_install_read16_handler(space, 0xa000, 0xffff, 0, 0, ti99_nop_8_r); |
| 504 | memory_install_write16_handler(space, 0xa000, 0xffff, 0, 0, ti99_nop_8_w); |
| 613 | 505 | break; |
| 614 | 506 | } |
| 615 | 507 | |
| r8296 | r8297 | |
| 634 | 526 | } |
| 635 | 527 | |
| 636 | 528 | if (has_ide) |
| 637 | | ti99_ide_reset(machine, ti99_model == model_99_8); |
| 529 | ti99_ide_reset(machine, FALSE); |
| 638 | 530 | |
| 639 | 531 | if (has_hsgpl) |
| 640 | 532 | ti99_hsgpl_reset(machine); |
| r8296 | r8297 | |
| 642 | 534 | hsgpl_crdena = 0; |
| 643 | 535 | |
| 644 | 536 | if (has_usb_sm) |
| 645 | | ti99_usbsm_reset(machine, ti99_model == model_99_8); |
| 537 | ti99_usbsm_reset(machine, FALSE); |
| 646 | 538 | |
| 647 | 539 | if (has_evpc) |
| 540 | { |
| 541 | /* Get the EVPC settings once */ |
| 542 | evpc_switch[0] = input_port_read(machine, "EVPC-SW1"); |
| 543 | evpc_switch[1] = input_port_read(machine, "EVPC-SW3"); |
| 544 | evpc_switch[2] = input_port_read(machine, "EVPC-SW4"); |
| 545 | evpc_switch[3] = input_port_read(machine, "EVPC-SW8"); |
| 648 | 546 | ti99_evpc_reset(machine); |
| 547 | } |
| 649 | 548 | |
| 650 | 549 | if (has_pcode) |
| 651 | 550 | ti99_pcode_reset(machine); |
| r8296 | r8297 | |
| 672 | 571 | |
| 673 | 572 | NVRAM_HANDLER( ti99 ) |
| 674 | 573 | { |
| 675 | | const char *filename; |
| 574 | // called from generic.c |
| 575 | // (running_machine *machine, mame_file *file, int read_or_write) |
| 676 | 576 | |
| 677 | | /* We may have different HSGPL settings for 80 column and traditional */ |
| 678 | | /* 40 column display. For convenience, we use two different nvram files. */ |
| 679 | | if (has_evpc) |
| 680 | | filename = "hsgpl80.nv"; |
| 681 | | else |
| 682 | | filename = "hsgpl40.nv"; |
| 577 | astring *hsname = astring_assemble_3(astring_alloc(), machine->gamedrv->name, PATH_SEPARATOR, "hsgpl.nv"); |
| 578 | astring *evname = astring_assemble_3(astring_alloc(), machine->gamedrv->name, PATH_SEPARATOR, "evpc.nv"); |
| 683 | 579 | |
| 684 | 580 | // We always try to read the HSGPL, even when the config switch is |
| 685 | 581 | // set to off. Otherwise, when the system is started without HSGPL |
| r8296 | r8297 | |
| 688 | 584 | // even when the card has been turned off during runtime. |
| 689 | 585 | if (read_or_write==0) |
| 690 | 586 | { |
| 691 | | ti99_hsgpl_load_flashroms(machine, filename); |
| 587 | ti99_hsgpl_load_flashroms(machine, astring_c(hsname)); |
| 588 | if (has_evpc) ti99_evpc_load_novram(machine, astring_c(evname)); |
| 692 | 589 | } |
| 693 | 590 | else |
| 694 | 591 | { |
| 695 | | ti99_hsgpl_save_flashroms(machine, filename); |
| 592 | ti99_hsgpl_save_flashroms(machine, astring_c(hsname)); |
| 593 | if (has_evpc) ti99_evpc_save_novram(machine, astring_c(evname)); |
| 696 | 594 | } |
| 595 | |
| 596 | astring_free(hsname); |
| 597 | astring_free(evname); |
| 697 | 598 | } |
| 698 | 599 | |
| 699 | 600 | INPUT_CHANGED( hsgpl_changed ) |
| r8296 | r8297 | |
| 712 | 613 | } |
| 713 | 614 | |
| 714 | 615 | /* |
| 715 | | video initialization. |
| 716 | | */ |
| 717 | | VIDEO_START( ti99_4ev ) |
| 718 | | { |
| 719 | | VIDEO_START_CALL(generic_bitmapped); |
| 720 | | v9938_init(machine, 0, machine->primary_screen, machine->generic.tmpbitmap, |
| 721 | | MODEL_V9938, 0x20000, tms9901_set_int2); /* v38 with 128 kb of video RAM */ |
| 722 | | } |
| 723 | | |
| 724 | | /* |
| 725 | 616 | VBL interrupt (mmm... actually, it happens when the beam enters the lower |
| 726 | 617 | border, so it is not a genuine VBI, but who cares ?) |
| 727 | 618 | */ |
| r8296 | r8297 | |
| 730 | 621 | TMS9928A_interrupt(device->machine); |
| 731 | 622 | if (has_handset) |
| 732 | 623 | ti99_handset_task(device->machine); |
| 733 | | has_mecmouse = input_port_read(device->machine, "HCI") & HCI_MECMOUSE; |
| 734 | 624 | if (has_mecmouse) |
| 735 | 625 | mecmouse_poll(device->machine); |
| 736 | 626 | } |
| 737 | 627 | |
| 738 | | INTERRUPT_GEN( ti99_4ev_hblank_interrupt ) |
| 739 | | { |
| 740 | | static int line_count; |
| 741 | | v9938_interrupt(device->machine, 0); |
| 742 | | if (++line_count == 262) |
| 743 | | { |
| 744 | | line_count = 0; |
| 745 | | has_mecmouse = input_port_read(device->machine, "HCI") & HCI_MECMOUSE; |
| 746 | | if (has_mecmouse) |
| 747 | | mecmouse_poll(device->machine); |
| 748 | | } |
| 749 | | } |
| 750 | | |
| 751 | 628 | /* |
| 752 | 629 | Backdoor function that is called by hsgpl, so that the machine code knows |
| 753 | 630 | whether hsgpl or console GROMs are active |
| r8296 | r8297 | |
| 808 | 685 | */ |
| 809 | 686 | WRITE16_HANDLER ( ti99_cart_w ) |
| 810 | 687 | { |
| 811 | | ti99_multicart_w(cartslots, offset, data, mem_mask); |
| 812 | | if (hsgpl_crdena && !hsgpl_flash_mode) |
| 813 | | /* hsgpl is enabled */ |
| 814 | | ti99_hsgpl_rom6_w(space, offset, data, mem_mask); |
| 815 | | } |
| 688 | // Writing always means that we access the cartridges (and possibly the HGSPL) |
| 689 | // Except when we use the SGCPU. |
| 690 | if (ti99_model != model_99_4p) |
| 691 | ti99_multicart_w(cartslots, offset, data, mem_mask); |
| 816 | 692 | |
| 817 | | /* |
| 818 | | 99/4p cartridge space: mapped either to internal ROM6 or to HSGPL. |
| 819 | | */ |
| 820 | | READ16_HANDLER ( ti99_4p_cart_r ) |
| 821 | | { |
| 822 | | if (ti99_4p_internal_rom6_enable) |
| 823 | | return ti99_4p_internal_ROM6[offset]; |
| 824 | | |
| 825 | | cpu_adjust_icount(devtag_get_device(space->machine, "maincpu"),-4); |
| 826 | | // cpu_spinuntil_time(space->machine->firstcpu, ATTOTIME_IN_USEC(6)); |
| 827 | | |
| 828 | 693 | if (hsgpl_crdena && !hsgpl_flash_mode) |
| 829 | 694 | /* hsgpl is enabled */ |
| 830 | | return ti99_hsgpl_rom6_r(space, offset, mem_mask); |
| 831 | | |
| 832 | | return 0; |
| 833 | | } |
| 834 | | |
| 835 | | WRITE16_HANDLER ( ti99_4p_cart_w ) |
| 836 | | { |
| 837 | | if (ti99_4p_internal_rom6_enable) |
| 838 | | { |
| 839 | | ti99_4p_internal_ROM6 = (UINT16 *) (memory_region(space->machine, "maincpu") + (FPTR)((offset & 1) ? offset_rom6b_4p : offset_rom6_4p)); |
| 840 | | return; |
| 841 | | } |
| 842 | | |
| 843 | | cpu_adjust_icount(devtag_get_device(space->machine, "maincpu"),-4); |
| 844 | | // cpu_spinuntil_time(space->machine->firstcpu, ATTOTIME_IN_USEC(6)); |
| 845 | | |
| 846 | | if (hsgpl_crdena && !hsgpl_flash_mode) |
| 847 | | /* hsgpl is enabled */ |
| 848 | 695 | ti99_hsgpl_rom6_w(space, offset, data, mem_mask); |
| 849 | 696 | } |
| 850 | 697 | |
| r8296 | r8297 | |
| 926 | 773 | } |
| 927 | 774 | |
| 928 | 775 | /* |
| 929 | | V38 VDP read |
| 930 | | */ |
| 931 | | READ16_HANDLER ( ti99_rv38_r ) |
| 932 | | { |
| 933 | | cpu_adjust_icount(devtag_get_device(space->machine, "maincpu"),-4); |
| 934 | | // cpu_spinuntil_time(space->machine->firstcpu, ATTOTIME_IN_USEC(6)); |
| 935 | | |
| 936 | | if (offset & 1) |
| 937 | | { /* read VDP status */ |
| 938 | | return ((int) v9938_0_status_r(space, 0)) << 8; |
| 939 | | } |
| 940 | | else |
| 941 | | { /* read VDP RAM */ |
| 942 | | return ((int) v9938_0_vram_r(space, 0)) << 8; |
| 943 | | } |
| 944 | | } |
| 945 | | |
| 946 | | /* |
| 947 | | V38 vdp write |
| 948 | | */ |
| 949 | | WRITE16_HANDLER ( ti99_wv38_w ) |
| 950 | | { |
| 951 | | cpu_adjust_icount(devtag_get_device(space->machine, "maincpu"),-4); |
| 952 | | // cpu_spinuntil_time(space->machine->firstcpu, ATTOTIME_IN_USEC(6)); |
| 953 | | |
| 954 | | switch (offset & 3) |
| 955 | | { |
| 956 | | case 0: |
| 957 | | /* write VDP data */ |
| 958 | | v9938_0_vram_w(space, 0, (data >> 8) & 0xff); |
| 959 | | break; |
| 960 | | case 1: |
| 961 | | /* write VDP address */ |
| 962 | | v9938_0_command_w(space, 0, (data >> 8) & 0xff); |
| 963 | | break; |
| 964 | | case 2: |
| 965 | | /* write VDP palette */ |
| 966 | | v9938_0_palette_w(space, 0, (data >> 8) & 0xff); |
| 967 | | break; |
| 968 | | case 3: |
| 969 | | /* write VDP register */ |
| 970 | | v9938_0_register_w(space, 0, (data >> 8) & 0xff); |
| 971 | | break; |
| 972 | | } |
| 973 | | } |
| 974 | | |
| 975 | | /* |
| 976 | 776 | TMS0285 speech chip read |
| 977 | 777 | */ |
| 978 | 778 | static READ16_HANDLER ( ti99_rspeech_r ) |
| r8296 | r8297 | |
| 1151 | 951 | console_GROMs.raddr_LSB = TRUE; |
| 1152 | 952 | } |
| 1153 | 953 | /* GROM address values must be globally unique. */ |
| 1154 | | // FIXME: HSGPL asserts here when switched on during runtime |
| 1155 | | // You should not do that, but again the emulation should |
| 1156 | | // not assert either |
| 1157 | 954 | assert (replycart == reply); |
| 1158 | 955 | } |
| 1159 | 956 | else |
| r8296 | r8297 | |
| 1233 | 1030 | } |
| 1234 | 1031 | } |
| 1235 | 1032 | |
| 1236 | | /* |
| 1237 | | GROM read for TI-99/8 |
| 1238 | | For comments, see the handler for TI-99/4A |
| 1239 | | */ |
| 1240 | | static READ8_HANDLER ( ti99_grom_r8 ) |
| 1241 | | { |
| 1242 | | UINT8 reply, replycart; |
| 1243 | | |
| 1244 | | cpu_adjust_icount(space->machine->firstcpu,-4); |
| 1245 | | |
| 1246 | | if (offset & 2) |
| 1247 | | { |
| 1248 | | replycart = ti99_cartridge_grom_r(cartslots, offset); |
| 1249 | | console_GROMs.waddr_LSB = FALSE; |
| 1250 | | |
| 1251 | | if (console_GROMs.raddr_LSB) |
| 1252 | | { |
| 1253 | | reply = console_GROMs.addr & 0x00ff; |
| 1254 | | console_GROMs.raddr_LSB = FALSE; |
| 1255 | | } |
| 1256 | | else |
| 1257 | | { |
| 1258 | | reply = (console_GROMs.addr>>8) & 0x00ff; |
| 1259 | | console_GROMs.raddr_LSB = TRUE; |
| 1260 | | } |
| 1261 | | /* GROM address values must be globally unique. */ |
| 1262 | | assert (replycart == reply); |
| 1263 | | } |
| 1264 | | else |
| 1265 | | { |
| 1266 | | reply = GROM_dataread(space->machine, offset); |
| 1267 | | } |
| 1268 | | return reply; |
| 1269 | | } |
| 1270 | | |
| 1271 | | /* |
| 1272 | | GROM write for TI-99/8 |
| 1273 | | For comments, see the handler for TI-99/4A |
| 1274 | | */ |
| 1275 | | static WRITE8_HANDLER ( ti99_grom_w8 ) |
| 1276 | | { |
| 1277 | | cpu_adjust_icount(space->machine->firstcpu,-4/*20+3*/); /* from 4 to 23? */ |
| 1278 | | |
| 1279 | | if (offset & 2) |
| 1280 | | { |
| 1281 | | ti99_cartridge_grom_w(cartslots, offset, data); |
| 1282 | | console_GROMs.raddr_LSB = FALSE; |
| 1283 | | if (console_GROMs.waddr_LSB) |
| 1284 | | { |
| 1285 | | console_GROMs.addr = (console_GROMs.addr & 0xFF00) | (data & 0xFF); |
| 1286 | | |
| 1287 | | GROM_dataread(space->machine, offset&0xfffc); |
| 1288 | | console_GROMs.waddr_LSB = FALSE; |
| 1289 | | } |
| 1290 | | else |
| 1291 | | { |
| 1292 | | console_GROMs.addr = ((data<<8) & 0xFF00) | (console_GROMs.addr & 0xFF); |
| 1293 | | console_GROMs.waddr_LSB = TRUE; |
| 1294 | | } |
| 1295 | | |
| 1296 | | } |
| 1297 | | else |
| 1298 | | { |
| 1299 | | GRAM_datawrite(offset, (data>>8)&0xff); |
| 1300 | | console_GROMs.raddr_LSB = console_GROMs.waddr_LSB = FALSE; |
| 1301 | | } |
| 1302 | | } |
| 1303 | | |
| 1304 | | |
| 1305 | | /* |
| 1306 | | GROM read for TI-99/4p |
| 1307 | | */ |
| 1308 | | READ16_HANDLER ( ti99_4p_grom_r ) |
| 1309 | | { |
| 1310 | | cpu_adjust_icount(devtag_get_device(space->machine, "maincpu"),-4); /* HSGPL is located on 8-bit bus? */ |
| 1311 | | // cpu_spinuntil_time(space->machine->firstcpu, ATTOTIME_IN_USEC(6)); |
| 1312 | | |
| 1313 | | return hsgpl_crdena? ti99_hsgpl_gpl_r(space, offset, mem_mask) : 0; |
| 1314 | | } |
| 1315 | | |
| 1316 | | /* |
| 1317 | | GROM write |
| 1318 | | */ |
| 1319 | | WRITE16_HANDLER ( ti99_4p_grom_w ) |
| 1320 | | { |
| 1321 | | cpu_adjust_icount(devtag_get_device(space->machine, "maincpu"),-4); /* HSGPL is located on 8-bit bus? */ |
| 1322 | | // cpu_spinuntil_time(space->machine->firstcpu, ATTOTIME_IN_USEC(6)); |
| 1323 | | |
| 1324 | | if (hsgpl_crdena) |
| 1325 | | ti99_hsgpl_gpl_w(space, offset, data, mem_mask); |
| 1326 | | } |
| 1327 | | |
| 1328 | | |
| 1329 | | #if 0 |
| 1330 | | #pragma mark - |
| 1331 | | #pragma mark 99/8 MEMORY HANDLERS |
| 1332 | | #endif |
| 1333 | | |
| 1334 | | READ8_HANDLER( ti99_8_r ) |
| 1335 | | { |
| 1336 | | /* Set the page. Page size is 4 KiB; page number are the high 4 bits. */ |
| 1337 | | int page = offset >> 12; |
| 1338 | | UINT32 mapper_reg; |
| 1339 | | UINT8 reply = 0; |
| 1340 | | |
| 1341 | | if (ti99_8_enable_rom_and_ports) |
| 1342 | | { |
| 1343 | | /* This is only important for address access 0000-1fff and |
| 1344 | | 8000-9fff. Outside, the mapper mode is used. */ |
| 1345 | | if ((offset >= 0x0000) && (offset < 0x2000)) |
| 1346 | | { |
| 1347 | | /* ROM */ |
| 1348 | | reply = ROM0_ptr_8[offset & 0x1fff]; |
| 1349 | | return reply; |
| 1350 | | } |
| 1351 | | else if ((offset >= 0x8000) && (offset < 0xa000)) |
| 1352 | | { |
| 1353 | | /* ti99 scratch pad and memory-mapped registers */ |
| 1354 | | /* 0x8000-0x9fff */ |
| 1355 | | switch ((offset - 0x8000) >> 10) |
| 1356 | | { |
| 1357 | | case 0: |
| 1358 | | /* RAM: >8000 - >83ff */ |
| 1359 | | reply = sRAM_ptr_8[offset & 0x1fff]; |
| 1360 | | break; |
| 1361 | | |
| 1362 | | case 1: |
| 1363 | | /* >8400 - >840f: sound (cannot read) |
| 1364 | | >8410 - >87ff: SRAM */ |
| 1365 | | if (offset >= 0x8410) |
| 1366 | | reply = sRAM_ptr_8[offset & 0x1fff]; |
| 1367 | | break; |
| 1368 | | |
| 1369 | | case 2: |
| 1370 | | /* VDP read + mapper status */ |
| 1371 | | if (offset < 0x8810) |
| 1372 | | { |
| 1373 | | if (! (offset & 1)) |
| 1374 | | { |
| 1375 | | if (offset & 2) |
| 1376 | | /* read VDP status >8802 */ |
| 1377 | | reply = TMS9928A_register_r(space, 0); |
| 1378 | | else |
| 1379 | | /* read VDP RAM >8800 */ |
| 1380 | | reply = TMS9928A_vram_r(space, 0); |
| 1381 | | } |
| 1382 | | } |
| 1383 | | else |
| 1384 | | { |
| 1385 | | /* Read mapper >8810 */ |
| 1386 | | reply = ti99_8_mapper_status; |
| 1387 | | ti99_8_mapper_status = 0; |
| 1388 | | } |
| 1389 | | break; |
| 1390 | | |
| 1391 | | case 4: |
| 1392 | | /* speech read: >9000 */ |
| 1393 | | if (! (offset & 1)) |
| 1394 | | { |
| 1395 | | cpu_adjust_icount(devtag_get_device(space->machine, "maincpu"),-16*4); /* this is just a minimum, it can be more */ |
| 1396 | | reply = tms5220_status_r(devtag_get_device(space->machine, "tms5220"), 0); |
| 1397 | | } |
| 1398 | | break; |
| 1399 | | |
| 1400 | | case 6: |
| 1401 | | /* GROM read: >9800 */ |
| 1402 | | if (! (offset & 1)) |
| 1403 | | reply = ti99_grom_r8(space, offset); |
| 1404 | | break; |
| 1405 | | |
| 1406 | | default: |
| 1407 | | logerror("unmapped read offs=%d\n", (int) offset); |
| 1408 | | break; |
| 1409 | | } |
| 1410 | | return reply; |
| 1411 | | } |
| 1412 | | } |
| 1413 | | |
| 1414 | | mapper_reg = ti99_8_mapper_regs[page]; |
| 1415 | | offset = (mapper_reg + (offset & 0x0fff)) & 0x00ffffff; |
| 1416 | | |
| 1417 | | #if 0 |
| 1418 | | /* test read protect */ |
| 1419 | | if (mapper_reg & 0x20000000) |
| 1420 | | ; |
| 1421 | | |
| 1422 | | /* test execute protect */ |
| 1423 | | if (mapper_reg & 0x40000000) |
| 1424 | | ; |
| 1425 | | #endif |
| 1426 | | |
| 1427 | | if (offset < 0x010000) |
| 1428 | | /* Read RAM */ |
| 1429 | | reply = xRAM_ptr_8[offset]; |
| 1430 | | |
| 1431 | | if (offset >= 0xff0000) |
| 1432 | | { |
| 1433 | | switch ((offset >> 13) & 7) |
| 1434 | | { |
| 1435 | | default: |
| 1436 | | /* should never happen */ |
| 1437 | | case 0: |
| 1438 | | /* ff0000 - ff1fff: unassigned? */ |
| 1439 | | case 1: |
| 1440 | | /* ff2000 - ff3fff: ? */ |
| 1441 | | case 4: |
| 1442 | | /* ff8000 - ff9fff: internal DSR ROM? (normally enabled with a write to CRU >2700) */ |
| 1443 | | case 7: |
| 1444 | | /* ffe000 - ffffff: ? */ |
| 1445 | | logerror("unmapped read page=%d offs=%d\n", (int) page, (int) offset); |
| 1446 | | break; |
| 1447 | | |
| 1448 | | case 2: |
| 1449 | | /* ff4000 - ff5fff: DSR space */ |
| 1450 | | reply = ti99_8_peb_r(space, offset & 0x1fff); |
| 1451 | | break; |
| 1452 | | |
| 1453 | | case 3: |
| 1454 | | /* ff6000 - ff7fff: cartridge ROM space */ |
| 1455 | | offset &= 0x1fff; |
| 1456 | | |
| 1457 | | /* We do not support hsgpl here because it is a 16 bit |
| 1458 | | system. Just check the cartridges. */ |
| 1459 | | reply = ti99_multicart8_r(multicart8, offset); |
| 1460 | | break; |
| 1461 | | |
| 1462 | | case 5: |
| 1463 | | /* ffa000 - ffbfff: >2000 ROM (ROM1) */ |
| 1464 | | reply = ROM1_ptr_8[offset & 0x1fff]; |
| 1465 | | break; |
| 1466 | | |
| 1467 | | case 6: |
| 1468 | | /* ffc000 - ffdfff: >6000 ROM */ |
| 1469 | | reply = ROM3_ptr_8[offset & 0x1fff]; |
| 1470 | | break; |
| 1471 | | } |
| 1472 | | } |
| 1473 | | |
| 1474 | | return reply; |
| 1475 | | } |
| 1476 | | |
| 1477 | | WRITE8_HANDLER ( ti99_8_w ) |
| 1478 | | { |
| 1479 | | int page = offset >> 12; |
| 1480 | | UINT32 mapper_reg; |
| 1481 | | |
| 1482 | | if (ti99_8_enable_rom_and_ports) |
| 1483 | | { |
| 1484 | | /* memory mapped ports enabled */ |
| 1485 | | if ((offset >= 0x0000) && (offset < 0x2000)) |
| 1486 | | { |
| 1487 | | /* ROM? */ |
| 1488 | | return; |
| 1489 | | } |
| 1490 | | else if ((offset >= 0x8000) && (offset < 0xa000)) |
| 1491 | | { |
| 1492 | | /* ti99 scratch pad and memory-mapped registers */ |
| 1493 | | /* 0x8000-0x9fff */ |
| 1494 | | switch ((offset - 0x8000) >> 10) |
| 1495 | | { |
| 1496 | | case 0: |
| 1497 | | /* RAM */ |
| 1498 | | sRAM_ptr_8[offset & 0x1fff] = data; |
| 1499 | | break; |
| 1500 | | |
| 1501 | | case 1: |
| 1502 | | /* sound write + RAM */ |
| 1503 | | if (offset < 0x8410) |
| 1504 | | sn76496_w(devtag_get_device(space->machine, "sn76496"), offset, data); |
| 1505 | | else |
| 1506 | | sRAM_ptr_8[offset & 0x1fff] = data; |
| 1507 | | break; |
| 1508 | | |
| 1509 | | case 2: |
| 1510 | | /* VDP read + mapper control */ |
| 1511 | | if (offset >= 0x8810) |
| 1512 | | { |
| 1513 | | int file = (data >> 1) & 3; |
| 1514 | | int i; |
| 1515 | | |
| 1516 | | if (data & 1) |
| 1517 | | { /* load */ |
| 1518 | | for (i=0; i<16; i++) |
| 1519 | | { |
| 1520 | | ti99_8_mapper_regs[i] = (sRAM_ptr_8[(file << 6) + (i << 2)] << 24) |
| 1521 | | | (sRAM_ptr_8[(file << 6) + (i << 2) + 1] << 16) |
| 1522 | | | (sRAM_ptr_8[(file << 6) + (i << 2) + 2] << 8) |
| 1523 | | | sRAM_ptr_8[(file << 6) + (i << 2) + 3]; |
| 1524 | | } |
| 1525 | | } |
| 1526 | | else |
| 1527 | | { /* save */ |
| 1528 | | for (i=0; i<16; i++) |
| 1529 | | { |
| 1530 | | sRAM_ptr_8[(file << 6) + (i << 2)] = ti99_8_mapper_regs[i] >> 24; |
| 1531 | | sRAM_ptr_8[(file << 6) + (i << 2) + 1] = ti99_8_mapper_regs[i] >> 16; |
| 1532 | | sRAM_ptr_8[(file << 6) + (i << 2) + 2] = ti99_8_mapper_regs[i] >> 8; |
| 1533 | | sRAM_ptr_8[(file << 6) + (i << 2) + 3] = ti99_8_mapper_regs[i]; |
| 1534 | | } |
| 1535 | | } |
| 1536 | | } |
| 1537 | | break; |
| 1538 | | |
| 1539 | | case 3: |
| 1540 | | /* VDP write */ |
| 1541 | | if (! (offset & 1)) |
| 1542 | | { |
| 1543 | | if (offset & 2) |
| 1544 | | /* read VDP status */ |
| 1545 | | TMS9928A_register_w(space, 0, data); |
| 1546 | | else |
| 1547 | | /* read VDP RAM */ |
| 1548 | | TMS9928A_vram_w(space, 0, data); |
| 1549 | | } |
| 1550 | | break; |
| 1551 | | |
| 1552 | | case 5: |
| 1553 | | /* speech write */ |
| 1554 | | if (! (offset & 1)) |
| 1555 | | { |
| 1556 | | cpu_adjust_icount(devtag_get_device(space->machine, "maincpu"),-48*4); /* this is just an approx. minimum, it can be much more */ |
| 1557 | | |
| 1558 | | /* the stupid design of the tms5220 core means that ready is cleared when |
| 1559 | | there are 15 bytes in FIFO. It should be 16. Of course, if it were the |
| 1560 | | case, we would need to store the value on the bus, which would be more |
| 1561 | | complex. */ |
| 1562 | | if (! tms5220_readyq_r(devtag_get_device(space->machine, "tms5220"))) |
| 1563 | | { |
| 1564 | | attotime time_to_ready = double_to_attotime(tms5220_time_to_ready(devtag_get_device(space->machine, "tms5220"))); |
| 1565 | | double d = cputag_attotime_to_clocks(space->machine, "maincpu", time_to_ready); |
| 1566 | | int cycles_to_ready = ((int) (d + 3)) & ~3; |
| 1567 | | |
| 1568 | | logerror("time to ready: %f -> %d\n", attotime_to_double(time_to_ready) |
| 1569 | | , (int) cycles_to_ready); |
| 1570 | | |
| 1571 | | cpu_adjust_icount(devtag_get_device(space->machine, "maincpu"),-cycles_to_ready); |
| 1572 | | timer_set(space->machine, attotime_zero, NULL, 0, /*speech_kludge_callback*/NULL); |
| 1573 | | } |
| 1574 | | |
| 1575 | | tms5220_data_w(devtag_get_device(space->machine, "tms5220"), offset, data); |
| 1576 | | } |
| 1577 | | break; |
| 1578 | | |
| 1579 | | case 7: |
| 1580 | | /* GPL write */ |
| 1581 | | if (! (offset & 1)) |
| 1582 | | ti99_grom_w8(space, offset, data); |
| 1583 | | break; |
| 1584 | | |
| 1585 | | default: |
| 1586 | | logerror("unmapped write offs=%d data=%d\n", (int) offset, (int) data); |
| 1587 | | break; |
| 1588 | | } |
| 1589 | | return; |
| 1590 | | } |
| 1591 | | } |
| 1592 | | |
| 1593 | | mapper_reg = ti99_8_mapper_regs[page]; |
| 1594 | | |
| 1595 | | /* 4 KiB page size */ |
| 1596 | | offset = (mapper_reg + (offset & 0x0fff)) & 0x00ffffff; |
| 1597 | | |
| 1598 | | #if 0 |
| 1599 | | /* test write protect */ |
| 1600 | | if (mapper_reg & 0x80000000) |
| 1601 | | ; |
| 1602 | | #endif |
| 1603 | | |
| 1604 | | if (offset < 0x010000) |
| 1605 | | { /* Write RAM */ |
| 1606 | | xRAM_ptr_8[offset] = data; |
| 1607 | | } |
| 1608 | | else if (offset >= 0xff0000) |
| 1609 | | { |
| 1610 | | switch ((offset >> 13) & 7) |
| 1611 | | { |
| 1612 | | default: |
| 1613 | | /* should never happen */ |
| 1614 | | case 0: |
| 1615 | | /* unassigned??? */ |
| 1616 | | case 1: |
| 1617 | | /* ??? */ |
| 1618 | | case 4: |
| 1619 | | /* internal DSR ROM??? (normally enabled with a write to CRU >2700) */ |
| 1620 | | case 7: |
| 1621 | | /* ??? */ |
| 1622 | | break; |
| 1623 | | |
| 1624 | | case 2: |
| 1625 | | /* DSR space */ |
| 1626 | | ti99_8_peb_w(space, offset & 0x1fff, data); |
| 1627 | | break; |
| 1628 | | |
| 1629 | | case 3: |
| 1630 | | /* cartridge space */ |
| 1631 | | /* We do not support HSGPL for the 99/8 at this time. */ |
| 1632 | | ti99_multicart8_w(multicart8, offset & 0x1fff, data); |
| 1633 | | break; |
| 1634 | | |
| 1635 | | case 5: |
| 1636 | | /* >2000 ROM (ROM1) */ |
| 1637 | | break; |
| 1638 | | |
| 1639 | | case 6: |
| 1640 | | /* >6000 ROM */ |
| 1641 | | break; |
| 1642 | | } |
| 1643 | | } |
| 1644 | | else |
| 1645 | | { |
| 1646 | | logerror("unmapped write page=%d offs=%d\n", (int) page, (int) offset); |
| 1647 | | } |
| 1648 | | } |
| 1649 | | |
| 1650 | 1033 | /*===========================================================================*/ |
| 1651 | 1034 | #if 0 |
| 1652 | 1035 | #pragma mark - |
| r8296 | r8297 | |
| 1698 | 1081 | |
| 1699 | 1082 | if (handset_buflen == 1) |
| 1700 | 1083 | { |
| 1701 | | /* Unless I am missing something, the third and last nybble of the |
| 1702 | | message is not acknowledged by the DSR in any way, and the first nybble |
| 1703 | | of next message is not requested for either, so we need to decide on |
| 1704 | | our own when we can post a new event. Currently, we wait for 1000us |
| 1705 | | after the DSR acknowledges the second nybble. */ |
| 1084 | // Unless I am missing something, the third and last nybble of the |
| 1085 | // message is not acknowledged by the DSR in any way, and the first nybble |
| 1086 | // of next message is not requested for either, so we need to decide on |
| 1087 | // our own when we can post a new event. Currently, we wait for 1000us |
| 1088 | // after the DSR acknowledges the second nybble. |
| 1706 | 1089 | timer_set(machine, ATTOTIME_IN_USEC(1000), NULL, 0, ti99_handset_ack_callback); |
| 1707 | 1090 | } |
| 1708 | 1091 | |
| r8296 | r8297 | |
| 1713 | 1096 | |
| 1714 | 1097 | /* |
| 1715 | 1098 | ti99_handset_set_ack() |
| 1716 | | |
| 1717 | 1099 | Handler for tms9901 P0 pin (handset data acknowledge) |
| 1718 | 1100 | */ |
| 1719 | 1101 | static WRITE8_DEVICE_HANDLER( ti99_handset_set_ack ) |
| r8296 | r8297 | |
| 1747 | 1129 | |
| 1748 | 1130 | /* |
| 1749 | 1131 | ti99_handset_poll_keyboard() |
| 1750 | | |
| 1751 | 1132 | Poll the current state of one given handset keypad. |
| 1752 | | |
| 1753 | 1133 | num: number of the keypad to poll (0-3) |
| 1754 | | |
| 1755 | 1134 | Returns TRUE if the handset state has changed and a message was posted. |
| 1756 | 1135 | */ |
| 1757 | 1136 | static int ti99_handset_poll_keyboard(running_machine *machine, int num) |
| r8296 | r8297 | |
| 1766 | 1145 | /* read current key state */ |
| 1767 | 1146 | key_buf = ( input_port_read(machine, keynames[num]) | (input_port_read(machine, keynames[num + 1]) << 16) ) >> (4*num); |
| 1768 | 1147 | |
| 1769 | | /* If a key was previously pressed, this key was not shift, and this key is |
| 1770 | | still down, then don't change the current key press. */ |
| 1148 | // If a key was previously pressed, this key was not shift, and this key is |
| 1149 | // still down, then don't change the current key press. |
| 1771 | 1150 | if (previous_key[num] && (previous_key[num] != 0x24) |
| 1772 | 1151 | && (key_buf & (1 << (previous_key[num] & 0x1f)))) |
| 1773 | 1152 | { |
| r8296 | r8297 | |
| 1777 | 1156 | return FALSE; |
| 1778 | 1157 | else |
| 1779 | 1158 | { |
| 1780 | | /* the shift modifier state has changed: we need to update the |
| 1781 | | keyboard state */ |
| 1159 | // The shift modifier state has changed: we need to update the |
| 1160 | // keyboard state |
| 1782 | 1161 | if (key_buf & 0x0008) |
| 1783 | 1162 | { /* shift has been pressed down */ |
| 1784 | 1163 | previous_key[num] = current_key = previous_key[num] | 0x20; |
| r8296 | r8297 | |
| 1805 | 1184 | current_key |= 0x20; /* set shift flag */ |
| 1806 | 1185 | |
| 1807 | 1186 | if (current_key != 0x24) |
| 1808 | | /* If this is the shift key, any other key we may find will |
| 1809 | | have higher priority; otherwise, we may exit the loop and keep |
| 1810 | | the key we have just found. */ |
| 1187 | // If this is the shift key, any other key we may find will |
| 1188 | // have higher priority; otherwise, we may exit the loop and keep |
| 1189 | // the key we have just found. |
| 1811 | 1190 | break; |
| 1812 | 1191 | } |
| 1813 | 1192 | } |
| r8296 | r8297 | |
| 1829 | 1208 | ti99_handset_poll_joystick() |
| 1830 | 1209 | |
| 1831 | 1210 | Poll the current state of one given handset joystick. |
| 1832 | | |
| 1833 | 1211 | num: number of the joystick to poll (0-3) |
| 1834 | | |
| 1835 | 1212 | Returns TRUE if the handset state has changed and a message was posted. |
| 1836 | 1213 | */ |
| 1837 | 1214 | static int ti99_handset_poll_joystick(running_machine *machine, int num) |
| r8296 | r8297 | |
| 1863 | 1240 | message = 0; |
| 1864 | 1241 | |
| 1865 | 1242 | /* set sign */ |
| 1866 | | /* note that we set the sign if the joystick position is 0 to work |
| 1867 | | around a bug in the ti99/4 ROMs */ |
| 1243 | // note that we set the sign if the joystick position is 0 to work |
| 1244 | // around a bug in the ti99/4 ROMs |
| 1868 | 1245 | if (current_joy_x <= 0) |
| 1869 | 1246 | { |
| 1870 | 1247 | message |= 0x040; |
| r8296 | r8297 | |
| 1904 | 1281 | |
| 1905 | 1282 | /* |
| 1906 | 1283 | ti99_handset_task() |
| 1907 | | |
| 1908 | 1284 | Manage handsets, posting an event if the state of any handset has changed. |
| 1909 | 1285 | */ |
| 1910 | 1286 | static void ti99_handset_task(running_machine *machine) |
| r8296 | r8297 | |
| 2143 | 1519 | { |
| 2144 | 1520 | if (intreq) |
| 2145 | 1521 | { |
| 2146 | | /* On TI99, TMS9900 IC0-3 lines are not connected to TMS9901, |
| 2147 | | * but hard-wired to force level 1 interrupts */ |
| 1522 | // On TI99, TMS9900 IC0-3 lines are not connected to TMS9901, |
| 1523 | // but hard-wired to force level 1 interrupts |
| 2148 | 1524 | cputag_set_input_line_and_vector(device->machine, "maincpu", 0, ASSERT_LINE, 1); /* interrupt it, baby */ |
| 2149 | 1525 | } |
| 2150 | 1526 | else |
| r8296 | r8297 | |
| 2276 | 1652 | else |
| 2277 | 1653 | KeyCol &= ~ (1 << (offset-2)); |
| 2278 | 1654 | |
| 2279 | | if (has_mecmouse) |
| 2280 | | mecmouse_select(KeyCol, (ti99_model == model_99_4) ? 5 : 6, |
| 2281 | | (ti99_model == model_99_4) ? 6 : 7); |
| 1655 | if (has_mecmouse) |
| 1656 | mecmouse_select(KeyCol, (ti99_model == model_99_4) ? 5 : 6, (ti99_model == model_99_4) ? 6 : 7); |
| 2282 | 1657 | } |
| 2283 | 1658 | |
| 2284 | 1659 | /* |
| r8296 | r8297 | |
| 2291 | 1666 | } |
| 2292 | 1667 | |
| 2293 | 1668 | /* |
| 2294 | | Read pins INT3*-INT7* of TI99's 9901. |
| 2295 | | |
| 2296 | | signification: |
| 2297 | | (bit 1: INT1 status) |
| 2298 | | (bit 2: INT2 status) |
| 2299 | | bits 3-4: unused? |
| 2300 | | bit 5: ??? |
| 2301 | | bit 6-7: keyboard status bits 0 through 1 |
| 2302 | | */ |
| 2303 | | static READ8_DEVICE_HANDLER( ti99_8_R9901_0 ) |
| 2304 | | { |
| 2305 | | int answer; |
| 2306 | | static const char *const keynames[] = { |
| 2307 | | "KEY0", "KEY1", "KEY2", "KEY3", "KEY4", "KEY5", "KEY6", "KEY7", |
| 2308 | | "KEY8", "KEY9", "KEY10", "KEY11", "KEY12", "KEY13", "KEY14", "KEY15" |
| 2309 | | }; |
| 2310 | | |
| 2311 | | if (has_mecmouse && (KeyCol == 15)) |
| 2312 | | { |
| 2313 | | int buttons = input_port_read(device->machine, "MOUSE0") & 3; |
| 2314 | | |
| 2315 | | answer = ((mecmouse_read_y ? mecmouse_y_buf : mecmouse_x_buf) << 7) & 0x80; |
| 2316 | | |
| 2317 | | if (! (buttons & 1)) |
| 2318 | | /* action button */ |
| 2319 | | answer |= 0x40; |
| 2320 | | } |
| 2321 | | else |
| 2322 | | { |
| 2323 | | answer = (input_port_read(device->machine, keynames[KeyCol]) << 6) & 0xC0; |
| 2324 | | } |
| 2325 | | |
| 2326 | | return answer; |
| 2327 | | } |
| 2328 | | |
| 2329 | | /* |
| 2330 | 1669 | Read pins INT8*-INT15* of TI99's 9901. |
| 2331 | 1670 | |
| 2332 | 1671 | signification: |
| r8296 | r8297 | |
| 2368 | 1707 | } |
| 2369 | 1708 | |
| 2370 | 1709 | /* |
| 2371 | | WRITE key column select (P0-P3) |
| 2372 | | */ |
| 2373 | | static WRITE8_DEVICE_HANDLER( ti99_8_KeyC ) |
| 2374 | | { |
| 2375 | | if (data) |
| 2376 | | KeyCol |= 1 << offset; |
| 2377 | | else |
| 2378 | | KeyCol &= ~ (1 << offset); |
| 2379 | | |
| 2380 | | if (has_mecmouse) |
| 2381 | | mecmouse_select(KeyCol, 14, 15); |
| 2382 | | } |
| 2383 | | |
| 2384 | | static WRITE8_DEVICE_HANDLER( ti99_8_WCRUS ) |
| 2385 | | { |
| 2386 | | ti99_8_enable_rom_and_ports = data; |
| 2387 | | } |
| 2388 | | |
| 2389 | | static WRITE8_DEVICE_HANDLER( ti99_8_PTGEN ) |
| 2390 | | { |
| 2391 | | /* ... */ |
| 2392 | | } |
| 2393 | | |
| 2394 | | /* |
| 2395 | 1710 | command CS1/CS2 tape unit motor (P6-P7) |
| 2396 | 1711 | */ |
| 2397 | 1712 | static WRITE8_DEVICE_HANDLER( ti99_CS_motor ) |
| r8296 | r8297 | |
| 2439 | 1754 | } |
| 2440 | 1755 | } |
| 2441 | 1756 | |
| 2442 | | |
| 2443 | | |
| 2444 | | /*===========================================================================*/ |
| 2445 | | #if 0 |
| 2446 | | #pragma mark - |
| 2447 | | #pragma mark 99/8 INTERNAL DSR |
| 2448 | | #endif |
| 2449 | | /* |
| 2450 | | TI 99/8 internal DSR support. |
| 2451 | | |
| 2452 | | Includes a few specific signals, and an extra ROM. |
| 2453 | | */ |
| 2454 | | |
| 2455 | | /* prototypes */ |
| 2456 | | static void ti99_8_internal_dsr_cru_w(running_machine *machine, int offset, int data); |
| 2457 | | static READ8_HANDLER(ti99_8_internal_dsr_r); |
| 2458 | | |
| 2459 | | |
| 2460 | | static const ti99_peb_card_handlers_t ti99_8_internal_dsr_handlers = |
| 1757 | /* tms9901 setup */ |
| 1758 | const tms9901_interface tms9901reset_param_ti99_4x = |
| 2461 | 1759 | { |
| 2462 | | NULL, |
| 2463 | | ti99_8_internal_dsr_cru_w, |
| 2464 | | ti99_8_internal_dsr_r, |
| 2465 | | NULL |
| 2466 | | }; |
| 1760 | TMS9901_INT1 | TMS9901_INT2 | TMS9901_INTC, /* only input pins whose state is always known */ |
| 2467 | 1761 | |
| 2468 | | /* pointer to the internal DSR ROM data */ |
| 2469 | | static UINT8 *ti99_8_internal_DSR; |
| 1762 | { /* read handlers */ |
| 1763 | ti99_R9901_0, |
| 1764 | ti99_R9901_1, |
| 1765 | ti99_R9901_2, |
| 1766 | ti99_R9901_3 |
| 1767 | }, |
| 2470 | 1768 | |
| 1769 | { /* write handlers */ |
| 1770 | ti99_handset_set_ack, |
| 1771 | NULL, |
| 1772 | ti99_KeyC, |
| 1773 | ti99_KeyC, |
| 1774 | ti99_KeyC, |
| 1775 | ti99_AlphaW, |
| 1776 | ti99_CS_motor, |
| 1777 | ti99_CS_motor, |
| 1778 | ti99_audio_gate, |
| 1779 | ti99_CS_output, |
| 1780 | NULL, |
| 1781 | NULL, |
| 1782 | NULL, |
| 1783 | NULL, |
| 1784 | NULL, |
| 1785 | NULL |
| 1786 | }, |
| 2471 | 1787 | |
| 2472 | | /* set up handlers, and set initial state */ |
| 2473 | | static void ti99_8_internal_dsr_reset(running_machine *machine) |
| 2474 | | { |
| 2475 | | ti99_8_internal_DSR = memory_region(machine, "maincpu") + offset_rom0_8 + 0x4000; |
| 1788 | /* interrupt handler */ |
| 1789 | tms9901_interrupt_callback, |
| 2476 | 1790 | |
| 2477 | | ti99_peb_set_card_handlers(0x2700, & ti99_8_internal_dsr_handlers); |
| 2478 | | } |
| 2479 | | |
| 2480 | | /* write CRU bit: |
| 2481 | | bit0: enable/disable internal DSR ROM, |
| 2482 | | bit1: hard reset */ |
| 2483 | | static void ti99_8_internal_dsr_cru_w(running_machine *machine, int offset, int data) |
| 2484 | | { |
| 2485 | | switch (offset) |
| 2486 | | { |
| 2487 | | case 1: |
| 2488 | | /* hard reset -- not emulated */ |
| 2489 | | break; |
| 2490 | | } |
| 2491 | | } |
| 2492 | | |
| 2493 | | /* read internal DSR ROM */ |
| 2494 | | static READ8_HANDLER(ti99_8_internal_dsr_r) |
| 2495 | | { |
| 2496 | | return ti99_8_internal_DSR[offset]; |
| 2497 | | } |
| 2498 | | |
| 2499 | | |
| 2500 | | |
| 2501 | | /*===========================================================================*/ |
| 2502 | | #if 0 |
| 2503 | | #pragma mark - |
| 2504 | | #pragma mark SGCPU INTERNAL DSR |
| 2505 | | #endif |
| 2506 | | /* |
| 2507 | | SNUG SGCPU (a.k.a. 99/4p) internal DSR support. |
| 2508 | | |
| 2509 | | Includes a few specific signals, and an extra ROM. |
| 2510 | | */ |
| 2511 | | |
| 2512 | | /* prototypes */ |
| 2513 | | static void ti99_4p_internal_dsr_cru_w(running_machine *machine, int offset, int data); |
| 2514 | | static READ16_HANDLER(ti99_4p_internal_dsr_r); |
| 2515 | | |
| 2516 | | |
| 2517 | | static const ti99_peb_16bit_card_handlers_t ti99_4p_internal_dsr_handlers = |
| 2518 | | { |
| 2519 | | NULL, |
| 2520 | | ti99_4p_internal_dsr_cru_w, |
| 2521 | | ti99_4p_internal_dsr_r, |
| 2522 | | NULL |
| 1791 | /* clock rate = 3MHz */ |
| 1792 | 3000000. |
| 2523 | 1793 | }; |
| 2524 | 1794 | |
| 2525 | | /* pointer to the internal DSR ROM data */ |
| 2526 | | static UINT16 *ti99_4p_internal_DSR; |
| 2527 | | |
| 2528 | | |
| 2529 | | /* set up handlers, and set initial state */ |
| 2530 | | static void ti99_4p_internal_dsr_reset(running_machine *machine) |
| 2531 | | { |
| 2532 | | UINT8* mem = memory_region(machine, "maincpu"); |
| 2533 | | |
| 2534 | | ti99_4p_internal_DSR = (UINT16 *) (mem + offset_rom4_4p); |
| 2535 | | ti99_4p_internal_ROM6 = (UINT16 *) (mem + offset_rom6_4p); |
| 2536 | | |
| 2537 | | ti99_peb_set_16bit_card_handlers(0x0f00, & ti99_4p_internal_dsr_handlers); |
| 2538 | | |
| 2539 | | ti99_4p_internal_rom6_enable = 0; |
| 2540 | | ti99_4p_peb_set_senila(0); |
| 2541 | | ti99_4p_peb_set_senilb(0); |
| 2542 | | } |
| 2543 | | |
| 2544 | | /* write CRU bit: |
| 2545 | | bit0: enable/disable internal DSR ROM, |
| 2546 | | bit1: enable/disable internal cartridge ROM |
| 2547 | | bit2: set/clear senila |
| 2548 | | bit3: set/clear senilb*/ |
| 2549 | | static void ti99_4p_internal_dsr_cru_w(running_machine *machine, int offset, int data) |
| 2550 | | { |
| 2551 | | switch (offset) |
| 2552 | | { |
| 2553 | | case 1: |
| 2554 | | ti99_4p_internal_rom6_enable = data; |
| 2555 | | break; |
| 2556 | | case 2: |
| 2557 | | ti99_4p_peb_set_senila(data); |
| 2558 | | break; |
| 2559 | | case 3: |
| 2560 | | ti99_4p_peb_set_senilb(data); |
| 2561 | | break; |
| 2562 | | case 4: |
| 2563 | | /* 0: 16-bit (fast) memory timings */ |
| 2564 | | /* 1: 8-bit memory timings */ |
| 2565 | | break; |
| 2566 | | case 5: |
| 2567 | | /* if 0: "KBENA" mode (enable keyboard?) */ |
| 2568 | | /* if 1: "KBINH" mode (inhibit keyboard?) */ |
| 2569 | | break; |
| 2570 | | } |
| 2571 | | } |
| 2572 | | |
| 2573 | | /* read internal DSR ROM */ |
| 2574 | | static READ16_HANDLER(ti99_4p_internal_dsr_r) |
| 2575 | | { |
| 2576 | | return ti99_4p_internal_DSR[offset]; |
| 2577 | | } |
| 2578 | | |
| 2579 | | |
| 2580 | | |
| 2581 | | #if 0 |
| 2582 | | #pragma mark - |
| 2583 | | #pragma mark MEMORY EXPANSION CARDS |
| 2584 | | #endif |
| 2585 | 1795 | /*===========================================================================*/ |
| 2586 | 1796 | /* |
| 2587 | 1797 | TI memory extension support. |
| r8296 | r8297 | |
| 2669 | 1879 | static int sAMS_mapper_on; |
| 2670 | 1880 | static int sAMSlookup[16]; |
| 2671 | 1881 | |
| 2672 | | |
| 2673 | 1882 | /* set up super AMS handlers, and set initial state */ |
| 2674 | 1883 | static void ti99_sAMSxram_init(running_machine *machine) |
| 2675 | 1884 | { |
| r8296 | r8297 | |
| 2757 | 1966 | COMBINE_DATA(xRAM_ptr + offset+0x5000); |
| 2758 | 1967 | } |
| 2759 | 1968 | |
| 2760 | | |
| 2761 | 1969 | /*===========================================================================*/ |
| 2762 | 1970 | /* |
| 2763 | | SNUG SGCPU (a.k.a. 99/4p) Super AMS clone support. |
| 2764 | | Compatible with Super AMS, but uses a 16-bit bus. |
| 2765 | | |
| 2766 | | Up to 1Mb of SRAM. Straightforward mapper, works with 4kb chunks. |
| 2767 | | */ |
| 2768 | | |
| 2769 | | /* prototypes */ |
| 2770 | | static void ti99_4p_mapper_cru_w(running_machine *machine, int offset, int data); |
| 2771 | | static READ16_HANDLER(ti99_4p_mapper_r); |
| 2772 | | static WRITE16_HANDLER(ti99_4p_mapper_w); |
| 2773 | | |
| 2774 | | |
| 2775 | | static const ti99_peb_16bit_card_handlers_t ti99_4p_mapper_handlers = |
| 2776 | | { |
| 2777 | | NULL, |
| 2778 | | ti99_4p_mapper_cru_w, |
| 2779 | | ti99_4p_mapper_r, |
| 2780 | | ti99_4p_mapper_w |
| 2781 | | }; |
| 2782 | | |
| 2783 | | |
| 2784 | | static int ti99_4p_mapper_on; |
| 2785 | | static int ti99_4p_mapper_lookup[16]; |
| 2786 | | |
| 2787 | | |
| 2788 | | /* set up handlers, and set initial state */ |
| 2789 | | static void ti99_4p_mapper_init(running_machine *machine) |
| 2790 | | { |
| 2791 | | int i; |
| 2792 | | char bank_name[10]; |
| 2793 | | /* Not required at run-time */ |
| 2794 | | #if 0 |
| 2795 | | memory_install_read16_handler(space, 0x2000, 0x2fff, SMH_BANK(3)); |
| 2796 | | memory_install_write16_handler(space, 0x2000, 0x2fff, SMH_BANK(3)); |
| 2797 | | memory_install_read16_handler(space, 0x3000, 0x3fff, SMH_BANK(4)); |
| 2798 | | memory_install_write16_handler(space, 0x3000, 0x3fff, SMH_BANK(4)); |
| 2799 | | memory_install_read16_handler(space, 0xa000, 0xafff, SMH_BANK(5)); |
| 2800 | | memory_install_write16_handler(space, 0xa000, 0xafff, SMH_BANK(5)); |
| 2801 | | memory_install_read16_handler(space, 0xb000, 0xbfff, SMH_BANK(6)); |
| 2802 | | memory_install_write16_handler(space, 0xb000, 0xbfff, SMH_BANK(6)); |
| 2803 | | memory_install_read16_handler(space, 0xc000, 0xcfff, SMH_BANK(7)); |
| 2804 | | memory_install_write16_handler(space, 0xc000, 0xcfff, SMH_BANK(7)); |
| 2805 | | memory_install_read16_handler(space, 0xd000, 0xdfff, SMH_BANK(8)); |
| 2806 | | memory_install_write16_handler(space, 0xd000, 0xdfff, SMH_BANK(8)); |
| 2807 | | memory_install_read16_handler(space, 0xe000, 0xefff, SMH_BANK(9)); |
| 2808 | | memory_install_write16_handler(space, 0xe000, 0xefff, SMH_BANK(9)); |
| 2809 | | memory_install_read16_handler(space, 0xf000, 0xffff, SMH_BANK(10)); |
| 2810 | | memory_install_write16_handler(space, 0xf000, 0xffff, SMH_BANK(10)); |
| 2811 | | #endif |
| 2812 | | |
| 2813 | | ti99_peb_set_16bit_card_handlers(0x1e00, & ti99_4p_mapper_handlers); |
| 2814 | | |
| 2815 | | ti99_4p_mapper_on = 0; |
| 2816 | | |
| 2817 | | for (i=0; i<16; i++) |
| 2818 | | { |
| 2819 | | ti99_4p_mapper_lookup[i] = i << 11; |
| 2820 | | |
| 2821 | | /* update bank base */ |
| 2822 | | switch (i) |
| 2823 | | { |
| 2824 | | case 2: |
| 2825 | | case 3: |
| 2826 | | sprintf(bank_name,"bank%d",3+(i-2)); |
| 2827 | | memory_set_bankptr(machine,bank_name, xRAM_ptr + (i<<11)); |
| 2828 | | break; |
| 2829 | | |
| 2830 | | case 10: |
| 2831 | | case 11: |
| 2832 | | case 12: |
| 2833 | | case 13: |
| 2834 | | case 14: |
| 2835 | | case 15: |
| 2836 | | sprintf(bank_name,"bank%d",5+(i-10)); |
| 2837 | | memory_set_bankptr(machine,bank_name, xRAM_ptr + (i<<11)); |
| 2838 | | break; |
| 2839 | | } |
| 2840 | | } |
| 2841 | | } |
| 2842 | | |
| 2843 | | /* write CRU bit: |
| 2844 | | bit0: enable/disable mapper registers in DSR space, |
| 2845 | | bit1: enable/disable address mapping */ |
| 2846 | | static void ti99_4p_mapper_cru_w(running_machine *machine, int offset, int data) |
| 2847 | | { |
| 2848 | | int i; |
| 2849 | | char bank_name[10]; |
| 2850 | | |
| 2851 | | if (offset == 1) |
| 2852 | | { |
| 2853 | | if (ti99_4p_mapper_on != data) |
| 2854 | | { |
| 2855 | | ti99_4p_mapper_on = data; |
| 2856 | | |
| 2857 | | for (i=0; i<16; i++) |
| 2858 | | { |
| 2859 | | /* update bank base */ |
| 2860 | | switch (i) |
| 2861 | | { |
| 2862 | | case 2: |
| 2863 | | case 3: |
| 2864 | | sprintf(bank_name,"bank%d",3+(i-2)); |
| 2865 | | memory_set_bankptr(machine,bank_name, xRAM_ptr + (ti99_4p_mapper_on ? (ti99_4p_mapper_lookup[i]) : (i<<11))); |
| 2866 | | break; |
| 2867 | | |
| 2868 | | case 10: |
| 2869 | | case 11: |
| 2870 | | case 12: |
| 2871 | | case 13: |
| 2872 | | case 14: |
| 2873 | | case 15: |
| 2874 | | sprintf(bank_name,"bank%d",5+(i-10)); |
| 2875 | | memory_set_bankptr(machine,bank_name, xRAM_ptr + (ti99_4p_mapper_on ? (ti99_4p_mapper_lookup[i]) : (i<<11))); |
| 2876 | | break; |
| 2877 | | } |
| 2878 | | } |
| 2879 | | } |
| 2880 | | } |
| 2881 | | |
| 2882 | | } |
| 2883 | | |
| 2884 | | /* read a mapper register */ |
| 2885 | | static READ16_HANDLER(ti99_4p_mapper_r) |
| 2886 | | { |
| 2887 | | return (ti99_4p_mapper_lookup[offset & 0xf] >> 3); |
| 2888 | | } |
| 2889 | | |
| 2890 | | /* write a mapper register */ |
| 2891 | | static WRITE16_HANDLER(ti99_4p_mapper_w) |
| 2892 | | { |
| 2893 | | int page = offset & 0xf; |
| 2894 | | char bank_name[10]; |
| 2895 | | ti99_4p_mapper_lookup[page] = (data & 0xff00) << 3; |
| 2896 | | |
| 2897 | | if (ti99_4p_mapper_on) |
| 2898 | | { |
| 2899 | | /* update bank base */ |
| 2900 | | switch (page) |
| 2901 | | { |
| 2902 | | case 2: |
| 2903 | | case 3: |
| 2904 | | sprintf(bank_name,"bank%d",3+(page-2)); |
| 2905 | | memory_set_bankptr(space->machine,bank_name, xRAM_ptr+ti99_4p_mapper_lookup[page]); |
| 2906 | | break; |
| 2907 | | |
| 2908 | | case 10: |
| 2909 | | case 11: |
| 2910 | | case 12: |
| 2911 | | case 13: |
| 2912 | | case 14: |
| 2913 | | case 15: |
| 2914 | | sprintf(bank_name,"bank%d",5+(page-10)); |
| 2915 | | memory_set_bankptr(space->machine,bank_name, xRAM_ptr+ti99_4p_mapper_lookup[page]); |
| 2916 | | break; |
| 2917 | | } |
| 2918 | | } |
| 2919 | | } |
| 2920 | | |
| 2921 | | |
| 2922 | | /*===========================================================================*/ |
| 2923 | | /* |
| 2924 | 1971 | myarc-ish memory extension support (foundation, and myarc clones). |
| 2925 | 1972 | |
| 2926 | 1973 | Up to 512kb of RAM. Straightforward mapper, works with 32kb chunks. |
| r8296 | r8297 | |
| 2943 | 1990 | NULL |
| 2944 | 1991 | }; |
| 2945 | 1992 | |
| 2946 | | |
| 2947 | 1993 | static int myarc_cur_page_offset; |
| 2948 | 1994 | static int myarc_page_offset_mask; |
| 2949 | 1995 | |
| 2950 | | |
| 2951 | 1996 | /* set up myarc handlers, and set initial state */ |
| 2952 | 1997 | static void ti99_myarcxram_init(running_machine *machine) |
| 2953 | 1998 | { |
| r8296 | r8297 | |
| 3022 | 2067 | static READ16_HANDLER ( ti99_myarcxramlow_r ) |
| 3023 | 2068 | { |
| 3024 | 2069 | cpu_adjust_icount(devtag_get_device(space->machine, "maincpu"),-4); |
| 3025 | | |
| 3026 | 2070 | return xRAM_ptr[myarc_cur_page_offset + offset]; |
| 3027 | 2071 | } |
| 3028 | 2072 | |
| 3029 | 2073 | static WRITE16_HANDLER ( ti99_myarcxramlow_w ) |
| 3030 | 2074 | { |
| 3031 | 2075 | cpu_adjust_icount(devtag_get_device(space->machine, "maincpu"),-4); |
| 3032 | | |
| 3033 | 2076 | COMBINE_DATA(xRAM_ptr + myarc_cur_page_offset + offset); |
| 3034 | 2077 | } |
| 3035 | 2078 | |
| r8296 | r8297 | |
| 3037 | 2080 | static READ16_HANDLER ( ti99_myarcxramhigh_r ) |
| 3038 | 2081 | { |
| 3039 | 2082 | cpu_adjust_icount(devtag_get_device(space->machine, "maincpu"),-4); |
| 3040 | | |
| 3041 | 2083 | return xRAM_ptr[myarc_cur_page_offset + offset+0x1000]; |
| 3042 | 2084 | } |
| 3043 | 2085 | |
| 3044 | 2086 | static WRITE16_HANDLER ( ti99_myarcxramhigh_w ) |
| 3045 | 2087 | { |
| 3046 | 2088 | cpu_adjust_icount(devtag_get_device(space->machine, "maincpu"),-4); |
| 3047 | | |
| 3048 | 2089 | COMBINE_DATA(xRAM_ptr + myarc_cur_page_offset + offset+0x1000); |
| 3049 | 2090 | } |
| 3050 | 2091 | |
| 3051 | 2092 | |
| 3052 | | /*===========================================================================*/ |
| 3053 | | #if 0 |
| 3054 | | #pragma mark - |
| 3055 | | #pragma mark EVPC VIDEO CARD |
| 3056 | | #endif |
| 3057 | | /* |
| 3058 | | SNUG's EVPC emulation |
| 3059 | | */ |
| 2093 | /************************************************************************** |
| 2094 | EVPC (Enhanced Video Processor Card) from SNUG |
| 2095 | based on v9938 (may also be equipped with v9958) |
| 2096 | Can be used with TI-99/4A as an add-on card; internal VDP must be removed |
| 3060 | 2097 | |
| 2098 | The SGCPU ("TI-99/4P") only runs with EVPC. |
| 2099 | ***************************************************************************/ |
| 2100 | |
| 2101 | #include "emuopts.h" |
| 2102 | |
| 3061 | 2103 | /* prototypes */ |
| 3062 | 2104 | static int evpc_cru_r(running_machine *machine, int offset); |
| 3063 | 2105 | static void evpc_cru_w(running_machine *machine, int offset, int data); |
| r8296 | r8297 | |
| 3067 | 2109 | /* pointer to the evpc DSR area */ |
| 3068 | 2110 | static UINT8 *ti99_evpc_DSR; |
| 3069 | 2111 | |
| 3070 | | /* pointer to the evpc novram area */ |
| 3071 | | /*static UINT8 *ti99_evpc_novram;*/ |
| 3072 | | |
| 3073 | 2112 | static int RAMEN; |
| 3074 | | |
| 3075 | 2113 | static int evpc_dsr_page; |
| 3076 | 2114 | |
| 2115 | /* |
| 2116 | NOVRAM area |
| 2117 | */ |
| 2118 | static UINT8 ti99_evpc_novram[256]; |
| 2119 | |
| 3077 | 2120 | static const ti99_peb_card_handlers_t evpc_handlers = |
| 3078 | 2121 | { |
| 3079 | 2122 | evpc_cru_r, |
| r8296 | r8297 | |
| 3082 | 2125 | evpc_mem_w |
| 3083 | 2126 | }; |
| 3084 | 2127 | |
| 2128 | static struct |
| 2129 | { |
| 2130 | UINT8 read_index, write_index, mask; |
| 2131 | int read; |
| 2132 | int state; |
| 2133 | struct { UINT8 red, green, blue; } color[0x100]; |
| 2134 | //int dirty; |
| 2135 | } evpc_palette; |
| 3085 | 2136 | |
| 3086 | 2137 | /* |
| 2138 | NOVRAM handling |
| 2139 | */ |
| 2140 | static void ti99_evpc_load_novram(running_machine *machine, const char *filename) |
| 2141 | { |
| 2142 | file_error filerr; |
| 2143 | mame_file *file; |
| 2144 | |
| 2145 | filerr = mame_fopen(SEARCHPATH_NVRAM, filename, OPEN_FLAG_READ, &file); |
| 2146 | if (filerr == FILERR_NONE) |
| 2147 | { |
| 2148 | if (mame_fread(file, ti99_evpc_novram, 256) != 256) |
| 2149 | logerror("ti99_4ev: NOVRAM load error\n"); |
| 2150 | mame_fclose(file); |
| 2151 | } |
| 2152 | } |
| 2153 | |
| 2154 | static void ti99_evpc_save_novram(running_machine *machine, const char *filename) |
| 2155 | { |
| 2156 | file_error filerr; |
| 2157 | mame_file *file; |
| 2158 | |
| 2159 | filerr = mame_fopen(SEARCHPATH_NVRAM, filename, |
| 2160 | OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &file); |
| 2161 | |
| 2162 | if (filerr == FILERR_NONE) |
| 2163 | { |
| 2164 | if (mame_fwrite(file, ti99_evpc_novram, 256) != 256) |
| 2165 | logerror("ti99_4ev: NOVRAM save error\n"); |
| 2166 | mame_fclose(file); |
| 2167 | } |
| 2168 | } |
| 2169 | |
| 2170 | INPUT_CHANGED( evpc_changed ) |
| 2171 | { |
| 2172 | evpc_switch[(UINT64)param&0x03] = newval; |
| 2173 | } |
| 2174 | |
| 2175 | INTERRUPT_GEN( ti99_4ev_hblank_interrupt ) |
| 2176 | { |
| 2177 | // static int line_count; |
| 2178 | v9938_interrupt(device->machine, 0); |
| 2179 | |
| 2180 | // No Mechatronic Mouse with v9938 (has own mouse) |
| 2181 | /* if (++line_count == 262) |
| 2182 | { |
| 2183 | line_count = 0; |
| 2184 | if (has_mecmouse) |
| 2185 | mecmouse_poll(device->machine); |
| 2186 | } */ |
| 2187 | } |
| 2188 | |
| 2189 | // still unused |
| 2190 | TIMER_DEVICE_CALLBACK( ti99_4ev_scanline_interrupt ) |
| 2191 | { |
| 2192 | v9938_interrupt(timer->machine, 0); |
| 2193 | } |
| 2194 | |
| 2195 | /* |
| 2196 | Video initialization. (also used by SGCPU) |
| 2197 | */ |
| 2198 | VIDEO_START( ti99_4ev ) |
| 2199 | { |
| 2200 | VIDEO_START_CALL(generic_bitmapped); |
| 2201 | v9938_init(machine, 0, machine->primary_screen, machine->generic.tmpbitmap, |
| 2202 | MODEL_V9938, 0x20000, tms9901_set_int2); /* v38 with 128 kb of video RAM */ |
| 2203 | } |
| 2204 | |
| 2205 | /* |
| 2206 | V38 VDP read |
| 2207 | */ |
| 2208 | READ16_HANDLER ( ti99_rv38_r ) |
| 2209 | { |
| 2210 | cpu_adjust_icount(devtag_get_device(space->machine, "maincpu"),-4); |
| 2211 | // cpu_spinuntil_time(space->machine->firstcpu, ATTOTIME_IN_USEC(6)); |
| 2212 | |
| 2213 | if (offset & 1) |
| 2214 | { /* read VDP status */ |
| 2215 | return ((int) v9938_0_status_r(space, 0)) << 8; |
| 2216 | } |
| 2217 | else |
| 2218 | { /* read VDP RAM */ |
| 2219 | return ((int) v9938_0_vram_r(space, 0)) << 8; |
| 2220 | } |
| 2221 | } |
| 2222 | |
| 2223 | /* |
| 2224 | V38 vdp write |
| 2225 | */ |
| 2226 | WRITE16_HANDLER ( ti99_wv38_w ) |
| 2227 | { |
| 2228 | cpu_adjust_icount(devtag_get_device(space->machine, "maincpu"),-4); |
| 2229 | // cpu_spinuntil_time(space->machine->firstcpu, ATTOTIME_IN_USEC(6)); |
| 2230 | |
| 2231 | switch (offset & 3) |
| 2232 | { |
| 2233 | case 0: |
| 2234 | /* write VDP data */ |
| 2235 | v9938_0_vram_w(space, 0, (data >> 8) & 0xff); |
| 2236 | break; |
| 2237 | case 1: |
| 2238 | /* write VDP address */ |
| 2239 | v9938_0_command_w(space, 0, (data >> 8) & 0xff); |
| 2240 | break; |
| 2241 | case 2: |
| 2242 | /* write VDP palette */ |
| 2243 | v9938_0_palette_w(space, 0, (data >> 8) & 0xff); |
| 2244 | break; |
| 2245 | case 3: |
| 2246 | /* write VDP register pointer (indirect access) */ |
| 2247 | v9938_0_register_w(space, 0, (data >> 8) & 0xff); |
| 2248 | break; |
| 2249 | } |
| 2250 | } |
| 2251 | |
| 2252 | /* |
| 3087 | 2253 | Reset evpc card, set up handlers |
| 3088 | 2254 | */ |
| 3089 | 2255 | static void ti99_evpc_reset(running_machine *machine) |
| r8296 | r8297 | |
| 3097 | 2263 | } |
| 3098 | 2264 | |
| 3099 | 2265 | /* |
| 3100 | | Read evpc CRU interface |
| 2266 | Read EVPC CRU interface (dip switches) |
| 2267 | 0: Video timing (PAL/NTSC) |
| 2268 | 1: - |
| 2269 | 2: charset |
| 2270 | 3: RAM shift |
| 2271 | 4: - |
| 2272 | 5: - |
| 2273 | 6: - |
| 2274 | 7: DIP or NOVRAM |
| 2275 | Logic is inverted |
| 3101 | 2276 | */ |
| 3102 | 2277 | static int evpc_cru_r(running_machine *machine, int offset) |
| 3103 | 2278 | { |
| 3104 | | return 0; /* dip-switch value */ |
| 2279 | UINT8 value = 0; |
| 2280 | |
| 2281 | if (offset == 0) |
| 2282 | value = ~(evpc_switch[0] | (evpc_switch[1]<<2) | (evpc_switch[2]<<3) | (evpc_switch[3]<<7)); |
| 2283 | |
| 2284 | return value; |
| 3105 | 2285 | } |
| 3106 | 2286 | |
| 3107 | 2287 | /* |
| r8296 | r8297 | |
| 3150 | 2330 | } |
| 3151 | 2331 | } |
| 3152 | 2332 | |
| 3153 | | |
| 3154 | | static struct |
| 3155 | | { |
| 3156 | | UINT8 read_index, write_index, mask; |
| 3157 | | int read; |
| 3158 | | int state; |
| 3159 | | struct { UINT8 red, green, blue; } color[0x100]; |
| 3160 | | //int dirty; |
| 3161 | | } evpc_palette; |
| 3162 | | |
| 3163 | 2333 | /* |
| 3164 | 2334 | read a byte in evpc DSR space |
| 3165 | 2335 | */ |
| r8296 | r8297 | |
| 3167 | 2337 | { |
| 3168 | 2338 | UINT8 reply = 0; |
| 3169 | 2339 | |
| 3170 | | |
| 3171 | 2340 | if (offset < 0x1f00) |
| 3172 | 2341 | { |
| 3173 | 2342 | reply = ti99_evpc_DSR[offset+evpc_dsr_page*0x2000]; |
| r8296 | r8297 | |
| 3175 | 2344 | else if (offset < 0x1ff0) |
| 3176 | 2345 | { |
| 3177 | 2346 | if (RAMEN) |
| 3178 | | { /* NOVRAM */ |
| 3179 | | reply = 0; |
| 2347 | { |
| 2348 | reply = ti99_evpc_novram[offset-0x1f00]; |
| 3180 | 2349 | } |
| 3181 | 2350 | else |
| 3182 | 2351 | { |
| r8296 | r8297 | |
| 3185 | 2354 | } |
| 3186 | 2355 | else |
| 3187 | 2356 | { /* PALETTE */ |
| 3188 | | logerror("palette read, offset=%d\n", offset-0x1ff0); |
| 3189 | 2357 | switch (offset - 0x1ff0) |
| 3190 | 2358 | { |
| 3191 | 2359 | case 0: |
| 3192 | 2360 | /* Palette Read Address Register */ |
| 3193 | | logerror("EVPC palette address read\n"); |
| 3194 | 2361 | reply = evpc_palette.write_index; |
| 3195 | 2362 | break; |
| 3196 | 2363 | |
| 3197 | 2364 | case 2: |
| 3198 | 2365 | /* Palette Read Color Value */ |
| 3199 | | logerror("EVPC palette color read\n"); |
| 3200 | 2366 | if (evpc_palette.read) |
| 3201 | 2367 | { |
| 3202 | 2368 | switch (evpc_palette.state) |
| r8296 | r8297 | |
| 3222 | 2388 | |
| 3223 | 2389 | case 4: |
| 3224 | 2390 | /* Palette Read Pixel Mask */ |
| 3225 | | logerror("EVPC palette mask read\n"); |
| 3226 | 2391 | reply = evpc_palette.mask; |
| 3227 | 2392 | break; |
| 3228 | 2393 | case 6: |
| 3229 | 2394 | /* Palette Read Address Register for Color Value */ |
| 3230 | | logerror("EVPC palette status read\n"); |
| 3231 | 2395 | if (evpc_palette.read) |
| 3232 | 2396 | reply = 0; |
| 3233 | 2397 | else |
| r8296 | r8297 | |
| 3245 | 2409 | static WRITE8_HANDLER(evpc_mem_w) |
| 3246 | 2410 | { |
| 3247 | 2411 | if ((offset >= 0x1f00) && (offset < 0x1ff0) && RAMEN) |
| 3248 | | { /* NOVRAM */ |
| 2412 | { |
| 2413 | // NOVRAM |
| 2414 | ti99_evpc_novram[offset-0x1f00] = data; |
| 3249 | 2415 | } |
| 3250 | 2416 | else if (offset >= 0x1ff0) |
| 3251 | 2417 | { /* PALETTE */ |
| r8296 | r8297 | |
| 3304 | 2470 | } |
| 3305 | 2471 | } |
| 3306 | 2472 | |
| 3307 | | /* tms9901 setup */ |
| 3308 | | const tms9901_interface tms9901reset_param_ti99_4x = |
| 2473 | /************************************************************************** |
| 2474 | TI-99/8 |
| 2475 | ***************************************************************************/ |
| 2476 | |
| 2477 | DRIVER_INIT( ti99_8 ) |
| 3309 | 2478 | { |
| 3310 | | TMS9901_INT1 | TMS9901_INT2 | TMS9901_INTC, /* only input pins whose state is always known */ |
| 2479 | UINT8 *mem = memory_region(machine, "maincpu"); |
| 2480 | ti99_model = model_99_8; |
| 2481 | has_evpc = FALSE; |
| 3311 | 2482 | |
| 3312 | | { /* read handlers */ |
| 3313 | | ti99_R9901_0, |
| 3314 | | ti99_R9901_1, |
| 3315 | | ti99_R9901_2, |
| 3316 | | ti99_R9901_3 |
| 3317 | | }, |
| 2483 | /* set up memory pointers */ |
| 2484 | xRAM_ptr_8 = mem + offset_xram_8; |
| 2485 | ROM0_ptr_8 = mem + offset_rom0_8; |
| 2486 | ROM1_ptr_8 = ROM0_ptr_8 + 0x2000; |
| 2487 | ROM2_ptr_8 = ROM1_ptr_8 + 0x2000; |
| 2488 | ROM3_ptr_8 = ROM2_ptr_8 + 0x2000; |
| 2489 | sRAM_ptr_8 = mem + offset_sram_8; |
| 3318 | 2490 | |
| 3319 | | { /* write handlers */ |
| 3320 | | ti99_handset_set_ack, |
| 3321 | | NULL, |
| 3322 | | ti99_KeyC, |
| 3323 | | ti99_KeyC, |
| 3324 | | ti99_KeyC, |
| 3325 | | ti99_AlphaW, |
| 3326 | | ti99_CS_motor, |
| 3327 | | ti99_CS_motor, |
| 3328 | | ti99_audio_gate, |
| 3329 | | ti99_CS_output, |
| 3330 | | NULL, |
| 3331 | | NULL, |
| 3332 | | NULL, |
| 3333 | | NULL, |
| 3334 | | NULL, |
| 3335 | | NULL |
| 3336 | | }, |
| 2491 | /* Pull this one up here. */ |
| 2492 | ti99_8_enable_rom_and_ports = 1; |
| 3337 | 2493 | |
| 3338 | | /* interrupt handler */ |
| 3339 | | tms9901_interrupt_callback, |
| 2494 | console_GROMs.data_ptr = memory_region(machine, region_grom); |
| 2495 | create_grom_high2k(0x0000, 0x5fff); |
| 3340 | 2496 | |
| 3341 | | /* clock rate = 3MHz */ |
| 3342 | | 3000000. |
| 2497 | multicart8 = devtag_get_device(machine, "ti99_multicart"); |
| 2498 | assert (multicart8 != NULL); |
| 2499 | } |
| 2500 | |
| 2501 | /* |
| 2502 | ti99_init_machine(); called before ti99_load_rom... |
| 2503 | */ |
| 2504 | MACHINE_RESET( ti99_8 ) |
| 2505 | { |
| 2506 | /*console_GROMs.data_ptr = memory_region(machine, region_grom);*/ |
| 2507 | console_GROMs.addr = 0; |
| 2508 | console_GROMs.buf = 0; |
| 2509 | console_GROMs.raddr_LSB = FALSE; |
| 2510 | console_GROMs.waddr_LSB = FALSE; |
| 2511 | |
| 2512 | ti99_8_enable_rom_and_ports = 1; /* ??? maybe there is a pull-up */ |
| 2513 | /* MZ: already setting this in driver init, otherwise machine locks up */ |
| 2514 | |
| 2515 | TMS9928A_reset(); |
| 2516 | |
| 2517 | /* clear keyboard interface state (probably overkill, but can't harm) */ |
| 2518 | KeyCol = 0; |
| 2519 | AlphaLockLine = 0; |
| 2520 | |
| 2521 | tms9901_set_single_int(devtag_get_device(machine, "tms9901"), 12, 0); |
| 2522 | |
| 2523 | xRAM_kind = RAM_99_8; |
| 2524 | has_speech = TRUE; |
| 2525 | has_ide = input_port_read(machine, "HDCTRL") & HD_IDE; |
| 2526 | has_rs232 = input_port_read(machine, "SERIAL") & SERIAL_TI; |
| 2527 | has_handset = FALSE; |
| 2528 | |
| 2529 | has_mecmouse = input_port_read(machine, "HCI") & HCI_MECMOUSE; |
| 2530 | |
| 2531 | has_hsgpl = input_port_read(machine, "EXTCARD") & (EXT_HSGPL_ON | EXT_HSGPL_FLASH); |
| 2532 | hsgpl_flash_mode = input_port_read(machine, "EXTCARD") & EXT_HSGPL_FLASH; |
| 2533 | |
| 2534 | has_usb_sm = input_port_read(machine, "HDCTRL") & HD_USB; |
| 2535 | has_pcode = input_port_read(machine, "EXTCARD") & EXT_PCODE; |
| 2536 | |
| 2537 | /* Get the GK settings once */ |
| 2538 | gk_switch[1] = input_port_read(machine, "GKSWITCH1"); |
| 2539 | gk_switch[2] = input_port_read(machine, "GKSWITCH2"); |
| 2540 | gk_switch[3] = input_port_read(machine, "GKSWITCH3"); |
| 2541 | gk_switch[4] = input_port_read(machine, "GKSWITCH4"); |
| 2542 | gk_switch[5] = input_port_read(machine, "GKSWITCH5"); |
| 2543 | |
| 2544 | // Removes all card handlers |
| 2545 | ti99_peb_init(); |
| 2546 | |
| 2547 | // set up optional expansion hardware |
| 2548 | ti99_peb_reset(FALSE, tms9901_set_int1, NULL); |
| 2549 | |
| 2550 | ti99_8_internal_dsr_reset(machine); |
| 2551 | |
| 2552 | static const spchroms_interface speech_intf = { region_speech_rom }; |
| 2553 | spchroms_config(machine, &speech_intf); |
| 2554 | |
| 2555 | switch (input_port_read(machine, "DISKCTRL")) |
| 2556 | { |
| 2557 | case DISK_TIFDC: |
| 2558 | ti99_fdc_reset(machine); |
| 2559 | break; |
| 2560 | #if HAS_99CCFDC |
| 2561 | case DISK_CC: |
| 2562 | ti99_ccfdc_reset(machine); |
| 2563 | break; |
| 2564 | #endif |
| 2565 | case DISK_BWG: |
| 2566 | ti99_bwg_reset(machine); |
| 2567 | break; |
| 2568 | case DISK_HFDC: |
| 2569 | ti99_hfdc_reset(machine); |
| 2570 | break; |
| 2571 | case DISK_NONE: |
| 2572 | break; |
| 2573 | } |
| 2574 | |
| 2575 | if (has_ide) |
| 2576 | ti99_ide_reset(machine, TRUE); |
| 2577 | |
| 2578 | if (has_hsgpl) |
| 2579 | ti99_hsgpl_reset(machine); |
| 2580 | else |
| 2581 | hsgpl_crdena = 0; |
| 2582 | |
| 2583 | if (has_usb_sm) |
| 2584 | ti99_usbsm_reset(machine, TRUE); |
| 2585 | |
| 2586 | if (has_pcode) |
| 2587 | ti99_pcode_reset(machine); |
| 2588 | |
| 2589 | /* initialize mechatronics mouse */ |
| 2590 | mecmouse_sel = 0; |
| 2591 | mecmouse_read_y = 0; |
| 2592 | mecmouse_x = 0; |
| 2593 | mecmouse_y = 0; |
| 2594 | } |
| 2595 | |
| 2596 | /* |
| 2597 | GROM read for TI-99/8 |
| 2598 | For comments, see the handler for TI-99/4A |
| 2599 | */ |
| 2600 | static READ8_HANDLER ( ti99_grom_r8 ) |
| 2601 | { |
| 2602 | UINT8 reply, replycart; |
| 2603 | |
| 2604 | cpu_adjust_icount(space->machine->firstcpu,-4); |
| 2605 | |
| 2606 | if (offset & 2) |
| 2607 | { |
| 2608 | replycart = ti99_cartridge_grom_r(cartslots, offset); |
| 2609 | console_GROMs.waddr_LSB = FALSE; |
| 2610 | |
| 2611 | if (console_GROMs.raddr_LSB) |
| 2612 | { |
| 2613 | reply = console_GROMs.addr & 0x00ff; |
| 2614 | console_GROMs.raddr_LSB = FALSE; |
| 2615 | } |
| 2616 | else |
| 2617 | { |
| 2618 | reply = (console_GROMs.addr>>8) & 0x00ff; |
| 2619 | console_GROMs.raddr_LSB = TRUE; |
| 2620 | } |
| 2621 | /* GROM address values must be globally unique. */ |
| 2622 | assert (replycart == reply); |
| 2623 | } |
| 2624 | else |
| 2625 | { |
| 2626 | reply = GROM_dataread(space->machine, offset); |
| 2627 | } |
| 2628 | return reply; |
| 2629 | } |
| 2630 | |
| 2631 | /* |
| 2632 | GROM write for TI-99/8 |
| 2633 | For comments, see the handler for TI-99/4A |
| 2634 | */ |
| 2635 | static WRITE8_HANDLER ( ti99_grom_w8 ) |
| 2636 | { |
| 2637 | cpu_adjust_icount(space->machine->firstcpu,-4/*20+3*/); /* from 4 to 23? */ |
| 2638 | |
| 2639 | if (offset & 2) |
| 2640 | { |
| 2641 | ti99_cartridge_grom_w(cartslots, offset, data); |
| 2642 | console_GROMs.raddr_LSB = FALSE; |
| 2643 | if (console_GROMs.waddr_LSB) |
| 2644 | { |
| 2645 | console_GROMs.addr = (console_GROMs.addr & 0xFF00) | (data & 0xFF); |
| 2646 | |
| 2647 | GROM_dataread(space->machine, offset&0xfffc); |
| 2648 | console_GROMs.waddr_LSB = FALSE; |
| 2649 | } |
| 2650 | else |
| 2651 | { |
| 2652 | console_GROMs.addr = ((data<<8) & 0xFF00) | (console_GROMs.addr & 0xFF); |
| 2653 | console_GROMs.waddr_LSB = TRUE; |
| 2654 | } |
| 2655 | |
| 2656 | } |
| 2657 | else |
| 2658 | { |
| 2659 | GRAM_datawrite(offset, (data>>8)&0xff); |
| 2660 | console_GROMs.raddr_LSB = console_GROMs.waddr_LSB = FALSE; |
| 2661 | } |
| 2662 | } |
| 2663 | |
| 2664 | READ8_HANDLER( ti99_8_r ) |
| 2665 | { |
| 2666 | /* Set the page. Page size is 4 KiB; page number are the high 4 bits. */ |
| 2667 | int page = offset >> 12; |
| 2668 | UINT32 mapper_reg; |
| 2669 | UINT8 reply = 0; |
| 2670 | |
| 2671 | if (ti99_8_enable_rom_and_ports) |
| 2672 | { |
| 2673 | // This is only important for address access 0000-1fff and |
| 2674 | // 8000-9fff. Outside, the mapper mode is used. |
| 2675 | if ((offset >= 0x0000) && (offset < 0x2000)) |
| 2676 | { |
| 2677 | /* ROM */ |
| 2678 | reply = ROM0_ptr_8[offset & 0x1fff]; |
| 2679 | return reply; |
| 2680 | } |
| 2681 | else if ((offset >= 0x8000) && (offset < 0xa000)) |
| 2682 | { |
| 2683 | /* ti99 scratch pad and memory-mapped registers */ |
| 2684 | /* 0x8000-0x9fff */ |
| 2685 | switch ((offset - 0x8000) >> 10) |
| 2686 | { |
| 2687 | case 0: |
| 2688 | /* RAM: >8000 - >83ff */ |
| 2689 | reply = sRAM_ptr_8[offset & 0x1fff]; |
| 2690 | break; |
| 2691 | |
| 2692 | case 1: |
| 2693 | // >8400 - >840f: sound (cannot read) |
| 2694 | // >8410 - >87ff: SRAM |
| 2695 | if (offset >= 0x8410) |
| 2696 | reply = sRAM_ptr_8[offset & 0x1fff]; |
| 2697 | break; |
| 2698 | |
| 2699 | case 2: |
| 2700 | /* VDP read + mapper status */ |
| 2701 | if (offset < 0x8810) |
| 2702 | { |
| 2703 | if (! (offset & 1)) |
| 2704 | { |
| 2705 | if (offset & 2) |
| 2706 | /* read VDP status >8802 */ |
| 2707 | reply = TMS9928A_register_r(space, 0); |
| 2708 | else |
| 2709 | /* read VDP RAM >8800 */ |
| 2710 | reply = TMS9928A_vram_r(space, 0); |
| 2711 | } |
| 2712 | } |
| 2713 | else |
| 2714 | { |
| 2715 | /* Read mapper >8810 */ |
| 2716 | reply = ti99_8_mapper_status; |
| 2717 | ti99_8_mapper_status = 0; |
| 2718 | } |
| 2719 | break; |
| 2720 | |
| 2721 | case 4: |
| 2722 | /* speech read: >9000 */ |
| 2723 | if (! (offset & 1)) |
| 2724 | { |
| 2725 | cpu_adjust_icount(devtag_get_device(space->machine, "maincpu"),-16*4); /* this is just a minimum, it can be more */ |
| 2726 | reply = tms5220_status_r(devtag_get_device(space->machine, "tms5220"), 0); |
| 2727 | } |
| 2728 | break; |
| 2729 | |
| 2730 | case 6: |
| 2731 | /* GROM read: >9800 */ |
| 2732 | if (! (offset & 1)) |
| 2733 | reply = ti99_grom_r8(space, offset); |
| 2734 | break; |
| 2735 | |
| 2736 | default: |
| 2737 | logerror("unmapped read offs=%d\n", (int) offset); |
| 2738 | break; |
| 2739 | } |
| 2740 | return reply; |
| 2741 | } |
| 2742 | } |
| 2743 | |
| 2744 | mapper_reg = ti99_8_mapper_regs[page]; |
| 2745 | offset = (mapper_reg + (offset & 0x0fff)) & 0x00ffffff; |
| 2746 | |
| 2747 | if (offset < 0x010000) |
| 2748 | /* Read RAM */ |
| 2749 | reply = xRAM_ptr_8[offset]; |
| 2750 | |
| 2751 | if (offset >= 0xff0000) |
| 2752 | { |
| 2753 | switch ((offset >> 13) & 7) |
| 2754 | { |
| 2755 | default: |
| 2756 | /* should never happen */ |
| 2757 | case 0: |
| 2758 | /* ff0000 - ff1fff: unassigned? */ |
| 2759 | case 1: |
| 2760 | /* ff2000 - ff3fff: ? */ |
| 2761 | case 4: |
| 2762 | /* ff8000 - ff9fff: internal DSR ROM? (normally enabled with a write to CRU >2700) */ |
| 2763 | case 7: |
| 2764 | /* ffe000 - ffffff: ? */ |
| 2765 | logerror("unmapped read page=%d offs=%d\n", (int) page, (int) offset); |
| 2766 | break; |
| 2767 | |
| 2768 | case 2: |
| 2769 | /* ff4000 - ff5fff: DSR space */ |
| 2770 | reply = ti99_8_peb_r(space, offset & 0x1fff); |
| 2771 | break; |
| 2772 | |
| 2773 | case 3: |
| 2774 | /* ff6000 - ff7fff: cartridge ROM space */ |
| 2775 | offset &= 0x1fff; |
| 2776 | |
| 2777 | // We do not support hsgpl here. Just check the cartridges. |
| 2778 | reply = ti99_multicart8_r(multicart8, offset); |
| 2779 | break; |
| 2780 | |
| 2781 | case 5: |
| 2782 | /* ffa000 - ffbfff: >2000 ROM (ROM1) */ |
| 2783 | reply = ROM1_ptr_8[offset & 0x1fff]; |
| 2784 | break; |
| 2785 | |
| 2786 | case 6: |
| 2787 | /* ffc000 - ffdfff: >6000 ROM */ |
| 2788 | reply = ROM3_ptr_8[offset & 0x1fff]; |
| 2789 | break; |
| 2790 | } |
| 2791 | } |
| 2792 | |
| 2793 | return reply; |
| 2794 | } |
| 2795 | |
| 2796 | WRITE8_HANDLER ( ti99_8_w ) |
| 2797 | { |
| 2798 | int page = offset >> 12; |
| 2799 | UINT32 mapper_reg; |
| 2800 | |
| 2801 | if (ti99_8_enable_rom_and_ports) |
| 2802 | { |
| 2803 | /* memory mapped ports enabled */ |
| 2804 | if ((offset >= 0x0000) && (offset < 0x2000)) |
| 2805 | { |
| 2806 | /* ROM? */ |
| 2807 | return; |
| 2808 | } |
| 2809 | else if ((offset >= 0x8000) && (offset < 0xa000)) |
| 2810 | { |
| 2811 | /* ti99 scratch pad and memory-mapped registers */ |
| 2812 | /* 0x8000-0x9fff */ |
| 2813 | switch ((offset - 0x8000) >> 10) |
| 2814 | { |
| 2815 | case 0: |
| 2816 | /* RAM */ |
| 2817 | sRAM_ptr_8[offset & 0x1fff] = data; |
| 2818 | break; |
| 2819 | |
| 2820 | case 1: |
| 2821 | /* sound write + RAM */ |
| 2822 | if (offset < 0x8410) |
| 2823 | sn76496_w(devtag_get_device(space->machine, "sn76496"), offset, data); |
| 2824 | else |
| 2825 | sRAM_ptr_8[offset & 0x1fff] = data; |
| 2826 | break; |
| 2827 | |
| 2828 | case 2: |
| 2829 | /* VDP read + mapper control */ |
| 2830 | if (offset >= 0x8810) |
| 2831 | { |
| 2832 | int file = (data >> 1) & 3; |
| 2833 | int i; |
| 2834 | |
| 2835 | if (data & 1) |
| 2836 | { /* load */ |
| 2837 | for (i=0; i<16; i++) |
| 2838 | { |
| 2839 | ti99_8_mapper_regs[i] = (sRAM_ptr_8[(file << 6) + (i << 2)] << 24) |
| 2840 | | (sRAM_ptr_8[(file << 6) + (i << 2) + 1] << 16) |
| 2841 | | (sRAM_ptr_8[(file << 6) + (i << 2) + 2] << 8) |
| 2842 | | sRAM_ptr_8[(file << 6) + (i << 2) + 3]; |
| 2843 | } |
| 2844 | } |
| 2845 | else |
| 2846 | { /* save */ |
| 2847 | for (i=0; i<16; i++) |
| 2848 | { |
| 2849 | sRAM_ptr_8[(file << 6) + (i << 2)] = ti99_8_mapper_regs[i] >> 24; |
| 2850 | sRAM_ptr_8[(file << 6) + (i << 2) + 1] = ti99_8_mapper_regs[i] >> 16; |
| 2851 | sRAM_ptr_8[(file << 6) + (i << 2) + 2] = ti99_8_mapper_regs[i] >> 8; |
| 2852 | sRAM_ptr_8[(file << 6) + (i << 2) + 3] = ti99_8_mapper_regs[i]; |
| 2853 | } |
| 2854 | } |
| 2855 | } |
| 2856 | break; |
| 2857 | |
| 2858 | case 3: |
| 2859 | /* VDP write */ |
| 2860 | if (! (offset & 1)) |
| 2861 | { |
| 2862 | if (offset & 2) |
| 2863 | /* read VDP status */ |
| 2864 | TMS9928A_register_w(space, 0, data); |
| 2865 | else |
| 2866 | /* read VDP RAM */ |
| 2867 | TMS9928A_vram_w(space, 0, data); |
| 2868 | } |
| 2869 | break; |
| 2870 | |
| 2871 | case 5: |
| 2872 | /* speech write */ |
| 2873 | if (! (offset & 1)) |
| 2874 | { |
| 2875 | cpu_adjust_icount(devtag_get_device(space->machine, "maincpu"),-48*4); /* this is just an approx. minimum, it can be much more */ |
| 2876 | |
| 2877 | // the stupid design of the tms5220 core means that ready is cleared when |
| 2878 | // there are 15 bytes in FIFO. It should be 16. Of course, if it were the |
| 2879 | // case, we would need to store the value on the bus, which would be more |
| 2880 | // complex. |
| 2881 | if (! tms5220_readyq_r(devtag_get_device(space->machine, "tms5220"))) |
| 2882 | { |
| 2883 | attotime time_to_ready = double_to_attotime(tms5220_time_to_ready(devtag_get_device(space->machine, "tms5220"))); |
| 2884 | double d = cputag_attotime_to_clocks(space->machine, "maincpu", time_to_ready); |
| 2885 | int cycles_to_ready = ((int) (d + 3)) & ~3; |
| 2886 | |
| 2887 | logerror("time to ready: %f -> %d\n", attotime_to_double(time_to_ready) |
| 2888 | , (int) cycles_to_ready); |
| 2889 | |
| 2890 | cpu_adjust_icount(devtag_get_device(space->machine, "maincpu"),-cycles_to_ready); |
| 2891 | timer_set(space->machine, attotime_zero, NULL, 0, /*speech_kludge_callback*/NULL); |
| 2892 | } |
| 2893 | |
| 2894 | tms5220_data_w(devtag_get_device(space->machine, "tms5220"), offset, data); |
| 2895 | } |
| 2896 | break; |
| 2897 | |
| 2898 | case 7: |
| 2899 | /* GPL write */ |
| 2900 | if (! (offset & 1)) |
| 2901 | ti99_grom_w8(space, offset, data); |
| 2902 | break; |
| 2903 | |
| 2904 | default: |
| 2905 | logerror("unmapped write offs=%d data=%d\n", (int) offset, (int) data); |
| 2906 | break; |
| 2907 | } |
| 2908 | return; |
| 2909 | } |
| 2910 | } |
| 2911 | |
| 2912 | mapper_reg = ti99_8_mapper_regs[page]; |
| 2913 | |
| 2914 | /* 4 KiB page size */ |
| 2915 | offset = (mapper_reg + (offset & 0x0fff)) & 0x00ffffff; |
| 2916 | |
| 2917 | #if 0 |
| 2918 | /* test write protect */ |
| 2919 | if (mapper_reg & 0x80000000) |
| 2920 | ; |
| 2921 | #endif |
| 2922 | |
| 2923 | if (offset < 0x010000) |
| 2924 | { /* Write RAM */ |
| 2925 | xRAM_ptr_8[offset] = data; |
| 2926 | } |
| 2927 | else if (offset >= 0xff0000) |
| 2928 | { |
| 2929 | switch ((offset >> 13) & 7) |
| 2930 | { |
| 2931 | default: |
| 2932 | /* should never happen */ |
| 2933 | case 0: |
| 2934 | /* unassigned??? */ |
| 2935 | case 1: |
| 2936 | /* ??? */ |
| 2937 | case 4: |
| 2938 | /* internal DSR ROM??? (normally enabled with a write to CRU >2700) */ |
| 2939 | case 7: |
| 2940 | /* ??? */ |
| 2941 | break; |
| 2942 | |
| 2943 | case 2: |
| 2944 | /* DSR space */ |
| 2945 | ti99_8_peb_w(space, offset & 0x1fff, data); |
| 2946 | break; |
| 2947 | |
| 2948 | case 3: |
| 2949 | /* cartridge space */ |
| 2950 | /* We do not support HSGPL for the 99/8 at this time. */ |
| 2951 | ti99_multicart8_w(multicart8, offset & 0x1fff, data); |
| 2952 | break; |
| 2953 | |
| 2954 | case 5: |
| 2955 | /* >2000 ROM (ROM1) */ |
| 2956 | break; |
| 2957 | |
| 2958 | case 6: |
| 2959 | /* >6000 ROM */ |
| 2960 | break; |
| 2961 | } |
| 2962 | } |
| 2963 | else |
| 2964 | { |
| 2965 | logerror("unmapped write page=%d offs=%d\n", (int) page, (int) offset); |
| 2966 | } |
| 2967 | } |
| 2968 | |
| 2969 | /* |
| 2970 | WRITE key column select (P0-P3) |
| 2971 | */ |
| 2972 | static WRITE8_DEVICE_HANDLER( ti99_8_KeyC ) |
| 2973 | { |
| 2974 | if (data) |
| 2975 | KeyCol |= 1 << offset; |
| 2976 | else |
| 2977 | KeyCol &= ~ (1 << offset); |
| 2978 | |
| 2979 | if (has_mecmouse) |
| 2980 | mecmouse_select(KeyCol, 14, 15); |
| 2981 | } |
| 2982 | |
| 2983 | static WRITE8_DEVICE_HANDLER( ti99_8_WCRUS ) |
| 2984 | { |
| 2985 | ti99_8_enable_rom_and_ports = data; |
| 2986 | } |
| 2987 | |
| 2988 | static WRITE8_DEVICE_HANDLER( ti99_8_PTGEN ) |
| 2989 | { |
| 2990 | /* ... */ |
| 2991 | } |
| 2992 | |
| 2993 | /* |
| 2994 | TI 99/8 internal DSR support. |
| 2995 | Includes a few specific signals, and an extra ROM. |
| 2996 | */ |
| 2997 | |
| 2998 | /* prototypes */ |
| 2999 | static void ti99_8_internal_dsr_cru_w(running_machine *machine, int offset, int data); |
| 3000 | static READ8_HANDLER(ti99_8_internal_dsr_r); |
| 3001 | |
| 3002 | |
| 3003 | static const ti99_peb_card_handlers_t ti99_8_internal_dsr_handlers = |
| 3004 | { |
| 3005 | NULL, |
| 3006 | ti99_8_internal_dsr_cru_w, |
| 3007 | ti99_8_internal_dsr_r, |
| 3008 | NULL |
| 3343 | 3009 | }; |
| 3344 | 3010 | |
| 3011 | /* pointer to the internal DSR ROM data */ |
| 3012 | static UINT8 *ti99_8_internal_DSR; |
| 3013 | |
| 3014 | |
| 3015 | /* set up handlers, and set initial state */ |
| 3016 | static void ti99_8_internal_dsr_reset(running_machine *machine) |
| 3017 | { |
| 3018 | ti99_8_internal_DSR = memory_region(machine, "maincpu") + offset_rom0_8 + 0x4000; |
| 3019 | |
| 3020 | ti99_peb_set_card_handlers(0x2700, & ti99_8_internal_dsr_handlers); |
| 3021 | } |
| 3022 | |
| 3023 | /* write CRU bit: |
| 3024 | bit0: enable/disable internal DSR ROM, |
| 3025 | bit1: hard reset */ |
| 3026 | static void ti99_8_internal_dsr_cru_w(running_machine *machine, int offset, int data) |
| 3027 | { |
| 3028 | switch (offset) |
| 3029 | { |
| 3030 | case 1: |
| 3031 | /* hard reset -- not emulated */ |
| 3032 | break; |
| 3033 | } |
| 3034 | } |
| 3035 | |
| 3036 | /* read internal DSR ROM */ |
| 3037 | static READ8_HANDLER(ti99_8_internal_dsr_r) |
| 3038 | { |
| 3039 | return ti99_8_internal_DSR[offset]; |
| 3040 | } |
| 3041 | |
| 3042 | /* |
| 3043 | Read pins INT3*-INT7* of TI99's 9901. |
| 3044 | |
| 3045 | signification: |
| 3046 | (bit 1: INT1 status) |
| 3047 | (bit 2: INT2 status) |
| 3048 | bits 3-4: unused? |
| 3049 | bit 5: ??? |
| 3050 | bit 6-7: keyboard status bits 0 through 1 |
| 3051 | */ |
| 3052 | static READ8_DEVICE_HANDLER( ti99_8_R9901_0 ) |
| 3053 | { |
| 3054 | int answer; |
| 3055 | static const char *const keynames[] = { |
| 3056 | "KEY0", "KEY1", "KEY2", "KEY3", "KEY4", "KEY5", "KEY6", "KEY7", |
| 3057 | "KEY8", "KEY9", "KEY10", "KEY11", "KEY12", "KEY13", "KEY14", "KEY15" |
| 3058 | }; |
| 3059 | |
| 3060 | if (has_mecmouse && (KeyCol == 15)) |
| 3061 | { |
| 3062 | int buttons = input_port_read(device->machine, "MOUSE0") & 3; |
| 3063 | |
| 3064 | answer = ((mecmouse_read_y ? mecmouse_y_buf : mecmouse_x_buf) << 7) & 0x80; |
| 3065 | |
| 3066 | if (! (buttons & 1)) |
| 3067 | /* action button */ |
| 3068 | answer |= 0x40; |
| 3069 | } |
| 3070 | else |
| 3071 | { |
| 3072 | answer = (input_port_read(device->machine, keynames[KeyCol]) << 6) & 0xC0; |
| 3073 | } |
| 3074 | |
| 3075 | return answer; |
| 3076 | } |
| 3077 | |
| 3345 | 3078 | const tms9901_interface tms9901reset_param_ti99_8 = |
| 3346 | 3079 | { |
| 3347 | 3080 | TMS9901_INT1 | TMS9901_INT2 | TMS9901_INTC, /* only input pins whose state is always known */ |
| r8296 | r8297 | |
| 3378 | 3111 | /* clock rate = 3.58MHz??? 2.68MHz??? */ |
| 3379 | 3112 | /*3579545.*/2684658.75 |
| 3380 | 3113 | }; |
| 3114 | |
| 3115 | |
| 3116 | /************************************************************************** |
| 3117 | SGCPU (aka "TI-99/4P") |
| 3118 | Requires EVPC and HSGPL (with content) |
| 3119 | ***************************************************************************/ |
| 3120 | |
| 3121 | /* True if SGCPU rom6 is enabled */ |
| 3122 | static int ti99_4p_internal_rom6_enable; |
| 3123 | |
| 3124 | /* Pointer to the memory area. */ |
| 3125 | static UINT16 *ti99_4p_mem; |
| 3126 | |
| 3127 | /* pointer to the internal DSR ROM data */ |
| 3128 | static UINT16 *ti99_4p_internal_DSR; |
| 3129 | |
| 3130 | /* Offset to the ROM6 bank. */ |
| 3131 | static offs_t rom6_bank_offset; |
| 3132 | |
| 3133 | static void ti99_4p_mapper_cru_w(running_machine *machine, int offset, int data); |
| 3134 | static READ16_HANDLER(ti99_4p_mapper_r); |
| 3135 | static WRITE16_HANDLER(ti99_4p_mapper_w); |
| 3136 | static void ti99_4p_internal_dsr_cru_w(running_machine *machine, int offset, int data); |
| 3137 | static READ16_HANDLER(ti99_4p_internal_dsr_r); |
| 3138 | |
| 3139 | static const ti99_peb_16bit_card_handlers_t ti99_4p_internal_dsr_handlers = |
| 3140 | { |
| 3141 | NULL, |
| 3142 | ti99_4p_internal_dsr_cru_w, |
| 3143 | ti99_4p_internal_dsr_r, |
| 3144 | NULL |
| 3145 | }; |
| 3146 | |
| 3147 | static const ti99_peb_16bit_card_handlers_t ti99_4p_mapper_handlers = |
| 3148 | { |
| 3149 | NULL, |
| 3150 | ti99_4p_mapper_cru_w, |
| 3151 | ti99_4p_mapper_r, |
| 3152 | ti99_4p_mapper_w |
| 3153 | }; |
| 3154 | |
| 3155 | static int ti99_4p_mapper_on; |
| 3156 | static int ti99_4p_mapper_lookup[16]; |
| 3157 | |
| 3158 | DRIVER_INIT( ti99_4p ) |
| 3159 | { |
| 3160 | ti99_model = model_99_4p; |
| 3161 | has_evpc = TRUE; |
| 3162 | |
| 3163 | /* set up memory pointers */ |
| 3164 | xRAM_ptr = (UINT16 *) (memory_region(machine, "maincpu") + offset_xram_4p); |
| 3165 | } |
| 3166 | |
| 3167 | MACHINE_START( ti99_4p ) |
| 3168 | { |
| 3169 | UINT8* mem = memory_region(machine, "maincpu"); |
| 3170 | |
| 3171 | // Set up system ROM pointers. Must be set up here |
| 3172 | // so that the system can successfully reset (otherwise the reset |
| 3173 | // vector would be missing in 0x0000). |
| 3174 | memory_set_bankptr(machine, "bank1", mem + offset_rom0_4p); // system ROM |
| 3175 | |
| 3176 | ti99_floppy_controllers_init_all(machine); |
| 3177 | ti99_ide_init(machine); |
| 3178 | ti99_hsgpl_init(machine); |
| 3179 | ti99_usbsm_init(machine); |
| 3180 | } |
| 3181 | |
| 3182 | /* |
| 3183 | Reset the machine. |
| 3184 | */ |
| 3185 | MACHINE_RESET( ti99_4p ) |
| 3186 | { |
| 3187 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 3188 | |
| 3189 | UINT8* mem = memory_region(machine, "maincpu"); |
| 3190 | |
| 3191 | /* set up system ROM and scratch pad pointers */ |
| 3192 | memory_set_bankptr(machine, "bank1", mem + offset_rom0_4p); /* system ROM */ |
| 3193 | memory_set_bankptr(machine, "bank2", mem + offset_sram_4p); /* scratch pad */ |
| 3194 | memory_set_bankptr(machine, "bank11", mem + offset_dram_4p); /* extra RAM for debugger */ |
| 3195 | |
| 3196 | v9938_reset(0); |
| 3197 | |
| 3198 | /* clear keyboard interface state (probably overkill, but can't harm) */ |
| 3199 | KeyCol = 0; |
| 3200 | AlphaLockLine = 0; |
| 3201 | |
| 3202 | tms9901_set_single_int(devtag_get_device(machine, "tms9901"), 12, 0); |
| 3203 | |
| 3204 | xRAM_kind = RAM_99_4P; |
| 3205 | has_speech = input_port_read(machine, "SPEECH"); |
| 3206 | has_ide = input_port_read(machine, "HDCTRL") & HD_IDE; |
| 3207 | has_rs232 = input_port_read(machine, "SERIAL") & SERIAL_TI; |
| 3208 | |
| 3209 | has_handset = FALSE; |
| 3210 | has_mecmouse = FALSE; // mouse is connected to v9938 |
| 3211 | has_hsgpl = TRUE; |
| 3212 | has_usb_sm = input_port_read(machine, "HDCTRL") & HD_USB; |
| 3213 | has_pcode = input_port_read(machine, "EXTCARD") & EXT_PCODE; |
| 3214 | |
| 3215 | // Removes all card handlers |
| 3216 | ti99_peb_init(); |
| 3217 | |
| 3218 | // set up optional expansion hardware |
| 3219 | ti99_peb_reset(TRUE, tms9901_set_int1, NULL); |
| 3220 | |
| 3221 | ti99_4p_internal_dsr_reset(machine); |
| 3222 | ti99_4p_mapper_init(machine); |
| 3223 | ti99_hsgpl_reset(machine); |
| 3224 | ti99_evpc_reset(machine); |
| 3225 | |
| 3226 | if (has_speech) |
| 3227 | { |
| 3228 | static const spchroms_interface speech_intf = { region_speech_rom }; |
| 3229 | spchroms_config(machine, &speech_intf); |
| 3230 | memory_install_read16_handler(space, 0x9000, 0x93ff, 0, 0, ti99_rspeech_r); |
| 3231 | memory_install_write16_handler(space, 0x9400, 0x97ff, 0, 0, ti99_wspeech_w); |
| 3232 | } |
| 3233 | else |
| 3234 | { |
| 3235 | memory_install_read16_handler(space, 0x9000, 0x93ff, 0, 0, ti99_nop_8_r); |
| 3236 | memory_install_write16_handler(space, 0x9400, 0x97ff, 0, 0, ti99_nop_8_w); |
| 3237 | } |
| 3238 | |
| 3239 | |
| 3240 | switch (input_port_read(machine, "DISKCTRL")) |
| 3241 | { |
| 3242 | case DISK_TIFDC: |
| 3243 | ti99_fdc_reset(machine); |
| 3244 | break; |
| 3245 | #if HAS_99CCFDC |
| 3246 | case DISK_CC: |
| 3247 | ti99_ccfdc_reset(machine); |
| 3248 | break; |
| 3249 | #endif |
| 3250 | case DISK_BWG: |
| 3251 | ti99_bwg_reset(machine); |
| 3252 | break; |
| 3253 | case DISK_HFDC: |
| 3254 | ti99_hfdc_reset(machine); |
| 3255 | break; |
| 3256 | case DISK_NONE: |
| 3257 | break; |
| 3258 | } |
| 3259 | |
| 3260 | if (has_ide) |
| 3261 | ti99_ide_reset(machine, FALSE); |
| 3262 | |
| 3263 | if (has_usb_sm) |
| 3264 | ti99_usbsm_reset(machine, FALSE); |
| 3265 | |
| 3266 | if (has_pcode) |
| 3267 | ti99_pcode_reset(machine); |
| 3268 | } |
| 3269 | |
| 3270 | |
| 3271 | /* |
| 3272 | SNUG SGCPU (a.k.a. 99/4p) Super AMS clone support. |
| 3273 | Compatible with Super AMS, but uses a 16-bit bus. |
| 3274 | |
| 3275 | Up to 1Mb of SRAM. Straightforward mapper, works with 4kb chunks. |
| 3276 | */ |
| 3277 | |
| 3278 | /* set up handlers, and set initial state */ |
| 3279 | static void ti99_4p_mapper_init(running_machine *machine) |
| 3280 | { |
| 3281 | int i; |
| 3282 | char bank_name[10]; |
| 3283 | /* Not required at run-time */ |
| 3284 | ti99_peb_set_16bit_card_handlers(0x1e00, & ti99_4p_mapper_handlers); |
| 3285 | |
| 3286 | ti99_4p_mapper_on = 0; |
| 3287 | |
| 3288 | for (i=0; i<16; i++) |
| 3289 | { |
| 3290 | ti99_4p_mapper_lookup[i] = i << 11; |
| 3291 | |
| 3292 | /* update bank base */ |
| 3293 | switch (i) |
| 3294 | { |
| 3295 | case 2: |
| 3296 | case 3: |
| 3297 | sprintf(bank_name,"bank%d",3+(i-2)); |
| 3298 | memory_set_bankptr(machine,bank_name, xRAM_ptr + (i<<11)); |
| 3299 | break; |
| 3300 | |
| 3301 | case 10: |
| 3302 | case 11: |
| 3303 | case 12: |
| 3304 | case 13: |
| 3305 | case 14: |
| 3306 | case 15: |
| 3307 | sprintf(bank_name,"bank%d",5+(i-10)); |
| 3308 | memory_set_bankptr(machine,bank_name, xRAM_ptr + (i<<11)); |
| 3309 | break; |
| 3310 | } |
| 3311 | } |
| 3312 | } |
| 3313 | |
| 3314 | /* |
| 3315 | Write CRU bit: |
| 3316 | bit0: enable/disable mapper registers in DSR space, |
| 3317 | bit1: enable/disable address mapping |
| 3318 | */ |
| 3319 | static void ti99_4p_mapper_cru_w(running_machine *machine, int offset, int data) |
| 3320 | { |
| 3321 | int i; |
| 3322 | char bank_name[10]; |
| 3323 | |
| 3324 | if (offset == 1) |
| 3325 | { |
| 3326 | if (ti99_4p_mapper_on != data) |
| 3327 | { |
| 3328 | ti99_4p_mapper_on = data; |
| 3329 | |
| 3330 | for (i=0; i<16; i++) |
| 3331 | { |
| 3332 | /* update bank base */ |
| 3333 | switch (i) |
| 3334 | { |
| 3335 | case 2: |
| 3336 | case 3: |
| 3337 | sprintf(bank_name,"bank%d",3+(i-2)); |
| 3338 | memory_set_bankptr(machine,bank_name, xRAM_ptr + (ti99_4p_mapper_on ? (ti99_4p_mapper_lookup[i]) : (i<<11))); |
| 3339 | break; |
| 3340 | |
| 3341 | case 10: |
| 3342 | case 11: |
| 3343 | case 12: |
| 3344 | case 13: |
| 3345 | case 14: |
| 3346 | case 15: |
| 3347 | sprintf(bank_name,"bank%d",5+(i-10)); |
| 3348 | memory_set_bankptr(machine,bank_name, xRAM_ptr + (ti99_4p_mapper_on ? (ti99_4p_mapper_lookup[i]) : (i<<11))); |
| 3349 | break; |
| 3350 | } |
| 3351 | } |
| 3352 | } |
| 3353 | } |
| 3354 | } |
| 3355 | |
| 3356 | /* read a mapper register */ |
| 3357 | static READ16_HANDLER(ti99_4p_mapper_r) |
| 3358 | { |
| 3359 | return (ti99_4p_mapper_lookup[offset & 0xf] >> 3); |
| 3360 | } |
| 3361 | |
| 3362 | /* write a mapper register */ |
| 3363 | static WRITE16_HANDLER(ti99_4p_mapper_w) |
| 3364 | { |
| 3365 | int page = offset & 0xf; |
| 3366 | char bank_name[10]; |
| 3367 | ti99_4p_mapper_lookup[page] = (data & 0xff00) << 3; |
| 3368 | |
| 3369 | if (ti99_4p_mapper_on) |
| 3370 | { |
| 3371 | /* update bank base */ |
| 3372 | switch (page) |
| 3373 | { |
| 3374 | case 2: |
| 3375 | case 3: |
| 3376 | sprintf(bank_name,"bank%d",3+(page-2)); |
| 3377 | memory_set_bankptr(space->machine,bank_name, xRAM_ptr+ti99_4p_mapper_lookup[page]); |
| 3378 | break; |
| 3379 | |
| 3380 | case 10: |
| 3381 | case 11: |
| 3382 | case 12: |
| 3383 | case 13: |
| 3384 | case 14: |
| 3385 | case 15: |
| 3386 | sprintf(bank_name,"bank%d",5+(page-10)); |
| 3387 | memory_set_bankptr(space->machine,bank_name, xRAM_ptr+ti99_4p_mapper_lookup[page]); |
| 3388 | break; |
| 3389 | } |
| 3390 | } |
| 3391 | } |
| 3392 | |
| 3393 | /* |
| 3394 | Internal DSR support. |
| 3395 | Includes a few specific signals, and an extra ROM. |
| 3396 | */ |
| 3397 | static void ti99_4p_internal_dsr_reset(running_machine *machine) |
| 3398 | { |
| 3399 | // set up handlers, and set initial state |
| 3400 | UINT8* mem = memory_region(machine, "maincpu"); |
| 3401 | |
| 3402 | ti99_4p_internal_DSR = (UINT16 *) (mem + offset_rom4_4p); |
| 3403 | rom6_bank_offset = offset_rom6_4p; |
| 3404 | ti99_4p_mem = (UINT16 *)mem; |
| 3405 | |
| 3406 | ti99_peb_set_16bit_card_handlers(0x0f00, & ti99_4p_internal_dsr_handlers); |
| 3407 | |
| 3408 | ti99_4p_internal_rom6_enable = 0; |
| 3409 | ti99_4p_peb_set_senila(0); |
| 3410 | ti99_4p_peb_set_senilb(0); |
| 3411 | } |
| 3412 | |
| 3413 | /* |
| 3414 | Write CRU bit: |
| 3415 | bit0: enable/disable internal DSR ROM, |
| 3416 | bit1: enable/disable internal cartridge ROM |
| 3417 | bit2: set/clear senila |
| 3418 | bit3: set/clear senilb |
| 3419 | */ |
| 3420 | static void ti99_4p_internal_dsr_cru_w(running_machine *machine, int offset, int data) |
| 3421 | { |
| 3422 | switch (offset) |
| 3423 | { |
| 3424 | case 1: |
| 3425 | ti99_4p_internal_rom6_enable = data; |
| 3426 | break; |
| 3427 | case 2: |
| 3428 | ti99_4p_peb_set_senila(data); |
| 3429 | break; |
| 3430 | case 3: |
| 3431 | ti99_4p_peb_set_senilb(data); |
| 3432 | break; |
| 3433 | case 4: |
| 3434 | /* 0: 16-bit (fast) memory timings */ |
| 3435 | /* 1: 8-bit memory timings */ |
| 3436 | break; |
| 3437 | case 5: |
| 3438 | /* if 0: "KBENA" mode (enable keyboard?) */ |
| 3439 | /* if 1: "KBINH" mode (inhibit keyboard?) */ |
| 3440 | break; |
| 3441 | } |
| 3442 | } |
| 3443 | |
| 3444 | /* |
| 3445 | Read internal DSR ROM. |
| 3446 | Addresses 4000-5fff |
| 3447 | */ |
| 3448 | static READ16_HANDLER(ti99_4p_internal_dsr_r) |
| 3449 | { |
| 3450 | return ti99_4p_internal_DSR[offset]; |
| 3451 | } |
| 3452 | |
| 3453 | /* |
| 3454 | SGCPU cartridge space: mapped either to internal ROM6 or to HSGPL. |
| 3455 | Addresses 6000-7fff |
| 3456 | */ |
| 3457 | READ16_HANDLER ( ti99_4p_cart_r ) |
| 3458 | { |
| 3459 | UINT16 value = 0; |
| 3460 | if (ti99_4p_internal_rom6_enable) |
| 3461 | { |
| 3462 | value = ti99_4p_mem[(rom6_bank_offset>>1) + offset]; |
| 3463 | } |
| 3464 | else |
| 3465 | { |
| 3466 | cpu_adjust_icount(devtag_get_device(space->machine, "maincpu"),-4); |
| 3467 | // cpu_spinuntil_time(space->machine->firstcpu, ATTOTIME_IN_USEC(6)); |
| 3468 | |
| 3469 | if (hsgpl_crdena) |
| 3470 | /* hsgpl is enabled */ |
| 3471 | value = ti99_hsgpl_rom6_r(space, offset, mem_mask); |
| 3472 | } |
| 3473 | return value; |
| 3474 | } |
| 3475 | |
| 3476 | WRITE16_HANDLER ( ti99_4p_cart_w ) |
| 3477 | { |
| 3478 | if (ti99_4p_internal_rom6_enable) |
| 3479 | { |
| 3480 | // Switch ROMs |
| 3481 | if (offset & 1) |
| 3482 | rom6_bank_offset = offset_rom6b_4p; |
| 3483 | else |
| 3484 | rom6_bank_offset = offset_rom6_4p; |
| 3485 | } |
| 3486 | else |
| 3487 | { |
| 3488 | cpu_adjust_icount(devtag_get_device(space->machine, "maincpu"),-4); |
| 3489 | // cpu_spinuntil_time(space->machine->firstcpu, ATTOTIME_IN_USEC(6)); |
| 3490 | |
| 3491 | if (hsgpl_crdena) |
| 3492 | /* hsgpl is enabled */ |
| 3493 | ti99_hsgpl_rom6_w(space, offset, data, mem_mask); |
| 3494 | } |
| 3495 | } |
| 3496 | |
| 3497 | /* |
| 3498 | GROM read for TI-99/4p |
| 3499 | */ |
| 3500 | READ16_HANDLER ( ti99_4p_grom_r ) |
| 3501 | { |
| 3502 | UINT16 value = 0; |
| 3503 | // HSGPL is located on 8-bit bus |
| 3504 | cpu_adjust_icount(devtag_get_device(space->machine, "maincpu"),-4); |
| 3505 | // cpu_spinuntil_time(space->machine->firstcpu, ATTOTIME_IN_USEC(6)); |
| 3506 | |
| 3507 | // When crdena is false, we must still be able to query the address |
| 3508 | // counter (offset & 1) |
| 3509 | if (hsgpl_crdena || (offset & 1)) |
| 3510 | value = ti99_hsgpl_gpl_r(space, offset, mem_mask); |
| 3511 | |
| 3512 | return value; |
| 3513 | } |
| 3514 | |
| 3515 | /* |
| 3516 | GROM write |
| 3517 | */ |
| 3518 | WRITE16_HANDLER ( ti99_4p_grom_w ) |
| 3519 | { |
| 3520 | // HSGPL is located on 8-bit bus |
| 3521 | cpu_adjust_icount(devtag_get_device(space->machine, "maincpu"),-4); |
| 3522 | // cpu_spinuntil_time(space->machine->firstcpu, ATTOTIME_IN_USEC(6)); |
| 3523 | |
| 3524 | if (hsgpl_crdena || (offset & 1)) |
| 3525 | ti99_hsgpl_gpl_w(space, offset, data, mem_mask); |
| 3526 | } |
| 3527 | |
src/mess/drivers/ti99_4p.c
| r8296 | r8297 | |
| 34 | 34 | If you use memory view in the debugger, it crashes at 6000 and some higher addresses. This is |
| 35 | 35 | because the memory map has references to GROM handlers. |
| 36 | 36 | |
| 37 | 2010-06-19 |
| 38 | MZ: Driver fixed |
| 39 | Important: The SGCPU card relies on a properly set up HSGPL flash memory |
| 40 | card; without, it will immediately lock up. It is impossible to set it up |
| 41 | from here (a bootstrap problem; you cannot start without the HSGPL). |
| 42 | The best chance is to start a ti99_4ev, activate the |
| 43 | HSGPL, and go through the setup process there. Copy the hsgpl.nv into this |
| 44 | driver's nvram subdirectory. The contents will be directly usable for the SGCPU. |
| 37 | 45 | */ |
| 38 | 46 | |
| 39 | 47 | #include "emu.h" |
| r8296 | r8297 | |
| 60 | 68 | #include "devices/ti99_hd.h" |
| 61 | 69 | #include "machine/idectrl.h" |
| 62 | 70 | #include "machine/smc92x4.h" |
| 71 | #include "machine/mm58274c.h" |
| 63 | 72 | #include "machine/rtc65271.h" |
| 64 | 73 | #include "formats/ti99_dsk.h" |
| 65 | 74 | |
| 66 | 75 | |
| 67 | 76 | static ADDRESS_MAP_START(memmap, ADDRESS_SPACE_PROGRAM, 16) |
| 68 | | AM_RANGE(0x0000, 0x1fff) AM_ROMBANK("bank1") /*system ROM*/ |
| 69 | | AM_RANGE(0x2000, 0x2fff) AM_RAMBANK("bank3") /*lower 8kb of RAM extension: AMS bank 2*/ |
| 70 | | AM_RANGE(0x3000, 0x3fff) AM_RAMBANK("bank4") /*lower 8kb of RAM extension: AMS bank 3*/ |
| 71 | | AM_RANGE(0x4000, 0x5fff) AM_READWRITE(ti99_4p_peb_r, ti99_4p_peb_w) /*DSR ROM space*/ |
| 72 | | AM_RANGE(0x6000, 0x7fff) AM_READWRITE(ti99_4p_cart_r,ti99_4p_cart_w)/*cartridge space (internal or hsgpl)*/ |
| 73 | | AM_RANGE(0x8000, 0x83ff) AM_RAMBANK("bank2") /*RAM PAD*/ |
| 74 | | AM_RANGE(0x8400, 0x87ff) AM_READWRITE(ti99_nop_8_r, ti99_wsnd_w) /*soundchip write*/ |
| 75 | | AM_RANGE(0x8800, 0x8bff) AM_READWRITE(ti99_rv38_r, ti99_nop_8_w) /*vdp read*/ |
| 76 | | AM_RANGE(0x8C00, 0x8fff) AM_READWRITE(ti99_nop_8_r, ti99_wv38_w) /*vdp write*/ |
| 77 | | AM_RANGE(0x9000, 0x93ff) AM_READWRITE(ti99_nop_8_r, ti99_nop_8_w) /*speech read - installed dynamically*/ |
| 78 | | AM_RANGE(0x9400, 0x97ff) AM_READWRITE(ti99_nop_8_r, ti99_nop_8_w) /*speech write - installed dynamically*/ |
| 79 | | AM_RANGE(0x9800, 0x98ff) AM_READWRITE(ti99_4p_grom_r, ti99_nop_8_w) /*GPL read*/ |
| 80 | | AM_RANGE(0x9900, 0x9bff) AM_RAMBANK("bank11") /*extra RAM for debugger*/ |
| 81 | | AM_RANGE(0x9c00, 0x9fff) AM_READWRITE(ti99_nop_8_r, ti99_4p_grom_w) /*GPL write*/ |
| 82 | | AM_RANGE(0xa000, 0xafff) AM_RAMBANK("bank5") /*upper 24kb of RAM extension: AMS bank 10*/ |
| 83 | | AM_RANGE(0xb000, 0xbfff) AM_RAMBANK("bank6") /*upper 24kb of RAM extension: AMS bank 11*/ |
| 84 | | AM_RANGE(0xc000, 0xcfff) AM_RAMBANK("bank7") /*upper 24kb of RAM extension: AMS bank 12*/ |
| 85 | | AM_RANGE(0xd000, 0xdfff) AM_RAMBANK("bank8") /*upper 24kb of RAM extension: AMS bank 13*/ |
| 86 | | AM_RANGE(0xe000, 0xefff) AM_RAMBANK("bank9") /*upper 24kb of RAM extension: AMS bank 14*/ |
| 87 | | AM_RANGE(0xf000, 0xffff) AM_RAMBANK("bank10") /*upper 24kb of RAM extension: AMS bank 15*/ |
| 77 | AM_RANGE(0x0000, 0x1fff) AM_ROMBANK("bank1") // system ROM |
| 78 | AM_RANGE(0x2000, 0x2fff) AM_RAMBANK("bank3") // lower 8kb of RAM extension: AMS bank 2 |
| 79 | AM_RANGE(0x3000, 0x3fff) AM_RAMBANK("bank4") // lower 8kb of RAM extension: AMS bank 3 |
| 80 | AM_RANGE(0x4000, 0x5fff) AM_READWRITE(ti99_4p_peb_r, ti99_4p_peb_w) // DSR ROM space |
| 81 | AM_RANGE(0x6000, 0x7fff) AM_READWRITE(ti99_4p_cart_r,ti99_4p_cart_w) // cartridge space (internal or hsgpl) |
| 82 | AM_RANGE(0x8000, 0x83ff) AM_RAMBANK("bank2") // RAM PAD |
| 83 | AM_RANGE(0x8400, 0x87ff) AM_READWRITE(ti99_nop_8_r, ti99_wsnd_w) // soundchip write |
| 84 | AM_RANGE(0x8800, 0x8bff) AM_READWRITE(ti99_rv38_r, ti99_nop_8_w) // vdp read |
| 85 | AM_RANGE(0x8C00, 0x8fff) AM_READWRITE(ti99_nop_8_r, ti99_wv38_w) // vdp write |
| 86 | AM_RANGE(0x9000, 0x93ff) AM_READWRITE(ti99_nop_8_r, ti99_nop_8_w) // speech read - installed dynamically |
| 87 | AM_RANGE(0x9400, 0x97ff) AM_READWRITE(ti99_nop_8_r, ti99_nop_8_w) // speech write - installed dynamically*/ |
| 88 | AM_RANGE(0x9800, 0x98ff) AM_READWRITE(ti99_4p_grom_r, ti99_nop_8_w) // GPL read |
| 89 | AM_RANGE(0x9900, 0x9bff) AM_RAMBANK("bank11") // extra RAM for debugger |
| 90 | AM_RANGE(0x9c00, 0x9fff) AM_READWRITE(ti99_nop_8_r, ti99_4p_grom_w) // GPL write |
| 91 | AM_RANGE(0xa000, 0xafff) AM_RAMBANK("bank5") // upper 24kb of RAM extension: AMS bank 10 |
| 92 | AM_RANGE(0xb000, 0xbfff) AM_RAMBANK("bank6") // upper 24kb of RAM extension: AMS bank 11 |
| 93 | AM_RANGE(0xc000, 0xcfff) AM_RAMBANK("bank7") // upper 24kb of RAM extension: AMS bank 12 |
| 94 | AM_RANGE(0xd000, 0xdfff) AM_RAMBANK("bank8") // upper 24kb of RAM extension: AMS bank 13 |
| 95 | AM_RANGE(0xe000, 0xefff) AM_RAMBANK("bank9") // upper 24kb of RAM extension: AMS bank 14 |
| 96 | AM_RANGE(0xf000, 0xffff) AM_RAMBANK("bank10") // upper 24kb of RAM extension: AMS bank 15 |
| 88 | 97 | ADDRESS_MAP_END |
| 89 | 98 | |
| 90 | 99 | static ADDRESS_MAP_START(cru_map, ADDRESS_SPACE_IO, 8) |
| r8296 | r8297 | |
| 121 | 130 | PORT_START( "HDCTRL" ) |
| 122 | 131 | PORT_CONFNAME( 0x03, 0x00, "HD controller" ) |
| 123 | 132 | PORT_CONFSETTING( 0x00, DEF_STR( None ) ) |
| 124 | | // PORT_CONFSETTING( 0x01, "Nouspikel IDE Controller" ) |
| 133 | // PORT_CONFSETTING( 0x01, "Nouspikel IDE Controller" ) |
| 125 | 134 | // PORT_CONFSETTING( 0x02, "WHTech SCSI Controller" ) |
| 126 | 135 | PORT_CONFNAME( 0x08, 0x00, "USB-SM card" ) |
| 127 | 136 | PORT_CONFSETTING( 0x00, DEF_STR( Off ) ) |
| r8296 | r8297 | |
| 137 | 146 | PORT_CONFSETTING( 0x00, DEF_STR( Off ) ) |
| 138 | 147 | PORT_CONFSETTING( 0x04, DEF_STR( On ) ) |
| 139 | 148 | |
| 140 | | PORT_START( "HCI" ) |
| 141 | | PORT_CONFNAME( 0x01, 0x00, "Mouse support" ) |
| 142 | | PORT_CONFSETTING( 0x00, DEF_STR( Off ) ) |
| 143 | | PORT_CONFSETTING( 0x01, "Mechatronics Mouse" ) |
| 144 | | |
| 145 | 149 | PORT_START( "HFDCDIP" ) |
| 146 | 150 | PORT_DIPNAME( 0xff, 0x55, "HFDC drive config" ) PORT_CONDITION( "DISKCTRL", 0x07, PORTCOND_EQUALS, 0x03 ) |
| 147 | 151 | PORT_DIPSETTING( 0x00, "40 track, 16 ms") |
| r8296 | r8297 | |
| 154 | 158 | PORT_CONFSETTING( 0x00, "No delay") |
| 155 | 159 | PORT_CONFSETTING( 0x01, "Realistic") |
| 156 | 160 | |
| 161 | PORT_START( "EVPC-SW1" ) |
| 162 | PORT_DIPNAME( 0x01, 0x00, "EVPC video mode" ) PORT_CONDITION( "EVPC-SW8", 0x01, PORTCOND_EQUALS, 0x00 ) PORT_CHANGED( evpc_changed, (void *)0) |
| 163 | PORT_DIPSETTING( 0x00, "PAL" ) |
| 164 | PORT_DIPSETTING( 0x01, "NTSC" ) |
| 165 | |
| 166 | PORT_START( "EVPC-SW3" ) |
| 167 | PORT_DIPNAME( 0x01, 0x00, "EVPC charset" ) PORT_CONDITION( "EVPC-SW8", 0x01, PORTCOND_EQUALS, 0x00 ) PORT_CHANGED( evpc_changed, (void *)1) |
| 168 | PORT_DIPSETTING( 0x00, DEF_STR( International )) |
| 169 | PORT_DIPSETTING( 0x01, DEF_STR( German )) |
| 170 | |
| 171 | PORT_START( "EVPC-SW4" ) |
| 172 | PORT_DIPNAME( 0x01, 0x00, "EVPC VDP RAM" ) PORT_CONDITION( "EVPC-SW8", 0x01, PORTCOND_EQUALS, 0x00 ) PORT_CHANGED( evpc_changed, (void *)2) |
| 173 | PORT_DIPSETTING( 0x00, "shifted" ) |
| 174 | PORT_DIPSETTING( 0x01, "not shifted" ) |
| 175 | |
| 176 | PORT_START( "EVPC-SW8" ) |
| 177 | PORT_DIPNAME( 0x01, 0x00, "EVPC Configuration" ) PORT_CHANGED( evpc_changed, (void *)3) |
| 178 | PORT_DIPSETTING( 0x00, "DIP" ) |
| 179 | PORT_DIPSETTING( 0x01, "NOVRAM" ) |
| 180 | |
| 157 | 181 | /* 3 ports for mouse */ |
| 158 | 182 | PORT_START("MOUSEX") /* Mouse - X AXIS */ |
| 159 | 183 | PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(0) PORT_PLAYER(1) |
| r8296 | r8297 | |
| 261 | 285 | #endif |
| 262 | 286 | }; |
| 263 | 287 | |
| 288 | /* F4 Character Displayer */ |
| 289 | static const gfx_layout ti99_6_charlayout = |
| 290 | { |
| 291 | 8, 6, /* 8 x 6 characters */ |
| 292 | 64, /* 64 characters */ |
| 293 | 1, /* 1 bits per pixel */ |
| 294 | { 0 }, /* no bitplanes */ |
| 295 | /* x offsets */ |
| 296 | { 0, 1, 2, 3, 4, 5, 6, 7 }, |
| 297 | /* y offsets */ |
| 298 | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8 }, |
| 299 | 8*6 /* every char takes 6 bytes */ |
| 300 | }; |
| 301 | |
| 302 | static const gfx_layout ti99_7_charlayout = |
| 303 | { |
| 304 | 8, 7, /* 8 x 7 characters */ |
| 305 | 95, /* 95 characters */ |
| 306 | 1, /* 1 bits per pixel */ |
| 307 | { 0 }, /* no bitplanes */ |
| 308 | /* x offsets */ |
| 309 | { 0, 1, 2, 3, 4, 5, 6, 7 }, |
| 310 | /* y offsets */ |
| 311 | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8 }, |
| 312 | 8*7 /* every char takes 7 bytes */ |
| 313 | }; |
| 314 | |
| 315 | static const gfx_layout ti99_8_charlayout = |
| 316 | { |
| 317 | 8, 8, /* 8 x 8 characters */ |
| 318 | 64, /* 64 characters */ |
| 319 | 1, /* 1 bits per pixel */ |
| 320 | { 0 }, /* no bitplanes */ |
| 321 | /* x offsets */ |
| 322 | { 0, 1, 2, 3, 4, 5, 6, 7 }, |
| 323 | /* y offsets */ |
| 324 | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 }, |
| 325 | 8*8 /* every char takes 8 bytes */ |
| 326 | }; |
| 327 | |
| 328 | static const gfx_layout ti99_c_charlayout = |
| 329 | { |
| 330 | 8, 8, /* 8 x 8 characters */ |
| 331 | 1, /* 1 characters */ |
| 332 | 1, /* 1 bits per pixel */ |
| 333 | { 0 }, /* no bitplanes */ |
| 334 | /* x offsets */ |
| 335 | { 0, 1, 2, 3, 4, 5, 6, 7 }, |
| 336 | /* y offsets */ |
| 337 | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 }, |
| 338 | 8*8 /* every char takes 8 bytes */ |
| 339 | }; |
| 340 | |
| 341 | static const gfx_layout ti99_24_charlayout = |
| 342 | { |
| 343 | 24, 24, /* 24 x 24 characters */ |
| 344 | 1, /* 1 characters */ |
| 345 | 1, /* 1 bits per pixel */ |
| 346 | { 0 }, /* no bitplanes */ |
| 347 | /* x offsets */ |
| 348 | { 0, 1, 2, 3, 4, 5, 6, 7, 64, 65, 66, 67, 68, 69, 70, 71, 128, 129, 130, 131, 132, 133, 134, 135 }, |
| 349 | /* y offsets */ |
| 350 | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8, 24*8, 25*8, 26*8, 27*8, 28*8, 29*8, 30*8, 31*8, 48*8, 49*8, 50*8, 51*8, 52*8, 53*8, 54*8, 55*8 }, |
| 351 | 24*24 /* every char takes 72 bytes */ |
| 352 | }; |
| 353 | |
| 354 | static GFXDECODE_START( ti99b ) |
| 355 | GFXDECODE_ENTRY( region_grom, 0x04b4, ti99_8_charlayout, 2, 2 ) |
| 356 | GFXDECODE_ENTRY( region_grom, 0x06b4, ti99_7_charlayout, 2, 2 ) |
| 357 | GFXDECODE_ENTRY( region_grom, 0x0950, ti99_24_charlayout, 2, 2 ) |
| 358 | GFXDECODE_ENTRY( region_grom, 0x0998, ti99_c_charlayout, 2, 2 ) |
| 359 | GFXDECODE_END |
| 360 | |
| 264 | 361 | /* |
| 265 | 362 | We use a DAC to emulate "audio gate", even though |
| 266 | 363 | a) there was no DAC in an actual TI99 |
| r8296 | r8297 | |
| 279 | 376 | DO_NOT_KEEP_GEOMETRY |
| 280 | 377 | }; |
| 281 | 378 | |
| 379 | static const mm58274c_interface floppy_mm58274c_interface = |
| 380 | { |
| 381 | 1, /* mode 24*/ |
| 382 | 0 /* first day of week */ |
| 383 | }; |
| 384 | |
| 282 | 385 | /* |
| 283 | 386 | Machine description. |
| 284 | 387 | */ |
| r8296 | r8297 | |
| 288 | 391 | MDRV_CPU_ADD("maincpu", TMS9900, 3000000) |
| 289 | 392 | MDRV_CPU_PROGRAM_MAP(memmap) |
| 290 | 393 | MDRV_CPU_IO_MAP(cru_map) |
| 291 | | MDRV_CPU_VBLANK_INT_HACK(ti99_4ev_hblank_interrupt, 263) /* 262.5 in 60Hz, 312.5 in 50Hz */ |
| 292 | 394 | |
| 395 | // MZ: Changed 263 to 262 to avoid blank image on startup |
| 396 | // The issue is somehow related to changing VReg 9 to 0 in an unconvenient situation |
| 397 | // but I could not identify it more closely. Seems to happen in v9938_interrupt. |
| 398 | MDRV_CPU_VBLANK_INT_HACK(ti99_4ev_hblank_interrupt, 262) /* 262.5 in 60Hz, 312.5 in 50Hz */ |
| 399 | |
| 293 | 400 | MDRV_MACHINE_START( ti99_4p ) |
| 294 | | MDRV_MACHINE_RESET( ti99 ) |
| 401 | MDRV_MACHINE_RESET( ti99_4p ) |
| 295 | 402 | |
| 296 | 403 | /* For HSGPL */ |
| 297 | 404 | MDRV_NVRAM_HANDLER( ti99 ) |
| r8296 | r8297 | |
| 304 | 411 | MDRV_SCREEN_SIZE(512+32, (212+28)*2) |
| 305 | 412 | MDRV_SCREEN_VISIBLE_AREA(0, 512+32 - 1, 0, (212+28)*2 - 1) |
| 306 | 413 | |
| 414 | // Didn't work, probably just done wrong by me: |
| 415 | // MDRV_TIMER_ADD_SCANLINE("v9938_scanline", ti99_4ev_scanline_interrupt , "screen", 0, 1) |
| 416 | |
| 307 | 417 | MDRV_PALETTE_LENGTH(512) |
| 308 | 418 | |
| 309 | 419 | MDRV_PALETTE_INIT(v9938) |
| 310 | 420 | MDRV_VIDEO_START(ti99_4ev) |
| 311 | 421 | MDRV_VIDEO_UPDATE(generic_bitmapped) |
| 422 | MDRV_GFXDECODE(ti99b) |
| 312 | 423 | |
| 313 | 424 | /* sound hardware */ |
| 314 | 425 | MDRV_SPEAKER_STANDARD_MONO("mono") |
| r8296 | r8297 | |
| 323 | 434 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) |
| 324 | 435 | |
| 325 | 436 | /* devices */ |
| 326 | | /* MDRV_IDE_CONTROLLER_ADD( "ide", ti99_ide_interrupt ) |
| 327 | | MDRV_RTC65271_ADD("ide_rtc", ti99_clk_interrupt_callback) */ |
| 437 | /* MDRV_IDE_CONTROLLER_ADD( "ide", ti99_ide_interrupt ) |
| 438 | MDRV_RTC65271_ADD("ide_rtc", ti99_clk_interrupt_callback) */ |
| 328 | 439 | |
| 329 | 440 | MDRV_CASSETTE_ADD( "cassette", default_cassette_config ) |
| 330 | 441 | |
| r8296 | r8297 | |
| 332 | 443 | MDRV_TMS9901_ADD("tms9901", tms9901reset_param_ti99_4x) |
| 333 | 444 | |
| 334 | 445 | MDRV_WD179X_ADD("wd179x", ti99_wd17xx_interface ) |
| 446 | |
| 447 | /* rtc */ |
| 448 | MDRV_MM58274C_ADD("mm58274c_floppy", floppy_mm58274c_interface) |
| 449 | |
| 335 | 450 | MDRV_SMC92X4_ADD("smc92x4", ti99_smc92x4_interface ) |
| 336 | 451 | |
| 337 | 452 | MDRV_FLOPPY_4_DRIVES_ADD(ti99_4p_floppy_config) |
| r8296 | r8297 | |
| 369 | 484 | ROM_END |
| 370 | 485 | |
| 371 | 486 | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT COMPANY FULLNAME */ |
| 372 | | COMP( 1996, ti99_4p, 0, 0, ti99_4p_60hz, ti99_4p, ti99_4p, "System 99 Users Group", "SGCPU (a.k.a. 99/4P)" , GAME_NOT_WORKING ) |
| 487 | COMP( 1996, ti99_4p, 0, 0, ti99_4p_60hz, ti99_4p, ti99_4p, "System 99 Users Group", "SGCPU (a.k.a. 99/4P)" , 0 ) |