Package: spectemu / 0.94a-19

external-rom-image.patch 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
From f2c9ba737a04fa012d5d755dc15fcc424171a06a Mon Sep 17 00:00:00 2001
From: Philip Kendall <philip-spectrum@shadowmagic.org.uk>
Date: Thu, 2 Jan 2014 06:28:16 +0000
Subject: Load the ROM image from a file rather than linking it directly

 The Spectrum ROM is non-free, so this allows spectemu to be in contrib and
 merely read non-free files rather than also being in non-free itself.
Bug-Debian: http://bugs.debian.org/134261
Forwarded: no
Last-Update: 2010-03-28

Patch-Name: external-rom-image.patch
---
 Makefile.in |  9 ++++++---
 spperif.c   | 28 +++++++++++++++++++++++++---
 2 files changed, 31 insertions(+), 6 deletions(-)

diff --git a/Makefile.in b/Makefile.in
index 872f874..bab432a 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -7,10 +7,13 @@ bindir = @bindir@
 mandir = @mandir@/man1
 srcdir = @srcdir@
 
+ROM_IMAGE = /usr/share/spectrum-roms/48.rom
+
 CC = @CC@
 CPP = @CPP@
 CFLAGS = @CFLAGS@
-CPPFLAGS = @DEFS@ @CPPFLAGS@ @X_CFLAGS@ -DDATADIR=\""$(datadir)"\"
+CPPFLAGS = @DEFS@ @CPPFLAGS@ @X_CFLAGS@ -DDATADIR=\""$(datadir)"\" \
+	   -DROM_IMAGE=\""$(ROM_IMAGE)"\"
 INSTALL = @INSTALL@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_DATA = @INSTALL_DATA@
@@ -57,10 +60,10 @@ install_data:
 
 install: installdirs install_prog install_man install_data
 
-z80_c_objs=z80.o z80optab.o z80_step.o spperif.o spect.o rom_imag.o \
+z80_c_objs=z80.o z80optab.o z80_step.o spperif.o spect.o \
            z80_op1.o z80_op2.o z80_op3.o z80_op4.o z80_op5.o z80_op6.o
 
-z80_i386_objs=z80.o spperif.o rom_imag.o i386emul.o
+z80_i386_objs=z80.o spperif.o i386emul.o
 
 spect_objs=spmain.o spscr.o spkey.o spsound.o sptape.o tapefile.o \
            snapshot.o compr.o sptiming.o interf.o misc.o spconf.o \
diff --git a/spperif.c b/spperif.c
index 9665289..5645837 100644
--- a/spperif.c
+++ b/spperif.c
@@ -26,8 +26,6 @@
 #include "spperif.h"
 #include "z80.h"
 
-extern unsigned char rom_imag[];
-
 int SPNM(quick_load) = 0;
 int SPNM(load_trapped);
 
@@ -72,6 +70,30 @@ void SPNM(init_screen_mark)(void)
   SPNM(border_update) = 1;
 }
 
+static void init_rom(void)
+{
+  FILE *fp;
+
+  fp = fopen(ROM_IMAGE, "rb");
+  if(fp == NULL) {
+    fprintf(stderr, "Could not open file %s: %s\n", ROM_IMAGE,
+	    strerror(errno));
+    exit(1);
+  }
+
+  if(fread(PRNM(proc).mem, 1, 0x4000, fp) != 0x4000) {
+    fprintf(stderr, "Error reading from %s: %s\n", ROM_IMAGE, strerror(errno));
+    fclose(fp);
+    exit(1);
+  }
+
+  if(fclose(fp)) {
+    fprintf(stderr, "Error closing %s: %s\n", ROM_IMAGE, strerror(errno));
+  }
+
+  return;
+}
+
 void SPNM(init)(void)
 {
   int i;
@@ -98,7 +120,7 @@ void SPNM(init)(void)
 
   SPNM(scline) = 0;
   
-  for(i = 0; i < 0x4000; i++) PRNM(proc).mem[i] = rom_imag[i];
+  init_rom();
 
   SPNM(init_screen_mark)();
 }