Пример #1
0
void FileSystem::loadFS( char* FS_File )
{
	initFS();
	initBlocks(); // 클래스 블럭들 포인터 초기화

	int fd = open( FS_File, O_RDONLY );

	if ( fd == -1 ) // 파일 열기 실패
	{	
		/* 블럭의 데이터 값을 초기화 함수 불러준다. */
 		superBlock.inputSuperBlockData(); // SuperBlock 값 초기화
		blockDescriptorTable.inputBlockDescriptorTableData(); // BDT 값 초기화

		for ( int i = 0; i <= 5; i++ ) // BlockBitmap 값 초기화
			blockBitmap[i] = '1';

		/* 디렉토리 초기화 */
		DirectoryManager& dm = *DirectoryManager::getInstance();
		dm.makeDefaultDirectory();

		for (int i = 0; i < 7; i++) // InodeBitmap 값 초기화
			inodeBitmap[i] = '1';
			
	}

	else // 파일 열기 성공
	{
		read( fd, blockList, BLOCK_SIZE * NUM_BLOCKS ); // blockList[409600]에 FS_File을 채워 넣어준다
		close( fd );
	}
}
Пример #2
0
    Game::Game(Config const *config) :
        config_(config),
        quitting_(false),
        windowWidth_(config->windowWidth),
        windowHeight_(config->windowHeight),
        window_(0),
        context_(0),

        appTime_(0.0),
        time_(0.0),

        bounds_(Vector2(-15.0f, -15.0f), Vector2(15.0f, 15.0f)),

        fpsTime_(0.0),
        fpsCount_(0),
    
        delauneyTriangulation_(bounds_),
        dungeonGenerator_(&random_, bounds_),

        playerActor_(0)
    {
        actorFactory_.reset(new ActorFactory(this));
        initWindow();
        initContext();
        initVoronoiDiagram();
        inputManager_.reset(new InputManager(this));
        physicsManager_.reset(new PhysicsManager(this));
        controlService_.reset(new ControlService(this));
        graphicsManager_.reset(new GraphicsManager(this));
        initBlocks();
        initDungeon();
        initMonsters();
    }
Пример #3
0
void Block$initBlocks() 
{
	_Block$initBlocks();

	mechanics->initBlocks();
	mechanics->initBlockItems();
}
Пример #4
0
GameMap::GameMap(IGame *__game): IMap(__game)
{
    cells=0;
    width=0;
    height=0;
    initBlocks();
    initWater();
}
Пример #5
0
void MainScene::onEnterTransitionDidFinish() {
	Layer::onEnterTransitionDidFinish();
    
    
    initBlocks();             // ブロックを配置する関数の呼び出し
    initCollisionSprite();		// コリジョンスプライトの作成
    initScoreLabel();			// スコアラベルの作成
    createMyUnit();				// MyUnitの生成
    initBall();
    
}
Пример #6
0
Storage::Storage() {
	LOGi("Storage create");

	// call once before using any other API calls of the persistent storage module
	BLE_CALL(pstorage_init, ());

	for (int i = 0; i < NR_CONFIG_ELEMENTS; i++) {
		LOGi("Init %i bytes persistent storage (FLASH) for id %d", config[i].storage_size, config[i].id);
		initBlocks(config[i].storage_size, config[i].handle);
	}
}
Пример #7
0
/*
*   Writes another 20 empty blocks if tar file has 
*   less than 2 empty blocks at the end. this function
*   is called when all elements in arvchive file have been
*   written to tar file 
*/
void writeArchiveFinished(void)
{
    int emptyBlocks;
    if(BytesInFile == 0){//return if nothing is written to tar file
        return;
    }
    emptyBlocks = (ReservedSpace - BytesInFile)/BLOCKLEN;
    //if tar file does not have 2 empty blocks at the end
    if(emptyBlocks < USTAREMPTYBLOCKSZ){
        initBlocks(BLOCKLEN*BLOCKFACTOR);
    }
}
Пример #8
0
void GameManager::nextLevel(int level)
{
	totalBlocksDestroyed = 0;
	ball.attachBall();
	for (auto & piece : pieces)
	{
		piece.isVisible = true;
	}
	if (level < 4)
		initBlocks(pieces, level);
	else
		initRandomMap(pieces);
}
Пример #9
0
namespace detail {
const char * initBlocks()
{
    static std::vector<char> result(blockLen * blockPow);
    for(size_t i = 0; i != blockPow; ++i)
    {
        result[i * blockLen] = '0' + i % 10;
        result[i * blockLen + 1] = '0' + (i /   10) % 10;
        result[i * blockLen + 2] = '0' + (i /  100) % 10;
        result[i * blockLen + 3] = '0' + (i / 1000) % 10;
    }
    return &result[0];
}

MSTD_DECL const char * const digitBlocks = initBlocks();

}
Пример #10
0
void initRoomEdition(void)
{
	initLights();
	initBlocks();
	initEntities();
	initInterface();
	initEditorRoom(&editorRoom);
	initContextButtons();
	initSelection(NULL);
	initCamera(&editorCamera);
	// initProjectionMatrixOrtho(&editorCamera, inttof32(-128), inttof32(127),inttof32(-96), inttof32(95), inttof32(-1000), inttof32(1000));
	initProjectionMatrix(&editorCamera, 70*90, inttof32(4)/3, inttof32(1)/10, inttof32(1000)); //TEMP?
	editorCamera.position=vect(0,0,0);
	editorTranslation=vect(0,0,inttof32(-1));
	editorScale=inttof32(1);
	lineOfTouchOrigin=vect(0,0,0);
	lineOfTouchVector=vect(0,0,0);
	currentScreen=false;

	//initial camera setup
	rotateMatrixY(editorCamera.transformationMatrix, 2048+384, true);
	rotateMatrixX(editorCamera.transformationMatrix, 1024+128, false);
	editorScale=inttof32(8*20);

	//controls stuff
	touchRead(&currentTouch);
	oldTouch=currentTouch;

	//cosmetics
	glSetOutlineColor(0,RGB15(0,0,0));
	glSetOutlineColor(1,RGB15(29,15,3));

	glMaterialf(GL_AMBIENT, RGB15(8,8,8));
	glMaterialf(GL_DIFFUSE, RGB15(24,24,24));
	glMaterialf(GL_SPECULAR, RGB15(0,0,0));
	glMaterialf(GL_EMISSION, RGB15(0,0,0));

	glSetToonTableRange(0, 2, RGB15(8,8,8));
	glSetToonTableRange(3, 31, RGB15(24,24,24));

	glLight(0, RGB15(31,31,31), cosLerp(4096)>>3, 0, sinLerp(4096)>>3);
}
Пример #11
0
/*
*   Writes file data in dataBuff to tar file 
*/
void writeDataBuffToFile(unsigned char* dataBuff,int bytesToWrite)
{
    /*always allocates and initializes a chunk of 
    BLOCKLEN*BLOCKFACTOR bytes with null character 
    if bytes in file plus bytes to write exceeds reserved space*/
    if( BytesInFile + bytesToWrite > ReservedSpace){
        initBlocks(BLOCKLEN*BLOCKFACTOR);
    }
    //move file cursor to next block of file
    if( lseek(tar_fd,BytesInFile,SEEK_SET) == -1){
        perror("lseek");
        exit(ERROREXITSTATUS);
    }
    //write to tar file
    if(write(tar_fd,dataBuff,bytesToWrite) != bytesToWrite){
        perror("write");
        exit(ERROREXITSTATUS);
    }
    //update bytes in file
    BytesInFile += bytesToWrite;
}
Пример #12
0
/*
*   Writes header data in header buff to the tar file 
*/
void writeHeaderBuffToFile(char* headerBuff)
{
    /*always allocates and initializes a chunk of 
    BLOCKLEN*BLOCKFACTOR bytes with null character 
    if reserved space is empty or filled*/
    if( BytesInFile >= ReservedSpace){
            initBlocks(BLOCKLEN*BLOCKFACTOR);
    }
    //move file cursor to next block of file
    if( lseek(tar_fd,BytesInFile,SEEK_SET) == -1){
        perror("lseek");
        exit(ERROREXITSTATUS);
    }
    //write header buffer to tar file
    if( write(tar_fd,headerBuff,USTARLEN) != USTARLEN){
        perror("write");
        exit(ERROREXITSTATUS);
    }
    //increment Bytes in File to a new position for next write 
    BytesInFile += BLOCKLEN;
}
Пример #13
0
void Block$initBlocks() {
	_Block$initBlocks();
	
	RepeaterBlock* repeater_off = new RepeaterBlock(93, "repeater_off", false);
	initBlockItems();
}
Пример #14
0
bool GameManager::init()
{
	// success flag
	auto success = true;

	// init SDL video and audio
	if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0)
	{
		printf("SDL could not initialize SDL ERROR: %s\n", SDL_GetError());
		success = false;
	}
	else
	{
		//Set texture filtering to linear
		if (!SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "1"))
		{
			printf("Warning: Linear texture filtering not enabled!");
		}

		// create the window
		window.window = SDL_CreateWindow("Breakout",
			SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
			SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN
			);

		if (window.window == nullptr) {
			printf("Window could not be created SDL ERROR: %s\n", SDL_GetError());
			success = false;

		}
		else
		{
			// create the renderer for the window
			gRenderer = SDL_CreateRenderer(window.window, -1, SDL_RENDERER_ACCELERATED);

			if (gRenderer == nullptr)
			{
				printf("Renderer could not be created SDL ERROR %s\n", SDL_GetError());
				success = false;
			}
			else
			{
				// init png loading
				int imgFlags = IMG_INIT_PNG;

				if (!(IMG_Init(imgFlags) & imgFlags))
				{
					printf("SDL_Image could not be initalized, SDL_Image ERROR: %s\n", IMG_GetError());
					success = false;
				}
				else {
					// init SDL_mixer
					success = bgMusic.init();
				}
			}
		}
	}

	//Initialize SDL_ttf
	if (TTF_Init() == -1)
	{
		printf("SDL_ttf could not initialize! SDL_ttf Error: %s\n", TTF_GetError());
		success = false;
	}

	// Initalizing default constructor of pieces, utilizing copy and move constructors
	Piece defaultInit;
	for (auto i = 0; i < PIECES; i++)
	{
		pieces.push_back(defaultInit);
	}

	// initialize the pieces level 0
	initBlocks(pieces, level);

	threadID = SDL_CreateThread(threading_.threadedFunction, "PrintingThread", static_cast<void*>(&ball));
	threadRunning = true;

	return success;
}
Пример #15
0
void main() 
{
	init_uart(_UART0,_DEFFREQ,_DEFBAUD); // set-up UART0 to 57600, 8n1
	
	timer2000();	//Starts the internal timer 
	LEDinit();		//Activates the LED displays
	LEDsetString("//Reflex Ball\\\\");	

	//Initialization of variables used during the game
	gamedata.ballspeed = 100;
	gamedata.strikerspeed = 20;
	gamedata.wigglecount = 0;
	gamedata.ballcount = 0;
	gamedata.strikercount = 0;
	gamedata.randAngle = 64;
	gamedata.ball2 = 0;
	
	//This loop resets game data and starts a new game
	while(1){
		//Menu 1 evaluates to true when player hits 'play' and selects no. of balls
		if(menu1()){ 
		
			//Ball, striker and block declarations
			Ball_t ball1;
			Ball_t ball2;
			Striker_t striker;
			Block_t block;

			//Ball, striker and block initializations
			ball1.angle = 64;
			gamedata.score = 0;
			gamedata.blocksleft = 0;
			if(gamedata.ball2) ball2.angle = 32;	//Only sets 2nd ball angle if user selects 2 balls
			striker.lives = 3;
			initBall(&ball1,ball1.angle,20,20); 
			if(gamedata.ball2) initBall(&ball2,ball2.angle,30,20);	//Only initializes 2nd ball if user selects it
			initStriker(&striker,62,77,38);

			clrscr();
			initBlocks(&block);		//Creates and draws the blocks on the map
			drawBox();				//Draws the borders of the map

			//Draws striker and various game data
			gotoxy(62,39);
			printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c",219,219,219,219,219,219,219,219,219,219,219,219,219,219,219);
			gotoxy(160,10);
			printf("Lives remaining: %d",striker.lives);
			gotoxy(160,12);
			printf("Score: %d",gamedata.score);
			gotoxy(160, 14);
			printf("Blocks left: %d",gamedata.blocksleft);
			window(158,8,180,16,"Stats",2);
			LEDsetString("Lives: 3");

			//This loop starts the actual game
			while(1) {

				//Quits current game and goes to menu if user hits all three buttons
				if(readkey() == 7){
					break;
				}

				//If all blocks are gone: celebrate with a lady and go back to menu
				if(gamedata.blocksleft == 0)
				{
					clrscr();
					lady();
					wiggleLady();
					break;
				}
				
				if(striker.lives > 0)
				{
					
					if(gamedata.strikerUpdate)  //Only runs when flag is high (controlled by timer)
					{ 
						updateStriker(&striker);
						gamedata.strikerUpdate = 0;

						
						if(striker.drawEnable)	//Only draws striker if it has moved and the flag is high
						{ 
							gotoxy((striker.x1_prev >> FIX14_SHIFT),39);
							printf("               ");			//Deletes 'old' striker
							gotoxy((striker.x1 >> FIX14_SHIFT),39);
							printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c",219,219,219,219,219,219,219,219,219,219,219,219,219,219,219); //Draws 'new' striker
						}
					}

					if(gamedata.ballUpdate) //Only runs when flag is high (controlled by timer)
					{ 
						gotoxy((ball1.xpos >> FIX14_SHIFT),(ball1.ypos >> FIX14_SHIFT));
						printf(" ");		//Deletes 'old' ball
						checkBallpos(&ball1,&striker);	//Checks if ball hits borders of map or striker and changes direction accordingly
						checkBlock(&block,&ball1);		//Checks if ball hits a block and takes actions accordingly
						if(ball1.xspeed == 0 && ball1.yspeed == 0) ball1.xpos = striker.x1 + (striker.x2 - striker.x1)/3;  //Places ball on top of striker if it just died
						updateBall(&ball1, &striker);	//Moves ball according to its vector
						gotoxy((ball1.xpos >> FIX14_SHIFT),(ball1.ypos >> FIX14_SHIFT));
						printf("%c",223);	//Draws 'new' ball

						if(gamedata.ball2) //If 2nd ball is in use, do the same to it as to the first ball above
						{
							gotoxy((ball2.xpos >> FIX14_SHIFT),(ball2.ypos >> FIX14_SHIFT));
							printf(" ");
							checkBallpos(&ball2,&striker);
							checkBlock(&block,&ball2);
							if(ball2.xspeed == 0 && ball2.yspeed == 0) ball2.xpos = striker.x1 + (striker.x2 - striker.x1)/3 + (striker.x2 - striker.x1)/2 ;
							updateBall(&ball2, &striker);
							gotoxy((ball2.xpos >> FIX14_SHIFT),(ball2.ypos >> FIX14_SHIFT));
							printf("%c",223);
						}
						gamedata.ballUpdate = 0;
					}
				}