From: banksie@khantazi.welly.gen.nz (Philip R. Banks)
Newsgroups: comp.sys.acorn.tech
Subject: I got the EventV Blues.
Keywords: EventV Problem HELP!
Date: Sat, 1 Aug 1992 00:05:27 +1200
Reply-To: banks_p@kosmos.wcc.govt.nz
Organization: My Arc.

   I have an interesting problem with some event code I am working on. The
problem is not so much that the code doesn't work at all but that it works
under certain circumstances. You see I have some code designed to catch key
and mouse events and do some processing of them. As the processing is a
little complex I have to use a CallBack to do it.

   Now the code works when the machine is not *loaded* heavily. By this I
mean I am not running a FS intensive/TaskWindow task. When the machine is
heavily loaded (behavior exhibted on an A3000 and an A5000) mouse clicks get
sluggish and sometimes are lost. The general effect is as if the mouse
interupt code has been slowen down to about three quarters normal speed.
Mouse double clicks are, when done at normal speed, quite often interpreted
as single clicks. Drags persist for longer than they should and generally
recognition of mouse events is slow.

   The code attaches itself to the EventV vector and is part of a module. As
far as I can see all registers are safely preserved and I have minimised the
work needed outside the callback, in the interupt code itself. The really
strange thing about it is that keypress activity is completely unaffected.
Can anyone see what I am doing that could be causing this problem? Or have I
hit a hardware/software limitation? (Seems strange given that the code
itself is fairly trivial.)

NB When run under RO2 IRQUtils 0.12 is loaded so CallBacks are functioning
fine.

---Code fragment begins---
.EventV
        STMFD   R13!,{R0-R5,R14}
        MOV     R5,PC           ; Store current settings/processor mode
        ORR     R4,R5,#3
        TEQP    R4,#0           ; Enter SVC mode
        MOV     R0,R0           ; NOP for contention purposes
        STMFD   R13!,{R14}      ; Stack SVC mode link register
.Event_mouse
        TEQ     R0,#10           ; Is it a mouse event?
        BNE     Event_key
        TST     R3,#%111
        BEQ     EventV_exit     ; Check for invalid mouse codes.
        FNmvi(0,mouse_bl%,"")
        TST     R3,#4            ; Select?
        MOVNE   R1,R0
        TST     R3,#2            ; Menu?
        ADDNE   R1,R0,#blocksize%
        TST     R3,#1            ; Adjust?
        ADDNE   R1,R0,#blocksize%*2
        ADR     R0,Event_callback
        SWI     "XOS_AddCallBack"; Set up a callback to process event.
        B       EventV_exit      ; Exit if no button was pressed
.Event_key
        TEQ     R0,#11           ; Is it a key event?
        BNE     EventV_exit      ; So is it a mouse event?
        TEQ     R1,#1            ; Is it a key DOWN event?
        BNE     EventV_exit      ; Exit if no key was pressed
        CMP     R2,#&67
        BHI     EventV_exit      ; Exit if an invalid key code is given
        FNmvi(0,key_bl%,"")
        MOV     R3,#blocksize%
        MUL     R1,R2,R3
        ADD     R1,R0,R1
        ADR     R0,Event_callback
        SWI     "XOS_AddCallBack"; Set up a callback to process event.
.EventV_exit
        LDMFD   R13!,{R14}      ; Restore SVC mode link register
        TEQP    R5,#0           ; Return to original mode
        MOV     R0,R0           ; NOP for contention
        LDMFD   R13!,{R0-R5,R14}; Restore Registers
        MOVS    PC,R14          ; Pass on the call.
---Code fragment ends---

    Philip

--
Philip R. Banks  Syntax: mail < banks_p@kosmos.wcc.govt.nz >            @@@@@/|
                                                                        @@@@/#|
                                                                        @@@/##|
I breathe the air, While they're running in a rat race,                 @@/---|
Way above it all, Standing on higher ground. ---A.P.P.                  @/    |