Factor out multiply repeated code into calc_ylookup().

git-svn-id: https://svn.eduke32.com/eduke32@3291 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2012-12-14 19:28:17 +00:00
parent 1c06bcf14e
commit c93096e938
5 changed files with 30 additions and 23 deletions

View file

@ -40,6 +40,8 @@ extern char offscreenrendering;
extern void (*baselayer_onvideomodechange)(int32_t);
void calc_ylookup(int32_t bpl, int32_t lastyidx);
#ifdef USE_OPENGL
void fullscreen_tint_gl(uint8_t r, uint8_t g, uint8_t b, uint8_t f);
extern int32_t osdcmd_glinfo(const osdfuncparm_t *parm);

View file

@ -5,6 +5,7 @@
#include "renderlayer.h"
#include "a.h"
#include "polymost.h"
// input
@ -126,6 +127,22 @@ void readjoybstatus(int32_t *b)
*b = joyb;
}
// Calculate ylookup[] and call setvlinebpl()
void calc_ylookup(int32_t bpl, int32_t lastyidx)
{
int32_t i, j=0;
Bassert(lastyidx <= MAXYDIM);
for (i=0; i<=lastyidx; i++)
{
ylookup[i] = j;
j += bpl;
}
setvlinebpl(bpl);
}
#ifdef USE_OPENGL
void fullscreen_tint_gl(uint8_t r, uint8_t g, uint8_t b, uint8_t f)
{

View file

@ -10312,7 +10312,7 @@ int32_t saveboard(const char *filename, const vec3_t *dapos, int16_t daang, int1
extern char videomodereset;
int32_t setgamemode(char davidoption, int32_t daxdim, int32_t daydim, int32_t dabpp)
{
int32_t i, j;
int32_t j;
#ifdef USE_OPENGL
extern char nogl;
@ -10370,9 +10370,7 @@ int32_t setgamemode(char davidoption, int32_t daxdim, int32_t daydim, int32_t da
//Force drawrooms to call dosetaspect & recalculate stuff
oxyaspect = oxdimen = oviewingrange = -1;
setvlinebpl(bytesperline);
j = 0;
for (i=0; i<=ydim; i++) ylookup[i] = j, j += bytesperline;
calc_ylookup(bytesperline, ydim);
setview(0L,0L,xdim-1,ydim-1);
clearallviews(0L);
@ -14066,8 +14064,6 @@ char getpixel(int32_t x, int32_t y)
//
void setviewtotile(int16_t tilenume, int32_t xsiz, int32_t ysiz)
{
int32_t i, j;
//DRAWROOMS TO TILE BACKUP&SET CODE
tilesizx[tilenume] = xsiz; tilesizy[tilenume] = ysiz;
bakxsiz[setviewcnt] = xsiz; bakysiz[setviewcnt] = ysiz;
@ -14089,8 +14085,8 @@ void setviewtotile(int16_t tilenume, int32_t xsiz, int32_t ysiz)
offscreenrendering = 1;
setview(0,0,ysiz-1,xsiz-1);
setaspect(65536,65536);
j = 0; for (i=0; i<=xsiz; i++) { ylookup[i] = j, j += ysiz; }
setvlinebpl(ysiz);
calc_ylookup(ysiz, xsiz);
}
@ -14100,7 +14096,7 @@ void setviewtotile(int16_t tilenume, int32_t xsiz, int32_t ysiz)
extern char modechange;
void setviewback(void)
{
int32_t i, j, k;
int32_t k;
if (setviewcnt <= 0) return;
setviewcnt--;
@ -14119,12 +14115,13 @@ void setviewback(void)
copybufbyte(&bakumost[windowx1],&startumost[windowx1],(windowx2-windowx1+1)*sizeof(startumost[0]));
copybufbyte(&bakdmost[windowx1],&startdmost[windowx1],(windowx2-windowx1+1)*sizeof(startdmost[0]));
frameplace = bakframeplace[setviewcnt];
if (setviewcnt == 0)
k = bakxsiz[0];
else
k = max(bakxsiz[setviewcnt-1],bakxsiz[setviewcnt]);
j = 0; for (i=0; i<=k; i++) ylookup[i] = j, j += bytesperline;
setvlinebpl(bytesperline);
calc_ylookup(bytesperline, k);
modechange=1;
}

View file

@ -1662,8 +1662,6 @@ void resetvideomode(void)
//
void begindrawing(void)
{
int32_t i,j;
if (bpp > 8)
{
if (offscreenrendering) return;
@ -1685,10 +1683,9 @@ void begindrawing(void)
if (sdl_surface->pitch != bytesperline || modechange)
{
bytesperline = sdl_surface->pitch;
setvlinebpl(bytesperline);
j = 0;
for (i=0; i<=ydim; i++) ylookup[i] = j, j += bytesperline;
calc_ylookup(bytesperline, ydim);
modechange=0;
}
}

View file

@ -1908,13 +1908,7 @@ void begindrawing(void)
bytesperline = xres|1;
}
setvlinebpl(bytesperline);
{
int32_t i = 0, j = 0;
for (; i<=ydim; i++)
ylookup[i] = j, j += bytesperline;
}
calc_ylookup(bytesperline, ydim);
}