summaryrefslogtreecommitdiff
path: root/emulators/gens/patches/patch-ah
blob: d333f9252a78fe1229e7380727c272288a5a3be0 (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
$NetBSD: patch-ah,v 1.1.1.1 2004/07/26 18:23:25 dillo Exp $

--- src/gens/util/rom.c.orig	2004-05-18 22:33:59.000000000 +0200
+++ src/gens/util/rom.c
@@ -17,6 +17,7 @@
 #include "ccnet.h"
 #include "misc.h"
 #include "unzip.h"
+#include "chd.h"
 #include "wave.h"
 #include "gym.h"
 #include <assert.h>
@@ -168,6 +169,7 @@ Detect_Format (char *Name)
   FILE *f;
   unzFile zf;
   unz_file_info zinf;
+  struct chd *cf;
   int i;
   char buf[1024], zname[256];
 
@@ -225,6 +227,19 @@ Detect_Format (char *Name)
       gzread (f, buf, 1024);
       gzclose (f);
     }
+  else if (!stricmp (".chd", &Name[strlen (Name) -4]))
+    {
+      char *p;
+      int n;
+
+      cf = chd_open(Name, NULL);
+      if (cf == NULL)
+	return -1;
+
+      chd_read_range(cf, buf, 0, 1024);
+
+      chd_close(cf);
+    }
   else
     {
       strcpy (zname, Name);
@@ -402,6 +417,10 @@ Get_Rom ()
       filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget));
     }
   gtk_widget_destroy (widget);
+  if (res != GTK_RESPONSE_OK)
+    {
+      return;
+    }
 
   strncpy (Name, filename, 2048);
   g_free (filename);