home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgLangD.iso / Assembly / CURSOR18.ASM < prev    next >
Assembly Source File  |  1986-09-24  |  3KB  |  129 lines

  1. CR        EQU    13        ;Carriage return
  2. LF        EQU    10        ;Line feed
  3.  
  4. CGROUP    GROUP    CODE_SEG
  5.     ASSUME    CS:CGROUP
  6.  
  7. CODE_SEG    SEGMENT PUBLIC
  8.  
  9.     PUBLIC    CLEAR_SCREEN
  10. ;-----------------------------------------------------------------------;
  11. ; This procedure clears the entire screen.                ;
  12. ;-----------------------------------------------------------------------;
  13. CLEAR_SCREEN    PROC    NEAR
  14.     PUSH    AX
  15.     PUSH    BX
  16.     PUSH    CX
  17.     PUSH    DX
  18.     XOR    AL,AL            ;Blank entire window
  19.     XOR    CX,CX            ;Upper left corner is at (0,0)
  20.     MOV    DH,24            ;Bottom line of screen is line 24
  21.     MOV    DL,79            ;Right side is at column 79
  22.     MOV    BH,7            ;Use normal attribute for blanks
  23.     MOV    AH,6            ;Call for SCROLL-UP function
  24.     INT    10h            ;Clear the window
  25.     POP    DX
  26.     POP    CX
  27.     POP    BX
  28.     POP    AX
  29.     RET
  30. CLEAR_SCREEN    ENDP
  31.  
  32.  
  33.     PUBLIC    GOTO_XY
  34. ;-----------------------------------------------------------------------;
  35. ; This procedure moves the cursor                    ;
  36. ;                                    ;
  37. ;    DH    Row (Y)                            ;
  38. ;    DL    Column (X)                        ;
  39. ;-----------------------------------------------------------------------;
  40. GOTO_XY        PROC    NEAR
  41.     PUSH    AX
  42.     PUSH    BX
  43.     MOV    BH,0            ;Display page 0
  44.     MOV    AH,2            ;Call for SET CURSOR POSITION
  45.     INT    10h
  46.     POP    BX
  47.     POP    AX
  48.     RET
  49. GOTO_XY        ENDP
  50.  
  51.     PUBLIC    CURSOR_RIGHT
  52. ;-----------------------------------------------------------------------;
  53. ; This procedure moves the cursor one position to the right or to the    ;
  54. ; next line if the cursor was at the end of a line.            ;
  55. ;                                    ;
  56. ; Uses:        SEND_CRLF                        ;
  57. ;-----------------------------------------------------------------------;
  58. CURSOR_RIGHT    PROC    NEAR
  59.     PUSH    AX
  60.     PUSH    BX
  61.     PUSH    CX
  62.     PUSH    DX
  63.     MOV    AH,3            ;Read the current cursor position
  64.     MOV    BH,0            ;On page 0
  65.     INT    10h            ;Read cursor position
  66.     MOV    AH,2            ;Set new cursor position
  67.     INC    DL            ;Set column to next position
  68.     CMP    DL,79            ;Make sure column <= 79
  69.     JBE    OK
  70.     CALL    SEND_CRLF        ;Go to next line
  71.     JMP    DONE
  72. OK:    INT    10h
  73. DONE:    POP    DX
  74.     POP    CX
  75.     POP    BX
  76.     POP    AX
  77.     RET
  78. CURSOR_RIGHT    ENDP
  79.  
  80.     PUBLIC    CLEAR_TO_END_OF_LINE
  81. ;-----------------------------------------------------------------------;
  82. ; This procedure clears the line from the current cursor position to    ;
  83. ; the end of that line.                            ;
  84. ;-----------------------------------------------------------------------;
  85. CLEAR_TO_END_OF_LINE    PROC    NEAR
  86.     PUSH    AX
  87.     PUSH    BX
  88.     PUSH    CX
  89.     PUSH    DX
  90.     MOV    AH,3            ;Read current cursor position
  91.     XOR    BH,BH            ; on page 0
  92.     INT    10h            ;Now have (X,Y) in DL, DH
  93.     MOV    AH,6            ;Set up to clear to end of line
  94.     XOR    AL,AL            ;Clear window
  95.     MOV    CH,DH            ;All on same line
  96.     MOV    CL,DL            ;Start at the cursor position
  97.     MOV    DL,79            ;And stop at the end of the line
  98.     MOV    BH,7            ;Use normal attribute
  99.     INT    10h
  100.     POP    DX
  101.     POP    CX
  102.     POP    BX
  103.     POP    AX
  104.     RET
  105. CLEAR_TO_END_OF_LINE    ENDP
  106.  
  107.     PUBLIC    SEND_CRLF
  108. ;-----------------------------------------------------------------------;
  109. ; This routine just sends a carriage return-line feed pair to the    ;
  110. ; display, using the DOS routines so that scrolling will be handled    ;
  111. ; correctly.                                ;
  112. ;-----------------------------------------------------------------------;
  113. SEND_CRLF    PROC    NEAR
  114.     PUSH    AX
  115.     PUSH    DX
  116.     MOV    AH,2
  117.     MOV    DL,CR
  118.     INT    21h
  119.     MOV    DL,LF
  120.     INT    21h
  121.     POP    DX
  122.     POP    AX
  123.     RET
  124. SEND_CRLF    ENDP
  125.  
  126. CODE_SEG    ENDS
  127.  
  128.     END
  129.