?? gba_hardware.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 + -