[comp.sys.mac.programmer] Using MIDI Manager from ThinkSpeed C. How? Help!

nick@lfcs.ed.ac.uk (Nick Rothwell) (09/07/89)

I've just spent an evening trying to get a simple MIDI Manager
application (MIDISignIn, MIDISignOut) going in LightThink C. No luck.
I tried cross-calling some assembly bolted onto the MIDI.a macro file.
I tried in-line assembler in THINK C. I even tried jumping to an array
of integers containing the instructions and the trap. This was the
most successful; I at least got *out* of MIDISignIn, even though I
couldn't go anywhere afterwards. So, what's wrong with something like
this:

	pascal OSErr MIDISignIn(clientID, refCon, icon, name)
	OSType clientID;
	long refCon;
	Handle icon;
	StringPtr name;
	{
	    asm {
		move.l #(((long)midiSignIn<<16) + midiToolNum), D0
		dc.w 0xA800		/* sound manager trap. */
	    }
	}

I have tried all sorts of combinations of literal opcodes and things.
I seem to half get into MIDISignIn, because the generic application
icon appears in the patchbay; next thing I know, I've skidded to a
halt in SetDItem with an odd address trap.
   Somebody out there must have this stuff off the ground..? Please?

		Nick.
--
Nick Rothwell,	Laboratory for Foundations of Computer Science, Edinburgh.
		nick@lfcs.ed.ac.uk    <Atlantic Ocean>!mcvax!ukc!lfcs!nick
~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~
               Fais que ton reve soit plus long que la nuit.

cbm@well.UUCP (Chris Muir) (09/09/89)

In message <336@castle.ed.ac.uk>, nick@lfcs.ed.ac.uk (Nick Rothwell)
writes:
=So, what's wrong with something like
=this:
=
=        pascal OSErr MIDISignIn(clientID, refCon, icon, name)
=        OSType clientID;
=        long refCon;
=        Handle icon;
=        StringPtr name;
=        {
=            asm {
=                move.l #(((long)midiSignIn<<16) + midiToolNum), D0
=                dc.w 0xA800             /* sound manager trap. */
=            }
=        }

I can barely read C but, what about the parameters to this trap? Does
C push them in the order the trap wants to see them? Is StringPtr ==
Str255? Why can't you use the routine in the .h file that came with
the MM? 

pascal OSErr MIDISignIn(OSType clientID, long refCon, Handle icon, Str255 name)
	= {0x203C,4,midiToolNum,0xA800};

Have you called SndDispVersion first? I believe SndDispVersion
does some important initialization.





-- 
_______________________________________________________________________________
Chris Muir                             |   "There is no language in our lungs
{hplabs,pacbell,ucbvax,apple}          |    to tell the world just how we feel" 
!well!cbm                              |                         - A. Partridge