Browse code

Emulator functions prefixed with emu_ instead of uxn_

Devine Lu Linvega authored on 24/07/2023 02:18:11
Showing 5 changed files
... ...
@@ -96,27 +96,6 @@ system_deo(Uxn *u, Uint8 *d, Uint8 port)
96 96
 	}
97 97
 }
98 98
 
99
-/* Errors */
100
-
101
-int
102
-uxn_halt(Uxn *u, Uint8 instr, Uint8 err, Uint16 addr)
103
-{
104
-	Uint8 *d = &u->dev[0];
105
-	Uint16 handler = PEEK2(d);
106
-	if(handler) {
107
-		u->wst.ptr = 4;
108
-		u->wst.dat[0] = addr >> 0x8;
109
-		u->wst.dat[1] = addr & 0xff;
110
-		u->wst.dat[2] = instr;
111
-		u->wst.dat[3] = err;
112
-		return uxn_eval(u, handler);
113
-	} else {
114
-		system_inspect(u);
115
-		fprintf(stderr, "%s %s, by %02x at 0x%04x.\n", (instr & 0x40) ? "Return-stack" : "Working-stack", errors[err - 1], instr, addr);
116
-	}
117
-	return 0;
118
-}
119
-
120 99
 /* Console */
121 100
 
122 101
 int
... ...
@@ -142,3 +121,24 @@ console_deo(Uint8 *d, Uint8 port)
142 121
 		return;
143 122
 	}
144 123
 }
124
+
125
+/* Errors */
126
+
127
+int
128
+emu_halt(Uxn *u, Uint8 instr, Uint8 err, Uint16 addr)
129
+{
130
+	Uint8 *d = &u->dev[0];
131
+	Uint16 handler = PEEK2(d);
132
+	if(handler) {
133
+		u->wst.ptr = 4;
134
+		u->wst.dat[0] = addr >> 0x8;
135
+		u->wst.dat[1] = addr & 0xff;
136
+		u->wst.dat[2] = instr;
137
+		u->wst.dat[3] = err;
138
+		return uxn_eval(u, handler);
139
+	} else {
140
+		system_inspect(u);
141
+		fprintf(stderr, "%s %s, by %02x at 0x%04x.\n", (instr & 0x40) ? "Return-stack" : "Working-stack", errors[err - 1], instr, addr);
142
+	}
143
+	return 0;
144
+}
... ...
@@ -25,13 +25,13 @@ WITH REGARD TO THIS SOFTWARE.
25 25
 #define N2 PEEK2(s->dat + s->ptr - 4)
26 26
 #define L2 PEEK2(s->dat + s->ptr - 6)
27 27
 
28
-#define HALT(c)    { return uxn_halt(u, ins, (c), pc - 1); }
28
+#define HALT(c)    { return emu_halt(u, ins, (c), pc - 1); }
29 29
 #define FLIP       { s = ins & 0x40 ? &u->wst : &u->rst; }
30 30
 #define SET(x, y)  { if(x > s->ptr) HALT(1) tmp = (x & k) + y + s->ptr; if(tmp > 254) HALT(2) s->ptr = tmp; }
31 31
 #define PUT(o, v)  { s->dat[(s->ptr - 1 - (o))] = (v); }
32 32
 #define PUT2(o, v) { tmp = (v); POKE2(s->dat + (s->ptr - o - 2), tmp); }
33
-#define DEO(a, b)  { u->dev[(a)] = (b); if((deo_mask[(a) >> 4] >> ((a) & 0xf)) & 0x1) uxn_deo(u, (a)); }
34
-#define DEI(a, b)  { PUT((a), ((dei_mask[(b) >> 4] >> ((b) & 0xf)) & 0x1) ? uxn_dei(u, (b)) : u->dev[(b)]) }
33
+#define DEO(a, b)  { u->dev[(a)] = (b); if((deo_mask[(a) >> 4] >> ((a) & 0xf)) & 0x1) emu_deo(u, (a)); }
34
+#define DEI(a, b)  { PUT((a), ((dei_mask[(b) >> 4] >> ((b) & 0xf)) & 0x1) ? emu_dei(u, (b)) : u->dev[(b)]) }
35 35
 
36 36
 int
37 37
 uxn_eval(Uxn *u, Uint16 pc)
... ...
@@ -37,9 +37,9 @@ typedef struct Uxn {
37 37
 
38 38
 /* required functions */
39 39
 
40
-extern Uint8 uxn_dei(Uxn *u, Uint8 addr);
41
-extern void uxn_deo(Uxn *u, Uint8 addr);
42
-extern int uxn_halt(Uxn *u, Uint8 instr, Uint8 err, Uint16 addr);
40
+extern Uint8 emu_dei(Uxn *u, Uint8 addr);
41
+extern void emu_deo(Uxn *u, Uint8 addr);
42
+extern int emu_halt(Uxn *u, Uint8 instr, Uint8 err, Uint16 addr);
43 43
 extern Uint16 dei_mask[];
44 44
 extern Uint16 deo_mask[];
45 45
 
... ...
@@ -21,7 +21,7 @@ Uint16 deo_mask[] = {0xc028, 0x0300, 0xc028, 0x8000, 0x8000, 0x8000, 0x8000, 0x0
21 21
 Uint16 dei_mask[] = {0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x07ff, 0x0000, 0x0000, 0x0000};
22 22
 
23 23
 Uint8
24
-uxn_dei(Uxn *u, Uint8 addr)
24
+emu_dei(Uxn *u, Uint8 addr)
25 25
 {
26 26
 	switch(addr & 0xf0) {
27 27
 	case 0xc0: return datetime_dei(u, addr);
... ...
@@ -30,7 +30,7 @@ uxn_dei(Uxn *u, Uint8 addr)
30 30
 }
31 31
 
32 32
 void
33
-uxn_deo(Uxn *u, Uint8 addr)
33
+emu_deo(Uxn *u, Uint8 addr)
34 34
 {
35 35
 	Uint8 p = addr & 0x0f, d = addr & 0xf0;
36 36
 	switch(d) {
... ...
@@ -84,7 +84,7 @@ audio_deo(int instance, Uint8 *d, Uint8 port, Uxn *u)
84 84
 }
85 85
 
86 86
 Uint8
87
-uxn_dei(Uxn *u, Uint8 addr)
87
+emu_dei(Uxn *u, Uint8 addr)
88 88
 {
89 89
 	Uint8 p = addr & 0x0f, d = addr & 0xf0;
90 90
 	switch(d) {
... ...
@@ -99,7 +99,7 @@ uxn_dei(Uxn *u, Uint8 addr)
99 99
 }
100 100
 
101 101
 void
102
-uxn_deo(Uxn *u, Uint8 addr)
102
+emu_deo(Uxn *u, Uint8 addr)
103 103
 {
104 104
 	Uint8 p = addr & 0x0f, d = addr & 0xf0;
105 105
 	switch(d) {
... ...
@@ -165,7 +165,9 @@ set_window_size(SDL_Window *window, int w, int h)
165 165
 	SDL_SetWindowSize(window, w, h);
166 166
 }
167 167
 
168
-int emu_resize(void){
168
+int
169
+emu_resize(void)
170
+{
169 171
 	if(emu_texture != NULL)
170 172
 		SDL_DestroyTexture(emu_texture);
171 173
 	SDL_RenderSetLogicalSize(emu_renderer, uxn_screen.width, uxn_screen.height);