Free Hero Mesh

Check-in [33593e7ab7]
Login
This is a mirror of the main repository for Free Hero Mesh. New tickets and changes will not be accepted at this mirror.
Overview
Comment:Correct and complete the implementation of arrays in the converter
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 33593e7ab7fce6e2af31979a4a62f7da5d0a7c3d
User & Date: user on 2021-02-25 05:36:38
Other Links: manifest | tags
Context
2021-02-25
07:04
Correct the array dimensions and complete the implementation of arrays. Some levels of FALLING still don't work, but at least some of these (such as level 9) are not due to arrays. check-in: e7e0e8408f user: user tags: trunk
05:36
Correct and complete the implementation of arrays in the converter check-in: 33593e7ab7 user: user tags: trunk
03:28
Implement the {append} macro; also start to implement arrays in the conversion check-in: c4bb0e3270 user: user tags: trunk
Changes

Modified mbtofhm.c from [86b6c496cf] to [3feb2569bb].

42
43
44
45
46
47
48

49
50
51
52
53
54
55
  unsigned short nmsgs;
  unsigned char**msgscode;
  short defpic;
} ClassInfo;
static int nusermsg;
static char**usermsg;
static ClassInfo*class[512];


// Levels
static int nlevels;
static unsigned short*levelid;

// Sounds
static int nsounds;







>







42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
  unsigned short nmsgs;
  unsigned char**msgscode;
  short defpic;
} ClassInfo;
static int nusermsg;
static char**usermsg;
static ClassInfo*class[512];
static char has_array;

// Levels
static int nlevels;
static unsigned short*levelid;

// Sounds
static int nsounds;
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
      case 51:
        fprintf(fp," 0x%02X",*op);
        break;
      case 52:
        fprintf(fp," 0x%X",op[1]|(op[2]<<8)|(op[3]<<16)|(op[4]<<24));
        len+=4; break;
      case 53:
        if(*op==5) fprintf(fp," %ld",puzzlesetnumber);
        else SubOpcode("Level","-1","0","1","0","0","MoveNumber");
        break;
      case 54:
        if(*op==255) fprintf(fp," XDir");
        else fprintf(fp," %s XDir",direction[*op]);
        break;
      case 55:
        if(*op==255) fprintf(fp," ,XDir");







<
|







585
586
587
588
589
590
591

592
593
594
595
596
597
598
599
      case 51:
        fprintf(fp," 0x%02X",*op);
        break;
      case 52:
        fprintf(fp," 0x%X",op[1]|(op[2]<<8)|(op[3]<<16)|(op[4]<<24));
        len+=4; break;
      case 53:

        SubOpcode("Level","-1","0","1","0","{PuzzleSetNumber}","MoveNumber");
        break;
      case 54:
        if(*op==255) fprintf(fp," XDir");
        else fprintf(fp," %s XDir",direction[*op]);
        break;
      case 55:
        if(*op==255) fprintf(fp," ,XDir");
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751



752
753
754


755
756

757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
      case 111:
        fprintf(fp," ,JumpTo .");
        st=0; break;
      case 112: case 113:
        fprintf(fp," Sound");
        st=0; break;
      case 114:
        if(op[1]) {
          SubOpcode(";","SetArray","InitArray");
        } else {
          x=0;
          y=nlbl;
          z=-1;
          while(y) {
            if(lbl[x+8]|(lbl[x+9]<<8))==ofs>>1) break;



            y--;
            x+=10;
          }


          if(z!=-1) fprintf(fp,"{Array @%s.%s %d %d}",cname,lbl+z*10,op[1],op[3]);
          len+=4*(op[1]*op[3]+1);

        }
        st=0; break;
      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;







|






|
>
>
>



>
>
|
|
>









|







737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
      case 111:
        fprintf(fp," ,JumpTo .");
        st=0; break;
      case 112: case 113:
        fprintf(fp," Sound");
        st=0; break;
      case 114:
        if(*op) {
          SubOpcode(";","SetArray","InitArray");
        } else {
          x=0;
          y=nlbl;
          z=-1;
          while(y) {
            if((lbl[x+8]|(lbl[x+9]<<8))==(ofs>>1)) {
              z=x;
              break;
            }
            y--;
            x+=10;
          }
          x=op[1]|(op[2]<<8);
          y=op[3]|(op[4]<<8);
          if(z!=-1) fprintf(fp,"{Array @%s.%s %d %d}",cname,lbl+z,x,y);
          len+=4*(x*y+1);
          has_array=1;
        }
        st=0; break;
      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)",";UpdateScreen");
        st=0; break;
      case 130:
        fprintf(fp," FlushClass");
        st=0; break;
      case 131:
        fprintf(fp," ,FlushObj");
        st=0; break;
799
800
801
802
803
804
805
806


807
808
809
810
811
812
813
static inline void out_classes(void) {
  FILE*fp;
  ClassInfo*c;
  int i,j,n,o;
  sprintf(nam,"%s.class",basename);
  fp=fopen(nam,"w");
  if(!fp) fatal("Cannot open file '%s' for writing\n",nam);
  fprintf(fp,"; Note: This file was automatically converted.\n; Remove this notice if you have corrected it.\n");


  for(n=0;n<512;n++) if(c=class[n]) {
    fprintf(fp,"\n($%s Compatible",c->name);
    if(c->attr[1]&1) fprintf(fp," Input");
    if(c->attr[1]&128) fprintf(fp," Player");
    if(!strcmp(c->name,"Quiz")) fprintf(fp," Quiz");
    fprintf(fp,"\n  (Image");
    for(j=i=0;i<c->npic;i++) {







|
>
>







805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
static inline void out_classes(void) {
  FILE*fp;
  ClassInfo*c;
  int i,j,n,o;
  sprintf(nam,"%s.class",basename);
  fp=fopen(nam,"w");
  if(!fp) fatal("Cannot open file '%s' for writing\n",nam);
  fprintf(fp,"; Note: This file was automatically converted.\n; Remove this notice if you have corrected it.\n\n");
  fprintf(fp,"{define \"Array\" {append \"array_defs\" (\\1 Array \\2 \\3)}}\n");
  fprintf(fp,"{define \"PuzzleSetNumber\" %lu}\n",puzzlesetnumber);
  for(n=0;n<512;n++) if(c=class[n]) {
    fprintf(fp,"\n($%s Compatible",c->name);
    if(c->attr[1]&1) fprintf(fp," Input");
    if(c->attr[1]&128) fprintf(fp," Player");
    if(!strcmp(c->name,"Quiz")) fprintf(fp," Quiz");
    fprintf(fp,"\n  (Image");
    for(j=i=0;i<c->npic;i++) {
926
927
928
929
930
931
932

933
934
935
936
937
938
939
      else fprintf(fp,"#???%d",j);
      class_codes(fp,c->msgscode[i]+4,o,c->msgslbl,c->nmsgslbl,c->subslbl,c->nsubslbl,c->vars,c->name);
      o+=(c->msgscode[i][2]<<1)|(c->msgscode[i][3]<<9);
      fprintf(fp,"\n  )\n");
    }
    fprintf(fp,")\n");
  }

  fclose(fp);
}

static void one_level(FILE*fp,int ord) {
  unsigned char buf[16];
  unsigned char mru[32];
  int i,j,x,y,n,q,r;







>







934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
      else fprintf(fp,"#???%d",j);
      class_codes(fp,c->msgscode[i]+4,o,c->msgslbl,c->nmsgslbl,c->subslbl,c->nsubslbl,c->vars,c->name);
      o+=(c->msgscode[i][2]<<1)|(c->msgscode[i][3]<<9);
      fprintf(fp,"\n  )\n");
    }
    fprintf(fp,")\n");
  }
  if(has_array) fprintf(fp,"\n{array_defs}\n");
  fclose(fp);
}

static void one_level(FILE*fp,int ord) {
  unsigned char buf[16];
  unsigned char mru[32];
  int i,j,x,y,n,q,r;