summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Ivan Vangelista <mesgnet@yahoo.it>2020-08-28 22:48:03 +0200
committer Ivan Vangelista <mesgnet@yahoo.it>2020-08-28 22:48:03 +0200
commite46f2d614ba4979bd1d3b0322cb29e4c8e005d6e (patch)
tree1a87f0e511250020b944edc144762f0d9a9c801c
parent4fb852792641094a0282bcd90776b5fcb01be540 (diff)
snesb.cpp: simplified decryption for wldgunsb [iq_132]
-rw-r--r--src/mame/drivers/snesb.cpp34
1 files changed, 10 insertions, 24 deletions
diff --git a/src/mame/drivers/snesb.cpp b/src/mame/drivers/snesb.cpp
index c3a2097e0a8..146ae743b56 100644
--- a/src/mame/drivers/snesb.cpp
+++ b/src/mame/drivers/snesb.cpp
@@ -33,7 +33,7 @@ TODO:
- legendsb : unknown dipswitches
- rushbets : dipswitches (stored at memory locations $785006 and $785008)
- venom : gfx glitches on second level
- - wldgunsb : check if it doesn't work because of protection or some bug in the decryption
+ - wldgunsb : protection simulation
***************************************************************************
@@ -1363,44 +1363,30 @@ void snesb_state::init_wldgunsb()
uint8_t *dst = memregion("user3")->base();
static uint8_t address_tab_high[0x20] = {
- // 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f
- 0x0b, 0x1d, 0x05, 0x15, 0x09, 0x19, 0x04, 0x13, 0x02, 0x1f, 0x07, 0x17, 0x0d, 0x11, 0x0a, 0x1a, // unkn
- 0x14, 0x0e, 0x18, 0x06, 0x1e, 0x01, 0x10, 0x0c, 0x1b, 0x0f, 0x16, 0x00, 0x12, 0x08, 0x1c, 0x03 // 0x10
+ 0x0b, 0x1d, 0x05, 0x15, 0x09, 0x19, 0x04, 0x13, 0x02, 0x1f, 0x07, 0x17, 0x0d, 0x11, 0x0a, 0x1a,
+ 0x14, 0x0e, 0x18, 0x06, 0x1e, 0x01, 0x10, 0x0c, 0x1b, 0x0f, 0x16, 0x00, 0x12, 0x08, 0x1c, 0x03
};
static uint8_t address_tab_low[0x40] = {
- // 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f
0x14, 0x1d, 0x11, 0x3c, 0x0a, 0x29, 0x2d, 0x2e, 0x30, 0x32, 0x16, 0x36, 0x05, 0x25, 0x26, 0x37,
0x20, 0x21, 0x27, 0x28, 0x33, 0x34, 0x23, 0x12, 0x1e, 0x1f, 0x3b, 0x24, 0x2c, 0x35, 0x38, 0x39,
0x3d, 0x0c, 0x2a, 0x0d, 0x22, 0x18, 0x19, 0x1a, 0x03, 0x08, 0x04, 0x3a, 0x0b, 0x0f, 0x15, 0x17,
0x1b, 0x13, 0x00, 0x1c, 0x2b, 0x01, 0x06, 0x2f, 0x07, 0x09, 0x02, 0x31, 0x10, 0x0e, 0x3f, 0x3e
};
- static uint8_t data_table[0x100] = {
- // 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f
- 0x35, 0xad, 0x85, 0xb5, 0x95, 0x05, 0x25, 0xa5, 0x0d, 0xbd, 0x3d, 0x1d, 0x8d, 0x15, 0x2d, 0x9d, // 0x00
- 0x73, 0xeb, 0xc3, 0xf3, 0xd3, 0x43, 0x63, 0xe3, 0x4b, 0xfb, 0x7b, 0x5b, 0xcb, 0x53, 0x6b, 0xdb, // 0x10
- 0x70, 0xe8, 0xc0, 0xf0, 0xd0, 0x40, 0x60, 0xe0, 0x48, 0xf8, 0x78, 0x58, 0xc8, 0x50, 0x68, 0xd8, // 0x20
- 0x75, 0xed, 0xc5, 0xf5, 0xd5, 0x45, 0x65, 0xe5, 0x4d, 0xfd, 0x7d, 0x5d, 0xcd, 0x55, 0x6d, 0xdd, // 0x30
- 0x74, 0xec, 0xc4, 0xf4, 0xd4, 0x44, 0x64, 0xe4, 0x4c, 0xfc, 0x7c, 0x5c, 0xcc, 0x54, 0x6c, 0xdc, // 0x40
- 0x30, 0xa8, 0x80, 0xb0, 0x90, 0x00, 0x20, 0xa0, 0x08, 0xb8, 0x38, 0x18, 0x88, 0x10, 0x28, 0x98, // 0x50
- 0x31, 0xa9, 0x81, 0xb1, 0x91, 0x01, 0x21, 0xa1, 0x09, 0xb9, 0x39, 0x19, 0x89, 0x11, 0x29, 0x99, // 0x60
- 0x71, 0xe9, 0xc1, 0xf1, 0xd1, 0x41, 0x61, 0xe1, 0x49, 0xf9, 0x79, 0x59, 0xc9, 0x51, 0x69, 0xd9, // 0x70
- 0x32, 0xaa, 0x82, 0xb2, 0x92, 0x02, 0x22, 0xa2, 0x0a, 0xba, 0x3a, 0x1a, 0x8a, 0x12, 0x2a, 0x9a, // 0x80
- 0x77, 0xef, 0xc7, 0xf7, 0xd7, 0x47, 0x67, 0xe7, 0x4f, 0xff, 0x7f, 0x5f, 0xcf, 0x57, 0x6f, 0xdf, // 0x90
- 0x37, 0xaf, 0x87, 0xb7, 0x97, 0x07, 0x27, 0xa7, 0x0f, 0xbf, 0x3f, 0x1f, 0x8f, 0x17, 0x2f, 0x9f, // 0xa0
- 0x36, 0xae, 0x86, 0xb6, 0x96, 0x06, 0x26, 0xa6, 0x0e, 0xbe, 0x3e, 0x1e, 0x8e, 0x16, 0x2e, 0x9e, // 0xb0
- 0x72, 0xea, 0xc2, 0xf2, 0xd2, 0x42, 0x62, 0xe2, 0x4a, 0xfa, 0x7a, 0x5a, 0xca, 0x52, 0x6a, 0xda, // 0xc0
- 0x34, 0xac, 0x84, 0xb4, 0x94, 0x04, 0x24, 0xa4, 0x0c, 0xbc, 0x3c, 0x1c, 0x8c, 0x14, 0x2c, 0x9c, // 0xd0
- 0x33, 0xab, 0x83, 0xb3, 0x93, 0x03, 0x23, 0xa3, 0x0b, 0xbb, 0x3b, 0x1b, 0x8b, 0x13, 0x2b, 0x9b, // 0xe0
- 0x76, 0xee, 0xc6, 0xf6, 0xd6, 0x46, 0x66, 0xe6, 0x4e, 0xfe, 0x7e, 0x5e, 0xce, 0x56, 0x6e, 0xde // 0xf0
+ static const uint8_t data_low[16] = {
+ 0x30, 0xa8, 0x80, 0xb0, 0x90, 0x00, 0x20, 0xa0, 0x08, 0xb8, 0x38, 0x18, 0x88, 0x10, 0x28, 0x98
+ };
+
+ static const uint8_t data_high[16] = {
+ 0x05, 0x43, 0x40, 0x45, 0x44, 0x00, 0x01, 0x41, 0x02, 0x47, 0x07, 0x06, 0x42, 0x04, 0x03, 0x46
};
for (int i = 0; i < 0x100000; i++)
{
int j = (address_tab_high[i >> 15] << 15) + (i & 0x7fc0) + address_tab_low[i & 0x3f];
- dst[i] = data_table[src[j]];
+ dst[i] = data_high[src[j]>>4] | data_low[src[j]&0xf];
if (i >= 0x00000 && i < 0x10000) {
dst[i] = bitswap<8>(dst[i], 3, 1, 7, 0, 6, 4, 5, 2) ^ 0xff;