mirror of
https://github.com/holub/mame
synced 2025-07-04 17:38:08 +03:00
nscsi cd: Don't crash on certain commands when no cdrom is inserted
This commit is contained in:
parent
46df3e7640
commit
badecba0e3
@ -311,13 +311,13 @@ void nscsi_cdrom_device::scsi_command()
|
|||||||
}
|
}
|
||||||
|
|
||||||
case SC_READ_CAPACITY: {
|
case SC_READ_CAPACITY: {
|
||||||
|
LOG("command READ CAPACITY\n");
|
||||||
|
|
||||||
if(!cdrom) {
|
if(!cdrom) {
|
||||||
return_no_cd();
|
return_no_cd();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG("command READ CAPACITY\n");
|
|
||||||
|
|
||||||
// get the last used block on the disc
|
// get the last used block on the disc
|
||||||
const u32 temp = cdrom->get_track_start(0xaa) * (bytes_per_sector / bytes_per_block) - 1;
|
const u32 temp = cdrom->get_track_start(0xaa) * (bytes_per_sector / bytes_per_block) - 1;
|
||||||
|
|
||||||
@ -365,7 +365,7 @@ void nscsi_cdrom_device::scsi_command()
|
|||||||
scsi_cmdbuf[pos++] = 0x80; // WP, cache
|
scsi_cmdbuf[pos++] = 0x80; // WP, cache
|
||||||
|
|
||||||
// get the last used block on the disc
|
// get the last used block on the disc
|
||||||
const u32 temp = cdrom->get_track_start(0xaa) * (bytes_per_sector / bytes_per_block) - 1;
|
const u32 temp = cdrom ? cdrom->get_track_start(0xaa) * (bytes_per_sector / bytes_per_block) - 1 : 0;
|
||||||
scsi_cmdbuf[pos++] = 0x08; // Block descriptor length
|
scsi_cmdbuf[pos++] = 0x08; // Block descriptor length
|
||||||
|
|
||||||
scsi_cmdbuf[pos++] = 0x00; // density code
|
scsi_cmdbuf[pos++] = 0x00; // density code
|
||||||
@ -463,6 +463,11 @@ void nscsi_cdrom_device::scsi_command()
|
|||||||
|
|
||||||
case SC_READ_DISC_INFORMATION:
|
case SC_READ_DISC_INFORMATION:
|
||||||
LOG("command READ DISC INFORMATION\n");
|
LOG("command READ DISC INFORMATION\n");
|
||||||
|
if(!cdrom) {
|
||||||
|
return_no_cd();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
std::fill_n(scsi_cmdbuf, 34, 0);
|
std::fill_n(scsi_cmdbuf, 34, 0);
|
||||||
scsi_cmdbuf[1] = 32;
|
scsi_cmdbuf[1] = 32;
|
||||||
scsi_cmdbuf[2] = 2; // disc is complete
|
scsi_cmdbuf[2] = 2; // disc is complete
|
||||||
@ -538,6 +543,11 @@ void nscsi_cdrom_device::scsi_command()
|
|||||||
|
|
||||||
LOG("command READ TOC PMA ATIP, format %s msf=%d size=%d\n", format_names[format], msf, size);
|
LOG("command READ TOC PMA ATIP, format %s msf=%d size=%d\n", format_names[format], msf, size);
|
||||||
|
|
||||||
|
if(!cdrom) {
|
||||||
|
return_no_cd();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
switch (format) {
|
switch (format) {
|
||||||
case 0: {
|
case 0: {
|
||||||
|
Loading…
Reference in New Issue
Block a user