Esempio n. 1
0
void gfxDrawDualSprite(u8* spriteData, u16 width, u16 height, s16 x, s16 y)
{
	if(!spriteData)return;

	gfxDrawSprite(GFX_TOP, GFX_LEFT, spriteData, width, height, x-240, y);
	gfxDrawSprite(GFX_BOTTOM, GFX_LEFT, spriteData, width, height, x, y-40);
}
Esempio n. 2
0
void GUI_FileExplorer(){
	if (count != 0)
	{
		int n = 0;
		int divisions = count % 10 == 0 ? count / 10 : count / 10 + 1;
		int list[divisions];
		for (n = 0; n < divisions; n++)
		{
			if (n == divisions - 1 && count % 10 != 0)list[n] = count - (count / 10) * 10;
			else list[n] = 10;
		}

		int i = 0;

		itemShown = list[(pointer / 10)];
		
		for (i = beginning; i < beginning + list[(pointer / 10)]; i++) {
			char filename[100];
			strcpy(filename, files[i]);
			if (strlen(filename)>39)
			{
				filename[39] = '\0';
				strcat(filename, "...");
			}
			sprintf(buffer, "%s%s", i == pointer ? "> " : "", filename);
			if (pointer == i) drawFillRect(35, fontBlack.height * (i - beginning + 1), 275, fontBlack.height * (i - beginning + 1) + 15, 226, 226, 226, screenBottom);
			gfxDrawText(GFX_BOTTOM, GFX_LEFT, &fontBlack, filename, 40, 238 - fontBlack.height * (i - beginning + 1) - 15);
		}

		//Draw the next/prev page button if there's one
		if (beginning != 0) gfxDrawSprite(GFX_BOTTOM, GFX_LEFT, (u8*)PrevFM_bin, 71, 23, 9, 109);       // <--
		if (count > beginning + 10) gfxDrawSprite(GFX_BOTTOM, GFX_LEFT, (u8*)NextFM_bin, 72, 22, 289, 109); // -->	
	}
}
Esempio n. 3
0
/*! draw console to screen */
void
console_render(void)
{
  /* clear all screens */
  if (background != NULL){
    gfxDrawSprite(GFX_BOTTOM, GFX_LEFT, background, 240, 320, 0, 0);
  }else{
    gfxDrawSprite(GFX_BOTTOM, GFX_LEFT, (u8*)banner_bin, 240, 320, 0, 0);
  }

  /* flush framebuffer */
  gfxFlushBuffers();
  gspWaitForVBlank();
  gfxSwapBuffers();
}
Esempio n. 4
0
void drawThemeImageCheckAlpha(u8 * image, gfxScreen_t screen, int x, int y, int w, int h, bool hasAlpha) {
    if (hasAlpha) {
        gfxDrawSpriteAlphaBlend(screen, GFX_LEFT, image, w, h, x, y);
    }
    else {
        gfxDrawSprite(screen, GFX_LEFT, image, w, h, x, y);
    }
}
Esempio n. 5
0
int drawMenuEntry(menuEntry_s* me, gfxScreen_t screen, u16 x, u16 y, bool selected)
{
	if(!me)return 0;
	int i;

	//TODO : proper template sort of thing ?
	//this is all hardcoded and horrible

	const int totalWidth=selected?ENTRY_WIDTH_SELECTED:ENTRY_WIDTH;
	const int actualWidth=(selected?ENTRY_FWIDTH_SELECTED:ENTRY_FWIDTH);
	const int widthOffset=actualWidth-ENTRY_FWIDTH;
	const int actualHeight=selected?ENTRY_HEIGHT_SELECTED:ENTRY_HEIGHT;
	if(selected)y-=ENTRY_HEIGHT_SELECTED-ENTRY_HEIGHT;
	x-=ENTRY_WIDTH+widthOffset;

	//drop shadow
	if(selected)
	{
		const int sw=4;
		const int sx=x-sw;
		for(i=0; i<9; i++)gfxDrawRectangle(screen, GFX_LEFT, ENTRY_BGCOLOR_SHADOW, sx+roundLut[i], y+i, sw, 1);
		gfxDrawRectangle(screen, GFX_LEFT, ENTRY_BGCOLOR_SHADOW, sx, y+9, sw, actualHeight-9*2);
		for(i=0; i<9; i++)gfxDrawRectangle(screen, GFX_LEFT, ENTRY_BGCOLOR_SHADOW, sx+roundLut[i], y+actualHeight-1-i, sw, 1);
	}

	//main frame
	for(i=0; i<9; i++)gfxDrawRectangle(screen, GFX_LEFT, ENTRY_BGCOLOR, x-widthOffset+roundLut[i], y+i, actualWidth-roundLut[i]*2, 1);
	gfxDrawRectangle(screen, GFX_LEFT, ENTRY_BGCOLOR, x-widthOffset, y+9, actualWidth, actualHeight-9*2);
	for(i=0; i<9; i++)gfxDrawRectangle(screen, GFX_LEFT, ENTRY_BGCOLOR, x-widthOffset+roundLut[i], y+actualHeight-1-i, actualWidth-roundLut[i]*2, 1);

	//icon frame
	u8 colorIcon[]={225, 225, 225};
	for(i=0; i<5; i++)gfxDrawRectangle(screen, GFX_LEFT, colorIcon, x+3+roundLut2[i], y+4+i, 56-roundLut2[i]*2, 1);
	gfxDrawRectangle(screen, GFX_LEFT, colorIcon, x+3, y+9, 56, 46);
	for(i=0; i<5; i++)gfxDrawRectangle(screen, GFX_LEFT, colorIcon, x+3+roundLut2[i], y+4+56-1-i, 56-roundLut2[i]*2, 1);

	//app specific stuff
	gfxDrawSprite(screen, GFX_LEFT, me->iconData, ENTRY_ICON_WIDTH, ENTRY_ICON_HEIGHT, x+7, y+8);
	gfxDrawTextN(screen, GFX_LEFT, &fontTitle, me->name, ENTRY_NAMELENGTH, x+38, y+66);
	gfxDrawTextN(screen, GFX_LEFT, &fontDescription, me->description, 56, x+26, y+70);
	if(strlen(me->description) > 56 * 1)
	{
		gfxDrawTextN(screen, GFX_LEFT, &fontDescription, me->description + 56, 56, x+18, y+70);
	}
	else if(strlen(me->description) > 56 * 2)
	{
		gfxDrawTextN(screen, GFX_LEFT, &fontDescription, me->description + 56 * 1, 56, x+18, y+70);
		gfxDrawTextN(screen, GFX_LEFT, &fontDescription, me->description + 56 * 2, 56, x+10, y+70);
	}
	gfxDrawTextN(screen, GFX_LEFT, &fontDescription, me->author, ENTRY_AUTHORLENGTH, x+4, y+ENTRY_HEIGHT-getStringLength(&fontDescription, me->author)-10);

	return totalWidth;
}
Esempio n. 6
0
void GUI_OptionsUi(bool greyScale)
{
	gfxDrawSprite(GFX_BOTTOM, GFX_LEFT, (u8*)Options_bin, 171, 291, 14, 46);

	if (greyScale) //Color selection
	{
		drawFillRect(54, 176, 144, 184, 192, 192, 192, screenBottom);
	}
	else
	{
		drawFillRect(172, 176, 263, 184, 192, 192, 192, screenBottom);
	}
}
Esempio n. 7
0
void GUI_StatusBar(char* title)
{
	ACU_GetWifiStatus(NULL, &wifiStatus);
	PTMU_GetBatteryLevel(NULL, &batteryLevel);
	PTMU_GetBatteryChargeState(NULL, &charging);

	//Wifi icon
	if (wifiStatus) gfxDrawSprite(GFX_TOP, GFX_LEFT, (u8*)Wifi_bin, 20, 40, 0, 220);

	//Battery icon
	if (charging)
	{
		gfxDrawSprite(GFX_TOP, GFX_LEFT, batteryLevels[charging_animation/9], 19, 17, 0, 221);
		if(charging_animation!=49)charging_animation++;
		else charging_animation = 1;
	}
	else gfxDrawSprite(GFX_TOP, GFX_LEFT, batteryLevels[batteryLevel], 19, 17, 0, 221);

	//Clock
    GUI_Clock();

	//Title
    gfxDrawText(GFX_TOP, GFX_LEFT, &fontBlack, title, 80, 238 - fontBlack.height * 1);
}
Esempio n. 8
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;
}
Esempio n. 9
0
//void gfxDrawSpriteAlphaBlend(gfxScreen_t screen, gfx3dSide_t side, u8* spriteData, u16 width, u16 height, s16 x, s16 y);
void render(int full_field[], int full_judgement[], int local_field[], int cur_field, int cur_row, bool cur_visable, int ans[], int win, int cheat, int state, int modeselector){
	//render bgs
	gfxDrawSprite(GFX_TOP,GFX_LEFT, (u8*)top_bin, 240, 400, 0, 0);
	gfxDrawSprite(GFX_BOTTOM,GFX_LEFT, (u8*)bottom_bin, 240, 320, 0, 0);

	//top
	int x;
	int y;
	int z;
	for (x=0; x<7; x++){
		for (y=0; y<4; y++){
			if (full_field[x*4+y]>0)
				gfxDrawSpriteAlphaBlend(GFX_TOP,GFX_LEFT, (u8*)top_colors_bin+(full_field[x*4+y]-1)*1600, 20, 20, 11+x*33, 145+y*30);
		}
	}
	for (x=0; x<7; x++){
		for (y=0; y<2; y++){
			for(z=0;z<2; z++){
				if (full_judgement[y*2+z+x*4] == 1)
					gfxDrawSpriteAlphaBlend(GFX_TOP,GFX_LEFT, (u8*)top_pins_bin+196, 7, 7, 22-8*y+33*x, 262+8*z);
				if (full_judgement[y*2+z+x*4] == 2)
					gfxDrawSpriteAlphaBlend(GFX_TOP,GFX_LEFT, (u8*)top_pins_bin, 7, 7, 22-8*y+33*x, 262+8*z);
			}
		}
	}
	for (x=0; x<7; x++){
		if (cur_row == x){
			gfxDrawSpriteAlphaBlend(GFX_TOP,GFX_LEFT, (u8*)black_numbers_bin+336*x, 12, 7, 15+33*x, 128);
			gfxDrawSpriteAlphaBlend(GFX_TOP,GFX_LEFT, (u8*)top_arrow_bin, 10, 7, 15+33*x, 115);
		}else{
			gfxDrawSpriteAlphaBlend(GFX_TOP,GFX_LEFT, (u8*)grey_numbers_bin+336*x, 12, 7, 15+33*x, 128);
		}
	}
	if (cur_row == 7){
		gfxDrawSpriteAlphaBlend(GFX_TOP,GFX_LEFT, (u8*)top_gameover_bin, 80, 200, 100, 100);
		for (x=0; x<4; x++){
			gfxDrawSpriteAlphaBlend(GFX_TOP,GFX_LEFT, (u8*)top_colors_bin+(ans[x]-1)*1600, 20, 20, 108, 123+45*x);
		}
	}
	if (win == 1){
		gfxDrawSpriteAlphaBlend(GFX_TOP,GFX_LEFT, (u8*)top_win_bin, 60, 200, 90, 100);
	}
	if (cheat){
		for (y=0; y<4; y++){
			gfxDrawSpriteAlphaBlend(GFX_TOP,GFX_LEFT, (u8*)top_colors_bin+(ans[y]-1)*1600, 20, 20, 0, y*27);
		}
	}
	//bottom
	if (local_field[0] != 0)
		gfxDrawSpriteAlphaBlend(GFX_BOTTOM,GFX_LEFT, (u8*)bottom_colors_bin+11664*(local_field[0]-1), 54, 54, 132, 16);
	if (local_field[1] != 0)
		gfxDrawSpriteAlphaBlend(GFX_BOTTOM,GFX_LEFT, (u8*)bottom_colors_bin+11664*(local_field[1]-1), 54, 54, 132, 94);
	if (local_field[2] != 0)
		gfxDrawSpriteAlphaBlend(GFX_BOTTOM,GFX_LEFT, (u8*)bottom_colors_bin+11664*(local_field[2]-1), 54, 54, 132, 172);
	if (local_field[3] != 0)
		gfxDrawSpriteAlphaBlend(GFX_BOTTOM,GFX_LEFT, (u8*)bottom_colors_bin+11664*(local_field[3]-1), 54, 54, 132, 250);

	if (cur_visable && cur_row != 7)
		gfxDrawSpriteAlphaBlend(GFX_BOTTOM,GFX_LEFT, (u8*)bottom_circle_bin, 72, 72, 123, 7+78*cur_field);

	if (state == 0){
		gfxDrawSpriteAlphaBlend(GFX_BOTTOM,GFX_LEFT, (u8*)bottom_modeselect_bin, 80, 200, 100, 60);
		if (modeselector == 0){
			gfxDrawSpriteAlphaBlend(GFX_BOTTOM,GFX_LEFT, (u8*)bottom_modeselectbuttons_bin, 34, 98, 141, 64);
			gfxDrawSpriteAlphaBlend(GFX_BOTTOM,GFX_LEFT, (u8*)bottom_modeselectbuttons_bin+26656, 34, 98, 105, 64);
		}else if (modeselector == 1){
			gfxDrawSpriteAlphaBlend(GFX_BOTTOM,GFX_LEFT, (u8*)bottom_modeselectbuttons_bin+13328, 34, 98, 141, 64);
			gfxDrawSpriteAlphaBlend(GFX_BOTTOM,GFX_LEFT, (u8*)bottom_modeselectbuttons_bin+26656, 34, 98, 105, 64);
			gfxDrawSpriteAlphaBlend(GFX_BOTTOM,GFX_LEFT, (u8*)bottom_difselect_bin, 72, 88, 104, 167);
		}else{
			gfxDrawSpriteAlphaBlend(GFX_BOTTOM,GFX_LEFT, (u8*)bottom_modeselectbuttons_bin, 34, 98, 141, 64);
			gfxDrawSpriteAlphaBlend(GFX_BOTTOM,GFX_LEFT, (u8*)bottom_modeselectbuttons_bin+39984, 34, 98, 105, 64);
			gfxDrawSpriteAlphaBlend(GFX_BOTTOM,GFX_LEFT, (u8*)bottom_difselect_bin, 72, 88, 104, 167);
		}
	}else if (state == 2){
		gfxDrawSpriteAlphaBlend(GFX_TOP,GFX_LEFT, (u8*)top_instruction_bin, 60, 200, 90, 100);
		gfxDrawSpriteAlphaBlend(GFX_BOTTOM,GFX_LEFT, (u8*)bottom_currentplayer_bin, 19, 111, 221, 209);
	}else if (state == 3){
		gfxDrawSpriteAlphaBlend(GFX_BOTTOM,GFX_LEFT, (u8*)bottom_currentplayer_bin+8436, 19, 111, 221, 209);
	}
}
Esempio n. 10
0
void GUI_TextView(char* path, int page, bool greyScale)
{
	//Draw BKG
	gfxDrawSprite(GFX_TOP, GFX_LEFT, (u8*)TextBKG_bin, 240, 400, 0, 0); 
	if (greyScale)
	{
		drawFillRect(40, 20, 359, 239, 255, 255, 255, screenTopLeft);
		drawFillRect(0, 0, 319, 239, 255, 255, 255, screenBottom);
	}
	else
	{
		drawFillRect(40, 20, 359, 239, 243, 231, 189, screenTopLeft);
		drawFillRect(0, 0, 319, 239, 243, 231, 189, screenBottom);
	}

	//Draw page
	sprintf(buffer, "PG: %i", page + 1);
	gfxDrawText(GFX_TOP, GFX_LEFT, &fontBlack, buffer, 5, 238 - fontBlack.height * 15);	

	//Read the page
	int c;
	FILE *file;
	nextAvailable = true;
	
	file = fopen(path, "r");
	if (file) {
		//Show bookmark (with animation)
		if (page == TextView_GetBookmark(path))
		{
			if (bookmark_animation != 24) bookmark_animation+=4;
		}
		else bookmark_animation = 0;
		if(bookmark_animation != 0) drawFillRect(368, 20, 385, 20 + bookmark_animation, 255, 0, 0, screenTopLeft);

		//Start reading the page
        fseek(file, !page ? 4 : offsets[page], SEEK_SET);
		int i = 0;
		for (i = 0; i < 29; i++)
		{
			//Loads the line
			int j = 0;
			char line[55];

			for (j = 0; j < 55; j++)
			{
				if ((c = getc(file)) != EOF && c != '\n') line[j] = c;
				else
				{
					if (c == EOF) nextAvailable = false;
					line[j] = '\0';
					break;
				}
			}

			//Prints text
			gfxDrawText(
				i < 14 ? GFX_TOP : GFX_BOTTOM, GFX_LEFT,                 //Screen on which to print the text
				greyScale ? &fontBlack : &fontBrown,
				line,                                                    //Line of text to print
				i < 14 ? 44 : 5,                                         //Horizzontal position of the text
				238 - fontBlack.height * (i < 14 ? i + 2 : i + 1 - 14)       //Vertical position of the text
				);
		}
        //Save the current offset in file, for every page
	    fflush(file);
	    offsets[page+1] = ftell(file);
		fclose(file);
	}
	else
	{
		//Error
	    
	}

	//Next/Previous Page buttons:
	if (page!=0) gfxDrawSprite(GFX_TOP, GFX_LEFT, (u8*)PrevPG_bin, 71, 23, 0, 85);       // <--
	if (nextAvailable) gfxDrawSprite(GFX_TOP, GFX_LEFT, (u8*)NextPG_bin, 72, 22, 378, 85); // -->	

}
Esempio n. 11
0
void GUI_MenuView()
{
	gfxDrawSprite(GFX_TOP, GFX_LEFT, (u8*)MenuBKG_bin, 240, 400, 0, 0); //Top Background
	gfxDrawSprite(GFX_BOTTOM, GFX_LEFT, (u8*)FMBKG_bin, 216, 320, 0, 24);
	gfxDrawSprite(GFX_BOTTOM, GFX_LEFT, (u8*)Exit_bin, 24, 320, 0, 0); //Exit button
}
Esempio n. 12
0
void GUI_QuickUi()
{
	if (quickui_animation != 24)quickui_animation+=4; //Animation
	gfxDrawSprite(GFX_BOTTOM, GFX_LEFT, (u8*)QuickUI_bin, 24, 320, 0,-24+quickui_animation);
}