SDL1 to SDL2 port of small flxplayer

On the libsdl page we have in projects this one:

This is small amd simle anim player. While it works fine on SDL1, we tried to migrate it to SDL2 following migration guide, but stack on the “palette” based things. I.e. all works, windows creates, rendering going on, but we do have some mess of pixels, like, wrong pixel format is here. Can anyone plz have a look at this and made SDL2 compatible changes as well ?

There is what we have , maybe someone can spot an obvious errors there. All the code done via idef USE_SDL2 , so easy to follow:

Thanks in advance !