From c2b0667496096784fe28d7b89c86e26882849b82 Mon Sep 17 00:00:00 2001 From: Andrew Alderwick Date: Mon, 2 Jan 2023 14:40:23 +0000 Subject: [PATCH 1/5] Update Copyright years. --- src/devices/audio.c | 3 +-- src/devices/controller.c | 2 +- src/devices/datetime.c | 2 +- src/devices/file.c | 2 +- src/devices/mouse.c | 2 +- src/devices/screen.c | 3 +-- src/devices/system.c | 2 +- src/uxn.c | 2 +- src/uxnasm.c | 2 +- src/uxncli.c | 2 +- src/uxnemu.c | 2 +- 11 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/devices/audio.c b/src/devices/audio.c index ea06fd9..90d9e02 100644 --- a/src/devices/audio.c +++ b/src/devices/audio.c @@ -2,8 +2,7 @@ #include "audio.h" /* -Copyright (c) 2021 Devine Lu Linvega -Copyright (c) 2021 Andrew Alderwick +Copyright (c) 2021-2023 Devine Lu Linvega, Andrew Alderwick Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above diff --git a/src/devices/controller.c b/src/devices/controller.c index 55a7d06..3a08c65 100644 --- a/src/devices/controller.c +++ b/src/devices/controller.c @@ -2,7 +2,7 @@ #include "controller.h" /* -Copyright (c) 2021 Devine Lu Linvega, Andrew Alderwick +Copyright (c) 2021-2023 Devine Lu Linvega, Andrew Alderwick Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above diff --git a/src/devices/datetime.c b/src/devices/datetime.c index e7a9f86..41b0f7d 100644 --- a/src/devices/datetime.c +++ b/src/devices/datetime.c @@ -4,7 +4,7 @@ #include "datetime.h" /* -Copyright (c) 2021 Devine Lu Linvega, Andrew Alderwick +Copyright (c) 2021-2023 Devine Lu Linvega, Andrew Alderwick Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above diff --git a/src/devices/file.c b/src/devices/file.c index 18a518a..3f7144e 100644 --- a/src/devices/file.c +++ b/src/devices/file.c @@ -16,7 +16,7 @@ #include "file.h" /* -Copyright (c) 2021 Devine Lu Linvega, Andrew Alderwick +Copyright (c) 2021-2023 Devine Lu Linvega, Andrew Alderwick Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above diff --git a/src/devices/mouse.c b/src/devices/mouse.c index 0d6d7e8..935c1c6 100644 --- a/src/devices/mouse.c +++ b/src/devices/mouse.c @@ -2,7 +2,7 @@ #include "mouse.h" /* -Copyright (c) 2021 Devine Lu Linvega, Andrew Alderwick +Copyright (c) 2021-2023 Devine Lu Linvega, Andrew Alderwick Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above diff --git a/src/devices/screen.c b/src/devices/screen.c index 3199e05..69ad2b2 100644 --- a/src/devices/screen.c +++ b/src/devices/screen.c @@ -4,8 +4,7 @@ #include "screen.h" /* -Copyright (c) 2021 Devine Lu Linvega -Copyright (c) 2021 Andrew Alderwick +Copyright (c) 2021-2023 Devine Lu Linvega, Andrew Alderwick Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above diff --git a/src/devices/system.c b/src/devices/system.c index f1607cd..ece125a 100644 --- a/src/devices/system.c +++ b/src/devices/system.c @@ -4,7 +4,7 @@ #include "system.h" /* -Copyright (c) 2022 Devine Lu Linvega, Andrew Alderwick +Copyright (c) 2022-2023 Devine Lu Linvega, Andrew Alderwick Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above diff --git a/src/uxn.c b/src/uxn.c index 6228bbf..b6aa0fd 100644 --- a/src/uxn.c +++ b/src/uxn.c @@ -1,7 +1,7 @@ #include "uxn.h" /* -Copyright (u) 2022 Devine Lu Linvega, Andrew Alderwick, Andrew Richards +Copyright (u) 2022-2023 Devine Lu Linvega, Andrew Alderwick, Andrew Richards Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above diff --git a/src/uxnasm.c b/src/uxnasm.c index cae3270..f51998d 100644 --- a/src/uxnasm.c +++ b/src/uxnasm.c @@ -1,7 +1,7 @@ #include /* -Copyright (c) 2021 Devine Lu Linvega +Copyright (c) 2021-2023 Devine Lu Linvega, Andrew Alderwick Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above diff --git a/src/uxncli.c b/src/uxncli.c index 3c50e2b..02a1c29 100644 --- a/src/uxncli.c +++ b/src/uxncli.c @@ -7,7 +7,7 @@ #include "devices/datetime.h" /* -Copyright (c) 2021 Devine Lu Linvega +Copyright (c) 2021-2023 Devine Lu Linvega, Andrew Alderwick Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above diff --git a/src/uxnemu.c b/src/uxnemu.c index 76af70e..e0d1893 100644 --- a/src/uxnemu.c +++ b/src/uxnemu.c @@ -23,7 +23,7 @@ #pragma clang diagnostic pop /* -Copyright (c) 2021 Devine Lu Linvega +Copyright (c) 2021-2023 Devine Lu Linvega, Andrew Alderwick Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above From d94a84bc936e4a2c41338c386a33ba8fb4cc5b43 Mon Sep 17 00:00:00 2001 From: Andrew Alderwick Date: Mon, 2 Jan 2023 15:01:55 +0000 Subject: [PATCH 2/5] Port Audio to new devices scheme. --- src/devices/audio.c | 18 +++++++------- src/devices/audio.h | 19 +------------- src/uxnemu.c | 60 ++++++++++++++++++++++++--------------------- 3 files changed, 42 insertions(+), 55 deletions(-) diff --git a/src/devices/audio.c b/src/devices/audio.c index 90d9e02..2617bce 100644 --- a/src/devices/audio.c +++ b/src/devices/audio.c @@ -72,21 +72,21 @@ audio_render(int instance, Sint16 *sample, Sint16 *end) } void -audio_start(int instance, Device *d) +audio_start(int instance, Uint8 *d, Uxn *u) { UxnAudio *c = &uxn_audio[instance]; Uint16 addr, adsr; Uint8 pitch; - DEVPEEK16(adsr, 0x8); - DEVPEEK16(c->len, 0xa); - DEVPEEK16(addr, 0xc); + PEKDEV(adsr, 0x8); + PEKDEV(c->len, 0xa); + PEKDEV(addr, 0xc); if(c->len > 0x10000 - addr) c->len = 0x10000 - addr; - c->addr = &d->u->ram[addr]; - c->volume[0] = d->dat[0xe] >> 4; - c->volume[1] = d->dat[0xe] & 0xf; - c->repeat = !(d->dat[0xf] & 0x80); - pitch = d->dat[0xf] & 0x7f; + 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/audio.h b/src/devices/audio.h index 03469ca..bbf4afd 100644 --- a/src/devices/audio.h +++ b/src/devices/audio.h @@ -15,25 +15,8 @@ typedef signed int Sint32; #define SAMPLE_FREQUENCY 44100 #define POLYPHONY 4 -#define DEVPEEK16(o, x) \ - { \ - (o) = (d->dat[(x)] << 8) + d->dat[(x) + 1]; \ - } -#define DEVPOKE16(x, y) \ - { \ - d->dat[(x)] = (y) >> 8; \ - d->dat[(x) + 1] = (y); \ - } - -typedef struct Device { - struct Uxn *u; - Uint8 dat[16]; - Uint8 (*dei)(struct Device *d, Uint8); - void (*deo)(struct Device *d, Uint8); -} Device; - Uint8 audio_get_vu(int instance); Uint16 audio_get_position(int instance); int audio_render(int instance, Sint16 *sample, Sint16 *end); -void audio_start(int instance, Device *d); +void audio_start(int instance, Uint8 *d, Uxn *u); void audio_finished_handler(int instance); diff --git a/src/uxnemu.c b/src/uxnemu.c index e0d1893..b56c251 100644 --- a/src/uxnemu.c +++ b/src/uxnemu.c @@ -48,7 +48,6 @@ static SDL_Thread *stdin_thread; /* devices */ -static Device *devaudio0; static Uint8 zoom = 1; static Uint32 stdin_event, audio0_event; static Uint64 exec_deadline, deadline_interval, ms_interval; @@ -82,12 +81,39 @@ console_deo(Uint8 *d, Uint8 port) } } +static Uint8 +audio_dei(int instance, Uint8 *d, Uint8 port) +{ + if(!audio_id) return d[port]; + switch(port) { + case 0x4: return audio_get_vu(instance); + case 0x2: POKDEV(0x2, audio_get_position(instance)); /* fall through */ + default: return d[port]; + } +} + +static void +audio_deo(int instance, Uint8 *d, Uint8 port, Uxn *u) +{ + if(!audio_id) return; + if(port == 0xf) { + SDL_LockAudioDevice(audio_id); + audio_start(instance, d, u); + SDL_UnlockAudioDevice(audio_id); + SDL_PauseAudioDevice(audio_id, 0); + } +} + static Uint8 emu_dei(Uxn *u, Uint8 addr) { Uint8 p = addr & 0x0f, d = addr & 0xf0; switch(d) { case 0x20: return screen_dei(&u->dev[d], p); + case 0x30: return audio_dei(0, &u->dev[d], p); + case 0x40: return audio_dei(1, &u->dev[d], p); + case 0x50: return audio_dei(2, &u->dev[d], p); + case 0x60: return audio_dei(3, &u->dev[d], p); case 0xa0: return file_dei(0, &u->dev[d], p); case 0xb0: return file_dei(1, &u->dev[d], p); case 0xc0: return datetime_dei(&u->dev[d], p); @@ -109,6 +135,10 @@ emu_deo(Uxn *u, Uint8 addr, Uint8 v) break; case 0x10: console_deo(&u->dev[d], p); break; case 0x20: screen_deo(u->ram, &u->dev[d], p); break; + case 0x30: audio_deo(0, &u->dev[d], p, u); break; + case 0x40: audio_deo(1, &u->dev[d], p, u); break; + case 0x50: audio_deo(2, &u->dev[d], p, u); break; + case 0x60: audio_deo(3, &u->dev[d], p, u); break; case 0xa0: file_deo(0, u->ram, &u->dev[d], p); break; case 0xb0: file_deo(1, u->ram, &u->dev[d], p); break; } @@ -227,31 +257,6 @@ init(void) #pragma mark - Devices -static Uint8 -audio_dei(Device *d, Uint8 port) -{ - int instance = d - devaudio0; - if(!audio_id) return d->dat[port]; - switch(port) { - case 0x4: return audio_get_vu(instance); - case 0x2: DEVPOKE16(0x2, audio_get_position(instance)); /* fall through */ - default: return d->dat[port]; - } -} - -static void -audio_deo(Device *d, Uint8 port) -{ - int instance = d - devaudio0; - if(!audio_id) return; - if(port == 0xf) { - SDL_LockAudioDevice(audio_id); - audio_start(instance, d); - SDL_UnlockAudioDevice(audio_id); - SDL_PauseAudioDevice(audio_id, 0); - } -} - /* Boot */ static int @@ -379,8 +384,7 @@ handle_events(Uxn *u) } /* Audio */ else if(event.type >= audio0_event && event.type < audio0_event + POLYPHONY) { - /* Device *d = devaudio0 + (event.type - audio0_event); - uxn_eval(u, GETVECTOR(d)); */ + uxn_eval(u, GETVEC(&u->dev[0x30 + 0x10 * (event.type - audio0_event)])); } /* Mouse */ else if(event.type == SDL_MOUSEMOTION) From 1cb66df8689ba834ce4c430fc59719ab48a9ed1d Mon Sep 17 00:00:00 2001 From: Andrew Alderwick Date: Mon, 2 Jan 2023 15:07:34 +0000 Subject: [PATCH 3/5] (asma) Disable recursion tests that no longer function. --- etc/asma-test.sh | 16 ++++++++-------- projects/library/asma.tal | 7 ------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/etc/asma-test.sh b/etc/asma-test.sh index 48aae5c..a530ae1 100755 --- a/etc/asma-test.sh +++ b/etc/asma-test.sh @@ -86,14 +86,14 @@ expect_failure 'Memory overwrite: SUB' <<'EOD' |2000 ADD |1000 SUB EOD -expect_failure 'Recursion level too deep:' <<'EOD' -%me { you } -%you { me } -|1000 me -EOD -expect_failure 'Recursion level too deep: ~asma-test/in.tal' <<'EOD' -~asma-test/in.tal -EOD +# expect_failure 'Recursion level too deep:' <<'EOD' +# %me { you } +# %you { me } +# |1000 me +# EOD +# expect_failure 'Recursion level too deep: ~asma-test/in.tal' <<'EOD' +# ~asma-test/in.tal +# EOD expect_failure 'Label not found: ;blah' <<'EOD' |1000 ;blah EOD diff --git a/projects/library/asma.tal b/projects/library/asma.tal index b1bae87..69f816d 100644 --- a/projects/library/asma.tal +++ b/projects/library/asma.tal @@ -833,7 +833,6 @@ ( hex short ) ,asma-short-helper/raw JMP ¬-hex - .System/rst DEI #e0 GTH ,&too-deep JCN ;asma-trees/macros ;asma-traverse-tree JSR2 ,¬-macro JCN ¯o-loop @@ -855,12 +854,7 @@ ;asma-msg-token ;asma/error STA2 JMP2r - &too-deep - ;asma-msg-too-deep ;asma/error STA2 - JMP2r - @asma-include - .System/rst DEI #e0 GTH ,asma-normal-body/too-deep JCN ;heap LDA2 ;asma/token LDA2 ;append-heap-string JSR2 ;asma-assemble-file-pass JSR2 @@ -876,7 +870,6 @@ @asma-msg-token "Unrecognised 20 "token 00 @asma-msg-macro "Macro 20 "already 20 "exists 00 @asma-msg-rewound "Memory 20 "overwrite 00 -@asma-msg-too-deep "Recursion 20 "level 20 "too 20 "deep 00 @asma-msg-redefined "Label 20 "redefined 00 ( trees ) From 50e08f12cdf413f691ecf6004a6af55a711746ac Mon Sep 17 00:00:00 2001 From: Andrew Alderwick Date: Mon, 2 Jan 2023 15:14:19 +0000 Subject: [PATCH 4/5] Disable Windows build until new File device is fixed. --- .build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.build.yml b/.build.yml index 719ba61..a9b8289 100644 --- a/.build.yml +++ b/.build.yml @@ -46,7 +46,7 @@ tasks: done [ -e ~/.ssh/id_rsa ] || complete-build - build-windows: | - if ssh -o ConnectTimeout=10 win true; then + if false && ssh -o ConnectTimeout=10 win true; then ssh win "export PATH=\"\${PATH}:/mingw64/bin\"; set -ex; cd uxn; git fetch; git checkout .; git clean -xfd; git checkout $(cd uxn && git rev-parse HEAD); MSYSTEM=MSYS ./build.sh --no-run" rsync -rp win:uxn/bin/ build/uxn-win64/uxn/ else From 5cacb3f241468907e31245da7d14aa156d68ff25 Mon Sep 17 00:00:00 2001 From: Andrew Alderwick Date: Mon, 2 Jan 2023 15:23:28 +0000 Subject: [PATCH 5/5] Fix macOS build. --- src/devices/file.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/devices/file.c b/src/devices/file.c index 3f7144e..08b39e9 100644 --- a/src/devices/file.c +++ b/src/devices/file.c @@ -132,7 +132,9 @@ retry_realpath(const char *file_name) else return NULL; } - return strdup(r); + x = malloc(strlen(r) + 1); + strcpy(x, r); + return x; } static void