... | ... |
@@ -151,12 +151,18 @@ file_delete(UxnFile *c) |
151 | 151 |
return unlink(c->current_filename); |
152 | 152 |
} |
153 | 153 |
|
154 |
+static UxnFile * |
|
155 |
+file_instance(Device *d) |
|
156 |
+{ |
|
157 |
+ return &uxn_file[d - &d->u->dev[DEV_FILE0]]; |
|
158 |
+} |
|
159 |
+ |
|
154 | 160 |
/* IO */ |
155 | 161 |
|
156 | 162 |
void |
157 |
-file_i_deo(int instance, Device *d, Uint8 port) |
|
163 |
+file_deo(Device *d, Uint8 port) |
|
158 | 164 |
{ |
159 |
- UxnFile *c = &uxn_file[instance]; |
|
165 |
+ UxnFile *c = file_instance(d); |
|
160 | 166 |
Uint16 addr, len, res; |
161 | 167 |
switch(port) { |
162 | 168 |
case 0x5: |
... | ... |
@@ -196,9 +202,9 @@ file_i_deo(int instance, Device *d, Uint8 port) |
196 | 202 |
} |
197 | 203 |
|
198 | 204 |
Uint8 |
199 |
-file_i_dei(int instance, Device *d, Uint8 port) |
|
205 |
+file_dei(Device *d, Uint8 port) |
|
200 | 206 |
{ |
201 |
- UxnFile *c = &uxn_file[instance]; |
|
207 |
+ UxnFile *c = file_instance(d); |
|
202 | 208 |
Uint16 res; |
203 | 209 |
switch(port) { |
204 | 210 |
case 0xc: |
... | ... |
@@ -11,6 +11,7 @@ WITH REGARD TO THIS SOFTWARE. |
11 | 11 |
*/ |
12 | 12 |
|
13 | 13 |
#define POLYFILEY 2 |
14 |
+#define DEV_FILE0 0xa |
|
14 | 15 |
|
15 |
-void file_i_deo(int instance, Device *d, Uint8 port); |
|
16 |
-Uint8 file_i_dei(int instance, Device *d, Uint8 port); |
|
16 |
+void file_deo(Device *d, Uint8 port); |
|
17 |
+Uint8 file_dei(Device *d, Uint8 port); |
... | ... |
@@ -17,8 +17,6 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
17 | 17 |
WITH REGARD TO THIS SOFTWARE. |
18 | 18 |
*/ |
19 | 19 |
|
20 |
-static Device *devfile0; |
|
21 |
- |
|
22 | 20 |
static int |
23 | 21 |
error(char *msg, const char *err) |
24 | 22 |
{ |
... | ... |
@@ -44,18 +42,6 @@ console_deo(Device *d, Uint8 port) |
44 | 42 |
} |
45 | 43 |
} |
46 | 44 |
|
47 |
-static void |
|
48 |
-file_deo(Device *d, Uint8 port) |
|
49 |
-{ |
|
50 |
- file_i_deo(d - devfile0, d, port); |
|
51 |
-} |
|
52 |
- |
|
53 |
-static Uint8 |
|
54 |
-file_dei(Device *d, Uint8 port) |
|
55 |
-{ |
|
56 |
- return file_i_dei(d - devfile0, d, port); |
|
57 |
-} |
|
58 |
- |
|
59 | 45 |
static Uint8 |
60 | 46 |
nil_dei(Device *d, Uint8 port) |
61 | 47 |
{ |
... | ... |
@@ -122,7 +108,7 @@ start(Uxn *u) |
122 | 108 |
/* empty */ uxn_port(u, 0x7, nil_dei, nil_deo); |
123 | 109 |
/* empty */ uxn_port(u, 0x8, nil_dei, nil_deo); |
124 | 110 |
/* empty */ uxn_port(u, 0x9, nil_dei, nil_deo); |
125 |
- /* file0 */ devfile0 = uxn_port(u, 0xa, file_dei, file_deo); |
|
111 |
+ /* file0 */ uxn_port(u, 0xa, file_dei, file_deo); |
|
126 | 112 |
/* file1 */ uxn_port(u, 0xb, file_dei, file_deo); |
127 | 113 |
/* datetime */ uxn_port(u, 0xc, datetime_dei, nil_deo); |
128 | 114 |
/* empty */ uxn_port(u, 0xd, nil_dei, nil_deo); |
... | ... |
@@ -43,7 +43,7 @@ static SDL_Rect gRect; |
43 | 43 |
|
44 | 44 |
/* devices */ |
45 | 45 |
|
46 |
-static Device *devscreen, *devmouse, *devctrl, *devaudio0, *devfile0; |
|
46 |
+static Device *devscreen, *devmouse, *devctrl, *devaudio0; |
|
47 | 47 |
static Uint8 zoom = 1; |
48 | 48 |
static Uint32 stdin_event, audio0_event, redraw_event, interrupt_event; |
49 | 49 |
|
... | ... |
@@ -231,18 +231,6 @@ audio_deo(Device *d, Uint8 port) |
231 | 231 |
} |
232 | 232 |
} |
233 | 233 |
|
234 |
-static void |
|
235 |
-file_deo(Device *d, Uint8 port) |
|
236 |
-{ |
|
237 |
- file_i_deo(d - devfile0, d, port); |
|
238 |
-} |
|
239 |
- |
|
240 |
-static Uint8 |
|
241 |
-file_dei(Device *d, Uint8 port) |
|
242 |
-{ |
|
243 |
- return file_i_dei(d - devfile0, d, port); |
|
244 |
-} |
|
245 |
- |
|
246 | 234 |
static Uint8 |
247 | 235 |
nil_dei(Device *d, Uint8 port) |
248 | 236 |
{ |
... | ... |
@@ -289,7 +277,7 @@ start(Uxn *u, char *rom) |
289 | 277 |
/* unused */ uxn_port(u, 0x7, nil_dei, nil_deo); |
290 | 278 |
/* control */ devctrl = uxn_port(u, 0x8, nil_dei, nil_deo); |
291 | 279 |
/* mouse */ devmouse = uxn_port(u, 0x9, nil_dei, nil_deo); |
292 |
- /* file0 */ devfile0 = uxn_port(u, 0xa, file_dei, file_deo); |
|
280 |
+ /* file0 */ uxn_port(u, 0xa, file_dei, file_deo); |
|
293 | 281 |
/* file1 */ uxn_port(u, 0xb, file_dei, file_deo); |
294 | 282 |
/* datetime */ uxn_port(u, 0xc, datetime_dei, nil_deo); |
295 | 283 |
/* unused */ uxn_port(u, 0xd, nil_dei, nil_deo); |