commit 4e8375d8dfa5a90fe03f956ce863204b41c7fb18
parent 5936137166a9fb74c4c391ff9d87b5dd5539fa72
Author: neauoire <aliceffekt@gmail.com>
Date: Sat, 26 Jun 2021 13:17:41 -0700
Removed the Midi device
Diffstat:
7 files changed, 4 insertions(+), 157 deletions(-)
diff --git a/README.md b/README.md
@@ -6,7 +6,7 @@ An assembler and emulator for the [Uxn stack-machine](https://wiki.xxiivv.com/si
### Linux
-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.
+To build the Uxn emulator, you must have [SDL2](https://wiki.libsdl.org/).
```sh
./build.sh
diff --git a/build.sh b/build.sh
@@ -17,8 +17,6 @@ then
clang-format -i src/devices/ppu.c
clang-format -i src/devices/apu.h
clang-format -i src/devices/apu.c
- clang-format -i src/devices/mpu.h
- clang-format -i src/devices/mpu.c
clang-format -i src/uxnasm.c
clang-format -i src/uxnemu.c
clang-format -i src/uxncli.c
@@ -28,15 +26,6 @@ mkdir -p bin
CFLAGS="-std=c89 -Wall -Wno-unknown-pragmas"
UXNEMU_LDFLAGS="-L/usr/local/lib $(sdl2-config --cflags --libs)"
-if cc ${CFLAGS} -c src/devices/mpu.c -o bin/mpu.o 2>/dev/null; then
- rm -f bin/mpu.o
- echo "Building with portmidi.."
- UXNEMU_LDFLAGS="${UXNEMU_LDFLAGS} -lportmidi"
-else
- echo "Building without portmidi.."
- CFLAGS="${CFLAGS} -DNO_PORTMIDI"
-fi
-
if [ "${1}" = '--debug' ];
then
echo "[debug]"
@@ -48,7 +37,7 @@ else
fi
cc ${CFLAGS} src/uxnasm.c -o bin/uxnasm
-cc ${CFLAGS} ${CORE} src/devices/ppu.c src/devices/apu.c src/devices/mpu.c src/uxnemu.c ${UXNEMU_LDFLAGS} -o bin/uxnemu
+cc ${CFLAGS} ${CORE} src/devices/ppu.c src/devices/apu.c src/uxnemu.c ${UXNEMU_LDFLAGS} -o bin/uxnemu
cc ${CFLAGS} ${CORE} src/uxncli.c -o bin/uxncli
if [ -d "$HOME/bin" ] && [ -e ./bin/uxnemu ] && [ -e ./bin/uxnasm ]
diff --git a/projects/examples/demos/drum-rack.tal b/projects/examples/demos/drum-rack.tal
@@ -68,7 +68,6 @@
;on-control .Controller/vector DEO2
;on-mouse .Mouse/vector DEO2
;on-frame .Screen/vector DEO2
- ;on-midi .Midi/vector DEO2
( channel defaults )
#dd .Audio0/volume DEO
@@ -189,23 +188,6 @@ BRK
BRK
-@on-midi ( -> )
-
- .Midi/note DEI #00 ! #01 JCN [ BRK ]
-
- ( drums )
- .Midi/channel DEI #90 ! ,&no-drum JCN
- .Midi/note DEI #10 MOD ;play-pad JSR2
- BRK
- &no-drum
-
- ( TODO: synths )
- ;pad-addr #0008 ++ LDA2 .Audio0/addr DEO2
- #0008 .Audio0/length DEO2
- .Midi/note DEI .Audio0/pitch DEO
-
-BRK
-
@on-control ( -> )
.Controller/key DEI #00 ! #01 JCN [ BRK ]
diff --git a/projects/examples/demos/piano.tal b/projects/examples/demos/piano.tal
@@ -53,7 +53,6 @@
;on-frame .Screen/vector DEO2
;on-control .Controller/vector DEO2
;on-mouse .Mouse/vector DEO2
- ;on-midi .Midi/vector DEO2
( find center )
.Screen/width DEI2 2// .center/x STZ2
@@ -153,13 +152,6 @@ BRK
BRK
-@on-midi ( -> )
-
- .Midi/note DEI #00 ! #01 JCN [ BRK ]
- .Midi/note DEI .Audio0/pitch .Midi/channel DEI #04 MOD #10 * + DEO
-
-BRK
-
@on-mouse ( -> )
;draw-cursor JSR2
diff --git a/src/devices/mpu.c b/src/devices/mpu.c
@@ -1,54 +0,0 @@
-#include "mpu.h"
-
-/*
-Copyright (c) 2021 Devine Lu Linvega
-Copyright (c) 2021 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
-copyright notice and this permission notice appear in all copies.
-
-THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-WITH REGARD TO THIS SOFTWARE.
-*/
-
-int
-initmpu(Mpu *m, Uint8 dev_in, Uint8 dev_out)
-{
-#ifndef NO_PORTMIDI
- int i;
- Pm_Initialize();
- for(i = 0; i < Pm_CountDevices(); ++i)
- printf("Device #%d -> %s%s\n", i, Pm_GetDeviceInfo(i)->name, i == dev_in ? "[x]" : "[ ]");
- Pm_OpenInput(&m->input, dev_in, NULL, 128, 0, NULL);
- Pm_OpenOutput(&m->output, dev_out, NULL, 128, 0, NULL, 1);
- m->queue = 0;
- m->error = pmNoError;
-#endif
- (void)m;
- (void)dev_in;
- return 1;
-}
-
-void
-getmidi(Mpu *m)
-{
-#ifndef NO_PORTMIDI
- const int result = Pm_Read(m->input, m->events, 32);
- if(result < 0) {
- m->error = (PmError)result;
- m->queue = 0;
- return;
- }
- m->queue = result;
-#endif
- (void)m;
-}
-
-void
-putmidi(Mpu *m, Uint8 chan, Uint8 note, Uint8 velo)
-{
-#ifndef NO_PORTMIDI
- Pm_WriteShort(m->output, Pt_Time(), Pm_Message(0x90 + chan, note, velo));
-#endif
-}
-\ No newline at end of file
diff --git a/src/devices/mpu.h b/src/devices/mpu.h
@@ -1,38 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-
-/*
-Copyright (c) 2021 Devine Lu Linvega
-Copyright (c) 2021 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
-copyright notice and this permission notice appear in all copies.
-
-THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-WITH REGARD TO THIS SOFTWARE.
-*/
-
-#ifndef NO_PORTMIDI
-#include <portmidi.h>
-#include <porttime.h>
-#else
-typedef struct {
- int message;
-} PmEvent;
-#endif
-
-typedef unsigned char Uint8;
-
-typedef struct {
- Uint8 queue;
- PmEvent events[32];
-#ifndef NO_PORTMIDI
- PmStream *input, *output;
- PmError error;
-#endif
-} Mpu;
-
-int initmpu(Mpu *m, Uint8 dev_in, Uint8 dev_out);
-void getmidi(Mpu *m);
-void putmidi(Mpu *m, Uint8 chan, Uint8 note, Uint8 velo);
-\ No newline at end of file
diff --git a/src/uxnemu.c b/src/uxnemu.c
@@ -4,7 +4,6 @@
#include "uxn.h"
#include "devices/ppu.h"
#include "devices/apu.h"
-#include "devices/mpu.h"
/*
Copyright (c) 2021 Devine Lu Linvega
@@ -24,8 +23,7 @@ static SDL_Texture *fgTexture, *bgTexture;
static SDL_Rect gRect;
static Ppu ppu;
static Apu apu[POLYPHONY];
-static Mpu mpu;
-static Device *devscreen, *devmouse, *devctrl, *devmidi, *devaudio0;
+static Device *devscreen, *devmouse, *devctrl, *devaudio0;
#define PAD 16
@@ -126,8 +124,6 @@ init(void)
gRect.y = PAD;
gRect.w = ppu.width;
gRect.h = ppu.height;
- if(!initmpu(&mpu, 1, 0))
- return error("MPU", "Init failure");
if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0)
return error("Init", SDL_GetError());
gWindow = SDL_CreateWindow("Uxn", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, (ppu.width + PAD * 2) * zoom, (ppu.height + PAD * 2) * zoom, SDL_WINDOW_SHOWN);
@@ -324,16 +320,6 @@ datetime_talk(Device *d, Uint8 b0, Uint8 w)
}
void
-midi_talk(Device *d, Uint8 b0, Uint8 w)
-{
- if(w && b0 == 0x9) {
- putmidi(&mpu, d->dat[0x8], d->dat[0x9], 127);
- putmidi(&mpu, d->dat[0x8], d->dat[0x9], 0);
- }
- (void)d;
-}
-
-void
nil_talk(Device *d, Uint8 b0, Uint8 w)
{
(void)d;
@@ -349,7 +335,6 @@ start(Uxn *u)
evaluxn(u, 0x0100);
redraw(u);
while(1) {
- int i;
SDL_Event event;
double elapsed, start = 0;
if(!bench)
@@ -384,13 +369,6 @@ start(Uxn *u)
break;
}
}
- getmidi(&mpu);
- for(i = 0; i < mpu.queue; ++i) {
- devmidi->dat[2] = mpu.events[i].message;
- devmidi->dat[3] = mpu.events[i].message >> 8;
- devmidi->dat[4] = mpu.events[i].message >> 16;
- evaluxn(u, mempeek16(devmidi->dat, 0));
- }
evaluxn(u, mempeek16(devscreen->dat, 0));
if(reqdraw)
redraw(u);
@@ -424,7 +402,7 @@ main(int argc, char **argv)
portuxn(&u, 0x4, "audio1", audio_talk);
portuxn(&u, 0x5, "audio2", audio_talk);
portuxn(&u, 0x6, "audio3", audio_talk);
- devmidi = portuxn(&u, 0x7, "midi", midi_talk);
+ portuxn(&u, 0x7, "---", nil_talk);
devctrl = portuxn(&u, 0x8, "controller", nil_talk);
devmouse = portuxn(&u, 0x9, "mouse", nil_talk);
portuxn(&u, 0xa, "file", file_talk);