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