Esempio n. 1
0
int SDL_SYS_CDInit(void)
{
	metainit_t	metainit={0,0,0,0};
	metaopen_t	metaopen;
	int i, handle;
	struct cdrom_subchnl info;

	SDL_numcds = 0;
	SDL_memset(metados_drives, 0, sizeof(metados_drives));

	Metainit(&metainit);
	if (metainit.version == NULL) {
#ifdef DEBUG_CDROM
		fprintf(stderr, "MetaDOS not installed\n");
#endif
		return 0;
	}

	if (metainit.drives_map == 0) {
#ifdef DEBUG_CDROM
		fprintf(stderr, "No MetaDOS devices present\n");
#endif
		return 0;
	}

	for (i='A'; i<='Z'; i++) {
		metados_drives[SDL_numcds].device[0] = 0;
		metados_drives[SDL_numcds].device[1] = ':';
		metados_drives[SDL_numcds].device[2] = 0;

		if (metainit.drives_map & (1<<(i-'A'))) {
			handle = Metaopen(i, &metaopen);
			if (handle == 0) {

				info.cdsc_format = CDROM_MSF;
				if ( (Metaioctl(i, METADOS_IOCTL_MAGIC, CDROMSUBCHNL, &info) == 0) || ERRNO_TRAYEMPTY(errno) ) {
					metados_drives[SDL_numcds].device[0] = i;
					++SDL_numcds;
				}

				Metaclose(i);
			}
		}
	}

	/* Fill in our driver capabilities */
	SDL_CDcaps.Name = SDL_SYS_CDName;
	SDL_CDcaps.Open = SDL_SYS_CDOpen;
	SDL_CDcaps.Close = SDL_SYS_CDClose;

	SDL_CDcaps.GetTOC = SDL_SYS_CDGetTOC;
	SDL_CDcaps.Status = SDL_SYS_CDStatus;
	SDL_CDcaps.Play = SDL_SYS_CDPlay;
	SDL_CDcaps.Pause = SDL_SYS_CDPause;
	SDL_CDcaps.Resume = SDL_SYS_CDResume;
	SDL_CDcaps.Stop = SDL_SYS_CDStop;
	SDL_CDcaps.Eject = SDL_SYS_CDEject;

	return 0;
}
Esempio n. 2
0
static int SDL_SYS_CDOpen(int drive)
{
	int handle;

	handle = Metaopen(metados_drives[drive].device[0], &(metados_drives[drive].metaopen));
	if (handle == 0) {
		return drive;
	}

	return -1;
}