Exemple #1
0
void save_slot_preview(BYTE slot) {
	uTCHAR *file;
	FILE *fp;

	if (!save_slot.preview_start) {
		memcpy(tl.snaps[TL_SNAP_FREE] + tl.preview, screen.data, screen_size());
		save_slot.preview_start = TRUE;
	}

	if (!save_slot.state[slot]) {
		memcpy(screen.data, tl.snaps[TL_SNAP_FREE] + tl.preview, screen_size());
		gfx_draw_screen(TRUE);
		return;
	}

	if ((file = name_slot_file(slot)) == NULL) {
		memcpy(screen.data, tl.snaps[TL_SNAP_FREE] + tl.preview, screen_size());
		gfx_draw_screen(TRUE);
		return;
	}

	if ((fp = ufopen(file, uL("rb"))) == NULL) {
		memcpy(screen.data, tl.snaps[TL_SNAP_FREE] + tl.preview, screen_size());
		gfx_draw_screen(TRUE);
		fprintf(stderr, "error on load preview\n");
		return;
	}

	fseek(fp, save_slot.preview[slot], SEEK_SET);

	{
		DBWORD bytes;

		bytes = fread(screen.data, screen_size(), 1, fp);

		if (bytes != 1) {
			memcpy(screen.data, tl.snaps[TL_SNAP_FREE] + tl.preview, screen_size());
		}
	}

	fclose(fp);
	gfx_draw_screen(TRUE);
}
Exemple #2
0
BYTE emu_frame(void) {
#if defined (DEBUG)
	WORD PCBREAK = 0xA930;
#endif

#if defined (SDL) && defined (__WIN32__)
	gfx_sdlwe_tick();
#endif

	gui_control_visible_cursor();

	tas.lag_frame = TRUE;

	/* gestione uscita */
	if (info.stop == TRUE) {
		emu_quit(EXIT_SUCCESS);
	}

	/* eseguo un frame dell'emulatore */
	if (!(info.no_rom | info.pause)) {
		/* controllo se ci sono eventi di input */
		if (tas.type) {
			tas_frame();
		} else {
			BYTE i;

			for (i = PORT1; i < PORT_MAX; i++) {
				if (input_add_event[i]) {
					input_add_event[i](i);
				}
			}
		}

		/* riprendo a far correre la CPU */
		info.execute_cpu = TRUE;

		while (info.execute_cpu == TRUE) {
#if defined (DEBUG)
			if (cpu.PC == PCBREAK) {
				BYTE pippo = 5;
				pippo = pippo + 1;
			}
#endif
			/* eseguo CPU, PPU e APU */
			cpu_exe_op();
		}

		if ((cfg->cheat_mode == GAMEGENIE_MODE) && (gamegenie.phase == GG_LOAD_ROM)) {
			emu_reset(CHANGE_ROM);
			gamegenie.phase = GG_FINISH;
		}

		if (tas.lag_frame) {
			tas.total_lag_frames++;
		}

		if (snd_end_frame) {
			snd_end_frame();
		}

//#if defined (DEBUG)
//		gfx_draw_screen(TRUE);
//#else
		gfx_draw_screen(FALSE);
//#endif

		if (!tas.type && (++tl.frames == tl.frames_snap)) {
			timeline_snap(TL_NORMAL);
		}

		r4011.frames++;
	} else {
		gfx_draw_screen(FALSE);
	}

	/* gestione frameskip e calcolo fps */
	fps_frameskip();
	return (EXIT_OK);
}