1 /***************************************************************************
4 begin : Sun Oct 28 2001
5 copyright : (C) 2001 by Pete Bernert
6 email : BlackDove@addcom.de
7 ***************************************************************************/
8 /***************************************************************************
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. *
16 ***************************************************************************/
22 #define INFO_DRAWSTART 1
23 #define INFO_DRAWEND 2
24 #define INFO_DRAWOFF 3
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)
30 #define DATAREGISTERMODES unsigned short
33 #define DR_VRAMTRANSFER 1
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
52 #define GPUIsBusy (lGPUstatusRet &= ~GPUSTATUS_IDLE)
53 #define GPUIsIdle (lGPUstatusRet |= GPUSTATUS_IDLE)
55 #define GPUIsNotReadyForCommands (lGPUstatusRet &= ~GPUSTATUS_READYFORCOMMANDS)
56 #define GPUIsReadyForCommands (lGPUstatusRet |= GPUSTATUS_READYFORCOMMANDS)
68 /////////////////////////////////////////////////////////////////////////////
72 #define SWAP16(x) ({ uint16_t y=(x); (((y)>>8 & 0xff) | ((y)<<8 & 0xff00)); })
73 #define SWAP32(x) ({ uint32_t y=(x); (((y)>>24 & 0xfful) | ((y)>>8 & 0xff00ul) | ((y)<<8 & 0xff0000ul) | ((y)<<24 & 0xff000000ul)); })
78 #define HOST2LE32(x) SWAP32(x)
79 #define HOST2BE32(x) (x)
80 #define LE2HOST32(x) SWAP32(x)
81 #define BE2HOST32(x) (x)
83 #define HOST2LE16(x) SWAP16(x)
84 #define HOST2BE16(x) (x)
85 #define LE2HOST16(x) SWAP16(x)
86 #define BE2HOST16(x) (x)
90 // little endian config
91 #define HOST2LE32(x) (x)
92 #define HOST2BE32(x) SWAP32(x)
93 #define LE2HOST32(x) (x)
94 #define BE2HOST32(x) SWAP32(x)
96 #define HOST2LE16(x) (x)
97 #define HOST2BE16(x) SWAP16(x)
98 #define LE2HOST16(x) (x)
99 #define BE2HOST16(x) SWAP16(x)
103 #define GETLEs16(X) ((int16_t)GETLE16((uint16_t *)X))
104 #define GETLEs32(X) ((int16_t)GETLE32((uint16_t *)X))
106 #define GETLE16(X) LE2HOST16(*(uint16_t *)X)
107 #define GETLE32_(X) LE2HOST32(*(uint32_t *)X)
108 #define GETLE16D(X) ({uint32_t val = GETLE32(X); (val<<16 | val >> 16);})
109 #define PUTLE16(X, Y) do{*((uint16_t *)X)=HOST2LE16((uint16_t)Y);}while(0)
110 #define PUTLE32_(X, Y) do{*((uint32_t *)X)=HOST2LE16((uint32_t)Y);}while(0)
112 #define GETLE32(X) (*(uint16_t *)(X)|(((uint16_t *)(X))[1]<<16))
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)
115 #define GETLE32 GETLE32_
116 #define PUTLE32 PUTLE32_
119 /////////////////////////////////////////////////////////////////////////////
121 typedef struct VRAMLOADTTAG
129 unsigned short *ImagePtr;
132 /////////////////////////////////////////////////////////////////////////////
134 typedef struct PSXPOINTTAG
140 typedef struct PSXSPOINTTAG
146 typedef struct PSXRECTTAG
154 // linux defines for some windows stuff
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
165 #define __int64 long long int
168 typedef struct RECTTAG
176 /////////////////////////////////////////////////////////////////////////////
178 typedef struct TWINTAG
183 /////////////////////////////////////////////////////////////////////////////
185 typedef struct PSXDISPLAYTAG
187 PSXPoint_t DisplayModeNew;
188 PSXPoint_t DisplayMode;
189 PSXPoint_t DisplayPosition;
190 PSXPoint_t DisplayEnd;
195 int32_t InterlacedNew;
199 PSXSPoint_t DrawOffset;
205 /////////////////////////////////////////////////////////////////////////////
209 extern int32_t GlobalTextAddrX,GlobalTextAddrY,GlobalTextTP;
210 extern int32_t GlobalTextREST,GlobalTextABR,GlobalTextPAGE;
211 extern short ly0,lx0,ly1,lx1,ly2,lx2,ly3,lx3;
212 extern long lLowerpart;
213 extern BOOL bCheckMask;
214 extern unsigned short sSetMask;
215 extern unsigned long lSetMask;
219 extern short DrawSemiTrans;
223 extern BOOL bUsingTWin;
225 extern void (*primTableJ[256])(unsigned char *);
226 extern void (*primTableSkip[256])(unsigned char *);
227 extern unsigned short usMirror;
229 extern uint32_t dwCfgFixes;
230 extern uint32_t dwActFixes;
231 extern int iUseFixes;
232 extern int iUseDither;
233 extern BOOL bDoVSyncUpdate;
234 extern int32_t drawX;
235 extern int32_t drawY;
236 extern int32_t drawW;
237 extern int32_t drawH;
244 #define KEY_RESETTEXSTORE 1
245 #define KEY_SHOWFPS 2
246 #define KEY_RESETOPAQUE 4
247 #define KEY_RESETDITHER 8
248 #define KEY_RESETFILTER 16
249 #define KEY_RESETADVBLEND 32
250 #define KEY_BADTEXTURES 128
251 #define KEY_CHECKTHISOUT 256
253 #if !defined(__BIG_ENDIAN__) || defined(__x86_64__) || defined(__i386__)
254 #ifndef __LITTLE_ENDIAN__
255 #define __LITTLE_ENDIAN__
259 #ifdef __LITTLE_ENDIAN__
260 #define RED(x) (x & 0xff)
261 #define BLUE(x) ((x>>16) & 0xff)
262 #define GREEN(x) ((x>>8) & 0xff)
263 #define COLOR(x) (x & 0xffffff)
264 #elif defined __BIG_ENDIAN__
265 #define RED(x) ((x>>24) & 0xff)
266 #define BLUE(x) ((x>>8) & 0xff)
267 #define GREEN(x) ((x>>16) & 0xff)
268 #define COLOR(x) SWAP32(x & 0xffffff)
273 extern VRAMLoad_t VRAMWrite;
274 extern VRAMLoad_t VRAMRead;
275 extern DATAREGISTERMODES DataWriteMode;
276 extern DATAREGISTERMODES DataReadMode;
277 extern short sDispWidths[];
278 extern BOOL bDebugText;
279 extern PSXDisplay_t PSXDisplay;
280 extern PSXDisplay_t PreviousPSXDisplay;
281 extern BOOL bSkipNextFrame;
282 extern long lGPUstatusRet;
283 extern unsigned char * psxVSecure;
284 extern unsigned char * psxVub;
285 extern signed char * psxVsb;
286 extern unsigned short * psxVuw;
287 extern signed short * psxVsw;
288 extern uint32_t * psxVul;
289 extern int32_t * psxVsl;
290 extern unsigned short * psxVuw_eom;
291 extern BOOL bChangeWinMode;
292 extern long lSelectedSlot;
293 extern BOOL bInitCap;
294 extern DWORD dwLaceCnt;
295 extern uint32_t lGPUInfoVals[];
296 extern uint32_t ulStatusControl[];
300 extern int UseFrameLimit;
301 extern int UseFrameSkip;
302 extern float fFrameRate;
303 extern int iFrameLimit;
304 extern float fFrameRateHz;
305 extern float fps_skip;
306 extern float fps_cur;
310 void DoBufferSwap(void);
311 void DoClearScreenBuffer(void);
312 void DoClearFrontBuffer(void);
313 unsigned long ulInitDisplay(void);
314 void CloseDisplay(void);