URL
https://opencores.org/ocsvn/rtf65002/rtf65002/trunk
Subversion Repositories rtf65002
[/] [rtf65002/] [trunk/] [software/] [asm/] [iofocus.asm] - Rev 40
Compare with Previous | Blame | View Log
comment ~;------------------------------------------------------------------------------; Get a bit from the I/O focus table.;------------------------------------------------------------------------------GetIOFocusBit:phxphytaxand r1,r1,#$1F ; get bit index into wordlsr r2,r2,#5 ; get word index into tableldy IOFocusTbl,xlsr r3,r3,r1 ; extract bitand r1,r3,#1plyplxrts~;------------------------------------------------------------------------------; ForceIOFocus;; Force the IO focus to a specific job.;------------------------------------------------------------------------------;public ForceIOFocus:phaphxphyspl iof_sema + 1ldy IOFocusNdxcmp r1,r3beq fif1taxjsr CopyScreenToVirtualScreenlda JCB_pVirtVid,ysta JCB_pVidMem,ylda JCB_pVirtVidAttr,ysta JCB_pVidMemAttr,ystx IOFocusNdxlda #TEXTSCRsta JCB_pVidMem,xadd #$10000sta JCB_pVidMemAttr,xjsr CopyVirtualScreenToScreenfif1:stz iof_sema + 1plyplxplarts;------------------------------------------------------------------------------; SwitchIOFocus;; Switches the IO focus to the next task requesting the I/O focus. This; routine may be called when a task releases the I/O focus as well as when; the user presses ALT-TAB on the keyboard.; On Entry: the io focus semaphore is set already.;------------------------------------------------------------------------------;public SwitchIOFocus:phaphxphy; First check if it's even possible to switch the focus to another; task. The I/O focus list could be empty or there may be only a; single task in the list. In either case it's not possible to; switch.ldy IOFocusNdx ; Get the job at the head of the list.beq siof3 ; Is the list empty ?ldx JCB_iof_next,y ; Get the next job on the list.beq siof3 ; Nothing to switch to; Copy the current task's screen to it's virtual screen buffer.jsr CopyScreenToVirtualScreenlda JCB_pVirtVid,ysta JCB_pVidMem,ylda JCB_pVirtVidAttr,ysta JCB_pVidMemAttr,ystx IOFocusNdx ; Make task the new head of list.lda #TEXTSCRsta JCB_pVidMem,xadd #$10000sta JCB_pVidMemAttr,x; Copy the virtual screen of the task recieving the I/O focus to the; text screen.jsr CopyVirtualScreenToScreensiof3:plyplxplarts;------------------------------------------------------------------------------; The I/O focus list is an array indicating which jobs are requesting the; I/O focus. The I/O focus is user controlled by pressing ALT-TAB on the; keyboard.;------------------------------------------------------------------------------message "RequestIOFocus"public RequestIOFocus:phaphxphypush r4DisTmrKbdldx RunningTCBldx TCB_hJCB,xcpx #NR_JCBbhs riof1txabmt IOFocusTbl ; is the job already in the IO focus list ?bne riof1mul r4,r2,#JCB_Sizeadd r4,r4,#JCBslda IOFocusNdx ; Is the focus list empty ?beq riof2ldy JCB_iof_prev,r1beq riof4st r4,JCB_iof_prev,r1sta JCB_iof_next,r4sty JCB_iof_prev,r4st r4,JCB_iof_next,yriof3:txabms IOFocusTblriof1:EnTmrKbdpop r4plyplxplarts; Here, the IO focus list was empty. So expand it.; Make sure pointers are NULLriof2:st r4,IOFocusNdxstz JCB_iof_next,r4stz JCB_iof_prev,r4bra riof3; Here there was only a single entry in the list.; Setup pointers appropriately.riof4:sta JCB_iof_next,r4sta JCB_iof_prev,r4st r4,JCB_iof_next,r1st r4,JCB_iof_prev,r1bra riof3;------------------------------------------------------------------------------; Releasing the I/O focus causes the focus to switch if the running job; had the I/O focus.; ForceReleaseIOFocus forces the release of the IO focus for a job; different than the one currently running.;------------------------------------------------------------------------------;message "ForceReleaseIOFocus"public ForceReleaseIOFocus:phaphxphypush r4taxDisTmrKbdjmp rliof4message "ReleaseIOFocus"public ReleaseIOFocus:phaphxphypush r4DisTmrKbdldx RunningTCBldx TCB_hJCB,xrliof4:cpx #NR_JCBbhs rliof3; phxldy #1txabmt IOFocusTblbeq rliof3bmc IOFocusTbl; plxmul r4,r2,#JCB_Sizeadd r4,r4,#JCBscmp r4,IOFocusNdx ; Does the running job have the I/O focus ?bne rliof1jsr SwitchIOFocus ; If so, then switch the focus.rliof1:lda JCB_iof_next,r4 ; get next and previous fields.beq rliof5 ; Is list emptying ?ldy JCB_iof_prev,r4sta JCB_iof_next,y ; prev->next = current->nextsty JCB_iof_prev,r1 ; next->prev = current->prevbra rliof2rliof5:stz IOFocusNdx ; emptied.rliof2:stz JCB_iof_next,r4 ; Update the next and prev fields to indicatestz JCB_iof_prev,r4 ; the job is no longer on the list.rliof3:EnTmrKbdpop r4plyplxplarts
