Questions about video cards and keyboard scancode sets

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
ManOfSteel

Questions about video cards and keyboard scancode sets

Post by ManOfSteel »

Hello,

1. Is there any video card that has no hardware scrolling support at all?
2. Is there any video card that has less than 16Kb of text video memory?
By "any video card", I mean any kind: cga, ega, vga, etc...
3. Is there any way to detect the amount of text video memory available?
4. Finally, a question unrelated to video cards: what is the default keyboard scancode set used on most computers from 199x till now. I am using the one included below, but it is not complete and I could not find it in any document. Could any one help me find more about it so I could complete it?

Thank you for your help.

Incomplete scancode set:

Code: Select all

0x1b,'1','2','3','4','5','6','7','8','9','0','-','=',
0x8,0x9,'q','w','e','r','t','y','u','i','o','p','[',']',0xd,0xff,
'a','s','d','f','g','h','j','k','l',';',"'",'`',0xff,'\','z','x','c','v',
'b','n','m',',','.','/'
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Questions about video cards and keyboard scancode sets

Post by Pype.Clicker »

ManOfSteel wrote: Hello,
1. Is there any video card that has no hardware scrolling support at all?
What do you call "hardware scrolling" ? changing the memory offset at which the display should start ?
2. Is there any video card that has less than 16Kb of text video memory?
some CGA cards had only 40x25 text mode and 320x200x4 graphics mode iirc.
3. Is there any way to detect the amount of text video memory available?
afaik, that should be available in the Bios Data Area ...
4. Finally, a question unrelated to video cards: what is the default keyboard scancode set used on most computers from 199x till now. I am using the one included below, but it is not complete and I could not find it in any document. Could any one help me find more about it so I could complete it?
what you gave is not the scancode set: it's the keyboard map. Looking in the FAQ should point you towards a good tutorial (beyond logic) about keyboards that contains the scancode sets (that is, a blank keyboard with scancodes drawn on it)

http://www.osdev.org/osfaq2/index.php/G ... rd%20Input
Exabyte256

Re:Questions about video cards and keyboard scancode sets

Post by Exabyte256 »

Hardware scrolling... Although I'm sure for legacy reasons it's probably supported, it's old technology. I'm not sure what resolution it operates at either. A lot of screens now only support 640x480 and higher resolutions.

If you want to scroll the screen somehow then you should make a buffer the size of the full scrollable screen, and define a rectangle over it (which would be with the scrolling position and the actual screen resolution), the data in that window you copy to the actual video memory whenever it's changed.

With some optimizations, you could cut down a lot of memory copying to only copying the changes and even stopping the need to draw to the buffer in some cases.
ManOfSteel

Re:Questions about video cards and keyboard scancode sets

Post by ManOfSteel »

Thank you for your replies.

Pype.Clicker,
What do you call "hardware scrolling" ? changing the memory offset at which the display should start ?
Exactly.
some CGA cards had only 40x25 text mode and 320x200x4 graphics mode iirc.
Ok, but my questions were about the memory available for text mode. So, beginning from 0xB8000 (or 0xB0000 for mono), is there any video card that has less than 16kb?
afaik, that should be available in the Bios Data Area ...
In the BDA there is the type of video mode (EGA, VGA, PGA, CGA, Monochrome) but not how much text memory it has, if I am not mistaken.


Exabyte256,
Although I'm sure for legacy reasons it's probably supported, it's old technology.
It is old but still works, even with PIV integrated video cards.
I'm not sure what resolution it operates at either. A lot of screens now only support 640x480 and higher resolutions.
I was asking for the text mode, not graphic mode.
If you want to scroll the screen somehow then you should make a buffer the size of the full scrollable screen, and define a rectangle over it (which would be with the scrolling position and the actual screen resolution), the data in that window you copy to the actual video memory whenever it's changed.
As far as I understand, that is more or less "software scrolling" and I already do that, but it costs too much CPU work, just for one line scroll, when it does a carriage return on the last line when the enter key is pressed for example. That is why I will use hardware scrolling most of the time and software scrolling only when necessary. Note also that I am still and only talking about text mode, not graphic mode.
Kemp

Re:Questions about video cards and keyboard scancode sets

Post by Kemp »

Ok, but my questions were about the memory available for text mode.
How about doing the maths? 40x25 = 1000, double for attribute bytes is 2000. So a card which *only* supports 40x25 text mode probably won't have 16KB of onboard. Of course, 320x200x4 graphics mode comes to 32000 bytes, which is over 16KB so once again simple maths has solved your question (ignoring any tricks used by the card to fit it in less memory).
Exabyte256

Re:Questions about video cards and keyboard scancode sets

Post by Exabyte256 »

Ooh, I thought you were talking about actual graphics scrolling!

But I'm still not sure why it should take a lot of CPU work, especially with so little data. I guess I need to learn a bit more about how graphic blitting actually works.
ManOfSteel

Re:Questions about video cards and keyboard scancode sets

Post by ManOfSteel »

Kemp,
How about doing the maths? 40x25 = 1000, double for attribute bytes is 2000.
I did the maths long ago. I already have a working display and am currently implementing virtual consoles. But thank you anyway.
So a card which *only* supports 40x25 text mode probably won't have 16KB of onboard. Of course, 320x200x4 graphics mode comes to 32000 bytes, which is over 16KB
I just thought video cards did not only have the minimum necessary to show text, I thought they could have more than what is needed for one screen. That is why I asked these questions.
So, would such "text cards" only have 2000 bytes of memory? Do such cards exist? And anyway, am I mistaken or text memory has nothing to do with graphic memory, with one being mapped at 0xB8000 and the other at 0xA0000?


Exabyte256,
But I'm still not sure why it should take a lot of CPU work, especially with so little data.
Think for example about the tons of information about the hardware, their drivers, network and user settings being printed to screen at some point (like the start-up) as it is under unix-type OS. Everytime the text reachs the end of the 24th row, the OS scrolls the entire screen by moving 3840 bytes (80x24x2) and blanking one line (160 bytes). The same goes with every CR and LF.
Kemp

Re:Questions about video cards and keyboard scancode sets

Post by Kemp »

If you're developing for desktop systems you'll be hard pressed to find a card that only runs at the resolution mentioned, the only realistic way it'll ever run on one of them is if you use one yourself for testing purposes. On the other hand, if you're catering for a specialist market (embedded systems, squeezing performance out of super-low-end systems, etc etc) then you may very well come across a machine with these capabilities or less. It all depends what you're writing the OS for.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:Questions about video cards and keyboard scancode sets

Post by Solar »

ManOfSteel wrote: 4. Finally, a question unrelated to video cards: what is the default keyboard scancode set used on most computers from 199x till now.
Chinese, most likely...

Never mind. The rest of the world is rather used to the US QWERTY layout being the default. ;)
Every good solution is obvious once you've found it.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Questions about video cards and keyboard scancode sets

Post by Pype.Clicker »

yep. If you have to come with only one layout, pick US keymap. At least, people on MT will accept to use it when testing your system because we had to use US qwerty one day or the other and we can figure out where keys are hiding ... if i had to figure how is the damn backslash on finnish or german keyboard ... well ... i'll be in trouble.
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re:Questions about video cards and keyboard scancode sets

Post by Brendan »

Hi,
ManOfSteel wrote:Think for example about the tons of information about the hardware, their drivers, network and user settings being printed to screen at some point (like the start-up) as it is under unix-type OS. Everytime the text reachs the end of the 24th row, the OS scrolls the entire screen by moving 3840 bytes (80x24x2) and blanking one line (160 bytes). The same goes with every CR and LF.
In text mode, you'd only be moving ~4 KB (at most) which is trivial for anything that can handle protected mode (e.g. it won't even slow down Bochs noticeably).

It does cause problems when you're pretending your in text mode though. For example, if you set a high resolution graphics mode during boot and you're trying to make it look like you're in text mode when you aren't. In this case it can be much much slower - mostly because of the much larger amount of video RAM you're shifting.

In this case, most video cards probably do support hardware vertical scrolling, which could make it look very smooth and improve performance a lot. Unfortunately you'll probably need to write a video driver for every video card before it'll work reliably.

However, there are some things that can be done. The first would be to use an oversized double buffer in RAM. For example, for 1024 * 768 video mode you could have a 1024 * 2048 buffer in RAM, and blit from RAM to display memory (rather than copying data from display memory to display memory). This would also mean you'd only need to scroll the buffer in RAM when you reach the end of the buffer - e.g. row 2048 rather than row 768.

Another approach is to update the display every N mS (if necessary), rather than every time it changes. It's likely that software will be sent to video in "chunks" - for example, a disk driver might send 6 lines of text at once. In this case, you'd normally scroll the screen 6 times, one after the other. This isn't too smart - it'd be better to keep track of what has been added since the screen was updated last. Then you'd work out how many lines to scroll, scroll several lines at once, then add several lines to the bottom. Depending on the text you're displaying, instead of scrolling for every screen line it could work out to an average of every 5 lines or something.

If you combined both of these, the screen scrolling could easily be 10 times faster than a "simple" system. The extra work it takes to implement and the amount of RAM you'd need to use for it might be a problem though.

There is one third technique, which is a little cheeky. Basically, no-one ever reads these screenfulls of text, and to be honest they make the OS look un-professional, so don't bother displaying it! ;)

More accurately, there's 3 different types of users. There's the normal users, who never read it and don't want it in the first place - they'd rather see a "pretty" splash screen with the OS's logo or something.

Then there's system administrators. These people do want to see it (they're smart enough to know a "pretty" splash screen is useless), but they only want to read it when something has gone wrong, and then they'd rather only see the messages that are relevant to whatever went wrong rather than 10 screens of useless text.

Finally there's developers, who try to read this stuff but can't because it scrolls past so fast that they need a high speed camera to catch it.

It all sounds a bit silly to me...

A better idea would be to dump everything to a big long ASCIIZ string in memory and never display it (a "system log"). Then you can add extra code to handle error messages. These error messages would be sent to the system log too (just like normal stuff), but also displayed on the screen. Hopefully the error messages will be rare, and there won't be enough of them that scrolling the screen becomes a problem. After boot you'd dump the system log into a file (e.g. "boot.log"), so anyone who wants to read it can open it with their favourite text editor (or do "cat boot.log | more").

Of course this sort of thing doesn't help when you're first writing your kernel - what you really need is temporary "dump everything to the screen" code. Of course because it's temporary, any old hack will do...


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