SWIS 29.9 KB
Newer Older
Neil Turton's avatar
Neil Turton committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
; Copyright 1996 Acorn Computers Ltd
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
; You may obtain a copy of the License at
;
;     http://www.apache.org/licenses/LICENSE-2.0
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
;
; s.SWIS

Filter_SWIdecode
        Push    "LR"
Robert Sprowson's avatar
Robert Sprowson committed
19
        LDR     wp,[R12]                        ; wsptr --> workspace
Neil Turton's avatar
Neil Turton committed
20 21 22 23 24 25 26 27 28

        Debug   xx,"SWI ",r11

        CMP     R11,#maxnewswi
        ADDCC   R14,R11,#(swijptable-swijporg-4)/4    ; bodge factor
        ADDCC   PC,PC,R14,ASL #2                ; go!
swijporg
        Push    "R4"
        ADR     R0,ErrorBlock_BadSWI
Kevin Bracey's avatar
Kevin Bracey committed
29
        ADRL    R4,Title
Neil Turton's avatar
Neil Turton committed
30 31 32 33 34 35 36 37
        BL      MsgTrans_ErrorLookup
        Pull    "R4,PC"

swijptable
        B       SWIFilter_RegisterPreFilter
        B       SWIFilter_RegisterPostFilter
        B       SWIFilter_DeRegisterPreFilter
        B       SWIFilter_DeRegisterPostFilter
Kevin Bracey's avatar
Kevin Bracey committed
38 39 40 41 42 43 44 45
        B       SWIFilter_RegisterRectFilter
        B       SWIFilter_DeRegisterRectFilter
	B	SWIFilter_RegisterCopyFilter
	B	SWIFilter_DeRegisterCopyFilter
	B	SWIFilter_RegisterPostRectFilter
	B	SWIFilter_DeRegisterPostRectFilter
	B	SWIFilter_RegisterPostIconFilter
	B	SWIFilter_DeRegisterPostIconFilter
Neil Turton's avatar
Neil Turton committed
46 47 48 49 50 51 52 53 54 55 56 57 58 59
endswijptable
maxnewswi   *   (endswijptable-swijptable)/4

ErrorBlock_BadSWI
        DCD     0
        DCB     "BadSWI", 0
        ALIGN

Filter_SWInames
        DCB     "Filter",0                ; prefix
        DCB     "RegisterPreFilter",0
        DCB     "RegisterPostFilter",0
        DCB     "DeRegisterPreFilter",0
        DCB     "DeRegisterPostFilter",0
Kevin Bracey's avatar
Kevin Bracey committed
60 61 62 63 64 65 66 67
        DCB     "RegisterRectFilter",0
        DCB     "DeRegisterRectFilter",0
	DCB	"RegisterCopyFilter",0
	DCB	"DeRegisterCopyFilter",0
	DCB	"RegisterPostRectFilter",0
	DCB	"DeRegisterPostRectFilter",0
	DCB	"RegisterPostIconFilter",0
	DCB	"DeRegisterPostIconFilter",0
Neil Turton's avatar
Neil Turton committed
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
        DCB     0
        ALIGN

;;--------------------------------------------------------------------------
;; Filter_RegisterPreFilter
;;
;; Add a new pre filter to the list of pre filters.
;;
;; Entry:
;;        R0 - Pointer to 0 terminated filter name.
;;        R1 - Addresss of filter.
;;        R2 - Value to be passed in R12.
;;        R3 - Task handle of task to which filter is applied.
;;
;; Exit:
;;        Registers preserved.
;;
;;

SWIFilter_RegisterPreFilter

89
        Push    "r0-r3"
Neil Turton's avatar
Neil Turton committed
90 91 92 93 94 95 96 97 98 99 100 101 102 103

        DebugS  register,"Register pre-filter",R0,80
        Debug   register,"Name, address, ws, task",R0,R1,R2,R3

; Claim block to put data in.

        MOV     r0, #ModHandReason_Claim
        MOV     r3, #f_block_size
        SWI     XOS_Module

        DebugE  register,"pre-filter claim failed "

        ADDVS   sp,sp,#4
        Pull    "r1-r3,LR",VS
Stewart Brodie's avatar
Stewart Brodie committed
104
        RETURNVS VS                 ; Restore callers flags, and set V
Neil Turton's avatar
Neil Turton committed
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137

; Link block ^r2 to list.

        LDR     r14,pre_filters
        STR     r14,[r2,#next_ptr]  ; Point at next block
        CMP     r14,#0
        STRNE   r2,[r14,#prev_ptr]  ; Make next block point at the new block.
        MOV     R14,#0
        STR     R14,[r2,#prev_ptr]  ; This is the first block in the list
        STR     r2,pre_filters

        STR     R14,[r2,#f_mask]    ; Mask is not used for pre_filters.
        BLEQ    RegisterFilters     ; Register with wimp if this is first filter

        DebugE  register,"Cant register filters "

        BVS     %FT10               ; Jump if no wimp

        LDR     R14,[sp,#0*4]
        STR     R14,[r2,#f_name]    ; name of filter
        LDR     R14,[sp,#1*4]
        STR     R14,[r2,#f_address] ; address of filter
        LDR     R14,[sp,#2*4]
        STR     R14,[r2,#f_R12]     ; R12 for calling filter.
        LDR     R14,[sp,#3*4]
        MOV     R14,R14,ASL #16
        MOV     R14,R14,LSR #16
        STR     R14,[r2,#f_task]    ; Task ID.

        Debug   register,"Pre-filter registered ok"

; Exit to caller                    ; Preserves caller's flags.

138 139
        Pull    "r0-r3,LR"          ; V will be clear
        RETURNVC
Neil Turton's avatar
Neil Turton committed
140 141 142 143 144 145 146 147 148 149

; Error exit, freeing claimed block

10      STR     R0,[sp,#0*4]        ; Return error ptr
        LDR     R2,pre_filters
        MOV     R0,#0
        STR     R0,pre_filters
        MOV     R0,#ModHandReason_Free ; Free the block if error
        SWI     XOS_Module
        Pull    "r0-r3,LR"
Stewart Brodie's avatar
Stewart Brodie committed
150
        RETURNVS                    ; Restore callers flags, and set V
Neil Turton's avatar
Neil Turton committed
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171


;;--------------------------------------------------------------------------
;; Filter_RegisterPostFilter
;;
;; Add a new post filter to the list of post filters.
;;
;; Entry:
;;        R0 - Pointer to 0 terminated filter name.
;;        R1 - Addresss of filter.
;;        R2 - Value to be passed in R12.
;;        R3 - Task handle of task to which filter is applied.
;;        R4 - Event mask ( 1 bit masks the event out ).
;;
;; Exit:
;;        Registers preserved.
;;
;;

SWIFilter_RegisterPostFilter

172
        Push    "r0-r4"
Neil Turton's avatar
Neil Turton committed
173 174 175 176 177 178 179 180 181 182 183 184 185 186

        DebugS  register,"Register post-filter",R0,80
        Debug   register,"Name, address, ws, task",R0,R1,R2,R3

; Claim block to put data in.

        MOV     r0, #ModHandReason_Claim
        MOV     r3, #f_block_size
        SWI     XOS_Module

        DebugE  register,"post-filter claim failed "

        ADDVS   sp,sp,#4
        Pull    "r1-r4,LR",VS
Stewart Brodie's avatar
Stewart Brodie committed
187
        RETURNVS VS
Neil Turton's avatar
Neil Turton committed
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223

; Link block ^r2 to list.

        LDR     r14,post_filters

        Debug   register,"Post-filter anchor",r14

        STR     r14,[r2,#next_ptr]  ; Point at next block
        CMP     r14,#0
        STRNE   r2,[r14,#prev_ptr]  ; Make next block point at the new block.
        MOV     R14,#0
        STR     R14,[r2,#prev_ptr]  ; This is the first block in the list
        STR     r2,post_filters
        BLEQ    RegisterFilters     ; Register with wimp if this is first filter

        DebugE  register,"Cant register post-filter "

        BVS     %FT10               ; Jump if no wimp

        LDR     R14,[sp,#0*4]
        STR     R14,[r2,#f_name]    ; name of filter
        LDR     R14,[sp,#1*4]
        STR     R14,[r2,#f_address] ; address of filter
        LDR     R14,[sp,#2*4]
        STR     R14,[r2,#f_R12]     ; R12 for calling filter.
        LDR     R14,[sp,#3*4]
        MOV     R14,R14,ASL #16
        MOV     R14,R14,LSR #16
        STR     R14,[r2,#f_task]    ; Task ID.
        LDR     R14,[sp,#4*4]
        STR     R14,[r2,#f_mask]    ; Event mask.

        Debug   register,"Post-filter registered ok"

; Exit to caller                    ; Preserves caller's flags.

224 225
        Pull    "r0-r4,LR"          ; V will be clear
        RETURNVC
Neil Turton's avatar
Neil Turton committed
226 227 228 229 230 231 232 233 234 235

; Error exit

10      STR     R0,[sp,#0*4]        ; Return error ptr
        LDR     R2,post_filters
        MOV     R0,#0
        STR     R0,post_filters
        MOV     R0,#ModHandReason_Free ; Free the block if error
        SWI     XOS_Module
        Pull    "r0-r4,LR"
Stewart Brodie's avatar
Stewart Brodie committed
236
        RETURNVS
Neil Turton's avatar
Neil Turton committed
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272


;;-------------------------------------------------------------------------
;; find_filter
;;
;; Entry:
;;
;;        R0 - Pointer to name.
;;        R1 - Address
;;        R2 - R12 value
;;        R3 - Task handle
;;        R4 - Pointer to list head.
;; Exit:
;;        If found:
;;                  VC , R4-> filter block.
;;        If not found VS
;;
find_filter

        Push    "LR"

01
        LDR     r4,[r4,#next_ptr]
        CMP     r4,#0
        SETV    EQ
        Pull    "PC",VS            ; Not found.
        LDR     r14,[r4,#f_name]
        TEQ     r14,r0
        BNE     %BT01
        LDR     r14,[r4,#f_address]
        TEQ     r14,r1
        BNE     %BT01
        LDR     r14,[r4,#f_R12]
        TEQ     r14,r2
        BNE     %BT01
        LDR     r14,[r4,#f_task]
273
        BIC     r14,r14,#f_task_quit
Neil Turton's avatar
Neil Turton committed
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300
        TEQ     r14,r3
        CMPNE   r14,#0
        BNE     %BT01

; All are equal - found wanted filter.

        Pull    "PC"

;;--------------------------------------------------------------------------
;; Filter_DeRegisterPreFilter
;;
;; Remove a pre filter from the list of pre filters.
;;
;; Entry:
;;        R0 - Pointer to 0 terminated filter name.
;;        R1 - Addresss of filter.
;;        R2 - Value to be passed in R12.
;;        R3 - Task handle of task to which filter was applied.
;;
;;        All must be the same as those passed to RegisterPreFilter
;; Exit:
;;        Registers preserved.
;;
;;

SWIFilter_DeRegisterPreFilter

301
        Push    "r0-r4"
Neil Turton's avatar
Neil Turton committed
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316

        DebugS  register,"De-register pre-filter",R0,80
        Debug   register,"Name, address, ws, task",R0,R1,R2,R3

        ADR     r4,pre_filters
        MOV     R3,R3,ASL #16
        MOV     R3,R3,LSR #16   ; Task ID
        BL      find_filter     ; Finds the filter in the list

        DebugE  register,"Cant find pre-filter "

        ADDVS   sp,sp,#4
        ADRVS   r0,ErrorBlock_UnknownFilter
        BLVS    MsgTrans_ErrorLookup
        Pull    "r1-r4,LR",VS
Stewart Brodie's avatar
Stewart Brodie committed
317
        RETURNVS VS
Neil Turton's avatar
Neil Turton committed
318 319 320 321 322 323 324 325 326 327 328 329 330

; Found filter, remove it from list.

        LDR     r14,[r4,#next_ptr]
        LDR     r0, [r4,#prev_ptr]
        CMP     r0,#0
        STREQ   r14,pre_filters      ; Next block is now first on the list
        STRNE   r14,[r0,#next_ptr]   ; Or is next of previous block.
        CMP     R14,#0
        STRNE   r0,[R14,#prev_ptr]   ; If there is a next block update its prev_ptr.

        LDR     r14,pre_filters
        CMP     r14,#0               ; Any filters left?
Kevin Bracey's avatar
Kevin Bracey committed
331
        MOVEQ   r0,#WimpFilter_PrePoll
Neil Turton's avatar
Neil Turton committed
332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351
        MOVEQ   r1,#0                ;  No then de-register
 [ debugregister
        BNE     %FT00
        Debug   register,"Deregistering pre-filter",r0,r1
00
 ]
        SWIEQ   XWimp_RegisterFilter ; Remove filters for speed

        DebugE  register,"Cant de-register pre-filter "

        MOV     R0,#ModHandReason_Free ; Now free the block.
        MOV     R2,R4
        SWI     XOS_Module

        DebugE  register,"Cant free pre-filter block "

        Pull    "r0-r4,PC",VC

        ADD     sp,sp,#4                ; Drop caller's R0
        Pull    "r1-r4,LR"
Stewart Brodie's avatar
Stewart Brodie committed
352
        RETURNVS
Neil Turton's avatar
Neil Turton committed
353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372

;;--------------------------------------------------------------------------
;; Filter_DeRegisterPostFilter
;;
;; Remove a pre filter from the list of pre filters.
;;
;; Entry:
;;        R0 - Pointer to 0 terminated filter name.
;;        R1 - Addresss of filter.
;;        R2 - Value to be passed in R12.
;;        R3 - Task handle of task to which filter was applied.
;;
;;        All must be the same as those passed to RegisterPreFilter
;; Exit:
;;        Registers preserved.
;;
;;

SWIFilter_DeRegisterPostFilter

373
        Push    "r0-r4"
Neil Turton's avatar
Neil Turton committed
374 375 376 377 378 379 380 381 382 383 384 385 386 387 388

        DebugS  register,"De-register post-filter",R0,80
        Debug   register,"Name, address, ws, task",R0,R1,R2,R3

        ADR     r4,post_filters
        MOV     R3,R3,ASL #16
        MOV     R3,R3,LSR #16   ; Task ID
        BL      find_filter     ; Finds the filter in the list

        DebugE  register,"Cant find post-filter "

        ADRVS   r0,ErrorBlock_UnknownFilter
        BLVS    MsgTrans_ErrorLookup
        ADDVS   sp,sp,#4
        Pull    "r1-r4,LR",VS
Stewart Brodie's avatar
Stewart Brodie committed
389
        RETURNVS VS
Neil Turton's avatar
Neil Turton committed
390 391 392 393 394 395 396 397 398 399 400 401 402

; Found filter, remove it from list.

        LDR     r14,[r4,#next_ptr]
        LDR     r0, [r4,#prev_ptr]
        CMP     r0,#0
        STREQ   r14,post_filters     ; Next block is now first on the list
        STRNE   r14,[r0,#next_ptr]   ; Or is next of previous block.
        CMP     R14,#0
        STRNE   r0,[R14,#prev_ptr]   ; If there is a next block update its prev_ptr.

        LDR     r14,post_filters
        CMP     r14,#0               ; Any filters left?
Kevin Bracey's avatar
Kevin Bracey committed
403
        MOVEQ   r0,#WimpFilter_PostPoll
Neil Turton's avatar
Neil Turton committed
404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423
        MOVEQ   r1,#0                ;  No then de-register
 [ debugregister
        BNE     %FT00
        Debug   register,"Deregistering post-filter",r0,r1
00
 ]
        SWIEQ   XWimp_RegisterFilter ; Remove filters for speed

        DebugE  register,"Cant de-register post-filter "

        MOV     R0,#ModHandReason_Free ; Now free the block.
        MOV     R2,R4
        SWI     XOS_Module

        DebugE  register,"Cant free post-filter block "

        Pull    "r0-r4,PC",VC

        ADD     sp,sp,#4                ; Drop caller's R0
        Pull    "r1-r4,LR"
Stewart Brodie's avatar
Stewart Brodie committed
424
        RETURNVS
Neil Turton's avatar
Neil Turton committed
425

Kevin Bracey's avatar
Kevin Bracey committed
426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443
;;--------------------------------------------------------------------------
;; Filter_RegisterRectFilter
;;
;; Add a new rect filter to the list of rect filters.
;;
;; Entry:
;;        R0 - Pointer to 0 terminated filter name.
;;        R1 - Addresss of filter.
;;        R2 - Value to be passed in R12.
;;        R3 - Task handle of task to which filter is applied.
;;
;; Exit:
;;        Registers preserved.
;;
;;

SWIFilter_RegisterRectFilter

444
        Push    "r0-r3"
Kevin Bracey's avatar
Kevin Bracey committed
445 446 447 448 449 450 451 452 453 454 455 456 457 458

        DebugS  register,"Register rect-filter",R0,80
        Debug   register,"Name, address, ws, task",R0,R1,R2,R3

; Claim block to put data in.

        MOV     r0, #ModHandReason_Claim
        MOV     r3, #f_block_size
        SWI     XOS_Module

        DebugE  register,"rect-filter claim failed "

        ADDVS   sp,sp,#4
        Pull    "r1-r3,LR",VS
Stewart Brodie's avatar
Stewart Brodie committed
459
        RETURNVS VS
Kevin Bracey's avatar
Kevin Bracey committed
460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492

; Link block ^r2 to list.

        LDR     r14,rect_filters
        STR     r14,[r2,#next_ptr]  ; Point at next block
        CMP     r14,#0
        STRNE   r2,[r14,#prev_ptr]  ; Make next block point at the new block.
        MOV     R14,#0
        STR     R14,[r2,#prev_ptr]  ; This is the first block in the list
        STR     r2,rect_filters

        STR     R14,[r2,#f_mask]    ; Mask is not used for rect_filters.
        BLEQ    RegisterFilters     ; Register with wimp if this is first filter

        DebugE  register,"Cant register filters "

        BVS     %FT10               ; Jump if no wimp

        LDR     R14,[sp,#0*4]
        STR     R14,[r2,#f_name]    ; name of filter
        LDR     R14,[sp,#1*4]
        STR     R14,[r2,#f_address] ; address of filter
        LDR     R14,[sp,#2*4]
        STR     R14,[r2,#f_R12]     ; R12 for calling filter.
        LDR     R14,[sp,#3*4]
        MOV     R14,R14,ASL #16
        MOV     R14,R14,LSR #16
        STR     R14,[r2,#f_task]    ; Task ID.

        Debug   register,"rect-filter registered ok"

; Exit to caller                    ; Preserves caller's flags.

493 494
        Pull    "r0-r3,LR"          ; V will be clear
        RETURNVC
Kevin Bracey's avatar
Kevin Bracey committed
495 496 497 498 499 500 501 502 503 504

; Error exit, freeing claimed block

10      STR     R0,[sp,#0*4]        ; Return error ptr
        LDR     R2,rect_filters
        MOV     R0,#0
        STR     R0,rect_filters
        MOV     R0,#ModHandReason_Free ; Free the block if error
        SWI     XOS_Module
        Pull    "r0-r3,LR"
Stewart Brodie's avatar
Stewart Brodie committed
505
        RETURNVS
Kevin Bracey's avatar
Kevin Bracey committed
506

507 508 509 510 511
ErrorBlock_UnknownFilter
        DCD    0
        DCB    "UnkF",0
        ALIGN

Kevin Bracey's avatar
Kevin Bracey committed
512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528
;;--------------------------------------------------------------------------
;; Filter_RegisterCopyFilter
;;
;; Add a new rect filter to the list of rect filters.
;;
;; Entry:
;;        R0 - Pointer to 0 terminated filter name.
;;        R1 - Addresss of filter.
;;        R2 - Value to be passed in R12.
;;
;; Exit:
;;        Registers preserved.
;;
;;

SWIFilter_RegisterCopyFilter

529
        Push    "r0-r3"
Kevin Bracey's avatar
Kevin Bracey committed
530 531 532 533 534 535 536 537 538 539 540 541 542 543

        DebugS  register,"Register copy-filter",R0,80
        Debug   register,"Name, address, ws",R0,R1,R2

; Claim block to put data in.

        MOV     r0, #ModHandReason_Claim
        MOV     r3, #f_block_size
        SWI     XOS_Module

        DebugE  register,"copy-filter claim failed "

        ADDVS   sp,sp,#4
        Pull    "r1-r3,LR",VS
Stewart Brodie's avatar
Stewart Brodie committed
544
        RETURNVS VS
Kevin Bracey's avatar
Kevin Bracey committed
545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574

; Link block ^r2 to list.

        LDR     r14,copy_filters
        STR     r14,[r2,#next_ptr]  ; Point at next block
        CMP     r14,#0
        STRNE   r2,[r14,#prev_ptr]  ; Make next block point at the new block.
        MOV     R14,#0
        STR     R14,[r2,#prev_ptr]  ; This is the first block in the list
        STR     r2,copy_filters

        STR     R14,[r2,#f_mask]    ; Mask is not used for copy_filters.
        STR     R14,[r2,#f_task]    ; Task is not used for copy_filters.
        BLEQ    RegisterFilters     ; Register with wimp if this is first filter

        DebugE  register,"Cant register filters "

        BVS     %FT10               ; Jump if no wimp

        LDR     R14,[sp,#0*4]
        STR     R14,[r2,#f_name]    ; name of filter
        LDR     R14,[sp,#1*4]
        STR     R14,[r2,#f_address] ; address of filter
        LDR     R14,[sp,#2*4]
        STR     R14,[r2,#f_R12]     ; R12 for calling filter.

        Debug   register,"copy-filter registered ok"

; Exit to caller                    ; Preserves caller's flags.

575 576
        Pull    "r0-r3,LR"
        RETURNVC
Kevin Bracey's avatar
Kevin Bracey committed
577 578 579 580 581 582 583 584 585 586

; Error exit, freeing claimed block

10      STR     R0,[sp,#0*4]        ; Return error ptr
        LDR     R2,copy_filters
        MOV     R0,#0
        STR     R0,copy_filters
        MOV     R0,#ModHandReason_Free ; Free the block if error
        SWI     XOS_Module
        Pull    "r0-r3,LR"
Stewart Brodie's avatar
Stewart Brodie committed
587
        RETURNVS
Kevin Bracey's avatar
Kevin Bracey committed
588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606

;;--------------------------------------------------------------------------
;; Filter_RegisterPostRectFilter
;;
;; Add a new post-rect filter to the list of post-rect filters.
;;
;; Entry:
;;        R0 - Pointer to 0 terminated filter name.
;;        R1 - Addresss of filter.
;;        R2 - Value to be passed in R12.
;;        R3 - Task handle of task to which filter is applied.
;;
;; Exit:
;;        Registers preserved.
;;
;;

SWIFilter_RegisterPostRectFilter

607
        Push    "r0-r3"
Kevin Bracey's avatar
Kevin Bracey committed
608 609 610 611 612 613 614 615 616 617 618 619 620 621

        DebugS  register,"Register post-rect-filter",R0,80
        Debug   register,"Name, address, ws, task",R0,R1,R2,R3

; Claim block to put data in.

        MOV     r0, #ModHandReason_Claim
        MOV     r3, #f_block_size
        SWI     XOS_Module

        DebugE  register,"post-rect-filter claim failed "

        ADDVS   sp,sp,#4
        Pull    "r1-r3,LR",VS
Stewart Brodie's avatar
Stewart Brodie committed
622
        RETURNVS VS
Kevin Bracey's avatar
Kevin Bracey committed
623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655

; Link block ^r2 to list.

        LDR     r14,post_rect_filters
        STR     r14,[r2,#next_ptr]  ; Point at next block
        CMP     r14,#0
        STRNE   r2,[r14,#prev_ptr]  ; Make next block point at the new block.
        MOV     R14,#0
        STR     R14,[r2,#prev_ptr]  ; This is the first block in the list
        STR     r2,post_rect_filters

        STR     R14,[r2,#f_mask]    ; Mask is not used for post_rect_filters.
        BLEQ    RegisterFilters     ; Register with wimp if this is first filter

        DebugE  register,"Cant register filters "

        BVS     %FT10               ; Jump if no wimp

        LDR     R14,[sp,#0*4]
        STR     R14,[r2,#f_name]    ; name of filter
        LDR     R14,[sp,#1*4]
        STR     R14,[r2,#f_address] ; address of filter
        LDR     R14,[sp,#2*4]
        STR     R14,[r2,#f_R12]     ; R12 for calling filter.
        LDR     R14,[sp,#3*4]
        MOV     R14,R14,ASL #16
        MOV     R14,R14,LSR #16
        STR     R14,[r2,#f_task]    ; Task ID.

        Debug   register,"post-rect-filter registered ok"

; Exit to caller                    ; Preserves caller's flags.

656 657
        Pull    "r0-r3,LR"
        RETURNVC
Kevin Bracey's avatar
Kevin Bracey committed
658 659 660 661 662 663 664 665 666 667

; Error exit, freeing claimed block

10      STR     R0,[sp,#0*4]        ; Return error ptr
        LDR     R2,post_rect_filters
        MOV     R0,#0
        STR     R0,post_rect_filters
        MOV     R0,#ModHandReason_Free ; Free the block if error
        SWI     XOS_Module
        Pull    "r0-r3,LR"
Stewart Brodie's avatar
Stewart Brodie committed
668
        RETURNVS
Kevin Bracey's avatar
Kevin Bracey committed
669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687

;;--------------------------------------------------------------------------
;; Filter_RegisterPostIconFilter
;;
;; Add a new post-icon filter to the list of post-icon filters.
;;
;; Entry:
;;        R0 - Pointer to 0 terminated filter name.
;;        R1 - Address of filter.
;;        R2 - Value to be passed in R12.
;;        R3 - Task handle of task to which filter is applied.
;;
;; Exit:
;;        Registers preserved.
;;
;;

SWIFilter_RegisterPostIconFilter

688
        Push    "r0-r3"
Kevin Bracey's avatar
Kevin Bracey committed
689 690 691 692 693 694 695 696 697 698 699 700 701 702

        DebugS  register,"Register post-icon-filter",R0,80
        Debug   register,"Name, address, ws, task",R0,R1,R2,R3

; Claim block to put data in.

        MOV     r0, #ModHandReason_Claim
        MOV     r3, #f_block_size
        SWI     XOS_Module

        DebugE  register,"post-icon-filter claim failed "

        ADDVS   sp,sp,#4
        Pull    "r1-r3,LR",VS
Stewart Brodie's avatar
Stewart Brodie committed
703
        RETURNVS VS
Kevin Bracey's avatar
Kevin Bracey committed
704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736

; Link block ^r2 to list.

        LDR     r14,post_icon_filters
        STR     r14,[r2,#next_ptr]  ; Point at next block
        CMP     r14,#0
        STRNE   r2,[r14,#prev_ptr]  ; Make next block point at the new block.
        MOV     R14,#0
        STR     R14,[r2,#prev_ptr]  ; This is the first block in the list
        STR     r2,post_icon_filters

        STR     R14,[r2,#f_mask]    ; Mask is not used for post_icon_filters.
        BLEQ    RegisterFilters     ; Register with wimp if this is first filter

        DebugE  register,"Cant register filters "

        BVS     %FT10               ; Jump if no wimp

        LDR     R14,[sp,#0*4]
        STR     R14,[r2,#f_name]    ; name of filter
        LDR     R14,[sp,#1*4]
        STR     R14,[r2,#f_address] ; address of filter
        LDR     R14,[sp,#2*4]
        STR     R14,[r2,#f_R12]     ; R12 for calling filter.
        LDR     R14,[sp,#3*4]
        MOV     R14,R14,ASL #16
        MOV     R14,R14,LSR #16
        STR     R14,[r2,#f_task]    ; Task ID.

        Debug   register,"post-icon-filter registered ok"

; Exit to caller                    ; Preserves caller's flags.

737 738
        Pull    "r0-r3,LR"
        RETURNVC
Kevin Bracey's avatar
Kevin Bracey committed
739 740 741 742 743 744 745 746 747 748

; Error exit, freeing claimed block

10      STR     R0,[sp,#0*4]        ; Return error ptr
        LDR     R2,post_icon_filters
        MOV     R0,#0
        STR     R0,post_icon_filters
        MOV     R0,#ModHandReason_Free ; Free the block if error
        SWI     XOS_Module
        Pull    "r0-r3,LR"
Stewart Brodie's avatar
Stewart Brodie committed
749
        RETURNVS
Kevin Bracey's avatar
Kevin Bracey committed
750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769

;;--------------------------------------------------------------------------
;; Filter_DeRegisterRectFilter
;;
;; Remove a rect filter from the list of rect filters.
;;
;; Entry:
;;        R0 - Pointer to 0 terminated filter name.
;;        R1 - Addresss of filter.
;;        R2 - Value to be passed in R12.
;;        R3 - Task handle of task to which filter was applied.
;;
;;        All must be the same as those passed to RegisterRectFilter
;; Exit:
;;        Registers preserved.
;;
;;

SWIFilter_DeRegisterRectFilter

770
        Push    "r0-r4"
Kevin Bracey's avatar
Kevin Bracey committed
771 772 773 774 775 776 777 778 779 780 781 782 783 784 785

        DebugS  register,"De-register rect-filter",R0,80
        Debug   register,"Name, address, ws, task",R0,R1,R2,R3

        ADR     r4,rect_filters
        MOV     R3,R3,ASL #16
        MOV     R3,R3,LSR #16   ; Task ID
        BL      find_filter     ; Finds the filter in the list

        DebugE  register,"Cant find rect-filter "

        ADDVS   sp,sp,#4
        ADRVS   r0,ErrorBlock_UnknownFilter
        BLVS    MsgTrans_ErrorLookup
        Pull    "r1-r4,LR",VS
Stewart Brodie's avatar
Stewart Brodie committed
786
        RETURNVS VS
Kevin Bracey's avatar
Kevin Bracey committed
787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823

; Found filter, remove it from list.

        LDR     r14,[r4,#next_ptr]
        LDR     r0, [r4,#prev_ptr]
        CMP     r0,#0
        STREQ   r14,rect_filters      ; Next block is now first on the list
        STRNE   r14,[r0,#next_ptr]   ; Or is next of previous block.
        CMP     R14,#0
        STRNE   r0,[R14,#prev_ptr]   ; If there is a next block update its prev_ptr.

deregister_rect_for_fake_post_rect
        LDR     r14,rect_filters
        CMP     r14,#0               ; Any filters left?
        MOVEQ   r0,#WimpFilter_GetRectangle
        MOVEQ   r1,#0                ;  No then de-register
 [ debugregister
        BNE     %FT00
        Debug   register,"Deregistering rect-filter",r0,r1
00
 ]
        SWIEQ   XWimp_RegisterFilter ; Remove filters for speed

        DebugE  register,"Cant de-register rect-filter "

        MOV     R0,#ModHandReason_Free ; Now free the block.
        MOV     R2,R4
        SWI     XOS_Module

        DebugE  register,"Cant free rect-filter block "

	; DeRegisterPostRectFilter can exit through here, so
	; keep the stack usage the same!
        Pull    "r0-r4,PC",VC

        ADD     sp,sp,#4                ; Drop caller's R0
        Pull    "r1-r4,LR"
Stewart Brodie's avatar
Stewart Brodie committed
824
        RETURNVS
Kevin Bracey's avatar
Kevin Bracey committed
825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844

;;--------------------------------------------------------------------------
;; Filter_DeRegisterPostRectFilter
;;
;; Remove a post-rect filter from the list of rect filters.
;;
;; Entry:
;;        R0 - Pointer to 0 terminated filter name.
;;        R1 - Addresss of filter.
;;        R2 - Value to be passed in R12.
;;        R3 - Task handle of task to which filter was applied.
;;
;;        All must be the same as those passed to RegisterPostRectFilter
;; Exit:
;;        Registers preserved.
;;
;;

SWIFilter_DeRegisterPostRectFilter

845
        Push    "r0-r4"
Kevin Bracey's avatar
Kevin Bracey committed
846 847 848 849 850 851 852 853 854 855 856 857 858 859 860

        DebugS  register,"De-register post-rect-filter",R0,80
        Debug   register,"Name, address, ws, task",R0,R1,R2,R3

        ADR     r4,post_rect_filters
        MOV     R3,R3,ASL #16
        MOV     R3,R3,LSR #16   ; Task ID
        BL      find_filter     ; Finds the filter in the list

        DebugE  register,"Cant find post-rect-filter "

        ADDVS   sp,sp,#4
        ADRVS   r0,ErrorBlock_UnknownFilter
        BLVS    MsgTrans_ErrorLookup
        Pull    "r1-r4,LR",VS
Stewart Brodie's avatar
Stewart Brodie committed
861
        RETURNVS VS
Kevin Bracey's avatar
Kevin Bracey committed
862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900

; Found filter, remove it from list.

        LDR     r14,[r4,#next_ptr]
        LDR     r0, [r4,#prev_ptr]
        CMP     r0,#0
        STREQ   r14,post_rect_filters; Next block is now first on the list
        STRNE   r14,[r0,#next_ptr]   ; Or is next of previous block.
        CMP     R14,#0
        STRNE   r0,[R14,#prev_ptr]   ; If there is a next block update its prev_ptr.

        LDR     r14,post_rect_filters
        CMP     r14,#0               ; Any filters left?
	BNE	%FT05

	LDR	r14,fake_postrect	; Consider freeing RectFilter if faking
	TEQ	r14,#0
	BNE	deregister_rect_for_fake_post_rect

        MOV     r0,#WimpFilter_PostGetRectangle
        MOV     r1,#0
 [ debugregister
        Debug   register,"Deregistering post-rect-filter",r0,r1
 ]
        SWI     XWimp_RegisterFilter ; Remove filters for speed

        DebugE  register,"Cant de-register post-rect-filter "

05
        MOV     R0,#ModHandReason_Free ; Now free the block.
        MOV     R2,R4
        SWI     XOS_Module

        DebugE  register,"Cant free post-rect-filter block "

        Pull    "r0-r4,PC",VC

        ADD     sp,sp,#4                ; Drop caller's R0
        Pull    "r1-r4,LR"
Stewart Brodie's avatar
Stewart Brodie committed
901
        RETURNVS
Kevin Bracey's avatar
Kevin Bracey committed
902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920

;;--------------------------------------------------------------------------
;; Filter_DeRegisterCopyFilter
;;
;; Remove a copy filter from the list of copy filters.
;;
;; Entry:
;;        R0 - Pointer to 0 terminated filter name.
;;        R1 - Addresss of filter.
;;        R2 - Value to be passed in R12.
;;
;;        All must be the same as those passed to RegisterCopyFilter
;; Exit:
;;        Registers preserved.
;;
;;

SWIFilter_DeRegisterCopyFilter

921
        Push    "r0-r4"
Kevin Bracey's avatar
Kevin Bracey committed
922 923 924 925 926 927 928 929 930 931 932 933 934 935

        DebugS  register,"De-register copy-filter",R0,80
        Debug   register,"Name, address, ws",R0,R1,R2

        ADR     r4,copy_filters
	MOV	r3,#0
        BL      find_filter     ; Finds the filter in the list

        DebugE  register,"Cant find copy-filter "

        ADDVS   sp,sp,#4
        ADRVS   r0,ErrorBlock_UnknownFilter
        BLVS    MsgTrans_ErrorLookup
        Pull    "r1-r4,LR",VS
Stewart Brodie's avatar
Stewart Brodie committed
936
        RETURNVS VS
Kevin Bracey's avatar
Kevin Bracey committed
937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970

; Found filter, remove it from list.

        LDR     r14,[r4,#next_ptr]
        LDR     r0, [r4,#prev_ptr]
        CMP     r0,#0
        STREQ   r14,copy_filters      ; Next block is now first on the list
        STRNE   r14,[r0,#next_ptr]   ; Or is next of previous block.
        CMP     R14,#0
        STRNE   r0,[R14,#prev_ptr]   ; If there is a next block update its prev_ptr.

        LDR     r14,copy_filters
        CMP     r14,#0               ; Any filters left?
        MOVEQ   r0,#WimpFilter_BlockCopy
        MOVEQ   r1,#0                ;  No then de-register
 [ debugregister
        BNE     %FT00
        Debug   register,"Deregistering copy-filter",r0,r1
00
 ]
        SWIEQ   XWimp_RegisterFilter ; Remove filters for speed

        DebugE  register,"Cant de-register copy-filter "

        MOV     R0,#ModHandReason_Free ; Now free the block.
        MOV     R2,R4
        SWI     XOS_Module

        DebugE  register,"Cant free copy-filter block "

        Pull    "r0-r4,PC",VC

        ADD     sp,sp,#4                ; Drop caller's R0
        Pull    "r1-r4,LR"
Stewart Brodie's avatar
Stewart Brodie committed
971
        RETURNVS
Kevin Bracey's avatar
Kevin Bracey committed
972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990

;;--------------------------------------------------------------------------
;; Filter_DeRegisterPostIconFilter
;;
;; Remove a post-icon filter from the list of posticon filters.
;;
;; Entry:
;;        R0 - Pointer to 0 terminated filter name.
;;        R1 - Addresss of filter.
;;        R2 - Value to be passed in R12.
;;
;;        All must be the same as those passed to RegisterPostIconFilter
;; Exit:
;;        Registers preserved.
;;
;;

SWIFilter_DeRegisterPostIconFilter

991
        Push    "r0-r4"
Kevin Bracey's avatar
Kevin Bracey committed
992 993 994 995 996

        DebugS  register,"De-register post-icon-filter",R0,80
        Debug   register,"Name, address, ws",R0,R1,R2

        ADR     r4,post_icon_filters
997 998
        MOV     R3,R3,ASL #16   ; Fixed 31/12/97 SNB.  Used to mov r3, #0
        MOV     R3,R3,LSR #16   ; Task ID
Kevin Bracey's avatar
Kevin Bracey committed
999 1000 1001 1002 1003
        BL      find_filter     ; Finds the filter in the list

        DebugE  register,"Cant find posticon-filter "

        ADDVS   sp,sp,#4
1004
        ADRVSL  r0,ErrorBlock_UnknownFilter
Kevin Bracey's avatar
Kevin Bracey committed
1005 1006
        BLVS    MsgTrans_ErrorLookup
        Pull    "r1-r4,LR",VS
Stewart Brodie's avatar
Stewart Brodie committed
1007
        RETURNVS VS
Kevin Bracey's avatar
Kevin Bracey committed
1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041

; Found filter, remove it from list.

        LDR     r14,[r4,#next_ptr]
        LDR     r0, [r4,#prev_ptr]
        CMP     r0,#0
        STREQ   r14,post_icon_filters ; Next block is now first on the list
        STRNE   r14,[r0,#next_ptr]   ; Or is next of previous block.
        CMP     R14,#0
        STRNE   r0,[R14,#prev_ptr]   ; If there is a next block update its prev_ptr.

        LDR     r14,post_icon_filters
        CMP     r14,#0               ; Any filters left?
        MOVEQ   r0,#WimpFilter_PostIconGetRectangle
        MOVEQ   r1,#0                ;  No then de-register
 [ debugregister
        BNE     %FT00
        Debug   register,"Deregistering post-icon-filter",r0,r1
00
 ]
        SWIEQ   XWimp_RegisterFilter ; Remove filters for speed

        DebugE  register,"Cant de-register post-icon-filter "

        MOV     R0,#ModHandReason_Free ; Now free the block.
        MOV     R2,R4
        SWI     XOS_Module

        DebugE  register,"Cant free post-icon-filter block "

        Pull    "r0-r4,PC",VC

        ADD     sp,sp,#4                ; Drop caller's R0
        Pull    "r1-r4,LR"
Stewart Brodie's avatar
Stewart Brodie committed
1042
        RETURNVS
Kevin Bracey's avatar
Kevin Bracey committed
1043

Robert Sprowson's avatar
Robert Sprowson committed
1044
        LNK     MsgTrans.s