Exemple #1
0
/* Initialize for GD-ROM */
static int init_percd_gdrom() {
	int		i;
	CDROM_TOC	toc;

	/* Start off with no cached blocks */
	bclear();
	
	/* Locate the root session */
	if ((i = cdrom_reinit()) != 0)
		return i;
	if ((i = cdrom_read_toc(&toc, 1)) != 0)
		return i;
	if (!(session_base = cdrom_locate_data_track(&toc, 1)))
		return -1;

	/* Grab and check the volume descriptor */	
	i = bread(session_base + 16 - 150);
	if (i < 0) return i;
	if (memcmp((char*)cache[i]->data, "\01CD001", 6)) {
		printf("fs_iso9660: disc is not iso9660\r\n");
		return -1;
	}

	/* Locate the root directory */
	memcpy(&root_dirent, cache[i]->data+156, sizeof(iso_dirent_t));
	root_extent = iso_733(root_dirent.extent);
	root_size = iso_733(root_dirent.size);
	
	return 0;
}
Exemple #2
0
void gd_ripper_ipbin_name(){
	CDROM_TOC toc ;
	int status = 0, disc_type = 0, cdcr = 0, x = 0;
	char pbuff[2048] , text[MAX_FN_LEN];
	uint32 lba;

	cdrom_set_sector_size(2048);
	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;
			default:
				ds_printf("DS_ERROR: GD-rom error\n");
				return;
		}
	}
	if (disc_type == CD_CDROM_XA) {
		if(cdrom_read_toc(&toc, 0) != CMD_OK) { 
			ds_printf("DS_ERROR: Toc read error\n"); 
			return; 
		}
		if(!(lba = cdrom_locate_data_track(&toc))) {
			ds_printf("DS_ERROR: Error locate data track\n"); 
			return;
		}
		if (cdrom_read_sectors(pbuff,lba , 1)) {
			ds_printf("DS_ERROR: CD read error %d\n",lba); 
			return;
		}
	} else if (disc_type == CD_GDROM) {
		if (cdrom_read_sectors(pbuff,45150 , 1)) {
			ds_printf("DS_ERROR: GD read error\n"); 
			return;
		}
	}else {
		ds_printf("DS_ERROR: not game disc\n");
		return;
	}
	
	ipbin_meta_t *meta = (ipbin_meta_t*) pbuff;
	
	char *p;
	char *o;
	
	p = meta->title;
	o = text;

	// skip any spaces at the beginning
	while(*p == ' ' && meta->title + 29 > p) 
		p++;

	// copy rest to output buffer
	while(meta->title + 29 > p) { 
		*o = *p;
		p++; 
		o++; 
	}

	// make sure output buf is null terminated
	*o = '\0';
	o--;

	// remove trailing spaces
	while(*o == ' ' && o > text) {
		*o='\0';
		o--;
	}
	
	if (strlen(text) == 0) {
		GUI_TextEntrySetText(self.gname, "Game");	
	} else {
		for (x=0;text[x] !=0;x++) {
			if (text[x] == ' ') text[x] = '_' ;
		}
		GUI_TextEntrySetText(self.gname, text);
	}
	//ds_printf("Image name - %s\n",text);
}