{"id":13337692,"url":"https://github.com/peterhellberg/tic","last_synced_at":"2026-05-29T01:32:11.517Z","repository":{"id":207060894,"uuid":"718315921","full_name":"peterhellberg/tic","owner":"peterhellberg","description":"A small Zig :zap: module primarily meant for my own experiments with TIC-80 :video_game:","archived":false,"fork":false,"pushed_at":"2025-08-25T12:33:11.000Z","size":44,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-08-25T14:39:01.611Z","etag":null,"topics":["tic-80","zig-package","ziglang"],"latest_commit_sha":null,"homepage":"","language":"Zig","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/peterhellberg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-11-13T20:40:55.000Z","updated_at":"2025-08-25T12:33:15.000Z","dependencies_parsed_at":"2024-11-14T13:30:15.461Z","dependency_job_id":"56c9b702-3613-4469-b5eb-46cf49ba1893","html_url":"https://github.com/peterhellberg/tic","commit_stats":null,"previous_names":["peterhellberg/tic"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/peterhellberg/tic","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peterhellberg%2Ftic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peterhellberg%2Ftic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peterhellberg%2Ftic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peterhellberg%2Ftic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/peterhellberg","download_url":"https://codeload.github.com/peterhellberg/tic/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peterhellberg%2Ftic/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33633468,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-28T02:00:06.440Z","response_time":99,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["tic-80","zig-package","ziglang"],"created_at":"2024-07-29T19:14:55.965Z","updated_at":"2026-05-29T01:32:11.508Z","avatar_url":"https://github.com/peterhellberg.png","language":"Zig","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tic :zap:\n\nA small [Zig](https://ziglang.org/) ⚡ module, primarily meant for my own experiments with [TIC-80](https://tic80.com/) 🎮\n\nBased on the [tic80.zig template](https://github.com/nesbox/TIC-80/blob/main/templates/zig/src/tic80.zig), with a few small fixes here and there. :bug:\n\n\u003e [!IMPORTANT]\n\u003e You might want to install the [tic-init](https://github.com/peterhellberg/tic-init) tool and use that instead of manually creating the files for your cart.\n\n## Usage\n\nYou can have `zig build` retrieve the `tic` module if you specify it as a dependency.\n\n### Create a `build.zig.zon` that looks something like this:\n```zig\n.{\n    .name = .tic80_zig_game,\n    .version = \"0.0.0\",\n    .fingerprint = 0x0,\n    .paths = .{\"\"},\n    .dependencies = .{\n        .tic = .{\n            .url = \"https://github.com/peterhellberg/tic/archive/refs/tags/v0.0.7.tar.gz\",\n        },\n    },\n}\n```\n\n\u003e [!NOTE]\n\u003e If you leave out the hash then `zig build` will tell you that it is missing the hash, and what it is.\n\u003e Another way to get the hash is to use `zig fetch`, this is probably how you _should_ do it :)\n\n### Then you can add the module in your `build.zig` like this:\n```zig\n// Add the tic module to the executable\nexe.addModule(\"tic\", b.dependency(\"tic\", .{}).module(\"tic\"));\n```\n\n### In your `src/main.zig` you should now be able to:\n```zig\nconst tic = @import(\"tic\");\nconst std = @import(\"std\");\n\nexport fn BDR(row: i32) void {\n    const v = tic.time() / 99 + @as(f32, @floatFromInt(row)) / 2;\n    tic.poke(0x3ff9, @intFromFloat(2 + std.math.sin(v) * 1.2));\n}\n\nexport fn TIC() void {\n    tic.rect(0, 13, 92, 57, 4);\n    tic.rect(107, 13, 50, 11, 12);\n    tic.rect(107, 60, 49, 11, 12);\n    tic.rect(164, 14, 12, 56, 12);\n    tic.elli(214, 42, 32, 30, 12);\n    tic.elli(214, 42, 18, 18, 0);\n    tic.tri(223, 40, 240, 19, 240, 40, 0);\n    tic.tri(209, 40, 236, 40, 236, 56, 12);\n    tic.rect(236, 40, 4, 25, 0);\n    tic.rect(226, 48, 4, 9, 12);\n    tic.tri(141, 22, 107, 61, 124, 60, 12);\n    tic.tri(124, 60, 139, 22, 157, 24, 12);\n    tic.tri(18, 27, 28, 13, 22, 28, 0);\n    tic.tri(28, 13, 22, 28, 33, 13, 0);\n    tic.tri(19, 57, 8, 70, 13, 70, 0);\n    tic.tri(19, 57, 13, 70, 24, 57, 0);\n    tic.rect(15, 27, 66, 31, 0);\n    tic.tri(3, 83, 49, 26, 43, 56, 4);\n    tic.tri(43, 56, 51, 16, 87, 0, 4);\n    tic.tri(73, 27, 84, 13, 77, 13, 0);\n    tic.tri(77, 13, 64, 31, 73, 27, 0);\n    tic.tri(76, 57, 64, 72, 70, 57, 0);\n    tic.tri(70, 57, 65, 70, 60, 70, 0);\n    if (tic.btn(4)) tic.exit();\n}\n```\n\nHopefully with a result like this:\n\n![TIC-80 Zig Example](https://i.imgur.com/TAQVUVE.gif)\n\n## Examples\n\n### Example `build.zig`\n\n\u003e [!IMPORTANT]\n\u003e Make sure that you `exe.export_symbol_names` the [TIC-80 Callbacks](https://github.com/nesbox/TIC-80/wiki/API#callbacks) you are using.\n\n```zig\nconst std = @import(\"std\");\n\npub fn build(b: *std.Build) !void {\n    const exe = b.addExecutable(.{\n        .name = \"cart\",\n        .root_module = b.createModule(.{\n            .root_source_file = b.path(\"src/main.zig\"),\n            .target = b.resolveTargetQuery(.{\n                .cpu_arch = .wasm32,\n                .os_tag = .wasi,\n            }),\n            .optimize = .ReleaseSmall,\n        }),\n    });\n\n    // Add the tic module to the executable\n    exe.root_module.addImport(\"tic\", b.dependency(\"tic\", .{}).module(\"tic\"));\n\n    // No entry point in the WASM\n    exe.entry = .disabled;\n\n    // All the memory below 96kb is reserved for TIC\n    // and memory mapped I/O so our own usage must\n    // start above the 96kb mark\n    exe.global_base = 96 * 1024;\n    exe.stack_size = 8192;\n\n    // Four WASM memory pages\n    const memory: u64 = 65536 * 4;\n    exe.initial_memory = memory;\n    exe.max_memory = memory;\n    exe.import_memory = true;\n\n    // Export symbols for use by TIC\n    exe.root_module.export_symbol_names = \u0026[_][]const u8{\"TIC\"};\n\n    // Run command that requires you to have a `tic80-pro` binary\n    const run_cmd = b.addSystemCommand(\u0026[_][]const u8{\n        \"tic80-pro\",\n        \"--skip\",\n        \"--fullscreen\",\n        \"--fs\",\n        \".\",\n        \"--cmd\",\n        \"load cart.wasmp \u0026\" ++\n            \" import binary zig-out/bin/cart.wasm \u0026\" ++\n            \" save \u0026\" ++\n            \" run\",\n    });\n    run_cmd.step.dependOn(b.getInstallStep());\n\n    const run_step = b.step(\"run\", \"Run the cart in TIC-80 Pro\");\n    run_step.dependOn(\u0026run_cmd.step);\n\n    const spy_cmd = b.addSystemCommand(\u0026[_][]const u8{\n        \"spy\",\n        \"--exc\",\n        \"zig-cache\",\n        \"--inc\",\n        \"**/*.zig\",\n        \"-q\",\n        \"clear-zig\",\n        \"build\",\n    });\n    const spy_step = b.step(\"spy\", \"Run spy watching for file changes\");\n    spy_step.dependOn(\u0026spy_cmd.step);\n\n    b.installArtifact(exe);\n}\n```\n\n### Example `cart.wasmp`\n\n\u003e [!IMPORTANT]\n\u003e You can only use the `wasmp` format if you run the [TIC-80 Pro Version](https://github.com/nesbox/TIC-80#pro-version)\n\n```lua\n-- desc:   TIC-80 Zig Example\n-- script: wasm\n\"\nCode is compiled from src/main.zig\ninto zig-out/bin/cart.wasm\n\nLoad it like this:\n\nimport binary zig-out/bin/cart.wasm\nrun\n\n\"\n-- \u003cWAVES\u003e\n-- 000:00000000ffffffff00000000ffffffff\n-- 001:0123456789abcdeffedcba9876543210\n-- 002:0123456789abcdef0123456789abcdef\n-- \u003c/WAVES\u003e\n\n-- \u003cPALETTE\u003e\n-- 000:1a1c2c5d275db13e53ef7d57ffcd75a7f07038b76425717929366f3b5dc941a6f673eff7f4f4f494b0c2566c86333c57\n-- \u003c/PALETTE\u003e\n```\n\n### Example file structure\n\n\u003cimg width=\"60%\" src=\"https://github.com/peterhellberg/tic/assets/565124/eadbdf7c-18ed-426b-8438-813be3a99aee\" /\u003e\n\n## Links\n\n- https://github.com/nesbox/TIC-80/blob/main/templates/zig/src/tic80.zig\n- https://github.com/nesbox/TIC-80\n- https://tic80.com/\n- https://ziglang.org/\n\n## License (MIT)\n\nSince **TIC-80** itself is [licensed under MIT](https://github.com/nesbox/TIC-80/blob/main/LICENSE)\nit almost goes without saying that this project should be so as well :clipboard:\n\n### TIC-80 License\n```\nCopyright (c) 2017 Vadim Grigoruk\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the \"Software\"),\nto deal in the Software without restriction, including without limitation\nthe rights to use, copy, modify, merge, publish, distribute, sublicense,\nand/or sell copies of the Software, and to permit persons to whom the\nSoftware is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included\nin all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\nOF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\nDAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE\nOR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeterhellberg%2Ftic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpeterhellberg%2Ftic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeterhellberg%2Ftic/lists"}