YACE64 Logo

The Commodore 64 3D and VR Emulator

Home Introduction Features Screenshots Download Links Help About
Commodore 64
www.icons8.com

Overview

The new version of YACE supports Angelscript scripting. The script is also used for the 3D and VR transformation - here you can define your 3D scene and manipulate all visual objects (see 3D/VR tutorial).
Also it is possible to change or extend the gameplay or automate and manipulate user input like key press. Adding simple AI is also possible.

Many things can also be automated using the command console and the complex breakpoints to trigger actions.
Script and console command can also be used together, e.g. setting conditional actions or breakpoint from the script or reacting on them in the script.

Description

The scripting language Angelscript is quite easy to understand - it's like C++ without pointers.

Angelscripts can be loaded from the library or the file dialog. The global part of the script is executed directly on loading.
When starting YACE64 the script "Default.as" is loaded automatically, it just contains some samples.

When the script contain errors a message on the screen appears. The detailed script logging can be found in the file YACE.log within the emulator path. There will errors and warings be written. So if something doesn't work as expected, first have a look in this file. The file will be overridden on every start of YACE.

Note: If you are missing a function or callback, please contact me - most things can be added shortly.

YACE64 can call function within the script; currently the following are supported:

Callbacks

Callbacks are function, that are called from emulator, when defined in the script. For performance reasons only define functions that you need.

void OnLoad(bool reloaded) Script is loaded and the global code was executed.
reload is true, if the same script was loaded again.
Example
Tutorials
void OnUnload() Script is about to unload, because an other script is about to load or YACE64 shuts down  
void OnBreak(PC, device) Emulation is paused
PC is the current program counter (address the CPU is about to execute)
device is either the C64, D8 or D9 object, depending on which device was paused
 
void OnContinue(PC, device) Emulation is continued  
void OnFrameEnd() The VIC has finished drawing a frame. This is an asynchronous call! Tutorial 07
Tutorial 08
void  OnCondition(conditionId, device, data) A script condition was reached.
Condition can be set with the BS command in the console or with the SetCondition() function of the device C64, D8 or D9
conditionId is the identifier for the condition (this id is used to remove, enable, disable a specific condition)
device is either the C64, D8 or D9 object, depending for which device the condition was set
data is the text that was set when creating the condition
Example
Tutorial 08
 void OnJoystick(int port, JoystickContact contacts) A joystick was moved or fire was pressed
port is either port 1 or port 2
contacts is the binary mask of the joystick contacts (see JoystickContact)
Example
void OnKeyboard(bool pressed, Keys cbmKeyboard) A key (see Keys) on the (C64) keyboard was pressed or released. Example
Tutorial 07
void OnUser(int buttonId) A user button was clicked in the menu (Control/Script)
buttonId is 1 to 5
Example
Tutorial 21
Draw OnChar(int mode, CharInfo& charInfo, BlockManipulation& charManipulationBack, BlockManipulation& charManipulationFore) This is called for every char on the screen (also in bitmap modes) for each 8x8 pixel block (see 3D/VR tutorial).
charInfo has informations about this block (see "CharInfo"). The charManipulationBack and charManipulationFore structures can be manipulated to define how this pixel block should be shown on the screen (see BlockManipulation).

mode
: 1=3D and 2=VR

Returns how to draw the char (see enum Draw)
Tutorial
bool OnSprite(int mode, SpriteInfo& spriteInfo, BlockManipulation& spriteManipulation) This is called for every sprite on the screen (see 3D/VR tutorial).
spriteInfo has informations about this block (see "SpriteInfo"). The spriteManipulation structures can be manipulated to define how the sprites should be shown on the screen (see BlockManipulation).

mode
: 1=3D and 2=VR

Returns true, if the sprite should be dran.
Tutorials
void OnCharsFinished(int mode, WorldManipulation& worldManipulation) Called when all character or graphics blocks (see OnChar()) of a frame has been processed.
mode: 1=3D and 2=VR
The worldManipulation structure can be manipulated to apply an extra world transformation in a synchronous way.
Manipulating the view (e.g. with VR.SetScenePosition() in EndFrame()) will lead to jumping or flickering objects.
Note: Only OnCharsFinished or OnSpritesFinished should return a valid transformation per frame, otherwise the result is not predictable!
 
void OnSpritesFinished(int mode, WorldManipulation& worldManipulation) Called when allsprites (see OnSprite()) of a frame has been processed.
mode: 1=3D and 2=VR
The worldManipulation structure can be manipulated to apply an extra world transformation in a synchronous way.
Manipulating the view (e.g. with VR.SetScenePosition() in EndFrame()) will lead to jumping or flickering objects.
Note: Only OnCharsFinished or OnSpritesFinished should return a valid transformation per frame, otherwise the result is not predictable!
 
bool OnGetModel(int mode, int index, ModelDescription& modelDescription) This is called when a 3D model should be loaded, that is referenced in BlockManipulation.modelIndex to display a 3D model from a file (.obj wavefront). The index parameter is the modelIndex from the BlockManipulation.

The modelDescription has to filled with information about the model and the file (see ModelDescription).

mode
: 1=3D and 2=VR
Tutorial 08
grid<float>& OnGetDepthMap(int mode, int index, bool front) The index parameter is the depthMapIndex from the BlockManipulation.

The
front parameter gives the information, which for which side (front or back) the depth map is requested. This way it is possible to give a model another shape for the front and the back-side.
Note: When using different depth-maps for front and back-side, theses maps have to have the same size!

mode
: 1=3D and 2=VR
Tutorial 07
void OnTimer(int timerId) Is called when a timer is triggered (see SetTimer()). The timerId is the id given when creating the timer. Example

Global Functions

void SetTimer(int timerId, int frameCount, bool interval) Creates a timer with a self defined timerId, a frameCount when the OnTimer() funtion is called. Setting the interval to true will trigger the timer always each frameCount . Example
Tutorial 00
     

Objects

This are the following static objects, that are provided by YACE64:

APP

int Load(string fileName, int drive) Load all type of files YACE64 supports. When loading disc images (g64, d64) set the drive parameter to 8 or 9.
Loading any other files set, drive parameter to 0. With this function save-states (.yace), program-files (.prg), tape-file (.t64) and recordings (.yr) can be loaded.
Tutorial 00
void SendCbmKeys(array<CbmKeyState>&in cbmKeyStates) Send keyboard command. cbmKeyStates is an array of the CbmKeyState structure, which contains the CBM key code (see enum Keys) and a bool which indicates, if the key should be pressed (true) or released (false). Example
bool SendASCII(string asciiText) Send an ASCII text to the C64 keyboard. Returns false, if a previous SendCbmKeys() is not finished.
Use the C string style for special codes (e.g. CR=\n)
Example
bool IsSendASCIIDone() Returns true, if a previous SendCbmKeys() is finished.  
void SendMidi(int midiChannel, int midiStatus, int data1, int data2) Send a midi status to the SID (see MIDI implementation for the SID)  
string GetScriptPath() Returns the file-path of the currently executed script  
string GetLibraryPath() Returns the file-path of the library  
string GetDocumentPath() Returns the path of the YACE folder (typical <Drive>\User\YACE\)  
ViewMode ViewMode [get/set] Sets or return the current view-mode (see enum ViewMode)  
void SetPAL() Switch computer to PAL timing  
void SetNTSC() Switch computer to NTSC timing  
void Reset() Reset the computer and all floppy drives  
float Speed [get/set] Get or set the emulation speed factor (e.g. 1.0 is normal speed, 0.5 half speed, 2.0 double speed)
bool Audio3D [get/set] En- or disable the 3D sound Example
Tutorial 25
void SetAudioEmitter(AudioEmitter emitter, float x, float y, float z) Set the 3D position of the audio-source (emitter see enum AudioEmitter) to the x, y and z coordinate.
Note: Fast moving emitter will have a small doppler-effect.
Example
bool LoadAudio(AudioEmitter emitter, int buffer, string fileName) Loads a raw audio file for use with the given emitter (only the Aux1-Aux2 can be used).
For each emitter multiple file (buffer) can be loaded an played.
Audio has to be sampled with signed 16bit PCM and 44100 samples/s.
Tutorial 25
bool PlayAudio(AudioEmitter emitter, int buffer, bool loop) Start playing the audio-buffer of the given emitter. Set loop to true, to automatically repeat playing the buffer until StopAudio() is called.  
void StopAudio(AudioEmitter emitter) Stop playing audio of the given emitter.  
void SetJoystickPins(int port, JoystickContact up, JoystickContact down, JoystickContact left, JoystickContact right, JoystickContact fire) Change the routing of the joystick contacts for port 1 or 2.
Using this function the joystick can be rotated or mirrored, which is very usefull with the VR mode.
 
void ResetJoystickPins(int port) Set the routing of the joystick contacts to default for the given port 1 or 2.  
void SetJoystick(int port, Joystick joystick) Set which physical joystick to use with the given port 1 or 2.  
void SetJoystickContacts(int port, JoystickContact joystickContacts, bool set) This function closes or opens the joystick contacts of the given port 1 or 2. The joystickContacts can be binary "ored".
Joystick input can be simulated this way.
 
void ClearModels() Unloads all loaded 3D model from memory (see 3D tutorials).
Note: Unloading a script will not clear them!
 
void ClearDepthMaps() Unloads all loaded depth-maps from memory (see 3D tutorials).
Note: Unloading a script will not clear them!
 
void SetAmbientLight(float red, float green, float blue) Set the ambient light color of the 3D scene (see View-3D, View-VR and the 3D tutorials).
The value for the red, green and blue part are between 0.0 and 1.0.
 
void SetLightDir(float xVector, float yVector, float zVector) Set the light direct of the 3D scene as a vector (see View-3D, View-VR and the 3D tutorials).
Positiv xVector: Light from left to right
Positiv yVector: Light from bottom to top
Positiv zVector: Light from back to fore
Each vector-part is from 0.0 to 1.0
 
void SetColorMap(int mapIndex, array<array<float>> colors) Change a color map with the index mapIndex, which can be 1..15 (0 are the default VIC colors an can not be changed). The colors array should have the size 16 with 3 float each (red, green, blue from 0.0 to 1.0). Use BlockManipulation to change the color map for a char or sprite. Tutorial 15
ParticleEffect& CreateParticleEffect(int maxParticleCount, float minLifetime, float maxLifetime, bool repeat) Create a new particle effect which has maxParticleCount maximum particles at runtime. The minLifetime and maxLifetime is the time in milliseconds a particle is alive. When all particles lifetime is ended, the effect is disabled, when repeat is set to false. When repeat is set to true the particles are restartet. The effect can be restartet manually with the Restart() function. Tutorial 25
bool XZDefaultTranform [get] Set to true to set the default 3D transformation to the XZ-plane, instead of the XY-plane.
The character and sprites will then get a 90° rotation for the X-axis by default.
 
     

E3D

void SetSceneOrientation(float yaw, float pitch, float roll, float speed) yaw, pitch and roll in degree
void SetScenePosition(float x, float y, float z) x is left/right, y is up/down and z back/forth
void SetSceneScale(float x, float y, float z) x is horizontal, y is vertikel and z the depth

C64

void Pause(bool pauseState, string comment) The system is paused or continued
pauseState: true to pause, false to continue
comment: text, that is shown is logs
 
int PC  [get] Returns the current program counter address of the CPU  
int Read(int address) Reads and returns the content of the memory address as seen by the CPU  
void Write(int address, int value) Writes the value to the memory address as seen by the CPU  
int X  [get/set] Read/Writes the X register of the CPU  
int Y  [get/set] Read/Writes the Y register of the CPU  
int A  [get/set] Read/Writes the Accumulator of the CPU  
void LogInfo(string text) Logs an info text to the logging of the system in the global category  
void SetCondition(int conditionId, array<string> conditionExprArray, string dataString) Sets a condition for the C64
conditionId is the identifier for the condition
conditionExprArray an array of text conditions
dataString is a user text, that is provided in the OnCondition() callback
Example
Tutorial 08
void ClearCondition(int conditionId) Removes a condition
conditionId is the identifier for the condition
Example

D8, D9 (Discdrive 8 or 9)

void Pause(bool pauseState, string comment) The system is paused or continued
pauseState: true to pause, false to continue
comment: text, that is shown is logs
 
int PC  [get] Returns the current program counter address of the CPU  
int Read(int address) Reads and returns the content of the memory address as seen by the CPU  
void Write(int address, int value) Writes the value to the memory address as seen by the CPU  
int X  [get/set] Read/Writes the X register of the CPU  
int Y  [get/set] Read/Writes the Y register of the CPU  
int A  [get/set] Read/Writes the Accumulator of the CPU  
void LogInfo(string text) Logs an info text to the logging of the system in the global category  
void SetCondition(int conditionId, array<string> conditionExprArray, string dataString) Sets a condition for the disc drive
conditionId is the identifier for the condition
conditionExprArray an array of text conditions
dataString is a user text, that is provided in the OnCondition() callback
Example
Tutorial 08
void ClearCondition(int conditionId) Removes a condition
conditionId is the identifier for the condition
Example

GUI

void ShowInfoMessage(string text) Shows an information message on the screen
Example
void ShowErrorMessage(string text) Shows an error message on the screen  
void SetButtonTitle(int buttonId, string title) Sets the text of the user defined script buttons in the menu.
buttonId index of the button from 1 to 5. The buttonId is also given to the callback function OnUser()
Example

VIC

Int2 GetSpritePos(int spriteId) Returns the x,y position of the given sprite
spriteId: Index of the hardware sprite from 0 to 7
int Rasterline [get] Returns the current drawn rasterline
int Read(int address) Reads and returns the value of a VIC register (e.g. Read(53249) returns the sprite 0 y position)
void Write(int address, int value) Write a value to a VIC register (but using the memory address)

SID

int Read(int address) Read the value of a SID register (but using the memory address)  
void Write(int address, int value) Write a value to a SID register (but using the memory address)  
bool Mute[int oscillator]  [get/set] Mutes the given oscillator (0, 1 or 2) by setting this property to false,  
int POTX [get] Gets the current X potentiometer value of the joystick ports (SID register $19)  
int POTY [get] Gets the current Y potentiometer value of the joystick ports (SID register $1A)  
int OSC3 [get] Gets the current sample value of the third SID oscillator (SID register $1B)  
int ENV3 [get] Gets the current ADSR envelop value of the third SID oscillator (SID register $1C) Tutorial 08
bool OSC3Off [set] Disable the sound-output of the third SID oscilator by setting the property to trie (SID register $18, bit#7)  
SIDCtrl Control[int oscillator] [get/set] Get or set the control register of the oscillator (0, 1 or 2) using the SIDCtrl enum.  
int Freq[int oscillator] [set] Sets the frequence of the oscillator (0, 1 or 2) from 0 to 65535  
int Pulse[int oscillator] [set] Sets the pulse with of the oscillator (0, 1 or 2) from 0 to 4095 (2048=50%)  
int Volume [get/set] Set or get the volume of the SID from 0 to 15  
SIDMode Mode [set] Sets the filter mode of the SID (SIDMode)  
SIDFilter Filter [set] Sets the oscillators using the SID filter (SIDFilter)  
int Resonance [set] Sets the filter resonce from 0 to 15  
int Cutoff [set] Sets the filter cutoff frequency  from 0 to 2047  
int Attack[int oscillator] [set] Attack time from 0 to 15 for oscillator (0, 1 or 2)  
int Decay[int oscillator] [set] Decay time from 0 to 15 for oscillator (0, 1 or 2)  
int Sustain[int oscillator] [set] Volume level for the sustain phase from 0 to 15  
int Release[int oscillator] [set] Release time from 0 to 15 for oscillator (0, 1 or 2)  

VR

bool ShowComputer [get/set] Shows/hides the computer in the VR scene, set to true to show and false to hide
bool ShowRoom [get/set] Shows/hides the room in the VR scene, set to true to show and false to hide
void SetSpaceColor(r, g, b) Sets the ambient color of the VR scene
r, g, b are the floatingpoint  values for read, green and blue each from 0.0 to 1.0
Vector GetHMDPos() Gets the x, y, z coordinate of the headup device (values are in meter)
Vector GetHMDRot()  
Vector GetHMDDir()  
void SetSceneScale(x, y, z) Sets the x, y, z scaling of the 3D scene (default is each 1.0; y is vertical)
void SetScenePosition(x, y, z) Sets the x, y, z position of the 3D scene (default is each 0.0; y is vertical)
void SetSceneOrientation(yaw, pitch, roll, [speed]) Sets the yaw, pitch, roll (in degree) orientation of the 3D scene
optional the speed value can be given to define how fast the orientation will be reached; the values will be interpolated (value is stepvalue per second)
VRMode Mode [get/set] Set the view-mode of the 3D scene

ParticleEffect

void Restart() Restarts all particles, which lifetime is ended.
bool IsEnd [get] Returns true if all particle are ended.
bool Enable [set] En- or disable the effect-
void SetEmitterPosition(Vector position,Vector random) Sets the emitter to the 3D position, adding some random offset to it. e.g. Giving and x position of 0.5 and a random x value of 0.2, the particle emitted x position will randomly between 0.3 and 0.7.
void SetParticleDirection(Vector dir, Vector random, Vector gravity, Vector acc) Sets the particle direction with the vector dir. The length of the vector defines the speed of a particle. The random varies the direction vector with the offset. The gravity value defines the direction of the gravity and the acc value defines an acceleration.
Use the Vector methods SphericalRange() for easier vector and range calculation or see Tutorial 25.
void SetParticleColor(Vector color,Vector random, Vector acc) Sets the particle color (red, green, blue, alpha). The random value varies the color and the acc value accelerates the color (always per channel r, g, b or a). The values for each color channels can be between 0.0 and 1.0. The alpha channel is the opacity (0.0 invisible(full transparent), 1.0 full opaque).
void SetParticleSize(float size,float random ,float acc) The size of each particle (in world units (0.005 is the default VIC pixel size)). The size varies with the random value and can be accelerated (e.g. 0.995 the particles get smaller and 1.01 the particles get bigger).
void SetIntensity(float intensity) A value between 0.0 and 1.0, that defines how many particles are started at once.
void SetTextures(array<int> textures) Set up to four Particle textures to be used by the effect.  e.g. SetTextures({ Particle::CircleFilled, Particle::Star4, Particle::Star5Filled, Star6Filled });
void Delete() Delete the effect (should be done int OnUnload())
   

Types and enums

RotateZ(float deg)
enum ViewMode None Unknown state
  Edit3D Old 3D template editor view (deprecated!)
  Screen3D Old 3D view (deprecated!)
  Models2D Shows the C64, 1541 and Monitor with normal C64 screen
  Screen2D Shows only the normal C64 screen
  Diagnostic This is the VIC-Debugger
  Ext3D 3D transformed C64 screen view
     
struct CbmKeyState Keys key See enum Keys
  bool pressed true: press, false release the key
     
enum Keys F1, F3, F5, F7,
Restore,
LeftShift, RightShift, Commodore, Ctrl,
LeftArrow, UpArrow,
Del, Home, Return,
CrsrDown, CrsrRight,
Comma, Dot, Semicolon,
Space, Star, Pound, Stop,
DoublePoint, Slash,
Minus, Plus, Equal, At,
N0-N9, A-Z
The possible keys. (N0-N9 are the number keys)
     
enum AudioEmitter SID Soundoutput of the SID
  Keyboard Sound of the keyboard clicks
  Drive (Not supported yet)
  Aux1, Aux2, Aux3 See function LoadAudio() or PlayAudio()
     
enum JoystickContact Up, Down, Left, Right, Fire Using with the funtion SetJoystickContacts(), the values can be binary "ored"
     
enum Joystick None No joystick attached
  NumberBlock Use the number-block of the keyboard (1,2,3,4,6,7,8,9 for directions and 5 or 0 for fire)
  CursorBlock Use the cursor-block
  USB1, USB2, USB3 Use an USB port attached joystick (has to be a DirectInput device of type joystick)
     
struct CharInfo int x, y C64 x and y screen pixel coordinate
  int col, row C64 column and row of the character (0..39 and 0..24)
  int base Graphics address where the bitmap graphics for this character was read
  int backcolor Index of the VIC color for the background
  int forecolor Index of the VIC color for the foreground
     
struct SpriteInfo int index Index of the physical sprite (0-7)
  int x, y C64 screen coordinates of the sprite
  int width, height Size in pixel of the sprite (depends on the sprite extension flag)
  int base Memory address, where the graphics data for this sprite is located
  bool foreground This is the sprite priority (fore- or background)
  int color The dedicated sprite color
  int multicolor1, multicolor2 The two multi colors for the sprites
     
struct BlockManipulation float xScale, yScale, zScale Scaling to the x, y and z axis
  float xTranslation, yTranslation, zTranslation Translation alone the x, y and z axis
Rotation rotationAxis1, rotationAxis2, rotationAxis3 Define up to three rotations around the Rotation axis. Rotations are applied in the numbered order.
  float rotation1, rotation2, rotation3 Rotation angle (degree) around the axis defined with rotationAxis1, rotationAxis2 or rotationAxis3
  float ambient Proportion of the ambient color (0.0 only diffuse and reflective, 1.0 on ambient color)
  float reflective Proportion of the specular color (which is the ambient-light color)
  Voxel voxelMode Defines how the block will be transformed (see enum Voxel)
  int depthMapIndex Index to the depth map used to transform the depth of the graphics. 0 is the default flat depth.
Any other value calls the OnGetDepthMap() function to get the depth-map.
  int modelIndex Index to the 3D object model to use instead of transforming the graphics. Set to 0 if no model should be used. Any other value calls the OnGetModel() function to get the 3D model file.
  bool hide Set to true, when the block shouldn't be drawn.
  int colorMap Set the color map to use for the block or sprite. 0 are the default VIC colors. Use SetColorMap() to define own color maps.
     
struct WorldManipulation bool enable Set to true, to use the given transformations for the current frame
  float xScale, yScale, zScale Scaling to the x, y and z axis
  float xTranslation, yTranslation, zTranslation Translation alone the x, y and z axis
Rotation rotationAxis1, rotationAxis2, rotationAxis3 Define up to three rotations around the Rotation axis. Rotations are applied in the numbered order.
  float rotation1, rotation2, rotation3 Rotation angle (degree) around the axis defined with rotationAxis1, rotationAxis2 or rotationAxis3
     
enum Rotation None No rotation
  X,Y, Z Rotation around the X,Y or Z axis
     
struct ModelDescription string objFile Path and file name to the 3D model file (wavefront .obj)
  RenderSides renderSides Tell the renderer which sides should be drawn, some model have inconsistent triangle orientation (left/right hand), which makes needed to draw both sides. Normally the front-side is enough.
Note: For performance reasons only set the side which are really needed.
  float xOffset, yOffset, zOffset Optional set an offset to the models coordinates; for example you can move the zero-position to the middle (or a specific other psotion) of the model, which make is easier to rotate an position the 3D model in the scene.
enum RenderSides RenderSidesFront Render only the front-facing triangles of the 3D model
  RenderSidesBack Render only the back-facing triangles of the 3D model
  RenderSidesBoth Render front- and back-facing triangles of the 3D model
     
enum Draw DrawNothing Don't draw the char
  DrawBackground Only draw char background. See OnChar(), only the charManipulationBack BlockManipulation has to be filled, because the background is not drawn.
  DrawForeground Only draw char foreground. See OnChar(), only the charManipulationFore BlockManipulation has to be filled, because the foreground is not drawn.
  DrawBoth Draw char background and foreground separate. See OnChar(), both BlockManipulation (charManipulationBack and charManipulationFore) has to be filled, because each get their own manipulation.
  DrawCombined Draw char background and foreground combined. See OnChar(), only charManipulationFore is used and charManipulationBack is ignored.
     
class Vector x, y, z 3D coordinates
  Vector(float x, float y, float z) Constructor setting all coordinates
  Vector() Constructor setting all coordinates to zero
  RotateX(float deg) Rotate around x axis with the given angle deg in degree
  RotateY(float deg) Rotate around y axis with the given angle deg in degree
  Rotate around z axis with the given angle deg in degree
Normalize() Normalizes the direction
  float Length() Returns the length of the vector
  FromSpherical(float radius, float theta, float phi) Sets a with the spherical coordinates theta and phi. Set radius to 1.0 for a normal vector.
  Operators:  
  +Vector, -Vector, *Vector, /Vector  
  +=Vector, -=Vector, *=Vector, /=Vector  
  +float, -float, *float, /float  
  +=float, -=float, *=float, /=float  
  =Vector  
  =float  
  Vector SphericalRange(float radius, float phi, float theta, float radiusDelta, float phiDelta, float thetaDelta) Sets the vector direction to the given spherical coordinates in degree.
theta is the pitch (-90 is up, +90 is down, and 0 horizontal).
phi is the yaw (rotation around vertical axis).
radius the length of the resulting vector (the "speed").
The function returns the delta vector (e.g. to be used by the random value of SetParticleDirection())
The ...Delta parameters are the range (e.g. giving 45° to phi and 5° the phiDelta the variation is between 40° and 50°).
  Vector SetSpherical(float radius, float phi, float theta) Sets the vector direction to the given spherical coordinates in degree.
theta is the pitch (-90 is up, +90 is down, and 0 horizontal).
phi is the yaw (rotation around vertical axis).
radius the length of the resulting vector (the "speed").
Unlike the SphericalRange() function, it just returns a reference to its own vector.
     
enum Voxel HardEdge Draw hard edges and block-style surface
  SmoothEdge Draw smooth edges and block-style surface
  SmoothSurface Draw hard edges and smooth surface
  SmoothSurfaceEdge Draw smooth edges and smooth surface
     
enum VRMode Inactive VR is not active
  Screen Big screen
  Normal3D  
  Ext3D 3d scene
     
enum SIDCtrl GATE Oscillator active
  SYNC  
  RING Ringmodulation
  TEST  
  TRI Triangle waveform
  SAW Saw waveform
  PULSE Rectangle waveform
  NOISE Noise waveform
     
enum SIDFilter OSC1, OSC2, OSC3, EXT Bitmask which oscillator is routed through the audio filter
     
enum SIDMode LP, BP, HP SID filter mode (High, band and low-pass)
     
enum Particle CircleFilled, Circle Some predefined particle forms
  RectFilled, Rect  
  Star4  
  Star5Filled, Star5  
  Star6Filled, Star6  
  Cloud1, Cloud2, Cloud3  
  Frag1, Frag2, Frag3, Frag4  
     
     
     
     

Example etup"

const int startProgramTimerId = 1;

// Setting up the emulator with loading a program and initialising a complex 3D scene
void
OnLoad(bool reloaded)
{
    string scriptPath = APP.GetScriptPath(); // get the path, where this script is located

    APP.SetPAL(); // Set PAL timing for our "game"

    APP.ClearDepthMaps(); // Clear all loaded depth maps
    APP.ClearModels(); // Clear all loaded model

    // Set the view mode to the new 3D mode
    APP.ViewMode = ViewMode::Ext3D;

    // Set the ambient light color and brigtness of 3D mode
    APP.SetAmbientLight(0.3, 0.3, 0.3);

    // Set the direction of the light (from the middle off the scene (x), from top to bottom (y) and back to forth (z))
    APP.SetLightDir(0.0, -1.0, +1.0);

    // Position the 3D scene on the screen
    E3D.SetScenePosition(0.24, -0.35, -0.1);

    // Rotate the 3D scene a little bit
    E3D.SetSceneOrientation(-25.0, -15.0, 0.0, 0.0);

    if (!reloaded) // if this script is reloaded, we don't want to load the program again
    {
        // Load a program, that is located in the same path as the this script
        APP.Load(scriptPath + "Sprites.prg", 0);
        // Set a timer, that triggers the program to run
        SetTimer(startProgramTimerId, 120, false);
    }
}

void OnTimer(int timerId)
{
    if (timerId == startProgramTimerId)
    {
        APP.SendASCII("RUN\n");
    }
}

Example "Conditions"

void OnLoad(bool reloaded)
{
    // Will always call OnCondition(), when the rasterline 30 is reached
    C64.SetCondition(1, { "VIC.RL=30" }, "Rasterline 30"); // see breakpoint for a lot of possible conditions
}

void OnCondition(int device, int conditionId, string data)
{
    // Will show the message "OnCondition(1, Rasterline 30)" on the screen
    GUI.ShowInfoMessage("OnCondition(" + formatInt(conditionId) + ", " + data + ")");

    // Uncomment the following line, to clear the condition 1, when rasterline 30 has been reached the first time after SetCondition()
    //C64.ClearCondition(1);
}

Example "Buttons"

float audioEmitterX = 0.0

void OnLoad(bool reloaded)
{
    APP.Audio3D = true; // Enable 3D audio

    GUI.SetButtonTitle(1, "Audio +X");    // Name the button 1
    GUI.SetButtonTitle(2, "Audio -X");    // Name the button 2
}

void OnUser(int buttonIndex)
{
    if (buttonIndex == 1)
    {
        // Move SID audio position to the right
        audioEmitterX += 0.2f;
        APP.SetAudioEmitter(AudioEmitter::SID, audioEmitterX, 0.0, 0.5);
    }
    else if (buttonIndex == 2)
    {
        // Move SID audio position to the left
        audioEmitterX -= 0.2f;
        APP.SetAudioEmitter(AudioEmitter::SID, audioEmitterX, 0.0, 0.5);
    }
}


/*
function onCondition(conditionId, device, data) -- when a system triggered a condition then do:
    --rl = VIC.Rasterline
    x = C64:Read(0xbc01) + (C64:Read(0xbc02) * 256)    
-- read the player postion of a S.E.U.C.K game
    y = C64:Read(0xbc03)
    xd = (x - 150.0) / 120.0                           
-- do some calculations
    zd = (y / 55.0) - 3.5
    vert = -0.6 * (1.0-(y / 200.0))
    VR:SetScenePosition(xd + relCalibratedPosX, vert + relCalibratedPosY, zd + relCalibratedPosZ)
-- Set the 3D scene position (x, y, z in meter)
    VR:SetSceneOrientation(sceneYaw, scenePitch, sceneRoll, sceneSpeed)
-- Set the 3D scene orientation (yaw, pitch, roll in degree)
end

*/

Example "Keyboard and Timer"

const int runProgramTimerId = 1; // declare some identifiers for our timers
const int startProgramTimerId = 2;

void OnLoad(bool reloaded)
{
    // start a timer, that will send the "RUN" command after some time (e.g. to start a previous loaded game)
    SetTimer(runProgramTimerId , 125, false);   // start a timer, that will call OnTimer() after 125 frame (~2.5s)

    // start a second timmer that will later press a cursor- and the space key (e.g. to select or start something in the game menu)
    SetTimer(startProgramTimerId , 500, false); // start a timer, that will call OnTimer() after 500 frame (~10.0s)
}

void OnTimer(int timerId)
{
    if (timerId == runProgramTimerId)
    {
        APP.SendASCII("RUN\n");    // send a simple ASCII text to the keyboard (c-style strings)
    }
    else if (timerId == startProgramTimerId)
    {
        array<CbmKeyState> b(4); // declare four keyboard action

        b[0].key = Keys::CrsrDown; b[0].pressed = true;
        b[1].key = Keys::CrsrDown; b[1].pressed = false;

        b[2].key = Keys::Space; b[2].pressed = true;
        b[3].key = Keys::Space; b[3].pressed = false;

        APP.SendCbmKeys(b); // send more complex keyboard actions, which are not possible with SendASCII()
    }
}

Example "Joystick and Keyboard callback"

void OnKeyboard(bool pressed, Keys cbmKeyboard)
{
    if (cbmKeyboard == Keys::Space)
        GUI.ShowInfoMessage("OnKeyboard Space "+ (pressed ? "pressed": "released"));
    else
        GUI.ShowInfoMessage("OnKeyboard $" + formatInt(cbmKeyboard, "0H", 4) + " " + (pressed ? "pressed" : "released"));
}

void OnJoystick(int port, JoystickContact contactMask)
{
    if (contactMask == JoystickContact::Up)
        GUI.ShowInfoMessage(formatInt(port) + " OnJoystick Up");
    else
        GUI.ShowInfoMessage(formatInt(port) + " OnJoystick $" + formatInt(contactMask, "0H", 2));
}