From: Shawn Hargreaves Newsgroups: comp.os.msdos.djgpp Subject: Re: X-mode Date: Fri, 24 Jan 1997 20:27:03 +0000 Organization: None Lines: 47 Distribution: world Message-ID: <6$y9IrAXsR6yEw19@talula.demon.co.uk> References: <01bc07f9$fa24d420$a3f80f82 AT default> NNTP-Posting-Host: talula.demon.co.uk MIME-Version: 1.0 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Don writes: >I'm writing my first game in Djgpp and I'm trying to use Mode-X because >of the many advantages. The only thing I don't like is the non-linear >addressing. Whenever you plot a pixel you have to select the bit-plane >right?! Okay I wrote a function to do that, but obviously it is >somewhat slower than say a 13h function. My biggest problem is >blitting. How can I blit in mode X without plotting one pixel at a >time (as apposed to a say memcpy command to blit whole lines). Copy the image plane-by-plane, rather than pixel-by-pixel. Select plane 0, and then copy every fourth pixel from your source image to adjacent bytes in video memory. Ditto for planes 1-3. You should be able to draw pretty much anything with only four writes to the plane select register, if you order the operations correctly. >Basically I want a fast and easy way to copy a buffer containing an >image to the video buffer in mode-X. If your engine is based around blitting a buffer from system ram to video memory, it would be much faster in mode 13h. Quite apart from having to alter the plane registers, the planar video organisation wreaks havoc with your bus transfer rate (you can't read/write adjacent strips of four pixels with 32 bit instructions if they are scattered all over the place), and most modern cards can accept data a lot faster in linear modes (on my Matrox, blitting to a VBE 2.0 linear framebuffer 320x200 mode is nearly 20% faster than the same resolution in mode 13h, and over twice as fast as in mode-X). IMHO, mode-X only shines when you are doing all your rendering directly into video memory, and you are able to make use of the write planes to copy groups of four pixels simultaneously (ie. you are doing lots of solid-color fills, or you can fit all your sprites in an offscreen area of video RAM and copy them from there). It was essential on a 386 and well worth using on a 486, but on a pentium you'll almost certainly get better results from mode 13h, or best of all a VBE2.0 linear framebuffer mode... Of course that's just my opinion. If you want some others, pop over to rec.games.programmer, where several hundred people will be delighted to discuss the issue at great length (before getting sidetracked onto the respective merits of MS-DOS and Win95, and whether PC's or console systems make better gaming platforms :-) /* * Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/ * Ghoti: 'gh' as in 'enough', 'o' as in 'women', and 'ti' as in 'nation'. */