PGM big-endian patches from lantus.

This commit is contained in:
Barry Harris 2012-01-28 08:50:44 +00:00
parent b0360473f8
commit 1f6dad7e1e
3 changed files with 105 additions and 89 deletions

View File

@ -8,14 +8,14 @@ void pgm_decrypt_dw2()
UINT16 *src = (UINT16 *)PGM68KROM; UINT16 *src = (UINT16 *)PGM68KROM;
for (INT32 i = 0; i<nPGM68KROMLen/2; i++) { for (INT32 i = 0; i<nPGM68KROMLen/2; i++) {
UINT16 x = src[i]; UINT16 x = BURN_ENDIAN_SWAP_INT16(src[i]);
if ((i & 0x020890) == 0x000000) x ^= 0x0002; if ((i & 0x020890) == 0x000000) x ^= 0x0002;
if ((i & 0x020000) == 0x020000 && (i & 0x001500) != 0x001400) x ^= 0x0002; if ((i & 0x020000) == 0x020000 && (i & 0x001500) != 0x001400) x ^= 0x0002;
if ((i & 0x020400) == 0x000000 && (i & 0x002010) != 0x002010) x ^= 0x0400; if ((i & 0x020400) == 0x000000 && (i & 0x002010) != 0x002010) x ^= 0x0400;
if ((i & 0x020000) == 0x020000 && (i & 0x000148) != 0x000140) x ^= 0x0400; if ((i & 0x020000) == 0x020000 && (i & 0x000148) != 0x000140) x ^= 0x0400;
src[i] = x; src[i] = BURN_ENDIAN_SWAP_INT16(x);
} }
} }
@ -24,14 +24,14 @@ void pgm_decrypt_dw3()
UINT16 *src = (UINT16 *)PGM68KROM; UINT16 *src = (UINT16 *)PGM68KROM;
for (INT32 i = 0; i < nPGM68KROMLen/2; i++) { for (INT32 i = 0; i < nPGM68KROMLen/2; i++) {
UINT16 x = src[i]; UINT16 x = BURN_ENDIAN_SWAP_INT16(src[i]);
if ((i & 0x005460) == 0x001400) x ^= 0x0100; if ((i & 0x005460) == 0x001400) x ^= 0x0100;
if ((i & 0x005450) == 0x001040) x ^= 0x0100; if ((i & 0x005450) == 0x001040) x ^= 0x0100;
if ((i & 0x005e00) == 0x001c00) x ^= 0x0040; if ((i & 0x005e00) == 0x001c00) x ^= 0x0040;
if ((i & 0x005580) == 0x001100) x ^= 0x0040; if ((i & 0x005580) == 0x001100) x ^= 0x0040;
src[i] = x; src[i] = BURN_ENDIAN_SWAP_INT16(x);
} }
} }
@ -40,14 +40,14 @@ void pgm_decrypt_killbld()
UINT16 *src = (UINT16 *)PGM68KROM; UINT16 *src = (UINT16 *)PGM68KROM;
for (INT32 i = 0; i < nPGM68KROMLen/2; i++) { for (INT32 i = 0; i < nPGM68KROMLen/2; i++) {
UINT16 x = src[i]; UINT16 x = BURN_ENDIAN_SWAP_INT16(src[i]);
if ((i & 0x006d00) == 0x000400) x ^= 0x0008; if ((i & 0x006d00) == 0x000400) x ^= 0x0008;
if ((i & 0x006c80) == 0x000880) x ^= 0x0008; if ((i & 0x006c80) == 0x000880) x ^= 0x0008;
if ((i & 0x007500) == 0x002400) x ^= 0x1000; if ((i & 0x007500) == 0x002400) x ^= 0x1000;
if ((i & 0x007600) == 0x003200) x ^= 0x1000; if ((i & 0x007600) == 0x003200) x ^= 0x1000;
src[i] = x; src[i] = BURN_ENDIAN_SWAP_INT16(x);
} }
} }
@ -76,7 +76,7 @@ void pgm_decrypt_kov()
UINT16 *src = (UINT16 *)PGM68KROM; UINT16 *src = (UINT16 *)PGM68KROM;
for (INT32 i = 0; i < nPGM68KROMLen/2; i++) { for (INT32 i = 0; i < nPGM68KROMLen/2; i++) {
UINT16 x = src[i]; UINT16 x = BURN_ENDIAN_SWAP_INT16(src[i]);
if ((i & 0x040480) != 0x000080) x ^= 0x0001; if ((i & 0x040480) != 0x000080) x ^= 0x0001;
if ((i & 0x004008) == 0x004008) x ^= 0x0002; if ((i & 0x004008) == 0x004008) x ^= 0x0002;
@ -89,7 +89,7 @@ void pgm_decrypt_kov()
x ^= kov_tab[i & 0xff] << 8; x ^= kov_tab[i & 0xff] << 8;
src[i] = x; src[i] = BURN_ENDIAN_SWAP_INT16(x);
} }
} }
@ -117,7 +117,7 @@ void pgm_decrypt_kovsh()
UINT16 *src = (UINT16 *)PGM68KROM; UINT16 *src = (UINT16 *)PGM68KROM;
for (INT32 i = 0; i < nPGM68KROMLen/2; i++) { for (INT32 i = 0; i < nPGM68KROMLen/2; i++) {
UINT16 x = src[i]; UINT16 x = BURN_ENDIAN_SWAP_INT16(src[i]);
if ((i & 0x040080) != 0x000080) x ^= 0x0001; if ((i & 0x040080) != 0x000080) x ^= 0x0001;
if ((i & 0x004008) == 0x004008 && (i & 0x180000) != 0x000000) x ^= 0x0002; if ((i & 0x004008) == 0x004008 && (i & 0x180000) != 0x000000) x ^= 0x0002;
@ -130,7 +130,7 @@ void pgm_decrypt_kovsh()
x ^= kovsh_tab[i & 0xff] << 8; x ^= kovsh_tab[i & 0xff] << 8;
src[i] = x; src[i] = BURN_ENDIAN_SWAP_INT16(x);
} }
} }
@ -158,7 +158,7 @@ void pgm_decrypt_kovshp()
UINT16 *src = (UINT16 *)PGM68KROM; UINT16 *src = (UINT16 *)PGM68KROM;
for (INT32 i = 0; i < nPGM68KROMLen/2; i++) { for (INT32 i = 0; i < nPGM68KROMLen/2; i++) {
UINT16 x = src[i]; UINT16 x = BURN_ENDIAN_SWAP_INT16(src[i]);
if ((i & 0x040080) != 0x000080) x ^= 0x0001; if ((i & 0x040080) != 0x000080) x ^= 0x0001;
if ((i & 0x004008) == 0x004008 && (i & 0x180000) != 0x000000) x ^= 0x0002; if ((i & 0x004008) == 0x004008 && (i & 0x180000) != 0x000000) x ^= 0x0002;
@ -171,7 +171,7 @@ void pgm_decrypt_kovshp()
x ^= kovshp_tab[i & 0xff] << 8; x ^= kovshp_tab[i & 0xff] << 8;
src[i] = x; src[i] = BURN_ENDIAN_SWAP_INT16(x);
} }
} }
@ -199,7 +199,7 @@ void pgm_decrypt_photoy2k()
UINT16 *src = (UINT16 *)PGM68KROM; UINT16 *src = (UINT16 *)PGM68KROM;
for (INT32 i = 0; i < nPGM68KROMLen/2; i++) { for (INT32 i = 0; i < nPGM68KROMLen/2; i++) {
UINT16 x = src[i]; UINT16 x = BURN_ENDIAN_SWAP_INT16(src[i]);
if ((i & 0x40080) != 0x00080) x ^= 0x0001; if ((i & 0x40080) != 0x00080) x ^= 0x0001;
if ((i & 0x84008) == 0x84008) x ^= 0x0002; if ((i & 0x84008) == 0x84008) x ^= 0x0002;
@ -212,7 +212,7 @@ void pgm_decrypt_photoy2k()
x ^= photoy2k_tab[i & 0xff] << 8; x ^= photoy2k_tab[i & 0xff] << 8;
src[i] = x; src[i] = BURN_ENDIAN_SWAP_INT16(x);
} }
} }
@ -240,7 +240,7 @@ void pgm_decrypt_puzlstar()
UINT16 *src = (UINT16 *)PGM68KROM; UINT16 *src = (UINT16 *)PGM68KROM;
for (INT32 i = 0; i < nPGM68KROMLen/2; i++) { for (INT32 i = 0; i < nPGM68KROMLen/2; i++) {
UINT16 x = src[i]; UINT16 x = BURN_ENDIAN_SWAP_INT16(src[i]);
if ((i & 0x40480) != 0x00080) x ^= 0x0001; if ((i & 0x40480) != 0x00080) x ^= 0x0001;
if ((i & 0x00030) == 0x00010) x ^= 0x0004; if ((i & 0x00030) == 0x00010) x ^= 0x0004;
@ -252,7 +252,7 @@ void pgm_decrypt_puzlstar()
x ^= puzlstar_tab[i & 0xff] << 8; x ^= puzlstar_tab[i & 0xff] << 8;
src[i] = x; src[i] = BURN_ENDIAN_SWAP_INT16(x);
} }
} }
@ -280,7 +280,7 @@ void pgm_decrypt_puzzli2()
UINT16 *src = (UINT16 *)PGM68KROM; UINT16 *src = (UINT16 *)PGM68KROM;
for (INT32 i = 0; i < nPGM68KROMLen/2; i++) { for (INT32 i = 0; i < nPGM68KROMLen/2; i++) {
UINT16 x = src[i]; UINT16 x = BURN_ENDIAN_SWAP_INT16(src[i]);
if ((i & 0x040080) != 0x000080) x ^= 0x0001; if ((i & 0x040080) != 0x000080) x ^= 0x0001;
if ((i & 0x004008) == 0x004008) x ^= 0x0002; if ((i & 0x004008) == 0x004008) x ^= 0x0002;
@ -293,7 +293,7 @@ void pgm_decrypt_puzzli2()
x ^= puzzli2_tab[i & 0xff] << 8; x ^= puzzli2_tab[i & 0xff] << 8;
src[i] = x; src[i] = BURN_ENDIAN_SWAP_INT16(x);
} }
} }
@ -321,7 +321,7 @@ void pgm_decrypt_oldsplus()
UINT16 *src = (UINT16 *)PGM68KROM; UINT16 *src = (UINT16 *)PGM68KROM;
for (INT32 i = 0; i < nPGM68KROMLen/2; i++) { for (INT32 i = 0; i < nPGM68KROMLen/2; i++) {
UINT16 x = src[i]; UINT16 x = BURN_ENDIAN_SWAP_INT16(src[i]);
if ((i & 0x040480) != 0x000080) x ^= 0x0001; if ((i & 0x040480) != 0x000080) x ^= 0x0001;
if ((i & 0x004008) == 0x004008) x ^= 0x0002; if ((i & 0x004008) == 0x004008) x ^= 0x0002;
@ -334,7 +334,7 @@ void pgm_decrypt_oldsplus()
x ^= oldsplus_tab[i & 0xff] << 8; x ^= oldsplus_tab[i & 0xff] << 8;
src[i] = x; src[i] = BURN_ENDIAN_SWAP_INT16(x);
} }
} }
@ -362,7 +362,7 @@ void pgm_decrypt_py2k2() // and ddp3
UINT16 *src = (UINT16 *)PGM68KROM; UINT16 *src = (UINT16 *)PGM68KROM;
for (INT32 i = 0; i < nPGM68KROMLen/2; i++) { for (INT32 i = 0; i < nPGM68KROMLen/2; i++) {
UINT16 x = src[i]; UINT16 x = BURN_ENDIAN_SWAP_INT16(src[i]);
if ((i & 0x040480) != 0x000080) x ^= 0x0001; if ((i & 0x040480) != 0x000080) x ^= 0x0001;
if ((i & 0x084008) == 0x084008) x ^= 0x0002; if ((i & 0x084008) == 0x084008) x ^= 0x0002;
@ -375,7 +375,7 @@ void pgm_decrypt_py2k2() // and ddp3
x ^= py2k2_tab[i & 0xff] << 8; x ^= py2k2_tab[i & 0xff] << 8;
src[i] = x; src[i] = BURN_ENDIAN_SWAP_INT16(x);
} }
} }
@ -403,7 +403,7 @@ void pgm_decrypt_ketsui()
UINT16 *src = (UINT16 *)PGM68KROM; UINT16 *src = (UINT16 *)PGM68KROM;
for (INT32 i = 0; i < nPGM68KROMLen/2; i++) { for (INT32 i = 0; i < nPGM68KROMLen/2; i++) {
UINT16 x = src[i]; UINT16 x = BURN_ENDIAN_SWAP_INT16(src[i]);
if ((i & 0x040480) != 0x000080) x ^= 0x0001; if ((i & 0x040480) != 0x000080) x ^= 0x0001;
if ((i & 0x004008) == 0x004008) x ^= 0x0002; if ((i & 0x004008) == 0x004008) x ^= 0x0002;
@ -416,7 +416,7 @@ void pgm_decrypt_ketsui()
x ^= ketsui_tab[i & 0xff] << 8; x ^= ketsui_tab[i & 0xff] << 8;
src[i] = x; src[i] = BURN_ENDIAN_SWAP_INT16(x);
} }
} }
@ -444,7 +444,7 @@ void pgm_decrypt_espgaluda()
UINT16 *src = (UINT16 *)PGM68KROM; UINT16 *src = (UINT16 *)PGM68KROM;
for (INT32 i = 0; i < nPGM68KROMLen/2; i++) { for (INT32 i = 0; i < nPGM68KROMLen/2; i++) {
UINT16 x = src[i]; UINT16 x = BURN_ENDIAN_SWAP_INT16(src[i]);
if ((i & 0x040480) != 0x000080) x ^= 0x0001; if ((i & 0x040480) != 0x000080) x ^= 0x0001;
if ((i & 0x084008) == 0x084008) x ^= 0x0002; if ((i & 0x084008) == 0x084008) x ^= 0x0002;
@ -457,7 +457,7 @@ void pgm_decrypt_espgaluda()
x ^= espgal_tab[i & 0xff] << 8; x ^= espgal_tab[i & 0xff] << 8;
src[i] = x; src[i] = BURN_ENDIAN_SWAP_INT16(x);
} }
} }
@ -466,7 +466,7 @@ void pgm_decrypt_svg()
UINT16 *src = (UINT16 *)PGMUSER0; UINT16 *src = (UINT16 *)PGMUSER0;
for (INT32 i = 0; i < nPGMExternalARMLen/2; i++) { for (INT32 i = 0; i < nPGMExternalARMLen/2; i++) {
UINT16 x = src[i]; UINT16 x = BURN_ENDIAN_SWAP_INT16(src[i]);
if ((i & 0x040080) != 0x000080) x ^= 0x0001; if ((i & 0x040080) != 0x000080) x ^= 0x0001;
if ((i & 0x004008) == 0x004008) x ^= 0x0002; if ((i & 0x004008) == 0x004008) x ^= 0x0002;
@ -477,7 +477,7 @@ void pgm_decrypt_svg()
if ((i & 0x011800) != 0x010000) x ^= 0x0040; if ((i & 0x011800) != 0x010000) x ^= 0x0040;
if ((i & 0x000820) == 0x000820) x ^= 0x0080; if ((i & 0x000820) == 0x000820) x ^= 0x0080;
src[i] = x; src[i] = BURN_ENDIAN_SWAP_INT16(x);
} }
} }
@ -505,7 +505,7 @@ void pgm_decrypt_dfront()
UINT16 *src = (UINT16 *)PGMUSER0; UINT16 *src = (UINT16 *)PGMUSER0;
for (INT32 i = 0; i < nPGMExternalARMLen/2; i++) { for (INT32 i = 0; i < nPGMExternalARMLen/2; i++) {
UINT16 x = src[i]; UINT16 x = BURN_ENDIAN_SWAP_INT16(src[i]);
if ((i & 0x040080) != 0x000080) x ^= 0x0001; if ((i & 0x040080) != 0x000080) x ^= 0x0001;
if ((i & 0x104008) == 0x104008) x ^= 0x0002; if ((i & 0x104008) == 0x104008) x ^= 0x0002;
@ -518,7 +518,7 @@ void pgm_decrypt_dfront()
x ^= dfront_tab[(i >> 1) & 0xff] << 8; x ^= dfront_tab[(i >> 1) & 0xff] << 8;
src[i] = x; src[i] = BURN_ENDIAN_SWAP_INT16(x);
} }
} }
@ -546,7 +546,7 @@ void pgm_decrypt_ddp2()
UINT16 *src = (UINT16 *)PGMUSER0; UINT16 *src = (UINT16 *)PGMUSER0;
for (INT32 i = 0; i < nPGMExternalARMLen/2; i++) { for (INT32 i = 0; i < nPGMExternalARMLen/2; i++) {
UINT16 x = src[i]; UINT16 x = BURN_ENDIAN_SWAP_INT16(src[i]);
if ((i & 0x0480) != 0x0080) x ^= 0x0001; if ((i & 0x0480) != 0x0080) x ^= 0x0001;
if ((i & 0x0042) != 0x0042) x ^= 0x0008; if ((i & 0x0042) != 0x0042) x ^= 0x0008;
@ -557,7 +557,7 @@ void pgm_decrypt_ddp2()
x ^= ddp2_tab[(i >> 1) & 0xff] << 8; x ^= ddp2_tab[(i >> 1) & 0xff] << 8;
src[i] = x; src[i] = BURN_ENDIAN_SWAP_INT16(x);
} }
} }
@ -585,7 +585,7 @@ void pgm_decrypt_martmast() // and dw2001
UINT16 *src = (UINT16 *)PGMUSER0; UINT16 *src = (UINT16 *)PGMUSER0;
for (INT32 i = 0; i < nPGMExternalARMLen/2; i++) { for (INT32 i = 0; i < nPGMExternalARMLen/2; i++) {
UINT16 x = src[i]; UINT16 x = BURN_ENDIAN_SWAP_INT16(src[i]);
if ((i & 0x040480) != 0x000080) x ^= 0x0001; if ((i & 0x040480) != 0x000080) x ^= 0x0001;
if ((i & 0x004008) == 0x004008) x ^= 0x0002; if ((i & 0x004008) == 0x004008) x ^= 0x0002;
@ -598,7 +598,7 @@ void pgm_decrypt_martmast() // and dw2001
x ^= mm_tab[(i >> 1) & 0xff] << 8; x ^= mm_tab[(i >> 1) & 0xff] << 8;
src[i] = x; src[i] = BURN_ENDIAN_SWAP_INT16(x);
} }
} }
@ -626,7 +626,7 @@ void pgm_decrypt_kov2()
UINT16 *src = (UINT16 *)PGMUSER0; UINT16 *src = (UINT16 *)PGMUSER0;
for (INT32 i = 0; i < nPGMExternalARMLen/2; i++) { for (INT32 i = 0; i < nPGMExternalARMLen/2; i++) {
UINT16 x = src[i]; UINT16 x = BURN_ENDIAN_SWAP_INT16(src[i]);
if ((i & 0x40080) != 0x00080) x ^= 0x0001; if ((i & 0x40080) != 0x00080) x ^= 0x0001;
if ((i & 0x80030) == 0x80010) x ^= 0x0004; if ((i & 0x80030) == 0x80010) x ^= 0x0004;
@ -638,7 +638,7 @@ void pgm_decrypt_kov2()
x ^= kov2_tab[(i >> 1) & 0xff] << 8; x ^= kov2_tab[(i >> 1) & 0xff] << 8;
src[i] = x; src[i] = BURN_ENDIAN_SWAP_INT16(x);
} }
} }
@ -666,7 +666,7 @@ void pgm_decrypt_kov2p()
UINT16 *src = (UINT16*)PGMUSER0; UINT16 *src = (UINT16*)PGMUSER0;
for (INT32 i = 0; i < nPGMExternalARMLen/2; i++) { for (INT32 i = 0; i < nPGMExternalARMLen/2; i++) {
UINT16 x = src[i]; UINT16 x = BURN_ENDIAN_SWAP_INT16(src[i]);
if ((i & 0x040080) != 0x000080) x ^= 0x0001; if ((i & 0x040080) != 0x000080) x ^= 0x0001;
if ((i & 0x004008) == 0x004008) x ^= 0x0002; if ((i & 0x004008) == 0x004008) x ^= 0x0002;
@ -679,7 +679,7 @@ void pgm_decrypt_kov2p()
x ^= kov2p_tab[(i >> 1) & 0xff] << 8; x ^= kov2p_tab[(i >> 1) & 0xff] << 8;
src[i] = x; src[i] = BURN_ENDIAN_SWAP_INT16(x);
} }
} }
@ -707,7 +707,7 @@ void pgm_decrypt_theglad()
UINT16 *src = (UINT16*)PGMUSER0; UINT16 *src = (UINT16*)PGMUSER0;
for (INT32 i = 0; i < nPGMExternalARMLen/2; i++) { for (INT32 i = 0; i < nPGMExternalARMLen/2; i++) {
UINT16 x = src[i]; UINT16 x = BURN_ENDIAN_SWAP_INT16(src[i]);
if ((i & 0x040080) != 0x000080) x ^= 0x0001; if ((i & 0x040080) != 0x000080) x ^= 0x0001;
if ((i & 0x104008) == 0x104008) x ^= 0x0002; if ((i & 0x104008) == 0x104008) x ^= 0x0002;
@ -720,7 +720,7 @@ void pgm_decrypt_theglad()
x ^= theglad_tab[(i >> 1) & 0xff] << 8; x ^= theglad_tab[(i >> 1) & 0xff] << 8;
src[i] = x; src[i] = BURN_ENDIAN_SWAP_INT16(x);
} }
} }
@ -748,7 +748,7 @@ void pgm_decrypt_killbldp()
UINT16 *src = (UINT16*)PGMUSER0; UINT16 *src = (UINT16*)PGMUSER0;
for (INT32 i = 0; i< nPGMExternalARMLen/2; i++) { for (INT32 i = 0; i< nPGMExternalARMLen/2; i++) {
UINT16 x = src[i]; UINT16 x = BURN_ENDIAN_SWAP_INT16(src[i]);
if ((i & 0x040480) != 0x000080) x ^= 0x0001; if ((i & 0x040480) != 0x000080) x ^= 0x0001;
if ((i & 0x104008) == 0x104008) x ^= 0x0002; if ((i & 0x104008) == 0x104008) x ^= 0x0002;
@ -761,7 +761,7 @@ void pgm_decrypt_killbldp()
x ^= killbldp_tab[(i >> 1) & 0xff] << 8; x ^= killbldp_tab[(i >> 1) & 0xff] << 8;
src[i] = x; src[i] = BURN_ENDIAN_SWAP_INT16(x);
} }
} }
@ -789,7 +789,7 @@ void pgm_decrypt_happy6in1()
UINT16 *src = (UINT16*)PGMUSER0; UINT16 *src = (UINT16*)PGMUSER0;
for (INT32 i = 0; i < nPGMExternalARMLen/2; i++) { for (INT32 i = 0; i < nPGMExternalARMLen/2; i++) {
UINT16 x = src[i]; UINT16 x = BURN_ENDIAN_SWAP_INT16(src[i]);
if ((i & 0x040480) != 0x000080) x ^= 0x0001; if ((i & 0x040480) != 0x000080) x ^= 0x0001;
if ((i & 0x104008) == 0x104008) x ^= 0x0002; if ((i & 0x104008) == 0x104008) x ^= 0x0002;
@ -802,7 +802,7 @@ void pgm_decrypt_happy6in1()
x ^= happy6in1_tab[(i >> 1) & 0xff] << 8; x ^= happy6in1_tab[(i >> 1) & 0xff] << 8;
src[i] = x; src[i] = BURN_ENDIAN_SWAP_INT16(x);
} }
} }
@ -836,7 +836,7 @@ void pgm_decode_kovqhsgs_tile_data(UINT8 *source)
{ {
j = BITSWAP24(i, 23, 22, 9, 8, 21, 18, 0, 1, 2, 3, 16, 15, 14, 13, 12, 11, 10, 19, 20, 17, 7, 6, 5, 4); j = BITSWAP24(i, 23, 22, 9, 8, 21, 18, 0, 1, 2, 3, 16, 15, 14, 13, 12, 11, 10, 19, 20, 17, 7, 6, 5, 4);
dst[j] = BITSWAP16(src[i], 1, 14, 8, 7, 0, 15, 6, 9, 13, 2, 5, 10, 12, 3, 4, 11); dst[j] = BURN_ENDIAN_SWAP_INT16(BITSWAP16(BURN_ENDIAN_SWAP_INT16(src[i]), 1, 14, 8, 7, 0, 15, 6, 9, 13, 2, 5, 10, 12, 3, 4, 11));
} }
memcpy (src, dst, 0x800000); memcpy (src, dst, 0x800000);
@ -862,7 +862,7 @@ static void pgm_decode_kovqhsgs_program()
{ {
j = BITSWAP24(i, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 6, 7, 5, 4, 3, 2, 1, 0); j = BITSWAP24(i, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 6, 7, 5, 4, 3, 2, 1, 0);
dst[j] = BITSWAP16(src[i], 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 4, 5, 3, 2, 1, 0); dst[j] = BURN_ENDIAN_SWAP_INT16(BITSWAP16(BURN_ENDIAN_SWAP_INT16(src[i]), 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 4, 5, 3, 2, 1, 0));
} }
memcpy (src, dst, 0x400000); memcpy (src, dst, 0x400000);
@ -892,7 +892,7 @@ static void pgm_decode_kovlsqh2_program()
{ {
j = BITSWAP24(i, 23, 22, 21, 20, 19, 16, 15, 14, 13, 12, 11, 10, 9, 8, 0, 1, 2, 3, 4, 5, 6, 18, 17, 7); j = BITSWAP24(i, 23, 22, 21, 20, 19, 16, 15, 14, 13, 12, 11, 10, 9, 8, 0, 1, 2, 3, 4, 5, 6, 18, 17, 7);
dst[j] = src[i]; dst[j] = BURN_ENDIAN_SWAP_INT16(src[i]);
} }
memcpy (src, dst, 0x400000); memcpy (src, dst, 0x400000);

View File

@ -321,18 +321,18 @@ static void pgm_drawsprites()
{ {
if (source[4] == 0) break; // right? if (source[4] == 0) break; // right?
INT32 xpos = source[0] & 0x07ff; INT32 xpos = BURN_ENDIAN_SWAP_INT16(source[0]) & 0x07ff;
INT32 ypos = source[1] & 0x03ff; INT32 ypos = BURN_ENDIAN_SWAP_INT16(source[1]) & 0x03ff;
INT32 xzom = (source[0] & 0x7800) >> 11; INT32 xzom = (BURN_ENDIAN_SWAP_INT16(source[0]) & 0x7800) >> 11;
INT32 xgrow= (source[0] & 0x8000) >> 15; INT32 xgrow= (BURN_ENDIAN_SWAP_INT16(source[0]) & 0x8000) >> 15;
INT32 yzom = (source[1] & 0x7800) >> 11; INT32 yzom = (BURN_ENDIAN_SWAP_INT16(source[1]) & 0x7800) >> 11;
INT32 ygrow= (source[1] & 0x8000) >> 15; INT32 ygrow= (BURN_ENDIAN_SWAP_INT16(source[1]) & 0x8000) >> 15;
INT32 palt = (source[2] & 0x1f00) >> 8; INT32 palt = (BURN_ENDIAN_SWAP_INT16(source[2]) & 0x1f00) >> 8;
INT32 flip = (source[2] & 0x6000) >> 13; INT32 flip = (BURN_ENDIAN_SWAP_INT16(source[2]) & 0x6000) >> 13;
INT32 boff =((source[2] & 0x007f) << 16) | (source[3] & 0xffff); INT32 boff =((BURN_ENDIAN_SWAP_INT16(source[2]) & 0x007f) << 16) | (BURN_ENDIAN_SWAP_INT16(source[3]) & 0xffff);
INT32 wide = (source[4] & 0x7e00) >> 9; INT32 wide = (BURN_ENDIAN_SWAP_INT16(source[4]) & 0x7e00) >> 9;
INT32 prio = (source[2] & 0x0080) >> 7; INT32 prio = (BURN_ENDIAN_SWAP_INT16(source[2]) & 0x0080) >> 7;
INT32 high = source[4] & 0x01ff; INT32 high = BURN_ENDIAN_SWAP_INT16(source[4]) & 0x01ff;
if (xgrow) xzom = 0x10-xzom; if (xgrow) xzom = 0x10-xzom;
if (ygrow) yzom = 0x10-yzom; if (ygrow) yzom = 0x10-yzom;
@ -366,12 +366,12 @@ static void draw_text()
{ {
UINT16 *vram = (UINT16*)PGMTxtRAM; UINT16 *vram = (UINT16*)PGMTxtRAM;
INT32 scrollx = ((INT16)PGMVidReg[0x6000 / 2]) & 0x1ff; INT32 scrollx = ((INT16)BURN_ENDIAN_SWAP_INT16(PGMVidReg[0x6000 / 2])) & 0x1ff;
INT32 scrolly = ((INT16)PGMVidReg[0x5000 / 2]) & 0x0ff; INT32 scrolly = ((INT16)BURN_ENDIAN_SWAP_INT16(PGMVidReg[0x5000 / 2])) & 0x0ff;
for (INT32 offs = 0; offs < 64 * 32; offs++) for (INT32 offs = 0; offs < 64 * 32; offs++)
{ {
INT32 code = vram[offs * 2]; INT32 code = BURN_ENDIAN_SWAP_INT16(vram[offs * 2]);
if (texttrans[code] == 0) continue; // transparent if (texttrans[code] == 0) continue; // transparent
INT32 sx = (offs & 0x3f) << 3; INT32 sx = (offs & 0x3f) << 3;
@ -384,7 +384,7 @@ static void draw_text()
if (sx >= nScreenWidth || sy >= nScreenHeight) continue; if (sx >= nScreenWidth || sy >= nScreenHeight) continue;
INT32 attr = vram[offs * 2 + 1]; INT32 attr = BURN_ENDIAN_SWAP_INT16(vram[offs * 2 + 1]);
INT32 color = ((attr & 0x3e) >> 1) | 0x80; INT32 color = ((attr & 0x3e) >> 1) | 0x80;
INT32 flipx = (attr & 0x40); INT32 flipx = (attr & 0x40);
INT32 flipy = (attr & 0x80); INT32 flipy = (attr & 0x80);
@ -462,15 +462,15 @@ static void draw_background()
UINT16 *dst = pTransDraw; UINT16 *dst = pTransDraw;
UINT16 *rowscroll = PGMRowRAM; UINT16 *rowscroll = PGMRowRAM;
INT32 yscroll = (INT16)PGMVidReg[0x2000 / 2]; INT32 yscroll = (INT16)BURN_ENDIAN_SWAP_INT16(PGMVidReg[0x2000 / 2]);
INT32 xscroll = (INT16)PGMVidReg[0x3000 / 2]; INT32 xscroll = (INT16)BURN_ENDIAN_SWAP_INT16(PGMVidReg[0x3000 / 2]);
// check to see if we need to do line scroll // check to see if we need to do line scroll
INT32 t = 0; INT32 t = 0;
{ {
UINT16 *rs = rowscroll; UINT16 *rs = rowscroll;
for (INT32 i = 0; i < 224; i++) { for (INT32 i = 0; i < 224; i++) {
if (rs[0] != rs[i]) { if (BURN_ENDIAN_SWAP_INT16(rs[0]) != BURN_ENDIAN_SWAP_INT16(rs[i])) {
t = 1; t = 1;
break; break;
} }
@ -495,12 +495,12 @@ static void draw_background()
if (sx >= nScreenWidth || sy >= nScreenHeight) continue; if (sx >= nScreenWidth || sy >= nScreenHeight) continue;
INT32 code = vram[offs * 2]; INT32 code = BURN_ENDIAN_SWAP_INT16(vram[offs * 2]);
if (code >= nTileMask) continue; if (code >= nTileMask) continue;
if (tiletrans[code] == 0) continue; // transparent if (tiletrans[code] == 0) continue; // transparent
INT32 color = ((vram[offs*2+1] & 0x3e) >> 1) | 0x20; INT32 color = ((BURN_ENDIAN_SWAP_INT16(vram[offs*2+1]) & 0x3e) >> 1) | 0x20;
INT32 flipy = vram[offs*2+1] & 0x80; INT32 flipy = BURN_ENDIAN_SWAP_INT16(vram[offs*2+1]) & 0x80;
INT32 flipx = vram[offs*2+1] & 0x40; INT32 flipx = BURN_ENDIAN_SWAP_INT16(vram[offs*2+1]) & 0x40;
if (sx < 0 || sy < 0 || sx >= nScreenWidth - 32 || sy >= nScreenHeight - 32) if (sx < 0 || sy < 0 || sx >= nScreenWidth - 32 || sy >= nScreenHeight - 32)
{ {
@ -584,11 +584,11 @@ static void draw_background()
INT32 offs = ((scrolly & 0x1e0) << 2) | (((scrollx + x) & 0x7e0) >> 4); INT32 offs = ((scrolly & 0x1e0) << 2) | (((scrollx + x) & 0x7e0) >> 4);
INT32 code = vram[offs]; INT32 code = BURN_ENDIAN_SWAP_INT16(vram[offs]);
if (code >= nTileMask) continue; if (code >= nTileMask) continue;
if (tiletrans[code] == 0) continue; if (tiletrans[code] == 0) continue;
INT32 attr = vram[offs + 1]; INT32 attr = BURN_ENDIAN_SWAP_INT16(vram[offs + 1]);
INT32 color = ((attr & 0x3e) << 4) | 0x400; INT32 color = ((attr & 0x3e) << 4) | 0x400;
INT32 flipx = ((attr & 0x40) >> 6) * 0x1f; INT32 flipx = ((attr & 0x40) >> 6) * 0x1f;
INT32 flipy = ((attr & 0x80) >> 7) * 0x1f; INT32 flipy = ((attr & 0x80) >> 7) * 0x1f;

View File

@ -560,7 +560,7 @@ static void IGS022_do_dma(UINT16 src, UINT16 dst, UINT16 size, UINT16 mode)
{ {
for (INT32 x = 0; x < size; x++) for (INT32 x = 0; x < size; x++)
{ {
UINT16 dat2 = PROTROM[src + x]; UINT16 dat2 = BURN_ENDIAN_SWAP_INT16(PROTROM[src + x]);
UINT8 extraoffset = param & 0xfe; UINT8 extraoffset = param & 0xfe;
UINT8* dectable = (UINT8 *)PROTROM; UINT8* dectable = (UINT8 *)PROTROM;
@ -573,10 +573,18 @@ static void IGS022_do_dma(UINT16 src, UINT16 dst, UINT16 size, UINT16 mode)
if (mode==2) dat2 += extraxor; if (mode==2) dat2 += extraxor;
if (mode==1) dat2 -= extraxor; if (mode==1) dat2 -= extraxor;
sharedprotram[dst + x] = dat2; sharedprotram[dst + x] = BURN_ENDIAN_SWAP_INT16(dat2);
} }
if ((mode==3) && (param==0x54) && (src*2==0x2120) && (dst*2==0x2600)) sharedprotram[0x2600 / 2] = 0x4e75; // hack if ((mode==3) && (param==0x54) && (src*2==0x2120) && (dst*2==0x2600))
{
#ifdef LSB_FIRST
sharedprotram[0x2600 / 2] = 0x4e75; // hack
#else
sharedprotram[0x2600 / 2] = 0x754e;
#endif
}
} }
break; break;
@ -610,12 +618,12 @@ static void IGS022_do_dma(UINT16 src, UINT16 dst, UINT16 size, UINT16 mode)
static void IGS022_handle_command() static void IGS022_handle_command()
{ {
UINT16 cmd = sharedprotram[0x200/2]; UINT16 cmd = BURN_ENDIAN_SWAP_INT16(sharedprotram[0x200/2]);
if (cmd == 0x6d) // Store values to asic ram if (cmd == 0x6d) // Store values to asic ram
{ {
UINT32 p1 = (sharedprotram[0x298/2] << 16) | sharedprotram[0x29a/2]; UINT32 p1 = BURN_ENDIAN_SWAP_INT16((sharedprotram[0x298/2] << 16)) | BURN_ENDIAN_SWAP_INT16(sharedprotram[0x29a/2]);
UINT32 p2 = (sharedprotram[0x29c/2] << 16) | sharedprotram[0x29e/2]; UINT32 p2 = BURN_ENDIAN_SWAP_INT16((sharedprotram[0x29c/2] << 16)) | BURN_ENDIAN_SWAP_INT16(sharedprotram[0x29e/2]);
if ((p2 & 0xffff) == 0x9) // Set value if ((p2 & 0xffff) == 0x9) // Set value
{ {
@ -638,17 +646,17 @@ static void IGS022_handle_command()
if ((p2 & 0xffff) == 0xa) // Get value if ((p2 & 0xffff) == 0xa) // Get value
{ {
INT32 reg = (p1 >> 16) & 0x00ff; INT32 reg = (p1 >> 16) & 0x00ff;
sharedprotram[0x29c/2] = (kb_regs[reg] >> 16) & 0xffff; sharedprotram[0x29c/2] = BURN_ENDIAN_SWAP_INT16((kb_regs[reg] >> 16) & 0xffff);
sharedprotram[0x29e/2] = (kb_regs[reg] >> 0) & 0xffff; sharedprotram[0x29e/2] = BURN_ENDIAN_SWAP_INT16((kb_regs[reg] >> 0) & 0xffff);
} }
} }
if (cmd == 0x4f) // memcpy with encryption / scrambling if (cmd == 0x4f) // memcpy with encryption / scrambling
{ {
UINT16 src = sharedprotram[0x290 / 2] >> 1; // ? UINT16 src = BURN_ENDIAN_SWAP_INT16(sharedprotram[0x290 / 2]) >> 1; // ?
UINT16 dst = sharedprotram[0x292 / 2]; UINT16 dst = BURN_ENDIAN_SWAP_INT16(sharedprotram[0x292 / 2]);
UINT16 size = sharedprotram[0x294 / 2]; UINT16 size = BURN_ENDIAN_SWAP_INT16(sharedprotram[0x294 / 2]);
UINT16 mode = sharedprotram[0x296 / 2]; UINT16 mode = BURN_ENDIAN_SWAP_INT16(sharedprotram[0x296 / 2]);
IGS022_do_dma(src, dst, size, mode); IGS022_do_dma(src, dst, size, mode);
} }
@ -1177,7 +1185,7 @@ static UINT16 __fastcall asic27a_read_word(UINT32 address)
{ {
if ((address & 0xff0000) == 0xd00000) { if ((address & 0xff0000) == 0xd00000) {
pgm_cpu_sync(); pgm_cpu_sync();
return *((UINT16*)(PGMARMShareRAM + (address & 0xfffe))); return BURN_ENDIAN_SWAP_INT16(*((UINT16*)(PGMARMShareRAM + (address & 0xfffe))));
} }
if ((address & 0xfffffc) == 0xd10000) { if ((address & 0xfffffc) == 0xd10000) {
@ -1269,7 +1277,7 @@ static void __fastcall kovsh_asic27a_write_word(UINT32 address, UINT16 data)
static UINT16 __fastcall kovsh_asic27a_read_word(UINT32 address) static UINT16 __fastcall kovsh_asic27a_read_word(UINT32 address)
{ {
if ((address & 0xffffc0) == 0x4f0000) { if ((address & 0xffffc0) == 0x4f0000) {
return *((UINT16*)(PGMARMShareRAM + (address & 0x3e))); return BURN_ENDIAN_SWAP_INT16(*((UINT16*)(PGMARMShareRAM + (address & 0x3e))));
} }
switch (address) switch (address)
@ -1292,7 +1300,7 @@ static void kovsh_asic27a_arm7_write_word(UINT32 address, UINT16 data)
{ {
// written... but never read? // written... but never read?
if ((address & 0xffffff80) == 0x50800000) { if ((address & 0xffffff80) == 0x50800000) {
*((UINT16*)(PGMARMShareRAM + ((address>>1) & 0x3e))) = data; *((UINT16*)(PGMARMShareRAM + ((address>>1) & 0x3e))) = BURN_ENDIAN_SWAP_INT16(data);
return; return;
} }
} }
@ -1495,7 +1503,7 @@ static UINT16 __fastcall olds_mainram_read_word(UINT32 address)
{ {
if (SekGetPC(-1) >= 0x100000 && address != 0x8178d8) SekWriteWord(0x8178f4, SekReadWord(0x8178D8)); if (SekGetPC(-1) >= 0x100000 && address != 0x8178d8) SekWriteWord(0x8178f4, SekReadWord(0x8178D8));
return *((UINT16*)(PGM68KRAM + (address & 0x1fffe))); return BURN_ENDIAN_SWAP_INT16(*((UINT16*)(PGM68KRAM + (address & 0x1fffe))));
} }
static UINT8 __fastcall olds_mainram_read_byte(UINT32 address) static UINT8 __fastcall olds_mainram_read_byte(UINT32 address)
@ -1532,7 +1540,15 @@ void install_protection_asic25_asic28_olds()
UINT16 *gptr = (UINT16*)(PGMUSER0 + 0x10000); UINT16 *gptr = (UINT16*)(PGMUSER0 + 0x10000);
for(INT32 i = 0; i < 0x4000 / 2; i++) { for(INT32 i = 0; i < 0x4000 / 2; i++) {
if (gptr[i] == (0xffff - i)) gptr[i] = 0x4e75; if (gptr[i] == (0xffff - i))
{
#ifdef LSB_FIRST
gptr[i] = 0x4e75;
#else
gptr[i] = 0x754e;
#endif
}
} }
} }