OSDev.org

The Place to Start for Operating System Developers
It is currently Wed Oct 23, 2019 7:26 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: VGA Fonts In Graphics Mode
PostPosted: Sat May 25, 2019 4:52 pm 
Offline

Joined: Sat May 25, 2019 4:42 pm
Posts: 5
I'm currently trying to set up printing characters to the screen and I'm following the article on the wiki: https://wiki.osdev.org/VGA_Fonts

I can get the inefficient versions to work quit easily, that is, just calling the putpixel command several times. but I can't seem to get he optimised versions to work. I'm Specifically talking about the last piece of code in the article:
Code:
void drawchar_transparent_8BPP(unsigned char c, int x, int y, int fgcolor)
{
   void *dest;
   uint32_t *dest32;
   unsigned char *src;
   int row;
   uint32_t fgcolor32;

   fgcolor32 = fgcolor | (fgcolor << 8) | (fgcolor << 16) | (fgcolor << 24);
   src = font + c * 16;
   dest = videoBuffer + y * bytes_per_line + x;
   for(row = 0; row < 16; row++) {
      if(*src != 0) {
         mask_low = mask_table[*src][0];
         mask_high = mask_table[*src][1];
         dest32 = dest;
         dest32[0] = (dest[0] & ~mask_low) | (fgcolor32 & mask_low);
         dest32[1] = (dest[1] & ~mask_high) | (fgcolor32 & mask_high);
      }
      src++;
      dest += bytes_per_line;
   }
}

I cant seem to get this code to work even after modifying it a fair bunch. There is also an example on the wiki in a slightly different article https://wiki.osdev.org/Drawing_In_Protected_Mode
(the last code section in the article) but i also cant get that one to work either. Can someone confirm is these pieces of code are actually correct? or if you have any alternate implementations?

cheers
danny


Top
 Profile  
 
 Post subject: Re: VGA Fonts In Graphics Mode
PostPosted: Sat May 25, 2019 8:24 pm 
Offline
Member
Member

Joined: Fri Aug 26, 2016 1:41 pm
Posts: 488
Out of curiosity is this a 32-bit kernel or 64-bit kernel? Using Multiboot or your own custom bootloader? Do you have a project available to look at? Building with optimizations on or off?


Top
 Profile  
 
 Post subject: Re: VGA Fonts In Graphics Mode
PostPosted: Tue May 28, 2019 6:02 am 
Offline
Member
Member
User avatar

Joined: Thu Oct 13, 2016 4:55 pm
Posts: 392
Hi,

I've written a font renderer that may help you. See "ssfn_putc()".

Cheers,
bzt


Top
 Profile  
 
 Post subject: Re: VGA Fonts In Graphics Mode
PostPosted: Wed May 29, 2019 12:43 pm 
Offline

Joined: Sat May 25, 2019 4:42 pm
Posts: 5
Cheers bzt that helped quite a lot.
Turned out the issue was that the examples on wiki are only optimised for 8bpp and I was working in up to 32.
Solved the issue by reintroducing the inner for-loop and keeping the 'where' pointer outside of all the loops.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], MSN [Bot], thomtl and 12 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group