-#include "funcs.h"
-#include "database.h"
-
-/* hack to ignore GCC Unused Result */
-#define IGNORE(r) do{if(r){}}while(0)
-
-/* I/O routines (SPEAK, PSPEAK, RSPEAK, SETPRM, GETIN, YES) */
-
-void SPEAK(vocab_t N)
-/* Print the message which starts at LINES(N). Precede it with a blank line
- * unless game.blklin is false. */
-{
- long blank, casemake, I, K, L, NEG, NPARMS, PARM, PRMTYP, state;
-
- if (N == 0)
- return;
- blank=game.blklin;
- K=N;
- NPARMS=1;
-L10:
- L=labs(LINES[K])-1;
- K=K+1;
- LNLENG=0;
- LNPOSN=1;
- state=0;
- for (I=K; I<=L; I++) {
- PUTTXT(LINES[I],state,2);
- } /* end loop */
- LNPOSN=0;
-L30:
- LNPOSN=LNPOSN+1;
-L32:
- if(LNPOSN > LNLENG)
- goto L40;
- if(INLINE[LNPOSN] != 63)
- goto L30;
- {long x = LNPOSN+1; PRMTYP=INLINE[x];}
- /* 63 is a "%"; the next character determine the type of
- * parameter: 1 (!) = suppress message completely, 29 (S) = NULL
- * If PARM=1, else 'S' (optional plural ending), 33 (W) = word
- * (two 30-bit values) with trailing spaces suppressed, 22 (L) or
- * 31 (U) = word but map to lower/upper case, 13 (C) = word in
- * lower case with first letter capitalised, 30 (T) = text ending
- * with a word of -1, 65-73 (1-9) = number using that many
- * characters, 12 (B) = variable number of blanks. */
- if(PRMTYP == 1)
- return;
- if(PRMTYP == 29)
- goto L320;
- if(PRMTYP == 30)
- goto L340;
- if(PRMTYP == 12)
- goto L360;
- if(PRMTYP == 33 || PRMTYP == 22 || PRMTYP == 31 || PRMTYP == 13)
- goto L380;
- PRMTYP=PRMTYP-64;
- if(PRMTYP < 1 || PRMTYP > 9) goto L30;
- SHFTXT(LNPOSN+2,PRMTYP-2);
- LNPOSN=LNPOSN+PRMTYP;
- PARM=labs(PARMS[NPARMS]);
- NEG=0;
- if(PARMS[NPARMS] < 0)
- NEG=9;
- /* 390 */ for (I=1; I<=PRMTYP; I++) {
- LNPOSN=LNPOSN-1;
- INLINE[LNPOSN]=MOD(PARM,10)+64;
- if(I == 1 || PARM != 0)
- goto L390;
- INLINE[LNPOSN]=NEG;
- NEG=0;
-L390:
- PARM=PARM/10;
+#include "linenoise/linenoise.h"
+#include "dungeon.h"
+
+const char new_advent_to_ascii[] = {
+ ' ', '!', '"', '#', '$', '%', '&', '\'',
+ '(', ')', '*', '+', ',', '-', '.', '/',
+ '0', '1', '2', '3', '4', '5', '6', '7',
+ '8', '9', ':', ';', '<', '=', '>', '?',
+ '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
+ 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
+ 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
+ 'X', 'Y', 'Z', '\0', '\0', '\0', '\0', '\0',
+};
+
+const char new_ascii_to_advent[] = {
+ 63, 63, 63, 63, 63, 63, 63, 63,
+ 63, 63, 63, 63, 63, 63, 63, 63,
+ 63, 63, 63, 63, 63, 63, 63, 63,
+ 63, 63, 63, 63, 63, 63, 63, 63,
+
+ 0, 1, 2, 3, 4, 5, 6, 7,
+ 8, 9, 10, 11, 12, 13, 14, 15,
+ 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, 28, 29, 30, 31,
+ 32, 33, 34, 35, 36, 37, 38, 39,
+ 40, 41, 42, 43, 44, 45, 46, 47,
+ 48, 49, 50, 51, 52, 53, 54, 55,
+ 56, 57, 58, 59, 60, 61, 62, 63,
+
+ 63, 63, 63, 63, 63, 63, 63, 63,
+ 63, 63, 63, 63, 63, 63, 63, 63,
+ 63, 63, 63, 63, 63, 63, 63, 63,
+ 63, 63, 63, 63, 63, 63, 63, 63,
+};
+
+char* xstrdup(const char* s)
+{
+ char* ptr = strdup(s);
+ if (ptr == NULL) {
+ // LCOV_EXCL_START
+ // exclude from coverage analysis because we can't simulate an out of memory error in testing
+ fprintf(stderr, "Out of memory!\n");
+ exit(EXIT_FAILURE);