Commit | Line | Data |
---|---|---|
ef79bbde P |
1 | /*************************************************************************** |
2 | gpu.h - description | |
3 | ------------------- | |
4 | begin : Sun Oct 28 2001 | |
5 | copyright : (C) 2001 by Pete Bernert | |
6 | email : BlackDove@addcom.de | |
7 | ***************************************************************************/ | |
8 | /*************************************************************************** | |
9 | * * | |
10 | * This program is free software; you can redistribute it and/or modify * | |
11 | * it under the terms of the GNU General Public License as published by * | |
12 | * the Free Software Foundation; either version 2 of the License, or * | |
13 | * (at your option) any later version. See also the license.txt file for * | |
14 | * additional informations. * | |
15 | * * | |
16 | ***************************************************************************/ | |
17 | ||
a96a5eb2 | 18 | #ifndef _PSX_GPU_ |
19 | #define _PSX_GPU_ | |
20 | ||
21 | #define INFO_TW 0 | |
22 | #define INFO_DRAWSTART 1 | |
23 | #define INFO_DRAWEND 2 | |
24 | #define INFO_DRAWOFF 3 | |
25 | ||
26 | #define SHADETEXBIT(x) ((x>>24) & 0x1) | |
27 | #define SEMITRANSBIT(x) ((x>>25) & 0x1) | |
28 | #define PSXRGB(r,g,b) ((g<<10)|(b<<5)|r) | |
29 | ||
30 | #define DATAREGISTERMODES unsigned short | |
31 | ||
32 | #define DR_NORMAL 0 | |
33 | #define DR_VRAMTRANSFER 1 | |
34 | ||
35 | ||
36 | #define GPUSTATUS_ODDLINES 0x80000000 | |
37 | #define GPUSTATUS_DMABITS 0x60000000 // Two bits | |
38 | #define GPUSTATUS_READYFORCOMMANDS 0x10000000 | |
39 | #define GPUSTATUS_READYFORVRAM 0x08000000 | |
40 | #define GPUSTATUS_IDLE 0x04000000 | |
41 | #define GPUSTATUS_DISPLAYDISABLED 0x00800000 | |
42 | #define GPUSTATUS_INTERLACED 0x00400000 | |
43 | #define GPUSTATUS_RGB24 0x00200000 | |
44 | #define GPUSTATUS_PAL 0x00100000 | |
45 | #define GPUSTATUS_DOUBLEHEIGHT 0x00080000 | |
46 | #define GPUSTATUS_WIDTHBITS 0x00070000 // Three bits | |
47 | #define GPUSTATUS_MASKENABLED 0x00001000 | |
48 | #define GPUSTATUS_MASKDRAWN 0x00000800 | |
49 | #define GPUSTATUS_DRAWINGALLOWED 0x00000400 | |
50 | #define GPUSTATUS_DITHER 0x00000200 | |
51 | ||
52 | #define GPUIsBusy (lGPUstatusRet &= ~GPUSTATUS_IDLE) | |
53 | #define GPUIsIdle (lGPUstatusRet |= GPUSTATUS_IDLE) | |
54 | ||
55 | #define GPUIsNotReadyForCommands (lGPUstatusRet &= ~GPUSTATUS_READYFORCOMMANDS) | |
56 | #define GPUIsReadyForCommands (lGPUstatusRet |= GPUSTATUS_READYFORCOMMANDS) | |
57 | ||
58 | #define CALLBACK | |
59 | ||
60 | #include <stdio.h> | |
61 | #include <stdlib.h> | |
62 | #include <string.h> | |
63 | #include <sys/time.h> | |
64 | #include <math.h> | |
65 | #include <stdint.h> | |
66 | #include <unistd.h> | |
0a371c2c | 67 | #include "../../include/arm_features.h" |
a96a5eb2 | 68 | |
69 | ///////////////////////////////////////////////////////////////////////////// | |
70 | ||
71 | // byteswappings | |
72 | ||
ae097dfb PC |
73 | #define SWAP16(x) __builtin_bswap16(x) |
74 | #define SWAP32(x) __builtin_bswap32(x) | |
a96a5eb2 | 75 | |
04bd10b1 | 76 | #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ |
a96a5eb2 | 77 | |
78 | // big endian config | |
79 | #define HOST2LE32(x) SWAP32(x) | |
80 | #define HOST2BE32(x) (x) | |
81 | #define LE2HOST32(x) SWAP32(x) | |
82 | #define BE2HOST32(x) (x) | |
83 | ||
84 | #define HOST2LE16(x) SWAP16(x) | |
85 | #define HOST2BE16(x) (x) | |
86 | #define LE2HOST16(x) SWAP16(x) | |
87 | #define BE2HOST16(x) (x) | |
88 | ||
89 | #else | |
90 | ||
91 | // little endian config | |
92 | #define HOST2LE32(x) (x) | |
93 | #define HOST2BE32(x) SWAP32(x) | |
94 | #define LE2HOST32(x) (x) | |
95 | #define BE2HOST32(x) SWAP32(x) | |
96 | ||
97 | #define HOST2LE16(x) (x) | |
98 | #define HOST2BE16(x) SWAP16(x) | |
99 | #define LE2HOST16(x) (x) | |
100 | #define BE2HOST16(x) SWAP16(x) | |
101 | ||
102 | #endif | |
103 | ||
0a371c2c | 104 | #define GETLEs16(X) ((int16_t)GETLE16((uint16_t *)(X))) |
a96a5eb2 | 105 | |
0a371c2c | 106 | #define GETLE16(X) LE2HOST16(*(uint16_t *)(X)) |
107 | #define GETLE32_(X) LE2HOST32(*(uint32_t *)(X)) | |
108 | #define PUTLE16(X, Y) do{*((uint16_t *)(X))=HOST2LE16((uint16_t)(Y));}while(0) | |
109 | #define PUTLE32_(X, Y) do{*((uint32_t *)(X))=HOST2LE32((uint32_t)(Y));}while(0) | |
110 | #if defined(__arm__) && !defined(HAVE_ARMV6) | |
111 | // for (very) old ARMs with no unaligned loads? | |
112 | #define GETLE32(X) (*(uint16_t *)(X)|((uint32_t)((uint16_t *)(X))[1]<<16)) | |
a46e4627 | 113 | #define PUTLE32(X, Y) do{uint16_t *p_=(uint16_t *)(X);uint32_t y_=Y;p_[0]=y_;p_[1]=y_>>16;}while(0) |
0d16cda2 | 114 | #else |
115 | #define GETLE32 GETLE32_ | |
116 | #define PUTLE32 PUTLE32_ | |
117 | #endif | |
a96a5eb2 | 118 | |
119 | ///////////////////////////////////////////////////////////////////////////// | |
120 | ||
121 | typedef struct VRAMLOADTTAG | |
122 | { | |
123 | short x; | |
124 | short y; | |
125 | short Width; | |
126 | short Height; | |
127 | short RowsRemaining; | |
128 | short ColsRemaining; | |
129 | unsigned short *ImagePtr; | |
130 | } VRAMLoad_t; | |
131 | ||
132 | ///////////////////////////////////////////////////////////////////////////// | |
133 | ||
134 | typedef struct PSXPOINTTAG | |
135 | { | |
136 | int32_t x; | |
137 | int32_t y; | |
138 | } PSXPoint_t; | |
139 | ||
140 | typedef struct PSXSPOINTTAG | |
141 | { | |
142 | short x; | |
143 | short y; | |
144 | } PSXSPoint_t; | |
145 | ||
146 | typedef struct PSXRECTTAG | |
147 | { | |
148 | short x0; | |
149 | short x1; | |
150 | short y0; | |
151 | short y1; | |
152 | } PSXRect_t; | |
153 | ||
154 | // linux defines for some windows stuff | |
155 | ||
156 | #define FALSE 0 | |
157 | #define TRUE 1 | |
158 | #define BOOL unsigned short | |
159 | #define LOWORD(l) ((unsigned short)(l)) | |
160 | #define HIWORD(l) ((unsigned short)(((uint32_t)(l) >> 16) & 0xFFFF)) | |
161 | #define max(a,b) (((a) > (b)) ? (a) : (b)) | |
162 | #define min(a,b) (((a) < (b)) ? (a) : (b)) | |
163 | #define DWORD uint32_t | |
164 | #ifndef __int64 | |
165 | #define __int64 long long int | |
166 | #endif | |
167 | ||
168 | typedef struct RECTTAG | |
169 | { | |
170 | int left; | |
171 | int top; | |
172 | int right; | |
173 | int bottom; | |
174 | }RECT; | |
175 | ||
176 | ///////////////////////////////////////////////////////////////////////////// | |
177 | ||
178 | typedef struct TWINTAG | |
179 | { | |
180 | PSXRect_t Position; | |
e429fc60 | 181 | int xmask, ymask; |
a96a5eb2 | 182 | } TWin_t; |
183 | ||
184 | ///////////////////////////////////////////////////////////////////////////// | |
185 | ||
186 | typedef struct PSXDISPLAYTAG | |
187 | { | |
188 | PSXPoint_t DisplayModeNew; | |
189 | PSXPoint_t DisplayMode; | |
190 | PSXPoint_t DisplayPosition; | |
191 | PSXPoint_t DisplayEnd; | |
192 | ||
193 | int32_t Double; | |
194 | int32_t Height; | |
195 | int32_t PAL; | |
196 | int32_t InterlacedNew; | |
197 | int32_t Interlaced; | |
198 | int32_t RGB24New; | |
199 | int32_t RGB24; | |
200 | PSXSPoint_t DrawOffset; | |
201 | int32_t Disabled; | |
202 | PSXRect_t Range; | |
203 | ||
204 | } PSXDisplay_t; | |
205 | ||
206 | ///////////////////////////////////////////////////////////////////////////// | |
207 | ||
208 | // draw.c | |
209 | ||
210 | extern int32_t GlobalTextAddrX,GlobalTextAddrY,GlobalTextTP; | |
a48f1478 | 211 | extern int32_t GlobalTextABR,GlobalTextPAGE; |
a96a5eb2 | 212 | extern short ly0,lx0,ly1,lx1,ly2,lx2,ly3,lx3; |
213 | extern long lLowerpart; | |
214 | extern BOOL bCheckMask; | |
215 | extern unsigned short sSetMask; | |
216 | extern unsigned long lSetMask; | |
217 | extern short g_m1; | |
218 | extern short g_m2; | |
219 | extern short g_m3; | |
220 | extern short DrawSemiTrans; | |
221 | ||
222 | // prim.c | |
223 | ||
224 | extern BOOL bUsingTWin; | |
225 | extern TWin_t TWin; | |
226 | extern void (*primTableJ[256])(unsigned char *); | |
227 | extern void (*primTableSkip[256])(unsigned char *); | |
228 | extern unsigned short usMirror; | |
229 | extern int iDither; | |
230 | extern uint32_t dwCfgFixes; | |
231 | extern uint32_t dwActFixes; | |
232 | extern int iUseFixes; | |
233 | extern int iUseDither; | |
234 | extern BOOL bDoVSyncUpdate; | |
235 | extern int32_t drawX; | |
236 | extern int32_t drawY; | |
237 | extern int32_t drawW; | |
238 | extern int32_t drawH; | |
239 | ||
240 | // gpu.h | |
ef79bbde P |
241 | |
242 | #define OPAQUEON 10 | |
243 | #define OPAQUEOFF 11 | |
244 | ||
245 | #define KEY_RESETTEXSTORE 1 | |
246 | #define KEY_SHOWFPS 2 | |
247 | #define KEY_RESETOPAQUE 4 | |
248 | #define KEY_RESETDITHER 8 | |
249 | #define KEY_RESETFILTER 16 | |
250 | #define KEY_RESETADVBLEND 32 | |
ef79bbde P |
251 | #define KEY_BADTEXTURES 128 |
252 | #define KEY_CHECKTHISOUT 256 | |
253 | ||
04bd10b1 | 254 | #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ |
ef79bbde P |
255 | #define RED(x) (x & 0xff) |
256 | #define BLUE(x) ((x>>16) & 0xff) | |
257 | #define GREEN(x) ((x>>8) & 0xff) | |
258 | #define COLOR(x) (x & 0xffffff) | |
04bd10b1 | 259 | #else |
ef79bbde P |
260 | #define RED(x) ((x>>24) & 0xff) |
261 | #define BLUE(x) ((x>>8) & 0xff) | |
262 | #define GREEN(x) ((x>>16) & 0xff) | |
263 | #define COLOR(x) SWAP32(x & 0xffffff) | |
264 | #endif | |
265 | ||
a96a5eb2 | 266 | // gpu.c |
ef79bbde | 267 | |
a96a5eb2 | 268 | extern VRAMLoad_t VRAMWrite; |
269 | extern VRAMLoad_t VRAMRead; | |
270 | extern DATAREGISTERMODES DataWriteMode; | |
271 | extern DATAREGISTERMODES DataReadMode; | |
272 | extern short sDispWidths[]; | |
273 | extern BOOL bDebugText; | |
274 | extern PSXDisplay_t PSXDisplay; | |
275 | extern PSXDisplay_t PreviousPSXDisplay; | |
276 | extern BOOL bSkipNextFrame; | |
277 | extern long lGPUstatusRet; | |
278 | extern unsigned char * psxVSecure; | |
279 | extern unsigned char * psxVub; | |
a96a5eb2 | 280 | extern unsigned short * psxVuw; |
a96a5eb2 | 281 | extern unsigned short * psxVuw_eom; |
282 | extern BOOL bChangeWinMode; | |
283 | extern long lSelectedSlot; | |
284 | extern BOOL bInitCap; | |
285 | extern DWORD dwLaceCnt; | |
286 | extern uint32_t lGPUInfoVals[]; | |
287 | extern uint32_t ulStatusControl[]; | |
ef79bbde | 288 | |
a96a5eb2 | 289 | // fps.c |
290 | ||
291 | extern int UseFrameLimit; | |
292 | extern int UseFrameSkip; | |
293 | extern float fFrameRate; | |
294 | extern int iFrameLimit; | |
295 | extern float fFrameRateHz; | |
296 | extern float fps_skip; | |
297 | extern float fps_cur; | |
ef79bbde | 298 | |
a96a5eb2 | 299 | // draw.c |
300 | ||
301 | void DoBufferSwap(void); | |
302 | void DoClearScreenBuffer(void); | |
303 | void DoClearFrontBuffer(void); | |
304 | unsigned long ulInitDisplay(void); | |
305 | void CloseDisplay(void); | |
306 | ||
76f7048e | 307 | struct rearmed_cbs; |
308 | extern const struct rearmed_cbs *rcbs; | |
309 | ||
a96a5eb2 | 310 | #endif |