1
#include "machine/nscsi_cd.h"
2
#include "imagedev/chd_cd.h"
4
const device_type NSCSI_CDROM = &device_creator<nscsi_cdrom_device>;
6
nscsi_cdrom_device::nscsi_cdrom_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
7
nscsi_full_device(mconfig, NSCSI_CDROM, "SCSI CDROM", tag, owner, clock)
11
void nscsi_cdrom_device::device_start()
13
nscsi_full_device::device_start();
14
bytes_per_sector = 2048;
17
void nscsi_cdrom_device::device_reset()
19
nscsi_full_device::device_reset();
20
cdrom = subdevice<cdrom_image_device>("image")->get_cdrom_file();
26
cdrom_interface nscsi_cdrom_device::cd_intf = { 0, 0 };
28
static MACHINE_CONFIG_FRAGMENT(scsi_cdrom)
29
MCFG_CDROM_ADD("image", nscsi_cdrom_device::cd_intf)
32
machine_config_constructor nscsi_cdrom_device::device_mconfig_additions() const
34
return MACHINE_CONFIG_NAME(scsi_cdrom);
37
UINT8 nscsi_cdrom_device::scsi_get_data(int id, int pos)
40
return nscsi_full_device::scsi_get_data(id, pos);
41
int clba = lba + pos / bytes_per_sector;
44
if(!cdrom_read_data(cdrom, cur_lba, block, CD_TRACK_MODE1)) {
45
logerror("%s: CD READ ERROR !\n", tag());
46
memset(block, 0, sizeof(block));
49
return block[pos & (bytes_per_sector - 1)];
52
void nscsi_cdrom_device::scsi_command()
54
switch(scsi_cmdbuf[0]) {
55
case SC_TEST_UNIT_READY:
56
logerror("%s: command TEST UNIT READY\n", tag());
57
scsi_status_complete(SS_GOOD);
61
lba = ((scsi_cmdbuf[1] & 0x1f)<<16) | (scsi_cmdbuf[2]<<8) | scsi_cmdbuf[3];
62
blocks = scsi_cmdbuf[4];
66
logerror("%s: command READ start=%08x blocks=%04x\n",
69
scsi_data_in(2, blocks*bytes_per_sector);
70
scsi_status_complete(SS_GOOD);
74
int lun = get_lun(scsi_cmdbuf[1] >> 5);
75
logerror("%s: command INQUIRY lun=%d EVPD=%d page=%d alloc=%02x link=%02x\n",
77
lun, scsi_cmdbuf[1] & 1, scsi_cmdbuf[2], scsi_cmdbuf[4], scsi_cmdbuf[5]);
83
int page = scsi_cmdbuf[2];
84
int size = scsi_cmdbuf[4];
87
memset(scsi_cmdbuf, 0, 148);
88
scsi_cmdbuf[0] = 0x05; // device is present, device is CD/DVD (MMC-3)
89
scsi_cmdbuf[1] = 0x80; // media is removable
90
scsi_cmdbuf[2] = 0x05; // device complies with SPC-3 standard
91
scsi_cmdbuf[3] = 0x02; // response data format = SPC-3 standard
92
// some Konami games freak out if this isn't "Sony", so we'll lie
93
// this is the actual drive on my Nagano '98 board
94
strcpy((char *)&scsi_cmdbuf[8], "Sony");
95
strcpy((char *)&scsi_cmdbuf[16], "CDU-76S");
96
strcpy((char *)&scsi_cmdbuf[32], "1.0");
99
scsi_data_in(SBUF_MAIN, size);
102
scsi_status_complete(SS_GOOD);
106
case SC_START_STOP_UNIT:
107
logerror("%s: command START STOP UNIT\n", tag());
108
scsi_status_complete(SS_GOOD);
111
case SC_READ_CAPACITY: {
112
logerror("%s: command READ CAPACITY\n", tag());
114
UINT32 temp = cdrom_get_track_start(cdrom, 0xaa);
115
temp--; // return the last used block on the disc
117
scsi_cmdbuf[0] = (temp>>24) & 0xff;
118
scsi_cmdbuf[1] = (temp>>16) & 0xff;
119
scsi_cmdbuf[2] = (temp>>8) & 0xff;
120
scsi_cmdbuf[3] = (temp & 0xff);
123
scsi_cmdbuf[6] = (bytes_per_sector>>8)&0xff;
124
scsi_cmdbuf[7] = (bytes_per_sector & 0xff);
126
scsi_data_in(SBUF_MAIN, 8);
127
scsi_status_complete(SS_GOOD);
131
case SC_READ_EXTENDED:
132
lba = (scsi_cmdbuf[2]<<24) | (scsi_cmdbuf[3]<<16) | (scsi_cmdbuf[4]<<8) | scsi_cmdbuf[5];
133
blocks = (scsi_cmdbuf[7] << 8) | scsi_cmdbuf[8];
135
logerror("%s: command READ EXTENDED start=%08x blocks=%04x\n",
138
scsi_data_in(2, blocks*bytes_per_sector);
139
scsi_status_complete(SS_GOOD);
143
nscsi_full_device::scsi_command();