231 lines
5.7 KiB
C++
231 lines
5.7 KiB
C++
#include "SCENE.h"
|
|
|
|
#ifdef RASTERS_ACTIVATED
|
|
|
|
typedef struct RASTER_
|
|
{
|
|
char Name[128];
|
|
double TimeInMs;
|
|
double TimeInMs_BLENDED[MAX_RASTER];
|
|
} RASTER;
|
|
|
|
|
|
typedef struct RASTER_TREE_
|
|
{
|
|
RASTER_ENUM raster;
|
|
int parent;
|
|
double TimeInMs_Start;
|
|
double TimeInMs;
|
|
} RASTER_TREE;
|
|
|
|
|
|
void WORLD::DRawRaster(u32 Pos, u32 LC, u32 Color , float BeginTimeInMiliSeconds, float TimeInMiliSeconds)
|
|
{
|
|
DI->SetCurrentColor(0xff000000 | Color);
|
|
DI->DrawQuad(-1,
|
|
((float)XSize * (float)BeginTimeInMiliSeconds * 20.0f / 1000.0f),
|
|
((float)XSize * (float)(TimeInMiliSeconds+BeginTimeInMiliSeconds) * 20.0f / 1000.0f),
|
|
YSize - (Pos+LC),YSize - Pos);
|
|
DI->SetCurrentColor(0xffffffff);
|
|
DI->DrawQuad(-1,
|
|
XSize / 3,
|
|
(XSize / 3) + 2,
|
|
YSize - (Pos+LC),YSize - (Pos-LC));
|
|
DI->DrawQuad(-1,
|
|
2*(XSize / 3),
|
|
2*(XSize / 3) + 2,
|
|
YSize - (Pos+LC),YSize - (Pos-LC));
|
|
return;
|
|
u32 *Ptr,CCCCC,CCCCCBegin;
|
|
Color &= 0xfefefefe;
|
|
//Color>>=1;
|
|
while (LC--)
|
|
{
|
|
/*Ptr = (u32 *)SOURCEMAP->BASE + (Pos+LC) * SOURCEMAP->PITCH;
|
|
CCCCCBegin = (u32)((float)XSize * (float)BeginTimeInMiliSeconds * 20.0f / 1000.0f);
|
|
CCCCC = (u32)((float)XSize * (float)(TimeInMiliSeconds+BeginTimeInMiliSeconds) * 20.0f / 1000.0f);
|
|
if (CCCCCBegin > XSize) continue;
|
|
if (CCCCC > XSize) CCCCC = XSize;
|
|
CCCCC -= CCCCCBegin;
|
|
Ptr += CCCCCBegin;
|
|
while (CCCCC--) *(Ptr++) = Color ;
|
|
DrawLine_Clip(SOURCEMAP,XSize / 3,(Pos+0),XSize / 3,(Pos+5),0xffffff);
|
|
DrawLine_Clip(SOURCEMAP,XSize * 2 / 3,(Pos+0),XSize * 2 / 3,(Pos+5),0xffffff);*/
|
|
}
|
|
}
|
|
|
|
|
|
|
|
u32 GetColor(int i)
|
|
{
|
|
u32 Color;
|
|
Color = 0x202020;
|
|
i++;
|
|
if (i & 1) Color |= 0x800000;
|
|
if (i & 2) Color |= 0x8000;
|
|
if (i & 4) Color |= 0x80;
|
|
if (i & 8) Color |= 0x400000;
|
|
if (i & 16) Color |= 0x4000;
|
|
if (i & 32) Color |= 0x40;
|
|
|
|
return Color;
|
|
}
|
|
|
|
BOOL RasterInit = false;
|
|
RASTER AllRasters[MAX_RASTER];
|
|
RASTER_TREE AllRastersTree[1024];
|
|
|
|
int RasterInTreePosition = -1;
|
|
int RasterInTreeNb = 0;
|
|
|
|
int GetChild(RASTER_ENUM RE)
|
|
{
|
|
for (int i=RasterInTreePosition+1; i<RasterInTreeNb; i++)
|
|
{
|
|
if (AllRastersTree[i].raster == RE && AllRastersTree[i].parent == RasterInTreePosition)
|
|
return i;
|
|
}
|
|
AllRastersTree[RasterInTreeNb].raster = RE;
|
|
AllRastersTree[RasterInTreeNb].parent = RasterInTreePosition;
|
|
return RasterInTreeNb++;
|
|
}
|
|
|
|
void StartRaster(RASTER_ENUM RE, char *newName)
|
|
{
|
|
if (newName && strcmp(newName, AllRasters[RE].Name))
|
|
strcpy(AllRasters[RE].Name, newName);
|
|
|
|
if (RasterInTreePosition == -1 || AllRastersTree[RasterInTreePosition].raster != RE)
|
|
RasterInTreePosition = GetChild(RE);
|
|
else
|
|
RasterInTreePosition = RasterInTreePosition;
|
|
|
|
if (AllRastersTree[RasterInTreePosition].TimeInMs_Start == 0.0)
|
|
AllRastersTree[RasterInTreePosition].TimeInMs_Start = timeGetTime();
|
|
}
|
|
|
|
void StopRaster(RASTER_ENUM RE)
|
|
{
|
|
if (RasterInTreePosition < 0) return;
|
|
if (AllRastersTree[RasterInTreePosition].raster == RE)
|
|
{
|
|
if (AllRastersTree[RasterInTreePosition].TimeInMs_Start != 0.0)
|
|
AllRastersTree[RasterInTreePosition].TimeInMs += timeGetTime() - AllRastersTree[RasterInTreePosition].TimeInMs_Start + 0.0001;
|
|
AllRastersTree[RasterInTreePosition].TimeInMs_Start = 0.0;
|
|
RasterInTreePosition = AllRastersTree[RasterInTreePosition].parent;
|
|
}
|
|
}
|
|
|
|
int loopIndex = 0;
|
|
|
|
void WORLD::DrawRasters(bool draw)
|
|
{
|
|
u32 KBase = 10;
|
|
int childList[32];
|
|
int i,j,k;
|
|
float beginTime;
|
|
|
|
if (!RasterInit)
|
|
{
|
|
memset(AllRasters, 0, sizeof(AllRasters));
|
|
i = 0;
|
|
#define DEFINE_RASTER(a) strcpy(AllRasters[i++].Name, #a);
|
|
#include "RastersDefines.h"
|
|
RasterInit = true;
|
|
}
|
|
|
|
if (draw)
|
|
{
|
|
// New method ...
|
|
for (j=0; j<MAX_RASTER ; j++)
|
|
AllRasters[j].TimeInMs = 0;
|
|
|
|
j = RasterInTreeNb;
|
|
while (j--)
|
|
{
|
|
i = AllRastersTree[j].raster;
|
|
AllRasters[i].TimeInMs += AllRastersTree[j].TimeInMs;
|
|
//if (AllRastersTree[j].parent != -1)
|
|
//{
|
|
// k = AllRastersTree[AllRastersTree[j].parent].raster;
|
|
// AllRasters[k].TimeInMs += AllRasters[i].TimeInMs;
|
|
//}
|
|
}
|
|
|
|
for (i=0; i<MAX_RASTER ; i++)
|
|
{
|
|
#define BlendCoef 0.9
|
|
AllRasters[i].TimeInMs_BLENDED[i] =
|
|
(AllRasters[i].TimeInMs_BLENDED[i] * BlendCoef) + ((1.0f - BlendCoef) * AllRasters[i].TimeInMs);
|
|
for (j=0; j<MAX_RASTER; j++)
|
|
{
|
|
if (j == i) continue;
|
|
AllRasters[i].TimeInMs_BLENDED[j] = AllRasters[i].TimeInMs_BLENDED[j] * BlendCoef;
|
|
}
|
|
}
|
|
|
|
//for FPS and loading optimisation
|
|
/*
|
|
loopIndex++;
|
|
if (loopIndex<10)
|
|
{
|
|
char filename[64];
|
|
memset(filename, 0, 64);
|
|
sprintf(filename, "loop%d rasters.txt", loopIndex);
|
|
FILE* file = CC_fopen(filename, "w");
|
|
for (i=0; i<MAX_RASTER ; i++)
|
|
{
|
|
if (AllRasters[i].TimeInMs!=0)
|
|
fprintf(file, "%s: %d\n",AllRasters[i].Name, (int)AllRasters[i].TimeInMs);
|
|
}
|
|
CC_fclose(file);
|
|
}
|
|
*/
|
|
|
|
j = RasterInTreeNb;
|
|
while (j--)
|
|
{
|
|
if (AllRastersTree[j].parent == -1) continue;
|
|
i = AllRastersTree[j].raster;
|
|
k = AllRastersTree[AllRastersTree[j].parent].raster;
|
|
AllRasters[k].TimeInMs_BLENDED[i] = AllRasters[i].TimeInMs_BLENDED[i];
|
|
}
|
|
|
|
for (i = 0; i < MAX_RASTER ; i++)
|
|
{
|
|
u32 Color = 0xFF000000 | GetColor(i);
|
|
if (AllRasters[i].TimeInMs_BLENDED[i] != 0.0)
|
|
{
|
|
DI->DrawText((u8*)AllRasters[i].Name,0, KBase, 1,1,Color);
|
|
DRawRaster(KBase,2,Color, 0, AllRasters[i].TimeInMs_BLENDED[i]);
|
|
beginTime = 0;
|
|
for (j=0; j<MAX_RASTER; j++)
|
|
{
|
|
if (j == i) continue;
|
|
if (AllRasters[i].TimeInMs_BLENDED[j] != 0.0f)
|
|
{
|
|
Color = GetColor(j);
|
|
DRawRaster(KBase+2, 3, Color, beginTime, AllRasters[i].TimeInMs_BLENDED[j]);
|
|
beginTime += AllRasters[i].TimeInMs_BLENDED[j];
|
|
}
|
|
}
|
|
KBase += 16;
|
|
}
|
|
}
|
|
}
|
|
memset(AllRastersTree, 0, sizeof(AllRastersTree));
|
|
RasterInTreePosition = -1;
|
|
RasterInTreeNb = 0;
|
|
}
|
|
|
|
#else
|
|
|
|
void WORLD::DRawRaster(u32 Pos, u32 LC, u32 Color , float BeginTimeInMiliSeconds, float TimeInMiliSeconds)
|
|
{
|
|
}
|
|
|
|
void WORLD::DrawRasters(bool draw)
|
|
{
|
|
}
|
|
|
|
#endif
|