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

📄 gba_hardware.h

📁 可以编译产生在gba模拟器上执行的二进制映像的ads模板。
💻 H
字号:
/**************************************************************************
  
                    	 GBA API LIBRARY
  
             		COPYRIGHT (c)   2005 BY JJJ.
                       		--  ALL RIGHTS RESERVED  --
  
   	File Name:      GBA_Hardware.h
   	Author:         Jiang Jian Jun
   	Created:        2005/12/3
   	Modified:		NO
   	Revision: 		1.0
	Readme:			GBA的内部硬件资源,寄存器等一些宏定义  	
***************************************************************************/
#ifndef _DEFINE_GBA_HARDWARE_H_LIB_
#define _DEFINE_GBA_HARDWARE_H_LIB_

//Type Defination------------------------------------------------------------------

#ifndef PI
#define PI 3.1415926
#endif

#ifndef TRUE
#define TRUE	1
#endif

#ifndef FALSE
#define FALSE 	0
#endif

#ifndef NULL
#define NULL 	((void *)0)
#endif

#ifndef true
#define true	1
#endif

#ifndef false
#define false	0
#endif

//一些运算的宏定义
#define GBA_MIN(x,y)			(((x) < (y)) ? (x) : (y))
#define GBA_MAX(x,y)     		(((x) > (y)) ? (x) : (y))
#define GBA_MID(x,y,z)   		(GBA_MAX((x), GBA_MIN((y), (z)))
#define GBA_ABS(x)       		(((x) >= 0) ? (x) : (-(x)))

//颜色相关的一些宏定义
#define GBA_COLOR16_BLACK       0x0000
#define GBA_COLOR16_MAROON      0x0010
#define GBA_COLOR16_GREEN       0x0200
#define GBA_COLOR16_OLIVE       0x0210
#define GBA_COLOR16_NAVY        0x4000
#define GBA_COLOR16_PURPLE      0x4010
#define GBA_COLOR16_TEAL        0x4200
#define GBA_COLOR16_GRAY        0x4210
#define GBA_COLOR16_SILVER      0x6318
#define GBA_COLOR16_RED         0x001F
#define GBA_COLOR16_LIME        0x03E0
#define GBA_COLOR16_YELLOW      0x03FF
#define GBA_COLOR16_BLUE        0x7C00
#define GBA_COLOR16_FUCHSIA     0x7C1F
#define GBA_COLOR16_WHITE       0x7FFF
#define GBA_COLOR16_MONEYGREEN  0x6378
#define GBA_COLOR16_SKYBLUE     0x7B34
#define GBA_COLOR16_CREAM       0x7BFF
#define GBA_COLOR16_MEDGRAY     0x5294

#define GBA_RGB16(r,g,b) 		((unsigned short int)((r>>3) + ((g>>3)<<5) + ((b>>3)<<10)))	//GBA只支持16位色,定义16位色RGB的宏
#define GBA_GetRGB16_R(rgb)    	((unsigned char)((rgb & 0x001f) << 3))
#define GBA_GetRGB16_G(rgb)    	((unsigned char)(((rgb >> 5) & 0x001f) << 3))
#define GBA_GetRGB16_B(rgb)    	((unsigned char)(((rgb >> 10) & 0x001f) << 3))

#define GBA_RGB32(r,g,b)		((unsigned int)(r + (g<<8) + (b<<16)))						//定义真彩色的RGB宏
#define GBA_GetRGB32_R(rgb)    	((unsigned char)(rgb & 0x000000ff))
#define GBA_GetRGB32_G(rgb)    	((unsigned char)((rgb>>8) & 0x000000ff))
#define GBA_GetRGB32_B(rgb)    	((unsigned char)((rgb>>16) & 0x000000ff))

//位操作的一些宏
#define GBA_SetBit(v,b)			(v |= (1<<(b)))		//将某一位置1
#define GBA_ClrBit(v,b)			(v &= (~(1<<(b)))	//将某一位清0
#define GBA_TestBit(v,b)		(v & (1<<(b)))		//测试某位的值

//设置视频模式的宏
#define GBA_SetVideoMode(Mode) 	GBA_REG_DISPCNT = (Mode) 						//设置GBA显示模式的宏

//---------------------------------------------------------------------------------

//Memory---------------------------------------------------------------------------------
#define GBA_REG_BASE			(*(volatile unsigned short int *)0x04000000)	//控制寄存器的基地址,有1kb大小

//Video--------------------------------------------------------------
#define GBA_REG_DISPCNT 		(*(volatile unsigned short int *)0x04000000)	//显示控制寄存器地址
#define GBA_VRAM 				(*(volatile unsigned short int *)0x06000000)	//图像缓冲区地址
#define GBA_PALETTE 			(*(volatile unsigned short int *)0x05000000)    //调色板地址
#define GBA_M5_VRAM         	(*(volatile unsigned short int *)0x0600A000)	//M5缓冲区地址

#define GBA_MODE_0  			0x0000		//240*160 图块模式,支持4个文本模式背景
#define GBA_MODE_1  			0x0001		//240*160 图块模式,支持2个文本模式背景BG0、BG1和可旋转缩放的BG2
#define GBA_MODE_2  			0x0002		//240*160 图块模式,支持2个可旋转缩放的背景BG2、BG2
#define GBA_MODE_3  			0x0003  	//240*160 位图模式,支持16位色,单缓冲区
#define GBA_MODE_4  			0x0004  	//240*160 位图模式,支持 8位色,双缓冲区,比较好的模式,和以前DOS下的MODEX有点类似。可以很方便的画点,画圆,很多GBA真3D游戏,像<疯狂TAXI>,就是使用了这个模式。
#define GBA_MODE_5  			0x0005  	//160*128 位图模式,支持16位色,双缓冲区

#define GBA_BG0_ENABLE      	0x0100
#define GBA_BG1_ENABLE      	0x0200 
#define GBA_BG2_ENABLE      	0x0400
#define GBA_BG3_ENABLE      	0x0800

//Key---------------------------------------------------------------
#define GBA_KEYRAMADDRESS		(*(volatile unsigned short int *)0x04000130)	//键盘信息缓冲区地址

#define GBA_KEY_A 				0x0001
#define GBA_KEY_B 				0x0002
#define GBA_KEY_SELECT 			0x0004
#define GBA_KEY_START 			0x0008
#define GBA_KEY_RIGHT 			0x0010
#define GBA_KEY_LEFT 			0x0020
#define GBA_KEY_UP 				0x0040
#define GBA_KEY_DOWN 			0x0080
#define GBA_KEY_R 				0x0100
#define GBA_KEY_L 				0x0200
#define GBA_KEY_ALL				0x03FF
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
#endif  

⌨️ 快捷键说明

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