BACKENDS: Allow for specifying a drive via the cdrom option

This commit is contained in:
Matthew Hoops 2015-10-01 19:12:07 -04:00 committed by Johannes Schickel
parent e39faa239a
commit 1626fbd633
3 changed files with 30 additions and 3 deletions

View File

@ -155,5 +155,19 @@ DefaultAudioCDManager::Status DefaultAudioCDManager::getStatus() const {
}
bool DefaultAudioCDManager::openCD() {
return openCD(ConfMan.getInt("cdrom"));
Common::String cdrom = ConfMan.get("cdrom");
// Try to parse it as an int
char *endPos;
int drive = strtol(cdrom.c_str(), &endPos, 0);
// If not an integer, treat as a drive path
if (endPos == cdrom.c_str())
return openCD(cdrom);
if (drive < 0)
return false;
return openCD(drive);
}

View File

@ -26,6 +26,10 @@
#include "backends/audiocd/audiocd.h"
#include "audio/mixer.h"
namespace Common {
class String;
} // End of namespace Common
/**
* The default audio cd manager. Implements emulation of audio cd playback.
*/
@ -51,12 +55,20 @@ public:
* @note The index is implementation-defined, but 0 is always the best choice
*/
virtual bool openCD(int drive) { return false; }
virtual void updateCD() {}
virtual bool pollCD() const { return false; }
virtual void playCD(int track, int num_loops, int start_frame, int duration) {}
virtual void stopCD() {}
protected:
/**
* Open a CD from a specific drive
* @param drive The name of the drive/path
* @note The drive parameter is platform-specific
*/
virtual bool openCD(const Common::String &drive) { return false; }
Audio::SoundHandle _handle;
bool _emulating;

View File

@ -100,8 +100,9 @@ static const char HELP_STRING[] =
" -u, --dump-scripts Enable script dumping if a directory called 'dumps'\n"
" exists in the current directory\n"
"\n"
" --cdrom=NUM CD drive to play CD audio from (default: 0 = first\n"
" drive)\n"
" --cdrom=DRIVE CD drive to play CD audio from; can either be a\n"
" drive, path, or numeric index (default: 0 = best\n"
" choice drive)\n"
" --joystick[=NUM] Enable joystick input (default: 0 = first joystick)\n"
" --platform=WORD Specify platform of game (allowed values: 2gs, 3do,\n"
" acorn, amiga, atari, c64, fmtowns, nes, mac, pc, pc98,\n"