30 virtual void execute(
const std::vector<TclObject>& tokens,
32 virtual string help(
const vector<string>& tokens)
const;
39 static const unsigned MAX_CD = 26;
45 , motherBoard(config.getMotherBoard())
48 if (info.counter == 0) {
53 auto& cdInUse = *
reinterpret_cast<CDInUse*
>(info.stuff);
62 name[2] = char(
'a' +
id);
64 cdxCommand = make_unique<CDXCommand>(
71 remMedStatNotifEnabled =
false;
82 auto& cdInUse = *
reinterpret_cast<CDInUse*
>(info.stuff);
85 unsigned id = name[2] -
'a';
90 if (info.counter == 0) {
91 assert(cdInUse.none());
104 static const std::string NAME =
"OPENMSX CD-ROM";
115 buffer[0 * 2 + 0] = 0xC4;
118 buffer[0 * 2 + 1] = 0x85;
121 buffer[ 83 * 2 + 0] = 0x10;
123 buffer[ 86 * 2 + 0] = remMedStatNotifEnabled * 0x10;
125 buffer[127 * 2 + 0] = 0x01;
130 assert(readSectorData);
133 file->seek(transferOffset);
134 file->read(buffer, count);
135 transferOffset += count;
155 executePacketCommand(buffer);
173 if (remMedStatNotifEnabled) {
186 mediaChanged =
false;
196 remMedStatNotifEnabled =
false;
204 remMedStatNotifEnabled =
true;
216 void IDECDROM::startPacketReadTransfer(
unsigned count)
223 unsigned packetSize = 512;
227 unsigned size = std::min(packetSize, count);
232 void IDECDROM::executePacketCommand(
byte* packet)
242 readSectorData =
false;
252 const int byteCount = 18;
253 startPacketReadTransfer(byteCount);
255 for (
int i = 0; i < byteCount; i++) {
259 buffer[2] = senseKey >> 16;
260 buffer[12] = (senseKey >> 8) & 0xFF;
261 buffer[13] = senseKey & 0xFF;
262 buffer[7] = byteCount - 7;
268 int format = packet[2] & 0x0F;
286 fprintf(stderr,
" read TOC: format %d not implemented\n", format);
292 int sectorNumber = Endian::read_UA_B32(&packet[2]);
293 int sectorCount = Endian::read_UA_B32(&packet[6]);
316 readSectorData =
true;
317 transferOffset = sectorNumber * 2048;
318 unsigned count = sectorCount * 2048;
319 startPacketReadTransfer(count);
324 fprintf(stderr,
" unknown packet command 0x%02X\n", packet[0]);
333 senseKey = 0x06 << 16;
339 file = make_unique<File>(filename);
341 senseKey = 0x06 << 16;
360 if (tokens.size() == 1) {
361 File* file = cd.file.get();
365 }
else if ( (tokens.size() == 2) && (
366 tokens[1].getString() ==
"eject" || tokens[1].getString() ==
"-eject" )) {
369 if ( tokens[1].getString() ==
"-eject" ) {
371 "Warning: use of '-eject' is deprecated, instead use the 'eject' subcommand");
373 }
else if ( (tokens.size() == 2) || ( (tokens.size() == 3) && tokens[1].getString() ==
"insert")) {
375 if (tokens[1].getString() ==
"insert") {
376 if (tokens.size() > 2) {
384 tokens[fileToken].getString().str());
398 return cd.name +
" : display the cd image for this CDROM drive\n" +
399 cd.name +
" eject : eject the cd image from this CDROM drive\n" +
400 cd.name +
" insert <filename> : change the cd image for this CDROM drive\n" +
401 cd.name +
" <filename> : change the cd image for this CDROM drive\n";
406 static const char*
const extra[] = {
"eject",
"insert" };
411 template<
typename Archive>
414 ar.template serializeBase<AbstractIDEDevice>(*this);
416 string filename = file.get() ? file->getURL() :
"";
417 ar.serialize(
"filename", filename);
420 if (filename.empty()) {
427 ar.serialize(
"byteCountLimit", byteCountLimit);
428 ar.serialize(
"transferOffset", transferOffset);
429 ar.serialize(
"senseKey", senseKey);
430 ar.serialize(
"readSectorData", readSectorData);
431 ar.serialize(
"remMedStatNotifEnabled", remMedStatNotifEnabled);
432 ar.serialize(
"mediaChanged", mediaChanged);