+ g_layer_x = g_menuscreen_w / 2 - g_layer_w / 2;
+ g_layer_y = g_menuscreen_h / 2 - g_layer_h / 2;
+ if (g_layer_x < 0) g_layer_x = 0;
+ if (g_layer_y < 0) g_layer_y = 0;
+ if (g_layer_w > g_menuscreen_w) g_layer_w = g_menuscreen_w;
+ if (g_layer_h > g_menuscreen_h) g_layer_h = g_menuscreen_h;
+}
+
+static void *pl_vout_set_mode(int w, int h, int bpp)
+{
+ // special h handling, Wipeout likes to change it by 1-6
+ static int vsync_cnt_ms_prev;
+ if ((unsigned int)(vsync_cnt - vsync_cnt_ms_prev) < 5*60)
+ h = (h + 7) & ~7;
+ vsync_cnt_ms_prev = vsync_cnt;
+
+ if (w == psx_w && h == psx_h && bpp == psx_bpp)
+ return pl_vout_buf;
+
+ pl_vout_w = psx_w = w;
+ pl_vout_h = psx_h = h;
+ pl_vout_bpp = psx_bpp = bpp;
+
+ update_layer_size(pl_vout_w, pl_vout_h);
+
+ pl_vout_buf = plat_gvideo_set_mode(&pl_vout_w, &pl_vout_h, &pl_vout_bpp);
+ if (pl_vout_buf == NULL && pl_rearmed_cbs.pl_vout_raw_flip == NULL)
+ fprintf(stderr, "failed to set mode %dx%d@%d\n",
+ psx_w, psx_h, psx_bpp);
+
+ menu_notify_mode_change(pl_vout_w, pl_vout_h, pl_vout_bpp);
+
+ return pl_vout_buf;
+}
+
+// only used if raw flip is not defined
+static void *pl_vout_flip(void)
+{
+ pl_rearmed_cbs.flip_cnt++;
+
+ if (pl_vout_buf != NULL)
+ pl_print_hud(0);
+