unknownbrackets / maxcso

Fast cso compressor
ISC License
402 stars 23 forks source link

Adding CSO support to HPSX64 #28

Closed Zero3K closed 5 years ago

Zero3K commented 5 years ago

It would be nice if that were done for the PS2 emulator that is a part of it (and the PS1 emulator that is a part of it if possible). Its links are as follows:

Homepage: https://sourceforge.net/projects/hpsx64/ Source Code: https://github.com/Zero3K/hpsx64

unknownbrackets commented 5 years ago

From a quick search of the code, I guess it would be here: https://github.com/Zero3K/hpsx64/blob/48a8bf5eb39f91370a9e155cdd4aebbf3e209077/common/DiskImage/cd/src/cdimage.cpp#L2033

I'm not sure I'm likely to look into this soon, but CSO is pretty darn simple. You can see PPSSPP's code here: https://github.com/hrydgard/ppsspp/blob/master/Core/FileSystems/BlockDevices.cpp#L216-L288

It's in Play! and PCSX2, with a similar implementation, matching the format documented in README_CSO.md.

-[Unknown]

unknownbrackets commented 5 years ago

Anyway, since this isn't really an issue in PPSSPP itself (more like an issue in hpsx64), I'm going to close it.

The code in maxcso to read / write CSOs is more complicated, because it uses multiple simultaneous threads for maximum throughput when decompressing / compressing. I don't recommend using it as a model to implement CSO reading in an emulator.

-[Unknown]

Zero3K commented 5 years ago

How would I (or someone else) implement the code that you linked to?

unknownbrackets commented 5 years ago

It seems like image right now maps directly to a file (and there's cue sheet handling to determine where to read from.) I'd suggest abstracting out the CSO logic to a separate class, and maybe have image be an interface (it might be most convenient for it to become a pointer.)

It seems like it would just need to support Read(Async|Sync), Create(Async|Sync), Size, and WaitAsync mainly.

This other class could then read the header on Create: https://github.com/hrydgard/ppsspp/blob/ce6cb7e7c92643ab6e65928cc4cb114ac0d6df5f/Core/FileSystems/BlockDevices.cpp#L133-L207

And then essentially the code I linked to before on Read or the more efficient option for multiple sectors: https://github.com/hrydgard/ppsspp/blob/ce6cb7e7c92643ab6e65928cc4cb114ac0d6df5f/Core/FileSystems/BlockDevices.cpp#L290-L381

Basically:

-[Unknown]

Zero3K commented 5 years ago

I have an issue with HPSX64 that I wrote more about at https://github.com/Zero3K/hpsx64/issues/1.

Zero3K commented 5 years ago

How do I contact the developer of HPSX64?

Zero3K commented 5 years ago

No one else is interested in adding it.