diff --git a/src/emu/machine/ataflash.c b/src/emu/machine/ataflash.c index ee473dfbfa0..0170f07fe41 100644 --- a/src/emu/machine/ataflash.c +++ b/src/emu/machine/ataflash.c @@ -23,14 +23,20 @@ void ata_flash_pccard_device::device_reset() { ide_hdd_device::device_reset(); - m_locked = 0x1ff; - m_gnetreadlock = 1; - UINT32 metalength; + memset(m_key, 0, sizeof(m_key)); memset(m_cis, 0xff, 512); if (m_handle != NULL) + { m_handle->read_metadata(PCMCIA_CIS_METADATA_TAG, 0, m_cis, 512, metalength); + + if (m_handle->read_metadata(HARD_DISK_KEY_METADATA_TAG, 0, m_key, 5, metalength) == CHDERR_NONE) + { + m_locked = 0x1ff; + m_gnetreadlock = 1; + } + } } READ16_MEMBER( ata_flash_pccard_device::read_memory ) @@ -89,12 +95,9 @@ WRITE16_MEMBER( ata_flash_pccard_device::write_reg ) { if(offset >= 0x280 && offset <= 0x288 && m_handle != NULL) { - dynamic_buffer key(m_handle->hunk_bytes()); - m_handle->read_metadata(HARD_DISK_KEY_METADATA_TAG, 0, key); - UINT8 v = data; int pos = offset - 0x280; - UINT8 k = pos < key.count() ? key[pos] : 0; + UINT8 k = pos < sizeof(m_key) ? m_key[pos] : 0; if(v == k) { @@ -119,8 +122,6 @@ bool ata_flash_pccard_device::is_ready() bool ata_flash_pccard_device::process_command() { - UINT8 key[5]; - switch (m_command) { case IDE_COMMAND_TAITO_GNET_UNLOCK_1: @@ -145,8 +146,7 @@ bool ata_flash_pccard_device::process_command() //LOGPRINT(("IDE GNET Unlock 3\n")); /* key check */ - read_key(key); - if (m_feature == key[0] && m_sector_count == key[1] && m_sector_number == key[2] && m_cylinder_low == key[3] && m_cylinder_high == key[4]) + if (m_feature == m_key[0] && m_sector_count == m_key[1] && m_sector_number == m_key[2] && m_cylinder_low == m_key[3] && m_cylinder_high == m_key[4]) { m_gnetreadlock = 0; } @@ -175,12 +175,10 @@ void ata_flash_pccard_device::process_buffer() { if (m_command == IDE_COMMAND_TAITO_GNET_UNLOCK_2) { - UINT8 key[5] = { 0 }; int i, bad = 0; - read_key(key); for (i=0; !bad && i<512; i++) - bad = ((i < 2 || i >= 7) && m_buffer[i]) || ((i >= 2 && i < 7) && m_buffer[i] != key[i-2]); + bad = ((i < 2 || i >= 7) && m_buffer[i]) || ((i >= 2 && i < 7) && m_buffer[i] != m_key[i-2]); if (bad) { diff --git a/src/emu/machine/ataflash.h b/src/emu/machine/ataflash.h index b471d88d8bf..e656ba5442d 100644 --- a/src/emu/machine/ataflash.h +++ b/src/emu/machine/ataflash.h @@ -29,7 +29,8 @@ protected: virtual bool is_ready(); private: - unsigned char m_cis[512]; + UINT8 m_cis[512]; + UINT8 m_key[5]; UINT8 m_gnetreadlock; int m_locked; }; diff --git a/src/emu/machine/idehd.c b/src/emu/machine/idehd.c index a5c19b1b5e8..9232cff4e04 100644 --- a/src/emu/machine/idehd.c +++ b/src/emu/machine/idehd.c @@ -1423,16 +1423,6 @@ void ide_hdd_device::device_reset() } } -//------------------------------------------------- -// read device key -//------------------------------------------------- - -void ide_hdd_device::read_key(UINT8 key[]) -{ - UINT32 metalength; - m_handle->read_metadata(HARD_DISK_KEY_METADATA_TAG, 0, key, 5, metalength); -} - //------------------------------------------------- // machine_config_additions - device-specific // machine configurations diff --git a/src/emu/machine/idehd.h b/src/emu/machine/idehd.h index e21ba654456..dc9ead9048d 100644 --- a/src/emu/machine/idehd.h +++ b/src/emu/machine/idehd.h @@ -100,7 +100,6 @@ protected: virtual int read_sector(UINT32 lba, void *buffer) = 0; virtual int write_sector(UINT32 lba, const void *buffer) = 0; - virtual void read_key(UINT8 key[]) = 0; bool device_selected() { return m_csel == (m_device_head & IDE_DEVICE_HEAD_DRV) >> 4; } bool single_device() { return m_csel == 0 && m_dasp == 0; } @@ -180,8 +179,6 @@ protected: // optional information overrides virtual machine_config_constructor device_mconfig_additions() const; - virtual void read_key(UINT8 key[]); - chd_file *m_handle; hard_disk_file *m_disk; }; diff --git a/src/mame/drivers/chihiro.c b/src/mame/drivers/chihiro.c index 39aa132d655..0e54556cb52 100644 --- a/src/mame/drivers/chihiro.c +++ b/src/mame/drivers/chihiro.c @@ -2664,7 +2664,6 @@ public: virtual int read_sector(UINT32 lba, void *buffer); virtual int write_sector(UINT32 lba, const void *buffer); - virtual void read_key(UINT8 key[]) { } protected: // device-level overrides virtual void device_start();