diff --git a/desmume/ChangeLog b/desmume/ChangeLog index f5ced5b62..10a78796a 100644 --- a/desmume/ChangeLog +++ b/desmume/ChangeLog @@ -37,6 +37,7 @@ Gtk frontend: enh: switch all of menu/toolbar system to GtkAction + GtkUIManager enh: remove the gtglext 3d code enh: improve/speedup screen resize and final presentation logic in gtk frontend + enh: minimal rerecording hookups 0.9.1 -> 0.9.2 General/Core: diff --git a/desmume/src/NDSSystem.cpp b/desmume/src/NDSSystem.cpp index f69b87ad3..b69c2c95e 100644 --- a/desmume/src/NDSSystem.cpp +++ b/desmume/src/NDSSystem.cpp @@ -50,8 +50,8 @@ //#define USE_REAL_BIOS TCommonSettings CommonSettings; -static Driver _stub_driver; -Driver* driver = &_stub_driver; +static BaseDriver _stub_driver; +BaseDriver* driver = &_stub_driver; std::string InputDisplayString; static BOOL LidClosed = FALSE; diff --git a/desmume/src/SPU.cpp b/desmume/src/SPU.cpp index 923c7c0fe..31656f4d3 100644 --- a/desmume/src/SPU.cpp +++ b/desmume/src/SPU.cpp @@ -512,7 +512,7 @@ void SPU_struct::KeyOn(int channel) if(thischan.double_totlength_shifted == 0) { - printf("ERROR: Stopping channel %d due to zero length\n",channel); + printf("INFO: Stopping channel %d due to zero length\n",channel); thischan.status = CHANSTAT_STOPPED; int zzz=9; } diff --git a/desmume/src/commandline.cpp b/desmume/src/commandline.cpp index 3b0e90620..d67539911 100644 --- a/desmume/src/commandline.cpp +++ b/desmume/src/commandline.cpp @@ -26,6 +26,7 @@ #include #include "commandline.h" #include "types.h" +#include "movie.h" CommandLine::CommandLine() : error(NULL) @@ -111,7 +112,14 @@ void CommandLine::errorHelp(const char* binName) g_printerr("USAGE: %s --help - for help\n", binName); } -void foo() +void CommandLine::process_movieCommands() { - g_option_context_free(NULL); + if(play_movie_file != "") + { + FCEUI_LoadMovie(play_movie_file.c_str(),true,false,-1); + } + else if(record_movie_file != "") + { + FCEUI_SaveMovie(record_movie_file.c_str(), L""); + } } diff --git a/desmume/src/commandline.h b/desmume/src/commandline.h index a2aaa46a2..17d3da5dd 100644 --- a/desmume/src/commandline.h +++ b/desmume/src/commandline.h @@ -49,6 +49,9 @@ public: //validate the common commandline options bool validate(); + + //process movie play/record commands + void process_movieCommands(); //print a little help message for cases when erroneous commandlines are entered void errorHelp(const char* binName); diff --git a/desmume/src/driver.h b/desmume/src/driver.h index fbae6d3a9..2e459e6ee 100644 --- a/desmume/src/driver.h +++ b/desmume/src/driver.h @@ -27,9 +27,8 @@ #include "debug.h" #include -//this should be moved to a driver.h later, but for now, here they are. //each platform needs to implement this, although it doesnt need to implement any functions -class Driver { +class BaseDriver { public: virtual bool WIFI_Host_InitSystem() { return FALSE; } virtual void WIFI_Host_ShutdownSystem() {} @@ -38,6 +37,6 @@ public: virtual void USR_InfoMessage(const char *message) { LOG("%s\n", message); } virtual void AVI_SoundUpdate(void* soundData, int soundLen) {} }; -extern Driver* driver; +extern BaseDriver* driver; #endif //_DRIVER_H_ diff --git a/desmume/src/gtk/desmume.cpp b/desmume/src/gtk/desmume.cpp index 2802de056..622f98686 100644 --- a/desmume/src/gtk/desmume.cpp +++ b/desmume/src/gtk/desmume.cpp @@ -25,6 +25,7 @@ #include "sndsdl.h" #include "ctrlssdl.h" #include "desmume.h" +#include "movie.h" volatile BOOL execute = FALSE; BOOL click = FALSE; @@ -84,7 +85,9 @@ void desmume_cycle( void) /* Update keypad value */ update_keypad(keypad); + FCEUMOV_AddInputState(); NDS_exec(); SPU_Emulate_user(); + currFrameCounter++; //this needs to be moved into NDS_exec somehow } diff --git a/desmume/src/gtk/main.cpp b/desmume/src/gtk/main.cpp index 2aaf037b0..2a1443756 100644 --- a/desmume/src/gtk/main.cpp +++ b/desmume/src/gtk/main.cpp @@ -1,4 +1,4 @@ -/* main.c - this file is part of DeSmuME +/* main.cpp - this file is part of DeSmuME * * Copyright (C) 2006-2009 DeSmuME Team * Copyright (C) 2007 Pascal Giard (evilynux) @@ -42,6 +42,7 @@ #include "rasterize.h" #include "saves.h" #include "mic.h" +#include "movie.h" #include "dTool.h" #include "desmume_config.h" @@ -91,6 +92,9 @@ enum { gboolean EmuLoop(gpointer data); +static void RecordMovieDialog(); +static void PlayMovieDialog(); +static void StopMovie(); static void OpenNdsDialog(); static void SaveStateDialog(); static void LoadStateDialog(); @@ -121,6 +125,9 @@ static const char *ui_description = " " " " " " +" " +" " +" " " " " " " " @@ -230,6 +237,9 @@ static const GtkActionEntry action_entries[] = { { "open", "gtk-open", "_Open", "o", NULL, OpenNdsDialog }, { "savestateto", NULL, "Save state _to ...", NULL, NULL, SaveStateDialog }, { "loadstatefrom", NULL, "Load state _from ...", NULL, NULL, LoadStateDialog }, + { "recordmovie", NULL, "Record movie _to ...", NULL, NULL, RecordMovieDialog }, + { "playmovie", NULL, "Play movie _from ...", NULL, NULL, PlayMovieDialog }, + { "stopmovie", NULL, "Stop movie", NULL, NULL, StopMovie }, { "SavestateMenu", NULL, "_Save state" }, { "LoadstateMenu", NULL, "_Load state" }, #ifdef DESMUME_GTK_FIRMWARE_BROKEN @@ -651,6 +661,111 @@ static void LoadStateDialog() gtk_widget_destroy(pFileSelection); } +static void RecordMovieDialog() +{ + GtkFileFilter *pFilter_dsm, *pFilter_any; + GtkWidget *pFileSelection; + GtkWidget *pParent; + gchar *sPath; + + if (desmume_running()) + Pause(); + + pParent = GTK_WIDGET(pWindow); + + pFilter_dsm = gtk_file_filter_new(); + gtk_file_filter_add_pattern(pFilter_dsm, "*.dsm*"); + gtk_file_filter_set_name(pFilter_dsm, "DeSmuME movie file (.dsm*)"); + + pFilter_any = gtk_file_filter_new(); + gtk_file_filter_add_pattern(pFilter_any, "*"); + gtk_file_filter_set_name(pFilter_any, "All files"); + + /* Creating the selection window */ + pFileSelection = gtk_file_chooser_dialog_new("Save Movie To ...", + GTK_WINDOW(pParent), + GTK_FILE_CHOOSER_ACTION_SAVE, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_SAVE, GTK_RESPONSE_OK, + NULL); + gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (pFileSelection), TRUE); + + /* Only the dialog window is accepting events: */ + gtk_window_set_modal(GTK_WINDOW(pFileSelection), TRUE); + + gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(pFileSelection), pFilter_dsm); + gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(pFileSelection), pFilter_any); + + /* Showing the window */ + switch(gtk_dialog_run(GTK_DIALOG(pFileSelection))) { + case GTK_RESPONSE_OK: + sPath = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(pFileSelection)); + + FCEUI_SaveMovie(sPath,L""); + + g_free(sPath); + break; + default: + break; + } + gtk_widget_destroy(pFileSelection); +} + +static void StopMovie() +{ + FCEUI_StopMovie(); +} + +static void PlayMovieDialog() +{ + GtkFileFilter *pFilter_dsm, *pFilter_any; + GtkWidget *pFileSelection; + GtkWidget *pParent; + gchar *sPath; + + if (desmume_running()) + Pause(); + + pParent = GTK_WIDGET(pWindow); + + pFilter_dsm = gtk_file_filter_new(); + gtk_file_filter_add_pattern(pFilter_dsm, "*.dsm*"); + gtk_file_filter_set_name(pFilter_dsm, "DeSmuME movie file (.dsm*)"); + + pFilter_any = gtk_file_filter_new(); + gtk_file_filter_add_pattern(pFilter_any, "*"); + gtk_file_filter_set_name(pFilter_any, "All files"); + + /* Creating the selection window */ + pFileSelection = gtk_file_chooser_dialog_new("Play movie from...", + GTK_WINDOW(pParent), + GTK_FILE_CHOOSER_ACTION_OPEN, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_OPEN, GTK_RESPONSE_OK, + NULL); + gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (pFileSelection), TRUE); + + /* Only the dialog window is accepting events: */ + gtk_window_set_modal(GTK_WINDOW(pFileSelection), TRUE); + + gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(pFileSelection), pFilter_dsm); + gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(pFileSelection), pFilter_any); + + /* Showing the window */ + switch(gtk_dialog_run(GTK_DIALOG(pFileSelection))) { + case GTK_RESPONSE_OK: + sPath = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(pFileSelection)); + + FCEUI_LoadMovie(sPath,true,false,-1); + + g_free(sPath); + break; + default: + break; + } + gtk_widget_destroy(pFileSelection); +} + static void SaveStateDialog() { GtkFileFilter *pFilter_ds, *pFilter_any; @@ -1784,6 +1899,9 @@ common_gtk_main( struct configured_features *my_config) /* Command line arg */ if( my_config->nds_file != "") { if(Open( my_config->nds_file.c_str(), bad_glob_cflash_disk_image_file) >= 0) { + + my_config->process_movieCommands(); + if(my_config->load_slot){ loadstate_slot(my_config->load_slot); } @@ -1841,8 +1959,7 @@ common_gtk_main( struct configured_features *my_config) } -int -main (int argc, char *argv[]) +int main (int argc, char *argv[]) { configured_features my_config; diff --git a/desmume/src/movie.cpp b/desmume/src/movie.cpp index 1c353715f..1a03f11da 100644 --- a/desmume/src/movie.cpp +++ b/desmume/src/movie.cpp @@ -388,7 +388,7 @@ void FCEUI_StopMovie() //begin playing an existing movie -void FCEUI_LoadMovie(const char *fname, bool _read_only, bool tasedit, int _pauseframe) +void _CDECL_ FCEUI_LoadMovie(const char *fname, bool _read_only, bool tasedit, int _pauseframe) { //if(!tasedit && !FCEU_IsValidUI(FCEUI_PLAYMOVIE)) // return; @@ -462,7 +462,7 @@ static void openRecordingMovie(const char* fname) //begin recording a new movie //TODO - BUG - the record-from-another-savestate doesnt work. - void FCEUI_SaveMovie(const char *fname, std::wstring author) + void _CDECL_ FCEUI_SaveMovie(const char *fname, std::wstring author) { //if(!FCEU_IsValidUI(FCEUI_RECORDMOVIE)) // return; @@ -534,11 +534,6 @@ static void openRecordingMovie(const char* fname) //either dumps the current joystick state or loads one state from the movie void FCEUMOV_AddInputState() { - //todo - for tasedit, either dump or load depending on whether input recording is enabled - //or something like that - //(input recording is just like standard read+write movie recording with input taken from gamepad) - //otherwise, it will come from the tasedit data. - if(movieMode == MOVIEMODE_PLAY) { //stop when we run out of frames diff --git a/desmume/src/movie.h b/desmume/src/movie.h index a25029ee8..e428efa3d 100644 --- a/desmume/src/movie.h +++ b/desmume/src/movie.h @@ -183,8 +183,8 @@ extern EMOVIEMODE movieMode; //adelikat: main needs this for frame counter disp extern MovieData currMovieData; //adelikat: main needs this for frame counter display bool FCEUI_MovieGetInfo(std::istream* fp, MOVIE_INFO& info, bool skipFrameCount); -void FCEUI_SaveMovie(const char *fname, std::wstring author); -void FCEUI_LoadMovie(const char *fname, bool _read_only, bool tasedit, int _pauseframe); +void _CDECL_ FCEUI_SaveMovie(const char *fname, std::wstring author); +void _CDECL_ FCEUI_LoadMovie(const char *fname, bool _read_only, bool tasedit, int _pauseframe); void FCEUI_StopMovie(); void FCEUMOV_AddInputState(); void NDS_setTouchFromMovie(void); diff --git a/desmume/src/utils/xstring.cpp b/desmume/src/utils/xstring.cpp index f50ed0e46..b11edfbd1 100644 --- a/desmume/src/utils/xstring.cpp +++ b/desmume/src/utils/xstring.cpp @@ -589,7 +589,7 @@ namespace UtfConverter } else if (sizeof(wchar_t) == 4) { - wchar_t* widestringnative = new wchar_t[widesize]; + wchar_t* widestringnative = new wchar_t[widesize+1]; const UTF8* sourcestart = reinterpret_cast(utf8string.c_str()); const UTF8* sourceend = sourcestart + widesize; UTF32* targetstart = reinterpret_cast(widestringnative); diff --git a/desmume/src/windows/main.cpp b/desmume/src/windows/main.cpp index 0722ab79f..3655e630b 100644 --- a/desmume/src/windows/main.cpp +++ b/desmume/src/windows/main.cpp @@ -1,4 +1,4 @@ -/* aviout.cpp +/* main.cpp Copyright 2006 Theo Berkau Copyright (C) 2006-2009 DeSmuME team @@ -1511,7 +1511,7 @@ static void ExitRunLoop() emu_halt(); } -class WinDriver : public Driver +class WinDriver : public BaseDriver { virtual bool WIFI_Host_InitSystem() { #ifdef EXPERIMENTAL_WIFI @@ -1904,14 +1904,7 @@ int _main() } } - if(cmdline.play_movie_file != "") - { - FCEUI_LoadMovie(cmdline.play_movie_file.c_str(),true,false,-1); - } - else if(cmdline.record_movie_file != "") - { - FCEUI_SaveMovie(cmdline.record_movie_file.c_str(), L""); - } + cmdline.process_movieCommands(); if(cmdline.load_slot != 0) {