Explore how RIF handles low-level architectures through real code snippets. These examples demonstrate the power of the retargetable engine when applied to classic hardware.
Game Boy Advance (ARM7TDMI)
This snippet from the GBA example shows the entry point of a ROM, setting up the display and clearing the screen using ARM assembly instructions defined in the RIF gba plugin.
.rom
entry:
arm_mov_imm R3, 0x04000000
arm_mov_imm R0, 0x04000000
arm_mov_imm R1, 0x0400
arm_add_imm R1, R1, 0x03
arm_strh R1, R0, 0
clear_title_screen:
arm_mov_imm R2, 0x06000000
arm_mov_imm R9, 0x06000000
arm_add_imm R9, R9, 0x12C00
arm_mov_imm R5, 0x01E0
clear_title_loop:
arm_strh R5, R2, 0
arm_add_imm R2, R2, 2
arm_cmp R2, R9
arm_bcond ne, clear_title_loop
Defining a Minimal Pack
A .pack file is the heart of any RIF project. It defines how instructions are emitted and how the memory is structured.
# minimal.pack
commit "Minimal ISA"
comment "#"
separator ","
[rules]
byte $val:
emit u8 $val
word $val:
emit u16 $val
[memory]
ROM:
origin 0x08000000
size 0x10000
fill 0x00
Multimedia Integration
Using the image and fonts plugins, you can inject binary data directly from the source code without external converters.
# Injecting a bitmap font
.rodata
my_font:
@fill_font "fonts/standard.f"
# Converting and injecting a sprite
my_sprite:
@fill_image "assets/mario.png" palette=gba_4bpp