Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!apple!well!oster From: oster@well.sf.ca.us (David Phillip Oster) Newsgroups: comp.sys.mac.programmer Subject: Re: Driver Question Message-ID: <21811@well.sf.ca.us> Date: 24 Nov 90 05:29:35 GMT References: <1990Nov19.204829.4725@jarvis.csri.toronto.edu> <1990Nov20.180537.6876@eng.umd.edu> Distribution: na Organization: Whole Earth 'Lectronic Link, Sausalito, CA Lines: 47 This is a short summary of how to write drivers. Get a set of Macintosh tech notes. You can start with just the table of contents if you have on-line access. You make a file of type INIT. It contains a resource of type INIT, id=129 is good. Mark this resource Locked in your development system. In code it looks like: main(){ RenumberDriver(); OpenDriver(); } In THINK C, it'll look more like: #include main(){ Handle drvr; RememberA0(); SetUpA4(); drvr = GetResource('DRVR', RenumberDriver("\p.MyDriver"); OpenDriver("\p.MyDriver"); DetachResource(drvr); RetoreA4(); } You need to write RenumberDriver(). It should search the unit table, and the current resources, to find an acceptable free slot in the driver unit table, and renumber the driver so it uses that slot. Your DRVR resource should have its SystemHeap bit set. You should also have: a BNDL, an FREF, an ICN# and a signature. The signature should be registered with apple (Write to them at Apple tech support. They just want each program to have a unique signature so when a naive user double- clicks on a document, predicatble thinsg will happen. Your INIT should also either have the ShowInit resource, or incorporate that code into itself. I prefer the latter choice, so I can write my INIT to not load itself if the key is down, and to draw an X-ed out icon if it fails to load. If you need a user interface, use a CDEF or RDEV file and add the appropriate resources to be in the ControlPanel and Chooser respectively. If you need a lot of memory, add a 'sysz' resource and the system will grow the system heap before calling your INIT (but you'd better claim your memory at INIT time, because that space may be used by something else in the system heap later otherwise.) See Inside Mac Vol 4 (The Control Panel) for useful additional info. At INIT time, the stack is in the middle of memory, rather than at the end, and at one time Apple advised putting things above the stack. No longer, put them in the system heap. -- -- David Phillip Oster - Note new signature. Old one has gone Bye Bye. -- oster@well.sf.ca.us = {backbone}!well!oster