src/memory/header.cc
/*
 * Calculates the size of a rom section using the standard nes2 formula.
 *
 * Assumes the unit_size is correct for the section being calculated, and
 * that the high 4 bits of the msb are 0.
 */
Calculates the size of a rom section using the standard nes2 formula.
Assumes the unit_size is correct for the section being calculated, and
that the high 4 bits of the msb are 0.
Calculates the size of a rom section using the standard nes2 formula . Assumes the unit_size is correct for the section being calculated and that the high 4 bits of the msb are 0 .
static size_t GetNes2RomSectionSize(DataWord lsb, DataWord msb,
                                    size_t unit_size) {
  if (msb == 0xfU) {
    return (1 << (lsb & 0xFC)) * (((lsb & 0x03) << 1) + 1);
  } else {
    return (((static_cast<size_t>(msb)) << 8) | (static_cast<size_t>(lsb)))
                                              * unit_size;
  }
}
static size_t GetNes2RomSectionSize ( DataWord lsb , DataWord msb , size_t unit_size ) { if ( msb == 0xfU ) { return ( 1 << ( lsb & 0xFC ) ) * ( ( ( lsb & 0x03 ) << 1 ) + 1 ) ; } else { return ( ( ( static_cast < size_t > ( msb ) ) << 8 ) | ( static_cast < size_t > ( lsb ) ) ) * unit_size ; } }
Calculates the size of a rom section using the standard nes2 formula.
Calculates the size of a rom section using the standard nes2 formula .
// If the msb is 0xf, then the size follows the formula 2^E * (MM * 2 + 1), // where E is the high 6 bits of the lsb and MM is the lower 2 bits. // Otherwise, the msb and lsb are considered as one number and multiplied // by the given unit size.