src/mess/drivers/amstrad.c
| r2792 | r2793 | |
| 99 | 99 | #include "devices/printer.h" |
| 100 | 100 | #include "devices/cassette.h" |
| 101 | 101 | #include "formats/tzx_cas.h" |
| 102 | | #include "deprecat.h" |
| 103 | 102 | |
| 104 | 103 | |
| 105 | 104 | #ifdef AMSTRAD_VIDEO_EVENT_LIST |
| r2792 | r2793 | |
| 207 | 206 | /*------------- |
| 208 | 207 | - MULTIFACE - |
| 209 | 208 | -------------*/ |
| 210 | | static void multiface_rethink_memory(void); |
| 209 | static void multiface_rethink_memory(running_machine *machine); |
| 211 | 210 | static WRITE8_HANDLER(multiface_io_write); |
| 212 | 211 | static void multiface_init(void); |
| 213 | 212 | static void multiface_stop(running_machine *machine); |
| 214 | | static int multiface_hardware_enabled(void); |
| 213 | static int multiface_hardware_enabled(running_machine *machine); |
| 215 | 214 | static void multiface_reset(void); |
| 216 | 215 | |
| 217 | 216 | static const device_config *printer_device(running_machine *machine) |
| r2792 | r2793 | |
| 467 | 466 | /*----------------- |
| 468 | 467 | - Set Lower Rom - |
| 469 | 468 | -----------------*/ |
| 470 | | void amstrad_setLowerRom(void) |
| 469 | void amstrad_setLowerRom(running_machine *machine) |
| 471 | 470 | { |
| 472 | 471 | unsigned char *BankBase; |
| 473 | 472 | int banknum; |
| r2792 | r2793 | |
| 544 | 543 | /*----------------- |
| 545 | 544 | - Set Upper Rom - |
| 546 | 545 | -----------------*/ |
| 547 | | void amstrad_setUpperRom(void) |
| 546 | void amstrad_setUpperRom(running_machine *machine) |
| 548 | 547 | { |
| 549 | 548 | unsigned char *BankBase; |
| 550 | 549 | /* b3 : "1" Upper rom area disable or "0" Upper rom area enable */ |
| r2792 | r2793 | |
| 567 | 566 | } |
| 568 | 567 | } |
| 569 | 568 | |
| 570 | | static void AmstradCPC_SetLowerRom(int Data) |
| 569 | static void AmstradCPC_SetLowerRom(running_machine *machine, int Data) |
| 571 | 570 | { |
| 572 | 571 | if(amstrad_plus_asic_enabled != 0) |
| 573 | 572 | { |
| r2792 | r2793 | |
| 575 | 574 | amstrad_plus_lower_addr = (Data & 0x18) >> 3; // address of lower ROM area |
| 576 | 575 | if(amstrad_plus_lower_addr == 3) |
| 577 | 576 | { |
| 578 | | memory_install_read8_handler(Machine, 0, ADDRESS_SPACE_PROGRAM, 0x4000, 0x5fff, 0, 0, amstrad_plus_asic_4000_r); |
| 579 | | memory_install_read8_handler(Machine, 0, ADDRESS_SPACE_PROGRAM, 0x6000, 0x7fff, 0, 0, amstrad_plus_asic_6000_r); |
| 580 | | memory_install_write8_handler(Machine, 0, ADDRESS_SPACE_PROGRAM, 0x4000, 0x5fff, 0, 0, amstrad_plus_asic_4000_w); |
| 581 | | memory_install_write8_handler(Machine, 0, ADDRESS_SPACE_PROGRAM, 0x6000, 0x7fff, 0, 0, amstrad_plus_asic_6000_w); |
| 577 | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x4000, 0x5fff, 0, 0, amstrad_plus_asic_4000_r); |
| 578 | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x6000, 0x7fff, 0, 0, amstrad_plus_asic_6000_r); |
| 579 | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x4000, 0x5fff, 0, 0, amstrad_plus_asic_4000_w); |
| 580 | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x6000, 0x7fff, 0, 0, amstrad_plus_asic_6000_w); |
| 582 | 581 | amstrad_plus_asic_regpage = 1; // enable ASIC registers |
| 583 | 582 | } |
| 584 | 583 | else |
| 585 | 584 | { |
| 586 | | memory_install_read8_handler(Machine, 0, ADDRESS_SPACE_PROGRAM, 0x4000, 0x5fff, 0, 0, SMH_BANK3); |
| 587 | | memory_install_read8_handler(Machine, 0, ADDRESS_SPACE_PROGRAM, 0x6000, 0x7fff, 0, 0, SMH_BANK4); |
| 588 | | memory_install_write8_handler(Machine, 0, ADDRESS_SPACE_PROGRAM, 0x4000, 0x5fff, 0, 0, SMH_BANK11); |
| 589 | | memory_install_write8_handler(Machine, 0, ADDRESS_SPACE_PROGRAM, 0x6000, 0x7fff, 0, 0, SMH_BANK12); |
| 585 | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x4000, 0x5fff, 0, 0, SMH_BANK3); |
| 586 | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x6000, 0x7fff, 0, 0, SMH_BANK4); |
| 587 | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x4000, 0x5fff, 0, 0, SMH_BANK11); |
| 588 | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x6000, 0x7fff, 0, 0, SMH_BANK12); |
| 590 | 589 | amstrad_plus_asic_regpage = 0; // disable ASIC registers |
| 591 | 590 | } |
| 592 | 591 | // logerror("SYS: Secondary ROM select (lower ROM) - data = %02x - cart bank %i, addr %i\n",Data,amstrad_plus_lower,amstrad_plus_lower_addr); |
| r2792 | r2793 | |
| 596 | 595 | amstrad_plus_lower = 0; |
| 597 | 596 | amstrad_plus_lower_addr = 0; |
| 598 | 597 | } |
| 599 | | // amstrad_setLowerRom(); |
| 598 | // amstrad_setLowerRom(machine); |
| 600 | 599 | } |
| 601 | 600 | |
| 602 | | void AmstradCPC_SetUpperRom(int Data) |
| 601 | void AmstradCPC_SetUpperRom(running_machine *machine, int Data) |
| 603 | 602 | { |
| 604 | 603 | Amstrad_UpperRom = Amstrad_ROM_Table[Data & 0xFF]; |
| 605 | 604 | // logerror("H-ROM: set to ROM bank %i\n",Data); |
| 606 | | amstrad_setUpperRom(); |
| 605 | amstrad_setUpperRom(machine); |
| 607 | 606 | } |
| 608 | 607 | |
| 609 | 608 | /* ASIC RAM */ |
| r2792 | r2793 | |
| 869 | 868 | /*------------------ |
| 870 | 869 | - Rethink Memory - |
| 871 | 870 | ------------------*/ |
| 872 | | void amstrad_rethinkMemory(void) |
| 871 | void amstrad_rethinkMemory(running_machine *machine) |
| 873 | 872 | { |
| 874 | 873 | /* the following is used for banked memory read/writes and for setting up |
| 875 | 874 | * opcode and opcode argument reads */ |
| 876 | 875 | /* bank 0 - 0x0000..0x03fff */ |
| 877 | | amstrad_setLowerRom(); |
| 876 | amstrad_setLowerRom(machine); |
| 878 | 877 | /* bank 1 - 0x04000..0x07fff */ |
| 879 | 878 | if(amstrad_system_type == SYSTEM_CPC || amstrad_plus_asic_enabled == 0) |
| 880 | 879 | { |
| r2792 | r2793 | |
| 896 | 895 | } |
| 897 | 896 | } |
| 898 | 897 | else |
| 899 | | amstrad_setLowerRom(); |
| 898 | amstrad_setLowerRom(machine); |
| 900 | 899 | /* bank 3 - 0x0c000..0x0ffff */ |
| 901 | | amstrad_setUpperRom(); |
| 900 | amstrad_setUpperRom(machine); |
| 902 | 901 | /* other banks */ |
| 903 | 902 | if(aleste_mode & 0x04) |
| 904 | 903 | { |
| r2792 | r2793 | |
| 924 | 923 | } |
| 925 | 924 | |
| 926 | 925 | /* multiface hardware enabled? */ |
| 927 | | if (multiface_hardware_enabled()) { |
| 928 | | multiface_rethink_memory(); |
| 926 | if (multiface_hardware_enabled(machine)) { |
| 927 | multiface_rethink_memory(machine); |
| 929 | 928 | } |
| 930 | 929 | } |
| 931 | 930 | /* simplified ram configuration - e.g. only correct for 128k machines |
| r2792 | r2793 | |
| 944 | 943 | The CPC6128 has a 64k ram expansion built-in, giving 128K of RAM in this system. |
| 945 | 944 | In the CPC464,CPC664 and KC compact if a ram expansion is not present, then writing to this port has no effect and the ram will be in the same arrangement as if configuration 0 had been selected. |
| 946 | 945 | */ |
| 947 | | static void AmstradCPC_GA_SetRamConfiguration(void) |
| 946 | static void AmstradCPC_GA_SetRamConfiguration(running_machine *machine) |
| 948 | 947 | { |
| 949 | 948 | int ConfigurationIndex = amstrad_GateArray_RamConfiguration & 0x07; |
| 950 | 949 | int BankIndex,i; |
| r2792 | r2793 | |
| 959 | 958 | } |
| 960 | 959 | } else {/* Need to add the ram expansion configuration here ! */ |
| 961 | 960 | } |
| 962 | | amstrad_rethinkMemory(); |
| 961 | amstrad_rethinkMemory(machine); |
| 963 | 962 | } |
| 964 | 963 | /* ------------------- |
| 965 | 964 | - the Gate Array - |
| r2792 | r2793 | |
| 1057 | 1056 | { |
| 1058 | 1057 | if((dataToGateArray & 0x20) != 0) |
| 1059 | 1058 | { |
| 1060 | | AmstradCPC_SetLowerRom(dataToGateArray); |
| 1059 | AmstradCPC_SetLowerRom(machine, dataToGateArray); |
| 1061 | 1060 | break; |
| 1062 | 1061 | } |
| 1063 | 1062 | else |
| r2792 | r2793 | |
| 1081 | 1080 | } |
| 1082 | 1081 | /* b3b2 != 0 then change the state of upper or lower rom area and rethink memory */ |
| 1083 | 1082 | if (((amstrad_GateArray_ModeAndRomConfiguration & 0x0C)^(Previous_GateArray_ModeAndRomConfiguration & 0x0C)) != 0) { |
| 1084 | | amstrad_setLowerRom(); |
| 1085 | | amstrad_setUpperRom(); |
| 1083 | amstrad_setLowerRom(machine); |
| 1084 | amstrad_setUpperRom(machine); |
| 1086 | 1085 | } |
| 1087 | 1086 | /* b1b0 mode change? */ |
| 1088 | 1087 | if (((amstrad_GateArray_ModeAndRomConfiguration & 0x03)^(Previous_GateArray_ModeAndRomConfiguration & 0x03)) != 0) { |
| r2792 | r2793 | |
| 1173 | 1172 | } |
| 1174 | 1173 | |
| 1175 | 1174 | /* used for loading snapshot only ! */ |
| 1176 | | void AmstradCPC_PALWrite(int data) |
| 1175 | void AmstradCPC_PALWrite(running_machine *machine, int data) |
| 1177 | 1176 | { |
| 1178 | 1177 | if ((data & 0x0c0)==0x0c0) { |
| 1179 | 1178 | amstrad_GateArray_RamConfiguration = data; |
| 1180 | | AmstradCPC_GA_SetRamConfiguration(); |
| 1179 | AmstradCPC_GA_SetRamConfiguration(machine); |
| 1181 | 1180 | } |
| 1182 | 1181 | } |
| 1183 | 1182 | |
| r2792 | r2793 | |
| 1355 | 1354 | if ((offset & (1<<14)) != 0) |
| 1356 | 1355 | amstrad_GateArray_write(machine, data); |
| 1357 | 1356 | /* if b15 = 0 : RAM Configuration Write Selected*/ |
| 1358 | | AmstradCPC_GA_SetRamConfiguration(); |
| 1357 | AmstradCPC_GA_SetRamConfiguration(machine); |
| 1359 | 1358 | } |
| 1360 | 1359 | } |
| 1361 | 1360 | /*The Gate-Array and CRTC can't be selected simultaneously, which would otherwise cause potential display corruption.*/ |
| r2792 | r2793 | |
| 1388 | 1387 | { |
| 1389 | 1388 | if (previous_amstrad_UpperRom_data != (data & 0xff)) |
| 1390 | 1389 | { |
| 1391 | | AmstradCPC_SetUpperRom(data); |
| 1390 | AmstradCPC_SetUpperRom(machine, data); |
| 1392 | 1391 | } |
| 1393 | 1392 | previous_amstrad_UpperRom_data = (data & 0xff); |
| 1394 | 1393 | } |
| r2792 | r2793 | |
| 1606 | 1605 | multiface_flags |= MULTIFACE_VISIBLE; |
| 1607 | 1606 | } |
| 1608 | 1607 | |
| 1609 | | int multiface_hardware_enabled(void) |
| 1608 | int multiface_hardware_enabled(running_machine *machine) |
| 1610 | 1609 | { |
| 1611 | 1610 | if (multiface_ram!=NULL) |
| 1612 | 1611 | { |
| 1613 | | if ((input_port_read(Machine, "multiface") & 0x01)!=0) |
| 1612 | if ((input_port_read(machine, "multiface") & 0x01)!=0) |
| 1614 | 1613 | { |
| 1615 | 1614 | return 1; |
| 1616 | 1615 | } |
| r2792 | r2793 | |
| 1623 | 1622 | void multiface_stop(running_machine *machine) |
| 1624 | 1623 | { |
| 1625 | 1624 | /* multiface hardware enabled? */ |
| 1626 | | if (!multiface_hardware_enabled()) |
| 1625 | if (!multiface_hardware_enabled(machine)) |
| 1627 | 1626 | return; |
| 1628 | 1627 | |
| 1629 | 1628 | /* if stop button not already pressed, do press action */ |
| r2792 | r2793 | |
| 1641 | 1640 | amstrad_GateArray_ModeAndRomConfiguration &=~0x04; |
| 1642 | 1641 | |
| 1643 | 1642 | /* page rom into memory */ |
| 1644 | | multiface_rethink_memory(); |
| 1643 | multiface_rethink_memory(machine); |
| 1645 | 1644 | |
| 1646 | 1645 | /* pulse the nmi line */ |
| 1647 | 1646 | cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, PULSE_LINE); |
| r2792 | r2793 | |
| 1652 | 1651 | |
| 1653 | 1652 | } |
| 1654 | 1653 | |
| 1655 | | static void multiface_rethink_memory(void) |
| 1654 | static void multiface_rethink_memory(running_machine *machine) |
| 1656 | 1655 | { |
| 1657 | | unsigned char *multiface_rom; |
| 1656 | unsigned char *multiface_rom; |
| 1658 | 1657 | |
| 1659 | 1658 | /* multiface hardware enabled? */ |
| 1660 | | if (!multiface_hardware_enabled()) |
| 1659 | if (!multiface_hardware_enabled(machine)) |
| 1661 | 1660 | return; |
| 1662 | 1661 | |
| 1663 | | multiface_rom = &memory_region(REGION_CPU1)[0x01C000]; |
| 1662 | multiface_rom = &memory_region(REGION_CPU1)[0x01C000]; |
| 1664 | 1663 | |
| 1665 | 1664 | if ( |
| 1666 | 1665 | ((multiface_flags & MULTIFACE_RAM_ROM_ENABLED)!=0) && |
| r2792 | r2793 | |
| 1680 | 1679 | static WRITE8_HANDLER(multiface_io_write) |
| 1681 | 1680 | { |
| 1682 | 1681 | /* multiface hardware enabled? */ |
| 1683 | | if (!multiface_hardware_enabled()) |
| 1682 | if (!multiface_hardware_enabled(machine)) |
| 1684 | 1683 | return; |
| 1685 | 1684 | |
| 1686 | 1685 | /* visible? */ |
| r2792 | r2793 | |
| 1689 | 1688 | if (offset==0x0fee8) |
| 1690 | 1689 | { |
| 1691 | 1690 | multiface_flags |= MULTIFACE_RAM_ROM_ENABLED; |
| 1692 | | amstrad_rethinkMemory(); |
| 1691 | amstrad_rethinkMemory(machine); |
| 1693 | 1692 | } |
| 1694 | 1693 | |
| 1695 | 1694 | if (offset==0x0feea) |
| 1696 | 1695 | { |
| 1697 | 1696 | multiface_flags &= ~MULTIFACE_RAM_ROM_ENABLED; |
| 1698 | | amstrad_rethinkMemory(); |
| 1697 | amstrad_rethinkMemory(machine); |
| 1699 | 1698 | } |
| 1700 | 1699 | } |
| 1701 | 1700 | |
| r2792 | r2793 | |
| 2135 | 2134 | amstrad_common_init(machine); |
| 2136 | 2135 | amstrad_reset_machine(machine); |
| 2137 | 2136 | amstrad_plus_asic_ram[0x2805] = 0x01; // interrupt vector is undefined at startup, except that bit 0 is always 1. |
| 2138 | | AmstradCPC_GA_SetRamConfiguration(); |
| 2137 | AmstradCPC_GA_SetRamConfiguration(machine); |
| 2139 | 2138 | amstrad_plus_setsplitline(0,0); |
| 2140 | 2139 | // multiface_init(); |
| 2141 | 2140 | } |
| r2792 | r2793 | |
| 2184 | 2183 | amstrad_common_init(machine); |
| 2185 | 2184 | amstrad_reset_machine(machine); |
| 2186 | 2185 | amstrad_plus_asic_ram[0x2805] = 0x01; // interrupt vector is undefined at startup, except that bit 0 is always 1. |
| 2187 | | AmstradCPC_GA_SetRamConfiguration(); |
| 2186 | AmstradCPC_GA_SetRamConfiguration(machine); |
| 2188 | 2187 | amstrad_plus_setsplitline(0,0); |
| 2189 | 2188 | // multiface_init(); |
| 2190 | 2189 | } |