About video card text mode.

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
oizys
Posts: 3
Joined: Thu Aug 28, 2008 8:59 am

About video card text mode.

Post by oizys »

When I put a number into the video memory,there will be a char display on the monitor.
Then,how the video card konw which char will be display and how to show it? Is there any files in the video memory or pc memory control it ?


Because I want to write a OS can display Chinese in text mode,so it is important to me.
Thinks!



oizys
User avatar
thepowersgang
Member
Member
Posts: 734
Joined: Tue Dec 25, 2007 6:03 am
Libera.chat IRC: thePowersGang
Location: Perth, Western Australia
Contact:

Re: About video card text mode.

Post by thepowersgang »

http://wiki.osdev.org/VGA_Hardware

The basic gist is that in Text Mode, Planes 0 and 1 are used for the character and attributes and Plane 2 is the font data.
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: About video card text mode.

Post by Combuster »

The limit of text mode is that you can have only 256 (or 512 if you want to do VGA-specific stuff) different characters max on your screen. How do you intend to cope with the fact that chinese (as I recall it) has much more characters than that?
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Re: About video card text mode.

Post by jal »

Combuster wrote:The limit of text mode is that you can have only 256 (or 512 if you want to do VGA-specific stuff) different characters max on your screen. How do you intend to cope with the fact that chinese (as I recall it) has much more characters than that?
About 20,000 in the Unified CJK section of Unicode, but I think one can get by with about 1000-4000 for daily use.


JAL
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: About video card text mode.

Post by Brendan »

Hi,
Combuster wrote:The limit of text mode is that you can have only 256 (or 512 if you want to do VGA-specific stuff) different characters max on your screen. How do you intend to cope with the fact that chinese (as I recall it) has much more characters than that?
It might be theoretically possible to come slightly close - every time you draw a screen you find the 510 most frequently used characters, then auto-generate a new font that contains the 510 most frequently used characters. For the 2 remaining characters, one would be used for white-space. The last character would be a special "Sorry, can't display this properly at the moment" character.

With 40*25 text mode there's a maximum of 1000 characters on the screen at a time, so worst case would be 510 unique characters and 490 characters that can't be displayed. If 250 of those characters are whitespace and 250 of them are used twice, then it works without any characters that can't be displayed properly. Also, if you halve the resolution (e.g. only use even columns, where odd columns always contain whitespace) then you'd always be able to display all characters.

However, it'd be a lot easier to just use graphics mode instead. This would give better results too. Creating 8 * 8 or 8 * 16 bitmap fonts is hard enough for ASCII characters without trying to adequately represent the fine brush-strokes of Chinese (you can't use anti-aliasing for text mode fonts, or 32 * 32 fonts).


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
oizys
Posts: 3
Joined: Thu Aug 28, 2008 8:59 am

Re: About video card text mode.

Post by oizys »

Combuster wrote:The limit of text mode is that you can have only 256 (or 512 if you want to do VGA-specific stuff) different characters max on your screen. How do you intend to cope with the fact that chinese (as I recall it) has much more characters than that?


I know that there is only 256 characters can be show in text mode,but the rule is set by someone who write and build it...

So I want to change it,and I just want to konw if it is possible.


oizys
Last edited by oizys on Fri Sep 12, 2008 8:49 am, edited 1 time in total.
oizys
Posts: 3
Joined: Thu Aug 28, 2008 8:59 am

Re: About video card text mode.

Post by oizys »

Brendan wrote:Hi,
Combuster wrote:The limit of text mode is that you can have only 256 (or 512 if you want to do VGA-specific stuff) different characters max on your screen. How do you intend to cope with the fact that chinese (as I recall it) has much more characters than that?
It might be theoretically possible to come slightly close - every time you draw a screen you find the 510 most frequently used characters, then auto-generate a new font that contains the 510 most frequently used characters. For the 2 remaining characters, one would be used for white-space. The last character would be a special "Sorry, can't display this properly at the moment" character.

With 40*25 text mode there's a maximum of 1000 characters on the screen at a time, so worst case would be 510 unique characters and 490 characters that can't be displayed. If 250 of those characters are whitespace and 250 of them are used twice, then it works without any characters that can't be displayed properly. Also, if you halve the resolution (e.g. only use even columns, where odd columns always contain whitespace) then you'd always be able to display all characters.

However, it'd be a lot easier to just use graphics mode instead. This would give better results too. Creating 8 * 8 or 8 * 16 bitmap fonts is hard enough for ASCII characters without trying to adequately represent the fine brush-strokes of Chinese (you can't use anti-aliasing for text mode fonts, or 32 * 32 fonts).


Cheers,

Brendan


You are rigth,use graphics mode instead is much more simple.


I got a bin file of VIDEO ROM from my linux memroy by use "cat /proc/iomem" cmd,and I found there is a ASCII character bitmaps in it(sorry,I can't descrip it clearly by useing english).

Do you konw who will use these bitmaps,the video or the linux os,and how can I change it?
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: About video card text mode.

Post by Combuster »

The VGA can either use one font bank (for a total of 256 character slots) or two (for a total of 512 character slots) and that's the limit for text mode, period.

So you either use one of the methods Brendan mentioned to try and have enough free slots to describe all, or better, use graphics mode (which is more straightforward than hacking at the font banks which essentially is a braindamaged graphics mode already)

[additional post made]

The font bank stored in the video rom contains the default font for when the system is booted and a font is needed. The only point for the OS to use it is, is for when it doesn't come with its own font and consequently wants to reuse the one coming with the video card. (Which will work pretty well if you only plan on using the first 128 entries), But since you want to print in Chinese, you'll have no use in grabbing an english character set from the graphics card. :wink:
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: About video card text mode.

Post by Brendan »

Hi,
oizys wrote:I got a bin file of VIDEO ROM from my linux memroy by use "cat /proc/iomem" cmd,and I found there is a ASCII character bitmaps in it(sorry,I can't descrip it clearly by useing english).

Do you konw who will use these bitmaps,the video or the linux os,and how can I change it?
The font data you found in the video card's ROM is copied to the video card's RAM and used as the default font whenever the video BIOS is used to set a text mode. It's extremely difficult to change the font data in ROM, but not that hard to change the font data after it's been copied into the video card's RAM.

I'm not sure of the exact method used to change the font data in the video card's RAM - for my OS I use graphics video modes only (even when I only need to display ASCII). I'd be tempted to try this video BIOS function though (and probably this one too)...
oizys wrote:You are rigth,use graphics mode instead is much more simple.
Yes - it also let's you draw windows, icons, pictures, etc (everything that a modern OS needs to draw, not just characters)...


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Post Reply