mirror of
https://github.com/raphnet/gc_n64_usb-v3
synced 2024-12-21 23:08:53 -05:00
Add a mempak hexdump function
This commit is contained in:
parent
a56c4eef4e
commit
f09c77689d
@ -3,6 +3,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
#include <ctype.h>
|
||||
#include <libgen.h>
|
||||
#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; i<MEMPAK_MEM_SIZE; i+=0x20) {
|
||||
printf("%04x: ", i);
|
||||
for (j=0; j<0x20; j++) {
|
||||
printf("%02x ", pak->data[i+j]);
|
||||
}
|
||||
printf(" ");
|
||||
|
||||
for (j=0; j<0x20; j++) {
|
||||
printf("%c", isprint(pak->data[i+j]) ? pak->data[i+j] : '.' );
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -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"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user