From f5846116796eb6f26275b38be3bba71a7ebc463c Mon Sep 17 00:00:00 2001 From: yz70s Date: Sat, 11 Jan 2020 20:49:04 +0100 Subject: gdrom.cpp: modifications to make it useable with the naomi dimm board (nw) --- src/mame/machine/gdrom.cpp | 25 ++++++++++++++++++++++++- src/mame/machine/gdrom.h | 3 +++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/mame/machine/gdrom.cpp b/src/mame/machine/gdrom.cpp index a25cc5d5373..d981bf68071 100644 --- a/src/mame/machine/gdrom.cpp +++ b/src/mame/machine/gdrom.cpp @@ -422,6 +422,8 @@ void gdrom_device::ReadData( uint8_t *data, int dataLength ) case 0x71: memcpy(data, &GDROM_Cmd71_Reply[0], sizeof(GDROM_Cmd71_Reply)); + if (is_real_gdrom_disc) + data[10] = 0x1f; // needed by dimm board firmware break; case 0x40: // Get Subchannel status @@ -465,11 +467,23 @@ void gdrom_device::WriteData( uint8_t *data, int dataLength ) } } +void gdrom_device::SetDevice(void *device) +{ + t10mmc::SetDevice(device); + + // try to find if the mounted chd is from an actual gd-rom disc + if (m_cdrom) + if (cdrom_get_last_track(m_cdrom) == 3) + if ((cdrom_get_track_type(m_cdrom, 0) == CD_TRACK_MODE1_RAW) && (cdrom_get_track_type(m_cdrom, 1) == CD_TRACK_AUDIO) && (cdrom_get_track_type(m_cdrom, 2) == CD_TRACK_MODE1_RAW)) + is_real_gdrom_disc = true; +} + // device type definition DEFINE_DEVICE_TYPE(GDROM, gdrom_device, "gdrom", "GD-ROM") gdrom_device::gdrom_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : - atapi_cdrom_device(mconfig, GDROM, tag, owner, clock) + atapi_cdrom_device(mconfig, GDROM, tag, owner, clock), + is_real_gdrom_disc(false) { } @@ -523,3 +537,12 @@ void gdrom_device::process_buffer() atapi_hle_device::process_buffer(); m_sector_number = 0x80 | GDROM_PAUSE_STATE; /// HACK: find out when this should be updated } + +void gdrom_device::signature() +{ + atapi_hle_device::signature(); + + // naomi dimm board firmware needs the upper nibble to be 8 at the beginning + if (is_real_gdrom_disc) + m_sector_number = 0x81; +} diff --git a/src/mame/machine/gdrom.h b/src/mame/machine/gdrom.h index 8fc87e95d2d..12014f62094 100644 --- a/src/mame/machine/gdrom.h +++ b/src/mame/machine/gdrom.h @@ -26,6 +26,8 @@ public: protected: virtual void process_buffer() override; + virtual void signature() override; + virtual void SetDevice(void *device) override; // device-level overrides virtual void device_start() override; @@ -36,6 +38,7 @@ private: uint32_t read_type; // for command 0x30 only uint32_t data_select; // for command 0x30 only uint32_t transferOffset; + bool is_real_gdrom_disc; }; DECLARE_DEVICE_TYPE(GDROM, gdrom_device) -- cgit v1.2.3