Board index » delphi » writing text to screen while in graphics mode

writing text to screen while in graphics mode

'lo all.  I'm looking for code or a unit that to write text to the screen in
graphics mode.  Anyone know where to find one?

Thanks,
Nick

 

Re:writing text to screen while in graphics mode


Quote
Nick <soc...@mailroom.com> wrote:
> 'lo all.  I'm looking for code or a unit that to write text to the screen in
> graphics mode.  Anyone know where to find one?

Try looking in the Graphics unit. You may find "OutText" and "OutTextXY" to
be useful.

--
______________________________________________________________________
     The Scarlet Manuka,      |        Nitpickers' Party motto:
  Pratchett Quoter At Large,  |  "He who guards his lips guards his
 First Prophet of Bonni, is:  |  soul, but he who speaks rashly will
   sa...@maths.uwa.edu.au     |    come to ruin." -- Proverbs 13:3
______________________________|_______________________________________

Re:writing text to screen while in graphics mode


In article <r8D15.121$OkW.14483...@news.randori.com>,

Quote
Nick <soc...@mailroom.com> wrote:
>'lo all.  I'm looking for code or a unit that to write text to the screen in
>graphics mode.  Anyone know where to find one?

Either use outtext or outtextxy, or set directvideo (from CRT) to false
and use normal methods. However, the VGA graphics screen is 80x30
characters so you need to set then windmax manually to access the 5
last rows.

Osmo

Re:writing text to screen while in graphics mode


Hmm....
Well this is how I'm going into graphics mode (320x200 x256 MCGA):

procedure SetMCGA;
begin
  asm
     mov        ax,0013h
     int        10h
  end;
end;

To use OutText, I would need to initialize the graph using InitGraph which
would change the graphics mode I'm in.
That's why I can't use that... unless I can use OutText without having
InitGraph changing the mode I'm in.....

Quote
"Osmo Ronkanen" <ronka...@cc.helsinki.fi> wrote in message

news:8i7onk$j96$1@kruuna.Helsinki.FI...
Quote
> In article <r8D15.121$OkW.14483...@news.randori.com>,
> Nick <soc...@mailroom.com> wrote:
> >'lo all.  I'm looking for code or a unit that to write text to the screen
in
> >graphics mode.  Anyone know where to find one?

> Either use outtext or outtextxy, or set directvideo (from CRT) to false
> and use normal methods. However, the VGA graphics screen is 80x30
> characters so you need to set then windmax manually to access the 5
> last rows.

> Osmo

Re:writing text to screen while in graphics mode


Quote
Nick wrote:
> Hmm....
> Well this is how I'm going into graphics mode (320x200 x256 MCGA):

> procedure SetMCGA;
> begin
>   asm
>      mov        ax,0013h
>      int        10h
>   end;
> end;

> To use OutText, I would need to initialize the graph using InitGraph which
> would change the graphics mode I'm in.
> That's why I can't use that... unless I can use OutText without having
> InitGraph changing the mode I'm in.....

set directvideo := false; and then use writeln as in text mode.

Re:writing text to screen while in graphics mode


In article <bST15.134$mjY.2949...@news.randori.com>,

Quote
Nick <soc...@mailroom.com> wrote:
>Hmm....
>Well this is how I'm going into graphics mode (320x200 x256 MCGA):

>procedure SetMCGA;
>begin
>  asm
>     mov        ax,0013h
>     int        10h
>  end;
>end;

>To use OutText, I would need to initialize the graph using InitGraph which
>would change the graphics mode I'm in.
>That's why I can't use that... unless I can use OutText without having
>InitGraph changing the mode I'm in.....

If you do not use graph to set the mode then of course you cannot use
graph mode services. You can either set the directvideo, or then
simply draw the characters pixel by pixel:

type words=record lo,hi:word; end;
     pbyte=^byte;

Procedure DrawChar(x,y,n:integer; p:pbyte; color:byte);
var j,k,b:integer;
Begin
  for j:=y to y+n-1 do begin
     b:=p^;
     for k:=0 to 7 do
       if 128 shr k and b>0 then putpixel(x+k,j,color);
     inc(words(p).lo);
  End;
End;

type TVGAchar=array[0..15] of byte;

     Table=record case integer of
              16: (a16:array[0..255] of TVGAChar);
              14: (a14:array[0..255,0..13] of byte);
               8: (a8: array[0..255,0..7] of byte);
               1: (a1: array[0..4095] of byte);
             End;

const chartable:^Table=nil;
const csize:byte=16;
      cwidth:byte=8;

Function FontPtr(n:byte):pointer;
var rg:registers;
Begin
  rg.ax:=$1130;
  rg.bh:=n;
  intr($10,rg);
  FontPtr:=ptr(rg.es,rg.bp);
End;

Procedure DrawString(x,y:integer; st:string; col:byte);
var charp:pbyte;
    i:integer;
    c:integer;
Begin
  If CharTable=nil then Chartable:=FontPtr(6);
  for i:=1 to length(st) do begin
    c:=ord(st[i]);
    charp:=@(chartable^.a1[Csize*c]);
    DrawChar(x,y,Csize,Charp,col);
    inc(x,cwidth);
  End;
End;

I hope I got everything needed.

That uses rather big, 8x16 font, If you want 8x8, change then set
Chartable to FontPtr(3) and Csize to 8. (similarly FontPtr(2) returns
8x14 font, though AFAIK many modern cards do not support 8x14 by
default). You can use 9 pixels wide fonts also but that is pretty hard
so I will give it only if asked.

Osmo

Re:writing text to screen while in graphics mode


thanks a lot for your help!!!!

Quote
"Osmo Ronkanen" <ronka...@cc.helsinki.fi> wrote in message

news:8ibb78$aji$1@kruuna.Helsinki.FI...
Quote
> In article <bST15.134$mjY.2949...@news.randori.com>,
> Nick <soc...@mailroom.com> wrote:
> >Hmm....
> >Well this is how I'm going into graphics mode (320x200 x256 MCGA):

> >procedure SetMCGA;
> >begin
> >  asm
> >     mov        ax,0013h
> >     int        10h
> >  end;
> >end;

> >To use OutText, I would need to initialize the graph using InitGraph
which
> >would change the graphics mode I'm in.
> >That's why I can't use that... unless I can use OutText without having
> >InitGraph changing the mode I'm in.....

> If you do not use graph to set the mode then of course you cannot use
> graph mode services. You can either set the directvideo, or then
> simply draw the characters pixel by pixel:

> type words=record lo,hi:word; end;
>      pbyte=^byte;

> Procedure DrawChar(x,y,n:integer; p:pbyte; color:byte);
> var j,k,b:integer;
> Begin
>   for j:=y to y+n-1 do begin
>      b:=p^;
>      for k:=0 to 7 do
>        if 128 shr k and b>0 then putpixel(x+k,j,color);
>      inc(words(p).lo);
>   End;
> End;

> type TVGAchar=array[0..15] of byte;

>      Table=record case integer of
>               16: (a16:array[0..255] of TVGAChar);
>               14: (a14:array[0..255,0..13] of byte);
>                8: (a8: array[0..255,0..7] of byte);
>                1: (a1: array[0..4095] of byte);
>              End;

> const chartable:^Table=nil;
> const csize:byte=16;
>       cwidth:byte=8;

> Function FontPtr(n:byte):pointer;
> var rg:registers;
> Begin
>   rg.ax:=$1130;
>   rg.bh:=n;
>   intr($10,rg);
>   FontPtr:=ptr(rg.es,rg.bp);
> End;

> Procedure DrawString(x,y:integer; st:string; col:byte);
> var charp:pbyte;
>     i:integer;
>     c:integer;
> Begin
>   If CharTable=nil then Chartable:=FontPtr(6);
>   for i:=1 to length(st) do begin
>     c:=ord(st[i]);
>     charp:=@(chartable^.a1[Csize*c]);
>     DrawChar(x,y,Csize,Charp,col);
>     inc(x,cwidth);
>   End;
> End;

> I hope I got everything needed.

> That uses rather big, 8x16 font, If you want 8x8, change then set
> Chartable to FontPtr(3) and Csize to 8. (similarly FontPtr(2) returns
> 8x14 font, though AFAIK many modern cards do not support 8x14 by
> default). You can use 9 pixels wide fonts also but that is pretty hard
> so I will give it only if asked.

> Osmo

Re:writing text to screen while in graphics mode


thanks a lot for your help!!!!

Quote
"Osmo Ronkanen" <ronka...@cc.helsinki.fi> wrote in message

news:8ibb78$aji$1@kruuna.Helsinki.FI...
Quote
> In article <bST15.134$mjY.2949...@news.randori.com>,
> Nick <soc...@mailroom.com> wrote:
> >Hmm....
> >Well this is how I'm going into graphics mode (320x200 x256 MCGA):

> >procedure SetMCGA;
> >begin
> >  asm
> >     mov        ax,0013h
> >     int        10h
> >  end;
> >end;

> >To use OutText, I would need to initialize the graph using InitGraph
which
> >would change the graphics mode I'm in.
> >That's why I can't use that... unless I can use OutText without having
> >InitGraph changing the mode I'm in.....

> If you do not use graph to set the mode then of course you cannot use
> graph mode services. You can either set the directvideo, or then
> simply draw the characters pixel by pixel:

> type words=record lo,hi:word; end;
>      pbyte=^byte;

> Procedure DrawChar(x,y,n:integer; p:pbyte; color:byte);
> var j,k,b:integer;
> Begin
>   for j:=y to y+n-1 do begin
>      b:=p^;
>      for k:=0 to 7 do
>        if 128 shr k and b>0 then putpixel(x+k,j,color);
>      inc(words(p).lo);
>   End;
> End;

> type TVGAchar=array[0..15] of byte;

>      Table=record case integer of
>               16: (a16:array[0..255] of TVGAChar);
>               14: (a14:array[0..255,0..13] of byte);
>                8: (a8: array[0..255,0..7] of byte);
>                1: (a1: array[0..4095] of byte);
>              End;

> const chartable:^Table=nil;
> const csize:byte=16;
>       cwidth:byte=8;

> Function FontPtr(n:byte):pointer;
> var rg:registers;
> Begin
>   rg.ax:=$1130;
>   rg.bh:=n;
>   intr($10,rg);
>   FontPtr:=ptr(rg.es,rg.bp);
> End;

> Procedure DrawString(x,y:integer; st:string; col:byte);
> var charp:pbyte;
>     i:integer;
>     c:integer;
> Begin
>   If CharTable=nil then Chartable:=FontPtr(6);
>   for i:=1 to length(st) do begin
>     c:=ord(st[i]);
>     charp:=@(chartable^.a1[Csize*c]);
>     DrawChar(x,y,Csize,Charp,col);
>     inc(x,cwidth);
>   End;
> End;

> I hope I got everything needed.

> That uses rather big, 8x16 font, If you want 8x8, change then set
> Chartable to FontPtr(3) and Csize to 8. (similarly FontPtr(2) returns
> 8x14 font, though AFAIK many modern cards do not support 8x14 by
> default). You can use 9 pixels wide fonts also but that is pretty hard
> so I will give it only if asked.

> Osmo

Other Threads