static void displayticrate(fixed_t value) { int j,l,i; static tic_t lasttic; tic_t tics,t; t = I_GetTime(); tics = (t - lasttic)/NEWTICRATERATIO; lasttic = t; if (tics > OLDTICRATE) tics = OLDTICRATE; for (i=0; i<OLDTICRATE-1; i++) fpsgraph[i]=fpsgraph[i+1]; fpsgraph[OLDTICRATE-1]=OLDTICRATE-tics; if (value == 1 || value == 3) { char s[11]; sprintf(s, "FPS: %d/%u", OLDTICRATE-tics+1, OLDTICRATE); V_DrawString(BASEVIDWIDTH - V_StringWidth(s), BASEVIDHEIGHT-ST_HEIGHT+24, V_YELLOWMAP, s); } if (value == 1) return; if (rendermode == render_soft) { int k; // draw dots for (j=0; j<=OLDTICRATE*SCALE*vid.dupy; j+=2*SCALE*vid.dupy) { l=(vid.height-1-j)*vid.width*vid.bpp; for (i=0; i<OLDTICRATE*SCALE*vid.dupx; i+=2*SCALE*vid.dupx) screens[0][l+i]=0xff; } // draw the graph for (i=0; i<OLDTICRATE; i++) for (k=0; k<SCALE*vid.dupx; k++) PUTDOT(i*SCALE*vid.dupx+k, vid.height-1-(fpsgraph[i]*SCALE*vid.dupy),0xff); } #ifdef HWRENDER else { fline_t p; for (j=0; j<=OLDTICRATE*SCALE*vid.dupy; j+=2*SCALE*vid.dupy) { l=(vid.height-1-j); for (i=0; i<OLDTICRATE*SCALE*vid.dupx; i+=2*SCALE*vid.dupx) { p.a.x = i; p.a.y = l; p.b.x = i+1; p.b.y = l; HWR_drawAMline(&p, 0xff); } } for (i=1; i<OLDTICRATE; i++) { p.a.x = SCALE * (i-1); p.a.y = vid.height-1-fpsgraph[i-1]*SCALE*vid.dupy; p.b.x = SCALE * i; p.b.y = vid.height-1-fpsgraph[i]*SCALE*vid.dupy; HWR_drawAMline(&p, 0xff); } } #endif }
// // AM_drawFline() // // Draw a line in the frame buffer. // Classic Bresenham w/ whatever optimizations needed for speed // // Passed the frame coordinates of line, and the color to be drawn // Returns nothing // void AM_drawFline ( fline_t* fl, int color ) { register int x; register int y; register int dx; register int dy; register int sx; register int sy; register int ax; register int ay; register int d; #ifdef RANGECHECK // killough 2/22/98 static int f**k = 0; // For debugging only if ( fl->a.x < 0 || fl->a.x >= f_w || fl->a.y < 0 || fl->a.y >= f_h || fl->b.x < 0 || fl->b.x >= f_w || fl->b.y < 0 || fl->b.y >= f_h ) { fprintf(stderr, "f**k %d \r", f**k++); return; } #endif #define PUTDOT(xx,yy,cc) fb[(yy)*f_w+(xx)]=(cc) dx = fl->b.x - fl->a.x; ax = 2 * (dx<0 ? -dx : dx); sx = dx<0 ? -1 : 1; dy = fl->b.y - fl->a.y; ay = 2 * (dy<0 ? -dy : dy); sy = dy<0 ? -1 : 1; x = fl->a.x; y = fl->a.y; if (ax > ay) { d = ay - ax/2; while (1) { PUTDOT(x,y,color); if (x == fl->b.x) return; if (d>=0) { y += sy; d -= ax; } x += sx; d += ay; } } else { d = ax - ay/2; while (1) { PUTDOT(x, y, color); if (y == fl->b.y) return; if (d >= 0) { x += sx; d -= ay; } y += sy; d += ax; } } }