summaryrefslogtreecommitdiff
path: root/emulators/gens/patches/patch-aj
blob: 5cc421e14f2390173ed749f21765cd10e45525f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
$NetBSD: patch-aj,v 1.2 2004/08/15 12:13:53 dillo Exp $

--- src/gens/emulator/g_main.c.orig	2004-05-18 22:34:00.000000000 +0200
+++ src/gens/emulator/g_main.c
@@ -55,6 +55,23 @@ 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;
 
 void
@@ -394,6 +411,13 @@ update_SDL_events ()
 
 	      break;
 
+	    case SDLK_q:
+	      if (KMOD_CTRL & mod)
+		{
+		  close_gens ();
+		}
+	      break;
+
 	    case SDLK_v:
 	      if (KMOD_CTRL & mod)
 		{
@@ -429,14 +453,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;
@@ -850,3 +874,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;
+}