I started work on the MDEC (Macroblock Decoder / video decoder), and It’s going pretty well so far. Emulating it is pretty simple since it only has three commands, and all the decoding logic is documented as pseudocode on PSX-SPX, so it was straightforward to translate that to rust code.
So far I’ve only implemented decoding 4bit and 8bit colour-depth (monochrome) frames, and I ran into an issue where the test I was using was either outputting garbage or a white square. After A few hours of debugging I eventually figured out that this was causing by:
- Not writing to the quant tables and scale table properly (I wasn’t converting u32 input words into u8s and i16s properly)
- Not clipping the output to 9bit range correctly
After fixing those two issues I’m now decoding video properly! Unfortunately not a single PS1 game actually uses the 4bit/8bit modes, so I cant actually play any videos yet :/. At least now I can run the 4bit/8bit MDEC tests (which just prints a tiny heart to the screen).
Next I’m going to work on the 15bit and 24bit colour modes so I can actually play FMVs in my emulator (which should fix the majority of games that have issues atm).
Image: the 8bit MDEC test running correctly
Log in to leave a comment