From e97b52e944c4d1ca647d18c1797e533bd5044a80 Mon Sep 17 00:00:00 2001 From: Guy Perfect Date: Sun, 17 Nov 2024 12:31:37 -0600 Subject: [PATCH] Cleanup adjustments --- core/cpu.c | 5 ----- core/vb.c | 22 +++++++++++++--------- core/vsu.c | 2 +- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/core/cpu.c b/core/cpu.c index 39e978e..9024966 100644 --- a/core/cpu.c +++ b/core/cpu.c @@ -91,11 +91,6 @@ #define CPU_XORBSU 82 #define CPU_XORNBSU 83 -/* Functional operand types */ -#define CPU_LITERAL 0 -#define CPU_MEMORY 1 -#define CPU_REGISTER 2 - /* Bit string operations */ #define CPU_AND_BS 0 #define CPU_ANDN_BS 1 diff --git a/core/vb.c b/core/vb.c index 146f016..c73497f 100644 --- a/core/vb.c +++ b/core/vb.c @@ -643,6 +643,7 @@ VBAPI vbOnWrite vbGetWriteCallback(VB *sim) { VBAPI VB* vbInit(VB *sim) { sim->cart.ram = NULL; sim->cart.rom = NULL; + sim->ph.enabled = 0; sim->vsu.out.samples = NULL; sim->onExecute = NULL; sim->onFetch = NULL; @@ -652,7 +653,7 @@ VBAPI VB* vbInit(VB *sim) { sim->onSamples = NULL; sim->onWrite = NULL; sim->peer = NULL; - sim->ph.enabled = 0; + sim->tag = NULL; vbReset(sim); return sim; } @@ -716,28 +717,28 @@ VBAPI int vbSetCartROM(VB *sim, void *rom, uint32_t size) { /* Specify a new exception callback handler */ VBAPI vbOnException vbSetExceptionCallback(VB *sim, vbOnException callback) { vbOnException prev = sim->onException; - sim->onException = callback; + sim->onException = callback; return prev; } /* Specify a new execute callback handler */ VBAPI vbOnExecute vbSetExecuteCallback(VB *sim, vbOnExecute callback) { vbOnExecute prev = sim->onExecute; - sim->onExecute = callback; + sim->onExecute = callback; return prev; } /* Specify a new fetch callback handler */ VBAPI vbOnFetch vbSetFetchCallback(VB *sim, vbOnFetch callback) { vbOnFetch prev = sim->onFetch; - sim->onFetch = callback; + sim->onFetch = callback; return prev; } /* Specify a new frame callback handler */ VBAPI vbOnFrame vbSetFrameCallback(VB *sim, vbOnFrame callback) { vbOnFrame prev = sim->onFrame; - sim->onFrame = callback; + sim->onFrame = callback; return prev; } @@ -749,7 +750,7 @@ VBAPI uint16_t vbSetKeys(VB *sim, uint16_t keys) { /* Specify a new link callback handler */ VBAPI vbOnLink vbSetLinkCallback(VB *sim, vbOnLink callback) { vbOnLink prev = sim->onLink; - sim->onLink = callback; + sim->onLink = callback; return prev; } @@ -774,6 +775,8 @@ VBAPI int vbSetOption(VB *sim, int key, int value) { VBAPI void vbSetPeer(VB *sim, VB *peer) { if (sim->peer == peer) return; + if (sim->peer != NULL) + sim->peer->peer = NULL; sim->peer = peer; if (peer == NULL) return; @@ -784,6 +787,7 @@ VBAPI void vbSetPeer(VB *sim, VB *peer) { /* Specify a new value for the program counter */ VBAPI uint32_t vbSetProgramCounter(VB *sim, uint32_t value) { + sim->cpu.clocks = 0; sim->cpu.operation = CPU_FETCH; sim->cpu.pc = sim->cpu.nextPC = value & 0xFFFFFFFE; 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 */ VBAPI vbOnRead vbSetReadCallback(VB *sim, vbOnRead callback) { vbOnRead prev = sim->onRead; - sim->onRead = callback; + sim->onRead = callback; return prev; } @@ -829,7 +833,7 @@ VBAPI uint32_t vbSetSystemRegister(VB *sim, unsigned index, uint32_t value) { /* Specify a new write callback handler */ VBAPI vbOnWrite vbSetWriteCallback(VB *sim, vbOnWrite callback) { vbOnWrite prev = sim->onWrite; - sim->onWrite = callback; + sim->onWrite = callback; return prev; } @@ -841,7 +845,7 @@ VBAPI size_t vbSizeOf() { /* Specify a simulation's userdata pointer */ VBAPI void* vbSetUserData(VB *sim, void *tag) { void *prev = sim->tag; - sim->tag = tag; + sim->tag = tag; return prev; } diff --git a/core/vsu.c b/core/vsu.c index 9c16c25..706564b 100644 --- a/core/vsu.c +++ b/core/vsu.c @@ -345,7 +345,7 @@ static void vsuEmulate(VB *sim, uint32_t clocks) { /* Wait for the current sample to finish */ if (sim->vsu.clocks != 0) - continue; + return; /* Compute the output sample */ output[0] = output[1] = 0;