* main.c
*
* Copyright (C) 2015 Alexander Andrejevic <theflash AT sdf DOT lonestar DOT org>
- * Copyright (C) 2015 Jason Self <j@jxself.org>
+ * Copyright (C) 2015, 2019 Jason Self <j@jxself.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
#include "config.h"
+#include "header.h"
+
const int DEFAULT_ZVERSION = 6;
enum { ZVERSION = 11, ZORKID, ZSERIAL };
return OK;
}
-int assembly(void)
+int assembly(char *output_file)
{
/* TODO */
+ FILE *file = fopen(output_file, "w");
+ if (file)
+ {
+ program_header_reset(6);
+
+ int size = sizeof(Program_header );
+ //Program_header.
+
+ Program_header.mode = 0; // DISPLAY_AVAILABLE | MONOSPACE_AVAILABLE;
+ Program_header.release = 1; // game version
+
+ Program_header.startPC = 64;
+
+ Program_header.dynamic_size = 128;
+ Program_header.h_file_size = 9; //sizeof(Program_header) + zmb->used_size;
+
+ ZMemblock *zmb = zmem_init(Program_header.h_file_size * 8);
+
+ //fprintf(file, "%c", 178); // printi command
+ //fprintf(file, "hello, world!");
+
+ zmem_putbyte(zmb, 186); // quit command
+
+
+
+ outputToFile(&Program_header, file);
+
+ //fprintf(file, "%c", 186);
+ fwrite(zmb->contents, zmb->allocated_size, 1, file);
+ fclose(file);
+ }
+
return OK;
}
init_opcodes(Config.zversion, 0);
- while(init_assembly() == OK && assembly() == NEED_RESTART);
+ while(init_assembly() == OK && assembly(output_file) == NEED_RESTART);
/* TODO! List global symbols */
/* TODO! Find abbreviations */