An even better TaskWindow

 

Following the aforementioned TaskWindow speed-ups, Chris Manning decided to go one better and implement a variable poll-rate method.

Please note that this code is for, I think, the TaskWindow module part of RISC OS 4. It does not work here, with RISC OS 3.70. I suspect the offset is wrong but I've not looked into it. A crashed TaskWindow needs lots of TaskKilling (five or six times, twice), so be sure you have a task killer module ready...
For those of you with the correct TaskWindow module, Chris is using it on his system and it seems quite happy.

 

The changes to the TaskWindow module are:

Change:
   00000320 : 03A03034 : MOVEQ   R3,#&34
   00000330 : 7A000896 : BVC     &00002590

Change:
   0000141C : E59B0004 : LDR     R0,[R11,#4]
   00001420 : E590302C : LDR     R3,[R0,#&02C]
   00001424 : EB00045E : BL      &000025A4

Add:
   00002590 : E3A0E00F : MOV     R14,#&0F
   00002594 : E58CE02C : STR     R14,[R12,#&02C]
   00002598 : E58CE030 : STR     R14,[R12,#&030]
   0000259C : E3A0E000 : MOV     R14,#0
   000025A0 : EAFFF763 : B       &00000334

Add:
   000025A4 : E2533001 : SUBS    R3,R3,#1
   000025A8 : 05903030 : LDREQ   R3,[R0,#&030]
   000025AC : E580302C : STR     R3,[R0,#&02C]
   000025B0 : E3A00000 : MOV     R0,#0
   000025B4 : E3A03000 : MOV     R3,#0
   000025B8 : 11A0F00E : MOVNE   PC,R14
   000025BC : EAFFFDC8 : B       &00001CE4

 

This is backed up by the following code. It creates a file (in WimpScrap) which can be used to view or set the TaskWindow polling rate. The default rate is 15.

   REM >Source:Util.TaskWindowPollRate
   ON ERROR ON ERROR OFF: PROCerror: END
   buf_size%=4096
   DIM buf% buf_size%-1
   :
   name$="TaskWindowPollRate"
   filename$=name$
   :
   bufsize%=256
   mininterval%=1
   maxinterval%=255
   defaultinterval%=15
   :
   FlagF%=1<<26
   FlagI%=1<<27
   FlagV%=1<<28
   FlagC%=1<<29
   FlagZ%=1<<30
   FlagN%=1<<31
   :
   L%=buf%+buf_size%
   FOR opt%=12 TO 15 STEP 3
     P%=0
     O%=buf%
     [           OPT      opt%
                 ;
                 ;        r0   ->  command line
                 ;        r1   ->  command tail
                 ;        r12  ->  workspace (1kB)
                 ;        r13  ->  stack
                 ;
                 STMFD    r13!,{r14}
                 LDRB     r0,[r1]              ; First character of parameter
                 CMP      r0,#ASC(" ")         ; No param means the current
                 MVNLE    r6,#0                ;  value is to be displayed
                 BLE      _findmodule%
                 TEQ      r0,#ASC("*")         ; An asterisk means the
                 MOVEQ    r6,#defaultinterval% ;  default value is to be used
                 BEQ      _findmodule%
                 MOV      r0,r1                ; -> parameter
                 MOV      r1,r12               ; -> buffer
                 MOV      r2,#bufsize%         ; Length of buffer
                 SWI      "XOS_GSTrans"
                 LDMVSFD  r13!,{pc}
                 MOV      r0,r12               ; -> Translated string
                 MOV      r1,#0                ; Return result in r2
                 SWI      "XOS_EvaluateExpression"
                 LDMVSFD  r13!,{pc}
                 CMP      r2,#mininterval%     ; Check number is in range
                 BLT      _toosmall%
                 CMP      r2,#maxinterval%
                 BGT      _toobig%
                 MOV      r6,r2                ; r6 == poll interval
   ;
   ;
       ._findmodule%
                 MOV      r0,#18               ; Extract module info
                 ADR      r1,_taskwindow%
                 SWI      "XOS_Module"
                 LDMVSFD  r13!,{pc}
   ;
                 LDR      r0,[r4,#-4]          ; Size of work area
                 CMP      r0,#48               ; Patched TaskWindow has
                 LDMLEFD  r13!,{pc}            ;  larger workarea
                 CMP      r6,#0                ; -ve interval means 'display'
                 STRPL    r6,[r4,#44]          ; Remainder of this interval
                 STRPL    r6,[r4,#48]          ; New interval
                 LDMPLFD  r13!,{pc}^
   ;
                 LDR      r0,[r4,#48]          ; Active poll interval
                 ADR      r1,_currentnum%
                 MOV      r2,#_currentnumL%
                 SWI      "XOS_ConvertCardinal4"   ; Convert to a string
                 LDMVSFD  r13!,{pc}
                 ADR      r0,_current%
                 SWI      "XOS_Write0"         ; Display value
                 SWIVC    "XOS_NewLine"
                 LDMFD    r13!,{pc}
   ;
   ;
       ._compare%
                 LDRB     r7,[r3],#1           ; Byte from first string
                 LDRB     r8,[r5],#1           ; Byte from second string
                 TEQ      r7,r8                ; Compare bytes
                 MOVNE    pc,r14               ; Return NE if different
                 TEQ      r7,#0                ; Check for end
                 BNE      _compare%            ; Look at next byte
                 MOV      pc,r14               ; Return EQ if identical
   ;
       ._toosmall%
                 ADR      r0,_smallerror%      ; -> Error block
                 B        _toobig0%
       ._toobig%
                 ADR      r0,_bigerror%        ; -> Error block
       ._toobig0%
                 LDMFD    r13!,{r14}           ; Return address
                 ORRS     pc,r14,#FlagV%       ; Set V flag and return
       ._smallerror%
                 EQUD     &16C
                 EQUS     "Number too small"+CHR$(0)
                 ALIGN
       ._bigerror%
                 EQUD     &16C
                 EQUS     "Number too big"+CHR$(0)
       ._taskwindow%
                 EQUS     "TaskWindow"+CHR$(0)
       ._current%
                 EQUS     "Current poll rate is "
       ._currentnum%
                 EQUS     STRING$(10,"*")+CHR$(0)
       FNEqu("_currentnumL%","P%-_currentnum%")
     ]
   NEXT opt%
   OSCLI("Save <Wimp$ScrapDir>."+filename$+" "+STR$~(buf%)+" +"+STR$~(P%))
   OSCLI("SetType <Wimp$ScrapDir>."+filename$+" Utility")
   END
   :
   DEF PROCerror
     REPORT
     IF ERR<>17 PRINT " at line "; ERL ", location counter=&"; ~P%
   ENDPROC
   :
   :
   DEF FNEqu(variable$, value$)
   =EVAL("FNMakeVar("+variable$+","+value$+")")
   :
   :
   DEF FNMakeVar(RETURN var%, value%)
   var%=value%
   =0

Return to assembler index
Copyright © 2004 Richard Murray, code by Chris Manning 2002