FreeCalypso > hg > tcs211-pirelli
comparison chipsetsw/drivers/drv_app/r2d/lcds/R2D_vertical_lcd_i.c @ 0:509db1a7b7b8
initial import: leo2moko-r1
author | Space Falcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Mon, 01 Jun 2015 03:24:05 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:509db1a7b7b8 |
---|---|
1 #if (R2D_PIXEL_DEPTH == 32) | |
2 #define R2D_PIXEL_DOWN_OUT(a) (0) | |
3 #define R2D_PIXEL_UP_OUT(a) (0) | |
4 #else | |
5 #define R2D_PIXEL_DOWN_OUT(a) (a>>R2D_PIXEL_DEPTH) | |
6 #define R2D_PIXEL_UP_OUT(a) (a<<R2D_PIXEL_DEPTH) | |
7 #endif | |
8 | |
9 #if (R2D_ASM == R2D_ON) | |
10 | |
11 // All below global are modified in the context of a blit_rect and | |
12 // the use of the self modifying blit_rect is protected by | |
13 // a semaphore | |
14 | |
15 extern T_R2D_DRAWING_MODE r2d_g_old_mode; | |
16 extern R2D_BOOLEAN r2d_g_old_use_foreground; | |
17 extern INT32 r2d_g_old_srcdst; | |
18 extern UINT32 r2d_g_old_foreground_pixelvalue; | |
19 extern UINT32 r2d_g_old_background_pixelvalue; | |
20 | |
21 extern void r2d_blit_la(UINT32 *a); | |
22 extern void r2d_blit_lb(UINT32 *a); | |
23 | |
24 #endif | |
25 | |
26 extern BOOLEAN IND_r2d_color_framebuffer_foreground_pixel(UINT32 lcd_value,T_R2D_GC_PTR src_gc); | |
27 | |
28 | |
29 #define r2d_get_texture_color() ((T_R2D_ANCHORED_TEXTURE*)(gc->background_texture))->pattern[((x-gc->s_org_x)&texture_mask)*texture_size+((ty-gc->s_org_y)&texture_mask)] | |
30 | |
31 | |
32 | |
33 | |
34 | |
35 | |
36 void r2d_write_lcd_line(T_R2D_GC* gc,INT16 x,INT16 y,INT16 nb,R2D_BOOLEAN background) | |
37 { | |
38 UINT32 *p; | |
39 UINT16 tmp,ty; | |
40 // UINT32 temp; | |
41 UINT32 pixel_cache,pixel_value; | |
42 INT16 current_y,count; | |
43 UINT32 new_value,current_value; | |
44 T_R2D_DRAWING_OP dop; | |
45 INT16 texture_mask,texture_size; | |
46 | |
47 ty=y; // True y | |
48 | |
49 if (gc->background_texture!=NULL) | |
50 { | |
51 texture_mask=~((-1)<<gc->background_texture->size); | |
52 texture_size=1<<gc->background_texture->size; | |
53 } | |
54 | |
55 dop=gc->drawing_op; | |
56 | |
57 if (nb==0) | |
58 goto r2d_fail_line; | |
59 | |
60 p=((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->p_memory_words; | |
61 | |
62 switch(((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->kind) | |
63 { | |
64 case 0:// LCD format with hard coded dimensions | |
65 | |
66 { | |
67 | |
68 // Get position of the memory word containing the pixel | |
69 #if (R2D_REFRESH == R2D_VERTICAL) | |
70 p+=((x*R2D_MWHEIGHT+(y>>R2D_PIXELS_PER_MEMORY_WORD))); | |
71 #else | |
72 p+=((x*R2D_MWWIDTH+(y>>R2D_PIXELS_PER_MEMORY_WORD))); | |
73 #endif | |
74 | |
75 if ((y<0) || (x<0) || ((p<((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->p_memory_words) | |
76 || (p>((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->p_frame_buffer_end))) | |
77 { | |
78 #if (R2D_DEBUG == R2D_ON) | |
79 //printf("Error : frame_buffer overflow\n"); | |
80 IND_rvf_send_trace("R2D : Framebuffer overflow",26, NULL_PARAM, | |
81 RV_TRACE_LEVEL_ERROR, R2D_USE_ID ); | |
82 | |
83 #endif | |
84 goto r2d_fail_line; | |
85 } | |
86 | |
87 | |
88 | |
89 // Get the pixel position into the memory word | |
90 new_value=0; | |
91 y=y & R2D_WORD_POSITION_MASK; | |
92 y=y << R2D_PIXEL_POS_TO_BIT_POS; | |
93 pixel_cache=*p; | |
94 current_y=0; | |
95 current_value=pixel_cache; | |
96 if (y!=0) | |
97 { | |
98 do | |
99 { | |
100 new_value =R2D_PIXEL_DOWN_OUT(new_value); | |
101 new_value|=((current_value & R2D_PIXEL_MASK) | |
102 << ((1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH)) ; | |
103 current_value=R2D_PIXEL_DOWN_OUT(current_value); | |
104 current_y+=(1<<R2D_PIXEL_POS_TO_BIT_POS); | |
105 } while (current_y != y); | |
106 } | |
107 count=0; | |
108 #if (R2D_DITHERING == R2D_OFF) | |
109 if (background) | |
110 pixel_value=((T_R2D_GC*)gc)->background_pixel_value; | |
111 else | |
112 pixel_value=((T_R2D_GC*)gc)->foreground_pixel_value; | |
113 #endif | |
114 do | |
115 { | |
116 #if (R2D_DITHERING == R2D_ON) | |
117 if (background) | |
118 { | |
119 if (gc->background_texture!=NULL) | |
120 pixel_value=r2d_get_texture_color(); | |
121 else | |
122 pixel_value=r2d_get_dithering_matrix_entry(((T_R2D_GC*)gc)->p_background_dithered_cache,x,ty); | |
123 | |
124 } | |
125 else | |
126 pixel_value=r2d_get_dithering_matrix_entry(((T_R2D_GC*)gc)->p_foreground_dithered_cache,x,ty); | |
127 #endif | |
128 | |
129 #if (R2D_DITHERING == R2D_OFF) | |
130 if ((background) && (gc->background_texture!=NULL)) | |
131 pixel_value=r2d_get_texture_color(); | |
132 #endif | |
133 | |
134 ty++; | |
135 | |
136 new_value =R2D_PIXEL_DOWN_OUT(new_value); | |
137 | |
138 new_value|=((dop(current_value & R2D_PIXEL_MASK,pixel_value) & R2D_PIXEL_MASK) | |
139 << ((1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH)) ; | |
140 current_value=R2D_PIXEL_DOWN_OUT(current_value); | |
141 current_y+=(1<<R2D_PIXEL_POS_TO_BIT_POS); | |
142 if (current_y==(1<<R2D_MEMORY_WORD)) | |
143 { | |
144 current_y=0; | |
145 *p++=new_value; | |
146 current_value=*p; | |
147 } | |
148 count++; | |
149 } while (count<nb); | |
150 | |
151 while(current_y != (1<<R2D_MEMORY_WORD)) | |
152 { | |
153 new_value =R2D_PIXEL_DOWN_OUT(new_value) ; | |
154 new_value|=((current_value & R2D_PIXEL_MASK) | |
155 << ((1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH)) ; | |
156 current_value=R2D_PIXEL_DOWN_OUT(current_value); | |
157 current_y+=(1<<R2D_PIXEL_POS_TO_BIT_POS); | |
158 } | |
159 *p++=new_value; | |
160 | |
161 } | |
162 break; | |
163 case R2D_LCD_KIND: // LCD format with any size | |
164 { | |
165 INT16 height,width; | |
166 height=((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->height; | |
167 width=((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->width; | |
168 | |
169 // Get position of the memory word containing the pixel | |
170 #if (R2D_REFRESH == R2D_VERTICAL) | |
171 p+=((x*R2D_ALIGNED_MWLENGTH(height)+(y>>R2D_PIXELS_PER_MEMORY_WORD))); | |
172 #else | |
173 p+=((x*R2D_ALIGNED_MWLENGTH(width)+(y>>R2D_PIXELS_PER_MEMORY_WORD))); | |
174 #endif | |
175 | |
176 if ((y<0) || (x<0) || ((p<((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->p_memory_words) | |
177 || (p>((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->p_frame_buffer_end))) | |
178 { | |
179 #if (R2D_DEBUG == R2D_ON) | |
180 IND_rvf_send_trace("R2D : Framebuffer overflow",26, NULL_PARAM, | |
181 RV_TRACE_LEVEL_ERROR, R2D_USE_ID ); | |
182 #endif | |
183 goto r2d_fail_line; | |
184 } | |
185 | |
186 | |
187 | |
188 // Get the pixel position into the memory word | |
189 new_value=0; | |
190 y=y & R2D_WORD_POSITION_MASK; | |
191 y=y << R2D_PIXEL_POS_TO_BIT_POS; | |
192 pixel_cache=*p; | |
193 current_y=0; | |
194 current_value=pixel_cache; | |
195 if (y!=0) | |
196 { | |
197 do | |
198 { | |
199 new_value =R2D_PIXEL_DOWN_OUT(new_value) ; | |
200 new_value|=((current_value & R2D_PIXEL_MASK) | |
201 << ((1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH)) ; | |
202 current_value=R2D_PIXEL_DOWN_OUT(current_value); | |
203 current_y+=(1<<R2D_PIXEL_POS_TO_BIT_POS); | |
204 } while (current_y != y); | |
205 } | |
206 count=0; | |
207 #if (R2D_DITHERING == R2D_OFF) | |
208 if (background) | |
209 pixel_value=((T_R2D_GC*)gc)->background_pixel_value; | |
210 else | |
211 pixel_value=((T_R2D_GC*)gc)->foreground_pixel_value; | |
212 #endif | |
213 do | |
214 { | |
215 #if (R2D_DITHERING == R2D_ON) | |
216 if (background) | |
217 if (gc->background_texture!=NULL) | |
218 pixel_value=r2d_get_texture_color(); | |
219 else | |
220 pixel_value=r2d_get_dithering_matrix_entry(((T_R2D_GC*)gc)->p_background_dithered_cache,x,ty); | |
221 else | |
222 pixel_value=r2d_get_dithering_matrix_entry(((T_R2D_GC*)gc)->p_foreground_dithered_cache,x,ty); | |
223 #endif | |
224 | |
225 #if (R2D_DITHERING == R2D_OFF) | |
226 if ((background) && (gc->background_texture!=NULL)) | |
227 pixel_value=r2d_get_texture_color(); | |
228 #endif | |
229 | |
230 ty++; | |
231 | |
232 new_value =R2D_PIXEL_DOWN_OUT(new_value); | |
233 new_value|=((dop(current_value & R2D_PIXEL_MASK,pixel_value) & R2D_PIXEL_MASK) | |
234 << ((1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH)) ; | |
235 current_value=R2D_PIXEL_DOWN_OUT(current_value); | |
236 current_y+=(1<<R2D_PIXEL_POS_TO_BIT_POS); | |
237 if (current_y==(1<<R2D_MEMORY_WORD)) | |
238 { | |
239 current_y=0; | |
240 *p++=new_value; | |
241 current_value=*p; | |
242 } | |
243 count++; | |
244 } while (count<nb); | |
245 | |
246 while(current_y != (1<<R2D_MEMORY_WORD)) | |
247 { | |
248 new_value =R2D_PIXEL_DOWN_OUT(new_value); | |
249 new_value|=((current_value & R2D_PIXEL_MASK) | |
250 << ((1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH)) ; | |
251 current_value=R2D_PIXEL_DOWN_OUT(current_value); | |
252 current_y+=(1<<R2D_PIXEL_POS_TO_BIT_POS); | |
253 } | |
254 *p++=new_value; | |
255 | |
256 | |
257 } | |
258 break; | |
259 | |
260 case R2D_FULL_KIND: // LCD format with any size | |
261 { | |
262 INT16 height,width; | |
263 height=((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->height; | |
264 width=((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->width; | |
265 | |
266 | |
267 // Get position of the memory word containing the pixel | |
268 #if (R2D_REFRESH == R2D_VERTICAL) | |
269 p+=((x*height+y)); | |
270 #else | |
271 p+=((x*width+y)); | |
272 #endif | |
273 | |
274 if ((y<0) || (x<0) || ((p<((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->p_memory_words) | |
275 || (p>((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->p_frame_buffer_end))) | |
276 { | |
277 #if (R2D_DEBUG == R2D_ON) | |
278 IND_rvf_send_trace("R2D : Framebuffer overflow",26, NULL_PARAM, | |
279 RV_TRACE_LEVEL_ERROR, R2D_USE_ID ); | |
280 #endif | |
281 goto r2d_fail_line; | |
282 } | |
283 | |
284 | |
285 | |
286 // Get the pixel position into the memory word | |
287 y=0; | |
288 new_value=0; | |
289 pixel_cache=*p; | |
290 current_y=0; | |
291 current_value=pixel_cache; | |
292 count=0; | |
293 if (background) | |
294 { | |
295 pixel_value=((T_R2D_GC*)gc)->background_pixel_value; | |
296 } | |
297 else | |
298 { | |
299 pixel_value=((T_R2D_GC*)gc)->foreground_pixel_value; | |
300 } | |
301 | |
302 do | |
303 { | |
304 | |
305 if ((background) && (gc->background_texture!=NULL)) | |
306 pixel_value=r2d_get_texture_color(); | |
307 | |
308 ty++; | |
309 new_value=dop(current_value,pixel_value); | |
310 current_y=0; | |
311 *p++=new_value; | |
312 current_value=*p; | |
313 count++; | |
314 } while (count<nb); | |
315 | |
316 | |
317 | |
318 } | |
319 break; | |
320 } | |
321 r2d_fail_line:tmp=0; // Just because one needs code after a label | |
322 } | |
323 | |
324 void r2d_arc_write_lcd_line(T_R2D_GC* gc,INT16 x,INT16 y, | |
325 INT16 org_x,INT16 org_y,INT16 nb, | |
326 T_R2D_ARC_REGION *rgn,R2D_BOOLEAN background) | |
327 { | |
328 UINT32 *p; | |
329 UINT16 tmp,ty; | |
330 // UINT32 temp; | |
331 UINT32 pixel_cache,pixel_value; | |
332 INT32 current_y,count; | |
333 UINT32 new_value,current_value; | |
334 T_R2D_DRAWING_OP dop; | |
335 INT16 texture_mask,texture_size; | |
336 INT32 sides,sidee; | |
337 BOOLEAN start_filling=FALSE; | |
338 | |
339 sides=r2d_get_point_side((INT16)(x-org_x),(INT16)(y-org_y),rgn->sa,rgn->sb); | |
340 sidee=r2d_get_point_side((INT16)(x-org_x),(INT16)(y-org_y),rgn->ea,rgn->eb); | |
341 | |
342 ty=y; // True y | |
343 | |
344 if (gc->background_texture!=NULL) | |
345 { | |
346 texture_mask=~((-1)<<gc->background_texture->size); | |
347 texture_size=1<<gc->background_texture->size; | |
348 } | |
349 | |
350 dop=gc->drawing_op; | |
351 | |
352 if (nb==0) | |
353 goto r2d_fail_line; | |
354 | |
355 p=((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->p_memory_words; | |
356 | |
357 switch(((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->kind) | |
358 { | |
359 case 0:// LCD format with hard coded dimensions | |
360 | |
361 { | |
362 | |
363 // Get position of the memory word containing the pixel | |
364 #if (R2D_REFRESH == R2D_VERTICAL) | |
365 p+=((x*R2D_MWHEIGHT+(y>>R2D_PIXELS_PER_MEMORY_WORD))); | |
366 #else | |
367 p+=((x*R2D_MWWIDTH+(y>>R2D_PIXELS_PER_MEMORY_WORD))); | |
368 #endif | |
369 | |
370 if ((y<0) || (x<0) || ((p<((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->p_memory_words) | |
371 || (p>((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->p_frame_buffer_end))) | |
372 { | |
373 #if (R2D_DEBUG == R2D_ON) | |
374 //printf("Error : frame_buffer overflow\n"); | |
375 IND_rvf_send_trace("R2D : Framebuffer overflow",26, NULL_PARAM, | |
376 RV_TRACE_LEVEL_ERROR, R2D_USE_ID ); | |
377 | |
378 #endif | |
379 goto r2d_fail_line; | |
380 } | |
381 | |
382 | |
383 | |
384 // Get the pixel position into the memory word | |
385 new_value=0; | |
386 y=y & R2D_WORD_POSITION_MASK; | |
387 y=y << R2D_PIXEL_POS_TO_BIT_POS; | |
388 pixel_cache=*p; | |
389 current_y=0; | |
390 current_value=pixel_cache; | |
391 if (y!=0) | |
392 { | |
393 do | |
394 { | |
395 new_value =R2D_PIXEL_DOWN_OUT(new_value); | |
396 new_value|=((current_value & R2D_PIXEL_MASK) | |
397 << ((1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH)) ; | |
398 current_value=R2D_PIXEL_DOWN_OUT(current_value); | |
399 current_y+=(1<<R2D_PIXEL_POS_TO_BIT_POS); | |
400 } while (current_y != y); | |
401 } | |
402 count=0; | |
403 #if (R2D_DITHERING == R2D_OFF) | |
404 if (background) | |
405 pixel_value=((T_R2D_GC*)gc)->background_pixel_value; | |
406 else | |
407 pixel_value=((T_R2D_GC*)gc)->foreground_pixel_value; | |
408 #endif | |
409 do | |
410 { | |
411 #if (R2D_DITHERING == R2D_ON) | |
412 if (background) | |
413 { | |
414 if (gc->background_texture!=NULL) | |
415 pixel_value=r2d_get_texture_color(); | |
416 else | |
417 pixel_value=r2d_get_dithering_matrix_entry(((T_R2D_GC*)gc)->p_background_dithered_cache,x,ty); | |
418 | |
419 } | |
420 else | |
421 pixel_value=r2d_get_dithering_matrix_entry(((T_R2D_GC*)gc)->p_foreground_dithered_cache,x,ty); | |
422 #endif | |
423 | |
424 #if (R2D_DITHERING == R2D_OFF) | |
425 if ((background) && (gc->background_texture!=NULL)) | |
426 pixel_value=r2d_get_texture_color(); | |
427 #endif | |
428 | |
429 | |
430 | |
431 new_value =R2D_PIXEL_DOWN_OUT(new_value); | |
432 | |
433 if ( | |
434 ((rgn->one_sector==0) && (sides>=0) && (sidee>=0)) | |
435 || | |
436 ((rgn->one_sector==1) && (!(!(sides>=0) && !(sidee>=0)))) | |
437 || (rgn->one_sector==2) | |
438 ) | |
439 { | |
440 if (rgn->one_sector==0) | |
441 start_filling=TRUE; | |
442 new_value|=((dop(current_value & R2D_PIXEL_MASK,pixel_value) & R2D_PIXEL_MASK) | |
443 << ((1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH)) ; | |
444 } | |
445 else | |
446 { | |
447 if (start_filling) | |
448 goto r2d_fail_line; | |
449 new_value|=(current_value & R2D_PIXEL_MASK) | |
450 << ((1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH) ; | |
451 } | |
452 | |
453 ty++; | |
454 sides+=-(rgn->sa>>1); | |
455 sidee+=-(rgn->ea>>1); | |
456 | |
457 current_value=R2D_PIXEL_DOWN_OUT(current_value); | |
458 current_y+=(1<<R2D_PIXEL_POS_TO_BIT_POS); | |
459 if (current_y==(1<<R2D_MEMORY_WORD)) | |
460 { | |
461 current_y=0; | |
462 *p++=new_value; | |
463 current_value=*p; | |
464 } | |
465 count++; | |
466 } while (count<nb); | |
467 | |
468 while(current_y != (1<<R2D_MEMORY_WORD)) | |
469 { | |
470 new_value =R2D_PIXEL_DOWN_OUT(new_value) ; | |
471 new_value|=((current_value & R2D_PIXEL_MASK) | |
472 << ((1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH)) ; | |
473 current_value=R2D_PIXEL_DOWN_OUT(current_value); | |
474 current_y+=(1<<R2D_PIXEL_POS_TO_BIT_POS); | |
475 } | |
476 *p++=new_value; | |
477 | |
478 } | |
479 break; | |
480 case R2D_LCD_KIND: // LCD format with any size | |
481 { | |
482 INT16 height,width; | |
483 height=((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->height; | |
484 width=((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->width; | |
485 | |
486 // Get position of the memory word containing the pixel | |
487 #if (R2D_REFRESH == R2D_VERTICAL) | |
488 p+=((x*R2D_ALIGNED_MWLENGTH(height)+(y>>R2D_PIXELS_PER_MEMORY_WORD))); | |
489 #else | |
490 p+=((x*R2D_ALIGNED_MWLENGTH(width)+(y>>R2D_PIXELS_PER_MEMORY_WORD))); | |
491 #endif | |
492 | |
493 if ((y<0) || (x<0) || ((p<((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->p_memory_words) | |
494 || (p>((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->p_frame_buffer_end))) | |
495 { | |
496 #if (R2D_DEBUG == R2D_ON) | |
497 IND_rvf_send_trace("R2D : Framebuffer overflow",26, NULL_PARAM, | |
498 RV_TRACE_LEVEL_ERROR, R2D_USE_ID ); | |
499 #endif | |
500 goto r2d_fail_line; | |
501 } | |
502 | |
503 | |
504 | |
505 // Get the pixel position into the memory word | |
506 new_value=0; | |
507 y=y & R2D_WORD_POSITION_MASK; | |
508 y=y << R2D_PIXEL_POS_TO_BIT_POS; | |
509 pixel_cache=*p; | |
510 current_y=0; | |
511 current_value=pixel_cache; | |
512 if (y!=0) | |
513 { | |
514 do | |
515 { | |
516 new_value =R2D_PIXEL_DOWN_OUT(new_value) ; | |
517 new_value|=((current_value & R2D_PIXEL_MASK) | |
518 << ((1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH)) ; | |
519 current_value=R2D_PIXEL_DOWN_OUT(current_value); | |
520 current_y+=(1<<R2D_PIXEL_POS_TO_BIT_POS); | |
521 } while (current_y != y); | |
522 } | |
523 count=0; | |
524 #if (R2D_DITHERING == R2D_OFF) | |
525 if (background) | |
526 pixel_value=((T_R2D_GC*)gc)->background_pixel_value; | |
527 else | |
528 pixel_value=((T_R2D_GC*)gc)->foreground_pixel_value; | |
529 #endif | |
530 do | |
531 { | |
532 #if (R2D_DITHERING == R2D_ON) | |
533 if (background) | |
534 if (gc->background_texture!=NULL) | |
535 pixel_value=r2d_get_texture_color(); | |
536 else | |
537 pixel_value=r2d_get_dithering_matrix_entry(((T_R2D_GC*)gc)->p_background_dithered_cache,x,ty); | |
538 else | |
539 pixel_value=r2d_get_dithering_matrix_entry(((T_R2D_GC*)gc)->p_foreground_dithered_cache,x,ty); | |
540 #endif | |
541 | |
542 #if (R2D_DITHERING == R2D_OFF) | |
543 if ((background) && (gc->background_texture!=NULL)) | |
544 pixel_value=r2d_get_texture_color(); | |
545 #endif | |
546 | |
547 | |
548 | |
549 new_value =R2D_PIXEL_DOWN_OUT(new_value); | |
550 | |
551 if ( | |
552 ((rgn->one_sector==0) && (sides>=0) && (sidee>=0)) | |
553 || | |
554 ((rgn->one_sector==1) && (!(!(sides>=0) && !(sidee>=0)))) | |
555 || (rgn->one_sector==2) | |
556 ) | |
557 { | |
558 if (rgn->one_sector==0) | |
559 start_filling=TRUE; | |
560 new_value|=((dop(current_value & R2D_PIXEL_MASK,pixel_value) & R2D_PIXEL_MASK) | |
561 << ((1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH)) ; | |
562 } | |
563 else | |
564 { | |
565 if (start_filling) | |
566 goto r2d_fail_line; | |
567 new_value|=((current_value & R2D_PIXEL_MASK) | |
568 << ((1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH)) ; | |
569 } | |
570 ty++; | |
571 sides+=-(rgn->sa>>1); | |
572 sidee+=-(rgn->ea>>1); | |
573 | |
574 current_value=R2D_PIXEL_DOWN_OUT(current_value); | |
575 current_y+=(1<<R2D_PIXEL_POS_TO_BIT_POS); | |
576 if (current_y==(1<<R2D_MEMORY_WORD)) | |
577 { | |
578 current_y=0; | |
579 *p++=new_value; | |
580 current_value=*p; | |
581 } | |
582 count++; | |
583 } while (count<nb); | |
584 | |
585 while(current_y != (1<<R2D_MEMORY_WORD)) | |
586 { | |
587 new_value =R2D_PIXEL_DOWN_OUT(new_value); | |
588 new_value|=((current_value & R2D_PIXEL_MASK) | |
589 << ((1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH)) ; | |
590 current_value=R2D_PIXEL_DOWN_OUT(current_value); | |
591 current_y+=(1<<R2D_PIXEL_POS_TO_BIT_POS); | |
592 } | |
593 *p++=new_value; | |
594 | |
595 | |
596 } | |
597 break; | |
598 | |
599 case R2D_FULL_KIND: // LCD format with any size | |
600 { | |
601 INT16 height,width; | |
602 height=((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->height; | |
603 width=((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->width; | |
604 | |
605 | |
606 // Get position of the memory word containing the pixel | |
607 #if (R2D_REFRESH == R2D_VERTICAL) | |
608 p+=((x*height+y)); | |
609 #else | |
610 p+=((x*width+y)); | |
611 #endif | |
612 | |
613 if ((y<0) || (x<0) || ((p<((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->p_memory_words) | |
614 || (p>((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->p_frame_buffer_end))) | |
615 { | |
616 #if (R2D_DEBUG == R2D_ON) | |
617 IND_rvf_send_trace("R2D : Framebuffer overflow",26, NULL_PARAM, | |
618 RV_TRACE_LEVEL_ERROR, R2D_USE_ID ); | |
619 #endif | |
620 goto r2d_fail_line; | |
621 } | |
622 | |
623 | |
624 | |
625 // Get the pixel position into the memory word | |
626 y=0; | |
627 new_value=0; | |
628 pixel_cache=*p; | |
629 current_y=0; | |
630 current_value=pixel_cache; | |
631 count=0; | |
632 if (background) | |
633 { | |
634 pixel_value=((T_R2D_GC*)gc)->background_pixel_value; | |
635 } | |
636 else | |
637 { | |
638 pixel_value=((T_R2D_GC*)gc)->foreground_pixel_value; | |
639 } | |
640 | |
641 do | |
642 { | |
643 | |
644 if ((background) && (gc->background_texture!=NULL)) | |
645 pixel_value=r2d_get_texture_color(); | |
646 | |
647 | |
648 if ( | |
649 ((rgn->one_sector==0) && (sides>=0) && (sidee>=0)) | |
650 || | |
651 ((rgn->one_sector==1) && (!(!(sides>=0) && !(sidee>=0)))) | |
652 || (rgn->one_sector==2) | |
653 ) | |
654 { | |
655 if (rgn->one_sector==0) | |
656 start_filling=TRUE; | |
657 new_value=dop(current_value,pixel_value); | |
658 } | |
659 else | |
660 { | |
661 if (start_filling) | |
662 goto r2d_fail_line; | |
663 new_value=current_value; | |
664 } | |
665 ty++; | |
666 sides+=-(rgn->sa>>1); | |
667 sidee+=-(rgn->ea>>1); | |
668 | |
669 current_y=0; | |
670 *p++=new_value; | |
671 current_value=*p; | |
672 count++; | |
673 } while (count<nb); | |
674 | |
675 | |
676 | |
677 } | |
678 break; | |
679 } | |
680 r2d_fail_line:tmp=0; // Just because one needs code after a label | |
681 } | |
682 | |
683 // Returns the equivalent color pixel value | |
684 // for the color kind of framebuffer | |
685 // It must be converted to RGB components | |
686 // Don't confuse with r2d_get_pixel_value which is | |
687 // just reading the cached pixel vlue from | |
688 // the graphic context. | |
689 // That routine is extracting the pixel value at position (x,y) | |
690 // from framebuffer | |
691 UINT32 r2d_get_color_pixel_value(T_R2D_GC* gc,INT16 x,INT16 y) | |
692 { | |
693 UINT32 *p; | |
694 // UINT16 tmp; | |
695 UINT32 pixel_cache;//,new_value; | |
696 UINT32 result; | |
697 | |
698 p=((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->p_memory_words; | |
699 | |
700 switch(((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->kind) | |
701 { | |
702 case 0: // LCD format with hard coded dimensions | |
703 { | |
704 // Get position of the memory word containing the pixel | |
705 #if (R2D_REFRESH == R2D_VERTICAL) | |
706 p+=((x*R2D_MWHEIGHT+(y>>R2D_PIXELS_PER_MEMORY_WORD))); | |
707 #else | |
708 p+=((x*R2D_MWWIDTH+(y>>R2D_PIXELS_PER_MEMORY_WORD))); | |
709 #endif | |
710 | |
711 if ((y<0) || (x<0) || ((p<((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->p_memory_words) | |
712 || (p>((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->p_frame_buffer_end))) | |
713 { | |
714 #if (R2D_DEBUG == R2D_ON) | |
715 IND_rvf_send_trace("R2D : Framebuffer overflow",26, NULL_PARAM, | |
716 RV_TRACE_LEVEL_ERROR, R2D_USE_ID ); | |
717 #endif | |
718 goto r2d_fail_get_pixel; | |
719 } | |
720 | |
721 | |
722 // Get the pixel position into the memory word | |
723 y=y & R2D_WORD_POSITION_MASK; | |
724 y=y << R2D_PIXEL_POS_TO_BIT_POS; | |
725 pixel_cache=*p; | |
726 | |
727 result=(pixel_cache >> y) & R2D_PIXEL_MASK; | |
728 return((~IND_r2d_lcd_to_color(result)) & 0x00FFFFFF); | |
729 } | |
730 break; | |
731 case R2D_LCD_KIND: // LCD format with any size | |
732 { | |
733 INT16 height,width; | |
734 height=((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->height; | |
735 width=((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->width; | |
736 | |
737 #if (R2D_REFRESH == R2D_VERTICAL) | |
738 // Get position of the memory word containing the pixel | |
739 p+=((x*R2D_ALIGNED_MWLENGTH(height)+(y>>R2D_PIXELS_PER_MEMORY_WORD))); | |
740 #else | |
741 p+=((x*R2D_ALIGNED_MWLENGTH(width)+(y>>R2D_PIXELS_PER_MEMORY_WORD))); | |
742 #endif | |
743 | |
744 | |
745 if ((y<0) || (x<0) || ((p<((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->p_memory_words) | |
746 || (p>((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->p_frame_buffer_end))) | |
747 { | |
748 #if (R2D_DEBUG == R2D_ON) | |
749 IND_rvf_send_trace("R2D : Framebuffer overflow",26, NULL_PARAM, | |
750 RV_TRACE_LEVEL_ERROR, R2D_USE_ID ); | |
751 #endif | |
752 goto r2d_fail_get_pixel; | |
753 } | |
754 | |
755 | |
756 // Get the pixel position into the memory word | |
757 y=y & R2D_WORD_POSITION_MASK; | |
758 y=y << R2D_PIXEL_POS_TO_BIT_POS; | |
759 pixel_cache=*p; | |
760 | |
761 result=(pixel_cache >> y) & R2D_PIXEL_MASK; | |
762 | |
763 return(~IND_r2d_lcd_to_color(result) & 0x00FFFFFF); | |
764 } | |
765 break; | |
766 case R2D_FULL_KIND: | |
767 { | |
768 INT16 height,width; | |
769 height=((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->height; | |
770 width=((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->width; | |
771 | |
772 //printf("%08X\n",p); | |
773 // Get position of the memory word containing the pixel | |
774 #if (R2D_REFRESH == R2D_VERTICAL) | |
775 p+=(x*height+y); | |
776 #else | |
777 p+=(x*width+y); | |
778 #endif | |
779 | |
780 //printf(" --> %08X for x=%d and y=%d\n",p,x,y); | |
781 | |
782 | |
783 if ((y<0) || (x<0) || ((p<((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->p_memory_words) | |
784 || (p>((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->p_frame_buffer_end))) | |
785 { | |
786 #if (R2D_DEBUG == R2D_ON) | |
787 IND_rvf_send_trace("R2D : Framebuffer overflow",26, NULL_PARAM, | |
788 RV_TRACE_LEVEL_ERROR, R2D_USE_ID ); | |
789 #endif | |
790 goto r2d_fail_get_pixel; | |
791 } | |
792 | |
793 | |
794 // Get the pixel position into the memory word | |
795 y=0; | |
796 pixel_cache=*p; | |
797 | |
798 result=(~pixel_cache) & 0x00FFFFFF; | |
799 } | |
800 break; | |
801 } | |
802 r2d_fail_get_pixel:return(0); | |
803 } | |
804 | |
805 // Low level pixel drawing | |
806 // (Note that for filling a more efficient version is used | |
807 // taking into account the fact that the position | |
808 // in the framebuffer has not to be recomputed from the coordinates | |
809 // for each pixel) | |
810 void r2d_write_lcd_pixel(T_R2D_GC* gc,INT16 x,INT16 y,UINT32 pixel_value) | |
811 { | |
812 UINT32 *p; | |
813 UINT16 tmp; | |
814 UINT32 pixel_cache,new_value; | |
815 T_R2D_DRAWING_OP dop; | |
816 | |
817 dop=gc->drawing_op; | |
818 | |
819 p=((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->p_memory_words; | |
820 | |
821 switch(((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->kind) | |
822 { | |
823 case 0: // LCD format with hard coded dimensions | |
824 { | |
825 // Get position of the memory word containing the pixel | |
826 #if (R2D_REFRESH == R2D_VERTICAL) | |
827 p+=((x*R2D_MWHEIGHT+(y>>R2D_PIXELS_PER_MEMORY_WORD))); | |
828 #else | |
829 p+=((x*R2D_MWWIDTH+(y>>R2D_PIXELS_PER_MEMORY_WORD))); | |
830 #endif | |
831 | |
832 if ((y<0) || (x<0) || ((p<((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->p_memory_words) | |
833 || (p>((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->p_frame_buffer_end))) | |
834 { | |
835 #if (R2D_DEBUG == R2D_ON) | |
836 IND_rvf_send_trace("R2D : Framebuffer overflow",26, NULL_PARAM, | |
837 RV_TRACE_LEVEL_ERROR, R2D_USE_ID ); | |
838 #endif | |
839 goto r2d_fail_pixel; | |
840 } | |
841 | |
842 | |
843 // Get the pixel position into the memory word | |
844 y=y & R2D_WORD_POSITION_MASK; | |
845 y=y << R2D_PIXEL_POS_TO_BIT_POS; | |
846 pixel_cache=*p; | |
847 | |
848 new_value=dop((pixel_cache >> y) & R2D_PIXEL_MASK,pixel_value) & R2D_PIXEL_MASK; | |
849 pixel_cache &= ~(R2D_PIXEL_MASK << y) ; | |
850 | |
851 // Write new value | |
852 pixel_cache |= (new_value << y); | |
853 *p=pixel_cache; | |
854 } | |
855 break; | |
856 case R2D_LCD_KIND: // LCD format with any size | |
857 { | |
858 INT16 height,width; | |
859 height=((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->height; | |
860 width=((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->width; | |
861 | |
862 #if (R2D_REFRESH == R2D_VERTICAL) | |
863 // Get position of the memory word containing the pixel | |
864 p+=((x*R2D_ALIGNED_MWLENGTH(height)+(y>>R2D_PIXELS_PER_MEMORY_WORD))); | |
865 #else | |
866 p+=((x*R2D_ALIGNED_MWLENGTH(width)+(y>>R2D_PIXELS_PER_MEMORY_WORD))); | |
867 #endif | |
868 | |
869 | |
870 if ((y<0) || (x<0) || ((p<((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->p_memory_words) | |
871 || (p>((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->p_frame_buffer_end))) | |
872 { | |
873 #if (R2D_DEBUG == R2D_ON) | |
874 IND_rvf_send_trace("R2D : Framebuffer overflow",26, NULL_PARAM, | |
875 RV_TRACE_LEVEL_ERROR, R2D_USE_ID ); | |
876 #endif | |
877 goto r2d_fail_pixel; | |
878 } | |
879 | |
880 | |
881 // Get the pixel position into the memory word | |
882 y=y & R2D_WORD_POSITION_MASK; | |
883 y=y << R2D_PIXEL_POS_TO_BIT_POS; | |
884 pixel_cache=*p; | |
885 | |
886 new_value=dop((pixel_cache >> y) & R2D_PIXEL_MASK,pixel_value) & R2D_PIXEL_MASK; | |
887 pixel_cache &= ~(R2D_PIXEL_MASK << y) ; | |
888 | |
889 // Write new value | |
890 pixel_cache |= (new_value << y); | |
891 *p=pixel_cache; | |
892 | |
893 } | |
894 break; | |
895 case R2D_FULL_KIND: | |
896 { | |
897 INT16 height,width; | |
898 height=((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->height; | |
899 width=((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->width; | |
900 | |
901 //printf("%08X\n",p); | |
902 // Get position of the memory word containing the pixel | |
903 #if (R2D_REFRESH == R2D_VERTICAL) | |
904 p+=(x*height+y); | |
905 #else | |
906 p+=(x*width+y); | |
907 #endif | |
908 | |
909 //printf(" --> %08X for x=%d and y=%d\n",p,x,y); | |
910 | |
911 | |
912 if ((y<0) || (x<0) || ((p<((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->p_memory_words) | |
913 || (p>((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->p_frame_buffer_end))) | |
914 { | |
915 #if (R2D_DEBUG == R2D_ON) | |
916 IND_rvf_send_trace("R2D : Framebuffer overflow",26, NULL_PARAM, | |
917 RV_TRACE_LEVEL_ERROR, R2D_USE_ID ); | |
918 #endif | |
919 goto r2d_fail_pixel; | |
920 } | |
921 | |
922 | |
923 // Get the pixel position into the memory word | |
924 y=0; | |
925 pixel_cache=*p; | |
926 | |
927 new_value=dop(pixel_cache,pixel_value); | |
928 pixel_cache = new_value; | |
929 *p=pixel_cache; | |
930 } | |
931 break; | |
932 } | |
933 r2d_fail_pixel:tmp=0; // Just because one needs code after a label | |
934 } | |
935 | |
936 | |
937 | |
938 | |
939 #if (R2D_ASM == R2D_OFF) | |
940 | |
941 | |
942 | |
943 // For blitting, two scanning direction are required because of possible | |
944 // overlaps between src and dst | |
945 | |
946 // Shift new pixel from srcstream to dststream using variable srccache | |
947 // as a pixel cache.dstcounter allows to keep track of number | |
948 // of pixels written | |
949 // (scanning direction is down) | |
950 | |
951 #define r2d_shift_pixel_down(dststream,srccache,srccounter,srcstream) {dststream =R2D_PIXEL_DOWN_OUT(dststream); \ | |
952 dststream|=((srccache & R2D_PIXEL_MASK) \ | |
953 << ((1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH)) ; \ | |
954 srccache=R2D_PIXEL_DOWN_OUT(srccache); \ | |
955 srccounter--; \ | |
956 if (srccounter==0) \ | |
957 { \ | |
958 srccounter=(1<<R2D_PIXELS_PER_MEMORY_WORD); \ | |
959 srccache=*++srcstream; \ | |
960 } } | |
961 | |
962 | |
963 // Scanning direction is up | |
964 #define r2d_shift_pixel_up(dststream,srccache,srccounter,srcstream) {dststream =R2D_PIXEL_UP_OUT(dststream); \ | |
965 dststream |=(srccache >> ((1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH)) & R2D_PIXEL_MASK; \ | |
966 srccache=R2D_PIXEL_UP_OUT(srccache); \ | |
967 srccounter--; \ | |
968 if (srccounter==0) \ | |
969 { \ | |
970 srccounter=(1<<R2D_PIXELS_PER_MEMORY_WORD); \ | |
971 srccache=*--srcstream; \ | |
972 } } | |
973 | |
974 #endif | |
975 | |
976 // Check overlap of src and dst rectangle and return the | |
977 // horizontal and vertical scanning direction required to do the | |
978 // blit rect | |
979 | |
980 // A positive value means standard direction (increasing x and increasing y) | |
981 // When that routine is called, both rectangles are expressed in framebuffer | |
982 // coordinates and come from the same framebuffer. | |
983 // The routine is never called if dstGc and srcGc are not using the same framebuffer. | |
984 // | |
985 // INT32 used because of stack bug ? | |
986 void r2d_check_rectangle_overlap(INT16 src_x,INT16 src_y,INT16 dst_x,INT16 dst_y, | |
987 INT32 width,INT32 height, | |
988 INT32 *h_direction,INT32 *v_direction) | |
989 { | |
990 INT16 h,v; | |
991 INT16 rx,ry; | |
992 rx=dst_x-src_x; | |
993 ry=dst_y-src_y; | |
994 | |
995 h=1; | |
996 v=1; | |
997 | |
998 if ((rx>-width) && (rx < width) && (ry>-height) && (ry<height)) | |
999 { | |
1000 if (rx>0) | |
1001 h=-1; | |
1002 else | |
1003 h=1; | |
1004 if (ry>0) | |
1005 v=-1; | |
1006 else | |
1007 v=1; | |
1008 } | |
1009 | |
1010 *h_direction=h; | |
1011 *v_direction=v; | |
1012 } | |
1013 | |
1014 | |
1015 #if (R2D_ASM == R2D_OFF) | |
1016 | |
1017 | |
1018 static UINT32 r2d_get_pixel_value(T_R2D_GC_PTR gc,R2D_BOOLEAN foreground,INT16 x,INT16 y) | |
1019 { | |
1020 UINT32 pixel_value; | |
1021 if (foreground) | |
1022 { | |
1023 #if (R2D_DITHERING == R2D_OFF) | |
1024 pixel_value=((T_R2D_GC*)gc)->foreground_pixel_value; | |
1025 #else | |
1026 pixel_value=r2d_get_dithering_matrix_entry(((T_R2D_GC*)gc)->p_foreground_dithered_cache,x,y); | |
1027 #endif | |
1028 } | |
1029 else | |
1030 { | |
1031 #if (R2D_DITHERING == R2D_OFF) | |
1032 pixel_value=((T_R2D_GC*)gc)->background_pixel_value; | |
1033 #else | |
1034 pixel_value=r2d_get_dithering_matrix_entry(((T_R2D_GC*)gc)->p_background_dithered_cache,x,y); | |
1035 #endif | |
1036 } | |
1037 return(pixel_value); | |
1038 } | |
1039 | |
1040 // When foreground color is used, the source pixel | |
1041 // is converted to the background or foreground color | |
1042 // then dithered | |
1043 static UINT32 r2d_convert_from_lcd_to_lcd(R2D_BOOLEAN use_foreground,UINT32 src,T_R2D_GC_PTR src_gc,T_R2D_GC_PTR dst_gc,INT16 x,INT16 y) | |
1044 { | |
1045 if (use_foreground) | |
1046 { | |
1047 | |
1048 UINT32 pixel_value; | |
1049 if (IND_r2d_lcd_foreground_pixel(src,src_gc)) | |
1050 pixel_value=r2d_get_pixel_value(dst_gc,TRUE,x,y); | |
1051 else | |
1052 pixel_value=r2d_get_pixel_value(dst_gc,FALSE,x,y); | |
1053 | |
1054 return(pixel_value); | |
1055 } | |
1056 else return(src); | |
1057 } | |
1058 | |
1059 static UINT32 r2d_convert_from_color_to_color(R2D_BOOLEAN use_foreground,UINT32 src,T_R2D_GC_PTR src_gc,T_R2D_GC_PTR dst_gc,INT16 x,INT16 y) | |
1060 { | |
1061 if (use_foreground) | |
1062 { | |
1063 | |
1064 UINT32 pixel_value; | |
1065 if (IND_r2d_color_framebuffer_foreground_pixel(src,src_gc)) | |
1066 pixel_value=r2d_get_pixel_value(dst_gc,TRUE,x,y); | |
1067 else | |
1068 pixel_value=r2d_get_pixel_value(dst_gc,FALSE,x,y); | |
1069 | |
1070 return(pixel_value); | |
1071 } | |
1072 else return(src); | |
1073 } | |
1074 | |
1075 | |
1076 static UINT32 r2d_convert_from_color_to_lcd(R2D_BOOLEAN use_foreground,UINT32 src,T_R2D_GC_PTR src_gc,T_R2D_GC_PTR dst_gc,INT16 x,INT16 y) | |
1077 { | |
1078 if (use_foreground) | |
1079 { | |
1080 UINT32 pixel_value; | |
1081 if (IND_r2d_color_framebuffer_foreground_pixel(src,src_gc)) | |
1082 pixel_value=r2d_get_pixel_value(dst_gc,TRUE,x,y); | |
1083 else | |
1084 pixel_value=r2d_get_pixel_value(dst_gc,FALSE,x,y); | |
1085 | |
1086 return(pixel_value); | |
1087 } | |
1088 else return(IND_r2d_color_to_lcd(src,x,y)); | |
1089 } | |
1090 | |
1091 static UINT32 r2d_convert_from_lcd_to_color(R2D_BOOLEAN use_foreground,UINT32 src,T_R2D_GC_PTR src_gc,T_R2D_GC_PTR dst_gc,INT16 x,INT16 y) | |
1092 { | |
1093 if (use_foreground) | |
1094 { | |
1095 UINT32 pixel_value; | |
1096 if (IND_r2d_lcd_foreground_pixel(src,src_gc)) | |
1097 pixel_value=r2d_get_pixel_value(dst_gc,TRUE,x,y); | |
1098 else | |
1099 pixel_value=r2d_get_pixel_value(dst_gc,FALSE,x,y); | |
1100 | |
1101 return(pixel_value); | |
1102 } | |
1103 else | |
1104 { | |
1105 return(IND_r2d_lcd_to_color(src)); | |
1106 } | |
1107 } | |
1108 | |
1109 // FOR DEBUG | |
1110 //#define dop(a,b) b | |
1111 | |
1112 #define r2d_shift_pixel_down_and_write(dst,src) {\ | |
1113 dst##value =R2D_PIXEL_DOWN_OUT(dst##value); \ | |
1114 dst##value|=dop((dst##_current & R2D_PIXEL_MASK), \ | |
1115 r2d_convert_from_lcd_to_lcd(use_foreground_color,\ | |
1116 src##_current & R2D_PIXEL_MASK,src_gc,dst_gc,x,y)) \ | |
1117 << ((1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH) ; \ | |
1118 src##_current=R2D_PIXEL_DOWN_OUT(src##_current); \ | |
1119 dst##_current=R2D_PIXEL_DOWN_OUT(dst##_current); \ | |
1120 dst##counter--; \ | |
1121 src##counter--; \ | |
1122 if (src##counter==0) \ | |
1123 { \ | |
1124 src##counter=(1<<R2D_PIXELS_PER_MEMORY_WORD); \ | |
1125 src##_current=*++p_##src##_current; \ | |
1126 } \ | |
1127 if (dst##counter==0) \ | |
1128 { \ | |
1129 dst##counter=(1<<R2D_PIXELS_PER_MEMORY_WORD); \ | |
1130 } \ | |
1131 } | |
1132 | |
1133 #define r2d_shift_pixel_up_and_write(dst,src) {\ | |
1134 dst##value =R2D_PIXEL_UP_OUT(dst##value); \ | |
1135 dst##value |=dop( \ | |
1136 (dst##_current >> ((1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH)) & R2D_PIXEL_MASK, \ | |
1137 r2d_convert_from_lcd_to_lcd(use_foreground_color,\ | |
1138 (src##_current >> ((1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH)) & R2D_PIXEL_MASK, \ | |
1139 src_gc,dst_gc,x,y)); \ | |
1140 src##_current=R2D_PIXEL_UP_OUT(src##_current); \ | |
1141 dst##_current=R2D_PIXEL_UP_OUT(dst##_current); \ | |
1142 dst##counter--; \ | |
1143 src##counter--; \ | |
1144 if (src##counter==0) \ | |
1145 { \ | |
1146 src##counter=(1<<R2D_PIXELS_PER_MEMORY_WORD); \ | |
1147 src##_current=*--p_##src##_current; \ | |
1148 } \ | |
1149 if (dst##counter==0) \ | |
1150 { \ | |
1151 dst##counter=(1<<R2D_PIXELS_PER_MEMORY_WORD); \ | |
1152 } \ | |
1153 } | |
1154 | |
1155 extern UINT32 r2d_lcd_or_operator(UINT32 old,UINT32 value); | |
1156 // Requires shapes in graphic context coordinates | |
1157 void r2d_blit_lcd_to_lcd(T_R2D_GC_PTR src_gc,T_R2D_GC_PTR dst_gc, | |
1158 T_R2D_SHAPE_PTR src_rectangle, | |
1159 T_R2D_SHAPE_PTR dst_rectangle, | |
1160 R2D_BOOLEAN use_foreground_color) | |
1161 { | |
1162 UINT32 *p_src,*p_dst,*p_src_current,*p_dst_current,*p_src_start,*p_dst_start; | |
1163 INT16 rect_width,rect_height,src_x,src_y,dst_x,dst_y; | |
1164 INT16 src_offset,dst_offset,src_height,dst_height; | |
1165 INT16 xnb,ynb,src_nb_rows,dst_nb_rows; | |
1166 INT16 src_dy,dst_dy,end_dst_dy,end_src_dy; // distance from word boundary | |
1167 // INT16 shift; // relative position (modulo a memory word) between both rectangles | |
1168 // in bits | |
1169 INT16 current_src_dy,current_dst_dy; | |
1170 INT16 temp,dstcounter,srccounter; | |
1171 | |
1172 | |
1173 register UINT32 dstvalue,dst_current; | |
1174 register UINT32 src_current;//srcvalue; | |
1175 INT32 h_direction,v_direction; | |
1176 INT16 x,y; | |
1177 T_R2D_DRAWING_MODE mode; | |
1178 T_R2D_DRAWING_OP dop; | |
1179 BOOLEAN compensate=TRUE; | |
1180 | |
1181 | |
1182 dop=((T_R2D_GC*)dst_gc)->drawing_op; | |
1183 | |
1184 | |
1185 | |
1186 { | |
1187 | |
1188 p_src=((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)src_gc)->p_frame_buffer))->p_memory_words; | |
1189 p_dst=((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)dst_gc)->p_frame_buffer))->p_memory_words; | |
1190 | |
1191 rect_width=r2d_get_xmax(src_rectangle)-r2d_get_xmin(src_rectangle); | |
1192 rect_height=r2d_get_ymax(src_rectangle)-r2d_get_ymin(src_rectangle); | |
1193 if ((rect_width<=0) || (rect_height<=0)) | |
1194 goto end_blit; | |
1195 | |
1196 mode=IND_r2d_get_drawing_mode(dst_gc); | |
1197 | |
1198 | |
1199 src_x=r2d_get_xmin(src_rectangle); | |
1200 src_y=r2d_get_ymin(src_rectangle); | |
1201 | |
1202 dst_x=r2d_get_xmin(dst_rectangle); | |
1203 dst_y=r2d_get_ymin(dst_rectangle); | |
1204 | |
1205 src_dy=(src_y & R2D_WORD_POSITION_MASK); | |
1206 dst_dy=(dst_y & R2D_WORD_POSITION_MASK); | |
1207 | |
1208 // Clipping convention such end_dst_dy is the first y position which must not | |
1209 // be copied at the end of a column | |
1210 //printf("dest y max=%d\n",r2d_get_ymax(dst_rectangle)); | |
1211 end_dst_dy=((r2d_get_ymax(dst_rectangle)-1) & R2D_WORD_POSITION_MASK) ; | |
1212 end_src_dy=((r2d_get_ymax(src_rectangle)-1) & R2D_WORD_POSITION_MASK) ; | |
1213 | |
1214 //printf("dst_dy, end_dst_dy before reverse=%d,%d\n",dst_dy,end_dst_dy); | |
1215 // Number of rows is word containing last point - word containing first point | |
1216 // + 1 | |
1217 | |
1218 // We remove - 1 because last PIXEL is at 1 from the frontier line | |
1219 dst_nb_rows=R2D_ALIGNED_MWLENGTH(r2d_get_ymax(dst_rectangle)-1)-R2D_ALIGNED_MWLENGTH(dst_y)+1; | |
1220 src_nb_rows=R2D_ALIGNED_MWLENGTH(r2d_get_ymax(src_rectangle)-1)-R2D_ALIGNED_MWLENGTH(src_y)+1; | |
1221 | |
1222 //printf("src_nb_rows %d\n",src_nb_rows); | |
1223 //printf("dst_nb_rows %d\n",dst_nb_rows); | |
1224 | |
1225 | |
1226 h_direction=1; | |
1227 v_direction=1; | |
1228 if (((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)src_gc)->p_frame_buffer))== | |
1229 ((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)dst_gc)->p_frame_buffer))) | |
1230 r2d_check_rectangle_overlap(src_x,src_y,dst_x,dst_y, | |
1231 rect_width,rect_height,&h_direction,&v_direction); | |
1232 | |
1233 //printf("h,v=%d,%d\n",h_direction,v_direction); | |
1234 | |
1235 | |
1236 #if (R2D_REFRESH == R2D_VERTICAL) | |
1237 src_height=((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)src_gc)->p_frame_buffer))->height; | |
1238 dst_height=((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)dst_gc)->p_frame_buffer))->height; | |
1239 #else | |
1240 src_height=((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)src_gc)->p_frame_buffer))->width; | |
1241 dst_height=((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)dst_gc)->p_frame_buffer))->width; | |
1242 #endif | |
1243 | |
1244 src_offset=R2D_ALIGNED_MWLENGTH(src_height); | |
1245 dst_offset=R2D_ALIGNED_MWLENGTH(dst_height); | |
1246 | |
1247 //printf("%08X,dst offset=%08X\n",p_dst,dst_offset); | |
1248 | |
1249 p_src_start=p_src | |
1250 +((src_x*src_offset+(src_y>>R2D_PIXELS_PER_MEMORY_WORD))); | |
1251 p_dst_start=p_dst | |
1252 +((dst_x*dst_offset+(dst_y>>R2D_PIXELS_PER_MEMORY_WORD))); | |
1253 | |
1254 xnb=rect_width; | |
1255 | |
1256 //printf("src start %08X contains %08X\n",p_src_start,*p_src_start); | |
1257 //printf("dst start %08X contains %08X\n",p_dst_start,*p_dst_start); | |
1258 | |
1259 //printf("rect_width %d\n",rect_width); | |
1260 if (h_direction==-1) | |
1261 { | |
1262 x=r2d_get_xmax(dst_rectangle)-1; | |
1263 p_src_start+=(rect_width-1)*src_offset; | |
1264 p_dst_start+=(rect_width-1)*dst_offset; | |
1265 } | |
1266 else | |
1267 x=r2d_get_xmin(dst_rectangle); | |
1268 | |
1269 //printf("src start %08X contains %08X\n",p_src_start,*p_src_start); | |
1270 //printf("dst start %08X contains %08X\n",p_dst_start,*p_dst_start); | |
1271 | |
1272 if (v_direction==-1) | |
1273 { | |
1274 p_src_start+=src_nb_rows-1; | |
1275 p_dst_start+=dst_nb_rows-1; | |
1276 | |
1277 temp=src_dy; | |
1278 src_dy=end_src_dy; | |
1279 end_src_dy=temp; | |
1280 | |
1281 temp=dst_dy; | |
1282 dst_dy=end_dst_dy; | |
1283 end_dst_dy=temp; | |
1284 } | |
1285 | |
1286 | |
1287 //printf("src start %08X contains %08X\n",p_src_start,*p_src_start); | |
1288 //printf("dst start %08X contains %08X\n",p_dst_start,*p_dst_start); | |
1289 | |
1290 //printf("dst_start=%08X contains %08X\n",p_dst_start,*p_dst_start); | |
1291 while(xnb!=0) | |
1292 { | |
1293 p_dst_current=p_dst_start; | |
1294 p_src_current=p_src_start; | |
1295 | |
1296 //printf("xnb=%d\n",xnb); | |
1297 //printf("src start %08X contains %08X\n",p_src_start,*p_src_start); | |
1298 //printf("dst start %08X contains %08X\n",p_dst_start,*p_dst_start); | |
1299 | |
1300 | |
1301 ynb=dst_nb_rows-1; | |
1302 | |
1303 if (v_direction==-1) | |
1304 { | |
1305 y=r2d_get_ymax(dst_rectangle) - 1; | |
1306 current_src_dy=(1<<R2D_PIXELS_PER_MEMORY_WORD)-1; | |
1307 current_dst_dy=(1<<R2D_PIXELS_PER_MEMORY_WORD)-1; | |
1308 } | |
1309 else | |
1310 { | |
1311 current_src_dy=0; | |
1312 current_dst_dy=0; | |
1313 y=r2d_get_ymin(dst_rectangle); | |
1314 } | |
1315 | |
1316 dstcounter=(1<<R2D_PIXELS_PER_MEMORY_WORD); | |
1317 srccounter=(1<<R2D_PIXELS_PER_MEMORY_WORD); | |
1318 | |
1319 dst_current=*p_dst_current; | |
1320 src_current=*p_src_current; | |
1321 | |
1322 //printf("src_current=%08X, dst_current=%08X\n",src_current,dst_current); | |
1323 temp=0; | |
1324 //printf("new column\n dst=%08X\n",p_dst_current); | |
1325 //printf("current_dst_dy =%d, dst_dy=%d\n",current_dst_dy,dst_dy); | |
1326 dstvalue=0; | |
1327 if (v_direction==-1) | |
1328 { | |
1329 while(current_dst_dy!=dst_dy) | |
1330 { | |
1331 r2d_shift_pixel_up(dstvalue,dst_current,dstcounter,p_dst_current); | |
1332 current_dst_dy--; | |
1333 //printf("dstcounter=%d\n",dstcounter); | |
1334 y--; | |
1335 } | |
1336 while(current_src_dy!=src_dy) | |
1337 { | |
1338 | |
1339 //printf("current_src_dy=%d\n",current_src_dy); | |
1340 //printf("srccounter=%d\n",srccounter); | |
1341 | |
1342 r2d_shift_pixel_up(temp,src_current,srccounter,p_src_current); | |
1343 current_src_dy--; | |
1344 //printf("src_current=%08X\n",src_current); | |
1345 | |
1346 | |
1347 } | |
1348 while(ynb!=0) | |
1349 { | |
1350 | |
1351 r2d_shift_pixel_up_and_write(dst,src); | |
1352 //printf("srccounter=%d\n",srccounter); | |
1353 y--; | |
1354 | |
1355 if (dstcounter==(1<<R2D_PIXELS_PER_MEMORY_WORD)) | |
1356 { | |
1357 ynb--; | |
1358 | |
1359 *p_dst_current--=dstvalue; | |
1360 | |
1361 #if (R2D_DEBUG == R2D_ON) | |
1362 #if (R2D_DEBUG_WARNING == R2D_DEBUG_HIGH) | |
1363 if ((p_dst_current<((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)dst_gc)->p_frame_buffer))->p_memory_words) | |
1364 || (p_dst_current>((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)dst_gc)->p_frame_buffer))->p_frame_buffer_end)) | |
1365 { | |
1366 //printf("Error : frame_buffer overflow\n"); | |
1367 IND_rvf_send_trace("R2D : Framebuffer overflow1",27, NULL_PARAM, | |
1368 RV_TRACE_LEVEL_ERROR, R2D_USE_ID ); | |
1369 } | |
1370 #endif | |
1371 #endif | |
1372 | |
1373 current_dst_dy=(1<<R2D_PIXELS_PER_MEMORY_WORD)-1; | |
1374 | |
1375 dst_current=*p_dst_current; | |
1376 | |
1377 //printf("%08X <- %08X\n",p_dst_current,dstvalue); | |
1378 | |
1379 dstvalue=0; | |
1380 } | |
1381 | |
1382 } | |
1383 current_dst_dy++; | |
1384 while(current_dst_dy!=end_dst_dy) | |
1385 { | |
1386 | |
1387 r2d_shift_pixel_up_and_write(dst,src); | |
1388 current_dst_dy--; | |
1389 //printf("Last row %08X, %08X\n",p_dst_current,current_dst_dy); | |
1390 y--; | |
1391 | |
1392 } | |
1393 if (dstcounter==(1<<R2D_PIXELS_PER_MEMORY_WORD)) | |
1394 compensate=FALSE; | |
1395 while(dstcounter!=(1<<R2D_PIXELS_PER_MEMORY_WORD)) | |
1396 { | |
1397 | |
1398 r2d_shift_pixel_up(dstvalue,dst_current,dstcounter,p_dst_current); | |
1399 current_dst_dy--; | |
1400 //printf(" Last row %08X\n",p_src_current); | |
1401 //printf("dstcounter=%d\n",dstcounter); | |
1402 y--; | |
1403 | |
1404 | |
1405 | |
1406 } | |
1407 if (compensate==TRUE) | |
1408 { | |
1409 *++p_dst_current=dstvalue; | |
1410 | |
1411 } | |
1412 else | |
1413 { | |
1414 *p_dst_current=dstvalue; | |
1415 | |
1416 } | |
1417 #if (R2D_DEBUG == R2D_ON) | |
1418 #if (R2D_DEBUG_WARNING == R2D_DEBUG_HIGH) | |
1419 if ((p_dst_current<((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)dst_gc)->p_frame_buffer))->p_memory_words) | |
1420 || (p_dst_current>((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)dst_gc)->p_frame_buffer))->p_frame_buffer_end)) | |
1421 { | |
1422 //printf("Error : frame_buffer overflow\n"); | |
1423 IND_rvf_send_trace("R2D : Framebuffer overflow2",27, NULL_PARAM, | |
1424 RV_TRACE_LEVEL_ERROR, R2D_USE_ID ); | |
1425 } | |
1426 #endif | |
1427 #endif | |
1428 | |
1429 | |
1430 } | |
1431 else | |
1432 { | |
1433 while(current_dst_dy!=dst_dy) | |
1434 { | |
1435 r2d_shift_pixel_down(dstvalue,dst_current,dstcounter,p_dst_current); | |
1436 current_dst_dy++; | |
1437 y++; | |
1438 //printf("dstcounter=%d\n",dstcounter); | |
1439 } | |
1440 while(current_src_dy!=src_dy) | |
1441 { | |
1442 | |
1443 r2d_shift_pixel_down(temp,src_current,srccounter,p_src_current); | |
1444 current_src_dy++; | |
1445 | |
1446 | |
1447 } | |
1448 while(ynb!=0) | |
1449 { | |
1450 | |
1451 r2d_shift_pixel_down_and_write(dst,src); | |
1452 y++; | |
1453 | |
1454 if (dstcounter==(1<<R2D_PIXELS_PER_MEMORY_WORD)) | |
1455 { | |
1456 ynb--; | |
1457 | |
1458 | |
1459 *p_dst_current++=dstvalue; | |
1460 #if (R2D_DEBUG == R2D_ON) | |
1461 #if (R2D_DEBUG_WARNING == R2D_DEBUG_HIGH) | |
1462 if ((p_dst_current<((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)dst_gc)->p_frame_buffer))->p_memory_words) | |
1463 || (p_dst_current>((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)dst_gc)->p_frame_buffer))->p_frame_buffer_end)) | |
1464 { | |
1465 char error[256]; | |
1466 T_R2D_RECT *dst; | |
1467 | |
1468 //dst=(T_R2D_RECT*)dst_rectangle; | |
1469 //sprintf(error,"%d %d %d %d",dst->ul_x,dst->ul_y, | |
1470 // dst->br_x,dst->br_y); | |
1471 //IND_rvf_send_trace(error,strlen(error), NULL_PARAM, | |
1472 // RV_TRACE_LEVEL_ERROR, R2D_USE_ID ); | |
1473 //printf("Error : frame_buffer overflow\n"); | |
1474 IND_rvf_send_trace("R2D : Framebuffer overflow3",27, NULL_PARAM, | |
1475 RV_TRACE_LEVEL_ERROR, R2D_USE_ID ); | |
1476 } | |
1477 #endif | |
1478 #endif | |
1479 | |
1480 current_dst_dy=0; | |
1481 | |
1482 dst_current=*p_dst_current; | |
1483 | |
1484 //printf("%08X <- %08X\n",p_dst_current,dstvalue); | |
1485 | |
1486 dstvalue=0; | |
1487 } | |
1488 | |
1489 } | |
1490 | |
1491 current_dst_dy--; | |
1492 while(current_dst_dy!=end_dst_dy) | |
1493 { | |
1494 | |
1495 r2d_shift_pixel_down_and_write(dst,src); | |
1496 current_dst_dy++; | |
1497 //printf("Last row %08X\n",p_dst_current); | |
1498 y++; | |
1499 | |
1500 } | |
1501 if (dstcounter==(1<<R2D_PIXELS_PER_MEMORY_WORD)) | |
1502 compensate=FALSE; | |
1503 while(dstcounter!=(1<<R2D_PIXELS_PER_MEMORY_WORD)) | |
1504 { | |
1505 | |
1506 r2d_shift_pixel_down(dstvalue,dst_current,dstcounter,p_dst_current); | |
1507 current_dst_dy++; | |
1508 //printf("Last row %08X\n",p_dst_current); | |
1509 y++; | |
1510 | |
1511 } | |
1512 if (compensate==TRUE) | |
1513 { | |
1514 *--p_dst_current=dstvalue; | |
1515 } | |
1516 else | |
1517 { | |
1518 *p_dst_current=dstvalue; | |
1519 } | |
1520 #if (R2D_DEBUG == R2D_ON) | |
1521 #if (R2D_DEBUG_WARNING == R2D_DEBUG_HIGH) | |
1522 if ((p_dst_current<((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)dst_gc)->p_frame_buffer))->p_memory_words) | |
1523 || (p_dst_current>((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)dst_gc)->p_frame_buffer))->p_frame_buffer_end)) | |
1524 { | |
1525 //printf("Error : frame_buffer overflow\n"); | |
1526 IND_rvf_send_trace("R2D : Framebuffer overflow4",27, NULL_PARAM, | |
1527 RV_TRACE_LEVEL_ERROR, R2D_USE_ID ); | |
1528 } | |
1529 #endif | |
1530 #endif | |
1531 | |
1532 } | |
1533 | |
1534 | |
1535 dstvalue=0; | |
1536 | |
1537 | |
1538 if (h_direction==-1) | |
1539 { | |
1540 p_src_start-=src_offset; | |
1541 p_dst_start-=dst_offset; | |
1542 x--; | |
1543 } | |
1544 else | |
1545 { | |
1546 p_src_start+=src_offset; | |
1547 p_dst_start+=dst_offset; | |
1548 x++; | |
1549 } | |
1550 | |
1551 xnb--; | |
1552 } | |
1553 | |
1554 | |
1555 | |
1556 | |
1557 } | |
1558 end_blit: dstvalue=0; | |
1559 } | |
1560 | |
1561 | |
1562 #undef r2d_shift_pixel_down_and_write | |
1563 #undef r2d_shift_pixel_up_and_write | |
1564 | |
1565 #define r2d_shift_pixel_down_and_write(dst,src) {\ | |
1566 dst##value =R2D_PIXEL_DOWN_OUT(dst##value); \ | |
1567 dst##value|=dop((dst##_current & R2D_PIXEL_MASK), \ | |
1568 r2d_convert_from_color_to_color(use_foreground_color,\ | |
1569 src##_current & R2D_PIXEL_MASK,src_gc,dst_gc,x,y)) \ | |
1570 << ((1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH) ; \ | |
1571 src##_current=R2D_PIXEL_DOWN_OUT(src##_current); \ | |
1572 dst##_current=R2D_PIXEL_DOWN_OUT(dst##_current); \ | |
1573 dst##counter--; \ | |
1574 src##counter--; \ | |
1575 if (src##counter==0) \ | |
1576 { \ | |
1577 src##counter=(1<<R2D_PIXELS_PER_MEMORY_WORD); \ | |
1578 src##_current=*++p_##src##_current; \ | |
1579 } \ | |
1580 if (dst##counter==0) \ | |
1581 { \ | |
1582 dst##counter=(1<<R2D_PIXELS_PER_MEMORY_WORD); \ | |
1583 } \ | |
1584 } | |
1585 | |
1586 #define r2d_shift_pixel_up_and_write(dst,src) {\ | |
1587 dst##value =R2D_PIXEL_UP_OUT(dst##value); \ | |
1588 dst##value |=dop( \ | |
1589 (dst##_current >> ((1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH)) & R2D_PIXEL_MASK, \ | |
1590 r2d_convert_from_color_to_color(use_foreground_color,\ | |
1591 (src##_current >> ((1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH)) & R2D_PIXEL_MASK, \ | |
1592 src_gc,dst_gc,x,y)); \ | |
1593 src##_current=R2D_PIXEL_UP_OUT(src##_current); \ | |
1594 dst##_current=R2D_PIXEL_UP_OUT(dst##_current); \ | |
1595 dst##counter--; \ | |
1596 src##counter--; \ | |
1597 if (src##counter==0) \ | |
1598 { \ | |
1599 src##counter=(1<<R2D_PIXELS_PER_MEMORY_WORD); \ | |
1600 src##_current=*--p_##src##_current; \ | |
1601 } \ | |
1602 if (dst##counter==0) \ | |
1603 { \ | |
1604 dst##counter=(1<<R2D_PIXELS_PER_MEMORY_WORD); \ | |
1605 } \ | |
1606 } | |
1607 | |
1608 | |
1609 | |
1610 // Requires shapes in graphic context coordinates | |
1611 void r2d_blit_color_to_color(T_R2D_GC_PTR src_gc,T_R2D_GC_PTR dst_gc, | |
1612 T_R2D_SHAPE_PTR src_rectangle, | |
1613 T_R2D_SHAPE_PTR dst_rectangle, | |
1614 R2D_BOOLEAN use_foreground_color) | |
1615 { | |
1616 UINT32 *p_src,*p_dst,*p_src_current,*p_dst_current,*p_src_start,*p_dst_start,value; | |
1617 INT16 rect_width,rect_height,src_x,src_y,dst_x,dst_y; | |
1618 INT16 src_offset,dst_offset,src_height,dst_height; | |
1619 INT16 xnb,ynb,nb_rows; | |
1620 INT16 x,y;//,temp; | |
1621 | |
1622 | |
1623 INT32 h_direction,v_direction; | |
1624 T_R2D_DRAWING_MODE mode; | |
1625 T_R2D_DRAWING_OP dop; | |
1626 | |
1627 | |
1628 dop=((T_R2D_GC*)dst_gc)->drawing_op; | |
1629 | |
1630 | |
1631 | |
1632 { | |
1633 | |
1634 p_src=((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)src_gc)->p_frame_buffer))->p_memory_words; | |
1635 p_dst=((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)dst_gc)->p_frame_buffer))->p_memory_words; | |
1636 | |
1637 rect_width=r2d_get_xmax(src_rectangle)-r2d_get_xmin(src_rectangle); | |
1638 rect_height=r2d_get_ymax(src_rectangle)-r2d_get_ymin(src_rectangle); | |
1639 | |
1640 if ((rect_width<=0) || (rect_height<=0)) | |
1641 goto end_blit_c; | |
1642 | |
1643 mode=IND_r2d_get_drawing_mode(dst_gc); | |
1644 | |
1645 | |
1646 src_x=r2d_get_xmin(src_rectangle); | |
1647 src_y=r2d_get_ymin(src_rectangle); | |
1648 | |
1649 dst_x=r2d_get_xmin(dst_rectangle); | |
1650 dst_y=r2d_get_ymin(dst_rectangle); | |
1651 | |
1652 | |
1653 // Number of rows is word containing last point - word containing first point | |
1654 // + 1 | |
1655 nb_rows=(r2d_get_ymax(dst_rectangle)-1)-(dst_y)+1; | |
1656 //printf("nb_rows %d\n",nb_rows); | |
1657 | |
1658 h_direction=1; | |
1659 v_direction=1; | |
1660 if (((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)src_gc)->p_frame_buffer))== | |
1661 ((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)dst_gc)->p_frame_buffer))) | |
1662 r2d_check_rectangle_overlap(src_x,src_y,dst_x,dst_y, | |
1663 rect_width,rect_height,&h_direction,&v_direction); | |
1664 | |
1665 //printf("h,v=%d,%d\n",h_direction,v_direction); | |
1666 | |
1667 | |
1668 #if (R2D_REFRESH == R2D_VERTICAL) | |
1669 src_height=((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)src_gc)->p_frame_buffer))->height; | |
1670 dst_height=((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)dst_gc)->p_frame_buffer))->height; | |
1671 #else | |
1672 src_height=((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)src_gc)->p_frame_buffer))->width; | |
1673 dst_height=((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)dst_gc)->p_frame_buffer))->width; | |
1674 #endif | |
1675 | |
1676 src_offset=(src_height); | |
1677 dst_offset=(dst_height); | |
1678 | |
1679 //printf("%08X,dst offset=%08X\n",p_dst,dst_offset); | |
1680 | |
1681 p_src_start=p_src | |
1682 +((src_x*src_offset+(src_y))); | |
1683 p_dst_start=p_dst | |
1684 +((dst_x*dst_offset+(dst_y))); | |
1685 | |
1686 xnb=rect_width; | |
1687 | |
1688 //printf("start %08X contains %08X\n",p_dst_start,*p_dst_start); | |
1689 | |
1690 if (h_direction==-1) | |
1691 { | |
1692 x=r2d_get_xmax(dst_rectangle)-1; | |
1693 p_src_start+=(rect_width-1)*src_offset; | |
1694 p_dst_start+=(rect_width-1)*dst_offset; | |
1695 } | |
1696 else | |
1697 x=r2d_get_xmin(dst_rectangle); | |
1698 | |
1699 if (v_direction==-1) | |
1700 { | |
1701 p_src_start+=nb_rows-1; | |
1702 p_dst_start+=nb_rows-1; | |
1703 | |
1704 } | |
1705 | |
1706 //printf("dst_start=%08X contains %08X\n",p_dst_start,*p_dst_start); | |
1707 while(xnb!=0) | |
1708 { | |
1709 p_dst_current=p_dst_start; | |
1710 p_src_current=p_src_start; | |
1711 | |
1712 ynb=nb_rows; // Not using - 1 since not different processing of ending word | |
1713 // (which is here a pixel instead of being only a memory word) | |
1714 | |
1715 | |
1716 | |
1717 //printf("src_current=%08X, dst_current=%08X\n",src_current,dst_current); | |
1718 //printf("new column\n dst=%08X\n",p_dst_current); | |
1719 | |
1720 if (v_direction==-1) | |
1721 { | |
1722 while(ynb!=0) | |
1723 { | |
1724 | |
1725 value=*p_dst_current; | |
1726 *p_dst_current--=dop(value,*p_src_current--); | |
1727 y--; | |
1728 | |
1729 ynb--; | |
1730 } | |
1731 } | |
1732 else | |
1733 { | |
1734 while(ynb!=0) | |
1735 { | |
1736 | |
1737 value=*p_dst_current; | |
1738 *p_dst_current++=dop(value,*p_src_current++); | |
1739 y++; | |
1740 | |
1741 ynb--; | |
1742 } | |
1743 } | |
1744 | |
1745 | |
1746 | |
1747 if (h_direction==-1) | |
1748 { | |
1749 p_src_start-=src_offset; | |
1750 p_dst_start-=dst_offset; | |
1751 x--; | |
1752 } | |
1753 else | |
1754 { | |
1755 p_src_start+=src_offset; | |
1756 p_dst_start+=dst_offset; | |
1757 x++; | |
1758 } | |
1759 | |
1760 xnb--; | |
1761 } | |
1762 | |
1763 | |
1764 | |
1765 | |
1766 } | |
1767 end_blit_c:ynb=0; | |
1768 } | |
1769 | |
1770 | |
1771 #undef r2d_shift_pixel_down_and_write | |
1772 #undef r2d_shift_pixel_up_and_write | |
1773 | |
1774 #define r2d_shift_pixel_down_and_write(dst,src) {\ | |
1775 dst##value =r2d_convert_from_lcd_to_color(use_foreground_color,\ | |
1776 src##_current & R2D_PIXEL_MASK,src_gc,dst_gc,x,y); \ | |
1777 dst##value =dop(*p_dst_current,dst##value); \ | |
1778 *p_##dst##_current++=dst##value;\ | |
1779 src##_current=R2D_PIXEL_DOWN_OUT(src##_current); \ | |
1780 src##counter--; \ | |
1781 if (src##counter==0) \ | |
1782 { \ | |
1783 src##counter=(1<<R2D_PIXELS_PER_MEMORY_WORD); \ | |
1784 src##_current=*++p_##src##_current; \ | |
1785 } \ | |
1786 } | |
1787 | |
1788 | |
1789 #define r2d_shift_pixel_up_and_write(dst,src) {\ | |
1790 dst##value =r2d_convert_from_lcd_to_color(use_foreground_color,\ | |
1791 src##_current & R2D_PIXEL_MASK,src_gc,dst_gc,x,y); \ | |
1792 dst##value =dop(*p_dst_current,dst##value); \ | |
1793 *p_##dst##_current--=dst##value;\ | |
1794 src##_current=R2D_PIXEL_UP_OUT(src##_current); \ | |
1795 src##counter--; \ | |
1796 if (src##counter==0) \ | |
1797 { \ | |
1798 src##counter=(1<<R2D_PIXELS_PER_MEMORY_WORD); \ | |
1799 src##_current=*--p_##src##_current; \ | |
1800 } \ | |
1801 } | |
1802 | |
1803 // Requires shapes in graphic context coordinates | |
1804 void r2d_blit_lcd_to_color(T_R2D_GC_PTR src_gc,T_R2D_GC_PTR dst_gc, | |
1805 T_R2D_SHAPE_PTR src_rectangle, | |
1806 T_R2D_SHAPE_PTR dst_rectangle, | |
1807 R2D_BOOLEAN use_foreground_color) | |
1808 { | |
1809 UINT32 *p_src,*p_dst,*p_src_current,*p_dst_current,*p_src_start,*p_dst_start; | |
1810 INT16 rect_width,rect_height,src_x,src_y,dst_x,dst_y; | |
1811 INT16 src_offset,dst_offset,src_height,dst_height; | |
1812 INT16 xnb,ynb,src_nb_rows,dst_nb_rows; | |
1813 INT16 src_dy,dst_dy,end_dst_dy,end_src_dy; // distance from word boundary | |
1814 // INT16 shift; // relative position (modulo a memory word) between both rectangles | |
1815 // in bits | |
1816 INT16 current_src_dy;//,current_dst_dy; | |
1817 INT16 temp,srccounter;//,dstcounter; | |
1818 | |
1819 | |
1820 register UINT32 dstvalue;//,dst_current; | |
1821 register UINT32 src_current;//,srcvalue; | |
1822 INT32 h_direction,v_direction; | |
1823 INT16 x,y; | |
1824 T_R2D_DRAWING_MODE mode; | |
1825 T_R2D_DRAWING_OP dop; | |
1826 | |
1827 dop=((T_R2D_GC*)dst_gc)->drawing_op; | |
1828 | |
1829 | |
1830 | |
1831 | |
1832 { | |
1833 | |
1834 p_src=((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)src_gc)->p_frame_buffer))->p_memory_words; | |
1835 p_dst=((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)dst_gc)->p_frame_buffer))->p_memory_words; | |
1836 | |
1837 rect_width=r2d_get_xmax(src_rectangle)-r2d_get_xmin(src_rectangle); | |
1838 rect_height=r2d_get_ymax(src_rectangle)-r2d_get_ymin(src_rectangle); | |
1839 | |
1840 if ((rect_width<=0) || (rect_height<=0)) | |
1841 goto end_blit_d; | |
1842 | |
1843 mode=IND_r2d_get_drawing_mode(dst_gc); | |
1844 | |
1845 | |
1846 src_x=r2d_get_xmin(src_rectangle); | |
1847 src_y=r2d_get_ymin(src_rectangle); | |
1848 | |
1849 dst_x=r2d_get_xmin(dst_rectangle); | |
1850 dst_y=r2d_get_ymin(dst_rectangle); | |
1851 | |
1852 src_dy=src_y & R2D_WORD_POSITION_MASK; | |
1853 dst_dy=dst_y & R2D_WORD_POSITION_MASK; | |
1854 | |
1855 // Clipping convention such end_dst_dy is the first y position which must not | |
1856 // be copied at the end of a column | |
1857 end_dst_dy=(r2d_get_ymax(dst_rectangle)-1) & R2D_WORD_POSITION_MASK; | |
1858 end_src_dy=(r2d_get_ymax(src_rectangle)-1) & R2D_WORD_POSITION_MASK ; | |
1859 | |
1860 // Number of rows is word containing last point - word containing first point | |
1861 // + 1 | |
1862 src_nb_rows=R2D_ALIGNED_MWLENGTH(r2d_get_ymax(src_rectangle)-1)-R2D_ALIGNED_MWLENGTH(src_y) + 1; | |
1863 | |
1864 dst_nb_rows=(r2d_get_ymax(dst_rectangle))-(dst_y); | |
1865 //printf("nb_rows %d\n",nb_rows); | |
1866 | |
1867 h_direction=1; | |
1868 v_direction=1; | |
1869 if (((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)src_gc)->p_frame_buffer))== | |
1870 ((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)dst_gc)->p_frame_buffer))) | |
1871 r2d_check_rectangle_overlap(src_x,src_y,dst_x,dst_y, | |
1872 rect_width,rect_height,&h_direction,&v_direction); | |
1873 | |
1874 //printf("h,v=%d,%d\n",h_direction,v_direction); | |
1875 | |
1876 | |
1877 | |
1878 #if (R2D_REFRESH == R2D_VERTICAL) | |
1879 src_height=((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)src_gc)->p_frame_buffer))->height; | |
1880 dst_height=((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)dst_gc)->p_frame_buffer))->height; | |
1881 #else | |
1882 src_height=((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)src_gc)->p_frame_buffer))->width; | |
1883 dst_height=((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)dst_gc)->p_frame_buffer))->width; | |
1884 #endif | |
1885 | |
1886 src_offset=R2D_ALIGNED_MWLENGTH(src_height); | |
1887 dst_offset=dst_height; | |
1888 | |
1889 //printf("%08X,dst offset=%08X\n",p_dst,dst_offset); | |
1890 | |
1891 p_src_start=p_src | |
1892 +((src_x*src_offset+(src_y>>R2D_PIXELS_PER_MEMORY_WORD))); | |
1893 p_dst_start=p_dst | |
1894 +((dst_x*dst_offset+(dst_y))); | |
1895 | |
1896 xnb=rect_width; | |
1897 | |
1898 //printf("start %08X contains %08X\n",p_dst_start,*p_dst_start); | |
1899 | |
1900 if (h_direction==-1) | |
1901 { | |
1902 x=r2d_get_xmax(dst_rectangle)-1; | |
1903 p_src_start+=(rect_width-1)*src_offset; | |
1904 p_dst_start+=(rect_width-1)*dst_offset; | |
1905 } | |
1906 else | |
1907 x=r2d_get_xmin(dst_rectangle); | |
1908 | |
1909 if (v_direction==-1) | |
1910 { | |
1911 p_src_start+=src_nb_rows-1; | |
1912 p_dst_start+=dst_nb_rows-1; | |
1913 | |
1914 temp=src_dy; | |
1915 src_dy=end_src_dy; | |
1916 end_src_dy=temp; | |
1917 | |
1918 } | |
1919 | |
1920 //printf("dst_start=%08X contains %08X\n",p_dst_start,*p_dst_start); | |
1921 while(xnb!=0) | |
1922 { | |
1923 p_dst_current=p_dst_start; | |
1924 p_src_current=p_src_start; | |
1925 | |
1926 ynb=dst_nb_rows; // No -1 since no different processing for last word | |
1927 | |
1928 if (v_direction==-1) | |
1929 { | |
1930 current_src_dy=(1<<R2D_PIXELS_PER_MEMORY_WORD)-1; | |
1931 y=r2d_get_ymax(dst_rectangle)-1; | |
1932 } | |
1933 else | |
1934 { | |
1935 current_src_dy=0; | |
1936 y=r2d_get_ymin(dst_rectangle); | |
1937 } | |
1938 | |
1939 srccounter=(1<<R2D_PIXELS_PER_MEMORY_WORD); | |
1940 | |
1941 src_current=*p_src_current; | |
1942 //printf("src_current=%08X, dst_current=%08X\n",src_current,dst_current); | |
1943 temp=0; | |
1944 //printf("new column\n dst=%08X\n",p_dst_current); | |
1945 | |
1946 //printf("src_dy=%d\n",src_dy); | |
1947 | |
1948 if (v_direction==-1) | |
1949 { | |
1950 while(current_src_dy!=src_dy) | |
1951 { | |
1952 | |
1953 //printf("current_src_dy=%d\n",current_src_dy); | |
1954 r2d_shift_pixel_up(temp,src_current,srccounter,p_src_current); | |
1955 current_src_dy--; | |
1956 | |
1957 //printf("src_current=%08X\n",src_current); | |
1958 | |
1959 } | |
1960 //printf("src_current=%08X, dst_current=%08X, dstvalue=%08X\n dstcounter=%08X, srccounter=%08X\n", | |
1961 //src_current,dst_current,dstvalue,dstcounter,srccounter); | |
1962 while(ynb!=0) | |
1963 { | |
1964 | |
1965 r2d_shift_pixel_up_and_write(dst,src); | |
1966 y--; | |
1967 | |
1968 ynb--; | |
1969 | |
1970 } | |
1971 } | |
1972 else | |
1973 { | |
1974 while(current_src_dy!=src_dy) | |
1975 { | |
1976 | |
1977 r2d_shift_pixel_down(temp,src_current,srccounter,p_src_current); | |
1978 current_src_dy++; | |
1979 | |
1980 | |
1981 } | |
1982 //printf("src_current=%08X, dst_current=%08X, dstvalue=%08X\n dstcounter=%08X, srccounter=%08X\n", | |
1983 //src_current,dst_current,dstvalue,dstcounter,srccounter); | |
1984 while(ynb!=0) | |
1985 { | |
1986 | |
1987 r2d_shift_pixel_down_and_write(dst,src); | |
1988 y++; | |
1989 | |
1990 ynb--; | |
1991 | |
1992 } | |
1993 } | |
1994 | |
1995 | |
1996 | |
1997 | |
1998 | |
1999 if (h_direction==-1) | |
2000 { | |
2001 p_src_start-=src_offset; | |
2002 p_dst_start-=dst_offset; | |
2003 x--; | |
2004 } | |
2005 else | |
2006 { | |
2007 p_src_start+=src_offset; | |
2008 p_dst_start+=dst_offset; | |
2009 x++; | |
2010 } | |
2011 | |
2012 xnb--; | |
2013 } | |
2014 | |
2015 | |
2016 | |
2017 | |
2018 } | |
2019 end_blit_d:ynb=0; | |
2020 } | |
2021 | |
2022 | |
2023 | |
2024 #undef r2d_shift_pixel_down_and_write | |
2025 #undef r2d_shift_pixel_up_and_write | |
2026 | |
2027 #define r2d_shift_pixel_down_and_write(dst,src) {\ | |
2028 dst##value =R2D_PIXEL_DOWN_OUT(dst##value); \ | |
2029 src##_current=r2d_convert_from_color_to_lcd(use_foreground_color,\ | |
2030 *p_##src##_current++,src_gc,dst_gc,x,y); \ | |
2031 dst##value|=dop((dst##_current & R2D_PIXEL_MASK), \ | |
2032 src##_current) \ | |
2033 << ((1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH) ; \ | |
2034 dst##_current=R2D_PIXEL_DOWN_OUT(dst##_current); \ | |
2035 dst##counter--; \ | |
2036 if (dst##counter==0) \ | |
2037 { \ | |
2038 dst##counter=(1<<R2D_PIXELS_PER_MEMORY_WORD); \ | |
2039 } \ | |
2040 } | |
2041 | |
2042 | |
2043 #define r2d_shift_pixel_up_and_write(dst,src) {\ | |
2044 dst##value =R2D_PIXEL_UP_OUT(dst##value); \ | |
2045 src##_current=r2d_convert_from_color_to_lcd(use_foreground_color,\ | |
2046 *p_##src##_current--,src_gc,dst_gc,x,y); \ | |
2047 dst##value |=dop( \ | |
2048 (dst##_current >> ((1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH)) & R2D_PIXEL_MASK, \ | |
2049 src##_current); \ | |
2050 dst##_current=R2D_PIXEL_UP_OUT(dst##_current); \ | |
2051 dst##counter--; \ | |
2052 if (dst##counter==0) \ | |
2053 { \ | |
2054 dst##counter=(1<<R2D_PIXELS_PER_MEMORY_WORD); \ | |
2055 } \ | |
2056 } | |
2057 | |
2058 // Requires shapes in graphic context coordinates | |
2059 void r2d_blit_color_to_lcd(T_R2D_GC_PTR src_gc,T_R2D_GC_PTR dst_gc, | |
2060 T_R2D_SHAPE_PTR src_rectangle, | |
2061 T_R2D_SHAPE_PTR dst_rectangle, | |
2062 R2D_BOOLEAN use_foreground_color) | |
2063 { | |
2064 UINT32 *p_src,*p_dst,*p_src_current,*p_dst_current,*p_src_start,*p_dst_start; | |
2065 INT16 rect_width,rect_height,src_x,src_y,dst_x,dst_y; | |
2066 INT16 src_offset,dst_offset,src_height,dst_height; | |
2067 INT16 xnb,ynb,dst_nb_rows,src_nb_rows; | |
2068 INT16 src_dy,dst_dy,end_dst_dy,end_src_dy; // distance from word boundary | |
2069 // INT16 shift; // relative position (modulo a memory word) between both rectangles | |
2070 // in bits | |
2071 INT16 current_dst_dy;//,current_src_dy; | |
2072 INT16 temp,dstcounter,srccounter; | |
2073 | |
2074 | |
2075 register UINT32 dstvalue,dst_current; | |
2076 register UINT32 src_current;//,srcvalue; | |
2077 INT32 h_direction,v_direction; | |
2078 INT16 x,y; | |
2079 T_R2D_DRAWING_MODE mode; | |
2080 T_R2D_DRAWING_OP dop; | |
2081 BOOLEAN compensate=TRUE; | |
2082 | |
2083 dop=((T_R2D_GC*)dst_gc)->drawing_op; | |
2084 | |
2085 | |
2086 | |
2087 | |
2088 { | |
2089 | |
2090 p_src=((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)src_gc)->p_frame_buffer))->p_memory_words; | |
2091 p_dst=((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)dst_gc)->p_frame_buffer))->p_memory_words; | |
2092 | |
2093 rect_width=r2d_get_xmax(src_rectangle)-r2d_get_xmin(src_rectangle); | |
2094 rect_height=r2d_get_ymax(src_rectangle)-r2d_get_ymin(src_rectangle); | |
2095 | |
2096 if ((rect_width<=0) || (rect_height<=0)) | |
2097 goto end_blit_e; | |
2098 | |
2099 mode=IND_r2d_get_drawing_mode(dst_gc); | |
2100 | |
2101 | |
2102 src_x=r2d_get_xmin(src_rectangle); | |
2103 src_y=r2d_get_ymin(src_rectangle); | |
2104 | |
2105 dst_x=r2d_get_xmin(dst_rectangle); | |
2106 dst_y=r2d_get_ymin(dst_rectangle); | |
2107 | |
2108 src_dy=src_y & R2D_WORD_POSITION_MASK; | |
2109 dst_dy=dst_y & R2D_WORD_POSITION_MASK; | |
2110 | |
2111 // Clipping convention such end_dst_dy is the first y position which must not | |
2112 // be copied at the end of a column | |
2113 end_dst_dy=(r2d_get_ymax(dst_rectangle)-1) & R2D_WORD_POSITION_MASK ; | |
2114 end_src_dy=(r2d_get_ymax(src_rectangle)-1) & R2D_WORD_POSITION_MASK ; | |
2115 | |
2116 // Number of rows is word containing last point - word containing first point | |
2117 // + 1 | |
2118 dst_nb_rows=R2D_ALIGNED_MWLENGTH(r2d_get_ymax(dst_rectangle)-1)-R2D_ALIGNED_MWLENGTH(dst_y) + 1; | |
2119 src_nb_rows=(r2d_get_ymax(src_rectangle))-(src_y); | |
2120 | |
2121 //printf("src_nb_rows %d\n",src_nb_rows); | |
2122 //printf("dst_nb_rows %d\n",dst_nb_rows); | |
2123 | |
2124 h_direction=1; | |
2125 v_direction=1; | |
2126 if (((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)src_gc)->p_frame_buffer))== | |
2127 ((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)dst_gc)->p_frame_buffer))) | |
2128 r2d_check_rectangle_overlap(src_x,src_y,dst_x,dst_y, | |
2129 rect_width,rect_height,&h_direction,&v_direction); | |
2130 | |
2131 //printf("h,v=%d,%d\n",h_direction,v_direction); | |
2132 | |
2133 | |
2134 | |
2135 | |
2136 #if (R2D_REFRESH == R2D_VERTICAL) | |
2137 src_height=((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)src_gc)->p_frame_buffer))->height; | |
2138 dst_height=((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)dst_gc)->p_frame_buffer))->height; | |
2139 #else | |
2140 src_height=((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)src_gc)->p_frame_buffer))->width; | |
2141 dst_height=((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)dst_gc)->p_frame_buffer))->width; | |
2142 #endif | |
2143 | |
2144 src_offset=src_height; | |
2145 dst_offset=R2D_ALIGNED_MWLENGTH(dst_height); | |
2146 | |
2147 //printf("%08X,dst offset=%08X\n",p_dst,dst_offset); | |
2148 | |
2149 p_src_start=p_src | |
2150 +((src_x*src_offset+(src_y))); | |
2151 p_dst_start=p_dst | |
2152 +((dst_x*dst_offset+(dst_y>>R2D_PIXELS_PER_MEMORY_WORD))); | |
2153 | |
2154 xnb=rect_width; | |
2155 | |
2156 //printf("start %08X contains %08X\n",p_dst_start,*p_dst_start); | |
2157 | |
2158 if (h_direction==-1) | |
2159 { | |
2160 x=r2d_get_xmax(dst_rectangle)-1; | |
2161 p_src_start+=(rect_width-1)*src_offset; | |
2162 p_dst_start+=(rect_width-1)*dst_offset; | |
2163 } | |
2164 else | |
2165 x=r2d_get_xmin(dst_rectangle); | |
2166 | |
2167 if (v_direction==-1) | |
2168 { | |
2169 p_src_start+=src_nb_rows-1; | |
2170 p_dst_start+=dst_nb_rows-1; | |
2171 | |
2172 temp=dst_dy; | |
2173 dst_dy=end_dst_dy; | |
2174 end_dst_dy=temp; | |
2175 } | |
2176 | |
2177 | |
2178 //printf("dst_start=%08X contains %08X\n",p_dst_start,*p_dst_start); | |
2179 while(xnb!=0) | |
2180 { | |
2181 p_dst_current=p_dst_start; | |
2182 p_src_current=p_src_start; | |
2183 | |
2184 ynb=dst_nb_rows-1; | |
2185 | |
2186 if (v_direction==-1) | |
2187 { | |
2188 y=r2d_get_ymax(dst_rectangle) - 1; | |
2189 current_dst_dy=(1<<R2D_PIXELS_PER_MEMORY_WORD)-1; | |
2190 } | |
2191 else | |
2192 { | |
2193 current_dst_dy=0; | |
2194 y=r2d_get_ymin(dst_rectangle); | |
2195 } | |
2196 | |
2197 dstcounter=(1<<R2D_PIXELS_PER_MEMORY_WORD); | |
2198 srccounter=(1<<R2D_PIXELS_PER_MEMORY_WORD); | |
2199 | |
2200 dst_current=*p_dst_current; | |
2201 //printf("src_current=%08X, dst_current=%08X\n",src_current,dst_current); | |
2202 temp=0; | |
2203 //printf("new column\n dst=%08X\n",p_dst_current); | |
2204 dstvalue=0; | |
2205 //printf("current_dst_dy=%08X,dst_dy=%08X\n",current_dst_dy,dst_dy); | |
2206 | |
2207 if (v_direction==-1) | |
2208 { | |
2209 while(current_dst_dy!=dst_dy) | |
2210 { | |
2211 | |
2212 r2d_shift_pixel_up(dstvalue,dst_current,dstcounter,p_dst_current); | |
2213 current_dst_dy--; | |
2214 y--; | |
2215 //printf("dstcounter=%d\n",dstcounter); | |
2216 | |
2217 } | |
2218 while(ynb!=0) | |
2219 { | |
2220 | |
2221 r2d_shift_pixel_up_and_write(dst,src); | |
2222 y--; | |
2223 | |
2224 if (dstcounter==(1<<R2D_PIXELS_PER_MEMORY_WORD)) | |
2225 { | |
2226 ynb--; | |
2227 | |
2228 | |
2229 | |
2230 *p_dst_current--=dstvalue; | |
2231 current_dst_dy=(1<<R2D_PIXELS_PER_MEMORY_WORD)-1; | |
2232 | |
2233 dst_current=*p_dst_current; | |
2234 | |
2235 //printf("%08X <- %08X\n",p_dst_current,dstvalue); | |
2236 | |
2237 dstvalue=0; | |
2238 } | |
2239 | |
2240 } | |
2241 current_dst_dy++; | |
2242 | |
2243 while(current_dst_dy!=end_dst_dy) | |
2244 { | |
2245 | |
2246 r2d_shift_pixel_up_and_write(dst,src); | |
2247 current_dst_dy--; | |
2248 y--; | |
2249 //printf("Last row %08X, %08X\n",p_dst_current,current_dst_dy); | |
2250 | |
2251 } | |
2252 if (dstcounter==(1<<R2D_PIXELS_PER_MEMORY_WORD)) | |
2253 compensate=FALSE; | |
2254 while(dstcounter!=(1<<R2D_PIXELS_PER_MEMORY_WORD)) | |
2255 { | |
2256 | |
2257 r2d_shift_pixel_up(dstvalue,dst_current,dstcounter,p_dst_current); | |
2258 current_dst_dy--; | |
2259 //printf("Last row %08X\n",p_dst_current); | |
2260 //printf("dstcounter=%d\n",dstcounter); | |
2261 y--; | |
2262 | |
2263 | |
2264 | |
2265 } | |
2266 if (compensate==TRUE) | |
2267 { | |
2268 *++p_dst_current=dstvalue; | |
2269 | |
2270 } | |
2271 else | |
2272 { | |
2273 *p_dst_current=dstvalue; | |
2274 | |
2275 } | |
2276 | |
2277 } | |
2278 else | |
2279 { | |
2280 while(current_dst_dy!=dst_dy) | |
2281 { | |
2282 | |
2283 r2d_shift_pixel_down(dstvalue,dst_current,dstcounter,p_dst_current); | |
2284 current_dst_dy++; | |
2285 y++; | |
2286 //printf("dstcounter=%d\n",dstcounter); | |
2287 | |
2288 } | |
2289 while(ynb!=0) | |
2290 { | |
2291 | |
2292 r2d_shift_pixel_down_and_write(dst,src); | |
2293 y++; | |
2294 | |
2295 if (dstcounter==(1<<R2D_PIXELS_PER_MEMORY_WORD)) | |
2296 { | |
2297 ynb--; | |
2298 | |
2299 | |
2300 | |
2301 | |
2302 *p_dst_current++=dstvalue; | |
2303 current_dst_dy=0; | |
2304 | |
2305 dst_current=*p_dst_current; | |
2306 | |
2307 //printf("%08X <- %08X\n",p_dst_current,dstvalue); | |
2308 | |
2309 dstvalue=0; | |
2310 } | |
2311 | |
2312 } | |
2313 current_dst_dy--; | |
2314 | |
2315 while(current_dst_dy!=end_dst_dy) | |
2316 { | |
2317 | |
2318 r2d_shift_pixel_down_and_write(dst,src); | |
2319 current_dst_dy++; | |
2320 y++; | |
2321 //printf("Last row %08X\n",p_dst_current); | |
2322 | |
2323 } | |
2324 if (dstcounter==(1<<R2D_PIXELS_PER_MEMORY_WORD)) | |
2325 compensate=FALSE; | |
2326 while(dstcounter!=(1<<R2D_PIXELS_PER_MEMORY_WORD)) | |
2327 { | |
2328 | |
2329 r2d_shift_pixel_down(dstvalue,dst_current,dstcounter,p_dst_current); | |
2330 current_dst_dy++; | |
2331 //printf("Last row %08X\n",p_dst_current); | |
2332 y++; | |
2333 | |
2334 | |
2335 } | |
2336 if (compensate==TRUE) | |
2337 { | |
2338 *--p_dst_current=dstvalue; | |
2339 } | |
2340 else | |
2341 { | |
2342 *p_dst_current=dstvalue; | |
2343 } | |
2344 } | |
2345 | |
2346 | |
2347 //printf("src_current=%08X, dst_current=%08X, dstvalue=%08X\n dstcounter=%08X, srccounter=%08X\n", | |
2348 //src_current,dst_current,dstvalue,dstcounter,srccounter); | |
2349 | |
2350 // One need a different processing for last word | |
2351 //printf("Last row %08X,end_dst_dy=%08X,current_dy=%08X\n",p_dst_current,end_dst_dy,current_dst_dy); | |
2352 | |
2353 | |
2354 //end_dst_dy MUST be copied | |
2355 // It is at 1 from the copy bit rectangle frontier | |
2356 | |
2357 | |
2358 | |
2359 //printf("dstvalue: %08X <- %08X\n",p_dst_current,dstvalue); | |
2360 | |
2361 dstvalue=0; | |
2362 | |
2363 | |
2364 if (h_direction==-1) | |
2365 { | |
2366 x--; | |
2367 p_src_start-=src_offset; | |
2368 p_dst_start-=dst_offset; | |
2369 } | |
2370 else | |
2371 { | |
2372 x++; | |
2373 p_src_start+=src_offset; | |
2374 p_dst_start+=dst_offset; | |
2375 } | |
2376 | |
2377 xnb--; | |
2378 } | |
2379 | |
2380 | |
2381 | |
2382 | |
2383 } | |
2384 end_blit_e:dstvalue=0; | |
2385 } | |
2386 | |
2387 #endif | |
2388 | |
2389 /********************* | |
2390 | |
2391 R2D ASM MODE | |
2392 | |
2393 **********************/ | |
2394 | |
2395 #if (R2D_ASM == R2D_ON) | |
2396 | |
2397 #define R2D_BRANCH_INST 0xFF000000 | |
2398 | |
2399 /* | |
2400 Patch a block of 3 instructions with a block defined | |
2401 by the user. The block does not contain any branch instruction. | |
2402 The branch must use a special syntax introduced by the long word | |
2403 R2D_BRANCH_INST | |
2404 */ | |
2405 void r2d_patch_code_block(UINT32* src,UINT32 *dst) | |
2406 { | |
2407 | |
2408 | |
2409 if (*src == R2D_BRANCH_INST) | |
2410 { | |
2411 *dst++ = *(&r2d_start_branch_inst); | |
2412 src++; | |
2413 // PC is ahead of 8 bytes of current instruction because of prefetch | |
2414 // So -8 must be used | |
2415 *dst = (((((*src) - ((UINT32)dst)) - 8)>>2) & 0x0FFFFFF) | 0xEB000000; | |
2416 *++dst= *(&r2d_stop_branch_inst); | |
2417 } | |
2418 else | |
2419 { | |
2420 | |
2421 *dst++=*src++; | |
2422 *dst++=*src++; | |
2423 *dst++=*src++; | |
2424 } | |
2425 } | |
2426 | |
2427 /* | |
2428 Copy one instruction of code | |
2429 */ | |
2430 void r2d_patch_inst(UINT32* src,UINT32 *dst) | |
2431 { | |
2432 *dst++ = *src++; | |
2433 } | |
2434 | |
2435 | |
2436 /* | |
2437 Patch the sequence of instructions reading the foreground | |
2438 background colors. It copies a sequence containing | |
2439 two LDR and update the LDR offsets | |
2440 */ | |
2441 void r2d_patch_get_color(UINT32* src,UINT32 *dst) | |
2442 { | |
2443 UINT32 r,offset; | |
2444 INT16 delta; | |
2445 | |
2446 delta=(((INT32)src-(INT32)dst)); | |
2447 | |
2448 r=*src++; | |
2449 offset=r & 0xFFF; | |
2450 offset+=delta; | |
2451 offset=offset & 0xFFF; | |
2452 *dst++ = (r & 0xFFFFF000) | offset; | |
2453 | |
2454 r=*src++; | |
2455 offset=r & 0xFFF; | |
2456 offset+=delta; | |
2457 offset=offset & 0xFFF; | |
2458 *dst++ = (r & 0xFFFFF000) | offset; | |
2459 | |
2460 *dst++ = *src++; | |
2461 } | |
2462 | |
2463 /* | |
2464 Patch with a branch if f is true or add a NOP | |
2465 */ | |
2466 void r2d_patch_branch(UINT32 *src,UINT32 *dst,BOOLEAN f) | |
2467 { | |
2468 INT32 offset; | |
2469 if (f) | |
2470 { | |
2471 offset=(((((INT32)dst-(INT32)src))-8)>>2) & 0x00FFFFFF; | |
2472 *src=(0xEA<<24) | offset; | |
2473 } | |
2474 else | |
2475 { | |
2476 *src=0xe1a0b00b; | |
2477 } | |
2478 } | |
2479 | |
2480 | |
2481 /* | |
2482 Replace the shift value by another one | |
2483 */ | |
2484 #define R2D_MOV_OPCODE 0xD | |
2485 void r2d_patch_shift(UINT32 *src,UINT32 shift,INT16 left) | |
2486 { | |
2487 UINT32 data; | |
2488 | |
2489 data=*src; | |
2490 | |
2491 | |
2492 // Shift addressing by default | |
2493 data=data & 0xFDFFFFFF ; | |
2494 | |
2495 | |
2496 if ((shift !=0) && (shift != 32)) | |
2497 { | |
2498 data=data & 0xFFFFF00F; | |
2499 if (left==1) | |
2500 data=data|(((shift&0x01F)<<7)&0x0F80); // LSL | |
2501 else | |
2502 data=data|(((shift&0x01F)<<7)&0x0F80)| 0x20; // LSR | |
2503 } | |
2504 else if (shift != 32) | |
2505 { | |
2506 data=data & 0xFFFFF00F; | |
2507 data=data|(((shift&0x01F)<<7)&0x0F80); // LSL 0 | |
2508 | |
2509 } | |
2510 else | |
2511 { | |
2512 data=(data & 0xFFFFF07F); // LSR 0 | |
2513 | |
2514 } | |
2515 *src=data; | |
2516 } | |
2517 | |
2518 void r2d_patch_moveshift(UINT32 *src,UINT32 shift,INT16 left) | |
2519 { | |
2520 UINT32 data; | |
2521 UINT32 dstreg; | |
2522 UINT32 opcode; | |
2523 | |
2524 data=*src; | |
2525 | |
2526 dstreg=(data & 0x0F000); | |
2527 dstreg=dstreg>>12; | |
2528 | |
2529 opcode=data & 0x01E00000; | |
2530 opcode=opcode>>21; | |
2531 if (opcode!=R2D_MOV_OPCODE) | |
2532 dstreg=0; | |
2533 | |
2534 // Shift addressing by default | |
2535 data=data & 0xF1FFFFFF ; | |
2536 | |
2537 | |
2538 if ((shift !=0) && (shift != 32)) | |
2539 { | |
2540 if (opcode==R2D_MOV_OPCODE) | |
2541 data=data & 0xFFFFF000; | |
2542 else | |
2543 data=data & 0xFFFFF00F; | |
2544 if (left==1) | |
2545 data=data|(((shift&0x01F)<<7)&0x0F80)|dstreg; // LSL | |
2546 else | |
2547 data=data|(((shift&0x01F)<<7)&0x0F80)| 0x20|dstreg; // LSR | |
2548 } | |
2549 else if (shift != 32) | |
2550 { | |
2551 if (opcode==R2D_MOV_OPCODE) | |
2552 data=data & 0xFFFFF000; | |
2553 else | |
2554 data=data & 0xFFFFF00F; | |
2555 data=data|(((shift&0x01F)<<7)&0x0F80)|dstreg; // LSL 0 | |
2556 | |
2557 } | |
2558 else | |
2559 { | |
2560 //data=(data & 0xFFFFF07F); // LSR 32 | |
2561 data=(data & 0xFFFFF000) | 0x02000000; // LSR 32 | |
2562 | |
2563 } | |
2564 *src=data; | |
2565 } | |
2566 /* | |
2567 Patch the const table contained in the .text section | |
2568 with the new foreground and background values | |
2569 */ | |
2570 void r2d_patch_color_conversion(T_R2D_GC_PTR gc) | |
2571 { | |
2572 UINT32 *p; | |
2573 | |
2574 p=&r2d_blit_foreground; | |
2575 *p=((T_R2D_GC*)gc)->foreground_pixel_value; | |
2576 | |
2577 p=&r2d_blit_background; | |
2578 *p=((T_R2D_GC*)gc)->background_pixel_value; | |
2579 | |
2580 } | |
2581 | |
2582 void r2d_patch_blit(T_R2D_GC_PTR dst_gc,T_R2D_DRAWING_MODE mode, | |
2583 R2D_BOOLEAN use_foreground_color,INT32 srcdst) | |
2584 { | |
2585 // Patch mode | |
2586 | |
2587 extern R2D_BOOLEAN r2d_g_old_use_foreground; | |
2588 extern INT32 r2d_g_old_srcdst; | |
2589 | |
2590 if (r2d_g_old_mode != mode) | |
2591 { | |
2592 r2d_g_old_mode=mode; | |
2593 r2d_patch_code_block(r2d_get_asm_drawing_op(dst_gc,mode),&r2d_sb_down1); | |
2594 r2d_patch_code_block(r2d_get_asm_drawing_op(dst_gc,mode),&r2d_sb_down2); | |
2595 r2d_patch_code_block(r2d_get_asm_drawing_op(dst_gc,mode),&r2d_sa_up1); | |
2596 r2d_patch_code_block(r2d_get_asm_drawing_op(dst_gc,mode),&r2d_sa_up2); | |
2597 } | |
2598 | |
2599 // Meaning of variables names | |
2600 // Last word is [ab]_(down1|down2|up1|up2) | |
2601 // a or b is the blit version (blit_a oe blit_b) | |
2602 // down described which version of the macro is used | |
2603 // (down or up one) and the number is used to differentiate | |
2604 // the calls to the macro | |
2605 | |
2606 // For the prefix, sft_ is for part of the code where a shift must be | |
2607 // patched. For instance: sft_dst_n_a_up1 | |
2608 // The second part says if the shift is for a src, dst or other | |
2609 // n means noraml shift like R2D_PIXEL_DEPTH | |
2610 // The n means complementd for shift as (1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH | |
2611 | |
2612 // Patch color detection | |
2613 if (r2d_g_old_use_foreground != use_foreground_color) | |
2614 { | |
2615 r2d_g_old_use_foreground=use_foreground_color; | |
2616 if (use_foreground_color) | |
2617 { | |
2618 if (((T_R2D_FRAMEBUFFER*)(((T_R2D_GC *)dst_gc)->p_frame_buffer))->kind!=R2D_FULL_KIND) | |
2619 { | |
2620 r2d_patch_code_block(&r2d_lcd_start_foreground_pixel,&r2d_sdb_down1); | |
2621 r2d_patch_code_block(&r2d_lcd_start_foreground_pixel,&r2d_sdb_down2); | |
2622 r2d_patch_code_block(&r2d_lcd_start_foreground_pixel,&r2d_sda_up1); | |
2623 r2d_patch_code_block(&r2d_lcd_start_foreground_pixel,&r2d_sda_up2); | |
2624 } | |
2625 else | |
2626 { | |
2627 r2d_patch_code_block(&r2d_color_start_foreground_pixel,&r2d_sdb_down1); | |
2628 r2d_patch_code_block(&r2d_color_start_foreground_pixel,&r2d_sdb_down2); | |
2629 r2d_patch_code_block(&r2d_color_start_foreground_pixel,&r2d_sda_up1); | |
2630 r2d_patch_code_block(&r2d_color_start_foreground_pixel,&r2d_sda_up2); | |
2631 } | |
2632 | |
2633 r2d_patch_color_conversion(dst_gc); | |
2634 r2d_g_old_foreground_pixelvalue=((T_R2D_GC*)dst_gc)->foreground_pixel_value; | |
2635 r2d_g_old_background_pixelvalue=((T_R2D_GC*)dst_gc)->background_pixel_value; | |
2636 | |
2637 | |
2638 r2d_patch_get_color(&r2d_start_get_color,&r2d_scb_down1); | |
2639 r2d_patch_get_color(&r2d_start_get_color,&r2d_scb_down2); | |
2640 r2d_patch_get_color(&r2d_start_get_color,&r2d_sca_up1); | |
2641 r2d_patch_get_color(&r2d_start_get_color,&r2d_sca_up2); | |
2642 } | |
2643 else | |
2644 { | |
2645 | |
2646 r2d_patch_code_block(&r2d_lcd_start_nothing,&r2d_sdb_down1); | |
2647 r2d_patch_code_block(&r2d_lcd_start_nothing,&r2d_sdb_down2); | |
2648 r2d_patch_code_block(&r2d_lcd_start_nothing,&r2d_sda_up1); | |
2649 r2d_patch_code_block(&r2d_lcd_start_nothing,&r2d_sda_up2); | |
2650 | |
2651 r2d_patch_code_block(&r2d_lcd_start_nothing,&r2d_scb_down1); | |
2652 r2d_patch_code_block(&r2d_lcd_start_nothing,&r2d_scb_down2); | |
2653 r2d_patch_code_block(&r2d_lcd_start_nothing,&r2d_sca_up1); | |
2654 r2d_patch_code_block(&r2d_lcd_start_nothing,&r2d_sca_up2); | |
2655 } | |
2656 } | |
2657 else | |
2658 { | |
2659 if (use_foreground_color) | |
2660 { | |
2661 if ((r2d_g_old_foreground_pixelvalue != ((T_R2D_GC*)dst_gc)->foreground_pixel_value) | |
2662 || | |
2663 (r2d_g_old_background_pixelvalue != ((T_R2D_GC*)dst_gc)->background_pixel_value)) | |
2664 { | |
2665 r2d_patch_color_conversion(dst_gc); | |
2666 r2d_g_old_foreground_pixelvalue=((T_R2D_GC*)dst_gc)->foreground_pixel_value; | |
2667 r2d_g_old_background_pixelvalue=((T_R2D_GC*)dst_gc)->background_pixel_value; | |
2668 } | |
2669 | |
2670 } | |
2671 } | |
2672 | |
2673 if (r2d_g_old_srcdst != srcdst) | |
2674 { | |
2675 r2d_g_old_srcdst=srcdst; | |
2676 | |
2677 // Path color conversion | |
2678 if (srcdst==R2D_LCDLCD) | |
2679 { | |
2680 r2d_patch_code_block(&r2d_lcd_start_nothing,&r2d_sconvcolb_down1); | |
2681 r2d_patch_code_block(&r2d_lcd_start_nothing,&r2d_sconvcolb_down2); | |
2682 r2d_patch_code_block(&r2d_lcd_start_nothing,&r2d_sconvcola_up1); | |
2683 r2d_patch_code_block(&r2d_lcd_start_nothing,&r2d_sconvcola_up2); | |
2684 | |
2685 // write_shift_pixel_down | |
2686 r2d_patch_branch(&r2d_skip_load_src_a_up1,&r2d_no_null_src_counter_a,FALSE);//src | |
2687 r2d_patch_branch(&r2d_skip_load_src_a_up2,&r2d_end_a_up2,FALSE);//src | |
2688 | |
2689 // write_shift_pixel_up | |
2690 r2d_patch_branch(&r2d_skip_load_src_b_down1,&r2d_no_null_src_counter_b,FALSE);//src | |
2691 r2d_patch_branch(&r2d_skip_load_src_b_down2,&r2d_end_b_down2,FALSE);//src | |
2692 | |
2693 | |
2694 | |
2695 r2d_patch_branch(&r2d_skip_shift_down_downa,&r2d_end_downa,FALSE);// dst | |
2696 r2d_patch_branch(&r2d_skip_shift_down_downb,&r2d_end_downb,FALSE);//src | |
2697 r2d_patch_branch(&r2d_skip_shift_down_downb,&r2d_end_downc,FALSE);//dst | |
2698 | |
2699 r2d_patch_branch(&r2d_skip_shift_up_upa,&r2d_end_upa,FALSE);//dst | |
2700 r2d_patch_branch(&r2d_skip_shift_up_upb,&r2d_end_upb,FALSE);//src | |
2701 r2d_patch_branch(&r2d_skip_shift_up_upc,&r2d_end_upc,FALSE);//dst | |
2702 | |
2703 r2d_patch_inst(&r2d_never_write,&r2d_always_read_b_down1); | |
2704 r2d_patch_inst(&r2d_never_write,&r2d_always_read_b_down2); | |
2705 r2d_patch_inst(&r2d_never_write,&r2d_always_read_a_up1); | |
2706 r2d_patch_inst(&r2d_never_write,&r2d_always_read_a_up2); | |
2707 | |
2708 | |
2709 } | |
2710 | |
2711 if (srcdst==R2D_COLORCOLOR) | |
2712 { | |
2713 r2d_patch_code_block(&r2d_lcd_start_nothing,&r2d_sconvcolb_down1); | |
2714 r2d_patch_code_block(&r2d_lcd_start_nothing,&r2d_sconvcolb_down2); | |
2715 r2d_patch_code_block(&r2d_lcd_start_nothing,&r2d_sconvcola_up1); | |
2716 r2d_patch_code_block(&r2d_lcd_start_nothing,&r2d_sconvcola_up2); | |
2717 | |
2718 // write_shift_pixel_down | |
2719 r2d_patch_branch(&r2d_skip_load_src_a_up1,&r2d_no_null_src_counter_a,TRUE);//src | |
2720 r2d_patch_branch(&r2d_skip_load_src_a_up2,&r2d_end_a_up2,TRUE);//src | |
2721 | |
2722 // write_shift_pixel_up | |
2723 r2d_patch_branch(&r2d_skip_load_src_b_down1,&r2d_no_null_src_counter_b,TRUE);//src | |
2724 r2d_patch_branch(&r2d_skip_load_src_b_down2,&r2d_end_b_down2,TRUE);//src | |
2725 | |
2726 | |
2727 | |
2728 r2d_patch_branch(&r2d_skip_shift_down_downa,&r2d_end_downa,TRUE);// dst | |
2729 r2d_patch_branch(&r2d_skip_shift_down_downb,&r2d_end_downb,TRUE);//src | |
2730 r2d_patch_branch(&r2d_skip_shift_down_downb,&r2d_end_downc,TRUE);//dst | |
2731 | |
2732 r2d_patch_branch(&r2d_skip_shift_up_upa,&r2d_end_upa,TRUE);//dst | |
2733 r2d_patch_branch(&r2d_skip_shift_up_upb,&r2d_end_upb,TRUE);//src | |
2734 r2d_patch_branch(&r2d_skip_shift_up_upc,&r2d_end_upc,TRUE);//dst | |
2735 | |
2736 r2d_patch_inst(&r2d_always_read_down,&r2d_always_read_b_down1); | |
2737 r2d_patch_inst(&r2d_always_read_down,&r2d_always_read_b_down2); | |
2738 r2d_patch_inst(&r2d_always_read_up,&r2d_always_read_a_up1); | |
2739 r2d_patch_inst(&r2d_always_read_up,&r2d_always_read_a_up2); | |
2740 } | |
2741 | |
2742 if ((srcdst==R2D_COLORLCD)) | |
2743 { | |
2744 r2d_patch_code_block(&r2d_start_color_to_lcd,&r2d_sconvcolb_down1); | |
2745 r2d_patch_code_block(&r2d_start_color_to_lcd,&r2d_sconvcolb_down2); | |
2746 r2d_patch_code_block(&r2d_start_color_to_lcd,&r2d_sconvcola_up1); | |
2747 r2d_patch_code_block(&r2d_start_color_to_lcd,&r2d_sconvcola_up2); | |
2748 | |
2749 // write_shift_pixel_down | |
2750 r2d_patch_branch(&r2d_skip_load_src_a_up1,&r2d_no_null_src_counter_a,TRUE);//src | |
2751 r2d_patch_branch(&r2d_skip_load_src_a_up2,&r2d_end_a_up2,TRUE);//src | |
2752 | |
2753 // write_shift_pixel_up | |
2754 r2d_patch_branch(&r2d_skip_load_src_b_down1,&r2d_no_null_src_counter_b,TRUE);//src | |
2755 r2d_patch_branch(&r2d_skip_load_src_b_down2,&r2d_end_b_down2,TRUE);//src | |
2756 | |
2757 | |
2758 | |
2759 r2d_patch_branch(&r2d_skip_shift_down_downa,&r2d_end_downa,FALSE);// dst | |
2760 r2d_patch_branch(&r2d_skip_shift_down_downb,&r2d_end_downb,TRUE);//src | |
2761 r2d_patch_branch(&r2d_skip_shift_down_downb,&r2d_end_downc,FALSE);//dst | |
2762 | |
2763 r2d_patch_branch(&r2d_skip_shift_up_upa,&r2d_end_upa,FALSE);//dst | |
2764 r2d_patch_branch(&r2d_skip_shift_up_upb,&r2d_end_upb,TRUE);//src | |
2765 r2d_patch_branch(&r2d_skip_shift_up_upc,&r2d_end_upc,FALSE);//dst | |
2766 | |
2767 r2d_patch_inst(&r2d_always_read_down,&r2d_always_read_b_down1); | |
2768 r2d_patch_inst(&r2d_always_read_down,&r2d_always_read_b_down2); | |
2769 r2d_patch_inst(&r2d_always_read_up,&r2d_always_read_a_up1); | |
2770 r2d_patch_inst(&r2d_always_read_up,&r2d_always_read_a_up2); | |
2771 } | |
2772 | |
2773 | |
2774 | |
2775 if ((srcdst==R2D_LCDCOLOR)) | |
2776 { | |
2777 r2d_patch_code_block(&r2d_start_lcd_to_color,&r2d_sconvcolb_down1); | |
2778 r2d_patch_code_block(&r2d_start_lcd_to_color,&r2d_sconvcolb_down2); | |
2779 r2d_patch_code_block(&r2d_start_lcd_to_color,&r2d_sconvcola_up1); | |
2780 r2d_patch_code_block(&r2d_start_lcd_to_color,&r2d_sconvcola_up2); | |
2781 | |
2782 // write_shift_pixel_down | |
2783 r2d_patch_branch(&r2d_skip_load_src_a_up1,&r2d_no_null_src_counter_a,FALSE);//src | |
2784 r2d_patch_branch(&r2d_skip_load_src_a_up2,&r2d_end_a_up2,FALSE);//src | |
2785 | |
2786 // write_shift_pixel_up | |
2787 r2d_patch_branch(&r2d_skip_load_src_b_down1,&r2d_no_null_src_counter_b,FALSE);//src | |
2788 r2d_patch_branch(&r2d_skip_load_src_b_down2,&r2d_end_b_down2,FALSE);//src | |
2789 | |
2790 | |
2791 | |
2792 r2d_patch_branch(&r2d_skip_shift_down_downa,&r2d_end_downa,TRUE);// dst | |
2793 r2d_patch_branch(&r2d_skip_shift_down_downb,&r2d_end_downb,FALSE);//src | |
2794 r2d_patch_branch(&r2d_skip_shift_down_downb,&r2d_end_downc,TRUE);//dst | |
2795 | |
2796 r2d_patch_branch(&r2d_skip_shift_up_upa,&r2d_end_upa,TRUE);//dst | |
2797 r2d_patch_branch(&r2d_skip_shift_up_upb,&r2d_end_upb,FALSE);//src | |
2798 r2d_patch_branch(&r2d_skip_shift_up_upc,&r2d_end_upc,TRUE);//dst | |
2799 | |
2800 r2d_patch_inst(&r2d_never_write,&r2d_always_read_b_down1); | |
2801 r2d_patch_inst(&r2d_never_write,&r2d_always_read_b_down2); | |
2802 r2d_patch_inst(&r2d_never_write,&r2d_always_read_a_up1); | |
2803 r2d_patch_inst(&r2d_never_write,&r2d_always_read_a_up2); | |
2804 } | |
2805 | |
2806 // Patch writing subroutines | |
2807 // Remove part of code not required when dst is R2D color | |
2808 // framebuffer (some branch are used to skip the parts) | |
2809 if ((srcdst==R2D_COLORCOLOR) || (srcdst==R2D_LCDCOLOR)) | |
2810 { | |
2811 r2d_patch_inst(&r2d_always_write_down,&r2d_swb_down1); | |
2812 r2d_patch_inst(&r2d_always_write_down,&r2d_swb_down2); | |
2813 r2d_patch_inst(&r2d_always_write_up,&r2d_swa_up1); | |
2814 r2d_patch_inst(&r2d_always_write_up,&r2d_swa_up2); | |
2815 | |
2816 r2d_patch_branch(&r2d_skip_color_proc_a,&r2d_end_ynb_color_dst_a,TRUE); | |
2817 r2d_patch_branch(&r2d_skip_color_proc_b,&r2d_end_ynb_color_dst_b,TRUE); | |
2818 r2d_patch_branch(&r2d_skip_color_dst_a,&r2d_enda,TRUE); | |
2819 r2d_patch_branch(&r2d_skip_color_dst_b,&r2d_endb,TRUE); | |
2820 } | |
2821 else | |
2822 { | |
2823 r2d_patch_inst(&r2d_never_write,&r2d_swb_down1); | |
2824 r2d_patch_inst(&r2d_never_write,&r2d_swb_down2); | |
2825 r2d_patch_inst(&r2d_never_write,&r2d_swa_up1); | |
2826 r2d_patch_inst(&r2d_never_write,&r2d_swa_up2); | |
2827 | |
2828 r2d_patch_branch(&r2d_skip_color_proc_a,&r2d_end_ynb_color_dst_a,FALSE); | |
2829 r2d_patch_branch(&r2d_skip_color_proc_b,&r2d_end_ynb_color_dst_b,FALSE); | |
2830 r2d_patch_branch(&r2d_skip_color_dst_a,&r2d_enda,FALSE); | |
2831 r2d_patch_branch(&r2d_skip_color_dst_b,&r2d_endb,FALSE); | |
2832 } | |
2833 | |
2834 | |
2835 // Update or restore shifts related to src | |
2836 if ((srcdst==R2D_COLORCOLOR) || (srcdst==R2D_COLORLCD)) | |
2837 { | |
2838 // Patch list for write_shift_pixel_down | |
2839 r2d_patch_shift(&r2d_sft_src_c_b_down1,0,1); | |
2840 r2d_patch_shift(&r2d_sft_src_c_b_down2,0,1); | |
2841 | |
2842 r2d_patch_shift(&r2d_sft_b_c_b_down1,0,0); | |
2843 r2d_patch_shift(&r2d_sft_b_c_b_down2,0,0); | |
2844 | |
2845 r2d_patch_shift(&r2d_sft_srcb__b_down1,0,0); // Read already done | |
2846 r2d_patch_shift(&r2d_sft_srcb__b_down2,0,0); // No need to make free area | |
2847 | |
2848 // Patch list for write_shift_pixel_up | |
2849 r2d_patch_shift(&r2d_sft_src_c_a_up1,0,0); | |
2850 r2d_patch_shift(&r2d_sft_src_c_a_up2,0,0); | |
2851 | |
2852 r2d_patch_shift(&r2d_sft_b_c_a_up1,0,0); | |
2853 r2d_patch_shift(&r2d_sft_b_c_a_up2,0,0); | |
2854 | |
2855 r2d_patch_shift(&r2d_sft_srcb__a_up1,0,1); // Read already done | |
2856 r2d_patch_shift(&r2d_sft_srcb__a_up2,0,1); // No need to make free area | |
2857 | |
2858 // Patch list for shift_pixel_down | |
2859 r2d_patch_shift(&r2d_sft_src_c_downb,0,1); | |
2860 r2d_patch_moveshift(&r2d_sft_srcb_n_downb,32,0); | |
2861 | |
2862 // Patch list for shift_pixel_up | |
2863 r2d_patch_shift(&r2d_sft_src_c_upb,0,0); | |
2864 r2d_patch_moveshift(&r2d_sft_srcb_n_upb,32,1); | |
2865 | |
2866 } | |
2867 else | |
2868 { | |
2869 // Patch list for write_shift_pixel_down | |
2870 r2d_patch_shift(&r2d_sft_src_c_b_down1,(1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH,1); | |
2871 r2d_patch_shift(&r2d_sft_src_c_b_down2,(1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH,1); | |
2872 | |
2873 r2d_patch_shift(&r2d_sft_b_c_b_down1,(1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH,0); | |
2874 r2d_patch_shift(&r2d_sft_b_c_b_down2,(1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH,0); | |
2875 | |
2876 r2d_patch_shift(&r2d_sft_srcb__b_down1,R2D_PIXEL_DEPTH,0); | |
2877 r2d_patch_shift(&r2d_sft_srcb__b_down2,R2D_PIXEL_DEPTH,0); | |
2878 | |
2879 // Patch list for write_shift_pixel_up | |
2880 r2d_patch_shift(&r2d_sft_src_c_a_up1,(1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH,0); | |
2881 r2d_patch_shift(&r2d_sft_src_c_a_up2,(1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH,0); | |
2882 | |
2883 r2d_patch_shift(&r2d_sft_b_c_a_up1,(1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH,0); | |
2884 r2d_patch_shift(&r2d_sft_b_c_a_up2,(1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH,0); | |
2885 | |
2886 r2d_patch_shift(&r2d_sft_srcb__a_up1,R2D_PIXEL_DEPTH,1); | |
2887 r2d_patch_shift(&r2d_sft_srcb__a_up2,R2D_PIXEL_DEPTH,1); | |
2888 | |
2889 // Patch list for shift_pixel_down | |
2890 r2d_patch_shift(&r2d_sft_src_c_downb,(1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH,1); | |
2891 r2d_patch_moveshift(&r2d_sft_srcb_n_downb,R2D_PIXEL_DEPTH,0); | |
2892 | |
2893 // Patch list for shift_pixel_up | |
2894 r2d_patch_shift(&r2d_sft_src_c_upb,(1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH,0); | |
2895 r2d_patch_moveshift(&r2d_sft_srcb_n_upb,R2D_PIXEL_DEPTH,1); | |
2896 } | |
2897 | |
2898 | |
2899 | |
2900 // Update (or restore) shifts related to dst | |
2901 if ((srcdst==R2D_COLORCOLOR) || (srcdst==R2D_LCDCOLOR)) | |
2902 { | |
2903 // Patch list for write_shift_pixel_down | |
2904 r2d_patch_moveshift(&r2d_sft_dst_n_b_down1,32,0); // Shift when dst is R2D color | |
2905 // framebuffer. | |
2906 // Only instructions using dst | |
2907 // are impacted | |
2908 r2d_patch_moveshift(&r2d_sft_dst_n_b_down2,32,0); | |
2909 | |
2910 r2d_patch_shift(&r2d_sft_dstc__b_down1,0,0); // Already read | |
2911 r2d_patch_shift(&r2d_sft_dstc__b_down2,0,0); // No need to make free area | |
2912 | |
2913 r2d_patch_shift(&r2d_sft_dstb_c_b_down1,0,1); | |
2914 r2d_patch_shift(&r2d_sft_dstb_c_b_down2,0,1); | |
2915 r2d_patch_shift(&r2d_sft_d_c_b_down1,0,0); | |
2916 r2d_patch_shift(&r2d_sft_d_c_b_down2,0,0); | |
2917 r2d_patch_shift(&r2d_sft_dstc_c_b_down1,0,1); | |
2918 r2d_patch_shift(&r2d_sft_dstc_c_b_down2,0,1); | |
2919 | |
2920 | |
2921 | |
2922 // Patch list for write_shift_pixel_up | |
2923 r2d_patch_moveshift(&r2d_sft_dst_n_a_up1,32,1); | |
2924 r2d_patch_moveshift(&r2d_sft_dst_n_a_up2,32,1); | |
2925 | |
2926 r2d_patch_shift(&r2d_sft_dstc__a_up1,0,1); // Already read | |
2927 r2d_patch_shift(&r2d_sft_dstc__a_up2,0,1); // No need to make free area | |
2928 | |
2929 r2d_patch_shift(&r2d_sft_b_c_a_up1,0,0); | |
2930 r2d_patch_shift(&r2d_sft_b_c_a_up2,0,0); | |
2931 | |
2932 | |
2933 | |
2934 // Patch list for shift_pixel_down | |
2935 r2d_patch_moveshift(&r2d_sft_dst_n_downa,32,0); | |
2936 r2d_patch_moveshift(&r2d_sft_dst_n_downb,32,0); | |
2937 r2d_patch_moveshift(&r2d_sft_dst_n_downc,32,0); | |
2938 | |
2939 r2d_patch_shift(&r2d_sft_src_c_downa,0,1); | |
2940 r2d_patch_moveshift(&r2d_sft_srcb_n_downa,32,0); | |
2941 r2d_patch_shift(&r2d_sft_src_c_downc,0,1); | |
2942 r2d_patch_moveshift(&r2d_sft_srcb_n_downc,32,0); | |
2943 | |
2944 | |
2945 // Patch list for shift_pixel_up | |
2946 r2d_patch_moveshift(&r2d_sft_dst_n_upa,32,1); | |
2947 r2d_patch_moveshift(&r2d_sft_dst_n_upb,32,1); | |
2948 r2d_patch_moveshift(&r2d_sft_dst_n_upc,32,1); | |
2949 | |
2950 r2d_patch_shift(&r2d_sft_src_c_upa,0,0); | |
2951 r2d_patch_moveshift(&r2d_sft_srcb_n_upa,32,1); | |
2952 r2d_patch_shift(&r2d_sft_src_c_upc,0,0); | |
2953 r2d_patch_moveshift(&r2d_sft_srcb_n_upc,32,1); | |
2954 | |
2955 | |
2956 } | |
2957 else | |
2958 { | |
2959 | |
2960 | |
2961 // Patch list for write_shift_pixel_down | |
2962 r2d_patch_moveshift(&r2d_sft_dst_n_b_down1,R2D_PIXEL_DEPTH,0); // Shift when dst is R2D color | |
2963 // framebuffer. | |
2964 // Only instructions using dst | |
2965 // are impacted | |
2966 r2d_patch_moveshift(&r2d_sft_dst_n_b_down2,R2D_PIXEL_DEPTH,0); | |
2967 | |
2968 r2d_patch_shift(&r2d_sft_dstc__b_down1,R2D_PIXEL_DEPTH,0); | |
2969 r2d_patch_shift(&r2d_sft_dstc__b_down2,R2D_PIXEL_DEPTH,0); | |
2970 | |
2971 r2d_patch_shift(&r2d_sft_dstb_c_b_down1,((1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH),1); | |
2972 r2d_patch_shift(&r2d_sft_dstb_c_b_down2,((1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH),1); | |
2973 r2d_patch_shift(&r2d_sft_d_c_b_down1,((1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH),0); | |
2974 r2d_patch_shift(&r2d_sft_d_c_b_down2,((1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH),0); | |
2975 r2d_patch_shift(&r2d_sft_dstc_c_b_down1,((1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH),1); | |
2976 r2d_patch_shift(&r2d_sft_dstc_c_b_down2,((1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH),1); | |
2977 | |
2978 // Patch list for write_shift_pixel_up | |
2979 r2d_patch_moveshift(&r2d_sft_dst_n_a_up1,R2D_PIXEL_DEPTH,1); | |
2980 r2d_patch_moveshift(&r2d_sft_dst_n_a_up2,R2D_PIXEL_DEPTH,1); | |
2981 | |
2982 r2d_patch_shift(&r2d_sft_dstc__a_up1,R2D_PIXEL_DEPTH,1); | |
2983 r2d_patch_shift(&r2d_sft_dstc__a_up2,R2D_PIXEL_DEPTH,1); | |
2984 | |
2985 r2d_patch_shift(&r2d_sft_b_c_a_up1,((1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH),0); | |
2986 r2d_patch_shift(&r2d_sft_b_c_a_up2,((1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH),0); | |
2987 | |
2988 | |
2989 // Patch list for shift_pixel_down | |
2990 r2d_patch_moveshift(&r2d_sft_dst_n_downa,R2D_PIXEL_DEPTH,0); | |
2991 r2d_patch_moveshift(&r2d_sft_dst_n_downb,R2D_PIXEL_DEPTH,0); | |
2992 r2d_patch_moveshift(&r2d_sft_dst_n_downc,R2D_PIXEL_DEPTH,0); | |
2993 | |
2994 r2d_patch_shift(&r2d_sft_src_c_downa,(1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH,1); | |
2995 r2d_patch_moveshift(&r2d_sft_srcb_n_downa,R2D_PIXEL_DEPTH,0); | |
2996 r2d_patch_shift(&r2d_sft_src_c_downc,(1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH,1); | |
2997 r2d_patch_moveshift(&r2d_sft_srcb_n_downc,R2D_PIXEL_DEPTH,0); | |
2998 | |
2999 | |
3000 // Patch list for shift_pixel_up | |
3001 r2d_patch_moveshift(&r2d_sft_dst_n_upa,R2D_PIXEL_DEPTH,1); | |
3002 r2d_patch_moveshift(&r2d_sft_dst_n_upb,R2D_PIXEL_DEPTH,1); | |
3003 r2d_patch_moveshift(&r2d_sft_dst_n_upc,R2D_PIXEL_DEPTH,1); | |
3004 | |
3005 r2d_patch_shift(&r2d_sft_src_c_upa,(1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH,0); | |
3006 r2d_patch_moveshift(&r2d_sft_srcb_n_upa,R2D_PIXEL_DEPTH,1); | |
3007 r2d_patch_shift(&r2d_sft_src_c_upc,(1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH,0); | |
3008 r2d_patch_moveshift(&r2d_sft_srcb_n_upc,R2D_PIXEL_DEPTH,1); | |
3009 | |
3010 } | |
3011 | |
3012 } | |
3013 } | |
3014 | |
3015 | |
3016 #endif |