Author Topic: Fatfury2 - code update  (Read 16478 times)

Offline iq_132

  • Administrator
  • *****
  • Posts: 3728
  • Karma: +411/-0
  • Definitely not Dink!
    • NeoSource
Fatfury2 - code update
« on: January 04, 2006, 11:51:15 PM »
Here's an update to the fatfury2 code in mame:

Just replace your old fatfury2_protection_16_w with this one:

Code: [Select]
static WRITE16_HANDLER( fatfury2_protection_16_w )
{
switch (offset)
{
case 0x11112/2: /* data == 0x1111; expects 0xFF000000 back */
neogeo_prot_data = 0xFF000000;
break;

case 0x33332/2: /* data == 0x3333; expects 0x0000FFFF back */
neogeo_prot_data = 0x0000FFFF;
break;

case 0x44442/2: /* data == 0x4444; expects 0x00FF0000 back */
neogeo_prot_data = 0x00FF0000;
break;

case 0x55552/2: /* data == 0x5555; read back from 55550, ffff0, 00000, ff000 */
neogeo_prot_data = 0xff00ff00;
break;

case 0x56782/2: /* data == 0x1234; read back from 36000 *or* 36004 */
neogeo_prot_data = 0xf05a3601;
break;

case 0x42812/2: /* data == 0x1824; read back from 36008 *or* 3600c */
neogeo_prot_data = 0x81422418;
break;

case 0x55550/2:
case 0xffff0/2:
case 0xff000/2:
case 0x36000/2:
case 0x36004/2:
case 0x36008/2:
case 0x3600c/2:
neogeo_prot_data <<= 8;
break;

default:
logerror("unknown protection write at pc %06x, offset %08x, data %02x\n",activecpu_get_pc(),offset,data);
break;
}
}


These are no longer needed (they are hacks and should be removed)

Code: [Select]
UINT16 *mem16 = (UINT16 *)memory_region(REGION_CPU1);
mem16[0xb820/2] = 0x4e71;
mem16[0xb822/2] = 0x4e71;



Thanks to the FBA team for the code. :)  I just ported it over.


Offline James33

  • Expert
  • *****
  • Posts: 532
  • Karma: +3/-0
  • The Mame Man
    • Emulation Zone
Re: Fatfury2 - code update
« Reply #1 on: January 05, 2006, 12:44:12 AM »
This code works great :) Thanks IQ .
IQ Forum Member

Offline mamesick

  • Newbies
  • *
  • Posts: 17
  • Karma: +0/-0
  • MAME32FX
    • MAME32FX
Re: Fatfury2 - code update
« Reply #2 on: January 05, 2006, 03:33:53 AM »
Looks very good to me, but which are the benefits?  :confused:
JUst curious...

Offline iq_132

  • Administrator
  • *****
  • Posts: 3728
  • Karma: +411/-0
  • Definitely not Dink!
    • NeoSource
Re: Fatfury2 - code update
« Reply #3 on: January 05, 2006, 04:54:02 AM »
There's really only one benefit.  More accurate emulation.  Those patches that this allows you to
remove are hacks to work around the protection in the program roms.  This code emulates the protection.


Offline neo04

  • Jr. Member
  • **
  • Posts: 90
  • Karma: +1/-0
Re: Fatfury2 - code update
« Reply #4 on: January 05, 2006, 05:49:20 AM »
from iq's code:
Code: [Select]
case 0x11112/2: /* data == 0x1111; expects 0xFF000000 back */
prot_data = 0xFF000000;
break;

change prot_data to neogeo_prot_data

:)

Offline James33

  • Expert
  • *****
  • Posts: 532
  • Karma: +3/-0
  • The Mame Man
    • Emulation Zone
Re: Fatfury2 - code update
« Reply #5 on: January 05, 2006, 06:42:58 AM »
from iq's code:
Code: [Select]
case 0x11112/2: /* data == 0x1111; expects 0xFF000000 back */
prot_data = 0xFF000000;
break;

change prot_data to neogeo_prot_data

:)


And why is this needed ? 
Um never mind its already like that on the code I have here :)
« Last Edit: January 05, 2006, 06:45:38 AM by James33 »
IQ Forum Member

Offline Ashura-X

  • Member
  • ***
  • Posts: 138
  • Karma: +0/-0
Re: Fatfury2 - code update
« Reply #6 on: January 05, 2006, 05:17:38 PM »
Very nice !!! Much thx !!!! :biggrin:

Offline KingHanco

  • Sr. Member
  • ****
  • Posts: 401
  • Karma: +0/-4
  • "Special " Member
Re: Fatfury2 - code update
« Reply #7 on: January 06, 2006, 07:14:19 PM »
Thanks. Replace and done.

Code: [Select]
/************************ Fatal Fury 2 *************************
  todo: emulate, not patch!
***************************************************************/
int neogeo_prot_data;

static READ16_HANDLER( fatfury2_protection_16_r )
{
UINT16 res = (neogeo_prot_data >> 24) & 0xff;

switch (offset)
{
case 0x55550/2:
case 0xffff0/2:
case 0x00000/2:
case 0xff000/2:
case 0x36000/2:
case 0x36008/2:
return res;

case 0x36004/2:
case 0x3600c/2:
return ((res & 0xf0) >> 4) | ((res & 0x0f) << 4);

default:
logerror("unknown protection read at pc %06x, offset %08x\n",activecpu_get_pc(),offset<<1);
return 0;
}
}

static WRITE16_HANDLER( fatfury2_protection_16_w )
{
        switch (offset)
        {
               case 0x11112/2: /* data == 0x1111; expects 0xFF000000 back */
                       neogeo_prot_data = 0xFF000000;
                       break;

               case 0x33332/2: /* data == 0x3333; expects 0x0000FFFF back */
                       neogeo_prot_data = 0x0000FFFF;
                       break;

               case 0x44442/2: /* data == 0x4444; expects 0x00FF0000 back */
                       neogeo_prot_data = 0x00FF0000;
                       break;

               case 0x55552/2: /* data == 0x5555; read back from 55550, ffff0, 00000, ff000 */
                       neogeo_prot_data = 0xff00ff00;
                       break;

               case 0x56782/2: /* data == 0x1234; read back from 36000 *or* 36004 */
                       neogeo_prot_data = 0xf05a3601;
                       break;

               case 0x42812/2: /* data == 0x1824; read back from 36008 *or* 3600c */
                       neogeo_prot_data = 0x81422418;
                       break;

               case 0x55550/2:
               case 0xffff0/2:
               case 0xff000/2:
               case 0x36000/2:
               case 0x36004/2:
               case 0x36008/2:
               case 0x3600c/2:
                       neogeo_prot_data <<= 8;
                       break;

               default:

logerror("unknown protection write at pc %06x, offset %08x, data %02x\n",activecpu_get_pc(),offset,data);
                       break;
        }
}

void fatfury2_install_protection(void)
{
/* Hacks the program rom of Fatal Fury 2, needed either in arcade or console mode */
/* otherwise at level 2 you cannot hit the opponent and other problems */

/* there seems to also be another protection check like the countless ones */
/* patched above by protecting a SRAM location, but that trick doesn't work */
/* here (or maybe the SRAM location to protect is different), so I patch out */
/* the routine which trashes memory. Without this, the game goes nuts after */
/* the first bonus stage. */
// UINT16 *mem16 = (UINT16 *)memory_region(REGION_CPU1);
// mem16[0xb820/2] = 0x4e71;
// mem16[0xb822/2] = 0x4e71;

/* again, the protection involves reading and writing addresses in the */
/* 0x2xxxxx range. There are several checks all around the code. */
memory_install_read16_handler(0, ADDRESS_SPACE_PROGRAM, 0x200000, 0x2fffff, 0, 0, fatfury2_protection_16_r);
memory_install_write16_handler(0, ADDRESS_SPACE_PROGRAM, 0x200000, 0x2fffff, 0, 0, fatfury2_protection_16_w);
}

/************************ Fatal Fury 3 *************************
  is this still needed? -- some people report other lockups
  in this.
***************************************************************/

void fatfury3_install_protection(void)
{
/* patch the first word, it must be 0x0010 not 0x0000 (initial stack pointer) */
UINT16 *mem16 = (UINT16 *)memory_region(REGION_CPU1);
mem16[0x0000/2] = 0x0010;
}

Offline iq_132

  • Administrator
  • *****
  • Posts: 3728
  • Karma: +411/-0
  • Definitely not Dink!
    • NeoSource
Re: Fatfury2 - code update
« Reply #8 on: January 12, 2006, 12:33:13 PM »
I just noticed that this also works for ssideki (again, thanks fba team :))

in machine/neoprot.c delete this:
Code: [Select]
void ssideki_install_protection(void)
{
/* patch out protection check */
/* the protection routines are at 0x25dcc and involve reading and writing */
/* addresses in the 0x2xxxxx range */
UINT16 *mem16 = (UINT16 *)memory_region(REGION_CPU1);
mem16[0x2240/2] = 0x4e71;
}

in includes/neogeo.h delete this:
Code: [Select]
void ssideki_install_protection(void);


in drivers/neogeo.c replace this:

Code: [Select]
DRIVER_INIT( ssideki )
{
init_neogeo();
ssideki_install_protection();
}

With this:

Code: [Select]
DRIVER_INIT( ssideki )
{
init_neogeo();
fatfury2_install_protection();
}


Offline KingHanco

  • Sr. Member
  • ****
  • Posts: 401
  • Karma: +0/-4
  • "Special " Member
Re: Fatfury2 - code update
« Reply #9 on: January 13, 2006, 05:02:07 PM »
Thanks iq_132 and fba team.

Offline Ashura-X

  • Member
  • ***
  • Posts: 138
  • Karma: +0/-0
Re: Fatfury2 - code update
« Reply #10 on: January 14, 2006, 05:53:02 PM »
Thx again guys  :eek:

Offline Ashura-X

  • Member
  • ***
  • Posts: 138
  • Karma: +0/-0
Re: Fatfury2 - code update
« Reply #11 on: January 27, 2006, 04:37:14 PM »
Well like I see on mame bug report forum this code must be incomplete or something like that.
See this topic guys:
http://www.mameworld.info/ubbthreads/showthreaded.php?Cat=&Number=62842&page=0&view=expanded&sb=5&o=&fpart=1&vc=1
I have tried here on the official build and really the games glitches on that stage ....  :p
Dunno about super side kicks , this game isnt updated on official code with these changes.

Finished ssideki using cheats and I didn´t found any problem on this game.
« Last Edit: January 27, 2006, 04:47:36 PM by Ashura-X »

Offline James33

  • Expert
  • *****
  • Posts: 532
  • Karma: +3/-0
  • The Mame Man
    • Emulation Zone
Re: Fatfury2 - code update
« Reply #12 on: January 27, 2006, 08:22:03 PM »
Well like I see on mame bug report forum this code must be incomplete or something like that.
See this topic guys:
http://www.mameworld.info/ubbthreads/showthreaded.php?Cat=&Number=62842&page=0&view=expanded&sb=5&o=&fpart=1&vc=1
I have tried here on the official build and really the games glitches on that stage ....  :p


Strange I tested that code awhile back and there was no GFX problem with that game . I played the game right to the last stage .
IQ Forum Member

Offline KingHanco

  • Sr. Member
  • ****
  • Posts: 401
  • Karma: +0/-4
  • "Special " Member
Re: Fatfury2 - code update
« Reply #13 on: January 28, 2006, 12:52:53 AM »
Well. There are 3 problems on this as far I seen tested on 0.103u4.

http://www.mameworld.info/ubbthreads/showthreaded.php?Cat=&Number=62944&page=0&view=expanded&sb=5&o=&fpart=1&vc=1

I didn't get a snapshot on after the bonus stage. Weard messy screen. I gotting the other 2 snapshots though.

Offline James33

  • Expert
  • *****
  • Posts: 532
  • Karma: +3/-0
  • The Mame Man
    • Emulation Zone
Re: Fatfury2 - code update
« Reply #14 on: January 28, 2006, 01:36:15 AM »
Well. There are 3 problems on this as far I seen tested on 0.103u4.

http://www.mameworld.info/ubbthreads/showthreaded.php?Cat=&Number=62944&page=0&view=expanded&sb=5&o=&fpart=1&vc=1

I didn't get a snapshot on after the bonus stage. Weard messy screen. I gotting the other 2 snapshots though.

Not broken here , I feel there is only a tiny problem with the code . Which is not really a bug in the code just a new line needs to be put inbetween each handler .
IQ Forum Member