Plotting pixels directly in pmode
Plotting pixels directly in pmode
Hello everbody
I wanted to plot a pixel with the following function.
void plot_pixel(int x, int y, byte c)
{
byte* offset = (char*)0xA0000 + ((0x280 * x) + y);
*offset = c;
}
[0x280 means 640]
I work in 640*480*256 mode and in pmode.
but it doesn't work. Does anybody have an idea??
I wanted to plot a pixel with the following function.
void plot_pixel(int x, int y, byte c)
{
byte* offset = (char*)0xA0000 + ((0x280 * x) + y);
*offset = c;
}
[0x280 means 640]
I work in 640*480*256 mode and in pmode.
but it doesn't work. Does anybody have an idea??
RE:Plotting pixels directly in pmode
it should still do - in pmode as well.
do you have a data-descriptor with base 0 (otherwise it won't work)?
how do you switch to that vga-mode?
greets, hartyl
do you have a data-descriptor with base 0 (otherwise it won't work)?
how do you switch to that vga-mode?
greets, hartyl
RE:Plotting pixels directly in pmode
Yes my kernel lives in DPL0
I switch to this mode by switching to (un)real mode then do the mode switch via:
mov ax, 4f02h ;
mov bx, 101h ; 640*480*256
int 10h ; call SVGA bios
then I switch back to pmode
The only thing is that I can't plot pixels
I switch to this mode by switching to (un)real mode then do the mode switch via:
mov ax, 4f02h ;
mov bx, 101h ; 640*480*256
int 10h ; call SVGA bios
then I switch back to pmode
The only thing is that I can't plot pixels
RE:Plotting pixels directly in pmode
First off, you do know that the video memory window at 0x000A0000 is only a 64k chunk, right?
640x480 == ~300kb
In other words, you wont be able to access the entire span of video memory using this mechanism alone (you'll also need to use video bank switching).
Since you're using VESA, you might want to check out my VESA tutorial (meant for DJGPP, but easily ported to any language/environment) at http://www.neuraldk.org/document.php?djgppGraphics
Cheers,
Jeff
640x480 == ~300kb
In other words, you wont be able to access the entire span of video memory using this mechanism alone (you'll also need to use video bank switching).
Since you're using VESA, you might want to check out my VESA tutorial (meant for DJGPP, but easily ported to any language/environment) at http://www.neuraldk.org/document.php?djgppGraphics
Cheers,
Jeff
RE:Plotting pixels directly in pmode
when you're using VESA it's best to use the LFB (linear frame buffer). you can get the base-address of the buffer via an "int 10h"-call & write to it like to good old 0xA0000.
greets, hartyl
greets, hartyl
RE:Plotting pixels directly in pmode
Thanks I didn't knew that until I discovered it while plotting pixels. No I'm going to find out the addr of the LFB.
RE:Plotting pixels directly in pmode
thanks Hartyl,
After trying to work with the LFB it worked for me
Thanks mate!!
After trying to work with the LFB it worked for me
Thanks mate!!
RE:Plotting pixels directly in pmode
Just a quick note; the LFB is not supported on all graphics cards... at least not through VESA.
To support the widest variety of graphics cards, you should also consider writing drivers for VESA banked modes (using the real mode and pmode banking routines).
It's truely a pain, but it'll give you excellent coverage, and reduce the need for chipset specific drivers (which are even more a pain!) for a time.
Cheers,
Jeff
To support the widest variety of graphics cards, you should also consider writing drivers for VESA banked modes (using the real mode and pmode banking routines).
It's truely a pain, but it'll give you excellent coverage, and reduce the need for chipset specific drivers (which are even more a pain!) for a time.
Cheers,
Jeff
RE:Plotting pixels directly in pmode
Your right but I don't know how to do bankswitches in pmode. (without switching back to real mode). I know how to do it in real mode but how to this in pmode??
Greetz
Greetz
RE:Plotting pixels directly in pmode
The link I previously gave (http://www.neuraldk.org/document.php?djgppGraphics) shows how to use the pmode banking routines. VESA 2.0 defines a pointer (32-bit flat pointer) to both the LFB and protected mode banking routine.
Cheers,
Jeff
Cheers,
Jeff
RE:Plotting pixels directly in pmode
Hey,
Plotting of pixels could be quite simple if you read up on VESA. All you have to do is build v86 functionality into your kernel(quite simple). Then write a little biosCall function which will utilize the v86 procedures to call the bios and init a VESA mode for you. Then get the VESA information about the LFB and have your VMM map that region of memory in. Once all that is complete just write to it and you will see things appear on the screen. I on the other hand just use the ubix graphics lib plotPixel to do that.
-Christopher
Plotting of pixels could be quite simple if you read up on VESA. All you have to do is build v86 functionality into your kernel(quite simple). Then write a little biosCall function which will utilize the v86 procedures to call the bios and init a VESA mode for you. Then get the VESA information about the LFB and have your VMM map that region of memory in. Once all that is complete just write to it and you will see things appear on the screen. I on the other hand just use the ubix graphics lib plotPixel to do that.
-Christopher