{"id":13545827,"url":"https://github.com/haroldo-ok/choice4genesis","last_synced_at":"2025-07-28T15:30:40.441Z","repository":{"id":59945239,"uuid":"531704073","full_name":"haroldo-ok/choice4genesis","owner":"haroldo-ok","description":"A ChoiceScript clone that generates SGDK-compatible C source for the Sega Genesis","archived":false,"fork":false,"pushed_at":"2024-09-26T23:17:58.000Z","size":5025,"stargazers_count":23,"open_issues_count":46,"forks_count":2,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-04-04T23:33:16.795Z","etag":null,"topics":["choose-your-own-adventure","compiler","cyoa","homebrew","multimedia","presentation","sega-genesis","sgdk","slideshow","transpiler","visual-novel-engine"],"latest_commit_sha":null,"homepage":"https://haroldo-ok.itch.io/choice4genesis","language":"JavaScript","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/haroldo-ok.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}},"created_at":"2022-09-01T22:25:50.000Z","updated_at":"2025-03-28T18:55:48.000Z","dependencies_parsed_at":"2023-11-27T22:38:54.353Z","dependency_job_id":null,"html_url":"https://github.com/haroldo-ok/choice4genesis","commit_stats":null,"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"purl":"pkg:github/haroldo-ok/choice4genesis","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haroldo-ok%2Fchoice4genesis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haroldo-ok%2Fchoice4genesis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haroldo-ok%2Fchoice4genesis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haroldo-ok%2Fchoice4genesis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/haroldo-ok","download_url":"https://codeload.github.com/haroldo-ok/choice4genesis/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haroldo-ok%2Fchoice4genesis/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267538960,"owners_count":24103922,"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","status":"online","status_checked_at":"2025-07-28T02:00:09.689Z","response_time":68,"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":["choose-your-own-adventure","compiler","cyoa","homebrew","multimedia","presentation","sega-genesis","sgdk","slideshow","transpiler","visual-novel-engine"],"created_at":"2024-08-01T12:00:20.634Z","updated_at":"2025-07-28T15:30:39.985Z","avatar_url":"https://github.com/haroldo-ok.png","language":"JavaScript","funding_links":[],"categories":["Programming"],"sub_categories":["Frameworks and Compilers"],"readme":"# choice4genesis\n\nThis is a ChoiceScript clone that generates Sega Genesis ROMs. If can be used for visual novels or simple multimedia presentations.\n\nIt takes a bunch of scripts and images and, from that, it generates SGDK-compatible `.c` and `.res` files. Those are then compiled into a Sega Genesis compatible ROM, which can be run on an emulator or even on real hardware.\n\nThe syntax of the scripts is somewhat based on ChoiceScript, but it is not exactly the same.\n\n*Please note that this is an early work and progress, and it is not as stable or user-friendly as it is planned to become.*\n\n## Indentation\n\nJust like ChoiceScript, choice4genesis uses indentation to identify nested commands:\n\n```shell\n* choice\n\t# Say yes\n\t\tYou said yes!\n\t# Say no\n\t\tYou said no!\n```\n\nYou can use any amount  spaces or tabs to indent the code, but not both at the same time; the indentation character must be consistent.\n\n## Structure of the commands\n\nEach command can take three basic types of parameters:\n* Positional parameters: are obligatory, and must be always inform right at the start of the command:\n\t```shell\n\t* music \"Actraiser - Fillmore.vgm\"\n\t```\n    In the example above, the `music` command has one positional parameter: the file name.\n* Named parameters: are optional, and if informed, must be placed after the positional parameters; the positional parameters themselves can have one or more positional parameters:\n\t```shell\n\t* image \"Smiley.png\", at(30, 3)\n\t```\n\tIn the example above, the `image` command has one positional parameter, the file name, and one named parameter, called `at`, which, in turn, has two positional parameters, `x` and `y`.\n* Flags: are optional, and, if informed, must be placed after the positional parameters:\n\t```shell\n\t* clear background, foreground\n\t```\n\tIn the example above, the `clear` command comes with two flags: `background` and `foreground`.\n\t\n## Expressions\n\nMany commands accept expressions as parameters; the expressions can contain the following operators:\n* Comparison:\n\t* Equality: `variable = 33`;\n\t* Non equal to: `variable != 12`;\n\t* Greater than: `variable \u003e 37`;\n\t* Less than: `variable \u003c 98`;\n\t* Greater or equal to: `variable \u003e= 56`;\n\t* Greater or lesser than: `variable \u003c= 78`.\n* Arithmetic:\n\t* Addition: `variable + 48`;\n\t* Subtraction: `variable - 13`;\n\t* Multiplication: `variable * 89`;\n\t* Division: `variable / 75`;\n\t* Negation: `-variable`.\n* Logic:\n\t* And: `(variable \u003e 32) and (variable \u003c 64)`;\n\t* Or: `(variable \u003c 15) or (variable \u003e 32)`;\n\t* Not: `!(variable \u003e 31)`.\n* Constants:\n\t* Numeric: `123`, `456`;\n\t* Logical: `true`, `false`;\n\t* String: `\"This is a string.\"`.\n\n## Commands implemented so far\n\n### `font`\nLoads a `.png` file containing the 8x8 font. Fonts will use palette #1.\n#### Positional parameters:\n* `fileName`: a string pointing to the `.png` file to use.\n#### Example:\n```shell\n* font \"damieng.com - Hourglass font.png\"\n```\nLoads a image file named `\"damieng.com - Hourglass font.png\"` as a font.\n\n### `background`\nLoads a `.png` file as a background image. If the image is not paletized with 16 colors, it will be automatically converted by the tool. Backgrounds will use palette #0.\n#### Positional parameters:\n* `fileName`: a string pointing to the `.png` file to use.\n#### Example:\n```shell\n* background \"Blue Hedgehog.png\"\n```\nDisplays a image file named `\"Blue Hedgehog.png\"` into the background.\n\n### `choice`\nPresents a menu to the user, allowing to choose between multiple options.\n\n#### Example:\n```shell\n* choice\n\t# Play a music\n\t\t* music \"Example.vgm\"\n\t# Play a sound effect\n\t\t* sound \"Example.vgm\"\n```\nThis displays a menu with two options \"Play a music\" and \"Play a sound effect\"; if the first one is selected, a music starts playing; if the second one is selected, a sound effect is played.\n\n### `music`\nStarts playing a `.vgm`/`.xgm` music in the background.\n\n#### Positional parameters:\n* `fileName`: a string pointing to the `.vgm` or `.xgm` file to use.\n\n#### Example:\n```shell\n* music \"Actraiser - Fillmore.vgm\"\n```\nStarts playing a music file named `\"Actraiser - Fillmore.vgm\"`.\n\n### `sound`\nPlays a digitized sound.\n\n#### Positional parameters:\n* `fileName`: a string pointing to the `.wav` file to use.\n\n#### Example:\n```shell\n* sound \"ready.wav\"\n```\nStarts playing a sound file named `\"ready.wav\"`.\n\n### `stop`\nStops the music and/or sound.\n\n#### Flags:\n* `music`: tells it that it should stop the current music;\n* `sound`: tells it that it should stop the current sound effect.\n\n#### Examples:\n```shell\n* stop music\n```\nStops current music.\n```shell\n* stop sound\n```\nStops current sound.\n```shell\n* stop music, sound\n```\nStops both current music and current sound.\n```shell\n* stop\n```\nAlso stops both current music and current sound.\n\n\n### `image`\nAllows drawing a small image in `.png` format somewhere in the background. If the image is not paletized with 16 colors, it will be automatically converted by the tool. This command uses palette #2.\n\n#### Positional parameters:\n* `fileName`: a string pointing to the `.png` file to use.\n#### Named parameters:\n* `at(x, y)` if informed, will place the image at map position `x, y` on the target layer.\n#### Flags:\n* `foreground`: tells that the image should be drawn on the foreground layer;\n* `background`: tells that the image should be drawn on the background layer.\n\n#### Examples:\n```shell\n* image \"Example.png\", at(1, 2)\n```\nDraws the image \"Example.png\" at position `1, 2` of the background layer.\n```shell\n* image \"Example.png\", at(1, 2), foreground\n```\nDraws the image \"Example.png\" at position `1, 2` of the foreground layer.\n```shell\n* image \"Example.png\"\n```\nDraws the image \"Example.png\" background layer, at the same position used by the previous `image` command.\n\n\n\n### `wait`\nWaits for a few seconds.\n\n#### Positional parameters:\n* `duration`: tells how many seconds the command should wait.\n\n#### Example:\n```shell\n* wait 3\n```\nWaits for 3 seconds.\n\n### `create`\nCreates a global variable.\n\n#### Positional parameters:\n* `variable`: the name of the variable to create;\n* `initialValue`: the initial value of the variable; the type of this value also determines the type of the variable.\n\n#### Examples:\n```shell\n* create someVar, 12\n```\nCreates an integer variable named `someVar`, whose initial value is `12`.\n```shell\n* create anotherOne, true\n```\nCreates a logical variable named `anotherOne`, whose initial value is `true`.\n\n### `temp`\nCreates a local variable. `temp` variables are only visible inside the scene file that created them.\n\n#### Positional parameters:\n* `variable`: the name of the variable to create;\n* `initialValue`: the initial value of the variable; the type of this value also determines the type of the variable.\n\n#### Examples:\n```shell\n* temp someVar, 12\n```\nCreates an integer variable named `someVar`, whose initial value is `12`.\n```shell\n* temp anotherOne, true\n```\nCreates a logical variable named `anotherOne`, whose initial value is `true`.\n\n### `set`\nChanges the current value of an existing variable.\n\n#### Positional parameters:\n* `variable`: name of the variable to update;\n* `newValue`: expression defining the new value of the variable.\n\n#### Examples:\n```shell\n* set someThing, 2\n```\nUpdates the value of the `someThing` variable to be `2`.\n```shell\n* set anotherThing, anotherVar * 3\n```\nUpdates the value of the `anotherThing` variable to be the value of the variable `anotherVar` multiplied by `3`.\n```shell\n* set counter, counter + 2\n```\nAdds `2` to the value of the `counter` variable.\n\n### `if`/`elseif`/`else`\n\nAllows a certain block of code to only be executed on a given condition.\n\n#### Positional parameters for the `if` and `elseif` commands:\n* `condition`: a logical expression that will be used to determine if the corresponding block will be entered or not.\n\n#### Example:\n```shell\n* if myVar = 2\n\tIt is two.\n* elseif myVar = 3\n\tIt is three.\n* else\n\tIt is some other number.\n```\nIf the variable `myVar` equals `2`, it will say `It is two.` or else, if `myVar` equals `3`, instead, it will say `It is three.`; otherwise, it will say `It is some other number.`.\n\n### `while`\nKeeps looping a block of code while a given condition is met.\n\n#### Positional parameters:\n* `condition`: a logical expression that will be used to determine if the corresponding block will be entered or not.\n\n#### Example:\n```shell\n* temp counter, 3\n* while counter \u003e 0\n\tValue is ${counter}\n\t* set counter, counter - 1\n```\nThis will say `Value is 3`, then `Value is 2`, then `Value is 1`.\n\n### `goto_scene`\nJumps to a different scene. The scene files are located on the script directory, and have the `.choice` extension.\n\n#### Positional parameters:\n* `target`: the name of the scene to jump to.\n\n#### Example\n```shell\n* goto_scene test\n```\nJumps to the scene contained in the archive `test.choice`.\n\n### `window`\nAllows to configure the region of the screen that will be used for the text popups and menus.\n\n#### Positional parameters:\n* `from(x, y)`: the window will start at this coordinate, in characters;\n* `to(x, y)`: the window will end at this coordinate, in characters;\n* `size(w, h)`: the window will have this width and height, in characters.\n#### Flags:\n* `default`: the window will be located at the default position, with the default size.\n\n#### Examples:\n```shell\n* window from(1, 1), to(10, 4)\n```\nTells that the window will start at position `1, 1` and end at position `10, 4`, in characters.\n```shell\n* window from(29, 1), size(10, 6)\n```\nTells that the window will start at position `29, 1` and have a width of `10` and a height of `6`, in characters.\n```shell\n* window default\n```\nTells that the window will be located at the default position, with the default size.\n\n### `cursor`\nAllows to configure the blinking text cursor. It uses the palette #1.\n\n#### Positional parameters:\n* `fileName`: name of the `.png` file containing the graphics of the cursor sprite;\n* `width` of the cursor sprite, in characters; the amount of frames will be the width of the image file divided by the width of the sprite, both in characters;\n* `height`: height of the cursor sprite, in characters;\n* `frameDelay`: the amount of video frames that the animation should wait before advance to the next cursor animation frame.\n\n#### Example:\n```shell\n* cursor \"Cursor sprite.png\", 1, 1, 3\n```\nLoads the file `\"Cursor sprite.png\"` as a cursor, with a width of 1 character and a height of one character; it will wait 3 video frames betweeen one sprite frame and the next.\n\n### `flush`\nImmediately shows the contents of the current text buffer on the text window; if passed the flag `nowait`, does not wait for a button press.\n\n#### Flags:\n* `nowait`: if present, does not wait for a button press.\n\n#### Examples:\n```shell\n* flush\n```\nDisplays the text on the text window and waits for a button press.\n```shell\n* flush nowait\n```\nDisplays the text on the text window without waiting for a button press.\n\n### `clear`\nAllows to clear regions of the screen.\n\n#### Flags:\n* `background`: if present, clears the background layer;\n* `foreground`: if present, clears the foreground layer;\n* `window`: if present, clears the text window.\n\n#### Examples:\n```shell\n* clear background\n```\nClears the background.\n```shell\n* clear foreground\n```\nClears the foreground.\n```shell\n* clear window\n```\nClears the text window.\n```shell\n* clear background, foreground\n```\nClears both background and foreground.\n```shell\n* clear\n```\nAlso clears both background and foreground.\n\n### `title`\nSets the title of the story. Used to populate the ROM headers.\n\n#### Positional parameters:\n* `name`: The title of the story.\n\n#### Example\n```shell\n* title \"choice4genesis demo\"\n```\n\n### `author`\nSets the author of the story. Used to populate the ROM headers.\n\n#### Positional parameters:\n* `name`: The author of the story.\n\n#### Example\n```shell\n* author \"John Doe\"\n```\n\n### `import`\nImports the given `.h` file into the generated code. Useful when combined with the `native` command.\n\n#### Positional parameters:\n* `fileName`: The name of the `.h` file.\n\n#### Example\n```shell\n* import \"extra.h\"\n```\nWill import \"extra.h\" into the generated `C` file.\n\n### `native`\nDirectly calls a `C` language function.\n\n#### Positional parameters:\n* `functionName`: The name of the `C` function to call.\n\n#### Variadic parameters:\nAll the positional parameters after `functionName` are passed as parameters to the function.\n\n#### Named parameters:\n* `into(variable)` if informed, will update the given variable with the return of the callsed function.\n\n#### Example\n```shell\n* native addExample, currentTick, 1 + 2, into(functionResult)\n```\nWill call the function `addExample` passing as parameters the value of the variable `currentTick` and the result of `1 + 2`; the result of the function will be stored in the `functionResult` variable.\n\n\n\n## Planned commands\n\nThe tool accepts those commands, but, at the moment, they don't do anything.\n\n### `label`\nWill allow to mark a place where the `goto` command can jump to.\n\n### `goto`\nWill jump to a given label from anywhere on the same scene.\n\n### `scene_list`\nWill configure the default sequence in which the scenes will be played.\n\n### `finish`\nWill jump to the next scene in the game.\n\n### `video`\nWill play a full screen video.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharoldo-ok%2Fchoice4genesis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fharoldo-ok%2Fchoice4genesis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharoldo-ok%2Fchoice4genesis/lists"}