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 [8d61aca3bb]:

To Artifact [43426e4479]:


173
174
175
176
177
178
179




















180
181
182
183
184
185
186
  d->class=o->class;
  d->x=o->x;
  d->y=o->y;
  d->s=o->anim->step[o->anim->vstep];
  d->vtime=o->anim->vtime;
  d->vimage=o->anim->vimage;
}





















void objtrash(Uint32 n) {
  Object*o=objects[n];
  if(!o) return;
  if(!main_options['e']) {
    if(n==traced_obj.u && o->generation==traced_obj.t && main_options['t']) {
      printf("# Object traced at (%d,%d)\n",o->x,o->y);







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
  d->class=o->class;
  d->x=o->x;
  d->y=o->y;
  d->s=o->anim->step[o->anim->vstep];
  d->vtime=o->anim->vtime;
  d->vimage=o->anim->vimage;
}

static void v_animate_dead(Value x,Value y,Value c,Value s,Value e,Value z) {
  DeadAnimation*d;
  if(no_dead_anim || ndeadanim>=0x1000) return;
  if(x.t || y.t || s.t || e.t || z.t || c.t!=TY_CLASS) return;
  if(!z.u || (z.u&~255) || x.u<1 || x.u>pfwidth || y.u<1 || y.u>pfheight) return;
  if(!classes[c.u] || !classes[c.u]->nimages || (classes[c.u]->cflags&(CF_GROUP|CF_NOCLASS2))) return;
  deadanim=realloc(deadanim,(ndeadanim+1)*sizeof(DeadAnimation));
  if(!deadanim) fatal("Allocation failed\n");
  d=deadanim+ndeadanim++;
  d->class=c.u;
  d->x=x.u;
  d->y=y.u;
  d->s.flag=ANI_ONCE;
  d->s.start=s.u;
  d->s.end=e.u;
  d->s.speed=z.u;
  d->vtime=0;
  d->vimage=s.u;
}

void objtrash(Uint32 n) {
  Object*o=objects[n];
  if(!o) return;
  if(!main_options['e']) {
    if(n==traced_obj.u && o->generation==traced_obj.t && main_options['t']) {
      printf("# Object traced at (%d,%d)\n",o->x,o->y);
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
#define GetClassFlagOf(a) t2=Pop(),Push(t2.t==TY_CLASS?NVALUE(classes[t2.u]->cflags&a?1:0):(i=v_object(t2),i==VOIDLINK?NVALUE(0):NVALUE(classes[objects[i]->class]->cflags&a?1:0)))
#define SetFlagOf(a) do{ t2=Pop(); i=v_object(Pop()); if(i!=VOIDLINK) { if(v_bool(t2)) objects[i]->oflags|=a; else objects[i]->oflags&=~a; } }while(0)
#define NotSound(a) do{ if((a).t==TY_SOUND || (a).t==TY_USOUND) Throw("Cannot convert sound to type"); }while(0)
static void execute_program(Uint16*code,int ptr,Uint32 obj) {
  Uint32 i,j;
  Object*o=objects[obj];
  Value t1,t2;
  static Value t3,t4,t5;
  if(StackProtection()) Throw("Call stack overflow");
  // Note about bit shifting: At least when running Hero Mesh in DOSBOX, out of range bit shifts produce zero.
  // I don't know if this is true on all computers that Hero Mesh runs on, though. (Some documents suggest that x86 doesn't work this way)
  // The below code assumes that signed right shifting is available on the computer that Free Hero Mesh runs on.
  for(;;) switch(code[ptr++]) {
    case 0x0000 ... 0x00FF: StackReq(0,1); Push(NVALUE(code[ptr-1])); break;
    case 0x0100 ... 0x01FF: StackReq(0,1); Push(NVALUE(code[ptr-1]-0x200)); break;







|







1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
#define GetClassFlagOf(a) t2=Pop(),Push(t2.t==TY_CLASS?NVALUE(classes[t2.u]->cflags&a?1:0):(i=v_object(t2),i==VOIDLINK?NVALUE(0):NVALUE(classes[objects[i]->class]->cflags&a?1:0)))
#define SetFlagOf(a) do{ t2=Pop(); i=v_object(Pop()); if(i!=VOIDLINK) { if(v_bool(t2)) objects[i]->oflags|=a; else objects[i]->oflags&=~a; } }while(0)
#define NotSound(a) do{ if((a).t==TY_SOUND || (a).t==TY_USOUND) Throw("Cannot convert sound to type"); }while(0)
static void execute_program(Uint16*code,int ptr,Uint32 obj) {
  Uint32 i,j;
  Object*o=objects[obj];
  Value t1,t2;
  static Value t3,t4,t5,t6;
  if(StackProtection()) Throw("Call stack overflow");
  // Note about bit shifting: At least when running Hero Mesh in DOSBOX, out of range bit shifts produce zero.
  // I don't know if this is true on all computers that Hero Mesh runs on, though. (Some documents suggest that x86 doesn't work this way)
  // The below code assumes that signed right shifting is available on the computer that Free Hero Mesh runs on.
  for(;;) switch(code[ptr++]) {
    case 0x0000 ... 0x00FF: StackReq(0,1); Push(NVALUE(code[ptr-1])); break;
    case 0x0100 ... 0x01FF: StackReq(0,1); Push(NVALUE(code[ptr-1]-0x200)); break;
1412
1413
1414
1415
1416
1417
1418

1419
1420
1421
1422
1423
1424
1425
    case 0x3000 ... 0x37FF: NoIgnore(); StackReq(1,0); o->uservars[code[ptr-1]&0x7FF]=Pop(); break;
    case 0x3800 ... 0x38FF: NoIgnore(); StackReq(1,0); globals[code[ptr-1]&0x7FF]=Pop(); break;
    case 0x4000 ... 0x7FFF: StackReq(0,1); Push(CVALUE(code[ptr-1]-0x4000)); break;
    case 0x87E8 ... 0x87FF: StackReq(0,1); Push(NVALUE(1UL<<(code[ptr-1]&31))); break;
    case 0xC000 ... 0xFFFF: StackReq(0,1); Push(MVALUE((code[ptr-1]&0x3FFF)+256)); break;
    case OP_ADD: StackReq(2,1); t2=Pop(); Numeric(t2); t1=Pop(); Numeric(t1); Push(NVALUE(t1.u+t2.u)); break;
    case OP_ANIMATE: StackReq(4,0); t4=Pop(); Numeric(t4); t3=Pop(); Numeric(t3); t2=Pop(); Numeric(t2); t1=Pop(); Numeric(t1); animate(obj,t1.u,t2.u,t3.u,t4.u); break;

    case OP_ARG1: StackReq(0,1); Push(msgvars.arg1); break;
    case OP_ARG1_E: StackReq(1,0); msgvars.arg1=Pop(); break;
    case OP_ARG2: StackReq(0,1); Push(msgvars.arg2); break;
    case OP_ARG2_E: StackReq(1,0); msgvars.arg2=Pop(); break;
    case OP_ARG3: StackReq(0,1); Push(msgvars.arg3); break;
    case OP_ARG3_E: StackReq(1,0); msgvars.arg3=Pop(); break;
    case OP_ARRAYCELL: StackReq(3,1); t3=Pop(); Numeric(t3); t2=Pop(); Numeric(t2); t1=Pop(); Push(v_array_cell(t1,t2.u,t3.u)); break;







>







1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
    case 0x3000 ... 0x37FF: NoIgnore(); StackReq(1,0); o->uservars[code[ptr-1]&0x7FF]=Pop(); break;
    case 0x3800 ... 0x38FF: NoIgnore(); StackReq(1,0); globals[code[ptr-1]&0x7FF]=Pop(); break;
    case 0x4000 ... 0x7FFF: StackReq(0,1); Push(CVALUE(code[ptr-1]-0x4000)); break;
    case 0x87E8 ... 0x87FF: StackReq(0,1); Push(NVALUE(1UL<<(code[ptr-1]&31))); break;
    case 0xC000 ... 0xFFFF: StackReq(0,1); Push(MVALUE((code[ptr-1]&0x3FFF)+256)); break;
    case OP_ADD: StackReq(2,1); t2=Pop(); Numeric(t2); t1=Pop(); Numeric(t1); Push(NVALUE(t1.u+t2.u)); break;
    case OP_ANIMATE: StackReq(4,0); t4=Pop(); Numeric(t4); t3=Pop(); Numeric(t3); t2=Pop(); Numeric(t2); t1=Pop(); Numeric(t1); animate(obj,t1.u,t2.u,t3.u,t4.u); break;
    case OP_ANIMATEDEAD: StackReq(6,0); t6=Pop(); t5=Pop(); t4=Pop(); t3=Pop(); t2=Pop(); t1=Pop(); v_animate_dead(t1,t2,t3,t4,t5,t6); break;
    case OP_ARG1: StackReq(0,1); Push(msgvars.arg1); break;
    case OP_ARG1_E: StackReq(1,0); msgvars.arg1=Pop(); break;
    case OP_ARG2: StackReq(0,1); Push(msgvars.arg2); break;
    case OP_ARG2_E: StackReq(1,0); msgvars.arg2=Pop(); break;
    case OP_ARG3: StackReq(0,1); Push(msgvars.arg3); break;
    case OP_ARG3_E: StackReq(1,0); msgvars.arg3=Pop(); break;
    case OP_ARRAYCELL: StackReq(3,1); t3=Pop(); Numeric(t3); t2=Pop(); Numeric(t2); t1=Pop(); Push(v_array_cell(t1,t2.u,t3.u)); break;