home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / TP_ADV.ZIP / LIST0511.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1989-07-31  |  5.1 KB  |  115 lines

  1. Program CursorControl;
  2. { This program will use several different Inline Procedures   }
  3. { to do different types of cursor manipulations.  Included    }
  4. { here are routines to hide the cursor, restore the cursor,   }
  5. { define a block cursor, and to restore the cursor to its     }
  6. { default underline state.                                    }
  7. Uses Crt;         { Included here so we can do a ClrScr       }
  8.  
  9. Var
  10.   Row, Column : Byte;      { Position to replace cursor       }
  11.   Mode : Byte Absolute $40:$49;{ To determine video mode      }
  12.   Ch : Char;               { Used for user input              }
  13.  
  14. Procedure CursorOn;
  15. { This procedure will turn the cursor on by returning it to a }
  16. { displayable position.  The position is determined by the    }
  17. { global variables Row and Column.. This is necessary because }
  18. { of the way in which we hide the cursor.  Note that we also  }
  19. { define a local variable into the Bios Data Area so we can   }
  20. { determine the current active video page.                    }
  21. Var
  22.   ActivePage : Byte Absolute $40:$62;
  23.                     { Bios Data Area for the current page     }
  24.  
  25. Begin
  26.   Inline( $B8/$00/$02/       {  MOV AX,0200        }
  27.           $8A/$BE/ActivePage/{  MOV BH,ACTIVEPAGE  }
  28.           $8A/$36/Row/       {  MOV DH,ROW         }
  29.           $8A/$16/Column/    {  MOV DL,COLUMN      }
  30.           $CD/$10 );         {  INT 10             }
  31. End;
  32.  
  33. Procedure CursorOff;
  34. { This procedure turns the cursor off by placing it into a    }
  35. { position that is not normally displayable.  That is, we     }
  36. { reposition the cursor to screen position 255,255.  This is  }
  37. { one of two documented ways to hide the cursor.  Again we    }
  38. { define a local variable to determine the current video page }
  39. Var
  40.   ActivePage : Byte Absolute $40:$62;
  41.                     { BIOS data area for the active page      }
  42.  
  43. Begin
  44.   Inline( $B8/$00/$02/       {  MOV AX,0200        }
  45.           $8A/$BE/ActivePage/{  MOV BH,ACTIVEPAGE  }
  46.           $B6/$FF/           {  MOV DH,$FF         }
  47.           $B2/$FF/           {  MOV DL,$FF         }
  48.           $CD/$10 );         {  INT 10             }
  49. End;
  50.  
  51. Procedure NormalCursor;
  52. { This procedure will return the cursor to its normal state.  }
  53. { Since the definition of the cursor is dependant upon the    }
  54. { current video mode (mono versus color), we declare a        }
  55. { variable into the BIOS data area where the current video    }
  56. { mode value is kept.  We can then use this inside the inline }
  57. { code.                                                       }
  58.  
  59. Begin
  60.   Inline( $B8/$00/$01/       {  MOV AX,0100        }
  61.           $8A/$0E/Mode/      {  MOV CL,MODE        }
  62.           $B1/$07/           {  CMP CL,07          }
  63.           $75/$06/           {  JNZ 06             }
  64.           $B5/$0B/           {  MOV CH,0B          }
  65.           $B1/$0C/           {  MOV CL,0C          }
  66.           $EB/$04/           {  JMP 04             }
  67.           $B5/$06/           {  MOV CH,06          }
  68.           $B1/$07/           {  MOV CL,07          }
  69.           $CD/$10 );         {  INT 10             }
  70. End;
  71.  
  72. Procedure BlockCursor;
  73. { We can redefine the cursor to be any size by changing the   }
  74. { beginning and ending scan lines.  This procedure will set   }
  75. { the beginning value at 0 regardless of monitor type.  It    }
  76. { will then set the ending scan line based on the type of     }
  77. { monitor on the system.                                      }
  78.  
  79. { To modify this routine to turn the cursor off, simply       }
  80. { follow the comments next to the assembly mnemonics inside   }
  81. { the inline code.                                            }
  82. Begin                        {              Cursor Off }
  83.   Inline( $B8/$00/$01/       {  MOV AX,0100            }
  84.           $B5/$00/           {  MOV CH,00    MOV CH,20 }
  85.           $8A/$0E/Mode/      {  MOV CL,MODE            }
  86.           $38/$C8/           {  CMP AL,CL              }
  87.           $75/$06/           {  JNZ 04                 }
  88.           $B1/$0C/           {  MOV CL,0C    MOV CL,20 }
  89.           $EB/$02/           {  JMP 02                 }
  90.           $B1/$07/           {  MOV CL,07    MOV CL,20 }
  91.           $CD/$10 );         {  INT 10                 }
  92. End;
  93.  
  94. Begin
  95.   ClrScr;                    { Clear the output screen        }
  96.   Row := 10;                 { Set the cursor restore Y Coord }
  97.   Column := 20;              { Set the cursor restore X Coord }
  98.   Write( 'Ready to kill the Cursor?' );
  99.   Ch := Readkey;
  100.   Writeln;
  101.   Writeln( 'I''m Gone!' );
  102.   CursorOff;                 { Turn off the cursor            }
  103.   Readln;                    { Pause for viewing              }
  104.   CursorOn;                  { Turn the cursor back on        }
  105.   Writeln( 'I''m Back!' );
  106.   Readln;                    { Pause for screen viewing       }
  107.   BlockCursor;               { Redifine to a block cursor     }
  108.   Writeln( 'Now I''m a Block Cursor!' );
  109.   Readln;                    { Pause for screen viewing       }
  110.   NormalCursor;              { Restore to original state      }
  111.   Writeln( 'I''m an underline again... :(' );
  112.   Readln;                    { Pause for screen viewing       }
  113. End.
  114.  
  115.