// start the CDDA playback static void startCDDA(unsigned int offset) { if (playing) { if (initial_offset == offset) { return; } stopCDDA(); } cddaHandle = fopen(GetIsoFile(), "rb"); if (cddaHandle == NULL) { return; } initial_offset = offset; cddaCurOffset = initial_offset; fseek(cddaHandle, initial_offset, SEEK_SET); playing = TRUE; #ifdef _WIN32 threadid = (HANDLE)_beginthread(playthread, 0, NULL); #else pthread_create(&threadid, NULL, playthread, NULL); #endif }
// This function is invoked by the front-end when opening an ISO // file for playback static long CALLBACK ISOopen(void) { u32 modeTest = 0; if (cdHandle != NULL) { return 0; // it's already open } cdHandle = fopen(GetIsoFile(), "rb"); if (cdHandle == NULL) { return -1; } SysPrintf(_("Loaded CD Image: %s"), GetIsoFile()); cddaBigEndian = FALSE; subChanMixed = FALSE; subChanRaw = FALSE; isMode1ISO = FALSE; if (parseccd(GetIsoFile()) == 0) { SysPrintf("[+ccd]"); } else if (parsemds(GetIsoFile()) == 0) { SysPrintf("[+mds]"); } else if (parsecue(GetIsoFile()) == 0) { SysPrintf("[+cue]"); } else if (parsetoc(GetIsoFile()) == 0) { SysPrintf("[+toc]"); } else { //guess whether it is mode1/2048 fseek(cdHandle, 0, SEEK_END); if(ftell(cdHandle) % 2048 == 0) { fseek(cdHandle, 0, SEEK_SET); fread(&modeTest, 4, 1, cdHandle); if(SWAP32(modeTest)!=0xffffff00) isMode1ISO = TRUE; } fseek(cdHandle, 0, SEEK_SET); } if (!subChanMixed && opensubfile(GetIsoFile()) == 0) { SysPrintf("[+sub]"); } SysPrintf(".\n"); PrintTracks(); return 0; }
int LoadPlugins(void) { int ret; const char *cdrfilename=NULL; ReleasePlugins(); LoadMcds(Config.Mcd1, Config.Mcd2); ret = CDR_init(); if (ret < 0) { printf ("Error initializing CD-ROM plugin: %d\n", ret); return -1; } ret = GPU_init(); if (ret < 0) { printf ("Error initializing GPU plugin: %d\n", ret); return -1; } ret = SPU_init(); if (ret < 0) { printf ("Error initializing SPU plugin: %d\n", ret); return -1; } #ifdef spu_pcsxrearmed //senquack - NOTE: this is an important function to call, as SPU // IRQs will not be acknowledged otherwise, leading to repeating sound // problems in games like NFS3, Grandia, Fifa98, and some games will // lack music like Chrono Cross FMV music, THPS2 etc. // Only spu_pcsxrearmed supports this (older SPU plugins all had // problems with sound in these games.. TODO: add support?) SPU_registerCallback(AcknowledgeSPUIRQ); //senquack - pcsx_rearmed SPU plugin schedules its own updates: SPU_registerScheduleCb(ScheduleSPUUpdate); #endif cdrfilename=GetIsoFile(); if (cdrfilename[0] != '\0') { ret=CDR_open(); if (ret < 0) { printf ("Error opening CD-ROM: %s\n", cdrfilename); return -1; } } printf("Plugins loaded.\n"); return 0; }
// This function is invoked by the front-end when opening an ISO // file for playback static long CALLBACK ISOopen(void) { boolean isMode1ISO = FALSE; char alt_bin_filename[MAXPATHLEN]; const char *bin_filename; if (cdHandle != NULL) { return 0; // it's already open } cdHandle = fopen(GetIsoFile(), "rb"); if (cdHandle == NULL) { SysPrintf(_("Could't open '%s' for reading: %s\n"), GetIsoFile(), strerror(errno)); return -1; } SysPrintf(_("Loaded CD Image: %s"), GetIsoFile()); cddaBigEndian = FALSE; subChanMixed = FALSE; subChanRaw = FALSE; pregapOffset = 0; cdrIsoMultidiskCount = 1; multifile = 0; CDR_getBuffer = ISOgetBuffer; cdimg_read_func = cdread_normal; if (parsetoc(GetIsoFile()) == 0) { SysPrintf("[+toc]"); } else if (parseccd(GetIsoFile()) == 0) { SysPrintf("[+ccd]"); } else if (parsemds(GetIsoFile()) == 0) { SysPrintf("[+mds]"); } else if (parsecue(GetIsoFile()) == 0) { SysPrintf("[+cue]"); } if (handlepbp(GetIsoFile()) == 0) { SysPrintf("[pbp]"); CDR_getBuffer = ISOgetBuffer_compr; cdimg_read_func = cdread_compressed; } else if (handlecbin(GetIsoFile()) == 0) { SysPrintf("[cbin]"); CDR_getBuffer = ISOgetBuffer_compr; cdimg_read_func = cdread_compressed; } if (!subChanMixed && opensubfile(GetIsoFile()) == 0) { SysPrintf("[+sub]"); } if (opensbifile(GetIsoFile()) == 0) { SysPrintf("[+sbi]"); } fseek(cdHandle, 0, SEEK_END); // maybe user selected metadata file instead of main .bin .. bin_filename = GetIsoFile(); if (ftell(cdHandle) < 2352 * 0x10) { static const char *exts[] = { ".bin", ".BIN", ".img", ".IMG" }; FILE *tmpf = NULL; size_t i; char *p; strncpy(alt_bin_filename, bin_filename, sizeof(alt_bin_filename)); alt_bin_filename[MAXPATHLEN - 1] = '\0'; if (strlen(alt_bin_filename) >= 4) { p = alt_bin_filename + strlen(alt_bin_filename) - 4; for (i = 0; i < sizeof(exts) / sizeof(exts[0]); i++) { strcpy(p, exts[i]); tmpf = fopen(alt_bin_filename, "rb"); if (tmpf != NULL) break; } } if (tmpf != NULL) { bin_filename = alt_bin_filename; fclose(cdHandle); cdHandle = tmpf; fseek(cdHandle, 0, SEEK_END); } } // guess whether it is mode1/2048 if (ftell(cdHandle) % 2048 == 0) { unsigned int modeTest = 0; fseek(cdHandle, 0, SEEK_SET); fread(&modeTest, 4, 1, cdHandle); if (SWAP32(modeTest) != 0xffffff00) { SysPrintf("[2048]"); isMode1ISO = TRUE; } } fseek(cdHandle, 0, SEEK_SET); SysPrintf(".\n"); PrintTracks(); if (subChanMixed) cdimg_read_func = cdread_sub_mixed; else if (isMode1ISO) cdimg_read_func = cdread_2048; // make sure we have another handle open for cdda if (numtracks > 1 && ti[1].handle == NULL) { ti[1].handle = fopen(bin_filename, "rb"); } cdda_cur_sector = 0; cdda_file_offset = 0; return 0; }
// This function is invoked by the front-end when opening an ISO // file for playback static long ISOopen(void) { boolean isMode1ISO = FALSE; if (cdHandle != NULL) { return 0; // it's already open } cdHandle = fopen(GetIsoFile(), "rb"); if (cdHandle == NULL) { return -1; } SysPrintf("Loaded CD Image: %s", GetIsoFile()); cddaBigEndian = FALSE; subChanMixed = FALSE; subChanRaw = FALSE; pregapOffset = 0; CDR_getBuffer = ISOgetBuffer; cdimg_read_func = cdread_normal; if (parsecue(GetIsoFile()) == 0) { SysPrintf("[+cue]"); } else if (parsetoc(GetIsoFile()) == 0) { SysPrintf("[+toc]"); } else if (parseccd(GetIsoFile()) == 0) { SysPrintf("[+ccd]"); } else if (parsemds(GetIsoFile()) == 0) { SysPrintf("[+mds]"); } else if (parsepbp(GetIsoFile()) == 0) { SysPrintf("[pbp]"); CDR_getBuffer = ISOgetBuffer_compr; cdimg_read_func = cdread_compressed; } if (!subChanMixed && opensubfile(GetIsoFile()) == 0) { SysPrintf("[+sub]"); } if (opensbifile(GetIsoFile()) == 0) { SysPrintf("[+sbi]"); } // guess whether it is mode1/2048 fseek(cdHandle, 0, SEEK_END); if (ftell(cdHandle) % 2048 == 0) { unsigned int modeTest = 0; fseek(cdHandle, 0, SEEK_SET); fread(&modeTest, 4, 1, cdHandle); if (SWAP32(modeTest) != 0xffffff00) { SysPrintf("[2048]"); isMode1ISO = TRUE; } } fseek(cdHandle, 0, SEEK_SET); SysPrintf(".\n"); PrintTracks(); if (subChanMixed) cdimg_read_func = cdread_sub_mixed; else if (isMode1ISO) cdimg_read_func = cdread_2048; // make sure we have another handle open for cdda if (numtracks > 1 && ti[1].handle == NULL) { ti[1].handle = fopen(GetIsoFile(), "rb"); } cdda_cur_sector = cdda_start_sector = 0; return 0; }