w += dx; sx -= dx; dx = 0;
do_another = 0; Usecode_value& opval = arrval.get_elem(i); int opcode = opval.get_int_value(); switch (opcode) { case 0x01: break; case 0x0b: { do_another = 1; Usecode_value& cntval = arrval.get_elem(i + 2); int cnt = cntval.get_int_value(); if (cnt <= 0)  i += 2; else { cntval = Usecode_value(cnt - 1); Usecode_value& offval = arrval.get_elem(i + 1); i += offval.get_int_value() - 1; } 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 0x4e: { 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: { 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: { 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()); Usecode_value v(obj->get_dir_framenum( val.get_int_value(), Actor::standing)); usecode->set_item_frame(objval, v); break; } default:  if (opcode >= 0x60 && opcode <= 0x7f) { Usecode_value v(obj->get_dir_framenum( obj->get_usecode_dir(), opcode)); usecode->set_item_frame(objval, v); }  else if (opcode >= 0x30 && opcode <= 0x38) { #if 0 static short offsets[16] = { -1,0, -1,1, 1,0, 1,-1, 0,-1, -1,-1, -1,0, -1,1 };  #endif } else printf("Unhanded sched. opcode %02x\n",opcode); break; }
void Earthquake::handle_event	(	unsigned long curtime,		// Current time of day.	long udata			// ->usecode machine.	)	{	Image_window *win = gwin->get_win();	int w = win->get_width(), h = win->get_height();	int sx = 0, sy = 0;	int dx = rand()%9 - 4;	int dy = rand()%9 - 4;	if (dx > 0)		w -= dx;	else		{		w += dx;		sx -= dx;		dx = 0;		}	if (dy > 0)		h -= dy;	else		{		h += dy;		sy -= dy;		dy = 0;		}	win->copy(sx, sy, w, h, dx, dy);	gwin->set_painted();	gwin->show();					// Shake back.	win->copy(dx, dy, w, h, sx, sy);	if (++i < len)			// More to do?  Put back in queue.		gwin->get_tqueue()->add(curtime + 100, this, udata);	else		delete this;	}