libretro / libretro-meta

The Unlicense
4 stars 3 forks source link

per-game custom palettes #51

Closed sergiobenrocha2 closed 7 years ago

sergiobenrocha2 commented 7 years ago

From @eadmaster on June 7, 2012 12:14

Vanilla Gambatte also supports per-game custom palettes (they are saved in "%APPDATA%\gambatte\palettes"). How to use them with RetroArch?

Copied from original issue: libretro/gambatte-libretro#2

sergiobenrocha2 commented 7 years ago

From @eadmaster on August 27, 2012 18:42

since now we have a "system_directory" option, shall we look here for them?

sergiobenrocha2 commented 7 years ago

From @Themaister on August 27, 2012 19:4

Certainly possible. Could you implement it? I wouldn't be able to look at this until some other time.

sergiobenrocha2 commented 7 years ago

From @eadmaster on August 27, 2012 19:53

I need to setup the build environment and i have to study the code a bit, so i'm not able to help at the moment, sorry!

sergiobenrocha2 commented 7 years ago

From @eadmaster on January 4, 2013 23:18

this should be easy to fix: just add a few lines into https://github.com/libretro/gambatte-libretro/blob/master/libgambatte/libretro/libretro.cpp in the function "retro_load_game", after the rom is loaded, check if exists a file named "$system_directory/palettes/$input_rom_basename.pal". If yes, load the palette colors with "setDmgPaletteColor(unsigned palNum, unsigned colorNum, unsigned rgb32)" using 2 nested for loops like those in https://github.com/libretro/gambatte-libretro/blob/master/gambatte_qt/src/gambattemenuhandler.cpp (line 554)

Here it is an example of a .pal file:

[General]
Background0=11846369
Background1=15851184
Background2=9917014
Background3=0
Sprite%2010=0
Sprite%2011=16316664
Sprite%2012=14778518
Sprite%2013=8337480
Sprite%2020=0
Sprite%2021=16316664
Sprite%2022=14778518
Sprite%2023=8337480
slectedScheme=SUPER MARIOLAND
sergiobenrocha2 commented 7 years ago

From @Themaister on January 5, 2013 0:57

Please make a pull request. The feature is pretty far down on the TODO list atm for me at least.

sergiobenrocha2 commented 7 years ago

From @eadmaster on January 5, 2013 1:27

I haven't the compiler ready to test the results, so i prefer you to write the code...

EDIT: i've committed some skeleton code, if you need more help i can work on it tomorrow: https://github.com/eadmaster/gambatte-libretro/blob/master/libgambatte/libretro/libretro.cpp

sergiobenrocha2 commented 7 years ago

From @Themaister on January 5, 2013 11:37

Still need to parse the config file somehow. Any .ini reader code in gambatte?

sergiobenrocha2 commented 7 years ago

From @eadmaster on January 6, 2013 20:50

Gambatte is using the Qt builtin ini parser. Btw, since the palette file is so simple (without subsections), i think we could use a more lazy approach for parsing: (see my updated code)

sergiobenrocha2 commented 7 years ago

From @Themaister on January 6, 2013 23:20

Ye, looks simple enough that this is feasible. What platform are you on? Should be a simple matter to get a toolchain to test with.

sergiobenrocha2 commented 7 years ago

From @eadmaster on January 7, 2013 1:58

win7 64bit I have old Mingw, Cygwin and the SDL libraries installed, nothing else. Using mingw, "make -f Makefile.libretro" outputs:

Makefile.libretro:7: Extraneous text after `else' directive
Makefile.libretro:9: Extraneous text after `else' directive
Makefile.libretro:9: *** only one `else' per conditional.  Stop.
sergiobenrocha2 commented 7 years ago

From @Themaister on January 7, 2013 14:7

You probably have a really outdated MinGW setup. MinGW-w64 is the good stuff:

http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Automated%20Builds/ The latest one I see right now is: http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Automated%20Builds/mingw-w64-bin_i686-mingw_20111220.zip/download

Download, set PATH correctly, and you should be good to go.

sergiobenrocha2 commented 7 years ago

From @eadmaster on January 7, 2013 20:32

ok, i still have to add some code, when it's ready i'll warn you. I will also try to add GBC BIOS palettes to fix issue 1: https://github.com/libretro/gambatte-libretro/issues/1

sergiobenrocha2 commented 7 years ago

From @eadmaster on January 8, 2013 19:55

I've verified custom palettes are now working on my fork! I still need to do some testing and add GBC builtin BIOS palettes (i need to add an header file to store them).

Super Game Boy support would also be nice, but this was not present in vanilla Gambatte...

sergiobenrocha2 commented 7 years ago

From @Themaister on January 8, 2013 20:30

Great stuff. Please submit a pull request once you feel happy with your code :)