choice4genesis
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.
Indentation
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.
Structure of the commands
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.
Expressions
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:
Commands implemented so far
font
Loads a .png file containing the 8x8 font. Note that the image must be paletized, with 16 colors. Future versions of this tool will probably convert the image automagically. Fonts will use palette #0.
Positional parameters:
fileName: a string pointing to the.pngfile to use.
Example:
* font "damieng.com - Hourglass font.png"Loads a image file named "damieng.com - Hourglass font.png" as a font.
background
Loads a .png file as a background image. Note that the image must be paletized, with 16 colors. Future versions of this tool will probably convert the image automagically. Backgrounds will use palette #1.
Positional parameters:
fileName: a string pointing to the.pngfile to use.
Example:
* background "Blue Hedgehog.png"Displays a image file named "Blue Hedgehog.png" into the background.
choice
Presents a menu to the user, allowing to choose between multiple options.
Example:
* 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.
music
Starts playing a .vgm/.xgm music in the background.
Positional parameters:
fileName: a string pointing to the.vgmor.xgmfile to use.
Example:
* music "Actraiser - Fillmore.vgm"Starts playing a music file named "Actraiser - Fillmore.vgm".
sound
Plays a digitized sound.
Positional parameters:
fileName: a string pointing to the.wavfile to use.
Example:
* sound "ready.wav"Starts playing a sound file named "ready.wav".
stop
Stops the music and/or sound.
Flags:
music: tells it that it should stop the current music;sound: tells it that it should stop the current sound effect.
Examples:
* 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.
image
Allows drawing a small image in .png format somewhere in the background. Note that the image must be paletized, with 16 colors. Future versions of this tool will probably convert the image automagically. This command uses palette #2.
Positional parameters:
fileName: a string pointing to the.pngfile to use.
Named parameters:
at(x, y)if informed, will place the image at map positionx, yon the target layer.
Flags:
foreground: tells that the image should be drawn on the foreground layer;background: tells that the image should be drawn on the background layer.
Examples:
* 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.
wait
Waits for a few seconds.
Positional parameters:
duration: tells how many seconds the command should wait.
Example:
* wait 3Waits for 3 seconds.
create
Creates a global variable.
Positional parameters:
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.
Examples:
* 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.
temp
Creates a local variable. temp variables are only visible inside the scene file that created them.
Positional parameters:
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.
Examples:
* 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.
set
Changes the current value of an existing variable.
Positional parameters:
variable: name of the variable to update;newValue: expression defining the new value of the variable.
Examples:
* 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.
if/elseif/else
Allows a certain block of code to only be executed on a given condition.
Positional parameters for the if and elseif commands:
condition: a logical expression that will be used to determine if the corresponding block will be entered or not.
Example:
* 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..
while
Keeps looping a block of code while a given condition is met.
Positional parameters:
condition: a logical expression that will be used to determine if the corresponding block will be entered or not.
Example:
* 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.
goto_scene
Jumps to a different scene. The scene files are located on the script directory, and have the .choice extension.
Positional parameters:
target: the name of the scene to jump to.
Example
* goto_scene testJumps to the scene contained in the archive test.choice.
window
Allows to configure the region of the screen that will be used for the text popups and menus.
Positional parameters:
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.
Flags:
default: the window will be located at the default position, with the default size.
Examples:
* 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.
cursor
Allows to configure the blinking text cursor. It uses the palette #0.
Positional parameters:
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.
Example:
* 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.
flush
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.
Flags:
nowait: if present, does not wait for a button press.
Examples:
* 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.
clear
Allows to clear regions of the screen.
Flags:
background: if present, clears the background layer;foreground: if present, clears the foreground layer;window: if present, clears the text window.
Examples:
* 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.
title
Sets the title of the story. Used to populate the ROM headers.
Positional parameters:
name: The title of the story.
Example
* title "choice4genesis demo"author
Sets the author of the story. Used to populate the ROM headers.
Positional parameters:
name: The author of the story.
Example
* author "John Doe"Planned commands
The tool accepts those commands, but, at the moment, they don't do anything.
label
Will allow to mark a place where the goto command can jump to.
goto
Will jump to a given label from anywhere on the same scene.
scene_list
Will configure the default sequence in which the scenes will be played.
finish
Will jump to the next scene in the game.
video
Will play a full screen video.