uxn

Varvara Ordinator, written in ANSI C(SDL2)
git clone https://git.eamoncaddigan.net/uxn.git
Log | Files | Refs | README | LICENSE

commit 4789d8cceff9db2381ba380dedaeb51418543e3a
parent 0ee477615bc26ed141efedcbb099b2d2ee5b4961
Author: neauoire <aliceffekt@gmail.com>
Date:   Mon,  3 Jan 2022 13:29:47 -0800

Removed peek16

Diffstat:
Msrc/devices/file.c | 4+++-
Msrc/uxn.c | 2--
Msrc/uxn.h | 2--
Msrc/uxnemu.c | 17++++++++++++-----
4 files changed, 15 insertions(+), 10 deletions(-)

diff --git 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 @@ -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 @@ -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 @@ -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,