Author Topic: King of Fighters 10th Anniversary Edition  (Read 83380 times)

Offline NeoKIM®

  • Newbies
  • *
  • Posts: 11
  • Karma: +0/-0
Re: King of Fighters 10th Anniversary Edition
« Reply #90 on: January 01, 2006, 09:19:26 PM »
Quote
static const gfx_layout kof10th_layout =
{
   8,8,         /* 8 x 8 chars */
   8192,
   4,            /* 4 bits per pixel */
   { 0, 1, 2, 3 },    /* planes are packed in a nibble */
   { 33*4, 32*4, 49*4, 48*4, 1*4, 0*4, 17*4, 16*4 },
   { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
   32*8   /* 32 bytes per char */
};

static UINT16 kof10thExtraRAMB[0x01000];

static void kof10thBankswitch(unsigned int nBank)
{
   nBank = 0x100000 + ((nBank & 7) << 20);
   if (nBank >= 0x700000)
      nBank = 0x100000;
   neogeo_set_cpu1_second_bank(nBank);
}

READ16_HANDLER( kof10th_RAMB_r )
{
   return kof10thExtraRAMB[offset];
}

WRITE16_HANDLER( kof10th_custom_w )
{
   if (!kof10thExtraRAMB[0xFFE]) {
      UINT16 *prom = (UINT16*)memory_region( REGION_CPU1 );
      COMBINE_DATA(&prom[(0xE0000/2) + (offset & 0xFFFF)]);
   } else {
                 //    S data decoded on the fly
                 UINT8 *prom = (UINT8*)memory_region( REGION_GFX1 );
                 UINT8 datalow = BITSWAP8(data, 7, 6, 0, 4, 3, 2, 1, 5);
                 prom[offset] = datalow;
                 decodechar(Machine->gfx[0], offset>>5, prom, &kof10th_layout);
   }
}

static WRITE16_HANDLER( kof10th_bankswitch_w )
{
   if (offset >= 0x5F000) {
      if (offset == 0x5FFF8) { // Standard bankswitch
         kof10thBankswitch(data);
      } else if (offset == 0x5FFFC && kof10thExtraRAMB[0xFFC] != data) {
         UINT8 *src = memory_region( REGION_CPU1 );
         memcpy (src + 0x400,  src + ((data & 1) ? 0x700400 : 0x800400), 0xdfbff);
      }
      COMBINE_DATA(&kof10thExtraRAMB[offset & 0xFFF]);
   }
}

DRIVER_INIT( kof10th )
{
   int i, j;
   UINT8 *dst = malloc(0x900000);
   UINT8 *src = memory_region( REGION_CPU1 );
   UINT8 *srm = memory_region( REGION_GFX1 );

   if (dst) {
      memcpy(dst + 0x000000, src + 0x700000, 0x100000);
      memcpy(dst + 0x100000, src + 0x000000, 0x800000);
      for (i = 0; i < 0x900000; i++) {
         j = (i&0xFFF000) + BITSWAP16(i&0xFFF,15,14,13,12,11,2,9,8,7,1,5,4,3,10,6,0);
         src[j] = dst;
      }
      free(dst);
   }

   // Altera protection chip patches these over P ROM
   ((UINT16*)src)[0x0124/2] = 0x000d; // Enables XOR for RAM moves, forces SoftDIPs, and USA region
   ((UINT16*)src)[0x0126/2] = 0xf7a8;

   ((UINT16*)src)[0x8bf4/2] = 0x4ef9; // Run code to change "S" data
   ((UINT16*)src)[0x8bf6/2] = 0x000d;
   ((UINT16*)src)[0x8bf8/2] = 0xf980;

   }

   init_neogeo();
   
   memory_install_read16_handler(0,  ADDRESS_SPACE_PROGRAM, 0x2fe000, 0x2fffff, 0, 0, kof10th_RAMB_r);
   memory_install_write16_handler(0, ADDRESS_SPACE_PROGRAM, 0x200000, 0x23ffff, 0, 0, kof10th_custom_w);
   memory_install_write16_handler(0, ADDRESS_SPACE_PROGRAM, 0x240000, 0x2fffff, 0, 0, kof10th_bankswitch_w);
}

This code is certain? Lack something more?

Offline NeoKIM®

  • Newbies
  • *
  • Posts: 11
  • Karma: +0/-0
Re: King of Fighters 10th Anniversary Edition
« Reply #91 on: January 02, 2006, 12:23:49 AM »
my source code is of it ek-mame 0.99....
The compilation is giving error...
Some tip?

Offline iq_132

  • Administrator
  • *****
  • Posts: 3728
  • Karma: +411/-0
  • Definitely not Dink!
    • NeoSource
Re: King of Fighters 10th Anniversary Edition
« Reply #92 on: January 02, 2006, 12:29:25 AM »
Post a screenshot of the error.


Offline NeoKIM®

  • Newbies
  • *
  • Posts: 11
  • Karma: +0/-0
Re: King of Fighters 10th Anniversary Edition
« Reply #93 on: January 02, 2006, 01:05:41 AM »


This is the error... :redface:

 :idiot:

Offline mamesick

  • Newbies
  • *
  • Posts: 17
  • Karma: +0/-0
  • MAME32FX
    • MAME32FX
Re: King of Fighters 10th Anniversary Edition
« Reply #94 on: January 02, 2006, 02:15:57 AM »
He's using an old source... and in 0.99u4 a lot of structures were renamed in the core.
In particular:

struct GfxLayout ----> gfx_layout

So he must use this:
Code: [Select]
static struct GfxLayout kof10th_layout =

The rest of the code you posted looks ok to me...but in the case he will encounter other errors, he should keep in mind that in 0.99u6 another change was made:

data8_t ----> UINT8
data16_t ----> UINT16


BTW I don't think it's needed.
« Last Edit: January 02, 2006, 02:24:36 AM by mamesick »

Offline NeoKIM®

  • Newbies
  • *
  • Posts: 11
  • Karma: +0/-0
Re: King of Fighters 10th Anniversary Edition
« Reply #95 on: January 02, 2006, 03:08:50 AM »
INIT for MAME 0.99 or previous.....

Quote
static struct GfxLayout kof10th_layout =
{
   8,8,         /* 8 x 8 chars */
   8192,
   4,            /* 4 bits per pixel */
   { 0, 1, 2, 3 },    /* planes are packed in a nibble */
   { 33*4, 32*4, 49*4, 48*4, 1*4, 0*4, 17*4, 16*4 },
   { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
   32*8   /* 32 bytes per char */
};

static UINT16 kof10thExtraRAMB[0x01000];

static void kof10thBankswitch(unsigned int nBank)
{
   nBank = 0x100000 + ((nBank & 7) << 20);
   if (nBank >= 0x700000)
   nBank = 0x100000;
   neogeo_set_cpu1_second_bank(nBank);
}

READ16_HANDLER( kof10th_RAMB_r )
{
   return kof10thExtraRAMB[offset];
}

WRITE16_HANDLER( kof10th_custom_w )
{
   if (!kof10thExtraRAMB[0xFFE]) {
   UINT16 *prom = (UINT16*)memory_region( REGION_CPU1 );
   COMBINE_DATA(&prom[(0xE0000/2) + (offset & 0xFFFF)]);
   } else {
   UINT8 *prom=(UINT8*)memory_region( REGION_GFX1 );
   UINT8 datalow= BITSWAP8(data,7,6,0,4,3,2,1,5);
   prom[offset]=datalow;
   decodechar(Machine->gfx[0], offset>>5, prom, &kof10th_layout);
   }
}

static WRITE16_HANDLER( kof10th_bankswitch_w )
{
   if (offset >= 0x5F000) {
   if (offset == 0x5FFF8) { // Standard bankswitch
   kof10thBankswitch(data);
   } else if (offset == 0x5FFFC && kof10thExtraRAMB[0xFFC] != data) {
   UINT8 *src = memory_region( REGION_CPU1 );
   memcpy (src + 0x400,  src + ((data & 1) ? 0x700400 : 0x800400), 0xdfbff);
   }
   COMBINE_DATA(&kof10thExtraRAMB[offset & 0xFFF]);
   }
}

DRIVER_INIT( kof10th )
{
   int i, j;
   UINT8 *dst = malloc(0x900000);
   UINT8 *src = memory_region( REGION_CPU1 );

   if (dst) {
      memcpy(dst + 0x000000, src + 0x700000, 0x100000);
      memcpy(dst + 0x100000, src + 0x000000, 0x800000);
      for (i = 0; i < 0x900000; i++) {
         j = (i&0xFFF000) + BITSWAP16(i&0xFFF,15,14,13,12,11,2,9,8,7,1,5,4,3,10,6,0);
         src[j] = dst;
      }
      free(dst);
   }

   // Altera protection chip patches these over P ROM
   ((UINT16*)src)[0x0124/2] = 0x000d; // Enables XOR for RAM moves, forces SoftDIPs, and USA region
   ((UINT16*)src)[0x0126/2] = 0xf7a8;

   ((UINT16*)src)[0x8bf4/2] = 0x4ef9; // Run code to change "S" data
   ((UINT16*)src)[0x8bf6/2] = 0x000d;
   ((UINT16*)src)[0x8bf8/2] = 0xf980;

   memory_install_read16_handler (0, ADDRESS_SPACE_PROGRAM, 0x2fe000, 0x2fffff, 0, 0, kof10th_RAMB_r);
   memory_install_write16_handler(0, ADDRESS_SPACE_PROGRAM, 0x200000, 0x23ffff, 0, 0, kof10th_custom_w);
   memory_install_write16_handler(0, ADDRESS_SPACE_PROGRAM, 0x240000, 0x2fffff, 0, 0, kof10th_bankswitch_w);
   
   init_neogeo();      
}

For MAME 0.100 in ahead change only this...

Quote
static const gfx_layout kof10th_layout =
{
   8,8,         /* 8 x 8 chars */
   8192,
   4,            /* 4 bits per pixel */
   { 0, 1, 2, 3 },    /* planes are packed in a nibble */
   { 33*4, 32*4, 49*4, 48*4, 1*4, 0*4, 17*4, 16*4 },
   { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
   32*8   /* 32 bytes per char */
};

Thanks for help "MAMESICK"
« Last Edit: January 02, 2006, 10:00:00 AM by NeoKIM® »

Offline James33

  • Expert
  • *****
  • Posts: 532
  • Karma: +3/-0
  • The Mame Man
    • Emulation Zone
Re: King of Fighters 10th Anniversary Edition
« Reply #96 on: January 02, 2006, 06:27:29 AM »
Ah ok... I'm rather new to this, I didn't start until 0.101 - plus I've never done anything with ekmame.

Yeah ekmame can be a pain to compile .
If you do not want online play then there is not much need for that build .
IQ Forum Member

Offline pinhead

  • New Member
  • *
  • Posts: 2
  • Karma: +0/-0
Re: King of Fighters 10th Anniversary Edition
« Reply #97 on: January 02, 2006, 03:09:21 PM »
Hello,
You can get rid of the structure kof10th_layout by replacing &kof10th_layout with Machine->drv->gfxdecodeinfo[0].gfxlayout in the function decodechar():
//decodechar(Machine->gfx[0], offset>>5, prom, &kof10th_layout);                       
  decodechar(Machine->gfx[0], offset>>5, prom, Machine->drv->gfxdecodeinfo[0].gfxlayout);

Don't forget to remove/comment the declaration of the structure or the compiler could complain about an unused variable :
//static const gfx_layout kof10th_layout =               
//{                                                       
//   8,8,         /* 8 x 8 chars */                           
//   8192,                                                 
//   4,             /* 4 bits per pixel */                     
//   { 0, 1, 2, 3 },    /* planes are packed in a nibble */
//   { 33*4, 32*4, 49*4, 48*4, 1*4, 0*4, 17*4, 16*4 },     
//   { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },           
//   32*8   /* 32 bytes per char */                         
//};

Bye.

Offline James33

  • Expert
  • *****
  • Posts: 532
  • Karma: +3/-0
  • The Mame Man
    • Emulation Zone
Re: King of Fighters 10th Anniversary Edition
« Reply #98 on: January 03, 2006, 01:20:50 AM »
Thanks pinhead :)
Man that feels weird saying that lol .
IQ Forum Member

Offline iq_132

  • Administrator
  • *****
  • Posts: 3728
  • Karma: +411/-0
  • Definitely not Dink!
    • NeoSource
Re: King of Fighters 10th Anniversary Edition
« Reply #99 on: January 04, 2006, 05:38:18 AM »
Here's what I've got. :)

Code: [Select]
static UINT16 kof10thExtraRAMB[0x01000];

static void kof10thBankswitch(unsigned int nBank)
{
nBank = 0x100000 + ((nBank & 7) << 20);
if (nBank >= 0x700000)
nBank = 0x100000;
neogeo_set_cpu1_second_bank(nBank);
}

READ16_HANDLER( kof10th_RAMB_r )
{
return kof10thExtraRAMB[offset];
}

WRITE16_HANDLER( kof10th_custom_w )
{
if (!kof10thExtraRAMB[0xFFE]) { // Write to RAM bank A
UINT16 *prom = (UINT16*)memory_region( REGION_CPU1 );
COMBINE_DATA(&prom[(0xE0000/2) + (offset & 0xFFFF)]);
} else { // Write S data on-the-fly
UINT8 *srom = memory_region( REGION_GFX1 );
srom[offset] = BITSWAP8(data,7,6,0,4,3,2,1,5);
decodechar(Machine->gfx[0], offset>>5, srom, Machine->drv->gfxdecodeinfo[0].gfxlayout);
}
}

static WRITE16_HANDLER( kof10th_bankswitch_w )
{
if (offset >= 0x5F000) {
if (offset == 0x5FFF8) { // Standard bankswitch
kof10thBankswitch(data);
} else if (offset == 0x5FFFC && kof10thExtraRAMB[0xFFC] != data) { // Special bankswitch
UINT8 *src = memory_region( REGION_CPU1 );
memcpy (src + 0x10000,  src + ((data & 1) ? 0x810000 : 0x710000), 0xcffff);
}
COMBINE_DATA(&kof10thExtraRAMB[offset & 0xFFF]);
}
}

void install_kof10th_protection ( void )
{
memory_install_read16_handler(0,  ADDRESS_SPACE_PROGRAM, 0x2fe000, 0x2fffff, 0, 0, kof10th_RAMB_r);
memory_install_write16_handler(0, ADDRESS_SPACE_PROGRAM, 0x200000, 0x23ffff, 0, 0, kof10th_custom_w);
memory_install_write16_handler(0, ADDRESS_SPACE_PROGRAM, 0x240000, 0x2fffff, 0, 0, kof10th_bankswitch_w);
}

void decrypt_kof10th( void )
{
int i, j;
UINT8 *dst = malloc(0x900000);
UINT8 *src = memory_region( REGION_CPU1 );

if (dst) {
memcpy(dst + 0x000000, src + 0x700000, 0x100000); // Correct (Verified in Uni-bios)
memcpy(dst + 0x100000, src + 0x000000, 0x800000);
for (i = 0; i < 0x900000; i++) {
j = BITSWAP24(i,23,22,21,20,19,18,17,16,15,14,13,12,11,2,9,8,7,1,5,4,3,10,6,0);
src[j] = dst[i];
}
free(dst);
}

// Altera protection chip patches these over P ROM
((UINT16*)src)[0x0124/2] = 0x000d; // Enables XOR for RAM moves, forces SoftDIPs, and USA region
((UINT16*)src)[0x0126/2] = 0xf7a8;

((UINT16*)src)[0x8bf4/2] = 0x4ef9; // Run code to change "S" data
((UINT16*)src)[0x8bf6/2] = 0x000d;
((UINT16*)src)[0x8bf8/2] = 0xf980;
}


Please note a few changes:
      UINT8 *srom = memory_region( REGION_GFX1 );
      srom[offset] = BITSWAP8(data,7,6,0,4,3,2,1,5);
      decodechar(Machine->gfx[0], offset>>5, srom, Machine->drv->gfxdecodeinfo[0].gfxlayout);
I just combined/renamed a few things to shorten this up a bit.

memcpy (src + 0x10000,  src + ((data & 1) ? 0x810000 : 0x710000), 0xcffff);
This is modified so that it doesn't overwrite the "Run code to change 's' data" patches (which can cause problems).

memcpy(dst + 0x000000, src + 0x700000, 0x100000);
This is the correct order.  Just check it in unibios. ;)

j = BITSWAP24(i,23,22,21,20,19,18,17,16,15,14,13,12,11,2,9,8,7,1,5,4,3,10,6,0);
this is just cosmetic (functionally the same as the current line in mame)


Offline James33

  • Expert
  • *****
  • Posts: 532
  • Karma: +3/-0
  • The Mame Man
    • Emulation Zone
Re: King of Fighters 10th Anniversary Edition
« Reply #100 on: January 04, 2006, 06:45:58 AM »
Nice once IQ :) 
IQ Forum Member

Offline NeoKIM®

  • Newbies
  • *
  • Posts: 11
  • Karma: +0/-0
Re: King of Fighters 10th Anniversary Edition
« Reply #101 on: December 02, 2008, 10:48:24 AM »
decodechar (machine->gfx[0], offset>>5, srom, Machine->drv->gfxdecodeinfo[0].gfxlayout);

New code for mame 0.128?

thanks!

Offline NeoKIM®

  • Newbies
  • *
  • Posts: 11
  • Karma: +0/-0
Re: King of Fighters 10th Anniversary Edition
« Reply #102 on: October 21, 2010, 10:57:22 PM »

Good Night!

Could someone help me pass the code below for the current version of MAME?

static struct GfxLayout kof10th_layout =
{
   8,8,         /* 8 x 8 chars */
   8192,
   4,            /* 4 bits per pixel */
   { 0, 1, 2, 3 },    /* planes are packed in a nibble */
   { 33*4, 32*4, 49*4, 48*4, 1*4, 0*4, 17*4, 16*4 },
   { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
   32*8   /* 32 bytes per char */
};

static WRITE16_HANDLER( kof10th_custom_w )
{
   if (!kof10thExtraRAMB[0xFFE]) { // Write to RAM bank A
      UINT16 *prom = (UINT16*)memory_region( space->machine, "maincpu" );
      COMBINE_DATA(&prom[(0xE0000/2) + (offset & 0xFFFF)]);
   } else { // Write S data on-the-fly
      UINT8 *srom = memory_region( space->machine, "fixed" );
      srom[offset] = BITSWAP8(data,7,6,0,4,3,2,1,5);
      decodechar(Machine->gfx[0], offset>>5, prom, Machine->drv->gfxdecodeinfo[0].gfxlayout); <--- ERRO!!!
   }
}

I need this code to enable special moves like in Kawaks, when I enable the blows leaves a bug in NEOGEO soon and with this code is 100%

HELP-ME!!!