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)
67 #include "../../include/arm_features.h"
69 /////////////////////////////////////////////////////////////////////////////
73 #define SWAP16(x) __builtin_bswap16(x)
74 #define SWAP32(x) __builtin_bswap32(x)
76 #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
79 #define HOST2LE32(x) SWAP32(x)
80 #define HOST2BE32(x) (x)
81 #define LE2HOST32(x) SWAP32(x)
82 #define BE2HOST32(x) (x)
84 #define HOST2LE16(x) SWAP16(x)
85 #define HOST2BE16(x) (x)
86 #define LE2HOST16(x) SWAP16(x)
87 #define BE2HOST16(x) (x)
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)
97 #define HOST2LE16(x) (x)
98 #define HOST2BE16(x) SWAP16(x)
99 #define LE2HOST16(x) (x)
100 #define BE2HOST16(x) SWAP16(x)
104 #define GETLEs16(X) ((int16_t)GETLE16((uint16_t *)(X)))
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))
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
184 /////////////////////////////////////////////////////////////////////////////
186 typedef struct PSXDISPLAYTAG
188 PSXPoint_t DisplayModeNew;
189 PSXPoint_t DisplayMode;
190 PSXPoint_t DisplayPosition;
191 PSXPoint_t DisplayEnd;
196 int32_t InterlacedNew;
200 PSXSPoint_t DrawOffset;
206 /////////////////////////////////////////////////////////////////////////////
210 extern int32_t GlobalTextAddrX,GlobalTextAddrY,GlobalTextTP;
211 extern int32_t GlobalTextABR,GlobalTextPAGE;
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;
220 extern short DrawSemiTrans;
224 extern BOOL bUsingTWin;
226 extern void (*primTableJ[256])(unsigned char *);
227 extern void (*primTableSkip[256])(unsigned char *);
228 extern unsigned short usMirror;
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;
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
251 #define KEY_BADTEXTURES 128
252 #define KEY_CHECKTHISOUT 256
254 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
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)
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)
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;
280 extern unsigned short * psxVuw;
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[];
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;
301 void DoBufferSwap(void);
302 void DoClearScreenBuffer(void);
303 void DoClearFrontBuffer(void);
304 unsigned long ulInitDisplay(void);
305 void CloseDisplay(void);
308 extern const struct rearmed_cbs *rcbs;