示例#1
0
void MainLogicLoop(){
		//TODO lock the camera
		//lockCamera(&processHandle);

		//read the data at these pointers, now that offsets have been added and we have a static address
        ReadPlayer(&Enemy, processHandle, EnemyId);
        ReadPlayer(&Player, processHandle, PlayerId);

        //log distance in memory
        AppendDistance(distance(&Player, &Enemy));

        //start the neural network threads
        WakeThread(defense_mind_input);
        WakeThread(attack_mind_input);

        ResetVJoyController();

		//begin reading enemy state, and handle w logic and subroutines
        char attackImminent = EnemyStateProcessing(&Player, &Enemy);

        WaitForThread(defense_mind_input);
        guiPrint(LocationDetection",1:Defense Neural Network detected %d, and Attack %d", DefenseChoice, AttackChoice);
#if DebuggingPacifyDef
        DefenseChoice = 0;
#endif
		//defense mind makes choice to defend or not(ex backstab metagame decisions).
		//handles actually backstab checks, plus looks at info from obveous direct attacks from aboutToBeHit
        if (attackImminent == ImminentHit || inActiveDodgeSubroutine() || (DefenseChoice>0)){
            dodge(&Player, &Enemy, &iReport, attackImminent, DefenseChoice);
		}

        WaitForThread(attack_mind_input);
        guiPrint(LocationDetection",2:Attack Neural Network decided %d", AttackChoice);
#if DebuggingPacifyAtk
        AttackChoice = 0;
#endif
		//attack mind make choice about IF to attack or not, and how to attack
        //enter when we either have a Attack neural net action or a attackImminent action
        if (inActiveAttackSubroutine() || attackImminent != ImminentHit || (AttackChoice && DefenseChoice<=0)){
            attack(&Player, &Enemy, &iReport, attackImminent, AttackChoice);
        }

        //unset neural network desisions
        DefenseChoice = 0;
        AttackChoice = 0;
        //handle subroutine safe exits
        SafelyExitSubroutines();

        guiPrint(LocationDetection",5:Current Subroutine States ={%d,%d,%d,%d}", subroutine_states[0], subroutine_states[1], subroutine_states[2], subroutine_states[3]);

		//send this struct to the driver (only 1 call for setting all controls, much faster)
        guiPrint(LocationJoystick",0:AxisX:%d\nAxisY:%d\nButtons:0x%x", iReport.wAxisX, iReport.wAxisY, iReport.lButtons);
		UpdateVJD(iInterface, (PVOID)&iReport);

		//SetForegroundWindow(h);
		//SetFocus(h);
}
示例#2
0
static void CPROC SomeChoiceClicked( uintptr_t psv, PCONTROL pc )
{
	PBANNER banner = (PBANNER)psv;
   int choice = GetControlID( pc );
#ifdef DEBUG_BANNER_DRAW_UPDATE
	lprintf( WIDE( "SOME!" ) );
#endif
	banner->flags |= (BANNER_CLOSED);
	switch( choice )
	{
	case IDOK:
      banner->flags |= BANNER_OKAY;
	case IDCANCEL:
		break;

	case 3+IDOK:
		banner->flags |= BANNER_OKAY;
	case 3+IDCANCEL:
      banner->flags |= BANNER_EXTENDED_RESULT;
      break;
	}
	{
		PTHREAD thread = (banner)->pWaitThread;
		if( thread )
		{
			WakeThread( thread );
		}
	}
}
示例#3
0
void BrwLock::WakeReaders() {
    while (!wait_.IsEmpty()) {
        thread_t* next = wait_.Peek();
        if (next->state != THREAD_BLOCKED_READ_LOCK) {
            break;
        }
        WakeThread(next, kBrwLockReader);
    }
}
示例#4
0
void EnqueStrokes( const TEXTCHAR *strokes )
{
	uint32_t savepos;
	int len = strlen( strokes );
	bEnque = 1;
	savepos = tell( inputpipe );
	lprintf( WIDE("write to input event pipe") );
	lseek( inputpipe, 0, SEEK_END);
	write( inputpipe, strokes, len );
	lseek( inputpipe, savepos, SEEK_SET );
	bEnque = 0;
	lprintf( WIDE("wake input thread") );
	WakeThread( pThreadInput );
}
示例#5
0
static void CPROC CancelChoiceClicked( uintptr_t psv, PCONTROL pc )
{
	PBANNER banner = (PBANNER)psv;
#ifdef DEBUG_BANNER_DRAW_UPDATE
	lprintf( WIDE( "CANCEL!" ) );
#endif
	banner->flags |= (BANNER_CLOSED);
	{
		PTHREAD thread = (banner)->pWaitThread;
		if( thread )
		{
			WakeThread( thread );
		}
	}
}
示例#6
0
static void CPROC OkayChoiceClicked( uintptr_t psv, PCONTROL pc )
{
	PBANNER banner = (PBANNER)psv;
#ifdef DEBUG_BANNER_DRAW_UPDATE
	lprintf( WIDE( "OKAY!" ) );
#endif
	banner->flags |= (BANNER_CLOSED|BANNER_OKAY);
	{
		PTHREAD thread = (banner)->pWaitThread;
		if( thread && ( thread != MakeThread() ) )
		{
			WakeThread( thread );
		}
	}
}
示例#7
0
static uintptr_t CPROC TestWake2( PTHREAD thread )
{
   int n = 0;
	while( 1 )
	{
		lprintf( "sleeping 10" );
		WakeableSleep( 10 );
		lprintf( "woke 10" );
		if( n++ > 2 )
		{
         WakeThread( l._100_sleep );
         n = 0;
		}
	}
}
示例#8
0
static int OnKeyCommon( BANNER_NAME )( PSI_CONTROL pc, uint32_t key )
{
	PBANNER *ppBanner = (PBANNER*)GetCommonUserData( pc );
	PBANNER banner;
	// actually let's just pretend we don't handle any key....
   int handled = 0;
	if( !ppBanner || !(*ppBanner ) )
		return 0; // no cllick, already closed.
#ifdef DEBUG_BANNER_DRAW_UPDATE
	lprintf( WIDE( "..." ) );
#endif
	if( IsKeyPressed( key ) )
	{
		banner = (*ppBanner);
		if( banner )
		{
			if( KEY_CODE( key ) == KEY_ENTER )
			{
#ifdef DEBUG_BANNER_DRAW_UPDATE
				lprintf( WIDE( "enter.." ) );
#endif
				if( ( banner->flags & BANNER_OPTION_OKAYCANCEL )
					&& ( banner->flags & BANNER_OPTION_YESNO ) )
				{
				}
				else if( ( banner->flags & BANNER_OPTION_OKAYCANCEL )
					|| ( banner->flags & BANNER_OPTION_YESNO ) )
					banner->flags |= BANNER_OKAY;
 			}
			if( !(banner->flags & BANNER_DEAD )
				&& ( banner->flags & BANNER_CLICK ) )
			{
				banner->flags |= (BANNER_CLOSED);
				{
					PTHREAD thread = banner->pWaitThread;
					if( thread )
					{
						WakeThread( thread );
					}
				}
				// test for obutton too so any keypress also clearsit.
				//RemoveBannerEx( ppBanner DBG_SRC );
			}
		}
	}
   return handled;
}
示例#9
0
static void CPROC SystemTaskEnd( uintptr_t psvUser, PTASK_INFO task )
{
	struct task_end_notice *end_data = (struct task_end_notice *)psvUser;
	end_data->ended = TRUE;
	WakeThread( end_data->thread );
}
示例#10
0
void BrwLock::WakeWriter(thread_t* thread) {
    DEBUG_ASSERT(thread);
    writer_.store(thread, fbl::memory_order_relaxed);
    WakeThread(thread, kBrwLockWriter);
}