how to write characters in graphics mode !!!!
i can jus plot pixel !!
chars in graphics mode..
Re: chars in graphics mode..
I think you have to do it with something like "font files". These would be files with a bitmap for every character you want to print. If you want to print a character, you look for its bitmap and then you draw this bitmap on the screen.
(I don't think that your hardware will do that for you if you thought there'ld be a buffer like 0xB8000 in text mode.)
(I don't think that your hardware will do that for you if you thought there'ld be a buffer like 0xB8000 in text mode.)
Re: chars in graphics mode..
Hi,
In this case the "characterData" array describes the 8 * 8 character, in one bit per pixel format. The "conversionMask_8_to32" is used to convert from "one bit per pixel" format into "one byte per pixel" format, so (for e.g.) if the byte of character data is 0010011b you end up with the pair of 32-bit values 0x0000FF00 and 0x0000FFFF. Finally, the boolean operations use these masks to set some pixels to "colour" and leave other pixels untouched.
Note1: If you want, you could pre-process the character data so that you can do "byteMask1 = characterData32[character][row][0];". Even though this reduces the number of table lookups done, it might make things slower due the cache locality (increased chance of cache misses).
Note2: This same basic technique can work really well with SSE or in long mode, especially if you unroll the loop.
Note3: This basic technique can be improved with bit shifting, to ensure that all accesses to/from display memory (or your video buffer) are aligned.
Of course "efficient" isn't the same as "high quality" - for high quality results you'd want to use variable width fonts based on vectors.
Cheers,
Brendan
One of the most efficient methods tends to go something like this (for 256 colour mode with 8 * 8 character data):asdfgh wrote:how to write characters in graphics mode !!!!
i can jus plot pixel !!
Code: Select all
colourMask = colour << 24 | colour << 16 | colour << 8 | colour
for(row = 0; row < 8; row++) {
rowData = characterData[character][row];
byteMask1 = conversionMask_8_to32[rowData][0];
byteMask2 = conversionMask_8_to32[rowData][1];
*(u32 *)screenAddress = (colourMask & byteMask1) | (*(u32 *)screenAddress & ~byteMask1);
*(u32 *)(screenAddress + 4) = (colourMask & byteMask2) | (*(u32 *)(screenAddress + 4) & ~byteMask2);
screenAddress += bytes_per_row;
}
Note1: If you want, you could pre-process the character data so that you can do "byteMask1 = characterData32[character][row][0];". Even though this reduces the number of table lookups done, it might make things slower due the cache locality (increased chance of cache misses).
Note2: This same basic technique can work really well with SSE or in long mode, especially if you unroll the loop.
Note3: This basic technique can be improved with bit shifting, to ensure that all accesses to/from display memory (or your video buffer) are aligned.
Of course "efficient" isn't the same as "high quality" - for high quality results you'd want to use variable width fonts based on vectors.
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.
Re: chars in graphics mode..
You are just teasing him aren't you? It's quite clear he hasn't got a clue about much, let alone about SSE or long mode .Brendan wrote:Note2: This same basic technique can work really well with SSE or in long mode, especially if you unroll the loop.
JAL
Re: chars in graphics mode..
Yah have a feeling he's one off those people who write a VESA driver without doing anything else then try and setup a form of TUI on it....jal wrote:You are just teasing him aren't you? It's quite clear he hasn't got a clue about much, let alone about SSE or long mode .Brendan wrote:Note2: This same basic technique can work really well with SSE or in long mode, especially if you unroll the loop.
JAL
Brendan's being evil
Jules
edit: corrected spelling...
-
- Member
- Posts: 2566
- Joined: Sun Jan 14, 2007 9:15 pm
- Libera.chat IRC: miselin
- Location: Sydney, Australia (I come from a land down under!)
- Contact:
Re: chars in graphics mode..
Maybe not *him*, but I'm sure someone else might stumble across this thread and read Brendan's post and figure out one of their problems. All it takes is a simple forum searchYou are just teasing him aren't you? It's quite clear he hasn't got a clue about much, let alone about SSE or long mode