mirror of
https://github.com/holub/mame
synced 2025-04-22 08:22:15 +03:00
funworld/supercrd.cpp: addressed feedback and some tweaks to the XOR tables
This commit is contained in:
parent
a361756811
commit
5116119a61
@ -187,7 +187,7 @@
|
||||
// configurable logging
|
||||
#define LOG_UNKOPCODES (1U << 1)
|
||||
|
||||
#define VERBOSE (LOG_GENERAL | LOG_UNKOPCODES)
|
||||
//#define VERBOSE (LOG_GENERAL | LOG_UNKOPCODES)
|
||||
|
||||
#include "logmacro.h"
|
||||
|
||||
@ -325,8 +325,8 @@ uint32_t supercrd_state::screen_update(screen_device &screen, bitmap_rgb32 &bitm
|
||||
|
||||
uint8_t supercrd_state::decrypted_opcodes_r(offs_t offset)
|
||||
{
|
||||
uint8_t const data { m_maincpu->space(AS_PROGRAM).read_byte(offset) };
|
||||
uint8_t const row = (BIT(data, 4) + (BIT(data, 6) << 1) + (BIT(data, 7) << 2));
|
||||
uint8_t const data = m_maincpu->space(AS_PROGRAM).read_byte(offset);
|
||||
uint8_t const row = bitswap<3>(data, 7, 6, 4);
|
||||
uint8_t const xor_v = data & 0x07;
|
||||
|
||||
if (((m_decode_table[offset & 0x03][row][xor_v]) == 0x00) && (data != 0xc5) && (data != 0xcd) && (data != 0xe5) && (data != 0xed))
|
||||
@ -589,7 +589,7 @@ ROM_END
|
||||
Encryption observations:
|
||||
- only opcodes are encrypted;
|
||||
- there are 4 XOR tables selected by bits 0 and 1 of the address;
|
||||
- within a table the XOR is chosen depending on bits 0, 1, 2, 3, 4, 6, 7 of the data. Only bit 5 isn't considered;
|
||||
- within a table the XOR is chosen depending on bits 0, 1, 2, 4, 6, 7 of the data. Only bit 3 and 5 aren't considered;
|
||||
- XOR values only affect bits 0, 1, 4 and 6;
|
||||
- the games use different XOR tables;
|
||||
- code is mostly the same for both games up to 0x96e, then they start differing significantly;
|
||||
@ -605,7 +605,7 @@ void supercrd_state::init_supercrd() // TODO: check unknown opcodes
|
||||
{
|
||||
{
|
||||
{ 0x13, 0x11, 0x01, 0x11, 0x02, 0x50, 0x51, 0x43 }, // 0x0x and 0x2x
|
||||
{ 0x11, unkn, 0x50, 0x43, 0x10, 0x43, unkn, 0x02 }, // 0x1x and 0x3x
|
||||
{ 0x11, 0x52, 0x50, 0x43, 0x10, 0x43, unkn, 0x02 }, // 0x1x and 0x3x
|
||||
{ 0x51, 0x13, 0x02, 0x12, 0x43, 0x00, unkn, 0x51 }, // 0x4x and 0x6x
|
||||
{ 0x50, 0x53, 0x13, 0x00, 0x51, 0x12, 0x02, 0x11 }, // 0x5x and 0x7x
|
||||
{ 0x12, unkn, 0x40, 0x51, 0x03, 0x50, unkn, 0x12 }, // 0x8x and 0xax
|
||||
@ -645,6 +645,17 @@ void supercrd_state::init_supercrd() // TODO: check unknown opcodes
|
||||
}
|
||||
};
|
||||
|
||||
for (int j = 0; j < 0x04; j++)
|
||||
{
|
||||
for (int i = 0; i < 0x100; i++)
|
||||
{
|
||||
uint8_t const row = bitswap<3>(i, 7, 6, 4);
|
||||
uint8_t const xor_v = i & 0x07;
|
||||
if ((i & 0x28) == 0)
|
||||
LOGUNKOPCODES("table: %01x encop: %02x; decop: %02x\n", j, i, i ^ xor_table[j][row][xor_v]);
|
||||
}
|
||||
}
|
||||
|
||||
std::copy(&xor_table[0][0][0], &xor_table[0][0][0] + 0x04 * 0x08 * 0x08, &m_decode_table[0][0][0]);
|
||||
}
|
||||
|
||||
@ -656,46 +667,57 @@ void supercrd_state::init_fruitstr() // TODO: check unknown opcodes
|
||||
{
|
||||
{
|
||||
{ 0x40, 0x52, 0x53, 0x11, 0x40, 0x02, 0x10, 0x40 }, // 0x0x and 0x2x
|
||||
{ 0x11, 0x00, 0x02, 0x43, 0x40, 0x10, 0x00, 0x40 }, // 0x1x and 0x3x
|
||||
{ 0x40, 0x03, 0x10, 0x02, 0x02, unkn, 0x40, 0x43 }, // 0x4x and 0x6x
|
||||
{ 0x11, 0x00, 0x02, 0x43, 0x40, 0x10, 0x02, 0x40 }, // 0x1x and 0x3x
|
||||
{ 0x40, 0x03, 0x10, 0x02, 0x02, 0x00, 0x40, 0x43 }, // 0x4x and 0x6x
|
||||
{ 0x52, 0x12, 0x41, 0x50, 0x02, 0x00, 0x43, 0x40 }, // 0x5x and 0x7x
|
||||
{ unkn, unkn, 0x12, 0x42, 0x51, 0x53, unkn, unkn }, // 0x8x and 0xax
|
||||
{ 0x03, unkn, 0x12, 0x42, 0x51, 0x53, unkn, 0x01 }, // 0x8x and 0xax
|
||||
{ 0x43, 0x52, 0x50, 0x01, unkn, unkn, 0x00, unkn }, // 0x9x and 0xbx
|
||||
{ 0x11, 0x13, 0x53, 0x50, 0x02, 0x00, 0x41, unkn }, // 0xcx and 0xex
|
||||
{ 0x50, 0x50, 0x12, unkn, unkn, 0x41, 0x43, 0x40 } // 0xdx and 0xfx
|
||||
},
|
||||
{
|
||||
{ 0x42, 0x11, 0x51, 0x51, 0x51, 0x12, 0x10, unkn }, // 0x0x and 0x2x
|
||||
{ 0x42, 0x11, 0x51, 0x51, 0x51, 0x12, 0x10, 0x03 }, // 0x0x and 0x2x
|
||||
{ 0x40, 0x12, 0x13, 0x01, 0x42, 0x10, 0x51, 0x03 }, // 0x1x and 0x3x
|
||||
{ 0x01, 0x41, 0x11, 0x41, 0x42, unkn, 0x41, 0x01 }, // 0x4x and 0x6x
|
||||
{ 0x01, 0x41, 0x11, 0x41, 0x42, 0x00, 0x41, 0x01 }, // 0x4x and 0x6x
|
||||
{ unkn, 0x40, 0x41, 0x02, 0x41, 0x11, 0x02, 0x00 }, // 0x5x and 0x7x
|
||||
{ 0x12, 0x41, 0x50, 0x42, 0x00, unkn, unkn, 0x03 }, // 0x8x and 0xax
|
||||
{ 0x11, 0x40, 0x02, unkn, 0x52, 0x43, 0x00, 0x40 }, // 0x9x and 0xbx
|
||||
{ 0x51, 0x52, unkn, unkn, 0x51, 0x00, 0x00, 0x50 }, // 0xcx and 0xex
|
||||
{ 0x13, unkn, 0x10, 0x00, unkn, 0x01, 0x51, 0x02 } // 0xdx and 0xfx
|
||||
{ 0x51, 0x52, unkn, unkn, 0x51, 0x00, 0x40, 0x50 }, // 0xcx and 0xex
|
||||
{ 0x13, unkn, 0x10, 0x00, 0x40, 0x01, 0x51, 0x02 } // 0xdx and 0xfx
|
||||
},
|
||||
{
|
||||
{ unkn, 0x12, 0x50, 0x41, 0x53, 0x11, 0x03, 0x51 }, // 0x0x and 0x2x
|
||||
{ 0x11, 0x40, 0x10, 0x01, 0x01, 0x11, 0x42, 0x01 }, // 0x1x and 0x3x
|
||||
{ 0x00, 0x51, unkn, 0x40, 0x03, 0x00, unkn, 0x50 }, // 0x4x and 0x6x
|
||||
{ 0x00, 0x51, unkn, 0x40, 0x03, 0x00, 0x02, 0x50 }, // 0x4x and 0x6x
|
||||
{ 0x03, 0x51, 0x43, 0x03, 0x01, 0x53, 0x10, 0x50 }, // 0x5x and 0x7x
|
||||
{ 0x51, 0x40, 0x51, 0x02, 0x02, 0x52, 0x40, 0x13 }, // 0x8x and 0xax
|
||||
{ unkn, unkn, 0x02, 0x41, 0x42, 0x51, unkn, 0x13 }, // 0x9x and 0xbx
|
||||
{ 0xff, unkn, 0x02, 0x41, 0x42, 0x51, unkn, 0x13 }, // 0x9x and 0xbx
|
||||
{ 0x51, 0x52, 0x02, 0x00, unkn, 0x00, 0x53, 0x13 }, // 0xcx and 0xex
|
||||
{ unkn, 0x13, unkn, 0x41, 0x53, 0x42, 0x40, 0x02 } // 0xdx and 0xfx
|
||||
{ 0x53, 0x13, 0x50, 0x41, 0x53, 0x42, 0x40, 0x02 } // 0xdx and 0xfx
|
||||
},
|
||||
{
|
||||
{ 0x41, 0x13, 0x13, 0x13, 0x42, 0x42, 0x10, 0x01 }, // 0x0x and 0x2x
|
||||
{ 0x52, 0x12, 0x13, 0x53, 0x41, 0x10, 0x02, 0x41 }, // 0x1x and 0x3x
|
||||
{ 0x11, 0x13, 0x11, 0x50, 0x40, 0x00, unkn, 0x10 }, // 0x4x and 0x6x
|
||||
{ 0x52, 0x01, 0x11, 0x53, 0x10, 0x01, unkn, 0x50 }, // 0x5x and 0x7x
|
||||
{ 0x03, unkn, 0x52, 0x02, 0x42, 0x10, 0x52, unkn }, // 0x8x and 0xax
|
||||
{ 0x01, 0x01, 0x52, 0x40, 0x11, unkn, unkn, unkn }, // 0x9x and 0xbx
|
||||
{ 0x53, 0x43, 0x13, unkn, unkn, 0x00, 0x51, 0x12 }, // 0xcx and 0xex
|
||||
{ 0x11, 0x13, 0x11, 0x50, 0x40, 0x00, 0x53, 0x10 }, // 0x4x and 0x6x
|
||||
{ 0x52, 0x01, 0x11, 0x53, 0x10, 0x01, 0x41, 0x50 }, // 0x5x and 0x7x
|
||||
{ 0x03, 0x01, 0x52, 0x02, 0x42, 0x10, 0x52, unkn }, // 0x8x and 0xax
|
||||
{ 0x01, 0x01, 0x52, 0x40, 0x11, 0x01, unkn, unkn }, // 0x9x and 0xbx
|
||||
{ 0x53, 0x43, 0x13, 0x51, unkn, 0x00, 0x51, 0x12 }, // 0xcx and 0xex
|
||||
{ 0x13, 0x03, 0x10, 0x12, 0x52, 0x03, 0x51, unkn } // 0xdx and 0xfx
|
||||
}
|
||||
};
|
||||
|
||||
for (int j = 0; j < 0x04; j++)
|
||||
{
|
||||
for (int i = 0; i < 0x100; i++)
|
||||
{
|
||||
uint8_t const row = bitswap<3>(i, 7, 6, 4);
|
||||
uint8_t const xor_v = i & 0x07;
|
||||
if ((i & 0x28) == 0)
|
||||
LOGUNKOPCODES("table: %01x encop: %02x; decop: %02x\n", j, i, i ^ xor_table[j][row][xor_v]);
|
||||
}
|
||||
}
|
||||
|
||||
std::copy(&xor_table[0][0][0], &xor_table[0][0][0] + 0x04 * 0x08 * 0x08, &m_decode_table[0][0][0]);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user