示例#1
0
void Mapper_Fme07::write_register( int index, int data )
{
	regs [index] = data;
	int prg_bank = index - 0x09;
	if ( (unsigned) prg_bank < 3 ) // most common
	{
		set_prg_bank( 0x8000 | (prg_bank << bank_8k), bank_8k, data );
	}
	else if ( index == 0x08 )
	{
		enable_sram( (data & 0xC0) == 0xC0 );
		if ( !(data & 0xC0) )
			set_prg_bank( 0x6000, bank_8k, data & 0x3F );
	}
	else if ( index < 0x08 )
	{
		set_chr_bank( index * 0x400, bank_1k, data );
	}
	else
	{
		if ( data & 2 )
			mirror_single( data & 1 );
		else if ( data & 1 )
			mirror_horiz();
		else
			mirror_vert();
	}
}
示例#2
0
void Nes_Core::load_state( Nes_State_ const& in )
{
	require( cart );
	
	disable_rendering();
	error_count = 0;
	
	if ( in.nes_valid )
		nes = in.nes;
	
	// always use frame count
	ppu.burst_phase = 0; // avoids shimmer when seeking to same time over and over
	nes.frame_count = in.nes.frame_count;
	if ( (frame_count_t) nes.frame_count == invalid_frame_count )
		nes.frame_count = 0;
	
	if ( in.cpu_valid )
		cpu::r = *in.cpu;
	
	if ( in.joypad_valid )
		joypad = *in.joypad;
	
	if ( in.apu_valid )
	{
		impl->apu.load_state( *in.apu );
		// prevent apu from running extra at beginning of frame
		impl->apu.end_frame( -(int) nes.timestamp / ppu_overclock );
	}
	else
	{
		impl->apu.reset();
	}
	
	ppu.load_state( in );
	
	if ( in.ram_valid )
		memcpy( cpu::low_mem, in.ram, in.ram_size );
	
	sram_present = false;
	if ( in.sram_size )
	{
		sram_present = true;
		memcpy( impl->sram, in.sram, min( (int) in.sram_size, (int) sizeof impl->sram ) );
		enable_sram( true ); // mapper can override (read-only, unmapped, etc.)
	}
	
	if ( in.mapper_valid ) // restore last since it might reconfigure things
		mapper->load_state( *in.mapper );
}