|
|
|
@ -20,26 +20,28 @@ const static constexpr char ascii_map[255] = {
|
|
|
|
|
'.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.',
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const constexpr int ROW_SZ = 24;
|
|
|
|
|
|
|
|
|
|
namespace hv {
|
|
|
|
|
void print_screen(const span<unsigned char> memory, unsigned long offset)
|
|
|
|
|
{
|
|
|
|
|
fmt::print("0x{:016x} ", offset);
|
|
|
|
|
char ascii[17];
|
|
|
|
|
ascii[16] = 0;
|
|
|
|
|
char ascii[1 + ROW_SZ];
|
|
|
|
|
ascii[ROW_SZ] = 0;
|
|
|
|
|
std::size_t i=0;
|
|
|
|
|
for(;i<memory.size();i++) {
|
|
|
|
|
if (i && i % 16 == 0) {
|
|
|
|
|
if (i && i % ROW_SZ == 0) {
|
|
|
|
|
fmt::print(" {}", ascii);
|
|
|
|
|
fmt::print("\n0x{:016x} ", i+offset);
|
|
|
|
|
}
|
|
|
|
|
fmt::print("{:02x} ", memory[i]);
|
|
|
|
|
ascii[i%16] = ascii_map[memory[i]];
|
|
|
|
|
ascii[i%ROW_SZ] = ascii_map[memory[i]];
|
|
|
|
|
}
|
|
|
|
|
if (memory.size() % 16 != 0)
|
|
|
|
|
if (memory.size() % ROW_SZ != 0)
|
|
|
|
|
{
|
|
|
|
|
auto rest = memory.size() % 16;
|
|
|
|
|
auto rest = memory.size() % ROW_SZ;
|
|
|
|
|
ascii[rest] = 0;
|
|
|
|
|
for(std::size_t j=0;j< 16 - rest;j++)
|
|
|
|
|
for(std::size_t j=0;j< ROW_SZ - rest;j++)
|
|
|
|
|
fmt::print(" ");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|