Despite having an API that creates save state data into an user-provided buffer, some Libretro cores still create additional data as files. Additionally, Libretro save states don't feature a screenshot of the video frame buffer at the time the save state is created, making it impossible to preview the save state or restore the frame buffer when the save state is loaded back.
We also want to save data to completely restore the emulation state, like the core name and version, core options values, and any other data needed by the application.
To make it easier to put all this data into a single file, we'll use the RIFF format. RIFF is a chunked format, allowing us to save everything we need in an organized way.
All integers and float-point numbers are written in little-endian, and strings are null-terminated.