Mail Archives: djgpp/1996/08/08/20:45:26
In article <320647A3 DOT 5827 AT cadvision DOT com>,
John Meilleur <meilleuj AT cadvision DOT com> wrote:
>Can anyone help me speed up this bit of code. I'm writing some hi-res graphics routines and would like to know
>how i can speed up clearing the screen buffer and the buffer transfer. I know I should be able to do 32-bit
>transfering but I've had no luck with it sofar. The "video_ds" is the selector to video memory and starts at
>offset 0. Can any show me how to speed this up alot? TIA
>
>char *screen = malloc(640*480);
>while (!kbhit())
>{
> for (i=0;i<640*480;i++)
> screen[i]=0;
asm volatile (
"rep\n\t"
"stosl"
:
: "a" (0), "c" (640*480/4), "D" (screen)
: "%edi", "%ecx" );
> drawstuff(screen);
>
> _farsetsel(video_ds);
> for (i=0;i<640*480;i++)
> _farnspokeb(i,screen[i]);
asm volatile (
"movw %%es, %%dx\n\t"
"movw %%bx, %%es\n\t"
"rep\n\t"
"movsl\n\t"
"movw %%dx, %%es\n\t" /* put things back where you found 'em */
:
: "b" (video_ds), "c" (640*480/4), "S" (screen), "D" (0)
: "%ebx", "%ecx", "%edx", "%esi", "%edi" );
>
>}
I realize there are other tiny little optimizations, but they don't
amount to more than a cycle or 3 per page.
If at all possible, arrange to not have to clear the parts of the
screen that are overwritten anyway. 640*480 makes for a lot of bytes.
Don't write to them twice if you can.
For clarity's sake, I'd just use memset instead of the first asm,
and fmemcpy on the second. Well , *I* wouldn't, but I recommend it
anyway.
--Brennan
--
brennan AT rt66 DOT com | fsck /u
Unsolicited junk email may be returned to sender 1000 times or more.
- Raw text -