Page 1 of 1

Video mode and text output

Posted: Tue Aug 15, 2006 12:32 pm
by killedbydeath
Hi all,
i was wondering if it is possible in my real mode os to change the default black background color to white and the letters to black. But according to ralf brown's int list, in text mode only the border color is changeable. So i decided to change my video mode and go to graphics

xor ax,ax
mov ax,04h
int 10h

then i change the background color
xor ax,ax
mov ah,0Bh
mov bl,0Fh ;White
int 10h

and i've changed all my output functions
mov ah,0Eh
mov bl,00h ;black
int 10h

However what i get is a screen filled with an outstanding white and no black letters. How can i print black letters in graphics mode?

Thank you all!

Re:Video mode and text output

Posted: Tue Aug 15, 2006 3:13 pm
by viral
Well.. Once you enter a graphics mode you dont have text to print. I mean the bios fonts that you were using in text mode wont be available to you in graphics mode.

All you have is one thing PIXEL. This is a small magical dot with which you can form any image. And even you can print text by creating your own fonts with pixels.

Hope you got the point.

Re:Video mode and text output

Posted: Tue Aug 15, 2006 3:21 pm
by Bob the Avenger
Viral wrote: Hope you got the point.
Nice pun ;D

a link that may help you is: http://www.mega-tokyo.com/osfaq/How%20do%20I%20draw%20things%20in%20protected%20mode%3F if you look at the section "How do i draw text?" it should point you in the right direction.

Peace

Re:Video mode and text output

Posted: Tue Aug 15, 2006 5:40 pm
by spider
killedbydeath wrote: Hi all,
i was wondering if it is possible in my real mode os to change the default black background color to white and the letters to black. But according to ralf brown's int list, in text mode only the border color is changeable.
You could use some trickery to do this. If you "clear" the screen, in other words just print a space on every position on your screen that has the background colour white with the text black, you will make the all the screen white. Then all you have to do is print on the screen as you normally would.

Re:Video mode and text output

Posted: Tue Aug 15, 2006 6:24 pm
by evincarofautumn
I would do this by overwriting each word in the available video memory (starting at 0xb800?) with 0x0007 (nul, black on white) if it were in a text mode. This would avoid the slowish BIOS printing routines.

Cheers. :)

Re:Video mode and text output

Posted: Wed Aug 16, 2006 7:40 am
by killedbydeath
how much is the video memory , i mean it starts at 0xb800 but where does it end? (at which address)
Best Regards

Re:Video mode and text output

Posted: Wed Aug 16, 2006 7:50 am
by Pype.Clicker
that depends on your video mode. IIrc, the most basic text mode (e.g. mode 3) has 4 pages of 80x25 characters ... that makes 0xB8000, 0xB9000, 0xBA000 and 0xBC000. Whatever's beyond is no longer VRAM you can fill in with ascii code, afaik.

Re:Video mode and text output

Posted: Wed Aug 16, 2006 9:00 am
by killedbydeath
so a

mov ax,0xb800
mov bx,0xbc00
loop:
mov [ax],0x0007
cmp ax,bx ;reached 0xbc00
je stop_filling
inc ax
jmp loop
stop_filling:
mov [ax],0x0007 ;fill 0xbc00 with white too ;)
jmp <row of program>

would do the trick? i mean it fills with white the hole video memory but would my text appear black?

Best Regards

Re:Video mode and text output

Posted: Wed Aug 16, 2006 10:15 am
by viral
Hello..

Well I dont think you will get pure white background :( . See the color attribute byte of screen is treated as:

0 0 0 0 0 0 0 0
+ +-+-+ +---+---+
| | +---------- Foreground Color
| +------------------- Background Color
+------------------------ Blink Bit

So that means there are 8 backgrounds, starting from black(000) to lightgray(111) . So I think you can go for lightgray. I think white background is not available in 80x25 text mode.

Re:Video mode and text output

Posted: Wed Aug 16, 2006 2:59 pm
by Pype.Clicker
Viral wrote: Hello..
So I think you can go for lightgray. I think white background is not available in 80x25 text mode.
That depends on some other control settings. The "blink" bit can be replaced by a 16-colors background mode with appropriate knowledge of VGA registers. See the freevga documentations if you really wish to know how ...

Re:Video mode and text output

Posted: Wed Aug 16, 2006 4:12 pm
by evincarofautumn
You could also mess around with the palette:

Setting an entry

Code: Select all

    out     0x03c8,index(0-15)
    out     0x03c9,red(0-63)
    out     0x03c9,green(0-63)
    out     0x03c9,blue(0-63)
Getting an entry

Code: Select all

    out     0x03c7,index(0-15)
    in      0x03c9,red(0-63)
    in      0x03c9,green(0-63)
    in      0x03c9,blue(0-63)

Re:Video mode and text output

Posted: Sat Aug 19, 2006 6:18 am
by blip
It can be done with a simple BIOS call as well if you want, no need to fiddle with VGA registers.

Code: Select all

mov ax,1003h
mov bl,0
int 10h
http://heim.ifi.uio.no/~stanisls/helppc/int_10-10.html