Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!rutgers!apple!lsr From: lsr@Apple.COM (Larry Rosenstein) Newsgroups: comp.sys.mac.programmer Subject: Re: Fast image changes Message-ID: <538@internal.Apple.COM> Date: 6 Feb 89 18:10:42 GMT References: <243@usage.csd.unsw.oz> <2580015@hpausla.HP.COM> Organization: Advanced Technology Group, Apple Computer Lines: 50 In article <2580015@hpausla.HP.COM> jcl@hpausla.HP.COM (Jeff Laing) writes: >Has anyone had a look though the article in the February issue of MacTutor >which seems to be doing PlotIcon from within a VBL task? > >Has the discussion here been missing something, or will the article's program >have real problems? You are right, the article has problems. I found 3 problems (in increasing order of seriousness): (1) In the VBL task, the program sets up A5 based on the low memory value CurrentA5. This won't work under MultiFinder, if the VBL task is installed in the System Heap (which means it would be running when the application was in the background). The current recommendation is that a VBL task get the proper A5 from a value associated with the queue element. The application should set this value before starting the VBL task. (2) The program pushes the old value of A5 on the stack and pops it off at the end. Tech Note 208 warns against doing this because some compilers (eg, MPW C 3.0) will leave things on the stack and pop them off all at once. The technique of pushing A5 on the stack will mess this up. It is better to save A5 in a local variable of the VBL task and restore it from that variable. The Tech Note gives the code to do this. (3) As you mentioned, the VBL task calls PlotIcon and GetIcon, both of which are listed as moving memory, which means they can't be called from a VBL task. The third problem is generally fatal, although you could make it work most of the time if the icons were marked preload and locked in the resource file. In a small program like this, there wouldn't be much heap compaction going on, and you probably can get away with it. The first 2 points are not fatal, but are not good programming style. Unfortunately, the style that works in this simple case may not work in other cases. Someone who uses this article as a guide but makes his/her VBL task run in the background will find it won't work under MultiFinder. -- Larry Rosenstein, Object Specialist Apple Computer, Inc. 20525 Mariani Ave, MS 46-B Cupertino, CA 95014 AppleLink:Rosenstein1 domain:lsr@Apple.COM UUCP:{sun,voder,nsc,decwrl}!apple!lsr