Skip to content

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.

Doom: keys for any action, Use on Back, menu on EXE, options for brightness, keys, cheats, map overlay

Mason363db90aa206257
diff --git a/games/doom/src/doom/am_map.c b/games/doom/src/doom/am_map.c
index abc40d09..95070fea 100644
--- a/games/doom/src/doom/am_map.c
+++ b/games/doom/src/doom/am_map.c
@@ -83,6 +83,10 @@
#define THINGCOLORS GREENS
#define THINGRANGE GREENRANGE
#define SECRETWALLCOLORS WALLCOLORS
+#if NUMWORKS
+// (the options: secret doors and the edges of secret places in purple, until they are found)
+#define NW_SECRETCOLOR 252
+#endif
#define SECRETWALLRANGE WALLRANGE
#define GRIDCOLORS (GRAYS + GRAYSRANGE/2)
#define GRIDRANGE 0
@@ -560,8 +564,26 @@ void AM_LevelInit(void)
//
//
//
+#if NUMWORKS
+// the automap over the game view, its black left out (the automap key goes from the view to the map, to the
+// map over the view if the options have it, and back); the options' choices (doom.cfg)
+boolean am_overlay;
+int nw_map_overlay = 1, nw_map_secrets;
+#endif
+
+#if NUMWORKS
+// the Cheats menu's IDDT: the whole map, then the things too, then as it was
+void AM_NwCheat(void)
+{
+ cheating = (cheating + 1) % 3;
+}
+#endif
+
void AM_Stop (void)
{
+#if NUMWORKS
+ am_overlay = false;
+#endif
static event_t st_notify = { 0, ev_keyup, AM_MSGEXITED, 0 };
AM_unloadPics();
@@ -693,9 +715,19 @@ AM_Responder
}
else if (key == key_map_toggle)
{
+#if NUMWORKS
+ if (!am_overlay && nw_map_overlay)
+ {
+ am_overlay = true;
+ viewactive = true;
+ }
+ else
+#endif
+ {
bigstate = 0;
viewactive = true;
AM_Stop ();
+ }
}
else if (key == key_map_maxzoom)
{
@@ -1208,6 +1240,13 @@ void AM_drawWalls(void)
{ // teleporters
AM_drawMline(&l, WALLCOLORS+WALLRANGE/2);
}
+#if NUMWORKS
+ else if (nw_map_secrets && ((line_flags(li) & ML_SECRET) || line_frontsector(li)->special == 9
+ || line_backsector(li)->special == 9))
+ {
+ AM_drawMline(&l, NW_SECRETCOLOR);
+ }
+#endif
else if (line_flags(li) & ML_SECRET) // secret door
{
if (cheating) AM_drawMline(&l, SECRETWALLCOLORS + lightlev);
@@ -1414,6 +1453,9 @@ void AM_Drawer (void)
if (!automapactive) return;
fb = I_VideoBuffer;
+#if NUMWORKS
+ if (!am_overlay)
+#endif
AM_clearFB(BACKGROUND);
if (grid)
AM_drawGrid(GRIDCOLORS);
diff --git a/games/doom/src/doom/am_map.h b/games/doom/src/doom/am_map.h
index 572d2389..8c4e330c 100644
--- a/games/doom/src/doom/am_map.h
+++ b/games/doom/src/doom/am_map.h
@@ -41,6 +41,10 @@ void AM_Drawer (void);
// Called to force the automap to quit
// if the level is completed while it is up.
void AM_Stop (void);
+#if NUMWORKS
+extern boolean am_overlay;
+extern int nw_map_overlay, nw_map_secrets;
+#endif
extern cheatseq_t cheat_amap;
diff --git a/games/doom/src/doom/d_main.c b/games/doom/src/doom/d_main.c
index fa831c23..f2b33ee4 100644
--- a/games/doom/src/doom/d_main.c
+++ b/games/doom/src/doom/d_main.c
@@ -276,7 +276,11 @@ boolean D_Display (void)
// not sure what the reason for not drawing when gametic == 0 (i.e. the first frame of the game), however it means we
// don't draw anything in a network game until the sync is done, which screws up what we see during the wipe. I haven't
// seen any downside to doing the drawing.
+#if NUMWORKS
+ if (gamestate == GS_LEVEL && (!automapactive || am_overlay))
+#else
if (gamestate == GS_LEVEL && !automapactive)
+#endif
#endif
R_RenderPlayerView (&players[displayplayer]);
diff --git a/games/doom/src/doom/g_game.c b/games/doom/src/doom/g_game.c
index 1aef361f..a45147bc 100644
--- a/games/doom/src/doom/g_game.c
+++ b/games/doom/src/doom/g_game.c
@@ -2033,7 +2033,12 @@ void G_DoNewGame(boolean net)
#if NUMWORKS
if (nw_first_start)
{
- players[consoleplayer].message = "OK FIRES, EXE OPENS DOORS, BACK: MENU";
+ // (the keys as they are: the options can change them)
+ static char hint[80];
+ char fire[24], use[24], menu[24];
+ M_snprintf(hint, sizeof hint, "%s FIRES, %s OPENS DOORS, %s: MENU", nw_keys_of(NA_FIRE, fire, 12),
+ nw_keys_of(NA_USE, use, 12), nw_keys_of(NA_MENU, menu, 12));
+ players[consoleplayer].message = hint;
nw_first_start = false;
}
#endif
diff --git a/games/doom/src/doom/m_menu.c b/games/doom/src/doom/m_menu.c
index 157c7d75..ac7ddb2f 100644
--- a/games/doom/src/doom/m_menu.c
+++ b/games/doom/src/doom/m_menu.c
@@ -381,6 +381,10 @@ menu_t NewDef =
+#if NUMWORKS
+#include "nw/nw_menu.inc"
+#endif
+
//
// OPTIONS MENU
//
@@ -396,6 +400,12 @@ enum
scrnsize,
option_empty1,
#endif
+#if NUMWORKS
+ nw_bright,
+ nw_keys,
+ nw_cheats,
+ nw_more,
+#endif
#if !NO_USE_MOUSE
mousesens,
option_empty2,
@@ -422,7 +432,12 @@ static const menuitem_t OptionsMenu[]=
{2,VPATCH_NAME(M_MSENS),'m', M_ChangeSensitivity},
{-1,VPATCH_NAME_INVALID,'\0',0},
#endif
-#if !NUMWORKS
+#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},
+#else
{1,VPATCH_NAME(M_SVOL),'s', M_Sound}
#endif
};
@@ -1005,37 +1020,49 @@ void M_DrawReadThis1(void)
}
#if NUMWORKS
-// the first page of Read This!: the calculator's keys, drawn by the renderer over a flat, band by band
-static const char *const keys_page[][2] = {
- {"UP, DOWN", "WALK FORWARD, BACK"},
- {"LEFT, RIGHT", "TURN"},
- {"OK", "FIRE"},
- {"EXE, BACKSPACE", "USE: DOORS, SWITCHES"},
- {"HOLD SHIFT", "STRAFE WITH LEFT, RIGHT"},
- {"X,N,T VAR", "STRAFE LEFT, RIGHT"},
- {"HOLD ALPHA", "RUN"},
- {"1 TO 7", "WEAPONS"},
- {"TOOLBOX", "AUTOMAP"},
- {" + -", "ZOOM IN, OUT"},
- {" * / 0", "FOLLOW, GRID, WHOLE MAP"},
- {"SQUARE ROOT", "BRIGHTNESS"},
- {"BACK", "MENU AND PAUSE"},
- {"HOME", "KEEP THE MOMENT AND QUIT"},
+// the first page of Read This!: the calculator's keys as they are (the options can change them), drawn by the
+// renderer over a flat, band by band
+static const struct { const char *what; uint8_t actions[4]; } keys_page[] = {
+ {"WALK FORWARD, BACK", {NA_FORWARD, NA_BACKWARD}},
+ {"TURN", {NA_TURNLEFT, NA_TURNRIGHT}},
+ {"FIRE", {NA_FIRE}},
+ {"USE: DOORS, SWITCHES", {NA_USE}},
+ {"STRAFE (HELD)", {NA_STRAFE}},
+ {"STRAFE LEFT, RIGHT", {NA_STRAFELEFT, NA_STRAFERIGHT}},
+ {"RUN (HELD)", {NA_RUN}},
+ {"AUTOMAP", {NA_AUTOMAP}},
+ {"SCREEN SIZE, MAP ZOOM", {NA_BIGGER, NA_SMALLER}},
+ {"MAP: FOLLOW, GRID, ALL", {NA_FOLLOW, NA_GRID, NA_WHOLEMAP}},
+ {"BRIGHTNESS", {NA_GAMMA}},
+ {"QUICK SAVE, LOAD", {NA_QUICKSAVE, NA_QUICKLOAD}},
+ {"TYPE A CHEAT", {NA_CHEAT}},
+ {"MENU (PAUSES)", {NA_MENU}},
};
void M_DrawKeys(void)
{
static const char title[] = "THE CALCULATOR'S KEYS";
- static const char menus[] = "IN MENUS: ARROWS, OK AND BACK";
- int y = 22;
+ static const char weapons[] = "WEAPONS: THEIR NUMBERS. HOME KEEPS THE MOMENT.";
+ static const char menus[] = "IN MENUS: ARROWS, OK, BACK. OPTIONS: KEYS.";
+ int y = 20;
M_WriteText((SCREENWIDTH - M_StringWidth(title)) / 2, 6, title);
- for (unsigned i = 0; i < sizeof(keys_page) / sizeof(keys_page[0]); i++, y += 11)
+ for (unsigned i = 0; i < sizeof(keys_page) / sizeof(keys_page[0]); i++, y += 10)
{
- M_WriteText(20, y, keys_page[i][0]);
- M_WriteText(128, y, keys_page[i][1]);
+ char keys[64], one[32];
+ keys[0] = 0;
+ for (int j = 0; j < 4 && keys_page[i].actions[j]; j++)
+ {
+ nw_keys_of(keys_page[i].actions[j], one, sizeof one);
+ if (!one[0]) continue;
+ if (keys[0]) M_StringConcat(keys, ", ", sizeof keys);
+ M_StringConcat(keys, one, sizeof keys);
+ }
+ M_WriteText(16, y, keys[0] ? keys : "-");
+ M_WriteText(160, y, keys_page[i].what);
}
- M_WriteText(20, y + 6, menus);
+ M_WriteText(16, y + 4, weapons);
+ M_WriteText(16, y + 14, menus);
}
#endif
@@ -1277,6 +1304,15 @@ void M_DrawOptions(void)
M_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]);
+ M_NwLine(&OptionsDef, nw_keys, "KEYS", NULL);
+ M_NwLine(&OptionsDef, nw_cheats, "CHEATS", NULL);
+ M_NwLine(&OptionsDef, nw_more, "MORE OPTIONS", NULL);
+ }
+#endif
}
void M_Options(int choice)
@@ -2273,6 +2309,10 @@ boolean M_Responder (event_t* ev)
// Keys usable within menu
+#if NUMWORKS
+ if (M_NwSide(key))
+ return true;
+#endif
if (key == key_menu_down)
{
// Move down to next item
diff --git a/games/doom/src/nw/i_input.c b/games/doom/src/nw/i_input.c
index ef979633..9fa9b397 100644
--- a/games/doom/src/nw/i_input.c
+++ b/games/doom/src/nw/i_input.c
@@ -1,18 +1,25 @@
/* Doom on the calculator: the keyboard.
*
- * Each calculator key stands for a key of Doom's PC keyboard, pressed and released with it:
- * arrows the arrow keys: walk and turn
- * OK fire (Ctrl); Enter while a menu or a question is up
- * Back the menu (Escape), back one menu (Backspace)
- * backspace use: open doors, press switches (Space)
- * EXE use as well; Enter in menus
- * shift strafe with Left and Right, while held (Alt)
- * alpha run, while held (Shift)
- * x,n,t var strafe left, strafe right (, and .)
- * toolbox the automap (Tab); in it, + and - zoom, x follows, / shows the grid, 0 zooms all the way out
+ * Each calculator key does one of Doom's actions (nw_actions), which it does as the key of Doom's PC
+ * keyboard that does it would: pressed and released with the calculator's key. The keys can be given any
+ * action in the options (Keys); they are kept in doom.cfg. As they come:
+ * arrows walk and turn
+ * OK fire
+ * Back use: open doors, press switches
+ * EXE, backspace the menu (it pauses the game)
+ * shift strafe with Left and Right, while held
+ * alpha run, while held
+ * x,n,t var strafe left, strafe right
+ * toolbox the automap; in it, + and - zoom, x follows, / shows the grid, 0 shows the whole map,
+ * 8 puts a mark, 9 takes them away
* 1 to 7 the weapons
- * sqrt brightness (F11)
- * Home, On/Off keep the moment and quit */
+ * + - the screen bigger, smaller
+ * sqrt brightness
+ * ln, log quick save, quick load
+ * pi pause
+ * Ans type a cheat
+ * Home, On/Off keep the moment and quit
+ * In menus: the arrows, OK and EXE to choose, Back (or backspace) to go back. */
#include <string.h>
#include "doomtype.h"
@@ -22,24 +29,173 @@
#include "i_video.h"
#include "m_controls.h"
#include "doom/doomstat.h"
+#include "doom/d_player.h"
#include "plat.h"
#include "nw.h"
-/* the calculator's keys (eadk_key_*) */
-enum {
- NK_LEFT = 0, NK_UP = 1, NK_DOWN = 2, NK_RIGHT = 3, NK_OK = 4, NK_BACK = 5, NK_HOME = 6, NK_ONOFF = 8,
- NK_SHIFT = 12, NK_ALPHA = 13, NK_XNT = 14, NK_VAR = 15, NK_TOOLBOX = 16, NK_BACKSPACE = 17,
- NK_SQRT = 28, NK_SEVEN = 30, NK_EIGHT = 31, NK_NINE = 32, NK_FOUR = 36, NK_FIVE = 37, NK_SIX = 38,
- NK_MUL = 39, NK_DIV = 40, NK_ONE = 42, NK_TWO = 43, NK_THREE = 44, NK_PLUS = 45, NK_MINUS = 46,
- NK_ZERO = 48, NK_EXE = 52, NK_COUNT = 53
-};
-
int M_BackKey(void);
boolean M_WantsEnter(void);
boolean nw_home;
-static uint8_t sent[NK_COUNT]; /* the Doom key each held key pressed (released with the same one) */
+/* the Doom key each held key pressed (released with the same one), or NW_SENT_NONE for one that pressed none */
+#define NW_SENT_NONE 0x100
+static uint16_t sent[NK_COUNT];
+
+/* ------------------------------------------------------------------ actions */
+const nw_action_t nw_actions[NA_COUNT] = {
+ [NA_NONE] = {"NOTHING", 0},
+ [NA_FORWARD] = {"WALK FORWARD", KEY_UPARROW},
+ [NA_BACKWARD] = {"WALK BACK", KEY_DOWNARROW},
+ [NA_TURNLEFT] = {"TURN LEFT", KEY_LEFTARROW},
+ [NA_TURNRIGHT] = {"TURN RIGHT", KEY_RIGHTARROW},
+ [NA_FIRE] = {"FIRE", KEY_RCTRL},
+ [NA_USE] = {"USE: DOORS, SWITCHES", ' '},
+ [NA_STRAFE] = {"STRAFE (HELD)", KEY_RALT},
+ [NA_RUN] = {"RUN (HELD)", KEY_RSHIFT},
+ [NA_STRAFELEFT] = {"STRAFE LEFT", ','},
+ [NA_STRAFERIGHT] = {"STRAFE RIGHT", '.'},
+ [NA_WEAPON1] = {"FIST, CHAINSAW", '1'},
+ [NA_WEAPON2] = {"PISTOL", '2'},
+ [NA_WEAPON3] = {"SHOTGUN", '3'},
+ [NA_WEAPON4] = {"CHAINGUN", '4'},
+ [NA_WEAPON5] = {"ROCKET LAUNCHER", '5'},
+ [NA_WEAPON6] = {"PLASMA GUN", '6'},
+ [NA_WEAPON7] = {"BFG 9000", '7'},
+ [NA_AUTOMAP] = {"AUTOMAP", KEY_TAB},
+ [NA_MENU] = {"MENU", KEY_ESCAPE},
+ [NA_PAUSE] = {"PAUSE", KEY_PAUSE},
+ [NA_BIGGER] = {"BIGGER; MAP: ZOOM IN", '='},
+ [NA_SMALLER] = {"SMALLER; MAP: ZOOM OUT", '-'},
+ [NA_FOLLOW] = {"MAP: FOLLOW", 'f'},
+ [NA_GRID] = {"MAP: GRID", 'g'},
+ [NA_WHOLEMAP] = {"MAP: WHOLE MAP", '0'},
+ [NA_MARK] = {"MAP: MARK", 'm'},
+ [NA_CLEARMARKS] = {"MAP: CLEAR MARKS", 'c'},
+ [NA_GAMMA] = {"BRIGHTNESS", KEY_F11},
+ [NA_QUICKSAVE] = {"QUICK SAVE", KEY_F6},
+ [NA_QUICKLOAD] = {"QUICK LOAD", KEY_F9},
+ [NA_MESSAGES] = {"MESSAGES ON, OFF", KEY_F8},
+ [NA_DETAIL] = {"DETAIL HIGH, LOW", KEY_F5},
+ [NA_CHEAT] = {"TYPE A CHEAT", 0},
+};
+
+/* the calculator's keys, as the options and Read This! show them ("" for those that are not keys) */
+static const char *const key_names[NK_COUNT] = {
+ [NK_LEFT] = "LEFT", [NK_UP] = "UP", [NK_DOWN] = "DOWN", [NK_RIGHT] = "RIGHT", [NK_OK] = "OK",
+ [NK_BACK] = "BACK", [NK_HOME] = "HOME", [NK_ONOFF] = "ON/OFF", [NK_SHIFT] = "SHIFT", [NK_ALPHA] = "ALPHA",
+ [NK_XNT] = "X,N,T", [NK_VAR] = "VAR", [NK_TOOLBOX] = "TOOLBOX", [NK_BACKSPACE] = "BACKSPACE",
+ [NK_EXP] = "E^X", [NK_LN] = "LN", [NK_LOG] = "LOG", [NK_IMAG] = "I", [NK_COMMA] = "COMMA",
+ [NK_POWER] = "X^Y", [NK_SIN] = "SIN", [NK_COS] = "COS", [NK_TAN] = "TAN", [NK_PI] = "PI",
+ [NK_SQRT] = "SQUARE ROOT", [NK_SQUARE] = "X^2", [NK_SEVEN] = "7", [NK_EIGHT] = "8", [NK_NINE] = "9",
+ [NK_LPAREN] = "(", [NK_RPAREN] = ")", [NK_FOUR] = "4", [NK_FIVE] = "5", [NK_SIX] = "6", [NK_MUL] = "*",
+ [NK_DIV] = "/", [NK_ONE] = "1", [NK_TWO] = "2", [NK_THREE] = "3", [NK_PLUS] = "+", [NK_MINUS] = "-",
+ [NK_ZERO] = "0", [NK_DOT] = ".", [NK_EE] = "X10^X", [NK_ANS] = "ANS", [NK_EXE] = "EXE",
+};
+
+const char *nw_key_name(int k) { return k >= 0 && k < NK_COUNT && key_names[k] ? key_names[k] : ""; }
+boolean nw_key_bindable(int k) { return k >= 0 && k < NK_COUNT && key_names[k] && k != NK_HOME && k != NK_ONOFF; }
+
+uint8_t nw_binding[NK_COUNT];
+
+void nw_bindings_default(void) {
+ static const uint8_t def[][2] = {
+ {NK_UP, NA_FORWARD}, {NK_DOWN, NA_BACKWARD}, {NK_LEFT, NA_TURNLEFT}, {NK_RIGHT, NA_TURNRIGHT},
+ {NK_OK, NA_FIRE}, {NK_BACK, NA_USE}, {NK_EXE, NA_MENU}, {NK_BACKSPACE, NA_MENU},
+ {NK_SHIFT, NA_STRAFE}, {NK_ALPHA, NA_RUN}, {NK_XNT, NA_STRAFELEFT}, {NK_VAR, NA_STRAFERIGHT},
+ {NK_ONE, NA_WEAPON1}, {NK_TWO, NA_WEAPON2}, {NK_THREE, NA_WEAPON3}, {NK_FOUR, NA_WEAPON4},
+ {NK_FIVE, NA_WEAPON5}, {NK_SIX, NA_WEAPON6}, {NK_SEVEN, NA_WEAPON7}, {NK_TOOLBOX, NA_AUTOMAP},
+ {NK_PLUS, NA_BIGGER}, {NK_MINUS, NA_SMALLER}, {NK_MUL, NA_FOLLOW}, {NK_DIV, NA_GRID},
+ {NK_ZERO, NA_WHOLEMAP}, {NK_EIGHT, NA_MARK}, {NK_NINE, NA_CLEARMARKS}, {NK_SQRT, NA_GAMMA},
+ {NK_LN, NA_QUICKSAVE}, {NK_LOG, NA_QUICKLOAD}, {NK_PI, NA_PAUSE}, {NK_ANS, NA_CHEAT},
+ };
+ memset(nw_binding, NA_NONE, sizeof nw_binding);
+ for (unsigned i = 0; i < sizeof def / sizeof def[0]; i++) nw_binding[def[i][0]] = def[i][1];
+}
+
+/* the keys that do an action ("" if none), as "OK, EXE" */
+const char *nw_keys_of(int action, char *buf, int size) {
+ int n = 0;
+ buf[0] = 0;
+ for (int k = 0; k < NK_COUNT && n < size - 1; k++) {
+ if (nw_binding[k] != action || !nw_key_bindable(k)) continue;
+ const char *name = key_names[k];
+ int len = (int)strlen(name);
+ if (n + len + (n ? 2 : 0) >= size) break;
+ if (n) buf[n++] = ',', buf[n++] = ' ';
+ memcpy(buf + n, name, len + 1);
+ n += len;
+ }
+ return buf;
+}
+
+/* the options are choosing a key for an action: the next key pressed is it */
+int nw_capture = -1;
+/* ------------------------------------------------------------------ cheats
+ * Doom's cheats are typed on its keyboard: here each key types the letter it types after alpha on the
+ * calculator, and the numbers after IDCLEV; Back, OK or EXE stop */
+boolean nw_typing;
+static char typed[16];
+extern boolean message_dontfuckwithme;
+
+static int letter_of(int k) {
+ static const char letters[NK_COUNT] = {
+ [NK_EXP] = 'a', [NK_LN] = 'b', [NK_LOG] = 'c', [NK_IMAG] = 'd', [NK_COMMA] = 'e', [NK_POWER] = 'f',
+ [NK_SIN] = 'g', [NK_COS] = 'h', [NK_TAN] = 'i', [NK_PI] = 'j', [NK_SQRT] = 'k', [NK_SQUARE] = 'l',
+ [NK_SEVEN] = 'm', [NK_EIGHT] = 'n', [NK_NINE] = 'o', [NK_LPAREN] = 'p', [NK_RPAREN] = 'q',
+ [NK_FOUR] = 'r', [NK_FIVE] = 's', [NK_SIX] = 't', [NK_MUL] = 'u', [NK_DIV] = 'v', [NK_ONE] = 'w',
+ [NK_TWO] = 'x', [NK_THREE] = 'y', [NK_PLUS] = 'z',
+ };
+ static const char digits[NK_COUNT] = {
+ [NK_ZERO] = '0', [NK_ONE] = '1', [NK_TWO] = '2', [NK_THREE] = '3', [NK_FOUR] = '4', [NK_FIVE] = '5',
+ [NK_SIX] = '6', [NK_SEVEN] = '7', [NK_EIGHT] = '8', [NK_NINE] = '9',
+ };
+ /* (the numbers of IDCLEV and IDMUS: the episode and the map, the music) */
+ int n = (int)strlen(typed);
+ for (int i = n; i >= 0 && i >= n - 1; i--) {
+ if (i < n && (typed[i] < '0' || typed[i] > '9')) break;
+ if ((i >= 6 && !memcmp(typed + i - 6, "idclev", 6)) || (i >= 5 && !memcmp(typed + i - 5, "idmus", 5)))
+ if (digits[k]) return digits[k];
+ }
+ return letters[k];
+}
+
+static void show_typed(void) {
+ static char line[40];
+ strcpy(line, "CHEAT: ");
+ for (int i = 0; typed[i]; i++) line[7 + i] = typed[i] >= 'a' && typed[i] <= 'z' ? typed[i] - 32 : typed[i];
+ line[7 + strlen(typed)] = '_';
+ line[8 + strlen(typed)] = 0;
+ players[consoleplayer].message = line;
+ message_dontfuckwithme = true;
+}
+
+void nw_cheat_start(void) {
+ nw_typing = true;
+ typed[0] = 0;
+ show_typed();
+}
+
+static void cheat_key(int k) {
+ if (k == NK_BACK || k == NK_OK || k == NK_EXE) {
+ nw_typing = false;
+ return;
+ }
+ int c = letter_of(k);
+ if (!c) return;
+ int n = (int)strlen(typed);
+ if (n == (int)sizeof typed - 1) memmove(typed, typed + 1, n--);
+ typed[n] = (char)c;
+ typed[n + 1] = 0;
+ show_typed();
+ /* the letter, as Doom's keyboard would send it: the cheats see it (and say so when one works) */
+ event_t ev = {ev_keydown, c, c, 0, 0, 0};
+ D_PostEvent(&ev);
+ ev.type = ev_keyup;
+ D_PostEvent(&ev);
+}
+
+/* ------------------------------------------------------------------ the keys */
void nw_input_init(void) {
// the menus' questions: OK says yes, Back says no
key_menu_confirm = KEY_ENTER;
@@ -50,38 +206,29 @@ void nw_input_init(void) {
key_map_follow = 'f';
key_map_grid = 'g';
key_map_maxzoom = '0';
+ key_map_mark = 'm';
+ key_map_clearmark = 'c';
+ if (!nw_binding[NK_OK] && !nw_binding[NK_UP]) nw_bindings_default();
}
static int doom_key(int k) {
- switch (k) {
- case NK_LEFT: return KEY_LEFTARROW;
- case NK_RIGHT: return KEY_RIGHTARROW;
- case NK_UP: return KEY_UPARROW;
- case NK_DOWN: return KEY_DOWNARROW;
- case NK_OK: return M_WantsEnter() ? KEY_ENTER : KEY_RCTRL;
- case NK_EXE: return M_WantsEnter() ? KEY_ENTER : ' ';
- case NK_BACK: return M_BackKey();
- case NK_BACKSPACE: return M_WantsEnter() ? KEY_BACKSPACE : ' ';
- case NK_SHIFT: return KEY_RALT;
- case NK_ALPHA: return KEY_RSHIFT;
- case NK_XNT: return ',';
- case NK_VAR: return '.';
- case NK_TOOLBOX: return KEY_TAB;
- case NK_SQRT: return KEY_F11;
- case NK_ONE: return '1';
- case NK_TWO: return '2';
- case NK_THREE: return '3';
- case NK_FOUR: return '4';
- case NK_FIVE: return '5';
- case NK_SIX: return '6';
- case NK_SEVEN: return '7';
- case NK_PLUS: return '=';
- case NK_MINUS: return '-';
- case NK_MUL: return 'f';
- case NK_DIV: return 'g';
- case NK_ZERO: return '0';
- default: return 0;
+ if (M_WantsEnter()) {
+ /* menus and questions: arrows, OK and EXE choose, Back and backspace go back */
+ switch (k) {
+ case NK_LEFT: return KEY_LEFTARROW;
+ case NK_RIGHT: return KEY_RIGHTARROW;
+ case NK_UP: return KEY_UPARROW;
+ case NK_DOWN: return KEY_DOWNARROW;
+ case NK_OK:
+ case NK_EXE: return KEY_ENTER;
+ case NK_BACK: return M_BackKey();
+ case NK_BACKSPACE: return KEY_BACKSPACE;
+ default: break;
+ }
+ if (nw_binding[k] == NA_MENU) return KEY_ESCAPE;
}
+ int a = nw_binding[k];
+ return a < NA_COUNT ? nw_actions[a].key : 0;
}
void I_StartTic(void) {
@@ -93,15 +240,36 @@ void I_StartTic(void) {
for (int k = 0; k < NK_COUNT; k++) {
boolean down = (keys >> k) & 1;
if (down && !sent[k]) {
+ if (nw_capture >= 0) {
+ /* the options: this key is given the action */
+ if (nw_key_bindable(k)) {
+ nw_binding[k] = (uint8_t)nw_capture;
+ nw_capture = -1;
+ }
+ sent[k] = NW_SENT_NONE;
+ continue;
+ }
+ if (nw_typing && !M_WantsEnter()) {
+ cheat_key(k);
+ sent[k] = NW_SENT_NONE;
+ continue;
+ }
+ if (!M_WantsEnter() && nw_binding[k] == NA_CHEAT && gamestate == GS_LEVEL) {
+ nw_cheat_start();
+ sent[k] = NW_SENT_NONE;
+ continue;
+ }
int key = doom_key(k);
if (!key) continue;
- sent[k] = (uint8_t)key;
+ sent[k] = (uint16_t)key;
event_t ev = {ev_keydown, key, key, 0, 0, 0};
D_PostEvent(&ev);
} else if (!down && sent[k]) {
- event_t ev = {ev_keyup, sent[k], 0, 0, 0, 0};
+ if (sent[k] != NW_SENT_NONE) {
+ event_t ev = {ev_keyup, sent[k], 0, 0, 0, 0};
+ D_PostEvent(&ev);
+ }
sent[k] = 0;
- D_PostEvent(&ev);
}
}
}
diff --git a/games/doom/src/nw/i_video.c b/games/doom/src/nw/i_video.c
index 2311620d..fa7460d6 100644
--- a/games/doom/src/nw/i_video.c
+++ b/games/doom/src/nw/i_video.c
@@ -138,7 +138,8 @@ void nw_frame_end(void) {
* with a margin each side for the clock (1 ms steps) and the panel's blanking time. */
#define NW_SYNC_MARGIN (2 * 256)
static int32_t nw_sync_period, nw_sync_t0;
-static int32_t nw_band_ms, nw_push_ms; /* (how long a band takes to make and to send, on average) */
+/* how long each band takes to make (the most it took lately: a frame late for its refresh tears) and to send */
+static int32_t nw_band_ms[SCREENWIDTH / NW_BAND_W], nw_push_ms;
static int32_t nw_frame_r; /* the refresh this frame keeps to (its start) */
static uint32_t nw_band_start;
@@ -190,7 +191,7 @@ static void nw_sync_band(int j) {
while (nw_window_close(r, 0) < now) r += nw_sync_period;
int32_t p = now > nw_window_open(r, 0) ? now : nw_window_open(r, 0);
for (int k = 1; k < 5; k++) {
- p += nw_band_ms + nw_push_ms;
+ p += nw_band_ms[k] + nw_push_ms;
if (p < nw_window_open(r, k)) p = nw_window_open(r, k);
}
if (p > nw_window_close(r, 4)) r += nw_sync_period;
@@ -252,7 +253,8 @@ void nw_band_end(int x0, int x1) {
#endif
int j = nw_band_index++;
int32_t made = (int32_t)(plat_millis() - nw_band_start) * 256;
- nw_band_ms += (made - nw_band_ms) / 4;
+ int32_t *est = &nw_band_ms[j < SCREENWIDTH / NW_BAND_W ? j : 0];
+ *est = made > *est ? made : *est - (*est - made) / 16;
if (nw_sync_period && !nw_sync_off) nw_sync_band(j);
uint32_t t = plat_millis();
if (nw_melting) {
diff --git a/games/doom/src/nw/nw.h b/games/doom/src/nw/nw.h
index 5c4e3ebd..f0909e2b 100644
--- a/games/doom/src/nw/nw.h
+++ b/games/doom/src/nw/nw.h
@@ -21,6 +21,36 @@ void nw_show_error(const char *msg);
/* i_input.c: Home or On/Off is pressed (the moment is kept, then the app quits) */
extern boolean nw_home;
void nw_input_init(void);
+/* the calculator's keys (eadk_key_*) */
+enum {
+ NK_LEFT = 0, NK_UP = 1, NK_DOWN = 2, NK_RIGHT = 3, NK_OK = 4, NK_BACK = 5, NK_HOME = 6, NK_ONOFF = 8,
+ NK_SHIFT = 12, NK_ALPHA = 13, NK_XNT = 14, NK_VAR = 15, NK_TOOLBOX = 16, NK_BACKSPACE = 17, NK_EXP = 18,
+ NK_LN = 19, NK_LOG = 20, NK_IMAG = 21, NK_COMMA = 22, NK_POWER = 23, NK_SIN = 24, NK_COS = 25, NK_TAN = 26,
+ NK_PI = 27, NK_SQRT = 28, NK_SQUARE = 29, NK_SEVEN = 30, NK_EIGHT = 31, NK_NINE = 32, NK_LPAREN = 33,
+ NK_RPAREN = 34, NK_FOUR = 36, NK_FIVE = 37, NK_SIX = 38, NK_MUL = 39, NK_DIV = 40, NK_ONE = 42, NK_TWO = 43,
+ NK_THREE = 44, NK_PLUS = 45, NK_MINUS = 46, NK_ZERO = 48, NK_DOT = 49, NK_EE = 50, NK_ANS = 51, NK_EXE = 52,
+ NK_COUNT = 53
+};
+/* what a key can do: Doom's actions, each the key of Doom's keyboard that does it */
+enum {
+ NA_NONE, NA_FORWARD, NA_BACKWARD, NA_TURNLEFT, NA_TURNRIGHT, NA_FIRE, NA_USE, NA_STRAFE, NA_RUN,
+ NA_STRAFELEFT, NA_STRAFERIGHT, NA_WEAPON1, NA_WEAPON2, NA_WEAPON3, NA_WEAPON4, NA_WEAPON5, NA_WEAPON6,
+ NA_WEAPON7, NA_AUTOMAP, NA_MENU, NA_PAUSE, NA_BIGGER, NA_SMALLER, NA_FOLLOW, NA_GRID, NA_WHOLEMAP, NA_MARK,
+ NA_CLEARMARKS, NA_GAMMA, NA_QUICKSAVE, NA_QUICKLOAD, NA_MESSAGES, NA_DETAIL, NA_CHEAT, NA_COUNT
+};
+typedef struct {
+ const char *name;
+ int key;
+} nw_action_t;
+extern const nw_action_t nw_actions[NA_COUNT];
+extern uint8_t nw_binding[NK_COUNT]; /* each key's action (kept in doom.cfg) */
+void nw_bindings_default(void);
+const char *nw_key_name(int k);
+boolean nw_key_bindable(int k);
+const char *nw_keys_of(int action, char *buf, int size);
+extern int nw_capture; /* an action the next key pressed is given (the options), or -1 */
+extern boolean nw_typing; /* a cheat is being typed */
+void nw_cheat_start(void);
/* saves.c: the save slots (doomsav0.dsg to doomsav5.dsg), the moment kept on Home (slot NW_RESUME_SLOT,
* read once on the next start) and the copy of them all in doom_saves.py */
diff --git a/games/doom/src/nw/nw_back.inc b/games/doom/src/nw/nw_back.inc
index 8a309eb4..b6958755 100644
--- a/games/doom/src/nw/nw_back.inc
+++ b/games/doom/src/nw/nw_back.inc
@@ -438,7 +438,7 @@ static void nw_draw_band(uint8_t *band, int x0, int x1, bool view, int help, boo
I_VideoBuffer = render_frame_buffer;
nw_band_begin(band, x0, x1);
if (view) {
- if (automapactive) {
+ if (automapactive && !am_overlay) {
nw_direct = true;
AM_Drawer();
nw_direct = false;
@@ -462,6 +462,12 @@ static void nw_draw_band(uint8_t *band, int x0, int x1, bool view, int help, boo
nw_draw_view(x0, x1);
nw_strip_x0 = 0;
nw_strip_x1 = SCREENWIDTH;
+ if (automapactive) {
+ // (the map over the view)
+ nw_direct = true;
+ AM_Drawer();
+ nw_direct = false;
+ }
}
for (int y = viewheight; y < SCREENHEIGHT; y++) memset(render_frame_buffer + y * NW_STRIDE + x0, 0, x1 - x0);
} else {
@@ -493,7 +499,7 @@ static void nw_draw_frame() {
if (nw_scan_right_to_left) {
// (a frame drawn band by band has its visplanes in each band's pass: the spans' starts in the bands
// on the left are not known, and are taken where the band starts)
- bool edges = view && !automapactive && !strips;
+ bool edges = view && (!automapactive || am_overlay) && !strips;
if (edges) nw_plane_edges(band);
for (int k = bands - 1; k >= 0; k--) {
if (edges && k) {
@@ -578,7 +584,8 @@ void pd_end_frame(int wipe_start) {
}
if (force_strips) nw_overflowed = true;
#endif
- bool strips = view && !automapactive && nw_overflowed;
+ bool view3d = view && (!automapactive || am_overlay);
+ bool strips = view3d && nw_overflowed;
nw_flats_ready();
int fuzz_end = fuzzpos;
#if HOST
@@ -595,7 +602,7 @@ void pd_end_frame(int wipe_start) {
}
if (view && getenv("FUZZTRACE")) printf("FUZZ %d %d %d%d\n", leveltime, fuzzpos, gameepisode, gamemap);
#endif
- if (view && !automapactive) {
+ if (view3d) {
nw_col_frames[render_col_count / 250 < 40 ? render_col_count / 250 : 39]++;
fuzz_end = nw_fuzz_prepass(fuzzpos);
}
diff --git a/games/doom/src/nw/nw_menu.inc b/games/doom/src/nw/nw_menu.inc
new file mode 100644
index 00000000..5975154a
--- /dev/null
+++ b/games/doom/src/nw/nw_menu.inc
@@ -0,0 +1,275 @@
+// Doom on the calculator: what its Options add to vanilla's (included by m_menu.c): Brightness, the keys, the
+// cheats (as GBADoom has them) and a page of more choices. Their words are in Doom's small font, as vanilla's
+// own messages are.
+
+#include "nw/nw.h"
+#include "am_map.h"
+
+extern menu_t OptionsDef;
+extern int nw_scan_right_to_left, nw_sync_off;
+void AM_NwCheat(void);
+
+static void M_NwBrightness(int choice);
+static void M_NwKeys(int choice);
+static void M_NwCheats(int choice);
+static void M_NwMore(int choice);
+
+// a line of small words in a menu, where its big ones would be
+#define NW_TEXT_DY 4
+static int nw_value_x = 150;
+static void M_NwLine(const menu_t *m, int i, const char *label, const char *value)
+{
+ M_WriteText(m->x, m->y + LINEHEIGHT * i + NW_TEXT_DY, label);
+ if (value)
+ M_WriteText(m->x + nw_value_x, m->y + LINEHEIGHT * i + NW_TEXT_DY, value);
+}
+
+static void M_NwTitle(const char *title)
+{
+ int w = M_StringWidth(title);
+ M_WriteText(w < SCREENWIDTH ? (SCREENWIDTH - w) / 2 : 0, 16, title);
+}
+
+// ---------------------------------------------------------------- brightness (vanilla's gamma, its five levels)
+static void M_NwBrightness(int choice)
+{
+ if (choice == 0 && usegamma > 0)
+ usegamma--;
+ else if (choice == 1 && usegamma < 4)
+ usegamma++;
+ players[consoleplayer].message = DEH_String(gammamsg[usegamma]);
+ I_SetPaletteNum(0);
+}
+
+// ---------------------------------------------------------------- the keys
+// the actions a page at a time: choose one, then press the key for it
+#define NW_KEY_ROWS 6
+static int nw_keys_page;
+static const int nw_keys_pages = (NA_COUNT - 1 + NW_KEY_ROWS - 1) / NW_KEY_ROWS;
+
+static void M_NwKeyItem(int choice)
+{
+ if (choice == NW_KEY_ROWS)
+ {
+ nw_bindings_default();
+ players[consoleplayer].message = "THE KEYS ARE AS THEY CAME";
+ return;
+ }
+ int action = nw_keys_page * NW_KEY_ROWS + choice + 1;
+ if (action < NA_COUNT)
+ nw_capture = action;
+}
+
+static const menuitem_t KeysMenu[NW_KEY_ROWS + 1] = {
+ {1, VPATCH_NAME_INVALID, 0, M_NwKeyItem}, {1, VPATCH_NAME_INVALID, 0, M_NwKeyItem},
+ {1, VPATCH_NAME_INVALID, 0, M_NwKeyItem}, {1, VPATCH_NAME_INVALID, 0, M_NwKeyItem},
+ {1, VPATCH_NAME_INVALID, 0, M_NwKeyItem}, {1, VPATCH_NAME_INVALID, 0, M_NwKeyItem},
+ {1, VPATCH_NAME_INVALID, 'd', M_NwKeyItem},
+};
+
+static void M_DrawNwKeys(void);
+menu_t KeysDef = {NW_KEY_ROWS + 1, &OptionsDef, KeysMenu, M_DrawNwKeys, 40, 34, 0};
+
+static void M_DrawNwKeys(void)
+{
+ char buf[64], page[32];
+ nw_value_x = 150;
+ M_NwTitle("KEYS: OK, THEN THE KEY");
+ for (int i = 0; i < NW_KEY_ROWS; i++)
+ {
+ int action = nw_keys_page * NW_KEY_ROWS + i + 1;
+ if (action >= NA_COUNT)
+ continue;
+ const char *keys = nw_capture == action ? "PRESS A KEY" : nw_keys_of(action, buf, 24);
+ M_NwLine(&KeysDef, i, nw_actions[action].name, keys[0] ? keys : "-");
+ }
+ M_NwLine(&KeysDef, NW_KEY_ROWS, "THE KEYS AS THEY CAME", NULL);
+ M_snprintf(page, sizeof page, "PAGE %d OF %d: LEFT, RIGHT", nw_keys_page + 1, nw_keys_pages);
+ M_WriteText((SCREENWIDTH - M_StringWidth(page)) / 2, KeysDef.y + LINEHEIGHT * (NW_KEY_ROWS + 1) + 2, page);
+}
+
+static void M_NwKeys(int choice)
+{
+ nw_keys_page = 0;
+ M_SetupNextMenu(&KeysDef);
+}
+
+// ---------------------------------------------------------------- cheats
+// each does what typing its code does (the code is sent to the game as typed, so vanilla's rules and words
+// apply: none in Nightmare)
+static int nw_warp_map = 1, nw_power;
+static const char nw_power_codes[] = "vsiral";
+static const char *const nw_power_names[] = {"INVULNERABLE", "BERSERK", "INVISIBLE", "RADIATION SUIT",
+ "COMPUTER MAP", "LIGHT GOGGLES"};
+
+static void M_NwType(const char *code)
+{
+ M_ClearMenus();
+ for (; *code; code++)
+ {
+ event_t ev = {ev_keydown, *code, *code, 0, 0, 0};
+ D_PostEvent(&ev);
+ ev.type = ev_keyup;
+ D_PostEvent(&ev);
+ }
+}
+
+enum { ch_god, ch_kfa, ch_fa, ch_clip, ch_warp, ch_power, ch_map, ch_chainsaw, ch_type, ch_end };
+
+static void M_NwCheatItem(int choice)
+{
+ if (gamestate != GS_LEVEL || demoplayback)
+ {
+ players[consoleplayer].message = "CHEATS ARE FOR A GAME";
+ return;
+ }
+ char code[16];
+ switch (choice)
+ {
+ case ch_god: M_NwType("iddqd"); break;
+ case ch_kfa: M_NwType("idkfa"); break;
+ case ch_fa: M_NwType("idfa"); break;
+ case ch_clip: M_NwType("idclip"); break;
+ case ch_warp:
+ M_snprintf(code, sizeof code, "idclev%d%d", gamemode == commercial ? nw_warp_map / 10 : gameepisode,
+ nw_warp_map % 10);
+ M_NwType(code);
+ break;
+ case ch_power:
+ M_snprintf(code, sizeof code, "idbehold%c", nw_power_codes[nw_power]);
+ M_NwType(code);
+ break;
+ case ch_map:
+ M_ClearMenus();
+ AM_NwCheat();
+ break;
+ case ch_chainsaw: M_NwType("idchoppers"); break;
+ case ch_type:
+ M_ClearMenus();
+ nw_cheat_start();
+ break;
+ }
+}
+
+// (left and right choose the level and the power)
+static boolean M_NwCheatSide(int right)
+{
+ int maps = gamemode == commercial ? 32 : 9;
+ if (itemOn == ch_warp)
+ nw_warp_map = (nw_warp_map + (right ? 1 : maps - 1) - 1) % maps + 1;
+ else if (itemOn == ch_power)
+ nw_power = (nw_power + (right ? 1 : 5)) % 6;
+ else
+ return false;
+ return true;
+}
+
+static const menuitem_t CheatsMenu[] = {
+ {1, VPATCH_NAME_INVALID, 'g', M_NwCheatItem}, {1, VPATCH_NAME_INVALID, 'k', M_NwCheatItem},
+ {1, VPATCH_NAME_INVALID, 'f', M_NwCheatItem}, {1, VPATCH_NAME_INVALID, 'n', M_NwCheatItem},
+ {1, VPATCH_NAME_INVALID, 'w', M_NwCheatItem}, {1, VPATCH_NAME_INVALID, 'p', M_NwCheatItem},
+ {1, VPATCH_NAME_INVALID, 'm', M_NwCheatItem}, {1, VPATCH_NAME_INVALID, 'c', M_NwCheatItem},
+ {1, VPATCH_NAME_INVALID, 't', M_NwCheatItem},
+};
+
+static void M_DrawNwCheats(void);
+menu_t CheatsDef = {ch_end, &OptionsDef, CheatsMenu, M_DrawNwCheats, 36, 26, 0};
+
+static void M_DrawNwCheats(void)
+{
+ char warp[16];
+ player_t *p = &players[consoleplayer];
+ boolean on = gamestate == GS_LEVEL;
+ nw_value_x = 184;
+ M_NwTitle("CHEATS (LEFT, RIGHT: THE LEVEL, THE POWER)");
+ M_NwLine(&CheatsDef, ch_god, "GOD MODE (IDDQD)", on && (p->cheats & CF_GODMODE) ? "ON" : "OFF");
+ M_NwLine(&CheatsDef, ch_kfa, "ALL WEAPONS, KEYS (IDKFA)", NULL);
+ M_NwLine(&CheatsDef, ch_fa, "WEAPONS, AMMO (IDFA)", NULL);
+ M_NwLine(&CheatsDef, ch_clip, "NO CLIPPING (IDCLIP)", on && (p->cheats & CF_NOCLIP) ? "ON" : "OFF");
+ if (gamemode == commercial)
+ M_snprintf(warp, sizeof warp, "< MAP%02d >", nw_warp_map);
+ else
+ M_snprintf(warp, sizeof warp, "< E%dM%d >", gameepisode ? gameepisode : 1, nw_warp_map);
+ M_NwLine(&CheatsDef, ch_warp, "WARP (IDCLEV)", warp);
+ M_NwLine(&CheatsDef, ch_power, "POWER (IDBEHOLD)", nw_power_names[nw_power]);
+ M_NwLine(&CheatsDef, ch_map, "THE WHOLE MAP (IDDT)", NULL);
+ M_NwLine(&CheatsDef, ch_chainsaw, "CHAINSAW (IDCHOPPERS)", NULL);
+ M_NwLine(&CheatsDef, ch_type, "TYPE A CODE: IDMYPOS...", NULL);
+}
+
+static void M_NwCheats(int choice)
+{
+ if (gamestate == GS_LEVEL && gameepisode && gamemode != commercial)
+ nw_warp_map = gamemap;
+ M_SetupNextMenu(&CheatsDef);
+}
+
+// ---------------------------------------------------------------- more
+enum { more_overlay, more_secrets, more_sync, more_end };
+
+static void M_NwMoreItem(int choice)
+{
+ switch (itemOn)
+ {
+ case more_overlay: nw_map_overlay = !nw_map_overlay; break;
+ case more_secrets: nw_map_secrets = !nw_map_secrets; break;
+ case more_sync:
+ {
+ // left to right, right to left, none
+ int s = nw_sync_off ? 2 : nw_scan_right_to_left;
+ s = (s + (choice == 0 ? 2 : 1)) % 3;
+ nw_sync_off = s == 2;
+ nw_scan_right_to_left = s == 1;
+ break;
+ }
+ }
+}
+
+static const menuitem_t MoreMenu[] = {
+ {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};
+
+static void M_DrawNwMore(void)
+{
+ static const char *const sync[] = {"LEFT TO RIGHT", "RIGHT TO LEFT", "NONE"};
+ nw_value_x = 150;
+ M_NwTitle("MORE OPTIONS");
+ 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]);
+ static const char *const notes[] = {
+ "THE MAP KEY GOES FROM THE VIEW TO THE MAP,", "TO THE MAP OVER THE VIEW, THEN BACK.", "",
+ "THE PICTURE IS SENT AS THE CALCULATOR'S", "SCREEN REFRESHES: IF IT TEARS, TRY THE", "OTHER WAY ROUND.",
+ };
+ for (unsigned i = 0; i < sizeof notes / sizeof notes[0]; i++)
+ M_WriteText(16, MoreDef.y + LINEHEIGHT * more_end + 8 + 10 * i, notes[i]);
+}
+
+static void M_NwMore(int choice)
+{
+ M_SetupNextMenu(&MoreDef);
+}
+
+// left and right in the calculator's menus that vanilla's have no use for
+static boolean M_NwSide(int key)
+{
+ if (key != key_menu_left && key != key_menu_right)
+ return false;
+ if (currentMenu == &KeysDef)
+ {
+ nw_keys_page = (nw_keys_page + (key == key_menu_right ? 1 : nw_keys_pages - 1)) % nw_keys_pages;
+ S_StartUnpositionedSound(sfx_pstop);
+ return true;
+ }
+ if (currentMenu == &CheatsDef && M_NwCheatSide(key == key_menu_right))
+ {
+ S_StartUnpositionedSound(sfx_pstop);
+ return true;
+ }
+ return false;
+}
diff --git a/games/doom/src/nw/saves.c b/games/doom/src/nw/saves.c
index 4d7a5e6a..6832a55d 100644
--- a/games/doom/src/nw/saves.c
+++ b/games/doom/src/nw/saves.c
@@ -157,17 +157,30 @@ void nw_resume_done(void) {
/* ------------------------------------------------------------------ settings */
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)
+extern int nw_map_overlay, nw_map_secrets, nw_scan_right_to_left, nw_sync_off;
+
void nw_settings_load(void) {
uint32_t len;
const uint8_t *d = plat_load(CFG_NAME, &len);
nw_first_start = !d;
- if (!d || len < 4 || d[0] != 'D' || d[1] != 1) return;
+ if (!d || len < 4 || d[0] != 'D' || (d[1] != 1 && d[1] != 2)) return;
showMessages = d[2] ? 1 : 0;
usegamma = d[3] <= 4 ? d[3] : 0;
+ if (d[1] != 2 || len != CFG_LEN) return;
+ nw_map_overlay = d[4] != 0;
+ 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;
}
void nw_settings_save(void) {
- uint8_t d[4] = {'D', 1, (uint8_t)showMessages, (uint8_t)usegamma};
+ 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);
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/tests/check.py b/games/doom/tests/check.py
index 565bf5b5..f07c961d 100644
--- a/games/doom/tests/check.py
+++ b/games/doom/tests/check.py
@@ -89,7 +89,7 @@ if e:
check(e["state"] == GS_FINALE, "E1M8's exit: the ending")
# a new game from the menus: title, menu, New Game, the episode, Hurt Me Plenty; then the menus and the automap
-keys = "2000:ok,2700:ok,3400:ok,4100:ok,6000-8000:up,9000:toolbox,10000:plus,11000:toolbox,12000:back,12600:down," \
+keys = "2000:ok,2700:ok,3400:ok,4100:ok,6000-8000:up,9000:toolbox,10000:plus,11000:toolbox,12000:exe,12600:down," \
"13000:down,13400:back,14000:back"
e = run(["--keys", keys, "--ms", "16000"], what="a new game")
if e:
@@ -98,7 +98,7 @@ if e:
# saving in a slot from the menu, then loading it; Home keeps the moment, and the next start is back there
saves = tempfile.mkdtemp(prefix="doom_saves_")
# (the menu: Save Game is the fourth line; the first slot; its name is the level's: OK saves)
-save = "2000:ok,2700:ok,3400:ok,4100:ok,6000-7000:up,8000:back,8500:down,8800:down,9100:down,9600:ok,10200:ok,10800:ok"
+save = "2000:ok,2700:ok,3400:ok,4100:ok,6000-7000:up,8000:exe,8500:down,8800:down,9100:down,9600:ok,10200:ok,10800:ok"
e = run(["--keys", save, "--ms", "13000"], saves=saves, what="a save in a slot")
if e:
check("doomsav0.dsg" in e["files"] and "doomres.sav" in e["files"] and "doom_saves.py" in e["files"],
diff --git a/games/doom/tests/play.c b/games/doom/tests/play.c
index 5563e0b7..7b47e75f 100644
--- a/games/doom/tests/play.c
+++ b/games/doom/tests/play.c
@@ -28,7 +28,9 @@ int nw_main(void);
static const struct { const char *name; int key; } names[] = {
{"left", 0}, {"up", 1}, {"down", 2}, {"right", 3}, {"ok", 4}, {"back", 5}, {"home", 6}, {"onoff", 8},
- {"shift", 12}, {"alpha", 13}, {"xnt", 14}, {"var", 15}, {"toolbox", 16}, {"backspace", 17}, {"sqrt", 28},
+ {"shift", 12}, {"alpha", 13}, {"xnt", 14}, {"var", 15}, {"toolbox", 16}, {"backspace", 17}, {"exp", 18},
+ {"ln", 19}, {"log", 20}, {"i", 21}, {"comma", 22}, {"power", 23}, {"sin", 24}, {"cos", 25}, {"tan", 26},
+ {"pi", 27}, {"sqrt", 28}, {"square", 29}, {"lparen", 33}, {"rparen", 34}, {"ee", 50}, {"ans", 51},
{"7", 30}, {"8", 31}, {"9", 32}, {"4", 36}, {"5", 37}, {"6", 38}, {"mul", 39}, {"div", 40}, {"1", 42},
{"2", 43}, {"3", 44}, {"plus", 45}, {"minus", 46}, {"0", 48}, {"dot", 49}, {"exe", 52},
};
diff --git a/games/doom/tools/media.py b/games/doom/tools/media.py
index 141c430b..921e4701 100644
--- a/games/doom/tools/media.py
+++ b/games/doom/tools/media.py
@@ -76,8 +76,8 @@ save_png(thumb, os.path.join(media, "thumb_doom.png"))
# Hangar: through the courtyard, the automap, the menu over the game, then the exit and the intermission
walk = ("1500-2200:up,2200-2500:right,1700:ok,2700-3400:up,3400-3700:right,2900:ok,3900-4600:up,4600-4900:right,"
- "4100:ok,5100-5800:up,5800-6100:right,6300-7000:up,7000-7300:right,9000:toolbox,10500:toolbox,11500:back,"
- "13000:back,21000:ok")
+ "4100:ok,5100-5800:up,5800-6100:right,6300-7000:up,7000-7300:right,9000:toolbox,10500:toolbox,"
+ "10800:toolbox,11500:exe,13000:back,21000:ok")
hangar_shots = {"hangar": 5200, "automap": 9800, "menu": 12400, "intermission": 19600}
pics = play(["--warp", "11", "--exit-at", "14000", "--keys", walk], hangar_shots.values(), 20000)
for name, t in hangar_shots.items():
diff --git a/games/doom/tools/panel.py b/games/doom/tools/panel.py
index 480f40eb..41214f0c 100644
--- a/games/doom/tools/panel.py
+++ b/games/doom/tools/panel.py
@@ -74,10 +74,18 @@ class Panel(emu.Calculator):
if self.ref * T < a.t0 or not self.frames:
return
self.refreshes += 1
- best = min(int(np.count_nonzero(self.comp != f)) for f in self.frames + [self.mem])
+ cands = self.frames + [self.mem]
+ best = min(int(np.count_nonzero(self.comp != f)) for f in cands)
if best:
self.torn += 1
self.torn_pixels.append(best)
+ # which of the frames each band of 64 columns shows (-1: none of them)
+ bands = []
+ for b in range(5):
+ cols = slice(64 * b, 64 * b + 64)
+ m = [k for k, f in enumerate(cands) if not np.count_nonzero(self.comp[:, cols] != f[:, cols])]
+ bands.append(m[-1] - len(cands) + 1 if m else None)
+ print(f"torn at {self.ref * T:.0f} ms: bands show frames {bands} (0 the last sent)", flush=True)
if a.out and self.saved < 6:
from PIL import Image
c = self.comp.astype(np.uint32)