using System;
using YACEAutomation;
public class Script : ScriptBase
{
//
// Called when the script is created
//
public Script()
{
}
//
// Called when the script was loaded
//
public override void onStart()
{
// Global.BreakCycle = Global.Cycle + 2000000;
}
//
// Called when the script will be unloaded
//
public override void onStop()
{
// C64.clearBreakpoint(0xEA81);
}
//
// Called when the debugger enters a break condition
//
// system: C64, Drive8, Drive9
// address: Current CPU opcode address
// rasterline: 0-311
// rasterCycle: 0-129 (half cycles)
// reason: Operation, MemoryRead, MemoryWrite, Rasterline, Frame, Cycle, User or Save
//
// To get more informations call the properties of C64, Drive8, Drive9 or Global object
//
public override void onBreak(string system, int address, int rasterline, int rasterCycle, string reason, string message)
{
//App.showMessage(MessageFormat.Info, MessageChoose.Ok, "Break",reason);
//Global.BreakCycle = Global.Cycle + 2000000;
}
// Called when a system info occured
// This callback delivers informations about diverse state e.g. like current track number of disc drive
// system: Name of the system, that triggered the breakpoint. (C64, 1541-8, 1541-9)
// infoType: Enumeration 'InfoType' with one of this values: Undefined,DriveTrack,DriveLED,DriveMotor,DiscModified,DiscChanged
// infoData: Value according to the 'infoType'. Can be int (e.g. track number or bool e.g. LED on or off)
public override void onInfo(string system, InfoType infoType, object infoData)
{
// App.showMessage(MessageFormat.Info, MessageChoose.Ok, ""Info"",string.Format(""{0}: {1} = {2}"", system, infoType, infoData));
}
//
// Called when a user button is pressed
//
// The buttonIndex is 0, 1 or 2.
//
public override void onButton(int buttonIndex)
{
// C64.createSnapshot("i:\\temp\\test.bmp");
// App.startCapture(30);
// App.showMessage(MessageFormat.Info, MessageChoose.Ok, "Note",string.Format("Button {0} pressed", buttonIndex));
}
//
// Called when a frame was rendered
//
public override void onFrameEnd()
{
}
//
// Return the names of the user buttons (maximum 3)
//
// Setting a name to null, hides the button.
//
public override string[] Buttons
{
get
{
return (new string[]{"Test1", "Test2"});
}
}
}
Callback | Short description | Description |
---|---|---|
onStart() | The script was loaded | |
onStop() | The script will be unloaded | |
onBreak() | Called when the debugger enters a break condition |
Possible conditions are: Operation-Breakpoint MemoryRead-Breakpoint MemoryWrite-Breakpoint Rasterline-Breakpoint Frame Cycle-Breakpoint User paused |
onInfo() | A system info occured | This callback delivers informations about diverse states e.g. like current track number of disc drive, LED, Motor, etc |
onFrameEnd() | A frame was rendered |
MessageResult showMessage(MessageFormat messageFormat, MessageChoose messageChoose, string caption, string message)
Shows a message box and lets the user select an action.
If another message box is still open, no other message box is shown. showmessage() returns messageresult.ignored in this case.
Parameter | Description |
---|---|
messageFormat : MessageFormat | Info, Warning, Error |
messageChoose : MessageChoose | Ok, OkCancel, YesNo |
caption : string | Title of the box |
message : string | Text of the box |
Returns : MessageResult | Ok, Cancel, Yes, No, None, Ignored |
if (App.showMessage(MessageFormat.Info, MessageChoose.Ok, "Title", "Hello")==MessageResult.Ok)
{
}
void startCapture(string filenameAndPath, int maxLengthSeconds)
Start capturing audio and video.
An AVI File will be created with a given filename. Depending on the installed codecs the video will be compressed.
xvid should be used for a fast and good compression. Only codecs that support
compression of 24 or 32 bit RGB images are supported.
Parameter | Description |
---|---|
filenameAndPath : string | Name of the filename and the path, file will always be overriden |
maxLengthSeconds : int | Automatic stop after given number of seconds |
App.startCapture("Screen.avi", 60);
void startCapture(int maxLengthSeconds)
Start capturing audio and video.
AVI File will be created in the "Documents\YACE" folder. Depending on the installed codecs the video will be compressed.
xvid should be used for a fast and good compression. Only codecs that support
compression of 24 or 32 bit RGB images are supported.
Parameter | Description |
---|---|
maxLengthSeconds : int | Automatic stop after given number of seconds |
App.startCapture(60);
void stopCapture()
Stop capturing audio and video.
Parameter | Description |
---|
App.stopCapture();
void unloadScript()
Unload the current script.
Script will stop as soon as possible and onStop() will be called.
Parameter | Description |
---|
App.unloadScript();
void loadScriptCS(string fileNameAndPath)
Load a new C# script.
Current script will stop as soon as possible and onStop() will be called before loading the new script.
Parameter | Description |
---|---|
fileNameAndPath : string | Filename and path |
App.loadScriptCS("test.cs");
void loadScriptVB(string fileNameAndPath)
Load a new Visual Basic script.
Current script will stop as soon as possible and onStop() will be called before loading the new script.
Parameter | Description |
---|---|
fileNameAndPath : string | Filename and path |
App.loadScriptVB("test.vb");
void saveState(string fileNameAndPath)
Save the current state.
Parameter | Description |
---|---|
fileNameAndPath : string | Filename and path |
App.saveState("test.yace");
void loadState(string fileNameAndPath)
Load a saved state.
Parameter | Description |
---|---|
fileNameAndPath : string | Filename and path |
App.loadState("test.yace");
void load(string fileNameAndPath)
Loads a disc image or program file.
Program (.prg, .t64) files are loaded directly into memory. Disc images (.g64, .d64) are loaded into the selected drive.
Note: Changes on the current disc are lost, if the disc isn't saved before.
Parameter | Description |
---|---|
fileNameAndPath : string | Filename and path |
App.load("demo.g64");
// or
App.load("demo.prg");
void searchAndLoad(string fileName)
Loads a disc image or program file.
Program (.prg, .t64) files are loaded directly into memory. Disc images (.g64, .d64) are loaded into the selected drive.
Parameter | Description |
---|---|
fileName : string | Filename to be searched in Diskimage folder (see configuration). |
Returns : bool | true if the file was found. |
if (App.searchAndLoad("demo.g64"))
{
}
int SelectedDrive
Gets or sets the selected disc drive.
Load operations will be done on the selected drive.
Parameter | Description |
---|---|
get : int | Device ID, must be 8 or 9. |
set : int | Device ID, must be 8 or 9. |
App.SelectedDrive = 8;
int InputPort1
Gets or sets the selected input device for port 1.
The only wellknow device is the keyboard, all others may not be available on other configurations.
Parameter | Description |
---|---|
get : int | 0 = No device; 1 = Keyboard; 2...n = optional devices. |
set : int | 0 = No device; 1 = Keyboard; 2...n = optional devices. |
App.InputPort1 = 1;
int InputPort2
Gets or sets the selected input device for port 2.
The only wellknow device is the keyboard, all others may not be available on other configurations.
Parameter | Description |
---|---|
get : int | 0 = No device; 1 = Keyboard; 2...n = optional devices. |
set : int | 0 = No device; 1 = Keyboard; 2...n = optional devices. |
App.InputPort2 = 0;
bool NTSC
Set NTSC timing.
Switching the timing can cause undesired effects on a running emulation!
Parameter | Description |
---|---|
get : bool | true = NTSC, false = PAL |
set : bool | true = NTSC, false = PAL |
Global.NTSC = true;
Speed Speed
Sets the emulators speed.
Parameter | Description |
---|---|
get : Speed | Normal, Maximum, Half, Quarter, Tens |
set : Speed | Normal, Maximum, Half, Quarter, Tens |
Global.Speed = Speed.Normal;
uint Cycle
Current cycle time index (full cycle)
Parameter | Description |
---|---|
get : uint | 1/1000000s since start (depending on PAL or NTSC) |
if (Global.Cycle > 10000000) // about 10s after start
{
}
uint BreakCycle
Sets a breakpoint for a specific cycle time index.
One cycle is about 1 micro second (depending on PAL or NTSC).
The emulator will pause when this time is reaches and onBreak() will be called.
Parameter | Description |
---|---|
get : uint | 1/1000000s since start (depending on PAL or NTSC) |
set : uint | 1/1000000s since start (depending on PAL or NTSC) |
Global.BreakCycle = Global.Cycle + 1000000; // Break every ~1s
string[] getTraceModules()
Get the available trace module names.
Parameter | Description |
---|---|
Returns : string[] | String array of the names |
string[] modules = C64.getTraceModules(); // also Drive8 or Drive9
bool setTraceLevelDebug(string moduleName)
Sets the 'Debug' level for the given module.
This is the highest level and degrades the performance.
Parameter | Description |
---|---|
moduleName : string | Name of the module (see getTraceModules()) |
Returns : true | true, if level was set |
C64.setTraceLevelDebug("SID"));
bool setTraceLevelError(string moduleName)
Sets the 'Error' level for the given module.
Parameter | Description |
---|---|
moduleName : string | Name of the module (see getTraceModules()) |
Returns : true | true, if level was set |
C64.setTraceLevelError("CPU"));
bool setTraceLevelWarning(string moduleName)
Sets the 'Warning' level for the given module.
Parameter | Description |
---|---|
moduleName : string | Name of the module (see getTraceModules()) |
Returns : true | true, if level was set |
C64.setTraceLevelWarning("CPU"));
bool setTraceLevelInfo(string moduleName)
Sets the 'Information' level for the given module.
Parameter | Description |
---|---|
moduleName : string | Name of the module (see getTraceModules()) |
Returns : true | true, if level was set |
C64.setTraceLevelInfo("CPU"));
bool setTraceLevelVerbose(string moduleName)
Sets the 'Verbose' level for the given module.
Parameter | Description |
---|---|
moduleName : string | Name of the module (see getTraceModules()) |
Returns : true | true, if level was set |
C64.setTraceLevelVerbose("CPU"));
int RegisterPC
Get the programcounter.
Parameter | Description |
---|---|
get : int | Current programcounter 0-65535 |
int address = Drive8.RegisterPC;
byte RegisterSP
Get the stackpointer.
Parameter | Description |
---|---|
get : byte | Current stackpointer 0-255 |
byte stackPointer = Drive8.RegisterSP;
byte RegisterA
Get the accumulator.
Parameter | Description |
---|---|
get : byte | Current accumulator 0-255 |
byte accu = C64.RegisterA;
byte RegisterX
Get the index X register.
Parameter | Description |
---|---|
get : byte | Current index X register 0-255 |
byte accu = C64.RegisterX;
byte RegisterY
Get the index Y register.
Parameter | Description |
---|---|
get : byte | Current index Y register 0-255 |
byte accu = C64.RegisterY;
bool FlagZ
Get the Zero flag.
Parameter | Description |
---|---|
get : bool | true, Zero flag is set |
bool isZero = C64.FlagZ;
bool FlagN
Get the Negative flag.
Parameter | Description |
---|---|
get : bool | true, Negative flag is set |
bool isNegative = C64.FlagN;
bool FlagV
Get the oVerflow flag.
Parameter | Description |
---|---|
get : bool | true, oVerflow flag is set |
bool isOverflow = C64.FlagV;
bool FlagI
Get the Interrupt flag.
Parameter | Description |
---|---|
get : bool | true, Interrupt flag is set |
bool isInterruptBlocked = C64.FlagI;
bool FlagD
Get the Decimal flag.
Parameter | Description |
---|---|
get : bool | true, Decimal flag is set |
bool isDecimalMode = C64.FlagD;
bool FlagC
Get the Carry flag.
Parameter | Description |
---|---|
get : bool | true, Carry flag is set |
bool isCarry = C64.FlagC;
bool FlagB
Get the Break flag.
Parameter | Description |
---|---|
get : bool | true, Break flag is set |
bool isBreak = C64.FlagB;
void setBreakpoint(int address)
Sets a breakpoint at a specified address.
Parameter | Description |
---|---|
address : int | 0-65535 |
C64.setBreakpoint(0xEA81);
void clearBreakpoint(int address)
Clears a breakpoint at a specified address.
Parameter | Description |
---|---|
address : int | 0-65535 |
C64.clearBreakpoint(0xEA81);
bool getBreakpoint(int address)
Check if a breakpoint is set at the specified address.
Parameter | Description |
---|---|
address : int | 0-65535 |
Returns : bool | true, if a breakpoint is set |
bool isBreakpointSet = C64.getBreakpoint(0xEA81);
void setOperationAddressName(int address, string name)
Sets a name for an address.
Note: There are several names already set, espacially for the Kernal ROM routines.
Parameter | Description |
---|---|
address : int | 0-65535 |
name : string | Name that will be logged in a trace and a disassembly, when the CPU operates on the address |
C64.setOperationAddressName(0xEA81, "IRQ");
string getOperationAddressName(int address)
Sets a name for an address.
Parameter | Description |
---|---|
address : int | 0-65535 |
Returns : string | Name of the address |
string name = C64.getOperationAddressName(0xEA81);
void setOperationAddressComment(int address, string comment)
Sets a comment for an address.
Parameter | Description |
---|---|
address : int | 0-65535 |
comment : string | Comment that will be logged in a trace and a disassembly, when the address is accessed |
C64.setOperationAddressComment(0xEA81, "IRQ Routine");
string getOperationAddressComment(int address)
Sets a comment for an address.
Parameter | Description |
---|---|
address : int | 0-65535 |
Returns : string | Comment of the address |
string comment = C64.getOperationAddressComment(0xEA81);
byte readMemory(int address)
Reads the content of the memory or device.
The byte is read from the memory according to the current memory configuration.
This means that the functions reads the memory as if the CPU would read it from the bus.
Parameter | Description |
---|---|
address : int | 0-65535 |
Returns : byte | Databyte 0-255 |
byte data = C64.readMemory(0x0000);
void writeMemory(int address, byte value)
Writes a byte to the memory or device.
The byte is written into memory according to the current memory configuration.
This means that the functions writes the memory as if the CPU would write it to the bus.
Parameter | Description |
---|---|
address : int | 0-65535 |
value : byte | Databyte 0-255 |
C64.writeMemory(0x0000, 0x00);
void setMemoryReadBreakpoint(int address)
Sets a breakpoint for a read operation to the data bus.
Parameter | Description |
---|---|
address : int | 0-65535 |
C64.setMemoryReadBreakpoint(0x0000);
void clearMemoryReadBreakpoint(int address)
Clears a breakpoint for a read operation to the data bus.
Parameter | Description |
---|---|
address : int | 0-65535 |
C64.clearMemoryReadBreakpoint(0x0000);
bool getMemoryReadBreakpoint(int address)
Checks if a breakpoint is set for a read operation to the data bus.
Parameter | Description |
---|---|
address : int | 0-65535 |
returns : bool | true, if a breakpoint is set |
bool breakpointSet = C64.getMemoryReadBreakpoint(0x0000);
void setMemoryWriteBreakpoint(int address)
Sets a breakpoint for a write operation to the data bus.
Parameter | Description |
---|---|
address : int | 0-65535 |
C64.setMemoryWriteBreakpoint(0x0000);
void clearMemoryWriteBreakpoint(int address)
Clears a breakpoint for a write operation to the data bus.
Parameter | Description |
---|---|
address : int | 0-65535 |
C64.clearMemoryWriteBreakpoint(0x0000);
bool getMemoryWriteBreakpoint(int address)
Checks if a breakpoint is set for a write operation to the data bus.
Parameter | Description |
---|---|
address : int | 0-65535 |
returns : bool | true, if a breakpoint is set |
bool breakpointSet = C64.getMemoryWriteBreakpoint(0x0000);
void reset()
Trigger a reset.
Parameter | Description |
---|
C64.reset();
void step()
Performs a single assembler step, when a breakpoint was reached.
Parameter | Description |
---|
C64.step();
void run()
Continues running, when a breakpoint was reached.
Parameter | Description |
---|
C64.run();
void pause()
Stops running, like when a breakpoint was reached.
Parameter | Description |
---|
C64.pause();
bool Paused
Checks, if the system is currently paused (a breakpoint was reached).
Parameter | Description |
---|---|
returns : bool | true, if system is paused |
bool isPaused = C64.Paused;
void sendText(string asciiText)
Send simulated keystrokes to the keyboard.
Parameter | Description |
---|---|
asciiText : string | ASCII Text |
C64.sendText("LOAD""*"",8,1\n");
void setKeyboard(uint code)
Pushes key down.
Parameter | Description |
---|---|
code : uint | Keyboardcode |
C64.setKeyboard(0x4002); // E
void releaseKeyboard(uint code)
Releases key up.
Parameter | Description |
---|---|
code : uint | Keyboardcode |
C64.releaseKeyboard(0x4002); // E
void setJoystick(JoystickPort port, JoystickContact joystick)
Set Joystick contacts.
Parameter | Description |
---|---|
port : JoystickPort | Port1, Port2 |
joystick : JoystickContact (Flags) |
JoystickLeft, JoystickRight, JoystickUp, JoystickDown, JoystickFire |
C64.setJoystick(JoystickPort.Port1, JoystickContact.JoystickLeft|JoystickContact.JoystickRight);
void releaseJoystick(JoystickPort port, JoystickContact joystick)
Release Joystick contacts.
Parameter | Description |
---|---|
port : JoystickPort | Port1, Port2 |
joystick : JoystickContact (Flags) |
JoystickLeft, JoystickRight, JoystickUp, JoystickDown, JoystickFire |
C64.releaseJoystick(JoystickPort.Port1, JoystickContact.JoystickLeft|JoystickContact.JoystickRight);
void enableScreenTrace()
Enable VIC debugger.
System will stop after every frame.
Parameter | Description |
---|
C64.enableScreenTrace();
void disableScreenTrace()
Disable VIC debugger.
System will stop after every frame.
Parameter | Description |
---|
C64.disableScreenTrace();
void setRasterlineBreakpoint(int rasterline)
Set a breakpoint for a specific rasterline.
Parameter | Description |
---|---|
rasterline : int | Rasterline number 0-311 |
C64.setRasterlineBreakpoint(50);
void clearRasterlineBreakpoint(int rasterline)
Clears a breakpoint for a specific rasterline.
Parameter | Description |
---|---|
rasterline : int | Rasterline number 0-311 |
C64.clearRasterlineBreakpoint(50);
void setREU(int sizeKB)
Installs a REU (RAM Expansion Unit) with the given size.
Installing or removing a REU can corrupt a running emulation!
Parameter | Description |
---|---|
sizeKB : int | Size in KBytes (0,64,128,256,512). 0 removes the REU |
C64.setREU(128);
void createSnapshot(string filenameAndPath)
Creates a snapshot as bitmap file.
Parameter | Description |
---|---|
filenameAndPath : string | Name of the filename and the path, file will always be overriden |
C64.createSnapshot("Screen.bmp");
void Eject()
Removes the disc from the drive.
Note: Changes on the disc are lost, if the disc isn't saved before.
Parameter | Description |
---|
Drive8.Eject();
void Empty()
Inserts an empty (unformatted) disc into drive.
Note: Changes on the disc are lost, if the disc isn't saved before.
Parameter | Description |
---|
Drive8.Empty();
string DiscFile
Gets the filename of the currently inserted disc file.
Parameter | Description |
---|---|
Returns : string | Name and path of the disc file |
string discFile = Drive8.DiscFile;
void powerOff()
Turns the drive off.
Parameter | Description |
---|
Drive8.powerOff();
void powerOn()
Turns the drive on.
Parameter | Description |
---|
Drive8.powerOn();
bool WriteProtection
Sets or clears the write protection of the disc.
Parameter | Description |
---|---|
set : bool | true, to turn write protection on |
Drive8.WriteProtection = true;
void saveDisc(string g64FileNameAndPath)
Saves the current disc to a G64 file.
Parameter | Description |
---|---|
g64FileNameAndPath : string | Name of the filename and the path, file will always be overriden |
Drive8.saveDisc("MyDisc");