summaryrefslogtreecommitdiff
path: root/plugins/dfOpenGL/gpu_i.h
blob: a45c0e941b2dc446b2944198b412ea8a5eb6f7a0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
#ifndef _GPU_INTERNALS_H
#define _GPU_INTERNALS_H

#define GL_GLEXT_PROTOTYPES
#include <GL/glx.h>
#include <GL/gl.h>
#include <GL/glext.h>
#include <stdint.h>

#ifdef GPU_INTERNALS_DEF
#define GPUVAR_DEF
#else
#define GPUVAR_DEF extern
#endif

typedef int bool;
#define FALSE 0
#define TRUE 1

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;

typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

void gllog(int level, char *fmt,...);

extern unsigned short lutBGR2RGB[65536];

extern unsigned short textBuf[];

extern int32_t GPUstatusRet;
extern int32_t GPUInfoVals[16];

#define INFO_TW        0
#define INFO_DRAWSTART 1
#define INFO_DRAWEND   2
#define INFO_DRAWOFF   3

#define GPUSTATUS_ODDLINES            0x80000000
#define GPUSTATUS_DMABITS             0x60000000 // Two bits
#define GPUSTATUS_READYFORCOMMANDS    0x10000000
#define GPUSTATUS_READYFORVRAM        0x08000000
#define GPUSTATUS_IDLE                0x04000000
#define GPUSTATUS_DISPLAYDISABLED     0x00800000
#define GPUSTATUS_INTERLACED          0x00400000
#define GPUSTATUS_RGB24               0x00200000
#define GPUSTATUS_PAL                 0x00100000
#define GPUSTATUS_DOUBLEHEIGHT        0x00080000
#define GPUSTATUS_WIDTHBITS           0x00070000 // Three bits
#define GPUSTATUS_MASKENABLED         0x00001000
#define GPUSTATUS_MASKDRAWN           0x00000800
#define GPUSTATUS_DRAWINGALLOWED      0x00000400
#define GPUSTATUS_DITHER              0x00000200

#define GPUIsBusy (GPUstatusRet &= ~GPUSTATUS_IDLE)
#define GPUIsIdle (GPUstatusRet |= GPUSTATUS_IDLE)

#define GPUIsNotReadyForCommands (GPUstatusRet &= ~GPUSTATUS_READYFORCOMMANDS)
#define GPUIsReadyForCommands (GPUstatusRet |= GPUSTATUS_READYFORCOMMANDS)

extern unsigned char psxVub[];
extern signed char *psxVsb;
extern unsigned short *psxVuw;
extern signed short *psxVsw;
extern uint32_t *psxVul;
extern int32_t *psxVsl;


typedef struct {
	uint32_t x, y;
	uint32_t colormode;
	uint32_t abr;	//alpha blending
	uint32_t mirror;
} TextureState_t;

extern TextureState_t texinfo;

typedef struct VRAMLOADTTAG
{
	short x;
	short y;
	short w;
	short h;
	short curx;
	short cury;
	uint32_t* extratarget;
	bool enabled;
} VRAMLoad_t;

extern VRAMLoad_t vramWrite;

struct PSXDisplay_t {
	short modeX;
	short modeY;
	short startX;
	short startY;
	bool disabled;
	bool colordepth24;
	bool interlaced;
	bool pal;

	//Has to do with television hsync & vsync?
	//1 Y line = 1 vtrace? (typical 16 to 256 (32 to 512))
	//X (typical 608 to 3168)
	short rangeX1;
	short rangeY1;
	short rangeX2;
	short rangeY2;

	bool changed;
};
extern struct PSXDisplay_t psxDisp, oldpsxDisp;

struct PSXDraw_t {
	short offsetX;
	short offsetY;
	short clipX1;
	short clipX2;
	short clipY1;
	short clipY2;
	short texwinX1;
	short texwinY1;
	short texwinX2;
	short texwinY2;
	bool texwinenabled;
	bool enabled;
	bool setmask;
	bool testmask;
};
extern struct PSXDraw_t psxDraw;

extern short dispWidths[8];

extern int32_t dispLace;
extern int32_t dispLaceNew;
extern int32_t imageTransfer;
extern int32_t drawLace;
extern int32_t drawingLines;

extern short imTYc,imTXc,imTY,imTX;
extern int32_t imSize;
extern short imageX0,imageX1;
extern short imageY0,imageY1;


extern int32_t newTextX0,newTextX1,newTextX2,newTextX3;
extern int32_t newTextY0,newTextY1,newTextY2,newTextY3;
extern unsigned short textBuf[];

union uPointers{
	void *v;
	unsigned char *b;
	unsigned short *w;
	uint32_t *d;
	char *c;
	short *s;
	int32_t *l;
};
extern unsigned char psxVub[];
extern signed char *psxVsb;
extern unsigned short *psxVuw;
extern signed short *psxVsw;
extern uint32_t *psxVul;
extern int32_t *psxVsl;

typedef struct
{
	bool bFullscreen;
	bool bBilinear;
	int nMaxTextures;
	bool bWireFrame;
	bool bAntialias;
	bool bClearScreen;
	bool FrameLimit;
	short windowX;
	short windowY;
} GpuConfS;
extern GpuConfS gpuConfig;

extern short windowX, windowY;

extern unsigned char texshade[256];
extern uint32_t image[65536];
extern uint32_t torgba[65536];


struct texturecache{
	int32_t textAddrX;
	int32_t textAddrY;
	int32_t textTP;
	int32_t clutP;
	GLuint id;
	bool Update;
};
//#define maxtextures 32
extern struct texturecache texture[64];
extern GLuint xferTexture16;
extern GLuint xferTexture24;
extern GLuint nullid;
#define nullclutP (1024*512+1)


#endif // _GPU_INTERNALS_H