cps1, arbitrary screen size support for bankbank

This commit is contained in:
dinkc64 2023-12-10 01:10:44 -05:00
parent 0377a57a6f
commit cd8cf5dd23
7 changed files with 44 additions and 71 deletions

View File

@ -2236,6 +2236,15 @@ INT32 CpsInit()
}
}
if (BurnDrvGetFlags() & BDF_ORIENTATION_VERTICAL) {
BurnDrvGetVisibleSize(&nCpsScreenHeight, &nCpsScreenWidth);
} else {
BurnDrvGetVisibleSize(&nCpsScreenWidth, &nCpsScreenHeight);
}
nCpsGlobalXOffset = (nCpsScreenWidth-384)>>1;
nCpsGlobalYOffset = (nCpsScreenHeight-224)>>1;
if (!nCPS68KClockspeed) {
if (!(Cps & 1)) {
nCPS68KClockspeed = 11800000;
@ -2311,14 +2320,6 @@ INT32 Cps2Init()
{
Cps = 2;
if (BurnDrvGetFlags() & BDF_ORIENTATION_VERTICAL) {
BurnDrvGetVisibleSize(&nCpsScreenHeight, &nCpsScreenWidth);
} else {
BurnDrvGetVisibleSize(&nCpsScreenWidth, &nCpsScreenHeight);
}
nCpsGlobalXOffset = (nCpsScreenWidth-384)>>1;
nCpsGlobalYOffset = (nCpsScreenHeight-224)>>1;
if (CpsGetROMs(false)) {
return 1;
}

View File

@ -449,7 +449,7 @@ struct CpsrLineInfo {
INT16 Rows[16]; // 16 row scroll values for this line
INT32 nMaxLeft, nMaxRight; // Maximum row shifts left and right
};
extern struct CpsrLineInfo CpsrLineInfo[16];
extern struct CpsrLineInfo CpsrLineInfo[32];
INT32 Cps1rPrepare();
INT32 Cps2rPrepare();

View File

@ -219,7 +219,7 @@ static INT32 DrawStar(INT32 nLayer)
nStarXPos = (((nStar >> 8) << 5) - *((INT16*)(CpsSaveReg[0] + 0x18 + (nLayer << 2))) + (nStarColour & 0x1F) - 64) & 0x01FF;
nStarYPos = ((nStar & 0xFF) - *((INT16*)(CpsSaveReg[0] + 0x1A + (nLayer << 2))) - 16) & 0xFF;
if (nStarXPos < 384 && nStarYPos < 224) {
if (nStarXPos < nCpsScreenWidth && nStarYPos < nCpsScreenHeight) {
nStarColour = ((nStarColour & 0xE0) >> 1) + ((GetCurrentFrame() >> 4) % ((nStarColour & 0x80) ? 0xe : 0xf));
PutPix(pBurnDraw + (nBurnPitch * nStarYPos) + (nBurnBpp * nStarXPos), CpsPal[0x0800 + (nLayer << 9) + nStarColour]);
}
@ -444,7 +444,7 @@ void CpsClearScreen()
case 4: {
UINT32* pClear = (UINT32*)pBurnDraw;
UINT32 nColour = (fFakeDip & 1) ? 0 : CpsPal[0xbff ^ 15];
for (INT32 i = 0; i < 384 * 224 / 8; i++) {
for (INT32 i = 0; i < nCpsScreenWidth * nCpsScreenHeight / 8; i++) {
*pClear++ = nColour;
*pClear++ = nColour;
*pClear++ = nColour;
@ -464,7 +464,7 @@ void CpsClearScreen()
UINT8 b = (CpsPal[0xbff ^ 15] >> 16) & 0xFF;
if (fFakeDip & 1) r = g = b = 0;
for (INT32 i = 0; i < 384 * 224; i++) {
for (INT32 i = 0; i < nCpsScreenWidth * nCpsScreenHeight; i++) {
*pClear++ = r;
*pClear++ = g;
*pClear++ = b;
@ -477,7 +477,7 @@ void CpsClearScreen()
UINT32 nColour = CpsPal[0xbff ^ 15] | CpsPal[0xbff ^ 15] << 16;
if (fFakeDip & 1) nColour = 0;
for (INT32 i = 0; i < 384 * 224 / 16; i++) {
for (INT32 i = 0; i < nCpsScreenWidth * nCpsScreenHeight / 16; i++) {
*pClear++ = nColour;
*pClear++ = nColour;
*pClear++ = nColour;

View File

@ -189,6 +189,8 @@ INT32 CpsObjGet()
if (Cps1LockSpriteList910000) {
Get = CpsFindGfxRam(0x910000, 0x800);
}
pof->nShiftX += nCpsGlobalXOffset;
pof->nShiftY += nCpsGlobalYOffset;
}
if (Get==NULL) return 1;
@ -300,7 +302,7 @@ INT32 Cps1ObjDraw(INT32 nLevelFrom,INT32 nLevelTo)
nFlip=(a>>5)&3;
// Take care with tiles if the sprite goes off the screen
if (x<0 || y<0 || x+(bx<<4)>nCpsScreenWidth || y+(by<<4)>nCpsScreenHeight) {
if (x<0 || y<0 || x+(bx<<4)>(nCpsScreenWidth-1) || y+(by<<4)>(nCpsScreenHeight-1)) {
nCpstType=CTT_16X16 | CTT_CARE;
} else {
nCpstType=CTT_16X16;
@ -857,7 +859,7 @@ INT32 FcrashObjDraw(INT32 nLevelFrom,INT32 nLevelTo)
nFlip=(a>>5)&3;
// Take care with tiles if the sprite goes off the screen
if (x<0 || y<0 || x+(1<<4)>nCpsScreenWidth || y+(1<<4)>nCpsScreenHeight) {
if (x<0 || y<0 || x+(1<<4)>(nCpsScreenWidth-1) || y+(1<<4)>(nCpsScreenHeight-1)) {
nCpstType=CTT_16X16 | CTT_CARE;
} else {
nCpstType=CTT_16X16;

View File

@ -17,13 +17,15 @@ INT32 Cps1Scr1Draw(UINT8 *Base,INT32 sx,INT32 sy)
INT32 x,y;
INT32 ix,iy;
INT32 nKnowBlank=-1; // The tile we know is blank
INT32 nXTile = nCpsScreenWidth>>3; // 8x8 tiles
INT32 nYTile = nCpsScreenHeight>>3; // ""
ix=(sx>>3)+1; iy=(sy>>3)+1;
sx&=7; sy&=7; sx=8-sx; sy=8-sy;
for (y=-1; y<28; y++)
for (y=-1; y<nYTile; y++)
{
for (x=-1; x<48; x++)
for (x=-1; x<nXTile; x++)
{
INT32 t,a;
UINT16 *pst;
@ -52,7 +54,7 @@ INT32 Cps1Scr1Draw(UINT8 *Base,INT32 sx,INT32 sy)
CpstSetPal(0x20 | (a&0x1f));
// Don't need to clip except around the border
if (x<0 || x>=48-1 || y<0 || y>=28-1)
if (x<0 || x>=nXTile-1 || y<0 || y>=nYTile-1)
nCpstType=CTT_8X8 | CTT_CARE;
else
nCpstType=CTT_8X8;
@ -78,7 +80,7 @@ INT32 Cps2Scr1Draw(UINT8 *Base, INT32 sx, INT32 sy)
INT32 ix, iy;
INT32 nFirstY, nLastY;
INT32 nKnowBlank = -1; // The tile we know is blank
INT32 nXTile = nCpsScreenWidth>>3; // 48*8 = 384, 52*8 = 416
INT32 nXTile = nCpsScreenWidth>>3; // 8x8 tiles
ix = (sx >> 3) + 1;
sx &= 7;
@ -144,10 +146,12 @@ INT32 Cps1Scr3Draw(UINT8 *Base,INT32 sx,INT32 sy)
INT32 nKnowBlank=-1; // The tile we know is blank
ix=(sx>>5)+1; iy=(sy>>5)+1;
sx&=31; sy&=31; sx=32-sx; sy=32-sy;
INT32 nXTile = nCpsScreenWidth>>5; // 32x32 tiles
INT32 nYTile = nCpsScreenHeight>>5;
for (y=-1; y<7; y++)
for (y=-1; y<nYTile; y++)
{
for (x=-1; x<12; x++)
for (x=-1; x<nXTile; x++)
{
INT32 t,a;
UINT16 *pst;
@ -176,7 +180,7 @@ INT32 Cps1Scr3Draw(UINT8 *Base,INT32 sx,INT32 sy)
CpstSetPal(0x60 | (a&0x1f));
// Don't need to clip except around the border
if (x<0 || x>=12-1 || y<0 || y>=7-1)
if (x<0 || x>=nXTile-1 || y<0 || y>=nYTile-1)
nCpstType=CTT_32X32 | CTT_CARE;
else
nCpstType=CTT_32X32;
@ -201,7 +205,7 @@ INT32 Cps2Scr3Draw(UINT8 *Base, INT32 sx, INT32 sy)
INT32 ix, iy;
INT32 nFirstY, nLastY;
INT32 nKnowBlank = -1; // The tile we know is blank
INT32 nXTile = nCpsScreenWidth>>5; // 12*32 = 384, 13*32 = 416
INT32 nXTile = nCpsScreenWidth>>5; // 32x32 tiles
ix = (sx >> 5) + 1;
sx &= 31;

View File

@ -9,7 +9,7 @@ int nCpsrRowStart=0; // Start of row scroll (can wrap?)
static INT32 nShiftY=0;
static INT32 EndLineInfo=0;
struct CpsrLineInfo CpsrLineInfo[16]; // +1 added for Cps2Turbo
struct CpsrLineInfo CpsrLineInfo[32]; // supports up to 512-y lines
static void GetRowsRange(INT32 *pnStart,INT32 *pnWidth,INT32 nRowFrom,INT32 nRowTo)
{
@ -109,47 +109,9 @@ static INT32 PrepareRows()
INT32 Cps1rPrepare()
{
INT32 y; struct CpsrLineInfo *pli;
if (CpsrBase==NULL) return 1;
nEndline = nCpsScreenHeight;
nEndline = 224;
EndLineInfo = 14;
nShiftY=16-(nCpsrScrY&15);
for (y=-1,pli=CpsrLineInfo; y<EndLineInfo; y++,pli++)
{
INT32 nStart=0,nWidth=0;
if (CpsrRows!=NULL)
{
INT32 nRowFrom,nRowTo;
// Find out which rows we need to check
nRowFrom=(y<<4)+nShiftY;
nRowTo=nRowFrom+16;
if (nRowFrom<0) nRowFrom=0;
if (nRowTo>224) nRowTo=224;
// Shift by row table start offset
nRowFrom+=nCpsrRowStart;
nRowTo +=nCpsrRowStart;
// Find out what range of scroll values there are for this line
GetRowsRange(&nStart,&nWidth,nRowFrom,nRowTo);
}
nStart+=nCpsrScrX;
nStart&=0x3ff;
// Save info in CpsrLineInfo table
pli->nStart=nStart;
pli->nWidth=nWidth;
// Find range of tiles to draw to see whole width:
pli->nTileStart=nStart>>4;
pli->nTileEnd=(nStart+nWidth+nCpsScreenWidth+15)>>4;
}
PrepareRows();
return 0;
return Cps2rPrepare();
}
INT32 Cps2rPrepare()

View File

@ -5,7 +5,8 @@ static INT32 nKnowBlank=-1; // The tile we know is blank
static INT32 nFirstY, nLastY;
static INT32 bVCare;
static INT32 nXTiles = 24;
static INT32 nXTiles = 0;
static INT32 nYTiles = 0;
inline static UINT16 *FindTile(INT32 fx,INT32 fy)
{
@ -22,17 +23,17 @@ static void Cps1TileLine(INT32 y,INT32 sx)
INT32 x,ix,iy,sy;
bVCare=0;
if (y<0 || y>=14-1) bVCare=1; // Take care on the edges
if (y<0 || y>=nYTiles-1) bVCare=1; // Take care on the edges
ix=(sx>>4)+1; sx&=15; sx=16-sx;
sy=16-(nCpsrScrY&15); iy=(nCpsrScrY>>4)+1;
nCpstY=sy+(y<<4);
for (x=-1; x<24; x++)
for (x=-1; x<nXTiles; x++)
{
UINT16 *pst; INT32 t,a;
// Don't need to clip except around the border
if (bVCare || x<0 || x>=24-1) nCpstType=CTT_16X16 | CTT_CARE;
if (bVCare || x<0 || x>=nXTiles-1) nCpstType=CTT_16X16 | CTT_CARE;
else nCpstType=CTT_16X16;
pst=FindTile(ix+x,iy+y);
@ -93,7 +94,7 @@ static void Cps1TileLineRows(INT32 y,struct CpsrLineInfo *pli)
INT32 nLimLeft,nLimRight;
bVCare=0;
if (y<0 || y>=14-1) bVCare=1; // Take care on the edges
if (y<0 || y>=nYTiles-1) bVCare=1; // Take care on the edges
nTileCount=pli->nTileEnd-pli->nTileStart;
@ -200,10 +201,12 @@ INT32 Cps1rRender()
{
INT32 y; struct CpsrLineInfo *pli;
if (CpsrBase==NULL) return 1;
nXTiles = nCpsScreenWidth>>4; // 16x16 tiles
nYTiles = nCpsScreenHeight>>4;
nKnowBlank=-1; // We don't know which tile is blank yet
for (y=-1,pli=CpsrLineInfo; y<14; y++,pli++)
for (y=-1,pli=CpsrLineInfo; y<nYTiles; y++,pli++)
{
if (pli->nWidth==0)
Cps1TileLine(y,pli->nStart); // no rowscroll needed
@ -218,7 +221,8 @@ INT32 Cps2rRender()
INT32 y;
struct CpsrLineInfo *pli;
if (CpsrBase==NULL) return 1;
nXTiles = nCpsScreenWidth>>4; // 24*16 = 384, 26*16 = 416
nXTiles = nCpsScreenWidth>>4; // 16x16 tiles
nYTiles = nCpsScreenHeight>>4;
nKnowBlank = -1; // We don't know which tile is blank yet