First Demo
Without writing any code, we can test to see if everything is working.
First, let's instruct gvasm to create a skeleton program.
In a new directory, run:
gvasm init FirstDemo.gvasmThis will create a new file, FirstDemo.gvasm. If you're curious, you can open it and see what it looks like:
//
// Game v0
//
// include standard library for useful constants
.stdlib
// GBA header
.begin header
.arm
b main
.logo
.title "GAME"
.str "CUNE77"
.i16 150, 0, 0, 0, 0
.i8 0 // version
.crc
.i16 0
b header // ensure ROM isn't interpreted as multi-boot
.str "SRAM_Vnnn" // tell emulators to reserve 32K of SRAM
.align 4
.end
.begin main
.arm
// set cartridge wait state for faster access
ldr r0, =REG_WAITCNT
ldr r1, =0x4317
strh r1, [r0]
// Your game here!
// For example, this will set the display to blueish green:
// set REG_DISPCNT to 0
ldr r0, =REG_DISPCNT
ldr r1, =0
strh r1, [r0]
// set color 0 to blueish green
ldr r0, =0x05000000
ldr r1, =rgb(0, 31, 15)
strh r1, [r0]
// infinite loop
loop:
b loop
.pool
.endThis won't make sense at first, but don't worry, we will go over it in the next section.
For now, let's make the ROM file from this source code:
gvasm make FirstDemo.gvasmYou should see a successful message:
Success in 0.012s! Output: FirstDemo.gbaNext, load the FirstDemo.gba file into mGBA by double clicking it or dragging it into the mGBA window.
You should see a green screen:

You did it!
Last updated