src/mess/machine/nes_pcb.c
| r8375 | r8376 | |
| 577 | 577 | { "BMC-NTD-03", BMC_NTD_03 }, |
| 578 | 578 | { "BMC-8157", UNSUPPORTED_BOARD /*BMC_8157*/ }, |
| 579 | 579 | { "BMC-BS-5", BMC_BENSHENG_BS5 }, |
| 580 | | { "BMC-FK23C", UNSUPPORTED_BOARD /*BMC_FK23C*/ }, |
| 581 | | { "BMC-FK23CA", UNSUPPORTED_BOARD /*BMC_FK23C*/ }, // diff reg init |
| 580 | { "BMC-FK23C", BMC_FK23C }, |
| 581 | { "BMC-FK23CA", BMC_FK23CA }, |
| 582 | 582 | { "BMC-GHOSTBUSTERS63IN1", BMC_G63IN1 }, |
| 583 | 583 | { "BMC-SUPERVISION16IN1", UNSUPPORTED_BOARD }, // mapper 53 |
| 584 | 584 | { "BMC-RESETBASED-4IN1", UNSUPPORTED_BOARD },// mapper 60 with 64k prg and 32k chr |
| r8375 | r8376 | |
| 1228 | 1228 | nes_state *state = (nes_state *)machine->driver_data; |
| 1229 | 1229 | UINT8 prg_flip = (state->mmc_latch1 & 0x40) ? 2 : 0; |
| 1230 | 1230 | |
| 1231 | | if (state->mmc3_prg_cb) |
| 1232 | | { |
| 1233 | | state->mmc3_prg_cb(machine, 0, prg_base | (state->mmc_prg_bank[0 ^ prg_flip] & prg_mask)); |
| 1234 | | state->mmc3_prg_cb(machine, 1, prg_base | (state->mmc_prg_bank[1] & prg_mask)); |
| 1235 | | state->mmc3_prg_cb(machine, 2, prg_base | (state->mmc_prg_bank[2 ^ prg_flip] & prg_mask)); |
| 1236 | | state->mmc3_prg_cb(machine, 3, prg_base | (state->mmc_prg_bank[3] & prg_mask)); |
| 1237 | | } |
| 1238 | | else |
| 1239 | | { |
| 1240 | | prg8_x(machine, 0, prg_base | (state->mmc_prg_bank[0 ^ prg_flip] & prg_mask)); |
| 1241 | | prg8_x(machine, 1, prg_base | (state->mmc_prg_bank[1] & prg_mask)); |
| 1242 | | prg8_x(machine, 2, prg_base | (state->mmc_prg_bank[2 ^ prg_flip] & prg_mask)); |
| 1243 | | prg8_x(machine, 3, prg_base | (state->mmc_prg_bank[3] & prg_mask)); |
| 1244 | | } |
| 1231 | state->mmc3_prg_cb(machine, 0, prg_base | (state->mmc_prg_bank[0 ^ prg_flip] & prg_mask)); |
| 1232 | state->mmc3_prg_cb(machine, 1, prg_base | (state->mmc_prg_bank[1] & prg_mask)); |
| 1233 | state->mmc3_prg_cb(machine, 2, prg_base | (state->mmc_prg_bank[2 ^ prg_flip] & prg_mask)); |
| 1234 | state->mmc3_prg_cb(machine, 3, prg_base | (state->mmc_prg_bank[3] & prg_mask)); |
| 1245 | 1235 | } |
| 1246 | 1236 | |
| 1247 | 1237 | static void mmc3_set_chr( running_machine *machine, UINT8 chr, int chr_base, int chr_mask ) |
| r8375 | r8376 | |
| 1249 | 1239 | nes_state *state = (nes_state *)machine->driver_data; |
| 1250 | 1240 | UINT8 chr_page = (state->mmc_latch1 & 0x80) >> 5; |
| 1251 | 1241 | |
| 1252 | | if (state->mmc3_chr_cb) |
| 1253 | | { |
| 1254 | | state->mmc3_chr_cb(machine, chr_page ^ 0, chr_base | ((state->mmc_vrom_bank[0] & ~0x01) & chr_mask), chr); |
| 1255 | | state->mmc3_chr_cb(machine, chr_page ^ 1, chr_base | ((state->mmc_vrom_bank[0] | 0x01) & chr_mask), chr); |
| 1256 | | state->mmc3_chr_cb(machine, chr_page ^ 2, chr_base | ((state->mmc_vrom_bank[1] & ~0x01) & chr_mask), chr); |
| 1257 | | state->mmc3_chr_cb(machine, chr_page ^ 3, chr_base | ((state->mmc_vrom_bank[1] | 0x01) & chr_mask), chr); |
| 1258 | | state->mmc3_chr_cb(machine, chr_page ^ 4, chr_base | (state->mmc_vrom_bank[2] & chr_mask), chr); |
| 1259 | | state->mmc3_chr_cb(machine, chr_page ^ 5, chr_base | (state->mmc_vrom_bank[3] & chr_mask), chr); |
| 1260 | | state->mmc3_chr_cb(machine, chr_page ^ 6, chr_base | (state->mmc_vrom_bank[4] & chr_mask), chr); |
| 1261 | | state->mmc3_chr_cb(machine, chr_page ^ 7, chr_base | (state->mmc_vrom_bank[5] & chr_mask), chr); |
| 1262 | | } |
| 1263 | | else |
| 1264 | | { |
| 1265 | | chr1_x(machine, chr_page ^ 0, chr_base | ((state->mmc_vrom_bank[0] & ~0x01) & chr_mask), chr); |
| 1266 | | chr1_x(machine, chr_page ^ 1, chr_base | ((state->mmc_vrom_bank[0] | 0x01) & chr_mask), chr); |
| 1267 | | chr1_x(machine, chr_page ^ 2, chr_base | ((state->mmc_vrom_bank[1] & ~0x01) & chr_mask), chr); |
| 1268 | | chr1_x(machine, chr_page ^ 3, chr_base | ((state->mmc_vrom_bank[1] | 0x01) & chr_mask), chr); |
| 1269 | | chr1_x(machine, chr_page ^ 4, chr_base | (state->mmc_vrom_bank[2] & chr_mask), chr); |
| 1270 | | chr1_x(machine, chr_page ^ 5, chr_base | (state->mmc_vrom_bank[3] & chr_mask), chr); |
| 1271 | | chr1_x(machine, chr_page ^ 6, chr_base | (state->mmc_vrom_bank[4] & chr_mask), chr); |
| 1272 | | chr1_x(machine, chr_page ^ 7, chr_base | (state->mmc_vrom_bank[5] & chr_mask), chr); |
| 1273 | | } |
| 1242 | state->mmc3_chr_cb(machine, chr_page ^ 0, chr_base | ((state->mmc_vrom_bank[0] & ~0x01) & chr_mask), chr); |
| 1243 | state->mmc3_chr_cb(machine, chr_page ^ 1, chr_base | ((state->mmc_vrom_bank[0] | 0x01) & chr_mask), chr); |
| 1244 | state->mmc3_chr_cb(machine, chr_page ^ 2, chr_base | ((state->mmc_vrom_bank[1] & ~0x01) & chr_mask), chr); |
| 1245 | state->mmc3_chr_cb(machine, chr_page ^ 3, chr_base | ((state->mmc_vrom_bank[1] | 0x01) & chr_mask), chr); |
| 1246 | state->mmc3_chr_cb(machine, chr_page ^ 4, chr_base | (state->mmc_vrom_bank[2] & chr_mask), chr); |
| 1247 | state->mmc3_chr_cb(machine, chr_page ^ 5, chr_base | (state->mmc_vrom_bank[3] & chr_mask), chr); |
| 1248 | state->mmc3_chr_cb(machine, chr_page ^ 6, chr_base | (state->mmc_vrom_bank[4] & chr_mask), chr); |
| 1249 | state->mmc3_chr_cb(machine, chr_page ^ 7, chr_base | (state->mmc_vrom_bank[5] & chr_mask), chr); |
| 1274 | 1250 | } |
| 1275 | 1251 | |
| 1276 | 1252 | /* Here, IRQ counter decrements every scanline. */ |
| r8375 | r8376 | |
| 6915 | 6891 | |
| 6916 | 6892 | *************************************************************/ |
| 6917 | 6893 | |
| 6918 | | // remove mask & base parameters! |
| 6919 | | static void sgame_boog_set_prg( running_machine *machine, int prg_base, int prg_mask ) |
| 6894 | static void sgame_boog_prg_cb( running_machine *machine, int start, int bank ) |
| 6920 | 6895 | { |
| 6921 | 6896 | nes_state *state = (nes_state *)machine->driver_data; |
| 6922 | | if (state->map215_reg[0] & 0x80) |
| 6897 | if (!(state->map215_reg[0] & 0x80)) // if this is != 0 we should never even arrive here |
| 6923 | 6898 | { |
| 6924 | | prg16_89ab(machine, (state->map215_reg[0] & 0xf0) | (state->map215_reg[1] & 0x10)); |
| 6925 | | prg16_cdef(machine, (state->map215_reg[0] & 0xf0) | (state->map215_reg[1] & 0x10)); |
| 6926 | | } |
| 6927 | | else |
| 6928 | | { |
| 6929 | | state->mmc_prg_base = (state->map215_reg[1] & 0x08) ? 0x20 : (state->map215_reg[1] & 0x10); |
| 6930 | | state->mmc_prg_mask = (state->map215_reg[1] & 0x08) ? 0x1f : 0x0f; |
| 6899 | if (state->map215_reg[1] & 0x08) |
| 6900 | bank = (bank & 0x1f) | 0x20; |
| 6901 | else |
| 6902 | bank = (bank & 0x0f) | (state->map215_reg[1] & 0x10); |
| 6931 | 6903 | |
| 6932 | | mmc3_set_prg(machine, state->mmc_prg_base, state->mmc_prg_mask); |
| 6904 | prg8_x(machine, start, bank); |
| 6933 | 6905 | } |
| 6934 | 6906 | } |
| 6935 | 6907 | |
| 6936 | | static void sgame_boog_set_chr( running_machine *machine, UINT8 chr ) |
| 6908 | static void sgame_boog_chr_cb( running_machine *machine, int start, int bank, int source ) |
| 6937 | 6909 | { |
| 6938 | 6910 | nes_state *state = (nes_state *)machine->driver_data; |
| 6939 | | UINT8 chr_page = (state->mmc_latch1 & 0x80) >> 5; |
| 6940 | | int chr_base = (state->map215_reg[1] & 0x04) ? 0x100 : ((state->map215_reg[1] & 0x10) << 3); |
| 6941 | | int chr_mask = (state->map215_reg[1] & 0x04) ? 0xff : 0x7f; |
| 6911 | |
| 6912 | if ((state->map215_reg[1] & 0x04)) |
| 6913 | bank |= 0x100; |
| 6914 | else |
| 6915 | bank = (bank & 0x7f) | ((state->map215_reg[1] & 0x10) << 3); |
| 6916 | |
| 6917 | chr1_x(machine, start, bank, source); |
| 6918 | } |
| 6942 | 6919 | |
| 6943 | | chr1_x(machine, chr_page ^ 0, chr_base | ((state->mmc_vrom_bank[0] & ~0x01) & chr_mask), chr); |
| 6944 | | chr1_x(machine, chr_page ^ 1, chr_base | ((state->mmc_vrom_bank[0] | 0x01) & chr_mask), chr); |
| 6945 | | chr1_x(machine, chr_page ^ 2, chr_base | ((state->mmc_vrom_bank[1] & ~0x01) & chr_mask), chr); |
| 6946 | | chr1_x(machine, chr_page ^ 3, chr_base | ((state->mmc_vrom_bank[1] | 0x01) & chr_mask), chr); |
| 6947 | | chr1_x(machine, chr_page ^ 4, chr_base | (state->mmc_vrom_bank[2] & chr_mask), chr); |
| 6948 | | chr1_x(machine, chr_page ^ 5, chr_base | (state->mmc_vrom_bank[3] & chr_mask), chr); |
| 6949 | | chr1_x(machine, chr_page ^ 6, chr_base | (state->mmc_vrom_bank[4] & chr_mask), chr); |
| 6950 | | chr1_x(machine, chr_page ^ 7, chr_base | (state->mmc_vrom_bank[5] & chr_mask), chr); |
| 6920 | static void sgame_boog_set_prg( running_machine *machine ) |
| 6921 | { |
| 6922 | nes_state *state = (nes_state *)machine->driver_data; |
| 6923 | if (state->map215_reg[0] & 0x80) |
| 6924 | { |
| 6925 | prg16_89ab(machine, (state->map215_reg[0] & 0xf0) | (state->map215_reg[1] & 0x10)); |
| 6926 | prg16_cdef(machine, (state->map215_reg[0] & 0xf0) | (state->map215_reg[1] & 0x10)); |
| 6927 | } |
| 6928 | else |
| 6929 | mmc3_set_prg(machine, state->mmc_prg_base, state->mmc_prg_mask); |
| 6951 | 6930 | } |
| 6952 | 6931 | |
| 6953 | 6932 | static WRITE8_HANDLER( sgame_boog_l_w ) |
| r8375 | r8376 | |
| 6959 | 6938 | if (offset == 0x1000) |
| 6960 | 6939 | { |
| 6961 | 6940 | state->map215_reg[0] = data; |
| 6962 | | sgame_boog_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask); |
| 6941 | sgame_boog_set_prg(space->machine); |
| 6963 | 6942 | } |
| 6964 | 6943 | else if (offset == 0x1001) |
| 6965 | 6944 | { |
| 6966 | 6945 | state->map215_reg[1] = data; |
| 6967 | | sgame_boog_set_chr(space->machine, state->mmc_chr_source); |
| 6946 | mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask); |
| 6968 | 6947 | } |
| 6969 | 6948 | else if (offset == 0x1007) |
| 6970 | 6949 | { |
| 6971 | 6950 | state->mmc_latch1 = 0; |
| 6972 | 6951 | state->map215_reg[2] = data; |
| 6973 | | sgame_boog_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask); |
| 6974 | | sgame_boog_set_chr(space->machine, state->mmc_chr_source); |
| 6952 | sgame_boog_set_prg(space->machine); |
| 6953 | mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask); |
| 6975 | 6954 | } |
| 6976 | 6955 | } |
| 6977 | 6956 | |
| 6957 | static WRITE8_HANDLER( sgame_boog_m_w ) |
| 6958 | { |
| 6959 | nes_state *state = (nes_state *)space->machine->driver_data; |
| 6960 | LOG_MMC(("sgame_boog_m_w, offset: %04x, data: %02x\n", offset, data)); |
| 6961 | |
| 6962 | if (offset == 0x0000) |
| 6963 | { |
| 6964 | state->map215_reg[0] = data; |
| 6965 | sgame_boog_set_prg(space->machine); |
| 6966 | } |
| 6967 | else if (offset == 0x0001) |
| 6968 | { |
| 6969 | state->map215_reg[1] = data; |
| 6970 | mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask); |
| 6971 | } |
| 6972 | else if (offset == 0x0007) |
| 6973 | { |
| 6974 | state->mmc_latch1 = 0; |
| 6975 | state->map215_reg[2] = data; |
| 6976 | sgame_boog_set_prg(space->machine); |
| 6977 | mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask); |
| 6978 | } |
| 6979 | } |
| 6980 | |
| 6978 | 6981 | static WRITE8_HANDLER( sgame_boog_w ) |
| 6979 | 6982 | { |
| 6980 | 6983 | nes_state *state = (nes_state *)space->machine->driver_data; |
| 6981 | | UINT8 MMC3_helper, cmd; |
| 6982 | 6984 | static const UINT8 conv_table[8] = {0,2,5,3,6,1,7,4}; |
| 6983 | 6985 | LOG_MMC(("sgame_boog_w, offset: %04x, data: %02x\n", offset, data)); |
| 6984 | 6986 | |
| 6985 | | if (!state->map215_reg[2]) // in this case we act like MMC3, only with alt prg/chr handlers |
| 6987 | switch (offset & 0x6001) |
| 6986 | 6988 | { |
| 6987 | | switch (offset & 0x6001) |
| 6988 | | { |
| 6989 | | case 0x0000: |
| 6990 | | MMC3_helper = state->mmc_latch1 ^ data; |
| 6991 | | state->mmc_latch1 = data; |
| 6992 | | |
| 6993 | | /* Has PRG Mode changed? */ |
| 6994 | | if (MMC3_helper & 0x40) |
| 6995 | | sgame_boog_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask); |
| 6996 | | |
| 6997 | | /* Has CHR Mode changed? */ |
| 6998 | | if (MMC3_helper & 0x80) |
| 6999 | | sgame_boog_set_chr(space->machine, state->mmc_chr_source); |
| 7000 | | break; |
| 7001 | | |
| 7002 | | case 0x0001: |
| 7003 | | cmd = state->mmc_latch1 & 0x07; |
| 7004 | | switch (cmd) |
| 6989 | case 0x0000: |
| 6990 | if (!state->map215_reg[2]) |
| 6991 | txrom_w(space, 0x0000, data); |
| 6992 | break; |
| 6993 | |
| 6994 | case 0x0001: |
| 6995 | if (!state->map215_reg[2]) |
| 6996 | txrom_w(space, 0x0001, data); |
| 6997 | else if (state->map215_reg[3] && ((state->map215_reg[0] & 0x80) == 0 || (state->mmc_latch1 & 0x07) < 6)) // if we use the prg16 banks and cmd=6,7 DON'T enter! |
| 7005 | 6998 | { |
| 7006 | | case 0: case 1: // these do not need to be separated: we take care of them in set_chr! |
| 7007 | | case 2: case 3: case 4: case 5: |
| 7008 | | state->mmc_vrom_bank[cmd] = data; |
| 7009 | | sgame_boog_set_chr(space->machine, state->mmc_chr_source); |
| 7010 | | break; |
| 7011 | | case 6: |
| 7012 | | case 7: |
| 7013 | | state->mmc_prg_bank[cmd - 6] = data; |
| 7014 | | sgame_boog_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask); |
| 7015 | | break; |
| 6999 | state->map215_reg[3] = 0; |
| 7000 | txrom_w(space, 0x0001, data); |
| 7016 | 7001 | } |
| 7017 | | break; |
| 7018 | | |
| 7019 | | default: |
| 7020 | | txrom_w(space, offset, data); |
| 7021 | | break; |
| 7022 | | } |
| 7023 | | } |
| 7024 | | else |
| 7025 | | { |
| 7026 | | switch (offset & 0x6001) |
| 7027 | | { |
| 7028 | | case 0x0000: |
| 7029 | | break; |
| 7030 | | |
| 7031 | | case 0x0001: |
| 7032 | | cmd = state->mmc_latch1 & 0x07; |
| 7033 | | if (state->map215_reg[3] && ((state->map215_reg[0] & 0x80) == 0 || cmd < 6)) // if we use the prg16 banks and cmd=6,7 DON'T enter! |
| 7034 | | { |
| 7035 | | state->map215_reg[3] = 0; |
| 7036 | | switch (cmd) |
| 7037 | | { |
| 7038 | | case 0: case 1: // these do not need to be separated: we take care of them in set_chr! |
| 7039 | | case 2: case 3: case 4: case 5: |
| 7040 | | state->mmc_vrom_bank[cmd] = data; |
| 7041 | | sgame_boog_set_chr(space->machine, state->mmc_chr_source); |
| 7042 | | break; |
| 7043 | | case 6: |
| 7044 | | case 7: |
| 7045 | | state->mmc_prg_bank[cmd - 6] = data; |
| 7046 | | sgame_boog_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask); |
| 7047 | | break; |
| 7048 | | } |
| 7049 | | } |
| 7050 | | break; |
| 7051 | | |
| 7052 | | case 0x2000: |
| 7002 | break; |
| 7003 | |
| 7004 | case 0x2000: |
| 7005 | if (!state->map215_reg[2]) |
| 7006 | txrom_w(space, 0x2000, data); |
| 7007 | else |
| 7008 | { |
| 7053 | 7009 | data = (data & 0xc0) | conv_table[data & 0x07]; |
| 7054 | | MMC3_helper = state->mmc_latch1 ^ data; |
| 7055 | | state->mmc_latch1 = data; |
| 7056 | | |
| 7057 | | /* Has PRG Mode changed? */ |
| 7058 | | if (MMC3_helper & 0x40) |
| 7059 | | sgame_boog_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask); |
| 7060 | | |
| 7061 | | /* Has CHR Mode changed? */ |
| 7062 | | if (MMC3_helper & 0x80) |
| 7063 | | sgame_boog_set_chr(space->machine, state->mmc_chr_source); |
| 7064 | | |
| 7065 | 7010 | state->map215_reg[3] = 1; |
| 7011 | txrom_w(space, 0x0000, data); |
| 7066 | 7012 | break; |
| 7013 | } |
| 7014 | break; |
| 7067 | 7015 | |
| 7068 | | // case 0x2001: |
| 7069 | | // txrom_w(space, 0x4001, data); |
| 7070 | | // break; |
| 7071 | | |
| 7072 | | case 0x4000: |
| 7016 | case 0x4000: |
| 7017 | if (!state->map215_reg[2]) |
| 7018 | txrom_w(space, 0x4000, data); |
| 7019 | else |
| 7073 | 7020 | set_nt_mirroring(space->machine, ((data >> 7) | data) & 0x01 ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); |
| 7074 | | break; |
| 7021 | break; |
| 7075 | 7022 | |
| 7076 | | case 0x4001: |
| 7023 | case 0x4001: |
| 7024 | if (!state->map215_reg[2]) |
| 7025 | txrom_w(space, 0x4001, data); |
| 7026 | else |
| 7077 | 7027 | txrom_w(space, 0x6001, data); |
| 7078 | | break; |
| 7028 | break; |
| 7079 | 7029 | |
| 7080 | | // case 0x6000: |
| 7081 | | // txrom_w(space, 0x6000, data); |
| 7082 | | // break; |
| 7083 | | |
| 7084 | | case 0x6001: |
| 7030 | case 0x6001: |
| 7031 | if (!state->map215_reg[2]) |
| 7032 | txrom_w(space, 0x6001, data); |
| 7033 | else |
| 7034 | { |
| 7085 | 7035 | txrom_w(space, 0x4000, data); |
| 7086 | 7036 | txrom_w(space, 0x4001, data); |
| 7087 | | break; |
| 7088 | | |
| 7089 | | default: |
| 7090 | | txrom_w(space, offset, data); |
| 7091 | | break; |
| 7092 | | } |
| 7037 | } |
| 7038 | break; |
| 7039 | |
| 7040 | default: |
| 7041 | txrom_w(space, offset, data); |
| 7042 | break; |
| 7093 | 7043 | } |
| 7094 | 7044 | } |
| 7095 | 7045 | |
| r8375 | r8376 | |
| 9047 | 8997 | |
| 9048 | 8998 | *************************************************************/ |
| 9049 | 8999 | |
| 9050 | | static void kof96_set_prg( running_machine *machine, int prg_base, int prg_mask ) |
| 9000 | static void kof96_prg_cb( running_machine *machine, int start, int bank ) |
| 9051 | 9001 | { |
| 9052 | 9002 | nes_state *state = (nes_state *)machine->driver_data; |
| 9053 | | UINT8 prg_flip = (state->mmc_latch1 & 0x40) ? 2 : 0; |
| 9054 | 9003 | |
| 9055 | 9004 | if (!(state->mapper187_reg[0] & 0x80)) |
| 9056 | | { |
| 9057 | | prg8_89(machine, prg_base | (state->mmc_prg_bank[0 ^ prg_flip] & prg_mask)); |
| 9058 | | prg8_ab(machine, prg_base | (state->mmc_prg_bank[1] & prg_mask)); |
| 9059 | | prg8_cd(machine, prg_base | (state->mmc_prg_bank[2 ^ prg_flip] & prg_mask)); |
| 9060 | | prg8_ef(machine, prg_base | (state->mmc_prg_bank[3] & prg_mask)); |
| 9061 | | } |
| 9005 | prg8_x(machine, start, bank); |
| 9062 | 9006 | } |
| 9063 | 9007 | |
| 9064 | | static void kof96_set_chr( running_machine *machine, UINT8 chr, int chr_base, int chr_mask ) |
| 9008 | static void kof96_chr_cb( running_machine *machine, int start, int bank, int source ) |
| 9065 | 9009 | { |
| 9066 | 9010 | nes_state *state = (nes_state *)machine->driver_data; |
| 9067 | 9011 | UINT8 chr_page = (state->mmc_latch1 & 0x80) >> 5; |
| 9068 | | UINT8 new_base[8]; |
| 9069 | | int i; |
| 9070 | 9012 | |
| 9071 | | for (i = 0; i < 8; i++) |
| 9072 | | new_base[i] = ((i & 0x04) == chr_page)? (chr_base | 0x100) : chr_base; |
| 9013 | if ((start & 0x04) == chr_page) |
| 9014 | bank |= 0x100; |
| 9073 | 9015 | |
| 9074 | | chr1_x(machine, chr_page ^ 0, new_base[0] | ((state->mmc_vrom_bank[0] & ~0x01) & chr_mask), chr); |
| 9075 | | chr1_x(machine, chr_page ^ 1, new_base[1] | ((state->mmc_vrom_bank[0] | 0x01) & chr_mask), chr); |
| 9076 | | chr1_x(machine, chr_page ^ 2, new_base[2] | ((state->mmc_vrom_bank[1] & ~0x01) & chr_mask), chr); |
| 9077 | | chr1_x(machine, chr_page ^ 3, new_base[3] | ((state->mmc_vrom_bank[1] | 0x01) & chr_mask), chr); |
| 9078 | | chr1_x(machine, chr_page ^ 4, new_base[4] | (state->mmc_vrom_bank[2] & chr_mask), chr); |
| 9079 | | chr1_x(machine, chr_page ^ 5, new_base[5] | (state->mmc_vrom_bank[3] & chr_mask), chr); |
| 9080 | | chr1_x(machine, chr_page ^ 6, new_base[6] | (state->mmc_vrom_bank[4] & chr_mask), chr); |
| 9081 | | chr1_x(machine, chr_page ^ 7, new_base[7] | (state->mmc_vrom_bank[5] & chr_mask), chr); |
| 9016 | chr1_x(machine, start, bank, source); |
| 9082 | 9017 | } |
| 9083 | 9018 | |
| 9084 | 9019 | static WRITE8_HANDLER( kof96_l_w ) |
| r8375 | r8376 | |
| 9090 | 9025 | |
| 9091 | 9026 | if (offset == 0x1000) |
| 9092 | 9027 | { |
| 9093 | | switch (data & 0x03) |
| 9094 | | { |
| 9095 | | case 0x00: |
| 9096 | | case 0x01: |
| 9097 | | state->mapper187_reg[1] = 0x83; |
| 9098 | | break; |
| 9099 | | case 0x02: |
| 9100 | | state->mapper187_reg[1] = 0x42; |
| 9101 | | break; |
| 9102 | | case 0x03: |
| 9103 | | state->mapper187_reg[1] = 0x00; |
| 9104 | | break; |
| 9105 | | } |
| 9106 | | } |
| 9107 | | |
| 9108 | | if (!(offset <= 0x1000)) |
| 9109 | | { |
| 9110 | 9028 | state->mapper187_reg[0] = data; |
| 9111 | 9029 | |
| 9112 | 9030 | if (state->mapper187_reg[0] & 0x80) |
| r8375 | r8376 | |
| 9122 | 9040 | } |
| 9123 | 9041 | } |
| 9124 | 9042 | else |
| 9125 | | kof96_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask); |
| 9043 | mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask); |
| 9126 | 9044 | } |
| 9045 | |
| 9046 | if (offset >= 0x1000) |
| 9047 | { |
| 9048 | switch (data & 0x03) |
| 9049 | { |
| 9050 | case 0x00: |
| 9051 | case 0x01: |
| 9052 | state->mapper187_reg[1] = 0x83; |
| 9053 | break; |
| 9054 | case 0x02: |
| 9055 | state->mapper187_reg[1] = 0x42; |
| 9056 | break; |
| 9057 | case 0x03: |
| 9058 | state->mapper187_reg[1] = 0x00; |
| 9059 | break; |
| 9060 | } |
| 9061 | |
| 9062 | } |
| 9063 | |
| 9064 | if (!state->mapper187_reg[3] && offset > 0x1000) |
| 9065 | { |
| 9066 | state->mapper187_reg[3] = 1; |
| 9067 | memory_write_byte(space, 0x4017, 0x40); |
| 9068 | } |
| 9127 | 9069 | } |
| 9128 | 9070 | |
| 9129 | 9071 | static READ8_HANDLER( kof96_l_r ) |
| r8375 | r8376 | |
| 9141 | 9083 | static WRITE8_HANDLER( kof96_w ) |
| 9142 | 9084 | { |
| 9143 | 9085 | nes_state *state = (nes_state *)space->machine->driver_data; |
| 9144 | | UINT8 MMC3_helper, cmd; |
| 9145 | 9086 | LOG_MMC(("kof96_w, offset: %04x, data: %02x\n", offset, data)); |
| 9146 | 9087 | |
| 9147 | 9088 | switch (offset & 0x6003) |
| 9148 | 9089 | { |
| 9149 | 9090 | case 0x0000: |
| 9150 | 9091 | state->mapper187_reg[2] = 1; |
| 9151 | | MMC3_helper = state->mmc_latch1 ^ data; |
| 9152 | | state->mmc_latch1 = data; |
| 9153 | | |
| 9154 | | /* Has PRG Mode changed? */ |
| 9155 | | if (MMC3_helper & 0x40) |
| 9156 | | kof96_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask); |
| 9157 | | |
| 9158 | | /* Has CHR Mode changed? */ |
| 9159 | | if (MMC3_helper & 0x80) |
| 9160 | | kof96_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask); |
| 9092 | txrom_w(space, 0x0000, data); |
| 9161 | 9093 | break; |
| 9162 | 9094 | |
| 9163 | 9095 | case 0x0001: |
| 9164 | 9096 | if (state->mapper187_reg[2]) |
| 9165 | | { |
| 9166 | | cmd = state->mmc_latch1 & 0x07; |
| 9167 | | switch (cmd) |
| 9168 | | { |
| 9169 | | case 0: case 1: |
| 9170 | | case 2: case 3: case 4: case 5: |
| 9171 | | state->mmc_vrom_bank[cmd] = data; |
| 9172 | | kof96_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask); |
| 9173 | | break; |
| 9174 | | case 6: |
| 9175 | | case 7: |
| 9176 | | state->mmc_prg_bank[cmd - 6] = data; |
| 9177 | | kof96_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask); |
| 9178 | | break; |
| 9179 | | } |
| 9180 | | } |
| 9097 | txrom_w(space, 0x0001, data); |
| 9181 | 9098 | break; |
| 9182 | 9099 | |
| 9183 | 9100 | case 0x0002: |
| r8375 | r8376 | |
| 9975 | 9892 | *************************************************************/ |
| 9976 | 9893 | |
| 9977 | 9894 | /************************************************************* |
| 9895 | |
| 9896 | Board BMC-FK23C |
| 9897 | |
| 9898 | In MESS: partially supported (still to sort initial banking |
| 9899 | for many games) |
| 9900 | |
| 9901 | *************************************************************/ |
| 9978 | 9902 | |
| 9903 | #if 0 |
| 9904 | static void fk23c_prg_cb( running_machine *machine, int start, int bank ) |
| 9905 | { |
| 9906 | nes_state *state = (nes_state *)machine->driver_data; |
| 9907 | |
| 9908 | if (((state->mmc_reg[0] & 0x07) - 3) > 1 && (!(state->mmc_reg[3] & 0x02) || start < 2)) |
| 9909 | { |
| 9910 | if (state->mmc_reg[0] & 0x03) |
| 9911 | bank = (bank & (0x3f >> (state->mmc_reg[0] & 0x03))) | (state->mmc_reg[1] << 1); |
| 9912 | |
| 9913 | prg8_x(machine, start, bank); |
| 9914 | } |
| 9915 | } |
| 9916 | |
| 9917 | static void fk23c_chr_cb( running_machine *machine, int start, int bank, int source ) |
| 9918 | { |
| 9919 | nes_state *state = (nes_state *)machine->driver_data; |
| 9920 | |
| 9921 | if (!(state->mmc_reg[0] & 0x40) && (!(state->mmc_reg[3] & 0x02) || (start != 1 && start != 3))) |
| 9922 | chr1_x(machine, start, ((state->mmc_reg[2] & 0x7f) << 3) | bank, source); |
| 9923 | } |
| 9924 | |
| 9925 | #endif |
| 9926 | |
| 9927 | static void fk23c_prg_cb( running_machine *machine, int start, int bank ) |
| 9928 | { |
| 9929 | nes_state *state = (nes_state *)machine->driver_data; |
| 9930 | UINT8 mask = (0x3f >> (state->mmc_reg[0] & 0x03)); |
| 9931 | |
| 9932 | if ((state->mmc_reg[0] & 0x07) < 3) |
| 9933 | { |
| 9934 | if (!(state->mmc_reg[0] & 0x03)) |
| 9935 | bank = (bank & mask) | ((state->mmc_reg[1] & (0x7f ^ mask)) << 1); |
| 9936 | |
| 9937 | prg8_x(machine, start, bank); |
| 9938 | } |
| 9939 | } |
| 9940 | |
| 9941 | static void fk23c_chr_cb( running_machine *machine, int start, int bank, int source ) |
| 9942 | { |
| 9943 | nes_state *state = (nes_state *)machine->driver_data; |
| 9944 | |
| 9945 | if (!(state->mmc_reg[0] & 0x40) && (!(state->mmc_reg[3] & 0x02) || (start != 1 && start != 3))) |
| 9946 | chr1_x(machine, start, ((state->mmc_reg[2] & 0x7f) << 3) | bank, source); |
| 9947 | } |
| 9948 | |
| 9949 | static void fk23c_set_prg( running_machine *machine ) |
| 9950 | { |
| 9951 | nes_state *state = (nes_state *)machine->driver_data; |
| 9952 | |
| 9953 | if ((state->mmc_reg[0] & 0x07) == 4) |
| 9954 | prg32(machine, (state->mmc_reg[1] & 0x7f) >> 1); |
| 9955 | else if ((state->mmc_reg[0] & 0x07) == 3) |
| 9956 | { |
| 9957 | prg16_89ab(machine, state->mmc_reg[1] & 0x7f); |
| 9958 | prg16_cdef(machine, state->mmc_reg[1] & 0x7f); |
| 9959 | } |
| 9960 | else |
| 9961 | { |
| 9962 | if (state->mmc_reg[3] & 0x02) |
| 9963 | { |
| 9964 | prg8_cd(machine, state->mmc_reg[4]); |
| 9965 | prg8_ef(machine, state->mmc_reg[5]); |
| 9966 | } |
| 9967 | |
| 9968 | mmc3_set_prg(machine, state->mmc_prg_base, state->mmc_prg_mask); |
| 9969 | } |
| 9970 | } |
| 9971 | |
| 9972 | static void fk23c_set_chr( running_machine *machine ) |
| 9973 | { |
| 9974 | nes_state *state = (nes_state *)machine->driver_data; |
| 9975 | |
| 9976 | if (state->mmc_reg[0] & 0x40) |
| 9977 | chr8(machine, state->mmc_reg[2] | state->mmc_cmd1, state->mmc_chr_source); |
| 9978 | else |
| 9979 | { |
| 9980 | if (state->mmc_reg[3] & 0x02) |
| 9981 | { |
| 9982 | int base = (state->mmc_reg[2] & 0x7f) << 3; |
| 9983 | chr1_x(machine, 1, base | state->mmc_reg[6], state->mmc_chr_source); |
| 9984 | chr1_x(machine, 3, base | state->mmc_reg[7], state->mmc_chr_source); |
| 9985 | } |
| 9986 | |
| 9987 | mmc3_set_chr(machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask); |
| 9988 | } |
| 9989 | } |
| 9990 | |
| 9991 | static WRITE8_HANDLER( fk23c_l_w ) |
| 9992 | { |
| 9993 | nes_state *state = (nes_state *)space->machine->driver_data; |
| 9994 | LOG_MMC(("fk23c_l_w, offset: %04x, data: %02x\n", offset, data)); |
| 9995 | offset += 0x100; |
| 9996 | |
| 9997 | if (offset >= 0x1000) |
| 9998 | { |
| 9999 | if (offset & (1 << 4)) // here it should be (4 + state->mmc_dipsetting) |
| 10000 | { |
| 10001 | state->mmc_reg[offset & 0x03] = data; |
| 10002 | |
| 10003 | fk23c_set_prg(space->machine); |
| 10004 | fk23c_set_chr(space->machine); |
| 10005 | } |
| 10006 | } |
| 10007 | } |
| 10008 | |
| 10009 | static WRITE8_HANDLER( fk23c_w ) |
| 10010 | { |
| 10011 | nes_state *state = (nes_state *)space->machine->driver_data; |
| 10012 | LOG_MMC(("fk23c_w, offset: %04x, data: %02x\n", offset, data)); |
| 10013 | |
| 10014 | if (state->mmc_reg[0] & 0x40) |
| 10015 | { |
| 10016 | if (state->mmc_reg[0] & 0x30) |
| 10017 | state->mmc_cmd1 = 0; |
| 10018 | else |
| 10019 | { |
| 10020 | state->mmc_cmd1 = data & 0x03; |
| 10021 | fk23c_set_chr(space->machine); |
| 10022 | } |
| 10023 | } |
| 10024 | else |
| 10025 | { |
| 10026 | switch (offset & 0x6001) |
| 10027 | { |
| 10028 | case 0x0001: |
| 10029 | if ((state->mmc_reg[3] & 0x02) && (state->mmc_latch1 & 0x08)) |
| 10030 | { |
| 10031 | state->mmc_reg[4 | (state->mmc_latch1 & 0x03)] = data; |
| 10032 | fk23c_set_prg(space->machine); |
| 10033 | fk23c_set_chr(space->machine); |
| 10034 | } |
| 10035 | else |
| 10036 | txrom_w(space, offset, data); |
| 10037 | break; |
| 10038 | |
| 10039 | case 0x2000: |
| 10040 | set_nt_mirroring(space->machine, data ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); |
| 10041 | break; |
| 10042 | |
| 10043 | default: |
| 10044 | txrom_w(space, offset, data); |
| 10045 | break; |
| 10046 | } |
| 10047 | } |
| 10048 | } |
| 10049 | |
| 10050 | |
| 10051 | /************************************************************* |
| 10052 | |
| 9979 | 10053 | Board BMC-64IN1NOREPEAT |
| 9980 | 10054 | |
| 9981 | 10055 | Games: 64-in-1 Y2K |
| r8375 | r8376 | |
| 11731 | 11805 | |
| 11732 | 11806 | static WRITE8_HANDLER( dummy_l_w ) |
| 11733 | 11807 | { |
| 11734 | | logerror("write access, offset: %04x, data: %02x\n", offset + 0x8000, data); |
| 11808 | logerror("write access, offset: %04x, data: %02x\n", offset + 0x4100, data); |
| 11735 | 11809 | } |
| 11736 | 11810 | |
| 11737 | 11811 | static WRITE8_HANDLER( dummy_m_w ) |
| r8375 | r8376 | |
| 11741 | 11815 | |
| 11742 | 11816 | static WRITE8_HANDLER( dummy_w ) |
| 11743 | 11817 | { |
| 11744 | | logerror("write access, offset: %04x, data: %02x\n", offset + 0x4100, data); |
| 11818 | logerror("write access, offset: %04x, data: %02x\n", offset + 0x8000, data); |
| 11745 | 11819 | } |
| 11746 | 11820 | |
| 11747 | 11821 | static READ8_HANDLER( dummy_l_r ) |
| 11748 | 11822 | { |
| 11749 | | logerror("read access, offset: %04x\n", offset + 0x8000); |
| 11823 | logerror("read access, offset: %04x\n", offset + 0x4100); |
| 11750 | 11824 | return 0x00; |
| 11751 | 11825 | } |
| 11752 | 11826 | |
| r8375 | r8376 | |
| 11758 | 11832 | |
| 11759 | 11833 | static READ8_HANDLER( dummy_r ) |
| 11760 | 11834 | { |
| 11761 | | logerror("read access, offset: %04x\n", offset + 0x4100); |
| 11835 | logerror("read access, offset: %04x\n", offset + 0x8000); |
| 11762 | 11836 | return 0x00; |
| 11763 | 11837 | } |
| 11764 | 11838 | |
| r8375 | r8376 | |
| 11896 | 11970 | { REXSOFT_DBZ5, {rex_dbz_l_w, rex_dbz_l_r}, NES_NOACCESS, NES_WRITEONLY(rex_dbz_w), NULL, NULL, mmc3_irq }, |
| 11897 | 11971 | { REXSOFT_SL1632, NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(rex_sl1632_w), NULL, NULL, mmc3_irq }, |
| 11898 | 11972 | { RUMBLESTATION_BOARD, NES_NOACCESS, NES_WRITEONLY(rumblestation_m_w), NES_WRITEONLY(rumblestation_w), NULL, NULL, NULL }, |
| 11899 | | { SUPERGAME_BOOGERMAN, NES_WRITEONLY(sgame_boog_l_w), NES_NOACCESS, NES_WRITEONLY(sgame_boog_w), NULL, NULL, mmc3_irq }, |
| 11973 | { SUPERGAME_BOOGERMAN, NES_WRITEONLY(sgame_boog_l_w), NES_WRITEONLY(sgame_boog_m_w), NES_WRITEONLY(sgame_boog_w), NULL, NULL, mmc3_irq }, |
| 11900 | 11974 | { SUPERGAME_LIONKING, NES_NOACCESS, NES_WRITEONLY(sgame_lion_m_w), NES_WRITEONLY(sgame_lion_w), NULL, NULL, mmc3_irq }, |
| 11901 | 11975 | { TENGEN_800008, NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(tengen_800008_w), NULL, NULL, NULL }, |
| 11902 | 11976 | { TENGEN_800032, NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(tengen_800032_w), NULL, NULL, tengen_800032_irq }, |
| r8375 | r8376 | |
| 11992 | 12066 | { BMC_G63IN1, NES_NOACCESS, NES_NOACCESS, {bmc_gb63_w, bmc_gb63_r}, NULL, NULL, NULL }, |
| 11993 | 12067 | { UNL_EDU2K, NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(edu2k_w), NULL, NULL, NULL }, |
| 11994 | 12068 | { UNL_SHJY3, NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(shjy3_w), NULL, NULL, shjy3_irq }, |
| 12069 | { BMC_FK23C, NES_WRITEONLY(fk23c_l_w), NES_NOACCESS, NES_WRITEONLY(fk23c_w), NULL, NULL, mmc3_irq }, |
| 12070 | { BMC_FK23CA, NES_WRITEONLY(fk23c_l_w), NES_NOACCESS, NES_WRITEONLY(fk23c_w), NULL, NULL, mmc3_irq }, |
| 11995 | 12071 | // |
| 11996 | 12072 | { FFE_MAPPER6, NES_WRITEONLY(mapper6_l_w), NES_NOACCESS, NES_WRITEONLY(mapper6_w), NULL, NULL, ffe_irq }, |
| 11997 | 12073 | { FFE_MAPPER8, NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(mapper8_w), NULL, NULL, NULL }, |
| r8375 | r8376 | |
| 12065 | 12141 | if (intf == NULL) |
| 12066 | 12142 | fatalerror("Missing PCB interface\n"); |
| 12067 | 12143 | |
| 12068 | | // state->mmc3_chr_cb = chr1_x; |
| 12069 | | // state->mmc3_prg_cb = prg8_x; |
| 12070 | | |
| 12071 | 12144 | if (intf) |
| 12072 | 12145 | { |
| 12073 | 12146 | state->mmc_write_low = intf->mmc_l.write; |
| r8375 | r8376 | |
| 12089 | 12162 | state->mmc_read = NULL; // in progress |
| 12090 | 12163 | ppu_latch = NULL; |
| 12091 | 12164 | } |
| 12165 | |
| 12166 | state->mmc3_prg_cb = prg8_x; |
| 12167 | state->mmc3_chr_cb = chr1_x; |
| 12168 | |
| 12169 | switch (state->pcb_id) |
| 12170 | { |
| 12171 | case SUPERGAME_BOOGERMAN: |
| 12172 | state->mmc3_prg_cb = sgame_boog_prg_cb; |
| 12173 | state->mmc3_chr_cb = sgame_boog_chr_cb; |
| 12174 | break; |
| 12175 | case UNL_KOF96: |
| 12176 | state->mmc3_prg_cb = kof96_prg_cb; |
| 12177 | state->mmc3_chr_cb = kof96_chr_cb; |
| 12178 | break; |
| 12179 | case BMC_FK23C: |
| 12180 | state->mmc3_prg_cb = fk23c_prg_cb; |
| 12181 | state->mmc3_chr_cb = fk23c_chr_cb; |
| 12182 | break; |
| 12183 | } |
| 12092 | 12184 | } |
| 12093 | 12185 | |