Repository navigation
templates: add Go starter project template using TinyGo - #3002
Merged
Merged
Conversation
Compile Go to WebAssembly with TinyGo (target.json) and run it with
TIC-80's wasm runtime. Includes the cart/tic80 API wrapper library,
the demo game and wiki-inspired examples (pix, BDR glitch, per-scanline
palette gradient, ttri texture quad, sprite rotation), plus Makefile
targets and run.sh for each.
Highlights:
- Memory: reserve TIC-80's first 96 KiB of linear memory via a
stack-first layout (96 KiB + 8 KiB stack) inside the 4 wasm pages
TIC-80 provides; free RAM starts at 0x18000.
- tic80.Init() must be called first in BOOT: the TIC-80 wasm runtime
never calls the module's _initialize entry point, so TinyGo's runtime
(heap limits, GC state) only gets set up when Init runs - without it
the first heap allocation kills the game ('[trap] unreachable
executed').
- The wrapper masks wasm3's byte-typed returns (pix, peek*, vbank)
which only fill the low byte of the i32 return slot.
- Map remap callbacks work through the existing wasm function-table
mechanism without host changes; Print/Font/Trace use a shared static
NUL-terminated buffer so the leaking-GC setup stays allocation-free.
- The tilesheet is stored tile-major (tile (x/8,y/8) = 32 consecutive
bytes) - the examples' setSheetPix documents the correct addressing.
- ttri2 rotates the 2x2-tile sprite from the cartridge (the TIC guy
with cart.wasmp) with per-vertex z for perspective-correct texture
mapping; chroma key 14.
Based on the Go template from the WASM-4 project.
Owner
|
Read it: |
nesbox
approved these changes
Sep 18, 2026
nesbox
left a comment
Owner
There was a problem hiding this comment.
Read it: templates/ and its README already ask for this work, and the diff adds the Go entry, the templates/go/ tree and the .gitignore line its Makefile needs — nothing outside templates/ is touched.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is an AI assisted port of the WASM4 for Tinygo template.
I've tested some advanced features and hit some new bugs, that's why there are some more examples.
Compile Go to WebAssembly with TinyGo (target.json) and run it with TIC-80's wasm runtime. Includes the cart/tic80 API wrapper library, the demo game and wiki-inspired examples (pix, BDR glitch, per-scanline palette gradient, ttri texture quad, sprite rotation), plus Makefile targets and run.sh for each.