emulator for the original Sony PlayStation (or PS1/PSX). Still a WIP, but can now run a decent number of games.
emulator for the original Sony PlayStation (or PS1/PSX). Still a WIP, but can now run a decent number of games.
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
Things i couldn’t add because it wouldn’t let me post the full devlog even though it was under 2000 chars:
I haven’t really made much progress over the holidays (lack of motivation), but I have gotten controllers almost fully working! This means instead of using my keyboard to use the emulator I can use an actual controller (e.g a dualshock 4).
Getting basic controller input was pretty simple, although it took a while since i was a bit rusty from doing basically no coding since SoM. Initially I made Gilrs (the gamepad input library) select the first controller that connects to receive from, but for some reason my computer has a non-existent gamepad called HID-compliant game controller which always connects first, so annoyingly I had to hardcode it to not connect to controllers with that name :/.
Getting analog input to work was a bit more complicated, as in the emulator i was emulating the digital controller (which doesnt have joysticks). I decided to instead emulate the dual analog joypad (which was only on sale for a year before it was replaced with the dualshock 1), which has two joysticks but doesn’t have vibration motors. I chose not to emulate the dualshock 1 because it uses a different communication sequence which can stop games from booting if not implemented perfectly.
After that i wanted to start improving the CDROM drive emulation - in particular I wanted to improve CDDA audio sound quality (there is a buzzing noise in the background of every CDDA track for some reason), and get the BIOS CD player/audio visualiser working. For now I have hacked in support for the CD player by making the bios think all CDs are audio CDs. To get the audio visualiser working I needed to implement a weird edge case where 16-bit writes to the DMA controller are treated like 32-bit writes (the BIOS writes 16 bits when it should be writing 32 bits). Getting all this working should hopefully make debugging CDDA audio easier.
Video: the BIOS CD player / audio visualiser (i’m also using a controller in this clip, but you cant see that obviously).
I haven’t had a chance to work on my emulator for about 3 months (since SoM finished), so im hoping to make progress towards actually finishing this emulator over the winter holidays (you can’t really ever finish an emulator though - you can always improve the accuracy).
\n
What im hoping to get done:
Log in to leave a comment