From 55d920bf00e19649206fb5ec0d7b9b336a728b61 Mon Sep 17 00:00:00 2001 From: Kostas Missos Date: Fri, 1 Jun 2018 18:40:24 +0300 Subject: [PATCH] [GFX] Fix hedump print last 1-16 bytes --- ipl/gfx.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/ipl/gfx.c b/ipl/gfx.c index 9525b7a..ea98658 100755 --- a/ipl/gfx.c +++ b/ipl/gfx.c @@ -265,7 +265,7 @@ void gfx_hexdump(gfx_con_t *con, u32 base, const u8 *buf, u32 len) for(u32 j = 0; j < 0x10; j++) { u8 c = buf[i - 0x10 + j]; - if(c >= 32 && c < 128) + if(c >= 32 && c <= 126) gfx_putc(con, c); else gfx_putc(con, '.'); @@ -275,6 +275,27 @@ void gfx_hexdump(gfx_con_t *con, u32 base, const u8 *buf, u32 len) gfx_printf(con, "%08x: ", base + i); } gfx_printf(con, "%02x ", buf[i]); + if (i == len - 1) + { + int ln = len % 0x10 != 0; + u32 k = 0x10 - 1; + if (ln) + { + k = len & 0xF - 1; + for (u32 j = 0; j < 0x10 - k; j++) + gfx_puts(con, " "); + } + gfx_puts(con, "| "); + for(u32 j = 0; j < (ln ? k : k + 1); j++) + { + u8 c = buf[i - k + j]; + if(c >= 32 && c <= 126) + gfx_putc(con, c); + else + gfx_putc(con, '.'); + } + gfx_putc(con, '\n'); + } } gfx_putc(con, '\n'); }