diff options
Diffstat (limited to 'src/devices/bus/neogeo/prot_cmc.cpp')
-rw-r--r-- | src/devices/bus/neogeo/prot_cmc.cpp | 39 |
1 files changed, 9 insertions, 30 deletions
diff --git a/src/devices/bus/neogeo/prot_cmc.cpp b/src/devices/bus/neogeo/prot_cmc.cpp index 77591827f54..ea085b8ea96 100644 --- a/src/devices/bus/neogeo/prot_cmc.cpp +++ b/src/devices/bus/neogeo/prot_cmc.cpp @@ -661,18 +661,6 @@ static const uint8_t m1_address_0_7_xor[256] = }; -/* The CMC50 hardware does a checksum of the first 64kb of the M1 rom, and - uses this checksum as the basis of the key with which to decrypt the rom */ -uint16_t cmc_prot_device::generate_cs16(uint8_t *rom, int size) -{ - uint16_t cs16 = 0x0000; - for (int i = 0; i < size; i++) - cs16 += rom[i]; - - return cs16 & 0xffff; -} - - int cmc_prot_device::m1_address_scramble(int address, uint16_t key) { const int p1[8][16] = { @@ -711,7 +699,9 @@ void cmc_prot_device::cmc50_m1_decrypt(uint8_t* romcrypt, uint32_t romcrypt_size std::vector<uint8_t> buffer(rom_size); - uint16_t key = generate_cs16(rom, 0x10000); + /* The CMC50 hardware does a checksum of the first 64kb of the M1 rom, and + uses this checksum as the basis of the key with which to decrypt the rom */ + uint16_t key = util::sum16_creator::simple(rom, 0x10000); //printf("key %04x\n",key); @@ -723,36 +713,25 @@ void cmc_prot_device::cmc50_m1_decrypt(uint8_t* romcrypt, uint32_t romcrypt_size memcpy(rom2,rom, 0x10000); memcpy(rom2 + 0x10000, rom, 0x80000); - #if 0 + if (0) { - FILE *fp; - const char *gamename = machine().system().name; - char filename[256]; - sprintf(filename, "%s_m1.dump", gamename); - - fp=fopen(filename, "w+b"); + auto filename = std::string(machine().system().name) + "_m1.dump"; + auto fp = fopen(filename.c_str(), "w+b"); if (fp) { fwrite(rom, rom_size, 1, fp); fclose(fp); } } - #endif - - #if 0 + if (0) { - FILE *fp; - const char *gamename = machine().system().name; - char filename[256]; - sprintf(filename, "%s_m1extra.dump", gamename); - - fp=fopen(filename, "w+b"); + auto filename = std::string(machine().system().name) + "_m1extra.dump"; + auto fp = fopen(filename.c_str(), "w+b"); if (fp) { fwrite(&rom[0xf800], 0x800, 1, fp); fclose(fp); } } - #endif } |