Skip to content

Commit 3e9554d

Browse files
committed
Automatic detection of multi-disk / multi-tape content
Use known patterns (e.g. TOSEC, CPC-Clean-DB) to detect and automatically add the rest of the disk/tape images when opening the first one in set. Disk/tape changing is still manual.
1 parent 657980c commit 3e9554d

File tree

2 files changed

+86
-3
lines changed

2 files changed

+86
-3
lines changed

core/core.hpp

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,45 @@ const std::string locale_identifiers[LOCALE_AMOUNT] = {
224224
"(uk)", "[req zrom]", "[req brd-rom]", "(es)", "(fr)"
225225
};
226226

227+
const std::multimap<std::string, std::string> multidisk_replacements = {
228+
{"Tape 1 of 2 Side A" , "Tape 2 of 2 Side B"},
229+
{"Tape 1 of 4 Side A" , "Tape 2 of 4 Side B"},
230+
{"Tape 1 of 4 Side A" , "Tape 3 of 4 Side A"},
231+
{"Tape 1 of 4 Side A" , "Tape 4 of 4 Side B"},
232+
{"Tape 1 of" , "Tape 2 of"},
233+
{"Tape 1 of" , "Tape 3 of"},
234+
{"Tape 1 of" , "Tape 4 of"},
235+
{"Tape 1 of" , "Tape 5 of"},
236+
{"Tape 1 of" , "Tape 6 of"},
237+
{"Tape 1 of" , "Tape 7 of"},
238+
{"Tape 1 of" , "Tape 8 of"},
239+
{"Tape 1 of" , "Tape 9 of"},
240+
{"Tape 1 of" , "Tape 10 of"},
241+
{"Disk 1 Side A" , "Disk 1 Side B"},
242+
{"Disk 1 Side A" , "Disk 2 Side A"},
243+
{"Disk 1 Side A" , "Disk 2 Side B"},
244+
{"Disk 1 Side A" , "Disk 3 Side A"},
245+
{"Disk 1 Side A" , "Disk 3 Side B"},
246+
{"Disk 1A" , "Disk 1B"},
247+
{"Disk 1A" , "Disk 2A"},
248+
{"Disk 1A" , "Disk 2B"},
249+
{"Disk 1A" , "Disk 3A"},
250+
{"Disk 1A" , "Disk 3B"},
251+
{"Disk 1 of" , "Disk 2 of"},
252+
{"Disk 1 of" , "Disk 3 of"},
253+
{"Disk 1 of" , "Disk 4 of"},
254+
{"Disk 1 of" , "Disk 5 of"},
255+
{"Disk 1 of" , "Disk 6 of"},
256+
{"Side 1A" , "Side 1B"},
257+
{"Side 1A" , "Side 2A"},
258+
{"Side 1A" , "Side 2B"},
259+
{"Side 1A" , "Side 3A"},
260+
{"Side 1A" , "Side 3B"},
261+
{"Side 1A" , "Side 4A"},
262+
{"Side 1A" , "Side 4B"},
263+
{"Side A" , "Side B"},
264+
};
265+
227266
class LibretroCore
228267
{
229268
private:

core/main.cpp

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ EP Mouse support
4141
achievement support
4242
test mp3 support with sndfile 1.1 - cmake won't find lame / mpeg123 when compiling libsndfile
4343
led driver for tape / disk loading - see comments inside
44-
name-based autodetect for multi-disk, multi-tape interface support (cpc 3 guerra)
4544
4645
*/
4746

@@ -115,7 +114,7 @@ bool maxUsersSupported = true;
115114

116115
unsigned diskIndex = 0;
117116
unsigned diskCount = 1;
118-
#define MAX_DISK_COUNT 6
117+
#define MAX_DISK_COUNT 10
119118
std::string diskPaths[MAX_DISK_COUNT];
120119
std::string diskNames[MAX_DISK_COUNT];
121120
bool diskEjected = false;
@@ -418,6 +417,48 @@ static bool get_image_label_cb(unsigned index, char *label, size_t len) {
418417
return true;
419418
}
420419

420+
static bool add_new_image_auto(const char *path) {
421+
422+
unsigned index = diskCount;
423+
if (diskCount >= MAX_DISK_COUNT) return false;
424+
diskCount++;
425+
log_cb(RETRO_LOG_DEBUG, "Disk control: add new image (%d) as %s\n",diskCount,path);
426+
427+
diskPaths[index] = path;
428+
std::string contentPath;
429+
Ep128Emu::splitPath(diskPaths[index],contentPath,diskNames[index]);
430+
return true;
431+
}
432+
433+
static void scan_multidisk_files(const char *path) {
434+
435+
std::string filename(path);
436+
std::string filePrefix;
437+
std::string filePostfix;
438+
std::string additionalFile;
439+
std::map< std::string, std::string >::const_iterator iter_multidisk;
440+
441+
for (iter_multidisk = Ep128Emu::multidisk_replacements.begin(); iter_multidisk != Ep128Emu::multidisk_replacements.end(); ++iter_multidisk)
442+
{
443+
size_t idx = filename.rfind((*iter_multidisk).first);
444+
if(idx != std::string::npos) {
445+
filePrefix = filename.substr(0,idx);
446+
filePostfix = filename.substr(idx+(*iter_multidisk).first.length());
447+
additionalFile = filePrefix + (*iter_multidisk).second.c_str() + filePostfix;
448+
449+
if(Ep128Emu::does_file_exist(additionalFile.c_str()))
450+
{
451+
log_cb(RETRO_LOG_INFO, "Multidisk additional file found: %s => %s\n",filename.c_str(), additionalFile.c_str());
452+
if (!add_new_image_auto(additionalFile.c_str())) {
453+
log_cb(RETRO_LOG_WARN, "Multidisk additional image add unsuccessful: %s\n",additionalFile.c_str());
454+
break;
455+
}
456+
}
457+
}
458+
}
459+
}
460+
461+
421462

422463
void retro_init(void)
423464
{
@@ -579,7 +620,7 @@ void retro_get_system_info(struct retro_system_info *info)
579620
{
580621
memset(info, 0, sizeof(*info));
581622
info->library_name = "ep128emu";
582-
info->library_version = "v1.2.4";
623+
info->library_version = "v1.2.5";
583624
info->need_fullpath = true;
584625
info->valid_extensions = "img|dsk|tap|dtf|com|trn|128|bas|cas|cdt|tzx|wav|tvcwav|.";
585626
}
@@ -1006,6 +1047,9 @@ bool retro_load_game(const struct retro_game_info *info)
10061047
/* tape = openTapeFile(fileName.c_str(), 0,
10071048
defaultTapeSampleRate, bitsPerSample);*/
10081049
}
1050+
if (diskContent || tapeContent) {
1051+
scan_multidisk_files(info->path);
1052+
}
10091053
if (fileContent)
10101054
{
10111055
config->fileio.workingDirectory = contentPath;

0 commit comments

Comments
 (0)