Using Emulators

1. Starting Emulators from jGameBase

There are three ways to start an emulator.

1.1 Start executable directly

This is the simplest method of starting an emulator. While defining the emulator (Menu "Emulators") specify the executable of the emulator in the field "Command to execute". This command will be executed with the "fileToRun" as parameter.

1.2 Start via JavaScript

This is the preferred method of starting an emulator. The script has to have the file extension ".sh" and has to reside in the databases "Scripts" directory. The first command line parameter passed to the script is the "fileToRun", but there are many JavaScript variables set. Your script will be prefixed by an include ("Includes/includes.sh)) containing some predefined functions that simplify writing an emulator script.

If you write scripts please send them to me so I can include them in the next version of jGameBase

Example script:
This script starts the emulator executable "c64" after checking that the file type (extension) is supported and changing the configuration file to use the correct joystick port:

//  PLEASE SET YOUR EMULATOR PROPERTIES AS FOLLOWS:
//  Emulator File: c64.js
//  Emulator configuration file: c64.cfg
//  File Types: "d64;t64"

command = "c64";
Add_CLP(command);

// check the file types
if (itemType.contains("d64", "t64")) {

	// set the item controls
	if (itemControl === JOYPORT1) {
		// set joystick 1 ("input=1" in the config file)
		Set_CFG_Value(emulatorConfigFile, "input", "1");
	} else {
		// set joystick 2
		Set_CFG_Value(emulatorConfigFile, "input", "2");
	}

	// run the emulator
	Run_Emulator();
} else {
	// invalid item file type
	Show_Message(NOT_SUPPORTED + "\n\nSupported types: D64, T64");
}

1.2.1 Reference of predefined variables, objects and methods

As mentioned above there are predefined variables, objects and methods to simplify writing JavaScript scripts. Please click here for the complete reference.

As JavaScript can be difficult to debug, you best start by modifying an existing script.
If you encounter problems check the jgamebase.log in the database directory.

1.3 Start via other script

If no registered script engine for the script file extension is found in Java the script is started directly. This makes it possible to start scripts written in other scripting languages (e.g. BASH, Python, Lua or Ruby). The downside is that these scripts are often not as platform independent as JavaScript. The first command line parameter passed to the script is the "fileToRun", the environment variables set are the same as for JavaScript scripts, but there are no predefined includes.

 
Home   |   Mail Webmaster rated four out of five stars (silver rating) on 'The Linux Game Tome' Get jGameBase - Universal Emulator Frontend at SourceForge.net. Fast, secure and Free Open Source software downloads
Page last updated: 15. November 2022.