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

  1. CUR_X        EQU    -$158    ;current x pointer (restricted by screen res)
  2. CUR_Y        EQU    -$156    ;current y pointer
  3.  
  4. start        dc.w    $a000
  5. ;This is an 'illegal' instruction that generates a Line A Trap
  6. ;It is used to call Line A subroutines like TRAP #1 calls GEMDOS
  7. ;the last digit decides which routine is called
  8. ;This instruction returns a pointer to a table of values in a0
  9. ;These values are stored both before and after this pointer
  10.         move.l    a0,A_Table
  11.         
  12. check_key    
  13.         move.w    #$b,-(sp)
  14.         trap    #1        ;exit on any key
  15.         addq.w    #2,sp
  16.         tst.l    d0
  17.         bne.s    end_prog
  18.         
  19. ;show_position    
  20.         move.l    A_Table,a6    ;pointer to table of values
  21.         move.w    CUR_X(a6),d0
  22.         ext.l    d0
  23.         move.l    #mouse_x_str,a0
  24.         move.l    #$20202020,(a0)    ;put spaces in string
  25.         bsr.s    Dec_str    
  26.         move.w    CUR_Y(a6),d0
  27.         ext.l    d0
  28.         move.l    #mouse_y_str,a0
  29.         move.l    #$20202020,(a0)    ;put spaces in string
  30.         bsr.s    Dec_str    
  31.  
  32. ;write_string
  33.         pea    mouse_string
  34.         move.w    #9,-(sp)
  35.         trap    #1
  36.         addq.w    #6,sp
  37.  
  38.         bra.s    check_key
  39.         
  40. end_prog    move.w    #1,-(sp)
  41.         trap    #1
  42.         addq.w    #2,sp        ;get detected key
  43.         clr.w    -(sp)
  44.         trap    #1                
  45.         
  46.         DATA
  47. mouse_string    dc.b    27,'H',"Mouse X: "
  48. mouse_x_str    dc.b    "           "
  49.         dc.b    " Mouse Y: "
  50. mouse_y_str    dc.b    "           ",0
  51.         even        
  52.         BSS
  53. A_Table        ds.l    1    ;Pointer to Line A Table of values
  54.  
  55. ;***************************************************************************
  56. ;LIBRARY ROUTINE
  57.  
  58.         TEXT
  59. ;Convert Signed Long into Decimal String
  60. ;ENTRY:    A0 = Address to put string into
  61. ;    D0 = Value to Convert
  62. ;EXIT:    A0 = Address of first byte after converted string
  63. ;USES:    d0-d2/a0
  64.  
  65. ;Note: Does not terminate string and could use 1-11 digits (bytes)
  66.  
  67. Dec_str    moveq    #0,d1
  68.     moveq    #0,d2    ;byte set when first digit is not zero
  69.     tst.l    d0    ;check for plus or minus
  70.     bpl.s    .pos
  71.     neg.l    d0
  72.     move.b    #'-',(a0)+
  73. .pos    addq.b    #1,d1
  74.     sub.l    #1000000000,d0
  75.     bpl.s    .pos
  76.     subq.b    #1,d1
  77.     add.l    #1000000000,d0
  78.     tst.b    d1        ;skip if zero
  79.     beq.s    .e8
  80.     st    d2        ;first digit not zero
  81.     add.b    #'0',d1
  82.     move.b    d1,(a0)+
  83.     moveq    #0,d1
  84. .e8    addq.b    #1,d1
  85.     sub.l    #100000000,d0
  86.     bpl.s    .e8
  87.     subq.b    #1,d1
  88.     add.l    #100000000,d0
  89.     tst.b    d1        ;skip if zero
  90.     beq.s    .e7
  91.     st    d2        ;first digit not zero
  92.     add.b    #'0',d1
  93.     move.b    d1,(a0)+
  94.     moveq    #0,d1
  95. .e7    addq.b    #1,d1
  96.     sub.l    #10000000,d0
  97.     bpl.s    .e7
  98.     subq.b    #1,d1
  99.     add.l    #10000000,d0
  100.     tst.b    d1        ;skip if zero
  101.     beq.s    .e6
  102.     st    d2        ;first digit not zero
  103.     add.b    #'0',d1
  104.     move.b    d1,(a0)+
  105.     moveq    #0,d1
  106. .e6    addq.b    #1,d1
  107.     sub.l    #1000000,d0
  108.     bpl.s    .e6
  109.     subq.b    #1,d1
  110.     add.l    #1000000,d0
  111.     tst.b    d1        ;skip if zero
  112.     beq.s    .e5
  113.     st    d2        ;first digit not zero
  114.     add.b    #'0',d1
  115.     move.b    d1,(a0)+
  116.     moveq    #0,d1
  117. .e5    addq.b    #1,d1
  118.     sub.l    #100000,d0
  119.     bpl.s    .e5
  120.     subq.b    #1,d1
  121.     add.l    #100000,d0
  122.     tst.b    d1        ;skip if zero
  123.     beq.s    .e4
  124.     st    d2        ;first digit not zero
  125.     add.b    #'0',d1
  126.     move.b    d1,(a0)+
  127.     moveq    #0,d1        ;small enough for divu now
  128. .e4    divu    #10000,d0
  129.     tst.b    d0
  130.     beq.s    .e3
  131.     st    d2
  132.     add.b    #'0',d0
  133.     move.b    d0,(a0)+
  134. .e3    clr.w    d0        ;word only clear
  135.     swap    d0        ;remainder
  136.     divu    #1000,d0
  137.     tst.b    d0
  138.     beq.s    .e2
  139.     st    d2
  140.     add.b    #'0',d0
  141.     move.b    d0,(a0)+
  142. .e2    clr.w    d0
  143.     swap    d0        ;remainder
  144.     divu    #100,d0
  145.     tst.b    d0
  146.     beq.s    .e1
  147.     st    d2
  148.     add.b    #'0',d0
  149.     move.b    d0,(a0)+
  150. .e1    clr.w    d0
  151.     swap    d0        ;remainder
  152.     divu    #10,d0
  153.     tst.b    d0
  154.     beq.s    .e0
  155.     st    d2
  156.     add.b    #'0',d0
  157.     move.b    d0,(a0)+
  158. .e0    clr.w    d0
  159.     swap    d0        ;remainder
  160.     add.b    #'0',d0
  161.     move.b    d0,(a0)+
  162.     rts
  163.