libretro / libretro-cap32

caprice32 4.2.0 libretro
21 stars 34 forks source link

SNA support broken ? #105

Closed FabLafarge closed 2 years ago

FabLafarge commented 2 years ago

Loading a SNA file seems broken at the moment. The CPC just sits at the usual BASIC prompt instead of running the snapshot.

DSkywalk commented 2 years ago

Tested on lastest retroarch/core (standalone 1.10.0/cap32 - 4.5.2 b8f09a0) and working as expected :+1:

FabLafarge commented 2 years ago

Tested again, doesn't work here :

Steps to reproduce :

Reproduced on Windows and PSPVita builds. 00 01 02 03

FabLafarge commented 2 years ago

Further investigation seems to indicate SNA support may be incomplete

Enabling verbose logging and attempting to load produces the following log :

SNA Error (18): C:\Temp\Fruity Frank.sna (0)=1
 (1)=1

which would indicate this error: ERR_SNA_SIZE

This particular snapshot is 47.110 bytes in size, which would indicate some kind of compression. This file is valid with other emulators such as CPCEC.

I imagine SNA loading works fine with snapshots generated by the core itself, but will often fail with third party SNAs fetched off the internet.

FabLafarge commented 2 years ago

Had a dive into the code, and my findings so far are :

typedef struct {
   char id[8+1];
   char unused1[8];
   unsigned char version;
FabLafarge commented 2 years ago

Good news: I made a build changing this

typedef struct {
   char id[8+1];
   char unused1[8];
   unsigned char version;

to this

typedef struct {
   char id[8+1];
   char unused1[7];
   unsigned char version;

and the core now loads successfully thirdparty uncompressed snapshots :)

DSkywalk commented 2 years ago

We may have to make an old SNA converter, but it can be prepared as a contrib with a small python script. I prefer your solution and that the SNA is as the format that was decided as standard. Thank you very much.