home *** CD-ROM | disk | FTP | other *** search
- /*
- * main.c -- main() and its belongings.
- *
- * (c) 1993, 1994 by Han-Wen Nienhuys <hanwen@stack.urc.tue.nl>
- *
- * based on work originally by George Kyriazis, 1988.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
- #include <stdio.h>
- #include <stdlib.h>
-
- #include "ray.h"
- #include "proto.h"
- #include "extern.h"
-
- /* proto */
- PRIVATE void usage(void);
- PRIVATE void notice(void);
-
-
-
- int
- main(int argc, char *argv[])
- {
- char infn[100] = "input.r",
- outfn[100] = "output.tga";
-
- char c;
-
- /* print the (c) stuff */
- notice();
-
- /* no commandline options? */
- if (argc == 1)
- usage();
-
- /* set some global vars */
- set_defaults();
- initialize();
-
- /* scan commandline */
- while (--argc && ((c = **(++argv)) == '-' || c == '+')) {
- c = *++(argv[0]);
- switch (c) {
- case 'c': /* continue a previously interrupted
- * picture */
- continue_flag = TRUE;
- break;
- case 'd': /* turn on debugging */
- if (sscanf(++argv[0], "%ld", &debug_options) != 1)
- debug_options = ~0;
- break;
- case 'i': /* inputfile */
- if (sscanf(++argv[0], "%s", infn) != 1)
- usage();
-
- break;
-
- case 's':
- silent_mode = TRUE;
- break;
- case 'o': /* output file */
- if (sscanf(++argv[0], "%s", outfn) != 1)
- usage();
- break;
- case 'h': /* horizontal resolution */
- if (sscanf(++argv[0], "%d", &yres) != 1)
- usage();
- break;
- case 'w': /* vertical resolution */
- if (sscanf(++argv[0], "%d", &xres) != 1)
- usage();
- break;
- case 'x': /* disable keypress-exit */
- keyboard_exit = 0;
- break;
- case 't': /* for testing 'n debugging */
- test_flag = TRUE;
- break;
- case 'I': /* number of frames, "iterations" */
- if (sscanf(++argv[0], "%d", &iter_override) != 1)
- usage();
- tries = iter_override;
- break;
- default:
- usage();
- break;
- }
- }
-
-
- /* initialize any machine dependent stuff */
- init_machine();
-
- /* parse the input */
- readfile(infn);
- start_stats();
-
- /* and do the tracing */
- raytrace(outfn);
-
- exit(0);
- }
-
-
- PRIVATE void
- usage(void)
- {
- printf(
- "Rayce <options>\n"
- "-I# number of frames\n"
- "-i<file> input\n"
- "-o<file> output\n"
- "-h# height\n"
- "-w# width\n"
- "-x disable exit\n"
- "-c continue trace\n"
- "-d# debugging\n"
- " 1 = tokenizer, 2 = parser, 4 = runtime warnings, 8 = print_interior()\n"
- "\n"
- " Rayce was compiled with DEBUG %sdefined\n",
-
- #ifdef DEBUG
- ""
- #else
- "not "
- #endif
-
- );
- exit(0);
- }
-
- PRIVATE void
- notice(void)
- {
- printf("This is Rayce version 2.7\n"
- "Rayce is (c) 1993, 1994 Han-Wen Nienhuys <hanwen@stack.urc.tue.nl>\n"
- " It is based on \"Ray\" by George Kyriazis <kyriazis@turing.cs.rpi.edu>\n"
- " Rayce is released under the terms of the GNU General Public License,\n"
- " it has no warranty what so ever. For more details: see the file \"COPYING\"\n"
- "\n"
- "Enjoy!\n\n");
-
- return;
- }
-