|
|
@ -53,12 +53,18 @@ inline __attribute__((always_inline)) void prints(const S&... strings)
|
|
|
|
(fputs((const char*)strings, stdout), ...);
|
|
|
|
(fputs((const char*)strings, stdout), ...);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline void hex02(std::uint8_t byte, char buffer[3])
|
|
|
|
inline void hex02(std::uint8_t byte, char buffer[2])
|
|
|
|
{
|
|
|
|
{
|
|
|
|
buffer[0] =hex_map[byte][0];
|
|
|
|
buffer[0] =hex_map[byte][0];
|
|
|
|
buffer[1] =hex_map[byte][1];
|
|
|
|
buffer[1] =hex_map[byte][1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<int N>
|
|
|
|
|
|
|
|
inline __attribute__((always_inline)) void print_exact(const char (&ar)[N])
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
fwrite(ar, N, 1, stdout);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
namespace hv {
|
|
|
|
namespace hv {
|
|
|
|
void print_screen(const span<unsigned char> memory, unsigned long offset)
|
|
|
|
void print_screen(const span<unsigned char> memory, unsigned long offset)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -71,28 +77,34 @@ namespace hv {
|
|
|
|
fmt::print("0x{:016x} ", offset);
|
|
|
|
fmt::print("0x{:016x} ", offset);
|
|
|
|
char hxbuf[3];
|
|
|
|
char hxbuf[3];
|
|
|
|
std::size_t i=0;
|
|
|
|
std::size_t i=0;
|
|
|
|
char ascii[1 + ROW_SZ];
|
|
|
|
char r_ascii[2 + ROW_SZ];
|
|
|
|
|
|
|
|
r_ascii[0] = ' ';
|
|
|
|
ascii[ROW_SZ] = 0;
|
|
|
|
r_ascii[1] = ' ';
|
|
|
|
hxbuf[2] = 0;
|
|
|
|
char* ascii = r_ascii + 2;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
hxbuf[2] = ' ';
|
|
|
|
for(;i<memory.size();i++) {
|
|
|
|
for(;i<memory.size();i++) {
|
|
|
|
if (i && i % ROW_SZ == 0) {
|
|
|
|
if (i && i % ROW_SZ == 0) {
|
|
|
|
prints(" ", S ascii);
|
|
|
|
print_exact(r_ascii);
|
|
|
|
fmt::print("\n0x{:016x} ", i+offset);
|
|
|
|
fmt::print("\n0x{:016x} ", i+offset);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
unsigned char idx = memory[i];
|
|
|
|
unsigned char idx = memory[i];
|
|
|
|
hex02(idx, hxbuf);
|
|
|
|
hex02(idx, hxbuf);
|
|
|
|
prints(hxbuf, " ");
|
|
|
|
print_exact(hxbuf);
|
|
|
|
ascii[i%ROW_SZ] = ascii_map[idx];
|
|
|
|
ascii[i%ROW_SZ] = ascii_map[idx];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (memory.size() % ROW_SZ != 0)
|
|
|
|
if (memory.size() % ROW_SZ != 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
auto rest = memory.size() % ROW_SZ;
|
|
|
|
auto rest = memory.size() % ROW_SZ;
|
|
|
|
ascii[rest] = 0;
|
|
|
|
ascii[rest] = 0;
|
|
|
|
|
|
|
|
constexpr const char output[3] = { ' ', ' ', ' ' };
|
|
|
|
for(std::size_t j=0;j< ROW_SZ - rest;j++)
|
|
|
|
for(std::size_t j=0;j< ROW_SZ - rest;j++)
|
|
|
|
prints(" ");
|
|
|
|
print_exact(output);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
prints(r_ascii);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
print_exact(r_ascii);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fmt::print(" {}", S ascii);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|