Path: utzoo!attcan!uunet!tut.cis.ohio-state.edu!pt.cs.cmu.edu!andrew.cmu.edu!jpab+ From: jpab+@andrew.cmu.edu (Josh N. Pritikin) Newsgroups: comp.sys.mac.programmer Subject: Re: VBL tasks Think C 4.0 Message-ID: Date: 4 Jul 90 15:43:25 GMT References: <1990Jul3.123350.9958@jarvis.csri.toronto.edu> Distribution: na Organization: Carnegie Mellon, Pittsburgh, PA Lines: 31 In-Reply-To: <1990Jul3.123350.9958@jarvis.csri.toronto.edu> >I am writing an init that patches the JCrsrTask routine with my >own routine. I am confused about Think's SetUpA4 macro and the >IM SetUpA5 macro. They both seem to give me access to the globals In general, SetUpA5 is used in applications and SetUpA4 is used in code resources. Check the manual for specifics. Since you writing an INIT, your globals will be accessed through A4. Read the part in the manual about INITs now, then read the rest of this. I will describe one of many ways to do what you want to do. On entry, at bootup, D0 contains a pointer to the INIT resource. You should called RememberD0 and SetUpA4 (in addition to movem all the registers your going to change onto the stack). This set of calls will store the ptr in a local global variable (read, "not A4 referenced but it is static") and load A4 with it. If you want your INIT to stick around, you should RecoverHandle on A4, then DetachResource, HLock and HNoPurge (to be safe). When your INIT is called again from JCrsrTask or the like, you need to SetUpA4, but DON'T RememberD0. The local global variable already has the correct value (the handle is locked down). You can exit normally using RestoreA4, etc. To be safe, you shouldn't change any registers as a side effect of your routine unless you know what your doing. Always make sure the stack pointer doesn't get screwed up and happy debugging... /* Josh Pritikin jpab+@andrew.cmu.edu If you can't c, lisp. */