home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / CLIPPER / MISC / ISCURSOR.ZIP / ISCURSOR.ASM < prev    next >
Encoding:
Assembly Source File  |  1988-06-18  |  5.5 KB  |  117 lines

  1.     PAGE    60,132
  2.     TITLE   ISCURSOR - Cursor on or off function for Clipper s'87
  3. ; Clipper S'87 function to test if the cursor is ON or OFF
  4. ; Entered into the Public Domain. Use at your own risk.
  5. ; Assembled with Microsift MASM  4.0
  6. ;
  7. ;  I would like to thank any and all of my fellow Clipper users who
  8. ;  share their work via NANSIG.  I was motivated to write this function
  9. ;  after incorporating some of the HELP and RULER PROC's and FUNCTIONS
  10. ;  into my applications.  If they are called from a MENU wait state
  11. ;  (when the cursor is OFF), they return with the cursor ON, a small
  12. ;  problem, but unsightly none the less.  This small function can be
  13. ;  used to test for the cursor state on entry into these procs, and
  14. ;  the result used to set the cursor on exit.
  15. ;
  16. ;  John Scott Prinke 6/14/88    Source: BFH594
  17. ;
  18. ; DISCUSSION:
  19. ;  Memory at 0000:0461 stores the starting scan
  20. ;  line of the cursor.  ( 0460 stores starting scan line)
  21. ;
  22. ;  IF the cursor is ON, starting scan line is 06H for CGA,
  23. ;                       0BH for EGA and Monochrome
  24. ;  Clipper seems to use the CGA mode for EGA displays.
  25. ;  IF the cursor is OFF, the starting scan line is 20H.
  26. ;
  27. ;  You can test this with DEBUG by writing a one liner in Clipper
  28. ;        SET CURSOR OFF
  29. ;  compiling, linking, and running it.
  30. ;  Then enter DEBUG, and at the -prompt, type "d 0000:0450".
  31. ;    The eight 2 byte words on the 0450 line are the hex number
  32. ;    columns and rows for the location of the cursor on the eight
  33. ;    respective text video pages.  If Clipper removed the cursor
  34. ;    by placing it off the page, these bytes would show it.  What
  35. ;    they show is the location of the cursor (if it was on) when you
  36. ;    typed the -d 0000:0450 command into debug.  Only the first (active)
  37. ;    video page shows a cursor location if your computer is anything
  38. ;    like mine.  Remember, they are in hex, or Base16 notation.
  39. ;
  40. ;  The first two hex bytes on the 0460 line are the starting and
  41. ;    ending scan lines for the cursor.  WHen the cursor is ON my EGA
  42. ;    (and CGA) read 07 06, for a typical vanilla cursor.  I have not tested
  43. ;    Monochrome or VGA's, but I would expect 0C 0B for the Monochrome.
  44. ;    When the cursor is OFF, I read 00 20.
  45. ;
  46. ;  By reading the memory at 0461, and comparing it to 20, this function
  47. ;    could return logical .T. or .F. for ON and OFF respectively.
  48. ;
  49. ;  Instead, I used the BIOS VIDEO SERVICE 3 to get the same information,
  50. ;  hopefully maintaining some "good programming practices."  Video
  51. ;  Service 3 : Read Cursor Position provides the starting and ending
  52. ;  scan lines, and the column and row of the cursor for the video page
  53. ;  identified in the BH register when it is called.  For this function,
  54. ;  all I need is the CH register, the starting scan line.
  55. ;
  56. ;
  57. ;
  58. ;  Reference  PROGRAMMER'S GUIDE TO THE IBM PC, 1985
  59. ;             PETER NORTON
  60. ;             pp 174-176, 92, 55
  61.  
  62.         PUBLIC  ISCURSOR           ; NAME OF FUNCTION AS PUBLIC
  63.         EXTRN  __RETL:FAR          ; DECLARE CALLED FUNCTIONS EXTERNAL
  64.                                    ; external function from Clipper
  65.                                    ;   allowing return of Logical parm
  66.  
  67.   DGROUP GROUP         DATASG              ;Clipper's Data Segment
  68.   DATASG SEGMENT       PUBLIC '_DATA'
  69.  
  70.   DATASG               ENDS
  71.  
  72.   _PROG                SEGMENT  'CODE'
  73.                        ASSUME     CS:_PROG,DS:DGROUP,ES:DGROUP
  74.  
  75.   ;------------------- Save Current Registers Values -----------------
  76.  
  77.   ISCURSOR    PROC       FAR
  78.               PUSH       BP              ; Save stack
  79.               MOV        BP,SP
  80.               PUSH       DS
  81.               PUSH       ES
  82.               PUSH       SI
  83.               PUSH       DI
  84. ;-------------------  BIOS call  -------------------------------------
  85. ; BIOS CALL
  86.         MOV AH, 3                   ;  VIDEO SERVICE 3
  87.         MOV BH, 0                   ;  VIDEO PAGE 0 - FIRST (ACTIVE) PAGE
  88.         INT 10H                     ;  VIDEO BIOS REQUEST
  89.                                     ; returns start scan line - CH
  90.                                     ; returns end scan line   - CL
  91.                                     ; returns cursor row      - DH
  92.                                     ; returns cursor colum    - DL
  93. ;------------------  Determine logical return value -------------------
  94.         MOV BX, 0001H               ; START OUT AS TRUE, CHANGE IF FALSE
  95.         CMP CH, 20H                 ; COMPARE WITH 20H (CURSOR OFF)
  96.         JNE ISCURSOR_RET            ; JUMP OVER LOGICAL RESET IF CURSOR ON
  97.         MOV BX, 0000H               ; RESET LOGIC TO .F. IF CURSOR OFF
  98.  
  99.   ;------------------- Restore Registers and Return ------------------
  100.  
  101.   ISCURSOR_RET:
  102.         POP  DI                ; Restore Stack
  103.         POP  SI
  104.         POP  ES
  105.         POP  DS
  106.         POP  BP
  107.         ;
  108.         PUSH BX               ; push logical value onto stack
  109.         CALL __RETL           ; return it to Clipper
  110.         ADD SP,2              ; increment stack pointer
  111.         RET
  112.  
  113.   ISCURSOR   ENDP             ; Function ends
  114.   _PROG      ENDS             ; Code segment ends
  115.   END                         ; program
  116.  
  117.