Overview
Comment: | Several bugfixes in class codes converter |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
890d0c173d4c4273cc799f7543fc71ae |
User & Date: | user on 2018-03-18 21:57:26 |
Other Links: | manifest | tags |
Context
2018-03-25
| ||
22:11 | Start writing main program check-in: 6b70d94215 user: user tags: trunk | |
2018-03-18
| ||
21:57 | Several bugfixes in class codes converter check-in: 890d0c173d user: user tags: trunk | |
04:37 | Finally, class codes can be converted now. check-in: fa63933e67 user: user tags: trunk | |
Changes
Modified mbtofhm.c from [625d7a51f8] to [5d0704a0ba].
︙ | ︙ | |||
409 410 411 412 413 414 415 | } } } #define SubOpcode(...) do{ static const char*const ss[]={__VA_ARGS__}; if(*op>=sizeof(ss)/sizeof(*ss)) goto unknown; fprintf(fp," %s",ss[*op]); }while(0) #define PushFlowControl() do{ flowblock[flowptr]=ofs+2+(op[1]<<1)+(op[2]<<9); if(++flowptr==64) fatal("Too many nested flow controls\n"); len+=2; ind+=2; }while(0) | | < > > > > | < < < < | | 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 | } } } #define SubOpcode(...) do{ static const char*const ss[]={__VA_ARGS__}; if(*op>=sizeof(ss)/sizeof(*ss)) goto unknown; fprintf(fp," %s",ss[*op]); }while(0) #define PushFlowControl() do{ flowblock[flowptr]=ofs+2+(op[1]<<1)+(op[2]<<9); if(++flowptr==64) fatal("Too many nested flow controls\n"); len+=2; ind+=2; }while(0) static void class_codes(FILE*fp,const unsigned char*op,int ofs,const unsigned char*lbl,int nlbl,const unsigned char*subs,int nsubs,unsigned char*vars) { static const char*const stdvars[256]={ [0]="Class","Temperature","Shape", [4]="Xloc","Yloc","Dir","Image","Inertia","Misc1","Misc2","Misc3","Misc4","Misc5","Misc6","Misc7", [16]="Arrived","Departed","Arrivals","Departures", [32]="Busy","Invisible","UserSignal","UserState","KeyCleared","IsPlayer","Destroyed","Stealthy","VisualOnly", [48]="Msg","From","Arg1","Arg2", [64]="Density","Volume","Strength","Weight","Distance","Height","Climb", [72]="Hard","Hard","Hard","Hard","Sharp","Sharp","Sharp","Sharp","ShapeDir","ShapeDir","ShapeDir","ShapeDir", [84]="Shovable", }; static const char*const direction[16]={"E","NE","N","NW","W","SW","S","SE","F","LF","L","LB","B","RB","R","RF"}; int flowblock[64]; int flowptr=0; int ind=3; int st=0; int lix=0; int remlbl=nlbl; int x,y,z,len; while(remlbl && (lbl[lix+8]|(lbl[lix+9]<<8))<ofs>>1) { remlbl--; lix+=10; } for(;;) { while(flowptr && flowblock[flowptr-1]==ofs) { --flowptr; fprintf(fp,"\n%*s then",ind-=2,""); } if(*op==102 && op[1]!=1) return; if(!st) st=fprintf(fp,"\n%*s",ind,""); while(remlbl && (lbl[lix+8]|(lbl[lix+9]<<8))==ofs>>1) { fprintf(fp," :%s\n%*s",lbl+lix,ind,""); remlbl--; lix+=10; } len=1; switch(*op++) { case 1 ... 4: if(!stdvars[*op]) goto unknown; |
︙ | ︙ | |||
489 490 491 492 493 494 495 | len+=x=op[1]|(op[2]<<8); for(y=0;y<x;y++) switch(z=op[y+3]) { case 0: break; // do nothing case 1 ... 8: fprintf(fp,"\\%c",z+'0'-1); break; case 10: fprintf(fp,"\\n"); break; case 11: fprintf(fp,"\\l"); break; case 12: fprintf(fp,"\\c"); break; | | < | 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 | len+=x=op[1]|(op[2]<<8); for(y=0;y<x;y++) switch(z=op[y+3]) { case 0: break; // do nothing case 1 ... 8: fprintf(fp,"\\%c",z+'0'-1); break; case 10: fprintf(fp,"\\n"); break; case 11: fprintf(fp,"\\l"); break; case 12: fprintf(fp,"\\c"); break; case 14: fprintf(fp,"\\i%s:%d\\",class[op[y+4]|(op[y+5]<<8)]->name,op[y+6]|(op[y+7]<<8)); y+=4; break; case 15: fprintf(fp,"\\b"); break; case 16: fprintf(fp,"\\q"); break; case 9: case 13: case 17 ... 31: case 127 ... 255: fprintf(fp,"\\x%02X",z); break; case '\\': fputc(z,fp); //fallthrough default: fputc(z,fp); } fputc('"',fp); |
︙ | ︙ | |||
731 732 733 734 735 736 737 | case 126: fprintf(fp," Animate"); st=0; break; case 127: case 128: fprintf(fp," LoseLevel"); st=0; break; case 129: | | | 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 | case 126: fprintf(fp," Animate"); st=0; break; case 127: case 128: fprintf(fp," LoseLevel"); st=0; break; case 129: SubOpcode("WinLevel","LocateMe","IgnoreKey","Misc1 Misc2 Misc3 (PopUp 2)",";"); st=0; break; case 130: fprintf(fp," FlushClass"); st=0; break; case 131: fprintf(fp," FlushObj"); st=0; break; |
︙ | ︙ | |||
885 886 887 888 889 890 891 | } } if(c->subscode[1] || c->subscode[0]>2) { fprintf(fp," (SUBS"); class_codes(fp,c->subscode+2,2,c->subslbl,c->nsubslbl,c->subslbl,c->nsubslbl,c->vars); fprintf(fp,"\n )\n"); } | | | > | 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 | } } if(c->subscode[1] || c->subscode[0]>2) { fprintf(fp," (SUBS"); class_codes(fp,c->subscode+2,2,c->subslbl,c->nsubslbl,c->subslbl,c->nsubslbl,c->vars); fprintf(fp,"\n )\n"); } o=4; for(i=0;i<c->nmsgs;i++) { fprintf(fp," ("); j=c->msgscode[i][0]|(c->msgscode[i][1]<<8); if(j<20) fprintf(fp,"%s",standard_message_names[j]); else if(j-20<nusermsg && usermsg[j-20]) fprintf(fp,"#%s",usermsg[j-20]); else fprintf(fp,"#???%d",j); class_codes(fp,c->msgscode[i]+4,o,c->msgslbl,c->nmsgslbl,c->subslbl,c->nsubslbl,c->vars); o+=(c->msgscode[i][2]<<1)|(c->msgscode[i][3]<<9); fprintf(fp,"\n )\n"); } fprintf(fp,")\n"); } fclose(fp); } |
︙ | ︙ |