Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!att!pacbell.com!pacbell!hoptoad!tim From: tim@hoptoad.uucp (Tim Maroney) Newsgroups: comp.sys.mac.programmer Subject: Re: LClikLoop in a DA Message-ID: <14477@hoptoad.uucp> Date: 2 Jan 91 06:20:22 GMT References: <1990Dec31.202330.17197@athena.cs.uga.edu> Reply-To: tim@hoptoad.UUCP (Tim Maroney) Organization: Electronics for Imaging, San Bruno CA Lines: 46 In article <1990Dec31.202330.17197@athena.cs.uga.edu> fore@athena.cs.uga.edu (Howard Fore) writes: >I'm writing a DA that involves using the list manager in a variety of ways. >However, I am wanting to do some custom stuff and wish to use my own LClikLoop >with LClick. The problem is IM says "no parameters" and and a DA has no >"real" global data. How does one gain access to the "globals" handle (or even >the ListHandle) in the Control record if one's LClikLoop proc is isolated >as such? Is this possible? Have I overlooked something? I've pondered several >hacks, but they don't appear promising or reliable. You have to cheat. There are a few standard ways to do this. The most common is to write a little assembly language that uses PC-relative addressing to manage a little block of storage (DC.L) in code space. Another way, probably worse, is to rely on the undocumented fact that the List Manager passes the list handle to the click loop routine in register a3 or a4 -- I don't recall which. Of course, this could all change in the future. Yet another way is to write what some people erroneously refer to as self-modifying code. Your click loop routine pointer points to a piece of memory that contains the opcodes for something like move.l #0,-(sp) jsr realclikloop addq.l #4,sp rts And then, before ever calling this, write the list handle into the space occupied by the constant zero (which will be two bytes into the code). Then your realclikloop routine will get a parameter consisting of the list handle. Parameter-less procedure pointers are a major screwup in the OS. (One more thing -- notice that the list handle has a field for the use of the caller, much like a refcon field in a window; you can store all your data in a handle there.) -- Tim Maroney, Mac Software Consultant, sun!hoptoad!tim, tim@toad.com "The pride of the peacock is the glory of God. The lust of the goat is the bounty of God. The wrath of the lion is the wisdom of God. The nakedness of woman is the work of God." - Blake, "The Marriage of Heaven and Hell"