#ifndef COMPILE_H
#include "COMPILE.H"
#endif
#ifdef MEDIA425_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_A36M_A31E_A31M_A33M_A35E_A35M
void F0515_CHAMPION_ConvertPortraitsToAtariSTPlanar(
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
void
#endif
)
{
#ifdef MEDIA413_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        REGISTER int16_t L1687_i_ChampionIndex;
        REGISTER int16_t L6168_i_BitplaneLineWordOffset;
        REGISTER int16_t L6172_ui_BitplaneAddress;
        REGISTER unsigned int16_t* L1690_pui_Bitmap_Amiga;
        REGISTER unsigned int16_t* L1691_pui_Bitmap_AtariST;


        L1690_pui_Bitmap_Amiga = (unsigned int16_t*)F0468_MEMORY_Allocate((long)M075_BITMAP_BYTE_COUNT(32, 29), C0_ALLOCATION_TEMPORARY_ON_TOP_OF_HEAP);
        for (L1687_i_ChampionIndex = 0; L1687_i_ChampionIndex < G0305_ui_PartyChampionCount; L1687_i_ChampionIndex++) {
                F0007_MAIN_CopyBytes(M516_CHAMPIONS[L1687_i_ChampionIndex].Portrait, L1690_pui_Bitmap_Amiga, M075_BITMAP_BYTE_COUNT(32, 29));
                L1691_pui_Bitmap_AtariST = (unsigned int16_t*)&M516_CHAMPIONS[L1687_i_ChampionIndex].Portrait;
                /* 58 = BitplaneWordCount */
                /* 232 = 58 * 4 = Bitmap word count */
                for (L6168_i_BitplaneLineWordOffset = 0; L6168_i_BitplaneLineWordOffset < 58; L6168_i_BitplaneLineWordOffset += 2) {
                        for (L6172_ui_BitplaneAddress = 0; L6172_ui_BitplaneAddress < 232; L6172_ui_BitplaneAddress += 58) {
                                *L1691_pui_Bitmap_AtariST++ = L1690_pui_Bitmap_Amiga[L6172_ui_BitplaneAddress + L6168_i_BitplaneLineWordOffset];
                        }
                        for (L6172_ui_BitplaneAddress = 0; L6172_ui_BitplaneAddress < 232; L6172_ui_BitplaneAddress += 58) {
                                *L1691_pui_Bitmap_AtariST++ = L1690_pui_Bitmap_Amiga[L6172_ui_BitplaneAddress + L6168_i_BitplaneLineWordOffset + 1];
                        }
                }
        }
        F0469_MEMORY_FreeAtHeapTop((long)M075_BITMAP_BYTE_COUNT(32, 29));
#endif
#ifdef MEDIA746_A36M_A31E_A31M_A33M_A35E_A35M
        REGISTER int16_t L6172_ui_BitplaneAddress;
        REGISTER int16_t L1687_i_ChampionIndex;
        REGISTER int16_t L6168_i_BitplaneLineWordOffset;
        register int16_t L2274_i_BitplaneLineWordCount;
        register int16_t L2275_i_BitplaneWordCount;
        REGISTER unsigned int16_t* L1690_pui_Bitmap_Amiga;
        REGISTER unsigned int16_t* L1691_pui_Bitmap_AtariST;


        if (!G0305_ui_PartyChampionCount) {
                return;
        }
        L1690_pui_Bitmap_Amiga = (unsigned int16_t*)F0606_AllocateMemForGraphic(G2078_C32_PortraitWidth, G2079_C29_PortraitHeight, C0_ALLOCATION_TEMPORARY_ON_TOP_OF_HEAP);
        L2274_i_BitplaneLineWordCount = ((int16_t)((G2078_C32_PortraitWidth + 15) & 0xFFF0) >> 1) >> 3;
        L2275_i_BitplaneWordCount = G2079_C29_PortraitHeight * L2274_i_BitplaneLineWordCount;
        for (L1687_i_ChampionIndex = 0; L1687_i_ChampionIndex < G0305_ui_PartyChampionCount; L1687_i_ChampionIndex++) {
                F0616_CopyBitmap(L1691_pui_Bitmap_AtariST = (unsigned int16_t*)M516_CHAMPIONS[L1687_i_ChampionIndex].Portrait, L1690_pui_Bitmap_Amiga);
                for (L6168_i_BitplaneLineWordOffset = 0; L6168_i_BitplaneLineWordOffset < L2275_i_BitplaneWordCount; L6168_i_BitplaneLineWordOffset += L2274_i_BitplaneLineWordCount) {
                        for (L6172_ui_BitplaneAddress = 0; L6172_ui_BitplaneAddress < (L2275_i_BitplaneWordCount * 4); L6172_ui_BitplaneAddress += L2275_i_BitplaneWordCount) {
                                *L1691_pui_Bitmap_AtariST++ = L1690_pui_Bitmap_Amiga[L6172_ui_BitplaneAddress + L6168_i_BitplaneLineWordOffset];
                        }
                        for (L6172_ui_BitplaneAddress = 0; L6172_ui_BitplaneAddress < (L2275_i_BitplaneWordCount * 4); L6172_ui_BitplaneAddress += L2275_i_BitplaneWordCount) {
                                *L1691_pui_Bitmap_AtariST++ = L1690_pui_Bitmap_Amiga[L6172_ui_BitplaneAddress + L6168_i_BitplaneLineWordOffset + 1];
                        }
                }
        }
        F0607_FreeMemForGraphic(L1690_pui_Bitmap_Amiga);
#endif
}

void F0516_CHAMPION_ConvertPortraitsFromAtariSTPlanar(
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
void
#endif
)
{
#ifdef MEDIA413_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        REGISTER int16_t L1692_i_ChampionIndex;
        REGISTER int16_t L1693_i_BitplaneLineWordOffset;
        REGISTER int16_t L1694_i_BitplaneAddress;
        REGISTER unsigned int16_t* L1695_pui_Bitmap_Amiga;
        REGISTER unsigned int16_t* L1696_pui_Bitmap_AtariST;


        L1695_pui_Bitmap_Amiga = (unsigned int16_t*)F0468_MEMORY_Allocate((long)M075_BITMAP_BYTE_COUNT(32, 29), C0_ALLOCATION_TEMPORARY_ON_TOP_OF_HEAP);
        for (L1692_i_ChampionIndex = 0; L1692_i_ChampionIndex < G0305_ui_PartyChampionCount; L1692_i_ChampionIndex++) {
                L1696_pui_Bitmap_AtariST = (unsigned int16_t*)&M516_CHAMPIONS[L1692_i_ChampionIndex].Portrait;
                for (L1693_i_BitplaneLineWordOffset = 0; L1693_i_BitplaneLineWordOffset < 58; L1693_i_BitplaneLineWordOffset += 2) {
                        for (L1694_i_BitplaneAddress = 0; L1694_i_BitplaneAddress < 232; L1694_i_BitplaneAddress += 58) {
                                L1695_pui_Bitmap_Amiga[L1694_i_BitplaneAddress + L1693_i_BitplaneLineWordOffset] = *L1696_pui_Bitmap_AtariST++;
                        }
                        for (L1694_i_BitplaneAddress = 0; L1694_i_BitplaneAddress < 232; L1694_i_BitplaneAddress += 58) {
                                L1695_pui_Bitmap_Amiga[L1694_i_BitplaneAddress + L1693_i_BitplaneLineWordOffset + 1] = *L1696_pui_Bitmap_AtariST++;
                        }
                }
                F0007_MAIN_CopyBytes(L1695_pui_Bitmap_Amiga, M516_CHAMPIONS[L1692_i_ChampionIndex].Portrait, M075_BITMAP_BYTE_COUNT(32, 29));
        }
        F0469_MEMORY_FreeAtHeapTop((long)M075_BITMAP_BYTE_COUNT(32, 29));
#endif
#ifdef MEDIA746_A36M_A31E_A31M_A33M_A35E_A35M
        REGISTER int16_t L1694_i_BitplaneAddress;
        REGISTER int16_t L1692_i_ChampionIndex;
        REGISTER int16_t L1693_i_BitplaneLineWordOffset;
        register int16_t L2276_i_BitplaneLineWordCount;
        register int16_t L2277_i_BitplaneWordCount;
        REGISTER unsigned int16_t* L1695_pui_Bitmap_Amiga;
        REGISTER unsigned int16_t* L1696_pui_Bitmap_AtariST;


        if (!G0305_ui_PartyChampionCount) {
                return;
        }
        L1695_pui_Bitmap_Amiga = (unsigned int16_t*)F0606_AllocateMemForGraphic(G2078_C32_PortraitWidth, G2079_C29_PortraitHeight, C0_ALLOCATION_TEMPORARY_ON_TOP_OF_HEAP);
        L2276_i_BitplaneLineWordCount = ((int16_t)((G2078_C32_PortraitWidth + 15) & 0xFFF0) >> 1) >> 3;
        L2277_i_BitplaneWordCount = G2079_C29_PortraitHeight * L2276_i_BitplaneLineWordCount;
        for (L1692_i_ChampionIndex = 0; L1692_i_ChampionIndex < G0305_ui_PartyChampionCount; L1692_i_ChampionIndex++) {
                L1696_pui_Bitmap_AtariST = (unsigned int16_t*)M516_CHAMPIONS[L1692_i_ChampionIndex].Portrait;
                for (L1693_i_BitplaneLineWordOffset = 0; L1693_i_BitplaneLineWordOffset < L2277_i_BitplaneWordCount; L1693_i_BitplaneLineWordOffset += L2276_i_BitplaneLineWordCount) {
                        for (L1694_i_BitplaneAddress = 0; L1694_i_BitplaneAddress < (L2277_i_BitplaneWordCount * 4); L1694_i_BitplaneAddress += L2277_i_BitplaneWordCount) {
                                L1695_pui_Bitmap_Amiga[L1694_i_BitplaneAddress + L1693_i_BitplaneLineWordOffset] = *L1696_pui_Bitmap_AtariST++;
                        }
                        for (L1694_i_BitplaneAddress = 0; L1694_i_BitplaneAddress < (L2277_i_BitplaneWordCount * 4); L1694_i_BitplaneAddress += L2277_i_BitplaneWordCount) {
                                L1695_pui_Bitmap_Amiga[L1694_i_BitplaneAddress + L1693_i_BitplaneLineWordOffset + 1] = *L1696_pui_Bitmap_AtariST++;
                        }
                }
#ifdef MEDIA626_A31E_A31M_A33M_A35E_A35M
                L1696_pui_Bitmap_AtariST = (unsigned int16_t*)M516_CHAMPIONS[L1692_i_ChampionIndex].Portrait;
                F0616_CopyBitmap(L1695_pui_Bitmap_Amiga, L1696_pui_Bitmap_AtariST);
#endif
#ifdef MEDIA744_A36M
                F0616_CopyBitmap(L1695_pui_Bitmap_Amiga, (unsigned int16_t*)M516_CHAMPIONS[L1692_i_ChampionIndex].Portrait);
#endif
        }
        F0607_FreeMemForGraphic(L1695_pui_Bitmap_Amiga);
#endif
}
#endif

#if (EXETYPE == C06_CEDT)
#ifdef MEDIA762_AU1E
void F2104_CHAMPION_ConvertBitmapToAtariSTPlanar(register int16_t* P6031_pi_Bitmap, unsigned int16_t P6032_ui_Width, unsigned int16_t P6033_ui_Height) {
        register int16_t* L6166_pi_TemporaryBitmap;
        register int16_t* L6167_pi_Bitmap;
        register int16_t L6168_i_BitplaneLineWordOffset;
        register int16_t L6169_i_WordIndex;
        register unsigned int16_t L6170_ui_BitplaneLineWordCount;
        register unsigned long L6171_ul_BitplaneWordCount;
        register unsigned int16_t L6172_ui_BitplaneAddress;


        L6168_i_BitplaneLineWordOffset = 0;
        if ((P6032_ui_Width == 32) && (P6033_ui_Height == 29));
        L6167_pi_Bitmap = P6031_pi_Bitmap;
        L6170_ui_BitplaneLineWordCount = (P6032_ui_Width + 15) >> 4;
        L6171_ul_BitplaneWordCount = P6033_ui_Height * L6170_ui_BitplaneLineWordCount;
        L6166_pi_TemporaryBitmap = F2095_AllocateMemory((L6171_ul_BitplaneWordCount * 2) * 4);
        while (L6168_i_BitplaneLineWordOffset < L6171_ul_BitplaneWordCount) {
                for (L6169_i_WordIndex = 0; L6169_i_WordIndex < L6170_ui_BitplaneLineWordCount; L6169_i_WordIndex++) {
                        for (L6172_ui_BitplaneAddress = 0; L6172_ui_BitplaneAddress < L6171_ul_BitplaneWordCount * 4; L6172_ui_BitplaneAddress += L6171_ul_BitplaneWordCount) {
                                L6166_pi_TemporaryBitmap[L6172_ui_BitplaneAddress + L6168_i_BitplaneLineWordOffset + L6169_i_WordIndex] = *P6031_pi_Bitmap++;
                        }
                }
                L6168_i_BitplaneLineWordOffset += L6170_ui_BitplaneLineWordCount;
        }
        F7317_MAIN_CopyBytes_Alt(L6166_pi_TemporaryBitmap, L6167_pi_Bitmap, MASK0x0400_MEMREQ, MASK0x0400_MEMREQ, (L6171_ul_BitplaneWordCount * 2) * 4);
        F7024_Free(L6166_pi_TemporaryBitmap);
}

void F2105_CHAMPION_ConvertBitmapFromAtariSTPlanar(register int16_t* P6034_pi_Bitmap, unsigned int16_t P6035_ui_Width, unsigned int16_t P6036_ui_Height) {
        register int16_t* L6173_pi_TemporaryBitmap;
        register int16_t L6174_i_BitplaneLineWordOffset;
        register int16_t L6175_i_WordIndex;
        register unsigned int16_t L6176_ui_BitplaneLineWordCount;
        register unsigned long L6177_ul_BitplaneWordCount;
        register unsigned int16_t L6178_ui_BitplaneAddress;


        L6174_i_BitplaneLineWordOffset = 0;
        if ((P6035_ui_Width == 32) && (P6036_ui_Height == 29));
        L6176_ui_BitplaneLineWordCount = (P6035_ui_Width + 15) >> 4;
        L6177_ul_BitplaneWordCount = P6036_ui_Height * L6176_ui_BitplaneLineWordCount;
        L6173_pi_TemporaryBitmap = F2095_AllocateMemory((L6177_ul_BitplaneWordCount * 2) * 4);
        F7317_MAIN_CopyBytes_Alt(P6034_pi_Bitmap, L6173_pi_TemporaryBitmap, MASK0x0400_MEMREQ, MASK0x0400_MEMREQ, (L6177_ul_BitplaneWordCount * 2) * 4);
        while (L6174_i_BitplaneLineWordOffset < L6177_ul_BitplaneWordCount) {
                for (L6175_i_WordIndex = 0; L6175_i_WordIndex < L6176_ui_BitplaneLineWordCount; L6175_i_WordIndex++) {
                        for (L6178_ui_BitplaneAddress = 0; L6178_ui_BitplaneAddress < L6177_ul_BitplaneWordCount * 4; L6178_ui_BitplaneAddress += L6177_ul_BitplaneWordCount) {
                                *P6034_pi_Bitmap++ = L6173_pi_TemporaryBitmap[L6178_ui_BitplaneAddress + L6174_i_BitplaneLineWordOffset + L6175_i_WordIndex];
                        }
                }
                L6174_i_BitplaneLineWordOffset += L6176_ui_BitplaneLineWordCount;
        }
        F7024_Free(L6173_pi_TemporaryBitmap);
}
#endif
#ifdef MEDIA768_AU2E_AU3E
void F7251_ConvertBitmapFromAtariSTPlanar(register unsigned int16_t* P2353_Bitmap_AtariST, register unsigned int16_t* P2354_Bitmap, unsigned int16_t P4016_ui_Width, unsigned int16_t P4017_ui_Height)
{
        register int16_t L4548_i_BitplaneLineWordOffset;
        register unsigned int16_t L4547_ui_WordIndex;
        register int16_t L4549_i_BitplaneLineWordCount;
        register unsigned long L4550_ul_BitplaneWordCount;
        register unsigned int16_t L4551_ui_BitplaneAddress;


        L4549_i_BitplaneLineWordCount = (P4016_ui_Width + 15) >> 4;
        L4550_ul_BitplaneWordCount = P4017_ui_Height * L4549_i_BitplaneLineWordCount;
        for (L4548_i_BitplaneLineWordOffset = 0; L4548_i_BitplaneLineWordOffset < L4550_ul_BitplaneWordCount; L4548_i_BitplaneLineWordOffset += L4549_i_BitplaneLineWordCount) {
                for (L4547_ui_WordIndex = 0; L4547_ui_WordIndex < L4549_i_BitplaneLineWordCount; L4547_ui_WordIndex++) {
                        for (L4551_ui_BitplaneAddress = 0; L4551_ui_BitplaneAddress < (L4550_ul_BitplaneWordCount * 4); L4551_ui_BitplaneAddress += L4550_ul_BitplaneWordCount) {
                                P2354_Bitmap[L4551_ui_BitplaneAddress + L4548_i_BitplaneLineWordOffset + L4547_ui_WordIndex] = *P2353_Bitmap_AtariST++;
                        }
                }
        }
}

void F7252_ConvertBitmapToAtariSTPlanar(register int16_t* P4018_pc_Bitmap, register int16_t* P4019_pi_, unsigned int16_t P4020_ui_Width, unsigned int16_t P4021_ui_Height)
{
        register int16_t L4560_i_;
        register unsigned int16_t L4554_;
        register int16_t L4556_;
        register unsigned long L4557_;
        register unsigned int16_t L4558_;


        L4556_ = (P4020_ui_Width + 15) >> 4;
        L4557_ = P4021_ui_Height * L4556_;
        for (L4560_i_ = 0; L4560_i_ < L4557_; L4560_i_ += L4556_) {
                for (L4554_ = 0; L4554_ < L4556_; L4554_++) {
                        for (L4558_ = 0; L4558_ < (L4557_ * 4); L4558_ += L4557_) {
                                *P4019_pi_++ = P4018_pc_Bitmap[L4558_ + L4560_i_ + L4554_];
                        }
                }
        }
}
#endif
#ifdef MEDIA674_F31E_F31J_X31J_P31J
void F7251_ConvertBitmapFromAtariSTPlanar(unsigned char* P2353_Bitmap_AtariST, REGISTER unsigned char* P2354_Bitmap, unsigned int16_t P4016_ui_Width, int16_t P4017_ui_Height)
{
#ifdef MEDIA692_X31J
        register unsigned int16_t* L6059_pui_Bitmap;
#endif
        REGISTER unsigned int16_t L4548_ui_BitMask;
        REGISTER unsigned char L4547_uc_Byte;
        REGISTER int16_t L4549_i_AtariSTPixelBit0;
        REGISTER int16_t L4550_i_AtariSTPixelBit1;
        REGISTER int16_t L4551_i_AtariSTPixelBit2;
        int16_t L4552_i_AtariSTPixelBit3;
        int16_t L4553_i_Counter;


#ifdef MEDIA692_X31J
        L6059_pui_Bitmap = (unsigned int16_t*)P2353_Bitmap_AtariST;
#endif
        while (P4017_ui_Height--) {
                for (L4553_i_Counter = L4548_ui_BitMask = 0; L4553_i_Counter < P4016_ui_Width; L4553_i_Counter += 2) {
                        if (L4548_ui_BitMask == 0) {
                                L4548_ui_BitMask = 0x8000;
#ifdef MEDIA671_F31E_F31J_P31J
                                /* Convert words to little endian */
                                L4549_i_AtariSTPixelBit0 = *P2353_Bitmap_AtariST++ << 8;
                                L4549_i_AtariSTPixelBit0 |= *P2353_Bitmap_AtariST++;
                                L4550_i_AtariSTPixelBit1 = *P2353_Bitmap_AtariST++ << 8;
                                L4550_i_AtariSTPixelBit1 |= *P2353_Bitmap_AtariST++;
                                L4551_i_AtariSTPixelBit2 = *P2353_Bitmap_AtariST++ << 8;
                                L4551_i_AtariSTPixelBit2 |= *P2353_Bitmap_AtariST++;
                                L4552_i_AtariSTPixelBit3 = *P2353_Bitmap_AtariST++ << 8;
                                L4552_i_AtariSTPixelBit3 |= *P2353_Bitmap_AtariST++;
#endif
#ifdef MEDIA692_X31J
                                L4549_i_AtariSTPixelBit0 = *L6059_pui_Bitmap++;
                                L4550_i_AtariSTPixelBit1 = *L6059_pui_Bitmap++;
                                L4551_i_AtariSTPixelBit2 = *L6059_pui_Bitmap++;
                                L4552_i_AtariSTPixelBit3 = *L6059_pui_Bitmap++;
#endif
                        }
                        L4547_uc_Byte = 0;
                        if (L4549_i_AtariSTPixelBit0 & L4548_ui_BitMask) {
                                L4547_uc_Byte += 0x10;
                        }
                        if (L4550_i_AtariSTPixelBit1 & L4548_ui_BitMask) {
                                L4547_uc_Byte += 0x20;
                        }
                        if (L4551_i_AtariSTPixelBit2 & L4548_ui_BitMask) {
                                L4547_uc_Byte += 0x40;
                        }
                        if (L4552_i_AtariSTPixelBit3 & L4548_ui_BitMask) {
                                L4547_uc_Byte += 0x80;
                        }
                        L4548_ui_BitMask >>= 1;
                        if (L4549_i_AtariSTPixelBit0 & L4548_ui_BitMask) {
                                L4547_uc_Byte += 0x01;
                        }
                        if (L4550_i_AtariSTPixelBit1 & L4548_ui_BitMask) {
                                L4547_uc_Byte += 0x02;
                        }
                        if (L4551_i_AtariSTPixelBit2 & L4548_ui_BitMask) {
                                L4547_uc_Byte += 0x04;
                        }
                        if (L4552_i_AtariSTPixelBit3 & L4548_ui_BitMask) {
                                L4547_uc_Byte += 0x08;
                        }
                        L4548_ui_BitMask >>= 1;
#ifdef MEDIA670_F31E_F31J
                        L4547_uc_Byte = (L4547_uc_Byte >> 4) | (L4547_uc_Byte << 4); /* Swap pixels */
#endif
                        *P2354_Bitmap++ = L4547_uc_Byte;
                }
        }
}

void F7252_ConvertBitmapToAtariSTPlanar(REGISTER char* P4018_pc_Bitmap, char* P4019_pc_Bitmap_AtariST, unsigned int16_t P4020_ui_Width, unsigned int16_t P4021_ui_Height)
{
#ifdef MEDIA692_X31J
        register unsigned int16_t* L6187_pui_Bitmap_AtariST;
#endif
        REGISTER unsigned int16_t L4560_ui_BitMask;
#ifdef MEDIA671_F31E_F31J_P31J
        unsigned char L4554_uc_Byte;
        unsigned int16_t L4556_ui_AtariSTPixelBit0;
        unsigned int16_t L4557_ui_AtariSTPixelBit1;
        unsigned int16_t L4558_ui_AtariSTPixelBit2;
#endif
#ifdef MEDIA692_X31J
        register unsigned char L4554_uc_Byte;
        register unsigned int16_t L4556_ui_AtariSTPixelBit0;
        register unsigned int16_t L4557_ui_AtariSTPixelBit1;
        register unsigned int16_t L4558_ui_AtariSTPixelBit2;
#endif
        unsigned int16_t L4559_ui_AtariSTPixelBit3;
        int16_t L4555_i_Counter;


#ifdef MEDIA692_X31J
        L6187_pui_Bitmap_AtariST = (unsigned int16_t*)P4019_pc_Bitmap_AtariST;
#endif
        while (P4021_ui_Height--) {
                L4560_ui_BitMask = 0x8000;
                L4556_ui_AtariSTPixelBit0 = L4557_ui_AtariSTPixelBit1 = L4558_ui_AtariSTPixelBit2 = L4559_ui_AtariSTPixelBit3 = 0;
                L4555_i_Counter = 0;
                while (L4555_i_Counter < P4020_ui_Width) {
                        L4554_uc_Byte = *P4018_pc_Bitmap++;
#ifdef MEDIA670_F31E_F31J
                        L4554_uc_Byte = (L4554_uc_Byte >> 4) | (L4554_uc_Byte << 4);
#endif

                        if (L4554_uc_Byte & 0x10) {
                                L4556_ui_AtariSTPixelBit0 |= L4560_ui_BitMask;
                        }
                        if (L4554_uc_Byte & 0x20) {
                                L4557_ui_AtariSTPixelBit1 |= L4560_ui_BitMask;
                        }
                        if (L4554_uc_Byte & 0x40) {
                                L4558_ui_AtariSTPixelBit2 |= L4560_ui_BitMask;
                        }
                        if (L4554_uc_Byte & 0x80) {
                                L4559_ui_AtariSTPixelBit3 |= L4560_ui_BitMask;
                        }
                        L4560_ui_BitMask >>= 1;
                        if (L4554_uc_Byte & 0x01) {
                                L4556_ui_AtariSTPixelBit0 |= L4560_ui_BitMask;
                        }
                        if (L4554_uc_Byte & 0x02) {
                                L4557_ui_AtariSTPixelBit1 |= L4560_ui_BitMask;
                        }
                        if (L4554_uc_Byte & 0x04) {
                                L4558_ui_AtariSTPixelBit2 |= L4560_ui_BitMask;
                        }
                        if (L4554_uc_Byte & 0x08) {
                                L4559_ui_AtariSTPixelBit3 |= L4560_ui_BitMask;
                        }
                        if ((L4560_ui_BitMask >>= 1) == 0) {
                                L4560_ui_BitMask = 0x8000;
#ifdef MEDIA671_F31E_F31J_P31J
                                /* Convert to big endian */
                                *P4019_pc_Bitmap_AtariST++ = L4556_ui_AtariSTPixelBit0 >> 8;
                                *P4019_pc_Bitmap_AtariST++ = L4556_ui_AtariSTPixelBit0;
                                *P4019_pc_Bitmap_AtariST++ = L4557_ui_AtariSTPixelBit1 >> 8;
                                *P4019_pc_Bitmap_AtariST++ = L4557_ui_AtariSTPixelBit1;
                                *P4019_pc_Bitmap_AtariST++ = L4558_ui_AtariSTPixelBit2 >> 8;
                                *P4019_pc_Bitmap_AtariST++ = L4558_ui_AtariSTPixelBit2;
                                *P4019_pc_Bitmap_AtariST++ = L4559_ui_AtariSTPixelBit3 >> 8;
                                *P4019_pc_Bitmap_AtariST++ = L4559_ui_AtariSTPixelBit3;
#endif
#ifdef MEDIA692_X31J
                                *L6187_pui_Bitmap_AtariST++ = L4556_ui_AtariSTPixelBit0;
                                *L6187_pui_Bitmap_AtariST++ = L4557_ui_AtariSTPixelBit1;
                                *L6187_pui_Bitmap_AtariST++ = L4558_ui_AtariSTPixelBit2;
                                *L6187_pui_Bitmap_AtariST++ = L4559_ui_AtariSTPixelBit3;
#endif
                                L4556_ui_AtariSTPixelBit0 = L4557_ui_AtariSTPixelBit1 = L4558_ui_AtariSTPixelBit2 = L4559_ui_AtariSTPixelBit3 = 0;
                        }
                        L4555_i_Counter += 2;
                }
                if (L4560_ui_BitMask != 0x8000) {
#ifdef MEDIA671_F31E_F31J_P31J
                        *P4019_pc_Bitmap_AtariST++ = L4556_ui_AtariSTPixelBit0 >> 8;
                        *P4019_pc_Bitmap_AtariST++ = L4556_ui_AtariSTPixelBit0;
                        *P4019_pc_Bitmap_AtariST++ = L4557_ui_AtariSTPixelBit1 >> 8;
                        *P4019_pc_Bitmap_AtariST++ = L4557_ui_AtariSTPixelBit1;
                        *P4019_pc_Bitmap_AtariST++ = L4558_ui_AtariSTPixelBit2 >> 8;
                        *P4019_pc_Bitmap_AtariST++ = L4558_ui_AtariSTPixelBit2;
                        *P4019_pc_Bitmap_AtariST++ = L4559_ui_AtariSTPixelBit3 >> 8;
                        *P4019_pc_Bitmap_AtariST++ = L4559_ui_AtariSTPixelBit3;
#endif
#ifdef MEDIA692_X31J
                        *L6187_pui_Bitmap_AtariST++ = L4556_ui_AtariSTPixelBit0;
                        *L6187_pui_Bitmap_AtariST++ = L4557_ui_AtariSTPixelBit1;
                        *L6187_pui_Bitmap_AtariST++ = L4558_ui_AtariSTPixelBit2;
                        *L6187_pui_Bitmap_AtariST++ = L4559_ui_AtariSTPixelBit3;
#endif
                }
        }
}
#endif
#endif
