This is a ChoiceScript clone that generates Sega Genesis ROMs. If can be used for visual novels or simple multimedia presentations.
It 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.
The syntax of the scripts is somewhat based on ChoiceScript, but it is not exactly the same.
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.
Just like ChoiceScript, choice4genesis uses indentation to identify nested commands:
* choice
# Say yes
You said yes!
# Say no
You said no!You can use any amount spaces or tabs to indent the code, but not both at the same time; the indentation character must be consistent.
Each command can take three basic types of parameters:
- Positional parameters: are obligatory, and must be always inform right at the start of the command:
In the example above, the
* music "Actraiser - Fillmore.vgm"
musiccommand has one positional parameter: the file name. - 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:
In the example above, the
* image "Smiley.png", at(30, 3)
imagecommand has one positional parameter, the file name, and one named parameter, calledat, which, in turn, has two positional parameters,xandy. - Flags: are optional, and, if informed, must be placed after the positional parameters:
In the example above, the
* clear background, foregroundclearcommand comes with two flags:backgroundandforeground.
Many commands accept expressions as parameters; the expressions can contain the following operators:
- Comparison:
- Equality:
variable = 33; - Non equal to:
variable != 12; - Greater than:
variable > 37; - Less than:
variable < 98; - Greater or equal to:
variable >= 56; - Greater or lesser than:
variable <= 78.
- Equality:
- Arithmetic:
- Addition:
variable + 48; - Subtraction:
variable - 13; - Multiplication:
variable * 89; - Division:
variable / 75; - Negation:
-variable.
- Addition:
- Logic:
- And:
(variable > 32) and (variable < 64); - Or:
(variable < 15) or (variable > 32); - Not:
!(variable > 31).
- And:
- Constants:
- Numeric:
123,456; - Logical:
true,false; - String:
"This is a string.".
- Numeric:
Loads a .png file containing the 8x8 font. Fonts will use palette #1.
fileName: a string pointing to the.pngfile to use.
* font "damieng.com - Hourglass font.png"Loads a image file named "damieng.com - Hourglass font.png" as a font.
Loads 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.
fileName: a string pointing to the.pngfile to use.
* background "Blue Hedgehog.png"Displays a image file named "Blue Hedgehog.png" into the background.
Presents a menu to the user, allowing to choose between multiple options.
* choice
# Play a music
* music "Example.vgm"
# Play a sound effect
* sound "Example.vgm"This 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.
Starts playing a .vgm/.xgm music in the background.
fileName: a string pointing to the.vgmor.xgmfile to use.
* music "Actraiser - Fillmore.vgm"Starts playing a music file named "Actraiser - Fillmore.vgm".
Plays a digitized sound.
fileName: a string pointing to the.wavfile to use.
* sound "ready.wav"Starts playing a sound file named "ready.wav".
Stops the music and/or sound.
music: tells it that it should stop the current music;sound: tells it that it should stop the current sound effect.
* stop musicStops current music.
* stop soundStops current sound.
* stop music, soundStops both current music and current sound.
* stopAlso stops both current music and current sound.
Allows 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.
fileName: a string pointing to the.pngfile to use.
at(x, y)if informed, will place the image at map positionx, yon the target layer.
foreground: tells that the image should be drawn on the foreground layer;background: tells that the image should be drawn on the background layer.
* image "Example.png", at(1, 2)Draws the image "Example.png" at position 1, 2 of the background layer.
* image "Example.png", at(1, 2), foregroundDraws the image "Example.png" at position 1, 2 of the foreground layer.
* image "Example.png"Draws the image "Example.png" background layer, at the same position used by the previous image command.
Waits for a few seconds.
duration: tells how many seconds the command should wait.
* wait 3Waits for 3 seconds.
Creates a global variable.
variable: the name of the variable to create;initialValue: the initial value of the variable; the type of this value also determines the type of the variable.
* create someVar, 12Creates an integer variable named someVar, whose initial value is 12.
* create anotherOne, trueCreates a logical variable named anotherOne, whose initial value is true.
Creates a local variable. temp variables are only visible inside the scene file that created them.
variable: the name of the variable to create;initialValue: the initial value of the variable; the type of this value also determines the type of the variable.
* temp someVar, 12Creates an integer variable named someVar, whose initial value is 12.
* temp anotherOne, trueCreates a logical variable named anotherOne, whose initial value is true.
Changes the current value of an existing variable.
variable: name of the variable to update;newValue: expression defining the new value of the variable.
* set someThing, 2Updates the value of the someThing variable to be 2.
* set anotherThing, anotherVar * 3Updates the value of the anotherThing variable to be the value of the variable anotherVar multiplied by 3.
* set counter, counter + 2Adds 2 to the value of the counter variable.
Allows a certain block of code to only be executed on a given condition.
condition: a logical expression that will be used to determine if the corresponding block will be entered or not.
* if myVar = 2
It is two.
* elseif myVar = 3
It is three.
* else
It is some other number.If 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..
Keeps looping a block of code while a given condition is met.
condition: a logical expression that will be used to determine if the corresponding block will be entered or not.
* temp counter, 3
* while counter > 0
Value is ${counter}
* set counter, counter - 1This will say Value is 3, then Value is 2, then Value is 1.
Jumps to a different scene. The scene files are located on the script directory, and have the .choice extension.
target: the name of the scene to jump to.
* goto_scene testJumps to the scene contained in the archive test.choice.
Allows to configure the region of the screen that will be used for the text popups and menus.
from(x, y): the window will start at this coordinate, in characters;to(x, y): the window will end at this coordinate, in characters;size(w, h): the window will have this width and height, in characters.
default: the window will be located at the default position, with the default size.
* window from(1, 1), to(10, 4)Tells that the window will start at position 1, 1 and end at position 10, 4, in characters.
* window from(29, 1), size(10, 6)Tells that the window will start at position 29, 1 and have a width of 10 and a height of 6, in characters.
* window defaultTells that the window will be located at the default position, with the default size.
Allows to configure the blinking text cursor. It uses the palette #1.
fileName: name of the.pngfile containing the graphics of the cursor sprite;widthof 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;height: height of the cursor sprite, in characters;frameDelay: the amount of video frames that the animation should wait before advance to the next cursor animation frame.
* cursor "Cursor sprite.png", 1, 1, 3Loads 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.
Immediately shows the contents of the current text buffer on the text window; if passed the flag nowait, does not wait for a button press.
nowait: if present, does not wait for a button press.
* flushDisplays the text on the text window and waits for a button press.
* flush nowaitDisplays the text on the text window without waiting for a button press.
Allows to clear regions of the screen.
background: if present, clears the background layer;foreground: if present, clears the foreground layer;window: if present, clears the text window.
* clear backgroundClears the background.
* clear foregroundClears the foreground.
* clear windowClears the text window.
* clear background, foregroundClears both background and foreground.
* clearAlso clears both background and foreground.
Sets the title of the story. Used to populate the ROM headers.
name: The title of the story.
* title "choice4genesis demo"Sets the author of the story. Used to populate the ROM headers.
name: The author of the story.
* author "John Doe"Imports the given .h file into the generated code. Useful when combined with the native command.
fileName: The name of the.hfile.
* import "extra.h"Will import "extra.h" into the generated C file.
Directly calls a C language function.
functionName: The name of theCfunction to call.
All the positional parameters after functionName are passed as parameters to the function.
into(variable)if informed, will update the given variable with the return of the callsed function.
* native addExample, currentTick, 1 + 2, into(functionResult)Will 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.
The tool accepts those commands, but, at the moment, they don't do anything.
Will allow to mark a place where the goto command can jump to.
Will jump to a given label from anywhere on the same scene.
Will configure the default sequence in which the scenes will be played.
Will jump to the next scene in the game.
Will play a full screen video.