Establish display processing
This commit is contained in:
@@ -96,21 +96,34 @@ struct VB {
|
||||
uint8_t cta_r; /* Right column table index */
|
||||
} cta;
|
||||
|
||||
/* Display control */
|
||||
/* Display processor */
|
||||
struct {
|
||||
uint8_t disp; /* Display enabled */
|
||||
uint8_t fclk; /* Frame clock signal high */
|
||||
uint8_t l0bsy; /* Displaying left frame buffer 0 */
|
||||
uint8_t l1bsy; /* Displaying left frame buffer 1 */
|
||||
uint8_t lock; /* Lock CTA */
|
||||
uint8_t r0bsy; /* Displaying right frame buffer 0 */
|
||||
uint8_t r1bsy; /* Displaying right frame buffer 1*/
|
||||
uint8_t re; /* Memory refresh enabled */
|
||||
uint8_t scanrdy; /* Mirrors are stable */
|
||||
uint8_t synce; /* Servo enabled */
|
||||
} dpctrl;
|
||||
|
||||
/* Drawing control */
|
||||
/* Hardware state */
|
||||
uint8_t disp; /* Display enabled */
|
||||
uint8_t fclk; /* Frame clock signal high */
|
||||
uint8_t l0bsy; /* Displaying left frame buffer 0 */
|
||||
uint8_t l1bsy; /* Displaying left frame buffer 1 */
|
||||
uint8_t lock; /* Lock CTA */
|
||||
uint8_t r0bsy; /* Displaying right frame buffer 0 */
|
||||
uint8_t r1bsy; /* Displaying right frame buffer 1*/
|
||||
uint8_t re; /* Memory refresh enabled */
|
||||
uint8_t scanrdy; /* Mirrors are stable */
|
||||
uint8_t synce; /* Servo enabled */
|
||||
|
||||
/* Simulation state */
|
||||
uint8_t brt[4]; /* Precomputed brightness */
|
||||
int buffer; /* Index of frame buffer to display */
|
||||
uint32_t clocks; /* Master clocks to wait */
|
||||
int column; /* Index of column to display */
|
||||
uint32_t cta; /* Column table pointer in memory */
|
||||
uint32_t fbDest; /* Output frame pixel address */
|
||||
uint32_t fbSrc; /* Source frame buffer address */
|
||||
int32_t repeat; /* Current column table repeat value */
|
||||
int step; /* Processing phase */
|
||||
} dp;
|
||||
|
||||
/* Pixel processor */
|
||||
struct {
|
||||
uint8_t f0bsy; /* Drawing into frame buffer 0 */
|
||||
uint8_t f1bsy; /* Drawing into frame buffer 1 */
|
||||
@@ -119,7 +132,7 @@ struct VB {
|
||||
uint8_t sbcount; /* Current vertical output position */
|
||||
uint8_t sbout; /* Drawing specified vertical output position */
|
||||
uint8_t xpen; /* Drawing enabled */
|
||||
} xpctrl;
|
||||
} xp;
|
||||
|
||||
/* Control state */
|
||||
uint8_t bkcol; /* Backdrop color */
|
||||
@@ -131,8 +144,11 @@ 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];
|
||||
|
||||
/* Other state */
|
||||
uint8_t vram[0x40000]; /* Video memory */
|
||||
uint8_t ram[0x40000]; /* Video memory */
|
||||
} vip;
|
||||
|
||||
/* Other state */
|
||||
@@ -142,6 +158,7 @@ struct VB {
|
||||
vbOnException onException; /* CPU exception */
|
||||
vbOnExecute onExecute; /* CPU instruction execute */
|
||||
vbOnFetch onFetch; /* CPU instruction fetch */
|
||||
vbOnFrame onFrame; /* VIP frame ready */
|
||||
vbOnRead onRead; /* CPU instruction read */
|
||||
vbOnWrite onWrite; /* CPU instruction write */
|
||||
void *tag; /* User data */
|
||||
@@ -242,21 +259,26 @@ VBAPI void* vbGetCartROM(VB *sim, uint32_t *size) {
|
||||
return sim->cart.rom;
|
||||
}
|
||||
|
||||
/* Retrieve the exception callback handle */
|
||||
/* Retrieve the exception callback handler */
|
||||
VBAPI vbOnException vbGetExceptionCallback(VB *sim) {
|
||||
return sim->onException;
|
||||
}
|
||||
|
||||
/* Retrieve the execute callback handle */
|
||||
/* Retrieve the execute callback handler */
|
||||
VBAPI vbOnExecute vbGetExecuteCallback(VB *sim) {
|
||||
return sim->onExecute;
|
||||
}
|
||||
|
||||
/* Retrieve the fetch callback handle */
|
||||
/* Retrieve the fetch callback handler */
|
||||
VBAPI vbOnFetch vbGetFetchCallback(VB *sim) {
|
||||
return sim->onFetch;
|
||||
}
|
||||
|
||||
/* Retrieve the frame callback handler */
|
||||
VBAPI vbOnFrame vbGetFrameCallback(VB *sim) {
|
||||
return sim->onFrame;
|
||||
}
|
||||
|
||||
/* Retrieve the value of the program counter */
|
||||
VBAPI uint32_t vbGetProgramCounter(VB *sim) {
|
||||
return sim->cpu.pc;
|
||||
@@ -267,7 +289,7 @@ VBAPI int32_t vbGetProgramRegister(VB *sim, int index) {
|
||||
return index < 1 || index > 31 ? 0 : sim->cpu.program[index];
|
||||
}
|
||||
|
||||
/* Retrieve the read callback handle */
|
||||
/* Retrieve the read callback handler */
|
||||
VBAPI vbOnRead vbGetReadCallback(VB *sim) {
|
||||
return sim->onRead;
|
||||
}
|
||||
@@ -282,7 +304,7 @@ VBAPI void* vbGetUserData(VB *sim) {
|
||||
return sim->tag;
|
||||
}
|
||||
|
||||
/* Retrieve the write callback handle */
|
||||
/* Retrieve the write callback handler */
|
||||
VBAPI vbOnWrite vbGetWriteCallback(VB *sim) {
|
||||
return sim->onWrite;
|
||||
}
|
||||
@@ -293,6 +315,7 @@ VBAPI VB* vbInit(VB *sim) {
|
||||
sim->cart.rom = NULL;
|
||||
sim->onExecute = NULL;
|
||||
sim->onFetch = NULL;
|
||||
sim->onFrame = NULL;
|
||||
sim->onRead = NULL;
|
||||
sim->onWrite = NULL;
|
||||
vbReset(sim);
|
||||
@@ -344,27 +367,34 @@ VBAPI int vbSetCartROM(VB *sim, void *rom, uint32_t size) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Specify a new exception callback handle */
|
||||
/* Specify a new exception callback handler */
|
||||
VBAPI vbOnException vbSetExceptionCallback(VB *sim, vbOnException callback) {
|
||||
vbOnException prev = sim->onException;
|
||||
sim->onException = callback;
|
||||
return prev;
|
||||
}
|
||||
|
||||
/* Specify a new execute callback handle */
|
||||
/* Specify a new execute callback handler */
|
||||
VBAPI vbOnExecute vbSetExecuteCallback(VB *sim, vbOnExecute callback) {
|
||||
vbOnExecute prev = sim->onExecute;
|
||||
sim->onExecute = callback;
|
||||
return prev;
|
||||
}
|
||||
|
||||
/* Specify a new fetch callback handle */
|
||||
/* Specify a new fetch callback handler */
|
||||
VBAPI vbOnFetch vbSetFetchCallback(VB *sim, vbOnFetch callback) {
|
||||
vbOnFetch prev = sim->onFetch;
|
||||
sim->onFetch = callback;
|
||||
return prev;
|
||||
}
|
||||
|
||||
/* Specify a new frame callback handler */
|
||||
VBAPI vbOnFrame vbSetFrameCallback(VB *sim, vbOnFrame callback) {
|
||||
vbOnFrame prev = sim->onFrame;
|
||||
sim->onFrame = callback;
|
||||
return prev;
|
||||
}
|
||||
|
||||
/* Specify a new value for the program counter */
|
||||
VBAPI uint32_t vbSetProgramCounter(VB *sim, uint32_t value) {
|
||||
sim->cpu.operation = CPU_FETCH;
|
||||
@@ -378,7 +408,7 @@ VBAPI int32_t vbSetProgramRegister(VB *sim, int index, int32_t value) {
|
||||
return index < 1 || index > 31 ? 0 : (sim->cpu.program[index] = value);
|
||||
}
|
||||
|
||||
/* Specify a new read callback handle */
|
||||
/* Specify a new read callback handler */
|
||||
VBAPI vbOnRead vbSetReadCallback(VB *sim, vbOnRead callback) {
|
||||
vbOnRead prev = sim->onRead;
|
||||
sim->onRead = callback;
|
||||
@@ -391,7 +421,7 @@ VBAPI uint32_t vbSetSystemRegister(VB *sim, int index, uint32_t value) {
|
||||
cpuSetSystemRegister(sim, index, value, 1);
|
||||
}
|
||||
|
||||
/* Specify a new write callback handle */
|
||||
/* Specify a new write callback handler */
|
||||
VBAPI vbOnWrite vbSetWriteCallback(VB *sim, vbOnWrite callback) {
|
||||
vbOnWrite prev = sim->onWrite;
|
||||
sim->onWrite = callback;
|
||||
|
||||
Reference in New Issue
Block a user