src/memory/mappers/std_banked.cc
/*
 * Loads the CHR ROM data into the calling StdBanked class during construction.
 *
 * Assumes the provided rom file is non-null and points to a valid NES rom.
 * Assumes the header field of the class is valid and matches the rom.
 */
Loads the CHR ROM data into the calling StdBanked class during construction.
Assumes the provided rom file is non-null and points to a valid NES rom.
Assumes the header field of the class is valid and matches the rom.
Loads the CHR ROM data into the calling StdBanked class during construction . Assumes the provided rom file is non - null and points to a valid NES rom . Assumes the header field of the class is valid and matches the rom .
void StdBanked::LoadChr(FILE *rom_file) {
  if (header_->chr_ram_size > 0) {
    is_chr_ram_ = true;
    pattern_table_ = RandNew(CHR_RAM_SIZE);
    return;
  }
  is_chr_ram_ = false;
  pattern_table_ = new DataWord[header_->chr_rom_size];
  fseek(rom_file, HEADER_SIZE + header_->prg_rom_size, SEEK_SET);
  for (size_t i = 0; i < PATTERN_TABLE_SIZE; i++) {
    pattern_table_[i] = fgetc(rom_file);
  }
  return;
}
void StdBanked :: LoadChr ( FILE * rom_file ) { if ( header_ -> chr_ram_size > 0 ) { is_chr_ram_ = true ; pattern_table_ = RandNew ( CHR_RAM_SIZE ) ; return ; } is_chr_ram_ = false ; pattern_table_ = new DataWord [ header_ -> chr_rom_size ] ; fseek ( rom_file , HEADER_SIZE + header_ -> prg_rom_size , SEEK_SET ) ; for ( size_t i = 0 ; i < PATTERN_TABLE_SIZE ; i ++ ) { pattern_table_ [ i ] = fgetc ( rom_file ) ; } return ; }
Loads the CHR ROM data into the calling StdBanked class during construction.
Loads the CHR ROM data into the calling StdBanked class during construction .
// Check if the rom is using chr-ram, and allocate it if so. // Otherwise, the rom uses chr-rom and the data needs to be copied // from the rom file.