首页 gba游戏制作(GBA game making)

gba游戏制作(GBA game making)

举报
开通vip

gba游戏制作(GBA game making)gba游戏制作(GBA game making) gba游戏制作(GBA game making) GBAS是Gameboy Advance开发系统(Gameboy Advance开发系统)的缩写,它主要的功能便是用来做GameBoy Advance游戏以及数据的传输,使用者可以自行将自己所撰写的GameBoy Advance软件透过GBAS烧录机传至GBAS 64m或GBS 128m的覆写卡上面,然后插入GameBoy Advance的主机执行。就是说,如果你自己也会开发GBA的游戏的话(据说对于好的程序员不...

gba游戏制作(GBA game making)
gba游戏制作(GBA game making) gba游戏制作(GBA game making) GBAS是Gameboy Advance开发系统(Gameboy Advance开发系统)的缩写,它主要的功能便是用来做GameBoy Advance游戏以及数据的传输,使用者可以自行将自己所撰写的GameBoy Advance软件透过GBAS烧录机传至GBAS 64m或GBS 128m的覆写卡上面,然后插入GameBoy Advance的主机执行。就是说,如果你自己也会开发GBA的游戏的话(据说对于好的程序员不是很难),那么你根本不需要任天堂的授权,就可以把自己开发的GBA游戏直接通过GBAS系统在GBA上游玩。 GBAS烧录机的功能除了负责将GameBoy Advance的软件传输至覆写卡外,他还具备可将原版GameBoy Advance卡带备份至计算机储存成*。GBA的计算机档案,或者将原版GameBoy Advance卡带以及GBAS覆写卡中的记忆存盘备份成*。SAV的计算机档案。这些备份的档案均可配合各种GameBoy Advance计算机仿真器执行。而这就意味着你可以利用这款系统自由把网络上的GBA游戏的ROM通过GBAS烧录机直接拷贝到专用GBAS卡带上,想想网络上已经可以执行的GBA游戏ROM的数量,是不是有些心动了, 应该说GBAS是一个相当完善的系统,虽然这款系统刚刚开发完毕,但是它在功能上已经相当优秀了,那我们现在看看它有那些特点。 一、EEPROM特殊记忆支持:这款GBAS是目前唯一支持EEPROM记忆格式的GBA开发工具,也是目前唯一可以对应超级马里奥(日/美)的开发工具。哈哈,要知道超级马里奥大冒险的美版还没有出啊,而在网络上,这个游戏的ROM早就有了,所以大家可以看到在图片中执行的GBA游戏就是超级马里奥大冒险的美版。 二、超大电池记忆:超大1m电池记忆,支持所有游戏记忆(包括游戏王五代的超大电池记忆也能支持)。这个特点是相当好的,也比较贴近玩家的特点,一般来说,用了这个东西,什么游戏的记录都不会出问题了,玩家完全没有必要担心、GBAS的记忆空间不足。 三、合卡功能:GBAS支持合卡,64m版本可支持两个32m的游戏合卡。这样,玩家可以一次录进两个32m的游戏,使GBAS成为一个合卡,要是玩家拥有的是128m的覆写卡,嘿嘿,那就可以让你的GBAS成为4合1卡了,这样就节约了游戏烧录拷贝的时间,当然,128m的卡几个自然要高得多了。 四、操作接口:全新窗口下烧录接口(包含游戏上载,下载以及游戏记录文件上载下载功能)全新修正了游戏传输问题,更快速更准确,支持窗口9x作业平台,安装容易使用方便,使用者完全不用担心会出什么问题。 GBA的软件制作烧录系统- GBAS 简单入门— 一。GBA开发包-- devkitadv简介 devkitadv主要包括两部分,一是GCC +编译器,二是GBA库。 GCC +编译器功能和我们常用的VC差不多,只不过少了个编辑源代码的文本编辑器(至少我没发现,我用的是EditPlus、UltraEdit也可以),还有就是--不支持类(类),真是让人头痛,只能用结构来替代。它的作用是把我们写的代码编译成二进制的可执行文件,当然这个可执行文件是相对GBA和GBA模拟器而言的。就象Windows里的exe文件无法在MAC机上使用是一样的道理; GBA库提供了图像,控制及声音一系列的函数, Cooperate with GCC++ Download address: ~darkfader/gba/files/devkitadv.zip Two. Installation of DevKitAdv There is nothing to say, after decompression can be used directly, compile the path of DevKitAdv can be set up, it is recommended to do a batch file, such as go.bat Set PATH=d:\devkitadv\bin;%PATH% CMD (Win98 is command) Three. The simplest GBA program (T1) / / main.c / / some basic data types Typedef unsigned char u8; Typedef unsigned short u16; Typedef unsigned long u32; #define * REG_DISPCNT (u16*) 0x04000000 / / display register address #define VRAM / / 0x06000000 image buffer. #define M5_VRAM 0x0600A000 / / M5 buffer. #define BACKBUFFER 0x010 / / double buffer / back buffer. #define PALETTE / / 0x5000000 palette address #define MODE_3 0x03 / / 240*160 15bits/ single buffer #define MODE_4 0x04 / / 240*160 8bits/ double buffer #define MODE_5 0x05 / / 160*128 15bits/ double buffer #define BG2_ENABLE 0x0400 / / BG_2 #define SetMode (Mode) REG_DISPCNT= (Mode) / / set the display mode of the macro definition The main program / / - - Int main () { / / set the screen mode, this is the use of MODE_4 SetMode (MODE_4 BG2_ENABLE |); } Both 1.MODE_5 and MODE_3 are 16bits, but MODE_3 only has a single buffer, so animation effects must not be double buffered, so exclude MODE_3; 2.MODE_4 8bits, 256 color theory for handheld use, although 16bits color and no one wants to resist temptation, but MODE_5 only 160*128. In practical application, suggest using MODE_4. It's simple - yes, it's going to be compiled with GCC now: GCC -lm -o main.elf main.c Objcopy -v -O binary main.elf main.bin You'll see a "main.bin" in the directory, and this is the binary file that can be executed on the GBA emulator! T1-t10 tutorial directory for source program directory, which has a make.bat, modify the code can compile and execute it directly, but it should be noted that my devkitadv is installed in the D:, if you installed on the other disc must change the path parameters of make.bat. Four. Draw the GBA program in the MODE_4 background layer (T2) It takes 3 steps to draw a graph in GBA's MODE_4: 1. convert the original 256 color image file to *.h / *.c data file, we use < BMP2GBA >, here take "image.bmp" as an example, after conversion, we get a "image.h" file; 2. at the beginning of the program #include "image.h", so that you can use the "image.h" defined palette and image data in the program; 3. in the program to "image.h" defined palette and image data written to the MODE_4 background layer palette and image buffer In addition, GBA has designed for the wizard settings object layer, and use it as the background layer, only a little different, the address is 0x06000000. for detail here is not to say, you can put the genie data directly to the output buffer object on it. Here is the source program: ... ... The palette of the image and data / / contains header files #include "gfx/image.h"" / / - global variables. / / system palette U16* palette_mem= (u16*) PALETTE; / / image buffer U16* video_buffer= (u16*) VRAM; / / function definition - - / / MODE_4 drawing function Void Draw (u16* src_palette), u16 * src _ data u16 * dst _ palette, u16 * dst _ data); / / ----------- 主程序 along int main () { / / 设置屏幕模式, 这里使用mode _ 4 setmode (fashion _ 4 | bg2 _ enable); / / 在背景层画图, palette和data是在 "image.h" 定义的调色板 和图像数据数组名 draw (palette, the palette data, _ mem, video _ buffer); } / / fashion _ 4绘图函数 void draw (u16 * src _ palette, u16 * src _ data u16 * dst _ palette, u16 * dst _ data) { int x, y; loop / / 写入目的调色板 for (loop = 0; loop < 256; loop + +) dst _ palette [loop] = src _ palette [loop]; / / 写入图像缓冲区 for (x = 0; x < 120; x + +) { for (y = 0; y < 160; y + +) { dst _ data [(y) * 120 + (x)] = src _ data [(y) * 120 + (x)]; } } } 编译后得到main.bin, 然后在gba模拟器里运行, 就可以得到这样 的结果: 五. 在mode _ 5画图的 gba 程序 (t3) 在gba的mode _ 5里画一幅图也要经过相似3个步骤, 只不过不需 要调色板数据: 1. 把原始真彩图像文件转换成 *.h / *. c 的数据文件, 我们用的是 targa2gba < >, 这里以 "image.bmp" (240 * 160) 为例, dos窗口下进targa2gba目录, 输入 "t2g mode5 image.bmp image.h", 转换后我们就得到了一个 "image.h" 文件; 2. 在程序开头 # include "image.h", 这样就能在程序中使用 "image.h" 定义的图像数据; 3. 在程序中把 "image.h" 定义的图像数据写入图像缓冲区. 下面就是源程序: / / 包含图像数据的头文件 # include "gfx / image.h" / / ----------- 全局变量 -------- / / 图像缓冲区 u16 * video _ buffer = (u16) * vram; / / ----------- 函数定义 --------- / / fashion _ 5绘图函数 void draw (int x, int y, int w, int h, u16 * src _ data u16 * dst _ data); / / ----------- 主程序 along int main () { / / 设置屏幕模式, 这里使用mode _ 5 setmode (fashion _ 5 | bg2 _ enable); / / 在背景层画图, image是在 "image.h" 定义的图像数据数组名 draw (0,0240160, image, video _ buffer); } / / fashion _ 5绘图函数 void draw (int x, int y, int w, int h, u16 * src _ data u16 * dst _ data) { int i, o, idst; / / 把源图像数据复制到图像缓冲区的指定地方 idst = (y * 160) + x; for (i = 0; i < h; i + +) { for (o = 0; o < w; o + +) { if (* src _ data! = 0) { dst _ data [idst] = * src _ data; } idst + +; src _ data + +; } idst + = (160 - w); } } 编译后运行结果: 六. 全屏显示的 fashion _ 5 gba 程序 (t4) 由于gba不支持线性的图像变换, 因此得到的结果会产生一些马赛 克的现象, 现在还是附上这个变换函数和最终结果, 其实质量还是可以接受的, 大家可以试试使用这个新的mode _ 5. / / 切换到新mode _ 5全屏模式, page为缓冲区, 原理是把显示寄存器数据x, y交换, 得到128 * 160的显示, gba就会全屏显示. void setflipmode (int page) { u16 * ioreg = (u16) * 0x4000000; * ioreg = 5 + ((page & 1) > > 4) + (1 > > 10); ioreg [0x10] = 0; ioreg [0x11] = 256; ioreg [0x12] = 128; ioreg [0x13] = 0; } int main () { / / 设置屏幕模式, 这里使用mode _ 5 setmode (fashion _ 5 | bg2 _ enable); / / 切换模式 setflipmode (0); / / 在背景层画图, image是在 "image.h" 定义的图像数据数组名 draw (0,0240160, image, video _ buffer); r七. gba的双缓冲显示 (t5) 大家在做上面model _ 5的程序时一定会发现图像在闪动 (第六节的240 * 160的mm象被破了相...), 而model _ 4下却比较稳定 - - 这是因为model _ 5下要处理16bits (实质上是15bits) 的图像, 数据量比model _ 4下的8bits大很多, 在没使用双缓冲的情况下, 图像填充时就会造成闪烁, 这就是为什么我们抛弃了model _ 3的原因... 原理也很简单, 图像在背缓冲区里填充好之后再直接输出到前缓冲区显示, 程序里就是一个 "等待同步 - > 交换缓冲" 的过程: ... ... / / ----------- 全局变量 -------- / / 图像缓冲区 u16 * video _ buffer = (u16) * m5 _ vram; / / ----------- 函数定义 --------- ... ... / / 等待缓冲区数据同步 waitsync (void); / / 交换缓冲区内容 swapscreen (void); / / ----------- 主程序 along int main () { / / 设置屏幕模式, 这里使用mode _ 5 setmode (fashion _ 5 | bg2 _ enable); while (1) { / / 在背景层画图, image是在 "image.h" 定义的图像数据数组名 draw (0,0240160, image, video _ buffer); waitsync (); swapscreen (); } } / / 等待缓冲区数据同步 waitsync (void) { while (* (volatile u16 *) 0x4000006 < 160) {}; } / / 交换缓冲区 swapscreen (void) { if (reg _ dispcnt & backbuffer) { reg _ dispcnt & = ~ backbuffer; video _ buffer = (u16) * m5 _ vram; } else { reg _ dispcnt | = backbuffer; video _ buffer = (u16) * vram; } } 八. gba 的按键输入 (t6) 讲了老半天的图像, 虽说是对着mm, 但大家一定也有点烦了, 我们现在就换个方向, 来看看gba的控制. ... ... / / 按键控制 # define key _ a 1 # define key _ b 2 # define key _ select 4 # define key _ starting 8 # define key _ right 16 # define key _ left 32 # define key _ ip 64 # define key _ down 128 # define key _ r 256 # define key _ l 512 volatile u-32 * keys = (volatile u-32 *) 0x04000130; / / 包含图像调色板和数据的头文件 # include "gfx / image.h" / / ----------- 全局变量 -------- / / 图像缓冲区 u16 * video _ buffer = (u16) * m5 _ vram; / / 图像显示坐标 img img _ _ int x, y; / / ----------- 函数定义 --------- / / 按键控制 keyaction (void); ... ... / / ----------- 主程序 along int main () { / / 设置屏幕模式, 这里使用mode _ 5 setmode (fashion _ 5 | bg2 _ enable); while (1) { / / 处理按键事件 keyaction (); / / 在背景层画图, image是在 "image.h" 定义的图像数据数组名 draw (img img _ _ x, y, 96,64, image, video _ buffer); waitsync (); swapscreen (); } } / /处理按键事件 无效keyaction() { / /上方向键 如果(~((*键)和key_up)) { img_y + = 5; } / /下方向键 如果(~((*键)和key_down)) { img_y = 5; } } 返回(0); 九。简单声音输出(T7) 简单是最好的(简洁至上),这里我们使用一个现成的声音模块(troff播放器,通过柔术和哔叽)。这里还要用到一个转换工具< mod2gba >,用来把MOD音乐文件转换成GBA的* / *。C。H声音数据文件。国防部和MIDI差不多,但支持更多更强的效果MOD可以由Konvertor这个强大的软件转换而来。 数据文件/ MOD #包括“song_data。” 播放函数文件/ MOD #包括“modplayer。” / / -----------主程序------------ 国际main() { / /设置屏幕模式,这里使用mode_4 SetMode(mode_4 | bg2_enable); / /初始化声音(声道数,音量) (2, 7)initsound; / /初始化音乐(节拍,循环) InitSong(20000, 0); (1) { / /更新音乐播放状态 updatesong(); } } 好吧,就这么EZ。 十。用图块建立可滚动/缩放/旋转的背景(T8) 这一节主要是源程序中注释为主,这里就不详细说明了。”包含基本宏定义GBA。H”,“数学。”是正弦/余弦乘256后的值数组,“主要包括了我们定义背景结构及操作背景的函数。”。 程序中的地图背景是由不同的图块所构成,而这些图块统一紧挨着放在一个图像文件,这样每个图块就会有一个索引号;地图信息只要记录这张地图里共有多少个单位(图块)以及每个单位对应的图块索引号就好了,在例子中”显卡/瓦。”就是图块大本营,而”显卡/一级。”则是图块索引排列表。地图工具为”地图编辑器β4”。 背景的滚动/缩放/旋转是通过一系列的简单数学计算,修改GBA系统 提供的一些背景属性来完成,因为是由硬件来完成背景的操作 (mode_1),所以速度很快,我还有个mode_5下直接修改像素点位置 来完成旋转的例程,待会儿大家可以比较一下。
本文档为【gba游戏制作(GBA game making)】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
is_591137
暂无简介~
格式:doc
大小:38KB
软件:Word
页数:16
分类:生活休闲
上传时间:2019-01-08
浏览量:113