amiga-request@ab20.larc.nasa.gov (Amiga Sources/Binaries Moderator) (03/25/91)
Submitted-by: E. van Breemen <breemen@rulcvx.uucp> Posting-number: Volume 91, Issue 075 Archive-name: utilities/nocare-1.5/part01 [ includes uuencoded executable ...tad ] This is the nocare V1.5 archive. This was the first version of nocare and is using a task instead of resources used by the later nocare V1.2.1. ( I know the version number is lower than 1.5). This is an example of creating and cleaning up a task. -Erwin- #!/bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of archive 1 (of 1)." # Contents: NoCare.asm NoCare.doc NoCare.uu # Wrapped by tadguy@ab20 on Mon Mar 25 10:52:25 1991 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'NoCare.asm' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'NoCare.asm'\" else echo shar: Extracting \"'NoCare.asm'\" \(11898 characters\) sed "s/^X//" >'NoCare.asm' <<'END_OF_FILE' X;----------------------------------------------------------------------------- X; X; Program : NoCare.asm V1.5 X; Author : Raymond Hoving, The Orega Programming Group Holland X; Creation Date : Wed Jan 16 19:28:28 1991 X; Purpose : A utility to speed up the workbench window environment. X; Usage : NoCare - Starts/stops the program from a CLI/Shell. X; X; See copyright notes in file called 'NoCare.doc'. X; Bug reports or comments to: X; X; The Orega Programming Group Holland, X; P.o.box 499, Apothekersdijk 24, X; 2280 AL Rijswijk, 2312 DD Leiden, X; The Netherlands. The Netherlands. X; Phone .. - (0)71 - 14 49 71 X; X; or UUCP: breemen@rulcvx.LeidenUniv.nl (shared account). X; X;----------------------------------------------------------------------------- X XOPENLIB macro ; \1 library name. X data ; \2 address of failure handling code. X\1name dc.b '\1.library',0 Use 0 for \1fails. X even ; \3 Optional version number. X\1base ds.l 1 ; (Default value is 33) X code ; Registers affected d0,a1,a6. X lea.l \1name,a1 X ifne NARG-3 X move.l #33,d0 X endc X ifeq NARG-3 X move.l #\3,d0 X endc X CALL exec,OpenLibrary X move.l d0,\1base X ifc '\2','0' X beq \1fails X endc X ifnc '\2','0' X beq \2 X endc X endm X XCLOSELIB macro ; \1 library name. X move.l \1base,a1 ; Registers affected a1,a6. X CALL exec,CloseLibrary X endm X XCALL macro ; \1 library name. X ifnc '\1','exec' ; \2 function name. X move.l \1base,a6 ; Registers affected a6. X endc X ifc '\1','exec' X move.l _SysBase,a6 X endc X jsr _LVO\2(a6) X endm X XCALLR macro ; \1 function name. X jsr _LVO\1(a6) ; No registers affected. X endm X XSTANDARDOUTPUT macro ; Init of stdout, used by PRINT etc. X data Xstdout ds.l 1 X code X CALL dos,Output X move.l d0,stdout X endm X XPRINT macro ; Prints string at location \1 X move.l stdout,d1 ; with lenght \2. No automatic X move.l #\1,d2 ; linefeed. X move.l #\2,d3 X CALL dos,Write X endm X X_LVOOpenLibrary equ -552 ; Library vector offsets. X_LVOCloseLibrary equ -414 ; No need to link with amiga.lib. X_LVOOutput equ -60 X_LVOWrite equ -48 X_LVOAllocSignal equ -330 X_LVOFreeSignal equ -336 X_LVOFindTask equ -294 X_LVOFindPort equ -390 X_LVOAddPort equ -354 X_LVORemPort equ -360 X_LVOAllocEntry equ -222 X_LVOWaitPort equ -384 X_LVOGetMsg equ -372 X_LVOPutMsg equ -366 X_LVOReplyMsg equ -378 X_LVOSetFunction equ -420 X_LVOForbid equ -132 X_LVOPermit equ -138 X_LVOCopyMem equ -624 X_LVOAddTail equ -246 X_LVOAddTask equ -282 X_LVORemTask equ -288 X_LVOOpenWindow equ -204 X_SysBase equ $4 X X X include exec/exec.i X include intuition/intuition.i X include intuition/screens.i X XREFRESHBIT0 equ $06 XREFRESHBIT1 equ $07 ; Bits in the nw_Flags field. X XSTACKSIZE equ 200 ; Stack size for the NoCare task. X XMN_CONTENTS equ MN_SIZE XREPLY equ $0 XFAILURE equ $1 XSUCCESS equ $2 XREMOVE equ $3 ; Inter-task communication defenitions. X X code X X; Open dos.library and print message. X X OPENLIB dos,0 X STANDARDOUTPUT X PRINT mess1,mess2-mess1 X X; Create a message port for communication with the NoCare task: X X move.l #-1,d0 X CALL exec,AllocSignal X move.b d0,signal1 X bmi signal1fails ; Allocate a signal. X sub.l a1,a1 X CALLR FindTask X lea.l port1,a1 X move.l d0,MP_SIGTASK(a1) ; Link this task into messageport. X move.b signal1,MP_SIGBIT(a1) ; Link allocated signal into port. X CALLR AddPort ; Make the port a public one. X X; Is NoCare active already? X X CALLR Forbid X lea.l port2name,a1 ; Try to find NoCare2.Orega port. X CALLR FindPort X move.l d0,d6 X CALLR Permit X tst.l d6 X bne sendremovemessage X X; The NoCare2.Orega port has not been found, so start the NoCare task: X; First allocate memory for the task structure, the stack and a safe X; place for the PC-relative code of the NoCare task. X X lea.l memlist1,a0 X CALLR AllocEntry X bclr.l #31,d0 X bne allocerror ; Not enough memory! X move.l d0,a5 ; Remember address in a5. X X; Then copy the PC-relative taskcode to the safe place: X X move.l LN_SIZE+10(a5),a1 ; Get pointer to allocated memory. X lea.l codestart,a0 X move.l #codeend-codestart,d0 X CALLR CopyMem X X; Then create the new task (has no name yet): X X move.l LN_SIZE+2(a5),a0 ; Get pointer to allocated memory. X X; Link stack, task structure and code area into task's memlist: X X lea.l TC_MEMENTRY(a0),a0 ; Get pointer to task's memlist. X move.b #NT_MEMORY,LN_TYPE(a0) X move.l a0,(a0) X addq.l #LH_TAIL,(a0) X clr.l LH_TAIL(a0) ; Initialise list structure. X move.l a0,(LH_TAIL+LN_PRED)(a0) X X move.l a5,a1 X CALLR AddTail ; Add node to memlist. X X move.l LN_SIZE+2(a5),d0 X move.l d0,a1 X add.l #TC_SIZE,d0 X move.l d0,TC_SPLOWER(a1) ; Lower stack boundary, X add.l #STACKSIZE,d0 X move.l d0,TC_SPUPPER(a1) ; Upper stack boundary. X move.l d0,TC_SPREG(a1) ; Initial stack pointer. X move.b #NT_TASK,LN_TYPE(a1) ; Node type. X move.l LN_SIZE+10(a5),a2 ; Initial PC of NoCare task. X sub.l a3,a3 X CALLR AddTask ; Lets's go! X XRemTask X X; The NoCare task has been launched, now wait for the startup message: X Xgetmsgloop1 X lea.l port1,a0 X CALLR WaitPort ; Wait for a message. X lea.l port1,a0 X CALLR GetMsg ; Get the new message. X move.l d0,a1 X move.w MN_CONTENTS(a1),d6 ; Save the important field. X move.w #REPLY,MN_CONTENTS(a1) ; Mark as a replied message. X CALLR ReplyMsg ; Quickly reply message. X X; Examine the startup message now: X X cmp.w #FAILURE,d6 X beq.s installfailed X cmp.w #SUCCESS,d6 X bne.s getmsgloop1 ; Should never execute this. X PRINT mess2,mess3-mess2 ; 'Installed.' X bra ex1 Xinstallfailed X PRINT mess4,mess5-mess4 ; 'Could not install.' X bra ex1 X X; Send a message to the messageport of the NoCare task. X; This informs the NoCare task to remove the OpenWindow patch. X; The address of the messageport is in d6: X Xsendremovemessage X lea.l message1,a1 X move.w #REMOVE,MN_CONTENTS(a1) X move.l d6,a0 ; Destination port. X CALLR PutMsg Xgetmsgloop2 X lea.l port1,a0 X CALLR WaitPort ; Wait for reply. X lea.l port1,a0 X CALLR GetMsg X move.l d0,a0 X move.w MN_CONTENTS(a0),d0 X X; We asked the NoCare task to remove itself (and of course the X; OpenWindow patch). Examine the reply of the NoCare task: X X cmp.w #FAILURE,d0 X beq.s remerror X cmp.w #SUCCESS,d0 X bne.s getmsgloop2 ; Should never execute this. X PRINT mess3,mess4-mess3 ; 'Removed.' X bra.s ex1 Xremerror X PRINT mess5,mess6-mess5 ; 'Could not remove.' X bra.s ex1 X X; Error handling code: X Xsignal1fails X PRINT mess6,mess7-mess6 X bra.s ex0 Xallocerror X PRINT mess6,mess7-mess6 X X; Cleanup code follows: X Xex1 lea.l port1,a1 X CALL exec,RemPort X clr.l d0 X move.b signal1,d0 ; Free signal. X CALLR FreeSignal Xex0 CLOSELIB dos Xdosfails X rts X X data X Xmessage1 dc.l 0,0 ; ln_succ, ln_pred X dc.b NT_MESSAGE,0 ; ln_type, ln_pri X dc.l 0 ; ln_name X dc.l port1 ; mn_replyport X dc.w MN_SIZE+2 ; mn_length X dc.w 0 ; mn_contents X Xport1 dc.l 0,0 ; ln_succ, ln_pred X dc.b NT_MSGPORT,1 ; ln_type, ln_pri X dc.l port1name ; ln_name X dc.b PA_SIGNAL,0 ; mp_flags, mp_sigbit X dc.l 0 ; mp_sigtask X dc.l 0,0,0 ; lh_head, lh_tail, lh_tailpred X dc.b NT_MESSAGE,0 ; lh_type, lh_pad X Xmemlist1 dc.l 0,0 ; ln_succ, ln_pred X dc.b NT_MEMORY,0 ; ln_type, ln_pri X dc.l 0 ; ln_name X dc.w 2 ; Numer of entries. X dc.l MEMF_PUBLIC!MEMF_CLEAR X dc.l STACKSIZE+TC_SIZE X dc.l MEMF_PUBLIC X dc.l codeend-codestart X Xsignal1 ds.l 1 Xport1name dc.b 'NoCare1.Orega',0 Xport2name dc.b 'NoCare2.Orega',0 Xmess1 dc.b $1b,'[33mNoCare V1.5',$1b,'[0m by Raymond Hoving,' X dc.b ' THE OREGA PROGRAMMING GROUP HOLLAND.',$a Xmess2 dc.b 'OpenWindow() patch installed.',$a Xmess3 dc.b 'OpenWindow() patch removed.',$a Xmess4 dc.b 'ERROR: Could not install.',$a Xmess5 dc.b 'ERROR: Could not remove.',$a Xmess6 dc.b 'ERROR: Out of memory/signals',$a Xmess7 X X;----------------------------------------------------------------------------- X; Now follows the code of the NoCare task. This code is PC-relative. X; First we give this task a name: X X code X Xcodestart X sub.l a1,a1 X CALL exec,FindTask X move.l d0,a0 X lea.l taskname(PC),a1 X move.l a1,LN_NAME(a0) X X; Open intuition.library: X X lea.l intuitionname(PC),a1 X clr.l d0 X CALLR OpenLibrary X lea.l intuitionbase(PC),a2 X move.l d0,(a2) X; beq.s intuitionfails ; Any version will do. X X; Then patch the OpenWindow() function: X X move.l d0,a1 X move.w #_LVOOpenWindow,a0 X lea.l newopenwindow(PC),a2 X move.l a2,d0 X CALLR SetFunction X lea.l oldopenwindow(PC),a2 X move.l d0,(a2) X X; Create a message port (called NoCare2.Orega) X X move.l #-1,d0 X CALLR AllocSignal X; bmi signal2fails ; It's my task! X lea.l signal2(PC),a2 X move.b d0,(a2) X sub.l a1,a1 X CALLR FindTask X lea.l port2(PC),a1 X move.l d0,MP_SIGTASK(a1) X lea.l port2name2(PC),a0 X move.l a0,LN_NAME(a1) X move.b signal2(PC),MP_SIGBIT(a1) X CALLR AddPort ; Add port to system. X X; Now send a message to our parent task, that NoCare is installed X; without problems: X X CALLR Forbid X lea.l port1name2(PC),a1 ; Try to find NoCare1.Orega port. X CALLR FindPort X move.l d0,d6 ; Remember port in d6. X CALLR Permit X tst.l d6 X; beq port1gone ; Impossible situation! X X lea.l port2(PC),a0 X lea.l message2(PC),a1 X move.l a0,MN_REPLYPORT(a1) X move.w #SUCCESS,MN_CONTENTS(a1) X move.l d6,a0 ; Destination port. X CALLR PutMsg X X; Then wait for the REPLY message or the REMOVE message: X Xgetmsgloop3 X lea.l port2(PC),a0 X CALLR WaitPort ; Wait for message. X lea.l port2(PC),a0 X CALLR GetMsg X move.l d0,a0 X cmp.w #REMOVE,MN_CONTENTS(a0) X bne.s getmsgloop3 ; It's the REPLY message. X move.l d0,a5 ; Remember this message. X X; So the user wants to terminate NoCare. X; First test if someone else patched our patch. X X CALLR Forbid X move.l intuitionbase(PC),a3 X move.l _LVOOpenWindow+2(a3),a3 ; Get OpenWindow vector. X lea.l newopenwindow(PC),a4 X cmp.l a3,a4 X bne.s removeerror X X; Now we restore the old OpenWindow vector: X X move.l oldopenwindow(PC),d0 ; Pointer to original code. X move.l intuitionbase(PC),a1 X move.w #_LVOOpenWindow,a0 X CALLR SetFunction X CALLR Permit X X; Then we remove the messageport and free the signal bit: X X lea.l port2(PC),a1 X CALLR RemPort X clr.l d0 X move.b signal2(PC),d0 X CALLR FreeSignal ; Just to be nice. X X; Reply the REMOVE message: X X move.l a5,a1 ; Pointer to the REMOVE message. X move.w #SUCCESS,MN_CONTENTS(a1) X CALLR ReplyMsg X X; Close intuition.library: X X move.l intuitionbase(PC),a1 X CALLR CloseLibrary X X; Then call exec's standard task finalizer. The task structure, X; it's stack and the safeplace-area will be freed. X X sub.l a1,a1 X CALLR RemTask ; End of NoCare task. X X;----------------------------------------------------------------------------- X; When NoCare could not be removed, we reply with a failure type message. X Xremoveerror X CALLR Permit X move.l a5,a1 X move.w #FAILURE,MN_CONTENTS(a1) X CALLR ReplyMsg X bra getmsgloop3 ; Wait for another try... X X;----------------------------------------------------------------------------- X; As OpenWindow() is called, then a0 points to a NewWindow structure. X; We patch a bit in the nw_Flags field and than jump to the original X; OpenWindow() code. X Xnewopenwindow X cmp.w #WBENCHSCREEN,nw_Type(a0) X bne.s dontchange X move.l nw_Flags(a0),d0 X bclr #REFRESHBIT0,d0 ; We don't want SIMPLE_REFRESH ones. X move.l d0,nw_Flags(a0) Xdontchange X move.l oldopenwindow(PC),a1 X jmp (a1) ; Jump to original code. X X;----------------------------------------------------------------------------- X Xmessage2 dc.l 0,0 ; ln_succ, ln_pred X dc.b NT_MESSAGE,0 ; ln_type, ln_pri X dc.l 0 ; ln_name X dc.l 0 ; mn_replyport X dc.w MN_SIZE+2 ; mn_length X dc.w 0 ; mn_contents X Xport2 dc.l 0,0 ; ln_succ, ln_pred X dc.b NT_MSGPORT,1 ; ln_type, ln_pri X dc.l 0 ; ln_name X dc.b PA_SIGNAL,0 ; mp_flags, mp_sigbit X dc.l 0 ; mp_sigtask X dc.l 0,0,0 ; lh_head, lh_tail, lh_tailpred X dc.b NT_MESSAGE,0 ; lh_type, lh_pad X Xoldopenwindow ds.l 1 Xsignal2 ds.l 1 Xintuitionbase ds.l 1 Xtaskname dc.b 'NoCareTask.Orega',0 Xport1name2 dc.b 'NoCare1.Orega',0 Xport2name2 dc.b 'NoCare2.Orega',0 Xintuitionname dc.b 'intuition.library',0 X Xcodeend X X end X X;----------------------------------------------------------------------------- END_OF_FILE if test 11898 -ne `wc -c <'NoCare.asm'`; then echo shar: \"'NoCare.asm'\" unpacked with wrong size! fi # end of 'NoCare.asm' fi if test -f 'NoCare.doc' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'NoCare.doc'\" else echo shar: Extracting \"'NoCare.doc'\" \(1314 characters\) sed "s/^X//" >'NoCare.doc' <<'END_OF_FILE' XNAME X NoCare V1.5 - Faster windows. X XDATE X Wed Jan 16 1991 X XPURPOSE X This utility speeds up your windowing environment. X The OpenWindow vector is patched. When someone tries X to open a window in the workbench screen, the lower X refreshbit in the nw_Flags field is cleared. This way, X only NOCAREREFRESH windows will be opened, resulting in X faster window movements. Windows opened in customscreens X are not affected. X XUSAGE X Type 'NoCare' from a Shell/CLI to install/remove the patch. X NoCare will detach itself from the Shell/CLI, so no X need to use run(back). X XBUGS / LIMITATIONS X The price for faster windows is an increased usage X of chip memory. In some situations this may be unwanted. X Windows that were opened before NoCare was started are X not affected, and will still be slow. X For an unknown reason, the workbench 1.3 clock program X doesn't like NoCare 1.5 (don't try to resize the clock X window when you don't like strange phenomena ). X Bug reports, questions or comments to: X XAUTHOR X Raymond Hoving, X The Orega Programming Group Holland. X P.o.box 499, 2280 AL Rijswijk, The Netherlands. X Phone Holland (071) 14 49 71. X XCOPYRIGHT NOTES X NoCare V1.5 is public domain. However, it is not allowed to X use NoCare V1.5 as part of a commercial product without the X written permission of the author. END_OF_FILE if test 1314 -ne `wc -c <'NoCare.doc'`; then echo shar: \"'NoCare.doc'\" unpacked with wrong size! fi # end of 'NoCare.doc' fi if test -f 'NoCare.uu' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'NoCare.uu'\" else echo shar: Extracting \"'NoCare.uu'\" \(2361 characters\) sed "s/^X//" >'NoCare.uu' <<'END_OF_FILE' Xbegin 666 NoCare XM```#\P`````````"``````````$```$&````60```^D```$&0_D`````(#P`D XM```A+'D````$3J[]V"/`````#&<``CXL>0````Q.KO_$(\`````0(CD````0_ XM)#P```",)CP```!-+'D````,3J[_T"`\_____RQY````!$ZN_K83P````&QKR XM``&2D\E.KO[:0_D````J(T``$!-Y````;``/3J[^GDZN_WQ#^0```'Y.KOYZ@ XM+`!.KO]V2H9F``#H0?D```!,3J[_(@B``!]F``%H*D`B;0`80?D```)>(#P`; XM``&Y3J[]D"!M`!!!Z`!*$7P`"@`(((A8D$*H``0A2``((DU.KO\*("T`$")`4 XM!H````!<(T``.@:`````R"-``#XC0``V$WP``0`()&T`&)?+3J[^YD'Y````$ XM*DZN_H!!^0```"I.KOZ,(D`\*0`4,WP````43J[^AKQ\``%G)KQ\``)FT"(Y] XM````$"0\````V28\````'BQY````#$ZN_]!@``#0(CD````0)#P```$3)CP`V XM```:+'D````,3J[_T&```+!#^0```!0S?``#`!0@1DZN_I)!^0```"I.KOZ`, XM0?D````J3J[^C"!`,"@`%+!\``%G)+!\``)FVB(Y````$"0\````]R8\````` XM'"QY````#$ZN_]!@6"(Y````$"0\```!+28\````&2QY````#$ZN_]!@.B(YU XM````$"0\```!1B8\````'2QY````#$ZN_]!@."(Y````$"0\```!1B8\````^ XM'2QY````#$ZN_]!#^0```"HL>0````1.KOZ80H`0.0```&Q.KOZP(GD````," XM+'D````$3J[^8DYUD\DL>0````1.KO[:($!#^@%J(4D`"D/Z`8]"@$ZN_=A%" XM^@%4)(`B0#!\_S1%^@#N(`I.KOY<1?H!-B2`(#S_____3J[^MD7Z`2H4@)/)= XM3J[^VD/Z`/@C0``00?H!/2-(``H3>@$.``].KOZ>3J[_?$/Z`1E.KOYZ+`!.I XMKO]V2H9!^@#*0_H`L"-(``XS?``"`!0@1DZN_I)!^@"R3J[^@$'Z`*I.KOZ,G XM($`,:``#`!1FYBI`3J[_?"9Z`+PF:_\V2?H`6KG+9D`@.@"D(GH`J#!\_S1.P XMKOY<3J[_=D/Z`&Y.KOZ80H`0.@"*3J[^L")-,WP``@`43J[^AB)Z`'I.KOYB< XMD\E.KO[@3J[_=B)-,WP``0`43J[^AF``_WX,:``!`"YF#"`H``X(@``&(4``1 XM#B)Z`#Q.T0``````````!0`````````````6``````````````0!````````E XM``````````````````````4`````````````````3F]#87)E5&%S:RY/<F5G+ XM80!.;T-A<F4Q+D]R96=A`$YO0V%R93(N3W)E9V$`:6YT=6ET:6]N+FQI8G)A' XM<GD``````^P````!`````````+8````F`````0````(````8````(@```"P`@ XM```R````.````$0```!>````;@```'@```"(````G@```10```$>```!1```1 XM`4H```%6```!9````6H```%V```!A````98```&@```!O````<(```'.```!V XMV@```>````'L```!^````?X```(*```"%@```AP```(H```",@```D0```).6 XM`````````_(```/J````661O<RYL:6)R87)Y```````````````````````%I XM```````````J`!8`````````````!`$```!P````````````````````````U XM!0````````````H````````"``$``0```20````!```!N0````!.;T-A<F4Q< XM+D]R96=A`$YO0V%R93(N3W)E9V$`&ULS,VU.;T-A<F4@5C$N-1M;,&T@8GD@; XM4F%Y;6]N9"!(;W9I;F<L(%1(12!/4D5'02!04D]'4D%-34E.1R!'4D]54"!(8 XM3TQ,04Y$+@I/<&5N5VEN9&]W*"D@<&%T8V@@:6YS=&%L;&5D+@I/<&5N5VEN5 XM9&]W*"D@<&%T8V@@<F5M;W9E9"X*15)23U(Z($-O=6QD(&YO="!I;G-T86QLX XM+@I%4E)/4CH@0V]U;&0@;F]T(')E;6]V92X*15)23U(Z($]U="!O9B!M96UO) XH<GDO<VEG;F%L<PH````#[`````(````!````(@```#0````````#\B!M? X`` Xend Xsize 1660 END_OF_FILE if test 2361 -ne `wc -c <'NoCare.uu'`; then echo shar: \"'NoCare.uu'\" unpacked with wrong size! fi # end of 'NoCare.uu' fi echo shar: End of archive 1 \(of 1\). cp /dev/null ark1isdone MISSING="" for I in 1 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have the archive. rm -f ark[1-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0 -- Mail submissions (sources or binaries) to <amiga@uunet.uu.net>. Mail comments to the moderator at <amiga-request@uunet.uu.net>. Post requests for sources, and general discussion to comp.sys.amiga.misc.