From 4789d8cceff9db2381ba380dedaeb51418543e3a Mon Sep 17 00:00:00 2001 From: neauoire Date: Mon, 3 Jan 2022 13:29:47 -0800 Subject: [PATCH] Removed peek16 --- src/devices/file.c | 4 +++- src/uxn.c | 2 -- src/uxn.h | 2 -- src/uxnemu.c | 17 ++++++++++++----- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/devices/file.c b/src/devices/file.c index 473abd8..84526e9 100644 --- a/src/devices/file.c +++ b/src/devices/file.c @@ -146,7 +146,9 @@ file_deo(Device *d, Uint8 port) { Uint16 a, b, res; switch(port) { - case 0x1: d->vector = peek16(d->dat, 0x0); break; + case 0x1: + DEVPEEK16(d->vector, 0x0); + break; case 0x9: DEVPEEK16(a, 0x8); res = file_init(&d->mem[a]); diff --git a/src/uxn.c b/src/uxn.c index f4ef365..f16bb20 100644 --- a/src/uxn.c +++ b/src/uxn.c @@ -31,8 +31,6 @@ WITH REGARD TO THIS SOFTWARE. #define DEVW(d, x, y) { dev = (d); if(bs) { DEVW8((x), (y) >> 8); DEVW8((x) + 1, (y)); } else { DEVW8((x), (y)) } } #define WARP(x) { if(bs) u->ram.ptr = (x); else u->ram.ptr += (Sint8)(x); } -Uint16 peek16(Uint8 *m, Uint16 a) { Uint16 r = m[a] << 8; return r + m[a + 1]; } - int uxn_eval(Uxn *u, Uint16 vec) { diff --git a/src/uxn.h b/src/uxn.h index c936b68..7e4fd66 100644 --- a/src/uxn.h +++ b/src/uxn.h @@ -48,8 +48,6 @@ typedef struct Uxn { Device dev[16]; } Uxn; -Uint16 peek16(Uint8 *m, Uint16 a); - int uxn_boot(Uxn *c, Uint8 *memory); int uxn_eval(Uxn *u, Uint16 vec); int uxn_halt(Uxn *u, Uint8 error, char *name, int id); diff --git a/src/uxnemu.c b/src/uxnemu.c index eb77932..3b0f05c 100644 --- a/src/uxnemu.c +++ b/src/uxnemu.c @@ -217,13 +217,16 @@ audio_deo(Device *d, Uint8 port) UxnAudio *c = &uxn_audio[d - devaudio0]; if(!audio_id) return; if(port == 0xf) { + Uint16 addr, adsr; SDL_LockAudioDevice(audio_id); - c->len = peek16(d->dat, 0xa); - c->addr = &d->mem[peek16(d->dat, 0xc)]; + DEVPEEK16(adsr, 0x8); + DEVPEEK16(c->len, 0xa); + DEVPEEK16(addr, 0xc); + c->addr = &d->mem[addr]; c->volume[0] = d->dat[0xe] >> 4; c->volume[1] = d->dat[0xe] & 0xf; c->repeat = !(d->dat[0xf] & 0x80); - audio_start(c, peek16(d->dat, 0x8), d->dat[0xf] & 0x7f); + audio_start(c, adsr, d->dat[0xf] & 0x7f); SDL_UnlockAudioDevice(audio_id); SDL_PauseAudioDevice(audio_id, 0); } @@ -444,8 +447,12 @@ run(Uxn *u) SDL_free(event.drop.file); } /* Audio */ - else if(event.type >= audio0_event && event.type < audio0_event + POLYPHONY) - uxn_eval(u, peek16((devaudio0 + (event.type - audio0_event))->dat, 0)); + else if(event.type >= audio0_event && event.type < audio0_event + POLYPHONY) { + Device *d = devaudio0 + (event.type - audio0_event); + Uint16 res; + DEVPEEK16(res, 0x00); + uxn_eval(u, res); + } /* Mouse */ else if(event.type == SDL_MOUSEMOTION) mouse_pos(devmouse,