|
|
|
|
@ -17,7 +17,9 @@ DEVILUTION_BEGIN_NAMESPACE
|
|
|
|
|
|
|
|
|
|
/** automap pixel color 8-bit (palette entry) */ |
|
|
|
|
char gbPixelCol; |
|
|
|
|
BOOL gbRotateMap; // flip - if y < x
|
|
|
|
|
/** flip - if y < x */ |
|
|
|
|
BOOL gbRotateMap; |
|
|
|
|
/** Seed value before the most recent call to SetRndSeed() */ |
|
|
|
|
int orgseed; |
|
|
|
|
/** Width of sprite being blitted */ |
|
|
|
|
int sgnWidth; |
|
|
|
|
@ -26,7 +28,8 @@ int sglGameSeed;
|
|
|
|
|
static CCritSect sgMemCrit; |
|
|
|
|
/** Number of times the current seed has been fetched */ |
|
|
|
|
int SeedCount; |
|
|
|
|
BOOL gbNotInView; // valid - if x/y are in bounds
|
|
|
|
|
/** valid - if x/y are in bounds */ |
|
|
|
|
BOOL gbNotInView; |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Specifies the increment used in the Borland C/C++ pseudo-random. |
|
|
|
|
@ -895,32 +898,6 @@ void Cl2ApplyTrans(BYTE *p, BYTE *ttbl, int nCel)
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Blit CL2 sprite, to the back buffer at the given coordianates |
|
|
|
|
* @param sx Back buffer coordinate |
|
|
|
|
* @param sy Back buffer coordinate |
|
|
|
|
* @param pCelBuff CL2 buffer |
|
|
|
|
* @param nCel CL2 frame number |
|
|
|
|
* @param nWidth Width of sprite |
|
|
|
|
*/ |
|
|
|
|
void Cl2Draw(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth) |
|
|
|
|
{ |
|
|
|
|
BYTE *pRLEBytes; |
|
|
|
|
int nDataSize; |
|
|
|
|
|
|
|
|
|
assert(gpBuffer != NULL); |
|
|
|
|
assert(pCelBuff != NULL); |
|
|
|
|
assert(nCel > 0); |
|
|
|
|
|
|
|
|
|
pRLEBytes = CelGetFrameClipped(pCelBuff, nCel, &nDataSize); |
|
|
|
|
|
|
|
|
|
Cl2BlitSafe( |
|
|
|
|
&gpBuffer[sx + BUFFER_WIDTH * sy], |
|
|
|
|
pRLEBytes, |
|
|
|
|
nDataSize, |
|
|
|
|
nWidth); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Blit CL2 sprite to the given buffer |
|
|
|
|
* @param pDecodeTo The output buffer |
|
|
|
|
@ -928,7 +905,7 @@ void Cl2Draw(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth)
|
|
|
|
|
* @param nDataSize Size of CL2 in bytes |
|
|
|
|
* @param nWidth Width of sprite |
|
|
|
|
*/ |
|
|
|
|
void Cl2BlitSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth) |
|
|
|
|
static void Cl2BlitSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth) |
|
|
|
|
{ |
|
|
|
|
int w; |
|
|
|
|
char width; |
|
|
|
|
@ -999,36 +976,6 @@ void Cl2BlitSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth)
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Blit a solid colder shape one pixel larger then the given sprite shape, to the back buffer at the given coordianates |
|
|
|
|
* @param col Color index from current palette |
|
|
|
|
* @param sx Back buffer coordinate |
|
|
|
|
* @param sy Back buffer coordinate |
|
|
|
|
* @param pCelBuff CL2 buffer |
|
|
|
|
* @param nCel CL2 frame number |
|
|
|
|
* @param nWidth Width of sprite |
|
|
|
|
*/ |
|
|
|
|
void Cl2DrawOutline(char col, int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth) |
|
|
|
|
{ |
|
|
|
|
int nDataSize; |
|
|
|
|
BYTE *pRLEBytes; |
|
|
|
|
|
|
|
|
|
assert(gpBuffer != NULL); |
|
|
|
|
assert(pCelBuff != NULL); |
|
|
|
|
assert(nCel > 0); |
|
|
|
|
|
|
|
|
|
pRLEBytes = CelGetFrameClipped(pCelBuff, nCel, &nDataSize); |
|
|
|
|
|
|
|
|
|
gpBufEnd -= BUFFER_WIDTH; |
|
|
|
|
Cl2BlitOutlineSafe( |
|
|
|
|
&gpBuffer[sx + BUFFER_WIDTH * sy], |
|
|
|
|
pRLEBytes, |
|
|
|
|
nDataSize, |
|
|
|
|
nWidth, |
|
|
|
|
col); |
|
|
|
|
gpBufEnd += BUFFER_WIDTH; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Blit a solid colder shape one pixel larger then the given sprite shape, to the given buffer |
|
|
|
|
* @param pDecodeTo The output buffer |
|
|
|
|
@ -1037,7 +984,7 @@ void Cl2DrawOutline(char col, int sx, int sy, BYTE *pCelBuff, int nCel, int nWid
|
|
|
|
|
* @param nWidth Width of sprite |
|
|
|
|
* @param col Color index from current palette |
|
|
|
|
*/ |
|
|
|
|
void Cl2BlitOutlineSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth, char col) |
|
|
|
|
static void Cl2BlitOutlineSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth, char col) |
|
|
|
|
{ |
|
|
|
|
int w; |
|
|
|
|
char width; |
|
|
|
|
@ -1114,41 +1061,6 @@ void Cl2BlitOutlineSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWi
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Blit CL2 sprite, and apply a given lighting, to the back buffer at the given coordianates |
|
|
|
|
* @param sx Back buffer coordinate |
|
|
|
|
* @param sy Back buffer coordinate |
|
|
|
|
* @param pCelBuff CL2 buffer |
|
|
|
|
* @param nCel CL2 frame number |
|
|
|
|
* @param nWidth Width of sprite |
|
|
|
|
* @param light Light shade to use |
|
|
|
|
*/ |
|
|
|
|
void Cl2DrawLightTbl(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, char light) |
|
|
|
|
{ |
|
|
|
|
int nDataSize, idx; |
|
|
|
|
BYTE *pRLEBytes, *pDecodeTo; |
|
|
|
|
|
|
|
|
|
assert(gpBuffer != NULL); |
|
|
|
|
assert(pCelBuff != NULL); |
|
|
|
|
assert(nCel > 0); |
|
|
|
|
|
|
|
|
|
pRLEBytes = CelGetFrameClipped(pCelBuff, nCel, &nDataSize); |
|
|
|
|
pDecodeTo = &gpBuffer[sx + BUFFER_WIDTH * sy]; |
|
|
|
|
|
|
|
|
|
idx = light4flag ? 1024 : 4096; |
|
|
|
|
if (light == 2) |
|
|
|
|
idx += 256; // gray colors
|
|
|
|
|
if (light >= 4) |
|
|
|
|
idx += (light - 1) << 8; |
|
|
|
|
|
|
|
|
|
Cl2BlitLightSafe( |
|
|
|
|
pDecodeTo, |
|
|
|
|
pRLEBytes, |
|
|
|
|
nDataSize, |
|
|
|
|
nWidth, |
|
|
|
|
&pLightTbl[idx]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Blit CL2 sprite, and apply lighting, to the given buffer |
|
|
|
|
* @param pDecodeTo The output buffer |
|
|
|
|
@ -1157,7 +1069,7 @@ void Cl2DrawLightTbl(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, char
|
|
|
|
|
* @param nWidth With of CL2 sprite |
|
|
|
|
* @param pTable Light color table |
|
|
|
|
*/ |
|
|
|
|
void Cl2BlitLightSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth, BYTE *pTable) |
|
|
|
|
static void Cl2BlitLightSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth, BYTE *pTable) |
|
|
|
|
{ |
|
|
|
|
int w; |
|
|
|
|
char width; |
|
|
|
|
@ -1229,6 +1141,96 @@ void Cl2BlitLightSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidt
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Blit CL2 sprite, to the back buffer at the given coordianates |
|
|
|
|
* @param sx Back buffer coordinate |
|
|
|
|
* @param sy Back buffer coordinate |
|
|
|
|
* @param pCelBuff CL2 buffer |
|
|
|
|
* @param nCel CL2 frame number |
|
|
|
|
* @param nWidth Width of sprite |
|
|
|
|
*/ |
|
|
|
|
void Cl2Draw(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth) |
|
|
|
|
{ |
|
|
|
|
BYTE *pRLEBytes; |
|
|
|
|
int nDataSize; |
|
|
|
|
|
|
|
|
|
assert(gpBuffer != NULL); |
|
|
|
|
assert(pCelBuff != NULL); |
|
|
|
|
assert(nCel > 0); |
|
|
|
|
|
|
|
|
|
pRLEBytes = CelGetFrameClipped(pCelBuff, nCel, &nDataSize); |
|
|
|
|
|
|
|
|
|
Cl2BlitSafe( |
|
|
|
|
&gpBuffer[sx + BUFFER_WIDTH * sy], |
|
|
|
|
pRLEBytes, |
|
|
|
|
nDataSize, |
|
|
|
|
nWidth); |
|
|
|
|
} |
|
|
|
|
/**
|
|
|
|
|
* @brief Blit a solid colder shape one pixel larger then the given sprite shape, to the back buffer at the given coordianates |
|
|
|
|
* @param col Color index from current palette |
|
|
|
|
* @param sx Back buffer coordinate |
|
|
|
|
* @param sy Back buffer coordinate |
|
|
|
|
* @param pCelBuff CL2 buffer |
|
|
|
|
* @param nCel CL2 frame number |
|
|
|
|
* @param nWidth Width of sprite |
|
|
|
|
*/ |
|
|
|
|
void Cl2DrawOutline(char col, int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth) |
|
|
|
|
{ |
|
|
|
|
int nDataSize; |
|
|
|
|
BYTE *pRLEBytes; |
|
|
|
|
|
|
|
|
|
assert(gpBuffer != NULL); |
|
|
|
|
assert(pCelBuff != NULL); |
|
|
|
|
assert(nCel > 0); |
|
|
|
|
|
|
|
|
|
pRLEBytes = CelGetFrameClipped(pCelBuff, nCel, &nDataSize); |
|
|
|
|
|
|
|
|
|
gpBufEnd -= BUFFER_WIDTH; |
|
|
|
|
Cl2BlitOutlineSafe( |
|
|
|
|
&gpBuffer[sx + BUFFER_WIDTH * sy], |
|
|
|
|
pRLEBytes, |
|
|
|
|
nDataSize, |
|
|
|
|
nWidth, |
|
|
|
|
col); |
|
|
|
|
gpBufEnd += BUFFER_WIDTH; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Blit CL2 sprite, and apply a given lighting, to the back buffer at the given coordianates |
|
|
|
|
* @param sx Back buffer coordinate |
|
|
|
|
* @param sy Back buffer coordinate |
|
|
|
|
* @param pCelBuff CL2 buffer |
|
|
|
|
* @param nCel CL2 frame number |
|
|
|
|
* @param nWidth Width of sprite |
|
|
|
|
* @param light Light shade to use |
|
|
|
|
*/ |
|
|
|
|
void Cl2DrawLightTbl(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, char light) |
|
|
|
|
{ |
|
|
|
|
int nDataSize, idx; |
|
|
|
|
BYTE *pRLEBytes, *pDecodeTo; |
|
|
|
|
|
|
|
|
|
assert(gpBuffer != NULL); |
|
|
|
|
assert(pCelBuff != NULL); |
|
|
|
|
assert(nCel > 0); |
|
|
|
|
|
|
|
|
|
pRLEBytes = CelGetFrameClipped(pCelBuff, nCel, &nDataSize); |
|
|
|
|
pDecodeTo = &gpBuffer[sx + BUFFER_WIDTH * sy]; |
|
|
|
|
|
|
|
|
|
idx = light4flag ? 1024 : 4096; |
|
|
|
|
if (light == 2) |
|
|
|
|
idx += 256; // gray colors
|
|
|
|
|
if (light >= 4) |
|
|
|
|
idx += (light - 1) << 8; |
|
|
|
|
|
|
|
|
|
Cl2BlitLightSafe( |
|
|
|
|
pDecodeTo, |
|
|
|
|
pRLEBytes, |
|
|
|
|
nDataSize, |
|
|
|
|
nWidth, |
|
|
|
|
&pLightTbl[idx]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Blit CL2 sprite, and apply lighting, to the back buffer at the given coordinates |
|
|
|
|
* @param sx Back buffer coordinate |
|
|
|
|
|