Exemplo n.º 1
0
static void MenuButtonHandler(unsigned char MsgOptions)
{
  tMessage Msg;
  
  switch (MsgOptions)
  {
  case MENU_BUTTON_OPTION_EXIT:

    IdleUpdateHandler();
    break;

  case MENU_BUTTON_OPTION_TOGGLE_BLUETOOTH:

    if (BluetoothState() != Initializing)
      SendMessage(&Msg, RadioOn() ? TurnRadioOffMsg : TurnRadioOnMsg, MSG_OPT_NONE);
    break;

  case MENU_BUTTON_OPTION_DISPLAY_SECONDS:
    ToggleProperty(PROP_TIME_SECOND);
    MenuModeHandler(0);
    break;
    
  case MENU_BUTTON_OPTION_TOGGLE_LINK_ALARM:
    ToggleProperty(PROP_DISABLE_LINK_ALARM);
    MenuModeHandler(0);
    break;

  case MENU_BUTTON_OPTION_INVERT_DISPLAY:
    ToggleProperty(PROP_INVERT_DISPLAY);
    MenuModeHandler(0);
    break;

  case MENU_BUTTON_OPTION_MENU1:
    break;
  
  case MENU_BUTTON_OPTION_TOGGLE_RST_NMI_PIN:
    ToggleProperty(PROP_RSTNMI);
    ConfigResetPin(GetProperty(PROP_RSTNMI));
    MenuModeHandler(0);
    break;

  case MENU_BUTTON_OPTION_TOGGLE_SERIAL_SBW_GND:
    ToggleSerialGndSbw();
    MenuModeHandler(0);
    break;
    
  case MENU_BUTTON_OPTION_TOGGLE_ENABLE_CHARGING:
    ToggleCharging();
    MenuModeHandler(0);
    break;
    
  case MENU_BUTTON_OPTION_ENTER_BOOTLOADER_MODE:
    EnterBootloader();
    break;

  default:
    break;
  }
}
Exemplo n.º 2
0
static void MenuButtonHandler(unsigned char MsgOptions)
{
  tMessage Msg;
  
  switch (MsgOptions)
  {
  case MENU_BUTTON_OPTION_EXIT:

    IdleUpdateHandler();
    break;

  case MENU_BUTTON_OPTION_TOGGLE_BLUETOOTH:

    if (BluetoothState() != Initializing)
      SendMessage(&Msg, RadioOn() ? TurnRadioOffMsg : TurnRadioOnMsg, MSG_OPT_NONE);
    break;

  case MENU_BUTTON_OPTION_DISPLAY_SECONDS:
    ToggleProperty(PROP_TIME_SECOND);
    MenuModeHandler(0);
    break;
    
  case MENU_BUTTON_OPTION_TOGGLE_LINK_ALARM:
    LinkAlarmEnable = !LinkAlarmEnable;
    MenuModeHandler(0);
    break;

  case MENU_BUTTON_OPTION_INVERT_DISPLAY:
    ToggleProperty(PROP_INVERT_DISPLAY);
    MenuModeHandler(0);
    break;

  case MENU_BUTTON_OPTION_TOGGLE_RST_NMI_PIN:
    if (RESET_PIN) {SET_RESET_PIN_RST();}
    else {SET_RESET_PIN_NMI();}
    MenuModeHandler(0);
    break;

  case MENU_BUTTON_OPTION_TOGGLE_SERIAL_SBW_GND:
    ToggleSerialGndSbw();
    MenuModeHandler(0);
    break;
    
  case MENU_BUTTON_OPTION_TOGGLE_ENABLE_CHARGING:
    ToggleCharging();
//    SendMessage(&Msg, AccelMsg, 0); //test accel
    MenuModeHandler(0);
    break;
    
  case MENU_BUTTON_OPTION_ENTER_BOOTLOADER_MODE:
    EnterBootloader();
    break;

  case MENU_BUTTON_OPTION_TEST:
  
    SetupMessageWithBuffer(&Msg, SetVibrateMode, MSG_OPT_NONE);
    if (Msg.pBuffer != NULL)
    {
      *(tSetVibrateModePayload *)Msg.pBuffer = TestTone;
      RouteMsg(&Msg);
    }
    // test accelemeter MSG_OPT_ACCEL_ENABLE
//    SendMessage(&Msg, AccelMsg, 1);
    break;

  default:
    break;
  }
}
Exemplo n.º 3
0
Arquivo: main.c Projeto: jmp-no/c64fc
int main(int argc, char **argv) {
	if( argc != 2 && argc != 3 ) {
		printf( "Usage: c64 <command> [filename]\n" );
		printf( "Commands:\n" );
		printf( "     upload <filename>      - Uploads CRT image to C64FC\n" );
		printf( "     download <filename>    - Downloads image from C64FC (not implemented)\n");
		printf( "     reset                  - Resets the C64\n" );
		printf( "     clear                  - Clears the entire C64FC, writes 0x0 to every address\n");
		printf( "     hexdump                - Prints a hexdump of the entire cart\n");
		printf( "     bootloader             - Enters bootloader mode on cart\n");
		printf( "     ramsize                - Prints your EEPROM size\n");
		printf( "     chardump <fps>         - Takes stdout from pipe and dump it on screen\n");
		return( 1 );
	}

	if( OpenDevice() ) {
		printf( "C64FC not found\n" );
		return( 1 );
	}





	if( (strcasecmp( argv[1], "reset" ) == 0) && (argc == 2) ) {
		/* 
		 * Issues a Reset of the C64 
		 */
		Reset();


	} else 	if( (strcasecmp( argv[1], "bootloader" ) == 0) && (argc == 2) ) {
		/*
		 * Makes the cart enter bootloader mode, this mode needs a power cycle of the cart to exit from
		 */
		EnterBootloader();	


	} else if( (strcasecmp( argv[1], "upload" ) == 0) && (argc == 3) ) {
		/*
		 * Uploads data to the cart
		 */
		int skip = 0;
		FILE *fp = fopen( argv[2], "rb" );
		if( !fp ) {
			printf( "Can't open input file for reading\n" );
			return( 1 );
		}
		fseek( fp, 0L, SEEK_END );
		int len = ftell( fp );
		fseek( fp, 0L, SEEK_SET );
		unsigned char *array = malloc( len );
		fread( array, len, 1, fp );
		fclose( fp );
		if( array[0] == 'C' && array[1] == '6' && array[2] == '4' ) {
			skip = 80;
		}
		printf( "Sending data (%d bytes)..\n", len-skip );
		WriteData( 0, array+skip, len-skip );
		if( len-skip >= 8192 ) {
			Set16KMode();
		} else {
			Set8KMode();
		}
		printf( "Issuing reset..\n" );
		Reset();


	} else 	if( (strcasecmp( argv[1], "clear" ) == 0) && (argc == 2) ) {
		/*
		 * Clears the content of the entire C64FC
		 */



	} else if ((strcasecmp( argv[1], "fubar" ) == 0) && (argc == 2)) {
		/* 
		 * Runars test function
		 * Actually.. does nothing more than return fubar in hex to the user... :)
		 */
		char buff[10];
		int len = getFubar(buff);
		printf("getFubar: %s(%d)\n", buff, len);
		hexdump(0, buff, 10);

	} else if ((strcasecmp( argv[1], "hexdump" ) == 0) && (argc == 2)) {
		/* 
		 * Make a hexdump of the current register in the cart
		 */
		char buff[128];
		printf("Hexdump of cart:\n");
		int i;
		for (i = 0; i < 0x3FFF; i += 128) {
			memset(buff, 0x0, 128);
			int len = getData(i, buff,128);
			//printf("getData: %d(%d)\n", i, len);
			hexdump(i, buff, 128);
			//printf("\n");
		}

	} else if ((strcasecmp( argv[1], "ramsize" ) == 0) && (argc == 2)) {
		/* 
		 * Check if your cart is 8k or 16k..
		 * .. Thats it.. :) 
		 */
		unsigned int size = GetRamSize();
		printf("Your RAM is a %dkb chip\n", size);


	} else {
		/* 
		 * Command not understood... yea yea... 
		 */
		printf( "WHAT? WHAT\n" );
		return( 1 );
	}


	CloseDevice();
	return( 0 );

}