Add .bld support. Would someone mind setting up the default directory creation stuff?

This commit is contained in:
iq_132 2014-10-13 04:50:54 +00:00
parent 9edcc08a77
commit 2f60b635cd
7 changed files with 147 additions and 8 deletions

View File

@ -321,6 +321,7 @@ INT32 QscUpdate(INT32 nEnd);
extern UINT32* CpstPal;
extern UINT32 nCpstType; extern INT32 nCpstX,nCpstY;
extern UINT32 nCpstTile; extern INT32 nCpstFlip;
extern UINT32 nCpsBlend;
extern short* CpstRowShift;
extern UINT32 CpstPmsk; // Pixel mask

View File

@ -32,8 +32,68 @@ struct ObjFrame {
static INT32 nFrameCount = 0;
static struct ObjFrame of[3];
static UINT8 *blendtable;
static void CpsBlendInit()
{
blendtable = NULL;
char filename[256];
sprintf (filename, "support/blend/%s.bld", BurnDrvGetTextA(DRV_NAME));
FILE *fa = fopen(filename, "rt");
if (fa == NULL) {
sprintf (filename, "support/blend/%s.bld", BurnDrvGetTextA(DRV_PARENT));
fa = fopen(filename, "rt");
if (fa == NULL) {
return;
}
}
blendtable = (UINT8*)BurnMalloc(0x40000); // maximum number of sprites
memset (blendtable, 0, 0x40000); // no blend
char szLine[64];
INT32 table[4] = { 0, 0xff-0x3f, 0xff-0x7f, 0xff-0x7f }; // last one 7f?
while (1)
{
if (fgets (szLine, 64, fa) == NULL) break;
if (strncmp ("Game", szLine, 4) == 0) continue; // don't care
if (strncmp ("Name", szLine, 4) == 0) continue; // don't care
if (szLine[0] == ';') continue; // comment (also don't care)
int type;
unsigned int min,max,k, single_entry = -1;
for (k = 0; k < strlen(szLine); k++) {
if (szLine[k] == '-') { single_entry = k+1; break; }
}
if (single_entry < 0) {
sscanf(szLine,"%x %d",&max,&type);
min = max;
} else {
sscanf(szLine,"%x",&min);
sscanf(szLine+single_entry,"%x %d",&max,&type);
}
for (k = min; k <= max; k++) {
blendtable[k] = table[type&3];
}
}
}
INT32 CpsObjInit()
{
CpsBlendInit();
nMax = 0x100; // CPS1 has 256 sprites
if (Cps == 2) { // CPS2 has 1024 sprites
@ -67,6 +127,9 @@ INT32 CpsObjInit()
INT32 CpsObjExit()
{
if (blendtable)
BurnFree(blendtable);
for (INT32 i = 0; i < nFrameCount; i++) {
of[i].Obj = NULL;
of[i].nCount = 0;
@ -248,8 +311,10 @@ INT32 Cps1ObjDraw(INT32 nLevelFrom,INT32 nLevelTo)
nCpstX=x+(ex<<4);
nCpstY=y+(ey<<4);
nCpstTile = (n & ~0x0F) + (dy << 4) + ((n + dx) & 0x0F);
nCpsBlend = (blendtable) ? blendtable[nCpstTile] : 0;
nCpstTile <<= 7;
CpstOneObjDoX[0]();
nCpsBlend = 0;
}
}
@ -387,9 +452,11 @@ INT32 Cps2ObjDraw(INT32 nLevelFrom, INT32 nLevelTo)
// nCpstTile = n + (dy << 4) + dx; // normal version
nCpstTile = (n & ~0x0F) + (dy << 4) + ((n + dx) & 0x0F); // pgear fix
nCpsBlend = (blendtable) ? blendtable[nCpstTile] : 0;
nCpstTile <<= 7; // Find real tile address
pCpstOne();
nCpsBlend = 0;
}
}
}

View File

@ -7,6 +7,7 @@ UINT32 *CpstPal=NULL;
UINT32 nCpstType = 0;
INT32 nCpstX = 0, nCpstY = 0;
UINT32 nCpstTile = 0;
UINT32 nCpsBlend = 0;
INT32 nCpstFlip = 0;
INT16 *CpstRowShift = NULL;
UINT32 CpstPmsk = 0; // Pixel mask

View File

@ -10,6 +10,14 @@ UINT8 *pCtvTile=NULL; // Pointer to tile data
INT32 nCtvTileAdd=0; // Amount to add after each tile line
UINT8 *pCtvLine=NULL; // Pointer to output bitmap
static inline UINT32 alpha_blend(UINT32 d, UINT32 s, UINT32 p)
{
INT32 a = 255 - p;
return (((((s & 0xff00ff) * p) + ((d & 0xff00ff) * a)) & 0xff00ff00) +
((((s & 0x00ff00) * p) + ((d & 0x00ff00) * a)) & 0x00ff0000)) >> 8;
}
// Include all tile variants:
#include "ctv.h"

View File

@ -99,18 +99,18 @@ for (y = 0; y < CU_SIZE; y++, pCtvLine += nBurnPitch, pCtvTile += nCtvTileAdd
#endif
#elif CU_BPP==3
#if CU_MASK==1
#define PLOT { if(*pPixZ < ZValue) { pPix[0]=(UINT8)c; pPix[1]=(UINT8)(c>>8); pPix[2]=(UINT8)(c>>16); } }
#define PLOT { if(*pPixZ < ZValue) { if (nCpsBlend) { c = alpha_blend(pPix[0]|(pPix[1]<<8)|(pPix[2]<<16), c, nCpsBlend); } pPix[0]=(UINT8)c; pPix[1]=(UINT8)(c>>8); pPix[2]=(UINT8)(c>>16); } }
#define ADV { pPix+=3; pPixZ++; }
#else
#define PLOT { pPix[0]=(UINT8)c; pPix[1]=(UINT8)(c>>8); pPix[2]=(UINT8)(c>>16); }
#define PLOT { if (nCpsBlend) { c = alpha_blend(pPix[0]|(pPix[1]<<8)|(pPix[2]<<16), c, nCpsBlend); } pPix[0]=(UINT8)c; pPix[1]=(UINT8)(c>>8); pPix[2]=(UINT8)(c>>16); }
#define ADV pPix+=3
#endif
#elif CU_BPP==4
#if CU_MASK==1
#define PLOT { if(*pPixZ < ZValue) { *((UINT32 *)pPix)=c; *pPixZ=ZValue; } }
#define PLOT { if(*pPixZ < ZValue) { if (nCpsBlend) { c = alpha_blend(*((UINT32 *)pPix), c, nCpsBlend); } *((UINT32 *)pPix)=c; *pPixZ=ZValue; } }
#define ADV { pPix+=4; pPixZ++; }
#else
#define PLOT { *((UINT32 *)pPix)=c; }
#define PLOT { if (nCpsBlend) { c = alpha_blend(*((UINT32 *)pPix), c, nCpsBlend); } *((UINT32 *)pPix)=c; }
#define ADV pPix+=4
#endif
#else

View File

@ -34,6 +34,13 @@ static RenderBankFunction* RenderBank;
static UINT16 BankAttrib01, BankAttrib02, BankAttrib03;
static inline UINT32 alpha_blend(UINT32 d, UINT32 s, UINT32 p)
{
INT32 a = 255 - p;
return (((((s & 0xff00ff) * p) + ((d & 0xff00ff) * a)) & 0xff00ff00) +
((((s & 0x00ff00) * p) + ((d & 0x00ff00) * a)) & 0x00ff0000)) >> 8;
}
// Include the tile rendering functions
#include "neo_sprite_func.h"
@ -93,7 +100,6 @@ INT32 NeoRenderSprites()
}
if (nBankSize) {
nBankXZoom = (BankAttrib01 >> 8) & 0x0F;
if (nBankXPos >= 0x01E0) {
nBankXPos -= 0x200;
@ -140,6 +146,58 @@ void NeoSetSpriteSlot(INT32 nSlot)
nNeoMaxTileActive = nNeoMaxTile[nSlot];
}
static void NeoBlendInit(INT32 nSlot)
{
char filename[256];
sprintf (filename, "support/blend/%s.bld", BurnDrvGetTextA(DRV_NAME));
FILE *fa = fopen(filename, "rt");
if (fa == NULL) {
sprintf (filename, "support/blend/%s.bld", BurnDrvGetTextA(DRV_PARENT));
fa = fopen(filename, "rt");
if (fa == NULL) {
return;
}
}
char szLine[64];
INT32 table[4] = { 0, 0xff-0x3f, 0xff-0x7f, 0xff-0x7f }; // last one 7f?
while (1)
{
if (fgets (szLine, 64, fa) == NULL) break;
if (strncmp ("Game", szLine, 4) == 0) continue; // don't care
if (strncmp ("Name", szLine, 4) == 0) continue; // don't care
if (szLine[0] == ';') continue; // comment (also don't care)
int type;
unsigned int min,max,k, single_entry = -1;
for (k = 0; k < strlen(szLine); k++) {
if (szLine[k] == '-') { single_entry = k+1; break; }
}
if (single_entry < 0) {
sscanf(szLine,"%x %d",&max,&type);
min = max;
} else {
sscanf(szLine,"%x",&min);
sscanf(szLine+single_entry,"%x %d",&max,&type);
}
for (k = min; k <= max; k++) {
if (NeoTileAttrib[nSlot][k] != 1) // ?
NeoTileAttrib[nSlot][k] = table[type&3];
}
}
}
INT32 NeoInitSprites(INT32 nSlot)
{
// Create a table that indicates if a tile is transparent
@ -163,6 +221,8 @@ INT32 NeoInitSprites(INT32 nSlot)
NeoTileAttrib[nSlot][i] = 1;
}
NeoBlendInit(nSlot);
NeoTileAttribActive = NeoTileAttrib[nSlot];
NeoSpriteROMActive = NeoSpriteROM[nSlot];
nNeoTileMaskActive = nNeoTileMask[nSlot];

View File

@ -26,13 +26,15 @@
#elif BPP == 24
#define PLOTPIXEL(a,b) if (TESTCOLOUR(b) && TESTCLIP(a)) { \
UINT32 nRGB = pTilePalette[b]; \
if (nTransparent) nRGB = alpha_blend((pPixel[2]<<16)+(pPixel[1]<<8)+pPixel[0], nRGB, nTransparent); \
pPixel[0] = (UINT8)nRGB; \
pPixel[1] = (UINT8)(nRGB >> 8); \
pPixel[2] = (UINT8)(nRGB >> 16); \
}
#elif BPP == 32
#define PLOTPIXEL(a,b) if (TESTCOLOUR(b) && TESTCLIP(a)) { \
*((UINT32*)pPixel) = (UINT32)pTilePalette[b]; \
if (nTransparent) *((UINT32*)pPixel) = alpha_blend(*((UINT32*)pPixel), (UINT32)pTilePalette[b], nTransparent); \
else *((UINT32*)pPixel) = (UINT32)pTilePalette[b]; \
}
#else
#error unsupported bitdepth specified.
@ -619,13 +621,13 @@ static void FUNCTIONNAME(BPP,XZOOM,CLIP,OPACITY)()
nTransparent = NeoTileAttribActive[nTileNumber];
if (nTransparent == 0) {
if (nTransparent != 1) {
pTileData = (UINT32*)(NeoSpriteROMActive + (nTileNumber << 7));
pTilePalette = &NeoPalette[(nTileAttrib & 0xFF00) >> 4];
}
}
if (nTransparent == 0) {
if (nTransparent != 1) {
nLine = (pZoomValue[nThisLine] & 0x0F) << 1;
if (nTileAttrib & 2) { // Flip Y
nLine ^= 0x1E;