Browse code

Switch void context increments from pre to post

Andrew Alderwick authored on 04/01/2022 02:04:09
Showing 7 changed files
... ...
@@ -90,7 +90,7 @@ audio_get_vu(UxnAudio *c)
90 90
 	int i;
91 91
 	Sint32 sum[2] = {0, 0};
92 92
 	if(!c->advance || !c->period) return 0;
93
-	for(i = 0; i < 2; ++i) {
93
+	for(i = 0; i < 2; i++) {
94 94
 		if(!c->volume[i]) continue;
95 95
 		sum[i] = 1 + envelope(c, c->age) * c->volume[i] / 0x800;
96 96
 		if(sum[i] > 0xf) sum[i] = 0xf;
... ...
@@ -127,7 +127,7 @@ file_stat(void *dest, Uint16 len)
127 127
 {
128 128
 	char *basename = strrchr(current_filename, '/');
129 129
 	if(basename != NULL)
130
-		++basename;
130
+		basename++;
131 131
 	else
132 132
 		basename = current_filename;
133 133
 	return get_entry(dest, len, current_filename, basename, 0);
... ...
@@ -56,7 +56,7 @@ static void
56 56
 screen_blit(UxnScreen *p, Layer *layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 color, Uint8 flipx, Uint8 flipy, Uint8 twobpp)
57 57
 {
58 58
 	int v, h, opaque = blending[4][color];
59
-	for(v = 0; v < 8; ++v) {
59
+	for(v = 0; v < 8; v++) {
60 60
 		Uint16 c = sprite[v] | (twobpp ? sprite[v + 8] : 0) << 8;
61 61
 		for(h = 7; h >= 0; --h, c >>= 1) {
62 62
 			Uint8 ch = (c & 1) | ((c >> 7) & 2);
... ...
@@ -109,7 +109,7 @@ void
109 109
 screen_clear(UxnScreen *p, Layer *layer)
110 110
 {
111 111
 	Uint32 i, size = p->width * p->height;
112
-	for(i = 0; i < size; ++i)
112
+	for(i = 0; i < size; i++)
113 113
 		layer->pixels[i] = 0x00;
114 114
 	layer->changed = 1;
115 115
 }
... ...
@@ -118,9 +118,9 @@ void
118 118
 screen_redraw(UxnScreen *p, Uint32 *pixels)
119 119
 {
120 120
 	Uint32 i, size = p->width * p->height, palette[16];
121
-	for(i = 0; i < 16; ++i)
121
+	for(i = 0; i < 16; i++)
122 122
 		palette[i] = p->palette[(i >> 2) ? (i >> 2) : (i & 3)];
123
-	for(i = 0; i < size; ++i)
123
+	for(i = 0; i < size; i++)
124 124
 		pixels[i] = palette[p->fg.pixels[i] << 2 | p->bg.pixels[i]];
125 125
 	p->fg.changed = p->bg.changed = 0;
126 126
 }
... ...
@@ -129,7 +129,7 @@ void
129 129
 screen_debug(UxnScreen *p, Uint8 *stack, Uint8 wptr, Uint8 rptr, Uint8 *memory)
130 130
 {
131 131
 	Uint8 i, x, y, b;
132
-	for(i = 0; i < 0x20; ++i) {
132
+	for(i = 0; i < 0x20; i++) {
133 133
 		x = ((i % 8) * 3 + 1) * 8, y = (i / 8 + 1) * 8, b = stack[i];
134 134
 		/* working stack */
135 135
 		screen_blit(p, &p->fg, x, y, font[(b >> 4) & 0xf], 1 + (wptr == i) * 0x7, 0, 0, 0);
... ...
@@ -144,7 +144,7 @@ screen_debug(UxnScreen *p, Uint8 *stack, Uint8 wptr, Uint8 rptr, Uint8 *memory)
144 144
 	screen_blit(p, &p->fg, 0x8, y + 0x10, font[(rptr >> 4) & 0xf], 0x2, 0, 0, 0);
145 145
 	screen_blit(p, &p->fg, 0x10, y + 0x10, font[rptr & 0xf], 0x2, 0, 0, 0);
146 146
 	/* guides */
147
-	for(x = 0; x < 0x10; ++x) {
147
+	for(x = 0; x < 0x10; x++) {
148 148
 		screen_write(p, &p->fg, x, p->height / 2, 2);
149 149
 		screen_write(p, &p->fg, p->width - x, p->height / 2, 2);
150 150
 		screen_write(p, &p->fg, p->width / 2, p->height - x, 2);
... ...
@@ -60,7 +60,7 @@ uxn_eval(Uxn *u, Uint16 pc)
60 60
 		switch(instr & 0x1f) {
61 61
 		/* Stack */
62 62
 		case 0x00: /* LIT */ if(bs) { PEEK16(a, pc) PUSH16(src, a) pc += 2; }
63
-		                     else   { a = u->ram[pc]; PUSH8(src, a) ++pc; } break;
63
+		                     else   { a = u->ram[pc]; PUSH8(src, a) pc++; } break;
64 64
 		case 0x01: /* INC */ POP(a) PUSH(src, a + 1) break;
65 65
 		case 0x02: /* POP */ POP(a) break;
66 66
 		case 0x03: /* DUP */ POP(a) PUSH(src, a) PUSH(src, a) break;
... ...
@@ -110,7 +110,7 @@ uxn_boot(Uxn *u, Uint8 *memory)
110 110
 {
111 111
 	Uint32 i;
112 112
 	char *cptr = (char *)u;
113
-	for(i = 0; i < sizeof(*u); ++i)
113
+	for(i = 0; i < sizeof(*u); i++)
114 114
 		cptr[i] = 0x00;
115 115
 	u->ram = memory;
116 116
 	return 1;
... ...
@@ -57,8 +57,8 @@ static char ops[][4] = {
57 57
 static int   scmp(char *a, char *b, int len) { int i = 0; while(a[i] == b[i]) if(!a[i] || ++i >= len) return 1; return 0; } /* string compare */
58 58
 static int   sihx(char *s) { int i = 0; char c; while((c = s[i++])) if(!(c >= '0' && c <= '9') && !(c >= 'a' && c <= 'f')) return 0; return i > 1; } /* string is hexadecimal */
59 59
 static int   shex(char *s) { int n = 0, i = 0; char c; while((c = s[i++])) if(c >= '0' && c <= '9') n = n * 16 + (c - '0'); else if(c >= 'a' && c <= 'f') n = n * 16 + 10 + (c - 'a'); return n; } /* string to num */
60
-static int   slen(char *s) { int i = 0; while(s[i]) ++i; return i; } /* string length */
61
-static char *scpy(char *src, char *dst, int len) { int i = 0; while((dst[i] = src[i]) && i < len - 2) ++i; dst[i + 1] = '\0'; return dst; } /* string copy */
60
+static int   slen(char *s) { int i = 0; while(s[i]) i++; return i; } /* string length */
61
+static char *scpy(char *src, char *dst, int len) { int i = 0; while((dst[i] = src[i]) && i < len - 2) i++; dst[i + 1] = '\0'; return dst; } /* string copy */
62 62
 static char *scat(char *dst, const char *src) { char *ptr = dst + slen(dst); while(*src) *ptr++ = *src++; *ptr = '\0'; return dst; } /* string cat */
63 63
 
64 64
 /* clang-format on */
... ...
@@ -82,7 +82,7 @@ static Macro *
82 82
 findmacro(char *name)
83 83
 {
84 84
 	int i;
85
-	for(i = 0; i < p.mlen; ++i)
85
+	for(i = 0; i < p.mlen; i++)
86 86
 		if(scmp(p.macros[i].name, name, 64))
87 87
 			return &p.macros[i];
88 88
 	return NULL;
... ...
@@ -92,7 +92,7 @@ static Label *
92 92
 findlabel(char *name)
93 93
 {
94 94
 	int i;
95
-	for(i = 0; i < p.llen; ++i)
95
+	for(i = 0; i < p.llen; i++)
96 96
 		if(scmp(p.labels[i].name, name, 64))
97 97
 			return &p.labels[i];
98 98
 	return NULL;
... ...
@@ -102,7 +102,7 @@ static Uint8
102 102
 findopcode(char *s)
103 103
 {
104 104
 	int i;
105
-	for(i = 0; i < 0x20; ++i) {
105
+	for(i = 0; i < 0x20; i++) {
106 106
 		int m = 0;
107 107
 		if(!scmp(ops[i], s, 3))
108 108
 			continue;
... ...
@@ -116,7 +116,7 @@ findopcode(char *s)
116 116
 				i |= (1 << 7); /* mode: keep */
117 117
 			else
118 118
 				return 0; /* failed to match */
119
-			++m;
119
+			m++;
120 120
 		}
121 121
 		return i;
122 122
 	}
... ...
@@ -331,7 +331,7 @@ parse(char *w, FILE *f)
331 331
 			writeshort(shex(w), 0);
332 332
 		/* macro */
333 333
 		else if((m = findmacro(w))) {
334
-			for(i = 0; i < m->len; ++i)
334
+			for(i = 0; i < m->len; i++)
335 335
 				if(!parse(m->items[i], f))
336 336
 					return 0;
337 337
 			return 1;
... ...
@@ -346,7 +346,7 @@ resolve(void)
346 346
 {
347 347
 	Label *l;
348 348
 	int i;
349
-	for(i = 0; i < p.rlen; ++i) {
349
+	for(i = 0; i < p.rlen; i++) {
350 350
 		Reference *r = &p.refs[i];
351 351
 		switch(r->rune) {
352 352
 		case '.':
... ...
@@ -399,7 +399,7 @@ static void
399 399
 review(char *filename)
400 400
 {
401 401
 	int i;
402
-	for(i = 0; i < p.llen; ++i)
402
+	for(i = 0; i < p.llen; i++)
403 403
 		if(p.labels[i].name[0] >= 'A' && p.labels[i].name[0] <= 'Z')
404 404
 			continue; /* Ignore capitalized labels(devices) */
405 405
 		else if(!p.labels[i].refs)
... ...
@@ -32,8 +32,8 @@ inspect(Stack *s, char *name)
32 32
 {
33 33
 	Uint8 x, y;
34 34
 	fprintf(stderr, "\n%s\n", name);
35
-	for(y = 0; y < 0x04; ++y) {
36
-		for(x = 0; x < 0x08; ++x) {
35
+	for(y = 0; y < 0x04; y++) {
36
+		for(x = 0; x < 0x08; x++) {
37 37
 			Uint8 p = y * 0x08 + x;
38 38
 			fprintf(stderr,
39 39
 				p == s->ptr ? "[%02x]" : " %02x ",
... ...
@@ -181,7 +181,7 @@ main(int argc, char **argv)
181 181
 	/* empty    */ uxn_port(&u, 0xe, nil_dei, nil_deo);
182 182
 	/* empty    */ uxn_port(&u, 0xf, nil_dei, nil_deo);
183 183
 
184
-	for(i = 1; i < argc; ++i) {
184
+	for(i = 1; i < argc; i++) {
185 185
 		if(!loaded++) {
186 186
 			if(!load(&u, argv[i]))
187 187
 				return error("Load", "Failed");
... ...
@@ -65,7 +65,7 @@ audio_callback(void *u, Uint8 *stream, int len)
65 65
 	int i, running = 0;
66 66
 	Sint16 *samples = (Sint16 *)stream;
67 67
 	SDL_memset(stream, 0, len);
68
-	for(i = 0; i < POLYPHONY; ++i)
68
+	for(i = 0; i < POLYPHONY; i++)
69 69
 		running += audio_render(&uxn_audio[i], samples, samples + len / 2);
70 70
 	if(!running)
71 71
 		SDL_PauseAudioDevice(audio_id, 1);
... ...
@@ -520,7 +520,7 @@ main(int argc, char **argv)
520 520
 	/* set default zoom */
521 521
 	if(SDL_GetCurrentDisplayMode(0, &DM) == 0)
522 522
 		set_zoom(DM.w / 1280);
523
-	for(i = 1; i < argc; ++i) {
523
+	for(i = 1; i < argc; i++) {
524 524
 		/* get default zoom from flags */
525 525
 		if(strcmp(argv[i], "-s") == 0) {
526 526
 			if(i < argc - 1)