#ifndef COMPILE_H
#include "COMPILE.H"
#endif
#ifdef MEDIA525_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_F31E_F31J_X31J_P31J
#ifdef MEDIA496_F20E_F20J_P20JA_P20JB_I34E_I34M_F31E_F31J_P31J
void F0642_AllocateFontMemory(
void
)
{
        G2148_puc_InterfaceAndScrollsFontCustomColors = M533_F0468_MEMORY_Allocate((long)M075_BITMAP_BYTE_COUNT(1024, 6), C1_ALLOCATION_PERMANENT, MASK0x0400_MEMREQ);
}
#endif

unsigned char* F0643_BuildCustomColorsFont(
#ifdef MEDIA591_X30J_P20JA_P20JB_I34E_I34M_X31J_P31J
register int16_t P2180_i_TextColor       SEPARATOR /* register required for PC98 */ 
register int16_t P2181_i_BackgroundColor FINAL_SEPARATOR /* register required for PC98 */
#endif
#ifdef MEDIA551_F20E_F20J_F31E_F31J
register int16_t P2180_i_TextColor       SEPARATOR /* ANOMALY_FMT register required */
register int16_t P2181_i_BackgroundColor FINAL_SEPARATOR /* ANOMALY_FMT register required */
#endif
{
#ifdef MEDIA524_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_F31E_F31J_P31J   /* OK */
        register unsigned char* L3479_puc_;                    /* ANOMALY_FMT register required */
#endif
        REGISTER unsigned char* L3480_puc_;
#ifdef MEDIA692_X31J
        REGISTER unsigned char* L3479_puc_;
#endif
#ifdef MEDIA591_X30J_P20JA_P20JB_I34E_I34M_X31J_P31J
        register int16_t L3481_i_; /* register required for I34x */
#endif
#ifdef MEDIA551_F20E_F20J_F31E_F31J
        REGISTER int16_t L3481_i_;
#endif
        REGISTER int16_t L3482_i_;
#ifdef MEDIA591_X30J_P20JA_P20JB_I34E_I34M_X31J_P31J
        register int16_t L3483_i_; /* register required for I34x */
#endif
#ifdef MEDIA551_F20E_F20J_F31E_F31J
        REGISTER int16_t L3483_i_;
#endif
#ifdef MEDIA496_F20E_F20J_P20JA_P20JB_I34E_I34M_F31E_F31J_P31J
        int16_t L3484_i_;
        unsigned int16_t L3485_ui_;
        unsigned int16_t L3486_ui_;
#endif


        if ((G2104_i_InterfaceAndScrollsFontCurrentTextColor != P2180_i_TextColor) || (G2105_i_InterfaceAndScrollsFontCurrentBackgroundColor != P2181_i_BackgroundColor)) {
                L3479_puc_ = G0357_puc_InterfaceAndScrollsFont;
                L3480_puc_ = G2148_puc_InterfaceAndScrollsFontCustomColors;
                L3482_i_ = P2180_i_TextColor << 4;
                L3483_i_ = P2181_i_BackgroundColor << 4;
                for (L3481_i_ = 768; L3481_i_; L3481_i_--) {
#ifdef MEDIA496_F20E_F20J_P20JA_P20JB_I34E_I34M_F31E_F31J_P31J
                        L3485_ui_ = *L3479_puc_++;
                        for (L3486_ui_ = 0; L3486_ui_ < 4; L3486_ui_++) {
                                if (L3485_ui_ & 0x80)
#ifdef MEDIA463_P20JA_P20JB_I34E_I34M_P31J
                                        L3484_i_ = L3482_i_;
#endif
#ifdef MEDIA551_F20E_F20J_F31E_F31J
                                        L3484_i_ = P2180_i_TextColor;
#endif
                                else
#ifdef MEDIA463_P20JA_P20JB_I34E_I34M_P31J
                                        L3484_i_ = L3483_i_;
#endif
#ifdef MEDIA551_F20E_F20J_F31E_F31J
                                        L3484_i_ = P2181_i_BackgroundColor;
#endif
                                if (L3485_ui_ & 0x40)
#ifdef MEDIA463_P20JA_P20JB_I34E_I34M_P31J
                                        *L3480_puc_++ = (L3484_i_ | P2180_i_TextColor);
#endif
#ifdef MEDIA551_F20E_F20J_F31E_F31J
                                        *L3480_puc_++ = (L3484_i_ | L3482_i_);
#endif
                                else
#ifdef MEDIA463_P20JA_P20JB_I34E_I34M_P31J
                                        *L3480_puc_++ = (L3484_i_ | P2181_i_BackgroundColor);
#endif
#ifdef MEDIA551_F20E_F20J_F31E_F31J
                                        *L3480_puc_++ = (L3484_i_ | L3483_i_);
#endif
                                L3485_ui_ = L3485_ui_ << 2;
                        }
#endif
#ifdef MEDIA607_X30J_X31J
                        asm {
#ifdef MEDIA577_X30J
                                        move.b  (a4)+,d0
#endif
#ifdef MEDIA692_X31J
                                        move.b  (a3)+,d0
#endif
                                        lsl.b   #1,d0
                                        bcc.s   @Tloc_1F048
                                        move.b  d4,d1
                                        bra.s   @Tloc_1F04A
                                @Tloc_1F048:
                                        move.b  d3,d1
                                @Tloc_1F04A:
                                        lsl.b   #1,d0
                                        bcc.s   @Tloc_1F052
                                        or.b    d7,d1
                                        bra.s   @Tloc_1F054
                                @Tloc_1F052:
                                        or.b    d6,d1
                                @Tloc_1F054:
#ifdef MEDIA577_X30J
                                        move.b  d1,(a3)+
#endif
#ifdef MEDIA692_X31J
                                        move.b  d1,(a4)+
#endif
                                        lsl.b   #1,d0
                                        bcc.s   @Tloc_1F05E
                                        move.b  d4,d1
                                        bra.s   @Tloc_1F060
                                @Tloc_1F05E:
                                        move.b  d3,d1
                                @Tloc_1F060:
                                        lsl.b   #1,d0
                                        bcc.s   @Tloc_1F068
                                        or.b    d7,d1
                                        bra.s   @Tloc_1F06A
                                @Tloc_1F068:
                                        or.b    d6,d1
                                @Tloc_1F06A:
#ifdef MEDIA577_X30J
                                        move.b  d1,(a3)+
#endif
#ifdef MEDIA692_X31J
                                        move.b  d1,(a4)+
#endif
                                        lsl.b   #1,d0
                                        bcc.s   @Tloc_1F074
                                        move.b  d4,d1
                                        bra.s   @Tloc_1F076
                                @Tloc_1F074:
                                        move.b  d3,d1
                                @Tloc_1F076:
                                        lsl.b   #1,d0
                                        bcc.s   @Tloc_1F07E
                                        or.b    d7,d1
                                        bra.s   @Tloc_1F080
                                @Tloc_1F07E:
                                        or.b    d6,d1
                                @Tloc_1F080:
#ifdef MEDIA577_X30J
                                        move.b  d1,(a3)+
#endif
#ifdef MEDIA692_X31J
                                        move.b  d1,(a4)+
#endif
                                        lsl.b   #1,d0
                                        bcc.s   @Tloc_1F08A
                                        move.b  d4,d1
                                        bra.s   @Tloc_1F08C
                                @Tloc_1F08A:
                                        move.b  d3,d1
                                @Tloc_1F08C:
                                        lsl.b   #1,d0
                                        bcc.s   @Tloc_1F094
                                        or.b    d7,d1
                                        bra.s   @Tloc_1F096
                                @Tloc_1F094:
                                        or.b    d6,d1
                                @Tloc_1F096:
#ifdef MEDIA577_X30J
                                        move.b  d1,(a3)+
#endif
#ifdef MEDIA692_X31J
                                        move.b  d1,(a4)+
#endif
                        }
#endif
                }
                G2104_i_InterfaceAndScrollsFontCurrentTextColor = P2180_i_TextColor;
                G2105_i_InterfaceAndScrollsFontCurrentBackgroundColor = P2181_i_BackgroundColor;
        }
        return G2148_puc_InterfaceAndScrollsFontCustomColors;
}
#endif
