trunk/src/mame/machine/snes.c
| r21640 | r21641 | |
| 689 | 689 | value = state->snes_r_io(space, address); |
| 690 | 690 | else if (address < 0x8000) |
| 691 | 691 | { |
| 692 | | logerror("(PC=%06x) snes_r_bank1: Unmapped external chip read: %04x\n",space.device().safe_pc(),address); |
| 692 | logerror("(PC=%06x) snes_r_bank1: Unmapped external chip read: %04x\n", space.device().safe_pc(), address); |
| 693 | 693 | value = snes_open_bus_r(space, 0); /* Reserved */ |
| 694 | 694 | } |
| 695 | 695 | else |
| r21640 | r21641 | |
| 720 | 720 | } |
| 721 | 721 | else |
| 722 | 722 | { |
| 723 | | logerror( "(PC=%06x) snes_r_bank2: Unmapped external chip read: %04x\n",space.device().safe_pc(),address ); |
| 723 | logerror("(PC=%06x) snes_r_bank2: Unmapped external chip read: %04x\n", space.device().safe_pc(), address ); |
| 724 | 724 | value = snes_open_bus_r(space, 0); |
| 725 | 725 | } |
| 726 | 726 | } |
| r21640 | r21641 | |
| 739 | 739 | |
| 740 | 740 | if (state->m_cart[0].mode & 5) /* Mode 20 & 22 */ |
| 741 | 741 | { |
| 742 | | if ((address < 0x8000) && (state->m_cart[0].mode == SNES_MODE_20)) |
| 742 | if (address < 0x8000 && state->m_cart[0].mode == SNES_MODE_20) |
| 743 | 743 | value = snes_open_bus_r(space, 0); /* Reserved */ |
| 744 | 744 | else |
| 745 | 745 | value = snes_ram[0x400000 + offset]; //ROM |
| r21640 | r21641 | |
| 763 | 763 | value = snes_ram[0x600000 + offset]; //ROM |
| 764 | 764 | else |
| 765 | 765 | { |
| 766 | | logerror("(PC=%06x) snes_r_bank4: Unmapped external chip read: %04x\n",space.device().safe_pc(),address); |
| 766 | logerror("(PC=%06x) snes_r_bank4: Unmapped external chip read: %04x\n", space.device().safe_pc(), address); |
| 767 | 767 | value = snes_open_bus_r(space, 0); /* Reserved */ |
| 768 | 768 | } |
| 769 | 769 | } |
| r21640 | r21641 | |
| 780 | 780 | UINT8 value; |
| 781 | 781 | UINT16 address = offset & 0xffff; |
| 782 | 782 | |
| 783 | | if ((state->m_cart[0].mode & 5) && (address < 0x8000)) /* Mode 20 & 22 */ |
| 783 | if (state->m_cart[0].mode & 5 && address < 0x8000) /* Mode 20 & 22 */ |
| 784 | 784 | { |
| 785 | 785 | if (state->m_cart[0].m_nvram_size > 0x8000) |
| 786 | 786 | { |
| r21640 | r21641 | |
| 796 | 796 | } |
| 797 | 797 | else |
| 798 | 798 | { |
| 799 | | logerror("(PC=%06x) snes_r_bank5: Unmapped external chip read: %04x\n",space.device().safe_pc(),address); |
| 799 | logerror("(PC=%06x) snes_r_bank5: Unmapped external chip read: %04x\n", space.device().safe_pc(), address); |
| 800 | 800 | value = snes_open_bus_r(space, 0); /* Reserved */ |
| 801 | 801 | } |
| 802 | 802 | } |
| r21640 | r21641 | |
| 844 | 844 | int mask = state->m_cart[0].m_nvram_size - 1; /* Limit SRAM size to what's actually present */ |
| 845 | 845 | value = state->m_cart[0].m_nvram[offset & mask]; |
| 846 | 846 | } |
| 847 | else |
| 848 | { |
| 849 | logerror("(PC=%06x) snes_r_bank7: Unmapped external chip read: %04x\n", space.device().safe_pc(), address); |
| 850 | value = snes_open_bus_r(space, 0); /* Reserved */ |
| 851 | } |
| 847 | 852 | } |
| 848 | 853 | } |
| 849 | 854 | else |
| r21640 | r21641 | |
| 864 | 869 | else if (address < 0x6000) /* I/O */ |
| 865 | 870 | state->snes_w_io(space, address, data); |
| 866 | 871 | else if (address < 0x8000) |
| 867 | | logerror("snes_w_bank1: Attempt to write to reserved address: %x = %02x\n", offset, data); |
| 872 | logerror("(PC=%06x) snes_w_bank1: Attempt to write to reserved address: %x = %02x\n", space.device().safe_pc(), offset, data); |
| 868 | 873 | else |
| 869 | | logerror( "(PC=%06x) Attempt to write to ROM address: %X\n",space.device().safe_pc(),offset ); |
| 874 | logerror("(PC=%06x) Attempt to write to ROM address: %X\n", space.device().safe_pc(), offset); |
| 870 | 875 | } |
| 871 | 876 | |
| 872 | 877 | /* 0x300000 - 0x3fffff */ |
| r21640 | r21641 | |
| 889 | 894 | state->m_cart[0].m_nvram[(offset - 0x6000) & mask] = data; |
| 890 | 895 | } |
| 891 | 896 | else |
| 892 | | logerror("snes_w_bank2: Attempt to write to reserved address: %X = %02x\n", offset + 0x300000, data); |
| 897 | logerror("(PC=%06x) snes_w_bank2: Attempt to write to reserved address: %X = %02x\n", space.device().safe_pc(), offset + 0x300000, data); |
| 893 | 898 | } |
| 894 | 899 | else |
| 895 | | logerror("(PC=%06x) Attempt to write to ROM address: %X\n",space.device().safe_pc(),offset + 0x300000); |
| 900 | logerror("(PC=%06x) Attempt to write to ROM address: %X\n", space.device().safe_pc(), offset + 0x300000); |
| 896 | 901 | } |
| 897 | 902 | |
| 898 | 903 | /* 0x600000 - 0x6fffff */ |
| r21640 | r21641 | |
| 904 | 909 | if (state->m_cart[0].mode & 5) /* Mode 20 & 22 */ |
| 905 | 910 | { |
| 906 | 911 | if (address >= 0x8000) |
| 907 | | logerror("(PC=%06x) Attempt to write to ROM address: %X\n",space.device().safe_pc(),offset + 0x600000); |
| 912 | logerror("(PC=%06x) Attempt to write to ROM address: %X\n", space.device().safe_pc(), offset + 0x600000); |
| 908 | 913 | else |
| 909 | | logerror("snes_w_bank4: Attempt to write to reserved address: %X = %02x\n", offset + 0x600000, data); |
| 914 | logerror("(PC=%06x) snes_w_bank4: Attempt to write to reserved address: %X = %02x\n", space.device().safe_pc(), offset + 0x600000, data); |
| 910 | 915 | } |
| 911 | 916 | else if (state->m_cart[0].mode & 0x0a) |
| 912 | | logerror("(PC=%06x) Attempt to write to ROM address: %X\n",space.device().safe_pc(),offset + 0x600000); |
| 917 | logerror("(PC=%06x) Attempt to write to ROM address: %X\n", space.device().safe_pc(), offset + 0x600000); |
| 913 | 918 | } |
| 914 | 919 | |
| 915 | 920 | /* 0x700000 - 0x7dffff */ |
| r21640 | r21641 | |
| 918 | 923 | snes_state *state = space.machine().driver_data<snes_state>(); |
| 919 | 924 | UINT16 address = offset & 0xffff; |
| 920 | 925 | |
| 921 | | if ((state->m_cart[0].mode & 5) && (address < 0x8000)) /* Mode 20 & 22 */ |
| 926 | if (state->m_cart[0].mode & 5 && address < 0x8000) /* Mode 20 & 22 */ |
| 922 | 927 | { |
| 923 | 928 | if (state->m_cart[0].m_nvram_size > 0x8000) |
| 924 | 929 | { |
| r21640 | r21641 | |
| 933 | 938 | state->m_cart[0].m_nvram[offset & mask] = data; |
| 934 | 939 | } |
| 935 | 940 | else |
| 936 | | logerror("snes_w_bank5: Attempt to write to reserved address: %X = %02x\n", offset + 0x700000, data); |
| 941 | logerror("(PC=%06x) snes_w_bank5: Attempt to write to reserved address: %X = %02x\n", space.device().safe_pc(), offset + 0x700000, data); |
| 937 | 942 | } |
| 938 | | else if (state->m_cart[0].mode & 0x0a) |
| 939 | | logerror("(PC=%06x) Attempt to write to ROM address: %X\n",space.device().safe_pc(),offset + 0x700000); |
| 943 | else |
| 944 | logerror("(PC=%06x) Attempt to write to ROM address: %X\n", space.device().safe_pc(), offset + 0x700000); |
| 940 | 945 | } |
| 941 | 946 | |
| 942 | 947 | |
| r21640 | r21641 | |
| 946 | 951 | if ((offset & 0xffff) < 0x8000) |
| 947 | 952 | space.write_byte(offset, data); |
| 948 | 953 | else |
| 949 | | logerror("(PC=%06x) Attempt to write to ROM address: %X\n",space.device().safe_pc(),offset + 0x800000); |
| 954 | logerror("(PC=%06x) Attempt to write to ROM address: %X\n", space.device().safe_pc(), offset + 0x800000); |
| 950 | 955 | } |
| 951 | 956 | |
| 952 | 957 | |
| r21640 | r21641 | |
| 975 | 980 | return; |
| 976 | 981 | } |
| 977 | 982 | } |
| 978 | | logerror("(PC=%06x) snes_w_bank7: Attempt to write to ROM address: %X = %02x\n",space.device().safe_pc(),offset + 0xc00000, data); |
| 983 | else |
| 984 | logerror("(PC=%06x) snes_w_bank7: Attempt to write to ROM address: %X = %02x\n", space.device().safe_pc(), offset + 0xc00000, data); |
| 979 | 985 | } |
| 980 | 986 | else if (state->m_cart[0].mode & 0x0a) |
| 981 | | logerror("(PC=%06x) Attempt to write to ROM address: %X\n",space.device().safe_pc(),offset + 0xc00000); |
| 987 | logerror("(PC=%06x) Attempt to write to ROM address: %X\n", space.device().safe_pc(), offset + 0xc00000); |
| 982 | 988 | } |
| 983 | 989 | |
| 984 | 990 | |