From dfcd8e05be5c6c6cebf0c3d9632acce5da3546e5 Mon Sep 17 00:00:00 2001 From: Brendan Saricks Date: Thu, 20 Nov 2025 06:30:29 +0100 Subject: [PATCH] video: Rotation Direction in SPD (#1065) --- support/arcade/mra_loader.cpp | 29 +++++++++++++++++++++++++++++ support/arcade/mra_loader.h | 1 + video.cpp | 3 ++- 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/support/arcade/mra_loader.cpp b/support/arcade/mra_loader.cpp index f5b430b..ccaf2f9 100644 --- a/support/arcade/mra_loader.cpp +++ b/support/arcade/mra_loader.cpp @@ -55,6 +55,7 @@ static char mame_root[kBigTextSize]; static char arcade_setname[kBigTextSize] = {}; static bool is_vertical = false; +static int rotation_dir = 0; // 0 = None, 1 = CW, 2 = CCW static sw_struct switches = {}; @@ -1057,6 +1058,7 @@ static int xml_read_pre_parse(XMLEvent evt, const XMLNode* node, SXML_CHAR* text foundsetname = false; foundrotation = false; samedir = 0; + rotation_dir = 0; break; case XML_EVENT_START_NODE: @@ -1087,6 +1089,28 @@ static int xml_read_pre_parse(XMLEvent evt, const XMLNode* node, SXML_CHAR* text if(inrotation) { is_vertical = strncasecmp(text, "vertical", 8) == 0; + + rotation_dir = 0; + if (is_vertical) + { + // Check for CCW first (must check before CW since "ccw" contains "cw") + if (strstr(text, "ccw") || strstr(text, "CCW") || + strstr(text, "counterclockwise") || strstr(text, "counter-clockwise")) + { + rotation_dir = 2; + } + // Then check for CW + else if (strstr(text, "cw") || strstr(text, "CW") || + strstr(text, "clockwise")) + { + rotation_dir = 1; + } + // Default to CW if no direction specified + else + { + rotation_dir = 1; // Fallback to CW if no direction is declared + } + } } break; @@ -1172,6 +1196,11 @@ bool arcade_is_vertical() return is_vertical; } +int arcade_get_direction() +{ + return rotation_dir; +} + void arcade_check_error() { if (arcade_error_msg[0] != 0) { diff --git a/support/arcade/mra_loader.h b/support/arcade/mra_loader.h index 9982174..529f616 100644 --- a/support/arcade/mra_loader.h +++ b/support/arcade/mra_loader.h @@ -64,6 +64,7 @@ void arcade_sw_load(); void arcade_pre_parse(const char *xml); bool arcade_is_vertical(); +int arcade_get_direction(); void arcade_nvm_save(); diff --git a/video.cpp b/video.cpp index 03528c7..34040e8 100644 --- a/video.cpp +++ b/video.cpp @@ -28,6 +28,7 @@ #include "offload.h" #include "support.h" +#include "support/arcade/mra_loader.h" #include "lib/imlib2/Imlib2.h" #include "lib/md5/md5.h" @@ -2969,7 +2970,7 @@ static void spd_config_update() cfg.direct_video ? 'D' : 'V', cfg.direct_video ? 'V' : 'I', cfg.direct_video ? '1' : '1', // version - (uint8_t)((vi->interlaced ? 1 : 0) | (menu_present() ? 4 : 0) | (vi->rotated ? 8 : 0)), + (uint8_t)((vi->interlaced ? 1 : 0) | (menu_present() ? 4 : 0) | (vi->rotated ? 8 : 0) | (cfg.direct_video ? (arcade_get_direction() << 4) : 0)), (uint8_t)(vi->pixrep ? vi->pixrep : (vi->ctime / vi->width)), (uint8_t)vi->de_h, (uint8_t)(vi->de_h >> 8),