Example #1
0
int main()
{
	sf2d_init();
	sf2d_set_clear_color(RGBA8(0x40, 0x40, 0x40, 0xFF));

	consoleInit(GFX_BOTTOM, NULL);
	printf("sftd sample\n");

	// Font loading
	sftd_init();
	sftd_font *font = sftd_load_font_mem(airstrike_ttf, airstrike_ttf_size);

	while (aptMainLoop()) {

		hidScanInput();
		if (hidKeysDown() & KEY_START) break;

		sf2d_start_frame(GFX_TOP, GFX_LEFT);

			sftd_draw_text(font, 10, 10, RGBA8(255, 0, 0, 255), 20, "Font drawing on the top screen!");
			sftd_draw_textf(font, 10, 40, RGBA8(0, 255, 0, 255), 20, "FPS %f", sf2d_get_fps());

		sf2d_end_frame();

		sf2d_swapbuffers();
	}

	sftd_free_font(font);
	sftd_fini();

	sf2d_fini();
	return 0;
}
Example #2
0
void setupGame(bool loadUpWorld) {
	currentLevel = 1;

	// Reset entity manager.
	memset(&eManager, 0, sizeof(eManager));
	sf2d_set_clear_color(RGBA8(0x82, 0x6D, 0x6C, 0xFF));

	if (!loadUpWorld) {
		initNewMap();
		initPlayer();
		airWizardHealthDisplay = 2000;
		int i;
		for (i = 0; i < 5; ++i) {
			trySpawn(500, i);
		}
		addEntityToList(newAirWizardEntity(630, 820, 0), &eManager);
		player.p.hasWonSaved = false;
	} else {
		initPlayer();
		loadWorld(currentFileName, &eManager, &player, (u8*) map, (u8*) data);
	}

	initMiniMap(loadUpWorld);
	shouldRenderMap = false;
	mScrollX = 0;
	mScrollY = 0;
	zoomLevel = 2;
    sprintf(mapText,"x%d",zoomLevel);
	initGame = 0;
}
Example #3
0
static int lua_init(lua_State *L) {
    int argc = lua_gettop(L);
    if (argc != 0) return luaL_error(L, "wrong number of arguments");	
    sf2d_init();
	cur_screen = 2;
	sf2d_set_clear_color(RGBA8(0x00, 0x00, 0x00, 0xFF));
    return 0;
}
Example #4
0
static int graphicsSetBackgroundColor(lua_State *L) { // love.graphics.setBackgroundColor()

	int r = luaL_checkinteger(L, 1);
	int g = luaL_checkinteger(L, 2);
	int b = luaL_checkinteger(L, 3);

	sf2d_set_clear_color(RGBA8(r, g, b, 0xFF));

	return 0;

}
Example #5
0
int main(int argc, char **argv)
{
	// Start sf2dlib
	sf2d_init();
	sf2d_set_clear_color(RGBA8(0xF5, 0xF2, 0xEF, 0xFF));

	// Initialize console on top screen
	// consoleInit(GFX_TOP, NULL);

	printf("Sizeof report:\n");
	printf(" > elementNode: %i\n", sizeof(elementNode_s));
	printf(" > elementList: %i\n", sizeof(elementList_s));

	printf(" %2i | %2i |", strcmp("ab", "aa"), strcmp("ab", "ac"));
	printf(" %2i | %2i \n", strcmp("a ", "aA"), strcmp("a ", "aa"));

	AlchemyScene scene;
	scene.initialize();

	// consoleClear();

	keystate_s ks;
	while(aptMainLoop())
	{
		hidKeys(&ks);

		// Draw the top screen
		sf2d_start_frame(GFX_TOP, GFX_LEFT);
			scene.drawTopScreen();
		sf2d_end_frame();
		
		// Draw the bottom screen
		sf2d_start_frame(GFX_BOTTOM, GFX_LEFT);
			scene.drawBottomScreen();
		sf2d_end_frame();

		// Swap the buffers
		sf2d_swapbuffers();

		scene.updateInput(ks);

		// Exit the loop
		if (ks.down & KEY_START) break;
	}
	
	scene.destroy();

	// Stop sf2dlib
	sf2d_fini();

	return 0;
}
Example #6
0
File: gui.c Project: nop90/Vex3DS
void gui_DrawTopScreen() {

    sf2d_set_clear_color(RGBA8(0x00, 0x00, 0x44, 0xFF));

	sf2d_start_frame(GFX_TOP, GFX_LEFT);
		
	if(splash)
		sf2d_draw_texture_part_rotate_scale(splash, 200, 120, 0, 0, 0, splash->width, splash->height, splash->width/400, splash->height/240);
/*

		sf2d_draw_texture_part_rotate_scale(temptext, 200, 120, 0, 0, 0, 160, 102, 1, 1); //1x
*/
	sf2d_end_frame();
}
Example #7
0
int lockScreen()
{
	lockscreenBg = sf2d_create_texture_mem_RGBA8(lockscreen_img.pixel_data, lockscreen_img.width, lockscreen_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM);
	
	time_t unixTime = time(NULL);
	struct tm* timeStruct = gmtime((const time_t *)&unixTime);

	int hours = timeStruct->tm_hour;
	int minutes = timeStruct->tm_min;
	int day = timeStruct->tm_mday;
	
	sf2d_set_clear_color(RGBA8(0, 0, 0, 0));

	while (1)
	{
		hidScanInput();

		u32 kDown = hidKeysDown();
		
		sf2d_start_frame(GFX_TOP, GFX_LEFT);
		
		sf2d_draw_texture(background, 0, 0);
		sf2d_draw_texture(lockscreenBg, 0, 0);
		
		sftd_draw_textf(roboto, 142, 20, RGBA8(255, 255, 255, 255), 34, "0%2d : %02d", hours, minutes);
		sftd_draw_textf(roboto, 140, 80, RGBA8(255, 255, 255, 255), 10, "Monday");
		sftd_draw_textf(roboto, 200, 80, RGBA8(255, 255, 255, 255), 10, "%d", day);
		sftd_draw_textf(roboto, 220, 80, RGBA8(255, 255, 255, 255), 10, "October");
		
		digitalTime(350, 2); 
		batteryStatus(316, 2); 
		cursorController();
		
		sf2d_end_frame();
		
		if ((touch.px  >= 160 && touch.px  <= 235 && touch.py >= 210 && touch.py <= 240) && (kDown & KEY_A))
		{	
			sf2d_free_texture(lockscreenBg);
			return 1;
		}
			
		sf2d_swapbuffers();
	}
	
	sf2d_free_texture(lockscreenBg);
	
	return 0;
}
Example #8
0
void _loadingScreen(void* arg)
{
	TextureManager* that = (TextureManager*) arg;

	sf2d_set_clear_color(RGBA8(0xF8,0xF8,0xF8,0xFF));
	sf2d_set_vblank_wait(false);
	while (threadMainLoop)
	{
		sf2d_start_frame(GFX_TOP, GFX_LEFT);
			that->drawLoadingTopScreen();
		sf2d_end_frame();
		sf2d_start_frame(GFX_BOTTOM, GFX_LEFT);
			that->drawLoadingBottomScreen();
		sf2d_end_frame();
		sf2d_swapbuffers();
	}
	sf2d_set_vblank_wait(true);
}
Example #9
0
void init(void) {
    // Starting services
    sf2d_init();
    sf2d_set_vblank_wait(0);
    sftd_init();
    srvInit();
    aptInit();
    hidInit();
    audio_init();
    //romfsInit();

    // Configuring the right font to use (8bitoperator), and its proprieties
    font = sftd_load_font_file("font/eightbit.ttf");

    // Configuring graphics in general (images, textures, etc)
    sf2d_set_clear_color(RGBA8(0x00, 0x00, 0x00, 0xFF));

    /* Load Frisk textures
       Loop over every element in tex_arr_friskWalk and load the PNG buffer. */

    for (int i = 0; i < 4; ++i) {
        for (int j = 0; j < 4; ++j) {
            tex_arr_friskWalk[i][j] = loadTexture(friskFilenames[i][j]);
        }
    }

    room_init();

    // Reusing 'i' from above.
    // Load room textures.
    for (int i = 0; i < 3; ++i) fillTexture(&rooms[i].bg);

    // TODO: Add actual save loading logic. For now, just assume this room.
    player_pos = rooms[room].exits[0].entrance;

    // Play music
    home = sound_create(BGM);
    if (home != NULL) audio_load_ogg("sound/music/house1.ogg", home);
    else home->status = -1;

    timerStep();
}
Example #10
0
void TextureManager::drawStaticLoadingScreen(void)
{
	// Set the clear color to a false white.
	sf2d_set_clear_color(RGBA8(0xF8,0xF8,0xF8,0xFF));

	// Need to be called twice, probably a bug.
	sf2d_start_frame(GFX_TOP, GFX_LEFT);
	sf2d_end_frame();

	// Render a blank top screen.
	sf2d_start_frame(GFX_TOP, GFX_LEFT);
		drawLoadingTopScreen();
	sf2d_end_frame();

	// Render the loading screen on the bottom screen.
	sf2d_start_frame(GFX_BOTTOM, GFX_LEFT);
		drawLoadingBottomScreen();
	sf2d_end_frame();

	// Swap the buffers
	sf2d_swapbuffers();
}
Example #11
0
// --------------------------------------------------
Result BoxViewer::initialize()
// --------------------------------------------------
{
	if (hasChild()) { if (this->child->initialize() == PARENT_STEP); else return CHILD_STEP; }

	// Use the Save&Data Manager of PHBanku
	save = PHBanku::save;
	data = PHBanku::data;

	// Initialize the 2 boxes content
	cursorBox.inBank = true; selectViewBox();
	cursorBox.inBank = false; selectViewBox();

	// Initialize the current Pokémon
	selectViewPokemon();
	cancelMovePokemon();

	// Change the clear color of sf2d (not useful)
	sf2d_set_clear_color(RGBA8(0x00,0x00,0x00,0xFF));

	return PARENT_STEP;
}
Example #12
0
void setupGame(bool loadUpWorld){
    currentLevel = 1;
    
    // Reset entity manager.
    memset(&eManager, 0, sizeof(eManager));
    sf2d_set_clear_color(RGBA8(0x82, 0x6D, 0x6C, 0xFF));
    
    if(!loadUpWorld){
        initNewMap();
        initPlayer();
        airWizardHealthDisplay = 2000;
        int i;
        for(i=0;i<5;++i){ 
            trySpawn(500, i);    
        }
        addEntityToList(newAirWizardEntity(630,820,0), &eManager);
    } else {
        initPlayer();
        loadWorld(currentFileName, &eManager, &player, (u8*)map, (u8*)data);
    }
    
    initMiniMap(loadUpWorld);
    initGame = 0;  
}
Example #13
0
int main() {

	L = luaL_newstate();
	luaL_openlibs(L);
	luaL_requiref(L, "love", initLove, 1);

	sf2d_init(); // 2D Drawing lib.
	sftd_init(); // Text Drawing lib.
	cfguInit();
	ptmuInit();

	// consoleInit(GFX_BOTTOM, NULL);

	sf2d_set_clear_color(RGBA8(0x0, 0x0, 0x0, 0xFF)); // Reset background color.

	osSetSpeedupEnable(true); // Enables CPU speedup for a free performance boost.

	// Detect if we are running on a .cia, because if we are
	// we load from RomFS rather than the SD Card.
	// TODO: Load RomFS from .3dsx's aswell.

	Result rc = romfsInit();

	romfsExists = (rc) ? false : true;

	// Change working directory

	if (romfsExists) {

		chdir("romfs:/");

	} else {

		char cwd[256];
		getcwd(cwd, 256);
		char newCwd[261];

		strcat(newCwd, cwd);
		strcat(newCwd, "game");
		chdir(newCwd);

	}

	luaL_dobuffer(L, boot_lua, boot_lua_size, "boot"); // Do some setup Lua side.

	// If main.lua exists, execute it.
	// If not then just load the nogame screen.

	if (fileExists("main.lua")) {
		if (luaL_dofile(L, "main.lua")) displayError();
	} else {
		if (luaL_dobuffer(L, nogame_lua, nogame_lua_size, "nogame")) displayError();
	}
	
	if (luaL_dostring(L, "love.timer.step()")) displayError();

	if (luaL_dostring(L, "if love.load then love.load() end")) displayError();

	while (aptMainLoop()) {

		if (shouldQuit) {

			if (forceQuit) break;

			bool shouldAbort = false;

			// lua_getfield(L, LUA_GLOBALSINDEX, "love");
			// lua_getfield(L, -1, "quit");
			// lua_remove(L, -2);

			// if (!lua_isnil(L, -1)) {

			// 	lua_call(L, 0, 1);
			// 	shouldAbort = lua_toboolean(L, 1);
			// 	lua_pop(L, 1);

			// }; TODO: Do this properly.

			if (luaL_dostring(L, "if love.quit then love.quit() end")) displayError();

			if (!shouldAbort && !errorOccured) break;

		} // Quit event

		if (!errorOccured) {

			if (luaL_dostring(L,
				"love.keyboard.scan()\n"
				"love.timer.step()\n"
				"if love.update then love.update(love.timer.getDelta()) end")) {
					displayError();
			}

			// Top screen
			// Left side

			sf2d_start_frame(GFX_TOP, GFX_LEFT);

				if (luaL_dostring(L, "if love.draw then love.draw() end")) displayError();

			sf2d_end_frame();

			// Right side

			if (is3D) {

				sf2d_start_frame(GFX_TOP, GFX_RIGHT);

					if (luaL_dostring(L, "if love.draw then love.draw() end")) displayError();

				sf2d_end_frame();

			}

			// Bot screen

			sf2d_start_frame(GFX_BOTTOM, GFX_LEFT);

				if (luaL_dostring(L, "if love.draw then love.draw() end")) displayError();

			sf2d_end_frame();

			luaL_dostring(L, "love.graphics.present()");

		} else {

			hidScanInput();
			u32 kTempDown = hidKeysDown();
			if (kTempDown & KEY_START) {
				forceQuit = true;
				shouldQuit = true;
			}

			char *errMsg = lua_tostring(L, -1);

			sf2d_start_frame(GFX_TOP, GFX_LEFT);

				lua_getfield(L, LUA_GLOBALSINDEX, "love");
				lua_getfield(L, -1, "errhand");
				lua_remove(L, -2);

				if (!lua_isnil(L, -1)) {

					lua_pushstring(L, errMsg);
					lua_call(L, 1, 0);

				}

			sf2d_end_frame();

			sf2d_start_frame(GFX_BOTTOM, GFX_LEFT);

				lua_getfield(L, LUA_GLOBALSINDEX, "love");
				lua_getfield(L, -1, "errhand");
				lua_remove(L, -2);

				if (!lua_isnil(L, -1)) {

					lua_pushstring(L, errMsg);
					lua_call(L, 1, 0);

				}

			sf2d_end_frame();

			luaL_dostring(L, "love.graphics.present()");

		}

	}

	luaL_dostring(L, "love.audio.stop()");

	lua_close(L);

	sftd_fini();
	sf2d_fini();
	cfguExit();
	ptmuExit();

	if (soundEnabled) ndspExit();
	if (romfsExists) romfsExit();

	return 0;

}
Example #14
0
int main()
{
	sf2d_init();
	sf2d_set_clear_color(RGBA8(0x40, 0x40, 0x40, 0xFF));

	consoleInit(GFX_BOTTOM, NULL);
	printf("intraFont test sinusoid\n");

	intraFontInit();
	intraFont *font = intraFontLoad("/ltn8.pgf", INTRAFONT_CACHE_ASCII);
	intraFontSetStyle(font, 1.0f, 0, 0, 0.0f, INTRAFONT_ALIGN_CENTER);

	struct Sinusoid {
		float angle; // In degrees
		float amplitude;
		float step;
		float speed;
		float speed_inc;
		char str[64];
	} sinus = {0.f,35.f,10.f,0.f,0.007f,"intraFont 0.31 - 2009 by BenHur"};

	float x = 0.0f;
	float y = 0.0f;
	float size = 0.65f;
	float tmp_angle;
	int i;
	u32 held;

	while (aptMainLoop()) {

		hidScanInput();
		held = hidKeysHeld();
		if (held & KEY_START) {
			break;
		} else if (held & KEY_L) {
			size += 0.1f;
		} else if (held & KEY_R) {
			size -= 0.1f;
		}
		if (held & KEY_UP) {
			y -= 3.0f;
		} else if (held & KEY_DOWN) {
			y += 3.0f;
		}
		if (held & KEY_RIGHT) {
			x += 3.0f;
		} else if (held & KEY_LEFT) {
			x -= 3.0f;
		}

		sf2d_start_frame(GFX_TOP, GFX_LEFT);

			//sf2d_draw_rectangle(50, 60, 50, 50, RGBA8(0,255,0,255));

			intraFontSetStyle(font, size, RGBA8(255,0,0,255), RGBA8(0,255,0,255), 0.0f, INTRAFONT_ALIGN_LEFT);
			intraFontPrint(font, x, y, "ola k ase");

			// * Draw the sinusoid *
			/*float draw_x = x - intraFontMeasureText(font,sinus.str)/2;
			// Get the x position of the 1st char
			// Increment the speed
			if (fabsf(sinus.speed += sinus.speed_inc) > 10.f)
				sinus.speed_inc = -sinus.speed_inc;
			// Increment the angle
			tmp_angle = (sinus.angle += sinus.speed);
			if (sinus.angle > 360.f) sinus.angle -= 360.f;

			// Draw one by one
			for (i = 0; i != strlen(sinus.str); i++, tmp_angle += sinus.step) {
				intraFontSetStyle(font, 1.0f, WHITE, BLACK, 45.f*cosf(tmp_angle*M_PI/180.f),
					INTRAFONT_ALIGN_LEFT);
				draw_x = intraFontPrintEx(font, draw_x, y + sinus.amplitude*sinf(tmp_angle*M_PI/180.f),
					sinus.str+i,1);
			}*/

		sf2d_end_frame();

		sf2d_swapbuffers();
	}

	intraFontUnload(font);
	intraFontShutdown();
	sf2d_fini();

	return 0;
}
Example #15
0
void tickMenu(int menu){
    switch(menu){
        case MENU_SETTINGS:
        if(!bindOpt){
            if(!selBut){
		        if (k_up.clicked){ --currentSelection; if(currentSelection < 0)currentSelection=21;}
		        if (k_down.clicked){ ++currentSelection; if(currentSelection > 21)currentSelection=0;}
		        if (k_left.clicked){ left = true;}
		        if (k_right.clicked){ left = false;}
            } else {
                if (k_left.clicked){ 
                    if(left)switchGameBut(true,keys[currentSelection]);
                    else switchMenuBut(true,keys[currentSelection]);
                } else if (k_right.clicked) { 
                    if(left)switchGameBut(false,keys[currentSelection]);
                    else switchMenuBut(false,keys[currentSelection]);
                }
            }
		    
            if (k_accept.clicked) selBut = !selBut;
            if (k_decline.clicked){ 
                bindOpt = true;
                curSaveSel = 0;
            }
        } else {
		    if (k_up.clicked){ --curSaveSel; if(curSaveSel < 0)curSaveSel=2;}
		    if (k_down.clicked){ ++curSaveSel; if(curSaveSel > 2)curSaveSel=0;}
            if (k_decline.clicked){ 
                bindOpt = false;
                errorBut = -1;
            }
            if (k_accept.clicked){
                switch(curSaveSel){
                    case 0: // Exit and save  
                        if(checkPropButtons() == -1){
                            k_up.input = keyProp[0];
                            k_down.input = keyProp[1];
                            k_left.input = keyProp[2];
                            k_right.input = keyProp[3];
                            k_attack.input = keyProp[4];
                            k_menu.input = keyProp[5];
                            k_pause.input = keyProp[6];
                            k_accept.input = keyProp[7];
                            k_decline.input = keyProp[8];
                            k_delete.input = keyProp[9];
                            
                            FILE *fs=fopen("btnSave.bin","wb");
                            fwrite(keyProp,sizeof(int),9,fs);
                            fclose(fs);
                            
                            currentSelection = 2;
                            currentMenu = MENU_TITLE;
                            errorBut = -1;
                        } else errorBut = checkPropButtons();
                        break;
                    case 1: // Exit and DON'T save  
                        currentSelection = 2;
                        currentMenu = MENU_TITLE;
                        errorBut = -1;
                        break;
                    case 2: // reset defaults
	                    keyProp[0] = KEY_DUP | KEY_CPAD_UP | KEY_CSTICK_UP;
	                    keyProp[1] = KEY_DDOWN | KEY_CPAD_DOWN | KEY_CSTICK_DOWN;
	                    keyProp[2] = KEY_DLEFT | KEY_CPAD_LEFT | KEY_CSTICK_LEFT;
	                    keyProp[3] = KEY_DRIGHT | KEY_CPAD_RIGHT | KEY_CSTICK_RIGHT;
	                    keyProp[4] = KEY_A | KEY_B | KEY_L | KEY_ZR;
	                    keyProp[5] = KEY_X | KEY_Y | KEY_R | KEY_ZL;
	                    keyProp[6] = KEY_START;
                        keyProp[7] = KEY_A;
                        keyProp[8] = KEY_B;
                        keyProp[9] = KEY_X;
	                    bindOpt = false;
                        errorBut = -1;
                        break;
                    }
                }
            }
        break;
        case MENU_PAUSED:
            if(!areYouSure && !areYouSureSave){
                if(pauseSaveDisplayTimer > 0) --pauseSaveDisplayTimer;
                if (k_pause.clicked) currentMenu = MENU_NONE;
		        if (k_up.clicked){ --currentSelection; if(currentSelection < 0)currentSelection=2;}
		        if (k_down.clicked){ ++currentSelection; if(currentSelection > 2)currentSelection=0;}
                if (k_accept.clicked){
                    switch(currentSelection){
                    case 0:      
                        currentMenu = MENU_NONE;
                        break;
                    case 1:
	                    areYouSureSave = true;
                        break;
                    case 2:
	                    areYouSure = true;
                        break;
                    }
                }
            } else if(areYouSureSave) {
                if (k_accept.clicked){
                    pauseSaveDisplayTimer = 60;
                    saveCurrentWorld(currentFileName, &eManager, &player, (u8*)map, (u8*)data);
                    areYouSureSave = false;
                    areYouSure = false;
                } else if (k_decline.clicked){
                    areYouSureSave = false;
                    areYouSure = false;
                }
            } else {
                if (k_accept.clicked){
                    areYouSure = false;
                    areYouSureSave = false;
	                sf2d_set_clear_color(0xFF);
                    currentSelection = 0;
                    currentMenu = MENU_TITLE;
                } else if (k_decline.clicked){
                    areYouSure = false;
                    areYouSureSave = false;
                }
            }
        break;
        case MENU_INVENTORY:
            if (k_menu.clicked || k_decline.clicked){
                 currentMenu = MENU_NONE;
                 player.p.activeItem = &noItem;
                 player.p.isCarrying = false;
            }
            if (k_accept.clicked){ // Select item from inventory
                if(player.p.inv->lastSlot!=0){
                    median = player.p.inv->items[curInvSel]; // create copy of item.
                    removeItemFromInventory(curInvSel, player.p.inv); // remove original
                    pushItemToInventoryFront(median, player.p.inv); // add copy to front
                    player.p.activeItem = &player.p.inv->items[0]; // active item = copy.
                    if(player.p.activeItem->id > 27) player.p.isCarrying = true;
                    else player.p.isCarrying = false;
                }
                currentMenu = MENU_NONE;
            }
		    if (k_up.clicked){ --curInvSel; if(curInvSel < 0)curInvSel=player.p.inv->lastSlot-1;}
		    if (k_down.clicked){ ++curInvSel; if(curInvSel > player.p.inv->lastSlot-1)curInvSel=0;}
        break;
        
        case MENU_CRAFTING:
        if (k_menu.clicked || k_decline.clicked) currentMenu = MENU_NONE;
        if (k_accept.clicked){
            int newslot = player.p.activeItem->slotNum + 1;
            if(craftItem(currentRecipes, &currentRecipes->recipes[curInvSel], player.p.inv)){
                playSound(snd_craft);
                if(player.p.activeItem != &noItem)player.p.activeItem = &player.p.inv->items[newslot];
            }
        }
		if (k_up.clicked){ --curInvSel; if(curInvSel < 0)curInvSel=currentRecipes->size-1;}
		if (k_down.clicked){ ++curInvSel; if(curInvSel > currentRecipes->size-1)curInvSel=0;}
        break;
        
        case MENU_WIN:
            if (k_accept.clicked){ 
	            sf2d_set_clear_color(0xFF);
                currentMenu = MENU_TITLE;
                saveCurrentWorld(currentFileName, &eManager, &player, (u8*)map, (u8*)data);
            }
        break;
        case MENU_LOSE:
            if (k_accept.clicked){ 
	            sf2d_set_clear_color(0xFF);
                currentMenu = MENU_TITLE;
            }
        break;
        case MENU_ABOUT:
            if (k_decline.clicked) currentMenu = MENU_TITLE;
        break;
        
        case MENU_CONTAINER:
        if (k_menu.clicked || k_decline.clicked)currentMenu = MENU_NONE;
        
        if (k_left.clicked) {
			curChestEntity->entityFurniture.r = 0;
			int tmp = curInvSel;
			curInvSel = curChestEntity->entityFurniture.oSel;
			curChestEntity->entityFurniture.oSel = tmp;
		}
		if (k_right.clicked) {
			curChestEntity->entityFurniture.r = 1;
			int tmp = curInvSel;
			curInvSel = curChestEntity->entityFurniture.oSel;
			curChestEntity->entityFurniture.oSel = tmp;
		}
		
		Inventory* i1 = curChestEntity->entityFurniture.r == 1 ? player.p.inv : curChestEntity->entityFurniture.inv;
		Inventory* i2 = curChestEntity->entityFurniture.r == 0 ? player.p.inv : curChestEntity->entityFurniture.inv;
		int len = i1->lastSlot;
		if (curInvSel < 0) curInvSel = 0;
		if (curInvSel >= len) curInvSel = len - 1;
		if (k_up.clicked) --curInvSel;
		if (k_down.clicked) ++curInvSel;
		if (len == 0) curInvSel = 0;
		if (curInvSel < 0) curInvSel += len;
		if (curInvSel >= len) curInvSel -= len;
		
		if(k_accept.clicked && len > 0){
            Item* pullItem = &i1->items[curInvSel];
            Item pushItem = newItem(pullItem->id,pullItem->countLevel);
            pushItem.chestPtr = pullItem->chestPtr;
            pushItemToInventoryFront(pushItem, i2);
            if(i2 == player.p.inv){
                int newslot = player.p.activeItem->slotNum + 1;
                player.p.activeItem = &player.p.inv->items[newslot];
            } else if(pullItem == player.p.activeItem){
                player.p.activeItem = &noItem;
            }
            removeItemFromCurrentInv(pullItem);
			if (curInvSel >= i1->lastSlot) curInvSel = i1->lastSlot - 1;
        }
		
        break;
        
        case MENU_LOADGAME:
            if(!enteringName && !areYouSure){ // World select
                if (k_decline.clicked){
                    currentMenu = MENU_TITLE;
                    currentSelection = 0;
                }
                if (k_up.clicked){ --currentSelection; if(currentSelection < 0)currentSelection = worldFileCount;}
                if (k_down.clicked){ ++currentSelection; if(currentSelection > worldFileCount)currentSelection=0;}
            
                if(k_delete.clicked){
                    if(currentSelection < worldFileCount) areYouSure = true;
                }
            
                if(k_accept.clicked){
                    if(currentSelection == worldFileCount){
                        
                        enteringName = true;
                    } else {
                        memset(&currentFileName, 0, 255); // reset currentFileName
                            sprintf(currentFileName,"%s.wld",fileNames[currentSelection]);
                            playSound(snd_test);
                            initGame = 1;
                            currentMenu = MENU_NONE;
                    }
                }
            } else if (areYouSure){
                if (k_decline.clicked || k_delete.clicked) areYouSure = false;
                if (k_accept.clicked){
                    sprintf(currentFileName,"%s.wld",fileNames[currentSelection]);
                    remove(currentFileName);
                    readFiles();
                    enteringName = false;
                    areYouSure = false;
                    memset(&currentFileName, 0, 255); // reset currentFileName
                }
            }else { // Enter new world name.
                if(k_decline.clicked) enteringName = false;
                if(k_accept.clicked && errorFileName == 0){
                    errorFileName = checkFileNameForErrors();
                    if(errorFileName == 0){ // If no errors are found with the filename, then start a new game!
                        memset(&currentFileName, 0, 255); // reset currentFileName
                        sprintf(currentFileName,"%s.wld",fileNames[worldFileCount]);
                        currentMenu = MENU_NONE;
                        playSound(snd_test);
                        initGame = 2;
                        ++worldFileCount;
                    }
                }
                touchPosition touch;
                hidTouchRead(&touch);
                if((touch.px != 0 || touch.py != 0) && touchDelay == 0){ 
                    if(!isTouching)doTouchButton(touch); 
                }
                else if(touch.px == 0 || touch.py == 0) isTouching = false;
                if(touchDelay > 0) --touchDelay;
            }
        break;
        
        case MENU_TITLE:
		    if (k_up.clicked){ --currentSelection; if(currentSelection < 0)currentSelection=4;}
		    if (k_down.clicked){ ++currentSelection; if(currentSelection > 4)currentSelection=0;}
		    
		    if(k_accept.clicked){
                switch(currentSelection){
                    case 0:
                        currentMenu = MENU_LOADGAME;
                        readFiles();
                        currentSelection = 0;
                        enteringName = false;
                        areYouSure = false;
                    break;
                    case 2:
                        keyProp[0] = k_up.input;
                        keyProp[1] = k_down.input;
                        keyProp[2] = k_left.input;
                        keyProp[3] = k_right.input;
                        keyProp[4] = k_attack.input;
                        keyProp[5] = k_menu.input;
                        keyProp[6] = k_pause.input;
                        keyProp[7] = k_accept.input;
                        keyProp[8] = k_decline.input;
                        keyProp[9] = k_delete.input;
                        left = true;
                        selBut = false;
                        bindOpt = false;
                        currentSelection = 0;
                        currentMenu = MENU_SETTINGS;
                    break;
                    case 3: 
                        currentMenu = MENU_ABOUT;
                    break;
                    case 4: 
                        quitGame = true;
                    break;
                }
                
            }
        break;
    }
    
}
Example #16
0
int main() {
    cfguInit();
    CFGU_GetSystemModel(&MODEL_3DS);
	FILE * file;
	shouldRenderDebug = true;
	if ((file = fopen("settings.bin", "r"))) {
        fread(&shouldRenderDebug,sizeof(bool),1,file);
        fread(&shouldSpeedup,sizeof(bool),1,file);
        osSetSpeedupEnable(shouldSpeedup);
		fclose(file);
	}
    
	sf2d_init();
	csndInit();
	noItem = newItem(ITEM_NULL, 0);
	
	currentMenu = MENU_TITLE;
	currentSelection = 0;
	quitGame = false;

	icons = sfil_load_PNG_buffer(icons2_png, SF2D_PLACE_RAM);
	font = sfil_load_PNG_buffer(Font_png, SF2D_PLACE_RAM);
	bottombg = sfil_load_PNG_buffer(bottombg_png, SF2D_PLACE_RAM);
	
	dirtColor[0] = SWAP_UINT32(sf2d_get_pixel(icons, 16, 0)); 
	dirtColor[1] = SWAP_UINT32(sf2d_get_pixel(icons, 16, 1)); 
	dirtColor[2] = SWAP_UINT32(sf2d_get_pixel(icons, 16, 2)); 
	dirtColor[3] = SWAP_UINT32(sf2d_get_pixel(icons, 16, 3)); 
	dirtColor[4] = SWAP_UINT32(sf2d_get_pixel(icons, 16, 4)); 

	loadSound(&snd_playerHurt, "resources/playerhurt.raw");
	loadSound(&snd_playerDeath, "resources/playerdeath.raw");
	loadSound(&snd_monsterHurt, "resources/monsterhurt.raw");
	loadSound(&snd_test, "resources/test.raw");
	loadSound(&snd_pickup, "resources/pickup.raw");
	loadSound(&snd_bossdeath, "resources/bossdeath.raw");
	loadSound(&snd_craft, "resources/craft.raw");
	
	bakeLights();
	
	int i;
	for (i = 0; i < 5; ++i) {
		minimap[i] = sf2d_create_texture(128, 128, TEXFMT_RGBA8,
				SF2D_PLACE_RAM);
		sf2d_texture_tile32(minimap[i]);
	}
	
	sf2d_set_vblank_wait(true);

	sf2d_set_clear_color(0xFF000000);

	k_up.input = KEY_DUP | KEY_CPAD_UP | KEY_CSTICK_UP;
	k_down.input = KEY_DDOWN | KEY_CPAD_DOWN | KEY_CSTICK_DOWN;
	k_left.input = KEY_DLEFT | KEY_CPAD_LEFT | KEY_CSTICK_LEFT;
	k_right.input = KEY_DRIGHT | KEY_CPAD_RIGHT | KEY_CSTICK_RIGHT;
	k_attack.input = KEY_A | KEY_B | KEY_L | KEY_ZR;
	k_menu.input = KEY_X | KEY_Y | KEY_R | KEY_ZL;
	k_pause.input = KEY_START;
	k_accept.input = KEY_A;
	k_decline.input = KEY_B;
	k_delete.input = KEY_X;
	k_menuNext.input = KEY_R;
	k_menuPrev.input = KEY_L;

	if ((file = fopen("btnSave.bin", "rb"))) {
		fread(&k_up.input, sizeof(int), 1, file);
		fread(&k_down.input, sizeof(int), 1, file);
		fread(&k_left.input, sizeof(int), 1, file);
		fread(&k_right.input, sizeof(int), 1, file);
		fread(&k_attack.input, sizeof(int), 1, file);
		fread(&k_menu.input, sizeof(int), 1, file);
		fread(&k_pause.input, sizeof(int), 1, file);
		fread(&k_accept.input, sizeof(int), 1, file);
		fread(&k_decline.input, sizeof(int), 1, file);
		fread(&k_delete.input, sizeof(int), 1, file);
		fread(&k_menuNext.input, sizeof(int), 1, file);
		fread(&k_menuPrev.input, sizeof(int), 1, file);
		fclose(file);
	}
	
	if ((file = fopen("lastTP.bin", "r"))) {
		char fnbuf[256];
		fgets(fnbuf, 256, file); // get directory to texturepack
		loadTexturePack(fnbuf);   
		fclose(file);
	}

	tickCount = 0;
	initRecipes();
	defineTables();
	while (aptMainLoop()) {
		++tickCount;
		hidScanInput();
		tickKeys(hidKeysHeld(), hidKeysDown());

		if (quitGame) break;

		if (initGame > 0) setupGame(initGame == 1 ? true : false);

		if (currentMenu == 0) {
			tick();
			sf2d_start_frame(GFX_TOP, GFX_LEFT);

			offsetX = xscr;
			offsetY = yscr;
			sf2d_draw_rectangle(0, 0, 400, 240, 0xFF0C0C0C); //RGBA8(12, 12, 12, 255)); //You might think "real" black would be better, but it actually looks better that way
			renderLightsToStencil();

			renderBackground(xscr, yscr);
			renderEntities(player.x, player.y, &eManager);
			renderPlayer();
			
			resetStencilStuff();
			offsetX = 0;
			offsetY = 0;
			
			if(shouldRenderDebug){
			    sprintf(fpsstr, " FPS: %.0f, X:%d, Y:%d, E:%d", sf2d_get_fps(), player.x, player.y, eManager.lastSlot[currentLevel]);
			    drawText(fpsstr, 2, 225);
            }
			
			sf2d_end_frame();

            sf2d_start_frame(GFX_BOTTOM, GFX_LEFT);
                if(!shouldRenderMap){
                    sf2d_draw_texture(bottombg, 0, 0);
                    renderGui();
                } else {
                    renderZoomedMap();
                }
            sf2d_end_frame();
		} else {
			tickMenu(currentMenu);
			renderMenu(currentMenu, xscr, yscr);
		}

		sf2d_swapbuffers();
	}

	freeRecipes();

	freeLightBakes();
	sf2d_free_texture(icons);
	sf2d_free_texture(minimap[0]);
	sf2d_free_texture(minimap[1]);
	sf2d_free_texture(minimap[2]);
	sf2d_free_texture(minimap[3]);
	sf2d_free_texture(minimap[4]);
	freeSounds();
	csndExit();
    cfguExit();
	sf2d_fini();
	return 0;
}
Example #17
0
int settingsMenu()
{
	settingsBg = sf2d_create_texture_mem_RGBA8(settings_img.pixel_data, settings_img.width, settings_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM);
	
	about_highlight = sf2d_create_texture_mem_RGBA8(about_highlight_img.pixel_data, about_highlight_img.width, about_highlight_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM);
	display_highlight = sf2d_create_texture_mem_RGBA8(display_highlight_img.pixel_data, display_highlight_img.width, display_highlight_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM);
	developeroptions_highlight = sf2d_create_texture_mem_RGBA8(developeroptions_highlight_img.pixel_data, developeroptions_highlight_img.width, developeroptions_highlight_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM);
	performance_highlight = sf2d_create_texture_mem_RGBA8(performance_highlight_img.pixel_data, performance_highlight_img.width, performance_highlight_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM);
	security_highlight = sf2d_create_texture_mem_RGBA8(security_highlight_img.pixel_data, security_highlight_img.width, security_highlight_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM);
	wifi_highlight = sf2d_create_texture_mem_RGBA8(wifi_highlight_img.pixel_data, wifi_highlight_img.width, wifi_highlight_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM);

	sf2d_set_clear_color(RGBA8(0, 0, 0, 0));
	
	while (aptMainLoop())
	{
		hidScanInput();

		u32 kDown = hidKeysDown();
		
		sf2d_start_frame(GFX_TOP, GFX_LEFT);
		
		sf2d_draw_texture(settingsBg, 0, 0);
		
		sftd_draw_textf(roboto, 48, 106, RGBA8(0, 0, 0, 255), 12, "%s", lang_settingsMain[language][0]);
		sftd_draw_textf(roboto, 48, 153, RGBA8(0, 0, 0, 255), 12, "%s", lang_settingsMain[language][1]);
		sftd_draw_textf(roboto, 48, 202, RGBA8(0, 0, 0, 255), 12, "%s", lang_settingsMain[language][2]);
		sftd_draw_textf(roboto, 250, 106, RGBA8(0, 0, 0, 255), 12, "%s", lang_settingsMain[language][3]);
		sftd_draw_textf(roboto, 250, 153, RGBA8(0, 0, 0, 255), 12, "%s", lang_settingsMain[language][4]);
		sftd_draw_textf(roboto, 250, 202, RGBA8(0, 0, 0, 255), 12, "%s", lang_settingsMain[language][5]);
		
		settingsHighlight();
		
		digitalTime(350, 2); 
		batteryStatus(316, 2); 
		androidQuickSettings();
		cursorController();
		
		sf2d_end_frame();
		
		navbarControls(1); 
		
		if (kDown & KEY_Y)
			powerMenu(); 
		
		if (kDown & KEY_L)
			lockScreen();
		
		if (kDown & KEY_B)
		{
			settingsUnload();
			appDrawer();
		}
		
		if ((touch.px  >= 44 && touch.px  <= 119 && touch.py >= 201 && touch.py <= 240) && (kDown & KEY_A))
		{
			settingsUnload();
			appDrawer();
		}
		
		else if ((touch.px  >= 120 && touch.px  <= 195 && touch.py >= 201 && touch.py <= 240) && (kDown & KEY_A))
		{
			settingsUnload();
			home();
		}
		
		sf2d_swapbuffers();
	}
	
	settingsUnload();
	
	return 0;
}
Example #18
0
int main()
{
	sf2d_init();
	csndInit();
	noItem = newItem(ITEM_NULL,0);
	
	currentMenu = MENU_TITLE;
    currentSelection = 0;
	quitGame = false;

    icons = sfil_load_PNG_buffer(icons2_png, SF2D_PLACE_RAM);
    font = sfil_load_PNG_buffer(Font_png, SF2D_PLACE_RAM);
	
	//consoleInit(GFX_BOTTOM, NULL);
   // printf("Press 'Start' to exit.\n");

	loadSound(&snd_playerHurt, "resources/playerhurt.raw");
	loadSound(&snd_playerDeath, "resources/playerdeath.raw");
	loadSound(&snd_monsterHurt, "resources/monsterhurt.raw");
	loadSound(&snd_test, "resources/test.raw");
	loadSound(&snd_pickup, "resources/pickup.raw");
	loadSound(&snd_bossdeath, "resources/bossdeath.raw");
	loadSound(&snd_craft, "resources/craft.raw");
    
    int i;
    for(i = 0;i < 5;++i){
       minimap[i] = sf2d_create_texture(128,128,TEXFMT_RGBA8,SF2D_PLACE_RAM);
	   sf2d_texture_tile32(minimap[i]);
    }
    
    sf2d_set_vblank_wait(true);
	
	sf2d_set_clear_color(0xFF);
	
	/* Default inputs */
	k_up.input = KEY_DUP | KEY_CPAD_UP | KEY_CSTICK_UP;
	k_down.input = KEY_DDOWN | KEY_CPAD_DOWN | KEY_CSTICK_DOWN;
	k_left.input = KEY_DLEFT | KEY_CPAD_LEFT | KEY_CSTICK_LEFT;
	k_right.input = KEY_DRIGHT | KEY_CPAD_RIGHT | KEY_CSTICK_RIGHT;
	k_attack.input = KEY_A | KEY_B | KEY_L | KEY_ZR;
	k_menu.input = KEY_X | KEY_Y | KEY_R | KEY_ZL;
	k_pause.input = KEY_START;
    k_accept.input = KEY_A;
    k_decline.input = KEY_B;
    k_delete.input = KEY_X;
    FILE * file;
    
    /* If btnSave exists, then use that. */
    if ((file = fopen("btnSave.bin", "rb"))){
        fread(&k_up.input, sizeof(int), 1, file);
        fread(&k_down.input, sizeof(int), 1, file);
        fread(&k_left.input, sizeof(int), 1, file);
        fread(&k_right.input, sizeof(int), 1, file);
        fread(&k_attack.input, sizeof(int), 1, file);
        fread(&k_menu.input, sizeof(int), 1, file);
        fread(&k_pause.input, sizeof(int), 1, file);
        fread(&k_accept.input, sizeof(int), 1, file);
        fread(&k_decline.input, sizeof(int), 1, file);
        fread(&k_delete.input, sizeof(int), 1, file);
        fclose(file);
    }
	
	//screenShot = false;
	
    tickCount=0;
    initRecipes();
    defineTables();
	while (aptMainLoop()) {
		++tickCount;
		hidScanInput();
		tickKeys(hidKeysHeld(),hidKeysDown());

		//if (quitGame || hidKeysHeld() & KEY_SELECT) break;
		if (quitGame) break;
		//if (hidKeysDown() & (KEY_L | KEY_R)) screenShot = true;
	//	else screenShot = false;
        
        if(initGame > 0) setupGame(initGame == 1 ? true : false);
        
        if(currentMenu == 0){
            tick();
            sprintf(fpsstr, " FPS: %.0f, X:%d, Y:%d, E:%d", sf2d_get_fps(),player.x, player.y,eManager.lastSlot[currentLevel]);
		    sf2d_start_frame(GFX_TOP, GFX_LEFT);
                if(currentLevel == 0){ 
                    sf2d_draw_texture_part_scale(minimap[1],(-xscr/3)-256,(-yscr/3)-32,0,0,128,128,12.5,7.5);
                    sf2d_draw_rectangle(0,0,400,240, 0xDFDFDFAF);
                }
	            offsetX = xscr;offsetY = yscr;
		        renderBackground(xscr,yscr);
		        renderEntities(player.x, player.y, &eManager);
		        renderPlayer();
	            offsetX = 0;offsetY = 0;
		        renderItemWithText(player.p.activeItem, 10, 205);
		       // drawText(debugText,2,208);
		        drawText(fpsstr,2,225);
		    sf2d_end_frame();
		      
		    sf2d_start_frame(GFX_BOTTOM, GFX_LEFT);	
		        if(currentLevel == 0 && airWizardHealthDisplay > 0){ 
                    sprintf(bossHealthText, "BOSS: %.0f%%", ((float)airWizardHealthDisplay/2000.0)*100);
                    drawText(bossHealthText,2,225);
                }
		        renderGui();
                sf2d_draw_texture(minimap[currentLevel], 192, 112);//y:56
            sf2d_end_frame();
        } else{ 
            tickMenu(currentMenu);
            renderMenu(currentMenu,xscr,yscr);
        }
        
		sf2d_swapbuffers();
	}
	
    freeRecipes();
	sf2d_free_texture(icons);
	sf2d_free_texture(minimap[0]);
	sf2d_free_texture(minimap[1]);
	sf2d_free_texture(minimap[2]);
	sf2d_free_texture(minimap[3]);
	sf2d_free_texture(minimap[4]);
    freeSounds();
    csndExit();
	sf2d_fini();
	return 0;
}
Example #19
0
int main()
{
	char* names[] = {
		"nul/20",
		"item1",
		"second item",
		"the third one",
		"item4",
		"item5",
		"item6",
		"item7",
		"item8",
		"item9",
		"item10",
		"item11",
		"item12",
		"item13",
		"item14",
		"item15",
		"item16",
		"item17",
		"item18",
		"item19",
		"item20",
		"item21",
		"item22",
		"item23",
		"item24",
		"item25",
		"item26",
		"item27",
		"item28",
		"item29"
	};

	int nbitems = 30;
	uint8_t owneditem[nbitems];
	for (int i=0; i<nbitems; i++) owneditem[i] = 0;

	sf2d_init();
	sf2d_set_clear_color(RGBA8(255, 255, 255, 255));
	sf2d_set_vblank_wait(0);

	// Font loading
	sftd_init();
	sftd_font* font = sftd_load_font_mem(FreeSans_ttf, FreeSans_ttf_size);

	int fontSize = 20;

	int row = 0;
	int nbrow = 10;
	int firstrow = 0;

#define LONG_TIMEOUT 500
#define SHORT_TIMEOUT_MAX 100
#define SHORT_TIMEOUT_MIN 20

	u64 oldTime = osGetTime();
	u64 timer = 0;
	u64 timeout = LONG_TIMEOUT;

	while (aptMainLoop()) {

		hidScanInput();
		if (hidKeysDown() & KEY_START) break;

		if ((hidKeysHeld() & KEY_UP) && timer == 0) row--;
		if (row == -1) {
			row++;
			firstrow--;
			if (firstrow == -1) {
				row = nbrow-1;
				firstrow = nbitems-nbrow;
			}
		}

		if ((hidKeysHeld() & KEY_DOWN) && timer == 0) row++;
		if (row == nbrow) {
			row--;
			firstrow++;
			if (firstrow+nbrow == nbitems+1) {
				firstrow = 0;
				row = 0;
			}
		}

		int index = firstrow+row;
		owneditem[index] += 100;
		if (hidKeysDown() & KEY_LEFT) owneditem[index]--;
		if (hidKeysDown() & KEY_RIGHT) owneditem[index]++;
		owneditem[index] %= 100;

		// use osGetTime to have key repetition
		u64 newTime = osGetTime();
		u64 delay = newTime-oldTime;
		oldTime = newTime;
		if (hidKeysHeld()) {
			timer += delay;
			if (timer>timeout) {
				timer = 0;
				if (timeout == LONG_TIMEOUT) {
					timeout = SHORT_TIMEOUT_MAX;
				} else {
					timeout = umax(timeout-2, SHORT_TIMEOUT_MIN);
				}
			}
		} else {
			timer = 0;
			timeout = LONG_TIMEOUT;
		}

		sf2d_start_frame(GFX_TOP, GFX_LEFT);
		{
			for (int i=0; i<nbrow; i++) {
				unsigned int color = RGBA8(0, 0, 0, 255);
				if (i == row) {
					sf2d_draw_rectangle(0, i*fontSize, 400, fontSize, RGBA8(0, 0, 0, 255));
					color = RGBA8(255, 255, 255, 255);
				}
				sftd_draw_textf(font, 010, i*fontSize, color, fontSize, names[firstrow+i]);
				sftd_draw_textf(font, 210, i*fontSize, color, fontSize, "%i", owneditem[firstrow+i]);
			}
		}
		sf2d_end_frame();

		sf2d_start_frame(GFX_BOTTOM, GFX_LEFT);
		{
			sftd_draw_textf(font, 0, 20, RGBA8(0, 255, 0, 255), 20, "Press START to exit");
			sftd_draw_textf(font, 0, 40, RGBA8(0, 255, 0, 255), 20, "Timeout: %i", timeout);
		}
		sf2d_end_frame();

		sf2d_swapbuffers();
	}

	sftd_free_font(font);
	sftd_fini();

	sf2d_fini();
	return 0;
}
Example #20
0
int home()
{
	sf2d_set_clear_color(RGBA8(0, 0, 0, 0));

	ic_allapps_pressed = sf2d_create_texture_mem_RGBA8(ic_allapps_pressed_img.pixel_data, ic_allapps_pressed_img.width, ic_allapps_pressed_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM);
	
	ic_launcher_browser = sf2d_create_texture_mem_RGBA8(ic_launcher_browser_img.pixel_data, ic_launcher_browser_img.width, ic_launcher_browser_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM);
	ic_launcher_messenger = sf2d_create_texture_mem_RGBA8(ic_launcher_messenger_img.pixel_data, ic_launcher_messenger_img.width, ic_launcher_messenger_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM);
	ic_launcher_apollo = sf2d_create_texture_mem_RGBA8(ic_launcher_apollo_img.pixel_data, ic_launcher_apollo_img.width, ic_launcher_apollo_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM);
	ic_launcher_settings = sf2d_create_texture_mem_RGBA8(ic_launcher_settings_img.pixel_data, ic_launcher_settings_img.width, ic_launcher_settings_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM);
	
	// Main loop
	while (aptMainLoop())
	{

		//Scan all the inputs. This should be done once for each frame
		hidScanInput();
		
		//hidKeysDown returns information about which buttons have been just pressed (and they weren't in the previous frame)
		u32 kDown = hidKeysDown();
		//hidKeysUp returns information about which buttons have been just released
		//u32 kUp = hidKeysUp();
		
		sf2d_start_frame(GFX_TOP, GFX_LEFT);
		
		sf2d_draw_texture(background, 0, 0);
		
		sf2d_draw_texture(ic_launcher_browser, 49, 145);
		sf2d_draw_texture(ic_launcher_messenger, 114, 145);
		sf2d_draw_texture(ic_launcher_apollo, 241, 145);
		sf2d_draw_texture(ic_launcher_settings, 306, 145);
		appDrawerIcon();

		dayNightWidget();
		
		navbarControls(0); //Displays navbar
		digitalTime(350, 2); //Displays digital time
		batteryStatus(316, 2); //Displays battery status
		cursorController();
		
		sf2d_end_frame();
		
		if ((touch.px  >= 170 && touch.px  <= 210 && touch.py >= 148 && touch.py <= 190) && (kDown & KEY_A))
		{
			sf2d_free_texture(ic_allapps_pressed);
			appDrawer(); //Open app drawer
		}
		
		if ((touch.px  >= 306 && touch.px  <= 351 && touch.py >= 145 && touch.py <= 190) && (kDown & KEY_A))
		{
			sf2d_free_texture(ic_allapps_pressed);
			settingsMenu(); //Open settings menu
		}
		
		if (kDown & KEY_Y)
			powerMenu(); //Open power menu
		
		if (kDown & KEY_L)
			lockScreen(); //Locks the screen

		// Flush and swap framebuffers
		sf2d_swapbuffers();
	}

	sf2d_free_texture(ic_allapps_pressed);
	
	return 0;
}
Example #21
0
int main()
{
    // Set the random seed based on the time
    srand(time(NULL));

    sf2d_init();
    sf2d_set_clear_color(RGBA8(0x40, 0x40, 0x40, 0xFF));


    sf2d_texture *tex1 = sf2d_create_texture_mem_RGBA8(dice_img.pixel_data, dice_img.width, dice_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM);
    sf2d_texture *tex2 = sf2d_create_texture_mem_RGBA8(citra_img.pixel_data, citra_img.width, citra_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM);

    float rad = 0.0f;
    u16 touch_x = 320/2;
    u16 touch_y = 240/2;
    touchPosition touch;
    circlePosition circle;
    u32 held;

    while (aptMainLoop()) {

        hidScanInput();
        hidCircleRead(&circle);
        held = hidKeysHeld();

        if (held & KEY_START) {
            break;
        } else if (held & KEY_TOUCH) {
            hidTouchRead(&touch);
            touch_x = touch.px;
            touch_y = touch.py;
        } else if (held & (KEY_L | KEY_R)) {
            sf2d_set_clear_color(RGBA8(rand()%255, rand()%255, rand()%255, 255));
        }

        sf2d_start_frame(GFX_TOP, GFX_LEFT);
        sf2d_draw_rectangle_rotate(260, 20, 40, 40, RGBA8(0xFF, 0xFF, 0x00, 0xFF), -2.0f*rad);
        sf2d_draw_rectangle(20, 60, 40, 40, RGBA8(0xFF, 0x00, 0x00, 0xFF));
        sf2d_draw_rectangle(5, 5, 30, 30, RGBA8(0x00, 0xFF, 0xFF, 0xFF));
        sf2d_draw_texture_rotate(tex1, 400/2 + circle.dx, 240/2 - circle.dy, rad);
        sf2d_end_frame();

        sf2d_start_frame(GFX_BOTTOM, GFX_LEFT);
        sf2d_draw_rectangle_rotate(190, 160, 70, 60, RGBA8(0xFF, 0xFF, 0xFF, 0xFF), 3.0f*rad);
        sf2d_draw_rectangle(30, 100, 40, 60, RGBA8(0xFF, 0x00, 0xFF, 0xFF));
        sf2d_draw_texture_rotate(tex2, touch_x, touch_y, -rad);
        sf2d_draw_rectangle(160-15 + cosf(rad)*50.0f, 120-15 + sinf(rad)*50.0f, 30, 30, RGBA8(0x00, 0xFF, 0xFF, 0xFF));
        sf2d_draw_fill_circle(40, 40, 35, RGBA8(0x00, 0xFF, 0x00, 0xFF));
        sf2d_end_frame();

        rad += 0.2f;

        sf2d_swapbuffers();
    }

    sf2d_free_texture(tex1);
    sf2d_free_texture(tex2);

    sf2d_fini();
    return 0;
}
Example #22
0
int main()
{
	//gfxInitDefault();
	sf2d_init();
	sf2d_set_clear_color(RGBA8(0x40, 0x40, 0x40, 0xFF));
	consoleInit(GFX_TOP, NULL);
	
	Result rc = _srvGetServiceHandle(&romfsRealHandle, "fs:USER");
	printf("realHandle: %08lX\n", rc);
	
	rc = FSUSER_Initialize(&romfsRealHandle);
	printf("initReal: %08lX\n", rc);

    // Regular RomFS
	u8 zeros[0xC];
	memset(zeros, 0, sizeof(zeros));

	FS_archive arch = { ARCH_ROMFS, { PATH_EMPTY, 1, (u8*)"" }, 0, 0 };
	FS_path path = { PATH_BINARY, sizeof(zeros), zeros };
	Handle romFS_file;

	rc = FSUSER_OpenFileDirectly(&romfsRealHandle, &romFS_file, arch, path, FS_OPEN_READ, FS_ATTRIBUTE_NONE);
	printf("romfsOpen: %08lX\n", rc);
    
	rc = romfsInitFromFile(romFS_file, 0);
	u8 *decomp_out;
	u8 *darc_decomp;
	u32 decomp_size;
	u32 darc_decomp_size;
	sf2d_texture **mon;
	char *mon_garc;
	char *box_garc;
	if (rc)
	{
		printf("romfsInit: %08lX\n", rc);
		mon_garc = "sdmc:/1";
		box_garc = "sdmc:/3_box";
	}
	else
	{
		printf("romfs Init Successful!\n");
		mon_garc = "romfs:/a/0/9/3"; //Pokemon X/Y
		box_garc = "romfs:/a/1/0/4"; //Pokemon X/Y
		
		u32 num_mon = gnumrecords(mon_garc);
		if(!num_mon)
		{
		    mon_garc = "sdmc:/1";
		    num_mon = gnumrecords(mon_garc);
		}
		
		u32 box_test = gnumrecords(box_garc);
		if(!box_test)
		{
		    box_garc = "sdmc:/3_box";
		}
	}
	
	u32 num_mon = gnumrecords(mon_garc);
	mon = (sf2d_texture**)malloc(num_mon * sizeof(sf2d_texture*));
	printf("Loading sprites...");
	
	int i;
	for(i = 0; i < 32; i++)
	{
	    gfread(mon_garc, i, &decomp_out, &decomp_size); 	
	    sf2d_texture *mon_sprite = create_texture_from_xy7_clim(decomp_out, decomp_size);
	    mon[i] = mon_sprite;
	    free(decomp_out);
	}
	printf("Pokemon sprites read.\n");
	    
	gfread(box_garc, 0, &darc_decomp, &darc_decomp_size);
	printf("Box sprites read.\n");

	u32 box_clim_size;
	u32 box_bg_size;
	u32 box_name_size;
	void *box_clim;
	void *box_bg_clim;
	void *box_name;
	    
	if(darc_decomp)
	{
	    printf("darc_file: %x\n", box_clim);
	}
	
	printf("All read!\n");
	sf2d_texture *cursor = load_texture_from_darc(pokedarc_get_darc(darc_decomp), "cursol01.bclim");
	sf2d_texture *wallpaper = load_texture_from_darc(pokedarc_get_darc(darc_decomp), "box_wp02.bclim");
	sf2d_texture *name_box = load_texture_from_darc(pokedarc_get_darc(darc_decomp), "box_name02.bclim");
	
	sf2d_texture *mode01 = load_texture_from_darc(pokedarc_get_darc(darc_decomp), "mode01.bclim");
	sf2d_texture *mode02 = load_texture_from_darc(pokedarc_get_darc(darc_decomp), "mode02.bclim");
	sf2d_texture *mode03 = load_texture_from_darc(pokedarc_get_darc(darc_decomp), "mode03.bclim");
	
	sf2d_texture *left_button = load_texture_from_darc(pokedarc_get_darc(darc_decomp), "left_button.bclim");
	sf2d_texture *right_button = load_texture_from_darc(pokedarc_get_darc(darc_decomp), "right_button.bclim");
	
	float cursor_spot = 0;
	u8 cursor_direction = 1;
	float cursor_add = 0.4f;
	u8 cursor_mon_x = 3;
	u8 cursor_mon_y = 2;

	// Main loop
	while (aptMainLoop())
	{
		hidScanInput();
		
		if(cursor_direction)
		{
		    cursor_spot += cursor_add;
		    if(cursor_spot >= 5.0f)
		        cursor_direction--;
		}
		else
		{
		    cursor_spot -= cursor_add;
		    if(cursor_spot <= 0.0f)
		        cursor_direction++;
		}
		
		sf2d_start_frame(GFX_BOTTOM, GFX_LEFT);
		    clim_draw_texture(wallpaper, 0, 0);
		    
		    clim_draw_texture(mode01, 25, 0);
		    clim_draw_texture(mode02, 25+50+10, 0);
		    clim_draw_texture(mode03, 25+50+10+50+10, 0);
		    
		    clim_draw_texture(name_box, 20, 20);
		    clim_draw_texture(left_button, 5, 20);
		    clim_draw_texture(right_button, 20+name_box->width, 20);
		    
		    int x, y;
		    int i = 1;
		    for(y = 0; y < 5; y++)
		    {
		        for(x = 0; x < 6; x++)
		        {
		            clim_draw_texture(mon[i], 10+(x*32), 45+(y*30));
		            i++;
		        }
		    }
			
			clim_draw_texture(cursor, (int)(10-5+((cursor_mon_x + 1) * 32)-cursor_spot), (int)(45+5+((cursor_mon_y - 1) * 30)+cursor_spot));
		sf2d_end_frame();

		u32 kDown = hidKeysDown();
		if (kDown & KEY_START)
			break; // break in order to return to hbmenu
			
		sf2d_swapbuffers();
	}

    sf2d_fini();
	romfsExit();
	gfxExit();
	return 0;
}
Example #23
0
File: main.c Project: yuriks/mgba
int main() {
	hasSound = !csndInit();

	rotation.d.sample = _sampleRotation;
	rotation.d.readTiltX = _readTiltX;
	rotation.d.readTiltY = _readTiltY;
	rotation.d.readGyroZ = _readGyroZ;

	stream.postVideoFrame = 0;
	stream.postAudioFrame = 0;
	stream.postAudioBuffer = _postAudioBuffer;

	if (!allocateRomBuffer()) {
		return 1;
	}

	if (hasSound) {
		audioLeft = linearAlloc(AUDIO_SAMPLES * sizeof(int16_t));
		audioRight = linearAlloc(AUDIO_SAMPLES * sizeof(int16_t));
	}

	sf2d_init();
	sf2d_set_clear_color(0);
	tex = sf2d_create_texture(256, 256, TEXFMT_RGB565, SF2D_PLACE_RAM);
	memset(tex->data, 0, 256 * 256 * 2);

	sdmcArchive = (FS_archive) {
		ARCH_SDMC,
		(FS_path) { PATH_EMPTY, 1, (const u8*)"" },
		0, 0
	};
	FSUSER_OpenArchive(0, &sdmcArchive);

	logFile = VFileOpen("/mgba.log", O_WRONLY | O_CREAT | O_TRUNC);
	struct GUIFont* font = GUIFontCreate();

	if (!font) {
		goto cleanup;
	}

	struct GBAGUIRunner runner = {
		.params = {
			320, 240,
			font, "/",
			_drawStart, _drawEnd, _pollInput,
			0, 0,

			GUI_PARAMS_TRAIL
		},
		.setup = _setup,
		.teardown = 0,
		.gameLoaded = _gameLoaded,
		.gameUnloaded = _gameUnloaded,
		.prepareForFrame = 0,
		.drawFrame = _drawFrame,
		.pollGameInput = _pollGameInput
	};
	GBAGUIInit(&runner, 0);
	GBAGUIRunloop(&runner);
	GBAGUIDeinit(&runner);

cleanup:
	linearFree(renderer.outputBuffer);

	if (logFile) {
		logFile->close(logFile);
	}

	sf2d_free_texture(tex);
	sf2d_fini();

	if (hasSound) {
		linearFree(audioLeft);
		linearFree(audioRight);
	}
	csndExit();
	return 0;
}
Example #24
0
int main()
{
	touchPosition touch;

	sf2d_init();
	sftd_init();

	sftd_font *text = sftd_load_font_mem(Roboto_ttf, Roboto_ttf_size);
	sftd_font *title = sftd_load_font_mem(RobotoThin_ttf, RobotoThin_ttf_size);

	sf2d_texture *logo = sfil_load_PNG_buffer(logo_png, SF2D_PLACE_RAM);
	sf2d_texture *record = sfil_load_PNG_buffer(record_png, SF2D_PLACE_RAM);
	sf2d_texture *stop = sfil_load_PNG_buffer(stop_png, SF2D_PLACE_RAM);

	sf2d_set_clear_color(RGBA8(0xFA, 0xFA, 0xFA, 0xFF));

	sharedmem = (u32*)memalign(0x1000, sharedmem_size);
	audiobuf = linearAlloc(audiobuf_size);

	MIC_Initialize(sharedmem, sharedmem_size, control, 0, 3, 1, 1);//See mic.h.

	// Threading stuff
	svcCreateEvent(&threadRequest,0);
	u32 *threadStack = memalign(32, STACKSIZE);
	svcCreateThread(&threadHandle, threadMic, 0, &threadStack[STACKSIZE/4], 0x3f, 0);

	while(aptMainLoop())
	{
		hidScanInput();
		hidTouchRead(&touch);

		u32 kDown = hidKeysDown();

		if (kDown & KEY_START)
			break; // break in order to return to hbmenu

		sf2d_start_frame(GFX_TOP, GFX_LEFT);
			sf2d_draw_texture(logo, 60, 70);
			sftd_draw_text(title, 177, 80, RGBA8(0, 0, 0, 222), 40, "Audio");
			sftd_draw_text(title, 175, 120, RGBA8(0, 0, 0, 222), 40, "Recorder");
		sf2d_end_frame();

		sf2d_start_frame(GFX_BOTTOM, GFX_LEFT);
			sf2d_draw_texture(record, 85, 85);
			sf2d_draw_texture(stop, 165, 85);
		sf2d_end_frame();

		svcSignalEvent(threadRequest);

		if(print == 1)
		{
			sf2d_start_frame(GFX_TOP, GFX_LEFT);
				sf2d_draw_texture(logo, 60, 70);
				sftd_draw_text(title, 177, 80, RGBA8(0, 0, 0, 222), 40, "Audio");
				sftd_draw_text(title, 175, 120, RGBA8(0, 0, 0, 222), 40, "Recorder");
				sftd_draw_text(text, 130, 209, RGBA8(0, 0, 0, 222), 16, "Recording audio...");
			sf2d_end_frame();
		}

		if(recording == 2)
		{
			sf2d_start_frame(GFX_TOP, GFX_LEFT);
				sf2d_draw_texture(logo, 60, 70);
				sftd_draw_text(title, 177, 80, RGBA8(0, 0, 0, 222), 40, "Audio");
				sftd_draw_text(title, 175, 120, RGBA8(0, 0, 0, 222), 40, "Recorder");
				sftd_draw_text(text, 130, 209, RGBA8(0, 0, 0, 222), 16, "Saving audio...");
			sf2d_end_frame();
		}

		sf2d_swapbuffers();
	}

	MIC_Shutdown();

	sftd_free_font(text);
	sftd_free_font(title);
	sf2d_free_texture(logo);
	sf2d_free_texture(record);
	sf2d_free_texture(stop);

	// tell thread to exit
	threadExit = true;

	// signal the thread
	svcSignalEvent(threadRequest);

	// give it time to exit
	svcSleepThread(10000000ULL);

	// close handles and free allocated stack
	svcCloseHandle(threadRequest);
	svcCloseHandle(threadHandle);
	free(threadStack);

	free(sharedmem);
	linearFree(audiobuf);
	linearFree(nomute_audiobuf);

	sf2d_fini();
	sftd_fini();
	return 0;
}
Example #25
0
int main()
{
	sf2d_init();
	sf2d_set_vblank_wait(0);

	// this will depend on the level
	uint8_t mapWidth = 4;
	uint8_t mapHeight = 3;
	uint16_t mapDim = mapWidth*mapHeight;
	uint8_t map_u[mapDim];
	uint16_t mapLength = generateLevel(map_u, mapWidth, mapHeight, 12);
	uint8_t map[mapDim];
	memcpy(map, map_u, mapDim);

	// get some drawing parameters
	uint16_t areaWidth = TWIDTH*2/3;
	uint16_t areaHeight = THEIGHT*2/3;
	uint16_t recWidth = areaWidth/mapWidth;
	uint16_t recHeight = areaHeight/mapHeight;
	uint16_t areaTop = (THEIGHT-mapHeight*recHeight)/2;
	uint16_t areaLeft = (TWIDTH-mapWidth*recWidth)/2;

	uint8_t curX = 0;
	uint8_t curY = 0;
	uint16_t playerLength = 0;
	float colorInterpolation = 0;

	u64 oldTime = 0;
	u64 keyTime = 0;

	while (aptMainLoop()) {
		// manage timer according to time passed since last frame
		u64 newTime = osGetTime();
		keyTime += newTime-oldTime;
		oldTime = newTime;

		hidScanInput();
		if (hidKeysDown() & KEY_START) break;

		// move cursor according to input
		uint16_t oldCurXY = curY*mapWidth+curX;
		curX += mapWidth;
		curY += mapHeight;
		if (hidKeysDown() & KEY_LEFT) curX--;
		if (hidKeysDown() & KEY_RIGHT) curX++;
		if (hidKeysDown() & KEY_UP) curY--;
		if (hidKeysDown() & KEY_DOWN) curY++;
		curX %= mapWidth;
		curY %= mapHeight;
		uint16_t newCurXY = curY*mapWidth+curX;

		if (newCurXY != oldCurXY) {
			map[newCurXY]--;
			playerLength++;
			keyTime=0; // force cursor display now
		}
		if (map[newCurXY] == 255) {
			// reset level
			curX = 0;
			curY = 0;
			playerLength = 0;
			memcpy(map, map_u, mapDim);
		}
		if (playerLength == mapLength) break; // TODO should be "you won"

		u32 targetColor = RGBA8(0x00,0xaa,0xaa,255);
		float targetInterpolation = (float)playerLength/(float)mapLength;
		if (newTime%256==0) colorInterpolation = (colorInterpolation*3+targetInterpolation*1)/4;
		u32 darkColor = interpolate(targetColor, greyed(targetColor), colorInterpolation);
		u32 liteColor = interpolate(darkColor, 0xffffffff, 1.0f/3.0f); // white is too clear
		u32 bgColor = interpolate(darkColor, 0, 0.5f);

		sf2d_set_clear_color(bgColor);

		sf2d_start_frame(GFX_TOP, GFX_LEFT);
		{
			// draw tiles
			for (uint8_t x=0; x<mapWidth; x++) for (uint8_t y=0; y<mapHeight; y++) {
				sf2d_draw_rectangle(x*recWidth+areaLeft, y*recHeight+areaTop, recWidth, recHeight, interpolate(darkColor, liteColor, ((float)map[y*mapWidth+x])/3));
			}

			// draw cursor
			float t = (float)(keyTime%2048)/2048.0f;
			uint8_t op = pow(fabs(t-0.5f)*2,4)*255;
			sf2d_draw_rectangle(curX*recWidth+areaLeft, curY*recHeight+areaTop, recWidth, recHeight, RGBA8(0,0,0,op));
		}
		sf2d_end_frame();

		sf2d_swapbuffers();
	}

	sf2d_fini();

	return 0;
}
/**
 * @brief Lux_NATIVE_Background
 * @param fillcolor
 */
void Lux_NATIVE_Background(LuxColour fillcolor)
{
	sf2d_set_clear_color( RGBA8(fillcolor.r, fillcolor.g, fillcolor.b, fillcolor.a) );
}
/**
 * @brief Lux_NATIVE_BackgroundObject
 * @param background
 */
void Lux_NATIVE_BackgroundObject( MapObject background )
{
	sf2d_set_clear_color( RGBA8(background.effects.primary_colour.r, background.effects.primary_colour.g, background.effects.primary_colour.b, background.effects.primary_colour.a) );
}
Example #28
0
int aboutMenu()
{
	aboutBg = sf2d_create_texture_mem_RGBA8(about_img.pixel_data, about_img.width, about_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM);
	highlight = sf2d_create_texture_mem_RGBA8(highlight_img.pixel_data, highlight_img.width, highlight_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM);
	
	sf2d_set_clear_color(RGBA8(0, 0, 0, 0));
	
	while (aptMainLoop())
	{
		hidScanInput();

		u32 kDown = hidKeysDown();
		
		sf2d_start_frame(GFX_TOP, GFX_LEFT);
		
		sf2d_draw_texture(aboutBg, 0, 0);
		
		sftd_draw_textf(roboto, 20, 68, RGBA8(0, 0, 0, 255), 12, "%s", lang_settingsAbout[language][0]);
		sftd_draw_textf(roboto, 20, 83, RGBA8(0, 0, 0, 255), 12, "%s", lang_settingsAbout[language][1]);
		sftd_draw_textf(roboto, 20, 116, RGBA8(0, 0, 0, 255), 12, "%s", lang_settingsAbout[language][2]);
		//sftd_draw_textf(roboto, 20, 132, RGBA8(0, 0, 0, 255), 12, "Model = NULL");
		sftd_draw_textf(roboto, 20, 168, RGBA8(0, 0, 0, 255), 12, "%s", lang_settingsAbout[language][5]);
		//sftd_draw_textf(roboto, 20, 183, RGBA8(0, 0, 0, 255), 12, "NinjaHax version: NULL");
		
		if (touch.px  >= 0 && touch.px  <= 480 && touch.py >= 58 && touch.py <= 105)
		{
			sf2d_draw_texture(highlight, 0, 56);
			sftd_draw_textf(roboto, 20, 68, RGBA8(0, 0, 0, 255), 12, "Cyanogen3DS Updates");
			sftd_draw_textf(roboto, 20, 83, RGBA8(0, 0, 0, 255), 12, "Click for, view or isntall available updates");
		}
		else if (touch.px  >= 0 && touch.px  <= 480 && touch.py >= 106 && touch.py <= 157)
		{
			sf2d_draw_texture(highlight, 0, 105);
			sftd_draw_textf(roboto, 20, 116, RGBA8(0, 0, 0, 255), 12, "Cyanogen3DS version: 0.01-20151019-UNOFFICIAL");
			sftd_draw_textf(roboto, 20, 132, RGBA8(0, 0, 0, 255), 12, "Model = NULL");
		}
		 
		digitalTime(350, 2); 
		batteryStatus(316, 2); 
		androidQuickSettings();
		cursorController();
		
		sf2d_end_frame();
		
		navbarControls(1);
		
		if (kDown & KEY_Y)
			powerMenu(); 
		
		if (kDown & KEY_L)
			lockScreen();
		
		if (kDown & KEY_B)
		{
			sf2d_free_texture(aboutBg);
			sf2d_free_texture(highlight);
			settingsMenu();
		}
		
		if ((touch.px  >= 44 && touch.px  <= 119 && touch.py >= 201 && touch.py <= 240) && (kDown & KEY_A))
		{
			sf2d_free_texture(aboutBg);
			sf2d_free_texture(highlight);
			settingsMenu();
		}
		
		else if ((touch.px  >= 120 && touch.px  <= 195 && touch.py >= 201 && touch.py <= 240) && (kDown & KEY_A))
		{
			sf2d_free_texture(aboutBg);
			sf2d_free_texture(highlight);
			home();
		}
		
		sf2d_swapbuffers();
	}
	
	sf2d_free_texture(aboutBg);
	sf2d_free_texture(highlight);

	return 0;
}
Example #29
0
static int color_setBackground(lua_State *L) {
	color_background = luaL_checkinteger(L, 1);
	sf2d_set_clear_color(color_background);

	return 0;
}