From 486a60b1bd4a1fb8941542ef7f06e313d612fadb Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Wed, 1 Mar 2023 10:49:25 -0800 Subject: [PATCH] Removed PEKDEV macro --- src/devices/audio.c | 9 +++------ src/devices/file.c | 14 +++++++------- src/uxn.h | 1 - 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/devices/audio.c b/src/devices/audio.c index 2617bce..e3db676 100644 --- a/src/devices/audio.c +++ b/src/devices/audio.c @@ -75,18 +75,15 @@ void audio_start(int instance, Uint8 *d, Uxn *u) { UxnAudio *c = &uxn_audio[instance]; - Uint16 addr, adsr; - Uint8 pitch; - PEKDEV(adsr, 0x8); - PEKDEV(c->len, 0xa); - PEKDEV(addr, 0xc); + Uint8 pitch = d[0xf] & 0x7f; + Uint16 addr = PEEK16(d + 0xc), adsr = PEEK16(d + 0x8); + c->len = PEEK16(d + 0xa); if(c->len > 0x10000 - addr) c->len = 0x10000 - addr; c->addr = &u->ram[addr]; c->volume[0] = d[0xe] >> 4; c->volume[1] = d[0xe] & 0xf; c->repeat = !(d[0xf] & 0x80); - pitch = d[0xf] & 0x7f; if(pitch < 108 && c->len) c->advance = advances[pitch % 12] >> (8 - pitch / 12); else { diff --git a/src/devices/file.c b/src/devices/file.c index 1e583a8..f1e7ce4 100644 --- a/src/devices/file.c +++ b/src/devices/file.c @@ -237,8 +237,8 @@ file_deo(Uint8 id, Uint8 *ram, Uint8 *d, Uint8 port) Uint16 addr, len, res; switch(port) { case 0x5: - PEKDEV(addr, 0x4); - PEKDEV(len, 0xa); + addr = PEEK16(d + 0x4); + len = PEEK16(d + 0xa); if(len > 0x10000 - addr) len = 0x10000 - addr; res = file_stat(c, &ram[addr], len); @@ -249,21 +249,21 @@ file_deo(Uint8 id, Uint8 *ram, Uint8 *d, Uint8 port) POKDEV(0x2, res); break; case 0x9: - PEKDEV(addr, 0x8); + addr = PEEK16(d + 0x8); res = file_init(c, (char *)&ram[addr], 0x10000 - addr, 0); POKDEV(0x2, res); break; case 0xd: - PEKDEV(addr, 0xc); - PEKDEV(len, 0xa); + addr = PEEK16(d + 0xc); + len = PEEK16(d + 0xa); if(len > 0x10000 - addr) len = 0x10000 - addr; res = file_read(c, &ram[addr], len); POKDEV(0x2, res); break; case 0xf: - PEKDEV(addr, 0xe); - PEKDEV(len, 0xa); + addr = PEEK16(d + 0xe); + len = PEEK16(d + 0xa); if(len > 0x10000 - addr) len = 0x10000 - addr; res = file_write(c, &ram[addr], len, d[0x7]); diff --git a/src/uxn.h b/src/uxn.h index 75ba1ff..7bdc8ea 100644 --- a/src/uxn.h +++ b/src/uxn.h @@ -17,7 +17,6 @@ WITH REGARD TO THIS SOFTWARE. #define PEEK16(d) ((d)[0] << 8 | (d)[1]) #define POKDEV(x, y) { d[(x)] = (y) >> 8; d[(x) + 1] = (y); } -#define PEKDEV(o, x) { (o) = (d[(x)] << 8) + d[(x) + 1]; } /* clang-format on */