src/memory/header.cc
/*
 * Determines the format of the file header of a rom,
 * using a strategy outlined on nesdev.
 *
 * Assumes the header is non-null.
 */
Determines the format of the file header of a rom,
using a strategy outlined on nesdev.

Assumes the header is non-null.
Determines the format of the file header of a rom using a strategy outlined on nesdev . Assumes the header is non - null .
static NesHeaderType GetHeaderType(char *file_header, size_t rom_size) {
  size_t size = GetNes2PrgRomSize(file_header)
              + GetNes2ChrRomSize(file_header) + HEADER_SIZE;
  if (((file_header[7] & 0x0C) == 0x08) && size <= rom_size) {
    return NES2;
  }
  for (size_t i = HEADER_SIZE - 4; i < HEADER_SIZE; i++) {
    if (file_header[i] != 0) {
      return ARCHAIC_INES;
    }
  }
  return INES;
}
static NesHeaderType GetHeaderType ( char * file_header , size_t rom_size ) { size_t size = GetNes2PrgRomSize ( file_header ) + GetNes2ChrRomSize ( file_header ) + HEADER_SIZE ; if ( ( ( file_header [ 7 ] & 0x0C ) == 0x08 ) && size <= rom_size ) { return NES2 ; } for ( size_t i = HEADER_SIZE - 4 ; i < HEADER_SIZE ; i ++ ) { if ( file_header [ i ] != 0 ) { return ARCHAIC_INES ; } } return INES ; }
Determines the format of the file header of a rom,
 using a strategy outlined on nesdev.
Determines the format of the file header of a rom using a strategy outlined on nesdev .
/*
   * Byte 7, bits 2 and 3, of a nes file header contain an
   * indicator for whether or not the header is in the NES 2.0 format.
   * If the bits are equal to 2, it's a NES 2.0 header.
   * The problem with this is that an archaic INES header may set these bits,
   * so we must confirm the file size is correct to ensure it is NES2.
   */ // Get the size of the rom as if it was a nes2 header. // Determine if it's a nes2 header. // Most roms with headers in the Archaic INES format had // some kind of text filling their final bytes. In general, if // the headers final 4 bytes are 0, and it's not a NES 2.0 header, // then it's an INES header.