Mercurial > hg > Members > kono > os9 > sbc09
comparison os9/makerom.c @ 6:9c2602e1d716
level2 rom done
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 05 Jul 2018 00:02:54 +0900 |
parents | 3c736a81b886 |
children | a6db579d8c11 |
comparison
equal
deleted
inserted
replaced
5:35028b396a35 | 6:9c2602e1d716 |
---|---|
5 #include <stdio.h> | 5 #include <stdio.h> |
6 #include <stdlib.h> | 6 #include <stdlib.h> |
7 #include <strings.h> | 7 #include <strings.h> |
8 #include <sys/stat.h> | 8 #include <sys/stat.h> |
9 | 9 |
10 #define IOBASE 0xe000 | 10 int IOBASE = 0xe000; |
11 #define IOSIZE 0x100 | 11 int IOSIZE = 0x100; |
12 char * outfile ; | |
12 | 13 |
13 typedef struct os9module { | 14 typedef struct os9module { |
14 int size; | 15 int size; |
15 int location; | 16 int location; |
16 int ioflag; | 17 int ioflag; |
83 struct os9module *m = 0, root ; | 84 struct os9module *m = 0, root ; |
84 root.size = 0; | 85 root.size = 0; |
85 root.mod = 0; | 86 root.mod = 0; |
86 m = &root; | 87 m = &root; |
87 | 88 |
88 for(int i = 2 ; i<ac ; i++ ) { | 89 for(int i = 1 ; i<ac ; i++ ) { |
90 if (*av[i]=='-') { | |
91 if (av[i][1] =='i') { | |
92 IOBASE = strtol(av[i],(char**)0,0); | |
93 i += 1; | |
94 } else if (av[i][1] =='o') { | |
95 outfile = av[i+1]; | |
96 i += 1; | |
97 } else { | |
98 return 1; | |
99 } | |
100 continue; | |
101 } | |
89 struct os9module *cur; | 102 struct os9module *cur; |
90 cur = readOS9module(av[i]); | 103 cur = readOS9module(av[i]); |
91 m->next = cur; | 104 m->next = cur; |
92 m = cur; | 105 m = cur; |
93 } | 106 } |
94 | 107 |
95 FILE *romfile; | 108 FILE *romfile; |
96 unsigned pos; | 109 unsigned pos; |
110 if (outfile==0) return 1; | |
97 | 111 |
98 romfile=fopen(av[1],"wb"); | 112 romfile=fopen(outfile,"wb"); |
99 if(!romfile) { | 113 if(!romfile) { |
100 fprintf(stderr,"Cannot create file %s\n",av[1]); | 114 fprintf(stderr,"Cannot create file %s\n",av[1]); |
101 exit(1); | 115 exit(1); |
102 } | 116 } |
103 | 117 |
106 start = start&0xf800; | 120 start = start&0xf800; |
107 printf("\n\n"); | 121 printf("\n\n"); |
108 | 122 |
109 pos = start; | 123 pos = start; |
110 for(struct os9module *cur = root.next; cur ; cur = cur->next ) { | 124 for(struct os9module *cur = root.next; cur ; cur = cur->next ) { |
111 if ( cur->size && (cur->name[0]=='O' && cur->name[1]=='S' && cur->name[2]== -71)) { | 125 // last module have to os9p1 |
126 if ( cur->next == 0 ) { // cur->size && (cur->name[0]=='O' && cur->name[1]=='S' && cur->name[2]== -71)) { | |
112 for(; pos < 0xf800 ; pos++) { // os9p1 begins at 0xf800 | 127 for(; pos < 0xf800 ; pos++) { // os9p1 begins at 0xf800 |
113 fputc(0xff,romfile); | 128 fputc(0xff,romfile); |
114 } | 129 } |
115 } | 130 } |
116 printf("mod "); | 131 printf("mod "); |