2007-05-30 21:56:52 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
2007-04-27 12:58:35 +00:00
|
|
|
*
|
2007-05-30 21:56:52 +00:00
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
2007-04-27 12:58:35 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* $URL$
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "cruise/cruise_main.h"
|
2007-09-10 13:17:20 +00:00
|
|
|
#include "cruise/polys.h"
|
|
|
|
#include "common/util.h"
|
2007-04-27 12:58:35 +00:00
|
|
|
|
|
|
|
namespace Cruise {
|
|
|
|
|
|
|
|
int currentTransparent;
|
|
|
|
|
2007-04-28 22:31:55 +00:00
|
|
|
struct autoCellStruct {
|
|
|
|
struct autoCellStruct *next;
|
|
|
|
short int ovlIdx;
|
|
|
|
short int objIdx;
|
|
|
|
short int type;
|
|
|
|
short int newValue;
|
|
|
|
cellStruct *pCell;
|
2007-04-27 12:58:35 +00:00
|
|
|
};
|
|
|
|
|
2007-04-28 22:31:55 +00:00
|
|
|
autoCellStruct autoCellHead;
|
2007-04-27 12:58:35 +00:00
|
|
|
|
2007-04-28 22:31:55 +00:00
|
|
|
void addAutoCell(int overlayIdx, int idx, int type, int newVal, cellStruct *pObject) {
|
|
|
|
autoCellStruct *pNewEntry;
|
|
|
|
|
|
|
|
pNewEntry = new autoCellStruct;
|
|
|
|
|
|
|
|
pNewEntry->next = autoCellHead.next;
|
|
|
|
autoCellHead.next = pNewEntry;
|
|
|
|
|
|
|
|
pNewEntry->ovlIdx = overlayIdx;
|
|
|
|
pNewEntry->objIdx = idx;
|
|
|
|
pNewEntry->type = type;
|
|
|
|
pNewEntry->newValue = newVal;
|
|
|
|
pNewEntry->pCell = pObject;
|
|
|
|
}
|
|
|
|
|
|
|
|
void freeAutoCell(void) {
|
|
|
|
autoCellStruct *pCurrent = autoCellHead.next;
|
2007-04-27 12:58:35 +00:00
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
while (pCurrent) {
|
2007-04-28 22:31:55 +00:00
|
|
|
autoCellStruct *next = pCurrent->next;
|
2007-04-27 12:58:35 +00:00
|
|
|
|
2007-04-28 22:31:55 +00:00
|
|
|
if (pCurrent->type == 5) {
|
|
|
|
objInit(pCurrent->ovlIdx, pCurrent->objIdx, pCurrent->newValue);
|
2007-04-27 22:33:45 +00:00
|
|
|
} else {
|
2007-04-28 22:31:55 +00:00
|
|
|
setObjectPosition(pCurrent->ovlIdx, pCurrent->objIdx, pCurrent->type, pCurrent->newValue);
|
2007-04-27 12:58:35 +00:00
|
|
|
}
|
|
|
|
|
2007-04-28 22:31:55 +00:00
|
|
|
if (pCurrent->pCell->animWait < 0) {
|
2007-04-27 12:58:35 +00:00
|
|
|
objectParamsQuery params;
|
|
|
|
|
2007-04-28 22:31:55 +00:00
|
|
|
getMultipleObjectParam(pCurrent->ovlIdx, pCurrent->objIdx, ¶ms);
|
2007-04-27 12:58:35 +00:00
|
|
|
|
2007-04-28 22:31:55 +00:00
|
|
|
pCurrent->pCell->animCounter = params.var6 - 1;
|
2007-04-27 12:58:35 +00:00
|
|
|
}
|
|
|
|
|
2007-04-28 22:31:55 +00:00
|
|
|
delete pCurrent;
|
2007-04-27 12:58:35 +00:00
|
|
|
|
|
|
|
pCurrent = next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
void flipScreen(void) {
|
|
|
|
uint8 *swapPtr;
|
2007-04-27 12:58:35 +00:00
|
|
|
|
|
|
|
swapPtr = gfxModuleData.pPage00;
|
|
|
|
gfxModuleData.pPage00 = gfxModuleData.pPage10;
|
|
|
|
gfxModuleData.pPage10 = swapPtr;
|
|
|
|
|
|
|
|
gfxModuleData_flipScreen();
|
|
|
|
|
|
|
|
/*memcpy(globalAtariScreen, gfxModuleData.pPage00, 16000);
|
2007-04-27 22:33:45 +00:00
|
|
|
* convertAtariToRaw(gfxModuleData.pPage00,globalScreen,200,320); */
|
2007-04-27 12:58:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int spriteX1;
|
|
|
|
int spriteX2;
|
|
|
|
int spriteY1;
|
|
|
|
int spriteY2;
|
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
char *polyOutputBuffer;
|
2007-04-27 12:58:35 +00:00
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
void pixel(int x, int y, char color) {
|
|
|
|
if (x >= 0 && x < 320 && y >= 0 && y < 200)
|
|
|
|
polyOutputBuffer[320 * y + x] = color;
|
2007-04-27 12:58:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// this function checks if the dataPtr is not 0, else it retrives the data for X, Y, scale and DataPtr again (OLD: mainDrawSub1Sub1)
|
2007-11-01 11:22:11 +00:00
|
|
|
void flipPoly(int fileId, int16 *dataPtr, int scale, char** newFrame, int X, int Y, int *outX, int *outY, int *outScale)
|
|
|
|
{
|
|
|
|
if (*dataPtr == 0)
|
|
|
|
{
|
|
|
|
int16 offset;
|
|
|
|
int16 newX;
|
|
|
|
int16 newY;
|
|
|
|
|
|
|
|
dataPtr ++;
|
2007-04-27 12:58:35 +00:00
|
|
|
|
2007-11-01 11:22:11 +00:00
|
|
|
offset = *(dataPtr++);
|
|
|
|
flipShort(&offset);
|
2007-04-27 12:58:35 +00:00
|
|
|
|
2007-11-01 11:22:11 +00:00
|
|
|
newX = *(dataPtr++);
|
|
|
|
flipShort(&newX);
|
|
|
|
|
|
|
|
newY = *(dataPtr++);
|
2007-04-27 12:58:35 +00:00
|
|
|
flipShort(&newY);
|
|
|
|
|
2007-11-01 11:22:11 +00:00
|
|
|
offset += fileId;
|
2007-04-27 12:58:35 +00:00
|
|
|
|
2007-11-01 11:22:11 +00:00
|
|
|
if (offset >= 0 )
|
|
|
|
{
|
|
|
|
if (filesDatabase[offset].resType == 0 && filesDatabase[offset].subData.ptr)
|
|
|
|
{
|
|
|
|
dataPtr = (int16 *)filesDatabase[offset].subData.ptr;
|
2007-04-27 12:58:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
scale = -scale;
|
2007-04-27 22:33:45 +00:00
|
|
|
X -= newX;
|
|
|
|
Y -= newY;
|
2007-04-27 12:58:35 +00:00
|
|
|
}
|
|
|
|
|
2007-11-01 11:22:11 +00:00
|
|
|
*newFrame = (char*)dataPtr;
|
2007-04-27 22:33:45 +00:00
|
|
|
*outX = X;
|
|
|
|
*outY = Y;
|
|
|
|
*outScale = scale;
|
2007-04-27 12:58:35 +00:00
|
|
|
}
|
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
int upscaleValue(int value, int scale) {
|
2007-04-27 12:58:35 +00:00
|
|
|
return (((value * scale) << 8) / 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
int m_flipLeftRight;
|
|
|
|
int m_useSmallScale;
|
|
|
|
int m_lowerX;
|
|
|
|
int m_lowerY;
|
|
|
|
int m_coordCount;
|
|
|
|
int m_first_X;
|
|
|
|
int m_first_Y;
|
|
|
|
int m_scaleValue;
|
|
|
|
int m_color;
|
|
|
|
|
2007-11-01 11:22:11 +00:00
|
|
|
int16 DIST_3D[512];
|
2007-04-27 12:58:35 +00:00
|
|
|
int16 polyBuffer2[512];
|
2007-11-01 11:22:11 +00:00
|
|
|
int16 XMIN_XMAX[404];
|
2007-04-27 12:58:35 +00:00
|
|
|
int16 polyBuffer4[512];
|
|
|
|
|
|
|
|
// this function fills the sizeTable for the poly (OLD: mainDrawSub1Sub2)
|
2007-11-01 11:22:11 +00:00
|
|
|
void getPolySize(int positionX, int positionY, int scale, int sizeTable[4], unsigned char *dataPtr)
|
|
|
|
{
|
2007-04-27 12:58:35 +00:00
|
|
|
int upperBorder;
|
|
|
|
int lowerBorder;
|
|
|
|
m_flipLeftRight = 0;
|
|
|
|
|
2007-09-10 13:17:20 +00:00
|
|
|
if (scale < 0) { // flip left right
|
2007-04-27 12:58:35 +00:00
|
|
|
m_flipLeftRight = 1;
|
2007-04-27 22:33:45 +00:00
|
|
|
scale = -scale;
|
2007-04-27 12:58:35 +00:00
|
|
|
}
|
|
|
|
// X1
|
|
|
|
|
|
|
|
upperBorder = *(dataPtr + 3);
|
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
if (m_flipLeftRight) {
|
2007-04-27 12:58:35 +00:00
|
|
|
upperBorder = -upperBorder;
|
|
|
|
}
|
2007-04-27 22:33:45 +00:00
|
|
|
|
|
|
|
upperBorder = (upscaleValue(upperBorder, scale) + 0x8000) >> 16;
|
|
|
|
upperBorder = -upperBorder;
|
|
|
|
lowerBorder = upperBorder;
|
2007-04-27 12:58:35 +00:00
|
|
|
|
|
|
|
// X2
|
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
upperBorder = *(dataPtr + 1);
|
2007-04-27 12:58:35 +00:00
|
|
|
upperBorder -= *(dataPtr + 3);
|
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
if (m_flipLeftRight) {
|
2007-04-27 12:58:35 +00:00
|
|
|
upperBorder = -upperBorder;
|
|
|
|
}
|
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
upperBorder = (upscaleValue(upperBorder, scale) + 0x8000) >> 16;
|
2007-04-27 12:58:35 +00:00
|
|
|
|
2007-09-10 13:17:20 +00:00
|
|
|
if (upperBorder < lowerBorder) { // exchange borders if lower > upper
|
|
|
|
SWAP(upperBorder, lowerBorder);
|
2007-04-27 12:58:35 +00:00
|
|
|
}
|
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
sizeTable[0] = lowerBorder; // left
|
|
|
|
sizeTable[1] = upperBorder; // right
|
2007-04-27 12:58:35 +00:00
|
|
|
|
|
|
|
// Y1
|
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
upperBorder = *(dataPtr + 4);
|
|
|
|
upperBorder = (upscaleValue(upperBorder, scale) + 0x8000) >> 16;
|
|
|
|
upperBorder = -upperBorder;
|
|
|
|
lowerBorder = upperBorder;
|
2007-04-27 12:58:35 +00:00
|
|
|
|
|
|
|
// Y2
|
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
upperBorder = *(dataPtr + 2);
|
2007-04-27 12:58:35 +00:00
|
|
|
upperBorder -= *(dataPtr + 4);
|
2007-04-27 22:33:45 +00:00
|
|
|
upperBorder = (upscaleValue(upperBorder, scale) + 0x8000) >> 16;
|
2007-04-27 12:58:35 +00:00
|
|
|
|
2007-09-10 13:17:20 +00:00
|
|
|
if (upperBorder < lowerBorder) { // exchange borders if lower > upper
|
|
|
|
SWAP(upperBorder, lowerBorder);
|
2007-04-27 12:58:35 +00:00
|
|
|
}
|
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
sizeTable[2] = lowerBorder; // bottom
|
|
|
|
sizeTable[3] = upperBorder; // top
|
2007-04-27 12:58:35 +00:00
|
|
|
}
|
|
|
|
|
2007-11-03 12:30:02 +00:00
|
|
|
int nbseg;
|
|
|
|
int16 nbligne;
|
2007-11-01 11:22:11 +00:00
|
|
|
|
|
|
|
void blitPolyMode1(char *dest, char *ptr, int16 * buffer, char color)
|
|
|
|
{
|
|
|
|
ASSERT(0);
|
2007-04-27 12:58:35 +00:00
|
|
|
}
|
|
|
|
|
2007-11-01 11:22:11 +00:00
|
|
|
void blitPolyMode2(char *dest, int16 * buffer, char color)
|
|
|
|
{
|
2007-11-03 12:30:02 +00:00
|
|
|
int Y = XMIN_XMAX[0];
|
2007-11-01 11:22:11 +00:00
|
|
|
|
2007-11-03 12:30:02 +00:00
|
|
|
for(int i=0; i<nbligne; i++)
|
|
|
|
{
|
|
|
|
int currentY = Y+i;
|
|
|
|
int XMIN = XMIN_XMAX[1+i*2];
|
|
|
|
int XMAX = XMIN_XMAX[1+i*2+1];
|
|
|
|
|
|
|
|
if(XMAX > 0)
|
|
|
|
line(XMIN, currentY, XMAX, currentY, color);
|
|
|
|
}
|
|
|
|
/* int i;
|
|
|
|
|
|
|
|
for (i = 0; i < nbseg; i++) {
|
2007-11-01 11:22:11 +00:00
|
|
|
line(buffer[i * 2], buffer[i * 2 + 1], buffer[(i + 1) * 2], buffer[(i + 1) * 2 + 1], color);
|
|
|
|
}
|
|
|
|
|
2007-11-03 12:30:02 +00:00
|
|
|
fillpoly(buffer, nbseg, color); */
|
2007-04-27 12:58:35 +00:00
|
|
|
}
|
|
|
|
|
2007-11-03 12:30:02 +00:00
|
|
|
int polyXMin;
|
|
|
|
int polyXMax;
|
|
|
|
int polyYMax;
|
|
|
|
int polyYMin;
|
|
|
|
|
|
|
|
int16 *A2ptr;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void buildSegment(void)
|
|
|
|
{
|
|
|
|
int16* pOut = XMIN_XMAX;
|
|
|
|
|
|
|
|
if((polyXMin >= 320) || (polyXMax < 0) || (polyYMax < 0) || (polyYMin >= 200))
|
|
|
|
{
|
|
|
|
XMIN_XMAX[0] = -1;
|
|
|
|
nbligne = -1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(polyYMin == polyYMax) // line
|
|
|
|
{
|
|
|
|
*(pOut++) = polyYMin; // store initial Y
|
|
|
|
|
|
|
|
int cx = nbseg-1;
|
|
|
|
int16* pIn = A2ptr;
|
|
|
|
|
|
|
|
int XLeft;
|
|
|
|
int XRight;
|
|
|
|
|
|
|
|
XLeft = XRight = *pIn; // init to first X
|
|
|
|
pIn+=2;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
int X = *pIn;
|
|
|
|
if(XLeft > X)
|
|
|
|
XLeft = X;
|
|
|
|
if(XRight < X)
|
|
|
|
XRight = X;
|
|
|
|
pIn+=2;
|
|
|
|
}while(--cx);
|
|
|
|
|
|
|
|
// now store left and right coordinates in XMIN_XMAX
|
|
|
|
|
|
|
|
int XMin = XLeft;
|
|
|
|
int XMax = XRight;
|
|
|
|
|
|
|
|
if(XLeft < 0)
|
|
|
|
XMin = 0;
|
|
|
|
|
|
|
|
if(XRight >= 320)
|
|
|
|
XMax = 319;
|
|
|
|
|
|
|
|
*(pOut++) = XMin;
|
|
|
|
*(pOut++) = XMax;
|
|
|
|
*(pOut++) = -1;
|
|
|
|
|
|
|
|
nbligne = -1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// true polygon
|
|
|
|
|
|
|
|
int ydep;
|
2007-04-27 12:58:35 +00:00
|
|
|
|
2007-11-03 12:30:02 +00:00
|
|
|
if(polyYMin < 0)
|
|
|
|
ydep = 0;
|
|
|
|
else
|
|
|
|
ydep = polyYMin;
|
|
|
|
|
|
|
|
int yfin;
|
|
|
|
|
|
|
|
if(polyYMax > 199)
|
|
|
|
yfin = 199;
|
|
|
|
else
|
|
|
|
yfin = polyYMax;
|
|
|
|
|
|
|
|
nbligne = yfin - ydep + 1;
|
|
|
|
|
|
|
|
int16* ptrMini = XMIN_XMAX + 1;
|
|
|
|
XMIN_XMAX[0] = ydep;
|
|
|
|
|
|
|
|
int16* ptrMax = XMIN_XMAX + ((yfin - ydep) * 2) + 1;
|
|
|
|
ptrMax[2] = -1; // mark the end
|
|
|
|
|
|
|
|
// init table with default values
|
|
|
|
int16* si = XMIN_XMAX + 1;
|
|
|
|
int tempCount = nbligne;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
si[0] = 5000;
|
|
|
|
si[1] = -5000;
|
|
|
|
si+=2;
|
|
|
|
}while(--tempCount);
|
|
|
|
|
|
|
|
int16* di = A2ptr;
|
|
|
|
int segCount = nbseg;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
int X2 = di[2];
|
|
|
|
int X1 = di[0];
|
|
|
|
int Y2 = di[3];
|
|
|
|
int Y1 = di[1];
|
|
|
|
|
|
|
|
|
|
|
|
int tempAX = Y1;
|
|
|
|
int tempDX = Y2;
|
|
|
|
if(tempAX > tempDX)
|
|
|
|
{
|
|
|
|
// swap
|
|
|
|
tempAX = Y2;
|
|
|
|
tempDX = Y1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// is segment on screen ?
|
|
|
|
if(!((tempAX > 199) || (tempDX < 0)))
|
|
|
|
{
|
|
|
|
int dx = Y1;
|
|
|
|
int cx = X2 - X1;
|
|
|
|
if(cx == 0)
|
|
|
|
{
|
|
|
|
// vertical line
|
|
|
|
int CX = X2;
|
|
|
|
if(CX < 0)
|
|
|
|
CX = 0;
|
|
|
|
|
|
|
|
int DX = X2;
|
|
|
|
if(DX > 319)
|
|
|
|
DX = 319;
|
|
|
|
|
|
|
|
int16* BX = XMIN_XMAX + (Y2 - ydep) * 2 +1;
|
|
|
|
int16* DI = XMIN_XMAX + (Y1 - ydep) * 2 +1;
|
|
|
|
|
|
|
|
if(Y2 >= Y1)
|
|
|
|
{
|
|
|
|
int16* temp;
|
|
|
|
|
|
|
|
temp=BX;
|
|
|
|
BX = DI;
|
|
|
|
DI = temp;
|
|
|
|
}
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if((BX < ptrMax) && (BX > ptrMini)) // are we in screen ?
|
|
|
|
{
|
|
|
|
if(CX < BX[0])
|
|
|
|
BX[0] = CX;
|
|
|
|
|
|
|
|
if(DX > BX[1])
|
|
|
|
BX[1] = DX;
|
|
|
|
}
|
|
|
|
|
|
|
|
BX+=2;
|
|
|
|
}while(BX <= DI);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( cx < 0 )
|
|
|
|
{
|
|
|
|
cx = -cx;
|
|
|
|
dx = Y2;
|
|
|
|
|
|
|
|
int temp;
|
|
|
|
temp = X1;
|
|
|
|
X1 = X2;
|
|
|
|
X2 = temp;
|
|
|
|
|
|
|
|
temp = Y1;
|
|
|
|
Y1 = Y2;
|
|
|
|
Y2 = temp;
|
|
|
|
}
|
|
|
|
// swap again ?
|
|
|
|
int temp;
|
|
|
|
temp = X1;
|
|
|
|
X1 = X2;
|
|
|
|
X2 = temp;
|
|
|
|
|
|
|
|
int patchAdd = 2;
|
|
|
|
|
|
|
|
int dy = Y2 - Y1;
|
|
|
|
|
|
|
|
if( dy == 0 )
|
|
|
|
{
|
|
|
|
// hline
|
|
|
|
int16* ptr = (Y1 - ydep) * 2 + XMIN_XMAX + 1;
|
|
|
|
|
|
|
|
if((ptr <= ptrMax) && (ptr >= ptrMini)) // are we in screen ?
|
|
|
|
{
|
|
|
|
int CX = X1;
|
|
|
|
if(CX < 0)
|
|
|
|
CX = 0;
|
|
|
|
|
|
|
|
int SI = X2;
|
|
|
|
if(SI > 319)
|
|
|
|
SI = 319;
|
|
|
|
|
|
|
|
if(CX < ptr[0])
|
|
|
|
ptr[0] = CX;
|
|
|
|
|
|
|
|
if(SI > ptr[1])
|
|
|
|
ptr[1] = SI;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( dy < 0 )
|
|
|
|
{
|
|
|
|
dy = -dy;
|
|
|
|
patchAdd = -2;
|
|
|
|
}
|
|
|
|
|
|
|
|
int stepType = 0; // small DY <= DX
|
|
|
|
|
|
|
|
if(dy > cx)
|
|
|
|
{
|
|
|
|
stepType = 1; // DX < DY
|
|
|
|
|
|
|
|
int temp;
|
|
|
|
temp = dy;
|
|
|
|
dy = cx;
|
|
|
|
cx = dy;
|
|
|
|
}
|
|
|
|
int patchinc1 = 2*dy;
|
|
|
|
|
|
|
|
int d = 2 * dy - cx;
|
|
|
|
int bx = 2 * (dy - cx);
|
|
|
|
|
|
|
|
int patchinc2 = bx;
|
|
|
|
|
|
|
|
cx++; // cx is the number of pixels to trace
|
|
|
|
|
|
|
|
int16* ptr = (Y1 - ydep)*2 + XMIN_XMAX + 1;
|
|
|
|
|
|
|
|
if(stepType == 0)
|
|
|
|
{
|
|
|
|
// small step
|
|
|
|
int BP = X2;
|
|
|
|
|
|
|
|
int SI = BP;
|
|
|
|
if(SI < 0)
|
|
|
|
SI = 0;
|
|
|
|
int DX = BP;
|
|
|
|
if(DX > 319)
|
|
|
|
DX = 319;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if((ptr <= ptrMax) && (ptr >= ptrMini)) // are we in screen ?
|
|
|
|
{
|
|
|
|
if(SI < ptr[0])
|
|
|
|
ptr[0] = SI;
|
|
|
|
|
|
|
|
if(DX > ptr[1])
|
|
|
|
ptr[1] = DX;
|
|
|
|
}
|
|
|
|
|
|
|
|
BP ++;
|
|
|
|
|
|
|
|
// test limits
|
|
|
|
SI = BP;
|
|
|
|
if(SI < 0)
|
|
|
|
SI = 0;
|
|
|
|
DX = BP;
|
|
|
|
if(DX > 319)
|
|
|
|
DX = 319;
|
|
|
|
|
|
|
|
if(d < 0)
|
|
|
|
{
|
|
|
|
d += patchinc1;
|
|
|
|
if( cx == 1 ) // last ?
|
|
|
|
{
|
|
|
|
if((ptr <= ptrMax) && (ptr >= ptrMini)) // are we in screen ?
|
|
|
|
{
|
|
|
|
if(SI < ptr[0])
|
|
|
|
ptr[0] = SI;
|
|
|
|
|
|
|
|
if(DX > ptr[1])
|
|
|
|
ptr[1] = DX;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
d += patchinc2;
|
|
|
|
ptr+=patchAdd;
|
|
|
|
}
|
|
|
|
}while(--cx);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// big step
|
|
|
|
int BP = X2;
|
|
|
|
|
|
|
|
int SI = BP;
|
|
|
|
if(SI < 0)
|
|
|
|
SI = 0;
|
|
|
|
int DX = BP;
|
|
|
|
if(DX > 319)
|
|
|
|
DX = 319;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if((ptr <= ptrMax) && (ptr >= ptrMini)) // are we in screen ?
|
|
|
|
{
|
|
|
|
if(SI < ptr[0])
|
|
|
|
ptr[0] = SI;
|
|
|
|
|
|
|
|
if(DX > ptr[1])
|
|
|
|
ptr[1] = DX;
|
|
|
|
}
|
|
|
|
|
|
|
|
ptr += patchAdd; // next line
|
|
|
|
|
|
|
|
if(d < 0)
|
|
|
|
{
|
|
|
|
d += patchinc1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
d += patchinc2;
|
|
|
|
BP ++;
|
|
|
|
|
|
|
|
// test limits
|
|
|
|
SI = BP;
|
|
|
|
if(SI < 0)
|
|
|
|
SI = 0;
|
|
|
|
DX = BP;
|
|
|
|
if(DX > 319)
|
|
|
|
DX = 319;
|
|
|
|
}
|
|
|
|
}while(--cx);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
di+=2;
|
|
|
|
}while(--segCount);
|
|
|
|
}
|
2007-04-27 12:58:35 +00:00
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
char *drawPolyMode1(char *dataPointer, int linesToDraw) {
|
2007-04-27 12:58:35 +00:00
|
|
|
int index;
|
2007-04-27 22:33:45 +00:00
|
|
|
int16 *pBufferDest;
|
2007-04-27 12:58:35 +00:00
|
|
|
|
2007-11-03 12:30:02 +00:00
|
|
|
nbseg = linesToDraw;
|
|
|
|
pBufferDest = &polyBuffer4[nbseg * 2];
|
2007-04-27 22:33:45 +00:00
|
|
|
index = *(dataPointer++);
|
2007-04-27 12:58:35 +00:00
|
|
|
|
2007-11-03 12:30:02 +00:00
|
|
|
polyXMin = polyXMax = pBufferDest[-2] = pBufferDest[-2 + linesToDraw * 2] = polyBuffer2[index * 2];
|
|
|
|
polyYMin = polyYMax = pBufferDest[-1] = pBufferDest[-1 + linesToDraw * 2] = polyBuffer2[(index * 2) + 1];
|
2007-04-27 12:58:35 +00:00
|
|
|
|
|
|
|
linesToDraw--;
|
|
|
|
|
|
|
|
pBufferDest -= 2;
|
|
|
|
|
2007-11-03 12:30:02 +00:00
|
|
|
A2ptr = pBufferDest;
|
2007-04-27 12:58:35 +00:00
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
do {
|
2007-04-27 12:58:35 +00:00
|
|
|
index = *(dataPointer++);
|
2007-11-03 12:30:02 +00:00
|
|
|
int X = polyBuffer2[index * 2];
|
|
|
|
|
|
|
|
pBufferDest[-2] = pBufferDest[-2 + nbseg * 2] = X;
|
2007-04-27 22:33:45 +00:00
|
|
|
|
2007-11-03 12:30:02 +00:00
|
|
|
if (X < polyXMin) {
|
|
|
|
polyXMin = X;
|
2007-04-27 12:58:35 +00:00
|
|
|
}
|
2007-11-03 12:30:02 +00:00
|
|
|
if (X > polyXMax) {
|
|
|
|
polyXMax = X;
|
2007-04-27 12:58:35 +00:00
|
|
|
}
|
|
|
|
|
2007-11-03 12:30:02 +00:00
|
|
|
int Y = polyBuffer2[(index * 2) + 1];
|
2007-04-27 22:33:45 +00:00
|
|
|
|
2007-11-03 12:30:02 +00:00
|
|
|
pBufferDest[-1] = pBufferDest[-1 + nbseg * 2] = Y;
|
|
|
|
|
|
|
|
if (Y < polyYMin) {
|
|
|
|
polyYMin = Y;
|
2007-04-27 12:58:35 +00:00
|
|
|
}
|
2007-11-03 12:30:02 +00:00
|
|
|
if (Y > polyYMax) {
|
|
|
|
polyYMax = Y;
|
|
|
|
A2ptr = pBufferDest - 4;
|
2007-04-27 12:58:35 +00:00
|
|
|
}
|
|
|
|
pBufferDest -= 2;
|
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
} while (--linesToDraw);
|
2007-04-27 12:58:35 +00:00
|
|
|
|
2007-11-03 12:30:02 +00:00
|
|
|
buildSegment();
|
|
|
|
|
2007-04-27 12:58:35 +00:00
|
|
|
return dataPointer;
|
|
|
|
}
|
|
|
|
|
2007-11-01 11:22:11 +00:00
|
|
|
char *drawPolyMode2(char *dataPointer, int linesToDraw)
|
|
|
|
{
|
2007-04-27 12:58:35 +00:00
|
|
|
int index;
|
2007-04-27 22:33:45 +00:00
|
|
|
int16 *pBufferDest;
|
2007-04-27 12:58:35 +00:00
|
|
|
|
|
|
|
pBufferDest = polyBuffer4;
|
2007-11-03 12:30:02 +00:00
|
|
|
nbseg = linesToDraw;
|
|
|
|
A2ptr = polyBuffer4;
|
2007-04-27 22:33:45 +00:00
|
|
|
index = *(dataPointer++);
|
2007-04-27 12:58:35 +00:00
|
|
|
|
2007-11-03 12:30:02 +00:00
|
|
|
polyXMin = polyXMax = pBufferDest[0] = pBufferDest[linesToDraw * 2] = polyBuffer2[index * 2];
|
|
|
|
polyYMin = polyYMax = pBufferDest[1] = pBufferDest[linesToDraw * 2 + 1] = polyBuffer2[(index * 2) + 1];
|
2007-04-27 12:58:35 +00:00
|
|
|
|
|
|
|
linesToDraw--;
|
|
|
|
|
|
|
|
pBufferDest += 2;
|
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
do {
|
2007-04-27 12:58:35 +00:00
|
|
|
int value;
|
|
|
|
|
|
|
|
index = *(dataPointer++);
|
2007-11-03 12:30:02 +00:00
|
|
|
value = pBufferDest[0] = pBufferDest[nbseg * 2] = polyBuffer2[index * 2];
|
2007-04-27 22:33:45 +00:00
|
|
|
|
2007-11-03 12:30:02 +00:00
|
|
|
if (value < polyXMin) {
|
|
|
|
polyXMin = value;
|
2007-04-27 12:58:35 +00:00
|
|
|
}
|
2007-11-03 12:30:02 +00:00
|
|
|
if (value > polyXMax) {
|
|
|
|
polyXMax = value;
|
2007-04-27 12:58:35 +00:00
|
|
|
}
|
|
|
|
|
2007-11-03 12:30:02 +00:00
|
|
|
value = pBufferDest[1] = pBufferDest[nbseg * 2 + 1] = polyBuffer2[(index * 2) + 1];
|
2007-04-27 12:58:35 +00:00
|
|
|
|
2007-11-03 12:30:02 +00:00
|
|
|
if (value < polyYMin) {
|
|
|
|
polyYMin = value;
|
2007-04-27 12:58:35 +00:00
|
|
|
}
|
2007-11-03 12:30:02 +00:00
|
|
|
if (value > polyYMax) {
|
|
|
|
polyYMax = value;
|
|
|
|
A2ptr = pBufferDest;
|
2007-04-27 12:58:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pBufferDest += 2;
|
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
} while (--linesToDraw);
|
2007-04-27 12:58:35 +00:00
|
|
|
|
2007-11-03 12:30:02 +00:00
|
|
|
buildSegment();
|
|
|
|
|
2007-04-27 12:58:35 +00:00
|
|
|
return dataPointer;
|
|
|
|
}
|
|
|
|
|
|
|
|
// this function builds the poly model and then calls the draw functions (OLD: mainDrawSub1Sub5)
|
2007-11-01 11:22:11 +00:00
|
|
|
void buildPolyModel(int positionX, int positionY, int scale, char *pMask, char *destBuffer, char *dataPtr) {
|
2007-04-27 22:33:45 +00:00
|
|
|
int counter = 0; // numbers of coordinates to process
|
|
|
|
int startX = 0; // first X in model
|
|
|
|
int startY = 0; // first Y in model
|
|
|
|
int x = 0; // current X
|
|
|
|
int y = 0; // current Y
|
|
|
|
int offsetXinModel = 0; // offset of the X value in the model
|
|
|
|
int offsetYinModel = 0; // offset of the Y value in the model
|
|
|
|
unsigned char *dataPointer = (unsigned char *)dataPtr;
|
2007-11-01 11:22:11 +00:00
|
|
|
int16 *ptrPoly_1_Buf = DIST_3D;
|
2007-04-27 22:33:45 +00:00
|
|
|
int16 *ptrPoly_2_Buf;
|
|
|
|
polyOutputBuffer = destBuffer; // global
|
2007-04-27 12:58:35 +00:00
|
|
|
|
|
|
|
m_flipLeftRight = 0;
|
|
|
|
m_useSmallScale = 0;
|
2007-04-27 22:33:45 +00:00
|
|
|
m_lowerX = *(dataPointer + 3);
|
|
|
|
m_lowerY = *(dataPointer + 4);
|
2007-04-27 12:58:35 +00:00
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
if (scale < 0) {
|
|
|
|
scale = -scale; // flip left right
|
2007-04-27 12:58:35 +00:00
|
|
|
m_flipLeftRight = 1;
|
|
|
|
}
|
|
|
|
|
2007-09-10 13:17:20 +00:00
|
|
|
if (scale < 0x180) { // If scale is smaller than 384
|
2007-04-27 12:58:35 +00:00
|
|
|
m_useSmallScale = 1;
|
2007-04-27 22:33:45 +00:00
|
|
|
m_scaleValue = scale << 1; // double scale
|
|
|
|
} else {
|
2007-04-27 12:58:35 +00:00
|
|
|
m_scaleValue = scale;
|
|
|
|
}
|
|
|
|
|
|
|
|
dataPointer += 5;
|
|
|
|
|
|
|
|
m_coordCount = (*(dataPointer++)) + 1; // original uses +1 here but its later substracted again, we could skip it
|
2007-04-27 22:33:45 +00:00
|
|
|
m_first_X = *(dataPointer++);
|
|
|
|
m_first_Y = *(dataPointer++);
|
|
|
|
startX = m_lowerX - m_first_X;
|
|
|
|
startY = m_lowerY - m_first_Y;
|
2007-04-27 12:58:35 +00:00
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
if (m_useSmallScale) {
|
2007-04-27 12:58:35 +00:00
|
|
|
startX >>= 1;
|
|
|
|
startY >>= 1;
|
|
|
|
}
|
2007-04-27 22:33:45 +00:00
|
|
|
|
|
|
|
if (m_flipLeftRight) {
|
2007-04-27 12:58:35 +00:00
|
|
|
startX = -startX;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2007-04-27 22:33:45 +00:00
|
|
|
* NOTE:
|
|
|
|
*
|
|
|
|
* The original code continues here with using X, Y instead of startX and StartY.
|
|
|
|
*
|
|
|
|
* Original code:
|
|
|
|
* positionX -= (upscaleValue(startX, m_scaleValue) + 0x8000) >> 16;
|
|
|
|
* positionY -= (upscaleValue(startX, m_scaleValue) + 0x8000) >> 16;
|
|
|
|
*/
|
|
|
|
|
2007-04-27 12:58:35 +00:00
|
|
|
// get coordinates from data
|
|
|
|
|
2007-11-01 11:22:11 +00:00
|
|
|
startX = positionX - ((upscaleValue(startX, m_scaleValue) + 0x8000) >> 16);
|
|
|
|
startY = positionY - ((upscaleValue(startY, m_scaleValue) + 0x8000) >> 16);
|
2007-04-27 22:33:45 +00:00
|
|
|
|
2007-04-27 12:58:35 +00:00
|
|
|
ptrPoly_1_Buf[0] = 0;
|
|
|
|
ptrPoly_1_Buf[1] = 0;
|
2007-04-27 22:33:45 +00:00
|
|
|
ptrPoly_1_Buf += 2;
|
|
|
|
counter = m_coordCount - 1 - 1; // skip the first pair, we already have the values
|
2007-04-27 12:58:35 +00:00
|
|
|
|
2007-11-01 11:22:11 +00:00
|
|
|
// dpbcl0
|
2007-04-27 22:33:45 +00:00
|
|
|
do {
|
2007-04-27 12:58:35 +00:00
|
|
|
x = *(dataPointer++) - m_first_X;
|
2007-09-10 13:17:20 +00:00
|
|
|
if (m_useSmallScale) { // shrink all coordinates by factor 2 if a scale smaller than 384 is used
|
2007-04-27 12:58:35 +00:00
|
|
|
x >>= 1;
|
|
|
|
}
|
|
|
|
ptrPoly_1_Buf[0] = offsetXinModel - x;
|
|
|
|
ptrPoly_1_Buf++;
|
|
|
|
offsetXinModel = x;
|
2007-04-27 22:33:45 +00:00
|
|
|
|
2007-11-01 11:22:11 +00:00
|
|
|
y = *(dataPointer++) - m_first_Y;
|
|
|
|
if (m_useSmallScale) {
|
|
|
|
y >>= 1;
|
|
|
|
}
|
2007-04-27 12:58:35 +00:00
|
|
|
ptrPoly_1_Buf[0] = -(offsetYinModel - y);
|
|
|
|
ptrPoly_1_Buf++;
|
|
|
|
offsetYinModel = y;
|
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
} while (--counter);
|
2007-04-27 12:58:35 +00:00
|
|
|
|
|
|
|
// scale and adjust coordinates with offset (using two polybuffers by doing that)
|
2007-11-01 11:22:11 +00:00
|
|
|
ptrPoly_2_Buf = DIST_3D;
|
2007-04-27 12:58:35 +00:00
|
|
|
ptrPoly_1_Buf = polyBuffer2;
|
2007-04-27 22:33:45 +00:00
|
|
|
counter = m_coordCount - 1; // reset counter // process first pair two
|
2007-11-01 11:22:11 +00:00
|
|
|
int m_current_X = 0;
|
|
|
|
int m_current_Y = 0;
|
2007-04-27 12:58:35 +00:00
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
do {
|
2007-04-27 12:58:35 +00:00
|
|
|
x = ptrPoly_2_Buf[0];
|
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
if (m_flipLeftRight == 0) {
|
|
|
|
x = -x;
|
|
|
|
}
|
2007-04-27 12:58:35 +00:00
|
|
|
//////////////////
|
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
m_current_X += upscaleValue(x, m_scaleValue);
|
|
|
|
ptrPoly_1_Buf[0] = ((m_current_X + 0x8000) >> 16) + startX; // adjust X value with start offset
|
|
|
|
|
|
|
|
m_current_Y += upscaleValue(ptrPoly_2_Buf[1], m_scaleValue);
|
|
|
|
ptrPoly_1_Buf[1] = ((m_current_Y + 0x8000) >> 16) + startY; // adjust Y value with start offset
|
2007-04-27 12:58:35 +00:00
|
|
|
|
|
|
|
/////////////////
|
|
|
|
|
|
|
|
ptrPoly_1_Buf += 2;
|
|
|
|
ptrPoly_2_Buf += 2;
|
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
} while (--counter);
|
2007-04-27 12:58:35 +00:00
|
|
|
|
|
|
|
// position of the dataPointer is m_coordCount * 2
|
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
do {
|
2007-04-27 12:58:35 +00:00
|
|
|
int linesToDraw = *dataPointer++;
|
|
|
|
|
2007-09-10 13:17:20 +00:00
|
|
|
if (linesToDraw > 1) { // if value not zero
|
2007-04-27 12:58:35 +00:00
|
|
|
uint16 minimumScale;
|
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
m_color = *dataPointer; // color
|
2007-04-27 12:58:35 +00:00
|
|
|
dataPointer += 2;
|
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
minimumScale = *(uint16 *) (dataPointer);
|
2007-04-27 12:58:35 +00:00
|
|
|
dataPointer += 2;
|
|
|
|
|
|
|
|
flipShort(&minimumScale);
|
|
|
|
|
2007-11-01 11:22:11 +00:00
|
|
|
if (minimumScale <= scale)
|
|
|
|
{
|
2007-04-27 22:33:45 +00:00
|
|
|
if (m_flipLeftRight) {
|
2007-11-01 11:22:11 +00:00
|
|
|
drawPolyMode1((char *)dataPointer, linesToDraw);
|
2007-04-27 22:33:45 +00:00
|
|
|
} else {
|
2007-11-01 11:22:11 +00:00
|
|
|
drawPolyMode2((char *)dataPointer, linesToDraw);
|
2007-04-27 12:58:35 +00:00
|
|
|
}
|
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
if (destBuffer) {
|
2007-11-01 11:22:11 +00:00
|
|
|
if (pMask) {
|
|
|
|
blitPolyMode1(destBuffer, pMask, polyBuffer4, m_color & 0xF);
|
2007-04-27 22:33:45 +00:00
|
|
|
} else {
|
2007-11-01 11:22:11 +00:00
|
|
|
blitPolyMode2(destBuffer, polyBuffer4, m_color & 0xF);
|
2007-04-27 12:58:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-11-01 11:22:11 +00:00
|
|
|
|
|
|
|
dataPointer += linesToDraw;
|
2007-04-27 22:33:45 +00:00
|
|
|
} else {
|
2007-04-27 12:58:35 +00:00
|
|
|
dataPointer += 4;
|
|
|
|
}
|
2007-04-27 22:33:45 +00:00
|
|
|
} while (*dataPointer != 0xFF);
|
2007-04-27 12:58:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// draw poly sprite (OLD: mainDrawSub1)
|
2007-11-01 11:22:11 +00:00
|
|
|
void mainDrawPolygons(int fileIndex, cellStruct *pObject, int X, int scale, int Y, char *destBuffer, char *dataPtr) {
|
2007-04-27 22:33:45 +00:00
|
|
|
int newX;
|
|
|
|
int newY;
|
|
|
|
int newScale;
|
2007-11-01 11:22:11 +00:00
|
|
|
char *newFrame;
|
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
int var_8; // unused
|
2007-04-27 12:58:35 +00:00
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
int sizeTable[4]; // 0 = left, 1 = right, 2 = bottom, 3 = top
|
2007-04-27 12:58:35 +00:00
|
|
|
|
|
|
|
// this function checks if the dataPtr is not 0, else it retrives the data for X, Y, scale and DataPtr again (OLD: mainDrawSub1Sub1)
|
2007-11-01 11:22:11 +00:00
|
|
|
flipPoly(fileIndex, (int16*)dataPtr, scale, &newFrame, X, Y, &newX, &newY, &newScale);
|
2007-04-27 22:33:45 +00:00
|
|
|
|
2007-04-27 12:58:35 +00:00
|
|
|
// this function fills the sizeTable for the poly (OLD: mainDrawSub1Sub2)
|
2007-11-01 11:22:11 +00:00
|
|
|
getPolySize(newX, newY, newScale, sizeTable, (unsigned char *)newFrame);
|
2007-04-27 12:58:35 +00:00
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
spriteX2 = sizeTable[0] - 2; // left border
|
2007-04-27 12:58:35 +00:00
|
|
|
spriteX1 = sizeTable[1] + 18; // right border
|
2007-04-27 22:33:45 +00:00
|
|
|
spriteY2 = sizeTable[2] - 2; // bottom border
|
|
|
|
spriteY1 = sizeTable[3] + 2; // top border
|
|
|
|
|
|
|
|
if (spriteX2 >= 320)
|
2007-04-27 12:58:35 +00:00
|
|
|
return;
|
2007-04-27 22:33:45 +00:00
|
|
|
if (spriteX1 < 0)
|
2007-04-27 12:58:35 +00:00
|
|
|
return;
|
2007-04-27 22:33:45 +00:00
|
|
|
if (spriteY2 >= 200)
|
2007-04-27 12:58:35 +00:00
|
|
|
return;
|
2007-04-27 22:33:45 +00:00
|
|
|
if (spriteY1 < 0)
|
2007-04-27 12:58:35 +00:00
|
|
|
return;
|
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
if (spriteX2 < 0) {
|
2007-04-27 12:58:35 +00:00
|
|
|
spriteX2 = 0;
|
|
|
|
}
|
2007-04-27 22:33:45 +00:00
|
|
|
if (spriteX1 > 320) {
|
2007-04-27 12:58:35 +00:00
|
|
|
spriteX1 = 320;
|
|
|
|
}
|
2007-04-27 22:33:45 +00:00
|
|
|
if (spriteY2 < 0) {
|
2007-04-27 12:58:35 +00:00
|
|
|
spriteY2 = 0;
|
|
|
|
}
|
2007-04-27 22:33:45 +00:00
|
|
|
if (spriteY1 > 200) {
|
2007-04-27 12:58:35 +00:00
|
|
|
spriteY1 = 200;
|
|
|
|
}
|
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
if (spriteX1 == spriteX2)
|
2007-04-27 12:58:35 +00:00
|
|
|
return;
|
2007-04-27 22:33:45 +00:00
|
|
|
if (spriteY1 == spriteY2)
|
2007-04-27 12:58:35 +00:00
|
|
|
return;
|
|
|
|
|
2007-11-01 11:22:11 +00:00
|
|
|
char *pMask = NULL;
|
2007-04-27 12:58:35 +00:00
|
|
|
var_8 = 0;
|
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
if (pObject) {
|
|
|
|
cellStruct *pCurrentObject = pObject;
|
2007-04-27 12:58:35 +00:00
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
do {
|
2007-10-28 17:40:04 +00:00
|
|
|
if (pCurrentObject->type == OBJ_TYPE_BGMK)
|
|
|
|
{
|
|
|
|
// ASSERT(0);
|
2007-04-27 12:58:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pCurrentObject = pCurrentObject->next;
|
2007-04-27 22:33:45 +00:00
|
|
|
} while (pCurrentObject);
|
2007-04-27 12:58:35 +00:00
|
|
|
}
|
2007-11-01 11:22:11 +00:00
|
|
|
|
2007-04-27 12:58:35 +00:00
|
|
|
// this function builds the poly model and then calls the draw functions (OLD: mainDrawSub1Sub5)
|
2007-11-01 11:22:11 +00:00
|
|
|
buildPolyModel(newX, newY, newScale, pMask, destBuffer, newFrame);
|
2007-04-27 12:58:35 +00:00
|
|
|
}
|
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
void mainSprite(int globalX, int globalY, gfxEntryStruct *pGfxPtr,
|
|
|
|
uint8 *ouputPtr, int newColor, int idx) {
|
2007-04-27 12:58:35 +00:00
|
|
|
// this is used for font only
|
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
if (pGfxPtr) {
|
|
|
|
uint8 *initialOuput;
|
|
|
|
uint8 *output;
|
2007-04-27 12:58:35 +00:00
|
|
|
int i;
|
|
|
|
int j;
|
|
|
|
int x;
|
|
|
|
int y;
|
2007-04-27 22:33:45 +00:00
|
|
|
uint8 *ptr = pGfxPtr->imagePtr;
|
2007-04-27 12:58:35 +00:00
|
|
|
int height = pGfxPtr->height;
|
2007-04-27 22:33:45 +00:00
|
|
|
int width = pGfxPtr->width;
|
2007-04-27 12:58:35 +00:00
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
if (globalY < 0) {
|
2007-04-27 12:58:35 +00:00
|
|
|
globalY = 0;
|
|
|
|
}
|
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
if (globalY + pGfxPtr->height >= 198) {
|
2007-04-27 12:58:35 +00:00
|
|
|
globalY = 198 - pGfxPtr->height;
|
|
|
|
}
|
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
initialOuput = ouputPtr + (globalY * 320) + globalX;
|
2007-04-27 12:58:35 +00:00
|
|
|
|
|
|
|
y = globalY;
|
|
|
|
x = globalX;
|
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
for (i = 0; i < height; i++) {
|
2007-04-27 12:58:35 +00:00
|
|
|
output = initialOuput + 320 * i;
|
2007-04-27 22:33:45 +00:00
|
|
|
|
|
|
|
for (j = 0; j < width; j++) {
|
2007-04-27 12:58:35 +00:00
|
|
|
uint8 color = *(ptr++);
|
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
if (color) {
|
|
|
|
if ((x >= 0) && (x < 320) && (y >= 0)
|
|
|
|
&& (y < 200)) {
|
|
|
|
if (color == 1) {
|
2007-04-27 12:58:35 +00:00
|
|
|
*output = (uint8) 0;
|
2007-04-27 22:33:45 +00:00
|
|
|
} else {
|
|
|
|
*output =
|
|
|
|
(uint8) newColor;
|
2007-04-27 12:58:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
output++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
void mainDrawSub4(int objX1, int var_6, cellStruct *currentObjPtr,
|
|
|
|
char *data1, int objY2, int objX2, char *output, char *data2) {
|
2007-04-27 12:58:35 +00:00
|
|
|
int x = 0;
|
|
|
|
int y = 0;
|
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
for (y = 0; y < var_6; y++) {
|
|
|
|
for (x = 0; x < (objX1 * 8); x++) {
|
2007-04-27 12:58:35 +00:00
|
|
|
uint8 color = (data1[0]);
|
|
|
|
data1++;
|
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
if ((x + objX2) >= 0 && (x + objX2) < 320
|
|
|
|
&& (y + objY2) >= 0 && (y + objY2) < 200) {
|
|
|
|
if (color != currentTransparent) {
|
|
|
|
output[320 * (y + objY2) + x + objX2] =
|
|
|
|
color;
|
2007-04-27 12:58:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef _DEBUG
|
2007-04-27 22:33:45 +00:00
|
|
|
void drawCtp(void) {
|
2007-04-27 12:58:35 +00:00
|
|
|
int i;
|
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
if (ctp_walkboxTable) {
|
|
|
|
for (i = 0; i < 15; i++) {
|
|
|
|
uint16 *dataPtr = &ctp_walkboxTable[i * 40];
|
|
|
|
int type = walkboxType[i]; // show different types in different colors
|
2007-04-27 12:58:35 +00:00
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
if (*dataPtr) {
|
2007-04-27 12:58:35 +00:00
|
|
|
int j;
|
2007-04-27 22:33:45 +00:00
|
|
|
fillpoly((short *)dataPtr + 1, *dataPtr, type);
|
2007-04-27 12:58:35 +00:00
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
for (j = 0; j < (*dataPtr - 1); j++) {
|
|
|
|
line(dataPtr[1 + j * 2],
|
|
|
|
dataPtr[1 + j * 2 + 1],
|
|
|
|
dataPtr[1 + (j + 1) * 2],
|
|
|
|
dataPtr[1 + (j + 1) * 2 + 1], 0);
|
2007-04-27 12:58:35 +00:00
|
|
|
}
|
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
line(dataPtr[1 + j * 2],
|
|
|
|
dataPtr[1 + j * 2 + 1], dataPtr[1],
|
|
|
|
dataPtr[2], 0);
|
2007-04-27 12:58:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
void drawMenu(menuStruct *pMenu) {
|
|
|
|
if (pMenu && pMenu->numElements) {
|
2007-04-27 12:58:35 +00:00
|
|
|
int height;
|
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
int var_10;
|
|
|
|
int bx;
|
|
|
|
int newX;
|
|
|
|
int var_6;
|
|
|
|
int currentY;
|
|
|
|
int var_8;
|
|
|
|
int di;
|
2007-04-27 22:33:45 +00:00
|
|
|
menuElementStruct *si;
|
2007-04-27 12:58:35 +00:00
|
|
|
|
|
|
|
height = pMenu->gfx->height;
|
2007-04-27 22:33:45 +00:00
|
|
|
x = pMenu->x;
|
|
|
|
y = pMenu->y;
|
2007-04-27 12:58:35 +00:00
|
|
|
|
|
|
|
var_10 = pMenu->gfx->width / (199 - (pMenu->gfx->width * 2));
|
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
bx = var_10 / (pMenu->numElements + 1); // rustine...
|
2007-04-27 12:58:35 +00:00
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
if (!bx) {
|
2007-04-27 12:58:35 +00:00
|
|
|
bx++;
|
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
if ((pMenu->numElements * height) + y > 199 - height) {
|
2007-04-27 12:58:35 +00:00
|
|
|
y = ((-1 - pMenu->numElements) * height) + 200;
|
|
|
|
}
|
2007-04-27 22:33:45 +00:00
|
|
|
} else {
|
|
|
|
if (var_10 % pMenu->numElements) {
|
2007-04-27 12:58:35 +00:00
|
|
|
bx++;
|
|
|
|
}
|
|
|
|
|
|
|
|
y = height;
|
|
|
|
}
|
|
|
|
|
|
|
|
newX = 320 * (2 - bx);
|
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
if (newX < x) {
|
2007-04-27 12:58:35 +00:00
|
|
|
x = newX;
|
|
|
|
}
|
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
if (x < 0) {
|
2007-04-27 12:58:35 +00:00
|
|
|
x = 0;
|
|
|
|
}
|
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
var_6 = (80 * (bx - 1)) + x;
|
2007-04-27 12:58:35 +00:00
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
if (var_6 <= 320) {
|
|
|
|
mainSprite(var_6, y - height, pMenu->gfx,
|
|
|
|
gfxModuleData.pPage10, video4, 320);
|
2007-04-27 12:58:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
currentY = y;
|
|
|
|
var_8 = 0;
|
|
|
|
di = x;
|
|
|
|
|
|
|
|
si = pMenu->ptrNextElement;
|
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
if (si) {
|
|
|
|
do {
|
2007-04-27 12:58:35 +00:00
|
|
|
int color;
|
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
gfxEntryStruct *var_2 = si->gfx;
|
2007-04-27 12:58:35 +00:00
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
si->x = di;
|
|
|
|
si->y = currentY;
|
2007-04-27 12:58:35 +00:00
|
|
|
si->varA = 320;
|
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
if (si->varC) {
|
2007-04-27 12:58:35 +00:00
|
|
|
color = video3;
|
2007-04-27 22:33:45 +00:00
|
|
|
} else {
|
|
|
|
if (si->color != 255) {
|
2007-04-27 12:58:35 +00:00
|
|
|
color = si->color;
|
2007-04-27 22:33:45 +00:00
|
|
|
} else {
|
2007-04-27 12:58:35 +00:00
|
|
|
color = video2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
if (di < 320) {
|
|
|
|
mainSprite(di, currentY, var_2,
|
|
|
|
gfxModuleData.pPage10, color, 320);
|
2007-04-27 12:58:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
currentY += height;
|
|
|
|
var_8++;
|
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
if (var_8 == var_10) {
|
|
|
|
var_8 = 0;
|
|
|
|
di += 320;
|
2007-04-27 12:58:35 +00:00
|
|
|
currentY = y;
|
|
|
|
}
|
|
|
|
|
|
|
|
si = si->next;
|
2007-04-27 22:33:45 +00:00
|
|
|
} while (si);
|
2007-04-27 12:58:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
int getValueFromObjectQuerry(objectParamsQuery *params, int idx) {
|
|
|
|
switch (idx) {
|
2007-04-27 12:58:35 +00:00
|
|
|
case 0:
|
|
|
|
return params->X;
|
|
|
|
case 1:
|
|
|
|
return params->Y;
|
|
|
|
case 2:
|
|
|
|
return params->baseFileIdx;
|
|
|
|
case 3:
|
|
|
|
return params->fileIdx;
|
|
|
|
case 4:
|
|
|
|
return params->scale;
|
|
|
|
case 5:
|
|
|
|
return params->var5;
|
|
|
|
case 6:
|
|
|
|
return params->var6;
|
|
|
|
case 7:
|
|
|
|
return params->var7;
|
|
|
|
}
|
|
|
|
|
|
|
|
assert(0);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
void mainDraw(int16 param) {
|
|
|
|
uint8 *bgPtr;
|
|
|
|
cellStruct *currentObjPtr;
|
2007-04-27 12:58:35 +00:00
|
|
|
int16 currentObjIdx;
|
|
|
|
int16 objX1 = 0;
|
|
|
|
int16 objY1 = 0;
|
|
|
|
int16 objZ1 = 0;
|
|
|
|
int16 objX2;
|
|
|
|
int16 objY2;
|
2007-04-27 20:31:43 +00:00
|
|
|
int16 objZ2;
|
2007-04-27 12:58:35 +00:00
|
|
|
int16 spriteHeight;
|
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
if (fadeVar) {
|
2007-04-27 12:58:35 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
bgPtr = backgroundPtrtable[currentActiveBackgroundPlane];
|
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
if (bgPtr) {
|
2007-05-16 22:44:22 +00:00
|
|
|
gfxModuleData_gfxCopyScreen((char *)bgPtr, (char *)gfxModuleData.pPage10);
|
2007-04-27 12:58:35 +00:00
|
|
|
}
|
|
|
|
|
2007-04-28 22:31:55 +00:00
|
|
|
autoCellHead.next = NULL;
|
2007-04-27 12:58:35 +00:00
|
|
|
|
2007-04-27 20:31:43 +00:00
|
|
|
currentObjPtr = cellHead.next;
|
2007-04-27 12:58:35 +00:00
|
|
|
|
|
|
|
#ifdef _DEBUG
|
2007-04-27 20:31:43 +00:00
|
|
|
/* polyOutputBuffer = (char*)bgPtr;
|
|
|
|
drawCtp(); */
|
2007-04-27 12:58:35 +00:00
|
|
|
#endif
|
|
|
|
|
2007-04-27 20:31:43 +00:00
|
|
|
//-------------------------------------------------- PROCESS SPRITES -----------------------------------------//
|
2007-04-27 12:58:35 +00:00
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
while (currentObjPtr) {
|
2007-05-16 22:44:22 +00:00
|
|
|
if ((currentActiveBackgroundPlane == currentObjPtr->backgroundPlane) && (currentObjPtr->freeze == 0) && (currentObjPtr->type == OBJ_SPRITE)) {
|
2007-04-27 12:58:35 +00:00
|
|
|
objectParamsQuery params;
|
|
|
|
|
|
|
|
currentObjIdx = currentObjPtr->idx;
|
|
|
|
|
2007-05-16 22:44:22 +00:00
|
|
|
if ((currentObjPtr->followObjectOverlayIdx != currentObjPtr->overlay) || (currentObjPtr->followObjectIdx != currentObjPtr->idx)) {
|
2007-04-27 12:58:35 +00:00
|
|
|
// Declaring this twice ?
|
|
|
|
// objectParamsQuery params;
|
|
|
|
|
2007-05-16 22:44:22 +00:00
|
|
|
getMultipleObjectParam(currentObjPtr->followObjectOverlayIdx, currentObjPtr->followObjectIdx, ¶ms);
|
2007-04-27 12:58:35 +00:00
|
|
|
|
|
|
|
objX1 = params.X;
|
|
|
|
objY1 = params.Y;
|
|
|
|
objZ1 = params.fileIdx;
|
2007-04-27 22:33:45 +00:00
|
|
|
} else {
|
2007-04-27 20:31:43 +00:00
|
|
|
objX1 = 0;
|
|
|
|
objY1 = 0;
|
|
|
|
objZ1 = 0;
|
|
|
|
}
|
2007-04-27 12:58:35 +00:00
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
getMultipleObjectParam(currentObjPtr->overlay,
|
|
|
|
currentObjIdx, ¶ms);
|
2007-04-27 12:58:35 +00:00
|
|
|
|
|
|
|
objX2 = objX1 + params.X;
|
|
|
|
objY2 = objY1 + params.Y;
|
2007-04-27 20:31:43 +00:00
|
|
|
objZ2 = params.fileIdx;
|
2007-04-27 12:58:35 +00:00
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
if (objZ2 >= 0) {
|
2007-04-27 20:31:43 +00:00
|
|
|
objZ2 += objZ1;
|
2007-04-27 12:58:35 +00:00
|
|
|
}
|
|
|
|
|
2007-04-28 22:31:55 +00:00
|
|
|
if ((params.var5 >= 0) && (objZ2 >= 0) && filesDatabase[objZ2].subData.ptr) {
|
2007-09-10 13:17:20 +00:00
|
|
|
if (filesDatabase[objZ2].subData.resourceType == 8) { // Poly
|
2007-04-27 22:33:45 +00:00
|
|
|
mainDrawPolygons(objZ2, currentObjPtr, objX2, params.scale, objY2, (char *)gfxModuleData.pPage10, (char *)filesDatabase[objZ2].subData.ptr); // poly
|
2007-09-10 13:17:20 +00:00
|
|
|
} else if (filesDatabase[objZ2].subData.resourceType == 6) { // sound
|
|
|
|
} else if (filesDatabase[objZ2].resType == 1) { //(num plan == 1)
|
2007-04-28 22:31:55 +00:00
|
|
|
} else if (filesDatabase[objZ2].subData.resourceType == 4) {
|
2007-04-27 22:33:45 +00:00
|
|
|
objX1 = filesDatabase[objZ2].width; // width
|
2007-04-27 20:31:43 +00:00
|
|
|
spriteHeight = filesDatabase[objZ2].height; // height
|
2007-04-27 12:58:35 +00:00
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
if (filesDatabase[objZ2].subData.ptr) {
|
2007-04-28 22:31:55 +00:00
|
|
|
currentTransparent = filesDatabase[objZ2].subData.transparency;
|
|
|
|
|
|
|
|
mainDrawSub4(objX1, spriteHeight, currentObjPtr, (char *)filesDatabase[objZ2].subData.ptr, objY2, objX2,(char *)gfxModuleData.pPage10,(char *)filesDatabase[objZ2].subData.ptr);
|
2007-04-27 12:58:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-05-16 22:44:22 +00:00
|
|
|
// automatic animation process
|
|
|
|
if (currentObjPtr->animStep && !param) {
|
2007-04-28 22:31:55 +00:00
|
|
|
if (currentObjPtr->animCounter <= 0) {
|
2007-05-16 22:44:22 +00:00
|
|
|
|
2007-04-27 20:31:43 +00:00
|
|
|
bool change = true;
|
2007-04-27 12:58:35 +00:00
|
|
|
|
2007-05-16 22:44:22 +00:00
|
|
|
int newVal = getValueFromObjectQuerry(¶ms, currentObjPtr->animChange) + currentObjPtr->animStep;
|
2007-04-27 22:33:45 +00:00
|
|
|
|
|
|
|
if (currentObjPtr->animStep > 0) {
|
2007-04-28 22:31:55 +00:00
|
|
|
if (newVal > currentObjPtr->animEnd) {
|
|
|
|
if (currentObjPtr->animLoop) {
|
|
|
|
newVal = currentObjPtr->animStart;
|
2007-09-18 20:16:33 +00:00
|
|
|
if (currentObjPtr->animLoop>0)
|
2007-05-16 22:44:22 +00:00
|
|
|
currentObjPtr->animLoop--;
|
2007-04-27 22:33:45 +00:00
|
|
|
} else {
|
2007-04-27 20:31:43 +00:00
|
|
|
int16 data2;
|
2007-04-28 22:31:55 +00:00
|
|
|
data2 = currentObjPtr->animStart;
|
2007-04-27 12:58:35 +00:00
|
|
|
|
2007-04-27 20:31:43 +00:00
|
|
|
change = false;
|
2007-04-28 22:31:55 +00:00
|
|
|
currentObjPtr->animStep = 0;
|
2007-04-27 12:58:35 +00:00
|
|
|
|
2007-09-10 13:17:20 +00:00
|
|
|
if (currentObjPtr->animType) { // should we resume the script ?
|
2007-04-28 22:31:55 +00:00
|
|
|
if (currentObjPtr->parentType == 20) {
|
2007-10-29 22:03:55 +00:00
|
|
|
changeScriptParamInList(currentObjPtr->parentOverlay, currentObjPtr->parent, &procHead, -1, 0);
|
2007-09-10 13:17:20 +00:00
|
|
|
} else if (currentObjPtr->parentType == 30) {
|
2007-10-29 22:03:55 +00:00
|
|
|
changeScriptParamInList(currentObjPtr->parentOverlay, currentObjPtr->parent, &relHead, -1, 0);
|
2007-04-27 20:31:43 +00:00
|
|
|
}
|
2007-04-27 12:58:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-04-27 22:33:45 +00:00
|
|
|
} else {
|
2007-10-29 22:03:55 +00:00
|
|
|
if (newVal < currentObjPtr->animEnd) {
|
|
|
|
if (currentObjPtr->animLoop) {
|
|
|
|
newVal = currentObjPtr->animStart;
|
|
|
|
if (currentObjPtr->animLoop>0)
|
|
|
|
currentObjPtr->animLoop--;
|
|
|
|
} else {
|
|
|
|
int16 data2;
|
|
|
|
data2 = currentObjPtr->animStart;
|
|
|
|
|
|
|
|
change = false;
|
|
|
|
currentObjPtr->animStep = 0;
|
|
|
|
|
|
|
|
if (currentObjPtr->animType) { // should we resume the script ?
|
|
|
|
if (currentObjPtr->parentType == 20) {
|
|
|
|
changeScriptParamInList(currentObjPtr->parentOverlay, currentObjPtr->parent, &procHead, -1, 0);
|
|
|
|
} else if (currentObjPtr->parentType == 30) {
|
|
|
|
changeScriptParamInList(currentObjPtr->parentOverlay, currentObjPtr->parent, &relHead, -1, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-04-27 12:58:35 +00:00
|
|
|
}
|
|
|
|
|
2007-04-28 22:31:55 +00:00
|
|
|
if (currentObjPtr->animWait >= 0) {
|
|
|
|
currentObjPtr->animCounter = currentObjPtr->animWait;
|
2007-04-27 12:58:35 +00:00
|
|
|
}
|
|
|
|
|
2007-04-28 22:31:55 +00:00
|
|
|
if ((currentObjPtr->animSignal >= 0) && (currentObjPtr->animSignal == newVal) && (currentObjPtr->animType != 0)) {
|
|
|
|
if (currentObjPtr->parentType == 20) {
|
2007-10-29 22:03:55 +00:00
|
|
|
changeScriptParamInList(currentObjPtr->parentOverlay, currentObjPtr->parent, &procHead, -1, 0);
|
2007-04-28 22:31:55 +00:00
|
|
|
} else if (currentObjPtr->parentType == 30) {
|
2007-10-29 22:03:55 +00:00
|
|
|
changeScriptParamInList(currentObjPtr->parentOverlay, currentObjPtr->parent, &relHead, -1, 0);
|
2007-04-27 20:31:43 +00:00
|
|
|
}
|
2007-04-27 12:58:35 +00:00
|
|
|
|
2007-04-28 22:31:55 +00:00
|
|
|
currentObjPtr->animType = 0;
|
2007-04-27 12:58:35 +00:00
|
|
|
}
|
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
if (change) {
|
2007-04-28 22:31:55 +00:00
|
|
|
addAutoCell(currentObjPtr->overlay, currentObjPtr->idx, currentObjPtr->animChange, newVal, currentObjPtr);
|
2007-04-27 12:58:35 +00:00
|
|
|
}
|
2007-04-27 22:33:45 +00:00
|
|
|
} else {
|
2007-04-28 22:31:55 +00:00
|
|
|
currentObjPtr->animCounter--;
|
2007-04-27 12:58:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
currentObjPtr = currentObjPtr->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------------------------------------------//
|
|
|
|
|
2007-04-28 22:31:55 +00:00
|
|
|
freeAutoCell();
|
2007-04-27 12:58:35 +00:00
|
|
|
var20 = 0;
|
|
|
|
|
2007-04-28 00:26:57 +00:00
|
|
|
//-------------------------------------------------- DRAW OBJECTS TYPE 5 (MSG)-----------------------------------------//
|
2007-04-27 12:58:35 +00:00
|
|
|
|
2007-04-27 20:31:43 +00:00
|
|
|
currentObjPtr = cellHead.next;
|
2007-04-27 12:58:35 +00:00
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
while (currentObjPtr) {
|
|
|
|
if (currentObjPtr->type == 5 && currentObjPtr->freeze == 0) {
|
2007-04-28 22:31:55 +00:00
|
|
|
mainSprite(currentObjPtr->x, currentObjPtr->field_C, currentObjPtr->gfxPtr, gfxModuleData.pPage10, currentObjPtr->color, currentObjPtr->spriteIdx);
|
2007-04-27 12:58:35 +00:00
|
|
|
var20 = 1;
|
|
|
|
}
|
|
|
|
currentObjPtr = currentObjPtr->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------------------------------------------//
|
|
|
|
|
2007-04-27 22:33:45 +00:00
|
|
|
if (currentActiveMenu != -1) {
|
|
|
|
if (menuTable[currentActiveMenu]) {
|
2007-04-27 12:58:35 +00:00
|
|
|
drawMenu(menuTable[currentActiveMenu]);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2007-10-29 20:56:19 +00:00
|
|
|
else
|
|
|
|
if ((linkedRelation) && (linkedMsgList))
|
|
|
|
{
|
2007-04-27 12:58:35 +00:00
|
|
|
ASSERT(0);
|
|
|
|
// TODO: draw mouse here
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} // End of namespace Cruise
|