High-level TROR drawing: clean up how things are passed around.

git-svn-id: https://svn.eduke32.com/eduke32@2880 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2012-08-13 18:25:37 +00:00
parent 8eafee0636
commit 2b2be071d4
8 changed files with 27 additions and 33 deletions

View file

@ -132,12 +132,13 @@ static inline int32_t yax_waltosecmask(int32_t walclipmask)
return ((walclipmask&1)<<9) | ((walclipmask&64)<<5); return ((walclipmask&1)<<9) | ((walclipmask&64)<<5);
} }
void yax_preparedrawrooms(void); void yax_preparedrawrooms(void);
void yax_drawrooms(void (*ExtAnalyzeSprites)(void), int32_t horiz, int16_t sectnum, int32_t didmirror); void yax_drawrooms(void (*SpriteAnimFunc)(int32_t,int32_t,int32_t,int32_t),
int16_t sectnum, int32_t didmirror, int32_t smoothr);
# define YAX_SKIPSECTOR(i) if (graysectbitmap[(i)>>3]&(1<<((i)&7))) continue # define YAX_SKIPSECTOR(i) if (graysectbitmap[(i)>>3]&(1<<((i)&7))) continue
# define YAX_SKIPWALL(i) if (graywallbitmap[(i)>>3]&(1<<((i)&7))) continue # define YAX_SKIPWALL(i) if (graywallbitmap[(i)>>3]&(1<<((i)&7))) continue
#else #else
# define yax_preparedrawrooms() # define yax_preparedrawrooms()
# define yax_drawrooms(ExtAnalyzeSprites, horiz, sectnum, didmirror) # define yax_drawrooms(SpriteAnimFunc, sectnum, didmirror, smoothr)
# define YAX_SKIPSECTOR(i) (i)=(i) # define YAX_SKIPSECTOR(i) (i)=(i)
# define YAX_SKIPWALL(i) (i)=(i) # define YAX_SKIPWALL(i) (i)=(i)
#endif #endif

View file

@ -158,7 +158,7 @@ extern int32_t ExtInit(void);
extern int32_t ExtPreInit(int32_t argc,const char **argv); extern int32_t ExtPreInit(int32_t argc,const char **argv);
extern void ExtUnInit(void); extern void ExtUnInit(void);
extern void ExtPreCheckKeys(void); extern void ExtPreCheckKeys(void);
extern void ExtAnalyzeSprites(void); extern void ExtAnalyzeSprites(int32_t, int32_t, int32_t, int32_t);
extern void ExtCheckKeys(void); extern void ExtCheckKeys(void);
extern void ExtPreLoadMap(void); extern void ExtPreLoadMap(void);
extern void ExtSetupMapFilename(const char *mapname); extern void ExtSetupMapFilename(const char *mapname);

View file

@ -467,9 +467,9 @@ void M32_DrawRoomsAndMasks(void)
{ {
yax_preparedrawrooms(); yax_preparedrawrooms();
drawrooms(pos.x,pos.y,pos.z,ang,horiz,cursectnum); drawrooms(pos.x,pos.y,pos.z,ang,horiz,cursectnum);
yax_drawrooms(ExtAnalyzeSprites, horiz, cursectnum, 0); yax_drawrooms(ExtAnalyzeSprites, cursectnum, 0, 0);
ExtAnalyzeSprites(); ExtAnalyzeSprites(0,0,0,0);
drawmasks(); drawmasks();
M32_ResetFakeRORTiles(); M32_ResetFakeRORTiles();
@ -478,7 +478,7 @@ void M32_DrawRoomsAndMasks(void)
{ {
polymer_editorpick(); polymer_editorpick();
drawrooms(pos.x,pos.y,pos.z,ang,horiz,cursectnum); drawrooms(pos.x,pos.y,pos.z,ang,horiz,cursectnum);
ExtAnalyzeSprites(); ExtAnalyzeSprites(0,0,0,0);
drawmasks(); drawmasks();
M32_ResetFakeRORTiles(); M32_ResetFakeRORTiles();
} }

View file

@ -204,6 +204,7 @@ static void scansector(int16_t sectnum);
static void draw_rainbow_background(void); static void draw_rainbow_background(void);
int16_t editstatus = 0; int16_t editstatus = 0;
static int32_t global100horiz; // (-100..300)-scale horiz (the one passed to drawrooms)
////////// YAX ////////// ////////// YAX //////////
@ -838,10 +839,13 @@ void yax_preparedrawrooms(void)
} }
} }
void yax_drawrooms(void (*ExtAnalyzeSprites)(void), int32_t horiz, int16_t sectnum, int32_t didmirror) void yax_drawrooms(void (*SpriteAnimFunc)(int32_t,int32_t,int32_t,int32_t),
int16_t sectnum, int32_t didmirror, int32_t smoothr)
{ {
static uint8_t havebunch[YAX_MAXBUNCHES>>3]; static uint8_t havebunch[YAX_MAXBUNCHES>>3];
const int32_t horiz = global100horiz;
int32_t i, j, k, lev, cf, nmp; int32_t i, j, k, lev, cf, nmp;
int32_t bnchcnt, bnchnum[2] = {0,0}, maxlev[2]; int32_t bnchcnt, bnchnum[2] = {0,0}, maxlev[2];
int16_t ourbunch[2] = {-1,-1}, osectnum=sectnum; int16_t ourbunch[2] = {-1,-1}, osectnum=sectnum;
@ -1052,7 +1056,7 @@ void yax_drawrooms(void (*ExtAnalyzeSprites)(void), int32_t horiz, int16_t sectn
yax_globallev-YAX_MAXDRAWS, j, k, spritesortcnt, yax_globallev-YAX_MAXDRAWS, j, k, spritesortcnt,
(double)(1000*(gethiticks()-t))/hitickspersec); (double)(1000*(gethiticks()-t))/hitickspersec);
ExtAnalyzeSprites(); SpriteAnimFunc(globalposx, globalposy, globalang, smoothr);
drawmasks(); drawmasks();
} }
@ -8259,6 +8263,8 @@ int32_t drawrooms(int32_t daposx, int32_t daposy, int32_t daposz,
globalposx = daposx; globalposy = daposy; globalposz = daposz; globalposx = daposx; globalposy = daposy; globalposz = daposz;
globalang = (daang&2047); globalang = (daang&2047);
global100horiz = dahoriz;
// xdimenscale is scale(xdimen,yxaspect,320); // xdimenscale is scale(xdimen,yxaspect,320);
// normalization by viewingrange so that center-of-aim doesn't depend on it // normalization by viewingrange so that center-of-aim doesn't depend on it
globalhoriz = mulscale16(dahoriz-100,divscale16(xdimenscale,viewingrange))+(ydimen>>1); globalhoriz = mulscale16(dahoriz-100,divscale16(xdimenscale,viewingrange))+(ydimen>>1);

View file

@ -2808,7 +2808,7 @@ static void ExtSE40Draw(int32_t spnum,int32_t x,int32_t y,int32_t z,int16_t a,in
} }
drawrooms(x+offx,y+offy,z+offz,a,h,sprite[floor2].sectnum); drawrooms(x+offx,y+offy,z+offz,a,h,sprite[floor2].sectnum);
ExtAnalyzeSprites(); ExtAnalyzeSprites(0,0,0,0);
drawmasks(); drawmasks();
M32_ResetFakeRORTiles(); M32_ResetFakeRORTiles();
@ -2834,7 +2834,7 @@ static void ExtSE40Draw(int32_t spnum,int32_t x,int32_t y,int32_t z,int16_t a,in
// Now re-draw // Now re-draw
drawrooms(x+offx,y+offy,z+offz,a,h,sprite[floor2].sectnum); drawrooms(x+offx,y+offy,z+offz,a,h,sprite[floor2].sectnum);
ExtAnalyzeSprites(); ExtAnalyzeSprites(0,0,0,0);
drawmasks(); drawmasks();
M32_ResetFakeRORTiles(); M32_ResetFakeRORTiles();
} }
@ -10874,12 +10874,17 @@ void ExtPreCheckKeys(void) // just before drawrooms
enddrawing(); //}}} enddrawing(); //}}}
} }
void ExtAnalyzeSprites(void) void ExtAnalyzeSprites(int32_t ourx, int32_t oury, int32_t oura, int32_t smoothr)
{ {
int32_t i, k; int32_t i, k;
spritetype *tspr; spritetype *tspr;
int32_t frames=0, sh; int32_t frames=0, sh;
UNREFERENCED_PARAMETER(ourx);
UNREFERENCED_PARAMETER(oury);
UNREFERENCED_PARAMETER(oura);
UNREFERENCED_PARAMETER(smoothr);
for (i=0,tspr=&tsprite[0]; i<spritesortcnt; i++,tspr++) for (i=0,tspr=&tsprite[0]; i<spritesortcnt; i++,tspr++)
{ {
frames=0; frames=0;

View file

@ -3324,14 +3324,6 @@ static void G_SE40(int32_t smoothratio)
} }
} }
int32_t g_yax_smoothratio;
#ifdef YAX_ENABLE
void G_AnalyzeSprites(void)
{
G_DoSpriteAnimations(ud.camera.x,ud.camera.y,ud.cameraang,g_yax_smoothratio);
}
#endif
void G_HandleMirror(int32_t x, int32_t y, int32_t z, int32_t a, int32_t horiz, int32_t smoothratio) void G_HandleMirror(int32_t x, int32_t y, int32_t z, int32_t a, int32_t horiz, int32_t smoothratio)
{ {
if ((gotpic[MIRROR>>3]&(1<<(MIRROR&7))) if ((gotpic[MIRROR>>3]&(1<<(MIRROR&7)))
@ -3393,8 +3385,7 @@ void G_HandleMirror(int32_t x, int32_t y, int32_t z, int32_t a, int32_t horiz, i
yax_preparedrawrooms(); yax_preparedrawrooms();
didmirror = drawrooms(tposx,tposy,z,tang,horiz,g_mirrorSector[i]+MAXSECTORS); didmirror = drawrooms(tposx,tposy,z,tang,horiz,g_mirrorSector[i]+MAXSECTORS);
g_yax_smoothratio = smoothratio; yax_drawrooms(G_DoSpriteAnimations, g_mirrorSector[i], didmirror, smoothratio);
yax_drawrooms(G_AnalyzeSprites, horiz, g_mirrorSector[i], didmirror);
} }
#ifdef USE_OPENGL #ifdef USE_OPENGL
else else
@ -3470,8 +3461,7 @@ void G_DrawRooms(int32_t snum, int32_t smoothratio)
#endif #endif
yax_preparedrawrooms(); yax_preparedrawrooms();
drawrooms(s->x,s->y,s->z-(4<<8),ud.cameraang,s->yvel,s->sectnum); drawrooms(s->x,s->y,s->z-(4<<8),ud.cameraang,s->yvel,s->sectnum);
g_yax_smoothratio = smoothratio; yax_drawrooms(G_DoSpriteAnimations, s->sectnum, 0, smoothratio);
yax_drawrooms(G_AnalyzeSprites, s->yvel, s->sectnum, 0);
G_DoSpriteAnimations(s->x,s->y,ud.cameraang,smoothratio); G_DoSpriteAnimations(s->x,s->y,ud.cameraang,smoothratio);
drawmasks(); drawmasks();
} }
@ -3684,9 +3674,7 @@ void G_DrawRooms(int32_t snum, int32_t smoothratio)
yax_preparedrawrooms(); yax_preparedrawrooms();
drawrooms(ud.camera.x,ud.camera.y,ud.camera.z,ud.cameraang,ud.camerahoriz,ud.camerasect); drawrooms(ud.camera.x,ud.camera.y,ud.camera.z,ud.cameraang,ud.camerahoriz,ud.camerasect);
g_yax_smoothratio = smoothratio; yax_drawrooms(G_DoSpriteAnimations, ud.camerasect, 0, smoothratio);
yax_drawrooms(G_AnalyzeSprites, ud.camerahoriz, ud.camerasect, 0);
// dupe the sprites touching the portal to the other sector // dupe the sprites touching the portal to the other sector

View file

@ -242,8 +242,6 @@ extern int8_t g_noFloorPal[MAXPALOOKUPS];
extern user_defs ud; extern user_defs ud;
//extern int32_t g_yax_smoothratio;
int32_t A_CheckInventorySprite(spritetype *s); int32_t A_CheckInventorySprite(spritetype *s);
int32_t A_InsertSprite(int32_t whatsect,int32_t s_x,int32_t s_y,int32_t s_z,int32_t s_pn,int32_t s_s,int32_t s_xr,int32_t s_yr,int32_t s_a,int32_t s_ve,int32_t s_zv,int32_t s_ow,int32_t s_ss); int32_t A_InsertSprite(int32_t whatsect,int32_t s_x,int32_t s_y,int32_t s_z,int32_t s_pn,int32_t s_s,int32_t s_xr,int32_t s_yr,int32_t s_a,int32_t s_ve,int32_t s_zv,int32_t s_ow,int32_t s_ss);
int32_t A_Spawn(int32_t j,int32_t pn); int32_t A_Spawn(int32_t j,int32_t pn);
@ -290,9 +288,6 @@ void G_HandleLocalKeys(void);
void G_HandleSpecialKeys(void); void G_HandleSpecialKeys(void);
void G_PrintGameQuotes(void); void G_PrintGameQuotes(void);
//void G_SE40(int32_t smoothratio); //void G_SE40(int32_t smoothratio);
#ifdef YAX_ENABLE
void G_AnalyzeSprites(void);
#endif
void G_SetCrosshairColor(int32_t r,int32_t g,int32_t b); void G_SetCrosshairColor(int32_t r,int32_t g,int32_t b);
void G_SetStatusBarScale(int32_t sc); void G_SetStatusBarScale(int32_t sc);
void G_Shutdown(void); void G_Shutdown(void);

View file

@ -572,8 +572,7 @@ void G_SetupCamTile(int32_t i,int32_t wn)
yax_preparedrawrooms(); yax_preparedrawrooms();
drawrooms(SX,SY,SZ,SA,100+sprite[i].shade,SECT); drawrooms(SX,SY,SZ,SA,100+sprite[i].shade,SECT);
// g_yax_smoothratio? yax_drawrooms(G_DoSpriteAnimations, SECT, 0, 65536);
yax_drawrooms(G_AnalyzeSprites, 100+sprite[i].shade, SECT, 0);
display_mirror = 1; display_mirror = 1;
G_DoSpriteAnimations(SX,SY,SA,65536L); G_DoSpriteAnimations(SX,SY,SA,65536L);