Still haven’t had a lot of time to work on this because of school but I have made a bit of progress.
I finally figured out why CD audio was making a buzzing noise, it was a really stupid bug lol: When I was reading the audio sector, I wasn’t including the first 12 bytes, since in data sectors those bytes aren’t included in reads, but CDDA audio uses the entire sector, so I was skipping 12 bytes of every 2352 byte sector, causing a high-pitched buzzing noise. I thought it was something complicated like an issue with volume clamping or the SPU (PS1’s sound chip), but no it was super simple and was just a 4 line fix lol.
Another stupid bug that I’ve been stumped by for months is this issue where a game will start sending garbage data to the GPU, overwriting all the textures. Again, I thought it had to be something super complicated, so I combed through all my CDROM code to try and find an issue with how I was reading data from the disc, and I found a few minor bugs but it didn’t fix what I was trying to fix (I was stuck on this for ages lol). I Also looked at the DMA controller but still nothing (although I did find some clues).
By this point its 4am so I went to bed, but in the morning I discovered the actual cause of the bug, and it was literally two characters that were causing this whole thing. In the GPU, I was storing the length of the transfer in a u16 instead of a u32, so if the transfer length was two large it would just truncate the value to 16 bits and the GPU would go out of sync with the DMAC, causing it to interpret DMA data as GPU commands, corrupting VRAM. To fix this I just changed it from u16 to u32. I stayed up all night trying to fix this and the fix was just 2 characters >:(
This fixing this one issue fixed most of the games that weren’t working before (to some degree at least)! Next I’m going to work on the video decoder (MDEC).
Log in to leave a comment
Comments
Things i couldn’t add because it wouldn’t let me post the full devlog even though it was under 2000 chars:
- One of the reasons I thought it was a CDROM issue for so long was that Wipeout 2097 kept printing CDROM read errors which I thought was related to this
- A lot of bugs are super agonising like this in emulators because there are so many complicated, interconnected systems that can cause issues and its very difficult to debug them when something goes wrong.
- Some of the games that have been fixed include: Spyro, Gran Turismo 1, Wipeout 2097, Quake II, Colin McRae Rally, and Driver (gets to the menu)