commit c4622fe
Devine Lu Linvega
·
2026-03-12 01:32:41 +0000 UTC
parent cb43390
Removed old TWOS macro
1 files changed,
+22,
-15
+22,
-15
1@@ -41,7 +41,6 @@ static int rX, rY, rA, rMX, rMY, rMA, rML, rDX, rDY, rL1, rL2;
2 #define HEIGHT (40 * 8)
3
4 #define CLAMP(v, a, b) { if(v < a) v = a; else if(v >= b) v = b; }
5-#define TWOS(v) (v & 0x8000 ? (int)v - 0x10000 : (int)v)
6
7 static inline Uint16 peek2(const Uint8 *d) { return ((Uint16)d[0] << 8) | d[1]; }
8 static inline void poke2(Uint8 *d, Uint16 v) { d[0] = v >> 8, d[1] = v; }
9@@ -144,7 +143,8 @@ console_input(int c, unsigned int type)
10 {
11 if(c == EOF) c = 0, type = CONSOLE_END;
12 dev[0x12] = c, dev[0x17] = type;
13- if(console_vector) uxn_eval(console_vector);
14+ if(console_vector)
15+ uxn_eval(console_vector);
16 return type != CONSOLE_END;
17 }
18
19@@ -561,8 +561,8 @@ static void screen_deo_vector(void) { screen_vector = peek2(&dev[0x20]); }
20 static void screen_deo_width(void) { screen_resize(peek2(&dev[0x22]) & 0xfff, screen_height & 0xfff); }
21 static void screen_deo_height(void) { screen_resize(screen_width & 0xfff, peek2(&dev[0x24]) & 0xfff); }
22 static void screen_deo_auto(void) { rMX = dev[0x26] & 0x1, rMY = dev[0x26] & 0x2, rMA = dev[0x26] & 0x4, rML = dev[0x26] >> 4, rDX = rMX << 3, rDY = rMY << 2; }
23-static void screen_deo_x(void) { rX = (dev[0x28] << 8) | dev[0x29], rX = TWOS(rX); }
24-static void screen_deo_y(void) { rY = (dev[0x2a] << 8) | dev[0x2b], rY = TWOS(rY); }
25+static void screen_deo_x(void) { rX = (dev[0x28] << 8) | dev[0x29], rX = (short)rX; }
26+static void screen_deo_y(void) { rY = (dev[0x2a] << 8) | dev[0x2b], rY = (short)rY; }
27 static void screen_deo_addr(void) { rA = (dev[0x2c] << 8) | dev[0x2d]; }
28
29 /* clang-format on */
30@@ -575,7 +575,8 @@ controller_down(Uint8 mask)
31 {
32 if(mask) {
33 dev[0x82] |= mask;
34- if(controller_vector) uxn_eval(controller_vector);
35+ if(controller_vector)
36+ uxn_eval(controller_vector);
37 }
38 }
39
40@@ -584,7 +585,8 @@ controller_up(Uint8 mask)
41 {
42 if(mask) {
43 dev[0x82] &= (~mask);
44- if(controller_vector) uxn_eval(controller_vector);
45+ if(controller_vector)
46+ uxn_eval(controller_vector);
47 }
48 }
49
50@@ -593,7 +595,8 @@ controller_key(Uint8 key)
51 {
52 if(key) {
53 dev[0x83] = key;
54- if(controller_vector) uxn_eval(controller_vector);
55+ if(controller_vector)
56+ uxn_eval(controller_vector);
57 dev[0x83] = 0;
58 }
59 }
60@@ -611,14 +614,16 @@ static void
61 mouse_down(Uint8 mask)
62 {
63 dev[0x96] |= mask;
64- if(mouse_vector) uxn_eval(mouse_vector);
65+ if(mouse_vector)
66+ uxn_eval(mouse_vector);
67 }
68
69 static void
70 mouse_up(Uint8 mask)
71 {
72 dev[0x96] &= (~mask);
73- if(mouse_vector) uxn_eval(mouse_vector);
74+ if(mouse_vector)
75+ uxn_eval(mouse_vector);
76 }
77
78 static void
79@@ -626,7 +631,8 @@ mouse_pos(Uint16 x, Uint16 y)
80 {
81 poke2(&dev[0x92], x);
82 poke2(&dev[0x94], y);
83- if(mouse_vector) uxn_eval(mouse_vector);
84+ if(mouse_vector)
85+ uxn_eval(mouse_vector);
86 }
87
88 static void
89@@ -634,7 +640,8 @@ mouse_scroll(Uint16 x, Uint16 y)
90 {
91 poke2(&dev[0x9a], x);
92 poke2(&dev[0x9c], -y);
93- if(mouse_vector) uxn_eval(mouse_vector);
94+ if(mouse_vector)
95+ uxn_eval(mouse_vector);
96 poke2(&dev[0x9a], 0);
97 poke2(&dev[0x9c], 0);
98 }
99@@ -679,14 +686,14 @@ make_pathfile(char *pathbuf, const char *filepath, const char *basename)
100 *pathbuf = 0;
101 }
102
103-static unsigned int
104+static inline unsigned int
105 put_fill(Uint8 *dest, unsigned int len, char c)
106 {
107 memset(dest, c, len);
108 return len;
109 }
110
111-static unsigned int
112+static inline unsigned int
113 put_size(Uint8 *dest, unsigned int len, unsigned int size)
114 {
115 unsigned int i;
116@@ -695,7 +702,7 @@ put_size(Uint8 *dest, unsigned int len, unsigned int size)
117 return len;
118 }
119
120-static unsigned int
121+static inline unsigned int
122 put_text(Uint8 *dest, const char *text)
123 {
124 Uint8 *anchor = dest;
125@@ -1304,7 +1311,7 @@ main(int argc, char **argv)
126 {
127 int i = 1;
128 if(argc == 2 && argv[1][0] == '-' && argv[1][1] == 'v')
129- return !fprintf(stdout, "%s - Varvara Emulator, 18 Feb 2026.\n", argv[0]);
130+ return !fprintf(stdout, "%s - Varvara Emulator, 11 Mar 2026.\n", argv[0]);
131 else if(argc == 1)
132 return !fprintf(stdout, "usage: %s [-v] file.rom [args..]\n", argv[0]);
133 else if(!system_boot(argv[i++], argc > 2))