diff options
Diffstat (limited to 'src/mame/machine/cps2crypt.cpp')
-rw-r--r-- | src/mame/machine/cps2crypt.cpp | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/src/mame/machine/cps2crypt.cpp b/src/mame/machine/cps2crypt.cpp index 0171570fbd9..efdff933a9f 100644 --- a/src/mame/machine/cps2crypt.cpp +++ b/src/mame/machine/cps2crypt.cpp @@ -134,7 +134,7 @@ static const int fn2_groupB[8] = { 3, 5, 9, 10, 8, 15, 12, 11 }; struct sbox { - const UINT8 table[64]; + const uint8_t table[64]; const int inputs[6]; // positions of the inputs bits, -1 means no input except from key const int outputs[2]; // positions of the output bits }; @@ -144,8 +144,8 @@ struct sbox // following one struct optimised_sbox { - UINT8 input_lookup[256]; - UINT8 output[64]; + uint8_t input_lookup[256]; + uint8_t output[64]; }; @@ -442,7 +442,7 @@ static const struct sbox fn2_r4_boxes[4] = /******************************************************************************/ -static UINT8 fn(UINT8 in, const struct optimised_sbox *sboxes, UINT32 key) +static uint8_t fn(uint8_t in, const struct optimised_sbox *sboxes, uint32_t key) { const struct optimised_sbox *sbox1 = &sboxes[0]; const struct optimised_sbox *sbox2 = &sboxes[1]; @@ -460,7 +460,7 @@ static UINT8 fn(UINT8 in, const struct optimised_sbox *sboxes, UINT32 key) // srckey is the 64-bit master key (2x32 bits) // dstkey will contain the 96-bit key for the 1st FN (4x24 bits) -static void expand_1st_key(UINT32 *dstkey, const UINT32 *srckey) +static void expand_1st_key(uint32_t *dstkey, const uint32_t *srckey) { static const int bits[96] = { @@ -495,7 +495,7 @@ static void expand_1st_key(UINT32 *dstkey, const UINT32 *srckey) // srckey is the 64-bit master key (2x32 bits) XORed with the subkey // dstkey will contain the 96-bit key for the 2nd FN (4x24 bits) -static void expand_2nd_key(UINT32 *dstkey, const UINT32 *srckey) +static void expand_2nd_key(uint32_t *dstkey, const uint32_t *srckey) { static const int bits[96] = { @@ -532,7 +532,7 @@ static void expand_2nd_key(UINT32 *dstkey, const UINT32 *srckey) // seed is the 16-bit seed generated by the first FN // subkey will contain the 64-bit key to be XORed with the master key // for the 2nd FN (2x32 bits) -static void expand_subkey(UINT32* subkey, UINT16 seed) +static void expand_subkey(uint32_t* subkey, uint16_t seed) { // Note that each row of the table is a permutation of the seed bits. static const int bits[64] = @@ -553,12 +553,12 @@ static void expand_subkey(UINT32* subkey, UINT16 seed) -static UINT16 feistel(UINT16 val, const int *bitsA, const int *bitsB, +static uint16_t feistel(uint16_t val, const int *bitsA, const int *bitsB, const struct optimised_sbox* boxes1, const struct optimised_sbox* boxes2, const struct optimised_sbox* boxes3, const struct optimised_sbox* boxes4, - UINT32 key1, UINT32 key2, UINT32 key3, UINT32 key4) + uint32_t key1, uint32_t key2, uint32_t key3, uint32_t key4) { - UINT8 l = BITSWAP8(val, bitsB[7],bitsB[6],bitsB[5],bitsB[4],bitsB[3],bitsB[2],bitsB[1],bitsB[0]); - UINT8 r = BITSWAP8(val, bitsA[7],bitsA[6],bitsA[5],bitsA[4],bitsA[3],bitsA[2],bitsA[1],bitsA[0]); + uint8_t l = BITSWAP8(val, bitsB[7],bitsB[6],bitsB[5],bitsB[4],bitsB[3],bitsB[2],bitsB[1],bitsB[0]); + uint8_t r = BITSWAP8(val, bitsA[7],bitsA[6],bitsA[5],bitsA[4],bitsA[3],bitsA[2],bitsA[1],bitsA[0]); l ^= fn(r, boxes1, key1); r ^= fn(l, boxes2, key2); @@ -586,7 +586,7 @@ static UINT16 feistel(UINT16 val, const int *bitsA, const int *bitsB, -static int extract_inputs(UINT32 val, const int *inputs) +static int extract_inputs(uint32_t val, const int *inputs) { int i; int res = 0; @@ -632,10 +632,10 @@ static void optimise_sboxes(struct optimised_sbox* out, const struct sbox* in) -static void cps2_decrypt(running_machine &machine, UINT16 *rom, UINT16 *dec, int length, const UINT32 *master_key, UINT32 lower_limit, UINT32 upper_limit) +static void cps2_decrypt(running_machine &machine, uint16_t *rom, uint16_t *dec, int length, const uint32_t *master_key, uint32_t lower_limit, uint32_t upper_limit) { int i; - UINT32 key1[4]; + uint32_t key1[4]; struct optimised_sbox sboxes1[4*4]; struct optimised_sbox sboxes2[4*4]; @@ -664,9 +664,9 @@ static void cps2_decrypt(running_machine &machine, UINT16 *rom, UINT16 *dec, int for (i = 0; i < 0x10000; ++i) { int a; - UINT16 seed; - UINT32 subkey[2]; - UINT32 key2[4]; + uint16_t seed; + uint32_t subkey[2]; + uint32_t key2[4]; if ((i & 0xff) == 0) { @@ -732,8 +732,8 @@ static void cps2_decrypt(running_machine &machine, UINT16 *rom, UINT16 *dec, int struct game_keys { const char *name; /* game driver name */ - const UINT32 keys[2]; - UINT32 upper_limit; + const uint32_t keys[2]; + uint32_t upper_limit; }; @@ -745,9 +745,9 @@ DRIVER_INIT_MEMBER(cps_state,cps2crypt) { if (m_region_key) { - UINT32 key[2]; - UINT32 lower; - UINT32 upper; + uint32_t key[2]; + uint32_t lower; + uint32_t upper; int b; @@ -787,6 +787,6 @@ DRIVER_INIT_MEMBER(cps_state,cps2crypt) logerror("cps2 decrypt 0x%08x,0x%08x,0x%08x,0x%08x\n", key[0], key[1], lower, upper); // we have a proper key so use it to decrypt - cps2_decrypt(machine(), (UINT16 *)memregion("maincpu")->base(), m_decrypted_opcodes, memregion("maincpu")->bytes(), key, lower / 2, upper / 2); + cps2_decrypt(machine(), (uint16_t *)memregion("maincpu")->base(), m_decrypted_opcodes, memregion("maincpu")->bytes(), key, lower / 2, upper / 2); } } |