git » fp-git.git » commit 2fb361a

main is now a parser, the kernel makes the stuff

author ecalot
2004-06-16 20:28:08 UTC
committer ecalot
2004-06-16 20:28:08 UTC
parent 9d9340392ff10db6e313b3522e642cfa5e3637d0

main is now a parser, the kernel makes the stuff

FP/src/main.c +59 -32

diff --git a/FP/src/main.c b/FP/src/main.c
index a2cb491..b21a666 100644
--- a/FP/src/main.c
+++ b/FP/src/main.c
@@ -19,9 +19,9 @@
 */
 
 /*
-resources.h: Princed Resources : Resource Handler headers
-\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf\xaf
- Copyright 2003 Princed Development Team
+main.c: FreePrince : Main function - parsing
+\xaf\xaf\xaf\xaf\xaf\xaf
+ Copyright 2004, 2003 Princed Development Team
   Created: 24 Mar 2004
 
   Author: Endfhgfhgfhg <efghgfdht.cod@princed.com.ar>
@@ -30,37 +30,64 @@ resources.h: Princed Resources : Resource Handler headers
   DO NOT remove this copyright notice
 */
 
-#include "input.h"
-#include "interpreter.h"
+#define _GNU_SOURCE
+#include <unistd.h>
+#include <getopt.h>
+#include "kernel.h"
 #include "main.h"
-#include "output.h"
-#include "parse.h"
-#include "resources.h"
-
-int main(int argc,char** argv) {
-	tGame game;
-	int playing;
-
-	/* Parse options */
-	game=parseFile("engine.dat");
-	if (!game) {
-		printf("Game couldn't be loaded\n");
-		return 0;
+#include <stdio.h>
+
+/***************************************************************\
+|      Standard executable command line parsing function        |
+\***************************************************************/
+
+int main (int argc, char **argv) {
+	/* declare variables */
+	int c;
+	int optionflag=0;
+	int junk = 0;
+
+	int level=-1;
+
+	/* Parse command line options */
+	do {
+		static struct option long_options[] = PARSING_OPTIONS;
+
+		c = getopt_long(argc,argv,PARSING_CHARS,long_options,&junk);
+		switch (c) {
+				case 'm':
+					setFlag(menu_flag);
+					break;
+				case 'l':
+					level=0;
+					if (optarg) level=atoi(optarg);
+					break;
+				case 't':
+					setFlag(megahit_flag);
+				case -1:
+					break;
+				case 1:
+					setFlag(version_flag);
+					break;
+				default:
+					setFlag(help_flag);
+					break;
+		}
+	} while (c!=-1);
+
+
+	/* Check syntax, help and version screens */
+	
+	if (hasFlag(help_flag)) {
+		fprintf(stderr,"This is a help screen\n");
+		exit(1);
 	}
 
-	/* Initialize Devices */
-	startGraphicMode();
-
-	/* Start interpreter */
-	if (!initGame(game)) return 0;
-
-	/* Main Loop */
-	while(performActions(getKey()));
+	if (hasFlag(version_flag)) {
+		fprintf(stderr,"This is a version screen\n");
+		exit(1);
+	}
 
-	/* End */
-	stopGraphicMode();
-	freeGame(game);
-	return 1;
+	/* Start kernel program */
+	return kernel(optionflag,level);
 }
-
-