From: csantill AT lausd DOT k12 DOT ca DOT us Message-ID: <33D2CFCB.4A39@lausd.k12.ca.us> Date: Sun, 20 Jul 1997 19:56:11 -0700 MIME-Version: 1.0 To: dj AT delorie DOT com, djgpp AT delorie DOT com Subject: Re: Is the FAQ wrong about FAR/NEAR ptr speed References: <199707210027 DOT UAA09914 AT delorie DOT com> Content-Type: multipart/mixed; boundary="------------1443276F5BF" Precedence: bulk This is a multi-part message in MIME format. --------------1443276F5BF Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit DJ Delorie wrote: > > Remember that VGA memory is so slow it often doesn't matter how fast > your code is. Try copying to/from DOS memory and see how fast it is. Do you mean(in pseudo code) for y for x put pix get pix Well, I now tested as put pix & then get pix in buff[200][320]. The put pix timings & get pix timings as seperate timings but I get the exact same fps rate(24.98 GFPS-get frames per sec). I think I'll try the pseudo code above next & see if there is a difference though I doubt there will be. I have a Q's though before I give you my new code, I've heard about descriptors & would to know a few things about it. Can I full source on how to do it correct(my hack off the FAQ didn't seem to work)? Is it "faster" & safer? Thanx for your input DJ. Here's my code. --------------1443276F5BF Content-Type: text/plain; charset=us-ascii; name="Vga_comp.c" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="Vga_comp.c" #include #include #include #include #include #include #include #include // The includes are from my original file - circle/box/line snipped out // I owe a big thanx to Sinan for my receipt of some actually working VGA // code. THAAAAAAAAAAAAAAAANNNNNNNNXXXXXXXXXXXXXXXXXXX!!!!!!!!!!!!! :] enum GR_MODE{GR_INVALID=-1, GR_TEXT=0x03, GR_VGA=0x13}; enum GR_MODE Set_GR_Mode(enum GR_MODE mode) { __dpmi_regs r; memset(&r, 0, sizeof(r)); r.x.ax=mode; return(__dpmi_int(0x10,&r) ? GR_INVALID:mode); } // ************************************************************************ void Put_Pix_Far(int x, int y, char c) { _farpokeb(_dos_ds, 0xA0000+(y<<8)+(y<<6)+x,c); return; } // ************************************************************************ char Get_Pix_Far(int x, int y) { return _farpeekb(_dos_ds, 0xA0000+(y<<8)+(y<<6)+x); } // ************************************************************************ void Put_Pix_Near(int x, int y, char c) { char *v_m=(char *)(0xA0000+__djgpp_conventional_base); v_m[(y<<8)+(y<<6)+x] = c; } // ************************************************************************ char Get_Pix_Near(int x, int y) { char *v_m=(char *)(0xA0000+__djgpp_conventional_base); return v_m[(y<<8)+(y<<6)+x]; } // ************************************************************************ int main(void) { int x, y, co; uclock_t st1, st2, et1, et2; char vid_mem_capture_buff[200][320]; if(GR_INVALID==Set_GR_Mode(GR_VGA)) { printf("Error setting mode 13h\n"); exit(8); } // Beginning of FAR PTR SPEED TEST st1=uclock(); for(co=0; co<7680; co++) for(y=0; y<200; y++) for(x=0; x<320; x++) Put_Pix_Far(x,y,co % 256); et1=uclock(); // Ending of FAR PTR SPEED TEST printf("Done w/FAR PTR set_pix test\nHit ENTER to start NEAR PTR" " set_pix TEST\n"); getchar(); // Beginning of NEAR PTR SPEED TEST if(__djgpp_nearptr_enable()) { st2=uclock(); for(co=0; co<7680; co++) for(y=0; y<200; y++) for(x=0; x<320; x++) Put_Pix_Near(x,y,co % 256); et2=uclock(); }; __djgpp_nearptr_disable(); // Ending of NEAR PTR SPEED TEST Set_GR_Mode(GR_TEXT); // Show the results printf("On my Pentium 120, 16MB RAM, Trident ET6???? w/1MB, while using" " RHIDE 1.3, GCC\n2.7 w/-O9 & -m386(-m486 I get the same results), I get" " 24.98 fps for both test.\nIs this unusual?\n\nYour results:\n"); // FAR PTR results printf("FPS for FAR PTR set_pix = %3.2f\n", (float)7680/((float)((et1-st1)/UCLOCKS_PER_SEC))); // NEAR PTR results printf("FPS for NEAR PTR set_pix= %3.2f\n", (float)7680/((float)((et2-st2)/UCLOCKS_PER_SEC))); printf("\n\nHit ENTER to start Get_Pix speed test\n"); getchar(); */ // GET PIX TESTS if(GR_INVALID==Set_GR_Mode(GR_VGA)) { printf("Error setting mode 13h\n"); exit(8); } // Beginning of FAR PTR SPEED TEST st1=uclock(); for(co=0; co<7680;co++) for(y=0; y<200; y++) for(x=0; x<320; x++) vid_mem_capture_buff[y][x]=Get_Pix_Far(x,y); et1=uclock(); // Ending of FAR PTR SPEED TEST printf("Done w/FAR PTR get_pix test\nHit ENTER to start NEAR PTR" " set_pix TEST\n"); getchar(); for(co=0;co<25;co++) printf("\n"); // Beginning of NEAR PTR SPEED TEST if(__djgpp_nearptr_enable()) { st2=uclock(); for(co=0; co<7680; co++) for(y=0; y<200; y++) for(x=0; x<320; x++) vid_mem_capture_buff[y][x]=Get_Pix_Near(x,y); et2=uclock(); }; __djgpp_nearptr_disable(); // Ending of NEAR PTR SPEED TEST Set_GR_Mode(GR_TEXT); // Show the results printf("On my Pentium 120, 16MB RAM, Trident ET6???? w/1MB, while using" " RHIDE 1.3, GCC\n2.7 w/-O9 & -m386(-m486 I get the same results), I get" " 90.35 fps for both test.\nIs this unusual?\n\nYour results:\n"); // FAR PTR results printf("FPS for FAR PTR get_pix = %3.2f\n", (float)7680/((float)((et1-st1)/UCLOCKS_PER_SEC))); // NEAR PTR results printf("FPS for NEAR PTR get_pix= %3.2f\n", (float)7680/((float)((et2-st2)/UCLOCKS_PER_SEC))); getchar(); return 0; } --------------1443276F5BF--