Author Topic: Lansquenet 2004 (Hack)  (Read 8668 times)

Offline iq_132

  • Administrator
  • *****
  • Posts: 3724
  • Karma: +411/-0
  • Definitely not Dink!
    • NeoSource
Lansquenet 2004 (Hack)
« on: December 04, 2005, 02:07:55 PM »
OK, got this working, JImmy_Page tipped me off about it being a problem with the cx_decrypt ;)

Code: [Select]
// Lansquenet 2004 (hack)

static struct BurnRomInfo lans2004RomDesc[] = {
{ "lnsq-p1.bin",  0x200000, 0xb40a879a,    1 | BRF_ESS | BRF_PRG }, //  0 68K code
{ "lnsq-p21.bin", 0x200000, 0xecdb2d42,    1 | BRF_ESS | BRF_PRG }, //  1
{ "lnsq-p22.bin", 0x200000, 0xfac5e2e7,    1 | BRF_ESS | BRF_PRG }, //  2

{ "lnsq-s1.bin",  0x020000, 0x39e82897,    2 | BRF_GRA }, //  3 Text data

{ "lnsq-c1.bin",  0x800000, 0xb83de59f,    3 | BRF_GRA }, //  4 Sprite data
{ "lnsq-c2.bin",  0x800000, 0xe08969fd,    3 | BRF_GRA }, //  5
{ "lnsq-c3.bin",  0x800000, 0x013f2cda,    3 | BRF_GRA }, //  6
{ "lnsq-c4.bin",  0x800000, 0xd8c3a758,    3 | BRF_GRA }, //  7
{ "lnsq-c5.bin",  0x800000, 0x75500b82,    3 | BRF_GRA }, //  8
{ "lnsq-c6.bin",  0x800000, 0x670ac13b,    3 | BRF_GRA }, //  9

{ "246-m1.bin",   0x020000, 0xd0604ad1,    4 | BRF_ESS | BRF_PRG }, //  10 Z80 code

{ "lnsq-v1.bin",  0x400000, 0x4408ebc3,    5 | BRF_SND }, //  11 Sound data
{ "lnsq-v2.bin",  0x400000, 0x3d953975,    5 | BRF_SND }, //  12
{ "lnsq-v3.bin",  0x200000, 0x437d1d8e,    5 | BRF_SND }, //  13
};

STDROMPICKEXT(lans2004, lans2004, neogeo);
STD_ROM_FN(lans2004);

static void lans2004_sx_decrypt()
{
unsigned char* tmp = (unsigned char*)malloc(0x20000);
if (tmp) {
memcpy( tmp, NeoTextROM + 0x20000, 0x20000 );
// descrambling the S1 by dorriGa
for ( int j = 0; j < 0x20000; j += 0x000010 ) {
memcpy( NeoTextROM + 0x20000 + j, tmp + j + 0x000008, 8);
memcpy( NeoTextROM + 0x20000 + j + 0x000008, tmp + j, 8);
}
}
free( tmp );
}

// Thanks to Jimmy_Page for the fix :)
static void lans2004_cx_decrypt()
{
unsigned char* src = NeoSpriteROM;
unsigned char* cso = (unsigned char*)malloc(128);
for (int i=0;i < 0x3000000; i+=128){
memcpy(cso, src+i+64, 64);
memcpy(cso+64, src+i, 64);
memcpy(NeoSpriteROM+i, cso, 128);
}
free(cso);
}

// Thanks to Razoola for the info
static void lans2004_px_decrypt()
{
int i;
unsigned char *src = Neo68KROM;
unsigned short *rom = (unsigned short*)Neo68KROM;
unsigned char *dst = (unsigned char*)malloc(0x600000);

if (dst) {
int sec[8] = { 0x3, 0x8, 0x7, 0xC, 0x1, 0xA, 0x6, 0xD };

for (i = 0; i < 8; i++)
memcpy (dst + i * 0x20000, src + sec[i] * 0x20000, 0x20000);

memcpy (dst + 0x0BBB00, src + 0x045B00, 0x001710);
memcpy (dst + 0x02FFF0, src + 0x1A92BE, 0x000010);
memcpy (dst + 0x100000, src + 0x200000, 0x400000);
memcpy (src, dst, 0x600000);
free (dst);
}

for (i = 0xBBB00/2; i < 0xBE000/2; i++) {
if ((((rom[i]&0xFFBF)==0x4EB9) || ((rom[i]&0xFFBF)==0x43B9)) && (rom[i+1]==0x0000)) {
rom[i + 1] = 0x000B;
rom[i + 2] += 0x6000;
}
}

for (i = 0; i < 0x100000/2; i++)
if ((rom[i]==0xBE79) && (rom[i+1]==0x0010)) rom[i+3] = 0x6002;

rom[0x2D15C/2] = 0x000B;
rom[0x2D15E/2] = 0xBB00;

lans2004_sx_decrypt();
lans2004_cx_decrypt();
}

static int lans2004Init()
{
extern unsigned char* YM2610ADPCMAROM;

pNeoInitCallback = lans2004_px_decrypt;

int nRet = NeoInit();

if (nRet == 0) {
for (int i = 0; i < 0xA00000; i++)
YM2610ADPCMAROM[i] = BITSWAP08(YM2610ADPCMAROM[i], 0, 1, 5, 4, 3, 2, 6, 7);
}
return nRet;
}

struct BurnDriver BurnDrvlans2004 = {
"lans2004", "shocktr2", "neogeo", "2002",
"Lansquenet 2004 (hack)\0", NULL, "Saurus", "Neo Geo",
NULL, NULL, NULL, NULL,
BDF_GAME_WORKING | BDF_CLONE, 2, HARDWARE_SNK_NEOGEO,
NULL, lans2004RomInfo, lans2004RomName, neogeoInputInfo, neogeoDIPInfo,
lans2004Init, NeoExit, NeoFrame, NeoRender, NeoScan, &NeoRecalcPalette,
nNeoScreenWidth, 224, 4, 3
};


Offline James33

  • Expert
  • *****
  • Posts: 532
  • Karma: +3/-0
  • The Mame Man
    • Emulation Zone
Re: Lansquenet 2004 (Hack)
« Reply #1 on: December 04, 2005, 08:15:33 PM »
Cool . I would never of thought it was the C decrypt that caused that problem .
Do you think that fix would good on mame as well ?
« Last Edit: December 04, 2005, 10:25:41 PM by James33 »
IQ Forum Member

Offline iq_132

  • Administrator
  • *****
  • Posts: 3724
  • Karma: +411/-0
  • Definitely not Dink!
    • NeoSource
Re: Lansquenet 2004 (Hack)
« Reply #2 on: December 04, 2005, 08:53:17 PM »
It didn't affect the mame driver.  :biggrin:


Offline James33

  • Expert
  • *****
  • Posts: 532
  • Karma: +3/-0
  • The Mame Man
    • Emulation Zone
Re: Lansquenet 2004 (Hack)
« Reply #3 on: December 04, 2005, 09:05:01 PM »
Yeah I know But it might a better decrypt code ?
IQ Forum Member

Offline Shoometsu

  • Jr. Member
  • **
  • Posts: 66
  • Karma: +0/-0
  • I finally have an avatar XD
Re: Lansquenet 2004 (Hack)
« Reply #4 on: December 05, 2005, 09:44:41 AM »
wow, is that a christmas gift? 4 new drivers at the same time XD thanks...
<- Who are you?

Offline iq_132

  • Administrator
  • *****
  • Posts: 3724
  • Karma: +411/-0
  • Definitely not Dink!
    • NeoSource
Re: Lansquenet 2004 (Hack)
« Reply #5 on: December 06, 2005, 09:33:29 AM »
Yeah I know But it might a better decrypt code ?
Yeah, in some ways it is.  It takes a lot less ram to descramble the Cx, but the code itself is longer.

wow, is that a christmas gift? 4 new drivers at the same time XD thanks...
lol, pretty much every time a new Neo-Geo rom is released it's like Christmas around here :)


Offline James33

  • Expert
  • *****
  • Posts: 532
  • Karma: +3/-0
  • The Mame Man
    • Emulation Zone
Re: Lansquenet 2004 (Hack)
« Reply #6 on: December 07, 2005, 03:03:18 AM »
Yeah, in some ways it is.  It takes a lot less ram to descramble the Cx, but the code itself is longer.

Well I am useing it anyway :)

Code: [Select]
DRIVER_INIT( lans2004 )
{
int i;
UINT8 *src = memory_region( REGION_CPU1 );
UINT16 *rom = (UINT16*)memory_region( REGION_CPU1 );
UINT8 *dst = malloc(0x600000);
UINT8 *snd_rom = memory_region( REGION_SOUND1 );
unsigned char* gfx = memory_region( REGION_GFX3 );
unsigned char* cso = (unsigned char*)malloc(128);

if (dst) {
int sec[8] = { 0x3, 0x8, 0x7, 0xC, 0x1, 0xA, 0x6, 0xD };

for (i = 0; i < 8; i++)
memcpy (dst + i * 0x20000, src + sec[i] * 0x20000, 0x20000);

memcpy (dst + 0x0BBB00, src + 0x045B00, 0x001710);
memcpy (dst + 0x02FFF0, src + 0x1A92BE, 0x000010);
memcpy (dst + 0x100000, src + 0x200000, 0x400000);
memcpy (src, dst, 0x600000);
free (dst);
}

for (i = 0xBBB00/2; i < 0xBE000/2; i++) {
if ((((rom[i]&0xFFBF)==0x4EB9) || ((rom[i]&0xFFBF)==0x43B9)) && (rom[i+1]==0x0000)) {
rom[i + 1] = 0x000B;
rom[i + 2] += 0x6000;
}
}

rom[0x2D15C/2] = 0x000B;
rom[0x2D15E/2] = 0xBB00;
rom[0x2D1E4/2] = 0x6002;
rom[0x2EA7E/2] = 0x6002;
rom[0xBBCD0/2] = 0x6002;
rom[0xBBDF2/2] = 0x6002;
rom[0xBBE42/2] = 0x6002;

for (i = 0; i < 0xA00000; i++)
snd_rom[i] = BITSWAP8(snd_rom[i], 0, 1, 5, 4, 3, 2, 6, 7);

for (i = 0; i < 0x3000000; i+=128){
memcpy(cso, gfx+i+64, 64);
memcpy(cso+64, gfx+i, 64);
memcpy(gfx+i, cso, 128);
}
free(cso);

kog_sx_decrypt();
init_neogeo();
}
IQ Forum Member

Offline iq_132

  • Administrator
  • *****
  • Posts: 3724
  • Karma: +411/-0
  • Definitely not Dink!
    • NeoSource
Re: Lansquenet 2004 (Hack)
« Reply #7 on: December 08, 2005, 11:54:28 AM »
I modified the driver in the first post a bit, now these are no longer required :)
Code: [Select]
      rom[0x2D1E4/2] = 0x6002;
      rom[0x2EA7E/2] = 0x6002;
      rom[0xBBCD0/2] = 0x6002;
      rom[0xBBDF2/2] = 0x6002;
      rom[0xBBE42/2] = 0x6002;


Offline James33

  • Expert
  • *****
  • Posts: 532
  • Karma: +3/-0
  • The Mame Man
    • Emulation Zone
Re: Lansquenet 2004 (Hack)
« Reply #8 on: December 08, 2005, 11:07:45 PM »
The changes work ok on Mame as well :)
IQ Forum Member