Free Hero Mesh

Diff
Login
This is a mirror of the main repository for Free Hero Mesh. New tickets and changes will not be accepted at this mirror.

Differences From Artifact [fc5168bbe3]:

To Artifact [9fbf2afe75]:


443
444
445
446
447
448
449
450

451
452
453
454
455
456
457
443
444
445
446
447
448
449

450
451
452
453
454
455
456
457







-
+







  }
  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;
  int i,j,x,y,n,q,r;
  i=fgetc(stdin);
  i|=fgetc(stdin)<<8;
  levelid[ord]=i;
  sprintf(nam,"%d.LVL",i);
  hamarc_begin(fp);
  fputc(0,fp); fputc(0,fp); // Level version
  fputc(ord,fp); fputc(ord>>8,fp); // Level code
481
482
483
484
485
486
487
488

489
490
491
492
493
494
495
496
497


498
499
500
501
502
503
504
481
482
483
484
485
486
487

488
489
490
491
492
493
494
495


496
497
498
499
500
501
502
503
504







-
+







-
-
+
+







    }
  }
  fread(mru,1,32,stdin); // Skip border colours
  fread(buf,1,2,stdin); // Skip border colours
  mru[0x04]=mru[0x14]=255;
  n=fgetc(stdin);
  n|=fgetc(stdin)<<8;
  x=q=0;
  x=q=r=0;
  y=1;
  // Free Hero Mesh level format for objects:
  //   * bit flags (or 0xFF for end):
  //     bit7 = MRU (omit everything but position)
  //     bit6 = Next position
  //     bit5 = New X position
  //     bit4 = New Y position
  //     bit3 = Has MiscVars
  //     bit2-bit0 = LastDir (should be RLE in case of MRU?)
  //     bit3 = Has MiscVars (RLE in case of MRU)
  //     bit2-bit0 = LastDir (RLE in case of MRU)
  //   * new X if applicable
  //   * new Y if applicable
  //   * class (one-based; add 0x8000 for image 0) (two bytes)
  //   * image (one byte)
  //   * data types (if has MiscVars):
  //     bit7-bit6 = How many (0=has Misc2 and Misc3, not Misc1)
  //     bit5-bit4 = Misc3 type
518
519
520
521
522
523
524
525
526
527







528
529
530
531
532
533
534
518
519
520
521
522
523
524

525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540







-


+
+
+
+
+
+
+







    if(q<32 && !memcmp(mru+q,buf,16)) {
      i|=0x80;
    } else {
      i|=buf[4]&7;
      if(buf[5] || memcmp(buf+10,"\0\0\0\0\0\0",6)) i|=0x08;
      if(q<32) memcpy(mru+q,buf,16);
    }
    fputc(i,fp);
    x=buf[6];
    y=buf[8];
    if(i==0xC0) {
      if(++r==16) fputc(r+0xBF,fp),r=0;
      continue;
    } else if(r) {
      fputc(r+0xBF,fp),r=0;
    }
    fputc(i,fp);
    if(i&0x20) fputc(x,fp);
    if(i&0x10) fputc(y,fp);
    if(i<0x80) {
      if(buf[2]) {
        fwrite(buf,1,3,fp);
      } else {
        fputc(*buf,fp);
563
564
565
566
567
568
569

570
571
572
573
574
575
576
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583







+







          fputc(j+236,fp); fputc((j+236)>>8,fp);
        } else {
          fwrite(buf+14,1,2,fp);
        }
      }
    }
  }
  if(r) fputc(r+0xBF,fp);
  fputc(255,fp); // End of objects
  n=fgetc(stdin);
  n|=fgetc(stdin)<<8;
  while(n--) {
    i=fgetc(stdin);
    i|=fgetc(stdin)<<8;
    // fputc(17,fp); // Select proportional font