2 Copyright © 1995-2017, The AROS Development Team. All rights reserved.
11 /*********************************************************************************
12 Not a very good example at all. But at least it should prove that
13 AROS is able to use camd-drivers. -Kjetil M.
15 Compiling it up is easy. Its just like any other AROS-program, showed
19 debugdriver: debugdriver.o
20 gcc -nostartfiles -nostdlib -Xlinker -i ../../lib/startup.o debugdriver.o -o debugdriver -L../../lib -larossupport -lamiga -larosc -larosm
22 debugdriver.o: debugdriver.c makefile
23 gcc debugdriver.c -c -I../../Include -Wall
26 ***********************************************************************************/
29 #include <proto/exec.h>
30 #include <exec/types.h>
31 #include <midi/camddevices.h>
32 #include <libcore/compiler.h>
38 struct ExecBase
*SysBase
;
42 /* A camd mididriver is not supposed to be run directly, so we return an error. */
50 extern void kprintf(char *bla
,...);
52 BOOL ASM
Init(REG(a6
) APTR sysbase
);
54 SAVEDS ASM
struct MidiPortData
*OpenPort(
55 REG(a3
) struct MidiDeviceData
*data
,
57 REG(a0
) ULONG (* ASM transmitfunc
)(APTR
REG(a2
) userdata
),
58 REG(a1
) void (* ASM receivefunc
)(UWORD
REG(d0
) input
,APTR
REG(a2
) userdata
),
62 REG(a3
) struct MidiDeviceData
*data
,
70 /***********************************************************************
71 The mididevicedata struct.
72 Note. It doesn't have to be declared with the const qualifier, since
73 NPorts may be set at Init. You should set the name-field to the
74 same as the filename, that might be a demand...
75 ***********************************************************************/
76 const struct MidiDeviceData mididevicedata
={
79 "Debugdriver V41.0 (c) 2001 AROS - The AROS Research OS",
90 /****************************************************************
91 We only store sysbase, thats all we need in this example.
92 Otherwise, you may want to open libraries, set number of
93 ports, obtain interrupts, etc.
94 ***************************************************************/
95 SAVEDS ASM BOOL
Init(REG(a6
) APTR sysbase
){
100 /****************************************************************
101 Nothing to do here. Normally, you may want to free memory,
102 close some libraries, free some interrupts, etc.
103 *****************************************************************/
110 ULONG (ASM
*TransmitFunc
)(REG(a2
) APTR userdata
);
111 APTR UserData
[NUMPORTS
];
115 /****************************************************************
116 Normally, you may want to start an interrupt, or signal another task,
117 or send a message to a port, that calls the transmit-function.
118 But for this small example, sending the signal directly via
119 kprintf is excactly what we want to do.
120 ****************************************************************/
121 SAVEDS ASM
void ActivateXmit(REG(a2
) APTR userdata
,ULONG
REG(d0
) portnum
){
125 data
=(TransmitFunc
)(userdata
);
127 if(data
==0x100) return;
128 D(kprintf("Debugdriver has received: %lx at port %ld\n",data
,portnum
);)
132 struct MidiPortData midiportdata
={
137 /****************************************************************
138 This one is called whenever a program that has opened
139 camd.library wants to use your services.
140 ****************************************************************/
141 SAVEDS ASM
struct MidiPortData
*OpenPort(
142 REG(a3
) struct MidiDeviceData
*data
,
143 REG(d0
) LONG portnum
,
144 REG(a0
) ULONG (* ASM transmitfunc
)(APTR
REG(a2
) userdata
),
145 REG(a1
) void (* ASM receiverfunc
)(UWORD
REG(d0
) input
,APTR
REG(a2
) userdata
),
146 REG(a2
) APTR userdata
148 /* We haven't got any receiver function, so we don't bother about storing the receiverfunc variable. */
150 TransmitFunc
=transmitfunc
;
151 UserData
[portnum
-1]=userdata
;
152 return &midiportdata
;
157 /****************************************************************
158 Nothing to do here. Normally, you may want to free memory,
159 mark the port not to be in use anymore, delete a task, etc.
160 *****************************************************************/
162 REG(a3
) struct MidiDeviceData
*data
,