No description
Find a file
2026-02-19 14:57:42 +03:00
.vscode feat: Add globals.d.luau for _G definition 2025-09-25 22:31:51 +03:00
src docs: Add comments for GBState 2026-02-19 14:57:42 +03:00
test test: Use string indexes for main test 2026-02-17 21:45:45 +03:00
.envrc chore: add vibe coded flake.nix 2026-02-17 13:04:56 +03:00
.gitignore chore: add vibe coded flake.nix 2026-02-17 13:04:56 +03:00
.gitmodules test: Remove gameboy doctor dependency 2025-07-12 20:44:01 +03:00
.luaurc First draft - CPU emulation only, with static buffer memory 2025-04-04 00:45:51 +03:00
aftman.toml First draft - CPU emulation only, with static buffer memory 2025-04-04 00:45:51 +03:00
flake.lock chore: add vibe coded flake.nix 2026-02-17 13:04:56 +03:00
flake.nix chore: add vibe coded flake.nix 2026-02-17 13:04:56 +03:00
globals.d.luau feat: Add globals.d.luau for _G definition 2025-09-25 22:31:51 +03:00
README.md test: Remove gameboy doctor dependency 2025-07-12 20:44:01 +03:00
registers.d.luau feat: MBC RAM support 2026-02-17 13:52:05 +03:00
selene.toml First draft - CPU emulation only, with static buffer memory 2025-04-04 00:45:51 +03:00
selene_defs.yml chore(selene_defs): Removed duplicate REG_A definition 2025-04-04 01:46:58 +03:00
stylua.toml First draft - CPU emulation only, with static buffer memory 2025-04-04 00:45:51 +03:00

Luau Gameboy Emulator

A Gameboy emulator implementation in Luau.

Overview

The purpose of this project is not to write an accurate emulator, but rather research ways to optimize Luau code to be efficient and fast. This includes processing the code using various tools like darklua, and some parts of the code will use different implementations depending on the darklua settings (using inject_global_value rule):

  • USE_BIT32 - if set, will use bit32 implementations. If not, will use native arithmetic operators.
  • NO_BRANCHED_EXPRESSIONS - if set, minimize the amount of if A then B else C expressions, opting to use arithmetic or bit32 instead (depending on USE_BIT32 flag)
  • DEBUG - if set, will include additional checks to catch bugs

The reason for the USE_BIT32 and NO_BRANCHED_EXPRESSIONS flags is to test which implementations work best for different Luau configurations. From my own observations (but not based on any benchmarks yet), using bit32 with no branched expressions (no conditional checks) works best with codegen (the --!native flag), since it results in linear code with no jump instructions, but in regular Luau VM the native operators with conditional checks work better, since they result in smaller bytecode and avoid GETIMPORT and additional function calls.

Testing

The emulator is tested using Blargg's test ROMs (for now, only from the cpu_instrs folder).

Running Tests

Run all tests at once

./test/run_all_configurations.sh

Run a specific test ROM

./test/run.sh path/to/rom.gb logfile.log

Example - run CPU instruction test #3:

./test/run.sh test/gb-test-roms/cpu_instrs/individual/03-op-sp,hl.gb log.txt

Development

This project uses Lune for running scripts and tests.

Acknowledgements