Ejemplo n.º 1
0
int log_init()
{
	historyline_t *line;

	if(logfd) {
		printf("log_init:  already initialized\n");
		return(0);
	}

	//clear the string
	memset(logfilename,0,MAX_PATH);

	//parse the log path
	config_get_eval_string(logfilename,"path.user");

	//append the path seperator
	str_appendchar(logfilename,PATH_SEPERATOR);

	//append the bios filename
	strcat(logfilename,LOGFILENAME);

	//try to open
	if((logfd = fopen(logfilename,"wt")) == 0) {
		strcpy(logfilename,LOGFILENAME);
		if((logfd = fopen(LOGFILENAME,"wt")) == 0) {
			printf("log_init:  error opening log file '%s'\n",logfilename);
			return(1);
		}
	}

	//catch up the log file with lines that weren't added
	line = history.lines;
	while(line->next) {
		line = line->next;
	}
	while(line) {
		fputs(line->str,logfd);
		line = line->prev;
	}
	fflush(logfd);
	history_clear(&history);

	log_printf("log_init:  log initialized.  nesemu2 v"VERSION"\n");
	log_printf("log_init:  log filename is '%s'.\n",logfilename);
	return(0);
}
Ejemplo n.º 2
0
int genie_load()
{
	char biosfile[1024];

	//if the rom isnt loaded, we need to do that now
	if(genierom == 0) {

		//clear the string
		memset(biosfile,0,1024);

		//parse the bios path
		config_get_eval_string(biosfile,"path.bios");

		//append the path seperator
		str_appendchar(biosfile,PATH_SEPERATOR);

		//append the bios filename
		strcat(biosfile,config_get_string("nes.gamegenie.bios"));

		//try to load bios from the bios directory
		if(genie_loadrom(biosfile) != 0) {

			//see if bios is in the current directory
			if(genie_loadrom(config_get_string("nes.gamegenie.bios")) != 0) {
				return(1);
			}
		}

		//register the save state stuff
		state_register(B_GG,genie_state);
	}

	//load in the genie mapper
	nes->mapper = &mapperB_GENIE;

	return(0);
}
Ejemplo n.º 3
0
Archivo: nsf.c Proyecto: Aleyr/nesemu2
int cart_load_nsf(cart_t *ret,memfile_t *file)
{
	int n = 0;
	char biosfile[1024];
	u32 size;
	u32 loadaddr;
	u8 nobankswitch[8 + 8] = {0,0,0,0,0,0,0,0,  0,1,2,3,4,5,6,7};

	//clear the string
	memset(biosfile,0,1024);

	//parse the bios path
	config_get_eval_string(biosfile,"path.bios");

	//append the path seperator
	str_appendchar(biosfile,PATH_SEPERATOR);

	//append the bios filename
	strcat(biosfile,"nsfbios.bin");

	//try to load bios from the bios directory
	if(loadbios(ret,biosfile) != 0) {

		//see if bios is in the current directory
		if(loadbios(ret,"nsfbios.bin") != 0) {
			return(1);
		}
	}

	//get length of file
	size = memfile_size(file);

	//discount for the header
	size -= 0x80;

	if(memfile_read(ret->data,1,0x80,file) != 0x80) {
		log_printf("cart_load_nsf:  error reading header from '%s'\n",file->filename);
		n = 1;
	}
	else {
		loadaddr = ret->data[8] | (ret->data[9] << 8);

		//if the nsf doesnt use bankswitching
		if(memcmp((u8*)ret->data + 0x70,(u8*)nobankswitch,8) == 0) {
			memcpy((u8*)ret->data + 0x70,(u8*)nobankswitch + 8,8);
			ret->prg.size = (u32)size + (loadaddr & 0x7FFF);
			ret->prg.data = (u8*)mem_alloc(ret->prg.size);
			memset(ret->prg.data,0,ret->prg.size);
			memfile_read(ret->prg.data + (loadaddr & 0x7FFF),1,size,file);
		}

		//else the nsf is bankswitched
		else {
			ret->prg.size = (u32)size + (loadaddr & 0xFFF);
			ret->prg.data = (u8*)mem_alloc(ret->prg.size);
			memset(ret->prg.data,0,ret->prg.size);
			memfile_read(ret->prg.data + (loadaddr & 0xFFF),1,size,file);
		}

		//setup mapper
		ret->mapperid = B_NSF;
		log_printf("cart_load_nsf:  nsf v%d loaded, %d bytes (padded to %d), %d songs.\n",ret->data[5],size,ret->prg.size,ret->data[6]);
		log_printf("init $%04X, play $%04X\n",ret->data[0xA] | (ret->data[0xB] << 8),ret->data[0xC] | (ret->data[0xD] << 8));
	}

	return(n);
}
Ejemplo n.º 4
0
Archivo: fds.c Proyecto: Aleyr/nesemu2
int cart_load_fds(cart_t *ret,memfile_t *file)
{
	u8 header[16];
	u32 size;
	char biosfile[1024];

	//clear the string
	memset(biosfile,0,1024);

	//parse the bios path
	config_get_eval_string(biosfile,"path.bios");

	//append the path seperator
	str_appendchar(biosfile,PATH_SEPERATOR);

	//append the bios filename
	strcat(biosfile,config_get_string("nes.fds.bios"));

	//try to load bios from the bios directory
	if(loadbios(ret,biosfile) != 0) {

		//see if bios is in the current directory
		if(loadbios(ret,config_get_string("nes.fds.bios")) != 0) {
			return(1);
		}
	}

	//get length of file
	size = memfile_size(file);

	//read the header
	memfile_read(header,1,16,file);

	//check if this is raw fds disk
	if(memcmp(header,fdsident2,15) == 0) {

		//check if the file is a valid size
		if((size % 65500) != 0) {
			log_printf("cart_load_fds:  fds disk image size not multiple of 65500, aborting\n");
			return(1);
		}

		//set number of disk sides
//		ret->disksides = size / 65500;

		//skip back to the beginning
		memfile_rewind(file);
	}

	//check if this is 16-byte header fds disk
	else if(memcmp(header,fdsident,4) == 0) {

		//set number of disk sides
//		ret->disksides = header[4];
		size -= 16;

	}

	//set mapper id to fds mapper
	ret->mapperid = B_FDS;

	//setup the disk data pointers
	ret->disk.size = size;
	ret->disk.data = (u8*)mem_alloc(size);
	ret->diskoriginal.size = size;
	ret->diskoriginal.data = (u8*)mem_alloc(size);

	//read disk data into pointer
	memfile_read(ret->disk.data,1,size,file);

	//copy to original disk data pointer
	memcpy(ret->diskoriginal.data,ret->disk.data,size);

	log_printf("cart_load_fds:  loaded disk, %d sides (%d bytes)\n",ret->disk.size / 65500,size);
	return(0);
}