示例#1
0
blargg_err_t Nes_Cart::load_ines( Auto_File_Reader in )
{
	RETURN_ERR( in.open() );
	
	ines_header_t h;
	RETURN_ERR( in->read( &h, sizeof h ) );
	
	if ( 0 != memcmp( h.signature, "NES\x1A", 4 ) )
		return not_ines_file;
	
	if ( h.zero [7] ) // handle header defaced by a f*****g idiot's handle
		h.flags2 = 0;
	
	set_mapper( h.flags, h.flags2 );
	
	if ( h.flags & 0x04 ) // skip trainer
		RETURN_ERR( in->skip( 512 ) );
	
	RETURN_ERR( resize_prg( h.prg_count * 16 * 1024L ) );
	RETURN_ERR( resize_chr( h.chr_count * 8 * 1024L ) );
	
	RETURN_ERR( in->read( prg(), prg_size() ) );
	RETURN_ERR( in->read( chr(), chr_size() ) );
	
	return 0;
}
示例#2
0
文件: logger.cpp 项目: bioothod/swarm
void add_file_frontend(logger_base &log, const std::string &file, log_level level)
{
	log.verbosity(level);

	auto formatter = blackhole::utils::make_unique<blackhole::formatter::string_t>(format());
	formatter->set_mapper(mapping());
	auto sink = blackhole::utils::make_unique<blackhole::sink::files_t<>>(blackhole::sink::files_t<>::config_type(file));
	auto frontend = blackhole::utils::make_unique<blackhole::frontend_t<blackhole::formatter::string_t, blackhole::sink::files_t<>>>(std::move(formatter), std::move(sink));

	log.add_frontend(std::move(frontend));
}
示例#3
0
file_logger::file_logger(const char *file, log_level level)
{
	verbosity(level);

	auto formatter = blackhole::utils::make_unique<blackhole::formatter::string_t>(format());
	formatter->set_mapper(file_logger::mapping());
	auto sink = blackhole::utils::make_unique<elliptics_file_t>(elliptics_file_t::config_type(file));
	auto frontend = blackhole::utils::make_unique
		<blackhole::frontend_t<blackhole::formatter::string_t, elliptics_file_t>>
			(std::move(formatter), std::move(sink));

	add_frontend(std::move(frontend));

	add_attribute(keyword::request_id() = 0);
}
示例#4
0
    static
    std::unique_ptr<base_frontend_t>
    create_frontend(const frontend_config_t& config) {
        auto formatter = aux::util::make_unique<Formatter>(
            aux::config_mapper<Formatter>::map(config.formatter.config())
        );
        formatter->set_mapper(config.formatter.mapper);

        auto sink = aux::util::make_unique<Sink>(
            aux::config_mapper<Sink>::map(config.sink.config())
        );

        return aux::util::make_unique<
            frontend_t<Formatter, Sink>
        >(std::move(formatter), std::move(sink));
    }
示例#5
0
blargg_err_t Nes_Rom::load_ines_rom( Data_Reader& in )
{
	ines_header_t h;
	BLARGG_RETURN_ERR( in.read( &h, sizeof h ) );
	
	if ( 0 != memcmp( h.signature, "NES\x1A", 4 ) )
		return "Not a iNES ROM file";
	
	if ( h.zero [7] ) // handle header defaced by a f*****g idiot's handle
		h.flags2 = 0;
	
	set_mapper( h.flags, h.flags2 );
	
	if ( h.flags & 0x04 ) // skip trainer
		BLARGG_RETURN_ERR( in.skip( 512 ) );
	
	BLARGG_RETURN_ERR( resize_prg( h.prg_count * 16 * 1024L ) );
	BLARGG_RETURN_ERR( resize_chr( h.chr_count * 8 * 1024L ) );
	
	BLARGG_RETURN_ERR( in.read( prg(), prg_size() ) );
	BLARGG_RETURN_ERR( in.read( chr(), chr_size() ) );
	
	return blargg_success;
}
示例#6
0
uint32_t load_rom(uint8_t* filename, uint32_t base_addr, uint8_t flags) {
  UINT bytes_read;
  DWORD filesize;
  UINT count=0;
  tick_t ticksstart, ticks_total=0;
  ticksstart=getticks();
  printf("%s\n", filename);
  file_open(filename, FA_READ);
  if(file_res) {
    uart_putc('?');
    uart_putc(0x30+file_res);
    return 0;
  }
  filesize = file_handle.fsize;
  smc_id(&romprops);
  file_close();
  /* reconfigure FPGA if necessary */
  if(romprops.fpga_conf) {
    printf("reconfigure FPGA with %s...\n", romprops.fpga_conf);
    fpga_pgm((uint8_t*)romprops.fpga_conf);
  }
  set_mcu_addr(base_addr + romprops.load_address);
  file_open(filename, FA_READ);
  ff_sd_offload=1;
  sd_offload_tgt=0;
  f_lseek(&file_handle, romprops.offset);
  for(;;) {
    ff_sd_offload=1;
    sd_offload_tgt=0;
    bytes_read = file_read();
    if (file_res || !bytes_read) break;
    if(!(count++ % 512)) {
      uart_putc('.');
    }
  }
  file_close();
  set_mapper(romprops.mapper_id);
  printf("rom header map: %02x; mapper id: %d\n", romprops.header.map, romprops.mapper_id);
  ticks_total=getticks()-ticksstart;
  printf("%u ticks total\n", ticks_total);
  if(romprops.mapper_id==3) {
    printf("BSX Flash cart image\n");
    printf("attempting to load BSX BIOS /sd2snes/bsxbios.bin...\n");
    load_sram_offload((uint8_t*)"/sd2snes/bsxbios.bin", 0x800000);
    printf("attempting to load BS data file /sd2snes/bsxpage.bin...\n");
    load_sram_offload((uint8_t*)"/sd2snes/bsxpage.bin", 0x900000);
    printf("Type: %02x\n", romprops.header.destcode);
    set_bsx_regs(0xc0, 0x3f);
    uint16_t rombase;
    if(romprops.header.ramsize & 1) {
      rombase = romprops.load_address + 0xff00;
//      set_bsx_regs(0x36, 0xc9);
    } else {
      rombase = romprops.load_address + 0x7f00;
//      set_bsx_regs(0x34, 0xcb);
    }
    sram_writebyte(0x33, rombase+0xda);
    sram_writebyte(0x00, rombase+0xd4);
    sram_writebyte(0xfc, rombase+0xd5);
    set_fpga_time(0x0220110301180530LL);
  }
  if(romprops.has_dspx || romprops.has_cx4) {
    printf("DSPx game. Loading firmware image %s...\n", romprops.dsp_fw);
    load_dspx(romprops.dsp_fw, romprops.fpga_features);
    /* fallback to DSP1B firmware if DSP1.bin is not present */
    if(file_res && romprops.dsp_fw == DSPFW_1) {
      load_dspx(DSPFW_1B, romprops.fpga_features);
    }
    if(file_res) {
      snes_menu_errmsg(MENU_ERR_NODSP, (void*)romprops.dsp_fw);
    }
  }
  uint32_t rammask;
  uint32_t rommask;

  while(filesize > (romprops.romsize_bytes + romprops.offset)) {
    romprops.romsize_bytes <<= 1;
  }

  if(romprops.header.ramsize == 0) {
    rammask = 0;
  } else {
    rammask = romprops.ramsize_bytes - 1;
  }
  rommask = romprops.romsize_bytes - 1;
  printf("ramsize=%x rammask=%lx\nromsize=%x rommask=%lx\n", romprops.header.ramsize, rammask, romprops.header.romsize, rommask);
  set_saveram_mask(rammask);
  set_rom_mask(rommask);
  readled(0);
  if(flags & LOADROM_WITH_SRAM) {
    if(romprops.ramsize_bytes) {
      sram_memset(SRAM_SAVE_ADDR, romprops.ramsize_bytes, 0);
      strcpy(strrchr((char*)filename, (int)'.'), ".srm");
      printf("SRM file: %s\n", filename);
      load_sram(filename, SRAM_SAVE_ADDR);
      saveram_crc_old = calc_sram_crc(SRAM_SAVE_ADDR, romprops.ramsize_bytes);
    } else {
      printf("No SRAM\n");
    }
  }

  printf("check MSU...");
  if(msu1_check(filename)) {
    romprops.fpga_features |= FEAT_MSU1;
    romprops.has_msu1 = 1;
  } else {
    romprops.has_msu1 = 0;
  }
  printf("done\n");

  romprops.fpga_features |= FEAT_SRTC;
  romprops.fpga_features |= FEAT_213F;

  fpga_set_213f(romprops.region);
  fpga_set_features(romprops.fpga_features);

  if(flags & LOADROM_WITH_RESET) {
    fpga_dspx_reset(1);
    snes_reset_pulse();
    fpga_dspx_reset(0);
  }

  return (uint32_t)filesize;
}
示例#7
0
文件: cli.c 项目: Godzil/sd2snes
void cmd_mapper(void) {
  int32_t mapper;
  mapper = parse_unsigned(0,7,10);
  set_mapper((uint8_t)mapper & 0x7);
  printf("mapper set to %ld\n", mapper);
}