frontend: make text bg dark
[pcsx_rearmed.git] / plugins / gpu-gles / gpuPrim.c
CommitLineData
ce879073 1/***************************************************************************\r
2 prim.c - description\r
3 -------------------\r
4 begin : Sun Mar 08 2009\r
5 copyright : (C) 1999-2009 by Pete Bernert\r
6 web : www.pbernert.com \r
7 ***************************************************************************/\r
8\r
9/***************************************************************************\r
10 * *\r
11 * This program is free software; you can redistribute it and/or modify *\r
12 * it under the terms of the GNU General Public License as published by *\r
13 * the Free Software Foundation; either version 2 of the License, or *\r
14 * (at your option) any later version. See also the license.txt file for *\r
15 * additional informations. *\r
16 * *\r
17 ***************************************************************************/\r
18\r
19//*************************************************************************// \r
20// History of changes:\r
21//\r
22// 2009/03/08 - Pete \r
23// - generic cleanup for the Peops release\r
24//\r
25//*************************************************************************// \r
26\r
27#define _IN_PRIMDRAW\r
28\r
ce879073 29#include "gpuStdafx.h"\r
30#include "gpuExternals.h"\r
31#include "gpuPlugin.h"\r
32#include "gpuDraw.h"\r
33#include "gpuTexture.h"\r
34#include "gpuPrim.h"\r
35\r
ce879073 36//////////////////////////////////////////////////////////////////////// \r
37// defines\r
38////////////////////////////////////////////////////////////////////////\r
39\r
40#define DEFOPAQUEON glAlphaFunc(GL_EQUAL,0.0f);bBlendEnable=FALSE;glDisable(GL_BLEND); \r
41#define DEFOPAQUEOFF glAlphaFunc(GL_GREATER,0.49f);\r
42#define fpoint(x) x\r
43//////////////////////////////////////////////////////////////////////// \r
44// globals\r
45////////////////////////////////////////////////////////////////////////\r
46\r
13326d3e 47EGLSurface surface;\r
48EGLDisplay display;\r
49\r
ce879073 50\r
51BOOL bDrawTextured; // current active drawing states\r
52BOOL bDrawSmoothShaded;\r
53BOOL bOldSmoothShaded;\r
54BOOL bDrawNonShaded;\r
55BOOL bDrawMultiPass;\r
56int iOffscreenDrawing;\r
57int iDrawnSomething=0;\r
58\r
59BOOL bRenderFrontBuffer=FALSE; // flag for front buffer rendering\r
60\r
61GLubyte ubGloAlpha; // texture alpha\r
62GLubyte ubGloColAlpha; // color alpha\r
63int iFilterType; // type of filter\r
64BOOL bFullVRam=FALSE; // sign for tex win\r
65BOOL bDrawDither; // sign for dither\r
66BOOL bUseMultiPass; // sign for multi pass\r
67GLuint gTexName; // binded texture\r
68BOOL bTexEnabled; // texture enable flag\r
69BOOL bBlendEnable; // blend enable flag\r
70PSXRect_t xrUploadArea; // rect to upload\r
71PSXRect_t xrUploadAreaIL; // rect to upload\r
72PSXRect_t xrUploadAreaRGB24; // rect to upload rgb24\r
73int iSpriteTex=0; // flag for "hey, it's a sprite"\r
74unsigned short usMirror; // mirror, mirror on the wall\r
75\r
76BOOL bNeedUploadAfter=FALSE; // sign for uploading in next frame\r
77BOOL bNeedUploadTest=FALSE; // sign for upload test\r
78BOOL bUsingTWin=FALSE; // tex win active flag\r
79BOOL bUsingMovie=FALSE; // movie active flag\r
80PSXRect_t xrMovieArea; // rect for movie upload\r
81short sSprite_ux2; // needed for sprire adjust\r
82short sSprite_vy2; // \r
83unsigned long ulOLDCOL=0; // active color\r
84unsigned long ulClutID; // clut\r
85\r
86unsigned long dwCfgFixes; // game fixes\r
87unsigned long dwActFixes=0;\r
88unsigned long dwEmuFixes=0;\r
89BOOL bUseFixes;\r
90\r
91long drawX,drawY,drawW,drawH; // offscreen drawing checkers\r
92short sxmin,sxmax,symin,symax;\r
ac608d8a 93unsigned int CSVERTEX=0,CSCOLOR=0,CSTEXTURE=0;\r
94\r
95void offsetPSX4(void)\r
96{\r
97 lx0 += PSXDisplay.DrawOffset.x;\r
98 ly0 += PSXDisplay.DrawOffset.y;\r
99 lx1 += PSXDisplay.DrawOffset.x;\r
100 ly1 += PSXDisplay.DrawOffset.y;\r
101 lx2 += PSXDisplay.DrawOffset.x;\r
102 ly2 += PSXDisplay.DrawOffset.y;\r
103 lx3 += PSXDisplay.DrawOffset.x;\r
104 ly3 += PSXDisplay.DrawOffset.y;\r
105}\r
ce879073 106\r
107//////////////////////////////////////////////////////////////////////// \r
108// Update global TP infos\r
109////////////////////////////////////////////////////////////////////////\r
110\r
111void UpdateGlobalTP(unsigned short gdata)\r
112{\r
113 GlobalTextAddrX = (gdata << 6) & 0x3c0;\r
114\r
115 if(iGPUHeight==1024) // ZN mode\r
116 {\r
117 if(dwGPUVersion==2) // very special zn gpu\r
118 {\r
119 GlobalTextAddrY =((gdata & 0x60 ) << 3);\r
120 GlobalTextIL =(gdata & 0x2000) >> 13;\r
121 GlobalTextABR = (unsigned short)((gdata >> 7) & 0x3);\r
122 GlobalTextTP = (gdata >> 9) & 0x3;\r
123 if(GlobalTextTP==3) GlobalTextTP=2; \r
124 GlobalTexturePage = (GlobalTextAddrX>>6)+(GlobalTextAddrY>>4);\r
125 usMirror =0;\r
126 STATUSREG = (STATUSREG & 0xffffe000 ) | (gdata & 0x1fff );\r
127 return;\r
128 }\r
129 else // "enhanced" psx gpu\r
130 {\r
131 GlobalTextAddrY = (unsigned short)(((gdata << 4) & 0x100) | ((gdata >> 2) & 0x200));\r
132 }\r
133 }\r
134 else GlobalTextAddrY = (gdata << 4) & 0x100; // "normal" psx gpu\r
135\r
136 usMirror=gdata&0x3000;\r
137 \r
138 GlobalTextTP = (gdata >> 7) & 0x3; // tex mode (4,8,15)\r
139 if(GlobalTextTP==3) GlobalTextTP=2; // seen in Wild9 :(\r
140 GlobalTextABR = (gdata >> 5) & 0x3; // blend mode\r
141\r
142 GlobalTexturePage = (GlobalTextAddrX>>6)+(GlobalTextAddrY>>4);\r
143\r
144 STATUSREG&=~0x07ff; // Clear the necessary bits\r
145 STATUSREG|=(gdata & 0x07ff); // set the necessary bits\r
146}\r
147\r
148//////////////////////////////////////////////////////////////////////// \r
149// Some ASM color convertion... Lewpy's special...\r
150////////////////////////////////////////////////////////////////////////\r
151\r
ce879073 152\r
153unsigned long DoubleBGR2RGB (unsigned long BGR)\r
154{\r
155 unsigned long ebx,eax,edx;\r
156\r
157 ebx=(BGR&0x000000ff)<<1;\r
158 if(ebx&0x00000100) ebx=0x000000ff;\r
159\r
160 eax=(BGR&0x0000ff00)<<1;\r
161 if(eax&0x00010000) eax=0x0000ff00;\r
162\r
163 edx=(BGR&0x00ff0000)<<1;\r
164 if(edx&0x01000000) edx=0x00ff0000;\r
165\r
166 return (ebx|eax|edx);\r
167}\r
168\r
169unsigned short BGR24to16 (unsigned long BGR)\r
170{\r
171 return ((BGR>>3)&0x1f)|((BGR&0xf80000)>>9)|((BGR&0xf800)>>6);\r
172}\r
173\r
ce879073 174\r
175////////////////////////////////////////////////////////////////////////\r
176// OpenGL primitive drawing commands\r
177////////////////////////////////////////////////////////////////////////\r
178\r
13326d3e 179void PRIMdrawTexturedQuad(OGLVertex* vertex1, OGLVertex* vertex2,\r
ce879073 180 OGLVertex* vertex3, OGLVertex* vertex4) \r
181{\r
182\r
183\r
184Vertex v[4];\r
185\r
186v[0].xyz.x = fpoint(vertex1->x);\r
187v[0].xyz.y = fpoint(vertex1->y);\r
188v[0].xyz.z = fpoint(vertex1->z);\r
189v[0].st.x = fpoint(vertex1->sow);\r
190v[0].st.y = fpoint(vertex1->tow);\r
191\r
192v[1].xyz.x = fpoint(vertex2->x);\r
193v[1].xyz.y = fpoint(vertex2->y);\r
194v[1].xyz.z = fpoint(vertex2->z);\r
195v[1].st.x = fpoint(vertex2->sow);\r
196v[1].st.y = fpoint(vertex2->tow);\r
197\r
198v[2].xyz.x = fpoint(vertex4->x);\r
199v[2].xyz.y = fpoint(vertex4->y);\r
200v[2].xyz.z = fpoint(vertex4->z);\r
201v[2].st.x = fpoint(vertex4->sow);\r
202v[2].st.y = fpoint(vertex4->tow);\r
203\r
204v[3].xyz.x = fpoint(vertex3->x);\r
205v[3].xyz.y = fpoint(vertex3->y);\r
206v[3].xyz.z = fpoint(vertex3->z);\r
207v[3].st.x = fpoint(vertex3->sow);\r
208v[3].st.y = fpoint(vertex3->tow);\r
ac608d8a 209if (CSCOLOR==1) glDisableClientState(GL_COLOR_ARRAY);glError();\r
210if (CSTEXTURE==0) glEnableClientState(GL_TEXTURE_COORD_ARRAY);glError();\r
211if (CSVERTEX==0) glEnableClientState(GL_VERTEX_ARRAY);glError();\r
212glTexCoordPointer(2, GL_FLOAT, sizeof(v[0]), &v[0].st);glError();\r
213glVertexPointer(3, GL_FLOAT, sizeof(v[0]), &v[0].xyz);glError();\r
214glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);glError();\r
215CSTEXTURE=CSVERTEX=1;\r
216CSCOLOR=0;\r
ce879073 217}\r
218\r
219///////////////////////////////////////////////////////// \r
220\r
ac608d8a 221void PRIMdrawTexturedTri(OGLVertex* vertex1, OGLVertex* vertex2,\r
ce879073 222 OGLVertex* vertex3) \r
223{\r
224Vertex v[3];\r
ac608d8a 225if (vertex1->x==0&&vertex1->y==0&&vertex2->x==0&&vertex2->y==0&&vertex3->x==0&&vertex3->y==0) return;\r
ce879073 226\r
227v[0].xyz.x = fpoint(vertex1->x);\r
228v[0].xyz.y = fpoint(vertex1->y);\r
229v[0].xyz.z = fpoint(vertex1->z);\r
230v[0].st.x = fpoint(vertex1->sow);\r
231v[0].st.y = fpoint(vertex1->tow);\r
232\r
233v[1].xyz.x = fpoint(vertex2->x);\r
234v[1].xyz.y = fpoint(vertex2->y);\r
235v[1].xyz.z = fpoint(vertex2->z);\r
236v[1].st.x = fpoint(vertex2->sow);\r
237v[1].st.y = fpoint(vertex2->tow);\r
238\r
239v[2].xyz.x = fpoint(vertex3->x);\r
240v[2].xyz.y = fpoint(vertex3->y);\r
241v[2].xyz.z = fpoint(vertex3->z);\r
242v[2].st.x = fpoint(vertex3->sow);\r
243v[2].st.y = fpoint(vertex3->tow);\r
ac608d8a 244if (CSCOLOR==1) glDisableClientState(GL_COLOR_ARRAY);glError();\r
245if (CSTEXTURE==0) glEnableClientState(GL_TEXTURE_COORD_ARRAY);glError();\r
246if (CSVERTEX==0) glEnableClientState(GL_VERTEX_ARRAY);glError();\r
247glTexCoordPointer(2, GL_FLOAT, sizeof(v[0]), &v[0].st);glError();\r
248glVertexPointer(3, GL_FLOAT, sizeof(v[0]), &v[0].xyz);glError();\r
249glDrawArrays(GL_TRIANGLES, 0, 3);glError();\r
250CSTEXTURE=CSVERTEX=1;\r
251CSCOLOR=0;\r
ce879073 252\r
253}\r
254\r
255///////////////////////////////////////////////////////// \r
256\r
ac608d8a 257void PRIMdrawTexGouraudTriColor(OGLVertex* vertex1, OGLVertex* vertex2,\r
ce879073 258 OGLVertex* vertex3) \r
259{\r
260\r
261Vertex2 v[3];\r
ac608d8a 262if (vertex1->x==0&&vertex1->y==0&&vertex2->x==0&&vertex2->y==0&&vertex3->x==0&&vertex3->y==0) return;\r
ce879073 263\r
264v[0].xyz.x = fpoint(vertex1->x);\r
265v[0].xyz.y = fpoint(vertex1->y);\r
266v[0].xyz.z = fpoint(vertex1->z);\r
267v[0].st.x = fpoint(vertex1->sow);\r
268v[0].st.y = fpoint(vertex1->tow);\r
269v[0].rgba.r = vertex1->c.col[0];\r
270v[0].rgba.g = vertex1->c.col[1];\r
271v[0].rgba.b = vertex1->c.col[2];\r
272v[0].rgba.a = vertex1->c.col[3];\r
273\r
274v[1].xyz.x = fpoint(vertex2->x);\r
275v[1].xyz.y = fpoint(vertex2->y);\r
276v[1].xyz.z = fpoint(vertex2->z);\r
277v[1].st.x = fpoint(vertex2->sow);\r
278v[1].st.y = fpoint(vertex2->tow);\r
279v[1].rgba.r = vertex2->c.col[0];\r
280v[1].rgba.g = vertex2->c.col[1];\r
281v[1].rgba.b = vertex2->c.col[2];\r
282v[1].rgba.a = vertex2->c.col[3];\r
283\r
284v[2].xyz.x = fpoint(vertex3->x);\r
285v[2].xyz.y = fpoint(vertex3->y);\r
286v[2].xyz.z = fpoint(vertex3->z);\r
287v[2].st.x = fpoint(vertex3->sow);\r
288v[2].st.y = fpoint(vertex3->tow);\r
289v[2].rgba.r = vertex3->c.col[0];\r
290v[2].rgba.g = vertex3->c.col[1];\r
291v[2].rgba.b = vertex3->c.col[2];\r
292v[2].rgba.a = vertex3->c.col[3];\r
293\r
ac608d8a 294if (CSTEXTURE==0) glEnableClientState(GL_TEXTURE_COORD_ARRAY);glError();\r
295if (CSVERTEX==0) glEnableClientState(GL_VERTEX_ARRAY);glError();\r
296if (CSCOLOR==0) glEnableClientState(GL_COLOR_ARRAY);glError();\r
ce879073 297\r
ac608d8a 298glTexCoordPointer(2, GL_FLOAT, sizeof(v[0]), &v[0].st);glError();\r
299glVertexPointer(3, GL_FLOAT, sizeof(v[0]), &v[0].xyz);glError();\r
300glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(v[0]), &v[0].rgba);glError();\r
ce879073 301\r
ac608d8a 302glDrawArrays(GL_TRIANGLES, 0, 3);glError();\r
303CSTEXTURE=CSVERTEX=CSCOLOR=1;\r
ce879073 304}\r
305\r
306///////////////////////////////////////////////////////// \r
307\r
ac608d8a 308void PRIMdrawTexGouraudTriColorQuad(OGLVertex* vertex1, OGLVertex* vertex2,\r
ce879073 309 OGLVertex* vertex3, OGLVertex* vertex4) \r
310{\r
311Vertex2 v[4];\r
ac608d8a 312if (vertex1->x==0&&vertex1->y==0&&vertex2->x==0&&vertex2->y==0&&vertex3->x==0&&vertex3->y==0&&vertex4->x==0&&vertex4->y==0) return;\r
ce879073 313\r
314v[0].xyz.x = fpoint(vertex1->x);\r
315v[0].xyz.y = fpoint(vertex1->y);\r
316v[0].xyz.z = fpoint(vertex1->z);\r
317v[0].st.x = fpoint(vertex1->sow);\r
318v[0].st.y = fpoint(vertex1->tow);\r
319v[0].rgba.r = vertex1->c.col[0];\r
320v[0].rgba.g = vertex1->c.col[1];\r
321v[0].rgba.b = vertex1->c.col[2];\r
322v[0].rgba.a = vertex1->c.col[3];\r
323\r
324v[1].xyz.x = fpoint(vertex2->x);\r
325v[1].xyz.y = fpoint(vertex2->y);\r
326v[1].xyz.z = fpoint(vertex2->z);\r
327v[1].st.x = fpoint(vertex2->sow);\r
328v[1].st.y = fpoint(vertex2->tow);\r
329v[1].rgba.r = vertex2->c.col[0];\r
330v[1].rgba.g = vertex2->c.col[1];\r
331v[1].rgba.b = vertex2->c.col[2];\r
332v[1].rgba.a = vertex2->c.col[3];\r
333\r
334v[2].xyz.x = fpoint(vertex4->x);\r
335v[2].xyz.y = fpoint(vertex4->y);\r
336v[2].xyz.z = fpoint(vertex4->z);\r
337v[2].st.x = fpoint(vertex4->sow);\r
338v[2].st.y = fpoint(vertex4->tow);\r
339v[2].rgba.r = vertex4->c.col[0];\r
340v[2].rgba.g = vertex4->c.col[1];\r
341v[2].rgba.b = vertex4->c.col[2];\r
342v[2].rgba.a = vertex4->c.col[3];\r
343\r
344v[3].xyz.x = fpoint(vertex3->x);\r
345v[3].xyz.y = fpoint(vertex3->y);\r
346v[3].xyz.z = fpoint(vertex3->z);\r
347v[3].st.x = fpoint(vertex3->sow);\r
348v[3].st.y = fpoint(vertex3->tow);\r
349v[3].rgba.r = vertex3->c.col[0];\r
350v[3].rgba.g = vertex3->c.col[1];\r
351v[3].rgba.b = vertex3->c.col[2];\r
352v[3].rgba.a = vertex3->c.col[3];\r
353\r
ac608d8a 354if (CSTEXTURE==0) glEnableClientState(GL_TEXTURE_COORD_ARRAY);glError();\r
355if (CSVERTEX==0) glEnableClientState(GL_VERTEX_ARRAY);glError();\r
356if (CSCOLOR==0) glEnableClientState(GL_COLOR_ARRAY);glError();\r
ce879073 357\r
ac608d8a 358glTexCoordPointer(2, GL_FLOAT, sizeof(v[0]), &v[0].st);glError();\r
359glVertexPointer(3, GL_FLOAT, sizeof(v[0]), &v[0].xyz);glError();\r
360glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(v[0]), &v[0].rgba);glError();\r
ce879073 361\r
ac608d8a 362glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);glError();\r
363CSTEXTURE=CSVERTEX=CSCOLOR=1;\r
ce879073 364}\r
365\r
366///////////////////////////////////////////////////////// \r
367\r
ac608d8a 368void PRIMdrawTri(OGLVertex* vertex1, OGLVertex* vertex2, OGLVertex* vertex3)\r
ce879073 369{\r
370Vec3f v[3];\r
ac608d8a 371if (vertex1->x==0&&vertex1->y==0&&vertex2->x==0&&vertex2->y==0&&vertex3->x==0&&vertex3->y==0) return;\r
ce879073 372\r
373v[0].x = fpoint(vertex1->x);\r
374v[0].y = fpoint(vertex1->y);\r
375v[0].z = fpoint(vertex1->z);\r
376\r
377v[1].x = fpoint(vertex2->x);\r
378v[1].y = fpoint(vertex2->y);\r
379v[1].z = fpoint(vertex2->z);\r
380\r
381v[2].x = fpoint(vertex3->x);\r
382v[2].y = fpoint(vertex3->y);\r
383v[2].z = fpoint(vertex3->z);\r
384\r
ac608d8a 385if (CSVERTEX==0) glEnableClientState(GL_VERTEX_ARRAY);glError();\r
386if (CSTEXTURE==1) glDisableClientState(GL_TEXTURE_COORD_ARRAY);glError();\r
387if (CSCOLOR==1) glDisableClientState(GL_COLOR_ARRAY);glError();\r
388\r
389glVertexPointer(3, GL_FLOAT, sizeof(v[0]), &v[0]);glError();\r
390glDrawArrays(GL_TRIANGLES, 0, 3);glError();\r
391CSVERTEX=1;\r
392CSTEXTURE=CSCOLOR=0;\r
393\r
ce879073 394}\r
395\r
396///////////////////////////////////////////////////////// \r
397\r
ac608d8a 398void PRIMdrawTri2(OGLVertex* vertex1, OGLVertex* vertex2,\r
ce879073 399 OGLVertex* vertex3, OGLVertex* vertex4) \r
400{\r
401Vec3f v[4];\r
ac608d8a 402if (vertex1->x==0&&vertex1->y==0&&vertex2->x==0&&vertex2->y==0&&vertex3->x==0&&vertex3->y==0&&vertex4->x==0&&vertex4->y==0) return;\r
ce879073 403\r
404v[0].x = fpoint(vertex1->x);\r
405v[0].y = fpoint(vertex1->y);\r
406v[0].z = fpoint(vertex1->z);\r
407\r
408v[1].x = fpoint(vertex3->x);\r
409v[1].y = fpoint(vertex3->y);\r
410v[1].z = fpoint(vertex3->z);\r
411\r
412v[2].x = fpoint(vertex2->x);\r
413v[2].y = fpoint(vertex2->y);\r
414v[2].z = fpoint(vertex2->z);\r
415\r
416v[3].x = fpoint(vertex4->x);\r
417v[3].y = fpoint(vertex4->y);\r
418v[3].z = fpoint(vertex4->z);\r
419\r
ac608d8a 420if (CSVERTEX==0) glEnableClientState(GL_VERTEX_ARRAY);glError();\r
421if (CSTEXTURE==1) glDisableClientState(GL_TEXTURE_COORD_ARRAY);glError();\r
422if (CSCOLOR==1) glDisableClientState(GL_COLOR_ARRAY);glError();\r
423\r
424glVertexPointer(3, GL_FLOAT, sizeof(v[0]), &v[0]);glError();\r
425glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);glError();\r
426CSVERTEX=1;\r
427CSTEXTURE=CSCOLOR=0;\r
ce879073 428}\r
429\r
430///////////////////////////////////////////////////////// \r
431\r
ac608d8a 432void PRIMdrawGouraudTriColor(OGLVertex* vertex1, OGLVertex* vertex2,\r
ce879073 433 OGLVertex* vertex3) \r
434{\r
435Vertex2 v[3];\r
ac608d8a 436if (vertex1->x==0&&vertex1->y==0&&vertex2->x==0&&vertex2->y==0&&vertex3->x==0&&vertex3->y==0) return;\r
ce879073 437\r
438v[0].xyz.x = fpoint(vertex1->x);\r
439v[0].xyz.y = fpoint(vertex1->y);\r
440v[0].xyz.z = fpoint(vertex1->z);\r
441v[0].rgba.r = vertex1->c.col[0];\r
442v[0].rgba.g = vertex1->c.col[1];\r
443v[0].rgba.b = vertex1->c.col[2];\r
444v[0].rgba.a = vertex1->c.col[3];\r
445\r
446v[1].xyz.x = fpoint(vertex2->x);\r
447v[1].xyz.y = fpoint(vertex2->y);\r
448v[1].xyz.z = fpoint(vertex2->z);\r
449v[1].rgba.r = vertex2->c.col[0];\r
450v[1].rgba.g = vertex2->c.col[1];\r
451v[1].rgba.b = vertex2->c.col[2];\r
452v[1].rgba.a = vertex2->c.col[3];\r
453\r
454v[2].xyz.x = fpoint(vertex3->x);\r
455v[2].xyz.y = fpoint(vertex3->y);\r
456v[2].xyz.z = fpoint(vertex3->z);\r
457v[2].rgba.r = vertex3->c.col[0];\r
458v[2].rgba.g = vertex3->c.col[1];\r
459v[2].rgba.b = vertex3->c.col[2];\r
460v[2].rgba.a = vertex3->c.col[3];\r
461\r
ac608d8a 462if (CSVERTEX==0) glEnableClientState(GL_VERTEX_ARRAY);glError();\r
463if (CSCOLOR==0) glEnableClientState(GL_COLOR_ARRAY);glError();\r
464if (CSTEXTURE==1) glDisableClientState(GL_TEXTURE_COORD_ARRAY);glError();\r
ce879073 465\r
ac608d8a 466glVertexPointer(3, GL_FLOAT, sizeof(v[0]), &v[0].xyz);glError();\r
467glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(v[0]), &v[0].rgba);glError();\r
ce879073 468\r
ac608d8a 469glDrawArrays(GL_TRIANGLES, 0, 3);glError();\r
470CSVERTEX=CSCOLOR=1;\r
471CSTEXTURE=0;\r
ce879073 472}\r
473\r
474///////////////////////////////////////////////////////// \r
475\r
ac608d8a 476void PRIMdrawGouraudTri2Color(OGLVertex* vertex1, OGLVertex* vertex2,\r
ce879073 477 OGLVertex* vertex3, OGLVertex* vertex4) \r
478{\r
479Vertex2 v[4];\r
ac608d8a 480if (vertex1->x==0&&vertex1->y==0&&vertex2->x==0&&vertex2->y==0&&vertex3->x==0&&vertex3->y==0&&vertex4->x==0&&vertex4->y==0) return;\r
ce879073 481\r
482v[0].xyz.x = fpoint(vertex1->x);\r
483v[0].xyz.y = fpoint(vertex1->y);\r
484v[0].xyz.z = fpoint(vertex1->z);\r
485v[0].rgba.r = vertex1->c.col[0];\r
486v[0].rgba.g = vertex1->c.col[1];\r
487v[0].rgba.b = vertex1->c.col[2];\r
488v[0].rgba.a = vertex1->c.col[3];\r
489\r
490v[1].xyz.x = fpoint(vertex2->x);\r
491v[1].xyz.y = fpoint(vertex2->y);\r
492v[1].xyz.z = fpoint(vertex2->z);\r
493v[1].rgba.r = vertex2->c.col[0];\r
494v[1].rgba.g = vertex2->c.col[1];\r
495v[1].rgba.b = vertex2->c.col[2];\r
496v[1].rgba.a = vertex2->c.col[3];\r
497\r
498v[2].xyz.x = fpoint(vertex3->x);\r
499v[2].xyz.y = fpoint(vertex3->y);\r
500v[2].xyz.z = fpoint(vertex3->z);\r
501v[2].rgba.r = vertex3->c.col[0];\r
502v[2].rgba.g = vertex3->c.col[1];\r
503v[2].rgba.b = vertex3->c.col[2];\r
504v[2].rgba.a = vertex3->c.col[3];\r
505\r
506v[3].xyz.x = fpoint(vertex4->x);\r
507v[3].xyz.y = fpoint(vertex4->y);\r
508v[3].xyz.z = fpoint(vertex4->z);\r
509v[3].rgba.r = vertex4->c.col[0];\r
510v[3].rgba.g = vertex4->c.col[1];\r
511v[3].rgba.b = vertex4->c.col[2];\r
512v[3].rgba.a = vertex4->c.col[3];\r
513\r
ac608d8a 514if (CSTEXTURE==1) glDisableClientState(GL_TEXTURE_COORD_ARRAY);glError();\r
515if (CSVERTEX==0) glEnableClientState(GL_VERTEX_ARRAY);glError();\r
516if (CSCOLOR==0) glEnableClientState(GL_COLOR_ARRAY);glError();\r
ce879073 517\r
ac608d8a 518glVertexPointer(3, GL_FLOAT, sizeof(v[0]), &v[0].xyz);glError();\r
519glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(v[0]), &v[0].rgba);glError();\r
ce879073 520\r
ac608d8a 521glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);glError();\r
522CSTEXTURE=0;\r
523CSVERTEX=CSCOLOR=1;\r
ce879073 524}\r
525\r
526///////////////////////////////////////////////////////// \r
527\r
ac608d8a 528void PRIMdrawFlatLine(OGLVertex* vertex1, OGLVertex* vertex2,OGLVertex* vertex3, OGLVertex* vertex4)\r
ce879073 529{\r
530Vertex2 v[4];\r
ac608d8a 531if (vertex1->x==0&&vertex1->y==0&&vertex2->x==0&&vertex2->y==0&&vertex3->x==0&&vertex3->y==0&&vertex4->x==0&&vertex4->y==0) return;\r
ce879073 532\r
533v[0].xyz.x = fpoint(vertex1->x);\r
534v[0].xyz.y = fpoint(vertex1->y);\r
535v[0].xyz.z = fpoint(vertex1->z);\r
536v[0].rgba.r = vertex1->c.col[0];\r
537v[0].rgba.g = vertex1->c.col[1];\r
538v[0].rgba.b = vertex1->c.col[2];\r
539v[0].rgba.a = vertex1->c.col[3];\r
540\r
541v[1].xyz.x = fpoint(vertex2->x);\r
542v[1].xyz.y = fpoint(vertex2->y);\r
543v[1].xyz.z = fpoint(vertex2->z);\r
544v[1].rgba.r = vertex1->c.col[0];\r
545v[1].rgba.g = vertex1->c.col[1];\r
546v[1].rgba.b = vertex1->c.col[2];\r
547v[1].rgba.a = vertex1->c.col[3];\r
548\r
549v[2].xyz.x = fpoint(vertex4->x);\r
550v[2].xyz.y = fpoint(vertex4->y);\r
551v[2].xyz.z = fpoint(vertex4->z);\r
552v[2].rgba.r = vertex1->c.col[0];\r
553v[2].rgba.g = vertex1->c.col[1];\r
554v[2].rgba.b = vertex1->c.col[2];\r
555v[2].rgba.a = vertex1->c.col[3];\r
556\r
557v[3].xyz.x = fpoint(vertex3->x);\r
558v[3].xyz.y = fpoint(vertex3->y);\r
559v[3].xyz.z = fpoint(vertex3->z);\r
560v[3].rgba.r = vertex1->c.col[0];\r
561v[3].rgba.g = vertex1->c.col[1];\r
562v[3].rgba.b = vertex1->c.col[2];\r
563v[3].rgba.a = vertex1->c.col[3];\r
564\r
ac608d8a 565if (CSTEXTURE==1) glDisableClientState(GL_TEXTURE_COORD_ARRAY);glError();\r
566if (CSVERTEX==0) glEnableClientState(GL_VERTEX_ARRAY);glError();\r
567if (CSCOLOR==0) glEnableClientState(GL_COLOR_ARRAY);glError();\r
ce879073 568\r
ac608d8a 569glVertexPointer(3, GL_FLOAT, sizeof(v[0]), &v[0].xyz);glError();\r
570glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(v[0]), &v[0].rgba);glError();\r
ce879073 571\r
ac608d8a 572glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);glError();\r
573\r
574CSTEXTURE=0;\r
575CSVERTEX=CSCOLOR=1;\r
ce879073 576\r
577\r
578}\r
579\r
580///////////////////////////////////////////////////////// \r
581 \r
ac608d8a 582void PRIMdrawGouraudLine(OGLVertex* vertex1, OGLVertex* vertex2,OGLVertex* vertex3, OGLVertex* vertex4)\r
ce879073 583{\r
584 Vertex2 v[4];\r
ac608d8a 585if (vertex1->x==0&&vertex1->y==0&&vertex2->x==0&&vertex2->y==0&&vertex3->x==0&&vertex3->y==0&&vertex4->x==0&&vertex4->y==0) return;\r
ce879073 586\r
587v[0].xyz.x = fpoint(vertex1->x);\r
588v[0].xyz.y = fpoint(vertex1->y);\r
589v[0].xyz.z = fpoint(vertex1->z);\r
590v[0].rgba.r = vertex1->c.col[0];\r
591v[0].rgba.g = vertex1->c.col[1];\r
592v[0].rgba.b = vertex1->c.col[2];\r
593v[0].rgba.a = vertex1->c.col[3];\r
594\r
595v[1].xyz.x = fpoint(vertex2->x);\r
596v[1].xyz.y = fpoint(vertex2->y);\r
597v[1].xyz.z = fpoint(vertex2->z);\r
598v[1].rgba.r = vertex2->c.col[0];\r
599v[1].rgba.g = vertex2->c.col[1];\r
600v[1].rgba.b = vertex2->c.col[2];\r
601v[1].rgba.a = vertex2->c.col[3];\r
602\r
603v[3].xyz.x = fpoint(vertex3->x);\r
604v[3].xyz.y = fpoint(vertex3->y);\r
605v[3].xyz.z = fpoint(vertex3->z);\r
606v[3].rgba.r = vertex3->c.col[0];\r
607v[3].rgba.g = vertex3->c.col[1];\r
608v[3].rgba.b = vertex3->c.col[2];\r
609v[3].rgba.a = vertex3->c.col[3];\r
610\r
611v[2].xyz.x = fpoint(vertex4->x);\r
612v[2].xyz.y = fpoint(vertex4->y);\r
613v[2].xyz.z = fpoint(vertex4->z);\r
614v[2].rgba.r = vertex4->c.col[0];\r
615v[2].rgba.g = vertex4->c.col[1];\r
616v[2].rgba.b = vertex4->c.col[2];\r
617v[2].rgba.a = vertex4->c.col[3];\r
618\r
ac608d8a 619if (CSTEXTURE==1) glDisableClientState(GL_TEXTURE_COORD_ARRAY);glError();\r
620if (CSVERTEX==0) glEnableClientState(GL_VERTEX_ARRAY);glError();\r
621if (CSCOLOR==0) glEnableClientState(GL_COLOR_ARRAY);glError();\r
ce879073 622\r
ac608d8a 623glVertexPointer(3, GL_FLOAT, sizeof(v[0]), &v[0].xyz);glError();\r
624glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(v[0]), &v[0].rgba);glError();\r
ce879073 625\r
ac608d8a 626glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);glError();\r
627CSTEXTURE=0;\r
628CSVERTEX=CSCOLOR=1;\r
ce879073 629}\r
630\r
631///////////////////////////////////////////////////////// \r
632 \r
ac608d8a 633void PRIMdrawQuad(OGLVertex* vertex1, OGLVertex* vertex2,\r
ce879073 634 OGLVertex* vertex3, OGLVertex* vertex4) \r
635{\r
636Vec3f v[4];\r
ac608d8a 637if (vertex1->x==0&&vertex1->y==0&&vertex2->x==0&&vertex2->y==0&&vertex3->x==0&&vertex3->y==0&&vertex4->x==0&&vertex4->y==0) return;\r
ce879073 638\r
639v[0].x = fpoint(vertex1->x);\r
640v[0].y = fpoint(vertex1->y);\r
641v[0].z = fpoint(vertex1->z);\r
642\r
643v[1].x = fpoint(vertex2->x);\r
644v[1].y = fpoint(vertex2->y);\r
645v[1].z = fpoint(vertex2->z);\r
646\r
647v[2].x = fpoint(vertex4->x);\r
648v[2].y = fpoint(vertex4->y);\r
649v[2].z = fpoint(vertex4->z);\r
650\r
651v[3].x = fpoint(vertex3->x);\r
652v[3].y = fpoint(vertex3->y);\r
653v[3].z = fpoint(vertex3->z);\r
654\r
ac608d8a 655if (CSTEXTURE==1) glDisableClientState(GL_TEXTURE_COORD_ARRAY);glError();\r
656if (CSVERTEX==0) glEnableClientState(GL_VERTEX_ARRAY);glError();\r
657if (CSCOLOR==1) glDisableClientState(GL_COLOR_ARRAY);glError();\r
658\r
659glVertexPointer(3, GL_FLOAT, sizeof(v[0]), &v[0]);glError();\r
660glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);glError();\r
661CSTEXTURE=0;\r
662CSVERTEX=1;\r
663CSCOLOR=0;\r
ce879073 664}\r
665\r
666//////////////////////////////////////////////////////////////////////// \r
667// Transparent blending settings\r
668////////////////////////////////////////////////////////////////////////\r
669\r
670static GLenum obm1=GL_ZERO;\r
671static GLenum obm2=GL_ZERO;\r
672\r
673typedef struct SEMITRANSTAG\r
674{\r
675 GLenum srcFac;\r
676 GLenum dstFac;\r
677 GLubyte alpha;\r
678} SemiTransParams;\r
679\r
680SemiTransParams TransSets[4]=\r
681{\r
682 {GL_SRC_ALPHA,GL_SRC_ALPHA, 127},\r
683 {GL_ONE, GL_ONE, 255},\r
684 {GL_ZERO, GL_ONE_MINUS_SRC_COLOR,255},\r
685 {GL_ONE_MINUS_SRC_ALPHA,GL_ONE, 192}\r
686}; \r
687\r
688////////////////////////////////////////////////////////////////////////\r
689\r
690void SetSemiTrans(void)\r
691{\r
692/*\r
693* 0.5 x B + 0.5 x F\r
694* 1.0 x B + 1.0 x F\r
695* 1.0 x B - 1.0 x F\r
696* 1.0 x B +0.25 x F\r
697*/\r
698\r
699 if(!DrawSemiTrans) // no semi trans at all?\r
700 {\r
701 if(bBlendEnable)\r
9f58cabb 702 {glDisable(GL_BLEND);glError();bBlendEnable=FALSE;}// -> don't wanna blend\r
ce879073 703 ubGloAlpha=ubGloColAlpha=255; // -> full alpha\r
704 return; // -> and bye\r
705 }\r
706\r
707 ubGloAlpha=ubGloColAlpha=TransSets[GlobalTextABR].alpha;\r
708\r
709 if(!bBlendEnable)\r
9f58cabb 710 {glEnable(GL_BLEND);glError();bBlendEnable=TRUE;} // wanna blend\r
ce879073 711\r
712 if(TransSets[GlobalTextABR].srcFac!=obm1 || \r
713 TransSets[GlobalTextABR].dstFac!=obm2)\r
714 {\r
715 //if(glBlendEquationEXTEx==NULL)\r
716 {\r
717 obm1=TransSets[GlobalTextABR].srcFac;\r
718 obm2=TransSets[GlobalTextABR].dstFac;\r
9f58cabb 719 glBlendFunc(obm1,obm2); glError(); // set blend func\r
ce879073 720 }\r
721 /*else\r
722 if(TransSets[GlobalTextABR].dstFac !=GL_ONE_MINUS_SRC_COLOR)\r
723 {\r
724 if(obm2==GL_ONE_MINUS_SRC_COLOR)\r
725 glBlendEquationEXTEx(FUNC_ADD_EXT);\r
726 obm1=TransSets[GlobalTextABR].srcFac;\r
727 obm2=TransSets[GlobalTextABR].dstFac;\r
728 glBlendFunc(obm1,obm2); // set blend func\r
729 }\r
730 else\r
731 {\r
732 glBlendEquationEXTEx(FUNC_REVERSESUBTRACT_EXT);\r
733 obm1=TransSets[GlobalTextABR].srcFac;\r
734 obm2=TransSets[GlobalTextABR].dstFac;\r
735 glBlendFunc(GL_ONE,GL_ONE); // set blend func\r
736 }*/\r
737 }\r
738}\r
739\r
740void SetScanTrans(void) // blending for scan lines\r
741{\r
742/* if(glBlendEquationEXTEx!=NULL)\r
743 {\r
744 if(obm2==GL_ONE_MINUS_SRC_COLOR)\r
745 glBlendEquationEXTEx(FUNC_ADD_EXT);\r
746 }\r
747*/\r
748 obm1=TransSets[0].srcFac;\r
749 obm2=TransSets[0].dstFac;\r
9f58cabb 750 glBlendFunc(obm1,obm2); glError(); // set blend func\r
ce879073 751}\r
752\r
753void SetScanTexTrans(void) // blending for scan mask texture\r
754{\r
755/* if(glBlendEquationEXTEx!=NULL)\r
756 {\r
757 if(obm2==GL_ONE_MINUS_SRC_COLOR)\r
758 glBlendEquationEXTEx(FUNC_ADD_EXT);\r
759 }\r
760*/\r
761 obm1=TransSets[2].srcFac;\r
762 obm2=TransSets[2].dstFac;\r
9f58cabb 763 glBlendFunc(obm1,obm2); glError(); // set blend func\r
ce879073 764}\r
765\r
766//////////////////////////////////////////////////////////////////////// \r
767// multi pass in old 'Advanced blending' mode... got it from Lewpy :)\r
768//////////////////////////////////////////////////////////////////////// \r
769\r
770SemiTransParams MultiTexTransSets[4][2]=\r
771{\r
772 {\r
773 {GL_ONE ,GL_SRC_ALPHA, 127},\r
774 {GL_SRC_ALPHA,GL_ONE, 127}\r
775 },\r
776 {\r
777 {GL_ONE, GL_SRC_ALPHA, 255},\r
778 {GL_SRC_ALPHA,GL_ONE, 255}\r
779 },\r
780 {\r
781 {GL_ZERO, GL_ONE_MINUS_SRC_COLOR,255},\r
782 {GL_ZERO, GL_ONE_MINUS_SRC_COLOR,255}\r
783 },\r
784 {\r
785 {GL_SRC_ALPHA,GL_ONE, 127},\r
786 {GL_ONE_MINUS_SRC_ALPHA,GL_ONE, 255}\r
787 }\r
788}; \r
789\r
790//////////////////////////////////////////////////////////////////////// \r
791\r
792SemiTransParams MultiColTransSets[4]=\r
793{\r
794 {GL_ONE_MINUS_SRC_ALPHA,GL_SRC_ALPHA,127},\r
795 {GL_ONE, GL_ONE, 255},\r
796 {GL_ZERO, GL_ONE_MINUS_SRC_COLOR,255},\r
797 {GL_SRC_ALPHA,GL_ONE, 127}\r
798}; \r
799\r
800//////////////////////////////////////////////////////////////////////// \r
801\r
802void SetSemiTransMulti(int Pass)\r
803{\r
804 static GLenum bm1=GL_ZERO;\r
805 static GLenum bm2=GL_ONE;\r
806\r
807 ubGloAlpha=255;\r
808 ubGloColAlpha=255;\r
809 \r
810 // are we enabling SemiTransparent mode?\r
811 if(DrawSemiTrans)\r
812 {\r
813 if(bDrawTextured)\r
814 {\r
815 bm1=MultiTexTransSets[GlobalTextABR][Pass].srcFac;\r
816 bm2=MultiTexTransSets[GlobalTextABR][Pass].dstFac;\r
817 ubGloAlpha=MultiTexTransSets[GlobalTextABR][Pass].alpha;\r
818 }\r
819 // no texture\r
820 else\r
821 {\r
822 bm1=MultiColTransSets[GlobalTextABR].srcFac;\r
823 bm2=MultiColTransSets[GlobalTextABR].dstFac;\r
824 ubGloColAlpha=MultiColTransSets[GlobalTextABR].alpha;\r
825 }\r
826 }\r
827 // no shading\r
828 else\r
829 {\r
830 if(Pass==0)\r
831 {\r
832 // disable blending\r
833 bm1=GL_ONE;bm2=GL_ZERO;\r
834 }\r
835 else\r
836 {\r
837 // disable blending, but add src col a second time\r
838 bm1=GL_ONE;bm2=GL_ONE;\r
839 }\r
840 }\r
841\r
842 if(!bBlendEnable)\r
9f58cabb 843 {glEnable(GL_BLEND);glError();bBlendEnable=TRUE;} // wanna blend\r
ce879073 844\r
845 if(bm1!=obm1 || bm2!=obm2)\r
846 {\r
9f58cabb 847 glBlendFunc(bm1,bm2); glError(); // set blend func\r
ce879073 848 obm1=bm1;obm2=bm2;\r
849 }\r
850}\r
851\r
852//////////////////////////////////////////////////////////////////////// \r
853// Set several rendering stuff including blending \r
854////////////////////////////////////////////////////////////////////////\r
855\r
ac608d8a 856void SetZMask3O(void)\r
ce879073 857{\r
858 if(iUseMask && DrawSemiTrans && !iSetMask)\r
859 {\r
860 vertex[0].z=vertex[1].z=vertex[2].z=gl_z;\r
861 gl_z+=0.00004f;\r
862 }\r
863}\r
864\r
ac608d8a 865void SetZMask3(void)\r
ce879073 866{\r
867 if(iUseMask)\r
868 {\r
869 if(iSetMask || DrawSemiTrans)\r
870 {vertex[0].z=vertex[1].z=vertex[2].z=0.95f;}\r
871 else\r
872 {\r
873 vertex[0].z=vertex[1].z=vertex[2].z=gl_z;\r
874 gl_z+=0.00004f;\r
875 }\r
876 }\r
877}\r
878\r
ac608d8a 879void SetZMask3NT(void)\r
ce879073 880{\r
881 if(iUseMask)\r
882 {\r
883 if(iSetMask)\r
884 {vertex[0].z=vertex[1].z=vertex[2].z=0.95f;}\r
885 else\r
886 {\r
887 vertex[0].z=vertex[1].z=vertex[2].z=gl_z;\r
888 gl_z+=0.00004f;\r
889 }\r
890 }\r
891}\r
892\r
893////////////////////////////////////////////////////////////////////////\r
894\r
ac608d8a 895 void SetZMask4O(void)\r
ce879073 896{\r
897 if(iUseMask && DrawSemiTrans && !iSetMask)\r
898 {\r
899 vertex[0].z=vertex[1].z=vertex[2].z=vertex[3].z=gl_z;\r
900 gl_z+=0.00004f;\r
901 }\r
902}\r
903\r
ac608d8a 904 void SetZMask4(void)\r
ce879073 905{\r
906 if(iUseMask)\r
907 {\r
908 if(iSetMask || DrawSemiTrans)\r
909 {vertex[0].z=vertex[1].z=vertex[2].z=vertex[3].z=0.95f;}\r
910 else\r
911 {\r
912 vertex[0].z=vertex[1].z=vertex[2].z=vertex[3].z=gl_z;\r
913 gl_z+=0.00004f;\r
914 }\r
915 }\r
916}\r
917\r
ac608d8a 918 void SetZMask4NT(void)\r
ce879073 919{\r
920 if(iUseMask)\r
921 {\r
922 if(iSetMask==1)\r
923 {vertex[0].z=vertex[1].z=vertex[2].z=vertex[3].z=0.95f;}\r
924 else\r
925 {\r
926 vertex[0].z=vertex[1].z=vertex[2].z=vertex[3].z=gl_z;\r
927 gl_z+=0.00004f;\r
928 }\r
929 }\r
930}\r
931\r
ac608d8a 932 void SetZMask4SP(void)\r
ce879073 933{\r
934 if(iUseMask)\r
935 {\r
936 if(iSetMask==1)\r
937 {vertex[0].z=vertex[1].z=vertex[2].z=vertex[3].z=0.95f;}\r
938 else\r
939 {\r
940 if(bCheckMask)\r
941 {\r
942 vertex[0].z=vertex[1].z=vertex[2].z=vertex[3].z=gl_z;\r
943 gl_z+=0.00004f;\r
944 }\r
945 else\r
946 {vertex[0].z=vertex[1].z=vertex[2].z=vertex[3].z=0.95f;}\r
947 }\r
948 }\r
949}\r
950\r
951////////////////////////////////////////////////////////////////////////\r
952\r
ac608d8a 953 void SetRenderState(unsigned long DrawAttributes)\r
ce879073 954{\r
955 bDrawNonShaded = (SHADETEXBIT(DrawAttributes)) ? TRUE : FALSE;\r
956 DrawSemiTrans = (SEMITRANSBIT(DrawAttributes)) ? TRUE : FALSE;\r
957} \r
958\r
959//////////////////////////////////////////////////////////////////////// \r
960\r
ac608d8a 961 void SetRenderColor(unsigned long DrawAttributes)\r
ce879073 962{\r
963 if(bDrawNonShaded) {g_m1=g_m2=g_m3=128;}\r
964 else\r
965 {\r
966 g_m1=DrawAttributes&0xff;\r
967 g_m2=(DrawAttributes>>8)&0xff;\r
968 g_m3=(DrawAttributes>>16)&0xff;\r
969 }\r
970}\r
971\r
972//////////////////////////////////////////////////////////////////////// \r
973 \r
974void SetRenderMode(unsigned long DrawAttributes,BOOL bSCol)\r
975{\r
976 if((bUseMultiPass) && (bDrawTextured) && !(bDrawNonShaded))\r
977 {bDrawMultiPass = TRUE; SetSemiTransMulti(0);}\r
978 else {bDrawMultiPass = FALSE;SetSemiTrans();}\r
979\r
980 if(bDrawTextured) // texture ? build it/get it from cache\r
981 {\r
982 GLuint currTex;\r
983 if(bUsingTWin) currTex=LoadTextureWnd(GlobalTexturePage,GlobalTextTP, ulClutID);\r
984 else if(bUsingMovie) currTex=LoadTextureMovie();\r
985 else currTex=SelectSubTextureS(GlobalTextTP,ulClutID);\r
986\r
987 if(gTexName!=currTex)\r
9f58cabb 988 {gTexName=currTex;glBindTexture(GL_TEXTURE_2D,currTex); glError();}\r
ce879073 989\r
990 if(!bTexEnabled) // -> turn texturing on\r
9f58cabb 991 {bTexEnabled=TRUE;glEnable(GL_TEXTURE_2D); glError();}\r
ce879073 992 }\r
993 else // no texture ?\r
994 if(bTexEnabled) \r
9f58cabb 995 {bTexEnabled=FALSE;glDisable(GL_TEXTURE_2D); glError();} // -> turn texturing off\r
ce879073 996\r
997 if(bSCol) // also set color ?\r
998 {\r
999 if((dwActFixes&4) && ((DrawAttributes&0x00ffffff)==0))\r
1000 DrawAttributes|=0x007f7f7f;\r
1001\r
1002 if(bDrawNonShaded) // -> non shaded?\r
1003 {\r
1004/* if(bGLBlend) vertex[0].c.lcol=0x7f7f7f; // --> solid color...\r
1005 else */vertex[0].c.lcol=0xffffff;\r
1006 }\r
1007 else // -> shaded?\r
1008 {\r
1009// if(!bUseMultiPass && !bGLBlend) // --> given color...\r
1010 vertex[0].c.lcol=DoubleBGR2RGB(DrawAttributes);\r
1011// else vertex[0].c.lcol=DrawAttributes;\r
1012 }\r
1013 vertex[0].c.col[3]=ubGloAlpha; // -> set color with\r
1014 SETCOL(vertex[0]); // texture alpha\r
1015 }\r
1016 \r
1017 if(bDrawSmoothShaded!=bOldSmoothShaded) // shading changed?\r
1018 {\r
1019 if(bDrawSmoothShaded) glShadeModel(GL_SMOOTH); // -> set actual shading\r
1020 else glShadeModel(GL_FLAT);\r
9f58cabb 1021 glError();\r
ce879073 1022 bOldSmoothShaded=bDrawSmoothShaded;\r
1023 }\r
1024}\r
1025\r
1026//////////////////////////////////////////////////////////////////////// \r
1027// Set Opaque multipass color\r
1028////////////////////////////////////////////////////////////////////////\r
1029\r
1030void SetOpaqueColor(unsigned long DrawAttributes)\r
1031{\r
1032 if(bDrawNonShaded) return; // no shading? bye\r
1033 \r
1034 DrawAttributes=DoubleBGR2RGB(DrawAttributes); // multipass is just half color, so double it on opaque pass\r
1035 vertex[0].c.lcol=DrawAttributes|0xff000000;\r
1036 SETCOL(vertex[0]); // set color\r
1037}\r
1038\r
1039//////////////////////////////////////////////////////////////////////// \r
1040// Fucking stupid screen coord checking\r
1041////////////////////////////////////////////////////////////////////////\r
1042\r
1043BOOL ClipVertexListScreen(void)\r
1044{\r
1045 if (lx0 >= PSXDisplay.DisplayEnd.x) goto NEXTSCRTEST;\r
1046 if (ly0 >= PSXDisplay.DisplayEnd.y) goto NEXTSCRTEST;\r
1047 if (lx2 < PSXDisplay.DisplayPosition.x) goto NEXTSCRTEST;\r
1048 if (ly2 < PSXDisplay.DisplayPosition.y) goto NEXTSCRTEST;\r
1049\r
1050 return TRUE;\r
1051\r
1052NEXTSCRTEST:\r
1053 if(PSXDisplay.InterlacedTest) return FALSE;\r
1054\r
1055 if (lx0 >= PreviousPSXDisplay.DisplayEnd.x) return FALSE;\r
1056 if (ly0 >= PreviousPSXDisplay.DisplayEnd.y) return FALSE;\r
1057 if (lx2 < PreviousPSXDisplay.DisplayPosition.x) return FALSE;\r
1058 if (ly2 < PreviousPSXDisplay.DisplayPosition.y) return FALSE;\r
1059\r
1060 return TRUE;\r
1061}\r
1062\r
1063////////////////////////////////////////////////////////////////////////\r
1064\r
1065BOOL bDrawOffscreenFront(void)\r
1066{\r
1067 if(sxmin < PSXDisplay.DisplayPosition.x) return FALSE; // must be complete in front\r
1068 if(symin < PSXDisplay.DisplayPosition.y) return FALSE;\r
1069 if(sxmax > PSXDisplay.DisplayEnd.x) return FALSE;\r
1070 if(symax > PSXDisplay.DisplayEnd.y) return FALSE;\r
1071 return TRUE;\r
1072}\r
1073\r
1074BOOL bOnePointInFront(void)\r
1075{\r
1076 if(sxmax< PSXDisplay.DisplayPosition.x)\r
1077 return FALSE;\r
1078\r
1079 if(symax< PSXDisplay.DisplayPosition.y)\r
1080 return FALSE;\r
1081\r
1082 if(sxmin>=PSXDisplay.DisplayEnd.x)\r
1083 return FALSE;\r
1084\r
1085 if(symin>=PSXDisplay.DisplayEnd.y)\r
1086 return FALSE;\r
1087\r
1088 return TRUE;\r
1089}\r
1090 \r
1091\r
1092BOOL bOnePointInBack(void)\r
1093{\r
1094 if(sxmax< PreviousPSXDisplay.DisplayPosition.x)\r
1095 return FALSE;\r
1096\r
1097 if(symax< PreviousPSXDisplay.DisplayPosition.y)\r
1098 return FALSE;\r
1099\r
1100 if(sxmin>=PreviousPSXDisplay.DisplayEnd.x)\r
1101 return FALSE;\r
1102\r
1103 if(symin>=PreviousPSXDisplay.DisplayEnd.y)\r
1104 return FALSE;\r
1105\r
1106 return TRUE;\r
1107}\r
1108 \r
1109BOOL bDrawOffscreen4(void)\r
1110{\r
1111 BOOL bFront;short sW,sH;\r
1112\r
1113 sxmax=max(lx0,max(lx1,max(lx2,lx3)));\r
1114 if(sxmax<drawX) return FALSE;\r
1115 sxmin=min(lx0,min(lx1,min(lx2,lx3)));\r
1116 if(sxmin>drawW) return FALSE;\r
1117 symax=max(ly0,max(ly1,max(ly2,ly3)));\r
1118 if(symax<drawY) return FALSE;\r
1119 symin=min(ly0,min(ly1,min(ly2,ly3)));\r
1120 if(symin>drawH) return FALSE;\r
1121\r
1122 if(PSXDisplay.Disabled) return TRUE; // disabled? ever\r
1123\r
1124 if(iOffscreenDrawing==1) return bFullVRam;\r
1125\r
1126 if(dwActFixes&1 && iOffscreenDrawing==4)\r
1127 {\r
1128 if(PreviousPSXDisplay.DisplayPosition.x==PSXDisplay.DisplayPosition.x &&\r
1129 PreviousPSXDisplay.DisplayPosition.y==PSXDisplay.DisplayPosition.y &&\r
1130 PreviousPSXDisplay.DisplayEnd.x==PSXDisplay.DisplayEnd.x &&\r
1131 PreviousPSXDisplay.DisplayEnd.y==PSXDisplay.DisplayEnd.y)\r
1132 {\r
1133 bRenderFrontBuffer=TRUE;\r
1134 return FALSE;\r
1135 }\r
1136 }\r
1137\r
1138 sW=drawW-1;sH=drawH-1;\r
1139 \r
1140 sxmin=min(sW,max(sxmin,drawX));\r
1141 sxmax=max(drawX,min(sxmax,sW));\r
1142 symin=min(sH,max(symin,drawY));\r
1143 symax=max(drawY,min(symax,sH));\r
1144\r
1145 if(bOnePointInBack()) return bFullVRam;\r
1146\r
1147 if(iOffscreenDrawing==2) \r
1148 bFront=bDrawOffscreenFront();\r
1149 else bFront=bOnePointInFront();\r
1150\r
1151 if(bFront)\r
1152 {\r
1153 if(PSXDisplay.InterlacedTest) return bFullVRam; // -> ok, no need for adjust\r
1154 \r
1155 vertex[0].x=lx0 - PSXDisplay.DisplayPosition.x+PreviousPSXDisplay.Range.x0;\r
1156 vertex[1].x=lx1 - PSXDisplay.DisplayPosition.x+PreviousPSXDisplay.Range.x0;\r
1157 vertex[2].x=lx2 - PSXDisplay.DisplayPosition.x+PreviousPSXDisplay.Range.x0;\r
1158 vertex[3].x=lx3 - PSXDisplay.DisplayPosition.x+PreviousPSXDisplay.Range.x0;\r
1159 vertex[0].y=ly0 - PSXDisplay.DisplayPosition.y+PreviousPSXDisplay.Range.y0;\r
1160 vertex[1].y=ly1 - PSXDisplay.DisplayPosition.y+PreviousPSXDisplay.Range.y0;\r
1161 vertex[2].y=ly2 - PSXDisplay.DisplayPosition.y+PreviousPSXDisplay.Range.y0;\r
1162 vertex[3].y=ly3 - PSXDisplay.DisplayPosition.y+PreviousPSXDisplay.Range.y0;\r
1163\r
1164 if(iOffscreenDrawing==4 && !(dwActFixes&1)) // -> frontbuffer wanted\r
1165 {\r
1166 bRenderFrontBuffer=TRUE;\r
1167 //return TRUE;\r
1168 }\r
1169 return bFullVRam; // -> but no od\r
1170 }\r
1171\r
1172 return TRUE;\r
1173}\r
1174\r
1175////////////////////////////////////////////////////////////////////////\r
1176 \r
1177BOOL bDrawOffscreen3(void)\r
1178{\r
1179 BOOL bFront;short sW,sH;\r
1180\r
1181 sxmax=max(lx0,max(lx1,lx2));\r
1182 if(sxmax<drawX) return FALSE;\r
1183 sxmin=min(lx0,min(lx1,lx2));\r
1184 if(sxmin>drawW) return FALSE;\r
1185 symax=max(ly0,max(ly1,ly2));\r
1186 if(symax<drawY) return FALSE;\r
1187 symin=min(ly0,min(ly1,ly2));\r
1188 if(symin>drawH) return FALSE;\r
1189\r
1190 if(PSXDisplay.Disabled) return TRUE; // disabled? ever\r
1191\r
1192 if(iOffscreenDrawing==1) return bFullVRam;\r
1193\r
1194 sW=drawW-1;sH=drawH-1;\r
1195 sxmin=min(sW,max(sxmin,drawX));\r
1196 sxmax=max(drawX,min(sxmax,sW));\r
1197 symin=min(sH,max(symin,drawY));\r
1198 symax=max(drawY,min(symax,sH));\r
1199\r
1200 if(bOnePointInBack()) return bFullVRam;\r
1201\r
1202 if(iOffscreenDrawing==2) \r
1203 bFront=bDrawOffscreenFront();\r
1204 else bFront=bOnePointInFront();\r
1205\r
1206 if(bFront)\r
1207 {\r
1208 if(PSXDisplay.InterlacedTest) return bFullVRam; // -> ok, no need for adjust\r
1209\r
1210 vertex[0].x=lx0 - PSXDisplay.DisplayPosition.x+PreviousPSXDisplay.Range.x0;\r
1211 vertex[1].x=lx1 - PSXDisplay.DisplayPosition.x+PreviousPSXDisplay.Range.x0;\r
1212 vertex[2].x=lx2 - PSXDisplay.DisplayPosition.x+PreviousPSXDisplay.Range.x0;\r
1213 vertex[0].y=ly0 - PSXDisplay.DisplayPosition.y+PreviousPSXDisplay.Range.y0;\r
1214 vertex[1].y=ly1 - PSXDisplay.DisplayPosition.y+PreviousPSXDisplay.Range.y0;\r
1215 vertex[2].y=ly2 - PSXDisplay.DisplayPosition.y+PreviousPSXDisplay.Range.y0;\r
1216\r
1217 if(iOffscreenDrawing==4) // -> frontbuffer wanted\r
1218 {\r
1219 bRenderFrontBuffer=TRUE;\r
1220 // return TRUE;\r
1221 }\r
1222\r
1223 return bFullVRam; // -> but no od\r
1224 }\r
1225\r
1226 return TRUE;\r
1227}\r
1228\r
1229////////////////////////////////////////////////////////////////////////\r
1230\r
1231BOOL FastCheckAgainstScreen(short imageX0,short imageY0,short imageX1,short imageY1)\r
1232{\r
1233 PSXRect_t xUploadArea;\r
1234\r
1235 imageX1 += imageX0;\r
1236 imageY1 += imageY0;\r
1237\r
1238 if (imageX0 < PreviousPSXDisplay.DisplayPosition.x)\r
1239 xUploadArea.x0 = PreviousPSXDisplay.DisplayPosition.x;\r
1240 else\r
1241 if (imageX0 > PreviousPSXDisplay.DisplayEnd.x)\r
1242 xUploadArea.x0 = PreviousPSXDisplay.DisplayEnd.x;\r
1243 else\r
1244 xUploadArea.x0 = imageX0;\r
1245\r
1246 if(imageX1 < PreviousPSXDisplay.DisplayPosition.x)\r
1247 xUploadArea.x1 = PreviousPSXDisplay.DisplayPosition.x;\r
1248 else\r
1249 if (imageX1 > PreviousPSXDisplay.DisplayEnd.x)\r
1250 xUploadArea.x1 = PreviousPSXDisplay.DisplayEnd.x;\r
1251 else\r
1252 xUploadArea.x1 = imageX1;\r
1253\r
1254 if (imageY0 < PreviousPSXDisplay.DisplayPosition.y)\r
1255 xUploadArea.y0 = PreviousPSXDisplay.DisplayPosition.y;\r
1256 else\r
1257 if (imageY0 > PreviousPSXDisplay.DisplayEnd.y)\r
1258 xUploadArea.y0 = PreviousPSXDisplay.DisplayEnd.y;\r
1259 else\r
1260 xUploadArea.y0 = imageY0;\r
1261\r
1262 if (imageY1 < PreviousPSXDisplay.DisplayPosition.y)\r
1263 xUploadArea.y1 = PreviousPSXDisplay.DisplayPosition.y;\r
1264 else\r
1265 if (imageY1 > PreviousPSXDisplay.DisplayEnd.y)\r
1266 xUploadArea.y1 = PreviousPSXDisplay.DisplayEnd.y;\r
1267 else\r
1268 xUploadArea.y1 = imageY1;\r
1269\r
1270 if ((xUploadArea.x0 != xUploadArea.x1) && (xUploadArea.y0 != xUploadArea.y1))\r
1271 return TRUE;\r
1272 else return FALSE;\r
1273}\r
1274\r
1275BOOL CheckAgainstScreen(short imageX0,short imageY0,short imageX1,short imageY1)\r
1276{\r
1277 imageX1 += imageX0;\r
1278 imageY1 += imageY0;\r
1279\r
1280 if (imageX0 < PreviousPSXDisplay.DisplayPosition.x)\r
1281 xrUploadArea.x0 = PreviousPSXDisplay.DisplayPosition.x;\r
1282 else\r
1283 if (imageX0 > PreviousPSXDisplay.DisplayEnd.x)\r
1284 xrUploadArea.x0 = PreviousPSXDisplay.DisplayEnd.x;\r
1285 else\r
1286 xrUploadArea.x0 = imageX0;\r
1287\r
1288 if(imageX1 < PreviousPSXDisplay.DisplayPosition.x)\r
1289 xrUploadArea.x1 = PreviousPSXDisplay.DisplayPosition.x;\r
1290 else\r
1291 if (imageX1 > PreviousPSXDisplay.DisplayEnd.x)\r
1292 xrUploadArea.x1 = PreviousPSXDisplay.DisplayEnd.x;\r
1293 else\r
1294 xrUploadArea.x1 = imageX1;\r
1295\r
1296 if (imageY0 < PreviousPSXDisplay.DisplayPosition.y)\r
1297 xrUploadArea.y0 = PreviousPSXDisplay.DisplayPosition.y;\r
1298 else\r
1299 if (imageY0 > PreviousPSXDisplay.DisplayEnd.y)\r
1300 xrUploadArea.y0 = PreviousPSXDisplay.DisplayEnd.y;\r
1301 else\r
1302 xrUploadArea.y0 = imageY0;\r
1303\r
1304 if (imageY1 < PreviousPSXDisplay.DisplayPosition.y)\r
1305 xrUploadArea.y1 = PreviousPSXDisplay.DisplayPosition.y;\r
1306 else\r
1307 if (imageY1 > PreviousPSXDisplay.DisplayEnd.y)\r
1308 xrUploadArea.y1 = PreviousPSXDisplay.DisplayEnd.y;\r
1309 else\r
1310 xrUploadArea.y1 = imageY1;\r
1311\r
1312 if ((xrUploadArea.x0 != xrUploadArea.x1) && (xrUploadArea.y0 != xrUploadArea.y1))\r
1313 return TRUE;\r
1314 else return FALSE;\r
1315}\r
1316\r
1317BOOL FastCheckAgainstFrontScreen(short imageX0,short imageY0,short imageX1,short imageY1)\r
1318{\r
1319 PSXRect_t xUploadArea;\r
1320\r
1321 imageX1 += imageX0;\r
1322 imageY1 += imageY0;\r
1323\r
1324 if (imageX0 < PSXDisplay.DisplayPosition.x)\r
1325 xUploadArea.x0 = PSXDisplay.DisplayPosition.x;\r
1326 else\r
1327 if (imageX0 > PSXDisplay.DisplayEnd.x)\r
1328 xUploadArea.x0 = PSXDisplay.DisplayEnd.x;\r
1329 else\r
1330 xUploadArea.x0 = imageX0;\r
1331\r
1332 if(imageX1 < PSXDisplay.DisplayPosition.x)\r
1333 xUploadArea.x1 = PSXDisplay.DisplayPosition.x;\r
1334 else\r
1335 if (imageX1 > PSXDisplay.DisplayEnd.x)\r
1336 xUploadArea.x1 = PSXDisplay.DisplayEnd.x;\r
1337 else\r
1338 xUploadArea.x1 = imageX1;\r
1339\r
1340 if (imageY0 < PSXDisplay.DisplayPosition.y)\r
1341 xUploadArea.y0 = PSXDisplay.DisplayPosition.y;\r
1342 else\r
1343 if (imageY0 > PSXDisplay.DisplayEnd.y)\r
1344 xUploadArea.y0 = PSXDisplay.DisplayEnd.y;\r
1345 else\r
1346 xUploadArea.y0 = imageY0;\r
1347\r
1348 if (imageY1 < PSXDisplay.DisplayPosition.y)\r
1349 xUploadArea.y1 = PSXDisplay.DisplayPosition.y;\r
1350 else\r
1351 if (imageY1 > PSXDisplay.DisplayEnd.y)\r
1352 xUploadArea.y1 = PSXDisplay.DisplayEnd.y;\r
1353 else\r
1354 xUploadArea.y1 = imageY1;\r
1355\r
1356 if ((xUploadArea.x0 != xUploadArea.x1) && (xUploadArea.y0 != xUploadArea.y1))\r
1357 return TRUE; \r
1358 else return FALSE;\r
1359}\r
1360\r
1361BOOL CheckAgainstFrontScreen(short imageX0,short imageY0,short imageX1,short imageY1)\r
1362{\r
1363 imageX1 += imageX0;\r
1364 imageY1 += imageY0;\r
1365\r
1366 if (imageX0 < PSXDisplay.DisplayPosition.x)\r
1367 xrUploadArea.x0 = PSXDisplay.DisplayPosition.x;\r
1368 else\r
1369 if (imageX0 > PSXDisplay.DisplayEnd.x)\r
1370 xrUploadArea.x0 = PSXDisplay.DisplayEnd.x;\r
1371 else\r
1372 xrUploadArea.x0 = imageX0;\r
1373\r
1374 if(imageX1 < PSXDisplay.DisplayPosition.x)\r
1375 xrUploadArea.x1 = PSXDisplay.DisplayPosition.x;\r
1376 else\r
1377 if (imageX1 > PSXDisplay.DisplayEnd.x)\r
1378 xrUploadArea.x1 = PSXDisplay.DisplayEnd.x;\r
1379 else\r
1380 xrUploadArea.x1 = imageX1;\r
1381\r
1382 if (imageY0 < PSXDisplay.DisplayPosition.y)\r
1383 xrUploadArea.y0 = PSXDisplay.DisplayPosition.y;\r
1384 else\r
1385 if (imageY0 > PSXDisplay.DisplayEnd.y)\r
1386 xrUploadArea.y0 = PSXDisplay.DisplayEnd.y;\r
1387 else\r
1388 xrUploadArea.y0 = imageY0;\r
1389\r
1390 if (imageY1 < PSXDisplay.DisplayPosition.y)\r
1391 xrUploadArea.y1 = PSXDisplay.DisplayPosition.y;\r
1392 else\r
1393 if (imageY1 > PSXDisplay.DisplayEnd.y)\r
1394 xrUploadArea.y1 = PSXDisplay.DisplayEnd.y;\r
1395 else\r
1396 xrUploadArea.y1 = imageY1;\r
1397\r
1398 if ((xrUploadArea.x0 != xrUploadArea.x1) && (xrUploadArea.y0 != xrUploadArea.y1))\r
1399 return TRUE; \r
1400 else return FALSE;\r
1401}\r
1402\r
1403////////////////////////////////////////////////////////////////////////\r
1404\r
1405void PrepareFullScreenUpload (long Position)\r
1406{\r
1407 if (Position==-1) // rgb24\r
1408 {\r
1409 if(PSXDisplay.Interlaced)\r
1410 {\r
1411 xrUploadArea.x0 = PSXDisplay.DisplayPosition.x;\r
1412 xrUploadArea.x1 = PSXDisplay.DisplayEnd.x;\r
1413 xrUploadArea.y0 = PSXDisplay.DisplayPosition.y;\r
1414 xrUploadArea.y1 = PSXDisplay.DisplayEnd.y;\r
1415 }\r
1416 else\r
1417 {\r
1418 xrUploadArea.x0 = PreviousPSXDisplay.DisplayPosition.x;\r
1419 xrUploadArea.x1 = PreviousPSXDisplay.DisplayEnd.x;\r
1420 xrUploadArea.y0 = PreviousPSXDisplay.DisplayPosition.y;\r
1421 xrUploadArea.y1 = PreviousPSXDisplay.DisplayEnd.y;\r
1422 }\r
1423\r
1424 if(bNeedRGB24Update)\r
1425 {\r
1426 if(lClearOnSwap) \r
1427 {\r
1428// lClearOnSwap=0;\r
1429 }\r
1430 else \r
1431 if(PSXDisplay.Interlaced && PreviousPSXDisplay.RGB24<2) // in interlaced mode we upload at least two full frames (GT1 menu)\r
1432 {\r
1433 PreviousPSXDisplay.RGB24++;\r
1434 }\r
1435 else\r
1436 {\r
1437 xrUploadArea.y1 = min(xrUploadArea.y0+xrUploadAreaRGB24.y1,xrUploadArea.y1);\r
1438 xrUploadArea.y0+=xrUploadAreaRGB24.y0;\r
1439 }\r
1440 }\r
1441 }\r
1442 else\r
1443 if (Position)\r
1444 {\r
1445 xrUploadArea.x0 = PSXDisplay.DisplayPosition.x;\r
1446 xrUploadArea.x1 = PSXDisplay.DisplayEnd.x;\r
1447 xrUploadArea.y0 = PSXDisplay.DisplayPosition.y;\r
1448 xrUploadArea.y1 = PSXDisplay.DisplayEnd.y;\r
1449 }\r
1450 else\r
1451 {\r
1452 xrUploadArea.x0 = PreviousPSXDisplay.DisplayPosition.x;\r
1453 xrUploadArea.x1 = PreviousPSXDisplay.DisplayEnd.x;\r
1454 xrUploadArea.y0 = PreviousPSXDisplay.DisplayPosition.y;\r
1455 xrUploadArea.y1 = PreviousPSXDisplay.DisplayEnd.y;\r
1456 }\r
1457\r
1458 if (xrUploadArea.x0 < 0) xrUploadArea.x0 = 0;\r
1459 else\r
1460 if (xrUploadArea.x0 > 1023) xrUploadArea.x0 = 1023;\r
1461\r
1462 if (xrUploadArea.x1 < 0) xrUploadArea.x1 = 0;\r
1463 else\r
1464 if (xrUploadArea.x1 > 1024) xrUploadArea.x1 = 1024;\r
1465\r
1466 if (xrUploadArea.y0 < 0) xrUploadArea.y0 = 0;\r
1467 else\r
1468 if (xrUploadArea.y0 > iGPUHeightMask) xrUploadArea.y0 = iGPUHeightMask;\r
1469\r
1470 if (xrUploadArea.y1 < 0) xrUploadArea.y1 = 0;\r
1471 else\r
1472 if (xrUploadArea.y1 > iGPUHeight) xrUploadArea.y1 = iGPUHeight;\r
1473\r
1474 if (PSXDisplay.RGB24)\r
1475 {\r
1476 InvalidateTextureArea(xrUploadArea.x0,xrUploadArea.y0,xrUploadArea.x1-xrUploadArea.x0,xrUploadArea.y1-xrUploadArea.y0);\r
1477 }\r
1478}\r
1479\r
1480////////////////////////////////////////////////////////////////////////\r
1481// Upload screen (MDEC and such)\r
1482////////////////////////////////////////////////////////////////////////\r
1483////////////////////////////////////////////////////////////////////////\r
1484\r
677ea103 1485unsigned char * LoadDirectMovieFast(void);\r
ce879073 1486\r
1487void UploadScreenEx(long Position)\r
1488{\r
1489 short ya,yb,xa,xb,x, y, YStep, XStep, U, UStep,ux[4],vy[4];\r
1490\r
1491 if(!PSXDisplay.DisplayMode.x) return;\r
1492 if(!PSXDisplay.DisplayMode.y) return;\r
1493\r
9f58cabb 1494 glDisable(GL_SCISSOR_TEST); glError();\r
1495 glShadeModel(GL_FLAT); glError();\r
ce879073 1496 bOldSmoothShaded=FALSE;\r
9f58cabb 1497 glDisable(GL_BLEND); glError();\r
ce879073 1498 bBlendEnable=FALSE;\r
9f58cabb 1499 glDisable(GL_TEXTURE_2D); glError();\r
ce879073 1500 bTexEnabled=FALSE;\r
9f58cabb 1501 glDisable(GL_ALPHA_TEST); glError();\r
ce879073 1502\r
1503 //glPixelZoom(((float)rRatioRect.right)/((float)PSXDisplay.DisplayMode.x),\r
1504 // -1.0f*(((float)rRatioRect.bottom)/((float)PSXDisplay.DisplayMode.y)));\r
1505 \r
1506 //----------------------------------------------------//\r
1507\r
1508 YStep = 256; // max texture size\r
1509 XStep = 256;\r
1510 UStep = (PSXDisplay.RGB24 ? 128 : 0);\r
1511 ya = xrUploadArea.y0;\r
1512 yb = xrUploadArea.y1;\r
1513 xa = xrUploadArea.x0;\r
1514 xb = xrUploadArea.x1;\r
1515 \r
1516 for(y=ya;y<=yb;y+=YStep) // loop y\r
1517 {\r
1518 U = 0;\r
1519 for(x=xa;x<=xb;x+=XStep) // loop x\r
1520 {\r
1521 ly0 = ly1 = y; // -> get y coords\r
1522 ly2 = y + YStep;\r
1523 if (ly2 > yb) ly2 = yb;\r
1524 ly3 = ly2;\r
1525\r
1526 lx0 = lx3 = x; // -> get x coords\r
1527 lx1 = x + XStep;\r
1528 if (lx1 > xb) lx1 = xb;\r
1529\r
1530 lx2 = lx1;\r
1531\r
1532 ux[0]=ux[3]=(xa - x); // -> set tex x coords\r
1533 if (ux[0] < 0) ux[0]=ux[3]=0;\r
1534 ux[2]=ux[1]=(xb - x);\r
1535 if (ux[2] > 256) ux[2]=ux[1]=256;\r
1536\r
1537 vy[0]=vy[1]=(ya - y); // -> set tex y coords\r
1538 if (vy[0] < 0) vy[0]=vy[1]=0;\r
1539 vy[2]=vy[3]=(yb - y);\r
1540 if (vy[2] > 256) vy[2]=vy[3]=256;\r
1541\r
1542 if ((ux[0] >= ux[2]) || // -> cheaters never win...\r
1543 (vy[0] >= vy[2])) continue; // (but winners always cheat...)\r
1544 \r
1545 xrMovieArea.x0=lx0+U; xrMovieArea.y0=ly0;\r
1546 xrMovieArea.x1=lx2+U; xrMovieArea.y1=ly2;\r
1547 \r
1548 offsetScreenUpload(Position);\r
1549\r
1550 //glRasterPos2f(vertex[0].x,vertex[0].y);\r
1551\r
1552 //glDrawPixels(xrMovieArea.x1-xrMovieArea.x0,\r
1553 // xrMovieArea.y1-xrMovieArea.y0,\r
1554 // GL_RGBA,GL_UNSIGNED_BYTE,\r
1555 LoadDirectMovieFast();//);\r
1556\r
1557 U+=UStep;\r
1558 }\r
1559 }\r
1560\r
1561 //----------------------------------------------------//\r
1562\r
1563// glPixelZoom(1.0F,1.0F);\r
1564\r
9f58cabb 1565 glEnable(GL_ALPHA_TEST); glError();\r
1566 glEnable(GL_SCISSOR_TEST); glError();\r
ce879073 1567}\r
1568\r
1569////////////////////////////////////////////////////////////////////////\r
1570\r
1571void UploadScreen(long Position)\r
1572{\r
1573 short x, y, YStep, XStep, U, s, UStep,ux[4],vy[4];\r
1574 short xa,xb,ya,yb;\r
1575\r
1576 if(xrUploadArea.x0>1023) xrUploadArea.x0=1023;\r
1577 if(xrUploadArea.x1>1024) xrUploadArea.x1=1024;\r
1578 if(xrUploadArea.y0>iGPUHeightMask) xrUploadArea.y0=iGPUHeightMask;\r
1579 if(xrUploadArea.y1>iGPUHeight) xrUploadArea.y1=iGPUHeight;\r
1580\r
1581 if(xrUploadArea.x0==xrUploadArea.x1) return;\r
1582 if(xrUploadArea.y0==xrUploadArea.y1) return;\r
1583\r
1584 if(PSXDisplay.Disabled && iOffscreenDrawing<4) return;\r
1585\r
1586 iDrawnSomething = 2;\r
1587 iLastRGB24=PSXDisplay.RGB24+1;\r
1588\r
1589 if(bSkipNextFrame) return;\r
1590\r
1591 if(dwActFixes & 2) {UploadScreenEx(Position);return;}\r
1592\r
1593 bUsingMovie = TRUE;\r
1594 bDrawTextured = TRUE; // just doing textures\r
1595 bDrawSmoothShaded = FALSE;\r
1596\r
1597/* if(bGLBlend) vertex[0].c.lcol=0xff7f7f7f; // set solid col\r
1598 else */vertex[0].c.lcol=0xffffffff;\r
1599 SETCOL(vertex[0]); \r
1600\r
1601 SetOGLDisplaySettings(0);\r
1602\r
1603 YStep = 256; // max texture size\r
1604 XStep = 256;\r
1605\r
1606 UStep = (PSXDisplay.RGB24 ? 128 : 0);\r
1607 \r
1608 ya=xrUploadArea.y0;\r
1609 yb=xrUploadArea.y1;\r
1610 xa=xrUploadArea.x0;\r
1611 xb=xrUploadArea.x1;\r
1612\r
1613 for(y=ya;y<=yb;y+=YStep) // loop y\r
1614 {\r
1615 U = 0;\r
1616 for(x=xa;x<=xb;x+=XStep) // loop x\r
1617 {\r
1618 ly0 = ly1 = y; // -> get y coords\r
1619 ly2 = y + YStep;\r
1620 if (ly2 > yb) ly2 = yb;\r
1621 ly3 = ly2;\r
1622\r
1623 lx0 = lx3 = x; // -> get x coords\r
1624 lx1 = x + XStep;\r
1625 if (lx1 > xb) lx1 = xb;\r
1626\r
1627 lx2 = lx1;\r
1628\r
1629 ux[0]=ux[3]=(xa - x); // -> set tex x coords\r
1630 if (ux[0] < 0) ux[0]=ux[3]=0;\r
1631 ux[2]=ux[1]=(xb - x);\r
1632 if (ux[2] > 256) ux[2]=ux[1]=256;\r
1633\r
1634 vy[0]=vy[1]=(ya - y); // -> set tex y coords\r
1635 if (vy[0] < 0) vy[0]=vy[1]=0;\r
1636 vy[2]=vy[3]=(yb - y);\r
1637 if (vy[2] > 256) vy[2]=vy[3]=256;\r
1638\r
1639 if ((ux[0] >= ux[2]) || // -> cheaters never win...\r
1640 (vy[0] >= vy[2])) continue; // (but winners always cheat...)\r
1641 \r
1642 xrMovieArea.x0=lx0+U; xrMovieArea.y0=ly0;\r
1643 xrMovieArea.x1=lx2+U; xrMovieArea.y1=ly2;\r
1644\r
1645 s=ux[2] - ux[0]; if(s>255) s=255;\r
1646\r
1647 gl_ux[2] = gl_ux[1] = s;\r
1648 s=vy[2] - vy[0]; if(s>255) s=255;\r
1649 gl_vy[2] = gl_vy[3] = s;\r
1650 gl_ux[0] = gl_ux[3] = gl_vy[0] = gl_vy[1] = 0;\r
1651\r
1652 SetRenderState((unsigned long)0x01000000);\r
1653 SetRenderMode((unsigned long)0x01000000, FALSE); // upload texture data\r
1654 offsetScreenUpload(Position);\r
1655 assignTextureVRAMWrite();\r
1656\r
1657 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r
1658\r
1659 U+=UStep;\r
1660 }\r
1661 }\r
1662\r
1663 bUsingMovie=FALSE; // done...\r
1664 bDisplayNotSet = TRUE;\r
1665}\r
1666\r
1667////////////////////////////////////////////////////////////////////////\r
1668// Detect next screen\r
1669////////////////////////////////////////////////////////////////////////\r
1670\r
1671BOOL IsCompleteInsideNextScreen(short x, short y, short xoff, short yoff)\r
1672{ \r
1673 if (x > PSXDisplay.DisplayPosition.x+1) return FALSE;\r
1674 if ((x + xoff) < PSXDisplay.DisplayEnd.x-1) return FALSE;\r
1675 yoff+=y;\r
1676 if (y >= PSXDisplay.DisplayPosition.y &&\r
1677 y <= PSXDisplay.DisplayEnd.y )\r
1678 {\r
1679 if ((yoff) >= PSXDisplay.DisplayPosition.y &&\r
1680 (yoff) <= PSXDisplay.DisplayEnd.y ) return TRUE;\r
1681 } \r
1682 if (y > PSXDisplay.DisplayPosition.y+1) return FALSE;\r
1683 if (yoff < PSXDisplay.DisplayEnd.y-1) return FALSE;\r
1684 return TRUE;\r
1685}\r
1686\r
1687BOOL IsPrimCompleteInsideNextScreen(short x, short y, short xoff, short yoff)\r
1688{\r
1689 x+=PSXDisplay.DrawOffset.x;\r
1690 if (x > PSXDisplay.DisplayPosition.x+1) return FALSE;\r
1691 y+=PSXDisplay.DrawOffset.y;\r
1692 if (y > PSXDisplay.DisplayPosition.y+1) return FALSE;\r
1693 xoff+=PSXDisplay.DrawOffset.x;\r
1694 if (xoff < PSXDisplay.DisplayEnd.x-1) return FALSE;\r
1695 yoff+=PSXDisplay.DrawOffset.y;\r
1696 if (yoff < PSXDisplay.DisplayEnd.y-1) return FALSE;\r
1697 return TRUE;\r
1698}\r
1699\r
1700BOOL IsInsideNextScreen(short x, short y, short xoff, short yoff)\r
1701{ \r
1702 if (x > PSXDisplay.DisplayEnd.x) return FALSE;\r
1703 if (y > PSXDisplay.DisplayEnd.y) return FALSE;\r
1704 if ((x + xoff) < PSXDisplay.DisplayPosition.x) return FALSE;\r
1705 if ((y + yoff) < PSXDisplay.DisplayPosition.y) return FALSE;\r
1706 return TRUE;\r
1707}\r
1708\r
1709////////////////////////////////////////////////////////////////////////\r
1710// mask stuff...\r
1711////////////////////////////////////////////////////////////////////////\r
1712\r
1713//Mask1 Set mask bit while drawing. 1 = on\r
1714//Mask2 Do not draw to mask areas. 1= on\r
1715\r
677ea103 1716void cmdSTP(unsigned char * baseAddr)\r
ce879073 1717{\r
1718 unsigned long gdata = ((unsigned long*)baseAddr)[0];\r
1719\r
1720 STATUSREG&=~0x1800; // clear the necessary bits\r
1721 STATUSREG|=((gdata & 0x03) << 11); // set the current bits\r
1722\r
1723 if(!iUseMask) return;\r
1724\r
1725 if(gdata&1) {sSetMask=0x8000;lSetMask=0x80008000;iSetMask=1;}\r
1726 else {sSetMask=0; lSetMask=0; iSetMask=0;}\r
1727\r
1728 if(gdata&2) \r
1729 {\r
1730 if(!(gdata&1)) iSetMask=2;\r
1731 bCheckMask=TRUE;\r
1732 if(iDepthFunc==0) return;\r
1733 iDepthFunc=0;\r
9f58cabb 1734 glDepthFunc(GL_LESS); glError();\r
ce879073 1735 }\r
1736 else\r
1737 {\r
1738 bCheckMask=FALSE;\r
1739 if(iDepthFunc==1) return;\r
9f58cabb 1740 glDepthFunc(GL_ALWAYS); glError();\r
ce879073 1741 iDepthFunc=1;\r
1742 }\r
1743}\r
1744\r
1745////////////////////////////////////////////////////////////////////////\r
1746// cmd: Set texture page infos\r
1747////////////////////////////////////////////////////////////////////////\r
1748\r
677ea103 1749void cmdTexturePage(unsigned char * baseAddr)\r
ce879073 1750{\r
1751 unsigned long gdata = ((unsigned long*)baseAddr)[0];\r
1752 UpdateGlobalTP((unsigned short)gdata);\r
1753 GlobalTextREST = (gdata&0x00ffffff)>>9;\r
1754}\r
1755\r
1756////////////////////////////////////////////////////////////////////////\r
1757// cmd: turn on/off texture window\r
1758////////////////////////////////////////////////////////////////////////\r
1759\r
677ea103 1760void cmdTextureWindow(unsigned char *baseAddr)\r
ce879073 1761{\r
1762 unsigned long gdata = ((unsigned long*)baseAddr)[0];\r
1763\r
1764 unsigned long YAlign,XAlign;\r
1765\r
1766 ulGPUInfoVals[INFO_TW]=gdata&0xFFFFF;\r
1767\r
1768 if(gdata & 0x020)\r
1769 TWin.Position.y1 = 8; // xxxx1\r
1770 else if (gdata & 0x040)\r
1771 TWin.Position.y1 = 16; // xxx10\r
1772 else if (gdata & 0x080)\r
1773 TWin.Position.y1 = 32; // xx100\r
1774 else if (gdata & 0x100)\r
1775 TWin.Position.y1 = 64; // x1000\r
1776 else if (gdata & 0x200)\r
1777 TWin.Position.y1 = 128; // 10000\r
1778 else\r
1779 TWin.Position.y1 = 256; // 00000\r
1780\r
1781 // Texture window size is determined by the least bit set of the relevant 5 bits\r
1782\r
1783 if (gdata & 0x001)\r
1784 TWin.Position.x1 = 8; // xxxx1\r
1785 else if (gdata & 0x002)\r
1786 TWin.Position.x1 = 16; // xxx10\r
1787 else if (gdata & 0x004)\r
1788 TWin.Position.x1 = 32; // xx100\r
1789 else if (gdata & 0x008)\r
1790 TWin.Position.x1 = 64; // x1000\r
1791 else if (gdata & 0x010)\r
1792 TWin.Position.x1 = 128; // 10000\r
1793 else\r
1794 TWin.Position.x1 = 256; // 00000\r
1795\r
1796 // Re-calculate the bit field, because we can't trust what is passed in the data\r
1797\r
1798 YAlign = (unsigned long)(32 - (TWin.Position.y1 >> 3));\r
1799 XAlign = (unsigned long)(32 - (TWin.Position.x1 >> 3));\r
1800\r
1801 // Absolute position of the start of the texture window\r
1802\r
1803 TWin.Position.y0 = (short)(((gdata >> 15) & YAlign) << 3);\r
1804 TWin.Position.x0 = (short)(((gdata >> 10) & XAlign) << 3);\r
1805\r
1806 if((TWin.Position.x0 == 0 && // tw turned off\r
1807 TWin.Position.y0 == 0 &&\r
1808 TWin.Position.x1 == 0 &&\r
1809 TWin.Position.y1 == 0) ||\r
1810 (TWin.Position.x1 == 256 &&\r
1811 TWin.Position.y1 == 256))\r
1812 {\r
1813 bUsingTWin = FALSE; // -> just do it\r
1814\r
1815#ifdef OWNSCALE\r
1816 TWin.UScaleFactor = 1.0f;\r
1817 TWin.VScaleFactor = 1.0f;\r
1818#else\r
1819 TWin.UScaleFactor = \r
1820 TWin.VScaleFactor = 1.0f/256.0f;\r
1821#endif\r
1822 }\r
1823 else // tw turned on\r
1824 {\r
1825 bUsingTWin = TRUE;\r
1826\r
1827 TWin.OPosition.y1 = TWin.Position.y1; // -> get psx sizes\r
1828 TWin.OPosition.x1 = TWin.Position.x1; \r
1829\r
1830 if(TWin.Position.x1<=2) TWin.Position.x1=2; // -> set OGL sizes\r
1831 else\r
1832 if(TWin.Position.x1<=4) TWin.Position.x1=4;\r
1833 else\r
1834 if(TWin.Position.x1<=8) TWin.Position.x1=8;\r
1835 else\r
1836 if(TWin.Position.x1<=16) TWin.Position.x1=16;\r
1837 else\r
1838 if(TWin.Position.x1<=32) TWin.Position.x1=32;\r
1839 else\r
1840 if(TWin.Position.x1<=64) TWin.Position.x1=64;\r
1841 else\r
1842 if(TWin.Position.x1<=128) TWin.Position.x1=128;\r
1843 else\r
1844 if(TWin.Position.x1<=256) TWin.Position.x1=256;\r
1845 \r
1846 if(TWin.Position.y1<=2) TWin.Position.y1=2;\r
1847 else\r
1848 if(TWin.Position.y1<=4) TWin.Position.y1=4;\r
1849 else\r
1850 if(TWin.Position.y1<=8) TWin.Position.y1=8;\r
1851 else\r
1852 if(TWin.Position.y1<=16) TWin.Position.y1=16;\r
1853 else\r
1854 if(TWin.Position.y1<=32) TWin.Position.y1=32;\r
1855 else\r
1856 if(TWin.Position.y1<=64) TWin.Position.y1=64;\r
1857 else\r
1858 if(TWin.Position.y1<=128) TWin.Position.y1=128;\r
1859 else\r
1860 if(TWin.Position.y1<=256) TWin.Position.y1=256;\r
1861\r
1862#ifdef OWNSCALE\r
1863 TWin.UScaleFactor = (float)TWin.Position.x1;\r
1864 TWin.VScaleFactor = (float)TWin.Position.y1;\r
1865#else\r
1866 TWin.UScaleFactor = ((float)TWin.Position.x1)/256.0f; // -> set scale factor\r
1867 TWin.VScaleFactor = ((float)TWin.Position.y1)/256.0f;\r
1868#endif\r
1869 }\r
1870}\r
1871\r
1872////////////////////////////////////////////////////////////////////////\r
1873// mmm, Lewpy uses that in TileS ... I don't ;)\r
1874////////////////////////////////////////////////////////////////////////\r
1875\r
1876/*\r
1877void ClampToPSXDrawAreaOffset(short *x0, short *y0, short *x1, short *y1)\r
1878{\r
1879 if (*x0 < PSXDisplay.DrawArea.x0)\r
1880 {\r
1881 *x1 -= (PSXDisplay.DrawArea.x0 - *x0);\r
1882 *x0 = PSXDisplay.DrawArea.x0;\r
1883 }\r
1884 else\r
1885 if (*x0 > PSXDisplay.DrawArea.x1)\r
1886 {\r
1887 *x0 = PSXDisplay.DrawArea.x1;\r
1888 *x1 = 0;\r
1889 }\r
1890\r
1891 if (*y0 < PSXDisplay.DrawArea.y0)\r
1892 {\r
1893 *y1 -= (PSXDisplay.DrawArea.y0 - *y0);\r
1894 *y0 = PSXDisplay.DrawArea.y0;\r
1895 }\r
1896 else\r
1897 if (*y0 > PSXDisplay.DrawArea.y1)\r
1898 {\r
1899 *y0 = PSXDisplay.DrawArea.y1;\r
1900 *y1 = 0;\r
1901 }\r
1902\r
1903 if (*x1 < 0) *x1 = 0;\r
1904\r
1905 if ((*x1 + *x0) > PSXDisplay.DrawArea.x1)\r
1906 *x1 = (PSXDisplay.DrawArea.x1 - *x0 + 1);\r
1907\r
1908 if (*y1 < 0) *y1 = 0;\r
1909\r
1910 if ((*y1 + *y0) > PSXDisplay.DrawArea.y1)\r
1911 *y1 = (PSXDisplay.DrawArea.y1 - *y0 + 1);\r
1912}\r
1913*/\r
1914\r
1915////////////////////////////////////////////////////////////////////////\r
1916// Check draw area dimensions\r
1917////////////////////////////////////////////////////////////////////////\r
1918\r
1919void ClampToPSXScreen(short *x0, short *y0, short *x1, short *y1)\r
1920{\r
1921 if (*x0 < 0) *x0 = 0;\r
1922 else\r
1923 if (*x0 > 1023) *x0 = 1023;\r
1924 \r
1925 if (*x1 < 0) *x1 = 0;\r
1926 else\r
1927 if (*x1 > 1023) *x1 = 1023;\r
1928\r
1929 if (*y0 < 0) *y0 = 0;\r
1930 else\r
1931 if (*y0 > iGPUHeightMask) *y0 = iGPUHeightMask;\r
1932 \r
1933 if (*y1 < 0) *y1 = 0;\r
1934 else\r
1935 if (*y1 > iGPUHeightMask) *y1 = iGPUHeightMask;\r
1936}\r
1937\r
1938////////////////////////////////////////////////////////////////////////\r
1939// Used in Load Image and Blk Fill\r
1940////////////////////////////////////////////////////////////////////////\r
1941\r
1942void ClampToPSXScreenOffset(short *x0, short *y0, short *x1, short *y1)\r
1943{\r
1944 if (*x0 < 0)\r
1945 { *x1 += *x0; *x0 = 0; }\r
1946 else\r
1947 if (*x0 > 1023)\r
1948 { *x0 = 1023; *x1 = 0; }\r
1949\r
1950 if (*y0 < 0)\r
1951 { *y1 += *y0; *y0 = 0; }\r
1952 else\r
1953 if (*y0 > iGPUHeightMask)\r
1954 { *y0 = iGPUHeightMask; *y1 = 0; }\r
1955\r
1956 if (*x1 < 0) *x1 = 0;\r
1957\r
1958 if ((*x1 + *x0) > 1024) *x1 = (1024 - *x0);\r
1959\r
1960 if (*y1 < 0) *y1 = 0;\r
1961\r
1962 if ((*y1 + *y0) > iGPUHeight) *y1 = (iGPUHeight - *y0);\r
1963}\r
1964\r
1965////////////////////////////////////////////////////////////////////////\r
1966// cmd: start of drawing area... primitives will be clipped inside\r
1967////////////////////////////////////////////////////////////////////////\r
1968\r
677ea103 1969void cmdDrawAreaStart(unsigned char * baseAddr)\r
ce879073 1970{\r
1971 unsigned long gdata = ((unsigned long*)baseAddr)[0];\r
1972\r
1973 drawX = gdata & 0x3ff; // for soft drawing\r
1974 if(drawX>=1024) drawX=1023;\r
1975\r
1976 if(dwGPUVersion==2)\r
1977 {\r
1978 ulGPUInfoVals[INFO_DRAWSTART]=gdata&0x3FFFFF;\r
1979 drawY = (gdata>>12)&0x3ff;\r
1980 }\r
1981 else\r
1982 {\r
1983 ulGPUInfoVals[INFO_DRAWSTART]=gdata&0xFFFFF;\r
1984 drawY = (gdata>>10)&0x3ff;\r
1985 }\r
1986\r
1987 if(drawY>=iGPUHeight) drawY=iGPUHeightMask;\r
1988\r
1989 PreviousPSXDisplay.DrawArea.y0=PSXDisplay.DrawArea.y0;\r
1990 PreviousPSXDisplay.DrawArea.x0=PSXDisplay.DrawArea.x0;\r
1991\r
1992 PSXDisplay.DrawArea.y0 = (short)drawY; // for OGL drawing\r
1993 PSXDisplay.DrawArea.x0 = (short)drawX;\r
1994}\r
1995\r
1996////////////////////////////////////////////////////////////////////////\r
1997// cmd: end of drawing area... primitives will be clipped inside\r
1998////////////////////////////////////////////////////////////////////////\r
1999\r
677ea103 2000void cmdDrawAreaEnd(unsigned char * baseAddr)\r
ce879073 2001{\r
2002 unsigned long gdata = ((unsigned long*)baseAddr)[0];\r
2003\r
2004 drawW = gdata & 0x3ff; // for soft drawing\r
2005 if(drawW>=1024) drawW=1023;\r
2006\r
2007 if(dwGPUVersion==2)\r
2008 {\r
2009 ulGPUInfoVals[INFO_DRAWEND]=gdata&0x3FFFFF;\r
2010 drawH = (gdata>>12)&0x3ff;\r
2011 }\r
2012 else\r
2013 {\r
2014 ulGPUInfoVals[INFO_DRAWEND]=gdata&0xFFFFF;\r
2015 drawH = (gdata>>10)&0x3ff;\r
2016 }\r
2017 \r
2018 if(drawH>=iGPUHeight) drawH=iGPUHeightMask;\r
2019\r
2020 PSXDisplay.DrawArea.y1 = (short)drawH; // for OGL drawing\r
2021 PSXDisplay.DrawArea.x1 = (short)drawW;\r
2022\r
2023 ClampToPSXScreen(&PSXDisplay.DrawArea.x0, // clamp\r
2024 &PSXDisplay.DrawArea.y0,\r
2025 &PSXDisplay.DrawArea.x1,\r
2026 &PSXDisplay.DrawArea.y1);\r
2027\r
2028 bDisplayNotSet = TRUE;\r
2029}\r
2030\r
2031////////////////////////////////////////////////////////////////////////\r
2032// cmd: draw offset... will be added to prim coords\r
2033////////////////////////////////////////////////////////////////////////\r
2034\r
677ea103 2035void cmdDrawOffset(unsigned char * baseAddr)\r
ce879073 2036{\r
2037 unsigned long gdata = ((unsigned long*)baseAddr)[0];\r
2038\r
2039 PreviousPSXDisplay.DrawOffset.x = \r
2040 PSXDisplay.DrawOffset.x = (short)(gdata & 0x7ff);\r
2041\r
2042 if(dwGPUVersion==2)\r
2043 {\r
2044 ulGPUInfoVals[INFO_DRAWOFF]=gdata&0x7FFFFF;\r
2045 PSXDisplay.DrawOffset.y = (short)((gdata>>12) & 0x7ff);\r
2046 }\r
2047 else\r
2048 {\r
2049 ulGPUInfoVals[INFO_DRAWOFF]=gdata&0x3FFFFF;\r
2050 PSXDisplay.DrawOffset.y = (short)((gdata>>11) & 0x7ff);\r
2051 }\r
2052 \r
2053 PSXDisplay.DrawOffset.x=(short)(((int)PSXDisplay.DrawOffset.x<<21)>>21);\r
2054 PSXDisplay.DrawOffset.y=(short)(((int)PSXDisplay.DrawOffset.y<<21)>>21);\r
2055\r
2056 PSXDisplay.CumulOffset.x = // new OGL prim offsets\r
2057 PSXDisplay.DrawOffset.x - PSXDisplay.GDrawOffset.x + PreviousPSXDisplay.Range.x0;\r
2058 PSXDisplay.CumulOffset.y = \r
2059 PSXDisplay.DrawOffset.y - PSXDisplay.GDrawOffset.y + PreviousPSXDisplay.Range.y0;\r
2060}\r
2061\r
2062////////////////////////////////////////////////////////////////////////\r
2063// cmd: load image to vram\r
2064////////////////////////////////////////////////////////////////////////\r
2065\r
677ea103 2066void primLoadImage(unsigned char * baseAddr)\r
ce879073 2067{\r
2068 unsigned short *sgpuData = ((unsigned short *) baseAddr);\r
2069\r
2070 VRAMWrite.x = sgpuData[2]&0x03ff;\r
2071 VRAMWrite.y = sgpuData[3]&iGPUHeightMask;\r
2072 VRAMWrite.Width = sgpuData[4];\r
2073 VRAMWrite.Height = sgpuData[5];\r
2074\r
2075 iDataWriteMode = DR_VRAMTRANSFER;\r
2076 VRAMWrite.ImagePtr = psxVuw + (VRAMWrite.y<<10) + VRAMWrite.x;\r
2077 VRAMWrite.RowsRemaining = VRAMWrite.Width;\r
2078 VRAMWrite.ColsRemaining = VRAMWrite.Height;\r
2079\r
2080 bNeedWriteUpload=TRUE;\r
2081}\r
2082\r
2083////////////////////////////////////////////////////////////////////////\r
2084\r
2085void PrepareRGB24Upload(void)\r
2086{\r
2087 VRAMWrite.x=(VRAMWrite.x*2)/3;\r
2088 VRAMWrite.Width=(VRAMWrite.Width*2)/3;\r
2089\r
2090 if(!PSXDisplay.InterlacedTest && // NEW\r
2091 CheckAgainstScreen(VRAMWrite.x, VRAMWrite.y, VRAMWrite.Width, VRAMWrite.Height))\r
2092 {\r
2093 xrUploadArea.x0-=PreviousPSXDisplay.DisplayPosition.x;\r
2094 xrUploadArea.x1-=PreviousPSXDisplay.DisplayPosition.x;\r
2095 xrUploadArea.y0-=PreviousPSXDisplay.DisplayPosition.y;\r
2096 xrUploadArea.y1-=PreviousPSXDisplay.DisplayPosition.y;\r
2097 } \r
2098 else\r
2099 if(CheckAgainstFrontScreen(VRAMWrite.x, VRAMWrite.y, VRAMWrite.Width, VRAMWrite.Height))\r
2100 {\r
2101 xrUploadArea.x0-=PSXDisplay.DisplayPosition.x;\r
2102 xrUploadArea.x1-=PSXDisplay.DisplayPosition.x;\r
2103 xrUploadArea.y0-=PSXDisplay.DisplayPosition.y;\r
2104 xrUploadArea.y1-=PSXDisplay.DisplayPosition.y;\r
2105 } \r
2106 else return;\r
2107\r
2108 if(bRenderFrontBuffer) \r
2109 {\r
2110 updateFrontDisplay();\r
2111 }\r
2112\r
2113 if(bNeedRGB24Update==FALSE)\r
2114 {\r
2115 xrUploadAreaRGB24=xrUploadArea;\r
2116 bNeedRGB24Update=TRUE;\r
2117 }\r
2118 else\r
2119 {\r
2120 xrUploadAreaRGB24.x0=min(xrUploadAreaRGB24.x0,xrUploadArea.x0);\r
2121 xrUploadAreaRGB24.x1=max(xrUploadAreaRGB24.x1,xrUploadArea.x1);\r
2122 xrUploadAreaRGB24.y0=min(xrUploadAreaRGB24.y0,xrUploadArea.y0);\r
2123 xrUploadAreaRGB24.y1=max(xrUploadAreaRGB24.y1,xrUploadArea.y1);\r
2124 }\r
2125}\r
2126\r
2127////////////////////////////////////////////////////////////////////////\r
2128\r
2129void CheckWriteUpdate()\r
2130{\r
2131 int iX=0,iY=0;\r
2132\r
2133 if(VRAMWrite.Width) iX=1;\r
2134 if(VRAMWrite.Height) iY=1;\r
2135\r
2136 InvalidateTextureArea(VRAMWrite.x, VRAMWrite.y, VRAMWrite.Width-iX, VRAMWrite.Height-iY);\r
2137\r
2138 if(PSXDisplay.Interlaced && !iOffscreenDrawing) return;\r
2139\r
2140 if(PSXDisplay.RGB24) {PrepareRGB24Upload();return;}\r
2141\r
2142 if(!PSXDisplay.InterlacedTest &&\r
2143 CheckAgainstScreen(VRAMWrite.x, VRAMWrite.y, VRAMWrite.Width, VRAMWrite.Height)) \r
2144 {\r
2145 if(dwActFixes&0x800) return;\r
2146\r
2147 if(bRenderFrontBuffer) \r
2148 {\r
2149 updateFrontDisplay();\r
2150 }\r
2151\r
2152 UploadScreen(FALSE);\r
2153\r
2154 bNeedUploadTest=TRUE;\r
2155 }\r
2156 else \r
2157 if(iOffscreenDrawing)\r
2158 {\r
2159 if (CheckAgainstFrontScreen(VRAMWrite.x, VRAMWrite.y, VRAMWrite.Width, VRAMWrite.Height)) \r
2160 {\r
2161 if(PSXDisplay.InterlacedTest)\r
2162 {\r
2163 if(PreviousPSXDisplay.InterlacedNew) \r
2164 {\r
2165 PreviousPSXDisplay.InterlacedNew=FALSE;\r
2166 bNeedInterlaceUpdate=TRUE;\r
2167 xrUploadAreaIL.x0=PSXDisplay.DisplayPosition.x;\r
2168 xrUploadAreaIL.y0=PSXDisplay.DisplayPosition.y;\r
2169 xrUploadAreaIL.x1=PSXDisplay.DisplayPosition.x+PSXDisplay.DisplayModeNew.x;\r
2170 xrUploadAreaIL.y1=PSXDisplay.DisplayPosition.y+PSXDisplay.DisplayModeNew.y;\r
2171 if(xrUploadAreaIL.x1>1023) xrUploadAreaIL.x1=1023;\r
2172 if(xrUploadAreaIL.y1>511) xrUploadAreaIL.y1=511;\r
2173 }\r
2174\r
2175 if(bNeedInterlaceUpdate==FALSE)\r
2176 {\r
2177 xrUploadAreaIL=xrUploadArea;\r
2178 bNeedInterlaceUpdate=TRUE;\r
2179 }\r
2180 else\r
2181 {\r
2182 xrUploadAreaIL.x0=min(xrUploadAreaIL.x0,xrUploadArea.x0);\r
2183 xrUploadAreaIL.x1=max(xrUploadAreaIL.x1,xrUploadArea.x1);\r
2184 xrUploadAreaIL.y0=min(xrUploadAreaIL.y0,xrUploadArea.y0);\r
2185 xrUploadAreaIL.y1=max(xrUploadAreaIL.y1,xrUploadArea.y1);\r
2186 }\r
2187 return;\r
2188 }\r
2189\r
2190 if(!bNeedUploadAfter)\r
2191 {\r
2192 bNeedUploadAfter = TRUE;\r
2193 xrUploadArea.x0=VRAMWrite.x;\r
2194 xrUploadArea.x1=VRAMWrite.x+VRAMWrite.Width;\r
2195 xrUploadArea.y0=VRAMWrite.y;\r
2196 xrUploadArea.y1=VRAMWrite.y+VRAMWrite.Height;\r
2197 }\r
2198 else\r
2199 {\r
2200 xrUploadArea.x0=min(xrUploadArea.x0,VRAMWrite.x);\r
2201 xrUploadArea.x1=max(xrUploadArea.x1,VRAMWrite.x+VRAMWrite.Width);\r
2202 xrUploadArea.y0=min(xrUploadArea.y0,VRAMWrite.y);\r
2203 xrUploadArea.y1=max(xrUploadArea.y1,VRAMWrite.y+VRAMWrite.Height);\r
2204 }\r
2205\r
2206 if(dwActFixes&0x8000)\r
2207 {\r
2208 if((xrUploadArea.x1-xrUploadArea.x0)>=(PSXDisplay.DisplayMode.x-32) &&\r
2209 (xrUploadArea.y1-xrUploadArea.y0)>=(PSXDisplay.DisplayMode.y-32))\r
2210 {\r
2211 UploadScreen(-1);\r
2212 updateFrontDisplay();\r
2213 }\r
2214 }\r
2215 }\r
2216 }\r
2217}\r
2218\r
2219////////////////////////////////////////////////////////////////////////\r
2220// cmd: vram -> psx mem\r
2221////////////////////////////////////////////////////////////////////////\r
2222\r
677ea103 2223void primStoreImage(unsigned char * baseAddr)\r
ce879073 2224{\r
2225 unsigned short *sgpuData = ((unsigned short *) baseAddr);\r
2226\r
2227 VRAMRead.x = sgpuData[2]&0x03ff;\r
2228 VRAMRead.y = sgpuData[3]&iGPUHeightMask;\r
2229 VRAMRead.Width = sgpuData[4];\r
2230 VRAMRead.Height = sgpuData[5];\r
2231\r
2232 VRAMRead.ImagePtr = psxVuw + (VRAMRead.y<<10) + VRAMRead.x;\r
2233 VRAMRead.RowsRemaining = VRAMRead.Width;\r
2234 VRAMRead.ColsRemaining = VRAMRead.Height;\r
2235\r
2236 iDataReadMode = DR_VRAMTRANSFER;\r
2237\r
2238 STATUSREG |= GPUSTATUS_READYFORVRAM;\r
2239}\r
2240\r
2241////////////////////////////////////////////////////////////////////////\r
2242// cmd: blkfill - NO primitive! Doesn't care about draw areas...\r
2243////////////////////////////////////////////////////////////////////////\r
2244\r
677ea103 2245void primBlkFill(unsigned char * baseAddr)\r
ce879073 2246{\r
2247 unsigned long *gpuData = ((unsigned long *) baseAddr);\r
2248 short *sgpuData = ((short *) baseAddr);\r
2249\r
2250 iDrawnSomething=1;\r
2251\r
2252 sprtX = sgpuData[2];\r
2253 sprtY = sgpuData[3];\r
2254 sprtW = sgpuData[4] & 0x3ff;\r
2255 sprtH = sgpuData[5] & iGPUHeightMask;\r
2256\r
2257 sprtW = (sprtW+15) & ~15;\r
2258\r
2259 // Increase H & W if they are one short of full values, because they never can be full values\r
2260 if (sprtH == iGPUHeightMask) sprtH=iGPUHeight;\r
2261 if (sprtW == 1023) sprtW=1024; \r
2262 \r
2263 // x and y of start\r
2264 ly0 = ly1 = sprtY;\r
2265 ly2 = ly3 = (sprtY+sprtH);\r
2266 lx0 = lx3 = sprtX;\r
2267 lx1 = lx2 = (sprtX+sprtW);\r
2268\r
2269 offsetBlk();\r
2270\r
2271 if(ClipVertexListScreen()) \r
2272 {\r
2273 PSXDisplay_t * pd;\r
2274 if(PSXDisplay.InterlacedTest) pd=&PSXDisplay;\r
2275 else pd=&PreviousPSXDisplay;\r
2276\r
2277 if ((lx0 <= pd->DisplayPosition.x+16) &&\r
2278 (ly0 <= pd->DisplayPosition.y+16) &&\r
2279 (lx2 >= pd->DisplayEnd.x-16) &&\r
2280 (ly2 >= pd->DisplayEnd.y-16))\r
2281 {\r
2282 GLclampf g,b,r;\r
2283 g=((GLclampf)GREEN(gpuData[0]))/255.0f;\r
2284 b=((GLclampf)BLUE(gpuData[0]))/255.0f;\r
2285 r=((GLclampf)RED(gpuData[0]))/255.0f;\r
2286 \r
edee4a7f 2287 //glDisable(GL_SCISSOR_TEST); glError();\r
9f58cabb 2288 glClearColor(r,g,b,1.0f); glError();\r
2289 glClear(uiBufferBits); glError();\r
ce879073 2290 gl_z=0.0f;\r
2291\r
2292 if(gpuData[0]!=0x02000000 &&\r
2293 (ly0>pd->DisplayPosition.y ||\r
2294 ly2<pd->DisplayEnd.y))\r
2295 {\r
2296 bDrawTextured = FALSE;\r
2297 bDrawSmoothShaded = FALSE;\r
2298 SetRenderState((unsigned long)0x01000000);\r
2299 SetRenderMode((unsigned long)0x01000000, FALSE);\r
2300 vertex[0].c.lcol=0xff000000;\r
2301 SETCOL(vertex[0]); \r
2302 if(ly0>pd->DisplayPosition.y)\r
2303 {\r
2304 vertex[0].x=0;vertex[0].y=0;\r
2305 vertex[1].x=pd->DisplayEnd.x-pd->DisplayPosition.x;vertex[1].y=0;\r
2306 vertex[2].x=vertex[1].x;vertex[2].y=ly0-pd->DisplayPosition.y;\r
2307 vertex[3].x=0;vertex[3].y=vertex[2].y;\r
2308 PRIMdrawQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r
2309 }\r
2310 if(ly2<pd->DisplayEnd.y)\r
2311 {\r
2312 vertex[0].x=0;vertex[0].y=(pd->DisplayEnd.y-pd->DisplayPosition.y)-(pd->DisplayEnd.y-ly2);\r
2313 vertex[1].x=pd->DisplayEnd.x-pd->DisplayPosition.x;vertex[1].y=vertex[0].y;\r
2314 vertex[2].x=vertex[1].x;vertex[2].y=pd->DisplayEnd.y;\r
2315 vertex[3].x=0;vertex[3].y=vertex[2].y;\r
2316 PRIMdrawQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r
2317 }\r
2318 }\r
2319\r
edee4a7f 2320 //glEnable(GL_SCISSOR_TEST); glError();\r
ce879073 2321 }\r
2322 else\r
2323 {\r
2324 bDrawTextured = FALSE;\r
2325 bDrawSmoothShaded = FALSE;\r
2326 SetRenderState((unsigned long)0x01000000);\r
2327 SetRenderMode((unsigned long)0x01000000, FALSE);\r
2328 vertex[0].c.lcol=gpuData[0]|0xff000000;\r
2329 SETCOL(vertex[0]); \r
edee4a7f 2330 //glDisable(GL_SCISSOR_TEST); glError();\r
ce879073 2331 PRIMdrawQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r
edee4a7f 2332 //glEnable(GL_SCISSOR_TEST); glError();\r
ce879073 2333 }\r
2334 }\r
2335\r
2336 //mmm... will clean all stuff, also if not all _should_ be cleaned...\r
2337 //if (IsInsideNextScreen(sprtX, sprtY, sprtW, sprtH))\r
2338 // try this:\r
2339 if (IsCompleteInsideNextScreen(sprtX, sprtY, sprtW, sprtH))\r
2340 {\r
2341 lClearOnSwapColor = COLOR(gpuData[0]);\r
2342 lClearOnSwap = 1;\r
2343 }\r
2344\r
2345/* if(iOffscreenDrawing)\r
2346 {\r
2347 ClampToPSXScreenOffset( &sprtX, &sprtY, &sprtW, &sprtH);\r
2348 if ((sprtW == 0) || (sprtH == 0)) return;\r
2349 InvalidateTextureArea(sprtX, sprtY, sprtW-1, sprtH-1); \r
2350\r
2351 sprtW+=sprtX;\r
2352 sprtH+=sprtY;\r
2353\r
2354 FillSoftwareArea(sprtX, sprtY, sprtW, sprtH, BGR24to16(gpuData[0]));\r
2355 }*/\r
2356}\r
2357 \r
2358////////////////////////////////////////////////////////////////////////\r
2359// cmd: move image vram -> vram\r
2360////////////////////////////////////////////////////////////////////////\r
2361\r
2362void MoveImageWrapped(short imageX0,short imageY0,\r
2363 short imageX1,short imageY1,\r
2364 short imageSX,short imageSY)\r
2365{\r
2366 int i,j,imageXE,imageYE;\r
2367\r
2368 if(iFrameReadType&2)\r
2369 {\r
2370 imageXE=imageX0+imageSX;\r
2371 imageYE=imageY0+imageSY;\r
2372\r
2373 if(imageYE>iGPUHeight && imageXE>1024) \r
2374 {\r
2375 CheckVRamRead(0,0,\r
2376 (imageXE&0x3ff),\r
2377 (imageY0&iGPUHeightMask),\r
2378 FALSE);\r
2379 }\r
2380\r
2381 if(imageXE>1024) \r
2382 {\r
2383 CheckVRamRead(0,imageY0, \r
2384 (imageXE&0x3ff),\r
2385 (imageYE>iGPUHeight)?iGPUHeight:imageYE,\r
2386 FALSE);\r
2387 }\r
2388\r
2389 if(imageYE>iGPUHeight) \r
2390 {\r
2391 CheckVRamRead(imageX0,0, \r
2392 (imageXE>1024)?1024:imageXE,\r
2393 imageYE&iGPUHeightMask,\r
2394 FALSE);\r
2395 }\r
2396\r
2397 CheckVRamRead(imageX0,imageY0, \r
2398 (imageXE>1024)?1024:imageXE,\r
2399 (imageYE>iGPUHeight)?iGPUHeight:imageYE,\r
2400 FALSE);\r
2401 }\r
2402\r
2403 for(j=0;j<imageSY;j++)\r
2404 for(i=0;i<imageSX;i++)\r
2405 psxVuw [(1024*((imageY1+j)&iGPUHeightMask))+((imageX1+i)&0x3ff)]=\r
2406 psxVuw[(1024*((imageY0+j)&iGPUHeightMask))+((imageX0+i)&0x3ff)];\r
2407\r
2408 if(!PSXDisplay.RGB24)\r
2409 {\r
2410 imageXE=imageX1+imageSX;\r
2411 imageYE=imageY1+imageSY;\r
2412\r
2413 if(imageYE>iGPUHeight && imageXE>1024) \r
2414 {\r
2415 InvalidateTextureArea(0,0,\r
2416 (imageXE&0x3ff)-1,\r
2417 (imageYE&iGPUHeightMask)-1);\r
2418 }\r
2419\r
2420 if(imageXE>1024) \r
2421 {\r
2422 InvalidateTextureArea(0,imageY1,\r
2423 (imageXE&0x3ff)-1,\r
2424 ((imageYE>iGPUHeight)?iGPUHeight:imageYE)-imageY1-1);\r
2425 }\r
2426\r
2427 if(imageYE>iGPUHeight) \r
2428 {\r
2429 InvalidateTextureArea(imageX1,0,\r
2430 ((imageXE>1024)?1024:imageXE)-imageX1-1,\r
2431 (imageYE&iGPUHeightMask)-1);\r
2432 }\r
2433\r
2434 InvalidateTextureArea(imageX1,imageY1,\r
2435 ((imageXE>1024)?1024:imageXE)-imageX1-1,\r
2436 ((imageYE>iGPUHeight)?iGPUHeight:imageYE)-imageY1-1);\r
2437 }\r
2438}\r
2439\r
2440////////////////////////////////////////////////////////////////////////\r
2441\r
677ea103 2442void primMoveImage(unsigned char * baseAddr)\r
ce879073 2443{\r
2444 short *sgpuData = ((short *) baseAddr);\r
2445 short imageY0,imageX0,imageY1,imageX1,imageSX,imageSY,i,j;\r
2446\r
2447 imageX0 = sgpuData[2]&0x03ff;\r
2448 imageY0 = sgpuData[3]&iGPUHeightMask;\r
2449 imageX1 = sgpuData[4]&0x03ff;\r
2450 imageY1 = sgpuData[5]&iGPUHeightMask;\r
2451 imageSX = sgpuData[6];\r
2452 imageSY = sgpuData[7];\r
2453\r
2454 if((imageX0 == imageX1) && (imageY0 == imageY1)) return; \r
2455 if(imageSX<=0) return;\r
2456 if(imageSY<=0) return;\r
2457\r
2458 if(iGPUHeight==1024 && sgpuData[7]>1024) return;\r
2459\r
2460 if((imageY0+imageSY)>iGPUHeight ||\r
2461 (imageX0+imageSX)>1024 ||\r
2462 (imageY1+imageSY)>iGPUHeight ||\r
2463 (imageX1+imageSX)>1024)\r
2464 {\r
2465 MoveImageWrapped(imageX0,imageY0,imageX1,imageY1,imageSX,imageSY);\r
2466 if((imageY0+imageSY)>iGPUHeight) imageSY=iGPUHeight-imageY0;\r
2467 if((imageX0+imageSX)>1024) imageSX=1024-imageX0;\r
2468 if((imageY1+imageSY)>iGPUHeight) imageSY=iGPUHeight-imageY1;\r
2469 if((imageX1+imageSX)>1024) imageSX=1024-imageX1;\r
2470 }\r
2471\r
2472 if(iFrameReadType&2)\r
2473 CheckVRamRead(imageX0,imageY0, \r
2474 imageX0+imageSX,\r
2475 imageY0+imageSY,\r
2476 FALSE);\r
2477\r
2478 if(imageSX&1)\r
2479 {\r
2480 unsigned short *SRCPtr, *DSTPtr;\r
2481 unsigned short LineOffset;\r
2482\r
2483 SRCPtr = psxVuw + (1024*imageY0) + imageX0;\r
2484 DSTPtr = psxVuw + (1024*imageY1) + imageX1;\r
2485\r
2486 LineOffset = 1024 - imageSX;\r
2487\r
2488 for(j=0;j<imageSY;j++)\r
2489 {\r
2490 for(i=0;i<imageSX;i++) *DSTPtr++ = *SRCPtr++;\r
2491 SRCPtr += LineOffset;\r
2492 DSTPtr += LineOffset;\r
2493 }\r
2494 }\r
2495 else\r
2496 {\r
2497 unsigned long *SRCPtr, *DSTPtr;\r
2498 unsigned short LineOffset;\r
2499 int dx=imageSX>>1;\r
2500\r
2501 SRCPtr = (unsigned long *)(psxVuw + (1024*imageY0) + imageX0);\r
2502 DSTPtr = (unsigned long *)(psxVuw + (1024*imageY1) + imageX1);\r
2503\r
2504 LineOffset = 512 - dx;\r
2505\r
2506 for(j=0;j<imageSY;j++)\r
2507 {\r
2508 for(i=0;i<dx;i++) *DSTPtr++ = *SRCPtr++;\r
2509 SRCPtr += LineOffset;\r
2510 DSTPtr += LineOffset;\r
2511 }\r
2512 }\r
2513\r
2514 if (!PSXDisplay.RGB24)\r
2515 {\r
2516 InvalidateTextureArea(imageX1,imageY1,imageSX-1,imageSY-1);\r
2517\r
2518 if (CheckAgainstScreen(imageX1,imageY1,imageSX,imageSY)) \r
2519 {\r
2520 if(imageX1>=PreviousPSXDisplay.DisplayPosition.x &&\r
2521 imageX1<PreviousPSXDisplay.DisplayEnd.x &&\r
2522 imageY1>=PreviousPSXDisplay.DisplayPosition.y &&\r
2523 imageY1<PreviousPSXDisplay.DisplayEnd.y)\r
2524 {\r
2525 imageX1 += imageSX;\r
2526 imageY1 += imageSY;\r
2527\r
2528 if(imageX1>=PreviousPSXDisplay.DisplayPosition.x &&\r
2529 imageX1<=PreviousPSXDisplay.DisplayEnd.x &&\r
2530 imageY1>=PreviousPSXDisplay.DisplayPosition.y &&\r
2531 imageY1<=PreviousPSXDisplay.DisplayEnd.y)\r
2532 {\r
2533 if(!(\r
2534 imageX0>=PSXDisplay.DisplayPosition.x &&\r
2535 imageX0<PSXDisplay.DisplayEnd.x &&\r
2536 imageY0>=PSXDisplay.DisplayPosition.y &&\r
2537 imageY0<PSXDisplay.DisplayEnd.y \r
2538 ))\r
2539 {\r
2540 if(bRenderFrontBuffer) \r
2541 {\r
2542 updateFrontDisplay();\r
2543 }\r
2544 \r
2545 UploadScreen(FALSE);\r
2546 }\r
2547 else bFakeFrontBuffer=TRUE;\r
2548 }\r
2549 }\r
2550\r
2551 bNeedUploadTest=TRUE;\r
2552 }\r
2553 else\r
2554 if(iOffscreenDrawing)\r
2555 {\r
2556 if (CheckAgainstFrontScreen(imageX1,imageY1,imageSX,imageSY)) \r
2557 {\r
2558 if(!PSXDisplay.InterlacedTest &&\r
2559// !bFullVRam &&\r
2560 ((\r
2561 imageX0>=PreviousPSXDisplay.DisplayPosition.x &&\r
2562 imageX0<PreviousPSXDisplay.DisplayEnd.x &&\r
2563 imageY0>=PreviousPSXDisplay.DisplayPosition.y &&\r
2564 imageY0<PreviousPSXDisplay.DisplayEnd.y\r
2565 ) ||\r
2566 (\r
2567 imageX0>=PSXDisplay.DisplayPosition.x &&\r
2568 imageX0<PSXDisplay.DisplayEnd.x &&\r
2569 imageY0>=PSXDisplay.DisplayPosition.y &&\r
2570 imageY0<PSXDisplay.DisplayEnd.y\r
2571 )))\r
2572 return;\r
2573\r
2574 bNeedUploadTest=TRUE;\r
2575\r
2576 if(!bNeedUploadAfter)\r
2577 {\r
2578 bNeedUploadAfter = TRUE;\r
2579 xrUploadArea.x0=imageX0;\r
2580 xrUploadArea.x1=imageX0+imageSX;\r
2581 xrUploadArea.y0=imageY0;\r
2582 xrUploadArea.y1=imageY0+imageSY;\r
2583 }\r
2584 else\r
2585 {\r
2586 xrUploadArea.x0=min(xrUploadArea.x0,imageX0);\r
2587 xrUploadArea.x1=max(xrUploadArea.x1,imageX0+imageSX);\r
2588 xrUploadArea.y0=min(xrUploadArea.y0,imageY0);\r
2589 xrUploadArea.y1=max(xrUploadArea.y1,imageY0+imageSY);\r
2590 }\r
2591 }\r
2592 }\r
2593 }\r
2594}\r
2595\r
2596\r
2597////////////////////////////////////////////////////////////////////////\r
2598// cmd: draw free-size Tile \r
2599////////////////////////////////////////////////////////////////////////\r
2600\r
677ea103 2601void primTileS(unsigned char * baseAddr)\r
ce879073 2602{\r
2603 unsigned long *gpuData = ((unsigned long*)baseAddr);\r
2604 short *sgpuData = ((short *) baseAddr);\r
2605\r
2606 sprtX = sgpuData[2];\r
2607 sprtY = sgpuData[3];\r
2608 sprtW = sgpuData[4] & 0x3ff;\r
2609 sprtH = sgpuData[5] & iGPUHeightMask;\r
2610\r
2611 // x and y of start\r
2612\r
2613 lx0 = sprtX;\r
2614 ly0 = sprtY;\r
2615\r
2616 offsetST();\r
2617\r
2618 if((dwActFixes&1) && // FF7 special game gix (battle cursor)\r
2619 sprtX==0 && sprtY==0 && sprtW==24 && sprtH==16) \r
2620 return;\r
2621\r
2622 bDrawTextured = FALSE;\r
2623 bDrawSmoothShaded = FALSE;\r
2624\r
2625 SetRenderState(gpuData[0]);\r
2626\r
2627/* if(iOffscreenDrawing)\r
2628 {\r
2629 if(IsPrimCompleteInsideNextScreen(lx0,ly0,lx2,ly2) ||\r
2630 (ly0==-6 && ly2==10)) // OH MY GOD... I DIDN'T WANT TO DO IT... BUT I'VE FOUND NO OTHER WAY... HACK FOR GRADIUS SHOOTER :(\r
2631 {\r
2632 lClearOnSwapColor = COLOR(gpuData[0]);\r
2633 lClearOnSwap = 1;\r
2634 }\r
2635\r
2636 offsetPSX4();\r
2637 if(bDrawOffscreen4())\r
2638 {\r
2639 if(!(iTileCheat && sprtH==32 && gpuData[0]==0x60ffffff)) // special cheat for certain ZiNc games\r
2640 {\r
2641 InvalidateTextureAreaEx(); \r
2642 FillSoftwareAreaTrans(lx0,ly0,lx2,ly2,\r
2643 BGR24to16(gpuData[0])); \r
2644 }\r
2645 }\r
2646 }*/\r
2647\r
2648 SetRenderMode(gpuData[0], FALSE);\r
2649 SetZMask4NT();\r
2650\r
2651 if(bIgnoreNextTile) {bIgnoreNextTile=FALSE;return;}\r
2652\r
2653 vertex[0].c.lcol=gpuData[0];\r
2654 vertex[0].c.col[3]=ubGloColAlpha;\r
2655 SETCOL(vertex[0]); \r
2656 \r
2657 PRIMdrawQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r
2658\r
2659 iDrawnSomething=1;\r
2660}\r
2661\r
2662////////////////////////////////////////////////////////////////////////\r
2663// cmd: draw 1 dot Tile (point)\r
2664////////////////////////////////////////////////////////////////////////\r
2665\r
677ea103 2666void primTile1(unsigned char * baseAddr)\r
ce879073 2667{\r
2668 unsigned long *gpuData = ((unsigned long*)baseAddr);\r
2669 short *sgpuData = ((short *) baseAddr);\r
2670\r
2671 sprtX = sgpuData[2];\r
2672 sprtY = sgpuData[3];\r
2673 sprtW = 1;\r
2674 sprtH = 1;\r
2675\r
2676 lx0 = sprtX;\r
2677 ly0 = sprtY;\r
2678\r
2679 offsetST();\r
2680\r
2681 bDrawTextured = FALSE;\r
2682 bDrawSmoothShaded = FALSE;\r
2683\r
2684 SetRenderState(gpuData[0]);\r
2685\r
2686/* if(iOffscreenDrawing)\r
2687 {\r
2688 offsetPSX4();\r
2689\r
2690 if(bDrawOffscreen4())\r
2691 {\r
2692 InvalidateTextureAreaEx(); \r
2693 FillSoftwareAreaTrans(lx0,ly0,lx2,ly2,\r
2694 BGR24to16(gpuData[0])); \r
2695 }\r
2696 }\r
2697*/\r
2698 SetRenderMode(gpuData[0], FALSE);\r
2699 SetZMask4NT();\r
2700\r
2701 vertex[0].c.lcol=gpuData[0];vertex[0].c.col[3]=ubGloColAlpha;\r
2702 SETCOL(vertex[0]); \r
2703\r
2704 PRIMdrawQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r
2705\r
2706 iDrawnSomething=1;\r
2707}\r
2708\r
2709////////////////////////////////////////////////////////////////////////\r
2710// cmd: draw 8 dot Tile (small rect)\r
2711////////////////////////////////////////////////////////////////////////\r
2712\r
677ea103 2713void primTile8(unsigned char * baseAddr)\r
ce879073 2714{\r
2715 unsigned long *gpuData = ((unsigned long*)baseAddr);\r
2716 short *sgpuData = ((short *) baseAddr);\r
2717\r
2718 sprtX = sgpuData[2];\r
2719 sprtY = sgpuData[3];\r
2720 sprtW = 8;\r
2721 sprtH = 8;\r
2722\r
2723 lx0 = sprtX;\r
2724 ly0 = sprtY;\r
2725\r
2726 offsetST();\r
2727\r
2728 bDrawTextured = FALSE;\r
2729 bDrawSmoothShaded = FALSE;\r
2730 SetRenderState(gpuData[0]);\r
2731\r
2732/* if(iOffscreenDrawing)\r
2733 {\r
2734 offsetPSX4();\r
2735\r
2736 if(bDrawOffscreen4())\r
2737 {\r
2738 InvalidateTextureAreaEx(); \r
2739 FillSoftwareAreaTrans(lx0,ly0,lx2,ly2,\r
2740 BGR24to16(gpuData[0])); \r
2741 }\r
2742 }\r
2743*/\r
2744 SetRenderMode(gpuData[0], FALSE);\r
2745 SetZMask4NT();\r
2746\r
2747 vertex[0].c.lcol=gpuData[0];\r
2748 vertex[0].c.col[3]=ubGloColAlpha;\r
2749 SETCOL(vertex[0]); \r
2750\r
2751 PRIMdrawQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r
2752\r
2753 iDrawnSomething=1;\r
2754}\r
2755\r
2756////////////////////////////////////////////////////////////////////////\r
2757// cmd: draw 16 dot Tile (medium rect)\r
2758////////////////////////////////////////////////////////////////////////\r
2759\r
677ea103 2760void primTile16(unsigned char * baseAddr)\r
ce879073 2761{\r
2762 unsigned long *gpuData = ((unsigned long*)baseAddr);\r
2763 short *sgpuData = ((short *) baseAddr);\r
2764\r
2765 sprtX = sgpuData[2];\r
2766 sprtY = sgpuData[3];\r
2767 sprtW = 16;\r
2768 sprtH = 16;\r
2769 // x and y of start\r
2770 lx0 = sprtX;\r
2771 ly0 = sprtY;\r
2772\r
2773 offsetST();\r
2774\r
2775 bDrawTextured = FALSE;\r
2776 bDrawSmoothShaded = FALSE;\r
2777 SetRenderState(gpuData[0]);\r
2778\r
2779/* if(iOffscreenDrawing)\r
2780 {\r
2781 offsetPSX4();\r
2782\r
2783 if(bDrawOffscreen4())\r
2784 {\r
2785 InvalidateTextureAreaEx(); \r
2786 FillSoftwareAreaTrans(lx0,ly0,lx2,ly2,\r
2787 BGR24to16(gpuData[0])); \r
2788 }\r
2789 }\r
2790*/\r
2791 SetRenderMode(gpuData[0], FALSE);\r
2792 SetZMask4NT();\r
2793\r
2794 vertex[0].c.lcol=gpuData[0];\r
2795 vertex[0].c.col[3]=ubGloColAlpha;\r
2796 SETCOL(vertex[0]); \r
2797\r
2798 PRIMdrawQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r
2799\r
2800 iDrawnSomething=1;\r
2801}\r
2802\r
2803////////////////////////////////////////////////////////////////////////\r
2804// helper: filter effect by multipass rendering\r
2805////////////////////////////////////////////////////////////////////////\r
2806\r
2807/*void DrawMultiBlur(void)\r
2808{\r
2809 long lABR,lDST;float fx,fy;\r
2810\r
2811 lABR=GlobalTextABR;\r
2812 lDST=DrawSemiTrans;\r
2813\r
2814 fx=(float)PSXDisplay.DisplayMode.x/(float)(iResX); \r
2815 fy=(float)PSXDisplay.DisplayMode.y/(float)(iResY);\r
2816\r
2817 vertex[0].x+=fx;vertex[1].x+=fx;\r
2818 vertex[2].x+=fx;vertex[3].x+=fx;\r
2819\r
2820 GlobalTextABR=0;\r
2821 DrawSemiTrans=1;\r
2822 SetSemiTrans();\r
2823\r
2824 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r
2825\r
2826 vertex[0].y+=fy;vertex[1].y+=fy;\r
2827 vertex[2].y+=fy;vertex[3].y+=fy;\r
2828 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r
2829\r
2830 if(bDrawMultiPass) {obm1=obm2=GL_SRC_ALPHA;}\r
2831\r
2832 GlobalTextABR=lABR;\r
2833 DrawSemiTrans=lDST;\r
2834}\r
2835*/\r
2836////////////////////////////////////////////////////////////////////////\r
2837\r
2838#define POFF 0.375f\r
2839\r
2840void DrawMultiFilterSprite(void)\r
2841{\r
2842 long lABR,lDST;\r
2843\r
2844 if(bUseMultiPass || DrawSemiTrans || ubOpaqueDraw) \r
2845 {\r
2846 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r
2847 return;\r
2848 }\r
2849\r
2850 lABR=GlobalTextABR;\r
2851 lDST=DrawSemiTrans;\r
2852 vertex[0].c.col[3]=ubGloAlpha/2; // -> set color with\r
2853 SETCOL(vertex[0]); // texture alpha\r
2854 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r
2855 vertex[0].x+=POFF;vertex[1].x+=POFF;\r
2856 vertex[2].x+=POFF;vertex[3].x+=POFF;\r
2857 vertex[0].y+=POFF;vertex[1].y+=POFF;\r
2858 vertex[2].y+=POFF;vertex[3].y+=POFF;\r
2859 GlobalTextABR=0;\r
2860 DrawSemiTrans=1;\r
2861 SetSemiTrans();\r
2862 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r
2863 GlobalTextABR=lABR;\r
2864 DrawSemiTrans=lDST;\r
2865}\r
2866\r
2867////////////////////////////////////////////////////////////////////////\r
2868// cmd: small sprite (textured rect)\r
2869////////////////////////////////////////////////////////////////////////\r
2870\r
677ea103 2871void primSprt8(unsigned char * baseAddr)\r
ce879073 2872{\r
2873 unsigned long *gpuData = ((unsigned long *) baseAddr);\r
2874 short *sgpuData = ((short *) baseAddr);\r
2875 short s;\r
2876\r
2877 iSpriteTex=1;\r
2878\r
2879 sprtX = sgpuData[2];\r
2880 sprtY = sgpuData[3];\r
2881 sprtW = 8;\r
2882 sprtH = 8;\r
2883\r
2884 lx0 = sprtX;\r
2885 ly0 = sprtY;\r
2886\r
2887 offsetST();\r
2888\r
2889 // do texture stuff\r
2890 gl_ux[0]=gl_ux[3]=baseAddr[8];//gpuData[2]&0xff;\r
2891\r
2892 if(usMirror & 0x1000) \r
2893 {\r
2894 s=gl_ux[0];\r
2895 s-=sprtW-1;\r
2896 if(s<0) {s=0;}\r
2897 gl_ux[0]=gl_ux[3]=s;\r
2898 }\r
2899\r
2900 sSprite_ux2=s=gl_ux[0]+sprtW; \r
2901 if(s) s--;\r
2902 if(s>255) s=255;\r
2903 gl_ux[1]=gl_ux[2]=s;\r
2904 // Y coords\r
2905 gl_vy[0]=gl_vy[1]=baseAddr[9];//(gpuData[2]>>8)&0xff;\r
2906\r
2907 if(usMirror & 0x2000) \r
2908 {\r
2909 s=gl_vy[0];\r
2910 s-=sprtH-1;\r
2911 if(s<0) {s=0;}\r
2912 gl_vy[0]=gl_vy[1]=s;\r
2913 }\r
2914\r
2915 sSprite_vy2=s=gl_vy[0]+sprtH; \r
2916 if(s) s--;\r
2917 if(s>255) s=255;\r
2918 gl_vy[2]=gl_vy[3]=s;\r
2919\r
2920 ulClutID=(gpuData[2]>>16);\r
2921\r
2922 bDrawTextured = TRUE;\r
2923 bDrawSmoothShaded = FALSE;\r
2924 SetRenderState(gpuData[0]);\r
2925\r
2926/* if(iOffscreenDrawing) \r
2927 {\r
2928 offsetPSX4();\r
2929\r
2930 if(bDrawOffscreen4())\r
2931 {\r
2932 InvalidateTextureAreaEx(); \r
2933 SetRenderColor(gpuData[0]);\r
2934 lx0-=PSXDisplay.DrawOffset.x;\r
2935 ly0-=PSXDisplay.DrawOffset.y;\r
2936\r
2937 if(bUsingTWin) DrawSoftwareSpriteTWin(baseAddr,8,8);\r
2938 else\r
2939 if(usMirror) DrawSoftwareSpriteMirror(baseAddr,8,8);\r
2940 else\r
2941 DrawSoftwareSprite(baseAddr,8,8,baseAddr[8],baseAddr[9]);\r
2942 }\r
2943 }\r
2944*/\r
2945 SetRenderMode(gpuData[0], TRUE);\r
2946 SetZMask4SP();\r
2947\r
2948 sSprite_ux2=gl_ux[0]+sprtW;\r
2949 sSprite_vy2=gl_vy[0]+sprtH;\r
2950\r
2951 assignTextureSprite();\r
2952\r
2953 if(iFilterType>4) \r
2954 DrawMultiFilterSprite();\r
2955 else\r
2956 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r
2957\r
2958 if(bDrawMultiPass)\r
2959 {\r
2960 SetSemiTransMulti(1);\r
2961 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r
2962 }\r
2963\r
2964 if(ubOpaqueDraw)\r
2965 {\r
2966 SetZMask4O();\r
2967 if(bUseMultiPass) SetOpaqueColor(gpuData[0]);\r
2968 DEFOPAQUEON\r
2969\r
2970/* if(bSmallAlpha && iFilterType<=2)\r
2971 {\r
2972 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);\r
2973 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);\r
2974 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r
2975 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);\r
2976 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);\r
2977 SetZMask4O();\r
2978 }\r
2979*/\r
2980 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r
2981 DEFOPAQUEOFF\r
2982 }\r
2983\r
2984 iSpriteTex=0;\r
2985 iDrawnSomething=1;\r
2986}\r
2987\r
2988////////////////////////////////////////////////////////////////////////\r
2989// cmd: medium sprite (textured rect)\r
2990////////////////////////////////////////////////////////////////////////\r
2991\r
677ea103 2992void primSprt16(unsigned char * baseAddr)\r
ce879073 2993{\r
2994 unsigned long *gpuData = ((unsigned long *) baseAddr);\r
2995 short *sgpuData = ((short *) baseAddr);\r
2996 short s;\r
2997\r
2998 iSpriteTex=1;\r
2999\r
3000 sprtX = sgpuData[2];\r
3001 sprtY = sgpuData[3];\r
3002 sprtW = 16;\r
3003 sprtH = 16;\r
3004\r
3005 lx0 = sprtX;\r
3006 ly0 = sprtY;\r
3007\r
3008 offsetST();\r
3009\r
3010 // do texture stuff\r
3011 gl_ux[0]=gl_ux[3]=baseAddr[8];//gpuData[2]&0xff;\r
3012\r
3013 if(usMirror & 0x1000) \r
3014 {\r
3015 s=gl_ux[0];\r
3016 s-=sprtW-1;\r
3017 if(s<0) {s=0;}\r
3018 gl_ux[0]=gl_ux[3]=s;\r
3019 }\r
3020\r
3021 sSprite_ux2=s=gl_ux[0]+sprtW; \r
3022 if(s) s--;\r
3023 if(s>255) s=255;\r
3024 gl_ux[1]=gl_ux[2]=s; \r
3025 // Y coords\r
3026 gl_vy[0]=gl_vy[1]=baseAddr[9];//(gpuData[2]>>8)&0xff;\r
3027\r
3028 if(usMirror & 0x2000) \r
3029 {\r
3030 s=gl_vy[0];\r
3031 s-=sprtH-1;\r
3032 if(s<0) {s=0;}\r
3033 gl_vy[0]=gl_vy[1]=s;\r
3034 }\r
3035\r
3036 sSprite_vy2=s=gl_vy[0]+sprtH; \r
3037 if(s) s--;\r
3038 if(s>255) s=255;\r
3039 gl_vy[2]=gl_vy[3]=s;\r
3040\r
3041 ulClutID=(gpuData[2]>>16);\r
3042\r
3043 bDrawTextured = TRUE;\r
3044 bDrawSmoothShaded = FALSE;\r
3045 SetRenderState(gpuData[0]);\r
3046\r
3047/* if(iOffscreenDrawing) \r
3048 {\r
3049 offsetPSX4();\r
3050\r
3051 if(bDrawOffscreen4())\r
3052 {\r
3053 InvalidateTextureAreaEx(); \r
3054 SetRenderColor(gpuData[0]);\r
3055 lx0-=PSXDisplay.DrawOffset.x;\r
3056 ly0-=PSXDisplay.DrawOffset.y;\r
3057 if(bUsingTWin) DrawSoftwareSpriteTWin(baseAddr,16,16);\r
3058 else\r
3059 if(usMirror) DrawSoftwareSpriteMirror(baseAddr,16,16);\r
3060 else\r
3061 DrawSoftwareSprite(baseAddr,16,16,baseAddr[8],baseAddr[9]);\r
3062 }\r
3063 }\r
3064*/\r
3065 SetRenderMode(gpuData[0], TRUE);\r
3066 SetZMask4SP();\r
3067\r
3068 sSprite_ux2=gl_ux[0]+sprtW;\r
3069 sSprite_vy2=gl_vy[0]+sprtH;\r
3070\r
3071 assignTextureSprite();\r
3072\r
3073 if(iFilterType>4) \r
3074 DrawMultiFilterSprite();\r
3075 else\r
3076 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r
3077\r
3078 if(bDrawMultiPass)\r
3079 {\r
3080 SetSemiTransMulti(1);\r
3081 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r
3082 }\r
3083\r
3084 if(ubOpaqueDraw)\r
3085 {\r
3086 SetZMask4O();\r
3087 if(bUseMultiPass) SetOpaqueColor(gpuData[0]);\r
3088 DEFOPAQUEON\r
3089\r
3090/* if(bSmallAlpha && iFilterType<=2)\r
3091 {\r
3092 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);\r
3093 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);\r
3094 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r
3095 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);\r
3096 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);\r
3097 SetZMask4O();\r
3098 }\r
3099*/\r
3100 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r
3101 DEFOPAQUEOFF\r
3102 }\r
3103\r
3104 iSpriteTex=0;\r
3105 iDrawnSomething=1;\r
3106}\r
3107\r
3108////////////////////////////////////////////////////////////////////////\r
3109// cmd: free-size sprite (textured rect)\r
3110////////////////////////////////////////////////////////////////////////\r
3111 \r
677ea103 3112void primSprtSRest(unsigned char * baseAddr,unsigned short type)\r
ce879073 3113{\r
3114 unsigned long *gpuData = ((unsigned long *) baseAddr);\r
3115 short *sgpuData = ((short *) baseAddr);\r
3116 short s;unsigned short sTypeRest=0;\r
3117\r
3118 sprtX = sgpuData[2];\r
3119 sprtY = sgpuData[3];\r
3120 sprtW = sgpuData[6] & 0x3ff;\r
3121 sprtH = sgpuData[7] & 0x1ff;\r
3122\r
3123\r
3124 // do texture stuff\r
3125 switch(type)\r
3126 {\r
3127 case 1:\r
3128 gl_vy[0]=gl_vy[1]=baseAddr[9];\r
3129 s=256-baseAddr[8];\r
3130 sprtW-=s;\r
3131 sprtX+=s;\r
3132 gl_ux[0]=gl_ux[3]=0;\r
3133 break;\r
3134 case 2:\r
3135 gl_ux[0]=gl_ux[3]=baseAddr[8];\r
3136 s=256-baseAddr[9];\r
3137 sprtH-=s;\r
3138 sprtY+=s;\r
3139 gl_vy[0]=gl_vy[1]=0;\r
3140 break;\r
3141 case 3:\r
3142 s=256-baseAddr[8];\r
3143 sprtW-=s;\r
3144 sprtX+=s;\r
3145 gl_ux[0]=gl_ux[3]=0;\r
3146 s=256-baseAddr[9];\r
3147 sprtH-=s;\r
3148 sprtY+=s;\r
3149 gl_vy[0]=gl_vy[1]=0;\r
3150 break;\r
3151\r
3152 case 4:\r
3153 gl_vy[0]=gl_vy[1]=baseAddr[9];\r
3154 s=512-baseAddr[8];\r
3155 sprtW-=s;\r
3156 sprtX+=s;\r
3157 gl_ux[0]=gl_ux[3]=0;\r
3158 break;\r
3159 case 5:\r
3160 gl_ux[0]=gl_ux[3]=baseAddr[8];\r
3161 s=512-baseAddr[9];\r
3162 sprtH-=s;\r
3163 sprtY+=s;\r
3164 gl_vy[0]=gl_vy[1]=0;\r
3165 break;\r
3166 case 6:\r
3167 s=512-baseAddr[8];\r
3168 sprtW-=s;\r
3169 sprtX+=s;\r
3170 gl_ux[0]=gl_ux[3]=0;\r
3171 s=512-baseAddr[9];\r
3172 sprtH-=s;\r
3173 sprtY+=s;\r
3174 gl_vy[0]=gl_vy[1]=0;\r
3175 break;\r
3176\r
3177 }\r
3178\r
3179 if(usMirror & 0x1000) \r
3180 {\r
3181 s=gl_ux[0];\r
3182 s-=sprtW-1;if(s<0) s=0;\r
3183 gl_ux[0]=gl_ux[3]=s;\r
3184 }\r
3185 if(usMirror & 0x2000) \r
3186 {\r
3187 s=gl_vy[0];\r
3188 s-=sprtH-1;if(s<0) {s=0;}\r
3189 gl_vy[0]=gl_vy[1]=s;\r
3190 }\r
3191\r
3192 sSprite_ux2=s=gl_ux[0]+sprtW; \r
3193 if(s>255) s=255;\r
3194 gl_ux[1]=gl_ux[2]=s;\r
3195 sSprite_vy2=s=gl_vy[0]+sprtH; \r
3196 if(s>255) s=255;\r
3197 gl_vy[2]=gl_vy[3]=s;\r
3198\r
3199 if(!bUsingTWin)\r
3200 {\r
3201 if(sSprite_ux2>256) \r
3202 {sprtW=256-gl_ux[0];sSprite_ux2=256;sTypeRest+=1;}\r
3203 if(sSprite_vy2>256) \r
3204 {sprtH=256-gl_vy[0];sSprite_vy2=256;sTypeRest+=2;}\r
3205 }\r
3206 \r
3207 lx0 = sprtX;\r
3208 ly0 = sprtY;\r
3209\r
3210 offsetST();\r
3211\r
3212 ulClutID=(gpuData[2]>>16);\r
3213\r
3214 bDrawTextured = TRUE;\r
3215 bDrawSmoothShaded = FALSE;\r
3216 SetRenderState(gpuData[0]);\r
3217\r
3218/* if(iOffscreenDrawing)\r
3219 {\r
3220 offsetPSX4();\r
3221\r
3222 if(bDrawOffscreen4())\r
3223 {\r
3224 InvalidateTextureAreaEx(); \r
3225 SetRenderColor(gpuData[0]);\r
3226 lx0-=PSXDisplay.DrawOffset.x;\r
3227 ly0-=PSXDisplay.DrawOffset.y;\r
3228 if(bUsingTWin) DrawSoftwareSpriteTWin(baseAddr,sprtW,sprtH);\r
3229 else\r
3230 if(usMirror) DrawSoftwareSpriteMirror(baseAddr,sprtW,sprtH);\r
3231 else\r
3232 DrawSoftwareSprite(baseAddr,sprtW,sprtH,baseAddr[8],baseAddr[9]);\r
3233 }\r
3234 }\r
3235*/\r
3236 SetRenderMode(gpuData[0], TRUE);\r
3237 SetZMask4SP();\r
3238\r
3239 sSprite_ux2=gl_ux[0]+sprtW;\r
3240 sSprite_vy2=gl_vy[0]+sprtH;\r
3241\r
3242 assignTextureSprite();\r
3243\r
3244 if(iFilterType>4) \r
3245 DrawMultiFilterSprite();\r
3246 else\r
3247 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r
3248 \r
3249 if(bDrawMultiPass)\r
3250 {\r
3251 SetSemiTransMulti(1);\r
3252 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r
3253 }\r
3254\r
3255 if(ubOpaqueDraw)\r
3256 {\r
3257 SetZMask4O();\r
3258 if(bUseMultiPass) SetOpaqueColor(gpuData[0]);\r
3259 DEFOPAQUEON\r
3260\r
3261/* if(bSmallAlpha && iFilterType<=2)\r
3262 {\r
3263 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);\r
3264 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);\r
3265 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r
3266 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);\r
3267 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);\r
3268 SetZMask4O();\r
3269 }\r
3270*/\r
3271 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r
3272 DEFOPAQUEOFF\r
3273 }\r
3274\r
3275 if(sTypeRest && type<4) \r
3276 {\r
3277 if(sTypeRest&1 && type==1) primSprtSRest(baseAddr,4);\r
3278 if(sTypeRest&2 && type==2) primSprtSRest(baseAddr,5);\r
3279 if(sTypeRest==3 && type==3) primSprtSRest(baseAddr,6);\r
3280 }\r
3281}\r
3282\r
677ea103 3283void primSprtS(unsigned char * baseAddr)\r
ce879073 3284{\r
3285 unsigned long *gpuData = ((unsigned long *) baseAddr);\r
3286 short *sgpuData = ((short *) baseAddr);\r
3287\r
3288 short s;unsigned short sTypeRest=0;\r
3289\r
3290 sprtX = sgpuData[2];\r
3291 sprtY = sgpuData[3];\r
3292 sprtW = sgpuData[6] & 0x3ff;\r
3293 sprtH = sgpuData[7] & 0x1ff;\r
3294\r
3295 if(!sprtH) return;\r
3296 if(!sprtW) return;\r
3297\r
3298 iSpriteTex=1;\r
3299\r
3300 // do texture stuff\r
3301 gl_ux[0]=gl_ux[3]=baseAddr[8];//gpuData[2]&0xff;\r
3302 gl_vy[0]=gl_vy[1]=baseAddr[9];//(gpuData[2]>>8)&0xff;\r
3303\r
3304 if(usMirror & 0x1000) \r
3305 {\r
3306 s=gl_ux[0];\r
3307 s-=sprtW-1;\r
3308 if(s<0) {s=0;}\r
3309 gl_ux[0]=gl_ux[3]=s;\r
3310 }\r
3311 if(usMirror & 0x2000) \r
3312 {\r
3313 s=gl_vy[0];\r
3314 s-=sprtH-1;\r
3315 if(s<0) {s=0;}\r
3316 gl_vy[0]=gl_vy[1]=s;\r
3317 }\r
3318\r
3319 sSprite_ux2=s=gl_ux[0]+sprtW; \r
3320 if(s) s--;\r
3321 if(s>255) s=255;\r
3322 gl_ux[1]=gl_ux[2]=s;\r
3323 sSprite_vy2=s=gl_vy[0]+sprtH; \r
3324 if(s) s--;\r
3325 if(s>255) s=255;\r
3326 gl_vy[2]=gl_vy[3]=s;\r
3327\r
3328 if(!bUsingTWin)\r
3329 {\r
3330 if(sSprite_ux2>256) \r
3331 {sprtW=256-gl_ux[0];sSprite_ux2=256;sTypeRest+=1;}\r
3332 if(sSprite_vy2>256) \r
3333 {sprtH=256-gl_vy[0];sSprite_vy2=256;sTypeRest+=2;}\r
3334 }\r
3335\r
3336 lx0 = sprtX;\r
3337 ly0 = sprtY;\r
3338\r
3339 offsetST();\r
3340\r
3341 ulClutID=(gpuData[2]>>16);\r
3342\r
3343 bDrawTextured = TRUE;\r
3344 bDrawSmoothShaded = FALSE;\r
3345 SetRenderState(gpuData[0]);\r
3346\r
3347/* if(iOffscreenDrawing)\r
3348 {\r
3349 offsetPSX4();\r
3350\r
3351 if(bDrawOffscreen4())\r
3352 {\r
3353 InvalidateTextureAreaEx(); \r
3354 SetRenderColor(gpuData[0]);\r
3355 lx0-=PSXDisplay.DrawOffset.x;\r
3356 ly0-=PSXDisplay.DrawOffset.y;\r
3357 if(bUsingTWin) DrawSoftwareSpriteTWin(baseAddr,sprtW,sprtH);\r
3358 else\r
3359 if(usMirror) DrawSoftwareSpriteMirror(baseAddr,sprtW,sprtH);\r
3360 else\r
3361 DrawSoftwareSprite(baseAddr,sprtW,sprtH,baseAddr[8],baseAddr[9]);\r
3362 }\r
3363 }\r
3364*/\r
3365 SetRenderMode(gpuData[0], TRUE);\r
3366 SetZMask4SP();\r
3367\r
3368 if((dwActFixes&1) && gTexFrameName && gTexName==gTexFrameName) \r
3369 {iSpriteTex=0;return;}\r
3370\r
3371 sSprite_ux2=gl_ux[0]+sprtW;\r
3372 sSprite_vy2=gl_vy[0]+sprtH;\r
3373\r
3374 assignTextureSprite();\r
3375\r
3376 if(iFilterType>4) \r
3377 DrawMultiFilterSprite();\r
3378 else\r
3379 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r
3380 \r
3381 if(bDrawMultiPass)\r
3382 {\r
3383 SetSemiTransMulti(1);\r
3384 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r
3385 }\r
3386\r
3387 if(ubOpaqueDraw)\r
3388 {\r
3389 SetZMask4O();\r
3390 if(bUseMultiPass) SetOpaqueColor(gpuData[0]);\r
3391 DEFOPAQUEON\r
3392\r
3393/* if(bSmallAlpha && iFilterType<=2)\r
3394 {\r
3395 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);\r
3396 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);\r
3397 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r
3398 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);\r
3399 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);\r
3400 SetZMask4O();\r
3401 }\r
3402*/\r
3403 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r
3404 DEFOPAQUEOFF\r
3405 }\r
3406\r
3407 if(sTypeRest) \r
3408 {\r
3409 if(sTypeRest&1) primSprtSRest(baseAddr,1);\r
3410 if(sTypeRest&2) primSprtSRest(baseAddr,2);\r
3411 if(sTypeRest==3) primSprtSRest(baseAddr,3);\r
3412 }\r
3413\r
3414 iSpriteTex=0;\r
3415 iDrawnSomething=1;\r
3416}\r
3417\r
3418////////////////////////////////////////////////////////////////////////\r
3419// cmd: flat shaded Poly4\r
3420////////////////////////////////////////////////////////////////////////\r
3421\r
677ea103 3422void primPolyF4(unsigned char *baseAddr)\r
ce879073 3423{\r
3424 unsigned long *gpuData = ((unsigned long *) baseAddr);\r
3425 short *sgpuData = ((short *) baseAddr);\r
3426\r
3427 lx0 = sgpuData[2];\r
3428 ly0 = sgpuData[3];\r
3429 lx1 = sgpuData[4];\r
3430 ly1 = sgpuData[5];\r
3431 lx2 = sgpuData[6];\r
3432 ly2 = sgpuData[7];\r
3433 lx3 = sgpuData[8];\r
3434 ly3 = sgpuData[9];\r
3435\r
3436 if(offset4()) return;\r
3437\r
3438 bDrawTextured = FALSE;\r
3439 bDrawSmoothShaded = FALSE;\r
3440 SetRenderState(gpuData[0]);\r
3441\r
3442/* if(iOffscreenDrawing)\r
3443 {\r
3444 offsetPSX4();\r
3445 if(bDrawOffscreen4())\r
3446 {\r
3447 InvalidateTextureAreaEx(); \r
3448 drawPoly4F(gpuData[0]);\r
3449 }\r
3450 }\r
3451*/\r
3452 SetRenderMode(gpuData[0], FALSE);\r
3453 SetZMask4NT();\r
3454\r
3455 vertex[0].c.lcol=gpuData[0];vertex[0].c.col[3]=ubGloColAlpha;\r
3456 SETCOL(vertex[0]); \r
3457\r
3458 PRIMdrawTri2(&vertex[0], &vertex[1], &vertex[2],&vertex[3]);\r
3459\r
3460 iDrawnSomething=1;\r
3461}\r
3462\r
3463////////////////////////////////////////////////////////////////////////\r
3464// cmd: smooth shaded Poly4\r
3465////////////////////////////////////////////////////////////////////////\r
3466\r
677ea103 3467void primPolyG4(unsigned char * baseAddr);\r
ce879073 3468\r
3469BOOL bDrawOffscreenFrontFF9G4(void)\r
3470{\r
3471 if(lx0< PSXDisplay.DisplayPosition.x) return FALSE; // must be complete in front\r
3472 if(lx0> PSXDisplay.DisplayEnd.x) return FALSE;\r
3473 if(ly0< PSXDisplay.DisplayPosition.y) return FALSE;\r
3474 if(ly0> PSXDisplay.DisplayEnd.y) return FALSE;\r
3475 if(lx1< PSXDisplay.DisplayPosition.x) return FALSE;\r
3476 if(lx1> PSXDisplay.DisplayEnd.x) return FALSE;\r
3477 if(ly1< PSXDisplay.DisplayPosition.y) return FALSE;\r
3478 if(ly1> PSXDisplay.DisplayEnd.y) return FALSE;\r
3479 if(lx2< PSXDisplay.DisplayPosition.x) return FALSE;\r
3480 if(lx2> PSXDisplay.DisplayEnd.x) return FALSE;\r
3481 if(ly2< PSXDisplay.DisplayPosition.y) return FALSE;\r
3482 if(ly2> PSXDisplay.DisplayEnd.y) return FALSE;\r
3483 if(lx3< PSXDisplay.DisplayPosition.x) return FALSE;\r
3484 if(lx3> PSXDisplay.DisplayEnd.x) return FALSE;\r
3485 if(ly3< PSXDisplay.DisplayPosition.y) return FALSE;\r
3486 if(ly3> PSXDisplay.DisplayEnd.y) return FALSE;\r
3487 return TRUE;\r
3488}\r
3489\r
677ea103 3490BOOL bCheckFF9G4(unsigned char * baseAddr)\r
ce879073 3491{\r
677ea103 3492 static unsigned char pFF9G4Cache[32];\r
ce879073 3493 static int iFF9Fix=0;\r
3494\r
3495 if(baseAddr)\r
3496 {\r
3497 if(iFF9Fix==0)\r
3498 {\r
3499 if(bDrawOffscreenFrontFF9G4())\r
3500 {\r
3501 short *sgpuData = ((short *) pFF9G4Cache);\r
3502 iFF9Fix=2;\r
3503 memcpy(pFF9G4Cache,baseAddr,32);\r
3504\r
3505 if(sgpuData[2]==142)\r
3506 {\r
3507 sgpuData[2] +=65;\r
3508 sgpuData[10]+=65;\r
3509 }\r
3510 return TRUE;\r
3511 }\r
3512 else iFF9Fix=1;\r
3513 }\r
3514 return FALSE;\r
3515 }\r
3516\r
3517 if(iFF9Fix==2)\r
3518 {\r
3519 long labr=GlobalTextABR;\r
3520 GlobalTextABR=1;\r
3521 primPolyG4(pFF9G4Cache);\r
3522 GlobalTextABR=labr;\r
3523 }\r
3524 iFF9Fix=0;\r
3525\r
3526 return FALSE;\r
3527}\r
3528\r
3529////////////////////////////////////////////////////////////////////////\r
3530\r
677ea103 3531void primPolyG4(unsigned char * baseAddr)\r
ce879073 3532{\r
3533 unsigned long *gpuData = (unsigned long *)baseAddr;\r
3534 short *sgpuData = ((short *) baseAddr);\r
3535\r
3536 lx0 = sgpuData[2];\r
3537 ly0 = sgpuData[3];\r
3538 lx1 = sgpuData[6];\r
3539 ly1 = sgpuData[7];\r
3540 lx2 = sgpuData[10];\r
3541 ly2 = sgpuData[11];\r
3542 lx3 = sgpuData[14];\r
3543 ly3 = sgpuData[15];\r
3544\r
3545 if(offset4()) return;\r
3546\r
3547 bDrawTextured = FALSE;\r
3548 bDrawSmoothShaded = TRUE;\r
3549 SetRenderState(gpuData[0]);\r
3550\r
3551/* if(iOffscreenDrawing)\r
3552 {\r
3553 offsetPSX4();\r
3554\r
3555 if((dwActFixes&512) && bCheckFF9G4(baseAddr)) return;\r
3556\r
3557 if(bDrawOffscreen4())\r
3558 {\r
3559 InvalidateTextureAreaEx(); \r
3560 drawPoly4G(gpuData[0], gpuData[2], gpuData[4], gpuData[6]);\r
3561 } \r
3562 }\r
3563*/\r
3564 SetRenderMode(gpuData[0], FALSE);\r
3565 SetZMask4NT();\r
3566\r
3567 vertex[0].c.lcol=gpuData[0];\r
3568 vertex[1].c.lcol=gpuData[2];\r
3569 vertex[2].c.lcol=gpuData[4];\r
3570 vertex[3].c.lcol=gpuData[6];\r
3571\r
3572 vertex[0].c.col[3]=vertex[1].c.col[3]=vertex[2].c.col[3]=vertex[3].c.col[3]=ubGloAlpha;\r
3573\r
3574\r
3575 PRIMdrawGouraudTri2Color(&vertex[0],&vertex[1], &vertex[2], &vertex[3]);\r
3576\r
3577 iDrawnSomething=1;\r
3578}\r
3579\r
3580////////////////////////////////////////////////////////////////////////\r
3581// cmd: flat shaded Texture3\r
3582////////////////////////////////////////////////////////////////////////\r
3583\r
3584BOOL DoLineCheck(unsigned long * gpuData)\r
3585{\r
3586 BOOL bQuad=FALSE;short dx,dy;\r
3587\r
3588 if(lx0==lx1)\r
3589 {\r
3590 dx=lx0-lx2;if(dx<0) dx=-dx;\r
3591\r
3592 if(ly1==ly2) \r
3593 {\r
3594 dy=ly1-ly0;if(dy<0) dy=-dy;\r
3595 if(dx<=1)\r
3596 {\r
3597 vertex[3]=vertex[2];\r
3598 vertex[2]=vertex[0];\r
3599 vertex[2].x=vertex[3].x;\r
3600 }\r
3601 else\r
3602 if(dy<=1)\r
3603 {\r
3604 vertex[3]=vertex[2];\r
3605 vertex[2].y=vertex[0].y;\r
3606 }\r
3607 else return FALSE;\r
3608\r
3609 bQuad=TRUE;\r
3610 }\r
3611 else\r
3612 if(ly0==ly2) \r
3613 {\r
3614 dy=ly0-ly1;if(dy<0) dy=-dy;\r
3615 if(dx<=1)\r
3616 {\r
3617 vertex[3]=vertex[1];\r
3618 vertex[3].x=vertex[2].x;\r
3619 }\r
3620 else\r
3621 if(dy<=1)\r
3622 {\r
3623 vertex[3]=vertex[2];\r
3624 vertex[3].y=vertex[1].y;\r
3625 }\r
3626 else return FALSE;\r
3627\r
3628 bQuad=TRUE;\r
3629 }\r
3630 }\r
3631\r
3632 if(lx0==lx2)\r
3633 {\r
3634 dx=lx0-lx1;if(dx<0) dx=-dx;\r
3635\r
3636 if(ly2==ly1) \r
3637 {\r
3638 dy=ly2-ly0;if(dy<0) dy=-dy;\r
3639 if(dx<=1)\r
3640 {\r
3641 vertex[3]=vertex[1];\r
3642 vertex[1]=vertex[0];\r
3643 vertex[1].x=vertex[3].x;\r
3644 }\r
3645 else\r
3646 if(dy<=1)\r
3647 {\r
3648 vertex[3]=vertex[1];\r
3649 vertex[1].y=vertex[0].y;\r
3650 }\r
3651 else return FALSE;\r
3652\r
3653 bQuad=TRUE;\r
3654 }\r
3655 else\r
3656 if(ly0==ly1)\r
3657 {\r
3658 dy=ly2-ly0;if(dy<0) dy=-dy;\r
3659 if(dx<=1)\r
3660 {\r
3661 vertex[3]=vertex[2];\r
3662 vertex[3].x=vertex[1].x;\r
3663 }\r
3664 else\r
3665 if(dy<=1)\r
3666 {\r
3667 vertex[3]=vertex[1];\r
3668 vertex[3].y=vertex[2].y;\r
3669 }\r
3670 else return FALSE;\r
3671\r
3672 bQuad=TRUE;\r
3673 }\r
3674 }\r
3675\r
3676 if(lx1==lx2)\r
3677 {\r
3678 dx=lx1-lx0;if(dx<0) dx=-dx;\r
3679\r
3680 if(ly1==ly0)\r
3681 {\r
3682 dy=ly1-ly2;if(dy<0) dy=-dy;\r
3683\r
3684 if(dx<=1)\r
3685 {\r
3686 vertex[3]=vertex[2];\r
3687 vertex[2].x=vertex[0].x;\r
3688 }\r
3689 else\r
3690 if(dy<=1)\r
3691 {\r
3692 vertex[3]=vertex[2];\r
3693 vertex[2]=vertex[0];\r
3694 vertex[2].y=vertex[3].y;\r
3695 }\r
3696 else return FALSE;\r
3697\r
3698 bQuad=TRUE;\r
3699 }\r
3700 else\r
3701 if(ly2==ly0)\r
3702 {\r
3703 dy=ly2-ly1;if(dy<0) dy=-dy;\r
3704\r
3705 if(dx<=1)\r
3706 {\r
3707 vertex[3]=vertex[1];\r
3708 vertex[1].x=vertex[0].x;\r
3709 }\r
3710 else\r
3711 if(dy<=1)\r
3712 {\r
3713 vertex[3]=vertex[1];\r
3714 vertex[1]=vertex[0];\r
3715 vertex[1].y=vertex[3].y;\r
3716 }\r
3717 else return FALSE;\r
3718\r
3719 bQuad=TRUE;\r
3720 }\r
3721 }\r
3722\r
3723 if(!bQuad) return FALSE;\r
3724\r
3725 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[3], &vertex[2]);\r
3726\r
3727 if(bDrawMultiPass)\r
3728 {\r
3729 SetSemiTransMulti(1);\r
3730 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[3], &vertex[2]);\r
3731 }\r
3732\r
3733 if(ubOpaqueDraw)\r
3734 {\r
3735 SetZMask4O();\r
3736 if(bUseMultiPass) SetOpaqueColor(gpuData[0]);\r
3737 DEFOPAQUEON\r
3738 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[3], &vertex[2]);\r
3739 DEFOPAQUEOFF\r
3740 }\r
3741\r
3742 iDrawnSomething=1;\r
3743\r
3744 return TRUE;\r
3745}\r
3746\r
3747////////////////////////////////////////////////////////////////////////\r
3748\r
677ea103 3749void primPolyFT3(unsigned char * baseAddr)\r
ce879073 3750{\r
3751 unsigned long *gpuData = ((unsigned long *) baseAddr);\r
3752 short *sgpuData = ((short *) baseAddr);\r
3753\r
3754 lx0 = sgpuData[2];\r
3755 ly0 = sgpuData[3];\r
3756 lx1 = sgpuData[6];\r
3757 ly1 = sgpuData[7];\r
3758 lx2 = sgpuData[10];\r
3759 ly2 = sgpuData[11];\r
3760\r
3761 if(offset3()) return;\r
3762 \r
3763 // do texture UV coordinates stuff\r
3764 gl_ux[0]=gl_ux[3]=baseAddr[8];//gpuData[2]&0xff;\r
3765 gl_vy[0]=gl_vy[3]=baseAddr[9];//(gpuData[2]>>8)&0xff;\r
3766 gl_ux[1]=baseAddr[16];//gpuData[4]&0xff;\r
3767 gl_vy[1]=baseAddr[17];//(gpuData[4]>>8)&0xff;\r
3768 gl_ux[2]=baseAddr[24];//gpuData[6]&0xff;\r
3769 gl_vy[2]=baseAddr[25];//(gpuData[6]>>8)&0xff;\r
3770\r
3771 UpdateGlobalTP((unsigned short)(gpuData[4]>>16));\r
3772 ulClutID=gpuData[2]>>16;\r
3773\r
3774 bDrawTextured = TRUE;\r
3775 bDrawSmoothShaded = FALSE;\r
3776 SetRenderState(gpuData[0]);\r
3777\r
3778/* if(iOffscreenDrawing)\r
3779 {\r
3780 offsetPSX3();\r
3781 if(bDrawOffscreen3())\r
3782 {\r
3783 InvalidateTextureAreaEx(); \r
3784 SetRenderColor(gpuData[0]);\r
3785 drawPoly3FT(baseAddr);\r
3786 }\r
3787 }\r
3788*/\r
3789 SetRenderMode(gpuData[0], TRUE);\r
3790 SetZMask3();\r
3791\r
3792 assignTexture3();\r
3793\r
3794 if(!(dwActFixes&0x10))\r
3795 {\r
3796 if(DoLineCheck(gpuData)) return;\r
3797 }\r
3798\r
3799 PRIMdrawTexturedTri(&vertex[0], &vertex[1], &vertex[2]);\r
3800\r
3801 if(bDrawMultiPass)\r
3802 {\r
3803 SetSemiTransMulti(1);\r
3804 PRIMdrawTexturedTri(&vertex[0], &vertex[1], &vertex[2]);\r
3805 }\r
3806\r
3807 if(ubOpaqueDraw)\r
3808 {\r
3809 SetZMask3O();\r
3810 if(bUseMultiPass) SetOpaqueColor(gpuData[0]);\r
3811 DEFOPAQUEON\r
3812 PRIMdrawTexturedTri(&vertex[0], &vertex[1], &vertex[2]);\r
3813 DEFOPAQUEOFF\r
3814 }\r
3815\r
3816 iDrawnSomething=1;\r
3817}\r
3818\r
3819////////////////////////////////////////////////////////////////////////\r
3820// cmd: flat shaded Texture4\r
3821////////////////////////////////////////////////////////////////////////\r
3822\r
3823#define ST_FAC 255.99f\r
3824\r
3825void RectTexAlign(void)\r
3826{\r
3827 int UFlipped = FALSE;\r
3828 int VFlipped = FALSE;\r
3829\r
3830 if(gTexName==gTexFrameName) return;\r
3831\r
3832 if(ly0==ly1)\r
3833 {\r
3834 if(!((lx1==lx3 && ly3==ly2 && lx2==lx0) ||\r
3835 (lx1==lx2 && ly2==ly3 && lx3==lx0)))\r
3836 return;\r
3837\r
3838 if(ly0<ly2) \r
3839 {\r
3840 if (vertex[0].tow > vertex[2].tow)\r
3841 VFlipped = 1;\r
3842 }\r
3843 else\r
3844 {\r
3845 if (vertex[0].tow < vertex[2].tow)\r
3846 VFlipped = 2;\r
3847 }\r
3848 }\r
3849 else\r
3850 if(ly0==ly2)\r
3851 {\r
3852 if(!((lx2==lx3 && ly3==ly1 && lx1==lx0) ||\r
3853 (lx2==lx1 && ly1==ly3 && lx3==lx0)))\r
3854 return;\r
3855\r
3856 if(ly0<ly1) \r
3857 {\r
3858 if (vertex[0].tow > vertex[1].tow)\r
3859 VFlipped = 3;\r
3860 }\r
3861 else\r
3862 {\r
3863 if (vertex[0].tow < vertex[1].tow)\r
3864 VFlipped = 4;\r
3865 }\r
3866 }\r
3867 else\r
3868 if(ly0==ly3)\r
3869 {\r
3870 if(!((lx3==lx2 && ly2==ly1 && lx1==lx0) ||\r
3871 (lx3==lx1 && ly1==ly2 && lx2==lx0)))\r
3872 return;\r
3873\r
3874 if(ly0<ly1) \r
3875 {\r
3876 if (vertex[0].tow > vertex[1].tow)\r
3877 VFlipped = 5;\r
3878 }\r
3879 else\r
3880 {\r
3881 if (vertex[0].tow < vertex[1].tow)\r
3882 VFlipped = 6;\r
3883 }\r
3884 }\r
3885 else return;\r
3886\r
3887 if(lx0==lx1)\r
3888 {\r
3889 if(lx0<lx2) \r
3890 {\r
3891 if (vertex[0].sow > vertex[2].sow)\r
3892 UFlipped = 1;\r
3893 }\r
3894 else\r
3895 {\r
3896 if (vertex[0].sow < vertex[2].sow)\r
3897 UFlipped = 2;\r
3898 }\r
3899 }\r
3900 else\r
3901 if(lx0==lx2)\r
3902 {\r
3903 if(lx0<lx1) \r
3904 {\r
3905 if (vertex[0].sow > vertex[1].sow)\r
3906 UFlipped = 3;\r
3907 }\r
3908 else\r
3909 {\r
3910 if (vertex[0].sow < vertex[1].sow)\r
3911 UFlipped = 4;\r
3912 }\r
3913 }\r
3914 else\r
3915 if(lx0==lx3)\r
3916 {\r
3917 if(lx0<lx1) \r
3918 {\r
3919 if (vertex[0].sow > vertex[1].sow)\r
3920 UFlipped = 5;\r
3921 }\r
3922 else\r
3923 {\r
3924 if (vertex[0].sow < vertex[1].sow)\r
3925 UFlipped = 6;\r
3926 }\r
3927 }\r
3928\r
3929 if (UFlipped)\r
3930 {\r
3931#ifdef OWNSCALE\r
3932 if(bUsingTWin)\r
3933 {\r
3934 switch(UFlipped)\r
3935 {\r
3936 case 1:\r
3937 vertex[2].sow+=0.95f/TWin.UScaleFactor; \r
3938 vertex[3].sow+=0.95f/TWin.UScaleFactor;\r
3939 break;\r
3940 case 2:\r
3941 vertex[0].sow+=0.95f/TWin.UScaleFactor; \r
3942 vertex[1].sow+=0.95f/TWin.UScaleFactor;\r
3943 break;\r
3944 case 3:\r
3945 vertex[1].sow+=0.95f/TWin.UScaleFactor; \r
3946 vertex[3].sow+=0.95f/TWin.UScaleFactor;\r
3947 break;\r
3948 case 4:\r
3949 vertex[0].sow+=0.95f/TWin.UScaleFactor; \r
3950 vertex[2].sow+=0.95f/TWin.UScaleFactor;\r
3951 break;\r
3952 case 5:\r
3953 vertex[1].sow+=0.95f/TWin.UScaleFactor; \r
3954 vertex[2].sow+=0.95f/TWin.UScaleFactor;\r
3955 break;\r
3956 case 6:\r
3957 vertex[0].sow+=0.95f/TWin.UScaleFactor; \r
3958 vertex[3].sow+=0.95f/TWin.UScaleFactor;\r
3959 break;\r
3960 }\r
3961 }\r
3962 else\r
3963 {\r
3964 switch(UFlipped)\r
3965 {\r
3966 case 1:\r
3967 vertex[2].sow+=1.0f/ST_FAC; \r
3968 vertex[3].sow+=1.0f/ST_FAC;\r
3969 break;\r
3970 case 2:\r
3971 vertex[0].sow+=1.0f/ST_FAC; \r
3972 vertex[1].sow+=1.0f/ST_FAC;\r
3973 break;\r
3974 case 3:\r
3975 vertex[1].sow+=1.0f/ST_FAC; \r
3976 vertex[3].sow+=1.0f/ST_FAC;\r
3977 break;\r
3978 case 4:\r
3979 vertex[0].sow+=1.0f/ST_FAC; \r
3980 vertex[2].sow+=1.0f/ST_FAC;\r
3981 break;\r
3982 case 5:\r
3983 vertex[1].sow+=1.0f/ST_FAC; \r
3984 vertex[2].sow+=1.0f/ST_FAC;\r
3985 break;\r
3986 case 6:\r
3987 vertex[0].sow+=1.0f/ST_FAC; \r
3988 vertex[3].sow+=1.0f/ST_FAC;\r
3989 break;\r
3990 }\r
3991 }\r
3992#else\r
3993 if(bUsingTWin)\r
3994 {\r
3995 switch(UFlipped)\r
3996 {\r
3997 case 1:\r
3998 vertex[2].sow+=1.0f/TWin.UScaleFactor; \r
3999 vertex[3].sow+=1.0f/TWin.UScaleFactor;\r
4000 break;\r
4001 case 2:\r
4002 vertex[0].sow+=1.0f/TWin.UScaleFactor; \r
4003 vertex[1].sow+=1.0f/TWin.UScaleFactor;\r
4004 break;\r
4005 case 3:\r
4006 vertex[1].sow+=1.0f/TWin.UScaleFactor; \r
4007 vertex[3].sow+=1.0f/TWin.UScaleFactor;\r
4008 break;\r
4009 case 4:\r
4010 vertex[0].sow+=1.0f/TWin.UScaleFactor; \r
4011 vertex[2].sow+=1.0f/TWin.UScaleFactor;\r
4012 break;\r
4013 case 5:\r
4014 vertex[1].sow+=1.0f/TWin.UScaleFactor; \r
4015 vertex[2].sow+=1.0f/TWin.UScaleFactor;\r
4016 break;\r
4017 case 6:\r
4018 vertex[0].sow+=1.0f/TWin.UScaleFactor; \r
4019 vertex[3].sow+=1.0f/TWin.UScaleFactor;\r
4020 break;\r
4021 }\r
4022 }\r
4023 else\r
4024 {\r
4025 switch(UFlipped)\r
4026 {\r
4027 case 1:\r
4028 vertex[2].sow+=1.0f; \r
4029 vertex[3].sow+=1.0f;\r
4030 break;\r
4031 case 2:\r
4032 vertex[0].sow+=1.0f; \r
4033 vertex[1].sow+=1.0f;\r
4034 break;\r
4035 case 3:\r
4036 vertex[1].sow+=1.0f; \r
4037 vertex[3].sow+=1.0f;\r
4038 break;\r
4039 case 4:\r
4040 vertex[0].sow+=1.0f; \r
4041 vertex[2].sow+=1.0f;\r
4042 break;\r
4043 case 5:\r
4044 vertex[1].sow+=1.0f; \r
4045 vertex[2].sow+=1.0f;\r
4046 break;\r
4047 case 6:\r
4048 vertex[0].sow+=1.0f; \r
4049 vertex[3].sow+=1.0f;\r
4050 break;\r
4051 }\r
4052 }\r
4053#endif\r
4054 }\r
4055\r
4056 if (VFlipped)\r
4057 {\r
4058#ifdef OWNSCALE\r
4059 if(bUsingTWin)\r
4060 {\r
4061 switch(VFlipped)\r
4062 {\r
4063 case 1:\r
4064 vertex[2].tow+=0.95f/TWin.VScaleFactor; \r
4065 vertex[3].tow+=0.95f/TWin.VScaleFactor;\r
4066 break;\r
4067 case 2:\r
4068 vertex[0].tow+=0.95f/TWin.VScaleFactor; \r
4069 vertex[1].tow+=0.95f/TWin.VScaleFactor;\r
4070 break;\r
4071 case 3:\r
4072 vertex[1].tow+=0.95f/TWin.VScaleFactor; \r
4073 vertex[3].tow+=0.95f/TWin.VScaleFactor;\r
4074 break;\r
4075 case 4:\r
4076 vertex[0].tow+=0.95f/TWin.VScaleFactor; \r
4077 vertex[2].tow+=0.95f/TWin.VScaleFactor;\r
4078 break;\r
4079 case 5:\r
4080 vertex[1].tow+=0.95f/TWin.VScaleFactor; \r
4081 vertex[2].tow+=0.95f/TWin.VScaleFactor;\r
4082 break;\r
4083 case 6:\r
4084 vertex[0].tow+=0.95f/TWin.VScaleFactor; \r
4085 vertex[3].tow+=0.95f/TWin.VScaleFactor;\r
4086 break;\r
4087 }\r
4088 }\r
4089 else\r
4090 {\r
4091 switch(VFlipped)\r
4092 {\r
4093 case 1:\r
4094 vertex[2].tow+=1.0f/ST_FAC; \r
4095 vertex[3].tow+=1.0f/ST_FAC;\r
4096 break;\r
4097 case 2:\r
4098 vertex[0].tow+=1.0f/ST_FAC; \r
4099 vertex[1].tow+=1.0f/ST_FAC;\r
4100 break;\r
4101 case 3:\r
4102 vertex[1].tow+=1.0f/ST_FAC;\r
4103 vertex[3].tow+=1.0f/ST_FAC;\r
4104 break;\r
4105 case 4:\r
4106 vertex[0].tow+=1.0f/ST_FAC; \r
4107 vertex[2].tow+=1.0f/ST_FAC;\r
4108 break;\r
4109 case 5:\r
4110 vertex[1].tow+=1.0f/ST_FAC;\r
4111 vertex[2].tow+=1.0f/ST_FAC;\r
4112 break;\r
4113 case 6:\r
4114 vertex[0].tow+=1.0f/ST_FAC;\r
4115 vertex[3].tow+=1.0f/ST_FAC;\r
4116 break;\r
4117 }\r
4118 }\r
4119#else\r
4120 if(bUsingTWin)\r
4121 {\r
4122 switch(VFlipped)\r
4123 {\r
4124 case 1:\r
4125 vertex[2].tow+=1.0f/TWin.VScaleFactor; \r
4126 vertex[3].tow+=1.0f/TWin.VScaleFactor;\r
4127 break;\r
4128 case 2:\r
4129 vertex[0].tow+=1.0f/TWin.VScaleFactor; \r
4130 vertex[1].tow+=1.0f/TWin.VScaleFactor;\r
4131 break;\r
4132 case 3:\r
4133 vertex[1].tow+=1.0f/TWin.VScaleFactor; \r
4134 vertex[3].tow+=1.0f/TWin.VScaleFactor;\r
4135 break;\r
4136 case 4:\r
4137 vertex[0].tow+=1.0f/TWin.VScaleFactor; \r
4138 vertex[2].tow+=1.0f/TWin.VScaleFactor;\r
4139 break;\r
4140 case 5:\r
4141 vertex[1].tow+=1.0f/TWin.VScaleFactor; \r
4142 vertex[2].tow+=1.0f/TWin.VScaleFactor;\r
4143 break;\r
4144 case 6:\r
4145 vertex[0].tow+=1.0f/TWin.VScaleFactor; \r
4146 vertex[3].tow+=1.0f/TWin.VScaleFactor;\r
4147 break;\r
4148 }\r
4149 }\r
4150 else\r
4151 {\r
4152 switch(VFlipped)\r
4153 {\r
4154 case 1:\r
4155 vertex[2].tow+=1.0f; \r
4156 vertex[3].tow+=1.0f;\r
4157 break;\r
4158 case 2:\r
4159 vertex[0].tow+=1.0f; \r
4160 vertex[1].tow+=1.0f;\r
4161 break;\r
4162 case 3:\r
4163 vertex[1].tow+=1.0f; \r
4164 vertex[3].tow+=1.0f;\r
4165 break;\r
4166 case 4:\r
4167 vertex[0].tow+=1.0f; \r
4168 vertex[2].tow+=1.0f;\r
4169 break;\r
4170 case 5:\r
4171 vertex[1].tow+=1.0f; \r
4172 vertex[2].tow+=1.0f;\r
4173 break;\r
4174 case 6:\r
4175 vertex[0].tow+=1.0f; \r
4176 vertex[3].tow+=1.0f;\r
4177 break;\r
4178 }\r
4179 }\r
4180#endif\r
4181 }\r
4182\r
4183}\r
4184\r
677ea103 4185void primPolyFT4(unsigned char * baseAddr)\r
ce879073 4186{\r
4187 unsigned long *gpuData = ((unsigned long *) baseAddr);\r
4188 short *sgpuData = ((short *) baseAddr);\r
4189\r
4190 lx0 = sgpuData[2];\r
4191 ly0 = sgpuData[3];\r
4192 lx1 = sgpuData[6];\r
4193 ly1 = sgpuData[7];\r
4194 lx2 = sgpuData[10];\r
4195 ly2 = sgpuData[11];\r
4196 lx3 = sgpuData[14];\r
4197 ly3 = sgpuData[15];\r
4198\r
4199 if(offset4()) return;\r
4200\r
4201 gl_vy[0]=baseAddr[9];//((gpuData[2]>>8)&0xff);\r
4202 gl_vy[1]=baseAddr[17];//((gpuData[4]>>8)&0xff);\r
4203 gl_vy[2]=baseAddr[25];//((gpuData[6]>>8)&0xff);\r
4204 gl_vy[3]=baseAddr[33];//((gpuData[8]>>8)&0xff);\r
4205 \r
4206 gl_ux[0]=baseAddr[8];//(gpuData[2]&0xff);\r
4207 gl_ux[1]=baseAddr[16];//(gpuData[4]&0xff);\r
4208 gl_ux[2]=baseAddr[24];//(gpuData[6]&0xff);\r
4209 gl_ux[3]=baseAddr[32];//(gpuData[8]&0xff);\r
4210\r
4211 UpdateGlobalTP((unsigned short)(gpuData[4]>>16));\r
4212 ulClutID=(gpuData[2]>>16);\r
4213\r
4214 bDrawTextured = TRUE;\r
4215 bDrawSmoothShaded = FALSE;\r
4216 SetRenderState(gpuData[0]);\r
4217\r
4218/* if(iOffscreenDrawing)\r
4219 {\r
4220 offsetPSX4();\r
4221 if(bDrawOffscreen4())\r
4222 {\r
4223 InvalidateTextureAreaEx(); \r
4224 SetRenderColor(gpuData[0]);\r
4225 drawPoly4FT(baseAddr);\r
4226 }\r
4227 }\r
4228*/\r
4229 SetRenderMode(gpuData[0], TRUE);\r
4230\r
4231 SetZMask4();\r
4232\r
4233 assignTexture4();\r
4234\r
4235 RectTexAlign();\r
4236\r
4237 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[3], &vertex[2]);\r
4238\r
4239 if(bDrawMultiPass)\r
4240 {\r
4241 SetSemiTransMulti(1);\r
4242 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[3], &vertex[2]);\r
4243 }\r
4244\r
4245 if(ubOpaqueDraw)\r
4246 {\r
4247 SetZMask4O();\r
4248 if(bUseMultiPass) SetOpaqueColor(gpuData[0]);\r
4249 DEFOPAQUEON\r
4250\r
4251/* if(bSmallAlpha && iFilterType<=2)\r
4252 {\r
4253 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);\r
4254 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);\r
4255 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[3], &vertex[2]);\r
4256 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);\r
4257 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);\r
4258 SetZMask4O();\r
4259 }\r
4260*/\r
4261 \r
4262 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[3], &vertex[2]);\r
4263 DEFOPAQUEOFF\r
4264 }\r
4265\r
4266 iDrawnSomething=1;\r
4267}\r
4268\r
4269////////////////////////////////////////////////////////////////////////\r
4270// cmd: smooth shaded Texture3\r
4271////////////////////////////////////////////////////////////////////////\r
4272\r
677ea103 4273void primPolyGT3(unsigned char *baseAddr)\r
ce879073 4274{ \r
4275 unsigned long *gpuData = ((unsigned long *) baseAddr);\r
4276 short *sgpuData = ((short *) baseAddr);\r
4277\r
4278 lx0 = sgpuData[2];\r
4279 ly0 = sgpuData[3];\r
4280 lx1 = sgpuData[8];\r
4281 ly1 = sgpuData[9];\r
4282 lx2 = sgpuData[14];\r
4283 ly2 = sgpuData[15];\r
4284\r
4285 if(offset3()) return;\r
4286\r
4287 // do texture stuff\r
4288 gl_ux[0]=gl_ux[3]=baseAddr[8];//gpuData[2]&0xff;\r
4289 gl_vy[0]=gl_vy[3]=baseAddr[9];//(gpuData[2]>>8)&0xff;\r
4290 gl_ux[1]=baseAddr[20];//gpuData[5]&0xff;\r
4291 gl_vy[1]=baseAddr[21];//(gpuData[5]>>8)&0xff;\r
4292 gl_ux[2]=baseAddr[32];//gpuData[8]&0xff;\r
4293 gl_vy[2]=baseAddr[33];//(gpuData[8]>>8)&0xff;\r
4294\r
4295 UpdateGlobalTP((unsigned short)(gpuData[5]>>16));\r
4296 ulClutID=(gpuData[2]>>16);\r
4297 \r
4298 bDrawTextured = TRUE;\r
4299 bDrawSmoothShaded = TRUE;\r
4300 SetRenderState(gpuData[0]);\r
4301\r
4302/* if(iOffscreenDrawing)\r
4303 {\r
4304 offsetPSX3();\r
4305 if(bDrawOffscreen3())\r
4306 {\r
4307 InvalidateTextureAreaEx(); \r
4308 drawPoly3GT(baseAddr);\r
4309 }\r
4310 }\r
4311*/\r
4312 SetRenderMode(gpuData[0], FALSE);\r
4313 SetZMask3();\r
4314\r
4315 assignTexture3();\r
4316\r
4317 if(bDrawNonShaded)\r
4318 {\r
4319 //if(!bUseMultiPass) vertex[0].lcol=DoubleBGR2RGB(gpuData[0]); else vertex[0].lcol=gpuData[0];\r
4320 // eat this...\r
4321/* if(bGLBlend) vertex[0].c.lcol=0x7f7f7f;\r
4322 else */vertex[0].c.lcol=0xffffff;\r
4323 vertex[0].c.col[3]=ubGloAlpha;\r
4324 SETCOL(vertex[0]); \r
4325\r
4326 PRIMdrawTexturedTri(&vertex[0], &vertex[1], &vertex[2]);\r
4327\r
4328 if(ubOpaqueDraw)\r
4329 {\r
4330 SetZMask3O();\r
4331 DEFOPAQUEON\r
4332 PRIMdrawTexturedTri(&vertex[0], &vertex[1], &vertex[2]);\r
4333 DEFOPAQUEOFF\r
4334 }\r
4335 return; \r
4336 }\r
4337\r
4338/* if(!bUseMultiPass && !bGLBlend)\r
4339 {\r
4340 */ vertex[0].c.lcol=DoubleBGR2RGB(gpuData[0]); \r
4341 vertex[1].c.lcol=DoubleBGR2RGB(gpuData[3]); \r
4342 vertex[2].c.lcol=DoubleBGR2RGB(gpuData[6]);\r
4343 /*}\r
4344 else\r
4345 {\r
4346 vertex[0].c.lcol=gpuData[0];\r
4347 vertex[1].c.lcol=gpuData[3];\r
4348 vertex[2].c.lcol=gpuData[6];\r
4349 }*/\r
4350 vertex[0].c.col[3]=vertex[1].c.col[3]=vertex[2].c.col[3]=ubGloAlpha;\r
4351\r
4352 PRIMdrawTexGouraudTriColor(&vertex[0], &vertex[1], &vertex[2]);\r
4353\r
4354 if(bDrawMultiPass)\r
4355 {\r
4356 SetSemiTransMulti(1);\r
4357 PRIMdrawTexGouraudTriColor(&vertex[0], &vertex[1], &vertex[2]);\r
4358 }\r
4359\r
4360 if(ubOpaqueDraw)\r
4361 {\r
4362 SetZMask3O();\r
4363 if(bUseMultiPass) \r
4364 {\r
4365 vertex[0].c.lcol=DoubleBGR2RGB(gpuData[0]);\r
4366 vertex[1].c.lcol=DoubleBGR2RGB(gpuData[3]);\r
4367 vertex[2].c.lcol=DoubleBGR2RGB(gpuData[6]);\r
4368 vertex[0].c.col[3]=vertex[1].c.col[3]=vertex[2].c.col[3]=ubGloAlpha;\r
4369 }\r
4370 DEFOPAQUEON\r
4371 PRIMdrawTexGouraudTriColor(&vertex[0], &vertex[1], &vertex[2]);\r
4372 DEFOPAQUEOFF\r
4373 }\r
4374\r
4375 iDrawnSomething=1;\r
4376}\r
4377\r
4378////////////////////////////////////////////////////////////////////////\r
4379// cmd: smooth shaded Poly3\r
4380////////////////////////////////////////////////////////////////////////\r
4381\r
677ea103 4382void primPolyG3(unsigned char *baseAddr)\r
ce879073 4383{ \r
4384 unsigned long *gpuData = ((unsigned long *) baseAddr);\r
4385 short *sgpuData = ((short *) baseAddr);\r
4386\r
4387 lx0 = sgpuData[2];\r
4388 ly0 = sgpuData[3];\r
4389 lx1 = sgpuData[6];\r
4390 ly1 = sgpuData[7];\r
4391 lx2 = sgpuData[10];\r
4392 ly2 = sgpuData[11];\r
4393\r
4394 if(offset3()) return;\r
4395\r
4396 bDrawTextured = FALSE;\r
4397 bDrawSmoothShaded = TRUE;\r
4398 SetRenderState(gpuData[0]);\r
4399\r
4400/* if(iOffscreenDrawing) \r
4401 {\r
4402 offsetPSX3();\r
4403 if(bDrawOffscreen3())\r
4404 {\r
4405 InvalidateTextureAreaEx(); \r
4406 drawPoly3G(gpuData[0], gpuData[2], gpuData[4]);\r
4407 }\r
4408 }\r
4409*/\r
4410 SetRenderMode(gpuData[0], FALSE);\r
4411 SetZMask3NT();\r
4412\r
4413 vertex[0].c.lcol=gpuData[0];\r
4414 vertex[1].c.lcol=gpuData[2];\r
4415 vertex[2].c.lcol=gpuData[4];\r
4416 vertex[0].c.col[3]=vertex[1].c.col[3]=vertex[2].c.col[3]=ubGloColAlpha; \r
4417\r
4418 PRIMdrawGouraudTriColor(&vertex[0], &vertex[1], &vertex[2]);\r
4419\r
4420 iDrawnSomething=1;\r
4421}\r
4422\r
4423////////////////////////////////////////////////////////////////////////\r
4424// cmd: smooth shaded Texture4\r
4425////////////////////////////////////////////////////////////////////////\r
4426\r
677ea103 4427void primPolyGT4(unsigned char *baseAddr)\r
ce879073 4428{ \r
4429 unsigned long *gpuData = ((unsigned long *) baseAddr);\r
4430 short *sgpuData = ((short *) baseAddr);\r
4431\r
4432 lx0 = sgpuData[2];\r
4433 ly0 = sgpuData[3];\r
4434 lx1 = sgpuData[8];\r
4435 ly1 = sgpuData[9];\r
4436 lx2 = sgpuData[14];\r
4437 ly2 = sgpuData[15];\r
4438 lx3 = sgpuData[20];\r
4439 ly3 = sgpuData[21];\r
4440\r
4441 if(offset4()) return;\r
4442\r
4443 // do texture stuff\r
4444 gl_ux[0]=baseAddr[8];//gpuData[2]&0xff;\r
4445 gl_vy[0]=baseAddr[9];//(gpuData[2]>>8)&0xff;\r
4446 gl_ux[1]=baseAddr[20];//gpuData[5]&0xff;\r
4447 gl_vy[1]=baseAddr[21];//(gpuData[5]>>8)&0xff;\r
4448 gl_ux[2]=baseAddr[32];//gpuData[8]&0xff;\r
4449 gl_vy[2]=baseAddr[33];//(gpuData[8]>>8)&0xff;\r
4450 gl_ux[3]=baseAddr[44];//gpuData[11]&0xff;\r
4451 gl_vy[3]=baseAddr[45];//(gpuData[11]>>8)&0xff;\r
4452\r
4453 UpdateGlobalTP((unsigned short)(gpuData[5]>>16));\r
4454 ulClutID=(gpuData[2]>>16);\r
4455\r
4456 bDrawTextured = TRUE;\r
4457 bDrawSmoothShaded = TRUE;\r
4458 SetRenderState(gpuData[0]);\r
4459\r
4460/* if(iOffscreenDrawing)\r
4461 {\r
4462 offsetPSX4();\r
4463 if(bDrawOffscreen4())\r
4464 {\r
4465 InvalidateTextureAreaEx(); \r
4466 drawPoly4GT(baseAddr);\r
4467 } \r
4468 }\r
4469*/\r
4470 SetRenderMode(gpuData[0], FALSE);\r
4471 SetZMask4();\r
4472\r
4473 assignTexture4();\r
4474\r
4475 RectTexAlign();\r
4476\r
4477 if(bDrawNonShaded)\r
4478 {\r
4479 //if(!bUseMultiPass) vertex[0].lcol=DoubleBGR2RGB(gpuData[0]); else vertex[0].lcol=gpuData[0];\r
4480/* if(bGLBlend) vertex[0].c.lcol=0x7f7f7f;\r
4481 else */vertex[0].c.lcol=0xffffff;\r
4482 vertex[0].c.col[3]=ubGloAlpha;\r
4483 SETCOL(vertex[0]); \r
4484\r
4485 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[3], &vertex[2]);\r
4486 \r
4487 if(ubOpaqueDraw)\r
4488 {\r
4489 SetZMask4O();\r
4490 ubGloAlpha=ubGloColAlpha=0xff; \r
4491 DEFOPAQUEON\r
4492 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[3], &vertex[2]);\r
4493 DEFOPAQUEOFF\r
4494 }\r
4495 return;\r
4496 }\r
4497\r
4498// if(!bUseMultiPass && !bGLBlend) \r
4499 {\r
4500 vertex[0].c.lcol=DoubleBGR2RGB(gpuData[0]);\r
4501 vertex[1].c.lcol=DoubleBGR2RGB(gpuData[3]);\r
4502 vertex[2].c.lcol=DoubleBGR2RGB(gpuData[6]);\r
4503 vertex[3].c.lcol=DoubleBGR2RGB(gpuData[9]);\r
4504 }\r
4505 /*else\r
4506 {\r
4507 vertex[0].c.lcol=gpuData[0];\r
4508 vertex[1].c.lcol=gpuData[3];\r
4509 vertex[2].c.lcol=gpuData[6];\r
4510 vertex[3].c.lcol=gpuData[9];\r
4511 }*/\r
4512\r
4513 vertex[0].c.col[3]=vertex[1].c.col[3]=vertex[2].c.col[3]=vertex[3].c.col[3]=ubGloAlpha; \r
4514\r
4515 PRIMdrawTexGouraudTriColorQuad(&vertex[0], &vertex[1], &vertex[3],&vertex[2]);\r
4516 \r
4517 if(bDrawMultiPass)\r
4518 {\r
4519 SetSemiTransMulti(1);\r
4520 PRIMdrawTexGouraudTriColorQuad(&vertex[0], &vertex[1], &vertex[3],&vertex[2]);\r
4521 }\r
4522\r
4523 if(ubOpaqueDraw)\r
4524 {\r
4525 SetZMask4O();\r
4526 if(bUseMultiPass) \r
4527 {\r
4528 vertex[0].c.lcol=DoubleBGR2RGB(gpuData[0]);\r
4529 vertex[1].c.lcol=DoubleBGR2RGB(gpuData[3]);\r
4530 vertex[2].c.lcol=DoubleBGR2RGB(gpuData[6]);\r
4531 vertex[3].c.lcol=DoubleBGR2RGB(gpuData[9]);\r
4532 vertex[0].c.col[3]=vertex[1].c.col[3]=vertex[2].c.col[3]=vertex[3].c.col[3]=ubGloAlpha; \r
4533 }\r
4534 ubGloAlpha=ubGloColAlpha=0xff; \r
4535 DEFOPAQUEON\r
4536 PRIMdrawTexGouraudTriColorQuad(&vertex[0], &vertex[1], &vertex[3],&vertex[2]);\r
4537 DEFOPAQUEOFF\r
4538 }\r
4539\r
4540 iDrawnSomething=1;\r
4541}\r
4542\r
4543////////////////////////////////////////////////////////////////////////\r
4544// cmd: smooth shaded Poly3\r
4545////////////////////////////////////////////////////////////////////////\r
4546\r
677ea103 4547void primPolyF3(unsigned char *baseAddr)\r
ce879073 4548{ \r
4549 unsigned long *gpuData = ((unsigned long *) baseAddr);\r
4550 short *sgpuData = ((short *) baseAddr);\r
4551\r
4552 lx0 = sgpuData[2];\r
4553 ly0 = sgpuData[3];\r
4554 lx1 = sgpuData[4];\r
4555 ly1 = sgpuData[5];\r
4556 lx2 = sgpuData[6];\r
4557 ly2 = sgpuData[7];\r
4558\r
4559 if(offset3()) return;\r
4560\r
4561 bDrawTextured = FALSE;\r
4562 bDrawSmoothShaded = FALSE;\r
4563 SetRenderState(gpuData[0]);\r
4564\r
4565/* if(iOffscreenDrawing)\r
4566 {\r
4567 offsetPSX3();\r
4568 if(bDrawOffscreen3())\r
4569 {\r
4570 InvalidateTextureAreaEx(); \r
4571 drawPoly3F(gpuData[0]);\r
4572 }\r
4573 }\r
4574*/\r
4575 SetRenderMode(gpuData[0], FALSE);\r
4576 SetZMask3NT();\r
4577\r
4578 vertex[0].c.lcol=gpuData[0];\r
4579 vertex[0].c.col[3]=ubGloColAlpha;\r
4580 SETCOL(vertex[0]); \r
4581\r
4582 PRIMdrawTri(&vertex[0], &vertex[1], &vertex[2]);\r
4583\r
4584 iDrawnSomething=1;\r
4585}\r
4586\r
4587////////////////////////////////////////////////////////////////////////\r
4588// cmd: skipping shaded polylines\r
4589////////////////////////////////////////////////////////////////////////\r
4590\r
677ea103 4591void primLineGSkip(unsigned char *baseAddr)\r
ce879073 4592{ \r
4593 unsigned long *gpuData = ((unsigned long *) baseAddr);\r
4594 short *sgpuData = ((short *) baseAddr);\r
4595 int iMax=255;\r
4596 int i=2;\r
4597\r
4598 lx1 = sgpuData[2];\r
4599 ly1 = sgpuData[3];\r
4600\r
4601 while(!(((gpuData[i] & 0xF000F000) == 0x50005000) && i>=4))\r
4602 {\r
4603 i++;\r
4604\r
4605 ly1 = (short)((gpuData[i]>>16) & 0xffff);\r
4606 lx1 = (short)(gpuData[i] & 0xffff);\r
4607\r
4608 i++;if(i>iMax) break;\r
4609 }\r
4610}\r
4611\r
4612////////////////////////////////////////////////////////////////////////\r
4613// cmd: shaded polylines\r
4614////////////////////////////////////////////////////////////////////////\r
4615\r
677ea103 4616void primLineGEx(unsigned char *baseAddr)\r
ce879073 4617{ \r
4618 unsigned long *gpuData = ((unsigned long *) baseAddr);\r
4619 int iMax=255;\r
4620 short cx0,cx1,cy0,cy1;int i;BOOL bDraw=TRUE;\r
4621\r
4622 bDrawTextured = FALSE;\r
4623 bDrawSmoothShaded = TRUE;\r
4624 SetRenderState(gpuData[0]);\r
4625 SetRenderMode(gpuData[0], FALSE);\r
4626 SetZMask4NT();\r
4627\r
4628 vertex[0].c.lcol=vertex[3].c.lcol=gpuData[0];\r
4629 vertex[0].c.col[3]=vertex[3].c.col[3]=ubGloColAlpha; \r
4630 ly1 = (short)((gpuData[1]>>16) & 0xffff);\r
4631 lx1 = (short)(gpuData[1] & 0xffff);\r
4632\r
4633 i=2;\r
4634\r
4635 //while((gpuData[i]>>24)!=0x55)\r
4636 //while((gpuData[i]&0x50000000)!=0x50000000) \r
4637 // currently best way to check for poly line end:\r
4638 while(!(((gpuData[i] & 0xF000F000) == 0x50005000) && i>=4))\r
4639 {\r
4640 ly0 = ly1;lx0=lx1;\r
4641 vertex[1].c.lcol=vertex[2].c.lcol=vertex[0].c.lcol;\r
4642 vertex[0].c.lcol=vertex[3].c.lcol=gpuData[i];\r
4643 vertex[0].c.col[3]=vertex[3].c.col[3]=ubGloColAlpha; \r
4644\r
4645 i++;\r
4646\r
4647 ly1 = (short)((gpuData[i]>>16) & 0xffff);\r
4648 lx1 = (short)(gpuData[i] & 0xffff);\r
4649\r
4650 if(offsetline()) bDraw=FALSE; else bDraw=TRUE;\r
4651 \r
4652 if (bDraw && ((lx0 != lx1) || (ly0 != ly1)))\r
4653 {\r
4654/* if(iOffscreenDrawing)\r
4655 {\r
4656 cx0=lx0;cx1=lx1;cy0=ly0;cy1=ly1;\r
4657 offsetPSXLine();\r
4658 if(bDrawOffscreen4())\r
4659 {\r
4660 InvalidateTextureAreaEx(); \r
4661 drawPoly4G(gpuData[i-3],gpuData[i-1],gpuData[i-3],gpuData[i-1]);\r
4662 }\r
4663 lx0=cx0;lx1=cx1;ly0=cy0;ly1=cy1;\r
4664 }*/\r
4665\r
4666 PRIMdrawGouraudLine(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r
4667 }\r
4668 i++; \r
4669\r
4670 if(i>iMax) break;\r
4671 }\r
4672\r
4673 iDrawnSomething=1;\r
4674}\r
4675\r
4676////////////////////////////////////////////////////////////////////////\r
4677// cmd: shaded polyline2\r
4678////////////////////////////////////////////////////////////////////////\r
4679\r
677ea103 4680void primLineG2(unsigned char *baseAddr)\r
ce879073 4681{ \r
4682 unsigned long *gpuData = ((unsigned long *) baseAddr);\r
4683 short *sgpuData = ((short *) baseAddr);\r
4684\r
4685 lx0 = sgpuData[2];\r
4686 ly0 = sgpuData[3];\r
4687 lx1 = sgpuData[6];\r
4688 ly1 = sgpuData[7];\r
4689\r
4690 vertex[0].c.lcol=vertex[3].c.lcol=gpuData[0];\r
4691 vertex[1].c.lcol=vertex[2].c.lcol=gpuData[2];\r
4692 vertex[0].c.col[3]=vertex[1].c.col[3]=vertex[2].c.col[3]=vertex[3].c.col[3]=ubGloColAlpha; \r
4693\r
4694 bDrawTextured = FALSE;\r
4695 bDrawSmoothShaded = TRUE;\r
4696\r
4697 if((lx0 == lx1) && (ly0 == ly1)) return;\r
4698 \r
4699 if(offsetline()) return;\r
4700 \r
4701 SetRenderState(gpuData[0]);\r
4702 SetRenderMode(gpuData[0], FALSE);\r
4703 SetZMask4NT();\r
4704\r
4705/* if(iOffscreenDrawing)\r
4706 {\r
4707 offsetPSXLine();\r
4708 if(bDrawOffscreen4())\r
4709 {\r
4710 InvalidateTextureAreaEx(); \r
4711 drawPoly4G(gpuData[0],gpuData[2],gpuData[0],gpuData[2]);\r
4712 }\r
4713 }\r
4714*/\r
4715 //if(ClipVertexList4())\r
4716 PRIMdrawGouraudLine(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r
4717\r
4718 iDrawnSomething=1;\r
4719}\r
4720\r
4721////////////////////////////////////////////////////////////////////////\r
4722// cmd: skipping flat polylines\r
4723////////////////////////////////////////////////////////////////////////\r
4724\r
677ea103 4725void primLineFSkip(unsigned char *baseAddr)\r
ce879073 4726{\r
4727 unsigned long *gpuData = ((unsigned long *) baseAddr);\r
4728 int i=2,iMax=255;\r
4729\r
4730 ly1 = (short)((gpuData[1]>>16) & 0xffff);\r
4731 lx1 = (short)(gpuData[1] & 0xffff);\r
4732\r
4733 while(!(((gpuData[i] & 0xF000F000) == 0x50005000) && i>=3))\r
4734 {\r
4735 ly1 = (short)((gpuData[i]>>16) & 0xffff);\r
4736 lx1 = (short)(gpuData[i] & 0xffff);\r
4737 i++;if(i>iMax) break;\r
4738 } \r
4739}\r
4740\r
4741////////////////////////////////////////////////////////////////////////\r
4742// cmd: drawing flat polylines\r
4743////////////////////////////////////////////////////////////////////////\r
4744\r
677ea103 4745void primLineFEx(unsigned char *baseAddr)\r
ce879073 4746{\r
4747 unsigned long *gpuData = ((unsigned long *) baseAddr);\r
4748 int iMax;\r
4749 short cx0,cx1,cy0,cy1;int i;\r
4750\r
4751 iMax=255;\r
4752\r
4753 bDrawTextured = FALSE;\r
4754 bDrawSmoothShaded = FALSE;\r
4755 SetRenderState(gpuData[0]);\r
4756 SetRenderMode(gpuData[0], FALSE);\r
4757 SetZMask4NT();\r
4758\r
4759 vertex[0].c.lcol=gpuData[0];\r
4760 vertex[0].c.col[3]=ubGloColAlpha; \r
4761\r
4762 ly1 = (short)((gpuData[1]>>16) & 0xffff);\r
4763 lx1 = (short)(gpuData[1] & 0xffff);\r
4764\r
4765 i=2;\r
4766\r
4767// while(!(gpuData[i]&0x40000000)) \r
4768// while((gpuData[i]>>24)!=0x55)\r
4769// while((gpuData[i]&0x50000000)!=0x50000000) \r
4770// currently best way to check for poly line end:\r
4771 while(!(((gpuData[i] & 0xF000F000) == 0x50005000) && i>=3))\r
4772 {\r
4773 ly0 = ly1;lx0=lx1;\r
4774 ly1 = (short)((gpuData[i]>>16) & 0xffff);\r
4775 lx1 = (short)(gpuData[i] & 0xffff);\r
4776\r
4777 if(!offsetline())\r
4778 {\r
4779/* if(iOffscreenDrawing)\r
4780 {\r
4781 cx0=lx0;cx1=lx1;cy0=ly0;cy1=ly1;\r
4782 offsetPSXLine();\r
4783 if(bDrawOffscreen4())\r
4784 {\r
4785 InvalidateTextureAreaEx(); \r
4786 drawPoly4F(gpuData[0]);\r
4787 }\r
4788 lx0=cx0;lx1=cx1;ly0=cy0;ly1=cy1;\r
4789 }*/\r
4790 PRIMdrawFlatLine(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r
4791 }\r
4792 \r
4793 i++;if(i>iMax) break;\r
4794 }\r
4795\r
4796 iDrawnSomething=1;\r
4797}\r
4798\r
4799////////////////////////////////////////////////////////////////////////\r
4800// cmd: drawing flat polyline2\r
4801////////////////////////////////////////////////////////////////////////\r
4802\r
677ea103 4803void primLineF2(unsigned char *baseAddr)\r
ce879073 4804{\r
4805 unsigned long *gpuData = ((unsigned long *) baseAddr);\r
4806 short *sgpuData = ((short *) baseAddr);\r
4807\r
4808 lx0 = sgpuData[2];\r
4809 ly0 = sgpuData[3];\r
4810 lx1 = sgpuData[4];\r
4811 ly1 = sgpuData[5];\r
4812\r
4813 if(offsetline()) return;\r
4814\r
4815 bDrawTextured = FALSE;\r
4816 bDrawSmoothShaded = FALSE;\r
4817 SetRenderState(gpuData[0]);\r
4818 SetRenderMode(gpuData[0], FALSE);\r
4819 SetZMask4NT();\r
4820\r
4821 vertex[0].c.lcol=gpuData[0];\r
4822 vertex[0].c.col[3]=ubGloColAlpha; \r
4823\r
4824/* if(iOffscreenDrawing)\r
4825 {\r
4826 offsetPSXLine();\r
4827 if(bDrawOffscreen4())\r
4828 {\r
4829 InvalidateTextureAreaEx(); \r
4830 drawPoly4F(gpuData[0]);\r
4831 }\r
4832 }\r
4833*/\r
4834 //if(ClipVertexList4()) \r
4835 PRIMdrawFlatLine(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r
4836\r
4837 iDrawnSomething=1;\r
4838}\r
4839\r
4840////////////////////////////////////////////////////////////////////////\r
4841// cmd: well, easiest command... not implemented\r
4842////////////////////////////////////////////////////////////////////////\r
4843\r
677ea103 4844void primNI(unsigned char *bA)\r
ce879073 4845{\r
4846}\r
4847\r
4848////////////////////////////////////////////////////////////////////////\r
4849// cmd func ptr table\r
4850////////////////////////////////////////////////////////////////////////\r
4851\r
677ea103 4852void (*primTableJ[256])(unsigned char *) = \r
ce879073 4853{\r
4854 // 00\r
4855 primNI,primNI,primBlkFill,primNI,primNI,primNI,primNI,primNI,\r
4856 // 08\r
4857 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r
4858 // 10\r
4859 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r
4860 // 18\r
4861 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r
4862 // 20\r
4863 primPolyF3,primPolyF3,primPolyF3,primPolyF3,primPolyFT3,primPolyFT3,primPolyFT3,primPolyFT3,\r
4864 // 28\r
4865 primPolyF4,primPolyF4,primPolyF4,primPolyF4,primPolyFT4,primPolyFT4,primPolyFT4,primPolyFT4,\r
4866 // 30\r
4867 primPolyG3,primPolyG3,primPolyG3,primPolyG3,primPolyGT3,primPolyGT3,primPolyGT3,primPolyGT3,\r
4868 // 38\r
4869 primPolyG4,primPolyG4,primPolyG4,primPolyG4,primPolyGT4,primPolyGT4,primPolyGT4,primPolyGT4,\r
4870 // 40\r
4871 primLineF2,primLineF2,primLineF2,primLineF2,primNI,primNI,primNI,primNI,\r
4872 // 48\r
4873 primLineFEx,primLineFEx,primLineFEx,primLineFEx,primLineFEx,primLineFEx,primLineFEx,primLineFEx,\r
4874 // 50\r
4875 primLineG2,primLineG2,primLineG2,primLineG2,primNI,primNI,primNI,primNI,\r
4876 // 58\r
4877 primLineGEx,primLineGEx,primLineGEx,primLineGEx,primLineGEx,primLineGEx,primLineGEx,primLineGEx,\r
4878 // 60\r
4879 primTileS,primTileS,primTileS,primTileS,primSprtS,primSprtS,primSprtS,primSprtS,\r
4880 // 68\r
4881 primTile1,primTile1,primTile1,primTile1,primNI,primNI,primNI,primNI,\r
4882 // 70\r
4883 primTile8,primTile8,primTile8,primTile8,primSprt8,primSprt8,primSprt8,primSprt8,\r
4884 // 78\r
4885 primTile16,primTile16,primTile16,primTile16,primSprt16,primSprt16,primSprt16,primSprt16,\r
4886 // 80\r
4887 primMoveImage,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r
4888 // 88\r
4889 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r
4890 // 90\r
4891 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r
4892 // 98\r
4893 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r
4894 // a0\r
4895 primLoadImage,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r
4896 // a8\r
4897 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r
4898 // b0\r
4899 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r
4900 // b8\r
4901 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r
4902 // c0\r
4903 primStoreImage,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r
4904 // c8\r
4905 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r
4906 // d0\r
4907 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r
4908 // d8\r
4909 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r
4910 // e0\r
4911 primNI,cmdTexturePage,cmdTextureWindow,cmdDrawAreaStart,cmdDrawAreaEnd,cmdDrawOffset,cmdSTP,primNI,\r
4912 // e8\r
4913 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r
4914 // f0\r
4915 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r
4916 // f8\r
4917 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI\r
4918};\r
4919\r
4920////////////////////////////////////////////////////////////////////////\r
4921// cmd func ptr table for skipping\r
4922////////////////////////////////////////////////////////////////////////\r
4923\r
677ea103 4924void (*primTableSkip[256])(unsigned char *) = \r
ce879073 4925{\r
4926 // 00\r
4927 primNI,primNI,primBlkFill,primNI,primNI,primNI,primNI,primNI,\r
4928 // 08\r
4929 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r
4930 // 10\r
4931 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r
4932 // 18\r
4933 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r
4934 // 20\r
4935 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r
4936 // 28\r
4937 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r
4938 // 30\r
4939 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r
4940 // 38\r
4941 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r
4942 // 40\r
4943 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r
4944 // 48\r
4945 primLineFSkip,primLineFSkip,primLineFSkip,primLineFSkip,primLineFSkip,primLineFSkip,primLineFSkip,primLineFSkip,\r
4946 // 50\r
4947 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r
4948 // 58\r
4949 primLineGSkip,primLineGSkip,primLineGSkip,primLineGSkip,primLineGSkip,primLineGSkip,primLineGSkip,primLineGSkip,\r
4950 // 60\r
4951 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r
4952 // 68\r
4953 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r
4954 // 70\r
4955 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r
4956 // 78\r
4957 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r
4958 // 80\r
4959 primMoveImage,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r
4960 // 88\r
4961 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r
4962 // 90\r
4963 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r
4964 // 98\r
4965 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r
4966 // a0\r
4967 primLoadImage,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r
4968 // a8\r
4969 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r
4970 // b0\r
4971 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r
4972 // b8\r
4973 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r
4974 // c0\r
4975 primStoreImage,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r
4976 // c8\r
4977 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r
4978 // d0\r
4979 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r
4980 // d8\r
4981 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r
4982 // e0\r
4983 primNI,cmdTexturePage,cmdTextureWindow,cmdDrawAreaStart,cmdDrawAreaEnd,cmdDrawOffset,cmdSTP,primNI,\r
4984 // e8\r
4985 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r
4986 // f0\r
4987 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r
4988 // f8\r
4989 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI\r
4990};\r