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

📄 doublebuffering_tv_main.c

📁 ADC图形图像例子
💻 C
📖 第 1 页 / 共 2 页
字号:
//#include "data1.txt"//#include "face1.txt"#include "uart.h"/////////defines////////////////typedef unsigned int    dword;typedef unsigned short  word;typedef unsigned char   byte;//extern char face1[];byte *bmp256 = (byte *) 0x00050000; //face1;//extern char girl2[];byte *bmp256_1 = (byte *) 0x00050000;//girl2;byte *memb=(byte *) 0x00000000;#define  memw *(word *)&memb#define  meml *(dword *)&membword  *memW=(word  *) 0x00000000;dword *memL=(dword *) 0x00000000;byte *regb=(byte *) 0x01800000;#define  regw *(word*)&regb#define  regl *(int *)&regbbyte *cregb=(byte *) 0x03000000;#define  cregw *(word*)&cregb#define  cregl *(int *)&cregbbyte *tmemb=(byte *) 0x03800000;word *tmemW=(word *) 0x03800000;int  *tmemL=(int  *) 0x03800000;#define  tmemw *(word*)&tmemb#define  tmeml *(int *)&tmembbyte *fmemb=(byte *) 0x04000000;word *fmemW=(word *) 0x04000000;int  *fmemL=(int  *) 0x04000000;#define  fmemw *(word*)&fmemb#define  fmeml *(int *)&fmembbyte *smemb=(byte *) 0x04800000;word *smemW=(word *) 0x04800000;int  *smemL=(int  *) 0x04800000;#define  smemw *(word*)&smemb#define  smeml *(int *)&smemb///////pictures///////////////////void PutPixel_t(int start_position, int x,int y,int color){ //0x40000  tmemw[start_position+256*y+x*2]=color; // 256}void Make_BMP_1(void){  int x,y,X,Y;  int color;  byte R,G,B;	Y = 128;	X = 128;	for( y = Y-1; y >= 0; y--)	{		for( x = 0; x < X; x++)		{        		  if((x <= 64)&&(y <= 64))		  { R = 0x0ff;                    G = 0x0;                    B = 0x0;		  }  		  else if(( x > 64 )&&( y <= 64))		  { R = 0x0;                    G = 0x0ff;                    B = 0x0;		  }                  else if((x <= 64)&&(y > 64))		  { R = 0x0;                    G = 0x0;                    B = 0x0ff;		  }                  else if((x > 64)&&(y > 64))		  { R = 0xbb;                    G = 0xbb;                    B = 0xbb;		  }                                                      color=((R&0xf8)<<8) | ((G&0xfc)<<3) | (B>>3);		  PutPixel_t(0x40000,x,y,color);		}	}}void Make_New_BMP1(void){       int x,y,color,X,Y;        byte R,G,B;	Y = 128;	X = 128;	for( y = Y-1; y >= 0; y--)	{		for( x = 0; x < X; x++)		{        		  if((x <= 64)&&(y <= 64))		  { R = 0x0ff;                    G = 0x0;                    B = 0x0;		  }  		  else if(( x > 64 )&&( y <= 64))		  { R = 0x0;                    G = 0x0ff;                    B = 0x0;		  }                  else if((x <= 64)&&(y > 64))		  { R = 0x0;                    G = 0x0;                    B = 0x0ff;		  }                  else if((x > 64)&&(y > 64))		  { R = 0xbb;                    G = 0xbb;                    B = 0xbb;		  }                                                      color=((R&0xf8)<<8) | ((G&0xfc)<<3) | (B>>3);		  PutPixel_t(0x48000,x,y,color);		}       }}/////////////////////////////////////////////////////// Synchronous flipping/////////////////////////////////////////////////////void WritePacket_Flip( unsigned short* packet_addr ){	packet_addr[0] = 0x0001;}/////////////////////////////////////////////////////// Asynchronous flipping/////////////////////////////////////////////////////void WritePacket_AsyncFlip( unsigned short* packet_addr ){	packet_addr[0] = 0x0080;}/////////////////////////////////////////////////////// push flipping command & wait done../////////////////////////////////////////////////////void PushCommand( void(*WritePacket)(unsigned short *packet_addr) );void Flip(){	// flip counter reset	*(unsigned short*)0x030000a6 = 0;	// increment flip count	*(unsigned short*)0x030000a6 = 1;	// push flipping command	// refer to 7.4 page flipping	//PushFlipCommand()	PushCommand( WritePacket_Flip );	// wait for flipping	while( *(unsigned short*)0x030000a6 != 0 );}/////////////////////////////////////////////////////// clear screen/////////////////////////////////////////////////////void WritePacket_Clear( unsigned short* packet_addr ){	packet_addr[0] = 0x1110; // PH	packet_addr[1] = 0; // PD[1] : left-top x	packet_addr[2] = 0; // PD[2] : left-top y	packet_addr[3] = 360; // PD[3] : right-bottom x	packet_addr[4] = 240; // PD[4] : right-bottom y		packet_addr[21] = (0x00<<8) | 0x00; // PD[21] : G<<8 | B	packet_addr[22] = 0x00;             // PD[22] : R}/////////////////////////////////////////////////////// draw box/////////////////////////////////////////////////////long x,y;void WritePacket_Box( unsigned short* packet_addr ){	packet_addr[0] = 0x1110; // PH	packet_addr[1] = x; // PD[1] : left-top x	packet_addr[2] = y; // PD[2] : left-top y	packet_addr[3] = x+63; // PD[3] : right-bottom x	packet_addr[4] = y+63; // PD[4] : right-bottom y		packet_addr[21] = (0x00<<8) | 0x00; // PD[21] : G<<8 | B	packet_addr[22] = 0xff;             // PD[22] : R}/////////////////////////////////////////////////////// Graphics functions/////////////////////////////////////////////////////void InitRenderingEngine();void PushCommand( void(*WritePacket)(unsigned short *packet_addr) );/////////////////////////////////////////////////////// system initialize functions.../////////////////////////////////////////////////////void VR0_memory_controller_reset();void CRT_320x240_noninterlace();////////////////////////////////////////////////////void Write_Packet_com(int mode, int ScrX1, int ScrY1, int ScrX2, int ScrY2,                       int Tx1, int Ty1, int A, int B, int C, int D,                       int Transparency_Color_RGB, int Offset_t, int Size_t){    unsigned short reg_front = memw[0x3000080];    unsigned short reg_rear;    unsigned short next_front = (reg_front+1)%2048; memw[0x03800000 + reg_front*64 + 0x00]= mode; //0x4708;  memw[0x03800000 + reg_front*64 + 0x02]=ScrX1; //200; //128; //32;  //DstX1 memw[0x03800000 + reg_front*64 + 0x04]=ScrY1; //; //128; //32;  //DstY1 memw[0x03800000 + reg_front*64 + 0x06]=ScrX2; //128*5+; //DstX2 memw[0x03800000 + reg_front*64 + 0x08]=ScrY2; //; //DstY2  memw[0x03800000 + reg_front*64 + 0x0a]= Tx1 & 0x0ffff; //0;  //256; //SrcX memw[0x03800000 + reg_front*64 + 0x0c]=(Tx1 >>16)& 0x1f;  //SrcX memw[0x03800000 + reg_front*64 + 0x0e]= Ty1 & 0x0ffff;//0;  //256; //SrcY memw[0x03800000 + reg_front*64 + 0x10]=(Ty1>>16)&0x1f;//0;  //SrcY  memw[0x03800000 + reg_front*64 + 0x12]=A & 0x0ffff;//512; //A memw[0x03800000 + reg_front*64 + 0x14]=(A>>16)&0x1f;;//0;   //A memw[0x03800000 + reg_front*64 + 0x16]=B & 0x0ffff;   //B memw[0x03800000 + reg_front*64 + 0x18]=(B>>16)&0x1f;//0;   //B memw[0x03800000 + reg_front*64 + 0x1a]=C & 0x0ffff;   //C memw[0x03800000 + reg_front*64 + 0x1c]=(C>>16)&0x1f;//0;   //C memw[0x03800000 + reg_front*64 + 0x1e]=D & 0x0ffff; //D memw[0x03800000 + reg_front*64 + 0x20]=(D>>16)&0x1f;//0;   //D memw[0x03800000 + reg_front*64 + 0x2e]=Transparency_Color_RGB&0x0fcf8;    //0x0fc00; //transparency memw[0x03800000 + reg_front*64 + 0x30]=(Transparency_Color_RGB>>16)&0x0f8;//0x00; memw[0x03800000 + reg_front*64 + 0x34]= Offset_t >>7; //(0x48000>>7);//bit map offset memw[0x03800000 + reg_front*64 + 0x38]= Size_t; //0x00a4;    // command queue	while( 1 )	{	reg_rear = memw[0x03000082];	if( next_front != reg_rear ) break;        }	// front pointer	memw[0x3000080] = next_front;}void Moving_obj(void){	int x = 0;	int y = 0;        int n=3;        int m=3;          int i =500;        Make_BMP_1();        Make_New_BMP1();	while(i)	{   /*Write_Packet_com(int mode, int ScrX1, int ScrY1, int ScrX2, int ScrY2, \                  int Tx1, int Ty1, int A, int B, int C, int D, \                  int Transparency_Color_RGB, int Offset_t, int Size_t);
*///put backgroundWrite_Packet_com(0x4708,0,0,360,240,0,0,256,0,0,1024,0,0x40000,0x00a4);//put rotation picWrite_Packet_com(0x670c,10,10,138,138,0,0,362,-362,362,362,0x00ff00,0x40000,0x00a4);//moving object to new positionWrite_Packet_com(0x4708,x,y,(x+128),(y+128*0.9),0,0,512,0,0,(512*1.1),0,0x48000,0x00a4);            Flip();            

⌨️ 快捷键说明

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