ゲームボーイアドバンスのプログラム開発をするのにいくつか開発環境があるけど、どれがいいかな?
- devkitPro
- gdbk
- zgb
.
.
.
ここらへんを読んだりして、
https://gbdev.io/guides/tools.html#asm-help
https://www.reddit.com/r/gamedev/comments/zw1fms/gameboy_programming_in_20222023_what_are_the_best/
今回は、gdbk を試してみました。
環境
- Ubuntu 22.04 LTS
ダウンロード
https://github.com/gbdk-2020/gbdk-2020/releases

gbdk-linux-arm64.tar.gz をダウンロード。
インストール
解凍。
$ tar xzvf gbdk-linux64.tar.gz
$ cd gbdk
$ ls
ChangeLog README asmlnk_manual.txt bin examples gbdk_manual.pdf include lib libexec licenses sdccman.pdf
サンプルプログラムを試す
$ cd examples
$ ls
Makefile compile.bat cross-platform gb megaduck msxdos nes sms
$ ls
Makefile compile.bat cross-platform gb megaduck msxdos nes sms
$ cd gb
$ ls
Makefile compile.bat galaxy hblank_copy linkerfile ram_function sgb_pong template_minimal
apa_image crash gb-dtmf hicolor mbc3_rtc rand sgb_sfx template_subfolders
colorbar dscan gbprinter isr_vector mbc7_accelerometer rpn sound wav_sample
comm filltest gbtype lcd_isr_wobble paint sgb_border space
$ cat Makefile
# Register all subdirectories in the project's root directory.
SUBDIRS := $(wildcard */.)
# Top-level phony targets.
all clean compile.bat: $(SUBDIRS) FORCE
# Similar to:
# .PHONY: all clean
# all clean: $(SUBDIRS)
# GNU's .PHONY target is more efficient in that it explicitly declares non-files.
# Recurse `make` into each subdirectory
# Pass along targets specified at command-line (if any).
$(SUBDIRS): FORCE
$(MAKE) -C $@ $(MAKECMDGOALS)
# Force targets.
FORCE:
なるほど。Makeしてみます。
$ make
全部ビルドができたみたいです。
$ ls -alh galaxy/
合計 100K
drwxr-xr-x 2 nanbuwks nanbuwks 4.0K 10月 21 23:01 .
drwxr-xr-x 31 nanbuwks nanbuwks 4.0K 5月 20 00:21 ..
-rw-r--r-- 1 nanbuwks nanbuwks 654 5月 20 00:21 Makefile
-rw-r--r-- 1 nanbuwks nanbuwks 100 5月 20 00:21 compile.bat
-rw-r--r-- 1 nanbuwks nanbuwks 23K 5月 20 00:21 galaxy.c
-rw-rw-r-- 1 nanbuwks nanbuwks 32K 10月 21 23:01 galaxy.gb
-rw-rw-r-- 1 nanbuwks nanbuwks 20K 10月 21 23:01 galaxy.map
-rw-rw-r-- 1 nanbuwks nanbuwks 5.0K 10月 21 23:01 galaxy.noi
「mGBA を Ubuntu で使ってみる」
https://qiita.com/nanbuwks/items/5cf770b6e53b026ef5c2
でインストールした mGBA で動かしてみます。
$ cd galaxy
$ mgba galaxy.gb
動きました。
hello.c
gdbk フォルダの中に app/test ディレクトリを作ってそこでプログラムをすることにしました。
$ cd app/test
hello.c を以下の内容で作ります。
# include <stdio.h>
void main() {
printf("Hello!");
}
以下のようにコンパイルができました。
$ ../../bin/lcc -Wa-l -Wl-m -Wl-j hello.c -o hello.gb
hello.c:3: warning 283: function declarator with no prototype
実行できるかな?
$ ls
Makefile hello.c hello.gb hello.map hello.noi
$ mgba hello.gb

