From: Jeff Weeks Newsgroups: comp.os.msdos.djgpp Subject: Re: wirting to a virtual screen - HELP! Date: Sat, 18 Oct 1997 14:57:45 -0400 Organization: Code X Software Lines: 58 Message-ID: <344906A8.AAA3ED1B@execulink.com> References: <3446a9d5 DOT 2362988 AT news DOT polaristel DOT net> NNTP-Posting-Host: ppp34.a6.execulink.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 waage wrote: > I am having problems copying info from a virtual screen allocated with > malloc and copying it to the VGA 0xa000. The code looks like this, > when compiled it says no errors but when I try to write to the virtual > screen with my put_pixel it crashes. [ snipped code, etc ] Whoa there fella :) You're making it too difficult for yourself. Here, try this: char *get_screen(int x, int y) { return (char *)malloc(x*y); } void putpixel(char *screen, int x, int y, char c) { screen[y*max_x+x] = c; } void show_screen(char *screen) { dosmemput(screen, max_x*max_y, 0xA0000); // or perhaps... dosmemput(screen, sizeof(*screen), 0xA0000); } int main(void) { char *screen; // set video mode here screen = get_screen(max_x, max_y); putpixel(screen, 0, 0, 15); show_screen(screen); // goto text mode here } There... that should get you up and running, I hope. That's all off the top of my head though, so they're may be a few tiny errors... but I don't think so. I've checked through it. Also, unless you specifically _have_ to, just copy the virtual screen, don't swap it with video memory... reading from video memory is very slow. Plus, dosmemput isn't exactly the fastest method to copy the virtual screen either. For more information about graphics programming, check out my DJGPP graphics programming tutorial on my hompage (location is in my sig.). It's due for an update, but still has a lot of good stuff in it. Jeff -------------------------------------------- - Code X Software - Programming to a Higher Power email: mailto:pweeks AT execulink DOT com web: http://www.execulink.com/~pweeks/ --------------------------------------------