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

📄 doublebuffering_tv_main.c

📁 ADC图形图像例子
💻 C
📖 第 1 页 / 共 2 页
字号:
           if((x>=232)&&(n= 3)) n=-3; //bounce back           else if((x<=10)&&(n=-3)) n= 3;           if((y>=125)&&(m= 3)) m=-3;           else if((y<=10)&&(m=-3)) m= 3;	   x =x+n;	   y =y+m;           i--;	}}///////////////////////read BMP file and write in texture////////////////////int DrawBMP_true_t(int BMPaddress, unsigned char *BmpImage){  int index=0;  int x,y;    int color;typedef	struct		// Windows (.BMP) file	{		byte	bmp_id[2];	// 'BM' = 0x4D42		dword	bmp_size;		word	reserv_1;	// 0		word	reserv_2;	// 0		dword	offset;	} BMP_HEADER;typedef	struct	{	dword	InfoHeadSize;	// 0x28 = 40byte		dword	width_x;		dword	width_y;		word	planes;		// = 1		word	BitPixel;	// 1 (2 color), 4 (16 color), 8 (256color)		dword	Compression;		dword	Imagesize;		dword	X_Resolution;		dword	Y_Resolution;		dword	Colors;		dword	ImportantColors;	} BMP_INFO_HEADER;typedef	struct	{		byte	Blue;		byte	Green;		byte	Red;		byte	Reserved;	// 0	} RGB_BLOCK;  byte R,G,B,pel;  BMP_HEADER		Header;  BMP_INFO_HEADER		InfoHeader;  int	pal_offset;	// palette start offset  int	 X, Y;  int	cnt;  int   Pal[300];	Header.bmp_id[0] =	BmpImage[index++];	Header.bmp_id[1] =	BmpImage[index++];	Header.bmp_size =	(dword)BmpImage[index++];	Header.bmp_size +=	(dword)BmpImage[index++]<<8;	Header.bmp_size +=	(dword)BmpImage[index++]<<16;	Header.bmp_size +=	(dword)BmpImage[index++]<<24;	Header.reserv_1 =	(word)BmpImage[index++];	Header.reserv_1 +=	(word)BmpImage[index++]<<8;	Header.reserv_2 =	(word)BmpImage[index++];	Header.reserv_2 +=	(word)BmpImage[index++]<<8;	Header.offset =	(dword)BmpImage[index++];	Header.offset +=	(dword)BmpImage[index++]<<8;	Header.offset +=	(dword)BmpImage[index++]<<16;	Header.offset +=	(dword)BmpImage[index++]<<28;//Printf("\nHeader.bmp_size=%ld",Header.bmp_size);  //		dword	if( Header.bmp_id[0] != 'B' || Header.bmp_id[1] != 'M' )	{	//Printf("\r\n This is not BMP file \r\n");		return(1);	}	InfoHeader.InfoHeadSize =	(dword)BmpImage[index++];	InfoHeader.InfoHeadSize +=	(dword)BmpImage[index++]<<8;	InfoHeader.InfoHeadSize +=	(dword)BmpImage[index++]<<16;	InfoHeader.InfoHeadSize +=	(dword)BmpImage[index++]<<24;	InfoHeader.width_x =	(dword)BmpImage[index++];	InfoHeader.width_x +=	(dword)BmpImage[index++]<<8;	InfoHeader.width_x +=	(dword)BmpImage[index++]<<16;	InfoHeader.width_x +=	(dword)BmpImage[index++]<<24;	InfoHeader.width_y =	(dword)BmpImage[index++];	InfoHeader.width_y +=	(dword)BmpImage[index++]<<8;	InfoHeader.width_y +=	(dword)BmpImage[index++]<<16;	InfoHeader.width_y +=	(dword)BmpImage[index++]<<24;	InfoHeader.planes =	(word)BmpImage[index++];	InfoHeader.planes +=	(word)BmpImage[index++]<<8;	InfoHeader.BitPixel =	(word)BmpImage[index++];	InfoHeader.BitPixel +=	(word)BmpImage[index++]<<8;	InfoHeader.Compression =	(dword)BmpImage[index++];	InfoHeader.Compression +=	(dword)BmpImage[index++]<<8;	InfoHeader.Compression +=	(dword)BmpImage[index++]<<16;	InfoHeader.Compression +=	(dword)BmpImage[index++]<<24;	InfoHeader.Imagesize =	(dword)BmpImage[index++];	InfoHeader.Imagesize +=	(dword)BmpImage[index++]<<8;	InfoHeader.Imagesize +=	(dword)BmpImage[index++]<<16;	InfoHeader.Imagesize +=	(dword)BmpImage[index++]<<24;	InfoHeader.X_Resolution =	(dword)BmpImage[index++];	InfoHeader.X_Resolution +=	(dword)BmpImage[index++]<<8;	InfoHeader.X_Resolution +=	(dword)BmpImage[index++]<<16;	InfoHeader.X_Resolution +=	(dword)BmpImage[index++]<<24;	InfoHeader.Y_Resolution =	(dword)BmpImage[index++];	InfoHeader.Y_Resolution +=	(dword)BmpImage[index++]<<8;	InfoHeader.Y_Resolution +=	(dword)BmpImage[index++]<<16;	InfoHeader.Y_Resolution +=	(dword)BmpImage[index++]<<24;	InfoHeader.Colors =	(dword)BmpImage[index++];	InfoHeader.Colors +=	(dword)BmpImage[index++]<<8;	InfoHeader.Colors +=	(dword)BmpImage[index++]<<16;	InfoHeader.Colors +=	(dword)BmpImage[index++]<<24;	InfoHeader.ImportantColors =	(dword)BmpImage[index++];	InfoHeader.ImportantColors +=	(dword)BmpImage[index++]<<8;	InfoHeader.ImportantColors +=	(dword)BmpImage[index++]<<16;	InfoHeader.ImportantColors +=	(dword)BmpImage[index++]<<24;//Printf("\nInfoHeader.width_x=%ld",InfoHeader.width_x);//		dword//Printf("\nInfoHeader.width_y=%ld",InfoHeader.width_y);//		dword//Printf("\nInfoHeader.BitPixel=%d",InfoHeader.BitPixel);	// 1 (2 color), 4 (16 color), 8 (256color)//word	pal_offset = 14+ + InfoHeader.InfoHeadSize;	cnt = (Header.offset - pal_offset) / 4;	Y = InfoHeader.width_y;	X = InfoHeader.width_x ;	for( y = Y-1; y >= 0; y--)	{		for( x = 0; x < X; x++)		{          	  B =	BmpImage[index++];	          G =	BmpImage[index++];	          R =	BmpImage[index++];                  color=((R&0xf8)<<8) | ((G&0xfc)<<3) | (B>>3);		  PutPixel_t(0x50000 + BMPaddress,x,y,color);		}	}        color=Pal[pel];
	return 0;}void Display_BMP(void) //128*128{  DrawBMP_true_t(0x100,bmp256);  PushCommand( WritePacket_Clear );  Write_Packet_com(0x4708,50,10,306,266,0,0,256,0,0,256,0,0x50100,0x00a4); //enlarge by 2  Flip();}void Display_BMP2(void)  //256*256{   DrawBMP_true_t(0x8000,bmp256_1);  PushCommand( WritePacket_Clear );  Write_Packet_com(0x4708,0,0,256,256,0,0,512,0,0,512,0,0x58000,0x00ab);  Flip();}/////////////////////////////////////////////////////// main and cache/////////////////////////////////////////////////////#define __CACHE_INVALIDATE_SET(VALUE) asm( "CACHE_INVALIDATE_SET: "); asm( "push %R0");	 asm( "ldi  %0   , %%R0" : : "i" (VALUE) );	asm( "mvtc  0   , %CR5"); asm( "pop  %R0");		  #define __CACHE_INVALIDATE_CHECK() asm( "CACHE_INVALIDATE_CHECK:");	asm( "mvfc  0  , %CR6"); asm( "and  %R0, 0x00100000, %R0");	asm( "jnz   CACHE_INVALIDATE_CHECK"); #define __CACHE_MODE_SET(VALUE)	asm( "CACHE_MODE_SET: "); asm( "push %R0"); asm( "ldi  %0   , %%R0" : : "i" (VALUE) ); asm( "mvtc  0   , %CR3"); asm( "pop  %R0");#define __CACHE_ACTIVE_SET(VALUE) asm( "CACHE_ACTIVE_SET: "); asm( "push %R0"); asm( "ldi  %0   , %%R0" : : "i" (VALUE) ); asm( "mvtc  0   , %CR7"); asm( "pop  %R0");/*#define __CACHE_INVALIDATE_SET(VALUE)				\                  asm( "CACHE_INVALIDATE_SET: ");		\		  asm( "push %R0");				\		  asm( "ldi  %0   , %%R0" : : "i" (VALUE) );	\		  asm( "mvtc  0   , %CR5");			\		  asm( "pop  %R0");		  #define __CACHE_INVALIDATE_CHECK()				\                  asm( "CACHE_INVALIDATE_CHECK:");		\                  asm( "mvfc  0  , %CR6");			\                  asm( "and  %R0, 0x00100000, %R0");		\                  asm( "jnz   CACHE_INVALIDATE_CHECK"); #define __CACHE_MODE_SET(VALUE)					\                  asm( "CACHE_MODE_SET: ");			\		  asm( "push %R0");				\		  asm( "ldi  %0   , %%R0" : : "i" (VALUE) );	\		  asm( "mvtc  0   , %CR3");			\		  asm( "pop  %R0");#define __CACHE_ACTIVE_SET(VALUE)				\                  asm( "CACHE_ACTIVE_SET: ");			\		  asm( "push %R0");				\		  asm( "ldi  %0   , %%R0" : : "i" (VALUE) );	\		  asm( "mvtc  0   , %CR7");			\		  asm( "pop  %R0");*/		  /**************************************************/// CACHE MASTER COMMAND REGISTER/**************************************************/#     define __CACHE_UNIT_DISABLE          ( 0 << 11 )#     define __CACHE_UNIT_ENABLE           ( 1 << 11 )#     define __CACHE_UNIT_NORMAL           ( 0 << 0 )#     define __CACHE_UNIT_DELAY            ( 1 << 0 )/**************************************************/// CACHE INVALIDATE REGISTER/**************************************************/#     define __CACHE_INVALIDATE_DISABLE   ( 0 << 0 )#     define __CACHE_INVALIDATE_ENABLE    ( 1 << 0 )		  /**************************************************/// CACHE INVALIDATE REGISTER/**************************************************/#     define __CACHE_WRITE_THROUGH        ( 0 << 6 )#     define __CACHE_WRITE_BACK           ( 1 << 6 )int main(){	unsigned long j;	asm("CACHE_CONFIGURATION_SET:");	__CACHE_INVALIDATE_SET(__CACHE_INVALIDATE_ENABLE)	__CACHE_INVALIDATE_CHECK()	__CACHE_MODE_SET(__CACHE_WRITE_BACK)	//__CACHE_MODE_SET(__CACHE_WRITE_THROUGH)		__CACHE_ACTIVE_SET(__CACHE_UNIT_ENABLE  | 	//                   __CACHE_UNIT_NORMAL   )  // process read_hit & miss at one cpuclk 					   __CACHE_UNIT_DELAY   )     // process read_hit & miss at two cpuclk	// initialize for DebugPrintf
	UartConfigCh1(DATABIT8, BPS115200); 	// FMEM/TMEM - memory controller reset	VR0_memory_controller_reset();				// set screen mode	CRT_320x240_noninterlace();			// Rendering engine reset	InitRenderingEngine();			// select Render target => back-buffer	// for double buffering...		 *(unsigned short*)(0x300008c) = 0x0006; // dither mode : disable,render target : back-buffer	    j =500;	x = 0;  	y = 0;	while(j)	{		x = (x+4)%360;		y = (y+4)%240;				PushCommand( WritePacket_Clear );		PushCommand( WritePacket_Box );		// 		PushCommand( WritePacket_AsyncFlip );
// 		PushCommand( WritePacket_Flip );		Flip();        j--;	}    Moving_obj();// 	Display_BMP();// 	Display_BMP2();	return 1;}

⌨️ 快捷键说明

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