trunk/src/mame/machine/snes.c
| r21584 | r21585 | |
| 403 | 403 | return spc_port_out(state->m_spc700, space, offset & 0x3); |
| 404 | 404 | } |
| 405 | 405 | |
| 406 | | if (state->m_has_addon_chip == HAS_SUPERFX && state->m_superfx != NULL) |
| 407 | | { |
| 408 | | if (offset >= 0x3000 && offset < 0x3300) |
| 409 | | { |
| 410 | | return superfx_mmio_read(state->m_superfx, offset); |
| 411 | | } |
| 412 | | } |
| 413 | | |
| 406 | // DMA accesses are from 4300 to 437f |
| 414 | 407 | if (offset >= DMAP0 && offset < 0x4380) |
| 415 | 408 | { |
| 416 | 409 | return snes_io_dma_r(space, offset); |
| r21584 | r21585 | |
| 513 | 506 | return; |
| 514 | 507 | } |
| 515 | 508 | |
| 516 | | if (state->m_has_addon_chip == HAS_SUPERFX && state->m_superfx != NULL) |
| 517 | | { |
| 518 | | if (offset >= 0x3000 && offset < 0x3300) |
| 519 | | { |
| 520 | | superfx_mmio_write(state->m_superfx, offset, data); |
| 521 | | return; |
| 522 | | } |
| 523 | | } |
| 524 | | |
| 509 | // DMA accesses are from 4300 to 437f |
| 525 | 510 | if (offset >= DMAP0 && offset < 0x4380) |
| 526 | 511 | { |
| 527 | 512 | snes_io_dma_w(space, offset, data); |
| r21584 | r21585 | |
| 731 | 716 | } |
| 732 | 717 | else if (address < 0x8000) |
| 733 | 718 | { |
| 734 | | if (state->m_has_addon_chip == HAS_SUPERFX && state->m_superfx != NULL) |
| 735 | | { |
| 736 | | if (superfx_access_ram(state->m_superfx)) |
| 737 | | value = snes_ram[0xf00000 + (offset & 0x1fff)]; // here it should be 0xe00000 but there are mirroring issues |
| 738 | | else |
| 739 | | value = snes_open_bus_r(space, 0); |
| 740 | | } |
| 741 | | else |
| 742 | | { |
| 743 | | logerror("(PC=%06x) snes_r_bank1: Unmapped external chip read: %04x\n",space.device().safe_pc(),address); |
| 744 | | value = snes_open_bus_r(space, 0); /* Reserved */ |
| 745 | | } |
| 719 | logerror("(PC=%06x) snes_r_bank1: Unmapped external chip read: %04x\n",space.device().safe_pc(),address); |
| 720 | value = snes_open_bus_r(space, 0); /* Reserved */ |
| 746 | 721 | } |
| 747 | 722 | else |
| 748 | 723 | value = snes_ram[offset]; |
| r21584 | r21585 | |
| 768 | 743 | } |
| 769 | 744 | else if (address < 0x8000) /* SRAM for mode_21, Reserved othewise */ |
| 770 | 745 | { |
| 771 | | if (state->m_has_addon_chip == HAS_SUPERFX && state->m_superfx != NULL) |
| 746 | if (state->m_cart[0].mode == SNES_MODE_21 && state->m_cart[0].sram > 0) |
| 772 | 747 | { |
| 773 | | if (superfx_access_ram(state->m_superfx)) |
| 774 | | value = snes_ram[0xf00000 + (offset & 0x1fff)]; // here it should be 0xe00000 but there are mirroring issues |
| 775 | | else |
| 776 | | value = snes_open_bus_r(space, 0); |
| 777 | | } |
| 778 | | else if ((state->m_cart[0].mode == SNES_MODE_21) && (state->m_cart[0].sram > 0)) |
| 779 | | { |
| 780 | 748 | /* Donkey Kong Country checks this and detects a copier if 0x800 is not masked out due to sram size */ |
| 781 | 749 | /* OTOH Secret of Mana does not work properly if sram is not mirrored on later banks */ |
| 782 | 750 | int mask = (state->m_cart[0].sram - 1) & 0x7fff; /* Limit SRAM size to what's actually present */ |
| r21584 | r21585 | |
| 801 | 769 | UINT8 value = 0xff; |
| 802 | 770 | UINT16 address = offset & 0xffff; |
| 803 | 771 | |
| 804 | | if (state->m_has_addon_chip == HAS_SUPERFX && state->m_superfx != NULL) |
| 772 | if (state->m_cart[0].mode & 5) /* Mode 20 & 22 */ |
| 805 | 773 | { |
| 806 | | if (superfx_access_rom(state->m_superfx)) |
| 807 | | value = snes_ram[0x400000 + offset]; |
| 808 | | else |
| 809 | | { |
| 810 | | static const UINT8 sfx_data[16] = { |
| 811 | | 0x00, 0x01, 0x00, 0x01, 0x04, 0x01, 0x00, 0x01, |
| 812 | | 0x00, 0x01, 0x08, 0x01, 0x00, 0x01, 0x0c, 0x01, |
| 813 | | }; |
| 814 | | return sfx_data[offset & 0x0f]; |
| 815 | | } |
| 816 | | } |
| 817 | | else if ((state->m_cart[0].mode & 5) && !(state->m_has_addon_chip == HAS_SUPERFX)) /* Mode 20 & 22 */ |
| 818 | | { |
| 819 | 774 | if ((address < 0x8000) && (state->m_cart[0].mode == SNES_MODE_20)) |
| 820 | 775 | value = snes_open_bus_r(space, 0); /* Reserved */ |
| 821 | 776 | else |
| 822 | 777 | value = snes_ram[0x400000 + offset]; |
| 823 | 778 | } |
| 824 | | else /* Mode 21 & 25 + SuperFX games */ |
| 779 | else /* Mode 21 & 25 */ |
| 825 | 780 | value = snes_ram[0x400000 + offset]; |
| 826 | 781 | |
| 827 | 782 | return value; |
| r21584 | r21585 | |
| 834 | 789 | UINT8 value = 0xff; |
| 835 | 790 | UINT16 address = offset & 0xffff; |
| 836 | 791 | |
| 837 | | if (state->m_has_addon_chip == HAS_SUPERFX && state->m_superfx != NULL) |
| 792 | if (state->m_cart[0].mode & 5) /* Mode 20 & 22 */ |
| 838 | 793 | { |
| 839 | | if (superfx_access_ram(state->m_superfx)) |
| 840 | | value = snes_ram[0xe00000 + offset]; |
| 841 | | else |
| 842 | | value = snes_open_bus_r(space, 0); |
| 843 | | } |
| 844 | | else if (state->m_cart[0].mode & 5) /* Mode 20 & 22 */ |
| 845 | | { |
| 846 | 794 | if (address >= 0x8000) |
| 847 | 795 | value = snes_ram[0x600000 + offset]; |
| 848 | 796 | else |
| r21584 | r21585 | |
| 864 | 812 | UINT8 value; |
| 865 | 813 | UINT16 address = offset & 0xffff; |
| 866 | 814 | |
| 867 | | if (state->m_has_addon_chip == HAS_SUPERFX && state->m_superfx != NULL) |
| 815 | if ((state->m_cart[0].mode & 5) && (address < 0x8000)) /* Mode 20 & 22 */ |
| 868 | 816 | { |
| 869 | | if (superfx_access_ram(state->m_superfx)) |
| 870 | | value = snes_ram[0xf00000 + offset]; |
| 871 | | else |
| 872 | | value = snes_open_bus_r(space, 0); |
| 873 | | } |
| 874 | | else if ((state->m_cart[0].mode & 5) && (address < 0x8000)) /* Mode 20 & 22 */ |
| 875 | | { |
| 876 | 817 | if (state->m_cart[0].sram > 0x8000) |
| 877 | 818 | { |
| 878 | 819 | // In this case, SRAM is mapped in 0x8000 chunks at diff offsets: 0x700000-0x707fff, 0x710000-0x717fff, etc. |
| r21584 | r21585 | |
| 904 | 845 | UINT8 value = 0; |
| 905 | 846 | UINT16 address = offset & 0xffff; |
| 906 | 847 | |
| 907 | | if (state->m_has_addon_chip == HAS_SUPERFX) |
| 908 | | value = space.read_byte(offset); |
| 909 | | else if (address < 0x8000) |
| 848 | if (address < 0x8000) |
| 910 | 849 | { |
| 911 | 850 | if (state->m_cart[0].mode != SNES_MODE_25) |
| 912 | 851 | value = space.read_byte(offset); |
| r21584 | r21585 | |
| 939 | 878 | UINT8 value = 0; |
| 940 | 879 | UINT16 address = offset & 0xffff; |
| 941 | 880 | |
| 942 | | if (state->m_has_addon_chip == HAS_SUPERFX && state->m_superfx != NULL) |
| 881 | if (state->m_cart[0].mode & 5) /* Mode 20 & 22 */ |
| 943 | 882 | { |
| 944 | | if (offset < 0x200000) // ROM |
| 945 | | { |
| 946 | | if (superfx_access_rom(state->m_superfx)) |
| 947 | | value = snes_ram[0xc00000 + offset]; |
| 948 | | else |
| 949 | | { |
| 950 | | static const UINT8 sfx_data[16] = { |
| 951 | | 0x00, 0x01, 0x00, 0x01, 0x04, 0x01, 0x00, 0x01, |
| 952 | | 0x00, 0x01, 0x08, 0x01, 0x00, 0x01, 0x0c, 0x01, |
| 953 | | }; |
| 954 | | return sfx_data[offset & 0x0f]; |
| 955 | | } |
| 956 | | } |
| 957 | | else // RAM |
| 958 | | { |
| 959 | | offset -= 0x200000; |
| 960 | | if (superfx_access_ram(state->m_superfx)) |
| 961 | | value = snes_ram[0xe00000 + offset]; |
| 962 | | else |
| 963 | | value = snes_open_bus_r(space, 0); |
| 964 | | } |
| 965 | | } |
| 966 | | else if ((state->m_cart[0].mode & 5) && !(state->m_has_addon_chip == HAS_SUPERFX)) /* Mode 20 & 22 */ |
| 967 | | { |
| 968 | 883 | if (address < 0x8000) |
| 969 | 884 | value = space.read_byte(0x400000 + offset); |
| 970 | 885 | else |
| 971 | 886 | value = snes_ram[0xc00000 + offset]; |
| 972 | 887 | } |
| 973 | | else /* Mode 21 & 25 + SuperFX Games */ |
| 888 | else /* Mode 21 & 25 */ |
| 974 | 889 | value = snes_ram[0xc00000 + offset]; |
| 975 | 890 | |
| 976 | 891 | return value; |
| r21584 | r21585 | |
| 993 | 908 | snes_w_io(space, address, data); |
| 994 | 909 | } |
| 995 | 910 | else if (address < 0x8000) |
| 996 | | { |
| 997 | | if (state->m_has_addon_chip == HAS_SUPERFX) |
| 998 | | snes_ram[0xf00000 + (offset & 0x1fff)] = data; // here it should be 0xe00000 but there are mirroring issues |
| 999 | | else |
| 1000 | | logerror("snes_w_bank1: Attempt to write to reserved address: %x = %02x\n", offset, data); |
| 1001 | | } |
| 911 | logerror("snes_w_bank1: Attempt to write to reserved address: %x = %02x\n", offset, data); |
| 1002 | 912 | else |
| 1003 | 913 | logerror( "(PC=%06x) Attempt to write to ROM address: %X\n",space.device().safe_pc(),offset ); |
| 1004 | 914 | } |
| r21584 | r21585 | |
| 1020 | 930 | } |
| 1021 | 931 | else if (address < 0x8000) /* SRAM for mode_21, Reserved othewise */ |
| 1022 | 932 | { |
| 1023 | | if (state->m_has_addon_chip == HAS_SUPERFX) |
| 1024 | | snes_ram[0xf00000 + (offset & 0x1fff)] = data; // here it should be 0xe00000 but there are mirroring issues |
| 1025 | | else if ((state->m_cart[0].mode == SNES_MODE_21) && (state->m_cart[0].sram > 0)) |
| 933 | if ((state->m_cart[0].mode == SNES_MODE_21) && (state->m_cart[0].sram > 0)) |
| 1026 | 934 | { |
| 1027 | 935 | /* Donkey Kong Country checks this and detects a copier if 0x800 is not masked out due to sram size */ |
| 1028 | 936 | /* OTOH Secret of Mana does not work properly if sram is not mirrored on later banks */ |
| r21584 | r21585 | |
| 1042 | 950 | snes_state *state = space.machine().driver_data<snes_state>(); |
| 1043 | 951 | UINT16 address = offset & 0xffff; |
| 1044 | 952 | |
| 1045 | | if (state->m_has_addon_chip == HAS_SUPERFX) |
| 1046 | | snes_ram[0xe00000 + offset] = data; |
| 1047 | | else if (state->m_cart[0].mode & 5) /* Mode 20 & 22 */ |
| 953 | if (state->m_cart[0].mode & 5) /* Mode 20 & 22 */ |
| 1048 | 954 | { |
| 1049 | 955 | if (address >= 0x8000) |
| 1050 | 956 | logerror("(PC=%06x) Attempt to write to ROM address: %X\n",space.device().safe_pc(),offset + 0x600000); |
| r21584 | r21585 | |
| 1061 | 967 | snes_state *state = space.machine().driver_data<snes_state>(); |
| 1062 | 968 | UINT16 address = offset & 0xffff; |
| 1063 | 969 | |
| 1064 | | if (state->m_has_addon_chip == HAS_SUPERFX) |
| 1065 | | snes_ram[0xf00000 + offset] = data; |
| 1066 | | else if ((state->m_cart[0].mode & 5) && (address < 0x8000)) /* Mode 20 & 22 */ |
| 970 | if ((state->m_cart[0].mode & 5) && (address < 0x8000)) /* Mode 20 & 22 */ |
| 1067 | 971 | { |
| 1068 | 972 | if (state->m_cart[0].sram > 0x8000) |
| 1069 | 973 | { |
| r21584 | r21585 | |
| 1091 | 995 | snes_state *state = space.machine().driver_data<snes_state>(); |
| 1092 | 996 | UINT16 address = offset & 0xffff; |
| 1093 | 997 | |
| 1094 | | if (state->m_has_addon_chip == HAS_SUPERFX) |
| 1095 | | space.write_byte(offset, data); |
| 1096 | | else if (address < 0x8000) |
| 998 | if (address < 0x8000) |
| 1097 | 999 | { |
| 1098 | 1000 | if (state->m_cart[0].mode != SNES_MODE_25) |
| 1099 | 1001 | space.write_byte(offset, data); |
| r21584 | r21585 | |
| 1121 | 1023 | snes_state *state = space.machine().driver_data<snes_state>(); |
| 1122 | 1024 | UINT16 address = offset & 0xffff; |
| 1123 | 1025 | |
| 1124 | | if (state->m_has_addon_chip == HAS_SUPERFX) |
| 1026 | if (state->m_cart[0].mode & 5) /* Mode 20 & 22 */ |
| 1125 | 1027 | { |
| 1126 | | if (offset >= 0x200000) |
| 1127 | | { |
| 1128 | | offset -= 0x200000; |
| 1129 | | snes_ram[0xe00000 + offset] = data; // SFX RAM |
| 1130 | | } |
| 1131 | | else |
| 1132 | | logerror("(PC=%06x) Attempt to write to ROM address: %X\n",space.device().safe_pc(),offset + 0xc00000); |
| 1133 | | } |
| 1134 | | else if (state->m_cart[0].mode & 5) /* Mode 20 & 22 */ |
| 1135 | | { |
| 1136 | 1028 | if (address < 0x8000) |
| 1137 | 1029 | { |
| 1138 | 1030 | if (offset >= 0x3e0000) |
trunk/src/mess/drivers/snes.c
| r21584 | r21585 | |
| 160 | 160 | if ((state->m_has_addon_chip == HAS_SPC7110 || state->m_has_addon_chip == HAS_SPC7110_RTC) |
| 161 | 161 | && offset >= 0x500000 && offset < 0x510000) |
| 162 | 162 | return spc7110_mmio_read(space, 0x4800); |
| 163 | if (state->m_has_addon_chip == HAS_SUPERFX && state->m_superfx != NULL |
| 164 | && offset < 0x400000) |
| 165 | { |
| 166 | if (address >= 0x3000 && address < 0x3300) |
| 167 | return superfx_mmio_read(state->m_superfx, address); |
| 168 | if (address >= 0x6000 && address < 0x8000) // here it should be snes_ram[0xe00000+...] but there are mirroring issues |
| 169 | return superfx_access_ram(state->m_superfx) ? snes_ram[0xf00000 + (offset & 0x1fff)] : snes_open_bus_r(space, 0); |
| 170 | } |
| 171 | if (state->m_has_addon_chip == HAS_SUPERFX && state->m_superfx != NULL |
| 172 | && offset >= 0x400000 && offset < 0x600000) |
| 173 | { |
| 174 | if (superfx_access_rom(state->m_superfx)) |
| 175 | return snes_ram[offset]; |
| 176 | else |
| 177 | { |
| 178 | static const UINT8 sfx_data[16] = { |
| 179 | 0x00, 0x01, 0x00, 0x01, 0x04, 0x01, 0x00, 0x01, |
| 180 | 0x00, 0x01, 0x08, 0x01, 0x00, 0x01, 0x0c, 0x01, |
| 181 | }; |
| 182 | return sfx_data[offset & 0x0f]; |
| 183 | } |
| 184 | } |
| 185 | if (state->m_has_addon_chip == HAS_SUPERFX && state->m_superfx != NULL |
| 186 | && offset >= 0x600000) |
| 187 | return superfx_access_ram(state->m_superfx) ? snes_ram[0x800000 + offset] : snes_open_bus_r(space, 0); |
| 163 | 188 | |
| 164 | 189 | // base cart access |
| 165 | 190 | if (offset < 0x300000) |
| r21584 | r21585 | |
| 231 | 256 | if ((state->m_has_addon_chip == HAS_SPC7110 || state->m_has_addon_chip == HAS_SPC7110_RTC) |
| 232 | 257 | && offset >= 0x500000) |
| 233 | 258 | return spc7110_bank7_read(space, offset - 0x400000); |
| 259 | if (state->m_has_addon_chip == HAS_SUPERFX && state->m_superfx != NULL) |
| 260 | return space.read_byte(offset); // [80-ff] same as [00-7f] |
| 234 | 261 | |
| 235 | 262 | // base cart access |
| 236 | 263 | if (offset < 0x400000) |
| r21584 | r21585 | |
| 307 | 334 | if (offset >= 0x300000 && offset < 0x310000 && address >= 0x6000 && address < 0x8000) |
| 308 | 335 | { snes_ram[0x306000 + (address & 0x1fff)] = data; return; } |
| 309 | 336 | } |
| 337 | if (state->m_has_addon_chip == HAS_SUPERFX && state->m_superfx != NULL |
| 338 | && offset < 0x400000) |
| 339 | { |
| 340 | if (address >= 0x3000 && address < 0x3300) |
| 341 | { superfx_mmio_write(state->m_superfx, address, data); return; } |
| 342 | if (address >= 0x6000 && address < 0x8000) // here it should be snes_ram[0xe00000+...] but there are mirroring issues |
| 343 | { snes_ram[0xf00000 + (offset & 0x1fff)] = data; return; } |
| 344 | } |
| 345 | if (state->m_has_addon_chip == HAS_SUPERFX && state->m_superfx != NULL |
| 346 | && offset >= 0x600000) |
| 347 | { snes_ram[0x800000 + offset] = data; return; } |
| 310 | 348 | |
| 311 | 349 | // base cart access |
| 312 | 350 | if (offset < 0x300000) |
| r21584 | r21585 | |
| 389 | 427 | if (offset >= 0x300000 && offset < 0x310000 && address >= 0x6000 && address < 0x8000) |
| 390 | 428 | { snes_ram[0x306000 + (address & 0x1fff)] = data; return; } |
| 391 | 429 | } |
| 430 | if (state->m_has_addon_chip == HAS_SUPERFX && state->m_superfx != NULL) |
| 431 | { space.write_byte(offset, data); return; } // [80-ff] same as [00-7f] |
| 392 | 432 | |
| 393 | 433 | // base cart access |
| 394 | 434 | if (offset < 0x400000) |
| r21584 | r21585 | |
| 1603 | 1643 | if (address >= 0x8000) |
| 1604 | 1644 | return state->m_slotcart->m_cart->read_h(space, offset); //ROM |
| 1605 | 1645 | } |
| 1606 | | if (offset < 0x600000) |
| 1646 | else if (offset < 0x600000) |
| 1607 | 1647 | return state->m_slotcart->m_cart->read_h(space, offset); //ROM |
| 1608 | 1648 | |
| 1609 | 1649 | return state->m_slotcart->m_cart->read_h(space, offset); //RAM |
| r21584 | r21585 | |
| 1632 | 1672 | if (address >= 0x8000) |
| 1633 | 1673 | return state->m_slotcart->m_cart->read_l(space, offset); //ROM |
| 1634 | 1674 | } |
| 1635 | | if (offset < 0x600000) |
| 1675 | else if (offset < 0x600000) |
| 1636 | 1676 | return state->m_slotcart->m_cart->read_l(space, offset); //ROM |
| 1637 | 1677 | |
| 1638 | 1678 | return state->m_slotcart->m_cart->read_l(space, offset); //RAM |