src/mess/machine/nes.c
| r10035 | r10036 | |
| 50 | 50 | /* Brutal hack put in as a consequence of the new memory system; we really need to fix the NES code */ |
| 51 | 51 | memory_install_readwrite_bank(space, 0x0000, 0x07ff, 0, 0x1800, "bank10"); |
| 52 | 52 | |
| 53 | | memory_install_readwrite8_handler(cpu_get_address_space(machine->device("ppu"), ADDRESS_SPACE_PROGRAM), 0, 0x1fff, 0, 0, nes_chr_r, nes_chr_w); |
| 54 | | memory_install_readwrite8_handler(cpu_get_address_space(machine->device("ppu"), ADDRESS_SPACE_PROGRAM), 0x2000, 0x3eff, 0, 0, nes_nt_r, nes_nt_w); |
| 53 | memory_install_readwrite8_handler(device_get_space(machine->device("ppu"), ADDRESS_SPACE_PROGRAM), 0, 0x1fff, 0, 0, nes_chr_r, nes_chr_w); |
| 54 | memory_install_readwrite8_handler(device_get_space(machine->device("ppu"), ADDRESS_SPACE_PROGRAM), 0x2000, 0x3eff, 0, 0, nes_nt_r, nes_nt_w); |
| 55 | 55 | |
| 56 | 56 | memory_set_bankptr(machine, "bank10", state->rom); |
| 57 | 57 | |
| r10035 | r10036 | |
| 710 | 710 | state->prg_chunks = mapint3; |
| 711 | 711 | state->chr_chunks = mapint4; |
| 712 | 712 | logerror("NES.HSI info: %d %d %d %d\n", mapint1, mapint2, mapint3, mapint4); |
| 713 | | // printf("NES.HSI info: %d %d %d %d\n", mapint1, mapint2, mapint3, mapint4); |
| 713 | // mame_printf_error("NES.HSI info: %d %d %d %d\n", mapint1, mapint2, mapint3, mapint4); |
| 714 | 714 | goodcrcinfo = 1; |
| 715 | 715 | state->ines20 = 0; |
| 716 | 716 | } |
| r10035 | r10036 | |
| 725 | 725 | } |
| 726 | 726 | |
| 727 | 727 | state->hard_mirroring = (local_options & 0x01) ? PPU_MIRROR_VERT : PPU_MIRROR_HORZ; |
| 728 | | // printf("%s\n", state->hard_mirroring & 0x01 ? "Vertical" : "Horizontal"); |
| 728 | // mame_printf_error("%s\n", state->hard_mirroring & 0x01 ? "Vertical" : "Horizontal"); |
| 729 | 729 | state->battery = local_options & 0x02; |
| 730 | 730 | state->trainer = local_options & 0x04; |
| 731 | 731 | state->four_screen_vram = local_options & 0x08; |
| r10035 | r10036 | |
| 930 | 930 | if (prgout) |
| 931 | 931 | { |
| 932 | 932 | fwrite(&state->rom[0x10000], 1, 0x4000 * state->prg_chunks, prgout); |
| 933 | | printf("Created PRG chunk\n"); |
| 933 | mame_printf_error("Created PRG chunk\n"); |
| 934 | 934 | } |
| 935 | 935 | |
| 936 | 936 | fclose(prgout); |
| r10035 | r10036 | |
| 940 | 940 | logerror("**\n"); |
| 941 | 941 | logerror("Mapper: %d\n", state->mapper); |
| 942 | 942 | logerror("PRG chunks: %02x, size: %06x\n", state->prg_chunks, 0x4000 * state->prg_chunks); |
| 943 | | // printf("Mapper: %d\n", state->mapper); |
| 944 | | // printf("PRG chunks: %02x, size: %06x\n", state->prg_chunks, 0x4000 * state->prg_chunks); |
| 943 | // mame_printf_error("Mapper: %d\n", state->mapper); |
| 944 | // mame_printf_error("PRG chunks: %02x, size: %06x\n", state->prg_chunks, 0x4000 * state->prg_chunks); |
| 945 | 945 | |
| 946 | 946 | /* Read in any chr chunks */ |
| 947 | 947 | if (state->chr_chunks > 0) |
| r10035 | r10036 | |
| 962 | 962 | if (chrout) |
| 963 | 963 | { |
| 964 | 964 | fwrite(state->vrom, 1, 0x2000 * state->chr_chunks, chrout); |
| 965 | | printf("Created CHR chunk\n"); |
| 965 | mame_printf_error("Created CHR chunk\n"); |
| 966 | 966 | } |
| 967 | 967 | fclose(chrout); |
| 968 | 968 | } |
| r10035 | r10036 | |
| 970 | 970 | |
| 971 | 971 | logerror("CHR chunks: %02x, size: %06x\n", state->chr_chunks, 0x2000 * state->chr_chunks); |
| 972 | 972 | logerror("**\n"); |
| 973 | | // printf("CHR chunks: %02x, size: %06x\n", state->chr_chunks, 0x2000 * state->chr_chunks); |
| 974 | | // printf("**\n"); |
| 973 | // mame_printf_error("CHR chunks: %02x, size: %06x\n", state->chr_chunks, 0x2000 * state->chr_chunks); |
| 974 | // mame_printf_error("**\n"); |
| 975 | 975 | } |
| 976 | 976 | else if ((magic[0] == 'U') && (magic[1] == 'N') && (magic[2] == 'I') && (magic[3] == 'F')) /* If header starts with 'UNIF' it is UNIF */ |
| 977 | 977 | { |
| r10035 | r10036 | |
| 1285 | 1285 | if (prgout) |
| 1286 | 1286 | { |
| 1287 | 1287 | fwrite(&state->rom[0x10000], 1, 0x4000 * state->prg_chunks, prgout); |
| 1288 | | printf("Created PRG chunk\n"); |
| 1288 | mame_printf_error("Created PRG chunk\n"); |
| 1289 | 1289 | } |
| 1290 | 1290 | |
| 1291 | 1291 | fclose(prgout); |
| r10035 | r10036 | |
| 1303 | 1303 | if (chrout) |
| 1304 | 1304 | { |
| 1305 | 1305 | fwrite(state->vrom, 1, 0x2000 * state->chr_chunks, chrout); |
| 1306 | | printf("Created CHR chunk\n"); |
| 1306 | mame_printf_error("Created CHR chunk\n"); |
| 1307 | 1307 | } |
| 1308 | 1308 | fclose(chrout); |
| 1309 | 1309 | } |
| r10035 | r10036 | |
| 1442 | 1442 | state->vrc_ls_prg_a = nes_cart_get_line(image.get_feature("vrc2-pin3")); |
| 1443 | 1443 | state->vrc_ls_prg_b = nes_cart_get_line(image.get_feature("vrc2-pin4")); |
| 1444 | 1444 | state->vrc_ls_chr = (nes_cart_get_line(image.get_feature("vrc2-pin21")) != 10) ? 1 : 0; |
| 1445 | | // printf("VRC-2, pin3: A%d, pin4: A%d, pin21: %s\n", state->vrc_ls_prg_a, state->vrc_ls_prg_b, state->vrc_ls_chr ? "NC" : "A10"); |
| 1445 | // mame_printf_error("VRC-2, pin3: A%d, pin4: A%d, pin21: %s\n", state->vrc_ls_prg_a, state->vrc_ls_prg_b, state->vrc_ls_chr ? "NC" : "A10"); |
| 1446 | 1446 | } |
| 1447 | 1447 | |
| 1448 | 1448 | if (state->pcb_id == KONAMI_VRC4) |
| 1449 | 1449 | { |
| 1450 | 1450 | state->vrc_ls_prg_a = nes_cart_get_line(image.get_feature("vrc4-pin3")); |
| 1451 | 1451 | state->vrc_ls_prg_b = nes_cart_get_line(image.get_feature("vrc4-pin4")); |
| 1452 | | // printf("VRC-4, pin3: A%d, pin4: A%d\n", state->vrc_ls_prg_a, state->vrc_ls_prg_b); |
| 1452 | // mame_printf_error("VRC-4, pin3: A%d, pin4: A%d\n", state->vrc_ls_prg_a, state->vrc_ls_prg_b); |
| 1453 | 1453 | } |
| 1454 | 1454 | |
| 1455 | 1455 | if (state->pcb_id == KONAMI_VRC6) |
| 1456 | 1456 | { |
| 1457 | 1457 | state->vrc_ls_prg_a = nes_cart_get_line(image.get_feature("vrc6-pin9")); |
| 1458 | 1458 | state->vrc_ls_prg_b = nes_cart_get_line(image.get_feature("vrc6-pin10")); |
| 1459 | | // printf("VRC-6, pin9: A%d, pin10: A%d\n", state->vrc_ls_prg_a, state->vrc_ls_prg_b); |
| 1459 | // mame_printf_error("VRC-6, pin9: A%d, pin10: A%d\n", state->vrc_ls_prg_a, state->vrc_ls_prg_b); |
| 1460 | 1460 | } |
| 1461 | 1461 | |
| 1462 | 1462 | /* Check for other misc board variants */ |
| r10035 | r10036 | |
| 1483 | 1483 | |
| 1484 | 1484 | #if 0 |
| 1485 | 1485 | if (state->pcb_id == UNSUPPORTED_BOARD) |
| 1486 | | printf("This board (%s) is currently not supported by MESS\n", image.get_feature("pcb")); |
| 1487 | | printf("PCB Feature: %s\n", image.get_feature("pcb")); |
| 1488 | | printf("PRG chunks: %d\n", state->prg_chunks); |
| 1489 | | printf("CHR chunks: %d\n", state->chr_chunks); |
| 1490 | | printf("VRAM: Present %s, size: %d\n", state->vram_chunks ? "Yes" : "No", vram_size); |
| 1491 | | printf("NVWRAM: Present %s, size: %d\n", state->battery ? "Yes" : "No", state->battery_size); |
| 1492 | | printf("WRAM: Present %s, size: %d\n", state->prg_ram ? "Yes" : "No", state->wram_size); |
| 1486 | mame_printf_error("This board (%s) is currently not supported by MESS\n", image.get_feature("pcb")); |
| 1487 | mame_printf_error("PCB Feature: %s\n", image.get_feature("pcb")); |
| 1488 | mame_printf_error("PRG chunks: %d\n", state->prg_chunks); |
| 1489 | mame_printf_error("CHR chunks: %d\n", state->chr_chunks); |
| 1490 | mame_printf_error("VRAM: Present %s, size: %d\n", state->vram_chunks ? "Yes" : "No", vram_size); |
| 1491 | mame_printf_error("NVWRAM: Present %s, size: %d\n", state->battery ? "Yes" : "No", state->battery_size); |
| 1492 | mame_printf_error("WRAM: Present %s, size: %d\n", state->prg_ram ? "Yes" : "No", state->wram_size); |
| 1493 | 1493 | #endif |
| 1494 | 1494 | } |
| 1495 | 1495 | |
src/mess/machine/snescart.c
| r10035 | r10036 | |
| 573 | 573 | { |
| 574 | 574 | state->has_addon_chip = HAS_SA1; |
| 575 | 575 | supported_type = 0; |
| 576 | | printf("This is a SA-1 type game, currently unsupported by the driver"); |
| 576 | mame_printf_error("This is a SA-1 type game, currently unsupported by the driver\n"); |
| 577 | 577 | } |
| 578 | 578 | break; |
| 579 | 579 | |
| r10035 | r10036 | |
| 765 | 765 | else |
| 766 | 766 | memcpy(ROM, image.get_software_region("rom") + offset, state->cart_size - offset); |
| 767 | 767 | |
| 768 | | if (SNES_CART_DEBUG) printf("size %08X\n", state->cart_size - offset); |
| 768 | if (SNES_CART_DEBUG) mame_printf_error("size %08X\n", state->cart_size - offset); |
| 769 | 769 | |
| 770 | 770 | /* First, look if the cart is HiROM or LoROM (and set snes_cart accordingly) */ |
| 771 | 771 | int_header_offs = snes_find_hilo_mode(image, ROM, offset, 0); |
| r10035 | r10036 | |
| 824 | 824 | st_bios = 1; |
| 825 | 825 | } |
| 826 | 826 | |
| 827 | | if (SNES_CART_DEBUG) printf("mode %d\n", state->cart[0].mode); |
| 827 | if (SNES_CART_DEBUG) mame_printf_error("mode %d\n", state->cart[0].mode); |
| 828 | 828 | |
| 829 | 829 | /* FIXME: Insert crc check here? */ |
| 830 | 830 | |
| r10035 | r10036 | |
| 832 | 832 | total_blocks = ((state->cart_size - offset) / (state->cart[0].mode & 0xa5 ? 0x8000 : 0x10000)); |
| 833 | 833 | read_blocks = 0; |
| 834 | 834 | |
| 835 | | if (SNES_CART_DEBUG) printf("blocks %d\n", total_blocks); |
| 835 | if (SNES_CART_DEBUG) mame_printf_error("blocks %d\n", total_blocks); |
| 836 | 836 | |
| 837 | 837 | /* Loading all the data blocks from cart, we only partially cover banks 0x00 to 0x7f. Therefore, we |
| 838 | 838 | * have to mirror the blocks until we reach the end. E.g. for a 11Mbits image (44 blocks), we proceed |
| r10035 | r10036 | |
| 978 | 978 | case SNES_MODE_ST: |
| 979 | 979 | if (!st_bios) |
| 980 | 980 | { |
| 981 | | printf("This is a Sufami Turbo data cart and cannot be loaded for snes/snespal in MESS.\n"); |
| 982 | | printf("Please use snesst driver to load it, instead.\n"); |
| 981 | mame_printf_error("This is a Sufami Turbo data cart and cannot be loaded for snes/snespal in MESS.\n"); |
| 982 | mame_printf_error("Please use snesst driver to load it, instead.\n"); |
| 983 | 983 | return IMAGE_INIT_FAIL; |
| 984 | 984 | } |
| 985 | 985 | else |
| r10035 | r10036 | |
| 1007 | 1007 | case SNES_MODE_BSLO: |
| 1008 | 1008 | case SNES_MODE_BSHI: |
| 1009 | 1009 | /* not handled yet */ |
| 1010 | | printf("This is a BS-X Satellaview image: MESS does not support these yet, sorry.\n"); |
| 1010 | mame_printf_error("This is a BS-X Satellaview image: MESS does not support these yet, sorry.\n"); |
| 1011 | 1011 | #if 0 |
| 1012 | 1012 | // shall we force incompatibility of flash carts without a base unit? |
| 1013 | 1013 | if (!has_bsx_slot) |
| 1014 | 1014 | { |
| 1015 | | printf("This is a BS-X flash cart and cannot be loaded in snes/snespal.\n"); |
| 1016 | | // printf("Please use snesbsx driver to load it, instead.\n"); |
| 1015 | mame_printf_error("This is a BS-X flash cart and cannot be loaded in snes/snespal.\n"); |
| 1016 | // mame_printf_error("Please use snesbsx driver to load it, instead.\n"); |
| 1017 | 1017 | return IMAGE_INIT_FAIL; |
| 1018 | 1018 | } |
| 1019 | 1019 | #endif |
| r10035 | r10036 | |
| 1144 | 1144 | else |
| 1145 | 1145 | memcpy(ROM, image.get_software_region("rom") + offset, state->cart_size - offset); |
| 1146 | 1146 | |
| 1147 | | if (SNES_CART_DEBUG) printf("size %08X\n", state->cart_size - offset); |
| 1147 | if (SNES_CART_DEBUG) mame_printf_error("size %08X\n", state->cart_size - offset); |
| 1148 | 1148 | |
| 1149 | 1149 | /* Detect Sufami Turbo carts */ |
| 1150 | 1150 | if (!memcmp(ROM, "BANDAI SFC-ADX", 14)) |
| r10035 | r10036 | |
| 1155 | 1155 | } |
| 1156 | 1156 | else |
| 1157 | 1157 | { |
| 1158 | | printf("This is not a Sufami Turbo data pack.\n"); |
| 1159 | | printf("This image cannot be loaded in snesst (Use snes or snespal drivers, instead).\n"); |
| 1158 | mame_printf_error("This is not a Sufami Turbo data pack.\n"); |
| 1159 | mame_printf_error("This image cannot be loaded in snesst (Use snes or snespal drivers, instead).\n"); |
| 1160 | 1160 | return IMAGE_INIT_FAIL; |
| 1161 | 1161 | } |
| 1162 | 1162 | |
| 1163 | 1163 | if (st_bios == 1) |
| 1164 | 1164 | { |
| 1165 | | printf("This is the Sufami Turbo BIOS and not a Sufami Turbo data pack.\n"); |
| 1166 | | printf("This image cannot be loaded in snesst.\n"); |
| 1165 | mame_printf_error("This is the Sufami Turbo BIOS and not a Sufami Turbo data pack.\n"); |
| 1166 | mame_printf_error("This image cannot be loaded in snesst.\n"); |
| 1167 | 1167 | return IMAGE_INIT_FAIL; |
| 1168 | 1168 | } |
| 1169 | 1169 | |
| r10035 | r10036 | |
| 1174 | 1174 | read_blocks = 0; |
| 1175 | 1175 | |
| 1176 | 1176 | if (SNES_CART_DEBUG) |
| 1177 | | printf("blocks %d\n", total_blocks); |
| 1177 | mame_printf_error("blocks %d\n", total_blocks); |
| 1178 | 1178 | |
| 1179 | 1179 | // actually load the cart |
| 1180 | 1180 | while (read_blocks < 32 && read_blocks < total_blocks) |
| r10035 | r10036 | |
| 1235 | 1235 | else |
| 1236 | 1236 | memcpy(ROM, image.get_software_region("rom") + offset, state->cart_size - offset); |
| 1237 | 1237 | |
| 1238 | | if (SNES_CART_DEBUG) printf("size %08X\n", state->cart_size - offset); |
| 1238 | if (SNES_CART_DEBUG) mame_printf_error("size %08X\n", state->cart_size - offset); |
| 1239 | 1239 | |
| 1240 | 1240 | /* First, look if the cart is HiROM or LoROM (and set snes_cart accordingly) */ |
| 1241 | 1241 | int_header_offs = snes_find_hilo_mode(image, ROM, offset, 0); |
| r10035 | r10036 | |
| 1271 | 1271 | } |
| 1272 | 1272 | else |
| 1273 | 1273 | { |
| 1274 | | printf("This is not a BS-X compatible cart.\n"); |
| 1275 | | printf("This image cannot be loaded in the first cartslot of snesbsx.\n"); |
| 1274 | mame_printf_error("This is not a BS-X compatible cart.\n"); |
| 1275 | mame_printf_error("This image cannot be loaded in the first cartslot of snesbsx.\n"); |
| 1276 | 1276 | return IMAGE_INIT_FAIL; |
| 1277 | 1277 | } |
| 1278 | 1278 | |
| r10035 | r10036 | |
| 1283 | 1283 | total_blocks = (state->cart_size - offset) / 0x8000; |
| 1284 | 1284 | read_blocks = 0; |
| 1285 | 1285 | |
| 1286 | | if (SNES_CART_DEBUG) printf("blocks %d\n", total_blocks); |
| 1286 | if (SNES_CART_DEBUG) mame_printf_error("blocks %d\n", total_blocks); |
| 1287 | 1287 | |
| 1288 | 1288 | // actually load the cart |
| 1289 | 1289 | while (read_blocks < 64 && read_blocks < total_blocks) |
| r10035 | r10036 | |
| 1335 | 1335 | else |
| 1336 | 1336 | memcpy(ROM, image.get_software_region("rom") + offset, state->cart_size - offset); |
| 1337 | 1337 | |
| 1338 | | if (SNES_CART_DEBUG) printf("size %08X\n", state->cart_size - offset); |
| 1338 | if (SNES_CART_DEBUG) mame_printf_error("size %08X\n", state->cart_size - offset); |
| 1339 | 1339 | |
| 1340 | 1340 | /* First, look if the cart is HiROM or LoROM (and set snes_cart accordingly) */ |
| 1341 | 1341 | int_header_offs = snes_find_hilo_mode(image, ROM, offset, 1); |
| r10035 | r10036 | |
| 1357 | 1357 | |
| 1358 | 1358 | if (state->cart[1].mode != SNES_MODE_BSX) |
| 1359 | 1359 | { |
| 1360 | | printf("This is not a BS-X flash cart.\n"); |
| 1361 | | printf("This image cannot be loaded in the second cartslot of snesbsx.\n"); |
| 1360 | mame_printf_error("This is not a BS-X flash cart.\n"); |
| 1361 | mame_printf_error("This image cannot be loaded in the second cartslot of snesbsx.\n"); |
| 1362 | 1362 | return IMAGE_INIT_FAIL; |
| 1363 | 1363 | } |
| 1364 | 1364 | |