Further housekeeping

This commit is contained in:
Guy Perfect 2020-10-05 08:10:14 -05:00
parent 81840f71d2
commit f893ecd2cf
7 changed files with 61 additions and 143 deletions

View File

@ -103,7 +103,7 @@ clean_desktop:
# Delete everything but the .jar # Delete everything but the .jar
.PHONY: clean_most .PHONY: clean_most
clean_most: clean_desktop clean_most: clean_desktop
@rm -f src/desktop/vue/vue_NativeVUE.h native/*.dll native/*.so @rm -f src/desktop/vue/vue_NativeVue.h native/*.dll native/*.so
@ -112,14 +112,14 @@ clean_most: clean_desktop
############################################################################### ###############################################################################
# JNI header file # JNI header file
src/desktop/vue/vue_NativeVUE.h: src/desktop/vue/NativeVUE.java src/desktop/vue/vue_NativeVue.h: src/desktop/vue/NativeVue.java
@javac -h src/desktop/vue -sourcepath src/desktop -d . \ @javac -h src/desktop/vue -sourcepath src/desktop -d . \
src/desktop/vue/NativeVUE.java src/desktop/vue/NativeVue.java
@sleep 3 @sleep 3
# linux_x86 # linux_x86
.PHONY: lin32_pre .PHONY: lin32_pre
lin32_pre: src/desktop/vue/vue_NativeVUE.h lin32_pre: src/desktop/vue/vue_NativeVue.h
$(eval name = linux_x86) $(eval name = linux_x86)
$(eval prefix = `uname -m`-linux-gnu-) $(eval prefix = `uname -m`-linux-gnu-)
$(eval include = -I$(include_linux) -I$(include_linux)/linux) $(eval include = -I$(include_linux) -I$(include_linux)/linux)
@ -130,7 +130,7 @@ lin32: lin32_pre native_common
# linux_x86-64 # linux_x86-64
.PHONY: lin64_pre .PHONY: lin64_pre
lin64_pre: src/desktop/vue/vue_NativeVUE.h lin64_pre: src/desktop/vue/vue_NativeVue.h
$(eval name = linux_x86-64) $(eval name = linux_x86-64)
$(eval prefix = `uname -m`-linux-gnu-) $(eval prefix = `uname -m`-linux-gnu-)
$(eval include = -I$(include_linux) -I$(include_linux)/linux) $(eval include = -I$(include_linux) -I$(include_linux)/linux)
@ -141,7 +141,7 @@ lin64: lin64_pre native_common
# windows_x86 # windows_x86
.PHONY: win32_pre .PHONY: win32_pre
win32_pre: src/desktop/vue/vue_NativeVUE.h win32_pre: src/desktop/vue/vue_NativeVue.h
$(eval name = windows_x86) $(eval name = windows_x86)
$(eval prefix = i686-w64-mingw32-) $(eval prefix = i686-w64-mingw32-)
$(eval include = -I$(include_windows) -I$(include_windows)/win32) $(eval include = -I$(include_windows) -I$(include_windows)/win32)
@ -151,7 +151,7 @@ win32: win32_pre native_common
# windows_x86-64 # windows_x86-64
.PHONY: win64_pre .PHONY: win64_pre
win64_pre: src/desktop/vue/vue_NativeVUE.h win64_pre: src/desktop/vue/vue_NativeVue.h
$(eval name = windows_x86-64) $(eval name = windows_x86-64)
$(eval prefix = x86_64-w64-mingw32-) $(eval prefix = x86_64-w64-mingw32-)
$(eval include = -I$(include_windows) -I$(include_windows)/win32) $(eval include = -I$(include_windows) -I$(include_windows)/win32)
@ -165,4 +165,4 @@ native_common:
@echo " Building native module $(name)" @echo " Building native module $(name)"
@$(prefix)gcc $(include) -Isrc/core/include $(gccargs) -s -shared -O2 \ @$(prefix)gcc $(include) -Isrc/core/include $(gccargs) -s -shared -O2 \
-fno-strict-aliasing -fPIC -Werror \ -fno-strict-aliasing -fPIC -Werror \
-o native/$(name)$(ext) src/desktop/vue/NativeVUE.c src/core/vue.c -o native/$(name)$(ext) src/desktop/vue/NativeVue.c src/core/vue.c

View File

@ -303,7 +303,7 @@ static int32_t evalSubtract(
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// Evaluate address // Evaluate address
static int32_t evalAddress(VUE *vue) { static int32_t evalAddress(Vue *vue) {
if (vue->cpu.inst.format == 6) if (vue->cpu.inst.format == 6)
return vue->cpu.program[vue->cpu.inst.reg1] + vue->cpu.inst.disp; return vue->cpu.program[vue->cpu.inst.reg1] + vue->cpu.inst.disp;
switch (vue->cpu.inst.id) { switch (vue->cpu.inst.id) {
@ -318,7 +318,7 @@ static int32_t evalAddress(VUE *vue) {
} }
// Evaluate cond // Evaluate cond
static int32_t evalCond(VUE *vue) { static int32_t evalCond(Vue *vue) {
switch (vue->cpu.inst.id) { switch (vue->cpu.inst.id) {
case VUE_BCOND: return vue->cpu.inst.cond; case VUE_BCOND: return vue->cpu.inst.cond;
case VUE_SETF : return vue->cpu.inst.imm; case VUE_SETF : return vue->cpu.inst.imm;
@ -327,7 +327,7 @@ static int32_t evalCond(VUE *vue) {
} }
// Evaluate disp // Evaluate disp
static int32_t evalDisp(VUE *vue) { static int32_t evalDisp(Vue *vue) {
switch (vue->cpu.inst.format) { switch (vue->cpu.inst.format) {
case 3: case 4: case 6: return vue->cpu.inst.disp; case 3: case 4: case 6: return vue->cpu.inst.disp;
} }
@ -335,7 +335,7 @@ static int32_t evalDisp(VUE *vue) {
} }
// Evaluate imm // Evaluate imm
static int32_t evalImm(VUE *vue) { static int32_t evalImm(Vue *vue) {
switch (vue->cpu.inst.format) { switch (vue->cpu.inst.format) {
case 2: case 5: return vue->cpu.inst.imm; case 2: case 5: return vue->cpu.inst.imm;
} }
@ -343,7 +343,7 @@ static int32_t evalImm(VUE *vue) {
} }
// Evaluate reg1 // Evaluate reg1
static int32_t evalReg1(VUE *vue) { static int32_t evalReg1(Vue *vue) {
switch (vue->cpu.inst.format) { switch (vue->cpu.inst.format) {
case 1: case 5: case 6: case 7: return vue->cpu.inst.reg1; case 1: case 5: case 6: case 7: return vue->cpu.inst.reg1;
} }
@ -351,7 +351,7 @@ static int32_t evalReg1(VUE *vue) {
} }
// Evaluate reg2 // Evaluate reg2
static int32_t evalReg2(VUE *vue) { static int32_t evalReg2(Vue *vue) {
switch (vue->cpu.inst.format) { switch (vue->cpu.inst.format) {
case 1: case 2: case 5: case 6: case 7: return vue->cpu.inst.reg2; case 1: case 2: case 5: case 6: case 7: return vue->cpu.inst.reg2;
} }
@ -359,7 +359,7 @@ static int32_t evalReg2(VUE *vue) {
} }
// Evaluate regid // Evaluate regid
static int32_t evalRegId(VUE *vue) { static int32_t evalRegId(Vue *vue) {
switch (vue->cpu.inst.id) { switch (vue->cpu.inst.id) {
case VUE_LDSR: case VUE_STSR: return vue->cpu.inst.imm; case VUE_LDSR: case VUE_STSR: return vue->cpu.inst.imm;
} }
@ -367,7 +367,7 @@ static int32_t evalRegId(VUE *vue) {
} }
// Evaluate subopcode // Evaluate subopcode
static int32_t evalSubopcode(VUE *vue) { static int32_t evalSubopcode(Vue *vue) {
switch (vue->cpu.inst.opcode) { switch (vue->cpu.inst.opcode) {
case 0x1F: return vue->cpu.inst.imm; case 0x1F: return vue->cpu.inst.imm;
case 0x3E: return vue->cpu.inst.subopcode; case 0x3E: return vue->cpu.inst.subopcode;
@ -376,12 +376,12 @@ static int32_t evalSubopcode(VUE *vue) {
} }
// Evaluate value // Evaluate value
static int evalValue(VUE *vue) { static int evalValue(Vue *vue) {
return vue->cpu.inst.format == 6 ? vue->cpu.access.value : 0; return vue->cpu.inst.format == 6 ? vue->cpu.access.value : 0;
} }
// Evaluate vector // Evaluate vector
static int evalVector(VUE *vue) { static int evalVector(Vue *vue) {
return vue->cpu.inst.id == VUE_TRAP ? vue->cpu.inst.imm : 0; return vue->cpu.inst.id == VUE_TRAP ? vue->cpu.inst.imm : 0;
} }
@ -422,7 +422,7 @@ static int32_t evalFloor(int32_t isWord, int32_t value) {
} }
// Evaluate [] // Evaluate []
static int32_t evalReadWord(int32_t isWord, int32_t value, VUE *vue) { static int32_t evalReadWord(int32_t isWord, int32_t value, Vue *vue) {
return vueRead(vue, isWord ? value : toWord(asFloat(value)), VUE_S32); return vueRead(vue, isWord ? value : toWord(asFloat(value)), VUE_S32);
} }
@ -548,7 +548,7 @@ static int32_t evalBinary(int32_t id, int32_t *stack, int32_t size) {
} }
// Evaluate a functional symbol // Evaluate a functional symbol
static int32_t evalSymbol(VUE *vue, int32_t id, int32_t *stack, int32_t size) { static int32_t evalSymbol(Vue *vue, int32_t id, int32_t *stack, int32_t size) {
int32_t ret = 0; int32_t ret = 0;
if (id == VUE_PC) if (id == VUE_PC)
ret = vue->cpu.pc; ret = vue->cpu.pc;
@ -580,7 +580,7 @@ static int32_t evalSymbol(VUE *vue, int32_t id, int32_t *stack, int32_t size) {
} }
// Evaluate a unary operator // Evaluate a unary operator
static void evalUnary(VUE *vue, int32_t id, int32_t *stack, int32_t size) { static void evalUnary(Vue *vue, int32_t id, int32_t *stack, int32_t size) {
int32_t type = stack[size - 2]; int32_t type = stack[size - 2];
int32_t value = stack[size - 1]; int32_t value = stack[size - 1];
int32_t isWord = type == WORD; int32_t isWord = type == WORD;
@ -609,7 +609,7 @@ static void evalUnary(VUE *vue, int32_t id, int32_t *stack, int32_t size) {
} }
// Evaluate a breakpoint condition for an emulation context // Evaluate a breakpoint condition for an emulation context
int32_t evaluate(VUE *vue, Breakpoint *brk, int32_t *stack) { int32_t evaluate(Vue *vue, Breakpoint *brk, int32_t *stack) {
// The condition is empty // The condition is empty
if (brk->numCondition == 0) if (brk->numCondition == 0)
@ -618,7 +618,7 @@ int32_t evaluate(VUE *vue, Breakpoint *brk, int32_t *stack) {
// Process tokens // Process tokens
int size = 0; int size = 0;
for (int x = 0; x < brk->numCondition; x++) { for (int x = 0; x < brk->numCondition; x++) {
TOKEN *tok = &brk->condition[x]; Token *tok = &brk->condition[x];
switch (tok->type) { switch (tok->type) {
case BINARY: size = case BINARY: size =
evalBinary( tok->value, stack, size); continue; evalBinary( tok->value, stack, size); continue;

View File

@ -273,11 +273,9 @@ this.cycles = 0; // DEBUG: Stop processing after execute
private boolean exception() { private boolean exception() {
// Application callback // Application callback
if (vue.onException != null) { vue.breakCode = vue.onException(exception);
vue.breakCode = vue.onException.call(vue, exception);
if (vue.breakCode != 0) if (vue.breakCode != 0)
return true; return true;
}
// Configure working variables // Configure working variables
exception.code &= 0xFFFF; exception.code &= 0xFFFF;
@ -333,11 +331,9 @@ this.cycles = 0; // DEBUG: Stop processing after execute
private boolean execute() { private boolean execute() {
// Application callback // Application callback
if (vue.onExecute != null) { vue.breakCode = vue.onExecute(inst);
vue.breakCode = vue.onExecute.call(vue, inst);
if (vue.breakCode != 0) if (vue.breakCode != 0)
return true; return true;
}
// Processing by instruction ID // Processing by instruction ID
switch (inst.id) { switch (inst.id) {
@ -474,12 +470,8 @@ this.cycles = 0; // DEBUG: Stop processing after execute
access.type = type; access.type = type;
access.value = vue.read(address, type); access.value = vue.read(address, type);
// There is no application callback // Application callback
if (vue.onRead == null) vue.breakCode = vue.onRead(access);
return false;
// Call the application callback
vue.breakCode = vue.onRead.call(vue, access);
return vue.breakCode != 0; return vue.breakCode != 0;
} }
@ -530,13 +522,11 @@ this.cycles = 0; // DEBUG: Stop processing after execute
access.value = value; access.value = value;
// Application callback // Application callback
if (vue.onWrite != null) { vue.breakCode = vue.onWrite(access);
vue.breakCode = vue.onWrite.call(vue, access);
if (vue.breakCode != 0) if (vue.breakCode != 0)
return true; return true;
if (access.type == Vue.CANCEL) if (access.type == Vue.CANCEL)
return false; return false;
}
// Perform the operation // Perform the operation
vue.write(access.address, access.type, access.value); vue.write(access.address, access.type, access.value);

View File

@ -9,10 +9,6 @@ class JavaVue extends Vue {
// Package fields // Package fields
int breakCode; // Application break code int breakCode; // Application break code
CPU cpu; // Processor CPU cpu; // Processor
OnException onException; // Exception callback handler
OnExecute onExecute; // Execute callback handler
OnRead onRead; // Read callback handler
OnWrite onWrite; // Write callback handler
GamePak pak; // Game pak GamePak pak; // Game pak
byte[] wram; // System WRAM byte[] wram; // System WRAM
@ -184,21 +180,6 @@ class JavaVue extends Vue {
Arrays.fill(wram, 0, 0x10000, (byte) 0); Arrays.fill(wram, 0, 0x10000, (byte) 0);
} }
// Specify an exception breakpoint callback
public void setException(OnException callback) {
onException = callback;
}
// Specify an execute breakpoint callback
public void setExecute(OnExecute callback) {
onExecute = callback;
}
// Specify a read breakpoint callback
public void setRead(OnRead callback) {
onRead = callback;
}
// Specify a register value // Specify a register value
public int setRegister(int index, boolean system, int value) { public int setRegister(int index, boolean system, int value) {
return return
@ -227,11 +208,6 @@ class JavaVue extends Vue {
return true; return true;
} }
// Specify a write breakpoint callback
public void setWrite(OnWrite callback) {
onWrite = callback;
}
// Write a value to the CPU bus // Write a value to the CPU bus
public void write(int address, int type, int value) { public void write(int address, int type, int value) {
switch (address >> 24 & 7) { switch (address >> 24 & 7) {
@ -273,6 +249,26 @@ class JavaVue extends Vue {
// Package Methods // // Package Methods //
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// Exception break handler
int onException(Ecxeption exp) {
return 0;
}
// Execute break handler
int onExecute(Instruction inst) {
return 0;
}
// Read break handler
int onRead(Access acc) {
return 0;
}
// Write break handler
int onWrite(Access acc) {
return 0;
}
// Read a value from a byte buffer // Read a value from a byte buffer
static int readBuffer(byte[] data, int address, int type) { static int readBuffer(byte[] data, int address, int type) {

View File

@ -61,18 +61,11 @@ typedef struct {
// Component Includes // // Component Includes //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#define NATIVEVue #define NATIVEVUE
#include "Breakpoint.c" #include "Breakpoint.c"
///////////////////////////////////////////////////////////////////////////////
// Internal Functions //
///////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// Method Functions // // Method Functions //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -184,24 +177,6 @@ JNIEXPORT void JNICALL Java_vue_NativeVue_reset
vueReset(&core->vue); vueReset(&core->vue);
} }
// Specify an exception breakpoint callback
JNIEXPORT void JNICALL Java_vue_NativeVue_setException
(JNIEnv *env, jobject vue, jlong handle, jobject onException) {
Core *core = *(Core **)&handle;
}
// Specify an execute breakpoint callback
JNIEXPORT void JNICALL Java_vue_NativeVue_setExecute
(JNIEnv *env, jobject vue, jlong handle, jobject onExecute) {
Core *core = *(Core **)&handle;
}
// Specify a read breakpoint callback
JNIEXPORT void JNICALL Java_vue_NativeVue_setRead
(JNIEnv *env, jobject vue, jlong handle, jobject onRead) {
Core *core = *(Core **)&handle;
}
// Specify a register value // Specify a register value
JNIEXPORT jint JNICALL Java_vue_NativeVue_setRegister JNIEXPORT jint JNICALL Java_vue_NativeVue_setRegister
(JNIEnv *env, jobject vue, jlong handle, jint index, jboolean system, (JNIEnv *env, jobject vue, jlong handle, jint index, jboolean system,
@ -238,12 +213,6 @@ JNIEXPORT jboolean JNICALL Java_vue_NativeVue_setROM
return JNI_TRUE; return JNI_TRUE;
} }
// Specify a write breakpoint callback
JNIEXPORT void JNICALL Java_vue_NativeVue_setWrite
(JNIEnv *env, jobject vue, jlong handle, jobject onWrite) {
Core *core = *(Core **)&handle;
}
// Write a value to the CPU bus // Write a value to the CPU bus
JNIEXPORT void JNICALL Java_vue_NativeVue_write JNIEXPORT void JNICALL Java_vue_NativeVue_write
(JNIEnv *env, jobject vue, jlong handle, jint address, jint type, (JNIEnv *env, jobject vue, jlong handle, jint address, jint type,

View File

@ -71,21 +71,6 @@ class NativeVue extends Vue {
public void reset() public void reset()
{ reset(handle); } { reset(handle); }
// Specify an exception breakpoint callback
private native void setException(long handle, OnException callback);
public void setException(OnException callback)
{ setException(handle, callback); }
// Specify an execute breakpoint callback
private native void setExecute(long handle, OnExecute callback);
public void setExecute(OnExecute callback)
{ setExecute(handle, callback); }
// Specify a read breakpoint callback
private native void setRead(long handle, OnRead callback);
public void setRead(OnRead callback)
{ setRead(handle, callback); }
// Specify a register value // Specify a register value
private native int setRegister(long handle, int index, boolean system, private native int setRegister(long handle, int index, boolean system,
int value); int value);
@ -98,11 +83,6 @@ class NativeVue extends Vue {
public boolean setROM(byte[] data, int offset, int length) public boolean setROM(byte[] data, int offset, int length)
{ return setROM(handle, data, offset, length); } { return setROM(handle, data, offset, length); }
// Specify a write breakpoint callback
private native void setWrite(long handle, OnWrite callback);
public void setWrite(OnWrite callback)
{ setWrite(handle, callback); }
// Write a value to the CPU bus // Write a value to the CPU bus
private native void write(long handle, int address, int type, int value); private native void write(long handle, int address, int type, int value);
public void write(int address, int type, int value) public void write(int address, int type, int value)

View File

@ -8,17 +8,6 @@ public abstract class Vue {
///////////////////////////////////////////////////////////////////////////
// Types //
///////////////////////////////////////////////////////////////////////////
public interface OnException { int call(Vue vue, Ecxeption exp ); }
public interface OnExecute { int call(Vue vue, Instruction inst ); }
public interface OnRead { int call(Vue vue, Access access); }
public interface OnWrite { int call(Vue vue, Access access); }
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// Constants // // Constants //
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
@ -167,12 +156,6 @@ public abstract class Vue {
// Public Methods // // Public Methods //
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// Attach a breakpoint
//public abstract boolean attachBreakpoint(Breakpoint brk);
// Detach a breakpoint
//public abstract boolean detachBreakpoint(Breakpoint brk);
// Release any used resources // Release any used resources
public abstract void dispose(); public abstract void dispose();