From f09c77689df6fe97399f9883d10ac26a0fc57f61 Mon Sep 17 00:00:00 2001 From: Raphael Assenat Date: Sun, 1 Nov 2015 14:11:38 -0500 Subject: [PATCH] Add a mempak hexdump function --- tool/mempak.c | 21 +++++++++++++++++++++ tool/mempak.h | 4 +++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/tool/mempak.c b/tool/mempak.c index be3a015..74995cb 100644 --- a/tool/mempak.c +++ b/tool/mempak.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include "mempak.h" @@ -433,3 +434,23 @@ int mempak_getFilenameFormat(const char *filename) return MPK_FORMAT_INVALID; } +int mempak_hexdump(mempak_structure_t *pak) +{ + int i,j; + + for (i=0; idata[i+j]); + } + printf(" "); + + for (j=0; j<0x20; j++) { + printf("%c", isprint(pak->data[i+j]) ? pak->data[i+j] : '.' ); + } + printf("\n"); + } + + return 0; +} + diff --git a/tool/mempak.h b/tool/mempak.h index ced0d55..a2cef26 100644 --- a/tool/mempak.h +++ b/tool/mempak.h @@ -1,6 +1,7 @@ #ifndef _mempak_h__ #define _mempak_h__ +#define MEMPAK_MEM_SIZE 0x8000 #define MEMPAK_NUM_NOTES 16 #define MAX_NOTE_COMMENT_SIZE 257 // including 0 termination @@ -12,7 +13,7 @@ typedef struct mempak_structure { - unsigned char data[0x8000]; + unsigned char data[MEMPAK_MEM_SIZE]; unsigned char file_format; char note_comments[MEMPAK_NUM_NOTES][MAX_NOTE_COMMENT_SIZE]; @@ -29,6 +30,7 @@ void mempak_free(mempak_structure_t *mpk); int mempak_getFilenameFormat(const char *filename); int mempak_string2format(const char *str); const char *mempak_format2string(int fmt); +int mempak_hexdump(mempak_structure_t *pak); #include "mempak_fs.h"