コード例 #1
0
ファイル: samegame.c プロジェクト: z88dk/z88dk
int main()
{
  int   mode;
  void *param = &udgs;
  console_ioctl(IOCTL_GENCON_SET_UDGS, &param);

  putch(1);
  putch(32);

#ifdef SWITCH_MODE
   mode = SWITCH_MODE;
   console_ioctl(IOCTL_GENCON_SET_MODE, &mode);
#endif


    while ( 1 ) {
        initialise_level();
        playing = 1;
        score = 0;
        clrscr();
        moved();
        while ( playing ) {
            handle_keys();         
        }
    }
}
コード例 #2
0
ファイル: menu.cpp プロジェクト: toughkidcst/mame
const ui_menu_event *ui_menu::process(UINT32 flags)
{
	// reset the menu_event
	menu_event.iptkey = IPT_INVALID;

	// first make sure our selection is valid
	validate_selection(1);

	// draw the menu
	if (numitems > 1 && (item[0].flags & MENU_FLAG_MULTILINE) != 0)
		draw_text_box();
	else
		draw(flags & UI_MENU_PROCESS_CUSTOM_ONLY);

	// process input
	if (!(flags & UI_MENU_PROCESS_NOKEYS))
	{
		// read events
		handle_events();

		// handle the keys if we don't already have an menu_event
		if (menu_event.iptkey == IPT_INVALID)
			handle_keys(flags);
	}

	// update the selected item in the menu_event
	if (menu_event.iptkey != IPT_INVALID && selected >= 0 && selected < numitems)
	{
		menu_event.itemref = item[selected].ref;
		return &menu_event;
	}
	return nullptr;
}
コード例 #3
0
bool RobotBrainServiceService::start(int argc, char* argv[])
{
  char adapterStr[255];

  //Create the adapter
  int port = RobotBrainObjects::RobotBrainPort;
  bool connected = false;

  while(!connected)
    {
      try
        {
          LINFO("Trying Port:%d", port);
          sprintf(adapterStr, "default -p %i", port);
          itsAdapter = communicator()->createObjectAdapterWithEndpoints("SeaBee3SimulatorAdapter",
                                                                        adapterStr);
          connected = true;
        }
      catch(Ice::SocketException)
        {
          port++;
        }
    }

  //Create the manager and its objects
  itsMgr = new ModelManager("SeaBee3SimulatorServiceManager");

  nub::ref<OutputFrameSeries> ofs(new OutputFrameSeries(*itsMgr));
  itsMgr->addSubComponent(ofs);


  LINFO("Starting SeaBee3 Simulator");
  nub::ref<SeaBee3Simulator> subSim(new SeaBee3Simulator(*itsMgr, "SeaBee3Simulator", "SeaBee3Simulator"));
  itsMgr->addSubComponent(subSim);
  subSim->init(communicator(), itsAdapter);

  itsMgr->parseCommandLine((const int)argc, (const char**)argv, "", 0, 0);

  itsAdapter->activate();

  itsMgr->start();

  while(1){
    Layout<PixRGB<byte> > outDisp;

    subSim->simLoop();
    Image<PixRGB<byte> > forwardCam = flipVertic(subSim->getFrame(1));
    Image<PixRGB<byte> > downwardCam = flipVertic(subSim->getFrame(2));

    outDisp = vcat(outDisp, hcat(forwardCam, downwardCam));

    ofs->writeRgbLayout(outDisp, "subSim", FrameInfo("subSim", SRC_POS));

    handle_keys(ofs, subSim);
  }


  return true;
}
コード例 #4
0
ファイル: particleed.cpp プロジェクト: kvakvs/hge
bool frame_func() {
    float px, py;
    const auto dt = hge->Timer_GetDelta();

    // Update

    hge->Input_GetMousePos(&state.mx, &state.my);
    if (hge->Input_GetKeyState(HGEK_RBUTTON)) {
        psx = state.mx;
        psy = state.my;
    }
    else {
        psx = 400;
        psy = 300;
    }

    if (state.bIFace) {
        if (psx > 631) {
            psx = 631;
        }
        if (psx < 168) {
            psx = 168;
        }
    }

    state.ps->GetPosition(&px, &py);
    state.ps->MoveTo(px + (psx - px) * 10 * dt, py + (psy - py) * 10 * dt);
    state.ps->Update(dt);

    if (handle_keys(hge->Input_GetKey())) {
        return true;
    }

    if (state.bIFace) {
        if (do_commands(gui->Update(dt))) {
            return true;
        }
    }

    GET_TEXT_CTRL(CMD_NPARTICLES)->printf("%d", state.ps->GetParticlesAlive());
    GET_TEXT_CTRL(CMD_FPS)->printf("%d", hge->Timer_GetFPS());

    return false;
}
コード例 #5
0
/* If main_cycle returns false, don't process more events! */
int main_cycle() {
	unsigned int key, kascii;
	struct vt_entry *v = &game.view_table[0];

	poll_timer();		/* msdos driver -> does nothing */
	update_timer();

	if (game.ver == 0) {
		_text->message_box("Warning: game CRC not listed, assuming AGI version 2.917.");
		game.ver = -1;
	}

	key = do_poll_keyboard();

	/* In AGI Mouse emulation mode we must update the mouse-related
	 * vars in every interpreter cycle.
	 */
	if (opt.agimouse) {
		game.vars[28] = mouse.x / 2;
		game.vars[29] = mouse.y;
	}

	if (key == KEY_PRIORITY) {
		_sprites->erase_both();
		debug_.priority = !debug_.priority;
		show_pic();
		_sprites->blit_both();
		_sprites->commit_both();
		key = 0;
	}

	if (key == KEY_STATUSLN) {
		debug_.statusline = !debug_.statusline;
		_text->write_status();
		key = 0;
	}

	/* Click-to-walk mouse interface */
	if (game.player_control && v->flags & ADJ_EGO_XY) {
		v->direction = get_direction(v->x_pos, v->y_pos, v->parm1, v->parm2, v->step_size);

		if (v->direction == 0)
			in_destination(v);
	}

	kascii = KEY_ASCII(key);

	if (kascii)
		setvar(V_key, kascii);
	process_key:
	switch (game.input_mode) {
	case INPUT_NORMAL:
		if (!handle_controller(key)) {
			if (key == 0 || !game.input_enabled)
				break;
			handle_keys(key);

			/* if ESC pressed, activate menu before
			 * accept.input from the interpreter cycle
			 * sets the input mode to normal again
			 * (closes: #540856)
			 */
			if (key == KEY_ESCAPE) {
				key = 0;
				goto process_key;
			}

			/* commented out to close bug #438872
			 * if (key) game.keypress = key;
			 */
		}
		break;
	case INPUT_GETSTRING:
		handle_controller(key);
		handle_getstring(key);
		setvar(V_key, 0);	/* clear ENTER key */
		break;
	case INPUT_MENU:
		menu->keyhandler(key);
		do_update();
		return false;
	case INPUT_NONE:
		handle_controller(key);
		if (key)
			game.keypress = key;
		break;
	}

	do_update();

	if (game.msg_box_ticks > 0)
		game.msg_box_ticks--;

	return true;
}
コード例 #6
0
ファイル: main.c プロジェクト: nivertech/live-f1
int
main (int   argc,
      char *argv[])
{
    CurrentState *state;
    const char   *home_dir;
    char         *config_file;
    int           opt, sock;

    setlocale (LC_ALL, "");
    bindtextdomain (PACKAGE, LOCALEDIR);
    textdomain (PACKAGE);

    program_name = argv[0];

    while ((opt = getopt_long (argc, argv, opts, longopts, NULL)) != -1) {
        switch (opt) {
        case 'v':
            verbosity++;
            break;
        case 0400 + 'h':
            print_usage ();
            return 0;
        case 0400 + 'v':
            print_version ();
            return 0;
        case '?':
            fprintf (stderr,
                     _("Try `%s --help' for more information.\n"),
                     program_name);
            return 1;
        }
    }

    home_dir = getenv ("HOME");
    if (! home_dir) {
        fprintf (stderr, "%s: %s\n", program_name,
                 _("unable to find HOME in environment"));
        return 1;
    }

    print_version ();
    printf ("\n");

    if (ne_sock_init ()) {
        fprintf (stderr, "%s: %s\n", program_name,
                 _("unable to initialise http library"));
        return 1;
    }


    state = malloc (sizeof (CurrentState));
    memset (state, 0, sizeof (CurrentState));
    state->host = NULL;
    state->auth_host = NULL;
    state->email = NULL;
    state->password = NULL;
    state->cookie = NULL;
    state->car_position = NULL;
    state->car_info = NULL;

    config_file = malloc (strlen (home_dir) + 7);
    sprintf (config_file, "%s/.f1rc", home_dir);

    if (read_config (state, config_file))
        return 1;

    if ((! state->email) || (! state->password)) {
        if (get_config (state) || write_config (state, config_file))
            return 1;
    }

    if (! state->host)
        state->host = DEFAULT_HOST;
    if (! state->auth_host)
        state->auth_host = DEFAULT_HOST;

    free (config_file);

    do
    {
        state->cookie = obtain_auth_cookie (state->auth_host, state->email, state->password);
    }
    while (! state->cookie);

    for (;;) {
        int ret;

        sock = open_stream (state->host, 4321);
        if (sock < 0) {
            close_display ();
            fprintf (stderr, "%s: %s: %s\n", program_name,
                     _("unable to open data stream"),
                     strerror (errno));
            return 2;
        }

        state->key = 0;
        state->frame = 0;
        state->event_no = 0;
        state->event_type = RACE_EVENT;
        state->epoch_time = 0;
        state->remaining_time = 0;
        state->laps_completed = 0;
        state->total_laps = 0;
        state->flag = GREEN_FLAG;

        state->track_temp = 0;
        state->air_temp = 0;
        state->wind_speed = 0;
        state->humidity = 0;
        state->pressure = 0;
        state->wind_direction = 0;

        if (state->fl_car) free (state->fl_car);
        state->fl_car = calloc(3, sizeof(char));
        if (state->fl_driver) free (state->fl_driver);
        state->fl_driver = calloc(15, sizeof(char));
        if (state->fl_time) free (state->fl_time);
        state->fl_time = calloc(9, sizeof(char));
        if (state->fl_lap) free (state->fl_lap);
        state->fl_lap = calloc(3, sizeof(char));

        state->num_cars = 0;
        if (state->car_position) {
            free (state->car_position);
            state->car_position = NULL;
        }
        if (state->car_info) {
            free (state->car_info);
            state->car_info = NULL;
        }

        reset_decryption (state);

        while ((ret = read_stream (state, sock)) > 0) {
            if (handle_keys (state) < 0) {
                close_display ();
                close (sock);
                return 0;
            }
        }

        if (ret < 0) {
            close_display ();
            fprintf (stderr, "%s: %s: %s\n", program_name,
                     _("error reading from data stream"),
                     strerror (errno));
            return 2;
        }

        close (sock);
        info (1, _("Reconnecting ...\n"));
    }
}
コード例 #7
0
ファイル: life.c プロジェクト: hollobon/jy-mcu-3208-life
/* Interrupt handler for timer1. Polls keys and pushes events onto message queue. */
ISR (TIMER1_CAPT_vect, ISR_NOBLOCK)
{
    handle_keys();
    handle_timers();
}