Parcourir la source

Store a few extra header fields in the ROM struct; typo fix.

master
Ben Kurtovic il y a 8 ans
Parent
révision
962171b7ee
3 fichiers modifiés avec 10 ajouts et 4 suppressions
  1. +1
    -1
      src/mmu.c
  2. +7
    -3
      src/rom.c
  3. +2
    -0
      src/rom.h

+ 1
- 1
src/mmu.c Voir le fichier

@@ -55,7 +55,7 @@ static void dump_bank_table(const MMU *mmu, const uint8_t *data)
/*
Load a block of ROM into the MMU.

size must be a multiple of MMU_ROM_BANK_SIZE (16 KB), the load will fail
size must be a multiple of MMU_ROM_BANK_SIZE (16 KB), or the load will fail
silently. It should also be a power of two, or problems might occur with
ROM mirroring logic. It should not be larger than
MMU_ROM_BANK_SIZE * MMU_NUM_ROM_BANKS, or the extra banks will be ignored.


+ 7
- 3
src/rom.c Voir le fichier

@@ -63,7 +63,7 @@ static void print_header_dump(const uint8_t *header)
@DEBUG_LEVEL
Print out the analyzed header to stdout.
*/
static void print_header_contents(const ROM *rom, const uint8_t *header)
static void print_header_contents(const ROM *rom)
{
DEBUG("- header info:")
if (rom->reported_checksum == rom->expected_checksum)
@@ -77,7 +77,7 @@ static void print_header_contents(const ROM *rom, const uint8_t *header)
DEBUG(" - region code: %u (%s)", rom->region_code,
rom_region(rom) ? rom_region(rom) : "unknown")
DEBUG(" - reported size: %s",
size_to_string(size_code_to_bytes(header[0xF] & 0xF)))
size_to_string(size_code_to_bytes(rom->declared_size)))
}

/*
@@ -116,9 +116,10 @@ static bool parse_header(ROM *rom, const uint8_t *header)
(bcd_decode(header[0xD]) * 100) + ((header[0xE] >> 4) * 10000);
rom->version = header[0xE] & 0x0F;
rom->region_code = header[0xF] >> 4;
rom->declared_size = header[0xF] & 0xF;

if (DEBUG_LEVEL)
print_header_contents(rom, header);
print_header_contents(rom);
return true;
}

@@ -144,6 +145,7 @@ static bool find_and_read_header(ROM *rom)
}
else {
DEBUG(" - magic found")
rom->header_location = location;
return parse_header(rom, header);
}
}
@@ -182,11 +184,13 @@ const char* rom_open(ROM **rom_ptr, const char *path)
rom->name = NULL;
rom->data = NULL;
rom->size = 0;
rom->header_location = 0;
rom->reported_checksum = 0;
rom->expected_checksum = 0;
rom->product_code = 0;
rom->version = 0;
rom->region_code = 0;
rom->declared_size = 0;

// Set rom->name:
rom->name = cr_malloc(sizeof(char) * (strlen(path) + 1));


+ 2
- 0
src/rom.h Voir le fichier

@@ -31,11 +31,13 @@ typedef struct {
char *name;
uint8_t *data;
size_t size;
uint16_t header_location;
uint16_t reported_checksum;
uint16_t expected_checksum;
uint32_t product_code;
uint8_t version;
uint8_t region_code;
uint8_t declared_size;
} ROM;

/* Functions */


Chargement…
Annuler
Enregistrer