Corrective tweaks
This commit is contained in:
+3
-3
@@ -5,7 +5,7 @@
|
||||
|
||||
/**************************** Component Functions ****************************/
|
||||
|
||||
/* Read a value from a memory buffer */
|
||||
/* Read a data unit from a memory buffer */
|
||||
static int32_t busReadMemory(uint8_t *mem, int type) {
|
||||
|
||||
/* Generic implementation */
|
||||
@@ -39,7 +39,7 @@ static int32_t busRead(VB *emu, uint32_t address, int type, int debug) {
|
||||
address &= ~((uint32_t) TYPE_SIZES[type] - 1);
|
||||
|
||||
/* Process by address range */
|
||||
switch (address >> 24 ^ 7) {
|
||||
switch (address >> 24 & 7) {
|
||||
case 0 : return 0; /* VIP */
|
||||
case 1 : debug = debug; return 0; /* VSU */
|
||||
case 2 : return 0; /* Miscellaneous hardware */
|
||||
@@ -84,7 +84,7 @@ static void busWriteMemory(uint8_t *mem, int type, int32_t value) {
|
||||
|
||||
}
|
||||
|
||||
/* Read a value from the bus */
|
||||
/* Write a data unit to the bus */
|
||||
static void busWrite(
|
||||
VB *emu, uint32_t address, int type, uint32_t value, int debug) {
|
||||
|
||||
|
||||
@@ -38,6 +38,20 @@ int32_t vbGetProgramRegister(VB *emu, int id) {
|
||||
return id < 1 || id > 31 ? 0 : emu->cpu.program[id];
|
||||
}
|
||||
|
||||
/* Retrieve the ROM buffer */
|
||||
void* vbGetROM(VB *emu, uint32_t *size) {
|
||||
if (size != NULL)
|
||||
*size = emu->cart.romSize;
|
||||
return emu->cart.rom;
|
||||
}
|
||||
|
||||
/* Retrieve the SRAM buffer */
|
||||
void* vbGetSRAM(VB *emu, uint32_t *size) {
|
||||
if (size != NULL)
|
||||
*size = emu->cart.sramSize;
|
||||
return emu->cart.sram;
|
||||
}
|
||||
|
||||
/* Retrieve the value of a system register */
|
||||
uint32_t vbGetSystemRegister(VB *emu, int id) {
|
||||
switch (id) {
|
||||
@@ -76,8 +90,15 @@ uint32_t vbGetSystemRegister(VB *emu, int id) {
|
||||
|
||||
/* Prepare a simulation state instance for use */
|
||||
void vbInit(VB *emu) {
|
||||
emu->cart.rom = NULL;
|
||||
emu->cart.sram = NULL;
|
||||
|
||||
/* Cartridge */
|
||||
emu->cart.rom = NULL;
|
||||
emu->cart.romSize = 0;
|
||||
emu->cart.sram = NULL;
|
||||
emu->cart.sramSize = 0;
|
||||
|
||||
/* All others */
|
||||
vbReset(emu);
|
||||
}
|
||||
|
||||
/* Read a data unit from the bus */
|
||||
@@ -96,6 +117,8 @@ void vbReset(VB *emu) {
|
||||
vbSetSystemRegister(emu, VB_PSW, 0x00008000);
|
||||
|
||||
/* Initialize extra CPU registers (the hardware does not do this) */
|
||||
for (x = 0; x < 32; x++)
|
||||
emu->cpu.program[x] = 0;
|
||||
emu->cpu.adtre = 0;
|
||||
emu->cpu.eipc = 0;
|
||||
emu->cpu.eipsw = 0;
|
||||
|
||||
@@ -114,6 +114,8 @@ struct VB {
|
||||
|
||||
VBAPI uint32_t vbGetProgramCounter (VB *emu);
|
||||
VBAPI int32_t vbGetProgramRegister (VB *emu, int id);
|
||||
VBAPI void* vbGetROM (VB *emu, uint32_t *size);
|
||||
VBAPI void* vbGetSRAM (VB *emu, uint32_t *size);
|
||||
VBAPI uint32_t vbGetSystemRegister (VB *emu, int id);
|
||||
VBAPI void vbInit (VB *emu);
|
||||
VBAPI int32_t vbRead (VB *emu, uint32_t address, int type, int debug);
|
||||
|
||||
Reference in New Issue
Block a user