home *** CD-ROM | disk | FTP | other *** search
- * moonmouse.asm Copyright 1987 by Scott Turner ALL RIGHTS RESERVED
- *
- * This program was inspired by Sunmouse 1.0 written by Scott Evernden.
- * However, Sunmouse was written in Aztec C. I dislike have fat and slothly C
- * code eat my precious ram. I like it even less when it's in a memory resident
- * program like Sunmouse. Also, Sunmouse required you to RUN it and then it
- * ate a CLI and TONS of extra ram on top of what the C code porked down.
- * Also, unlike Sunmouse, this program is NOT shareware. So you can use moonmouse
- * without developing a guilt complex. I'm disturbed by the trend of people to
- * slap "shareware" on everything "just in case". Especially on this genre of
- * "tiny" but useful programs.
- *
- * So, here I have written moonmouse. I call it moonmouse because it's like a
- * Surveyor moon launch, very little of the code below remains in ram. Most of it
- * is "staging" code to "land" the "payload" on the "moon". It is in many
- * respects like my DeciGEL program in that it runs and leaves some code behind
- * in a hunk of ram it allocates and then doesn't return.
- *
- * What this "payload" does is intercept events in the input stream. It does two
- * things depending on various other things. If the event is a raw mouse event
- * it sets a flag indicating that it has seen mouse activity. If the event is a
- * non-system raw key (ie doesn't have Left-Alt or Left-Amiga qualifiers) AND
- * the current front screen equals the workbench screen AND the mouse has "moved"
- * It inserts a Left mouse button down/Left mouse button up event sequence onto
- * the head of the event. This has the effect of pressing the left mouse button
- * for you to make sure that key codes go to the window the mouse is pointing
- * at. I kinda like it since I can just "elbow" the mouse to where I want to
- * send input and leave my fingers on the keyboard.
- *
- * Moonmouse is intended to be inserted into your s:Startup-Sequence file. It
- * should be placed as near the top as possible so that the "payload" doesn't
- * unduly fragment the heap. Once installed moonmouse can't be removed. But hey,
- * I said "Surveyor" not "Apollo" right? (grin) MoonMouse eats 172 bytes of ram.
- *
- * If you have questions/comments/requests concerning this source code, please
- * direct them in WRITING (no I don't mean via phone!) to:
- *
- * Scott Turner
- * L5 Computing
- * 12311 Maplewood Avenue
- * Edmonds, WA. 98020-1115
- *
- * I may also be reached via:
- *
- * JST on GEnie
- *
- * I am NOT releasing this source code into the public domain. However, I here
- * by grant a license for distribution via AmigaDOS format 3.5" diskette or via
- * an online telecommunications medium provided that the party charges less than
- * the following to do so:
- *
- * USA $10 for a copy on an AmigaDOS 3.5" disk.
- * USA $10 an hour for 1200 baud connection at 18:00 PST from Seattle, WA USA.
- *
- * I reserve all other rights. This source code is made available "AS IS" and I
- * make no warranties for it's fitness for any purpose.
- *
- *------------------------------------------------------------------------------
- *
- * I hate assembling 3,000 lines of include files. How about you?
- *
- * External EXEC references
- _Supervisor EQU -6*5
- _Forbid EQU -6*22
- _Permit EQU -6*23
- _AllocMem EQU -6*33
- _FindTask EQU -6*49
- _OpenLibrary EQU -6*68
- _CloseLibrary EQU -6*69
- _OpenDevice EQU -6*74
- _CloseDevice EQU -6*75
- _DOIO EQU -6*76
- *
- * External AmigaDOG references
- _Write EQU -6*8
- _Output EQU -6*10
- *
- * Startup code
- MOVE.L A7,D5
- LEA ThePayloadData(PC),A4
- MOVEA.L 4,A6
- *
- * Call the "dog"
- MOVEQ #0,D0
- LEA DogName(PC),A1
- JSR _OpenLibrary(A6)
- MOVEA.L D0,A5
- TST.L D0
- BEQ.S FireNeutronBomb
- *
- * Open intuition
- MOVEQ #0,D0
- LEA IntuiName(PC),A1
- JSR _OpenLibrary(A6)
- MOVE.L D0,IntuiBase(A4)
- TST.L D0
- BNE.S LibrariesOpen
- *
- * We arrive here because the system is in a phrase "royally fucked". Since the
- * Amiga is not prone to this, some menacing outside influence must have caused
- * it. Fight back by dropping a "Neutron bomb" on the rascals.
- FireNeutronBomb LEA TheBomb(PC),A5
- JSR _Supervisor(A6)
- DC.W $4AFC
-
- TheBomb MOVE.L #'HELP',0 ; Kiss off Ctrl-Amiga-Amiga
- ADDQ.L #1,A7 ; The ONE hole in the 680X0's protection...
- RTE
-
- *
- * Grab our screen's pointer from intuition.base
- LibrariesOpen MOVEA.L D0,A0
- MOVE.L 60(A0),MyScreen(A4)
- *
- * Allocate ram for payload.
- MOVE.L #$10001,D1
- MOVE.L #PayloadSize,D0
- JSR _AllocMem(A6)
- TST.L D0
- BEQ.S MissedMoon
- MOVEA.L D0,A3
- *
- * Copy payload to this hunk of ram
- MOVEQ #PayloadSize/4-1,D0
- MOVEA.L A3,A1
- LEA ThePayload(PC),A0
- 0$ MOVE.L (A0)+,(A1)+
- DBF D0,0$
- *
- * Init the port to use to access the input.device
- SUBA.L A1,A1
- JSR _FindTask(A6)
- LEA InputPort(PC),A2
- MOVE.L D0,16(A2)
- *
- * Open the input device
- MOVEQ #0,D1
- MOVEQ #0,D0
- LEA InputIOReq(PC),A1
- LEA InputName(PC),A0
- JSR _OpenDevice(A6)
- TST.L D0
- BNE.S MissedMoon
- *
- * Add payload to input stream
- LEA InputIOReq(PC),A1
- LEA PayloadData(A3),A0
- LEA InputIRQ(A0),A2
- MOVE.L A0,14(A2) ; Init IRQ data pointer
- MOVE.L A3,18(A2) ; Init IRQ code pointer
- MOVE.L A2,40(A1) ; Pointer to Payload's IRQ
- MOVE.W #9,28(A1)
- JSR _DOIO(A6)
- LEA Logo(PC),A0
- TST.L D0
- BEQ.S Exit
- MissedMoon LEA Ooops(PC),A0
-
- Exit MOVEA.L A0,A2
- MOVE.L A0,D3
- 0$ TST.B (A0)+
- BNE.S 0$
- SUBA.L D3,A0
- MOVE.L A0,D3
- SUBQ.L #1,D3 ;Length
- MOVE.L A2,D2 ;Buffer
- JSR _Output(A5)
- MOVE.L D0,D1 ;FileHandle
- JSR _Write(A5)
-
- MOVEA.L A5,A1
- JSR _CloseLibrary(A6)
- *
- * Intuition is left open since the payload "uses" it.
- LEA InputIOReq(PC),A1
- JSR _CloseDevice(A6)
- MOVEQ #0,D0
- MOVEA.L D5,A7
- RTS
-
- *
- * Payload, this is the handler routine that all of the above code installs
- PayloadStart
- ThePayload MOVEM.L D1/A0-A2/A4/A6,-(A7)
- *
- * Setup registers
- MOVEA.L A0,A2
- MOVEA.L A1,A4
- *
- * Is this a RawMouse event?
- CMPI.B #2,4(A2)
- BNE.S 0$
- *
- * Record we saw the mouse move
- ST (A4)
- BRA.S 1$
- *
- * Non-mouse event
- *
- * Has the mouse moved since last time through?
- 0$ TST.W (A4)
- BEQ.S 1$
- *
- * Is this a raw key code?
- CMPI.B #1,4(A2)
- BNE.S 1$
- *
- * Must be a key DOWN code
- TST.B 7(A2)
- BMI.S 1$
- *
- * Is the front screen my screen?
- MOVEA.L IntuiBase(A4),A0
- MOVEA.L 60(A0),A1
- CMPA.L MyScreen(A4),A1 ; Correct screen?
- BNE.S 1$
- *
- * This is a key down event, is it a non-system key?
- MOVEQ #$50,D0
- AND.W 8(A2),D0
- BNE.S 1$
- *
- * This key be for US. Lock out pesky task switcher.
- MOVEA.L 4,A6
- JSR _Forbid(A6)
- LEA MouseUp(A4),A1
- LEA MouseDown(A4),A0
- EXG A0,A2
- MOVE.L A0,(A1) ; Tack event after mouse up event
- MOVE.L A1,(A2) ; Tack mouse up after mouse down
- ; Return mouse down as the first event, clever eh?
- SF (A4)
- JSR _Permit(A6)
- 1$ MOVE.L A2,D0
- MOVEM.L (A7)+,D1/A0-A2/A4/A6
- RTS
-
- ThePayloadData
- PayloadData EQU *-PayloadStart
- DC.W 0 ; Mouse moved variable
- IntuiBase EQU *-ThePayloadData
- DC.L 0 ; Intuition base
- MyScreen EQU *-ThePayloadData
- DC.L 0 ; MyScreen pointer
- MouseDown EQU *-ThePayloadData
- ; Mouse down event
- DC.L 0,$02000068
- DC.W $C000
- DC.L 0,0,0
- MouseUp EQU *-ThePayloadData
- ; Mouse up event
- DC.L 0,$020000E8
- DC.W $8000
- DC.L 0,0,0
- InputIRQ EQU *-ThePayloadData
- ; input.device IRQ
- DC.L 0,0
- DC.W $0233
- DC.L 0
- DC.L 0 ; Data
- DC.L 0 ; Code
- PayloadEnd
- PayloadSize EQU PayloadEnd-PayloadStart
-
- DogName DC.B 'dos.library',0
- IntuiName DC.B 'intuition.library',0
- InputName DC.B 'input.device',0
- Logo DC.B 'MoonMouse 0.1 installed. Copyright 1987 Scott Turner'
- DC.B 10,0
- Ooops DC.B 'Ooops, MoonMouse missed the moon, sorry.',10,0
- DS.W 0
-
- InputPort DC.L 0 ;0
- DC.L 0 ;4
- DC.W $0400 ;8
- DC.L 0 ;10
- DC.B 0 ;14
- DC.B 31 ;15
- DC.L 0 ;16 Task addr goes here
- LH1 DC.L LH2 ;20
- LH2 DC.L 0 ;24
- DC.L LH1 ;28
- DC.B 0 ;32
- DC.B 0 ;33
- InputIOReq DC.L 0 ;0
- DC.L 0 ;4
- DC.B 5 ;8
- DC.B 0 ;9
- DC.L 0 ;10
- DC.L InputPort ;14
- DC.W 48 ;18
- DC.L 0 ;20
- DC.L 0 ;24
- DC.W 9 ;28
- DC.W 0 ;30
- DC.L 0 ;32
- DC.L 0 ;36
- DC.L 0 ;40 IO_DATA
- DC.L 0 ;44
-
- END
-