pkgsrc/emulators/gens/patches/patch-aj

161 lines
3.4 KiB
Text

$NetBSD: patch-aj,v 1.4 2006/06/25 18:36:28 wiz Exp $
--- src/gens/emulator/g_main.c.orig 2004-05-18 20:34:00.000000000 +0000
+++ src/gens/emulator/g_main.c
@@ -55,8 +55,27 @@ int Intro_Style = 2;
int SegaCD_Accurate = 0;
int Kaillera_Client_Running = 0;
+int NbRerecord=0;
+char MovieFileName[1024];
+int MoviePlaying=0;
+int FrameCount=0;
+unsigned MovieLastFrame=0;
+
+FILE *MovieFile;
+
+struct type_MovieFrame
+{
+ char P1;
+ char P2;
+ char PX;
+};
+
+struct type_MovieFrame *MovieData = NULL;
+
static int Gens_Running = 0;
+static int Build_Language_String (void);
+
void
SetWindowText (const char *s)
{
@@ -394,6 +413,13 @@ update_SDL_events ()
break;
+ case SDLK_q:
+ if (KMOD_CTRL & mod)
+ {
+ close_gens ();
+ }
+ break;
+
case SDLK_v:
if (KMOD_CTRL & mod)
{
@@ -429,14 +455,14 @@ update_SDL_events ()
case SDL_JOYAXISMOTION:
if (event.jaxis.axis < 2)
{
- if (event.jaxis.value < -500)
+ if (event.jaxis.value < -10922)
{
joystate[0x100 * event.jaxis.which +
((event.jaxis.axis == 0) ? 0x3 : 0x1)] = 1;
joystate[0x100 * event.jaxis.which +
((event.jaxis.axis == 0) ? 0x4 : 0x2)] = 0;
}
- else if (event.jaxis.value > 500)
+ else if (event.jaxis.value > 10922)
{
joystate[0x100 * event.jaxis.which +
((event.jaxis.axis == 0) ? 0x4 : 0x2)] = 1;
@@ -661,11 +687,11 @@ idle_loop (gpointer data)
int
main (int argc, char *argv[])
{
- Init_Genesis_Bios ();
-
char sdlbuf[32];
GtkWidget *widget;
+ Init_Genesis_Bios ();
+
add_pixmap_directory (DATADIR);
gtk_init (&argc, &argv);
gens_window = create_gens_window ();
@@ -850,3 +876,83 @@ Build_Language_String (void)
return (0);
}
+
+void PlayMovie()
+{
+ if(MoviePlaying) {
+ StopMovie();
+ return;
+ }
+ if(Change_File_L_MV(MovieFileName, State_Dir)==0)
+ return;
+ if (Genesis_Started)
+ {
+ Reset_Genesis();
+ }
+ else if (_32X_Started)
+ {
+ Reset_32X();
+ }
+ FrameCount=0;
+ if(LoadMovieFromFile(MovieFile,MovieFileName)==0)
+ return;
+ MESSAGE_NUM_L("Playing movie from start: %d rerecords","Playing movie from start: %d rerecords",NbRerecord,1500);
+ MoviePlaying=1;
+}
+
+int LoadMovieFromFile(FILE *MovieFile,char* FileName)
+{
+ MovieFile=fopen(FileName,"r+b");
+ if(MovieFile==NULL)
+ {
+ MESSAGE_L("Error loading movie:disk error","Error loading movie:disk error", 2000);
+ return 0;
+ }
+
+ fseek(MovieFile,0,SEEK_END);
+ MovieLastFrame=(ftell(MovieFile)-64)/3;
+
+ MovieData = malloc(sizeof(struct type_MovieFrame)*MovieLastFrame);
+ if(!MovieData)
+ {
+ MESSAGE_L("Memory error allocating movie", "Memory error allocating movie", 2000);
+ return 0;
+ }
+ fseek(MovieFile,64,SEEK_SET);
+
+ if(fread(MovieData, sizeof(*MovieData), MovieLastFrame, MovieFile) < MovieLastFrame)
+ {
+ MESSAGE_L("Error loading movie:file read","Error loading movie:file read", 2000);
+ return 0;
+ }
+
+ fseek(MovieFile,16,SEEK_SET);
+ fread((char*)&NbRerecord,sizeof(NbRerecord),1,MovieFile);
+
+ fclose(MovieFile);
+ MovieFile=NULL;
+
+ return 1;
+}
+void ReadInMovie(unsigned frame, char *p1, char *p2, char *px)
+{
+ if(frame>MovieLastFrame)
+ {
+ MESSAGE_NUM_L("Overflow error reading frame : %d","Overflow error reading frame : %d",frame,2000);
+ return;
+ }
+ *p1=MovieData[frame].P1;
+ *p2=MovieData[frame].P2;
+ *px=MovieData[frame].PX;
+}
+
+void
+StopMovie(void)
+{
+ if (!MoviePlaying)
+ return;
+
+ MoviePlaying = 0;
+ free(MovieData);
+ MovieData = NULL;
+}