Setting up programming environment, part 2

August 15, 2009

In order to get quickly to template folder you can make an alias.

$ cd ~/
$ vi .bashrc

- go to end of file
- press “a”
- add following lines:

alias gotemp=’cd /devkitpro/examples/gba/template’
alias gosrc=’cd /devkitpro/examples/gba/template/source’
alias rungba=’/
usr/bin/VisualBoyAdvance /devkitpro/examples/gba/template/template_mb.gba’
alias vb=’/usr/bin/VisualBoyAdvance’

- press “Esc” and “ZZ” to save and quick file

If during editing file something goes wrong, press “Esc” and “:quit” to quit without saving.
“gotemp”, “gosrc” and “rungba” are names of yours aliases and can be replace by anything else.

Now $ exit and run termina again. $ gosrc to take yourself to source folder where file template.c is located.

$ gedit template.c

This is the file where you’ll put your program code.

Now, you’ll make a script that automatic does make clean, make, rungba in this order.

  1. $ cd ~/Documents
  2. $ mkdir scripts
  3. $ gedit gbscr

Write these and save the file:

cd /devkitpro/examples/gba/template
echo "Deleting template_mb.gba and template_mb.elf"
make clean
echo "Compiling code ..."
make
echo "Running template_mb.gba in emulator"
/usr/bin/VisualBoyAdvance /devkitpro/examples/gba/template/template_mb.gba

Now, add scripts folder to $PATH environmental variable

  1. $ cd ~/
  2. gedit .bashrc

Add
export PATH=$PATH:$HOME/scripts
to the end of the file.

  1. $ exit
  2. Run terminal again
  3. $ gbscr

Last command should compile your template project and open it in emulator.

Running GBA emulator

August 14, 2009

In your terminal type sudo synaptic

Synaptic Package Manager will open. In Quick search type “visual boy advance”. In the middle field should be two packages: visualboyadvance and visualboyadvance-gtk (if there isn’t choose Edit → Reload Package Information or just press Ctrl + R and try again). Check the two squares to the left choosing Mark for Installation. Press Apply and wait until all packages are downloaded and installed. Type (in terminal)

/usr/bin/VisualBoyAdvance to start application. Syntax is /usr/bin/VisualBoyAdvance [parameters] file so if I have .gba file in Desktop folder I could type /usr/bin/VisualBoyAdvance /home/special/Desktop/template_mb.gba to emulate it.

Setting up programming environment

August 14, 2009

If you successfully installed Linux you can start setting up programming environment. Download these files:

1.devkitARM_r26-i686-linux.tar.bz2
2.gba-examples-20090222.tar.bz2
3.libgba-20090222.tar.bz2

If you are using Firefox, the default download folder is in /home/<user>/Desktop e.g. /home/special/Desktop. Now unpack them to folder /devkitpro. And becouse that folder don’t exist, create it with:

$ cd /
$ sudo mkdir devkitpro

Every time you use sudo command you have to also type your user password, the same used for login into the system. Command sudo gives you administrative privileges. Now go into /devkitpro and create folders libgba and examples. In terminal go to libgba folder and execute

$ tar -jxvf <filename>

eg. tar – jxvf ~/Desktop/libgba-20090222.tar.bz2

This will unpack all files into current folder. ~/ means home directory. Next do the same with gba-examples-20090222.tar.bz2 and devkitARM_r26-i686-linux.tar.bz2. Last one can be unpack direct to devkitpro folder.

Setting up system variables

$ vi ~/.bashrc
go to end of file
press key “a”
type this:

export DEVKITPRO=/devkitpro
export DEVKITARM=$DEVKITPRO/devkitARM

press Esc
type “ZZ” to save  and press Enter

Compiling template

Go to /devkitpro/examples/template and type $ make
You will see these lines:

built … template_mb.gba
ROM fixed!

Now you have template_mb.gba file that can be run in emulator or GBA console.

Introduction

August 13, 2009

Everyone interested in Gameboy Advance programming under Linux are welcome to learn and comment. I have Ubuntu 9.04 and no Linux or programming experience. I want to learn both and share whatever I know. My GBA knowledge is based on TONC‘s manual.


Follow

Get every new post delivered to your Inbox.