PoRtFilter 3.79 KB
Newer Older
Kevin Bracey's avatar
Kevin Bracey committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
; Copyright 1997 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.PoRtFilter

;;----------------------------------------------------------------
;; post_rect_filter_handler
;;
;; This is called by the Wimp on exit from int_get_rectangle
;;
;; Entry:
;;
;;      R2    - Task handle of calling task.
;;      R6-R9 - screen coordinates of rectangle (x0,y0,x1,y1)
;;      R10   - window handle - 1
;;
;; Exit:
;;
;;      All other registers preserved.
;;
;;      All interested filters called.
;;
;;

post_rect_filter_handler

        Push    "r0-r2,LR"

        MOV     R2,R2,ASL #16
        MOV     R2,R2,LSR #16

43
        Rel     r0,r10                   ; find the window being redrawn
Kevin Bracey's avatar
Kevin Bracey committed
44 45 46 47

        LDR     r1,post_rect_filters
post_rect_filter_exit
        CMP     r1,#0
48
      [ No26bitCode
Stewart Brodie's avatar
Stewart Brodie committed
49
        Pull    "r0-r2,PC",EQ            ; End of list.
50 51 52
      |
        Pull    "r0-r2,PC",EQ,^          ; End of list.
      ]
Kevin Bracey's avatar
Kevin Bracey committed
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
        LDR     r14,[r1,#next_ptr]
        Push    "r14"

        LDR     r14,[r1,#f_task]
        TEQ     r14,R2
        CMPNE   r14,#0
        Pull    "r1",NE
        BNE     post_rect_filter_exit        ; Filter not interested.

        LDR     r12,[r1,#f_R12]        ; Set R12.

        MOV     LR,PC
        LDR     PC, [r1,#f_address]
        NOP
        Pull    "r1"
        B       post_rect_filter_exit

Stewart Brodie's avatar
Stewart Brodie committed
70 71
        [ :LNOT: No26bitCode

Kevin Bracey's avatar
Kevin Bracey committed
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 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
	; Can get away with this inline data as we'll only need to
	; fake when softloading anyway.

	; Eight words to store R2,R6-R9,R10,R12
fake_regdump
	%	7*4
	; The address that int_get_rectangle was supposed to return to
fake_retaddr
	%	4

	; We want to return to 2 instructions after this instruction
	; in the Wimp's int_get_rectangle routine.
fake_magic_marker
	TST	R14,#&0C

int_get_rectangle_reentry_addr
	DCD 	0

	; This rectangle filter checks that we are being called from
	; the second rectangle filter call in the Wimp (R0=-1), and
	; if so, we poke a new return address into the stack, so that
	; int_get_rectangle returns to fakepostrect_handler.
	; What we then do is return to within int_get_rectangle, having
	; fixed the stack up, to where it sets the fg/bg colours
	; (starting at the instruction "fake_magic_marker").
	;
	; The stack at this point contains 4 words from rect_filt_handler,
	; 3 words from the Wimp's CallFilter macro, followed by
	; handle, userblk and lr from int_get_rectangle.
sortout_fakepostrect
	CMP	r0,#-1
	MOVNES	pc,lr
	Push	"r0-r1,r10,lr"
	ADR	r0,fakepostrect_handler
	LDR	lr,[r13,#(4+4+3+2)*4]		; Fiddle with int_get_rectangle's
	AND	r1,lr,#&FC000003		; lr
	ORR	r0,r0,r1
	STR	r0,[r13,#(4+4+3+2)*4]
	LDR	r10,[r13,#(4+4+3+0)*4]		; Get int_get_rectangle's handle
	ADR	r0,fake_regdump
	STMIA	r0,{r2,r6-r9,r10,r12,lr}
	; Find int_get_rectangle_reentry_addr
	LDR	r0,int_get_rectangle_reentry_addr
	TEQ	r0,#0
	Pull	"r0-r1,r10,pc",NE
	LDR	lr,[r13,#(4+3)*4]		; Get original lr passed to rect filter
	BIC	lr,lr,#&FC000003
	LDR	r1,fake_magic_marker
	; Scan forward to find the magic marker
05	LDR	r0,[lr,#4]!
	TEQ	r0,r1
	BNE	%BT05
	ADD	lr,lr,#8
	STR	lr,int_get_rectangle_reentry_addr
	Pull	"r0-r1,r10,pc"

fakepostrect_handler
	LDR	lr,fake_retaddr
	Push	"r2,r6-r9,r10,r12,lr"
	ADR	lr,fake_regdump
	LDMIA	lr,{r2,r6-r9,r10,r12}
	BL	post_rect_filter_handler
	Pull	"r2,r6-r9,r10,r12"
	LDR	pc,int_get_rectangle_reentry_addr

Stewart Brodie's avatar
Stewart Brodie committed
137 138
        ]

Robert Sprowson's avatar
Robert Sprowson committed
139
        LNK     PoIcFilter.s
Kevin Bracey's avatar
Kevin Bracey committed
140 141