15#include <sys/unistd.h>
21extern QWORD GsPrimWorkArea[];
23void GsSetDefaultDrawEnv(
GS_DRAWENV *drawenv, u16 psm, u16 w, u16 h)
25 drawenv->offset_x = 2048-w/2;
26 drawenv->offset_y = 2048-h/2;
31 drawenv->draw_mask = 0;
32 drawenv->auto_clear = 1;
34 drawenv->bg_color.r = 0x01;
35 drawenv->bg_color.g = 0x01;
36 drawenv->bg_color.b = 0x01;
37 drawenv->bg_color.a = 0x80;
38 drawenv->bg_color.q = 0.0f;
40 drawenv->fbw = (w+63)/64;
42 drawenv->vram_addr = 0;
47void GsSetDefaultDrawEnvAddress(
GS_DRAWENV *drawenv, u16 vram_addr)
49 drawenv->vram_addr=vram_addr;
52int checkModelVersion(
void)
57 if((fd=open(
"rom0:ROMVER", O_RDONLY))>=0)
61 for(pData=data,i=0; (
unsigned int)i<
sizeof(data); i++)
64 if(*pData++==
'\0')
break;
69 result=(20010608<atoi(data+i-9));
76void GsSetDefaultDisplayEnv(
GS_DISPENV *dispenv, u16 psm, u16 w, u16 h, u16 dx, u16 dy)
79 int gs_DH, gs_DW, gs_DY, gs_DX;
81 pGParams=GsGetGParam();
82 dispenv->disp.
pad1=dispenv->disp.
pad2=0;
84 if(pGParams->
omode >= GS_MODE_NTSC && pGParams->
omode <= GS_MODE_PAL)
91 if(checkModelVersion())
92 _GetGsDxDyOffset(pGParams->
omode, &gs_DX, &gs_DY, &gs_DW, &gs_DH);
101 dispenv->dispfb.
pad1=dispenv->dispfb.
pad2=0;
105 dispenv->dispfb.
fbw=(w+63)/64;
106 dispenv->dispfb.
psm=psm;
107 switch(pGParams->
omode)
113 dispenv->disp.
display_x = (gs_DX+0x27C) + dx*((w+0x9FF)/w);
114 dispenv->disp.
magnify_h = (w+0x9FF)/w - 1;
116 dispenv->disp.
display_w = (w+0x9FF)/w*w - 1;
124 dispenv->disp.
display_x = gs_DX+0x27C + dx*((w+0x9FF)/w);
126 dispenv->disp.
magnify_h = (w+0x9FF)/w - 1;
128 dispenv->disp.
display_w = (w+0x9FF)/w*w - 1;
135 dispenv->disp.
display_x = gs_DX+0x290 + dx*((w+0x9FF)/w);
136 dispenv->disp.
magnify_h = (w+0x9FF)/w - 1;
138 dispenv->disp.
display_w = (w+0x9FF)/w*w - 1;
146 dispenv->disp.
display_x = gs_DX+0x290 + dx*((w+0x9FF)/w);
148 dispenv->disp.
magnify_h = (w+0x9FF)/w - 1;
150 dispenv->disp.
display_w = (w+0x9FF)/w*w - 1;
153 case GS_MODE_DTV_480P:
154 dispenv->disp.
display_x = gs_DX+((0x2D0-w) + ((0x2D0-w)>>31))/2*2 + (dx<<1)+0xE8;
162 printf(
"GsSetDefaultDisplayEnv: Unsupported video mode: 0x%x\n", pGParams->
omode);
166void GsSetDefaultDisplayEnvAddress(
GS_DISPENV *dispenv,
unsigned short vram_addr)
168 dispenv->dispfb.
address=vram_addr;
173 GsSetXYOffset1(drawenv->offset_x<<4, drawenv->offset_y<<4);
174 GsSetScissor1(drawenv->clip.x, drawenv->clip.y, drawenv->clip.x+drawenv->clip.w, drawenv->clip.y+drawenv->clip.h);
175 GsSetFrame1(drawenv->vram_addr, drawenv->fbw, drawenv->psm, drawenv->draw_mask);
178 if(drawenv->auto_clear)
186 unsigned char context;
192 p=UNCACHED_SEG(GsPrimWorkArea);
195 gs_setR_RGBAQ(((
GS_R_RGBAQ *)&p[2]), drawenv->bg_color.r, drawenv->bg_color.g, drawenv->bg_color.b, drawenv->bg_color.a, drawenv->bg_color.q);
196 gs_setR_XYZ2(((
GS_R_XYZ *)&p[3]), (drawenv->offset_x+drawenv->clip.x)<<4, (drawenv->offset_y+drawenv->clip.y)<<4, 0x00000000);
197 gs_setR_XYZ2(((
GS_R_XYZ *)&p[4]), (drawenv->offset_x+drawenv->clip.x+drawenv->clip.w)<<4, (drawenv->offset_y+drawenv->clip.y+drawenv->clip.h)<<4, 0x00000000);
199 GsDmaSend(GsPrimWorkArea, 5);
211 GsSetXYOffset2(drawenv->offset_x<<4, drawenv->offset_y<<4);
212 GsSetScissor2(drawenv->clip.x, drawenv->clip.y, drawenv->clip.x+drawenv->clip.w, drawenv->clip.y+drawenv->clip.h);
213 GsSetFrame2(drawenv->vram_addr, drawenv->fbw, drawenv->psm, drawenv->draw_mask);
215 if(drawenv->auto_clear)
223 unsigned char context;
229 p=UNCACHED_SEG(GsPrimWorkArea);
232 gs_setR_RGBAQ(((
GS_R_RGBAQ *)&p[2]), drawenv->bg_color.r, drawenv->bg_color.g, drawenv->bg_color.b, drawenv->bg_color.a, drawenv->bg_color.q);
233 gs_setR_XYZ2(((
GS_R_XYZ *)&p[3]), (drawenv->offset_x+drawenv->clip.x)<<4, (drawenv->offset_y+drawenv->clip.y)<<4, 0x00000000);
234 gs_setR_XYZ2(((
GS_R_XYZ *)&p[4]), (drawenv->offset_x+drawenv->clip.x+drawenv->clip.w)<<4, (drawenv->offset_y+drawenv->clip.y+drawenv->clip.h)<<4, 0x00000000);
236 GsDmaSend(GsPrimWorkArea, 5);
void GsClearDrawEnv2(GS_DRAWENV *drawenv)
void GsClearDrawEnv1(GS_DRAWENV *drawenv)