mirror of
https://github.com/holub/mame
synced 2025-06-30 16:00:01 +03:00
ch376 updates [R. Belmont]
- Ignore non-8.3 compliant filenames when generating the directory since CH376 is super-tied to FAT12 semantics - Implement CHECK_EXIST command for BBC Micro - Implement undocumented command 0x16, also for BBC Micro - Fix status return from SET_USB_MODE
This commit is contained in:
parent
2077c7dca0
commit
488e60b3ab
@ -2,10 +2,11 @@
|
||||
// copyright-holders:R. Belmont
|
||||
/***************************************************************************
|
||||
|
||||
ch376.h
|
||||
ch376.cpp
|
||||
|
||||
"File manage and control chip CH376"
|
||||
https://www.mpja.com/download/ch376ds1.pdf
|
||||
https://github.com/djuseeq/Ch376msc/blob/master/src/CommDef.h
|
||||
|
||||
This is a module intended to offload USB and USB mass storage
|
||||
I/O from a small microcontroller or microprocessor.
|
||||
@ -44,7 +45,11 @@ static constexpr u8 STATUS_USB_INT_DISK_WRITE = 0x1e;
|
||||
static constexpr u8 STATUS_USB_INT_DISK_ERR = 0x1f;
|
||||
static constexpr u8 STATUS_ERR_MISS_FILE = 0x42;
|
||||
|
||||
// despite the name, this isn't a command
|
||||
static constexpr u8 CMD_RET_SUCCESS = 0x51;
|
||||
|
||||
static constexpr u8 CMD_GET_IC_VER = 0x01;
|
||||
static constexpr u8 CMD_CHECK_EXIST = 0x06;
|
||||
static constexpr u8 CMD_GET_FILE_SIZE = 0x0c;
|
||||
static constexpr u8 CMD_SET_USB_MODE = 0x15;
|
||||
static constexpr u8 CMD_GET_STATUS = 0x22;
|
||||
@ -144,8 +149,18 @@ void ch376_device::write(offs_t offset, u8 data)
|
||||
m_last_command = data;
|
||||
switch (data)
|
||||
{
|
||||
case 0x16: // not a documented valid command, but apparently used by the BBC Micro software
|
||||
m_dataBuffer[0] = m_int_status = STATUS_USB_INT_CONNECT;
|
||||
m_dataPtr = 0;
|
||||
m_dataLen = 1;
|
||||
break;
|
||||
|
||||
case CMD_CHECK_EXIST:
|
||||
m_state = STATE_CHECK_EXIST;
|
||||
break;
|
||||
|
||||
case CMD_GET_IC_VER:
|
||||
m_dataBuffer[0] = 0x41; //
|
||||
m_dataBuffer[0] = 0x41;
|
||||
m_dataPtr = 0;
|
||||
m_dataLen = 1;
|
||||
break;
|
||||
@ -327,8 +342,17 @@ void ch376_device::write(offs_t offset, u8 data)
|
||||
{
|
||||
switch (m_state)
|
||||
{
|
||||
case STATE_CHECK_EXIST:
|
||||
m_data = (data ^ 0xff);
|
||||
m_state = STATE_IDLE;
|
||||
break;
|
||||
|
||||
case STATE_USB_MODE_SET:
|
||||
m_state = STATE_IDLE;
|
||||
if ((data == 0x6) || (data == 0x7))
|
||||
{
|
||||
m_data = CMD_RET_SUCCESS;
|
||||
}
|
||||
break;
|
||||
|
||||
case STATE_SET_FILE_NAME:
|
||||
@ -440,6 +464,13 @@ bool ch376_device::generateNextDirEntry()
|
||||
}
|
||||
}
|
||||
|
||||
// is this an 8.3 filename? CH376 can only really cope with 8.3, so
|
||||
// skip this entry and recurse to get the next one.
|
||||
if (dotIdx > 8)
|
||||
{
|
||||
return generateNextDirEntry();
|
||||
}
|
||||
|
||||
int baseLen = std::min(8, dotIdx);
|
||||
for (int idx = 0; idx < baseLen; idx++)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user