Skip to content

Commit

Permalink
Merge pull request #246 from finalburnneo/master
Browse files Browse the repository at this point in the history
Updates
  • Loading branch information
barbudreadmon committed Feb 13, 2020
2 parents ea16141 + b9e36c8 commit 0ad0e3c
Showing 1 changed file with 69 additions and 54 deletions.
123 changes: 69 additions & 54 deletions src/burn/drv/cps3/cps3run.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ static UINT8 *RomUser;

static UINT8 *RamMain;
static UINT32 *RamSpr;
static UINT32 *SprList;
static UINT16 *RamPal;

static UINT32 *RamCRam;
Expand Down Expand Up @@ -83,6 +84,9 @@ static UINT32 paldma_length = 0;
static UINT32 chardma_source = 0;
static UINT32 chardma_table_address = 0;

static UINT16 spritelist_dma = 0;
static UINT16 prev;

static INT32 cps3_gfx_width, cps3_gfx_height;
static INT32 cps3_gfx_max_x, cps3_gfx_max_y;

Expand Down Expand Up @@ -445,7 +449,6 @@ static void cps3_process_character_dma(UINT32 address)
UINT32 real_length = (((dat1&0x001fffff)+1)<<3);

if (dat1==0x01000000) break; // end of list marker
if (dat1==0x13131313) break; // our default fill

switch ( dat1 & 0x00e00000 ) {
case 0x00800000:
Expand Down Expand Up @@ -498,6 +501,7 @@ static INT32 MemIndex()

RamPal = (UINT16 *) Next; Next += 0x0020000 * sizeof(UINT16);
RamSpr = (UINT32 *) Next; Next += 0x0020000 * sizeof(UINT32);
SprList = (UINT32 *) Next; Next += 0x80000/4 * sizeof(UINT32);

RamCRam = (UINT32 *) Next; Next += 0x0200000 * sizeof(UINT32);
RamSS = (UINT32 *) Next; Next += 0x0004000 * sizeof(UINT32);
Expand Down Expand Up @@ -631,21 +635,14 @@ void __fastcall cps3WriteByte(UINT32 addr, UINT8 data)
}
}

#define max(a,b) (((a)>(b))?(a):(b))
#define min(a,b) (((a)<(b))?(a):(b))

static inline UINT8 get_fade(INT32 c, INT32 f)
inline static UINT8 cps3_get_fade(INT32 c, INT32 f)
{
// bit 7 unknown
// bit 7 unused, explicit masked out
// bit 6 fade enable / disable
// bit 5 fade mode
// bit 5 fade mode (1 = invert input values and output)
// bit 4-0 fade value
if (f & 0x40) // Fading enable / disable
{
f &= 0x3f;
c = (f & 0x20) ? (c + (((0x1f - c) * (f & 0x1f)) / 0x1f)) : ((c * f) / 0x1f);
c = max(0, min(0x1f, c));
}
c = (f & 0x20) ? ((((c ^ 0x1f) * (~f & 0x1f)) >> 5) ^ 0x1f) : (c * (f & 0x1f) >> 5);
return c;
}

Expand All @@ -654,7 +651,26 @@ void __fastcall cps3WriteWord(UINT32 addr, UINT16 data)
addr &= 0xc7ffffff;

switch (addr) {


case 0x040c0080: break;
case 0x040c0082:
prev = spritelist_dma;
spritelist_dma = data;
if ((spritelist_dma & 8) && !(prev & 8)) // 0->1
{
for (int i = 0; i < 0x2000/4; i += 4)
{
memcpy(SprList + i, RamSpr + i, 4*sizeof(UINT32)); // copy main list record
UINT32 dat = RamSpr[i];
if (dat & 0x80000000)
break;
UINT32 offs = (dat & 0x00007fff) << 2;
UINT32 length = (dat & 0x01ff0000) >> 16;
memcpy(SprList + offs, RamSpr + offs, length*4*sizeof(UINT32)); // copy sublist
}
}
break;

case 0x040c0084: break;
case 0x040c0086:
if (cram_bank != data) {
Expand Down Expand Up @@ -704,9 +720,9 @@ void __fastcall cps3WriteWord(UINT32 addr, UINT16 data)
UINT32 g = (coldata & 0x03E0) >> 5;
UINT32 b = (coldata & 0x7C00) >> 10;
if (paldma_fade & 0x40400040) {
r = get_fade(r, (paldma_fade & 0x7f000000)>>24);
g = get_fade(g, (paldma_fade & 0x007f0000)>>16);
b = get_fade(b, (paldma_fade & 0x0000007f)>>0);
r = cps3_get_fade(r, (paldma_fade & 0x7f000000)>>24);
g = cps3_get_fade(g, (paldma_fade & 0x007f0000)>>16);
b = cps3_get_fade(b, (paldma_fade & 0x0000007f)>>0);
coldata = (coldata & 0x8000) | (r << 0) | (g << 5) | (b << 10);
}

Expand Down Expand Up @@ -1087,6 +1103,7 @@ static INT32 Cps3Reset()
}

cps3_current_eeprom_read = 0;
spritelist_dma = 0;
cps3SndReset();
cps3_reset = 0;

Expand Down Expand Up @@ -1127,7 +1144,8 @@ INT32 cps3Init()
INT32 nLen = MemEnd - (UINT8 *)0;
if ((Mem = (UINT8 *)BurnMalloc(nLen)) == NULL) return 1;
memset(Mem, 0, nLen); // blank all memory
MemIndex();
MemIndex();
SprList[0] = 0x80000000;

// load and decode bios roms
ii = 0; offset = 0;
Expand Down Expand Up @@ -1699,7 +1717,7 @@ static void cps3_draw_tilemapsprite_line(INT32 drawline, UINT32 * regs )
scrollx = (regs[0]&0xffff0000)>>16;
} else {
scrollx = (regs[0]&0xffff0000)>>16;
scrollx+= (RamSpr[linebase+((line+16-4)&0x3ff)]>>16)&0x3ff;
scrollx+= (RamSpr[linebase+((line+16)&0x3ff)]>>16)&0x3ff; // test case: sfiii Ryu's stage 2nd round floor
}

if (drawline>cps3_gfx_max_y+4) return;
Expand Down Expand Up @@ -1731,8 +1749,6 @@ static INT32 WideScreenFrameDelay = 0;

INT32 DrvCps3Draw()
{
INT32 bg_drawn[4] = { 0, 0, 0, 0 };

UINT32 fullscreenzoom = RamVReg[ 6 * 4 + 3 ] & 0xff;
UINT32 fullscreenzoomwidecheck = RamVReg[6 * 4 + 1];

Expand Down Expand Up @@ -1785,22 +1801,22 @@ INT32 DrvCps3Draw()
{
for (INT32 i=0x00000/4;i<0x2000/4;i+=4) {

if (RamSpr[i+0]&0x80000000) break;
if (SprList[i+0]&0x80000000) break;

INT32 gscroll = (RamSpr[i+0]&0x70000000)>>28;
INT32 length = (RamSpr[i+0]&0x01ff0000)>>14; // how many entries in the sprite table
UINT32 start = (RamSpr[i+0]&0x00007ff0)>>4;
INT32 gscroll = (SprList[i+0]&0x70000000)>>28;
INT32 length = (SprList[i+0]&0x01ff0000)>>14; // how many entries in the sprite table
UINT32 start = (SprList[i+0]&0x00007ff0)>>4;

INT32 xpos = (RamSpr[i+1]&0x03ff0000)>>16;
INT32 ypos = (RamSpr[i+1]&0x000003ff)>>0;
INT32 xpos = (SprList[i+1]&0x03ff0000)>>16;
INT32 ypos = (SprList[i+1]&0x000003ff)>>0;

INT32 whichbpp = (RamSpr[i+2]&0x40000000)>>30; // not 100% sure if this is right, jojo title / characters
INT32 whichpal = (RamSpr[i+2]&0x20000000)>>29;
INT32 global_xflip = (RamSpr[i+2]&0x10000000)>>28;
INT32 global_yflip = (RamSpr[i+2]&0x08000000)>>27;
INT32 global_alpha = (RamSpr[i+2]&0x04000000)>>26; // alpha / shadow? set on sfiii2 shadows, and big black image in jojo intro
INT32 global_bpp = (RamSpr[i+2]&0x02000000)>>25;
INT32 global_pal = (RamSpr[i+2]&0x01ff0000)>>16;
INT32 whichbpp = (SprList[i+2]&0x40000000)>>30; // not 100% sure if this is right, jojo title / characters
INT32 whichpal = (SprList[i+2]&0x20000000)>>29;
INT32 global_xflip = (SprList[i+2]&0x10000000)>>28;
INT32 global_yflip = (SprList[i+2]&0x08000000)>>27;
INT32 global_alpha = (SprList[i+2]&0x04000000)>>26; // alpha / shadow? set on sfiii2 shadows, and big black image in jojo intro
INT32 global_bpp = (SprList[i+2]&0x02000000)>>25;
INT32 global_pal = (SprList[i+2]&0x01ff0000)>>16;

INT32 gscrollx = (RamVReg[gscroll]&0x03ff0000)>>16;
INT32 gscrolly = (RamVReg[gscroll]&0x000003ff)>>0;
Expand All @@ -1809,9 +1825,9 @@ INT32 DrvCps3Draw()

for (INT32 j=0; j<length; j+=4) {

UINT32 value1 = (RamSpr[start+j+0]);
UINT32 value2 = (RamSpr[start+j+1]);
UINT32 value3 = (RamSpr[start+j+2]);
UINT32 value1 = (SprList[start+j+0]);
UINT32 value2 = (SprList[start+j+1]);
UINT32 value3 = (SprList[start+j+2]);

INT32 tilestable[4] = { 8,1,2,4 };

Expand Down Expand Up @@ -1841,27 +1857,18 @@ INT32 DrvCps3Draw()
if (nBurnLayer & 1)
{
INT32 tilemapnum = ((value3 & 0x00000030)>>4);
INT32 startline;
INT32 endline;
INT32 height = (value3 & 0x7f000000)>>24;
UINT32 * regs;

regs = RamVReg + 8 + tilemapnum * 4;
endline = value2;
startline = endline - height;

startline &=0x3ff;
endline &=0x3ff;
UINT32 * regs = RamVReg + 8 + tilemapnum * 4;

if (bg_drawn[tilemapnum]==0)
for (yy = 0; yy <= ysizedraw2; yy++)
{
UINT32 srcy = 0;
for (INT32 ry = 0; ry < 224; ry++, srcy += fsz) {
cps3_draw_tilemapsprite_line( srcy >> 16, regs );
}
}
INT32 cury_pos = ypos2 + gscrolly - yy;
cury_pos = ~cury_pos;
cury_pos -= 18;
cury_pos &= 0x3ff;

bg_drawn[tilemapnum] = 1;
if (cury_pos >= 0 && cury_pos <= cps3_gfx_max_y)
cps3_draw_tilemapsprite_line(cury_pos, regs);
}
}
} else {
if (~nSpriteEnable & 1) continue;
Expand Down Expand Up @@ -2078,6 +2085,12 @@ INT32 cps3Scan(INT32 nAction, INT32 *pnMin)
ba.szName = "Sprite RAM";
BurnAcb(&ba);

ba.Data = SprList;
ba.nLen = 0x0080000;
ba.nAddress = 0;
ba.szName = "Sprite List";
BurnAcb(&ba);

ba.Data = RamSS;
ba.nLen = 0x0010000;
ba.nAddress = 0;
Expand Down Expand Up @@ -2149,6 +2162,8 @@ INT32 cps3Scan(INT32 nAction, INT32 *pnMin)

SCAN_VAR(chardma_source);
SCAN_VAR(chardma_table_address);

SCAN_VAR(spritelist_dma);

//SCAN_VAR(main_flash);

Expand Down

0 comments on commit 0ad0e3c

Please sign in to comment.