Beispiel #1
0
void Handle_Home(int disable_screenshot)
{
	if (CFG.home == CFG_HOME_EXIT) {
		Con_Clear();
		printf("\n");
		printf_("Exiting...");
		__console_flush(0);
		Sys_Exit();
	} else if (CFG.home == CFG_HOME_SCRSHOT) {
		__console_flush(0);
		Make_ScreenShot();
		if (disable_screenshot)	CFG.home = CFG_HOME_EXIT;
	} else if (CFG.home == CFG_HOME_HBC) {
		Con_Clear();
		printf("\n");
		printf_("HBC...");
		__console_flush(0);
		Sys_HBC();
	} else if (CFG.home == CFG_HOME_REBOOT) { 
		Con_Clear();
		Restart();
	} else {
		// Priiloader magic words, and channels
		if ((CFG.home & 0xFF) < 'a') {
			// upper case final letter implies channel
			Con_Clear();
			Sys_Channel(CFG.home);
		} else {
			// lower case final letter implies magic word
			Con_Clear();
			*(vu32*)0x8132FFFB = CFG.home;
			Restart();
		}
	}
}
Beispiel #2
0
void input_t::loop(){
	SDL_PumpEvents();
	SDL_Event event;
	input_keyboard_map_t *keyboard_map = nullptr;
	try{
		keyboard_map = (input_keyboard_map_t*)find_pointer(keyboard_map_id);
		throw_if_nullptr(keyboard_map);
	}catch(std::logic_error &e){
		return;
	}
	keyboard_map->array.data_lock.lock();
	while(SDL_PollEvent(&event)){
		switch(event.type){
		case SDL_KEYUP:
			printf_("DEBUG: SDL_KEYUP was received\n", PRINTF_DEBUG);
			keyboard_map->keyboard_map[entry_from_scancode(event.key.keysym.scancode)] = false;
			break;
		case SDL_KEYDOWN:
			printf_("DEBUG: SDL_KEYDOWN was received\n", PRINTF_DEBUG);
			keyboard_map->keyboard_map[entry_from_scancode(event.key.keysym.scancode)] = true;
			break;
		default:
			// not supported yet, but this should be enough for simple control
			break;
		}
	}
	keyboard_to_signal();
	keyboard_map->array.data_lock.unlock();
}
Beispiel #3
0
void __WBFS_Spinner(s32 x, s32 max)
{
	static time_t start;
	static u32 expected;

	f32 percent, size;
	u32 d, h, m, s;

	/* First time */
	if (!x) {
		start    = time(0);
		expected = 300;
	}

	/* Elapsed time */
	d = time(0) - start;

	if (x != max) {
		/* Expected time */
		if (d && x)
			expected = (expected * 3 + d * max / x) / 4;

		/* Remaining time */
		d = (expected > d) ? (expected - d) : 1;
	}

	/* Calculate time values */
	h =  d / 3600;
	m = (d / 60) % 60;
	s =  d % 60;

	/* Calculate percentage/size */
	percent = (x * 100.0) / max;
	if (hdd) {
		size = (hdd->wii_sec_sz / GB_SIZE) * max;
	} else {
		size = (0x8000 / GB_SIZE) * max;
	}

	Con_ClearLine();

	/* Show progress */
	if (x != max) {
		printf_(gt("%.2f%% of %.2fGB (%c) ETA: %d:%02d:%02d"),
				percent, size, "/-\\|"[(x / 10) % 4], h, m, s);
		printf("\r");
		fflush(stdout);
	} else {
		printf_(gt("%.2fGB copied in %d:%02d:%02d"), size, h, m, s);
		printf("  \n");
	}

	__console_flush(1);
}
Beispiel #4
0
void child1_thread()
{
  while (1)
  {
    char c = uart_read();
    printf_("char >%c<\n", c); 

    led_on(LED_1);
    printf_("child 1 thread 1111111\n");
    led_off(LED_1);

    timer_delay_ms(300);
  }
}
Beispiel #5
0
udp_socket_t::udp_socket_t(array_id_t tmp_connection_info_id){
	connection_info_id = tmp_connection_info_id;
	net_ip_connection_info_t *tmp = (net_ip_connection_info_t*)find_pointer(connection_info_id);
	socket = nullptr;
	if(tmp == nullptr){
		printf_("The net_ip_connection_info_t that this socket has to use does not exist (ID: " + std::to_string(tmp_connection_info_id) + ")\n", PRINTF_ERROR);
	}else{
		socket = SDLNet_UDP_Open(tmp->port);
		if(unlikely(!socket)){
			printf_("Socket will not open (port: " + std::to_string(tmp->port) + ")\n", PRINTF_VITAL);
			assert(false);
		}
	}
}
Beispiel #6
0
void set_signal(int signal, bool value){
	if(unlikely(signal > SIGNAL_ARRAY_SIZE || signal < 0)){
		printf_("ERROR: signal is out of bounds\n", PRINTF_ERROR);
		return;
	}
	signal_array[signal-1] = value;
}
Beispiel #7
0
s32 WBFS_Init(u32 device, u32 timeout)
{
	u32 cnt;
	s32 ret = -1;

	/* Wrong timeout */
	if (!timeout)
		return -1;

	/* Try to mount device */
	for (cnt = 0; cnt < timeout; cnt++) {

		ret = WBFS_Init_Dev(device);
		if (ret >= 0) break;

		Gui_Console_Enable();
		printf("%d ", cnt + 1);

		/* Sleep 1 second */
		sleep(1);
	}

	printf_("%s\n", ret < 0 ? gt("ERROR!") : gt("OK!"));
	return ret;
}
Beispiel #8
0
static void net_send_data(){
	int_ what_to_update = INT_MAX;
	std::vector<array_id_t> client_vector = all_ids_of_type("client_t");
	const uint_ client_vector_size = client_vector.size();
	if(client_vector_size == 0){
		return;
	}
	if(once_per_second){
		const std::string reset_vector = wrap(ARRAY_FUNCTION_START, "reset_vector", ARRAY_FUNCTION_END);
		for(uint_ i = 0;i < client_vector_size;i++){
			net->write(reset_vector, ((client_t*)find_pointer(client_vector[i], "coord_t"))->connection_info_id);
		}
	}
	std::vector<std::string> data_to_send = generate_outbound_class_data();
	for(uint_ c = 0;c < data_to_send.size();c++){
		for(uint_ i = 0;i < client_vector_size;i++){
			client_t *tmp_client = (client_t*)find_pointer(client_vector[i], "client_t");
			if(tmp_client != nullptr){
				if(find_pointer(tmp_client->connection_info_id, "net_ip_connection_info_t") == nullptr){
					printf_("WARNING: Found an addressless client", PRINTF_UNUSUAL_WARN);
				}else{
					net->write(gen_string, tmp_client->connection_info_id);
				}
			}
		}
	}
}
Beispiel #9
0
int  FLASH_write(char* argv){
	/* Porgram FLASH Bank1 ********************************************************/       
	/* Unlock the Flash Bank1 Program Erase controller */
	char *pData;
	int need_erase = 0; 
	char buffer[20];
	int Data=0x87654321;
	int Address,FLASHStatus;
	Address = atoi(argv);
	pData = strchr(argv,SEP_FIELD);
	pData++;
	Data = atoi(pData);
	sprintf(buffer,"\naddr:%x\n",Address);
	printf_(buffer);
	sprintf(buffer,"\ndata:%x\n",Data);
	printf_(buffer);
	if ( *(__IO uint32_t*)Address != 0xffffffff)
		need_erase =1;
	FLASH_UnlockBank1();
	if ( need_erase!=0 ){
		printf_("\r\nNeeds erasing page first!erase now...\r\n");
	}
	/* Define the number of page to be erased */

	if ( (Address&0x3) !=0){
		printf_("\r\nError:Address must align by four bytes!");
		return 3;  //3,  命令参数无效
	}

	FLASH_ProgramWord(Address, Data);
	FLASH_LockBank1();

	return 0;

	/* Check the correctness of written data */
	//~ Address = BANK1_WRITE_START_ADDR;

	//~ while((Address < BANK1_WRITE_END_ADDR) && (MemoryProgramStatus != FAILED))
	//~ {
	//~ if((*(__IO uint32_t*) Address) != Data)
	//~ {
	//~ MemoryProgramStatus = FAILED;
	//~ }
	//~ Address += 4;
	//~ }

}
Beispiel #10
0
int_ net_ip_t::send_now(net_ip_write_buffer_t *data){
	int_ return_value = 0;
	net_ip_connection_info_t *tmp_conn = (net_ip_connection_info_t*)find_pointer(data->connection_info_id, "net_ip_connection_info_t");
	if(outbound == NULL){
		printf("Cannot use outbound port. Check to see if you have proper permissions to use raw sockets\n");
		return_value = -1;
		return return_value;
	}
	uint_ position = 0;
	if(tmp_conn != nullptr){
		std::vector<std::string> raw_packets;
		std::string data_prefix = wrap(NET_PACKET_ID_START, std::to_string(data->packet_id), NET_PACKET_ID_END);
		if(data->data.size() > NET_MTU-NET_MTU_OVERHEAD){
			while(data->data != ""){
				uint_ chunk = NET_MTU-NET_MTU_OVERHEAD;
				std::string pos_prefix = wrap(NET_PACKET_POS_START, std::to_string( position), NET_PACKET_POS_END);
				std::string tmp_string = data_prefix + pos_prefix + data->data.substr(0,chunk);
				raw_packets.push_back(tmp_string);
				if(chunk > data->data.size()){
					break;
				}
				data->data = data->data.substr(chunk, data->data.size());
				position++;
			}
		}else{
			std::string tmp;
			tmp = wrap(NET_PACKET_ID_START, std::to_string(data->packet_id), NET_PACKET_ID_END);
			tmp += wrap(NET_PACKET_POS_START, "0", NET_PACKET_POS_END);
			tmp += data->data;
			raw_packets.push_back(tmp);
		}
		const uint_ raw_packets_size = raw_packets.size();
		raw_packets[0] = NET_PACKET_START + raw_packets[0];
		raw_packets[raw_packets_size-1] += NET_PACKET_END;
		IPaddress IP;
		SDLNet_ResolveHost(&IP, tmp_conn->ip.c_str(), (unsigned short int)tmp_conn->port);
		outbound_packet->address.host = IP.host;
		outbound_packet->address.port = IP.port;
		uint_ total_byte_size = 0;
		const uint_ max_total_sent_byte = 8*KILOBYTE_TO_BYTE;
		for(uint_ i = 0;i < raw_packets_size;i++){
			negative_to_positive_trick(&raw_packets[i]);
			unsigned char* outbound_data = (unsigned char *)raw_packets[i].c_str();
			outbound_packet->len = (int)(raw_packets[i].size()+1);
			outbound_packet->data = outbound_data;
			SDLNet_UDP_Send(outbound->socket, -1, outbound_packet);
			total_byte_size += outbound_packet->len;
			if(unlikely(total_byte_size > max_total_sent_byte)){
				// no packet loss if the client is sending data to itself
				total_byte_size = 0;
				loop_receive();
			}
		}
		raw_packets.clear();
	}else{
		printf_("The connection ID (" + std::to_string(data->connection_info_id) + ") does not match up with anything here\n", PRINTF_STATUS);
	}
	return return_value;
}
Beispiel #11
0
float get_hal_pin(HPNAME name){
  for(int i = 0; i < hal.hal_pin_count; i++){
    if(!strcmp(hal.hal_pins[i]->name, name)){
      return(hal.hal_pins[i]->source->source->value);
    }
  }
  printf_("get not possible %s\n", name);
  return(0.0);
}
Beispiel #12
0
int register_hal_pin(struct hal_pin* pin){
  if(hal.hal_pin_count >= MAX_HAL_PINS){
    printf_("reg hal pin: too many pins: %i\n", hal.hal_pin_count);
    return(0);
  }

  for(int i = 0; i < hal.hal_pin_count; i++){
    if(!strcmp(hal.hal_pins[i]->name, pin->name)){
      printf_("reg hal pin: name fault: %s\n", pin->name);
      return(0);
    }
  }

  hal.hal_pins[hal.hal_pin_count] = pin;
  hal.hal_pin_count++;

  return(1);
}
Beispiel #13
0
void main_thread()
{
  led_on(LED_1);

  printf_(OS_WELCOME_MESSAGE);

  create_thread(child1_thread, child1_thread_stack, sizeof(child1_thread_stack), PRIORITY_MAX);
  create_thread(child2_thread, child2_thread_stack, sizeof(child2_thread_stack), PRIORITY_MAX);

  while (1)
  {
    led_on(LED_1);
    printf_("main thread\n");
    led_off(LED_1);

    timer_delay_ms(500);
  }
}
Beispiel #14
0
void Restart(void)
{
	printf("\n");
	printf_(gt("Restarting Wii..."));
	fflush(stdout);
	__console_flush(0);

	/* Load system menu */
	Sys_LoadMenu();
}
Beispiel #15
0
void child2_thread()
{
  while (1)
  {
    led_on(LED_1);
    printf_("child 2 thread 2222222\n");
    led_off(LED_1);

    timer_delay_ms(700);
  }
}
Beispiel #16
0
int set_hal_pin(HPNAME name, float value){
  for(int i = 0; i < hal.hal_pin_count; i++){
    if(!strcmp(hal.hal_pins[i]->name, name)){
      hal.hal_pins[i]->value = value;
      hal.hal_pins[i]->source = hal.hal_pins[i];
      return(1);
    }
  }
  printf_("set not possible %s = %f\n", name, value);
  return(0);
}
Beispiel #17
0
void main_thread()
{
	printf_(OS_WELCOME_MESSAGE);

	u32 res = hmc5883_init();

	while (1)
	{
		led_on(LED_1);
		hmc5883_read();
		//printf_("%u : %i %i %i\n", res, g_hmc5883.mx, g_hmc5883.my, g_hmc5883.mz);
		printf_("%u : %i \n", res, g_hmc5883.mz);
		led_off(LED_1);


		timer_delay_ms(100);
	}

	robot_main();
}
Beispiel #18
0
void Restart_Wait(void)
{
	printf("\n");
	printf_(gt("Press any button to restart..."));
	fflush(stdout);

	/* Wait for button */
	Wpad_WaitButtonsCommon();

	/* Restart */
	Restart();
}
Beispiel #19
0
void Menu_DumpBCA(u8 *id)
{
	int ret;
	char fname[100];
	memset(BCA_Data, 0, 64);
	printf_("\n");
	printf_(gt("Reading BCA..."));
	printf("\n\n");
	ret = WDVD_Read_Disc_BCA(BCA_Data);
	hex_dump3(BCA_Data, 64);
	printf_("\n");
	if (ret) {
		printf_(gt("ERROR reading BCA!"));
		printf("\n\n");
		goto out;
	}
	// save
	snprintf(D_S(fname), "%s/%.6s.bca", USBLOADER_PATH, (char*)id);
	if (!Menu_Confirm(gt("save"))) return;
	printf("\n");
	printf_(gt("Writing: %s"), fname);
	printf("\n\n");
	FILE *f = fopen(fname, "wb");
	if (!f) {
		printf_(gt("ERROR writing BCA!"));
		printf("\n\n");
		goto out;
	}
	fwrite(BCA_Data, 64, 1, f);
	fclose(f);
	out:
	Menu_PrintWait();
}
Beispiel #20
0
bool input_t::query_key(int scancode){
	bool return_value = false;
	if(likely(scancode > 0 && scancode < KEYBOARD_MAP_SIZE)){
		try{
			input_keyboard_map_t *keyboard_map = (input_keyboard_map_t*)find_pointer(keyboard_map_id);
			throw_if_nullptr(keyboard_map);
			return_value = keyboard_map->keyboard_map[scancode];
		}catch(std::logic_error &e){}
	}else{
		printf_("ERROR: The scancode is outside of the keyboard bounds. You might be trying to acess some special variable (mouse control, joystick control, etc.)\n", PRINTF_ERROR);
		return_value = false;
	}
	return return_value;
}
Beispiel #21
0
int set_comp_type(HPNAME name){
  for(int i = 0; i < hal.comp_type_count; i++){
    if(!strcmp(hal.comp_types[i], name)){
      hal.comp_type = i;
      return(hal.comp_types_counter[hal.comp_type]++);
    }
  }

  if(hal.comp_type_count < MAX_COMP_TYPES){
    strncpy(hal.comp_types[hal.comp_type_count], name, MAX_HPNAME);
    hal.comp_type = hal.comp_type_count++;
    return(0);
  }
  printf_("set comp type: too many comps types: %i\n", hal.comp_type_count);
  return(-1);
}
Beispiel #22
0
int link_hal_pins(HPNAME source, HPNAME sink){
  struct hal_pin* d;
  struct hal_pin* s;
  d = find_hal_pin(source);
  s = find_hal_pin(sink);

  if(d != 0 && s != 0){
   //   if(s->source != s){
   //      printf_("relink %s:%i -> %s:%i to %s:%i -> %s:%i\n", s->source->name, s->source, sink, s, source, d, sink, s);
   //   }
    s->value = s->source->source->value;
    s->source = d;
	return(1);
  }
  printf_("link not possible %s:%i -> %s:%i\n", source, d, sink, s);
  return(0);
}
Beispiel #23
0
void input_engine(){
	try{
		input_t *input = (input_t*)find_pointer(all_ids_of_type("input_t")[0]);
		throw_if_nullptr(input);
		input->array.data_lock.lock(); // no throws are allowed beyond this point
		client_t *self = (client_t*)find_pointer(self_id);
		if(self != nullptr && self->keyboard_map_id != DEFAULT_INT_VALUE){
			input->array.data_lock.unlock();
			input->set_keyboard_map_id(self->keyboard_map_id);
			input->array.data_lock.lock();
		}
		input->loop();
		if(input->query_key(SDL_SCANCODE_ESCAPE)){
			set_signal(SIGTERM, true);
		}
		input->array.data_lock.unlock();
	}catch(std::logic_error &e){
		printf_("WARNING: input_t: cannot use the input library yet\n", PRINTF_UNLIKELY_WARN);
	}
}
Beispiel #24
0
int  FLASH_read(char* argv){
	uint32_t  i=0,len =32,data=0;
	char buffer[buffer_sz];
	char* pHead,*pEnd;
	uint32_t  address =  0x08000800;
	if (*argv){
		pHead = argv;
		pEnd = strchr(pHead,SEP_FIELD);
		if (pEnd) {
			*pEnd = '\0';
			address = atoi(pHead);
			if (address < 0x08000000 && address >0x0800ffff) // for 64kBytes flash MCU
				return 4; //4,  超出命令范围 in uart.c
			pHead = pEnd +1;
			if (*pHead)
				len = atoi(pHead);
			if (len<0 && len > 1024)
				return 4; //4,  超出命令范围 in uart.c
		}
	}
	printf_("\r\n");
	printf_hex((char*)address,(int) len);
	return 0;
}
Beispiel #25
0
void Print_SYS_Info()
{
	FgColor(CFG.color_inactive);
	printf_("");
	Fat_print_sd_mode();
	printf_(gt("CFG base: %s"), USBLOADER_PATH);
	printf("\n");
	if (strcmp(LAST_CFG_PATH, USBLOADER_PATH)) {
		// if last cfg differs, print it out
		printf_(gt("Additional config:"));
		printf("\n");
		printf_("  %s/config.txt\n", LAST_CFG_PATH);
	}
	printf_(gt("Loader Version: %s"), CFG_VERSION);
	printf("\n");
	printf_("IOS%u (Rev %u)\n",
			IOS_GetVersion(), IOS_GetRevision());
	DefaultColor();
}
Beispiel #26
0
void Menu_Boot()
{
	struct discHdr *header;
	bool gc = false;

	header = &gameList[gameSelected];
	
	s32 ret;
	struct Game_CFG_2 *game_cfg = NULL;

	/* Clear console */
	if (!CFG.direct_launch) {
		Con_Clear();
	}
	FgColor(CFG.color_header);
	printf_x(gt("Start this game?"));
	printf("\n\n");
	DefaultColor();
	
	game_cfg = CFG_find_game(header->id);

	// Get game size
	gc = header->magic == GC_MAGIC;
	bool do_skip = !CFG.confirm_start;
/*
	SoundInfo snd;
	u8 banner_title[84];
	memset(banner_title, 0, 84);
	memset(&snd, 0, sizeof(snd));
	WBFS_Banner(header->id, &snd, banner_title, !do_skip, CFG_read_active_game_setting(header->id).write_playlog);
*/
	if (do_skip) {
		goto skip_confirm;
	}

	printf("\n");

	/* Show game info */
	printf_("%s\n", get_title(header));
	printf_("(%.6s)\n\n", header->id);

	__Menu_ShowGameInfo(true, header->id); /* load game info from XML */
	printf("\n");

	//Does DL warning apply to launching discs too? Not sure
	printf_h(gt("Press %s button to continue."), (button_names[CFG.button_confirm.num]));
	printf("\n");
	printf_h(gt("Press %s button to go back."), (button_names[CFG.button_cancel.num]));
	if (!gc) {
		printf("\n");
		printf_h(gt("Press %s button for options."), (button_names[CFG.button_other.num]));
	}
	printf("\n\n");
	__console_flush(0);

	// play banner sound
/*
	if (snd.dsp_data) {
		SND_PauseVoice(0, 1); // pause mp3
		int fmt = (snd.channels == 2) ? VOICE_STEREO_16BIT : VOICE_MONO_16BIT;
		SND_SetVoice(1, fmt, snd.rate, 0,
			snd.dsp_data, snd.size,
			255,255, //volume,volume,
			NULL); //DataTransferCallback
	}
*/
	/* Wait for user answer */
	u32 buttons;
	for (;;) {
		buttons = Wpad_WaitButtons();
		if (buttons & CFG.button_confirm.mask) break;
		if (buttons & CFG.button_cancel.mask) break;
		if (!gc && (buttons & CFG.button_other.mask)) break;
		if (buttons & CFG.button_exit.mask) break;
	}
/*
	// stop banner sound, resume mp3
	if (snd.dsp_data) {
		SND_StopVoice(1);
		SAFE_FREE(snd.dsp_data);
		if (buttons & CFG.button_confirm.mask) {
			SND_ChangeVolumeVoice(0, 0, 0);
		}
		SND_PauseVoice(0, 0);
	}
*/
	if (buttons & CFG.button_cancel.mask) goto close;
	if (buttons & CFG.button_exit.mask) {
		Handle_Home(0);
		return;
	}
	if (!gc && (buttons & CFG.button_other.mask)) {
		Menu_Boot_Options(header);
		return;
	}
	// A button: continue to boot

	skip_confirm:

	if (game_cfg) {
		CFG.game = game_cfg->curr;
	}

	if (CFG.game.write_playlog && set_playrec(header->id, (u8 *) header->title) < 0) { // banner_title) < 0) {
		printf_(gt("Error storing playlog file.\nStart from the Wii Menu to fix."));
		printf("\n");
		printf_h(gt("Press %s button to exit."), (button_names[CFG.button_exit.num]));
		printf("\n");
		if (!Menu_Confirm(0)) return;
	}

	WBFS_OpenDisc(header->id, header->game_idx);

	printf("\n");
	printf_x(gt("Booting Wii game, please wait..."));
	printf("\n\n");
	
	// load stuff before ios reloads & services close
	ocarina_load_code(header->id);
	load_wip_patches(header->id);

	// Close the wode stuff
	WBFS_Close();
	use_dvdx = 0;
	
	Disc_Init();
	ret = Disc_Wait();
	if (ret < 0) {
		printf("Cannot mount newly selected image: %d\n", ret);
	}
	Disc_Open();

	// stop services (music, gui)
	Services_Close();

	setPlayStat(header->id); //I'd rather do this after the check, but now you unmount fat before that ;)
	
	Fat_UnmountAll();

	if (gc) {
		WII_Initialize();
		ret = WII_LaunchTitle(0x0000000100000100ULL);
	} else {
		switch(CFG.game.language)
				{
						// 0 = CFG_LANG_CONSOLE
						case 0: configbytes[0] = 0xCD; break; 
						case 1: configbytes[0] = 0x00; break; 
						case 2: configbytes[0] = 0x01; break; 
						case 3: configbytes[0] = 0x02; break; 
						case 4: configbytes[0] = 0x03; break; 
						case 5: configbytes[0] = 0x04; break; 
						case 6: configbytes[0] = 0x05; break; 
						case 7: configbytes[0] = 0x06; break; 
						case 8: configbytes[0] = 0x07; break; 
						case 9: configbytes[0] = 0x08; break; 
						case 10: configbytes[0] = 0x09; break;
				}

		/* Boot Wii disc */
		ret = Disc_WiiBoot();
	}
	printf_(gt("Returned! (ret = %d)"), ret);
	printf("\n");

	printf("\n");
	printf_(gt("Press any button to exit..."));
	printf("\n");

	/* Wait for button */
	Wpad_WaitButtonsCommon();
	exit(0);
close:
	WDVD_StopMotor();
	header = &gameList[gameSelected];
	Gui_DrawCover(header->id);
	
	// Reopen the wode
	WBFS_Init();
	
	return;
}
Beispiel #27
0
void DoAction(int action)
{
	if (action & CFG_BTN_REMAP) return;
	switch(action) {
		case CFG_BTN_NOTHING:
			break;
		case CFG_BTN_OPTIONS: 
			if (!CFG.disable_options) Menu_Options();
			break;
		case CFG_BTN_GUI:
			if (go_gui) {
				action_string[0] = 0;
				action_alpha=0;
			}
			if (CFG.gui) go_gui = !go_gui;
			break;
		case CFG_BTN_REBOOT:
			Con_Clear();
			Restart();
			break;
		case CFG_BTN_EXIT:
			Con_Clear();
			printf("\n");
			printf_("Exiting...");
			__console_flush(0);
			Sys_Exit();
			break;
		case CFG_BTN_SCREENSHOT:
			__console_flush(0);
			Make_ScreenShot();
			CFG.home = CFG_HOME_EXIT;
			break;
		case CFG_BTN_MAIN_MENU: 
			Menu_Views();
			break;
		case CFG_BTN_GLOBAL_OPS:
			if (!CFG.disable_options) Menu_Global_Options();
			break;
		case CFG_BTN_PROFILE: 
			if (CFG.current_profile == CFG.num_profiles-1)
				CFG.current_profile = 0;
			else
				CFG.current_profile++;
			Switch_Favorites(enable_favorite);
			
			sprintf(action_string, gt("Profile: %s"), CFG.profile_names[CFG.current_profile]);
			
			break;
		case CFG_BTN_FAVORITES:
			{
				extern void reset_sort_default();
				reset_sort_default();
				Switch_Favorites(!enable_favorite);
			}
			break;
		case CFG_BTN_BOOT_GAME:
			Menu_Boot(0);
			break;
		case CFG_BTN_BOOT_DISC:
			Menu_Boot(1);
			break;
		case CFG_BTN_THEME:
			CFG_switch_theme(cur_theme + 1);
			if (gameCnt) Gui_DrawCover(gameList[gameSelected].id);//redraw_cover = 1;
			Cache_Invalidate();
			
			sprintf(action_string, gt("Theme: %s"), theme_list[cur_theme]);
			if (go_gui) action_alpha = 0xFF;
			
			break;
		case CFG_BTN_UNLOCK:
			if (CFG.admin_lock) Menu_Unlock();
			break;
		case CFG_BTN_HBC:
			Con_Clear();
			printf("\n");
			printf_("HBC...");
			__console_flush(0);
			Sys_HBC();
			break;
		case CFG_BTN_SORT:
			if (sort_desc) {
				sort_desc = 0;
				if (sort_index == sortCnt - 1)
					sort_index = 0;
				else
					sort_index = sort_index + 1;
				sortList(sortTypes[sort_index].sortAsc);
			} else {
				sort_desc = 1;
				sortList(sortTypes[sort_index].sortDsc);
			}
			if (gameCnt) Gui_DrawCover(gameList[gameSelected].id);//redraw_cover = 1;

			
			sprintf(action_string, gt("Sort: %s-%s"), sortTypes[sort_index].name, (sort_desc) ? "DESC":"ASC");
			
			break;
		case CFG_BTN_FILTER:
			Menu_Filter();
			break;
		default:
			// Priiloader magic words, and channels
			if ((action & 0xFF) < 'a') {
				// upper case final letter implies channel
				Con_Clear();
				Sys_Channel(action);
			} else {
				// lower case final letter implies magic word
				Con_Clear();
				*(vu32*)0x8132FFFB = action;
				Restart();
			}
			break;
	}
}
Beispiel #28
0
void Menu_Partition(bool must_select)
{
	int i;
	s32 ret = 0;
	int pnum = WBFS_GetPartitionCount();

	struct Menu menu;
	char active[256];
	menu_init(&menu, pnum);
	menu_init_active(&menu, active, 256);

loop:
	menu_begin(&menu);
	/* Clear console */
	Con_Clear();

	FgColor(CFG.color_header);
	printf_x(gt("Select a partition"));
	printf(":\n\n");
	DefaultColor();

	printf_("P# Name\n");
	printf_("-----------------------------\n");
	//       P#1  ram1ro
	//       P#2  sda1ro
	//       P#3  sda2ro

	char partname[32];
	for (i = 0; i < pnum; i++) {
		memset(partname, 0, 32);
		WBFS_GetPartitionName(i, (char *) &partname);
		MENU_MARK();
		printf("%d  %s\n", i, partname);
	}
	printf("\n");
	printf_h(gt("Press %s button to select."), (button_names[CFG.button_confirm.num]));
	printf("\n");
	printf_h(gt("Press %s button to go back."), (button_names[CFG.button_cancel.num]));
	printf("\n");

	u32 buttons = Wpad_WaitButtonsCommon();

	menu_move(&menu, buttons);

	// B button
	if (buttons & CFG.button_cancel.mask) {
		if (must_select) {
			if (WBFS_Selected()) return;
			printf("\n");
			printf_(gt("No partition selected!"));
			printf("\n");
			sleep(2);
		} else {
			return;
		}
	}

	// A button
	if (buttons & CFG.button_confirm.mask) {
		i = menu.current;

		__console_flush(0);
		ret = WBFS_OpenPart(i, CFG.partition);
		if (ret == 0) {
			if (must_select) {
				// called from global options
				__Menu_GetEntries();
			}
			return;
		}
	}

	goto loop;
}
Beispiel #29
0
UDPsocket udp_socket_t::get_socket(){
	if(socket == nullptr){
		printf_("ERROR: Socket is null (net_ip_connection_info_t ID (striped): " + std::to_string(strip_id(connection_info_id)) + "\n", PRINTF_VITAL);
	}
	return socket;
}
Beispiel #30
0
void __Menu_ShowList(void)
{
	FgColor(CFG.color_header);
	if (enable_favorite) {
		printf_x(gt("Favorite Games"));
		printf(":\n");
	} else {
		if (!CFG.hide_header) {
			printf_x(gt("Select the game you want to boot"));
			printf(":\n");
		}
	}
	DefaultColor();
	if (CFG.console_mark_page && gameStart > 0) {
		printf(" %s +", CFG.cursor_space);
	}
	printf("\n");

	/* No game list*/
	if (gameCnt) {
		u32 cnt;

		/* Print game list */
		for (cnt = gameStart; cnt < gameCnt; cnt++) {
			struct discHdr *header = &gameList[cnt];

			/* Entries per page limit reached */
			if ((cnt - gameStart) >= ENTRIES_PER_PAGE)
				break;

			if (gameSelected == cnt) {
				FgColor(CFG.color_selected_fg);
				BgColor(CFG.color_selected_bg);
				Con_ClearLine();
			} else {
				DefaultColor();
			}

			/* Print entry */
			//printf(" %2s %s\n", (gameSelected == cnt) ? ">>" : "  ",
			char *title = __Menu_PrintTitle(get_title(header));
			// cursor
			printf(" %s", (gameSelected == cnt) ? CFG.cursor : CFG.cursor_space);
			// favorite mark
			printf("%s", (CFG.console_mark_favorite && is_favorite(header->id))
					? CFG.favorite : " ");
			// title
			printf("%s", title);
			// saved mark
			if (CFG.console_mark_saved) {
				printf("%*s", (MAX_CHARACTERS - con_len(title)),
					(CFG_is_saved(header->id)) ? CFG.saved : " ");
			}
			printf("\n");
		}
		DefaultColor();
		if (CFG.console_mark_page && cnt < gameCnt) {
			printf(" %s +", CFG.cursor_space);
		} else {
			printf(" %s  ", CFG.cursor_space);
		}
		//if (CFG.hide_hddinfo) {
		FgColor(CFG.color_footer);
		BgColor(CONSOLE_BG_COLOR);
		int num_page = 1 + (gameCnt - 1) / ENTRIES_PER_PAGE;
		int cur_page = 1 + gameSelected / ENTRIES_PER_PAGE;
		printf(" %-*.*s %d/%d", MAX_CHARACTERS - 8, MAX_CHARACTERS - 8, action_string, cur_page, num_page);
		action_string[0] = 0;
		//}
	} else {
		printf(" ");
		printf(gt("%s No games found!!"), CFG.cursor);
		printf("\n");
	}

	/* Print free/used space */
	FgColor(CFG.color_footer);
	BgColor(CONSOLE_BG_COLOR);
	if (!CFG.hide_footer) {
		printf("\n");
		// (B) GUI (1) Options (2) Favorites
		// B: GUI 1: Options 2: Favorites
		//char c_gui = 'B', c_opt = '1';
		//if (CFG.buttons == CFG_BTN_OPTIONS_B) {
		//	c_gui = '1'; c_opt = 'B';
		//}
		printf_("");
		if (CFG.gui && CFG.button_gui) {
			printf("%s: GUI ", (button_names[CFG.button_gui]));
		}
		if (!CFG.disable_options && CFG.button_opt) {
			printf("%s: Options ", (button_names[CFG.button_opt]));
		}
		if (CFG.button_fav) {
			printf("%s: Favorites", (button_names[CFG.button_fav]));
		}
	}
	if (CFG.db_show_info) {
		printf("\n");
		//load game info from XML - lustar
		__Menu_ShowGameInfo(false, gameList[gameSelected].id);
	}
	DefaultColor();
	__console_flush(0);
}