- const char *output_file = NULL;
- int i;
-
- fill_config();
-
- int opt = 0;
- while ((opt = getopt_long (argc, argv, "hVo:", long_options, NULL)) != -1)
- {
- switch(opt)
- {
- case 'h' :
- print_usage(0);
- case 'V' :
- print_version();
- case 'o' :
- if (output_file) wrong_arg("Output file must be given once\n");
- output_file = optarg;
- break;
- case ZVERSION:
- parse_intarg(&Config.zversion, "zversion", 1, 8, 1);
- break;
- case ZORKID :
- parse_intarg(&Config.zorkid, "zorkid", 0, 0xFFFF, 0);
- break;
- case ZSERIAL :
- parse_zserial();
- break;
- default :
- wrong_arg(0);
- }
- }
-
- int first_input_file = optind;
- if (first_input_file >= argc)
- wrong_arg("Missing input file\n");
-
- if (!output_file)
- {
- const char suffix[] = ".dat";
- const char *input_file = argv[first_input_file];
- int n = strlen(input_file) + strlen(suffix);
- char *ofile = malloc(n); /* todo!!! check for NULL. free. */
- new_file_suffix(ofile, n, input_file, suffix);
- output_file = ofile;
- }
-
- // TODO: Everything :)
-
- printf("Input files:\n");
- for (i = optind; i < argc; i++)
- printf("\t%s\n", argv[i]);
-
- printf("Output file: %s\n\n", output_file);
-
- printf("Config:\n"
- "- ZVersion: %d\n"
- "- ZorkID: %d\n"
- "- ZSerial: %s\n",
- Config.zversion, Config.zorkid, Config.zserial
- );
-
- return 0;
+ const char *output_file = NULL;
+ int i;
+
+ fill_config();
+
+ int opt = 0;
+ while ((opt = getopt_long (argc, argv, "hVo:", long_options, NULL)) != -1) {
+ switch(opt) {
+ case 'h' : print_usage(0);
+ case 'V' : print_version();
+ case 'o' : if (output_file) wrong_arg("Output file must be given once\n");
+ output_file = optarg;
+ break;
+ case ZVERSION: parse_intarg(&Config.zversion, "zversion", 1, 8, 1); break;
+ case ZORKID : parse_intarg(&Config.zorkid, "zorkid", 0, 0xFFFF, 0); break;
+ case ZSERIAL : parse_zserial(); break;
+ default : wrong_arg(0);
+ }
+ }
+
+ int first_input_file = optind;
+ if (first_input_file >= argc)
+ wrong_arg("Missing input file\n");
+ if (!output_file)
+ output_file = build_output_filename(argv[first_input_file], ".dat");
+
+ // TODO: Everything :)
+
+ printf("Input files:\n");
+ for (i = optind; i < argc; i++)
+ printf("\t%s\n", argv[i]);
+
+ printf("Output file: %s\n\n", output_file);
+
+ printf("Config:\n"
+ "- ZVersion: %d\n"
+ "- ZorkID: %d\n"
+ "- ZSerial: %s\n",
+ Config.zversion, Config.zorkid, Config.zserial
+ );
+
+ init_opcodes(Config.zversion, 0);
+
+ while(init_assembly() == OK && assembly() == NEED_RESTART);
+
+ /* TODO! List global symbols */
+ /* TODO! Find abbreviations */
+
+ return 0;