This commit is contained in:
parent
c787d81564
commit
f857751606
6 changed files with 250 additions and 202 deletions
|
@ -11,9 +11,12 @@
|
|||
#ifndef __TPAGE_H__
|
||||
#include "gfx\tpage.h"
|
||||
#endif
|
||||
#ifndef __PRIMPLUS_HEADER__
|
||||
#include "gfx\primplus.h"
|
||||
#endif
|
||||
|
||||
#define MAX_OT (1024)
|
||||
#define MAX_PRIMS (1024)
|
||||
#define MAX_PRIMS (1024*2)
|
||||
|
||||
#define USE_NTAGS 1
|
||||
|
||||
|
@ -214,6 +217,74 @@ typedef u32 sOT;
|
|||
#define GetPrimLG4() GetPrim(LINE_G4);\
|
||||
setLineG4(CurrPrim-sizeof(LINE_G4))
|
||||
|
||||
#define GetPrimSPRT8() GetPrim(SPRT8);\
|
||||
setSprt8(CurrPrim-sizeof(SPRT8))
|
||||
|
||||
#define GetPrimSPRT16() GetPrim(SPRT16);\
|
||||
setSprt16(CurrPrim-sizeof(SPRT16))
|
||||
|
||||
#define GetPrimSPRT() GetPrim(SPRT);\
|
||||
setSprt(CurrPrim-sizeof(SPRT))
|
||||
|
||||
#define GetPrimTILE8() GetPrim(TILE8);\
|
||||
setTile(CurrPrim-sizeof(TILE8))
|
||||
|
||||
#define GetPrimTILE16() GetPrim(TILE16);\
|
||||
setTile(CurrPrim-sizeof(TILE16))
|
||||
|
||||
#define GetPrimTILE() GetPrim(TILE);\
|
||||
setTile(CurrPrim-sizeof(TILE))
|
||||
|
||||
// Extra prims :o)
|
||||
#define GetPrimTF3() GetPrim(TPOLY_F3);\
|
||||
setTPolyF3(CurrPrim-sizeof(TPOLY_F3))
|
||||
|
||||
#define GetPrimTF4() GetPrim(TPOLY_F4);\
|
||||
setTPolyF4(CurrPrim-sizeof(TPOLY_F4))
|
||||
|
||||
#define GetPrimTG3() GetPrim(TPOLY_G3);\
|
||||
setTPolyG3(CurrPrim-sizeof(TPOLY_G3))
|
||||
|
||||
#define GetPrimTG4() GetPrim(TPOLY_G4);\
|
||||
setTPolyG4(CurrPrim-sizeof(TPOLY_G4))
|
||||
|
||||
#define GetPrimTLF2() GetPrim(TLINE_F2); \
|
||||
setTLineF2(CurrPrim-sizeof(TLINE_F2))
|
||||
|
||||
#define GetPrimTLF3() GetPrim(TLINE_F3);\
|
||||
setTLineF3(CurrPrim-sizeof(TLINE_F3))
|
||||
|
||||
#define GetPrimTLF4() GetPrim(TLINE_F4);\
|
||||
setTLineF4((TLINE_F4*)CurrPrim-1)
|
||||
|
||||
#define GetPrimTLG2() GetPrim(TLINE_G2);\
|
||||
setTLineG2(CurrPrim-sizeof(TLINE_G2))
|
||||
|
||||
#define GetPrimTLG3() GetPrim(TLINE_G3);\
|
||||
setTLineG3(CurrPrim-sizeof(TLINE_G3))
|
||||
|
||||
#define GetPrimTLG4() GetPrim(TLINE_G4);\
|
||||
setTLineG4(CurrPrim-sizeof(TLINE_G4))
|
||||
|
||||
#define GetPrimTSPRT8() GetPrim(TSPRT8);\
|
||||
setTSprt8(CurrPrim-sizeof(TSPRT8))
|
||||
|
||||
#define GetPrimTSPRT16() GetPrim(TSPRT16);\
|
||||
setTSprt16(CurrPrim-sizeof(TSPRT16))
|
||||
|
||||
#define GetPrimTSPRT() GetPrim(TSPRT);\
|
||||
setTSprt(CurrPrim-sizeof(TSPRT))
|
||||
|
||||
#define GetPrimTTILE8() GetPrim(TTILE8);\
|
||||
setTile(CurrPrim-sizeof(TTILE8))
|
||||
|
||||
#define GetPrimTTILE16() GetPrim(TTILE16);\
|
||||
setTile(CurrPrim-sizeof(TTILE16))
|
||||
|
||||
#define GetPrimTTILE() GetPrim(TTILE);\
|
||||
setTile(CurrPrim-sizeof(TTILE))
|
||||
|
||||
|
||||
/********************************************************************************************************/
|
||||
#define OtInRange (MAX_OT-1)
|
||||
#define OtOutRange (0xffffffff-OtInRange)
|
||||
|
|
|
@ -3,13 +3,14 @@
|
|||
*
|
||||
* 'New' polygon types, and associated macros, for non-textured primitives (and
|
||||
* sprites) with per-poly ABR control. Also includes tpage control for sprites.
|
||||
*
|
||||
* Courtesty of Dead Ashton
|
||||
*
|
||||
*
|
||||
*************************************************************************************/
|
||||
|
||||
#ifndef __PRIMPLUS_H
|
||||
#define __PRIMPLUS_H
|
||||
#ifndef __PRIMPLUS_HEADER__
|
||||
#define __PRIMPLUS_HEADER__
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Defines
|
||||
|
@ -107,10 +108,10 @@
|
|||
#define setTPolyG4(p) setTDrawTPageSize((p), GPUSIZE_TPOLY_G4), setcode(&((p)->tag_poly), GPUCODE_POLY_G4), ((p)->tag_poly)=0
|
||||
|
||||
#define setTLineF2(p) setTDrawTPageSize((p), GPUSIZE_TLINE_F2), setcode(&((p)->tag_poly), GPUCODE_LINE_F2), ((p)->tag_poly)=0
|
||||
#define setTLineG2(p) setTDrawTPageSize((p), GPUSIZE_TLINE_G2), setcode(&((p)->tag_poly), GPUCODE_LINE_G2), ((p)->tag_poly)=0
|
||||
#define setTLineF3(p) setTDrawTPageSize((p), GPUSIZE_TLINE_F3), setcode(&((p)->tag_poly), GPUCODE_LINE_F3), ((p)->tag_poly)=0, ((p)->pad)=0x55555555
|
||||
#define setTLineG3(p) setTDrawTPageSize((p), GPUSIZE_TLINE_G3), setcode(&((p)->tag_poly), GPUCODE_LINE_G3), ((p)->tag_poly)=0, ((p)->pad)=0x55555555
|
||||
#define setTLineF4(p) setTDrawTPageSize((p), GPUSIZE_TLINE_F4), setcode(&((p)->tag_poly), GPUCODE_LINE_F4), ((p)->tag_poly)=0, ((p)->pad)=0x55555555
|
||||
#define setTLineG2(p) setTDrawTPageSize((p), GPUSIZE_TLINE_G2), setcode(&((p)->tag_poly), GPUCODE_LINE_G2), ((p)->tag_poly)=0
|
||||
#define setTLineG3(p) setTDrawTPageSize((p), GPUSIZE_TLINE_G3), setcode(&((p)->tag_poly), GPUCODE_LINE_G3), ((p)->tag_poly)=0, ((p)->pad)=0x55555555
|
||||
#define setTLineG4(p) setTDrawTPageSize((p), GPUSIZE_TLINE_G4), setcode(&((p)->tag_poly), GPUCODE_LINE_G4), ((p)->tag_poly)=0, ((p)->pad)=0x55555555
|
||||
|
||||
#define setTSprt(p) setTDrawTPageSize((p), GPUSIZE_TSPRT), setcode(&((p)->tag_poly), GPUCODE_SPRT), ((p)->tag_poly)=0
|
||||
|
@ -134,7 +135,7 @@
|
|||
// Structures
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
typedef struct __tpoly_f3
|
||||
struct TPOLY_F3 // Flat Triangle with ABR control
|
||||
{
|
||||
u_long tag;
|
||||
u_long t_code[1];
|
||||
|
@ -143,9 +144,9 @@ typedef struct __tpoly_f3
|
|||
short x0, y0;
|
||||
short x1, y1;
|
||||
short x2, y2;
|
||||
} TPOLY_F3; // Flat Triangle with ABR control
|
||||
};
|
||||
|
||||
typedef struct __tpoly_f4
|
||||
struct TPOLY_F4 // Flat Quadrangle with ABR control
|
||||
{
|
||||
u_long tag;
|
||||
u_long t_code[1];
|
||||
|
@ -155,9 +156,9 @@ typedef struct __tpoly_f4
|
|||
short x1, y1;
|
||||
short x2, y2;
|
||||
short x3, y3;
|
||||
} TPOLY_F4; // Flat Quadrangle with ABR control
|
||||
};
|
||||
|
||||
typedef struct __tpoly_g3
|
||||
struct TPOLY_G3 // Gouraud Triangle with ABR control
|
||||
{
|
||||
u_long tag;
|
||||
u_long t_code[1];
|
||||
|
@ -168,9 +169,9 @@ typedef struct __tpoly_g3
|
|||
short x1, y1;
|
||||
u_char r2, g2, b2, pad2;
|
||||
short x2, y2;
|
||||
} TPOLY_G3; // Gouraud Triangle with ABR control
|
||||
};
|
||||
|
||||
typedef struct __tpoly_g4
|
||||
struct TPOLY_G4 // Gouraud Quadrangle with ABR control
|
||||
{
|
||||
u_long tag;
|
||||
u_long t_code[1];
|
||||
|
@ -183,13 +184,13 @@ typedef struct __tpoly_g4
|
|||
short x2, y2;
|
||||
u_char r3, g3, b3, pad3;
|
||||
short x3, y3;
|
||||
} TPOLY_G4; // Gouraud Quadrangle with ABR control
|
||||
};
|
||||
|
||||
//
|
||||
// Line Primitive Definitions
|
||||
//
|
||||
|
||||
typedef struct __tline_f2
|
||||
struct TLINE_F2 // Unconnected Flat Line with ABR control
|
||||
{
|
||||
u_long tag;
|
||||
u_long t_code[1];
|
||||
|
@ -197,9 +198,9 @@ typedef struct __tline_f2
|
|||
u_char r0, g0, b0, code;
|
||||
short x0, y0;
|
||||
short x1, y1;
|
||||
} TLINE_F2; // Unconnected Flat Line with ABR control
|
||||
};
|
||||
|
||||
typedef struct __tline_g2
|
||||
struct TLINE_G2 // Unconnected Gouraud Line with ABR control
|
||||
{
|
||||
u_long tag;
|
||||
u_long t_code[1];
|
||||
|
@ -208,9 +209,9 @@ typedef struct __tline_g2
|
|||
short x0, y0;
|
||||
u_char r1, g1, b1, p1;
|
||||
short x1, y1;
|
||||
} TLINE_G2; // Unconnected Gouraud Line with ABR control
|
||||
};
|
||||
|
||||
typedef struct __tline_f3
|
||||
struct TLINE_F3 // 2 connected Flat Line with ABR control
|
||||
{
|
||||
u_long tag;
|
||||
u_long t_code[1];
|
||||
|
@ -220,9 +221,9 @@ typedef struct __tline_f3
|
|||
short x1, y1;
|
||||
short x2, y2;
|
||||
u_long pad;
|
||||
} TLINE_F3; // 2 connected Flat Line with ABR control
|
||||
};
|
||||
|
||||
typedef struct __tline_g3
|
||||
struct TLINE_G3 // 2 connected Gouraud Line with ABR control
|
||||
{
|
||||
u_long tag;
|
||||
u_long t_code[1];
|
||||
|
@ -234,9 +235,9 @@ typedef struct __tline_g3
|
|||
u_char r2, g2, b2, p2;
|
||||
short x2, y2;
|
||||
u_long pad;
|
||||
} TLINE_G3; // 2 connected Gouraud Line with ABR control
|
||||
};
|
||||
|
||||
typedef struct __tline_f4
|
||||
struct TLINE_F4 // 3 connected Flat Line Quadrangle with ABR control
|
||||
{
|
||||
u_long tag;
|
||||
u_long t_code[1];
|
||||
|
@ -247,9 +248,9 @@ typedef struct __tline_f4
|
|||
short x2, y2;
|
||||
short x3, y3;
|
||||
u_long pad;
|
||||
} TLINE_F4; // 3 connected Flat Line Quadrangle with ABR control
|
||||
};
|
||||
|
||||
typedef struct __tline_g4
|
||||
struct TLINE_G4 // 3 connected Gouraud Line with ABR control
|
||||
{
|
||||
u_long tag;
|
||||
u_long t_code[1];
|
||||
|
@ -263,13 +264,13 @@ typedef struct __tline_g4
|
|||
u_char r3, g3, b3, p3;
|
||||
short x3, y3;
|
||||
u_long pad;
|
||||
} TLINE_G4; // 3 connected Gouraud Line with ABR control
|
||||
};
|
||||
|
||||
//
|
||||
// Sprite Primitive Definitions
|
||||
//
|
||||
|
||||
typedef struct __tsprt
|
||||
struct TSPRT // Free size Sprite with TPage/ABR control
|
||||
{
|
||||
u_long tag;
|
||||
u_long t_code[1];
|
||||
|
@ -278,9 +279,9 @@ typedef struct __tsprt
|
|||
short x0, y0;
|
||||
u_char u0, v0; u_short clut;
|
||||
short w, h;
|
||||
} TSPRT; // Free size Sprite with TPage/ABR control
|
||||
};
|
||||
|
||||
typedef struct __tsprt_16
|
||||
struct TSPRT_16 // 16x16 Sprite with TPage/ABR control
|
||||
{
|
||||
u_long tag;
|
||||
u_long t_code[1];
|
||||
|
@ -288,9 +289,9 @@ typedef struct __tsprt_16
|
|||
u_char r0, g0, b0, code;
|
||||
short x0, y0;
|
||||
u_char u0, v0; u_short clut;
|
||||
} TSPRT_16; // 16x16 Sprite with TPage/ABR control
|
||||
};
|
||||
|
||||
typedef struct __tsprt_8
|
||||
struct TSPRT_8 // 8x8 Sprite with TPage/ABR control
|
||||
{
|
||||
u_long tag;
|
||||
u_long t_code[1];
|
||||
|
@ -298,13 +299,13 @@ typedef struct __tsprt_8
|
|||
u_char r0, g0, b0, code;
|
||||
short x0, y0;
|
||||
u_char u0, v0; u_short clut;
|
||||
} TSPRT_8; // 8x8 Sprite with TPage/ABR control
|
||||
};
|
||||
|
||||
//
|
||||
// Tile Primitive Definitions
|
||||
//
|
||||
|
||||
typedef struct __ttile
|
||||
struct TTILE // free size Tile with ABR control
|
||||
{
|
||||
u_long tag;
|
||||
u_long t_code[1];
|
||||
|
@ -312,33 +313,33 @@ typedef struct __ttile
|
|||
u_char r0, g0, b0, code;
|
||||
short x0, y0;
|
||||
short w, h;
|
||||
} TTILE; // free size Tile with ABR control
|
||||
};
|
||||
|
||||
typedef struct __ttile16
|
||||
struct TTILE_16 // 16x16 Tile with ABR control
|
||||
{
|
||||
u_long tag;
|
||||
u_long t_code[1];
|
||||
u_long tag_poly;
|
||||
u_char r0, g0, b0, code;
|
||||
short x0, y0;
|
||||
} TTILE_16; // 16x16 Tile with ABR control
|
||||
};
|
||||
|
||||
typedef struct __ttile_8
|
||||
struct TTILE_8 // 8x8 Tile with ABR control
|
||||
{
|
||||
u_long tag;
|
||||
u_long t_code[1];
|
||||
u_long tag_poly;
|
||||
u_char r0, g0, b0, code;
|
||||
short x0, y0;
|
||||
} TTILE_8; // 8x8 Tile with ABR control
|
||||
};
|
||||
|
||||
typedef struct __ttile_1
|
||||
struct TTILE_1 // 1x1 Tile with ABR control
|
||||
{
|
||||
u_long tag;
|
||||
u_long t_code[1];
|
||||
u_long tag_poly;
|
||||
u_char r0, g0, b0, code;
|
||||
short x0, y0;
|
||||
} TTILE_1; // 1x1 Tile with ABR control
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -27,8 +27,6 @@ CLayerTile::CLayerTile(sLayerHdr *Hdr,sTile *_TileList,sTri *_TriList,sQuad *_Qu
|
|||
VtxList=_VtxList;
|
||||
Map=(sTileMapElem*)MakePtr(Hdr,sizeof(sLayerHdr));
|
||||
|
||||
DAVE_DBGMSG("LayerTile\n");
|
||||
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -36,42 +34,12 @@ CLayerTile::~CLayerTile()
|
|||
{
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
int CLayerTile::GetLayerType(int SubType)
|
||||
{
|
||||
switch(SubType)
|
||||
{
|
||||
case CLayerTile::LAYER_TILE_SUBTYPE_BACK: return(LAYER_TYPE_TILE_BACK);
|
||||
case CLayerTile::LAYER_TILE_SUBTYPE_MID: return(LAYER_TYPE_TILE_MID);
|
||||
case CLayerTile::LAYER_TILE_SUBTYPE_ACTION: return(LAYER_TYPE_TILE_ACTION);
|
||||
case CLayerTile::LAYER_TILE_SUBTYPE_FORE: return(LAYER_TYPE_TILE_FORE);
|
||||
}
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
void CLayerTile::init()
|
||||
{
|
||||
return;
|
||||
int Width=GetWidth();
|
||||
int Height=GetHeight();
|
||||
int Size=Width*Height;
|
||||
|
||||
for (int i=0; i<Size; i++)
|
||||
Map[i].Tile =0;
|
||||
/*
|
||||
for (int Y=0; Y<4; Y++)
|
||||
{
|
||||
for (int X=0; X<4; X++)
|
||||
{
|
||||
Map[X+(Y*Width)].Tile=X+(Y*4);
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
for (int i=0; i<16; i++) Map[i].Tile=i;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -80,42 +48,60 @@ void CLayerTile::shutdown()
|
|||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
int XOfs=64;
|
||||
int YOfs=64;
|
||||
int Dx=0;
|
||||
int Dy=0;
|
||||
int MapX=0;
|
||||
int MapY=0;
|
||||
|
||||
|
||||
void CLayerTile::render()
|
||||
{
|
||||
int Width=GetWidth();
|
||||
int Height=GetHeight();
|
||||
int Width=32;//GetWidth();
|
||||
int Height=21;//GetHeight();
|
||||
POLY_FT4 *ft4;
|
||||
sTileMapElem *ThisElem=Map;
|
||||
XOfs+=Dx;
|
||||
YOfs+=Dy;
|
||||
int XOfs=MapX;
|
||||
int YOfs=MapY;
|
||||
int XTileOfs,YTileOfs;
|
||||
|
||||
|
||||
if (LayerHdr->SubType==LAYER_TILE_SUBTYPE_BACK)
|
||||
{
|
||||
XOfs/=4;
|
||||
YOfs/=4;
|
||||
}
|
||||
if (LayerHdr->SubType==LAYER_TILE_SUBTYPE_MID)
|
||||
{
|
||||
XOfs/=2;
|
||||
YOfs/=2;
|
||||
}
|
||||
|
||||
YTileOfs=YOfs;
|
||||
for (int Y=0; Y<Height; Y++)
|
||||
{
|
||||
XTileOfs=XOfs;
|
||||
for (int X=0; X<Width; X++)
|
||||
{
|
||||
|
||||
if (ThisElem->Tile)
|
||||
{
|
||||
sTile *ThisTile=&TileList[ThisElem->Tile];
|
||||
if (ThisTile->TPage)
|
||||
{
|
||||
s16 x0=XTileOfs;
|
||||
s16 x1=XTileOfs+TILE_WIDTH;
|
||||
s16 y0=YTileOfs;
|
||||
s16 y1=YTileOfs+TILE_HEIGHT;
|
||||
|
||||
ft4=GetPrimFT4();
|
||||
setShadeTex(ft4,1);
|
||||
setSemiTrans(ft4,1);
|
||||
ft4->tpage=ThisTile->TPage;
|
||||
ft4->clut=ThisTile->Clut;
|
||||
ft4->x0=(X*TILE_WIDTH)+XOfs; ft4->y0=(Y*TILE_HEIGHT)+YOfs;
|
||||
ft4->x1=ft4->x0+TILE_WIDTH; ft4->y1=ft4->y0;
|
||||
ft4->x2=ft4->x0; ft4->y2=ft4->y0+TILE_HEIGHT;
|
||||
ft4->x3=ft4->x1; ft4->y3=ft4->y2;
|
||||
ft4->x0=x0 ; ft4->y0=y0;
|
||||
ft4->x1=x1 ; ft4->y1=y0;
|
||||
ft4->x2=x0 ; ft4->y2=y1;
|
||||
ft4->x3=x1 ; ft4->y3=y1;
|
||||
*(u16*)&ft4->u0=*(u16*)ThisTile->uv0;
|
||||
*(u16*)&ft4->u1=*(u16*)ThisTile->uv1;
|
||||
*(u16*)&ft4->u2=*(u16*)ThisTile->uv2;
|
||||
*(u16*)&ft4->u3=*(u16*)ThisTile->uv3;
|
||||
setRGB0(ft4,255,255,255);
|
||||
AddPrimToList(ft4,0);
|
||||
}
|
||||
else
|
||||
|
@ -123,37 +109,12 @@ sTileMapElem *ThisElem=Map;
|
|||
}
|
||||
}
|
||||
ThisElem++;
|
||||
XTileOfs+=TILE_WIDTH;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
void CLayerTile::render()
|
||||
{
|
||||
int ListSize=186;
|
||||
sTri *Tri=TriList;
|
||||
POLY_FT3 *ft3;
|
||||
POLY_FT4 *ft4;
|
||||
sTile *ThisTile=TileList;
|
||||
|
||||
int X,Y;
|
||||
X=XOfs;
|
||||
Y=YOfs;
|
||||
for (int i=0; i<ListSize; i++)
|
||||
{
|
||||
if (ThisTile->TriCount)
|
||||
{
|
||||
}
|
||||
ThisTile++;
|
||||
X+=16;
|
||||
if (X>(512-64))
|
||||
{
|
||||
X=XOfs;
|
||||
Y+=12;
|
||||
}
|
||||
YTileOfs+=TILE_HEIGHT;
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
void CLayerTile::think(int _frames)
|
||||
{
|
||||
|
|
|
@ -22,8 +22,6 @@ public:
|
|||
CLayerTile(sLayerHdr *Hdr,sTile *_TileList,sTri *_TriList,sQuad *_QuadList,sVtx *_VtxList);
|
||||
~CLayerTile();
|
||||
|
||||
static int GetLayerType(int SubType);
|
||||
|
||||
void init();
|
||||
void shutdown();
|
||||
void render();
|
||||
|
|
|
@ -6,19 +6,25 @@
|
|||
#include "fileio\fileio.h"
|
||||
#include "utils\utils.h"
|
||||
#include "gfx\tpage.h"
|
||||
#include "gfx\prim.h"
|
||||
#include <DStructs.h>
|
||||
|
||||
#include "level\level.h"
|
||||
#include "level\layer.h"
|
||||
#include "level\layertile.h"
|
||||
|
||||
#include "pad\pads.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
CLevel::CLevel()
|
||||
{
|
||||
for (int i=0; i<CLayer::LAYER_TYPE_MAX; i++)
|
||||
{
|
||||
LayerList[i]=0;
|
||||
TileLayers[i]=0;
|
||||
}
|
||||
DAVE_DBGMSG("sizeof(POLY_FT4)=%i\n",sizeof(POLY_FT4));
|
||||
DAVE_DBGMSG("sizeof(SPRT)=%i\n",sizeof(SPRT));
|
||||
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -26,7 +32,7 @@ CLevel::~CLevel()
|
|||
{
|
||||
for (int i=0; i<CLayer::LAYER_TYPE_MAX; i++)
|
||||
{
|
||||
if (LayerList[i]) delete LayerList[i];
|
||||
if (TileLayers[i]) delete TileLayers[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,50 +42,48 @@ void CLevel::init()
|
|||
LevelHdr=(sLvlHdr *)CFileIO::loadFile(CHAPTER01_LEVEL01_LVL,"Level Data");
|
||||
TPLoadTex(CHAPTER01_LEVEL01_TEX);
|
||||
|
||||
LevelHdr->TriList=(sTri*)MakePtr(LevelHdr,(int)LevelHdr->TriList);
|
||||
LevelHdr->QuadList=(sQuad*)MakePtr(LevelHdr,(int)LevelHdr->QuadList);
|
||||
LevelHdr->VtxList=(sVtx*)MakePtr(LevelHdr,(int)LevelHdr->VtxList);
|
||||
LevelHdr->TileList=(sTile*)MakePtr(LevelHdr,(int)LevelHdr->TileList);
|
||||
DAVE_DBGMSG("LayerCount=%i\n",GetLayerCount());
|
||||
LoadLayers();
|
||||
|
||||
for (int i=0; i<CLayer::LAYER_TYPE_MAX; i++)
|
||||
{
|
||||
if (LayerList[i]) LayerList[i]->init();
|
||||
}
|
||||
|
||||
initLayers();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void CLevel::LoadLayers()
|
||||
void CLevel::initLayers()
|
||||
{
|
||||
int LayerCount=GetLayerCount();
|
||||
int *HdrOfs=(int*)MakePtr(LevelHdr,sizeof(sLvlHdr));
|
||||
sTri *TriList=(sTri*)MakePtr(LevelHdr,LevelHdr->TriList);
|
||||
sQuad *QuadList=(sQuad*)MakePtr(LevelHdr,LevelHdr->QuadList);
|
||||
sVtx *VtxList=(sVtx*)MakePtr(LevelHdr,LevelHdr->VtxList);
|
||||
sTile *TileList=(sTile*)MakePtr(LevelHdr,LevelHdr->TileList);
|
||||
|
||||
for (int i=0; i<LayerCount; i++)
|
||||
// Back
|
||||
if (LevelHdr->BackLayer)
|
||||
{
|
||||
sLayerHdr *Hdr=(sLayerHdr*)MakePtr(LevelHdr,*HdrOfs++);
|
||||
DAVE_DBGMSG("T:%i S:%i W:%i H:%i\n",Hdr->Type,Hdr->SubType,Hdr->Width,Hdr->Height);
|
||||
int LayerType=CLayer::GetLayerType(Hdr->Type,Hdr->SubType);
|
||||
switch (LayerType)
|
||||
{
|
||||
case CLayer::LAYER_TYPE_TILE_BACK:
|
||||
LayerList[LayerType]=new ("Back Layer") CLayerTile(Hdr,LevelHdr->TileList, LevelHdr->TriList, LevelHdr->QuadList, LevelHdr->VtxList);
|
||||
break;
|
||||
case CLayer::LAYER_TYPE_TILE_MID:
|
||||
LayerList[LayerType]=new ("Mid Layer") CLayerTile(Hdr,LevelHdr->TileList, LevelHdr->TriList, LevelHdr->QuadList, LevelHdr->VtxList);
|
||||
break;
|
||||
case CLayer::LAYER_TYPE_TILE_ACTION:
|
||||
LayerList[LayerType]=new ("Action Layer") CLayerTile(Hdr,LevelHdr->TileList, LevelHdr->TriList, LevelHdr->QuadList, LevelHdr->VtxList);
|
||||
break;
|
||||
case CLayer::LAYER_TYPE_TILE_FORE:
|
||||
LayerList[LayerType]=new ("Fore Layer") CLayerTile(Hdr,LevelHdr->TileList, LevelHdr->TriList, LevelHdr->QuadList, LevelHdr->VtxList);
|
||||
break;
|
||||
default:
|
||||
DAVE_DBGMSG("%i\n",LayerType);
|
||||
ASSERT(!"Unknown Layer");
|
||||
break;
|
||||
sLayerHdr *Layer=(sLayerHdr*)MakePtr(LevelHdr,LevelHdr->BackLayer);
|
||||
CLayer *NewLayer=new ("Back Layer") CLayerTile(Layer, TileList, TriList, QuadList, VtxList);
|
||||
NewLayer->init();
|
||||
TileLayers[CLayer::LAYER_TYPE_TILE_BACK]=NewLayer;
|
||||
}
|
||||
// Mid
|
||||
if (LevelHdr->MidLayer)
|
||||
{
|
||||
sLayerHdr *Layer=(sLayerHdr*)MakePtr(LevelHdr,LevelHdr->MidLayer);
|
||||
CLayer *NewLayer=new ("Mid Layer") CLayerTile(Layer, TileList, TriList, QuadList, VtxList);
|
||||
NewLayer->init();
|
||||
TileLayers[CLayer::LAYER_TYPE_TILE_MID]=NewLayer;
|
||||
}
|
||||
// Action
|
||||
if (LevelHdr->ActionLayer)
|
||||
{
|
||||
sLayerHdr *Layer=(sLayerHdr*)MakePtr(LevelHdr,LevelHdr->ActionLayer);
|
||||
CLayer *NewLayer=new ("Action Layer") CLayerTile(Layer, TileList, TriList, QuadList, VtxList);
|
||||
NewLayer->init();
|
||||
TileLayers[CLayer::LAYER_TYPE_TILE_ACTION]=NewLayer;
|
||||
}
|
||||
// Fore
|
||||
if (LevelHdr->ForeLayer)
|
||||
{
|
||||
sLayerHdr *Layer=(sLayerHdr*)MakePtr(LevelHdr,LevelHdr->ForeLayer);
|
||||
CLayer *NewLayer=new ("Fore Layer") CLayerTile(Layer, TileList, TriList, QuadList, VtxList);
|
||||
NewLayer->init();
|
||||
TileLayers[CLayer::LAYER_TYPE_TILE_FORE]=NewLayer;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -89,21 +93,35 @@ void CLevel::shutdown()
|
|||
MemFree(LevelHdr);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
void CLevel::render()
|
||||
{
|
||||
for (int i=0; i<CLayer::LAYER_TYPE_MAX; i++)
|
||||
{
|
||||
if (LayerList[i]) LayerList[i]->render();
|
||||
if (TileLayers[i]) TileLayers[i]->render();
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
extern int MapX;
|
||||
extern int MapY;
|
||||
|
||||
void CLevel::think(int _frames)
|
||||
{
|
||||
int padh = PadGetHeld( 0 );
|
||||
|
||||
if (padh & PAD_LEFT) MapX+=4;
|
||||
if (padh & PAD_RIGHT) MapX-=4;
|
||||
if (padh & PAD_UP) MapY+=4;
|
||||
if (padh & PAD_DOWN) MapY-=4;
|
||||
|
||||
for (int i=0; i<CLayer::LAYER_TYPE_MAX; i++)
|
||||
{
|
||||
if (LayerList[i]) LayerList[i]->think(_frames);
|
||||
if (TileLayers[i]) TileLayers[i]->think(_frames);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,14 +21,13 @@ public:
|
|||
void render();
|
||||
void think(int _frames);
|
||||
|
||||
int GetLayerCount() {return(LevelHdr->LayerCount);}
|
||||
|
||||
|
||||
private:
|
||||
void LoadLayers();
|
||||
void initLayers();
|
||||
|
||||
sLvlHdr *LevelHdr;
|
||||
CLayer *LayerList[CLayer::LAYER_TYPE_MAX];
|
||||
|
||||
// Tile Layers
|
||||
CLayer *TileLayers[CLayer::LAYER_TYPE_MAX];
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue