if (gwin->get_mode() == Game_window::conversation) { gwin->set_mode(Game_window::normal); gwin->paint(); } delete this;
win->copy(sx, sy, w, h, dx, dy); gwin->set_painted(); gwin->show();  win->copy(dx, dy, w, h, sx, sy); if (++i < len) gwin->get_tqueue()->add(curtime + 100, this, udata); else delete this;
void Scheduled_usecode::handle_event	(	unsigned long curtime,		// Current time of day.	long udata			// ->usecode machine.	)	{	Usecode_machine *usecode = (Usecode_machine *) udata;	Game_window *gwin = usecode->gwin;	int delay = 200;			// Trying default delay.	int do_another = 1;			// Flag to keep going.	for ( ; i < cnt && do_another; i++)		{		do_another = 0;		Usecode_value& opval = arrval.get_elem(i);		int opcode = opval.get_int_value();		switch (opcode)			{		case 0x01:		// ??			break;		case 0x0b:		// ?? 2 parms, 1st one < 0.			{		// Loop(offset, cnt).			do_another = 1;			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;				}			break;			}#if 1		case 0x0c:		// Loop with 3 parms.???			{		// Loop(offset, cnt1, cnt2?).			do_another = 1;			Usecode_value& cntval = arrval.get_elem(i + 2);			int cnt = cntval.get_int_value();			if (cnt <= 0)					// Done.				i += 3;			else				{	// Decr. and loop.				cntval = Usecode_value(cnt - 1);				Usecode_value& offval = arrval.get_elem(i + 1);				i += offval.get_int_value() - 1;				}			break;			}#endif		case 0x23:		// ??			break;		case 0x27:		// ?? 1 parm. Guessing:			{		//   delay before next instruction.			Usecode_value& delayval = arrval.get_elem(++i);					// ?? Guessing at time.			delay = 200*(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 0x46:			{		// Set frame.			Usecode_value& fval = arrval.get_elem(++i);			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 0x55:		// Call?			{			Usecode_value& val = arrval.get_elem(++i);			usecode->call_usecode(val.get_int_value(), obj, 					Usecode_machine::internal_exec);			break;			}		case 0x58:		// ?? 1 parm, fairly large byte.			i++;		// Perhaps timing??			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 direction.			if (opcode >= 0x60 && opcode <= 0x7f)				{				Usecode_value v(obj->get_dir_framenum(					obj->get_usecode_dir(), opcode));				usecode->set_item_frame(objval, v);				}					// ++++Guessing:			else if (opcode >= 0x30 && opcode <= 0x38)				{	// Step in dir. opcode&7.????				static short offset[16] = {					-1,0, -1,1, 1,0, 1,-1, 0,-1,					-1,-1, -1,0, -1,1 };				Actor *act = usecode->as_actor(obj);				if (!act)					break;				int dir = opcode&7;				Frames_sequence *frames = act->get_frames(dir);					// Get frame (updates frame_index).				int frame = frames->get_next(frame_index);				Tile_coord tile = act->get_abs_tile_coord() +				  	Tile_coord(offset[2*dir],							offset[2*dir + 1], 0);				act->step(tile, frame);				gwin->paint_dirty();				gwin->show();				}			else			        cout << "Unhandled sched. opcode " << hex << 			"0x" << setfill(0x30) << setw(2) << opcode << endl;			break;			}		}	if (i < cnt)			// More to do?		{		gwin->get_tqueue()->add(curtime + delay, this, udata);		return;		}					// Don't get stuck in conv. mode.	if (gwin->get_mode() == Game_window::conversation)		{		gwin->set_mode(Game_window::normal);		gwin->paint();		}	delete this;			// Hope this is safe.	}