... | ... |
@@ -46,7 +46,7 @@ tasks: |
46 | 46 |
done |
47 | 47 |
[ -e ~/.ssh/id_rsa ] || complete-build |
48 | 48 |
- build-windows: | |
49 |
- if ssh -o ConnectTimeout=10 win true; then |
|
49 |
+ if false && ssh -o ConnectTimeout=10 win true; then |
|
50 | 50 |
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" |
51 | 51 |
rsync -rp win:uxn/bin/ build/uxn-win64/uxn/ |
52 | 52 |
else |
... | ... |
@@ -86,14 +86,14 @@ expect_failure 'Memory overwrite: SUB' <<'EOD' |
86 | 86 |
|2000 ADD |
87 | 87 |
|1000 SUB |
88 | 88 |
EOD |
89 |
-expect_failure 'Recursion level too deep:' <<'EOD' |
|
90 |
-%me { you } |
|
91 |
-%you { me } |
|
92 |
-|1000 me |
|
93 |
-EOD |
|
94 |
-expect_failure 'Recursion level too deep: ~asma-test/in.tal' <<'EOD' |
|
95 |
-~asma-test/in.tal |
|
96 |
-EOD |
|
89 |
+# expect_failure 'Recursion level too deep:' <<'EOD' |
|
90 |
+# %me { you } |
|
91 |
+# %you { me } |
|
92 |
+# |1000 me |
|
93 |
+# EOD |
|
94 |
+# expect_failure 'Recursion level too deep: ~asma-test/in.tal' <<'EOD' |
|
95 |
+# ~asma-test/in.tal |
|
96 |
+# EOD |
|
97 | 97 |
expect_failure 'Label not found: ;blah' <<'EOD' |
98 | 98 |
|1000 ;blah |
99 | 99 |
EOD |
... | ... |
@@ -833,7 +833,6 @@ |
833 | 833 |
( hex short ) ,asma-short-helper/raw JMP |
834 | 834 |
|
835 | 835 |
¬-hex |
836 |
- .System/rst DEI #e0 GTH ,&too-deep JCN |
|
837 | 836 |
;asma-trees/macros ;asma-traverse-tree JSR2 ,¬-macro JCN |
838 | 837 |
|
839 | 838 |
¯o-loop |
... | ... |
@@ -855,12 +854,7 @@ |
855 | 854 |
;asma-msg-token ;asma/error STA2 |
856 | 855 |
JMP2r |
857 | 856 |
|
858 |
- &too-deep |
|
859 |
- ;asma-msg-too-deep ;asma/error STA2 |
|
860 |
- JMP2r |
|
861 |
- |
|
862 | 857 |
@asma-include |
863 |
- .System/rst DEI #e0 GTH ,asma-normal-body/too-deep JCN |
|
864 | 858 |
;heap LDA2 |
865 | 859 |
;asma/token LDA2 ;append-heap-string JSR2 |
866 | 860 |
;asma-assemble-file-pass JSR2 |
... | ... |
@@ -876,7 +870,6 @@ |
876 | 870 |
@asma-msg-token "Unrecognised 20 "token 00 |
877 | 871 |
@asma-msg-macro "Macro 20 "already 20 "exists 00 |
878 | 872 |
@asma-msg-rewound "Memory 20 "overwrite 00 |
879 |
-@asma-msg-too-deep "Recursion 20 "level 20 "too 20 "deep 00 |
|
880 | 873 |
@asma-msg-redefined "Label 20 "redefined 00 |
881 | 874 |
|
882 | 875 |
( trees ) |
... | ... |
@@ -2,8 +2,7 @@ |
2 | 2 |
#include "audio.h" |
3 | 3 |
|
4 | 4 |
/* |
5 |
-Copyright (c) 2021 Devine Lu Linvega |
|
6 |
-Copyright (c) 2021 Andrew Alderwick |
|
5 |
+Copyright (c) 2021-2023 Devine Lu Linvega, Andrew Alderwick |
|
7 | 6 |
|
8 | 7 |
Permission to use, copy, modify, and distribute this software for any |
9 | 8 |
purpose with or without fee is hereby granted, provided that the above |
... | ... |
@@ -73,21 +72,21 @@ audio_render(int instance, Sint16 *sample, Sint16 *end) |
73 | 72 |
} |
74 | 73 |
|
75 | 74 |
void |
76 |
-audio_start(int instance, Device *d) |
|
75 |
+audio_start(int instance, Uint8 *d, Uxn *u) |
|
77 | 76 |
{ |
78 | 77 |
UxnAudio *c = &uxn_audio[instance]; |
79 | 78 |
Uint16 addr, adsr; |
80 | 79 |
Uint8 pitch; |
81 |
- DEVPEEK16(adsr, 0x8); |
|
82 |
- DEVPEEK16(c->len, 0xa); |
|
83 |
- DEVPEEK16(addr, 0xc); |
|
80 |
+ PEKDEV(adsr, 0x8); |
|
81 |
+ PEKDEV(c->len, 0xa); |
|
82 |
+ PEKDEV(addr, 0xc); |
|
84 | 83 |
if(c->len > 0x10000 - addr) |
85 | 84 |
c->len = 0x10000 - addr; |
86 |
- c->addr = &d->u->ram[addr]; |
|
87 |
- c->volume[0] = d->dat[0xe] >> 4; |
|
88 |
- c->volume[1] = d->dat[0xe] & 0xf; |
|
89 |
- c->repeat = !(d->dat[0xf] & 0x80); |
|
90 |
- pitch = d->dat[0xf] & 0x7f; |
|
85 |
+ c->addr = &u->ram[addr]; |
|
86 |
+ c->volume[0] = d[0xe] >> 4; |
|
87 |
+ c->volume[1] = d[0xe] & 0xf; |
|
88 |
+ c->repeat = !(d[0xf] & 0x80); |
|
89 |
+ pitch = d[0xf] & 0x7f; |
|
91 | 90 |
if(pitch < 108 && c->len) |
92 | 91 |
c->advance = advances[pitch % 12] >> (8 - pitch / 12); |
93 | 92 |
else { |
... | ... |
@@ -15,25 +15,8 @@ typedef signed int Sint32; |
15 | 15 |
#define SAMPLE_FREQUENCY 44100 |
16 | 16 |
#define POLYPHONY 4 |
17 | 17 |
|
18 |
-#define DEVPEEK16(o, x) \ |
|
19 |
- { \ |
|
20 |
- (o) = (d->dat[(x)] << 8) + d->dat[(x) + 1]; \ |
|
21 |
- } |
|
22 |
-#define DEVPOKE16(x, y) \ |
|
23 |
- { \ |
|
24 |
- d->dat[(x)] = (y) >> 8; \ |
|
25 |
- d->dat[(x) + 1] = (y); \ |
|
26 |
- } |
|
27 |
- |
|
28 |
-typedef struct Device { |
|
29 |
- struct Uxn *u; |
|
30 |
- Uint8 dat[16]; |
|
31 |
- Uint8 (*dei)(struct Device *d, Uint8); |
|
32 |
- void (*deo)(struct Device *d, Uint8); |
|
33 |
-} Device; |
|
34 |
- |
|
35 | 18 |
Uint8 audio_get_vu(int instance); |
36 | 19 |
Uint16 audio_get_position(int instance); |
37 | 20 |
int audio_render(int instance, Sint16 *sample, Sint16 *end); |
38 |
-void audio_start(int instance, Device *d); |
|
21 |
+void audio_start(int instance, Uint8 *d, Uxn *u); |
|
39 | 22 |
void audio_finished_handler(int instance); |
... | ... |
@@ -2,7 +2,7 @@ |
2 | 2 |
#include "controller.h" |
3 | 3 |
|
4 | 4 |
/* |
5 |
-Copyright (c) 2021 Devine Lu Linvega, Andrew Alderwick |
|
5 |
+Copyright (c) 2021-2023 Devine Lu Linvega, Andrew Alderwick |
|
6 | 6 |
|
7 | 7 |
Permission to use, copy, modify, and distribute this software for any |
8 | 8 |
purpose with or without fee is hereby granted, provided that the above |
... | ... |
@@ -4,7 +4,7 @@ |
4 | 4 |
#include "datetime.h" |
5 | 5 |
|
6 | 6 |
/* |
7 |
-Copyright (c) 2021 Devine Lu Linvega, Andrew Alderwick |
|
7 |
+Copyright (c) 2021-2023 Devine Lu Linvega, Andrew Alderwick |
|
8 | 8 |
|
9 | 9 |
Permission to use, copy, modify, and distribute this software for any |
10 | 10 |
purpose with or without fee is hereby granted, provided that the above |
... | ... |
@@ -16,7 +16,7 @@ |
16 | 16 |
#include "file.h" |
17 | 17 |
|
18 | 18 |
/* |
19 |
-Copyright (c) 2021 Devine Lu Linvega, Andrew Alderwick |
|
19 |
+Copyright (c) 2021-2023 Devine Lu Linvega, Andrew Alderwick |
|
20 | 20 |
|
21 | 21 |
Permission to use, copy, modify, and distribute this software for any |
22 | 22 |
purpose with or without fee is hereby granted, provided that the above |
... | ... |
@@ -132,7 +132,9 @@ retry_realpath(const char *file_name) |
132 | 132 |
else |
133 | 133 |
return NULL; |
134 | 134 |
} |
135 |
- return strdup(r); |
|
135 |
+ x = malloc(strlen(r) + 1); |
|
136 |
+ strcpy(x, r); |
|
137 |
+ return x; |
|
136 | 138 |
} |
137 | 139 |
|
138 | 140 |
static void |
... | ... |
@@ -2,7 +2,7 @@ |
2 | 2 |
#include "mouse.h" |
3 | 3 |
|
4 | 4 |
/* |
5 |
-Copyright (c) 2021 Devine Lu Linvega, Andrew Alderwick |
|
5 |
+Copyright (c) 2021-2023 Devine Lu Linvega, Andrew Alderwick |
|
6 | 6 |
|
7 | 7 |
Permission to use, copy, modify, and distribute this software for any |
8 | 8 |
purpose with or without fee is hereby granted, provided that the above |
... | ... |
@@ -4,8 +4,7 @@ |
4 | 4 |
#include "screen.h" |
5 | 5 |
|
6 | 6 |
/* |
7 |
-Copyright (c) 2021 Devine Lu Linvega |
|
8 |
-Copyright (c) 2021 Andrew Alderwick |
|
7 |
+Copyright (c) 2021-2023 Devine Lu Linvega, Andrew Alderwick |
|
9 | 8 |
|
10 | 9 |
Permission to use, copy, modify, and distribute this software for any |
11 | 10 |
purpose with or without fee is hereby granted, provided that the above |
... | ... |
@@ -4,7 +4,7 @@ |
4 | 4 |
#include "system.h" |
5 | 5 |
|
6 | 6 |
/* |
7 |
-Copyright (c) 2022 Devine Lu Linvega, Andrew Alderwick |
|
7 |
+Copyright (c) 2022-2023 Devine Lu Linvega, Andrew Alderwick |
|
8 | 8 |
|
9 | 9 |
Permission to use, copy, modify, and distribute this software for any |
10 | 10 |
purpose with or without fee is hereby granted, provided that the above |
... | ... |
@@ -1,7 +1,7 @@ |
1 | 1 |
#include "uxn.h" |
2 | 2 |
|
3 | 3 |
/* |
4 |
-Copyright (u) 2022 Devine Lu Linvega, Andrew Alderwick, Andrew Richards |
|
4 |
+Copyright (u) 2022-2023 Devine Lu Linvega, Andrew Alderwick, Andrew Richards |
|
5 | 5 |
|
6 | 6 |
Permission to use, copy, modify, and distribute this software for any |
7 | 7 |
purpose with or without fee is hereby granted, provided that the above |
... | ... |
@@ -1,7 +1,7 @@ |
1 | 1 |
#include <stdio.h> |
2 | 2 |
|
3 | 3 |
/* |
4 |
-Copyright (c) 2021 Devine Lu Linvega |
|
4 |
+Copyright (c) 2021-2023 Devine Lu Linvega, Andrew Alderwick |
|
5 | 5 |
|
6 | 6 |
Permission to use, copy, modify, and distribute this software for any |
7 | 7 |
purpose with or without fee is hereby granted, provided that the above |
... | ... |
@@ -7,7 +7,7 @@ |
7 | 7 |
#include "devices/datetime.h" |
8 | 8 |
|
9 | 9 |
/* |
10 |
-Copyright (c) 2021 Devine Lu Linvega |
|
10 |
+Copyright (c) 2021-2023 Devine Lu Linvega, Andrew Alderwick |
|
11 | 11 |
|
12 | 12 |
Permission to use, copy, modify, and distribute this software for any |
13 | 13 |
purpose with or without fee is hereby granted, provided that the above |
... | ... |
@@ -23,7 +23,7 @@ |
23 | 23 |
#pragma clang diagnostic pop |
24 | 24 |
|
25 | 25 |
/* |
26 |
-Copyright (c) 2021 Devine Lu Linvega |
|
26 |
+Copyright (c) 2021-2023 Devine Lu Linvega, Andrew Alderwick |
|
27 | 27 |
|
28 | 28 |
Permission to use, copy, modify, and distribute this software for any |
29 | 29 |
purpose with or without fee is hereby granted, provided that the above |
... | ... |
@@ -48,7 +48,6 @@ static SDL_Thread *stdin_thread; |
48 | 48 |
|
49 | 49 |
/* devices */ |
50 | 50 |
|
51 |
-static Device *devaudio0; |
|
52 | 51 |
static Uint8 zoom = 1; |
53 | 52 |
static Uint32 stdin_event, audio0_event; |
54 | 53 |
static Uint64 exec_deadline, deadline_interval, ms_interval; |
... | ... |
@@ -82,12 +81,39 @@ console_deo(Uint8 *d, Uint8 port) |
82 | 81 |
} |
83 | 82 |
} |
84 | 83 |
|
84 |
+static Uint8 |
|
85 |
+audio_dei(int instance, Uint8 *d, Uint8 port) |
|
86 |
+{ |
|
87 |
+ if(!audio_id) return d[port]; |
|
88 |
+ switch(port) { |
|
89 |
+ case 0x4: return audio_get_vu(instance); |
|
90 |
+ case 0x2: POKDEV(0x2, audio_get_position(instance)); /* fall through */ |
|
91 |
+ default: return d[port]; |
|
92 |
+ } |
|
93 |
+} |
|
94 |
+ |
|
95 |
+static void |
|
96 |
+audio_deo(int instance, Uint8 *d, Uint8 port, Uxn *u) |
|
97 |
+{ |
|
98 |
+ if(!audio_id) return; |
|
99 |
+ if(port == 0xf) { |
|
100 |
+ SDL_LockAudioDevice(audio_id); |
|
101 |
+ audio_start(instance, d, u); |
|
102 |
+ SDL_UnlockAudioDevice(audio_id); |
|
103 |
+ SDL_PauseAudioDevice(audio_id, 0); |
|
104 |
+ } |
|
105 |
+} |
|
106 |
+ |
|
85 | 107 |
static Uint8 |
86 | 108 |
emu_dei(Uxn *u, Uint8 addr) |
87 | 109 |
{ |
88 | 110 |
Uint8 p = addr & 0x0f, d = addr & 0xf0; |
89 | 111 |
switch(d) { |
90 | 112 |
case 0x20: return screen_dei(&u->dev[d], p); |
113 |
+ case 0x30: return audio_dei(0, &u->dev[d], p); |
|
114 |
+ case 0x40: return audio_dei(1, &u->dev[d], p); |
|
115 |
+ case 0x50: return audio_dei(2, &u->dev[d], p); |
|
116 |
+ case 0x60: return audio_dei(3, &u->dev[d], p); |
|
91 | 117 |
case 0xa0: return file_dei(0, &u->dev[d], p); |
92 | 118 |
case 0xb0: return file_dei(1, &u->dev[d], p); |
93 | 119 |
case 0xc0: return datetime_dei(&u->dev[d], p); |
... | ... |
@@ -109,6 +135,10 @@ emu_deo(Uxn *u, Uint8 addr, Uint8 v) |
109 | 135 |
break; |
110 | 136 |
case 0x10: console_deo(&u->dev[d], p); break; |
111 | 137 |
case 0x20: screen_deo(u->ram, &u->dev[d], p); break; |
138 |
+ case 0x30: audio_deo(0, &u->dev[d], p, u); break; |
|
139 |
+ case 0x40: audio_deo(1, &u->dev[d], p, u); break; |
|
140 |
+ case 0x50: audio_deo(2, &u->dev[d], p, u); break; |
|
141 |
+ case 0x60: audio_deo(3, &u->dev[d], p, u); break; |
|
112 | 142 |
case 0xa0: file_deo(0, u->ram, &u->dev[d], p); break; |
113 | 143 |
case 0xb0: file_deo(1, u->ram, &u->dev[d], p); break; |
114 | 144 |
} |
... | ... |
@@ -227,31 +257,6 @@ init(void) |
227 | 257 |
|
228 | 258 |
#pragma mark - Devices |
229 | 259 |
|
230 |
-static Uint8 |
|
231 |
-audio_dei(Device *d, Uint8 port) |
|
232 |
-{ |
|
233 |
- int instance = d - devaudio0; |
|
234 |
- if(!audio_id) return d->dat[port]; |
|
235 |
- switch(port) { |
|
236 |
- case 0x4: return audio_get_vu(instance); |
|
237 |
- case 0x2: DEVPOKE16(0x2, audio_get_position(instance)); /* fall through */ |
|
238 |
- default: return d->dat[port]; |
|
239 |
- } |
|
240 |
-} |
|
241 |
- |
|
242 |
-static void |
|
243 |
-audio_deo(Device *d, Uint8 port) |
|
244 |
-{ |
|
245 |
- int instance = d - devaudio0; |
|
246 |
- if(!audio_id) return; |
|
247 |
- if(port == 0xf) { |
|
248 |
- SDL_LockAudioDevice(audio_id); |
|
249 |
- audio_start(instance, d); |
|
250 |
- SDL_UnlockAudioDevice(audio_id); |
|
251 |
- SDL_PauseAudioDevice(audio_id, 0); |
|
252 |
- } |
|
253 |
-} |
|
254 |
- |
|
255 | 260 |
/* Boot */ |
256 | 261 |
|
257 | 262 |
static int |
... | ... |
@@ -379,8 +384,7 @@ handle_events(Uxn *u) |
379 | 384 |
} |
380 | 385 |
/* Audio */ |
381 | 386 |
else if(event.type >= audio0_event && event.type < audio0_event + POLYPHONY) { |
382 |
- /* Device *d = devaudio0 + (event.type - audio0_event); |
|
383 |
- uxn_eval(u, GETVECTOR(d)); */ |
|
387 |
+ uxn_eval(u, GETVEC(&u->dev[0x30 + 0x10 * (event.type - audio0_event)])); |
|
384 | 388 |
} |
385 | 389 |
/* Mouse */ |
386 | 390 |
else if(event.type == SDL_MOUSEMOTION) |