Frame buffer management fixes

This commit is contained in:
2025-01-05 20:54:37 -06:00
parent 06849b54ba
commit 57dcd8370a
3 changed files with 22 additions and 10 deletions
+19 -8
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) {
@@ -656,11 +656,12 @@ static int vipEmulateDisplay(VB *sim, uint32_t clocks) {
/* Game frame */
if (sim->vip.xp.xpen) {
if (sim->vip.xp.frame >= sim->vip.frmcyc) {
sim->vip.xp.frame = 0;
sim->vip.dp.buffer ^= sim->vip.xp.toggle;
sim->vip.xp.frame = 0;
sim->vip.xp.toggle = 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;
@@ -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;
@@ -1330,11 +1333,11 @@ static void vipRead(VB *sim, uint32_t address, int type, int32_t *value) {
/* Simulate a hardware reset */
static void vipReset(VB *sim) {
Cell *cell; /* BG map cell state */
Character *chr; /* Character state */
Object *obj; /* Object state */
World *world; /* World state */
int x, y; /* Iterators */
Cell *cell; /* BG map cell state */
Character *chr; /* Character state */
Object *obj; /* Object state */
World *world; /* World state */
int x, y, z; /* Iterators */
/* Normal */
sim->vip.intenb = 0x0000;
@@ -1424,6 +1427,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 +1444,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;
}