|
|
|
@ -59,6 +59,12 @@ inline void hex02(std::uint8_t byte, char buffer[2])
|
|
|
|
|
buffer[1] =hex_map[byte][1];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<std::size_t N>
|
|
|
|
|
inline __attribute((always_inline)) void print_exact(const char* ar)
|
|
|
|
|
{
|
|
|
|
|
fwrite(ar, 1, N, stdout);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<std::size_t N>
|
|
|
|
|
inline __attribute__((always_inline)) void print_exact(const char (&ar)[N])
|
|
|
|
|
{
|
|
|
|
@ -69,10 +75,12 @@ namespace hv {
|
|
|
|
|
void print_screen(const span<unsigned char> memory, unsigned long offset)
|
|
|
|
|
{
|
|
|
|
|
#ifndef FIXED_ROW_SIZE
|
|
|
|
|
#define S (const char*)
|
|
|
|
|
#define S (2+ROW_SZ)
|
|
|
|
|
#define P_EX(n, buf) fwrite(buf, 1, n, stdout)
|
|
|
|
|
int ROW_SZ = 24;
|
|
|
|
|
#else
|
|
|
|
|
#define S
|
|
|
|
|
#define P_EX(n, buf) print_exact(buf)
|
|
|
|
|
#endif
|
|
|
|
|
fmt::print("0x{:016x} ", offset);
|
|
|
|
|
char hxbuf[3];
|
|
|
|
@ -85,7 +93,7 @@ namespace hv {
|
|
|
|
|
hxbuf[2] = ' ';
|
|
|
|
|
for(;i<memory.size();i++) {
|
|
|
|
|
if (i && i % ROW_SZ == 0) { //TODO: Change to i +=16 so we don't have to branch here on every byte. Make sure to not overrun buffer tho
|
|
|
|
|
print_exact(r_ascii);
|
|
|
|
|
P_EX(S, r_ascii);
|
|
|
|
|
fmt::print("\n0x{:016x} ", i+offset); //TODO: Implement this manually then write the buffer with `print_exact`
|
|
|
|
|
}
|
|
|
|
|
unsigned char idx = memory[i];
|
|
|
|
@ -101,10 +109,10 @@ namespace hv {
|
|
|
|
|
for(std::size_t j=0;j< ROW_SZ - rest;j++)
|
|
|
|
|
print_exact(output);
|
|
|
|
|
|
|
|
|
|
prints(r_ascii);
|
|
|
|
|
prints((const char*) r_ascii);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
print_exact(r_ascii);
|
|
|
|
|
P_EX(S, r_ascii);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|