Browse code

Removed PEKDEV macro

Devine Lu Linvega authored on 01/03/2023 18:49:25
Showing 3 changed files
... ...
@@ -75,18 +75,15 @@ void
75 75
 audio_start(int instance, Uint8 *d, Uxn *u)
76 76
 {
77 77
 	UxnAudio *c = &uxn_audio[instance];
78
-	Uint16 addr, adsr;
79
-	Uint8 pitch;
80
-	PEKDEV(adsr, 0x8);
81
-	PEKDEV(c->len, 0xa);
82
-	PEKDEV(addr, 0xc);
78
+	Uint8 pitch = d[0xf] & 0x7f;
79
+	Uint16 addr = PEEK16(d + 0xc), adsr = PEEK16(d + 0x8);
80
+	c->len = PEEK16(d + 0xa);
83 81
 	if(c->len > 0x10000 - addr)
84 82
 		c->len = 0x10000 - addr;
85 83
 	c->addr = &u->ram[addr];
86 84
 	c->volume[0] = d[0xe] >> 4;
87 85
 	c->volume[1] = d[0xe] & 0xf;
88 86
 	c->repeat = !(d[0xf] & 0x80);
89
-	pitch = d[0xf] & 0x7f;
90 87
 	if(pitch < 108 && c->len)
91 88
 		c->advance = advances[pitch % 12] >> (8 - pitch / 12);
92 89
 	else {
... ...
@@ -237,8 +237,8 @@ file_deo(Uint8 id, Uint8 *ram, Uint8 *d, Uint8 port)
237 237
 	Uint16 addr, len, res;
238 238
 	switch(port) {
239 239
 	case 0x5:
240
-		PEKDEV(addr, 0x4);
241
-		PEKDEV(len, 0xa);
240
+		addr = PEEK16(d + 0x4);
241
+		len = PEEK16(d + 0xa);
242 242
 		if(len > 0x10000 - addr)
243 243
 			len = 0x10000 - addr;
244 244
 		res = file_stat(c, &ram[addr], len);
... ...
@@ -249,21 +249,21 @@ file_deo(Uint8 id, Uint8 *ram, Uint8 *d, Uint8 port)
249 249
 		POKDEV(0x2, res);
250 250
 		break;
251 251
 	case 0x9:
252
-		PEKDEV(addr, 0x8);
252
+		addr = PEEK16(d + 0x8);
253 253
 		res = file_init(c, (char *)&ram[addr], 0x10000 - addr, 0);
254 254
 		POKDEV(0x2, res);
255 255
 		break;
256 256
 	case 0xd:
257
-		PEKDEV(addr, 0xc);
258
-		PEKDEV(len, 0xa);
257
+		addr = PEEK16(d + 0xc);
258
+		len = PEEK16(d + 0xa);
259 259
 		if(len > 0x10000 - addr)
260 260
 			len = 0x10000 - addr;
261 261
 		res = file_read(c, &ram[addr], len);
262 262
 		POKDEV(0x2, res);
263 263
 		break;
264 264
 	case 0xf:
265
-		PEKDEV(addr, 0xe);
266
-		PEKDEV(len, 0xa);
265
+		addr = PEEK16(d + 0xe);
266
+		len = PEEK16(d + 0xa);
267 267
 		if(len > 0x10000 - addr)
268 268
 			len = 0x10000 - addr;
269 269
 		res = file_write(c, &ram[addr], len, d[0x7]);
... ...
@@ -17,7 +17,6 @@ WITH REGARD TO THIS SOFTWARE.
17 17
 #define PEEK16(d) ((d)[0] << 8 | (d)[1])
18 18
 
19 19
 #define POKDEV(x, y) { d[(x)] = (y) >> 8; d[(x) + 1] = (y); }
20
-#define PEKDEV(o, x) { (o) = (d[(x)] << 8) + d[(x) + 1]; }
21 20
 
22 21
 /* clang-format on */
23 22