home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / assemblr / library / nor_asm / phanto22.asm < prev    next >
Assembly Source File  |  1989-05-17  |  7KB  |  223 lines

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