added concrete implementations of putc(), getc(), getchar() and gets()
[tangerine.git] / workbench / libs / camd / getsysex.c
blob48899c5132e0ceddc8d2ee0b253bf2edb81c9d6b
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: English
7 */
10 #include <proto/exec.h>
12 #include "camd_intern.h"
15 /*****************************************************************************
17 NAME */
19 AROS_LH3(ULONG, GetSysEx,
21 /* SYNOPSIS */
22 AROS_LHA(struct MidiNode *, midinode, A0),
23 AROS_LHA(UBYTE *, Buf, A1),
24 AROS_LHA(ULONG, len, D0),
26 /* LOCATION */
27 struct CamdBase *, CamdBase, 27, Camd)
29 /* FUNCTION
30 Remind me to fill in things here later.
32 INPUTS
34 RESULT
36 NOTES
38 EXAMPLE
40 BUGS
41 Not tested. SysEx receiving does probably have some bugs.
43 SEE ALSO
44 SkipSysEx, QuierySysEx
46 INTERNALS
48 HISTORY
50 2001-01-12 ksvalast first created
52 *****************************************************************************/
54 AROS_LIBFUNC_INIT
56 struct MyMidiNode *mymidinode=(struct MyMidiNode *)midinode;
57 ULONG numread=0;
58 UBYTE data;
60 if(mymidinode->sysex_nextis0==TRUE) return 0;
62 ObtainSemaphore(&mymidinode->sysexsemaphore2);
64 mymidinode->sysex_nextis0=FALSE;
66 while(numread<len){
67 data=*mymidinode->sysex_read;
68 mymidinode->sysex_read++;
69 if(mymidinode->sysex_read==mymidinode->sysex_end){
70 mymidinode->sysex_read=mymidinode->sysex_start;
72 Buf[numread]=data;
73 numread++;
75 if(data==0xf7){
76 mymidinode->sysex_nextis0=TRUE;
77 break;
81 ReleaseSemaphore(&mymidinode->sysexsemaphore2);
84 return numread;
87 AROS_LIBFUNC_EXIT