Message-ID: <361938A4.F9B3E4CB@null.net> From: "L. R. Nix" X-Mailer: Mozilla 4.04 [en] (Win95; I) MIME-Version: 1.0 Newsgroups: comp.os.msdos.djgpp Subject: Re: Writing Drivers? References: <907589267 DOT 988799 AT mars DOT cs DOT unp DOT ac DOT za> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 55 Date: Mon, 05 Oct 1998 21:22:46 GMT NNTP-Posting-Host: 24.0.162.54 NNTP-Posting-Date: Mon, 05 Oct 1998 14:22:46 PDT Organization: @Home Network To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com try having your routines call a dummy function, then make your 'mode setting' routine set the dummy function to call the appropriate function as needed. void putpixel1(int x,int y,int c) { } // function 1 void putpixel2(int x,int y,int c) { } // function 2 void *putdummy; void setmode() { if (mode==BANKED) putdummy=(void *)putpixel1; else putdummy=(void *)putpixel2; } void something() { // set a pixel putdummy(x,y,c); } Does this make sense? call a pointer to the appropriate function. I'm a bit rusty in the exact wording, but that's kinda the best way to do it. The setmode routine determines which one to use, and sets up the pointer as appropriate. Hope this helps Lonnie Nix lornix AT null DOT net James Dominy wrote: > Right I've got two putpixel routines, one for VESA 1.2 banked mode, the > other for VESA 2.0 Linear Frame Buffer Mode. > > They are both implemented as macros now for speed purposes, although no > doubt inline would have much the same effect on performance. > > However, I do not want to continuously have if statements all over my code > checking which routine should be used. So, I set up an array as such > > void *putpixel[2](int x, int y, int c); > > and call putpixel[0](0,0,15) for example or use 1 instead of 0 for the > second routine. > > But can I inline them in any way? I realize that this would involve the > compiler knowing which routine would be used on each call, but I would know > that from after my mode setting routine! > > Any help appreciated! > > Thanx James.