1 /***************************************************************************
2 * Copyright (C) 2010 PCSX4ALL Team *
3 * Copyright (C) 2010 Unai *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA. *
19 ***************************************************************************/
21 #ifndef __GPU_UNAI_GPU_RASTER_IMAGE_H__
22 #define __GPU_UNAI_GPU_RASTER_IMAGE_H__
24 ///////////////////////////////////////////////////////////////////////////////
26 void gpuLoadImage(PtrUnion packet)
29 x0 = packet.U2[2] & 1023;
30 y0 = packet.U2[3] & 511;
34 if ((y0 + h0) > FRAME_HEIGHT)
36 h0 = FRAME_HEIGHT - y0;
39 gpu_senquack.dma.FrameToWrite = ((w0)&&(h0));
41 gpu_senquack.dma.px = 0;
42 gpu_senquack.dma.py = 0;
43 gpu_senquack.dma.x_end = w0;
44 gpu_senquack.dma.y_end = h0;
45 gpu_senquack.dma.pvram = &((u16*)gpu_senquack.vram)[x0+(y0*1024)];
47 gpu_senquack.GPU_GP1 |= 0x08000000;
51 ///////////////////////////////////////////////////////////////////////////////
53 void gpuStoreImage(PtrUnion packet)
56 x0 = packet.U2[2] & 1023;
57 y0 = packet.U2[3] & 511;
61 if ((y0 + h0) > FRAME_HEIGHT)
63 h0 = FRAME_HEIGHT - y0;
65 gpu_senquack.dma.FrameToRead = ((w0)&&(h0));
67 gpu_senquack.dma.px = 0;
68 gpu_senquack.dma.py = 0;
69 gpu_senquack.dma.x_end = w0;
70 gpu_senquack.dma.y_end = h0;
71 gpu_senquack.dma.pvram = &((u16*)gpu_senquack.vram)[x0+(y0*1024)];
73 gpu_senquack.GPU_GP1 |= 0x08000000;
77 void gpuMoveImage(PtrUnion packet)
81 x0 = packet.U2[2] & 1023;
82 y0 = packet.U2[3] & 511;
83 x1 = packet.U2[4] & 1023;
84 y1 = packet.U2[5] & 511;
88 if( (x0==x1) && (y0==y1) ) return;
89 if ((w0<=0) || (h0<=0)) return;
91 #ifdef ENABLE_GPU_LOG_SUPPORT
92 fprintf(stdout,"gpuMoveImage(x0=%u,y0=%u,x1=%u,y1=%u,w0=%d,h0=%d)\n",x0,y0,x1,y1,w0,h0);
95 if (((y0+h0)>512)||((x0+w0)>1024)||((y1+h0)>512)||((x1+w0)>1024))
97 u16 *psxVuw=gpu_senquack.vram;
101 psxVuw [(1024*((y1+j)&511))+((x1+i)&0x3ff)]=
102 psxVuw[(1024*((y0+j)&511))+((x0+i)&0x3ff)];
104 else if ((x0&1)||(x1&1))
107 lpDst = lpSrc = (u16*)gpu_senquack.vram;
108 lpSrc += FRAME_OFFSET(x0, y0);
109 lpDst += FRAME_OFFSET(x1, y1);
110 x1 = FRAME_WIDTH - w0;
113 do { *lpDst++ = *lpSrc++; } while (--x0);
121 lpDst = lpSrc = (u32*)(void*)gpu_senquack.vram;
122 lpSrc += ((FRAME_OFFSET(x0, y0))>>1);
123 lpDst += ((FRAME_OFFSET(x1, y1))>>1);
126 x1 = (FRAME_WIDTH - w0 +1)>>1;
130 *((u16*)lpDst) = *((u16*)lpSrc);
137 do { *lpDst++ = *lpSrc++; } while (--x0);
138 *((u16*)lpDst) = *((u16*)lpSrc);
145 x1 = (FRAME_WIDTH - w0)>>1;
149 do { *lpDst++ = *lpSrc++; } while (--x0);
157 void gpuClearImage(PtrUnion packet)
162 w0 = packet.S2[4] & 0x3ff;
163 h0 = packet.S2[5] & 0x3ff;
167 if (w0 > FRAME_WIDTH) w0 = FRAME_WIDTH;
172 if (h0 > FRAME_HEIGHT) h0 = FRAME_HEIGHT;
176 #ifdef ENABLE_GPU_LOG_SUPPORT
177 fprintf(stdout,"gpuClearImage(x0=%d,y0=%d,w0=%d,h0=%d)\n",x0,y0,w0,h0);
182 u16* pixel = (u16*)gpu_senquack.vram + FRAME_OFFSET(x0, y0);
183 u16 rgb = GPU_RGB16(packet.U4[0]);
184 y0 = FRAME_WIDTH - w0;
187 do { *pixel++ = rgb; } while (--x0);
193 u32* pixel = (u32*)gpu_senquack.vram + ((FRAME_OFFSET(x0, y0))>>1);
194 u32 rgb = GPU_RGB16(packet.U4[0]);
198 y0 = (FRAME_WIDTH - w0 +1)>>1;
202 do { *pixel++ = rgb; } while (--x0);
203 *((u16*)pixel) = (u16)rgb;
209 y0 = (FRAME_WIDTH - w0)>>1;
213 do { *pixel++ = rgb; } while (--x0);
220 #endif /* __GPU_UNAI_GPU_RASTER_IMAGE_H__ */