
DisPatch:  movea.l    ex_LaunchPoint(A6),A4
           move.w     #$FFFF,IDNestCnt(A6)
           move.w     #$C000,_custom+INTENA
           lea        TaskReady(A6),A0
StopResume: move.w     #$2700,sr
           movea.l    (A0),A3
           move.l     (A3),D0
            bne.b      NoStop
           addq.l     #1,IdleCount(A6)
           bset       #$7,SysFlags(A6)
          stop       #$2000
StopRoutine: bra.b      StopResume
NoStop:    move.l     D0,(A0)
           movea.l    D0,A1
           move.l     A0,$4(A1)
           move.l     A3,ThisTask(A6)
           move.w     Quantum(A6),Elapsed(A6)
           bclr       #$6,SysFlags(A6)
           move.b     #$2,$F(A3)
           move.w     $10(A3),IDNestCnt(A6)
           tst.b      IDNestCnt(A6)
            bmi.b      5$
           move.w     #$4000,_custom+INTENA
5$:        move.w     #$2000,sr
           addq.l     #1,DispCount(A6)
           move.b     $E(A3),D0
           and.b      #$A0,D0
            beq.b      6$
            bsr.b      Routine1
6$:        movea.l    $36(A3),A5
7$:       jmp        (A4)
exit:     rtS

Routine1:  btst       #$7,D0
            beq.b      11$
           move.b     D0,D2
           movea.l    $46(A3),A5
10$:        jsr        (A5)
           move.b     D2,D0
11$:       btst       #$5,D0
            beq.b      exit
           bclr       #$5,$E(A3)
           move.l     $2A(A3),D1
            beq.b      exit
           move.w     #$4000,_custom+INTENA
           addq.b     #1,IDNestCnt(A6)
           move.l     $1A(A3),D0
           and.l      $1E(A3),D0
           eor.l      D0,$1E(A3)
           eor.l      D0,$1A(A3)
           subq.b     #1,IDNestCnt(A6)
            bge.b      12$
           move.w     #$C000,_custom+INTENA
12$:       movea.l    $36(A3),A1
           move.l     $E(A3),-(A1)
           tst.b      IDNestCnt(A6)
            bne.b      13$
           subq.b     #1,IDNestCnt(A6)
            bge.b      13$
           move.w     #$C000,_custom+INTENA
13$:       move.l     #Routine2,-(A1)
           move.l     A1,usp
           btst       #$0,AttnFlags+1(A6)
            beq.b      14$
           move.w     #$0020,-(A7)
14$:       move.l     D1,-(A7)
           clr.w      -(A7)
           movea.l    $26(A3),A1
          rte

Routine2:  movea.l    $4.W,A6
           lea        16$(PC),A5
          jmp        Supervisor(A6)
16$:       movea.l    ex_LaunchPoint(A6),A4
           btst       #$0,AttnFlags+1(A6)
            beq.b      17$
           addq.l     #2,A7
17$:       addq.l     #6,A7
           movea.l    ThisTask(A6),A3
           or.l       D0,tc_SigExcept(A3)
           move.l     usp,A1
           move.l     (A1)+,tc_Flags(A3)
           move.l     A1,tc_SPReg(A3)
           move.w     tc_IDNestCnt(A3),IDNestCnt(A6)
           tst.b      IDNestCnt(A6)
            bmi.b      18$
           move.w     #$4000,_custom+INTENA
18$:      rtS

