home *** CD-ROM | disk | FTP | other *** search
/ Falcon 030 Power 2 / F030_POWER2.iso / ST_STE / MAGS / ICTARI09.ARJ / ictari.09 / ASSEMBLY / MOUSPROB.ANS / MOUSE2.S < prev    next >
Text File  |  1994-03-24  |  18KB  |  635 lines

  1.  
  2. * How to use the IKBD to read mouse data packets, and use them to update
  3. * program variables mousex & mousey.
  4.  
  5. * Started 14th December, 1993. Mike Barnard.
  6.  
  7. ****************************************************************************
  8.  
  9. * The equals statements, for ease of changing variables.
  10.  
  11. * screen limits for mouse movement.
  12.  
  13. xmax    equ    319    low rez
  14. ymax    equ    199
  15. xmin    equ    0
  16. ymin    equ    0
  17.  
  18. ****************************************************************************
  19.  
  20. * Main loop.
  21.  
  22.     text
  23. ;WHY NOT USE BSR (UNLESS PROGRAM IS HUGE!) AND BSR.S FOR SHORT JUMPS
  24. start    bsr    init        set it all up
  25.     bsr    printmes    print messages
  26. main    bsr.s    readmouse    read the mouse packet and set the variables
  27.     bsr    printxy        print the values of the variables
  28.     bsr    input        look for user input
  29. *    bsr    count        print a counter to the screen to check speed
  30.     bra.s    main
  31.     
  32. **************************************************************************
  33. ;PRESUME NONE OF THIS IS USED
  34. * loop counter
  35.  
  36. count
  37. ;    move.l    counter,d0
  38. ;    addq.l    #1,d0
  39. ;    move.l    d0,counter
  40. ;WHY NOT USE THIS INSTEAD?
  41.     addq.l    #1,counter
  42.  
  43.     
  44. * set the cursor
  45.  
  46.     move.b    #30,cursx    set cursx
  47.     move.b    #5,cursy    set cursy
  48. ;    jsr    setcurs        set the cursor position on screen
  49. ;USE BSR
  50.     bsr    setcurs
  51.     
  52. * turn counter into decimal in decbuf
  53.  
  54.     bsr    bins2dec    go to convertion routine    
  55.  
  56. * print value of x in decimal
  57.  
  58.     move.l    #decbuf,-(sp)    address of string onto stack
  59.     move.w    #9,-(sp)    GEMDOS 9 - PRINT A STRING
  60.     trap    #1
  61. ;USE WORD LENGTH TO ADD TO ADDRESS REGISTERS
  62.     addq.w    #6,sp
  63.     
  64.     rts
  65.  
  66. **************************************************************************
  67. ;DON'T LIKE ALL THE JUMPS IN THIS - RE-ARRANGED TO PUT SUB-ROUTINES
  68. ;IN-LINE - COMPARE THIS WITH ORIGINAL CODE
  69. * Change the variables using data from the mouse packet
  70.  
  71. readmouse
  72.  
  73. * load the registers with the X variable
  74.     
  75.     move.w    mousex,d0    put the x variable into d0
  76. ;    clr.w    d1        ensure no rubbish left in the word
  77.     move.w    mpack+2,d1    put the x data packet into d1
  78.     SUB.W    D1,mpack+2    subtract read value from pool
  79. ;NOTE: CHANGED TO WORD NOW AS INTERRUPTS ADD THE X OFFSET TO THIS VALUE
  80. ;AND VALUE TAKEN OUT IS SUBTRACTED FROM MPACK IN CASE INTERRUPT ADDS
  81. ;AGAIN AFTER READING BUT BEFORE CLEARING!
  82. ;USE EXT.W AFTER MOVE.B IF DATA IS SIGNED, INSTEAD OF CLR.W BEFORE
  83. ;    ext.w    d1
  84. * do the calculating
  85.  
  86. ;USE BSR, NOT JSR
  87. ;THIS IS NOT NEEDED - JUST ADD THE SIGNED VALUE - SEE COMMENTS IN CALCMOUSE
  88. ;    bsr    calcmouse    calculate the changes
  89.     add.w    d1,d0
  90.  
  91. * test the result for going beyond the screen limits
  92.     
  93.     cmpi.w    #xmin,d0    compare the result with the left border
  94. ;SHORT JUMP
  95. ;CHANGED TO OPPOSITE CONDITION AND PUT SUB-ROUTINE INSIDE GAP!
  96.     bpl.s    .aa        if it's more than xmin then branch past
  97.     move.w    #xmin,d0    set d0 to xmin
  98.  
  99. .aa    cmpi.w    #xmax,d0    compare the result with the right border
  100. ;SHORT JUMP
  101.     ble.s    .bb        if it's not more than xmax then branch past
  102.     move.w    #xmax,d0    set d0 to xmax
  103.  
  104. * save the resulting value
  105.  
  106. .bb    move.w    d0,mousex    put new value in store
  107.     
  108. * load the registers with the Y variable
  109.     
  110.     move.w    mousey,d0    put the y variable into d0
  111. ;    clr.w    d1        ensure no rubbish left in the word
  112.     move.w    mpack+4,d1    put the y data packet into d1
  113.     SUB.W    D1,mpack+4    and subtract it from the pool
  114. ;NOTE: MPACK NOW HAS 3 WORDS FOR BUTTONS,X & Y AS EACH INTERRUPT ADDS TO THIS VALUE
  115. ;AND YOU SHOULD SUBTRACT EACH VALUE YOU TAKE OUT IN CASE IT ADDS WHILE YOU ARE
  116. ;IN THE MIDDLE OF CLEARING (YOU'D LOSE THE NEW VALUE)
  117. ;MAKE IT A SIGNED WORD FOR ADDING
  118. ;    ext.w    d1
  119.     
  120. * do the calculating
  121. ;BSR INSTEAD OF JSR - JUST ADD VALUE (SINCE IT IS SIGNED)
  122. ;    bsr    calcmouse    calculate the changes
  123.     add.w    d1,d0
  124.  
  125. * test the result for going beyond the screen limits
  126.     
  127.     cmpi.w    #ymin,d0    compare the result with the top border
  128. ;SHORT JUMP
  129.     bpl.s    .cc        if it's not less than ymin then branch past
  130.     move.w    #ymin,d0    set d0 to ymin
  131.  
  132. .cc    cmpi.w    #ymax,d0    compare the result with the bottom border
  133. ;SHORT JUMP
  134.     ble.s    .dd        if it's not more than ymax then branch past
  135.     move.w    #ymax,d0    set d0 to xmax
  136.  
  137. * save the resulting value
  138.  
  139. .dd    move.w    d0,mousey    put new value in store
  140.  
  141. * DON'T clear the data packet - YOU DON'T KNOW WHEN IT IS BEING USED!.
  142. ;USE CLR INSTEAD OF MOVE
  143. ;    clr.l    mpack    zero the 4 bytes at 'mpack'
  144.     
  145.     rts
  146.  
  147. calcmouse
  148. ;NOTE: LOOK AT COMMENTS - THIS ROUTINE IS NO LONGER USED
  149. * put variable to change into d0, word sized.
  150. * put the data byte into d1, word sized.
  151. * call here.
  152.  
  153. * multiply the data byte by this factor, for mouse sensitivity
  154. ;SHORT JUMPS USED
  155.     tst.b    d1        set the ccr for the data type
  156.     beq.s    .end        if it's a zero, no change so branch out
  157.     bmi.s    .neg        if it's negative then branch
  158.     
  159. * it must be positive, so add it to the variable
  160.  
  161.     add.w    d1,d0        add data to value. result in d0
  162.     bra.s    .end        then leave
  163.     
  164. * it must be negative, so take the data from the variable.
  165. ;THIS IS NON-SENSICAL - ADDING A NEGATIVE NUMBER IS THE SAME AS 
  166. ;SUBTRACTING A POSITIVE NUMBER
  167. .neg
  168.     ext.w    d1        extend the byte to the word
  169.     neg.w    d1        then 2's complement it.
  170.     sub.w    d1,d0        take data from value. result in d0.
  171.     
  172. .end    rts
  173.  
  174. **************************************************************************
  175.  
  176. * look for input from the user
  177.  
  178. input
  179.  
  180. * get a scancode
  181. ;USE BRANCH RATHER THAN JUMP
  182.     bsr    getscan        look for a keypress
  183.     cmpi.w    #1,scancode    is it code 1 <Esc>?
  184.     beq    exit        yes, return to desktop
  185.     
  186.     rts
  187.     
  188. **************************************************************************
  189.  
  190. * INITIALISE
  191.  
  192. init
  193.  
  194. * who cares what rez we're in...
  195. * or where the screen is...
  196. * or what the palette is...
  197. * yet...
  198.  
  199. * set initial value of mousex and mousey
  200.  
  201.     move.w    #55,mousex
  202.     move.w    #295,mousey
  203.     
  204. * set background colour to print text to green
  205.  
  206.     move.l    #textback2,-(sp)    address of esc string
  207.     move.w    #9,-(sp)        function number
  208.     trap    #1            GEMDOS 9 - PRINT A STRING
  209. ;    addq.l    #6,sp            tidy
  210. ;QUICKER TO ADD WORDS TO ADDRESS REGISTERS AS ALL 32 BITS OF ADDRESS REGISTER
  211. ;ARE STILL AFFECTED!
  212.     addq.w    #6,sp
  213.  
  214.  
  215. * get the keyboard vector table
  216.  
  217.     move.w    #34,-(sp)    function number
  218.     trap    #14        XBIOS 34 - GET TABLE
  219. ;    addq.l    #2,sp        tidy
  220. ;AS ABOVE - USE WORDS WHEN ADDING TO ADDRESS REGISTERS
  221.     addq.w    #2,sp
  222.     move.l    d0,keyvectable    address of keyboard vector table saved
  223.     
  224. * put address of my mouse handler into the table
  225.  
  226.     move.l    d0,a0            address of start of table
  227. ;    lea    mhand,a1        address of my routine
  228. ;DON'T NEED TO USE A1 - JUST PUT THE ADDRESS AS IMMEDIATE DATA INTO 16(A0)
  229.     move.l    16(a0),oldmousevec    save the original mouse vector
  230. ;    move.l    a1,16(a0)        and replace with my routine's address
  231. ;SEE ABOVE - USE BELOW INSTEAD
  232.     move.l    #mhand,16(a0)
  233.     
  234. * tell the IKBD to use relative mouse movement
  235.  
  236.     pea    ikcom03        address of IKbd COMmand 03 onto stack
  237. ;    move.w    #0,-(sp)    length of command minus 1
  238. ;WHY NOT USE CLR INSTEAD?
  239.     clr.w    -(sp)
  240.     move.w    #25,-(sp)    function number
  241.     trap    #14        XBIOS 25 - SEND IKBD COMMAND
  242. ;    add.l    #8,sp        tidy
  243. ;AND ADDQ AGAIN WITH .W
  244.     addq.w    #8,sp
  245.     rts
  246.     
  247. **************************************************************************
  248.  
  249. * display the variables
  250.  
  251. printxy
  252.  
  253. * turn mousex into decimal in decbuf
  254.  
  255.     clr.l    d0        ensure totally clear register
  256.     move.w    mousex,d0    put mousex into d0
  257. ;NOTE
  258.     Bsr.S    bins2dec    go to convertion routine    
  259.  
  260. * set the cursor
  261.  
  262.     move.b    #19,cursx    set cursx
  263.     move.b    #5,cursy    set cursy
  264. ;NOTE
  265.     Bsr.S    setcurs        set the cursor position on screen
  266.  
  267. * print value of x in decimal
  268.  
  269.     move.l    #decbuf,-(sp)    address of string onto stack
  270.     move.w    #9,-(sp)    GEMDOS 9 - PRINT A STRING
  271.     trap    #1
  272.     addq.l    #6,sp
  273.     
  274. * turn mousey into decimal in decbuf
  275.  
  276.     clr.l    d0        ensure totally clear register
  277.     move.w    mousey,d0    put mousex into d0
  278. ;NOTE
  279.     Bsr.S    bins2dec    go to convertion routine    
  280.  
  281. * set the cursor
  282.  
  283.     move.b    #19,cursx    set cursx
  284.     move.b    #7,cursy    set cursy
  285. ;NOTE
  286.     Bsr.S    setcurs        set the cursor position on screen
  287.  
  288. * print value of y in decimal
  289.  
  290.     move.l    #decbuf,-(sp)    address of string onto stack
  291.     move.w    #9,-(sp)    GEMDOS 9 - PRINT A STRING
  292.     trap    #1
  293. ;NOTE
  294.     addq.W    #6,sp
  295.  
  296.     rts
  297.  
  298. *************************************************************************
  299.  
  300. * SET THE CURSOR POSITION
  301.  
  302. * set BOTH 'cursx' & 'cursy' values before calling.  Note that if one of
  303. * them is left from a previous call, it will have 31 added to it AGAIN.
  304.  
  305. setcurs
  306. ;NOTE: GEMDOS USES ONLY D0-D2/A0-A2
  307.     movem.l    d0-d2/a0-a2,-(sp)    save registers
  308.  
  309. * ascii the cursor references
  310.  
  311.     add.b    #31,cursx    adding 31 makes it ascii for printing
  312.     add.b    #31,cursy    adding 31 makes it ascii for printing
  313.  
  314. * print the cursor string, setting the screen cursor
  315.  
  316.     move.l    #curspos,-(sp)    address of string onto stack
  317.     move.w    #9,-(sp)    GEMDOS 9 - PRINT A STRING
  318.     trap    #1
  319. ;NOTE
  320.     addq.W    #6,sp
  321.     
  322.     movem.l    (sp)+,d0-d2/a0-a2    restore registers
  323.  
  324.     rts
  325. *************************************************************************
  326.  
  327. * CONVERT A SIGNED, WORD-SIZED, NUMBER IN BINARY, TO A DECIMAL STRING OF
  328. * ASCII CHARACTERS READY TO PRINT OUT. 
  329.  
  330. * The ascii result will be justified to the left, and padded out with
  331. * spaces on the right. Negative numbers will be prefixed with a minus sign.
  332.  
  333. * Requires an 8 byte buffer. A word sized, signed, number can have values
  334. * ranging from -32768 to +32767. That gives 5 digits, a possible minus sign
  335. * if it is negative, and a zero byte marking the end of the string to
  336. * be printed. (The eigth byte ensures a word boundry.)
  337.  
  338. * put the number to be printed into the low word of d0
  339. * put the address of the 7 byte buffer into a0
  340.  
  341. bins2dec
  342.  
  343. * set up the registers
  344.  
  345.     movem.l    a0-a1/d0-d4,-(sp)    save registers
  346.  
  347.     move.l    #decbuf,a0    address of buffer into a0    
  348. ;quicker to move a0 to a1
  349. ;    move.l    #decbuf,a1    address of buffer into a1
  350.     move.l    a0,a1
  351. ;MOVEQ IS QUICKER FOR A DATA REGISTER THAN CLR
  352.     moveq    #0,d1        counter - number of decimal digits
  353.     moveq    #0,d2        flag - leading zero found - d2=0
  354.     
  355. * is the number negative?
  356. ;REMEMBER D0 IS A WORD - SO CONVERT IT TO A LONG FIRST
  357. ;AFTER THAT DIV16 MAKES SURE IT IS EXTENDED TO A LONG
  358. ;    tst.w    d0        is d0 negative?
  359.     ext.l    d0        ;STILL SETS N BIT (TESTED BY BPL)
  360. ;SHORT JUMPS
  361.     bpl.s    calcdg        no, branch
  362.  
  363. * if so, negate d0 & put a minus sign first on the string
  364. ;NOTE
  365.     neg.L    d0        take d0 from 0. result in d0.
  366.     move.b    #"-",(a1)+    put the ascii for a minus sign in buffer
  367.     addq.b    #1,d1        inc number of digits counter
  368.     
  369. * now calculate the seperate digits
  370. ;SHORT JUMPS    
  371. calcdg    move.w    #10000,d3    d3 = the divisor
  372.     bsr.s    divs16        divide d0 by d3 and save ascii in buffer
  373.  
  374.     move.w    #1000,d3
  375.     bsr.s    divs16
  376.  
  377.     move.w    #100,d3
  378.     bsr.s    divs16    
  379.  
  380.     move.w    #10,d3
  381.     bsr.s    divs16    
  382.     
  383.     add.b    #'0',d0        convert the units digit to ascii
  384.     move.b    d0,(a1)+    always save the units digit
  385.     addq.b    #1,d1        inc number of digits
  386.  
  387.     cmpi.b    #6,d1        Has the number come up with 6 digits?
  388. ;SHORT JUMPS
  389.     beq.s    .end        Yes, branch. no spaces need to be added.
  390.     
  391. * add spaces
  392.  
  393.     move.w    #6,d3        d3 now holds the max number of digits
  394.     sub.w    d1,d3        take d1 from d3. d3 now holds number of spaces
  395.  
  396. .loop    move.b    #" ",(a1)+    put ascii for a space into buffer
  397.     subi.w    #1,d3        take one from number of spaces to be added
  398.     tst.w    d3        test d3 for zero, all spaces entered
  399. ;SHORT JUMPS
  400.     bne.s    .loop        if not zero, branch.
  401. ;USE CLR INSTEAD OF MOVE    
  402. .end    clr.b    (a1)+    put a terminating zero in the buffer
  403.     movem.l    (sp)+,a0-a1/d0-d4    restore registers
  404.     rts    
  405.  
  406. * divide a (long) number in d0 by a (word) number in d3 low word
  407. ;SHORT JUMPS    
  408. divs16    divu    d3,d0        unsigned division
  409.     move.w    d0,d4        save the answer to d4
  410.     clr.w    d0        set low word of d0 to 0
  411.     swap    d0        put the remainder into low word of d0
  412.     
  413.     tst.b    d2        test the leading zero flag
  414.     bne.s    svdig        branch if the flag is not zero
  415.     
  416.     tst.b    d4        test this digit for zero
  417.     beq.s    enddiv        yes, branch
  418.     addq.b    #1,d2        d4 not zero, so set the flag to say so
  419.  
  420. * save the number in d4 to the buffer as ascii
  421.  
  422. svdig    add.b    #'0',d4        make into ascii
  423.     move.b    d4,(a1)+    save ascii digit in buffer
  424.     addq.b    #1,d1        inc number of digits        
  425.  
  426. enddiv    rts
  427.  
  428. **************************************************************************
  429. ;BIG BOO BOO!
  430. ;THE PACKETS ARE BEING OVERWRITTEN EACH TIME THIS INTERRUPT IS CALLED!
  431. ;YOU NEED TO ADD THE X & Y HERE AND SUBTRACT IT WHEN YOU ADD IT TO YOUR VALUE!
  432. * My mouse data packet handler.
  433.  
  434. * called by the IKBD exception routine
  435. ;DON'T FORGET TO SAVE ALL REGISTERS USED!!!
  436. mhand
  437. ;***NOTE:
  438.     movem.l    d0/a0-a1,-(sp)
  439. ;NOT WORTH LOOPING FOR LESS THAN SAY 5 REALLY
  440. ;    move.b    #3,d0        d0=counter, 3 to 0
  441.     lea    mpack,a1    address of buffer to store packets (as words) in
  442.     move.b    (a0)+,d0    mouse button status byte
  443.     AND.W    #$3,d0        ;MANY CHOICES OF OPCODE BUT CLEAR DOWN TO
  444.                 ;BUTTON VALUES ONLY - 0=NONE/1=L/2=R/3=BOTH
  445.     MOVE.W    D0,(A1)+
  446.     MOVE.B    (A0)+,D0    ;X VALUE TO ADD TO EXISTING VALUES NOT YET DEALT WITH
  447.     EXT.W    D0        ;EXTEND IT TO SIGNED WORD
  448.     ADD.W    D0,(A1)+    ;IF POSITIVE IT ADDS, IF NEGATIVE IT SUBTRACTS!
  449.     MOVE.B    (A0)+,D0    ;Y VALUE TO ADD TO EXISTING VALUES NOT YET DEALT WITH
  450.     EXT.W    D0        ;EXTEND IT TO SIGNED WORD
  451.     ADD.W    D0,(A1)+    ;IF POSITIVE IT ADDS, IF NEGATIVE IT SUBTRACTS!
  452. ;***NOTE:
  453.     movem.l    (sp)+,d0/a0-a1
  454. ;ESPECIALLY USE SHORT JUMPS IN LOOPS LIKE THIS USED TO HAVE IN IT!
  455.     rts
  456.     
  457. *************************************************************************
  458.  
  459. * GET, (BUT DON'T EXAMINE), A KEYPRESS
  460.  
  461. * result returned as a word in 'scancode'
  462.  
  463. getscan
  464. ;ONLY NEED TO SAVE A0-A2/D0-D2 FOR GEMDOS!
  465.     movem.l    d0-d2/a0-a2,-(sp)    Save registers
  466.     move.w    #0,scancode        Ensure a null return unless a key is found
  467.     
  468. * has a key been pressed?
  469.  
  470.     move.w    #$0b,-(sp)    GEMDOS $0B - KEYBOARD BUFFER STATUS?
  471.     trap    #1        Result returned in d0.
  472. ;NOTE
  473.     addq.w    #2,sp
  474.  
  475.     tst.w    d0        d0.w=0, no keys pressed, -1 = yes
  476. ;SHORT JUMPS
  477.     beq.s    .end        no keypresses in buffer, so return
  478.     
  479. * yes, get it's scancode
  480.  
  481.     move.w    #$08,-(sp)    GEMDOS 8 - GET A KEYPRESS
  482.     trap    #1
  483. ;NOTE
  484.     addq.w    #2,sp
  485.  
  486.     swap    d0        put scancode into low word
  487.     move.w    d0,scancode    save the scancode for later
  488.  
  489. .end    
  490.     movem.l    (sp)+,d0-d2/a0-a2    restore registers
  491.     rts
  492.     
  493. ******************************************************************************
  494.  
  495. * print the messages
  496.  
  497. printmes
  498.  
  499. * set the cursor
  500.  
  501.     move.b    #5,cursx    set cursx
  502.     move.b    #3,cursy    set cursy
  503. ;USE BSR NOT JSR
  504.     bsr    setcurs        set the cursor position on screen
  505.  
  506. * print  message(04) 'using relative pakets'
  507.  
  508.     move.l    #mes04,-(sp)    address of message
  509.     move.w    #9,-(sp)    GEMDOS 9 - PRINT A STRING
  510.     trap    #1
  511. ;USE ADDQ.W FOR ADDRESS REGISTERS
  512. ;    addq.l    #6,sp
  513.     addq.w    #6,sp
  514. * set the cursor
  515.  
  516.     move.b    #5,cursx    set cursx
  517.     move.b    #5,cursy    set cursy
  518. ;USE BSR NOT JSR
  519.     bsr    setcurs        set the cursor position on screen
  520.  
  521. * print mes01 (x is)
  522.  
  523.     move.l    #mes01,-(sp)    address of string onto stack
  524.     move.w    #9,-(sp)    GEMDOS 9 - PRINT A STRING
  525.     trap    #1
  526. ;NOTE
  527.     addq.w    #6,sp
  528.  
  529. * set the cursor
  530.  
  531.     move.b    #5,cursx    set cursx
  532.     move.b    #7,cursy    set cursy
  533. ;NOTE
  534.     bsr    setcurs        set the cursor position on screen
  535.  
  536. * print mes02 (y is)
  537.  
  538.     move.l    #mes02,-(sp)    address of string onto stack
  539.     move.w    #9,-(sp)    GEMDOS 9 - PRINT A STRING
  540.     trap    #1
  541. ;NOTE
  542.     addq.w    #6,sp
  543.  
  544. * set the cursor
  545.  
  546.     move.b    #5,cursx    set cursx
  547.     move.b    #11,cursy    set cursy
  548. ;NOTE
  549.     bsr    setcurs        set the cursor position on screen
  550.  
  551. * print message(03) 'press esc'
  552.  
  553.     move.l    #mes03,-(sp)    address of message
  554.     move.w    #9,-(sp)    GEMDOS 9 - PRINT A STRING
  555.     trap    #1
  556. ;NOTE
  557.     addq.w    #6,sp
  558.  
  559.     rts
  560.  
  561. **************************************************************************
  562.  
  563. * restore values to the system before exiting
  564.  
  565. exit
  566.  
  567. * Restore the original IKBD mouse vector
  568.  
  569.     move.l    keyvectable,a0    address of start of table
  570. ;    move.l    oldmousevec,a1    address of original vector
  571. ;JUST SHOVE IT STRAIGHT INTO 16(A0)
  572. ;    move.l    a1,16(a0)    replace original vector in the table
  573.     move.l    oldmousevec,16(a0)
  574.  
  575. * restore the IKBD to relative mouse movement
  576.  
  577.     pea    ikcom03        address of IKbd COMmand 03 onto stack
  578. ;USE CLR
  579. ;    move.w    #0,-(sp)    length of command minus 1
  580.     clr.w    -(sp)
  581.     move.w    #25,-(sp)    function number
  582.     trap    #14        XBIOS 25 - SEND IKBD COMMAND
  583. ;    add.l    #8,sp        tidy
  584. ;USE QUICK FORM AND WORD LENGTH FOR ADDRESS REGISTERS
  585.     addq.w    #8,sp
  586.  
  587. * Return to the desktop
  588. ;USE CLR
  589. ;    move.w    #0,-(sp)    function number
  590.     clr.w    -(sp)
  591.     trap    #1        GEMDOS 0 - TERMinate
  592.     
  593. **************************************************************************
  594.  
  595. * Storeage areas.
  596.  
  597.     data
  598.     
  599. curspos        dc.b    27,'Y'        Escape command - set cursor
  600. cursy        dc.b    32
  601. cursx        dc.b    32
  602.         dc.b    0
  603.         
  604. ikcom01        dc.b    $09        IKBD command - set mouse absolute
  605.         dc.b    $01,$3f        xmax (319)
  606.         dc.b    $00,$c7        ymax (199)
  607. ikcom02        dc.b    $0b,2,2        IKBD command - set threshold
  608. ikcom03        dc.b    $08        IKBD command - set mouse relative
  609.  
  610. mes01        dc.b    '"MOUSEX" is : ',0    informative messages
  611. mes02        dc.b    '"MOUSEY" is : ',0
  612. mes03        dc.b    'Press <ESC> to exit...',0
  613. mes04        dc.b    'Using "relative" IKBD data packets.',0
  614.  
  615. textback0    dc.b    27,'c','0',0    escape strings to print. will set
  616. textback1    dc.b    27,'c','1',0    the background colour of printed
  617. textback2    dc.b    27,'c','2',0    text to the colour register noted.
  618. textback3    dc.b    27,'c','3',0
  619.     
  620.     bss
  621.     
  622. counter        ds.l    1    variable for a loop counter
  623. decbuf        ds.w    4    buffer for printing a signed number in dec
  624. keyvectable    ds.l    1    address of the keyboard vector table
  625. mousex        ds.w    1    mouse pointer reference
  626. mousey        ds.w    1    mouse pointer reference
  627. mpack        ds.W    3    buffer to store mouse UNpackED data
  628.                 ;BUTTONS.W,X.W AND Y.W
  629. oldmousevec    ds.l    1    address of original mouse packet handler
  630. random        ds.w    1    store for random numbers
  631. scancode    ds.w    1    scancode of a keypress
  632.  
  633.  
  634.  
  635.