psxmem: Add support for Lightrec's custom mem init sequence
[pcsx_rearmed.git] / plugins / dfxvideo / gpu.h
CommitLineData
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>
67
68/////////////////////////////////////////////////////////////////////////////
69
70// byteswappings
71
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)); })
74
75#ifdef __BIG_ENDIAN__
76
77// big endian config
78#define HOST2LE32(x) SWAP32(x)
79#define HOST2BE32(x) (x)
80#define LE2HOST32(x) SWAP32(x)
81#define BE2HOST32(x) (x)
82
83#define HOST2LE16(x) SWAP16(x)
84#define HOST2BE16(x) (x)
85#define LE2HOST16(x) SWAP16(x)
86#define BE2HOST16(x) (x)
87
88#else
89
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)
95
96#define HOST2LE16(x) (x)
97#define HOST2BE16(x) SWAP16(x)
98#define LE2HOST16(x) (x)
99#define BE2HOST16(x) SWAP16(x)
100
101#endif
102
103#define GETLEs16(X) ((int16_t)GETLE16((uint16_t *)X))
104#define GETLEs32(X) ((int16_t)GETLE32((uint16_t *)X))
105
106#define GETLE16(X) LE2HOST16(*(uint16_t *)X)
0d16cda2 107#define GETLE32_(X) LE2HOST32(*(uint32_t *)X)
a96a5eb2 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)
0d16cda2 110#define PUTLE32_(X, Y) do{*((uint32_t *)X)=HOST2LE16((uint32_t)Y);}while(0)
111#ifdef __arm__
a46e4627 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)
0d16cda2 114#else
115#define GETLE32 GETLE32_
116#define PUTLE32 PUTLE32_
117#endif
a96a5eb2 118
119/////////////////////////////////////////////////////////////////////////////
120
121typedef 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
134typedef struct PSXPOINTTAG
135{
136 int32_t x;
137 int32_t y;
138} PSXPoint_t;
139
140typedef struct PSXSPOINTTAG
141{
142 short x;
143 short y;
144} PSXSPoint_t;
145
146typedef 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
168typedef struct RECTTAG
169{
170 int left;
171 int top;
172 int right;
173 int bottom;
174}RECT;
175
176/////////////////////////////////////////////////////////////////////////////
177
178typedef struct TWINTAG
179{
180 PSXRect_t Position;
e429fc60 181 int xmask, ymask;
a96a5eb2 182} TWin_t;
183
184/////////////////////////////////////////////////////////////////////////////
185
186typedef 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
210extern int32_t GlobalTextAddrX,GlobalTextAddrY,GlobalTextTP;
a48f1478 211extern int32_t GlobalTextABR,GlobalTextPAGE;
a96a5eb2 212extern short ly0,lx0,ly1,lx1,ly2,lx2,ly3,lx3;
213extern long lLowerpart;
214extern BOOL bCheckMask;
215extern unsigned short sSetMask;
216extern unsigned long lSetMask;
217extern short g_m1;
218extern short g_m2;
219extern short g_m3;
220extern short DrawSemiTrans;
221
222// prim.c
223
224extern BOOL bUsingTWin;
225extern TWin_t TWin;
226extern void (*primTableJ[256])(unsigned char *);
227extern void (*primTableSkip[256])(unsigned char *);
228extern unsigned short usMirror;
229extern int iDither;
230extern uint32_t dwCfgFixes;
231extern uint32_t dwActFixes;
232extern int iUseFixes;
233extern int iUseDither;
234extern BOOL bDoVSyncUpdate;
235extern int32_t drawX;
236extern int32_t drawY;
237extern int32_t drawW;
238extern 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
254#if !defined(__BIG_ENDIAN__) || defined(__x86_64__) || defined(__i386__)
255#ifndef __LITTLE_ENDIAN__
256#define __LITTLE_ENDIAN__
257#endif
258#endif
259
260#ifdef __LITTLE_ENDIAN__
261#define RED(x) (x & 0xff)
262#define BLUE(x) ((x>>16) & 0xff)
263#define GREEN(x) ((x>>8) & 0xff)
264#define COLOR(x) (x & 0xffffff)
265#elif defined __BIG_ENDIAN__
266#define RED(x) ((x>>24) & 0xff)
267#define BLUE(x) ((x>>8) & 0xff)
268#define GREEN(x) ((x>>16) & 0xff)
269#define COLOR(x) SWAP32(x & 0xffffff)
270#endif
271
a96a5eb2 272// gpu.c
ef79bbde 273
a96a5eb2 274extern VRAMLoad_t VRAMWrite;
275extern VRAMLoad_t VRAMRead;
276extern DATAREGISTERMODES DataWriteMode;
277extern DATAREGISTERMODES DataReadMode;
278extern short sDispWidths[];
279extern BOOL bDebugText;
280extern PSXDisplay_t PSXDisplay;
281extern PSXDisplay_t PreviousPSXDisplay;
282extern BOOL bSkipNextFrame;
283extern long lGPUstatusRet;
284extern unsigned char * psxVSecure;
285extern unsigned char * psxVub;
286extern signed char * psxVsb;
287extern unsigned short * psxVuw;
288extern signed short * psxVsw;
289extern uint32_t * psxVul;
290extern int32_t * psxVsl;
291extern unsigned short * psxVuw_eom;
292extern BOOL bChangeWinMode;
293extern long lSelectedSlot;
294extern BOOL bInitCap;
295extern DWORD dwLaceCnt;
296extern uint32_t lGPUInfoVals[];
297extern uint32_t ulStatusControl[];
ef79bbde 298
a96a5eb2 299// fps.c
300
301extern int UseFrameLimit;
302extern int UseFrameSkip;
303extern float fFrameRate;
304extern int iFrameLimit;
305extern float fFrameRateHz;
306extern float fps_skip;
307extern float fps_cur;
ef79bbde 308
a96a5eb2 309// draw.c
310
311void DoBufferSwap(void);
312void DoClearScreenBuffer(void);
313void DoClearFrontBuffer(void);
314unsigned long ulInitDisplay(void);
315void CloseDisplay(void);
316
76f7048e 317struct rearmed_cbs;
318extern const struct rearmed_cbs *rcbs;
319
a96a5eb2 320#endif