i8257: Added LOG messages

This commit is contained in:
Joakim Larsson Edstrom 2017-12-15 22:19:35 +01:00
parent b8d7d74fe6
commit 479a9c8123

View File

@ -9,9 +9,23 @@
#include "emu.h"
#include "i8257.h"
//#define VERBOSE 1
//#define LOG_GENERAL (1U << 0) //defined in logmacro.h already
#define LOG_SETUP (1U << 1)
#define LOG_TFR (1U << 2)
//#define VERBOSE (LOG_GENERAL | LOG_SETUP | LOG_TFR)
//#define LOG_OUTPUT_STREAM std::cout
#include "logmacro.h"
#define LOGSETUP(...) LOGMASKED(LOG_SETUP, __VA_ARGS__)
#define LOGTFR(...) LOGMASKED(LOG_TFR, __VA_ARGS__)
#ifdef _MSC_VER
#define FUNCNAME __func__
#else
#define FUNCNAME __PRETTY_FUNCTION__
#endif
//**************************************************************************
// DEVICE DEFINITIONS
@ -85,6 +99,7 @@ inline void i8257_device::dma_request(int channel, int state)
inline bool i8257_device::is_request_active(int channel) const
{
LOG("%s Channel %d: %02x && MODE_CHAN_ENABLE:%02x\n", FUNCNAME, channel, m_request, MODE_CHAN_ENABLE(channel));
return BIT(m_request, channel) && MODE_CHAN_ENABLE(channel);
}
@ -94,6 +109,7 @@ inline bool i8257_device::is_request_active(int channel) const
inline void i8257_device::set_hreq(int state)
{
LOG("%s\n", FUNCNAME);
if (m_hreq != state)
{
m_out_hrq_cb(state);
@ -108,6 +124,7 @@ inline void i8257_device::set_hreq(int state)
inline void i8257_device::set_tc(int state)
{
LOG("%s: %d\n", FUNCNAME, state);
if (m_tc != state)
{
m_out_tc_cb(state);
@ -123,6 +140,7 @@ inline void i8257_device::set_tc(int state)
inline void i8257_device::set_dack()
{
LOG("%s\n", FUNCNAME);
m_out_dack_0_cb(m_current_channel != 0);
m_out_dack_1_cb(m_current_channel != 1);
m_out_dack_2_cb(m_current_channel != 2);
@ -136,12 +154,14 @@ inline void i8257_device::set_dack()
inline void i8257_device::dma_read()
{
LOG("%s\n", FUNCNAME);
offs_t offset = m_channel[m_current_channel].m_address;
switch (MODE_TRANSFER_MASK)
{
case MODE_TRANSFER_VERIFY:
case MODE_TRANSFER_WRITE:
LOGTFR(" - MODE TRANSFER VERIFY/WRITE");
switch(m_current_channel)
{
case 0:
@ -160,10 +180,11 @@ inline void i8257_device::dma_read()
break;
case MODE_TRANSFER_READ:
LOGTFR(" - MODE TRANSFER READ");
m_temp = m_in_memr_cb(offset);
break;
}
LOGTFR(" channel %d Offset %04x: %02x\n", m_current_channel, offset, m_temp);
}
@ -173,11 +194,13 @@ inline void i8257_device::dma_read()
inline void i8257_device::dma_write()
{
LOG("%s\n", FUNCNAME);
offs_t offset = m_channel[m_current_channel].m_address;
switch (MODE_TRANSFER_MASK)
{
case MODE_TRANSFER_VERIFY: {
LOGTFR(" - MODE TRANSFER VERIFY");
uint8_t v1 = m_in_memr_cb(offset);
if(0 && m_temp != v1)
logerror("verify error %02x vs. %02x\n", m_temp, v1);
@ -185,10 +208,12 @@ inline void i8257_device::dma_write()
}
case MODE_TRANSFER_WRITE:
LOGTFR(" - MODE TRANSFER WRITE");
m_out_memw_cb(offset, m_temp);
break;
case MODE_TRANSFER_READ:
LOGTFR(" - MODE TRANSFER READ");
switch(m_current_channel)
{
case 0:
@ -206,6 +231,7 @@ inline void i8257_device::dma_write()
}
break;
}
LOGTFR(" channel %d Offset %04x: %02x\n", m_channel, offset, m_temp);
}
@ -215,6 +241,7 @@ inline void i8257_device::dma_write()
inline void i8257_device::advance()
{
LOG("%s\n", FUNCNAME);
bool tc = (m_channel[m_current_channel].m_count == 0);
bool al = (MODE_AUTOLOAD && (m_current_channel == 2));
@ -297,6 +324,7 @@ i8257_device::i8257_device(const machine_config &mconfig, const char *tag, devic
void i8257_device::device_start()
{
LOG("%s\n", FUNCNAME);
// set our instruction counter
m_icountptr = &m_icount;
@ -351,6 +379,7 @@ void i8257_device::device_start()
void i8257_device::device_reset()
{
LOG("%s\n", FUNCNAME);
m_state = STATE_SI;
m_transfer_mode = 0;
m_status = 0;
@ -373,6 +402,7 @@ void i8257_device::device_reset()
bool i8257_device::next_channel()
{
LOG("%s\n", FUNCNAME);
int priority[] = { 0, 1, 2, 3 };
if (MODE_ROTATING_PRIORITY)
@ -405,6 +435,7 @@ bool i8257_device::next_channel()
void i8257_device::execute_run()
{
LOG("%s\n", FUNCNAME);
do
{
switch (m_state)
@ -488,6 +519,7 @@ void i8257_device::execute_run()
READ8_MEMBER( i8257_device::read )
{
LOG("%s\n", FUNCNAME);
uint8_t data = 0;
if (!BIT(offset, 3))
@ -543,6 +575,7 @@ READ8_MEMBER( i8257_device::read )
WRITE8_MEMBER( i8257_device::write )
{
LOG("%s \n", FUNCNAME);
if (!BIT(offset, 3))
{
int channel = (offset >> 1) & 0x03;
@ -550,6 +583,7 @@ WRITE8_MEMBER( i8257_device::write )
switch (offset & 0x01)
{
case REGISTER_ADDRESS:
LOGSETUP(" * Register Address <- %02x\n", data);
if (m_msb)
{
m_channel[channel].m_address = (data << 8) | (m_channel[channel].m_address & 0xff);
@ -565,6 +599,7 @@ WRITE8_MEMBER( i8257_device::write )
break;
case REGISTER_WORD_COUNT:
LOGSETUP(" * Register Word Count <- %02x\n", data);
if (m_msb)
{
m_channel[channel].m_count = ((data & 0x3f) << 8) | (m_channel[channel].m_count & 0xff);
@ -594,7 +629,7 @@ WRITE8_MEMBER( i8257_device::write )
{
m_transfer_mode = data;
LOG("I8257 Command Register: %02x\n", m_transfer_mode);
LOGSETUP("I8257 Command Register: %02x\n", m_transfer_mode);
}
trigger(1);
}
@ -631,6 +666,7 @@ WRITE_LINE_MEMBER( i8257_device::ready_w )
WRITE_LINE_MEMBER( i8257_device::dreq0_w )
{
LOG("%s\n", FUNCNAME);
dma_request(0, state);
}
@ -641,6 +677,7 @@ WRITE_LINE_MEMBER( i8257_device::dreq0_w )
WRITE_LINE_MEMBER( i8257_device::dreq1_w )
{
LOG("%s\n", FUNCNAME);
dma_request(1, state);
}
@ -651,6 +688,7 @@ WRITE_LINE_MEMBER( i8257_device::dreq1_w )
WRITE_LINE_MEMBER( i8257_device::dreq2_w )
{
LOG("%s\n", FUNCNAME);
dma_request(2, state);
}
@ -661,5 +699,6 @@ WRITE_LINE_MEMBER( i8257_device::dreq2_w )
WRITE_LINE_MEMBER( i8257_device::dreq3_w )
{
LOG("%s\n", FUNCNAME);
dma_request(3, state);
}