Frame buffer management fixes
This commit is contained in:
parent
06849b54ba
commit
57dcd8370a
|
@ -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++;
|
||||
|
|
|
@ -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);
|
||||
|
|
27
core/vip.c
27
core/vip.c
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue