Skip to content

Commit

Permalink
cdrom: implemented cmdGetparam #66
Browse files Browse the repository at this point in the history
  • Loading branch information
JaCzekanski committed Jan 19, 2020
1 parent 85d7a60 commit 356191e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/device/cdrom/cdrom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ void CDROM::handleCommand(uint8_t cmd) {
case 0x0c: cmdDemute(); break;
case 0x0d: cmdSetFilter(); break;
case 0x0e: cmdSetmode(); break;
// Missing 0x0f cmdGetparam
case 0x0f: cmdGetparam(); break;
case 0x10: cmdGetlocL(); break;
case 0x11: cmdGetlocP(); break;
case 0x12: cmdSetSession(); break;
Expand Down
1 change: 1 addition & 0 deletions src/device/cdrom/cdrom.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ class CDROM {
void cmdDemute();
void cmdSetFilter();
void cmdSetmode();
void cmdGetparam();
void cmdGetlocL();
void cmdGetlocP();
void cmdGetTN();
Expand Down
25 changes: 22 additions & 3 deletions src/device/cdrom/commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,17 @@ void CDROM::cmdSetmode() {
if (verbose) fmt::print("CDROM: cmdSetmode(0x{:02x})\n", setmode);
}

void CDROM::cmdGetparam() {
postInterrupt(3);
writeResponse(stat._reg);
writeResponse(mode._reg);
writeResponse(0x00);
writeResponse(filter.file);
writeResponse(filter.channel);

if (verbose) fmt::print("CDROM: cmdGetparam({})\n", dumpFifo(CDROM_response));
}

void CDROM::cmdSetSession() {
uint8_t session = readParam();

Expand Down Expand Up @@ -196,14 +207,15 @@ void CDROM::cmdGetlocL() {
if (verbose) {
fmt::print(
"CDROM: cmdGetlocL -> ("
"pos = (0x{:02x}:0x{:02x}:0x{:02x}), ",
"pos = (0x{:02x}:0x{:02x}:0x{:02x}), "
"mode = 0x{:x}, "
"file = 0x{:x}, "
"channel = 0x{:x}, "
"submode = 0x{:x}, "
"ci = 0x{:x}"
")\n",
CDROM_response[0], CDROM_response[1], CDROM_response[2], CDROM_response[3], CDROM_response[4], CDROM_response[5],
CDROM_response[0], CDROM_response[1], CDROM_response[2], //
CDROM_response[3], CDROM_response[4], CDROM_response[5], //
CDROM_response[6], CDROM_response[7]);
}
}
Expand Down Expand Up @@ -306,6 +318,13 @@ void CDROM::cmdTest() {
writeResponse(0x09);
writeResponse(0x19);
writeResponse(0xc0);
} else if (opcode == 0x22) { // Get CDROM BIOS region
// Simulate SCEA bios
postInterrupt(3);
const std::string region = "for U/C";
for (auto c : region) {
writeResponse(c);
}
} else {
fmt::print("CDROM: Unimplemented test opcode (0x{:x})!\n", opcode);
postInterrupt(5);
Expand All @@ -331,7 +350,7 @@ void CDROM::cmdGetId() {
// No CD
if (disc->getTrackCount() == 0) {
postInterrupt(5);
writeResponse(0x08);
writeResponse(stat._reg);
writeResponse(0x40);
for (int i = 0; i < 6; i++) writeResponse(0);
}
Expand Down

0 comments on commit 356191e

Please sign in to comment.