From: "John M. Aldrich" Newsgroups: comp.os.msdos.djgpp Subject: Re: Mode13h help... Date: Thu, 11 Dec 1997 19:03:45 +0000 Organization: Two pounds of chaos and a pinch of salt Lines: 107 Message-ID: <34903911.4069@cs.com> References: <348F6F25 DOT 564D AT alpha DOT delta DOT edu> Reply-To: fighteer AT cs DOT com NNTP-Posting-Host: ppp203.cs.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Matt Kris wrote: > > Howdy... > > This code is suppose to just plot a pixel. It will compile with DJGPP > but will not run. Please look through it and see what you's can come up > with. Thanks You're using real mode memory access code in a protected mode environment. This simply will not work the way you have written it. At best, it will crash; at worst it may overwrite other parts of your program. Just a question: I'm curious how you think the number 0xA00000000 is going to fit into a 4 byte variable. :-) Lots of information on graphics and memory access under protected mode can be found in chapters 10, 17, and 18 of the DJGPP Frequently Asked Questions list, available from SimTel as v2/faq210b.zip, or online at http://www.delorie.com/djgpp/v2faq/. A brief beginner's graphics tutorial can be found at http://www.rt66.com/~brennan/djgpp/. BTW, I'll rewrite your code so that it works. hth! ----------- /** ******************************************************************* * fast.c * * written by Matt Kris * **********************************************************************/ #include #include #include /* kbhit */ #include /* __dpmi_regs, __dpmi_int */ #include /* __djgpp_nearptr_* */ #define VIDEO 0x10 /* the BIOS video interrupt. */ #define SET_MODE 0x00 /* BIOS func set video mode. */ #define VGA_256_COLOR_MODE 0x13 /* use to set 256-color mode. */ #define TEXT_MODE 0x03 /* use to set 80x25 text mode. */ char *video_buffer; /* global is okay, but don't initialize yet */ /* char color; */ /* these should not be global */ /* int x, y; */ /*- set mode-------------------------------------------------------*/ void set_mode(unsigned char mode) { __dpmi_regs regs; /* more appropriate for DJGPP */ regs.h.ah = SET_MODE; regs.h.al = mode; /* __dpmi_int() is a safer, better way to call interrupts. */ __dpmi_int( VIDEO, ®s ); return; } /*- Plot_Pixel_Fast ------------*/ void Plot_Pixel_Fast(int x, int y, char color) { video_buffer[((y<<8) + (y<<6)) + x] = color; } /*- Main -----------------------*/ int main(void) { char color; int x, y; color = 8; x = 50; y = 50; /* initialize near pointers */ if ( !__djgpp_nearptr_enable() ) { fprintf( stderr, "Unable to initialize near pointers.\n" ); exit( 1 ); } video_buffer = (char *) (0xa0000 + __djgpp_conventional_base); set_mode(VGA_256_COLOR_MODE); /* set the video mode. */ Plot_Pixel_Fast(x,y,color); while(!kbhit()){} /* Waits for a key to be hit */ set_mode(TEXT_MODE); /* Cuts back to text mode */ __djgpp_nearptr_disable(); return 0; } -- --------------------------------------------------------------------- | John M. Aldrich | "Money is truthful. If a man speaks | | aka Fighteer I | of his honor, make him pay cash." | | mailto:fighteer AT cs DOT com | | | http://www.cs.com/fighteer | - Lazarus Long | ---------------------------------------------------------------------