X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=pcsx_rearmed.git;a=blobdiff_plain;f=libpcsxcore%2Fcdrom.c;h=d9a3bb37cd05372f3f2369557b55c0acf3495051;hp=343d82c96eb2d29053889cdf5c8bd77f536af3f4;hb=42f3c5125fcb99e1445dfb7ca3d1b21330cde414;hpb=aa40e1b827555d6efb0cb9177b015ec02d44c7dd diff --git a/libpcsxcore/cdrom.c b/libpcsxcore/cdrom.c index 343d82c9..d9a3bb37 100644 --- a/libpcsxcore/cdrom.c +++ b/libpcsxcore/cdrom.c @@ -709,11 +709,12 @@ void cdrInterrupt() { Wild 9: skip PREGAP + starting accurate SubQ - plays tracks without retry play */ + /* unneeded with correct cdriso? Set_Track(); + */ Find_CurTrack(); ReadTrack( cdr.SetSectorPlay ); - // GameShark CD Player: Calls 2x + Play 2x if( cdr.FastBackward || cdr.FastForward ) { if( cdr.FastForward ) cdr.FastForward--; @@ -861,7 +862,17 @@ void cdrInterrupt() { cdr.Result[0] = cdr.StatP; cdr.Stat = Acknowledge; - AddIrqQueue(CdlPause + 0x20, 0x800); + /* + Gundam Battle Assault 2: much slower (*) + - Fixes boot, gameplay + + Hokuto no Ken 2: slower + - Fixes intro + subtitles + + InuYasha - Feudal Fairy Tale: slower + - Fixes battles + */ + AddIrqQueue(CdlPause + 0x20, cdReadTime * 3); cdr.Ctrl |= 0x80; break; @@ -978,10 +989,9 @@ void cdrInterrupt() { } // redump.org - wipe time - /*if( !cdr.Play && CheckSBI(cdr.Result+5) ) { + if( !cdr.Play && CheckSBI(cdr.Result+5) ) { memset( cdr.Result+2, 0, 6 ); } - */ cdr.Stat = Acknowledge; break; @@ -1207,13 +1217,15 @@ void cdrInterrupt() { // - fixes cutscene speech { u8 *buf = CDR_getBuffer(); - memcpy(cdr.Transfer, buf, 8); + if (buf != NULL) + memcpy(cdr.Transfer, buf, 8); } /* Duke Nukem: Land of the Babes - seek then delay read for one frame - fixes cutscenes + C-12 - Final Resistance - doesn't like seek */ if (!cdr.Seeked) { @@ -1318,14 +1330,34 @@ void cdrReadInterrupt() { int ret = xa_decode_sector(&cdr.Xa, cdr.Transfer+4, cdr.FirstSector); if (!ret) { + // only handle attenuator basic channel switch for now + if (cdr.Xa.stereo) { + int i; + if ((cdr.AttenuatorLeft[0] | cdr.AttenuatorLeft[1]) + && !(cdr.AttenuatorRight[0] | cdr.AttenuatorRight[1])) + { + for (i = 0; i < cdr.Xa.nsamples; i++) + cdr.Xa.pcm[i*2 + 1] = cdr.Xa.pcm[i*2]; + } + else if (!(cdr.AttenuatorLeft[0] | cdr.AttenuatorLeft[1]) + && (cdr.AttenuatorRight[0] | cdr.AttenuatorRight[1])) + { + for (i = 0; i < cdr.Xa.nsamples; i++) + cdr.Xa.pcm[i*2] = cdr.Xa.pcm[i*2 + 1]; + } + } + SPU_playADPCMchannel(&cdr.Xa); cdr.FirstSector = 0; - +#if 0 // Crash Team Racing: music, speech + // - done using cdda decoded buffer (spu irq) + // - don't do here // signal ADPCM data ready psxHu32ref(0x1070) |= SWAP32((u32)0x200); +#endif } else cdr.FirstSector = -1; } @@ -1442,6 +1474,7 @@ unsigned char cdrRead1(void) { } void cdrWrite1(unsigned char rt) { + char set_loc[3]; int i; #ifdef CDR_LOG @@ -1451,7 +1484,7 @@ void cdrWrite1(unsigned char rt) { // Tekken: CDXA fade-out if( (cdr.Ctrl & 3) == 3 ) { - //cdr.AttenuatorRight[0] = rt; + cdr.AttenuatorRight[0] = rt; } @@ -1490,9 +1523,12 @@ void cdrWrite1(unsigned char rt) { case CdlSetloc: StopReading(); - cdr.Seeked = FALSE; for (i = 0; i < 3; i++) - cdr.SetSector[i] = btoi(cdr.Param[i]); + set_loc[i] = btoi(cdr.Param[i]); + i = abs(msf2sec(cdr.SetSector) - msf2sec(set_loc)); + if (i > 16) + cdr.Seeked = FALSE; + memcpy(cdr.SetSector, set_loc, 3); cdr.SetSector[3] = 0; /* @@ -1610,17 +1646,7 @@ void cdrWrite1(unsigned char rt) { cdr.Ctrl |= 0x80; cdr.Stat = NoIntr; - /* - Gundam Battle Assault 2: much slower (*) - - Fixes boot, gameplay - - Hokuto no Ken 2: slower - - Fixes intro + subtitles - - InuYasha - Feudal Fairy Tale: slower - - Fixes battles - */ - AddIrqQueue(cdr.Cmd, cdReadTime * 3); + AddIrqQueue(cdr.Cmd, 0x800); break; case CdlReset: @@ -1813,10 +1839,10 @@ void cdrWrite2(unsigned char rt) { // Tekken: CDXA fade-out if( (cdr.Ctrl & 3) == 2 ) { - //cdr.AttenuatorLeft[0] = rt; + cdr.AttenuatorLeft[0] = rt; } else if( (cdr.Ctrl & 3) == 3 ) { - //cdr.AttenuatorRight[1] = rt; + cdr.AttenuatorRight[1] = rt; } @@ -1858,7 +1884,7 @@ void cdrWrite3(unsigned char rt) { #ifdef CDR_LOG CDR_LOG("cdrWrite3() Log: CD3 write: %x\n", rt); #endif -/* + // Tekken: CDXA fade-out if( (cdr.Ctrl & 3) == 2 ) { cdr.AttenuatorLeft[1] = rt; @@ -1870,7 +1896,7 @@ void cdrWrite3(unsigned char rt) { cdr.AttenuatorRight[0], cdr.AttenuatorRight[1] ); #endif } -*/ + // GameShark CDX CD Player: Irq timing mania if( rt == 0 && @@ -1898,11 +1924,15 @@ void cdrWrite3(unsigned char rt) { // - Final Fantasy Tactics // - various other games - /* if (cdr.Reading && !cdr.ResultReady) { - CDREAD_INT((cdr.Mode & MODE_SPEED) ? (cdReadTime / 2) : cdReadTime); + int left = psxRegs.intCycle[PSXINT_CDREAD].sCycle + psxRegs.intCycle[PSXINT_CDREAD].cycle - psxRegs.cycle; + int time = (cdr.Mode & MODE_SPEED) ? (cdReadTime / 2) : cdReadTime; + if (Config.CdrReschedule != 2) + if (left < time / 2 || Config.CdrReschedule) { // rearmed guesswork hack + //printf("-- resched %d -> %d\n", left, time); + CDREAD_INT(time); + } } - */ return; } @@ -1929,6 +1959,7 @@ void cdrWrite3(unsigned char rt) { void psxDma3(u32 madr, u32 bcr, u32 chcr) { u32 cdsize; + int size; u8 *ptr; #ifdef CDR_LOG @@ -1973,15 +2004,12 @@ void psxDma3(u32 madr, u32 bcr, u32 chcr) { - CdlPlay - Spams DMA3 and gets buffer overrun */ - - if( (cdr.pTransfer-cdr.Transfer) + cdsize > 2352 ) + size = CD_FRAMESIZE_RAW - (cdr.pTransfer - cdr.Transfer); + if (size > cdsize) + size = cdsize; + if (size > 0) { - // avoid crash - probably should wrap here - //memcpy(ptr, cdr.pTransfer, cdsize); - } - else - { - memcpy(ptr, cdr.pTransfer, cdsize); + memcpy(ptr, cdr.pTransfer, size); } psxCpu->Clear(madr, cdsize / 4); @@ -2010,8 +2038,11 @@ void psxDma3(u32 madr, u32 bcr, u32 chcr) { void cdrDmaInterrupt() { - HW_DMA3_CHCR &= SWAP32(~0x01000000); - DMA_INTERRUPT(3); + if (HW_DMA3_CHCR & SWAP32(0x01000000)) + { + HW_DMA3_CHCR &= SWAP32(~0x01000000); + DMA_INTERRUPT(3); + } } void cdrReset() { @@ -2019,6 +2050,12 @@ void cdrReset() { cdr.CurTrack = 1; cdr.File = 1; cdr.Channel = 1; + + // BIOS player - default values + cdr.AttenuatorLeft[0] = 0x80; + cdr.AttenuatorLeft[1] = 0x00; + cdr.AttenuatorRight[0] = 0x80; + cdr.AttenuatorRight[1] = 0x00; } int cdrFreeze(gzFile f, int Mode) { @@ -2036,9 +2073,13 @@ int cdrFreeze(gzFile f, int Mode) { gzfreeze(&tmp, sizeof(tmp)); - if (Mode == 0) + if (Mode == 0) { cdr.pTransfer = cdr.Transfer + tmp; + if (cdr.Play && !Config.Cdda) + CDR_play(cdr.SetSectorPlay); + } + return 0; }