コード例 #1
0
ファイル: gfx.c プロジェクト: ObsidianX/3ds_monty
STATIC mp_obj_t mod_citrus_gfx_set_double_buffering(mp_obj_t which, mp_obj_t enabled) {
    int screen = _mod_citrus_gfx_get_gfx_screen(which);

    gfxSetDoubleBuffering(screen, mp_obj_is_true(enabled));

    return mp_const_none;
}
コード例 #2
0
ファイル: splash.c プロジェクト: leo60228/BootCtr
int splash_image(char *splash_path)
{
    // load image in memory, doing proper error checking
    FILE *splash_file = fopen(splash_path, "rb");
    if (!splash_file) {
        printf("\nCouldn't open splash image %s.\n", splash_path);
        goto force_splash_ascii;
    }
    fseek(splash_file, 0, SEEK_END);
    u32 splash_size = ftell(splash_file);
    fseek(splash_file, 0, SEEK_SET);
    u8 *splash_buf = malloc(splash_size);
    if (!splash_buf) {
        printf("\nSplash image %s is too big.\n", splash_path);
        goto force_splash_ascii;
    }
    size_t splash_read = fread(splash_buf, 1, splash_size, splash_file);
    if (splash_read != splash_size) {
        printf("\nError while reading splash image %s.\n", splash_path);
        goto force_splash_ascii;
    }
    // disable double buffering, to avoid flickering
    gfxSetDoubleBuffering(GFX_TOP, false);
    // copy splash image to framebuffer
    memcpy(gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL),
            splash_buf, splash_size);
    return 0;

// force ASCII splash art in case of error
force_splash_ascii:
    splash_ascii();
    return -1;
}
コード例 #3
0
ファイル: gfx.c プロジェクト: ctruLua/ctruLua
/***
Disable the console.
@function disableConsole
*/
static int gfx_disableConsole(lua_State *L) {
	gfxSetScreenFormat(consoleScreen, GSP_BGR8_OES);
	gfxSetDoubleBuffering(consoleScreen, true);
	gfxSwapBuffersGpu();
	gspWaitForVBlank();
	
	return 0;
}
コード例 #4
0
ファイル: main.cpp プロジェクト: Wheth/PHBank
/// A very bad implementation for consoleExit, only for debug.
PrintConsole* consoleExit(gfxScreen_t screen, PrintConsole* console)
{
	// TODO Future implementation!
	*currentConsole = *consoleGetDefault();
	gfxSetScreenFormat(screen, GSP_BGR8_OES);
	gfxSetDoubleBuffering(screen, true);
	gspWaitForVBlank();
	return console;
}
コード例 #5
0
ファイル: sys_ctr.c プロジェクト: masterfeizz/ctrQuake
int main (int argc, char **argv)
{
	float		time, oldtime;

	APT_CheckNew3DS(&isN3DS);
	if(isN3DS)
		osSetSpeedupEnable(true);

	gfxInit(GSP_RGB565_OES,GSP_RGB565_OES,false);
	gfxSetDoubleBuffering(GFX_TOP, false);
	gfxSetDoubleBuffering(GFX_BOTTOM, false);
	gfxSet3D(true);
	consoleInit(GFX_BOTTOM, NULL);

	#ifdef _3DS_CIA
		if(chdir("sdmc:/3ds/ctrQuake") != 0)
			Sys_Error("Could not find folder: sdmc:/3ds/ctrQuake");
	#endif

	static quakeparms_t    parms;

	parms.memsize = 24*1024*1024;
	parms.membase = malloc (parms.memsize);
	parms.basedir = ".";

	COM_InitArgv (argc, argv);

	parms.argc = com_argc;
	parms.argv = com_argv;
	Host_Init (&parms);
	
	Sys_Init();

	oldtime = Sys_FloatTime() -0.1;
	while (aptMainLoop())
	{
		time = Sys_FloatTime();
		separation_distance = osGet3DSliderState();
		Host_Frame (time - oldtime);
		oldtime = time;
	}
	gfxExit();
	return 0;
}
コード例 #6
0
ファイル: main.c プロジェクト: RedInquisitive/3DS-Remote
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;
}
コード例 #7
0
ファイル: 3ds_ui.cpp プロジェクト: FaithFeather/Player
CtrUi::CtrUi(int width, int height) :
	BaseUi() {
	
	frame = 0;
	fullscreen = false;
	trigger_state = false;
	sf2d_init();
	current_display_mode.width = width;
	current_display_mode.height = height;
	current_display_mode.bpp = 32;
	const DynamicFormat format(
		32,
		0x000000FF,
		0x0000FF00,
		0x00FF0000,
		0xFF000000,
		PF::NoAlpha);
	Bitmap::SetFormat(Bitmap::ChooseFormat(format));
	main_surface = Bitmap::Create(width, height, true, 32);
	main_texture = sf2d_create_texture_mem_RGBA8(main_surface->pixels(),
	                                             main_surface->GetWidth(), main_surface->GetHeight(), 
	                                             TEXFMT_RGBA8, SF2D_PLACE_VRAM);
												 
	#ifdef SUPPORT_AUDIO
		audio_.reset(new CtrAudio());
	#endif
	
	#ifdef NO_DEBUG
	// Loading bottom screen keyboard
	u8* key_buffer = (u8*)&keyboard_bmp[0x36];
	u32 key_buffer_size = keyboard_bmp_size - 0x36;
	u8* key_buffer_rgba = (u8*)malloc((key_buffer_size/3)<<2);
	int z = 0;
	for(int i=0;i<key_buffer_size;i=i+3){
		key_buffer_rgba[z+2] = key_buffer[i];
		key_buffer_rgba[z+1] = key_buffer[i+1];
		key_buffer_rgba[z] = key_buffer[i+2];
		key_buffer_rgba[z+3] = 0xFF;
		z = z + 4;
	}
	keyboard_texture = sf2d_create_texture_mem_RGBA8(key_buffer_rgba,
	                                             320, 240, 
	                                             TEXFMT_RGBA8, SF2D_PLACE_RAM);
	free(key_buffer_rgba);
	
	// Disabling debug console
	devoptab_list[STD_OUT] = &dotab_null;
	devoptab_list[STD_ERR] = &dotab_null;
	consoleGetDefault()->frameBuffer = NULL;
	gfxSetScreenFormat(GFX_BOTTOM,GSP_BGR8_OES);
	gfxSetDoubleBuffering(GFX_BOTTOM,true);
	
	// Drawing keyboard once then unloading it
	for (int i=0;i<5;i++){ // If we don't print this a couple of time, image is corrupted
		sf2d_start_frame(GFX_BOTTOM, GFX_LEFT);
		sf2d_draw_texture(keyboard_texture, 0, 0);
		sf2d_end_frame();
		sf2d_swapbuffers();
	}
	sf2d_free_texture(keyboard_texture);
	#endif
	
}
コード例 #8
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;
}
コード例 #9
0
ファイル: main.c プロジェクト: nalistegit/3DSController
int main(void) {
	acInit();
	gfxInitDefault();
	
	gfxSetDoubleBuffering(GFX_TOP, false);
	gfxSetDoubleBuffering(GFX_BOTTOM, false);
	
	if(setjmp(exitJmp)) goto exit;
	
	preRenderKeyboard();
	
	clearScreen();
	drawString(10, 10, "Initing FS...");
	gfxFlushBuffers();
	gfxSwapBuffers();
	
	fsInit();
	
	clearScreen();
	drawString(10, 10, "Initing SOC...");
	gfxFlushBuffers();
	gfxSwapBuffers();
	
	SOC_Initialize((u32 *)memalign(0x1000, 0x100000), 0x100000);
	
	u32 wifiStatus = 0;
	ACU_GetWifiStatus(NULL, &wifiStatus);
	if(!wifiStatus) {
		hang("No WiFi! Is your wireless slider on?");
	}
	
	clearScreen();
	drawString(10, 10, "Reading settings...");
	gfxFlushBuffers();
	gfxSwapBuffers();
	
	if(!readSettings()) {
		hang("Could not read 3DSController.ini!");
	}
	
	clearScreen();
	drawString(10, 10, "Connecting to %s on port %d...", settings.IPString, settings.port);
	gfxFlushBuffers();
	gfxSwapBuffers();
	
	openSocket(settings.port);
	sendConnectionRequest();
	
	clearScreen();
	gfxFlushBuffers();
	gfxSwapBuffers();
	
	disableBacklight();
	
	while(aptMainLoop()) {
		hidScanInput();
		irrstScanInput();
		
		u32 kHeld = hidKeysHeld();
		circlePosition circlePad;
		circlePosition cStick;
		hidCstickRead(&cStick);
		hidCircleRead(&circlePad);
		touchPosition touch;
		touchRead(&touch);
		
		clearScreen();
		
		if((kHeld & KEY_L) && (kHeld & KEY_R) && (kHeld & KEY_X)) {
			if(keyboardToggle) {
				keyboardActive = !keyboardActive;
				keyboardToggle = false;
				
				if(keyboardActive) enableBacklight();
			}
		}
		else keyboardToggle = true;
		
		if(keyboardActive) {
			drawKeyboard();
			
			if(touch.px >= 1 && touch.px <= 312 && touch.py >= 78 && touch.py <= 208) {
				int x = (int)((float)touch.px * 12.0f / 320.0f);
				int y = (int)((float)(touch.py - 78) * 12.0f / 320.0f);
				int width = 24;
				int height = 24;
				
				if(keyboardChars[x + y * 12] == ' ') {
					while(keyboardChars[(x - 1) + y * 12] == ' ') x--;
					
					width = (int)(5.0f * 320.0f / 12.0f) - 1;
				}
				
				else if(keyboardChars[x + y * 12] == '\13') {
					while(keyboardChars[(x - 1) + y * 12] == '\13') x--;
					while(keyboardChars[x + (y - 1) * 12] == '\13') y--;
					
					width = (int)(2.0f * 320.0f / 12.0f) - 1;
					height = (int)(3.0f * 320.0f / 12.0f) - 1;
				}
				
				if(keyboardChars[x + y * 12]) drawBox((int)((float)x * 320.0f / 12.0f) + 1, (int)(78.0f + (float)y * 320.0f / 12.0f) + 1, width, height, 31, 31, 0);
			}
		}
		
		sendKeys(kHeld, circlePad, touch, cStick);
		
		//receiveBuffer(sizeof(struct packet));
		
		if((kHeld & KEY_START) && (kHeld & KEY_SELECT)) longjmp(exitJmp, 1);
		
		gfxFlushBuffers();
		gspWaitForVBlank();
		gfxSwapBuffers();
	}
	
	exit:
	
	enableBacklight();
	
	SOC_Shutdown();
	
	svcCloseHandle(fileHandle);
	fsExit();
	
	gfxExit();
	acExit();
	
	return 0;
}