⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 r2d_vertical_lcd_i.c

📁 是一个手机功能的模拟程序
💻 C
📖 第 1 页 / 共 5 页
字号:
              //printf("Error : frame_buffer overflow\n");
			  IND_rvf_send_trace("R2D : Framebuffer overflow C",28, NULL_PARAM, 
				   RV_TRACE_LEVEL_ERROR, R2D_USE_ID );
         }
#endif
#endif

        
		}
		else
		{
			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(current_src_dy!=src_dy)
			{
            
              r2d_shift_pixel_down(temp,src_current,srccounter,p_src_current);
              current_src_dy++;
			  
            
			}
			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;
#if (R2D_DEBUG == R2D_ON)
#if (R2D_DEBUG_WARNING == R2D_DEBUG_HIGH)
         if ((p_dst_current<((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)dst_gc)->p_frame_buffer))->p_memory_words) 
         || (p_dst_current>((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)dst_gc)->p_frame_buffer))->p_frame_buffer_end))
         {
			 char error[256];
			 T_R2D_RECT *dst;

			 //dst=(T_R2D_RECT*)dst_rectangle;
			 //sprintf(error,"%d %d %d %d",dst->ul_x,dst->ul_y,
			//	 dst->br_x,dst->br_y);
			 //IND_rvf_send_trace(error,strlen(error), NULL_PARAM, 
			//	   RV_TRACE_LEVEL_ERROR, R2D_USE_ID );
              //printf("Error : frame_buffer overflow\n");
			  IND_rvf_send_trace("R2D : Framebuffer overflow D",28, NULL_PARAM, 
				   RV_TRACE_LEVEL_ERROR, R2D_USE_ID );
         }
#endif
#endif

                 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++;
              //printf("Last row %08X\n",p_dst_current);
			  y++;
            
			}
			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;
			}
#if (R2D_DEBUG == R2D_ON)
#if (R2D_DEBUG_WARNING == R2D_DEBUG_HIGH)
         if ((p_dst_current<((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)dst_gc)->p_frame_buffer))->p_memory_words) 
         || (p_dst_current>((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)dst_gc)->p_frame_buffer))->p_frame_buffer_end))
         {
              //printf("Error : frame_buffer overflow\n");
			  IND_rvf_send_trace("R2D : Framebuffer overflow E",28, NULL_PARAM, 
				   RV_TRACE_LEVEL_ERROR, R2D_USE_ID );
         }
#endif
#endif

		}

        
        dstvalue=0;
        
          
        if (h_direction==-1)
        {
          p_src_start-=src_offset;
          p_dst_start-=dst_offset;
		  x--;
        }
        else
        {
          p_src_start+=src_offset;
          p_dst_start+=dst_offset;
		  x++;
        }

        xnb--;
      }

      
      
    
  }
  
}


#undef r2d_shift_pixel_down_and_write
#undef r2d_shift_pixel_up_and_write

#define r2d_shift_pixel_down_and_write(dst,src) {\
               dst##value =R2D_PIXEL_DOWN_OUT(dst##value); \
               dst##value|=dop((dst##_current & R2D_PIXEL_MASK), \
               r2d_convert_from_color_to_color(use_foreground_color,\
			   src##_current & R2D_PIXEL_MASK,src_gc,dst_gc,x,y)) \
               << ((1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH) ; \
               src##_current=R2D_PIXEL_DOWN_OUT(src##_current); \
               dst##_current=R2D_PIXEL_DOWN_OUT(dst##_current); \
               dst##counter--; \
               src##counter--; \
               if (src##counter==0) \
               { \
                 src##counter=(1<<R2D_PIXELS_PER_MEMORY_WORD); \
                 src##_current=*++p_##src##_current;  \
               } \
               if (dst##counter==0) \
               { \
                 dst##counter=(1<<R2D_PIXELS_PER_MEMORY_WORD); \
               } \
               }

#define r2d_shift_pixel_up_and_write(dst,src) {\
               dst##value =R2D_PIXEL_UP_OUT(dst##value); \
               dst##value |=dop( \
               (dst##_current >> ((1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH)) & R2D_PIXEL_MASK, \
               r2d_convert_from_color_to_color(use_foreground_color,\
			   (src##_current >> ((1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH)) & R2D_PIXEL_MASK, \
			   src_gc,dst_gc,x,y)); \
               src##_current=R2D_PIXEL_UP_OUT(src##_current); \
               dst##_current=R2D_PIXEL_UP_OUT(dst##_current); \
               dst##counter--; \
               src##counter--; \
               if (src##counter==0) \
               { \
                 src##counter=(1<<R2D_PIXELS_PER_MEMORY_WORD); \
                 src##_current=*--p_##src##_current;  \
               } \
               if (dst##counter==0) \
               { \
                 dst##counter=(1<<R2D_PIXELS_PER_MEMORY_WORD); \
               } \
               }



// Requires shapes in graphic context coordinates
void           r2d_blit_color_to_color(T_R2D_GC_PTR src_gc,T_R2D_GC_PTR dst_gc,
                             T_R2D_SHAPE_PTR src_rectangle, 
							 T_R2D_SHAPE_PTR dst_rectangle,
							 R2D_BOOLEAN use_foreground_color)
{
    UINT32 *p_src,*p_dst,*p_src_current,*p_dst_current,*p_src_start,*p_dst_start,value;
    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,nb_rows;
    INT16 temp,x,y;


    INT32  h_direction,v_direction;
    T_R2D_DRAWING_MODE mode;
    T_R2D_DRAWING_OP dop;
	

    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);

    mode=IND_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);


    // Number of rows is word containing last point - word containing first point
    // + 1
    nb_rows=(r2d_get_ymax(dst_rectangle)-1)-(dst_y)+1;
    //printf("nb_rows %d\n",nb_rows);
    
    h_direction=1;
    v_direction=1;
    if (((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)src_gc)->p_frame_buffer))==
       ((T_R2D_FRAMEBUFFER*)(((T_R2D_GC*)dst_gc)->p_frame_buffer)))
      r2d_check_rectangle_overlap(src_x,src_y,dst_x,dst_y,
      rect_width,rect_height,&h_direction,&v_direction);

    //printf("h,v=%d,%d\n",h_direction,v_direction);


 #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

      src_offset=(src_height);
      dst_offset=(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)));

      xnb=rect_width;

      //printf("start %08X contains %08X\n",p_dst_start,*p_dst_start);

      if (h_direction==-1)
      {
		x=r2d_get_xmax(dst_rectangle)-1;
        p_src_start+=(rect_width-1)*src_offset;
        p_dst_start+=(rect_width-1)*dst_offset;
      }
	  else
		x=r2d_get_xmin(dst_rectangle);

      if (v_direction==-1)
      {
        p_src_start+=nb_rows-1;
        p_dst_start+=nb_rows-1;

      }

      //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=nb_rows; // Not using - 1 since not different processing of ending word
        // (which is here a pixel instead of being only a memory word)
        
        
        
        //printf("src_current=%08X, dst_current=%08X\n",src_current,dst_current);
        //printf("new column\n dst=%08X\n",p_dst_current);
        
		if (v_direction==-1)
		{
			while(ynb!=0)
			{
            
              value=*p_dst_current;
              *p_dst_current--=dop(value,*p_src_current--);
			  y--;
            
              ynb--;
			}
		}
		else
		{
			while(ynb!=0)
			{
            
              value=*p_dst_current;
              *p_dst_current++=dop(value,*p_src_current++);
			  y++;
           
              ynb--;
			}
		}

        
          
        if (h_direction==-1)
        {
          p_src_start-=src_offset;
          p_dst_start-=dst_offset;
		  x--;
        }
        else
        {
          p_src_start+=src_offset;
          p_dst_start+=dst_offset;
		  x++;
        }

        xnb--;
      }

      
      
   
  }
  
}


#undef r2d_shift_pixel_down_and_write
#undef r2d_shift_pixel_up_and_write

#define r2d_shift_pixel_down_and_write(dst,src) {\
               dst##value =r2d_convert_from_lcd_to_color(use_foreground_color,\
			   src##_current & R2D_PIXEL_MASK,src_gc,dst_gc,x,y); \
               dst##value =dop(*p_dst_current,dst##value); \
               *p_##dst##_current++=dst##value;\
               src##_current=R2D_PIXEL_DOWN_OUT(src##_current); \
               src##counter--; \
               if (src##counter==0) \
               { \
                 src##counter=(1<<R2D_PIXELS_PER_MEMORY_WORD); \
                 src##_current=*++p_##src##_current;  \
               } \
               }


#define r2d_shift_pixel_up_and_write(dst,src) {\
               dst##value =r2d_convert_from_lcd_to_color(use_foreground_color,\
			   src##_current & R2D_PIXEL_MASK,src_gc,dst_gc,x,y); \
               dst##value =dop(*p_dst_current,dst##value); \
               *p_##dst##_current--=dst##value;\
               src##_current=R2D_PIXEL_UP_OUT(src##_current); \
               src##counter--; \
               if (src##counter==0) \
               { \
                 src##counter=(1<<R2D_PIXELS_PER_MEMORY_WORD); \
                 src##_current=*--p_##src##_current;  \
               } \
               }

// Requires shapes in graphic context coordinates
void           r2d_blit_lcd_to_color(T_R2D_GC_PTR src_gc,T_R2D_GC_PTR dst_gc,
                             T_R2D_SHAPE_PTR src_rectangle, 
							 T_R2D_SHAPE_PTR dst_rectangle,
							 R2D_BOOLEAN use_foreground_color)
{
    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,src_nb_rows,dst_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_src_dy,current_dst_dy;
    INT16 temp,dstcounter,srccounter;


    register UINT32 dstvalue,dst_current;
    register UINT32 srcvalue,src_current;
    INT32  h_direction,v_direction;
	INT16 x,y;
    T_R2D_DRAWING_MODE mode;
	T_R2D_DRAWING_OP dop;

    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);

    mode=IND_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);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -