Cleaned up some code.

This commit is contained in:
rheiny 2007-02-06 18:59:15 +00:00
parent e163d2cd87
commit 62efccb998
7 changed files with 779 additions and 545 deletions

View File

@ -31,16 +31,16 @@
**/
static CFGSTRUCT fceuconfig[] = {
ACS(rfiles[0]),
ACS(rfiles[1]),
ACS(rfiles[2]),
ACS(rfiles[3]),
ACS(rfiles[4]),
ACS(rfiles[5]),
ACS(rfiles[6]),
ACS(rfiles[7]),
ACS(rfiles[8]),
ACS(rfiles[9]),
ACS(recent_files[0]),
ACS(recent_files[1]),
ACS(recent_files[2]),
ACS(recent_files[3]),
ACS(recent_files[4]),
ACS(recent_files[5]),
ACS(recent_files[6]),
ACS(recent_files[7]),
ACS(recent_files[8]),
ACS(recent_files[9]),
ACS(rdirs[0]),
ACS(rdirs[1]),

Binary file not shown.

View File

@ -4,8 +4,18 @@
//
#define GUI_BOT_CLOSE 1
#define GUI_BOT_VALUES 2
#define MENU_OPEN_FILE 100
#define MENU_CLOSE_FILE 101
#define IDI_ICON1 101
#define IDI_ICON2 102
#define MENU_RECENT_FILES 102
#define MENU_SAVE_STATE 110
#define MENU_LOAD_STATE 111
#define MENU_RECORD_MOVIE 141
#define MENU_REPLAY_MOVIE 142
#define MENU_STOP_MOVIE 143
#define MENU_RECORD_AVI 151
#define MENU_STOP_AVI 152
#define GUI_BOT_A_1 1000
#define GUI_BOT_B_1 1001
#define GUI_BOT_SELECT_1 1002
@ -141,7 +151,7 @@
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 103
#define _APS_NEXT_COMMAND_VALUE 40013
#define _APS_NEXT_COMMAND_VALUE 40023
#define _APS_NEXT_CONTROL_VALUE 1117
#define _APS_NEXT_SYMED_VALUE 101
#endif

View File

@ -1,38 +1,52 @@
/**
* Show an Save File dialog and save a savegame state to the selected file.
**/
void FCEUD_SaveStateAs(void)
{
const char filter[]="FCE Ultra Save State(*.fc?)\0*.fc?\0";
char nameo[2048];
OPENFILENAME ofn;
const char filter[] = "FCE Ultra Save State(*.fc?)\0*.fc?\0";
char nameo[2048];
OPENFILENAME ofn;
memset(&ofn,0,sizeof(ofn));
ofn.lStructSize=sizeof(ofn);
ofn.hInstance=fceu_hInstance;
ofn.lpstrTitle="Save State As...";
ofn.lpstrFilter=filter;
nameo[0]=0;
ofn.lpstrFile=nameo;
ofn.nMaxFile=256;
ofn.Flags=OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY;
if(GetSaveFileName(&ofn))
FCEUI_SaveState(nameo);
memset(&ofn, 0, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hInstance = fceu_hInstance;
ofn.lpstrTitle = "Save State As...";
ofn.lpstrFilter = filter;
nameo[0] = 0;
ofn.lpstrFile = nameo;
ofn.nMaxFile = 256;
ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
if(GetSaveFileName(&ofn))
{
FCEUI_SaveState(nameo);
}
}
/**
* Show an Open File dialog and load a savegame state from the selected file.
**/
void FCEUD_LoadStateFrom(void)
{
const char filter[]="FCE Ultra Save State(*.fc?)\0*.fc?\0";
char nameo[2048];
OPENFILENAME ofn;
const char filter[]="FCE Ultra Save State(*.fc?)\0*.fc?\0";
char nameo[2048];
OPENFILENAME ofn;
memset(&ofn,0,sizeof(ofn));
ofn.lStructSize=sizeof(ofn);
ofn.hInstance=fceu_hInstance;
ofn.lpstrTitle="Load State From...";
ofn.lpstrFilter=filter;
nameo[0]=0;
ofn.lpstrFile=nameo;
ofn.nMaxFile=256;
ofn.Flags=OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY;
if(GetOpenFileName(&ofn))
FCEUI_LoadState(nameo);
// Create and show an Open File dialog.
memset(&ofn,0,sizeof(ofn));
ofn.lStructSize=sizeof(ofn);
ofn.hInstance=fceu_hInstance;
ofn.lpstrTitle="Load State From...";
ofn.lpstrFilter=filter;
nameo[0]=0;
ofn.lpstrFile=nameo;
ofn.nMaxFile=256;
ofn.Flags=OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY;
if(GetOpenFileName(&ofn))
{
// Load save state if a file was selected.
FCEUI_LoadState(nameo);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -127,14 +127,18 @@ int FCEUMOV_ShouldPause(void)
int suppressMovieStop=0;
int movieConvertOffset1=0, movieConvertOffset2=0,movieConvertOK=0,movieSyncHackOn=0;
/**
* Stop movie playback.
**/
static void StopPlayback(void)
{
if(suppressMovieStop)
return;
resetDMCacc=movieSyncHackOn=0;
fclose(slots[-1 - current]);
current=0;
FCEU_DispMessage("Movie playback stopped.");
if(suppressMovieStop)
return;
resetDMCacc = movieSyncHackOn = 0;
fclose(slots[-1 - current]);
current = 0;
FCEU_DispMessage("Movie playback stopped.");
}
void MovieFlushHeader(void)
@ -211,28 +215,47 @@ void MovieFlushHeader(void)
fseek(fp, loc, SEEK_SET);
}
static void StopRecording(void)
/**
* Stop movie recording
**/
void StopRecording(void)
{
if(suppressMovieStop)
return;
resetDMCacc=movieSyncHackOn=0;
DoEncode(0,0,1); /* Write a dummy timestamp value so that the movie will keep
"playing" after user input has stopped. */
// finish header
MovieFlushHeader();
if(suppressMovieStop)
{
return;
}
// FIXME: truncate movie to length
// ftruncate();
fclose(slots[current - 1]);
MovieStatus[current - 1] = 1;
current=0;
FCEU_DispMessage("Movie recording stopped.");
resetDMCacc = movieSyncHackOn = 0;
DoEncode(0,0,1); /* Write a dummy timestamp value so that the movie will keep
"playing" after user input has stopped. */
// finish header
MovieFlushHeader();
// FIXME: truncate movie to length
// ftruncate();
fclose(slots[current - 1]);
MovieStatus[current - 1] = 1;
current = 0;
FCEU_DispMessage("Movie recording stopped.");
}
void FCEUI_StopMovie(void)
/**
* Stop movie recording or movie playback.
**/
void FCEUI_StopMovie()
{
if(current < 0) StopPlayback();
if(current > 0) StopRecording();
if(current < 0)
{
StopPlayback();
}
if(current > 0)
{
StopRecording();
}
}
#ifdef MSVC

View File

@ -639,36 +639,44 @@ int loadStateFailed = 0; // hack, this function should return a value instead
void FCEUI_LoadState(char *fname)
{
StateShow=0;
loadStateFailed=0;
StateShow = 0;
loadStateFailed = 0;
/* For network play, be load the state locally, and then save the state to a temporary file,
and send that. This insures that if an older state is loaded that is missing some
information expected in newer save states, desynchronization won't occur(at least not
from this ;)).
*/
if(FCEUSS_Load(fname))
{
if(FCEUnetplay)
{
char *fn=FCEU_MakeFName(FCEUMKF_NPTEMP,0,0);
FILE *fp;
/* For network play, be load the state locally, and then save the state to a temporary file,
and send that. This insures that if an older state is loaded that is missing some
information expected in newer save states, desynchronization won't occur(at least not
from this ;)).
*/
if((fp=fopen(fn,"wb")))
{
if(FCEUSS_SaveFP(fp))
{
fclose(fp);
FCEUNET_SendFile(FCEUNPCMD_LOADSTATE, fn);
}
else fclose(fp);
unlink(fn);
}
free(fn);
}
}
else loadStateFailed=1;
if(FCEUSS_Load(fname))
{
if(FCEUnetplay)
{
char *fn = FCEU_MakeFName(FCEUMKF_NPTEMP, 0, 0);
FILE *fp;
if((fp = fopen(fn," wb")))
{
if(FCEUSS_SaveFP(fp))
{
fclose(fp);
FCEUNET_SendFile(FCEUNPCMD_LOADSTATE, fn);
}
else
{
fclose(fp);
}
unlink(fn);
}
free(fn);
}
}
else
{
loadStateFailed = 1;
}
}
void FCEU_DrawSaveStates(uint8 *XBuf)