#ifndef COMPILE_H
#include "COMPILE.H"
#endif
#ifdef MEDIA042_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
#ifdef MEDIA619_A31E_A31M
extern void F9086_GRF1_06_Blit(
unsigned int16_t* P4196_pui_Bitmap_Source,
unsigned int16_t* P4197_pui_Bitmap_Destination,
int16_t* P4198_pi_XYZ,
int16_t P4199_i_X,
int16_t P4200_i_Y,
int16_t P4201_i_SourceByteWidth,
int16_t P4202_i_DestinationByteWidth,
char P4203_c_TransparentColor,
int16_t P4204_i_SourceHeight,
int16_t P4205_i_DestinationHeight);
#endif

#ifdef MEDIA457_P20JA
char G3041_ac_[800];
#endif

#ifdef MEDIA007_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E
overlay "show"
#endif
#ifdef MEDIA351_G14ED_G20E_G21E
segment "gsthings"
#endif

/* This function creates a bitmap in P0210_puc_Bitmap_Temporary with the dimensions of P0211_pi_Box and filled with units from P0207_puc_Bitmap_Source starting from P0213_ui_FirstUnitIndex to P0212_i_LastUnitIndex
The written units are masked with P0209_puc_Bitmap_Mask and the pixels removed by the mask are replaced by the color P0215_i_TransparentColor. The bitmap at coordinates P0216_i_X and P0217_i_Y in the resulting P0210_puc_Bitmap_Temporary is blitted to P0208_puc_Bitmap_Destination with transparent color P0215_i_TransparentColor
The dimensions of P0207_puc_Bitmap_Source are ignored as it is only used as a source for units. Consequently the source bitmap is never drawn as is and is always distorted */
void F0133_VIDEO_BlitBoxFilledWithMaskedBitmap(
#ifdef MEDIA008_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E
P0207_puc_Bitmap_Source, P0208_puc_Bitmap_Destination, P0209_puc_Bitmap_Mask, P0210_puc_Bitmap_Temporary, P0211_pi_Box, P0212_i_LastUnitIndex, P0213_ui_FirstUnitIndex, P0214_ui_DestinationByteWidth, P0215_i_TransparentColor, P0216_i_X, P0217_i_Y)
#endif
#ifdef MEDIA413_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0207_puc_Bitmap_Source, P0208_puc_Bitmap_Destination, P0209_puc_Bitmap_Mask, P0210_puc_Bitmap_Temporary, P0211_pi_Box, P0212_i_LastUnitIndex, P0213_ui_FirstUnitIndex, P0214_ui_DestinationByteWidth, P0215_i_TransparentColor, P0216_i_X, P0217_i_Y, P0927_i_DestinationHeight, P0928_i_Height2)
#endif
#ifdef MEDIA017_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
unsigned char*          P0207_puc_Bitmap_Source       SEPARATOR
#endif
#ifdef MEDIA577_X30J
register unsigned char* P0207_puc_Bitmap_Source       SEPARATOR
#endif
unsigned char*          P0208_puc_Bitmap_Destination  SEPARATOR
unsigned char*          P0209_puc_Bitmap_Mask         SEPARATOR
unsigned char*          P0210_puc_Bitmap_Temporary    SEPARATOR
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
int16_t*                P0211_pi_Box                  SEPARATOR
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
int16_t*                P2416_pi_XYZ                  SEPARATOR
#endif
int16_t                 P0212_i_LastUnitIndex         SEPARATOR /* Index of the last source bitmap unit to write to the destination box. Must be greater than P0213_ui_FirstUnitIndex. After this unit is written to the destination box, the next unit to write will be set to the first unit in the source bitmap, and not reset to P0213_ui_FirstUnitIndex */
unsigned int16_t        P0213_ui_FirstUnitIndex       SEPARATOR /* Index of the first source bitmap unit to write to the destination box. Must be lower than P0212_i_LastUnitIndex */
unsigned int16_t        P0214_ui_DestinationByteWidth SEPARATOR
#if (EXETYPE == C13_GRF1)
char                    P0215_i_TransparentColor      SEPARATOR
#else
int16_t                 P0215_i_TransparentColor      SEPARATOR
#endif
int16_t                 P0216_i_X                     SEPARATOR
#ifdef MEDIA098_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_F31E_F31J_X31J_P31J
int16_t                 P0217_i_Y                     FINAL_SEPARATOR
#endif
#ifdef MEDIA425_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_A36M_A31E_A31M_A33M_A35E_A35M
int16_t                 P0217_i_Y                     SEPARATOR
int16_t                 P0927_i_DestinationHeight     SEPARATOR
int16_t                 P0928_i_Height2               FINAL_SEPARATOR
#endif
{
#ifdef MEDIA007_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E
        int16_t L0232_i_BoxUnitWidth;


        asm {
                        movem.l D5-D7/A2-A4,-(A7)
                        move.w  P0215_i_TransparentColor(A6),D0
                        cmp.b   #255,D0
                        beq.s   T0133001                                /* If mask should not be used */
                        tst.b   D0
                        bpl.s   T0133002                                /* If P0215_i_TransparentColor >= 0. If mask should be used */
                        andi.w  #0x007F,P0215_i_TransparentColor(A6)     /* Clear bit 7 for later call to F0132_VIDEO_Blit */
                T0133001:
                        lea     T0133026_TransparentColor00_NoMask(PC),A3
                        bra.s   T0133004
                T0133002:
                        lea     T0133010_UseMask(PC),A3
                        move.w  D0,D1
                        add.w   D0,D0
                        add.w   D1,D0
                        add.w   D0,D0                                   /* D0 = 6 * P0215_i_TransparentColor (each entry in the jump table below is 6 bytes large) */
                        jmp     2(PC,D0.w)                              /* This jumptable is used to set in A1 the address of the routine to set the color of pixels excluded by the mask to the specified transparent color */
                T0133003:
                        lea     T0133026_TransparentColor00_NoMask(PC),A1
                        bra.s   T0133004
                        lea     T0133025_TransparentColor01(PC),A1
                        bra.s   T0133004
                        lea     T0133015_TransparentColor02(PC),A1
                        bra.s   T0133004
                        lea     T0133024_TransparentColor03(PC),A1
                        bra.s   T0133004
                        lea     T0133017_TransparentColor04(PC),A1
                        bra.s   T0133004
                        lea     T0133019_TransparentColor05(PC),A1
                        bra.s   T0133004
                        lea     T0133016_TransparentColor06(PC),A1
                        bra.s   T0133004
                        lea     T0133023_TransparentColor07(PC),A1
                        bra.s   T0133004
                        lea     T0133013_TransparentColor08(PC),A1
                        bra.s   T0133004
                        lea     T0133021_TransparentColor09(PC),A1
                        bra.s   T0133004
                        lea     T0133014_TransparentColor10(PC),A1
                        bra.s   T0133004
                        lea     T0133020_TransparentColor11(PC),A1
                        bra.s   T0133004
                        lea     T0133012_TransparentColor12(PC),A1
                        bra.s   T0133004
                        lea     T0133018_TransparentColor13(PC),A1
                        bra.s   T0133004
                        lea     T0133011_TransparentColor14(PC),A1
                        bra.s   T0133004
                        lea     T0133022_TransparentColor15(PC),A1
                T0133004:
                        movea.l P0207_puc_Bitmap_Source(A6),A0
                        move.w  P0212_i_LastUnitIndex(A6),D6
                        move.w  P0213_ui_FirstUnitIndex(A6),D7
                        move.w  D7,D0
                        lsl.w   #3,D0                                   /* P0213_ui_FirstUnitIndex * 8 = offset in bytes in P0207_puc_Bitmap_Source */
                        adda.w  D0,A0
                        swap    D7                                      /* Most significant word of D7 contains P0213_ui_FirstUnitIndex */
                        movea.l P0211_pi_Box(A6),A2
                        moveq   #0,D3                                   /* Prepare D3 for X1 */
                        moveq   #0,D0                                   /* Prepare D0 for X2 */
                        tst.w   G0578_B_UseByteBoxCoordinates(A4)
                        beq.s   T0133005                                /* Branch if G0578_B_UseByteBoxCoordinates = C0_FALSE */
                        move.b  (A2)+,D3                                /* X1 */
                        move.b  (A2)+,D0                                /* X2 */
                        bra.s   T0133006
                T0133005:
                        move.w  (A2)+,D3                                /* X1 */
                        move.w  (A2)+,D0                                /* X2 */
                T0133006:
                        sub.w   D3,D0                                   /* X2 - X1 */
                        lsr.w   #4,D0                                   /* (X2 - X1) / 16 */
                        addq.w  #1,D0                                   /* ((X2 - X1) / 16) + 1 */
                        move.w  D0,L0232_i_BoxUnitWidth(A6)
                        moveq   #0,D3                                   /* Prepare D3 for Y1 */
                        moveq   #0,D5                                   /* Prepare D5 for Y2 */
                        tst.w   G0578_B_UseByteBoxCoordinates(A4)
                        beq.s   T0133007                                /* Branch if G0578_B_UseByteBoxCoordinates = C0_FALSE */
                        move.b  (A2)+,D3                                /* Y1 */
                        move.b  (A2),D5                                 /* Y2 */
                        bra.s   T0133008
                T0133007:
                        move.w  (A2)+,D3                                /* Y1 */
                        move.w  (A2),D5                                 /* Y2 */
                T0133008:
                        sub.w   D3,D5                                   /* Y2 - Y1 */
                        addq.w  #1,D5                                   /* (Y2 - Y1) + 1 */
                        mulu.w  D0,D5                                   /* ((Y2 - Y1) + 1) * (((X2 - X1) / 16) + 1) */
                        subq.w  #1,D5                                   /* (((Y2 - Y1) + 1) * (((X2 - X1) / 16) + 1)) - 1 */
                        move.w  D5,D7                                   /* Least significant word of D7 contains box unit count: the number of bitmap units that must be written to the box from the source bitmap */
                        movea.l A1,A4
                        movea.l P0209_puc_Bitmap_Mask(A6),A1
                        movea.l P0210_puc_Bitmap_Temporary(A6),A2
                T0133009_Loop:
                        movem.w (A0)+,D0-D3                             /* Load unit (4 words) of bitmap data */
                        jmp     (A3)                                    /* A3 = T0133010_UseMask or T0133026_TransparentColor00_NoMask */
                T0133010_UseMask:
                        move.w  (A1),D5                                 /* Get one word from the mask */
                        addq.l  #8,A1                                   /* Proceed to next unit */
                        and.w   D5,D0                                   /* Clear bits in fourth word bitmap according to mask */
                        and.w   D5,D1                                   /* Clear bits in third word of bitmap according to mask */
                        and.w   D5,D2                                   /* Clear bits in second word of bitmap according to mask */
                        and.w   D5,D3                                   /* Clear bits in first word of bitmap according to mask */
                        not.w   D5
                        jmp     (A4)                                    /* A4 = One of T0133011_TransparentColor14 to T0133026_TransparentColor00_NoMask */
                T0133011_TransparentColor14:
                        or.w    D5,D1                                   /* Set bits 1 (2) in third word of bitmap according to mask */
                T0133012_TransparentColor12:
                        or.w    D5,D2                                   /* Set bits 2 (4) in second word of bitmap according to mask */
                T0133013_TransparentColor08:
                        or.w    D5,D3                                   /* Set bits 3 (8) in first word of bitmap according to mask */
                        bra.s   T0133026_TransparentColor00_NoMask
                T0133014_TransparentColor10:
                        or.w    D5,D3                                   /* Set bits 3 (8) in first word of bitmap according to mask */
                T0133015_TransparentColor02:
                        or.w    D5,D1                                   /* Set bits 1 (2) in third word of bitmap according to mask */
                        bra.s   T0133026_TransparentColor00_NoMask
                T0133016_TransparentColor06:
                        or.w    D5,D1                                   /* Set bits 1 (2) in third word of bitmap according to mask */
                T0133017_TransparentColor04:
                        or.w    D5,D2                                   /* Set bits 2 (4) in second word of bitmap according to mask */
                        bra.s   T0133026_TransparentColor00_NoMask
                T0133018_TransparentColor13:
                        or.w    D5,D3                                   /* Set bits 3 (8) in first word of bitmap according to mask */
                T0133019_TransparentColor05:
                        or.w    D5,D2                                   /* Set bits 2 (4) in second word of bitmap according to mask */
                        or.w    D5,D0                                   /* Set bits 0 (1) in fourth word of bitmap according to mask */
                        bra.s   T0133026_TransparentColor00_NoMask
                T0133020_TransparentColor11:
                        or.w    D5,D1                                   /* Set bits 1 (2) in third word of bitmap according to mask */
                T0133021_TransparentColor09:
                        or.w    D5,D3                                   /* Set bits 3 (8) in first word of bitmap according to mask */
                        or.w    D5,D0                                   /* Set bits 0 (1) in fourth word of bitmap according to mask */
                        bra.s   T0133026_TransparentColor00_NoMask
                T0133022_TransparentColor15:
                        or.w    D5,D3                                   /* Set bits 3 (8) in first word of bitmap according to mask */
                T0133023_TransparentColor07:
                        or.w    D5,D2                                   /* Set bits 2 (4) in second word of bitmap according to mask */
                T0133024_TransparentColor03:
                        or.w    D5,D1                                   /* Set bits 1 (2) in third word of bitmap according to mask */
                T0133025_TransparentColor01:
                        or.w    D5,D0                                   /* Set bits 0 (1) in fourth word of bitmap according to mask */
                T0133026_TransparentColor00_NoMask:
                        movem.w D0-D3,(A2)                              /* Write a unit (4 words) of bitmap to P0210_puc_Bitmap_Temporary */
                        addq.l  #8,A2                                   /* Proceed to the next unit (4 words = 8 bytes) in P0210_puc_Bitmap_Temporary */
                        swap    D7                                      /* Least significant word is P0213_ui_FirstUnitIndex, most significant word is count of units left to write */
                        addq.w  #1,D7                                   /* Increment P0213_ui_FirstUnitIndex */
                        cmp.w   D6,D7
                        beq.s   T0133028                                /* Branch if P0213_ui_FirstUnitIndex = P0212_i_LastUnitIndex */
                T0133027:
                        swap    D7                                      /* Least significant word is Unit count */
                        dbf     D7,T0133009_Loop                        /* Decrement D7 (count of units left to write) and branch if D7 >= 0 */
                        bra.s   T0133029
                T0133028:
                        move.w  #0,D7                                   /* P0213_ui_FirstUnitIndex = 0 */
                        movea.l P0207_puc_Bitmap_Source(A6),A0
                        bra.s   T0133027
                T0133029:
                        movem.l (A7)+,D5-D7/A2-A4
        }
        F0132_VIDEO_Blit(P0210_puc_Bitmap_Temporary, P0208_puc_Bitmap_Destination, P0211_pi_Box, P0216_i_X, P0217_i_Y, L0232_i_BoxUnitWidth << 3, P0214_ui_DestinationByteWidth, P0215_i_TransparentColor);
#endif
#ifdef MEDIA351_G14ED_G20E_G21E
        int16_t L6348_;
        int16_t L6343_;
        unsigned char* L6349_;
        unsigned char* L6357_Unreferenced;
        unsigned char* L6350_;
        unsigned char* L6355_;
#ifdef MEDIA350_G14ED_G20E
        unsigned char* L6356_;
#endif
        char L6353_;
        char L6354_;
#ifdef MEDIA350_G14ED_G20E
        char L6358_;
#endif
        int16_t L6344_;
        int16_t L6345_;
        int16_t L6346_;
        int16_t L6347_;
        int16_t L6351_;
        int16_t L6352_;
        int16_t L6359_;


        L6343_ = (P0215_i_TransparentColor != CM1_COLOR_NO_TRANSPARENCY) && (P0215_i_TransparentColor != 255) && ((P0215_i_TransparentColor == 255) || !(P0215_i_TransparentColor & 0x80));
        if (P0215_i_TransparentColor != CM1_COLOR_NO_TRANSPARENCY) {
                P0215_i_TransparentColor &= 0x7F;
        }
        if (G0578_B_UseByteBoxCoordinates == C1_TRUE) {
                L6344_ = M768_BOX_LEFT(((char*)P0211_pi_Box));
                L6345_ = M769_BOX_RIGHT(((char*)P0211_pi_Box));
                L6347_ = M771_BOX_BOTTOM(((char*)P0211_pi_Box));
                L6346_ = M770_BOX_TOP(((char*)P0211_pi_Box));
        } else {
                L6344_ = M768_BOX_LEFT(P0211_pi_Box);
                L6345_ = M769_BOX_RIGHT(P0211_pi_Box);
                L6347_ = M771_BOX_BOTTOM(P0211_pi_Box);
                L6346_ = M770_BOX_TOP(P0211_pi_Box);
        }
        P0212_i_LastUnitIndex <<= 3;
        P0213_ui_FirstUnitIndex <<= 3;
        L6348_ = P0212_i_LastUnitIndex - P0213_ui_FirstUnitIndex;
        L6349_ = P0207_puc_Bitmap_Source + P0213_ui_FirstUnitIndex;
        if (P0208_puc_Bitmap_Destination == NULL) {
                P0208_puc_Bitmap_Destination = G0348_Bitmap_Screen;
        }
        L6350_ = P0208_puc_Bitmap_Destination += (P0214_ui_DestinationByteWidth * L6346_) + (L6344_ >> 1);
        L6351_ = L6347_ - L6346_ + 1;
        L6352_ = (L6345_ - L6344_ + 1) >> 1;
        if (L6344_ % 2) {
                L6353_ = 0x0F;
        } else {
                L6353_ = 0xFF;
        }
        if (L6345_ % 2) {
                L6354_ = 0xFF;
        } else {
                L6354_ = 0xF0;
        }
        if ((L6353_ & L6354_) == 0xFF) {
                L6352_--;
        }
        if (L6352_ == 0) {
                if (L6344_ == L6345_) {
                        L6353_ &= L6354_;
                } else {
                        L6353_ |= L6354_;
                }
        }
        L6355_ = G3980_apuc_[P0215_i_TransparentColor];
#ifdef MEDIA350_G14ED_G20E
        L6356_ = G3981_apuc_[P0215_i_TransparentColor];
#endif
        if (L6343_) {
                P0215_i_TransparentColor = (P0215_i_TransparentColor << 4) | P0215_i_TransparentColor;
                asm {
                                LDX        L6348_
                        L0812E1:
                                LDA        L6352_
                                STA        L6359_
                                BNE        L0812EA
                                BRL        L081370
                        L0812EA:
                                SEP        #0x30
#ifdef MEDIA350_G14ED_G20E
                                LDA        [P0209_puc_Bitmap_Mask]
                                EOR        #0xff
                                AND        P0215_i_TransparentColor
                                STA        L6358_
#endif
                                LDA        [L6349_]
#ifdef MEDIA350_G14ED_G20E
                                AND        [P0209_puc_Bitmap_Mask]
                                ORA        L6358_
#endif
                                TAY
#ifdef MEDIA350_G14ED_G20E
                                LDA        [L6350_]
                                AND        [L6355_],Y
                                ORA        [L6356_],Y
#endif
                                EOR        [L6350_]
#ifdef MEDIA409_G21E
                                AND        [L6355_],Y
                                AND        [P0209_puc_Bitmap_Mask]
#endif
                                AND        L6354_
                                EOR        [L6350_]
                                STA        [L6350_]
                                REP        #0x30
                                DEX
                                BEQ        L081316
                                INC        L6349_
                                BNE        L081320
                                INC        L6349_+2
                                BRA        L081320
                        L081316:
                                LDA        P0207_puc_Bitmap_Source
                                STA        L6349_
                                LDA        P0207_puc_Bitmap_Source+2
                                STA        L6349_+2
                                LDX        P0212_i_LastUnitIndex
                        L081320:
                                INC        P0209_puc_Bitmap_Mask
                                BNE        L081326
                                INC        P0209_puc_Bitmap_Mask+2
                        L081326:
                                INC        L6350_
                                BNE        L08132C
                                INC        L6350_+2
                        L08132C:
                                DEC        L6359_
                                BEQ        L081370
                        L081330:
                                SEP        #0x30
#ifdef MEDIA350_G14ED_G20E
                                LDA        [P0209_puc_Bitmap_Mask]
                                EOR        #0xff
                                AND        P0215_i_TransparentColor
                                STA        L6358_
#endif
                                LDA        [L6349_]
#ifdef MEDIA350_G14ED_G20E
                                AND        [P0209_puc_Bitmap_Mask]
                                ORA        L6358_
#endif
                                TAY
#ifdef MEDIA350_G14ED_G20E
                                LDA        [L6350_]
#endif
#ifdef MEDIA409_G21E
                                EOR        [L6350_]
#endif
                                AND        [L6355_],Y
#ifdef MEDIA350_G14ED_G20E
                                ORA        [L6356_],Y
#endif
#ifdef MEDIA409_G21E
                                AND        [P0209_puc_Bitmap_Mask]
                                EOR        [L6350_]
#endif
                                STA        [L6350_]
                                REP        #0x30
                                DEX
                                BEQ        L081356
                                INC        L6349_
                                BNE        L081360
                                INC        L6349_+2
                                BRA        L081360
                        L081356:
                                LDA        P0207_puc_Bitmap_Source
                                STA        L6349_
                                LDA        P0207_puc_Bitmap_Source+2
                                STA        L6349_+2
                                LDX        P0212_i_LastUnitIndex
                        L081360:
                                INC        P0209_puc_Bitmap_Mask
                                BNE        L081366
                                INC        P0209_puc_Bitmap_Mask+2
                        L081366:
                                INC        L6350_
                                BNE        L08136C
                                INC        L6350_+2
                        L08136C:
                                DEC        L6359_
                                BNE        L081330
                        L081370:
                                SEP        #0x30
#ifdef MEDIA350_G14ED_G20E
                                LDA        [P0209_puc_Bitmap_Mask]
                                EOR        #0xff
                                AND        P0215_i_TransparentColor
                                STA        L6358_
#endif
                                LDA        [L6349_]
#ifdef MEDIA350_G14ED_G20E
                                AND        [P0209_puc_Bitmap_Mask]
                                ORA        L6358_
#endif
                                TAY
#ifdef MEDIA350_G14ED_G20E
                                LDA        [L6350_]
                                AND        [L6355_],Y
                                ORA        [L6356_],Y
#endif
                                EOR        [L6350_]
#ifdef MEDIA409_G21E
                                AND        [L6355_],Y
#endif
                                AND        L6353_
#ifdef MEDIA409_G21E
                                AND        [P0209_puc_Bitmap_Mask]
#endif
                                EOR        [L6350_]
                                STA        [L6350_]
                                REP        #0x30
                                DEX
                                BEQ        L08139C
                                INC        L6349_
                                BNE        L0813A6
                                INC        L6349_+2
                                BRA        L0813A6
                        L08139C:
                                LDA        P0207_puc_Bitmap_Source
                                STA        L6349_
                                LDA        P0207_puc_Bitmap_Source+2
                                STA        L6349_+2
                                LDX        P0212_i_LastUnitIndex
                        L0813A6:
                                INC        P0209_puc_Bitmap_Mask
                                BNE        L0813AC
                                INC        P0209_puc_Bitmap_Mask+2
                        L0813AC:
                                CLC
                                LDA        P0208_puc_Bitmap_Destination
                                ADC        P0214_ui_DestinationByteWidth
                                STA        P0208_puc_Bitmap_Destination
                                STA        L6350_
                                LDA        P0208_puc_Bitmap_Destination+2
                                ADC        #0x00
                                STA        P0208_puc_Bitmap_Destination+2
                                STA        L6350_+2
                                DEC        L6351_
                                BEQ        L0813C5
                                BRL        L0812E1
                        L0813C5:
                }
        } else {
                asm {
                        L0813C8:
                                LDX        L6348_
                        L0813CA:
                                LDA        L6352_
                                STA        L6359_
                                BEQ        L081432
                                SEP        #0x30
                                LDA        [L6349_]
                                TAY
#ifdef MEDIA350_G14ED_G20E
                                LDA        [L6350_]
                                AND        [L6355_],Y
                                ORA        [L6356_],Y
#endif
                                EOR        [L6350_]
#ifdef MEDIA409_G21E
                                AND        [L6355_],Y
#endif
                                AND        L6354_
                                EOR        [L6350_]
                                STA        [L6350_]
                                REP        #0x30
                                DEX
                                BEQ        L0813F0
                                INC        L6349_
                                BNE        L0813FA
                                INC        L6349_+2
                                BRA        L0813FA
                        L0813F0:
                                LDA        P0207_puc_Bitmap_Source
                                STA        L6349_
                                LDA        P0207_puc_Bitmap_Source+2
                                STA        L6349_+2
                                LDX        P0212_i_LastUnitIndex
                        L0813FA:
                                INC        L6350_
                                BNE        L081400
                                INC        L6350_+2
                        L081400:
                                DEC        L6359_
                                BEQ        L081432
                        L081404:
                                SEP        #0x30
                                LDA        [L6349_]
                                TAY
#ifdef MEDIA350_G14ED_G20E
                                LDA        [L6350_]
#endif
#ifdef MEDIA409_G21E
                                EOR        [L6350_]
#endif
                                AND        [L6355_],Y
#ifdef MEDIA350_G14ED_G20E
                                ORA        [L6356_],Y
#endif
#ifdef MEDIA409_G21E
                                EOR        [L6350_]
#endif
                                STA        [L6350_]
                                REP        #0x30
                                DEX
                                BEQ        L08141E
                                INC        L6349_
                                BNE        L081428
                                INC        L6349_+2
                                BRA        L081428
                        L08141E:
                                LDA        P0207_puc_Bitmap_Source
                                STA        L6349_
                                LDA        P0207_puc_Bitmap_Source+2
                                STA        L6349_+2
                                LDX        P0212_i_LastUnitIndex
                        L081428:
                                INC        L6350_
                                BNE        L08142E
                                INC        L6350_+2
                        L08142E:
                                DEC        L6359_
                                BNE        L081404
                        L081432:
                                SEP        #0x30
                                LDA        [L6349_]
                                TAY
#ifdef MEDIA350_G14ED_G20E
                                LDA        [L6350_]
                                AND        [L6355_],Y
                                ORA        [L6356_],Y
#endif
                                EOR        [L6350_]
#ifdef MEDIA409_G21E
                                AND        [L6355_],Y
#endif
                                AND        L6353_
                                EOR        [L6350_]
                                STA        [L6350_]
                                REP        #0x30
                                DEX
                                BEQ        L081452
                                INC        L6349_
                                BNE        L08145C
                                INC        L6349_+2
                                BRA        L08145C
                        L081452:
                                LDA        P0207_puc_Bitmap_Source
                                STA        L6349_
                                LDA        P0207_puc_Bitmap_Source+2
                                STA        L6349_+2
                                LDX        P0212_i_LastUnitIndex
                        L08145C:
                                CLC
                                LDA        P0208_puc_Bitmap_Destination
                                ADC        P0214_ui_DestinationByteWidth
                                STA        P0208_puc_Bitmap_Destination
                                STA        L6350_
                                LDA        P0208_puc_Bitmap_Destination+2
                                ADC        #0x00
                                STA        P0208_puc_Bitmap_Destination+2
                                STA        L6350_+2
                                DEC        L6351_
                                BEQ        L081475
                                BRL        L0813CA
                        L081475:
                }
        }
#endif
#ifdef MEDIA413_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        int16_t L1624_i_BoxHeight;
        int16_t L0232_i_BoxUnitWidth;
        long L1625_l_Unreferenced;


        AztecCDirective_asm
                        movem.l d4-d7/a2-a4,-(sp)
                        move.w  34(a5),d0               ; P0215_i_TransparentColor
                        cmp.b   #$FF,d0
                        beq.s   T0133030
                        tst.b   d0
                        bpl.s   T0133031
                        andi.w  #$7F,34(a5)             ; P0215_i_TransparentColor
                T0133030:
                        lea     T0133054,a3             ; if P0215_i_TransparentColor == 255 (no transparency)
                                                        ; OR not using mask then a3 = T0133054
                        bra.s   T0133032
                T0133031:
                        lea     T0133038,a3             ; if using mask and transparent color then a3 = T0133038
                        move.w  d0,d1
                        add.w   d0,d0
                        add.w   d1,d0
                        lsl.w   #1,d0
                        addq.w  #2,d0
                        jmp     (pc,d0.w)
                        lea     T0133054,a1
                        bra.s   T0133032
                        lea     T0133041,a1
                        bra.s   T0133032
                        lea     T0133045,a1
                        bra.s   T0133032
                        lea     T0133040,a1
                        bra.s   T0133032
                        lea     T0133043,a1
                        bra.s   T0133032
                        lea     T0133042,a1
                        bra.s   T0133032
                        lea     T0133044,a1
                        bra.s   T0133032
                        lea     T0133039,a1
                        bra.s   T0133032
                        lea     T0133053,a1
                        bra.s   T0133032
                        lea     T0133049,a1
                        bra.s   T0133032
                        lea     T0133047,a1
                        bra.s   T0133032
                        lea     T0133046,a1
                        bra.s   T0133032
                        lea     T0133052,a1
                        bra.s   T0133032
                        lea     T0133048,a1
                        bra.s   T0133032
                        lea     T0133051,a1
                        bra.s   T0133032
                        lea     T0133050,a1
                T0133032:
                        movea.l 8(a5),a0                ; P0207_puc_Bitmap_Source
                        move.w  42(a5),d6               ; P0928_i_Height2
                        move.w  30(a5),d7               ; P0213_ui_FirstUnitIndex
                        move.w  d7,d0
                        lsl.w   #1,d0
                        adda.w  d0,a0
                        swap    d7
                        movea.l 24(a5),a2               ; P0211_pi_Box
                        moveq   #0,d3
                        moveq   #0,d0
                        tst.w   _G0578_B_UseByteBoxCoordinates
                        beq.s   T0133033
                        move.b  (a2)+,d3
                        move.b  (a2)+,d0
                        bra.s   T0133034
                T0133033:
                        move.w  (a2)+,d3
                        move.w  (a2)+,d0
                T0133034:
                        sub.w   d3,d0
                        lsr.w   #4,d0
                        addq.w  #1,d0
                        move.w  d0,-4(a5)               ; L0232_i_BoxUnitWidth
                        moveq   #0,d3
                        moveq   #0,d5
                        tst.w   _G0578_B_UseByteBoxCoordinates
                        beq.s   T0133035
                        move.b  (a2)+,d3
                        move.b  (a2),d5
                        bra.s   T0133036
                T0133035:
                        move.w  (a2)+,d3
                        move.w  (a2),d5
                T0133036:
                        sub.w   d3,d5
                        addq.w  #1,d5
                        move.w  d5,-2(a5)               ; L1624_i_BoxHeight
                        mulu.w  d0,d5
                        move.w  d5,d7
                        swap    d6
                        move.w  d7,d6
                        lsl.w   #1,d6
                        swap    d6
                        subq.w  #1,d7
                        movea.l a1,a4
                        movea.l 16(a5),a1               ; P0209_puc_Bitmap_Mask
                        movea.l 20(a5),a2               ; P0210_puc_Bitmap_Temporary
                T0133037:
                        move.w  d6,d4
                        lsl.w   #1,d4
                        move.w  (a0),d0
                        move.w  (a0,d4.w),d1
                        move.w  d4,d5
                        lsl.w   #1,d5
                        move.w  (a0,d5.w),d2
                        add.w   d4,d5
                        move.w  (a0,d5.w),d3
                        addq.l  #2,a0
                        jmp     (a3)
                T0133038:
                        move.w  (a1)+,d5
                        and.w   d5,d0
                        and.w   d5,d1
                        and.w   d5,d2
                        and.w   d5,d3
                        not.w   d5
                        jmp     (a4)
                T0133039:
                        or.w    d5,d2
                T0133040:
                        or.w    d5,d1
                T0133041:
                        or.w    d5,d0
                        bra.s   T0133054
                T0133042:
                        or.w    d5,d0
                T0133043:
                        or.w    d5,d2
                        bra.s   T0133054
                T0133044:
                        or.w    d5,d2
                T0133045:
                        or.w    d5,d1
                        bra.s   T0133054
                T0133046:
                        or.w    d5,d0
                T0133047:
                        or.w    d5,d1
                        or.w    d5,d3
                        bra.s   T0133054
                T0133048:
                        or.w    d5,d2
                T0133049:
                        or.w    d5,d0
                        or.w    d5,d3
                        bra.s   T0133054
                T0133050:
                        or.w    d5,d0
                T0133051:
                        or.w    d5,d1
                T0133052:
                        or.w    d5,d2
                T0133053:
                        or.w    d5,d3
                T0133054:
                        move.l  d6,d4
                        swap    d4
                        move.w  d0,(a2)
                        move.w  d1,(a2,d4.w)
                        move.w  d4,d5
                        lsl.w   #1,d5
                        move.w  d2,(a2,d5.w)
                        add.w   d4,d5
                        move.w  d3,(a2,d5.w)
                        addq.l  #2,a2
                        swap    d7
                        addq.w  #1,d7
                        cmp.w   28(a5),d7               ; P0212_i_LastUnitIndex
                        beq.s   T0133056
                T0133055:
                        swap    d7
                        dbf     d7,T0133037
                        bra.s   T0133057
                T0133056:
                        move.w  #0,d7
                        movea.l 8(a5),a0                ; P0207_puc_Bitmap_Source
                        bra.s   T0133055
                T0133057:
                        movem.l (sp)+,d4-d7/a2-a4
                public _G0578_B_UseByteBoxCoordinates
        AztecCDirective_endasm
        F0132_VIDEO_Blit(P0210_puc_Bitmap_Temporary, P0208_puc_Bitmap_Destination, P0211_pi_Box, P0216_i_X, P0217_i_Y, L0232_i_BoxUnitWidth << 3, P0214_ui_DestinationByteWidth, P0215_i_TransparentColor, L1624_i_BoxHeight, P0927_i_DestinationHeight);
#endif
#ifdef MEDIA746_A36M_A31E_A31M_A33M_A35E_A35M
        int16_t L2214_ai_XYZ[4];
        int16_t L1624_i_BoxHeight;
        int16_t L0232_i_BoxUnitWidth;


#if (EXETYPE == C13_GRF1)
        ASM_STUB_PREFIX
#endif
        /* Very similar but different code as in Amiga 2.x */
        F1132_ConvertBoxCoordinates(P2416_pi_XYZ, L2214_ai_XYZ);
        asm {
                        movem.l d3-d7/a2-a6,-(sp)
                        move.w  P0215_i_TransparentColor(a6),d0
                        cmpi.b  #0xFF,d0
                        beq.s   @Tloc_139B6
                        tst.b   d0
                        bpl.s   @Tloc_139BE
                        andi.w  #0x7F,P0215_i_TransparentColor(a6)
                @Tloc_139B6:
                        lea     @Tloc_13AD6,a3
#ifdef MEDIA626_A31E_A31M_A33M_A35E_A35M
                        bra.w   @Tloc_13A2E
#endif
#ifdef MEDIA744_A36M
                        bra.s   @Tloc_13A2E
#endif
                @Tloc_139BE:
                        lea     @Tloc_13A9C,a3
                        move.w  d0,d1
                        add.w   d0,d0
                        add.w   d1,d0
                        lsl.w   #1,d0
                        addq.w  #2,d0
                        jmp     (pc,d0.w)
                        lea     @Tloc_13AD6,a1
                        bra.s   @Tloc_13A2E
                        lea     @Tloc_13AAE,a1
                        bra.s   @Tloc_13A2E
                        lea     @Tloc_13ABA,a1
                        bra.s   @Tloc_13A2E
                        lea     @Tloc_13AAC,a1
                        bra.s   @Tloc_13A2E
                        lea     @Tloc_13AB4,a1
                        bra.s   @Tloc_13A2E
                        lea     @Tloc_13AB2,a1
                        bra.s   @Tloc_13A2E
                        lea     @Tloc_13AB8,a1
                        bra.s   @Tloc_13A2E
                        lea     @Tloc_13AAA,a1
                        bra.s   @Tloc_13A2E
                        lea     @Tloc_13AD4,a1
                        bra.s   @Tloc_13A2E
                        lea     @Tloc_13AC8,a1
                        bra.s   @Tloc_13A2E
                        lea     @Tloc_13AC0,a1
                        bra.s   @Tloc_13A2E
                        lea     @Tloc_13ABE,a1
                        bra.s   @Tloc_13A2E
                        lea     @Tloc_13AD2,a1
                        bra.s   @Tloc_13A2E
                        lea     @Tloc_13AC6,a1
                        bra.s   @Tloc_13A2E
                        lea     @Tloc_13AD0,a1
                        bra.s   @Tloc_13A2E
                        lea     @Tloc_13ACE,a1
                @Tloc_13A2E:
                        movea.l P0207_puc_Bitmap_Source(a6),a0
                        move.w  P0928_i_Height2(a6),d6
                        move.w  P0213_ui_FirstUnitIndex(a6),d7
                        move.w  d7,d0
                        lsl.w   #1,d0
                        adda.w  d0,a0
                        swap    d7
                        lea     L2214_ai_XYZ(a6),a2
                        moveq   #0,d3
                        moveq   #0,d0
                        move.w  (a2)+,d3
                        move.w  (a2)+,d0
                        sub.w   d3,d0
                        lsr.w   #4,d0
                        addq.w  #1,d0
                        move.w  d0,L0232_i_BoxUnitWidth(a6)
                        moveq   #0,d3
                        moveq   #0,d5
                        move.w  (a2)+,d3
                        move.w  (a2),d5
                        sub.w   d3,d5
                        addq.w  #1,d5
                        move.w  d5,L1624_i_BoxHeight(a6)
                        mulu.w  d0,d5
                        move.w  d5,d7
                        swap    d6
                        move.w  d7,d6
                        lsl.w   #1,d6
                        swap    d6
                        subq.w  #1,d7
                        movea.l a1,a4
                        movea.l P0209_puc_Bitmap_Mask(a6),a1
                        movea.l P0210_puc_Bitmap_Temporary(a6),a2
                @Tloc_13A80:
                        move.w  d6,d4
                        lsl.w   #1,d4
                        move.w  (a0),d0
                        move.w  (a0,d4.w),d1
                        move.w  d4,d5
                        lsl.w   #1,d5
                        move.w  (a0,d5.w),d2
                        add.w   d4,d5
                        move.w  (a0,d5.w),d3
                        addq.l  #2,a0
                        jmp     (a3)
                @Tloc_13A9C:
                        move.w  (a1)+,d5
                        and.w   d5,d0
                        and.w   d5,d1
                        and.w   d5,d2
                        and.w   d5,d3
                        not.w   d5
                        jmp     (a4)
                @Tloc_13AAA:
                        or.w    d5,d2
                @Tloc_13AAC:
                        or.w    d5,d1
                @Tloc_13AAE:
                        or.w    d5,d0
                        bra.s   @Tloc_13AD6
                @Tloc_13AB2:
                        or.w    d5,d0
                @Tloc_13AB4:
                        or.w    d5,d2
                        bra.s   @Tloc_13AD6
                @Tloc_13AB8:
                        or.w    d5,d2
                @Tloc_13ABA:
                        or.w    d5,d1
                        bra.s   @Tloc_13AD6
                @Tloc_13ABE:
                        or.w    d5,d0
                @Tloc_13AC0:
                        or.w    d5,d1
                        or.w    d5,d3
                        bra.s   @Tloc_13AD6
                @Tloc_13AC6:
                        or.w    d5,d2
                @Tloc_13AC8:
                        or.w    d5,d0
                        or.w    d5,d3
                        bra.s   @Tloc_13AD6
                @Tloc_13ACE:
                        or.w    d5,d0
                @Tloc_13AD0:
                        or.w    d5,d1
                @Tloc_13AD2:
                        or.w    d5,d2
                @Tloc_13AD4:
                        or.w    d5,d3
                @Tloc_13AD6:
                        move.l  d6,d4
                        swap    d4
                        move.w  d0,(a2)
                        move.w  d1,(a2,d4.w)
                        move.w  d4,d5
                        lsl.w   #1,d5
                        move.w  d2,(a2,d5.w)
                        add.w   d4,d5
                        move.w  d3,(a2,d5.w)
                        addq.l  #2,a2
                        swap    d7
                        addq.w  #1,d7
                        cmp.w   P0212_i_LastUnitIndex(a6),d7
                        beq.s   @Tloc_13B02
                @Tloc_13AFA:
                        swap    d7
                        dbf     d7,@Tloc_13A80
                        bra.s   @Tloc_13B0C
                @Tloc_13B02:
                        move.w  #0,d7
                        movea.l P0207_puc_Bitmap_Source(a6),a0
                        bra.s   @Tloc_13AFA
                @Tloc_13B0C:
                        movem.l (sp)+,d3-d7/a2-a6
        }
#if (EXETYPE == C13_GRF1)
        F9086_GRF1_06_Blit(P0210_puc_Bitmap_Temporary, P0208_puc_Bitmap_Destination, P2416_pi_XYZ, P0216_i_X, P0217_i_Y, L0232_i_BoxUnitWidth << 4, P0214_ui_DestinationByteWidth, P0215_i_TransparentColor, L1624_i_BoxHeight, P0927_i_DestinationHeight);
#else
        F0132_VIDEO_Blit(P0210_puc_Bitmap_Temporary, P0208_puc_Bitmap_Destination, P2416_pi_XYZ, P0216_i_X, P0217_i_Y, L0232_i_BoxUnitWidth << 4, P0214_ui_DestinationByteWidth, P0215_i_TransparentColor, L1624_i_BoxHeight, P0927_i_DestinationHeight);
#endif
#endif
#ifdef MEDIA457_P20JA
        int16_t L2215_ai_XYZ1[4];
        int16_t L2216_ai_XYZ2[4];
        int16_t L2217_i_;
        unsigned char* L2218_puc_puc_Bitmap;
        char L2219_c_;
        unsigned char L2220_uc_;
        int16_t L2221_i_;
        int16_t L2222_i_;


        P0213_ui_FirstUnitIndex = P0213_ui_FirstUnitIndex << 4;
        L2222_i_ = P0212_i_LastUnitIndex << 4;
        M704_ZONE_LEFT(L2216_ai_XYZ2) = M704_ZONE_LEFT(P2416_pi_XYZ);
        M705_ZONE_RIGHT(L2216_ai_XYZ2) = M705_ZONE_RIGHT(P2416_pi_XYZ);
        M706_ZONE_TOP(L2216_ai_XYZ2) = M706_ZONE_TOP(P2416_pi_XYZ);
        M707_ZONE_BOTTOM(L2216_ai_XYZ2) = M707_ZONE_BOTTOM(P2416_pi_XYZ);
        L2222_i_ >>= 1;
        P0213_ui_FirstUnitIndex >>= 1;
        L2220_uc_ = P0215_i_TransparentColor & 0x0F;
        for (L2221_i_ = 0; L2221_i_ < L2222_i_; L2221_i_++) {
                L2219_c_ = 0;
                if ((P0207_puc_Bitmap_Source[L2221_i_] & 0x0F) != L2220_uc_) {
                        L2219_c_ |= P0207_puc_Bitmap_Source[L2221_i_] & 0x0F;
                }
                if ((P0207_puc_Bitmap_Source[L2221_i_] >> 4) != L2220_uc_) {
                        L2219_c_ |= P0207_puc_Bitmap_Source[L2221_i_] & 0xF0;
                }
                G3041_ac_[L2221_i_] = L2219_c_;
        }
        L2217_i_ = ((M708_ZONE_WIDTH(L2216_ai_XYZ2) + 1) >> 1) * (M709_ZONE_HEIGHT(L2216_ai_XYZ2));
        L2218_puc_puc_Bitmap = P0210_puc_Bitmap_Temporary;
        if (P0213_ui_FirstUnitIndex > 0) {
                F0007_MAIN_CopyBytes((char*)G3041_ac_ + P0213_ui_FirstUnitIndex, (char*)L2218_puc_puc_Bitmap, (long)(L2221_i_ = L2222_i_ - P0213_ui_FirstUnitIndex));
                L2217_i_ -= L2221_i_;
                L2218_puc_puc_Bitmap += L2221_i_;
        }
        while (L2217_i_ > L2222_i_) {
                F0007_MAIN_CopyBytes((char*)G3041_ac_, (char*)L2218_puc_puc_Bitmap, (long)L2222_i_);
                L2217_i_ -= L2222_i_;
                L2218_puc_puc_Bitmap += L2222_i_;
        }
        if (L2217_i_ > 0) {
                F0007_MAIN_CopyBytes((char*)G3041_ac_, (char*)L2218_puc_puc_Bitmap, (long)L2217_i_);
        }
        M704_ZONE_LEFT(L2215_ai_XYZ1) = 0;
        M705_ZONE_RIGHT(L2215_ai_XYZ1) = M708_ZONE_WIDTH(L2216_ai_XYZ2) - 1;
        M706_ZONE_TOP(L2215_ai_XYZ1) = 0;
        M707_ZONE_BOTTOM(L2215_ai_XYZ1) = M709_ZONE_HEIGHT(L2216_ai_XYZ2) - 1;
        if (!M007_GET(P0215_i_TransparentColor, MASK0x0080_UNKNOWN)) {
                F0132_VIDEO_Blit(P0209_puc_Bitmap_Mask, P0210_puc_Bitmap_Temporary, L2215_ai_XYZ1, 0, 0, M705_ZONE_RIGHT(L2215_ai_XYZ1) + 1, M705_ZONE_RIGHT(L2215_ai_XYZ1) + 1, C15_COLOR_WHITE, MASK0x0000_NO_FLIP);
        }
        F0132_VIDEO_Blit(P0210_puc_Bitmap_Temporary, P0208_puc_Bitmap_Destination, L2216_ai_XYZ2, P0216_i_X, P0217_i_Y, M705_ZONE_RIGHT(L2215_ai_XYZ1) + 1, P0214_ui_DestinationByteWidth, C00_COLOR_BLACK, MASK0x0000_NO_FLIP);
#endif
#ifdef MEDIA601_X30J_P20JB_I34E_I34M_X31J_P31J
#ifdef MEDIA600_X30J_P20JB_X31J
        REGISTER unsigned char* L2006_puc_Bitmap;
#endif
#ifdef MEDIA469_P20JB
        int16_t L2010_i_;
        int16_t L2008_i_;
#endif
#ifdef MEDIA600_X30J_P20JB_X31J
        REGISTER int16_t L2009_i_;
        char L2012_c_;
#endif
#ifdef MEDIA607_X30J_X31J
        int16_t L2013_i_;
#endif
#ifdef MEDIA600_X30J_P20JB_X31J
        unsigned char L2014_uc_;
        REGISTER unsigned char* L2007_puc_Buffer;
        int16_t L2015_ai_XYZ1[4];
        int16_t L2016_ai_XYZ2[4];
        REGISTER int16_t L2017_i_;
#endif
#ifdef MEDIA469_P20JB
        int16_t L2013_i_;
#endif
#ifdef MEDIA607_X30J_X31J
        register int16_t L2008_i_;
        register int16_t L2010_i_;
#endif
#ifdef MEDIA600_X30J_P20JB_X31J
        REGISTER int16_t L2011_i_;
#endif
#ifdef MEDIA553_F20E_F20J_I34E_I34M_F31E_F31J_P31J
        unsigned char* L2006_puc_Bitmap;
        unsigned char* L2007_puc_Buffer;
#ifdef MEDIA709_I34E_I34M_P31J
        int16_t L2008_i_;
#endif
#ifdef MEDIA551_F20E_F20J_F31E_F31J
        register int16_t L2008_i_;
#endif
        int16_t L2009_i_;
        int16_t L2010_i_;
        int16_t L2011_i_;
#ifdef MEDIA709_I34E_I34M_P31J
        char L2012_c_;
#endif
#ifdef MEDIA551_F20E_F20J_F31E_F31J
        register char L2012_c_;
#endif
        int16_t L2013_i_;
        unsigned char L2014_uc_;
        int16_t L2015_ai_XYZ1[4];
        int16_t L2016_ai_XYZ2[4];
#ifdef MEDIA709_I34E_I34M_P31J
        int16_t L2017_i_;
#endif
#ifdef MEDIA551_F20E_F20J_F31E_F31J
        register int16_t L2017_i_;
#endif
#endif


#if (defined(MEDIA634_A31E_A31M_X31J) && (EXETYPE == C13_GRF1))
        ASM_STUB_PREFIX
#endif
#if (!(defined(MEDIA692_X31J) && (EXETYPE == C13_GRF1))) /* Function body is nearly empty in this version */
        P0213_ui_FirstUnitIndex <<= 3;
#ifdef MEDIA501_F20E_F20J_P20JB
        L2008_i_ = P0212_i_LastUnitIndex << 4;
#endif
#ifdef MEDIA608_X30J_I34E_I34M_F31E_F31J_X31J_P31J
        L2008_i_ = P0212_i_LastUnitIndex << 3;
#endif
        F0007_MAIN_CopyBytes((char*)P2416_pi_XYZ, (char*)L2016_ai_XYZ2, (long)sizeof(L2016_ai_XYZ2));
#ifdef MEDIA501_F20E_F20J_P20JB
        L2008_i_ >>= 1;
#endif
        L2007_puc_Buffer = M533_F0468_MEMORY_Allocate(C800L_UNKNOWN, C0_ALLOCATION_TEMPORARY_ON_TOP_OF_HEAP, MASK0x0008_MEMREQ);
#ifdef MEDIA608_X30J_I34E_I34M_F31E_F31J_X31J_P31J
        L2014_uc_ = P0215_i_TransparentColor & 0x0F;
#endif
        L2017_i_ = 0;
        L2013_i_ = 0;
#ifdef MEDIA601_X30J_P20JB_I34E_I34M_X31J_P31J
        if ((L2011_i_ = M100_PIXEL_WIDTH(P0207_puc_Bitmap_Source) & 1) != 0) {
                L2011_i_ = (2 - L2011_i_) >> 1;
        }
#endif
#ifdef MEDIA551_F20E_F20J_F31E_F31J
        if ((L2011_i_ = M100_PIXEL_WIDTH(P0207_puc_Bitmap_Source) & 0x1F) != 0)
                L2011_i_ = (32 - L2011_i_) >> 1;
#endif
#ifdef MEDIA501_F20E_F20J_P20JB
        L2014_uc_ = P0215_i_TransparentColor & 0x0F;
#endif
        for (L2009_i_ = 0; L2009_i_ < L2008_i_; L2009_i_++) {
                L2012_c_ = 0;
                if ((P0207_puc_Bitmap_Source[L2017_i_] & 0x0F) != L2014_uc_)
                        L2012_c_ |= P0207_puc_Bitmap_Source[L2017_i_] & 0x0F;
                if ((P0207_puc_Bitmap_Source[L2017_i_] >> 4) != L2014_uc_)
                        L2012_c_ |= P0207_puc_Bitmap_Source[L2017_i_] & 0xF0;
                L2007_puc_Buffer[L2009_i_] = L2012_c_;
                L2017_i_++;
                if (L2011_i_ && (++L2013_i_ >= (M100_PIXEL_WIDTH(P0207_puc_Bitmap_Source) >> 1))) {
                        L2017_i_ += L2011_i_;
                        L2013_i_ = 0;
                }
        }
        L2010_i_ = M103_BITMAP_BYTE_COUNT(M708_ZONE_WIDTH(L2016_ai_XYZ2), M709_ZONE_HEIGHT(L2016_ai_XYZ2));
        L2006_puc_Bitmap = P0210_puc_Bitmap_Temporary;
        if (P0213_ui_FirstUnitIndex > 0) {
                L2009_i_ = L2008_i_ - P0213_ui_FirstUnitIndex;
                F0007_MAIN_CopyBytes((char*)L2007_puc_Buffer + P0213_ui_FirstUnitIndex, (char*)L2006_puc_Bitmap, (long)L2009_i_);
                L2010_i_ -= L2009_i_;
                L2006_puc_Bitmap += L2009_i_;
        }
        while (L2010_i_ > L2008_i_) {
                F0007_MAIN_CopyBytes((char*)L2007_puc_Buffer, (char*)L2006_puc_Bitmap, (long)L2008_i_);
                L2010_i_ -= L2008_i_;
                L2006_puc_Bitmap += L2008_i_;
        }
        if (L2010_i_ > 0) {
                F0007_MAIN_CopyBytes((char*)L2007_puc_Buffer, (char*)L2006_puc_Bitmap, (long)L2010_i_);
        }
        F0469_MEMORY_FreeAtHeapTop(C800L_UNKNOWN);
#ifdef MEDIA541_F20E_F20J_X30J_P20JB
        M704_ZONE_LEFT(L2015_ai_XYZ1) = 0;
        M705_ZONE_RIGHT(L2015_ai_XYZ1) = M708_ZONE_WIDTH(L2016_ai_XYZ2) - 1;
        M706_ZONE_TOP(L2015_ai_XYZ1) = 0;
        M707_ZONE_BOTTOM(L2015_ai_XYZ1) = M709_ZONE_HEIGHT(L2016_ai_XYZ2) - 1;
#endif
#ifdef MEDIA713_I34E_I34M_F31E_F31J_X31J_P31J
        M704_ZONE_LEFT(L2015_ai_XYZ1) = M706_ZONE_TOP(L2015_ai_XYZ1) = 0;
        M708_ZONE_WIDTH(L2015_ai_XYZ1) = M708_ZONE_WIDTH(L2016_ai_XYZ2);
        M709_ZONE_HEIGHT(L2015_ai_XYZ1) = M709_ZONE_HEIGHT(L2016_ai_XYZ2);
#endif
#ifdef MEDIA480_P20JB_I34E_I34M_P31J
        if (!M007_GET(P0215_i_TransparentColor, MASK0x0080_UNKNOWN)) {
#endif
#ifdef MEDIA543_F20E_F20J_X30J_F31E_F31J_X31J
        if (M007_GET(P0215_i_TransparentColor, MASK0x0080_UNKNOWN) == 0) {
#endif
#ifdef MEDIA469_P20JB
                F0132_VIDEO_Blit(P0209_puc_Bitmap_Mask, P0210_puc_Bitmap_Temporary, L2015_ai_XYZ1, P0216_i_X, P0217_i_Y, M705_ZONE_RIGHT(L2015_ai_XYZ1) + P0216_i_X + 1, M705_ZONE_RIGHT(L2015_ai_XYZ1) + 1, C15_COLOR_WHITE, MASK0x0000_NO_FLIP);
        }
        F0132_VIDEO_Blit(P0210_puc_Bitmap_Temporary, P0208_puc_Bitmap_Destination, L2016_ai_XYZ2, 0, 0, M705_ZONE_RIGHT(L2015_ai_XYZ1) + 1, P0214_ui_DestinationByteWidth, C00_COLOR_BLACK, MASK0x0000_NO_FLIP);
#endif
#ifdef MEDIA506_F20E_F20J_X30J
                F0132_VIDEO_Blit(P0209_puc_Bitmap_Mask, P0210_puc_Bitmap_Temporary, L2015_ai_XYZ1, 0, 0, M705_ZONE_RIGHT(L2015_ai_XYZ1) + 1, M705_ZONE_RIGHT(L2015_ai_XYZ1) + 1, C15_COLOR_WHITE);
        }
        F0132_VIDEO_Blit(P0210_puc_Bitmap_Temporary, P0208_puc_Bitmap_Destination, L2016_ai_XYZ2, P0216_i_X, P0217_i_Y, M705_ZONE_RIGHT(L2015_ai_XYZ1) + 1, P0214_ui_DestinationByteWidth, C00_COLOR_BLACK);
#endif
#ifdef MEDIA673_F31E_F31J_X31J
                F0132_VIDEO_Blit(P0209_puc_Bitmap_Mask, P0210_puc_Bitmap_Temporary, L2015_ai_XYZ1, P0216_i_X, P0217_i_Y, M708_ZONE_WIDTH(L2016_ai_XYZ2), M708_ZONE_WIDTH(L2016_ai_XYZ2), C15_COLOR_WHITE);
        }
        F0132_VIDEO_Blit(P0210_puc_Bitmap_Temporary, P0208_puc_Bitmap_Destination, L2016_ai_XYZ2, 0, 0, M708_ZONE_WIDTH(L2016_ai_XYZ2), P0214_ui_DestinationByteWidth, C00_COLOR_BLACK);
#endif
#ifdef MEDIA709_I34E_I34M_P31J
                F0132_VIDEO_Blit(P0209_puc_Bitmap_Mask, P0210_puc_Bitmap_Temporary, L2015_ai_XYZ1, P0216_i_X, P0217_i_Y, M708_ZONE_WIDTH(L2016_ai_XYZ2), M708_ZONE_WIDTH(L2016_ai_XYZ2), C15_COLOR_WHITE, MASK0x0000_NO_FLIP);
        }
        F0132_VIDEO_Blit(P0210_puc_Bitmap_Temporary, P0208_puc_Bitmap_Destination, L2016_ai_XYZ2, 0, 0, M708_ZONE_WIDTH(L2016_ai_XYZ2), P0214_ui_DestinationByteWidth, C00_COLOR_BLACK, MASK0x0000_NO_FLIP);
#endif
#endif
#if (defined(MEDIA634_A31E_A31M_X31J) && (EXETYPE == C13_GRF1))
        ASM_STUB_SUFFIX
#endif
#endif
#ifdef MEDIA551_F20E_F20J_F31E_F31J
#ifdef MEDIA488_F20E_F20J
        int16_t L2008_i_;
        int16_t L2017_i_;
        char L2012_c_;
        unsigned char* L2006_puc_Bitmap;
        int16_t L2010_i_;
        int16_t L2009_i_;
        unsigned char L2014_uc_;
        unsigned char* L2007_puc_Buffer;
        int16_t L2015_ai_XYZ1[4];
        int16_t L2016_ai_XYZ2[4];
        int16_t L2013_i_;
        int16_t L2011_i_;
#endif
#ifdef MEDIA670_F31E_F31J
        int16_t L2017_i_;
        int16_t L2008_i_;
        char L2012_c_;
        unsigned char* L2006_puc_Bitmap;
        unsigned char* L2007_puc_Buffer;
        int16_t L2009_i_;
        int16_t L2010_i_;
        int16_t L2011_i_;
        int16_t L2013_i_;
        unsigned char L2014_uc_;
        int16_t L2015_ai_XYZ1[4];
        int16_t L2016_ai_XYZ2[4];
#endif


        P0213_ui_FirstUnitIndex <<= 3;
#ifdef MEDIA488_F20E_F20J
        L2008_i_ = P0212_i_LastUnitIndex << 4;
#endif
#ifdef MEDIA670_F31E_F31J
        L2008_i_ = P0212_i_LastUnitIndex << 3;
#endif
        F0007_MAIN_CopyBytes((char*)P2416_pi_XYZ, (char*)L2016_ai_XYZ2, (long)sizeof(L2016_ai_XYZ2));
#ifdef MEDIA488_F20E_F20J
        L2008_i_ >>= 1;
#endif
        L2007_puc_Buffer = M533_F0468_MEMORY_Allocate(C800L_UNKNOWN, C0_ALLOCATION_TEMPORARY_ON_TOP_OF_HEAP, MASK0x0008_MEMREQ);
#ifdef MEDIA670_F31E_F31J
        L2014_uc_ = P0215_i_TransparentColor & 0x0F;
#endif
#ifdef MEDIA488_F20E_F20J
        L2017_i_ = L2013_i_ = 0;
#endif
#ifdef MEDIA670_F31E_F31J
        L2017_i_ = 0;
        L2013_i_ = 0;
#endif
        if ((L2011_i_ = M100_PIXEL_WIDTH(P0207_puc_Bitmap_Source) & 0x1F) != 0)
                L2011_i_ = (32 - L2011_i_) >> 1;
#ifdef MEDIA488_F20E_F20J
        L2014_uc_ = P0215_i_TransparentColor & 0x0F;
#endif
        for (L2009_i_ = 0; L2009_i_ < L2008_i_; L2009_i_++) {
                L2012_c_ = 0;
                if ((P0207_puc_Bitmap_Source[L2017_i_] & 0x0F) != L2014_uc_)
                        L2012_c_ |= P0207_puc_Bitmap_Source[L2017_i_] & 0x0F;
                if ((P0207_puc_Bitmap_Source[L2017_i_] >> 4) != L2014_uc_)
                        L2012_c_ |= P0207_puc_Bitmap_Source[L2017_i_] & 0xF0;
                L2007_puc_Buffer[L2009_i_] = L2012_c_;
                L2017_i_++;
                if (L2011_i_ && (++L2013_i_ >= (M100_PIXEL_WIDTH(P0207_puc_Bitmap_Source) >> 1))) {
                        L2017_i_ += L2011_i_;
                        L2013_i_ = 0;
                }
        }
        L2010_i_ = M103_BITMAP_BYTE_COUNT(M708_ZONE_WIDTH(L2016_ai_XYZ2), M709_ZONE_HEIGHT(L2016_ai_XYZ2));
        L2006_puc_Bitmap = P0210_puc_Bitmap_Temporary;
        if (P0213_ui_FirstUnitIndex > 0) {
                L2009_i_ = L2008_i_ - P0213_ui_FirstUnitIndex;
                F0007_MAIN_CopyBytes((char*)L2007_puc_Buffer + P0213_ui_FirstUnitIndex, (char*)L2006_puc_Bitmap, (long)L2009_i_);
                L2010_i_ -= L2009_i_;
                L2006_puc_Bitmap += L2009_i_;
        }
        while (L2010_i_ > L2008_i_) {
                F0007_MAIN_CopyBytes((char*)L2007_puc_Buffer, (char*)L2006_puc_Bitmap, (long)L2008_i_);
                L2010_i_ -= L2008_i_;
                L2006_puc_Bitmap += L2008_i_;
        }
        if (L2010_i_ > 0) {
                F0007_MAIN_CopyBytes((char*)L2007_puc_Buffer, (char*)L2006_puc_Bitmap, (long)L2010_i_);
        }
        F0469_MEMORY_FreeAtHeapTop(C800L_UNKNOWN);
#ifdef MEDIA488_F20E_F20J
        M704_ZONE_LEFT(L2015_ai_XYZ1) = 0;
        M705_ZONE_RIGHT(L2015_ai_XYZ1) = L2016_ai_XYZ2[1] - L2016_ai_XYZ2[0];
        M706_ZONE_TOP(L2015_ai_XYZ1) = 0;
        M707_ZONE_BOTTOM(L2015_ai_XYZ1) = L2016_ai_XYZ2[3] - L2016_ai_XYZ2[2];
#endif
#ifdef MEDIA670_F31E_F31J
        M704_ZONE_LEFT(L2015_ai_XYZ1) = M706_ZONE_TOP(L2015_ai_XYZ1) = 0;
        M708_ZONE_WIDTH(L2015_ai_XYZ1) = M708_ZONE_WIDTH(L2016_ai_XYZ2);
        M709_ZONE_HEIGHT(L2015_ai_XYZ1) = M709_ZONE_HEIGHT(L2016_ai_XYZ2);
#endif
        if (M007_GET(P0215_i_TransparentColor, MASK0x0080_UNKNOWN) == 0) {
#ifdef MEDIA488_F20E_F20J
                F0132_VIDEO_Blit(P0209_puc_Bitmap_Mask, P0210_puc_Bitmap_Temporary, L2015_ai_XYZ1, 0, 0, M705_ZONE_RIGHT(L2015_ai_XYZ1) + 1, M705_ZONE_RIGHT(L2015_ai_XYZ1) + 1, C15_COLOR_WHITE);
        }
        F0132_VIDEO_Blit(P0210_puc_Bitmap_Temporary, P0208_puc_Bitmap_Destination, L2016_ai_XYZ2, P0216_i_X, P0217_i_Y, M705_ZONE_RIGHT(L2015_ai_XYZ1) + 1, P0214_ui_DestinationByteWidth, C00_COLOR_BLACK);
#endif
#ifdef MEDIA670_F31E_F31J
                F0132_VIDEO_Blit(P0209_puc_Bitmap_Mask, P0210_puc_Bitmap_Temporary, L2015_ai_XYZ1, P0216_i_X, P0217_i_Y, M708_ZONE_WIDTH(L2016_ai_XYZ2), M708_ZONE_WIDTH(L2016_ai_XYZ2), C15_COLOR_WHITE);
        }
        F0132_VIDEO_Blit(P0210_puc_Bitmap_Temporary, P0208_puc_Bitmap_Destination, L2016_ai_XYZ2, 0, 0, M708_ZONE_WIDTH(L2016_ai_XYZ2), P0214_ui_DestinationByteWidth, C00_COLOR_BLACK);
#endif
#endif
}
#endif
