/***************************************
 FDS Simulator Mapper20
***************************************/
function cpu_dump(d,prg_size,prg_size_dummy)
{
	cpu_write(d,0xA001,0);//enable dump/flash
	for(local i = 0; i < prg_size/0x2000; i += 2){
		cpu_write(d, 0x8000, i);
		cpu_write(d, 0x8001, i | 1);
		cpu_read(d, 0x8000, 0x2000 * 2);
	}
}

function cpu_erase(d, prg_size, prg_size_dummy)
{
	cpu_write(d,0xA001,0);//enable dump/flash
	cpu_write(d,0x8000,0);
	cpu_write_flash(d,0x8555,0xF0);
	cpu_write_flash(d,0x8555,0xAA);
	cpu_write_flash(d,0x82AA,0x55);
	cpu_write_flash(d,0x8555,0x80);
	cpu_write_flash(d,0x8555,0xAA);
	cpu_write_flash(d,0x82AA,0x55);
	cpu_write_flash(d,0x8555,0x10);
}
function cpu_flash(d, prg_size, prg_size_dummy)
{
	cpu_write(d,0xA001,0);//enable dump/flash
	flash_configure(d,0xA000,0xA555,0xA2AA,0xA555);
	for(local i = 0; i < prg_size/0x2000; i += 1){
		cpu_write(d, 0x8001, i);
		prg_flash(d, 0xA000, 0x2000);
	}
	
	
}