• R/O
  • SSH
  • HTTPS

oswanpsp: Commit


Commit MetaInfo

Revisão26 (tree)
Hora2009-07-29 11:18:30
Autorbird_may_nike

Mensagem de Log

(mensagem de log vazia)

Mudança Sumário

Diff

--- trunc/src/video.c (revision 25)
+++ trunc/src/video.c (revision 26)
@@ -21,22 +21,22 @@
2121
2222 static const ScePspIMatrix4 dither_matrix =
2323 {
24- // Bayer dither
25- { 0, 8, 2, 10 },
26- { 12, 4, 14, 6 },
27- { 3, 11, 1, 9 },
28- { 15, 7, 13, 5 }
24+ // Bayer dither
25+ { 0, 8, 2, 10 },
26+ { 12, 4, 14, 6 },
27+ { 3, 11, 1, 9 },
28+ { 15, 7, 13, 5 }
2929 };
3030
3131 struct Vertex
3232 {
33- unsigned short u, v;
34- unsigned short color;
35- short x, y, z;
33+ unsigned short u, v;
34+ unsigned short color;
35+ short x, y, z;
3636 };
3737
3838 /*--------------------------------------------------------
39- ビデオ処理初期化
39+ ビデオ処理初期化
4040 --------------------------------------------------------*/
4141
4242 void video_init(void)
@@ -45,73 +45,73 @@
4545 intraFontInit();
4646 jpn0 = intraFontLoad("flash0:/font/jpn0.pgf", INTRAFONT_STRING_SJIS | INTRAFONT_CACHE_ALL);
4747
48- draw_frame = (void *)(FRAMESIZE * 0);
49- show_frame = (void *)(FRAMESIZE * 1);
50- work_frame = (void *)(FRAMESIZE * 2);
51- tex_frame = (void *)(FRAMESIZE * 3);
48+ draw_frame = (void *)(FRAMESIZE * 0);
49+ show_frame = (void *)(FRAMESIZE * 1);
50+ work_frame = (void *)(FRAMESIZE * 2);
51+ tex_frame = (void *)(FRAMESIZE * 3);
5252
53- sceGuDisplay(GU_FALSE);
54- sceGuInit();
53+ sceGuDisplay(GU_FALSE);
54+ sceGuInit();
5555
56- sceGuStart(GU_DIRECT, gulist);
57- sceGuDrawBuffer(GU_PSM_4444, draw_frame, BUF_WIDTH);
58- sceGuDispBuffer(SCR_WIDTH, SCR_HEIGHT, show_frame, BUF_WIDTH);
59- sceGuOffset(2048 - (SCR_WIDTH / 2), 2048 - (SCR_HEIGHT / 2));
60- sceGuViewport(2048, 2048, SCR_WIDTH, SCR_HEIGHT);
56+ sceGuStart(GU_DIRECT, gulist);
57+ sceGuDrawBuffer(GU_PSM_4444, draw_frame, BUF_WIDTH);
58+ sceGuDispBuffer(SCR_WIDTH, SCR_HEIGHT, show_frame, BUF_WIDTH);
59+ sceGuOffset(2048 - (SCR_WIDTH / 2), 2048 - (SCR_HEIGHT / 2));
60+ sceGuViewport(2048, 2048, SCR_WIDTH, SCR_HEIGHT);
6161
62- sceGuEnable(GU_SCISSOR_TEST);
63- sceGuScissor(0, 0, SCR_WIDTH, SCR_HEIGHT);
62+ sceGuEnable(GU_SCISSOR_TEST);
63+ sceGuScissor(0, 0, SCR_WIDTH, SCR_HEIGHT);
6464
65- sceGuDisable(GU_ALPHA_TEST);
66- sceGuAlphaFunc(GU_LEQUAL, 0, 0x01);
65+ sceGuDisable(GU_ALPHA_TEST);
66+ sceGuAlphaFunc(GU_LEQUAL, 0, 0x01);
6767
68- sceGuEnable(GU_BLEND);
69- sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0);
68+ sceGuEnable(GU_BLEND);
69+ sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0);
7070
71- sceGuDisable(GU_DEPTH_TEST);
72- sceGuDepthRange(65535, 0);
73- sceGuDepthFunc(GU_GEQUAL);
74- sceGuDepthMask(GU_TRUE);
71+ sceGuDisable(GU_DEPTH_TEST);
72+ sceGuDepthRange(65535, 0);
73+ sceGuDepthFunc(GU_GEQUAL);
74+ sceGuDepthMask(GU_TRUE);
7575
76- sceGuEnable(GU_TEXTURE_2D);
77- sceGuTexMode(GU_PSM_4444, 0, 0, GU_FALSE);
78- sceGuTexScale(1.0f / BUF_WIDTH, 1.0f / BUF_WIDTH);
79- sceGuTexOffset(0, 0);
80- sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGBA);
76+ sceGuEnable(GU_TEXTURE_2D);
77+ sceGuTexMode(GU_PSM_4444, 0, 0, GU_FALSE);
78+ sceGuTexScale(1.0f / BUF_WIDTH, 1.0f / BUF_WIDTH);
79+ sceGuTexOffset(0, 0);
80+ sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGBA);
8181
82- sceGuClutMode(GU_PSM_4444, 0, 0xff, 0);
82+ sceGuClutMode(GU_PSM_4444, 0, 0xff, 0);
8383
84- sceGuSetDither(&dither_matrix);
85- sceGuDisable(GU_DITHER);
84+ sceGuSetDither(&dither_matrix);
85+ sceGuDisable(GU_DITHER);
8686
87- sceGuClearDepth(0);
88- sceGuClearColor(0);
87+ sceGuClearDepth(0);
88+ sceGuClearColor(0);
8989
90- sceGuFinish();
91- sceGuSync(0, GU_SYNC_FINISH);
90+ sceGuFinish();
91+ sceGuSync(0, GU_SYNC_FINISH);
9292
93- sceDisplayWaitVblankStart();
94- sceGuDisplay(GU_TRUE);
93+ sceDisplayWaitVblankStart();
94+ sceGuDisplay(GU_TRUE);
9595 }
9696
9797 /*--------------------------------------------------------
98- ビデオ処理終了(共通)
98+ ビデオ処理終了(共通)
9999 --------------------------------------------------------*/
100100
101101 void video_exit(void)
102102 {
103103 intraFontUnload(jpn0);
104- sceGuDisplay(GU_FALSE);
105- sceGuTerm();
104+ sceGuDisplay(GU_FALSE);
105+ sceGuTerm();
106106 }
107107
108108 /*--------------------------------------------------------
109- VSYNCを待つ
109+ VSYNCを待つ
110110 --------------------------------------------------------*/
111111
112112 void video_wait_vsync(void)
113113 {
114- sceDisplayWaitVblankStart();
114+ sceDisplayWaitVblankStart();
115115 }
116116
117117 void video_wait_vsync_n(unsigned long count)
@@ -122,451 +122,451 @@
122122 }
123123
124124 /*--------------------------------------------------------
125- スクリーンをフリップ
125+ スクリーンをフリップ
126126 --------------------------------------------------------*/
127127
128128 void video_flip_screen(int vsync)
129129 {
130- if (vsync) sceDisplayWaitVblankStart();
131- show_frame = draw_frame;
132- draw_frame = sceGuSwapBuffers();
130+ if (vsync) sceDisplayWaitVblankStart();
131+ show_frame = draw_frame;
132+ draw_frame = sceGuSwapBuffers();
133133 }
134134
135135 /*--------------------------------------------------------
136- VRAMのアドレスを取得
136+ VRAMのアドレスを取得
137137 --------------------------------------------------------*/
138138
139139 unsigned short* video_frame_addr(void *frame, int x, int y)
140140 {
141- return GU_FRAME_ADDR(frame) + x + (y << 9);
141+ return GU_FRAME_ADDR(frame) + x + (y << 9);
142142 }
143143
144144 /*--------------------------------------------------------
145- 指定したフレームをクリア
145+ 指定したフレームをクリア
146146 --------------------------------------------------------*/
147147
148148 void video_clear_frame(void *frame)
149149 {
150- sceGuStart(GU_DIRECT, gulist);
151- sceGuDrawBufferList(GU_PSM_4444, frame, BUF_WIDTH);
152- sceGuScissor(0, 0, BUF_WIDTH, SCR_HEIGHT);
153- sceGuClearColor(0);
154- sceGuClear(GU_COLOR_BUFFER_BIT);
155- sceGuFinish();
156- sceGuSync(0, GU_SYNC_FINISH);
150+ sceGuStart(GU_DIRECT, gulist);
151+ sceGuDrawBufferList(GU_PSM_4444, frame, BUF_WIDTH);
152+ sceGuScissor(0, 0, BUF_WIDTH, SCR_HEIGHT);
153+ sceGuClearColor(0);
154+ sceGuClear(GU_COLOR_BUFFER_BIT);
155+ sceGuFinish();
156+ sceGuSync(0, GU_SYNC_FINISH);
157157 }
158158
159159
160160 /*--------------------------------------------------------
161- 描画/表示フレームをクリア
161+ 描画/表示フレームをクリア
162162 --------------------------------------------------------*/
163163
164164 void video_clear_screen(void)
165165 {
166- video_clear_frame(show_frame);
167- video_clear_frame(draw_frame);
166+ video_clear_frame(show_frame);
167+ video_clear_frame(draw_frame);
168168 }
169169
170170
171171 /*--------------------------------------------------------
172- 指定した矩形範囲をクリア
172+ 指定した矩形範囲をクリア
173173 --------------------------------------------------------*/
174174
175175 void video_clear_rect(void *frame, RECT *rect)
176176 {
177- sceGuStart(GU_DIRECT, gulist);
178- sceGuDrawBufferList(GU_PSM_4444, frame, BUF_WIDTH);
179- sceGuScissor(rect->left, rect->top, rect->right, rect->bottom);
180- sceGuClearColor(0);
181- sceGuClear(GU_COLOR_BUFFER_BIT);
182- sceGuFinish();
183- sceGuSync(0, GU_SYNC_FINISH);
177+ sceGuStart(GU_DIRECT, gulist);
178+ sceGuDrawBufferList(GU_PSM_4444, frame, BUF_WIDTH);
179+ sceGuScissor(rect->left, rect->top, rect->right, rect->bottom);
180+ sceGuClearColor(0);
181+ sceGuClear(GU_COLOR_BUFFER_BIT);
182+ sceGuFinish();
183+ sceGuSync(0, GU_SYNC_FINISH);
184184 }
185185
186186
187187 /*--------------------------------------------------------
188- 指定したフレームを塗りつぶし
188+ 指定したフレームを塗りつぶし
189189 --------------------------------------------------------*/
190190
191191 void video_fill_frame(void *frame, unsigned long color)
192192 {
193- sceGuStart(GU_DIRECT, gulist);
194- sceGuDrawBufferList(GU_PSM_4444, frame, BUF_WIDTH);
195- sceGuScissor(0, 0, SCR_WIDTH, SCR_HEIGHT);
196- sceGuClearColor(color);
197- sceGuClear(GU_COLOR_BUFFER_BIT);
198- sceGuFinish();
199- sceGuSync(0, GU_SYNC_FINISH);
193+ sceGuStart(GU_DIRECT, gulist);
194+ sceGuDrawBufferList(GU_PSM_4444, frame, BUF_WIDTH);
195+ sceGuScissor(0, 0, SCR_WIDTH, SCR_HEIGHT);
196+ sceGuClearColor(color);
197+ sceGuClear(GU_COLOR_BUFFER_BIT);
198+ sceGuFinish();
199+ sceGuSync(0, GU_SYNC_FINISH);
200200 }
201201
202202
203203 /*--------------------------------------------------------
204- 指定した矩形範囲を塗りつぶし
204+ 指定した矩形範囲を塗りつぶし
205205 --------------------------------------------------------*/
206206
207207 void video_fill_rect(void *frame, unsigned long color, RECT *rect)
208208 {
209- sceGuStart(GU_DIRECT, gulist);
210- sceGuDrawBufferList(GU_PSM_4444, frame, BUF_WIDTH);
211- sceGuScissor(rect->left, rect->top, rect->right, rect->bottom);
212- sceGuClearColor(color);
213- sceGuClear(GU_COLOR_BUFFER_BIT);
214- sceGuFinish();
215- sceGuSync(0, GU_SYNC_FINISH);
209+ sceGuStart(GU_DIRECT, gulist);
210+ sceGuDrawBufferList(GU_PSM_4444, frame, BUF_WIDTH);
211+ sceGuScissor(rect->left, rect->top, rect->right, rect->bottom);
212+ sceGuClearColor(color);
213+ sceGuClear(GU_COLOR_BUFFER_BIT);
214+ sceGuFinish();
215+ sceGuSync(0, GU_SYNC_FINISH);
216216 }
217217
218218 /*--------------------------------------------------------
219- 矩形範囲をコピー
219+ 矩形範囲をコピー
220220 --------------------------------------------------------*/
221221
222222 void video_copy_rect(void *src, void *dst, RECT *src_rect, RECT *dst_rect)
223223 {
224- int j, sw, dw, sh, dh;
225- struct Vertex *vertices;
224+ int j, sw, dw, sh, dh;
225+ struct Vertex *vertices;
226226
227- sw = src_rect->right - src_rect->left;
228- dw = dst_rect->right - dst_rect->left;
229- sh = src_rect->bottom - src_rect->top;
230- dh = dst_rect->bottom - dst_rect->top;
227+ sw = src_rect->right - src_rect->left;
228+ dw = dst_rect->right - dst_rect->left;
229+ sh = src_rect->bottom - src_rect->top;
230+ dh = dst_rect->bottom - dst_rect->top;
231231
232- sceGuStart(GU_DIRECT, gulist);
232+ sceGuStart(GU_DIRECT, gulist);
233233
234- sceGuDrawBufferList(GU_PSM_4444, dst, BUF_WIDTH);
235- sceGuScissor(dst_rect->left, dst_rect->top, dst_rect->right, dst_rect->bottom);
236- sceGuDisable(GU_ALPHA_TEST);
234+ sceGuDrawBufferList(GU_PSM_4444, dst, BUF_WIDTH);
235+ sceGuScissor(dst_rect->left, dst_rect->top, dst_rect->right, dst_rect->bottom);
236+ sceGuDisable(GU_ALPHA_TEST);
237237
238- sceGuTexMode(GU_PSM_4444, 0, 0, GU_FALSE);
239- sceGuTexImage(0, BUF_WIDTH, BUF_WIDTH, BUF_WIDTH, GU_FRAME_ADDR(src));
240- sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGBA);
241- if (sw == dw && sh == dh)
242- sceGuTexFilter(GU_NEAREST, GU_NEAREST);
243- else
244- sceGuTexFilter(GU_LINEAR, GU_LINEAR);
238+ sceGuTexMode(GU_PSM_4444, 0, 0, GU_FALSE);
239+ sceGuTexImage(0, BUF_WIDTH, BUF_WIDTH, BUF_WIDTH, GU_FRAME_ADDR(src));
240+ sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGBA);
241+ if (sw == dw && sh == dh)
242+ sceGuTexFilter(GU_NEAREST, GU_NEAREST);
243+ else
244+ sceGuTexFilter(GU_LINEAR, GU_LINEAR);
245245
246- for (j = 0; (j + SLICE_SIZE) < sw; j = j + SLICE_SIZE)
247- {
248- vertices = (struct Vertex *)sceGuGetMemory(2 * sizeof(struct Vertex));
246+ for (j = 0; (j + SLICE_SIZE) < sw; j = j + SLICE_SIZE)
247+ {
248+ vertices = (struct Vertex *)sceGuGetMemory(2 * sizeof(struct Vertex));
249249
250- vertices[0].u = src_rect->left + j;
251- vertices[0].v = src_rect->top;
252- vertices[0].x = dst_rect->left + j * dw / sw;
253- vertices[0].y = dst_rect->top;
250+ vertices[0].u = src_rect->left + j;
251+ vertices[0].v = src_rect->top;
252+ vertices[0].x = dst_rect->left + j * dw / sw;
253+ vertices[0].y = dst_rect->top;
254254
255- vertices[1].u = src_rect->left + j + SLICE_SIZE;
256- vertices[1].v = src_rect->bottom;
257- vertices[1].x = dst_rect->left + (j + SLICE_SIZE) * dw / sw;
258- vertices[1].y = dst_rect->bottom;
255+ vertices[1].u = src_rect->left + j + SLICE_SIZE;
256+ vertices[1].v = src_rect->bottom;
257+ vertices[1].x = dst_rect->left + (j + SLICE_SIZE) * dw / sw;
258+ vertices[1].y = dst_rect->bottom;
259259
260- sceGuDrawArray(GU_SPRITES, TEXTURE_FLAGS, 2, NULL, vertices);
261- }
260+ sceGuDrawArray(GU_SPRITES, TEXTURE_FLAGS, 2, NULL, vertices);
261+ }
262262
263- if (j < sw)
264- {
265- vertices = (struct Vertex *)sceGuGetMemory(2 * sizeof(struct Vertex));
263+ if (j < sw)
264+ {
265+ vertices = (struct Vertex *)sceGuGetMemory(2 * sizeof(struct Vertex));
266266
267- vertices[0].u = src_rect->left + j;
268- vertices[0].v = src_rect->top;
269- vertices[0].x = dst_rect->left + j * dw / sw;
270- vertices[0].y = dst_rect->top;
267+ vertices[0].u = src_rect->left + j;
268+ vertices[0].v = src_rect->top;
269+ vertices[0].x = dst_rect->left + j * dw / sw;
270+ vertices[0].y = dst_rect->top;
271271
272- vertices[1].u = src_rect->right;
273- vertices[1].v = src_rect->bottom;
274- vertices[1].x = dst_rect->right;
275- vertices[1].y = dst_rect->bottom;
272+ vertices[1].u = src_rect->right;
273+ vertices[1].v = src_rect->bottom;
274+ vertices[1].x = dst_rect->right;
275+ vertices[1].y = dst_rect->bottom;
276276
277- sceGuDrawArray(GU_SPRITES, TEXTURE_FLAGS, 2, NULL, vertices);
278- }
277+ sceGuDrawArray(GU_SPRITES, TEXTURE_FLAGS, 2, NULL, vertices);
278+ }
279279
280- sceGuFinish();
281- sceGuSync(0, GU_SYNC_FINISH);
280+ sceGuFinish();
281+ sceGuSync(0, GU_SYNC_FINISH);
282282 }
283283
284284 /*--------------------------------------------------------
285- 矩形範囲を左右反転してコピー
285+ 矩形範囲を左右反転してコピー
286286 --------------------------------------------------------*/
287287
288288 void video_copy_rect_flip(void *src, void *dst, RECT *src_rect, RECT *dst_rect)
289289 {
290- short j, sw, dw, sh, dh;
291- struct Vertex *vertices;
290+ short j, sw, dw, sh, dh;
291+ struct Vertex *vertices;
292292
293- sw = src_rect->right - src_rect->left;
294- dw = dst_rect->right - dst_rect->left;
295- sh = src_rect->bottom - src_rect->top;
296- dh = dst_rect->bottom - dst_rect->top;
293+ sw = src_rect->right - src_rect->left;
294+ dw = dst_rect->right - dst_rect->left;
295+ sh = src_rect->bottom - src_rect->top;
296+ dh = dst_rect->bottom - dst_rect->top;
297297
298- sceGuStart(GU_DIRECT, gulist);
298+ sceGuStart(GU_DIRECT, gulist);
299299
300- sceGuDrawBufferList(GU_PSM_4444, dst, BUF_WIDTH);
301- sceGuScissor(dst_rect->left, dst_rect->top, dst_rect->right, dst_rect->bottom);
302- sceGuDisable(GU_ALPHA_TEST);
300+ sceGuDrawBufferList(GU_PSM_4444, dst, BUF_WIDTH);
301+ sceGuScissor(dst_rect->left, dst_rect->top, dst_rect->right, dst_rect->bottom);
302+ sceGuDisable(GU_ALPHA_TEST);
303303
304- sceGuTexMode(GU_PSM_4444, 0, 0, GU_FALSE);
305- sceGuTexImage(0, BUF_WIDTH, BUF_WIDTH, BUF_WIDTH, GU_FRAME_ADDR(src));
306- sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGBA);
307- if (sw == dw && sh == dh)
308- sceGuTexFilter(GU_NEAREST, GU_NEAREST);
309- else
310- sceGuTexFilter(GU_LINEAR, GU_LINEAR);
304+ sceGuTexMode(GU_PSM_4444, 0, 0, GU_FALSE);
305+ sceGuTexImage(0, BUF_WIDTH, BUF_WIDTH, BUF_WIDTH, GU_FRAME_ADDR(src));
306+ sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGBA);
307+ if (sw == dw && sh == dh)
308+ sceGuTexFilter(GU_NEAREST, GU_NEAREST);
309+ else
310+ sceGuTexFilter(GU_LINEAR, GU_LINEAR);
311311
312- for (j = 0; (j + SLICE_SIZE) < sw; j = j + SLICE_SIZE)
313- {
314- vertices = (struct Vertex *)sceGuGetMemory(2 * sizeof(struct Vertex));
312+ for (j = 0; (j + SLICE_SIZE) < sw; j = j + SLICE_SIZE)
313+ {
314+ vertices = (struct Vertex *)sceGuGetMemory(2 * sizeof(struct Vertex));
315315
316- vertices[0].u = src_rect->left + j;
317- vertices[0].v = src_rect->top;
318- vertices[0].x = dst_rect->right - j * dw / sw;
319- vertices[0].y = dst_rect->bottom;
316+ vertices[0].u = src_rect->left + j;
317+ vertices[0].v = src_rect->top;
318+ vertices[0].x = dst_rect->right - j * dw / sw;
319+ vertices[0].y = dst_rect->bottom;
320320
321- vertices[1].u = src_rect->left + j + SLICE_SIZE;
322- vertices[1].v = src_rect->bottom;
323- vertices[1].x = dst_rect->right - (j + SLICE_SIZE) * dw / sw;
324- vertices[1].y = dst_rect->top;
321+ vertices[1].u = src_rect->left + j + SLICE_SIZE;
322+ vertices[1].v = src_rect->bottom;
323+ vertices[1].x = dst_rect->right - (j + SLICE_SIZE) * dw / sw;
324+ vertices[1].y = dst_rect->top;
325325
326- sceGuDrawArray(GU_SPRITES, TEXTURE_FLAGS, 2, NULL, vertices);
327- }
326+ sceGuDrawArray(GU_SPRITES, TEXTURE_FLAGS, 2, NULL, vertices);
327+ }
328328
329- if (j < sw)
330- {
331- vertices = (struct Vertex *)sceGuGetMemory(2 * sizeof(struct Vertex));
329+ if (j < sw)
330+ {
331+ vertices = (struct Vertex *)sceGuGetMemory(2 * sizeof(struct Vertex));
332332
333- vertices[0].u = src_rect->left + j;
334- vertices[0].v = src_rect->top;
335- vertices[0].x = dst_rect->right - j * dw / sw;
336- vertices[0].y = dst_rect->bottom;
333+ vertices[0].u = src_rect->left + j;
334+ vertices[0].v = src_rect->top;
335+ vertices[0].x = dst_rect->right - j * dw / sw;
336+ vertices[0].y = dst_rect->bottom;
337337
338- vertices[1].u = src_rect->right;
339- vertices[1].v = src_rect->bottom;
340- vertices[1].x = dst_rect->left;
341- vertices[1].y = dst_rect->top;
338+ vertices[1].u = src_rect->right;
339+ vertices[1].v = src_rect->bottom;
340+ vertices[1].x = dst_rect->left;
341+ vertices[1].y = dst_rect->top;
342342
343- sceGuDrawArray(GU_SPRITES, TEXTURE_FLAGS, 2, NULL, vertices);
344- }
343+ sceGuDrawArray(GU_SPRITES, TEXTURE_FLAGS, 2, NULL, vertices);
344+ }
345345
346- sceGuFinish();
347- sceGuSync(0, GU_SYNC_FINISH);
346+ sceGuFinish();
347+ sceGuSync(0, GU_SYNC_FINISH);
348348 }
349349
350350
351351 /*--------------------------------------------------------
352- 矩形範囲を270度回転してコピー
352+ 矩形範囲を270度回転してコピー
353353 --------------------------------------------------------*/
354354
355355 void video_copy_rect_rotate(void *src, void *dst, RECT *src_rect, RECT *dst_rect)
356356 {
357- short j, sw, dw, sh, dh;
358- struct Vertex *vertices;
357+ short j, sw, dw, sh, dh;
358+ struct Vertex *vertices;
359359
360- sw = src_rect->right - src_rect->left;
361- dw = dst_rect->right - dst_rect->left;
362- sh = src_rect->bottom - src_rect->top;
363- dh = dst_rect->bottom - dst_rect->top;
360+ sw = src_rect->right - src_rect->left;
361+ dw = dst_rect->right - dst_rect->left;
362+ sh = src_rect->bottom - src_rect->top;
363+ dh = dst_rect->bottom - dst_rect->top;
364364
365- sceGuStart(GU_DIRECT, gulist);
365+ sceGuStart(GU_DIRECT, gulist);
366366
367- sceGuDrawBufferList(GU_PSM_4444, dst, BUF_WIDTH);
368- sceGuScissor(dst_rect->left, dst_rect->top, dst_rect->right, dst_rect->bottom);
369- sceGuDisable(GU_ALPHA_TEST);
370- sceGuDisable(GU_BLEND);
371- sceGuDisable(GU_DEPTH_TEST);
367+ sceGuDrawBufferList(GU_PSM_4444, dst, BUF_WIDTH);
368+ sceGuScissor(dst_rect->left, dst_rect->top, dst_rect->right, dst_rect->bottom);
369+ sceGuDisable(GU_ALPHA_TEST);
370+ sceGuDisable(GU_BLEND);
371+ sceGuDisable(GU_DEPTH_TEST);
372372
373- sceGuTexMode(GU_PSM_4444, 0, 0, GU_FALSE);
374- sceGuTexImage(0, BUF_WIDTH, BUF_WIDTH, BUF_WIDTH, GU_FRAME_ADDR(src));
375- sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGBA);
376- if (sw == dh && sh == dw)
377- sceGuTexFilter(GU_NEAREST, GU_NEAREST);
378- else
379- sceGuTexFilter(GU_LINEAR, GU_LINEAR);
373+ sceGuTexMode(GU_PSM_4444, 0, 0, GU_FALSE);
374+ sceGuTexImage(0, BUF_WIDTH, BUF_WIDTH, BUF_WIDTH, GU_FRAME_ADDR(src));
375+ sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGBA);
376+ if (sw == dh && sh == dw)
377+ sceGuTexFilter(GU_NEAREST, GU_NEAREST);
378+ else
379+ sceGuTexFilter(GU_LINEAR, GU_LINEAR);
380380
381- vertices = (struct Vertex *)sceGuGetMemory(2 * sizeof(struct Vertex));
381+ vertices = (struct Vertex *)sceGuGetMemory(2 * sizeof(struct Vertex));
382382
383- for (j = 0; (j + SLICE_SIZE) < sw; j = j + SLICE_SIZE)
384- {
385- vertices = (struct Vertex *)sceGuGetMemory(2 * sizeof(struct Vertex));
383+ for (j = 0; (j + SLICE_SIZE) < sw; j = j + SLICE_SIZE)
384+ {
385+ vertices = (struct Vertex *)sceGuGetMemory(2 * sizeof(struct Vertex));
386386
387- vertices[0].u = src_rect->right - j;
388- vertices[0].v = src_rect->bottom;
389- vertices[0].x = dst_rect->right;
390- vertices[0].y = dst_rect->top - j * dh / sw;
387+ vertices[0].u = src_rect->right - j;
388+ vertices[0].v = src_rect->bottom;
389+ vertices[0].x = dst_rect->right;
390+ vertices[0].y = dst_rect->top - j * dh / sw;
391391
392- vertices[1].u = src_rect->right - j + SLICE_SIZE;
393- vertices[1].v = src_rect->top;
394- vertices[1].x = dst_rect->right;
395- vertices[1].y = dst_rect->bottom - (j + SLICE_SIZE) * dh / sw;
392+ vertices[1].u = src_rect->right - j + SLICE_SIZE;
393+ vertices[1].v = src_rect->top;
394+ vertices[1].x = dst_rect->right;
395+ vertices[1].y = dst_rect->bottom - (j + SLICE_SIZE) * dh / sw;
396396
397- sceGuDrawArray(GU_SPRITES, TEXTURE_FLAGS, 2, NULL, vertices);
398- }
397+ sceGuDrawArray(GU_SPRITES, TEXTURE_FLAGS, 2, NULL, vertices);
398+ }
399399
400- if (j < sw)
401- {
402- vertices = (struct Vertex *)sceGuGetMemory(2 * sizeof(struct Vertex));
400+ if (j < sw)
401+ {
402+ vertices = (struct Vertex *)sceGuGetMemory(2 * sizeof(struct Vertex));
403403
404- vertices[0].u = src_rect->right + j;
405- vertices[0].v = src_rect->bottom;
406- vertices[0].x = dst_rect->right;
407- vertices[0].y = dst_rect->top - j * dh / sw;
404+ vertices[0].u = src_rect->right + j;
405+ vertices[0].v = src_rect->bottom;
406+ vertices[0].x = dst_rect->right;
407+ vertices[0].y = dst_rect->top - j * dh / sw;
408408
409- vertices[1].u = src_rect->left;
410- vertices[1].v = src_rect->top;
411- vertices[1].x = dst_rect->left;
412- vertices[1].y = dst_rect->bottom;
409+ vertices[1].u = src_rect->left;
410+ vertices[1].v = src_rect->top;
411+ vertices[1].x = dst_rect->left;
412+ vertices[1].y = dst_rect->bottom;
413413
414- sceGuDrawArray(GU_SPRITES, TEXTURE_FLAGS, 2, NULL, vertices);
415- }
414+ sceGuDrawArray(GU_SPRITES, TEXTURE_FLAGS, 2, NULL, vertices);
415+ }
416416
417- sceGuFinish();
418- sceGuSync(0, GU_SYNC_FINISH);
417+ sceGuFinish();
418+ sceGuSync(0, GU_SYNC_FINISH);
419419 }
420420
421421
422422 /*--------------------------------------------------------
423- テクスチャを矩形範囲を指定して描画
423+ テクスチャを矩形範囲を指定して描画
424424 --------------------------------------------------------*/
425425
426426 void video_draw_texture(unsigned long src_fmt, unsigned long dst_fmt, void *src, void *dst, RECT *src_rect, RECT *dst_rect)
427427 {
428- int j, sw, dw, sh, dh;
429- struct Vertex *vertices;
428+ int j, sw, dw, sh, dh;
429+ struct Vertex *vertices;
430430
431- sw = src_rect->right - src_rect->left;
432- dw = dst_rect->right - dst_rect->left;
433- sh = src_rect->bottom - src_rect->top;
434- dh = dst_rect->bottom - dst_rect->top;
431+ sw = src_rect->right - src_rect->left;
432+ dw = dst_rect->right - dst_rect->left;
433+ sh = src_rect->bottom - src_rect->top;
434+ dh = dst_rect->bottom - dst_rect->top;
435435
436- sceGuStart(GU_DIRECT, gulist);
436+ sceGuStart(GU_DIRECT, gulist);
437437
438- sceGuDrawBufferList(dst_fmt, dst, BUF_WIDTH);
439- sceGuScissor(dst_rect->left, dst_rect->top, dst_rect->right, dst_rect->bottom);
438+ sceGuDrawBufferList(dst_fmt, dst, BUF_WIDTH);
439+ sceGuScissor(dst_rect->left, dst_rect->top, dst_rect->right, dst_rect->bottom);
440440
441- sceGuTexMode(src_fmt, 0, 0, GU_FALSE);
442- sceGuTexImage(0, BUF_WIDTH, BUF_WIDTH, BUF_WIDTH, GU_FRAME_ADDR(src));
443- sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGBA);
444- if (sw == dw && sh == dh)
445- sceGuTexFilter(GU_NEAREST, GU_NEAREST);
446- else
447- sceGuTexFilter(GU_LINEAR, GU_LINEAR);
441+ sceGuTexMode(src_fmt, 0, 0, GU_FALSE);
442+ sceGuTexImage(0, BUF_WIDTH, BUF_WIDTH, BUF_WIDTH, GU_FRAME_ADDR(src));
443+ sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGBA);
444+ if (sw == dw && sh == dh)
445+ sceGuTexFilter(GU_NEAREST, GU_NEAREST);
446+ else
447+ sceGuTexFilter(GU_LINEAR, GU_LINEAR);
448448
449- for (j = 0; (j + SLICE_SIZE) < sw; j = j + SLICE_SIZE)
450- {
451- vertices = (struct Vertex *)sceGuGetMemory(2 * sizeof(struct Vertex));
449+ for (j = 0; (j + SLICE_SIZE) < sw; j = j + SLICE_SIZE)
450+ {
451+ vertices = (struct Vertex *)sceGuGetMemory(2 * sizeof(struct Vertex));
452452
453- vertices[0].u = src_rect->left + j;
454- vertices[0].v = src_rect->top;
455- vertices[0].x = dst_rect->left + j * dw / sw;
456- vertices[0].y = dst_rect->top;
453+ vertices[0].u = src_rect->left + j;
454+ vertices[0].v = src_rect->top;
455+ vertices[0].x = dst_rect->left + j * dw / sw;
456+ vertices[0].y = dst_rect->top;
457457
458- vertices[1].u = src_rect->left + j + SLICE_SIZE;
459- vertices[1].v = src_rect->bottom;
460- vertices[1].x = dst_rect->left + (j + SLICE_SIZE) * dw / sw;
461- vertices[1].y = dst_rect->bottom;
458+ vertices[1].u = src_rect->left + j + SLICE_SIZE;
459+ vertices[1].v = src_rect->bottom;
460+ vertices[1].x = dst_rect->left + (j + SLICE_SIZE) * dw / sw;
461+ vertices[1].y = dst_rect->bottom;
462462
463- sceGuDrawArray(GU_SPRITES, TEXTURE_FLAGS, 2, NULL, vertices);
464- }
463+ sceGuDrawArray(GU_SPRITES, TEXTURE_FLAGS, 2, NULL, vertices);
464+ }
465465
466- if (j < sw)
467- {
468- vertices = (struct Vertex *)sceGuGetMemory(2 * sizeof(struct Vertex));
466+ if (j < sw)
467+ {
468+ vertices = (struct Vertex *)sceGuGetMemory(2 * sizeof(struct Vertex));
469469
470- vertices[0].u = src_rect->left + j;
471- vertices[0].v = src_rect->top;
472- vertices[0].x = dst_rect->left + j * dw / sw;
473- vertices[0].y = dst_rect->top;
470+ vertices[0].u = src_rect->left + j;
471+ vertices[0].v = src_rect->top;
472+ vertices[0].x = dst_rect->left + j * dw / sw;
473+ vertices[0].y = dst_rect->top;
474474
475- vertices[1].u = src_rect->right;
476- vertices[1].v = src_rect->bottom;
477- vertices[1].x = dst_rect->right;
478- vertices[1].y = dst_rect->bottom;
475+ vertices[1].u = src_rect->right;
476+ vertices[1].v = src_rect->bottom;
477+ vertices[1].x = dst_rect->right;
478+ vertices[1].y = dst_rect->bottom;
479479
480- sceGuDrawArray(GU_SPRITES, TEXTURE_FLAGS, 2, NULL, vertices);
481- }
480+ sceGuDrawArray(GU_SPRITES, TEXTURE_FLAGS, 2, NULL, vertices);
481+ }
482482
483- sceGuFinish();
484- sceGuSync(0, GU_SYNC_FINISH);
483+ sceGuFinish();
484+ sceGuSync(0, GU_SYNC_FINISH);
485485 }
486486
487487 /*--------------------------------------------------------
488- 文字列表示
488+ 文字列表示
489489 --------------------------------------------------------*/
490490
491491 void mh_start(void)
492492 {
493- sceGuStart(GU_DIRECT, gulist);
494- sceGuDrawBufferList(GU_PSM_4444, draw_frame, BUF_WIDTH);
493+ sceGuStart(GU_DIRECT, gulist);
494+ sceGuDrawBufferList(GU_PSM_4444, draw_frame, BUF_WIDTH);
495495 }
496496
497497 void mh_print(int x,int y,const char *str,unsigned int color)
498498 {
499499 intraFontSetStyle(jpn0, 0.6f, color, 0, 0);
500- intraFontPrint(jpn0, x, y + 12, str);
500+ intraFontPrint(jpn0, x, y + 12, str);
501501 }
502502
503503 void mh_end(void)
504504 {
505- sceGuFinish();
506- sceGuSync(0, GU_SYNC_FINISH);
505+ sceGuFinish();
506+ sceGuSync(0, GU_SYNC_FINISH);
507507 }
508508
509509 void mh_print_num(int x, int y, int num, unsigned short color)
510510 {
511- int i, j, n, val[4];
512- unsigned char ch, *ft;
513- unsigned short* vr;
514- unsigned short *vp;
511+ int i, j, n, val[4];
512+ unsigned char ch, *ft;
513+ unsigned short* vr;
514+ unsigned short *vp;
515515
516- if (num < 10)
517- {
518- n = 2;
519- val[0] = num;
520- val[1] = 0;
521- }
522- else if (num < 100)
523- {
524- n = 2;
525- val[0] = num % 10;
526- val[1] = num / 10;
527- }
528- else if (num < 1000)
529- {
530- n = 3;
531- val[0] = num % 10;
532- num /= 10;
533- val[1] = num % 10;
534- val[2] = num / 10;
535- }
536- else if (num < 10000)
537- {
538- n = 4;
539- val[0] = num % 10;
540- num /= 10;
541- val[1] = num % 10;
542- num /= 10;
543- val[2] = num % 10;
544- val[3] = num / 10;
545- }
546- else return;
547- while (n--)
548- {
549- ft = (unsigned char*)font + ((val[n]+'0') << 3);
550- vr = video_frame_addr(tex_frame, x, y);
551- for (i = 0; i < 8; i++)
552- {
553- vp = vr;
554- ch = 0x80;
555- for (j = 0; j < 8; j++)
556- {
557- if (*ft & ch)
558- {
559- *vp++ = 0xFFFF;
560- }
561- else
562- {
563- *vp++ = 0x8000;
564- }
565- ch >>= 1;
566- }
567- ft++;
568- vr += BUF_WIDTH;
569- }
570- x += 8;
571- }
516+ if (num < 10)
517+ {
518+ n = 2;
519+ val[0] = num;
520+ val[1] = 0;
521+ }
522+ else if (num < 100)
523+ {
524+ n = 2;
525+ val[0] = num % 10;
526+ val[1] = num / 10;
527+ }
528+ else if (num < 1000)
529+ {
530+ n = 3;
531+ val[0] = num % 10;
532+ num /= 10;
533+ val[1] = num % 10;
534+ val[2] = num / 10;
535+ }
536+ else if (num < 10000)
537+ {
538+ n = 4;
539+ val[0] = num % 10;
540+ num /= 10;
541+ val[1] = num % 10;
542+ num /= 10;
543+ val[2] = num % 10;
544+ val[3] = num / 10;
545+ }
546+ else return;
547+ while (n--)
548+ {
549+ ft = (unsigned char*)font + ((val[n]+'0') << 3);
550+ vr = video_frame_addr(tex_frame, x, y);
551+ for (i = 0; i < 8; i++)
552+ {
553+ vp = vr;
554+ ch = 0x80;
555+ for (j = 0; j < 8; j++)
556+ {
557+ if (*ft & ch)
558+ {
559+ *vp++ = 0xFFFF;
560+ }
561+ else
562+ {
563+ *vp++ = 0x8000;
564+ }
565+ ch >>= 1;
566+ }
567+ ft++;
568+ vr += BUF_WIDTH;
569+ }
570+ x += 8;
571+ }
572572 }
Show on old repository browser