コード例 #1
0
ファイル: Directory.cpp プロジェクト: turbanoff/X-plore
bool C_dir::ScanBegin(const wchar *dir){

   S_scan_data *sd = (S_scan_data*)find_data;
   if(sd)
      win::FindClose(sd->h);
   else
      find_data = sd = new(true) S_scan_data;
#ifdef _WIN32_WCE
   sd->is_card_scan = false;
#endif

   Cstr_w dirw = dir;
   //C_file::GetFullPath(dir, dirw);
   if(dirw.Length() && dirw[dirw.Length()-1]!='\\')
      dirw<<'\\';
   dirw<<L"*.*";
#ifndef _WIN32_WCE
   win::SetErrorMode(SEM_FAILCRITICALERRORS);  //don't fail for drives with noninserted disks
#endif
   sd->h = win::FindFirstFile(dirw, sd);
#ifndef _WIN32_WCE
   win::SetErrorMode(0);
#endif
   if(sd->h==win::HANDLE(-1)){
      ScanEnd();
      return false;
   }
   return true;
}
コード例 #2
0
ファイル: Directory.cpp プロジェクト: turbanoff/X-plore
bool C_dir::ScanBegin(const wchar *dir){

   ScanEnd();
   S_scan_data *sd = new(true) S_scan_data;
   find_data = sd;

   Cstr_w dirw = dir;
   //C_file::GetFullPath(dir, dirw);
   if(dirw.Length() && dirw[dirw.Length()-1]!='\\')
      dirw<<'\\';
   TPtrC fptr((word*)(const wchar*)dirw, dirw.Length());

   RFs file_session;
   RFs &fs = InitFileSession(file_session);
   int err = fs.GetDir(fptr, KEntryAttHidden | KEntryAttSystem | KEntryAttDir, ESortNone, sd->list);
   CloseFileSession(file_session);
   if(err || !sd->list || !sd->list->Count()){
      ScanEnd();
      return false;
   }
   sd->count = sd->list->Count();
   return true;
}
コード例 #3
0
ファイル: Directory.cpp プロジェクト: turbanoff/X-plore
bool C_dir::ScanMemoryCards(){

   S_scan_data *sd = (S_scan_data*)find_data;
   if(sd)
      win::FindClose(sd->h);
   else
      find_data = sd = new(true) S_scan_data;
   sd->is_card_scan = true;
   sd->h = win::FindFirstFlashCard(sd);
   if(sd->h==win::HANDLE(-1) || !sd->cFileName[0]){
      ScanEnd();
      return false;
   }
   return true;
}
コード例 #4
0
ファイル: Compiler.cpp プロジェクト: alex-games/a1
bool Compiler::Compile( const std::string& f, VM::Data& data )
{
	// System call
	AddFunction( VM::SYS_PRINT, TYPE_VOID, "print", "s" );
	AddFunction( VM::SYS_TOSTR, TYPE_STRING, "str", "i" );

	AddFunction( VM::SYS_FLOAT_TO_INT, TYPE_INTEGER, "FtoI", "f" );		// int FtoI( float );
	AddFunction( VM::SYS_INT_TO_FLOAT, TYPE_FLOAT, "ItoF", "i" );		// float ItoF( int );

	AddFunction( VM::SYS_SIN, TYPE_FLOAT, "sin", "f" );					// float sin( rad );
	AddFunction( VM::SYS_COS, TYPE_FLOAT, "cos", "f" );					// float cos( rad );
	AddFunction( VM::SYS_ATAN2, TYPE_FLOAT, "atan2", "ff" );			// float atan2( y, x );

	AddFunction( VM::SYS_DEG_TO_RAD, TYPE_FLOAT, "DegToRad", "f" );		// float DegToRad();

	AddFunction( VM::SYS_GET_PLAYER_POSX, TYPE_FLOAT, "GetPlayerPosX", "" );				// float GetPlayerPosX();
	AddFunction( VM::SYS_GET_PLAYER_POSY, TYPE_FLOAT, "GetPlayerPosY", "" );				// float GetPlayerPosY();
	AddFunction( VM::SYS_GET_RANDOM_F, TYPE_FLOAT, "GetRandF", "" );							// float GatRand();
	AddFunction( VM::SYS_ADD_SCORE, TYPE_VOID, "AddScore", "i" );							// void AddScore( score );

	AddFunction( VM::SYS_PLAY_SE, TYPE_VOID, "PlaySE", "i" );			// void PlaySE( id );
	AddFunction( VM::SYS_STOP_SE, TYPE_VOID, "StopSE", "i" );			// void StopSE( id );
	AddFunction( VM::SYS_PLAY_BGM, TYPE_VOID, "PlayBGM", "i" );	// void PlayBGM( id );
	AddFunction( VM::SYS_STOP_BGM, TYPE_VOID, "StopBGM", "i" );	// void StopBGM( id );

	// System call for enemy.
	AddFunction( VM::SYS_ENEMY_GET_POSX, TYPE_FLOAT, "GetEnemyPosX", "" );				// float GetEnemyPosX();
	AddFunction( VM::SYS_ENEMY_GET_POSY, TYPE_FLOAT, "GetEnemyPosY", "" );				// float GetEnemyPosY();
	AddFunction( VM::SYS_ENEMY_GET_HP, TYPE_INTEGER, "GetEnemyHP", "" );					// int GetEnemyHP();
	AddFunction( VM::SYS_ENEMY_GET_SPEED, TYPE_INTEGER, "GetEnemySpeed", "" );				// int GetEnemySpeed();
	AddFunction( VM::SYS_ENEMY_GET_COUNTER, TYPE_INTEGER, "GetEnemyCounter", "" );			// int GetEnemyCounter();
	AddFunction( VM::SYS_ENEMY_GET_COUNTER_F, TYPE_FLOAT, "GetEnemyCounterF", "" );			// float GetEnemyCounterF();
	AddFunction( VM::SYS_ENEMY_SET_ANGLE, TYPE_INTEGER, "GetEnemyAngle", "" );				// int GetEnemyAngle();
	AddFunction( VM::SYS_ENEMY_SET_POS, TYPE_VOID, "SetEnemyPos", "ff" );					// void SetEnemyPos( x, y );
	AddFunction( VM::SYS_ENEMY_SET_ANGLE, TYPE_VOID, "SetEnemyAngle", "i" );				// void SetEnemyAngle( angle );
	AddFunction( VM::SYS_ENEMY_SET_SPEED, TYPE_VOID, "SetEnemySpeed", "i" );				// void SetEnemySpeed( speed );
	AddFunction( VM::SYS_ENEMY_SET_HP, TYPE_VOID, "SetEnemyHP", "i" );						// void SetEnemyHP( hp );
	AddFunction( VM::SYS_ENEMY_SET_IMAGE, TYPE_VOID, "SetEnemyImgID", "i" );				// void SetEnemyImage( texture_id );
	AddFunction( VM::SYS_ENEMY_SET_COLLISION_RADIUS, TYPE_VOID, "SetEnemyCollisionRadius", "f" );		// void SetEnemyCollisionRadius( radius );
	AddFunction( VM::SYS_ENEMY_SET_SCORE, TYPE_VOID, "SetEnemyScore", "i" );							// void SetEnemyScore( score );
	AddFunction( VM::SYS_ENEMY_CREATE_SHOT_1, TYPE_VOID, "CreateEnemyShot1", "fffffi" );	// void CreateEnemyShot1( x, y, speed, angle, radius, texture_id );
	AddFunction( VM::SYS_ENEMY_CREATE_EFFECT_1, TYPE_VOID, "CreateEffect1", "ffi" );		// void CreateEffect1( x, y, texture_id );
	AddFunction( VM::SYS_ENEMY_SET_BOSS_FLAG, TYPE_VOID, "SetEnemyBossFlag", "i" );			// void SetEnemyBossFlag( flag );

	// System call for stage.
	AddFunction( VM::SYS_STAGE_ADD_ENEMY, TYPE_VOID, "AddEnemy", "i" );					// void AddEnemy( script_id );
	AddFunction( VM::SYS_STAGE_ADD_ENEMY_INIPOS, TYPE_VOID, "AddEnemyIniPos", "iff" );	// void AddEnemyIniPos( script_id, x, y );
	AddFunction( VM::SYS_STAGE_GET_FRAME, TYPE_INTEGER, "GetFrame", "" );				// int GetFrame();
	AddFunction( VM::SYS_STAGE_SET_FRAME, TYPE_VOID, "SetFrame", "i" );					// void SetFrame( frame );
	AddFunction( VM::SYS_UPDATE, TYPE_VOID, "Update", "" );								// void Update();

	// Global variables.
	m_Variables.push_back( ValueTable() );
	m_Variables[ 0 ].SetGlobal();

	// HALT operation is first operation.
	OpHalt();

	m_File = f;
	ScanBegin();						// Initialize scanner.
	yy::Parser parser( *this );			// Build parser.
	int result = parser.parse();		// Analyze grammer.
	ScanEnd();							// End scanner.

	if( result != 0 ){
		return false;
	}

	int codeSize = LabelSetting();		// Set address to label.
	CreateData( data, codeSize );		// Create binary.

	return m_ErrorCount == 0;
}