Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 24 additions & 12 deletions src/devices/machine/am9513.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,14 @@
#define LOG_MODE (1U << 1)
#define LOG_INPUT (1U << 2)
#define LOG_TC (1U << 3)
#define LOG_WARN (1U << 4)

//#define VERBOSE (LOG_GENERAL | LOG_MODE)

#include "logmacro.h"

#define LOGWARN(...) LOGMASKED(LOG_WARN, "WARNING: " __VA_ARGS__)


//**************************************************************************
// TYPE DEFINITIONS
Expand Down Expand Up @@ -976,7 +980,7 @@ void am9513_device::write_gate_alt(int c, bool level)
{
if (bus_is_16_bit())
{
logerror("Gate %dA written when configured as DB%d\n", c + 1, c + 8);
LOGWARN("Gate %dA written when configured as DB%d\n", c + 1, c + 8);
return;
}

Expand Down Expand Up @@ -1102,7 +1106,7 @@ void am9513_device::internal_write(u16 data)
set_master_mode(data);
break;
case 0x1f: // Status register (read only?)
logerror("Writing %04X to status register\n", data);
LOGWARN("Writing %04X to status register\n", data);
break;
case 0x07: // Alarm 1 register
case 0x0f: // Alarm 2 register
Expand Down Expand Up @@ -1138,7 +1142,7 @@ void am9513_device::internal_write(u16 data)
m_counter_hold[(m_dpr & 7) - 1] = data;
break;
default: // Invalid register
logerror("Writing %04X to register %02X\n", data, m_dpr);
LOGWARN("Writing %04X to register %02X\n", data, m_dpr);
break;
}
}
Expand Down Expand Up @@ -1217,7 +1221,7 @@ void am9513_device::command_write(u8 data)
case 0x00:
if ((data & 0x07) == 0x00 || (data & 0x07) == 0x06)
{
logerror("Invalid register selected: %02X\n", data);
LOGWARN("Invalid register selected: %02X\n", data);
break;
}

Expand Down Expand Up @@ -1251,9 +1255,15 @@ void am9513_device::command_write(u8 data)
if (BIT(data, c))
{
if (!BIT(data, 5))
{
LOGMASKED(LOG_MODE, "Disarm Counter %d\n", c + 1);
disarm_counter(c);
}
if (!BIT(data, 6))
{
LOGMASKED(LOG_MODE, "Save Counter %d\n", c + 1);
save_counter(c);
}
Comment on lines 1257 to +1266
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOG_MODE is for logging the master mode control setup. It’s inappropriate to use here.

Also, there are already LOG_GENERAL messages in both disarm_counter and save_counter so these are unnecessary.

}
}
break;
Expand All @@ -1277,6 +1287,7 @@ void am9513_device::command_write(u8 data)
m_mmr = ((m_mmr & ~(1 << 12)) | BIT(data, 3) << 12);
break;
case 0xe7: case 0xef: // Clear/set MM13 (8-bit bus/16-bit bus)
LOGMASKED(LOG_MODE, "Data Bus Width = %d-Bit\n", BIT(data, 3) ? 16 : 8);
m_mmr = ((m_mmr & ~(1 << 13)) | BIT(data, 3) << 13);
break;
case 0xf1: // Step counter 1
Expand All @@ -1298,7 +1309,7 @@ void am9513_device::command_write(u8 data)
}
[[fallthrough]];
default:
logerror("Invalid command: %02X\n", data);
LOGWARN("Invalid command: %02X\n", data);
break;
}
break;
Expand Down Expand Up @@ -1391,7 +1402,7 @@ void am9513_device::write8(offs_t offset, u8 data)
if (BIT(offset, 0))
{
if (data == 0xef)
logerror("16-bit data bus selected with 8-bit write\n");
LOGWARN("16-bit data bus selected with 8-bit write\n");
command_write(data);
}
else
Expand All @@ -1410,7 +1421,7 @@ u16 am9513_device::read16(offs_t offset)
else
{
if (!bus_is_16_bit())
logerror("16-bit data read in 8-bit bus mode\n");
LOGWARN("16-bit data read in 8-bit bus mode\n");
return data_read();
}
}
Expand All @@ -1423,19 +1434,20 @@ u16 am9513_device::read16(offs_t offset)
void am9513_device::write16(offs_t offset, u16 data)
{
if ((!bus_is_16_bit() || BIT(offset, 0)) && (data & 0xff00) != 0xff00)
logerror("Errant write of %02X to upper byte of %s register in %d-bit bus mode\n",
LOGWARN("Errant write of %02X to upper byte of %s register in %d-bit bus mode\n",
(data & 0xff00) >> 8,
BIT(offset, 0) ? "control" : "data",
bus_is_16_bit() ? 16 : 8);

if (BIT(offset, 0))
{
command_write(data & 0x00ff);

// NB testing afterwards because this command may have been changing bus width
if ((data & 0x00ff) == 0x00e7)
logerror("8-bit data bus selected with 16-bit write\n");
LOGWARN("8-bit data bus selected with 16-bit write\n");
else if ((data & 0x00ff) == 0x00ef && !bus_is_16_bit())
logerror("16-bit data bus selected\n");

command_write(data & 0x00ff);
LOGWARN("16-bit data bus selected\n");
Comment on lines +1444 to +1450
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this won’t work properly after the change – else if ((data & 0x00ff) == 0x00ef && !bus_is_16_bit()) won’t be true after calling command_write because the 16-bit mode will have selected.

}
else
data_write(data);
Expand Down