OpenCores
URL https://opencores.org/ocsvn/rtf65002/rtf65002/trunk

Subversion Repositories rtf65002

[/] [rtf65002/] [trunk/] [software/] [asm/] [iofocus.asm] - Blame information for rev 40

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 40 robfinch
comment ~
2
;------------------------------------------------------------------------------
3
; Get a bit from the I/O focus table.
4
;------------------------------------------------------------------------------
5
GetIOFocusBit:
6
        phx
7
        phy
8
        tax
9
        and             r1,r1,#$1F              ; get bit index into word
10
        lsr             r2,r2,#5                ; get word index into table
11
        ldy             IOFocusTbl,x
12
        lsr             r3,r3,r1                ; extract bit
13
        and             r1,r3,#1
14
        ply
15
        plx
16
        rts
17
~
18
;------------------------------------------------------------------------------
19
; ForceIOFocus
20
;
21
; Force the IO focus to a specific job.
22
;------------------------------------------------------------------------------
23
;
24
public ForceIOFocus:
25
        pha
26
        phx
27
        phy
28
        spl             iof_sema + 1
29
        ldy             IOFocusNdx
30
        cmp             r1,r3
31
        beq             fif1
32
        tax
33
        jsr             CopyScreenToVirtualScreen
34
        lda             JCB_pVirtVid,y
35
        sta             JCB_pVidMem,y
36
        lda             JCB_pVirtVidAttr,y
37
        sta             JCB_pVidMemAttr,y
38
        stx             IOFocusNdx
39
        lda             #TEXTSCR
40
        sta             JCB_pVidMem,x
41
        add             #$10000
42
        sta             JCB_pVidMemAttr,x
43
        jsr             CopyVirtualScreenToScreen
44
fif1:
45
        stz             iof_sema + 1
46
        ply
47
        plx
48
        pla
49
        rts
50
 
51
;------------------------------------------------------------------------------
52
; SwitchIOFocus
53
;
54
; Switches the IO focus to the next task requesting the I/O focus. This
55
; routine may be called when a task releases the I/O focus as well as when
56
; the user presses ALT-TAB on the keyboard.
57
; On Entry: the io focus semaphore is set already.
58
;------------------------------------------------------------------------------
59
;
60
public SwitchIOFocus:
61
        pha
62
        phx
63
        phy
64
 
65
        ; First check if it's even possible to switch the focus to another
66
        ; task. The I/O focus list could be empty or there may be only a
67
        ; single task in the list. In either case it's not possible to
68
        ; switch.
69
        ldy             IOFocusNdx              ; Get the job at the head of the list.
70
        beq             siof3                   ; Is the list empty ?
71
        ldx             JCB_iof_next,y  ; Get the next job on the list.
72
        beq             siof3                   ; Nothing to switch to
73
 
74
        ; Copy the current task's screen to it's virtual screen buffer.
75
        jsr             CopyScreenToVirtualScreen
76
        lda             JCB_pVirtVid,y
77
        sta             JCB_pVidMem,y
78
        lda             JCB_pVirtVidAttr,y
79
        sta             JCB_pVidMemAttr,y
80
 
81
        stx             IOFocusNdx              ; Make task the new head of list.
82
        lda             #TEXTSCR
83
        sta             JCB_pVidMem,x
84
        add             #$10000
85
        sta             JCB_pVidMemAttr,x
86
 
87
        ; Copy the virtual screen of the task recieving the I/O focus to the
88
        ; text screen.
89
        jsr             CopyVirtualScreenToScreen
90
siof3:
91
        ply
92
        plx
93
        pla
94
        rts
95
 
96
;------------------------------------------------------------------------------
97
; The I/O focus list is an array indicating which jobs are requesting the
98
; I/O focus. The I/O focus is user controlled by pressing ALT-TAB on the
99
; keyboard.
100
;------------------------------------------------------------------------------
101
message "RequestIOFocus"
102
public RequestIOFocus:
103
        pha
104
        phx
105
        phy
106
        push    r4
107
        DisTmrKbd
108
        ldx             RunningTCB
109
        ldx             TCB_hJCB,x
110
        cpx             #NR_JCB
111
        bhs             riof1
112
        txa
113
        bmt             IOFocusTbl              ; is the job already in the IO focus list ?
114
        bne             riof1
115
        mul             r4,r2,#JCB_Size
116
        add             r4,r4,#JCBs
117
        lda             IOFocusNdx              ; Is the focus list empty ?
118
        beq             riof2
119
        ldy             JCB_iof_prev,r1
120
        beq             riof4
121
        st              r4,JCB_iof_prev,r1
122
        sta             JCB_iof_next,r4
123
        sty             JCB_iof_prev,r4
124
        st              r4,JCB_iof_next,y
125
riof3:
126
        txa
127
        bms             IOFocusTbl
128
riof1:
129
        EnTmrKbd
130
        pop             r4
131
        ply
132
        plx
133
        pla
134
        rts
135
 
136
        ; Here, the IO focus list was empty. So expand it.
137
        ; Make sure pointers are NULL
138
riof2:
139
        st              r4,IOFocusNdx
140
        stz             JCB_iof_next,r4
141
        stz             JCB_iof_prev,r4
142
        bra             riof3
143
 
144
        ; Here there was only a single entry in the list.
145
        ; Setup pointers appropriately.
146
riof4:
147
        sta             JCB_iof_next,r4
148
        sta             JCB_iof_prev,r4
149
        st              r4,JCB_iof_next,r1
150
        st              r4,JCB_iof_prev,r1
151
        bra             riof3
152
 
153
;------------------------------------------------------------------------------
154
; Releasing the I/O focus causes the focus to switch if the running job
155
; had the I/O focus.
156
; ForceReleaseIOFocus forces the release of the IO focus for a job
157
; different than the one currently running.
158
;------------------------------------------------------------------------------
159
;
160
message "ForceReleaseIOFocus"
161
public ForceReleaseIOFocus:
162
        pha
163
        phx
164
        phy
165
        push    r4
166
        tax
167
        DisTmrKbd
168
        jmp             rliof4
169
message "ReleaseIOFocus"
170
public ReleaseIOFocus:
171
        pha
172
        phx
173
        phy
174
        push    r4
175
        DisTmrKbd
176
        ldx             RunningTCB
177
        ldx             TCB_hJCB,x
178
rliof4:
179
        cpx             #NR_JCB
180
        bhs             rliof3
181
;       phx
182
        ldy             #1
183
        txa
184
        bmt             IOFocusTbl
185
        beq             rliof3
186
        bmc             IOFocusTbl
187
;       plx
188
        mul             r4,r2,#JCB_Size
189
        add             r4,r4,#JCBs
190
        cmp             r4,IOFocusNdx   ; Does the running job have the I/O focus ?
191
        bne             rliof1
192
        jsr             SwitchIOFocus   ; If so, then switch the focus.
193
rliof1:
194
        lda             JCB_iof_next,r4 ; get next and previous fields.
195
        beq             rliof5                  ; Is list emptying ?
196
        ldy             JCB_iof_prev,r4
197
        sta             JCB_iof_next,y  ; prev->next = current->next
198
        sty             JCB_iof_prev,r1 ; next->prev = current->prev
199
        bra             rliof2
200
rliof5:
201
        stz             IOFocusNdx              ; emptied.
202
rliof2:
203
        stz             JCB_iof_next,r4 ; Update the next and prev fields to indicate
204
        stz             JCB_iof_prev,r4 ; the job is no longer on the list.
205
rliof3:
206
        EnTmrKbd
207
        pop             r4
208
        ply
209
        plx
210
        pla
211
        rts
212
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.