Game Boy Color (CGB) engine for P1Xel Editor data
  • Python 56.3%
  • Zig 43.7%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Krzysztof Krystian Jankowski c809fe408c M12: fix BG tile addressing end to end; showcase game; engine hardening
Root cause of the blank-tile bug: the contract, the P1XEL exporter and the
engine font path used map byte = (CHR + 128) & $FF. Under the engine's
signed $8800 LCDC mode the hardware does the opposite, so every exported
cell resolved to the empty CHR range 256..383. The correct formula is
byte = CHR & $FF (P1XEL-CONTRACT.md "BG tile IDs"). Fixed in the exporter
(p1xel-editor), window.rgbinc and the docs; assets re-exported.

Engine
- abi.rgbinc: single definitions-only engine<->game header (DIR_*, PAD_*,
  PADF_*, WINDOW_*, BG_BLANK_*); catalogc includes it instead of mirroring.
- Popup window moved to the hardware Window layer on the BG map the level
  does not use: camera-independent, no save/restore strip, dirty-flag VRAM
  writes. VideoBGMapBase replaces 8 copies of the $9800/$9C00 select.
- EngineInit zeroes all of WRAM0 (game state included) - random boot RAM
  left GAME_POPUP_MODE set and swallowed all input on BGB/hardware.
- LevelLoad: bank-correct level addressing (section bank-aligned), field
  clamping, camera reset to start_x/y, failure -> EngineFatal red screen.
- CameraClamp shared by LevelLoad/CameraFollowEntity; fixes <20x18 levels.
- Entity slot masking; EntityTryDir trampoline removed; input.rgbinc guard.
- catalogc: ident sanitiser matches P1XEL, duplicate names fail the build,
  meta-tiles emit CATALOG_TILE_<name> + _FIRST/_LAST.
- Macros: PADF_* instead of magic masks, PopupPreamble/DpadDir dedupe,
  OnTileGoto, Despawn, edge-triggered menu nav, dpad repeat throttle.

Showcase game (src/game/game.rgbasm, project.p1x via tools/sample)
Title (text, flipped frame, palettes, static OAM, menu) -> 32x32 scrolling
maze (solid tiles, spawn markers, hunting enemy, camera, pause, exit
meta-tile) -> Win; About; Dead/RETRY.

Tests: selftest.py now boots with scribbled RAM and asserts VRAM map bytes,
CHR contents, window map text, SCX/SCY and OAM, not just WRAM state.

Repo: editor binaries removed from the engine repo, junk file and stale
tmp/ copies deleted, .gitignore covers *.sav/.pi/__pycache__.
2026-10-09 16:37:14 +02:00
rom M12: fix BG tile addressing end to end; showcase game; engine hardening 2026-10-09 16:37:14 +02:00
src M12: fix BG tile addressing end to end; showcase game; engine hardening 2026-10-09 16:37:14 +02:00
tools M12: fix BG tile addressing end to end; showcase game; engine hardening 2026-10-09 16:37:14 +02:00
.gitignore M12: fix BG tile addressing end to end; showcase game; engine hardening 2026-10-09 16:37:14 +02:00
AGENT.md M8: rename macro layer to prefix-less macros.rgbinc; fresh-start docs 2026-10-07 22:34:46 +02:00
build.zig M9-B: declare 8KB cart RAM in rgbfix (-r 2) - fixes BGB 'rom size and card type do not match' 2026-10-08 09:42:16 +02:00
ENGINE.md M12: fix BG tile addressing end to end; showcase game; engine hardening 2026-10-09 16:37:14 +02:00
ingame.png M12: fix BG tile addressing end to end; showcase game; engine hardening 2026-10-09 16:37:14 +02:00
MACROS.md M12: fix BG tile addressing end to end; showcase game; engine hardening 2026-10-09 16:37:14 +02:00
P1XEL-CONTRACT.md M12: fix BG tile addressing end to end; showcase game; engine hardening 2026-10-09 16:37:14 +02:00
project.p1x M12: fix BG tile addressing end to end; showcase game; engine hardening 2026-10-09 16:37:14 +02:00
README.md M12: fix BG tile addressing end to end; showcase game; engine hardening 2026-10-09 16:37:14 +02:00
ref.png M11: visible menus/popups - window text rendering fixed end to end 2026-10-08 10:56:52 +02:00
RULES.md M8: rename macro layer to prefix-less macros.rgbinc; fresh-start docs 2026-10-07 22:34:46 +02:00

Nomad Core - Game Boy Color Engine

Produced by Krzysztof Krystian Jankowski

2026 Cyfrowy Nomada

Nomad Core is a deliberately small RGBDS engine for top-down, tile-centric Game Boy Color games. Game logic is written in rgbasm via the game macro layer (see MACROS.md), isolated from hardware-facing engine code, and P1XEL exports four memory-shaped runtime data files.

See:

  • ENGINE.md - architecture and roadmap
  • MACROS.md - game-layer macro library
  • RULES.md - engine/game boundary
  • P1XEL-CONTRACT.md - runtime asset format
  • AGENT.md - rules for AI agents writing game code

Build

Requirements: Zig 0.16, RGBDS (in tools/rgbds/ via the P1XEL toolchain wizard, or on PATH). Optional: Python 3 + pyboy + Pillow for the self-test, BGB or mGBA for zig build emulate.

zig build                       # rom/the-game-boy-engine.gbc
zig build emulate               # build + run in BGB/mGBA
python tools/test/selftest.py   # headless regression test (state + pixels)

The showcase game

src/game/game.rgbasm is a complete small game exercising every engine feature: a title screen with text, flipped frame tiles, CGB palettes and static sprites; a two-item menu in the popup window; a 32x32 scrolling maze with solid walls, spawn markers, a hunting enemy, camera follow, a pause popup and an exit meta-tile; About, Win and Dead screens.

Its assets come from project.p1x, which is generated by tools/sample/make_sample.py and exported by P1XEL (or, headless, by p1xel-editor/tests/export_harness.exe project.p1x src/game/assets). Open project.p1x in P1XEL to edit the levels, then Export All into src/game/assets/ and zig build.

Workflow

P1XEL (project.p1x)  --Export All-->  src/game/assets/{meta.dat, tileset.chr,
                                      levels.tlm, levels.oam, catalog.toml}
catalogc                            -> src/game/catalog.rgbinc (names -> bytes)
rgbasm/rgblink/rgbfix               -> rom/the-game-boy-engine.gbc

Edit only src/game/game.rgbasm for game logic; the engine never needs to know about your game.