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:
* music "Actraiser - Fillmore.vgm"
In the example above, the music
command has one positional parameter: the file name.
* image "Smiley.png", at(30, 3)
In 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
.
* clear background, foreground
In the example above, the clear
command comes with two flags: background
and foreground
.
Many commands accept expressions as parameters; the expressions can contain the following operators:
variable = 33
;variable != 12
;variable > 37
;variable < 98
;variable >= 56
;variable <= 78
.variable + 48
;variable - 13
;variable * 89
;variable / 75
;-variable
.(variable > 32) and (variable < 64)
;(variable < 15) or (variable > 32)
;!(variable > 31)
.123
, 456
;true
, false
;"This is a string."
.font
Loads a .png
file containing the 8x8 font. Fonts will use palette #1.
fileName
: a string pointing to the .png
file to use.
Loads a image file named `"damieng.com - Hourglass font.png"` as a font.
background
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 .png
file to use.
Displays a image file named `"Blue Hedgehog.png"` into the background.
choice
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.
music
Starts playing a .vgm
/.xgm
music in the background.
fileName
: a string pointing to the .vgm
or .xgm
file to use.* music "Actraiser - Fillmore.vgm"
Starts playing a music file named "Actraiser - Fillmore.vgm"
.
sound
Plays a digitized sound.
fileName
: a string pointing to the .wav
file to use.* sound "ready.wav"
Starts playing a sound file named "ready.wav"
.
stop
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 music
Stops current music.
* stop sound
Stops current sound.
* stop music, sound
Stops both current music and current sound.
* stop
Also stops both current music and current sound.
image
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 .png
file to use.
at(x, y)
if informed, will place the image at map position x, y
on 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), foreground
Draws 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.
duration
: tells how many seconds the command should wait.* wait 3
Waits for 3 seconds.
create
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, 12
Creates an integer variable named someVar
, whose initial value is 12
.
* create anotherOne, true
Creates 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.
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, 12
Creates an integer variable named someVar
, whose initial value is 12
.
* temp anotherOne, true
Creates a logical variable named anotherOne
, whose initial value is true
.
set
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, 2
Updates the value of the someThing
variable to be 2
.
* set anotherThing, anotherVar * 3
Updates the value of the anotherThing
variable to be the value of the variable anotherVar
multiplied by 3
.
* set counter, counter + 2
Adds 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.
if
and elseif
commands: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.
.
while
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 - 1
This 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.
target
: the name of the scene to jump to.* goto_scene test
Jumps 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.
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 default
Tells 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 #1.
fileName
: name of the .png
file containing the graphics of the cursor sprite;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;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, 3
Loads 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.
nowait
: if present, does not wait for a button press.* flush
Displays the text on the text window and waits for a button press.
* flush nowait
Displays the text on the text window without waiting for a button press.
clear
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 background
Clears the background.
* clear foreground
Clears the foreground.
* clear window
Clears the text window.
* clear background, foreground
Clears both background and foreground.
* clear
Also clears both background and foreground.
title
Sets the title of the story. Used to populate the ROM headers.
name
: The title of the story.* title "choice4genesis demo"
author
Sets the author of the story. Used to populate the ROM headers.
name
: The author of the story.* author "John Doe"
import
Imports the given .h
file into the generated code. Useful when combined with the native
command.
fileName
: The name of the .h
file.* import "extra.h"
Will import "extra.h" into the generated C
file.
native
Directly calls a C
language function.
functionName
: The name of the C
function 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.
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.