[comp.sys.dec.micro] Getting the Rainbow's Cursor Position: A Quick Demo

iav1917@ritcv.UUCP (s) (01/04/88)

   Hello Net-land:

   The following is a quick demo program that contains two functions
   GetCursorColPos and GetCursorRowPos which return the cursor's
   current column and row positions, respectively.  The routines
   each grab a byte of data out of the Rainbow's screen RAM segment.
   This pair of routines are a lot easier to use than trying to
   use VT102 escape sequences or other methods of figuring out where
   the cursor is.  These routines are probably best used to 'remember'
   the cursor's position before using the SaveScreen and after using
   the RestoreScreen routines in the RBDEMO3 demo.

   The routines are after the .signature.

   Enjoy,
   Alan


   Alan I. Vymetalik  @  {allegra,seismo}!rochester!ritcv!iav1917
   ----------------------------------+----------------------------------
   J.A.M, Inc.                       |   Prism Software Designs
   300 Main Street                   |   44 Arborwood Crescent
   East Rochester, New York, 14445   |   Rochester, New York, 14615-3807
                                     |   1-716-458-4932
   ----------------------------------+----------------------------------
   DISCLAIMER:   The above statements and opinions belong to the author.
   Any resemblence to statements found in actual reality is purely coin-
   cidental.  And, as always, the above opinions have absolutely nothing
   to do with the little, fat man putting $100 bills in my pocket.
   ---------------------------------------------------------------------

   ---------------------------------------------------------------------

program DEC_Rainbow_Cursor_Demo;

var
   i : byte;                      { misc. loop variable }

{
   GetCursorColPos
   ======================================================================

   and

   GetCursorRowPos
   ======================================================================

   GetCursorColPos and GetCursorRowPos return the screen cursor's current
   column and row positions, respectively, from the values stored in the
   Screen RAM segment of video memory.

   These procedures can be useful in saving the cursor's position in a
   storage variable before saving and clearing the screen.  Later, the
   cursor can be properly replaced when the screen is restored.
}

function GetCursorColPos : byte;

begin { GetCursorColPos }

   GetCursorColPos := mem[$EE00:$0F41];

end;  { GetCursorColPos }



function GetCursorRowPos : byte;

begin { GetCursorRowPos }

   GetCursorRowPos := mem[$EE00:$0F42];

end;  { GetCursorRowPos }


{
   A quick demo program to demonstrate the above functions...
   The first character displayed is located at the position
   decribed.
}

Begin { demo }

   Write(#27,'[2J',#27,'[H');              { clear screen, home cursor }

   For i := 1 To 23 Do
      Begin
         GotoXY(i,i);
         Write(GetCursorColPos:1,',',GetCursorRowPos:1);
      End;

   For i := 23 DownTo 1 Do
      Begin
         GotoXY(76-i,i);
         Write(GetCursorColPos:1,',',GetCursorRowPos:1);
      End;

End.  { demo }