temp - Lavesiime/lavesiime.github.io GitHub Wiki
This is a handbook that details RSDK's RetroScript, more specifically the version found in RSDK V4. Please note that this wiki is always in-progress, so some things may be incomplete or otherwise lacking.
This wiki has been split into several sections for ease of reading. Please use the table of contents to navigate through this wiki in order to find what you need.
The Retro Engine Software Development Kit (Retro-Engine or RSDK) is a primarily 2D game engine with many “old-school” graphics effects, including palette-based graphics and functionality akin to “Mode 7” on the SNES. The dubbed the Retro Sonic Engine, the first game made with the RSDK was Retro-Sonic in 2002. Then, the engine was later upgraded in 2008 to be used in Sonic Nexus. RSDKv3, the 3rd version which was previously thought to be RSDKv2, was only used in the Sonic CD (2011) remaster. From there, the engine was then upgraded to RSDKv4, previously thought to be RSDKvB, for the Sonic 1 and 2 mobile remasters and likely the Sonic 3 proof-of-concept, using an updated version of RetroScript with more built-ins. Mania uses RSDKv5, the latest officially used version of RSDK, which uses a transpilable version of RetroScript. Versioning for RSDK has followed the editor’s version since v3. RetroScript remains officially unnamed, though it was previously confused with TaxReciept, which is Retro-Sonic's bytecode.
RetroScript V4 is the scripting language used in RSDKv4, or the version of the Retro Engine to first be released in 2013. It is a simple object-oriented language with a somewhat syntax similar to that of Visual Basic or Python. Because of it being a scripting language, it offers many benefits compared to a typical language such like C:
- Scripts are recompiled when a stage is loaded/restarted
- Changes are incredibly easy to make and test almost instantly
- Specifically designed to create object code, making it easy to create objects
As with any programming language, it is important to know the formatting of RetroScript and how the syntax works. Although it is similar to other programming languages, there are also small things to note, such as:
- Line breaks are regarded as the end of a code line
- Semicolons are only to be used in static variable declarations, using them as a line break will not work
- CRLF line endings are used, not LF
- Custom variables cannot be defined. One must use the temporary built-in variables (discussed later in the handbook)
- There are no data types other than integers. No decimal places (floats) or strings can be stored, except for passing some string constants to some built-in functions
- User-defined functions cannot be passed any parameters. All variables are however kept the same, so it is possible to use the built-in variables as a “passing” method
- You cannot have multiple expressions on one line. For example, A = B + C is invalid, but A = B then A += C is valid (discussed more on the next page)
As previously mentioned, you can only have 1 single arithmetic expression in a line. There can only ever be 1 variable on the right and another on the left. This means that, for complex calculations, each operation must all be done one by one. The list of mathematical arithmetic operators is limited to the following assignment operators:
-
=- regular assignment - 4-function
-
+=-- addition -
-=- subtraction -
*=- multiplication -
/=- division, rounding down (flooring)
-
- Bit math
-
<<=- shift left -
>>=- shift right -
&=- AND -
|=- OR -
^=- XOR
-
- Unary
-
++- used asVariable++, equivalent toVariable += 1 -
--- used asVariable--, equivalent toVariable -= 1
-
| Pseudo-code | RetroScript (with custom variables) |
i = 0;
j = 15;
i++; //i is 1
i = j + 2; //i is 17 |
i = 0
j = 15
i++ //i is 1
i = j //i is 15
i += 2 //i is 17 |
x = 19;
y = 3;
d = 5;
x -= d-- //x subtracted by 4
y -= d-- //y subtracted by 4
//d is already 3 |
x = 19
y = 3
d = 5
d--
x -= d //x subtracted by 4
y -= d //y subtracted by 4
d-- //d is now 3 |
Since RetroScript does not use braces, there are specific keyword pairs that get used, along with small specifics for each:
- If statements:
-
if [statement]-[statement]is a single boolean expression else-
endif- use as the “ending brace” - There is no such thing as a direct else-if in RetroScript. To achieve an else-if, one must make a new if statement on a new line and close it properly
-
- While statements:
-
while [statement]-[statement]is a single boolean expression as shown above -
loop- used as the “ending brace”
-
- Switch statements:
-
switch [variable]-[variable]is the variable to check for -
case [int/alias]-[int/alias]is an integer or alias to check if the variable is equal to -
endswitch- use as the “ending brace” - Switches behave similarly as they do in C;
defaultis optional andbreakis used in cases to stop fallthrough
-
- Foreach statements:
-
foreach (objectGroup, store, type)- iterates every object of in group
objectGroupand setsstoreto the object’s slotID- recommended to use
TypeName[objectName]rather than numerical types -
objectGroupcan beGROUP_ALLgo through all objects
- recommended to use
-
typeis eitherALL_ENTITIESorACTIVE_ENTITIES
- iterates every object of in group
-
next- use as the “ending brace"
-
Boolean operation is also possible but can only be used in control statements, and thus why they are in this section. There is no such boolean “or” or boolean “and” operator (|| and && respectively). The list of operators are as follows:
-
==- equal to (not = on its own) -
>- greater than -
>=- greater than or equal to -
<- less than -
<=- less than or equal to -
!=- not equal to
There are, however, some functions that you can use to assign variables boolean expressions:
CheckEqual(A, B)CheckNotEqual(A, B)CheckGreater(A, B)CheckLower(A, B)
All these set CheckResult to either 0 or 1 based on the result of the function, which can later be checked and ORed/ANDed with. An example can be seen below
| Pseudo-code | RetroScript (with custom variables) |
if (x == 0) {
y = 15;
z = 3;
} else {
y = 3;
z = 15;
} |
if x == 0
y = 15
z = 3
else
y = 3
z = 15
end if |
if ((x == 1) || (y == 2) || (z == 3)) {
a = 7;
} |
CheckEqual(x, 1)
temp0 = checkResult
CheckEqual(y, 2)
temp0 |= checkResult
CheckEqual(z, 3)
temp0 |= checkResult
if temp0 == true
a = 7
end if |
while (x < 10) {
x++;
if (y == 5) break;
} |
while x < 10
x++
if y == 5
break
end if
loop |
switch (x) {
case 1:
case 2:
y++;
case 3:
x++;
break;
default:
z++;
break;
} |
switch x
case 1
case 2
y++
case 3
x++
break
default
z++
break
endswitch |
Events are easily thought of as “default functions” and are all called periodically during gameplay. To define events, you can use event [name] as the start and end event as the “closing brace”. The definable game events are as follows:
-
ObjectMain- Called once every frame per object if priority allows for it, see priority notes -
ObjectDraw- Called once every frame per object if priority allows for it, see priority notes. The ordering is based on the value ofobject.drawOrder -
ObjectStartup- Called once per object type and once when the stage loads. Used for loading assets and sprite frames
There are also a couple of editor-related events available. They are never called in-game and are only used by external editors, such as RetroED or the official RSDK editor. It is not necessary to have these present in objects, but it is highly recommended.
-
RSDKDraw- Similar toObjectDraw, used by the program to draw each object -
RSDKLoad- Similar toObjectStartup, used by the program to load any assets and sprite frames needed in order to draw the object
Custom functions are defined by using function [name] to start a function and end function as the “closing brace.” Functions can be forward declared using the preprocessor directive reserve function [name]. To call functions, you use CallFunction([name]). This means functions cannot have built in parameters, but there are ways to get around it as seen in the example below. return can be used to preemptively end a function.
| Pseudo-code | RetroScript (with custom variables) |
MyFunc(y);
ObjectMain() {
x = 5; // x is 5
x = MyFunc(x) // Pass x (not it’s value)
// x is 7
}
MyFunc(y) {
x += 2; // Increase x by 2
return;
x += 5; // This line doesn’t hit
} |
reserve function MyFunc
event ObjectMain
x = 5
CallFunction(MyFunc)
// x is 7
end event
function MyFunc
x += 2
return
x += 5 // This line doesn’t hit
end function |
RetroScript v4 has 1 preprocessor directive that is available to use. The preprocessor directive format for it is as follows:
-
#platform: [type][...]#endplatformThis will skip over any lines of code inbetween the two statements if the type does does match what the code is being compiled for.
The types for it are the following
The only type that truly is for platforms, this is used to differentiate between different platforms the game may be running on. This can be used for things such as handling input, where it's necesary to decide whether to take touchscreen or gamepad input.
It's recommended to use engine.deviceType with RETRO_STANDARD/RETRO_MOBILE instead, as that runs via normal code and will run across different systems correctly, even after compilation.
For software rendering and hardware rendering, respectively. It is normally not needed to change things based on current renderer, as even mobile phones are now powerful enough to run software rendering. However, these platform flags are still here, just in case.
For whether haptic feedback is enabled or not. Although these exist, there isn't much use to these, either, as there are no haptic feedback functions actually available.
Used to determine if RSDK networking is enabled or not. Normally used for multiplayer, although it can also be used for other things.
A platform flag for code meant to be used specifically for the Retro Engine V4 decompilation. Currently, this is the only public place with the RetroScript V4 compiler, but this platform flag is here in case another compiler comes in the future.
A platform flag also meant for the Retro Engine V4 decompilation, this one is used set to true if the mod loader is enabled. The mod loader being enabled itself isn't too major of a thing, but it also brings several features of its own which are discussed later in this document.
RetroScript v4 has 3 formats for extra variables that are available to use. These use the keywords public and private. public means this variable can be accessed by any script compiled after the current one, while private means the variable can only be accessed by the script it was created in. the formats for the variables are as follows:
-
[public]/[private] alias [val] : [name]- Creates a new alias that gets replaced byvalon compile time- Example:
private alias 1 : myAliaswould make the compiler treat all instances ofmyAliasas simply being the number1instead
- Example:
-
[public]/[private] value [name] = [val];- Creates a new static variable with the value ofval. Static variables are not tied to an object and thus should not be used when a value is needed for every instance of an object. Instead, they are regular values that can be accessed the same as any other built-in one- Example:
public value myValue = 0;would create the valuemyValuewith a default value of0and allow any other objects compiled after this one to access the value
- Example:
-
[public]/[private] table [name] [values][...]end table- Creates a new table and fills it up with values fromvalues- For more information, see below
One of RetroScript V4's additions from its V3 counterpart is the addition of tables. The format of a table is described above, with [values] holding all the values the table should have, with the end being signified by an end table keyword. Values should be separated by either a , character or a newline. Having both after an entry will cause an empty entry in between.
To interact with tables, the [G/S]etTableValue functions exist. Their arguments are as follows:
- Gets a value from table
arrayat positionindexand stores the result instore- Used for reading from tables
- Sets the value in table
arrayat positionindextovalue- Used for writing to tables
Just like any other language, tables can be used for a variety of purposes. One example can be seen below, where a table is being used to hold frame durations used in the animation of an object.
| RetroScript (with custom variables) |
private table Object_dummyTable
64, 1, 1, 1, 1, 1, 2, 1, 2, 1, 234
end table
event ObjectMain
GetTableValue(temp0, object.frame, Object_dummyTable)
object.timer++
if object.timer == temp0
object.timer = 0
object.frame++
end if
end event |
Music is in the stored in ogg format, with a sample rate of 44100. In order to use a custom music track during gameplay, all that is needed is for the file to be present in the Data/Music/ directory. Only one music track can play at a time, but operations such as fading out, stopping, or swapping can be preformed during playback.
- Takes the music track located at
filePathand assigns it to IDtrackIDwith a loop point ofloopPoint -
loopPointis track loop point- 0 is used to signify no loop, 1 is used to loop from the begining of the track, any other values are the point to loop from in samples
- This will only set the music track to the track ID, it will not play the music
- In order to play it,
PlayMusicis needed
- In order to play it,
- Plays the music track loaded into the slot at
trackID -
trackIDmusic information needs to be set withSetMusicTrackbeforehand, see previous entry
- Stops the currently playing music
- Pauses the currently playing music
- Can be resumed with
ResumeMusiclater
- Can be resumed with
- Resumes the music formerly paused by
StopMusic
- Works similar to
SetMusicTrack()&PlayMusic()but starts at a position based onratio-
ratiois using an8000-based value, so8000= 1.0 music speed,4000= 0.5, etc
-
- The volume of the currently playing music
- Can be manipulated in order to fade in/out music
- ID of the currently playing music track
- Read only, but new music can be played via
PlayMusic
- Read only, but new music can be played via
- The position of the currently playing music track
- Stored in sample number
- Read only
- The master volume for all music
- Ranges from 0-100
- Combined with
music.volumeto get the final output volume
- Changing this often is not recommended
-
music.volumeshould be changed, instead
-
Sound effects are stored in the wav format and have to be present in the Data/SoundFX/ directory. In order to use them during gameplay, they need to be present in either the global sound effects list or the scene-specific sound effects list. Once added, a name can be entered for them in order to use SFXName. This isn't necessary, but it's highly recommended. Without a name, sound effects can only be played with numerical ID's.
- Plays SFX
sfxloopCnttimes-
sfxis ID of SFX, SFX ID can be found by looking at the by looking at GameConfig + StageConfig - Using
SfxNameis recomended
-
- Changes the properties of SFX
sfx-
sfxis ID of SFX, see above for more info- Using
SfxNameis recomended
- Using
-
loopCntis the amount of times for the sound to loop. Use-1in order to leave it unchanged -
panis how much the sound should be panned.-100is to the left, while100is to the right. 0 can be used in order to balance it
-
- Stops the sound effect
sfx-
sfxis ID of SFX - Using
SfxNameis recomended
-
- The master volume for all SFX
- Changing this often is not recommended
placeholder stuff pretend there's nothing below here
If the same sheet is loaded twice, it doesn't load again and returns the I'd of the existing sheet Sheets are cleared upon scene load
Sprites are stored in the gif format in the Data/Sprites/ directory. The sheet's dimensions must be a power of two, but it is not required to be a square. For example, sprite sheets with dimensions of 256x512 and 64x64 could work, but one that has a size of 300x300 wouldn't. Sheets can be loaded via LoadSpriteSheet, at which point they get assigned a sprite sheet ID. Up to 24 different sheets can be loaded at once, although one can be removed from memory at any time with RemoveSpriteSheet. Additionally, loaded sheets are cleared upon a scene reset, so it is not nesecary to manually remove sheets from memory.
- Loads the sprite sheet from
pathand assigns it to the current object-
pathis based offData/Sprites/directory, not RSDK root
-
- Removes the sprite sheet at
patchfrom memory-
pathis based offData/Sprites/directory, not RSDK root - This doesn't delete any files; the actual file will remain untouched
-
- Creates a spriteframe with the specified values
-
pivotXandpivotYare where the center of the sprite is -
widthandheightare how wide and tall the sprite is -
sprXandsprYare the location of the sprite on the loaded sprite sheet
-
- Edits spriteframe
frameof the current object to use the new values specified- Values follow same format as
SpriteFrame, see above
- Values follow same format as
- Draws sprite
frameat the object's current X and Y position
- Draws sprite
frameatXPosandYPos- Uses world-space position instead of screen space (
0, 0is top left,0x10000, 0is 1 px to the right)
- Uses world-space position instead of screen space (
- Draws sprite
frameatXPosandYPos- Uses screen-space position (
0, 0is top left,1, 0is 1 px to the right)
- Uses screen-space position (
- Draws sprite
frameatXPosandYPoswithfxeffects- Uses world-space positioning (
0, 0is top left,0x10000, 0is 1 px to the right)
- Uses world-space positioning (
- Draws sprite
frameatXPosandYPoswithfxeffects- Uses screen-space positioning (
0, 0is top left,1, 0is 1 px to the right)
- Uses screen-space positioning (
- Effect ID's to be used for
DrawSpriteFXandDrawSpriteScreenFX.- FX_FLIP allows for sprite flipping
- FX_SCALE allows for sprite scaling
- FX_ROTATE allows for sprite rotation
- FX_ROTOZOOM allows for sprite scaling and rotation at the same time
- FX_INK allows for different ink effects (see INK_ section for more details)
- Draws a rectangle with the specified values
-
XposandYPosare the position to draw it in screen-space (0, 0is top left,1, 0is 1 px to the right) -
widthandheightare the dimensions for the rectangle -
R,G, andBdetermine what color the rectanlge should be following theRGBformat -
Ais the alpha, or transparency, to draw it at
-
- Draws a tint rectangle with the dimensions of
widthandheightatXPosandYPos, relative to screen-space
DrawNumbers(int startingFrame, int XPos, int YPos, int value, int digitCnt, int spacing, int showAllDigits)
- Draws the provided numbers to the screen
-
startingFrameis the first frame the numbers start from- Starts at
0, then assumes following numbers will be1-9
- Starts at
-
XPosandYPosare the position to starting drawing from in screen-space (0, 0is top left,1, 0is 1 px to the right) -
valueis the value to draw to the screen -
digitCntis the -
spacingis how many pixels should be between each number - If
showAllDigitsis 0, then only valid digits will be drawn- Otherwise,
digitCntdigits will be drawn, with extras being0
- Otherwise,
-
DrawActName(int startingFrame, int XPos, int YPos, int align, int unknown, int unknown2, int spacing)
- Draws the loaded stage’s act name
- Uses 26 frames, starting from
startingFrame -
XPosandYPosare position to draw it at in screen-space (0, 0is top left,1, 0is 1 px to the right) - Only uppercase english letters are supported
-
alignmentis used to determine where the text center is (0= left,1= middle,2= right) -
spacingpixels are placed between each letter
- Uses 26 frames, starting from
- Adds
objectPosto the drawListlayer
- Sets the value in drawList
layeratobjectPosto the value ofvalue
- Gets the value in drawList
layeratobjectPosand stores it instore
- Removes all entries in drawList
layer
Although there aren't many animation-related commands available for use, animations as a whole are still an important part of RSDK. It allows objects to be animated independantly of their object scripts, although said object's animations can still be manually controlled via scripts if needed. When using animations, sprite sheets and sprite frames don't need to be done via script, as they are all handled via the animation file instead.
- Loads the animation file at
Data/Animations/[filePath]for the current object to use
- Cycles through all animations in the currently loaded animation file to find what animation ID correspongs to with
animationNameand sets the result tostore-
storewill be set to 0 if animation can't be found
-
- Updates the current object's animation based on the object's various values such as:
object.animationobject.animationSpeedobject.animationTimerobject.frame
- Draws the object at its
XPosandYPosbased on the currently loaded animation file andobject.animation/object.frame
Palettes are stored within the Data/Palettes/ directory. Palettes should be in the act file format, which stands for for Adobe Color Table. The format itself is very simple; it is just a series of RGB colors stored as RR GG BB in bytes with no header or otherwise padding information. RSDK can only hold 255 colors in a single palette, although there can be up to 8 separate palettes at once, combining up to a total of 2040 available colors at once. The first color in each palette is reserved for transparency.
- Loads the palette from
Data/Palettes/[filePath]intopalID-
startPalIndexis used to signify where to start from in the game's current palette -
startIndexis used to signify where to start from in the externally loaded palette -
endIndexis used to signify where to stop reading from the externally loaded palette
-
- Rotates all colours
palIDstarting fromstartIndexthrough toendIndex- Rotates one to the left if
rightis 0, otherwise rotates one right
- Rotates one to the left if
- Sets a global fade-out effect based on
r,g,banda
- Sets the active palette to
palIDfor all lines fromstartLinethoughendLine-
startLineandendLineare based on screen-space position
-
- Sets the palette entry at
indexinpalIDto the value ofcolour-
colouris packed RGB value, of0xRRGGBB
-
- Gets the palette entry at
indexfrompalIDand sets it to store- Color set to
storeis packed RGB value, format of0xRRGGBB
- Color set to
- Blends
srcPalAwithsrcPalBbyblendAmount, starting fromstartIndexand continuing though toendIndex, storing the resulting colors indstPal
- Copies
countcolors fromsrcPalatsrcPalStartindex todstPalatdstPalStart
- Clears all pixels on screen with the colour from
indexin the active palette
RetroScript is an object-oriented programming langauge, and as such, code cannot be run from outside an object. Each object has about a hundred values available for use, a far step up from RSDKv3's mere 25 or so.
index is the index of the target object. Appending + or - to a number will instead look at the object based on an offset from the current object's position. Additionally, index is optional, not including it will refrence the current object.
- The object's type
- Corresponds to an object script path from which the object's code is run
- The object's type group
- By default, this matches the object's type, but it can be set to another value by script
-
0x1000upwards are never assigned by default, so they can work just fine for custom groups
-
- Commonly used in
foreachstatements
- By default, this matches the object's type, but it can be set to another value by script
- The object's property value, or a variation value to indicate which version of an object to use
- Comparable to "subtypes"
- The object's current state
- Can be used in any way by the object, whether it be a numbered state, a function pointer, or etc.
- The object's tile angle
- Usually set via ProcessObjectMovement()
- Not to be confused with
object.rotation, which is how much to rotate the object when drawing
- The object's rotation
- Used with
DrawSprite[Screen]FXandFX_ROTATEorFX_ROTOZOOM - Meant for visual effects
- Used with
- The object's scale
- Used with
DrawSprite[Screen]FXandFX_SCALE,FX_ROTOZOOM, orFX_TINT - Uses a 9-bit bitshifted value, so 0x200 (512) == 1.0
- Used with
- The object's transparency
- Between 0 and 255
- The object's current animation
- Used by
ProcessAnimation() - Between 0 and 255
- Used by
- The object's animation from the previous frame
- Used by
ProcessAnimation() - Between 0 and 255, same range as
object.animation
- Used by
- A timer used in processing animations for the object
- Used by
ProcessAnimation()
- Used by
- The object's animation speed
- Used by
ProcessAnimation()
- Used by
- The object's X and Y position
- Uses world-space position (
0, 0is top left,0x10000, 0is 1 px to the right)
- Uses world-space position (
- The object's X and Y position, but truncated to screen-space position (
0, 0is top left,1, 0is 1 px to the right)
- The camera offset from the player's position
- The object's X and Y velocities
- World-space
- The object's speed
- World-space
- The object’s priority value, determines how the engine handles object activity
- Set to
PRIORITY_ACTIVE_BOUNDSby default
- Set to
- The object's drawing layer
- Manages what
drawListthe object is placed in - 3 is default
- Manages what
- The object's direction
- Determines which way to flip the sprite if using
DrawSprite[Screen]FX
- Determines which way to flip the sprite if using
- ID's for
object.direction
- Determines the blending mode used by
DrawSprite[Screen]FXwithFX_INK
- 47 integer variables used for long-term storage. What they are used for varies between every object.
- Individual values can be retrieved via
GetObjectValueand set viaSetObjectValue
- Gets
object[objectPos].value[index]and sets it tostore
- Sets
object[objectPos].value[index]to the value ofvalue
- The object's collision mode
- ID's for
object.collisionMode
- The object's collision plane
- Either
0or1
- Either
- The object's control mode
- 0 by default
- The object's control lock timer
- The object's pushing flag
- Usually set by collision functions
- Determines if the object is visible or not
- Object's draw event is only called if this is true
- Determines if the object will interact with tiles or not
- Determines if the object will interact with other objects
- The object's gravity state
- ID's for
object.gravity
- Object input buffer values
- Generally set via ProcessPlayerControl()
- Per-object values, not to be confused with
inputDown.uporinputPress.leftand such
- Determines if the object will track the object's position or simply follow it instead
- Object collision censors for when on the ground
- True if there was collision, false if there wasn't
- The object's active hitbox based on the loaded animation file and
object.animation/object.framevalues
- Sets the update ranges for all objects
-
rangeis how wide the“screen range should be - The default values are the same as
SetObjectRange(424)
-
- Copies
countobjects starting fromsrcSlotinto slotdestSlotin the entity list- The active object list has 1184 slots. However, after that, there are anther 1184 slots meant to be used for storage.
- These storage slots are kept the same between scene reloads, meaning that they can be used to keep an object between different scenes
- EX:
CopyObject(1200, 0, 5)will copy objects from slot0-4into slots1200-1204
Stages themselves are unable to have code attached to them, but there are several variables that are associated with stages nonetheless. Additionally, stages can have an object specific to them created in order to run code specific to this stage, as well as a global object having code that should be shared between all stages. Things that would normally need to be done by specific stages include palette cycles and animated tiles, but there is also much more.
- The stage's current state
- ID's for
stage.state
- Timer values for the current stage
- These are automatically set by the engine if
stage.TimeEnabledistrue
- These are automatically set by the engine if
- Determines whether time should increase or not
- The ID of the next stage to load
- Based on, as the name implies, the stage's position on the stage list
- The active list to load stages from, ID's are below
- List ID's for
stage.activeList
- The amount of stages in stage list
index- ID's for use are provided above
- Loads a stage with an ID of
stage.listPosfromstage.activeList- All objects and their object values will be refreshed, although global variables will remain
- In order to keep an object between different scenes,
CopyObjectcan be used
- The act number of the currently loaded stage
- Determines whether or not the game can be paused
- The stage’s main camera boundaries, the camera will not go beyond these
- The stage’s other camera boundaries, the camera will not go beyond these, either
- These are used when setting new camera boundaries
- The layer deformation data arrays
- 0 & 1 are used for the FG Layer (0 being for above water, 1 being for below water)
- 2 & 3 are used for the BG Layers (2 being for above water, 3 being for below water)
- The stage's current water level
- Drawable layer ID's, with index 0 being the lowest and index 3 being the highest
Any layers that are not set with this array or are set to 9 will not be drawn
- Any active layers above this value will draw only tiles on the high Visual Plane
- Otherwise only tiles on the low Visual Plane will be drawn
- The current player selection
- Persists between scene reloads
- Whether debug mode is enabled or not
- Exact purpose unknown, seems to be a misnomer
- Looks to be the same as
object.entityPos
- Looks to be the same as
- Sets the deformation of the deformation data array of
deformIDbased on thedeformvalues
- Gets the
chunkIDof the chunk atchunkX,chunkYon tileLayerlayerand stores it instore
- Sets the
chunkIDof the chunk atchunkX,chunkYon tileLayerlayerand sets the index tovalue
- Gets the info of
infoTypeof the tile attileX,tileYand stores it instore
- Sets the info of
infoTypeof the tile attileX,tileYand sets it tovalue
- ID's for
infoTypefor[G/S]et16x16TileInfo-
TILEINFO_FLAGSB&TILEINFO_ANGLEBare read-only and can only be used withGet16x16TileInfo()
-
- Copies the tileset image data from
srctodst- Used for animated tiles
- If the loaded stage's folder matches
folder,CheckResultis set to true- Otherwise, it is set to false
- The size of tile layer
indexin chunks
- The type of rendering that the tile layer
indexuses
- ID's for
tileLayer.type
- The angle of the tile layer
- Used for
3DFLOORand3DSKYrotations
- Used for
- The position of the tile layer
- Used for
3DFLOORand3DSKYrotations
- Used for
- The parallax values of the tile layer
- The offset for the deformation data arrays when rendering
- The scroll info’s parallax factor, or relative speed, which determines how many pixels the parallax moves per pixel move of the camera
- The scroll info’s scroll constant speed which determines how many pixels the parallax moves per frame
- The scroll info’s scroll position, which is how many pixels the parallax is offset from the starting position
- Used to get the ID of a stage/scene based on its name
- EX:
GREEN HILL ZONE 1has an stgID of 0 in Sonic 1, so usingStageName[R - GREEN HILL ZONE 1]would be the same as using0
- EX:
| Variables | Description |
inputDown.up
inputDown.down
inputDown.left
inputDown.right
inputDown.buttonA
inputDown.buttonB
inputDown.buttonC
inputDown.buttonX
inputDown.buttonY
inputDown.buttonZ
inputDown.buttonL
inputDown.buttonR
inputDown.start
inputDown.select |
True if the corresponding button/key has been held |
inputPress.up
inputPress.down
inputPress.left
inputPress.right
inputPress.buttonA
inputPress.buttonB
inputPress.buttonC
inputPress.buttonX
inputPress.buttonY
inputPress.buttonZ
inputPress.buttonL
inputPress.buttonR
inputPress.start
inputPress.select |
True if the corresponding button/key was pressed on this frame |
- Checks if a touch input was detected between the inputted coordinates and sets
CheckResultaccordingly- Based on screen position
- Gets the value from the sin/cos512 lookup table based on
angleand sets it instore
- Gets the value from the sin/cos256 lookup table based on
angleand sets it instore
- Performs an arctan operation using
xandyand stores the result instore
- Gets bit at index
posfromvalueand stores it instore
- Sets bit at index
postosetand updatesvalueaccordingly
- Gets a random value from 0 to
maxand stores it instore
- Performs a NOT operation on
valueand updates it- (value = ~value)
- Sets
valueto the absolute version of it
- Linearly interpolates (LERPs)
xandybypercentand stores the result instore-
percentis0through255.
-
- InterpolateXY does 2 at once for points (
aX,aY) and (bX,bY)
Although the Retro Engine is primarily a 2d-based engine, it also has a robust 3d system. Although this system doesn't allow for custom model loading, it still allows for a great deal of things to be done.
- RSDKv4 only allow use of 3 matrices: world, view & temp.
- Passing these should only be done to parameters of type mat.
- Matrix values are shifted 8 bits, so 0x100 (starting vals) is 1.0
- Amount of active faces/vertices in each buffer respectively
- Max of 1024 faces and 4096 vertices
- The width (X) and height (Y) of the 3DScene draw buffer.
- These values determine what base resolution to use for drawing functions
- The colour of the fog in RGB format and the strength of the fog (0-255)
- Used with FADE_FADED flag
- The vertex indices to use to control this face’s drawing
- The different face drawing flags that can be used with
faceBuffer.flag
- The active drawing flag for this face
- The colour to draw the face when drawing with
FACE_COLOURED_2DorFACE_COLOURED_3Dflags
- The vertex coordinates for the specified vertex
- Sets the matrix of
matrixto the identity state
- Multiplies
matrixAbymatrixBand stores the result inmatrixA
- Translates
matrixtox,y,z, all shifted 8 bits (0x100 = 1.0)
- Scales
matrixbyx,y,z, all shifted 8 bits (0x100 = 1.0)
- Rotates
matrixtoangleon the specified axis, or all if usingMatrixRotateXYZ- Angles are 512-based, similar to sin/cos
- Performs an inversion on the values of
matrix
- Transforms all vertices from
startIndextoendIndexusingmatrix
- Draws the active 3DScene data to the screen
Menus are primarily used to display large amounts of text. The font is locked to an 8x8 size, with there being no way to change it. Custom fonts are loaded via LoadSpriteSheet(). Text positions are the same as the default system font found in Data/Game/SystemText.gif.
Although unconventional, menus can also be used to load raw data which can then be read from via GetTextInfo(). If doing this, then note that attempting to draw the menu may result in garbage text being drawn to the screen
- Menu ID's used for menu parameters
- The current row selection for
MENU_1andMENU_2, respectively
- Loads the file from
filePathand appends it tomenu-
filePathis from executable directory, orData/..
-
- Sets up
menuwithrowCountrows,selectionCountactive selections, and aligning it toalignment-
alignmentvalues are:-
0- left alignment -
1- right alignment -
2- center alignment
-
-
- Adds a menu entry to
menuwith the contents oftextand highlighting it ifhighlightEntryis set to true
- Edits the entry at
rowIDinmenuto have the contents oftext, highlighting it ifhighlightEntryis set to true
- Gets text info of
typefrommenuat rowindexand stores it instore-
offsetis only used iftypeisTEXTINFO_TEXTDATA, whereoffsetis which character to read from
-
- The types of data that can be fetched via
GetTextInfo
- Draws menu
menuatXPosandYPosusing screen-space position (0, 0is top left,1, 0is 1 px to the right)
- A rather specialised function that adds the game's verion number as text to
menu, highlighted ifhighlightis set to true
| RetroScript (with custom variables) |
event ObjectMain
// Act on input
if inputPress.up == true
menu1.selection++
else
if inputPress.down == true
menu1.selection--
end if
end if
// Limit selections to 0-3
if menu1.selection < 0
menu1.selection = 0
else
if menu1.selection > 3
menu1.selection = 3
end if
end if
end event
event ObjectDraw
// Draw MENU_1 20 px from the top of the screen and at the middle of the screen
DrawMenu(MENU_1, screen.xcenter, 20)
end event
event ObjectMain
LoadSpriteSheet("UI/MenuFont.gif")
SetupMenu(MENU_1, 0, 3, 2)
AddMenuEntry(MENU_1, "PLAYER 1", 1)
AddMenuEntry(MENU_1, "PLAYER 2", 1)
AddMenuEntry(MENU_1, "SETTINGS", 1)
AddMenuEntry(MENU_1, "EXIT", 1)
menu1.selection = 0
end event |
The engine has several variables of its own, mostly to control game flow and other engine-level things.
- The current engine game loop state, can be set to
RESET_GAMEin order to restart the game
- The language the engine is actively using
- Whether or not online functionality is enabled for the engine
- Can be used in conjunction with
#platform: USE_NETWORKING
- Can be used in conjunction with
- Whether or not the game is built as a "trial version"
- Basically always false
- The current device type the game is currently running on
- Device types for
engine.deviceType
Things that don't really fit into any other category but are still nonetheless very important.
- Temporary values used to store things operations
- Variables used for storing indexes to be used with arrays
- Prints a message to the console & the log
- If
isIntis set thenmessagewill be treated as an int, otherwise it will be treated as a string. - If
addNewLineis set a\ncharacter will be added to the end of the message when printed.
- If
- Reads the contents of the save file and stores it into
SaveRAM
- Writes the contents of
SaveRAMto the save file
- An array of data capable set with
ReadSaveRAM()and saved withWriteSaveRAM()
- Calls the native engine function with the ID of
callbackFuncIDusing no params, 2 params, or 4 params respectively.- Adding a global variable with a name that matches any of the valid function names will result in its value being set to the function id internally
- EX: A global variable with the name “SetAchievement” will have its value set to the function ID of the “SetAchievement” function
- Valid function names are shown below.
- Adding a global variable with a name that matches any of the valid function names will result in its value being set to the function id internally
Native functions present are as follows:
| Function | Description |
SetAchievement(int id, int status) |
Sets an achievement’s status to Status. Status 100 is achieved, anything else is unachieved. |
Connect2PVS(int gameLength, int itemMode) |
Initializes a 2P VS session |
Disconnect2PVS() |
Ends the currently active 2P VS session |
SendEntity(int entityID, int unused) |
Sends the entity in slot |
SendValue(int value, int unused) |
Sends |
ReceiveEntity(int entityID, bool incrementSlot) |
Receives (and loads) the next entity in the stack from the other player. |
ReceiveValue(int value, bool incrementSlot) |
Receives the next value in the stack from the other player. |
TransmitGlobal(int value, string name) |
Sends a global value to the other player in the VS session. |
ShowPromoPopup(int id, string promoName) |
Attempts to display a promotional popup. |
HapticEffect(int id, int unknown1, int unknown2, int unknown3) |
Plays a haptic effect on the controller/mobile device. |
SetNetworkGameName(int unused, string name) |
Sets the game name of the network to |
ExitGame() |
Simply exits the game |
OpenModMenu() |
Opens the dev-menu based mod menu |
AddAchievement(int unused, string name) |
Adds a new achievement with the name |
SetAchievementDescription(int id, string description)
|
Sets the description of the achievement with id, to description |
ClearAchievements() |
Clears all loaded achievements |
GetAchievementCount() |
Gets the amount of loaded achievements and stores the value in |
GetAchievement(int id, int unused) |
Gets the status of achievement id and stores the value in |
GetAchievementName(int id, int textMenu) |
Gets the name of the achievement |
GetAchievementDescription(int id, int textMenu) |
Gets the description of the achievement |
SetScreenWidth(int width, int unused) |
Sets the internal screen width of the game to be |
SetWindowScale(int scale, int unused) |
Sets the scale of the window size to |
SetWindowFullScreen(bool fullscreen, int unused) |
Sets the window to fullscreen or windowed, depending on the value of |
GetModCount() |
Gets the amount of loaded mods (not active) and stores the value in |
GetModName(int textMenu, bool highlight, int id, int unused) |
Gets the name of the mod |
GetModDescription(int textMenu, bool highlight, int id, int unused) |
Gets the description of the mod |
GetModAuthor(int textMenu, bool highlight, int id, int unused) |
Gets the author of the mod |
GetModVersion(int textMenu, bool highlight, int id, int unused) |
Gets the version of the mod |
GetModActive(int id, int unused) |
Gets the active flag of mod |
SetModActive(int id, bool active) |
Sets the active flag of mod |
RefreshEngine() |
Reloads the engine. |