* copy it to a string.
*
*/
+char *filename_decoded = 0;
+
static void get_default_name (char *default_name, zword addr)
{
- if (addr != 0) {
-
- zbyte len;
- int i;
-
- LOW_BYTE (addr, len);
- addr++;
-
- for (i = 0; i < len; i++) {
-
- zbyte c;
-
- LOW_BYTE (addr, c);
- addr++;
-
- if (c >= 'A' && c <= 'Z')
- c += 'a' - 'A';
-
- default_name[i] = c;
-
- }
+ int i;
- default_name[i] = 0;
+ if (addr != 0) {
+ memset (default_name, 0, MAX_FILE_NAME + 1);
+ filename_decoded = default_name;
+ decode_text (FILENAME, addr);
+ filename_decoded = 0;
if (strchr (default_name, '.') == NULL)
- strcpy (default_name + i, ".AUX");
+ strcpy (strchr (default_name, '\0'), EXT_AUX);
} else strcpy (default_name, f_setup.aux_name);
*
* zargs[0] = address of area to restore (optional)
* zargs[1] = number of bytes to restore
- * zargs[2] = address of suggested file name
+ * zargs[2] = packed address of suggested file name
*
*/
void z_restore (void)
*
* zargs[0] = address of memory area to save (optional)
* zargs[1] = number of bytes to save
- * zargs[2] = address of suggested file name
+ * zargs[2] = packed address of suggested file name
*
*/
void z_save (void)
void os_warn (const char *, ...);
void os_quit (void);
+
+/*** text decoding API ***/
+enum string_type {
+ LOW_STRING, ABBREVIATION, HIGH_STRING, EMBEDDED_STRING, VOCABULARY, FILENAME
+};
+
+void decode_text (enum string_type st, zword addr);
+
+
/**
* Called regularly by the interpreter, at least every few instructions
* (only when interpreting: e.g., not when waiting for input).
#include "frotz.h"
-enum string_type {
- LOW_STRING, ABBREVIATION, HIGH_STRING, EMBEDDED_STRING, VOCABULARY
-};
-
extern zword object_name (zword);
static zchar decoded[10];
static zword encoded[3];
+extern zchar *filename_decoded;
/*
* According to Matteo De Luigi <matteo.de.luigi@libero.it>,
* HIGH_STRING - from the end of the memory map (packed address)
* EMBEDDED_STRING - from the instruction stream (at PC)
* VOCABULARY - from the dictionary (byte address)
+ * FIlENAME - high string used as a filename, to be decoded instead of
+ * printed out
*
- * The last type is only used for word completion.
+ * The VOCABULARY type is only used for word completion.
*
*/
-#define outchar(c) if (st==VOCABULARY) *ptr++=c; else print_char(c)
-static void decode_text (enum string_type st, zword addr)
+#define outchar(c) if (st==VOCABULARY||st==FILENAME) *ptr++=c; else print_char(c)
+void decode_text (enum string_type st, zword addr)
{
zchar *ptr;
long byte_addr;
byte_addr = (long) addr << 1;
- else if (st == HIGH_STRING) {
+ else if (st == HIGH_STRING || st == FILENAME) {
if (h_version <= V3)
byte_addr = (long) addr << 1;
if (st == VOCABULARY)
ptr = decoded;
+ else if (st == FILENAME)
+ ptr = filename_decoded;
+
do {
int i;
if (st == LOW_STRING || st == VOCABULARY) {
LOW_WORD (addr, code)
addr += 2;
- } else if (st == HIGH_STRING || st == ABBREVIATION) {
+ } else if (st == HIGH_STRING || st == ABBREVIATION || st == FILENAME) {
HIGH_WORD (byte_addr, code)
byte_addr += 2;
} else
} while (!(code & 0x8000));
- if (st == VOCABULARY)
+ if (st == VOCABULARY || st == FILENAME)
*ptr = 0;
}/* decode_text */