FreeCalypso > hg > fc-selenite
comparison src/cs/drivers/drv_app/r2d/lcds/r2d_geometry_no2_lcd_i.c @ 0:b6a5e36de839
src/cs: initial import from Magnetite
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 15 Jul 2018 04:39:26 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:b6a5e36de839 |
---|---|
1 #include "rv/general.h" | |
2 #include "rvf/rvf_api.h" | |
3 #include "r2d/r2d_config.h" | |
4 #include "r2d/r2d.h" | |
5 #include "r2d/r2d_i.h" | |
6 #include "r2d/r2d_independance_layer.h" | |
7 | |
8 #if (R2D_PIXEL_DEPTH == 32) | |
9 #define R2D_PIXEL_DOWN_OUT(a) (0) | |
10 #define R2D_PIXEL_UP_OUT(a) (0) | |
11 #else | |
12 #define R2D_PIXEL_DOWN_OUT(a) (a>>R2D_PIXEL_DEPTH) | |
13 #define R2D_PIXEL_UP_OUT(a) (a<<R2D_PIXEL_DEPTH) | |
14 #endif | |
15 | |
16 | |
17 #if (R2D_ASM == R2D_ON) | |
18 extern void r2d_blit_la(UINT32 *a); | |
19 extern void r2d_blit_lb(UINT32 *a); | |
20 | |
21 extern UINT32 r2d_lcd_start_copy; | |
22 extern UINT32 r2d_lcd_start_or; | |
23 extern UINT32 r2d_lcd_start_and; | |
24 extern UINT32 r2d_lcd_start_xor; | |
25 extern UINT32 r2d_lcd_start_notcopy; | |
26 extern UINT32 r2d_lcd_start_notor; | |
27 extern UINT32 r2d_lcd_start_notand; | |
28 extern UINT32 r2d_lcd_start_notxor; | |
29 extern UINT32 r2d_lcd_start_alpha; | |
30 extern UINT32 r2d_lcd_start_erase; | |
31 extern UINT32 r2d_lcd_start_foreground_pixel; | |
32 | |
33 extern UINT32 r2d_color_start_copy; | |
34 extern UINT32 r2d_color_start_or; | |
35 extern UINT32 r2d_color_start_and; | |
36 extern UINT32 r2d_color_start_xor; | |
37 extern UINT32 r2d_color_start_notcopy; | |
38 extern UINT32 r2d_color_start_notor; | |
39 extern UINT32 r2d_color_start_notand; | |
40 extern UINT32 r2d_color_start_notxor; | |
41 extern UINT32 r2d_color_start_alpha; | |
42 extern UINT32 r2d_color_start_erase; | |
43 extern UINT32 r2d_color_start_foreground_pixel; | |
44 | |
45 extern UINT32 r2d_start_get_color; | |
46 | |
47 | |
48 // Drawing mode | |
49 extern UINT32 r2d_sb_down1; | |
50 extern UINT32 r2d_sb_down2; | |
51 extern UINT32 r2d_sa_up1; | |
52 extern UINT32 r2d_sa_up2; | |
53 | |
54 // Foreground detection | |
55 extern UINT32 r2d_sdb_down1; | |
56 extern UINT32 r2d_sdb_down2; | |
57 extern UINT32 r2d_sda_up1; | |
58 extern UINT32 r2d_sda_up2; | |
59 | |
60 // Color conversion | |
61 extern UINT32 r2d_scb_down1; | |
62 extern UINT32 r2d_scb_down2; | |
63 extern UINT32 r2d_sca_up1; | |
64 extern UINT32 r2d_sca_up2; | |
65 | |
66 extern UINT32 r2d_start_branch_inst; | |
67 extern UINT32 r2d_stop_branch_inst; | |
68 extern UINT32 r2d_blit_foreground; | |
69 extern UINT32 r2d_blit_background; | |
70 extern UINT32 r2d_skip_color_proc_a; | |
71 extern UINT32 r2d_end_ynb_color_dst_a; | |
72 extern UINT32 r2d_skip_color_proc_b; | |
73 extern UINT32 r2d_end_ynb_color_dst_b; | |
74 | |
75 // Patch list for write_shift_pixel_down | |
76 extern UINT32 r2d_sft_dst_n_b_down1,r2d_sft_dst_n_b_down2; | |
77 extern UINT32 r2d_sft_srcb_n_b_down1,r2d_sft_srcb_n_b_down2; | |
78 extern UINT32 r2d_sft_dstc_n_b_down1,r2d_sft_dstc_n_b_down2; | |
79 | |
80 extern UINT32 r2d_sft_src_c_b_down1,r2d_sft_src_c_b_down2; | |
81 extern UINT32 r2d_sft_b_c_b_down1,r2d_sft_b_c_b_down2; | |
82 extern UINT32 r2d_sft_dstb_c_b_down1,r2d_sft_dstb_c_b_down2; | |
83 extern UINT32 r2d_sft_d_c_b_down1,r2d_sft_d_c_b_down2; | |
84 extern UINT32 r2d_sft_dstc_c_b_down1,r2d_sft_dstc_c_b_down2; | |
85 | |
86 // Patch list for write_shift_pixel_up | |
87 extern UINT32 r2d_sft_dst_n_a_up1,r2d_sft_dst_n_a_up2; | |
88 extern UINT32 r2d_sft_srcb_n_a_up1,r2d_sft_srcb_n_a_up2; | |
89 extern UINT32 r2d_sft_dstc_n_a_up1,r2d_sft_dstc_n_a_up2; | |
90 | |
91 extern UINT32 r2d_sft_src_c_a_up1,r2d_sft_src_c_a_up2; | |
92 extern UINT32 r2d_sft_b_c_a_up1,r2d_sft_b_c_a_up2; | |
93 | |
94 // Patch list fro shift_pixel_down | |
95 extern UINT32 r2d_sft_dst_n_downa,r2d_sft_dst_n_downb,r2d_sft_dst_n_downc; | |
96 extern UINT32 r2d_sft_srcb_n_downa,r2d_sft_srcb_n_downb,r2d_sft_srcb_n_downc; | |
97 | |
98 extern UINT32 r2d_sft_src_c_downa,r2d_sft_src_c_downb,r2d_sft_src_c_downc; | |
99 | |
100 // Patch list fro shift_pixel_up | |
101 extern UINT32 r2d_sft_dst_n_upa,r2d_sft_dst_n_upb,r2d_sft_dst_n_upc; | |
102 extern UINT32 r2d_sft_srcb_n_upa,r2d_sft_srcb_n_upb,r2d_sft_srcb_n_upc; | |
103 | |
104 extern UINT32 r2d_sft_src_c_upa,r2d_sft_src_c_upb,r2d_sft_src_c_upc; | |
105 | |
106 extern UINT32 r2d_sconvcolb_down1,r2d_econvcolb_down1; | |
107 extern UINT32 r2d_sconvcolb_down2,r2d_econvcolb_down2; | |
108 extern UINT32 r2d_sconvcola_up1,r2d_econvcola_up1; | |
109 extern UINT32 r2d_sconvcola_up2,r2d_econvcola_up2; | |
110 extern UINT32 r2d_start_lcd_to_color,r2d_start_color_to_lcd; | |
111 | |
112 extern UINT32 r2d_always_write_down,r2d_always_write_up,r2d_never_write; | |
113 extern UINT32 r2d_swb_down1,r2d_swb_down2,r2d_swa_up1,r2d_swa_up2; | |
114 | |
115 extern UINT32 r2d_skip_color_dst_a,r2d_skip_color_dst_b; | |
116 extern UINT32 r2d_always_skip; | |
117 extern UINT32 r2d_enda,r2d_endb; | |
118 extern UINT32 r2d_lcd_start_nothing; | |
119 | |
120 UINT32* r2d_g_asm_lcd_operators[]= | |
121 { | |
122 &r2d_lcd_start_copy, | |
123 &r2d_lcd_start_or, | |
124 &r2d_lcd_start_and, | |
125 &r2d_lcd_start_xor, | |
126 &r2d_lcd_start_notcopy, | |
127 &r2d_lcd_start_notor, | |
128 &r2d_lcd_start_notand, | |
129 &r2d_lcd_start_notxor, | |
130 &r2d_lcd_start_alpha, | |
131 &r2d_lcd_start_erase | |
132 }; | |
133 | |
134 UINT32* r2d_g_asm_color_operators[]= | |
135 { | |
136 &r2d_color_start_copy, | |
137 &r2d_color_start_or, | |
138 &r2d_color_start_and, | |
139 &r2d_color_start_xor, | |
140 &r2d_color_start_notcopy, | |
141 &r2d_color_start_notor, | |
142 &r2d_color_start_notand, | |
143 &r2d_color_start_notxor, | |
144 &r2d_color_start_alpha, | |
145 &r2d_color_start_erase | |
146 }; | |
147 | |
148 | |
149 extern void r2d_patch_color_conversion(T_R2D_GC_PTR gc); | |
150 extern void r2d_patch_shift(UINT32 *src,UINT32 shift); | |
151 extern void r2d_patch_branch(UINT32 *src,UINT32 *dst,BOOLEAN f); | |
152 extern void r2d_patch_get_color(UINT32* src,UINT32 *dst); | |
153 extern void r2d_patch_inst(UINT32* src,UINT32 *dst); | |
154 extern void r2d_patch_code_block(UINT32* src,UINT32 *dst); | |
155 | |
156 extern void r2d_check_rectangle_overlap(INT16 src_x,INT16 src_y,INT16 dst_x,INT16 dst_y, | |
157 INT32 width,INT32 height, | |
158 INT32 *h_direction,INT32 *v_direction); | |
159 | |
160 /********************* | |
161 | |
162 R2D ASM MODE | |
163 | |
164 **********************/ | |
165 | |
166 | |
167 // Requires shapes in graphic context coordinates | |
168 void r2d_blit_asm(T_R2D_GC_PTR src_gc,T_R2D_GC_PTR dst_gc, | |
169 T_R2D_SHAPE_PTR src_rectangle, | |
170 T_R2D_SHAPE_PTR dst_rectangle, | |
171 R2D_BOOLEAN use_foreground_color,INT32 srcdst) | |
172 { | |
173 T_R2D_GC_PTR local_src_gc,local_dst_gc; | |
174 UINT32 *p_src,*p_dst,*p_src_current,*p_dst_current,*p_src_start,*p_dst_start; | |
175 INT16 rect_width,rect_height,src_x,src_y,dst_x,dst_y; | |
176 INT16 src_offset,dst_offset,src_height,dst_height; | |
177 INT16 xnb,ynb,src_nb_rows,dst_nb_rows; | |
178 INT16 src_dy,dst_dy,end_dst_dy,end_src_dy; // distance from word boundary | |
179 INT16 shift; // relative position (modulo a memory word) between both rectangles | |
180 // in bits | |
181 INT16 current_src_dy,current_dst_dy; | |
182 INT16 temp,dstcounter,srccounter; | |
183 | |
184 | |
185 UINT32 dstvalue,dst_current; | |
186 UINT32 srcvalue,src_current; | |
187 INT32 h_direction,v_direction; | |
188 INT16 x,y; | |
189 BOOLEAN compensate; | |
190 UINT32* code_dest; | |
191 UINT32* code_src; | |
192 | |
193 compensate=TRUE; | |
194 | |
195 // Copy argument to local ones for enabling asm access | |
196 | |
197 local_src_gc=src_gc; | |
198 local_dst_gc=dst_gc; | |
199 | |
200 | |
201 | |
202 | |
203 { | |
204 | |
205 p_src=((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)src_gc)->p_frame_buffer))->p_memory_words; | |
206 p_dst=((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)dst_gc)->p_frame_buffer))->p_memory_words; | |
207 | |
208 rect_width=r2d_get_xmax(src_rectangle)-r2d_get_xmin(src_rectangle); | |
209 rect_height=r2d_get_ymax(src_rectangle)-r2d_get_ymin(src_rectangle); | |
210 | |
211 | |
212 if ((rect_width<=0) || (rect_height<=0)) | |
213 goto end_blit_b; | |
214 | |
215 src_x=r2d_get_xmin(src_rectangle); | |
216 src_y=r2d_get_ymin(src_rectangle); | |
217 | |
218 dst_x=r2d_get_xmin(dst_rectangle); | |
219 dst_y=r2d_get_ymin(dst_rectangle); | |
220 | |
221 if ((srcdst==R2D_LCDLCD) || (srcdst==R2D_LCDCOLOR)) | |
222 src_dy=(src_y & R2D_WORD_POSITION_MASK); | |
223 else | |
224 src_dy=0; | |
225 | |
226 if ((srcdst==R2D_LCDLCD) || (srcdst==R2D_COLORLCD)) | |
227 dst_dy=(dst_y & R2D_WORD_POSITION_MASK); | |
228 else | |
229 dst_dy=0; | |
230 | |
231 // Clipping convention such end_dst_dy is the first y position which must not | |
232 // be copied at the end of a column | |
233 //printf("dest y max=%d\n",r2d_get_ymax(dst_rectangle)); | |
234 if ((srcdst==R2D_LCDLCD) || (srcdst==R2D_COLORLCD)) | |
235 end_dst_dy=((r2d_get_ymax(dst_rectangle)-1) & R2D_WORD_POSITION_MASK) ; | |
236 else | |
237 end_dst_dy=0; | |
238 | |
239 if ((srcdst==R2D_LCDLCD) || (srcdst==R2D_LCDCOLOR)) | |
240 end_src_dy=((r2d_get_ymax(src_rectangle)-1) & R2D_WORD_POSITION_MASK) ; | |
241 else | |
242 end_src_dy=0; | |
243 | |
244 //printf("dst_dy, end_dst_dy before reverse=%d,%d\n",dst_dy,end_dst_dy); | |
245 // Number of rows is word containing last point - word containing first point | |
246 // + 1 | |
247 | |
248 // We remove - 1 because last PIXEL is at 1 from the frontier line | |
249 if ((srcdst==R2D_LCDLCD) || (srcdst==R2D_COLORLCD)) | |
250 dst_nb_rows=R2D_ALIGNED_MWLENGTH(r2d_get_ymax(dst_rectangle)-1)-R2D_ALIGNED_MWLENGTH(dst_y)+1; | |
251 else | |
252 dst_nb_rows=r2d_get_ymax(dst_rectangle)-1-dst_y+1; | |
253 | |
254 if ((srcdst==R2D_LCDCOLOR) || (srcdst==R2D_LCDLCD)) | |
255 src_nb_rows=R2D_ALIGNED_MWLENGTH(r2d_get_ymax(src_rectangle)-1)-R2D_ALIGNED_MWLENGTH(src_y)+1; | |
256 else | |
257 src_nb_rows=r2d_get_ymax(src_rectangle)-1-src_y+1; | |
258 | |
259 //printf("src_nb_rows %d\n",src_nb_rows); | |
260 //printf("dst_nb_rows %d\n",dst_nb_rows); | |
261 | |
262 | |
263 h_direction=1; | |
264 v_direction=1; | |
265 if (((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)src_gc)->p_frame_buffer))== | |
266 ((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)dst_gc)->p_frame_buffer))) | |
267 r2d_check_rectangle_overlap(src_x,src_y,dst_x,dst_y, | |
268 rect_width,rect_height,&h_direction,&v_direction); | |
269 | |
270 //printf("h,v=%d,%d\n",h_direction,v_direction); | |
271 | |
272 | |
273 #if (R2D_REFRESH == R2D_VERTICAL) | |
274 src_height=((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)src_gc)->p_frame_buffer))->height; | |
275 dst_height=((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)dst_gc)->p_frame_buffer))->height; | |
276 #else | |
277 src_height=((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)src_gc)->p_frame_buffer))->width; | |
278 dst_height=((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)dst_gc)->p_frame_buffer))->width; | |
279 #endif | |
280 | |
281 if ((srcdst==R2D_LCDCOLOR) || (srcdst==R2D_LCDLCD)) | |
282 src_offset=R2D_ALIGNED_MWLENGTH(src_height); | |
283 else | |
284 src_offset=src_height; | |
285 | |
286 if ((srcdst==R2D_LCDLCD) || (srcdst==R2D_COLORLCD)) | |
287 dst_offset=R2D_ALIGNED_MWLENGTH(dst_height); | |
288 else | |
289 dst_offset=dst_height; | |
290 | |
291 | |
292 //printf("%08X,dst offset=%08X\n",p_dst,dst_offset); | |
293 | |
294 if ((srcdst==R2D_LCDCOLOR) || (srcdst==R2D_LCDLCD)) | |
295 p_src_start=p_src | |
296 +((src_x*src_offset+(src_y>>R2D_PIXELS_PER_MEMORY_WORD))); | |
297 else | |
298 p_src_start=p_src | |
299 +((src_x*src_offset+(src_y))); | |
300 | |
301 if ((srcdst==R2D_LCDLCD) || (srcdst==R2D_COLORLCD)) | |
302 p_dst_start=p_dst | |
303 +((dst_x*dst_offset+(dst_y>>R2D_PIXELS_PER_MEMORY_WORD))); | |
304 else | |
305 p_dst_start=p_dst | |
306 +((dst_x*dst_offset+(dst_y))); | |
307 | |
308 xnb=rect_width; | |
309 | |
310 //printf("src start %08X contains %08X\n",p_src_start,*p_src_start); | |
311 //printf("dst start %08X contains %08X\n",p_dst_start,*p_dst_start); | |
312 | |
313 //printf("rect_width %d\n",rect_width); | |
314 if (h_direction==-1) | |
315 { | |
316 x=r2d_get_xmax(dst_rectangle)-1; | |
317 p_src_start+=(rect_width-1)*src_offset; | |
318 p_dst_start+=(rect_width-1)*dst_offset; | |
319 } | |
320 else | |
321 x=r2d_get_xmin(dst_rectangle); | |
322 | |
323 //printf("src start %08X contains %08X\n",p_src_start,*p_src_start); | |
324 //printf("dst start %08X contains %08X\n",p_dst_start,*p_dst_start); | |
325 | |
326 if (v_direction==-1) | |
327 { | |
328 p_src_start+=src_nb_rows-1; | |
329 p_dst_start+=dst_nb_rows-1; | |
330 | |
331 temp=src_dy; | |
332 src_dy=end_src_dy; | |
333 end_src_dy=temp; | |
334 | |
335 temp=dst_dy; | |
336 dst_dy=end_dst_dy; | |
337 end_dst_dy=temp; | |
338 } | |
339 | |
340 | |
341 //printf("src start %08X contains %08X\n",p_src_start,*p_src_start); | |
342 //printf("dst start %08X contains %08X\n",p_dst_start,*p_dst_start); | |
343 | |
344 //printf("dst_start=%08X contains %08X\n",p_dst_start,*p_dst_start); | |
345 while(xnb!=0) | |
346 { | |
347 p_dst_current=p_dst_start; | |
348 p_src_current=p_src_start; | |
349 | |
350 //printf("xnb=%d\n",xnb); | |
351 //printf("src start %08X contains %08X\n",p_src_start,*p_src_start); | |
352 //printf("dst start %08X contains %08X\n",p_dst_start,*p_dst_start); | |
353 | |
354 | |
355 if ((srcdst==R2D_COLORCOLOR) || (srcdst==R2D_LCDCOLOR)) | |
356 ynb=dst_nb_rows; | |
357 else | |
358 ynb=dst_nb_rows-1; // no -1 when dest is R2D color | |
359 | |
360 if (v_direction==-1) | |
361 { | |
362 y=r2d_get_ymax(dst_rectangle) - 1; | |
363 if ((srcdst==R2D_LCDLCD) || (srcdst==R2D_LCDCOLOR)) | |
364 current_src_dy=(1<<R2D_PIXELS_PER_MEMORY_WORD)-1; | |
365 else | |
366 current_src_dy=0; | |
367 | |
368 if ((srcdst==R2D_LCDLCD) || (srcdst==R2D_COLORLCD)) | |
369 current_dst_dy=(1<<R2D_PIXELS_PER_MEMORY_WORD)-1; | |
370 else | |
371 current_dst_dy=0; | |
372 } | |
373 else | |
374 { | |
375 current_src_dy=0; | |
376 current_dst_dy=0; | |
377 y=r2d_get_ymin(dst_rectangle); | |
378 } | |
379 | |
380 dstcounter=(1<<R2D_PIXELS_PER_MEMORY_WORD); | |
381 srccounter=(1<<R2D_PIXELS_PER_MEMORY_WORD); | |
382 | |
383 dst_current=*p_dst_current; | |
384 src_current=*p_src_current; | |
385 //printf("src_current=%08X, dst_current=%08X\n",src_current,dst_current); | |
386 temp=0; | |
387 //printf("new column\n dst=%08X\n",p_dst_current); | |
388 //printf("current_dst_dy =%d, dst_dy=%d\n",current_dst_dy,dst_dy); | |
389 dstvalue=0; | |
390 | |
391 if (v_direction==-1) | |
392 r2d_blit_la((UINT32*)&local_src_gc); | |
393 else | |
394 r2d_blit_lb((UINT32*)&local_src_gc); | |
395 | |
396 | |
397 | |
398 | |
399 dstvalue=0; | |
400 | |
401 | |
402 if (h_direction==-1) | |
403 { | |
404 p_src_start-=src_offset; | |
405 p_dst_start-=dst_offset; | |
406 x--; | |
407 } | |
408 else | |
409 { | |
410 p_src_start+=src_offset; | |
411 p_dst_start+=dst_offset; | |
412 x++; | |
413 } | |
414 | |
415 xnb--; | |
416 } | |
417 | |
418 | |
419 | |
420 | |
421 } | |
422 end_blit_b:dstvalue=0; | |
423 } | |
424 #endif |