예제 #1
0
파일: save.c 프로젝트: rockcarry/ffnes
int nes_load_replay(NES *nes, char *file)
{
    FILE *fpsrc   = fopen(file, "rb");
    FILE *fpdst   = NULL;
    int   running = 0;
    int   ret     = 0;

    // pause nes thread if running
    running = nes_getrun(nes);
    if (running) nes_setrun(nes, 0);

    // close lastreplay file
    if (nes->replay.fp) {
        fclose(nes->replay.fp);
        nes->replay.fp = NULL;
    }

    fpdst = fopen(nes->replay.fname, "wb");
    ret   = copyfile(fpdst, fpsrc);

    // set replay to play mode
    nes->replay.mode = NES_REPLAY_PLAY;

    // reset nes
    nes_reset(nes);

    // show text
    nes_textout(nes, 0, 222, "replay", -1, 2);

    // resume running
    if (running) nes_setrun(nes, 1);

    return ret;
}
예제 #2
0
static void click_hardreset()
{
	if((nes == 0) || (nes->rom == 0))
		return;
	nes_reset(1);
	//deactivate the gui
	joykeys[config.gui_keys[0]] = 1;
}
예제 #3
0
int loadrom(char *fn)
{
	log_message("loadrom: loading rom '%s'\n",fn);
	unloadrom();
	if(((rom = rom_load(fn)) == 0) || (nes_load(rom) != 0)) {
		log_message("loadrom: error loading rom '%s'\n",fn);
		return(1);
	}
	if(rom->diskdata)
		loaddiskstate();
//	if(config.autostates)
//		loadstate();
	nes_reset(1);	//perform hard reset
	add_recent(fn);
	return(0);
}
예제 #4
0
파일: debugger.c 프로젝트: Aleyr/nesemu2
LRESULT CALLBACK DebuggerDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
	SCROLLINFO si;
	breakpoint_t *bp;

	switch(message) {

		case WM_INITDIALOG:
			pc = nes->cpu.pc;
			si.cbSize = sizeof(SCROLLINFO);
			si.fMask = SIF_PAGE | SIF_RANGE;
			si.nMin = 0;
			si.nMax = 0xFFFF;
			si.nPage = 0x400;
			SetScrollInfo(GetDlgItem(hDlg,IDC_DISASMSCROLL),SB_CTL,&si,TRUE);
			update(hDlg);
			return(TRUE);

		case WM_COMMAND:
			switch(LOWORD(wParam)) {

				//control
				case IDC_STEPBUTTON:
					cpu_execute(1);
					pc = nes->cpu.pc;
					update(hDlg);
					return(TRUE);
				case IDC_RUNBUTTON:
					return(TRUE);
				case IDC_SOFTRESETBUTTON:
					nes_reset(0);
					return(TRUE);
				case IDC_HARDRESETBUTTON:
					nes_reset(1);
					return(TRUE);

				//seeking
				case IDC_SEEKCURRENTPCBUTTON:
					pc = nes->cpu.pc;
					update(hDlg);
					return(TRUE);
				case IDC_SEEKADDRESSBUTTON:
					update(hDlg);
					return(TRUE);

				//breakpoint handling
				case IDC_ADDBPBUTTON:
					bp = DialogBoxParam(hInst,(LPCTSTR)IDD_BREAKPOINT,hWnd,BreakpointDlg,(LPARAM)0);
					return(TRUE);
				case IDOK:
				case IDCANCEL:
					EndDialog(hDlg,LOWORD(wParam));
					return(TRUE);
			}
			break;

		case WM_VSCROLL:
			if((HWND)lParam == GetDlgItem(hDlg,IDC_DISASMSCROLL)) {
				log_printf("scrolling\n");
				si.cbSize = sizeof(SCROLLINFO);
				si.fMask = SIF_PAGE | SIF_POS | SIF_RANGE;
				GetScrollInfo((HWND)lParam,SB_CTL,&si);
				switch(LOWORD(wParam)) {
					case SB_LINEUP:			pc--;						break;
					case SB_LINEDOWN:			pc++;						break;
					case SB_PAGEUP:			pc -= si.nPage;		break;
					case SB_PAGEDOWN:			pc += si.nPage;		break;
					case SB_THUMBPOSITION:	pc = HIWORD(wParam);	break;
				}
				if(pc < si.nMin)
					pc = si.nMin;
				if(pc > si.nMax)
					pc = si.nMax;
				update_disasm(hDlg);
			}
			break;
	}
	return(FALSE);
}