tracyn@dgp.toronto.edu (Tracy Narine) (07/03/90)
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 but I am unsure if I need to call both macros when I enter my VBL task, then call the corresponding RestoreA4,A5 when I leave the task to access my globals. What is the appropriate way of accessing global variables in a VBL task routine that is encoded in an init? tracy
jpab+@andrew.cmu.edu (Josh N. Pritikin) (07/04/90)
>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. */