X-Git-Url: https://jxself.org/git/?p=zilutils.git;a=blobdiff_plain;f=zilasm%2Fmain.c;fp=zilasm%2Fmain.c;h=b60233930a32f83ea2b8c7132654f14157909aa8;hp=f0f335b61e8c5fb3768d1eb1c53cb836dbaae1de;hb=37d32bd49e745a5c1686b6495f60172b24222361;hpb=83cad370b16c3abb67c05ad75aade35211c0c892 diff --git a/zilasm/main.c b/zilasm/main.c index f0f335b..b602339 100644 --- a/zilasm/main.c +++ b/zilasm/main.c @@ -2,7 +2,7 @@ * main.c * * Copyright (C) 2015 Alexander Andrejevic - * Copyright (C) 2015 Jason Self + * Copyright (C) 2015, 2019 Jason Self * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as @@ -30,6 +30,8 @@ #include "config.h" +#include "header.h" + const int DEFAULT_ZVERSION = 6; enum { ZVERSION = 11, ZORKID, ZSERIAL }; @@ -176,9 +178,41 @@ int init_assembly(void) 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; } @@ -227,7 +261,7 @@ int main(int argc, char *argv[], char *envp[]) 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 */