Free Hero Mesh

Check-in [e7e0e8408f]
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 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.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: e7e0e8408fefb2a74ac66032ac75ad8727f8d714
User & Date: user on 2021-02-25 07:04:12
Other Links: manifest | tags
Context
2021-02-26
23:26
Remove keyicons directory from the manifest to shorten it. (It can be recovered from previous versions, or from keyicons.xbm file, if needed.) check-in: 20a441dc4f user: user tags: trunk
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
Changes

Modified class.c from [f9db23fff0] to [faac25474f].

907
908
909
910
911
912
913
914

915
916
917
918

919
920
921
922
923
924
925
907
908
909
910
911
912
913

914
915
916
917

918
919
920
921
922
923
924
925







-
+



-
+







  Uint32 x,y,z;
  nxttok();
  if(tokent!=TF_INT) ParseError("Number expected\n");
  x=tokenv;
  nxttok();
  if(tokent!=TF_INT) ParseError("Number expected\n");
  y=tokenv;
  if(x<1 || x>64 || y<1 || y>255) ParseError("Array dimension out of range\n");
  if(x<1 || x>64 || y<1 || y>1024) ParseError("Array dimension out of range\n");
  z=array_size;
  if(z+x*y>0xFFFE) ParseError("Out of array memory\n");
  array_size+=x*y;
  return z|(y<<16)|(x<<24);
  return z|((y-1)<<16)|((x-1)<<26);
}

static void begin_label_stack(void) {
  labelstack=0;
  labelptr=malloc(0x8000*sizeof(Uint16));
  if(!labelptr) fatal("Allocation failed\n");
  memset(labelptr,255,0x8000*sizeof(Uint16));

Modified class.doc from [31119da0f4] to [9dc0f9c081].

214
215
216
217
218
219
220
221

222
223
224
225



226
227
228
229
230
231
232
214
215
216
217
218
219
220

221
222



223
224
225
226
227
228
229
230
231
232







-
+

-
-
-
+
+
+








($<name> <definitions...>)
  Define a class. See the section about class definitions for details.

(@<name> <value>)
  Define a global variable and its initial value.

(@<name> Array <columns> <rows>)
(@<name> Array <rows> <columns>)
  Define a global variable whose value is a reference to a new array, with
  the specified dimensions. The maximum number of columns is 64, and the
  maximum number of rows is 255, and he maximum number of cells in all
  arrays in total is 65534.
  the specified dimensions. The maximum number of rows is 64, and the
  maximum number of columns is 1024, and the maximum number of cells in
  all arrays in total is 65534.

(<message> <code...>)
  Defines a default message code for all classes which do not specify
  their own code for this message.


=== Class definitions ===

Modified exec.c from [68326341a7] to [549a5eaa37].

1125
1126
1127
1128
1129
1130
1131



























1132
1133
1134
1135
1136
1137
1138
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







  }
  inventory=realloc(inventory,++ninventory*sizeof(Inventory));
  if(!inventory) fatal("Allocation failed\n");
  inventory[i].class=cl.u;
  inventory[i].image=im.u;
  inventory[i].value=va.u;
}

static void v_init_array(Value ar,Value v) {
  Uint32 s,n;
  if(ar.t!=TY_ARRAY) Throw("Type mismatch");
  s=ar.u&0xFFFF;
  n=((ar.u>>16)&0x3FF)+1;
  n*=((ar.u>>26)&0x3F)+1;
  while(n--) array_data[s++]=v;
}

static Value v_get_array(Value ar,Uint32 x,Uint32 y) {
  Uint32 s;
  if(ar.t!=TY_ARRAY) Throw("Type mismatch");
  s=ar.u&0xFFFF;
  if(y>((ar.u>>16)&0x3FF) || x>((ar.u>>26)&0x3F)) Throw("Array index out of bounds");
  s+=x+y+((ar.u>>26)&0x3F)*y;
  return array_data[s];
}

static void v_set_array(Value ar,Uint32 x,Uint32 y,Value v) {
  Uint32 s;
  if(ar.t!=TY_ARRAY) Throw("Type mismatch");
  s=ar.u&0xFFFF;
  if(y>((ar.u>>16)&0x3FF) || x>((ar.u>>26)&0x3F)) Throw("Array index out of bounds");
  s+=x+y+((ar.u>>26)&0x3F)*y;
  array_data[s]=v;
}

static void v_set_popup(Uint32 from,int argc) {
  const unsigned char*t;
  const unsigned char*u;
  sqlite3_str*s;
  Value v;
  int argi=1;
1415
1416
1417
1418
1419
1420
1421

1422
1423
1424
1425
1426
1427
1428
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456







+







    case OP_FLUSHCLASS: NoIgnore(); StackReq(1,0); t1=Pop(); if(t1.t==TY_CLASS) flush_class(t1.u); else if(t1.t==TY_NUMBER && t1.s==-1) flush_all(); else if(t1.t) Throw("Type mismatch"); break;
    case OP_FLUSHOBJ: NoIgnore(); flush_object(obj); break;
    case OP_FLUSHOBJ_C: NoIgnore(); StackReq(1,0); i=v_object(Pop()); if(i!=VOIDLINK) flush_object(i); break;
    case OP_FOR: NoIgnore(); StackReq(3,1); t3=Pop(); t2=Pop(); t1=Pop(); ptr=v_for(code,ptr,t1,t2,t3); break;
    case OP_FROM: StackReq(0,1); Push(OVALUE(msgvars.from)); break;
    case OP_GE: StackReq(2,1); t2=Pop(); t1=Pop(); Push(NVALUE(v_unsigned_greater(t2,t1)?0:1)); break;
    case OP_GE_C: StackReq(2,1); t2=Pop(); t1=Pop(); Push(NVALUE(v_signed_greater(t2,t1)?0:1)); break;
    case OP_GETARRAY: StackReq(3,1); t3=Pop(); Numeric(t3); t2=Pop(); Numeric(t2); t1=Pop(); Push(v_get_array(t1,t2.u,t3.u)); break;
    case OP_GETINVENTORY: StackReq(2,2); t2=Pop(); t1=Pop(); v_get_inventory(t1,t2); break;
    case OP_GOTO: ptr=code[ptr]; break;
    case OP_GT: StackReq(2,1); t2=Pop(); t1=Pop(); Push(NVALUE(v_unsigned_greater(t1,t2)?1:0)); break;
    case OP_GT_C: StackReq(2,1); t2=Pop(); t1=Pop(); Push(NVALUE(v_signed_greater(t1,t2)?1:0)); break;
    case OP_HARD: StackReq(1,1); j=v_sh_dir(Pop()); Push(NVALUE(o->hard[j])); break;
    case OP_HARD_C: StackReq(2,1); j=v_sh_dir(Pop()); Push(GetVariableOrAttributeOf(hard[j],NVALUE)); break;
    case OP_HARD_E: NoIgnore(); StackReq(2,0); j=v_sh_dir(Pop()); t1=Pop(); Numeric(t1); o->hard[j]=t1.u; break;
1443
1444
1445
1446
1447
1448
1449

1450
1451
1452
1453
1454
1455
1456
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485







+







    case OP_IN: StackReq(2,1); i=v_in(); Push(NVALUE(i?1:0)); break;
    case OP_INERTIA: StackReq(0,1); Push(NVALUE(o->inertia)); break;
    case OP_INERTIA_C: StackReq(1,1); Push(GetVariableOf(inertia,NVALUE)); break;
    case OP_INERTIA_E: StackReq(1,0); t1=Pop(); Numeric(t1); o->inertia=t1.u; break;
    case OP_INERTIA_E16: StackReq(1,0); t1=Pop(); Numeric(t1); o->inertia=t1.u&0xFFFF; break;
    case OP_INERTIA_EC: StackReq(2,0); t1=Pop(); Numeric(t1); i=v_object(Pop()); if(i!=VOIDLINK) objects[i]->inertia=t1.u; break;
    case OP_INERTIA_EC16: StackReq(2,0); t1=Pop(); Numeric(t1); i=v_object(Pop()); if(i!=VOIDLINK) objects[i]->inertia=t1.u&0xFFFF; break;
    case OP_INITARRAY: StackReq(2,0); t2=Pop(); t1=Pop(); v_init_array(t1,t2); break;
    case OP_INT16: StackReq(0,1); Push(NVALUE(code[ptr++])); break;
    case OP_INT32: StackReq(0,1); t1=UVALUE(code[ptr++]<<16,TY_NUMBER); t1.u|=code[ptr++]; Push(t1); break;
    case OP_INTMOVE: NoIgnore(); StackReq(1,1); t1=Pop(); Numeric(t1); Push(NVALUE(move_dir(obj,obj,t1.u))); break;
    case OP_INTMOVE_C: NoIgnore(); StackReq(2,1); t1=Pop(); Numeric(t1); i=v_object(Pop()); if(i==VOIDLINK) Push(NVALUE(0)); else Push(NVALUE(move_dir(obj,i,t1.u))); break;
    case OP_INTMOVE_D: NoIgnore(); StackReq(1,0); t1=Pop(); Numeric(t1); move_dir(obj,obj,t1.u); break;
    case OP_INTMOVE_CD: NoIgnore(); StackReq(2,0); t1=Pop(); Numeric(t1); i=v_object(Pop()); if(i!=VOIDLINK) move_dir(obj,i,t1.u); break;
    case OP_INVISIBLE: StackReq(0,1); if(o->oflags&OF_INVISIBLE) Push(NVALUE(1)); else Push(NVALUE(0)); break;
1545
1546
1547
1548
1549
1550
1551

1552
1553
1554
1555
1556
1557
1558
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588







+







    case OP_SEND_C: StackReq(4,1); t4=Pop(); t3=Pop(); t2=Pop(); t1=Pop(); Push(v_send_message(obj,t1,t2,t3,t4,NVALUE(0))); break;
    case OP_SEND_D: StackReq(3,0); t4=Pop(); t3=Pop(); t2=Pop(); v_send_self(obj,t2,t3,t4,NVALUE(0)); break;
    case OP_SEND_CD: StackReq(4,0); t4=Pop(); t3=Pop(); t2=Pop(); t1=Pop(); v_send_message(obj,t1,t2,t3,t4,NVALUE(0)); break;
    case OP_SENDEX: StackReq(4,1); t5=Pop(); t4=Pop(); t3=Pop(); t2=Pop(); Push(v_send_self(obj,t2,t3,t4,t5)); break;
    case OP_SENDEX_C: StackReq(5,1); t5=Pop(); t4=Pop(); t3=Pop(); t2=Pop(); t1=Pop(); Push(v_send_message(obj,t1,t2,t3,t4,t5)); break;
    case OP_SENDEX_D: StackReq(4,0); t5=Pop(); t4=Pop(); t3=Pop(); t2=Pop(); v_send_self(obj,t2,t3,t4,t5); break;
    case OP_SENDEX_CD: StackReq(5,0); t5=Pop(); t4=Pop(); t3=Pop(); t2=Pop(); t1=Pop(); v_send_message(obj,t1,t2,t3,t4,t5); break;
    case OP_SETARRAY: StackReq(4,0); t4=Pop(); t3=Pop(); Numeric(t3); t2=Pop(); Numeric(t2); t1=Pop(); v_set_array(t1,t2.u,t3.u,t4); break;
    case OP_SETINVENTORY: StackReq(3,0); t3=Pop(); t2=Pop(); t1=Pop(); v_set_inventory(t1,t2,t3); break;
    case OP_SHAPE: StackReq(0,1); Push(NVALUE(o->shape)); break;
    case OP_SHAPE_C: StackReq(1,1); Push(GetVariableOrAttributeOf(shape,NVALUE)); break;
    case OP_SHAPE_E: NoIgnore(); StackReq(1,0); t1=Pop(); Numeric(t1); o->shape=t1.u; break;
    case OP_SHAPE_EC: NoIgnore(); StackReq(2,0); t1=Pop(); Numeric(t1); i=v_object(Pop()); if(i!=VOIDLINK) objects[i]->shape=t1.u; break;
    case OP_SHAPEDIR: StackReq(1,1); j=v_sh_dir(Pop()); Push(NVALUE((o->shape>>(j+j))&3)); break;
    case OP_SHAPEDIR_C: StackReq(2,1); j=v_sh_dir(Pop()); t1=GetVariableOrAttributeOf(sharp[j],NVALUE); t1.u=(t1.u>>(j+j))&3; Push(t1); break;
1934
1935
1936
1937
1938
1939
1940

1941
1942
1943
1944
1945
1946
1947
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978







+







        if(*s==':') traced_obj.t=strtol(s+1,0,10);
        printf("Tracing object <%ld:%ld>\n",(long)traced_obj.u,(long)traced_obj.t);
      } else {
        traced_obj.t=TY_FOR;
      }
    }
  }
  if(array_size) memset(array_data,0,array_size*sizeof(Value));
  memcpy(globals,initglobals,sizeof(globals));
  quiz_obj=NVALUE(0);
  gameover=0;
  changed=0;
  key_ignored=0;
  all_flushed=0;
  lastimage_processing=0;

Modified instruc from [530d389594] to [fccdfbdf14].

253
254
255
256
257
258
259
260

261
262

263
264
265
266
267
268
269
253
254
255
256
257
258
259

260
261

262
263
264
265
266
267
268
269







-
+

-
+







tmark
in
nin
-mbegin

; Arrays
-Array
,GetArray
GetArray
InitArray
,SetArray
SetArray

; Specials
*Function
*Local
*Label
*String
*Int16

Modified instruc.h from [68f9f64e2e] to [9be41debf3].

365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
365
366
367
368
369
370
371

372
373

374
375
376
377
378
379
380







-


-







#define OP_MARK 32946
#define OP_TMARK 32947
#define OP_IN 32948
#define OP_NIN 32949
#define OP_MBEGIN 32950
#define OP_ARRAY 32951
#define OP_GETARRAY 32952
#define OP_GETARRAY_C 35000
#define OP_INITARRAY 32953
#define OP_SETARRAY 32954
#define OP_SETARRAY_C 35002
#define OP_FUNCTION 32955
#define OP_LOCAL 32956
#define OP_LABEL 32957
#define OP_STRING 32958
#define OP_INT16 32959
#define OP_INT32 32960
#define OP_DISPATCH 32961
457
458
459
460
461
462
463
464

465
466
467
468
469
470
471
455
456
457
458
459
460
461

462
463
464
465
466
467
468
469







-
+







{"FLOATED",8389132},
{"FROG",8389383},
{"FlushClass",8421516},
{"FlushObj",8487053},
{"From",8421490},
{"GLASS",8389379},
{"GLISSANT",8389419},
{"GetArray",8487096},
{"GetArray",8421560},
{"GetInventory",8421518},
{"HAWK",8389425},
{"HEARTBEAT",8389407},
{"HIT",8389134},
{"HITBY",8389135},
{"Hard",8618061},
{"Height",9142343},
554
555
556
557
558
559
560
561

562
563
564
565
566
567
568
552
553
554
555
556
557
558

559
560
561
562
563
564
565
566







-
+







{"STOP",8388608},
{"SUBS",8683648},
{"SUNK",8389131},
{"SW",9437189},
{"Self",8421488},
{"Send",10584231},
{"SendEx",10584232},
{"SetArray",8487098},
{"SetArray",8421562},
{"SetInventory",8421545},
{"Shape",8618040},
{"ShapeDir",8618063},
{"Sharp",8618062},
{"Shovable",8618064},
{"Sound",8421546},
{"Stealthy",8618089},

Modified mbtofhm.c from [3feb2569bb] to [b26f53b2f9].

753
754
755
756
757
758
759
760

761
762
763
764
765
766
767
753
754
755
756
757
758
759

760
761
762
763
764
765
766
767







-
+







              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);
          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;