关于GBA游戏的入门教程(1)2023.10月

一下链接是CSDN的一位博主在3年前所编写,

GBA开发入门:做一个名叫Hello World的游戏_gba游戏制作教程-CSDN博客

我们注意到他的操作系统使用的是win 7,win 7又分32bit和64bit两个大类的,这两年的时间我在此教程上断断续续实现了其过程,可以很明确的是该教程中的DevKit这款GBA开发工具不再适用于64bit机,也就是win10 和win11都是没法使用的,不过Github上貌似有DevKit PRO的GBA开发工具,没有过多了解,应该是为64bit机打造的,这里就不再多说,可以自行寻找PRO的开发包。

现在我们回到这篇教程,我们需要做的是在VMware或者Virual Box等虚拟机软件上安装Win 7 32bit(x64)版本的操作系统进行MakeFile的开发,不过但凡懂一些Linux知识都应该知道屁MakeFile本就是Linux领域的编辑工具,所以最好使用Linux进行GBA开发。

devkitadv GBA开发工具 任天堂GBA官方开发包安装及开发环境的设置 Romandoo 解压安装包至某目录后,安照以下步骤操作: 一: 安装CYGWIN工具 运行CYGWIN_SETUP目录下setup.exe进行cygwin的安装 选INSTALL FROM LOCAL DIRECTORY 在SELECT INSTALL ROOT diretory 选择安装目录 next> 再NEXT 在弹出的窗口中,在Perv Curr Exp 中选Curr 点开列表栏中各项, 选 base 的 cygwin ash bash login sh-utils 选 devel 的 autoconf automake binutils gcc gdb make 选 shell下的 ash bash sh-utils 置NEW栏显示版本号,表示将其安装,而其它的工具选为skip表示跳过不安装 最后选next开始安装! (注意,我为了节省空间,我删除了许多不重要的东西,其实cygwin下有高达几百m的各式各样的工具,今后你可根据自已需要到网上下载安装去) 二、安装任天堂官方开发包 在 AGB LIBRARY3.0中点 agbsetup1安装 注意,一定要安装到c:\agb目录下,因为这是官方的默认目录,有一些例子与这个目录关连了 所以最好选这个目录 ,不然可能编不过去。否则自已设置会麻烦一点的。 修改c:\autoexec.bat 文件增加如下代码行 SET AGBDIR=C:\AGB 三、安装CYGWIN补丁 (由于刚安装完的cygwin版本并不支持arm cpu,所以需要将某些程序、库覆盖成arm相关的程序库) 将arm-thumb-elf连目录一起copy到安装好的cygwin目录的\lib\gcc-lib下 将bin-patch目录下的所有文件copy到cygwin目录的bin下面覆盖 将include patch目录下文件copy到cygwin目录的include下面 四:编绎例子程序 OK!前三步已经将我们的开发环境构好了!! 现在我们可以正式进行开发了,至于开发技术吗,在agb目录的doc下应有尽有,大家可以好好研究一下子。 下面我就介绍如何编绎代码了。 编绎也是很简单的一件事情了。 官方资料里有许多的例子,和两个游戏demo源代码。 我们就拿里面的一个具有代表性的例子编绎吧 functional_sample 在编绎之前,你必须重起你的机器,因为刚才我们修改了 autoexec.bat 而设置此时需要生效才行。(当然也有其它办法不必重起就生效,说来话长了) 好,重起之后,我们运行刚才装好的cygwin程序 进入了一个控制台窗口 这个控制台shell,命令行支持的是类式linux的指令,你可能不太了解,不过你不用担心呵 我们不需要记太多的命令指令,很简单的几句这可以了 就当是dos命令,只不过命令名称变了而已 下面是几个对应 ls 相当于dos下的dir指令 cd 相当于dos下的cd 指令 你也就需要这两个指令就搞定了,呵 行,那么我们正式开始: cd c: cd agb cd src cd samples cd functional_sample //以上几步作的就是进入c:\agb\src\samples\functional_sample目录下,和dos一样吧,呵 然后注意了,忘了提醒有关functional_sample这个例子的一个问题, 就是这个例子源代码share.c 中定义了 vu16 Cont; vu16 Trg; 但是在share.h中又申明为 extern u16 Cont; extern u16 Trg; 该编绎器检查认为是错误,所以你要改一下 将share.h文件里改成 extern vu16 Cont; extern vu16 Trg; 否则编绎报错。 好,改好share.h之后,我们输入 make 回车! 好,你可以看到现在开始正式编绎了,太爽了,官方的例子在被编绎,呵 过了几十秒编绎完成之后,就会生成了bin与elf文件 你用visualBoyAdvance打开bin文件看一看是 什么例子,哇,原来是个非常强的GBA各个功能展示,有alpha混合,有图层显示 有马塞可显示,有放大缩小,有精灵移动,旋转,字体显示,声音,有地图显示,有窗口模式。 但是需要注意的一个问题:::::: 如果你想使用gcc里面的库函数 需要在makefile里面修改一下 CFLAGS 中加入 -I"C:\cygwin\include" LDFLAGS 中加入 -lm 否则你将无法使用sin,cos,sqrt等有用的库函数 编完这个,你可以再去试试看
gba开发文档。包括一份gba的cpu说明(中文翻译版)和ads环境下的gba开发模板(包括一个gba模拟器tool)。 // // HAM (c) Emanuel Schleussinger 2001/2002 // all rights reserved. // // Includes Doxygen compatible documentation // http://www.doxygen.org // /* ---------------------------------------------------------- REG_ --> Register location absolute adress of a register. includes typecasting for direct c writes. example: R_DISPCNT = value; MEN_ --> MEMORY address V_ --> Value A register related value used by macros and functions. Register Masks are also treated as values, this is currently in- consistent with C_ (constants), which they should be really. Anyone want to clean up? :-) C_ --> Constant Helpers that will never need change. holds values for bitfields that are hard to remember Also note, C_'s might get declared only once for a set of registers. If so, two rules apply: - the C_ declaration always is in the first register of the set. - the number of the register (example BG0CNT, BG1CNT) is set to C_BGXCNT. F_ --> Function a function returns a value suchas true M_ --> Macro A macro does stuff on its own, suchas switching a display mode or enabling sprites. This is what you will be using most of the time. Example: M_INTMST_ENABLE will enable interrupts TOOL_ --> Tool function Usually a collection of macros and/or functions. Propably not the fastest on earth, but very convienient. These are found at the end of the file. For example TOOL_INIT_ALL(1) sets up the display for BGMode 1 and inits sound and interrupts. Notes: ------ Some of the functions/macros are not the fastest on earth, i know that. Most of them are built for convienience rather than speed, and will suffice in the most cases. Also, please do not mail me about the fact that using REG= A | B | C | D is faster than what is being done here. I know that ;-) First of all, that only applies sometimes (if you need to set whole bitfields), and second of all, you can still do it on your own using the R_ defines. I do the same in my code, but it proves handy to have the base cases covered. Disclaimer: ----------- I'd like to be greeted in your demo if you use this header :) Be fair. Also, this source file and any other part of HAM must NOT: - be changed and redistributed as new versions, I would like to keep the main distribution point on my end. Help with any suggestions please, though. You WILL be mentioned for any help you did on HAM, and also, you can join in the team. --------------------------------------------------------- */
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值