@@ -83,6 +83,7 @@ nscsi_cdrom_device::nscsi_cdrom_device(const machine_config &mconfig, device_typ
83
83
: nscsi_full_device(mconfig, type, tag, owner, clock)
84
84
, image(*this , " image" )
85
85
, cdda(*this , " cdda" )
86
+ , m_removal_prevented(false )
86
87
, bytes_per_block(bytes_per_sector)
87
88
, lba(0 )
88
89
, cur_sector(0 )
@@ -549,6 +550,7 @@ void nscsi_cdrom_device::scsi_command()
549
550
case SC_PREVENT_ALLOW_MEDIUM_REMOVAL:
550
551
// TODO: support eject prevention
551
552
LOG (" command %s MEDIUM REMOVAL\n " , (scsi_cmdbuf[4 ] & 0x1 ) ? " PREVENT" : " ALLOW" );
553
+ m_removal_prevented = BIT (scsi_cmdbuf[4 ], 0 );
552
554
scsi_status_complete (SS_GOOD);
553
555
break ;
554
556
@@ -883,11 +885,21 @@ void nscsi_cdrom_apple_device::device_start()
883
885
}
884
886
885
887
/*
886
- The Apple II SCSI Card firmware demands that ASC on a failing TEST_UNIT_READY be either 0x28 or 0xb0 .
887
- 0x28 is MEDIA_CHANGED, 0xb0 is vendor-specific. If the drive returns the normal 0x3A for disc-not-present,
888
+ The Apple II SCSI Card firmware demands that ASC on a failing TEST_UNIT_READY be either 0x28 or 0xB0 .
889
+ 0x28 is MEDIA_CHANGED, 0xB0 is vendor-specific. If the drive returns the normal 0x3A for disc-not-present,
888
890
the firmware assumes the drive is broken and retries the TEST_UNIT_READY for 60 seconds before giving up
889
891
and booting the machine.
892
+
893
+ MacOS will see the normal 0x3A disc-not-present and simply disbelieve it and hammer on the drive while
894
+ asking the user to format it because it's unreadable. 0xB0 makes it behave as expected.
890
895
*/
896
+
897
+ void nscsi_cdrom_apple_device::return_no_cd ()
898
+ {
899
+ sense (false , SK_NOT_READY, 0xb0 );
900
+ scsi_status_complete (SS_CHECK_CONDITION);
901
+ }
902
+
891
903
void nscsi_cdrom_apple_device::scsi_command ()
892
904
{
893
905
if (scsi_cmdbuf[0 ] != 8 && scsi_cmdbuf[0 ] != 0x28 && scsi_cmdbuf[0 ] != 0 && scsi_cmdbuf[0 ] != 0x03 )
@@ -908,8 +920,7 @@ void nscsi_cdrom_apple_device::scsi_command()
908
920
}
909
921
else
910
922
{
911
- sense (false , SK_NOT_READY, 0xb0 );
912
- scsi_status_complete (SS_CHECK_CONDITION);
923
+ return_no_cd ();
913
924
}
914
925
break ;
915
926
@@ -1312,15 +1323,33 @@ void nscsi_cdrom_apple_device::scsi_command()
1312
1323
case APPLE_AUDIO_CONTROL:
1313
1324
LOG (" command APPLE AUDIO CONTROL, size %d\n " , scsi_cmdbuf[8 ]);
1314
1325
1315
- scsi_data_out (3 , scsi_cmdbuf[8 ]);
1316
- scsi_status_complete (SS_GOOD);
1326
+ if (image->exists ())
1327
+ {
1328
+ scsi_data_out (3 , scsi_cmdbuf[8 ]);
1329
+ scsi_status_complete (SS_GOOD);
1330
+ }
1331
+ else
1332
+ {
1333
+ return_no_cd ();
1334
+ }
1317
1335
break ;
1318
1336
1319
1337
case APPLE_EJECT:
1320
1338
LOG (" command APPLE EJECT\n " );
1321
- cdda->stop_audio ();
1322
- m_stopped = true ;
1323
- scsi_status_complete (SS_GOOD);
1339
+ if (!m_removal_prevented)
1340
+ {
1341
+ cdda->stop_audio ();
1342
+ m_stopped = true ;
1343
+ image->unload ();
1344
+ sense (false , SK_NOT_READY, SK_ASC_MEDIUM_NOT_PRESENT);
1345
+ scsi_status_complete (SS_GOOD);
1346
+ }
1347
+ else
1348
+ {
1349
+ LOG (" Eject not allowed by PREVENT_ALLOW_MEDIA_REMOVAL\n " );
1350
+ sense (false , SK_ILLEGAL_REQUEST, 0x80 ); // "Prevent bit is set"
1351
+ scsi_status_complete (SS_CHECK_CONDITION);
1352
+ }
1324
1353
break ;
1325
1354
1326
1355
case SC_READ_6:
0 commit comments