Beispiel #1
0
bool videoVBL()
{
	if(!videoPlaying) return false;
	
	while(videoFrames == 0) swiWaitForVBlank();
	videoFrames--;
	
	printf("\x1b[13;1HOVERHEAD:  %d         ", videoFrames);
	
	timerStart(0, ClockDivider_1024, 0, NULL);
	bool ok = videoReadFrame();
	int dd = timerElapsed(0)/ (BUS_CLOCK / 100 / 60 / 1024);
	printf("\x1b[11;1HREAD TIME:  %d %%        ", dd);
	timerStop(0);
	
	if(!ok) return false;
	timerStart(0, ClockDivider_1024, 0, NULL);
	videoDecodeFrame();
	dd = timerElapsed(0)/ (BUS_CLOCK / 100 / 60 / 1024);
	printf("\x1b[12;1HDISP TIME:  %d %%        ", dd);
	timerStop(0);
	printf("\x1b[14;1HFRAME SIZE: %d        ", videoFrameLen);
	
	return true;
}
void addNewBricks()
{
	ticks += timerElapsed(0);

	if(ticks > newBricksSpeedTicks)
	{
		ticks = 0;
		s16 i;

		for(i=MAX_BRICKS-1; i >= 0; i--)
		{
			if(bricks[i].alive)
			{
				if(i+FIELD_WIDTH >= MAX_BRICKS) return; 
				bricks[i+FIELD_WIDTH] = bricks[i];
				bricks[i].alive = 0;	
			}
		}
		
		for(i=0; i < FIELD_WIDTH; i++)
		{
			bricks[i].alive = 1;
			bricks[i].color = RANDOM_COLOR;
		}
	
	}
}
Beispiel #3
0
//---------------------------------------------------------------------------------
u16 timerPause(int timer) {
//---------------------------------------------------------------------------------
	sassert(timer < 4, "timer must be in range 0 - 3");
	TIMER_CR(timer) &= ~TIMER_ENABLE;
	u16 temp = timerElapsed(timer);
	elapsed[timer] = 0;
	return temp;
}
Beispiel #4
0
//---------------------------------------------------------------------------------
u16 timerStop(int timer) {
//---------------------------------------------------------------------------------
	sassert(timer < 4, "timer must be in range 0 - 3");
	TIMER_CR(timer) = 0;
	u16 temp = timerElapsed(timer);
	elapsed[timer] = 0;
	return temp;
}
void titleUpdate()
{
	if(keepDrawing)
		drawingTicks += timerElapsed(0);

	if(releasedKeys & KEY_TOUCH || releasedKeys & KEY_START)
		setGameState(GAME_STATE_BREAKOUT);

}
Beispiel #6
0
int main()
{
	consoleDemoInit();

	uint ticks = 0;
	TimerStates state = timerState_Stop;
	int down = keysDown();

	while(!(down & KEY_START))
	{
		swiWaitForVBlank();
		consoleClear();
		scanKeys();
		down = keysDown();

		if(state == timerState_Running)
		{
			ticks += timerElapsed(0);
		}

		if(down & KEY_A)
		{
			if(state == timerState_Stop)
			{
				timerStart(0, ClockDivider_1024, 0, NULL);
				state = timerState_Running;
			}
			else if(state == timerState_Pause)
			{
				timerUnpause(0);
				state = timerState_Running;
			}
			else if(state == timerState_Running)
			{
				ticks += timerPause(0);
				state = timerState_Pause;
			}
		}
		else if(down & KEY_B)
		{
			timerStop(0);
			ticks = 0;
			state = timerState_Stop;
		}

		iprintf("Press A to start and pause the \ntimer, B to clear the timer \nand start to quit the program.\n\n");
		iprintf("ticks:  %u\n", ticks);
		iprintf("second: %u:%u\n", ticks/TIMER_SPEED, ((ticks%TIMER_SPEED)*1000) /TIMER_SPEED);
	}

	if(state != timerState_Stop)
	{
		timerStop(0);
	}

	return 0;
}
	//-------------------------------------------------------------------------------------------------
	u64 Timer::GetTotalTicks()
	{
		static bool running = false;
		static u64  totalTicks = 0;

		if (!running)
		{
			timerStart(0, ClockDivider_1024, 0, NULL);
			running = true;
		}

		totalTicks += timerElapsed(0);

		return totalTicks;
	}
void ProcedureFootswitch::pressProcedureFootswitch()
{
	if (!m_tester || !m_tester->connected())
	{
		return;
	}

	m_targetProcedureFSState = FSPedalDown;

	if (m_currentProcedureFSState == FSPedalUp)
	{
		setFSState(FSIntermediate);
		QTimer::singleShot(randomTimerInterval(m_intermediateLength), this, SLOT(timerElapsed()));
	}
}
Beispiel #9
0
void FemtecTester::pressProcedureFootswitch()
{
	if (!m_enabled)
	{
		return;
	}

	m_targetProcedureFSState = PedalDown;

	if (m_currentProcedureFSState == PedalUp)
	{
		setFSState(Intermediate);
		QTimer::singleShot(randomTimerInterval(m_intermediateLength), this, SLOT(timerElapsed()));
	}
}
void ProcedureFootswitch::releaseProcedureFootswitch()
{
	if (!m_tester || !m_tester->connected())
	{
		return;
	}

	m_pauseState = NoPause;
	m_targetProcedureFSState = FSPedalUp;

	if (m_currentProcedureFSState == FSPedalDown) // if Intermediate timer is still active
	{
		setFSState(FSIntermediate);
		QTimer::singleShot(randomTimerInterval(m_intermediateLength), this, SLOT(timerElapsed()));
	}
}
Beispiel #11
0
void FemtecTester::releaseProcedureFootswitch()
{
	if (!m_enabled)
	{
		return;
	}

	m_pauseState = NoPause;
	m_targetProcedureFSState = PedalUp;

	if (m_currentProcedureFSState == PedalDown) // if Intermediate timer is still active
	{
		setFSState(Intermediate);
		QTimer::singleShot(randomTimerInterval(m_intermediateLength), this, SLOT(timerElapsed()));
	}
}
Beispiel #12
0
void FemtecTester::timerElapsed()
{
	switch (m_currentProcedureFSState)
	{
		case Intermediate:
			setFSState(m_targetProcedureFSState);
			break;
		default:
			if (m_targetProcedureFSState != m_currentProcedureFSState)
			{
				setFSState(Intermediate);
				QTimer::singleShot(randomTimerInterval(m_intermediateLength), this, SLOT(timerElapsed()));
			}
			break;
	}

}
Beispiel #13
0
void FemtecTester::pressProcedureFootswitchDelayed()
{
	if (!m_enabled)
	{
		return;
	}

	m_targetProcedureFSState = PedalDown;

	if (m_currentProcedureFSState == PedalUp) // if Intermediate, fs is pressed immediately
	{
		int delay = randomTimerInterval(m_treatmentDelay);
		//qDebug() << "pressing footswitch in " << (delay / 1000) << " seconds...";
		showCountdown("pressing footswitch in %1 seconds...", delay, 100);
		QTimer::singleShot(delay, this, SLOT(timerElapsed()));
	}
}
void ProcedureFootswitch::timerElapsed()
{
	if (!m_tester || !m_tester->connected())
	{
		return;
	}

	switch (m_currentProcedureFSState)
	{
		case FSIntermediate:
			setFSState(m_targetProcedureFSState);
			break;
		default:
			if (m_targetProcedureFSState != m_currentProcedureFSState)
			{
				setFSState(FSIntermediate);
				QTimer::singleShot(randomTimerInterval(m_intermediateLength), this, SLOT(timerElapsed()));
			}
			break;
	}

}
void breakoutUpdate()
{
	if(gameOver)
	{
		if(releasedKeys & KEY_TOUCH || releasedKeys & KEY_A)
			reset();	
	}
	else if(playing)
	{
		movePaddle(&paddle);
		moveBall(&ball);
		
		handleBallBricksCollisions(&ball);
		handleBallPaddleCollision(&ball, &paddle);
		
		addNewBricks();
	}
	else
	{
		ticks += timerElapsed(0);
		if(ticks > 50000 || releasedKeys & KEY_TOUCH || releasedKeys & KEY_A)
			playing = 1;
	}
}
Beispiel #16
0
static
portTASK_FUNCTION(Key_Press, pvParameters)
{
    int down = keysDown();
        

    while(!(down & KEY_START))
    {int k=0;
        swiWaitForVBlank();
        consoleClear();
        scanKeys();
        down = keysDown();

        if(state == timerState_Running)
        {
            ticks += timerElapsed(0);
        }

        if(down & KEY_A)
        {
            if(state == timerState_Stop)
            {
                timerStart(0, ClockDivider_1024, 0, NULL);
                state = timerState_Running;
            }
            else if(state == timerState_Pause)
            {
                timerUnpause(0);
                state = timerState_Running;
                
            }
            else if(state == timerState_Running)
            {
                ticks += timerPause(0);
                state = timerState_Pause;
                sc[j] = ticks/TIMER_SPEED;
                scp[j] = ((ticks%TIMER_SPEED)*1000) /TIMER_SPEED;
                j++;
                

            }

        }
        else if(down & KEY_B)
        {
            timerStop(0);
            ticks = 0;
            state = timerState_Stop;
            j = 0;
        }

        iprintf("(A)     : Start & Pause Timer.\n(B)     : Clean Timer.\n(Start) : Exit Timer.\n\n");
        iprintf("Time\n");
        iprintf("ticks:  %u\n", ticks);
        iprintf("second: %u:%u\n", ticks/TIMER_SPEED, ((ticks%TIMER_SPEED)*1000) /TIMER_SPEED);
        iprintf("LIST\n");
        for(i = 0; i < j; i++) {
        iprintf(" [%d] :  %u : %u \n",i+1, sc[i],scp[i]);
        }
   	        
	

    }

    if(state != timerState_Stop)
    {
        timerStop(0);
    }
    vTaskDelay(portMAX_DELAY);
}
Beispiel #17
0
int App_Test::start()
{
    int code_out = 0;

    this->model_animated[ 0] = (u8 *)heavy_walk_01_bin;
    this->model_animated[ 1] = (u8 *)heavy_walk_02_bin;
    this->model_animated[ 2] = (u8 *)heavy_walk_03_bin;
    this->model_animated[ 3] = (u8 *)heavy_walk_04_bin;
    this->model_animated[ 4] = (u8 *)heavy_walk_05_bin;
    this->model_animated[ 5] = (u8 *)heavy_walk_06_bin;
    this->model_animated[ 6] = (u8 *)heavy_walk_07_bin;
    this->model_animated[ 7] = (u8 *)heavy_walk_08_bin;
    this->model_animated[ 8] = (u8 *)heavy_walk_09_bin;
    this->model_animated[ 9] = (u8 *)heavy_walk_10_bin;
    this->model_animated[10] = (u8 *)heavy_walk_11_bin;
    this->model_animated[11] = (u8 *)heavy_walk_12_bin;
    this->model_animated[12] = (u8 *)heavy_walk_13_bin;
    this->model_animated[13] = (u8 *)heavy_walk_14_bin;
    this->model_animated[14] = (u8 *)heavy_walk_15_bin;
    this->model_animated[15] = (u8 *)heavy_walk_16_bin;
    this->model_animated[16] = (u8 *)heavy_walk_17_bin;
    this->model_animated[17] = (u8 *)heavy_walk_18_bin;
    this->model_animated[18] = (u8 *)heavy_walk_19_bin;
    this->model_animated[19] = (u8 *)heavy_walk_20_bin;
    this->model_animated[20] = (u8 *)heavy_walk_21_bin;
    this->model_animated[21] = (u8 *)heavy_walk_22_bin;
    this->model_animated[22] = (u8 *)heavy_walk_23_bin;
    this->model_animated[23] = (u8 *)heavy_walk_24_bin;
    this->model_animated[24] = (u8 *)heavy_walk_25_bin;
    this->model_animated[25] = (u8 *)heavy_walk_26_bin;
    this->model_animated[26] = (u8 *)heavy_walk_27_bin;
    this->model_animated[27] = (u8 *)heavy_walk_28_bin;
    this->model_animated[28] = (u8 *)heavy_walk_29_bin;
    this->model_animated[29] = (u8 *)heavy_walk_30_bin;
    this->model_animated[30] = (u8 *)heavy_walk_31_bin;
    this->model_animated[31] = (u8 *)heavy_walk_32_bin;
    this->model_animated[32] = (u8 *)heavy_walk_33_bin;
    this->model_animated[33] = (u8 *)heavy_walk_34_bin;
    this->model_animated[34] = (u8 *)heavy_walk_35_bin;
    this->model_animated[35] = (u8 *)heavy_walk_36_bin;
    this->model_animated[36] = (u8 *)heavy_walk_37_bin;
    this->model_animated[37] = (u8 *)heavy_walk_38_bin;
    this->model_animated[38] = (u8 *)heavy_walk_39_bin;
    this->model_animated[39] = (u8 *)heavy_walk_40_bin;



    //Animations variables
	this->frame = 0;
    this->max_frame = 40;

	//Debug variables for animations
	int32 test_time = 0; 
 
	this->xrot = 0.0f;
    this->yrot = 0.0f;
    this->zrot = 0.0f;

    this->p_mgr_display->setup_screen();

    this->target.set_vec_ox(0);
    this->target.set_vec_oy(0);
    this->target.set_vec_oz(0);

    this->camera.setLookAt(CAMERA_MODE_TARGET,&(this->target));
    this->camera.computeLookAt();
	this->camera.dist_from_target = floattof32(23);
    this->p_mgr_display->set_camera(&(this->camera));

    this->p_mgr_display->init();
    this->load_Texture();

    this->app_running = 1;
    this->p_mgr_system->reset_timer();

	this->animation_pause = 1;	

    glSetToonTableRange( 0, 8, RGB15(8,8,8) );
    glSetToonTableRange( 8, 10, RGB15(12,12,12) );
    glSetToonTableRange( 10, 13, RGB15(16,16,16) );
    glSetToonTableRange( 13, 31, RGB15(31,31,31) );

	//glEnable(GL_TOON_HIGHLIGHT);
    while(this->app_running)
    {
        this->process_inputs();
        //printf("%d\n",this->p_mgr_system->last_millisec);
        //this->camera.setStep(this->p_mgr_system->last_millisec); // TODO : init and use millisec pointer within Model_Camera
        this->camera.setStep(17); // TODO : init and use millisec pointer within Model_Camera

        //Animations step calculation
        //this->frame += mulf32(this->frame_speed,this->p_mgr_system->last_millisec);
		if (!this->animation_pause) this->frame+= test_time;
		else this->frame=0;
        if (this->frame >= this->max_frame) this->frame = this->frame - this->max_frame;
		
		this->model_selected = this->model_animated[this->frame];
        //Start Display

        this->p_mgr_display->begin_3D();

        this->display_Model();

        this->p_mgr_display->end_3D();

        this->p_mgr_display->flush_display();
        //End Display

        iprintf("\x1b[2J");
        iprintf("\x1b[1;0Hframe  = %d\n",this->frame);
	    iprintf("\x1b[2;0Htest_timer  = %d\n",timerElapsed(0));
	    iprintf("\x1b[3;0Htest_ms  = %d\n",test_time);

		swiIntrWait(IRQ_TIMER0,1);
	    iprintf("\x1b[5;0H Timer ok\n");
		test_time = this->p_mgr_system->last_millisec;
        this->p_mgr_system->reset_timer();

//        printf("dst_from_target = %f\n",f32tofloat(this->camera.dist_from_target));
		swiWaitForVBlank(); 

    }

    return code_out;

}