Printing text in 640x480 graphics mode is not working

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.
User avatar
Roman
Member
Member
Posts: 568
Joined: Thu Mar 27, 2014 3:57 am
Location: Moscow, Russia
Contact:

Re: Printing text in 640x480 graphics mode is not working

Post by Roman »

I'm not really experienced with VGA, but couldn't it be that the frame buffer is not contiguous?
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
- Alan Kay
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: Printing text in 640x480 graphics mode is not working

Post by Brendan »

Hi,
catnikita255 wrote:
Brendan wrote:Then we need more symptoms - e.g. is the loop doing 8 iterations but the pixels aren't being set or is the loop actually only doing one iteration; is something in "putpixel()" dodgy and interfering with the loop; if you call "vgaPutchar" multiple times do you get the same symptoms for all characters or just the first; etc.
1) I can't check it, because i can't print text.
Anything that causes a difference in observable behaviour can be used to check it. This includes printing text; but also includes (deliberately) triple faulting or doing a "while(forever)" (where you can tell if the computer reboots or not), or making keyboard LEDs flash, or making PC speaker beep, or filling the entire screen with white (or black, or not). Also don't forget that you should be able to execute your code in a virtual machine and watch everything that happens as it happens (e.g. single-stepping in Bochs).
catnikita255 wrote:I'm fully filled first line of letters with '1' symbols, so i can see that it's printing it.
Maybe your "putpixel()" is broken (e.g. and does something like "address = displayMemory + y * 123456789 + x/8", so that it only works properly if y=0) and there's nothing wrong with your "vgaPutchar()". Did you try printing anything on the second line (or any other lines)?


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.
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: Printing text in 640x480 graphics mode is not working

Post by Brendan »

Hi,
Roman wrote:I'm not really experienced with VGA, but couldn't it be that the frame buffer is not contiguous?
For "640*480 with 16 colour" VGA mode, it's not contiguous - it's 4 planes with 1 bit per pixel; where a single pixel is 4 bits and those 4 bits are spread across all 4 planes. This is what makes it extremely slow if you don't do things right. ;)


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.
User avatar
osdever
Member
Member
Posts: 492
Joined: Fri Apr 03, 2015 9:41 am
Contact:

Re: Printing text in 640x480 graphics mode is not working

Post by osdever »

Brendan wrote:Hi,
catnikita255 wrote:
Brendan wrote:Then we need more symptoms - e.g. is the loop doing 8 iterations but the pixels aren't being set or is the loop actually only doing one iteration; is something in "putpixel()" dodgy and interfering with the loop; if you call "vgaPutchar" multiple times do you get the same symptoms for all characters or just the first; etc.
1) I can't check it, because i can't print text.
Anything that causes a difference in observable behaviour can be used to check it. This includes printing text; but also includes (deliberately) triple faulting or doing a "while(forever)" (where you can tell if the computer reboots or not), or making keyboard LEDs flash, or making PC speaker beep, or filling the entire screen with white (or black, or not). Also don't forget that you should be able to execute your code in a virtual machine and watch everything that happens as it happens (e.g. single-stepping in Bochs).
catnikita255 wrote:I'm fully filled first line of letters with '1' symbols, so i can see that it's printing it.
Maybe your "putpixel()" is broken (e.g. and does something like "address = displayMemory + y * 123456789 + x/8", so that it only works properly if y=0) and there's nothing wrong with your "vgaPutchar()". Did you try printing anything on the second line (or any other lines)?


Cheers,

Brendan
1) I'm using QEMU, is it have single-stepping in it? 2) I'm drawn some figures and they are displaying fine, so my putpixel() is working.
Developing U365.
Source:
only testing: http://gitlab.com/bps-projs/U365/tree/testing

OSDev newbies can copy any code from my repositories, just leave a notice that this code was written by U365 development team, not by you.
User avatar
osdever
Member
Member
Posts: 492
Joined: Fri Apr 03, 2015 9:41 am
Contact:

Re: Printing text in 640x480 graphics mode is not working

Post by osdever »

Now i'm writed my vgaPrintStr() function, all lines is displaying, but why it's not displaying letters? Only background color is displaying.
Developing U365.
Source:
only testing: http://gitlab.com/bps-projs/U365/tree/testing

OSDev newbies can copy any code from my repositories, just leave a notice that this code was written by U365 development team, not by you.
User avatar
iansjack
Member
Member
Posts: 4707
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Printing text in 640x480 graphics mode is not working

Post by iansjack »

catnikita255 wrote: 1) I can't check it, because i can't print text.
Run your code under a debugger; then you can check whatever you want to.
User avatar
osdever
Member
Member
Posts: 492
Joined: Fri Apr 03, 2015 9:41 am
Contact:

Re: Printing text in 640x480 graphics mode is not working

Post by osdever »

No, i'm fixed problem with 1 line, but text is not displaying, only BG color.
Developing U365.
Source:
only testing: http://gitlab.com/bps-projs/U365/tree/testing

OSDev newbies can copy any code from my repositories, just leave a notice that this code was written by U365 development team, not by you.
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re: Printing text in 640x480 graphics mode is not working

Post by Candy »

Hi.

So far the troubles that you've had seem to be things that you can easily solve in a regular development environment, and are code that is not tied to OS development specifically, so I would recommend you to first try to get the code working in a normal environment (with debuggers and so on, say using SDL for graphics output) and only *then* porting it to a barebones environment.
User avatar
osdever
Member
Member
Posts: 492
Joined: Fri Apr 03, 2015 9:41 am
Contact:

Re: Printing text in 640x480 graphics mode is not working

Post by osdever »

Thank you all, now text is displaying fine! I'm so happy now!
Developing U365.
Source:
only testing: http://gitlab.com/bps-projs/U365/tree/testing

OSDev newbies can copy any code from my repositories, just leave a notice that this code was written by U365 development team, not by you.
Post Reply