Board index » delphi » screen writes w/out 'crt'

screen writes w/out 'crt'

Quote
>    Reply to: scott lamb

>                           SCREEN WRITES W/OUT 'CRT'

>    29 Jun 1995 18:41:57 -0400
>    iii-net
>   Newsgroups:
>          comp.lang.pascal.borland
>   Reply to newsgroup(s)
>i was wondering if some one could help me with find a procedure that will
>write direcly to the screen with out useing the 'crt' unit?  somthing in
>asm would be ok but borland turbo pascal would be most helpful.

>        thank you for any help you can give,
>                scott lamb
>                ton...@iii.net

that's really quite simple. text mode screen memory is stored at mem
address $B800. it's 4000 bytes long, and alternates character/attribute
byte for every place on the screen. to represent screen mem, do this:
type
  screen_type=array[1..25,1..80] of record
                                ch:char; {or byte}
                                at:byte;
                        end;
  Pscreen=^screen_type;

then, you can do either one of these:

const
  screen:Pscreen=ptr($B800,0);

---or---

var
  screen:Pscreen;  

......
pscreen:=ptr($B800,0);

to alter the char at a certain place on the screen, just do:

screen^[ycoordinate,xcoordinate].ch:='Z';

here's something to print a string:

procedure print_string_xy(var str:string;x,y:byte);
  var
    n:byte;
  begin
    for n:=0 to length(str)-1 do
      screen^[y,x+n].ch:=str[n+1];
  end;

how to set the colors.

here's the layout of the att byte:

bits:   7   6   5   4   3   2   1   0
       [B] [R] [G] [B] [H] [R] [G] [B]
        l   e   r   l | i   e   r   l
        i   d   e   u | g   d   e   u  
        n       e   e | h       e   e
        k       n     |         n
                      |
        {background  }{foreground    }
what does this mean? to set the color, just do:

screen^[y,x].at:=forground+(16*background);

if you want it to blink, just add 128.

 

Re:screen writes w/out 'crt'


Re:screen writes w/out 'crt'


I'm just learning windows programming & am using BP7's Object windows.  I
want to display text in a TEditWindow, with some of the text being in
bold or italics.  Does anyone know is there a way to do this?  Or is
there some other object I should use rather than TEditWindow?  It's not
critical that the user be able to edit the text, just to be able to
select portions of it & copy to the clipboard.

Any help would be greatly appreciated!

Gerry Leatherman

Other Threads