This commit is contained in:
Daveo 2000-12-09 17:22:06 +00:00
parent 06bf236150
commit cd381e1694
7 changed files with 287 additions and 251 deletions

View File

@ -60,7 +60,6 @@ void PrimDisplay()
/*** Clipping ****************************************************************/ /*** Clipping ****************************************************************/
extern int FrameFlipFlag;
void PrimClip(RECT *R, u32 Depth) void PrimClip(RECT *R, u32 Depth)
{ {
DR_AREA *CPtr=(DR_AREA*)CurrPrim; DR_AREA *CPtr=(DR_AREA*)CurrPrim;

View File

@ -20,13 +20,13 @@
#define GPUCODE_MODE_SEMI_TRANS (1<<1) #define GPUCODE_MODE_SEMI_TRANS (1<<1)
// GPU Primitive codes. Please remember that 3 and 4 point lines require the pad field setting to 0x55555555. // GPU Primitive codes. Please remember that 3 and 4 point lines require the pad field setting to 0x55555555.
#define GPUCODE_POLY_F3 (0x20) #define GPUCODE_POLY_F3 (0x20)
#define GPUCODE_POLY_FT3 (0x24) #define GPUCODE_POLY_FT3 (0x24)
#define GPUCODE_POLY_G3 (0x30) #define GPUCODE_POLY_G3 (0x30)
#define GPUCODE_POLY_GT3 (0x34) #define GPUCODE_POLY_GT3 (0x34)
#define GPUCODE_POLY_F4 (0x28) #define GPUCODE_POLY_F4 (0x28)
#define GPUCODE_POLY_FT4 (0x2c) #define GPUCODE_POLY_FT4 (0x2c)
#define GPUCODE_POLY_G4 (0x38) #define GPUCODE_POLY_G4 (0x38)
#define GPUCODE_POLY_GT4 (0x3c) #define GPUCODE_POLY_GT4 (0x3c)
#define GPUCODE_SPRT (0x64) #define GPUCODE_SPRT (0x64)
@ -45,14 +45,14 @@
#define GPUCODE_LINE_F4 (0x4c) #define GPUCODE_LINE_F4 (0x4c)
#define GPUCODE_LINE_G4 (0x5c) #define GPUCODE_LINE_G4 (0x5c)
// GPU Primitive sizes excluding the tag word. This is NOT the same as sizeof(<primitive type>) // GPU Primitive sizes excluding the tag word. This is NOT the same as sizeof(<primitive type>) due to lack of tag word
#define GPUSIZE_POLY_F3 (4) #define GPUSIZE_POLY_F3 (4)
#define GPUSIZE_POLY_FT3 (7) #define GPUSIZE_POLY_FT3 (7)
#define GPUSIZE_POLY_G3 (6) #define GPUSIZE_POLY_G3 (6)
#define GPUSIZE_POLY_GT3 (9) #define GPUSIZE_POLY_GT3 (9)
#define GPUSIZE_POLY_F4 (5) #define GPUSIZE_POLY_F4 (5)
#define GPUSIZE_POLY_FT4 (9) #define GPUSIZE_POLY_FT4 (9)
#define GPUSIZE_POLY_G4 (8) #define GPUSIZE_POLY_G4 (8)
#define GPUSIZE_POLY_GT4 (12) #define GPUSIZE_POLY_GT4 (12)
#define GPUSIZE_SPRT (4) #define GPUSIZE_SPRT (4)
@ -73,190 +73,183 @@
#define GPUSIZE_DR_TPAGE (1) #define GPUSIZE_DR_TPAGE (1)
#define GPUSIZE_TPOLY_F3 (GPUSIZE_DR_TPAGE+GPUSIZE_POLY_F3+1) #define GPUSIZE_TPOLY_F3 (GPUSIZE_DR_TPAGE+GPUSIZE_POLY_F3)
#define GPUSIZE_TPOLY_F4 (GPUSIZE_DR_TPAGE+GPUSIZE_POLY_F4+1) #define GPUSIZE_TPOLY_F4 (GPUSIZE_DR_TPAGE+GPUSIZE_POLY_F4)
#define GPUSIZE_TPOLY_G3 (GPUSIZE_DR_TPAGE+GPUSIZE_POLY_G3+1) #define GPUSIZE_TPOLY_G3 (GPUSIZE_DR_TPAGE+GPUSIZE_POLY_G3)
#define GPUSIZE_TPOLY_G4 (GPUSIZE_DR_TPAGE+GPUSIZE_POLY_G4+1) #define GPUSIZE_TPOLY_G4 (GPUSIZE_DR_TPAGE+GPUSIZE_POLY_G4)
#define GPUSIZE_TLINE_F2 (GPUSIZE_DR_TPAGE+GPUSIZE_LINE_F3+1) #define GPUSIZE_TLINE_F2 (GPUSIZE_DR_TPAGE+GPUSIZE_LINE_F3)
#define GPUSIZE_TLINE_G2 (GPUSIZE_DR_TPAGE+GPUSIZE_LINE_G2+1) #define GPUSIZE_TLINE_G2 (GPUSIZE_DR_TPAGE+GPUSIZE_LINE_G2)
#define GPUSIZE_TLINE_F3 (GPUSIZE_DR_TPAGE+GPUSIZE_LINE_F3+1) #define GPUSIZE_TLINE_F3 (GPUSIZE_DR_TPAGE+GPUSIZE_LINE_F3)
#define GPUSIZE_TLINE_G3 (GPUSIZE_DR_TPAGE+GPUSIZE_LINE_G3+1) #define GPUSIZE_TLINE_G3 (GPUSIZE_DR_TPAGE+GPUSIZE_LINE_G3)
#define GPUSIZE_TLINE_F4 (GPUSIZE_DR_TPAGE+GPUSIZE_LINE_F4+1) #define GPUSIZE_TLINE_F4 (GPUSIZE_DR_TPAGE+GPUSIZE_LINE_F4)
#define GPUSIZE_TLINE_G4 (GPUSIZE_DR_TPAGE+GPUSIZE_LINE_G4+1) #define GPUSIZE_TLINE_G4 (GPUSIZE_DR_TPAGE+GPUSIZE_LINE_G4)
#define GPUSIZE_TSPRT (GPUSIZE_DR_TPAGE+GPUSIZE_SPRT+1) #define GPUSIZE_TSPRT (GPUSIZE_DR_TPAGE+GPUSIZE_SPRT)
#define GPUSIZE_TSPRT_8 (GPUSIZE_DR_TPAGE+GPUSIZE_SPRT_8+1) #define GPUSIZE_TSPRT_8 (GPUSIZE_DR_TPAGE+GPUSIZE_SPRT_8)
#define GPUSIZE_TSPRT_16 (GPUSIZE_DR_TPAGE+GPUSIZE_SPRT_16+1) #define GPUSIZE_TSPRT_16 (GPUSIZE_DR_TPAGE+GPUSIZE_SPRT_16)
#define GPUSIZE_TTILE (GPUSIZE_DR_TPAGE+GPUSIZE_TILE+1) #define GPUSIZE_TTILE (GPUSIZE_DR_TPAGE+GPUSIZE_TILE)
#define GPUSIZE_TTILE_1 (GPUSIZE_DR_TPAGE+GPUSIZE_TILE_1+1) #define GPUSIZE_TTILE_1 (GPUSIZE_DR_TPAGE+GPUSIZE_TILE_1)
#define GPUSIZE_TTILE_8 (GPUSIZE_DR_TPAGE+GPUSIZE_TILE_8+1) #define GPUSIZE_TTILE_8 (GPUSIZE_DR_TPAGE+GPUSIZE_TILE_8)
#define GPUSIZE_TTILE_16 (GPUSIZE_DR_TPAGE+GPUSIZE_TILE_16+1) #define GPUSIZE_TTILE_16 (GPUSIZE_DR_TPAGE+GPUSIZE_TILE_16)
#define GPU_COLOUR_MASK (0x00ffffff)
#define GPU_CODE_MASK (0xff000000)
#define GPU_CODE_SHIFT (24)
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Macros // Macros
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
#define setTDrawTPageSize(p,s) setlen((p), (s)), (p)->t_code[0] = _get_mode(0,1,0) #define setTDrawTPageSize(p,s) setlen((p), (s)), (p)->t_code = _get_mode(0,1,0)
#define setTDrawTPage(p) setTDrawTPageSize((p), 1) #define setTDrawTPage(p) setTDrawTPageSize((p), 1)
#define setTPolyF3(p) setTDrawTPageSize((p), GPUSIZE_TPOLY_F3), setcode(&((p)->tag_poly), GPUCODE_POLY_F3), ((p)->tag_poly)=0 #define setTPolyF3(p) setTDrawTPageSize((p), GPUSIZE_TPOLY_F3), ((p)->code)=GPUCODE_POLY_F3
#define setTPolyF4(p) setTDrawTPageSize((p), GPUSIZE_TPOLY_F4), setcode(&((p)->tag_poly), GPUCODE_POLY_F4), ((p)->tag_poly)=0 #define setTPolyF4(p) setTDrawTPageSize((p), GPUSIZE_TPOLY_F4), ((p)->code)=GPUCODE_POLY_F4
#define setTPolyG3(p) setTDrawTPageSize((p), GPUSIZE_TPOLY_G3), setcode(&((p)->tag_poly), GPUCODE_POLY_G3), ((p)->tag_poly)=0 #define setTPolyG3(p) setTDrawTPageSize((p), GPUSIZE_TPOLY_G3), ((p)->code)=GPUCODE_POLY_G3
#define setTPolyG4(p) setTDrawTPageSize((p), GPUSIZE_TPOLY_G4), setcode(&((p)->tag_poly), GPUCODE_POLY_G4), ((p)->tag_poly)=0 #define setTPolyG4(p) setTDrawTPageSize((p), GPUSIZE_TPOLY_G4), ((p)->code)=GPUCODE_POLY_G4
#define setTLineF2(p) setTDrawTPageSize((p), GPUSIZE_TLINE_F2), setcode(&((p)->tag_poly), GPUCODE_LINE_F2), ((p)->tag_poly)=0 #define setTLineF2(p) setTDrawTPageSize((p), GPUSIZE_TLINE_F2), ((p)->code)=GPUCODE_LINE_F2
#define setTLineF3(p) setTDrawTPageSize((p), GPUSIZE_TLINE_F3), setcode(&((p)->tag_poly), GPUCODE_LINE_F3), ((p)->tag_poly)=0, ((p)->pad)=0x55555555 #define setTLineG2(p) setTDrawTPageSize((p), GPUSIZE_TLINE_G2), ((p)->code)=GPUCODE_LINE_G2
#define setTLineF4(p) setTDrawTPageSize((p), GPUSIZE_TLINE_F4), setcode(&((p)->tag_poly), GPUCODE_LINE_F4), ((p)->tag_poly)=0, ((p)->pad)=0x55555555 #define setTLineF3(p) setTDrawTPageSize((p), GPUSIZE_TLINE_F3), ((p)->code)=GPUCODE_LINE_F3, ((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), ((p)->code)=GPUCODE_LINE_G3, ((p)->pad)=0x55555555, ((p)->p2)=0
#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), ((p)->code)=GPUCODE_LINE_F4, ((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 setTLineG4(p) setTDrawTPageSize((p), GPUSIZE_TLINE_G4), ((p)->code)=GPUCODE_LINE_G4, ((p)->pad)=0x55555555, ((p)->p2)=0, ((p)->p3)=0
#define setTSprt(p) setTDrawTPageSize((p), GPUSIZE_TSPRT), setcode(&((p)->tag_poly), GPUCODE_SPRT), ((p)->tag_poly)=0 #define setTSprt(p) setTDrawTPageSize((p), GPUSIZE_TSPRT), ((p)->code)=GPUCODE_SPRT
#define setTSprt8(p) setTDrawTPageSize((p), GPUSIZE_TSPRT_8), setcode(&((p)->tag_poly), GPUCODE_SPRT_8), ((p)->tag_poly)=0 #define setTSprt8(p) setTDrawTPageSize((p), GPUSIZE_TSPRT_8), ((p)->code)=GPUCODE_SPRT_8
#define setTSprt16(p) setTDrawTPageSize((p), GPUSIZE_TSPRT_16), setcode(&((p)->tag_poly), GPUCODE_SPRT_16), ((p)->tag_poly)=0 #define setTSprt16(p) setTDrawTPageSize((p), GPUSIZE_TSPRT_16), ((p)->code)=GPUCODE_SPRT_16
#define setTTile(p) setTDrawTPageSize((p), GPUSIZE_TTILE), setcode(&((p)->tag_poly), GPUCODE_TILE), ((p)->tag_poly)=0 #define setTTile(p) setTDrawTPageSize((p), GPUSIZE_TTILE), ((p)->code)=GPUCODE_TILE
#define setTTile1(p) setTDrawTPageSize((p), GPUSIZE_TTILE_1), setcode(&((p)->tag_poly), GPUCODE_TILE_1), ((p)->tag_poly)=0 #define setTTile1(p) setTDrawTPageSize((p), GPUSIZE_TTILE_1), ((p)->code)=GPUCODE_TILE_1
#define setTTile8(p) setTDrawTPageSize((p), GPUSIZE_TTILE_8), setcode(&((p)->tag_poly), GPUCODE_TILE_8), ((p)->tag_poly)=0 #define setTTile8(p) setTDrawTPageSize((p), GPUSIZE_TTILE_8), ((p)->code)=GPUCODE_TILE_8
#define setTTile16(p) setTDrawTPageSize((p), GPUSIZE_TTILE_16), setcode(&((p)->tag_poly), GPUCODE_TILE_16), ((p)->tag_poly)=0 #define setTTile16(p) setTDrawTPageSize((p), GPUSIZE_TTILE_16), ((p)->code)=GPUCODE_TILE_16
#define setTSemiTrans(p, abe) setSemiTrans(&((p)->tag_poly), (abe)) #define setTSemiTrans(p, abe) setSemiTrans(&((p)->t_code), (abe))
#define setTABRMode(p,abr) (p)->t_code[0] = _get_mode(0,1,(abr<<5)) #define setTSetShadeTex(p, st) setShadeTex(&((p)->t_code), (st))
#define setTSprtTPage(p,tp) (p)->t_code[0] = _get_mode(0,1,(tp)) #define setTABRMode(p,abr) ((p)->t_code) = _get_mode(0,1,(abr<<5))
#define setTSprtTPageABR(p,t,a) (p)->t_code[0] = _get_mode(0,1,(((t)&0x19f)|((a)<<5))) #define setTSprtTPage(p,tp) ((p)->t_code) = _get_mode(0,1,(tp))
#define setTSprtTPageABR(p,t,a) ((p)->t_code) = _get_mode(0,1,(((t)&0x19f)|((a)<<5)))
#define addPrimSize(ot,p,size) (p)->tag = ((*(ot))|((size)<<24)), *((ot)) = (((u_long)(p)<<8)>>8)
#define addPrimSize(ot,p,size) ((p)->tag) = ((*(ot))|((size)<<24)), *((ot)) = (((u_long)(p)<<8)>>8)
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Structures // Structures
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
struct TPOLY_F3 // Flat Triangle with ABR control typedef struct __tpoly_f3
{ {
u_long tag; u_long tag;
u_long t_code[1]; u_long t_code;
u_long tag_poly;
u_char r0, g0, b0, code; u_char r0, g0, b0, code;
short x0, y0; short x0, y0;
short x1, y1; short x1, y1;
short x2, y2; short x2, y2;
}; } TPOLY_F3; // Flat Triangle with ABR control
struct TPOLY_F4 // Flat Quadrangle with ABR control typedef struct __tpoly_f4
{ {
u_long tag; u_long tag;
u_long t_code[1]; u_long t_code;
u_long tag_poly;
u_char r0, g0, b0, code; u_char r0, g0, b0, code;
short x0, y0; short x0, y0;
short x1, y1; short x1, y1;
short x2, y2; short x2, y2;
short x3, y3; short x3, y3;
}; } TPOLY_F4; // Flat Quadrangle with ABR control
struct TPOLY_G3 // Gouraud Triangle with ABR control typedef struct __tpoly_g3
{ {
u_long tag; u_long tag;
u_long t_code[1]; u_long t_code;
u_long tag_poly;
u_char r0, g0, b0, code; u_char r0, g0, b0, code;
short x0, y0; short x0, y0;
u_char r1, g1, b1, pad1; u_char r1, g1, b1, pad1;
short x1, y1; short x1, y1;
u_char r2, g2, b2, pad2; u_char r2, g2, b2, pad2;
short x2, y2; short x2, y2;
}; } TPOLY_G3; // Gouraud Triangle with ABR control
struct TPOLY_G4 // Gouraud Quadrangle with ABR control typedef struct __tpoly_g4
{ {
u_long tag; u_long tag;
u_long t_code[1]; u_long t_code;
u_long tag_poly;
u_char r0, g0, b0, code; u_char r0, g0, b0, code;
short x0, y0; short x0, y0;
u_char r1, g1, b1, pad1; u_char r1, g1, b1, pad1;
short x1, y1; short x1, y1;
u_char r2, g2, b2, pad2; u_char r2, g2, b2, pad2;
short x2, y2; short x2, y2;
u_char r3, g3, b3, pad3; u_char r3, g3, b3, pad3;
short x3, y3; short x3, y3;
}; } TPOLY_G4; // Gouraud Quadrangle with ABR control
// //
// Line Primitive Definitions // Line Primitive Definitions
// //
struct TLINE_F2 // Unconnected Flat Line with ABR control typedef struct __tline_f2
{ {
u_long tag; u_long tag;
u_long t_code[1]; u_long t_code;
u_long tag_poly;
u_char r0, g0, b0, code; u_char r0, g0, b0, code;
short x0, y0; short x0, y0;
short x1, y1; short x1, y1;
}; } TLINE_F2; // Unconnected Flat Line with ABR control
struct TLINE_G2 // Unconnected Gouraud Line with ABR control typedef struct __tline_g2
{ {
u_long tag; u_long tag;
u_long t_code[1]; u_long t_code;
u_long tag_poly;
u_char r0, g0, b0, code; u_char r0, g0, b0, code;
short x0, y0; short x0, y0;
u_char r1, g1, b1, p1; u_char r1, g1, b1, p1;
short x1, y1; short x1, y1;
}; } TLINE_G2; // Unconnected Gouraud Line with ABR control
struct TLINE_F3 // 2 connected Flat Line with ABR control typedef struct __tline_f3
{ {
u_long tag; u_long tag;
u_long t_code[1]; u_long t_code;
u_long tag_poly;
u_char r0, g0, b0, code; u_char r0, g0, b0, code;
short x0, y0; short x0, y0;
short x1, y1; short x1, y1;
short x2, y2; short x2, y2;
u_long pad; u_long pad;
}; } TLINE_F3; // 2 connected Flat Line with ABR control
struct TLINE_G3 // 2 connected Gouraud Line with ABR control typedef struct __tline_g3
{ {
u_long tag; u_long tag;
u_long t_code[1]; u_long t_code;
u_long tag_poly;
u_char r0, g0, b0, code; u_char r0, g0, b0, code;
short x0, y0; short x0, y0;
u_char r1, g1, b1, p1; u_char r1, g1, b1, p1;
short x1, y1; short x1, y1;
u_char r2, g2, b2, p2; u_char r2, g2, b2, p2;
short x2, y2; short x2, y2;
u_long pad; u_long pad;
}; } TLINE_G3; // 2 connected Gouraud Line with ABR control
struct TLINE_F4 // 3 connected Flat Line Quadrangle with ABR control typedef struct __tline_f4
{ {
u_long tag; u_long tag;
u_long t_code[1]; u_long t_code;
u_long tag_poly;
u_char r0, g0, b0, code; u_char r0, g0, b0, code;
short x0, y0; short x0, y0;
short x1, y1; short x1, y1;
short x2, y2; short x2, y2;
short x3, y3; short x3, y3;
u_long pad; u_long pad;
}; } TLINE_F4; // 3 connected Flat Line Quadrangle with ABR control
struct TLINE_G4 // 3 connected Gouraud Line with ABR control typedef struct __tline_g4
{ {
u_long tag; u_long tag;
u_long t_code[1]; u_long t_code;
u_long tag_poly;
u_char r0, g0, b0, code; u_char r0, g0, b0, code;
short x0, y0; short x0, y0;
u_char r1, g1, b1, p1; u_char r1, g1, b1, p1;
short x1, y1; short x1, y1;
u_char r2, g2, b2, p2; u_char r2, g2, b2, p2;
@ -264,82 +257,75 @@ struct TLINE_G4 // 3 connected Gouraud Line with ABR control
u_char r3, g3, b3, p3; u_char r3, g3, b3, p3;
short x3, y3; short x3, y3;
u_long pad; u_long pad;
}; } TLINE_G4; // 3 connected Gouraud Line with ABR control
// //
// Sprite Primitive Definitions // Sprite Primitive Definitions
// //
struct TSPRT // Free size Sprite with TPage/ABR control typedef struct __tsprt
{ {
u_long tag; u_long tag;
u_long t_code[1]; u_long t_code;
u_long tag_poly;
u_char r0, g0, b0, code; u_char r0, g0, b0, code;
short x0, y0; short x0, y0;
u_char u0, v0; u_short clut; u_char u0, v0; u_short clut;
short w, h; short w, h;
}; } TSPRT; // Free size Sprite with TPage/ABR control
struct TSPRT_16 // 16x16 Sprite with TPage/ABR control typedef struct __tsprt_16
{ {
u_long tag; u_long tag;
u_long t_code[1]; u_long t_code;
u_long tag_poly;
u_char r0, g0, b0, code; u_char r0, g0, b0, code;
short x0, y0; short x0, y0;
u_char u0, v0; u_short clut; u_char u0, v0; u_short clut;
}; } TSPRT_16; // 16x16 Sprite with TPage/ABR control
struct TSPRT_8 // 8x8 Sprite with TPage/ABR control typedef struct __tsprt_8
{ {
u_long tag; u_long tag;
u_long t_code[1]; u_long t_code;
u_long tag_poly;
u_char r0, g0, b0, code; u_char r0, g0, b0, code;
short x0, y0; short x0, y0;
u_char u0, v0; u_short clut; u_char u0, v0; u_short clut;
}; } TSPRT_8; // 8x8 Sprite with TPage/ABR control
// //
// Tile Primitive Definitions // Tile Primitive Definitions
// //
struct TTILE // free size Tile with ABR control typedef struct __ttile
{ {
u_long tag; u_long tag;
u_long t_code[1]; u_long t_code;
u_long tag_poly;
u_char r0, g0, b0, code; u_char r0, g0, b0, code;
short x0, y0; short x0, y0;
short w, h; short w, h;
}; } TTILE; // free size Tile with ABR control
struct TTILE_16 // 16x16 Tile with ABR control typedef struct __ttile16
{ {
u_long tag; u_long tag;
u_long t_code[1]; u_long t_code;
u_long tag_poly;
u_char r0, g0, b0, code; u_char r0, g0, b0, code;
short x0, y0; short x0, y0;
}; } TTILE_16; // 16x16 Tile with ABR control
struct TTILE_8 // 8x8 Tile with ABR control typedef struct __ttile_8
{ {
u_long tag; u_long tag;
u_long t_code[1]; u_long t_code;
u_long tag_poly;
u_char r0, g0, b0, code; u_char r0, g0, b0, code;
short x0, y0; short x0, y0;
}; } TTILE_8; // 8x8 Tile with ABR control
struct TTILE_1 // 1x1 Tile with ABR control typedef struct __ttile_1
{ {
u_long tag; u_long tag;
u_long t_code[1]; u_long t_code;
u_long tag_poly;
u_char r0, g0, b0, code; u_char r0, g0, b0, code;
short x0, y0; short x0, y0;
}; } TTILE_1; // 1x1 Tile with ABR control
#endif #endif

View File

@ -5,22 +5,17 @@
#include "system\global.h" #include "system\global.h"
#include <DStructs.h> #include <DStructs.h>
#include "utils\utils.h" #include "utils\utils.h"
#include "system\vid.h"
#include "gfx\prim.h" #include "gfx\prim.h"
#include "Layer.h"
#include "LayerTile.h" #include "LayerTile.h"
enum /*****************************************************************************/
{ /*****************************************************************************/
TILE_WIDTH=16, /*****************************************************************************/
TILE_HEIGHT=16, CLayerTile::CLayerTile(sLayerHdr *Hdr,sTile *_TileList,sTri *_TriList,sQuad *_QuadList,sVtx *_VtxList)
};
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
CLayerTile::CLayerTile(sLayerHdr *Hdr,sTile *_TileList,sTri *_TriList,sQuad *_QuadList,sVtx *_VtxList) : CLayer(Hdr)
{ {
LayerHdr=Hdr;
TileList=_TileList; TileList=_TileList;
TriList=_TriList; TriList=_TriList;
QuadList=_QuadList; QuadList=_QuadList;
@ -32,91 +27,103 @@ CLayerTile::CLayerTile(sLayerHdr *Hdr,sTile *_TileList,sTri *_TriList,sQuad *_Qu
/*****************************************************************************/ /*****************************************************************************/
CLayerTile::~CLayerTile() CLayerTile::~CLayerTile()
{ {
} if (TileMap2d[0].List) MemFree(TileMap2d[0].List);
if (TileMap2d[1].List) MemFree(TileMap2d[1].List);
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
void CLayerTile::init()
{
} }
/*****************************************************************************/ /*****************************************************************************/
void CLayerTile::shutdown() // NEED TO UPDATE FOR DIFF MAP POS's
void CLayerTile::InitTileMap2d(int InitX,int InitY,int Width,int Height)
{ {
} int Size=Width*Height;
int MapWidth=GetWidth();
int MapHeight=GetWidth();
/*****************************************************************************/ ASSERT(Width>=SCREEN_TILE_WIDTH);
int MapX=0; ASSERT(Height>=SCREEN_TILE_HEIGHT);
int MapY=0;
TileMapWidth=Width;
TileMapHeight=Height;
void CLayerTile::render() for (int Buffer=0; Buffer<2; Buffer++)
{
int Width=32;//GetWidth();
int Height=21;//GetHeight();
POLY_FT4 *ft4;
sTileMapElem *ThisElem=Map;
int XOfs=MapX;
int YOfs=MapY;
int XTileOfs,YTileOfs;
if (LayerHdr->SubType==LAYER_TILE_SUBTYPE_BACK)
{ {
XOfs/=4; sTileMapElem *MapPtr=Map;
YOfs/=4; sTileMap2dElem *List=(sTileMap2dElem*) MemAlloc(Size*sizeof(sTileMap2dElem),"2d TileMap");
} TileMap2d[Buffer].List=List;
if (LayerHdr->SubType==LAYER_TILE_SUBTYPE_MID)
{
XOfs/=2;
YOfs/=2;
}
YTileOfs=YOfs; for (int Y=0; Y<Height; Y++)
for (int Y=0; Y<Height; Y++)
{
XTileOfs=XOfs;
for (int X=0; X<Width; X++)
{ {
if (ThisElem->Tile) for (int X=0; X<Width; X++)
{ {
sTile *ThisTile=&TileList[ThisElem->Tile]; sTileMap2dElem *ThisElem=&List[X+(Y*Width)];
if (ThisTile->TPage) // Tile prim
{ TSPRT_16 *ThisTile=&ThisElem->Tile;
s16 x0=XTileOfs; sTile *SrcTile=&TileList[MapPtr->Tile];
s16 x1=XTileOfs+TILE_WIDTH; setTSprt16(ThisTile);
s16 y0=YTileOfs; setTSprtTPage(ThisTile,SrcTile->TPage);
s16 y1=YTileOfs+TILE_HEIGHT; ThisTile->r0=128;
ThisTile->g0=128;
ThisTile->b0=128;
ThisTile->clut=SrcTile->Clut;
ThisTile->u0=SrcTile->uv0[0];
ThisTile->v0=SrcTile->uv0[1];
ft4=GetPrimFT4(); // Table
setShadeTex(ft4,1); int TableR=(X+1) % Width;
ft4->tpage=ThisTile->TPage; int TableD=(Y+1) % Height;
ft4->clut=ThisTile->Clut; ThisElem->Right=&List[TableR+(Y*Width)];
ft4->x0=x0 ; ft4->y0=y0; ThisElem->Down=&List[X+(TableD*Width)];
ft4->x1=x1 ; ft4->y1=y0;
ft4->x2=x0 ; ft4->y2=y1; MapPtr++;
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;
AddPrimToList(ft4,0);
}
else
{
}
} }
ThisElem++;
XTileOfs+=TILE_WIDTH;
} }
YTileOfs+=TILE_HEIGHT;
} }
} }
/*****************************************************************************/ /*****************************************************************************/
void CLayerTile::think(int _frames)
void CLayerTile::RenderTileMap2d(int MapX,int MapY)
{ {
sTileMap2dElem *Table=TileMap2d[FrameFlipFlag].List;
int XShift,YShift;
u32 XYPos;
const u32 XInc=16<<0;
const u32 YInc=16<<16;
// Setup shift bits of pos
XShift=15-(MapX&15);
YShift=15-(MapY&15);
XYPos=YShift<<16 | XShift<<0;
MapX>>=4;
MapY>>=4;
// Calc Start pos (fully wrapping)
/**/ MapX=MapX % TileMapWidth;
/**/ MapY=MapY % TileMapHeight;
/**/ Table+=MapX;
/**/ Table+=MapY*TileMapWidth;
// Render it!!
for (int TileY=0; TileY<SCREEN_TILE_HEIGHT; TileY++)
{
sTileMap2dElem *TableDown=Table->Down;
u32 XYPosDown=XYPos+YInc;
for (int TileX=0; TileX<SCREEN_TILE_WIDTH; TileX++)
{
TSPRT_16 *TileData=&Table->Tile;
*(u32*)&TileData->x0=XYPos;
/**/ //AddPrimToList(TileData,0);
/**/ AddPrim(OtPtr,TileData);
Table=Table->Right;
XYPos+=XInc;
}
Table=TableDown;
XYPos=XYPosDown;
}
} }
/*****************************************************************************/

View File

@ -7,33 +7,68 @@
/*****************************************************************************/ /*****************************************************************************/
class CLayerTile : public CLayer struct sTileMap2dElem
{
TSPRT_16 Tile;
sTileMap2dElem *Right;
sTileMap2dElem *Down;
};
struct sTileMap2d
{
int X,Y;
sTileMap2dElem *List;
};
/*****************************************************************************/
class CLayerTile
{ {
public: public:
enum LAYER_TILE_SUBTYPE enum LAYER_TILE_TYPE
{ { // Stored reverse for rendering :o)
LAYER_TILE_SUBTYPE_BACK=0, LAYER_TILE_TYPE_FORE,
LAYER_TILE_SUBTYPE_MID, LAYER_TILE_TYPE_ACTION,
LAYER_TILE_SUBTYPE_ACTION, LAYER_TILE_TYPE_MID,
LAYER_TILE_SUBTYPE_FORE, LAYER_TILE_TYPE_BACK,
LAYER_TILE_SUBTYPE_MAX LAYER_TILE_TYPE_MAX
}; };
enum
{
TILE_WIDTH=16,
TILE_HEIGHT=16,
SCREEN_TILE_WIDTH=32, // fast bits ops :o)
SCREEN_TILE_HEIGHT=16, // fast bits ops :o)
SCREEN_TILE_SIZE=SCREEN_TILE_WIDTH*SCREEN_TILE_HEIGHT
};
CLayerTile(sLayerHdr *Hdr,sTile *_TileList,sTri *_TriList,sQuad *_QuadList,sVtx *_VtxList); CLayerTile(sLayerHdr *Hdr,sTile *_TileList,sTri *_TriList,sQuad *_QuadList,sVtx *_VtxList);
~CLayerTile(); virtual ~CLayerTile();
void init(); virtual void init()=0;
void shutdown(); virtual void shutdown()=0;
void render(); virtual void render()=0;
void think(int _frames); virtual void think(int _frames)=0;
private: void InitTileMap2d(int X,int Y,int Width=SCREEN_TILE_WIDTH,int Height=SCREEN_TILE_HEIGHT);
int GetWidth() {return(LayerHdr->Width);}
int GetHeight() {return(LayerHdr->Height);}
protected:
void RenderTileMap2d(int X,int Y);
sLayerHdr *LayerHdr;
sTile *TileList; sTile *TileList;
sTri *TriList; sTri *TriList;
sQuad *QuadList; sQuad *QuadList;
sVtx *VtxList; sVtx *VtxList;
sTileMapElem *Map; sTileMapElem *Map;
int TileMapWidth,TileMapHeight;
sTileMap2d TileMap2d[2]; // Double Buffered
}; };

View File

@ -10,27 +10,27 @@
#include <DStructs.h> #include <DStructs.h>
#include "level\level.h" #include "level\level.h"
#include "level\layer.h"
#include "level\layertile.h" #include "level\layertile.h"
#include "level\layerback.h"
#include "pad\pads.h" #include "pad\pads.h"
/*****************************************************************************/ /*****************************************************************************/
CLevel::CLevel() CLevel::CLevel()
{ {
for (int i=0; i<CLayer::LAYER_TYPE_MAX; i++) for (int i=0; i<CLayerTile::LAYER_TILE_TYPE_MAX; i++)
{ {
TileLayers[i]=0; TileLayers[i]=0;
} }
DAVE_DBGMSG("sizeof(POLY_FT4)=%i\n",sizeof(POLY_FT4)); DAVE_DBGMSG("sizeof(POLY_FT4)=%i",sizeof(POLY_FT4));
DAVE_DBGMSG("sizeof(SPRT)=%i\n",sizeof(SPRT)); DAVE_DBGMSG("sizeof(TSPRT)=%i",sizeof(TSPRT));
} }
/*****************************************************************************/ /*****************************************************************************/
CLevel::~CLevel() CLevel::~CLevel()
{ {
for (int i=0; i<CLayer::LAYER_TYPE_MAX; i++) for (int i=0; i<CLayerTile::LAYER_TILE_TYPE_MAX; i++)
{ {
if (TileLayers[i]) delete TileLayers[i]; if (TileLayers[i]) delete TileLayers[i];
} }
@ -57,34 +57,36 @@ sTile *TileList=(sTile*)MakePtr(LevelHdr,LevelHdr->TileList);
if (LevelHdr->BackLayer) if (LevelHdr->BackLayer)
{ {
sLayerHdr *Layer=(sLayerHdr*)MakePtr(LevelHdr,LevelHdr->BackLayer); sLayerHdr *Layer=(sLayerHdr*)MakePtr(LevelHdr,LevelHdr->BackLayer);
CLayer *NewLayer=new ("Back Layer") CLayerTile(Layer, TileList, TriList, QuadList, VtxList); CLayerTile *NewLayer=new ("Back Layer") CLayerBack(Layer, TileList);
NewLayer->init(); NewLayer->init();
TileLayers[CLayer::LAYER_TYPE_TILE_BACK]=NewLayer; TileLayers[CLayerTile::LAYER_TILE_TYPE_BACK]=NewLayer;
} }
/*
// Mid // Mid
if (LevelHdr->MidLayer) if (LevelHdr->MidLayer)
{ {
sLayerHdr *Layer=(sLayerHdr*)MakePtr(LevelHdr,LevelHdr->MidLayer); sLayerHdr *Layer=(sLayerHdr*)MakePtr(LevelHdr,LevelHdr->MidLayer);
CLayer *NewLayer=new ("Mid Layer") CLayerTile(Layer, TileList, TriList, QuadList, VtxList); CLayerTile *NewLayer=new ("Mid Layer") CLayerTile(Layer, TileList, TriList, QuadList, VtxList);
NewLayer->init(); NewLayer->init();
TileLayers[CLayer::LAYER_TYPE_TILE_MID]=NewLayer; TileLayers[CLayerTile::LAYER_TILE_TYPE_MID]=NewLayer;
} }
// Action // Action
if (LevelHdr->ActionLayer) if (LevelHdr->ActionLayer)
{ {
sLayerHdr *Layer=(sLayerHdr*)MakePtr(LevelHdr,LevelHdr->ActionLayer); sLayerHdr *Layer=(sLayerHdr*)MakePtr(LevelHdr,LevelHdr->ActionLayer);
CLayer *NewLayer=new ("Action Layer") CLayerTile(Layer, TileList, TriList, QuadList, VtxList); CLayerTile *NewLayer=new ("Action Layer") CLayerTile(Layer, TileList, TriList, QuadList, VtxList);
NewLayer->init(); NewLayer->init();
TileLayers[CLayer::LAYER_TYPE_TILE_ACTION]=NewLayer; TileLayers[CLayerTile::LAYER_TILE_TYPE_ACTION]=NewLayer;
} }
// Fore // Fore
if (LevelHdr->ForeLayer) if (LevelHdr->ForeLayer)
{ {
sLayerHdr *Layer=(sLayerHdr*)MakePtr(LevelHdr,LevelHdr->ForeLayer); sLayerHdr *Layer=(sLayerHdr*)MakePtr(LevelHdr,LevelHdr->ForeLayer);
CLayer *NewLayer=new ("Fore Layer") CLayerTile(Layer, TileList, TriList, QuadList, VtxList); CLayerTile *NewLayer=new ("Fore Layer") CLayerTile(Layer, TileList, TriList, QuadList, VtxList);
NewLayer->init(); NewLayer->init();
TileLayers[CLayer::LAYER_TYPE_TILE_FORE]=NewLayer; TileLayers[CLayerTile::LAYER_TILE_TYPE_FORE]=NewLayer;
} }
*/
} }
/*****************************************************************************/ /*****************************************************************************/
@ -98,7 +100,7 @@ void CLevel::shutdown()
/*****************************************************************************/ /*****************************************************************************/
void CLevel::render() void CLevel::render()
{ {
for (int i=0; i<CLayer::LAYER_TYPE_MAX; i++) for (int i=0; i<CLayerTile::LAYER_TILE_TYPE_MAX; i++)
{ {
if (TileLayers[i]) TileLayers[i]->render(); if (TileLayers[i]) TileLayers[i]->render();
} }
@ -109,17 +111,20 @@ void CLevel::render()
/*****************************************************************************/ /*****************************************************************************/
extern int MapX; extern int MapX;
extern int MapY; extern int MapY;
int MapSpd=8;
void CLevel::think(int _frames) void CLevel::think(int _frames)
{ {
int padh = PadGetHeld( 0 ); int padh = PadGetHeld( 0 );
if (padh & PAD_LEFT) MapX+=4; if (padh & PAD_LEFT) MapX-=MapSpd;
if (padh & PAD_RIGHT) MapX-=4; if (padh & PAD_RIGHT) MapX+=MapSpd;
if (padh & PAD_UP) MapY+=4; if (padh & PAD_UP) MapY-=MapSpd;
if (padh & PAD_DOWN) MapY-=4; if (padh & PAD_DOWN) MapY+=MapSpd;
for (int i=0; i<CLayer::LAYER_TYPE_MAX; i++) if (MapX<0) MapX=0;
if (MapY<0) MapY=0;
for (int i=0; i<CLayerTile::LAYER_TILE_TYPE_MAX; i++)
{ {
if (TileLayers[i]) TileLayers[i]->think(_frames); if (TileLayers[i]) TileLayers[i]->think(_frames);
} }

View File

@ -5,7 +5,7 @@
#ifndef __LEVEL_LEVEL_H__ #ifndef __LEVEL_LEVEL_H__
#define __LEVEL_LEVEL_H__ #define __LEVEL_LEVEL_H__
#include "level/layer.h" #include "level/layertile.h"
/*****************************************************************************/ /*****************************************************************************/
class CLayer; class CLayer;
@ -27,7 +27,7 @@ private:
sLvlHdr *LevelHdr; sLvlHdr *LevelHdr;
// Tile Layers // Tile Layers
CLayer *TileLayers[CLayer::LAYER_TYPE_MAX]; CLayerTile *TileLayers[CLayerTile::LAYER_TILE_TYPE_MAX];
}; };
/*****************************************************************************/ /*****************************************************************************/

View File

@ -21,6 +21,10 @@ struct sVidScreen
}; };
/*****************************************************************************/ /*****************************************************************************/
extern int FrameFlipFlag;
/*****************************************************************************/
void VidInit(); void VidInit();
void VidScrOn(); void VidScrOn();