comparison os9/makerom.c @ 34:2032755628dc

fix for nitros9
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sun, 15 Jul 2018 14:18:19 +0900
parents 7c5379eb406e
children
comparison
equal deleted inserted replaced
33:7c5379eb406e 34:2032755628dc
45 45
46 // #define DEBUG 46 // #define DEBUG
47 47
48 typedef struct os9module { 48 typedef struct os9module {
49 int size; 49 int size;
50 int entry;
50 int location; 51 int location;
51 int ioflag; 52 int ioflag;
52 unsigned char *mod; 53 unsigned char *mod;
53 char *name; 54 char *name;
54 struct os9module *next; 55 struct os9module *next;
72 m->next = 0; 73 m->next = 0;
73 m->ioflag = 0; 74 m->ioflag = 0;
74 m->mod = (unsigned char*)m + sizeof(struct os9module); 75 m->mod = (unsigned char*)m + sizeof(struct os9module);
75 fread(m->mod , size, 1, fp); 76 fread(m->mod , size, 1, fp);
76 m->name = (char*) (m->mod + (m->mod[4]*256 + m->mod[5]) ); 77 m->name = (char*) (m->mod + (m->mod[4]*256 + m->mod[5]) );
78 m->entry = m->mod[9]*256 + m->mod[10] ;
77 fclose(fp); 79 fclose(fp);
78 return m; 80 return m;
79 } 81 }
80 82
81 void 83 void
85 fputc(x&0xff,fp); 87 fputc(x&0xff,fp);
86 } 88 }
87 89
88 void printOs9Str(char *p) 90 void printOs9Str(char *p)
89 { 91 {
92 char *q = p;
90 while((*p & 0x80)==0) { 93 while((*p & 0x80)==0) {
91 putchar(*p); 94 putchar(*p);
92 p++; 95 p++;
93 } 96 }
94 putchar(*p & 0x7f); 97 putchar(*p & 0x7f);
98 while(p<q+8) {
99 putchar(' '); p++;
100 }
95 } 101 }
96 102
97 unsigned short 103 unsigned short
98 getword(unsigned char *ptr) 104 getword(unsigned char *ptr)
99 { 105 {
246 } 252 }
247 printf("mod "); 253 printf("mod ");
248 printOs9Str(cur->name); 254 printOs9Str(cur->name);
249 cur->location = pos; 255 cur->location = pos;
250 fwrite(cur->mod, cur->size, 1, romfile); 256 fwrite(cur->mod, cur->size, 1, romfile);
251 printf(" \t: 0x%x - 0x%x size 0x%x\n",pos, pos + cur->size-1,cur->size); 257 printf(" \t: 0x%x - 0x%x size 0x%04x entry 0x%x\n",pos, pos + cur->size-1,cur->size,cur->entry+cur->location);
252 #ifdef DEBUG 258 #ifdef DEBUG
253 printf(" \t: 0x%x \n",cur->location); 259 printf(" \t: 0x%x \n",cur->location);
254 printf(" \t: 0x%x - 0x%x : 0x%lx \n",pos, pos + cur->size, ftell(romfile)+start); 260 printf(" \t: 0x%x - 0x%x : 0x%lx \n",pos, pos + cur->size, ftell(romfile)+start);
255 #endif 261 #endif
256 pos = pos+cur->size; 262 pos = pos+cur->size;
271 if (1) { 277 if (1) {
272 int vecofs = search_vector(os9p1); 278 int vecofs = search_vector(os9p1);
273 if (vecofs==0) { 279 if (vecofs==0) {
274 printf("can't find vector\n"); 280 printf("can't find vector\n");
275 } 281 }
282 static int perm[] = {0,1,5,4,2,3};
276 for(int i=0;i<6;i++) { 283 for(int i=0;i<6;i++) {
277 fputword(os9p1->location +vecofs+i*4,romfile); 284 fputword(os9p1->location +vecofs+perm[i]*4,romfile);
278 } 285 }
279 int entry_ofs = (m->mod[9]<<8) + m->mod[10]; 286 int entry_ofs = (m->mod[9]<<8) + m->mod[10];
280 fputword( os9p1->location + entry_ofs ,romfile); 287 fputword( os9p1->location + entry_ofs ,romfile);
281 // printf("os9p1 location ofs %0x\n", os9p1->location); 288 // printf("os9p1 location ofs %0x\n", os9p1->location);
282 // printf("vector ofs %0x\n", vecofs); 289 // printf("vector ofs %0x\n", vecofs);
329 if ( cur->ioflag ==0) continue; 336 if ( cur->ioflag ==0) continue;
330 cur->location = pos; 337 cur->location = pos;
331 printf("mod "); 338 printf("mod ");
332 printOs9Str(cur->name); 339 printOs9Str(cur->name);
333 fwrite(cur->mod, cur->size, 1, romfile); 340 fwrite(cur->mod, cur->size, 1, romfile);
334 printf(" \t: 0x%x - 0x%x size 0x%x\n",pos, pos + cur->size-1, cur->size); 341 printf(" \t: 0x%x - 0x%x size 0x%04x entry 0x%x\n",pos, pos + cur->size-1, cur->size, cur->entry+cur->location);
335 #ifdef DEBUG 342 #ifdef DEBUG
336 printf(" \t: 0x%x \n",cur->location); 343 printf(" \t: 0x%x \n",cur->location);
337 printf(" \t: 0x%x - 0x%x : 0x%lx \n",pos, pos + cur->size, ftell(romfile)+start); 344 printf(" \t: 0x%x - 0x%x : 0x%lx \n",pos, pos + cur->size, ftell(romfile)+start);
338 #endif 345 #endif
339 pos += cur->size; 346 pos += cur->size;