109 lines
3.4 KiB
Java
109 lines
3.4 KiB
Java
package vue;
|
|
|
|
// Template for emulation core implementations
|
|
public abstract class VUE {
|
|
|
|
// Static fields
|
|
private static String nativeID = null; // ID of loaded native library
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
// Constants //
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
// Memory access types
|
|
public static final int S8 = 0;
|
|
public static final int U8 = 1;
|
|
public static final int S16 = 2;
|
|
public static final int U16 = 3;
|
|
public static final int S32 = 4;
|
|
|
|
// System register indexes
|
|
public static final int ADTRE = 25;
|
|
public static final int CHCW = 24;
|
|
public static final int ECR = 4;
|
|
public static final int EIPC = 0;
|
|
public static final int EIPSW = 1;
|
|
public static final int FEPC = 2;
|
|
public static final int FEPSW = 3;
|
|
public static final int PIR = 6;
|
|
public static final int PSW = 5;
|
|
public static final int TKCW = 7;
|
|
|
|
// Non-standard register indexes
|
|
public static final int PC = -1;
|
|
public static final int JUMP_FROM = -2;
|
|
public static final int JUMP_TO = -3;
|
|
|
|
// Program register indexes
|
|
public static final int GP = 4;
|
|
public static final int HP = 2;
|
|
public static final int LP = 31;
|
|
public static final int SP = 3;
|
|
public static final int TP = 5;
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
// Static Methods //
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
// Produce an emulation core context
|
|
public static VUE create(boolean useNative) {
|
|
return !useNative ? new JavaVUE() :
|
|
isNativeLoaded() ? new NativeVUE() : null;
|
|
}
|
|
|
|
// Retrieve the ID of the loaded native library, if any
|
|
public static String getNativeID() {
|
|
return nativeID;
|
|
}
|
|
|
|
// Determine whether the native module is loaded
|
|
public static boolean isNativeLoaded() {
|
|
return nativeID != null;
|
|
}
|
|
|
|
// Specify the ID of the loaded native library
|
|
public static void setNativeID(String nativeID) {
|
|
VUE.nativeID = nativeID;
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
// Public Methods //
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
// Release any used resources
|
|
public abstract void dispose();
|
|
|
|
// Retrieve a register value
|
|
public abstract int getRegister(int index, boolean system);
|
|
|
|
// Retrieve a copy of the ROM data
|
|
public abstract byte[] getROM();
|
|
|
|
// Determine whether the context is native-backed
|
|
public abstract boolean isNative();
|
|
|
|
// Read bytes from the CPU bus
|
|
public abstract boolean read(int address, byte[] dest, int offset,
|
|
int length);
|
|
|
|
// Initialize all system components
|
|
public abstract void reset();
|
|
|
|
// Specify a register value
|
|
public abstract int setRegister(int index, boolean system, int value);
|
|
|
|
// Provide new ROM data
|
|
public abstract boolean setROM(byte[] data, int offset, int length);
|
|
|
|
// Write bytes to the CPU bus
|
|
public abstract boolean write(int address, byte[] src, int offset,
|
|
int length);
|
|
|
|
}
|