diff --git a/source/duke3d/src/events_defs.h b/source/duke3d/src/events_defs.h index e268dae36..c55308c06 100644 --- a/source/duke3d/src/events_defs.h +++ b/source/duke3d/src/events_defs.h @@ -132,6 +132,8 @@ enum GameEvent_t { EVENT_DISPLAYEND, EVENT_OPENMENUSOUND, EVENT_RECOGSOUND, + EVENT_UPDATESCREENAREA, + EVENT_DISPLAYBORDER, #ifdef LUNATIC EVENT_ANIMATEALLSPRITES, #endif diff --git a/source/duke3d/src/game.h b/source/duke3d/src/game.h index a3c55d99a..7c614436a 100644 --- a/source/duke3d/src/game.h +++ b/source/duke3d/src/game.h @@ -147,6 +147,7 @@ typedef struct { int32_t democams,color,msgdisptime,statusbarmode; int32_t m_noexits,noexits,autovote,automsg,idplayers; int32_t team, viewbob, weaponsway, althud, weaponscale, textscale; + int32_t screenarea_x1, screenarea_y1, screenarea_x2, screenarea_y2; int32_t entered_name,screen_tilting,shadows,fta_on,executions,auto_run; int32_t coords,showfps,levelstats,m_coop,coop,screen_size,lockout,crosshair; diff --git a/source/duke3d/src/gamedef.cpp b/source/duke3d/src/gamedef.cpp index 4e5297486..d60245682 100644 --- a/source/duke3d/src/gamedef.cpp +++ b/source/duke3d/src/gamedef.cpp @@ -728,6 +728,8 @@ const char *EventNames[MAXEVENTS] = "EVENT_DISPLAYEND", "EVENT_OPENMENUSOUND", "EVENT_RECOGSOUND", + "EVENT_UPDATESCREENAREA", + "EVENT_DISPLAYBORDER", #ifdef LUNATIC "EVENT_ANIMATEALLSPRITES", #endif @@ -1220,6 +1222,10 @@ const memberlabel_t UserdefsLabels[]= { "mgametext_tracking", USERDEFS_MGAMETEXT_TRACKING, 0, 0 }, { "menutext_tracking", USERDEFS_MENUTEXT_TRACKING, 0, 0 }, { "maxspritesonscreen", USERDEFS_MAXSPRITESONSCREEN, 0, 0 }, + { "screenarea_x1", USERDEFS_SCREENAREA_X1, 0, 0 }, + { "screenarea_y1", USERDEFS_SCREENAREA_Y1, 0, 0 }, + { "screenarea_x2", USERDEFS_SCREENAREA_X2, 0, 0 }, + { "screenarea_y2", USERDEFS_SCREENAREA_Y2, 0, 0 }, { NULL, -1, 0, 0 } // END OF LIST }; diff --git a/source/duke3d/src/gamedef.h b/source/duke3d/src/gamedef.h index 30290e83e..44f222000 100644 --- a/source/duke3d/src/gamedef.h +++ b/source/duke3d/src/gamedef.h @@ -526,6 +526,10 @@ enum UserdefsLabel_t USERDEFS_MGAMETEXT_TRACKING, USERDEFS_MENUTEXT_TRACKING, USERDEFS_MAXSPRITESONSCREEN, + USERDEFS_SCREENAREA_X1, + USERDEFS_SCREENAREA_Y1, + USERDEFS_SCREENAREA_X2, + USERDEFS_SCREENAREA_Y2, USERDEFS_END }; diff --git a/source/duke3d/src/gamestructures.cpp b/source/duke3d/src/gamestructures.cpp index f6cfaf212..615475aae 100644 --- a/source/duke3d/src/gamestructures.cpp +++ b/source/duke3d/src/gamestructures.cpp @@ -173,6 +173,10 @@ int32_t __fastcall VM_GetUserdef(int32_t labelNum) case USERDEFS_MGAMETEXT_TRACKING: labelNum = MF_Bluefont.between.x; break; case USERDEFS_MENUTEXT_TRACKING: labelNum = MF_Redfont.between.x; break; case USERDEFS_MAXSPRITESONSCREEN: labelNum = maxspritesonscreen; break; + case USERDEFS_SCREENAREA_X1: labelNum = ud.screenarea_x1; break; + case USERDEFS_SCREENAREA_Y1: labelNum = ud.screenarea_y1; break; + case USERDEFS_SCREENAREA_X2: labelNum = ud.screenarea_x2; break; + case USERDEFS_SCREENAREA_Y2: labelNum = ud.screenarea_y2; break; default: labelNum = -1; break; } @@ -296,6 +300,10 @@ void __fastcall VM_SetUserdef(int32_t const labelNum, int32_t const iSet) case USERDEFS_MGAMETEXT_TRACKING: MF_BluefontRed.between.x = MF_Bluefont.between.x = iSet; break; case USERDEFS_MENUTEXT_TRACKING: MF_Redfont.between.x = iSet; break; case USERDEFS_MAXSPRITESONSCREEN: maxspritesonscreen = clamp(iSet, MAXSPRITESONSCREEN>>2, MAXSPRITESONSCREEN); break; + case USERDEFS_SCREENAREA_X1: ud.screenarea_x1 = iSet; break; + case USERDEFS_SCREENAREA_Y1: ud.screenarea_y1 = iSet; break; + case USERDEFS_SCREENAREA_X2: ud.screenarea_x2 = iSet; break; + case USERDEFS_SCREENAREA_Y2: ud.screenarea_y2 = iSet; break; default: break; } } diff --git a/source/duke3d/src/premap.cpp b/source/duke3d/src/premap.cpp index cea7f352d..0a48cb6e0 100644 --- a/source/duke3d/src/premap.cpp +++ b/source/duke3d/src/premap.cpp @@ -569,11 +569,11 @@ void G_UpdateScreenArea(void) { const int32_t ss = max(ud.screen_size-8,0); - const int32_t x1 = scale(ss,xdim,160); + int32_t x1 = scale(ss,xdim,160); int32_t x2 = xdim-x1; int32_t y1 = ss; - int32_t y2 = 200; + int32_t y2 = 200-ss; if (ud.screen_size > 0 && (g_gametypeFlags[ud.coop]&GAMETYPE_FRAGBAR) && (g_netServer || ud.multimode > 1)) { @@ -582,17 +582,31 @@ void G_UpdateScreenArea(void) for (TRAVERSE_CONNECT(i)) if (i > j) j = i; - if (j >= 1) y1 += 8; - if (j >= 4) y1 += 8; - if (j >= 8) y1 += 8; - if (j >= 12) y1 += 8; + if (j > 0) y1 += 8; + if (j > 4) y1 += 8; + if (j > 8) y1 += 8; + if (j > 12) y1 += 8; } + y2 *= 100; if (ud.screen_size >= 8 && ud.statusbarmode==0) - y2 -= (ss+scale(tilesiz[BOTTOMSTATUSBAR].y,ud.statusbarscale,100)); + y2 -= tilesiz[BOTTOMSTATUSBAR].y*ud.statusbarscale; y1 = scale(y1,ydim,200); - y2 = scale(y2,ydim,200)+(getrendermode() != REND_CLASSIC); + y2 = scale(y2,ydim,200*100); + + if (VM_HaveEvent(EVENT_UPDATESCREENAREA)) + { + ud.screenarea_x1 = x1; + ud.screenarea_y1 = y1; + ud.screenarea_x2 = x2; + ud.screenarea_y2 = y2; + VM_OnEvent(EVENT_UPDATESCREENAREA, g_player[screenpeek].ps->i, screenpeek); + x1 = ud.screenarea_x1; + y1 = ud.screenarea_y1; + x2 = ud.screenarea_x2; + y2 = ud.screenarea_y2; + } if (g_halveScreenArea) { diff --git a/source/duke3d/src/sbar.cpp b/source/duke3d/src/sbar.cpp index e56f96a5d..65114a73a 100644 --- a/source/duke3d/src/sbar.cpp +++ b/source/duke3d/src/sbar.cpp @@ -1021,25 +1021,13 @@ void G_DrawStatusBar(int32_t snum) void G_DrawBackground(void) { - const int32_t dapicnum = BIGHOLE; int32_t x, y, x1, x2; flushperms(); int32_t y1=0, y2=ydim; - if ((g_player[myconnectindex].ps->gm&MODE_GAME) || ud.recstat == 2) - { -#if 0 - // [JM] Commented out since it breaks fragbar in widescreen and serves no other useful purpose anymore. - if (g_gametypeFlags[ud.coop] & GAMETYPE_FRAGBAR) - { - if ((g_netServer || ud.multimode > 1)) y1 += scale(ydim, 8, 200); - if (ud.multimode > 4) y1 += scale(ydim, 8, 200); - } -#endif - } - else + if ((g_player[myconnectindex].ps->gm&MODE_GAME) == 0 && ud.recstat != 2) { const int32_t MENUTILE = MENUSCREEN;//(getrendermode() == REND_CLASSIC ? MENUSCREEN : LOADSCREEN); const int32_t fstilep = tilesiz[MENUTILE].x>=320 && tilesiz[MENUTILE].y==200; @@ -1067,85 +1055,92 @@ void G_DrawBackground(void) return; } + int32_t const dapicnum = VM_OnEventWithReturn(EVENT_DISPLAYBORDER, g_player[screenpeek].ps->i, screenpeek, BIGHOLE); + // XXX: if dapicnum is not available, this might leave the menu background // not drawn, leading to "HOM". - if (tilesiz[dapicnum].x == 0 || tilesiz[dapicnum].y == 0) + if ((dapicnum >= 0 && tilesiz[dapicnum].x == 0) || (dapicnum >= 0 && tilesiz[dapicnum].y == 0) || + (windowxy1.x-1 <= 0 && windowxy2.x >= xdim-1 && windowxy1.y-1 <= 0 && windowxy2.y >= ydim-1) || + dapicnum < 0) { pus = pub = NUMPAGES; return; } - y2 = scale(ydim, 200-sbarsc(tilesiz[BOTTOMSTATUSBAR].y), 200); - - if ((ud.screen_size > 8) || ((g_gametypeFlags[ud.coop] & GAMETYPE_FRAGBAR) && ud.screen_size >= 4)) + if (ud.screen_size > 0 && (g_gametypeFlags[ud.coop]&GAMETYPE_FRAGBAR) && (g_netServer || ud.multimode > 1)) { - // across top - for (y=0; y j) j = i; + + if (j > 0) y1 += 8; + if (j > 4) y1 += 8; + if (j > 8) y1 += 8; + if (j > 12) y1 += 8; + + y1 = scale(ydim, y1, 200); + y1 -= ((tilesiz[dapicnum].y / y1) +1) * tilesiz[dapicnum].y; } - if (ud.screen_size > 8) + if (windowxy1.y > 0) + { + for (y=y1; y 0 || windowxy2.x < xdim) { - // sides const int32_t rx = windowxy2.x-windowxy2.x%tilesiz[dapicnum].x; - for (y=windowxy1.y-windowxy1.y%tilesiz[dapicnum].y; y 0) + rotatesprite(x<<16, y<<16, 65536L, 0, dapicnum, 8, 0, 8+16+64, 0, windowxy1.y-1, windowxy1.x-2, windowxy2.y); // left + if (windowxy2.x < xdim) + rotatesprite((x+rx)<<16, y<<16, 65536L, 0, dapicnum, 8, 0, 8+16+64, windowxy2.x+1, windowxy1.y-1, xdim-1, windowxy2.y); // right } + } - // along bottom - for (y=windowxy2.y-(windowxy2.y%tilesiz[dapicnum].y); y= 8 && ud.statusbarmode == 0) + x1 = windowxy1.x-4; + y1 = windowxy1.y-4; + x2 = windowxy2.x+4; + y2 = windowxy2.y+4; + + if (windowxy1.x > 0 || windowxy2.x < xdim) + for (y=y1+4; y> 1; - for (y=y2-y2%tilesiz[dapicnum].y; y>1; x+=tilesiz[dapicnum].x) - { - rotatesprite(x<<16, y<<16, 65536L, 0, dapicnum, 8, 0, 8+16+64, 0, y2, x2, ydim-1); - rotatesprite((xdim-x)<<16, y<<16, 65536L, 0, dapicnum, 8, 0, 8+16+64, xdim-x2-1, y2, xdim-1, ydim-1); - } + if (windowxy1.x > 0) + rotatesprite(x1<<16, y<<16, 65536L, 0, VIEWBORDER, 0, 0, 8+16+64, x1, y1, x2, y2); // left + if (windowxy2.x < xdim) + rotatesprite((x2+1)<<16, (y+64)<<16, 65536L, 1024, VIEWBORDER, 0, 0, 8+16+64, x1, y1, x2, y2); // right } - if (ud.screen_size > 8) + if (windowxy1.y > 0 || windowxy2.y < ydim) + for (x=x1+4; x 1)) y += 8; - if (ud.multimode > 4) y += 8; - } - - x1 = max(windowxy1.x-4, 0); - y1 = max(windowxy1.y-4, y); - x2 = min(windowxy2.x+4, xdim-1); - y2 = min(windowxy2.y+4, scale(ydim, 200-sbarsc(tilesiz[BOTTOMSTATUSBAR].y), 200)-1); - - for (y=y1+4; y 0) + rotatesprite((x+64)<<16, y1<<16, 65536L, 512, VIEWBORDER, 0, 0, 8+16+64, x1, y1, x2, y2); // top + if (windowxy2.y < ydim) + rotatesprite(x<<16, (y2+1)<<16, 65536L, 1536, VIEWBORDER, 0, 0, 8+16+64, x1, y1, x2, y2); // bottom } + if (windowxy1.x > 0 && windowxy1.y > 0) + rotatesprite(x1<<16, y1<<16, 65536L, 0, VIEWBORDER+1, 0, 0, 8+16+64, x1, y1, x2, y2); // top left + if (windowxy2.x < xdim && windowxy1.y > 0) + rotatesprite((x2+1)<<16, y1<<16, 65536L, 512, VIEWBORDER+1, 0, 0, 8+16+64, x1, y1, x2, y2); // top right + if (windowxy2.x < xdim && windowxy2.y < ydim) + rotatesprite((x2+1)<<16, (y2+1)<<16, 65536L, 1024, VIEWBORDER+1, 0, 0, 8+16+64, x1, y1, x2, y2); // bottom right + if (windowxy1.x > 0 && windowxy2.y < ydim) + rotatesprite(x1<<16, (y2+1)<<16, 65536L, 1536, VIEWBORDER+1, 0, 0, 8+16+64, x1, y1, x2, y2); // bottom left + pus = pub = NUMPAGES; }