亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? simple_graphics.c

?? VGA核的verilog實現
?? C
?? 第 1 頁 / 共 3 頁
字號:
/***********************************************************************
 *                                                                     *
 * File:     simple_graphics.c                                         *
 *                                                                     *
 * Purpose:  Contains some useful graphics routines                    *
 *                                                                     *
 * Author:   N. Knight                                                 *
 *           Altera Corporation                                        *
 *           Apr 2006                                                  *
 **********************************************************************/

#include <string.h>

#include "simple_graphics.h"
#include "io.h"
#include "sys/alt_alarm.h"
#include "sys/alt_cache.h"
#include "system.h"


/******************************************************************
*  Function: vid_draw_line
*
*  Purpose: Draws a line between two end points. First checks
*           to see if the line is horizontal.  If it is, it calls
*           vid_draw_horiz_line(), which is much faster than 
*           vid_draw_sloped_line.
*
******************************************************************/
__inline__ void vid_draw_line(int horiz_start, int vert_start, int horiz_end, int vert_end, int width, int color, display_frame_buffer_struct* frame_buffer)
{
 
  if( vert_start == vert_end )
  {
//    c2h_draw_horiz_line( (unsigned short)horiz_start, 
//                         (unsigned short)horiz_end,  
//                         (unsigned short)vert_start,
//                         color,
//                         frame_buffer->frame1);

    vid_draw_horiz_line( (unsigned short)horiz_start, 
                         (unsigned short)horiz_end, 
                         (unsigned short)vert_start,
                         color,
                         frame_buffer );
  }
  else
  {
    vid_draw_sloped_line( (unsigned short)horiz_start, 
                          (unsigned short)vert_start, 
                          (unsigned short)horiz_end, 
                          (unsigned short)vert_end, 
                          (unsigned short)width, 
                          color,
                          frame_buffer );
  }
}



void vid_scroll_string_quit(vid_text_scroll_struct* scroll)
{
  free(scroll->string);
  free(scroll);
}

vid_text_scroll_struct* vid_scroll_string_init(int hbegin, int vbegin, int hend, int f_color, int b_color, char* font, int ms_delay, char *string)
{
  vid_text_scroll_struct* scroll;
  scroll = malloc(sizeof (vid_text_scroll_struct));
  
  scroll->hbegin = hbegin;
  scroll->vbegin = vbegin;
  scroll->hend = hend;
  scroll->f_color = f_color;
  scroll->b_color = b_color;
  scroll->string = malloc(strlen(string)+2);
  strcpy(scroll->string, string);
  scroll->font = font;
  scroll->ms_delay = ms_delay;
  scroll->ticks_at_last_move = alt_nticks();
  scroll->text_scroll_index = 0;
  scroll->text_scroll_started = 0;
  scroll->window_width = scroll->hend - scroll->hbegin;
  scroll->length_of_string = strlen(string);
  scroll->string_points = scroll->length_of_string * 8;
  scroll->scroll_points = (scroll->window_width + scroll->string_points);
 
  return(scroll);
  
}


int vid_scroll_string(vid_text_scroll_struct* scroll, display_frame_buffer_struct* frame_buffer)
{

  int x_start, x_end, x_index, string_x_index, string_char_index, char_row, char_column;
  char character, column_mask;
  char* font_char_ptr;
  char pixels_to_move_by = 1;

  // If it's time to move the scroll..
  if (alt_nticks() >= (scroll->ticks_at_last_move + ((alt_ticks_per_second() * (scroll->ms_delay)) / 1000))) {
    scroll->ticks_at_last_move = alt_nticks();
    
    // Track where we are in the scroll.
    if(scroll->text_scroll_started == 0) {
      scroll->text_scroll_index = 0;
      scroll->text_scroll_started = 1;
    } else if(scroll->text_scroll_index >= scroll->scroll_points)  {
      scroll->text_scroll_started = 0;
    } else {
      scroll->text_scroll_index += pixels_to_move_by;
    }
    
    //Find out where we start
    if (scroll->text_scroll_index < scroll->window_width) {
      x_start = scroll->hbegin + scroll->window_width - scroll->text_scroll_index;
    } else {
      x_start = scroll->hbegin;
    }
    //Find out where we end
    if (scroll->string_points > scroll->text_scroll_index) {
      x_end = scroll->hend;
    } else {
      x_end = (scroll->hend - scroll->text_scroll_index + scroll->string_points);
    }

    // Write the string segment a column (x) at a time
    for(x_index = x_start; x_index < x_end; x_index++) {
      // Find the x index we're at within the string
      // If first part of string hasnt yet reached left side of scroll window
      if (scroll->text_scroll_index < scroll->window_width) {
        string_x_index = (x_index - x_start);
      } else {
        string_x_index = scroll->text_scroll_index - scroll->window_width + x_index - x_start;
      }
      //Find the character we're supposed to be writing
      string_char_index = (string_x_index / 8);
      character = scroll->string[string_char_index];
      char_column = (string_x_index % 8);
      column_mask = (((unsigned int)0x80) >> char_column);
      font_char_ptr = (scroll->font + ((character - 0x20) * FONT_10PT_ROW));
      //We have all the data now, so let's write a column
      for(char_row = 0; char_row < 11; char_row++) {
        // If the font table says this pixel is on, then set it to the foreground color
        if (*(font_char_ptr + char_row) & column_mask) {
          vid_set_pixel(x_index, scroll->vbegin + char_row, scroll->f_color, frame_buffer); 
        // Otherwise, set it to the background color.
        } else {
          vid_set_pixel(x_index, scroll->vbegin + char_row, scroll->b_color, frame_buffer); //background color
        }
      }
    }
    // Erase the leftover column (x) of the last string we wrote.
    vid_draw_line(x_end, scroll->vbegin, x_end, scroll->vbegin + 10, 1, scroll->b_color, frame_buffer);
    // Log what time we moved the scroll.
  }
  return(0);
}


/******************************************************************
*  Function: vid_move_block
*
*  Purpose: Moves a block around the screen, backfilling with 
*           the backfill_color parameter.
*
******************************************************************/

int vid_move_block(int xbegin, int ybegin, int xend, int yend, int x_distance, int y_distance, int backfill_color, display_frame_buffer_struct* frame_buffer)
{
  int read_x, read_y, write_x, write_y;
  short temp_pixel;
  
  if(x_distance <= 0 && y_distance <= 0) {  
    //Move by rows because they are contiguous in memory (could help speed if in SDRAM)
    for (read_y = ybegin; read_y < yend; read_y++) {
      write_y = read_y + y_distance;
      for(read_x = xbegin; read_x < xend; read_x++) {
        write_x = read_x + x_distance;
        temp_pixel = vid_get_pixel(read_x, read_y, frame_buffer);
        vid_set_pixel(write_x, write_y, temp_pixel, frame_buffer);
        if(read_x >= xend + x_distance || read_y >= yend + y_distance) 
        {
	        vid_set_pixel(read_x, read_y, backfill_color, frame_buffer);
        }
      }
    }
  }
  return (0);
}

/******************************************************************
*  Function: vid_print_string
*
*  Purpose: Prints a string to the specified location of the screen
*           using the specified font and color.
*           Calls vid_print_char
*
******************************************************************/
int vid_print_string(int horiz_offset, int vert_offset, int color, char *font, display_frame_buffer_struct* frame_buffer, char string[])
{
  int i = 0;
  int original_horiz_offset;

  original_horiz_offset = horiz_offset;

  // Print until we hit the '\0' char.
  while (string[i]) {
    //Handle newline char here.
    if (string[i] == '\n') {
      horiz_offset = original_horiz_offset;
      vert_offset += 12;
      i++;
      continue;
    }
    // Lay down that character and increment our offsets.
    vid_print_char (horiz_offset, vert_offset, color, string[i], font, frame_buffer);
    i++;
    horiz_offset += 8;
  }
  return (0);
}

/******************************************************************
*  Function: vid_draw_box
*
*  Purpose: Draws a box on the screen with the specified corner
*  points.  The fill parameter tells the function whether or not
*  to fill in the box.  1 = fill, 0 = do not fill.
*
******************************************************************/
int vid_draw_box (int horiz_start, int vert_start, int horiz_end, int vert_end, int color, int fill, display_frame_buffer_struct* frame_buffer)
{

  // If we want to fill in our box
  if (fill) {
     vid_paint_block (horiz_start, vert_start, horiz_end, vert_end, color, frame_buffer);
  // If we're not filling in the box, just draw four lines.
  } else {
    vid_draw_line(horiz_start, vert_start, horiz_start, vert_end-1, 1, color, frame_buffer);
    vid_draw_line(horiz_end-1, vert_start, horiz_end-1, vert_end-1, 1, color, frame_buffer);
    vid_draw_line(horiz_start, vert_start, horiz_end-1, vert_start, 1, color, frame_buffer);
    vid_draw_line(horiz_start, vert_end-1, horiz_end-1, vert_end-1, 1, color, frame_buffer);
  }

  return (0);
}


/******************************************************************
*  Function: vid_print_char
*
*  Purpose: Prints a character to the specified location of the
*           screen using the specified font and color.
*
******************************************************************/

int vid_print_char (int horiz_offset, int vert_offset, int color, char character, char *font, display_frame_buffer_struct* frame_buffer)
{

  int i, j;
  
  char temp_char, char_row;

  // Convert the ASCII value to an array offset
  temp_char = (character - 0x20);

  //Each character is 8 pixels wide and 11 tall.
  for(i = 0; i < 11; i++) {
      char_row = *(font + (temp_char * FONT_10PT_ROW) + i);
    for (j = 0; j < 8; j++) {
      //If the font table says the pixel in this location is on for this character, then set it.
      if (char_row & (((unsigned char)0x80) >> j)) {
        vid_set_pixel((horiz_offset + j), (vert_offset + i), color, frame_buffer); // plot the pixel
      }
    }
  }
  return(0);
}


/******************************************************************
*  Function: vid_set_pixel
*
*  Purpose: Sets the specified pixel to the specified color.
*           Sets one pixel although frame buffer consists of
*           two-pixel words.  Therefore this function is not
*           efficient when painting large areas of the screen.
*
******************************************************************/

void vid_set_pixel(int horiz, int vert, unsigned int color, display_frame_buffer_struct* frame_buffer)
{
  int addr;
  
  if( frame_buffer->color_depth == 32 )
  {
  	addr = ( ( (int)(frame_buffer->frame1) )+ (vert * (frame_buffer->width * 4)) + horiz * 4);
		IOWR_32DIRECT( addr, 0, (unsigned int)(color));
  }
  
  else if( frame_buffer->color_depth == 24 )
  {
  	addr = ( ( (int)(frame_buffer->frame1) )+ (vert * (frame_buffer->width * 3)) + horiz * 3);
		IOWR_8DIRECT( addr, 0, (unsigned char)(color));
 		IOWR_8DIRECT( addr+1, 0, (unsigned char)(color >> 8));
    IOWR_8DIRECT( addr+2, 0, (unsigned char)(color >> 16));
  }
  
  else if( frame_buffer->color_depth == 16 )
  {
  	addr = ( ( (int)(frame_buffer->frame1) )+ (vert * (frame_buffer->width * 2)) + horiz * 2);
  	IOWR_16DIRECT( addr, 0, (int)(color));
	}


}

/******************************************************************
*  Function: vid_get_pixel
*
*  Purpose: Reads the color of the pixel at the given coordinates
*
******************************************************************/

short vid_get_pixel(int horiz, int vert, display_frame_buffer_struct* frame_buffer)
{
  int addr;
  
  addr = ( ( (int)(frame_buffer->frame1) )+ (vert * (frame_buffer->width * 2)) + horiz * 2);
  return(IORD_16DIRECT(addr, 0));

}


/******************************************************************
*  Function: vid_paint_block
*
*  Purpose: Paints a block of the screen the specified color.
*           Note: works with two pixels at a time to maintain high
*           bandwidth.  Therefore, corner points must be even
*           numbered coordinates.  Use vid_draw_solid_box() for
*           areas with odd-numbered corner points.
*           The color parameter must contain two pixel's worth
*           (32 bits).
*
******************************************************************/
void vid_paint_block (int Hstart,int Vstart, int Hend, int Vend, int color, display_frame_buffer_struct* frame_buffer)
{

  int i;
  int addr;
  int bytes_per_line, bytes_per_pixel;
  char* line;
  
  bytes_per_pixel = (frame_buffer->color_depth / 8);
  bytes_per_line = ((Hend - Hstart) * bytes_per_pixel);

  line = malloc(bytes_per_line + 12);

	if(frame_buffer->color_depth == 16)
	{
    for (i = 0; i < bytes_per_line; i+=2) 
    {

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
中文字幕在线不卡国产视频| 国产福利精品导航| 久久久久久久久一| 欧美不卡一区二区三区| 91成人免费网站| 欧美性高清videossexo| 一本一道波多野结衣一区二区| 国产精品一区二区男女羞羞无遮挡 | 国产成人精品免费看| 久久成人久久鬼色| 国产大片一区二区| av一区二区三区黑人| 91国模大尺度私拍在线视频| 欧美性一二三区| 日韩欧美的一区| 国产午夜一区二区三区| 中文字幕av一区二区三区免费看| 国产精品国产自产拍在线| 亚洲欧美另类小说视频| 亚州成人在线电影| 国产剧情一区二区| 一本久久a久久免费精品不卡| 欧美丝袜丝交足nylons| 欧美三片在线视频观看| 337p亚洲精品色噜噜狠狠| 欧美mv日韩mv国产网站| 国产精品视频线看| 亚洲bdsm女犯bdsm网站| 国产精品中文有码| 欧美午夜一区二区三区免费大片| 日韩一区二区三区视频| 国产精品不卡视频| 另类调教123区| 色中色一区二区| 久久综合九色综合97_久久久| 亚洲同性gay激情无套| 蜜臀av性久久久久蜜臀aⅴ流畅| 国产电影一区二区三区| 精品1区2区3区| 中文幕一区二区三区久久蜜桃| 亚洲一区二区欧美| 国产不卡视频在线观看| 制服丝袜中文字幕亚洲| 国产精品热久久久久夜色精品三区| 亚洲成av人综合在线观看| 粉嫩蜜臀av国产精品网站| 欧美日韩国产免费一区二区| 国产精品午夜久久| 国内精品伊人久久久久av影院| 欧洲一区在线电影| 中文字幕在线不卡国产视频| 国产成人自拍网| 日韩情涩欧美日韩视频| 亚洲成人1区2区| 色婷婷综合激情| 中文字幕高清不卡| 国产麻豆一精品一av一免费| 91精品国产综合久久精品app| 一区二区三区国产精品| 成人av资源在线观看| 久久久99精品免费观看不卡| 久草在线在线精品观看| 91麻豆精品国产91久久久资源速度 | 亚洲国产成人一区二区三区| 蜜桃久久久久久| 欧美日韩一区二区欧美激情| 一区二区三区不卡在线观看 | 一本大道综合伊人精品热热| 亚洲国产高清不卡| 成人黄色777网| 国产精品久久久久毛片软件| 波多野洁衣一区| 国产精品久久久久影院老司 | 欧美一区二区三区人| 亚洲第一主播视频| 欧美日韩黄视频| 天天爽夜夜爽夜夜爽精品视频| 3751色影院一区二区三区| 三级影片在线观看欧美日韩一区二区 | 日韩精品一二区| 日韩一区二区免费电影| 美腿丝袜亚洲综合| 欧美精品一区二区在线观看| 经典三级一区二区| 国产偷国产偷亚洲高清人白洁| 韩国一区二区视频| 中文字幕av一区二区三区| 成人美女视频在线看| 国产精品美女久久久久久久久| 99久久精品情趣| 亚洲午夜电影在线| 8x8x8国产精品| 国产精品一区二区久久不卡| 亚洲欧洲一区二区三区| 欧美精品日韩一区| 韩国欧美国产一区| 国产精品视频你懂的| 欧美日韩一区二区电影| 韩国精品一区二区| 亚洲视频小说图片| 欧美一区二区在线看| 粉嫩一区二区三区性色av| 亚洲综合男人的天堂| 欧美大胆人体bbbb| 99精品国产热久久91蜜凸| 五月婷婷久久丁香| 亚洲国产精品精华液ab| 欧美日韩免费视频| 丁香婷婷深情五月亚洲| 亚洲黄色性网站| 久久综合九色综合97婷婷女人| 91久久精品一区二区三区| 久久aⅴ国产欧美74aaa| 一区二区三区中文免费| 久久久.com| 7799精品视频| 欧洲精品中文字幕| 国产成a人亚洲精品| 日韩激情在线观看| 综合久久综合久久| 国产日韩欧美综合一区| 欧美精品 日韩| 在线一区二区三区| 成人精品视频.| 国产美女视频91| 蜜臀av一区二区| 亚洲综合另类小说| 日韩一区欧美一区| 久久嫩草精品久久久精品一| 91精品国产综合久久精品麻豆 | 欧美视频中文一区二区三区在线观看| 国产一区二区三区精品视频| 亚洲gay无套男同| 亚洲六月丁香色婷婷综合久久| 欧美xxxxx牲另类人与| 欧美麻豆精品久久久久久| 99久久国产综合精品色伊| 国产91精品精华液一区二区三区 | 欧美岛国在线观看| 欧美一区二区三区影视| 欧美综合亚洲图片综合区| 不卡在线视频中文字幕| 国产成人精品午夜视频免费| 国内精品在线播放| 美腿丝袜亚洲三区| 美女久久久精品| 麻豆一区二区在线| 六月丁香婷婷色狠狠久久| 日本欧美一区二区在线观看| 丝袜美腿亚洲一区| 免费的成人av| 看电影不卡的网站| 精品一区二区三区欧美| 男女视频一区二区| 精品亚洲国内自在自线福利| 久久草av在线| 国产一区二区三区av电影 | 夜夜夜精品看看| 亚洲综合色噜噜狠狠| 亚洲女人****多毛耸耸8| 国产精品高清亚洲| 一区二区三区日韩精品视频| 亚洲美女免费在线| 香蕉加勒比综合久久| 麻豆久久久久久久| 国产91精品露脸国语对白| a级精品国产片在线观看| 日本精品免费观看高清观看| 欧美三区在线观看| 精品久久国产字幕高潮| 日本一区二区三区电影| 亚洲蜜臀av乱码久久精品蜜桃| 亚洲国产成人高清精品| 蜜桃视频免费观看一区| 成人黄页毛片网站| 欧美亚洲国产一区二区三区| 91精品国产一区二区三区蜜臀| 337p日本欧洲亚洲大胆色噜噜| 中文字幕第一区综合| 亚洲无人区一区| 国产剧情av麻豆香蕉精品| 色av成人天堂桃色av| 日韩欧美亚洲国产精品字幕久久久| 中文字幕av一区二区三区高| 午夜欧美一区二区三区在线播放| 日av在线不卡| 97成人超碰视| 精品剧情在线观看| 亚洲人成7777| 国产一区二区三区电影在线观看 | 国产真实乱偷精品视频免| 91亚洲永久精品| 日韩欧美电影一二三| 亚洲精品你懂的| 激情图片小说一区| 欧美日韩亚洲高清一区二区| 中文字幕av在线一区二区三区| 天堂影院一区二区| 99精品久久免费看蜜臀剧情介绍| 欧美一区二区三区播放老司机|