[comp.lang.pascal] Help with algorthm

kamal@wpi.WPI.EDU (Kamal Z Zamli) (12/31/90)

Hi everyone,
            I had some trouble on my program, it goes something 
like this:
 
    
   const
     DisplayPtr:pointer=ptr($B800,0000) (* assume CGA *)
     
 
   type
     DataArray = array [1..5000] of string;
  
   var
     Data:DataArray;
 
 
  
Here's my problem, I can't seem to find an algorithm ( I'm using TP 
5.5) to assign the formatted ( key problem!!!! ) output of 
DataArray to the offset of DisplayPtr.
 
 
Any help would be greatly appreciated, thanks.

einstein@cs.mcgill.ca (Michael CHOWET) (01/01/91)

In article <1990Dec31.093559.21618@wpi.WPI.EDU> kamal@wpi.WPI.EDU (Kamal Z Zamli) writes:
>Hi everyone,
> I had some trouble on my program, it goes something like this:
>   const
>     DisplayPtr:pointer=ptr($B800,0000) (* assume CGA *)
>     
>   type
>     DataArray = array [1..5000] of string;
>  
>   var
>     Data:DataArray;
>  
>Here's my problem, I can't seem to find an algorithm ( I'm using TP 
>5.5) to assign the formatted ( key problem!!!! ) output of 
>DataArray to the offset of DisplayPtr.

  I'm not positive of what it is you want to do here, but it seems to me
what you want to do is write info straight into the video memory.

  Here's what you can do. First, have your Data array actually mapped over
the video buffer. How? Well, first you'll have to modify the structure, since
each character takes two bytes of storage, one for ASCII number, one for the
character's attribute. So, create a CHARTYPE = Record
                                                 CharNum : Byte ;
                                                 Attrib  : Byte ;
                                               End ;

  Then, make your DataArray = Array [ 1..Max ] Of CharType ; 
As your last step, at the Var statement, you specify where you want it, via
the ABS. So it'd look like:

VAR
  Data : DataArray ABS DisplayPtr ;

  Note that your array *is* in effect your video memory. As a result, any 
changes to the array will be IMMEDIATELY apparent on the screen as either
a changed character, or the colors of a letter shift. 

  Now, another way to do it, is via the MOVE. Again, you would have to change
the structure of your array, since each character take TWO bytes apiece. This
method, however, would allow you to change around the array, then place it
in the video buffer at will. Here, you would create your Data array (not the 
type), without the ABS. Then, when you want to move the array onto the video
buffer, use the MOVE with the following parameters: 

  MOVE ( source, dest, size_of_memory_chunk_to_move ) ;

  This sounds rather cumbersome, but you would use it as follows:

  MOVE ( @Data, DisplayPtr, SizeOf ( Data ) ) ;

  The @ symbol means use the pointer at the particular variable. The
SizeOf function will return the size of the array, and consequently the amount
of memory you want to move.

  I have never used this method, myself. I use the mapping method, and so have
no idea what you can expect to be left in the array, althouh I would 
*seriously* doubt that this procedure changes the contents of the array.

  I hope this was what you were looking for.


==============================================================================
Today's message was brought to you by the letter 'S', the number 6, and

  		    =====> Einstein@cs.mcgill.ca  <====
             =====> Mike CHOWET | McGill CSUS VP External <=====

			Post back soon, now y'hear...
==============================================================================

-- 
==============================================================================
Today's message was brought to you by the letter 'S', the number 6, and

  		    =====> Einstein@cs.mcgill.ca  <====