SBSPSS/source/gfx/primplus.h

332 lines
9.6 KiB
C
Raw Normal View History

2000-12-08 15:33:38 +01:00
/*************************************************************************************
*
*
* 'New' polygon types, and associated macros, for non-textured primitives (and
* sprites) with per-poly ABR control. Also includes tpage control for sprites.
2000-12-08 15:48:50 +01:00
*
2000-12-08 15:33:38 +01:00
* Courtesty of Dead Ashton
*
*
*************************************************************************************/
2000-12-08 15:48:50 +01:00
#ifndef __PRIMPLUS_HEADER__
#define __PRIMPLUS_HEADER__
2000-12-08 15:33:38 +01:00
//------------------------------------------------------------------------------------
// Defines
//------------------------------------------------------------------------------------
#define GPUCODE_MODE_SHADE_TEX (1<<0)
#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.
2000-12-09 18:22:06 +01:00
#define GPUCODE_POLY_F3 (0x20)
2000-12-08 15:33:38 +01:00
#define GPUCODE_POLY_FT3 (0x24)
2000-12-09 18:22:06 +01:00
#define GPUCODE_POLY_G3 (0x30)
2000-12-08 15:33:38 +01:00
#define GPUCODE_POLY_GT3 (0x34)
2000-12-09 18:22:06 +01:00
#define GPUCODE_POLY_F4 (0x28)
2000-12-08 15:33:38 +01:00
#define GPUCODE_POLY_FT4 (0x2c)
2000-12-09 18:22:06 +01:00
#define GPUCODE_POLY_G4 (0x38)
2000-12-08 15:33:38 +01:00
#define GPUCODE_POLY_GT4 (0x3c)
#define GPUCODE_SPRT (0x64)
#define GPUCODE_SPRT_8 (0x74)
#define GPUCODE_SPRT_16 (0x7c)
#define GPUCODE_TILE (0x60)
#define GPUCODE_TILE_1 (0x68)
#define GPUCODE_TILE_8 (0x70)
#define GPUCODE_TILE_16 (0x78)
#define GPUCODE_LINE_F2 (0x40)
#define GPUCODE_LINE_G2 (0x50)
#define GPUCODE_LINE_F3 (0x48)
#define GPUCODE_LINE_G3 (0x58)
#define GPUCODE_LINE_F4 (0x4c)
#define GPUCODE_LINE_G4 (0x5c)
2000-12-09 18:22:06 +01:00
// 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)
2000-12-08 15:33:38 +01:00
#define GPUSIZE_POLY_FT3 (7)
2000-12-09 18:22:06 +01:00
#define GPUSIZE_POLY_G3 (6)
2000-12-08 15:33:38 +01:00
#define GPUSIZE_POLY_GT3 (9)
2000-12-09 18:22:06 +01:00
#define GPUSIZE_POLY_F4 (5)
2000-12-08 15:33:38 +01:00
#define GPUSIZE_POLY_FT4 (9)
2000-12-09 18:22:06 +01:00
#define GPUSIZE_POLY_G4 (8)
2000-12-08 15:33:38 +01:00
#define GPUSIZE_POLY_GT4 (12)
#define GPUSIZE_SPRT (4)
#define GPUSIZE_SPRT_8 (3)
#define GPUSIZE_SPRT_16 (3)
#define GPUSIZE_TILE (3)
#define GPUSIZE_TILE_1 (2)
#define GPUSIZE_TILE_8 (2)
#define GPUSIZE_TILE_16 (2)
#define GPUSIZE_LINE_F2 (3)
#define GPUSIZE_LINE_G2 (4)
#define GPUSIZE_LINE_F3 (5)
#define GPUSIZE_LINE_G3 (7)
#define GPUSIZE_LINE_F4 (6)
#define GPUSIZE_LINE_G4 (9)
#define GPUSIZE_DR_TPAGE (1)
2000-12-09 18:22:06 +01:00
#define GPUSIZE_TPOLY_F3 (GPUSIZE_DR_TPAGE+GPUSIZE_POLY_F3)
#define GPUSIZE_TPOLY_F4 (GPUSIZE_DR_TPAGE+GPUSIZE_POLY_F4)
#define GPUSIZE_TPOLY_G3 (GPUSIZE_DR_TPAGE+GPUSIZE_POLY_G3)
#define GPUSIZE_TPOLY_G4 (GPUSIZE_DR_TPAGE+GPUSIZE_POLY_G4)
2000-12-08 15:33:38 +01:00
2000-12-09 18:22:06 +01:00
#define GPUSIZE_TLINE_F2 (GPUSIZE_DR_TPAGE+GPUSIZE_LINE_F3)
#define GPUSIZE_TLINE_G2 (GPUSIZE_DR_TPAGE+GPUSIZE_LINE_G2)
#define GPUSIZE_TLINE_F3 (GPUSIZE_DR_TPAGE+GPUSIZE_LINE_F3)
#define GPUSIZE_TLINE_G3 (GPUSIZE_DR_TPAGE+GPUSIZE_LINE_G3)
#define GPUSIZE_TLINE_F4 (GPUSIZE_DR_TPAGE+GPUSIZE_LINE_F4)
#define GPUSIZE_TLINE_G4 (GPUSIZE_DR_TPAGE+GPUSIZE_LINE_G4)
2000-12-08 15:33:38 +01:00
2000-12-09 18:22:06 +01:00
#define GPUSIZE_TSPRT (GPUSIZE_DR_TPAGE+GPUSIZE_SPRT)
#define GPUSIZE_TSPRT_8 (GPUSIZE_DR_TPAGE+GPUSIZE_SPRT_8)
#define GPUSIZE_TSPRT_16 (GPUSIZE_DR_TPAGE+GPUSIZE_SPRT_16)
2000-12-08 15:33:38 +01:00
2000-12-09 18:22:06 +01:00
#define GPUSIZE_TTILE (GPUSIZE_DR_TPAGE+GPUSIZE_TILE)
#define GPUSIZE_TTILE_1 (GPUSIZE_DR_TPAGE+GPUSIZE_TILE_1)
#define GPUSIZE_TTILE_8 (GPUSIZE_DR_TPAGE+GPUSIZE_TILE_8)
#define GPUSIZE_TTILE_16 (GPUSIZE_DR_TPAGE+GPUSIZE_TILE_16)
2000-12-08 15:33:38 +01:00
2000-12-09 18:22:06 +01:00
#define GPU_COLOUR_MASK (0x00ffffff)
#define GPU_CODE_MASK (0xff000000)
#define GPU_CODE_SHIFT (24)
2000-12-08 15:33:38 +01:00
//------------------------------------------------------------------------------------
// Macros
//------------------------------------------------------------------------------------
2000-12-09 18:22:06 +01:00
#define setTDrawTPageSize(p,s) setlen((p), (s)), (p)->t_code = _get_mode(0,1,0)
2000-12-08 15:33:38 +01:00
#define setTDrawTPage(p) setTDrawTPageSize((p), 1)
2000-12-09 18:22:06 +01:00
#define setTPolyF3(p) setTDrawTPageSize((p), GPUSIZE_TPOLY_F3), ((p)->code)=GPUCODE_POLY_F3
#define setTPolyF4(p) setTDrawTPageSize((p), GPUSIZE_TPOLY_F4), ((p)->code)=GPUCODE_POLY_F4
#define setTPolyG3(p) setTDrawTPageSize((p), GPUSIZE_TPOLY_G3), ((p)->code)=GPUCODE_POLY_G3
#define setTPolyG4(p) setTDrawTPageSize((p), GPUSIZE_TPOLY_G4), ((p)->code)=GPUCODE_POLY_G4
2000-12-08 15:33:38 +01:00
2000-12-09 18:22:06 +01:00
#define setTLineF2(p) setTDrawTPageSize((p), GPUSIZE_TLINE_F2), ((p)->code)=GPUCODE_LINE_F2
#define setTLineG2(p) setTDrawTPageSize((p), GPUSIZE_TLINE_G2), ((p)->code)=GPUCODE_LINE_G2
#define setTLineF3(p) setTDrawTPageSize((p), GPUSIZE_TLINE_F3), ((p)->code)=GPUCODE_LINE_F3, ((p)->pad)=0x55555555
#define setTLineG3(p) setTDrawTPageSize((p), GPUSIZE_TLINE_G3), ((p)->code)=GPUCODE_LINE_G3, ((p)->pad)=0x55555555, ((p)->p2)=0
#define setTLineF4(p) setTDrawTPageSize((p), GPUSIZE_TLINE_F4), ((p)->code)=GPUCODE_LINE_F4, ((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
2000-12-08 15:33:38 +01:00
2000-12-09 18:22:06 +01:00
#define setTSprt(p) setTDrawTPageSize((p), GPUSIZE_TSPRT), ((p)->code)=GPUCODE_SPRT
#define setTSprt8(p) setTDrawTPageSize((p), GPUSIZE_TSPRT_8), ((p)->code)=GPUCODE_SPRT_8
#define setTSprt16(p) setTDrawTPageSize((p), GPUSIZE_TSPRT_16), ((p)->code)=GPUCODE_SPRT_16
2000-12-08 15:33:38 +01:00
2000-12-09 18:22:06 +01:00
#define setTTile(p) setTDrawTPageSize((p), GPUSIZE_TTILE), ((p)->code)=GPUCODE_TILE
#define setTTile1(p) setTDrawTPageSize((p), GPUSIZE_TTILE_1), ((p)->code)=GPUCODE_TILE_1
#define setTTile8(p) setTDrawTPageSize((p), GPUSIZE_TTILE_8), ((p)->code)=GPUCODE_TILE_8
#define setTTile16(p) setTDrawTPageSize((p), GPUSIZE_TTILE_16), ((p)->code)=GPUCODE_TILE_16
2000-12-08 15:33:38 +01:00
2000-12-09 18:22:06 +01:00
#define setTSemiTrans(p, abe) setSemiTrans(&((p)->t_code), (abe))
#define setTSetShadeTex(p, st) setShadeTex(&((p)->t_code), (st))
#define setTABRMode(p,abr) ((p)->t_code) = _get_mode(0,1,(abr<<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)))
2000-12-08 15:33:38 +01:00
2000-12-09 18:22:06 +01:00
#define addPrimSize(ot,p,size) ((p)->tag) = ((*(ot))|((size)<<24)), *((ot)) = (((u_long)(p)<<8)>>8)
2000-12-08 15:33:38 +01:00
//------------------------------------------------------------------------------------
// Structures
//------------------------------------------------------------------------------------
2000-12-09 18:22:06 +01:00
typedef struct __tpoly_f3
2000-12-08 15:33:38 +01:00
{
u_long tag;
2000-12-09 18:22:06 +01:00
u_long t_code;
2000-12-08 15:33:38 +01:00
u_char r0, g0, b0, code;
2000-12-09 18:22:06 +01:00
short x0, y0;
2000-12-08 15:33:38 +01:00
short x1, y1;
short x2, y2;
2000-12-09 18:22:06 +01:00
} TPOLY_F3; // Flat Triangle with ABR control
2000-12-08 15:33:38 +01:00
2000-12-09 18:22:06 +01:00
typedef struct __tpoly_f4
2000-12-08 15:33:38 +01:00
{
u_long tag;
2000-12-09 18:22:06 +01:00
u_long t_code;
2000-12-08 15:33:38 +01:00
u_char r0, g0, b0, code;
2000-12-09 18:22:06 +01:00
short x0, y0;
2000-12-08 15:33:38 +01:00
short x1, y1;
short x2, y2;
short x3, y3;
2000-12-09 18:22:06 +01:00
} TPOLY_F4; // Flat Quadrangle with ABR control
2000-12-08 15:33:38 +01:00
2000-12-09 18:22:06 +01:00
typedef struct __tpoly_g3
2000-12-08 15:33:38 +01:00
{
u_long tag;
2000-12-09 18:22:06 +01:00
u_long t_code;
2000-12-08 15:33:38 +01:00
u_char r0, g0, b0, code;
2000-12-09 18:22:06 +01:00
short x0, y0;
2000-12-08 15:33:38 +01:00
u_char r1, g1, b1, pad1;
short x1, y1;
u_char r2, g2, b2, pad2;
short x2, y2;
2000-12-09 18:22:06 +01:00
} TPOLY_G3; // Gouraud Triangle with ABR control
2000-12-08 15:33:38 +01:00
2000-12-09 18:22:06 +01:00
typedef struct __tpoly_g4
2000-12-08 15:33:38 +01:00
{
u_long tag;
2000-12-09 18:22:06 +01:00
u_long t_code;
2000-12-08 15:33:38 +01:00
u_char r0, g0, b0, code;
2000-12-09 18:22:06 +01:00
short x0, y0;
2000-12-08 15:33:38 +01:00
u_char r1, g1, b1, pad1;
short x1, y1;
u_char r2, g2, b2, pad2;
short x2, y2;
u_char r3, g3, b3, pad3;
short x3, y3;
2000-12-09 18:22:06 +01:00
} TPOLY_G4; // Gouraud Quadrangle with ABR control
2000-12-08 15:33:38 +01:00
//
// Line Primitive Definitions
//
2000-12-09 18:22:06 +01:00
typedef struct __tline_f2
2000-12-08 15:33:38 +01:00
{
u_long tag;
2000-12-09 18:22:06 +01:00
u_long t_code;
2000-12-08 15:33:38 +01:00
u_char r0, g0, b0, code;
2000-12-09 18:22:06 +01:00
short x0, y0;
2000-12-08 15:33:38 +01:00
short x1, y1;
2000-12-09 18:22:06 +01:00
} TLINE_F2; // Unconnected Flat Line with ABR control
2000-12-08 15:33:38 +01:00
2000-12-09 18:22:06 +01:00
typedef struct __tline_g2
2000-12-08 15:33:38 +01:00
{
u_long tag;
2000-12-09 18:22:06 +01:00
u_long t_code;
2000-12-08 15:33:38 +01:00
u_char r0, g0, b0, code;
2000-12-09 18:22:06 +01:00
short x0, y0;
2000-12-08 15:33:38 +01:00
u_char r1, g1, b1, p1;
short x1, y1;
2000-12-09 18:22:06 +01:00
} TLINE_G2; // Unconnected Gouraud Line with ABR control
2000-12-08 15:33:38 +01:00
2000-12-09 18:22:06 +01:00
typedef struct __tline_f3
2000-12-08 15:33:38 +01:00
{
u_long tag;
2000-12-09 18:22:06 +01:00
u_long t_code;
2000-12-08 15:33:38 +01:00
u_char r0, g0, b0, code;
2000-12-09 18:22:06 +01:00
short x0, y0;
2000-12-08 15:33:38 +01:00
short x1, y1;
short x2, y2;
u_long pad;
2000-12-09 18:22:06 +01:00
} TLINE_F3; // 2 connected Flat Line with ABR control
2000-12-08 15:33:38 +01:00
2000-12-09 18:22:06 +01:00
typedef struct __tline_g3
2000-12-08 15:33:38 +01:00
{
u_long tag;
2000-12-09 18:22:06 +01:00
u_long t_code;
2000-12-08 15:33:38 +01:00
u_char r0, g0, b0, code;
2000-12-09 18:22:06 +01:00
short x0, y0;
2000-12-08 15:33:38 +01:00
u_char r1, g1, b1, p1;
short x1, y1;
u_char r2, g2, b2, p2;
short x2, y2;
u_long pad;
2000-12-09 18:22:06 +01:00
} TLINE_G3; // 2 connected Gouraud Line with ABR control
2000-12-08 15:33:38 +01:00
2000-12-09 18:22:06 +01:00
typedef struct __tline_f4
2000-12-08 15:33:38 +01:00
{
u_long tag;
2000-12-09 18:22:06 +01:00
u_long t_code;
2000-12-08 15:33:38 +01:00
u_char r0, g0, b0, code;
2000-12-09 18:22:06 +01:00
short x0, y0;
2000-12-08 15:33:38 +01:00
short x1, y1;
short x2, y2;
short x3, y3;
u_long pad;
2000-12-09 18:22:06 +01:00
} TLINE_F4; // 3 connected Flat Line Quadrangle with ABR control
2000-12-08 15:33:38 +01:00
2000-12-09 18:22:06 +01:00
typedef struct __tline_g4
2000-12-08 15:33:38 +01:00
{
u_long tag;
2000-12-09 18:22:06 +01:00
u_long t_code;
2000-12-08 15:33:38 +01:00
u_char r0, g0, b0, code;
2000-12-09 18:22:06 +01:00
short x0, y0;
2000-12-08 15:33:38 +01:00
u_char r1, g1, b1, p1;
short x1, y1;
u_char r2, g2, b2, p2;
short x2, y2;
u_char r3, g3, b3, p3;
short x3, y3;
u_long pad;
2000-12-09 18:22:06 +01:00
} TLINE_G4; // 3 connected Gouraud Line with ABR control
2000-12-08 15:33:38 +01:00
//
// Sprite Primitive Definitions
//
2000-12-09 18:22:06 +01:00
typedef struct __tsprt
2000-12-08 15:33:38 +01:00
{
u_long tag;
2000-12-09 18:22:06 +01:00
u_long t_code;
2000-12-08 15:33:38 +01:00
u_char r0, g0, b0, code;
2000-12-09 18:22:06 +01:00
short x0, y0;
2000-12-08 15:33:38 +01:00
u_char u0, v0; u_short clut;
short w, h;
2000-12-09 18:22:06 +01:00
} TSPRT; // Free size Sprite with TPage/ABR control
2000-12-08 15:33:38 +01:00
2000-12-09 18:22:06 +01:00
typedef struct __tsprt_16
2000-12-08 15:33:38 +01:00
{
u_long tag;
2000-12-09 18:22:06 +01:00
u_long t_code;
2000-12-08 15:33:38 +01:00
u_char r0, g0, b0, code;
2000-12-09 18:22:06 +01:00
short x0, y0;
2000-12-08 15:33:38 +01:00
u_char u0, v0; u_short clut;
2000-12-09 18:22:06 +01:00
} TSPRT_16; // 16x16 Sprite with TPage/ABR control
2000-12-08 15:33:38 +01:00
2000-12-09 18:22:06 +01:00
typedef struct __tsprt_8
2000-12-08 15:33:38 +01:00
{
u_long tag;
2000-12-09 18:22:06 +01:00
u_long t_code;
2000-12-08 15:33:38 +01:00
u_char r0, g0, b0, code;
2000-12-09 18:22:06 +01:00
short x0, y0;
2000-12-08 15:33:38 +01:00
u_char u0, v0; u_short clut;
2000-12-09 18:22:06 +01:00
} TSPRT_8; // 8x8 Sprite with TPage/ABR control
2000-12-08 15:33:38 +01:00
//
// Tile Primitive Definitions
//
2000-12-09 18:22:06 +01:00
typedef struct __ttile
2000-12-08 15:33:38 +01:00
{
u_long tag;
2000-12-09 18:22:06 +01:00
u_long t_code;
2000-12-08 15:33:38 +01:00
u_char r0, g0, b0, code;
2000-12-09 18:22:06 +01:00
short x0, y0;
2000-12-08 15:33:38 +01:00
short w, h;
2000-12-09 18:22:06 +01:00
} TTILE; // free size Tile with ABR control
2000-12-08 15:33:38 +01:00
2000-12-09 18:22:06 +01:00
typedef struct __ttile16
2000-12-08 15:33:38 +01:00
{
u_long tag;
2000-12-09 18:22:06 +01:00
u_long t_code;
2000-12-08 15:33:38 +01:00
u_char r0, g0, b0, code;
2000-12-09 18:22:06 +01:00
short x0, y0;
} TTILE_16; // 16x16 Tile with ABR control
2000-12-08 15:33:38 +01:00
2000-12-09 18:22:06 +01:00
typedef struct __ttile_8
2000-12-08 15:33:38 +01:00
{
u_long tag;
2000-12-09 18:22:06 +01:00
u_long t_code;
2000-12-08 15:33:38 +01:00
u_char r0, g0, b0, code;
2000-12-09 18:22:06 +01:00
short x0, y0;
} TTILE_8; // 8x8 Tile with ABR control
2000-12-08 15:33:38 +01:00
2000-12-09 18:22:06 +01:00
typedef struct __ttile_1
2000-12-08 15:33:38 +01:00
{
u_long tag;
2000-12-09 18:22:06 +01:00
u_long t_code;
2000-12-08 15:33:38 +01:00
u_char r0, g0, b0, code;
2000-12-09 18:22:06 +01:00
short x0, y0;
} TTILE_1; // 1x1 Tile with ABR control
2000-12-08 15:33:38 +01:00
#endif