stella icon indicating copy to clipboard operation
stella copied to clipboard

(libretro) ERROR: invalid palette file ./stella.pal

Open keithbowes opened this issue 3 years ago • 7 comments

Hm. It's weird that it's not searching in the system directory instead of the current directory. It's also weird that it's searching for a palette when a pre-defined palette is being used.

keithbowes avatar Mar 17 '21 22:03 keithbowes

This error can be ignored for now. The problem is that the filesystem code for libretro in Stella is incomplete; it only works for loading ROMs, and nothing else. So, when Stella looks for an external palette file, the current code loads from something else, sees that it's invalid data, and prints the message you see.

To properly fix this, the filesystem code would need to be reworked. This is a low-priority task, since it's not causing any problems at the moment. I'm not sure if I will fix this in the current Stella code, or wait until C++17 has proper cross-platform filesystem handling, and then use that to fix it.

sa666666 avatar Mar 17 '21 22:03 sa666666

Would it help to skip loading the user defined palette when a different palette options is chosen? And load the palette on demand only?

thrust26 avatar May 04 '21 07:05 thrust26

Loading the palette won't work at all. The issue is that the FSNodeLIBRETRO class is merely a skeleton class that is (ab)used to load ROM files only. And most of the other methods are stubbed out.

To fix this would require expanding that class to handle filesystem operations, like FSNodePOSIX, FSNodeWindows, etc. There are three ways to fix this completely:

  • port the above classes to FSNodeLIBRETRO, and detect at compile-time which to use (essentially duplicating code from Stella mainline)
  • make use of cross-platform filesystem code from libretro itself, and adapt FSNodeLIBRETRO to use that (if that functionality exists, of course)
  • the best option: use C++17 filesystem API, where the cross-platform functionality is built into C++ itself

I really want to use the last one, since there's some pretty hairy code in FSNode and friends that I want to kill. But I haven't had time to research that yet, hence why this is a low priority issue.

sa666666 avatar May 04 '21 20:05 sa666666

I meant, if we only load on demand, then the error you mentioned above would not happen as long as no user palette is selected.

Also it would become possible to reload the palette without exiting Stella.

thrust26 avatar May 04 '21 20:05 thrust26

Right, from that POV it makes sense. Perhaps all I mentioned above belongs in an issue of its own.

sa666666 avatar May 04 '21 20:05 sa666666

I think I can fix that in minute, we don't need a separate issue.

thrust26 avatar May 04 '21 20:05 thrust26

See 54af43426. This should suppress the error showing.

thrust26 avatar Sep 04 '21 08:09 thrust26

This is now fixed in the commit above. The C++17 filesystem stuff is being worked on, and is not related to this specific issue.

sa666666 avatar Oct 10 '22 00:10 sa666666