Free games for graphing calculators: NumWorks, TI-Nspire CX, Casio fx-CG50 and soon TI-84 Plus CE. Balatro, Celeste, Hollow Knight, Minecraft and more.
C calculatorcalculator-gamescasiochesscrossy-roaddrive-madfx-cg50gamesgeometry-dashgraphing-calculatorndlessnumworksnumworks-appsnumworks-calculatornumworks-gamenumworks-gamestetristi-84-plus-ceti-nspire
Doom: vanilla screen sizes, full screen and low detail
Mason36340de3e7a76dc
diff --git a/games/doom/src/doom/d_main.c b/games/doom/src/doom/d_main.cindex f2b33ee4..db2510d6 100644--- a/games/doom/src/doom/d_main.c+++ b/games/doom/src/doom/d_main.c@@ -213,6 +213,9 @@ boolean D_Display (void)oldgamestate = -1; // force background redrawborderdrawcount = 3;}+#elif NUMWORKS+ if (setsizeneeded)+ R_ExecuteSetViewSize ();#endif// save the current screen if about to wipe@@ -2157,6 +2160,16 @@ void D_DoomMain (void)// the calculator's keys and settings; the moment kept by Home, if there is one, comes backnw_input_init();nw_settings_load();+#if HOST+ if (getenv("NWVIEW"))+ {+ // (tests: NWVIEW="blocks detail" plays at that screen size and detail)+ const char *v = getenv("NWVIEW");+ screenblocks = atoi(v);+ detailLevel = strchr(v, ' ') ? atoi(strchr(v, ' ')) : 0;+ M_NwViewLoaded();+ }+#endifif (nw_warp){// (tests: straight into a level, on Ultra-Violence)diff --git a/games/doom/src/doom/m_menu.c b/games/doom/src/doom/m_menu.cindex ac7ddb2f..010d560b 100644--- a/games/doom/src/doom/m_menu.c+++ b/games/doom/src/doom/m_menu.c@@ -395,13 +395,12 @@ enum#endifendgame,messages,-#if !DOOM_TINY+#if !DOOM_TINY || NUMWORKSdetail,scrnsize,option_empty1,#endif#if NUMWORKS- nw_bright,nw_keys,nw_cheats,nw_more,@@ -423,7 +422,7 @@ static const menuitem_t OptionsMenu[]=#endif{1,VPATCH_NAME(M_ENDGAM),'e', M_EndGame},{1,VPATCH_NAME(M_MESSG), 'm',M_ChangeMessages},-#if !DOOM_TINY+#if !DOOM_TINY || NUMWORKS{1,VPATCH_NAME(M_DETAIL),'g', M_ChangeDetail},{2,VPATCH_NAME(M_SCRNSZ),'s', M_SizeDisplay},{-1,VPATCH_NAME_INVALID,'\0',0},@@ -433,7 +432,6 @@ static const menuitem_t OptionsMenu[]={-1,VPATCH_NAME_INVALID,'\0',0},#endif#if NUMWORKS- {2,VPATCH_NAME_INVALID,'b', M_NwBrightness},{1,VPATCH_NAME_INVALID,'k', M_NwKeys},{1,VPATCH_NAME_INVALID,'c', M_NwCheats},{1,VPATCH_NAME_INVALID,'o', M_NwMore},@@ -1300,14 +1298,15 @@ void M_DrawOptions(void)10, mouseSensitivity);#endif-#if !DOOM_TINY+#if !DOOM_TINY || NUMWORKSM_DrawThermo(OptionsDef.x,OptionsDef.y+LINEHEIGHT*(scrnsize+1),9,screenSize);#endif#if NUMWORKS{- static const char *const levels[] = {"OFF", "1", "2", "3", "4"};- M_NwLine(&OptionsDef, nw_bright, "BRIGHTNESS", levels[usegamma]);+ static const vpatch_handle_large_t detailPatches[2] = {VPATCH_NAME(M_GDHIGH), VPATCH_NAME(M_GDLOW)};+ V_DrawPatchDirect(OptionsDef.x + 175, OptionsDef.y + LINEHEIGHT * detail,+ VPATCH_HANDLE(detailPatches[detailLevel]));M_NwLine(&OptionsDef, nw_keys, "KEYS", NULL);M_NwLine(&OptionsDef, nw_cheats, "CHEATS", NULL);M_NwLine(&OptionsDef, nw_more, "MORE OPTIONS", NULL);@@ -2180,7 +2179,7 @@ boolean M_Responder (event_t* ev)// F-Keysif (!menuactive){-#if !DOOM_TINY+#if !DOOM_TINY || NUMWORKSif (key == key_menu_decscreen) // Screen size down{if (automapactive || chat_on)@@ -2238,7 +2237,7 @@ boolean M_Responder (event_t* ev)S_StartUnpositionedSound( sfx_swtchn);return true;}-#if !DOOM_TINY+#if !DOOM_TINY || NUMWORKSelse if (key == key_menu_detail) // Detail toggle{M_ChangeDetail(0);diff --git a/games/doom/src/doom/r_bsp.c b/games/doom/src/doom/r_bsp.cindex f638fea1..499dfee0 100644--- a/games/doom/src/doom/r_bsp.c+++ b/games/doom/src/doom/r_bsp.c@@ -295,8 +295,8 @@ void R_AddLine(seg_t *line) {// but not necessarily visible.angle1 = (angle1 + ANG90) >> ANGLETOFINESHIFT;angle2 = (angle2 + ANG90) >> ANGLETOFINESHIFT;- x1 = viewangletox[angle1];- x2 = viewangletox[angle2];+ x1 = viewangletox_at(angle1);+ x2 = viewangletox_at(angle2);// Does not cross a pixel?if (x1 == x2)@@ -444,8 +444,8 @@ boolean R_CheckBBox(const node_coord_t *bspcoord) {// (adjacent pixels are touching).angle1 = (angle1 + ANG90) >> ANGLETOFINESHIFT;angle2 = (angle2 + ANG90) >> ANGLETOFINESHIFT;- sx1 = viewangletox[angle1];- sx2 = viewangletox[angle2];+ sx1 = viewangletox_at(angle1);+ sx2 = viewangletox_at(angle2);// Does not cross a pixel.if (sx1 == sx2)diff --git a/games/doom/src/doom/r_main.c b/games/doom/src/doom/r_main.cindex 671e9bdd..30d7790d 100644--- a/games/doom/src/doom/r_main.c+++ b/games/doom/src/doom/r_main.c@@ -115,7 +115,8 @@ isb_int16_t viewangletox[FINEANGLES / 2];// from clipangle to -clipangle.angle_t xtoviewangle[SCREENWIDTH + 1];#else-const uint16_t xtoviewangle_[SCREENWIDTH + 1] = {+#if HOST // (RP2040 Doom's, for the full width: the check, nw_init_texture_mapping)+const uint16_t ref_xtoviewangle_[SCREENWIDTH + 1] = {0x2008, 0x1fe0, 0x1fc0, 0x1fa0, 0x1f80, 0x1f60, 0x1f40, 0x1f18, 0x1ef8, 0x1ed8, 0x1eb0, 0x1e90, 0x1e70, 0x1e48, 0x1e28, 0x1e00,0x1de0, 0x1db8, 0x1d98, 0x1d70, 0x1d50, 0x1d28, 0x1d00, 0x1ce0, 0x1cb8, 0x1c90, 0x1c68, 0x1c48, 0x1c20, 0x1bf8, 0x1bd0, 0x1ba8,0x1b80, 0x1b58, 0x1b30, 0x1b08, 0x1ae0, 0x1ab8, 0x1a90, 0x1a68, 0x1a38, 0x1a10, 0x19e8, 0x19c0, 0x1990, 0x1968, 0x1940, 0x1910,@@ -138,7 +139,7 @@ const uint16_t xtoviewangle_[SCREENWIDTH + 1] = {0xe220, 0xe200, 0xe1d8, 0xe1b8, 0xe190, 0xe170, 0xe150, 0xe128, 0xe108, 0xe0e8, 0xe0c0, 0xe0a0, 0xe080, 0xe060, 0xe040, 0xe020,0xdff8,};-const int16_t viewangletox[FINEANGLES / 2] = {+const int16_t ref_viewangletox[FINEANGLES / 2] = {0x0140, 0x0140, 0x0140, 0x0140, 0x0140, 0x0140, 0x0140, 0x0140, 0x0140, 0x0140, 0x0140, 0x0140, 0x0140, 0x0140, 0x0140, 0x0140,0x0140, 0x0140, 0x0140, 0x0140, 0x0140, 0x0140, 0x0140, 0x0140, 0x0140, 0x0140, 0x0140, 0x0140, 0x0140, 0x0140, 0x0140, 0x0140,0x0140, 0x0140, 0x0140, 0x0140, 0x0140, 0x0140, 0x0140, 0x0140, 0x0140, 0x0140, 0x0140, 0x0140, 0x0140, 0x0140, 0x0140, 0x0140,@@ -398,6 +399,7 @@ const int16_t viewangletox[FINEANGLES / 2] = {};#endif+#endif#if !USE_LIGHTMAP_INDEXESconst lighttable_t* scalelight[LIGHTLEVELS][MAXLIGHTSCALE];@@ -819,11 +821,65 @@ void R_InitTables(void) {}+#if NUMWORKS+// the view's tables for its size (vanilla's R_InitTextureMapping and R_ExecuteSetViewSize): viewangletox is+// worked out when it is needed rather than kept (8 KB)+static fixed_t nw_focallength;+uint16_t xtoviewangle_[SCREENWIDTH + 1];+uint16_t _distscale[SCREENWIDTH];++static int nw_viewangletox_raw(int i) {+ fixed_t tangent = finetangent(i);+ int t;+ if (tangent > FRACUNIT * 2)+ t = -1;+ else if (tangent < -FRACUNIT * 2)+ t = viewwidth + 1;+ else {+ t = FixedMul(tangent, nw_focallength);+ t = (centerxfrac - t + FRACUNIT - 1) >> FRACBITS;+ if (t < -1)+ t = -1;+ else if (t > viewwidth + 1)+ t = viewwidth + 1;+ }+ return t;+}++// (with the fencepost cases taken out)+int nw_viewangletox(int i) {+ int t = nw_viewangletox_raw(i);+ return t == -1 ? 0 : t == viewwidth + 1 ? viewwidth : t;+}++static void nw_init_texture_mapping(void) {+ nw_focallength = FixedDiv(centerxfrac, finetangent(FINEANGLES / 4 + FIELDOFVIEW / 2));+ // xtoviewangle: the smallest view angle that maps to x (the first i with viewangletox[i] <= x)+ int i = 0;+ for (int x = viewwidth; x >= 0; x--) {+ while (nw_viewangletox_raw(i) > x)+ i++;+ xtoviewangle_[x] = (uint16_t)(((angle_t)i << ANGLETOFINESHIFT) - ANG90 >> 16);+ }+#if HOST+ // (the full width's are RP2040 Doom's, worked out the same way)+ if (viewwidth == SCREENWIDTH) {+ for (int x = 0; x <= SCREENWIDTH; x++)+ if (xtoviewangle_[x] != ref_xtoviewangle_[x]) I_Error("xtoviewangle %d", x);+ for (int j = 0; j < FINEANGLES / 2; j++)+ if (nw_viewangletox(j) != ref_viewangletox[j]) I_Error("viewangletox %d", j);+ }+#endif+}+#endif+//// R_InitTextureMapping//void R_InitTextureMapping(void) {-#if !FIXED_SCREENWIDTH+#if NUMWORKS+ nw_init_texture_mapping();+#elif !FIXED_SCREENWIDTHint i;int x;int t;@@ -950,7 +1006,7 @@ void R_InitLightTables(void) {// The change will take effect next refresh.//boolean setsizeneeded;-#if !DOOM_TINY+#if !DOOM_TINY || NUMWORKSint setblocks;int setdetail;#else@@ -964,7 +1020,7 @@ R_SetViewSize(int blocks,int detail) {setsizeneeded = true;-#if !DOOM_TINY+#if !DOOM_TINY || NUMWORKSsetblocks = blocks;setdetail = detail;#endif@@ -1041,6 +1097,20 @@ void R_ExecuteSetViewSize(void) {cosadj = abs(finecosine(xtoviewangle[i] >> ANGLETOFINESHIFT));_distscale[i] = FixedDiv(FRACUNIT, cosadj);}+#elif NUMWORKS+ // (between 1 and 1.5: kept without its integer part)+ for (i = 0; i < viewwidth; i++) {+ cosadj = abs(finecosine(x_to_viewangle(i) >> ANGLETOFINESHIFT));+ fixed_t d = FixedDiv(FRACUNIT, cosadj);+#if HOST+ extern const uint16_t ref_distscale[SCREENWIDTH];+ if (viewwidth == SCREENWIDTH && (d >> 16 != 1 || (uint16_t)d != ref_distscale[i])) I_Error("distscale %d", i);+#endif+ _distscale[i] = (uint16_t)d;+ }+ // the view's place on the screen (vanilla's R_InitBuffer)+ viewwindowx = (SCREENWIDTH - scaledviewwidth) >> 1;+ viewwindowy = scaledviewwidth == SCREENWIDTH ? 0 : (SCREENHEIGHT - 32 - viewheight) >> 1; // (32: the status bar)#endif// Calculate the light levels to usediff --git a/games/doom/src/doom/r_plane.c b/games/doom/src/doom/r_plane.cindex 1f400e19..fc15bc1e 100644--- a/games/doom/src/doom/r_plane.c+++ b/games/doom/src/doom/r_plane.c@@ -94,7 +94,7 @@ int8_t *planezlight;#endiffixed_t planeheight;-#if !DOOM_TINY+#if !DOOM_TINY || NUMWORKSfixed_t yslope[SCREENHEIGHT];#elsefixed_t yslope[MAIN_VIEWHEIGHT];@@ -104,7 +104,8 @@ fixed_t _distscale[SCREENWIDTH];#elsestatic_assert(SCREENWIDTH == 320, "");#define DC(x) ((((x)>>16)==1)?(x)&0xffffu:0xffffffff)-const uint16_t _distscale[SCREENWIDTH] = {+#if HOST // (RP2040 Doom's, for the full width: the check in R_ExecuteSetViewSize)+const uint16_t ref_distscale[SCREENWIDTH] = {DC(0x00016a75), DC(0x00016912), DC(0x000167fa), DC(0x000166e4), DC(0x000165d0), DC(0x000164bf), DC(0x000163b0), DC(0x00016262), DC(0x00016158), DC(0x00016052), DC(0x00015f0b), DC(0x00015e0b), DC(0x00015d0b), DC(0x00015bce), DC(0x00015ad6), DC(0x0001599f),DC(0x000158ab), DC(0x0001577c), DC(0x0001568b), DC(0x00015561), DC(0x00015475), DC(0x00015353), DC(0x00015232), DC(0x0001514e), DC(0x00015034), DC(0x00014f1b), DC(0x00014e08), DC(0x00014d2d), DC(0x00014c1d), DC(0x00014b13), DC(0x00014a0a), DC(0x00014902),DC(0x00014800), DC(0x000146ff), DC(0x00014601), DC(0x00014506), DC(0x0001440d), DC(0x00014319), DC(0x00014226), DC(0x00014136), DC(0x00014018), DC(0x00013f2d), DC(0x00013e46), DC(0x00013d60), DC(0x00013c50), DC(0x00013b70), DC(0x00013a91), DC(0x0001398b),@@ -127,6 +128,7 @@ const uint16_t _distscale[SCREENWIDTH] = {DC(0x0001586e), DC(0x00015963), DC(0x00015a97), DC(0x00015b90), DC(0x00015ccc), DC(0x00015dcb), DC(0x00015ecc), DC(0x00016010), DC(0x00016115), DC(0x0001621f), DC(0x0001636d), DC(0x0001647b), DC(0x0001658c), DC(0x0001669e), DC(0x000167b3), DC(0x000168cc),};#endif+#endiffixed_t basexscale;fixed_t baseyscale;diff --git a/games/doom/src/doom/r_plane.h b/games/doom/src/doom/r_plane.hindex 7d007181..ea836eef 100644--- a/games/doom/src/doom/r_plane.h+++ b/games/doom/src/doom/r_plane.h@@ -43,13 +43,21 @@ extern floor_ceiling_clip_t ceilingclip[SCREENWIDTH];#if !DOOM_TINYextern fixed_t yslope[SCREENHEIGHT];#else+#if NUMWORKS+extern fixed_t yslope[SCREENHEIGHT];+#elseextern fixed_t yslope[MAIN_VIEWHEIGHT];#endif+#endif#if !FIXED_SCREENWIDTHextern fixed_t _distscale[SCREENWIDTH];#define distscale(x) _distscale[x]#else+#if NUMWORKS+extern uint16_t _distscale[SCREENWIDTH];+#elseextern const uint16_t _distscale[SCREENWIDTH];+#endif#define distscale(x) (_distscale[x] | (fixed_t)0x10000)#endifextern fixed_t basexscale;diff --git a/games/doom/src/doom/r_state.h b/games/doom/src/doom/r_state.hindex 08f56f77..95f84e67 100644--- a/games/doom/src/doom/r_state.h+++ b/games/doom/src/doom/r_state.h@@ -207,8 +207,15 @@ extern player_t* viewplayer;extern isb_int16_t viewangletox[FINEANGLES/2];extern angle_t xtoviewangle[SCREENWIDTH+1];#define x_to_viewangle(x) xtoviewangle[x]+#define viewangletox_at(i) viewangletox[i]+#elif NUMWORKS+int nw_viewangletox(int i);+#define viewangletox_at(i) nw_viewangletox(i)+extern uint16_t xtoviewangle_[SCREENWIDTH+1];+#define x_to_viewangle(x) ((angle_t)xtoviewangle_[x] << 16)#elseextern const int16_t viewangletox[FINEANGLES/2];+#define viewangletox_at(i) viewangletox[i]extern const uint16_t xtoviewangle_[SCREENWIDTH+1];#define x_to_viewangle(x) (xtoviewangle_[x] << 16)#endifdiff --git a/games/doom/src/doom/st_stuff.c b/games/doom/src/doom/st_stuff.cindex 93673dbc..c37c1aa2 100644--- a/games/doom/src/doom/st_stuff.c+++ b/games/doom/src/doom/st_stuff.c@@ -809,6 +809,10 @@ void ST_drawWidgets(boolean refresh)void ST_doRefresh(boolean refresh){+#if NUMWORKS+ if (!st_statusbaron)+ return; // (the full screen view)+#endif#if !DOOM_TINYst_firsttime = false;diff --git a/games/doom/src/doom1.whx b/games/doom/src/doom1.whxindex 98f26f76..c3339691 100644Binary files a/games/doom/src/doom1.whx and b/games/doom/src/doom1.whx differdiff --git a/games/doom/src/nw/nw.h b/games/doom/src/nw/nw.hindex f0909e2b..73e0ea65 100644--- a/games/doom/src/nw/nw.h+++ b/games/doom/src/nw/nw.h@@ -61,6 +61,7 @@ boolean nw_resume_ready(void);void nw_resume_save(void); /* the game as it is now, if there is one to keep */void nw_resume_done(void); /* the moment was read back: it goes */void nw_settings_load(void);+void M_NwViewLoaded(void); /* m_menu.c: the loaded screen size and detail take effect */void nw_settings_save(void);extern boolean nw_first_start; /* no settings yet: the first game starts with a word on the keys */#endifdiff --git a/games/doom/src/nw/nw_back.inc b/games/doom/src/nw/nw_back.incindex b6958755..3f262a77 100644--- a/games/doom/src/nw/nw_back.inc+++ b/games/doom/src/nw/nw_back.inc@@ -132,8 +132,8 @@ static void nw_pass_start() {// (its texture position worked out at its start, as R_MapPlane does)#define nw_vbit (nw_shared.band.vbit)-static int8_t nw_carry_plane[MAIN_VIEWHEIGHT];-static int16_t nw_carry_start[MAIN_VIEWHEIGHT];+static int8_t nw_carry_plane[SCREENHEIGHT];+static int16_t nw_carry_start[SCREENHEIGHT];// (right to left: the carries at the left edge of each band but the first, worked out first, from the left)#define nw_edge_plane (nw_shared.band.edge_plane)#define nw_edge_start (nw_shared.band.edge_start)@@ -163,7 +163,7 @@ static void nw_plane_runs(int x0, int x1, bool draw) {memset(visplane_heads, -1, numvisplanes * sizeof(visplane_heads[0]));nw_flat_run_count = 0;}- for (int y = 0; y < viewheight && y < MAIN_VIEWHEIGHT; y++) {+ for (int y = 0; y < viewheight; y++) {const uint8_t *vb = nw_vbit + y * (NW_BAND_W / 8);const uint8_t *row = render_frame_buffer + y * NW_STRIDE;int carry_plane = nw_carry_plane[y];@@ -203,14 +203,29 @@ static void nw_plane_runs(int x0, int x1, bool draw) {if (draw && nw_flat_run_count) nw_flush_planes(numvisplanes);}+// the view's columns in the screen's columns x0 to x1 (low detail: one for each two)+static void nw_view_cols(int x0, int x1, int *v0, int *v1) {+ int a = (x0 - viewwindowx) >> detailshift, b = (x1 - viewwindowx) >> detailshift;+ *v0 = a < 0 ? 0 : a > viewwidth ? viewwidth : a;+ *v1 = b < 0 ? 0 : b > viewwidth ? viewwidth : b;+}++// where the band's view pixels go: in place, or in low detail at the band's left, to be doubled+static uint8_t *nw_view_buffer(uint8_t *band, int x0, int v0) {+ return band + viewwindowy * NW_STRIDE + (detailshift ? -v0 : viewwindowx - x0);+}+// before drawing right to left: each band's carries from its left neighbour, worked out left to rightstatic void nw_plane_edges(uint8_t *band) {memset(nw_carry_plane, -1, sizeof nw_carry_plane);for (int k = 0; k < SCREENWIDTH / NW_BAND_W - 1; k++) {- int x0 = k * NW_BAND_W;- render_frame_buffer = band - x0;- nw_mark_planes(x0, x0 + NW_BAND_W);- nw_plane_runs(x0, x0 + NW_BAND_W, false);+ int v0, v1;+ nw_view_cols(k * NW_BAND_W, (k + 1) * NW_BAND_W, &v0, &v1);+ if (v0 < v1) {+ render_frame_buffer = nw_view_buffer(band, k * NW_BAND_W, v0);+ nw_mark_planes(v0, v1);+ nw_plane_runs(v0, v1, false);+ }memcpy(nw_edge_plane[k], nw_carry_plane, sizeof nw_carry_plane);memcpy(nw_edge_start[k], nw_carry_start, sizeof nw_carry_start);}@@ -334,14 +349,18 @@ static void nw_draw_splash(int patch_num, int x0, int x1) {}}-// a flat tiled over the band (behind the ending's text, and darker behind the keys page)-static void nw_tile_flat(const char *name, int x0, int x1, int light = 0) {+// a flat's pixels, decoded if they are not kept (flat[x * 64 + y])+static const uint8_t *nw_flat(const char *name) {int flatnum = W_GetNumForName(name) - firstflat;- uint8_t *flat_data = nullptr;for (int slot = 0; slot < cached_flat_slots; slot++) {- if (FLAT_SLOT_PIC(slot) == flatnum) flat_data = FLAT_SLOT_ADDR(slot);+ if (FLAT_SLOT_PIC(slot) == flatnum) return FLAT_SLOT_ADDR(slot);}- if (!flat_data) flat_data = decode_flat_to_slot(0, flatnum);+ return decode_flat_to_slot(0, flatnum);+}++// a flat tiled over the band (behind the ending's text, and darker behind the keys page)+static void nw_tile_flat(const char *name, int x0, int x1, int light = 0) {+ const uint8_t *flat_data = nw_flat(name);const lighttable_t *map = light ? xcolormaps + 256 * light : nullptr;for (int y = 0; y < SCREENHEIGHT; y++) {uint8_t *dest = render_frame_buffer + y * NW_STRIDE;@@ -431,6 +450,50 @@ static void nw_draw_view(int x0, int x1) {nw_draw_masked();}+// low detail: the view's columns v0 to v1, drawn at the band's left, each made two of the screen's (as+// R_DrawColumnLow and R_DrawSpanLow draw them), from the right so that none is written over before it is read+static void nw_double_columns(uint8_t *band, int x0, int v0, int v1) {+ for (int y = 0; y < viewheight; y++) {+ uint8_t *row = band + (viewwindowy + y) * NW_STRIDE;+ for (int v = v1 - 1; v >= v0; v--) {+ uint8_t *d = row + viewwindowx + 2 * v - x0;+ d[0] = d[1] = row[v - v0];+ }+ }+}++// the smaller screen sizes: vanilla's R_FillBackScreen, a flat around the view (the bevel's patches are drawn+// with the others, pd_end_frame)+static void nw_draw_border(int x0, int x1) {+ const uint8_t *flat_data = nw_flat(gamemode == commercial ? "GRNROCK" : "FLOOR7_2");+ int l = viewwindowx, r = viewwindowx + scaledviewwidth;+ for (int y = 0; y < SCREENHEIGHT - ST_HEIGHT; y++) {+ uint8_t *dest = render_frame_buffer + y * NW_STRIDE;+ const uint8_t *src = flat_data + (y & 63);+ bool beside = y >= viewwindowy && y < viewwindowy + viewheight;+ for (int x = x0; x < x1; x++) {+ if (beside && x >= l && x < r) x = r;+ if (x >= x1) break;+ dest[x] = src[(x & 63) * 64];+ }+ }+}++static void nw_draw_bezel() {+ if (scaledviewwidth == SCREENWIDTH) return;+ int n = scaledviewwidth / 8 - 1;+ V_DrawPatchN(viewwindowx, viewwindowy - 8, VPATCH_HANDLE(VPATCH_NAME(BRDR_T)), n);+ V_DrawPatchN(viewwindowx, viewwindowy + viewheight, VPATCH_HANDLE(VPATCH_NAME(BRDR_B)), n);+ for (int y = 0; y < viewheight; y += 8) {+ V_DrawPatch(viewwindowx - 8, viewwindowy + y, VPATCH_HANDLE(VPATCH_NAME(BRDR_L)));+ V_DrawPatch(viewwindowx + scaledviewwidth, viewwindowy + y, VPATCH_HANDLE(VPATCH_NAME(BRDR_R)));+ }+ V_DrawPatch(viewwindowx - 8, viewwindowy - 8, VPATCH_HANDLE(VPATCH_NAME(BRDR_TL)));+ V_DrawPatch(viewwindowx + scaledviewwidth, viewwindowy - 8, VPATCH_HANDLE(VPATCH_NAME(BRDR_TR)));+ V_DrawPatch(viewwindowx - 8, viewwindowy + viewheight, VPATCH_HANDLE(VPATCH_NAME(BRDR_BL)));+ V_DrawPatch(viewwindowx + scaledviewwidth, viewwindowy + viewheight, VPATCH_HANDLE(VPATCH_NAME(BRDR_BR)));+}+static void nw_draw_band(uint8_t *band, int x0, int x1, bool view, int help, bool strips) {nw_band_x0 = x0;nw_band_x1 = x1;@@ -443,25 +506,39 @@ static void nw_draw_band(uint8_t *band, int x0, int x1, bool view, int help, booAM_Drawer();nw_direct = false;} else {- if (strips) {- // this band's view: the BSP pass again, its columns alone kept- pd_begin_frame();- nw_strip_x0 = x0;- nw_strip_x1 = x1;- R_RenderPlayerView(&players[displayplayer]);- render_frame_buffer = band - x0;- nw_flats_ready();- if (nw_overflowed) {- // (not even the band's pieces all found room: what has none is left black)- for (int y = 0; y < viewheight; y++) memset(render_frame_buffer + y * NW_STRIDE + x0, 0, x1 - x0);+ // (the view's own columns: nw_band_x0 and nw_band_x1 are those while it is drawn)+ int v0, v1;+ nw_view_cols(x0, x1, &v0, &v1);+ if (v0 < v1) {+ uint8_t *vbuf = nw_view_buffer(band, x0, v0);+ nw_band_x0 = v0;+ nw_band_x1 = v1;+ render_frame_buffer = vbuf;+ if (strips) {+ // this band's view: the BSP pass again, its columns alone kept+ pd_begin_frame();+ nw_strip_x0 = v0;+ nw_strip_x1 = v1;+ R_RenderPlayerView(&players[displayplayer]);+ render_frame_buffer = vbuf;+ nw_flats_ready();+ if (nw_overflowed) {+ // (not even the band's pieces all found room: what has none is left black)+ for (int y = 0; y < viewheight; y++) memset(vbuf + y * NW_STRIDE + v0, 0, v1 - v0);+ }+ // (the fuzz of the sprites, the same as in the first pass, is where that pass's count left it)+ nw_strips++;}- // (the fuzz of the sprites, the same as in the first pass, is where that pass's count left it)- nw_strips++;+ nw_scratch_base = render_col_count;+ nw_draw_view(v0, v1);+ nw_strip_x0 = 0;+ nw_strip_x1 = SCREENWIDTH;+ if (detailshift) nw_double_columns(band, x0, v0, v1);+ nw_band_x0 = x0;+ nw_band_x1 = x1;+ render_frame_buffer = band - x0;}- nw_scratch_base = render_col_count;- nw_draw_view(x0, x1);- nw_strip_x0 = 0;- nw_strip_x1 = SCREENWIDTH;+ if (scaledviewwidth != SCREENWIDTH) nw_draw_border(x0, x1);if (automapactive) {// (the map over the view)nw_direct = true;@@ -469,7 +546,8 @@ static void nw_draw_band(uint8_t *band, int x0, int x1, bool view, int help, boonw_direct = false;}}- for (int y = viewheight; y < SCREENHEIGHT; y++) memset(render_frame_buffer + y * NW_STRIDE + x0, 0, x1 - x0);+ int below = scaledviewwidth == SCREENWIDTH ? viewheight : SCREENHEIGHT - ST_HEIGHT;+ for (int y = below; y < SCREENHEIGHT; y++) memset(render_frame_buffer + y * NW_STRIDE + x0, 0, x1 - x0);} else {nw_draw_background(x0, x1, help);if (gamestate == GS_FINALE && finalestage == F_STAGE_TEXT && !help) {@@ -610,8 +688,9 @@ void pd_end_frame(int wipe_start) {// what is drawn over the picture, gathered oncenw_patches[0].header.max = count_of(nw_patches) - 1;V_BeginPatchList(nw_patches);+ if (view3d) nw_draw_bezel();if (!help) {- if (gamestate == GS_LEVEL) ST_Drawer(false, true);+ if (gamestate == GS_LEVEL) ST_Drawer(viewheight == SCREENHEIGHT, true);else if (gamestate == GS_INTERMISSION) WI_Drawer();} else if (gamestate == GS_LEVEL) {ST_doPaletteStuff();diff --git a/games/doom/src/nw/nw_menu.inc b/games/doom/src/nw/nw_menu.incindex 5975154a..0e2b5f5d 100644--- a/games/doom/src/nw/nw_menu.inc+++ b/games/doom/src/nw/nw_menu.inc@@ -205,12 +205,20 @@ static void M_NwCheats(int choice)}// ---------------------------------------------------------------- more-enum { more_overlay, more_secrets, more_sync, more_end };+enum { more_bright, more_overlay, more_secrets, more_sync, more_end };++// (the settings loaded: the screen size and detail they have)+void M_NwViewLoaded(void)+{+ screenSize = screenblocks - 3;+ R_SetViewSize(screenblocks, detailLevel);+}static void M_NwMoreItem(int choice){switch (itemOn){+ case more_bright: M_NwBrightness(choice); break;case more_overlay: nw_map_overlay = !nw_map_overlay; break;case more_secrets: nw_map_secrets = !nw_map_secrets; break;case more_sync:@@ -226,19 +234,22 @@ static void M_NwMoreItem(int choice)}static const menuitem_t MoreMenu[] = {+ {2, VPATCH_NAME_INVALID, 'b', M_NwMoreItem},{2, VPATCH_NAME_INVALID, 'm', M_NwMoreItem},{2, VPATCH_NAME_INVALID, 's', M_NwMoreItem},{2, VPATCH_NAME_INVALID, 'r', M_NwMoreItem},};static void M_DrawNwMore(void);-menu_t MoreDef = {more_end, &OptionsDef, MoreMenu, M_DrawNwMore, 40, 50, 0};+menu_t MoreDef = {more_end, &OptionsDef, MoreMenu, M_DrawNwMore, 40, 40, 0};static void M_DrawNwMore(void){static const char *const sync[] = {"LEFT TO RIGHT", "RIGHT TO LEFT", "NONE"};+ static const char *const levels[] = {"OFF", "1", "2", "3", "4"};nw_value_x = 150;M_NwTitle("MORE OPTIONS");+ M_NwLine(&MoreDef, more_bright, "BRIGHTNESS", levels[usegamma]);M_NwLine(&MoreDef, more_overlay, "MAP OVER THE VIEW", nw_map_overlay ? "ON" : "OFF");M_NwLine(&MoreDef, more_secrets, "SECRETS ON THE MAP", nw_map_secrets ? "PURPLE" : "OFF");M_NwLine(&MoreDef, more_sync, "SCREEN REFRESH", sync[nw_sync_off ? 2 : nw_scan_right_to_left]);diff --git a/games/doom/src/nw/saves.c b/games/doom/src/nw/saves.cindex 6832a55d..a10a85fe 100644--- a/games/doom/src/nw/saves.c+++ b/games/doom/src/nw/saves.c@@ -158,9 +158,11 @@ void nw_resume_done(void) {boolean nw_first_start;/* 'D', the version (2), messages, brightness, the map over the view, secrets on the map, the screen's refresh- * (left to right, right to left, none), then each calculator key's action (NK_COUNT of them) */-#define CFG_LEN (7 + NK_COUNT)+ * (left to right, right to left, none), the detail, the screen size, then each calculator key's action (NK_COUNT+ * of them) */+#define CFG_LEN (9 + NK_COUNT)extern int nw_map_overlay, nw_map_secrets, nw_scan_right_to_left, nw_sync_off;+extern isb_int8_t detailLevel, screenblocks;void nw_settings_load(void) {uint32_t len;@@ -174,13 +176,17 @@ void nw_settings_load(void) {nw_map_secrets = d[5] != 0;nw_scan_right_to_left = d[6] == 1;nw_sync_off = d[6] == 2;- for (int k = 0; k < NK_COUNT; k++) nw_binding[k] = d[7 + k] < NA_COUNT ? d[7 + k] : NA_NONE;+ detailLevel = d[7] == 1;+ screenblocks = d[8] >= 3 && d[8] <= 11 ? d[8] : 10;+ for (int k = 0; k < NK_COUNT; k++) nw_binding[k] = d[9 + k] < NA_COUNT ? d[9 + k] : NA_NONE;+ M_NwViewLoaded();}void nw_settings_save(void) {uint8_t d[CFG_LEN] = {'D', 2, (uint8_t)showMessages, (uint8_t)usegamma, (uint8_t)nw_map_overlay,- (uint8_t)nw_map_secrets, (uint8_t)(nw_sync_off ? 2 : nw_scan_right_to_left)};- memcpy(d + 7, nw_binding, NK_COUNT);+ (uint8_t)nw_map_secrets, (uint8_t)(nw_sync_off ? 2 : nw_scan_right_to_left),+ (uint8_t)detailLevel, (uint8_t)screenblocks};+ memcpy(d + 9, nw_binding, NK_COUNT);uint32_t len;const uint8_t *old = plat_load(CFG_NAME, &len);if (old && len == sizeof d && !memcmp(old, d, sizeof d)) return;diff --git a/games/doom/src/pd_render.cpp b/games/doom/src/pd_render.cppindex 4da9d1bb..9df78260 100644--- a/games/doom/src/pd_render.cpp+++ b/games/doom/src/pd_render.cpp@@ -421,9 +421,9 @@ static union {struct {int16_t bidx[NW_BATCH], blink[NW_BATCH];flat_run flat_runs[NW_FLAT_RUNS];- uint8_t vbit[(NW_BAND_W / 8) * MAIN_VIEWHEIGHT];- int8_t edge_plane[SCREENWIDTH / NW_BAND_W - 1][MAIN_VIEWHEIGHT];- int16_t edge_start[SCREENWIDTH / NW_BAND_W - 1][MAIN_VIEWHEIGHT];+ uint8_t vbit[(NW_BAND_W / 8) * SCREENHEIGHT];+ int8_t edge_plane[SCREENWIDTH / NW_BAND_W - 1][SCREENHEIGHT];+ int16_t edge_start[SCREENWIDTH / NW_BAND_W - 1][SCREENHEIGHT];} band;} nw_shared;extern "C" { uint8_t (*const nw_plane_used)[SCREENWIDTH / 8] = nw_shared.plane_used; }diff --git a/games/doom/src/whddata.h b/games/doom/src/whddata.hindex 358b220b..83ddbf1a 100644--- a/games/doom/src/whddata.h+++ b/games/doom/src/whddata.h@@ -512,7 +512,17 @@ enum vpatch_type {VPATCH_NAME(END3), \VPATCH_NAME(END4), \VPATCH_NAME(END5), \- VPATCH_NAME(END6)+ VPATCH_NAME(END6), \+ VPATCH_NAME(M_GDHIGH), \+ VPATCH_NAME(M_GDLOW), \+ VPATCH_NAME(BRDR_T), \+ VPATCH_NAME(BRDR_B), \+ VPATCH_NAME(BRDR_L), \+ VPATCH_NAME(BRDR_R), \+ VPATCH_NAME(BRDR_TL), \+ VPATCH_NAME(BRDR_TR), \+ VPATCH_NAME(BRDR_BL), \+ VPATCH_NAME(BRDR_BR)// note we must include intermediate flats even if not directly references (since we deal with consecutive ranges)#define NAMED_FLAT_LIST \diff --git a/games/doom/tools/whd_gen/whd_gen.cpp b/games/doom/tools/whd_gen/whd_gen.cppindex db13b200..3efb6ed0 100644--- a/games/doom/tools/whd_gen/whd_gen.cpp+++ b/games/doom/tools/whd_gen/whd_gen.cpp@@ -164,6 +164,8 @@ static std::vector<std::string> named_lumps = {"INTERPIC","VICTORY2","BOSSBACK",+ "FLOOR7_2", // (the border of the smaller screen sizes)+ "GRNROCK","FLOOR4_8","SFLR6_1","MFLR8_4",@@ -566,6 +568,14 @@ static std::vector<std::string> run16_misc_vpatches = {// remaining <64 color graphics ... these are encoded as "pixel runs" for rendering speedstatic std::vector<std::string> run64_misc_vpatches = {+ "BRDR_T",+ "BRDR_B",+ "BRDR_L",+ "BRDR_R",+ "BRDR_TL",+ "BRDR_TR",+ "BRDR_BL",+ "BRDR_BR","M_SKULL1","M_SKULL2","M_THERMO",@@ -5063,12 +5073,7 @@ int main(int argc, const char **argv) {name_required.insert(e.second.name);}}- for (auto &e : wad.get_lumps()) {- if (e.second.name.length() > 4 && e.second.name.substr(0, 4) == "BRDR") {- touched[e.first] = TOUCHED_UNUSED_GRAPHIC;- e.second.data.clear();- }- }+ // (the BRDR_ patches are kept: the calculator has vanilla's smaller screen sizes and their border)int total_size = 0;std::vector<std::string> level_data = {"THINGS", "LINEDEFS", "SIDEDEFS", "VERTEXES", "SEGS", "SSECTORS", "NODES", "SECTORS", "REJECT",