Manually applied BigEndian fixes for CPS-1/2 from Lantus

This commit is contained in:
Barry Harris 2012-01-24 15:40:34 +00:00
parent ad6ebb20e8
commit 3030c35f11
8 changed files with 69 additions and 61 deletions

View File

@ -741,9 +741,9 @@ static void cps2_decrypt(const UINT32 *master_key, UINT32 upper_limit)
// decrypt the opcodes
for (a = i; a < length/2 && a < upper_limit/2; a += 0x10000)
{
dec[a] = feistel(rom[a], fn2_groupA, fn2_groupB,
dec[a] = BURN_ENDIAN_SWAP_INT16(feistel(BURN_ENDIAN_SWAP_INT16(rom[a]), fn2_groupA, fn2_groupB,
&sboxes2[0*4], &sboxes2[1*4], &sboxes2[2*4], &sboxes2[3*4],
key2[0], key2[1], key2[2], key2[3]);
key2[0], key2[1], key2[2], key2[3]));
}
// copy the unencrypted part (not really needed)
while (a < length/2)

View File

@ -59,11 +59,11 @@ static INT32 DrawScroll1(INT32 i)
INT32 nOff, nScrX, nScrY;
UINT8 *Find;
nOff = *((UINT16 *)(CpsSaveReg[i] + 0x02));
nOff = BURN_ENDIAN_SWAP_INT16(*((UINT16 *)(CpsSaveReg[i] + 0x02)));
// Get scroll coordinates
nScrX = *((UINT16 *)(CpsSaveReg[i] + 0x0c)); // Scroll 1 X
nScrY = *((UINT16 *)(CpsSaveReg[i] + 0x0e)); // Scroll 1 Y
nScrX = BURN_ENDIAN_SWAP_INT16(*((UINT16 *)(CpsSaveReg[i] + 0x0c))); // Scroll 1 X
nScrY = BURN_ENDIAN_SWAP_INT16(*((UINT16 *)(CpsSaveReg[i] + 0x0e))); // Scroll 1 Y
nScrX += 0x40;
@ -87,14 +87,14 @@ static INT32 DrawScroll2Init(INT32 i)
// Draw Scroll 2
INT32 nScr2Off; INT32 n;
nScr2Off = *((UINT16 *)(CpsSaveReg[i] + 0x04));
nScr2Off = BURN_ENDIAN_SWAP_INT16(*((UINT16 *)(CpsSaveReg[i] + 0x04)));
// Get scroll coordinates
nCpsrScrX= *((UINT16 *)(CpsSaveReg[i] + 0x10)); // Scroll 2 X
nCpsrScrY= *((UINT16 *)(CpsSaveReg[i] + 0x12)); // Scroll 2 Ytess
nCpsrScrX= BURN_ENDIAN_SWAP_INT16(*((UINT16 *)(CpsSaveReg[i] + 0x10))); // Scroll 2 X
nCpsrScrY= BURN_ENDIAN_SWAP_INT16(*((UINT16 *)(CpsSaveReg[i] + 0x12))); // Scroll 2 Ytess
// Get row scroll information
n = *((UINT16 *)(CpsSaveReg[i] + 0x22));
n = BURN_ENDIAN_SWAP_INT16(*((UINT16 *)(CpsSaveReg[i] + 0x22)));
nScr2Off <<= 8;
@ -121,8 +121,8 @@ static INT32 DrawScroll2Init(INT32 i)
INT32 nTab, nStart;
// Find row scroll table:
nTab = *((UINT16 *)(CpsSaveReg[i] + 0x08));
nStart = *((UINT16 *)(CpsSaveReg[i] + 0x20));
nTab = BURN_ENDIAN_SWAP_INT16(*((UINT16 *)(CpsSaveReg[i] + 0x08)));
nStart = BURN_ENDIAN_SWAP_INT16(*((UINT16 *)(CpsSaveReg[i] + 0x20)));
nTab <<= 8;
nTab &= 0xFFF800; // Vampire - Row scroll effect in VS screen background
@ -161,11 +161,11 @@ static INT32 DrawScroll3(INT32 i)
INT32 nOff, nScrX, nScrY;
UINT8 *Find;
nOff = *((UINT16 *)(CpsSaveReg[i] + 0x06));
nOff = BURN_ENDIAN_SWAP_INT16(*((UINT16 *)(CpsSaveReg[i] + 0x06)));
// Get scroll coordinates
nScrX = *((UINT16 *)(CpsSaveReg[i] + 0x14)); // Scroll 3 X
nScrY = *((UINT16 *)(CpsSaveReg[i] + 0x16)); // Scroll 3 Y
nScrX = BURN_ENDIAN_SWAP_INT16(*((UINT16 *)(CpsSaveReg[i] + 0x14))); // Scroll 3 X
nScrY = BURN_ENDIAN_SWAP_INT16(*((UINT16 *)(CpsSaveReg[i] + 0x16))); // Scroll 3 Y
nScrX += 0x40;
@ -214,7 +214,7 @@ static void Cps1Layers()
INT32 i=0;
nDrawMask=1; // Sprites always on
LayerCont = *((UINT16 *)(CpsSaveReg[0] + nCpsLcReg));
LayerCont = BURN_ENDIAN_SWAP_INT16(*((UINT16 *)(CpsSaveReg[0] + nCpsLcReg)));
// Get correct bits from Layer Controller
if (LayerCont & CpsLayEn[1]) nDrawMask|=2;
if (LayerCont & CpsLayEn[2]) nDrawMask|=4;
@ -294,7 +294,7 @@ static void Cps2Layers()
INT32 nSlice = 0;
do {
LayerCont = *((UINT16 *)(CpsSaveReg[nSlice] + nCpsLcReg));
LayerCont = BURN_ENDIAN_SWAP_INT16(*((UINT16 *)(CpsSaveReg[nSlice] + nCpsLcReg)));
// Determine which layers are enabled
nDrawMask[nSlice] = 1; // Sprites always on

View File

@ -99,7 +99,7 @@ INT32 CpsObjGet()
pof->nShiftX = -CpsSaveFrg[0][0x9];
pof->nShiftY = -CpsSaveFrg[0][0xB];
} else {
INT32 nOff = *((UINT16*)(CpsReg + 0x00)) << 8;
INT32 nOff = BURN_ENDIAN_SWAP_INT16(*((UINT16*)(CpsReg + 0x00)) << 8);
nOff &= 0xfff800;
Get = CpsFindGfxRam(nOff, 0x800);
@ -119,30 +119,30 @@ INT32 CpsObjGet()
UINT16* ps = (UINT16*)pg;
if (Cps == 2) {
if (ps[1] & 0x8000) { // end of sprite list?
if (BURN_ENDIAN_SWAP_INT16(ps[1]) & 0x8000) { // end of sprite list?
break;
}
if (ps[0] == 0 && ps[1] == 0x0100 && ps[2] == 0 && ps[3] == 0xff00) { // Slammasters end of sprite list?
if (BURN_ENDIAN_SWAP_INT16(ps[0]) == 0 && BURN_ENDIAN_SWAP_INT16(ps[1]) == 0x0100 && BURN_ENDIAN_SWAP_INT16(ps[2]) == 0 && BURN_ENDIAN_SWAP_INT16(ps[3]) == 0xff00) { // Slammasters end of sprite list?
break;
}
} else {
if (Dinopic) {
if (ps[1] == 0x8000) { // end of sprite list
if (BURN_ENDIAN_SWAP_INT16(ps[1]) == 0x8000) { // end of sprite list
break;
}
} else {
if (ps[3] == 0xff00) { // end of sprite list
if (BURN_ENDIAN_SWAP_INT16(ps[3]) == 0xff00) { // end of sprite list
break;
}
}
}
if (Dinopic) {
if (((ps[2] - 461) | ps[1]) == 0) { // sprite blank
if (((BURN_ENDIAN_SWAP_INT16(ps[2]) - 461) | BURN_ENDIAN_SWAP_INT16(ps[1])) == 0) { // sprite blank
continue;
}
} else {
if ((ps[0] | ps[3]) == 0) { // sprite blank
if ((BURN_ENDIAN_SWAP_INT16(ps[0]) | BURN_ENDIAN_SWAP_INT16(ps[3])) == 0) { // sprite blank
continue;
}
}
@ -201,11 +201,11 @@ INT32 Cps1ObjDraw(INT32 nLevelFrom,INT32 nLevelTo)
INT32 x,y,n,a,bx,by,dx,dy; INT32 nFlip;
if (Dinopic) {
n = ps[0]; a = ps[1]; x = ps[2] - 461; y = 0x2f0 - ps[3];
n = BURN_ENDIAN_SWAP_INT16(ps[0]); a = BURN_ENDIAN_SWAP_INT16(ps[1]); x = BURN_ENDIAN_SWAP_INT16(ps[2]) - 461; y = 0x2f0 - BURN_ENDIAN_SWAP_INT16(ps[3]);
bx = 1;
by = 1;
} else {
x = ps[0]; y = ps[1]; n = ps[2]; a = ps[3];
x = BURN_ENDIAN_SWAP_INT16(ps[0]); y = BURN_ENDIAN_SWAP_INT16(ps[1]); n = BURN_ENDIAN_SWAP_INT16(ps[2]); a = BURN_ENDIAN_SWAP_INT16(ps[3]);
// Find out sprite size
bx=((a>> 8)&15)+1;
@ -280,7 +280,7 @@ INT32 Cps2ObjDraw(INT32 nLevelFrom, INT32 nLevelTo)
for (ZValue = (UINT16)nMaxZValue; ZValue <= nCount; ZValue++, ps += nPsAdd) {
INT32 x, y, n, a, bx, by, dx, dy;
INT32 nFlip;
INT32 v = ps[0] >> 13;
INT32 v = BURN_ENDIAN_SWAP_INT16(ps[0]) >> 13;
if ((nSpriteEnable & (1 << v)) == 0) {
continue;
@ -308,10 +308,10 @@ INT32 Cps2ObjDraw(INT32 nLevelFrom, INT32 nLevelTo)
pCpstOne = CpstOneObjDoX[0];
}
x = ps[0];
y = ps[1];
n = ps[2];
a = ps[3];
x = BURN_ENDIAN_SWAP_INT16(ps[0]);
y = BURN_ENDIAN_SWAP_INT16(ps[1]);
n = BURN_ENDIAN_SWAP_INT16(ps[2]);
a = BURN_ENDIAN_SWAP_INT16(ps[3]);
if (a & 0x80) { // marvel vs capcom ending sprite off-set
x += CpsSaveFrg[0][0x9];
@ -344,7 +344,7 @@ INT32 Cps2ObjDraw(INT32 nLevelFrom, INT32 nLevelTo)
// y -= CpsSaveFrg[0][0xB];
#endif
n |= (ps[1] & 0x6000) << 3; // high bits of address
n |= (BURN_ENDIAN_SWAP_INT16(ps[1]) & 0x6000) << 3; // high bits of address
// Find the palette for the tiles on this sprite
CpstPal = CpsObjPal + ((a & 0x1F) << 4);

View File

@ -12,6 +12,10 @@ inline static UINT32 CalcColCPS1(UINT16 a)
{
INT32 r, g, b, f;
const INT32 F_OFFSET = 0x0F;
#ifndef LSB_FIRST
a = BURN_ENDIAN_SWAP_INT16(a);
#endif
// Format is FFFF RRRR GGGG BBBB
f = (a & 0xF000) >> 12;
@ -35,6 +39,10 @@ static UINT32 CalcColCPS2(UINT16 a)
{
INT32 r, g, b, f;
const INT32 F_OFFSET = 0x0F;
#ifndef LSB_FIRST
a = BURN_ENDIAN_SWAP_INT16(a);
#endif
// Format is FFFF RRRR GGGG BBBB
f = (a & 0xF000) >> 12;

View File

@ -161,7 +161,7 @@ INT32 CpsRunExit()
inline static void GetPalette(INT32 nStart, INT32 nCount)
{
// Update Palette (Ghouls points to the wrong place on boot up I think)
INT32 nPal = (*((UINT16*)(CpsReg + 0x0A)) << 8) & 0xFFF800;
INT32 nPal = BURN_ENDIAN_SWAP_INT16((*((UINT16*)(CpsReg + 0x0A)) << 8)) & 0xFFF800;
UINT8* Find = CpsFindGfxRam(nPal, 0x1000);
if (Find) {
@ -373,17 +373,17 @@ INT32 Cps2Frame()
// Determine which (if any) of the line counters generates the first IRQ
bEnableAutoIrq50 = bEnableAutoIrq52 = false;
nIrqLine50 = nIrqLine52 = 0x0106;
if (*((UINT16*)(CpsReg + 0x50)) & 0x8000) {
if (BURN_ENDIAN_SWAP_INT16(*((UINT16*)(CpsReg + 0x50))) & 0x8000) {
bEnableAutoIrq50 = true;
}
if (bEnableAutoIrq50 || (*((UINT16*)(CpsReg + 0x4E)) & 0x0200) == 0) {
nIrqLine50 = (*((UINT16*)(CpsReg + 0x50)) & 0x01FF);
if (bEnableAutoIrq50 || (BURN_ENDIAN_SWAP_INT16(*((UINT16*)(CpsReg + 0x4E))) & 0x0200) == 0) {
nIrqLine50 = (BURN_ENDIAN_SWAP_INT16(*((UINT16*)(CpsReg + 0x50))) & 0x01FF);
}
if (*((UINT16*)(CpsReg + 0x52)) & 0x8000) {
if (BURN_ENDIAN_SWAP_INT16(*((UINT16*)(CpsReg + 0x52))) & 0x8000) {
bEnableAutoIrq52 = true;
}
if (bEnableAutoIrq52 || (*((UINT16*)(CpsReg + 0x4E)) & 0x0200) == 0) {
nIrqLine52 = (*((UINT16*)(CpsReg + 0x52)) & 0x01FF);
if (bEnableAutoIrq52 || (BURN_ENDIAN_SWAP_INT16(*((UINT16*)(CpsReg + 0x4E))) & 0x0200) == 0) {
nIrqLine52 = (BURN_ENDIAN_SWAP_INT16(*((UINT16*)(CpsReg + 0x52))) & 0x01FF);
}
ScheduleIRQ();

View File

@ -38,7 +38,7 @@ INT32 Cps1Scr1Draw(UINT8 *Base,INT32 sx,INT32 sy)
p&=0x3fff;
pst=(UINT16 *)(Base + p);
t=pst[0];
t = BURN_ENDIAN_SWAP_INT16(pst[0]);
if (Scroll1TileMask) t &= Scroll1TileMask;
@ -50,7 +50,7 @@ INT32 Cps1Scr1Draw(UINT8 *Base,INT32 sx,INT32 sy)
t+=nCpsGfxScroll[1]; // add on offset to scroll tiles
if (t==nKnowBlank) continue; // Don't draw: we know it's blank
a=pst[1];
a = BURN_ENDIAN_SWAP_INT16(pst[1]);
CpstSetPal(0x20 | (a&0x1f));
@ -64,7 +64,7 @@ INT32 Cps1Scr1Draw(UINT8 *Base,INT32 sx,INT32 sy)
nCpstTile=t; nCpstFlip=(a>>5)&3;
if (nBgHi) {
CpstPmsk = *(UINT16*)(CpsSaveReg[0] + MaskAddr[(a & 0x180) >> 7]);
CpstPmsk = BURN_ENDIAN_SWAP_INT16(*(UINT16*)(CpsSaveReg[0] + MaskAddr[(a & 0x180) >> 7]));
}
if(CpstOneDoX[nBgHi]()) nKnowBlank=t;
@ -108,13 +108,13 @@ INT32 Cps2Scr1Draw(UINT8 *Base, INT32 sx, INT32 sy)
p &= 0x3FFF;
pst = (UINT16 *)(Base + p);
t = pst[0];
t = BURN_ENDIAN_SWAP_INT16(pst[0]);
t <<= 6; // Get real tile address
t += nCpsGfxScroll[1]; // add on offset to scroll tiles
if (t != nKnowBlank) { // Draw tile
a = pst[1];
a = BURN_ENDIAN_SWAP_INT16(pst[1]);
CpstSetPal(0x20 | (a & 0x1F));
@ -161,7 +161,7 @@ INT32 Cps1Scr3Draw(UINT8 *Base,INT32 sx,INT32 sy)
p&=0x3fff;
pst=(UINT16 *)(Base + p);
t=pst[0];
t = BURN_ENDIAN_SWAP_INT16(pst[0]);
if (Scroll3TileMask) t &= Scroll3TileMask;
@ -173,7 +173,7 @@ INT32 Cps1Scr3Draw(UINT8 *Base,INT32 sx,INT32 sy)
if (t==nKnowBlank) continue; // Don't draw: we know it's blank
a=pst[1];
a = BURN_ENDIAN_SWAP_INT16(pst[1]);
CpstSetPal(0x60 | (a&0x1f));
@ -187,7 +187,7 @@ INT32 Cps1Scr3Draw(UINT8 *Base,INT32 sx,INT32 sy)
nCpstTile=t; nCpstFlip=(a>>5)&3;
if (nBgHi) {
CpstPmsk = *(UINT16*)(CpsSaveReg[0] + MaskAddr[(a & 0x180) >> 7]);
CpstPmsk = BURN_ENDIAN_SWAP_INT16(*(UINT16*)(CpsSaveReg[0] + MaskAddr[(a & 0x180) >> 7]));
}
if(CpstOneDoX[nBgHi]()) nKnowBlank=t;
@ -230,7 +230,7 @@ INT32 Cps2Scr3Draw(UINT8 *Base, INT32 sx, INT32 sy)
p &= 0x3FFF;
pst = (UINT16 *)(Base + p);
t = pst[0];
t = BURN_ENDIAN_SWAP_INT16(pst[0]);
if(Xmcota && t>=0x5800) t-=0x4000;
else if(Ssf2t && t<0x5600) t+=0x4000;
@ -238,7 +238,7 @@ INT32 Cps2Scr3Draw(UINT8 *Base, INT32 sx, INT32 sy)
t += nCpsGfxScroll[3]; // add on offset to scroll tiles
if (t != nKnowBlank) { // Draw tile
a = pst[1];
a = BURN_ENDIAN_SWAP_INT16(pst[1]);
CpstSetPal(0x60 | (a & 0x1F));

View File

@ -17,11 +17,11 @@ static void GetRowsRange(INT32 *pnStart,INT32 *pnWidth,INT32 nRowFrom,INT32 nRow
// Get the range of scroll values within nRowCount rows
// Start with zero range
nStart=CpsrRows[nRowFrom&0x3ff]; nStart&=0x3ff; nWidth=0;
nStart = BURN_ENDIAN_SWAP_INT16(CpsrRows[nRowFrom&0x3ff]); nStart&=0x3ff; nWidth=0;
for (i=nRowFrom;i<nRowTo;i++)
{
INT32 nViz; INT32 nDiff;
nViz=CpsrRows[i&0x3ff]; nViz&=0x3ff;
nViz = BURN_ENDIAN_SWAP_INT16(CpsrRows[i&0x3ff]); nViz&=0x3ff;
// Work out if this is on the left or the right of our
// start point.
nDiff=nViz-nStart;
@ -82,7 +82,7 @@ static INT32 PrepareRows()
{
INT32 v;
v =(pli->nTileStart<<4)-nCpsrScrX;
v-=CpsrRows[(nCpsrRowStart+r)&0x3ff];
v -= BURN_ENDIAN_SWAP_INT16(CpsrRows[(nCpsrRowStart+r)&0x3ff]);
// clip to 10-bit signed
v+=0x200; v&=0x3ff; v-=0x200;
*pr=(INT16)v;

View File

@ -34,7 +34,7 @@ static void Cps1TileLine(INT32 y,INT32 sx)
else nCpstType=CTT_16X16;
pst=FindTile(ix+x,iy+y);
t=pst[0];
t = BURN_ENDIAN_SWAP_INT16(pst[0]);
if (Scroll2TileMask) t &= Scroll2TileMask;
@ -45,12 +45,12 @@ static void Cps1TileLine(INT32 y,INT32 sx)
t+=nCpsGfxScroll[2]; // add on offset to scroll tile
if (t==nKnowBlank) continue; // Don't draw: we know it's blank
a=pst[1];
a = BURN_ENDIAN_SWAP_INT16(pst[1]);
CpstSetPal(0x40 | (a&0x1f));
nCpstX=sx+(x<<4); nCpstTile=t; nCpstFlip=(a>>5)&3;
if(nBgHi) CpstPmsk=*(UINT16 *)(CpsSaveReg[0] + MaskAddr[(a&0x180)>>7]);
if(nBgHi) CpstPmsk = BURN_ENDIAN_SWAP_INT16(*(UINT16 *)(CpsSaveReg[0] + MaskAddr[(a&0x180)>>7]));
if(CpstOneDoX[nBgHi]()) nKnowBlank=t;
}
}
@ -71,11 +71,11 @@ static void Cps2TileLine(INT32 y,INT32 sx)
else nCpstType=CTT_16X16;
pst=FindTile(ix+x,iy+y);
t=pst[0];
t = BURN_ENDIAN_SWAP_INT16(pst[0]);
t<<=7; // Get real tile address
t+=nCpsGfxScroll[2]; // add on offset to scroll tiles
if (t==nKnowBlank) continue; // Don't draw: we know it's blank
a=pst[1];
a = BURN_ENDIAN_SWAP_INT16(pst[1]);
CpstSetPal(0x40 | (a&0x1f));
nCpstX=sx+(x<<4); nCpstTile=t; nCpstFlip=(a>>5)&3;
@ -121,7 +121,7 @@ static void Cps1TileLineRows(INT32 y,struct CpsrLineInfo *pli)
else nCpstType=CTT_16X16 | CTT_ROWS;
pst=FindTile(tx,iy+y);
t=pst[0];
t = BURN_ENDIAN_SWAP_INT16(pst[0]);
if (Scroll2TileMask) t &= Scroll2TileMask;
@ -132,14 +132,14 @@ static void Cps1TileLineRows(INT32 y,struct CpsrLineInfo *pli)
t+=nCpsGfxScroll[2]; // add on offset to scroll tiles
if (t==nKnowBlank) continue; // Don't draw: we know it's blank
a=pst[1];
a = BURN_ENDIAN_SWAP_INT16(pst[1]);
CpstSetPal(0x40 | (a&0x1f));
nCpstX=x<<4; nCpstTile=t; nCpstFlip=(a>>5)&3;
if (nBgHi) {
CpstPmsk = *(UINT16*)(CpsSaveReg[0] + MaskAddr[(a & 0x180) >> 7]);
CpstPmsk = BURN_ENDIAN_SWAP_INT16(*(UINT16*)(CpsSaveReg[0] + MaskAddr[(a & 0x180) >> 7]));
}
if(CpstOneDoX[nBgHi]()) nKnowBlank=t;
@ -180,12 +180,12 @@ static void Cps2TileLineRows(INT32 y,struct CpsrLineInfo *pli)
else nCpstType=CTT_16X16 | CTT_ROWS;
pst=FindTile(tx,iy+y);
t=pst[0];
t = BURN_ENDIAN_SWAP_INT16(pst[0]);
t<<=7; // Get real tile address
t+=nCpsGfxScroll[2]; // add on offset to scroll tiles
if (t==nKnowBlank) continue; // Don't draw: we know it's blank
a=pst[1];
a = BURN_ENDIAN_SWAP_INT16(pst[1]);
CpstSetPal(0x40 | (a&0x1f));