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
.PHONY: clean_most
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
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 . \
src/desktop/vue/NativeVUE.java
src/desktop/vue/NativeVue.java
@sleep 3
# linux_x86
.PHONY: lin32_pre
lin32_pre: src/desktop/vue/vue_NativeVUE.h
lin32_pre: src/desktop/vue/vue_NativeVue.h
$(eval name = linux_x86)
$(eval prefix = `uname -m`-linux-gnu-)
$(eval include = -I$(include_linux) -I$(include_linux)/linux)
@ -130,7 +130,7 @@ lin32: lin32_pre native_common
# linux_x86-64
.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 prefix = `uname -m`-linux-gnu-)
$(eval include = -I$(include_linux) -I$(include_linux)/linux)
@ -141,7 +141,7 @@ lin64: lin64_pre native_common
# windows_x86
.PHONY: win32_pre
win32_pre: src/desktop/vue/vue_NativeVUE.h
win32_pre: src/desktop/vue/vue_NativeVue.h
$(eval name = windows_x86)
$(eval prefix = i686-w64-mingw32-)
$(eval include = -I$(include_windows) -I$(include_windows)/win32)
@ -151,7 +151,7 @@ win32: win32_pre native_common
# windows_x86-64
.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 prefix = x86_64-w64-mingw32-)
$(eval include = -I$(include_windows) -I$(include_windows)/win32)
@ -165,4 +165,4 @@ native_common:
@echo " Building native module $(name)"
@$(prefix)gcc $(include) -Isrc/core/include $(gccargs) -s -shared -O2 \
-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
static int32_t evalAddress(VUE *vue) {
static int32_t evalAddress(Vue *vue) {
if (vue->cpu.inst.format == 6)
return vue->cpu.program[vue->cpu.inst.reg1] + vue->cpu.inst.disp;
switch (vue->cpu.inst.id) {
@ -318,7 +318,7 @@ static int32_t evalAddress(VUE *vue) {
}
// Evaluate cond
static int32_t evalCond(VUE *vue) {
static int32_t evalCond(Vue *vue) {
switch (vue->cpu.inst.id) {
case VUE_BCOND: return vue->cpu.inst.cond;
case VUE_SETF : return vue->cpu.inst.imm;
@ -327,7 +327,7 @@ static int32_t evalCond(VUE *vue) {
}
// Evaluate disp
static int32_t evalDisp(VUE *vue) {
static int32_t evalDisp(Vue *vue) {
switch (vue->cpu.inst.format) {
case 3: case 4: case 6: return vue->cpu.inst.disp;
}
@ -335,7 +335,7 @@ static int32_t evalDisp(VUE *vue) {
}
// Evaluate imm
static int32_t evalImm(VUE *vue) {
static int32_t evalImm(Vue *vue) {
switch (vue->cpu.inst.format) {
case 2: case 5: return vue->cpu.inst.imm;
}
@ -343,7 +343,7 @@ static int32_t evalImm(VUE *vue) {
}
// Evaluate reg1
static int32_t evalReg1(VUE *vue) {
static int32_t evalReg1(Vue *vue) {
switch (vue->cpu.inst.format) {
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
static int32_t evalReg2(VUE *vue) {
static int32_t evalReg2(Vue *vue) {
switch (vue->cpu.inst.format) {
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
static int32_t evalRegId(VUE *vue) {
static int32_t evalRegId(Vue *vue) {
switch (vue->cpu.inst.id) {
case VUE_LDSR: case VUE_STSR: return vue->cpu.inst.imm;
}
@ -367,7 +367,7 @@ static int32_t evalRegId(VUE *vue) {
}
// Evaluate subopcode
static int32_t evalSubopcode(VUE *vue) {
static int32_t evalSubopcode(Vue *vue) {
switch (vue->cpu.inst.opcode) {
case 0x1F: return vue->cpu.inst.imm;
case 0x3E: return vue->cpu.inst.subopcode;
@ -376,12 +376,12 @@ static int32_t evalSubopcode(VUE *vue) {
}
// Evaluate value
static int evalValue(VUE *vue) {
static int evalValue(Vue *vue) {
return vue->cpu.inst.format == 6 ? vue->cpu.access.value : 0;
}
// Evaluate vector
static int evalVector(VUE *vue) {
static int evalVector(Vue *vue) {
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 []
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);
}
@ -548,7 +548,7 @@ static int32_t evalBinary(int32_t id, int32_t *stack, int32_t size) {
}
// 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;
if (id == VUE_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
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 value = stack[size - 1];
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
int32_t evaluate(VUE *vue, Breakpoint *brk, int32_t *stack) {
int32_t evaluate(Vue *vue, Breakpoint *brk, int32_t *stack) {
// The condition is empty
if (brk->numCondition == 0)
@ -618,7 +618,7 @@ int32_t evaluate(VUE *vue, Breakpoint *brk, int32_t *stack) {
// Process tokens
int size = 0;
for (int x = 0; x < brk->numCondition; x++) {
TOKEN *tok = &brk->condition[x];
Token *tok = &brk->condition[x];
switch (tok->type) {
case BINARY: size =
evalBinary( tok->value, stack, size); continue;

View File

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

View File

@ -7,14 +7,10 @@ import java.util.*;
class JavaVue extends Vue {
// Package fields
int breakCode; // Application break code
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
byte[] wram; // System WRAM
int breakCode; // Application break code
CPU cpu; // Processor
GamePak pak; // Game pak
byte[] wram; // System WRAM
@ -184,21 +180,6 @@ class JavaVue extends Vue {
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
public int setRegister(int index, boolean system, int value) {
return
@ -227,11 +208,6 @@ class JavaVue extends Vue {
return true;
}
// Specify a write breakpoint callback
public void setWrite(OnWrite callback) {
onWrite = callback;
}
// Write a value to the CPU bus
public void write(int address, int type, int value) {
switch (address >> 24 & 7) {
@ -273,6 +249,26 @@ class JavaVue extends Vue {
// 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
static int readBuffer(byte[] data, int address, int type) {

View File

@ -61,18 +61,11 @@ typedef struct {
// Component Includes //
///////////////////////////////////////////////////////////////////////////////
#define NATIVEVue
#define NATIVEVUE
#include "Breakpoint.c"
///////////////////////////////////////////////////////////////////////////////
// Internal Functions //
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Method Functions //
///////////////////////////////////////////////////////////////////////////////
@ -184,24 +177,6 @@ JNIEXPORT void JNICALL Java_vue_NativeVue_reset
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
JNIEXPORT jint JNICALL Java_vue_NativeVue_setRegister
(JNIEnv *env, jobject vue, jlong handle, jint index, jboolean system,
@ -238,12 +213,6 @@ JNIEXPORT jboolean JNICALL Java_vue_NativeVue_setROM
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
JNIEXPORT void JNICALL Java_vue_NativeVue_write
(JNIEnv *env, jobject vue, jlong handle, jint address, jint type,

View File

@ -71,21 +71,6 @@ class NativeVue extends Vue {
public void reset()
{ 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
private native int setRegister(long handle, int index, boolean system,
int value);
@ -98,11 +83,6 @@ class NativeVue extends Vue {
public boolean setROM(byte[] data, int offset, int 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
private native void write(long handle, 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 //
///////////////////////////////////////////////////////////////////////////
@ -167,12 +156,6 @@ public abstract class Vue {
// Public Methods //
///////////////////////////////////////////////////////////////////////////
// Attach a breakpoint
//public abstract boolean attachBreakpoint(Breakpoint brk);
// Detach a breakpoint
//public abstract boolean detachBreakpoint(Breakpoint brk);
// Release any used resources
public abstract void dispose();