Exemplo n.º 1
0
void main_state_load(const char *filename)
{

    if (filename != NULL)
        savestates_select_filename(filename);

    controllerCommand(0, StopRumble);
    controllerCommand(1, StopRumble);
    controllerCommand(2, StopRumble);
    controllerCommand(3, StopRumble);

    savestates_job |= LOADSTATE;
}
Exemplo n.º 2
0
void main_state_load(const char *filename)
{
    static unsigned char StopRumble[6] = {0x23, 0x01, 0x03, 0xc0, 0x1b, 0x00};

    if (filename != NULL)
        savestates_select_filename(filename);

    controllerCommand(0, StopRumble);
    controllerCommand(1, StopRumble);
    controllerCommand(2, StopRumble);
    controllerCommand(3, StopRumble);

    savestates_job |= LOADSTATE;
}
/*************************************************************************
Function: main()
**************************************************************************/
int main(void){
	init_wyvern();
	LED_green_on();
	LED_ucgreen_on();
	char input;
	menuScreen = 'a';
	for( ; ; ){
		printMenu();
		input = '0';
		outgoing.command = input;
		if(DataInReceiveBuffer()){
			input = ReceiveByte();
		}
		getJoystick();
		controllerCommand(input);
		controllerTransmit();
		_delay_ms(5);
	if(incoming.battery < 100){
			LED_red_toggle();
			LED_ucred_toggle();
			LED_blue_toggle();
			LED_yellow_toggle();
			LED_green_toggle();
		}
	}
	return 0;
}
Exemplo n.º 4
0
void update_pif_write()
{
   int i=0, channel=0;
#ifdef DEBUG_PIF
   printf("write\n");
   print_pif();
#endif
   if (PIF_RAMb[0x3F] > 1)
     {
	switch (PIF_RAMb[0x3F])
	  {
	   case 0x02:
	     for (i=0; i<sizeof(pif2_lut)/32; i++)
	       {
		  if (!memcmp(PIF_RAMb + 64-2*8, pif2_lut[i][0], 16))
		    {
		       memcpy(PIF_RAMb + 64-2*8, pif2_lut[i][1], 16);
		       return;
		    }
	       }
	     printf("unknown pif2 code:\n");
	     for (i=(64-2*8)/8; i<(64/8); i++)
	       printf("%x %x %x %x | %x %x %x %x\n",
		      PIF_RAMb[i*8+0], PIF_RAMb[i*8+1],PIF_RAMb[i*8+2], PIF_RAMb[i*8+3],
		      PIF_RAMb[i*8+4], PIF_RAMb[i*8+5],PIF_RAMb[i*8+6], PIF_RAMb[i*8+7]);
	     break;
	   case 0x08:
	     PIF_RAMb[0x3F] = 0;
	     break;
	   default:
	     printf("error in update_pif_write : %x\n", PIF_RAMb[0x3F]);
	  }
	return;
     }
   while (i<0x40)
     {
	switch(PIF_RAMb[i])
	  {
	   case 0x00:
	     channel++;
	     if (channel > 6) i=0x40;
	     break;
	   case 0xFF:
	     break;
	   default:

	     if (!(PIF_RAMb[i] & 0xC0))
	       {
		  if (channel < 4)
		    {
		       if (Controls[channel].Present && 
			   Controls[channel].RawData)
			 controllerCommand(channel, &PIF_RAMb[i]);
		       else
			 internal_ControllerCommand(channel, &PIF_RAMb[i]);
		    }
		  else if (channel == 4)
		    EepromCommand(&PIF_RAMb[i]);
		  else
		    printf("channel >= 4 in update_pif_write\n");
		  i += PIF_RAMb[i] + (PIF_RAMb[(i+1)] & 0x3F) + 1;
		  channel++;
	       }
	     else
	       i=0x40; 
	  }
	i++;
     }
 
   //PIF_RAMb[0x3F] = 0;
   controllerCommand(-1, NULL);
#ifdef DEBUG_PIF
   print_pif();
#endif
}
Exemplo n.º 5
0
void internal_ControllerCommand(int Control, BYTE *Command)
{
   switch (Command[2])
     {
      case 0x00: // check
      case 0xFF:
	if ((Command[1] & 0x80))
	  break;
	if (Controls[Control].Present)
	  {
	     Command[3] = 0x05;
	     Command[4] = 0x00;
	     switch(Controls[Control].Plugin)
	       {
		case PLUGIN_MEMPAK:
		  Command[5] = 1;
		  break;
		case PLUGIN_RAW:
		  Command[5] = 1;
		  break;
		default:
		  Command[5] = 0;
		  break;
	       }
	  }
	else
	  Command[1] |= 0x80;
	break;
      case 0x01:
	if (!Controls[Control].Present)
	  Command[1] |= 0x80;
	break;
      case 0x02: // read controller pack
	if (Controls[Control].Present)
	  {
	     switch(Controls[Control].Plugin)
	       {
		case PLUGIN_MEMPAK:
		    {
		       int address = (Command[3] << 8) | Command[4];
		       if (address == 0x8001)
			 {
			    memset(&Command[5], 0, 0x20);
			    Command[0x25] = mempack_crc(&Command[5]);
			 }
		       else
			 {
			    address &= 0xFFE0;
			    if (address <= 0x7FE0)
			      {
				 char *filename;
				 FILE *f;
				 filename = malloc(strlen(get_savespath())+
						   strlen(ROM_SETTINGS.goodname)+4+1);
				 strcpy(filename, get_savespath());
				 strcat(filename, ROM_SETTINGS.goodname);
				 if (UseSave == 1)
                 strcat(filename, ".mpk");
                 else
                 strcat(filename,".net");
				 f = fopen(filename, "rb");
				 if (f)
				   {
				      fread(mempack[0], 1, 0x8000, f);
				      fread(mempack[1], 1, 0x8000, f);
				      fread(mempack[2], 1, 0x8000, f);
				      fread(mempack[3], 1, 0x8000, f);
				      fclose(f);
				   }
				 else format_mempacks();
				 free(filename);
				 memcpy(&Command[5], &mempack[Control][address], 0x20);
			      }
			    else
			      {
				 memset(&Command[5], 0, 0x20);
			      }
			    Command[0x25] = mempack_crc(&Command[5]);
			 }
		    }
		  break;
		case PLUGIN_RAW:
		  if (controllerCommand) controllerCommand(Control, Command);
		  break;
		default:
		  memset(&Command[5], 0, 0x20);
		  Command[0x25] = 0;
	       }
	  }
	else
	  Command[1] |= 0x80;
	break;
      case 0x03: // write controller pack
	if (Controls[Control].Present)
	  {
	     switch(Controls[Control].Plugin)
	       {
		case PLUGIN_MEMPAK:
		    {
		       int address = (Command[3] << 8) | Command[4];
		       if (address == 0x8001) 
			 Command[0x25] = mempack_crc(&Command[5]);
		       else
			 {
			    address &= 0xFFE0;
			    if (address <= 0x7FE0)
			      {
				 char *filename;
				 FILE *f;
				 filename = malloc(strlen(get_savespath())+
						   strlen(ROM_SETTINGS.goodname)+4+1);
				 strcpy(filename, get_savespath());
				 strcat(filename, ROM_SETTINGS.goodname);
				 if (UseSave == 1)
                 strcat(filename, ".mpk");
                 else
                 strcat(filename,".net");
				 f = fopen(filename, "rb");
				 if (f)
				   {
				      fread(mempack[0], 1, 0x8000, f);
				      fread(mempack[1], 1, 0x8000, f);
				      fread(mempack[2], 1, 0x8000, f);
				      fread(mempack[3], 1, 0x8000, f);
				      fclose(f);
				   }
				 else format_mempacks();
				 memcpy(&mempack[Control][address], &Command[5], 0x20);
				 f = fopen(filename, "wb");
				 fwrite(mempack[0], 1, 0x8000, f);
				 fwrite(mempack[1], 1, 0x8000, f);
				 fwrite(mempack[2], 1, 0x8000, f);
				 fwrite(mempack[3], 1, 0x8000, f);
				 fclose(f);
				 free(filename);
			      }
			    Command[0x25] = mempack_crc(&Command[5]);
			 }
		    }
		  break;
		case PLUGIN_RAW:
		  if (controllerCommand) controllerCommand(Control, Command);
		  break;
		default:
		  Command[0x25] = mempack_crc(&Command[5]);
	       }
	  }
	else
	  Command[1] |= 0x80;
	break;
     }
}