Closed fafling closed 3 years ago
OK, I got to reproduce it in Bizhawk. Real hardware (with Satiator) failed to reproduce the bug in multiple tested demos (jo_demo, my game, a testing demo, metal orange, and wolf3d). The bug from Bizhawk (which could be a different emulator-unrelated bug) sounded like the pitchword was improperly set (which would be a bug in the linked library). The issue also did not occur after the first soft reset. The game crashed after the first soft-reset and then soft-reset itself again after pressing START (without ABC being held). Then the issue occurred.
I doubt its a deeper issue than an emulator one, but you did say you reproduced it on hardware. I'm curious to see it recorded from an NTSC system.
As per discussion on Discord, the issue has been narrowed down slightly to occurring only on 320-wide resolutions (and by extension, 640-wide). 352-wide resolutions (or 704) are unaffected.
If anyone out there does care about this issue, there are two solutions: A - Use a 352-wide resolution. It increases the system clock speed, you might as well do it. B - If for some reason you do not want to use a 352-wide (or 704) resolution, follow the procedures to initialize the system at a 352-wide resolution then switch back to whatever resolution you want.
In load_driver_binary in pcm_sys.c, if I clear the SCSP slot register area, the sounds are no longer distorted after a reset via multiplayer.
void load_driver_binary(Sint8 * filename, void * buffer, int master_adx_frequency)
{
GfsHn s_gfs;
Sint32 file_size;
Sint32 local_name = GFS_NameToId(filename);
//Open GFS
s_gfs = GFS_Open((Sint32)local_name);
//Get file information (mostly, the file size)
GFS_GetFileInfo(s_gfs, NULL, NULL, &file_size, NULL);
GFS_Close(s_gfs);
GFS_Load(local_name, 0, (Uint32 *)buffer, file_size);
//The immediacy of these commands is important.
//As per SEGA technical bulletin 51, the Sound CPU is not to be turned off for more than 0.5 seconds.
// Turn off Sound CPU
smpc_issue_command(SMPC_CMD_SNDOFF);
smpc_wait_till_ready();
//Set max master volume + 4mbit memory
*master_volume = 0x20F;
// Clear SCSP Slot Control Register
for (int i = 0; i < 508; i+=2){
*(volatile unsigned short *)(SNDRAM + 0x100000 + i) = 0x0000;
}
//Copy the driver binary (code) over to sound RAM. The binary includes the vector table information.
slDMACopy(buffer, (void*)SNDRAM, file_size);
slDMAWait();
//Set the ADX coefficients for the driver to use, if one was selected.
if(master_adx_frequency == ADX_MASTER_768)
{
m68k_com->drv_adx_coef_1 = ADX_768_COEF_1;
m68k_com->drv_adx_coef_2 = ADX_768_COEF_2;
} else if(master_adx_frequency == ADX_MASTER_1152){
m68k_com->drv_adx_coef_1 = ADX_1152_COEF_1;
m68k_com->drv_adx_coef_2 = ADX_1152_COEF_2;
} else if(master_adx_frequency == ADX_MASTER_1536){
m68k_com->drv_adx_coef_1 = ADX_1536_COEF_1;
m68k_com->drv_adx_coef_2 = ADX_1536_COEF_2;
} else if(master_adx_frequency == ADX_MASTER_2304){
m68k_com->drv_adx_coef_1 = ADX_2304_COEF_1;
m68k_com->drv_adx_coef_2 = ADX_2304_COEF_2;
} else {
m68k_com->drv_adx_coef_1 = 1;
m68k_com->drv_adx_coef_2 = 1;
}
// Turn on Sound CPU again
smpc_wait_till_ready();
smpc_issue_command(SMPC_CMD_SNDON);
//
}
vbt-senpai said he tested that.... Anyway, will push into the repo.
I confirm that the problem is solved in the demo with the updated driver 👍
On the console with the Satiator and in Kronos v2.1.5, when jo_demo is launched from the multiplayer screen, all sounds are distorted.
In Kronos, maintain A when launching the iso or when resetting until multiplayer screen displays, then select "Start application".
On the console with the Satiator, launch the demo once, then maintain A when pressing reset until multiplayer screen displays and select "Start application".
In both case, the problem doesn't occur when resetting without going through multiplayer screen.