delay = c_std_delay*(delayval.get_int_value());
delay = 400*(delayval.get_int_value());
void Scheduled_usecode::handle_event	(	unsigned long curtime,		// Current time of day.	long udata			// ->usecode machine.	)	{	Usecode_internal *usecode = (Usecode_internal *) udata;	Game_window *gwin = usecode->gwin;	int delay = c_std_delay;		// Trying default delay.	int do_another = 1;			// Flag to keep going.	int opcode;					// If a 1 follows, keep going.	for (; i < cnt && ((opcode = arrval.get_elem(i).get_int_value()) 						== 0x1 || do_another); i++)		{		do_another = 0;		switch (opcode)			{		case 0x1:		// Means keep going without painting.			do_another = 1;			gwin->set_painted();	// Want to paint when done.			break;		case 0x0b:		// ?? 2 parms, 1st one < 0.			{		// Loop(offset, cnt).			Usecode_value& cntval = arrval.get_elem(i + 2);			int cnt = cntval.get_int_value();			if (cnt <= 0)					// Done.				i += 2;			else				{	// Decr. and loop.				cntval = Usecode_value(cnt - 1);				Usecode_value& offval = arrval.get_elem(i + 1);				i += offval.get_int_value() - 1;				do_another = 1;				}			break;			}		case 0x0c:		// Loop with 3 parms.???			{		// Loop(offset, cnt1, cnt2?).++++				//+++ guessing: loop cnt1 each round. use cnt2 as loop var.				//This is necessary for loop nesting.				//(used in mining machine, orb of the moons)				// maybe cnt1 and cnt2 should be swapped... not sure			do_another = 1;			Usecode_value& cntval = arrval.get_elem(i + 3);			Usecode_value& origval = arrval.get_elem(i + 2);			int cnt = cntval.get_int_value();			int orig = origval.get_int_value();			if (cnt > orig) { // ++++ First pass? Set to orig or not?				cntval = origval;				cnt = orig;			}			if (cnt <= 0) {					// Done.				i += 3;				cntval = origval; // restore counter			} else				{	// Decr. and loop.				cntval = Usecode_value(cnt - 1);				Usecode_value& offval = arrval.get_elem(i + 1);				i += offval.get_int_value() - 1;				}			break;			}		case 0x23:		// ?? Always appears first.					// Maybe means "don't let					//    intrinsic 5c stop it".			no_halt = 1;	// PURE GUESS.			do_another = 1;			break;		case 0x27:		// ?? 1 parm. Guessing:			{		//   delay before next instruction.			Usecode_value& delayval = arrval.get_elem(++i);					// ?? Guessing at time.// NOTE: Changing this can have a major impact!//			delay = 250*(delayval.get_int_value());// Changed Jul. 30, 2001 to:			delay = c_std_delay*(delayval.get_int_value());			break;					}#if 0		case 0x2c:		// Quit if there's already scheduled					//   code for item?					// Or supercede the existing one?			break;#endif		case 0x2d:		// Remove itemref.			usecode->remove_item(obj);			break;		case 0x39:		// Rise?  (For flying carpet.			{			Tile_coord t = obj->get_abs_tile_coord();			if (t.tz < 10)				t.tz++;			obj->move(t);			break;			}		case 0x38:		// Descend?			{			Tile_coord t = obj->get_abs_tile_coord();			if (t.tz > 0)				t.tz--;			obj->move(t);			break;			}		case 0x46:			{		// Set frame.			Usecode_value& fval = arrval.get_elem(++i);			usecode->set_item_frame(objval, fval);			break;			}		case 0x48:		// Guessing:  activate egg.			activate_eggs(usecode);			break;		case 0x4d:		// ??Also show next frame?			{			int nframes = gwin->get_shapes().get_num_frames(							obj->get_shapenum());			if (obj->get_framenum() < nframes) {				Usecode_value fval(1+obj->get_framenum());				usecode->set_item_frame(objval, fval);			}			break;			}		case 0x4e:		// Show next frame.			{			int nframes = gwin->get_shapes().get_num_frames(							obj->get_shapenum());			Usecode_value fval((1 + obj->get_framenum())%nframes);			usecode->set_item_frame(objval, fval);			break;			}		case 0x50:		// Guessing: Show prev. frame.			{			int nframes = gwin->get_shapes().get_num_frames(							obj->get_shapenum());			int pframe = obj->get_framenum() - 1;			Usecode_value fval((pframe + nframes)%nframes);			usecode->set_item_frame(objval, fval);			break;			}		case 0x52:		// Say string.			{			Usecode_value& strval = arrval.get_elem(++i);			usecode->item_say(objval, strval);			break;			}		case 0x54:		// Unknown.		        cout << "Und sched. opcode " << hex << 				"0x" << setfill((char)0x30) << setw(2) 						<< opcode << std::dec << endl;			++i;		// Takes 1 parameter!			break;		case 0x55:		// Call?			{			Usecode_value& val = arrval.get_elem(++i);			int fun = val.get_int_value();					// REALLY guessing (for Forge):			Usecode_internal::Usecode_events ev = 					Usecode_internal::internal_exec;			if (obj && obj->is_egg() && 				((Egg_object *)obj)->get_type() ==			    				Egg_object::usecode)				{				ev = Usecode_internal::egg_proximity;				cout << "0x55:  guessing with egg" << endl;				}			usecode->call_usecode(fun, obj, ev);			break;			}		case 0x56:		// Play speech track.			{			Usecode_value& val = arrval.get_elem(++i);			int track = val.get_int_value();			if (track >= 0)				Audio::get_ptr()->start_speech(track);			}		case 0x58:		// Play sound effect!			{			Usecode_value& val = arrval.get_elem(++i);			Audio::get_ptr()->play_sound_effect(val.get_int_value());					// Or play sound effect??			break;			}		case 0x59:		// Parm. is dir. (0-7).  0=north?			{					// Look in that dir.			Usecode_value& val = arrval.get_elem(++i);					// It may be 0x3x.  Face dir?			int dir = val.get_int_value()&7;			obj->set_usecode_dir(dir);			Usecode_value v(obj->get_dir_framenum(							dir, Actor::standing));			usecode->set_item_frame(objval, v);			frame_index = 0;// Reset walking frame index.			break;			}		default:					// Frames with dir.  U7-verified!			if (opcode >= 0x61 && opcode <= 0x70)				{	// But don't show empty frames.				Usecode_value v(obj->get_dir_framenum(					obj->get_usecode_dir(), 					opcode - 0x61));				usecode->set_item_frame(objval, v, 1);				}					// ++++Guessing:			else if (opcode >= 0x30 && opcode < 0x38)					// Step in dir. opcode&7.				step(usecode, opcode&7);			else				{			        cout << "Und sched. opcode " << hex << 					"0x" << setfill((char)0x30) << setw(2) << opcode << std::dec << endl;				do_another = 1; // Don't let it delay us.				}			break;			}		}	if (i < cnt)			// More to do?		{		gwin->get_tqueue()->add(curtime + delay, this, udata);		return;		}	if (count == 1 &&		// Last one?  GUESSING:	    objpos.tx != -1)		// And valid pos.	{		usecode->activate_cached(objpos);	}	delete this;			// Hope this is safe.	}