do_another = 0; Usecode_value& opval = arrval.get_elem(i); int opcode = opval.get_int_value(); switch (opcode) { case 0x01: break; case 0x0b: i += 2; break; case 0x23: break; case 0x27: { Usecode_value& delayval = arrval.get_elem(++i);  delay = 200*(delayval.get_int_value()); break; } case 0x2d: usecode->remove_item(obj); break; case 0x46: { Usecode_value& fval = arrval.get_elem(++i); usecode->set_item_frame(objval, fval); break; } case 0x50: break; case 0x52: { Usecode_value& strval = arrval.get_elem(++i); usecode->item_say(objval, strval); break; } case 0x55: { Usecode_value& val = arrval.get_elem(++i); usecode->call_usecode(val.get_int_value(), obj, Usecode_machine::internal_exec); break; } case 0x58: i++; break; case 0x59: {  Usecode_value& val = arrval.get_elem(++i); obj->set_usecode_dir(val.get_int_value()); break; } default:  if (opcode >= 0x60 && opcode <= 0x7f) {  static unsigned char rotate[8] = { 0, 0, 48, 48, 16, 16, 32, 32}; int dir = obj->get_usecode_dir(); Usecode_value v(rotate[dir] + (opcode & 0xf)); usecode->set_item_frame(objval, v); } else printf("Unhanded sched. opcode %02x\n",opcode); break; }
w += dx; sx -= dx; dx = 0;
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.			i += 2;			break;		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;					}		case 0x2d:		// ?? Remove itemref?			usecode->remove_item(obj);			break;		case 0x46:		// ?? 1 parm. This IS a frame.			{		// Set frame?  Pretty sure.			Usecode_value& fval = arrval.get_elem(++i);			usecode->set_item_frame(objval, fval);			break;			}		case 0x50:		// ??			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 a soundfx or sprite??			break;		case 0x59:		// Parm. is dir. (0-7).  0=north?			{					// Look in that dir.			Usecode_value& val = arrval.get_elem(++i);			obj->set_usecode_dir(val.get_int_value());			break;			}		default:					// Frames with direction.			if (opcode >= 0x60 && opcode <= 0x7f)				{	// Looks okay, so far.					// Bit 5=S, Bit6=reflect. on diag.				static unsigned char rotate[8] =					{ 0, 0, 48, 48, 16, 16, 32, 32};				int dir = obj->get_usecode_dir();				Usecode_value v(rotate[dir] + (opcode & 0xf));				usecode->set_item_frame(objval, v);				}			else				printf("Unhanded sched. opcode %02x\n",opcode);			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.	}