home *** CD-ROM | disk | FTP | other *** search
-
- /* climain.c - this file handles the flow of control if playriff was
- launched with some parameters from the CLI. The next_token/pushback_token
- formalism is kind of overkill if you're just reading the command line,
- but thinking of expanding it soon to read from a file or maybe do wild
- card expansions. */
-
- #include <exec/types.h>
- #include <graphics/gfx.h>
- #include <intuition/intuition.h>
- #include <functions.h>
- #include <ctype.h>
- #include "jiff.h"
- #include "vcomp.h"
- #include "playriff.h"
-
-
- /* cl_count & cl_names are basically local copies of argc, argv as in
- main(argc, argv) */
- int cl_count;
- char **cl_names;
-
- int cl_ix; /* index into cl_names */
- char *reuse_clname; /* if want to use a name over again... */
-
- /* pushback_token() - reuse a token from the input stream */
- pushback_token(token)
- char *token;
- {
- reuse_clname = token;
- }
-
- /* next_token() - grab next token from input stream (in this case
- the command line, NULL at end of stream */
- char *
- next_token()
- {
- register char *n;
- register char *ncl;
- char c;
- static char matched1;
-
- if (reuse_clname != NULL) /* check to see if pushed-back */
- {
- n = reuse_clname;
- reuse_clname = NULL;
- return(n);
- }
- if (cl_ix >= cl_count)
- return(NULL);
- return(cl_names[cl_ix++]);
- }
-
-
-
- /* cli_playriff() - basically this guy is what does the stuff if we're
- executed from the cli with any command line arguments. */
- cli_playriff(count, names)
- int count;
- char *names[];
- {
- int loops;
-
- cl_count = count;
- cl_names = names;
- cl_ix = 1;
-
- loops = 1;
- for(;;)
- {
- if (( name = next_token()) == NULL) /* go fetch next argument */
- break;
- if (isdigit(name[0]) ) /* if it's numerical then it's a loop count */
- loops = atoi(name);
- else if (strcmp(name, "+") == 0) /* an extra + from errors ... skip */
- {
- puts("extra plus");
- }
- else /* it's a name, so figure it's a file name and go load it */
- {
- printf("loading %s\n", name);
- /* load up head separately so can alloc screen first before
- run out of memory ... */
- if (!load_riff_head() )
- goto loop_again;
- if (!screen_for_rh())
- {
- puts("couldn't open %d by %d by %d screen\n",
- ns.Width, ns.Height, ns.Depth);
- goto loop_again;
- }
- first_rh = demo_rh;
- strcpy(first_name, name); /* squirrel away a copy for error msgs */
- load_riff_body();
- if (!fatal_load) /* assuming loaded one, go check to see if
- there's any more to append (ie + something),
- and if so go appending... */
- {
- for (;;)
- {
- if ((name = next_token()) == NULL)
- break;
- if (strcmp(name, "+") != 0) /* if not a plus will reuse it*/
- {
- pushback_token(name);
- break;
- }
- if ((name = next_token()) == NULL)
- break;
- printf("appending %s\n", name);
- if (load_riff_head())
- {
- if (!match_res())
- continue;
- load_riff_body();
- if (fatal_load)
- {
- goto loop_again;
- }
- }
- }
- pointeroff();
- play_demo_riff(loops);
- loop_again:
- free_demo_riff();
- close_demo_screen();
- }
- }
- }
- }
-
-
-