Game Boy Advance - Midi Interface (Hack Part 2)
Game Boy Advance - Midi Interface (Hack Part 2)
Game Boy Advance - Midi Interface (Hack Part 2)
in Linux
Versión en Español
All GBA C sources are written for this toolchain (local copy) and for this crt0/lnkscript
by Jeff Frohwein. Nevertheless it is very easy to adapt the sources for the
http://www.devkitpro.org's toolchain.
• utils
• sound
• graphics
• games
• hardware
• linksavelinoherrera@hotpop.com
Utils
• bin2o.cpp - A binary to ELF object file converter that lets you create C buffers
from raw data files directly in .o format. The original utility by DarkFader
(http://darkfader.net/gp32). I had to patch it. To compile simply do a: g++ -o bin2o
bin2o.cpp on Linux.
o The GBA uses graphic mode 0, so we have a 30x20 characters screen (8x8 pixels
each character). We write to screen ussing the usual commands printf, puts, etc, because
the screen is the file handle 1 (as in Unix). Be careful: there is no extended ASCII support
(only the ASCII codes from 32 to 127 are visibles, plus the '\n' character that is used for
new line).
o There is no file handle associated to GBA keypad and the file handle 0 (standard
input) cannot be used, perhaps in the future... ;-)
o The file handle 2 (standard error output) is mapped at SRAM (the internal static
non-volatile RAM on all flash cartridges). This SRAM is 64KByte length. It is possible
to call lseek over file handle 2 to positioning into SRAM.
o There is romfs support. We can open, close, lseek, read and fstat files located at a
romfs image merged with the main program ROM: cat my_program.gba image.romfs >
my_final_program.gba.
• int AgbMain() {
• console_init();
• romfs_init();
• ...
• printf("opening 'index.html'...\n");
• fd = open("index.html", O_RDONLY);
• printf("handle = %d\n", fd);
• printf("=== BEGIN\n");
• while (1) {
• int readed = read(fd, &data, 1);
• if (readed == 0)
• break;
• putchar(data);
• }
• close(fd);
• printf("=== EOF\n");
• ...
}
int AgbMain() {
console_init();
romfs_init();
...
printf("writing SRAM...");
write(2, "Hello, SRAM :-)", 16);
printf("ok\n");
lseek(2, 0, SEEK_SET);
read(2, sram_example_data, 20);
printf("SRAM content = '%s'\n", sram_example_data);
...
}
Sound
Graphics
Games
Hardware
• I have connected some leds to the GBA serial port (EXT) and I have tested them
ussing a program that writes to the REG_R register in general purpose mode.
• Here is the source code for this mini project :-) and this is the circuit diagram
connected to the EXT port.
•
• Here you can obtain a detailed description of the GBA link port.
midioutadvance
The following are some photos of the Gameboy Advance with this MIDI out
interface. It is now 100% MIDI compatible!
I have used the 2-player link cable with the master end connected to GBA (in my
cable it is labeled 1P).
• http://linux.gbadev.org - Very nice step by step tutorial: How to build your own
Gameboy Advance toolchain in Linux ussing standard GNU tools (binutils, gcc
and newlib).
• http://gbajunkie.co.uk - GBA programming tutorials (here you can download the
adaptation made by me of the gbajunkie.co.uk tutorial examples to compile with
the linux.gbadev.org toolchain).
• http://belogic.com/gba - GBA programming tutorial for the GBA sound
subsystem.
• http://www.reinerziegler.de/GBA/gba.htm - Very useful hardware technical info.
• http://nocash.emubase.de/gbatek.htm - All the registers, the memory map, BIOS
functions, etc listed.