2015-10-25 01:57:10 -04:00
|
|
|
#include <stdio.h>
|
2015-10-25 02:41:54 -04:00
|
|
|
#include <string.h>
|
2015-10-25 01:57:10 -04:00
|
|
|
#include "mempak.h"
|
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
const char *infile;
|
|
|
|
mempak_structure_t *mpk;
|
|
|
|
int note;
|
|
|
|
int res;
|
|
|
|
|
|
|
|
if (argc < 2) {
|
|
|
|
printf("Usage: ./mempak_ls file\n");
|
|
|
|
printf("\n");
|
|
|
|
printf("Raw files (.MPK, .BIN) and Dexdrive (.N64) formats accepted.\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
infile = argv[1];
|
|
|
|
mpk = mempak_loadFromFile(infile);
|
|
|
|
if (!mpk) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2015-10-25 15:22:35 -04:00
|
|
|
printf("Mempak image loaded. Image type %d (%s)\n", mpk->file_format, mempak_format2string(mpk->file_format));
|
2015-10-25 01:57:10 -04:00
|
|
|
|
|
|
|
if (0 != validate_mempak(mpk)) {
|
|
|
|
printf("Mempak invalid (not formatted or corrupted)\n");
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("Mempak content is valid\n");
|
2015-10-25 15:22:35 -04:00
|
|
|
printf("Block usage: %d / %d\n", 123-get_mempak_free_space(mpk), 123);
|
2015-10-25 01:57:10 -04:00
|
|
|
|
|
|
|
for (note = 0; note<MEMPAK_NUM_NOTES; note++) {
|
|
|
|
entry_structure_t note_data;
|
|
|
|
|
|
|
|
printf("Note %d: ", note);
|
|
|
|
res = get_mempak_entry(mpk, note, ¬e_data);
|
|
|
|
if (res) {
|
|
|
|
printf("Error!\n");
|
|
|
|
} else {
|
|
|
|
if (note_data.valid) {
|
|
|
|
printf("%s (%d blocks) ", note_data.name, note_data.blocks);
|
2015-10-25 02:41:54 -04:00
|
|
|
// printf("%08x ", note_data.vendor);
|
|
|
|
// printf("%04x ", note_data.game_id);
|
|
|
|
// printf("%02x ", note_data.region);
|
|
|
|
if (strlen(mpk->note_comments[note]) > 0) {
|
|
|
|
printf("{ %s }", mpk->note_comments[note]);
|
|
|
|
}
|
2015-10-25 01:57:10 -04:00
|
|
|
printf("\n");
|
|
|
|
} else {
|
2015-10-25 15:22:35 -04:00
|
|
|
printf("Free\n");
|
2015-10-25 01:57:10 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
done:
|
|
|
|
mempak_free(mpk);
|
|
|
|
return 0;
|
|
|
|
}
|