Mail Archives: djgpp/1999/05/19/18:57:46
Ghalos wrote:
>
> Recently having jumped ship from Borland C++ I found that my project would
> not compile.... well I expected some problems. Anyway I will have to change
> my graphics functions because as I understand it I cant use the:
>
> unsigned char far *screen_ptr = 0xA0000000L;
>
> screen_ptr[x + (y << 6) + (y << 8)] = val;
>
> thing anymore.
> I trawled a bit to find out how it can be done under DJGPP and found
> LOTS of ways (including the THIS MAY DESTROY YOUR COMPUTER way) I just
> wondered... which way is the fastest and most reliable for use in Mode 13h?
Far pointers are quite safe and reasonably fast:
_farpokeb(_dos_ds, 0xa0000 + x + (y * 320), val);
If you have a buffered graphics algorithm (draw to a memory array and
blit to the screen), you can use dosmemput; that's about as fast as you
can get.
[Btw: Interestingly, GCC generates better code for `y * 320' than for
`(y << 6) + (y << 8)'. Try them and see. Hint: The `lea' instruction
can multiply by five!]
--
Nate Eldredge
nate AT cartsys DOT com
- Raw text -