diff options
Diffstat (limited to 'dump_mappers.c')
| -rw-r--r-- | dump_mappers.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/dump_mappers.c b/dump_mappers.c index 42034de..98dad4e 100644 --- a/dump_mappers.c +++ b/dump_mappers.c @@ -9,6 +9,13 @@ #define INES_HEADER_SIZE 16 +static void print_mapper(uint32_t mapper, const char *path) { + uint32_t mapper_id = mapper >> 4; + uint32_t submapper = mapper & 0xF; + + printf("%03u_%x %s\n", mapper_id, submapper, path); +} + static void process_nes_file(const char *path) { FILE *f = fopen(path, "rb"); if(!f) return; @@ -27,8 +34,10 @@ static void process_nes_file(const char *path) { uint8_t mapper_ext = header[8] & 0x0F; uint8_t submapper = header[8] >> 4; - uint32_t mapper = (submapper << 12) | (mapper_ext << 8) | mapper_high | mapper_low; - printf("0x%04x %s\n", mapper, path); + uint32_t mapper = (mapper_ext << 8) | mapper_high | mapper_low; + mapper = (mapper << 4) | submapper; + + print_mapper(mapper, path); } static void process_zip_file(const char *path) { @@ -73,8 +82,10 @@ static void process_zip_file(const char *path) { uint8_t mapper_ext = header[8] & 0x0F; uint8_t submapper = header[8] >> 4; - uint32_t mapper = (submapper << 12) | (mapper_ext << 8) | mapper_high | mapper_low; - printf("0x%04x %s\n", mapper, path); + uint32_t mapper = (mapper_ext << 8) | mapper_high | mapper_low; + mapper = (mapper << 4) | submapper; + + print_mapper(mapper, path); } static void scan_directory(const char *path) { @@ -104,7 +115,7 @@ static void scan_directory(const char *path) { int main(int argc, char **argv) { if(argc < 2) { - fprintf(stderr, "usage: %s <romdir>\n", argv[0]); + fprintf(stderr, "Usage: %s <romdir>\n", argv[0]); return 1; } scan_directory(argv[1]); |
