225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
|
case OP_LOR: StackReq(2,1); t1=Pop(); t2=Pop(); if(v_bool(t1) || v_bool(t2)) Push(NVALUE(1)); else Push(NVALUE(0)); break;
case OP_LOSELEVEL: gameover=-1; Throw(0); break;
case OP_NIP: StackReq(2,1); t1=Pop(); Pop(); Push(t1); break;
case OP_RET: return;
case OP_SWAP: StackReq(2,2); t1=Pop(); t2=Pop(); Push(t1); Push(t2); break;
case OP_TRACE: StackReq(3,0); trace_stack(obj); break;
case OP_WINLEVEL: key_ignored=0; gameover=1; Throw(0); break;
default: Throw("Internal error: Unrecognized opcode");
}
}
static void trace_message(Uint32 obj) {
Object*o;
const char*s;
if(!traceprefix) {
optionquery[1]=Q_tracePrefix;
traceprefix=xrm_get_resource(resourcedb,optionquery,optionquery,2);
if(!traceprefix) traceprefix="";
}
if(msgvars.msg<256) s=standard_message_names[msgvars.msg]; else s=messages[msgvars.msg-256];
o=msgvars.from==VOIDLINK?0:objects[msgvars.from];
printf("%s%d : %s : %d : %u %u",traceprefix,move_number,s,vstackptr,o?o->generation:0,o?msgvars.from:0);
if(o) printf(" [$%s %d %d]",classes[o->class]->name,o->x,o->y);
o=objects[obj];
printf(" : %u %u [$%s %d %d]",o->generation,obj,classes[o->class]->name,o->x,o->y);
printf(" : %u %u : %u %u\n",msgvars.arg1.t,msgvars.arg1.u,msgvars.arg2.t,msgvars.arg2.u,msgvars.arg3.t,msgvars.arg3.u);
}
static Value send_message(Uint32 from,Uint32 to,Uint16 msg,Value arg1,Value arg2,Value arg3) {
MessageVars saved=msgvars;
Uint16 c=objects[to]->class;
Uint16 p=get_message_ptr(c,msg);
Uint16*code;
|
|
|
|
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
|
case OP_LOR: StackReq(2,1); t1=Pop(); t2=Pop(); if(v_bool(t1) || v_bool(t2)) Push(NVALUE(1)); else Push(NVALUE(0)); break;
case OP_LOSELEVEL: gameover=-1; Throw(0); break;
case OP_NIP: StackReq(2,1); t1=Pop(); Pop(); Push(t1); break;
case OP_RET: return;
case OP_SWAP: StackReq(2,2); t1=Pop(); t2=Pop(); Push(t1); Push(t2); break;
case OP_TRACE: StackReq(3,0); trace_stack(obj); break;
case OP_WINLEVEL: key_ignored=0; gameover=1; Throw(0); break;
default: fprintf(stderr,"Unrecognized opcode 0x%04X at 0x%04X\n",code[ptr-1],ptr-1); Throw("Internal error: Unrecognized opcode");
}
}
static void trace_message(Uint32 obj) {
Object*o;
const char*s;
if(!traceprefix) {
optionquery[1]=Q_tracePrefix;
traceprefix=xrm_get_resource(resourcedb,optionquery,optionquery,2);
if(!traceprefix) traceprefix="";
}
if(msgvars.msg<256) s=standard_message_names[msgvars.msg]; else s=messages[msgvars.msg-256];
o=msgvars.from==VOIDLINK?0:objects[msgvars.from];
printf("%s%d : %s : %d : %u %u",traceprefix,move_number,s,vstackptr,o?o->generation:0,o?msgvars.from:0);
if(o) printf(" [$%s %d %d]",classes[o->class]->name,o->x,o->y);
o=objects[obj];
printf(" : %u %u [$%s %d %d]",o->generation,obj,classes[o->class]->name,o->x,o->y);
printf(" : %u %u : %u %u : %u %u\n",msgvars.arg1.t,msgvars.arg1.u,msgvars.arg2.t,msgvars.arg2.u,msgvars.arg3.t,msgvars.arg3.u);
}
static Value send_message(Uint32 from,Uint32 to,Uint16 msg,Value arg1,Value arg2,Value arg3) {
MessageVars saved=msgvars;
Uint16 c=objects[to]->class;
Uint16 p=get_message_ptr(c,msg);
Uint16*code;
|
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
|
if(key_ignored && changed) return "Invalid use of IgnoreKey";
if(generation_number<=TY_MAXTYPE) return "Too many generations of objects";
return 0;
}
const char*init_level(void) {
if(setjmp(my_env)) return my_error;
if(main_options['t']) printf("[Level %d restarted]",level_id);
gameover=0;
changed=0;
key_ignored=0;
lastimage_processing=0;
vstackptr=0;
move_number=0;
broadcast(0,0,MSG_INIT,NVALUE(0),NVALUE(0),NVALUE(0),0);
broadcast(0,0,MSG_POSTINIT,NVALUE(0),NVALUE(0),NVALUE(0),0);
if(generation_number<=TY_MAXTYPE) return "Too many generations of objects";
return 0;
}
|
|
|
|
|
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
|
if(key_ignored && changed) return "Invalid use of IgnoreKey";
if(generation_number<=TY_MAXTYPE) return "Too many generations of objects";
return 0;
}
const char*init_level(void) {
if(setjmp(my_env)) return my_error;
if(main_options['t']) printf("[Level %d restarted]\n",level_id);
gameover=0;
changed=0;
key_ignored=0;
lastimage_processing=0;
vstackptr=0;
move_number=0;
broadcast(VOIDLINK,0,MSG_INIT,NVALUE(0),NVALUE(0),NVALUE(0),0);
broadcast(VOIDLINK,0,MSG_POSTINIT,NVALUE(0),NVALUE(0),NVALUE(0),0);
if(generation_number<=TY_MAXTYPE) return "Too many generations of objects";
return 0;
}
|