Пример #1
0
void pgInit()
{
    PSP2_Video_Init();

	//sceDisplaySetMode(0,SCREEN_WIDTH,SCREEN_HEIGHT);
	pgScreenFrame(0,0);
}
Пример #2
0
int xmain(int ra)
{
	SetupCallbacks();

	pgInit();
	pgScreenFrame(1, 0);
	pgFillvram(0);

	mainImpl();
	
	pgWaitVn(500);
	sceKernelExitGame();

	return 0;
}
Пример #3
0
void NewPrompter() {
	char* buttons[MAX_CONTROL];
	char tempstring[MAX_CONTROL][MAX_TEMP_STRING];
	char* tempkeystring[MAX_CONTROL+2];
	tempkeystring[0] = "WEAPON";
	tempkeystring[1] = "ENTER";
	tempkeystring[2] = "ESC";
	tempkeystring[3] = "USE";
	tempkeystring[4] = "MOVE";
	tempkeystring[5] = "MAP";
	tempkeystring[6] = "RUN";
	tempkeystring[7] = "FIRE";
	tempkeystring[8] = "M_LEFT";
	tempkeystring[9] = "M_RIGHT";
    //tempkeystring[10] = "222";
    //tempkeystring[11] = "266";
    //tempkeystring[12] = "333";
	buttons[0] = "ANALOG   ";
	buttons[1] = "START    ";
	buttons[2] = "SELECT   ";
	buttons[3] = "CROSS    ";
	buttons[4] = "DPAD     ";
	buttons[5] = "TRIANGLE ";
	buttons[6] = "SQUARE   ";
	buttons[7] = "CIRCLE   ";
	buttons[8] = "L_TRIG   ";
	buttons[9] = "R_TRIG   ";
	//buttons[10] = "CPU_CLOCK";
	
	control_bef_ctl = 0;
	pgScreenFrame(2,0);
	pgFillvram(0);
	pgScreenFlipV();
	while (1) {
	    pgFillvram(0);
	    int i = 0;
	    int die = 0;
	    int col;
	    for (i=0; i<MAX_CONTROL; i++) {
	    
		if (d_controls[i] == CKEY_WEAPON) die = 0;
		else if (d_controls[i] == KEY_ENTER) die = 1;
		else if (d_controls[i] == KEY_ESCAPE) die = 2;
		else if (d_controls[i] == ' ') die = 3;
		else if (d_controls[i] == CKEY_MOVE) die = 4;
		else if (d_controls[i] == KEY_TAB) die = 5;
		else if (d_controls[i] == KEY_RSHIFT) die = 6;
		else if (d_controls[i] == KEY_RCTRL) die = 7;
		else if (d_controls[i] == ',') die = 8;
		else if (d_controls[i] == '.') die = 9;
		else if (d_controls[i] == 222) die = 10;
		else if (d_controls[i] == 266) die = 11;
		else if (d_controls[i] == 333) die = 12;
	
		col = rgb2col(255,255,255);
	
		if (i==d_clist_curpos) {
		    col = rgb2col(255,0,0);
		}
	
		sprintf(tempstring[i], "%s = %s",buttons[i],tempkeystring[die]);
        mh_print(5, ((i + 2) * 20), tempstring[i], col, 0, 0);
	    }
	    if (d_clist_curpos != 10) {
	        mh_print(5,255,"X: Exit | O: Change | Triangle: Save To File",rgb2col(50,255,50),0,0);
	    }
	    else {
	        mh_print(5,255,"X: Exit | O: Increment | Square: Decrement | Triangle: Save To File",rgb2col(50,255,50),0,0);
	    }
	    pgScreenFlipV();
	
	    if (control_bef_ctl == 0) {
	        Read_Key2();
	        pgWaitV();
	    }
	    else {
	        unsigned long ankey;
	        while (1) {
	    	    ankey = Read_Key3();
	    	if (ankey != 0) break;
	    	    pgWaitV();
	    	}
	    	new_pad = old_pad = now_pad = ankey;
	    	control_bef_ctl = 0;
	    }
	    
	   
	    if (new_pad & SCE_CTRL_UP) {
		if (d_clist_curpos > 0) {
			d_clist_curpos--;
			if (d_clist_curpos < d_clist_start) { d_clist_start = d_clist_curpos; }
		}
	    }
	    else if (new_pad & SCE_CTRL_DOWN) {
		if (d_clist_curpos < (MAX_CONTROL-1)) {
			d_clist_curpos++;
			if (d_clist_curpos >= (d_clist_start+MAX_CONTROL-1)) { d_clist_start++; }
		}
	    }
	
	    else if (new_pad & SCE_CTRL_CIRCLE) {
	    if (d_clist_curpos != 10) {
	        ButtonChange(tempstring, buttons, tempkeystring);
	    }
	    else {
	        change_cpu_clock(1);  // increment
	    }
	    }
	
	    else if (new_pad & SCE_CTRL_TRIANGLE) {
	    SaveToFile(tempstring, buttons, tempkeystring);
	    }
	    
	    else if (new_pad & SCE_CTRL_SQUARE) {
	    if (d_clist_curpos == 10)
	        change_cpu_clock(0); // decrement
	    }
	    
	    else if (new_pad & SCE_CTRL_CROSS) {
	    break;
	    }
	}
	
}
Пример #4
0
////////////////////////////////////////////////////////////////////////////////////
// This is just a quick and easy procedure to wait for a PSP to join, the following
// is what is done in Lumines:
//
//   - Wait for a PSP to join
//   - Add the PSP to the list of machines available
//   - Wait for the user to select a PSP
//   - Call sceMatchingSelectTarget
//   - The other PSP will receive MATCHING_SELECTED event
//   - The other PSP displays a message to accept or cancel
//   - If accepted the other PSP calls sceMatchingSelectTarget
//   - The first PSP receives MATCHING_ESTABLISHED
// 
// In lumines they then close the connection and start a new adhoc connection
// with just those two machines in it.
///////////////////////////////////////////////////////////////////////////////////
int adhocSelect(void)
{
	SceCtrlData m_PspPad;
	int err = 0;
	char mac[10];
	char name[256];
	int waitAccept = 0;
	int currentState = PSP_LISTING;
	int oldButtons = 0;
	char tempStr[100];
	char str[256];
	
	sceDisplaySetMode( 0, SCREEN_WIDTH, SCREEN_HEIGHT );
	sceDisplaySetFrameBuf( (char*)VRAM_ADDR, 512, 1, 1 );
	pgFillAllvram(0);pgScreenFrame(2,0);

	for(;;)
	{
		sceCtrlReadBufferPositive(&m_PspPad, 1);
		//pspDebugScreenSetTextColor(0xFFFF);

		switch(currentState)
		{
			case PSP_LISTING:
			{
				//pspDebugScreenInit();
				//pspDebugScreenPrintf("Select a server to connect to, or triangle to return\n\n\n");
				pgFillAllvram(0);pgScreenFrame(2,0);
				mh_print(0,0,"Select a server to connect to, or triangle to return",0xFFFF);
				
				DisplayPspList();
				
				pgScreenFlipV();

				g_Server = 0;

				if(m_PspPad.Buttons != oldButtons)
				{
					if(m_PspPad.Buttons & PSP_CTRL_UP)
					{
						UpList();
					}

					if(m_PspPad.Buttons & PSP_CTRL_DOWN)
					{
						DownList();
					}

					if(m_PspPad.Buttons & PSP_CTRL_CROSS)
					{
						if(GetPspEntry(mac, name) > 0)
						{
							currentState = PSP_SELECTING;
							sceNetAdhocMatchingSelectTarget(matchingId, mac, 0, 0);
						}
					}

					if(m_PspPad.Buttons & PSP_CTRL_TRIANGLE)
						return -1;
				}		
				if(matchChanged)
				{
					if(g_matchEvent == MATCHING_SELECTED)
					{
						memcpy(mac, g_mac, 6);
						strcpy(name, g_matchOptData);
						currentState = PSP_SELECTED;
					}
				}
				break;
			}
			case PSP_SELECTING:
			{
				//pspDebugScreenInit();
				pgFillAllvram(0);pgScreenFrame(2,0);				
				
				sceNetEtherNtostr(mac, tempStr);
				//printf("Waiting for %s to accept the connection\nTo cancel press O\n", tempStr);
				sprintf(str,"Waiting for %s to accept the connection\nTo cancel press O\n", tempStr);
				mh_print(0,0,str,0xFFFF);
				pgScreenFlipV();

				if(m_PspPad.Buttons != oldButtons)
				{
					if(m_PspPad.Buttons & PSP_CTRL_CIRCLE)
					{
						sceNetAdhocMatchingCancelTarget(matchingId, mac);
						currentState = PSP_LISTING;
					}
				}

				if(matchChanged)
				{
					if(g_matchEvent == MATCHING_SELECTED)
					{
						sceNetAdhocMatchingCancelTarget(matchingId, mac);
					}
					else if(g_matchEvent == MATCHING_ESTABLISHED)
					{
						currentState = PSP_ESTABLISHED;
					}
					else if(g_matchEvent == MATCHING_REJECTED)
					{
						currentState = PSP_LISTING;
					}
				}
				break;
			}
			case PSP_SELECTED:
			{
				g_Server = 1;

				//pspDebugScreenInit();
				pgFillAllvram(0);pgScreenFrame(2,0);
				
				sceNetEtherNtostr(mac, tempStr);
				sprintf(str,"%s has requested a connection\nTo accept the connection press X, to cancel press O\n", tempStr);
				mh_print(0,0,str,0xFFFF);
				pgScreenFlipV();

				if(m_PspPad.Buttons != oldButtons)
				{
					if(m_PspPad.Buttons & PSP_CTRL_CIRCLE)
					{
						sceNetAdhocMatchingCancelTarget(matchingId, mac);
						currentState = PSP_LISTING;
					}
					if(m_PspPad.Buttons & PSP_CTRL_CROSS)
					{
						sceNetAdhocMatchingSelectTarget(matchingId, mac, 0, 0);
						currentState = PSP_WAIT_EST;
					}
				}

				if(matchChanged)
				{
					if(g_matchEvent == MATCHING_CANCELED)
					{
						currentState = PSP_LISTING;
					}
				}
				break;
			}
			case PSP_WAIT_EST:
			{
				if(matchChanged)
				{
					if(g_matchEvent == MATCHING_ESTABLISHED)
					{
						currentState = PSP_ESTABLISHED;
					}
				}
				break;
			}
		}

		matchChanged = 0;
		oldButtons = m_PspPad.Buttons;

		if(currentState == PSP_ESTABLISHED)
			break;

		sceDisplayWaitVblankStart();
	}

	char macAddr[10];
	char *tempMac;
	if(g_Server)
	{
		sceWlanGetEtherAddr(macAddr);
		tempMac = macAddr;
	}
	else
	{
		tempMac = mac;
	}

	sceNetEtherNtostr(tempMac, tempStr);

	char ssid[10];
	sprintf(ssid, "%c%c%c%c%c%c", tempStr[9], tempStr[10], tempStr[12], tempStr[13], 
			tempStr[15], tempStr[16]);
	adhocReconnect(ssid);

	// We only get here if both PSP's have agreed to connect
	//pspDebugScreenInit();
	//pspDebugScreenPrintf("Connected\n");
	pgFillAllvram(0);pgScreenFrame(2,0);
	mh_print(0,0,"Connected",0xFFFF);
	pgScreenFlipV();

	return 0;
}
Пример #5
0
int psp_initadhocgame(void){
	int retval;
	//testing net stuff	
	//pspDebugScreenInit();
		
	sprintf(str_id,"%s\/%s",os9x_nickname,shortrom_filename);
			
	if((adhocInit(str_id) >= 0) && (adhocSelect() >=0)) { //init adhoc		
		unsigned int length;
		uint8 *buffer;
		int err = 0;
		int i=0;
		if (g_Server) os9x_conId = 1;
		else os9x_conId = 2;
		//buffer=(uint8*)malloc(256);
		//sceKernelDelayThread(1000000); //wait
		//pspDebugScreenInit();
		
		if (os9x_conId==1) { //server
			//send settings			is now done in psp.cpp	
			/*save_buffer_settings(buffer);			
			sceKernelDelayThread(3000000); //wait
			
			printf("Sending settings data to the client\n");
			err = adhocSendRecvAck(buffer, 256);		
			if (!err) printf("Done sending data\n");
			else {
					printf("Error %d!",err);					
					retval=-2;					
					sceKernelDelayThread(1000000); //wait
			}*/
			//server is pl1
			os9x_netpadindex=0;
		} else { //client
			/*int size = 0;
			
			// receive the settings data
			printf("Waiting for settings data\n");
			length = 256;
			err = adhocRecvSendAck(buffer, &length);			
			if (!err) {
				printf("Received data from server %d bytes\n",length);				
				load_buffer_settings(buffer);
		  } else {
					printf("Error %d!",err);					
					retval=-3;
					sceKernelDelayThread(1000000); //wait
			}*/
			//client is pl2
			os9x_netpadindex=1;
		}
		retval=0;
		//free(buffer);			
		
	} else retval=-1;
	
	sceDisplaySetMode( 0, SCREEN_WIDTH, SCREEN_HEIGHT );
	sceDisplaySetFrameBuf( (char*)VRAM_ADDR, 512, 1, 1 );
	pgScreenFrame(2,0);		
	
	return retval;
}
Пример #6
0
int main(int argc, char** argv)
{
#ifdef USE_DEBUGNET
    int ret = debugNetInit("255.255.255.255", 18194, DEBUG);
    printf("debugNetInit: %d", ret);
#endif

    printf("DOOM started\n");

    setbuf(stdout, NULL);

    int res = scePowerSetArmClockFrequency(50);
    if (res != 0x0)
    {
        printf("scePowerSetArmClockFrequency failed! (0x%08x) (Normal if not using PSM Unity 1.06. No clock speed change for you.)\n", res);
    }

    myargc = 0;
    myargv = 0;

    doomwaddir = PSP2_DIR("Documents/");
    strcpy_s(doomwaddir2, 256, doomwaddir);
    strcat(doomwaddir2, "WADS/");

    printf("WAD folder: %s\n", doomwaddir2);

	//pspAudioInit();
	//pspAudioSetChannelCallback(0, (void *)&sound_callback);

	//_DisableFPUExceptions();
//	pspDebugScreenInit();

	//sceCtrlSetSamplingCycle(0);

	//int result = sceCtrlSetSamplingMode(PSP2_CTRL_MODE_ANALOG);
 //   if (result < 0)
 //   {
 //       printf("sceCtrlSetSamplingMode : 0x%x", result);
 //   }

	//SetupCallbacks();
        pgInit();
        pgScreenFrame(2,0);
        pgFillvram(0);

    Get_DirList(doomwaddir2);
    dlist_start  = 0;
    dlist_curpos = 0;
    now_depth    = 0;

while(1) {
    Draw_All();
switch(Control()) {
		case 1:
			Get_DirList(doomwaddir2);
			break;
		case 2:
                        pgFillvram(0);
                        strcpy_s(target, 264, doomwaddir2);
                        strcat(target, dlist[dlist_curpos].name);

                        pgScreenFlipV();
                        //pspDebugScreenInit();

    D_DoomMain (); 
        }
    }    

    return 0;

}
Пример #7
0
void pgInit()
{
	sceDisplaySetMode(0,SCREEN_WIDTH,SCREEN_HEIGHT);
	pgScreenFrame(0,0);
}