Brought back portmidi with conditional compilation
This commit is contained in:
parent
adf32aa9f4
commit
8783bf12b2
|
@ -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/).
|
||||
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.
|
||||
|
||||
```sh
|
||||
./build.sh
|
||||
|
|
9
build.sh
9
build.sh
|
@ -19,10 +19,17 @@ rm -f ./bin/uxnemu
|
|||
rm -f ./bin/uxncli
|
||||
rm -f ./bin/boot.rom
|
||||
|
||||
echo "Building.."
|
||||
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]"
|
||||
|
|
|
@ -15,7 +15,7 @@ WITH REGARD TO THIS SOFTWARE.
|
|||
int
|
||||
initmpu(Mpu *m, Uint8 device)
|
||||
{
|
||||
/*
|
||||
#ifndef NO_PORTMIDI
|
||||
int i;
|
||||
Pm_Initialize();
|
||||
for(i = 0; i < Pm_CountDevices(); ++i)
|
||||
|
@ -26,7 +26,7 @@ initmpu(Mpu *m, Uint8 device)
|
|||
Pm_OpenInput(&m->midi, device, NULL, 128, 0, NULL);
|
||||
m->queue = 0;
|
||||
m->error = pmNoError;
|
||||
*/
|
||||
#endif
|
||||
(void)m;
|
||||
(void)device;
|
||||
return 1;
|
||||
|
@ -35,7 +35,7 @@ initmpu(Mpu *m, Uint8 device)
|
|||
void
|
||||
listenmpu(Mpu *m)
|
||||
{
|
||||
/*
|
||||
#ifndef NO_PORTMIDI
|
||||
const int result = Pm_Read(m->midi, m->events, 32);
|
||||
if(result < 0) {
|
||||
m->error = (PmError)result;
|
||||
|
@ -43,6 +43,6 @@ listenmpu(Mpu *m)
|
|||
return;
|
||||
}
|
||||
m->queue = result;
|
||||
*/
|
||||
#endif
|
||||
(void)m;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
/* #include <portmidi.h> */
|
||||
|
||||
/*
|
||||
Copyright (c) 2021 Devine Lu Linvega
|
||||
|
@ -14,19 +13,23 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|||
WITH REGARD TO THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
typedef unsigned char Uint8;
|
||||
|
||||
#ifndef NO_PORTMIDI
|
||||
#include <portmidi.h>
|
||||
#else
|
||||
typedef struct {
|
||||
int message;
|
||||
} PmEvent;
|
||||
#endif
|
||||
|
||||
typedef unsigned char Uint8;
|
||||
|
||||
typedef struct {
|
||||
Uint8 queue;
|
||||
PmEvent events[32];
|
||||
/*
|
||||
#ifndef NO_PORTMIDI
|
||||
PmStream *midi;
|
||||
PmError error;
|
||||
*/
|
||||
#endif
|
||||
} Mpu;
|
||||
|
||||
int initmpu(Mpu *m, Uint8 device);
|
||||
|
|
Loading…
Reference in New Issue