Ejemplo n.º 1
0
void Replay_LoadMovie()
{
	if (suggestReadOnlyReplay)
		replayReadOnlySetting = true;
	else
		replayReadOnlySetting = FCEUI_GetMovieToggleReadOnly();

	char* fn = (char*)DialogBoxParam(fceu_hInstance, "IDD_REPLAYINP", hAppWnd, ReplayDialogProc, 0);

	if(fn)
	{
		FCEUI_LoadMovie(fn, replayReadOnlySetting, replayStopFrameSetting);

		free(fn);

		//mbg 6/21/08 - i think this stuff has to get updated in case the movie changed the pal emulation flag
		pal_emulation = FCEUI_GetCurrentVidSystem(0,0);
		UpdateCheckedMenuItems();
		SetMainWindowStuff();
		RefreshThrottleFPS();
	}
}
Ejemplo n.º 2
0
/**
 * Attempts to initialize the graphical video display.  Returns 0 on
 * success, -1 on failure.
 */
int
InitVideo(FCEUGI *gi)
{
	// XXX soules - const?  is this necessary?
	const SDL_VideoInfo *vinf;
	int error, flags = 0;
	int doublebuf, xstretch, ystretch, xres, yres, show_fps;

	FCEUI_printf("Initializing video...");

	// load the relevant configuration variables
	g_config->getOption("SDL.Fullscreen", &s_fullscreen);
	g_config->getOption("SDL.DoubleBuffering", &doublebuf);
#ifdef OPENGL
	g_config->getOption("SDL.OpenGL", &s_useOpenGL);
#endif
	g_config->getOption("SDL.SpecialFilter", &s_sponge);
	g_config->getOption("SDL.XStretch", &xstretch);
	g_config->getOption("SDL.YStretch", &ystretch);
	g_config->getOption("SDL.LastXRes", &xres);
	g_config->getOption("SDL.LastYRes", &yres);
	g_config->getOption("SDL.ClipSides", &s_clipSides);
	g_config->getOption("SDL.NoFrame", &noframe);
	g_config->getOption("SDL.ShowFPS", &show_fps);

	// check the starting, ending, and total scan lines
	FCEUI_GetCurrentVidSystem(&s_srendline, &s_erendline);
	s_tlines = s_erendline - s_srendline + 1;

	// check if we should auto-set x/y resolution

    // check for OpenGL and set the global flags
#if OPENGL
	if(s_useOpenGL && !s_sponge) {
		flags = SDL_OPENGL;
	}
#endif

	// initialize the SDL video subsystem if it is not already active
	if(!SDL_WasInit(SDL_INIT_VIDEO)) {
		error = SDL_InitSubSystem(SDL_INIT_VIDEO);
		if(error) {
			FCEUD_PrintError(SDL_GetError());
			return -1;
		}
	}
	s_inited = 1;

	// shows the cursor within the display window
	SDL_ShowCursor(1);

	// determine if we can allocate the display on the video card
	vinf = SDL_GetVideoInfo();
	if(vinf->hw_available) {
		flags |= SDL_HWSURFACE;
	}
    
	// get the monitor's current resolution if we do not already have it
	if(s_nativeWidth < 0) {
		s_nativeWidth = vinf->current_w;
	}
	if(s_nativeHeight < 0) {
		s_nativeHeight = vinf->current_h;
	}

	// check to see if we are showing FPS
	FCEUI_SetShowFPS(show_fps);
    
	// check if we are rendering fullscreen
	if(s_fullscreen) {
		int no_cursor;
		g_config->getOption("SDL.NoFullscreenCursor", &no_cursor);
		flags |= SDL_FULLSCREEN;
		SDL_ShowCursor(!no_cursor);
	}
	else {
		SDL_ShowCursor(1);
	}
    
	if(noframe) {
		flags |= SDL_NOFRAME;
	}

	// gives the SDL exclusive palette control... ensures the requested colors
	// flags |= SDL_HWPALETTE;

	// enable double buffering if requested and we have hardware support
#ifdef OPENGL
	if(s_useOpenGL) {
		FCEU_printf("Initializing with OpenGL (Disable with '--opengl 0').\n");
		if(doublebuf) {
			 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
		}
	} else
#endif
		if(doublebuf && (flags & SDL_HWSURFACE)) {
			flags |= SDL_DOUBLEBUF;
		}

	if(s_fullscreen) {
		int desbpp, autoscale;
		g_config->getOption("SDL.BitsPerPixel", &desbpp);
		g_config->getOption("SDL.AutoScale", &autoscale);
		if (autoscale)
		{
			double auto_xscale = GetXScale(xres);
			double auto_yscale = GetYScale(yres);
			double native_ratio = ((double)NWIDTH) / s_tlines;
			double screen_ratio = ((double)xres) / yres;
			int keep_ratio;
            
			g_config->getOption("SDL.KeepRatio", &keep_ratio);
            
			// Try to choose resolution
			if (screen_ratio < native_ratio)
			{
				// The screen is narrower than the original. Maximizing width will not clip
				auto_xscale = auto_yscale = GetXScale(xres);
				if (keep_ratio) 
					auto_yscale = GetYScale(yres);
			}
			else
			{
				auto_yscale = auto_xscale = GetYScale(yres);
				if (keep_ratio) 
					auto_xscale = GetXScale(xres);
			}
			s_exs = auto_xscale;
			s_eys = auto_yscale;
		}
		else
		{
			g_config->getOption("SDL.XScale", &s_exs);
			g_config->getOption("SDL.YScale", &s_eys);
		}
		g_config->getOption("SDL.SpecialFX", &s_eefx);

#ifdef OPENGL
		if(!s_useOpenGL) {
			s_exs = (int)s_exs;
			s_eys = (int)s_eys;
		} else {
			desbpp = 0;
		}
        
		// -Video Modes Tag-
		if(s_sponge) {
			if(s_sponge == 4 || s_sponge == 5) {
				s_exs = s_eys = 3;
			} else {
				s_exs = s_eys = 2;
			}
			s_eefx = 0;
			if(s_sponge == 1 || s_sponge == 4) {
				desbpp = 32;
			}
		}

		if((s_useOpenGL && !xstretch) || !s_useOpenGL)
#endif
			if(xres < (NWIDTH * s_exs) || s_exs <= 0.01) {
				FCEUD_PrintError("xscale out of bounds.");
				KillVideo();
				return -1;
			}

#ifdef OPENGL
		if((s_useOpenGL && !ystretch) || !s_useOpenGL)
#endif
			if(yres < s_tlines * s_eys || s_eys <= 0.01) {
				FCEUD_PrintError("yscale out of bounds.");
				KillVideo();
				return -1;
			}

#ifdef OPENGL
		s_screen = SDL_SetVideoMode(s_useOpenGL ? s_nativeWidth : xres,
									s_useOpenGL ? s_nativeHeight : yres,
									desbpp, flags);
#else
		s_screen = SDL_SetVideoMode(xres, yres, desbpp, flags);
#endif

		if(!s_screen) {
			FCEUD_PrintError(SDL_GetError());
			return -1;
		}
	} else {
		int desbpp;
		g_config->getOption("SDL.BitsPerPixel", &desbpp);

		g_config->getOption("SDL.XScale", &s_exs);
		g_config->getOption("SDL.YScale", &s_eys);
		g_config->getOption("SDL.SpecialFX", &s_eefx);
        
		// -Video Modes Tag-
		if(s_sponge) {
			if(s_sponge >= 4) {
				s_exs = s_eys = 3;
			} else {
				s_exs = s_eys = 2;
			}
			s_eefx = 0;
		}

#ifdef OPENGL
		if(!s_useOpenGL) {
			s_exs = (int)s_exs;
			s_eys = (int)s_eys;
		}
		if(s_exs <= 0.01) {
			FCEUD_PrintError("xscale out of bounds.");
			KillVideo();
			return -1;
		}
		if(s_eys <= 0.01) {
			FCEUD_PrintError("yscale out of bounds.");
			KillVideo();
			return -1;
		}
		if(s_sponge && s_useOpenGL) {
			FCEUD_PrintError("scalers not compatible with openGL mode.");
			KillVideo();
			return -1;
		}
#endif

#if defined(_GTK) && defined(SDL_VIDEO_DRIVER_X11)
		if(noGui == 0)
		{
			while (gtk_events_pending())
				gtk_main_iteration_do(FALSE);
        
			char SDL_windowhack[128];
			sprintf(SDL_windowhack, "SDL_WINDOWID=%u", (unsigned int)GDK_WINDOW_XID(gtk_widget_get_window(evbox)));
			SDL_putenv(SDL_windowhack);
        
			// init SDL video
			if (SDL_WasInit(SDL_INIT_VIDEO))
				SDL_QuitSubSystem(SDL_INIT_VIDEO);
			if ( SDL_InitSubSystem(SDL_INIT_VIDEO) < 0 )
			{
				fprintf(stderr, "Couldn't init SDL video: %s\n", SDL_GetError());
				gtk_main_quit();
			}
		}
#endif
        
		s_screen = SDL_SetVideoMode((int)(NWIDTH * s_exs),
								(int)(s_tlines * s_eys),
								desbpp, flags);
		if(!s_screen) {
			FCEUD_PrintError(SDL_GetError());
			return -1;
		}

#ifdef _GTK
		if(noGui == 0)
		{
			GtkRequisition req;
			gtk_widget_size_request(GTK_WIDGET(MainWindow), &req);
			gtk_window_resize(GTK_WINDOW(MainWindow), req.width, req.height);
		 }
#endif
		 }
	s_curbpp = s_screen->format->BitsPerPixel;
	if(!s_screen) {
		FCEUD_PrintError(SDL_GetError());
		KillVideo();
		return -1;
	}

#if 0
	// XXX soules - this would be creating a surface on the video
    //              card, but was commented out for some reason...
    s_BlitBuf = SDL_CreateRGBSurface(SDL_HWSURFACE, 256, 240,
                                     s_screen->format->BitsPerPixel,
                                     s_screen->format->Rmask,
                                     s_screen->format->Gmask,
                                     s_screen->format->Bmask, 0);
#endif

	FCEU_printf(" Video Mode: %d x %d x %d bpp %s\n",
				s_screen->w, s_screen->h, s_screen->format->BitsPerPixel,
				s_fullscreen ? "full screen" : "");

	if(s_curbpp != 8 && s_curbpp != 16 && s_curbpp != 24 && s_curbpp != 32) {
		FCEU_printf("  Sorry, %dbpp modes are not supported by FCE Ultra.  Supported bit depths are 8bpp, 16bpp, and 32bpp.\n", s_curbpp);
		KillVideo();
		return -1;
	}

	// if the game being run has a name, set it as the window name
	if(gi)
	{
		if(gi->name) {
			SDL_WM_SetCaption((const char *)gi->name, (const char *)gi->name);
		} else {
			SDL_WM_SetCaption(FCEU_NAME_AND_VERSION,"FCE Ultra");
		}
	}

	// create the surface for displaying graphical messages
#ifdef LSB_FIRST
	s_IconSurface = SDL_CreateRGBSurfaceFrom((void *)fceu_playicon.pixel_data,
											32, 32, 24, 32 * 3,
											0xFF, 0xFF00, 0xFF0000, 0x00);
#else
	s_IconSurface = SDL_CreateRGBSurfaceFrom((void *)fceu_playicon.pixel_data,
											32, 32, 24, 32 * 3,
											0xFF0000, 0xFF00, 0xFF, 0x00);
#endif
	SDL_WM_SetIcon(s_IconSurface,0);
	s_paletterefresh = 1;

	// XXX soules - can't SDL do this for us?
	 // if using more than 8bpp, initialize the conversion routines
	if(s_curbpp > 8) {
	InitBlitToHigh(s_curbpp >> 3,
						s_screen->format->Rmask,
						s_screen->format->Gmask,
						s_screen->format->Bmask,
						s_eefx, s_sponge, 0);
#ifdef OPENGL
		if(s_useOpenGL) 
		{
			int openGLip;
			g_config->getOption("SDL.OpenGLip", &openGLip);

			if(!InitOpenGL(NOFFSET, 256 - (s_clipSides ? 8 : 0),
						s_srendline, s_erendline + 1,
						s_exs, s_eys, s_eefx,
						openGLip, xstretch, ystretch, s_screen)) 
			{
				FCEUD_PrintError("Error initializing OpenGL.");
				KillVideo();
				return -1;
			}
		}
#endif
	}
Ejemplo n.º 3
0
static void FixFL(void)
{
 FCEUI_GetCurrentVidSystem(&srendline,&erendline);
 totallines=erendline-srendline+1;
}
Ejemplo n.º 4
0
int FCEUI_AviBegin(const char* fname)
{
	FCEUI_AviEnd();

	struct VideoSystemInfo vsi;
	BITMAPINFOHEADER bi;
	int is_pal;

	is_pal=FCEUI_GetCurrentVidSystem(&vsi.start_scanline, &vsi.end_scanline);
	vsi.fps = FCEUI_GetDesiredFPS();//is_pal ? 50 : 60;
	vsi.end_scanline++;

	memset(&bi, 0, sizeof(bi));
	bi.biSize = sizeof(BITMAPINFOHEADER);    
	bi.biPlanes = 1;
	bi.biBitCount = 24;
	bi.biWidth = VIDEO_WIDTH;
	bi.biHeight = vsi.end_scanline-vsi.start_scanline;
	bi.biSizeImage = 3 * bi.biWidth * bi.biHeight;

	//mbg 6/27/08 -- this was originally labeled as hacky..
	WAVEFORMATEX wf;
	wf.cbSize = sizeof(WAVEFORMATEX);
	wf.nAvgBytesPerSec = soundrate * 2;
	wf.nBlockAlign = 2;
	wf.nChannels = 1;
	wf.nSamplesPerSec = soundrate;
	wf.wBitsPerSample = 16;
	wf.wFormatTag = WAVE_FORMAT_PCM;
	

	saved_avi_ext[0]='\0';

	//mbg 8/10/08 - decide whether there will be sound in this movie
	//if this is a new movie..
	if(!avi_file) {
		if(FSettings.SndRate)
			use_sound = true;
		else use_sound = false;
	}

	//mbg 8/10/08 - if there is no sound in this movie, then dont open the audio stream
	WAVEFORMATEX* pwf = &wf;
	if(!use_sound)
		pwf = 0;


	if(!avi_open(fname, &bi, pwf, &vsi))
	{
		saved_avi_fname[0]='\0';
		return 0;
	}

	// Don't display at file splits
	if(!avi_segnum)
		FCEU_DispMessage("AVI recording started.",0);

	strncpy(saved_cur_avi_fnameandext,fname,MAX_PATH);
	strncpy(saved_avi_fname,fname,MAX_PATH);
	char* dot = strrchr(saved_avi_fname, '.');
	if(dot && dot > strrchr(saved_avi_fname, '/') && dot > strrchr(saved_avi_fname, '\\'))
	{
		strcpy(saved_avi_ext,dot);
		dot[0]='\0';
	}
	return 1;
}
Ejemplo n.º 5
0
int InitVideo(FCEUGI *gi)
{
	// This is a big TODO.  Stubbing this off into its own function,
	// as the SDL surface routines have changed drastically in SDL2
	// TODO - SDL2
	const char * window_name;
	int error, flags = 0;
	int doublebuf, xstretch, ystretch, xres, yres, show_fps;
	uint32_t  Amask, Rmask, Gmask, Bmask;
	int   bpp;

	FCEUI_printf("Initializing video (SDL2.x) ...");

	// load the relevant configuration variables
	g_config->getOption("SDL.Fullscreen", &s_fullscreen);
	g_config->getOption("SDL.DoubleBuffering", &doublebuf);
#ifdef OPENGL
	g_config->getOption("SDL.OpenGL", &s_useOpenGL);
#endif
	g_config->getOption("SDL.SpecialFilter", &s_sponge);
	g_config->getOption("SDL.XStretch", &xstretch);
	g_config->getOption("SDL.YStretch", &ystretch);
	g_config->getOption("SDL.LastXRes", &xres);
	g_config->getOption("SDL.LastYRes", &yres);
	g_config->getOption("SDL.ClipSides", &s_clipSides);
	g_config->getOption("SDL.NoFrame", &noframe);
	g_config->getOption("SDL.ShowFPS", &show_fps);

	// check the starting, ending, and total scan lines
	FCEUI_GetCurrentVidSystem(&s_srendline, &s_erendline);
	s_tlines = s_erendline - s_srendline + 1;

#if OPENGL
	if( !s_useOpenGL || s_sponge )
	{
		FCEUD_PrintError("SDL2 Does not support non-OpenGL rendering or special filters\n");
		KillVideo();
		return -1;
	}
#endif

	// initialize the SDL video subsystem if it is not already active
	if(!SDL_WasInit(SDL_INIT_VIDEO)) {
		error = SDL_InitSubSystem(SDL_INIT_VIDEO);
		if(error) {
			FCEUD_PrintError(SDL_GetError());
			return -1;
		}
	}
	s_inited = 1;

	// For simplicity, hard-code this to 32bpp for now...
	s_curbpp = 32;

	// If game is running, set window name accordingly
	if( gi )
	{
		window_name = (const char *) gi->name;
	}
	else
	{
		window_name = "FCE Ultra";
	}

	s_exs = 1.0;
	s_eys = 1.0;
	if(s_fullscreen) {
		s_window = SDL_CreateWindow( window_name,
		                             SDL_WINDOWPOS_UNDEFINED,
		                             SDL_WINDOWPOS_UNDEFINED,
		                             0, 0,  // Res not specified in full-screen mode
		                             SDL_WINDOW_FULLSCREEN_DESKTOP);
	} else {
#if defined(_GTK) && defined(SDL_VIDEO_DRIVER_X11)
		if(noGui == 0 && strcmp(SDL_GetCurrentVideoDriver(), "x11") == 0) {
			s_window = SDL_CreateWindowFrom((void*)GDK_WINDOW_XID (gtk_widget_get_window(evbox)));
		}
		else
#endif
			s_window = SDL_CreateWindow( window_name,
				                         SDL_WINDOWPOS_UNDEFINED,
				                         SDL_WINDOWPOS_UNDEFINED,
				                         xres, yres,
				                         0);
	}

	// This stuff all applies regardless of full-screen vs windowed mode.
	s_renderer =  SDL_CreateRenderer(s_window, -1, 0);

	// Set logical rendering size & specify scaling mode.  All rendering is
	// now done to the renderer rather than directly to the screen surface.
	// The renderer takes care of any scaling necessary.
	//
	// NOTE: setting scale quality to "nearest" will result in a blown-up but
	// pixelated while "linear" will tend to blur everything.
	SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "nearest");
	SDL_RenderSetLogicalSize(s_renderer, xres, yres);


	//
	// Create the texture that will ultimately be rendered.
	// s_screen is used to build up an image, then the texture will be updated
	// all at once when it's ready
	s_texture = SDL_CreateTexture(s_renderer,
	                              SDL_PIXELFORMAT_ARGB8888,
	                              SDL_TEXTUREACCESS_STREAMING,
	                              xres, yres);
	//
	// Create a surface to draw pixels onto
	//
	SDL_PixelFormatEnumToMasks(SDL_PIXELFORMAT_ARGB8888, &bpp, &Rmask, &Gmask, &Bmask, &Amask);
	s_screen = SDL_CreateRGBSurface(0, xres, yres, bpp,
	                                Rmask, Gmask, Bmask, Amask);

	if( !s_screen )
	{
		FCEUD_PrintError(SDL_GetError());
		return -1;
	}

	//
	// Setup Icon surface
	//
#ifdef LSB_FIRST
	s_IconSurface = SDL_CreateRGBSurfaceFrom((void *)fceu_playicon.pixel_data,
	                32, 32, 24, 32 * 3,
	                0xFF, 0xFF00, 0xFF0000, 0x00);
#else
	s_IconSurface = SDL_CreateRGBSurfaceFrom((void *)fceu_playicon.pixel_data,
	                32, 32, 24, 32 * 3,
	                0xFF0000, 0xFF00, 0xFF, 0x00);
#endif

	SDL_SetWindowIcon(s_window, s_IconSurface);

	s_paletterefresh = 1;   // Force palette refresh

	// always init blit to high since bpp forced to 32 for now.
	InitBlitToHigh(s_curbpp >> 3,
	               s_screen->format->Rmask,
	               s_screen->format->Gmask,
	               s_screen->format->Bmask,
	               0, //s_eefx,  Hard-code SFX off
	               0, //s_sponge,  Hard-code special filters off.
	               0);

	return 0;
}
Ejemplo n.º 6
0
void FCEUI_SaveMovie(char *fname, uint8 flags, const char* metadata)
{
    FILE *fp;
    char *fn;
    int poweron=0;
    uint8 padding[4] = {0,0,0,0};
    int n_padding;

    FCEUI_StopMovie();

    char origname[512];
    if(fname)
    {
        fp = FCEUD_UTF8fopen(fname, "wb");
        strcpy(origname,fname);
    }
    else
    {
        fp=FCEUD_UTF8fopen(fn=FCEU_MakeFName(FCEUMKF_MOVIE,CurrentMovie,0),"wb");
        strcpy(origname,fn);
        free(fn);
    }

    if(!fp) return;

// don't need the movieSyncHackOn sync hack for newly recorded movies
    flags |= MOVIE_FLAG_NOSYNCHACK;
    resetDMCacc=movieSyncHackOn=0;

// add PAL flag
    if(FCEUI_GetCurrentVidSystem(0,0))
        flags |= MOVIE_FLAG_PAL;

    if(flags & MOVIE_FLAG_FROM_POWERON)
    {
        poweron=1;
        flags &= ~MOVIE_FLAG_FROM_POWERON;
        flags |= MOVIE_FLAG_FROM_RESET;
    }

// write header
    write32le(MOVIE_MAGIC, fp);
    write32le(MOVIE_VERSION, fp);
    fputc(flags, fp);
    fputc(0, fp);                      // reserved
    fputc(0, fp);                      // reserved
    fputc(0, fp);                      // reserved
    write32le(0, fp);                  // leave room for length frames
    write32le(0, fp);                  // leave room for rerecord count
    write32le(0, fp);                  // leave room for movie data size
    write32le(0, fp);                  // leave room for savestate_offset
    write32le(0, fp);                  // leave room for offset_to_controller_data
    fwrite(FCEUGameInfo->MD5, 1, 16, fp);	// write ROM checksum
    write32le(FCEU_VERSION_NUMERIC, fp);	// write emu version used
    fputs(FileBase, fp);					// write ROM name used
    fputc(0, fp);
    if(metadata)
    {
        if(strlen(metadata) < MOVIE_MAX_METADATA)
            fputs(metadata, fp);
        else
            fwrite(metadata, 1, MOVIE_MAX_METADATA-1, fp);
    }
    fputc(0, fp);

// add padding
    n_padding = (4 - (ftell(fp) & 0x3)) & 0x3;
    fwrite(padding, 1, n_padding, fp);

    if(flags & MOVIE_FLAG_FROM_RESET)
    {
        if(poweron)
        {
            // make a for-movie-recording power-on clear the game's save data, too
            // (note: FCEU makes a save state immediately after this and that loads that on movie playback)
            extern char lastLoadedGameName [2048];
            extern int disableBatteryLoading, suppressAddPowerCommand;
            suppressAddPowerCommand=1;
            disableBatteryLoading=1;
            suppressMovieStop=1;
            {
                // NOTE:  this will NOT write an FCEUNPCMD_POWER into the movie file
                FCEUGI * gi = FCEUI_LoadGame(lastLoadedGameName);
                if(!gi)
                    PowerNES(); // and neither will this, if it can even happen
            }
            suppressMovieStop=0;
            disableBatteryLoading=0;
            suppressAddPowerCommand=0;
        }
    }

    savestate_offset = ftell(fp);
    FCEUSS_SaveFP(fp);
    fseek(fp, 0, SEEK_END);

    ResetInputTypes();

// add padding
    n_padding = (4 - (ftell(fp) & 0x3)) & 0x3;
    fwrite(padding, 1, n_padding, fp);

    firstframeoffset = ftell(fp);

// finish header
    fseek(fp, 24, SEEK_SET);			// offset_to_savestate offset
    write32le(savestate_offset, fp);
    write32le(firstframeoffset, fp);

    fseek(fp, firstframeoffset, SEEK_SET);

// set recording flag
    current=CurrentMovie;

    movie_readonly = 0;
    frameptr = 0;
    framecount = 0;
    rerecord_count = 0;
    slots[current] = fp;
    memset(joop,0,sizeof(joop));
    current++;
    framets=0;
    nextd = -1;

// trigger a reset
    if(flags & MOVIE_FLAG_FROM_RESET)
    {
        if(poweron)
        {
            PowerNES();							// NOTE:  this will write an FCEUNPCMD_POWER into the movie file
        }
        else
            ResetNES();							// NOTE:  this will write an FCEUNPCMD_RESET into the movie file
    }
    if(!fname)
        FCEUI_SelectMovie(CurrentMovie,1);       /* Quick hack to display status. */
    else
        FCEU_DispMessage("Movie recording started.");

    strcpy(curMovieFilename, origname);
}
Ejemplo n.º 7
0
static const char* convertToFCM(const char *fname, char *buffer)
{
#ifdef WIN32
    justAutoConverted=0;

    // convert to fcm if not already
    const char* dot = strrchr(fname, '.');
    if(dot)
    {
        int fmv = !stricmp(dot, ".fmv");
        int nmv = !stricmp(dot, ".nmv");
        int vmv = !stricmp(dot, ".vmv");
        if(fmv || nmv || vmv)
        {
            strcpy(buffer, fname);
            buffer[dot-fname]='\0';
            strcat(buffer,"-autoconverted.fcm");

            int fceuver=0;
            if(fmv)
                fceuver=1;
            else if(nmv)
                fceuver=2;
            else if(vmv)
                fceuver=3;

            extern char lastLoadedGameName [2048];
            char cmd [1024], offset[64], romInfo[1024];
            if(movieConvertOK)
                sprintf(romInfo, "-smd5=\"%s\" -sromname=\"%s (MAYBE)\" -s", lastLoadedGameName, FileBase);
            else
                sprintf(romInfo, "-sromname=\"(unknown)\" -s");
            if(movieConvertOffset2) sprintf(offset, "-o %d:%d", movieConvertOffset2,movieConvertOffset1);
            else sprintf(offset, "-o %d", movieConvertOffset1);
            sprintf(cmd, ".\\util\\nesmock\\nesmock.exe %s %s -spal=%c -sfceuver=%d \"%s\" \"%s\" ", offset, romInfo, FCEUI_GetCurrentVidSystem(0,0)?'1':'0', fceuver, fname, buffer);
//				FCEU_PrintError(cmd);
            executeCommand(cmd);

            FILE* file = FCEUD_UTF8fopen(buffer,"rb");
            if(file)
            {
                fseek(file, 12, SEEK_SET);
                int frames=0;
                read32le(&frames, file);
                if(frames)
                {
                    fname = buffer;
                    justAutoConverted=1;
                }
                else
                {
                    static int errAlready=0;
                    if(!errAlready)
                    {
                        errAlready=1;
                        FCEU_PrintError("For some reason, nesmock was unable to create a valid FCM from the given file.\nThe command given was:\n%s\nPerhaps the file specified is not a movie file or contains no input data,\nor perhaps it is a movie file of a version unsupported by nesmock.\n\n(This error message will self-destruct until you restart FCEU.)", cmd);
                    }
                }
                fclose(file);
            }
            else
            {
                char str [512];
                str[0] = '\0';
                GetCurrentDirectory(512,str);
                strcat(str, "\\util\\nesmock\\nesmock.exe");
                file = FCEUD_UTF8fopen(str, "rb");
                if(file)
                {
                    static int errAlready=0;
                    if(!errAlready)
                    {
                        errAlready=1;
                        FCEU_PrintError("For some reason, nesmock was unable to convert the movie to FCM format.\nThe command given was:\n%s\n\n(This error message will self-destruct until you restart FCEU.)", cmd);
                        fclose(file);
                    }
                }
                else
                {
                    static int errAlready=0;
                    if(!errAlready)
                    {
                        errAlready=1;
                        FCEU_PrintError("Nesmock not found, so the movie could not be converted to FCM format.\nYou must place nesmock.exe at this location so FCEU can find it:\n%s\n\n(This error message will self-destruct until you restart FCEU.)", str);
                    }
                }
            }
        }
    }
#endif
    return fname;
}
Ejemplo n.º 8
0
void UpdateReplayDialog(HWND hwndDlg)
{
	int doClear=1;
	char *fn=GetReplayPath(hwndDlg);

	// remember the previous setting for the read-only checkbox
	replayReadOnlySetting = (SendDlgItemMessage(hwndDlg, IDC_CHECK_READONLY, BM_GETCHECK, 0, 0) == BST_CHECKED);

	EnableWindow(GetDlgItem(hwndDlg,IDC_BUTTON_METADATA),FALSE);

	if(fn)
	{
		MOVIE_INFO info;

		FCEUFILE* fp = FCEU_fopen(fn,0,"rb",0);
		fp->stream = fp->stream->memwrap();
		bool isarchive = FCEU_isFileInArchive(fn);
		bool ismovie = FCEUI_MovieGetInfo(fp, info, false);
		delete fp;
		if(ismovie)
		{
			char tmp[256];
			double div;

			sprintf(tmp, "%u", (unsigned)info.num_frames);
			SetWindowTextA(GetDlgItem(hwndDlg,IDC_LABEL_FRAMES), tmp);                   // frames
			SetDlgItemText(hwndDlg,IDC_EDIT_STOPFRAME,tmp);
			stopframeWasEditedByUser = false;

			EnableWindow(GetDlgItem(hwndDlg,IDC_CHECK_READONLY),TRUE);

			div = (FCEUI_GetCurrentVidSystem(0,0)) ? 50.006977968268290849 : 60.098813897440515532;				// PAL timing
			double tempCount = (info.num_frames / div) + 0.005; // +0.005s for rounding
			int num_seconds = (int)tempCount;
			int fraction = (int)((tempCount - num_seconds) * 100);
			int seconds = num_seconds % 60;
			int minutes = (num_seconds / 60) % 60;
			int hours = (num_seconds / 60 / 60) % 60;
			sprintf(tmp, "%02d:%02d:%02d.%02d", hours, minutes, seconds, fraction);
			SetWindowTextA(GetDlgItem(hwndDlg,IDC_LABEL_LENGTH), tmp);                   // length

			sprintf(tmp, "%u", (unsigned)info.rerecord_count);
			SetWindowTextA(GetDlgItem(hwndDlg,IDC_LABEL_UNDOCOUNT), tmp);                   // rerecord

			SendDlgItemMessage(hwndDlg,IDC_CHECK_READONLY,BM_SETCHECK,(replayReadOnlySetting ? BST_CHECKED : BST_UNCHECKED), 0);

			SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_RECORDEDFROM),info.poweron ? "Power-On" : (info.reset?"Soft-Reset":"Savestate"));

			if(isarchive) {
				EnableWindow(GetDlgItem(hwndDlg,IDC_CHECK_READONLY),FALSE);
				Button_SetCheck(GetDlgItem(hwndDlg,IDC_CHECK_READONLY),BST_CHECKED);
			} else 
				EnableWindow(GetDlgItem(hwndDlg,IDC_CHECK_READONLY),TRUE);

			//-----------
			//mbg 5/26/08 - getting rid of old movie formats

			//if(info.movie_version > 1)
			//{
				char emuStr[128];
				SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_ROMUSED),info.name_of_rom_used.c_str());
				SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_ROMCHECKSUM),md5_asciistr(info.md5_of_rom_used));
				char boolstring[4] = "On ";
				if (!info.pal)
					strcpy(boolstring, "Off");
				SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_PALUSED),boolstring);
				if (info.ppuflag)
					strcpy(boolstring, "On ");
				else
					strcpy(boolstring, "Off");
				SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_NEWPPUUSED),boolstring);



				if(info.emu_version_used < 20000 )
					sprintf(emuStr, "FCEU %d.%02d.%02d%s", info.emu_version_used/10000, (info.emu_version_used/100)%100, (info.emu_version_used)%100, info.emu_version_used < 9813 ? " (blip)" : "");
				else 
					sprintf(emuStr, "FCEUX %d.%02d.%02d", info.emu_version_used/10000, (info.emu_version_used/100)%100, (info.emu_version_used)%100);
				//else
				//{
				//	if(info.emu_version_used == 1)
				//		strcpy(emuStr, "Famtasia");
				//	else if(info.emu_version_used == 2)
				//		strcpy(emuStr, "Nintendulator");
				//	else if(info.emu_version_used == 3)
				//		strcpy(emuStr, "VirtuaNES");
				//	else
				//	{
				//		strcpy(emuStr, "(unknown)");
				//		char* dot = strrchr(fn,'.');
				//		if(dot)
				//		{
				//			if(!stricmp(dot,".fmv"))
				//				strcpy(emuStr, "Famtasia? (unknown version)");
				//			else if(!stricmp(dot,".nmv"))
				//				strcpy(emuStr, "Nintendulator? (unknown version)");
				//			else if(!stricmp(dot,".vmv"))
				//				strcpy(emuStr, "VirtuaNES? (unknown version)");
				//			else if(!stricmp(dot,".fcm"))
				//				strcpy(emuStr, "FCEU? (unknown version)");
				//		}
				//	}
				//}
				SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_EMULATORUSED),emuStr);
			//}
			//else
			//{
			//	SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_ROMUSED),"unknown");
			//	SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_ROMCHECKSUM),"unknown");
			//	SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_EMULATORUSED),"FCEU 0.98.10 (blip)");
			//}
			//--------------------

			SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_CURRCHECKSUM),md5_asciistr(GameInfo->MD5));

			// enable OK and metadata
			EnableWindow(GetDlgItem(hwndDlg,IDOK),TRUE);  
			EnableWindow(GetDlgItem(hwndDlg,IDC_BUTTON_METADATA),TRUE);
			currComments = info.comments;
			currSubtitles = info.subtitles;

			doClear = 0;
		}

		free(fn);
	}
	else
	{
		EnableWindow(GetDlgItem(hwndDlg,IDC_EDIT_OFFSET),FALSE);
		EnableWindow(GetDlgItem(hwndDlg,IDC_EDIT_FROM),FALSE);
	}

	if(doClear)
	{
		SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_LENGTH),"");
		SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_FRAMES),"");
		SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_UNDOCOUNT),"");
		SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_ROMUSED),"");
		SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_ROMCHECKSUM),"");
		SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_RECORDEDFROM),"");
		SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_EMULATORUSED),"");
		SetWindowText(GetDlgItem(hwndDlg,IDC_LABEL_CURRCHECKSUM),md5_asciistr(GameInfo->MD5));
		SetDlgItemText(hwndDlg,IDC_EDIT_STOPFRAME,""); stopframeWasEditedByUser=false;
		EnableWindow(GetDlgItem(hwndDlg,IDC_CHECK_READONLY),FALSE);
		EnableWindow(GetDlgItem(hwndDlg,IDOK),FALSE);
	}
}