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

  1. CGROUP    GROUP    CODE_SEG, DATA_SEG
  2.     ASSUME    CS:CGROUP, DS:CGROUP
  3.  
  4.  
  5. CODE_SEG    SEGMENT PUBLIC
  6.  
  7. ;-----------------------------------------------------------------------;
  8. ; These four procedures move the phantom cursors.            ;
  9. ;                                    ;
  10. ; Uses:        ERASE_PHANTOM, WRITE_PHANTOM                ;
  11. ; Reads:    PHANTOM_CURSOR_X, PHANTOM_CURSOR_Y            ;
  12. ; Writes:    PHANTOM_CURSOR_X, PHANTOM_CURSOR_Y            ;
  13. ;-----------------------------------------------------------------------;
  14.  
  15.     PUBLIC    PHANTOM_UP
  16. PHANTOM_UP    PROC    NEAR
  17.     CALL    ERASE_PHANTOM        ;Erase at current position
  18.     DEC    PHANTOM_CURSOR_Y    ;Move cursor up one line
  19.     JNS    WASNT_AT_TOP        ;Was not at the top, write cursor
  20.     MOV    PHANTOM_CURSOR_Y,0    ;Was at the top, so put back there
  21. WASNT_AT_TOP:
  22.     CALL    WRITE_PHANTOM        ;Write the phantom at new position
  23.     RET
  24. PHANTOM_UP    ENDP
  25.  
  26.     PUBLIC    PHANTOM_DOWN
  27. PHANTOM_DOWN    PROC    NEAR
  28.     CALL    ERASE_PHANTOM        ;Erase at current position
  29.     INC    PHANTOM_CURSOR_Y    ;Move cursor down one line
  30.     CMP    PHANTOM_CURSOR_Y,16    ;Was it at the bottom?
  31.     JB    WASNT_AT_BOTTOM        ;No, so write phantom
  32.     MOV    PHANTOM_CURSOR_Y,15    ;Was at bottom, so put back there
  33. WASNT_AT_BOTTOM:
  34.     CALL    WRITE_PHANTOM        ;Write the phantom cursor
  35.     RET
  36. PHANTOM_DOWN    ENDP
  37.  
  38.     PUBLIC    PHANTOM_LEFT
  39. PHANTOM_LEFT    PROC    NEAR
  40.     CALL    ERASE_PHANTOM        ;Erase at current position
  41.     DEC    PHANTOM_CURSOR_X    ;Move cursor left one column
  42.     JNS    WASNT_AT_LEFT        ;Was not at the left side, write cursor
  43.     MOV    PHANTOM_CURSOR_X,0    ;Was at left, so put back there
  44. WASNT_AT_LEFT:
  45.     CALL    WRITE_PHANTOM        ;Write the phantom cursor
  46.     RET
  47. PHANTOM_LEFT    ENDP
  48.  
  49.     PUBLIC    PHANTOM_RIGHT
  50. PHANTOM_RIGHT    PROC    NEAR
  51.     CALL    ERASE_PHANTOM        ;Erase at current position
  52.     INC    PHANTOM_CURSOR_X    ;Move cursor right one column
  53.     CMP    PHANTOM_CURSOR_X,16    ;Was it already at the right side?
  54.     JB    WASNT_AT_RIGHT
  55.     MOV    PHANTOM_CURSOR_X,15    ;Was at right, so put back there
  56. WASNT_AT_RIGHT:
  57.     CALL    WRITE_PHANTOM        ;Write the phantom cursor
  58.     RET
  59. PHANTOM_RIGHT    ENDP
  60.  
  61.  
  62.  
  63.     PUBLIC    MOV_TO_HEX_POSITION
  64.     EXTRN    GOTO_XY:NEAR
  65. DATA_SEG    SEGMENT PUBLIC
  66.     EXTRN    LINES_BEFORE_SECTOR:BYTE
  67. DATA_SEG    ENDS
  68. ;-----------------------------------------------------------------------;
  69. ; This procedure moves the real cursor to the position of the phantom    ;
  70. ; cursor in the hex window.                        ;
  71. ;                                    ;
  72. ; Uses:        GOTO_XY                            ;
  73. ; Reads:    LINES_BEFORE_SECTOR, PHANTOM_CURSOR_X, PHANTOM_CURSOR_Y    ;
  74. ;-----------------------------------------------------------------------;
  75. MOV_TO_HEX_POSITION    PROC    NEAR
  76.     PUSH    AX
  77.     PUSH    CX
  78.     PUSH    DX
  79.     MOV    DH,LINES_BEFORE_SECTOR    ;Find row of phantom (0,0)
  80.     ADD    DH,2            ;Plus row of hex and horizontal bar
  81.     ADD    DH,PHANTOM_CURSOR_Y    ;DH = row of phantom cursor
  82.     MOV    DL,8            ;Indent on left side
  83.     MOV    CL,3            ;Each column uses 3 characters,so
  84.     MOV    AL,PHANTOM_CURSOR_X    ; we must multiply CURSOR_X by 3
  85.     MUL    CL
  86.     ADD    DL,AL            ;And add to the indent, to get column
  87.     CALL    GOTO_XY            ; for phantom cursor
  88.     POP    DX
  89.     POP    CX
  90.     POP    AX
  91.     RET
  92. MOV_TO_HEX_POSITION    ENDP
  93.  
  94.     PUBLIC    MOV_TO_ASCII_POSITION
  95.     EXTRN    GOTO_XY:NEAR
  96. DATA_SEG    SEGMENT PUBLIC
  97.     EXTRN    LINES_BEFORE_SECTOR:BYTE
  98. DATA_SEG    ENDS
  99. ;-----------------------------------------------------------------------;
  100. ; This procedure moves the real cursor to the beginning of the phantom    ;
  101. ; cursor in the ASCII window.                        ;
  102. ;                                    ;
  103. ; Uses:        GOTO_XY                            ;
  104. ; Reads:    LINES_BEFORE_SECTOR, PHANTOM_CURSOR_X, PHANTOM_CURSOR_Y    ;
  105. ;-----------------------------------------------------------------------;
  106. MOV_TO_ASCII_POSITION    PROC    NEAR
  107.     PUSH    AX
  108.     PUSH    DX
  109.     MOV    DH,LINES_BEFORE_SECTOR    ;Find row of phantom (0,0)
  110.     ADD    DH,2            ;Plus row of hex and horizontal bar
  111.     ADD    DH,PHANTOM_CURSOR_Y    ;DH = row of phantom cursor
  112.     MOV    DL,59            ;Indent on left side
  113.     ADD    DL,PHANTOM_CURSOR_X    ;Add CURSOR_X to get X position
  114.     CALL    GOTO_XY            ; for phantom cursor
  115.     POP    DX
  116.     POP    AX
  117.     RET
  118. MOV_TO_ASCII_POSITION    ENDP
  119.  
  120.     PUBLIC    SAVE_REAL_CURSOR
  121. ;-----------------------------------------------------------------------;
  122. ; This procedure saves the position of the real cursor in the two    ;
  123. ; variables REAL_CURSOR_X and REAL_CURSOR_Y.                ;
  124. ;                                    ;
  125. ; Writes:    REAL_CURSOR_X, REAL_CURSOR_Y                ;
  126. ;-----------------------------------------------------------------------;
  127. SAVE_REAL_CURSOR    PROC    NEAR
  128.     PUSH    AX
  129.     PUSH    BX
  130.     PUSH    CX
  131.     PUSH    DX
  132.     MOV    AH,3            ;Read cursor position
  133.     XOR    BH,BH            ; on page 0
  134.     INT    10h            ;And return in DL,DH
  135.     MOV    REAL_CURSOR_Y,DL    ;Save position
  136.     MOV    REAL_CURSOR_X,DH
  137.     POP    DX
  138.     POP    CX
  139.     POP    BX
  140.     POP    AX
  141.     RET
  142. SAVE_REAL_CURSOR    ENDP
  143.  
  144.     PUBLIC    RESTORE_REAL_CURSOR
  145.     EXTRN    GOTO_XY:NEAR
  146. ;-----------------------------------------------------------------------;
  147. ; This procedure restorest he real cursor to its old position, saved in    ;
  148. ; REAL_CURSOR_X and REAL_CURSOR_Y.                    ;
  149. ;                                    ;
  150. ; Uses:        GOTO_XY                            ;
  151. ; Reads:    REAL_CURSOR_X, REAL_CURSOR_Y                ;
  152. ;-----------------------------------------------------------------------;
  153. RESTORE_REAL_CURSOR    PROC    NEAR
  154.     PUSH    DX
  155.     MOV    DL,REAL_CURSOR_Y
  156.     MOV    DH,REAL_CURSOR_X
  157.     CALL    GOTO_XY
  158.     POP    DX
  159.     RET
  160. RESTORE_REAL_CURSOR    ENDP
  161.  
  162.     PUBLIC    WRITE_PHANTOM
  163.     EXTRN    WRITE_ATTRIBUTE_N_TIMES:NEAR
  164. ;-----------------------------------------------------------------------;
  165. ; This procedure uses CURSOR_X and CURSOR_Y, through MOV_TO_..., as the    ;
  166. ; coordinates for the phantom cursor.  WRITE_PHANTOM writes this    ;
  167. ; phantom cursor.                            ;
  168. ;                                    ;
  169. ; Uses:        WRITE_ATTRIBUTE_N_TIMES, SAVE_REAL_CURSOR        ;
  170. ;        RESTORE_REAL_CURSOR, MOV_TO_HEX_POSITION        ;
  171. ;        MOV_TO_ASCII_POSITION                    ;
  172. ;-----------------------------------------------------------------------;
  173. WRITE_PHANTOM    PROC    NEAR
  174.     PUSH    CX
  175.     PUSH    DX
  176.     CALL    SAVE_REAL_CURSOR
  177.     CALL    MOV_TO_HEX_POSITION    ;Coord. of cursor in hex window
  178.     MOV    CX,4            ;Make phantom cursor four chars wide
  179.     MOV    DL,70h
  180.     CALL    WRITE_ATTRIBUTE_N_TIMES
  181.     CALL    MOV_TO_ASCII_POSITION    ;Coord. of cursor in ASCII window
  182.     MOV    CX,1            ;Cursor is one character wide here
  183.     CALL    WRITE_ATTRIBUTE_N_TIMES
  184.     CALL    RESTORE_REAL_CURSOR
  185.     POP    DX
  186.     POP    CX
  187.     RET
  188. WRITE_PHANTOM    ENDP
  189.  
  190.     PUBLIC    ERASE_PHANTOM
  191.     EXTRN    WRITE_ATTRIBUTE_N_TIMES:NEAR
  192. ;-----------------------------------------------------------------------;
  193. ; This procedure erases the phantom cursor, just the opposite of    ;
  194. ; WRITE_PHANTOM.                            ;
  195. ;                                    ;
  196. ; Uses:        WRITE_ATTRIBUTE_N_TIMES, SAVE_REAL_CURSOR        ;
  197. ;        RESTORE_REAL_CURSOR, MOV_TO_HEX_POSITION        ;
  198. ;        MOV_TO_ASCII_POSITION                    ;
  199. ;-----------------------------------------------------------------------;
  200. ERASE_PHANTOM    PROC    NEAR
  201.     PUSH    CX
  202.     PUSH    DX
  203.     CALL    SAVE_REAL_CURSOR
  204.     CALL    MOV_TO_HEX_POSITION    ;Coord. of cursor in hex window
  205.     MOV    CX,4            ;Change back to white on black
  206.     MOV    DL,7
  207.     CALL    WRITE_ATTRIBUTE_N_TIMES
  208.     CALL    MOV_TO_ASCII_POSITION
  209.     MOV    CX,1
  210.     CALL    WRITE_ATTRIBUTE_N_TIMES
  211.     CALL    RESTORE_REAL_CURSOR
  212.     POP    DX
  213.     POP    CX
  214.     RET
  215. ERASE_PHANTOM    ENDP
  216.  
  217. CODE_SEG    ENDS
  218.  
  219.  
  220. DATA_SEG    SEGMENT PUBLIC
  221. REAL_CURSOR_X        DB    0
  222. REAL_CURSOR_Y        DB    0
  223.     PUBLIC    PHANTOM_CURSOR_X, PHANTOM_CURSOR_Y
  224. PHANTOM_CURSOR_X    DB    0
  225. PHANTOM_CURSOR_Y    DB    0
  226. DATA_SEG    ENDS
  227.  
  228.  
  229.     END
  230.