From 023dc919e7ceaacf94e992eb7faba89a214bb878 Mon Sep 17 00:00:00 2001 From: AJR Date: Mon, 8 Jan 2024 21:56:09 -0500 Subject: neogeo/prot_cmc.cpp: Use util::sum16_creator --- src/devices/bus/neogeo/prot_cmc.cpp | 16 +++------------- src/devices/bus/neogeo/prot_cmc.h | 1 - 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/src/devices/bus/neogeo/prot_cmc.cpp b/src/devices/bus/neogeo/prot_cmc.cpp index 5ddda3f2ada..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 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); diff --git a/src/devices/bus/neogeo/prot_cmc.h b/src/devices/bus/neogeo/prot_cmc.h index 2853c71aa8f..d1f8dd10b9a 100644 --- a/src/devices/bus/neogeo/prot_cmc.h +++ b/src/devices/bus/neogeo/prot_cmc.h @@ -59,7 +59,6 @@ public: void sfix_decrypt(uint8_t* rom, uint32_t rom_size, uint8_t* fixed, uint32_t fixed_size); - uint16_t generate_cs16(uint8_t *rom, int size); int m1_address_scramble(int address, uint16_t key); void cmc50_m1_decrypt(uint8_t* romcrypt, uint32_t romcrypt_size, uint8_t* romaudio, uint32_t romaudio_size); -- cgit v1.2.3