Introduce pseudo-halt
This commit is contained in:
@@ -308,6 +308,29 @@ struct VB {
|
||||
int sample; /* Output sample index, period 417 */
|
||||
} vsu;
|
||||
|
||||
/* Pseudo-halt */
|
||||
struct {
|
||||
uint32_t address; /* Monitor address */
|
||||
uint8_t enabled; /* Pseudo-halt function is enabled */
|
||||
uint8_t operation; /* Monitoring operation */
|
||||
uint8_t step; /* Number of consecutive matching reads */
|
||||
int type; /* Memory access type */
|
||||
int32_t value; /* Value read from monitor address */
|
||||
|
||||
/* CPU snapshot */
|
||||
uint32_t adtre;
|
||||
uint32_t chcw;
|
||||
uint32_t eipc;
|
||||
uint32_t eipsw;
|
||||
uint32_t fepc;
|
||||
uint32_t fepsw;
|
||||
uint32_t pc;
|
||||
int32_t program[31];
|
||||
uint32_t psw;
|
||||
uint32_t sr29;
|
||||
uint32_t sr31;
|
||||
} ph;
|
||||
|
||||
/* Other state */
|
||||
uint8_t wcr; /* Wait controller state */
|
||||
uint8_t wram[0x10000]; /* System RAM */
|
||||
@@ -348,6 +371,7 @@ static int32_t SignExtend(int32_t value, int32_t bits) {
|
||||
#include "cpu.c"
|
||||
#include "vip.c"
|
||||
#include "vsu.c"
|
||||
#include "pseudo-halt.c"
|
||||
|
||||
|
||||
|
||||
@@ -451,6 +475,14 @@ VBAPI uint16_t vbGetKeys(VB *sim) {
|
||||
return sim->pad.keys;
|
||||
}
|
||||
|
||||
/* Retrieve a core option value */
|
||||
VBAPI int vbGetOption(VB *sim, int key) {
|
||||
switch (key) {
|
||||
case VB_PSEUDO_HALT: return sim->ph.enabled;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Retrieve the most recent frame image pixels */
|
||||
VBAPI void vbGetPixels(VB *sim, void *left, int leftStrideX, int leftStrideY,
|
||||
void *right, int rightStrideX, int rightStrideY) {
|
||||
@@ -553,6 +585,7 @@ VBAPI VB* vbInit(VB *sim) {
|
||||
sim->onRead = NULL;
|
||||
sim->onSamples = NULL;
|
||||
sim->onWrite = NULL;
|
||||
sim->ph.enabled = 0;
|
||||
vbReset(sim);
|
||||
return sim;
|
||||
}
|
||||
@@ -583,6 +616,9 @@ VBAPI VB* vbReset(VB *sim) {
|
||||
tmrReset(sim);
|
||||
vipReset(sim);
|
||||
vsuReset(sim);
|
||||
|
||||
/* Pseudo-halt */
|
||||
sim->ph.step = 0;
|
||||
return sim;
|
||||
}
|
||||
|
||||
@@ -641,6 +677,23 @@ VBAPI uint16_t vbSetKeys(VB *sim, uint16_t keys) {
|
||||
return sim->pad.keys = keys;
|
||||
}
|
||||
|
||||
/* Specify a new core option value */
|
||||
VBAPI int vbSetOption(VB *sim, int key, int value) {
|
||||
switch (key) {
|
||||
case VB_PSEUDO_HALT:
|
||||
sim->ph.enabled = value = !!value;
|
||||
if (!value) {
|
||||
sim->ph.step = 0;
|
||||
if (sim->cpu.operation == CPU_PHALT) {
|
||||
sim->cpu.operation = CPU_FETCH;
|
||||
sim->cpu.step = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/* Specify a new value for the program counter */
|
||||
VBAPI uint32_t vbSetProgramCounter(VB *sim, uint32_t value) {
|
||||
sim->cpu.operation = CPU_FETCH;
|
||||
|
||||
Reference in New Issue
Block a user