CPS palette handling, simplify palette handling, map palette registers, remove obj palette lag, change palette update timing to sync with palette base register write, support palette pages and brightness

This commit is contained in:
Barry Harris 2012-02-21 13:50:51 +00:00
parent 7b546680ad
commit 6c64b16ce1
9 changed files with 127 additions and 300 deletions

View File

@ -1004,6 +1004,8 @@ INT32 CpsExit()
BurnFree(CpsGfx);
BurnFree(CpsCode);
bCpsUpdatePalEveryFrame = 0;
nCPS68KClockspeed = 0;
Cps = 0;

View File

@ -132,12 +132,11 @@ extern void SetCpsBId(INT32 CpsBId, INT32 bStars);
// cps_pal.cpp
extern UINT32* CpsPal; // Hicolor version of palette
extern UINT32* CpsObjPal; // Pointer to lagged obj palette
extern INT32 nLagObjectPalettes; // Lag object palettes by one frame if non-zero
extern INT32 nCpsPalCtrlReg;
extern INT32 bCpsUpdatePalEveryFrame;
INT32 CpsPalInit();
INT32 CpsPalExit();
INT32 CpsPalUpdate(UINT8 *pNewPal,INT32 bRecalcAll);
INT32 CpsStarPalUpdate(UINT8* pNewPal, INT32 nLayer, INT32 bRecalcAll);
INT32 CpsPalUpdate(UINT8 *pNewPal);
// cps_mem.cpp
extern UINT8 *CpsRam90;
@ -169,6 +168,17 @@ inline static UINT8* CpsFindGfxRam(INT32 nAddr,INT32 nLen)
return NULL;
}
inline static void GetPalette(INT32 nStart, INT32 nCount)
{
// Update Palette (Ghouls points to the wrong place on boot up I think)
INT32 nPal = (BURN_ENDIAN_SWAP_INT16(*((UINT16*)(CpsReg + 0x0A))) << 8) & 0xFFFC00;
UINT8* Find = CpsFindGfxRam(nPal, 0xc00 << 1);
if (Find) {
memcpy(CpsSavePal + (nStart << 10), Find + (nStart << 10), nCount << 10);
}
}
// cps_rw.cpp
// Treble Winner - Added INP(1FD) for sf2ue
#define CPSINPSET INP(000) INP(001) INP(006) INP(007) INP(008) INP(010) INP(011) INP(012) INP(018) INP(019) INP(020) INP(021) INP(029) INP(176) INP(177) INP(179) INP(186) INP(1fd)

View File

@ -835,6 +835,8 @@ void SetCpsBId(INT32 CpsBId, INT32 bStars)
MaskAddr[1] = 0x6a;
MaskAddr[2] = 0x6c;
MaskAddr[3] = 0x6e;
nCpsPalCtrlReg = 0x70;
CpsLayEn[1] = 0x02;
CpsLayEn[2] = 0x04;
@ -861,6 +863,8 @@ void SetCpsBId(INT32 CpsBId, INT32 bStars)
MaskAddr[1] = 0x68;
MaskAddr[2] = 0x66;
MaskAddr[3] = 0x64;
nCpsPalCtrlReg = 0x62;
CpsLayEn[1] = 0x02;
CpsLayEn[2] = 0x04;
@ -887,6 +891,8 @@ void SetCpsBId(INT32 CpsBId, INT32 bStars)
MaskAddr[1] = 0x6c;
MaskAddr[2] = 0x6a;
MaskAddr[3] = 0x68;
nCpsPalCtrlReg = 0x66;
CpsLayEn[1] = 0x20;
CpsLayEn[2] = 0x10;
@ -913,6 +919,8 @@ void SetCpsBId(INT32 CpsBId, INT32 bStars)
MaskAddr[1] = 0x70;
MaskAddr[2] = 0x68;
MaskAddr[3] = 0x72;
nCpsPalCtrlReg = 0x6a;
CpsLayEn[1] = 0x02;
//CpsLayEn[2] = 0x0c;
@ -941,6 +949,8 @@ void SetCpsBId(INT32 CpsBId, INT32 bStars)
MaskAddr[1] = 0x6c;
MaskAddr[2] = 0x6e;
MaskAddr[3] = 0x70;
nCpsPalCtrlReg = 0x72;
CpsLayEn[1] = 0x02;
CpsLayEn[2] = 0x08;
@ -967,6 +977,8 @@ void SetCpsBId(INT32 CpsBId, INT32 bStars)
MaskAddr[1] = 0x6a;
MaskAddr[2] = 0x6c;
MaskAddr[3] = 0x6e;
nCpsPalCtrlReg = 0x70;
CpsLayEn[1] = 0x08;
CpsLayEn[2] = 0x10;
@ -993,6 +1005,8 @@ void SetCpsBId(INT32 CpsBId, INT32 bStars)
MaskAddr[1] = 0x68;
MaskAddr[2] = 0x66;
MaskAddr[3] = 0x64;
nCpsPalCtrlReg = 0x62;
CpsLayEn[1] = 0x02;
CpsLayEn[2] = 0x04;
@ -1019,6 +1033,8 @@ void SetCpsBId(INT32 CpsBId, INT32 bStars)
MaskAddr[1] = 0x66;
MaskAddr[2] = 0x68;
MaskAddr[3] = 0x6a;
nCpsPalCtrlReg = 0x6c;
CpsLayEn[1] = 0x20;
CpsLayEn[2] = 0x02;
@ -1045,6 +1061,8 @@ void SetCpsBId(INT32 CpsBId, INT32 bStars)
MaskAddr[1] = 0x56;
MaskAddr[2] = 0x58;
MaskAddr[3] = 0x5a;
nCpsPalCtrlReg = 0x5c;
CpsLayEn[1] = 0x08;
CpsLayEn[2] = 0x20;
@ -1071,6 +1089,8 @@ void SetCpsBId(INT32 CpsBId, INT32 bStars)
MaskAddr[1] = 0x46;
MaskAddr[2] = 0x48;
MaskAddr[3] = 0x4a;
nCpsPalCtrlReg = 0x4c;
CpsLayEn[1] = 0x04;
CpsLayEn[2] = 0x02;
@ -1097,6 +1117,8 @@ void SetCpsBId(INT32 CpsBId, INT32 bStars)
MaskAddr[1] = 0x48;
MaskAddr[2] = 0x46;
MaskAddr[3] = 0x44;
nCpsPalCtrlReg = 0x42;
CpsLayEn[1] = 0x10;
CpsLayEn[2] = 0x0a;
@ -1123,6 +1145,8 @@ void SetCpsBId(INT32 CpsBId, INT32 bStars)
MaskAddr[1] = 0x50;
MaskAddr[2] = 0x4e;
MaskAddr[3] = 0x4c;
nCpsPalCtrlReg = 0x4a;
CpsLayEn[1] = 0x08;
CpsLayEn[2] = 0x10;
@ -1149,6 +1173,8 @@ void SetCpsBId(INT32 CpsBId, INT32 bStars)
MaskAddr[1] = 0xd8;
MaskAddr[2] = 0xd6;
MaskAddr[3] = 0xd4;
nCpsPalCtrlReg = 0xd2;
CpsLayEn[1] = 0x10;
CpsLayEn[2] = 0x08;
@ -1175,6 +1201,8 @@ void SetCpsBId(INT32 CpsBId, INT32 bStars)
MaskAddr[1] = 0x64;
MaskAddr[2] = 0x62;
MaskAddr[3] = 0x60;
nCpsPalCtrlReg = 0x70;
CpsLayEn[1] = 0x20;
CpsLayEn[2] = 0x04;
@ -1201,6 +1229,8 @@ void SetCpsBId(INT32 CpsBId, INT32 bStars)
MaskAddr[1] = 0x6c;
MaskAddr[2] = 0x6a;
MaskAddr[3] = 0x68;
nCpsPalCtrlReg = 0x70;
CpsLayEn[1] = 0x30;
CpsLayEn[2] = 0x08;
@ -1227,6 +1257,8 @@ void SetCpsBId(INT32 CpsBId, INT32 bStars)
MaskAddr[1] = 0x6c;
MaskAddr[2] = 0x6a;
MaskAddr[3] = 0x68;
nCpsPalCtrlReg = 0x70;
CpsLayEn[1] = 0x20;
CpsLayEn[2] = 0x12;
@ -1253,6 +1285,8 @@ void SetCpsBId(INT32 CpsBId, INT32 bStars)
MaskAddr[1] = 0x64;
MaskAddr[2] = 0x62;
MaskAddr[3] = 0x60;
nCpsPalCtrlReg = 0x70;
CpsLayEn[1] = 0x20;
CpsLayEn[2] = 0x10;
@ -1279,6 +1313,8 @@ void SetCpsBId(INT32 CpsBId, INT32 bStars)
MaskAddr[1] = 0x6c;
MaskAddr[2] = 0x6a;
MaskAddr[3] = 0x68;
nCpsPalCtrlReg = 0x70;
CpsLayEn[1] = 0x20;
CpsLayEn[2] = 0x04;
@ -1305,6 +1341,8 @@ void SetCpsBId(INT32 CpsBId, INT32 bStars)
MaskAddr[1] = 0x6c;
MaskAddr[2] = 0x6a;
MaskAddr[3] = 0x68;
nCpsPalCtrlReg = 0x70;
CpsLayEn[1] = 0x20;
CpsLayEn[2] = 0x14;
@ -1331,6 +1369,8 @@ void SetCpsBId(INT32 CpsBId, INT32 bStars)
MaskAddr[1] = 0x00;
MaskAddr[2] = 0x00;
MaskAddr[3] = 0x00;
nCpsPalCtrlReg = 0x52;
CpsLayEn[1] = 0x14;
CpsLayEn[2] = 0x02;
@ -1357,6 +1397,8 @@ void SetCpsBId(INT32 CpsBId, INT32 bStars)
MaskAddr[1] = 0x6a;
MaskAddr[2] = 0x6c;
MaskAddr[3] = 0x6e;
nCpsPalCtrlReg = 0x70;
CpsLayEn[1] = 0x02;
CpsLayEn[2] = 0x04;
@ -1383,6 +1425,8 @@ void SetCpsBId(INT32 CpsBId, INT32 bStars)
MaskAddr[1] = 0x66;
MaskAddr[2] = 0x68;
MaskAddr[3] = 0x6a;
nCpsPalCtrlReg = 0x6c;
CpsLayEn[1] = 0x10;
CpsLayEn[2] = 0x08;
@ -1409,6 +1453,8 @@ void SetCpsBId(INT32 CpsBId, INT32 bStars)
MaskAddr[1] = 0x4e;
MaskAddr[2] = 0x40;
MaskAddr[3] = 0x42;
nCpsPalCtrlReg = 0x44;
CpsLayEn[1] = 0x16;
CpsLayEn[2] = 0x16;
@ -1435,6 +1481,8 @@ void SetCpsBId(INT32 CpsBId, INT32 bStars)
MaskAddr[1] = 0x56;
MaskAddr[2] = 0x48;
MaskAddr[3] = 0x4a;
nCpsPalCtrlReg = 0x4c;
CpsLayEn[1] = 0x04;
CpsLayEn[2] = 0x02;
@ -1461,6 +1509,8 @@ void SetCpsBId(INT32 CpsBId, INT32 bStars)
MaskAddr[1] = 0x42;
MaskAddr[2] = 0x68;
MaskAddr[3] = 0x6a;
nCpsPalCtrlReg = 0x6c;
CpsLayEn[1] = 0x04;
CpsLayEn[2] = 0x08;
@ -1487,6 +1537,8 @@ void SetCpsBId(INT32 CpsBId, INT32 bStars)
MaskAddr[1] = 0x6e;
MaskAddr[2] = 0x70;
MaskAddr[3] = 0x72;
nCpsPalCtrlReg = 0x5c;
CpsLayEn[1] = 0x04;
CpsLayEn[2] = 0x08;
@ -1513,6 +1565,8 @@ void SetCpsBId(INT32 CpsBId, INT32 bStars)
MaskAddr[1] = 0x50;
MaskAddr[2] = 0x4e;
MaskAddr[3] = 0x4c;
nCpsPalCtrlReg = 0x4a;
CpsLayEn[1] = 0xff;
CpsLayEn[2] = 0xff;
@ -1539,6 +1593,8 @@ void SetCpsBId(INT32 CpsBId, INT32 bStars)
MaskAddr[1] = 0x50;
MaskAddr[2] = 0x4e;
MaskAddr[3] = 0x4c;
nCpsPalCtrlReg = 0x4a; // s2m3 & sf2m8 (untested none of them write this)
CpsLayEn[1] = 0x02;
CpsLayEn[2] = 0x02;
@ -1565,6 +1621,8 @@ void SetCpsBId(INT32 CpsBId, INT32 bStars)
MaskAddr[1] = 0x6a;
MaskAddr[2] = 0x6c;
MaskAddr[3] = 0x6e;
nCpsPalCtrlReg = 0x6a;
CpsLayEn[1] = 0x02;
CpsLayEn[2] = 0x04;
@ -1591,6 +1649,8 @@ void SetCpsBId(INT32 CpsBId, INT32 bStars)
MaskAddr[1] = 0x6c;
MaskAddr[2] = 0x6a;
MaskAddr[3] = 0x68;
nCpsPalCtrlReg = 0x66;
CpsLayEn[1] = 0x02;
CpsLayEn[2] = 0x04;

View File

@ -234,7 +234,6 @@ static void Cps1Layers()
for (i = 0; i < 2; i++) {
if (LayerCont & CpsLayEn[4 + i]) {
CpsStarPalUpdate(CpsSavePal, i, CpsRecalcPal);
DrawStar(i);
}
}
@ -464,8 +463,8 @@ static void DoDraw(INT32 Recalc)
{
CtvReady(); // Point to correct tile drawing functions
// Update Palette
CpsPalUpdate(CpsSavePal, Recalc); // recalc whole palette if needed
if (bCpsUpdatePalEveryFrame) GetPalette(0, 6);
if (Recalc || bCpsUpdatePalEveryFrame) CpsPalUpdate(CpsSavePal); // recalc whole palette if needed
CpsClearScreen();

View File

@ -225,7 +225,7 @@ INT32 Cps1ObjDraw(INT32 nLevelFrom,INT32 nLevelTo)
y+=pof->nShiftY;
// Find the palette for the tiles on this sprite
CpstPal = CpsObjPal + ((a & 0x1F) << 4);
CpstPal = CpsPal + ((a & 0x1F) << 4);
nFlip=(a>>5)&3;
@ -347,7 +347,7 @@ INT32 Cps2ObjDraw(INT32 nLevelFrom, INT32 nLevelTo)
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);
CpstPal = CpsPal + ((a & 0x1F) << 4);
nFlip = (a >> 5) & 3;
// Find out sprite size

View File

@ -1,141 +1,30 @@
#include "cps.h"
#include "bitswap.h"
// CPS (palette)
static UINT8* CpsPalSrc = NULL; // Copy of current input palette
UINT32* CpsPal = NULL; // Hicolor version of palette
UINT32* CpsObjPal = NULL;
INT32 nLagObjectPalettes;
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;
r = (a & 0x0F00) >> 4; // Red
r |= r >> 4;
g = (a & 0x00F0); // Green
g |= g >> 4;
b = (a & 0x000F); // Blue
b |= b << 4;
f += F_OFFSET;
r *= f; r /= F_OFFSET + 0x0F;
g *= f; g /= F_OFFSET + 0x0F;
b *= f; b /= F_OFFSET + 0x0F;
return BurnHighCol(r, g, b, 0);
}
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;
r = (a & 0x0F00) >> 4; // Red
r |= r >> 4;
g = (a & 0x00F0); // Green
g |= g >> 4;
b = (a & 0x000F); // Blue
b |= b << 4;
f += F_OFFSET;
r *= f; r /= F_OFFSET + 0x0F;
g *= f; g /= F_OFFSET + 0x0F;
b *= f; b /= F_OFFSET + 0x0F;
return BurnHighCol(r, g, b, 0);
}
static INT32 CalcAll()
{
UINT16* ps;
if (Cps == 2) {
if (nLagObjectPalettes) {
ps = (UINT16*)CpsPalSrc + 0x0C00;
for (INT32 i = 0x0C00; i < 0x0E00; i++, ps++) {
CpsPal[i ^ 15] = CalcColCPS2(*ps);
}
ps = (UINT16*)CpsPalSrc + 0x0200;
for (INT32 i = 0x0200; i < 0x0800; i++, ps++) {
CpsPal[i ^ 15] = CalcColCPS2(*ps);
}
memcpy(CpsPal + 0x0E00, CpsPal + 0x0C00, 0x0200 << 2);
} else {
ps = (UINT16*)CpsPalSrc;
for (INT32 i = 0x0000; i < 0x0800; i++, ps++) {
CpsPal[i ^ 15] = CalcColCPS2(*ps);
}
}
} else {
ps = (UINT16*)CpsPalSrc;
for (INT32 i = 0x0000; i < 0x0c00; i++, ps++) {
CpsPal[i ^ 15] = CalcColCPS1(*ps);
}
}
return 0;
}
static void CalcAllStar(INT32 nLayer)
{
UINT16* ps = (UINT16*)CpsPalSrc;
INT32 nOffset = 0x0800 + (nLayer << 9);
for (INT32 i = 0; i < 128; i++, ps++) {
CpsPal[(i + nOffset) ^ 15] = CalcColCPS1(*(ps + nOffset));
}
}
INT32 nCpsPalCtrlReg;
INT32 bCpsUpdatePalEveryFrame = 0; // Some of the hacks need this as they don't write to CpsReg 0x0a
INT32 CpsPalInit()
{
INT32 nLen = 0;
nLen = 0x1000 * sizeof(UINT16);
nLen = 0xc00 * sizeof(UINT16);
CpsPalSrc = (UINT8*)BurnMalloc(nLen);
if (CpsPalSrc == NULL) {
return 1;
}
memset(CpsPalSrc, 0, nLen);
// The star layer palettes are at the end of the normal palette, so double the size
nLen = 0x1000 * sizeof(UINT32);
nLen = 0xc00 * sizeof(UINT32);
CpsPal = (UINT32*)BurnMalloc(nLen);
if (CpsPal == NULL) {
return 1;
}
// Set CpsPal to initial values
CalcAll();
if (CpsStar) {
CalcAllStar(0);
CalcAllStar(1);
}
if (nLagObjectPalettes) {
CpsObjPal = CpsPal + 0x0C00;
} else {
CpsObjPal = CpsPal;
}
return 0;
}
@ -146,154 +35,39 @@ INT32 CpsPalExit()
return 0;
}
// Update CpsPal with the new palette at pNewPal (length 0x1000 bytes)
INT32 CpsPalUpdate(UINT8* pNewPal, INT32 bRecalcAll)
// Update CpsPal with the new palette at pNewPal (length 0xc00 bytes)
INT32 CpsPalUpdate(UINT8* pNewPal)
{
INT32 i;
UINT16 *ps, *pn;
// If we are recalculating the whole palette, just copy to CpsPalSrc
// and recalculate it all
if (bRecalcAll) {
ps = (UINT16*)CpsPalSrc;
pn = (UINT16*)pNewPal;
ps = (UINT16*)CpsPalSrc;
pn = (UINT16*)pNewPal;
if (nLagObjectPalettes) {
INT32 nBuffer = 0x0C00 + ((GetCurrentFrame() & 1) << 9);
memcpy(ps, pn, 0xc00 * sizeof(UINT16));
INT32 nCtrl = CpsReg[nCpsPalCtrlReg];
UINT16 *PaletteRAM = (UINT16*)CpsPalSrc;
for (INT32 nPage = 0; nPage < 6; nPage++) {
if (BIT(nCtrl, nPage)) {
for (INT32 Offset = 0; Offset < 0x200; ++Offset) {
INT32 Palette = *(PaletteRAM++);
INT32 r, g, b, Bright;
Bright = 0x0f + ((Palette >> 12) << 1);
memcpy(ps + 0x0200, pn + 0x0200, 0x0600 << 1);
memcpy(ps + nBuffer, pn, 0x0200 << 1);
memcpy(ps + 0x0E00, pn, 0x0200 << 1);
CpsObjPal = CpsPal + nBuffer;
r = ((Palette >> 8) & 0x0f) * 0x11 * Bright / 0x2d;
g = ((Palette >> 4) & 0x0f) * 0x11 * Bright / 0x2d;
b = ((Palette >> 0) & 0x0f) * 0x11 * Bright / 0x2d;
CpsPal[(0x200 * nPage) + (Offset ^ 15)] = BurnHighCol(r, g, b, 0);
}
} else {
memcpy(ps, pn, 0x0c00 << 1);
}
CalcAll();
return 0;
}
if (Cps == 2) {
if (nLagObjectPalettes) {
INT32 nBuffer = 0x0C00 + ((GetCurrentFrame() & 1) << 9);
ps = (UINT16*)CpsPalSrc + (nBuffer ^ 0x0200);
pn = (UINT16*)pNewPal;
CpsObjPal = CpsPal + (nBuffer ^ 0x0200);
for (i = 0; i < 0x0200; i++, ps++, pn++) {
UINT16 n;
n = *pn;
if (*ps == n) {
continue; // Colour hasn't changed - great!
}
*ps = n; // Update our copy of the palette
CpsObjPal[i ^ 15] = CalcColCPS2(n);
if (PaletteRAM != (UINT16*)CpsPalSrc) {
PaletteRAM += 0x200;
}
ps = (UINT16*)CpsPalSrc + 0x0200;
pn = (UINT16*)pNewPal + 0x0200;
for (i = 0x0200; i < 0x0800; i++, ps++, pn++) {
UINT16 n;
n = *pn;
if (*ps == n) {
continue; // Colour hasn't changed - great!
}
*ps = n; // Update our copy of the palette
CpsPal[i ^ 15] = CalcColCPS2(n);
}
CpsObjPal = CpsPal + nBuffer;
} else {
ps = (UINT16*)CpsPalSrc;
pn = (UINT16*)pNewPal;
for (i = 0x0000; i < 0x0800; i++, ps++, pn++) {
UINT16 n = *pn;
if (*ps == n) {
continue; // Colour hasn't changed - great!
}
*ps = n; // Update our copy of the palette
CpsPal[i ^ 15] = CalcColCPS2(n);
}
}
} else {
ps = (UINT16*)CpsPalSrc;
pn = (UINT16*)pNewPal;
for (i = 0x0000; i < 0x0c00; i++, ps++, pn++) {
UINT16 n = *pn;
if (*ps == n) {
continue; // Colour hasn't changed - great!
}
*ps = n; // Update our copy of the palette
CpsPal[i ^ 15] = CalcColCPS1(n);
}
}
return 0;
}
INT32 CpsStarPalUpdate(UINT8* pNewPal, INT32 nLayer, INT32 bRecalcAll)
{
INT32 i;
UINT16 *ps, *pn;
if (nLayer == 0) {
ps = (UINT16*)CpsPalSrc + 0x0800;
pn = (UINT16*)pNewPal + 0x0800;
if (bRecalcAll) {
memcpy(ps, pn, 256);
CalcAllStar(nLayer);
return 0;
}
// Star layer 0
for (i = 0x0800; i < 0x0880; i++, ps++, pn++) {
UINT16 n = *pn;
if (*ps == n) {
continue; // Colour hasn't changed - great!
}
*ps = n; // Update our copy of the palette
CpsPal[i ^ 15] = CalcColCPS1(n);
}
} else {
ps = (UINT16*)CpsPalSrc + 0x0A00;
pn = (UINT16*)pNewPal + 0x0A00;
if (bRecalcAll) {
memcpy(ps, pn, 256);
CalcAllStar(nLayer);
return 0;
}
// Star layer 1
for (i = 0x0A00; i < 0x0A80; i++, ps++, pn++) {
UINT16 n = *pn;
if (*ps == n) {
continue; // Colour hasn't changed - great!
}
*ps = n; // Update our copy of the palette
CpsPal[i ^ 15] = CalcColCPS1(n);
}
}
return 0;
}

View File

@ -97,10 +97,6 @@ static const eeprom_interface cps2_eeprom_interface =
INT32 CpsRunInit()
{
nLagObjectPalettes = 0;
if (Cps == 2) nLagObjectPalettes = 1;
SekInit(0, 0x68000); // Allocate 68000
if (CpsMemInit()) { // Memory init
@ -175,29 +171,6 @@ INT32 CpsRunExit()
return 0;
}
// nStart = 0-3, nCount=1-4
inline static void GetPalette(INT32 nStart, INT32 nCount)
{
// Update Palette (Ghouls points to the wrong place on boot up I think)
INT32 nPal = (BURN_ENDIAN_SWAP_INT16(*((UINT16*)(CpsReg + 0x0A))) << 8) & 0xFFF800;
UINT8* Find = CpsFindGfxRam(nPal, 0x1000);
if (Find) {
memcpy(CpsSavePal + (nStart << 10), Find + (nStart << 10), nCount << 10);
}
}
static void GetStarPalette()
{
INT32 nPal = (BURN_ENDIAN_SWAP_INT16(*((UINT16*)(CpsReg + 0x0A))) << 8) & 0xFFF800;
UINT8* Find = CpsFindGfxRam(nPal, 256);
if (Find) {
memcpy(CpsSavePal + 4096, Find + 4096, 256);
memcpy(CpsSavePal + 5120, Find + 5120, 256);
}
}
inline static void CopyCpsReg(INT32 i)
{
memcpy(CpsSaveReg[i], CpsReg, 0x0100);
@ -320,11 +293,6 @@ INT32 Cps1Frame()
memcpy(CpsSaveReg[0], CpsReg, 0x100); // Registers correct now
GetPalette(0, 6); // Get palette
if (CpsStar) {
GetStarPalette();
}
if (CpsDrawSpritesInReverse) {
if (i == 3) CpsObjGet(); // Get objects
}
@ -425,7 +393,6 @@ INT32 Cps2Frame()
ScheduleIRQ();
}
GetPalette(0, 4); // Get palettes
CpsObjGet(); // Get objects
for (i = 0; i < 3; i++) {

View File

@ -319,6 +319,11 @@ static void CpsWritePort(const UINT32 ia, UINT8 d)
return;
}
CpsReg[(ia ^ 1) & 0xFF] = d;
if (ia == 0x10b) {
GetPalette(0, 6);
CpsPalUpdate(CpsSavePal);
}
return;
}

View File

@ -10381,6 +10381,13 @@ static INT32 CawingbInit()
return 0;
}
static INT32 Cps1demoInit()
{
bCpsUpdatePalEveryFrame = 1;
return DrvInit();
}
void __fastcall DinopicScrollWrite(UINT32 a, UINT16 d)
{
if (a == 0x980000) {
@ -11086,6 +11093,9 @@ void __fastcall Sf2m3WriteWord(UINT32 a, UINT16 d)
case 0x80010a: {
CpsReg[0x0a] = d & 0xff;
CpsReg[0x0b] = d >> 8;
GetPalette(0, 6);
CpsPalUpdate(CpsSavePal);
return;
}
@ -11632,7 +11642,7 @@ struct BurnDriver BurnDrvCpsCps1demo = {
NULL, NULL, NULL, NULL,
BDF_GAME_WORKING | BDF_DEMO, 2, HARDWARE_CAPCOM_CPS1, GBF_MISC, 0,
NULL, Cps1demoRomInfo, Cps1demoRomName, NULL, NULL, FfightInputInfo, FfightDIPInfo,
DrvInit, DrvExit, Cps1Frame, CpsRedraw, CpsAreaScan,
Cps1demoInit, DrvExit, Cps1Frame, CpsRedraw, CpsAreaScan,
&CpsRecalcPal, 0x1000, 384, 224, 4, 3
};
@ -13412,7 +13422,7 @@ struct BurnDriver BurnDrvCpsCps1frog = {
NULL, NULL, NULL, NULL,
BDF_GAME_WORKING | BDF_HOMEBREW, 2, HARDWARE_CAPCOM_CPS1, GBF_MISC, 0,
NULL, Cps1frogRomInfo, Cps1frogRomName, NULL, NULL, FfightInputInfo, FfightDIPInfo,
DrvInit, DrvExit, Cps1Frame, CpsRedraw, CpsAreaScan,
Cps1demoInit, DrvExit, Cps1Frame, CpsRedraw, CpsAreaScan,
&CpsRecalcPal, 0x1000, 384, 224, 4, 3
};