Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cdrom: rename mode constants to defineds #299

Merged
merged 1 commit into from
Jul 12, 2023
Merged

Conversation

anzz1
Copy link
Contributor

@anzz1 anzz1 commented Jul 12, 2023

minor cleanup

@anzz1
Copy link
Contributor Author

anzz1 commented Jul 12, 2023

was also wondering whether MODE_SPEED should be exposed as an option, correct me if I'm wrong but that is essentially the "2x speed" mode found on the PS2, right?

@notaz
Copy link
Owner

notaz commented Jul 12, 2023

PS1 has a 2x cdrom so games can enable double read speed.

@notaz notaz merged commit 32ac4c7 into notaz:master Jul 12, 2023
@anzz1
Copy link
Contributor Author

anzz1 commented Jul 12, 2023

PS1 has a 2x cdrom so games can enable double read speed.

Isn't that controlled by the BIOS rather than the games themselves? I'm not sure about this but I'm certain that PS2 does have a "PS1 disc read speed" option in the main menu (BIOS), which can be set to either Fast/Normal and Fast greatly reduces loading times on games which it works (which is most of them, but not all). That would imply that the speed isn't controlled by the games?

Also was thinking whether a tri-state config option would be good, like this:
CD Read Speed: 1x/2x/Instant
Where 'Instant' would eliminate the delay completely if there are some games/homebrew which don't rely on the cd access timings at all?

edit: according to this comment the PS2 fast mode reads the discs at 12X speed and PS1 is 2x , just like you said. So maybe a 'Fast' / 'PS2' mode then?

@anzz1
Copy link
Contributor Author

anzz1 commented Jul 12, 2023

I tried this quick-n-dirty speed hack to set read speed to 24x and it reduced loading times to basically nothing !
There was some bugs like FMVs playing too fast with this but there's definitely something here !

--- a/libpcsxcore/cdrom.c
+++ b/libpcsxcore/cdrom.c
@@ -135,7 +135,7 @@ unsigned char Test23[] = { 0x43, 0x58, 0x44, 0x32, 0x39 ,0x34, 0x30, 0x51 };
 // 1x = 75 sectors per second
 // PSXCLK = 1 sec in the ps
 // so (PSXCLK / 75) = cdr read time (linuzappz)
-#define cdReadTime (PSXCLK / 75)
+#define cdReadTime (PSXCLK / (75*12)) // 24x speed hack
 
 enum drive_state {
 	DRIVESTATE_STANDBY = 0,
@@ -780,8 +780,10 @@ void cdrInterrupt() {
 			}
 			else
 			{
-				delay = (((cdr.Mode & MODE_SPEED) ? 2 : 1) * (1000000));
-				CDRMISC_INT((cdr.Mode & MODE_SPEED) ? cdReadTime / 2 : cdReadTime);
+				//delay = (((cdr.Mode & MODE_SPEED) ? 2 : 1) * (1000000));
+				//CDRMISC_INT((cdr.Mode & MODE_SPEED) ? cdReadTime / 2 : cdReadTime);
+				delay = (2 * (1000000));
+				CDRMISC_INT(cdReadTime / 2);
 			}
 			AddIrqQueue(CdlPause + 0x100, delay);
 			cdr.Ctrl |= 0x80;
@@ -1045,7 +1047,8 @@ void cdrInterrupt() {
 			*/
 			cdr.StatP |= STATUS_READ;
 			cdr.StatP &= ~STATUS_SEEK;
-			CDREAD_INT(((cdr.Mode & 0x80) ? (cdReadTime) : cdReadTime * 2) + seekTime);
+			//CDREAD_INT(((cdr.Mode & 0x80) ? (cdReadTime) : cdReadTime * 2) + seekTime);
+			CDREAD_INT(cdReadTime + seekTime);
 
 			cdr.Result[0] = cdr.StatP;
 			start_rotating = 1;
@@ -1177,7 +1180,8 @@ void cdrReadInterrupt() {
 		memset(cdr.Transfer, 0, DATA_SIZE);
 		cdr.Stat = DiskError;
 		cdr.Result[0] |= STATUS_ERROR;
-		CDREAD_INT((cdr.Mode & 0x80) ? (cdReadTime / 2) : cdReadTime);
+		//CDREAD_INT((cdr.Mode & 0x80) ? (cdReadTime / 2) : cdReadTime);
+		CDREAD_INT(cdReadTime / 2);
 		return;
 	}
 
@@ -1237,7 +1241,8 @@ void cdrReadInterrupt() {
 
 	cdr.Readed = 0;
 
-	uint32_t delay = (cdr.Mode & MODE_SPEED) ? (cdReadTime / 2) : cdReadTime;
+	//uint32_t delay = (cdr.Mode & MODE_SPEED) ? (cdReadTime / 2) : cdReadTime;
+	uint32_t delay = (cdReadTime / 2);
 	if (cdr.m_locationChanged) {
 		CDREAD_INT(delay * 30);
 		cdr.m_locationChanged = FALSE;

@notaz
Copy link
Owner

notaz commented Jul 12, 2023

The games have to control it, for example when playing cdda the game has to enable 1x mode or else music will also play at double speed.

"instant" is not possible as it's not how it works. The game reads data in 2K sectors that it often has to process further. If you flood those sectors too fast you leave no time for processing and likely crash the game.

I don't see the benefit of 12x mode. People enable such options and forget and then report bugs, then tons of time is wasted by everyone involved figuring out why the game doesn't work for that specific user. The emulator and frontends already have "fast forward" key for skipping load times.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants