Mail Archives: djgpp/1997/07/18/02:35:53
This is a multi-part message in MIME format.
--------------65A45FC06110
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
from: csantill AT lausd DOT k12 DOT ca DOT us
Now that I got some working mode 13h code to hack
(thanx alot to Sinan!), I decided to test how fast
it was. I've been using uclock & clock to do my
timing procedures but I always seem to get a
SIGFPE error(division by zero) at line 54:
fps=7680/((t[2]-t[1])/UCLOCKS_PER_SEC)
or
fps=7680/((t[2]-t[1])/CLOCKS_PER_SEC)
This is odd because it does not occur when I compile
w/O0 or O1.
Here's my code if anybody is interested.
--------------65A45FC06110
Content-Type: text/plain; charset=us-ascii; name="Vga_pix.c"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="Vga_pix.c"
#include <sys/farptr.h>
#include <dpmi.h>
#include <go32.h>
#include <time.h>
#include <string.h>
#include <stdio.h>
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, int c)
{
_farpokeb(_dos_ds, 0xA0000+y*320+x,c);
return;
}
int main(void)
{
int x, y, co;
char c,c1;
int fps;
// uclock_t t[2];
clock_t t[2];
if(GR_INVALID==Set_GR_Mode(GR_VGA))
{
printf("Error setting mode 13h\n");
exit(8);
}
clock();
t[1]=clock();
// t[1]=uclock();
for(c=0; c<30; c++)
for(co=0; co<256; co++)
for(y=0; y<200; y++)
for(x=0; x<320; x++)
put_pix_far(x,y,co);
t[2]=clock();
// t[2]=uclock();
Set_GR_Mode(GR_TEXT);
fps=7680/((t[2]-t[1])/CLOCKS_PER_SEC);
// fps=7680/((t[2]-t[1])/UCLOCKS_PER_SEC);
printf("fps = %d\n",fps);
getchar();
return 0;
}
--------------65A45FC06110--
- Raw text -