Cleanup adjustments

This commit is contained in:
Guy Perfect 2024-11-17 12:31:37 -06:00
parent 7e31fbd582
commit e97b52e944
3 changed files with 14 additions and 15 deletions

View File

@ -91,11 +91,6 @@
#define CPU_XORBSU 82 #define CPU_XORBSU 82
#define CPU_XORNBSU 83 #define CPU_XORNBSU 83
/* Functional operand types */
#define CPU_LITERAL 0
#define CPU_MEMORY 1
#define CPU_REGISTER 2
/* Bit string operations */ /* Bit string operations */
#define CPU_AND_BS 0 #define CPU_AND_BS 0
#define CPU_ANDN_BS 1 #define CPU_ANDN_BS 1

View File

@ -643,6 +643,7 @@ VBAPI vbOnWrite vbGetWriteCallback(VB *sim) {
VBAPI VB* vbInit(VB *sim) { VBAPI VB* vbInit(VB *sim) {
sim->cart.ram = NULL; sim->cart.ram = NULL;
sim->cart.rom = NULL; sim->cart.rom = NULL;
sim->ph.enabled = 0;
sim->vsu.out.samples = NULL; sim->vsu.out.samples = NULL;
sim->onExecute = NULL; sim->onExecute = NULL;
sim->onFetch = NULL; sim->onFetch = NULL;
@ -652,7 +653,7 @@ VBAPI VB* vbInit(VB *sim) {
sim->onSamples = NULL; sim->onSamples = NULL;
sim->onWrite = NULL; sim->onWrite = NULL;
sim->peer = NULL; sim->peer = NULL;
sim->ph.enabled = 0; sim->tag = NULL;
vbReset(sim); vbReset(sim);
return sim; return sim;
} }
@ -716,28 +717,28 @@ VBAPI int vbSetCartROM(VB *sim, void *rom, uint32_t size) {
/* Specify a new exception callback handler */ /* Specify a new exception callback handler */
VBAPI vbOnException vbSetExceptionCallback(VB *sim, vbOnException callback) { VBAPI vbOnException vbSetExceptionCallback(VB *sim, vbOnException callback) {
vbOnException prev = sim->onException; vbOnException prev = sim->onException;
sim->onException = callback; sim->onException = callback;
return prev; return prev;
} }
/* Specify a new execute callback handler */ /* Specify a new execute callback handler */
VBAPI vbOnExecute vbSetExecuteCallback(VB *sim, vbOnExecute callback) { VBAPI vbOnExecute vbSetExecuteCallback(VB *sim, vbOnExecute callback) {
vbOnExecute prev = sim->onExecute; vbOnExecute prev = sim->onExecute;
sim->onExecute = callback; sim->onExecute = callback;
return prev; return prev;
} }
/* Specify a new fetch callback handler */ /* Specify a new fetch callback handler */
VBAPI vbOnFetch vbSetFetchCallback(VB *sim, vbOnFetch callback) { VBAPI vbOnFetch vbSetFetchCallback(VB *sim, vbOnFetch callback) {
vbOnFetch prev = sim->onFetch; vbOnFetch prev = sim->onFetch;
sim->onFetch = callback; sim->onFetch = callback;
return prev; return prev;
} }
/* Specify a new frame callback handler */ /* Specify a new frame callback handler */
VBAPI vbOnFrame vbSetFrameCallback(VB *sim, vbOnFrame callback) { VBAPI vbOnFrame vbSetFrameCallback(VB *sim, vbOnFrame callback) {
vbOnFrame prev = sim->onFrame; vbOnFrame prev = sim->onFrame;
sim->onFrame = callback; sim->onFrame = callback;
return prev; return prev;
} }
@ -749,7 +750,7 @@ VBAPI uint16_t vbSetKeys(VB *sim, uint16_t keys) {
/* Specify a new link callback handler */ /* Specify a new link callback handler */
VBAPI vbOnLink vbSetLinkCallback(VB *sim, vbOnLink callback) { VBAPI vbOnLink vbSetLinkCallback(VB *sim, vbOnLink callback) {
vbOnLink prev = sim->onLink; vbOnLink prev = sim->onLink;
sim->onLink = callback; sim->onLink = callback;
return prev; return prev;
} }
@ -774,6 +775,8 @@ VBAPI int vbSetOption(VB *sim, int key, int value) {
VBAPI void vbSetPeer(VB *sim, VB *peer) { VBAPI void vbSetPeer(VB *sim, VB *peer) {
if (sim->peer == peer) if (sim->peer == peer)
return; return;
if (sim->peer != NULL)
sim->peer->peer = NULL;
sim->peer = peer; sim->peer = peer;
if (peer == NULL) if (peer == NULL)
return; return;
@ -784,6 +787,7 @@ VBAPI void vbSetPeer(VB *sim, VB *peer) {
/* Specify a new value for the program counter */ /* Specify a new value for the program counter */
VBAPI uint32_t vbSetProgramCounter(VB *sim, uint32_t value) { VBAPI uint32_t vbSetProgramCounter(VB *sim, uint32_t value) {
sim->cpu.clocks = 0;
sim->cpu.operation = CPU_FETCH; sim->cpu.operation = CPU_FETCH;
sim->cpu.pc = sim->cpu.nextPC = value & 0xFFFFFFFE; sim->cpu.pc = sim->cpu.nextPC = value & 0xFFFFFFFE;
sim->cpu.step = 0; sim->cpu.step = 0;
@ -798,7 +802,7 @@ VBAPI int32_t vbSetProgramRegister(VB *sim, unsigned index, int32_t value) {
/* Specify a new read callback handler */ /* Specify a new read callback handler */
VBAPI vbOnRead vbSetReadCallback(VB *sim, vbOnRead callback) { VBAPI vbOnRead vbSetReadCallback(VB *sim, vbOnRead callback) {
vbOnRead prev = sim->onRead; vbOnRead prev = sim->onRead;
sim->onRead = callback; sim->onRead = callback;
return prev; return prev;
} }
@ -829,7 +833,7 @@ VBAPI uint32_t vbSetSystemRegister(VB *sim, unsigned index, uint32_t value) {
/* Specify a new write callback handler */ /* Specify a new write callback handler */
VBAPI vbOnWrite vbSetWriteCallback(VB *sim, vbOnWrite callback) { VBAPI vbOnWrite vbSetWriteCallback(VB *sim, vbOnWrite callback) {
vbOnWrite prev = sim->onWrite; vbOnWrite prev = sim->onWrite;
sim->onWrite = callback; sim->onWrite = callback;
return prev; return prev;
} }
@ -841,7 +845,7 @@ VBAPI size_t vbSizeOf() {
/* Specify a simulation's userdata pointer */ /* Specify a simulation's userdata pointer */
VBAPI void* vbSetUserData(VB *sim, void *tag) { VBAPI void* vbSetUserData(VB *sim, void *tag) {
void *prev = sim->tag; void *prev = sim->tag;
sim->tag = tag; sim->tag = tag;
return prev; return prev;
} }

View File

@ -345,7 +345,7 @@ static void vsuEmulate(VB *sim, uint32_t clocks) {
/* Wait for the current sample to finish */ /* Wait for the current sample to finish */
if (sim->vsu.clocks != 0) if (sim->vsu.clocks != 0)
continue; return;
/* Compute the output sample */ /* Compute the output sample */
output[0] = output[1] = 0; output[0] = output[1] = 0;