*****************************************************      A S S E M B L E R   M O U S E               *************************************************cmw**      module head for RTOS-UH                     *MDLE:  DC.L   TASK1          for the loader        *       DC.L   0              for the loader        *       DC     $10                                  *       DC.B   'ASMOUS'                             ******************************************************      hyperprocessor and trap definitions         *TERMI  OPD    $4E41          terminate self        *REQU   OPD    $4E46          request semaphore     *RELEA  OPD    $4E47          release semaphore     *ENAB   OPD    $A032          enable interrupt      *DISAB  OPD    $A034          disable interrupt     ******************************************************      module variables                            *SYNC   DC.L   $40000000      vsync interrupt       *MAUS   DC.L   $80000000      mouse interrupt       *MTO    DC     0              old mouse status      ******************************************************                                                  **      M O U S E                                   **      last update:   02.09.86   20h55             **                                                  ******************************************************      task head for RTOS-UH                       *TASK1: DC.L   0              for loader            *       DC.L   MDLE           for loader            *       DC     $81            type: resident task   *       DC.B   'MOUSE '       task name             *       DC     PRIO           task priority         *       DC.L   WSPLEN         work space length     *       DC.L   0,0            for System            *       DC     PRIO           also priority         *       DC.L   MOUSE          start-PC              *       DC.L   0,0,0,0,0,0,0,0      64 bytes zero   *       DC.L   0,0,0,0,0,0,0,0                      *****************************************************PRIO   EQU    15             task priority         *WSPLEN EQU    $FE            workspace length      ******************************************************      task workspace definitions                  *STACK  EQU    WSPLEN         workspace length      *****************************************************MOUSE  LEA    STACK.T,A7     set up stack          *       MOVE.L MAUS,D0        get interrupt mask    *       DISAB                 disable MAUS interrupt*       MOVE.B $8E6,D0        get new mouse status  *       CMP.B  MTO,D0         compare with old one  *       BEQ.S  MM0            b: didn't change      *       LEA    MTO,A1         get address of MTO    *       MOVE.B D0,(A1)        save status           *       BTST   =1,D0          test left button      *       SNE    >LBTN          save result of test   *       BTST   =0,D0          test right button     *       SNE    >RBTN          save result of test   *       BRA.S  MEXIT          it's done, go to exit **      mouse has been moved                        *MM0:   LEA    >SCRSEM,A1     get address of sema   *       REQU                  request the semaphor  *       MOVE.B $8E7,D0        get x-movement        *       BEQ.S  MMY            b: no x-movement      *       EXT.W  D0             sign extend to word   *       ADD.W  >MX,D0         add old position      *       CMP.W  =630,D0        test for screen border*       BCS.S  MM2            b: not out of range   *       BPL.S  MM1            b: x greater than 629 **      x is negativ, replace by 0                  *       MOVEQ  =0,D0          x = 0                 *       BRA.S  MM2                                  **      x is greater than 629, replace by 629       *MM1:   MOVE.W =629,D0        x = 629               *MM2:   MOVE.W D0,>MX         save new x            **      handle y-movement                           *MMY:   MOVE.B $8E8,D0        get y-movement        *       BEQ.S  MM5            b: no y-movement      *       EXT.W  D0             sign extend to word   *       ADD.W  >MY,D0         add old position      *       CMP.W  =390,D0        test for screen border*       BCS.S  MM4            b: not out of range   *       BPL.S  MM3            b: y greater than 389 **      y is negativ, replace by 0                  *       MOVEQ  =0,D0          y = 0                 *       BRA.S  MM4                                  **      y is greater than 389, replace by 389       *MM3:   MOVE.W =389,D0        y = 389               *MM4:   MOVE.W D0,>MY         save new y            **      enable the SYNC interrupt                   *MM5:   MOVE.L SYNC,D0        get interrupt mask    *       ENAB                  enable SYNC interrupt *       LEA    >SCRSEM,A1     get address of sema   *       RELEA                 release the semaphor  **      enable the MAUS interrupt for next movement *MEXIT: MOVE.L MAUS,D0        get interrupt mask    *       ENAB                  enable MAUS interrupt *       TERMI                 quick end of joy      **                                                  *****************************************************       END    TASK1                                *****************************************************