Welcome!

Final Burn Neo => FBN Development => Topic started by: FerchogtX on November 24, 2004, 07:29:37 PM

Title: NeoTextROMFix code
Post by: FerchogtX on November 24, 2004, 07:29:37 PM
If anyone needs this here the whole code I use by now...
EDIT: Fixed the code, the old one didn't do anything to the svcchaos/svcnd texts, now it's ok
in neogeo.h:
add this after // neo_run.cpp
Code: [Select]
extern int nNeoTextROMFixType;in neo_run.cpp
add this after #include "neogeo.h"
Code: [Select]
#include "bitswap.h"find:
Code: [Select]
int NeoSRAMProtection = -1;add this after:
Code: [Select]
int nNeoTextROMFixType = 0; // Text fix for games that have TextBankswitchfind:
Code: [Select]
BurnLoadRom(NeoTextROM + 0x020000, pInfo->nTextOffset, 1);add this after
Code: [Select]
/* Original code for MAME by fataku */
if (nNeoTextROMFixType == 1) {
       unsigned char* srom = NeoTextROM+0x20000;
       for (int i=0;i<0x20000;i++) {
        srom[i]=BITSWAP08(srom[i],3,2,4,5,1,6,0,7);
       }
}
/* Original code from mame traduced by FerchogtX */
if (nNeoTextROMFixType == 2) {
/* Descrambling S1 by FerchogtX, bassed on DorriGa's code */
unsigned char* srom = NeoTextROM+0x20000;
unsigned char* dst = (unsigned char*)malloc(0x20000);
memcpy( dst+0x00000, srom+0x10000, 0x10000 );
memcpy( dst+0x10000, srom+0x00000, 0x10000 );
memcpy( srom, dst, 0x20000 );
free(dst);
}
/* Thanks also to HappyASR for the info */
if (nNeoTextROMFixType == 3) {
unsigned char* srom = NeoTextROM+0x20000;
unsigned char* dst = (unsigned char*)malloc(0x20000);
if (dst)
{
memcpy(dst,srom,0x20000);
// descrambling the S1 by dorriGa
for (int j=0;j<0x20000 ; j+=0x000010)
{
memcpy(srom+j, dst+j+0x000008,8);
memcpy(srom+j+0x000008, dst+j,8);
}
}
free(dst);
}
/* Thanks to Badzou for the info */
if (nNeoTextROMFixType == 4) {
/* Descrambling S1 by dorriga */
unsigned char* srom = NeoTextROM+0x20000;
unsigned char* dst = (unsigned char*)malloc(0x80000);
memcpy( dst+0x00000, srom+0x60000, 0x20000 );
memcpy( dst+0x20000, srom+0x40000, 0x20000 );
memcpy( dst+0x40000, srom+0x20000, 0x20000 );
memcpy( dst+0x60000, srom+0x00000, 0x20000 );
memcpy( srom, dst, 0x80000 );
free(dst);
}
// Converted by Jimmy_Page (www.neofighters.com)
if (nNeoTextROMFixType == 5) {
       unsigned char* srom = NeoTextROM+0x20000;
       for (int i=0;i<0x20000;i++) {
        srom[i]=BITSWAP08(srom[i],7,6,0,4,3,2,1,5);
       }
}
find:
Code: [Select]
NeoExtractSData(NeoSpriteROM, NeoTextROM + 0x020000, nSpriteSize, nNeoTextROMSize);add this after:
Code: [Select]
// Original convertion by IQ_132 (This is for svcchaos and clones)
if (nNeoTextROMFixType == 6) {
unsigned char* srom = NeoTextROM+0x20000;
for( int i=0;i<nNeoTextROMSize;i++ ){
srom[i]=BITSWAP08(srom[i]^0xd2,4,0,7,2,5,1,6,3);
}
}
find NeoExit()
add this after nNeoSRAMProtection = -1;
Code: [Select]
nNeoTextROMFixType = 0; // Turns off Text fix when you quit a gameDon't forget to replace all nTextBankswitch references with this new name:
Code: [Select]
nNeoTextROMFixTypeif you have the old names...
See ya!!!!!!! :D
P.D. here a reference for the values:
1 is for kf2k1pla
2 is for svcboot, svcplusa, ms5plusa
3 is for ms5plus, kof2003b, svcplus, samsh5bl, kf97plsa
4 is for games that uses a 512 KB s1 rom to simulate certain effects, this is not realy a valid init, when we can get working kof2003 (PCB) and svcchaos and clones, this will be deleted, games that uses this value: svcboota, svcplusb, svcsplsa, kof2k3ba, kof2k4xa.
5 is for svcsplus, kof2k3up (thanks james33)
6 is for svcnd
Title: NeoTextROMFix code
Post by: James33 on November 24, 2004, 08:51:42 PM
5 should also work for King of Fighters 2004 ultra Plus
Title: NeoTextROMFix code
Post by: Xeon on November 24, 2004, 11:30:15 PM
okay thanks peeps, time to update code :)
Title: NeoTextROMFix code
Post by: Accosta_m on November 26, 2004, 05:18:46 PM
Very Thanks Fercho  :D
Title: NeoTextROMFix code
Post by: Shoometsu on November 27, 2004, 07:58:01 AM
Quote
Don't forget to replace all nTextBankswitch references with this new name:

Code:

Code: [Select]
nNeoTextROMFixType

Where do I find these references

 :confused:
Title: NeoTextROMFix code
Post by: iq_132 on November 27, 2004, 08:05:02 AM
He means that if you have the old "nTextBankswitch" code in your build, go through your source files and do a "search and replace" -- replacing "nTextBankswitch" with "nNeoTextROMFixType"

If you don't have the nTextBankswitch code in your build, don't worry about it ;)
Title: NeoTextROMFix code
Post by: Shoometsu on November 27, 2004, 10:34:01 AM
I've discovered that I don't have this (thanks ultraedit32), search in each file for that should be a pain in the behind, no one reference to nTextBankswitch in any file here XD

one more thing: in the explanation begining where

find in neo_run.cpp:

Code: [Select]
int NeoSRAMProtection = -1;
I've found only

Code: [Select]
int nNeoSRAMProtection = -1;
I don't know if I'm doing something wrog, but " did the compilation without any error messages.
Title: NeoTextROMFix code
Post by: James33 on November 27, 2004, 10:40:33 AM
Good old Notepad does the job for me . :D
Title: NeoTextROMFix code
Post by: Shoometsu on November 27, 2004, 11:17:22 AM
Quote from: James33
Good old Notepad does the job for me . :D


Sure, i like notepad too, but I don't know where could be the reference, so utraedit searched in each source file by itself, I didn't need to open each file in notepad XD lot of time saved
Title: NeoTextROMFix code
Post by: FerchogtX on November 28, 2004, 01:17:19 AM
Don't forget that Ultra Edit adds auto spaces when needed... very usefull :P
Better to use UE... you can also undo some things that you do if are wrong...
See ya!!!!! :D
P.D. and adds colors like the Visual Studio editor XD
Title: NeoTextROMFix code
Post by: FerchogtX on December 07, 2004, 07:42:33 PM
Add this after the case 5:
for ct2003sp s1 ROM
Code: [Select]
if (nNeoTextROMFixType = 7) {
unsigned char *rom = NeoTextROM+0x20000;
unsigned char *buf = (unsigned char*)malloc( 0x40000 );
int i, ofst;

memcpy( buf, rom, 0x40000 );

for( i = 0; i < 0x40000; i++ ){
ofst = BITSWAP24( (i & 0x1ffff),23,22,21,20,19,18,17,3,
0,1,4,2,13,14,16,15,5,6,11,10,9,8,7,12 );
ofst += (i >> 17) << 17;
rom[ i ] = buf[ ofst ];
}

memcpy( buf, rom, 0x40000 );

memcpy( &rom[ 0x08000 ], &buf[ 0x10000 ], 0x8000 );
memcpy( &rom[ 0x10000 ], &buf[ 0x08000 ], 0x8000 );
memcpy( &rom[ 0x28000 ], &buf[ 0x30000 ], 0x8000 );
memcpy( &rom[ 0x30000 ], &buf[ 0x28000 ], 0x8000 );

free( buf );
}
maybe this works, i had to remove all not declared functions on it, to see the original driver check on the HalRin page
See ya!!!!!! :D
Title: NeoTextROMFix code
Post by: fataku on December 08, 2004, 12:41:29 AM
i thought the code was easiest, something like this:

Code: [Select]
if (nNeoTextROMFixType = 7) {
        // thanks to dorriGa and arnoldso for analyze the scramble
        unsigned char *rom = NeoTextROM+0x20000;
        unsigned char *buf = (unsigned char*)malloc( 0x40000 );
        int i, j;

        for (i=0;i<0x40000;i++){
            j=BITSWAP24(i,23,22,21,20,19,18,17,9,8,10,11,0,5,4,3,2,1,6,7,13,16,12,14,15);
            buf[j]=rom[i];
        }
memcpy( rom, buf, 0x40000 );
free( buf );
}

and yeah a code for mame too:

Code: [Select]
static void cthd2k3s1spls(void)
{
// thanks to dorriGa and arnoldso for analyze the scramble
UINT8 *src = (memory_region(REGION_GFX1));
UINT8 *dst = (UINT8*)malloc(0x40000);
int i,j;
for (i=0;i<0x40000;i++){
j=BITSWAP24(i,23,22,21,20,19,18,17,9,8,10,11,0,5,4,3,2,1,6,7,13,16,12,14,15);
dst[j]=src[i];
}
memcpy(src,dst,0x40000);
}
Title: NeoTextROMFix code
Post by: Shoometsu on December 12, 2004, 04:19:18 PM
Quote from: fataku
i thought the code was easiest, something like this:

Code: [Select]
if (nNeoTextROMFixType = 7) {
        // thanks to dorriGa and arnoldso for analyze the scramble
        unsigned char *rom = NeoTextROM+0x20000;
        unsigned char *buf = (unsigned char*)malloc( 0x40000 );
        int i, j;

        for (i=0;i<0x40000;i++){
            j=BITSWAP24(i,23,22,21,20,19,18,17,9,8,10,11,0,5,4,3,2,1,6,7,13,16,12,14,15);
            buf[j]=rom[i];
        }
memcpy( rom, buf, 0x40000 );
free( buf );
}

and yeah a code for mame too:

Code: [Select]
static void cthd2k3s1spls(void)
{
// thanks to dorriGa and arnoldso for analyze the scramble
UINT8 *src = (memory_region(REGION_GFX1));
UINT8 *dst = (UINT8*)malloc(0x40000);
int i,j;
for (i=0;i<0x40000;i++){
j=BITSWAP24(i,23,22,21,20,19,18,17,9,8,10,11,0,5,4,3,2,1,6,7,13,16,12,14,15);
dst[j]=src[i];
}
memcpy(src,dst,0x40000);
}

ct2003sp extract the s data from the end of c roms? I don't know if i add this before the 6th or the 5th option according to the extraction (or not)
 :confused:
Title: NeoTextROMFix code
Post by: James33 on December 12, 2004, 09:58:33 PM
No thats meant to descramble the S rom .
Title: NeoTextROMFix code
Post by: Shoometsu on December 13, 2004, 08:20:57 PM
Quote from: James33
No thats meant to descramble the S rom .


Code: [Select]


NeoTextROM = (unsigned char*)malloc(nNeoTextROMSize + 0x020000);
if (NeoTextROM == NULL) {
return 1;

                options 1 to 5 here

        } else {
// Extract data from the end of C ROMS
BurnUpdateProgress(0.0, "Gerando gráficos de texto ", 0);
NeoExtractSData(NeoSpriteROM, NeoTextROM + 0x020000, nSpriteSize, nNeoTextROMSize);

                option 6 here


 where do I insert the 7th option? with the other 5 or with the 6th in thi "if" structure?
Title: NeoTextROMFix code
Post by: James33 on December 13, 2004, 09:37:40 PM
I would not worry about it The code is useless , Does not work for FBA .
Title: NeoTextROMFix code
Post by: FerchogtX on December 14, 2004, 11:10:39 PM
Quote from: James33
I would not worry about it The code is useless , Does not work for FBA .

It works, the problem is that FBA is not loading the data correctly, but the descrambling is correct, i think that fataku's code is better because it works either with 128 KB version and 256, the second doesn't work correctly because the loading routine for this rom is not correct at all, test the fataku version splitting the s1 rom, you'll see that works, the other s1 probs come from the rom itself...
I hope someone can fix the 256 KB s1 rom problem :(
See ya!!!! :D
Title: NeoTextROMFix code
Post by: FerchogtX on December 14, 2004, 11:11:01 PM
Quote from: Shoometsu
Code: [Select]


NeoTextROM = (unsigned char*)malloc(nNeoTextROMSize + 0x020000);
if (NeoTextROM == NULL) {
return 1;

                options 1 to 5 here

        } else {
// Extract data from the end of C ROMS
BurnUpdateProgress(0.0, "Gerando gráficos de texto ", 0);
NeoExtractSData(NeoSpriteROM, NeoTextROM + 0x020000, nSpriteSize, nNeoTextROMSize);

                option 6 here


 where do I insert the 7th option? with the other 5 or with the 6th in thi "if" structure?

after option 5
Title: NeoTextROMFix code
Post by: Shoometsu on December 15, 2004, 03:46:52 PM
Quote from: FerchogtX
after option 5


thkx again XD
Title: NeoTextROMFix code
Post by: Sho on February 23, 2005, 06:39:21 AM
where is the option 8

thx!
Title: NeoTextROMFix code
Post by: iq_132 on February 23, 2005, 12:12:08 PM
Just use the same option you've been using for kof2003, if that's what you mean...
Title: NeoTextROMFix code
Post by: bms888 on February 23, 2005, 08:24:51 PM
Quote from: Sho
where is the option 8

thx!


ok,this is my NeoTextROMFix code:

Code: [Select]

/* Original code from mame - converted by FerchogtX */
switch (nNeoTextROMFixType) {
unsigned char *srom, *dst;

case 1:
/* Thanks to Badzou for the info */
/* Descrambling S1 by dorriga */
srom = NeoTextROM + 0x20000;
dst = (unsigned char*)malloc(0x80000);
memcpy(dst+0x00000, srom+0x60000, 0x20000);
memcpy(dst+0x20000, srom+0x40000, 0x20000);
memcpy(dst+0x40000, srom+0x20000, 0x20000);
memcpy(dst+0x60000, srom+0x00000, 0x20000);
memcpy(srom, dst, 0x80000);
free(dst);
break;

case 3:
/* Thanks also to HappyASR for the info */
srom = NeoTextROM + 0x20000;
dst = (unsigned char *)malloc(0x20000);
memcpy(dst, srom, 0x20000);
// descrambling the S1 by dorriGa
for (int i=0; i<0x20000; i+=0x10){
memcpy(srom+i, dst+i+0x08, 0x08);
memcpy(srom+i+0x08, dst+i, 0x08);
}
free(dst);
break;

case 4:
/* Descrambling S1 by FerchogtX, based on DorriGa's code */
srom = NeoTextROM+0x20000;
dst = (unsigned char*)malloc(0x20000);
memcpy(dst+0x00000, srom+0x10000, 0x10000);
memcpy(dst+0x10000, srom+0x00000, 0x10000);
memcpy(srom, dst, 0x20000);
free(dst);
break;

case 5:
/* Original code for MAME by fataku */
/* This is for kf2k1pla */
       srom = NeoTextROM+0x20000;
       for (int i=0; i<0x20000; i++)
       srom[i]=BITSWAP08(srom[i],3,2,4,5,1,6,0,7);
break;

case 6:
/* Original code taken from MAME */
/* This is for CTHD2003 */
srom = NeoTextROM+0x20000;
dst = (unsigned char*)malloc(0x10000);
memcpy(dst+0x00000,srom+0x10000,0x08000);
memcpy(dst+0x08000,srom+0x08000,0x08000);
memcpy(srom+0x08000,dst,0x10000);
free(dst);
break;

case 7:
// Converted by Jimmy_Page (www.neofighters.com)
srom = NeoTextROM+0x20000;
for (int i=0; i<0x20000; i++)
srom[i]=BITSWAP08(srom[i],7,6,0,4,3,2,1,5);
break;

case 8:
srom = NeoTextROM+0x20000;
for (int i=0; i srom[i]=BITSWAP08(srom[i]^0xd2,4,0,7,2,5,1,6,3 );
break;

case 9:
/* thanks to dorriGa and arnoldso for analyze the scramble
Original Code by HalRIN, Converted by JiMMy_PaGe
This is for cthd2003 super plus */
srom = NeoTextROM+0x20000;
dst = (unsigned char*)malloc( 0x20000 );
int i, ofst;
memcpy( dst, srom, 0x20000 );
for( i=0; i<0x20000; i++ ){
ofst = BITSWAP24( (i & 0x1ffff),23,22,21,20,19,18,17,3,
               0,1,4,2,13,14,15,16,
               5,6,11,10,9,8,7,12 );

ofst += (i >> 17) << 17;
srom[i] = dst[ofst];
}
free( dst );
break;
}


Code: [Select]

nNeoTextROMFixType = 0;
for kof2k3bc S1,^_^
{"271-s1bc.bin", 0x080000, 0x4FB43DDF,    1}, //  2 Text layer tiles (scrambled)

==========================
nNeoTextROMFixType = 2;
for kof2k3bb S1,^_^
{"271-s1bb.bin", 0x080000, 0xB52800D8,    1}, //  2 Text layer tiles (scrambled)
Title: NeoTextROMFix code
Post by: Sho on February 26, 2005, 06:00:00 PM
thank you very much
Title: Re: NeoTextROMFix code
Post by: youngshare on July 16, 2005, 01:21:59 AM
Very very very Great code! :biggrin:
It helps me to get the "blending" HP of kof2003, thx!