Text mode font - help! 
Author Message
 Text mode font - help!

Hi,
    I'm currently developing an operating system (just for fun) and I need
to change the text mode font temporarily during boot up (so I can display a
small graphic in the corner of the screen - gfx mode is a pain when you're
only trying to display a 200x100 image). I've got the font changed, but
there's a thin (one pixel) line running vertically through my picture - one
line between each character. Is there any way to get rid of the lines?
Basically, here's what's happening:

******** ********
******** ********
******** ********
******** ********

... and so on

Any ideas?

I know it's possible (my PC's Award BIOS does it on boot up). I just need to
know how...

TIA.

--
Phil.
http://www.*-*-*.com/

PGP Key Fingerprint:
  1FA6 6C7F A2FD BB15 84BF
  4993 2B27 0628 E54E 33B1



Wed, 09 Jul 2003 23:26:14 GMT  
 Text mode font - help!

Quote:
>    I'm currently developing an operating system (just for fun) and I need
>to change the text mode font temporarily during boot up (so I can display a
>small graphic in the corner of the screen - gfx mode is a pain when you're
>only trying to display a 200x100 image). I've got the font changed, but
>there's a thin (one pixel) line running vertically through my picture - one
>line between each character. Is there any way to get rid of the lines?
>Basically, here's what's happening:

>******** ********
>******** ********
>******** ********
>******** ********

>... and so on

>Any ideas?

>I know it's possible (my PC's Award BIOS does it on boot up). I just need to
>know how...

VGA fonts are 8-bits wide, but there are 9 bits wide modes, in which the VGA
controller copies the 8th to the 9th.

This "copying" behaviour can be influenced via an INT $10 call. Check SWAG
for examples: (www.gdsoft.org)



Thu, 10 Jul 2003 00:18:24 GMT  
 Text mode font - help!

Quote:

>I've got the font changed, but
>there's a thin (one pixel) line running vertically through my picture - one
>line between each character. Is there any way to get rid of the lines?
>Basically, here's what's happening:

>******** ********
>******** ********
>******** ********
>******** ********

>... and so on

The font is 8 pixels wide but defined by using 8 bit bytes. This
means the 8th pixel row is blank with the exception of graphics
characters. #196..#223 in which it is the duplicate of the 8th row.
This behavior can be somewhat controlled by BIOS calls.

If you cannot live with it then you might change the display so that
it uses 90 columns or that it only uses 640 pixels instead of the normal
720. These require hardware programming.

Osmo



Thu, 10 Jul 2003 02:25:01 GMT  
 Text mode font - help!


Quote:
> >    I'm currently developing an operating system (just for fun) and I
need
> >to change the text mode font temporarily during boot up (so I can display
a
> >small graphic in the corner of the screen - gfx mode is a pain when
you're
> >only trying to display a 200x100 image). I've got the font changed, but
> >there's a thin (one pixel) line running vertically through my picture -
one
> >line between each character. Is there any way to get rid of the lines?
> >Basically, here's what's happening:

> >******** ********
> >******** ********
> >******** ********
> >******** ********

> >... and so on

> >Any ideas?

> >I know it's possible (my PC's Award BIOS does it on boot up). I just need
to
> >know how...

> VGA fonts are 8-bits wide, but there are 9 bits wide modes, in which the
VGA
> controller copies the 8th to the 9th.

> This "copying" behaviour can be influenced via an INT $10 call. Check SWAG
> for examples: (www.gdsoft.org)

Right. I've looked through my copy of the SWAG and I couldn't find anything
even remotely useful. I've found this piece of code on the TP Programmers
Page that seems to work, but my attempts to convert it to assembler have
thus far been completely in vain. Anyone care to tell me what I'm doing
wrong? Here's the code:

<cut>

uses
  DOS;

{$I KNGTWULF.INC}

procedure SetCharWidth( hwidth : byte );
var
  x    : byte;                        { Value for misc. output reg. }
begin
  asm
        cmp [hwidth],   8

        mov bx,         $8000


         mov    bx,     $0001



         mov    dx,     $3CC                      { Toggle horizontal }
         in     al,     dx                        { resolution from   }
         and    al,     $F3                       { 720 to 640 pixels }
         mov    [x],    al

         cmp    [hwidth], 9

         mov    al,    [x]
         or     al,    4
         mov    [x],   al


         mov    al,     [x]
         mov    dx,     $3C2
         out    dx,     al

         cli                            { Toggle sequencer from 8 to 9
pixels }

         mov    ax,     $0100
         mov    dx,     $3C4
         out    dx,     ax

         mov    al,     bl              { ax := bl shl 8 }
         mov    ah,     0
         shl    ax,     8
         inc    ax
         out    dx,     ax

         mov    ax,     $0300
         out    dx,     ax

         sti

         mov    ax,     $1000
         mov    bl,     $13
         int    $10
  end;
end;

procedure SetCharWidth2( hwidth : byte );

var Regs : Registers;        { Processor registers for interrupt call }
    x    : byte;                        { Value for misc. output reg. }

begin
  if ( hwidth = 8 ) then Regs.BX := $0001     { BH = horiz. direction }
                    else Regs.BX := $0800;     { BL = seq. reg. value }

  x := port[ $3CC ] and not(4+8);                 { Toggle horizontal }
  if ( hwidth = 9 ) then                          { resolution from   }
    x := x or 4;                                  { 720 to 640 pixels }
  port[ $3C2 ] := x;

  Inline($FA);                     {CLI - Toggle sequencer from 8 to 9
pixels }
  portw[ $3C4 ] := $0100;
  portw[ $3C4 ] := { $01 + }(Regs.BL shl 8) + 1;
  portw[ $3C4 ] := $0300;
  Inline($FB);  {STI}

  Regs.AX := $1000;
  Regs.BL := $13;
  intr( $10, Regs );
end;

begin
  SetCharWidth2(8);
  readln;
  SetCharWidth(8);
  readln;
  SetCharWidth2(9);
  ReadLn;
end.

<cut>

The ASM routine (or at least my hack of it) is at the top, the TP routine is
in the middle and the main code is at the end. I have no idea why the asm
code is bombing (don't try and debug this if you've got a fixed sync
monitor - last time I tried it my monitor gave me a "Bad Sync" error).

TIA.

--
Phil.
http://www.philpem.f9.co.uk/

PGP Key Fingerprint:
  1FA6 6C7F A2FD BB15 84BF
  4993 2B27 0628 E54E 33B1



Thu, 10 Jul 2003 06:56:43 GMT  
 Text mode font - help!


wrote at Sat, 20 Jan 2001 15:26:14 :-

Quote:
>    I'm currently developing an operating system (just for fun) and I need
>to change the text mode font temporarily during boot up (so I can display a
>small graphic in the corner of the screen - gfx mode is a pain when you're
>only trying to display a 200x100 image). I've got the font changed, but
>there's a thin (one pixel) line running vertically through my picture - one
>line between each character. Is there any way to get rid of the lines?
>Basically, here's what's happening:

>******** ********
>******** ********
>******** ********
>******** ********

>... and so on

>Any ideas?

>I know it's possible (my PC's Award BIOS does it on boot up). I just need to
>know how...

Font characters are 8 bits wide and the system normally leaves a gap
between them, which explains what you see.

But the line-drawing characters are treated differently; Column 9 is,
instead of being blank, shown as a repeat of Column 8.  These are
characters decimal 176 or 179 to 218 or 223 in Code Page 437.

Not all the characters in the cited range actually need the extension to
Column 9, but that should be enough clue for you to sort it out or to
decide that the problem or solution lies elsewhere.

--

 <URL: http://www.merlyn.demon.co.uk/> TP/BP/Delphi/&c., FAQqy topics & links;
 <URL: http://www.merlyn.demon.co.uk/clpb-faq.txt> Pedt Scragg: c.l.p.b. mFAQ;
 <URL: ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip> Timo Salmi's Turbo Pascal FAQ.



Thu, 10 Jul 2003 04:31:21 GMT  
 Text mode font - help!


Wed, 18 Jun 1902 08:00:00 GMT  
 Text mode font - help!
Thanks for your help Marco. I've just converted the routine into Assembler
and it works fine. I completely nuked the ASM routine then converted it in
blocks (INT block, etc). For those who are interested, here's the source
code, including the include file I forgot last time. If you want the whole
lot (font converter, font2inc, etc.) have a look on my website. Should be up
within the next two/three hours all being well.

The include file is merely a BMP-to-INC conversion of the "Knightwulf" EPA
logo (available from www.overclockers.au). I took the GIF, used PSP to
convert it into a 16-colour BMP, then I ran it through FontConv, followed by
a run through FME2INC. Can't post the converters here (too big). Like said,
there will be a ZIP file up on my site soon (see the Programming section).

<BEGIN KNGTWULF.INC>
const
  KnightWulf : array[0..1359] of Byte =
 (  0,   0,  60,  24,  24,  25,  31,  31,  28,  24,  24,  24,  60,   0,   0,
0,
    0,   0,   0,   0,   0,   0,   7,   7,   7,   7,   7,   7,   7,   6,   6,
4,
    4,   4,   4,   7,   7,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,
4,
    4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,
4,
    4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   4,   7,   0,   0,
0,
    0,   0,  62, 112, 224, 192, 128, 192, 224, 112,  56,  24,  30,   0,   0,
0,
    0,   0,   0,   0,   0,   0, 255, 255, 195, 129, 129,  24,  24,  60,   0,
0,
    0, 126, 126, 255, 255,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
0,
   15,  31,  63,  59, 113, 254, 241, 193,   0,   0,   0,   0,  96,  97,  97,
96,
   98,   2,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, 255,   0,   0,
0,
    0,   0, 240, 112, 120, 124, 110, 103,  99,  97,  96,  96, 240,   0,   0,
0,
    0,   0,   0,   0,   0,   0, 255, 255, 227, 225, 224, 224, 224,  98,  99,
35,
   35,  35,  35, 255, 255,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
0,
  130, 142, 159, 159, 156,  92, 222, 222,   0,   0,   0,   0, 243, 150, 150,
146,
  227,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, 255,   0,   0,
0,
    0,   0, 123,  49,  49,  49,  49,  49, 177, 241, 241, 113, 123,   0,   0,
0,
    0,   0,   0,   0,   0,   0, 255, 255, 241, 225, 193,   1,   1,  17,  49,
241,
  241, 241, 241, 255, 255,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
0,
   56,  56, 127, 127, 115, 115, 227, 231,   0,   0,   0,   0, 207,  89,  89,
73,
  142,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, 255,   0,   0,
0,
    0,   0, 193, 135, 142, 156, 152, 152, 152, 156, 142, 135, 193,   0,   0,
0,
    0,   0,   0,   0,   0,   0, 255, 255, 128, 128, 143, 143, 143, 143, 143,
143,
  143, 128, 128, 255, 255,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
0,
   12,  28, 156, 157, 187, 187, 187, 112,   0,   0,   0,   0,  12,  12,  15,
11,
    8,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, 255,   0,   0,
0,
    0,   0, 249, 255,   3,   1,   0, 128, 255, 255, 131, 255, 252,   0,   0,
0,
    0,   0,   0,   0,   0,   0, 255, 254,  63,  31,  15, 143, 143, 142, 140,
140,
   12,  28,  60, 252, 255,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
0,
    0,   0, 252, 254, 142, 142, 254, 249,   0,   0,   0,   0, 200, 200,  79,
72,
   72,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, 255,   0,   0,
0,
    0,   0,  60,  24,  24,  24,  31,  31, 152, 152, 152,  24,  60,   0,   0,
0,
    0,   0,   0,   0,   0,   0, 255,   0,   0, 128, 192, 252,  60,  60,  60,
6,
    7,   7,  15,  31, 255,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
0,
    0,   0, 127, 255, 227, 231, 231, 199,   0,   0,   0,   0, 128, 188, 136,
152,
  190,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, 255,   0,   0,
0,
    0,   0,  30,  12,  12,  12, 252, 252,  12,  12,  12,  12,  30,   0,   0,
0,
    0,   0,   0,   0,   0,   0, 224,  32,  32,  32,  32,  32,  32,  32,  32,
32,
   32, 160, 224, 224, 224,  32,  32,  32,  32,  32,  32,  32,  32,  32,  32,
32,
   32,  32,  32,  32,  32,  32,  32,  32,  32,  32,  32,  32,  32,  32,  32,
32,
   32,  32,  32,  32,  32,  32,  32,  32,  32,  32,  32,  32, 224,   0,   0,
0,
    0, 128, 255, 255, 134,   6,   6,   6,   6,   6,   6,   6,  15,   0,   0,
0,
    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
0,
    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
0,
    0,   0,   0,   0,   0,   0,   1,   7,  15,  31,  63, 127, 123,  63,  30,
15,
    5,   3,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
0,
    0,  16, 247, 241,  17,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
0,
    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
0,
    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   1,   0,
3,
    3,   3,   7,  15,  63, 127, 252, 248, 251, 247, 128, 133, 143,  31, 120,
160,
  128,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
0,
    0,   0, 195, 131, 131, 199, 198, 110, 108, 108,  56,  56,  56,   0,   0,
0,
    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
0,
   30,  63,  31,  15,  15,   7,  31,  63,  63, 127, 127, 255, 255, 255, 251,
247,
  235, 222, 166, 175, 159, 191, 115,  96, 135, 135, 120, 255, 207, 129,   0,
1,
    1,   1,   1,   3,   2, 127,  63,  30,  11,  15,   4,   0,   0,   0,   0,
0,
    0,   0, 195, 193, 193, 227,  99, 118,  54,  54,  60,  28,  28,   0,   0,
0,
    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   6,   1,
14,
   31, 143, 247, 243, 255, 199, 199, 215, 215, 241, 248, 255, 255, 127, 255,
255,
  252, 252, 255, 255, 252, 248, 127, 127, 136, 192,  24, 143, 207, 207, 232,
193,
  225, 231, 196, 204, 200, 152,  96, 192, 192,   0,   0,   0,   0,   0,   0,
0,
    0,   0, 239, 134, 134,   6,   6,   6,   6,   6,   7,   3,   1,   0,   0,
0,
    0,   0,   0,   0,   0,   0,   0,   0,   0,   3,   6,  13,  15,  14, 158,
60,
  124, 120, 203, 143, 191, 191, 255, 121, 168, 128, 120, 248, 254, 254, 233,
200,
   64, 113,   0, 129,   1,   7, 199,   3,   2,   2, 128,   0, 128,  17, 255,
128,
  128,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
0,
    0,   0,  15,   6,   6,   6,   6,   6,   6,   6,  14, 252, 248,   0,   0,
0,
    0,   0,   0,   0,   0,   0,   0,  15,  15,  63, 255, 255, 255, 191, 239,
137,
  131, 191, 254, 240, 255, 255, 255,  15,  63,  15,   1,  32, 240, 252, 254,
250,
  122, 252, 253, 255, 255, 255, 191, 207,  47,  15,   3,   8, 126,  78, 120,
192,
    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
0,
    0,   0, 120,  48,  48,  48,  48,  48,  48,  48,  48,  63, 127,   0,   0,
0,
    0,   0,   0,   0,   0,   0, 111, 255, 255, 255, 248, 240, 224, 248, 255,
243,
  240, 255,  15,   0,   0, 240,   0, 224, 240, 204, 224, 240, 112,  48, 110,
127,
   16,  12,   1,   8,  28,   7,  50,  31,   4, 208, 215, 240, 248,  60,   6,
0,
    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
0,
    0,   0,  15,   7,   6,   6,   7,   7,   6,   6,  38, 230, 239,  32,   0,
0,
    0,   0,   0,   0,   0,   0, 124, 252, 192,   0, 124,  95,  15,   0,  14,
8,
  240, 240, 191,   7,  15,  15, 112,  30,  31,  15,   7,   3,   3,  27,  15,
135,
    3,   1,   1, 129, 140,  31, 128, 128, 192, 208,   0,   0,   0,   0,   0,
0,
    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
0,
    0,   2, 254, 254,   2,   8, 248, 248,   8,   0,   0,   0,   0,   0,   0,
0,
    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, 128, 192, 112,
0,
    0,   0,  96, 192, 128, 128, 224, 248, 120,  32, 176, 240, 208, 240,  28,
14,
  128, 192, 128, 128, 128,  64, 192, 192,  32,   0,   0,   0,   0,   0,   0,
0,
    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
0);
<END KNGTWULF.INC>
<BEGIN FONTSHW.PAS>
uses
  DOS;

{$I KNGTWULF.INC}

procedure PutFontC (C : Byte; var Data);
  {-Define font character bitmap}
begin
  inline($FA);
  PortW[$3C4]:=$0402;
  PortW[$3C4]:=$0704;
  PortW[$3CE]:=$0204;
  PortW[$3CE]:=$0005;
  PortW[$3CE]:=$0006;
  Move(Data, Mem[SegA000:C * 32], 16);
  PortW[$3C4]:=$0302;
  PortW[$3C4]:=$0304;
  PortW[$3CE]:=$0004;
  PortW[$3CE]:=$1005;
  PortW[$3CE]:=$0E06;
  inline($FB);
end;

procedure PutFont(C : Byte; Count : Byte; var Data);
var
  Cnt : Byte;
  Pnt : Pointer;
begin
  for Cnt := C to C + Count do
  begin
    Pnt := Ptr(Seg(Data), Ofs(Data) + ((Cnt-C) * 16));
    PutFontC(Cnt, Pnt^);
  end;
end;

procedure SetCharWidth( hwidth : byte );
var
  x    : byte;                        { Value for misc. output reg. }
begin
  asm
    cmp         hwidth, 8

    mov         bx,     0800h


    mov         bx,     0001h

    mov         dx,     03cch
    in          al,     dx
    and         al,     0f3h
    mov         [x],    al

    cmp         hwidth, 9



    mov         al,     [x]
    or          al,     4
    mov         [x],    al


     mov        al,     [x]
     mov        dx,     03c2h
     out        dx,     al

     cli
     mov        dx,     03c4h
     mov        ax,     0100h
     out        dx,     ax

     mov        ax,     0000h
     mov        al,     bl
     shl        ax,     8
     inc        ax
     mov        dx,     03c4h
     out        dx,     ax

     mov        dx,     03c4h
     mov        ax,     0300h
     out        dx,     ax
     sti

     mov        ax,     1000h
     mov        bl,     13h
     int        10h
  end;
end;

procedure SetCharWidth2( hwidth : byte );

var Regs : Registers;        { Processor registers for interrupt call }
    x    : byte;                        { Value for misc. output reg. }

begin
  if ( hwidth = 8 ) then Regs.BX := $0001     { BH = horiz. direction }
                    else Regs.BX := $0800;     { BL = seq. reg. value }

  x := port[ $3CC ] and not(4+8);                 { Toggle horizontal }
  if ( hwidth = 9 ) then                          { resolution from   }
    x := x or 4;                  
...

read more »



Fri, 11 Jul 2003 02:45:59 GMT  
 Text mode font - help!
Quote:
> The include file is merely a BMP-to-INC conversion of the "Knightwulf" EPA
> logo (available from www.overclockers.au). I took the GIF, used PSP to

Oops... That should be www.overclockers.com.au.

--
Phil.
http://www.philpem.f9.co.uk/

PGP Key Fingerprint:
  1FA6 6C7F A2FD BB15 84BF
  4993 2B27 0628 E54E 33B1



Fri, 11 Jul 2003 07:01:30 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. graphics in text mode using dual fonts

2. Fonts in Text Mode ...

3. CHANGING FONT IN TEXT MODE

4. Scrolling Text in Text Mode - PLEASE HELP!

5. Text mode - graphics mode conflict (Help!)

6. Text mode vs graphics mode conflict (Help!)

7. Problem with GotoXY in EGA/VGA text mode (43/50 line mode)

8. Please help with graphics in text mode!

9. Bios text in graphics mode. Help please

10. Need help on manipulating pixels in text mode

11. I need help with graphics and text mode!!

12. Please help with graphics in text mode!

 

 
Powered by phpBB® Forum Software