예제 #1
0
int scanDirCallback(char *dirName){
    oslStartDrawing();
    drawCommonGraphics();
    drawButtonBar(MODE_MEDIA_LIBRARY);

    int startX = (480 - scanBkg->sizeX) / 2;
    int startY = (272 - scanBkg->sizeY) / 2;
    oslDrawImageXY(scanBkg, startX, startY);
    skinGetColor("RGBA_POPUP_TITLE_TEXT", tempColor);
    skinGetColor("RGBA_POPUP_TITLE_TEXT_SHADOW", tempColorShadow);
    setFontStyle(fontNormal, defaultTextSize, RGBA(tempColor[0], tempColor[1], tempColor[2], tempColor[3]), RGBA(tempColorShadow[0], tempColorShadow[1], tempColorShadow[2], tempColorShadow[3]), INTRAFONT_ALIGN_LEFT);
    oslDrawString((480 - oslGetStringWidth(langGetString("SCANNING"))) / 2, startY + 3, langGetString("SCANNING"));
    skinGetColor("RGBA_POPUP_MESSAGE_TEXT", tempColor);
    skinGetColor("RGBA_POPUP_MESSAGE_TEXT_SHADOW", tempColorShadow);
    setFontStyle(fontNormal, defaultTextSize, RGBA(tempColor[0], tempColor[1], tempColor[2], tempColor[3]), RGBA(tempColorShadow[0], tempColorShadow[1], tempColorShadow[2], tempColorShadow[3]), INTRAFONT_ALIGN_LEFT);
    getFileName(dirName, buffer);
    if (strlen(buffer) > 70)
       buffer[70] = '\0';
    oslDrawString((480 - oslGetStringWidth(buffer)) / 2, startY + 30, buffer);

    oslReadKeys();
    oslEndDrawing();
    oslEndFrame();
    oslSyncFrame();
    return 0;
}
예제 #2
0
void WarningScreen::draw()
{
	oslDrawImageXY(mCover,0,0);
	oslIntraFontSetStyle(gFont, 1.2f,RGBA(175,137,62,255), RGBA(0,0,0,0),INTRAFONT_ALIGN_CENTER);
	oslDrawString(240,20,Resource::STR_WARNING_CAPTION);
	oslIntraFontSetStyle(gFont, 0.6f,RGBA(175,137,62,255), RGBA(0,0,0,0),INTRAFONT_ALIGN_CENTER);
	oslDrawString(240,100,Resource::STR_WARNING_TEXT);
	oslDrawImageXY(mBack, (430) - (mBack->stretchX), (272) - (mBack->stretchY));
	oslIntraFontSetStyle(gFont, 0.7f,RGBA(175,137,62,255), RGBA(0,0,0,0),INTRAFONT_ALIGN_CENTER);
	oslDrawString((510) - mBack->stretchX,(272) - (mBack->stretchY/2),Resource::STR_BACK_SK);
}
예제 #3
0
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Connect to Access Point:
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int connectAPCallback(int state){
    oslStartDrawing();
    oslDrawImageXY(bkg, 0, 0);
    oslDrawString(30, 200, "Connecting to AP...");
    sprintf(buffer, "State: %i", state);
    oslDrawString(30, 230, buffer);
    oslEndDrawing();
    oslEndFrame();
    oslSyncFrame();

    return 0;
}
예제 #4
0
int initiateMessage()
{
    char* nickname = (char*)malloc(100);
    int skip = 0;

    oslSetFont(Roboto);
	oslIntraFontSetStyle(Roboto, fontSize, BLACK, 0, INTRAFONT_ALIGN_LEFT);
	
    while(!osl_quit)
    {
       if (!skip)
       {
               oslStartDrawing();
               if (oslIsWlanPowerOn())
               {
                   oslDrawString(10, 10, "Please Enter nickname By Pressing X (Client)...");
                   oslDrawString(10, 25, "Please Press O To Act As Server...");
                   if (oslOskIsActive()){
                    oslDrawOsk();
                    if (oslGetOskStatus() == PSP_UTILITY_DIALOG_NONE)
                    {
                        if (oslOskGetResult() == OSL_OSK_CANCEL)
                        {
                            nickname = (char*)"Client";
                        }   
                        else
                        {
                            oslOskGetText(nickname);
                        }
                        oslEndOsk();
                    }
               }
               else
               {
                   oslDrawString(10, 40, "Please turn on the wlan switch!");
               }
               oslEndDrawing();
           }
           oslEndFrame();
           skip = oslSyncFrame();
           oslReadKeys();
           if (osl_keys->released.cross && oslIsWlanPowerOn())
           {
               oslInitOsk((char*)"Please enter nickname!", (char*)"Client", 99, 1, -1);

           }
      }

    }

    sceKernelExitGame();
    return 0;
}
예제 #5
0
int connectToAP(int config){
    oslStartDrawing();
    oslDrawImageXY(bkg, 0, 0);
    oslDrawString(30, 200, "Connecting to AP...");
    oslEndDrawing();
    oslEndFrame();
    oslSyncFrame();

    int result = oslConnectToAP(config, 30, connectAPCallback);
    if (!result){
        char ip[30] = "";
        char resolvedIP[30] = "";

        oslStartDrawing();
        oslDrawImageXY(bkg, 0, 0);
        oslGetIPaddress(ip);
        sprintf(buffer, "IP address: %s", ip);
        oslDrawString(30, 170, buffer);

        sprintf(buffer, "Resolving %s", ADDRESS);
        oslDrawString(30, 200, buffer);
        oslEndDrawing();
        oslEndFrame();
        oslSyncFrame();

        result = oslResolveAddress(ADDRESS, resolvedIP);

        oslStartDrawing();
        oslDrawImageXY(bkg, 0, 0);
        oslGetIPaddress(ip);
        if (!result)
            sprintf(buffer, "Resolved IP address: %s", ip);
        else
            sprintf(buffer, "Error resolving address!");
        oslDrawString(30, 230, buffer);
        oslEndDrawing();
        oslEndFrame();
        oslSyncFrame();
		sceKernelDelayThread(3*1000000);
    }else{
        oslStartDrawing();
        oslDrawImageXY(bkg, 0, 0);
        sprintf(buffer, "Error connecting to AP!");
        oslDrawString(30, 200, buffer);
        oslEndDrawing();
        oslEndFrame();
        oslSyncFrame();
		sceKernelDelayThread(3*1000000);
    }
    oslDisconnectFromAP();
    return 0;
}
예제 #6
0
//The client is connected and can send data:
void clientConnected(struct remotePsp *aPsp)
{
    int skip = 0;
	char mess[100] = "Hello distant World !!!";

    while(!osl_quit){
	
        if (!skip){
            oslStartDrawing();
			printInfo();
			oslDrawStringf(10, 60, "Press O to send a message to %s", aPsp->name);
            oslDrawString(10, 70, "Press O to abort");

            oslEndDrawing();
        }
        oslEndFrame();
        skip = oslSyncFrame();

        oslReadKeys();
		if (osl_keys->released.cross)
		{
			oslPlaySound(KeypressStandard, 1);  
			oslQuit();
		}
		else if (osl_keys->released.circle)
		{
			oslAdhocSendData(aPsp, mess, strlen( mess));
		}
	}
}
예제 #7
0
파일: Fps.cpp 프로젝트: dogo/gods-defense
void Fps::renderInfo()
{
	//dogo : oslPrintf_xy(0,25,"FPS : %0.1f %d\n", getFps(), getUpf());
	char fps[256];
	sprintf(fps, "FPS : %0.1f", getFps());
	oslIntraFontSetStyle(gFont, 1.0f,RGBA(192,192,192,255), RGBA(0,0,0,0),INTRAFONT_ALIGN_LEFT);
	oslDrawString(0,23, fps);
}
예제 #8
0
//The server accepted the connection and it's ready to receive data:
void serverConnected(struct remotePsp *aPsp)
{
    int skip = 0;
	char buffer[100] = "";
	int dataLength = 0;

    while(!osl_quit){
		if (dataLength <= 0)
			dataLength = oslAdhocReceiveData(aPsp, buffer, 100);

        if (!skip){
            oslStartDrawing();

			printInfo();

			if (dataLength <= 0)
			{
				oslDrawStringf(10, 40, "Waiting for data from %s", aPsp->name);
			}
			else
			{
				oslDrawStringf(10, 40, "Data received from %s:", aPsp->name);
				oslDrawStringf(10, 55, buffer);
				oslDrawString(10, 70, "Press O to receive more data");
			}
			oslDrawString(150, 250, "Press X to quit");
            oslEndDrawing();
        }
        oslEndFrame();
        skip = oslSyncFrame();

        oslReadKeys();
		if (osl_keys->released.cross)
		{
			oslQuit();
		}
		else if (osl_keys->released.circle && dataLength > 0)
		{
			dataLength = 0;
			memset(buffer, sizeof(buffer), 0);
		}
	}
}
예제 #9
0
void TitleScreen::draw()
{
	//draw logo image
	oslDrawImageXY(GDSplash, (480/2) - (GDSplash->stretchX/2), (272/2) - (GDSplash->stretchY/2));
	
	//Flashing
	float t = ((float)(clock() % CLOCKS_PER_SEC)) / ((float)CLOCKS_PER_SEC);
	int val = (t < 0.5f) ? t*511 : (1.0f-t)*511;
	oslIntraFontSetStyle(gFont, 0.7f,RGBA(255,255,255,255),(0xFF<<24)+(val<<16)+(val<<8)+(val),INTRAFONT_ALIGN_CENTER);
	oslDrawString(240,220,Resource::STR_PRESS_START);
	oslIntraFontSetStyle(gFont, 0.7f,RGBA(255,255,255,255), RGBA(0,0,0,0),INTRAFONT_ALIGN_CENTER);
}
예제 #10
0
bool tmDeleteWarning(int slot) {
	bool x = FALSE;
	char msg[50];
	sprintf(msg, "Are you sure you want to delete song%d.tms ?", slot);
	while (!osl_quit) {
		oslStartDrawing();
		oslReadKeys();
		tmDrawGrid();
		oslDrawFillRect(0, 0, 480, 272, RGBA(0, 0, 0, 125));
		oslDrawString(13, 70, msg);
		oslDrawString(100, 90, "X - Yes");
		oslDrawString(100, 100, "O - No");
		if (osl_keys->pressed.cross) {
			x = TRUE;
			break;
		}
		if (osl_keys->pressed.circle)
			break;
		oslEndDrawing();
		oslSyncFrame();
	}
	return x;
}
예제 #11
0
bool tmClearAllWarning(void) {
	oslClearScreen(RGBA(0, 0, 0, 255));
	bool x = FALSE;
	while (!osl_quit) {
		oslStartDrawing();
		oslReadKeys();
		tmDrawGrid();
		oslDrawFillRect(0, 0, 480, 272, RGBA(0, 0, 0, 125));
		oslSetTextColor(RGBA(255,0,0,255));
		oslDrawString(200, 50, "WARNING:");
		oslSetTextColor(RGBA(255,255,255,255));
		oslDrawString(3, 70, "Are you sure you want to clear all grids? This cannot be undone.");
		oslDrawString(13, 80, "Press X to clear all grids, or press O to cancel.");
		if (osl_keys->pressed.cross) {
			x = TRUE;
			break;
		}
		if (osl_keys->pressed.circle)
			break;
		oslEndDrawing();
		oslSyncFrame();
	}
	return x;
}
예제 #12
0
static PyObject* osl_drawString(PyObject *self,
                                PyObject *args,
                                PyObject *kwargs)
{
    char *string;
    int x, y;

    if (!PyArg_ParseTuple(args, "iis:drawString", &x, &y, &string))
        return NULL;

    oslDrawString(x, y, string);

    Py_INCREF(Py_None);
    return Py_None;
}
예제 #13
0
파일: text.c 프로젝트: DavisDev/oslib-mod
void oslDrawTextBoxByWords(int x0, int y0, int x1, int y1, const char *text, int format)
{
	char buffer[50];
	int contaCaratteri;
	unsigned char c;
	int x,y, x2; //x2 => width della parola
	x = x0;
	y = y0;
    const char *text2;
    text2=text;
    while(*text2)
    {
        memset(buffer,'\0',50);
        //estrae una parola
        contaCaratteri = 0;
		x2 = 0;
        while (*text2 != '\n' && *text2 != ' ' && *text2) {
            contaCaratteri++;
			text2++;
        }
        if (contaCaratteri > 0 ) {
            strncpy( buffer, text, contaCaratteri);
			x2 = oslGetStringWidth(buffer);
			if ((x+x2)> x1)
            {
            	x = x0;
				y += osl_curFont->charHeight;
				if (y > y1) break;

            }
            oslDrawString(x, y, buffer);
			text+=contaCaratteri;
			x += x2;
        }
        if (*text2 == ' ') {
			c = *text;
            x += osl_curFont->charWidths[c];
			text2++; text++;
        }
        if (*text2 == '\n') {
			x = x0;
			y += osl_curFont->charHeight;
			if (y> y1) break;
			text2++; text++;
        }
    }
}
예제 #14
0
void MainMenuScreen::draw()
{
	oslDrawImageXY(menubg, (480/2) - (menubg->stretchX/2), (272/2) - (menubg->stretchY/2));
	(gMenu == 0) ? oslIntraFontSetStyle(gFont, 1.2f,RGBA(175,137,62,255), RGBA(0,0,0,255),INTRAFONT_ALIGN_CENTER) : oslIntraFontSetStyle(gFont, 0.6f,RGBA(120,120,120,255), RGBA(0,0,0,0xFF),INTRAFONT_ALIGN_CENTER);
	oslDrawString(340, 100,Resource::STR_START_GAME);
	(gMenu == 1) ? oslIntraFontSetStyle(gFont, 1.2f,RGBA(175,137,62,255), RGBA(0,0,0,255),INTRAFONT_ALIGN_CENTER) : oslIntraFontSetStyle(gFont, 0.6f,RGBA(120,120,120,255), RGBA(0,0,0,0xFF),INTRAFONT_ALIGN_CENTER);
	oslDrawString(340, 120,Resource::STR_MULTIPLAYER_CAPTION);
	(gMenu == 2) ? oslIntraFontSetStyle(gFont, 1.2f,RGBA(175,137,62,255), RGBA(0,0,0,255),INTRAFONT_ALIGN_CENTER) : oslIntraFontSetStyle(gFont, 0.6f,RGBA(120,120,120,255), RGBA(0,0,0,0xFF),INTRAFONT_ALIGN_CENTER);
	oslDrawString(340, 140,Resource::STR_HELP_CAPTION);
	(gMenu == 3) ? oslIntraFontSetStyle(gFont, 1.2f,RGBA(175,137,62,255), RGBA(0,0,0,255),INTRAFONT_ALIGN_CENTER) : oslIntraFontSetStyle(gFont, 0.6f,RGBA(120,120,120,255), RGBA(0,0,0,0xFF),INTRAFONT_ALIGN_CENTER);
	oslDrawString(340, 160,Resource::STR_TROPHIES_CAPTION);
	(gMenu == 4) ? oslIntraFontSetStyle(gFont, 1.2f,RGBA(175,137,62,255), RGBA(0,0,0,255),INTRAFONT_ALIGN_CENTER) : oslIntraFontSetStyle(gFont, 0.6f,RGBA(120,120,120,255), RGBA(0,0,0,0xFF),INTRAFONT_ALIGN_CENTER);
	oslDrawString(340, 180,Resource::STR_ABOUT_CAPTION);
	(gMenu == 5) ? oslIntraFontSetStyle(gFont, 1.2f,RGBA(175,137,62,255), RGBA(0,0,0,0xFF),INTRAFONT_ALIGN_CENTER) : oslIntraFontSetStyle(gFont, 0.6f,RGBA(120,120,120,255), RGBA(0,0,0,0xFF),INTRAFONT_ALIGN_CENTER);
	oslDrawString(340, 200,Resource::STR_EXIT_CAPTION);
}
예제 #15
0
파일: Text.cpp 프로젝트: gawron89/pspgame
void Text::draw( RenderTarget& t )
{
#ifdef __WIN32__

	sf::Text text;
	Font* f = Font::getGlobalFont();
	if(f)
		text.setFont(f->handle);
	text.setColor(gawColorToSfColor(color));
	text.setPosition(m_position.x, m_position.y);
	text.setString(str);
	text.setCharacterSize(15);

	t.handle->draw(text);
#else

	oslSetTextColor(color.rgba);
	oslDrawString(m_position.x, m_position.y, str.c_str());


#endif
}
예제 #16
0
int calculator()
{
	//int result;
	int x = 1;
	int y = 1;
	/*
	int enterednumber;
	int numberuse = 0;
	int suppression = 1;
	int Number = 0;
	*/

	calcbackground = oslLoadImageFile("system/app/calculator/calcbg.png", OSL_IN_RAM, OSL_PF_8888);

	oslSetFont(Roboto);
	
	if (!calcbackground)
		debugDisplay();
		
	while (!osl_quit)
	{
		LowMemExit();
	
		oslStartDrawing();
		
		oslClearScreen(RGB(0,0,0));
		
		controls();	

		oslDrawImageXY(calcbackground, 0, 0);
		
		battery(370,2,1);
		digitaltime(420,4,0,hrTime);
		volumeController();
		
		oslIntraFontSetStyle(Roboto, 0.8f,WHITE,0,0);

		oslDrawString(35,120,"7");
		oslDrawString(90,120,"8");
		oslDrawString(145,120,"9");
		oslDrawString(35,160,"4");
		oslDrawString(90,160,"5");
		oslDrawString(145,160,"6");
		oslDrawString(35,200,"1");
		oslDrawString(90,200,"2");
		oslDrawString(145,200,"3");
		oslDrawString(90,240,"0");

		oslDrawString(218,120,"/");
		oslDrawString(218,160,"x");
		oslDrawString(218,200,"-");
		oslDrawString(218,240,"+");
		oslIntraFontSetStyle(Roboto, 0.6f,WHITE,0,0);
		oslDrawString(260,120,"DEL");

		oslDrawString(326,120,"sin");
		oslDrawString(366,120,"cos");
		oslDrawString(406,120,"tan");
		oslDrawString(446,120,"ln");
	
		if (osl_keys->pressed.left)
		x -= 1;
		if (x == 0)
		x = 8;

		if (osl_keys->pressed.right)
		x += 1;
		if (x == 10)
		x = 1;

		if (osl_keys->pressed.up)
		y -= 1;
		if (y == 0)
		y = 4;

		if (osl_keys->pressed.down)
		y += 1;
		if (y == 5)
		y = 1;
			
			if (y == 1 && x ==1)
			{
				oslIntraFontSetStyle(Roboto, 0.8f,RED,0,0);
				oslDrawString(35,120,"7");
			}
			else if (y == 1 && x == 2)
			{
				oslIntraFontSetStyle(Roboto, 0.8f,RED,0,0);
				oslDrawString(90,120,"8");
			}
			else if (y == 1 && x  == 3) 
			{
				oslIntraFontSetStyle(Roboto, 0.8f,RED,0,0);
				oslDrawString(145,120,"9");
			}
			else if (y == 1 && x == 4)
			{
				oslIntraFontSetStyle(Roboto, 0.8f,RED,0,0);
				oslDrawString(218,120,"/");
			}
			else if (y == 1 && x == 5)
			{
				oslIntraFontSetStyle(Roboto, 0.6f,RED,0,0);
				oslDrawString(260,120,"DEL");
			}
			else if (y == 1 && x  == 6) 
			{
				oslIntraFontSetStyle(Roboto, 0.6f,RED,0,0);
				oslDrawString(326,120,"sin");
			}
			else if (y == 1 && x  == 7)
			{
				oslIntraFontSetStyle(Roboto, 0.6f,RED,0,0);
				oslDrawString(366,120,"cos");
			}
			else if (y == 1 && x  == 8)
			{
				oslIntraFontSetStyle(Roboto, 0.6f,RED,0,0);
				oslDrawString(406,120,"tan");
			}
			else if (y == 1 && x  == 9)
			{
				oslIntraFontSetStyle(Roboto, 0.6f,RED,0,0);
				oslDrawString(446,120,"ln");
			}
			
			if (y == 2 && x == 1)
			{
				oslIntraFontSetStyle(Roboto, 0.8f,RED,0,0);
				oslDrawString(35,160,"4");
			}
			else if (y == 2 && x == 2) 
			{
				oslIntraFontSetStyle(Roboto, 0.8f,RED,0,0);
				oslDrawString(90,160,"5");
			}
			else if (y == 2 && x == 3)
			{
				oslIntraFontSetStyle(Roboto, 0.8f,RED,0,0);
				oslDrawString(145,160,"6");
			}
			else if (y == 2 && x == 4) 
			{
				oslIntraFontSetStyle(Roboto, 0.8f,RED,0,0);
				oslDrawString(218,160,"x");
			}

			if (y == 3 && x == 1)
			{
				oslIntraFontSetStyle(Roboto, 0.8f,RED,0,0);
				oslDrawString(35,200,"1");
			}
			else if (y == 3 && x == 2)
			{
				oslIntraFontSetStyle(Roboto, 0.8f,RED,0,0);
				oslDrawString(90,200,"2");
			}
			else if (y == 3 && x == 3)
			{
				oslIntraFontSetStyle(Roboto, 0.8f,RED,0,0);
				oslDrawString(145,200,"3");
			}
			else if (y == 3 && x == 4)
			{
				oslIntraFontSetStyle(Roboto, 0.8f,RED,0,0);
				oslDrawString(218,200,"-");
			}	

			if (y == 4 && x == 1)
			{
				oslIntraFontSetStyle(Roboto, 0.8f,RED,0,0);
				oslDrawString(90,240,"0");
			}
			else if (y == 4 && x == 2)
			{
				oslIntraFontSetStyle(Roboto, 0.8f,RED,0,0);
				oslDrawString(218,240,"+");
			}
		
		if (osl_keys->pressed.square)
		{
			powermenu();
		}
		
		if (osl_keys->pressed.circle)
		{	
			oslDeleteImage(calcbackground);
			appdrawer();
		}
		
		if (osl_keys->pressed.L)
		{
			oslPlaySound(Lock, 1);  
			lockscreen();
        }
		
		captureScreenshot();
		
        oslEndDrawing(); 
		oslEndFrame(); 
		oslSyncFrame();
	}
	return 0;
}
예제 #17
0
void newMessage()
{	
	new_message = oslLoadImageFilePNG("system/app/messenger/new_message.png", OSL_IN_RAM, OSL_PF_8888);
	
	if (!new_message)
		debugDisplay();
	
	while (!osl_quit)
	{
		LowMemExit();
		
		oslStartDrawing();
		
		oslClearScreen(RGB(0,0,0));
		
		controls();	

		oslDrawImageXY(new_message, 0, 0);
		
		navbarButtons(2);
		battery(330,2,0);
		digitaltime(381,4,0,hrTime);
		androidQuickSettings();
		volumeController();
		oslDrawImage(cursor);
		
		if (osl_keys->pressed.L)
		{
			oslPlaySound(Lock, 1);  
			lockscreen();
		}
		
		if (osl_keys->pressed.circle)
		{
			oslDeleteImage(new_message);
			messenger();
		}

		if ((cursor->x  >= 444 && cursor->x  <= 480) && (cursor->y >= 157 && cursor->y <= 213) && (osl_keys->pressed.cross))
		{
			oslPlaySound(KeypressStandard, 1);  
			oslDeleteImage(messengerbg);
			messenger();
		}

		if ((cursor->x  >= 444 && cursor->x  <= 480) && (cursor->y >= 76 && cursor->y <= 155) && (osl_keys->pressed.cross))
		{
			oslPlaySound(KeypressStandard, 1);  
			oslDeleteImage(messengerbg);
			home();
		}
		
		if ((cursor->x  >= 444 && cursor->x  <= 480) && (cursor->y >= 19 && cursor->y <= 75) && (osl_keys->pressed.cross))
		{
			oslPlaySound(KeypressStandard, 1);  
			multitask();
		}
		
		captureScreenshot();
		
		if (cursor->x >= 7 && cursor->x <= 435 && cursor->y >= 55 && cursor->y <= 86 && osl_keys->pressed.cross)
		{
			oslPlaySound(KeypressStandard, 1);  
			doServer();
		}
		
		oslIntraFontSetStyle(Roboto, fontSize, BLACK, 0, INTRAFONT_ALIGN_LEFT);
		oslDrawString(14, 245, tempMessage);
		
		if (cursor->x >= 10 && cursor->x <= 362 && cursor->y >= 228 && cursor->y <= 270 && osl_keys->pressed.cross)
		{
			oslPlaySound(KeypressStandard, 1);  
			openOSK("Enter Message", "", 128, -1);
		}
		
		if ((cursor->x >= 10 && cursor->x <= 405 && cursor->y >= 88 && cursor->y <= 118 && osl_keys->pressed.cross) && oslIsWlanPowerOn())
			doClient();
        else if ((cursor->x >= 410 && cursor->x <= 442 && cursor->y >= 92 && cursor->y <= 118 && osl_keys->pressed.cross) && oslIsWlanPowerOn())
			doServer();
		
        oslEndDrawing(); 
		oslEndFrame(); 
        oslSyncFrame();
	}
}
예제 #18
0
//Waits for a connection from a psp:
void doServer()
{
    int skip = 0;
	int quit = 0;
	char message[100] = "";
	int dialog = OSL_DIALOG_NONE;
	int connected = 0;

	int init = oslAdhocInit("ULUS99999");
	if (init)
	{
		snprintf(message, sizeof(message), "adhocInit error: %i", init);
		oslMessageBox(message, "Debug",  oslMake3Buttons(OSL_KEY_CROSS, OSL_MB_OK , 0, 0, 0, 0));
		return;
	}

    while(!osl_quit && !quit){
		struct remotePsp *reqPsp = oslAdhocGetConnectionRequest();

        if (!skip){
            oslStartDrawing();

			printInfo();
			oslDrawString(10, 40, "Press O to abort");
			if (reqPsp == NULL)
			{
				oslDrawString(10, 100, "Waiting for a connection request...");
			}
			else
			{
				snprintf(message, sizeof(message), "Accept request from psp : %s", reqPsp->name);
				oslDrawString(10, 100, message);
				if (oslGetDialogType() == OSL_DIALOG_NONE)
					oslInitMessageDialog(message, 1);
			}

            dialog = oslGetDialogType();
            if (dialog){
                oslDrawDialog();
                if (oslGetDialogStatus() == PSP_UTILITY_DIALOG_NONE){
                    if (dialog == OSL_DIALOG_MESSAGE){
                        int button = oslGetDialogButtonPressed();
                        if (button == PSP_UTILITY_MSGDIALOG_RESULT_YES)
						{
							oslAdhocAcceptConnection(reqPsp);
							connected = 1;
						}
                        else if (button == PSP_UTILITY_MSGDIALOG_RESULT_NO)
						{
							oslAdhocRejectConnection(reqPsp);
						}
                    }
                    oslEndDialog();
                }
			}

            oslEndDrawing();
        }
        oslEndFrame();
        skip = oslSyncFrame();

		if (connected)
			serverConnected(reqPsp);

		oslReadKeys();
		if (dialog == OSL_DIALOG_NONE)
		{
			if (osl_keys->released.circle)
			{
				quit = 1;
			}
		}
	}
	oslAdhocTerm();
}
예제 #19
0
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Draw info on selected item:
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void drawMLinfo(){
	static u64 lastMenuChange = 0;
	static int lastSelected = -1;

	OSL_FONT *font = fontNormal;
	OSL_IMAGE *tmpCoverArt = NULL;

    if (mediaLibraryStatus != STATUS_QUERYMENU)
        return;

    skinGetPosition("POS_MEDIALIBRARY_INFO_BKG", tempPos);
    oslDrawImageXY(infoBkg, tempPos[0], tempPos[1]);
    oslSetFont(font);
    skinGetColor("RGBA_LABEL_TEXT", tempColor);
    skinGetColor("RGBA_LABEL_TEXT_SHADOW", tempColorShadow);
    setFontStyle(fontNormal, defaultTextSize, RGBA(tempColor[0], tempColor[1], tempColor[2], tempColor[3]), RGBA(tempColorShadow[0], tempColorShadow[1], tempColorShadow[2], tempColorShadow[3]), INTRAFONT_ALIGN_LEFT);

	switch (mlQueryType)
	{
	case QUERY_COUNT:
	case QUERY_COUNT_RATING:
	case QUERY_COUNT_ARTIST:
        skinGetPosition("POS_MEDIALIBRARY_TOTAL_TRACKS_LABEL", tempPos);
        oslDrawString(tempPos[0], tempPos[1], langGetString("TOTAL_TRACKS"));
        skinGetPosition("POS_MEDIALIBRARY_TOTAL_TIME_LABEL", tempPos);
        oslDrawString(tempPos[0], tempPos[1], langGetString("TOTAL_TIME"));
        skinGetColor("RGBA_TEXT", tempColor);
        skinGetColor("RGBA_TEXT_SHADOW", tempColorShadow);
        setFontStyle(fontNormal, defaultTextSize, RGBA(tempColor[0], tempColor[1], tempColor[2], tempColor[3]), RGBA(tempColorShadow[0], tempColorShadow[1], tempColorShadow[2], tempColorShadow[3]), INTRAFONT_ALIGN_LEFT);
        snprintf(buffer, sizeof(buffer), "%.f", MLresult[commonMenu.selected - mlBufferPosition]->intField01);
        skinGetPosition("POS_MEDIALIBRARY_TOTAL_TRACKS_VALUE", tempPos);
        oslDrawString(tempPos[0], tempPos[1], buffer);

        formatHHMMSS(MLresult[commonMenu.selected - mlBufferPosition]->intField02, buffer, sizeof(buffer));
        skinGetPosition("POS_MEDIALIBRARY_TOTAL_TIME_VALUE", tempPos);
        oslDrawString(tempPos[0], tempPos[1], buffer);
		break;
	case QUERY_SINGLE_ENTRY:
        skinGetPosition("POS_MEDIALIBRARY_GENRE_LABEL", tempPos);
        oslDrawString(tempPos[0], tempPos[1], langGetString("GENRE"));
        skinGetPosition("POS_MEDIALIBRARY_YEAR_LABEL", tempPos);
        oslDrawString(tempPos[0], tempPos[1], langGetString("YEAR"));
        skinGetPosition("POS_MEDIALIBRARY_TIME_LABEL", tempPos);
        oslDrawString(tempPos[0], tempPos[1], langGetString("TIME"));
        skinGetPosition("POS_MEDIALIBRARY_RATING_LABEL", tempPos);
        oslDrawString(tempPos[0], tempPos[1], langGetString("RATING"));
        skinGetPosition("POS_MEDIALIBRARY_PLAYED_LABEL", tempPos);
        oslDrawString(tempPos[0], tempPos[1], langGetString("PLAYED"));

        skinGetColor("RGBA_TEXT", tempColor);
        skinGetColor("RGBA_TEXT_SHADOW", tempColorShadow);
        setFontStyle(fontNormal, defaultTextSize, RGBA(tempColor[0], tempColor[1], tempColor[2], tempColor[3]), RGBA(tempColorShadow[0], tempColorShadow[1], tempColorShadow[2], tempColorShadow[3]), INTRAFONT_ALIGN_LEFT);
        skinGetPosition("POS_MEDIALIBRARY_GENRE_VALUE", tempPos);
        oslDrawString(tempPos[0], tempPos[1], MLresult[commonMenu.selected - mlBufferPosition]->genre);
        skinGetPosition("POS_MEDIALIBRARY_YEAR_VALUE", tempPos);
        oslDrawString(tempPos[0], tempPos[1], MLresult[commonMenu.selected - mlBufferPosition]->year);

        formatHHMMSS(MLresult[commonMenu.selected - mlBufferPosition]->seconds, buffer, sizeof(buffer));
        skinGetPosition("POS_MEDIALIBRARY_TIME_VALUE", tempPos);
        oslDrawString(tempPos[0], tempPos[1], buffer);

        skinGetPosition("POS_MEDIALIBRARY_RATING_VALUE", tempPos);
        drawRating(tempPos[0], tempPos[1], MLresult[commonMenu.selected - mlBufferPosition]->rating);

		skinGetPosition("POS_MEDIALIBRARY_PLAYED_VALUE", tempPos);
		snprintf(buffer, sizeof(buffer), "%i", MLresult[commonMenu.selected - mlBufferPosition]->played);
		oslDrawString(tempPos[0], tempPos[1], buffer);

		if (commonMenu.selected != lastSelected){
			sceRtcGetCurrentTick (&lastMenuChange);
			lastSelected = commonMenu.selected;
			if (coverArt){
				oslDeleteImage(coverArt);
				coverArt = NULL;
			}
			coverArtFailed = 0;
		}else if (!coverArt && !coverArtFailed){
			u64 currentTime;
			sceRtcGetCurrentTick(&currentTime);
			if (currentTime - lastMenuChange > COVERTART_DELAY){
				char dirName[264];
				int size = 0;

				cpuBoost();
				snprintf(dirName, sizeof(dirName), "%s", MLresult[commonMenu.selected - mlBufferPosition]->shortpath);
				directoryUp(dirName);
				//Look for folder.jpg in the same directory:
				snprintf(buffer, sizeof(buffer), "%s/%s", dirName, "folder.jpg");

				size = fileExists(buffer);
				if (size > 0 && size <= MAX_IMAGE_DIMENSION)
                {
					tmpCoverArt = oslLoadImageFileJPG(buffer, OSL_IN_RAM | OSL_SWIZZLED, OSL_PF_8888);
                }
				else
                {
					//Look for cover.jpg in same directory:
					snprintf(buffer, sizeof(buffer), "%s/%s", dirName, "cover.jpg");
					size = fileExists(buffer);
					if (size > 0 && size <= MAX_IMAGE_DIMENSION)
						tmpCoverArt = oslLoadImageFileJPG(buffer, OSL_IN_RAM | OSL_SWIZZLED, OSL_PF_8888);
				}
				if (tmpCoverArt){
    				int coverArtWidth  = skinGetParam("MEDIALIBRARY_COVERART_WIDTH");
    				int coverArtHeight = skinGetParam("MEDIALIBRARY_COVERART_HEIGHT");

					coverArt = oslScaleImageCreate(tmpCoverArt, OSL_IN_RAM | OSL_SWIZZLED, coverArtWidth, coverArtHeight, OSL_PF_8888);
					oslDeleteImage(tmpCoverArt);
					tmpCoverArt = NULL;

        			coverArt->stretchX = coverArtWidth;
        			coverArt->stretchY = coverArtHeight;
				}else{
					coverArtFailed = 1;
				}
				cpuRestore();
			}
		}

		if (coverArt){
			skinGetPosition("POS_MEDIALIBRARY_COVERART", tempPos);
			oslDrawImageXY(coverArt, tempPos[0], tempPos[1]);
		}
		break;
	}
}
예제 #20
0
//Connects to a psp:
void doClient()
{
    int skip = 0;
	int quit = 0;
	int i = 0;
	int current = 0;

	int init = oslAdhocInit("ULUS99999");
	if (init)
	{
		char message[100] = "";
		sprintf(message, "adhocInit error: %i", init);
		oslMessageBox(message, "Debug",  oslMake3Buttons(OSL_KEY_CROSS, OSL_MB_OK , 0, 0, 0, 0));
		return;
	}

    while(!osl_quit && !quit){
        if (!skip){
            oslStartDrawing();

			printInfo();
			if (oslAdhocGetRemotePspCount())
				oslDrawString(10, 60, "Press X to request a connection");
				oslDrawString(10, 70, "Press O to abort");
			for (i=0; i < oslAdhocGetRemotePspCount(); i++)
			{
				if (i == current)
				    oslIntraFontSetStyle(Roboto, 1.0, RGBA(100,100,100,255), RGBA(0,0,0,0), INTRAFONT_ALIGN_LEFT);
				else
				    oslIntraFontSetStyle(Roboto, 1.0, RGBA(255,255,255,255), RGBA(0,0,0,0), INTRAFONT_ALIGN_LEFT);
				oslDrawString(10, 100 + 15 * i, oslAdhocGetPspByIndex(i)->name);
			}
            oslEndDrawing();
        }
        oslEndFrame();
        skip = oslSyncFrame();

		oslReadKeys();
		if (osl_keys->released.down)
		{
			if (++current >= oslAdhocGetRemotePspCount())
				current = 0;
		}
		else if (osl_keys->released.up)
		{
			if (--current < 0)
				current = oslAdhocGetRemotePspCount() - 1;
		}
		else if (osl_keys->released.cross && oslAdhocGetRemotePspCount())
		{
			//Request a connection:
			int ret = oslAdhocRequestConnection(oslAdhocGetPspByIndex(current), 30, NULL);
			if (ret == OSL_ADHOC_ACCEPTED || ret == OSL_ADHOC_ESTABLISHED)
			{
				clientConnected(oslAdhocGetPspByIndex(current));
			}
		}
		else if (osl_keys->released.circle)
		{
			quit = 1;
		}
	}
	oslAdhocTerm();
}
예제 #21
0
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Main:
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main(){
	int skip = 0;
    int enabled = 1;
    int selectedConfig = 0;
    SetupCallbacks();

    initOSLib();
    oslIntraFontInit(INTRAFONT_CACHE_MED);
    oslNetInit();

    //Loads image:
    bkg = oslLoadImageFilePNG("bkg.png", OSL_IN_RAM | OSL_SWIZZLED, OSL_PF_8888);

    //Load font:
    OSL_FONT *font = oslLoadFontFile("flash0:/font/ltn0.pgf");
    oslSetFont(font);

    if (!oslIsWlanPowerOn())
        sprintf(message, "Please turn on the WLAN.");

    //Get connections list:
    struct oslNetConfig configs[OSL_MAX_NET_CONFIGS];
    int numconfigs = oslGetNetConfigs(configs);
    if (!numconfigs){
        sprintf(message, "No configuration found!");
        enabled = 0;
    }

    while(runningFlag && !osl_quit){
        if (!skip){
			oslStartDrawing();
			oslDrawImageXY(bkg, 0, 0);
            if (enabled){
                sprintf(buffer, "Press X to connect to %s.", configs[selectedConfig].name);
    			oslDrawString(30, 50, buffer);
    			oslDrawString(30, 80, "Press UP and DOWN to change settings.");
            }
            oslDrawString(30, 150, "Press /\\ to quit.");
			oslDrawString(30, 200, message);

			oslEndDrawing();
		}
        oslEndFrame();
        skip = oslSyncFrame();

        oslReadKeys();
        if (osl_keys->released.triangle)
            runningFlag = 0;

        if (osl_keys->released.cross){
            connectToAP(selectedConfig + 1);
        }else if (osl_keys->released.up){
            if (++selectedConfig >= numconfigs)
                selectedConfig = numconfigs - 1;
        }else if (osl_keys->released.down){
            if (--selectedConfig < 0)
                selectedConfig = 0;
        }
    }
    //Quit OSL:
    oslNetTerm();
    oslEndGfx();
    sceKernelExitGame();
    return 0;

}
예제 #22
0
/*
  call-seq: drawScripted(x, y, txt)

  Draws a scripted (i.e. which may use \n, ...) text on the screen.
*/
VALUE drawScripted(VALUE self, VALUE x, VALUE y, VALUE text)
{
    text = rb_obj_as_string(text);
    oslDrawString(FIX2INT(x), FIX2INT(y), StringValuePtr(text));
    return Qnil;
}
예제 #23
0
/*
  call-seq: drawText(x, y, text)

  Draws a text on the screen.
*/
VALUE drawText(VALUE self, VALUE x, VALUE y, VALUE text)
{
   oslDrawString(FIX2INT(x), FIX2INT(y), StringValuePtr(text));
   return Qnil;
}
예제 #24
0
unsigned char tmMenu(void) {
	int x;
	char mstrings[MAX_MENU_ITEMS][40];
	char ver[25];
	while (!osl_quit) {
		oslStartDrawing();
		oslReadKeys();
		tmDrawGrid();
		oslDrawFillRect(0, 0, 480, 272, RGBA(0, 0, 0, 125));
		tempo = tmTempo(bpm);
		bpm = tmBPM(tempo);
		for (x = 0; x < MAX_MENU_ITEMS; x++) {
			bzero(mstrings[x], sizeof(mstrings[x]));
			switch (x) {
				case SAVEM:
					sprintf(mstrings[x], "%s Save song", (menuoption == x) ? "->" : "  ");
					break;
				case LOADM:
					sprintf(mstrings[x], "%s Load song", (menuoption == x) ? "->" : "  ");
					break;
				case HELPM:
					sprintf(mstrings[x], "%s Help me", (menuoption == x) ? "->" : "  ");
					break;
				case LOOPM:
					sprintf(mstrings[x], "%s Loop all: %s", (menuoption == x) ? "->" : "  ", (loopall) ? "on" : "off");
					break;
				case TEMPOM:
					sprintf(mstrings[x], "%s Tempo: %d BPM", (menuoption == x) ? "->" : "  ", tmBPM(tempo));
					break;
				case GRIDM:
					sprintf(mstrings[x], "%s Grid: %d", (menuoption == x) ? "->" : "  ", (current+1));
					break;
				case CUTM:
					sprintf(mstrings[x], "%s Cut grid", (menuoption == x) ? "->" : "  ");
					break;
				case COPYM:
					sprintf(mstrings[x], "%s Copy grid", (menuoption == x) ? "->" : "  ");
					break;
				case PASTEM:
					if (tmIsGridEmpty(clipboard))
						oslSetTextColor(RGBA(255,0,0,255));
					sprintf(mstrings[x], "%s Paste grid", (menuoption == x) ? "->" : "  ");
					break;
				case CLEARM:
					sprintf(mstrings[x], "%s Clear grid", (menuoption == x) ? "->" : "  ");
					break;
				case CLEARALLM:
					sprintf(mstrings[x], "%s Clear all grids", (menuoption == x) ? "->" : "  ");
					break;
			}
			oslDrawString(10, (60+(x*10)), mstrings[x]);
			oslSetTextColor(RGBA(255,255,255,255));
		}
		bzero(ver, sizeof(ver));
		// sprintf(ver, "ToneMatrix %s by Babkock", VERSION);
		oslDrawString(10, 240, ver);
		if ((osl_keys->pressed.up) && (menuoption > 0)) {
			menuoption--;
			if (menuoption == BREAK)
				menuoption--;
		}
		if ((osl_keys->pressed.down) && (menuoption < (MAX_MENU_ITEMS-1))) {
			menuoption++;
			if (menuoption == BREAK)
				menuoption++;
		}
		if (osl_keys->pressed.left) {
			switch (menuoption) {
				case GRIDM:
					if (current > 0)
						current--;
					break;
				case LOOPM:
					loopall = (loopall) ? FALSE : TRUE;
					break;
				case TEMPOM:
					if (bpm > MIN_BPM)
						bpm -= 5;
					tempo = tmTempo(bpm);
					break;
			}
		}
		if (osl_keys->pressed.right) {
			switch (menuoption) {
				case GRIDM:
					if (current < (MAX_GRIDS-1))
						current++;
					break;
				case LOOPM:
					loopall = (loopall) ? FALSE : TRUE;
					break;
				case TEMPOM:
					if (bpm < MAX_BPM)
						bpm += 5;
					tempo = tmTempo(bpm);
					break;
			}
		}
		if (osl_keys->pressed.cross) {
			if ((menuoption != LOOPM) && (menuoption != TEMPOM) && (menuoption != GRIDM) &&
				(menuoption != CUTM) && (menuoption != COPYM) && (menuoption != PASTEM))
				return menuoption;
			else {
				switch (menuoption) {
					case CUTM:
						clipboard = tmClear();
						clipboard = data[current];
						data[current] = tmClear();
						break;
					case COPYM:
						clipboard = tmClear();
						clipboard = data[current];
						break;
					case PASTEM:
						if (!tmIsGridEmpty(clipboard)) {
							data[current] = tmClear();
							data[current] = clipboard;
						}
						break;
				}
			}
		}
		if (osl_keys->pressed.start)
			break;
		oslEndDrawing();
		oslSyncFrame();
	}
	return 69;
}
예제 #25
0
void tmFileDialog(bool save) {
	int x;
	unsigned char option = 0;
	bool empty[MAX_SAVE_SLOTS];
	char strings[MAX_SAVE_SLOTS][50];
	char mdate[MAX_SAVE_SLOTS][50];
	char tmp[30];
	
	SceIoStat a;
	typedef struct {
		int year, month, day;
		int minute, hour;
	} metadata;
	metadata songMeta[MAX_SAVE_SLOTS];

	current = 0;
	for (x = 0; x < MAX_SAVE_SLOTS; x++) {
		bzero(tmp, sizeof(tmp));
		sprintf(tmp, "songs/song%d.tms", x);
		sceIoGetstat(tmp, &a);
		songMeta[x].year = a.st_mtime.year;
		songMeta[x].month = a.st_mtime.month;
		songMeta[x].day = a.st_mtime.day;
		songMeta[x].minute = a.st_mtime.minute;
		songMeta[x].hour = a.st_mtime.hour;
	}
	// I have to make a separate struct because accessing sm->tm_mday
	// from the while (!osl_quit) fries the memory stick
	// same reason why there's a bool empty[]

	for (x = 0; x < MAX_SAVE_SLOTS; x++) {
		bzero(tmp, sizeof(tmp));
		sprintf(tmp, "songs/song%d.tms", x);
		empty[x] = tmDoesFileExist(tmp);
	}
	while (!osl_quit) {
		oslStartDrawing();
		oslReadKeys();
		tmDrawGrid();
		oslDrawFillRect(0, 0, 480, 272, RGBA(0, 0, 0, 125));
		if (save)
			oslDrawString(10, 40, "Press X (cross) to save your song in the selected slot.");
		else
			oslDrawString(10, 40, "Press X (cross) to load a song from the selected slot.");
		oslDrawString(10, 50, "Press O (circle) to cancel.");
		for (x = 0; x < MAX_SAVE_SLOTS; x++) {
			bzero(strings[x], sizeof(strings[x]));
			bzero(tmp, sizeof(tmp));
			sprintf(tmp, "song%d.tms", x);
			sprintf(strings[x], "%s %s", (option == x) ? "->" : "  ", (empty[x]) ? "EMPTY" : tmp);
			sprintf(mdate[x], "%d/%d/%d %d:%d UTC", songMeta[x].month, songMeta[x].day, songMeta[x].year, songMeta[x].hour, songMeta[x].minute);
			oslDrawString(10, (70+(x*10)), strings[x]);
			if (!empty[x])
				oslDrawString(200, (70+(x*10)), mdate[x]);
		}
		oslDrawString(10, 190, "Press /\\ (triangle) to delete the selected song slot.");
		if ((osl_keys->pressed.up) && (option > 0))
			option--;
		if ((osl_keys->pressed.down) && (option < (MAX_SAVE_SLOTS-1)))
			option++;
		if (osl_keys->pressed.cross) {
			if (empty[option]) {
				if (save) {
					tmWrite(option);
					break;
				}
			}
			else {
				if (save) {
					if (tmOverwriteWarning(option)) {
						tmWrite(option);
						break;
					}
				}
				else {
					tmRead(option);
					break;
				}
			}
		}
		if (osl_keys->pressed.triangle) {
			if (!empty[option]) {
				if (tmDeleteWarning(option)) {
					bzero(tmp, sizeof(tmp));
					sprintf(tmp, "songs/song%d.tms", option);
					remove(tmp);
					empty[option] = TRUE;
				}
			}
		}
		if (osl_keys->pressed.circle)
			break;
		if (osl_keys->pressed.start)
			break;
		oslEndDrawing();
		oslSyncFrame();
	}
	return;
}
예제 #26
0
int main(int argc, char *argp[]){
	// Init More Stuff...
	
	// Initialize Osl
	oslInit(3); // Based on Onelua xD
	
	// Init Crls Functions..
	sceCtrlSetSamplingCycle(0);
	sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
	
	// Init Configs Stuff.
	InitConfig();
	memcpy(menuConfigDefault, &menuConfig, sizeof(menuConfig)); //Sauvegarde pour plus tard
	
	// Init Stuff GU "Video"
	oslInitGfx(OSL_PF_8888, 1);// OSL_PF_5650 Aqui estaba esto.. Cambiado a 8888	
	oslInitConsole();
	oslStartDrawing();
	VideoGuScreenClear();// Check If really its vital
	/* Añadido
	oslIntraFontInit(INTRAFONT_CACHE_ALL | INTRAFONT_STRING_UTF8);
	OSL_FONT * oneFont = oslLoadFontFile("flash0:/font/jpn0.pgf");
	oslIntraFontSetStyle(oneFont, 0.7, RGB(255,255,255), RGBA(0,0,0,0), INTRAFONT_ALIGN_LEFT);
	oslSetFont(oneFont);
	*/
	//Main screen: in VRAM for speed
	Screen.scrBuffer = oslGetUncachedPtr(oslVramMgrAllocBlock(SCR_BUFFER_SIZE));
	Screen.pal = oslGetUncachedPtr(oslVramMgrAllocBlock(256*2));
	//Sub screen: in RAM for mem sparing
	ScreenTemp.scrBuffer = oslGetUncachedPtr(malloc(SCR_BUFFER_SIZE));
	ScreenTemp.pal = NULL;
	bitmap.data   = (unsigned char*)Screen.scrBuffer;
	/* Term of stuff gu */
	
	// Init More Vars..
	u32 nFrame, nDrawnFrames, skip=0, framerate;
	int nbRenderedFramesPerSec, nbVirtualFramesPerSec = 0, lastVCount = 0;
	int frameskip = 0;

	memset(&bitmap, 0, sizeof(bitmap_t));
	bitmap.width  = 256;
	bitmap.height = 192;
	bitmap.depth  = menuConfig.video.renderDepth;
	bitmap.pitch  = 256 * menuConfig.video.renderDepth / 8;

	menuConfig.file.filename[0] = '\0';

	sms.save = 1;

	// Display the menu to load up the ROM
	//	displayMenu();
	menuIsInGame = 0;

	//menuPlusShowMenu();
	MenuPlusAction(MA_LOADROM, "ms0:/Poke_Oro.gbc");

	//Bidouille pour détecter les choses qui ont changé
	MenuOptionsConfigure(-1);
	MenuOptionsConfigure(0);

	VideoGuScreenClear();

	//Système
	SmsInit();
	nFrame = nDrawnFrames = 0;
	menuConfig.video.turbo = menuConfig.video.pause = 0;
	nbRenderedFramesPerSec = 0;
	gblFramerate = gblVirtualFramerate = 0;
	menuUpdateRender = 0;

	//Système
	if (gblMachineType == EM_SMS)
		system_poweron();

	while(1){ // Principal Cycle
		//Pal support
		if (menuConfig.video.country == 1)
			framerate = 50;
		else
			framerate = 60;
		oslSetFramerate(framerate);

		if (menuUpdateRender)
			nDrawnFrames = 0, menuUpdateRender = 0;

		if (gblMachineType == EM_SMS)
			ControlsUpdate();
		else if (gblMachineType == EM_GBC){
			gbe_refresh();
			gbe_updatePad();
		}

		if (osl_quit)
			break;

		//Framerate
		if (menuConfig.video.cpuTime == 2){
			int vcount = osl_vblCount;
			if (!skip)
				nbRenderedFramesPerSec++;
			nbVirtualFramesPerSec++;
			if (vcount / framerate > lastVCount / framerate)			{
				gblFramerate = nbRenderedFramesPerSec;
				gblVirtualFramerate = nbVirtualFramesPerSec;
				nbRenderedFramesPerSec = 0;
				nbVirtualFramesPerSec = 0;
			}
			lastVCount = vcount;
		}

		if (!menuConfig.video.pause){
			if (gblMachineType == EM_SMS){
				system_frame(skip);
				if (menuConfig.sound.turboSound /*== 2*/ || !menuConfig.video.turbo){
					//On peut commencer à jouer le son: tout est initialisé (sinon il faut attendre)
					soundPause = 0;
					if (!menuConfig.sound.perfectSynchro){
						SoundUpdate();
					}
				}
			}
			else if (gblMachineType == EM_GBC){
				//Run one GB frame
				gb_doFrame(skip);
				soundPause = 0;
				if (menuConfig.sound.turboSound /*== 2*/ || !menuConfig.video.turbo)		{
					soundPause = 0;
					if (!menuConfig.sound.perfectSynchro)			{
						snd_render_orig(snd.output, snd.sample_count);
						SoundUpdate();
					}
				}
			}
		}

		if (!skip && menuConfig.video.syncMode == 0){
			//if (gblMachineType == EM_SMS)
			VideoGuUpdate(nDrawnFrames, menuConfig.video.render);
			frameReady = 1;
			nDrawnFrames++;
		}
		oslDrawString(10,10,"Mod By Davis");
		//vsyncAdd = 0;
		//redo:
		if (menuConfig.video.turbo){
			if (!skip){
				oslEndDrawing();
				oslSwapBuffers();
			}
			skip = nFrame % (menuConfig.video.turboSkip + 1);
		}
		else{
			int vsync = 4 /*+ vsyncAdd*/;
			if (menuConfig.video.vsync == 2)
				vsync |= 1;
			/*else if (menuConfig.video.vsync == 1)
				vsync |= 8;*/

			/*if (autoFskip && !skip)
				tmp = oslMeanBenchmarkTestEx(OSL_BENCH_END, 0);*/

			skip = oslSyncFrameEx(oslMinMax(frameskip+1, menuConfig.video.frameskip, menuConfig.video.frameskipMax), menuConfig.video.frameskipMax, vsync);

			/*if (autoFskip && !skip)		{
				//Store the CPU usage (in percent)
				cpuTime = tmp * 6 / 1000;
				oslBenchmarkTest(OSL_BENCH_START);
			}*/
		}

		/*if (autoFskip){
			if (!skip){
				cpuTime = oslMeanBenchmarkTestEx(OSL_BENCH_GET_LAST, 0) * 6 / 1000;
				oslMeanBenchmarkTestEx(OSL_BENCH_START, 0);
				targetFrameskip = skippedFrames;
				skippedFrames = 0;
			}
			else{
				skippedFrames++;
			}
		}*/
		if (!skip && menuConfig.video.syncMode == 1)			{
			//if (gblMachineType == EM_SMS)
			VideoGuUpdate(nDrawnFrames, menuConfig.video.render);
			frameReady = 1;
			nDrawnFrames++;
		}

		nFrame++;
		//Pal
		/*if (menuConfig.video.country == 1 && nFrame % 6 == 0)		{
			if (!skip)
				vsyncAdd = 16;
			goto redo;
		}*/
		//In game, menu not currently shown - WARNING: DONT MOVE THIS, THE MESSAGEBOX CODE RELIES ON menuIsInGame == 2 TO KNOW IF THE GAME IS CURRENTLY RUNNING (or menuIsInGame == 1 = menu is shown)
		menuIsInGame = 2;

		if (menuDisplaySpecialMessage)
			MenuSpecialMessageDisplay();
	} // End Of While
	SmsTerm();
	//SmsEmulate();
	// End Emulate
	SaveMyPlacesFile();
	sceKernelExitGame();

    return 0;
}
예제 #27
0
void Menu(){
    static char message[100] = "";
    static int dialog = OSL_DIALOG_NONE;

    dialog = oslGetDialogType();
    if (dialog){
        oslDrawDialog();
        if (oslGetDialogStatus() == PSP_UTILITY_DIALOG_NONE){
            if (oslDialogGetResult() == OSL_DIALOG_CANCEL)
                sprintf(message, "Cancel");
            else if (dialog == OSL_DIALOG_MESSAGE){
                int button = oslGetDialogButtonPressed();
                if (button == PSP_UTILITY_MSGDIALOG_RESULT_YES)
                    sprintf(message, "You pressed YES");
                else if (button == PSP_UTILITY_MSGDIALOG_RESULT_NO)
                    sprintf(message, "You pressed NO");
                else sprintf(message, "IDK what was pressed");
			}
            oslEndDialog();
        }
    }
    if (dialog == OSL_DIALOG_NONE){
        //oslReadKeys();
        if (osl_pad.held.triangle && osl_pad.held.down){
            runningFlag = 0;
        }else if (osl_pad.pressed.square){
            //oslInitMessageDialog("Test message dialog", 1);
            //memset(message, 0, sizeof(message));
            oslInitNetDialog();
            oslDialogDrawAndWait(OSL_DIALOG_NETCONF);
            HRESULT=oslDialogGetResult();
            if (HRESULT==OSL_DIALOG_CANCEL) {
            	sprintf(message, "Connection canceled(%d)",HRESULT);}
            	else {
            	sprintf(message, "Connection OK(%d)",HRESULT);
    			Connected = 1;
    			showjoypad=1;showfire=1;
    			drawMenu=0;
                snprintf(netbuf,1024,"AT*COMWDG=%d%c",AT_SEQ++,CR);//XY
    			sendto(DroneUdp, netbuf, strlen(netbuf), 0, (struct sockaddr*)&dest, sizeof(dest));
    		    //Connected = oslNetSocketConnect(DroneSck, DRONE_IP, FTP_PORT);//For V1 TCP?
    		    //sprintf(message, "Connect: %d",Connected);
				//HResult = oslNetSocketSend(DroneSck, "TEST", 4);
            }
            oslEndDialog();
            //memset(message, 0, sizeof(message));
        }else if (osl_pad.pressed.start){
			drawMenu=0;
        }else if (osl_pad.pressed.select){
            //oslInitErrorDialog(0x80020001);
            //memset(message, 0, sizeof(message));
			snprintf(netbuf,1024,"AT*REF=%d,%d%c",AT_SEQ++,AT_REF|256,CR);//NO EMERGENCY
			sendto(DroneUdp, netbuf, strlen(netbuf), 0, (struct sockaddr*)&dest, sizeof(dest));
		}else if (osl_pad.held.up && osl_pad.held.cross){
			runningFlag=0;
		}else if (osl_pad.pressed.up){
			if (mscale<1) mscale=mscale+0.05;
		}else if (osl_pad.pressed.down){
			if (mscale>0) mscale=mscale-0.05;
		}else if (osl_pad.pressed.left){
			snprintf(netbuf,1024,"AT*LED=%d,%d,%d,2%c",AT_SEQ++,LedAnim++,LedAnimFreq.i,CR);
			sendto(DroneUdp, netbuf, strlen(netbuf), 0, (struct sockaddr*)&dest, sizeof(dest));
			if (LedAnim == ARDRONE_LED_NB_ANIMATION) LedAnim=0;
			//Drone.AddCmd "AT*LED=", CStr(Seq) & "," & CStr(Single2Long(2)) & ",2" vbcode
		}else if (osl_pad.pressed.right){
			snprintf(netbuf,1024,"AT*ANIM=%d,%d,%d%c",AT_SEQ++,MoveAnim,MAYDAY_TIMEOUT[MoveAnim],CR);
			MoveAnim++;
			sendto(DroneUdp, netbuf, strlen(netbuf), 0, (struct sockaddr*)&dest, sizeof(dest));
			if (MoveAnim == ARDRONE_NB_ANIM_MAYDAY) MoveAnim=0;
		}
        oslDrawString(30, 50, "[] - Connect to ARDrone");
        oslDrawStringf(30, 70, "Left - LED animation %d/%d",LedAnim,ARDRONE_LED_NB_ANIMATION);
        oslDrawStringf(30, 90, "Right - Move animation %d/%d",MoveAnim,ARDRONE_NB_ANIM_MAYDAY);
        oslDrawString(30, 110, "Up/Down Change mov. scale");
        oslDrawString(30, 130, "Select - Emergency cutoff");
        oslDrawString(30, 150, "Start - Exit menu");
        oslDrawString(30, 170, "Up+X - Exit program");

        oslDrawString(30, 200, message);

    }

}
예제 #28
0
void tmHelp(void) {
	oslClearScreen(RGBA(0, 0, 0, 255));
	while (!osl_quit) {
		oslStartDrawing();
		oslReadKeys();
		tmDrawGrid();
		oslDrawFillRect(0, 0, 480, 272, RGBA(0, 0, 0, 125));
		oslDrawString(1, 10, "ToneMatrix is a 16-step drum machine. The X axis represents one");
		oslDrawString(1, 20, "4/4 measure in sixteenth notes, and the Y axis represents eight");
		oslDrawString(1, 30, "different sounds. Select a node on the grid with the D-pad and the");
		oslDrawString(1, 40, "sound will be played in time.");
		oslDrawString(1, 60, "Press O (circle) to stop or resume playing. Press [] (square) to");
		oslDrawString(1, 70, "mute the row the cursor is on. Press /\\ (triangle) to mute every");
		oslDrawString(1, 80, "row except the row the cursor is on. You can mute more than one row");
		oslDrawString(1, 90, "at once.");
		oslDrawString(1, 110, "Press START to use the menu, and use the D-pad to select a menu");
		oslDrawString(1, 120, "item or change a value (like the tempo), and X (cross) to confirm");
		oslDrawString(1, 130, "to confirm your choice.");
		oslDrawString(1, 150, "You can play up to sixteen measures in a row by using the R and L");
		oslDrawString(1, 160, "triggers, or by switching the \"grid\" value in the START menu.");
		oslDrawString(1, 170, "If \"loop all\" is on, then the measures will play one after");
		oslDrawString(1, 180, "another. If it is off, it will only repeat one measure. It is");
		oslDrawString(1, 190, "recommended that you stop playback before editing another grid.");
		oslDrawString(1, 210, "Press SELECT to hide this screen.");
		if (osl_keys->pressed.select)
			break;
		oslEndDrawing();
		oslSyncFrame();
	}
	return;
}
예제 #29
0
파일: main.c 프로젝트: DavisDev/oslib-mod
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Main:
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main(){
    int skip = 0;
    SetupCallbacks();

    initOSLib();
    oslIntraFontInit(INTRAFONT_CACHE_MED);

    //Loads image:
    OSL_IMAGE *bkg = oslLoadImageFilePNG("bkg.png", OSL_IN_RAM | OSL_SWIZZLED, OSL_PF_8888);
    OSL_IMAGE *rect_01 = oslLoadImageFilePNG("rect_01.png", OSL_IN_RAM | OSL_SWIZZLED, OSL_PF_8888);

    //Load fonts:
    OSL_FONT *pgfFont = oslLoadFontFile("flash0:/font/ltn0.pgf");
    oslIntraFontSetStyle(pgfFont, 0.5, RGBA(255,255,255,255), RGBA(0,0,0,0), INTRAFONT_ALIGN_LEFT);

    OSL_FONT *oftFont = oslLoadFontFile("font.oft");
    oslSetTextColor(RGBA(255,255,255,255));
    oslSetBkColor(RGBA(0,0,0,0));

    while(runningFlag && !osl_quit){
        if (!skip){
            oslStartDrawing();
            oslDrawImageXY(bkg, 0, 0);

            oslDrawImageXY(rect_01, 50, 50);
            oslSetFont(pgfFont);
            oslDrawString(55, 55, "pgf on alpha image");
            oslSetFont(oftFont);
            oslDrawString(55, 70, "oft on alpha image");

            oslDrawFillRect(30, 150, 200, 250, RGB(150, 150, 150));
            oslSetFont(pgfFont);
            oslDrawString(35, 155, "pgf on rect");
            oslSetFont(oftFont);
            oslDrawString(35, 170, "oft on rect");

            oslDrawFillRect(300, 150, 400, 250, RGB(100, 100, 100));
            oslSetFont(pgfFont);
            oslDrawString(305, 155, "pgf on rect");
            oslSetFont(oftFont);
            oslDrawString(305, 170, "oft on rect");

            oslDrawGradientRect(300, 20, 430, 120, RGBA(100, 100, 100, 100),RGBA(100, 100, 100, 100), RGBA(200, 200, 200, 100), RGBA(200, 200, 200, 100));
            oslSetFont(pgfFont);
            oslDrawString(305, 25, "pgf on gradient rect");
            oslSetFont(oftFont);
            oslDrawString(305, 40, "oft on gradient rect");

            oslEndDrawing();
        }
        oslEndFrame();
        skip = oslSyncFrame();
    }
    //Quit OSL:
    oslEndGfx();
    oslQuit();

    sceKernelExitGame();
    return 0;

}