vrm@blackwater.cerc.wvu.wvnet.edu (Vasile R. Montan) (12/17/90)
I am writing a program in which I am animating a lot of icons at one time. I want to keep the animation smooth and clean, and I also want to keep everything going at a constant rate regardless of the processor speed, which means that I will somehow have to involve the tick counter. I can think of two strategies for doing this: #1: Have the main program be constantly thinking about the animation of the icons, but handle the actual animation during the video horizontal retrace, when the processor is interrupted and when no drawing is taking place on the screen. I could have a queue of icons to be plotted, and plot just one during each retrace cycle. (I have never written a routine for the horizontal retrace interrupt, however, so this would mean doing some figuring.) #2: Handle the animation wholly in the main program, looking at the tick counter to calculate the position of an icon at any given time. If anyone has done anything like this, I would appreciate your guidance. Second question: How do you draw an icon in XOR? Is this possible with the easy-to-use PlotIcon, or do I have to mess with some kind of bit transfer? Thank you again! --Kurisuto (who is not Vasile) un020070@vaxa.wvnet.edu "At times like these, it helps to remember that there have always been times like these."
stevec@Apple.COM (Steve Christensen) (12/18/90)
In article <1116@babcock.cerc.wvu.wvnet.edu> un020070@vaxa.wvnet.edu writes: >I am writing a program in which I am animating a lot of icons >at one time. I want to keep the animation smooth and clean, and >I also want to keep everything going at a constant rate regardless >of the processor speed, which means that I will somehow have to involve >the tick counter. I can think of two strategies for doing this: > >#1: Have the main program be constantly thinking about the animation >of the icons, but handle the actual animation during the video >horizontal retrace, when the processor is interrupted and when no >drawing is taking place on the screen. I could have a queue of >icons to be plotted, and plot just one during each retrace cycle. >(I have never written a routine for the horizontal retrace interrupt, >however, so this would mean doing some figuring.) You also can't draw from an interrupt routine because the heap may not be consistent, and QuickDraw uses the Memory Manager for regions. >#2: Handle the animation wholly in the main program, looking at >the tick counter to calculate the position of an icon at any >given time. This is probably the safer route. Your animation won't run any faster than at the tick rate you set, but it could run slower since you can't control how long GetNextEvent() will take, especially when running under MultiFinder. >Second question: How do you draw an icon in XOR? Is this possible >with the easy-to-use PlotIcon, or do I have to mess with some kind >of bit transfer? Well, you should just be able to set the transfer mode to XOR and do the plot. steve -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Steve Christensen | Apple Computer, Inc. | Disclaimer: | 20525 Mariani Ave, MS-81CS | the above may be stevec@apple.com | Cupertino, CA 95014 | a lie...or not.
vrm@babcock.cerc.wvu.wvnet.edu (Vasile R. Montan) (12/18/90)
From article <47444@apple.Apple.COM>, by stevec@Apple.COM (Steve Christensen): > In article <1116@babcock.cerc.wvu.wvnet.edu> un020070@vaxa.wvnet.edu writes: [Deleted material in which I talk about plotting icons during the vertical retrace interrupt] > You also can't draw from an interrupt routine because the heap may not be > consistent, and QuickDraw uses the Memory Manager for regions. Really? One book that I saw (but don't own- I think it's called Mac Programming Secrets) suggesting doing drawing during the VBL to accomplish flicker-free animation. Did the interrupt routine somehow signal the main program that the VBL was going on? >>Second question: How do you draw an icon in XOR? Is this possible >>with the easy-to-use PlotIcon, or do I have to mess with some kind >>of bit transfer? > Well, you should just be able to set the transfer mode to XOR and do the plot. I tried this, and it didn't seem to work. I couldn't get the transfer mode to affect PlotIcon at all, which was why I wondered if there might not be some special considerations. Thank you! --Kurisuto (who is not Vasile) email un020070@vaxa.wvnet.edu
stevec@Apple.COM (Steve Christensen) (12/18/90)
vrm@babcock.cerc.wvu.wvnet.edu (Vasile R. Montan) writes: >From article <47444@apple.Apple.COM>, by stevec@Apple.COM (Steve Christensen): >> In article <1116@babcock.cerc.wvu.wvnet.edu> un020070@vaxa.wvnet.edu writes: > >[Deleted material in which I talk about plotting icons during the >vertical retrace interrupt] >> You also can't draw from an interrupt routine because the heap may not be >> consistent, and QuickDraw uses the Memory Manager for regions. >Really? One book that I saw (but don't own- I think it's called >Mac Programming Secrets) suggesting doing drawing during the VBL >to accomplish flicker-free animation. Did the interrupt routine >somehow signal the main program that the VBL was going on? Well, you could probably do drawing during interrupt routines assuming you didn't use QuickDraw, and that any required heap space was locked before you used it. Inside Mac II, pp. 211-213 lists routines that may move memory, and probably all of QuickDraw's drawing routines are represented (vol V, pp601-602 adds the color routines). >>>Second question: How do you draw an icon in XOR? Is this possible >>>with the easy-to-use PlotIcon, or do I have to mess with some kind >>>of bit transfer? >>Well, you should just be able to set the transfer mode to XOR and do the plot. >I tried this, and it didn't seem to work. I couldn't get the transfer >mode to affect PlotIcon at all, which was why I wondered if there might >not be some special considerations. I haven't looked at the PlotIcon code myself, but it could be forcing the drawing mode to srcCopy before drawing the icon. It may just be that the way to do it is to call CopyBits and specify srcXor. steve -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Steve Christensen | Apple Computer, Inc. | Disclaimer: | 20525 Mariani Ave, MS-81CS | the above may be stevec@apple.com | Cupertino, CA 95014 | a lie...or not.
time@tbomb.ice.com (Tim Endres) (12/18/90)
In article <47454@apple.Apple.COM>, stevec@Apple.COM (Steve Christensen) writes: > I haven't looked at the PlotIcon code myself, but it could be forcing the > drawing mode to srcCopy before drawing the icon. It may just be that the way > to do it is to call CopyBits and specify srcXor. > I frequently get burned by using srcXOR where I need patXOR. tim.
daven@svc.portal.com (12/19/90)
In article <1116@babcock.cerc.wvu.wvnet.edu> un020070@vaxa.wvnet.edu writes: > I am writing a program in which I am animating a lot of icons > at one time. I want to keep the animation smooth and clean, and > I also want to keep everything going at a constant rate regardless > of the processor speed, which means that I will somehow have to involve > the tick counter. I can think of two strategies for doing this: > > #1: Have the main program be constantly thinking about the animation > of the icons, but handle the actual animation during the video > horizontal retrace, when the processor is interrupted and when no > drawing is taking place on the screen. I could have a queue of > icons to be plotted, and plot just one during each retrace cycle. > (I have never written a routine for the horizontal retrace interrupt, > however, so this would mean doing some figuring.) Using a VBL task would probably produce the smoothest animation. However, there is an issue here I've always wondered about. With the non-color Mac's the VBL task was tied to the vertical blanking of the B&W monitor. With the color Mac's there is no gaurantee that this is so. I believe the Apple 13" color monitor refreshes it's screen at a faster rate than the 60Hz rate of the VBL task queue. So, could animation by means of a VBL task could cause some flicker on a color monitor? > #2: Handle the animation wholly in the main program, looking at > the tick counter to calculate the position of an icon at any > given time. Probably a simplier scheme to implement. You'd be free of the restrictions governing what a VBL task can and can't do. > If anyone has done anything like this, I would appreciate your guidance. > > Second question: How do you draw an icon in XOR? Is this possible > with the easy-to-use PlotIcon, or do I have to mess with some kind > of bit transfer? PlotIcon calls CopyBits with SrcCopy mode, so no it can't do SrcXor. You will have to call do the work of PlotIcon yourself, calling CopyBits with SrcXor mode. -- ------------------------------------------------------------------------------- Dave Newman | daven@svc.portal.com | AppleLink: D0025 Sofware Ventures Corp. | AOL: MicroPhone | CIS: 76004,2161 Berkeley, CA 94705 | WELL: tinman@well.sf.ca.us | (415) 644-3232
daven@svc.portal.com (12/19/90)
In article <47444@apple.Apple.COM> stevec@Apple.COM (Steve Christensen) writes: > In article <1116@babcock.cerc.wvu.wvnet.edu> un020070@vaxa.wvnet.edu writes: > >I am writing a program in which I am animating a lot of icons > >at one time. I want to keep the animation smooth and clean, and > >I also want to keep everything going at a constant rate regardless > >of the processor speed, which means that I will somehow have to involve > >the tick counter. I can think of two strategies for doing this: > > > >#1: Have the main program be constantly thinking about the animation > >of the icons, but handle the actual animation during the video > >horizontal retrace, when the processor is interrupted and when no > >drawing is taking place on the screen. I could have a queue of > >icons to be plotted, and plot just one during each retrace cycle. > >(I have never written a routine for the horizontal retrace interrupt, > >however, so this would mean doing some figuring.) > > You also can't draw from an interrupt routine because the heap may not be > consistent, and QuickDraw uses the Memory Manager for regions. However, if he refrains from calls that move memory, and manages to set A5 to the application's A5, then there's nothing preventing him from persuing this route. > >Second question: How do you draw an icon in XOR? Is this possible > >with the easy-to-use PlotIcon, or do I have to mess with some kind > >of bit transfer? > > Well, you should just be able to set the transfer mode to XOR and do the plot. No, IM I page 473 says this about PlotIcon: "It calls the QuickDraw procedure CopyBits and uses the srcCopy transfer mode." It looks like one must use CopyBits oneself with a srcXor mode. -- ------------------------------------------------------------------------------- Dave Newman | daven@svc.portal.com | AppleLink: D0025 Sofware Ventures Corp. | AOL: MicroPhone | CIS: 76004,2161 Berkeley, CA 94705 | WELL: tinman@well.sf.ca.us | (415) 644-3232
rmh@apple.com (Rick Holzgrafe) (12/20/90)
In article <1990Dec18.205338.6800@svc.portal.com> daven@svc.portal.com writes: > Using a VBL task would probably produce the smoothest animation. However, > there is an issue here I've always wondered about. With the non-color > Mac's the VBL task was tied to the vertical blanking of the B&W monitor. > With the color Mac's there is no gaurantee that this is so. I believe the > Apple 13" color monitor refreshes it's screen at a faster rate than the 60Hz > rate of the VBL task queue. So, could animation by means of a VBL task could > cause some flicker on a color monitor? If you use the "standard" VBL queue, yes - on modular Macs, it's no longer tied to any monitor's vertical blanking. (Which means it's misnamed, but that's a quibble. :-) However, there is a way. The Vertical Retrace Manager has been extended to support more than the standard queue; there's now one for every slot in a modular Mac. Two of the new calls are SlotVInstall, which installs a task on the VBL queue for a given slot, and SlotVRemove, which removes the task. These calls are documented in IM V-567. "So how do I find out what slot the monitor is in?" Here I gotta go out on a limb - I haven't tried this stuff, I've just pawed through Inside Mac Vol. V. If I understand what I've read correctly, you use the routines in Chapter 5 "Graphics Devices" to learn about each of the display devices that are available. The GDevice record for each will give you the refnum of the driver for the monitor. Now go to Chapter 23 "The Device Manager" and use the refnum to get the AuxDCE record for the driver; this will give you the slot number. Hope this helps (and I hope it's correct...) ========================================================================== Rick Holzgrafe | {sun,voder,nsc,mtxinu,dual}!apple!rmh Software Engineer | AppleLink HOLZGRAFE1 rmh@apple.com Apple Computer, Inc. | "All opinions expressed are mine, and do 20525 Mariani Ave. MS: 3-PK | not necessarily represent those of my Cupertino, CA 95014 | employer, Apple Computer Inc."
oster@well.sf.ca.us (David Phillip Oster) (12/20/90)
Steve, you said you can't draw at interrupt time because Quickdraw references the rgnHandle field of the grafPort, and if the Memory Manager is shuffling the heap, those may not be valid. Is there any reason why my interrupt routine can't have a PRIVATE heap, and have the grafport and its regions allocated inside that? If the interrupt routine's drawing is the only thing using that heap, it can never be in an invalid state during interrupt drawing. -- -- David Phillip Oster - At least the government doesn't make death worse. -- oster@well.sf.ca.us = {backbone}!well!oster
daven@svc.portal.com (Dave Newman) (12/21/90)
In article <1990Dec18.220806.8816@svc.portal.com>, daven@svc.portal.com writes: > In article <47444@apple.Apple.COM> stevec@Apple.COM (Steve Christensen) writes: > > You also can't draw from an interrupt routine because the heap may not be > > consistent, and QuickDraw uses the Memory Manager for regions. > > However, if he refrains from calls that move memory, and manages to set > A5 to the application's A5, then there's nothing preventing him from > persuing this route. > I erred. One can not call QuickDraw from inside a VBL task for the simple reason that QuickDraw is not reentrant. Shoule the task run while QD was in the middle of drawing, the results are likely to be amusing at best, or diastrous at worst. I thank others for pointing out that the Vertical Retrace Mgr on II class Macs can manage multiple VBL task queues, each synchronized to a different monitor's VBL clock. This means that one can have a VBL task inform the application when a VBL is occuring on a particular monitor. --
russotto@eng.umd.edu (Matthew T. Russotto) (12/22/90)
In article <11592@goofy.Apple.COM> rmh@apple.com (Rick Holzgrafe) writes: >In article <1990Dec18.205338.6800@svc.portal.com> daven@svc.portal.com >writes: >> Using a VBL task would probably produce the smoothest animation. However, >> there is an issue here I've always wondered about. With the non-color >> Mac's the VBL task was tied to the vertical blanking of the B&W monitor. >> With the color Mac's there is no gaurantee that this is so. I believe the >> Apple 13" color monitor refreshes it's screen at a faster rate than the >60Hz >> rate of the VBL task queue. So, could animation by means of a VBL task >could >> cause some flicker on a color monitor? > [SlotVInstall info] >"So how do I find out what slot the monitor is in?" Here I gotta go out on >a limb - I haven't tried this stuff, I've just pawed through Inside Mac >Vol. V. If I understand what I've read correctly, you use the routines in >Chapter 5 "Graphics Devices" to learn about each of the display devices >that are available. The GDevice record for each will give you the refnum >of the driver for the monitor. Now go to Chapter 23 "The Device Manager" >and use the refnum to get the AuxDCE record for the driver; this will give >you the slot number. > >Hope this helps (and I hope it's correct...) Sounds correct to me-- here's the code I use. gd = GetMainDevice(); /* or get a different device if you like */ SlotVInstall(taskptr, (*GetADCtlEntry((*gd)->gdRefNum))->dCtlSlot); AuxDCEHandle GetADCtlEntry(refnum) unsigned long refnum; { return *(*((AuxDCEHandle **)0x11c) + (refnum ^ 0xFFFFFFFF)); } (0x11c is the unit table base) -- Matthew T. Russotto russotto@eng.umd.edu russotto@wam.umd.edu .sig under construction, like the rest of this campus.
Lawson.English@p88.f15.n300.z1.fidonet.org (Lawson English) (12/22/90)
Vasile R. Montan writes in a message to All VRM> I tried this, and it didn't seem to work. I couldn't get the VRM> transfer mode to affect PlotIcon at all, which was why I wondered VRM> if there might not be some special considerations From TechNote #055, Drawing Icons, by Jim Friedlander: "[create two bit maps, one for the icon (iBitMap), one for the mask (mBitMap)] Drawing icons as non-open is basically the same for online and offline volumes. We need to punch a hole in the desktop for the icon. This is analogous to punching a hole in dough with an irrecular shaped cookie-cutter. We can then sprinkle jimmies* all over hte cookie and they will only stick in the area that we punced out (the mask). We do this by copyBitsing the mask onto the desktop (whatever pattern) to our destRect. For non-open, non-selelcted icons, we use the SrcBic mode so we that we punch a white hole: SetRect(destRect,left,top,left+32,top+32); CopyBits(mBitMap, thePort^.portBits, icnRect,destRect,SrcXor,NIL); Then we XOR in the icon: CopyBits(iBitMap, thePort^.portBits,iconRect,destRect,SrcXor, Nil); That's all there is to drawing a icon as non-open, non-selected." [...] "*Jimmies: little bits of chocolate" I trust that this will help? Get ahold of the TechNotes stack, it is well worth your while... Lawson -- Uucp: ...{gatech,ames,rutgers}!ncar!asuvax!stjhmc!300!15.88!Lawson.English Internet: Lawson.English@p88.f15.n300.z1.fidonet.org
Chris.Gehlker@p12.f56.n114.z1.fidonet.org (Chris Gehlker) (12/24/90)
VRM> I am writing a program in which I am animating a lot of icons VRM> at one time. I want to keep the animation smooth and clean, and VRM> I also want to keep everything going at a constant rate regardless VRM> of the processor speed, which means that I will somehow have VRM> to involve the tick counter. I can think of two strategies for VRM> doing this: The stratagies that you suggest should work but if you happen to be writing in THINK Pascal, check out Synch on page 355 of the main manual. It may be all you need. -- Uucp: ...{gatech,ames,rutgers}!ncar!asuvax!stjhmc!56.12!Chris.Gehlker Internet: Chris.Gehlker@p12.f56.n114.z1.fidonet.org