Exemplo n.º 1
0
void IdleFunc()
{
  static int MarkTime;
  
  if ((int)(MarkTime - timer_ms_gettime64()) < 0)
  {
    MarkTime = timer_ms_gettime64() + YETI_VIEWPORT_INTERVAL;

    keyboard_update(&yeti.keyboard);
    
    pvr_wait_ready();
    pvr_scene_begin();
    
   /* The cool thing here is that we don't have to worry about which display list
      to open/close, which display list is open, or any of that when using PVR DMA.
      We submit everything with pvr_list_prim instead of pvr_prim and things get
      submitted in the right order automatically. Just run your game loop in between
      "pvr_scene_begin();" and "pvr_scene_finish();" and the rest is taken care of. */    
    
    game_loop(&yeti);
    
    /* Done drawing! */
    pvr_scene_finish();
    
  }
}
Exemplo n.º 2
0
int ppp_modem_init(const char *number, int blind, int *conn_rate) {
    uint64_t timeout;

    /* Initialize the modem. */
    if(!modem_init())
        return -1;

    /* Set the modem up to connect to a remote machine. */
    modem_set_mode(MODEM_MODE_REMOTE, MODEM_SPEED_V8_AUTO);

    /* If we aren't doing blind dialing, wait up to 5 seconds for a dialtone. */
    if(!blind) {
        if(modem_wait_dialtone(5000)) {
            modem_shutdown();
            return -2;
        }
    }

    /* Dial the specified phone number. */
    if(!modem_dial(number)) {
        modem_shutdown();
        return -3;
    }

    /* Give ourselves a 60 second timeout to establish a connection. */
    timeout = timer_ms_gettime64() + 60 * 1000;
    while(timer_ms_gettime64() < timeout && modem_is_connecting()) {
        thd_pass();
    }

    /* Did we connect successfully? */
    if(!modem_is_connected()) {
        modem_shutdown();
        return -4;
    }

    /* Does the user want the connection rate back? If so give it to them. */
    if(conn_rate) {
        *conn_rate = modem_get_connection_rate();
    }

    dbglog(DBG_KDEBUG, "ppp_modem: connected at %lu bps\n",
           modem_get_connection_rate());

    /* We connected to the peer successfully, set our device with libppp. */
    ppp_set_device(&modem_dev);

    return 0;
}
Exemplo n.º 3
0
static void snd_hook(int strm, void * obj, int freq, int chn, void ** buf, int *req) {
    int actual;
    uint64 t;

    mutex_lock(hookmut);
    actual = *req;

    if(actual > 16384 * 2)
        actual = 16384 * 2;

    memcpy(sndbuffer + 0, sndbuffer + 1, sndbuffer_cnt * 4);
    memcpy(sndbuffer + 1, *buf, actual);
    sndbuffer_cnt = actual / 4;

    t = timer_ms_gettime64();

    if(last_time != 0) {
        uint32 elapsed = (uint32)(t - last_time);
        takeframes = elapsed * 60 / 1000;
    }

    last_time = t;
    curpos = 0;
    mutex_unlock(hookmut);
}
Exemplo n.º 4
0
static int pap_send_auth_req(ppp_protocol_t *self, int resend) {
    int nl = strlen(ppp_state->username);
    int pl = strlen(ppp_state->passwd);
    uint16_t len = 6 + nl + pl;
    uint8_t buf[len];
    int i = 0, j;
    pap_pkt_t *pkt = (pap_pkt_t *)buf;

    (void)self;

    /* Fill in the header. */
    pkt->code = PAP_AUTHENTICATE_REQ;

    if(resend)
        pkt->id = pap_id;
    else
        pkt->id = ++pap_id;

    pkt->len = htons(len);

    /* Fill in the rest of the packet. */
    pkt->data[i++] = nl;

    for(j = 0; j < nl; ++j) {
        pkt->data[i++] = ppp_state->username[j];
    }

    pkt->data[i++] = pl;

    for(j = 0; j < pl; ++j) {
        pkt->data[i++] = ppp_state->passwd[j];
    }

    /* Set the resend timer for 3 seconds. */
    next_resend = timer_ms_gettime64() + 3000;

    if(!resend)
        resend_cnt = 10;

    return ppp_send(buf, len, PPP_PROTOCOL_PAP);
}
Exemplo n.º 5
0
int64_t av_gettime(void)
{
  //return ta_state.frame_counter * 1000000LL / 60;
  return timer_ms_gettime64();
}
Exemplo n.º 6
0
void Speedtest_Run(GUI_Widget *widget) {

	uint8 *buff = (uint8*)0x8c400000;
	size_t buff_size = 0x10000;
	int size = 0x800000, cnt = 0, rs; 
	int64 time_before, time_after;
	uint32 t;
	double speed;
	file_t fd;
	int read_only = 0;
	
	char name[64];
	char result[128];
	const char *wname = GUI_ObjectGetName((GUI_Object *)widget);
	
	if(!strncasecmp(wname, "/cd", 3)) {
		
		read_only = 1;
		snprintf(name, sizeof(name), "%s/1DS_CORE.BIN", wname);

		if(FileExists(name)) {
			goto readtest;
		} else {
			snprintf(name, sizeof(name), "%s/1ST_READ.BIN", wname);
			goto readtest;
		}
	}
	
	show_status_ok("Testing WRITE speed...");
	GUI_LabelSetText(self.speedwr, "...");
	GUI_LabelSetText(self.speedrd, "   ");
	
	snprintf(name, sizeof(name), "%s/%s.tst", wname, lib_get_name());
	
	if(FileExists(name)) {
		fs_unlink(name);
	}
	
	/* WRITE TEST */
	fd = fs_open(name, O_CREAT | O_WRONLY);
	
	if (fd == FILEHND_INVALID) {
		ds_printf("DS_ERROR: Can't open %s for write: %d\n", name, errno);
		show_status_error("Can't open file for write");
		return;
	}

	ShutdownVideoThread(); 
	time_before = timer_ms_gettime64();
	
	while(cnt < size) {
		
		rs = fs_write(fd, buff, buff_size);
		
		if(rs <= 0) {
			fs_close(fd);
			InitVideoThread(); 
			ds_printf("DS_ERROR: Can't write to file: %d\n", errno);
			show_status_error("Can't write to file");
			return;
		}
		
		buff += rs;
		cnt += rs;
	}
	
	time_after = timer_ms_gettime64();
	InitVideoThread();
	
	t = (uint32)(time_after - time_before);
	speed = size / ((float)t / 1000);
	fs_close(fd);
	
	snprintf(result, sizeof(result), 
				"Write speed %.2f Kbytes/s (%.2f Mbit/s) Time: %ld ms",
				speed / 1024, ((speed / 1024) / 1024) * 8, t);
	
	GUI_LabelSetText(self.speedwr, result);
	show_status_ok("Complete!"); 
	
	ds_printf("DS_OK: Complete!\n"
				" Test: write\n Time: %ld ms\n"
				" Speed: %.2f Kbytes/s (%.2f Mbit/s)\n"
				" Size: %d Kb\n Buff: %d Kb\n", 
				t, speed / 1024, 
				((speed / 1024) / 1024) * 8, 
				size / 1024, buff_size / 1024); 
				
readtest:

	show_status_ok("Testing READ speed...");
	GUI_LabelSetText(self.speedrd, "...");

	/* READ TEST */
	fd = fs_open(name, O_RDONLY);
	
	if (fd == FILEHND_INVALID) {
		ds_printf("DS_ERROR: Can't open %s for read: %d\n", name, errno);
		show_status_error("Can't open file for read");
		return;
	}

	if(read_only) {
		GUI_LabelSetText(self.speedwr, "Write test passed");
		/* Reset ISO9660 filesystem cache */
		fs_ioctl(fd, NULL, 0);
		fs_close(fd);
		fd = fs_open(name, O_RDONLY);
	}
	
	time_before = time_after = t = cnt = 0;
	speed = 0.0f;
	size = fs_total(fd);
	buff = rd_buff;

	ShutdownVideoThread();
	time_before = timer_ms_gettime64();

	while(cnt < size) {
		
		rs = fs_read(fd, buff, buff_size);
		
		if(rs <= 0) {
			fs_close(fd);
			InitVideoThread(); 
			ds_printf("DS_ERROR: Can't read file: %d\n", errno);
			show_status_error("Can't read file");
			return;
		}
		
		cnt += rs;
	}
	
	time_after = timer_ms_gettime64();
	t = (uint32)(time_after - time_before);
	speed = size / ((float)t / 1000);
	fs_close(fd);
	
	if(!read_only) { 
		fs_unlink(name);
	} else {
		cdrom_spin_down();
	}
	
	snprintf(result, sizeof(result), 
			"Read speed %.2f Kbytes/s (%.2f Mbit/s) Time: %ld ms",
			speed / 1024, ((speed / 1024) / 1024) * 8, t);
	
	InitVideoThread();
	
	ds_printf("DS_OK: Complete!\n"
				" Test: read\n Time: %ld ms\n"
				" Speed: %.2f Kbytes/s (%.2f Mbit/s)\n"
				" Size: %d Kb\n Buff: %d Kb\n", 
				t, speed / 1024, 
				((speed / 1024) / 1024) * 8, 
				size / 1024, buff_size / 1024);
    
	GUI_LabelSetText(self.speedrd, result);
	show_status_ok("Complete!"); 
}
Exemplo n.º 7
0
Uint32 SDL_GetTicks(void)
{
	return(timer_ms_gettime64()-start);
}
Exemplo n.º 8
0
void SDL_StartTicks(void)
{
	/* Set first ticks value */
	start = timer_ms_gettime64();
}
Exemplo n.º 9
0
void gd_ripper_StartRip() {
	file_t fd;
	CDROM_TOC toc ;
	int status, disc_type ,cdcr ,start ,s_end ,nsec ,type ,tn ,session,terr=0;
	char dst_folder[MAX_FN_LEN];
	char dst_file[MAX_FN_LEN];
	char riplabel[64];
	char text[MAX_FN_LEN];
	uint64 stoptimer , starttimer , riptime;
	
	starttimer = timer_ms_gettime64 (); // timer
	cdrom_reinit();
	snprintf(text ,MAX_FN_LEN,"%s", GUI_TextEntryGetText(self.gname));
	if(GUI_WidgetGetState(self.sd_c)) {
		snprintf(dst_folder, MAX_FN_LEN, "/sd/%s", text);
	}else if(GUI_WidgetGetState(self.hdd_c)) {
		snprintf(dst_folder, MAX_FN_LEN, "/ide/%s", text);
	}else if(GUI_WidgetGetState(self.net_c)) {
		snprintf(dst_folder, MAX_FN_LEN, "/net/%s", text);
	}
//ds_printf("Dst file1 %s\n" ,dst_folder);	
getstatus:	
	if((cdcr = cdrom_get_status(&status, &disc_type)) != ERR_OK) {
		switch (cdcr){
			case ERR_NO_DISC :
				ds_printf("DS_ERROR: Disk not inserted\n");
				return;
			case ERR_DISC_CHG :
				cdrom_reinit();
				goto getstatus;
			case CD_STATUS_BUSY :
				thd_sleep(200);
				goto getstatus;
			case CD_STATUS_SEEKING :
				thd_sleep(200);
				goto getstatus;
			case CD_STATUS_SCANNING :
				thd_sleep(200);
				goto getstatus;
			default:
				ds_printf("DS_ERROR: GD-rom error\n");
				return;
		}
	}
	if (disc_type == CD_CDROM_XA){
	rname:
			snprintf(dst_file,MAX_FN_LEN, "%s.iso", dst_folder);
			if ((fd=fs_open(dst_file , O_RDONLY)) != FILEHND_INVALID) {
				fs_close(fd); strcpy(dst_file,"\0"); 
				strcat(dst_folder , "0"); 
				goto rname ;
			} else disc_type = 1;
	} else if (disc_type == CD_GDROM){
	rname1:
			if ((fd=fs_open (dst_folder , O_DIR)) != FILEHND_INVALID) {
				fs_close(fd); 
				strcat(dst_folder , "0"); 
				goto rname1 ;
			} else {strcpy(dst_file,"\0");
			snprintf(dst_file,MAX_FN_LEN,"%s", dst_folder); 
			disc_type = 2; 
			fs_mkdir(dst_file);
			}
			
			while(cdrom_read_toc(&toc, 1) != CMD_OK) { 
				terr++;
				cdrom_reinit();
				if (terr > 100){
				ds_printf("DS_ERROR: Toc read error for gdlast\n");
				fs_rmdir(dst_folder); 
				return; 
				}
			}
			terr=0;
			self.lastgdtrack = TOC_TRACK(toc.last);
	} else {
			ds_printf("DS_ERROR: This is not game disk\nInserted %d disk\n",disc_type);
			return;
	}
//ds_printf("Dst file %s\n" ,dst_file);
	
	for (session=0; session < disc_type; session++) {
		cdrom_set_sector_size(2048);
		while(cdrom_read_toc(&toc, session) != CMD_OK) {
			terr++; 
			if(terr==5) cdrom_reinit(); 
			thd_sleep(500); 
			if (terr > 10) { 
				ds_printf("DS_ERROR: Toc read error\n");
			if (disc_type == 1) {
				if(fs_unlink(dst_file) != 0) 
				ds_printf("Error delete file: %s\n" ,dst_file);
			}else {
					if ((fd=fs_open (dst_folder , O_DIR)) == FILEHND_INVALID) {
						ds_printf("Error folder '%s' not found\n" ,dst_folder); 
						return;
					}
					dirent_t *dir;
					while ((dir = fs_readdir(fd))){
						if (!strcmp(dir->name,".") || !strcmp(dir->name,"..")) continue;
						strcpy(dst_file,"\0");
						snprintf(dst_file, MAX_FN_LEN, "%s/%s", dst_folder, dir->name);
						fs_unlink(dst_file);
					}
					fs_close(fd);
					fs_rmdir(dst_folder);
				} 
				return; 
			}
		}
		terr = 0;
		int first = TOC_TRACK(toc.first);
		int last = TOC_TRACK(toc.last);
		for (tn=first; tn <= last; tn++ ) {
			if (disc_type == 1) tn = last;
			type = TOC_CTRL(toc.entry[tn-1]);
			if (disc_type == 2) {
				strcpy(dst_file,"\0"); 
				snprintf(dst_file,MAX_FN_LEN,"%s/track%02d.%s", dst_folder, tn, (type == 4 ? "iso" : "raw"));
			}
			
			start = TOC_LBA(toc.entry[tn-1]);
			s_end = TOC_LBA((tn == last ? toc.leadout_sector : toc.entry[tn]));
			nsec = s_end - start;
			
			if (disc_type == 1 && type == 4) nsec -= 2 ;
			else if (session==1 && tn != last && type != TOC_CTRL(toc.entry[tn])) nsec -= 150;
			else if (session==0 && type == 4) nsec -= 150;
			
			if (disc_type == 2 && session == 0) {
				strcpy(riplabel,"\0"); 
				sprintf(riplabel,"Track %d of %d\n",tn ,self.lastgdtrack );
			} else if (disc_type == 2 && session == 1 && tn != self.lastgdtrack) {
				strcpy(riplabel,"\0"); 
				sprintf(riplabel,"Track %d of %d\n",tn ,self.lastgdtrack );
			} else {
				strcpy(riplabel,"\0"); 
				sprintf(riplabel,"Last track\n");
			}
			
			GUI_LabelSetText(self.track_label, riplabel);
			
			if (rip_sec(tn, start, nsec, type, dst_file, disc_type) != CMD_OK) {
				GUI_LabelSetText(self.track_label, " ");
				stoptimer = timer_ms_gettime64 (); // timer
				GUI_ProgressBarSetPosition(self.pbar, 0.0);
				cdrom_spin_down();
				if (disc_type == 1) {
					if(fs_unlink(dst_file) != 0) ds_printf("Error delete file: %s\n" ,dst_file);
				} else {
					if ((fd=fs_open (dst_folder , O_DIR)) == FILEHND_INVALID) {
						ds_printf("Error folder '%s' not found\n" ,dst_folder); 
						return;
					}
					
					dirent_t *dir;
					while ((dir = fs_readdir(fd))){
						if (!strcmp(dir->name,".") || !strcmp(dir->name,"..")) continue;
						strcpy(dst_file,"\0");
						snprintf(dst_file, MAX_FN_LEN, "%s/%s", dst_folder, dir->name);
						fs_unlink(dst_file);
					}
					fs_close(fd);
					fs_rmdir(dst_folder);
				}
				return ;
			}
			GUI_LabelSetText(self.track_label, " ");
			GUI_ProgressBarSetPosition(self.pbar, 0.0);
		}
	}
	GUI_LabelSetText(self.track_label, " ");
	GUI_WidgetMarkChanged(self.app->body);
	if (disc_type == 2){
		if (gdfiles(dst_folder, dst_file, text) != CMD_OK){
			cdrom_spin_down();
			if ((fd=fs_open (dst_folder , O_DIR)) == FILEHND_INVALID) {
				ds_printf("Error folder '%s' not found\n" ,dst_folder); 
				return;
			}
			
			dirent_t *dir;
			
			while ((dir = fs_readdir(fd))){
				if (!strcmp(dir->name,".") || !strcmp(dir->name,"..")) continue;
				strcpy(dst_file,"\0");
				snprintf(dst_file, MAX_FN_LEN, "%s/%s", dst_folder, dir->name);
				fs_unlink(dst_file);
			}
			fs_close(fd);
			fs_rmdir(dst_folder);
			return;	
		}
		
		
	}
	GUI_ProgressBarSetPosition(self.pbar, 0.0);
	cdrom_spin_down();
	stoptimer = timer_ms_gettime64 (); // timer
	riptime = stoptimer - starttimer;
	int ripmin = riptime / 60000 ;
	int ripsec = riptime % 60 ;
	ds_printf("DS_OK: End ripping. Save at %d:%d\n",ripmin,ripsec);
}