Files
fluxengine/lib/hexdump.cc
David Given cf9730fbb3 Splitting by hard sectors works, up to a point; we can correctly decode (with
CRC checking!) most of the Zilog MCS disk. However, we're still stumped by the
extra index hole.
2019-03-09 12:19:28 +01:00

42 lines
742 B
C++

#include "globals.h"
#include "bytes.h"
#include "fmt/format.h"
void hexdump(std::ostream& stream, const Bytes& buffer)
{
size_t pos = 0;
while (pos < buffer.size())
{
stream << fmt::format("{:05x} : ", pos);
for (int i=0; i<16; i++)
{
if ((pos+i) < buffer.size())
stream << fmt::format("{:02x} ", buffer[pos+i]);
else
stream << "-- ";
}
stream << " : ";
for (int i=0; i<16; i++)
{
if ((pos+i) >= buffer.size())
break;
uint8_t c = buffer[pos+i];
stream << (isprint(c) ? (char)c : '.');
}
stream << std::endl;
pos += 16;
}
}
void hexdumpForSrp16(std::ostream& stream, const Bytes& buffer)
{
for (uint8_t byte : buffer)
stream << fmt::format("{:02x}", byte);
stream << std::endl;
}