2 Copyright © 1995-2001, 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>
36 struct ExecBase
*SysBase
;
40 /* A camd mididriver is not supposed to be run directly, so we return an error. */
48 extern void kprintf(char *bla
,...);
50 BOOL ASM
Init(REG(a6
) APTR sysbase
);
52 SAVEDS ASM
struct MidiPortData
*OpenPort(
53 REG(a3
) struct MidiDeviceData
*data
,
55 REG(a0
) ULONG (* ASM transmitfunc
)(APTR
REG(a2
) userdata
),
56 REG(a1
) void (* ASM recievefunc
)(UWORD
REG(d0
) input
,APTR
REG(a2
) userdata
),
60 REG(a3
) struct MidiDeviceData
*data
,
68 /***********************************************************************
69 The mididevicedata struct.
70 Note. It doesn't have to be declared with the const qualifier, since
71 NPorts may be set at Init. You should set the name-field to the
72 same as the filename, that might be a demand...
73 ***********************************************************************/
74 const struct MidiDeviceData mididevicedata
={
77 "Debugdriver V41.0 (c) 2001 AROS - The AROS Research OS",
88 /****************************************************************
89 We only store sysbase, thats all we need in this example.
90 Otherwise, you may want to open libraries, set number of
91 ports, obtain interrupts, etc.
92 ***************************************************************/
93 SAVEDS ASM BOOL
Init(REG(a6
) APTR sysbase
){
98 /****************************************************************
99 Nothing to do here. Normally, you may want to free memory,
100 close some libraries, free some interrupts, etc.
101 *****************************************************************/
108 ULONG (ASM
*TransmitFunc
)(REG(a2
) APTR userdata
);
109 APTR UserData
[NUMPORTS
];
113 /****************************************************************
114 Normally, you may want to start an interrupt, or signal another task,
115 or send a message to a port, that calls the transmit-function.
116 But for this small example, sending the signal directly via
117 kprintf is excactly what we want to do.
118 ****************************************************************/
119 SAVEDS ASM
void ActivateXmit(REG(a2
) APTR userdata
,ULONG
REG(d0
) portnum
){
123 data
=(TransmitFunc
)(userdata
);
125 if(data
==0x100) return;
126 kprintf("Debugdriver has received: %lx at port %ld\n",data
,portnum
);
130 struct MidiPortData midiportdata
={
135 /****************************************************************
136 This one is called whenever a program that has opened
137 camd.library wants to use your services.
138 ****************************************************************/
139 SAVEDS ASM
struct MidiPortData
*OpenPort(
140 REG(a3
) struct MidiDeviceData
*data
,
141 REG(d0
) LONG portnum
,
142 REG(a0
) ULONG (* ASM transmitfunc
)(APTR
REG(a2
) userdata
),
143 REG(a1
) void (* ASM recieverfunc
)(UWORD
REG(d0
) input
,APTR
REG(a2
) userdata
),
144 REG(a2
) APTR userdata
146 /* We haven't got any receiver function, so we don't bother about storing the receiverfunc variable. */
148 TransmitFunc
=transmitfunc
;
149 UserData
[portnum
-1]=userdata
;
150 return &midiportdata
;
155 /****************************************************************
156 Nothing to do here. Normally, you may want to free memory,
157 mark the port not to be in use anymore, delete a task, etc.
158 *****************************************************************/
160 REG(a3
) struct MidiDeviceData
*data
,