DOS Frotz restricted mode (not tested yet) and fixed problems in bcsample.c.
authorDavid Griffith <dave@661.org>
Wed, 12 Jul 2017 12:31:13 +0000 (05:31 -0700)
committerDavid Griffith <dave@661.org>
Wed, 12 Jul 2017 12:31:13 +0000 (05:31 -0700)
src/dos/bcinit.c
src/dos/bcinput.c
src/dos/bcparams.txt
src/dos/bcsample.c

index a08e03a4d104d55da0af6678ebfb8655708fb1e3..d6addfba8f701bcdfbf54ae28145d8be48b03b67 100644 (file)
@@ -21,19 +21,19 @@ static char information[] =
 "Complies with standard 1.0 of Graham Nelson's specification.\n"\r
 "\n"\r
 "Syntax: frotz [options] story-file\n"\r
-"  -a   watch attribute setting  \t -o   watch object movement\n"\r
-"  -A   watch attribute testing  \t -O   watch object locating\n"\r
-"  -b # background colour        \t -p   alter piracy opcode\n"\r
-"  -B # reverse background colour\t -r # right margin\n"\r
-"  -c # context lines            \t -s # random number seed value\n"\r
-"  -d # display mode (see below) \t -S # transscript width\n"\r
-"  -e # emphasis colour [mode 1] \t -t   set Tandy bit\n"\r
-"  -f # foreground colour        \t -T   bold typing [modes 2+4+5]\n"\r
-"  -F # reverse foreground colour\t -u # slots for multiple undo\n"\r
-"  -g # font [mode 5] (see below)\t -w # screen width\n"\r
-"  -h # screen height            \t -x   expand abbreviations g/x/z\n"\r
-"  -i   ignore runtime errors    \t -Z # error checking (see below)\n"\r
-"  -l # left margin"\r
+"  -a   watch attribute setting    \t -o   watch object movement\n"\r
+"  -A   watch attribute testing    \t -O   watch object locating\n"\r
+"  -b # background colour          \t -p   alter piracy opcode\n"\r
+"  -B # reverse background colour  \t -r # right margin\n"\r
+"  -c # context lines              \t -R <path> restricted read/write\n"\r
+"  -d # display mode (see below)   \t -s # random number seed value\n"\r
+"  -e # emphasis colour [mode 1]   \t -S # transscript width\n"\r
+"  -f # foreground colour          \t -t   set Tandy bit\n"\r
+"  -F # reverse foreground colour  \t -T   bold typing [modes 2+4+5]\n"\r
+"  -g # font [mode 5] (see below)  \t -u # slots for multiple undo\n"\r
+"  -h # screen height              \t -w # screen width\n"\r
+"  -i   ignore runtime errors      \t -x   expand abbreviations g/x/z\n"\r
+"  -l # left margin                \t -Z # error checking (see below)"\r
 "\n"\r
 "Fonts are 0 (fixed), 1 (sans serif), 2 (comic), 3 (times), 4 (serif).\n"\r
 "Display modes are 0 (mono), 1 (text), 2 (CGA), 3 (MCGA), 4 (EGA), 5 (Amiga)."\r
@@ -261,7 +261,7 @@ static void parse_options (int argc, char **argv)
 \r
        int num = 0;\r
 \r
-       c = getopt (argc, argv, "aAb:B:c:d:e:f:F:g:h:il:oOpr:s:S:tTu:w:xZ:");\r
+       c = getopt (argc, argv, "aAb:B:c:d:e:f:F:g:h:il:oOpr:R:s:S:tTu:w:xZ:");\r
 \r
        if (optarg != NULL)\r
            num = dectoi (optarg);\r
@@ -309,6 +309,8 @@ static void parse_options (int argc, char **argv)
            f_setup.piracy = 1;\r
        if (c == 'r')\r
            f_setup.right_margin = num;\r
+       if (c == 'R')\r
+           f_setup.restricted_path = strdup(optarg);\r
        if (c == 's')\r
            user_random_seed = num;\r
        if (c == 'S')\r
index 87a0361664745b8259b607efd282288f9964dc2b..d4231c02d1f43fee20baa0132f1c496c71ec5ba3 100644 (file)
@@ -928,6 +928,9 @@ int os_read_file_name (char *file_name, const char *default_name, int flag)
     bool saved_replay = istream_replay;
     bool saved_record = ostream_record;
 
+    int i;
+    char *tempname;
+
     /* Turn off playback and recording temporarily */
 
     istream_replay = FALSE;
@@ -961,6 +964,23 @@ int os_read_file_name (char *file_name, const char *default_name, int flag)
     if (strchr (file_name, '.') == NULL)
        strcat (file_name, extension);
 
+    /* FIXME: UNTESTED Check if we're restricted to one directory. */
+
+    if (f_setup.restricted_path != NULL) {
+       for (i = strlen(file_name); i > 0; i--) {
+           if (file_name[i] == PATH_SEPARATOR) {
+               i++;
+               break;
+           }
+       }
+       tempname = strdup(file_name + i);
+       strcpy(file_name, f_setup.restricted_path);
+       if (file_name[strlen(file_name)-1] != PATH_SEPARATOR) {
+           strcat(file_name, "\\");
+       }
+       strcat(file_name, tempname);
+    }
+
     /* Make sure it is safe to use this file name */
 
     result = TRUE;
index ce3fb599b9ee4aabe96327b7139b913171cdbcf2..eb88a20c299572e8b8213717f7802551cbd09d1c 100644 (file)
@@ -15,6 +15,7 @@
 -O   watch object locating
 -p   alter piracy opcode
 -r # right margin
+-R <path> restricted read/write
 -s # random number seed value
 -S # transscript width
 -t   set Tandy bit
index 258a972d2883448413698c9544c1c5759826e41a..49e3f5a4c602a9421a0a5748419e9fa1e37990da 100644 (file)
@@ -123,6 +123,23 @@ static void interrupt end_of_dma (void)
 
 }/* end_of_dma */
 
+
+/*
+ * os_init_sound
+ *
+ * Dummy function to satisfy the core code.  DOS Frotz does its sound
+ * initialization in bcinit.c in os_init_screen().
+ *
+ * FIXME: Move the sound initlization from os_init_screen() to here and
+ *        somehow work around the ifs.
+ *
+ */
+void os_init_sound(void)
+{
+       /* do nothing */
+}
+
+
 /*
  * dos_init_sound
  *
@@ -332,6 +349,8 @@ void os_start_sample (int number, int volume, int repeats, zword eos)
 {
 #ifdef SOUND_SUPPORT
 
+    eos=eos;   /* not used in DOS Frotz */
+
     os_stop_sample ();
 
     /* Exit if the sound board isn't set up properly */