Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!zephyr.ens.tek.com!tektronix!reed!lclark!dan From: dan@lclark.UUCP (Dan Revel) Newsgroups: comp.sys.mac.programmer Subject: Re: MIDI Manager/Think C/A5 Register Summary: saving A5 for completion routines Message-ID: <915@lclark.UUCP> Date: 13 Apr 90 22:32:04 GMT References: <9004121500.AA00697@canoe.cis.ohio-state.edu> Reply-To: dan@lclark.UUCP (Dan Revel) Organization: Lewis & Clark College, Portland OR Lines: 63 In article <9004121500.AA00697@canoe.cis.ohio-state.edu> james_kent@CIS.OHIO-STATE.EDU writes: >I've been trying to use MIDI manager with Think C and have come across the >following problem (at least as I understand it). ... >I need a method of doing the following, using Think C : > >1) save the application's A5 value somewhere when the application starts > (Location X) >2) when the interrupt routine is called, save the current A5 value (Location Y) > and move the value from Location X into A5 >3) when the interrupt routine completes, move the value from Location Y back > into A5 before returning Your call-back routine should be of the form: PROCEDURE MyCallBack(chan: SndChannelPtr; cmd: SndCommand); [IM V-480] in C that would be: pascal void MyCallBack(SndChannelPtr chan, SndCommand cmd); Store your CurrentA5 either in the userInfo field of your SndChannel or else put it just before your SndChannel and use Think C's assembler to recover it, e.g.: Ptr savedA5; SndChannel myChannel; mySetUp() { /* what have you */ savedA5 = CurrentA5; } pascal void MyCallBack(SndChannelPtr chan, SndCommand cmd) { Ptr myA5, oldA5; asm { move.l -4(chan), myA5 ; get savedA5 } oldA5 = SetA5(myA5); /* do your stuff */ SetA5(oldA5); /* restore A5 for the interrupt when you are done */ } pascal long SetA5(long newA5) = { 0x2f4d, 0x0004, 0x2a5f }; SetA5 is described in Tech Note #208 as 'The New, Totally Cool Way' to do this instead of using SetupA5() and RestoreA5(). Tech Note #180 might also be of interest to you. That's how you do it... I don't make any promises about the accuracy of my code, it is untested, I just wrote it as an example... Good Luck. -- dan@lclark tektronix!reed!lclark!dan Dylsexics untie! (-|