• MorphOS Developer
    Piru
    Posts: 429 from 2003/2/24
    From: finland, the l...
    Quote:

    kas1e wrote:
    @zukow
    Another thread where we tried to find an issue there:
    https://www.vogons.org/viewtopic.php?f=32&t=71547

    Jmarsh (author of that PPC JIT) keeps repeating that it's our SDLs and not all big-endian machines on the whole, and as an example, he says that he uses Wii and all the 15,16 and 32-bit modes work fine for him.

    Jmarsh is wrong.

    The reason he is wrong likely stems from the fact that the Wii uses little-endian 15- and 16-bit modes, and the SDL implementation doesn't perform SDL_Surface shadow byteswapping as needed, in which case the missing byte swapping goes unnoticed. It'll break for Wii if/when DOSBox code is fixed.

    SDL only specifies shift and mask values for the color guns. These are the only operations that are needed to convert color to specific SDL_Surface format. If the frame buffer would be byte swapped, the values could not be converted by simple shift + mask. If you look at the SDL SDL_MapRGB function, it will create value for given pixel format, R, G, B combo that can be written to the SDL_Surface frame buffer as-is. This routine does no byte swapping at all. This means that on given platform the 15- and 16-bit SDL_Surface frame buffers need to be in the native byte order. Thus for big-endian systems this necessitates that the 15- and 16-bit SDL_Surface frame buffers are big-endian.

    For big-endian SDL implementations rendering to little endian native display bitmaps (RGB15PC and RGB16PC) this requires byteswap from big-endian "shadow" frame buffer to little-endian native target bitmap. SDL applications compiled for big-endian systems need to render big-endian 15- and 16-bit SDL_Surface frame buffers. In case of DOSBox this requires byteswap from the "PC native" little-endian frame buffer to big-endian SDL_Surface frame buffer. This conversion is currently missing in DOSBox. Yes, this means that there is double byteswap in case the target display is natively little endian (RGB15PC and RGB16PC), but SDL API is what it is and this is necessary for things to work in all cases.

    Note that this does not apply to modes where the guns are 8-bit since simple shift + mask can represent both little- and big-endian without problems.

    [ Edited by Piru 26.01.2020 - 22:55 ]
  • »26.01.20 - 21:48
    Profile