Path: utzoo!utgpu!watmath!att!tut.cis.ohio-state.edu!ucbvax!pasteur!ames!uhccux!munnari.oz.au!stcns3!ipso!metro!pta!teti!teslab!andrew From: andrew@teslab.lab.OZ (Andrew Phillips 289 8712) Newsgroups: comp.sys.amiga.tech Subject: Exiting, but leaving some code "resident" Summary: What is the proper way to do it? Message-ID: <188@teslab.lab.OZ> Date: 8 Aug 89 07:03:30 GMT Reply-To: andrew@teslab.lab.OZ (Andrew Phillips) Organization: Technology Evaluation Section, L.A.B., Sydney Lines: 30 I am looking to write a software "disk drive active light", because my hard disk has no drive light (its just a card in my SideCar). To do this I just need a little bit of code to hook into a device and turn on a sprite (already positioned in a corner of the screen) when the drive access begins and turn it off again when the access is completed. It could also be used as a RAM disk drive light. Most of the program will be concerned with setting up the sprite etc and just a little bit will need to remain resident after the setup is complete. Under MSDOS it is quite easy to set up a TSR (terminate, stay resident) program that leaves a part of itself at the top of memory and frees the memory occupied by all of its initialization code back to DOS. I'm not sure, however, what the best way to do this is on the Amiga. My first thought was to look at how some PD programs such as Popcli do it. To my surprise Popcli never frees anything back to the OS, instead it goes through some incredible contortions to make itself as small as possible. Surely it would be preferable to only leave the relevant code in memory. This would save more memory than Popcli now does and still let the program be more "conventional" and hence more readable and portable. The only way I can think to do it is to allocate a bit of memory which is never freed. The program will allocate this memory, copy some machine code to it, redirect a few functions (BeginIO for the device?) into this code and then terminate. Is there a proper way to do it or is there at least a *better* way to do it? Andrew. -- Andrew Phillips (andrew@teslab.lab.oz{.au}) Ph. +61 (Aust) 2 (Sydney) 289 8712