home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 26 / AACD 26.iso / AACD / Programming / ace_gpl_release / src / lib / asm / csrpos.s < prev    next >
Encoding:
Text File  |  1998-10-04  |  1.9 KB  |  91 lines

  1. ;
  2. ; csrpos.s -- an ACE linked library module: CSRLIN and POS.
  3. ; Copyright (C) 1998 David Benn
  4. ; This program is free software; you can redistribute it and/or
  5. ; modify it under the terms of the GNU General Public License
  6. ; as published by the Free Software Foundation; either version 2
  7. ; of the License, or (at your option) any later version.
  8. ;
  9. ; This program is distributed in the hope that it will be useful,
  10. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. ; GNU General Public License for more details.
  13. ;
  14. ; You should have received a copy of the GNU General Public License
  15. ; along with this program; if not, write to the Free Software
  16. ; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  17. ;
  18. ; Author: David J Benn
  19. ;   Date: 19th March 1994
  20. ;
  21. ; registers d0-d6 and a0-a3 are modified by some of the following. BEWARE!
  22. ;
  23. ; a4,a5 are used by link/unlk.
  24. ; a6 is library base holder.
  25. ; a7 is stack pointer. 
  26. ; d7 is used for array index calculations.
  27. ;
  28.  
  29. ; * CONSTANTS *
  30.  
  31. cp_x        equ    36
  32. cp_y        equ    38
  33. Font        equ    52
  34. tf_YSize    equ    20
  35. tf_XSize    equ    24
  36.     
  37.     ; functions
  38.     xdef    _pos
  39.     xdef    _csrlin
  40.     
  41.        ; external references
  42.     xref    _IntuiMode
  43.     xref    _RPort
  44.  
  45.     SECTION csrpos_code,CODE
  46.  
  47. ;
  48. ; POS - returns the cursor's column for the current screen.
  49. ;
  50. _pos:
  51.     cmpi.b    #1,_IntuiMode
  52.     beq.s    _dopos
  53.  
  54.     ; in a window, so return zero
  55.     moveq    #0,d0
  56.     rts
  57.     
  58. _dopos:
  59.     movea.l    _RPort,a0
  60.     move.w    cp_x(a0),d0
  61.     ext.l    d0
  62.     movea.l    Font(a0),a0
  63.     move.w    tf_XSize(a0),d1
  64.     divu    d1,d0
  65.     addq    #1,d0    ; COLUMN = x/font width + 1            
  66.     rts            
  67.  
  68. ;
  69. ; CSRLIN - returns the cursor's line for the current screen.
  70. ;
  71. _csrlin:
  72.     cmpi.b    #1,_IntuiMode
  73.     beq.s    _docsrlin
  74.  
  75.     ; in a window, so return zero
  76.     moveq    #0,d0
  77.     rts
  78.  
  79. _docsrlin:
  80.     movea.l    _RPort,a0
  81.     move.w    cp_y(a0),d0
  82.     ext.l    d0
  83.     movea.l    Font(a0),a0
  84.     move.w    tf_YSize(a0),d1
  85.     addq    #2,d0
  86.     divu    d1,d0    ; LINE = (y+2)/font height
  87.     rts
  88.  
  89.     END
  90.