📄 r2d_geometry_no2_lcd_i_color_to_lcd.c
字号:
#include "general.h"
#include "rvf/rvf_api.h"
#include "r2d/r2d_config.h"
#include "r2d/r2d.h"
#include "r2d/r2d_i.h"
#include "r2d/r2d_independance_layer.h"
#if (R2D_PIXEL_DEPTH == 32)
#define R2D_PIXEL_DOWN_OUT(a) (0)
#define R2D_PIXEL_UP_OUT(a) (0)
#else
#define R2D_PIXEL_DOWN_OUT(a) (a>>R2D_PIXEL_DEPTH)
#define R2D_PIXEL_UP_OUT(a) (a<<R2D_PIXEL_DEPTH)
#endif
#if (R2D_ASM == R2D_ON)
#define r2d_shift_pixel_down(dststream,srccache,srccounter,srcstream) {dststream =R2D_PIXEL_DOWN_OUT(dststream); \
dststream|=((srccache & R2D_PIXEL_MASK) \
<< ((1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH)) ; \
srccache=R2D_PIXEL_DOWN_OUT(srccache); \
srccounter--; \
if (srccounter==0) \
{ \
srccounter=(1<<R2D_PIXELS_PER_MEMORY_WORD); \
srccache=*++srcstream; \
} }
#define my_r2d_convert_from_color_to_lcd(pixel_value) \
(\
(((pixel_value)&0xF80000)>>8) | \
(((pixel_value)&0xFC00)>>5) |\
(((pixel_value)&0xF8)>>3)\
)
#define r2d_shift_pixel_down_and_write(dst,src) {\
dst##value =R2D_PIXEL_DOWN_OUT(dst##value); \
src##_current=my_r2d_convert_from_color_to_lcd(*p_##src##_current); \
p_##src##_current++;\
dst##value|=dop((dst##_current & R2D_PIXEL_MASK), \
src##_current) \
<< ((1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH) ; \
dst##_current=R2D_PIXEL_DOWN_OUT(dst##_current); \
dst##counter--; \
if (dst##counter==0) \
{ \
dst##counter=(1<<R2D_PIXELS_PER_MEMORY_WORD); \
} \
}
void memcpy_16(char *dst, char *src, int width)
{
int *s = (int *)src;
short *d = (short*)dst;
int quotient,reste;
quotient=width >> 3;
reste=width&7;
while (quotient-->0)
{
*d++ = my_r2d_convert_from_color_to_lcd(*s);s++;
*d++ = my_r2d_convert_from_color_to_lcd(*s);s++;
*d++ = my_r2d_convert_from_color_to_lcd(*s);s++;
*d++ = my_r2d_convert_from_color_to_lcd(*s);s++;
*d++ = my_r2d_convert_from_color_to_lcd(*s);s++;
*d++ = my_r2d_convert_from_color_to_lcd(*s);s++;
*d++ = my_r2d_convert_from_color_to_lcd(*s);s++;
*d++ = my_r2d_convert_from_color_to_lcd(*s);s++;
}
while (reste-->0)
{
*d++ = my_r2d_convert_from_color_to_lcd(*s);s++;
}
}
void r2d_blit_color_to_lcd_little(T_R2D_GC_PTR src_gc,T_R2D_GC_PTR dst_gc,
T_R2D_SHAPE_PTR src_rectangle,
T_R2D_SHAPE_PTR dst_rectangle )
{
UINT32 *p_src,*p_dst,*p_src_current,*p_dst_current,*p_src_start,*p_dst_start;
INT16 rect_width,rect_height,src_x,src_y,dst_x,dst_y;
INT16 src_offset,dst_offset,src_height,dst_height;
INT16 xnb,ynb,dst_nb_rows,src_nb_rows;
INT16 src_dy,dst_dy,end_dst_dy,end_src_dy; // distance from word boundary
// INT16 shift; // relative position (modulo a memory word) between both rectangles
// in bits
INT16 current_dst_dy;//,current_src_dy;
INT16 temp,dstcounter,srccounter;
register UINT32 dstvalue,dst_current;
register UINT32 src_current;//,srcvalue;
INT16 x,y;
T_R2D_DRAWING_MODE mode;
T_R2D_DRAWING_OP dop;
BOOLEAN compensate=TRUE;
short *d;
dop=((T_R2D_GC*)dst_gc)->drawing_op;
{
p_src=((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)src_gc)->p_frame_buffer))->p_memory_words;
p_dst=((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)dst_gc)->p_frame_buffer))->p_memory_words;
rect_width=r2d_get_xmax(src_rectangle)-r2d_get_xmin(src_rectangle);
rect_height=r2d_get_ymax(src_rectangle)-r2d_get_ymin(src_rectangle);
if ((rect_width<=0) || (rect_height<=0))
goto end_blit_e;
mode=r2d_get_drawing_mode(dst_gc);
src_x=r2d_get_xmin(src_rectangle);
src_y=r2d_get_ymin(src_rectangle);
dst_x=r2d_get_xmin(dst_rectangle);
dst_y=r2d_get_ymin(dst_rectangle);
src_dy=src_y & R2D_WORD_POSITION_MASK;
dst_dy=dst_y & R2D_WORD_POSITION_MASK;
// Clipping convention such end_dst_dy is the first y position which must not
// be copied at the end of a column
end_dst_dy=(r2d_get_ymax(dst_rectangle)-1) & R2D_WORD_POSITION_MASK ;
end_src_dy=(r2d_get_ymax(src_rectangle)-1) & R2D_WORD_POSITION_MASK ;
// Number of rows is word containing last point - word containing first point
// + 1
dst_nb_rows=R2D_ALIGNED_MWLENGTH(r2d_get_ymax(dst_rectangle)-1)-R2D_ALIGNED_MWLENGTH(dst_y) + 1;
src_nb_rows=(r2d_get_ymax(src_rectangle))-(src_y);
#if (R2D_REFRESH == R2D_VERTICAL)
src_height=((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)src_gc)->p_frame_buffer))->height;
dst_height=((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)dst_gc)->p_frame_buffer))->height;
#else
src_height=((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)src_gc)->p_frame_buffer))->width;
dst_height=((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)dst_gc)->p_frame_buffer))->width;
#endif
#if 1
src_offset=src_height;
dst_offset=(R2D_ALIGNED_MWLENGTH(dst_height)<<1);
d = (short *)p_dst;
p_src_start=p_src
+((src_x*src_offset+(src_y)));
d+=(dst_x*dst_offset+(dst_y));
xnb=rect_width;
dst_nb_rows=r2d_get_ymax(dst_rectangle)-dst_y;
while(xnb--!=0)
{
memcpy_16((char *)d, (char *)p_src_start, dst_nb_rows);
d+=dst_offset;
p_src_start+=src_offset;
}
#else
src_offset=src_height;
dst_offset=R2D_ALIGNED_MWLENGTH(dst_height);
//printf("%08X,dst offset=%08X\n",p_dst,dst_offset);
p_src_start=p_src
+((src_x*src_offset+(src_y)));
p_dst_start=p_dst
+((dst_x*dst_offset+(dst_y>>R2D_PIXELS_PER_MEMORY_WORD)));
xnb=rect_width;
//printf("start %08X contains %08X\n",p_dst_start,*p_dst_start);
x=r2d_get_xmin(dst_rectangle);
//printf("dst_start=%08X contains %08X\n",p_dst_start,*p_dst_start);
while(xnb!=0)
{
p_dst_current=p_dst_start;
p_src_current=p_src_start;
ynb=dst_nb_rows-1;
current_dst_dy=0;
y=r2d_get_ymin(dst_rectangle);
dstcounter=(1<<R2D_PIXELS_PER_MEMORY_WORD);
srccounter=(1<<R2D_PIXELS_PER_MEMORY_WORD);
dst_current=*p_dst_current;
//printf("src_current=%08X, dst_current=%08X\n",src_current,dst_current);
temp=0;
//printf("new column\n dst=%08X\n",p_dst_current);
dstvalue=0;
//printf("current_dst_dy=%08X,dst_dy=%08X\n",current_dst_dy,dst_dy);
while(current_dst_dy!=dst_dy)
{
r2d_shift_pixel_down(dstvalue,dst_current,dstcounter,p_dst_current);
current_dst_dy++;
y++;
//printf("dstcounter=%d\n",dstcounter);
}
while(ynb!=0)
{
r2d_shift_pixel_down_and_write(dst,src);
y++;
if (dstcounter==(1<<R2D_PIXELS_PER_MEMORY_WORD))
{
ynb--;
*p_dst_current++=dstvalue;
current_dst_dy=0;
dst_current=*p_dst_current;
//printf("%08X <- %08X\n",p_dst_current,dstvalue);
dstvalue=0;
}
}
current_dst_dy--;
while(current_dst_dy!=end_dst_dy)
{
r2d_shift_pixel_down_and_write(dst,src);
current_dst_dy++;
y++;
//printf("Last row %08X\n",p_dst_current);
}
if (dstcounter==(1<<R2D_PIXELS_PER_MEMORY_WORD))
compensate=FALSE;
while(dstcounter!=(1<<R2D_PIXELS_PER_MEMORY_WORD))
{
r2d_shift_pixel_down(dstvalue,dst_current,dstcounter,p_dst_current);
current_dst_dy++;
//printf("Last row %08X\n",p_dst_current);
y++;
}
if (compensate==TRUE)
{
*--p_dst_current=dstvalue;
}
else
{
*p_dst_current=dstvalue;
}
dstvalue=0;
x++;
p_src_start+=src_offset;
p_dst_start+=dst_offset;
xnb--;
}
#endif
}
end_blit_e:dstvalue=0;
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -