Exemplo n.º 1
0
static void Cleanup(void)
{
 rom_unload();

 if(NGPGfx != NULL)
 {
  delete NGPGfx;
  NGPGfx = NULL;
 }
}
Exemplo n.º 2
0
void unloadrom()
{
//	if(config.autostates)
//		savestate();
	log_message("unloadrom: unloading rom\n");
	nes_unload();
	if(rom) {
		if(rom->diskdata)
			savediskstate();
		rom_unload(rom);
		rom = 0;
	}
}
Exemplo n.º 3
0
int main(int argc, char* argv[]) {

    int done;
    deviceEntry* gpu;
    ramBlock* mainRAM;
    romBlock* monitorROM;
    interfaceChip* userInterface;

    //Start SDL
    SDL_Init( SDL_INIT_EVERYTHING );
    SDL_ShowCursor( SDL_DISABLE );
    atexit(SDL_Quit);
    printf("SDL started.\n");

    gpu = gpu_create(0xFC00);
    if(gpu == NULL)
      return 0;
    mainRAM = ram_create(0x1000, 0xF7FF);
    monitorROM = rom_create(0x0000, 0x0FFF, "monitor.rom");
    userInterface = interface_create(0xFFFE);

    cpu_addDevice(mainRAM->device);
    cpu_addDevice(monitorROM->device);
    cpu_addDevice(gpu);
    cpu_addDevice(userInterface->device);

    cpu_reset();

    while(cpu_cycle(2000)){

        interface_pollKeyboard();
        gpu_redraw(); //<- this is slowing execution down a lot. We should really put it on a 30-60hz timer.

    }
    gpu_redraw();

    printf("CPU halted.", "Notice");

    ram_unload();
    rom_unload();
    interface_unload();
    gpu_unload();
    cpu_unloadDevices();

    SDL_Quit();

    return 0;

}
Exemplo n.º 4
0
rom_t *rom_load(const char *filename)
{
	int fd;						//file handle
	rom_t *ret = 0;			//rom data struct
	u8 header[16];
	char *p;

	//parse out the rom filename
	if((p = strrchr(filename,'/')) == 0) {
		if((p = strrchr(filename,'\\')) == 0) {
			p = (char*)filename;
		}
		else
			p++;
	}
	else
		p++;

	//allocate memory for rom struct
	ret = (rom_t*)malloc(sizeof(rom_t));

	//zero the rom struct
	memset(ret,0,sizeof(rom_t));

	//copy the rom filename
	strcpy(ret->filename,p);

	//try to open the file
	if((fd = file_open((char*)filename,"rb")) == -1) {
		log_message("rom_load:  cannot open rom image\n");
		rom_unload(ret);
		return(0);
	}

	log_message("loading '%s'...\n",ret->filename);

	//read in the file header
	if(file_read(fd,(u8*)header,16) != 16) {
		log_message("rom_load:  error reading file header\n");
		rom_unload(ret);
		file_close(fd);
		return(0);
	}

//hack for ps2
#ifdef PS2
	file_close(fd);
	fd = file_open((char*)filename,"rb");
#else
	//return to beginning of file
	file_seek(fd,0,SEEK_SET);
#endif

	//if the file is a state save, then try to find the rom
	if(memcmp(header,nstident,5) == 0) {
//		if(rom_load_state(fd,ret) == 0) {
//			rom_unload(ret);
			log_message("loading states as roms not implemented...yet\n");
			file_close(fd);
			return(0);
//		}
	}

	//see if it is an ines rom image
	else if(memcmp(header,inesident,4) == 0) {
		//check header for ines 2.0 or old ines format
		if((((header[7] & 0xC) == 8) && (rom_load_ines20(fd,ret) == 0)) ||
			(rom_load_ines(fd,ret) == 0)) {
			file_close(fd);
			return(0);
		}
	}

	//if the file is an fds disk image
	else if(memcmp(header,fdsident,4) == 0) {
		if(rom_load_fds(fd,ret) == 0) {
			file_close(fd);
			return(0);
		}
	}

	//if the file is an unif image
	else if(memcmp(header,unifident,4) == 0) {
		if(rom_load_unif(fd,ret) == 0) {
			file_close(fd);
			return(0);
		}
	}

	//if the file is a nsf music file
	else if(memcmp(header,nsfident,5) == 0) {
		if(rom_load_nsf(fd,ret) == 0) {
			file_close(fd);
			return(0);
		}
	}

	//unknown file type
	else {
		log_message("bad image\n");
		file_close(fd);
		return(0);
	}

	log_message("nes image '%s' loaded ok\n",ret->filename);

	//close the file and return
	file_close(fd);
	return(ret);
}
Exemplo n.º 5
0
static void CloseGame(void)
{
 rom_unload();
}