From 32f48ebb75f4fefcc7bcf0482289c0afa57d9973 Mon Sep 17 00:00:00 2001 From: Erik Date: Sun, 19 Feb 2023 17:24:34 +0000 Subject: Reduced usage of sprintf. (#10892) --- src/devices/bus/isa/3c503.cpp | 2 +- src/devices/bus/neogeo/prot_cmc.cpp | 16 +- src/devices/bus/nes/nes_unif.hxx | 14 +- src/devices/bus/ti99/internal/992board.cpp | 5 +- src/frontend/mame/ui/viewgfx.cpp | 6 +- src/mame/amiga/arsystems.cpp | 6 +- src/mame/atari/harddriv.h | 1 + src/mame/atari/harddriv_v.cpp | 20 +- src/mame/bfm/bfm_sc45_helper.cpp | 16 +- src/mame/capcom/cps2crypt.cpp | 8 +- src/mame/capcom/cps3.cpp | 26 +- src/mame/capcom/mitchell.cpp | 16 +- src/mame/dataeast/deco32.cpp | 5 +- src/mame/excellent/excellent_spr.cpp | 17 - src/mame/igt/videopkr.cpp | 11 +- src/mame/kaneko/kaneko_calc3.cpp | 45 +-- src/mame/nintendo/n64_v.cpp | 627 +++++++++++++++-------------- src/mame/nintendo/n64_v.h | 2 +- src/mame/snk/hng64_a.cpp | 6 +- src/mame/subsino/subsino_m.cpp | 6 +- src/mame/taito/tnzs.cpp | 10 +- src/mame/taito/undrfire_v.cpp | 14 +- src/osd/modules/netdev/pcap.cpp | 7 +- src/tools/chdman.cpp | 13 +- src/tools/image_handler.cpp | 2 +- src/tools/imgtool/modules/psion.cpp | 2 +- src/tools/imgtool/modules/thomson.cpp | 22 +- 27 files changed, 409 insertions(+), 516 deletions(-) diff --git a/src/devices/bus/isa/3c503.cpp b/src/devices/bus/isa/3c503.cpp index 0bf96c34f53..8e95bb60220 100644 --- a/src/devices/bus/isa/3c503.cpp +++ b/src/devices/bus/isa/3c503.cpp @@ -27,7 +27,7 @@ void el2_3c503_device::device_start() { char mac[7]; uint32_t num = machine().rand(); memset(m_prom, 0x57, 16); - sprintf(mac, "\x02\x60\x8c%c%c%c", (num >> 16) & 0xff, (num >> 8) & 0xff, num & 0xff); + snprintf(mac, std::size(mac), "\x02\x60\x8c%c%c%c", (num >> 16) & 0xff, (num >> 8) & 0xff, num & 0xff); memcpy(m_prom, mac, 6); memset(m_rom, 0, 8*1024); // empty m_dp8390->set_mac(mac); diff --git a/src/devices/bus/neogeo/prot_cmc.cpp b/src/devices/bus/neogeo/prot_cmc.cpp index 77591827f54..bba91d1ff74 100644 --- a/src/devices/bus/neogeo/prot_cmc.cpp +++ b/src/devices/bus/neogeo/prot_cmc.cpp @@ -725,12 +725,8 @@ void cmc_prot_device::cmc50_m1_decrypt(uint8_t* romcrypt, uint32_t romcrypt_size #if 0 { - FILE *fp; - const char *gamename = machine().system().name; - char filename[256]; - sprintf(filename, "%s_m1.dump", gamename); - - fp=fopen(filename, "w+b"); + auto filename = std::string{ machine().system().name } + "_m1.dump"; + auto fp = fopen(filename.c_str(), "w+b"); if (fp) { fwrite(rom, rom_size, 1, fp); @@ -742,12 +738,8 @@ void cmc_prot_device::cmc50_m1_decrypt(uint8_t* romcrypt, uint32_t romcrypt_size #if 0 { - FILE *fp; - const char *gamename = machine().system().name; - char filename[256]; - sprintf(filename, "%s_m1extra.dump", gamename); - - fp=fopen(filename, "w+b"); + auto filename = std::string{ machine().system().name } + "_m1extra.dump"; + auto fp = fopen(filename.c_str(), "w+b"); if (fp) { fwrite(&rom[0xf800], 0x800, 1, fp); diff --git a/src/devices/bus/nes/nes_unif.hxx b/src/devices/bus/nes/nes_unif.hxx index b3d3a95f694..85dacf1846b 100644 --- a/src/devices/bus/nes/nes_unif.hxx +++ b/src/devices/bus/nes/nes_unif.hxx @@ -500,11 +500,8 @@ void nes_cart_slot_device::call_load_unif() #if SPLIT_PRG { - FILE *prgout; - char outname[255]; - - sprintf(outname, "%s.prg", filename()); - prgout = fopen(outname, "wb"); + 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); @@ -518,11 +515,8 @@ void nes_cart_slot_device::call_load_unif() #if SPLIT_CHR if (state->m_chr_chunks > 0) { - FILE *chrout; - char outname[255]; - - sprintf(outname, "%s.chr", filename()); - chrout= fopen(outname, "wb"); + 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); diff --git a/src/devices/bus/ti99/internal/992board.cpp b/src/devices/bus/ti99/internal/992board.cpp index 7dae38759ee..1075e6cfb34 100644 --- a/src/devices/bus/ti99/internal/992board.cpp +++ b/src/devices/bus/ti99/internal/992board.cpp @@ -163,15 +163,14 @@ video992_32_device::video992_32_device(const machine_config &mconfig, const char std::string video992_device::tts(attotime t) { - char buf[256]; const char *sign = ""; if (t.seconds() < 0) { t = attotime::zero - t; sign = "-"; } int nsec = t.attoseconds() / ATTOSECONDS_PER_NANOSECOND; - sprintf(buf, "%s%04d.%03d,%03d,%03d", sign, int(t.seconds()), nsec / 1000000, (nsec / 1000) % 1000, nsec % 1000); - return buf; + auto result = util::string_format("%s%04d.%03d,%03d,%03d", sign, int(t.seconds()), nsec / 1000000, (nsec / 1000) % 1000, nsec % 1000); + return result; } TIMER_CALLBACK_MEMBER(video992_device::hold_cpu) diff --git a/src/frontend/mame/ui/viewgfx.cpp b/src/frontend/mame/ui/viewgfx.cpp index 2fcc0949484..56dfd008893 100644 --- a/src/frontend/mame/ui/viewgfx.cpp +++ b/src/frontend/mame/ui/viewgfx.cpp @@ -1003,8 +1003,7 @@ uint32_t gfx_viewer::handle_palette(mame_ui_manager &mui, render_container &cont container.add_point(0.5f * (x0 + cellboxbounds.x0), y0 + 0.5f * cellheight, UI_LINE_WIDTH, rgb_t::white(), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); // draw the row header - char buffer[10]; - sprintf(buffer, "%5X", index); + auto buffer = util::string_format("%5X", index); for (int x = 4; x >= 0; x--) { x0 -= ui_font->char_width(chheight, aspect, buffer[x]); @@ -1209,8 +1208,7 @@ uint32_t gfx_viewer::handle_gfxset(mame_ui_manager &mui, render_container &conta container.add_point(0.5f * (x0 + boxbounds.x0 + 6.0f * chwidth), y0 + 0.5f * cellheight, UI_LINE_WIDTH, rgb_t::white(), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); // draw the row header - char buffer[10]; - sprintf(buffer, "%5X", set.m_offset + (y * xcells)); + auto buffer = util::string_format("%5X", set.m_offset + (y * xcells)); for (int x = 4; x >= 0; x--) { x0 -= ui_font->char_width(chheight, aspect, buffer[x]); diff --git a/src/mame/amiga/arsystems.cpp b/src/mame/amiga/arsystems.cpp index f8938cc9dca..60216e0972d 100644 --- a/src/mame/amiga/arsystems.cpp +++ b/src/mame/amiga/arsystems.cpp @@ -941,10 +941,8 @@ void arcadia_amiga_state::generic_decode(const char *tag, int bit7, int bit6, in uint8_t *ROM = memregion(tag)->base(); // int size = memregion(tag)->bytes(); - FILE *fp; - char filename[256]; - sprintf(filename,"decrypted_%s", machine().system().name); - fp=fopen(filename, "w+b"); + auto filename = std::string{ "decrypted_" } + machine().system().name; + auto fp = fopen(filename.c_str(), "w+b"); if (fp) { for (i = 0; i < 0x20000; i++) diff --git a/src/mame/atari/harddriv.h b/src/mame/atari/harddriv.h index b940349d956..74b6b31f535 100644 --- a/src/mame/atari/harddriv.h +++ b/src/mame/atari/harddriv.h @@ -258,6 +258,7 @@ protected: uint16_t hdadsp_speedup_r(); uint16_t hdds3_speedup_r(); + void display_speedups(); DECLARE_WRITE_LINE_MEMBER(hdds3sdsp_timer_enable_callback); void hdds3sdsp_serial_tx_callback(uint32_t data); diff --git a/src/mame/atari/harddriv_v.cpp b/src/mame/atari/harddriv_v.cpp index 83c7fa519f9..1acd195466d 100644 --- a/src/mame/atari/harddriv_v.cpp +++ b/src/mame/atari/harddriv_v.cpp @@ -387,21 +387,21 @@ void harddriv_state::hdgsp_paletteram_hi_w(offs_t offset, uint16_t data, uint16_ * *************************************/ -static void display_speedups(void) +void harddriv_state::display_speedups() { #if DISPLAY_SPEEDUPS char temp[200]; - sprintf(temp, "GSP:%d/%d/%d/%d", - gsp_speedup_count[0], gsp_speedup_count[1], - gsp_speedup_count[2], gsp_speedup_count[3]); + snprintf(temp, std::size(temp), "GSP:%d/%d/%d/%d", + m_gsp_speedup_count[0], m_gsp_speedup_count[1], + m_gsp_speedup_count[2], m_gsp_speedup_count[3]); ui_draw_text(temp, 0, 0); - sprintf(temp, "MSP:%d/%d/%d/%d", - msp_speedup_count[0], msp_speedup_count[1], - msp_speedup_count[2], msp_speedup_count[3]); + snprintf(temp, std::size(temp), "MSP:%d/%d/%d/%d", + m_msp_speedup_count[0], m_msp_speedup_count[1], + m_msp_speedup_count[2], m_msp_speedup_count[3]); ui_draw_text(temp, 0, 10); - sprintf(temp, "ADSP:%d/%d/%d/%d", - adsp_speedup_count[0], adsp_speedup_count[1], - adsp_speedup_count[2], adsp_speedup_count[3]); + snprintf(temp, std::size(temp), "ADSP:%d/%d/%d/%d", + m_adsp_speedup_count[0], m_adsp_speedup_count[1], + m_adsp_speedup_count[2], m_adsp_speedup_count[3]); ui_draw_text(temp, 0, 20); #endif } diff --git a/src/mame/bfm/bfm_sc45_helper.cpp b/src/mame/bfm/bfm_sc45_helper.cpp index ba21922638a..0ad512f61dd 100644 --- a/src/mame/bfm/bfm_sc45_helper.cpp +++ b/src/mame/bfm/bfm_sc45_helper.cpp @@ -429,11 +429,7 @@ int find_lamp_strings(running_machine &machine) { for (int x = 0; x < 16; x++) { - char tmp[32]; - - sprintf(tmp, "(%02d:%02d)", y, x); - - lamps[y][x].lampname = std::string(tmp); + lamps[y][x].lampname = util::string_format("(%02d:%02d)", y, x); lamps[y][x].used = false; lamps[y][x].y = (y * 28); lamps[y][x].x = 380 + (x * 24); @@ -443,7 +439,6 @@ int find_lamp_strings(running_machine &machine) lamps[y][x].lamptypename = "unusedlamp"; lamps[y][x].clickport = -1; lamps[y][x].clickmask = 0; - } } @@ -598,8 +593,7 @@ int find_lamp_strings(running_machine &machine) for (int reel = 0; reel < 8; reel++) { char tempname[32]; - sprintf(tempname, "reel%d ", reel+1); - + snprintf(tempname, std::size(tempname), "reel%d ", reel+1); for (int pos = 0; pos < 3; pos++) { @@ -609,7 +603,6 @@ int find_lamp_strings(running_machine &machine) if (pos == 1) snprintf(tempname2, std::size(tempname2), "%smid", tempname); if (pos == 2) snprintf(tempname2, std::size(tempname2), "%sbot", tempname); - for (auto & lamp : lamps) { for (int x = 0; x < 16; x++) @@ -624,14 +617,11 @@ int find_lamp_strings(running_machine &machine) lamp[x].width = 50; lamp[x].height = 17; lamp[x].lamptypename = "reellamp"; - - } else { //printf("%s:%s:\n", tempname2, lamps[y][x].lampname_alt.c_str()); } - } } } @@ -656,8 +646,6 @@ int find_lamp_strings(running_machine &machine) set_clickable_temp(machine, "cash bust", 8, 0x04); // no 'refill' lamp? - - } diff --git a/src/mame/capcom/cps2crypt.cpp b/src/mame/capcom/cps2crypt.cpp index fc85ca349ac..45f37c0f011 100644 --- a/src/mame/capcom/cps2crypt.cpp +++ b/src/mame/capcom/cps2crypt.cpp @@ -664,18 +664,15 @@ void cps2_decrypt(running_machine &machine, uint16_t *rom, uint16_t *dec, int le { if ((i & 0xff) == 0) { - char loadingMessage[256]; // for displaying with UI - sprintf(loadingMessage, "Decrypting %d%%", i*100/0x10000); - machine.ui().set_startup_text(loadingMessage, false); + auto loadingMessage = util::string_format("Decrypting %d%%", i*100/0x10000); + machine.ui().set_startup_text(loadingMessage.c_str(), false); } - // pass the address through FN1 uint16_t const seed = feistel(i, fn1_groupA, fn1_groupB, &sboxes1[0*4], &sboxes1[1*4], &sboxes1[2*4], &sboxes1[3*4], key1[0], key1[1], key1[2], key1[3]); - // expand the result to 64-bit uint32_t subkey[2]; expand_subkey(subkey, seed); @@ -698,7 +695,6 @@ void cps2_decrypt(running_machine &machine, uint16_t *rom, uint16_t *dec, int le key2[2] ^= BIT(key2[2], 7) << 11; key2[3] ^= BIT(key2[3], 1) << 5; - // decrypt the opcodes for (int a = i; a < length/2; a += 0x10000) { diff --git a/src/mame/capcom/cps3.cpp b/src/mame/capcom/cps3.cpp index a8dafd55cba..4a5ded7ddfc 100644 --- a/src/mame/capcom/cps3.cpp +++ b/src/mame/capcom/cps3.cpp @@ -861,12 +861,8 @@ void cps3_state::decrypt_bios() #if 0 /* Dump to file */ { - FILE *fp; - const char *gamename = machine().system().name; - char filename[256]; - sprintf(filename, "%s_bios.dump", gamename); - - fp=fopen(filename, "w+b"); + 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); @@ -2400,24 +2396,6 @@ void cps3_state::copy_from_nvram() flashnum+=2; } } - - - /* - { - FILE *fp; - const char *gamename = machine().system().name; - char filename[256]; - sprintf(filename, "%s_bios.dump", gamename); - - fp=fopen(filename, "w+b"); - if (fp) - { - fwrite(rom, 0x080000, 1, fp); - fclose(fp); - } - } - */ - } diff --git a/src/mame/capcom/mitchell.cpp b/src/mame/capcom/mitchell.cpp index f3a1038d490..823bbfb82f9 100644 --- a/src/mame/capcom/mitchell.cpp +++ b/src/mame/capcom/mitchell.cpp @@ -428,14 +428,11 @@ void mitchell_state::colorram_w(offs_t offset, uint8_t data) void mitchell_state::gfxctrl_w(uint8_t data) { -logerror("PC %04x: gfxctrl_w %02x\n", m_maincpu->pc(), data); -{ + logerror("PC %04x: gfxctrl_w %02x\n", m_maincpu->pc(), data); + #if 0 - char baf[40]; - sprintf(baf, "%02x", data); - popmessage(baf); + popmessage("%02x", data); #endif -} // bit 0 is unknown (used, maybe back color enable?) @@ -467,11 +464,8 @@ logerror("PC %04x: gfxctrl_w %02x\n", m_maincpu->pc(), data); void mstworld_state::gfxctrl_w(uint8_t data) { logerror("PC %04x: gfxctrl_w %02x\n", m_maincpu->pc(), data); -{ - char baf[40]; - sprintf(baf, "%02x", data); -// popmessage(baf); -} + + // popmessage("%02x", data); // bit 0 is unknown (used, maybe back color enable?) diff --git a/src/mame/dataeast/deco32.cpp b/src/mame/dataeast/deco32.cpp index 619ba2c7a18..71017ed6008 100644 --- a/src/mame/dataeast/deco32.cpp +++ b/src/mame/dataeast/deco32.cpp @@ -1271,10 +1271,7 @@ void dragngun_state::dragngun_init_common() { u8 *ROM = memregion("dvi")->base(); - FILE *fp; - char filename[256]; - sprintf(filename,"video.dvi"); - fp=fopen(filename, "w+b"); + auto fp = fopen("video.dvi", "w+b"); if (fp) { fwrite(ROM, 0xc00000, 1, fp); diff --git a/src/mame/excellent/excellent_spr.cpp b/src/mame/excellent/excellent_spr.cpp index 5c4cc9f9200..1577adc2c31 100644 --- a/src/mame/excellent/excellent_spr.cpp +++ b/src/mame/excellent/excellent_spr.cpp @@ -187,15 +187,6 @@ void excellent_spr_device::aquarium_draw_sprites(screen_device &screen, bitmap_i } } } - -#if 0 - if (rotate) - { - char buf[80]; - sprintf(buf, "sprite rotate offs %04x ?", rotate); - popmessage(buf); - } -#endif } void excellent_spr_device::gcpinbal_draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int y_offs) @@ -269,12 +260,4 @@ void excellent_spr_device::gcpinbal_draw_sprites(screen_device &screen, bitmap_i } } } -#if 0 - if (rotate) - { - char buf[80]; - sprintf(buf, "sprite rotate offs %04x ?", rotate); - popmessage(buf); - } -#endif } diff --git a/src/mame/igt/videopkr.cpp b/src/mame/igt/videopkr.cpp index 9e1fc83714b..c10a8eb9173 100644 --- a/src/mame/igt/videopkr.cpp +++ b/src/mame/igt/videopkr.cpp @@ -458,12 +458,11 @@ static uint8_t dec_7seg(int data) /* Display a seven digit counter on layout - Index points to less significant digit*/ void videopkr_state::count_7dig(unsigned long data, uint8_t index) { - uint8_t i; - char strn[8]; - sprintf(strn,"%7lu",data); - - for (i = 0; i < 7; i++) - m_digits[index+i] = dec_7seg((strn[6 - i] | 0x10) - 0x30); + for (auto i = 0; i < 7; i++) + { + m_digits[index+i] = dec_7seg(data % 10); + data /= 10; + } } void videopkr_state::videopkr_palette(palette_device &palette) const diff --git a/src/mame/kaneko/kaneko_calc3.cpp b/src/mame/kaneko/kaneko_calc3.cpp index 306e81b190b..c9da9b772be 100644 --- a/src/mame/kaneko/kaneko_calc3.cpp +++ b/src/mame/kaneko/kaneko_calc3.cpp @@ -1519,58 +1519,50 @@ int kaneko_calc3_device::decompress_table(int tabnum, uint8_t* dstram, int dstof void kaneko_calc3_device::initial_scan_tables() { - uint8_t numregions; uint8_t* datarom = memregion(":calc3_rom")->base(); - int x; - m_mcu_crc = 0; - for (x=0;x<0x20000;x++) + for (int x=0;x<0x20000;x++) { m_mcu_crc+=datarom[x]; } //printf("crc %04x\n",m_mcu_crc); - numregions = datarom[0]; - for (x=0;x tmpdstram(0x2000); #if VERBOSE_OUTPUT - int length; -#endif + uint8_t numregions = datarom[0]; - memset(&tmpdstram[0], 0x00,0x2000); + for (int x=0; x tmpdstram(0x2000, 0x00); -#if VERBOSE_OUTPUT - length = decompress_table(x, tmpdstram, 0); + int length = decompress_table(x, tmpdstram.data(), 0); // dump to file if (length) { - FILE *fp; - char filename[256]; + std::string filename; if (m_blocksize_offset==3) { - sprintf(filename,"data_%s_table_%04x k%02x m%02x u%02x length %04x", - machine().system().name, - x, m_decryption_key_byte, m_mode, m_alternateswaps, length); + filename = util::string_format("data_%s_table_%04x k%02x m%02x u%02x length %04x", + machine().system().name, + x, m_decryption_key_byte, m_mode, m_alternateswaps, length); } else { - sprintf(filename,"data_%s_table_%04x k%02x (use indirect size %02x) m%02x u%02x length %04x", + filename = util::string_format("data_%s_table_%04x k%02x (use indirect size %02x) m%02x u%02x length %04x", machine().system().name, x, m_decryption_key_byte, m_blocksize_offset-3, m_mode, m_alternateswaps, length); } - fp=fopen(filename, "w+b"); + auto fp = fopen(filename.c_str(), "w+b"); if (fp) { - fwrite(tmpdstram, length, 1, fp); + fwrite(tmpdstram.data(), length, 1, fp); fclose(fp); } } -#endif } +#endif // there is also a 0x1000 block of data at the end.. same on both games, maybe it's related to the decryption tables?? // the calc3_dataend points to the data after the last block processed, as we process all the blocks in the above loop, we assume this points @@ -1579,13 +1571,8 @@ void kaneko_calc3_device::initial_scan_tables() // dump out the 0x1000 sized block at the end #if VERBOSE_OUTPUT { - FILE *fp; - char filename[256]; - - sprintf(filename,"data_%s_finalblock", - machine().system().name); - - fp=fopen(filename, "w+b"); + auto filename = util::string_format("data_%s_finalblock", machine().system().name); + auto fp = fopen(filename.c_str(), "w+b"); if (fp) { fwrite(&datarom[m_dataend], 0x1000, 1, fp); diff --git a/src/mame/nintendo/n64_v.cpp b/src/mame/nintendo/n64_v.cpp index 504b6e0b76a..020503195cf 100644 --- a/src/mame/nintendo/n64_v.cpp +++ b/src/mame/nintendo/n64_v.cpp @@ -33,6 +33,7 @@ TODO: #include "screen.h" #include +#include #define LOG_RDP_EXECUTION 0 #define DEBUG_RDP_PIXEL 0 @@ -1327,8 +1328,9 @@ int32_t const n64_rdp::s_rdp_command_length[64] = 8 // 0x3f, Set_Color_Image }; -void n64_rdp::disassemble(uint64_t *cmd_buf, char* buffer) +std::string n64_rdp::disassemble(uint64_t *cmd_buf) { + std::ostringstream buffer; char sl[32], tl[32], sh[32], th[32]; char s[32], t[32], w[32]; char dsdx[32], dtdx[32], dwdx[32]; @@ -1342,10 +1344,10 @@ void n64_rdp::disassemble(uint64_t *cmd_buf, char* buffer) char drde[32], dgde[32], dbde[32], dade[32]; const int32_t tile = (cmd_buf[0] >> 56) & 0x7; - sprintf(sl, "%4.2f", (float)((cmd_buf[0] >> 44) & 0xfff) / 4.0f); - sprintf(tl, "%4.2f", (float)((cmd_buf[0] >> 32) & 0xfff) / 4.0f); - sprintf(sh, "%4.2f", (float)((cmd_buf[0] >> 12) & 0xfff) / 4.0f); - sprintf(th, "%4.2f", (float)((cmd_buf[0] >> 0) & 0xfff) / 4.0f); + snprintf(sl, std::size(sl), "%4.2f", (float)((cmd_buf[0] >> 44) & 0xfff) / 4.0f); + snprintf(tl, std::size(tl), "%4.2f", (float)((cmd_buf[0] >> 32) & 0xfff) / 4.0f); + snprintf(sh, std::size(sh), "%4.2f", (float)((cmd_buf[0] >> 12) & 0xfff) / 4.0f); + snprintf(th, std::size(th), "%4.2f", (float)((cmd_buf[0] >> 0) & 0xfff) / 4.0f); const char* format = s_image_format[(cmd_buf[0] >> 53) & 0x7]; const char* size = s_image_size[(cmd_buf[0] >> 51) & 0x3]; @@ -1358,368 +1360,370 @@ void n64_rdp::disassemble(uint64_t *cmd_buf, char* buffer) const uint32_t command = (cmd_buf[0] >> 56) & 0x3f; switch (command) { - case 0x00: sprintf(buffer, "No Op"); break; + case 0x00: buffer << "No Op"; break; case 0x08: // Tri_NoShade { const int32_t lft = (cmd_buf[0] >> 55) & 0x1; - sprintf(yl, "%4.4f", (float)((cmd_buf[0] >> 32) & 0x1fff) / 4.0f); - sprintf(ym, "%4.4f", (float)((cmd_buf[0] >> 16) & 0x1fff) / 4.0f); - sprintf(yh, "%4.4f", (float)((cmd_buf[0] >> 0) & 0x1fff) / 4.0f); - sprintf(xl, "%4.4f", (float)int32_t(cmd_buf[1] >> 32) / 65536.0f); - sprintf(dxldy, "%4.4f", (float)int32_t(cmd_buf[1]) / 65536.0f); - sprintf(xh, "%4.4f", (float)int32_t(cmd_buf[2] >> 32) / 65536.0f); - sprintf(dxhdy, "%4.4f", (float)int32_t(cmd_buf[2]) / 65536.0f); - sprintf(xm, "%4.4f", (float)int32_t(cmd_buf[3] >> 32) / 65536.0f); - sprintf(dxmdy, "%4.4f", (float)int32_t(cmd_buf[3]) / 65536.0f); - - sprintf(buffer, "Tri_NoShade %d, XL: %s, XM: %s, XH: %s, YL: %s, YM: %s, YH: %s\n", lft, xl,xm,xh,yl,ym,yh); + snprintf(yl, std::size(yl), "%4.4f", (float)((cmd_buf[0] >> 32) & 0x1fff) / 4.0f); + snprintf(ym, std::size(ym), "%4.4f", (float)((cmd_buf[0] >> 16) & 0x1fff) / 4.0f); + snprintf(yh, std::size(yh), "%4.4f", (float)((cmd_buf[0] >> 0) & 0x1fff) / 4.0f); + snprintf(xl, std::size(xl), "%4.4f", (float)int32_t(cmd_buf[1] >> 32) / 65536.0f); + snprintf(dxldy, std::size(dxldy), "%4.4f", (float)int32_t(cmd_buf[1]) / 65536.0f); + snprintf(xh, std::size(xh), "%4.4f", (float)int32_t(cmd_buf[2] >> 32) / 65536.0f); + snprintf(dxhdy, std::size(dxhdy), "%4.4f", (float)int32_t(cmd_buf[2]) / 65536.0f); + snprintf(xm, std::size(xm), "%4.4f", (float)int32_t(cmd_buf[3] >> 32) / 65536.0f); + snprintf(dxmdy, std::size(dxmdy), "%4.4f", (float)int32_t(cmd_buf[3]) / 65536.0f); + + util::stream_format(buffer, "Tri_NoShade %d, XL: %s, XM: %s, XH: %s, YL: %s, YM: %s, YH: %s\n", lft, xl,xm,xh,yl,ym,yh); break; } case 0x09: // Tri_NoShadeZ { const int32_t lft = (cmd_buf[0] >> 55) & 0x1; - sprintf(yl, "%4.4f", (float)((cmd_buf[0] >> 32) & 0x1fff) / 4.0f); - sprintf(ym, "%4.4f", (float)((cmd_buf[0] >> 16) & 0x1fff) / 4.0f); - sprintf(yh, "%4.4f", (float)((cmd_buf[0] >> 0) & 0x1fff) / 4.0f); - sprintf(xl, "%4.4f", (float)int32_t(cmd_buf[1] >> 32) / 65536.0f); - sprintf(dxldy, "%4.4f", (float)int32_t(cmd_buf[1]) / 65536.0f); - sprintf(xh, "%4.4f", (float)int32_t(cmd_buf[2] >> 32) / 65536.0f); - sprintf(dxhdy, "%4.4f", (float)int32_t(cmd_buf[2]) / 65536.0f); - sprintf(xm, "%4.4f", (float)int32_t(cmd_buf[3] >> 32) / 65536.0f); - sprintf(dxmdy, "%4.4f", (float)int32_t(cmd_buf[3]) / 65536.0f); - - sprintf(buffer, "Tri_NoShadeZ %d, XL: %s, XM: %s, XH: %s, YL: %s, YM: %s, YH: %s\n", lft, xl,xm,xh,yl,ym,yh); + snprintf(yl, std::size(yl), "%4.4f", (float)((cmd_buf[0] >> 32) & 0x1fff) / 4.0f); + snprintf(ym, std::size(ym), "%4.4f", (float)((cmd_buf[0] >> 16) & 0x1fff) / 4.0f); + snprintf(yh, std::size(yh), "%4.4f", (float)((cmd_buf[0] >> 0) & 0x1fff) / 4.0f); + snprintf(xl, std::size(xl), "%4.4f", (float)int32_t(cmd_buf[1] >> 32) / 65536.0f); + snprintf(dxldy, std::size(dxldy), "%4.4f", (float)int32_t(cmd_buf[1]) / 65536.0f); + snprintf(xh, std::size(xh), "%4.4f", (float)int32_t(cmd_buf[2] >> 32) / 65536.0f); + snprintf(dxhdy, std::size(dxhdy), "%4.4f", (float)int32_t(cmd_buf[2]) / 65536.0f); + snprintf(xm, std::size(xm), "%4.4f", (float)int32_t(cmd_buf[3] >> 32) / 65536.0f); + snprintf(dxmdy, std::size(dxmdy), "%4.4f", (float)int32_t(cmd_buf[3]) / 65536.0f); + + util::stream_format(buffer, "Tri_NoShadeZ %d, XL: %s, XM: %s, XH: %s, YL: %s, YM: %s, YH: %s\n", lft, xl,xm,xh,yl,ym,yh); break; } case 0x0a: // Tri_Tex { const int32_t lft = (cmd_buf[0] >> 55) & 0x1; - sprintf(yl, "%4.4f", (float)((cmd_buf[0] >> 32) & 0x1fff) / 4.0f); - sprintf(ym, "%4.4f", (float)((cmd_buf[0] >> 16) & 0x1fff) / 4.0f); - sprintf(yh, "%4.4f", (float)((cmd_buf[0] >> 0) & 0x1fff) / 4.0f); - sprintf(xl, "%4.4f", (float)int32_t(cmd_buf[1] >> 32) / 65536.0f); - sprintf(dxldy, "%4.4f", (float)int32_t(cmd_buf[1]) / 65536.0f); - sprintf(xh, "%4.4f", (float)int32_t(cmd_buf[2] >> 32) / 65536.0f); - sprintf(dxhdy, "%4.4f", (float)int32_t(cmd_buf[2]) / 65536.0f); - sprintf(xm, "%4.4f", (float)int32_t(cmd_buf[3] >> 32) / 65536.0f); - sprintf(dxmdy, "%4.4f", (float)int32_t(cmd_buf[3]) / 65536.0f); - - sprintf(s, "%4.4f", (float)int32_t( ((cmd_buf[4] >> 32) & 0xffff0000) | ((cmd_buf[ 6] >> 48) & 0xffff)) / 65536.0f); - sprintf(t, "%4.4f", (float)int32_t((((cmd_buf[4] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[ 6] >> 32) & 0xffff)) / 65536.0f); - sprintf(w, "%4.4f", (float)int32_t( (cmd_buf[4] & 0xffff0000) | ((cmd_buf[ 6] >> 16) & 0xffff)) / 65536.0f); - sprintf(dsdx, "%4.4f", (float)int32_t( ((cmd_buf[5] >> 32) & 0xffff0000) | ((cmd_buf[ 7] >> 48) & 0xffff)) / 65536.0f); - sprintf(dtdx, "%4.4f", (float)int32_t((((cmd_buf[5] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[ 7] >> 32) & 0xffff)) / 65536.0f); - sprintf(dwdx, "%4.4f", (float)int32_t( (cmd_buf[5] & 0xffff0000) | ((cmd_buf[ 7] >> 16) & 0xffff)) / 65536.0f); - sprintf(dsde, "%4.4f", (float)int32_t( ((cmd_buf[8] >> 32) & 0xffff0000) | ((cmd_buf[10] >> 48) & 0xffff)) / 65536.0f); - sprintf(dtde, "%4.4f", (float)int32_t((((cmd_buf[8] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[10] >> 32) & 0xffff)) / 65536.0f); - sprintf(dwde, "%4.4f", (float)int32_t( (cmd_buf[8] & 0xffff0000) | ((cmd_buf[10] >> 16) & 0xffff)) / 65536.0f); - sprintf(dsdy, "%4.4f", (float)int32_t( ((cmd_buf[9] >> 32) & 0xffff0000) | ((cmd_buf[11] >> 48) & 0xffff)) / 65536.0f); - sprintf(dtdy, "%4.4f", (float)int32_t((((cmd_buf[9] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[11] >> 32) & 0xffff)) / 65536.0f); - sprintf(dwdy, "%4.4f", (float)int32_t( (cmd_buf[9] & 0xffff0000) | ((cmd_buf[11] >> 16) & 0xffff)) / 65536.0f); - - buffer+=sprintf(buffer, "Tri_Tex %d, XL: %s, XM: %s, XH: %s, YL: %s, YM: %s, YH: %s\n", lft, xl,xm,xh,yl,ym,yh); - buffer+=sprintf(buffer, " "); - buffer+=sprintf(buffer, " S: %s, T: %s, W: %s\n", s, t, w); - buffer+=sprintf(buffer, " "); - buffer+=sprintf(buffer, " DSDX: %s, DTDX: %s, DWDX: %s\n", dsdx, dtdx, dwdx); - buffer+=sprintf(buffer, " "); - buffer+=sprintf(buffer, " DSDE: %s, DTDE: %s, DWDE: %s\n", dsde, dtde, dwde); - buffer+=sprintf(buffer, " "); - buffer+=sprintf(buffer, " DSDY: %s, DTDY: %s, DWDY: %s\n", dsdy, dtdy, dwdy); + snprintf(yl, std::size(yl), "%4.4f", (float)((cmd_buf[0] >> 32) & 0x1fff) / 4.0f); + snprintf(ym, std::size(ym), "%4.4f", (float)((cmd_buf[0] >> 16) & 0x1fff) / 4.0f); + snprintf(yh, std::size(yh), "%4.4f", (float)((cmd_buf[0] >> 0) & 0x1fff) / 4.0f); + snprintf(xl, std::size(xl), "%4.4f", (float)int32_t(cmd_buf[1] >> 32) / 65536.0f); + snprintf(dxldy, std::size(dxldy), "%4.4f", (float)int32_t(cmd_buf[1]) / 65536.0f); + snprintf(xh, std::size(xh), "%4.4f", (float)int32_t(cmd_buf[2] >> 32) / 65536.0f); + snprintf(dxhdy, std::size(dxhdy), "%4.4f", (float)int32_t(cmd_buf[2]) / 65536.0f); + snprintf(xm, std::size(xm), "%4.4f", (float)int32_t(cmd_buf[3] >> 32) / 65536.0f); + snprintf(dxmdy, std::size(dxmdy), "%4.4f", (float)int32_t(cmd_buf[3]) / 65536.0f); + + snprintf(s, std::size(s), "%4.4f", (float)int32_t( ((cmd_buf[4] >> 32) & 0xffff0000) | ((cmd_buf[ 6] >> 48) & 0xffff)) / 65536.0f); + snprintf(t, std::size(t), "%4.4f", (float)int32_t((((cmd_buf[4] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[ 6] >> 32) & 0xffff)) / 65536.0f); + snprintf(w, std::size(w), "%4.4f", (float)int32_t( (cmd_buf[4] & 0xffff0000) | ((cmd_buf[ 6] >> 16) & 0xffff)) / 65536.0f); + snprintf(dsdx, std::size(dsdx), "%4.4f", (float)int32_t( ((cmd_buf[5] >> 32) & 0xffff0000) | ((cmd_buf[ 7] >> 48) & 0xffff)) / 65536.0f); + snprintf(dtdx, std::size(dtdx), "%4.4f", (float)int32_t((((cmd_buf[5] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[ 7] >> 32) & 0xffff)) / 65536.0f); + snprintf(dwdx, std::size(dwdx), "%4.4f", (float)int32_t( (cmd_buf[5] & 0xffff0000) | ((cmd_buf[ 7] >> 16) & 0xffff)) / 65536.0f); + snprintf(dsde, std::size(dsde), "%4.4f", (float)int32_t( ((cmd_buf[8] >> 32) & 0xffff0000) | ((cmd_buf[10] >> 48) & 0xffff)) / 65536.0f); + snprintf(dtde, std::size(dtde), "%4.4f", (float)int32_t((((cmd_buf[8] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[10] >> 32) & 0xffff)) / 65536.0f); + snprintf(dwde, std::size(dwde), "%4.4f", (float)int32_t( (cmd_buf[8] & 0xffff0000) | ((cmd_buf[10] >> 16) & 0xffff)) / 65536.0f); + snprintf(dsdy, std::size(dsdy), "%4.4f", (float)int32_t( ((cmd_buf[9] >> 32) & 0xffff0000) | ((cmd_buf[11] >> 48) & 0xffff)) / 65536.0f); + snprintf(dtdy, std::size(dtdy), "%4.4f", (float)int32_t((((cmd_buf[9] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[11] >> 32) & 0xffff)) / 65536.0f); + snprintf(dwdy, std::size(dwdy), "%4.4f", (float)int32_t( (cmd_buf[9] & 0xffff0000) | ((cmd_buf[11] >> 16) & 0xffff)) / 65536.0f); + + util::stream_format(buffer, "Tri_Tex %d, XL: %s, XM: %s, XH: %s, YL: %s, YM: %s, YH: %s\n", lft, xl,xm,xh,yl,ym,yh); + buffer << " "; + util::stream_format(buffer, " S: %s, T: %s, W: %s\n", s, t, w); + buffer << " "; + util::stream_format(buffer, " DSDX: %s, DTDX: %s, DWDX: %s\n", dsdx, dtdx, dwdx); + buffer << " "; + util::stream_format(buffer, " DSDE: %s, DTDE: %s, DWDE: %s\n", dsde, dtde, dwde); + buffer << " "; + util::stream_format(buffer, " DSDY: %s, DTDY: %s, DWDY: %s\n", dsdy, dtdy, dwdy); break; } case 0x0b: // Tri_TexZ { const int32_t lft = (cmd_buf[0] >> 55) & 0x1; - sprintf(yl, "%4.4f", (float)((cmd_buf[0] >> 32) & 0x1fff) / 4.0f); - sprintf(ym, "%4.4f", (float)((cmd_buf[0] >> 16) & 0x1fff) / 4.0f); - sprintf(yh, "%4.4f", (float)((cmd_buf[0] >> 0) & 0x1fff) / 4.0f); - sprintf(xl, "%4.4f", (float)int32_t(cmd_buf[1] >> 32) / 65536.0f); - sprintf(dxldy, "%4.4f", (float)int32_t(cmd_buf[1]) / 65536.0f); - sprintf(xh, "%4.4f", (float)int32_t(cmd_buf[2] >> 32) / 65536.0f); - sprintf(dxhdy, "%4.4f", (float)int32_t(cmd_buf[2]) / 65536.0f); - sprintf(xm, "%4.4f", (float)int32_t(cmd_buf[3] >> 32) / 65536.0f); - sprintf(dxmdy, "%4.4f", (float)int32_t(cmd_buf[3]) / 65536.0f); - - sprintf(s, "%4.4f", (float)int32_t( ((cmd_buf[4] >> 32) & 0xffff0000) | ((cmd_buf[ 6] >> 48) & 0xffff)) / 65536.0f); - sprintf(t, "%4.4f", (float)int32_t((((cmd_buf[4] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[ 6] >> 32) & 0xffff)) / 65536.0f); - sprintf(w, "%4.4f", (float)int32_t( (cmd_buf[4] & 0xffff0000) | ((cmd_buf[ 6] >> 16) & 0xffff)) / 65536.0f); - sprintf(dsdx, "%4.4f", (float)int32_t( ((cmd_buf[5] >> 32) & 0xffff0000) | ((cmd_buf[ 7] >> 48) & 0xffff)) / 65536.0f); - sprintf(dtdx, "%4.4f", (float)int32_t((((cmd_buf[5] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[ 7] >> 32) & 0xffff)) / 65536.0f); - sprintf(dwdx, "%4.4f", (float)int32_t( (cmd_buf[5] & 0xffff0000) | ((cmd_buf[ 7] >> 16) & 0xffff)) / 65536.0f); - sprintf(dsde, "%4.4f", (float)int32_t( ((cmd_buf[8] >> 32) & 0xffff0000) | ((cmd_buf[10] >> 48) & 0xffff)) / 65536.0f); - sprintf(dtde, "%4.4f", (float)int32_t((((cmd_buf[8] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[10] >> 32) & 0xffff)) / 65536.0f); - sprintf(dwde, "%4.4f", (float)int32_t( (cmd_buf[8] & 0xffff0000) | ((cmd_buf[10] >> 16) & 0xffff)) / 65536.0f); - sprintf(dsdy, "%4.4f", (float)int32_t( ((cmd_buf[9] >> 32) & 0xffff0000) | ((cmd_buf[11] >> 48) & 0xffff)) / 65536.0f); - sprintf(dtdy, "%4.4f", (float)int32_t((((cmd_buf[9] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[11] >> 32) & 0xffff)) / 65536.0f); - sprintf(dwdy, "%4.4f", (float)int32_t( (cmd_buf[9] & 0xffff0000) | ((cmd_buf[11] >> 16) & 0xffff)) / 65536.0f); - - buffer+=sprintf(buffer, "Tri_TexZ %d, XL: %s, XM: %s, XH: %s, YL: %s, YM: %s, YH: %s\n", lft, xl,xm,xh,yl,ym,yh); - buffer+=sprintf(buffer, " "); - buffer+=sprintf(buffer, " S: %s, T: %s, W: %s\n", s, t, w); - buffer+=sprintf(buffer, " "); - buffer+=sprintf(buffer, " DSDX: %s, DTDX: %s, DWDX: %s\n", dsdx, dtdx, dwdx); - buffer+=sprintf(buffer, " "); - buffer+=sprintf(buffer, " DSDE: %s, DTDE: %s, DWDE: %s\n", dsde, dtde, dwde); - buffer+=sprintf(buffer, " "); - buffer+=sprintf(buffer, " DSDY: %s, DTDY: %s, DWDY: %s\n", dsdy, dtdy, dwdy); + snprintf(yl, std::size(yl), "%4.4f", (float)((cmd_buf[0] >> 32) & 0x1fff) / 4.0f); + snprintf(ym, std::size(ym), "%4.4f", (float)((cmd_buf[0] >> 16) & 0x1fff) / 4.0f); + snprintf(yh, std::size(yh), "%4.4f", (float)((cmd_buf[0] >> 0) & 0x1fff) / 4.0f); + snprintf(xl, std::size(xl), "%4.4f", (float)int32_t(cmd_buf[1] >> 32) / 65536.0f); + snprintf(dxldy, std::size(dxldy), "%4.4f", (float)int32_t(cmd_buf[1]) / 65536.0f); + snprintf(xh, std::size(xh), "%4.4f", (float)int32_t(cmd_buf[2] >> 32) / 65536.0f); + snprintf(dxhdy, std::size(dxhdy), "%4.4f", (float)int32_t(cmd_buf[2]) / 65536.0f); + snprintf(xm, std::size(xm), "%4.4f", (float)int32_t(cmd_buf[3] >> 32) / 65536.0f); + snprintf(dxmdy, std::size(dxmdy), "%4.4f", (float)int32_t(cmd_buf[3]) / 65536.0f); + + snprintf(s, std::size(s), "%4.4f", (float)int32_t( ((cmd_buf[4] >> 32) & 0xffff0000) | ((cmd_buf[ 6] >> 48) & 0xffff)) / 65536.0f); + snprintf(t, std::size(t), "%4.4f", (float)int32_t((((cmd_buf[4] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[ 6] >> 32) & 0xffff)) / 65536.0f); + snprintf(w, std::size(w), "%4.4f", (float)int32_t( (cmd_buf[4] & 0xffff0000) | ((cmd_buf[ 6] >> 16) & 0xffff)) / 65536.0f); + snprintf(dsdx, std::size(dsdx), "%4.4f", (float)int32_t( ((cmd_buf[5] >> 32) & 0xffff0000) | ((cmd_buf[ 7] >> 48) & 0xffff)) / 65536.0f); + snprintf(dtdx, std::size(dtdx), "%4.4f", (float)int32_t((((cmd_buf[5] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[ 7] >> 32) & 0xffff)) / 65536.0f); + snprintf(dwdx, std::size(dwdx), "%4.4f", (float)int32_t( (cmd_buf[5] & 0xffff0000) | ((cmd_buf[ 7] >> 16) & 0xffff)) / 65536.0f); + snprintf(dsde, std::size(dsde), "%4.4f", (float)int32_t( ((cmd_buf[8] >> 32) & 0xffff0000) | ((cmd_buf[10] >> 48) & 0xffff)) / 65536.0f); + snprintf(dtde, std::size(dtde), "%4.4f", (float)int32_t((((cmd_buf[8] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[10] >> 32) & 0xffff)) / 65536.0f); + snprintf(dwde, std::size(dwde), "%4.4f", (float)int32_t( (cmd_buf[8] & 0xffff0000) | ((cmd_buf[10] >> 16) & 0xffff)) / 65536.0f); + snprintf(dsdy, std::size(dsdy), "%4.4f", (float)int32_t( ((cmd_buf[9] >> 32) & 0xffff0000) | ((cmd_buf[11] >> 48) & 0xffff)) / 65536.0f); + snprintf(dtdy, std::size(dtdy), "%4.4f", (float)int32_t((((cmd_buf[9] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[11] >> 32) & 0xffff)) / 65536.0f); + snprintf(dwdy, std::size(dwdy), "%4.4f", (float)int32_t( (cmd_buf[9] & 0xffff0000) | ((cmd_buf[11] >> 16) & 0xffff)) / 65536.0f); + + util::stream_format(buffer, "Tri_TexZ %d, XL: %s, XM: %s, XH: %s, YL: %s, YM: %s, YH: %s\n", lft, xl,xm,xh,yl,ym,yh); + buffer << " "; + util::stream_format(buffer, " S: %s, T: %s, W: %s\n", s, t, w); + buffer << " "; + util::stream_format(buffer, " DSDX: %s, DTDX: %s, DWDX: %s\n", dsdx, dtdx, dwdx); + buffer << " "; + util::stream_format(buffer, " DSDE: %s, DTDE: %s, DWDE: %s\n", dsde, dtde, dwde); + buffer << " "; + util::stream_format(buffer, " DSDY: %s, DTDY: %s, DWDY: %s\n", dsdy, dtdy, dwdy); break; } case 0x0c: // Tri_Shade { const int32_t lft = (cmd_buf[0] >> 23) & 0x1; - sprintf(yl, "%4.4f", (float)((cmd_buf[0] >> 32) & 0x1fff) / 4.0f); - sprintf(ym, "%4.4f", (float)((cmd_buf[0] >> 16) & 0x1fff) / 4.0f); - sprintf(yh, "%4.4f", (float)((cmd_buf[0] >> 0) & 0x1fff) / 4.0f); - sprintf(xl, "%4.4f", (float)int32_t(cmd_buf[1] >> 32) / 65536.0f); - sprintf(dxldy, "%4.4f", (float)int32_t(cmd_buf[1]) / 65536.0f); - sprintf(xh, "%4.4f", (float)int32_t(cmd_buf[2] >> 32) / 65536.0f); - sprintf(dxhdy, "%4.4f", (float)int32_t(cmd_buf[2]) / 65536.0f); - sprintf(xm, "%4.4f", (float)int32_t(cmd_buf[3] >> 32) / 65536.0f); - sprintf(dxmdy, "%4.4f", (float)int32_t(cmd_buf[3]) / 65536.0f); - - sprintf(rt, "%4.4f", (float)int32_t( ((cmd_buf[4] >> 32) & 0xffff0000) | ((cmd_buf[ 6] >> 48) & 0xffff)) / 65536.0f); - sprintf(gt, "%4.4f", (float)int32_t((((cmd_buf[4] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[ 6] >> 32) & 0xffff)) / 65536.0f); - sprintf(bt, "%4.4f", (float)int32_t( (cmd_buf[4] & 0xffff0000) | ((cmd_buf[ 6] >> 16) & 0xffff)) / 65536.0f); - sprintf(at, "%4.4f", (float)int32_t( ((cmd_buf[4] & 0x0000ffff) << 16) | ( cmd_buf[ 6] & 0xffff)) / 65536.0f); - sprintf(drdx, "%4.4f", (float)int32_t( ((cmd_buf[5] >> 32) & 0xffff0000) | ((cmd_buf[ 7] >> 48) & 0xffff)) / 65536.0f); - sprintf(dgdx, "%4.4f", (float)int32_t((((cmd_buf[5] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[ 7] >> 32) & 0xffff)) / 65536.0f); - sprintf(dbdx, "%4.4f", (float)int32_t( (cmd_buf[5] & 0xffff0000) | ((cmd_buf[ 7] >> 16) & 0xffff)) / 65536.0f); - sprintf(dadx, "%4.4f", (float)int32_t( ((cmd_buf[5] & 0x0000ffff) << 16) | ( cmd_buf[ 7] & 0xffff)) / 65536.0f); - sprintf(drde, "%4.4f", (float)int32_t( ((cmd_buf[8] >> 32) & 0xffff0000) | ((cmd_buf[10] >> 48) & 0xffff)) / 65536.0f); - sprintf(dgde, "%4.4f", (float)int32_t((((cmd_buf[8] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[10] >> 32) & 0xffff)) / 65536.0f); - sprintf(dbde, "%4.4f", (float)int32_t( (cmd_buf[8] & 0xffff0000) | ((cmd_buf[10] >> 16) & 0xffff)) / 65536.0f); - sprintf(dade, "%4.4f", (float)int32_t( ((cmd_buf[8] & 0x0000ffff) << 16) | ( cmd_buf[10] & 0xffff)) / 65536.0f); - sprintf(drdy, "%4.4f", (float)int32_t( ((cmd_buf[9] >> 32) & 0xffff0000) | ((cmd_buf[11] >> 48) & 0xffff)) / 65536.0f); - sprintf(dgdy, "%4.4f", (float)int32_t((((cmd_buf[9] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[11] >> 32) & 0xffff)) / 65536.0f); - sprintf(dbdy, "%4.4f", (float)int32_t( (cmd_buf[9] & 0xffff0000) | ((cmd_buf[11] >> 16) & 0xffff)) / 65536.0f); - sprintf(dady, "%4.4f", (float)int32_t( ((cmd_buf[9] & 0x0000ffff) << 16) | ( cmd_buf[11] & 0xffff)) / 65536.0f); - - buffer+=sprintf(buffer, "Tri_Shade %d, XL: %s, XM: %s, XH: %s, YL: %s, YM: %s, YH: %s\n", lft, xl,xm,xh,yl,ym,yh); - buffer+=sprintf(buffer, " "); - buffer+=sprintf(buffer, " R: %s, G: %s, B: %s, A: %s\n", rt, gt, bt, at); - buffer+=sprintf(buffer, " "); - buffer+=sprintf(buffer, " DRDX: %s, DGDX: %s, DBDX: %s, DADX: %s\n", drdx, dgdx, dbdx, dadx); - buffer+=sprintf(buffer, " "); - buffer+=sprintf(buffer, " DRDE: %s, DGDE: %s, DBDE: %s, DADE: %s\n", drde, dgde, dbde, dade); - buffer+=sprintf(buffer, " "); - buffer+=sprintf(buffer, " DRDY: %s, DGDY: %s, DBDY: %s, DADY: %s\n", drdy, dgdy, dbdy, dady); + snprintf(yl, std::size(yl), "%4.4f", (float)((cmd_buf[0] >> 32) & 0x1fff) / 4.0f); + snprintf(ym, std::size(ym), "%4.4f", (float)((cmd_buf[0] >> 16) & 0x1fff) / 4.0f); + snprintf(yh, std::size(yh), "%4.4f", (float)((cmd_buf[0] >> 0) & 0x1fff) / 4.0f); + snprintf(xl, std::size(xl), "%4.4f", (float)int32_t(cmd_buf[1] >> 32) / 65536.0f); + snprintf(dxldy, std::size(dxldy), "%4.4f", (float)int32_t(cmd_buf[1]) / 65536.0f); + snprintf(xh, std::size(xh), "%4.4f", (float)int32_t(cmd_buf[2] >> 32) / 65536.0f); + snprintf(dxhdy, std::size(dxhdy), "%4.4f", (float)int32_t(cmd_buf[2]) / 65536.0f); + snprintf(xm, std::size(xm), "%4.4f", (float)int32_t(cmd_buf[3] >> 32) / 65536.0f); + snprintf(dxmdy, std::size(dxmdy), "%4.4f", (float)int32_t(cmd_buf[3]) / 65536.0f); + + snprintf(rt, std::size(rt), "%4.4f", (float)int32_t( ((cmd_buf[4] >> 32) & 0xffff0000) | ((cmd_buf[ 6] >> 48) & 0xffff)) / 65536.0f); + snprintf(gt, std::size(gt), "%4.4f", (float)int32_t((((cmd_buf[4] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[ 6] >> 32) & 0xffff)) / 65536.0f); + snprintf(bt, std::size(bt), "%4.4f", (float)int32_t( (cmd_buf[4] & 0xffff0000) | ((cmd_buf[ 6] >> 16) & 0xffff)) / 65536.0f); + snprintf(at, std::size(at), "%4.4f", (float)int32_t( ((cmd_buf[4] & 0x0000ffff) << 16) | ( cmd_buf[ 6] & 0xffff)) / 65536.0f); + snprintf(drdx, std::size(drdx), "%4.4f", (float)int32_t( ((cmd_buf[5] >> 32) & 0xffff0000) | ((cmd_buf[ 7] >> 48) & 0xffff)) / 65536.0f); + snprintf(dgdx, std::size(dgdx), "%4.4f", (float)int32_t((((cmd_buf[5] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[ 7] >> 32) & 0xffff)) / 65536.0f); + snprintf(dbdx, std::size(dbdx), "%4.4f", (float)int32_t( (cmd_buf[5] & 0xffff0000) | ((cmd_buf[ 7] >> 16) & 0xffff)) / 65536.0f); + snprintf(dadx, std::size(dadx), "%4.4f", (float)int32_t( ((cmd_buf[5] & 0x0000ffff) << 16) | ( cmd_buf[ 7] & 0xffff)) / 65536.0f); + snprintf(drde, std::size(drde), "%4.4f", (float)int32_t( ((cmd_buf[8] >> 32) & 0xffff0000) | ((cmd_buf[10] >> 48) & 0xffff)) / 65536.0f); + snprintf(dgde, std::size(dgde), "%4.4f", (float)int32_t((((cmd_buf[8] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[10] >> 32) & 0xffff)) / 65536.0f); + snprintf(dbde, std::size(dbde), "%4.4f", (float)int32_t( (cmd_buf[8] & 0xffff0000) | ((cmd_buf[10] >> 16) & 0xffff)) / 65536.0f); + snprintf(dade, std::size(dade), "%4.4f", (float)int32_t( ((cmd_buf[8] & 0x0000ffff) << 16) | ( cmd_buf[10] & 0xffff)) / 65536.0f); + snprintf(drdy, std::size(drdy), "%4.4f", (float)int32_t( ((cmd_buf[9] >> 32) & 0xffff0000) | ((cmd_buf[11] >> 48) & 0xffff)) / 65536.0f); + snprintf(dgdy, std::size(dgdy), "%4.4f", (float)int32_t((((cmd_buf[9] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[11] >> 32) & 0xffff)) / 65536.0f); + snprintf(dbdy, std::size(dbdy), "%4.4f", (float)int32_t( (cmd_buf[9] & 0xffff0000) | ((cmd_buf[11] >> 16) & 0xffff)) / 65536.0f); + snprintf(dady, std::size(dady), "%4.4f", (float)int32_t( ((cmd_buf[9] & 0x0000ffff) << 16) | ( cmd_buf[11] & 0xffff)) / 65536.0f); + + util::stream_format(buffer, "Tri_Shade %d, XL: %s, XM: %s, XH: %s, YL: %s, YM: %s, YH: %s\n", lft, xl,xm,xh,yl,ym,yh); + buffer << " "; + util::stream_format(buffer, " R: %s, G: %s, B: %s, A: %s\n", rt, gt, bt, at); + buffer << " "; + util::stream_format(buffer, " DRDX: %s, DGDX: %s, DBDX: %s, DADX: %s\n", drdx, dgdx, dbdx, dadx); + buffer << " "; + util::stream_format(buffer, " DRDE: %s, DGDE: %s, DBDE: %s, DADE: %s\n", drde, dgde, dbde, dade); + buffer << " "; + util::stream_format(buffer, " DRDY: %s, DGDY: %s, DBDY: %s, DADY: %s\n", drdy, dgdy, dbdy, dady); break; } case 0x0d: // Tri_ShadeZ { const int32_t lft = (cmd_buf[0] >> 23) & 0x1; - sprintf(yl, "%4.4f", (float)((cmd_buf[0] >> 32) & 0x1fff) / 4.0f); - sprintf(ym, "%4.4f", (float)((cmd_buf[0] >> 16) & 0x1fff) / 4.0f); - sprintf(yh, "%4.4f", (float)((cmd_buf[0] >> 0) & 0x1fff) / 4.0f); - sprintf(xl, "%4.4f", (float)int32_t(cmd_buf[1] >> 32) / 65536.0f); - sprintf(dxldy, "%4.4f", (float)int32_t(cmd_buf[1]) / 65536.0f); - sprintf(xh, "%4.4f", (float)int32_t(cmd_buf[2] >> 32) / 65536.0f); - sprintf(dxhdy, "%4.4f", (float)int32_t(cmd_buf[2]) / 65536.0f); - sprintf(xm, "%4.4f", (float)int32_t(cmd_buf[3] >> 32) / 65536.0f); - sprintf(dxmdy, "%4.4f", (float)int32_t(cmd_buf[3]) / 65536.0f); - - sprintf(rt, "%4.4f", (float)int32_t( ((cmd_buf[4] >> 32) & 0xffff0000) | ((cmd_buf[ 6] >> 48) & 0xffff)) / 65536.0f); - sprintf(gt, "%4.4f", (float)int32_t((((cmd_buf[4] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[ 6] >> 32) & 0xffff)) / 65536.0f); - sprintf(bt, "%4.4f", (float)int32_t( (cmd_buf[4] & 0xffff0000) | ((cmd_buf[ 6] >> 16) & 0xffff)) / 65536.0f); - sprintf(at, "%4.4f", (float)int32_t( ((cmd_buf[4] & 0x0000ffff) << 16) | ( cmd_buf[ 6] & 0xffff)) / 65536.0f); - sprintf(drdx, "%4.4f", (float)int32_t( ((cmd_buf[5] >> 32) & 0xffff0000) | ((cmd_buf[ 7] >> 48) & 0xffff)) / 65536.0f); - sprintf(dgdx, "%4.4f", (float)int32_t((((cmd_buf[5] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[ 7] >> 32) & 0xffff)) / 65536.0f); - sprintf(dbdx, "%4.4f", (float)int32_t( (cmd_buf[5] & 0xffff0000) | ((cmd_buf[ 7] >> 16) & 0xffff)) / 65536.0f); - sprintf(dadx, "%4.4f", (float)int32_t( ((cmd_buf[5] & 0x0000ffff) << 16) | ( cmd_buf[ 7] & 0xffff)) / 65536.0f); - sprintf(drde, "%4.4f", (float)int32_t( ((cmd_buf[8] >> 32) & 0xffff0000) | ((cmd_buf[10] >> 48) & 0xffff)) / 65536.0f); - sprintf(dgde, "%4.4f", (float)int32_t((((cmd_buf[8] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[10] >> 32) & 0xffff)) / 65536.0f); - sprintf(dbde, "%4.4f", (float)int32_t( (cmd_buf[8] & 0xffff0000) | ((cmd_buf[10] >> 16) & 0xffff)) / 65536.0f); - sprintf(dade, "%4.4f", (float)int32_t( ((cmd_buf[8] & 0x0000ffff) << 16) | ( cmd_buf[10] & 0xffff)) / 65536.0f); - sprintf(drdy, "%4.4f", (float)int32_t( ((cmd_buf[9] >> 32) & 0xffff0000) | ((cmd_buf[11] >> 48) & 0xffff)) / 65536.0f); - sprintf(dgdy, "%4.4f", (float)int32_t((((cmd_buf[9] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[11] >> 32) & 0xffff)) / 65536.0f); - sprintf(dbdy, "%4.4f", (float)int32_t( (cmd_buf[9] & 0xffff0000) | ((cmd_buf[11] >> 16) & 0xffff)) / 65536.0f); - sprintf(dady, "%4.4f", (float)int32_t( ((cmd_buf[9] & 0x0000ffff) << 16) | ( cmd_buf[11] & 0xffff)) / 65536.0f); - - buffer+=sprintf(buffer, "Tri_ShadeZ %d, XL: %s, XM: %s, XH: %s, YL: %s, YM: %s, YH: %s\n", lft, xl,xm,xh,yl,ym,yh); - buffer+=sprintf(buffer, " "); - buffer+=sprintf(buffer, " R: %s, G: %s, B: %s, A: %s\n", rt, gt, bt, at); - buffer+=sprintf(buffer, " "); - buffer+=sprintf(buffer, " DRDX: %s, DGDX: %s, DBDX: %s, DADX: %s\n", drdx, dgdx, dbdx, dadx); - buffer+=sprintf(buffer, " "); - buffer+=sprintf(buffer, " DRDE: %s, DGDE: %s, DBDE: %s, DADE: %s\n", drde, dgde, dbde, dade); - buffer+=sprintf(buffer, " "); - buffer+=sprintf(buffer, " DRDY: %s, DGDY: %s, DBDY: %s, DADY: %s\n", drdy, dgdy, dbdy, dady); + snprintf(yl, std::size(yl), "%4.4f", (float)((cmd_buf[0] >> 32) & 0x1fff) / 4.0f); + snprintf(ym, std::size(ym), "%4.4f", (float)((cmd_buf[0] >> 16) & 0x1fff) / 4.0f); + snprintf(yh, std::size(yh), "%4.4f", (float)((cmd_buf[0] >> 0) & 0x1fff) / 4.0f); + snprintf(xl, std::size(xl), "%4.4f", (float)int32_t(cmd_buf[1] >> 32) / 65536.0f); + snprintf(dxldy, std::size(dxldy), "%4.4f", (float)int32_t(cmd_buf[1]) / 65536.0f); + snprintf(xh, std::size(xh), "%4.4f", (float)int32_t(cmd_buf[2] >> 32) / 65536.0f); + snprintf(dxhdy, std::size(dxhdy), "%4.4f", (float)int32_t(cmd_buf[2]) / 65536.0f); + snprintf(xm, std::size(xm), "%4.4f", (float)int32_t(cmd_buf[3] >> 32) / 65536.0f); + snprintf(dxmdy, std::size(dxmdy), "%4.4f", (float)int32_t(cmd_buf[3]) / 65536.0f); + + snprintf(rt, std::size(rt), "%4.4f", (float)int32_t( ((cmd_buf[4] >> 32) & 0xffff0000) | ((cmd_buf[ 6] >> 48) & 0xffff)) / 65536.0f); + snprintf(gt, std::size(gt), "%4.4f", (float)int32_t((((cmd_buf[4] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[ 6] >> 32) & 0xffff)) / 65536.0f); + snprintf(bt, std::size(bt), "%4.4f", (float)int32_t( (cmd_buf[4] & 0xffff0000) | ((cmd_buf[ 6] >> 16) & 0xffff)) / 65536.0f); + snprintf(at, std::size(at), "%4.4f", (float)int32_t( ((cmd_buf[4] & 0x0000ffff) << 16) | ( cmd_buf[ 6] & 0xffff)) / 65536.0f); + snprintf(drdx, std::size(drdx), "%4.4f", (float)int32_t( ((cmd_buf[5] >> 32) & 0xffff0000) | ((cmd_buf[ 7] >> 48) & 0xffff)) / 65536.0f); + snprintf(dgdx, std::size(dgdx), "%4.4f", (float)int32_t((((cmd_buf[5] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[ 7] >> 32) & 0xffff)) / 65536.0f); + snprintf(dbdx, std::size(dbdx), "%4.4f", (float)int32_t( (cmd_buf[5] & 0xffff0000) | ((cmd_buf[ 7] >> 16) & 0xffff)) / 65536.0f); + snprintf(dadx, std::size(dadx), "%4.4f", (float)int32_t( ((cmd_buf[5] & 0x0000ffff) << 16) | ( cmd_buf[ 7] & 0xffff)) / 65536.0f); + snprintf(drde, std::size(drde), "%4.4f", (float)int32_t( ((cmd_buf[8] >> 32) & 0xffff0000) | ((cmd_buf[10] >> 48) & 0xffff)) / 65536.0f); + snprintf(dgde, std::size(dgde), "%4.4f", (float)int32_t((((cmd_buf[8] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[10] >> 32) & 0xffff)) / 65536.0f); + snprintf(dbde, std::size(dbde), "%4.4f", (float)int32_t( (cmd_buf[8] & 0xffff0000) | ((cmd_buf[10] >> 16) & 0xffff)) / 65536.0f); + snprintf(dade, std::size(dade), "%4.4f", (float)int32_t( ((cmd_buf[8] & 0x0000ffff) << 16) | ( cmd_buf[10] & 0xffff)) / 65536.0f); + snprintf(drdy, std::size(drdy), "%4.4f", (float)int32_t( ((cmd_buf[9] >> 32) & 0xffff0000) | ((cmd_buf[11] >> 48) & 0xffff)) / 65536.0f); + snprintf(dgdy, std::size(dgdy), "%4.4f", (float)int32_t((((cmd_buf[9] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[11] >> 32) & 0xffff)) / 65536.0f); + snprintf(dbdy, std::size(dbdy), "%4.4f", (float)int32_t( (cmd_buf[9] & 0xffff0000) | ((cmd_buf[11] >> 16) & 0xffff)) / 65536.0f); + snprintf(dady, std::size(dady), "%4.4f", (float)int32_t( ((cmd_buf[9] & 0x0000ffff) << 16) | ( cmd_buf[11] & 0xffff)) / 65536.0f); + + util::stream_format(buffer, "Tri_ShadeZ %d, XL: %s, XM: %s, XH: %s, YL: %s, YM: %s, YH: %s\n", lft, xl,xm,xh,yl,ym,yh); + buffer << " "; + util::stream_format(buffer, " R: %s, G: %s, B: %s, A: %s\n", rt, gt, bt, at); + buffer << " "; + util::stream_format(buffer, " DRDX: %s, DGDX: %s, DBDX: %s, DADX: %s\n", drdx, dgdx, dbdx, dadx); + buffer << " "; + util::stream_format(buffer, " DRDE: %s, DGDE: %s, DBDE: %s, DADE: %s\n", drde, dgde, dbde, dade); + buffer << " "; + util::stream_format(buffer, " DRDY: %s, DGDY: %s, DBDY: %s, DADY: %s\n", drdy, dgdy, dbdy, dady); break; } case 0x0e: // Tri_TexShade { const int32_t lft = (cmd_buf[0] >> 23) & 0x1; - sprintf(yl, "%4.4f", (float)((cmd_buf[0] >> 32) & 0x1fff) / 4.0f); - sprintf(ym, "%4.4f", (float)((cmd_buf[0] >> 16) & 0x1fff) / 4.0f); - sprintf(yh, "%4.4f", (float)((cmd_buf[0] >> 0) & 0x1fff) / 4.0f); - sprintf(xl, "%4.4f", (float)int32_t(cmd_buf[1] >> 32) / 65536.0f); - sprintf(dxldy, "%4.4f", (float)int32_t(cmd_buf[1]) / 65536.0f); - sprintf(xh, "%4.4f", (float)int32_t(cmd_buf[2] >> 32) / 65536.0f); - sprintf(dxhdy, "%4.4f", (float)int32_t(cmd_buf[2]) / 65536.0f); - sprintf(xm, "%4.4f", (float)int32_t(cmd_buf[3] >> 32) / 65536.0f); - sprintf(dxmdy, "%4.4f", (float)int32_t(cmd_buf[3]) / 65536.0f); - - sprintf(rt, "%4.4f", (float)int32_t( ((cmd_buf[4] >> 32) & 0xffff0000) | ((cmd_buf[ 6] >> 48) & 0xffff)) / 65536.0f); - sprintf(gt, "%4.4f", (float)int32_t((((cmd_buf[4] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[ 6] >> 32) & 0xffff)) / 65536.0f); - sprintf(bt, "%4.4f", (float)int32_t( (cmd_buf[4] & 0xffff0000) | ((cmd_buf[ 6] >> 16) & 0xffff)) / 65536.0f); - sprintf(at, "%4.4f", (float)int32_t( ((cmd_buf[4] & 0x0000ffff) << 16) | ( cmd_buf[ 6] & 0xffff)) / 65536.0f); - sprintf(drdx, "%4.4f", (float)int32_t( ((cmd_buf[5] >> 32) & 0xffff0000) | ((cmd_buf[ 7] >> 48) & 0xffff)) / 65536.0f); - sprintf(dgdx, "%4.4f", (float)int32_t((((cmd_buf[5] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[ 7] >> 32) & 0xffff)) / 65536.0f); - sprintf(dbdx, "%4.4f", (float)int32_t( (cmd_buf[5] & 0xffff0000) | ((cmd_buf[ 7] >> 16) & 0xffff)) / 65536.0f); - sprintf(dadx, "%4.4f", (float)int32_t( ((cmd_buf[5] & 0x0000ffff) << 16) | ( cmd_buf[ 7] & 0xffff)) / 65536.0f); - sprintf(drde, "%4.4f", (float)int32_t( ((cmd_buf[8] >> 32) & 0xffff0000) | ((cmd_buf[10] >> 48) & 0xffff)) / 65536.0f); - sprintf(dgde, "%4.4f", (float)int32_t((((cmd_buf[8] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[10] >> 32) & 0xffff)) / 65536.0f); - sprintf(dbde, "%4.4f", (float)int32_t( (cmd_buf[8] & 0xffff0000) | ((cmd_buf[10] >> 16) & 0xffff)) / 65536.0f); - sprintf(dade, "%4.4f", (float)int32_t( ((cmd_buf[8] & 0x0000ffff) << 16) | ( cmd_buf[10] & 0xffff)) / 65536.0f); - sprintf(drdy, "%4.4f", (float)int32_t( ((cmd_buf[9] >> 32) & 0xffff0000) | ((cmd_buf[11] >> 48) & 0xffff)) / 65536.0f); - sprintf(dgdy, "%4.4f", (float)int32_t((((cmd_buf[9] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[11] >> 32) & 0xffff)) / 65536.0f); - sprintf(dbdy, "%4.4f", (float)int32_t( (cmd_buf[9] & 0xffff0000) | ((cmd_buf[11] >> 16) & 0xffff)) / 65536.0f); - sprintf(dady, "%4.4f", (float)int32_t( ((cmd_buf[9] & 0x0000ffff) << 16) | ( cmd_buf[11] & 0xffff)) / 65536.0f); - - sprintf(s, "%4.4f", (float)int32_t( ((cmd_buf[4] >> 32) & 0xffff0000) | ((cmd_buf[ 6] >> 48) & 0xffff)) / 65536.0f); - sprintf(t, "%4.4f", (float)int32_t((((cmd_buf[4] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[ 6] >> 32) & 0xffff)) / 65536.0f); - sprintf(w, "%4.4f", (float)int32_t( (cmd_buf[4] & 0xffff0000) | ((cmd_buf[ 6] >> 16) & 0xffff)) / 65536.0f); - sprintf(dsdx, "%4.4f", (float)int32_t( ((cmd_buf[5] >> 32) & 0xffff0000) | ((cmd_buf[ 7] >> 48) & 0xffff)) / 65536.0f); - sprintf(dtdx, "%4.4f", (float)int32_t((((cmd_buf[5] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[ 7] >> 32) & 0xffff)) / 65536.0f); - sprintf(dwdx, "%4.4f", (float)int32_t( (cmd_buf[5] & 0xffff0000) | ((cmd_buf[ 7] >> 16) & 0xffff)) / 65536.0f); - sprintf(dsde, "%4.4f", (float)int32_t( ((cmd_buf[8] >> 32) & 0xffff0000) | ((cmd_buf[10] >> 48) & 0xffff)) / 65536.0f); - sprintf(dtde, "%4.4f", (float)int32_t((((cmd_buf[8] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[10] >> 32) & 0xffff)) / 65536.0f); - sprintf(dwde, "%4.4f", (float)int32_t( (cmd_buf[8] & 0xffff0000) | ((cmd_buf[10] >> 16) & 0xffff)) / 65536.0f); - sprintf(dsdy, "%4.4f", (float)int32_t( ((cmd_buf[9] >> 32) & 0xffff0000) | ((cmd_buf[11] >> 48) & 0xffff)) / 65536.0f); - sprintf(dtdy, "%4.4f", (float)int32_t((((cmd_buf[9] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[11] >> 32) & 0xffff)) / 65536.0f); - sprintf(dwdy, "%4.4f", (float)int32_t( (cmd_buf[9] & 0xffff0000) | ((cmd_buf[11] >> 16) & 0xffff)) / 65536.0f); - - buffer+=sprintf(buffer, "Tri_TexShade %d, XL: %s, XM: %s, XH: %s, YL: %s, YM: %s, YH: %s\n", lft, xl,xm,xh,yl,ym,yh); - buffer+=sprintf(buffer, " "); - buffer+=sprintf(buffer, " R: %s, G: %s, B: %s, A: %s\n", rt, gt, bt, at); - buffer+=sprintf(buffer, " "); - buffer+=sprintf(buffer, " DRDX: %s, DGDX: %s, DBDX: %s, DADX: %s\n", drdx, dgdx, dbdx, dadx); - buffer+=sprintf(buffer, " "); - buffer+=sprintf(buffer, " DRDE: %s, DGDE: %s, DBDE: %s, DADE: %s\n", drde, dgde, dbde, dade); - buffer+=sprintf(buffer, " "); - buffer+=sprintf(buffer, " DRDY: %s, DGDY: %s, DBDY: %s, DADY: %s\n", drdy, dgdy, dbdy, dady); - - buffer+=sprintf(buffer, " "); - buffer+=sprintf(buffer, " S: %s, T: %s, W: %s\n", s, t, w); - buffer+=sprintf(buffer, " "); - buffer+=sprintf(buffer, " DSDX: %s, DTDX: %s, DWDX: %s\n", dsdx, dtdx, dwdx); - buffer+=sprintf(buffer, " "); - buffer+=sprintf(buffer, " DSDE: %s, DTDE: %s, DWDE: %s\n", dsde, dtde, dwde); - buffer+=sprintf(buffer, " "); - buffer+=sprintf(buffer, " DSDY: %s, DTDY: %s, DWDY: %s\n", dsdy, dtdy, dwdy); + snprintf(yl, std::size(yl), "%4.4f", (float)((cmd_buf[0] >> 32) & 0x1fff) / 4.0f); + snprintf(ym, std::size(ym), "%4.4f", (float)((cmd_buf[0] >> 16) & 0x1fff) / 4.0f); + snprintf(yh, std::size(yh), "%4.4f", (float)((cmd_buf[0] >> 0) & 0x1fff) / 4.0f); + snprintf(xl, std::size(xl), "%4.4f", (float)int32_t(cmd_buf[1] >> 32) / 65536.0f); + snprintf(dxldy, std::size(dxldy), "%4.4f", (float)int32_t(cmd_buf[1]) / 65536.0f); + snprintf(xh, std::size(xh), "%4.4f", (float)int32_t(cmd_buf[2] >> 32) / 65536.0f); + snprintf(dxhdy, std::size(dxhdy), "%4.4f", (float)int32_t(cmd_buf[2]) / 65536.0f); + snprintf(xm, std::size(xm), "%4.4f", (float)int32_t(cmd_buf[3] >> 32) / 65536.0f); + snprintf(dxmdy, std::size(dxmdy), "%4.4f", (float)int32_t(cmd_buf[3]) / 65536.0f); + + snprintf(rt, std::size(rt), "%4.4f", (float)int32_t( ((cmd_buf[4] >> 32) & 0xffff0000) | ((cmd_buf[ 6] >> 48) & 0xffff)) / 65536.0f); + snprintf(gt, std::size(gt), "%4.4f", (float)int32_t((((cmd_buf[4] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[ 6] >> 32) & 0xffff)) / 65536.0f); + snprintf(bt, std::size(bt), "%4.4f", (float)int32_t( (cmd_buf[4] & 0xffff0000) | ((cmd_buf[ 6] >> 16) & 0xffff)) / 65536.0f); + snprintf(at, std::size(at), "%4.4f", (float)int32_t( ((cmd_buf[4] & 0x0000ffff) << 16) | ( cmd_buf[ 6] & 0xffff)) / 65536.0f); + snprintf(drdx, std::size(drdx), "%4.4f", (float)int32_t( ((cmd_buf[5] >> 32) & 0xffff0000) | ((cmd_buf[ 7] >> 48) & 0xffff)) / 65536.0f); + snprintf(dgdx, std::size(dgdx), "%4.4f", (float)int32_t((((cmd_buf[5] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[ 7] >> 32) & 0xffff)) / 65536.0f); + snprintf(dbdx, std::size(dbdx), "%4.4f", (float)int32_t( (cmd_buf[5] & 0xffff0000) | ((cmd_buf[ 7] >> 16) & 0xffff)) / 65536.0f); + snprintf(dadx, std::size(dadx), "%4.4f", (float)int32_t( ((cmd_buf[5] & 0x0000ffff) << 16) | ( cmd_buf[ 7] & 0xffff)) / 65536.0f); + snprintf(drde, std::size(drde), "%4.4f", (float)int32_t( ((cmd_buf[8] >> 32) & 0xffff0000) | ((cmd_buf[10] >> 48) & 0xffff)) / 65536.0f); + snprintf(dgde, std::size(dgde), "%4.4f", (float)int32_t((((cmd_buf[8] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[10] >> 32) & 0xffff)) / 65536.0f); + snprintf(dbde, std::size(dbde), "%4.4f", (float)int32_t( (cmd_buf[8] & 0xffff0000) | ((cmd_buf[10] >> 16) & 0xffff)) / 65536.0f); + snprintf(dade, std::size(dade), "%4.4f", (float)int32_t( ((cmd_buf[8] & 0x0000ffff) << 16) | ( cmd_buf[10] & 0xffff)) / 65536.0f); + snprintf(drdy, std::size(drdy), "%4.4f", (float)int32_t( ((cmd_buf[9] >> 32) & 0xffff0000) | ((cmd_buf[11] >> 48) & 0xffff)) / 65536.0f); + snprintf(dgdy, std::size(dgdy), "%4.4f", (float)int32_t((((cmd_buf[9] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[11] >> 32) & 0xffff)) / 65536.0f); + snprintf(dbdy, std::size(dbdy), "%4.4f", (float)int32_t( (cmd_buf[9] & 0xffff0000) | ((cmd_buf[11] >> 16) & 0xffff)) / 65536.0f); + snprintf(dady, std::size(dady), "%4.4f", (float)int32_t( ((cmd_buf[9] & 0x0000ffff) << 16) | ( cmd_buf[11] & 0xffff)) / 65536.0f); + + snprintf(s, std::size(s), "%4.4f", (float)int32_t( ((cmd_buf[4] >> 32) & 0xffff0000) | ((cmd_buf[ 6] >> 48) & 0xffff)) / 65536.0f); + snprintf(t, std::size(t), "%4.4f", (float)int32_t((((cmd_buf[4] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[ 6] >> 32) & 0xffff)) / 65536.0f); + snprintf(w, std::size(w), "%4.4f", (float)int32_t( (cmd_buf[4] & 0xffff0000) | ((cmd_buf[ 6] >> 16) & 0xffff)) / 65536.0f); + snprintf(dsdx, std::size(dsdx), "%4.4f", (float)int32_t( ((cmd_buf[5] >> 32) & 0xffff0000) | ((cmd_buf[ 7] >> 48) & 0xffff)) / 65536.0f); + snprintf(dtdx, std::size(dtdx), "%4.4f", (float)int32_t((((cmd_buf[5] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[ 7] >> 32) & 0xffff)) / 65536.0f); + snprintf(dwdx, std::size(dwdx), "%4.4f", (float)int32_t( (cmd_buf[5] & 0xffff0000) | ((cmd_buf[ 7] >> 16) & 0xffff)) / 65536.0f); + snprintf(dsde, std::size(dsde), "%4.4f", (float)int32_t( ((cmd_buf[8] >> 32) & 0xffff0000) | ((cmd_buf[10] >> 48) & 0xffff)) / 65536.0f); + snprintf(dtde, std::size(dtde), "%4.4f", (float)int32_t((((cmd_buf[8] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[10] >> 32) & 0xffff)) / 65536.0f); + snprintf(dwde, std::size(dwde), "%4.4f", (float)int32_t( (cmd_buf[8] & 0xffff0000) | ((cmd_buf[10] >> 16) & 0xffff)) / 65536.0f); + snprintf(dsdy, std::size(dsdy), "%4.4f", (float)int32_t( ((cmd_buf[9] >> 32) & 0xffff0000) | ((cmd_buf[11] >> 48) & 0xffff)) / 65536.0f); + snprintf(dtdy, std::size(dtdy), "%4.4f", (float)int32_t((((cmd_buf[9] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[11] >> 32) & 0xffff)) / 65536.0f); + snprintf(dwdy, std::size(dwdy), "%4.4f", (float)int32_t( (cmd_buf[9] & 0xffff0000) | ((cmd_buf[11] >> 16) & 0xffff)) / 65536.0f); + + util::stream_format(buffer, "Tri_TexShade %d, XL: %s, XM: %s, XH: %s, YL: %s, YM: %s, YH: %s\n", lft, xl,xm,xh,yl,ym,yh); + buffer << " "; + util::stream_format(buffer, " R: %s, G: %s, B: %s, A: %s\n", rt, gt, bt, at); + buffer << " "; + util::stream_format(buffer, " DRDX: %s, DGDX: %s, DBDX: %s, DADX: %s\n", drdx, dgdx, dbdx, dadx); + buffer << " "; + util::stream_format(buffer, " DRDE: %s, DGDE: %s, DBDE: %s, DADE: %s\n", drde, dgde, dbde, dade); + buffer << " "; + util::stream_format(buffer, " DRDY: %s, DGDY: %s, DBDY: %s, DADY: %s\n", drdy, dgdy, dbdy, dady); + + buffer << " "; + util::stream_format(buffer, " S: %s, T: %s, W: %s\n", s, t, w); + buffer << " "; + util::stream_format(buffer, " DSDX: %s, DTDX: %s, DWDX: %s\n", dsdx, dtdx, dwdx); + buffer << " "; + util::stream_format(buffer, " DSDE: %s, DTDE: %s, DWDE: %s\n", dsde, dtde, dwde); + buffer << " "; + util::stream_format(buffer, " DSDY: %s, DTDY: %s, DWDY: %s\n", dsdy, dtdy, dwdy); break; } case 0x0f: // Tri_TexShadeZ { const int32_t lft = (cmd_buf[0] >> 23) & 0x1; - sprintf(yl, "%4.4f", (float)((cmd_buf[0] >> 32) & 0x1fff) / 4.0f); - sprintf(ym, "%4.4f", (float)((cmd_buf[0] >> 16) & 0x1fff) / 4.0f); - sprintf(yh, "%4.4f", (float)((cmd_buf[0] >> 0) & 0x1fff) / 4.0f); - sprintf(xl, "%4.4f", (float)int32_t(cmd_buf[1] >> 32) / 65536.0f); - sprintf(dxldy, "%4.4f", (float)int32_t(cmd_buf[1]) / 65536.0f); - sprintf(xh, "%4.4f", (float)int32_t(cmd_buf[2] >> 32) / 65536.0f); - sprintf(dxhdy, "%4.4f", (float)int32_t(cmd_buf[2]) / 65536.0f); - sprintf(xm, "%4.4f", (float)int32_t(cmd_buf[3] >> 32) / 65536.0f); - sprintf(dxmdy, "%4.4f", (float)int32_t(cmd_buf[3]) / 65536.0f); - - sprintf(rt, "%4.4f", (float)int32_t( ((cmd_buf[4] >> 32) & 0xffff0000) | ((cmd_buf[ 6] >> 48) & 0xffff)) / 65536.0f); - sprintf(gt, "%4.4f", (float)int32_t((((cmd_buf[4] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[ 6] >> 32) & 0xffff)) / 65536.0f); - sprintf(bt, "%4.4f", (float)int32_t( (cmd_buf[4] & 0xffff0000) | ((cmd_buf[ 6] >> 16) & 0xffff)) / 65536.0f); - sprintf(at, "%4.4f", (float)int32_t( ((cmd_buf[4] & 0x0000ffff) << 16) | ( cmd_buf[ 6] & 0xffff)) / 65536.0f); - sprintf(drdx, "%4.4f", (float)int32_t( ((cmd_buf[5] >> 32) & 0xffff0000) | ((cmd_buf[ 7] >> 48) & 0xffff)) / 65536.0f); - sprintf(dgdx, "%4.4f", (float)int32_t((((cmd_buf[5] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[ 7] >> 32) & 0xffff)) / 65536.0f); - sprintf(dbdx, "%4.4f", (float)int32_t( (cmd_buf[5] & 0xffff0000) | ((cmd_buf[ 7] >> 16) & 0xffff)) / 65536.0f); - sprintf(dadx, "%4.4f", (float)int32_t( ((cmd_buf[5] & 0x0000ffff) << 16) | ( cmd_buf[ 7] & 0xffff)) / 65536.0f); - sprintf(drde, "%4.4f", (float)int32_t( ((cmd_buf[8] >> 32) & 0xffff0000) | ((cmd_buf[10] >> 48) & 0xffff)) / 65536.0f); - sprintf(dgde, "%4.4f", (float)int32_t((((cmd_buf[8] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[10] >> 32) & 0xffff)) / 65536.0f); - sprintf(dbde, "%4.4f", (float)int32_t( (cmd_buf[8] & 0xffff0000) | ((cmd_buf[10] >> 16) & 0xffff)) / 65536.0f); - sprintf(dade, "%4.4f", (float)int32_t( ((cmd_buf[8] & 0x0000ffff) << 16) | ( cmd_buf[10] & 0xffff)) / 65536.0f); - sprintf(drdy, "%4.4f", (float)int32_t( ((cmd_buf[9] >> 32) & 0xffff0000) | ((cmd_buf[11] >> 48) & 0xffff)) / 65536.0f); - sprintf(dgdy, "%4.4f", (float)int32_t((((cmd_buf[9] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[11] >> 32) & 0xffff)) / 65536.0f); - sprintf(dbdy, "%4.4f", (float)int32_t( (cmd_buf[9] & 0xffff0000) | ((cmd_buf[11] >> 16) & 0xffff)) / 65536.0f); - sprintf(dady, "%4.4f", (float)int32_t( ((cmd_buf[9] & 0x0000ffff) << 16) | ( cmd_buf[11] & 0xffff)) / 65536.0f); - - sprintf(s, "%4.4f", (float)int32_t( ((cmd_buf[4] >> 32) & 0xffff0000) | ((cmd_buf[ 6] >> 48) & 0xffff)) / 65536.0f); - sprintf(t, "%4.4f", (float)int32_t((((cmd_buf[4] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[ 6] >> 32) & 0xffff)) / 65536.0f); - sprintf(w, "%4.4f", (float)int32_t( (cmd_buf[4] & 0xffff0000) | ((cmd_buf[ 6] >> 16) & 0xffff)) / 65536.0f); - sprintf(dsdx, "%4.4f", (float)int32_t( ((cmd_buf[5] >> 32) & 0xffff0000) | ((cmd_buf[ 7] >> 48) & 0xffff)) / 65536.0f); - sprintf(dtdx, "%4.4f", (float)int32_t((((cmd_buf[5] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[ 7] >> 32) & 0xffff)) / 65536.0f); - sprintf(dwdx, "%4.4f", (float)int32_t( (cmd_buf[5] & 0xffff0000) | ((cmd_buf[ 7] >> 16) & 0xffff)) / 65536.0f); - sprintf(dsde, "%4.4f", (float)int32_t( ((cmd_buf[8] >> 32) & 0xffff0000) | ((cmd_buf[10] >> 48) & 0xffff)) / 65536.0f); - sprintf(dtde, "%4.4f", (float)int32_t((((cmd_buf[8] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[10] >> 32) & 0xffff)) / 65536.0f); - sprintf(dwde, "%4.4f", (float)int32_t( (cmd_buf[8] & 0xffff0000) | ((cmd_buf[10] >> 16) & 0xffff)) / 65536.0f); - sprintf(dsdy, "%4.4f", (float)int32_t( ((cmd_buf[9] >> 32) & 0xffff0000) | ((cmd_buf[11] >> 48) & 0xffff)) / 65536.0f); - sprintf(dtdy, "%4.4f", (float)int32_t((((cmd_buf[9] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[11] >> 32) & 0xffff)) / 65536.0f); - sprintf(dwdy, "%4.4f", (float)int32_t( (cmd_buf[9] & 0xffff0000) | ((cmd_buf[11] >> 16) & 0xffff)) / 65536.0f); - - buffer+=sprintf(buffer, "Tri_TexShadeZ %d, XL: %s, XM: %s, XH: %s, YL: %s, YM: %s, YH: %s\n", lft, xl,xm,xh,yl,ym,yh); - buffer+=sprintf(buffer, " "); - buffer+=sprintf(buffer, " R: %s, G: %s, B: %s, A: %s\n", rt, gt, bt, at); - buffer+=sprintf(buffer, " "); - buffer+=sprintf(buffer, " DRDX: %s, DGDX: %s, DBDX: %s, DADX: %s\n", drdx, dgdx, dbdx, dadx); - buffer+=sprintf(buffer, " "); - buffer+=sprintf(buffer, " DRDE: %s, DGDE: %s, DBDE: %s, DADE: %s\n", drde, dgde, dbde, dade); - buffer+=sprintf(buffer, " "); - buffer+=sprintf(buffer, " DRDY: %s, DGDY: %s, DBDY: %s, DADY: %s\n", drdy, dgdy, dbdy, dady); - - buffer+=sprintf(buffer, " "); - buffer+=sprintf(buffer, " S: %s, T: %s, W: %s\n", s, t, w); - buffer+=sprintf(buffer, " "); - buffer+=sprintf(buffer, " DSDX: %s, DTDX: %s, DWDX: %s\n", dsdx, dtdx, dwdx); - buffer+=sprintf(buffer, " "); - buffer+=sprintf(buffer, " DSDE: %s, DTDE: %s, DWDE: %s\n", dsde, dtde, dwde); - buffer+=sprintf(buffer, " "); - buffer+=sprintf(buffer, " DSDY: %s, DTDY: %s, DWDY: %s\n", dsdy, dtdy, dwdy); + snprintf(yl, std::size(yl), "%4.4f", (float)((cmd_buf[0] >> 32) & 0x1fff) / 4.0f); + snprintf(ym, std::size(ym), "%4.4f", (float)((cmd_buf[0] >> 16) & 0x1fff) / 4.0f); + snprintf(yh, std::size(yh), "%4.4f", (float)((cmd_buf[0] >> 0) & 0x1fff) / 4.0f); + snprintf(xl, std::size(xl), "%4.4f", (float)int32_t(cmd_buf[1] >> 32) / 65536.0f); + snprintf(dxldy, std::size(dxldy), "%4.4f", (float)int32_t(cmd_buf[1]) / 65536.0f); + snprintf(xh, std::size(xh), "%4.4f", (float)int32_t(cmd_buf[2] >> 32) / 65536.0f); + snprintf(dxhdy, std::size(dxhdy), "%4.4f", (float)int32_t(cmd_buf[2]) / 65536.0f); + snprintf(xm, std::size(xm), "%4.4f", (float)int32_t(cmd_buf[3] >> 32) / 65536.0f); + snprintf(dxmdy, std::size(dxmdy), "%4.4f", (float)int32_t(cmd_buf[3]) / 65536.0f); + + snprintf(rt, std::size(rt), "%4.4f", (float)int32_t( ((cmd_buf[4] >> 32) & 0xffff0000) | ((cmd_buf[ 6] >> 48) & 0xffff)) / 65536.0f); + snprintf(gt, std::size(gt), "%4.4f", (float)int32_t((((cmd_buf[4] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[ 6] >> 32) & 0xffff)) / 65536.0f); + snprintf(bt, std::size(bt), "%4.4f", (float)int32_t( (cmd_buf[4] & 0xffff0000) | ((cmd_buf[ 6] >> 16) & 0xffff)) / 65536.0f); + snprintf(at, std::size(at), "%4.4f", (float)int32_t( ((cmd_buf[4] & 0x0000ffff) << 16) | ( cmd_buf[ 6] & 0xffff)) / 65536.0f); + snprintf(drdx, std::size(drdx), "%4.4f", (float)int32_t( ((cmd_buf[5] >> 32) & 0xffff0000) | ((cmd_buf[ 7] >> 48) & 0xffff)) / 65536.0f); + snprintf(dgdx, std::size(dgdx), "%4.4f", (float)int32_t((((cmd_buf[5] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[ 7] >> 32) & 0xffff)) / 65536.0f); + snprintf(dbdx, std::size(dbdx), "%4.4f", (float)int32_t( (cmd_buf[5] & 0xffff0000) | ((cmd_buf[ 7] >> 16) & 0xffff)) / 65536.0f); + snprintf(dadx, std::size(dadx), "%4.4f", (float)int32_t( ((cmd_buf[5] & 0x0000ffff) << 16) | ( cmd_buf[ 7] & 0xffff)) / 65536.0f); + snprintf(drde, std::size(drde), "%4.4f", (float)int32_t( ((cmd_buf[8] >> 32) & 0xffff0000) | ((cmd_buf[10] >> 48) & 0xffff)) / 65536.0f); + snprintf(dgde, std::size(dgde), "%4.4f", (float)int32_t((((cmd_buf[8] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[10] >> 32) & 0xffff)) / 65536.0f); + snprintf(dbde, std::size(dbde), "%4.4f", (float)int32_t( (cmd_buf[8] & 0xffff0000) | ((cmd_buf[10] >> 16) & 0xffff)) / 65536.0f); + snprintf(dade, std::size(dade), "%4.4f", (float)int32_t( ((cmd_buf[8] & 0x0000ffff) << 16) | ( cmd_buf[10] & 0xffff)) / 65536.0f); + snprintf(drdy, std::size(drdy), "%4.4f", (float)int32_t( ((cmd_buf[9] >> 32) & 0xffff0000) | ((cmd_buf[11] >> 48) & 0xffff)) / 65536.0f); + snprintf(dgdy, std::size(dgdy), "%4.4f", (float)int32_t((((cmd_buf[9] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[11] >> 32) & 0xffff)) / 65536.0f); + snprintf(dbdy, std::size(dbdy), "%4.4f", (float)int32_t( (cmd_buf[9] & 0xffff0000) | ((cmd_buf[11] >> 16) & 0xffff)) / 65536.0f); + snprintf(dady, std::size(dady), "%4.4f", (float)int32_t( ((cmd_buf[9] & 0x0000ffff) << 16) | ( cmd_buf[11] & 0xffff)) / 65536.0f); + + snprintf(s, std::size(s), "%4.4f", (float)int32_t( ((cmd_buf[4] >> 32) & 0xffff0000) | ((cmd_buf[ 6] >> 48) & 0xffff)) / 65536.0f); + snprintf(t, std::size(t), "%4.4f", (float)int32_t((((cmd_buf[4] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[ 6] >> 32) & 0xffff)) / 65536.0f); + snprintf(w, std::size(w), "%4.4f", (float)int32_t( (cmd_buf[4] & 0xffff0000) | ((cmd_buf[ 6] >> 16) & 0xffff)) / 65536.0f); + snprintf(dsdx, std::size(dsdx), "%4.4f", (float)int32_t( ((cmd_buf[5] >> 32) & 0xffff0000) | ((cmd_buf[ 7] >> 48) & 0xffff)) / 65536.0f); + snprintf(dtdx, std::size(dtdx), "%4.4f", (float)int32_t((((cmd_buf[5] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[ 7] >> 32) & 0xffff)) / 65536.0f); + snprintf(dwdx, std::size(dwdx), "%4.4f", (float)int32_t( (cmd_buf[5] & 0xffff0000) | ((cmd_buf[ 7] >> 16) & 0xffff)) / 65536.0f); + snprintf(dsde, std::size(dsde), "%4.4f", (float)int32_t( ((cmd_buf[8] >> 32) & 0xffff0000) | ((cmd_buf[10] >> 48) & 0xffff)) / 65536.0f); + snprintf(dtde, std::size(dtde), "%4.4f", (float)int32_t((((cmd_buf[8] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[10] >> 32) & 0xffff)) / 65536.0f); + snprintf(dwde, std::size(dwde), "%4.4f", (float)int32_t( (cmd_buf[8] & 0xffff0000) | ((cmd_buf[10] >> 16) & 0xffff)) / 65536.0f); + snprintf(dsdy, std::size(dsdy), "%4.4f", (float)int32_t( ((cmd_buf[9] >> 32) & 0xffff0000) | ((cmd_buf[11] >> 48) & 0xffff)) / 65536.0f); + snprintf(dtdy, std::size(dtdy), "%4.4f", (float)int32_t((((cmd_buf[9] >> 32) & 0x0000ffff) << 16) | ((cmd_buf[11] >> 32) & 0xffff)) / 65536.0f); + snprintf(dwdy, std::size(dwdy), "%4.4f", (float)int32_t( (cmd_buf[9] & 0xffff0000) | ((cmd_buf[11] >> 16) & 0xffff)) / 65536.0f); + + util::stream_format(buffer, "Tri_TexShadeZ %d, XL: %s, XM: %s, XH: %s, YL: %s, YM: %s, YH: %s\n", lft, xl,xm,xh,yl,ym,yh); + buffer << " "; + util::stream_format(buffer, " R: %s, G: %s, B: %s, A: %s\n", rt, gt, bt, at); + buffer << " "; + util::stream_format(buffer, " DRDX: %s, DGDX: %s, DBDX: %s, DADX: %s\n", drdx, dgdx, dbdx, dadx); + buffer << " "; + util::stream_format(buffer, " DRDE: %s, DGDE: %s, DBDE: %s, DADE: %s\n", drde, dgde, dbde, dade); + buffer << " "; + util::stream_format(buffer, " DRDY: %s, DGDY: %s, DBDY: %s, DADY: %s\n", drdy, dgdy, dbdy, dady); + + buffer << " "; + util::stream_format(buffer, " S: %s, T: %s, W: %s\n", s, t, w); + buffer << " "; + util::stream_format(buffer, " DSDX: %s, DTDX: %s, DWDX: %s\n", dsdx, dtdx, dwdx); + buffer << " "; + util::stream_format(buffer, " DSDE: %s, DTDE: %s, DWDE: %s\n", dsde, dtde, dwde); + buffer << " "; + util::stream_format(buffer, " DSDY: %s, DTDY: %s, DWDY: %s\n", dsdy, dtdy, dwdy); break; } case 0x24: case 0x25: { - sprintf(s, "%4.4f", (float)int16_t((cmd_buf[1] >> 48) & 0xffff) / 32.0f); - sprintf(t, "%4.4f", (float)int16_t((cmd_buf[1] >> 32) & 0xffff) / 32.0f); - sprintf(dsdx, "%4.4f", (float)int16_t((cmd_buf[1] >> 16) & 0xffff) / 1024.0f); - sprintf(dtdy, "%4.4f", (float)int16_t((cmd_buf[1] >> 0) & 0xffff) / 1024.0f); + snprintf(s, std::size(s), "%4.4f", (float)int16_t((cmd_buf[1] >> 48) & 0xffff) / 32.0f); + snprintf(t, std::size(t), "%4.4f", (float)int16_t((cmd_buf[1] >> 32) & 0xffff) / 32.0f); + snprintf(dsdx, std::size(dsdx), "%4.4f", (float)int16_t((cmd_buf[1] >> 16) & 0xffff) / 1024.0f); + snprintf(dtdy, std::size(dtdy), "%4.4f", (float)int16_t((cmd_buf[1] >> 0) & 0xffff) / 1024.0f); if (command == 0x24) - sprintf(buffer, "Texture_Rectangle %d, %s, %s, %s, %s, %s, %s, %s, %s", tile, sh, th, sl, tl, s, t, dsdx, dtdy); + util::stream_format(buffer, "Texture_Rectangle %d, %s, %s, %s, %s, %s, %s, %s, %s", tile, sh, th, sl, tl, s, t, dsdx, dtdy); else - sprintf(buffer, "Texture_Rectangle_Flip %d, %s, %s, %s, %s, %s, %s, %s, %s", tile, sh, th, sl, tl, s, t, dsdx, dtdy); + util::stream_format(buffer, "Texture_Rectangle_Flip %d, %s, %s, %s, %s, %s, %s, %s, %s", tile, sh, th, sl, tl, s, t, dsdx, dtdy); break; } - case 0x26: sprintf(buffer, "Sync_Load"); break; - case 0x27: sprintf(buffer, "Sync_Pipe"); break; - case 0x28: sprintf(buffer, "Sync_Tile"); break; - case 0x29: sprintf(buffer, "Sync_Full"); break; - case 0x2d: sprintf(buffer, "Set_Scissor %s, %s, %s, %s", sl, tl, sh, th); break; - case 0x2e: sprintf(buffer, "Set_Prim_Depth %04X, %04X", uint32_t(cmd_buf[0] >> 16) & 0xffff, (uint32_t)cmd_buf[0] & 0xffff); break; - case 0x2f: sprintf(buffer, "Set_Other_Modes %08X %08X", uint32_t(cmd_buf[0] >> 32), (uint32_t)cmd_buf[0]); break; - case 0x30: sprintf(buffer, "Load_TLUT %d, %s, %s, %s, %s", tile, sl, tl, sh, th); break; - case 0x32: sprintf(buffer, "Set_Tile_Size %d, %s, %s, %s, %s", tile, sl, tl, sh, th); break; - case 0x33: sprintf(buffer, "Load_Block %d, %03X, %03X, %03X, %03X", tile, uint32_t(cmd_buf[0] >> 44) & 0xfff, uint32_t(cmd_buf[0] >> 32) & 0xfff, uint32_t(cmd_buf[0] >> 12) & 0xfff, uint32_t(cmd_buf[0]) & 0xfff); break; - case 0x34: sprintf(buffer, "Load_Tile %d, %s, %s, %s, %s", tile, sl, tl, sh, th); break; - case 0x35: sprintf(buffer, "Set_Tile %d, %s, %s, %d, %04X", tile, format, size, (uint32_t(cmd_buf[0] >> 41) & 0x1ff) * 8, (uint32_t(cmd_buf[0] >> 32) & 0x1ff) * 8); break; - case 0x36: sprintf(buffer, "Fill_Rectangle %s, %s, %s, %s", sh, th, sl, tl); break; - case 0x37: sprintf(buffer, "Set_Fill_Color R: %d, G: %d, B: %d, A: %d", r, g, b, a); break; - case 0x38: sprintf(buffer, "Set_Fog_Color R: %d, G: %d, B: %d, A: %d", r, g, b, a); break; - case 0x39: sprintf(buffer, "Set_Blend_Color R: %d, G: %d, B: %d, A: %d", r, g, b, a); break; - case 0x3a: sprintf(buffer, "Set_Prim_Color %d, %d, R: %d, G: %d, B: %d, A: %d", uint32_t(cmd_buf[0] >> 40) & 0x1f, uint32_t(cmd_buf[0] >> 32) & 0xff, r, g, b, a); break; - case 0x3b: sprintf(buffer, "Set_Env_Color R: %d, G: %d, B: %d, A: %d", r, g, b, a); break; - case 0x3c: sprintf(buffer, "Set_Combine %08X %08X", uint32_t(cmd_buf[0] >> 32), (uint32_t)cmd_buf[0]); break; - case 0x3d: sprintf(buffer, "Set_Texture_Image %s, %s, %d, %08X", format, size, (uint32_t(cmd_buf[0] >> 32) & 0x1ff) + 1, (uint32_t)cmd_buf[0]); break; - case 0x3e: sprintf(buffer, "Set_Mask_Image %08X", (uint32_t)cmd_buf[0]); break; - case 0x3f: sprintf(buffer, "Set_Color_Image %s, %s, %d, %08X", format, size, (uint32_t(cmd_buf[0] >> 32) & 0x1ff) + 1, (uint32_t)cmd_buf[0]); break; - default: sprintf(buffer, "Unknown (%08X %08X)", uint32_t(cmd_buf[0] >> 32), (uint32_t)cmd_buf[0]); break; + case 0x26: buffer << "Sync_Load"; break; + case 0x27: buffer << "Sync_Pipe"; break; + case 0x28: buffer << "Sync_Tile"; break; + case 0x29: buffer << "Sync_Full"; break; + case 0x2d: util::stream_format(buffer, "Set_Scissor %s, %s, %s, %s", sl, tl, sh, th); break; + case 0x2e: util::stream_format(buffer, "Set_Prim_Depth %04X, %04X", uint32_t(cmd_buf[0] >> 16) & 0xffff, (uint32_t)cmd_buf[0] & 0xffff); break; + case 0x2f: util::stream_format(buffer, "Set_Other_Modes %08X %08X", uint32_t(cmd_buf[0] >> 32), (uint32_t)cmd_buf[0]); break; + case 0x30: util::stream_format(buffer, "Load_TLUT %d, %s, %s, %s, %s", tile, sl, tl, sh, th); break; + case 0x32: util::stream_format(buffer, "Set_Tile_Size %d, %s, %s, %s, %s", tile, sl, tl, sh, th); break; + case 0x33: util::stream_format(buffer, "Load_Block %d, %03X, %03X, %03X, %03X", tile, uint32_t(cmd_buf[0] >> 44) & 0xfff, uint32_t(cmd_buf[0] >> 32) & 0xfff, uint32_t(cmd_buf[0] >> 12) & 0xfff, uint32_t(cmd_buf[0]) & 0xfff); break; + case 0x34: util::stream_format(buffer, "Load_Tile %d, %s, %s, %s, %s", tile, sl, tl, sh, th); break; + case 0x35: util::stream_format(buffer, "Set_Tile %d, %s, %s, %d, %04X", tile, format, size, (uint32_t(cmd_buf[0] >> 41) & 0x1ff) * 8, (uint32_t(cmd_buf[0] >> 32) & 0x1ff) * 8); break; + case 0x36: util::stream_format(buffer, "Fill_Rectangle %s, %s, %s, %s", sh, th, sl, tl); break; + case 0x37: util::stream_format(buffer, "Set_Fill_Color R: %d, G: %d, B: %d, A: %d", r, g, b, a); break; + case 0x38: util::stream_format(buffer, "Set_Fog_Color R: %d, G: %d, B: %d, A: %d", r, g, b, a); break; + case 0x39: util::stream_format(buffer, "Set_Blend_Color R: %d, G: %d, B: %d, A: %d", r, g, b, a); break; + case 0x3a: util::stream_format(buffer, "Set_Prim_Color %d, %d, R: %d, G: %d, B: %d, A: %d", uint32_t(cmd_buf[0] >> 40) & 0x1f, uint32_t(cmd_buf[0] >> 32) & 0xff, r, g, b, a); break; + case 0x3b: util::stream_format(buffer, "Set_Env_Color R: %d, G: %d, B: %d, A: %d", r, g, b, a); break; + case 0x3c: util::stream_format(buffer, "Set_Combine %08X %08X", uint32_t(cmd_buf[0] >> 32), (uint32_t)cmd_buf[0]); break; + case 0x3d: util::stream_format(buffer, "Set_Texture_Image %s, %s, %d, %08X", format, size, (uint32_t(cmd_buf[0] >> 32) & 0x1ff) + 1, (uint32_t)cmd_buf[0]); break; + case 0x3e: util::stream_format(buffer, "Set_Mask_Image %08X", (uint32_t)cmd_buf[0]); break; + case 0x3f: util::stream_format(buffer, "Set_Color_Image %s, %s, %d, %08X", format, size, (uint32_t(cmd_buf[0] >> 32) & 0x1ff) + 1, (uint32_t)cmd_buf[0]); break; + default: util::stream_format(buffer, "Unknown (%08X %08X)", uint32_t(cmd_buf[0] >> 32), (uint32_t)cmd_buf[0]); break; } + + return std::move(buffer).str(); } /*****************************************************************************/ @@ -3102,10 +3106,9 @@ void n64_rdp::process_command_list() if (LOG_RDP_EXECUTION) { - char string[4000]; - disassemble(curr_cmd_buf, string); + auto disassembly = disassemble(curr_cmd_buf); - fprintf(rdp_exec, "%08X: %08X%08X %s\n", start, (uint32_t)(curr_cmd_buf[0] >> 32), (uint32_t)curr_cmd_buf[0], string); + fprintf(rdp_exec, "%08X: %08X%08X %s\n", start, (uint32_t)(curr_cmd_buf[0] >> 32), (uint32_t)curr_cmd_buf[0], disassembly.c_str()); fflush(rdp_exec); } diff --git a/src/mame/nintendo/n64_v.h b/src/mame/nintendo/n64_v.h index ffcb1529cd1..5ae6ab57246 100644 --- a/src/mame/nintendo/n64_v.h +++ b/src/mame/nintendo/n64_v.h @@ -163,7 +163,7 @@ public: void process_command_list(); uint64_t read_data(uint32_t address); - void disassemble(uint64_t *cmd_buf, char* buffer); + std::string disassemble(uint64_t *cmd_buf); void set_machine(running_machine& machine) { m_machine = &machine; } void set_n64_periphs(n64_periphs* periphs) { m_n64_periphs = periphs; } diff --git a/src/mame/snk/hng64_a.cpp b/src/mame/snk/hng64_a.cpp index 31e161d9f56..60455f8b391 100644 --- a/src/mame/snk/hng64_a.cpp +++ b/src/mame/snk/hng64_a.cpp @@ -89,10 +89,8 @@ 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"); - FILE *fp; - char filename[256]; - sprintf(filename,"soundram_%s", machine().system().name); - fp=fopen(filename, "w+b"); + auto filename = std::string{"soundram_"} + machine().system().name; + auto fp = fopen(filename.c_str(), "w+b"); if (fp) { fwrite((uint8_t*)m_soundram.get(), 0x80000*4, 1, fp); diff --git a/src/mame/subsino/subsino_m.cpp b/src/mame/subsino/subsino_m.cpp index 03ccfc51c9a..aefa4b0adcc 100644 --- a/src/mame/subsino/subsino_m.cpp +++ b/src/mame/subsino/subsino_m.cpp @@ -84,10 +84,8 @@ void victor21_bitswaps(uint8_t *decrypt, int i) #if 0 void dump_decrypted(running_machine& machine, uint8_t* decrypt) { - FILE *fp; - char filename[256]; - sprintf(filename,"dat_%s", machine.system().name); - fp=fopen(filename, "w+b"); + auto filename = std::string{ "dat_" } + machine.system().name; + auto fp = fopen(filename.c_str(), "w+b"); if (fp) { fwrite(decrypt, 0x10000, 1, fp); diff --git a/src/mame/taito/tnzs.cpp b/src/mame/taito/tnzs.cpp index bc9cce2c02f..326f7bc1d7b 100644 --- a/src/mame/taito/tnzs.cpp +++ b/src/mame/taito/tnzs.cpp @@ -673,6 +673,9 @@ d23f=input port 1 value #include "screen.h" #include "speaker.h" +//#define VERBOSE 1 +#include "logmacro.h" + SAMPLES_START_CB_MEMBER(kageki_state::init_samples) { @@ -737,8 +740,6 @@ uint8_t kageki_state::csport_r() void kageki_state::csport_w(uint8_t data) { - char mess[80]; - if (data > 0x3f) { // read dipsw port @@ -750,15 +751,14 @@ void kageki_state::csport_w(uint8_t data) { // play samples m_samples->start_raw(0, m_sampledata[data].get(), m_samplesize[data], 7000); - sprintf(mess, "VOICE:%02X PLAY", data); + LOG("VOICE:%02X PLAY", data); } else { // stop samples m_samples->stop(0); - sprintf(mess, "VOICE:%02X STOP", data); + LOG("VOICE:%02X STOP", data); } - // popmessage(mess); } } diff --git a/src/mame/taito/undrfire_v.cpp b/src/mame/taito/undrfire_v.cpp index 7b273938705..a09c8027c0e 100644 --- a/src/mame/taito/undrfire_v.cpp +++ b/src/mame/taito/undrfire_v.cpp @@ -452,12 +452,9 @@ u32 undrfire_state::screen_update_undrfire(screen_device &screen, bitmap_ind16 & /* Enable this to see rotation (?) control words */ #if 0 { - char buf[80]; - int i; - - for (i = 0; i < 8; i += 1) + for (auto i = 0; i < 8; i += 1) { - sprintf (buf, "%02x: %04x", i, m_rotate_ctrl[i]); + auto buf = util::string_format("%02x: %04x", i, m_rotate_ctrl[i]); ui_draw_text (buf, 0, i*8); } } @@ -607,12 +604,9 @@ u32 undrfire_state::screen_update_cbombers(screen_device &screen, bitmap_ind16 & /* Enable this to see rotation (?) control words */ #if 0 { - char buf[80]; - int i; - - for (i = 0; i < 8; i += 1) + for (auto i = 0; i < 8; i += 1) { - sprintf (buf, "%02x: %04x", i, m_rotate_ctrl[i]); + auto buf = util::string_format("%02x: %04x", i, m_rotate_ctrl[i]); ui_draw_text (buf, 0, i*8); } } diff --git a/src/osd/modules/netdev/pcap.cpp b/src/osd/modules/netdev/pcap.cpp index e8e0559e9bf..bf54f450ac8 100644 --- a/src/osd/modules/netdev/pcap.cpp +++ b/src/osd/modules/netdev/pcap.cpp @@ -189,15 +189,14 @@ netdev_pcap::netdev_pcap(const char *name, class device_network_interface *ifdev void netdev_pcap::set_mac(const char *mac) { - char filter[256]; struct bpf_program fp; if(!m_p) return; #ifdef SDLMAME_MACOSX - sprintf(filter, "not ether src %.2X:%.2X:%.2X:%.2X:%.2X:%.2X and (ether dst %.2X:%.2X:%.2X:%.2X:%.2X:%.2X or ether multicast or ether broadcast or ether dst 09:00:07:ff:ff:ff)", (unsigned char)mac[0], (unsigned char)mac[1], (unsigned char)mac[2],(unsigned char)mac[3], (unsigned char)mac[4], (unsigned char)mac[5], (unsigned char)mac[0], (unsigned char)mac[1], (unsigned char)mac[2],(unsigned char)mac[3], (unsigned char)mac[4], (unsigned char)mac[5]); + auto filter = util::string_format("not ether src %02X:%02X:%02X:%02X:%02X:%02X and (ether dst %02X:%02X:%02X:%02X:%02X:%02X or ether multicast or ether broadcast or ether dst 09:00:07:ff:ff:ff)", (unsigned char)mac[0], (unsigned char)mac[1], (unsigned char)mac[2],(unsigned char)mac[3], (unsigned char)mac[4], (unsigned char)mac[5], (unsigned char)mac[0], (unsigned char)mac[1], (unsigned char)mac[2],(unsigned char)mac[3], (unsigned char)mac[4], (unsigned char)mac[5]); #else - sprintf(filter, "ether dst %.2X:%.2X:%.2X:%.2X:%.2X:%.2X or ether multicast or ether broadcast", (unsigned char)mac[0], (unsigned char)mac[1], (unsigned char)mac[2],(unsigned char)mac[3], (unsigned char)mac[4], (unsigned char)mac[5]); + auto filter = util::string_format("ether dst %02X:%02X:%02X:%02X:%02X:%02X or ether multicast or ether broadcast", (unsigned char)mac[0], (unsigned char)mac[1], (unsigned char)mac[2],(unsigned char)mac[3], (unsigned char)mac[4], (unsigned char)mac[5]); #endif - if ((*module->pcap_compile_dl)(m_p, &fp, filter, 1, 0) == -1) { + if ((*module->pcap_compile_dl)(m_p, &fp, filter.c_str(), 1, 0) == -1) { osd_printf_error("Error with pcap_compile\n"); } if ((*module->pcap_setfilter_dl)(m_p, &fp) == -1) { diff --git a/src/tools/chdman.cpp b/src/tools/chdman.cpp index c414c05f5f5..bbbc81d4526 100644 --- a/src/tools/chdman.cpp +++ b/src/tools/chdman.cpp @@ -2429,8 +2429,7 @@ static void do_extract_cd(parameters_map ¶ms) int chop = default_name.find_last_of('.'); if (chop != -1) default_name.erase(chop, default_name.size()); - char basename[128]; - strncpy(basename, default_name.c_str(), 127); + std::string basename = default_name; default_name.append(".bin"); std::string *output_bin_file_str; if (output_bin_file_fnd == params.end()) @@ -2527,17 +2526,15 @@ static void do_extract_cd(parameters_map ¶ms) std::vector buffer; for (int tracknum = 0; tracknum < toc.numtrks; tracknum++) { - std::string trackbin_name(basename); + std::string trackbin_name = basename; if (mode == MODE_GDI) { - char temp[11]; - sprintf(temp, "%02d", tracknum+1); - trackbin_name.append(temp); + trackbin_name += util::string_format("%02d", tracknum+1); if (toc.tracks[tracknum].trktype == cdrom_file::CD_TRACK_AUDIO) - trackbin_name.append(".raw"); + trackbin_name += ".raw"; else - trackbin_name.append(".bin"); + trackbin_name += ".bin"; output_bin_file.reset(); diff --git a/src/tools/image_handler.cpp b/src/tools/image_handler.cpp index a2083bcbd59..9e88c501a95 100644 --- a/src/tools/image_handler.cpp +++ b/src/tools/image_handler.cpp @@ -266,9 +266,9 @@ bool image_handler::floppy_load(const floppy_format_info *format) bool image_handler::floppy_save(const floppy_format_info *format) { std::vector variants; - std::string msg = util::string_format("Error opening %s for writing", m_on_disk_path); FILE *f = fopen(m_on_disk_path.c_str(), "wb"); if (!f) { + auto msg = util::string_format("Error opening %s for writing", m_on_disk_path); perror(msg.c_str()); return true; } diff --git a/src/tools/imgtool/modules/psion.cpp b/src/tools/imgtool/modules/psion.cpp index 007650084b6..ec556bd1cff 100644 --- a/src/tools/imgtool/modules/psion.cpp +++ b/src/tools/imgtool/modules/psion.cpp @@ -488,7 +488,7 @@ static imgtoolerr_t datapack_next_enum(imgtool::directory &enumeration, imgtool_ return IMGTOOLERR_SUCCESS; } memcpy(ent.filename, pack->pack_index[iter->index].filename, 8); - sprintf(ent.attr, "Type: %02x ID: %02x", pack->pack_index[iter->index].type, pack->pack_index[iter->index].id); + snprintf(ent.attr, std::size(ent.attr), "Type: %02x ID: %02x", pack->pack_index[iter->index].type, pack->pack_index[iter->index].id); if (pack->pack_index[iter->index].data_rec) { diff --git a/src/tools/imgtool/modules/thomson.cpp b/src/tools/imgtool/modules/thomson.cpp index be584bde240..d5281542c60 100644 --- a/src/tools/imgtool/modules/thomson.cpp +++ b/src/tools/imgtool/modules/thomson.cpp @@ -595,14 +595,14 @@ static int thom_find_dirent(thom_floppy* f, unsigned head, { int n = 0; while ( 1 ) { - thom_get_dirent( f, head, n, d ); - if ( d->type == THOM_DIRENT_END ) return 0; - if ( d->type == THOM_DIRENT_FILE ) { - char buf[13]; - sprintf( buf, "%s.%s", d->name, d->ext ); - if ( ! strcmp( buf, name ) ) return 1; - } - n++; + thom_get_dirent( f, head, n, d ); + if ( d->type == THOM_DIRENT_END ) return 0; + if ( d->type == THOM_DIRENT_FILE ) { + char buf[13]; + snprintf( buf, std::size(buf), "%s.%s", d->name, d->ext ); + if ( ! strcmp( buf, name ) ) return 1; + } + n++; } } @@ -957,7 +957,7 @@ static imgtoolerr_t thom_read_file(imgtool::partition &part, /* convert filename */ thom_conv_filename( filename, name, ext ); - sprintf( fname, "%s.%s", name, ext ); + snprintf( fname, std::size(fname), "%s.%s", name, ext ); if ( ! thom_find_dirent( f, head, fname, &d ) ) return IMGTOOLERR_FILENOTFOUND; @@ -978,7 +978,7 @@ static imgtoolerr_t thom_delete_file(imgtool::partition &part, /* convert filename */ thom_conv_filename( filename, name, ext ); - sprintf( fname, "%s.%s", name, ext ); + snprintf( fname, std::size(fname), "%s.%s", name, ext ); if ( ! thom_find_dirent( f, head, fname, &d ) ) return IMGTOOLERR_FILENOTFOUND; @@ -1007,7 +1007,7 @@ static imgtoolerr_t thom_write_file(imgtool::partition &part, /* convert filename */ thom_conv_filename( filename, name, ext ); - sprintf( fname, "%s.%s", name, ext ); + snprintf( fname, std::size(fname), "%s.%s", name, ext ); /* check available space & find dir entry */ if ( thom_find_dirent( f, head, fname, &d ) ) { -- cgit v1.2.3