Compare commits
6
Commits
5f563e6cac
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
08fb65cb77 | ||
|
|
1d6f62e319 | ||
|
|
2e1cd12829 | ||
|
|
2273761222 | ||
|
|
bfc2254b9e | ||
|
|
7c25a4ac93 |
+628
-276
File diff suppressed because it is too large
Load Diff
@@ -65,16 +65,21 @@ struct VB {
|
||||
|
||||
/* Working data */
|
||||
union {
|
||||
struct {
|
||||
uint32_t dest;
|
||||
uint64_t src;
|
||||
} bs; /* Arithmetic bit strings */
|
||||
struct {
|
||||
uint32_t address;
|
||||
int32_t value;
|
||||
} data;
|
||||
} data; /* Data accesses */
|
||||
} aux;
|
||||
|
||||
/* Other state */
|
||||
uint32_t clocks; /* Master clocks to wait */
|
||||
uint16_t code[2]; /* Instruction code units */
|
||||
uint16_t exception; /* Exception cause code */
|
||||
int halt; /* CPU is halting */
|
||||
uint16_t irq; /* Interrupt request lines */
|
||||
int length; /* Instruction code length */
|
||||
uint32_t nextPC; /* Address of next instruction */
|
||||
@@ -86,6 +91,7 @@ struct VB {
|
||||
uint8_t wram[0x10000]; /* System RAM */
|
||||
|
||||
/* Application data */
|
||||
vbOnException onException; /* CPU exception */
|
||||
vbOnExecute onExecute; /* CPU instruction execute */
|
||||
vbOnFetch onFetch; /* CPU instruction fetch */
|
||||
vbOnRead onRead; /* CPU instruction read */
|
||||
@@ -185,6 +191,11 @@ VBAPI void* vbGetCartROM(VB *sim, uint32_t *size) {
|
||||
return sim->cart.rom;
|
||||
}
|
||||
|
||||
/* Retrieve the exception callback handle */
|
||||
VBAPI vbOnException vbGetExceptionCallback(VB *sim) {
|
||||
return sim->onException;
|
||||
}
|
||||
|
||||
/* Retrieve the execute callback handle */
|
||||
VBAPI vbOnExecute vbGetExecuteCallback(VB *sim) {
|
||||
return sim->onExecute;
|
||||
@@ -256,6 +267,7 @@ VBAPI VB* vbReset(VB *sim) {
|
||||
|
||||
/* CPU (normal) */
|
||||
sim->cpu.exception = 0;
|
||||
sim->cpu.halt = 0;
|
||||
sim->cpu.irq = 0;
|
||||
sim->cpu.pc = 0xFFFFFFF0;
|
||||
cpuSetSystemRegister(sim, VB_ECR, 0x0000FFF0, 1);
|
||||
@@ -304,6 +316,13 @@ VBAPI int vbSetCartROM(VB *sim, void *rom, uint32_t size) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Specify a new exception callback handle */
|
||||
VBAPI vbOnException vbSetExceptionCallback(VB *sim, vbOnException callback) {
|
||||
vbOnException prev = sim->onException;
|
||||
sim->onException = callback;
|
||||
return prev;
|
||||
}
|
||||
|
||||
/* Specify a new execute callback handle */
|
||||
VBAPI vbOnExecute vbSetExecuteCallback(VB *sim, vbOnExecute callback) {
|
||||
vbOnExecute prev = sim->onExecute;
|
||||
|
||||
@@ -52,6 +52,7 @@ extern "C" {
|
||||
typedef struct VB VB;
|
||||
|
||||
/* Callbacks */
|
||||
typedef int (*vbOnException)(VB *sim, uint16_t *cause);
|
||||
typedef int (*vbOnExecute )(VB *sim, uint32_t address, const uint16_t *code, int length);
|
||||
typedef int (*vbOnFetch )(VB *sim, int fetch, uint32_t address, int32_t *value, uint32_t *cycles);
|
||||
typedef int (*vbOnRead )(VB *sim, uint32_t address, int type, int32_t *value, uint32_t *cycles);
|
||||
@@ -67,6 +68,7 @@ VBAPI int vbEmulateEx (VB **sims, int count, uint32_t *clocks);
|
||||
VBAPI void* vbGetCallback (VB *sim, int id);
|
||||
VBAPI void* vbGetCartRAM (VB *sim, uint32_t *size);
|
||||
VBAPI void* vbGetCartROM (VB *sim, uint32_t *size);
|
||||
VBAPI vbOnException vbGetExceptionCallback(VB *sim);
|
||||
VBAPI vbOnExecute vbGetExecuteCallback (VB *sim);
|
||||
VBAPI vbOnFetch vbGetFetchCallback (VB *sim);
|
||||
VBAPI uint32_t vbGetProgramCounter (VB *sim);
|
||||
@@ -80,6 +82,7 @@ VBAPI int32_t vbRead (VB *sim, uint32_t address, int type);
|
||||
VBAPI VB* vbReset (VB *sim);
|
||||
VBAPI int vbSetCartRAM (VB *sim, void *sram, uint32_t size);
|
||||
VBAPI int vbSetCartROM (VB *sim, void *rom, uint32_t size);
|
||||
VBAPI vbOnException vbSetExceptionCallback(VB *sim, vbOnException callback);
|
||||
VBAPI vbOnExecute vbSetExecuteCallback (VB *sim, vbOnExecute callback);
|
||||
VBAPI vbOnFetch vbSetFetchCallback (VB *sim, vbOnFetch callback);
|
||||
VBAPI uint32_t vbSetProgramCounter (VB *sim, uint32_t value);
|
||||
|
||||
Reference in New Issue
Block a user