gillies@p.cs.uiuc.edu (05/22/89)
I'm sorry if this has been asked before -- How do I make my INIT display an icon as the system boots? I can't seem to find any documentation on this feature. Where is it documented? I've looked through Inside Mac I, II, IV, V, and Mac Programming Secrets. Is there some book/article/TN that describes "everything you need to know about writing code resource type XYZ?" Thanks. Don Gillies, Dept. of Computer Science, University of Illinois 1304 W. Springfield, Urbana, Ill 61801 ARPA: gillies@cs.uiuc.edu UUCP: {uunet,harvard}!uiucdcs!gillies
tim@hoptoad.uucp (Tim Maroney) (05/25/89)
In article <104700056@p.cs.uiuc.edu> gillies@p.cs.uiuc.edu writes: >How do I make my INIT display an icon as the system boots? I can't >seem to find any documentation on this feature. > >Where is it documented? I've looked through Inside Mac I, II, IV, V, >and Mac Programming Secrets. Is there some book/article/TN that >describes "everything you need to know about writing code resource >type XYZ?" You draw it yourself from inside the INIT. It's pretty easy; the only problem is that you can't be sure you aren't stepping on someone else's display. The PlotIcon routine is documented on page I-473; however, if you want to do the kind of fancy-schmancy stuff that others do, like having it grow from a point or march across the screen, you'll have to use CopyBits instead. -- Tim Maroney, Consultant, Eclectic Software, sun!hoptoad!tim "There's a real world out there, with real people. Go out and play there for a while and give the Usenet sandbox a rest. It will lower your stress levels and make the world a happier place for us all." -- Gene Spafford
ksitze@nmsu.edu (Kevin Sitze) (05/25/89)
There are no references to displaying icons onto the screen during startup because there are none (that I know of). Here's a simple program that will draw icons as well as install code into the system heap. Kind of useful but very limited. The routine it uses (DrawIcon) to draw the icons will do somewhat more than what the program makes it do. The program does keep the user interface up through the fact that if the mouse button or the shift key is pressed, then the code resource(s) won't be installed. For more information, read the info in the comments. Hope this helps. /* INIT Installer by Kevin L. Sitze This INIT resource checks the mouse button and the shift key and if either is down then 'ICN#' resource ID=127 will be put onto the screen and the program exits. Otherwise all 'code' resources in the INIT file will be copied into the system heap. The 'code' copy is put into a pointer in the system heap and then whatever is at the start of the code is given control. The current heap is the application heap. The 'ICN#' resource with the same ID number of the code will then be copied onto the screen. If any of the above 'ICN#' resources are not found, then nothing will be drawn though the code will still be allocated as previously mentioned. */ #include <asm.h> #include <Quickdraw.h> #include <MemoryMgr.h> #include <EventMgr.h> #define Chk(x) ((x) << 1 ^ 0x1021) #define KeyCode(x,y) (BitTst(&(x), (y) ^ 0x07)) #define True (1) #define False (0) extern int icnVert : 0x928; extern int icnVChk : 0x92a; extern int icnHorz : 0x92c; extern int icnHChk : 0x92e; GrafPtr myPort; main() { KeyMap myKMap; ResType rType; Str255 name; void (*p)(); THz myZone; int i, id; Handle h; myPort = (GrafPtr) NewPtr(sizeof(GrafPort)); OpenPort(myPort); GetKeys(&myKMap); if (!Button() && !KeyCode(myKMap, 56)) for (i = Count1Resources('code'); i > 0; --i) { if (h = Get1IndResource('code', i)) { asm { move.l h, a0 _GetHandleSize move.w d0, id _NewPtr SYS move.l a0, p } BlockMove(*h, (Ptr) p, id); GetResInfo(h, &id, &rType, name); ReleaseResource(h); (*p)(); /* Call code for startup */ DrawIcon(id, True); } } else DrawIcon(127, True); ClosePort(myPort); DisposPtr((Ptr) myPort); } /* This routines plots an icon onto the desktop. The variable 'icon' */ /* holds an ID number of the ICN# resource to be plotted to the screen */ /* and doInc is a flag that will make the next icon to be plotted, */ /* plotted either on top of the last icon or next to the last icon. */ /* This allows for 'animation sequences' if wanted. Other features */ /* are: 'autowrap' or wrapping to the previous line when icon will be */ /* plotted off the right hand side of the screen. This procedure */ /* should be compatable with most previous ShowIcon algorithms. */ DrawIcon(icon, doInc) int icon, doInc; { BitMap data, mask; Handle h; Rect dst; if (h = GetResource('ICN#', icon)) { if (Chk(icnVert) != icnVChk) icnVChk = Chk(icnVert = myPort->portBits.bounds.bottom - 40); if (Chk(icnHorz) != icnHChk) icnHChk = Chk(icnHorz = 8); if (icnHorz > myPort->portBits.bounds.right - 32) { icnHChk = Chk(icnHorz = 8); icnVChk = Chk(icnVert -= 40); } HLock(h); data.baseAddr = *h; mask.baseAddr = *h + 0x80; data.rowBytes = 4; mask.rowBytes = 4; SetRect(&data.bounds, 0, 0, 32, 32); SetRect(&mask.bounds, 0, 0, 32, 32); SetRect(&dst, icnHorz, icnVert, icnHorz + 32, icnVert + 32); CopyMask(&data, &mask, &myPort->portBits, &data.bounds, &mask.bounds, &dst); ReleaseResource(h); if (doInc) icnHChk = Chk(icnHorz += 40); } } -- +--------------------------------------------------------------------+ | From the Macintosh of: Kevin L. Sitze. This is ME: ksitze@NMSU.edu | +------------------------------------------------------+-------------+ | The difference between intelligence and stupidity is | Is this | | that intelligence has a limit. -- anonymous | better? | +------------------------------------------------------+-------------+