[comp.sys.amiga] System Requests to ActiveWindow

billk@pnet01.CTS.COM (Bill Kelly) (08/25/87)

(By the way, for those of you who haven't been watching comp.amiga.sources and
comp.amiga.binaries, I released WarpText 2.0 about a month-and-a-half ago. 
WarpText 2.0 is a text routine that is meant to be used in your programs. 
Assembler source code and object code for linking are supplied.  WarpText 2.0
will output text at ~30,000 characters per second.)

Anyway, after being annoyed too many times by System Requests popping up,
shoving the WorkBench screen to front, and then not putting it back, I decided
to see if something could be done about it.  Personally, I wasn't too thrilled
with an existing program which doesn't put up the requesters, but instead acts
as though you hac clicked on Cancel.  (Sometimes I needed to hit Retry!)

I poked around until I discovered the IntuitionBase structure, and then,
after seeing the ib_ActiveWindow field, decided to write "FixReq."

I am posting the source and UUEncoded binary here as it seems (perhaps
incorectly) too small to bother with comp.amiga.sources. 

Following is the assembler source code for FixReq, followed by the UUEncoded
binary. 

================================FixReq.asm==================================
****************************************************************************
* FixReq.asm -- makes all "System Request" requesters       Bill Kelly
* appear in the current active window.                      08/24/87
*
* This code is placed into the public domain without any
* guarantees or support of any kind.
*
* To the best of my knowledge, this program follows all of
* the "rules" for hacking at library vectors and is perfectly
* safe.  However, when you execute it, you are doing so at
* your own risk -- please don't try to sue me if it malfunctions!
*
* With that said, here's what it's doing:
* Every time the Intuition library AutoRequest() function is
* called, FixReq replaces the Window pointer supplied to
* AutoRequest() with a pointer to the currently active window.
*
* The result: All of the "System Request" requesters will conveniently
* pop up right in front of you instead of bringing the WorkBench
* Screen to front and not putting it back.  I find it kinda handy... :-)
****************************************************************************

LibVersion          equ     31              ; 1.1 should work fine.
_LVOOpenLibrary     equ     -($228)
_LVOCloseLibrary    equ     -($19e)
_LVOAllocMem        equ     -($0c6)
_LVOSetFunction     equ     -($1a4)
_LVOAutoRequest     equ     -($15c)
ib_ActiveWindow     equ     52              ; from intuition/intuiBase.i

            lea     newreq(pc),a0
            lea     newreqEnd(pc),a1
            suba.l  a0,a1                   ; find size of newreq routine
            move.l  a1,_newreqSize          ; save for later

            move.l  $4,a6                   ; get execbase

            move.l  _newreqSize,d0          ; bytesize
            moveq   #0,d1                   ; requirements
            jsr     _LVOAllocMem(a6)
            move.l  d0,_newreqAddr          ; save address
            beq.s   error                   ; wow, you are **low** on RAM!

            lea     _IntuiName(pc),a1       ; need to get intuiBase
            move.l  #LibVersion,d0
            jsr     _LVOOpenLibrary(a6)
            move.l  d0,_IntuiBase           ; save intuibase for newreq
            beq.s   error                   ; ..huh? where's intuition???

            move.l  _IntuiBase,a0
            adda.l  #_LVOAutoRequest+2,a0   ; ptr to addr of prev. AutoReq
            move.l  (a0),_oldreq            ; save addr of previous AutoReq

            lea     newreq(pc),a0
            move.l  _newreqAddr,a1
            move.l  _newreqSize,d0
            subq.l  #1,d0
newreqCopy: move.b  (a0)+,(a1)+             ; copy the code
            dbf     d0,newreqCopy

            move.l  _IntuiBase,a1           ; library
            move.l  #_LVOAutoRequest,a0     ; funcOffset
            move.l  _newreqAddr,d0          ; funcEntry
            jsr     _LVOSetFunction(a6)

            moveq   #0,d0                   ; no errors
            rts                             ; exit without error

error:      moveq   #20,d0                  ; no RAM or no intuiBase
            rts                             ; exit with FAIL errorcode

newreq:     move.l  _IntuiBase(pc),a0
            move.l  ib_ActiveWindow(a0),a0  ; get addr of active window
            move.l  _oldreq(pc),-(sp)       ; push prev AutoReq addr
            rts                             ; and return to it
_IntuiBase: ds.l    1                       ; space for intuibase
_oldreq:    ds.l    1                       ; space for addr of oldreq
newreqEnd:                                  ; used to find newreq size

    CNOP    0,4

_newreqSize ds.l    1
_newreqAddr ds.l    1

    CNOP    0,4

_IntuiName  dc.b    'intuition.library',0,0

    END

================================End FixREq.asm==============================

================================FixReq.uue==================================
begin 777 FixReq
M```#\P`````````!```````````````N```#Z0```"Y!^@"$0_H`EI/((\D`8
M``"<+'@`!"`Y````G'(`3J[_.B/`````H&=:0_H`>B`\````'TZN_=@CP```*
M`)1G1"!Y````E-'\___^IB/0````F$'Z`#0B>0```*`@.0```)Q3@!+84<C_:
M_")Y````E"!\___^I"`Y````H$ZN_EQP`$YU<!1.=2!Z``P@:``T+SH`"$YU&
M`````````````````````&EN='5I=&EO;BYL:6)R87)Y```````#[`````H`_
M````````=@```&H```!<````5@```$P```!`````.````"(````6````#```:
&``````/RU
``
end
================================End FixReq.uue==============================

Enjoy,
Bill

--
Bill Kelly,     {ihnp4, hplabs!hp-sdd, sdcsvax}!crash!pnet01!billk
DevWare Inc.    (Don't use pnet01!billk; try crash!pnet01!billk -- Thanks!)

                Well, does your {atari, IBM, apple} do a 
 "SwapBitsRastBlitCopListClipLockRectFreeSetPrefsROMWackColdReset()" ???
                Neither does my Amiga.  But it *could*!!! :-)