Compare commits

..
3 Commits
4 changed files with 45 additions and 26 deletions
+2
View File
@@ -159,6 +159,8 @@ static void busRead(VB *sim, uint32_t address, int type, int32_t *value) {
case 2: /* Misc. I/O */
*value = busReadMisc(sim, address, type);
if (type == VB_S8)
*value = (int8_t) *value;
break;
case 3: break; /* Unmapped */
+3 -1
View File
@@ -312,6 +312,7 @@ struct VB {
int frame; /* FRMCYC counter */
int32_t halfword; /* Current output halfword offset */
int step; /* Processing phase */
uint8_t toggle; /* Switch frame buffers next frame */
uint32_t until; /* Clocks until interrupt condition */
} xp;
@@ -326,6 +327,7 @@ struct VB {
uint16_t spt[4]; /* Object control */
/* Rendering shadow memory */
uint8_t buffer; /* Output buffer */
uint16_t halfwords[384*28]; /* Output timing by 1x8 halfword */
Pixels output[2]; /* Output images, row-major */
Pixels shadow; /* Drawing shadow image, column-major */
@@ -632,7 +634,7 @@ VBAPI void vbGetPixels(VB *sim, void *left, int leftStrideX, int leftStrideY,
continue;
/* Transfer pixels to the destination */
src = sim->vip.output[sim->vip.dp.buffer ^ 1][i];
src = sim->vip.output[sim->vip.buffer][i];
for (y = 0; y < 224; y++, dest += yStride)
for (x = offset = 0; x < 384; x++, offset += xStride)
dest[offset] = *src++;
-1
View File
@@ -126,7 +126,6 @@ typedef int (*vbOnWrite )(VB *sim, uint32_t address, int type, int32_t *valu
VBAPI int vbEmulate (VB *sim, uint32_t *clocks);
VBAPI int vbEmulateEx (VB **sims, unsigned 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);
+31 -15
View File
@@ -598,7 +598,7 @@ static void vipTransferColumn(VB *sim, int32_t eye) {
/* Select destination address in host memory */
dest = &sim->vip.output
[sim->vip.dp.buffer][eye][sim->vip.dp.column];
[sim->vip.buffer ^ 1][eye][sim->vip.dp.column];
/* Output is disabled */
if (!sim->vip.dp.enabled) {
@@ -654,28 +654,29 @@ static int vipEmulateDisplay(VB *sim, uint32_t clocks) {
vipThrow(sim, 0x0010); /* FRAMESTART */
/* Game frame */
if (sim->vip.xp.xpen) {
if (sim->vip.xp.frame >= sim->vip.frmcyc) {
sim->vip.xp.frame = 0;
/* Initiate drawing procedure */
if (sim->vip.xp.step == 0) {
sim->vip.dp.buffer ^= 1;
sim->vip.xp.enabled = 1;
sim->vip.xp.overtime = 0;
sim->vip.xp.step = 1;
vipThrow(sim, 0x0008); /* GAMESTART */
}
/* Drawing procedure has run into overtime */
else {
if (sim->vip.xp.step != 0) {
sim->vip.xp.overtime = 1;
vipThrow(sim, 0x8000); /* TIMEERR */
}
} else sim->vip.xp.frame++;
/* Initiate drawing procedure */
else if (sim->vip.xp.xpen) {
sim->vip.dp.buffer ^= sim->vip.xp.toggle;
sim->vip.xp.enabled = 1;
sim->vip.xp.overtime = 0;
sim->vip.xp.step = 1;
sim->vip.xp.toggle = 0;
}
}
/* Not a game frame */
else sim->vip.xp.frame++;
break;
/* 0ms-3ms - Idle */
@@ -767,6 +768,7 @@ static int vipEmulateDisplay(VB *sim, uint32_t clocks) {
/* 18ms-20ms - Idle */
case 8: /* 20ms - Display interval complete */
sim->vip.buffer ^= 1;
sim->vip.dp.step = 0;
if (vipOnFrame(sim))
return 1;
@@ -1264,6 +1266,7 @@ static void vipEmulateDrawing(VB *sim, uint32_t clocks) {
case 4: /* Drawing complete */
sim->vip.xp.enabled = 0;
sim->vip.xp.step = 0;
sim->vip.xp.toggle = 1;
if (sim->vip.dp.buffer == 0)
sim->vip.xp.f1bsy = 0;
else sim->vip.xp.f0bsy = 0;
@@ -1313,8 +1316,13 @@ static void vipRead(VB *sim, uint32_t address, int type, int32_t *value) {
*value = 0;
/* I/O register */
else if (address < 0x60000)
else if (address < 0x60000) {
*value = vipReadIO(sim, address, type);
switch (type) {
case VB_S8 : *value = (int8_t ) *value; break;
case VB_S16: *value = (int16_t) *value; break;
}
}
/* Unmapped */
else if (address < 0x78000)
@@ -1334,7 +1342,7 @@ static void vipReset(VB *sim) {
Character *chr; /* Character state */
Object *obj; /* Object state */
World *world; /* World state */
int x, y; /* Iterators */
int x, y, z; /* Iterators */
/* Normal */
sim->vip.intenb = 0x0000;
@@ -1424,6 +1432,13 @@ static void vipReset(VB *sim) {
sim->vip.xp.sbcount = 0;
sim->vip.xp.sbout = 0;
/* Other */
sim->vip.buffer = 0;
for (x = 0; x < 2; x++)
for (y = 0; y < 2; y++)
for (z = 0; z < 384*224; z++)
sim->vip.output[x][y][z] = 0;
/* Display processor other */
sim->vip.dp.brt[0] = 0;
sim->vip.dp.buffer = 0; /* TODO: Hardware might actually do this */
@@ -1434,6 +1449,7 @@ static void vipReset(VB *sim) {
/* Pixel processor other */
sim->vip.xp.clocks = 0;
sim->vip.xp.step = 0;
sim->vip.xp.toggle = 0;
sim->vip.xp.until = 0;
}