home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgLangD.iso / Assembly / PHANTO21.ASM < prev    next >
Assembly Source File  |  1986-09-25  |  5KB  |  174 lines

  1. CGROUP    GROUP    CODE_SEG, DATA_SEG
  2.     ASSUME    CS:CGROUP, DS:CGROUP
  3.  
  4.  
  5. CODE_SEG    SEGMENT PUBLIC
  6.  
  7.     PUBLIC    MOV_TO_HEX_POSITION
  8.     EXTRN    GOTO_XY:NEAR
  9. DATA_SEG    SEGMENT PUBLIC
  10.     EXTRN    LINES_BEFORE_SECTOR:BYTE
  11. DATA_SEG    ENDS
  12. ;-----------------------------------------------------------------------;
  13. ; This procedure moves the real cursor to the position of the phantom    ;
  14. ; cursor in the hex window.                        ;
  15. ;                                    ;
  16. ; Uses:        GOTO_XY                            ;
  17. ; Reads:    LINES_BEFORE_SECTOR, PHANTOM_CURSOR_X, PHANTOM_CURSOR_Y    ;
  18. ;-----------------------------------------------------------------------;
  19. MOV_TO_HEX_POSITION    PROC    NEAR
  20.     PUSH    AX
  21.     PUSH    CX
  22.     PUSH    DX
  23.     MOV    DH,LINES_BEFORE_SECTOR    ;Find row of phantom (0,0)
  24.     ADD    DH,2            ;Plus row of hex and horizontal bar
  25.     ADD    DH,PHANTOM_CURSOR_Y    ;DH = row of phantom cursor
  26.     MOV    DL,8            ;Indent on left side
  27.     MOV    CL,3            ;Each column uses 3 characters,so
  28.     MOV    AL,PHANTOM_CURSOR_X    ; we must multiply CURSOR_X by 3
  29.     MUL    CL
  30.     ADD    DL,AL            ;And add to the indent, to get column
  31.     CALL    GOTO_XY            ; for phantom cursor
  32.     POP    DX
  33.     POP    CX
  34.     POP    AX
  35.     RET
  36. MOV_TO_HEX_POSITION    ENDP
  37.  
  38.     PUBLIC    MOV_TO_ASCII_POSITION
  39.     EXTRN    GOTO_XY:NEAR
  40. DATA_SEG    SEGMENT PUBLIC
  41.     EXTRN    LINES_BEFORE_SECTOR:BYTE
  42. DATA_SEG    ENDS
  43. ;-----------------------------------------------------------------------;
  44. ; This procedure moves the real cursor to the beginning of the phantom    ;
  45. ; cursor in the ASCII window.                        ;
  46. ;                                    ;
  47. ; Uses:        GOTO_XY                            ;
  48. ; Reads:    LINES_BEFORE_SECTOR, PHANTOM_CURSOR_X, PHANTOM_CURSOR_Y    ;
  49. ;-----------------------------------------------------------------------;
  50. MOV_TO_ASCII_POSITION    PROC    NEAR
  51.     PUSH    AX
  52.     PUSH    DX
  53.     MOV    DH,LINES_BEFORE_SECTOR    ;Find row of phantom (0,0)
  54.     ADD    DH,2            ;Plus row of hex and horizontal bar
  55.     ADD    DH,PHANTOM_CURSOR_Y    ;DH = row of phantom cursor
  56.     MOV    DL,59            ;Indent on left side
  57.     ADD    DL,PHANTOM_CURSOR_X    ;Add CURSOR_X to get X position
  58.     CALL    GOTO_XY            ; for phantom cursor
  59.     POP    DX
  60.     POP    AX
  61.     RET
  62. MOV_TO_ASCII_POSITION    ENDP
  63.  
  64.     PUBLIC    SAVE_REAL_CURSOR
  65. ;-----------------------------------------------------------------------;
  66. ; This procedure saves the position of the real cursor in the two    ;
  67. ; variables REAL_CURSOR_X and REAL_CURSOR_Y.                ;
  68. ;                                    ;
  69. ; Writes:    REAL_CURSOR_X, REAL_CURSOR_Y                ;
  70. ;-----------------------------------------------------------------------;
  71. SAVE_REAL_CURSOR    PROC    NEAR
  72.     PUSH    AX
  73.     PUSH    BX
  74.     PUSH    CX
  75.     PUSH    DX
  76.     MOV    AH,3            ;Read cursor position
  77.     XOR    BH,BH            ; on page 0
  78.     INT    10h            ;And return in DL,DH
  79.     MOV    REAL_CURSOR_Y,DL    ;Save position
  80.     MOV    REAL_CURSOR_X,DH
  81.     POP    DX
  82.     POP    CX
  83.     POP    BX
  84.     POP    AX
  85.     RET
  86. SAVE_REAL_CURSOR    ENDP
  87.  
  88.     PUBLIC    RESTORE_REAL_CURSOR
  89.     EXTRN    GOTO_XY:NEAR
  90. ;-----------------------------------------------------------------------;
  91. ; This procedure restorest he real cursor to its old position, saved in    ;
  92. ; REAL_CURSOR_X and REAL_CURSOR_Y.                    ;
  93. ;                                    ;
  94. ; Uses:        GOTO_XY                            ;
  95. ; Reads:    REAL_CURSOR_X, REAL_CURSOR_Y                ;
  96. ;-----------------------------------------------------------------------;
  97. RESTORE_REAL_CURSOR    PROC    NEAR
  98.     PUSH    DX
  99.     MOV    DL,REAL_CURSOR_Y
  100.     MOV    DH,REAL_CURSOR_X
  101.     CALL    GOTO_XY
  102.     POP    DX
  103.     RET
  104. RESTORE_REAL_CURSOR    ENDP
  105.  
  106.     PUBLIC    WRITE_PHANTOM
  107.     EXTRN    WRITE_ATTRIBUTE_N_TIMES:NEAR
  108. ;-----------------------------------------------------------------------;
  109. ; This procedure uses CURSOR_X and CURSOR_Y, through MOV_TO_..., as the    ;
  110. ; coordinates for the phantom cursor.  WRITE_PHANTOM writes this    ;
  111. ; phantom cursor.                            ;
  112. ;                                    ;
  113. ; Uses:        WRITE_ATTRIBUTE_N_TIMES, SAVE_REAL_CURSOR        ;
  114. ;        RESTORE_REAL_CURSOR, MOV_TO_HEX_POSITION        ;
  115. ;        MOV_TO_ASCII_POSITION                    ;
  116. ;-----------------------------------------------------------------------;
  117. WRITE_PHANTOM    PROC    NEAR
  118.     PUSH    CX
  119.     PUSH    DX
  120.     CALL    SAVE_REAL_CURSOR
  121.     CALL    MOV_TO_HEX_POSITION    ;Coord. of cursor in hex window
  122.     MOV    CX,4            ;Make phantom cursor four chars wide
  123.     MOV    DL,70h
  124.     CALL    WRITE_ATTRIBUTE_N_TIMES
  125.     CALL    MOV_TO_ASCII_POSITION    ;Coord. of cursor in ASCII window
  126.     MOV    CX,1            ;Cursor is one character wide here
  127.     CALL    WRITE_ATTRIBUTE_N_TIMES
  128.     CALL    RESTORE_REAL_CURSOR
  129.     POP    DX
  130.     POP    CX
  131.     RET
  132. WRITE_PHANTOM    ENDP
  133.  
  134.     PUBLIC    ERASE_PHANTOM
  135.     EXTRN    WRITE_ATTRIBUTE_N_TIMES:NEAR
  136. ;-----------------------------------------------------------------------;
  137. ; This procedure erases the phantom cursor, just the opposite of    ;
  138. ; WRITE_PHANTOM.                            ;
  139. ;                                    ;
  140. ; Uses:        WRITE_ATTRIBUTE_N_TIMES, SAVE_REAL_CURSOR        ;
  141. ;        RESTORE_REAL_CURSOR, MOV_TO_HEX_POSITION        ;
  142. ;        MOV_TO_ASCII_POSITION                    ;
  143. ;-----------------------------------------------------------------------;
  144. ERASE_PHANTOM    PROC    NEAR
  145.     PUSH    CX
  146.     PUSH    DX
  147.     CALL    SAVE_REAL_CURSOR
  148.     CALL    MOV_TO_HEX_POSITION    ;Coord. of cursor in hex window
  149.     MOV    CX,4            ;Change back to white on black
  150.     MOV    DL,7
  151.     CALL    WRITE_ATTRIBUTE_N_TIMES
  152.     CALL    MOV_TO_ASCII_POSITION
  153.     MOV    CX,1
  154.     CALL    WRITE_ATTRIBUTE_N_TIMES
  155.     CALL    RESTORE_REAL_CURSOR
  156.     POP    DX
  157.     POP    CX
  158.     RET
  159. ERASE_PHANTOM    ENDP
  160.  
  161. CODE_SEG    ENDS
  162.  
  163.  
  164. DATA_SEG    SEGMENT PUBLIC
  165. REAL_CURSOR_X        DB    0
  166. REAL_CURSOR_Y        DB    0
  167.     PUBLIC    PHANTOM_CURSOR_X, PHANTOM_CURSOR_Y
  168. PHANTOM_CURSOR_X    DB    0
  169. PHANTOM_CURSOR_Y    DB    0
  170. DATA_SEG    ENDS
  171.  
  172.  
  173.     END
  174.