summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2024-03-25 15:17:12 +1100
committer Vas Crabb <vas@vastheman.com>2024-03-25 15:17:12 +1100
commitef7903fc220da3832efdfcd41f4ceb2e4a55f26a (patch)
tree20dd5a9eefeb21df59e76e76bed230dd522afc1f
parent6517b66f3e9f3be8d709872652432eab541b709e (diff)
-debugger/debuggdbstub.cpp: Don't write data to socket in text mode.
-mr/dribling.cpp, heathkit/h17_fdc.cpp: Tidy up a little.
-rw-r--r--src/mame/heathkit/h17_fdc.cpp15
-rw-r--r--src/mame/mr/dribling.cpp80
-rw-r--r--src/osd/modules/debugger/debuggdbstub.cpp44
3 files changed, 57 insertions, 82 deletions
diff --git a/src/mame/heathkit/h17_fdc.cpp b/src/mame/heathkit/h17_fdc.cpp
index f1ac88de5f7..7499368cd70 100644
--- a/src/mame/heathkit/h17_fdc.cpp
+++ b/src/mame/heathkit/h17_fdc.cpp
@@ -13,19 +13,14 @@
****************************************************************************/
#include "emu.h"
-
#include "h17_fdc.h"
-// Register setup
-#define LOG_REG (1U << 1)
-// Control lines
-#define LOG_LINES (1U << 2)
-// Drive select
-#define LOG_DRIVE (1U << 3)
-// Function calls
-#define LOG_FUNC (1U << 4)
+#define LOG_REG (1U << 1) // Register setup
+#define LOG_LINES (1U << 2) // Control lines
+#define LOG_DRIVE (1U << 3) // Drive select
+#define LOG_FUNC (1U << 4) // Function calls
-//#define VERBOSE (0xff)
+//#define VERBOSE (LOG_GENERAL | LOG_REG | LOG_LINES | LOG_DRIVE | LOG_FUNC)
#include "logmacro.h"
diff --git a/src/mame/mr/dribling.cpp b/src/mame/mr/dribling.cpp
index b7ab36a3be0..1a91dc1f3e5 100644
--- a/src/mame/mr/dribling.cpp
+++ b/src/mame/mr/dribling.cpp
@@ -11,7 +11,7 @@
* Dribbling
TODO:
- * Implement the 2 banks of 8 dips which determine coinage for the 2 players
+ * Implement the 2 banks of 8 DIP switches which determine coinage for the 2 players
* Actual game duration doesn't match the time reported in the manual
****************************************************************************
@@ -49,15 +49,13 @@
// configurable logging
#define LOG_MISC (1U << 1)
#define LOG_SOUND (1U << 2)
-#define LOG_PB (1U << 3)
-//#define VERBOSE (LOG_GENERAL | LOG_MISC | LOG_SOUND | LOG_PB)
+//#define VERBOSE (LOG_GENERAL | LOG_MISC | LOG_SOUND)
#include "logmacro.h"
#define LOGMISC(...) LOGMASKED(LOG_MISC, __VA_ARGS__)
#define LOGSOUND(...) LOGMASKED(LOG_SOUND, __VA_ARGS__)
-#define LOGPB(...) LOGMASKED(LOG_PB, __VA_ARGS__)
namespace {
@@ -72,7 +70,7 @@ public:
m_ppi8255(*this, "ppi8255%d", 0),
m_videoram(*this, "videoram"),
m_colorram(*this, "colorram"),
- m_mux(*this, "MUX%u", 0),
+ m_matrix(*this, "MUX%u", 0),
m_proms(*this, "proms"),
m_gfxroms(*this, "gfx"),
m_i_pb(*this, "snd_nl:pb%u", 0U),
@@ -103,7 +101,7 @@ private:
// memory pointers
required_shared_ptr<uint8_t> m_videoram;
required_shared_ptr<uint8_t> m_colorram;
- required_ioport_array<3> m_mux;
+ required_ioport_array<3> m_matrix;
required_region_ptr<uint8_t> m_proms;
required_region_ptr<uint8_t> m_gfxroms;
@@ -125,14 +123,14 @@ private:
uint8_t m_dr = 0U;
uint8_t m_ds = 0U;
uint8_t m_sh = 0U;
- uint8_t m_input_mux = 0U;
+ uint8_t m_input_sel = 0U;
uint8_t m_di = 0U;
uint8_t ioread(offs_t offset);
void iowrite(offs_t offset, uint8_t data);
void colorram_w(offs_t offset, uint8_t data);
uint8_t dsr_r();
- uint8_t input_mux0_r();
+ uint8_t input_matrix_read();
void misc_w(uint8_t data);
void sound_w(uint8_t data);
void pb_w(uint8_t data);
@@ -202,11 +200,11 @@ uint32_t dribling_state::screen_update(screen_device &screen, bitmap_ind16 &bitm
// loop over columns
for (int x = cliprect.min_x; x <= cliprect.max_x; x++)
{
- int const b7 = m_proms[(x >> 3) | ((y >> 3) << 5)] & 1;
+ int const b7 = BIT(m_proms[(x >> 3) | ((y >> 3) << 5)], 0);
int const b6 = m_abca;
- int const b5 = (x >> 3) & 1;
- int const b4 = (m_gfxroms[(x >> 3) | (y << 5)] >> (x & 7)) & 1;
- int const b3 = (m_videoram[(x >> 3) | (y << 5)] >> (x & 7)) & 1;
+ int const b5 = BIT(x, 3);
+ int const b4 = BIT(m_gfxroms[(x >> 3) | (y << 5)], x & 7);
+ int const b3 = BIT(m_videoram[(x >> 3) | (y << 5)], x & 7);
int const b2_0 = m_colorram[(x >> 3) | ((y >> 2) << 7)] & 7;
// assemble the various bits into a palette PROM index
@@ -245,16 +243,17 @@ uint8_t dribling_state::dsr_r()
}
-uint8_t dribling_state::input_mux0_r()
+uint8_t dribling_state::input_matrix_read()
{
// low value in the given bit selects
- if (!(m_input_mux & 0x01))
- return m_mux[0]->read();
- else if (!(m_input_mux & 0x02))
- return m_mux[1]->read();
- else if (!(m_input_mux & 0x04))
- return m_mux[2]->read();
- return 0xff;
+ u8 result = 0xff;
+ if (!BIT(m_input_sel, 0))
+ result &= m_matrix[0]->read();
+ if (!BIT(m_input_sel, 1))
+ result &= m_matrix[1]->read();
+ if (!BIT(m_input_sel, 2))
+ result &= m_matrix[2]->read();
+ return result;
}
@@ -287,7 +286,7 @@ void dribling_state::misc_w(uint8_t data)
// bit 2 = (9) = PC2
// bit 1 = (10) = PC1
// bit 0 = (32) = PC0
- m_input_mux = data & 7;
+ m_input_sel = data & 7;
}
@@ -295,35 +294,20 @@ void dribling_state::sound_w(uint8_t data)
{
LOGSOUND("%s:sound_w(%02X)\n", machine().describe_context(), data);
- // bit 7 = stop palla (ball stop)
- m_i_stop_palla->write_line(BIT(data, 7));
-
- // bit 6 = contrasto (tackle)
- m_i_contrasto->write_line(BIT(data, 6));
-
- // bit 5 = calcio a (kick a)
- m_i_calcio_a->write_line(BIT(data, 5));
-
- // bit 4 = fischio (whistle)
- m_i_fischio->write_line(BIT(data, 4));
-
- // bit 3 = calcio b (kick b)
- m_i_calcio_b->write_line(BIT(data, 3));
-
- // bit 2 = folla a (crowd a)
- m_i_folla_a->write_line(BIT(data, 2));
-
- // bit 1 = folla m (crowd m)
- m_i_folla_m->write_line(BIT(data, 1));
-
- // bit 0 = folla b (crowd b)
- m_i_folla_b->write_line(BIT(data, 0));
+ m_i_stop_palla->write_line(BIT(data, 7)); // stop palla (ball stop)
+ m_i_contrasto->write_line(BIT(data, 6)); // contrasto (tackle)
+ m_i_calcio_a->write_line(BIT(data, 5)); // calcio a (kick a)
+ m_i_fischio->write_line(BIT(data, 4)); // fischio (whistle)
+ m_i_calcio_b->write_line(BIT(data, 3)); // calcio b (kick b)
+ m_i_folla_a->write_line(BIT(data, 2)); // folla a (crowd a)
+ m_i_folla_m->write_line(BIT(data, 1)); // folla m (crowd m)
+ m_i_folla_b->write_line(BIT(data, 0)); // folla b (crowd b)
}
void dribling_state::pb_w(uint8_t data)
{
- LOGPB("%s:pb_w(%02X)\n", machine().describe_context(), data);
+ LOGSOUND("%s:pb_w(%02X)\n", machine().describe_context(), data);
for (int i = 0; i < 8; i++)
{
@@ -458,7 +442,7 @@ void dribling_state::machine_start()
save_item(NAME(m_dr));
save_item(NAME(m_ds));
save_item(NAME(m_sh));
- save_item(NAME(m_input_mux));
+ save_item(NAME(m_input_sel));
}
void dribling_state::machine_reset()
@@ -468,7 +452,7 @@ void dribling_state::machine_reset()
m_dr = 0;
m_ds = 0;
m_sh = 0;
- m_input_mux = 0;
+ m_input_sel = 0;
}
@@ -482,7 +466,7 @@ void dribling_state::dribling(machine_config &config)
I8255A(config, m_ppi8255[0]);
m_ppi8255[0]->in_pa_callback().set(FUNC(dribling_state::dsr_r));
- m_ppi8255[0]->in_pb_callback().set(FUNC(dribling_state::input_mux0_r));
+ m_ppi8255[0]->in_pb_callback().set(FUNC(dribling_state::input_matrix_read));
m_ppi8255[0]->out_pc_callback().set(FUNC(dribling_state::misc_w));
I8255A(config, m_ppi8255[1]);
diff --git a/src/osd/modules/debugger/debuggdbstub.cpp b/src/osd/modules/debugger/debuggdbstub.cpp
index 261ceb9beb5..e5092c71548 100644
--- a/src/osd/modules/debugger/debuggdbstub.cpp
+++ b/src/osd/modules/debugger/debuggdbstub.cpp
@@ -21,6 +21,7 @@
#include "fileio.h"
#include <cinttypes>
+#include <string_view>
namespace osd {
@@ -587,7 +588,7 @@ public:
int readchar();
- void send_reply(const char *str);
+ void send_reply(std::string_view str);
void send_stop_packet();
private:
@@ -676,15 +677,12 @@ int debug_gdbstub::readchar()
}
//-------------------------------------------------------------------------
-static std::string escape_packet(const std::string src)
+static std::string escape_packet(std::string_view src)
{
std::string result;
result.reserve(src.length());
- for ( char ch: src )
+ for ( char ch : src )
{
- if ( ch == '\n' ) // don't let socket convert line endings and messing up the checksum
- continue;
-
if ( ch == '#' || ch == '$' || ch == '}' )
{
result += '}';
@@ -704,10 +702,10 @@ void debug_gdbstub::generate_target_xml()
target_xml += "<?xml version=\"1.0\"?>\n";
target_xml += "<!DOCTYPE target SYSTEM \"gdb-target.dtd\">\n";
target_xml += "<target version=\"1.0\">\n";
- target_xml += string_format("<architecture>%s</architecture>\n", m_gdb_arch.c_str());
- target_xml += string_format(" <feature name=\"%s\">\n", m_gdb_feature.c_str());
+ target_xml += string_format("<architecture>%s</architecture>\n", m_gdb_arch);
+ target_xml += string_format(" <feature name=\"%s\">\n", m_gdb_feature);
for ( const auto &reg: m_gdb_registers )
- target_xml += string_format(" <reg name=\"%s\" bitsize=\"%d\" type=\"%s\"/>\n", reg.gdb_name.c_str(), reg.gdb_bitsize, gdb_register_type_str[reg.gdb_type]);
+ target_xml += string_format(" <reg name=\"%s\" bitsize=\"%d\" type=\"%s\"/>\n", reg.gdb_name, reg.gdb_bitsize, gdb_register_type_str[reg.gdb_type]);
target_xml += " </feature>\n";
target_xml += "</target>\n";
m_target_xml = escape_packet(target_xml);
@@ -840,26 +838,24 @@ void debug_gdbstub::debugger_update()
//-------------------------------------------------------------------------
void debug_gdbstub::send_nack()
{
- m_socket.puts("-");
+ m_socket.write("-", 1);
}
//-------------------------------------------------------------------------
void debug_gdbstub::send_ack()
{
- m_socket.puts("+");
+ m_socket.write("+", 1);
}
//-------------------------------------------------------------------------
-void debug_gdbstub::send_reply(const char *str)
+void debug_gdbstub::send_reply(std::string_view str)
{
- size_t length = strlen(str);
-
uint8_t checksum = 0;
- for ( size_t i = 0; i < length; i++ )
- checksum += str[i];
+ for ( char ch : str )
+ checksum += ch;
std::string reply = string_format("$%s#%02x", str, checksum);
- m_socket.puts(reply);
+ m_socket.write(reply.c_str(), reply.length());
}
@@ -917,7 +913,7 @@ debug_gdbstub::cmd_reply debug_gdbstub::handle_g(const char *buf)
std::string reply;
for ( const auto &reg: m_gdb_registers )
reply += get_register_string(reg.gdb_regnum);
- send_reply(reply.c_str());
+ send_reply(reply);
return REPLY_NONE;
}
@@ -986,7 +982,7 @@ debug_gdbstub::cmd_reply debug_gdbstub::handle_m(const char *buf)
uint8_t value = tspace->read_byte(offset + i);
reply += string_format("%02x", value);
}
- send_reply(reply.c_str());
+ send_reply(reply);
return REPLY_NONE;
}
@@ -1042,7 +1038,7 @@ debug_gdbstub::cmd_reply debug_gdbstub::handle_p(const char *buf)
if ( sscanf(buf, "%x", &gdb_regnum) != 1 || gdb_regnum >= m_gdb_registers.size() )
return REPLY_ENN;
std::string reply = get_register_string(gdb_regnum);
- send_reply(reply.c_str());
+ send_reply(reply);
return REPLY_NONE;
}
@@ -1109,7 +1105,7 @@ debug_gdbstub::cmd_reply debug_gdbstub::handle_q(const char *buf)
reply += string_format("%02x", *line++);
reply += "0A";
}
- send_reply(reply.c_str());
+ send_reply(reply);
return REPLY_NONE;
}
@@ -1126,7 +1122,7 @@ debug_gdbstub::cmd_reply debug_gdbstub::handle_q(const char *buf)
{
std::string reply = string_format("PacketSize=%x", MAX_PACKET_SIZE);
reply += ";qXfer:features:read+";
- send_reply(reply.c_str());
+ send_reply(reply);
return REPLY_NONE;
}
else if ( name == "Xfer" )
@@ -1147,7 +1143,7 @@ debug_gdbstub::cmd_reply debug_gdbstub::handle_q(const char *buf)
else
reply += 'l';
reply += m_target_xml.substr(offset, length);
- send_reply(reply.c_str());
+ send_reply(reply);
m_target_xml_sent = true;
return REPLY_NONE;
}
@@ -1334,7 +1330,7 @@ void debug_gdbstub::send_stop_packet()
if ( m_target_xml_sent )
for ( const auto &gdb_regnum: m_stop_reply_registers )
reply += string_format("%02x:%s;", gdb_regnum, get_register_string(gdb_regnum));
- send_reply(reply.c_str());
+ send_reply(reply);
}
//-------------------------------------------------------------------------