diff --git a/polymer/eduke32/build/include/baselayer.h b/polymer/eduke32/build/include/baselayer.h index 9cec09ebb..488aaced0 100644 --- a/polymer/eduke32/build/include/baselayer.h +++ b/polymer/eduke32/build/include/baselayer.h @@ -29,6 +29,8 @@ extern int32_t startwin_settitle(const char *); extern int32_t startwin_idle(void *); // video +extern int32_t r_usenewaspect, newaspect_enable; +extern uint32_t r_screenxy; extern int32_t xres, yres, bpp, fullscreen, bytesperline, imageSize; extern intptr_t frameplace; extern char offscreenrendering; diff --git a/polymer/eduke32/build/include/build.h b/polymer/eduke32/build/include/build.h index dd0305d28..5420291d4 100644 --- a/polymer/eduke32/build/include/build.h +++ b/polymer/eduke32/build/include/build.h @@ -453,6 +453,7 @@ void squarerotatetile(int16_t tilenume); int32_t setgamemode(char davidoption, int32_t daxdim, int32_t daydim, int32_t dabpp); void nextpage(void); +void setaspect_new(); void setview(int32_t x1, int32_t y1, int32_t x2, int32_t y2); void setaspect(int32_t daxrange, int32_t daaspect); void flushperms(void); diff --git a/polymer/eduke32/build/include/cache1d.h b/polymer/eduke32/build/include/cache1d.h index 59a84c267..7c764388b 100644 --- a/polymer/eduke32/build/include/cache1d.h +++ b/polymer/eduke32/build/include/cache1d.h @@ -26,10 +26,10 @@ int32_t findfrompath(const char *fn, char **where); int32_t openfrompath(const char *fn, int32_t flags, int32_t mode); BFILE *fopenfrompath(const char *fn, const char *mode); -int32_t initgroupfile(char *filename); +int32_t initgroupfile(const char *filename); void uninitsinglegroupfile(int32_t grphandle); void uninitgroupfile(void); -int32_t kopen4load(char *filename, char searchfirst); // searchfirst: 0 = anywhere, 1 = first group, 2 = any group +int32_t kopen4load(const char *filename, char searchfirst); // searchfirst: 0 = anywhere, 1 = first group, 2 = any group int32_t kread(int32_t handle, void *buffer, int32_t leng); int32_t klseek(int32_t handle, int32_t offset, int32_t whence); int32_t kfilelength(int32_t handle); diff --git a/polymer/eduke32/build/src/baselayer.c b/polymer/eduke32/build/src/baselayer.c index 3570caab0..ff73e8bb8 100644 --- a/polymer/eduke32/build/src/baselayer.c +++ b/polymer/eduke32/build/src/baselayer.c @@ -312,6 +312,8 @@ int32_t baselayer_init(void) cvar_t cvars_engine[] = { #ifdef SUPERBUILD + { "r_usenewaspect","r_usenewaspect: enable/disable new screen aspect ratio determination code",(void *)&r_usenewaspect, CVAR_BOOL, 0, 1 }, + { "r_screenaspect","r_screenaspect: if using the new aspect code and in fullscreen, screen aspect ratio in the form XXYY, e.g. 1609 for 16:9",(void *)&r_screenxy, CVAR_UINT, 100, 9999 }, { "r_novoxmips","r_novoxmips: turn off/on the use of mipmaps when rendering 8-bit voxels",(void *)&novoxmips, CVAR_BOOL, 0, 1 }, { "r_voxels","r_voxels: enable/disable automatic sprite->voxel rendering",(void *)&usevoxels, CVAR_BOOL, 0, 1 }, /* { "r_scrcaptureformat","r_scrcaptureformat: sets the output format for screenshots (TGA or PCX)",osdcmd_vars, CVAR_FUNCPTR, 0, 0 },*/ diff --git a/polymer/eduke32/build/src/cache1d.c b/polymer/eduke32/build/src/cache1d.c index 4424833c6..da0c148dc 100644 --- a/polymer/eduke32/build/src/cache1d.c +++ b/polymer/eduke32/build/src/cache1d.c @@ -15,7 +15,7 @@ //Insert '|' in front of filename //Doing this tells kzopen to load the file only if inside a .ZIP file -static intptr_t kzipopen(char *filnam) +static intptr_t kzipopen(const char *filnam) { uint32_t i; char newst[BMAX_PATH+8]; @@ -484,7 +484,7 @@ static char filenamsav[MAXOPENFILES][260]; static int32_t kzcurhand = -1; #endif -int32_t initgroupfile(char *filename) +int32_t initgroupfile(const char *filename) { char buf[16]; int32_t i, j, k; @@ -623,7 +623,7 @@ void uninitgroupfile(void) } } -int32_t kopen4load(char *filename, char searchfirst) +int32_t kopen4load(const char *filename, char searchfirst) { int32_t j, k, fil, newhandle = MAXOPENFILES-1; char bad, *gfileptr; diff --git a/polymer/eduke32/build/src/engine.c b/polymer/eduke32/build/src/engine.c index af64eedaf..61fff9558 100644 --- a/polymer/eduke32/build/src/engine.c +++ b/polymer/eduke32/build/src/engine.c @@ -76,6 +76,10 @@ int32_t dommxoverlay = 1, beforedrawrooms = 1, indrawroomsandmasks = 0; static int32_t oxdimen = -1, oviewingrange = -1, oxyaspect = -1; +// r_usenewaspect is the cvar, newaspect_enable to trigger the new behaviour in the code +int32_t r_usenewaspect = 0, newaspect_enable=0; +uint32_t r_screenxy = 403; // 4:3 aspect ratio + int32_t curbrightness = 0, gammabrightness = 0; double vid_gamma = DEFAULT_GAMMA; @@ -5524,7 +5528,7 @@ void *blockptr = NULL; int32_t preinitengine(void) { char *e; - if (initsystem()) exit(1); + if (initsystem()) exit(9); makeasmwriteable(); @@ -6270,6 +6274,8 @@ void drawmapview(int32_t dax, int32_t day, int32_t zoome, int16_t ang) int32_t xvect, yvect, xvect2, yvect2, daslope; int32_t oydim=ydim; + int32_t oyxaspect=yxaspect, oviewingrange=viewingrange; + ydim = (int32_t)((double)xdim * 0.625f); setaspect(65536L,(int32_t)divscale16(ydim*320L,xdim*200L)); ydim = oydim; @@ -6552,7 +6558,10 @@ void drawmapview(int32_t dax, int32_t day, int32_t zoome, int16_t ang) } enddrawing(); //}}} - setaspect(65536L,(int32_t)divscale16(ydim*320L,xdim*200L)); + if (r_usenewaspect) + setaspect(oviewingrange, oyxaspect); + else + setaspect(65536L,(int32_t)divscale16(ydim*320L,xdim*200L)); } @@ -9737,6 +9746,33 @@ void getzrange(const vec3_t *vect, int16_t sectnum, } } +void setaspect_new() +{ + if (r_usenewaspect && newaspect_enable) + { + // the correction factor 100/107 has been found + // out experimentally. squares ftw! + int32_t vr, yx=(65536*4*100)/(3*107); + int32_t y, x; + + if (fullscreen) + { + x=r_screenxy/100; y=r_screenxy%100; + if (y==0 || x==0) { x=4; y=3; } + } + else + { + x = xdim; + y = ydim; + } + + vr = (65536*x*3)/(y*4); + + setaspect(vr, yx); + } + else + setaspect(65536L,(int32_t)divscale16(ydim*320L,xdim*200L)); +} // // setview @@ -9754,7 +9790,7 @@ void setview(int32_t x1, int32_t y1, int32_t x2, int32_t y2) xdimenrecip = divscale32(1L,xdimen); ydimen = (y2-y1)+1; - setaspect(65536L,(int32_t)divscale16(ydim*320L,xdim*200L)); + setaspect_new(); for (i=0; i +#endif + static void sighandler(int signum) { UNREFERENCED_PARAMETER(signum); @@ -231,9 +236,20 @@ static void sighandler(int signum) { SDL_WM_GrabInput(SDL_GRAB_OFF); SDL_ShowCursor(SDL_ENABLE); +#if PRINTSTACKONSEGV + { + void *addr[32]; + int32_t errfd = fileno(stderr); + int32_t n=backtrace(addr, sizeof(addr)/sizeof(addr[0])); + backtrace_symbols_fd(addr, n, errfd); + } + // This is useful for attaching the debugger post-mortem. For those pesky + // cases where the program runs through happily when inspected from the start. +// usleep(15000000); +#endif attach_debugger_here(); uninitsystem(); - exit(1); + exit(8); } } diff --git a/polymer/eduke32/samples/a.m32 b/polymer/eduke32/samples/a.m32 index 3e1eaa9f1..6f9cdc272 100644 --- a/polymer/eduke32/samples/a.m32 +++ b/polymer/eduke32/samples/a.m32 @@ -25,7 +25,7 @@ define PREVIEW_DRAW_COLOR 11 // whether to use overridden aspect/range values when entering 3d mode (software/Polymost). // tweak with keys 7,8,9,0 on the top row -gamevar use_custom_aspect 0 0 +gamevar use_custom_aspect 0 0 // this is now the same as r_usenewaspect gamevar davr 65536 0 gamevar dayx 65536 0 @@ -426,12 +426,17 @@ onevent EVENT_PREKEYS2D } endevent +gamevar fyx 0 0 +gamevar fvr 0 0 defstate setas -// set j dayx -// mul j ydim mul j 8 -// div j xdim div j 5 - setaspect davr dayx + set fyx dayx + mul fyx 4 mul fyx 100 // the correction factor 100/107 has been found + div fyx 3 div fyx 107 // out experimentally. squares ftw! + set fvr davr + mul fvr xdim mul fvr 3 + div fvr ydim div fvr 4 + setaspect fvr fyx //davr dayx ends onevent EVENT_ENTER3DMODE @@ -960,8 +965,9 @@ onevent EVENT_KEYS3D } ife j 1 { - setaspect davr dayx - qsprintf TQUOTE "ASPECT: VR=%d, YX=%d" davr dayx +// setaspect davr dayx + state setas + qsprintf TQUOTE "ASPECT: davr=%d, dayx=%d | FVR=%d, FYX=%d" davr dayx fvr fyx quote TQUOTE } endevent diff --git a/polymer/eduke32/source/astub.c b/polymer/eduke32/source/astub.c index 50ae861ca..b08ec93e2 100644 --- a/polymer/eduke32/source/astub.c +++ b/polymer/eduke32/source/astub.c @@ -4293,7 +4293,7 @@ static void mouseaction_movesprites(int32_t *sumxvect, int32_t *sumyvect, int32_ if (highlightcnt<=0 || (show2dsprite[searchwall>>3] & (1<<(searchwall&7)))==0) { - clipmove(&tvec, &tsect, daxvect,dayvect, 128,64<<4,64<<4, spnoclip?1:CLIPMASK0); + clipmove(&tvec, &tsect, daxvect,dayvect, sp->clipdist,64<<4,64<<4, spnoclip?1:CLIPMASK0); setsprite(searchwall, &tvec); } else diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index e1b89fd54..34cd434b6 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -166,7 +166,7 @@ extern char forcegl; void M32RunScript(const char *s) { UNREFERENCED_PARAMETER(s); }; // needed for linking since it's referenced from build/src/osd.c -int32_t kopen4loadfrommod(char *filename, char searchfirst) +int32_t kopen4loadfrommod(const char *filename, char searchfirst) { static char fn[BMAX_PATH]; int32_t r; @@ -2354,7 +2354,7 @@ static void G_DrawOverheadMap(int32_t cposx, int32_t cposy, int32_t czoom, int16 } } - setaspect(65536L,(int32_t)divscale16(ydim*320L,xdim*200L)); + setaspect_new(); TRAVERSE_CONNECT(p) { @@ -3211,6 +3211,8 @@ void G_DrawRooms(int32_t snum, int32_t smoothratio) int16_t tang; int32_t tiltcx,tiltcy,tiltcs=0; // JBF 20030807 + int32_t tmpyx=yxaspect, tmpvr=viewingrange; + if (pub > 0 || getrendermode() >= 3) // JBF 20040101: redraw background always { if (getrendermode() >= 3 || ud.screen_size > 8 || (ud.screen_size == 8 && ud.statusbarscale<100)) @@ -3221,6 +3223,12 @@ void G_DrawRooms(int32_t snum, int32_t smoothratio) if (ud.overhead_on == 2 || ud.show_help || (p->cursectnum == -1 && getrendermode() < 3)) return; + if (r_usenewaspect) + { + newaspect_enable = 1; + setaspect_new(); + } + // smoothratio = min(max(smoothratio,0),65536); smoothratio = min(max((totalclock - ototalclock) * (65536 / 4),0),65536); @@ -3259,10 +3267,19 @@ void G_DrawRooms(int32_t snum, int32_t smoothratio) else { i = divscale22(1,sprite[p->i].yrepeat+28); -// if (i != oyrepeat) + + if (!r_usenewaspect) { - oyrepeat = i; - setaspect(oyrepeat,yxaspect); +// if (i != oyrepeat) + { + oyrepeat = i; + setaspect(oyrepeat,yxaspect); + } + } + else + { + tmpvr = i; + tmpyx = (65536*ydim*8)/(xdim*5); } if (g_screenCapture) @@ -3315,6 +3332,9 @@ void G_DrawRooms(int32_t snum, int32_t smoothratio) if (i > 256) i = 512-i; i = sintable[i+512]*8 + sintable[i]*5L; setaspect(i>>1,yxaspect); + + tmpvr = i>>1; + tmpyx = (65536*ydim*8)/(xdim*5); } else if (getrendermode() > 0 && ud.screen_tilting /*&& (p->rotscrnang || p->orotscrnang)*/) { @@ -3502,6 +3522,12 @@ void G_DrawRooms(int32_t snum, int32_t smoothratio) p->visibility += (ud.const_visibility-p->visibility)>>2; } else p->visibility = ud.const_visibility; + + if (r_usenewaspect) + { + newaspect_enable = 0; + setaspect(tmpvr, tmpyx); + } } static void G_DumpDebugInfo(void) @@ -8996,7 +9022,8 @@ static void G_Startup(void) wm_msgbox("Build Engine Initialization Error", "There was a problem initializing the Build engine: %s", engineerrstr); G_Cleanup(); - exit(1); + fprintf(stderr, "G_Startup: There was a problem initializing the Build engine: %s\n", engineerrstr); + exit(6); } G_InitDynamicTiles(); @@ -9239,7 +9266,7 @@ void app_crashhandler(void) } #endif -void app_main(int32_t argc,const char **argv) +int32_t app_main(int32_t argc,const char **argv) { int32_t i = 0, j; char cwd[BMAX_PATH]; @@ -9263,7 +9290,7 @@ void app_main(int32_t argc,const char **argv) { if (!wm_ynbox("EDuke32","Another Build game is currently running. " "Do you wish to continue starting this copy?")) - return; + return 3; } #endif @@ -9449,7 +9476,8 @@ void app_main(int32_t argc,const char **argv) { wm_msgbox("Build Engine Initialization Error", "There was a problem initializing the Build engine: %s", engineerrstr); - exit(1); + fprintf(stderr, "app_main: There was a problem initializing the Build engine: %s\n", engineerrstr); + exit(2); } if (Bstrcmp(setupfilename, SETUPFILENAME)) @@ -9737,7 +9765,7 @@ CLEAN_DIRECTORY: i = 1-i; } - if (quitevent) return; + if (quitevent) return 4; if (!loaddefinitionsfile(g_defNamePtr)) { @@ -9797,8 +9825,9 @@ CLEAN_DIRECTORY: if (CONTROL_Startup(1, &GetTime, TICRATE)) { + fprintf(stderr, "There was an error initializing the CONTROL system.\n"); uninitengine(); - exit(1); + exit(5); } G_SetupGameButtons(); @@ -10082,6 +10111,7 @@ MAIN_LOOP_RESTART: while (1); G_GameExit(" "); + return 0; // not reached (duh) } GAME_STATIC GAME_INLINE int32_t G_MoveLoop() diff --git a/polymer/eduke32/source/game.h b/polymer/eduke32/source/game.h index d2bf996a0..b2096a162 100644 --- a/polymer/eduke32/source/game.h +++ b/polymer/eduke32/source/game.h @@ -240,7 +240,7 @@ int32_t G_GameTextLen(int32_t x,const char *t); int32_t G_PrintGameText(int32_t f,int32_t tile,int32_t x,int32_t y,const char *t,int32_t s,int32_t p,int32_t o,int32_t x1,int32_t y1,int32_t x2,int32_t y2,int32_t z); int32_t GetTime(void); int32_t _EnterText(int32_t small,int32_t x,int32_t y,char *t,int32_t dalen,int32_t c); -int32_t kopen4loadfrommod(char *filename,char searchfirst); +int32_t kopen4loadfrommod(const char *filename,char searchfirst); int32_t minitext_(int32_t x,int32_t y,const char *t,int32_t s,int32_t p,int32_t sb); extern inline int32_t mpgametext(int32_t y,const char *t,int32_t s,int32_t dabits); int32_t startwin_run(void); @@ -278,7 +278,7 @@ void G_UpdatePlayerFromMenu(void); void M32RunScript(const char *s); void P_DoQuote(int32_t q,DukePlayer_t *p); void P_SetGamePalette(DukePlayer_t *player,uint8_t *pal,int32_t set); -void app_main(int32_t argc,const char **argv); +int32_t app_main(int32_t argc,const char **argv); void computergetinput(int32_t snum,input_t *syn); void fadepal(int32_t r,int32_t g,int32_t b,int32_t start,int32_t end,int32_t step); void fadepaltile(int32_t r,int32_t g,int32_t b,int32_t start,int32_t end,int32_t step,int32_t tile); diff --git a/polymer/eduke32/source/gamedef.c b/polymer/eduke32/source/gamedef.c index b2bbc6bd5..78e00b1a8 100644 --- a/polymer/eduke32/source/gamedef.c +++ b/polymer/eduke32/source/gamedef.c @@ -80,6 +80,7 @@ static struct { uint32_t keyw; uint32_t date; } g_keywdate[] = { CON_STOPACTORSOUND, 20090715 }, { CON_IFSERVER, 20100722 }, { CON_CALCHYPOTENUSE, 20100927 }, + { CON_CLIPMOVENOSLIDE, 20101009 }, }; char g_szScriptFileName[BMAX_PATH] = "(none)"; // file we're currently compiling