... | ... |
@@ -6,7 +6,7 @@ An assembler and emulator for the [Uxn stack-machine](https://wiki.xxiivv.com/si |
6 | 6 |
|
7 | 7 |
### Linux |
8 | 8 |
|
9 |
-To build the Uxn emulator, you must have [SDL2](https://wiki.libsdl.org/). If you wish to use the `Midi` device, you must also have [Portmidi](http://portmedia.sourceforge.net/portmidi/) installed. The build script indicates whether it has detected Portmidi or not, but will build Uxn either way. |
|
9 |
+To build the Uxn emulator, you must have [SDL2](https://wiki.libsdl.org/). |
|
10 | 10 |
|
11 | 11 |
```sh |
12 | 12 |
./build.sh |
... | ... |
@@ -17,8 +17,6 @@ then |
17 | 17 |
clang-format -i src/devices/ppu.c |
18 | 18 |
clang-format -i src/devices/apu.h |
19 | 19 |
clang-format -i src/devices/apu.c |
20 |
- clang-format -i src/devices/mpu.h |
|
21 |
- clang-format -i src/devices/mpu.c |
|
22 | 20 |
clang-format -i src/uxnasm.c |
23 | 21 |
clang-format -i src/uxnemu.c |
24 | 22 |
clang-format -i src/uxncli.c |
... | ... |
@@ -28,15 +26,6 @@ mkdir -p bin |
28 | 26 |
CFLAGS="-std=c89 -Wall -Wno-unknown-pragmas" |
29 | 27 |
UXNEMU_LDFLAGS="-L/usr/local/lib $(sdl2-config --cflags --libs)" |
30 | 28 |
|
31 |
-if cc ${CFLAGS} -c src/devices/mpu.c -o bin/mpu.o 2>/dev/null; then |
|
32 |
- rm -f bin/mpu.o |
|
33 |
- echo "Building with portmidi.." |
|
34 |
- UXNEMU_LDFLAGS="${UXNEMU_LDFLAGS} -lportmidi" |
|
35 |
-else |
|
36 |
- echo "Building without portmidi.." |
|
37 |
- CFLAGS="${CFLAGS} -DNO_PORTMIDI" |
|
38 |
-fi |
|
39 |
- |
|
40 | 29 |
if [ "${1}" = '--debug' ]; |
41 | 30 |
then |
42 | 31 |
echo "[debug]" |
... | ... |
@@ -48,7 +37,7 @@ else |
48 | 37 |
fi |
49 | 38 |
|
50 | 39 |
cc ${CFLAGS} src/uxnasm.c -o bin/uxnasm |
51 |
-cc ${CFLAGS} ${CORE} src/devices/ppu.c src/devices/apu.c src/devices/mpu.c src/uxnemu.c ${UXNEMU_LDFLAGS} -o bin/uxnemu |
|
40 |
+cc ${CFLAGS} ${CORE} src/devices/ppu.c src/devices/apu.c src/uxnemu.c ${UXNEMU_LDFLAGS} -o bin/uxnemu |
|
52 | 41 |
cc ${CFLAGS} ${CORE} src/uxncli.c -o bin/uxncli |
53 | 42 |
|
54 | 43 |
if [ -d "$HOME/bin" ] && [ -e ./bin/uxnemu ] && [ -e ./bin/uxnasm ] |
... | ... |
@@ -68,7 +68,6 @@ |
68 | 68 |
;on-control .Controller/vector DEO2 |
69 | 69 |
;on-mouse .Mouse/vector DEO2 |
70 | 70 |
;on-frame .Screen/vector DEO2 |
71 |
- ;on-midi .Midi/vector DEO2 |
|
72 | 71 |
|
73 | 72 |
( channel defaults ) |
74 | 73 |
#dd .Audio0/volume DEO |
... | ... |
@@ -189,23 +188,6 @@ BRK |
189 | 188 |
|
190 | 189 |
BRK |
191 | 190 |
|
192 |
-@on-midi ( -> ) |
|
193 |
- |
|
194 |
- .Midi/note DEI #00 ! #01 JCN [ BRK ] |
|
195 |
- |
|
196 |
- ( drums ) |
|
197 |
- .Midi/channel DEI #90 ! ,&no-drum JCN |
|
198 |
- .Midi/note DEI #10 MOD ;play-pad JSR2 |
|
199 |
- BRK |
|
200 |
- &no-drum |
|
201 |
- |
|
202 |
- ( TODO: synths ) |
|
203 |
- ;pad-addr #0008 ++ LDA2 .Audio0/addr DEO2 |
|
204 |
- #0008 .Audio0/length DEO2 |
|
205 |
- .Midi/note DEI .Audio0/pitch DEO |
|
206 |
- |
|
207 |
-BRK |
|
208 |
- |
|
209 | 191 |
@on-control ( -> ) |
210 | 192 |
|
211 | 193 |
.Controller/key DEI #00 ! #01 JCN [ BRK ] |
... | ... |
@@ -53,7 +53,6 @@ |
53 | 53 |
;on-frame .Screen/vector DEO2 |
54 | 54 |
;on-control .Controller/vector DEO2 |
55 | 55 |
;on-mouse .Mouse/vector DEO2 |
56 |
- ;on-midi .Midi/vector DEO2 |
|
57 | 56 |
|
58 | 57 |
( find center ) |
59 | 58 |
.Screen/width DEI2 2// .center/x STZ2 |
... | ... |
@@ -153,13 +152,6 @@ BRK |
153 | 152 |
|
154 | 153 |
BRK |
155 | 154 |
|
156 |
-@on-midi ( -> ) |
|
157 |
- |
|
158 |
- .Midi/note DEI #00 ! #01 JCN [ BRK ] |
|
159 |
- .Midi/note DEI .Audio0/pitch .Midi/channel DEI #04 MOD #10 * + DEO |
|
160 |
- |
|
161 |
-BRK |
|
162 |
- |
|
163 | 155 |
@on-mouse ( -> ) |
164 | 156 |
|
165 | 157 |
;draw-cursor JSR2 |
166 | 158 |
deleted file mode 100644 |
... | ... |
@@ -1,54 +0,0 @@ |
1 |
-#include "mpu.h" |
|
2 |
- |
|
3 |
-/* |
|
4 |
-Copyright (c) 2021 Devine Lu Linvega |
|
5 |
-Copyright (c) 2021 Andrew Alderwick |
|
6 |
- |
|
7 |
-Permission to use, copy, modify, and distribute this software for any |
|
8 |
-purpose with or without fee is hereby granted, provided that the above |
|
9 |
-copyright notice and this permission notice appear in all copies. |
|
10 |
- |
|
11 |
-THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
|
12 |
-WITH REGARD TO THIS SOFTWARE. |
|
13 |
-*/ |
|
14 |
- |
|
15 |
-int |
|
16 |
-initmpu(Mpu *m, Uint8 dev_in, Uint8 dev_out) |
|
17 |
-{ |
|
18 |
-#ifndef NO_PORTMIDI |
|
19 |
- int i; |
|
20 |
- Pm_Initialize(); |
|
21 |
- for(i = 0; i < Pm_CountDevices(); ++i) |
|
22 |
- printf("Device #%d -> %s%s\n", i, Pm_GetDeviceInfo(i)->name, i == dev_in ? "[x]" : "[ ]"); |
|
23 |
- Pm_OpenInput(&m->input, dev_in, NULL, 128, 0, NULL); |
|
24 |
- Pm_OpenOutput(&m->output, dev_out, NULL, 128, 0, NULL, 1); |
|
25 |
- m->queue = 0; |
|
26 |
- m->error = pmNoError; |
|
27 |
-#endif |
|
28 |
- (void)m; |
|
29 |
- (void)dev_in; |
|
30 |
- return 1; |
|
31 |
-} |
|
32 |
- |
|
33 |
-void |
|
34 |
-getmidi(Mpu *m) |
|
35 |
-{ |
|
36 |
-#ifndef NO_PORTMIDI |
|
37 |
- const int result = Pm_Read(m->input, m->events, 32); |
|
38 |
- if(result < 0) { |
|
39 |
- m->error = (PmError)result; |
|
40 |
- m->queue = 0; |
|
41 |
- return; |
|
42 |
- } |
|
43 |
- m->queue = result; |
|
44 |
-#endif |
|
45 |
- (void)m; |
|
46 |
-} |
|
47 |
- |
|
48 |
-void |
|
49 |
-putmidi(Mpu *m, Uint8 chan, Uint8 note, Uint8 velo) |
|
50 |
-{ |
|
51 |
-#ifndef NO_PORTMIDI |
|
52 |
- Pm_WriteShort(m->output, Pt_Time(), Pm_Message(0x90 + chan, note, velo)); |
|
53 |
-#endif |
|
54 |
-} |
|
55 | 0 |
\ No newline at end of file |
56 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,38 +0,0 @@ |
1 |
-#include <stdio.h> |
|
2 |
-#include <stdlib.h> |
|
3 |
- |
|
4 |
-/* |
|
5 |
-Copyright (c) 2021 Devine Lu Linvega |
|
6 |
-Copyright (c) 2021 Andrew Alderwick |
|
7 |
- |
|
8 |
-Permission to use, copy, modify, and distribute this software for any |
|
9 |
-purpose with or without fee is hereby granted, provided that the above |
|
10 |
-copyright notice and this permission notice appear in all copies. |
|
11 |
- |
|
12 |
-THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
|
13 |
-WITH REGARD TO THIS SOFTWARE. |
|
14 |
-*/ |
|
15 |
- |
|
16 |
-#ifndef NO_PORTMIDI |
|
17 |
-#include <portmidi.h> |
|
18 |
-#include <porttime.h> |
|
19 |
-#else |
|
20 |
-typedef struct { |
|
21 |
- int message; |
|
22 |
-} PmEvent; |
|
23 |
-#endif |
|
24 |
- |
|
25 |
-typedef unsigned char Uint8; |
|
26 |
- |
|
27 |
-typedef struct { |
|
28 |
- Uint8 queue; |
|
29 |
- PmEvent events[32]; |
|
30 |
-#ifndef NO_PORTMIDI |
|
31 |
- PmStream *input, *output; |
|
32 |
- PmError error; |
|
33 |
-#endif |
|
34 |
-} Mpu; |
|
35 |
- |
|
36 |
-int initmpu(Mpu *m, Uint8 dev_in, Uint8 dev_out); |
|
37 |
-void getmidi(Mpu *m); |
|
38 |
-void putmidi(Mpu *m, Uint8 chan, Uint8 note, Uint8 velo); |
|
39 | 0 |
\ No newline at end of file |
... | ... |
@@ -4,7 +4,6 @@ |
4 | 4 |
#include "uxn.h" |
5 | 5 |
#include "devices/ppu.h" |
6 | 6 |
#include "devices/apu.h" |
7 |
-#include "devices/mpu.h" |
|
8 | 7 |
|
9 | 8 |
/* |
10 | 9 |
Copyright (c) 2021 Devine Lu Linvega |
... | ... |
@@ -24,8 +23,7 @@ static SDL_Texture *fgTexture, *bgTexture; |
24 | 23 |
static SDL_Rect gRect; |
25 | 24 |
static Ppu ppu; |
26 | 25 |
static Apu apu[POLYPHONY]; |
27 |
-static Mpu mpu; |
|
28 |
-static Device *devscreen, *devmouse, *devctrl, *devmidi, *devaudio0; |
|
26 |
+static Device *devscreen, *devmouse, *devctrl, *devaudio0; |
|
29 | 27 |
|
30 | 28 |
#define PAD 16 |
31 | 29 |
|
... | ... |
@@ -126,8 +124,6 @@ init(void) |
126 | 124 |
gRect.y = PAD; |
127 | 125 |
gRect.w = ppu.width; |
128 | 126 |
gRect.h = ppu.height; |
129 |
- if(!initmpu(&mpu, 1, 0)) |
|
130 |
- return error("MPU", "Init failure"); |
|
131 | 127 |
if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0) |
132 | 128 |
return error("Init", SDL_GetError()); |
133 | 129 |
gWindow = SDL_CreateWindow("Uxn", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, (ppu.width + PAD * 2) * zoom, (ppu.height + PAD * 2) * zoom, SDL_WINDOW_SHOWN); |
... | ... |
@@ -323,16 +319,6 @@ datetime_talk(Device *d, Uint8 b0, Uint8 w) |
323 | 319 |
(void)w; |
324 | 320 |
} |
325 | 321 |
|
326 |
-void |
|
327 |
-midi_talk(Device *d, Uint8 b0, Uint8 w) |
|
328 |
-{ |
|
329 |
- if(w && b0 == 0x9) { |
|
330 |
- putmidi(&mpu, d->dat[0x8], d->dat[0x9], 127); |
|
331 |
- putmidi(&mpu, d->dat[0x8], d->dat[0x9], 0); |
|
332 |
- } |
|
333 |
- (void)d; |
|
334 |
-} |
|
335 |
- |
|
336 | 322 |
void |
337 | 323 |
nil_talk(Device *d, Uint8 b0, Uint8 w) |
338 | 324 |
{ |
... | ... |
@@ -349,7 +335,6 @@ start(Uxn *u) |
349 | 335 |
evaluxn(u, 0x0100); |
350 | 336 |
redraw(u); |
351 | 337 |
while(1) { |
352 |
- int i; |
|
353 | 338 |
SDL_Event event; |
354 | 339 |
double elapsed, start = 0; |
355 | 340 |
if(!bench) |
... | ... |
@@ -384,13 +369,6 @@ start(Uxn *u) |
384 | 369 |
break; |
385 | 370 |
} |
386 | 371 |
} |
387 |
- getmidi(&mpu); |
|
388 |
- for(i = 0; i < mpu.queue; ++i) { |
|
389 |
- devmidi->dat[2] = mpu.events[i].message; |
|
390 |
- devmidi->dat[3] = mpu.events[i].message >> 8; |
|
391 |
- devmidi->dat[4] = mpu.events[i].message >> 16; |
|
392 |
- evaluxn(u, mempeek16(devmidi->dat, 0)); |
|
393 |
- } |
|
394 | 372 |
evaluxn(u, mempeek16(devscreen->dat, 0)); |
395 | 373 |
if(reqdraw) |
396 | 374 |
redraw(u); |
... | ... |
@@ -424,7 +402,7 @@ main(int argc, char **argv) |
424 | 402 |
portuxn(&u, 0x4, "audio1", audio_talk); |
425 | 403 |
portuxn(&u, 0x5, "audio2", audio_talk); |
426 | 404 |
portuxn(&u, 0x6, "audio3", audio_talk); |
427 |
- devmidi = portuxn(&u, 0x7, "midi", midi_talk); |
|
405 |
+ portuxn(&u, 0x7, "---", nil_talk); |
|
428 | 406 |
devctrl = portuxn(&u, 0x8, "controller", nil_talk); |
429 | 407 |
devmouse = portuxn(&u, 0x9, "mouse", nil_talk); |
430 | 408 |
portuxn(&u, 0xa, "file", file_talk); |