Browse code

Removed peek16

neauoire authored on 03/01/2022 21:29:47
Showing 4 changed files
... ...
@@ -146,7 +146,9 @@ file_deo(Device *d, Uint8 port)
146 146
 {
147 147
 	Uint16 a, b, res;
148 148
 	switch(port) {
149
-	case 0x1: d->vector = peek16(d->dat, 0x0); break;
149
+	case 0x1:
150
+		DEVPEEK16(d->vector, 0x0);
151
+		break;
150 152
 	case 0x9:
151 153
 		DEVPEEK16(a, 0x8);
152 154
 		res = file_init(&d->mem[a]);
... ...
@@ -31,8 +31,6 @@ WITH REGARD TO THIS SOFTWARE.
31 31
 #define DEVW(d, x, y) { dev = (d); if(bs) { DEVW8((x), (y) >> 8); DEVW8((x) + 1, (y)); } else { DEVW8((x), (y)) } }
32 32
 #define WARP(x) { if(bs) u->ram.ptr = (x); else u->ram.ptr += (Sint8)(x); }
33 33
 
34
-Uint16 peek16(Uint8 *m, Uint16 a) { Uint16 r = m[a] << 8; return r + m[a + 1]; }
35
-
36 34
 int
37 35
 uxn_eval(Uxn *u, Uint16 vec)
38 36
 {
... ...
@@ -48,8 +48,6 @@ typedef struct Uxn {
48 48
 	Device dev[16];
49 49
 } Uxn;
50 50
 
51
-Uint16 peek16(Uint8 *m, Uint16 a);
52
-
53 51
 int uxn_boot(Uxn *c, Uint8 *memory);
54 52
 int uxn_eval(Uxn *u, Uint16 vec);
55 53
 int uxn_halt(Uxn *u, Uint8 error, char *name, int id);
... ...
@@ -217,13 +217,16 @@ audio_deo(Device *d, Uint8 port)
217 217
 	UxnAudio *c = &uxn_audio[d - devaudio0];
218 218
 	if(!audio_id) return;
219 219
 	if(port == 0xf) {
220
+		Uint16 addr, adsr;
220 221
 		SDL_LockAudioDevice(audio_id);
221
-		c->len = peek16(d->dat, 0xa);
222
-		c->addr = &d->mem[peek16(d->dat, 0xc)];
222
+		DEVPEEK16(adsr, 0x8);
223
+		DEVPEEK16(c->len, 0xa);
224
+		DEVPEEK16(addr, 0xc);
225
+		c->addr = &d->mem[addr];
223 226
 		c->volume[0] = d->dat[0xe] >> 4;
224 227
 		c->volume[1] = d->dat[0xe] & 0xf;
225 228
 		c->repeat = !(d->dat[0xf] & 0x80);
226
-		audio_start(c, peek16(d->dat, 0x8), d->dat[0xf] & 0x7f);
229
+		audio_start(c, adsr, d->dat[0xf] & 0x7f);
227 230
 		SDL_UnlockAudioDevice(audio_id);
228 231
 		SDL_PauseAudioDevice(audio_id, 0);
229 232
 	}
... ...
@@ -444,8 +447,12 @@ run(Uxn *u)
444 447
 				SDL_free(event.drop.file);
445 448
 			}
446 449
 			/* Audio */
447
-			else if(event.type >= audio0_event && event.type < audio0_event + POLYPHONY)
448
-				uxn_eval(u, peek16((devaudio0 + (event.type - audio0_event))->dat, 0));
450
+			else if(event.type >= audio0_event && event.type < audio0_event + POLYPHONY) {
451
+				Device *d = devaudio0 + (event.type - audio0_event);
452
+				Uint16 res;
453
+				DEVPEEK16(res, 0x00);
454
+				uxn_eval(u, res);
455
+			}
449 456
 			/* Mouse */
450 457
 			else if(event.type == SDL_MOUSEMOTION)
451 458
 				mouse_pos(devmouse,