Author Topic: New FBA SMA decryption  (Read 5798 times)

Offline FerchogtX

  • FBNeo Dev
  • ******
  • Posts: 375
  • Karma: +7/-0
  • FB Alpha Team ;)
    • FB Alpha Plus! Web Site
New FBA SMA decryption
« on: April 04, 2006, 08:33:34 PM »
If you want the mame code for fba:
Code: [Select]
static void Neo_SMA_SNK_1999(int nGame)
{
const unsigned char tbl0[5][16] = {
{ 13, 7, 3, 0, 9, 4, 5, 6, 1, 12, 8, 14, 10, 11, 2, 15 }, // kof99
{ 13, 12, 14, 10, 8, 2, 3, 1, 5, 9, 11, 4, 15, 0, 6, 7 }, // garou
{ 14, 5, 1, 11, 7, 4, 10, 15, 3, 12, 8, 13, 0, 2, 9, 6 }, // garouo
{ 4, 11, 14, 3, 1, 13, 0, 7, 2, 8, 12, 15, 10, 9, 5, 6 }, // mslug3
{ 12, 8, 11, 3, 15, 14, 7, 0, 10, 13, 6, 5, 9, 2, 1, 4 }, // kof2000
};

const unsigned char tbl1[5][2][18] = {
{ { 11, 6, 14, 17, 16, 5, 8, 10, 12, 0, 4, 3, 2, 7, 9, 15, 13, 1 }, { 17, 16, 15, 14, 13, 12, 11, 10, 6, 2, 4, 9, 8, 3, 1, 7, 0, 5 }, }, // kof99
{ { 4, 5, 16, 14, 7, 9, 6, 13, 17, 15, 3, 1, 2, 12, 11, 8, 10, 0 }, { 17, 16, 15, 14, 9, 4, 8, 3, 13, 6, 2, 7, 0, 12, 1, 11, 10, 5 }, }, // garou
{ { 5, 16, 11, 2, 6, 7, 17, 3, 12, 8, 14, 4, 0, 9, 1, 10, 15, 13 }, { 17, 16, 15, 14, 12, 8, 1, 7, 11, 3, 13, 10, 6, 9, 5, 4, 0, 2 }, }, // garouo
{ { 15, 2, 1, 13, 3, 0, 9, 6, 16, 4, 11, 5, 7, 12, 17, 14, 10, 8 }, { 17, 16, 15, 2, 11, 0, 14, 6, 4, 13, 8, 9, 3, 10, 7, 5, 12, 1 }, }, // mslug3
{ { 8, 4, 15, 13, 3, 14, 16, 2, 6, 17, 7, 12, 10, 0, 5, 11, 1, 9 }, { 17, 16, 15, 14, 13, 12, 11, 10, 4, 1, 3, 8, 6, 2, 7, 0, 9, 5 }, }, // kof2000
};

int nOffset[5][2] = {
{ 0x700000, 0x600000 }, // kof99
{ 0x710000, 0x800000 }, // garou
{ 0x7F8000, 0x800000 }, // garouo
{ 0x5D0000, 0x800000 }, // mslug3
{ 0x73A000, 0x63A000 }, // kof2000
};

int nBufSize[5] = { 0x000800, 0x008000, 0x008000, 0x010000, 0x000800 };

for (int i = 0; i < 0x800000 / 2; i++) {
((unsigned short*)(Neo68KROM + 0x100000))[i] = BITSWAP16(((unsigned short*)(Neo68KROM + 0x100000))[i], tbl0[nGame][0], tbl0[nGame][1], tbl0[nGame][2], tbl0[nGame][3], tbl0[nGame][4], tbl0[nGame][5], tbl0[nGame][6], tbl0[nGame][7], tbl0[nGame][8], tbl0[nGame][9], tbl0[nGame][10], tbl0[nGame][11], tbl0[nGame][12], tbl0[nGame][13], tbl0[nGame][14], tbl0[nGame][15]);
}

for (int i = 0; i < 0x0C0000 / 2; i++) {
((unsigned short*)Neo68KROM)[i] = ((unsigned short*)Neo68KROM)[nOffset[nGame][0] / 2 + BITSWAP24(i, 23, 22, 21, 20, 19, 18, tbl1[nGame][0][0], tbl1[nGame][0][1], tbl1[nGame][0][2], tbl1[nGame][0][3], tbl1[nGame][0][4], tbl1[nGame][0][5], tbl1[nGame][0][6], tbl1[nGame][0][7], tbl1[nGame][0][8], tbl1[nGame][0][9], tbl1[nGame][0][10], tbl1[nGame][0][11], tbl1[nGame][0][12], tbl1[nGame][0][13], tbl1[nGame][0][14], tbl1[nGame][0][15], tbl1[nGame][0][16], tbl1[nGame][0][17])];
}

for (int i = 0; i < nOffset[nGame][1] / 2; i += nBufSize[nGame] / 2) {
unsigned short *nBuffer = (unsigned short*)malloc((nBufSize[nGame] / 2) * sizeof(unsigned short));
memcpy(nBuffer, &((unsigned short*)(Neo68KROM + 0x100000))[i], nBufSize[nGame]);
for (int j = 0; j < nBufSize[nGame] / 2; j++) {
((unsigned short*)(Neo68KROM + 0x100000))[i + j] = nBuffer[BITSWAP24(j, 23, 22, 21, 20, 19, 18, tbl1[nGame][1][0], tbl1[nGame][1][1], tbl1[nGame][1][2], tbl1[nGame][1][3], tbl1[nGame][1][4], tbl1[nGame][1][5], tbl1[nGame][1][6], tbl1[nGame][1][7], tbl1[nGame][1][8], tbl1[nGame][1][9], tbl1[nGame][1][10], tbl1[nGame][1][11], tbl1[nGame][1][12], tbl1[nGame][1][13], tbl1[nGame][1][14], tbl1[nGame][1][15], tbl1[nGame][1][16], tbl1[nGame][1][17])];
}
}
}
if you saw the mame code, you surely know how to use this one XD
See ya!!! :wink:
EDIT: Tested and fixed code bugs... now works at 100%
« Last Edit: April 05, 2006, 10:47:15 PM by FerchogtX »

Good and evil co-exist because of the balance, lies are not part of it...

FB Alpha Plus! site infos updated, see the latest info clicking on my profile link...

Offline iq_132

  • Administrator
  • *****
  • Posts: 3724
  • Karma: +411/-0
  • Definitely not Dink!
    • NeoSource
Re: New FBA SMA decryption
« Reply #1 on: April 04, 2006, 09:21:18 PM »
Interesting :)  This should be nice for people whole like more unified code :)


Offline FerchogtX

  • FBNeo Dev
  • ******
  • Posts: 375
  • Karma: +7/-0
  • FB Alpha Team ;)
    • FB Alpha Plus! Web Site
Re: New FBA SMA decryption
« Reply #2 on: April 04, 2006, 10:57:43 PM »
Thanks man... I hope this can be usefull... BTW... is it working correctly? I haven't tested this yet...
See ya!!!! :biggrin:

Good and evil co-exist because of the balance, lies are not part of it...

FB Alpha Plus! site infos updated, see the latest info clicking on my profile link...

Offline FerchogtX

  • FBNeo Dev
  • ******
  • Posts: 375
  • Karma: +7/-0
  • FB Alpha Team ;)
    • FB Alpha Plus! Web Site
Re: New FBA SMA decryption
« Reply #3 on: April 05, 2006, 10:49:08 PM »
Tested... now the code works, just fixed some details and declarations

Good and evil co-exist because of the balance, lies are not part of it...

FB Alpha Plus! site infos updated, see the latest info clicking on my profile link...

Offline James33

  • Expert
  • *****
  • Posts: 532
  • Karma: +3/-0
  • The Mame Man
    • Emulation Zone
Re: New FBA SMA decryption
« Reply #4 on: April 06, 2006, 10:15:23 AM »
Nice work there :)
IQ Forum Member