summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZephiles <cae222@yahoo.com>2022-05-06 17:15:18 -0500
committerZephiles <cae222@yahoo.com>2022-05-06 17:15:18 -0500
commit785076c57b7a9fa04b6ecb798e14d701121d90e1 (patch)
treebeb8caf1611df0c373a3dd450d68879b07c2623f
parent0c3674e3ce5e570c17bb5fe2e62a8243d23d838e (diff)
Only mount/unmount the memory card once when generating the list of seeds
-rw-r--r--GameCube/source/rando/seedlist.cpp39
1 files changed, 23 insertions, 16 deletions
diff --git a/GameCube/source/rando/seedlist.cpp b/GameCube/source/rando/seedlist.cpp
index a0bf047b..e5eac628 100644
--- a/GameCube/source/rando/seedlist.cpp
+++ b/GameCube/source/rando/seedlist.cpp
@@ -37,31 +37,38 @@ namespace mod::rando
m_numSeeds = 0;
- for ( uint8_t i = 0; i < SEED_MAX_ENTRIES; i++ )
+ // Only mount/unmount the memory card once
+ constexpr int32_t memCardChan = CARD_SLOT_A;
+ if ( CARD_RESULT_READY == libtp::tools::mountMemoryCard( memCardChan ) )
{
- // Check next filename depending on i
- // rando-data0, rando-data1, ...
- filename[10] = static_cast<char>( '0' + i );
-
- Header header;
-
- if ( CARD_RESULT_READY == libtp::tools::ReadGCI( CARD_SLOT_A, filename, sizeof( header ), 0, &header, false ) )
+ for ( uint8_t i = 0; i < SEED_MAX_ENTRIES; i++ )
{
- uint16_t minVersion = header.minVersion;
- uint16_t maxVersion = header.maxVersion;
+ // Check next filename depending on i
+ // rando-data0, rando-data1, ...
+ filename[10] = static_cast<char>( '0' + i );
- uint16_t version = static_cast<uint16_t>( _VERSION_MAJOR << 8 | _VERSION_MINOR );
- if ( minVersion <= version )
+ Header header;
+
+ if ( CARD_RESULT_READY ==
+ libtp::tools::ReadGCIMounted( memCardChan, filename, sizeof( header ), 0, &header, false ) )
{
- if ( maxVersion >= version )
+ uint16_t minVersion = header.minVersion;
+ uint16_t maxVersion = header.maxVersion;
+
+ uint16_t version = static_cast<uint16_t>( _VERSION_MAJOR << 8 | _VERSION_MINOR );
+ if ( minVersion <= version )
{
- seedIDX = seedIDX | ( 1 << i );
- memcpy( &headerBuffer[i], &header, sizeof( Header ) );
+ if ( maxVersion >= version )
+ {
+ seedIDX = seedIDX | ( 1 << i );
+ memcpy( &headerBuffer[i], &header, sizeof( Header ) );
- m_numSeeds++;
+ m_numSeeds++;
+ }
}
}
}
+ libtp::gc_wii::card::CARDUnmount( memCardChan );
}
if ( m_numSeeds > 0 )