From fa05d20e0a491be3a77f4237777b0c04689a1fa5 Mon Sep 17 00:00:00 2001 From: Extrems Date: Fri, 24 May 2024 11:36:42 -0400 Subject: [PATCH] Dynamically apply Serial Port 1 feature bit --- gc/sdcard/gcsd.h | 6 +++--- libogc/gcsd.c | 24 +++++++++++++++++++----- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/gc/sdcard/gcsd.h b/gc/sdcard/gcsd.h index 09ddc189..8d6370a0 100644 --- a/gc/sdcard/gcsd.h +++ b/gc/sdcard/gcsd.h @@ -39,8 +39,8 @@ #define DEVICE_TYPE_GC_SD (('G'<<24)|('C'<<16)|('S'<<8)|'D') -extern const DISC_INTERFACE __io_gcsda; -extern const DISC_INTERFACE __io_gcsdb; -extern const DISC_INTERFACE __io_gcsd2; +extern DISC_INTERFACE __io_gcsda; +extern DISC_INTERFACE __io_gcsdb; +extern DISC_INTERFACE __io_gcsd2; #endif diff --git a/libogc/gcsd.c b/libogc/gcsd.c index 9de19289..ac28b987 100644 --- a/libogc/gcsd.c +++ b/libogc/gcsd.c @@ -124,7 +124,19 @@ static bool __gcsd_shutdown(int n) static bool __gcsda_startup(void) { - return __gcsd_startup(0); + bool ret; + + ret = __gcsd_startup(0); + + if(sdgecko_getDevice(0) == EXI_DEVICE_0) { + __io_gcsda.features |= FEATURE_GAMECUBE_SLOTA; + __io_gcsda.features &= ~FEATURE_GAMECUBE_PORT1; + } else { + __io_gcsda.features |= FEATURE_GAMECUBE_PORT1; + __io_gcsda.features &= ~FEATURE_GAMECUBE_SLOTA; + } + + return ret; } static bool __gcsda_isInserted(void) @@ -216,7 +228,7 @@ static bool __gcsd2_shutdown(void) return __gcsd_shutdown(2); } -const DISC_INTERFACE __io_gcsda = { +DISC_INTERFACE __io_gcsda = { DEVICE_TYPE_GC_SD, FEATURE_MEDIUM_CANREAD | FEATURE_MEDIUM_CANWRITE | FEATURE_GAMECUBE_SLOTA, __gcsda_startup, @@ -226,7 +238,8 @@ const DISC_INTERFACE __io_gcsda = { __gcsda_clearStatus, __gcsda_shutdown }; -const DISC_INTERFACE __io_gcsdb = { + +DISC_INTERFACE __io_gcsdb = { DEVICE_TYPE_GC_SD, FEATURE_MEDIUM_CANREAD | FEATURE_MEDIUM_CANWRITE | FEATURE_GAMECUBE_SLOTB, __gcsdb_startup, @@ -236,7 +249,8 @@ const DISC_INTERFACE __io_gcsdb = { __gcsdb_clearStatus, __gcsdb_shutdown }; -const DISC_INTERFACE __io_gcsd2 = { + +DISC_INTERFACE __io_gcsd2 = { DEVICE_TYPE_GC_SD, FEATURE_MEDIUM_CANREAD | FEATURE_MEDIUM_CANWRITE | FEATURE_GAMECUBE_PORT2, __gcsd2_startup, @@ -245,4 +259,4 @@ const DISC_INTERFACE __io_gcsd2 = { __gcsd2_writeSectors, __gcsd2_clearStatus, __gcsd2_shutdown -} ; +};