Implement VIP, fix interrupts

This commit is contained in:
2024-10-19 17:01:36 -05:00
parent 3c2c9bb938
commit 37b9a94338
4 changed files with 509 additions and 52 deletions
+11 -3
View File
@@ -8,6 +8,9 @@
/*********************************** Types ***********************************/
/* Output image */
typedef uint8_t Pixels[2][384*224];
/* Simulation state */
struct VB {
@@ -126,6 +129,7 @@ struct VB {
/* Pixel processor */
struct {
/* Hardware state */
uint8_t f0bsy; /* Drawing into frame buffer 0 */
uint8_t f1bsy; /* Drawing into frame buffer 1 */
@@ -137,7 +141,9 @@ struct VB {
/* Simulation state */
uint32_t clocks; /* Master clocks to wait */
int column; /* Current horizontal output position */
int frame; /* FRMCYC counter */
int32_t halfword; /* Current output halfword offset */
int step; /* Processing phase */
uint32_t until; /* Clocks until interrupt condition */
} xp;
@@ -152,8 +158,10 @@ struct VB {
uint8_t jplt[4][4]; /* Object palettes */
uint16_t spt[4]; /* Object control */
/* Output frame buffers [buffer index][0=left, 1=right][pixel index] */
uint8_t frames[2][2][384*224];
/* Rendering shadow memory */
uint16_t halfwords[384*28]; /* Output timing by 1x8 halfword */
Pixels output[2]; /* Output images, row-major */
Pixels shadow; /* Drawing shadow image, column-major */
/* Other state */
uint8_t ram[0x40000]; /* Video memory */
@@ -319,7 +327,7 @@ VBAPI void vbGetPixels(VB *sim, void *left, int leftStrideX, int leftStrideY,
continue;
/* Transfer pixels to the destination */
src = sim->vip.frames[sim->vip.dp.buffer][i];
src = sim->vip.output[sim->vip.dp.buffer ^ 1][i];
for (y = 0; y < 224; y++, dest += yStride)
for (x = offset = 0; x < 384; x++, offset += xStride)
dest[offset] = *src++;