Fix building with USE_OPENGL=0 and POLYMOST=0 and replace all instances in the game code in which the bpp or rendmode vars are checked directly with calls to getrendermode()

git-svn-id: https://svn.eduke32.com/eduke32@895 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2008-07-24 11:16:20 +00:00
parent fca9027ab7
commit 30c9c774eb
8 changed files with 75 additions and 70 deletions

View file

@ -6,6 +6,7 @@
#define __baselayer_h__
#include "compat.h"
#include "osd.h"
#ifdef __cplusplus
extern "C" {
@ -33,7 +34,6 @@ extern char offscreenrendering;
extern void (*baselayer_onvideomodechange)(int);
#ifdef USE_OPENGL
#include "osd.h"
extern int osdcmd_glinfo(const osdfuncparm_t *parm);
struct glinfo {

View file

@ -507,7 +507,9 @@ void drawcircle16(int x1, int y1, int r, char col);
int setrendermode(int renderer);
int getrendermode(void);
#ifdef POLYMOST
void setrollangle(int rolla);
#endif
// pal: pass -1 to invalidate all palettes for the tile, or >=0 for a particular palette
// how: pass -1 to invalidate all instances of the tile in texture memory, or a bitfield

View file

@ -654,7 +654,10 @@ static int defsparser(scriptfile *script)
break;
case T_DEFINEMODELFRAME:
{
char *framename, happy=1;
char *framename;
#if defined(POLYMOST) && defined(USE_OPENGL)
char happy=1;
#endif
int ftilenume, ltilenume, tilex;
if (scriptfile_getstring(script,&framename)) break;
@ -1535,7 +1538,10 @@ static int defsparser(scriptfile *script)
case T_UNDEFMODELOF:
{
int mid,r0;
int r0;
#if defined(POLYMOST) && defined(USE_OPENGL)
int mid;
#endif
if (scriptfile_getsymbol(script,&r0)) break;
if ((unsigned)r0 >= (unsigned)MAXTILES)

View file

@ -712,11 +712,16 @@ static void scansector(short sectnum);
#include "hightile.c"
#include "polymost.c"
#else
void hicsetpalettetint(int palnum, unsigned char r, unsigned char g, unsigned char b, unsigned char effect) { }
int hicsetsubsttex(int picnum, int palnum, char *filen, float alphacut, float xscale, float yscale, char flags) { return 0; }
int hicsetskybox(int picnum, int palnum, char *faces[6]) { return 0; }
int hicclearsubst(int picnum, int palnum) { return 0; }
int polymost_drawtilescreen(int tilex, int tiley, int wallnum, int dimen, int tilezoom) { return -1; }
void hicsetpalettetint(int palnum, unsigned char r, unsigned char g, unsigned char b, unsigned char effect)
{ UNREFERENCED_PARAMETER(palnum); UNREFERENCED_PARAMETER(r); UNREFERENCED_PARAMETER(g); UNREFERENCED_PARAMETER(b); UNREFERENCED_PARAMETER(effect);}
int hicsetsubsttex(int picnum, int palnum, char *filen, float alphacut, float xscale, float yscale, char flags)
{ UNREFERENCED_PARAMETER(picnum); UNREFERENCED_PARAMETER(palnum); UNREFERENCED_PARAMETER(filen); UNREFERENCED_PARAMETER(alphacut); UNREFERENCED_PARAMETER(xscale); UNREFERENCED_PARAMETER(yscale); UNREFERENCED_PARAMETER(flags); return 0;}
int hicsetskybox(int picnum, int palnum, char *faces[6])
{ UNREFERENCED_PARAMETER(picnum); UNREFERENCED_PARAMETER(palnum); UNREFERENCED_PARAMETER(faces); return 0;}
int hicclearsubst(int picnum, int palnum)
{ UNREFERENCED_PARAMETER(picnum); UNREFERENCED_PARAMETER(palnum);return 0;}
int polymost_drawtilescreen(int tilex, int tiley, int wallnum, int dimen, int tilezoom)
{ UNREFERENCED_PARAMETER(tilex); UNREFERENCED_PARAMETER(tiley); UNREFERENCED_PARAMETER(wallnum); UNREFERENCED_PARAMETER(dimen); UNREFERENCED_PARAMETER(tilezoom);return -1;}
#endif
//============================================================================= //POLYMOST ENDS
@ -4633,6 +4638,7 @@ static void dorotatesprite(int sx, int sy, int z, short a, short picnum, signed
int xv, yv, xv2, yv2, qlinemode=0, y1ve[4], y2ve[4], u4, d4;
char bad;
UNREFERENCED_PARAMETER(uniqid);
//============================================================================= //POLYMOST BEGINS
#ifdef POLYMOST
if (rendmode >= 3) { polymost_dorotatesprite(sx,sy,z,a,picnum,dashade,dapalnum,dastat,cx1,cy1,cx2,cy2,uniqid); return; }
@ -7579,7 +7585,7 @@ int loadmaphack(char *filename)
return 0;
}
#else
int loadmaphack(char *filename) { return -1; }
int loadmaphack(char *filename) { UNREFERENCED_PARAMETER(filename); return -1; }
#endif
@ -9985,13 +9991,11 @@ void setvgapalette(void)
//
// setbrightness
//
static unsigned int lastpalettesum = 0;
void setbrightness(char dabrightness, char *dapal, char noapply)
{
int i, k, j;
unsigned int newpalettesum, lastbright;
unsigned int lastbright = curbrightness;
lastbright = curbrightness;
if (!(noapply&4))
{
curbrightness = min(max((int)dabrightness,0),15);
@ -10021,7 +10025,8 @@ void setbrightness(char dabrightness, char *dapal, char noapply)
#if defined(POLYMOST) && defined(USE_OPENGL)
if (rendmode >= 3)
{
newpalettesum = crc32once((unsigned char *)curpalettefaded, sizeof(curpalettefaded));
static unsigned int lastpalettesum = 0;
unsigned int newpalettesum = crc32once((unsigned char *)curpalettefaded, sizeof(curpalettefaded));
// only reset the textures if the preserve flag (bit 1 of noapply) is clear and
// either (a) the new palette is different to the last, or (b) the brightness
@ -11704,7 +11709,7 @@ int screencapture_tga(char *filename, char inverseit)
int i,j;
char *ptr, head[18] = { 0,1,1,0,0,0,1,24,0,0,0,0,0/*wlo*/,0/*whi*/,0/*hlo*/,0/*hhi*/,8,0 };
//char palette[4*256];
char *fn = Bstrdup(filename), *inversebuf, c;
char *fn = Bstrdup(filename), *inversebuf;
BFILE *fil;
do // JBF 2004022: So we don't overwrite existing screenshots
@ -11793,6 +11798,7 @@ int screencapture_tga(char *filename, char inverseit)
#if defined(POLYMOST) && defined(USE_OPENGL)
if (rendmode >= 3 && qsetmode == 200)
{
char c;
// 24bit
inversebuf = (char *)kmalloc(xdim*ydim*3);
if (inversebuf)
@ -12029,6 +12035,7 @@ int screencapture(char *filename, char inverseit)
//
int setrendermode(int renderer)
{
UNREFERENCED_PARAMETER(renderer);
#ifdef POLYMOST
if (bpp == 8)
{
@ -12071,13 +12078,14 @@ int getrendermode(void)
//
// setrollangle
//
#ifdef POLYMOST
void setrollangle(int rolla)
{
#ifdef POLYMOST
UNREFERENCED_PARAMETER(rolla);
if (rolla == 0) gtang = 0.0;
else gtang = PI * (double)rolla / 1024.0;
#endif
}
#endif
//
@ -12123,6 +12131,9 @@ void invalidatetile(short tilenume, int pal, int how)
}
}
#endif
UNREFERENCED_PARAMETER(tilenume);
UNREFERENCED_PARAMETER(pal);
UNREFERENCED_PARAMETER(how);
}

View file

@ -2345,7 +2345,7 @@ static void tics(void)
if (i != frameval[framecnt])
{
j=(timer*AVERAGEFRAMES)/(i-frameval[framecnt]);
if (ud.tickrate && !(g_player[myconnectindex].ps->gm&MODE_MENU))
if (ud.tickrate /*&& !(g_player[myconnectindex].ps->gm&MODE_MENU)*/)
{
int ii, k = 0, p = 8;
@ -3627,7 +3627,7 @@ void drawbackground(void)
else
{
// when not rendering a game, fullscreen wipe
#define MENUTILE bpp==8?MENUSCREEN:LOADSCREEN
#define MENUTILE (!getrendermode()?MENUSCREEN:LOADSCREEN)
SetGameVarID(g_iReturnVarID,tilesizx[MENUTILE]==320&&tilesizy[MENUTILE]==200?MENUTILE:BIGHOLE, -1, -1);
OnEvent(EVENT_GETMENUTILE, -1, myconnectindex, -1);
if (GetGameVar("MENU_TILE", tilesizx[MENUTILE]==320&&tilesizy[MENUTILE]==200?0:1, -1, -1))
@ -3911,11 +3911,7 @@ void displayrooms(int snum,int smoothratio)
pub = 0;
}
#ifdef POLYMOST
if (ud.overhead_on == 2 || ud.show_help || (p->cursectnum == -1 && rendmode < 3))
#else
if (ud.overhead_on == 2 || ud.show_help || p->cursectnum == -1)
#endif
if (ud.overhead_on == 2 || ud.show_help || (p->cursectnum == -1 && getrendermode() < 3))
return;
smoothratio = min(max(smoothratio,0),65536);
@ -3926,10 +3922,7 @@ void displayrooms(int snum,int smoothratio)
ud.camerasect = p->cursectnum;
#ifdef POLYMOST
if (rendmode < 3)
#endif
if (ud.camerasect < 0 || ud.camerasect >= MAXSECTORS) return;
if (getrendermode() < 3 && (ud.camerasect < 0 || ud.camerasect >= MAXSECTORS)) return;
dointerpolations(smoothratio);
@ -3947,7 +3940,7 @@ void displayrooms(int snum,int smoothratio)
se40code(s->x,s->y,s->z,ud.cameraang,s->yvel,smoothratio);
#endif
#ifdef POLYMER
if (rendmode == 4)
if (getrendermode() == 4)
polymer_setanimatesprites(animatesprites, s->x, s->y, ud.cameraang, smoothratio);
#endif
drawrooms(s->x,s->y,s->z-(4<<8),ud.cameraang,s->yvel,s->sectnum);
@ -4016,7 +4009,9 @@ void displayrooms(int snum,int smoothratio)
}
else if (getrendermode() > 0 && ud.screen_tilting /*&& (p->rotscrnang || p->orotscrnang)*/)
{
#ifdef POLYMOST
setrollangle(p->orotscrnang + mulscale16(((p->rotscrnang - p->orotscrnang + 1024)&2047)-1024,smoothratio));
#endif
p->orotscrnang = p->rotscrnang; // JBF: save it for next time
}
@ -4093,7 +4088,7 @@ void displayrooms(int snum,int smoothratio)
#endif
if (((gotpic[MIRROR>>3]&(1<<(MIRROR&7))) > 0)
#if defined(POLYMOST) && defined(USE_OPENGL)
&& (rendmode != 4)
&& (getrendermode() != 4)
#endif
)
{
@ -4127,7 +4122,7 @@ void displayrooms(int snum,int smoothratio)
}
#ifdef POLYMER
if (rendmode == 4)
if (getrendermode() == 4)
polymer_setanimatesprites(animatesprites, ud.camerax,ud.cameray,ud.cameraang,smoothratio);
#endif
drawrooms(ud.camerax,ud.cameray,ud.cameraz,ud.cameraang,ud.camerahoriz,ud.camerasect);
@ -6305,7 +6300,7 @@ void animatesprites(int x,int y,int a,int smoothratio)
continue;
case CHAIR3__STATIC:
#if defined(POLYMOST) && defined(USE_OPENGL)
if (bpp > 8 && usemodels && md_tilehasmodel(t->picnum,t->pal) >= 0 && !(spriteext[i].flags&SPREXT_NOTMD))
if (getrendermode() >= 3 && usemodels && md_tilehasmodel(t->picnum,t->pal) >= 0 && !(spriteext[i].flags&SPREXT_NOTMD))
{
t->cstat &= ~4;
break;
@ -6588,7 +6583,7 @@ void animatesprites(int x,int y,int a,int smoothratio)
case RPG__STATIC:
#if defined(POLYMOST) && defined(USE_OPENGL)
if (bpp > 8 && usemodels && md_tilehasmodel(t->picnum,t->pal) >= 0 && !(spriteext[i].flags&SPREXT_NOTMD))
if (getrendermode() >= 3 && usemodels && md_tilehasmodel(t->picnum,t->pal) >= 0 && !(spriteext[i].flags&SPREXT_NOTMD))
{
int v=getangle(t->xvel,t->zvel>>4);
if (v>1023)v-=2048;
@ -6612,7 +6607,7 @@ void animatesprites(int x,int y,int a,int smoothratio)
case RECON__STATIC:
#if defined(POLYMOST) && defined(USE_OPENGL)
if (bpp > 8 && usemodels && md_tilehasmodel(t->picnum,t->pal) >= 0 && !(spriteext[i].flags&SPREXT_NOTMD))
if (getrendermode() >= 3 && usemodels && md_tilehasmodel(t->picnum,t->pal) >= 0 && !(spriteext[i].flags&SPREXT_NOTMD))
{
t->cstat &= ~4;
break;
@ -6715,7 +6710,7 @@ void animatesprites(int x,int y,int a,int smoothratio)
{
#if defined(POLYMOST) && defined(USE_OPENGL)
if (bpp > 8 && usemodels && md_tilehasmodel(s->picnum,t->pal) >= 0 && !(spriteext[i].flags&SPREXT_NOTMD))
if (getrendermode() >= 3 && usemodels && md_tilehasmodel(s->picnum,t->pal) >= 0 && !(spriteext[i].flags&SPREXT_NOTMD))
{
k = 0;
t->cstat &= ~4;
@ -6839,7 +6834,7 @@ PALONLY:
l = *(((intptr_t *)t4)+2); //For TerminX: was *(int *)(t4+8)
#if defined(POLYMOST) && defined(USE_OPENGL)
if (bpp > 8 && usemodels && md_tilehasmodel(s->picnum,t->pal) >= 0 && !(spriteext[i].flags&SPREXT_NOTMD))
if (getrendermode() >= 3 && usemodels && md_tilehasmodel(s->picnum,t->pal) >= 0 && !(spriteext[i].flags&SPREXT_NOTMD))
{
k = 0;
t->cstat &= ~4;
@ -6950,14 +6945,14 @@ PALONLY:
tsprite[spritesortcnt].yrepeat = yrep;
#if defined(POLYMOST) && defined(USE_OPENGL)
if (bpp > 8 && usemodels && md_tilehasmodel(t->picnum,t->pal) >= 0)
if (getrendermode() >= 3 && usemodels && md_tilehasmodel(t->picnum,t->pal) >= 0)
{
tsprite[spritesortcnt].yrepeat = 0;
// 512:trans reverse
//1024:tell MD2SPRITE.C to use Z-buffer hacks to hide overdraw issues
tsprite[spritesortcnt].cstat |= (512+1024);
}
else if (bpp > 8)
else if (getrendermode() >= 3)
{
int ii;
@ -7013,7 +7008,7 @@ PALONLY:
break;
case PLAYERONWATER__STATIC:
#if defined(POLYMOST) && defined(USE_OPENGL)
if (bpp > 8 && usemodels && md_tilehasmodel(s->picnum,s->pal) >= 0 && !(spriteext[i].flags&SPREXT_NOTMD))
if (getrendermode() >= 3 && usemodels && md_tilehasmodel(s->picnum,s->pal) >= 0 && !(spriteext[i].flags&SPREXT_NOTMD))
{
k = 0;
t->cstat &= ~4;
@ -7077,7 +7072,7 @@ PALONLY:
case RAT__STATIC:
#if defined(POLYMOST) && defined(USE_OPENGL)
if (bpp > 8 && usemodels && md_tilehasmodel(s->picnum,s->pal) >= 0 && !(spriteext[i].flags&SPREXT_NOTMD))
if (getrendermode() >= 3 && usemodels && md_tilehasmodel(s->picnum,s->pal) >= 0 && !(spriteext[i].flags&SPREXT_NOTMD))
{
t->cstat &= ~4;
break;
@ -7760,7 +7755,7 @@ static void nonsharedkeys(void)
{
if (ud.screen_size > 0)
sound(THUD);
if (ud.screen_size == 8 && ud.statusbarmode == 0 && bpp > 8)
if (getrendermode() >= 3 && ud.screen_size == 8 && ud.statusbarmode == 0)
ud.statusbarmode = 1;
else ud.screen_size -= 4;
@ -7784,7 +7779,7 @@ static void nonsharedkeys(void)
if (!SHIFTS_IS_PRESSED)
{
if (ud.screen_size < 64) sound(THUD);
if (ud.screen_size == 8 && ud.statusbarmode == 1 && bpp > 8)
if (getrendermode() >= 3 && ud.screen_size == 8 && ud.statusbarmode == 1)
ud.statusbarmode = 0;
else ud.screen_size += 4;
}
@ -10326,18 +10321,6 @@ void app_main(int argc,const char **argv)
exit(1);
}
OSD_SetFunctions(
GAME_drawosdchar,
GAME_drawosdstr,
GAME_drawosdcursor,
GAME_getcolumnwidth,
GAME_getrowheight,
GAME_clearbackground,
(int(*)(void))GetTime,
GAME_onshowosd
);
OSD_SetParameters(10,0, 0,12, 4,12);
initprintf("Using config file '%s'.\n",setupfilename);
ScanGroups();
@ -10366,6 +10349,7 @@ void app_main(int argc,const char **argv)
g_GameType = first->game;
duke3dgrpstring = (char *)grpfiles[0].name;
}
else if (!fg) duke3dgrpstring = "Unknown GRP";
}
#if (defined RENDERTYPEWIN || (defined RENDERTYPESDL && !defined __APPLE__ && defined HAVE_GTK2))
@ -10753,7 +10737,7 @@ MAIN_LOOP_RESTART:
else
i = 65536;
if (ud.statusbarmode == 1 && (ud.statusbarscale == 100 || bpp == 8))
if (ud.statusbarmode == 1 && (ud.statusbarscale == 100 || !getrendermode()))
{
ud.statusbarmode = 0;
vscrn();

View file

@ -5793,7 +5793,7 @@ static int parse(void)
#endif
if (((gotpic[MIRROR>>3]&(1<<(MIRROR&7))) > 0)
#if defined(POLYMOST) && defined(USE_OPENGL)
&& (rendmode != 4)
&& (getrendermode() != 4)
#endif
)
{
@ -5830,7 +5830,7 @@ static int parse(void)
}
#ifdef POLYMER
if (rendmode == 4)
if (getrendermode() == 4)
polymer_setanimatesprites(animatesprites, x,y,a,smoothratio);
#endif
drawrooms(x,y,z,a,horiz,sect);

View file

@ -614,12 +614,12 @@ void menus(void)
sh = 4-(sintable[(totalclock<<4)&2047]>>11);
if (bpp > 8)
if (getrendermode() >= 3)
{
int x,y=0;
for (;y<ydim;y+=tilesizy[BIGHOLE])
for (x=0;x<xdim;x+=tilesizx[BIGHOLE])
rotatesprite(x<<16,y<<16,65536L,0,BIGHOLE,80,0,1+8+16,0,0,xdim-1,ydim-1);
for (;y<ydim;y+=tilesizy[MENUSCREEN])
for (x=0;x<xdim;x+=tilesizx[MENUSCREEN])
rotatesprite(x<<16,y<<16,65536L,0,MENUSCREEN,80,0,1+8+16,0,0,xdim-1,ydim-1);
}
if (!(current_menu >= 1000 && current_menu <= 2999 && current_menu >= 300 && current_menu <= 369))
@ -2730,13 +2730,13 @@ cheat_for_port_credits:
int i;
i = ud.screen_size;
barsm(d+8,yy+7, &ud.screen_size,-4,x==io,MENUHIGHLIGHT(io),PHX(-5));
if (i < ud.screen_size && i == 8 && ud.statusbarmode == 1 && bpp > 8)
if (getrendermode() >= 3 && i < ud.screen_size && i == 8 && ud.statusbarmode == 1)
{
ud.statusbarmode = 0;
if (ud.statusbarscale != 100)
ud.screen_size = i;
}
else if (i > ud.screen_size && i == 8 && ud.statusbarmode == 0 && bpp > 8)
else if (getrendermode() >= 3 && i > ud.screen_size && i == 8 && ud.statusbarmode == 0)
{
if (ud.statusbarscale != 100)
{
@ -2775,7 +2775,9 @@ cheat_for_port_credits:
break;
case 7:
if (x==io) ud.screen_tilting = 1-ud.screen_tilting;
if (!ud.screen_tilting)setrollangle(0);
#ifdef POLYMOST
if (!ud.screen_tilting) setrollangle(0);
#endif
modval(0,1,(int *)&ud.screen_tilting,1,probey==io);
mgametextpal(d,yy, ud.screen_tilting ? "On" : "Off", MENUHIGHLIGHT(io), 0);
break; // original had a 'full' option
@ -3064,7 +3066,7 @@ cheat_for_port_credits:
c = (320>>1)-120;
#if defined(POLYMOST) && defined(USE_OPENGL)
x = (6+(bpp>8));
x = (6+(getrendermode() >= 3));
#else
x = 6;
#endif
@ -3294,7 +3296,7 @@ cheat_for_port_credits:
break;
case 5:
if (bpp==8)
if (!getrendermode())
{
ud.detail = 1-ud.detail;
break;
@ -3321,7 +3323,7 @@ cheat_for_port_credits:
gltexapplyprops();
break;
case 6:
if (bpp==8) break;
if (!getrendermode()) break;
cmenu(230);
break;
#endif
@ -3353,7 +3355,7 @@ cheat_for_port_credits:
}
}
*/
if (bpp == 8)
if (!getrendermode())
{
menutext(c,50+62+16+16,MENUHIGHLIGHT(5),0,"PIXEL DOUBLING");
menutext(c+154,50+62+16+16,MENUHIGHLIGHT(5),0,ud.detail?"OFF":"ON");
@ -3362,7 +3364,7 @@ cheat_for_port_credits:
#if defined(POLYMOST) && defined(USE_OPENGL)
else
{
menutext(c,50+62+16+16,MENUHIGHLIGHT(5),bpp==8,"FILTERING");
menutext(c,50+62+16+16,MENUHIGHLIGHT(5),!getrendermode(),"FILTERING");
switch (gltexfiltermode)
{
case 0:
@ -3387,7 +3389,7 @@ cheat_for_port_credits:
strcpy(tempbuf,"OTHER");
break;
}
mgametextpal(c+154,50+62+16+16-8,tempbuf,MENUHIGHLIGHT(5),bpp==8);
mgametextpal(c+154,50+62+16+16-8,tempbuf,MENUHIGHLIGHT(5),!getrendermode());
menutext(c,50+62+16+16+16,MENUHIGHLIGHT(6),bpp==8,"MORE SETTINGS");
}
#endif

View file

@ -546,7 +546,7 @@ void vscrn(void)
if (j >= 12) y1 += 8;
}
if (ud.screen_size >= 8 && !(ud.screen_size == 8 && ud.statusbarmode && bpp > 8))
if (ud.screen_size >= 8 && !(getrendermode() >= 3 && ud.screen_size == 8 && ud.statusbarmode))
y2 -= (ss+scale(tilesizy[BOTTOMSTATUSBAR],ud.statusbarscale,100));
y1 = scale(y1,ydim,200);