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

📄 r2d_vertical_lcd_i.c

📁 MMI层OBJ不能完全编译
💻 C
📖 第 1 页 / 共 5 页
字号:
         #if (R2D_DITHERING == R2D_OFF)
		   if ((background) && (gc->background_texture!=NULL))
			pixel_value=r2d_get_texture_color();
         #endif
		 
		 

         new_value =R2D_PIXEL_DOWN_OUT(new_value);
		 
		 if (
			 ((rgn->one_sector==0) && (sides>=0) && (sidee>=0))
			 || 
			 ((rgn->one_sector==1) && (!(!(sides>=0) && !(sidee>=0))))
			 || (rgn->one_sector==2)
			 )
		 {
			 if (rgn->one_sector==0)
			start_filling=TRUE;
            new_value|=((dop(current_value & R2D_PIXEL_MASK,pixel_value) & R2D_PIXEL_MASK)
              << ((1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH)) ;
		 }
		 else
		 {
		   if (start_filling)
			   goto r2d_fail_line;
           new_value|=(current_value & R2D_PIXEL_MASK)
           << ((1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH) ;
		 }

		 ty++;
		 sides+=-(rgn->sa>>1);
		 sidee+=-(rgn->ea>>1);

         current_value=R2D_PIXEL_DOWN_OUT(current_value);
         current_y+=(1<<R2D_PIXEL_POS_TO_BIT_POS);
         if (current_y==(1<<R2D_MEMORY_WORD))
         {
            current_y=0;
            *p++=new_value;
            current_value=*p;
         }
         count++;
      } while (count<nb);

       while(current_y != (1<<R2D_MEMORY_WORD))
       {
         new_value =R2D_PIXEL_DOWN_OUT(new_value) ;
         new_value|=((current_value & R2D_PIXEL_MASK)
           << ((1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH)) ;
         current_value=R2D_PIXEL_DOWN_OUT(current_value);
         current_y+=(1<<R2D_PIXEL_POS_TO_BIT_POS);
       }
       *p++=new_value;

  }
    break;
    case R2D_LCD_KIND: // LCD format with any size
    {
       INT16 height,width;
       height=((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->height;
       width=((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->width;
      
       // Get position of the memory word containing the pixel
	#if (R2D_REFRESH == R2D_VERTICAL)
       p+=((x*R2D_ALIGNED_MWLENGTH(height)+(y>>R2D_PIXELS_PER_MEMORY_WORD)));
#else
	   p+=((x*R2D_ALIGNED_MWLENGTH(width)+(y>>R2D_PIXELS_PER_MEMORY_WORD)));
#endif

         if ((y<0) || (x<0) || ((p<((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->p_memory_words) 
         || (p>((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->p_frame_buffer_end)))
         {
           #if (R2D_DEBUG == R2D_ON)
              IND_rvf_send_trace("R2D : Framebuffer overflow",26, NULL_PARAM, 
				   RV_TRACE_LEVEL_ERROR, R2D_USE_ID );
           #endif
           goto r2d_fail_line;
         }



       // Get the pixel position into the memory word
	   new_value=0;
       y=y & R2D_WORD_POSITION_MASK;
	   y=y << R2D_PIXEL_POS_TO_BIT_POS;
       pixel_cache=*p;
       current_y=0;
       current_value=pixel_cache;
       if (y!=0)
       {
          do
          {
            new_value =R2D_PIXEL_DOWN_OUT(new_value) ;
            new_value|=((current_value & R2D_PIXEL_MASK)
              << ((1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH)) ;
            current_value=R2D_PIXEL_DOWN_OUT(current_value);
            current_y+=(1<<R2D_PIXEL_POS_TO_BIT_POS);
          } while (current_y != y);
       }
       count=0;
	   #if (R2D_DITHERING == R2D_OFF)
             if (background)
				 pixel_value=((T_R2D_GC*)gc)->background_pixel_value;
			 else
				 pixel_value=((T_R2D_GC*)gc)->foreground_pixel_value;
       #endif
       do
       {
		 #if (R2D_DITHERING == R2D_ON)
           if (background)
			  if (gc->background_texture!=NULL)
                pixel_value=r2d_get_texture_color();
			  else
                pixel_value=r2d_get_dithering_matrix_entry(((T_R2D_GC*)gc)->p_background_dithered_cache,x,ty);   
           else
             pixel_value=r2d_get_dithering_matrix_entry(((T_R2D_GC*)gc)->p_foreground_dithered_cache,x,ty);      
         #endif

         #if (R2D_DITHERING == R2D_OFF)
            if ((background) && (gc->background_texture!=NULL))
			   pixel_value=r2d_get_texture_color();
            #endif

		 

         new_value =R2D_PIXEL_DOWN_OUT(new_value);

		 if (
			 ((rgn->one_sector==0) && (sides>=0) && (sidee>=0))
			 || 
			 ((rgn->one_sector==1) && (!(!(sides>=0) && !(sidee>=0))))
			 || (rgn->one_sector==2)
			 )
		 {
			 if (rgn->one_sector==0)
			 start_filling=TRUE;
           new_value|=((dop(current_value & R2D_PIXEL_MASK,pixel_value) & R2D_PIXEL_MASK)
             << ((1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH)) ;
         }
		  else
		  {
			  if (start_filling)
			   goto r2d_fail_line;
          new_value|=((current_value & R2D_PIXEL_MASK)
             << ((1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH)) ;
		  }
		 ty++;
		 sides+=-(rgn->sa>>1);
		 sidee+=-(rgn->ea>>1);

		 current_value=R2D_PIXEL_DOWN_OUT(current_value);
         current_y+=(1<<R2D_PIXEL_POS_TO_BIT_POS);
         if (current_y==(1<<R2D_MEMORY_WORD))
         {
            current_y=0;
            *p++=new_value;
            current_value=*p;
         }
         count++;
      } while (count<nb);

       while(current_y != (1<<R2D_MEMORY_WORD))
       {
         new_value =R2D_PIXEL_DOWN_OUT(new_value);
         new_value|=((current_value & R2D_PIXEL_MASK)
           << ((1<<R2D_MEMORY_WORD) - R2D_PIXEL_DEPTH)) ;
         current_value=R2D_PIXEL_DOWN_OUT(current_value);
         current_y+=(1<<R2D_PIXEL_POS_TO_BIT_POS);
       }
       *p++=new_value;

   
    }
       break;

    case R2D_FULL_KIND: // LCD format with any size
    {
       INT16 height,width;
       height=((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->height;
       width=((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->width;
       

       // Get position of the memory word containing the pixel
#if (R2D_REFRESH == R2D_VERTICAL)
       p+=((x*height+y));
#else
	   p+=((x*width+y));
#endif

         if ((y<0) || (x<0) || ((p<((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->p_memory_words) 
         || (p>((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->p_frame_buffer_end)))
         {
           #if (R2D_DEBUG == R2D_ON)
              IND_rvf_send_trace("R2D : Framebuffer overflow",26, NULL_PARAM, 
				   RV_TRACE_LEVEL_ERROR, R2D_USE_ID );
           #endif
           goto r2d_fail_line;
         }



       // Get the pixel position into the memory word
       y=0;
	   new_value=0;
       pixel_cache=*p;
       current_y=0;
       current_value=pixel_cache;
       count=0;
       if (background)
       {
           pixel_value=((T_R2D_GC*)gc)->background_pixel_value;
       }
       else
       {
           pixel_value=((T_R2D_GC*)gc)->foreground_pixel_value;
       }

       do
       {
		 
            if ((background) && (gc->background_texture!=NULL))
			   pixel_value=r2d_get_texture_color();

		 
         if (
			 ((rgn->one_sector==0) && (sides>=0) && (sidee>=0))
			 || 
			 ((rgn->one_sector==1) && (!(!(sides>=0) && !(sidee>=0))))
			 || (rgn->one_sector==2)
			 )
		 {
			 if (rgn->one_sector==0)
			 start_filling=TRUE;
            new_value=dop(current_value,pixel_value);
		 }
         else
		 {
			 if (start_filling)
			   goto r2d_fail_line;
            new_value=current_value;
		 }
		 ty++;
		 sides+=-(rgn->sa>>1);
		 sidee+=-(rgn->ea>>1);

         current_y=0;
         *p++=new_value;
         current_value=*p;
         count++;
      } while (count<nb);


    
    }
       break;
  }
  r2d_fail_line:tmp=0; // Just because one needs code after a label
}

// Returns the equivalent color pixel value
// for the color kind of framebuffer
// It must be converted to RGB components
// Don't confuse with r2d_get_pixel_value which is
// just reading the cached pixel vlue from
// the graphic context.
// That routine is extracting the pixel value at position (x,y)
// from framebuffer
UINT32 r2d_get_color_pixel_value(T_R2D_GC* gc,INT16 x,INT16 y)
{
  UINT32 *p;
//  UINT16 tmp;
  UINT32 pixel_cache;//,new_value;
  UINT32 result;

  p=((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->p_memory_words;

  switch(((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->kind)
  {
    case 0: // LCD format with hard coded dimensions
		{
        // Get position of the memory word containing the pixel
#if (R2D_REFRESH == R2D_VERTICAL)
        p+=((x*R2D_MWHEIGHT+(y>>R2D_PIXELS_PER_MEMORY_WORD)));
#else
		p+=((x*R2D_MWWIDTH+(y>>R2D_PIXELS_PER_MEMORY_WORD)));
#endif

          if ((y<0) || (x<0) || ((p<((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->p_memory_words) 
          || (p>((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->p_frame_buffer_end)))
          {
            #if (R2D_DEBUG == R2D_ON)
               IND_rvf_send_trace("R2D : Framebuffer overflow",26, NULL_PARAM, 
				   RV_TRACE_LEVEL_ERROR, R2D_USE_ID );
            #endif
            goto r2d_fail_get_pixel;
          }


        // Get the pixel position into the memory word
        y=y & R2D_WORD_POSITION_MASK;
		y=y << R2D_PIXEL_POS_TO_BIT_POS;
        pixel_cache=*p;

        result=(pixel_cache >> y) & R2D_PIXEL_MASK;
        return((~IND_r2d_lcd_to_color(result)) & 0x00FFFFFF);
		}
    break;
    case R2D_LCD_KIND: // LCD format with any size
    {
      INT16 height,width;
      height=((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->height;
      width=((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->width;
     
#if (R2D_REFRESH == R2D_VERTICAL)
        // Get position of the memory word containing the pixel
        p+=((x*R2D_ALIGNED_MWLENGTH(height)+(y>>R2D_PIXELS_PER_MEMORY_WORD)));
#else
		p+=((x*R2D_ALIGNED_MWLENGTH(width)+(y>>R2D_PIXELS_PER_MEMORY_WORD)));
#endif


          if ((y<0) || (x<0) || ((p<((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->p_memory_words) 
          || (p>((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->p_frame_buffer_end)))
          {
            #if (R2D_DEBUG == R2D_ON)
               IND_rvf_send_trace("R2D : Framebuffer overflow",26, NULL_PARAM, 
				   RV_TRACE_LEVEL_ERROR, R2D_USE_ID );
            #endif
            goto r2d_fail_get_pixel;
          }


        // Get the pixel position into the memory word
        y=y & R2D_WORD_POSITION_MASK;
		y=y << R2D_PIXEL_POS_TO_BIT_POS;
        pixel_cache=*p;

        result=(pixel_cache >> y) & R2D_PIXEL_MASK;
        
        return(~IND_r2d_lcd_to_color(result) & 0x00FFFFFF);
    }
    break;
    case R2D_FULL_KIND:
    {
      INT16 height,width;
      height=((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->height;
      width=((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->width;
     
       //printf("%08X\n",p);
        // Get position of the memory word containing the pixel
#if (R2D_REFRESH == R2D_VERTICAL)
        p+=(x*height+y);
#else
		p+=(x*width+y);
#endif

       //printf(" --> %08X for x=%d and y=%d\n",p,x,y);


          if ((y<0) || (x<0) || ((p<((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->p_memory_words) 
          || (p>((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->p_frame_buffer_end)))
          {
            #if (R2D_DEBUG == R2D_ON)
               IND_rvf_send_trace("R2D : Framebuffer overflow",26, NULL_PARAM, 
				   RV_TRACE_LEVEL_ERROR, R2D_USE_ID );
            #endif
            goto r2d_fail_get_pixel;
          }


        // Get the pixel position into the memory word
        y=0;
        pixel_cache=*p;

        result=(~pixel_cache) & 0x00FFFFFF;
	}
    break;
  }
r2d_fail_get_pixel:return(0);
}

// Low level pixel drawing
// (Note that for filling a more efficient version is used
// taking into account the fact that the position
// in the framebuffer has not to be recomputed from the coordinates
// for each pixel)
void r2d_write_lcd_pixel(T_R2D_GC* gc,INT16 x,INT16 y,UINT32 pixel_value)
{
  UINT32 *p;
  UINT16 tmp;
  UINT32 pixel_cache,new_value;
  T_R2D_DRAWING_OP dop;

  dop=gc->drawing_op;

  p=((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->p_memory_words;

  switch(((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->kind)
  {
    case 0: // LCD format with hard coded dimensions
		{
        // Get position of the memory word containing the pixel
#if (R2D_REFRESH == R2D_VERTICAL)
        p+=((x*R2D_MWHEIGHT+(y>>R2D_PIXELS_PER_MEMORY_WORD)));
#else
		p+=((x*R2D_MWWIDTH+(y>>R2D_PIXELS_PER_MEMORY_WORD)));
#endif

          if ((y<0) || (x<0) || ((p<((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->p_memory_words) 
          || (p>((T_R2D_FRAMEBUFFER*)(gc->p_frame_buffer))->p_frame_buffer_end)))
          {
            #if (R2D_DEBUG == R2D_ON)
               IND_rvf_send_trace("R2D : Framebuffer overflow",26, NULL_PARAM, 
				   RV_TRACE_LEVEL_ERROR, R2D_USE_ID );
            #endif
            goto r2d_fail_pixel;
          }


        // Get the pixel position into the memory word
        y=y & R2D_WORD_POSITION_MASK;
		y=y << R2D_PIXEL_POS_TO_BIT_POS;
        pixel_cache=*p;

⌨️ 快捷键说明

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