atastorage.cpp, ch376.cpp, dp83932c.cpp, smc91c9x.cpp: Use multibyte.h helpers

This commit is contained in:
AJR 2024-01-07 16:14:41 -05:00
parent 414d991244
commit 6f596b017b
4 changed files with 17 additions and 38 deletions

View File

@ -3,6 +3,8 @@
#include "emu.h"
#include "atastorage.h"
#include "multibyte.h"
/***************************************************************************
DEBUGGING
***************************************************************************/
@ -248,10 +250,7 @@ void ata_mass_storage_device_base::finished_command()
if (m_can_identify_device)
{
for( int w = 0; w < 256; w++ )
{
m_buffer[w * 2] = m_identify_buffer[ w ] & 0xff;
m_buffer[(w * 2) + 1] = m_identify_buffer[ w ] >> 8;
}
put_u16le(&m_buffer[w * 2], m_identify_buffer[ w ]);
m_status |= IDE_STATUS_DRQ;
}
@ -292,10 +291,7 @@ void ata_mass_storage_device_base::finished_command()
break;
case IDE_COMMAND_READ_NATIVE_MAX_ADDRESS:
m_buffer[0] = (total_sectors & 0xff000000) >> 24;
m_buffer[1] = (total_sectors & 0x00ff0000) >> 16;
m_buffer[2] = (total_sectors & 0x0000ff00) >> 8;
m_buffer[3] = (total_sectors & 0x000000ff);
put_u32be(&m_buffer[0], total_sectors);
set_irq(ASSERT_LINE);
break;
@ -886,9 +882,7 @@ void ide_hdd_device_base::device_reset()
if (ident.size() == 512)
{
for( int w = 0; w < 256; w++ )
{
m_identify_buffer[w] = (ident[(w * 2) + 1] << 8) | ident[w * 2];
}
m_identify_buffer[w] = get_u16le(&ident[w * 2]);
}
else
{

View File

@ -28,6 +28,8 @@
#include "emuopts.h"
#include "machine/ch376.h"
#include "multibyte.h"
#include "logmacro.h"
@ -415,10 +417,7 @@ void ch376_device::write(offs_t offset, u8 data)
case STATE_GET_FILE_SIZE:
// the host must write 0x68 here; it's unclear what the real chip does if the value doesn't match.
// reply with the size of the currently open file.
m_dataBuffer[0] = m_cur_file_size & 0xff;
m_dataBuffer[1] = (m_cur_file_size >> 8) & 0xff;
m_dataBuffer[2] = (m_cur_file_size >> 16) & 0xff;
m_dataBuffer[3] = (m_cur_file_size >> 24) & 0xff;
put_u32le(m_dataBuffer, m_cur_file_size);
m_dataPtr = 0;
m_dataLen = 4;
break;
@ -501,19 +500,9 @@ bool ch376_device::generateNextDirEntry()
m_dataBuffer[0xc] = 0; // no attributes
if (ourEntry->size >= u64(0x100000000))
{
m_dataBuffer[0x1d] = 0xff;
m_dataBuffer[0x1e] = 0xff;
m_dataBuffer[0x1f] = 0xff;
m_dataBuffer[0x20] = 0xff;
}
std::fill_n(&m_dataBuffer[0x1d], 4, 0xff);
else
{
m_dataBuffer[0x1d] = (ourEntry->size & 0xff);
m_dataBuffer[0x1e] = ((ourEntry->size >> 8) & 0xff);
m_dataBuffer[0x1f] = ((ourEntry->size >> 16) & 0xff);
m_dataBuffer[0x20] = ((ourEntry->size >> 24) & 0xff);
}
put_u32le(&m_dataBuffer[0x1d], ourEntry->size);
}
else // not a file or directory, recurse and hope the next one's better
{

View File

@ -22,7 +22,9 @@
#include "emu.h"
#include "dp83932c.h"
#include "hashing.h"
#include "multibyte.h"
#define LOG_COMMAND (1U << 1)
#define LOG_FILTER (1U << 2)
@ -386,10 +388,8 @@ void dp83932c_device::transmit()
u32 const crc = util::crc32_creator::simple(buf, length);
// insert the fcs
buf[length++] = crc >> 0;
buf[length++] = crc >> 8;
buf[length++] = crc >> 16;
buf[length++] = crc >> 24;
put_u32le(&buf[length], crc);
length += 4;
}
// advance ctda to the link field
@ -523,9 +523,7 @@ bool dp83932c_device::address_filter(u8 *buf)
return true;
}
u64 const address =
(u64(buf[0]) << 40) | (u64(buf[1]) << 32) | (u64(buf[2]) << 24) |
(u64(buf[3]) << 16) | (u64(buf[4]) << 8) | (u64(buf[5]) << 0);
u64 const address = get_u48be(buf);
// broadcast
if ((address == 0xffff'ffffffffULL) && (m_reg[RCR] & (RCR_AMC | RCR_BRD)))

View File

@ -564,10 +564,8 @@ TIMER_CALLBACK_MEMBER(smc91c9x_device::tx_poll)
{
u32 crc = util::crc32_creator::simple(tx_buffer + 4, length - 4);
tx_buffer[length++] = (crc >> 0) & 0xff;
tx_buffer[length++] = (crc >> 8) & 0xff;
tx_buffer[length++] = (crc >> 16) & 0xff;
tx_buffer[length++] = (crc >> 24) & 0xff;
put_u32le(&tx_buffer[length], crc);
length += 4;
}
// Remove status, length