src/mess/machine/nes_pcb.c
| r8383 | r8384 | |
| 1023 | 1023 | |
| 1024 | 1024 | if (data & 0x80) |
| 1025 | 1025 | { |
| 1026 | | state->mmc_count = 0; |
| 1027 | | state->mmc_latch1 = 0; |
| 1026 | state->mmc1_count = 0; |
| 1027 | state->mmc1_latch = 0; |
| 1028 | 1028 | |
| 1029 | 1029 | /* Set reg at 0x8000 to size 16k and lower half swap - needed for Robocop 3, Dynowars */ |
| 1030 | 1030 | state->mmc_reg[0] |= 0x0c; |
| r8383 | r8384 | |
| 1032 | 1032 | return; |
| 1033 | 1033 | } |
| 1034 | 1034 | |
| 1035 | | if (state->mmc_count < 5) |
| 1035 | if (state->mmc1_count < 5) |
| 1036 | 1036 | { |
| 1037 | | if (state->mmc_count == 0) state->mmc_latch1 = 0; |
| 1038 | | state->mmc_latch1 >>= 1; |
| 1039 | | state->mmc_latch1 |= (data & 0x01) ? 0x10 : 0x00; |
| 1040 | | state->mmc_count++; |
| 1037 | if (state->mmc1_count == 0) state->mmc1_latch = 0; |
| 1038 | state->mmc1_latch >>= 1; |
| 1039 | state->mmc1_latch |= (data & 0x01) ? 0x10 : 0x00; |
| 1040 | state->mmc1_count++; |
| 1041 | 1041 | } |
| 1042 | 1042 | |
| 1043 | | if (state->mmc_count == 5) |
| 1043 | if (state->mmc1_count == 5) |
| 1044 | 1044 | { |
| 1045 | 1045 | switch (offset & 0x6000) /* Which reg shall we write to? */ |
| 1046 | 1046 | { |
| 1047 | 1047 | case 0x0000: |
| 1048 | | state->mmc_reg[0] = state->mmc_latch1; |
| 1048 | state->mmc_reg[0] = state->mmc1_latch; |
| 1049 | 1049 | |
| 1050 | 1050 | switch (state->mmc_reg[0] & 0x03) |
| 1051 | 1051 | { |
| r8383 | r8384 | |
| 1058 | 1058 | mmc1_set_prg_wram(space, board); |
| 1059 | 1059 | break; |
| 1060 | 1060 | case 0x2000: |
| 1061 | | state->mmc_reg[1] = state->mmc_latch1; |
| 1061 | state->mmc_reg[1] = state->mmc1_latch; |
| 1062 | 1062 | mmc1_set_chr(machine); |
| 1063 | 1063 | mmc1_set_prg_wram(space, board); |
| 1064 | 1064 | break; |
| 1065 | 1065 | case 0x4000: |
| 1066 | | state->mmc_reg[2] = state->mmc_latch1; |
| 1066 | state->mmc_reg[2] = state->mmc1_latch; |
| 1067 | 1067 | mmc1_set_chr(machine); |
| 1068 | 1068 | break; |
| 1069 | 1069 | case 0x6000: |
| 1070 | | state->mmc_reg[3] = state->mmc_latch1; |
| 1070 | state->mmc_reg[3] = state->mmc1_latch; |
| 1071 | 1071 | mmc1_set_prg_wram(space, board); |
| 1072 | 1072 | break; |
| 1073 | 1073 | } |
| 1074 | | |
| 1075 | | state->mmc_count = 0; |
| 1074 | state->mmc1_count = 0; |
| 1076 | 1075 | } |
| 1077 | 1076 | } |
| 1078 | 1077 | |
| r8383 | r8384 | |
| 1101 | 1100 | nes_state *state = (nes_state *)device->machine->driver_data; |
| 1102 | 1101 | if ((offset & 0x3ff0) == 0x0fd0) |
| 1103 | 1102 | { |
| 1104 | | LOG_MMC(("mmc2 vrom latch switch (bank 0 low): %02x\n", state->MMC2_regs[0])); |
| 1103 | LOG_MMC(("mmc2 vrom latch switch (bank 0 low): %02x\n", state->mmc_reg[0])); |
| 1105 | 1104 | state->mmc_latch1 = 0xfd; |
| 1106 | | chr4_0(device->machine, state->MMC2_regs[0], CHRROM); |
| 1105 | chr4_0(device->machine, state->mmc_reg[0], CHRROM); |
| 1107 | 1106 | } |
| 1108 | 1107 | else if ((offset & 0x3ff0) == 0x0fe0) |
| 1109 | 1108 | { |
| 1110 | | LOG_MMC(("mmc2 vrom latch switch (bank 0 high): %02x\n", state->MMC2_regs[1])); |
| 1109 | LOG_MMC(("mmc2 vrom latch switch (bank 0 high): %02x\n", state->mmc_reg[1])); |
| 1111 | 1110 | state->mmc_latch1 = 0xfe; |
| 1112 | | chr4_0(device->machine, state->MMC2_regs[1], CHRROM); |
| 1111 | chr4_0(device->machine, state->mmc_reg[1], CHRROM); |
| 1113 | 1112 | } |
| 1114 | 1113 | else if ((offset & 0x3ff0) == 0x1fd0) |
| 1115 | 1114 | { |
| 1116 | | LOG_MMC(("mmc2 vrom latch switch (bank 1 low): %02x\n", state->MMC2_regs[2])); |
| 1115 | LOG_MMC(("mmc2 vrom latch switch (bank 1 low): %02x\n", state->mmc_reg[2])); |
| 1117 | 1116 | state->mmc_latch2 = 0xfd; |
| 1118 | | chr4_4(device->machine, state->MMC2_regs[2], CHRROM); |
| 1117 | chr4_4(device->machine, state->mmc_reg[2], CHRROM); |
| 1119 | 1118 | } |
| 1120 | 1119 | else if ((offset & 0x3ff0) == 0x1fe0) |
| 1121 | 1120 | { |
| 1122 | | LOG_MMC(("mmc2 vrom latch switch (bank 0 high): %02x\n", state->MMC2_regs[3])); |
| 1121 | LOG_MMC(("mmc2 vrom latch switch (bank 0 high): %02x\n", state->mmc_reg[3])); |
| 1123 | 1122 | state->mmc_latch2 = 0xfe; |
| 1124 | | chr4_4(device->machine, state->MMC2_regs[3], CHRROM); |
| 1123 | chr4_4(device->machine, state->mmc_reg[3], CHRROM); |
| 1125 | 1124 | } |
| 1126 | 1125 | } |
| 1127 | 1126 | |
| r8383 | r8384 | |
| 1135 | 1134 | prg8_89(space->machine, data); |
| 1136 | 1135 | break; |
| 1137 | 1136 | case 0x3000: |
| 1138 | | state->MMC2_regs[0] = data; |
| 1137 | state->mmc_reg[0] = data; |
| 1139 | 1138 | if (state->mmc_latch1 == 0xfd) |
| 1140 | | chr4_0(space->machine, state->MMC2_regs[0], CHRROM); |
| 1139 | chr4_0(space->machine, state->mmc_reg[0], CHRROM); |
| 1141 | 1140 | break; |
| 1142 | 1141 | case 0x4000: |
| 1143 | | state->MMC2_regs[1] = data; |
| 1142 | state->mmc_reg[1] = data; |
| 1144 | 1143 | if (state->mmc_latch1 == 0xfe) |
| 1145 | | chr4_0(space->machine, state->MMC2_regs[1], CHRROM); |
| 1144 | chr4_0(space->machine, state->mmc_reg[1], CHRROM); |
| 1146 | 1145 | break; |
| 1147 | 1146 | case 0x5000: |
| 1148 | | state->MMC2_regs[2] = data; |
| 1147 | state->mmc_reg[2] = data; |
| 1149 | 1148 | if (state->mmc_latch2 == 0xfd) |
| 1150 | | chr4_4(space->machine, state->MMC2_regs[2], CHRROM); |
| 1149 | chr4_4(space->machine, state->mmc_reg[2], CHRROM); |
| 1151 | 1150 | break; |
| 1152 | 1151 | case 0x6000: |
| 1153 | | state->MMC2_regs[3] = data; |
| 1152 | state->mmc_reg[3] = data; |
| 1154 | 1153 | if (state->mmc_latch2 == 0xfe) |
| 1155 | | chr4_4(space->machine, state->MMC2_regs[3], CHRROM); |
| 1154 | chr4_4(space->machine, state->mmc_reg[3], CHRROM); |
| 1156 | 1155 | break; |
| 1157 | 1156 | case 0x7000: |
| 1158 | 1157 | set_nt_mirroring(space->machine, BIT(data, 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); |
| r8383 | r8384 | |
| 1206 | 1205 | if (state->mmc_write_mid != NULL) |
| 1207 | 1206 | return; |
| 1208 | 1207 | |
| 1209 | | if (BIT(state->mmc_latch2, 7)) |
| 1208 | if (BIT(state->mmc3_wram_protect, 7)) |
| 1210 | 1209 | memory_install_readwrite_bank(space, 0x6000, 0x7fff, 0, 0, "bank5"); |
| 1211 | 1210 | else |
| 1212 | 1211 | { |
| r8383 | r8384 | |
| 1214 | 1213 | return; |
| 1215 | 1214 | } |
| 1216 | 1215 | |
| 1217 | | if (!BIT(state->mmc_latch2, 6)) |
| 1216 | if (!BIT(state->mmc3_wram_protect, 6)) |
| 1218 | 1217 | memory_install_write_bank(space, 0x6000, 0x7fff, 0, 0, "bank5"); |
| 1219 | 1218 | else |
| 1220 | 1219 | { |
| r8383 | r8384 | |
| 1226 | 1225 | static void mmc3_set_prg( running_machine *machine, int prg_base, int prg_mask ) |
| 1227 | 1226 | { |
| 1228 | 1227 | nes_state *state = (nes_state *)machine->driver_data; |
| 1229 | | UINT8 prg_flip = (state->mmc_latch1 & 0x40) ? 2 : 0; |
| 1228 | UINT8 prg_flip = (state->mmc3_latch & 0x40) ? 2 : 0; |
| 1230 | 1229 | |
| 1231 | 1230 | state->mmc3_prg_cb(machine, 0, prg_base | (state->mmc_prg_bank[0 ^ prg_flip] & prg_mask)); |
| 1232 | 1231 | state->mmc3_prg_cb(machine, 1, prg_base | (state->mmc_prg_bank[1] & prg_mask)); |
| r8383 | r8384 | |
| 1237 | 1236 | static void mmc3_set_chr( running_machine *machine, UINT8 chr, int chr_base, int chr_mask ) |
| 1238 | 1237 | { |
| 1239 | 1238 | nes_state *state = (nes_state *)machine->driver_data; |
| 1240 | | UINT8 chr_page = (state->mmc_latch1 & 0x80) >> 5; |
| 1239 | UINT8 chr_page = (state->mmc3_latch & 0x80) >> 5; |
| 1241 | 1240 | |
| 1242 | 1241 | state->mmc3_chr_cb(machine, chr_page ^ 0, chr_base | ((state->mmc_vrom_bank[0] & ~0x01) & chr_mask), chr); |
| 1243 | 1242 | state->mmc3_chr_cb(machine, chr_page ^ 1, chr_base | ((state->mmc_vrom_bank[0] | 0x01) & chr_mask), chr); |
| r8383 | r8384 | |
| 1275 | 1274 | static WRITE8_HANDLER( txrom_w ) |
| 1276 | 1275 | { |
| 1277 | 1276 | nes_state *state = (nes_state *)space->machine->driver_data; |
| 1278 | | UINT8 mmc3_helper, cmd; |
| 1277 | UINT8 mmc_helper, cmd; |
| 1279 | 1278 | |
| 1280 | 1279 | LOG_MMC(("txrom_w, offset: %04x, data: %02x\n", offset, data)); |
| 1281 | 1280 | |
| 1282 | 1281 | switch (offset & 0x6001) |
| 1283 | 1282 | { |
| 1284 | 1283 | case 0x0000: |
| 1285 | | mmc3_helper = state->mmc_latch1 ^ data; |
| 1286 | | state->mmc_latch1 = data; |
| 1284 | mmc_helper = state->mmc3_latch ^ data; |
| 1285 | state->mmc3_latch = data; |
| 1287 | 1286 | |
| 1288 | 1287 | /* Has PRG Mode changed? */ |
| 1289 | | if (mmc3_helper & 0x40) |
| 1288 | if (mmc_helper & 0x40) |
| 1290 | 1289 | mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask); |
| 1291 | 1290 | |
| 1292 | 1291 | /* Has CHR Mode changed? */ |
| 1293 | | if (mmc3_helper & 0x80) |
| 1292 | if (mmc_helper & 0x80) |
| 1294 | 1293 | mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask); |
| 1295 | 1294 | break; |
| 1296 | 1295 | |
| 1297 | 1296 | case 0x0001: |
| 1298 | | cmd = state->mmc_latch1 & 0x07; |
| 1297 | cmd = state->mmc3_latch & 0x07; |
| 1299 | 1298 | switch (cmd) |
| 1300 | 1299 | { |
| 1301 | 1300 | case 0: case 1: // these do not need to be separated: we take care of them in set_chr! |
| r8383 | r8384 | |
| 1316 | 1315 | break; |
| 1317 | 1316 | |
| 1318 | 1317 | case 0x2001: |
| 1319 | | state->mmc_latch2 = data; |
| 1318 | state->mmc3_wram_protect = data; |
| 1320 | 1319 | mmc3_set_wram(space); |
| 1321 | 1320 | break; |
| 1322 | 1321 | |
| r8383 | r8384 | |
| 1400 | 1399 | switch (offset & 0x6001) |
| 1401 | 1400 | { |
| 1402 | 1401 | case 0x0000: |
| 1403 | | mmc6_helper = state->mmc_latch1 ^ data; |
| 1404 | | state->mmc_latch1 = data; |
| 1402 | mmc6_helper = state->mmc3_latch ^ data; |
| 1403 | state->mmc3_latch = data; |
| 1405 | 1404 | |
| 1406 | 1405 | if (!state->mmc_latch2 && BIT(data, 5)) // if WRAM is disabled and has to be enabled, write |
| 1407 | 1406 | state->mmc_latch2 = BIT(data, 5); // (once WRAM has been enabled, it cannot be disabled without resetting the game) |
| r8383 | r8384 | |
| 1447 | 1446 | static void txsrom_set_mirror( running_machine *machine ) |
| 1448 | 1447 | { |
| 1449 | 1448 | nes_state *state = (nes_state *)machine->driver_data; |
| 1450 | | if (state->mmc_latch1 & 0x80) |
| 1449 | if (state->mmc3_latch & 0x80) |
| 1451 | 1450 | { |
| 1452 | 1451 | set_nt_page(machine, 0, CIRAM, (state->mmc_vrom_bank[2] & 0x80) >> 7, 1); |
| 1453 | 1452 | set_nt_page(machine, 1, CIRAM, (state->mmc_vrom_bank[3] & 0x80) >> 7, 1); |
| r8383 | r8384 | |
| 1463 | 1462 | } |
| 1464 | 1463 | } |
| 1465 | 1464 | |
| 1466 | | static WRITE8_HANDLER( txsrom_w ) |
| 1465 | static void txsrom_chr_cb( running_machine *machine, int start, int bank, int source ) |
| 1467 | 1466 | { |
| 1468 | | nes_state *state = (nes_state *)space->machine->driver_data; |
| 1469 | | UINT8 MMC3_helper, cmd; |
| 1470 | | LOG_MMC(("mapper118_w, offset: %04x, data: %02x\n", offset, data)); |
| 1467 | txsrom_set_mirror(machine); // we could probably update only for one (e.g. the first) call, to slightly optimize the code |
| 1468 | chr1_x(machine, start, bank, source); |
| 1469 | } |
| 1471 | 1470 | |
| 1471 | static WRITE8_HANDLER( txsrom_w ) |
| 1472 | { |
| 1473 | LOG_MMC(("txsrom_w, offset: %04x, data: %02x\n", offset, data)); |
| 1474 | |
| 1472 | 1475 | switch (offset & 0x6001) |
| 1473 | 1476 | { |
| 1474 | | case 0x0000: |
| 1475 | | MMC3_helper = state->mmc_latch1 ^ data; |
| 1476 | | state->mmc_latch1 = data; |
| 1477 | | |
| 1478 | | /* Has PRG Mode changed? */ |
| 1479 | | if (MMC3_helper & 0x40) |
| 1480 | | mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask); |
| 1481 | | |
| 1482 | | /* Has CHR Mode changed? */ |
| 1483 | | if (MMC3_helper & 0x80) |
| 1484 | | { |
| 1485 | | txsrom_set_mirror(space->machine); |
| 1486 | | mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask); |
| 1487 | | } |
| 1488 | | break; |
| 1489 | | |
| 1490 | | case 0x0001: |
| 1491 | | cmd = state->mmc_latch1 & 0x07; |
| 1492 | | switch (cmd) |
| 1493 | | { |
| 1494 | | case 0: case 1: |
| 1495 | | case 2: case 3: case 4: case 5: |
| 1496 | | state->mmc_vrom_bank[cmd] = data; |
| 1497 | | txsrom_set_mirror(space->machine); |
| 1498 | | mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask); |
| 1499 | | break; |
| 1500 | | case 6: |
| 1501 | | case 7: |
| 1502 | | state->mmc_prg_bank[cmd - 6] = data; |
| 1503 | | mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask); |
| 1504 | | break; |
| 1505 | | } |
| 1506 | | break; |
| 1507 | | |
| 1508 | 1477 | case 0x2000: |
| 1509 | 1478 | break; |
| 1510 | | |
| 1479 | |
| 1511 | 1480 | default: |
| 1512 | 1481 | txrom_w(space, offset, data); |
| 1513 | 1482 | break; |
| r8383 | r8384 | |
| 1529 | 1498 | static void tqrom_set_chr( running_machine *machine ) |
| 1530 | 1499 | { |
| 1531 | 1500 | nes_state *state = (nes_state *)machine->driver_data; |
| 1532 | | UINT8 chr_page = (state->mmc_latch1 & 0x80) >> 5; |
| 1501 | UINT8 chr_page = (state->mmc3_latch & 0x80) >> 5; |
| 1533 | 1502 | UINT8 chr_src[6], chr_mask[6]; |
| 1534 | 1503 | int i; |
| 1535 | 1504 | |
| r8383 | r8384 | |
| 1552 | 1521 | static WRITE8_HANDLER( tqrom_w ) |
| 1553 | 1522 | { |
| 1554 | 1523 | nes_state *state = (nes_state *)space->machine->driver_data; |
| 1555 | | UINT8 MMC3_helper, cmd; |
| 1556 | | LOG_MMC(("mapper119_w, offset: %04x, data: %02x\n", offset, data)); |
| 1524 | UINT8 mmc_helper, cmd; |
| 1525 | LOG_MMC(("tqrom_w, offset: %04x, data: %02x\n", offset, data)); |
| 1557 | 1526 | |
| 1558 | 1527 | switch (offset & 0x6001) |
| 1559 | 1528 | { |
| 1560 | 1529 | case 0x0000: |
| 1561 | | MMC3_helper = state->mmc_latch1 ^ data; |
| 1562 | | state->mmc_latch1 = data; |
| 1530 | mmc_helper = state->mmc3_latch ^ data; |
| 1531 | state->mmc3_latch = data; |
| 1563 | 1532 | |
| 1564 | 1533 | /* Has PRG Mode changed? */ |
| 1565 | | if (MMC3_helper & 0x40) |
| 1534 | if (mmc_helper & 0x40) |
| 1566 | 1535 | mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask); |
| 1567 | 1536 | |
| 1568 | 1537 | /* Has CHR Mode changed? */ |
| 1569 | | if (MMC3_helper & 0x80) |
| 1538 | if (mmc_helper & 0x80) |
| 1570 | 1539 | tqrom_set_chr(space->machine); |
| 1571 | 1540 | break; |
| 1572 | 1541 | case 0x0001: /* $8001 */ |
| 1573 | | cmd = state->mmc_latch1 & 0x07; |
| 1542 | cmd = state->mmc3_latch & 0x07; |
| 1574 | 1543 | switch (cmd) |
| 1575 | 1544 | { |
| 1576 | 1545 | case 0: case 1: // these do not need to be separated: we take care of them in set_chr! |
| r8383 | r8384 | |
| 1604 | 1573 | static WRITE8_HANDLER( zz_m_w ) |
| 1605 | 1574 | { |
| 1606 | 1575 | nes_state *state = (nes_state *)space->machine->driver_data; |
| 1607 | | UINT8 map37_helper; |
| 1576 | UINT8 mmc_helper = data & 0x07; |
| 1608 | 1577 | LOG_MMC(("zz_m_w, offset: %04x, data: %02x\n", offset, data)); |
| 1609 | 1578 | |
| 1610 | | map37_helper = data & 0x07; |
| 1611 | | |
| 1612 | | state->mmc_prg_base = (BIT(map37_helper, 2) << 4) | (((map37_helper & 0x03) == 0x03) ? 0x08 : 0); |
| 1613 | | state->mmc_prg_mask = (map37_helper << 1) | 0x07; |
| 1614 | | state->mmc_chr_base = BIT(map37_helper, 2) << 7; |
| 1579 | state->mmc_prg_base = (BIT(mmc_helper, 2) << 4) | (((mmc_helper & 0x03) == 0x03) ? 0x08 : 0); |
| 1580 | state->mmc_prg_mask = (mmc_helper << 1) | 0x07; |
| 1581 | state->mmc_chr_base = BIT(mmc_helper, 2) << 7; |
| 1615 | 1582 | state->mmc_chr_mask = 0x7f; |
| 1616 | 1583 | mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask); |
| 1617 | 1584 | mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask); |
| r8383 | r8384 | |
| 5092 | 5059 | LOG_MMC(("gouder_sf4_l_w, offset: %04x, data: %02x\n", offset, data)); |
| 5093 | 5060 | |
| 5094 | 5061 | if (!(offset < 0x1700)) |
| 5095 | | state->map208_reg[offset & 0x03] = data ^ conv_table[state->map208_reg[4]]; |
| 5062 | state->mmc_reg[offset & 0x03] = data ^ conv_table[state->mmc_reg[4]]; |
| 5096 | 5063 | else if (!(offset < 0xf00)) |
| 5097 | | state->map208_reg[4] = data; |
| 5064 | state->mmc_reg[4] = data; |
| 5098 | 5065 | else if (!(offset < 0x700)) |
| 5099 | 5066 | prg32(space->machine, ((data >> 3) & 0x02) | (data & 0x01)); |
| 5100 | 5067 | } |
| r8383 | r8384 | |
| 5105 | 5072 | LOG_MMC(("gouder_sf4_l_r, offset: %04x\n", offset)); |
| 5106 | 5073 | |
| 5107 | 5074 | if (!(offset < 0x1700)) |
| 5108 | | return state->map208_reg[offset & 0x03]; |
| 5075 | return state->mmc_reg[offset & 0x03]; |
| 5109 | 5076 | |
| 5110 | 5077 | return 0x00; |
| 5111 | 5078 | } |
| 5112 | 5079 | |
| 5113 | | /* This is like mmc3 but with no PRG bankswitch (beacuse it is handled by low writes) */ |
| 5114 | | // replace with map189_w... they are the same!! |
| 5115 | | static WRITE8_HANDLER( gouder_sf4_w ) |
| 5080 | /* writes to 0x8000-0xffff are like MMC3 but no PRG bankswitch (beacuse it is handled by low writes) */ |
| 5081 | static void gouder_sf4_prg_cb( running_machine *machine, int start, int bank ) |
| 5116 | 5082 | { |
| 5117 | | nes_state *state = (nes_state *)space->machine->driver_data; |
| 5118 | | UINT8 MMC3_helper, cmd; |
| 5119 | | LOG_MMC(("gouder_sf4_w, offset: %04x, data: %02x\n", offset, data)); |
| 5120 | | |
| 5121 | | switch (offset & 0x6001) |
| 5122 | | { |
| 5123 | | case 0x0000: |
| 5124 | | MMC3_helper = state->mmc_latch1 ^ data; |
| 5125 | | state->mmc_latch1 = data; |
| 5126 | | |
| 5127 | | /* Has CHR Mode changed? */ |
| 5128 | | if (MMC3_helper & 0x80) |
| 5129 | | mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask); |
| 5130 | | break; |
| 5131 | | |
| 5132 | | case 0x0001: |
| 5133 | | cmd = state->mmc_latch1 & 0x07; |
| 5134 | | switch (cmd) |
| 5135 | | { |
| 5136 | | case 0: case 1: |
| 5137 | | case 2: case 3: case 4: case 5: |
| 5138 | | state->mmc_vrom_bank[cmd] = data; |
| 5139 | | mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask); |
| 5140 | | break; |
| 5141 | | } |
| 5142 | | break; |
| 5143 | | |
| 5144 | | default: |
| 5145 | | txrom_w(space, offset, data); |
| 5146 | | break; |
| 5147 | | } |
| 5083 | return; |
| 5148 | 5084 | } |
| 5149 | 5085 | |
| 5086 | |
| 5150 | 5087 | /************************************************************* |
| 5151 | 5088 | |
| 5152 | 5089 | Bootleg Board by Henggedianzi |
| r8383 | r8384 | |
| 5682 | 5619 | static void kay_pp_chr_cb( running_machine *machine, int start, int bank, int source ) |
| 5683 | 5620 | { |
| 5684 | 5621 | nes_state *state = (nes_state *)machine->driver_data; |
| 5685 | | UINT8 chr_page = (state->mmc_latch1 & 0x80) >> 5; |
| 5622 | UINT8 chr_page = (state->mmc3_latch & 0x80) >> 5; |
| 5686 | 5623 | |
| 5687 | 5624 | if ((start & 0x04) == chr_page) |
| 5688 | 5625 | bank |= 0x100; |
| r8383 | r8384 | |
| 5739 | 5676 | |
| 5740 | 5677 | *************************************************************/ |
| 5741 | 5678 | |
| 5742 | | static void kasing_set_prg( running_machine *machine, int prg_base, int prg_mask ) |
| 5679 | static void kasing_prg_cb( running_machine *machine, int start, int bank ) |
| 5743 | 5680 | { |
| 5744 | 5681 | nes_state *state = (nes_state *)machine->driver_data; |
| 5745 | | if (state->mapper115_reg[0] & 0x80) |
| 5746 | | prg32(machine, state->mapper115_reg[0] >> 1); |
| 5682 | if (BIT(state->mmc_reg[0], 7)) |
| 5683 | prg32(machine, state->mmc_reg[0] >> 1); |
| 5747 | 5684 | else |
| 5748 | | mmc3_set_prg(machine, prg_base, prg_mask); |
| 5685 | prg8_x(machine, start, bank); |
| 5749 | 5686 | } |
| 5750 | | |
| 5687 | |
| 5751 | 5688 | static WRITE8_HANDLER( kasing_m_w ) |
| 5752 | 5689 | { |
| 5753 | 5690 | nes_state *state = (nes_state *)space->machine->driver_data; |
| 5754 | 5691 | LOG_MMC(("kasing_m_w, offset: %04x, data: %02x\n", offset, data)); |
| 5755 | | |
| 5692 | |
| 5756 | 5693 | switch (offset & 0x01) |
| 5757 | 5694 | { |
| 5758 | 5695 | case 0x00: |
| 5759 | | state->mapper115_reg[0] = data; |
| 5760 | | kasing_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask); |
| 5696 | state->mmc_reg[0] = data; |
| 5697 | mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask); |
| 5761 | 5698 | break; |
| 5762 | 5699 | case 0x01: |
| 5763 | 5700 | state->mmc_chr_base = (data & 0x01) ? 0x100 : 0x000; |
| r8383 | r8384 | |
| 5766 | 5703 | } |
| 5767 | 5704 | } |
| 5768 | 5705 | |
| 5769 | | static WRITE8_HANDLER( kasing_w ) |
| 5770 | | { |
| 5771 | | nes_state *state = (nes_state *)space->machine->driver_data; |
| 5772 | | UINT8 map115_helper, cmd; |
| 5773 | | LOG_MMC(("kasing_w, offset: %04x, data: %02x\n", offset, data)); |
| 5774 | | |
| 5775 | | switch (offset & 0x6001) |
| 5776 | | { |
| 5777 | | case 0x0000: |
| 5778 | | map115_helper = state->mmc_latch1 ^ data; |
| 5779 | | state->mmc_latch1 = data; |
| 5780 | | |
| 5781 | | /* Has PRG Mode changed? */ |
| 5782 | | if (map115_helper & 0x40) |
| 5783 | | kasing_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask); |
| 5784 | | |
| 5785 | | /* Has CHR Mode changed? */ |
| 5786 | | if (map115_helper & 0x80) |
| 5787 | | mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask); |
| 5788 | | break; |
| 5789 | | |
| 5790 | | case 0x0001: |
| 5791 | | cmd = state->mmc_latch1 & 0x07; |
| 5792 | | switch (cmd) |
| 5793 | | { |
| 5794 | | case 0: case 1: // these do not need to be separated: we take care of them in set_chr! |
| 5795 | | case 2: case 3: case 4: case 5: |
| 5796 | | state->mmc_vrom_bank[cmd] = data; |
| 5797 | | mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask); |
| 5798 | | break; |
| 5799 | | case 6: |
| 5800 | | case 7: |
| 5801 | | state->mmc_prg_bank[cmd - 6] = data; |
| 5802 | | kasing_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask); |
| 5803 | | break; |
| 5804 | | } |
| 5805 | | break; |
| 5806 | | |
| 5807 | | default: |
| 5808 | | txrom_w(space, offset, data); |
| 5809 | | break; |
| 5810 | | } |
| 5811 | | } |
| 5812 | | |
| 5813 | 5706 | /************************************************************* |
| 5814 | 5707 | |
| 5815 | 5708 | Bootleg Board by Magic Series |
| r8383 | r8384 | |
| 6178 | 6071 | |
| 6179 | 6072 | iNES: mapper 12 |
| 6180 | 6073 | |
| 6181 | | In MESS: Partially Supported |
| 6074 | In MESS: Supported |
| 6182 | 6075 | |
| 6183 | 6076 | *************************************************************/ |
| 6184 | 6077 | |
| 6185 | 6078 | static WRITE8_HANDLER( rex_dbz_l_w ) |
| 6186 | 6079 | { |
| 6187 | 6080 | nes_state *state = (nes_state *)space->machine->driver_data; |
| 6188 | | |
| 6189 | 6081 | LOG_MMC(("rex_dbz_l_w, offset: %04x, data: %02x\n", offset, data)); |
| 6190 | 6082 | |
| 6191 | | state->mapper12_reg = data; |
| 6083 | state->mmc_reg[0] = data; |
| 6084 | mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask); |
| 6192 | 6085 | } |
| 6193 | 6086 | |
| 6194 | 6087 | /* we would need to use this read handler in 0x6000-0x7fff as well */ |
| r8383 | r8384 | |
| 6198 | 6091 | return 0x01; |
| 6199 | 6092 | } |
| 6200 | 6093 | |
| 6201 | | static void rex_dbz_set_chr( running_machine *machine ) |
| 6094 | static void rex_dbz_chr_cb( running_machine *machine, int start, int bank, int source ) |
| 6202 | 6095 | { |
| 6203 | 6096 | nes_state *state = (nes_state *)machine->driver_data; |
| 6204 | | UINT8 chr_page = (state->mmc_latch1 & 0x80) >> 5; |
| 6097 | int shift = (start < 4) ? 8 : 4; |
| 6205 | 6098 | |
| 6206 | | chr1_x(machine, chr_page ^ 0, ((state->mapper12_reg & 0x01) << 8) | (state->mmc_vrom_bank[0] & ~0x01), CHRROM); |
| 6207 | | chr1_x(machine, chr_page ^ 1, ((state->mapper12_reg & 0x01) << 8) | (state->mmc_vrom_bank[0] | 0x01), CHRROM); |
| 6208 | | chr1_x(machine, chr_page ^ 2, ((state->mapper12_reg & 0x01) << 8) | (state->mmc_vrom_bank[1] & ~0x01), CHRROM); |
| 6209 | | chr1_x(machine, chr_page ^ 3, ((state->mapper12_reg & 0x01) << 8) | (state->mmc_vrom_bank[1] | 0x01), CHRROM); |
| 6210 | | chr1_x(machine, chr_page ^ 4, ((state->mapper12_reg & 0x10) << 4) | state->mmc_vrom_bank[2], CHRROM); |
| 6211 | | chr1_x(machine, chr_page ^ 5, ((state->mapper12_reg & 0x10) << 4) | state->mmc_vrom_bank[3], CHRROM); |
| 6212 | | chr1_x(machine, chr_page ^ 6, ((state->mapper12_reg & 0x10) << 4) | state->mmc_vrom_bank[4], CHRROM); |
| 6213 | | chr1_x(machine, chr_page ^ 7, ((state->mapper12_reg & 0x10) << 4) | state->mmc_vrom_bank[5], CHRROM); |
| 6099 | bank |= ((state->mmc_reg[0] << shift) & 0x100); |
| 6100 | chr1_x(machine, start, bank, source); |
| 6214 | 6101 | } |
| 6215 | 6102 | |
| 6216 | | static WRITE8_HANDLER( rex_dbz_w ) |
| 6217 | | { |
| 6218 | | nes_state *state = (nes_state *)space->machine->driver_data; |
| 6219 | | UINT8 MMC3_helper, cmd; |
| 6220 | | LOG_MMC(("rex_dbz_w, offset: %04x, data: %02x\n", offset, data)); |
| 6221 | | |
| 6222 | | switch (offset & 0x6001) |
| 6223 | | { |
| 6224 | | case 0x0000: |
| 6225 | | MMC3_helper = state->mmc_latch1 ^ data; |
| 6226 | | state->mmc_latch1 = data; |
| 6227 | | |
| 6228 | | /* Has PRG Mode changed? */ |
| 6229 | | if (MMC3_helper & 0x40) |
| 6230 | | mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask); |
| 6231 | | |
| 6232 | | /* Has CHR Mode changed? */ |
| 6233 | | if (MMC3_helper & 0x80) |
| 6234 | | rex_dbz_set_chr(space->machine); |
| 6235 | | break; |
| 6236 | | |
| 6237 | | case 0x0001: |
| 6238 | | cmd = state->mmc_latch1 & 0x07; |
| 6239 | | switch (cmd) |
| 6240 | | { |
| 6241 | | case 0: case 1: // these do not need to be separated: we take care of them in set_chr! |
| 6242 | | case 2: case 3: case 4: case 5: |
| 6243 | | state->mmc_vrom_bank[cmd] = data; |
| 6244 | | rex_dbz_set_chr(space->machine); |
| 6245 | | break; |
| 6246 | | case 6: |
| 6247 | | case 7: |
| 6248 | | state->mmc_prg_bank[cmd - 6] = data; |
| 6249 | | mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask); |
| 6250 | | break; |
| 6251 | | } |
| 6252 | | break; |
| 6253 | | |
| 6254 | | default: |
| 6255 | | txrom_w(space, offset, data); |
| 6256 | | break; |
| 6257 | | } |
| 6258 | | } |
| 6259 | | |
| 6260 | 6103 | /************************************************************* |
| 6261 | 6104 | |
| 6262 | 6105 | Rex Soft SL1632 Board |
| r8383 | r8384 | |
| 6275 | 6118 | { |
| 6276 | 6119 | nes_state *state = (nes_state *)machine->driver_data; |
| 6277 | 6120 | |
| 6278 | | if (state->map14_reg[0] & 0x02) |
| 6121 | if (state->mmc_reg[0] & 0x02) |
| 6279 | 6122 | { |
| 6280 | 6123 | mmc3_set_prg(machine, prg_base, prg_mask); |
| 6281 | 6124 | } |
| r8383 | r8384 | |
| 6292 | 6135 | { |
| 6293 | 6136 | nes_state *state = (nes_state *)machine->driver_data; |
| 6294 | 6137 | static const UINT8 conv_table[8] = {5, 5, 5, 5, 3, 3, 1, 1}; |
| 6295 | | UINT8 chr_page = (state->mmc_latch1 & 0x80) >> 5; |
| 6138 | UINT8 chr_page = (state->mmc3_latch & 0x80) >> 5; |
| 6296 | 6139 | UINT8 bank[8]; |
| 6297 | 6140 | UINT8 chr_base2[8]; |
| 6298 | 6141 | int i; |
| 6299 | 6142 | |
| 6300 | | if (state->map14_reg[0] & 0x02) |
| 6143 | if (state->mmc_reg[0] & 0x02) |
| 6301 | 6144 | { |
| 6302 | 6145 | for(i = 0; i < 8; i++) |
| 6303 | 6146 | { |
| 6304 | 6147 | bank[i] = state->mmc_vrom_bank[i]; |
| 6305 | | chr_base2[i] = chr_base | ((state->map14_reg[0] << conv_table[i]) & 0x100); |
| 6148 | chr_base2[i] = chr_base | ((state->mmc_reg[0] << conv_table[i]) & 0x100); |
| 6306 | 6149 | } |
| 6307 | 6150 | } |
| 6308 | 6151 | else |
| r8383 | r8384 | |
| 6327 | 6170 | static WRITE8_HANDLER( rex_sl1632_w ) |
| 6328 | 6171 | { |
| 6329 | 6172 | nes_state *state = (nes_state *)space->machine->driver_data; |
| 6330 | | UINT8 map14_helper1, map14_helper2, MMC3_helper, cmd; |
| 6173 | UINT8 map14_helper1, map14_helper2, mmc_helper, cmd; |
| 6331 | 6174 | LOG_MMC(("rex_sl1632_w, offset: %04x, data: %02x\n", offset, data)); |
| 6332 | 6175 | |
| 6333 | 6176 | if (offset == 0x2131) |
| 6334 | 6177 | { |
| 6335 | | state->map14_reg[0] = data; |
| 6178 | state->mmc_reg[0] = data; |
| 6336 | 6179 | rex_sl1632_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask); |
| 6337 | 6180 | rex_sl1632_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask); |
| 6338 | 6181 | |
| 6339 | | if (!(state->map14_reg[0] & 0x02)) |
| 6340 | | set_nt_mirroring(space->machine, BIT(state->map14_reg[1], 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); |
| 6182 | if (!(state->mmc_reg[0] & 0x02)) |
| 6183 | set_nt_mirroring(space->machine, BIT(state->mmc_reg[1], 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); |
| 6341 | 6184 | } |
| 6342 | 6185 | |
| 6343 | | if (state->map14_reg[0] & 0x02) |
| 6186 | if (state->mmc_reg[0] & 0x02) |
| 6344 | 6187 | { |
| 6345 | 6188 | switch (offset & 0x6001) |
| 6346 | 6189 | { |
| 6347 | 6190 | case 0x0000: |
| 6348 | | MMC3_helper = state->mmc_latch1 ^ data; |
| 6349 | | state->mmc_latch1 = data; |
| 6191 | mmc_helper = state->mmc3_latch ^ data; |
| 6192 | state->mmc3_latch = data; |
| 6350 | 6193 | |
| 6351 | 6194 | /* Has PRG Mode changed? */ |
| 6352 | | if (MMC3_helper & 0x40) |
| 6195 | if (mmc_helper & 0x40) |
| 6353 | 6196 | rex_sl1632_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask); |
| 6354 | 6197 | |
| 6355 | 6198 | /* Has CHR Mode changed? */ |
| 6356 | | if (MMC3_helper & 0x80) |
| 6199 | if (mmc_helper & 0x80) |
| 6357 | 6200 | rex_sl1632_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask); |
| 6358 | 6201 | break; |
| 6359 | 6202 | |
| 6360 | 6203 | case 0x0001: |
| 6361 | | cmd = state->mmc_latch1 & 0x07; |
| 6204 | cmd = state->mmc3_latch & 0x07; |
| 6362 | 6205 | switch (cmd) |
| 6363 | | { |
| 6206 | { |
| 6364 | 6207 | case 0: case 1: // these have to be changed due to the different way rex_sl1632_set_chr works (it handles 1k banks)! |
| 6365 | 6208 | state->mmc_vrom_bank[2 * cmd] = data; |
| 6366 | 6209 | state->mmc_vrom_bank[2 * cmd + 1] = data; |
| r8383 | r8384 | |
| 6375 | 6218 | state->mmc_prg_bank[cmd - 6] = data; |
| 6376 | 6219 | rex_sl1632_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask); |
| 6377 | 6220 | break; |
| 6378 | | } |
| 6221 | } |
| 6379 | 6222 | break; |
| 6380 | 6223 | |
| 6381 | 6224 | case 0x2000: |
| 6382 | | set_nt_mirroring(space->machine, BIT(state->map14_reg[1], 0) ? PPU_MIRROR_VERT : PPU_MIRROR_HORZ); |
| 6225 | set_nt_mirroring(space->machine, BIT(state->mmc_reg[1], 0) ? PPU_MIRROR_VERT : PPU_MIRROR_HORZ); |
| 6383 | 6226 | break; |
| 6384 | 6227 | |
| 6385 | 6228 | default: |
| r8383 | r8384 | |
| 6406 | 6249 | break; |
| 6407 | 6250 | |
| 6408 | 6251 | case 0x1000: |
| 6409 | | state->map14_reg[1] = data; |
| 6410 | | set_nt_mirroring(space->machine, BIT(state->map14_reg[1], 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); |
| 6252 | state->mmc_reg[1] = data; |
| 6253 | set_nt_mirroring(space->machine, BIT(state->mmc_reg[1], 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); |
| 6411 | 6254 | break; |
| 6412 | 6255 | } |
| 6413 | 6256 | } |
| r8383 | r8384 | |
| 6949 | 6792 | static void sgame_boog_prg_cb( running_machine *machine, int start, int bank ) |
| 6950 | 6793 | { |
| 6951 | 6794 | nes_state *state = (nes_state *)machine->driver_data; |
| 6952 | | if (!(state->map215_reg[0] & 0x80)) // if this is != 0 we should never even arrive here |
| 6795 | if (!(state->mmc_reg[0] & 0x80)) // if this is != 0 we should never even arrive here |
| 6953 | 6796 | { |
| 6954 | | if (state->map215_reg[1] & 0x08) |
| 6797 | if (state->mmc_reg[1] & 0x08) |
| 6955 | 6798 | bank = (bank & 0x1f) | 0x20; |
| 6956 | 6799 | else |
| 6957 | | bank = (bank & 0x0f) | (state->map215_reg[1] & 0x10); |
| 6800 | bank = (bank & 0x0f) | (state->mmc_reg[1] & 0x10); |
| 6958 | 6801 | |
| 6959 | 6802 | prg8_x(machine, start, bank); |
| 6960 | 6803 | } |
| r8383 | r8384 | |
| 6964 | 6807 | { |
| 6965 | 6808 | nes_state *state = (nes_state *)machine->driver_data; |
| 6966 | 6809 | |
| 6967 | | if ((state->map215_reg[1] & 0x04)) |
| 6810 | if ((state->mmc_reg[1] & 0x04)) |
| 6968 | 6811 | bank |= 0x100; |
| 6969 | 6812 | else |
| 6970 | | bank = (bank & 0x7f) | ((state->map215_reg[1] & 0x10) << 3); |
| 6813 | bank = (bank & 0x7f) | ((state->mmc_reg[1] & 0x10) << 3); |
| 6971 | 6814 | |
| 6972 | 6815 | chr1_x(machine, start, bank, source); |
| 6973 | 6816 | } |
| r8383 | r8384 | |
| 6975 | 6818 | static void sgame_boog_set_prg( running_machine *machine ) |
| 6976 | 6819 | { |
| 6977 | 6820 | nes_state *state = (nes_state *)machine->driver_data; |
| 6978 | | if (state->map215_reg[0] & 0x80) |
| 6821 | if (state->mmc_reg[0] & 0x80) |
| 6979 | 6822 | { |
| 6980 | | prg16_89ab(machine, (state->map215_reg[0] & 0xf0) | (state->map215_reg[1] & 0x10)); |
| 6981 | | prg16_cdef(machine, (state->map215_reg[0] & 0xf0) | (state->map215_reg[1] & 0x10)); |
| 6823 | prg16_89ab(machine, (state->mmc_reg[0] & 0xf0) | (state->mmc_reg[1] & 0x10)); |
| 6824 | prg16_cdef(machine, (state->mmc_reg[0] & 0xf0) | (state->mmc_reg[1] & 0x10)); |
| 6982 | 6825 | } |
| 6983 | 6826 | else |
| 6984 | 6827 | mmc3_set_prg(machine, state->mmc_prg_base, state->mmc_prg_mask); |
| r8383 | r8384 | |
| 6992 | 6835 | |
| 6993 | 6836 | if (offset == 0x1000) |
| 6994 | 6837 | { |
| 6995 | | state->map215_reg[0] = data; |
| 6838 | state->mmc_reg[0] = data; |
| 6996 | 6839 | sgame_boog_set_prg(space->machine); |
| 6997 | 6840 | } |
| 6998 | 6841 | else if (offset == 0x1001) |
| 6999 | 6842 | { |
| 7000 | | state->map215_reg[1] = data; |
| 6843 | state->mmc_reg[1] = data; |
| 7001 | 6844 | mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask); |
| 7002 | 6845 | } |
| 7003 | 6846 | else if (offset == 0x1007) |
| 7004 | 6847 | { |
| 7005 | | state->mmc_latch1 = 0; |
| 7006 | | state->map215_reg[2] = data; |
| 6848 | state->mmc3_latch = 0; |
| 6849 | state->mmc_reg[2] = data; |
| 7007 | 6850 | sgame_boog_set_prg(space->machine); |
| 7008 | 6851 | mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask); |
| 7009 | 6852 | } |
| r8383 | r8384 | |
| 7016 | 6859 | |
| 7017 | 6860 | if (offset == 0x0000) |
| 7018 | 6861 | { |
| 7019 | | state->map215_reg[0] = data; |
| 6862 | state->mmc_reg[0] = data; |
| 7020 | 6863 | sgame_boog_set_prg(space->machine); |
| 7021 | 6864 | } |
| 7022 | 6865 | else if (offset == 0x0001) |
| 7023 | 6866 | { |
| 7024 | | state->map215_reg[1] = data; |
| 6867 | state->mmc_reg[1] = data; |
| 7025 | 6868 | mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask); |
| 7026 | 6869 | } |
| 7027 | 6870 | else if (offset == 0x0007) |
| 7028 | 6871 | { |
| 7029 | | state->mmc_latch1 = 0; |
| 7030 | | state->map215_reg[2] = data; |
| 6872 | state->mmc3_latch = 0; |
| 6873 | state->mmc_reg[2] = data; |
| 7031 | 6874 | sgame_boog_set_prg(space->machine); |
| 7032 | 6875 | mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask); |
| 7033 | 6876 | } |
| r8383 | r8384 | |
| 7042 | 6885 | switch (offset & 0x6001) |
| 7043 | 6886 | { |
| 7044 | 6887 | case 0x0000: |
| 7045 | | if (!state->map215_reg[2]) |
| 6888 | if (!state->mmc_reg[2]) |
| 7046 | 6889 | txrom_w(space, 0x0000, data); |
| 7047 | 6890 | break; |
| 7048 | 6891 | |
| 7049 | 6892 | case 0x0001: |
| 7050 | | if (!state->map215_reg[2]) |
| 6893 | if (!state->mmc_reg[2]) |
| 7051 | 6894 | txrom_w(space, 0x0001, data); |
| 7052 | | 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! |
| 6895 | else if (state->mmc_reg[3] && ((state->mmc_reg[0] & 0x80) == 0 || (state->mmc_latch1 & 0x07) < 6)) // if we use the prg16 banks and cmd=6,7 DON'T enter! |
| 7053 | 6896 | { |
| 7054 | | state->map215_reg[3] = 0; |
| 6897 | state->mmc_reg[3] = 0; |
| 7055 | 6898 | txrom_w(space, 0x0001, data); |
| 7056 | 6899 | } |
| 7057 | 6900 | break; |
| 7058 | 6901 | |
| 7059 | 6902 | case 0x2000: |
| 7060 | | if (!state->map215_reg[2]) |
| 6903 | if (!state->mmc_reg[2]) |
| 7061 | 6904 | txrom_w(space, 0x2000, data); |
| 7062 | 6905 | else |
| 7063 | 6906 | { |
| 7064 | 6907 | data = (data & 0xc0) | conv_table[data & 0x07]; |
| 7065 | | state->map215_reg[3] = 1; |
| 6908 | state->mmc_reg[3] = 1; |
| 7066 | 6909 | txrom_w(space, 0x0000, data); |
| 7067 | 6910 | break; |
| 7068 | 6911 | } |
| 7069 | 6912 | break; |
| 7070 | 6913 | |
| 7071 | 6914 | case 0x4000: |
| 7072 | | if (!state->map215_reg[2]) |
| 6915 | if (!state->mmc_reg[2]) |
| 7073 | 6916 | txrom_w(space, 0x4000, data); |
| 7074 | 6917 | else |
| 7075 | 6918 | set_nt_mirroring(space->machine, ((data >> 7) | data) & 0x01 ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); |
| 7076 | 6919 | break; |
| 7077 | 6920 | |
| 7078 | 6921 | case 0x4001: |
| 7079 | | if (!state->map215_reg[2]) |
| 6922 | if (!state->mmc_reg[2]) |
| 7080 | 6923 | txrom_w(space, 0x4001, data); |
| 7081 | 6924 | else |
| 7082 | 6925 | txrom_w(space, 0x6001, data); |
| 7083 | 6926 | break; |
| 7084 | 6927 | |
| 7085 | 6928 | case 0x6001: |
| 7086 | | if (!state->map215_reg[2]) |
| 6929 | if (!state->mmc_reg[2]) |
| 7087 | 6930 | txrom_w(space, 0x6001, data); |
| 7088 | 6931 | else |
| 7089 | 6932 | { |
| r8383 | r8384 | |
| 7576 | 7419 | txc_tw_l_w(space, offset & 0xff, data); // offset does not really count for this mapper |
| 7577 | 7420 | } |
| 7578 | 7421 | |
| 7579 | | /* This is like mmc3 but with no PRG bankswitch (beacuse it is handled by low writes) */ |
| 7580 | | static WRITE8_HANDLER( txc_tw_w ) |
| 7422 | /* writes to 0x8000-0xffff are like MMC3 but no PRG bankswitch (beacuse it is handled by low writes) */ |
| 7423 | static void txc_tw_prg_cb( running_machine *machine, int start, int bank ) |
| 7581 | 7424 | { |
| 7582 | | nes_state *state = (nes_state *)space->machine->driver_data; |
| 7583 | | UINT8 MMC3_helper, cmd; |
| 7584 | | LOG_MMC(("txctw_w, offset: %04x, data: %02x\n", offset, data)); |
| 7585 | | |
| 7586 | | switch (offset & 0x6001) |
| 7587 | | { |
| 7588 | | case 0x0000: |
| 7589 | | MMC3_helper = state->mmc_latch1 ^ data; |
| 7590 | | state->mmc_latch1 = data; |
| 7591 | | |
| 7592 | | /* Has CHR Mode changed? */ |
| 7593 | | if (MMC3_helper & 0x80) |
| 7594 | | mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask); |
| 7595 | | break; |
| 7596 | | |
| 7597 | | case 0x0001: |
| 7598 | | cmd = state->mmc_latch1 & 0x07; |
| 7599 | | switch (cmd) |
| 7600 | | { |
| 7601 | | case 0: case 1: |
| 7602 | | case 2: case 3: case 4: case 5: |
| 7603 | | state->mmc_vrom_bank[cmd] = data; |
| 7604 | | mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask); |
| 7605 | | break; |
| 7606 | | } |
| 7607 | | break; |
| 7608 | | |
| 7609 | | default: |
| 7610 | | txrom_w(space, offset, data); |
| 7611 | | break; |
| 7612 | | } |
| 7425 | return; |
| 7613 | 7426 | } |
| 7614 | 7427 | |
| 7615 | 7428 | /************************************************************* |
| r8383 | r8384 | |
| 7980 | 7793 | switch (offset & 0x6001) |
| 7981 | 7794 | { |
| 7982 | 7795 | case 0x0001: |
| 7983 | | cmd = state->mmc_latch1 & 0x07; |
| 7796 | cmd = state->mmc3_latch & 0x07; |
| 7984 | 7797 | switch (cmd) |
| 7985 | 7798 | { |
| 7986 | 7799 | case 0: // in this case we set prg_base in addition to state->mmc_vrom_bank! |
| r8383 | r8384 | |
| 8366 | 8179 | { |
| 8367 | 8180 | nes_state *state = (nes_state *)machine->driver_data; |
| 8368 | 8181 | |
| 8369 | | if (!(state->unl_8237_reg[0] & 0x80)) |
| 8182 | if (!(state->mmc_reg[0] & 0x80)) |
| 8370 | 8183 | prg8_x(machine, start, bank); |
| 8371 | 8184 | } |
| 8372 | 8185 | |
| 8373 | 8186 | static void unl_8237_chr_cb( running_machine *machine, int start, int bank, int source ) |
| 8374 | 8187 | { |
| 8375 | 8188 | nes_state *state = (nes_state *)machine->driver_data; |
| 8376 | | bank |= ((state->unl_8237_reg[1] << 6) & 0x100); |
| 8189 | bank |= ((state->mmc_reg[1] << 6) & 0x100); |
| 8377 | 8190 | |
| 8378 | 8191 | chr1_x(machine, start, bank, source); |
| 8379 | 8192 | } |
| r8383 | r8384 | |
| 8386 | 8199 | |
| 8387 | 8200 | if (offset == 0x1000) |
| 8388 | 8201 | { |
| 8389 | | state->unl_8237_reg[0] = data; |
| 8390 | | if (state->unl_8237_reg[0] & 0x80) |
| 8202 | state->mmc_reg[0] = data; |
| 8203 | if (state->mmc_reg[0] & 0x80) |
| 8391 | 8204 | { |
| 8392 | | if (state->unl_8237_reg[0] & 0x20) |
| 8393 | | prg32(space->machine, (state->unl_8237_reg[0] & 0x0f) >> 1); |
| 8205 | if (state->mmc_reg[0] & 0x20) |
| 8206 | prg32(space->machine, (state->mmc_reg[0] & 0x0f) >> 1); |
| 8394 | 8207 | else |
| 8395 | 8208 | { |
| 8396 | | prg16_89ab(space->machine, state->unl_8237_reg[0] & 0x1f); |
| 8397 | | prg16_cdef(space->machine, state->unl_8237_reg[0] & 0x1f); |
| 8209 | prg16_89ab(space->machine, state->mmc_reg[0] & 0x1f); |
| 8210 | prg16_cdef(space->machine, state->mmc_reg[0] & 0x1f); |
| 8398 | 8211 | } |
| 8399 | 8212 | } |
| 8400 | 8213 | else |
| r8383 | r8384 | |
| 8403 | 8216 | |
| 8404 | 8217 | if (offset == 0x1001) |
| 8405 | 8218 | { |
| 8406 | | state->unl_8237_reg[1] = data; |
| 8219 | state->mmc_reg[1] = data; |
| 8407 | 8220 | mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask); |
| 8408 | 8221 | } |
| 8409 | 8222 | } |
| r8383 | r8384 | |
| 8411 | 8224 | static WRITE8_HANDLER( unl_8237_w ) |
| 8412 | 8225 | { |
| 8413 | 8226 | nes_state *state = (nes_state *)space->machine->driver_data; |
| 8414 | | static const UINT8 conv_table[8] = {0,2,6,1,7,3,4,5}; |
| 8227 | static const UINT8 conv_table[8] = {0, 2, 6, 1, 7, 3, 4, 5}; |
| 8415 | 8228 | LOG_MMC(("unl_8237_w offset: %04x, data: %02x\n", offset, data)); |
| 8416 | 8229 | |
| 8417 | 8230 | switch (offset & 0x7000) |
| r8383 | r8384 | |
| 8423 | 8236 | |
| 8424 | 8237 | case 0x2000: |
| 8425 | 8238 | case 0x3000: |
| 8426 | | state->unl_8237_reg[2] = 1; |
| 8239 | state->mmc_reg[2] = 1; |
| 8427 | 8240 | data = (data & 0xc0) | conv_table[data & 0x07]; |
| 8428 | 8241 | txrom_w(space, 0x0000, data); |
| 8429 | 8242 | break; |
| 8430 | 8243 | |
| 8431 | 8244 | case 0x4000: |
| 8432 | 8245 | case 0x5000: |
| 8433 | | if (state->unl_8237_reg[2]) |
| 8246 | if (state->mmc_reg[2]) |
| 8434 | 8247 | { |
| 8435 | | state->unl_8237_reg[2] = 0; |
| 8248 | state->mmc_reg[2] = 0; |
| 8436 | 8249 | txrom_w(space, 0x0001, data); |
| 8437 | 8250 | } |
| 8438 | 8251 | break; |
| r8383 | r8384 | |
| 8704 | 8517 | { |
| 8705 | 8518 | nes_state *state = (nes_state *)machine->driver_data; |
| 8706 | 8519 | |
| 8707 | | if (!(state->mapper187_reg[0] & 0x80)) |
| 8520 | if (!(state->mmc_reg[0] & 0x80)) |
| 8708 | 8521 | prg8_x(machine, start, bank); |
| 8709 | 8522 | } |
| 8710 | 8523 | |
| r8383 | r8384 | |
| 8728 | 8541 | |
| 8729 | 8542 | if (offset == 0x1000) |
| 8730 | 8543 | { |
| 8731 | | state->mapper187_reg[0] = data; |
| 8544 | state->mmc_reg[0] = data; |
| 8732 | 8545 | |
| 8733 | | if (state->mapper187_reg[0] & 0x80) |
| 8546 | if (state->mmc_reg[0] & 0x80) |
| 8734 | 8547 | { |
| 8735 | | new_bank = (state->mapper187_reg[0] & 0x1f); |
| 8548 | new_bank = (state->mmc_reg[0] & 0x1f); |
| 8736 | 8549 | |
| 8737 | | if (state->mapper187_reg[0] & 0x20) |
| 8550 | if (state->mmc_reg[0] & 0x20) |
| 8738 | 8551 | prg32(space->machine, new_bank >> 2); |
| 8739 | 8552 | else |
| 8740 | 8553 | { |
| r8383 | r8384 | |
| 8752 | 8565 | { |
| 8753 | 8566 | case 0x00: |
| 8754 | 8567 | case 0x01: |
| 8755 | | state->mapper187_reg[1] = 0x83; |
| 8568 | state->mmc_reg[1] = 0x83; |
| 8756 | 8569 | break; |
| 8757 | 8570 | case 0x02: |
| 8758 | | state->mapper187_reg[1] = 0x42; |
| 8571 | state->mmc_reg[1] = 0x42; |
| 8759 | 8572 | break; |
| 8760 | 8573 | case 0x03: |
| 8761 | | state->mapper187_reg[1] = 0x00; |
| 8574 | state->mmc_reg[1] = 0x00; |
| 8762 | 8575 | break; |
| 8763 | 8576 | } |
| 8764 | 8577 | |
| 8765 | 8578 | } |
| 8766 | 8579 | |
| 8767 | | if (!state->mapper187_reg[3] && offset > 0x1000) |
| 8580 | if (!state->mmc_reg[3] && offset > 0x1000) |
| 8768 | 8581 | { |
| 8769 | | state->mapper187_reg[3] = 1; |
| 8582 | state->mmc_reg[3] = 1; |
| 8770 | 8583 | memory_write_byte(space, 0x4017, 0x40); |
| 8771 | 8584 | } |
| 8772 | 8585 | } |
| r8383 | r8384 | |
| 8778 | 8591 | offset += 0x100; |
| 8779 | 8592 | |
| 8780 | 8593 | if (!(offset < 0x1000)) |
| 8781 | | return state->mapper187_reg[1]; |
| 8594 | return state->mmc_reg[1]; |
| 8782 | 8595 | else |
| 8783 | 8596 | return 0; |
| 8784 | 8597 | } |
| r8383 | r8384 | |
| 8791 | 8604 | switch (offset & 0x6003) |
| 8792 | 8605 | { |
| 8793 | 8606 | case 0x0000: |
| 8794 | | state->mapper187_reg[2] = 1; |
| 8607 | state->mmc_reg[2] = 1; |
| 8795 | 8608 | txrom_w(space, 0x0000, data); |
| 8796 | 8609 | break; |
| 8797 | 8610 | |
| 8798 | 8611 | case 0x0001: |
| 8799 | | if (state->mapper187_reg[2]) |
| 8612 | if (state->mmc_reg[2]) |
| 8800 | 8613 | txrom_w(space, 0x0001, data); |
| 8801 | 8614 | break; |
| 8802 | 8615 | |
| r8383 | r8384 | |
| 8804 | 8617 | break; |
| 8805 | 8618 | |
| 8806 | 8619 | case 0x0003: |
| 8807 | | state->mapper187_reg[2] = 0; |
| 8620 | state->mmc_reg[2] = 0; |
| 8808 | 8621 | |
| 8809 | 8622 | if (data == 0x28) |
| 8810 | 8623 | prg8_cd(space->machine, 0x17); |
| r8383 | r8384 | |
| 9144 | 8957 | static WRITE8_HANDLER( unl_sf3_w ) |
| 9145 | 8958 | { |
| 9146 | 8959 | nes_state *state = (nes_state *)space->machine->driver_data; |
| 9147 | | UINT8 MMC3_helper, cmd; |
| 8960 | UINT8 mmc_helper, cmd; |
| 9148 | 8961 | LOG_MMC(("unl_sf3_w, offset: %04x, data: %02x\n", offset, data)); |
| 9149 | 8962 | |
| 9150 | 8963 | switch (offset & 0x6001) |
| 9151 | 8964 | { |
| 9152 | 8965 | case 0x0000: |
| 9153 | | MMC3_helper = state->mmc_latch1 ^ data; |
| 9154 | | state->mmc_latch1 = data; |
| 8966 | mmc_helper = state->mmc3_latch ^ data; |
| 8967 | state->mmc3_latch = data; |
| 9155 | 8968 | |
| 9156 | 8969 | /* Has PRG Mode changed? */ |
| 9157 | | if (MMC3_helper & 0x40) |
| 8970 | if (mmc_helper & 0x40) |
| 9158 | 8971 | mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask); |
| 9159 | 8972 | |
| 9160 | 8973 | /* Has CHR Mode changed? */ |
| 9161 | | if (MMC3_helper & 0x80) |
| 8974 | if (mmc_helper & 0x80) |
| 9162 | 8975 | unl_sf3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask); |
| 9163 | 8976 | break; |
| 9164 | 8977 | |
| 9165 | 8978 | case 0x0001: |
| 9166 | | cmd = state->mmc_latch1 & 0x0f; |
| 8979 | cmd = state->mmc3_latch & 0x0f; |
| 9167 | 8980 | switch (cmd) |
| 9168 | | { |
| 8981 | { |
| 9169 | 8982 | case 0: case 2: case 4: |
| 9170 | 8983 | state->mmc_vrom_bank[cmd >> 1] = data; |
| 9171 | 8984 | unl_sf3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask); |
| r8383 | r8384 | |
| 9175 | 8988 | state->mmc_prg_bank[cmd - 6] = data; |
| 9176 | 8989 | mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask); |
| 9177 | 8990 | break; |
| 9178 | | } |
| 8991 | } |
| 9179 | 8992 | break; |
| 9180 | 8993 | |
| 9181 | 8994 | default: |
| r8383 | r8384 | |
| 9729 | 9542 | switch (offset & 0x6001) |
| 9730 | 9543 | { |
| 9731 | 9544 | case 0x0001: |
| 9732 | | if ((state->mmc_reg[3] & 0x02) && (state->mmc_latch1 & 0x08)) |
| 9545 | if ((state->mmc_reg[3] & 0x02) && (state->mmc3_latch & 0x08)) |
| 9733 | 9546 | { |
| 9734 | | state->mmc_reg[4 | (state->mmc_latch1 & 0x03)] = data; |
| 9547 | state->mmc_reg[4 | (state->mmc3_latch & 0x03)] = data; |
| 9735 | 9548 | fk23c_set_prg(space->machine); |
| 9736 | 9549 | fk23c_set_chr(space->machine); |
| 9737 | 9550 | } |
| r8383 | r8384 | |
| 9764 | 9577 | static void bmc_64in1nr_set_prg( running_machine *machine ) |
| 9765 | 9578 | { |
| 9766 | 9579 | nes_state *state = (nes_state *)machine->driver_data; |
| 9767 | | UINT8 helper1 = (state->bmc_64in1nr_reg[1] & 0x1f); |
| 9768 | | UINT8 helper2 = (helper1 << 1) | ((state->bmc_64in1nr_reg[1] & 0x40) >> 6); |
| 9580 | UINT8 helper1 = (state->mmc_reg[1] & 0x1f); |
| 9581 | UINT8 helper2 = (helper1 << 1) | ((state->mmc_reg[1] & 0x40) >> 6); |
| 9769 | 9582 | |
| 9770 | | if (state->bmc_64in1nr_reg[0] & 0x80) |
| 9583 | if (state->mmc_reg[0] & 0x80) |
| 9771 | 9584 | { |
| 9772 | | if (state->bmc_64in1nr_reg[1] & 0x80) |
| 9585 | if (state->mmc_reg[1] & 0x80) |
| 9773 | 9586 | prg32(machine, helper1); |
| 9774 | 9587 | else |
| 9775 | 9588 | { |
| r8383 | r8384 | |
| 9793 | 9606 | case 0x1001: |
| 9794 | 9607 | case 0x1002: |
| 9795 | 9608 | case 0x1003: |
| 9796 | | state->bmc_64in1nr_reg[offset & 0x03] = data; |
| 9609 | state->mmc_reg[offset & 0x03] = data; |
| 9797 | 9610 | bmc_64in1nr_set_prg(space->machine); |
| 9798 | | chr8(space->machine, ((state->bmc_64in1nr_reg[0] >> 1) & 0x03) | (state->bmc_64in1nr_reg[2] << 2), CHRROM); |
| 9611 | chr8(space->machine, ((state->mmc_reg[0] >> 1) & 0x03) | (state->mmc_reg[2] << 2), CHRROM); |
| 9799 | 9612 | break; |
| 9800 | 9613 | } |
| 9801 | 9614 | if (offset == 0x1000) /* reg[0] also sets mirroring */ |
| r8383 | r8384 | |
| 9807 | 9620 | nes_state *state = (nes_state *)space->machine->driver_data; |
| 9808 | 9621 | LOG_MMC(("bmc_64in1nr_w offset: %04x, data: %02x\n", offset, data)); |
| 9809 | 9622 | |
| 9810 | | state->bmc_64in1nr_reg[3] = data; // reg[3] is currently unused?!? |
| 9623 | state->mmc_reg[3] = data; // reg[3] is currently unused?!? |
| 9811 | 9624 | } |
| 9812 | 9625 | |
| 9813 | 9626 | /************************************************************* |
| r8383 | r8384 | |
| 9905 | 9718 | |
| 9906 | 9719 | Games: Super 24-in-1 |
| 9907 | 9720 | |
| 9908 | | In MESS: Supported |
| 9721 | In MESS: Partially Supported |
| 9909 | 9722 | |
| 9910 | 9723 | *************************************************************/ |
| 9911 | 9724 | |
| 9912 | | static void bmc_s24in1sc03_set_prg( running_machine *machine ) |
| 9725 | static void bmc_s24in1sc03_prg_cb( running_machine *machine, int start, int bank ) |
| 9913 | 9726 | { |
| 9914 | 9727 | nes_state *state = (nes_state *)machine->driver_data; |
| 9915 | 9728 | static const UINT8 masks[8] = {0x3f, 0x1f, 0x0f, 0x01, 0x03, 0x00, 0x00, 0x00}; |
| 9916 | | UINT8 prg_flip = (state->mmc_latch1 & 0x40) ? 2 : 0; |
| 9917 | | int prg_base = state->bmc_s24in1sc03_reg[1] << 1; |
| 9918 | | int prg_mask = masks[state->bmc_s24in1sc03_reg[0] & 0x07]; |
| 9729 | int prg_base = state->mmc_reg[1] << 1; |
| 9730 | int prg_mask = masks[state->mmc_reg[0] & 0x07]; |
| 9919 | 9731 | |
| 9920 | | prg8_89(machine, prg_base | (state->mmc_prg_bank[0 ^ prg_flip] & prg_mask)); |
| 9921 | | prg8_ab(machine, prg_base | (state->mmc_prg_bank[1] & prg_mask)); |
| 9922 | | prg8_cd(machine, prg_base | (state->mmc_prg_bank[2 ^ prg_flip] & prg_mask)); |
| 9923 | | prg8_ef(machine, prg_base | (state->mmc_prg_bank[3] & prg_mask)); |
| 9732 | bank = prg_base | (bank & prg_mask); |
| 9733 | prg8_x(machine, start, bank); |
| 9924 | 9734 | } |
| 9925 | 9735 | |
| 9926 | | static void bmc_s24in1sc03_set_chr( running_machine *machine ) |
| 9736 | static void bmc_s24in1sc03_chr_cb( running_machine *machine, int start, int bank, int source ) |
| 9927 | 9737 | { |
| 9928 | 9738 | nes_state *state = (nes_state *)machine->driver_data; |
| 9929 | | UINT8 chr_page = (state->mmc_latch1 & 0x80) >> 5; |
| 9930 | | UINT8 chr = (state->bmc_s24in1sc03_reg[0] & 0x20) ? CHRRAM : CHRROM; |
| 9931 | | int chr_base = (state->bmc_s24in1sc03_reg[2] << 3) & 0xf00; |
| 9932 | | |
| 9933 | | chr1_x(machine, chr_page ^ 0, chr_base | (state->mmc_vrom_bank[0] & ~0x01), chr); |
| 9934 | | chr1_x(machine, chr_page ^ 1, chr_base | (state->mmc_vrom_bank[0] | 0x01), chr); |
| 9935 | | chr1_x(machine, chr_page ^ 2, chr_base | (state->mmc_vrom_bank[1] & ~0x01), chr); |
| 9936 | | chr1_x(machine, chr_page ^ 3, chr_base | (state->mmc_vrom_bank[1] | 0x01), chr); |
| 9937 | | chr1_x(machine, chr_page ^ 4, chr_base | state->mmc_vrom_bank[2], chr); |
| 9938 | | chr1_x(machine, chr_page ^ 5, chr_base | state->mmc_vrom_bank[3], chr); |
| 9939 | | chr1_x(machine, chr_page ^ 6, chr_base | state->mmc_vrom_bank[4], chr); |
| 9940 | | chr1_x(machine, chr_page ^ 7, chr_base | state->mmc_vrom_bank[5], chr); |
| 9739 | UINT8 chr = BIT(state->mmc_reg[0], 5) ? CHRRAM : CHRROM; |
| 9740 | int chr_base = (state->mmc_reg[2] << 3) & 0xf00; |
| 9741 | |
| 9742 | chr1_x(machine, start, chr_base | bank, chr); |
| 9941 | 9743 | } |
| 9942 | 9744 | |
| 9943 | 9745 | static WRITE8_HANDLER( bmc_s24in1sc03_l_w ) |
| r8383 | r8384 | |
| 9948 | 9750 | |
| 9949 | 9751 | if (offset == 0x1ff0) |
| 9950 | 9752 | { |
| 9951 | | state->bmc_s24in1sc03_reg[0] = data; |
| 9952 | | bmc_s24in1sc03_set_prg(space->machine); |
| 9953 | | bmc_s24in1sc03_set_chr(space->machine); |
| 9753 | state->mmc_reg[0] = data; |
| 9754 | mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask); |
| 9755 | mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask); |
| 9954 | 9756 | } |
| 9955 | 9757 | |
| 9956 | 9758 | if (offset == 0x1ff1) |
| 9957 | 9759 | { |
| 9958 | | state->bmc_s24in1sc03_reg[1] = data; |
| 9959 | | bmc_s24in1sc03_set_prg(space->machine); |
| 9760 | state->mmc_reg[1] = data; |
| 9761 | mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask); |
| 9960 | 9762 | } |
| 9961 | 9763 | |
| 9962 | 9764 | if (offset == 0x1ff2) |
| 9963 | 9765 | { |
| 9964 | | state->bmc_s24in1sc03_reg[2] = data; |
| 9965 | | bmc_s24in1sc03_set_chr(space->machine); |
| 9766 | state->mmc_reg[2] = data; |
| 9767 | mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask); |
| 9966 | 9768 | } |
| 9967 | 9769 | } |
| 9968 | 9770 | |
| 9969 | | static WRITE8_HANDLER( bmc_s24in1sc03_w ) |
| 9970 | | { |
| 9971 | | nes_state *state = (nes_state *)space->machine->driver_data; |
| 9972 | | UINT8 cmd, bmc_s24in1sc03_helper; |
| 9973 | | LOG_MMC(("bmc_s24in1sc03_w offset: %04x, data: %02x\n", offset, data)); |
| 9974 | | |
| 9975 | | switch (offset & 0x6001) |
| 9976 | | { |
| 9977 | | case 0x0000: |
| 9978 | | bmc_s24in1sc03_helper = state->mmc_latch1 ^ data; |
| 9979 | | state->mmc_latch1 = data; |
| 9980 | | |
| 9981 | | /* Has PRG Mode changed? */ |
| 9982 | | if (bmc_s24in1sc03_helper & 0x40) |
| 9983 | | bmc_s24in1sc03_set_prg(space->machine); |
| 9984 | | |
| 9985 | | /* Has CHR Mode changed? */ |
| 9986 | | if (bmc_s24in1sc03_helper & 0x80) |
| 9987 | | bmc_s24in1sc03_set_chr(space->machine); |
| 9988 | | break; |
| 9989 | | |
| 9990 | | case 0x0001: |
| 9991 | | cmd = state->mmc_latch1 & 0x07; |
| 9992 | | switch (cmd) |
| 9993 | | { |
| 9994 | | case 0: case 1: // these do not need to be separated: we take care of them in set_chr! |
| 9995 | | case 2: case 3: case 4: case 5: |
| 9996 | | state->mmc_vrom_bank[cmd] = data; |
| 9997 | | bmc_s24in1sc03_set_chr(space->machine); |
| 9998 | | break; |
| 9999 | | case 6: |
| 10000 | | case 7: |
| 10001 | | state->mmc_prg_bank[cmd - 6] = data; |
| 10002 | | bmc_s24in1sc03_set_prg(space->machine); |
| 10003 | | break; |
| 10004 | | } |
| 10005 | | break; |
| 10006 | | |
| 10007 | | default: |
| 10008 | | txrom_w(space, offset, data); |
| 10009 | | break; |
| 10010 | | } |
| 10011 | | } |
| 10012 | | |
| 10013 | 9771 | /************************************************************* |
| 10014 | 9772 | |
| 10015 | 9773 | Board BMC-T-262 |
| r8383 | r8384 | |
| 10741 | 10499 | |
| 10742 | 10500 | /* This bit is the "register lock". Once register are locked, writes go to WRAM |
| 10743 | 10501 | and there is no way to unlock them (except by resetting the machine) */ |
| 10744 | | if ((state->mapper45_reg[3] & 0x40) && state->wram != NULL) |
| 10502 | if ((state->mmc_reg[3] & 0x40) && state->wram != NULL) |
| 10745 | 10503 | state->wram[offset] = data; |
| 10746 | 10504 | else |
| 10747 | 10505 | { |
| 10748 | | state->mapper45_reg[state->mmc_count] = data; |
| 10506 | state->mmc_reg[state->mmc_count] = data; |
| 10749 | 10507 | state->mmc_count = (state->mmc_count + 1) & 0x03; |
| 10750 | 10508 | |
| 10751 | 10509 | if (!state->mmc_count) |
| 10752 | 10510 | { |
| 10753 | | LOG_MMC(("bmc_hik8_m_w, command completed %02x %02x %02x %02x\n", state->mapper45_reg[3], |
| 10754 | | state->mapper45_reg[2], state->mapper45_reg[1], state->mapper45_reg[0])); |
| 10511 | LOG_MMC(("bmc_hik8_m_w, command completed %02x %02x %02x %02x\n", state->mmc_reg[3], |
| 10512 | state->mmc_reg[2], state->mmc_reg[1], state->mmc_reg[0])); |
| 10755 | 10513 | |
| 10756 | | state->mmc_prg_base = state->mapper45_reg[1]; |
| 10757 | | state->mmc_prg_mask = 0x3f ^ (state->mapper45_reg[3] & 0x3f); |
| 10758 | | state->mmc_chr_base = ((state->mapper45_reg[2] & 0xf0) << 4) | state->mapper45_reg[0]; |
| 10759 | | if (BIT(state->mapper45_reg[2], 3)) |
| 10760 | | state->mmc_chr_mask = (1 << ((state->mapper45_reg[2] & 7) + 1)) - 1; |
| 10761 | | else if (state->mapper45_reg[2]) |
| 10514 | state->mmc_prg_base = state->mmc_reg[1]; |
| 10515 | state->mmc_prg_mask = 0x3f ^ (state->mmc_reg[3] & 0x3f); |
| 10516 | state->mmc_chr_base = ((state->mmc_reg[2] & 0xf0) << 4) | state->mmc_reg[0]; |
| 10517 | if (BIT(state->mmc_reg[2], 3)) |
| 10518 | state->mmc_chr_mask = (1 << ((state->mmc_reg[2] & 7) + 1)) - 1; |
| 10519 | else if (state->mmc_reg[2]) |
| 10762 | 10520 | state->mmc_chr_mask = 0; |
| 10763 | 10521 | else |
| 10764 | 10522 | state->mmc_chr_mask = 0xff; // i.e. we use the vrom_bank with no masking |
| r8383 | r8384 | |
| 10790 | 10548 | /* mid writes only work when WRAM is enabled. not sure if I should |
| 10791 | 10549 | change the condition to state->mmc_latch2==0x80 (i.e. what is the effect of |
| 10792 | 10550 | the read-only bit?) */ |
| 10793 | | if (state->mmc_latch2 & 0x80) |
| 10551 | if (state->mmc3_wram_protect & 0x80) |
| 10794 | 10552 | { |
| 10795 | 10553 | if (data & 0x01) /* if this is 0, then we have 32k PRG blocks */ |
| 10796 | 10554 | { |
| r8383 | r8384 | |
| 10823 | 10581 | static void bmc_ball11_set_banks( running_machine *machine ) |
| 10824 | 10582 | { |
| 10825 | 10583 | nes_state *state = (nes_state *)machine->driver_data; |
| 10826 | | set_nt_mirroring(machine, (state->mapper51_reg[0] == 3) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); |
| 10584 | set_nt_mirroring(machine, (state->mmc_reg[0] == 3) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); |
| 10827 | 10585 | |
| 10828 | | if (state->mapper51_reg[0] & 0x01) |
| 10586 | if (state->mmc_reg[0] & 0x01) |
| 10829 | 10587 | { |
| 10830 | | prg32(machine, state->mapper51_reg[1]); |
| 10588 | prg32(machine, state->mmc_reg[1]); |
| 10831 | 10589 | } |
| 10832 | 10590 | else |
| 10833 | 10591 | { |
| 10834 | | prg16_89ab(machine, (state->mapper51_reg[1] << 1) | (state->mapper51_reg[0] >> 1)); |
| 10835 | | prg16_cdef(machine, (state->mapper51_reg[1] << 1) | 0x07); |
| 10592 | prg16_89ab(machine, (state->mmc_reg[1] << 1) | (state->mmc_reg[0] >> 1)); |
| 10593 | prg16_cdef(machine, (state->mmc_reg[1] << 1) | 0x07); |
| 10836 | 10594 | } |
| 10837 | 10595 | } |
| 10838 | 10596 | |
| r8383 | r8384 | |
| 10842 | 10600 | |
| 10843 | 10601 | LOG_MMC(("bmc_ball11_m_w, offset: %04x, data: %02x\n", offset, data)); |
| 10844 | 10602 | |
| 10845 | | state->mapper51_reg[0] = ((data >> 1) & 0x01) | ((data >> 3) & 0x02); |
| 10603 | state->mmc_reg[0] = ((data >> 1) & 0x01) | ((data >> 3) & 0x02); |
| 10846 | 10604 | bmc_ball11_set_banks(space->machine); |
| 10847 | 10605 | } |
| 10848 | 10606 | |
| r8383 | r8384 | |
| 10855 | 10613 | switch (offset & 0x6000) |
| 10856 | 10614 | { |
| 10857 | 10615 | case 0x4000: // here we also update reg[0] upper bit |
| 10858 | | state->mapper51_reg[0] = (state->mapper51_reg[0] & 0x01) | ((data >> 3) & 0x02); |
| 10616 | state->mmc_reg[0] = (state->mmc_reg[0] & 0x01) | ((data >> 3) & 0x02); |
| 10859 | 10617 | case 0x0000: |
| 10860 | 10618 | case 0x2000: |
| 10861 | 10619 | case 0x6000: |
| 10862 | | state->mapper51_reg[1] = data & 0x0f; |
| 10620 | state->mmc_reg[1] = data & 0x0f; |
| 10863 | 10621 | bmc_ball11_set_banks(space->machine); |
| 10864 | 10622 | break; |
| 10865 | 10623 | } |
| r8383 | r8384 | |
| 10889 | 10647 | /* mid writes only work when WRAM is enabled. not sure if I should |
| 10890 | 10648 | change the condition to state->mmc_latch2==0x80 (i.e. what is the effect of |
| 10891 | 10649 | the read-only bit?) and it only can happen once! */ |
| 10892 | | if ((state->mmc_latch2 & 0x80) && !state->map52_reg_written) |
| 10650 | if ((state->mmc3_wram_protect & 0x80) && !state->map52_reg_written) |
| 10893 | 10651 | { |
| 10894 | 10652 | map52_helper1 = (data & 0x08); |
| 10895 | 10653 | map52_helper2 = (data & 0x40); |
| r8383 | r8384 | |
| 10926 | 10684 | static void bmc_gc6in1_set_prg( running_machine *machine, int prg_base, int prg_mask ) |
| 10927 | 10685 | { |
| 10928 | 10686 | nes_state *state = (nes_state *)machine->driver_data; |
| 10929 | | state->mmc_prg_base = (state->map217_reg[1] & 0x08) ? 0 : (state->map217_reg[1] & 0x10); |
| 10930 | | state->mmc_prg_mask = (state->map217_reg[1] & 0x08) ? 0x1f : 0x0f; |
| 10687 | state->mmc_prg_base = (state->mmc_reg[1] & 0x08) ? 0 : (state->mmc_reg[1] & 0x10); |
| 10688 | state->mmc_prg_mask = (state->mmc_reg[1] & 0x08) ? 0x1f : 0x0f; |
| 10931 | 10689 | |
| 10932 | | state->mmc_prg_base |= ((state->map217_reg[1] & 0x03) << 5); |
| 10690 | state->mmc_prg_base |= ((state->mmc_reg[1] & 0x03) << 5); |
| 10933 | 10691 | |
| 10934 | 10692 | mmc3_set_prg(machine, state->mmc_prg_base, state->mmc_prg_mask); |
| 10935 | 10693 | } |
| r8383 | r8384 | |
| 10938 | 10696 | { |
| 10939 | 10697 | nes_state *state = (nes_state *)machine->driver_data; |
| 10940 | 10698 | UINT8 chr_page = (state->mmc_latch1 & 0x80) >> 5; |
| 10941 | | int chr_base = (state->map217_reg[1] & 0x08) ? 0x00 : ((state->map217_reg[1] & 0x10) << 3); |
| 10942 | | int chr_mask = (state->map217_reg[1] & 0x08) ? 0xff : 0x7f; |
| 10699 | int chr_base = (state->mmc_reg[1] & 0x08) ? 0x00 : ((state->mmc_reg[1] & 0x10) << 3); |
| 10700 | int chr_mask = (state->mmc_reg[1] & 0x08) ? 0xff : 0x7f; |
| 10943 | 10701 | |
| 10944 | | chr_base |= ((state->map217_reg[1] & 0x03) << 8); |
| 10702 | chr_base |= ((state->mmc_reg[1] & 0x03) << 8); |
| 10945 | 10703 | |
| 10946 | 10704 | chr1_x(machine, chr_page ^ 0, chr_base | ((state->mmc_vrom_bank[0] & ~0x01) & chr_mask), chr); |
| 10947 | 10705 | chr1_x(machine, chr_page ^ 1, chr_base | ((state->mmc_vrom_bank[0] | 0x01) & chr_mask), chr); |
| r8383 | r8384 | |
| 10962 | 10720 | |
| 10963 | 10721 | if (offset == 0x1000) |
| 10964 | 10722 | { |
| 10965 | | state->map217_reg[0] = data; |
| 10723 | state->mmc_reg[0] = data; |
| 10966 | 10724 | if (data & 0x80) |
| 10967 | 10725 | { |
| 10968 | | bank = (data & 0x0f) | ((state->map217_reg[1] & 0x03) << 4); |
| 10726 | bank = (data & 0x0f) | ((state->mmc_reg[1] & 0x03) << 4); |
| 10969 | 10727 | prg16_89ab(space->machine, bank); |
| 10970 | 10728 | prg16_cdef(space->machine, bank); |
| 10971 | 10729 | } |
| r8383 | r8384 | |
| 10974 | 10732 | } |
| 10975 | 10733 | else if (offset == 0x1001) |
| 10976 | 10734 | { |
| 10977 | | state->map217_reg[1] = data; |
| 10735 | state->mmc_reg[1] = data; |
| 10978 | 10736 | bmc_gc6in1_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask); |
| 10979 | 10737 | } |
| 10980 | 10738 | else if (offset == 0x1007) |
| 10981 | 10739 | { |
| 10982 | | state->map217_reg[2] = data; |
| 10740 | state->mmc_reg[2] = data; |
| 10983 | 10741 | } |
| 10984 | 10742 | } |
| 10985 | 10743 | |
| 10986 | 10744 | static WRITE8_HANDLER( bmc_gc6in1_w ) |
| 10987 | 10745 | { |
| 10988 | 10746 | nes_state *state = (nes_state *)space->machine->driver_data; |
| 10989 | | UINT8 MMC3_helper, cmd; |
| 10747 | UINT8 mmc_helper, cmd; |
| 10990 | 10748 | static const UINT8 conv_table[8] = {0, 6, 3, 7, 5, 2, 4, 1}; |
| 10991 | 10749 | LOG_MMC(("bmc_gc6in1_w, offset: %04x, data: %02x\n", offset, data)); |
| 10992 | 10750 | |
| 10993 | | if (!state->map217_reg[2]) // in this case we act like MMC3, only with alt prg/chr handlers |
| 10751 | if (!state->mmc_reg[2]) // in this case we act like MMC3, only with alt prg/chr handlers |
| 10994 | 10752 | { |
| 10995 | 10753 | switch (offset & 0x6001) |
| 10996 | 10754 | { |
| 10997 | 10755 | case 0x0000: |
| 10998 | | MMC3_helper = state->mmc_latch1 ^ data; |
| 10999 | | state->mmc_latch1 = data; |
| 10756 | mmc_helper = state->mmc3_latch ^ data; |
| 10757 | state->mmc3_latch = data; |
| 11000 | 10758 | |
| 11001 | 10759 | /* Has PRG Mode changed? */ |
| 11002 | | if (MMC3_helper & 0x40) |
| 10760 | if (mmc_helper & 0x40) |
| 11003 | 10761 | bmc_gc6in1_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask); |
| 11004 | 10762 | |
| 11005 | 10763 | /* Has CHR Mode changed? */ |
| 11006 | | if (MMC3_helper & 0x80) |
| 10764 | if (mmc_helper & 0x80) |
| 11007 | 10765 | bmc_gc6in1_set_chr(space->machine, state->mmc_chr_source); |
| 11008 | 10766 | break; |
| 11009 | 10767 | |
| 11010 | 10768 | case 0x0001: |
| 11011 | | cmd = state->mmc_latch1 & 0x07; |
| 10769 | cmd = state->mmc3_latch & 0x07; |
| 11012 | 10770 | switch (cmd) |
| 11013 | 10771 | { |
| 11014 | 10772 | case 0: case 1: // these do not need to be separated: we take care of them in set_chr! |
| r8383 | r8384 | |
| 11039 | 10797 | |
| 11040 | 10798 | case 0x0001: |
| 11041 | 10799 | data = (data & 0xc0) | conv_table[data & 0x07]; |
| 11042 | | MMC3_helper = state->mmc_latch1 ^ data; |
| 11043 | | state->mmc_latch1 = data; |
| 10800 | mmc_helper = state->mmc3_latch ^ data; |
| 10801 | state->mmc3_latch = data; |
| 11044 | 10802 | |
| 11045 | 10803 | /* Has PRG Mode changed? */ |
| 11046 | | if (MMC3_helper & 0x40) |
| 10804 | if (mmc_helper & 0x40) |
| 11047 | 10805 | bmc_gc6in1_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask); |
| 11048 | 10806 | |
| 11049 | 10807 | /* Has CHR Mode changed? */ |
| 11050 | | if (MMC3_helper & 0x80) |
| 10808 | if (mmc_helper & 0x80) |
| 11051 | 10809 | bmc_gc6in1_set_chr(space->machine, state->mmc_chr_source); |
| 11052 | 10810 | |
| 11053 | | state->map217_reg[3] = 1; |
| 10811 | state->mmc_reg[3] = 1; |
| 11054 | 10812 | break; |
| 11055 | 10813 | |
| 11056 | 10814 | case 0x2000: |
| 11057 | | cmd = state->mmc_latch1 & 0x07; |
| 11058 | | if (state->map217_reg[3]) |
| 10815 | cmd = state->mmc3_latch & 0x07; |
| 10816 | if (state->mmc_reg[3]) |
| 11059 | 10817 | { |
| 11060 | | state->map217_reg[3] = 0; |
| 10818 | state->mmc_reg[3] = 0; |
| 11061 | 10819 | switch (cmd) |
| 11062 | 10820 | { |
| 11063 | 10821 | case 0: case 1: // these do not need to be separated: we take care of them in set_chr! |
| r8383 | r8384 | |
| 11522 | 11280 | static void pjoy84_prg_cb( running_machine *machine, int start, int bank ) |
| 11523 | 11281 | { |
| 11524 | 11282 | nes_state *state = (nes_state *)machine->driver_data; |
| 11525 | | UINT8 flip = (state->mmc_latch1 & 0x40) ? 2 : 0; |
| 11283 | UINT8 flip = (state->mmc3_latch & 0x40) ? 2 : 0; |
| 11526 | 11284 | |
| 11527 | 11285 | if (!(state->mmc_reg[3] & 0x03)) |
| 11528 | 11286 | prg8_x(machine, start, bank); |
| r8383 | r8384 | |
| 11650 | 11408 | |
| 11651 | 11409 | if (data & 0x80) |
| 11652 | 11410 | { |
| 11653 | | state->mmc_count = 0; |
| 11654 | | state->mmc_latch2 = 0; |
| 11411 | state->mmc1_count = 0; |
| 11412 | state->mmc1_latch = 0; |
| 11655 | 11413 | |
| 11656 | 11414 | state->mmc_reg[0] |= 0x0c; |
| 11657 | 11415 | someri_mmc1_set_prg(space->machine); |
| 11658 | 11416 | return; |
| 11659 | 11417 | } |
| 11660 | 11418 | |
| 11661 | | if (state->mmc_count < 5) |
| 11419 | if (state->mmc1_count < 5) |
| 11662 | 11420 | { |
| 11663 | | if (state->mmc_count == 0) state->mmc_latch2 = 0; |
| 11664 | | state->mmc_latch2 >>= 1; |
| 11665 | | state->mmc_latch2 |= (data & 0x01) ? 0x10 : 0x00; |
| 11666 | | state->mmc_count++; |
| 11421 | if (state->mmc1_count == 0) state->mmc1_latch = 0; |
| 11422 | state->mmc1_latch >>= 1; |
| 11423 | state->mmc1_latch |= (data & 0x01) ? 0x10 : 0x00; |
| 11424 | state->mmc1_count++; |
| 11667 | 11425 | } |
| 11668 | 11426 | |
| 11669 | | if (state->mmc_count == 5) |
| 11427 | if (state->mmc1_count == 5) |
| 11670 | 11428 | { |
| 11671 | 11429 | switch (offset & 0x6000) |
| 11672 | 11430 | { |
| 11673 | 11431 | case 0x0000: |
| 11674 | | state->mmc_reg[0] = state->mmc_latch2; |
| 11432 | state->mmc_reg[0] = state->mmc1_latch; |
| 11675 | 11433 | switch (state->mmc_reg[0] & 0x03) |
| 11676 | 11434 | { |
| 11677 | 11435 | case 0: set_nt_mirroring(space->machine, PPU_MIRROR_LOW); break; |
| r8383 | r8384 | |
| 11683 | 11441 | someri_mmc1_set_prg(space->machine); |
| 11684 | 11442 | break; |
| 11685 | 11443 | case 0x2000: |
| 11686 | | state->mmc_reg[1] = state->mmc_latch2; |
| 11444 | state->mmc_reg[1] = state->mmc1_latch; |
| 11687 | 11445 | someri_mmc1_set_chr(space->machine); |
| 11688 | 11446 | someri_mmc1_set_prg(space->machine); |
| 11689 | 11447 | break; |
| 11690 | 11448 | case 0x4000: |
| 11691 | | state->mmc_reg[2] = state->mmc_latch2; |
| 11449 | state->mmc_reg[2] = state->mmc1_latch; |
| 11692 | 11450 | someri_mmc1_set_chr(space->machine); |
| 11693 | 11451 | break; |
| 11694 | 11452 | case 0x6000: |
| 11695 | | state->mmc_reg[3] = state->mmc_latch2; |
| 11453 | state->mmc_reg[3] = state->mmc1_latch; |
| 11696 | 11454 | someri_mmc1_set_prg(space->machine); |
| 11697 | 11455 | break; |
| 11698 | 11456 | } |
| 11699 | 11457 | |
| 11700 | | state->mmc_count = 0; |
| 11458 | state->mmc1_count = 0; |
| 11701 | 11459 | } |
| 11702 | 11460 | } |
| 11703 | 11461 | |
| r8383 | r8384 | |
| 11705 | 11463 | static WRITE8_HANDLER( someri_mmc3_w ) |
| 11706 | 11464 | { |
| 11707 | 11465 | nes_state *state = (nes_state *)space->machine->driver_data; |
| 11708 | | UINT8 mmc3_helper, cmd; |
| 11466 | UINT8 mmc_helper, cmd; |
| 11709 | 11467 | |
| 11710 | 11468 | assert(state->mmc_cmd1 == 1); |
| 11711 | 11469 | switch (offset & 0x6001) |
| 11712 | 11470 | { |
| 11713 | 11471 | case 0x0000: |
| 11714 | | mmc3_helper = state->mmc_latch1 ^ data; |
| 11715 | | state->mmc_latch1 = data; |
| 11472 | mmc_helper = state->mmc3_latch ^ data; |
| 11473 | state->mmc3_latch = data; |
| 11716 | 11474 | |
| 11717 | | if (mmc3_helper & 0x40) |
| 11475 | if (mmc_helper & 0x40) |
| 11718 | 11476 | mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask); |
| 11719 | 11477 | |
| 11720 | | if (mmc3_helper & 0x80) |
| 11478 | if (mmc_helper & 0x80) |
| 11721 | 11479 | mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask); |
| 11722 | 11480 | break; |
| 11723 | 11481 | |
| 11724 | 11482 | case 0x0001: |
| 11725 | | cmd = state->mmc_latch1 & 0x07; |
| 11483 | cmd = state->mmc3_latch & 0x07; |
| 11726 | 11484 | switch (cmd) |
| 11727 | 11485 | { |
| 11728 | 11486 | case 0: case 1: |
| r8383 | r8384 | |
| 11937 | 11695 | return 0x00; |
| 11938 | 11696 | } |
| 11939 | 11697 | |
| 11940 | | // further review needed for: TXROM, PXROM, FXROM, Bandai LZ93D50, Irem G-101, Konami VRC3 |
| 11941 | | // all multicart pcb, many unl/btl pcbs |
| 11942 | 11698 | static const nes_pcb_intf nes_intf_list[] = |
| 11943 | 11699 | { |
| 11944 | 11700 | { STD_NROM, NES_NOACCESS, NES_NOACCESS, NES_NOACCESS, NULL, NULL, NULL }, |
| r8383 | r8384 | |
| 11965 | 11721 | { STD_TXROM, NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(txrom_w), NULL, NULL, mmc3_irq }, |
| 11966 | 11722 | { STD_TVROM, NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(txrom_w), NULL, NULL, mmc3_irq }, |
| 11967 | 11723 | { STD_TKROM, NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(txrom_w), NULL, NULL, mmc3_irq }, |
| 11968 | | { STD_HKROM, NES_NOACCESS, {hkrom_m_w, hkrom_m_r}, NES_WRITEONLY(hkrom_w), NULL, NULL, mmc3_irq }, |
| 11724 | { STD_HKROM, NES_NOACCESS, {hkrom_m_w, hkrom_m_r}, NES_WRITEONLY(hkrom_w), NULL, NULL, mmc3_irq }, |
| 11969 | 11725 | { STD_TQROM, NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(tqrom_w), NULL, NULL, mmc3_irq }, |
| 11970 | 11726 | { STD_TXSROM, NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(txsrom_w), NULL, NULL, mmc3_irq }, |
| 11971 | 11727 | { STD_DXROM, NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(dxrom_w), NULL, NULL, NULL }, |
| r8383 | r8384 | |
| 12033 | 11789 | { DREAMTECH_BOARD, NES_WRITEONLY(dreamtech_l_w), NES_NOACCESS, NES_NOACCESS, NULL, NULL, NULL }, |
| 12034 | 11790 | { FUTUREMEDIA_BOARD, NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(futuremedia_w), NULL, NULL, futuremedia_irq }, |
| 12035 | 11791 | { FUKUTAKE_BOARD, {fukutake_l_w, fukutake_l_r}, NES_NOACCESS, NES_NOACCESS, NULL, NULL, NULL }, |
| 12036 | | { GOUDER_37017, {gouder_sf4_l_w, gouder_sf4_l_r}, NES_NOACCESS, NES_WRITEONLY(gouder_sf4_w), NULL, NULL, mmc3_irq }, |
| 11792 | { GOUDER_37017, {gouder_sf4_l_w, gouder_sf4_l_r}, NES_NOACCESS, NES_WRITEONLY(txrom_w), NULL, NULL, mmc3_irq }, |
| 12037 | 11793 | { HENGEDIANZI_BOARD, NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(henggedianzi_w), NULL, NULL, NULL }, |
| 12038 | 11794 | { HENGEDIANZI_XJZB, NES_WRITEONLY(heng_xjzb_l_w), NES_NOACCESS, NES_WRITEONLY(heng_xjzb_w), NULL, NULL, NULL }, |
| 12039 | 11795 | { HES6IN1_BOARD, NES_WRITEONLY(hes6in1_l_w), NES_NOACCESS, NES_NOACCESS, NULL, NULL, NULL }, |
| r8383 | r8384 | |
| 12045 | 11801 | { KAISER_KS202, NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(ks202_w), NULL, NULL, ks7032_irq }, |
| 12046 | 11802 | { KAISER_KS7017, NES_WRITEONLY(ks7017_l_w), NES_NOACCESS, NES_NOACCESS, NULL, NULL, mmc_fds_irq }, |
| 12047 | 11803 | { KAY_PANDAPRINCE, {kay_pp_l_w, kay_pp_l_r}, NES_NOACCESS, NES_WRITEONLY(kay_pp_w), NULL, NULL, mmc3_irq }, |
| 12048 | | { KASING_BOARD, NES_NOACCESS, NES_WRITEONLY(kasing_m_w), NES_WRITEONLY(kasing_w), NULL, NULL, mmc3_irq }, |
| 11804 | { KASING_BOARD, NES_NOACCESS, NES_WRITEONLY(kasing_m_w), NES_WRITEONLY(txrom_w), NULL, NULL, mmc3_irq }, |
| 12049 | 11805 | { SACHEN_74LS374, {sachen_74x374_l_w, sachen_74x374_l_r}, NES_NOACCESS, NES_NOACCESS, NULL, NULL, NULL }, |
| 12050 | 11806 | { SACHEN_74LS374_A, NES_WRITEONLY(sachen_74x374a_l_w), NES_NOACCESS, NES_NOACCESS, NULL, NULL, NULL }, |
| 12051 | 11807 | { SACHEN_8259A, NES_WRITEONLY(s8259_l_w), NES_WRITEONLY(s8259_m_w), NES_NOACCESS, NULL, NULL, NULL }, |
| r8383 | r8384 | |
| 12070 | 11826 | { OPENCORP_DAOU306, NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(daou306_w), NULL, NULL, NULL }, |
| 12071 | 11827 | { RCM_GS2015, NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(gs2015_w), NULL, NULL, NULL }, |
| 12072 | 11828 | { RCM_TETRISFAMILY, NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(rcm_tf_w), NULL, NULL, NULL }, |
| 12073 | | { REXSOFT_DBZ5, {rex_dbz_l_w, rex_dbz_l_r}, NES_NOACCESS, NES_WRITEONLY(rex_dbz_w), NULL, NULL, mmc3_irq }, |
| 11829 | { REXSOFT_DBZ5, {rex_dbz_l_w, rex_dbz_l_r}, NES_READONLY(rex_dbz_l_r), NES_WRITEONLY(txrom_w), NULL, NULL, mmc3_irq }, |
| 12074 | 11830 | { REXSOFT_SL1632, NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(rex_sl1632_w), NULL, NULL, mmc3_irq }, |
| 12075 | 11831 | { RUMBLESTATION_BOARD, NES_NOACCESS, NES_WRITEONLY(rumblestation_m_w), NES_WRITEONLY(rumblestation_w), NULL, NULL, NULL }, |
| 12076 | 11832 | { SOMERI_SL12, NES_WRITEONLY(someri_l_w), NES_NOACCESS, NES_WRITEONLY(someri_w), NULL, NULL, mmc3_irq }, |
| r8383 | r8384 | |
| 12082 | 11838 | { TXC_22211A, {txc_22211_l_w, txc_22211_l_r}, NES_NOACCESS, NES_WRITEONLY(txc_22211_w), NULL, NULL, NULL }, |
| 12083 | 11839 | { TXC_22211B, {txc_22211_l_w, txc_22211_l_r}, NES_NOACCESS, NES_WRITEONLY(txc_22211b_w), NULL, NULL, NULL }, |
| 12084 | 11840 | { TXC_22211C, {txc_22211_l_w, txc_22211c_l_r}, NES_NOACCESS, NES_WRITEONLY(txc_22211_w), NULL, NULL, NULL }, |
| 12085 | | { TXC_TW, NES_WRITEONLY(txc_tw_l_w), NES_WRITEONLY(txc_tw_m_w), NES_WRITEONLY(txc_tw_w), NULL, NULL, mmc3_irq }, |
| 11841 | { TXC_TW, NES_WRITEONLY(txc_tw_l_w), NES_WRITEONLY(txc_tw_m_w), NES_WRITEONLY(txrom_w), NULL, NULL, mmc3_irq }, |
| 12086 | 11842 | { TXC_STRIKEWOLF, NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(txc_strikewolf_w), NULL, NULL, NULL }, |
| 12087 | 11843 | { TXC_MXMDHTWO, NES_READONLY(txc_mxmdhtwo_l_r), NES_NOACCESS, NES_WRITEONLY(txc_mxmdhtwo_w), NULL, NULL, NULL }, |
| 12088 | 11844 | { WAIXING_TYPE_A, NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(waixing_a_w), NULL, NULL, mmc3_irq }, |
| r8383 | r8384 | |
| 12118 | 11874 | { UNL_XZY, NES_WRITEONLY(unl_xzy_l_w), NES_NOACCESS, NES_NOACCESS, NULL, NULL, NULL }, |
| 12119 | 11875 | { UNL_RACERMATE, NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(unl_racmate_w), NULL, NULL, NULL }, |
| 12120 | 11876 | { UNL_STUDYNGAME, NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(sng32_w), NULL, NULL, NULL }, |
| 12121 | | { UNL_603_5052, {unl_6035052_extra_w, unl_6035052_extra_r}, {unl_6035052_extra_w, unl_6035052_extra_r}, NES_WRITEONLY(txrom_w), NULL, NULL, NULL }, |
| 11877 | { UNL_603_5052, {unl_6035052_extra_w, unl_6035052_extra_r}, {unl_6035052_extra_w, unl_6035052_extra_r}, NES_WRITEONLY(txrom_w), NULL, NULL, mmc3_irq }, |
| 12122 | 11878 | { UNL_EDU2K, NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(edu2k_w), NULL, NULL, NULL }, |
| 12123 | 11879 | { UNL_SHJY3, NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(shjy3_w), NULL, NULL, shjy3_irq }, |
| 12124 | 11880 | { UNL_H2288, {h2288_l_w, h2288_l_r}, NES_NOACCESS, NES_WRITEONLY(h2288_w), NULL, NULL, mmc3_irq }, |
| r8383 | r8384 | |
| 12131 | 11887 | { BTL_SMB3, NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(btl_smb3_w), NULL, NULL, btl_smb3_irq }, |
| 12132 | 11888 | { BTL_SUPERBROS11, NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(btl_smb11_w), NULL, NULL, mmc3_irq }, |
| 12133 | 11889 | { BTL_TOBIDASE, NES_WRITEONLY(btl_tobi_l_w), NES_NOACCESS, NES_NOACCESS, NULL, NULL, NULL }, |
| 12134 | | { BTL_PIKACHUY2K, NES_NOACCESS, {btl_pika_y2k_m_w, btl_pika_y2k_m_r}, NES_WRITEONLY(btl_pika_y2k_w), NULL, NULL, NULL }, |
| 11890 | { BTL_PIKACHUY2K, NES_NOACCESS, {btl_pika_y2k_m_w, btl_pika_y2k_m_r}, NES_WRITEONLY(btl_pika_y2k_w), NULL, NULL, mmc3_irq }, |
| 12135 | 11891 | { WHIRLWIND_2706, NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(whirl2706_w), NULL, NULL, NULL }, |
| 12136 | 11892 | // |
| 12137 | 11893 | { BMC_190IN1, NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(bmc_190in1_w), NULL, NULL, NULL }, |
| r8383 | r8384 | |
| 12160 | 11916 | { BMC_22GAMES, NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(bmc_22g_w), NULL, NULL, NULL }, |
| 12161 | 11917 | { BMC_20IN1, NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(bmc_20in1_w), NULL, NULL, NULL }, |
| 12162 | 11918 | { BMC_110IN1, NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(bmc_110in1_w), NULL, NULL, NULL }, |
| 12163 | | { BMC_64IN1NR, NES_WRITEONLY(bmc_64in1nr_l_w), NES_NOACCESS, NES_WRITEONLY(bmc_64in1nr_w), NULL, NULL, NULL }, |
| 12164 | | { BMC_S24IN1SC03, NES_WRITEONLY(bmc_s24in1sc03_l_w), NES_NOACCESS, NES_WRITEONLY(bmc_s24in1sc03_w), NULL, NULL, mmc3_irq }, |
| 11919 | { BMC_64IN1NR, NES_WRITEONLY(bmc_64in1nr_l_w), NES_NOACCESS, NES_WRITEONLY(bmc_64in1nr_w), NULL, NULL, NULL }, |
| 11920 | { BMC_S24IN1SC03, NES_WRITEONLY(bmc_s24in1sc03_l_w), NES_NOACCESS, NES_WRITEONLY(txrom_w), NULL, NULL, mmc3_irq }, |
| 12165 | 11921 | { BMC_HIK8IN1, NES_NOACCESS, NES_WRITEONLY(bmc_hik8_m_w), NES_WRITEONLY(txrom_w), NULL, NULL, mmc3_irq }, |
| 12166 | 11922 | { BMC_SUPERHIK_4IN1, NES_NOACCESS, NES_WRITEONLY(bmc_hik4in1_m_w), NES_WRITEONLY(txrom_w), NULL, NULL, mmc3_irq }, |
| 12167 | 11923 | { BMC_SUPERBIG_7IN1, NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(bmc_sbig7_w), NULL, NULL, mmc3_irq }, |
| r8383 | r8384 | |
| 12278 | 12034 | |
| 12279 | 12035 | switch (state->pcb_id) |
| 12280 | 12036 | { |
| 12037 | case STD_TXSROM: |
| 12038 | state->mmc3_chr_cb = txsrom_chr_cb; |
| 12039 | break; |
| 12040 | case GOUDER_37017: |
| 12041 | state->mmc3_prg_cb = gouder_sf4_prg_cb; |
| 12042 | break; |
| 12043 | case KASING_BOARD: |
| 12044 | state->mmc3_prg_cb = kasing_prg_cb; |
| 12045 | break; |
| 12046 | case REXSOFT_DBZ5: |
| 12047 | state->mmc3_chr_cb = rex_dbz_chr_cb; |
| 12048 | break; |
| 12049 | case TXC_TW: |
| 12050 | state->mmc3_prg_cb = txc_tw_prg_cb; |
| 12051 | break; |
| 12281 | 12052 | case WAIXING_TYPE_A: |
| 12282 | 12053 | state->mmc3_chr_cb = waixing_a_chr_cb; |
| 12283 | 12054 | break; |
| r8383 | r8384 | |
| 12332 | 12103 | state->mmc3_prg_cb = fk23c_prg_cb; |
| 12333 | 12104 | state->mmc3_chr_cb = fk23c_chr_cb; |
| 12334 | 12105 | break; |
| 12106 | case BMC_S24IN1SC03: |
| 12107 | state->mmc3_prg_cb = bmc_s24in1sc03_prg_cb; |
| 12108 | state->mmc3_chr_cb = bmc_s24in1sc03_chr_cb; |
| 12109 | break; |
| 12335 | 12110 | case BMC_PJOY84: |
| 12336 | 12111 | state->mmc3_prg_cb = pjoy84_prg_cb; |
| 12337 | 12112 | state->mmc3_chr_cb = pjoy84_chr_cb; |