Merge pull request #72 from LinuxJedi/fix-rtg

Redo the DPMS patch
This commit is contained in:
beeanyew
2021-08-04 18:43:15 +02:00
committed by GitHub

View File

@@ -26,7 +26,7 @@
#define DEBUG(...)
#endif
uint8_t busy = 0, rtg_on = 0, rtg_initialized = 0, emulator_exiting = 0, rtg_output_in_vblank = 0, reinit = 0, rtg_dpms = 0;
uint8_t busy = 0, rtg_on = 0, rtg_initialized = 0, emulator_exiting = 0, rtg_output_in_vblank = 0, rtg_dpms = 0, shutdown = 0;
extern uint8_t *rtg_mem, display_enabled;
extern uint32_t framebuffer_addr;
extern uint32_t framebuffer_addr_adj;
@@ -193,7 +193,7 @@ void *rtgThread(void *args) {
printf("RTG thread running\n");
fflush(stdout);
int old_filter_mode = -1;
int reinit = 0, old_filter_mode = -1;
rtg_on = 1;
uint32_t *indexed_buf = NULL;
@@ -218,7 +218,6 @@ void *rtgThread(void *args) {
Texture raylib_clut_texture;
Image raylib_fb, raylib_cursor, raylib_clut;
reinit_raylib:;
InitWindow(GetScreenWidth(), GetScreenHeight(), "Pistorm RTG");
HideCursor();
SetTargetFPS(60);
@@ -245,6 +244,7 @@ reinit_raylib:;
raylib_cursor.data = cursor_data;
raylib_cursor_texture = LoadTextureFromImage(raylib_cursor);
reinit_raylib:;
if (reinit) {
printf("Reinitializing raylib...\n");
width = rtg_display_width;
@@ -365,7 +365,7 @@ reinit_raylib:;
DrawText("RTG is currently sleeping.", 16, 16, 12, RAYWHITE);
EndDrawing();
}
if (pitch != *data->pitch || height != *data->height || width != *data->width || format != *data->format || reinit) {
if (pitch != *data->pitch || height != *data->height || width != *data->width || format != *data->format) {
printf("Reinitializing due to something change.\n");
reinit = 1;
goto shutdown_raylib;
@@ -373,8 +373,12 @@ reinit_raylib:;
if (emulator_exiting) {
goto shutdown_raylib;
}
if (shutdown) {
break;
}
}
shutdown = 0;
rtg_initialized = 0;
printf("RTG thread shut down.\n");
@@ -407,11 +411,10 @@ void rtg_set_clut_entry(uint8_t index, uint32_t xrgb) {
void rtg_init_display() {
int err;
rtg_on = 1;
if (rtg_dpms) {
vc_tv_hdmi_power_on_preferred();
}
reinit = 1;
rtg_on = 1;
if (!rtg_initialized) {
err = pthread_create(&thread_id, NULL, &rtgThread, (void *)&rtg_share_data);
@@ -431,11 +434,13 @@ void rtg_init_display() {
void rtg_shutdown_display() {
printf("RTG display disabled.\n");
rtg_on = 0;
display_enabled = 0xFF;
if (rtg_dpms) {
shutdown = 1;
vc_tv_power_off();
}
rtg_on = 0;
display_enabled = 0xFF;
}
void rtg_enable_mouse_cursor() {