+ int x = g_layer_x, y = g_layer_y;
+ int w = g_layer_w, h = g_layer_h;
+
+ // it's not allowed for the layer to be partially offscreen,
+ // instead it is faked by plat_gvideo_set_mode()
+ if (x < 0) { w += x; x = 0; }
+ if (y < 0) { h += y; y = 0; }
+ if (x + w > 800) w = 800 - x;
+ if (y + h > 480) h = 480 - y;
+