Author Topic: Is this code meant to work ? svcchaos  (Read 3740 times)

Offline James33

  • Expert
  • *****
  • Posts: 532
  • Karma: +3/-0
  • The Mame Man
    • Emulation Zone
Is this code meant to work ? svcchaos
« on: November 21, 2004, 11:06:41 PM »
I tried a code for the svcchaos C roms but all i get is a black screen am I missing something here ?


Code: [Select]

/******************************************************************************
 Analyzed by HalRIN
 http://www52.tok2.com/home/foge/

ROM_START( svcchaos )
    ROM_REGION( 0x80000, REGION_GFX1, 0 )
    ROM_FILL(                 0x000000, 0x80000, 0 )

    ROM_REGION( 0x4000000, REGION_GFX3, 0 )
    ROM_LOAD( "269-c1.bin", 0x0000000, 0x2000000, CRC(1b608f9c) SHA1(4e70ad182da2ca18815bd3936efb04a06ebce01e) )
    ROM_LOAD( "269-c2.bin", 0x2000000, 0x2000000, CRC(5a95f294) SHA1(6123cc7b20b494076185d27c2ffea910e124b195) )
ROM_END
******************************************************************************/

#define BITSWAP32(val,B31,B30,B29,B28,B27,B26,B25,B24,B23,B22,B21,B20,B19,B18,B17,B16,B15,B14,B13,B12,B11,B10,B9,B8,B7,B6,B5,B4,B3,B2,B1,B0) \
        ((BIT(val,B31) << 31) | \
         (BIT(val,B30) << 30) | \
         (BIT(val,B29) << 29) | \
         (BIT(val,B28) << 28) | \
         (BIT(val,B27) << 27) | \
         (BIT(val,B26) << 26) | \
         (BIT(val,B25) << 25) | \
         (BIT(val,B24) << 24) | \
         (BIT(val,B23) << 23) | \
         (BIT(val,B22) << 22) | \
         (BIT(val,B21) << 21) | \
         (BIT(val,B20) << 20) | \
         (BIT(val,B19) << 19) | \
         (BIT(val,B18) << 18) | \
         (BIT(val,B17) << 17) | \
         (BIT(val,B16) << 16) | \
         (BIT(val,B15) << 15) | \
         (BIT(val,B14) << 14) | \
         (BIT(val,B13) << 13) | \
         (BIT(val,B12) << 12) | \
         (BIT(val,B11) << 11) | \
         (BIT(val,B10) << 10) | \
         (BIT(val, B9) <<  9) | \
         (BIT(val, B8) <<  8) | \
         (BIT(val, B7) <<  7) | \
         (BIT(val, B6) <<  6) | \
         (BIT(val, B5) <<  5) | \
         (BIT(val, B4) <<  4) | \
         (BIT(val, B3) <<  3) | \
         (BIT(val, B2) <<  2) | \
         (BIT(val, B1) <<  1) | \
         (BIT(val, B0) <<  0))

static void svcchaos_cx_sx_decrypt( void )
{
    const unsigned char xor1[ 4 ] = {
        0x34, 0x21, 0xc4, 0xe9,
    };

    int i;
    int ofst;
    UINT8 *src = memory_region( REGION_GFX3 );
    int len = memory_region_length( REGION_GFX3 );
    UINT8 *dst = malloc( len );

    for( i = 0; i < len; i++ ){
        src[ i ] ^= xor1[ (i % 4) ];
    }

    for( i = 0; i < len; i += 4 ){
        UINT32 *src32 = (UINT32*)&src[ i ];
        *src32 = BITSWAP32( *src32, 0x09, 0x0d, 0x13, 0x00, 0x17, 0x0f, 0x03, 0x05,
                                    0x04, 0x0c, 0x11, 0x1e, 0x12, 0x15, 0x0b, 0x06,
                                    0x1b, 0x0a, 0x1a, 0x1c, 0x14, 0x02, 0x0e, 0x1d,
                                    0x18, 0x08, 0x01, 0x10, 0x19, 0x1f, 0x07, 0x16 );
    }

    memcpy( dst, src, len );

    for( i = 0; i < len / 4; i++ ){
        ofst =  BITSWAP24( (i & 0x1fffff), 0x17, 0x16, 0x15, 0x04, 0x0b, 0x0e, 0x08, 0x0c,
                                           0x10, 0x00, 0x0a, 0x13, 0x03, 0x06, 0x02, 0x07,
                                           0x0d, 0x01, 0x11, 0x09, 0x14, 0x0f, 0x12, 0x05 );
        ofst ^= 0x0c8923;
        ofst += (i & 0xffe00000);

        memcpy( &src[ i * 4 ], &dst[ ofst * 4 ], 0x04 );
    }

    free( dst );

    kof2000_neogeo_gfx_decrypt(0x57);

    UINT8 *s1 = memory_region( REGION_GFX1 );
    size_t s1_size = memory_region_length( REGION_GFX1 );

    for( i = 0; i < s1_size; i++ ){
        s1[ i ] = BITSWAP8( s1[ i ] ^ 0xd2, 4, 0, 7, 2, 5, 1, 6, 3 );
    }
}

IQ Forum Member

Offline iq_132

  • Administrator
  • *****
  • Posts: 3612
  • Karma: +385/-0
  • Bare Knuckle!
    • NeoSource
Is this code meant to work ? svcchaos
« Reply #1 on: November 21, 2004, 11:32:38 PM »
Well, It doesn't work correctly for me either :(  I hadn't checked it in mame, only FBA.
All I get is more scrambled graphics.


Offline James33

  • Expert
  • *****
  • Posts: 532
  • Karma: +3/-0
  • The Mame Man
    • Emulation Zone
Is this code meant to work ? svcchaos
« Reply #2 on: November 22, 2004, 12:00:39 AM »
Oh ok did kof2003 C rom decrypt work in FBA as the text does not show in Mame at all with this code :(


Even the svcsplus code did not work untill i used a few lines from your FBA code :)


I think there is still code missing or somthing .

Code: [Select]

/******************************************************************************
 Analyzed by HalRIN
 http://www52.tok2.com/home/foge/

ROM_START( kof2003 )
    ROM_REGION( 0x100000, REGION_GFX1, 0 )
    ROM_FILL(                 0x000000, 0x100000, 0 )

    ROM_REGION( 0x6000000, REGION_GFX3, 0 )
    ROM_LOAD16_BYTE( "271-c1d.bin", 0x0000000, 0x1000000, CRC(c29acd28) SHA1(8a10409c5a9ad95fa9b56e94c14f1b96101fb179) )
    ROM_LOAD16_BYTE( "271-c2d.bin", 0x0000001, 0x1000000, CRC(328e80b1) SHA1(c7f8069488be1a88a2ea03718b6a131f5c96bd3f) )
    ROM_LOAD16_BYTE( "271-c3d.bin", 0x2000000, 0x1000000, CRC(020a11f1) SHA1(85cfae76234f72b0039ebc02f931bb2a9c10b1af) )
    ROM_LOAD16_BYTE( "271-c4d.bin", 0x2000001, 0x1000000, CRC(991b5ed2) SHA1(99c4c470bc9cb388773e27de6df4a16803fc7b45) )
    ROM_LOAD16_BYTE( "271-c5d.bin", 0x4000000, 0x1000000, CRC(c2de8b66) SHA1(40c2ea48fc20d470163a9dbb40c0276fc4cfceb9) )
    ROM_LOAD16_BYTE( "271-c6d.bin", 0x4000001, 0x1000000, CRC(3ff750db) SHA1(714f14a2eb2df6f25d10a6b6aff4b3adfbc7a5dc) )
ROM_END
******************************************************************************/

static void kof2003_sx_decrypt( void )
{
    int i;
    int tx_size = memory_region_length( REGION_GFX1 );
    int rom_size = memory_region_length( REGION_GFX3 );
    UINT8 *src;
    UINT8 *dst;

    src = memory_region( REGION_GFX3 ) + rom_size - 0x1000000 - 0x80000;
    dst = memory_region( REGION_GFX1 );

    for( i = 0; i < tx_size / 2; i++ ){
        dst[ i ] = src[ (i & ~0x1f) + ((i & 7) << 2) + ((~i & 8) >> 2) + ((i & 0x10) >> 4) ];
    }

    src = memory_region( REGION_GFX3 ) + rom_size - 0x80000;
    dst = memory_region( REGION_GFX1 ) + 0x80000;

    for( i = 0; i < tx_size / 2; i++ ){
        dst[ i ] = src[ (i & ~0x1f) + ((i & 7) << 2) + ((~i & 8) >> 2) + ((i & 0x10) >> 4) ];
    }

    dst = memory_region( REGION_GFX1 );
    for( i = 0; i < tx_size; i++ ){
        dst[ i ] = BITSWAP8( dst[ i ] ^ 0xd2, 4, 0, 7, 2, 5, 1, 6, 3 );
    }
}

IQ Forum Member

Offline iq_132

  • Administrator
  • *****
  • Posts: 3612
  • Karma: +385/-0
  • Bare Knuckle!
    • NeoSource
Is this code meant to work ? svcchaos
« Reply #3 on: November 22, 2004, 12:20:57 AM »
Works fine for me in fba.


Offline James33

  • Expert
  • *****
  • Posts: 532
  • Karma: +3/-0
  • The Mame Man
    • Emulation Zone
Is this code meant to work ? svcchaos
« Reply #4 on: November 22, 2004, 12:25:24 AM »
Yeah I got it working too :) I had code in the wrong place . Now for the kof2003 P decrypt code and it will be all done yay :)
IQ Forum Member

Offline James33

  • Expert
  • *****
  • Posts: 532
  • Karma: +3/-0
  • The Mame Man
    • Emulation Zone
svcchaos c roms working in Mame .
« Reply #5 on: November 22, 2004, 01:37:47 AM »
This should give an idea for FBA

Code: [Select]


ROM_START( svcchaos ) /* Jamma PCB */
        ROM_REGION( 0x600000, REGION_CPU1, 0 )
        ROM_LOAD16_WORD_SWAP( "269-p1.bin", 0x000000, 0x200000, CRC(336f219f) SHA1(d93459cb1447d70ff97506b84fc169e69f2e7560) )
ROM_LOAD16_WORD_SWAP( "269-p2.bin", 0x200000, 0x400000, CRC(e5a6589e) SHA1(cdd31645e8edbd7c0624a68c0e50e0687bcc90ba) )

ROM_REGION( 0x80000, REGION_GFX1, 0 )
ROM_FILL(                 0x000000, 0x80000, 0 )
ROM_REGION( 0x20000, REGION_GFX2, 0 )
ROM_LOAD( "sfix.sfx",  0x000000, 0x20000, CRC(354029fc) SHA1(4ae4bf23b4c2acff875775d4cbff5583893ce2a1) )

        NEO_BIOS_SOUND_128K( "269-m1d.bin", CRC(fd602218) SHA1(d7af0af3e116a7c2f594d1ca77a1289b4e31cd7e) )

        ROM_REGION( 0X1000000, REGION_SOUND1, ROMREGION_SOUNDONLY )
        /* decrypted */
        ROM_LOAD( "269-v1d.bin", 0x000000, 0x800000, CRC(dab37bef) SHA1(1f2f7159f932adad72b29f34a1b746932fd07b34) )
        ROM_LOAD( "269-v2d.bin", 0x800000, 0x800000, CRC(7b3e9487) SHA1(59f250b9c99a891c80204c3be307356b751b4c82) )
       
NO_DELTAT_REGION

ROM_REGION( 0x4000000, REGION_GFX3, 0 )
ROM_LOAD( "269-c1.bin", 0x0000000, 0x2000000, CRC(1b608f9c) SHA1(4e70ad182da2ca18815bd3936efb04a06ebce01e) )
ROM_LOAD( "269-c2.bin", 0x2000000, 0x2000000, CRC(5a95f294) SHA1(6123cc7b20b494076185d27c2ffea910e124b195) )
ROM_END


Code: [Select]

#define BITSWAP32(val,B31,B30,B29,B28,B27,B26,B25,B24,B23,B22,B21,B20,B19,B18,B17,B16,B15,B14,B13,B12,B11,B10,B9,B8,B7,B6,B5,B4,B3,B2,B1,B0) \
        ((BIT(val,B31) << 31) | \
         (BIT(val,B30) << 30) | \
         (BIT(val,B29) << 29) | \
         (BIT(val,B28) << 28) | \
         (BIT(val,B27) << 27) | \
         (BIT(val,B26) << 26) | \
         (BIT(val,B25) << 25) | \
         (BIT(val,B24) << 24) | \
         (BIT(val,B23) << 23) | \
         (BIT(val,B22) << 22) | \
         (BIT(val,B21) << 21) | \
         (BIT(val,B20) << 20) | \
         (BIT(val,B19) << 19) | \
         (BIT(val,B18) << 18) | \
         (BIT(val,B17) << 17) | \
         (BIT(val,B16) << 16) | \
         (BIT(val,B15) << 15) | \
         (BIT(val,B14) << 14) | \
         (BIT(val,B13) << 13) | \
         (BIT(val,B12) << 12) | \
         (BIT(val,B11) << 11) | \
         (BIT(val,B10) << 10) | \
         (BIT(val, B9) <<  9) | \
         (BIT(val, B8) <<  8) | \
         (BIT(val, B7) <<  7) | \
         (BIT(val, B6) <<  6) | \
         (BIT(val, B5) <<  5) | \
         (BIT(val, B4) <<  4) | \
         (BIT(val, B3) <<  3) | \
         (BIT(val, B2) <<  2) | \
         (BIT(val, B1) <<  1) | \
         (BIT(val, B0) <<  0))

static void svcchaos_cx_sx_decrypt( void )
{
    const unsigned char xor1[ 4 ] = {
        0x34, 0x21, 0xc4, 0xe9,
    };

    int i;
    int ofst;
    UINT8 *src = memory_region( REGION_GFX3 );
    int len = memory_region_length( REGION_GFX3 );
    UINT8 *dst = malloc( len );

    for( i = 0; i < len; i++ ){
        src[ i ] ^= xor1[ (i % 4) ];
    }

    for( i = 0; i < len; i += 4 ){
        UINT32 *src32 = (UINT32*)&src[ i ];
        *src32 = BITSWAP32( *src32, 0x09, 0x0d, 0x13, 0x00, 0x17, 0x0f, 0x03, 0x05,
                                    0x04, 0x0c, 0x11, 0x1e, 0x12, 0x15, 0x0b, 0x06,
                                    0x1b, 0x0a, 0x1a, 0x1c, 0x14, 0x02, 0x0e, 0x1d,
                                    0x18, 0x08, 0x01, 0x10, 0x19, 0x1f, 0x07, 0x16 );
    }

    memcpy( dst, src, len );

    for( i = 0; i < len / 4; i++ ){
        ofst =  BITSWAP24( (i & 0x1fffff), 0x17, 0x16, 0x15, 0x04, 0x0b, 0x0e, 0x08, 0x0c,
                                           0x10, 0x00, 0x0a, 0x13, 0x03, 0x06, 0x02, 0x07,
                                           0x0d, 0x01, 0x11, 0x09, 0x14, 0x0f, 0x12, 0x05 );
        ofst ^= 0x0c8923;
        ofst += (i & 0xffe00000);

        memcpy( &src[ i * 4 ], &dst[ ofst * 4 ], 0x04 );
    }

    free( dst );

kof2000_neogeo_gfx_decrypt(0x57);

    UINT8 *s1 = memory_region( REGION_GFX1 );
    size_t s1_size = memory_region_length( REGION_GFX1 );

    for( i = 0; i < s1_size; i++ ){
        s1[ i ] = BITSWAP8( s1[ i ] ^ 0xd2, 4, 0, 7, 2, 5, 1, 6, 3 );
    }
}

DRIVER_INIT( svcchaos )
{
neogeo_fix_bank_type = 2;
svcchaos_cx_sx_decrypt();
init_neogeo();
}
IQ Forum Member

Offline babytek

  • Newbies
  • *
  • Posts: 12
  • Karma: +0/-0
  • Junior Member
Is this code meant to work ? svcchaos
« Reply #6 on: November 23, 2004, 07:33:47 AM »
Works fine for me ;)

And if you want use svcnd clone of svcchaos, use this driver init :

Quote
DRIVER_INIT( svcnd )
{
   svcchaos_px_decrypt();
   
   init_neogeo();

   install_mem_read16_handler( 0, 0x2fe000, 0x2fffff, MRA16_RAM );
   install_mem_write16_handler( 0, 0x2fe000, 0x2fffff, MWA16_RAM );

   install_mem_read16_handler( 0, 0x2fffe0, 0x2fffef, mv0_prot_r );
   install_mem_write16_handler( 0, 0x2fffe0, 0x2fffef, mv0_prot_w );

   install_mem_read16_handler( 0, 0x2ffff0, 0x2ffff3, mv0_bankswitch_r );
   install_mem_write16_handler( 0, 0x2ffff0, 0x2ffff3, mv0_bankswitch_w );
}


:)