I am New to C programming . Please Someone Guide me how access VDU memory and well as VDU fundamentals
I am New to C programming . Please Someone Guide me how access VDU memory and well as VDU fundamentals
The name wasn't immediately familiar to me, but a quick google search brought up loads of funderful stuff; int86(), far pointers, CGA graphics...
It's the 21st century; are you sure you want to mess with that junk?
If so, give a better description of why you need to use archaic low level video functions.
hello, internet!
I agree to some extend.It's the 21st century; are you sure you want to mess with that junk?
But as you will look into this you will learn alot, i agree this is the 21st century...
Its not because we have online newspapers we should forget about normal "physical paper" which we can hold tight, adore or trow away when they write crap...
If you want a good reference and a great tutorial with source code included etc ( even for different compilers ) about VGA mode check out this site
http://www.brackeen.com/home/vga/.
For making cool OLD-looking console games these tutorials just rock .
:::reminds me about Commander Keen series:::
Greets,
Ganglylamb.
Last edited by GanglyLamb; 09-27-2004 at 09:51 AM.
Originally Posted by Salem
For someone new to graphics programming, I don't see how this is anything but a dead end though. The only support of this stuff comes from archaic compilers running on archaic systems. Win2k+ emulate some of the dirty tricks involved, but all that is very iffy.
In addition, IMO this is harder than learning modern graphics programming. I believe strongly in Allegro, a cross program graphics library. It supports a number of modern systems and modern hardware configurations, and is easy to learn. Drawing and graphics primitives are all documented in plain easy-to-understand english. There are also about eleventeen bazillion less wild pointers to take heed of.
hello, internet!
Direct acess to VDU memory is not allowed in later *nix nor windows NT, due to the protected memory mode. You'll have to use a high level API. Create a window and maximize it, and change the screen resolution. Or go back to old ms dos or win 95/98/me. You may use a dev environemt like DJGPP (gcc included). I've already worked with this package with the same purpose.
Try this url for the toolkit:
http://www.delorie.com/djgpp/
some extras (using of course DJGPP):
Comments: the above code display 2 rectangles, one on top of the other, in yellow background. This program is VBE compliant.Code:#include <dpmi.h> #include <go32.h> #include <sys/nearptr.h> #define pixel(buf, x, y, color) ((buf)[(y)*1024+(x)]=(color)) __dpmi_meminfo map; //memory mapping unsigned long GetMapVideoMem(int mode){ __dpmi_regs r; unsigned long dosbuf, address=0; dosbuf = __tb & 0xFFFFF; dosmemput(&address, 4, dosbuf+40); r.x.ax = 0x4F01; r.x.di = dosbuf & 0xF; r.x.es = (dosbuf>>4)& 0xFFFF; r.x.cx = mode; __dpmi_int(0x10, &r); if(r.h.ah) return 0; dosmemget(dosbuf+40, 4, &address); if(!address) return 0; return address; } void *GetVideoMemPtr(int mode){ __djgpp_nearptr_enable(); map.address = GetMapVideoMem(mode);//0xDA000000; if(!map.address) return 0; map.size = resH*resV*1; __dpmi_physical_address_mapping(&map); return (void *)(map.address + __djgpp_conventional_base); } void FreeVideoMemPtr(){ __dpmi_free_physical_address_mapping(&map); __djgpp_nearptr_disable(); } int ChangeVideoMode(int mode){ __dpmi_regs mode; mode.x.ax = 0x4F02; mode.x.bx = 0x4000 | mode; return !__dpmi_int(0x10, &mode); } int RestoreVideoMode(){ __dpmi_regs mode; mode.x.ax = 0x0003; return !__dpmi_int(0x10, &mode); } void DrawRectangle(char *buf,int x1,int y1,int x2, int y2, char color){ int i,j, tmp; //avoid exchanged variables if(x1>x2){tmp=x1;x1=x2;x2=tmp;} if(y1>y2){tmp=y1;y1=y2;y2=tmp;} //draw the rectangle for(i=x1;i<=x2; i++) for(j=y1;j<=y2;j++) pixel(buf,i,j,color); } int main(){ char *VDUmem;//8 bits per pixel int mode = 0x0105;//0x105h (1024x768x8bit) if(!ChangeVideoMode(mode)){ fprintf(stderr,"ERROR: graphics mode not changed.\n"); return 1; } VDUmem=(char*)GetVideoMemPtr(mode); if(!VDUmem){ fprintf(stderr,"ERRO: video memory mapping failed.\n"); RestoreVideoMode(); return 2; } DrawRectangle(VDUmem,0,0,1023,768,14);//yellow DrawRectangle(VDUmem,200,200,823,568,12);//light red DrawRectangle(VDUmem,400,300,623,468,2);//blue getch(); FreeVideoMemPtr(); RestoreVideoMode(); return 0; }
unsigned long GetMapVideoMem(int mode);
- Gets a linear adress for the screen buffer, starting at the upper-left pixel, to the lower-right
char *GetVideoMemPtr(int mode);
- Creates a physical memory map that adresses the linear buffer for the hardware
void FreeVideoMemPtr();
- release the physical memory map
int ChangeVideoMode(int mode);
- changes the current video mode to the one specified
int RestoreVideoMode();
- restores the video mode, to non-VBE compliant (or 80*25 character mode)
void DrawRectangle(char *buf,int x1,int y1,int x2, int y2, char color);
- like duh?!?
Plus, the video modes info:
http://www.geocities.com/SiliconVall...8933/vesa.html
Have fun...
[edit]
I almost forgot the most important of all!
http://www.vesa.org/
[/edit]
Last edited by xErath; 09-27-2004 at 06:41 PM.
Old OSes are still around, and are certainly fun to play with. But invest research into this type of programming only for educational purposes. Its not a marketable skill.