コード例 #1
0
ファイル: delay.c プロジェクト: 111X/radare
void mdelay(unsigned int ms)
{
	tb_t start, end;
	mftb(&start);
	while (1)
	{
		mftb(&end);
		if (tb_diff_msec(&end, &start) >= ms)
			break;
	}
}
コード例 #2
0
ファイル: sys_arch.c プロジェクト: AirBrowse/libxenon
/** Returns the current time in milliseconds,
 * may be the same as sys_jiffies or at least based on it. */
u32_t sys_now(void)
{
	tb_t now;
	mftb(&now);
	return (u32_t) tb_diff_msec(&now, &startTime);
}
コード例 #3
0
ファイル: menu.cpp プロジェクト: feraligatr/vbagx
void
MainMenu (int selectedMenu)
{
	tb_t start,end;
	mftb(&start);

	int quit = 0;
	int ret;

	#ifdef HW_RVL
	// don't show dvd motor off on the wii
	menuitems[5][0] = 0;
	// rename reset/exit items
	sprintf (menuitems[6], "Return to Wii Menu");
	sprintf (menuitems[7], "Return to Homebrew Channel");
	#endif

	// disable game-specific menu items if a ROM isn't loaded
	if (!ROMLoaded)
    	menuitems[3][0] = '\0';
	else
		sprintf (menuitems[3], "Game Menu");

	VIDEO_WaitVSync ();

	while (quit == 0)
	{
		if(selectedMenu >= 0)
		{
			ret = selectedMenu;
			selectedMenu = -1; // default back to main menu
		}
		else
		{
			ret = RunMenu (menuitems, menucount, (char*)"Main Menu");
		}

		switch (ret)
		{
			case 0:
				// Load ROM Menu
				quit = LoadManager ();
				break;

			case 1:
				// Configure Controllers
				ConfigureControllers ();
				break;

			case 2:
				// Preferences
				PreferencesMenu ();
				break;

			case 3:
				// Game Options
				quit = GameMenu ();
				break;

			case 4:
				// Credits
				Credits ();
				WaitButtonA ();
                break;

			case 5:
				// turn the dvd motor off (GC only)
				#ifdef HW_DOL
				dvd_motor_off ();
				#endif

			case 6:
				// Reset the Gamecube/Wii
			    Reboot();
                break;

			case 7:
				ExitToLoader();
				break;

			case -1: // Button B
				// Return to Game
				if(ROMLoaded)
					quit = 1;
				break;
		}
	}

	// Wait for buttons to be released
	int count = 0; // how long we've been waiting for the user to release the button
	while(count < 50 && (
		PAD_ButtonsHeld(0)
		#ifdef HW_RVL
		|| WPAD_ButtonsHeld(0)
		#endif
	))
	{
		VIDEO_WaitVSync();
		count++;
	}

	mftb(&end);
	loadtimeradjust += tb_diff_msec(&end, &start);
}
コード例 #4
0
    void Browser::Update() {
        
#ifdef WIN32
        W32Update();
#endif
        Hw::SystemPoll();

        get_controller_data(&ctrl, 0);
        {
            int up = 0;
            int down = 0;
            
            // button pressed
            if(ctrl.up && !old_ctrl.up){
                up++;
                lChange[0]=mftb();
            }
            else if (ctrl.down && !old_ctrl.down){
                down++;
                lChange[1]=mftb();
            }
            // button released
            if(!ctrl.up){
                lChange[0]=0;
            }
            if(!ctrl.down){
                lChange[1]=0;
            }
            
            uint64_t now = mftb();

            if(lChange[0]>0)
            if(tb_diff_msec(now,lChange[0])>250){
                static int uh=0;
                uh=!uh;
                if (uh) up++;
            }
            if(lChange[1]>0)
            if(tb_diff_msec(now,lChange[1])>250){
                static int dh=0;
                dh=!dh;
                if (dh) down++;
            }
            
            
            //if (get_controller_data(&ctrl, 0)) {
            if (up) {
                switch (panelSelected) {
                    case PANEL_FILE_LIST:
                        entrySelected--;
                        break;
                    case PANEL_ACTION:
                        actionSelected--;
                        break;
                }
            }

            if (down) {
                switch (panelSelected) {
                    case PANEL_FILE_LIST:
                        entrySelected++;
                        break;
                    case PANEL_ACTION:
                        actionSelected++;
                        break;
                }
            }
            if (ctrl.b && !old_ctrl.b) {
                switch (panelSelected) {
                    case PANEL_FILE_LIST:
                        append_dir_to_path(currentPath, "..");
                        ScanDir();
                        break;
                }
            }
            if (ctrl.back && !old_ctrl.back) {
#ifdef LIBXENON
                switch (panelSelected) {
                    case PANEL_FILE_LIST:
                        char path[2048];
                        
                        handle = get_devices(handle, path);

                        strcpy(currentPath, path);
                        ScanDir();
                        break;
                }
#endif
            }
            if
                (
                    (ctrl.start && !old_ctrl.start) || (ctrl.a && !old_ctrl.a)
                    ) {
                switch (panelSelected) {
                    case PANEL_FILE_LIST:
                    {
                        if (vEntry.size() == 0)
                            break;

                        FileEntry currentEntry = vEntry.at(entrySelected);

                        if (currentEntry.type == 1) {
                            append_dir_to_path(currentPath, (char*) currentEntry.name.c_str());
                            ScanDir();
                        } else {
                            sprintf(currentFile, "%s/%s", currentPath, currentEntry.name.c_str());
                            if (ActionLaunchFile != NULL)
                                ActionLaunchFile(currentFile);
                        }
                        break;
                    }
                    case PANEL_ACTION:
                    {
                        if (nbAction == 0)
                            break;

                        // Exec action ...
                        //FileEntry currentEntry = vEntry.at(entrySelected);
                        lpBrowserActionEntry currentAction = vAction[actionSelected];
                        if (currentAction != NULL && currentAction->action != NULL) {
                            currentAction->param = (void*) currentPath;
                            //currentAction->param = 
                            currentAction->action(currentAction);
                        }
                        break;
                    }
                }
            }

            if (ctrl.left && !old_ctrl.left) {
                //if(panelSelected!=PANEL_PROGRESS)
                panelSelected--;
            }
            if (ctrl.right && !old_ctrl.right) {
                //if(panelSelected!=PANEL_PROGRESS)
                panelSelected++;
            }

            // clamp ...
            CLAMP(entrySelected, 0, vEntry.size() - 1);
            CLAMP(actionSelected, 0, nbAction - 1);
            CLAMP(panelSelected, 0, 1);


            // Save the old value
            old_ctrl = ctrl;

            // Erase for the big loop
            memset(&ctrl, 0, sizeof (struct controller_data_s));
        }


    }