{"id":19207632,"url":"https://github.com/danilafe/chalk","last_synced_at":"2025-05-12T18:20:52.762Z","repository":{"id":80321992,"uuid":"149528900","full_name":"DanilaFe/chalk","owner":"DanilaFe","description":"A compiler from a toy language into CHIP-8, written in Crystal.","archived":false,"fork":false,"pushed_at":"2018-09-20T00:51:35.000Z","size":68,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-20T15:44:26.898Z","etag":null,"topics":["chip-8","compiler","crystal","language"],"latest_commit_sha":null,"homepage":null,"language":"Crystal","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DanilaFe.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":"2018-09-20T00:34:22.000Z","updated_at":"2024-04-13T18:07:56.000Z","dependencies_parsed_at":"2023-06-05T10:30:32.429Z","dependency_job_id":null,"html_url":"https://github.com/DanilaFe/chalk","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DanilaFe%2Fchalk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DanilaFe%2Fchalk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DanilaFe%2Fchalk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DanilaFe%2Fchalk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DanilaFe","download_url":"https://codeload.github.com/DanilaFe/chalk/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253795162,"owners_count":21965488,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["chip-8","compiler","crystal","language"],"created_at":"2024-11-09T13:21:06.103Z","updated_at":"2025-05-12T18:20:52.746Z","avatar_url":"https://github.com/DanilaFe.png","language":"Crystal","funding_links":[],"categories":[],"sub_categories":[],"readme":"# chalk\n\nChalk is a basic compiler from a toy language into CHIP-8 bytecode.\nIt supports some higher-level constructs like looks and if-statements,\nand has some higher-level functions for drawing numbers and sprites.\n\n## Installation\n\nTo compile chalk, simply run\n```Bash\ncrystal build --release src/chalk.cr\n```\n\n## Usage\n### Syntax\nChalk has minimal syntax. All code goes into functions, which are declared as follows:\n```\nfun function(param, another_param): return_type {\n\n}\n```\nAll parameters are assumed to be of type `u8`, an unsigned byte.\nThe return type can be either `u8` or `u0`, the latter being the same as `void` in C.\nUsers can declare variables using the `var` keyword:\n```\nvar name = 5;\n```\nAssigning to existing variables is performed as such:\n```\nname = 6;\n```\nIt's possible to call another function, which uses the CHIP-8 stack. This stack\nis used exclusively for function calls, and may not exceed 12, as per the specifications\nof the CHIP-8 virtual machine.\n```\nvar result = double(name);\n```\nAdditionally, to ensure that user-defined variables stored\nin registers are not modified, chalk uses its own custom stack, placed at the end of the program.\nThis stack is accessed by modifying a stack pointer register, which holds the offset from the beginning of the stack. Because CHIP-8 registers can only hold up 8-bit unsinged numbers, the stack is therefore limited to 254 items.\n\nIf statements take \"truthy\" values to be those that have a nonzero value. As such,\n`if (0) {}` will never run, while `while(5) {}` will never terminate. Input can be awaited\nusing the `get_key` function, which returns the number of the next key pressed.\n\nSprites can be declared using a quasi-visual syntax:\n```\nsprite dum [\n`  x  x  `\n`  x  x  `\n`  x  x  `\n`        `\n`x      x`\n` xxxxxx `\n]\n```\nThese sprites can then be used in calls to `draw_sprite(sprite, x, y)`.\n\n## Contributing\n\n1. Fork it (\u003chttps://github.com/DanilaFe/chalk/fork\u003e)\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\n## Contributors\n\n- [DanilaFe](https://github.com/DanilaFe) Danila Fedorin - creator, maintainer\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanilafe%2Fchalk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanilafe%2Fchalk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanilafe%2Fchalk/lists"}