commit 94b5282
Devine Lu Linvega
·
2025-05-17 23:13:00 +0000 UTC
parent 7adc008
Cleanup
2 files changed,
+57,
-57
+52,
-52
1@@ -35,7 +35,7 @@ static Window window;
2 static Uint8 *ram, dev[0x100];
3 static Stack wst, rst;
4
5-Uint8 emu_dei(Uint8 addr);
6+unsigned int emu_dei(Uint8 addr);
7 void emu_deo(Uint8 addr, Uint8 value);
8
9 /* clang-format off */
10@@ -148,12 +148,12 @@ system_print(char *name, Stack *s)
11 fprintf(stderr, "<%02x\n", s->ptr);
12 }
13
14-static int
15+static unsigned int
16 system_load(char *rom_path)
17 {
18 FILE *f = fopen(rom_path, "rb");
19 if(f) {
20- int i = 0, l = fread(ram + 0x100, 0x10000 - 0x100, 1, f);
21+ unsigned int i = 0, l = fread(ram + 0x100, 0x10000 - 0x100, 1, f);
22 while(l && ++i < BANKS)
23 l = fread(ram + i * 0x10000, 0x10000, 1, f);
24 fclose(f);
25@@ -161,8 +161,8 @@ system_load(char *rom_path)
26 return !!f;
27 }
28
29-static int
30-system_boot(char *rom_path, int has_args)
31+static unsigned int
32+system_boot(char *rom_path, unsigned int has_args)
33 {
34 ram = (Uint8 *)calloc(BANKS * 0x10000, sizeof(Uint8));
35 system_boot_path = rom_path;
36@@ -170,10 +170,10 @@ system_boot(char *rom_path, int has_args)
37 return ram && system_load(rom_path);
38 }
39
40-static int
41-system_reboot(int soft)
42+static unsigned int
43+system_reboot(unsigned int soft)
44 {
45- int i;
46+ unsigned int i;
47 for(i = 0x0; i < 0x100; i++) dev[i] = 0;
48 for(i = soft ? 0x100 : 0; i < 0x10000; i++) ram[i] = 0;
49 wst.ptr = rst.ptr = 0;
50@@ -391,8 +391,8 @@ console_close(void)
51 kill_child();
52 }
53
54-static int
55-console_input(int c, int type)
56+static unsigned int
57+console_input(int c, unsigned int type)
58 {
59 if(c == EOF) c = 0, type = 4;
60 dev[0x12] = c, dev[0x17] = type;
61@@ -422,7 +422,7 @@ static Uint8 blending[4][16] = {
62
63 void emu_resize(void);
64
65-static int
66+static unsigned int
67 screen_changed(void)
68 {
69 clamp(uxn_screen.x1, 0, uxn_screen.width);
70@@ -698,25 +698,25 @@ make_pathfile(char *pathbuf, const char *filepath, const char *basename)
71 *pathbuf = 0;
72 }
73
74-static int
75-put_fill(Uint8 *dest, int len, char c)
76+static unsigned int
77+put_fill(Uint8 *dest, unsigned int len, char c)
78 {
79- int i;
80+ unsigned int i;
81 for(i = 0; i < len; i++)
82 *dest = c, dest++;
83 return len;
84 }
85
86-static int
87-put_size(Uint8 *dest, int len, int size)
88+static unsigned int
89+put_size(Uint8 *dest, unsigned int len, unsigned int size)
90 {
91- int i;
92+ unsigned int i;
93 for(i = 0, dest += len; i < len; i++, size >>= 4)
94 *(--dest) = "0123456789abcdef"[(Uint8)(size & 0xf)];
95 return len;
96 }
97
98-static int
99+static unsigned int
100 put_text(Uint8 *dest, const char *text)
101 {
102 Uint8 *anchor = dest;
103@@ -726,8 +726,8 @@ put_text(Uint8 *dest, const char *text)
104 return dest - anchor;
105 }
106
107-static int
108-put_stat(Uint8 *dest, int len, int size, int err, int dir, int capsize)
109+static unsigned int
110+put_stat(Uint8 *dest, unsigned int len, unsigned int size, unsigned int err, unsigned int dir, unsigned int capsize)
111 {
112 if(err) return put_fill(dest, len, '!');
113 if(dir) return put_fill(dest, len, '-');
114@@ -735,10 +735,10 @@ put_stat(Uint8 *dest, int len, int size, int err, int dir, int capsize)
115 return put_size(dest, len, size);
116 }
117
118-static int
119+static unsigned int
120 put_statfile(Uint8 *dest, const char *filepath, const char *basename)
121 {
122- int err, dir;
123+ unsigned int err, dir;
124 struct stat st;
125 Uint8 *anchor = dest;
126 char pathbuf[0x2000];
127@@ -752,10 +752,10 @@ put_statfile(Uint8 *dest, const char *filepath, const char *basename)
128 return dest - anchor;
129 }
130
131-static int
132-put_fdir(Uint8 *dest, int len, const char *filepath, DIR *dir)
133+static unsigned int
134+put_fdir(Uint8 *dest, unsigned int len, const char *filepath, DIR *dir)
135 {
136- int i;
137+ unsigned int i;
138 struct dirent *de = readdir(dir);
139 for(_dirbuf = dirbuf; de != NULL; de = readdir(dir)) {
140 char *name = de->d_name;
141@@ -770,26 +770,26 @@ put_fdir(Uint8 *dest, int len, const char *filepath, DIR *dir)
142 return i;
143 }
144
145-static int
146+static unsigned int
147 is_dir_path(char *p)
148 {
149 char c;
150- int saw_slash = 0;
151+ unsigned int saw_slash = 0;
152 while((c = *p++)) saw_slash = c == '/';
153 return saw_slash;
154 }
155
156-static int
157+static unsigned int
158 is_dir_real(char *p)
159 {
160 struct stat st;
161 return stat(p, &st) == 0 && S_ISDIR(st.st_mode);
162 }
163
164-static int
165+static unsigned int
166 file_write_dir(char *p)
167 {
168- int ok = 1;
169+ unsigned int ok = 1;
170 char c, *s = p;
171 for(; ok && (c = *p); p++) {
172 if(c == '/') {
173@@ -802,23 +802,23 @@ file_write_dir(char *p)
174 }
175
176 static void
177-file_reset(int id)
178+file_reset(unsigned int id)
179 {
180 if(ufs[id].f != NULL) fclose(ufs[id].f), ufs[id].f = NULL;
181 if(ufs[id].dir != NULL) closedir(ufs[id].dir), ufs[id].dir = NULL;
182 ufs[id].state = IDLE;
183 }
184
185-static int
186-file_init(int id, Uint16 addr)
187+static unsigned int
188+file_init(unsigned int id, Uint16 addr)
189 {
190 file_reset(id);
191 ufs[id].filepath = (char *)&ram[addr];
192 return 0;
193 }
194
195-static int
196-file_not_ready(int id)
197+static unsigned int
198+file_not_ready(unsigned int id)
199 {
200 if(ufs[id].filepath == 0) {
201 fprintf(stderr, "File %d is uninitialized\n", id);
202@@ -827,8 +827,8 @@ file_not_ready(int id)
203 return 0;
204 }
205
206-static int
207-file_read(int id, Uint16 addr, int len)
208+static unsigned int
209+file_read(unsigned int id, Uint16 addr, unsigned int len)
210 {
211 void *dest = &ram[addr];
212 if(file_not_ready(id))
213@@ -847,10 +847,10 @@ file_read(int id, Uint16 addr, int len)
214 return 0;
215 }
216
217-static int
218-file_write(int id, Uint16 addr, int len, Uint8 flags)
219+static unsigned int
220+file_write(unsigned int id, Uint16 addr, unsigned int len, Uint8 flags)
221 {
222- int ret = 0;
223+ unsigned int ret = 0;
224 if(file_not_ready(id))
225 return 0;
226 file_write_dir(ufs[id].filepath);
227@@ -869,10 +869,10 @@ file_write(int id, Uint16 addr, int len, Uint8 flags)
228 return ret;
229 }
230
231-static int
232-file_stat(int id, Uint16 addr, int len)
233+static unsigned int
234+file_stat(unsigned int id, Uint16 addr, unsigned int len)
235 {
236- int err, dir;
237+ unsigned int err, dir;
238 struct stat st;
239 if(file_not_ready(id))
240 return 0;
241@@ -881,8 +881,8 @@ file_stat(int id, Uint16 addr, int len)
242 return put_stat(&ram[addr], len, st.st_size, err, dir, 0);
243 }
244
245-static int
246-file_delete(int id)
247+static unsigned int
248+file_delete(unsigned int id)
249 {
250 if(file_not_ready(id))
251 return -1;
252@@ -890,21 +890,21 @@ file_delete(int id)
253 }
254
255 static void
256-file_success(int port, int value)
257+file_success(unsigned int port, unsigned int value)
258 {
259 POKE2(&dev[port], value);
260 }
261
262 /* file registers */
263
264-static int rL1, rL2;
265+static unsigned int rL1, rL2;
266
267 /*
268 @|Datetime ---------------------------------------------------------- */
269
270 #include <time.h>
271
272-static Uint8
273+static unsigned int
274 datetime_dei(Uint8 addr)
275 {
276 time_t seconds = time(NULL);
277@@ -932,7 +932,7 @@ datetime_dei(Uint8 addr)
278
279 #define CONINBUFSIZE 256
280
281-Uint8
282+unsigned int
283 emu_dei(Uint8 addr)
284 {
285 switch(addr) {
286@@ -1043,7 +1043,7 @@ emu_resize(void)
287 }
288
289 static void
290-emu_restart(int soft)
291+emu_restart(unsigned int soft)
292 {
293 console_close();
294 screen_apply(WIDTH, HEIGHT);
295@@ -1151,7 +1151,7 @@ display_floating(Display *dpy, Window win)
296 XChangeProperty(dpy, win, wmType, 4, 32, PropModeReplace, (unsigned char *)&wmDialog, 1);
297 }
298
299-static int
300+static unsigned int
301 display_init(void)
302 {
303 Visual *visual;
304@@ -1176,7 +1176,7 @@ display_init(void)
305 return 1;
306 }
307
308-static int
309+static unsigned int
310 emu_run(void)
311 {
312 int has_input, has_eof;
+5,
-5
1@@ -137,7 +137,7 @@ system_print(char *name, Stack *s)
2 fprintf(stderr, "<%02x\n", s->ptr);
3 }
4
5-static int
6+static unsigned int
7 system_load(char *rom_path)
8 {
9 FILE *f = fopen(rom_path, "rb");
10@@ -150,7 +150,7 @@ system_load(char *rom_path)
11 return !!f;
12 }
13
14-static int
15+static unsigned int
16 system_boot(char *rom_path, unsigned int has_args)
17 {
18 ram = (Uint8 *)calloc(BANKS * 0x10000, sizeof(Uint8));
19@@ -209,7 +209,7 @@ system_expansion(Uint16 addr)
20 #include <util.h>
21 #endif
22
23-static int console_vector;
24+static unsigned int console_vector;
25
26 /* subprocess support */
27 static char *fork_args[4] = {"/bin/sh", "-c", "", NULL};
28@@ -364,8 +364,8 @@ start_fork(void)
29 start_fork_pipe();
30 }
31
32-static int
33-console_input(unsigned int c, unsigned int type)
34+static unsigned int
35+console_input(int c, unsigned int type)
36 {
37 if(c == EOF) c = 0, type = 4;
38 dev[0x12] = c, dev[0x17] = type;