summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--src/devices/bus/neogeo/prot_cmc.cpp11
-rw-r--r--src/devices/bus/nes/nes_unif.hxx10
-rw-r--r--src/devices/cpu/dsp32/dsp32dis.cpp4
-rw-r--r--src/lib/util/aviio.cpp81
-rw-r--r--src/lib/util/aviio.h2
-rw-r--r--src/mame/amiga/arsystems.cpp5
-rw-r--r--src/mame/capcom/cps3.cpp10
-rw-r--r--src/mame/konami/3dom2_te.cpp46
-rw-r--r--src/mame/konami/ksys573.cpp29
-rw-r--r--src/mame/midway/midtunit_v.cpp9
-rw-r--r--src/mame/mit/tx0_v.cpp9
-rw-r--r--src/mame/namco/namcos22_v.cpp10
-rw-r--r--src/mame/namco/namcos23.cpp33
-rw-r--r--src/mame/next/next.cpp23
-rw-r--r--src/mame/next/next.h2
-rw-r--r--src/mame/nintendo/pin64.cpp22
-rw-r--r--src/mame/sega/chihiro.cpp32
-rw-r--r--src/mame/sega/coolridr.cpp7
-rw-r--r--src/mame/sega/naomi.cpp6
-rw-r--r--src/mame/snk/hng64_a.cpp2
-rw-r--r--src/mame/subsino/subsino_m.cpp15
-rw-r--r--src/mame/tvgames/generalplus_gpl16250_nand.cpp6
-rw-r--r--src/mame/tvgames/generalplus_gpl32612.cpp6
-rw-r--r--src/mame/tvgames/spg29x.cpp6
-rw-r--r--src/osd/modules/output/network.cpp5
25 files changed, 160 insertions, 231 deletions
diff --git a/src/devices/bus/neogeo/prot_cmc.cpp b/src/devices/bus/neogeo/prot_cmc.cpp
index bba91d1ff74..5ddda3f2ada 100644
--- a/src/devices/bus/neogeo/prot_cmc.cpp
+++ b/src/devices/bus/neogeo/prot_cmc.cpp
@@ -723,9 +723,9 @@ void cmc_prot_device::cmc50_m1_decrypt(uint8_t* romcrypt, uint32_t romcrypt_size
memcpy(rom2,rom, 0x10000);
memcpy(rom2 + 0x10000, rom, 0x80000);
- #if 0
+ if (0)
{
- auto filename = std::string{ machine().system().name } + "_m1.dump";
+ auto filename = std::string(machine().system().name) + "_m1.dump";
auto fp = fopen(filename.c_str(), "w+b");
if (fp)
{
@@ -733,12 +733,10 @@ void cmc_prot_device::cmc50_m1_decrypt(uint8_t* romcrypt, uint32_t romcrypt_size
fclose(fp);
}
}
- #endif
-
- #if 0
+ if (0)
{
- auto filename = std::string{ machine().system().name } + "_m1extra.dump";
+ auto filename = std::string(machine().system().name) + "_m1extra.dump";
auto fp = fopen(filename.c_str(), "w+b");
if (fp)
{
@@ -746,5 +744,4 @@ void cmc_prot_device::cmc50_m1_decrypt(uint8_t* romcrypt, uint32_t romcrypt_size
fclose(fp);
}
}
- #endif
}
diff --git a/src/devices/bus/nes/nes_unif.hxx b/src/devices/bus/nes/nes_unif.hxx
index 85dacf1846b..ff900d88913 100644
--- a/src/devices/bus/nes/nes_unif.hxx
+++ b/src/devices/bus/nes/nes_unif.hxx
@@ -500,11 +500,11 @@ void nes_cart_slot_device::call_load_unif()
#if SPLIT_PRG
{
- auto outname = std::string{ filename() } + ".prg";
+ auto outname = std::string(filename()) + ".prg";
auto prgout = fopen(outname.c_str(), "wb");
if (prgout)
{
- fwrite(m_cart->get_prg_base(), 1, 0x4000 * m_cart->get_prg_size(), prgout);
+ ::fwrite(m_cart->get_prg_base(), 1, 0x4000 * m_cart->get_prg_size(), prgout);
osd_printf_error("Created PRG chunk\n");
}
@@ -515,16 +515,18 @@ void nes_cart_slot_device::call_load_unif()
#if SPLIT_CHR
if (state->m_chr_chunks > 0)
{
- auto outname = std::string{ filename() } + ".chr";
+ auto outname = std::string(filename()) + ".chr";
auto chrout = fopen(outname.c_str(), "wb");
if (chrout)
{
- fwrite(m_cart->get_vrom_base(), 1, m_cart->get_vrom_size(), chrout);
+ ::fwrite(m_cart->get_vrom_base(), 1, m_cart->get_vrom_size(), chrout);
osd_printf_error("Created CHR chunk\n");
}
+
fclose(chrout);
}
#endif
+
// SETUP steps 7: allocate the remaining pointer, when needed
if (vram_size)
m_cart->vram_alloc(vram_size);
diff --git a/src/devices/cpu/dsp32/dsp32dis.cpp b/src/devices/cpu/dsp32/dsp32dis.cpp
index 2c1b095e9c1..1fc0d225a70 100644
--- a/src/devices/cpu/dsp32/dsp32dis.cpp
+++ b/src/devices/cpu/dsp32/dsp32dis.cpp
@@ -442,10 +442,10 @@ offs_t dsp32c_disassembler::disassemble(std::ostream &stream, offs_t pc, const d
const char *rS2 = regname[(op >> 0) & 0x1f];
const char *s = sizesuffix[(op >> 31) & 1];
uint8_t threeop = (op >> 11) & 1;
- char condbuf[40] = { 0 };
+ std::string condbuf;
if ((op >> 10) & 1)
- sprintf(condbuf, "if (%s) ", condtable[(op >> 12) & 15]);
+ condbuf = "if (" + std::string(condtable[(op >> 12) & 15]) + ") ";
switch ((op >> 21) & 15)
{
diff --git a/src/lib/util/aviio.cpp b/src/lib/util/aviio.cpp
index e4865059676..18df706ef3a 100644
--- a/src/lib/util/aviio.cpp
+++ b/src/lib/util/aviio.cpp
@@ -9,6 +9,9 @@
***************************************************************************/
#include "aviio.h"
+
+#include "strformat.h"
+
#include "osdcomm.h"
#include "osdfile.h"
@@ -16,6 +19,7 @@
#include <cassert>
#include <cstdlib>
#include <cstring>
+#include <iostream>
/***************************************************************************
@@ -457,7 +461,7 @@ public:
virtual ~avi_file_impl() override;
- virtual void printf_chunks() override;
+ virtual void display_chunks() override;
virtual movie_info const &get_movie_info() const override;
virtual std::uint32_t first_sample_in_frame(std::uint32_t framenum) const override;
@@ -539,7 +543,7 @@ private:
error soundbuf_flush(bool only_flush_full);
// debugging
- void printf_chunk_recursive(avi_chunk const *chunk, int indent);
+ void display_chunk_recursive(avi_chunk const *chunk, int indent);
/* shared data */
osd_file::ptr m_file; /* pointer to open file */
@@ -711,26 +715,6 @@ inline void put_64bits(std::uint8_t *data, std::uint64_t value)
}
-/**
- * @fn static void u64toa(std::uint64_t val, char *output)
- *
- * @brief 64toas.
- *
- * @param val The value.
- * @param [in,out] output If non-null, the output.
- */
-
-inline void u64toa(std::uint64_t val, char *output)
-{
- auto lo = std::uint32_t(val & 0xffffffff);
- auto hi = std::uint32_t(val >> 32);
- if (hi != 0)
- sprintf(output, "%X%08X", hi, lo);
- else
- sprintf(output, "%X", lo);
-}
-
-
/*-------------------------------------------------
set_stream_chunk_info - set the chunk info
for a given chunk within a stream
@@ -1609,20 +1593,20 @@ avi_file_impl::~avi_file_impl()
/*-------------------------------------------------
- avi_printf_chunks - print the chunks in a file
+ display_chunks - print the chunks in a file
-------------------------------------------------*/
/**
- * @fn void avi_printf_chunks(avi_file *file)
+ * @fn void display_chunks(avi_file *file)
*
* @brief Avi printf chunks.
*
* @param [in,out] file If non-null, the file.
*/
-void avi_file_impl::printf_chunks()
+void avi_file_impl::display_chunks()
{
- printf_chunk_recursive(&m_rootchunk, 0);
+ display_chunk_recursive(&m_rootchunk, 0);
}
@@ -3561,12 +3545,12 @@ avi_file::error avi_file_impl::soundbuf_flush(bool only_flush_full)
/*-------------------------------------------------
- printf_chunk_recursive - print information
+ display_chunk_recursive - print information
about a chunk recursively
-------------------------------------------------*/
/**
- * @fn static void printf_chunk_recursive(avi_file *file, avi_chunk *container, int indent)
+ * @fn static void display_chunk_recursive(avi_file *file, avi_chunk *container, int indent)
*
* @brief Printf chunk recursive.
*
@@ -3575,34 +3559,33 @@ avi_file::error avi_file_impl::soundbuf_flush(bool only_flush_full)
* @param indent The indent.
*/
-void avi_file_impl::printf_chunk_recursive(avi_chunk const *container, int indent)
+void avi_file_impl::display_chunk_recursive(avi_chunk const *container, int indent)
{
- char size[20], offset[20];
avi_chunk curchunk;
error avierr;
- /* iterate over chunks in this container */
+ // iterate over chunks in this container
for (avierr = get_first_chunk(container, curchunk); avierr == error::NONE; avierr = get_next_chunk(container, curchunk))
{
std::uint32_t chunksize = curchunk.size;
bool recurse = false;
- u64toa(curchunk.size, size);
- u64toa(curchunk.offset, offset);
- printf("%*schunk = %c%c%c%c, size=%s (%s)\n", indent, "",
+ util::stream_format(std::cout, "%*schunk = %c%c%c%c, size=%X (%X)\n",
+ indent, "",
std::uint8_t(curchunk.type >> 0),
std::uint8_t(curchunk.type >> 8),
std::uint8_t(curchunk.type >> 16),
std::uint8_t(curchunk.type >> 24),
- size, offset);
+ curchunk.size,
+ curchunk.offset);
- /* certain chunks are just containers; recurse into them */
+ // certain chunks are just containers; recurse into them
switch (curchunk.type)
{
- /* basic containers */
+ // basic containers
case CHUNKTYPE_RIFF:
case CHUNKTYPE_LIST:
- printf("%*stype = %c%c%c%c\n", indent, "",
+ util::stream_format(std::cout, "%*stype = %c%c%c%c\n", indent, "",
std::uint8_t(curchunk.listtype >> 0),
std::uint8_t(curchunk.listtype >> 8),
std::uint8_t(curchunk.listtype >> 16),
@@ -3612,34 +3595,34 @@ void avi_file_impl::printf_chunk_recursive(avi_chunk const *container, int inden
break;
}
- /* print data within the chunk */
+ // print data within the chunk
if (chunksize > 0 && curchunk.size < 1024 * 1024)
{
std::unique_ptr<std::uint8_t []> data;
- /* read the data for a chunk */
+ // read the data for a chunk
avierr = read_chunk_data(curchunk, data);
if (avierr == error::NONE)
{
- std::uint32_t const bytes = (std::min)(std::uint32_t(512), chunksize);
+ auto bytes = std::min<std::uint32_t>(512, chunksize);
for (std::uint32_t i = 0; i < bytes; i++)
{
- if (i % 16 == 0) printf("%*s ", indent, "");
- printf("%02X ", data[i]);
- if (i % 16 == 15) printf("\n");
+ if (i % 16 == 0) util::stream_format(std::cout, "%*s ", indent, "");
+ util::stream_format(std::cout, "%02X ", data[i]);
+ if (i % 16 == 15) std::cout << "\n";
}
- if (chunksize % 16 != 0) printf("\n");
+ if (chunksize % 16 != 0) std::cout << "\n";
}
}
- /* if we're recursing, dive down */
+ // if we're recursing, dive down
if (recurse)
- printf_chunk_recursive(&curchunk, indent + 4);
+ display_chunk_recursive(&curchunk, indent + 4);
}
- /* if we didn't get a legitimate error, indicate that */
+ // if we didn't get a legitimate error, indicate that
if (avierr != error::END)
- printf("[chunk error %d]\n", int(avierr));
+ std::cout << "[chunk error " << int(avierr) << "]\n";
}
} // anonymous namespace
diff --git a/src/lib/util/aviio.h b/src/lib/util/aviio.h
index 4fdcf79b5bf..5dccfa1d64c 100644
--- a/src/lib/util/aviio.h
+++ b/src/lib/util/aviio.h
@@ -112,7 +112,7 @@ public:
static error create(std::string const &filename, movie_info const &info, ptr &file);
virtual ~avi_file();
- virtual void printf_chunks() = 0;
+ virtual void display_chunks() = 0;
static const char *error_string(error err);
virtual movie_info const &get_movie_info() const = 0;
diff --git a/src/mame/amiga/arsystems.cpp b/src/mame/amiga/arsystems.cpp
index 60216e0972d..53cf48f1100 100644
--- a/src/mame/amiga/arsystems.cpp
+++ b/src/mame/amiga/arsystems.cpp
@@ -936,12 +936,12 @@ void arcadia_amiga_state::generic_decode(const char *tag, int bit7, int bit6, in
for (i = 0; i < 0x20000/2; i++)
rom[i] = bitswap<16>(rom[i], 15,14,13,12,11,10,9,8, bit7,bit6,bit5,bit4,bit3,bit2,bit1,bit0);
- #if 0
+ if (0)
{
uint8_t *ROM = memregion(tag)->base();
// int size = memregion(tag)->bytes();
- auto filename = std::string{ "decrypted_" } + machine().system().name;
+ auto filename = "decrypted_" + std::string(machine().system().name);
auto fp = fopen(filename.c_str(), "w+b");
if (fp)
{
@@ -951,7 +951,6 @@ void arcadia_amiga_state::generic_decode(const char *tag, int bit7, int bit6, in
fclose(fp);
}
}
- #endif
}
diff --git a/src/mame/capcom/cps3.cpp b/src/mame/capcom/cps3.cpp
index 4a5ded7ddfc..c1736e4f5af 100644
--- a/src/mame/capcom/cps3.cpp
+++ b/src/mame/capcom/cps3.cpp
@@ -858,18 +858,18 @@ void cps3_state::decrypt_bios()
u32 xormask = cps3_mask(i, m_key1, m_key2);
coderegion[i/4] = dword ^ xormask;
}
-#if 0
- /* Dump to file */
+
+ // Dump to file
+ if (0)
{
- auto filename = std::string{ machine().system().name } + "_bios.dump";
+ auto filename = std::string(machine().system().name) + "_bios.dump";
auto fp = fopen(filename.c_str(), "w+b");
if (fp)
{
- fwrite(m_decrypted_bios, 0x080000, 1, fp);
+ fwrite(coderegion, codelength, 1, fp);
fclose(fp);
}
}
-#endif
}
diff --git a/src/mame/konami/3dom2_te.cpp b/src/mame/konami/3dom2_te.cpp
index 06f0e780039..e9808eb470f 100644
--- a/src/mame/konami/3dom2_te.cpp
+++ b/src/mame/konami/3dom2_te.cpp
@@ -12,6 +12,11 @@
#include "3dom2.h"
#include <cmath>
+#include <sstream>
+
+//#define VERBOSE 1
+#include "logmacro.h"
+
/*
TODO:
@@ -568,8 +573,7 @@ static void write_te_reg(uint32_t &reg, uint32_t data, m2_te_device::te_reg_wmod
}
}
-#if 0
-static const char *get_reg_name(uint32_t unit, uint32_t reg)
+static std::string get_reg_name(uint32_t unit, uint32_t reg)
{
static const char *gc_regs[] =
{
@@ -634,30 +638,25 @@ static const char *get_reg_name(uint32_t unit, uint32_t reg)
"ESCapData",
};
- static char buffer[128];
-
switch (unit)
{
case 0:
{
if (reg < sizeof(gc_regs))
{
- sprintf(buffer, "GC:%s", gc_regs[reg]);
- return buffer;
+ return std::string("GC:") + gc_regs[reg];
}
break;
}
case 1:
{
- sprintf(buffer, "SE:????");
- return buffer;
+ return "SE:????";
}
case 2:
{
if (reg < sizeof(es_regs))
{
- sprintf(buffer, "ES:%s", es_regs[reg]);
- return buffer;
+ return std::string("ES:") + es_regs[reg];
}
break;
}
@@ -665,8 +664,7 @@ static const char *get_reg_name(uint32_t unit, uint32_t reg)
{
// if (reg < sizeof(tm_regs))
{
- sprintf(buffer, "TM:????");
- return buffer;
+ return "TM:????";
}
break;
}
@@ -674,8 +672,7 @@ static const char *get_reg_name(uint32_t unit, uint32_t reg)
{
if (reg < sizeof(db_regs))
{
- sprintf(buffer, "DB:%s", db_regs[reg]);
- return buffer;
+ return std::string("DB:") + db_regs[reg];
}
break;
}
@@ -683,7 +680,7 @@ static const char *get_reg_name(uint32_t unit, uint32_t reg)
return "????";
}
-#endif
+
//**************************************************************************
// TRIANGLE ENGINE DEVICE
//**************************************************************************
@@ -825,7 +822,7 @@ void m2_te_device::write(offs_t offset, uint32_t data)
uint32_t reg = offset & 0x1ff;
te_reg_wmode wmode = static_cast<te_reg_wmode>((offset >> 9) & 3);
-// logerror("%s: TE W[%.8x] (%s) %.8x\n", machine().describe_context(), 0x00040000 + (offset << 2), get_reg_name(unit, reg), data);
+ LOG("%s: TE W[%.8x] (%s) %.8x\n", machine().describe_context(), 0x00040000 + (offset << 2), get_reg_name(unit, reg), data);
switch (unit)
{
@@ -1143,26 +1140,19 @@ void m2_te_device::log_triangle(uint32_t flags)
for (uint32_t i = 0; i < 3; ++i)
{
- char s[64];
- char t[64];
- char p[64];
-
- s[0] = '\0';
- t[0] = '\0';
- p[0] = '\0';
-
const se_vtx &vtx = m_se.vertices[i];
+ std::ostringstream optional;
if (flags & VTX_FLAG_SHAD)
- sprintf(s, "COLR[R:%.6f G:%.6f B:%.6f A:%.6f]", vtx.r, vtx.g, vtx.b, vtx.a);
+ util::stream_format(optional, " COLR[R:%.6f G:%.6f B:%.6f A:%.6f]", vtx.r, vtx.g, vtx.b, vtx.a);
if (flags & VTX_FLAG_TEXT)
- sprintf(t, "TEXT[UW:%.6f VW:%.6f]", vtx.uw, vtx.vw);
+ util::stream_format(optional, " TEXT[UW:%.6f VW:%.6f]", vtx.uw, vtx.vw);
if (flags & VTX_FLAG_PRSP)
- sprintf(p, "PRSP[W:%.6f]", vtx.w);
+ util::stream_format(optional, " PRSP[W:%.6f]", vtx.w);
- logerror("V%d: X:%.6f Y:%.6f %s %s %s\n", i, vtx.x, vtx.y, s, t, p);
+ logerror("V%d: X:%.6f Y:%.6f%s\n", i, vtx.x, vtx.y, std::move(optional).str());
}
}
diff --git a/src/mame/konami/ksys573.cpp b/src/mame/konami/ksys573.cpp
index acc3986a3e4..dc1b43a53d8 100644
--- a/src/mame/konami/ksys573.cpp
+++ b/src/mame/konami/ksys573.cpp
@@ -2344,7 +2344,7 @@ void pnchmn_state::init_pnchmn()
void ksys573_state::gunmania_w(offs_t offset, uint16_t data, uint16_t mem_mask)
{
- char s[ 1024 ] = "";
+ std::string message;
switch( offset )
{
@@ -2356,41 +2356,40 @@ void ksys573_state::gunmania_w(offs_t offset, uint16_t data, uint16_t mem_mask)
switch( data & 0xa0 )
{
case 0x20:
- strcat( s, "cable holder motor release " );
-
+ message += "cable holder motor release ";
m_cable_holder_release = 1;
break;
case 0x80:
- strcat( s, "cable holder motor catch " );
+ message += "cable holder motor catch ";
m_cable_holder_release = 0;
break;
case 0xa0:
- strcat( s, "cable holder motor stop " );
+ message += "cable holder motor stop ";
break;
}
switch( data & 0x50 )
{
case 0x10:
- strcat( s, "bullet supply motor rotate " );
+ message += "bullet supply motor rotate ";
break;
case 0x40:
- strcat( s, "bullet supply motor reverse " );
+ message += "bullet supply motor reverse ";
break;
case 0x50:
- strcat( s, "bullet shutter motor unknown " );
+ message += "bullet shutter motor unknown ";
break;
}
switch( data & 0x0a )
{
case 0x02:
- strcat( s, "tank shutter motor close " );
+ message += "tank shutter motor close ";
if( m_tank_shutter_position > 0 )
{
@@ -2400,7 +2399,7 @@ void ksys573_state::gunmania_w(offs_t offset, uint16_t data, uint16_t mem_mask)
break;
case 0x08:
- strcat( s, "tank shutter motor open " );
+ message += "tank shutter motor open ";
if( m_tank_shutter_position < 100 )
{
@@ -2410,20 +2409,18 @@ void ksys573_state::gunmania_w(offs_t offset, uint16_t data, uint16_t mem_mask)
break;
case 0x0a:
- strcat( s, "tank shutter motor unknown " );
+ message += "tank shutter motor unknown ";
break;
}
if( ( data & ~0xfa ) != 0 )
{
- char unknown[ 128 ];
- sprintf( unknown, "unknown bits %08x", data & ~0xfa );
- strcat( s, unknown );
+ message += util::string_format("unknown bits %08x", data & ~0xfa);
}
- if( s[ 0 ] != 0 )
+ if( !message.empty() )
{
-// popmessage( "%s", s );
+ LOG( message );
}
break;
diff --git a/src/mame/midway/midtunit_v.cpp b/src/mame/midway/midtunit_v.cpp
index 8347c6787dc..603c2b72879 100644
--- a/src/mame/midway/midtunit_v.cpp
+++ b/src/mame/midway/midtunit_v.cpp
@@ -1015,7 +1015,6 @@ void midtunit_video_device::log_bitmap(int command, int bpp, bool Skip)
if (m_log_json)
{
- char hex_buf[11];
rapidjson::StringBuffer s;
rapidjson::PrettyWriter<rapidjson::StringBuffer> writer(s);
emu_file json(m_log_path, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
@@ -1031,13 +1030,13 @@ void midtunit_video_device::log_bitmap(int command, int bpp, bool Skip)
writer.Key("DMAState");
writer.StartObject();
- sprintf(hex_buf, "0x%08x", raw_offset);
+ auto hex_buf = util::string_format("0x%08x", raw_offset);
writer.Key("MemoryAddress");
- writer.String(hex_buf);
+ writer.String(hex_buf.c_str());
- sprintf(hex_buf, "0x%08x", m_dma_state.offset >> 3);
+ hex_buf = util::string_format("0x%08x", m_dma_state.offset >> 3);
writer.Key("ROMSourceOffsetByte");
- writer.String(hex_buf);
+ writer.String(hex_buf.c_str());
writer.Key("ROMSourceOffsetBit");
writer.Int(m_dma_state.offset & 7);
diff --git a/src/mame/mit/tx0_v.cpp b/src/mame/mit/tx0_v.cpp
index 8c7f7924625..c14c670f29a 100644
--- a/src/mame/mit/tx0_v.cpp
+++ b/src/mame/mit/tx0_v.cpp
@@ -232,9 +232,6 @@ void tx0_state::tx0_draw_hline(bitmap_ind16 &bitmap, int x, int y, int width, in
*/
void tx0_state::tx0_draw_panel_backdrop(bitmap_ind16 &bitmap)
{
- int i;
- char buf[3];
-
/* fill with black */
const rectangle panel_bitmap_bounds(0, panel_window_width-1, 0, panel_window_height-1);
m_panel_bitmap.fill(pen_panel_bg, panel_bitmap_bounds);
@@ -251,10 +248,10 @@ void tx0_state::tx0_draw_panel_backdrop(bitmap_ind16 &bitmap)
tx0_draw_string(bitmap, "cm", x_panel_col1a_offset+8, y_panel_tss_offset, color_panel_caption);
tx0_draw_string(bitmap, "TSS", x_panel_col1a_offset+24, y_panel_tss_offset, color_panel_caption);
tx0_draw_string(bitmap, "lr", x_panel_col1a_offset+168, y_panel_tss_offset, color_panel_caption);
- for (i=0; i<16; i++)
+ for (int i=0; i<16; i++)
{
- sprintf(buf, "%2o", i);
- tx0_draw_string(bitmap, buf, x_panel_col1a_offset, y_panel_tss_offset+8+i*8, color_panel_caption);
+ auto buf = util::string_format("%2o", i);
+ tx0_draw_string(bitmap, buf.c_str(), x_panel_col1a_offset, y_panel_tss_offset+8+i*8, color_panel_caption);
}
/* column separator */
diff --git a/src/mame/namco/namcos22_v.cpp b/src/mame/namco/namcos22_v.cpp
index a59f2a94641..077d310d5aa 100644
--- a/src/mame/namco/namcos22_v.cpp
+++ b/src/mame/namco/namcos22_v.cpp
@@ -1490,17 +1490,15 @@ void namcos22_state::simulate_slavedsp()
default:
{
- std::string polydata;
+ std::ostringstream polydata;
int i = 0;
for (; i < len && i < 0x20; i++)
{
- char h[8];
- sprintf(h, " %06x", src[i] & 0xffffff);
- polydata += h;
+ util::stream_format(polydata ," %06x", src[i] & 0xffffff);
}
if (i < len)
- polydata += " (...)";
- logerror("simulate_slavedsp unknown 3d data: len=0x%x code=0x%x addr=0x%x!%s\n", len, code, index, polydata);
+ polydata << " (...)";
+ logerror("simulate_slavedsp unknown 3d data: len=0x%x code=0x%x addr=0x%x!%s\n", len, code, index, std::move(polydata).str());
return;
}
}
diff --git a/src/mame/namco/namcos23.cpp b/src/mame/namco/namcos23.cpp
index 0a2251fb039..ed5890e5726 100644
--- a/src/mame/namco/namcos23.cpp
+++ b/src/mame/namco/namcos23.cpp
@@ -1807,13 +1807,12 @@ void namcos23_state::c435_state_set_projection_matrix_line(const uint16_t *param
// line 2: 0 1 -(sy-b)/(sx/t) 0 0 -1 -(sy+b)/(sx/t) 0
// line 3: 0 0 -1 c 0 0 0 sx/t
- char buf[4096];
- char *p = buf;
- p += sprintf(p, "projection matrix line:");
+ std::ostringstream buf;
+ buf << "projection matrix line:";
for(int i=0; i<8; i++)
- p += sprintf(p, " %f", f24_to_f32((param[2*i+1] << 16) | param[2*i+2]));
- p += sprintf(p, "\n");
- logerror(buf);
+ util::stream_format(buf, " %f", f24_to_f32((param[2*i+1] << 16) | param[2*i+2]));
+ buf << "\n";
+ logerror(std::move(buf).str());
}
void namcos23_state::c435_state_set(uint16_t type, const uint16_t *param)
@@ -1822,13 +1821,12 @@ void namcos23_state::c435_state_set(uint16_t type, const uint16_t *param)
case 0x0001: c435_state_set_interrupt(param); break;
case 0x00c8: c435_state_set_projection_matrix_line(param); break;
default: {
- char buf[4096];
- char *p = buf;
- p += sprintf(buf, "WARNING: Unhandled state type %04x :", type);
+ std::ostringstream buf;
+ util::stream_format(buf, "WARNING: Unhandled state type %04x :", type);
for(int i=0; i<c435_get_state_entry_size(type); i++)
- p += sprintf(p, " %04x", param[i]);
- p += sprintf(p, "\n");
- logerror(buf);
+ util::stream_format(buf, " %04x", param[i]);
+ buf << "\n";
+ logerror(std::move(buf).str());
break;
}
}
@@ -2069,13 +2067,12 @@ void namcos23_state::c435_pio_w(uint16_t data)
}
if(!known) {
- char buf[4096];
- char *p = buf;
- p += sprintf(p, "c435 -");
+ std::ostringstream buf;
+ buf << "c435 -";
for(int i=0; i<m_c435_buffer_pos; i++)
- p += sprintf(p, " %04x", m_c435_buffer[i]);
- p += sprintf(p, "\n");
- logerror(buf);
+ util::stream_format(buf, " %04x", m_c435_buffer[i]);
+ buf << "\n";
+ logerror(std::move(buf).str());
}
m_c435_buffer_pos = 0;
diff --git a/src/mame/next/next.cpp b/src/mame/next/next.cpp
index 07d59227658..61334bb9c4f 100644
--- a/src/mame/next/next.cpp
+++ b/src/mame/next/next.cpp
@@ -277,13 +277,12 @@ bool const next_state::dma_has_saved[0x20] = {
false, false, false, false, false, false, false, false,
};
-const char *next_state::dma_name(int slot)
+std::string next_state::dma_name(int slot)
{
- static char buf[32];
if(dma_targets[slot])
return dma_targets[slot];
- sprintf(buf, "<%02x>", slot);
- return buf;
+
+ return util::string_format("<%02x>", slot);
}
void next_state::dma_drq_w(int slot, bool state)
@@ -458,8 +457,7 @@ uint32_t next_state::dma_regs_r(offs_t offset)
break;
}
- const char *name = dma_name(slot);
- logerror("dma_regs_r %s:%d %08x (%08x)\n", name, reg, res, maincpu->pc());
+ logerror("dma_regs_r %s:%d %08x (%08x)\n", dma_name(slot), reg, res, maincpu->pc());
return res;
}
@@ -469,9 +467,7 @@ void next_state::dma_regs_w(offs_t offset, uint32_t data)
int slot = offset >> 2;
int reg = offset & 3;
- const char *name = dma_name(slot);
-
- logerror("dma_regs_w %s:%d %08x (%08x)\n", name, reg, data, maincpu->pc());
+ logerror("dma_regs_w %s:%d %08x (%08x)\n", dma_name(slot), reg, data, maincpu->pc());
switch(reg) {
case 0:
dma_slots[slot].start = data;
@@ -494,10 +490,8 @@ uint32_t next_state::dma_ctrl_r(offs_t offset)
int slot = offset >> 2;
int reg = offset & 3;
- const char *name = dma_name(slot);
-
if(maincpu->pc() != 0x409bb4e)
- logerror("dma_ctrl_r %s:%d %02x (%08x)\n", name, reg, dma_slots[slot].state, maincpu->pc());
+ logerror("dma_ctrl_r %s:%d %02x (%08x)\n", dma_name(slot), reg, dma_slots[slot].state, maincpu->pc());
return reg ? 0 : dma_slots[slot].state << 24;
}
@@ -506,8 +500,7 @@ void next_state::dma_ctrl_w(offs_t offset, uint32_t data, uint32_t mem_mask)
{
int slot = offset >> 2;
int reg = offset & 3;
- const char *name = dma_name(slot);
- logerror("dma_ctrl_w %s:%d %08x @ %08x (%08x)\n", name, reg, data, mem_mask, maincpu->pc());
+ logerror("dma_ctrl_w %s:%d %08x @ %08x (%08x)\n", dma_name(slot), reg, data, mem_mask, maincpu->pc());
if(!reg) {
if(ACCESSING_BITS_16_23)
dma_do_ctrl_w(slot, data >> 16);
@@ -518,7 +511,7 @@ void next_state::dma_ctrl_w(offs_t offset, uint32_t data, uint32_t mem_mask)
void next_state::dma_do_ctrl_w(int slot, uint8_t data)
{
- const char *name = dma_name(slot);
+ const auto name = dma_name(slot);
#if 0
logerror("dma_ctrl_w %s %02x (%08x)\n", name, data, maincpu->pc());
diff --git a/src/mame/next/next.h b/src/mame/next/next.h
index fc0162df2ed..02ad9541704 100644
--- a/src/mame/next/next.h
+++ b/src/mame/next/next.h
@@ -209,7 +209,7 @@ private:
void irq_set(int id, bool raise);
void irq_check();
- const char *dma_name(int slot);
+ std::string dma_name(int slot);
void dma_do_ctrl_w(int slot, uint8_t data);
void dma_drq_w(int slot, bool state);
void dma_read(int slot, uint8_t &val, bool &eof, bool &err);
diff --git a/src/mame/nintendo/pin64.cpp b/src/mame/nintendo/pin64.cpp
index 1996b9cb2e5..05aa530e1b4 100644
--- a/src/mame/nintendo/pin64.cpp
+++ b/src/mame/nintendo/pin64.cpp
@@ -4,7 +4,7 @@
#include "emu.h"
#include "pin64.h"
-#define CAP_NAME "pin64_%d.cap"
+static const char CAP_NAME[] = "pin64_%d.cap";
// pin64_fileutil_t members
@@ -245,11 +245,10 @@ void pin64_t::start(int frames)
if (m_capture_file)
fatalerror("PIN64: Call to start() while already capturing\n");
- char name_buf[256];
- sprintf(name_buf, CAP_NAME, m_capture_index);
+ auto filename = util::string_format(CAP_NAME, m_capture_index);
m_capture_index++;
- m_capture_file = fopen(name_buf, "wb");
+ m_capture_file = fopen(filename.c_str(), "wb");
m_capture_frames = frames;
@@ -488,20 +487,17 @@ void pin64_t::clear() {
void pin64_t::init_capture_index()
{
- char name_buf[256];
- bool found = true;
-
m_capture_index = 0;
- do {
- sprintf(name_buf, CAP_NAME, m_capture_index);
+ while (true) {
+ auto filename = util::string_format(CAP_NAME, m_capture_index);
+ auto file = fopen(filename.c_str(), "rb");
- FILE* temp = fopen(name_buf, "rb");
- if (temp == nullptr) {
+ if (file == nullptr) {
break;
} else {
- fclose(temp);
+ fclose(file);
m_capture_index++;
}
- } while(found);
+ }
}
diff --git a/src/mame/sega/chihiro.cpp b/src/mame/sega/chihiro.cpp
index 1c0c31e0e05..afbf4663d07 100644
--- a/src/mame/sega/chihiro.cpp
+++ b/src/mame/sega/chihiro.cpp
@@ -703,23 +703,19 @@ void chihiro_state::jamtable_disasm(address_space &space, uint32_t address, uint
uint32_t op2 = space.read_dword_unaligned(addr);
addr += 4;
- char sop1[16];
- char sop2[16];
- char pcrel[16];
+ std::string sop1;
+ std::string pcrel;
if (opcode == 0xe1)
{
opcode = op2 & 255;
op2 = op1;
- //op1=edi;
- sprintf(sop2, "%08X", op2);
- sprintf(sop1, "ACC");
- sprintf(pcrel, "PC+ACC");
+ sop1 = "ACC";
+ pcrel = "PC+ACC";
}
else
{
- sprintf(sop2, "%08X", op2);
- sprintf(sop1, "%08X", op1);
- sprintf(pcrel, "%08X", base + 9 + op1);
+ sop1 = util::string_format("%08X", op1);
+ pcrel = util::string_format("%08X", base + 9 + op1);
}
con.printf("%08X ", base);
// dl=instr ebx=par1 eax=par2
@@ -736,33 +732,33 @@ void chihiro_state::jamtable_disasm(address_space &space, uint32_t address, uint
// | | Reserved | Bus Number | Device Number | Function Number | Register Number |0|0|
// +-+----------+------------+---------------+-----------------+-----------------+-+-+
// 31 - Enable bit
- con.printf("POKEPCI PCICONF[%s]=%s\n", sop2, sop1);
+ con.printf("POKEPCI PCICONF[%08X]=%s\n", op2, sop1);
break;
case 0x02:
- con.printf("OUTB PORT[%s]=%s\n", sop2, sop1);
+ con.printf("OUTB PORT[%08X]=%s\n", op2, sop1);
break;
case 0x03:
- con.printf("POKE MEM[%s]=%s\n", sop2, sop1);
+ con.printf("POKE MEM[%08X]=%s\n", op2, sop1);
break;
case 0x04:
- con.printf("BNE IF ACC != %s THEN PC=%s\n", sop2, pcrel);
+ con.printf("BNE IF ACC != %08X THEN PC=%s\n", op2, pcrel);
break;
case 0x05:
// out cf8,op2
// in acc,cfc
- con.printf("PEEKPCI ACC=PCICONF[%s]\n", sop2);
+ con.printf("PEEKPCI ACC=PCICONF[%08X]\n", op2);
break;
case 0x06:
- con.printf("AND/OR ACC=(ACC & %s) | %s\n", sop2, sop1);
+ con.printf("AND/OR ACC=(ACC & %08X) | %s\n", op2, sop1);
break;
case 0x07:
con.printf("BRA PC=%s\n", pcrel);
break;
case 0x08:
- con.printf("INB ACC=PORT[%s]\n", sop2);
+ con.printf("INB ACC=PORT[%08X]\n", op2);
break;
case 0x09:
- con.printf("PEEK ACC=MEM[%s]\n", sop2);
+ con.printf("PEEK ACC=MEM[%08X]\n", op2);
break;
case 0xee:
con.printf("END\n");
diff --git a/src/mame/sega/coolridr.cpp b/src/mame/sega/coolridr.cpp
index 5c40b410e80..b9157707d4a 100644
--- a/src/mame/sega/coolridr.cpp
+++ b/src/mame/sega/coolridr.cpp
@@ -3173,10 +3173,8 @@ void coolridr_state::machine_start()
if (0)
{
- FILE *fp;
- char filename[256];
- sprintf(filename,"expanded_%s_gfx", machine().system().name);
- fp=fopen(filename, "w+b");
+ auto filename = "expanded_" + std::string(machine().system().name) + "_gfx";
+ auto fp = fopen(filename.c_str(), "w+b");
if (fp)
{
for (int i=0;i<(0x800000*8);i++)
@@ -3184,7 +3182,6 @@ void coolridr_state::machine_start()
fwrite((uint8_t*)m_expanded_10bit_gfx.get()+(i^1), 1, 1, fp);
}
fclose(fp);
-
}
}
diff --git a/src/mame/sega/naomi.cpp b/src/mame/sega/naomi.cpp
index 59deb2af1ea..7f033017296 100644
--- a/src/mame/sega/naomi.cpp
+++ b/src/mame/sega/naomi.cpp
@@ -10648,10 +10648,8 @@ void naomi_state::create_pic_from_retdat()
{
uint8_t* newregion = rgn_newregion->base();
- FILE *fp;
- char filename[256];
- sprintf(filename,"picbin_%s", machine().system().name);
- fp=fopen(filename, "w+b");
+ auto filename = "picbin_" + std::string(machine().system().name);
+ auto fp = fopen(filename.c_str(), "w+b");
if (fp)
{
fwrite(newregion, outcount, 1, fp);
diff --git a/src/mame/snk/hng64_a.cpp b/src/mame/snk/hng64_a.cpp
index 60455f8b391..fb4760f308f 100644
--- a/src/mame/snk/hng64_a.cpp
+++ b/src/mame/snk/hng64_a.cpp
@@ -89,7 +89,7 @@ void hng64_state::hng64_soundram_w(offs_t offset, uint32_t data, uint32_t mem_ma
if (offset==0x7ffff)
{
logerror("dumping sound program in m_soundram\n");
- auto filename = std::string{"soundram_"} + machine().system().name;
+ auto filename = "soundram_" + std::string(machine().system().name);
auto fp = fopen(filename.c_str(), "w+b");
if (fp)
{
diff --git a/src/mame/subsino/subsino_m.cpp b/src/mame/subsino/subsino_m.cpp
index aefa4b0adcc..a162c503352 100644
--- a/src/mame/subsino/subsino_m.cpp
+++ b/src/mame/subsino/subsino_m.cpp
@@ -81,10 +81,9 @@ void victor21_bitswaps(uint8_t *decrypt, int i)
// Decrypt:
-#if 0
-void dump_decrypted(running_machine& machine, uint8_t* decrypt)
+[[maybe_unused]] static void dump_decrypted(running_machine& machine, uint8_t* decrypt)
{
- auto filename = std::string{ "dat_" } + machine.system().name;
+ auto filename = "dat_" + std::string(machine.system().name);
auto fp = fopen(filename.c_str(), "w+b");
if (fp)
{
@@ -92,19 +91,17 @@ void dump_decrypted(running_machine& machine, uint8_t* decrypt)
fclose(fp);
}
}
-#endif
void subsino_decrypt(running_machine& machine, void (*bitswaps)(uint8_t *decrypt, int i), const uint8_t *xors, int size)
{
- int i;
std::unique_ptr<uint8_t[]> decrypt = std::make_unique<uint8_t[]>(0x10000);
- uint8_t* region = machine.root_device().memregion("maincpu")->base();
+ uint8_t *const region = machine.root_device().memregion("maincpu")->base();
- for (i=0;i<0x10000;i++)
+ for (int i = 0; i < 0x10000; i++)
{
- if (i<size)
+ if (i < size)
{
- decrypt[i] = region[i]^xors[i&7];
+ decrypt[i] = region[i] ^ xors[i & 7];
bitswaps(decrypt.get(), i);
}
else
diff --git a/src/mame/tvgames/generalplus_gpl16250_nand.cpp b/src/mame/tvgames/generalplus_gpl16250_nand.cpp
index 03c6aeabab2..e90e15c04d6 100644
--- a/src/mame/tvgames/generalplus_gpl16250_nand.cpp
+++ b/src/mame/tvgames/generalplus_gpl16250_nand.cpp
@@ -706,10 +706,8 @@ void generalplus_gpac800_game_state::nand_create_stripped_region()
// debug to allow for easy use of unidasm.exe
if (0)
{
- FILE *fp;
- char filename[256];
- sprintf(filename,"stripped_%s", machine().system().name);
- fp=fopen(filename, "w+b");
+ auto filename = "stripped_" + std::string(machine().system().name);
+ auto fp = fopen(filename.c_str(), "w+b");
if (fp)
{
fwrite(&m_strippedrom[0], m_nandblocksize_stripped * numblocks, 1, fp);
diff --git a/src/mame/tvgames/generalplus_gpl32612.cpp b/src/mame/tvgames/generalplus_gpl32612.cpp
index 1645d396ef7..ce516986ffb 100644
--- a/src/mame/tvgames/generalplus_gpl32612.cpp
+++ b/src/mame/tvgames/generalplus_gpl32612.cpp
@@ -297,10 +297,8 @@ void generalplus_gpl32612_game_state::nand_init(int blocksize, int blocksize_str
// debug to allow for easy use of unidasm.exe
if (0)
{
- FILE *fp;
- char filename[256];
- sprintf(filename,"stripped_%s", machine().system().name);
- fp=fopen(filename, "w+b");
+ auto filename = "stripped_" + std::string(machine().system().name);
+ auto fp = fopen(filename.c_str(), "w+b");
if (fp)
{
fwrite(&m_strippedrom[0], blocksize_stripped * numblocks, 1, fp);
diff --git a/src/mame/tvgames/spg29x.cpp b/src/mame/tvgames/spg29x.cpp
index 4f750e2400f..7c139b91f2c 100644
--- a/src/mame/tvgames/spg29x.cpp
+++ b/src/mame/tvgames/spg29x.cpp
@@ -520,10 +520,8 @@ void spg29x_nand_game_state::nand_init(int blocksize, int blocksize_stripped)
// debug to allow for easy use of unidasm.exe
if (0)
{
- FILE *fp;
- char filename[256];
- sprintf(filename,"stripped_%s", machine().system().name);
- fp=fopen(filename, "w+b");
+ auto filename = "stripped_" + std::string(machine().system().name);
+ auto fp = fopen(filename.c_str(), "w+b");
if (fp)
{
fwrite(&m_strippedrom[0], blocksize_stripped * numblocks, 1, fp);
diff --git a/src/osd/modules/output/network.cpp b/src/osd/modules/output/network.cpp
index 0b3729df340..26ce3619a4c 100644
--- a/src/osd/modules/output/network.cpp
+++ b/src/osd/modules/output/network.cpp
@@ -225,9 +225,8 @@ public:
virtual void notify(const char *outname, int32_t value) override
{
- static char buf[256];
- sprintf(buf, "%s = %d\r", ((outname==nullptr) ? "none" : outname), value);
- m_server->deliver_to_all(buf);
+ auto msg = util::string_format("%s = %d\r", ((outname==nullptr) ? "none" : outname), value);
+ m_server->deliver_to_all(msg);
}
// implementation