commit aed26e5

neauoire  ·  2022-04-07 16:33:52 +0000 UTC
parent 2a179c9
Housekeeping
13 files changed,  +33, -43
+1, -12
 1@@ -2,8 +2,7 @@
 2 #include "controller.h"
 3 
 4 /*
 5-Copyright (c) 2021 Devine Lu Linvega
 6-Copyright (c) 2021 Andrew Alderwick
 7+Copyright (c) 2021 Devine Lu Linvega, Andrew Alderwick
 8 
 9 Permission to use, copy, modify, and distribute this software for any
10 purpose with or without fee is hereby granted, provided that the above
11@@ -40,13 +39,3 @@ controller_key(Uxn *u, Uint8 *d, Uint8 key)
12 		d[3] = 0x00;
13 	}
14 }
15-
16-void
17-controller_special(Uxn *u, Uint8 *d, Uint8 key)
18-{
19-	if(key) {
20-		d[4] = key;
21-		uxn_eval(u, GETVEC(d));
22-		d[4] = 0x00;
23-	}
24-}
+1, -3
 1@@ -1,6 +1,5 @@
 2 /*
 3-Copyright (c) 2021 Devine Lu Linvega
 4-Copyright (c) 2021 Andrew Alderwick
 5+Copyright (c) 2021 Devine Lu Linvega, Andrew Alderwick
 6 
 7 Permission to use, copy, modify, and distribute this software for any
 8 purpose with or without fee is hereby granted, provided that the above
 9@@ -13,4 +12,3 @@ WITH REGARD TO THIS SOFTWARE.
10 void controller_down(Uxn *u, Uint8 *d, Uint8 mask);
11 void controller_up(Uxn *u, Uint8 *d, Uint8 mask);
12 void controller_key(Uxn *u, Uint8 *d, Uint8 key);
13-void controller_special(Uxn *u, Uint8 *d, Uint8 key);
+1, -2
 1@@ -4,8 +4,7 @@
 2 #include "datetime.h"
 3 
 4 /*
 5-Copyright (c) 2021 Devine Lu Linvega
 6-Copyright (c) 2021 Andrew Alderwick
 7+Copyright (c) 2021 Devine Lu Linvega, Andrew Alderwick
 8 
 9 Permission to use, copy, modify, and distribute this software for any
10 purpose with or without fee is hereby granted, provided that the above
+1, -2
1@@ -1,6 +1,5 @@
2 /*
3-Copyright (c) 2021 Devine Lu Linvega
4-Copyright (c) 2021 Andrew Alderwick
5+Copyright (c) 2021 Devine Lu Linvega, Andrew Alderwick
6 
7 Permission to use, copy, modify, and distribute this software for any
8 purpose with or without fee is hereby granted, provided that the above
+1, -2
 1@@ -8,8 +8,7 @@
 2 #include "file.h"
 3 
 4 /*
 5-Copyright (c) 2021 Devine Lu Linvega
 6-Copyright (c) 2021 Andrew Alderwick
 7+Copyright (c) 2021 Devine Lu Linvega, Andrew Alderwick
 8 
 9 Permission to use, copy, modify, and distribute this software for any
10 purpose with or without fee is hereby granted, provided that the above
+1, -2
1@@ -1,6 +1,5 @@
2 /*
3-Copyright (c) 2021 Devine Lu Linvega
4-Copyright (c) 2021 Andrew Alderwick
5+Copyright (c) 2021 Devine Lu Linvega, Andrew Alderwick
6 
7 Permission to use, copy, modify, and distribute this software for any
8 purpose with or without fee is hereby granted, provided that the above
+1, -2
 1@@ -2,8 +2,7 @@
 2 #include "mouse.h"
 3 
 4 /*
 5-Copyright (c) 2021 Devine Lu Linvega
 6-Copyright (c) 2021 Andrew Alderwick
 7+Copyright (c) 2021 Devine Lu Linvega, Andrew Alderwick
 8 
 9 Permission to use, copy, modify, and distribute this software for any
10 purpose with or without fee is hereby granted, provided that the above
+1, -2
1@@ -1,6 +1,5 @@
2 /*
3-Copyright (c) 2021 Devine Lu Linvega
4-Copyright (c) 2021 Andrew Alderwick
5+Copyright (c) 2021 Devine Lu Linvega, Andrew Alderwick
6 
7 Permission to use, copy, modify, and distribute this software for any
8 purpose with or without fee is hereby granted, provided that the above
+1, -2
 1@@ -4,8 +4,7 @@
 2 #include "screen.h"
 3 
 4 /*
 5-Copyright (c) 2021 Devine Lu Linvega
 6-Copyright (c) 2021 Andrew Alderwick
 7+Copyright (c) 2021 Devine Lu Linvega, Andrew Alderwick
 8 
 9 Permission to use, copy, modify, and distribute this software for any
10 purpose with or without fee is hereby granted, provided that the above
+1, -2
1@@ -1,6 +1,5 @@
2 /*
3-Copyright (c) 2021 Devine Lu Linvega
4-Copyright (c) 2021 Andrew Alderwick
5+Copyright (c) 2021 Devine Lu Linvega, Andrew Alderwick
6 
7 Permission to use, copy, modify, and distribute this software for any
8 purpose with or without fee is hereby granted, provided that the above
+5, -5
 1@@ -24,7 +24,7 @@ WITH REGARD TO THIS SOFTWARE.
 2 #define PEEK(o, x) { if(bs) { PEEK16(o, x) } else { o = u->ram[(x)]; } }
 3 #define DEVR(o, x) { o = u->dei(u, x); if (bs) o = (o << 8) + u->dei(u, ((x) + 1) & 0xFF); }
 4 #define DEVW(x, y) { if (bs) { u->deo(u, (x), (y) >> 8); u->deo(u, ((x) + 1) & 0xFF, (y)); } else { u->deo(u, x, (y)); } }
 5-#define WARP(x) { if(bs) pc = (x); else pc += (Sint8)(x); }
 6+#define JUMP(x) { if(bs) pc = (x); else pc += (Sint8)(x); }
 7 
 8 int
 9 uxn_eval(Uxn *u, Uint16 pc)
10@@ -65,9 +65,9 @@ uxn_eval(Uxn *u, Uint16 pc)
11 		case 0x09: /* NEQ */ POP(a) POP(b) PUSH8(src, b != a) break;
12 		case 0x0a: /* GTH */ POP(a) POP(b) PUSH8(src, b > a) break;
13 		case 0x0b: /* LTH */ POP(a) POP(b) PUSH8(src, b < a) break;
14-		case 0x0c: /* JMP */ POP(a) WARP(a) break;
15-		case 0x0d: /* JCN */ POP(a) POP8(b) if(b) WARP(a) break;
16-		case 0x0e: /* JSR */ POP(a) PUSH16(dst, pc) WARP(a) break;
17+		case 0x0c: /* JMP */ POP(a) JUMP(a) break;
18+		case 0x0d: /* JCN */ POP(a) POP8(b) if(b) JUMP(a) break;
19+		case 0x0e: /* JSR */ POP(a) PUSH16(dst, pc) JUMP(a) break;
20 		case 0x0f: /* STH */ POP(a) PUSH(dst, a) break;
21 		/* Memory */
22 		case 0x10: /* LDZ */ POP8(a) PEEK(b, a) PUSH(src, b) break;
23@@ -86,7 +86,7 @@ uxn_eval(Uxn *u, Uint16 pc)
24 		case 0x1c: /* AND */ POP(a) POP(b) PUSH(src, b & a) break;
25 		case 0x1d: /* ORA */ POP(a) POP(b) PUSH(src, b | a) break;
26 		case 0x1e: /* EOR */ POP(a) POP(b) PUSH(src, b ^ a) break;
27-		case 0x1f: /* SFT */ POP8(a) POP(b) c = b >> (a & 0x0f) << ((a & 0xf0) >> 4); PUSH(src, c) break;
28+		case 0x1f: /* SFT */ POP8(a) POP(b) PUSH(src, b >> (a & 0x0f) << ((a & 0xf0) >> 4)) break;
29 		}
30 	}
31 	return 1;
+3, -3
 1@@ -32,10 +32,10 @@ typedef struct {
 2 typedef struct Uxn {
 3 	Uint8 *ram, *dev;
 4 	Stack *wst, *rst;
 5-	Uint8 (*dei)(struct Uxn *u, Uint8 address);
 6-	void (*deo)(struct Uxn *u, Uint8 address, Uint8 value);
 7+	Uint8 (*dei)(struct Uxn *u, Uint8 addr);
 8+	void (*deo)(struct Uxn *u, Uint8 addr, Uint8 value);
 9 } Uxn;
10 
11 int uxn_boot(Uxn *u, Uint8 *ram);
12 int uxn_eval(Uxn *u, Uint16 pc);
13-int uxn_halt(Uxn *u, Uint8 error, Uint16 addr);
14+int uxn_halt(Uxn *u, Uint8 err, Uint16 addr);
+15, -4
 1@@ -15,6 +15,17 @@
 2 #include "devices/file.h"
 3 #include "devices/datetime.h"
 4 
 5+/*
 6+Copyright (c) 2022 Devine Lu Linvega
 7+
 8+Permission to use, copy, modify, and distribute this software for any
 9+purpose with or without fee is hereby granted, provided that the above
10+copyright notice and this permission notice appear in all copies.
11+
12+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13+WITH REGARD TO THIS SOFTWARE.
14+*/
15+
16 static XImage *ximage;
17 static Display *display;
18 static Visual *visual;
19@@ -81,7 +92,7 @@ emu_deo(Uxn *u, Uint8 addr, Uint8 v)
20 }
21 
22 static void
23-emu_redraw(void)
24+emu_draw(void)
25 {
26 	screen_redraw(&uxn_screen, uxn_screen.pixels);
27 	XPutImage(display, window, DefaultGC(display, 0), ximage, 0, 0, 0, 0, uxn_screen.width, uxn_screen.height);
28@@ -142,7 +153,7 @@ emu_event(Uxn *u)
29 	XNextEvent(display, &ev);
30 	switch(ev.type) {
31 	case Expose:
32-		emu_redraw();
33+		emu_draw();
34 		break;
35 	case ClientMessage: {
36 		XDestroyImage(ximage);
37@@ -213,7 +224,6 @@ main(int argc, char **argv)
38 	char expirations[8];
39 	struct pollfd fds[2];
40 	static const struct itimerspec screen_tspec = {{0, 16666666}, {0, 16666666}};
41-	/* TODO: Try loading launcher.rom if present */
42 	if(argc < 2)
43 		return emu_error("Usage", "uxncli game.rom args");
44 	/* start sequence */
45@@ -227,6 +237,7 @@ main(int argc, char **argv)
46 		while(*p) console_input(&u, *p++);
47 		console_input(&u, '\n');
48 	}
49+	/* timer */
50 	fds[0].fd = XConnectionNumber(display);
51 	fds[1].fd = timerfd_create(CLOCK_MONOTONIC, 0);
52 	timerfd_settime(fds[1].fd, 0, &screen_tspec, NULL);
53@@ -242,7 +253,7 @@ main(int argc, char **argv)
54 			uxn_eval(&u, GETVEC(&u.dev[0x20])); /* Call the vector once, even if the timer fired multiple times */
55 		}
56 		if(uxn_screen.fg.changed || uxn_screen.bg.changed)
57-			emu_redraw();
58+			emu_draw();
59 	}
60 	XDestroyImage(ximage);
61 	return 0;