示例#1
0
static void frontend_ctr_deinit(void *data)
{
   (void)data;
#ifndef IS_SALAMANDER
   global_t *global   = global_get_ptr();
   global->verbosity = true;

#ifdef HAVE_FILE_LOGGER
   if (global->log_file)
      fclose(global->log_file);
   global->log_file = NULL;
#endif

   wait_for_input();

   csndExit();
   gfxExit();

#if 0
   sdmcExit();
   fsExit();
   hidExit();
   aptExit();
   srvExit();
#endif
#endif
}
示例#2
0
void exitServices() {
    if (titlemenuIsUpdating) {
        //Stop the title menu loading process, causing the thread to exit
        cancelTitleLoading();

        //Wait a little bit (two seconds) longer to allow the thread to actually terminate
        svcSleepThread(2000000000ULL);
    }

    if (titleThreadNeedsRelease) {
        releaseTitleThread();
    }

    // cleanup whatever we have to cleanup
	audio_stop();
	csndExit();

    freeThemeImages();
    netloader_exit();
    titlesExit();
    ptmuExit();
    acExit();
    hidExit();
    gfxExit();
    closeSDArchive();
    exitFilesystem();
    aptExit();
    srvExit();
}
示例#3
0
int main(int argc, char **argv)

{
	
	//Initialize some sounds for high quality sounding moans and SCREAMS from the ACTION!
	srvInit();
	aptInit();
	hidInit();
	csndInit();
	gfxInitDefault();
	consoleInit(GFX_TOP, NULL);



	printf("\x1b[1;5HGuess who is the freshest squid around?");
	wait(10000);
	printf("           ");
	printf("\x1b[5;19H\x1b[32m\ Marie Squid\x1b[0m\n");
	printf("\x1b[16;3HPress Start to know that such fresh exists.");
	printf("\x1b[17;3HPress A to get INTO IT!");

	

	// Main loop
	while (aptMainLoop())
	{
		//Scan all the inputs. This should be done once for each frame mostly for the shoots
		hidScanInput();
		

		//hidKeysDown returns information about which buttons have been just pressed (and they weren't in the previous frame)
		hidScanInput();
		u32 kDown = hidKeysDown();
		if (kDown & KEY_START){   //PRESS START TO RETURN TO HBL
		}
		if (kDown & KEY_A){   // PRESS A TO PLAY
			audio_load("squit.bin");
		}
		
		
		// Flush and swap framebuffers
		gfxFlushBuffers();
		gfxSwapBuffers();

		//Wait for VBlank
		gspWaitForVBlank();
	}

	// Exit services... I know you want to come back...

	audio_stop();
	audio_stop();
	csndExit();
	gfxExit();
	hidExit();
	aptExit();
	srvExit();
	return 0;
}
示例#4
0
	void __appExit() {
		// Exit services
		pxiDevExit();
		sdmcExit();
		fsExit();
		hidExit();
		gfxExit();
		aptExit();
		srvExit();
	}
示例#5
0
// this is called after main exits
void __appExit()
{
    srvExit();
    exitPXI();

    svcCloseHandle(terminationRequestedEvent);
    svcCloseHandle(sessionManager.sendAllBuffersToArm9Event);
    svcCloseHandle(sessionManager.replySemaphore);
    svcCloseHandle(sessionManager.PXISRV11CommandReceivedEvent);
    svcCloseHandle(sessionManager.PXISRV11ReplySentEvent);
}
示例#6
0
void system_cleanup() {
    mgr_save();
    mgr_exit();

    CSND_shutdown();

    fsExit();
    gfxExit();
    hidExit();
    aptExit();
    srvExit();
}
示例#7
0
int main()
{
	srvInit();
	aptInit();
	hidInit(NULL);
	irrstInit(NULL);
	gfxInitDefault();

	yeti_init(
		&yeti,
		(framebuffer_t*)gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL),
		(framebuffer_t*)gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL),
		textures, palette, lua
	);

	gfxSet3D(true);

	game_init(&yeti);

	while(aptMainLoop())
	{
		int i;
		for(i=0;i<2;i++)
		{
			yeti.viewport.front = yeti.viewport.back;
			yeti.viewport.back = (framebuffer_t*)gfxGetFramebuffer(GFX_TOP, leftOrRight?GFX_LEFT:GFX_RIGHT, NULL, NULL);

			game_draw(&yeti);

			leftOrRight^=1;
		}

		yetiUpdateKeyboard(&yeti);
		game_tick(&yeti);

		if(hidKeysDown()&KEY_START)break;

		gfxFlushBuffers();
		gfxSwapBuffers();

		gspWaitForEvent(GSPEVENT_VBlank0, true);
	}

	gfxExit();
	irrstExit();
	hidExit();
	aptExit();
	srvExit();
	return 0;
}
示例#8
0
文件: srv.c 项目: Bownairo/ctrulib
Result srvInit(void)
{
	Result rc = 0;

	if (AtomicPostIncrement(&srvRefCount)) return 0;

	rc = svcConnectToPort(&srvHandle, "srv:");
	if (R_FAILED(rc)) goto end;

	rc = srvRegisterClient();
end:
	if (R_FAILED(rc)) srvExit();
	return rc;
}
示例#9
0
void handy_3ds_quit(void)
{
    emulation   = -1;

	handy_3ds_video_quit();
	handy_3ds_audio_quit();

    hidExit();
    aptExit();
    srvExit();

    exit(EXIT_SUCCESS);

}
示例#10
0
文件: main.c 项目: codlab/ftpony
int main()
{
	srvInit();	
	aptInit();
	hidInit(NULL);
	irrstInit(NULL);
	gfxInit();

	gfxSet3D(false);

	srand(svcGetSystemTick());

	curQuote=rand()%numQuotes;
	superStr[0]=0;
	ftp_init();

	int connfd=ftp_getConnection();

	APP_STATUS status;
	while((status=aptGetStatus())!=APP_EXITING)
	{
		if(status == APP_RUNNING)
		{
			ftp_frame(connfd);
			drawFrame();

			hidScanInput();
			if(hidKeysDown()&KEY_B)break;
		}
		else if(status == APP_SUSPENDING)
		{
			aptReturnToMenu();
		}
		else if(status == APP_SLEEPMODE)
		{
			aptWaitStatusEvent();
		}
		gspWaitForEvent(GSPEVENT_VBlank0, false);
	}

	ftp_exit();
	gfxExit();
	irrstExit();
	hidExit();
	aptExit();
	srvExit();
	return 0;
}
示例#11
0
int main()
{
	//Grab the status of the app (running, suspending, sleeping, exiting)
	APP_STATUS status;

	//Initialize 3ds services
	srvInit();
	fsInit();
	aptInit();
	gfxInit();
	hidInit(NULL);
	//Setup event handler to listen for changes in status
	aptSetupEventHandler();


	while ((status = aptGetStatus()) != APP_EXITING)
	{

		if (status == APP_RUNNING)
		{
			//If the app is currently in the forground running, execute the program.
			program();
		}
		else if (status == APP_SUSPENDING)
		{
			//If the app is currently suspended in the background, return to the home menu.
			aptReturnToMenu();
		}
		else if (status == APP_SLEEPMODE)
		{
			//If the app is currently suspended in sleep mode, wait.
			aptWaitStatusEvent();
		}

		//Wait for GPU
		gspWaitForVBlank();

	}

	//Close all opened services.
	hidExit();
	gfxExit();
	aptExit();
	srvExit();
	//Kill the process.
	svcExitProcess();
	return 0;
}
示例#12
0
文件: main.c 项目: ThibG/ctrulib
int main()
{
	Result ret=0;
	httpcContext context;

	// Initialize services
	srvInit();
	aptInit();
	hidInit(NULL);
	gfxInit();
	//gfxSet3D(true); // uncomment if using stereoscopic 3D
	httpcInit();

	ret = httpcOpenContext(&context, "http://10.0.0.3/httpexample_rawimg.bin", 0);//Change this to your own URL.

	if(ret==0)
	{
		ret=http_download(&context);
		httpcCloseContext(&context);
	}

	// Main loop
	while (aptMainLoop())
	{
		gspWaitForVBlank();
		hidScanInput();

		// Your code goes here

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

		// Flush and swap framebuffers
		gfxFlushBuffers();
		gfxSwapBuffers();
	}

	// Exit services
	httpcExit();
	gfxExit();
	hidExit();
	aptExit();
	srvExit();
	return 0;
}
int main()
{
	// Initialize services
	srvInit();
	aptInit();
	hidInit(NULL);
	gfxInitDefault();

	// Main loop
	while (aptMainLoop())
	{
		//As nop90 suggested
		getFB();

		//Gets input (keys and touch)
		getInput();

		//Prints the GUI
		printGUI();  

		//Do stuff
		app();

		//Exit code
		if (input & KEY_START) break;
	
		// Flush and swap framebuffers
		gfxFlushBuffers();
		gfxSwapBuffers();

		//Wait for VBlank
		gspWaitForVBlank();

	}

	// Exit services
	gfxExit();
	hidExit();
	aptExit();
	srvExit();
	return 0;
}
示例#14
0
static void frontend_ctr_deinit(void *data)
{
   extern PrintConsole* currentConsole;
   Handle lcd_handle;
   u8 not_2DS;
   (void)data;
#ifndef IS_SALAMANDER
   global_t *global   = global_get_ptr();
   global->verbosity = true;

#ifdef HAVE_FILE_LOGGER
   if (global->log_file)
      fclose(global->log_file);
   global->log_file = NULL;
#endif

   if(gfxBottomFramebuffers[0] == (u8*)currentConsole->frameBuffer)
      wait_for_input();

   CFGU_GetModelNintendo2DS(&not_2DS);
   if(not_2DS && srvGetServiceHandle(&lcd_handle, "gsp::Lcd") >= 0)
   {
      u32 *cmdbuf = getThreadCommandBuffer();
      cmdbuf[0] = 0x00110040;
      cmdbuf[1] = 2;
      svcSendSyncRequest(lcd_handle);
      svcCloseHandle(lcd_handle);
   }

   exitCfgu();
   csndExit();
   gfxExit();

#if 0
   sdmcExit();
   fsExit();
   hidExit();
   aptExit();
   srvExit();
#endif
#endif
}
示例#15
0
文件: main.c 项目: idgrepthat/rxTools
s32 main (void) {
	// Initialize services
	srvInit();
	aptInit();
	hidInit(NULL);
	gfxInitDefault();
	fsInit();
	sdmcInit();
	hbInit();
	qtmInit();
	
	Handle fileHandle;
	u32 bytesRead;
    FS_archive sdmcArchive=(FS_archive){ARCH_SDMC, (FS_path){PATH_EMPTY, 1, (u8*)""}};
    FS_path filePath=FS_makePath(PATH_CHAR, "/rxTools.dat");
    Result ret=FSUSER_OpenFileDirectly(NULL, &fileHandle, sdmcArchive, filePath, FS_OPEN_READ, FS_ATTRIBUTE_NONE);
	if(ret) goto EXIT;
    FSFILE_Read(fileHandle, &bytesRead, 0x20000, 0x14400000, 320*1024);
    FSFILE_Close(fileHandle);
	
	consoleInit(GFX_BOTTOM, NULL);
	if (brahma_init()) {
		quick_boot_firm(1);
		printf("[!] Quickload failed\n");
		brahma_exit();

	} else {
		printf("* BRAHMA *\n\n[!]Not enough memory\n");
		wait_any_key();
	}
  EXIT:
	hbExit();
	sdmcExit();
	fsExit();
	gfxExit();
	hidExit();
	aptExit();
	srvExit();
	// Return to hbmenu
	return 0;
}
示例#16
0
s32 main(void) {
	// Initialize services
	srvInit();
	aptInit();
	hidInit(NULL);
	gfxInitDefault();
	gfxSet3D(true);
	fsInit();
	sdmcInit();
	hbInit();
	qtmInit();
	gfxSwapBuffers();

	Handle fileHandle;
	u32 bytesRead;
	FS_archive sdmcArchive = (FS_archive){ ARCH_SDMC, (FS_path){ PATH_EMPTY, 1, (u8*)"" } };
	FS_path filePath = FS_makePath(PATH_CHAR, "/" CODE_PATH);
	Result ret = FSUSER_OpenFileDirectly(NULL, &fileHandle, sdmcArchive, filePath, FS_OPEN_READ, FS_ATTRIBUTE_NONE);
	if (ret) goto EXIT;
	FSFILE_Read(fileHandle, &bytesRead, 0x14000, 0x14400000, 320 * 1024);
	FSFILE_Close(fileHandle);


	if (brahma_init())
	{
		quick_boot_firm(1);
		brahma_exit();
	}

EXIT:
	hbExit();
	sdmcExit();
	fsExit();
	gfxExit();
	hidExit();
	aptExit();
	srvExit();
	// Return to hbmenu
	return 0;
}
示例#17
0
int main() {
    // Initialize services
    srvInit();
    aptInit();
    hidInit(NULL);
    gfxInit();
    //gfxSet3D(true); // uncomment if using stereoscopic 3D
    
    char* a = "";

    // Main loop
    while (aptMainLoop() && strcmp(a, "q") != 0)
    {
        gspWaitForVBlank();
        hidScanInput();

        // Your code goes here

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

        a = bbHandleKeyboardBlocking("");
        
        u8* fb = gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL);
        memset(fb, 0, 240*400*3);
        tsDrawWord(GFX_TOP, GFX_LEFT, a, 40, 50, 255, 255, 255);

        // Flush and swap framebuffers
        gfxFlushBuffers();
        gfxSwapBuffers();
    }

    // Exit services
    gfxExit();
    hidExit();
    aptExit();
    srvExit();
    return 0;
}
示例#18
0
void patch_srv(void) {
    APT_CheckNew3DS(&is_n3ds);

    u32 pid1;
    svcGetProcessId(&pid1, 0xFFFF8001);
    // Set the current process id (PID) to 0
    svcBackdoor(&patch_pid);

    u32 pid2;
    svcGetProcessId(&pid2, 0xFFFF8001);
    // Re-initialize srv connection. It will consider this the process with id 0
    // so we will have access to any service
    srvExit();
    srvInit();

    // Once we tricked srv we can restore the real PID
    svcBackdoor(&restore_pid);

    u32 pid3;
    svcGetProcessId(&pid3, 0xFFFF8001);
    printf("%lu=%lu=%lu %lu=0 %s %s\n", pid1, pid_backup, pid3, pid2, patch_result, unpatch_result);
}
示例#19
0
int main()
{
    // Inits
    srvInit();
    aptInit();
    hidInit();
    bool stop = 0;


    csndInit();//start Audio Lib
    u32 kDown;

    while (aptMainLoop()) {

        hidScanInput();
        kDown = hidKeysDown();
        if (kDown & KEY_START) {  //PRESS START TO RETURN TO HBL
            stop=1;
        }
        if (kDown & KEY_A) {  // PRESS A TO PLAY
            audio_load("audio/original_raw.bin");
        }
        if (stop) {
            break;
        }
    }

    audio_stop();
    audio_stop();
    csndExit();

    hidExit();
    aptExit();
    srvExit();

    return 0;
}
示例#20
0
int main(void) {
	irmemloc = (u32*) memalign(0x1000, 0x1000);
	resultStartup = IRU_Initialize(irmemloc, 0x1000);
	resultSetBit = IRU_SetBitRate(0xB);
	recordedIR = (u32*) malloc(REC_SIZE * NUM_OF_BUTTONS); //Currently there are 11(NUM_OF_BUTTONS) recordable buttons. (start switches mode)
	recentIR = (u32*) calloc(REC_SIZE, 0x1); //Whatever was last viewed in memory
	resultGetStatus = irucmd_GetTransferState(&StatusIR);
	srvInit();        // services
	aptInit();        // applets
	hidInit(NULL);    // input
	gfxInitDefault(); // gfx
	
	gfxSetDoubleBuffering(GFX_TOP, true);
	gfxSetDoubleBuffering(GFX_BOTTOM, true);
	bot = gfxGetFramebuffer(GFX_BOTTOM, GFX_LEFT, NULL, NULL);
	top = gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL);
	
	if(setjmp(exitJmp)) goto exit;
	
	clearScreen();
	gfxFlushBuffers();
	gfxSwapBuffers();
	
	bool startToggle = false;
	bool upToggle = false;
	bool downToggle = false;
	
	while(aptMainLoop()) {
		bot = gfxGetFramebuffer(GFX_BOTTOM, GFX_LEFT, NULL, NULL);
		top = gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL);
		hidScanInput();
		irrstScanInput();
		
		u32 kHeld = hidKeysHeld();
		circlePosition circlePad;
		circlePosition cStick;
		hidCstickRead(&cStick);
		hidCircleRead(&circlePad);
		touchPosition touch;
		touchRead(&touch);
		
		clearScreen();
		
		char keys[30] = "ABXY URDL SEST LR ZLZR";
		
		if(kHeld & KEY_A) {
			keys[0] = '*';
			ir('A');
		}
		if(kHeld & KEY_B) {
			keys[1] = '*';
			ir('B');
		}
		if(kHeld & KEY_X) {
			keys[2] = '*';
			ir('X');
		}
		if(kHeld & KEY_Y) {
			keys[3] = '*';
			ir('Y');
		}
		if(kHeld & KEY_DUP) {
			keys[5] = '*';
			if(upToggle) {
				if(bitrate < 18) {
					bitrate++;
					resultSetBit = IRU_SetBitRate(bitrate);
				}
				upToggle = false;
			}
		} else {
			upToggle = true;
		}
		if(kHeld & KEY_DRIGHT) {
			keys[6] = '*';
			ir('R');
		}
		if(kHeld & KEY_DDOWN) {
			keys[7] = '*';
			if(downToggle) {
				if(bitrate > 3) {
					bitrate--;
					resultSetBit = IRU_SetBitRate(bitrate);
				}
				downToggle = false;
			}
		} else {
			downToggle = true;
		}
		if(kHeld & KEY_DLEFT) {
			keys[8] = '*';
			ir('L');
		}
		if(kHeld & KEY_SELECT) {
			keys[10] = '*';
			keys[11] = '*';
			ir('S');
		}
		if(kHeld & KEY_START) {
			keys[12] = '*';
			keys[13] = '*';
			if(startToggle) {
				rec = !rec;
				startToggle = false;
			}
		} else {
			startToggle = true;
		}
		if(kHeld & KEY_L) {
			keys[15] = '*';
			ir('L');
		}
		if(kHeld & KEY_R) {
			keys[16] = '*';
			ir('R');
		}
		if(kHeld & KEY_ZL) {
			keys[18] = '*';
			keys[19] = '*';
			ir('1');
		}
		if(kHeld & KEY_ZR) {
			keys[20] = '*';
			keys[21] = '*';
			ir('2');
		}
		drawString(top, 10, 10, keys);
		drawString(top, 10, 20, "Circle Pad   x: %04+d, y: %04+d", circlePad.dx, circlePad.dy);
		drawString(top, 10, 30, "Touch        x: %04d, y: %04d", touch.px, touch.py );
		if(resultStartup == 0) {
			drawString(top, 10, 40, "IR started!");
		} else {
			drawString(top, 10, 40, "IR Init     |Error: %x", resultStartup);
		}
		if(resultSetBit == 0) {
			drawString(top, 10, 50, "IR bit rate works!");
		} else {
			drawString(top, 10, 50, "IR bit rate |Error: %x", resultSetBit);
		}
		if(resultTransferIR == 0) {
			drawString(top, 10, 60, "IR transfer works!");
		} else {
			drawString(top, 10, 60, "IR transfer |Error: %x", resultTransferIR);
		}
		irucmd_GetTransferState(&StatusIR);
		drawString(top, 10, 70, "IR mode: %x", StatusIR);
		drawString(top, 10, 80, "Got %d bytes", TransIR);
		drawString(top, 10, 90, "Bitrate: %d (see IRU:SetBitRate)", bitrate);
		printMemory(NULL,REC_SIZE,10, false); //might be dangerous?
		
		if(rec) {
			drawString(top, 10, 210, "Recording mode active.");
		}else{
			drawString(top, 10, 210, "Sending mode active.");
		}
		drawString(top, 10, 220, "Start + Select to exit.");
		
		if((kHeld & KEY_START) && (kHeld & KEY_SELECT)) longjmp(exitJmp, 1);
		gfxFlushBuffers();
		gspWaitForVBlank();
		gfxSwapBuffers();
	}
	
	exit: //I should really be fixing these.
	
	free(recordedIR); //Crashes the program. Should free on release.
	free(irmemloc); //Crashes the program. Should free on release.
	free(recentIR); //Crashes the program. Should free on release.
	
	IRU_Shutdown(); //Crashes the program. Should free on release.
	gfxExit();
	hidExit();
	aptExit();
	srvExit();
	
	return 0;
}
示例#21
0
int main()
{
   // Initialize services
   srvInit();
   aptInit();
   hidInit(NULL);
   ptmInit();
   gfxInitDefault();
   // consoleInit(GFX_TOP, NULL);
   csndInit();
   // fsInit();
   // sdmcInit();

   chdir("sdmc:/");

   void *device = gfxCreateDevice(240, 320);
   gfxMakeCurrent(device);

   glMatrixMode(GL_PROJECTION);
   glLoadIdentity();
   glOrtho(0.0, 1.0, 1.0, 0.0, -1.0, 1.0);

   glTranslatef(0.5f, 0.5f, 0.0f);
   glRotatef(90.0f, 0.0f, 0.0f, 1.0f);
   glTranslatef(-0.5f, -0.5f, 0.0f);

   glMatrixMode(GL_MODELVIEW);
   glLoadIdentity();

   glGenTextures(1, &play_button);
   glGenTextures(1, &pause_button);
   glGenTextures(1, &loop_button);
   glGenTextures(1, &loop_disable_button);
   glGenTextures(1, &power_icon);

   glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

   int x, y, n;
   u8* image_data = stbi_load_from_memory(play_3_png, play_3_png_size, &x, &y, &n, 4);
   glBindTexture(GL_TEXTURE_2D, play_button);
   glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, x, y, 0, GL_RGBA, GL_UNSIGNED_BYTE, image_data);
   stbi_image_free(image_data);

   image_data = stbi_load_from_memory(pause_2_png, pause_2_png_size, &x, &y, &n, 4);
   glBindTexture(GL_TEXTURE_2D, pause_button);
   glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, x, y, 0, GL_RGBA, GL_UNSIGNED_BYTE, image_data);
   stbi_image_free(image_data);

   image_data = stbi_load_from_memory(loop_png, loop_png_size, &x, &y, &n, 4);
   glBindTexture(GL_TEXTURE_2D, loop_button);
   glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, x, y, 0, GL_RGBA, GL_UNSIGNED_BYTE, image_data);
   stbi_image_free(image_data);

   image_data = stbi_load_from_memory(loop_disable_png, loop_disable_png_size, &x, &y, &n, 4);
   glBindTexture(GL_TEXTURE_2D, loop_disable_button);
   glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, x, y, 0, GL_RGBA, GL_UNSIGNED_BYTE, image_data);
   stbi_image_free(image_data);

   image_data = stbi_load_from_memory(power_png, power_png_size, &x, &y, &n, 4);
   glBindTexture(GL_TEXTURE_2D, power_icon);
   glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, x, y, 0, GL_RGBA, GL_UNSIGNED_BYTE, image_data);
   stbi_image_free(image_data);

   glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

   void *top_device = gfxCreateDevice(240, 400);
   gfxMakeCurrent(top_device);
   initfont_goth();
   initfont_anita();
   glMatrixMode(GL_PROJECTION);
   glLoadIdentity();
   glOrtho(0.0, 1.0, 1.0, 0.0, -1.0, 1.0);

   glTranslatef(0.5f, 0.5f, 0.0f);
   glRotatef(90.0f, 0.0f, 0.0f, 1.0f);
   glTranslatef(-0.5f, -0.5f, 0.0f);

   glMatrixMode(GL_MODELVIEW);
   glLoadIdentity();
   glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
   glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
   glEnable(GL_BLEND);
   glEnable(GL_TEXTURE_2D);

   int frames = 0;
   int channel = 0x8;


   while (aptMainLoop())
   {
      gspWaitForVBlank();
      hidScanInput();
      gfxMakeCurrent(top_device);
      glClear(GL_COLOR_BUFFER_BIT);
      glLoadIdentity();
      glScalef(1.0/400.0, 1.0/240.0, 1.0);
      state_man();
      gfxFlush(gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL));
      u8 plevel;
      u8 charge;
      PTMU_GetBatteryLevel(NULL, &plevel);
      PTMU_GetBatteryChargeState(NULL, &charge);
      if (plevel != power_level) {
         power_level = plevel;
         // draw_ui = true;
      }
      if (charge != is_charging) {
         is_charging = charge;
         //draw_ui = true;
      }

      gfxMakeCurrent(device);
      u8* fb = gfxGetFramebuffer(GFX_BOTTOM, GFX_LEFT, NULL, NULL);
      render();
      gfxFlush(fb);
      // Your code goes here

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

      // Flush and swap framebuffers
      if (audiobuf && !paused) {
         if(frames >= 50) {
            frames = 0;
            int n = 0;
            if (decode_mode == AUDIO_MODE_VORBIS) {
               n = stb_vorbis_get_samples_short_interleaved(v, 2, audiobuf, Samples * 2);
            } else {
               while (audiobuf_index < Samples * 2) {
                  n = FLAC__stream_decoder_process_single(FLAC_decoder);
                  if (FLAC__stream_decoder_get_state(FLAC_decoder) == FLAC__STREAM_DECODER_END_OF_STREAM) break;
               }
               audiobuf_index = 0;
            }

            if(n == 0) {
               if (decode_mode == AUDIO_MODE_VORBIS) {
                  stb_vorbis_close(v);
               } else {
                  FLAC__stream_decoder_delete(FLAC_decoder);
               }
               linearFree(audiobuf);
               audiobuf = NULL;
               v = NULL;
               FLAC_decoder = NULL;
               if (loop_flag) play_file_from_filename(currently_playing);
            }

            GSPGPU_FlushDataCache(NULL, (u8*)audiobuf, audiobuf_size);
            if (channel == 0x8) channel = 0x6;
            if (channel == 0x6) channel = 0x8;
            csndPlaySound(SOUND_CHANNEL(channel), SOUND_ONE_SHOT | SOUND_LINEAR_INTERP | SOUND_FORMAT_16BIT, Samples * 2, 10.0, 0.0, (u32*)audiobuf, (u32*)audiobuf, audiobuf_size);

         }
         frames++;
      }

      gfxFlushBuffers();
      gfxSwapBuffersGpu();
   }

   // Exit services
   if (FLAC_decoder) {
      FLAC__stream_decoder_delete(FLAC_decoder);
   }
   csndExit();
   gfxExit();
   ptmExit();
   hidExit();
   aptExit();
   srvExit();
   return 0;
}
示例#22
0
void reinitSrv() {
    srvExit();
    srvInit();
}
示例#23
0
文件: main.cpp 项目: Hikiruka/coffei
int main(int argc, char **argv)
{
	srvInit();	
	aptInit();
	gfxInit();
	acInit();
	initCfgu();
	ptmInit();
	hidInit(NULL);
	irrstInit(NULL);
	fsInit();
	hbInit();
	Handle fileHandle;
	u64 size;
	u32 bytesRead;
	int restore;
	
	// Set main script
	char path[256];
	if (argc > 0){	
		int latest_slash = 0;
		int i=5;
		while (argv[0][i]  != '\0'){
		if (argv[0][i] == '/'){
		latest_slash = i;
		}
		i++;
		}
		strcpy(path,&argv[0][5]);
		path[latest_slash-5] = 0;
		strcpy(start_dir,path);
		strcpy(cur_dir,path); // Set current dir
	}else{
		strcpy(start_dir,"/");
		strcpy(cur_dir,"/"); // Set current dir for GW Mode
	}
		
	while(aptMainLoop())
	{
		restore=0;		
		char error[256];
		
		errMsg = runScript((const char*)index_lua, true);
		
		if (errMsg != NULL);
                {
				// Fake error to force interpreter shutdown
				if (strstr(errMsg, "lpp_exit_04")){
					break;
				}
				
				strcpy(error,"Error: ");
				strcat(error,errMsg);
				strcat(error,"\n\nPress A to restart\nPress B to exit");
				}

						while (restore==0){
							gspWaitForVBlank();
							RefreshScreen();
							ClearScreen(0);
							ClearScreen(1);
							DebugOutput(error);
							hidScanInput();
							if(hidKeysDown() & KEY_A){
								strcpy(cur_dir,start_dir);
								restore=1;
							}else if(hidKeysDown() & KEY_B){
								restore=2;
							}
							gfxFlushBuffers();
							gfxSwapBuffers();
						}
						if (restore==2){
							break;
						}
	}
	
	fsExit();
	irrstExit();
	hidExit();
	ptmExit();
	hbExit();
	acExit();
	exitCfgu();
	gfxExit();
	aptExit();
	srvExit();

	return 0;
}
示例#24
0
void __appExit(void) {
    // Exit services
    sdmcExit();
    fsExit();
    srvExit();
}
示例#25
0
文件: main.c 项目: smealum/ctrrpc
/*----------------*/
int main(int argc, char *argv[])
{
    APP_STATUS status;

    srvInit();
    aptInit(APPID_APPLICATION);
    gfxInit();
    hidInit(NULL);
    fsInit();

    svcCreateEvent(&new_cmd_event, 0);
    svcCreateEvent(&cmd_done_event, 0);
    svcCreateThread(&thread, cmd_thread_func, 0x0,
                    (u32*)((char*)thread_stack + sizeof(thread_stack)),
                    0x31, 0xfffffffe);

    int where = 0;
    u32 ret = SOC_Initialize((u32*)0x08000000, 0x48000);

    if(ret == 0) {
        listen_socket = socket(AF_INET, SOCK_STREAM, 0);
        if(listen_socket == -1) {
            where = 1;
            ret = SOC_GetErrno();
        }
        else {
            u32 tmp = fcntl(listen_socket, F_GETFL);
            fcntl(listen_socket, F_SETFL, tmp | O_NONBLOCK);

            struct sockaddr_in addr;
            addr.sin_family = AF_INET;
            addr.sin_port = __swap16(PORT);
            addr.sin_addr.s_addr = INADDR_ANY;

            ret = bind(listen_socket, (struct sockaddr *)&addr, sizeof(addr));
            if(ret != 0) {
                where = 2;
                ret = SOC_GetErrno();
            }
            else {
                ret = listen(listen_socket, 1);
                if(ret == -1) {
                    ret = SOC_GetErrno();
                    where = 3;
                }
            }
        }

    }

    u32 it = 0;
    int accept_errno = 0;
    int first = 1;


    while((status = aptGetStatus()) != APP_EXITING)
    {
        hidScanInput();
        consoleClear(&top);

        print(&top, "newver\n");
        print(&top, "ret: %08x, where: %d\n", ret, where);
        print(&top, "frame: %08x\n", it);
        u32 ip = gethostid();
        print(&top, "ip: %d.%d.%d.%d\n", ip & 0xFF, (ip>>8)&0xFF, (ip>>16)&0xFF, (ip>>24)&0xFF);
                
        if(accept_errno != 0) print(&top, "accept returned errno %d\n", accept_errno);

        if(!first) {
            int s = accept(listen_socket, NULL, NULL);
            if(s == -1) {
                int err = SOC_GetErrno();

                if(err != -EWOULDBLOCK)
                    accept_errno = err;
            }
            else {
                sock = s;
                conn_main();
                closesocket(sock);
            }
        }

        it++;
        first = 0;
        if(enable_draw)
            renderFrame(); 

        u32 keys = hidKeysUp();
        if(keys & KEY_A)
            break;
    }

    thread_exit = 1;
    svcSignalEvent(new_cmd_event);
    svcWaitSynchronization(thread, U64_MAX);
    svcCloseHandle(thread);

    svcCloseHandle(new_cmd_event);
    svcCloseHandle(cmd_done_event);

    SOC_Shutdown();
    fsExit();
    hidExit();
    gfxExit();
    aptExit();
    srvExit();
    return 0;
}
示例#26
0
// Main part of the coding, where everything works (or not)
int main(void) {
    init();

    // Main loop
    while (aptMainLoop()) {

        // Verify button presses
        hidScanInput();

        // Unsigned variables for different types of button presses
        u32 kDown = hidKeysDown();
        u32 kHeld = hidKeysHeld();
        // u32 kUp = hidKeysUp();

        // Exit homebrew
        if (kDown & KEY_START) {
            break;
        }

        // Activate first easter egg
        else if (kDown & KEY_SELECT) {
            easterEgg = !easterEgg;
        }

        // Change pages for the easterEgg/debug menu.
        else if (kDown & KEY_R) {
            if (++easterPage > MAX_PAGE) easterPage = 0;
        }
        else if (kDown & KEY_L) {
            if (--easterPage < 0) easterPage = MAX_PAGE;
        }


        timerStep();

        // If no movement, set the sprite timer to 0
        if (kDown & KEY_UP || kDown & KEY_DOWN || kDown & KEY_LEFT || kDown & KEY_RIGHT) {
            sprTimer = 0;
        }

        // Reset horizontal and vertical speeds
        vsp = 0;
        hsp = 0;

        // Player movement (pretty easy to understand)
        // TODO: Would it be possible to make this less... iffy?
        if (kHeld & KEY_UP) {
            if (!(kHeld & KEY_DOWN)) {
                vsp = -.5; // Vertical speed to negative .5
                playerDir = BACK; // Player direction = back
            }
        }

        if (kHeld & KEY_DOWN) {
            vsp = .5; // Vertical speed to .5
            playerDir = FORWARD; // Player direction = up
        }

        if (kHeld & KEY_LEFT) {
            if (!(kHeld & KEY_RIGHT)) {
                hsp = -.5; // Vertical speed to negative .5
                playerDir = LEFT; // Player direction = left
            }
        }

        if (kHeld & KEY_RIGHT) {
            hsp = .5; // Vertical speed to .5
            playerDir = RIGHT; // Player direction = right
        }

        // Diagonal movement speed fix
        if (vsp != 0) {
            if (hsp != 0) {
                vsp *= .8;
                hsp *= .8;
            }
        }

        // Movement calculation... AND proper room colision.
        // TODO: Consider a function for translating and/or clamping coordinates directly?
        player_pos.x = fclamp(player_pos.x + hsp * dt,
                              rooms[room].collision[0].x,
                              rooms[room].collision[1].x);

        player_pos.y = fclamp(player_pos.y + vsp * dt,
                              rooms[room].collision[0].y,
                              rooms[room].collision[1].y);

        // Scrolling calculation.
        // TODO: Make these constants better/customizable.
        if (player_pos.x - camera_pos.x >= 300) {
            camera_pos.x = player_pos.x - 300;
        }
        else if (player_pos.x - camera_pos.x <= 100) {
            camera_pos.x = player_pos.x - 100;
        }
        camera_pos.x = fclamp(camera_pos.x, 0, rooms[room].scroll_max.x);

        if (player_pos.y - camera_pos.y >= 200) {
            camera_pos.y = player_pos.y - 200;
        }
        else if (player_pos.y - camera_pos.y <= 50) {
            camera_pos.y = player_pos.y - 50;
        }
        camera_pos.y = fclamp(camera_pos.y, 0, rooms[room].scroll_max.y);

        // Player sprites
        if (hsp == 0 && vsp == 0) curr_tex = tex_arr_friskWalk[playerDir][0];

        else curr_tex = tex_arr_friskWalk[playerDir][(int)floor(sprTimer)];

        // Sprite animation timer
        // TODO: Why .15 * .03 * actual time?
        sprTimer += (.03 * dt);

        while (sprTimer >= 4) {
            sprTimer -= 4;
        }

        if (!next_exit){
            if (roomTimer < 255) {
                roomTimer = fmin(roomTimer + (4 * dt), 255);
            }
            next_exit = exit_room(room, &player_pos);
        }
        else {
            roomTimer -= 4 * dt;
            if (roomTimer <= 0) {
                room = next_exit->room_id;
                player_pos = next_exit->entrance;
                next_exit = NULL;
                roomTimer = 0;
            }
        }

        render();

        // Swap sf2d framebuffers and wait for VBlank
        sf2d_swapbuffers();
    }

    // Free images/textures/fonts from memory

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

    for (int i = 0; i < 3; ++i) {
        sf2d_free_texture(rooms[i].bg.tex);
    }

    sftd_free_font(font);

    // Exit services
    sf2d_fini();
    sftd_fini();
    sound_stop(home);
    audio_stop();
    hidExit();
    aptExit();
    srvExit();

    return 0;
}
示例#27
0
int main() {
    srvInit();
    aptInit();
    hidInit(NULL);
    gfxInitDefault();
    resetGame();
    int x;
    while (aptMainLoop()) {
        hidScanInput();
        hidTouchRead(&touch);
        u32 kDown = hidKeysDown();
        //u32 kHeld = hidKeysHeld(); Not used an otherwise you'll get warning during compile, this makes compile more pleasant to look at yea!
        if (state != 0 && cur_row != 7) {
            if (secretCode() && state != 3)
                cheat=1;
            if (kDown & KEY_TOUCH) {
                cur_visable=false;
            }

            if (kDown & KEY_RIGHT) {
                cur_field+=1;
                if (cur_field > 3)
                    cur_field=0;
                cur_visable=true;
            }
            if (kDown & KEY_LEFT) {
                cur_field-=1;
                if (cur_field < 0)
                    cur_field=3;
                cur_visable=true;
            }
            if (kDown & KEY_UP) {
                local_field[cur_field]+=1;
                if (local_field[cur_field] > col_amount)
                    local_field[cur_field]=1;
                cur_visable=true;
            }
            if (kDown & KEY_DOWN) {
                local_field[cur_field]-=1;
                if (local_field[cur_field] < 1)
                    local_field[cur_field]=col_amount;
                cur_visable=true;
            }
            if (kDown & KEY_A)
                submitTry();
            if (touchInBox(touch,231,163,84,44))
                submitTry();

            if (touchInBox(touch,7,28,71,16)) {
                local_field[0]+=1;
                if (local_field[0] > col_amount)
                    local_field[0]=1;
            }
            if (touchInBox(touch,85,28,71,16)) {
                local_field[1]+=1;
                if (local_field[1] > col_amount)
                    local_field[1]=1;
            }
            if (touchInBox(touch,163,28,71,16)) {
                local_field[2]+=1;
                if (local_field[2] > col_amount)
                    local_field[2]=1;
            }
            if (touchInBox(touch,241,28,71,16)) {
                local_field[3]+=1;
                if (local_field[3] > col_amount)
                    local_field[3]=1;
            }
            if (touchInBox(touch,7,119,71,16)) {
                local_field[0]-=1;
                if (local_field[0] <= 0)
                    local_field[0]=col_amount;
            }
            if (touchInBox(touch,85,119,71,16)) {
                local_field[1]-=1;
                if (local_field[1] <= 0)
                    local_field[1]=col_amount;
            }
            if (touchInBox(touch,163,119,71,16)) {
                local_field[2]-=1;
                if (local_field[2] <= 0)
                    local_field[2]=col_amount;
            }
            if (touchInBox(touch,241,119,71,16)) {
                local_field[3]-=1;
                if (local_field[3] <= 0)
                    local_field[3]=col_amount;
            }
            if (state != 2) {
                for (x=0; x < 4; x++) {
                    full_field[cur_row*4+x]=local_field[x];
                }
            }
        } else if (state == 0) {
            if (touchInBox(touch,65,66,98,34))
                modeselector=1;
            if (touchInBox(touch,65,102,98,34))
                modeselector=2;
            if (modeselector != 0) {
                if (touchInBox(touch,168,65,88,22)) {
                    difficulty=0;
                    startGame(modeselector);
                }
                if (touchInBox(touch,168,90,88,22)) {
                    difficulty=1;
                    startGame(modeselector);
                }
                if (touchInBox(touch,168,125,88,22)) {
                    difficulty=2;
                    startGame(modeselector);
                }
            }
        }

        if (touchInBox(touch,0,211,320,30)) {
            resetGame();
            state=0;
            modeselector=0;
        }
        if (touchInBox(touch,0,0,74,21))
            break;

        render(full_field, full_judgement, local_field, cur_field, cur_row, cur_visable, ans, win, cheat, state, modeselector);
        gfxFlushBuffers();
        gfxSwapBuffers();
        gspWaitForEvent(GSPEVENT_VBlank0, false);
    }
    gfxExit();
    hidExit();
    aptExit();
    srvExit();
    return 0;
}
示例#28
0
文件: main.c 项目: landm2000/sokoban
int main()
{
    char level_data_line[20*16];
    LEVELDATA this_level_data = {
        {&level_data_line[0],   &level_data_line[20], &level_data_line[40], &level_data_line[60],
         &level_data_line[80], &level_data_line[100],&level_data_line[120],&level_data_line[140],
         &level_data_line[160],&level_data_line[180],&level_data_line[200],&level_data_line[220],
         &level_data_line[240],&level_data_line[260],&level_data_line[280],&level_data_line[300]},
        19,11
    };
    // Initializations
    srvInit();  // services
    aptInit();  // applets
    hidInit();  // input
	gfxInitDefault();
//	gfxSet3D(true); // uncomment if using stereoscopic 3D
    gfxSetDoubleBuffering(GFX_TOP, true);
    gfxSetDoubleBuffering(GFX_BOTTOM, false);

    PrintConsole /*topScreen, */bottomScreen;
    consoleInit(GFX_BOTTOM, &bottomScreen);
//    consoleInit(GFX_TOP, &topScreen);
    clear_char_stack();
    int level = 0;
    int mode = MODE_INIT;
//    int mode_status  = 0;
    hcount = 0;

int timer = 0;
    // Main loop
    while (aptMainLoop())
    {
        hidScanInput();
        u32 kDown = hidKeysDown();
        u32 kUp   = hidKeysUp();
        u32 kHeld = hidKeysHeld();
        if (kDown & KEY_START){
            break; // break in order to return to hbmenu
        }

        if (mode == MODE_INIT){
//            consoleSelect(&topScreen);
//            printf("\033[2J");
            copyGame(level,&this_level_data);
            gspWaitForVBlank();
            printGame(&this_level_data);
            mode = MODE_GAME;
        }else if (mode == MODE_CLEAR){
            if ((kUp & KEY_A) || (kUp & KEY_B) || (kUp & KEY_X) || (kUp & KEY_Y)){
                level++;
                if (level >= sizeof(level_data)/sizeof(LEVELDATA)) {
                    mode = MODE_ALL_CLEAR;
                }else{
                    mode = MODE_INIT;
                }
            }
            if (level < sizeof(level_data)/sizeof(LEVELDATA)) {
                consoleSelect(&bottomScreen);
                printf("\033[2J");
                printf("\x1b[21;12HStage cleared!!");
                printf("\x1b[23;12HPush A to next Next Stage");
            }
        }else if (mode == MODE_ALL_CLEAR){
            level = 0;
            consoleSelect(&bottomScreen);
            printf("\033[2J");
            printf("\x1b[21;12HGame cleared!!!");
            printf("\x1b[23;12HPush Start to exit game");
            mode = MODE_NULL;
        }else if (mode == MODE_GAME){

        // Your code goes here


#ifdef DEBUG
consoleSelect(&bottomScreen);
if (timer%10==0){
//if (1    != 0){printf("\x1b[10;12HkUp  =%08x",(unsigned int)kUp);}
//if (1    != 0){printf("\x1b[11;12HkDown=%08x",(unsigned int)kDown);}
//if (1    != 0){printf("\x1b[12;12HkHeld=%08x",(unsigned int)kHeld);}
//printf("\x1b[22;12HKEY_CPAD_UP=%x",KEY_UP);
//printf("\x1b[23;12HKEY_CPAD_DN=%x",KEY_DOWN);
printf("\x1b[20;12HRest: [SELECT]");
printf("\x1b[22;12HExit: [START]");
printf("\x1b[24;12HTime: %08d",timer);
}
timer++;
#endif
            if (kDown != 0 || kHeld != 0){
                if (kDown & KEY_SELECT){
                    mode = MODE_INIT;
                }else{
                    moveMan(kDown, kHeld,level,&this_level_data);
                    if(checkCleared(&this_level_data,level)==0){ mode = MODE_CLEAR;}
                    gspWaitForVBlank();
                    draw_char_stack(this_level_data,spriteData, sizeof(spriteData)/sizeof(SPRITEDATA));
                }
            }else{
                gspWaitForVBlank();
            }
        }

        // Flush and swap framebuffers
        gfxFlushBuffers();
        gfxSwapBuffers();
    }

    gfxExit();
    hidExit();
    aptExit();
    srvExit();
	return 0;
}
示例#29
0
int main() {
    // Initialize services
    srvInit();
    aptInit();
    hidInit(NULL);
    gfxInit();
    CSND_initialize(NULL);
    srand(osGetTime());
    //gfxSet3D(true); // uncomment if using stereoscopic 3D
    
    u8 *audiobuf = linearAlloc(sadloop_bin_size);
    int i;
    for (i=0;i<sadloop_bin_size;i++) {
        memcpy(&audiobuf[i], &sadloop_bin[i], 1);    
    }
    
    bool flip = false;
    u64 nextflip = osGetTime()+500;
    u8 *crow = linearAlloc(crow1_bin_size);
    for (i=0;i<crow1_bin_size;i++) {
        memcpy(&crow[i], &crow1_bin[i], 1);    
    }
    
    CSND_setchannel_playbackstate(0x8, 0);
    CSND_sharedmemtype0_cmdupdatestate(0);
    
    u64 nextsong = osGetTime()+68000;
    CSND_playsound(0x8, CSND_LOOP_ENABLE, CSND_ENCODING_PCM16, 22050, (u32*)audiobuf, NULL, sadloop_bin_size, 2, 0);

    char* fact;
    u64 nextfact = osGetTime()+newFact(&fact);
    
    // Main loop
    while (aptMainLoop())
    {
        gspWaitForVBlank();
        hidScanInput();
        u64 now = osGetTime();
        
        
        if (now >= nextsong) {
            nextsong = now+68000;
            
            CSND_playsound(0x8, CSND_LOOP_ENABLE, CSND_ENCODING_PCM16, 22050, (u32*)audiobuf, NULL, sadloop_bin_size, 2, 0);
        }
        if (now >= nextflip) {
            nextflip = now+500;
            if (flip) {
                for (i=0;i<crow1_bin_size;i++) {
                    memcpy(&crow[i], &crow1_bin[i], 1);    
                }
                flip = false;
            } else {
                for (i=0;i<crow1_bin_size;i++) {
                    memcpy(&crow[i], &crow2_bin[i], 1);    
                }
                flip = true;
            }
        }
        if (now >= nextfact) {
            nextfact = now+newFact(&fact);
        }
        
        
        u32 kDown = hidKeysDown();
        if (kDown & KEY_START)
            break; // break in order to return to hbmenu
        
        // Please note that the 3DS screens are sideways (thus 240x400 and 240x320)
        u8* fb = gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL);
        memset(fb, 0, 240*400*3);
        
        tsDrawWord(GFX_TOP, GFX_LEFT, "Fact Crow says:", 30, 180, 255, 255, 255);
        drawFact(fact);
        gfxDrawSprite(GFX_TOP, GFX_LEFT, crow, 37, 37, 138, 30);

        // Flush and swap framebuffers
        gfxFlushBuffers();
        gfxSwapBuffers();
    }

    CSND_shutdown();
    linearFree(audiobuf);
    
    // Exit services
    gfxExit();
    hidExit();
    aptExit();
    srvExit();
    return 0;
}
示例#30
0
文件: main.cpp 项目: linoma/fb43ds
//---------------------------------------------------------------------------
int main(int argc, char** argv)
{
	touchPosition lastTouch;
	int frame=0,lp_frame=0;
	
	CWebRequest::InitializeClient();	
	gfxInitDefault();
	GPU_Init(NULL);
	gfxSet3D(false);
	srand(svcGetSystemTick());
	CFBClient::Initialize();
	while(aptMainLoop()){
		hidScanInput();		
		u32 press = hidKeysDown();
		u32 held = hidKeysHeld();
		u32 release = hidKeysUp();
		if((press & ~KEY_TOUCH)){
			CFBClient::onKeysPressEvent(press,1);
			hidCircleRead(&lcp);
		}
		if((release & ~KEY_TOUCH)){
			CFBClient::onKeysUpEvent(press,1);
			hidCircleRead(&lcp);
		}
		if (held & KEY_TOUCH){
			hidTouchRead(&lt);
			if(!lp_frame){
				lastTouch=lt;
				lp_frame++;
			}
			else{
				int i=0;
				
				if(abs(lt.px-lastTouch.px) <= 5){
					if(abs(lt.py-lastTouch.py) <= 5)
						i = 1;
				}
				if(i)
					lp_frame++;
				else{
					lp_frame = 0;
					CFBClient::onTouchEvent(&lt,2);
				}
			}
			if(!frame)
				CFBClient::onTouchEvent(&lt,1);
			frame++;
		}
		else{
			if(frame)
				CFBClient::onTouchEvent(&lt,lp_frame > 120 ? 8 : 4);
			frame = 0;
			lp_frame = 0;
		}
		CFBClient::main(0);
		gfxFlushBuffers();
		gfxSwapBuffers();
		gspWaitForVBlank();
	}
	CFBClient::Destroy();
	CWebRequest::DestroyClient();
	fsExit();
	hidExit();
	gfxExit();
	aptExit();
	srvExit();
	return 0;
}