#define DEBUG(...)
#endif
-uint8_t busy = 0, rtg_on = 0, rtg_initialized = 0, emulator_exiting = 0;
+uint8_t busy = 0, rtg_on = 0, rtg_initialized = 0, emulator_exiting = 0, rtg_output_in_vblank = 0;
extern uint8_t *rtg_mem;
extern uint32_t framebuffer_addr;
extern uint32_t framebuffer_addr_adj;
raylib_texture = LoadTextureFromImage(raylib_fb);
+ printf("Loaded framebuffer texture.\n");
+
srcrect.x = srcrect.y = 0;
srcrect.width = width;
srcrect.height = height;
while (1) {
if (rtg_on) {
BeginDrawing();
+ rtg_output_in_vblank = 0;
updating_screen = 1;
switch (format) {
}
EndDrawing();
+ rtg_output_in_vblank = 1;
if (format == RTGFMT_RBG565) {
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
uint8_t realtime_graphics_debug = 0;
extern int cpu_emulation_running;
extern struct emulator_config *cfg;
-extern uint8_t rtg_on;
+extern uint8_t rtg_on, rtg_output_in_vblank;
//#define DEBUG_RTG
unsigned int rtg_read(uint32_t address, uint8_t mode) {
//printf("%s read from RTG: %.8X\n", op_type_names[mode], address);
- if (address == RTG_COMMAND) {
- return 0xFFCF;
- }
if (address >= PIGFX_REG_SIZE) {
if (rtg_mem && (address - PIGFX_REG_SIZE) < PIGFX_UPPER) {
switch (mode) {
}
}
}
+ switch (address) {
+ case RTG_COMMAND:
+ return 0xFFCF;
+ case RTG_WAITVSYNC:
+ // fallthrough
+ case RTG_INVBLANK:
+ return !rtg_on || rtg_output_in_vblank;
+ default:
+ break;
+ }
return 0;
}
void SetReadPlane (__REGA0(struct BoardInfo *b), __REGD0(UBYTE plane));
void WaitVerticalSync (__REGA0(struct BoardInfo *b), __REGD0(BOOL toggle));
+BOOL GetVSyncState(__REGA0(struct BoardInfo *b), __REGD0(BOOL toggle));
void FillRect (__REGA0(struct BoardInfo *b), __REGA1(struct RenderInfo *r), __REGD0(WORD x), __REGD1(WORD y), __REGD2(WORD w), __REGD3(WORD h), __REGD4(ULONG color), __REGD5(UBYTE mask), __REGD7(RGBFTYPE format));
void InvertRect (__REGA0(struct BoardInfo *b), __REGA1(struct RenderInfo *r), __REGD0(WORD x), __REGD1(WORD y), __REGD2(WORD w), __REGD3(WORD h), __REGD4(UBYTE mask), __REGD7(RGBFTYPE format));
//b->SetSplitPosition = (void *)NULL;
//b->ReInitMemory = (void *)NULL;
//b->WriteYUVRect = (void *)NULL;
- //b->GetVSyncState = (void *)NULL;
+ b->GetVSyncState = (void *)GetVSyncState;
//b->GetVBeamPos = (void *)NULL;
//b->SetDPMSLevel = (void *)NULL;
//b->ResetChip = (void *)NULL;
void SetReadPlane (__REGA0(struct BoardInfo *b), __REGD0(UBYTE plane)) {
}
+static uint16_t vblank;
+
void WaitVerticalSync (__REGA0(struct BoardInfo *b), __REGD0(BOOL toggle)) {
- // I don't know why this one has a bool in D0, but it isn't used for anything.
+ vblank = 0;
+ do {
+ READSHORT(RTG_WAITVSYNC, vblank);
+ } while (!vblank);
+}
+
+BOOL GetVSyncState(__REGA0(struct BoardInfo *b), __REGD0(BOOL toggle)) {
+ READSHORT(RTG_INVBLANK, vblank);
+ return vblank;
}
void FillRect (__REGA0(struct BoardInfo *b), __REGA1(struct RenderInfo *r), __REGD0(WORD x), __REGD1(WORD y), __REGD2(WORD w), __REGD3(WORD h), __REGD4(ULONG color), __REGD5(UBYTE mask), __REGD7(RGBFTYPE format)) {