trunk/src/mess/drivers/atari400.c
| r20782 | r20783 | |
| 251 | 251 | public: |
| 252 | 252 | a400_state(const machine_config &mconfig, device_type type, const char *tag) |
| 253 | 253 | : driver_device(mconfig, type, tag) |
| 254 | , m_maincpu(*this, "maincpu") |
| 255 | , m_ram(*this, RAM_TAG) |
| 256 | , m_pia(*this, "pia") |
| 254 | 257 | , m_a800_cart_loaded(0) |
| 255 | 258 | , m_atari(0) |
| 256 | 259 | , m_a800_cart_type(A800_UNKNOWN) |
| 260 | , m_xegs_banks(0) |
| 261 | , m_xegs_cart(0) |
| 257 | 262 | { } |
| 258 | 263 | |
| 259 | 264 | DECLARE_DRIVER_INIT(xegs); |
| 260 | 265 | DECLARE_DRIVER_INIT(a800xl); |
| 261 | 266 | DECLARE_DRIVER_INIT(a600xl); |
| 267 | DECLARE_MACHINE_START(xegs); |
| 268 | DECLARE_MACHINE_START(a400); |
| 269 | DECLARE_MACHINE_START(a800); |
| 270 | DECLARE_MACHINE_START(a800xl); |
| 271 | DECLARE_MACHINE_START(a5200); |
| 262 | 272 | virtual void palette_init(); |
| 263 | 273 | DECLARE_WRITE8_MEMBER(a1200xl_pia_pb_w); |
| 264 | 274 | DECLARE_WRITE8_MEMBER(a800xl_pia_pb_w); |
| 265 | 275 | DECLARE_WRITE8_MEMBER(xegs_pia_pb_w); |
| 276 | DECLARE_WRITE8_MEMBER(x32_bank_w); |
| 277 | DECLARE_WRITE8_MEMBER(w64_bank_w); |
| 278 | DECLARE_WRITE8_MEMBER(ex64_bank_w); |
| 279 | DECLARE_WRITE8_MEMBER(bbsb_bankl_w); |
| 280 | DECLARE_WRITE8_MEMBER(bbsb_bankh_w); |
| 281 | DECLARE_WRITE8_MEMBER(oss_034m_w); |
| 282 | DECLARE_WRITE8_MEMBER(oss_m091_w); |
| 283 | DECLARE_WRITE8_MEMBER(xegs_bankswitch); |
| 266 | 284 | |
| 267 | 285 | DECLARE_DEVICE_IMAGE_LOAD_MEMBER( a800_cart ); |
| 268 | 286 | DECLARE_DEVICE_IMAGE_UNLOAD_MEMBER( a800_cart ); |
| r20782 | r20783 | |
| 280 | 298 | void ms_atari800xl_machine_start(int type, int has_cart); |
| 281 | 299 | |
| 282 | 300 | protected: |
| 301 | required_device<cpu_device> m_maincpu; |
| 302 | required_device<ram_device> m_ram; |
| 303 | required_device<pia6821_device> m_pia; |
| 304 | |
| 283 | 305 | int m_a800_cart_loaded; |
| 284 | 306 | int m_atari; |
| 285 | 307 | int m_a800_cart_type; |
| 308 | UINT8 m_xegs_banks; |
| 309 | UINT8 m_xegs_cart; |
| 286 | 310 | |
| 287 | 311 | void a800_setbank(int cart_mounted); |
| 288 | | |
| 312 | void a800xl_mmu(UINT8 new_mmu); |
| 313 | void a1200xl_mmu(UINT8 new_mmu); |
| 314 | void xegs_mmu(UINT8 new_mmu); |
| 315 | void a800_setup_mappers(int type); |
| 289 | 316 | }; |
| 290 | 317 | |
| 291 | 318 | /************************************************************** |
| r20782 | r20783 | |
| 795 | 822 | * |
| 796 | 823 | **************************************************************/ |
| 797 | 824 | |
| 798 | | static void a800xl_mmu(running_machine &machine, UINT8 new_mmu) |
| 825 | void a400_state::a800xl_mmu(UINT8 new_mmu) |
| 799 | 826 | { |
| 800 | | UINT8 *base = machine.root_device().memregion("maincpu")->base(); |
| 827 | UINT8 *base = memregion("maincpu")->base(); |
| 801 | 828 | UINT8 *base1, *base2, *base3, *base4; |
| 802 | 829 | |
| 803 | 830 | /* check if memory C000-FFFF changed */ |
| 804 | 831 | if( new_mmu & 0x01 ) |
| 805 | 832 | { |
| 806 | | logerror("%s MMU BIOS ROM\n", machine.system().name); |
| 833 | logerror("%s MMU BIOS ROM\n", machine().system().name); |
| 807 | 834 | base3 = base + 0x14000; /* 8K lo BIOS */ |
| 808 | 835 | base4 = base + 0x15800; /* 4K FP ROM + 8K hi BIOS */ |
| 809 | | machine.device("maincpu")->memory().space(AS_PROGRAM).install_read_bank(0xc000, 0xcfff, "bank3"); |
| 810 | | machine.device("maincpu")->memory().space(AS_PROGRAM).unmap_write(0xc000, 0xcfff); |
| 811 | | machine.device("maincpu")->memory().space(AS_PROGRAM).install_read_bank(0xd800, 0xffff, "bank4"); |
| 812 | | machine.device("maincpu")->memory().space(AS_PROGRAM).unmap_write(0xd800, 0xffff); |
| 836 | m_maincpu->space(AS_PROGRAM).install_read_bank(0xc000, 0xcfff, "bank3"); |
| 837 | m_maincpu->space(AS_PROGRAM).unmap_write(0xc000, 0xcfff); |
| 838 | m_maincpu->space(AS_PROGRAM).install_read_bank(0xd800, 0xffff, "bank4"); |
| 839 | m_maincpu->space(AS_PROGRAM).unmap_write(0xd800, 0xffff); |
| 813 | 840 | } |
| 814 | 841 | else |
| 815 | 842 | { |
| 816 | | logerror("%s MMU BIOS RAM\n", machine.system().name); |
| 843 | logerror("%s MMU BIOS RAM\n", machine().system().name); |
| 817 | 844 | base3 = base + 0x0c000; /* 8K RAM */ |
| 818 | 845 | base4 = base + 0x0d800; /* 4K RAM + 8K RAM */ |
| 819 | | machine.device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_bank(0xc000, 0xcfff, "bank3"); |
| 820 | | machine.device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_bank(0xd800, 0xffff, "bank4"); |
| 846 | m_maincpu->space(AS_PROGRAM).install_readwrite_bank(0xc000, 0xcfff, "bank3"); |
| 847 | m_maincpu->space(AS_PROGRAM).install_readwrite_bank(0xd800, 0xffff, "bank4"); |
| 821 | 848 | } |
| 822 | | machine.root_device().membank("bank3")->set_base(base3); |
| 823 | | machine.root_device().membank("bank4")->set_base(base4); |
| 849 | membank("bank3")->set_base(base3); |
| 850 | membank("bank4")->set_base(base4); |
| 824 | 851 | |
| 825 | 852 | /* check if BASIC changed */ |
| 826 | 853 | if( new_mmu & 0x02 ) |
| 827 | 854 | { |
| 828 | | logerror("%s MMU BASIC RAM\n", machine.system().name); |
| 829 | | machine.device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_bank(0xa000, 0xbfff, "bank1"); |
| 855 | logerror("%s MMU BASIC RAM\n", machine().system().name); |
| 856 | m_maincpu->space(AS_PROGRAM).install_readwrite_bank(0xa000, 0xbfff, "bank1"); |
| 830 | 857 | base1 = base + 0x0a000; /* 8K RAM */ |
| 831 | 858 | } |
| 832 | 859 | else |
| 833 | 860 | { |
| 834 | | logerror("%s MMU BASIC ROM\n", machine.system().name); |
| 835 | | machine.device("maincpu")->memory().space(AS_PROGRAM).install_read_bank(0xa000, 0xbfff, "bank1"); |
| 836 | | machine.device("maincpu")->memory().space(AS_PROGRAM).nop_write(0xa000, 0xbfff); |
| 861 | logerror("%s MMU BASIC ROM\n", machine().system().name); |
| 862 | m_maincpu->space(AS_PROGRAM).install_read_bank(0xa000, 0xbfff, "bank1"); |
| 863 | m_maincpu->space(AS_PROGRAM).nop_write(0xa000, 0xbfff); |
| 837 | 864 | base1 = base + 0x10000; /* 8K BASIC */ |
| 838 | 865 | } |
| 839 | 866 | |
| 840 | | machine.root_device().membank("bank1")->set_base(base1); |
| 867 | membank("bank1")->set_base(base1); |
| 841 | 868 | |
| 842 | 869 | /* check if self-test ROM changed */ |
| 843 | 870 | if( new_mmu & 0x80 ) |
| 844 | 871 | { |
| 845 | | logerror("%s MMU SELFTEST RAM\n", machine.system().name); |
| 846 | | machine.device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_bank(0x5000, 0x57ff, "bank2"); |
| 872 | logerror("%s MMU SELFTEST RAM\n", machine().system().name); |
| 873 | m_maincpu->space(AS_PROGRAM).install_readwrite_bank(0x5000, 0x57ff, "bank2"); |
| 847 | 874 | base2 = base + 0x05000; /* 0x0800 bytes */ |
| 848 | 875 | } |
| 849 | 876 | else |
| 850 | 877 | { |
| 851 | | logerror("%s MMU SELFTEST ROM\n", machine.system().name); |
| 852 | | machine.device("maincpu")->memory().space(AS_PROGRAM).install_read_bank(0x5000, 0x57ff, "bank2"); |
| 853 | | machine.device("maincpu")->memory().space(AS_PROGRAM).nop_write(0x5000, 0x57ff); |
| 878 | logerror("%s MMU SELFTEST ROM\n", machine().system().name); |
| 879 | m_maincpu->space(AS_PROGRAM).install_read_bank(0x5000, 0x57ff, "bank2"); |
| 880 | m_maincpu->space(AS_PROGRAM).nop_write(0x5000, 0x57ff); |
| 854 | 881 | base2 = base + 0x15000; /* 0x0800 bytes */ |
| 855 | 882 | } |
| 856 | | machine.root_device().membank("bank2")->set_base(base2); |
| 883 | membank("bank2")->set_base(base2); |
| 857 | 884 | } |
| 858 | 885 | |
| 859 | 886 | /* BASIC was available in a separate cart, so we don't test it */ |
| 860 | | static void a1200xl_mmu(running_machine &machine, UINT8 new_mmu) |
| 887 | void a400_state::a1200xl_mmu(UINT8 new_mmu) |
| 861 | 888 | { |
| 862 | | UINT8 *base = machine.root_device().memregion("maincpu")->base(); |
| 889 | UINT8 *base = memregion("maincpu")->base(); |
| 863 | 890 | UINT8 *base2, *base3, *base4; |
| 864 | 891 | |
| 865 | 892 | /* check if memory C000-FFFF changed */ |
| 866 | 893 | if( new_mmu & 0x01 ) |
| 867 | 894 | { |
| 868 | | logerror("%s MMU BIOS ROM\n", machine.system().name); |
| 895 | logerror("%s MMU BIOS ROM\n", machine().system().name); |
| 869 | 896 | base3 = base + 0x14000; /* 8K lo BIOS */ |
| 870 | 897 | base4 = base + 0x15800; /* 4K FP ROM + 8K hi BIOS */ |
| 871 | | machine.device("maincpu")->memory().space(AS_PROGRAM).install_read_bank(0xc000, 0xcfff, "bank3"); |
| 872 | | machine.device("maincpu")->memory().space(AS_PROGRAM).unmap_write(0xc000, 0xcfff); |
| 873 | | machine.device("maincpu")->memory().space(AS_PROGRAM).install_read_bank(0xd800, 0xffff, "bank4"); |
| 874 | | machine.device("maincpu")->memory().space(AS_PROGRAM).unmap_write(0xd800, 0xffff); |
| 898 | m_maincpu->space(AS_PROGRAM).install_read_bank(0xc000, 0xcfff, "bank3"); |
| 899 | m_maincpu->space(AS_PROGRAM).unmap_write(0xc000, 0xcfff); |
| 900 | m_maincpu->space(AS_PROGRAM).install_read_bank(0xd800, 0xffff, "bank4"); |
| 901 | m_maincpu->space(AS_PROGRAM).unmap_write(0xd800, 0xffff); |
| 875 | 902 | } |
| 876 | 903 | else |
| 877 | 904 | { |
| 878 | | logerror("%s MMU BIOS RAM\n", machine.system().name); |
| 905 | logerror("%s MMU BIOS RAM\n", machine().system().name); |
| 879 | 906 | base3 = base + 0x0c000; /* 8K RAM */ |
| 880 | 907 | base4 = base + 0x0d800; /* 4K RAM + 8K RAM */ |
| 881 | | machine.device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_bank(0xc000, 0xcfff, "bank3"); |
| 882 | | machine.device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_bank(0xd800, 0xffff, "bank4"); |
| 908 | m_maincpu->space(AS_PROGRAM).install_readwrite_bank(0xc000, 0xcfff, "bank3"); |
| 909 | m_maincpu->space(AS_PROGRAM).install_readwrite_bank(0xd800, 0xffff, "bank4"); |
| 883 | 910 | } |
| 884 | | machine.root_device().membank("bank3")->set_base(base3); |
| 885 | | machine.root_device().membank("bank4")->set_base(base4); |
| 911 | membank("bank3")->set_base(base3); |
| 912 | membank("bank4")->set_base(base4); |
| 886 | 913 | |
| 887 | 914 | /* check if self-test ROM changed */ |
| 888 | 915 | if( new_mmu & 0x80 ) |
| 889 | 916 | { |
| 890 | | logerror("%s MMU SELFTEST RAM\n", machine.system().name); |
| 917 | logerror("%s MMU SELFTEST RAM\n", machine().system().name); |
| 891 | 918 | base2 = base + 0x05000; /* 0x0800 bytes */ |
| 892 | | machine.device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_bank(0x5000, 0x57ff, "bank2"); |
| 919 | m_maincpu->space(AS_PROGRAM).install_readwrite_bank(0x5000, 0x57ff, "bank2"); |
| 893 | 920 | } |
| 894 | 921 | else |
| 895 | 922 | { |
| 896 | | logerror("%s MMU SELFTEST ROM\n", machine.system().name); |
| 923 | logerror("%s MMU SELFTEST ROM\n", machine().system().name); |
| 897 | 924 | base2 = base + 0x15000; /* 0x0800 bytes */ |
| 898 | | machine.device("maincpu")->memory().space(AS_PROGRAM).install_read_bank(0x5000, 0x57ff, "bank2"); |
| 899 | | machine.device("maincpu")->memory().space(AS_PROGRAM).unmap_write(0x5000, 0x57ff); |
| 925 | m_maincpu->space(AS_PROGRAM).install_read_bank(0x5000, 0x57ff, "bank2"); |
| 926 | m_maincpu->space(AS_PROGRAM).unmap_write(0x5000, 0x57ff); |
| 900 | 927 | } |
| 901 | | machine.root_device().membank("bank2")->set_base(base2); |
| 928 | membank("bank2")->set_base(base2); |
| 902 | 929 | } |
| 903 | 930 | |
| 904 | | static void xegs_mmu(running_machine &machine, UINT8 new_mmu) |
| 931 | void a400_state::xegs_mmu(UINT8 new_mmu) |
| 905 | 932 | { |
| 906 | | UINT8 *base = machine.root_device().memregion("maincpu")->base(); |
| 933 | UINT8 *base = memregion("maincpu")->base(); |
| 907 | 934 | UINT8 *base2, *base3, *base4; |
| 908 | 935 | |
| 909 | 936 | /* check if memory C000-FFFF changed */ |
| 910 | 937 | if( new_mmu & 0x01 ) |
| 911 | 938 | { |
| 912 | | logerror("%s MMU BIOS ROM\n", machine.system().name); |
| 939 | logerror("%s MMU BIOS ROM\n", machine().system().name); |
| 913 | 940 | base3 = base + 0x14000; /* 8K lo BIOS */ |
| 914 | 941 | base4 = base + 0x15800; /* 4K FP ROM + 8K hi BIOS */ |
| 915 | | machine.device("maincpu")->memory().space(AS_PROGRAM).install_read_bank(0xc000, 0xcfff, "bank3"); |
| 916 | | machine.device("maincpu")->memory().space(AS_PROGRAM).unmap_write(0xc000, 0xcfff); |
| 917 | | machine.device("maincpu")->memory().space(AS_PROGRAM).install_read_bank(0xd800, 0xffff, "bank4"); |
| 918 | | machine.device("maincpu")->memory().space(AS_PROGRAM).unmap_write(0xd800, 0xffff); |
| 942 | m_maincpu->space(AS_PROGRAM).install_read_bank(0xc000, 0xcfff, "bank3"); |
| 943 | m_maincpu->space(AS_PROGRAM).unmap_write(0xc000, 0xcfff); |
| 944 | m_maincpu->space(AS_PROGRAM).install_read_bank(0xd800, 0xffff, "bank4"); |
| 945 | m_maincpu->space(AS_PROGRAM).unmap_write(0xd800, 0xffff); |
| 919 | 946 | } |
| 920 | 947 | else |
| 921 | 948 | { |
| 922 | | logerror("%s MMU BIOS RAM\n", machine.system().name); |
| 949 | logerror("%s MMU BIOS RAM\n", machine().system().name); |
| 923 | 950 | base3 = base + 0x0c000; /* 8K RAM */ |
| 924 | 951 | base4 = base + 0x0d800; /* 4K RAM + 8K RAM */ |
| 925 | | machine.device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_bank(0xc000, 0xcfff, "bank3"); |
| 926 | | machine.device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_bank(0xd800, 0xffff, "bank4"); |
| 952 | m_maincpu->space(AS_PROGRAM).install_readwrite_bank(0xc000, 0xcfff, "bank3"); |
| 953 | m_maincpu->space(AS_PROGRAM).install_readwrite_bank(0xd800, 0xffff, "bank4"); |
| 927 | 954 | } |
| 928 | | machine.root_device().membank("bank3")->set_base(base3); |
| 929 | | machine.root_device().membank("bank4")->set_base(base4); |
| 955 | membank("bank3")->set_base(base3); |
| 956 | membank("bank4")->set_base(base4); |
| 930 | 957 | |
| 931 | 958 | |
| 932 | 959 | /* check if self-test ROM changed */ |
| 933 | 960 | if( new_mmu & 0x80 ) |
| 934 | 961 | { |
| 935 | | logerror("%s MMU SELFTEST RAM\n", machine.system().name); |
| 936 | | machine.device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_bank(0x5000, 0x57ff, "bank2"); |
| 962 | logerror("%s MMU SELFTEST RAM\n", machine().system().name); |
| 963 | m_maincpu->space(AS_PROGRAM).install_readwrite_bank(0x5000, 0x57ff, "bank2"); |
| 937 | 964 | base2 = base + 0x05000; /* 0x0800 bytes */ |
| 938 | 965 | } |
| 939 | 966 | else |
| 940 | 967 | { |
| 941 | | logerror("%s MMU SELFTEST ROM\n", machine.system().name); |
| 942 | | machine.device("maincpu")->memory().space(AS_PROGRAM).install_read_bank(0x5000, 0x57ff, "bank2"); |
| 943 | | machine.device("maincpu")->memory().space(AS_PROGRAM).nop_write(0x5000, 0x57ff); |
| 968 | logerror("%s MMU SELFTEST ROM\n", machine().system().name); |
| 969 | m_maincpu->space(AS_PROGRAM).install_read_bank(0x5000, 0x57ff, "bank2"); |
| 970 | m_maincpu->space(AS_PROGRAM).nop_write(0x5000, 0x57ff); |
| 944 | 971 | base2 = base + 0x15000; /* 0x0800 bytes */ |
| 945 | 972 | } |
| 946 | | machine.root_device().membank("bank2")->set_base(base2); |
| 973 | membank("bank2")->set_base(base2); |
| 947 | 974 | } |
| 948 | 975 | |
| 949 | 976 | |
| r20782 | r20783 | |
| 952 | 979 | { |
| 953 | 980 | offs_t ram_top; |
| 954 | 981 | // take care of 0x0000-0x7fff: RAM or NOP |
| 955 | | ram_top = MIN(machine().device<ram_device>(RAM_TAG)->size(), 0x8000) - 1; |
| 956 | | machine().device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_bank(0x0000, ram_top, "0000"); |
| 957 | | machine().root_device().membank("0000")->set_base(machine().device<ram_device>(RAM_TAG)->pointer()); |
| 982 | ram_top = MIN(m_ram->size(), 0x8000) - 1; |
| 983 | m_maincpu->space(AS_PROGRAM).install_readwrite_bank(0x0000, ram_top, "0000"); |
| 984 | membank("0000")->set_base(m_ram->pointer()); |
| 958 | 985 | |
| 959 | 986 | // take care of 0x8000-0x9fff: A800 -> either right slot or RAM or NOP, others -> RAM or NOP |
| 960 | 987 | // is there anything in the right slot? |
| 961 | 988 | if (cart_mounted & RIGHT_CARTSLOT_MOUNTED) |
| 962 | 989 | { |
| 963 | | machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_bank(0x8000, 0x9fff, "8000"); |
| 964 | | machine().root_device().membank("8000")->set_base(machine().root_device().memregion("rslot")->base()); |
| 965 | | machine().device("maincpu")->memory().space(AS_PROGRAM).unmap_write(0x8000, 0x9fff); |
| 990 | m_maincpu->space(AS_PROGRAM).install_read_bank(0x8000, 0x9fff, "8000"); |
| 991 | membank("8000")->set_base(memregion("rslot")->base()); |
| 992 | m_maincpu->space(AS_PROGRAM).unmap_write(0x8000, 0x9fff); |
| 966 | 993 | } |
| 967 | 994 | else if (m_a800_cart_type != BBSB) |
| 968 | 995 | { |
| 969 | | ram_top = MIN(machine().device<ram_device>(RAM_TAG)->size(), 0xa000) - 1; |
| 996 | ram_top = MIN(m_ram->size(), 0xa000) - 1; |
| 970 | 997 | if (ram_top > 0x8000) |
| 971 | 998 | { |
| 972 | | machine().device("maincpu")->memory().space(AS_PROGRAM).install_readwrite_bank(0x8000, ram_top, "8000"); |
| 973 | | machine().root_device().membank("8000")->set_base(machine().device<ram_device>(RAM_TAG)->pointer() + 0x8000); |
| 999 | m_maincpu->space(AS_PROGRAM).install_readwrite_bank(0x8000, ram_top, "8000"); |
| 1000 | membank("8000")->set_base(m_ram->pointer() + 0x8000); |
| 974 | 1001 | } |
| 975 | 1002 | } |
| 976 | 1003 | |
| r20782 | r20783 | |
| 982 | 1009 | { |
| 983 | 1010 | if (m_a800_cart_type == A800_16K) |
| 984 | 1011 | { |
| 985 | | machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_bank(0x8000, 0x9fff, "8000"); |
| 986 | | machine().root_device().membank("8000")->set_base(machine().root_device().memregion("lslot")->base()); |
| 987 | | machine().device("maincpu")->memory().space(AS_PROGRAM).unmap_write(0x8000, 0x9fff); |
| 1012 | m_maincpu->space(AS_PROGRAM).install_read_bank(0x8000, 0x9fff, "8000"); |
| 1013 | membank("8000")->set_base(memregion("lslot")->base()); |
| 1014 | m_maincpu->space(AS_PROGRAM).unmap_write(0x8000, 0x9fff); |
| 988 | 1015 | |
| 989 | | memcpy(machine().root_device().memregion("maincpu")->base() + 0x10000, machine().root_device().memregion("lslot")->base() + 0x2000, 0x2000); |
| 1016 | memcpy(memregion("maincpu")->base() + 0x10000, memregion("lslot")->base() + 0x2000, 0x2000); |
| 990 | 1017 | } |
| 991 | 1018 | else if (m_a800_cart_type == A800_8K) |
| 992 | | memcpy(machine().root_device().memregion("maincpu")->base() + 0x10000, machine().root_device().memregion("lslot")->base(), 0x2000); |
| 1019 | memcpy(memregion("maincpu")->base() + 0x10000, memregion("lslot")->base(), 0x2000); |
| 993 | 1020 | else |
| 994 | 1021 | fatalerror("This type of cart is not supported yet in this driver. Please use a400 or a800.\n"); |
| 995 | 1022 | } |
| 996 | 1023 | else if (m_a800_cart_type == A800_16K) |
| 997 | 1024 | { |
| 998 | | machine().root_device().membank("8000")->set_base(machine().root_device().memregion("lslot")->base()); |
| 999 | | machine().root_device().membank("a000")->set_base(machine().root_device().memregion("lslot")->base() + 0x2000); |
| 1000 | | machine().device("maincpu")->memory().space(AS_PROGRAM).unmap_write(0x8000, 0xbfff); |
| 1025 | membank("8000")->set_base(memregion("lslot")->base()); |
| 1026 | membank("a000")->set_base(memregion("lslot")->base() + 0x2000); |
| 1027 | m_maincpu->space(AS_PROGRAM).unmap_write(0x8000, 0xbfff); |
| 1001 | 1028 | } |
| 1002 | 1029 | else if (m_a800_cart_type == BBSB) |
| 1003 | 1030 | { |
| 1004 | 1031 | // this requires separate banking in 0x8000 & 0x9000! |
| 1005 | | machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_bank(0x8000, 0x8fff, "8000"); |
| 1006 | | machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_bank(0x9000, 0x9fff, "9000"); |
| 1007 | | machine().root_device().membank("8000")->set_base(machine().root_device().memregion("lslot")->base() + 0x0000); |
| 1008 | | machine().root_device().membank("9000")->set_base(machine().root_device().memregion("lslot")->base() + 0x4000); |
| 1009 | | machine().root_device().membank("a000")->set_base(machine().root_device().memregion("lslot")->base() + 0x8000); |
| 1010 | | machine().device("maincpu")->memory().space(AS_PROGRAM).unmap_write(0xa000, 0xbfff); |
| 1032 | m_maincpu->space(AS_PROGRAM).install_read_bank(0x8000, 0x8fff, "8000"); |
| 1033 | m_maincpu->space(AS_PROGRAM).install_read_bank(0x9000, 0x9fff, "9000"); |
| 1034 | membank("8000")->set_base(memregion("lslot")->base() + 0x0000); |
| 1035 | membank("9000")->set_base(memregion("lslot")->base() + 0x4000); |
| 1036 | membank("a000")->set_base(memregion("lslot")->base() + 0x8000); |
| 1037 | m_maincpu->space(AS_PROGRAM).unmap_write(0xa000, 0xbfff); |
| 1011 | 1038 | } |
| 1012 | 1039 | else if (m_a800_cart_type == OSS_034M) |
| 1013 | 1040 | { |
| 1014 | 1041 | // this requires separate banking in 0xa000 & 0xb000! |
| 1015 | | machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_bank(0xa000, 0xafff, "a000"); |
| 1016 | | machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_bank(0xb000, 0xbfff, "b000"); |
| 1017 | | machine().root_device().membank("b000")->set_base(machine().root_device().memregion("lslot")->base() + 0x3000); |
| 1018 | | machine().device("maincpu")->memory().space(AS_PROGRAM).unmap_write(0xa000, 0xbfff); |
| 1042 | m_maincpu->space(AS_PROGRAM).install_read_bank(0xa000, 0xafff, "a000"); |
| 1043 | m_maincpu->space(AS_PROGRAM).install_read_bank(0xb000, 0xbfff, "b000"); |
| 1044 | membank("b000")->set_base(memregion("lslot")->base() + 0x3000); |
| 1045 | m_maincpu->space(AS_PROGRAM).unmap_write(0xa000, 0xbfff); |
| 1019 | 1046 | } |
| 1020 | 1047 | else if (m_a800_cart_type == OSS_M091) |
| 1021 | 1048 | { |
| 1022 | 1049 | // this requires separate banking in 0xa000 & 0xb000! |
| 1023 | | machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_bank(0xa000, 0xafff, "a000"); |
| 1024 | | machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_bank(0xb000, 0xbfff, "b000"); |
| 1025 | | machine().root_device().membank("b000")->set_base(machine().root_device().memregion("lslot")->base()); |
| 1026 | | machine().device("maincpu")->memory().space(AS_PROGRAM).unmap_write(0xa000, 0xbfff); |
| 1050 | m_maincpu->space(AS_PROGRAM).install_read_bank(0xa000, 0xafff, "a000"); |
| 1051 | m_maincpu->space(AS_PROGRAM).install_read_bank(0xb000, 0xbfff, "b000"); |
| 1052 | membank("b000")->set_base(memregion("lslot")->base()); |
| 1053 | m_maincpu->space(AS_PROGRAM).unmap_write(0xa000, 0xbfff); |
| 1027 | 1054 | } |
| 1028 | 1055 | else if (m_a800_cart_type == XEGS_32K) |
| 1029 | 1056 | { |
| 1030 | | machine().root_device().membank("8000")->set_base(machine().root_device().memregion("lslot")->base()); |
| 1031 | | machine().root_device().membank("a000")->set_base(machine().root_device().memregion("lslot")->base() + 0x6000); |
| 1032 | | machine().device("maincpu")->memory().space(AS_PROGRAM).unmap_write(0x8000, 0xbfff); |
| 1057 | membank("8000")->set_base(memregion("lslot")->base()); |
| 1058 | membank("a000")->set_base(memregion("lslot")->base() + 0x6000); |
| 1059 | m_maincpu->space(AS_PROGRAM).unmap_write(0x8000, 0xbfff); |
| 1033 | 1060 | } |
| 1034 | 1061 | else |
| 1035 | 1062 | { |
| 1036 | | machine().root_device().membank("a000")->set_base(machine().root_device().memregion("lslot")->base()); |
| 1037 | | machine().device("maincpu")->memory().space(AS_PROGRAM).unmap_write(0xa000, 0xbfff); |
| 1063 | membank("a000")->set_base(memregion("lslot")->base()); |
| 1064 | m_maincpu->space(AS_PROGRAM).unmap_write(0xa000, 0xbfff); |
| 1038 | 1065 | } |
| 1039 | 1066 | } |
| 1040 | 1067 | } |
| r20782 | r20783 | |
| 1099 | 1126 | } |
| 1100 | 1127 | |
| 1101 | 1128 | |
| 1102 | | static WRITE8_HANDLER( x32_bank_w ) |
| 1129 | WRITE8_MEMBER( a400_state::x32_bank_w ) |
| 1103 | 1130 | { |
| 1104 | 1131 | // printf("written %x\n", data); |
| 1105 | 1132 | int bank = data & 0x03; |
| 1106 | | space.machine().root_device().membank("8000")->set_base(space.machine().root_device().memregion("lslot")->base() + bank * 0x2000); |
| 1133 | membank("8000")->set_base(memregion("lslot")->base() + bank * 0x2000); |
| 1107 | 1134 | } |
| 1108 | 1135 | |
| 1109 | 1136 | |
| 1110 | | static WRITE8_HANDLER( w64_bank_w ) |
| 1137 | WRITE8_MEMBER( a400_state::w64_bank_w ) |
| 1111 | 1138 | { |
| 1112 | 1139 | // printf("write to %x\n", offset); |
| 1113 | 1140 | |
| 1114 | 1141 | if (offset < 8) |
| 1115 | | space.machine().root_device().membank("a000")->set_base(space.machine().root_device().memregion("lslot")->base() + offset * 0x2000); |
| 1142 | membank("a000")->set_base(memregion("lslot")->base() + offset * 0x2000); |
| 1116 | 1143 | else |
| 1117 | | space.machine().root_device().membank("a000")->set_base(space.machine().root_device().memregion("maincpu")->base()); |
| 1144 | membank("a000")->set_base(memregion("maincpu")->base()); |
| 1118 | 1145 | // FIXME: writes to 0x8-0xf should disable the cart |
| 1119 | 1146 | } |
| 1120 | 1147 | |
| 1121 | 1148 | |
| 1122 | 1149 | // this covers Express 64, Diamond 64 and SpartaDOS (same bankswitch, but at different addresses) |
| 1123 | | static WRITE8_HANDLER( ex64_bank_w ) |
| 1150 | WRITE8_MEMBER( a400_state::ex64_bank_w ) |
| 1124 | 1151 | { |
| 1125 | 1152 | // printf("write to %x\n", offset); |
| 1126 | 1153 | |
| 1127 | 1154 | if (offset < 8) |
| 1128 | | space.machine().root_device().membank("a000")->set_base(space.machine().root_device().memregion("lslot")->base() + (7 - offset) * 0x2000); |
| 1155 | membank("a000")->set_base(memregion("lslot")->base() + (7 - offset) * 0x2000); |
| 1129 | 1156 | else |
| 1130 | | space.machine().root_device().membank("a000")->set_base(space.machine().root_device().memregion("maincpu")->base()); |
| 1157 | membank("a000")->set_base(memregion("maincpu")->base()); |
| 1131 | 1158 | // FIXME: writes to 0x8-0xf should disable the cart |
| 1132 | 1159 | } |
| 1133 | 1160 | |
| 1134 | 1161 | |
| 1135 | | static WRITE8_HANDLER( bbsb_bankl_w ) |
| 1162 | WRITE8_MEMBER( a400_state::bbsb_bankl_w ) |
| 1136 | 1163 | { |
| 1137 | 1164 | // printf("write to %x\n", 0x8000 + offset); |
| 1138 | 1165 | if (offset >= 0xff6 && offset <= 0xff9) |
| 1139 | | space.machine().root_device().membank("8000")->set_base(space.machine().root_device().memregion("lslot")->base() + 0x0000 + (offset - 0xff6) * 0x1000); |
| 1166 | membank("8000")->set_base(memregion("lslot")->base() + 0x0000 + (offset - 0xff6) * 0x1000); |
| 1140 | 1167 | } |
| 1141 | 1168 | |
| 1142 | 1169 | |
| 1143 | | static WRITE8_HANDLER( bbsb_bankh_w ) |
| 1170 | WRITE8_MEMBER( a400_state::bbsb_bankh_w ) |
| 1144 | 1171 | { |
| 1145 | 1172 | // printf("write to %x\n", 0x9000 + offset); |
| 1146 | 1173 | if (offset >= 0xff6 && offset <= 0xff9) |
| 1147 | | space.machine().root_device().membank("9000")->set_base(space.machine().root_device().memregion("lslot")->base() + 0x4000 + (offset - 0xff6) * 0x1000); |
| 1174 | membank("9000")->set_base(memregion("lslot")->base() + 0x4000 + (offset - 0xff6) * 0x1000); |
| 1148 | 1175 | } |
| 1149 | 1176 | |
| 1150 | 1177 | |
| 1151 | | static WRITE8_HANDLER( oss_034m_w ) |
| 1178 | WRITE8_MEMBER( a400_state::oss_034m_w ) |
| 1152 | 1179 | { |
| 1153 | 1180 | switch (offset & 0x0f) |
| 1154 | 1181 | { |
| 1155 | 1182 | case 0: |
| 1156 | 1183 | case 1: |
| 1157 | | space.machine().root_device().membank("a000")->set_base(space.machine().root_device().memregion("lslot")->base()); |
| 1158 | | space.machine().root_device().membank("b000")->set_base(space.machine().root_device().memregion("lslot")->base() + 0x3000); |
| 1184 | membank("a000")->set_base(memregion("lslot")->base()); |
| 1185 | membank("b000")->set_base(memregion("lslot")->base() + 0x3000); |
| 1159 | 1186 | break; |
| 1160 | 1187 | case 2: |
| 1161 | 1188 | case 6: |
| 1162 | 1189 | // docs says this should put 0xff in the 0xa000 bank -> let's point to the end of the cart |
| 1163 | | space.machine().root_device().membank("a000")->set_base(space.machine().root_device().memregion("lslot")->base() + 0x4000); |
| 1164 | | space.machine().root_device().membank("b000")->set_base(space.machine().root_device().memregion("lslot")->base() + 0x3000); |
| 1190 | membank("a000")->set_base(memregion("lslot")->base() + 0x4000); |
| 1191 | membank("b000")->set_base(memregion("lslot")->base() + 0x3000); |
| 1165 | 1192 | break; |
| 1166 | 1193 | case 3: |
| 1167 | 1194 | case 7: |
| 1168 | | space.machine().root_device().membank("a000")->set_base(space.machine().root_device().memregion("lslot")->base() + 0x1000); |
| 1169 | | space.machine().root_device().membank("b000")->set_base(space.machine().root_device().memregion("lslot")->base() + 0x3000); |
| 1195 | membank("a000")->set_base(memregion("lslot")->base() + 0x1000); |
| 1196 | membank("b000")->set_base(memregion("lslot")->base() + 0x3000); |
| 1170 | 1197 | break; |
| 1171 | 1198 | case 4: |
| 1172 | 1199 | case 5: |
| 1173 | | space.machine().root_device().membank("a000")->set_base(space.machine().root_device().memregion("lslot")->base() + 0x2000); |
| 1174 | | space.machine().root_device().membank("b000")->set_base(space.machine().root_device().memregion("lslot")->base() + 0x3000); |
| 1200 | membank("a000")->set_base(memregion("lslot")->base() + 0x2000); |
| 1201 | membank("b000")->set_base(memregion("lslot")->base() + 0x3000); |
| 1175 | 1202 | break; |
| 1176 | 1203 | default: |
| 1177 | | space.machine().root_device().membank("a000")->set_base(space.machine().root_device().memregion("maincpu")->base() + 0xa000); |
| 1178 | | space.machine().root_device().membank("b000")->set_base(space.machine().root_device().memregion("maincpu")->base() + 0xb000); |
| 1204 | membank("a000")->set_base(memregion("maincpu")->base() + 0xa000); |
| 1205 | membank("b000")->set_base(memregion("maincpu")->base() + 0xb000); |
| 1179 | 1206 | break; |
| 1180 | 1207 | } |
| 1181 | 1208 | } |
| 1182 | 1209 | |
| 1183 | 1210 | |
| 1184 | | static WRITE8_HANDLER( oss_m091_w ) |
| 1211 | WRITE8_MEMBER( a400_state::oss_m091_w ) |
| 1185 | 1212 | { |
| 1186 | 1213 | switch (offset & 0x09) |
| 1187 | 1214 | { |
| 1188 | 1215 | case 0: |
| 1189 | | space.machine().root_device().membank("a000")->set_base(space.machine().root_device().memregion("lslot")->base() + 0x1000); |
| 1190 | | space.machine().root_device().membank("b000")->set_base(space.machine().root_device().memregion("lslot")->base()); |
| 1216 | membank("a000")->set_base(memregion("lslot")->base() + 0x1000); |
| 1217 | membank("b000")->set_base(memregion("lslot")->base()); |
| 1191 | 1218 | break; |
| 1192 | 1219 | case 1: |
| 1193 | | space.machine().root_device().membank("a000")->set_base(space.machine().root_device().memregion("lslot")->base() + 0x3000); |
| 1194 | | space.machine().root_device().membank("b000")->set_base(space.machine().root_device().memregion("lslot")->base()); |
| 1220 | membank("a000")->set_base(memregion("lslot")->base() + 0x3000); |
| 1221 | membank("b000")->set_base(memregion("lslot")->base()); |
| 1195 | 1222 | break; |
| 1196 | 1223 | case 8: |
| 1197 | | space.machine().root_device().membank("a000")->set_base(space.machine().root_device().memregion("maincpu")->base() + 0xa000); |
| 1198 | | space.machine().root_device().membank("b000")->set_base(space.machine().root_device().memregion("maincpu")->base() + 0xb000); |
| 1224 | membank("a000")->set_base(memregion("maincpu")->base() + 0xa000); |
| 1225 | membank("b000")->set_base(memregion("maincpu")->base() + 0xb000); |
| 1199 | 1226 | break; |
| 1200 | 1227 | case 9: |
| 1201 | | space.machine().root_device().membank("a000")->set_base(space.machine().root_device().memregion("lslot")->base() + 0x2000); |
| 1202 | | space.machine().root_device().membank("b000")->set_base(space.machine().root_device().memregion("lslot")->base()); |
| 1228 | membank("a000")->set_base(memregion("lslot")->base() + 0x2000); |
| 1229 | membank("b000")->set_base(memregion("lslot")->base()); |
| 1203 | 1230 | break; |
| 1204 | 1231 | } |
| 1205 | 1232 | } |
| 1206 | 1233 | |
| 1207 | 1234 | |
| 1208 | | static UINT8 xegs_banks = 0; |
| 1209 | | static UINT8 xegs_cart = 0; |
| 1210 | | |
| 1211 | | static WRITE8_HANDLER( xegs_bankswitch ) |
| 1235 | WRITE8_MEMBER( a400_state::xegs_bankswitch ) |
| 1212 | 1236 | { |
| 1213 | | UINT8 *cart = space.machine().root_device().memregion("user1")->base(); |
| 1214 | | data &= xegs_banks - 1; |
| 1215 | | space.machine().root_device().membank("bank0")->set_base(cart + data * 0x2000); |
| 1237 | UINT8 *cart = memregion("user1")->base(); |
| 1238 | data &= m_xegs_banks - 1; |
| 1239 | membank("bank0")->set_base(cart + data * 0x2000); |
| 1216 | 1240 | } |
| 1217 | 1241 | |
| 1218 | | MACHINE_START( xegs ) |
| 1242 | MACHINE_START_MEMBER( a400_state, xegs ) |
| 1219 | 1243 | { |
| 1220 | | address_space &space = machine.device("maincpu")->memory().space(AS_PROGRAM); |
| 1221 | | UINT8 *cart = space.machine().root_device().memregion("user1")->base(); |
| 1222 | | UINT8 *cpu = space.machine().root_device().memregion("maincpu")->base(); |
| 1244 | address_space &space = m_maincpu->space(AS_PROGRAM); |
| 1245 | UINT8 *cart = memregion("user1")->base(); |
| 1246 | UINT8 *cpu = memregion("maincpu")->base(); |
| 1223 | 1247 | |
| 1224 | | atari_machine_start(machine); |
| 1225 | | space.install_legacy_write_handler(0xd500, 0xd5ff, FUNC(xegs_bankswitch)); |
| 1248 | atari_machine_start(machine()); |
| 1249 | space.install_write_handler(0xd500, 0xd5ff, write8_delegate(FUNC(a400_state::xegs_bankswitch),this)); |
| 1226 | 1250 | |
| 1227 | | if (xegs_cart) |
| 1251 | if (m_xegs_cart) |
| 1228 | 1252 | { |
| 1229 | | machine.root_device().membank("bank0")->set_base(cart); |
| 1230 | | machine.root_device().membank("bank1")->set_base(cart + (xegs_banks - 1) * 0x2000); |
| 1253 | membank("bank0")->set_base(cart); |
| 1254 | membank("bank1")->set_base(cart + (m_xegs_banks - 1) * 0x2000); |
| 1231 | 1255 | } |
| 1232 | 1256 | else |
| 1233 | 1257 | { |
| 1234 | 1258 | // point to built-in Missile Command (this does not work well, though... FIXME!!) |
| 1235 | | machine.root_device().membank("bank0")->set_base(cpu + 0x10000); |
| 1236 | | machine.root_device().membank("bank1")->set_base(cpu + 0x10000); |
| 1259 | membank("bank0")->set_base(cpu + 0x10000); |
| 1260 | membank("bank1")->set_base(cpu + 0x10000); |
| 1237 | 1261 | } |
| 1238 | 1262 | } |
| 1239 | 1263 | |
| 1240 | 1264 | |
| 1241 | 1265 | // currently this does nothing, but it will eventually install the memory handlers required by the mappers |
| 1242 | | static void a800_setup_mappers(running_machine &machine, int type) |
| 1266 | void a400_state::a800_setup_mappers(int type) |
| 1243 | 1267 | { |
| 1244 | 1268 | switch (type) |
| 1245 | 1269 | { |
| r20782 | r20783 | |
| 1252 | 1276 | case PHOENIX_8K: // as normal 8k cart, but it can be disabled by writing to 0xd500-0xdfff |
| 1253 | 1277 | break; |
| 1254 | 1278 | case XEGS_32K: |
| 1255 | | machine.device("maincpu")->memory().space(AS_PROGRAM).install_legacy_write_handler(0xd500, 0xd5ff, FUNC(x32_bank_w)); |
| 1279 | m_maincpu->space(AS_PROGRAM).install_write_handler(0xd500, 0xd5ff, write8_delegate(FUNC(a400_state::x32_bank_w),this)); |
| 1256 | 1280 | break; |
| 1257 | 1281 | case OSS_034M: |
| 1258 | | machine.device("maincpu")->memory().space(AS_PROGRAM).install_legacy_write_handler(0xd500, 0xd5ff, FUNC(oss_034m_w)); |
| 1282 | m_maincpu->space(AS_PROGRAM).install_write_handler(0xd500, 0xd5ff, write8_delegate(FUNC(a400_state::oss_034m_w),this)); |
| 1259 | 1283 | break; |
| 1260 | 1284 | case OSS_M091: |
| 1261 | | machine.device("maincpu")->memory().space(AS_PROGRAM).install_legacy_write_handler(0xd500, 0xd5ff, FUNC(oss_m091_w)); |
| 1285 | m_maincpu->space(AS_PROGRAM).install_write_handler(0xd500, 0xd5ff, write8_delegate(FUNC(a400_state::oss_m091_w),this)); |
| 1262 | 1286 | break; |
| 1263 | 1287 | case BBSB: |
| 1264 | | machine.device("maincpu")->memory().space(AS_PROGRAM).install_legacy_write_handler(0x8000, 0x8fff, FUNC(bbsb_bankl_w)); |
| 1265 | | machine.device("maincpu")->memory().space(AS_PROGRAM).install_legacy_write_handler(0x9000, 0x9fff, FUNC(bbsb_bankh_w)); |
| 1288 | m_maincpu->space(AS_PROGRAM).install_write_handler(0x8000, 0x8fff, write8_delegate(FUNC(a400_state::bbsb_bankl_w),this)); |
| 1289 | m_maincpu->space(AS_PROGRAM).install_write_handler(0x9000, 0x9fff, write8_delegate(FUNC(a400_state::bbsb_bankh_w),this)); |
| 1266 | 1290 | break; |
| 1267 | 1291 | case WILLIAMS_64K: |
| 1268 | | machine.device("maincpu")->memory().space(AS_PROGRAM).install_legacy_write_handler(0xd500, 0xd50f, FUNC(w64_bank_w)); |
| 1292 | m_maincpu->space(AS_PROGRAM).install_write_handler(0xd500, 0xd50f, write8_delegate(FUNC(a400_state::w64_bank_w),this)); |
| 1269 | 1293 | break; |
| 1270 | 1294 | case DIAMOND_64K: |
| 1271 | | machine.device("maincpu")->memory().space(AS_PROGRAM).install_legacy_write_handler(0xd5d0, 0xd5df, FUNC(ex64_bank_w)); |
| 1295 | m_maincpu->space(AS_PROGRAM).install_write_handler(0xd5d0, 0xd5df, write8_delegate(FUNC(a400_state::ex64_bank_w),this)); |
| 1272 | 1296 | break; |
| 1273 | 1297 | case EXPRESS_64: |
| 1274 | | machine.device("maincpu")->memory().space(AS_PROGRAM).install_legacy_write_handler(0xd570, 0xd57f, FUNC(ex64_bank_w)); |
| 1298 | m_maincpu->space(AS_PROGRAM).install_write_handler(0xd570, 0xd57f, write8_delegate(FUNC(a400_state::ex64_bank_w),this)); |
| 1275 | 1299 | break; |
| 1276 | 1300 | case SPARTADOS_X: |
| 1277 | | machine.device("maincpu")->memory().space(AS_PROGRAM).install_legacy_write_handler(0xd5e0, 0xd5ef, FUNC(ex64_bank_w)); |
| 1301 | m_maincpu->space(AS_PROGRAM).install_write_handler(0xd5e0, 0xd5ef, write8_delegate(FUNC(a400_state::ex64_bank_w),this)); |
| 1278 | 1302 | break; |
| 1279 | 1303 | default: |
| 1280 | 1304 | break; |
| r20782 | r20783 | |
| 1406 | 1430 | m_a800_cart_loaded = m_a800_cart_loaded & ~LEFT_CARTSLOT_MOUNTED; |
| 1407 | 1431 | m_a800_cart_type = a800_check_cart_type(image); |
| 1408 | 1432 | |
| 1409 | | a800_setup_mappers(image.device().machine(), m_a800_cart_type); |
| 1433 | a800_setup_mappers(m_a800_cart_type); |
| 1410 | 1434 | |
| 1411 | 1435 | if (image.software_entry() == NULL) |
| 1412 | 1436 | { |
| r20782 | r20783 | |
| 1417 | 1441 | size -= 0x10; |
| 1418 | 1442 | start = 0x10; |
| 1419 | 1443 | } |
| 1420 | | image.fread(image.device().machine().root_device().memregion("lslot")->base(), size - start); |
| 1444 | image.fread(memregion("lslot")->base(), size - start); |
| 1421 | 1445 | } |
| 1422 | 1446 | else |
| 1423 | 1447 | { |
| 1424 | 1448 | size = image.get_software_region_length("rom"); |
| 1425 | | memcpy(image.device().machine().root_device().memregion("lslot")->base(), image.get_software_region("rom"), size); |
| 1449 | memcpy(memregion("lslot")->base(), image.get_software_region("rom"), size); |
| 1426 | 1450 | } |
| 1427 | 1451 | |
| 1428 | 1452 | m_a800_cart_loaded |= (size > 0x0000) ? 1 : 0; |
| r20782 | r20783 | |
| 1439 | 1463 | m_a800_cart_loaded = m_a800_cart_loaded & ~RIGHT_CARTSLOT_MOUNTED; |
| 1440 | 1464 | m_a800_cart_type = a800_check_cart_type(image); |
| 1441 | 1465 | |
| 1442 | | a800_setup_mappers(image.device().machine(), m_a800_cart_type); |
| 1466 | a800_setup_mappers(m_a800_cart_type); |
| 1443 | 1467 | |
| 1444 | 1468 | if (image.software_entry() == NULL) |
| 1445 | 1469 | { |
| r20782 | r20783 | |
| 1450 | 1474 | size -= 0x10; |
| 1451 | 1475 | start = 0x10; |
| 1452 | 1476 | } |
| 1453 | | image.fread(image.device().machine().root_device().memregion("rslot")->base(), size - start); |
| 1477 | image.fread(memregion("rslot")->base(), size - start); |
| 1454 | 1478 | } |
| 1455 | 1479 | else |
| 1456 | 1480 | { |
| 1457 | 1481 | size = image.get_software_region_length("rom"); |
| 1458 | | memcpy(image.device().machine().root_device().memregion("rslot")->base(), image.get_software_region("rom"), size); |
| 1482 | memcpy(memregion("rslot")->base(), image.get_software_region("rom"), size); |
| 1459 | 1483 | } |
| 1460 | 1484 | |
| 1461 | 1485 | m_a800_cart_loaded |= (size > 0x0000) ? 2 : 0; |
| 1462 | 1486 | |
| 1463 | | logerror("%s loaded right cartridge '%s' size 8K\n", image.device().machine().system().name, image.filename()); |
| 1487 | logerror("%s loaded right cartridge '%s' size 8K\n", machine().system().name, image.filename()); |
| 1464 | 1488 | return IMAGE_INIT_PASS; |
| 1465 | 1489 | } |
| 1466 | 1490 | |
| r20782 | r20783 | |
| 1483 | 1507 | |
| 1484 | 1508 | DEVICE_IMAGE_LOAD_MEMBER( a400_state, a5200_cart ) |
| 1485 | 1509 | { |
| 1486 | | UINT8 *mem = image.device().machine().root_device().memregion("maincpu")->base(); |
| 1510 | UINT8 *mem = memregion("maincpu")->base(); |
| 1487 | 1511 | UINT32 size; |
| 1488 | 1512 | bool A13_mirr = FALSE; |
| 1489 | 1513 | |
| r20782 | r20783 | |
| 1524 | 1548 | |
| 1525 | 1549 | DEVICE_IMAGE_UNLOAD_MEMBER( a400_state, a5200_cart ) |
| 1526 | 1550 | { |
| 1527 | | UINT8 *mem = image.device().machine().root_device().memregion("maincpu")->base(); |
| 1551 | UINT8 *mem = memregion("maincpu")->base(); |
| 1528 | 1552 | /* zap the cartridge memory (again) */ |
| 1529 | 1553 | memset(&mem[0x4000], 0x00, 0x8000); |
| 1530 | 1554 | } |
| r20782 | r20783 | |
| 1533 | 1557 | DEVICE_IMAGE_LOAD_MEMBER( a400_state, xegs_cart ) |
| 1534 | 1558 | { |
| 1535 | 1559 | UINT32 size; |
| 1536 | | UINT8 *ptr = image.device().machine().root_device().memregion("user1")->base(); |
| 1560 | UINT8 *ptr = memregion("user1")->base(); |
| 1537 | 1561 | |
| 1538 | 1562 | if (image.software_entry() == NULL) |
| 1539 | 1563 | { |
| r20782 | r20783 | |
| 1549 | 1573 | memcpy(ptr, image.get_software_region("rom"), size); |
| 1550 | 1574 | } |
| 1551 | 1575 | |
| 1552 | | xegs_banks = size / 0x2000; |
| 1553 | | xegs_cart = 1; |
| 1576 | m_xegs_banks = size / 0x2000; |
| 1577 | m_xegs_cart = 1; |
| 1554 | 1578 | |
| 1555 | 1579 | return IMAGE_INIT_PASS; |
| 1556 | 1580 | } |
| r20782 | r20783 | |
| 1558 | 1582 | |
| 1559 | 1583 | DEVICE_IMAGE_UNLOAD_MEMBER( a400_state, xegs_cart ) |
| 1560 | 1584 | { |
| 1561 | | xegs_cart = 0; |
| 1562 | | xegs_banks = 0; |
| 1585 | m_xegs_cart = 0; |
| 1586 | m_xegs_banks = 0; |
| 1563 | 1587 | } |
| 1564 | 1588 | |
| 1565 | 1589 | |
| 1566 | | MACHINE_START( a400 ) |
| 1590 | MACHINE_START_MEMBER( a400_state, a400 ) |
| 1567 | 1591 | { |
| 1568 | | a400_state *state = machine.driver_data<a400_state>(); |
| 1569 | | atari_machine_start(machine); |
| 1570 | | state->ms_atari_machine_start(ATARI_400, TRUE); |
| 1592 | atari_machine_start(machine()); |
| 1593 | ms_atari_machine_start(ATARI_400, TRUE); |
| 1571 | 1594 | } |
| 1572 | 1595 | |
| 1573 | 1596 | |
| 1574 | | MACHINE_START( a800 ) |
| 1597 | MACHINE_START_MEMBER( a400_state, a800 ) |
| 1575 | 1598 | { |
| 1576 | | a400_state *state = machine.driver_data<a400_state>(); |
| 1577 | | atari_machine_start(machine); |
| 1578 | | state->ms_atari_machine_start(ATARI_800, TRUE); |
| 1599 | atari_machine_start(machine()); |
| 1600 | ms_atari_machine_start(ATARI_800, TRUE); |
| 1579 | 1601 | } |
| 1580 | 1602 | |
| 1581 | 1603 | |
| 1582 | | MACHINE_START( a800xl ) |
| 1604 | MACHINE_START_MEMBER( a400_state, a800xl ) |
| 1583 | 1605 | { |
| 1584 | | a400_state *state = machine.driver_data<a400_state>(); |
| 1585 | | atari_machine_start(machine); |
| 1586 | | state->ms_atari800xl_machine_start(ATARI_800XL, TRUE); |
| 1606 | atari_machine_start(machine()); |
| 1607 | ms_atari800xl_machine_start(ATARI_800XL, TRUE); |
| 1587 | 1608 | } |
| 1588 | 1609 | |
| 1589 | 1610 | |
| 1590 | | MACHINE_START( a5200 ) |
| 1611 | MACHINE_START_MEMBER( a400_state, a5200 ) |
| 1591 | 1612 | { |
| 1592 | | a400_state *state = machine.driver_data<a400_state>(); |
| 1593 | | atari_machine_start(machine); |
| 1594 | | state->ms_atari_machine_start(ATARI_800XL, TRUE); |
| 1613 | atari_machine_start(machine()); |
| 1614 | ms_atari_machine_start(ATARI_800XL, TRUE); |
| 1595 | 1615 | } |
| 1596 | 1616 | |
| 1597 | 1617 | |
| r20782 | r20783 | |
| 1602 | 1622 | * |
| 1603 | 1623 | **************************************************************/ |
| 1604 | 1624 | |
| 1605 | | WRITE8_MEMBER(a400_state::a1200xl_pia_pb_w){ device_t *device = machine().device("pia"); a1200xl_mmu(device->machine(), data); } |
| 1625 | WRITE8_MEMBER(a400_state::a1200xl_pia_pb_w){ a1200xl_mmu(data); } |
| 1606 | 1626 | WRITE8_MEMBER(a400_state::a800xl_pia_pb_w) |
| 1607 | 1627 | { |
| 1608 | | device_t *device = machine().device("pia"); |
| 1609 | | if (downcast<pia6821_device *>(device)->port_b_z_mask() != 0xff) |
| 1610 | | a800xl_mmu(machine(), data); |
| 1628 | if (m_pia->port_b_z_mask() != 0xff) |
| 1629 | a800xl_mmu(data); |
| 1611 | 1630 | } |
| 1612 | 1631 | |
| 1613 | 1632 | WRITE8_MEMBER(a400_state::xegs_pia_pb_w) |
| 1614 | 1633 | { |
| 1615 | | device_t *device = machine().device("pia"); |
| 1616 | | if (downcast<pia6821_device *>(device)->port_b_z_mask() != 0xff) |
| 1617 | | xegs_mmu(machine(), data); |
| 1634 | if (m_pia->port_b_z_mask() != 0xff) |
| 1635 | xegs_mmu(data); |
| 1618 | 1636 | } |
| 1619 | 1637 | |
| 1620 | 1638 | static const pokey_interface atari_pokey_interface = |
| r20782 | r20783 | |
| 1825 | 1843 | MCFG_CPU_PROGRAM_MAP(a400_mem) |
| 1826 | 1844 | MCFG_TIMER_ADD_SCANLINE("scantimer", a400_interrupt, "screen", 0, 1) |
| 1827 | 1845 | |
| 1828 | | MCFG_MACHINE_START( a400 ) |
| 1846 | MCFG_MACHINE_START_OVERRIDE( a400_state, a400 ) |
| 1829 | 1847 | |
| 1830 | 1848 | MCFG_SCREEN_MODIFY("screen") |
| 1831 | 1849 | MCFG_SCREEN_REFRESH_RATE(FRAME_RATE_60HZ) |
| r20782 | r20783 | |
| 1844 | 1862 | MCFG_CPU_PROGRAM_MAP(a400_mem) |
| 1845 | 1863 | MCFG_TIMER_ADD_SCANLINE("scantimer", a400_interrupt, "screen", 0, 1) |
| 1846 | 1864 | |
| 1847 | | MCFG_MACHINE_START( a400 ) |
| 1865 | MCFG_MACHINE_START_OVERRIDE( a400_state, a400 ) |
| 1848 | 1866 | |
| 1849 | 1867 | MCFG_SCREEN_MODIFY("screen") |
| 1850 | 1868 | MCFG_SCREEN_REFRESH_RATE(FRAME_RATE_50HZ) |
| r20782 | r20783 | |
| 1863 | 1881 | MCFG_CPU_PROGRAM_MAP(a800_mem) |
| 1864 | 1882 | MCFG_TIMER_ADD_SCANLINE("scantimer", a800_interrupt, "screen", 0, 1) |
| 1865 | 1883 | |
| 1866 | | MCFG_MACHINE_START( a800 ) |
| 1884 | MCFG_MACHINE_START_OVERRIDE( a400_state, a800 ) |
| 1867 | 1885 | |
| 1868 | 1886 | MCFG_SCREEN_MODIFY("screen") |
| 1869 | 1887 | MCFG_SCREEN_REFRESH_RATE(FRAME_RATE_60HZ) |
| r20782 | r20783 | |
| 1882 | 1900 | MCFG_CPU_PROGRAM_MAP(a800_mem) |
| 1883 | 1901 | MCFG_TIMER_ADD_SCANLINE("scantimer", a800_interrupt, "screen", 0, 1) |
| 1884 | 1902 | |
| 1885 | | MCFG_MACHINE_START( a800 ) |
| 1903 | MCFG_MACHINE_START_OVERRIDE( a400_state, a800 ) |
| 1886 | 1904 | |
| 1887 | 1905 | MCFG_SCREEN_MODIFY("screen") |
| 1888 | 1906 | MCFG_SCREEN_REFRESH_RATE(FRAME_RATE_50HZ) |
| r20782 | r20783 | |
| 1903 | 1921 | |
| 1904 | 1922 | MCFG_PIA6821_MODIFY( "pia", a600xl_pia_interface ) |
| 1905 | 1923 | |
| 1906 | | MCFG_MACHINE_START( a800xl ) // FIXME? |
| 1924 | MCFG_MACHINE_START_OVERRIDE( a400_state, a800xl ) // FIXME? |
| 1907 | 1925 | |
| 1908 | 1926 | MCFG_SCREEN_MODIFY("screen") |
| 1909 | 1927 | MCFG_SCREEN_REFRESH_RATE(FRAME_RATE_60HZ) |
| r20782 | r20783 | |
| 1928 | 1946 | |
| 1929 | 1947 | MCFG_PIA6821_MODIFY( "pia", a800xl_pia_interface ) |
| 1930 | 1948 | |
| 1931 | | MCFG_MACHINE_START( a800xl ) |
| 1949 | MCFG_MACHINE_START_OVERRIDE( a400_state, a800xl ) |
| 1932 | 1950 | |
| 1933 | 1951 | MCFG_SCREEN_MODIFY("screen") |
| 1934 | 1952 | MCFG_SCREEN_REFRESH_RATE(FRAME_RATE_60HZ) |
| r20782 | r20783 | |
| 1963 | 1981 | MCFG_CPU_MODIFY( "maincpu" ) |
| 1964 | 1982 | MCFG_CPU_PROGRAM_MAP(xegs_mem) |
| 1965 | 1983 | |
| 1966 | | MCFG_MACHINE_START( xegs ) |
| 1984 | MCFG_MACHINE_START_OVERRIDE( a400_state, xegs ) |
| 1967 | 1985 | |
| 1968 | 1986 | MCFG_PIA6821_MODIFY( "pia", xegs_pia_interface ) |
| 1969 | 1987 | |
| r20782 | r20783 | |
| 1998 | 2016 | |
| 1999 | 2017 | MCFG_PIA6821_MODIFY( "pia", a5200_pia_interface ) |
| 2000 | 2018 | |
| 2001 | | MCFG_MACHINE_START( a5200 ) |
| 2019 | MCFG_MACHINE_START_OVERRIDE( a400_state, a5200 ) |
| 2002 | 2020 | |
| 2003 | 2021 | MCFG_SCREEN_MODIFY( "screen" ) |
| 2004 | 2022 | MCFG_SCREEN_REFRESH_RATE(FRAME_RATE_60HZ) |
| r20782 | r20783 | |
| 2162 | 2180 | |
| 2163 | 2181 | DRIVER_INIT_MEMBER(a400_state,a800xl) |
| 2164 | 2182 | { |
| 2165 | | a800xl_mmu(machine(), 0xff); |
| 2183 | a800xl_mmu(0xff); |
| 2166 | 2184 | } |
| 2167 | 2185 | |
| 2168 | 2186 | DRIVER_INIT_MEMBER(a400_state,xegs) |
| 2169 | 2187 | { |
| 2170 | | xegs_mmu(machine(), 0xff); |
| 2188 | xegs_mmu(0xff); |
| 2171 | 2189 | } |
| 2172 | 2190 | |
| 2173 | 2191 | DRIVER_INIT_MEMBER(a400_state,a600xl) |
| 2174 | 2192 | { |
| 2175 | | UINT8 *rom = machine().root_device().memregion("maincpu")->base(); |
| 2193 | UINT8 *rom = memregion("maincpu")->base(); |
| 2176 | 2194 | memcpy( rom + 0x5000, rom + 0xd000, 0x800 ); |
| 2177 | 2195 | } |
| 2178 | 2196 | |