+// Function to add crosshairs
+static void addCrosshair(int port, int crosshair_color, unsigned short *buffer, int bufferStride, int pos_x, int pos_y, int thickness, int size_x, int size_y) {
+ for (port = 0; port < 2; port++) {
+ // Draw the horizontal line of the crosshair
+ for (int i = pos_y - thickness / 2; i <= pos_y + thickness / 2; i++) {
+ for (int j = pos_x - size_x / 2; j <= pos_x + size_x / 2; j++) {
+ if ((i + vout_height) >= 0 && (i + vout_height) < bufferStride && j >= 0 && j < bufferStride && in_enable_crosshair[port] > 0)
+ buffer[i * bufferStride + j] = crosshair_color;
+ }
+ }
+
+ // Draw the vertical line of the crosshair
+ for (int i = pos_x - thickness / 2; i <= pos_x + thickness / 2; i++) {
+ for (int j = pos_y - size_y / 2; j <= pos_y + size_y / 2; j++) {
+ if (i >= 0 && i < bufferStride && (j + vout_height) >= 0 && (j + vout_height) < bufferStride && in_enable_crosshair[port] > 0)
+ buffer[j * bufferStride + i] = crosshair_color;
+ }
+ }
+ }
+}
+
+struct CrosshairInfo {
+ int pos_x, pos_y, thickness, size_x, size_y;
+};
+
+// Calculate size and position of crosshairs
+static void CrosshairDimensions(int port, struct CrosshairInfo *info) {
+ int gunx = input_state_cb(port, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X);
+ int guny = input_state_cb(port, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y);
+ if (gunx == 32767) // Prevent crosshairs from wrapping around right side of screen to left
+ info->pos_x = (gunx + 32767.0f) * vout_width / 65534.0f - 0.5f;
+ else
+ info->pos_x = (gunx + 32767.0f) * vout_width / 65534.0f;
+ info->pos_y = (guny + 32767.0f) * vout_height / 65534.0f - vout_height;
+ info->thickness = pl_rearmed_cbs.gpu_neon.enhancement_enable ? 4 : 2;
+ info->size_x = psx_w * (pl_rearmed_cbs.gpu_neon.enhancement_enable ? 2 : 1) / 40.0f;
+ info->size_y = psx_h * (pl_rearmed_cbs.gpu_neon.enhancement_enable ? 2 : 1) * (4.0f / 3.0f) / 40.0f;
+}
+
+static void vout_flip(const void *vram, int stride, int bgr24,
+ int x, int y, int w, int h, int dims_changed)