Pure-MoonBit 32-bit ARM7TDMI Game Boy Advance emulator, ARM/Thumb disassembler, scanline PPU (Modes 0-5 + OBJ), HLE BIOS, headless CLI, and 60 FPS browser debugger
| Test ROM | Coverage | Status | Verified Output |
|---|---|---|---|
| arm/arm.gba | Full 32-bit ARMv4T instruction suite | PASS | r12=0, pc=0x08001EC4 |
| thumb/thumb.gba | Full 16-bit Thumb instruction suite | PASS | r12=0, pc=0x08000AAC |
| memory/memory.gba | Unaligned loads, VRAM/PRAM/OAM 8-bit quirks, mirrors, SRAM | PASS | r12=0, pc=0x080004C8 |
| ppu/hello.gba | Mode 4 bitmap text rendering | PASS | dispcnt=0x0404, non_black=209 |
| ppu/shades.gba | Mode 0 tiled 32-shade blue gradient | PASS | dispcnt=0x0100, avg_rgb=[0,0,115] |
| ppu/stripes.gba | Mode 0 tiled RGB stripe pattern | PASS | dispcnt=0x0100, non_black=38400 |
let gba = @gba.Gba::new(rom_bytes)
gba.set_key(@gba.KEY_RIGHT, true)
gba.run_frames(60)
let ppm = gba.framebuffer_ppm()
let lines = gba.disassemble_around_pc(8)# Run unit tests across all 4 targets
for target in wasm wasm-gc js native; do
moon test --target "$target" --deny-warn .
done
# Build native CLI and run jsmolka/gba-tests oracle
moon build --target native --release --deny-warn cmd/main
python3 demo/verify_gba.py --skip-build
# Build browser console bundle and run V8 smoke test
python3 demo/build_web.pypub(open) trait MemoryBus {
fn read8(Self, UInt) -> UInt
fn read16(Self, UInt) -> UInt
fn read32(Self, UInt) -> UInt
fn write8(Self, UInt, UInt) -> Unit
fn write16(Self, UInt, UInt) -> Unit
fn write32(Self, UInt, UInt) -> Unit
fn handle_swi(Self, Cpu, UInt) -> Bool
}pub struct Cpu {
r : FixedArray[UInt]
cpsr : UInt
spsr : UInt
bank_usr : FixedArray[UInt]
bank_fiq : FixedArray[UInt]
bank_irq : FixedArray[UInt]
bank_svc : FixedArray[UInt]
bank_abt : FixedArray[UInt]
bank_und : FixedArray[UInt]
spsr_fiq : UInt
spsr_irq : UInt
spsr_svc : UInt
spsr_abt : UInt
spsr_und : UInt
halted : Bool
branched : Bool
cycles : UInt64
}pub struct DmaChannel {
sad : UInt
dad : UInt
cnt_l : UInt
cnt_h : UInt
int_src : UInt
int_dst : UInt
int_cnt : UInt
enabled : Bool
}pub struct GbaBus {
bios : FixedArray[Byte]
ewram : FixedArray[Byte]
iwram : FixedArray[Byte]
pram : FixedArray[Byte]
vram : FixedArray[Byte]
oam : FixedArray[Byte]
sram : FixedArray[Byte]
rom : Bytes
bios_latch : UInt
irq_ime : UInt
irq_ie : UInt
irq_if : UInt
keyinput : UInt
keycnt : UInt
waitcnt : UInt
postflg : UInt
dma : FixedArray[DmaChannel]
timers : FixedArray[TimerChannel]
ppu : Ppu
}pub struct Ppu {
dispcnt : UInt
dispstat : UInt
vcount : UInt
bgcnt : FixedArray[UInt]
bghofs : FixedArray[UInt]
bgvofs : FixedArray[UInt]
bg2pa : UInt
bg2pb : UInt
bg2pc : UInt
bg2pd : UInt
bg2x : UInt
bg2y : UInt
bg2x_int : Int
bg2y_int : Int
bg3pa : UInt
bg3pb : UInt
bg3pc : UInt
bg3pd : UInt
bg3x : UInt
bg3y : UInt
bg3x_int : Int
bg3y_int : Int
line_cycles : Int
in_hblank : Bool
frame_count : UInt64
layer_mask : UInt
framebuf : FixedArray[Byte]
line_color : FixedArray[UInt]
line_prio : FixedArray[Int]
}pub struct SimpleBus {
mem : FixedArray[Byte]
base : UInt
}pub struct TimerChannel {
reload : UInt
counter : UInt
ctrl : UInt
sub_cycles : Int
}fn alu_add(a : UInt, b : UInt, carry_in : Bool) -> (UInt, Bool, Bool)fn alu_sub(a : UInt, b : UInt, carry_in : Bool) -> (UInt, Bool, Bool)fn asr32(val : UInt, amt : Int) -> UIntfn barrel_shift_imm(val : UInt, shift_type : UInt, amt : Int, carry_in : Bool) -> (UInt, Bool)fn barrel_shift_reg(val : UInt, shift_type : UInt, amt : Int, carry_in : Bool) -> (UInt, Bool)fn bgr555_to_rgb(c : UInt) -> (Byte, Byte, Byte)fn disassemble_arm(op : UInt, pc : UInt) -> Stringfn disassemble_thumb(op : UInt, pc : UInt) -> Stringfn init_hle_bios(bios : FixedArray[Byte]) -> Unitfn ror32(val : UInt, amt : Int) -> UIntfn sign_ext_28(v : UInt) -> IntInstall
Download zipPure-MoonBit 32-bit ARM7TDMI Game Boy Advance emulator, ARM/Thumb disassembler, scanline PPU (Modes 0-5 + OBJ), HLE BIOS, headless CLI, and 60 FPS browser debugger