Browse code

Minor cleanup

neauoire authored on 05/04/2021 03:35:52
Showing 4 changed files
... ...
@@ -28,7 +28,7 @@ else
28 28
 fi
29 29
 
30 30
 echo "Assembling.."
31
-./bin/assembler projects/examples/dev.audio.usm bin/boot.rom
31
+./bin/assembler projects/examples/dev.controller.usm bin/boot.rom
32 32
 
33 33
 echo "Running.."
34 34
 if [ "${2}" = '--cli' ]; 
... ...
@@ -99,6 +99,12 @@ setflag(Uint8 *a, char flag, int b)
99 99
 		*a &= (~flag);
100 100
 }
101 101
 
102
+int
103
+getflag(Uint8 *a, char flag)
104
+{
105
+	return *a & flag;
106
+}
107
+
102 108
 #pragma mark - Paint
103 109
 
104 110
 void
... ...
@@ -16,15 +16,12 @@ WITH REGARD TO THIS SOFTWARE.
16 16
 #pragma mark - Operations
17 17
 
18 18
 /* clang-format off */
19
-int    getflag(Uint8 *a, char flag) { return *a & flag; }
20 19
 Uint8  devpoke8(Uxn *u, Uint8 id, Uint8 b0, Uint8 b1){ return id < 0x10 ? u->dev[id].poke(u, PAGE_DEVICE + id * 0x10, b0, b1) : b1; }
21
-
22 20
 void   push8(Stack *s, Uint8 a) { if (s->ptr == 0xff) { s->error = 2; return; } s->dat[s->ptr++] = a; }
23 21
 Uint8  pop8(Stack *s) { if (s->ptr == 0) { s->error = 1; return 0; } return s->dat[--s->ptr]; }
24 22
 Uint8  peek8(Stack *s, Uint8 a) { if (s->ptr < a + 1) s->error = 1; return s->dat[s->ptr - a - 1]; }
25 23
 void   mempoke8(Uxn *u, Uint16 a, Uint8 b) { u->ram.dat[a] = (a & 0xff00) == PAGE_DEVICE ? devpoke8(u, (a & 0xff) >> 4, a & 0xf, b) : b; }
26 24
 Uint8  mempeek8(Uxn *u, Uint16 a) { return u->ram.dat[a]; }
27
-
28 25
 void   push16(Stack *s, Uint16 a) { push8(s, a >> 8); push8(s, a); }
29 26
 Uint16 pop16(Stack *s) { return pop8(s) + (pop8(s) << 8); }
30 27
 Uint16 peek16(Stack *s, Uint8 a) { return peek8(s, a * 2) + (peek8(s, a * 2 + 1) << 8); }
... ...
@@ -118,6 +115,7 @@ int
118 115
 haltuxn(Uxn *u, char *name, int id)
119 116
 {
120 117
 	printf("Halted: %s#%04x, at 0x%04x\n", name, id, u->ram.ptr);
118
+	u->ram.ptr = 0;
121 119
 	return 0;
122 120
 }
123 121
 
... ...
@@ -148,8 +146,7 @@ evaluxn(Uxn *u, Uint16 vec)
148 146
 	u->wst.error = 0;
149 147
 	u->rst.error = 0;
150 148
 	while(u->ram.ptr) {
151
-		Uint8 instr = u->ram.dat[u->ram.ptr++];
152
-		if(!stepuxn(u, instr))
149
+		if(!stepuxn(u, u->ram.dat[u->ram.ptr++]))
153 150
 			return 0;
154 151
 	}
155 152
 	return 1;
... ...
@@ -16,8 +16,6 @@ typedef signed char Sint8;
16 16
 typedef unsigned short Uint16;
17 17
 typedef signed short Sint16;
18 18
 
19
-#define FLAG_LIT1 0x04
20
-#define FLAG_LIT2 0x08
21 19
 #define PAGE_DEVICE 0x0100
22 20
 #define PAGE_VECTORS 0x0200
23 21
 
... ...
@@ -44,7 +42,6 @@ typedef struct Uxn {
44 42
 	Device dev[16];
45 43
 } Uxn;
46 44
 
47
-int getflag(Uint8 *status, char flag);
48 45
 int loaduxn(Uxn *c, char *filepath);
49 46
 int bootuxn(Uxn *c);
50 47
 int evaluxn(Uxn *u, Uint16 vec);