Package: dgen / 1.23-12

old-patches Patch series | download
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
Description: Upstream changes introduced in version 1.23-12
 This patch has been created by dpkg-source during the package build.
 Here's the last changelog entry, hopefully it gives details on why
 those changes were made:
 .
 dgen (1.23-12) unstable; urgency=low
 .
   * Readded the makefiles
   * debian/rules. Removed the clean rule.
   * Switch to dpkg-source 3.0 (quilt) format
   * Switch to quilt for manage the patches.
   * debian/control: Switch any to i386 on arch field.
   * Fix for some warnings about the dgenrc.5 manpage
 .
 The person named in the Author field signed this changelog entry.
Author: Edgar Antonio Palma de la Cruz <xbytemx@gmail.com>

---
The information above should follow the Patch Tagging Guidelines, please
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: <vendor|upstream|other>, <url of original patch>
Bug: <url in upstream bugtracker>
Bug-Debian: http://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: <no|not-needed|url proving that it has been forwarded>
Reviewed-By: <name and email of someone who approved the patch>
Last-Update: <YYYY-MM-DD>

--- a/pd.h
+++ b/pd.h
@@ -52,6 +52,8 @@
 // This should be a list of all the command-line options specific to this
 // platform, in the form given to getopt(3), i.e "a:b::c".
 extern char *pd_options;
+// This is called once, during startup, before pd_option is.
+void pd_initoptions();
 // And, this is called to handle platform-specific stuff.
 void pd_option(char c, const char *optarg);
 
--- a/dgen.1
+++ b/dgen.1
@@ -35,7 +35,7 @@
 .It Fl P
 Emulate 50Hz PAL mode (as used in European models of the MegaDrive).
 .It Fl R
-If running with root priviledges, set priority to -20, so no other processes
+If running with root priviledges, set priority to \-20, so no other processes
 interrupt (including the X server, which can be a Bad Thing).
 .It Fl f 
 Run fullscreen, if possible.
--- a/romload.c
+++ b/romload.c
@@ -7,6 +7,10 @@
 #include <string.h>
 #include <time.h>
 #include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/wait.h>
 
 static int load_bin_into(char *name,unsigned char *into)
 {
@@ -126,13 +130,32 @@
      (magicbuf[0] == 037 && magicbuf[1] == 0240) || /* LZH        (?)      */
      (magicbuf[0] == 'P' && magicbuf[1] == 'K'))    /* ZIP        (.zip ;) */
     {
-      char temp[0x100], temp2[0x80];
-      srand(time(NULL));
+      char temp[0x100], *temp2;
+      int f;
       /* Run it through gzip (I know this is cheap ;) */
-      sprintf(temp2, "/tmp/dgenrom_%d_%d", rand(), rand());
-      sprintf(temp, "gzip -S \"\" -cdq %s > %s", name, temp2);
-      /* If gzip returned an error, stop */
-      if(system(temp)) { remove(temp2); return -1; };
+      asprintf(&temp2, "/tmp/dgenrom_XXXXXX");
+      f = mkstemp(temp2);
+      if (f == -1) {
+	      perror("mkstemp");
+	      return -1;
+      }
+      close(f);
+
+      f = open(name, O_RDONLY);
+      if (f == -1) {
+	      perror("open");
+	      return -1;
+      }
+      if (dup2(f, 0) == -1) {
+	      perror("dup2");
+	      return -1;
+      }
+      sprintf(temp, "zcat > %s", temp2);
+      if (system(temp)) {
+	      perror("system");
+	      return -1;
+      }
+
       /* Recurse with the new file */
       len = load_rom_into(temp2, into);
       remove(temp2);
@@ -142,14 +165,32 @@
   /* Do bzip2 also */
   if(magicbuf[0] == 'B' && magicbuf[1] == 'Z' && magicbuf[2] == 'h')
     {
+      char temp[0x100], *temp2;
+      int f;
       /* Damn, this looks almost like the gzip stuff above. *lol* :) */
-      char temp[0x100], temp2[0x80];
-      srand(time(NULL));
-      /* Go through bzip2 */
-      sprintf(temp2, "/tmp/dgenrom_%d_%d", rand(), rand());
-      sprintf(temp, "bzip2 -cd %s > %s", name, temp2);
-      /* If we got an error, stop */
-      if(system(temp)) { remove(temp2); return -1; };
+      asprintf(&temp2, "/tmp/dgenrom_XXXXXX");
+      f = mkstemp(temp2);
+      if (f == -1) {
+	      perror("mkstemp");
+	      return -1;
+      }
+      close(f);
+
+      f = open(name, O_RDONLY);
+      if (f == -1) {
+	      perror("open");
+	      return -1;
+      }
+      if (dup2(f, 0) == -1) {
+	      perror("dup2");
+	      return -1;
+      }
+      sprintf(temp, "bzcat > %s", temp2);
+      if (system(temp)) {
+	      perror("system");
+	      return -1;
+      }
+
       /* Recurse with the uncompressed file */
       len = load_rom_into(temp2, into);
       remove(temp2);
@@ -161,7 +202,7 @@
     format = 1;
   /* Otherwise we can only hope it's binary */
   else format = 0;
-	    
+
   switch (format)
   {
     case 1:  return load_smd_into(name,into);
--- a/main.cpp
+++ b/main.cpp
@@ -92,7 +92,7 @@
     { /* Need to strip extension */
     	p = strtok(buf, ".");
     }
-    
+
     if(strchr(buf, '/'))
     { /* Need to strip /path/name */
         p = strtok(buf, "/");
@@ -169,7 +169,7 @@
       sprintf(temp, "Saved state to slot %d.", slot);
       pd_message(temp);
     }
-  else 
+  else
     {
       sprintf(temp, "Couldn't save state to slot %d!", slot);
       pd_message(temp);
@@ -193,7 +193,7 @@
       pd_message(temp);
     }
 }
- 
+
 // Load/save states from file
 static void ram_save(md& megad)
 {
@@ -236,6 +236,8 @@
   // Parse the RC file
   parse_rc(NULL);
 
+  pd_initoptions();
+
   // Check all our options
   strcpy(temp, "s:hvr:n:p:RPjd:D:");
   strcat(temp, pd_options);
@@ -326,7 +328,7 @@
   // BeOS snooze() sleeps in milliseconds, not microseconds
   dgen_nice /= 1000;
 #endif
-  
+
   // There should be a romname after all those options. If not, show help and
   // exit.
   if(optind >= argc)
@@ -388,7 +390,7 @@
   megad.reset();
   // Set PAL mode
   megad.pal = pal_mode;
-  
+
   // Make sure the .dgen hierarchy is setup
   mk_dgendir();
   // Load up save RAM
@@ -483,7 +485,7 @@
   gettimeofday(&endclk, NULL);
   printf("%d frames per second (optimal %d)\n",
 	 (unsigned)(f / (endclk.tv_sec - startclk.tv_sec)), (pal_mode? 50 : 60));
-  
+
   // Cleanup
   if(demo) fclose(demo);
   ram_save(megad);
@@ -493,5 +495,5 @@
   YM2612Shutdown();
 
   // Come back anytime :)
-  return 0; 
+  return 0;
 }
--- a/mkinstalldirs
+++ b/mkinstalldirs
@@ -4,7 +4,7 @@
 # Created: 1993-05-16
 # Public domain
 
-# $Id: mkinstalldirs,v 1.13 1999/01/05 03:18:55 bje Exp $
+# $Id: mkinstalldirs,v 1.1 2002/04/10 19:46:28 joey Rel $
 
 errstatus=0
 
--- a/tobin.1
+++ b/tobin.1
@@ -1,10 +1,10 @@
 .Dd February 21, 2001
 .Dt DGEN 1
 .Sh NAME
-.Nm tobin
+.Nm dgen_tobin
 .Nd Convert SMD-format Genesis/Megadrive image to raw (BIN) format
 .Sh SYNOPSIS
-.Nm tobin
+.Nm dgen_tobin
 .Ar FROMSMD
 .Ar TOBIN
 .Sh DESCRIPTION
@@ -27,4 +27,3 @@
 .An Joe Groff Aq joe@pknet.com .
 .Sh BUGS
 None (yet :-)
-
--- a/dgenrc.5
+++ b/dgenrc.5
@@ -13,7 +13,7 @@
 is parsed by
 .Xr dgen 1
 when the emuator is started. It is used to set controller keys, as well as other
-characteristics of the emulation. The contents of this file may be overriden
+characteristics of the emulation. The contents of this file may be overridden
 with the contents of another similarly-formatted file, via the
 .Fl r
 commandline switch.
@@ -170,7 +170,7 @@
 or any combination thereof, to require that the specified modifier be pressed
 in combination with the key. For example, the identifier "alt-enter" would
 correspond to holding down the Alt key while pressing Enter.
-
+.Pp
 The numbers "0" through "9" ("kp_0" through "kp_9" for the numeric keypad),
 letters "A" through "Z", and function keys "F1" through "F12" map to their key
 equivalents.
@@ -223,18 +223,18 @@
 kp_multiply
 kp_plus
 
-`	~
--	_
-=	+
-\	|
-[	{
-]	}
-:	;
-'	"
-,	<
-\.	>
-/	?
-
+ `	~
+ -	_
+ =	+
+ \\	|
+ [	{
+ ]	}
+ :	;
+ '	"
+ ,	<
+ .	>
+ /	?
+.Ed
 .Sh SEE ALSO
 .Xr dgen 1
 .Sh AUTHORS
--- a/musa/m68kmake.c
+++ b/musa/m68kmake.c
@@ -1029,9 +1029,10 @@
 	fprintf(filep, "/* ========================= OPCODE TABLE BUILDER ========================= */\n");
 	fprintf(filep, "/* ======================================================================== */\n\n");
 
+	fprintf(filep, "#include <stdlib.h>\n\n"); /* moved here for gcc 4.0 */
 	fprintf(filep, "#include \"m68kops.h\"\n");
 	fprintf(filep, "#include \"m68kcpu.h\"\n");
-	fprintf(filep, "#include <stdlib.h>\n\n");
+	/*fprintf(filep, "#include <stdlib.h>\n\n");*/
 	fprintf(filep, "#include <string.h>\n\n");
 
 	fprintf(filep, "extern void  (*m68k_instruction_jump_table[])(void); /* opcode handler jump table */\n\n");
--- a/star/star.c
+++ b/star/star.c
@@ -1931,7 +1931,6 @@
 	case aind: case ainc: case adec:
 	case adsp: case axdp:
 		usereg();
-	default:
 	}
 }
 
--- a/sdl/sdl.cpp
+++ b/sdl/sdl.cpp
@@ -157,13 +157,15 @@
   );
 }
 
+void pd_initoptions()
+{
+	fullscreen = dgen_fullscreen;
+	x_scale = y_scale = dgen_scale;
+}
+
 // Handle the switches
 void pd_option(char c, const char *)
 {
-  // Set stuff up from the rcfile first, so we can override it with commandline
-  // options
-  fullscreen = dgen_fullscreen;
-  x_scale = y_scale = dgen_scale;
 #ifdef SDL_OPENGL_SUPPORT
   opengl = dgen_opengl;
   if(opengl)