Page 1 of 1
BIOS plotting vs writing directly to video memory
Posted: Thu Jun 10, 2004 7:20 pm
by Kon-Tiki
Which one's the most efficient, and what's the best way for somebody new to this to learn how to do it? Got some tutorials, and they've allowed me to set graphical mode instead of text mode, but the actual plotting of pictures's still a point where I'm doubting wether to go one way or the other. BIOS is said to be easier to do, but alot slower, while writing straight to video memory's said to be alot faster, but harder to do too. I don't know how much it'll influence computers from 486 on, nor do I know exactly how big those differences are, so I have no basis as to what I should make my choice for now. Any help'd be greatly appreciated.
Re:BIOS plotting vs writing directly to video memory
Posted: Fri Jun 11, 2004 2:29 am
by srg
Although using BIOS is nice and easy, writting to video memory it wwwaaaaayyyyyy faster.
Are you in text mode of graphics?
Are you in Protected mode or real mode? In PMode, realistically you MUST go direct to video memory.
srg
Re:BIOS plotting vs writing directly to video memory
Posted: Fri Jun 11, 2004 7:41 am
by Kon-Tiki
Code: Select all
void SetMode (unsigned int Mode) {
union REGS regs;
regs.x.ax = Mode; /* Put the desired mode in register AX */
int86(0x10,®s,®s); /* Showtime! */
}
void Plot_Pixel_BIOS(unsigned int x, unsigned int y, int color) {
union REGS regs;
regs.h.ah = 0x0c;
regs.h.al = color;
regs.x.cx = x;
regs.x.dx = y;
/* Call BIOS function 0x0C (PlotPixel) */
int86(0x10, ®s, ®s);
}
union REGS regs;
regs.h.ah = 0x00; /* function 00h = mode set */
regs.h.al = 0x13; /* 256-color mode 13h */
int86(0x10,®s,®s); /* do it! */
regs.h.ah = 0x00;
regs.h.al = 0x03; /* text mode is mode 3 */
int86(0x10,®s,®s);
return 0;
This's all the code I have for now, taken from all over the total code. Dunno which one it is, PMode or RMode.
Re:BIOS plotting vs writing directly to video memory
Posted: Fri Jun 11, 2004 11:11 am
by Curufir
Looks like PMode code relying on a VM86 task to do the graphics via the standard BIOS int 10.
That'll be MUCH slower than handling things yourself.
Re:BIOS plotting vs writing directly to video memory
Posted: Fri Jun 11, 2004 1:05 pm
by Kon-Tiki
Ok, so according to Srg, I have to do it myself then. Does this mean that both effects neutralize themselves, or is it more like -5 + 1?
Re:BIOS plotting vs writing directly to video memory
Posted: Fri Jun 11, 2004 1:58 pm
by Curufir
Doing it yourself is going to be faster there's no doubt about it.
How complicated it is to program really depends on what graphics mode you're working in. Eg VGA 320x200x256 is very straightforward and simple to do, whilst 640x480x16 is far more of a pain in the neck.
If you can live with drawing using the BIOS interrupts then I'd suggest continuing and doing the rest of whatever your project is first. You can replace the drawing routines with your own at any point.
Re:BIOS plotting vs writing directly to video memory
Posted: Fri Jun 11, 2004 2:16 pm
by Kon-Tiki
Hmmm... 256 colors's always better than 16 ;D I'll go with that. This means directly writing, right? Any hints on doing that as simple and efficient as possible?
Re:BIOS plotting vs writing directly to video memory
Posted: Fri Jun 11, 2004 7:56 pm
by Curufir
Look up 'Graphics mode 13' in google.
That should give you some starting links. There are a huge number of tutorials on this mode because a lot of older demos got written in it (Because it's easy/fast).
Re:BIOS plotting vs writing directly to video memory
Posted: Sat Jun 12, 2004 4:05 am
by Kon-Tiki
I got
this,
and [url=http://mega.ist.utl.pt/~fjds//vga13tut1.html]this. The last two got me as far as I am now, but the first one seems to be able to get me further. It leaves a couple of questions open, though.
How do these lines of code work?
__dpmi_regs rg;
vb = (unsigned char*) (__djgpp_convential_base+0xA0000);
__dpmi_int (0x10, &rg);
What I'm asking is mostly 'bout that Djgpp-specific command (those things starting with __)
Typos in code
As the author made some typos, of which some in the example code (obvious one is: unsigned char *vidoe_buffer), which parts of the example code containts more of them that aren't as obvious (like they could be standard things... inport comes into mind)?