#ifndef COMPILE_H
#include "COMPILE.H"
#endif
#ifdef MEDIA044_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_SU1E_AU1E_AU2E
#ifdef MEDIA007_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E
overlay "show"
#endif
#ifdef MEDIA351_G14ED_G20E_G21E
segment "gsthings"
#endif

#ifdef MEDIA746_A36M_A31E_A31M_A33M_A35E_A35M
unsigned char G3212_auc_PaletteChanges_NoChanges[16] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
#endif
#ifdef MEDIA458_P20JA_P20JB
unsigned char G2304_ac_BlitShrink_PaletteChanges[16];
#endif
#ifdef MEDIA709_I34E_I34M_P31J
unsigned char* G2042_puc_BlitShrink_PaletteChanges;
#endif
#ifdef MEDIA463_P20JA_P20JB_I34E_I34M_P31J
unsigned char* G2043_puc_BlitShrink_BitmapSource;
unsigned char* G2044_puc_BlitShrink_BitmapDestination;
#endif

#ifdef MEDIA551_F20E_F20J_F31E_F31J /* Variables moved to FLIPVERT.C to force correct compilation of F0721_ and F0129_ */
extern unsigned char G2304_ac_BlitShrink_PaletteChanges[16];
extern unsigned char* G2042_puc_BlitShrink_PaletteChanges;
extern unsigned char* G2043_puc_BlitShrink_BitmapSource;
extern unsigned char* G2044_puc_BlitShrink_BitmapDestination;
#endif


#ifdef MEDIA496_F20E_F20J_P20JA_P20JB_I34E_I34M_F31E_F31J_P31J
STATICFUNCTION void F0720_ShrinkBLT_Sub1(
int16_t          P2408_i_  SEPARATOR
unsigned int16_t P2409_ui_ SEPARATOR
unsigned int16_t P2410_ui_ SEPARATOR
unsigned int16_t P2411_ui_ FINAL_SEPARATOR
{
#ifdef MEDIA463_P20JA_P20JB_I34E_I34M_P31J
        unsigned int16_t L2223_i_;
        unsigned int16_t L2224_i_;
        unsigned int16_t L2225_ui_;
        unsigned char L2226_uc_;
        unsigned char L2227_uc_;


        L2223_i_ = P2410_ui_ >> 1;
        L2224_i_ = P2409_ui_;
        while (P2411_ui_ + P2409_ui_ > L2224_i_) {
                L2226_uc_ = G2043_puc_BlitShrink_BitmapSource[(L2225_ui_ = (L2223_i_ >> 6) + P2408_i_) >> 1];
                L2223_i_ += P2410_ui_;
                if (M007_GET(L2225_ui_, MASK0x0001_UNKNOWN)) {
                        L2227_uc_ = L2226_uc_ << 4;
                } else {
                        L2227_uc_ = L2226_uc_ & 0xF0;
                }
                L2226_uc_ = G2043_puc_BlitShrink_BitmapSource[(L2225_ui_ = (L2223_i_ >> 6) + P2408_i_) >> 1];
                L2223_i_ += P2410_ui_;
                if (M007_GET(L2225_ui_, MASK0x0001_UNKNOWN)) {
                        G2044_puc_BlitShrink_BitmapDestination[L2224_i_ >> 1] = L2227_uc_ | (L2226_uc_ & 0x0F);
                } else {
                        G2044_puc_BlitShrink_BitmapDestination[L2224_i_ >> 1] = L2227_uc_ | (L2226_uc_ >> 4);
                }
                L2224_i_ += 2;
        }
#endif
#ifdef MEDIA551_F20E_F20J_F31E_F31J
        unsigned int16_t L2223_i_ = P2410_ui_ >> 1;
        unsigned int16_t L2224_i_;
        unsigned int16_t L2225_ui_;
        unsigned int16_t L6560_;


        for (L2224_i_ = 0; L2224_i_ < P2411_ui_; L2224_i_++) {
                L2225_ui_ = (L2223_i_ >> 6) + P2408_i_;
                L6560_ = (L2224_i_ >> 1) + (P2409_ui_ >> 1);
                if (L2224_i_ & 1) {
                        if (L2225_ui_ & 1) {
                                G2044_puc_BlitShrink_BitmapDestination[L6560_] = (G2044_puc_BlitShrink_BitmapDestination[L6560_] & 0x0F) | (G2043_puc_BlitShrink_BitmapSource[L2225_ui_ >> 1] & 0xF0);
                        } else {
                                G2044_puc_BlitShrink_BitmapDestination[L6560_] = (G2044_puc_BlitShrink_BitmapDestination[L6560_] & 0x0F) | (G2043_puc_BlitShrink_BitmapSource[L2225_ui_ >> 1] << 4);
                        }
                } else {
                        if (L2225_ui_ & 1) {
                                G2044_puc_BlitShrink_BitmapDestination[L6560_] = (G2044_puc_BlitShrink_BitmapDestination[L6560_] & 0xF0) | (G2043_puc_BlitShrink_BitmapSource[L2225_ui_ >> 1] >> 4);
                        } else {
                                G2044_puc_BlitShrink_BitmapDestination[L6560_] = (G2044_puc_BlitShrink_BitmapDestination[L6560_] & 0xF0) | (G2043_puc_BlitShrink_BitmapSource[L2225_ui_ >> 1] & 0x0F);
                        }
                }
                L2223_i_ += P2410_ui_;
        }
#endif
}

STATICFUNCTION void F0721_ShrinkBLT_Sub2(
int16_t          P2412_i_  SEPARATOR
unsigned int16_t P2413_ui_ SEPARATOR
unsigned int16_t P2414_ui_ SEPARATOR
unsigned int16_t P2415_ui_ FINAL_SEPARATOR
{
#ifdef MEDIA463_P20JA_P20JB_I34E_I34M_P31J
        unsigned int16_t L2228_ui_;
        unsigned int16_t L2229_ui_;
        unsigned int16_t L2230_ui_;
        unsigned char L2231_uc_;
        unsigned char L2232_uc_;


        L2228_ui_ = P2414_ui_ >> 1;
        L2229_ui_ = P2413_ui_;
        while (P2415_ui_ + P2413_ui_ > L2229_ui_) {
                L2231_uc_ = G2043_puc_BlitShrink_BitmapSource[(L2230_ui_ = (L2228_ui_ >> 6) + P2412_i_) >> 1];
                L2228_ui_ += P2414_ui_;
                if (M007_GET(L2230_ui_, MASK0x0001_UNKNOWN)) {
#ifdef MEDIA458_P20JA_P20JB
                        L2232_uc_ = G2304_ac_BlitShrink_PaletteChanges[L2231_uc_ & 0x0F] << 4;
#endif
#ifdef MEDIA709_I34E_I34M_P31J
                        L2232_uc_ = G2042_puc_BlitShrink_PaletteChanges[L2231_uc_ & 0x0F] << 4;
#endif
                } else {
#ifdef MEDIA458_P20JA_P20JB
                        L2232_uc_ = G2304_ac_BlitShrink_PaletteChanges[L2231_uc_ >> 4] << 4;
#endif
#ifdef MEDIA709_I34E_I34M_P31J
                        L2232_uc_ = G2042_puc_BlitShrink_PaletteChanges[L2231_uc_ >> 4] << 4;
#endif
                }
                L2231_uc_ = G2043_puc_BlitShrink_BitmapSource[(L2230_ui_ = (L2228_ui_ >> 6) + P2412_i_) >> 1];
                L2228_ui_ += P2414_ui_;
                if (M007_GET(L2230_ui_, MASK0x0001_UNKNOWN)) {
#ifdef MEDIA458_P20JA_P20JB
                        G2044_puc_BlitShrink_BitmapDestination[L2229_ui_ >> 1] = L2232_uc_ | G2304_ac_BlitShrink_PaletteChanges[L2231_uc_ & 0x0F];
#endif
#ifdef MEDIA709_I34E_I34M_P31J
                        G2044_puc_BlitShrink_BitmapDestination[L2229_ui_ >> 1] = L2232_uc_ | G2042_puc_BlitShrink_PaletteChanges[L2231_uc_ & 0x0F];
#endif
                } else {
#ifdef MEDIA458_P20JA_P20JB
                        G2044_puc_BlitShrink_BitmapDestination[L2229_ui_ >> 1] = L2232_uc_ | G2304_ac_BlitShrink_PaletteChanges[L2231_uc_ >> 4];
#endif
#ifdef MEDIA709_I34E_I34M_P31J
                        G2044_puc_BlitShrink_BitmapDestination[L2229_ui_ >> 1] = L2232_uc_ | G2042_puc_BlitShrink_PaletteChanges[L2231_uc_ >> 4];
#endif
                }
                L2229_ui_ += 2;
        }
#endif
#ifdef MEDIA551_F20E_F20J_F31E_F31J
        unsigned int16_t L2228_ui_ = P2414_ui_ >> 1;
        unsigned int16_t L2229_ui_;
        unsigned int16_t L2230_ui_;
        unsigned int16_t L6561_;
        unsigned char L2231_uc_;


        for (L2229_ui_ = 0; L2229_ui_ < P2415_ui_; L2229_ui_++) {
                L2230_ui_ = (L2228_ui_ >> 6) + P2412_i_;
                L6561_ = (L2229_ui_ >> 1) + (P2413_ui_ >> 1);
                L2231_uc_ = G2043_puc_BlitShrink_BitmapSource[L2230_ui_ >> 1];
                if (L2229_ui_ & 1) {
                        if (L2230_ui_ & 1) {
#ifdef MEDIA488_F20E_F20J
                                G2044_puc_BlitShrink_BitmapDestination[L6561_] = (G2044_puc_BlitShrink_BitmapDestination[L6561_] & 0x0F) | (G2304_ac_BlitShrink_PaletteChanges[L2231_uc_ >> 4] << 4);
#endif
#ifdef MEDIA670_F31E_F31J
                                G2044_puc_BlitShrink_BitmapDestination[L6561_] = (G2044_puc_BlitShrink_BitmapDestination[L6561_] & 0x0F) | (G2042_puc_BlitShrink_PaletteChanges[L2231_uc_ >> 4] << 4);
#endif
                        } else {
#ifdef MEDIA488_F20E_F20J
                                G2044_puc_BlitShrink_BitmapDestination[L6561_] = (G2044_puc_BlitShrink_BitmapDestination[L6561_] & 0x0F) | (G2304_ac_BlitShrink_PaletteChanges[L2231_uc_ & 0x0F] << 4);
#endif
#ifdef MEDIA670_F31E_F31J
                                G2044_puc_BlitShrink_BitmapDestination[L6561_] = (G2044_puc_BlitShrink_BitmapDestination[L6561_] & 0x0F) | (G2042_puc_BlitShrink_PaletteChanges[L2231_uc_ & 0x0F] << 4);
#endif
                        }
                } else {
                        if (L2230_ui_ & 1) {
#ifdef MEDIA488_F20E_F20J
                                G2044_puc_BlitShrink_BitmapDestination[L6561_] = (G2044_puc_BlitShrink_BitmapDestination[L6561_] & 0xF0) | (G2304_ac_BlitShrink_PaletteChanges[L2231_uc_ >> 4]);
#endif
#ifdef MEDIA670_F31E_F31J
                                G2044_puc_BlitShrink_BitmapDestination[L6561_] = (G2044_puc_BlitShrink_BitmapDestination[L6561_] & 0xF0) | (G2042_puc_BlitShrink_PaletteChanges[L2231_uc_ >> 4]);
#endif
                        } else {
#ifdef MEDIA488_F20E_F20J
                                G2044_puc_BlitShrink_BitmapDestination[L6561_] = (G2044_puc_BlitShrink_BitmapDestination[L6561_] & 0xF0) | (G2304_ac_BlitShrink_PaletteChanges[L2231_uc_ & 0x0F]);
#endif
#ifdef MEDIA670_F31E_F31J
                                G2044_puc_BlitShrink_BitmapDestination[L6561_] = (G2044_puc_BlitShrink_BitmapDestination[L6561_] & 0xF0) | (G2042_puc_BlitShrink_PaletteChanges[L2231_uc_ & 0x0F]);
#endif
                        }
                }
                L2228_ui_ += P2414_ui_;
        }
#endif
}
#endif

void F0129_VIDEO_BlitShrinkWithPaletteChanges(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0186_puc_Bitmap_Source, P0187_puc_Bitmap_Destination, P0188_i_SourcePixelWidth, P0189_i_SourceHeight, P0190_i_DestinationPixelWidth, P0191_i_DestinationHeight, P0192_puc_PaletteChanges)
#endif
unsigned char*   P0186_puc_Bitmap_Source       SEPARATOR
#ifdef MEDIA141_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
unsigned char*   P0187_puc_Bitmap_Destination  SEPARATOR
#endif
#ifdef MEDIA774_SU1E_AU1E_AU2E
unsigned char*   P0187_puc_Bitmap_Destination  SEPARATOR
#endif
#ifdef MEDIA351_G14ED_G20E_G21E
long             P0187_puc_Bitmap_Destination  SEPARATOR
#endif
#ifdef MEDIA151_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_X30J_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J_SU1E_AU1E_AU2E
int16_t          P0188_i_SourcePixelWidth      SEPARATOR
int16_t          P0189_i_SourceHeight          SEPARATOR
#endif
#ifdef MEDIA488_F20E_F20J
unsigned int16_t P0188_i_SourcePixelWidth      SEPARATOR
unsigned int16_t P0189_i_SourceHeight          SEPARATOR
#endif
#ifdef MEDIA372_G14ED_G20E_G21E_P20JA_P20JB
unsigned int16_t P0188_i_SourcePixelWidth      SEPARATOR
unsigned int16_t P0189_i_SourceHeight          SEPARATOR
#endif
#ifdef MEDIA147_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J_SU1E_AU1E_AU2E
int16_t          P0190_i_DestinationPixelWidth SEPARATOR
int16_t          P0191_i_DestinationHeight     SEPARATOR
#endif
#ifdef MEDIA373_G14ED_G20E_G21E_F20E_F20J
unsigned int16_t P0190_i_DestinationPixelWidth SEPARATOR
unsigned int16_t P0191_i_DestinationHeight     SEPARATOR
#endif
unsigned char*   P0192_puc_PaletteChanges      FINAL_SEPARATOR
{
#ifdef MEDIA174_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_SU1E
        long L0226_l_HeightRatio;
        long L0227_l_WidthRatio;
        int16_t L0228_i_SourceUnitWidth;


        asm {
                        movem.l D4-D7/A2-A5,-(A7)
                        movea.l P0192_puc_PaletteChanges(A6),A5
                        movea.l P0186_puc_Bitmap_Source(A6),A0
                        movea.l P0187_puc_Bitmap_Destination(A6),A1
                        moveq   #0,D1
                        move.w  P0188_i_SourcePixelWidth(A6),D1
                        moveq   #0x0F,D0
                        add.w   D1,D0
                        and.w   #0xFFF0,D0
                        lsr.w   #1,D0
                        move.w  D0,L0228_i_SourceUnitWidth(A6)
                        move.w  P0190_i_DestinationPixelWidth(A6),D3
                        moveq   #0x0A,D2
                        lsl.l   D2,D1                                   /* 1024 * P0188_i_SourcePixelWidth */
                        divu    D3,D1                                   /* 1024 * P0188_i_SourcePixelWidth / P0190_i_DestinationPixelWidth */
                        andi.l  #0x0000FFFF,D1
                        lsl.l   #6,D1                                   /* 65536 * P0188_i_SourcePixelWidth / P0190_i_DestinationPixelWidth */
                        movea.l D1,A2
                        lsr.l   #1,D1                                   /* 32768 * P0188_i_SourcePixelWidth / P0190_i_DestinationPixelWidth */
                        addi.l  #0x00007FFF,D1                          /* (32768 * P0188_i_SourcePixelWidth / P0190_i_DestinationPixelWidth) + 32767 */
                        move.l  D1,L0227_l_WidthRatio(A6)
                        moveq   #0,D1
                        move.w  P0189_i_SourceHeight(A6),D1
                        lsl.l   D2,D1
                        divu    P0191_i_DestinationHeight(A6),D1
                        andi.l  #0x0000FFFF,D1
                        lsl.l   #6,D1
                        move.l  D1,L0226_l_HeightRatio(A6)              /* 65536 * P0189_i_SourceHeight / P0191_i_DestinationHeight */
                        lsr.l   #1,D1
                        addi.l  #0x00007FFF,D1
                        movea.l D1,A4
                        swap    D1
                        mulu.w  D1,D0
                        adda.w  D0,A0
                        move.w  D3,-(A7)
                @T0129001_Loop:
                        movea.w #0xFFFF,A3
                        move.l  L0227_l_WidthRatio(A6),D4
                        move.l  #0x80008000,D7
                @T0129002_Loop:
                        moveq   #0,D2
                        moveq   #0,D3
                @T0129003_Loop:
                        swap    D4
#ifdef MEDIA007_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E
                        moveq   #0xF0,D6
#endif
#ifdef MEDIA772_SU1E
                        move.l  #0xFFF0,D6
#endif
                        and.w   D4,D6
                        cmp.w   A3,D6
                        beq.s   @T0129004
                        movea.w D6,A3
                        lsr.w   #1,D6
                        movem.l 0(A0,D6.w),D0-D1
                @T0129004:
                        moveq   #0x0F,D6
                        and.w   D4,D6
                        neg.w   D6
                        addi.w  #0x000F,D6
                        moveq   #0,D5
                        btst    D6,D0
                        beq.s   @T0129005
                        moveq   #2,D5
                @T0129005:
                        btst    D6,D1
                        beq.s   @T0129006
                        addq.w  #8,D5
                @T0129006:
                        addi.w  #0x0010,D6
                        btst    D6,D0
                        beq.s   @T0129007
                        addq.w  #1,D5
                @T0129007:
                        btst    D6,D1
                        beq.s   @T0129008
                        addq.w  #4,D5
                @T0129008:
                        move.b  0(A5,D5.w),D5                           /* Each code section below is 10 bytes large, this is why values in PaletteChanges are (10 * color index) */
                        jmp     2(PC,D5.w)
                @T0129009:
                        bra     @T0129010                               /* 0 */
                        nop
                        nop
                        nop
                        swap    D2                                      /* 1 */
                        or.w    D7,D2
                        swap    D2
                        bra     @T0129010
                        or.w    D7,D2                                   /* 2 */
                        bra     @T0129010
                        nop
                        nop
                        or.l    D7,D2                                   /* 3 */
                        bra     @T0129010
                        nop
                        nop
                        swap    D3                                      /* 4 */
                        or.w    D7,D3
                        swap    D3
                        bra.w   @T0129010
                        move.w  D7,D6                                   /* 5 */
                        swap    D6
                        or.l    D6,D2
                        or.l    D6,D3
                        bra.s   @T0129010
                        or.w    D7,D2                                   /* 6 */
                        swap    D3
                        or.w    D7,D3
                        swap    D3
                        bra.s   @T0129010
                        or.l    D7,D2                                   /* 7 */
                        swap    D3
                        or.w    D7,D3
                        swap    D3
                        bra.s   @T0129010
                        or.w    D7,D3                                   /* 8 */
                        bra.s   @T0129010
                        nop
                        nop
                        nop
                        or.w    D7,D3                                   /* 9 */
                        swap    D2
                        or.w    D7,D2
                        swap    D2
                        bra.s   @T0129010
                        or.w    D7,D2                                   /* 10 */
                        or.w    D7,D3
                        bra.s   @T0129010
                        nop
                        nop
                        or.l    D7,D2                                   /* 11 */
                        or.w    D7,D3
                        bra.s   @T0129010
                        nop
                        nop
                        or.l    D7,D3                                   /* 12 */
                        bra.s   @T0129010
                        nop
                        nop
                        nop
                        swap    D2                                      /* 13 */
                        or.w    D7,D2
                        swap    D2
                        or.l    D7,D3
                        bra.s   @T0129010
                        or.w    D7,D2                                   /* 14 */
                        or.l    D7,D3
                        bra.s   @T0129010
                        nop
                        nop
                        or.l    D7,D2                                   /* 15 */
                        or.l    D7,D3
#ifdef MEDIA772_SU1E
                        nop
                        nop
                        nop
#endif
                @T0129010:
                        subq.w  #1,(A7)
                        beq.s   @T0129011
                        swap    D4
                        add.l   A2,D4
                        ror.l   #1,D7
                        bcc     @T0129003_Loop
                        move.l  D2,(A1)+
                        move.l  D3,(A1)+
                        bra     @T0129002_Loop
                @T0129011:
                        move.l  D2,(A1)+
                        move.l  D3,(A1)+
                        subq.w  #1,P0191_i_DestinationHeight(A6)
                        beq.s   @T0129012
                        move.l  A4,D2
                        move.l  D2,D3
                        add.l   L0226_l_HeightRatio(A6),D3
                        movea.l D3,A4
                        swap    D2
                        swap    D3
                        sub.w   D2,D3
                        mulu.w  L0228_i_SourceUnitWidth(A6),D3
                        adda.w  D3,A0
                        move.w  P0190_i_DestinationPixelWidth(A6),(A7)
                        bra     @T0129001_Loop
                @T0129012:
                        addq.w  #2,A7
                        movem.l (A7)+,D4-D7/A2-A5
        }
#endif
#ifdef MEDIA351_G14ED_G20E_G21E
        long L6306_;
        long L6304_;
        long L6303_;
        long L6301_;
        long L6300_;
        long L6298_;
        long L6296_;
        long L6295_;
        long L6294_;
        int16_t L6293_;
        int16_t L6292_;
        int16_t L6291_Unreferenced;
        int16_t L6290_;
        int16_t L6289_;
        int16_t L6288_Unreferenced;
        char L6287_;
        unsigned char* L6286_;
        unsigned char* L6285_;
        char L6284_;
        char L6283_;
        unsigned char L6282_[16];


#ifdef MEDIA388_G20E_G21E
        asm {
                        SEP        #0x30
                        LDY        #0x0f
                L080430:
                        LDA        [P0192_puc_PaletteChanges],Y
                        TAX
                        LDA        >G3978_auc_FlippedPixels,X
                        TYX
                        STA        L6282_,X
                        DEY
                        BPL        L080430
                        REP        #0x30
        }
        if ((P0188_i_SourcePixelWidth == P0190_i_DestinationPixelWidth) && (P0189_i_SourceHeight == P0191_i_DestinationHeight)) {
                L6292_ = (P0190_i_DestinationPixelWidth * P0191_i_DestinationHeight) + 1;
                L6283_ = 0;
                asm {
                        L080462:
                                DEC        L6292_
                                BEQ        L0804A1
                                SEP        #0x30
                                LDA        [P0186_puc_Bitmap_Source]
                                LDX        L6283_
                                BMI        L08047E
                                AND        #0xf0
                                TAX
                                LDA        >G3978_auc_FlippedPixels,X
                                TAX
                                LDA        [P0187_puc_Bitmap_Destination]
                                AND        #0x0f
                                ORA        L6282_,X
                                BRA        L080487
                        L08047E:
                                AND        #0x0f
                                TAY
                                LDA        [P0187_puc_Bitmap_Destination]
                                AND        #0xf0
                                ORA        [P0192_puc_PaletteChanges],Y
                        L080487:
                                STA        [P0187_puc_Bitmap_Destination]
                                LDA        L6283_
                                EOR        #0x80
                                STA        L6283_
                                REP        #0x30
                                BMI        L080462
                                INC        P0187_puc_Bitmap_Destination
                                BNE        L080499
                                INC        P0187_puc_Bitmap_Destination+2
                        L080499:
                                INC        P0186_puc_Bitmap_Source
                                BNE        L080462
                                INC        P0186_puc_Bitmap_Source+2
                                BRA        L080462
                        L0804A1:
                                REP        #0x30
                }
                return;
        }
#endif
        L6296_ = ((P0190_i_DestinationPixelWidth + 15) & 0xFFF0) >> 1;
        L6295_ = L6296_ * P0191_i_DestinationHeight;
        L6294_ = L6295_ + P0187_puc_Bitmap_Destination;
        L6293_ = (P0188_i_SourcePixelWidth + 1) >> 1;
        L6306_ = (((long)P0188_i_SourcePixelWidth << 10) / P0190_i_DestinationPixelWidth) << 6;
        L6304_ = (((long)P0189_i_SourceHeight << 10) / P0191_i_DestinationHeight) << 6;
        L6284_ = L6283_ = 0;
        L6303_ = L6301_ = 0;
        P0191_i_DestinationHeight++;
        P0190_i_DestinationPixelWidth++;
        L6292_ = P0190_i_DestinationPixelWidth;
        if (P0192_puc_PaletteChanges == G0017_auc_Graphic562_PaletteChanges_NoChanges) {
                asm {
                        L08058B:
                                DEC        P0191_i_DestinationHeight
                                BNE        L080592
                                BRL        L08069B
                        L080592:
                                LDA        P0186_puc_Bitmap_Source
                                STA        L6286_
                                LDA        P0186_puc_Bitmap_Source+2
                                STA        L6286_+2
                                LDA        P0187_puc_Bitmap_Destination
                                STA        L6285_
                                LDA        P0187_puc_Bitmap_Destination+2
                                STA        L6285_+2
                        L0805A2:
                                DEC        L6292_
                                BNE        L0805A9
                                BRL        L08062A
                        L0805A9:
                                SEP        #0x30
                                LDA        [P0186_puc_Bitmap_Source]
                                TAX
                                LDA        L6284_
                                EOR        L6283_
                                BEQ        L0805BA
                                LDA        >G3978_auc_FlippedPixels,X
                                BRA        L0805BB
                        L0805BA:
                                TXA
                        L0805BB:
                                LDX        L6283_
                                BMI        L0805C9
                                AND        #0xf0
                                STA        L6287_
                                LDA        [P0187_puc_Bitmap_Destination]
                                AND        #0x0f
                                BRA        L0805D1
                        L0805C9:
                                AND        #0x0f
                                STA        L6287_
                                LDA        [P0187_puc_Bitmap_Destination]
                                AND        #0xf0
                        L0805D1:
                                ORA        L6287_
                                STA        [P0187_puc_Bitmap_Destination]
                                LDA        L6283_
                                EOR        #0x80
                                STA        L6283_
                                REP        #0x30
                                BMI        L0805E5
                                INC        P0187_puc_Bitmap_Destination
                                BNE        L0805E5
                                INC        P0187_puc_Bitmap_Destination+2
                        L0805E5:
                                CLC
                                LDA        L6303_
                                ADC        L6306_
                                STA        L6300_
                                LDA        L6303_+2
                                ADC        L6306_+2
                                STA        L6300_+2
                                SEC
                                SBC        L6303_+2
                                PHA
                                LDX        L6300_
                                STX        L6303_
                                LDX        L6300_+2
                                STX        L6303_+2
                                PLA
                                BNE        L080604
                                BRL        L0806FF
                        L080604:
                                LSR        A
                                PHP
                                CLC
                                ADC        P0186_puc_Bitmap_Source
                                STA        P0186_puc_Bitmap_Source
                                BCC        L08060F
                                INC        P0186_puc_Bitmap_Source+2
                        L08060F:
                                PLP
                                BCC        L0805A2
                                SEP        #0x30
                                LDA        L6284_
                                EOR        #0x80
                                STA        L6284_
                                REP        #0x30
                                BMI        L0805A2
                                INC        P0186_puc_Bitmap_Source
                                BEQ        L080625
                                BRL        L0805A2
                        L080625:
                                INC        P0186_puc_Bitmap_Source+2
                                BRL        L0805A2
                        L08062A:
                                REP        #0x30
                                CLC
                                LDA        L6301_
                                ADC        L6304_
                                STA        L6298_
                                LDA        L6301_+2
                                ADC        L6304_+2
                                STA        L6298_+2
                                SEC
                                SBC        L6301_+2
                                PHA
                                LDX        L6298_
                                STX        L6301_
                                LDX        L6298_+2
                                STX        L6301_+2
                                PLA
                                BEQ        L08062A
                                STA        L6290_
                                LDA        L6293_
                                STA        L6289_
                                LDA        #0x00
                                STA        P0186_puc_Bitmap_Source
                                STA        P0186_puc_Bitmap_Source+2
                                LDX        #0x10
                                LDA        #0x00
                        L08065B:
                                ASL        A
                                ROL        P0186_puc_Bitmap_Source+2
                                ASL        L6290_
                                BCC        L080669
                                CLC
                                ADC        L6289_
                                BCC        L080669
                                INC        P0186_puc_Bitmap_Source+2
                        L080669:
                                DEX
                                BNE        L08065B
                                STA        P0186_puc_Bitmap_Source
                                CLC
                                LDA        P0186_puc_Bitmap_Source
                                ADC        L6286_
                                STA        P0186_puc_Bitmap_Source
                                LDA        P0186_puc_Bitmap_Source+2
                                ADC        L6286_+2
                                STA        P0186_puc_Bitmap_Source+2
                                CLC
                                LDA        L6285_
                                ADC        L6296_
                                STA        P0187_puc_Bitmap_Destination
                                LDA        L6285_+2
                                ADC        L6296_+2
                                STA        P0187_puc_Bitmap_Destination+2
                                SEP        #0x30
                                STZ        L6284_
                                STZ        L6283_
                                REP        #0x30
                                STZ        L6303_
                                STZ        L6303_+2
                                LDA        P0190_i_DestinationPixelWidth
                                STA        L6292_
                                BRL        L08058B
                        L08069B:
                                REP        #0x30
                }
        } else {
                asm {
#ifdef MEDIA349_G14ED
                                SEP        #0x30
                                LDY        #0x0f
                        L070628:
                                LDA        [P0192_puc_PaletteChanges],Y
                                TAX
                                LDA        >G3978_auc_FlippedPixels,X
                                TYX
                                STA        L6282_,X
                                DEY
                                BPL        L070628
                                REP        #0x30
#endif
                        L0806A0:
                                DEC        P0191_i_DestinationHeight
                                BNE        L0806A7
                                BRL        L0807B2
                        L0806A7:
                                LDA        P0186_puc_Bitmap_Source
                                STA        L6286_
                                LDA        P0186_puc_Bitmap_Source+2
                                STA        L6286_+2
                                LDA        P0187_puc_Bitmap_Destination
                                STA        L6285_
                                LDA        P0187_puc_Bitmap_Destination+2
                                STA        L6285_+2
                        L0806B7:
                                DEC        L6292_
                                BNE        L0806BE
                                BRL        L080741
                        L0806BE:
                                SEP        #0x30
                                LDA        [P0186_puc_Bitmap_Source]
                                TAX
                                LDA        L6284_
                                EOR        L6283_
                                BEQ        L0806CF
                                LDA        >G3978_auc_FlippedPixels,X
                                BRA        L0806D0
                        L0806CF:
                                TXA
                        L0806D0:
                                LDX        L6283_
                                BMI        L0806E4
                                AND        #0xf0
                                TAX
                                LDA        >G3978_auc_FlippedPixels,X
                                TAX
                                LDA        [P0187_puc_Bitmap_Destination]
                                AND        #0x0f
                                ORA        L6282_,X
                                BRA        L0806ED
                        L0806E4:
                                AND        #0x0f
                                TAY
                                LDA        [P0187_puc_Bitmap_Destination]
                                AND        #0xf0
                                ORA        [P0192_puc_PaletteChanges],Y
                        L0806ED:
                                STA        [P0187_puc_Bitmap_Destination]
                                LDA        L6283_
                                EOR        #0x80
                                STA        L6283_
                                REP        #0x30
                                BMI        L0806FF
                                INC        P0187_puc_Bitmap_Destination
                                BNE        L0806FF
                                INC        P0187_puc_Bitmap_Destination+2
                        L0806FF:
                                CLC
                                LDA        L6303_
                                ADC        L6306_
                                STA        L6300_
                                LDA        L6303_+2
                                ADC        L6306_+2
                                STA        L6300_+2
                                SEC
                                SBC        L6303_+2
                                PHA
                                LDX        L6300_
                                STX        L6303_
                                LDX        L6300_+2
                                STX        L6303_+2
                                PLA
                                BEQ        L0806FF
                                LSR        A
                                PHP
                                CLC
                                ADC        P0186_puc_Bitmap_Source
                                STA        P0186_puc_Bitmap_Source
                                BCC        L080726
                                INC        P0186_puc_Bitmap_Source+2
                        L080726:
                                PLP
                                BCC        L0806B7
                                SEP        #0x30
                                LDA        L6284_
                                EOR        #0x80
                                STA        L6284_
                                REP        #0x30
                                BMI        L0806B7
                                INC        P0186_puc_Bitmap_Source
                                BEQ        L08073C
                                BRL        L0806B7
                        L08073C:
                                INC        P0186_puc_Bitmap_Source+2
                                BRL        L0806B7
                        L080741:
                                REP        #0x30
                                CLC
                                LDA        L6301_
                                ADC        L6304_
                                STA        L6298_
                                LDA        L6301_+2
                                ADC        L6304_+2
                                STA        L6298_+2
                                SEC
                                SBC        L6301_+2
                                PHA
                                LDX        L6298_
                                STX        L6301_
                                LDX        L6298_+2
                                STX        L6301_+2
                                PLA
                                BEQ        L080741
                                STA        L6290_
                                LDA        L6293_
                                STA        L6289_
                                LDA        #0x00
                                STA        P0186_puc_Bitmap_Source
                                STA        P0186_puc_Bitmap_Source+2
                                LDX        #0x10
                                LDA        #0x00
                        L080772:
                                ASL        A
                                ROL        P0186_puc_Bitmap_Source+2
                                ASL        L6290_
                                BCC        L080780
                                CLC
                                ADC        L6289_
                                BCC        L080780
                                INC        P0186_puc_Bitmap_Source+2
                        L080780:
                                DEX
                                BNE        L080772
                                STA        P0186_puc_Bitmap_Source
                                CLC
                                LDA        P0186_puc_Bitmap_Source
                                ADC        L6286_
                                STA        P0186_puc_Bitmap_Source
                                LDA        P0186_puc_Bitmap_Source+2
                                ADC        L6286_+2
                                STA        P0186_puc_Bitmap_Source+2
                                CLC
                                LDA        L6285_
                                ADC        L6296_
                                STA        P0187_puc_Bitmap_Destination
                                LDA        L6285_+2
                                ADC        L6296_+2
                                STA        P0187_puc_Bitmap_Destination+2
                                SEP        #0x30
                                STZ        L6284_
                                STZ        L6283_
                                REP        #0x30
                                STZ        L6303_
                                STZ        L6303_+2
                                LDA        P0190_i_DestinationPixelWidth
                                STA        L6292_
                                BRL        L0806A0
                        L0807B2:
                                REP        #0x30
                        L0807B4:
                }
        }
#endif
#ifdef MEDIA413_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        long L1586_l_1;
        long L1587_l_2;
        int16_t L1588_i_1;
        int16_t L1589_i_2;
        int16_t L1590_i_3;


        AztecCDirective_asm
                        movem.l d4-d7/a2-a5,-(sp)
                        movea.l $18(a5),a6              ; P0192_puc_PaletteChanges
                        movea.l 8(a5),a0                ; P0186_puc_Bitmap_Source
                        movea.l $C(a5),a1               ; P0187_puc_Bitmap_Destination
                        moveq   #0,d1
                        move.w  $10(a5),d1              ; P0188_i_SourcePixelWidth
                        moveq   #$F,d0
                        add.w   d1,d0
                        and.w   #$FFF0,d0
                        lsr.w   #3,d0
                        move.w  d0,-$A(a5)              ; L1588_i_1
                        move.w  $14(a5),d3              ; P0190_i_DestinationPixelWidth
                        moveq   #$A,d2
                        lsl.l   d2,d1
                        divu.w  d3,d1
                        andi.l  #$FFFF,d1
                        lsl.l   #6,d1
                        movea.l d1,a2
                        lsr.l   #1,d1
                        addi.l  #$7FFF,d1
                        move.l  d1,-8(a5)               ; L1587_l_2
                        moveq   #0,d1
                        move.w  $12(a5),d1              ; P0189_i_SourceHeight
                        lsl.l   d2,d1
                        divu.w  $16(a5),d1              ; P0191_i_DestinationHeight
                        andi.l  #$FFFF,d1
                        lsl.l   #6,d1
                        move.l  d1,-4(a5)               ; L1586_l_1
                        lsr.l   #1,d1
                        addi.l  #$7FFF,d1
                        movea.l d1,a4
                        swap    d1
                        mulu.w  d1,d0
                        adda.w  d0,a0
                        move.w  -$A(a5),d0              ; L1588_i_1
                        mulu.w  $12(a5),d0              ; P0189_i_SourceHeight
                        move.w  d0,-$C(a5)              ; L1589_i_2
                        moveq   #0,d0
                        move.w  $14(a5),d0              ; P0190_i_DestinationPixelWidth
                        moveq   #$F,d1
                        add.w   d1,d0
                        and.w   #$FFF0,d0
                        lsr.w   #3,d0
                        mulu.w  $16(a5),d0              ; P0191_i_DestinationHeight
                        move.w  d0,-$E(a5)              ; L1590_i_3
                        move.w  d3,-(sp)
                T0129013:
                        movea.w #$FFFF,a3
                        move.l  -8(a5),d4               ; L1587_l_2
                        move.l  #$80008000,d7
                T0129014:
                        moveq   #0,d2
                        moveq   #0,d3
                T0129015:
                        swap    d4
                        moveq   #$FFFFFFF0,d6
                        and.w   d4,d6
                        cmp.w   a3,d6
                        beq.s   T0129016
                        movea.w d6,a3
                        lsr.w   #1,d6
                        movem.l d6-d7,-(sp)
                        move.w  -$C(a5),d6              ; L1589_i_2
                        move.w  (a0),d0
                        swap    d0
                        move.w  (a0,d6.w),d0
                        move.w  d6,d7
                        lsl.l   #1,d6
                        move.w  (a0,d6.w),d1
                        swap    d1
                        add.w   d6,d7
                        move.w  (a0,d7.w),d1
                        addq.l  #2,a0
                        movem.l (sp)+,d6-d7
                T0129016:
                        moveq   #$F,d6
                        and.w   d4,d6
                        neg.w   d6
                        addi.w  #$F,d6
                        moveq   #0,d5
                        btst    d6,d0
                        beq.s   T0129017
                        moveq   #2,d5
                T0129017:
                        btst    d6,d1
                        beq.s   T0129018
                        addq.w  #8,d5
                T0129018:
                        addi.w  #$10,d6
                        btst    d6,d0
                        beq.s   T0129019
                        addq.w  #1,d5
                T0129019:
                        btst    d6,d1
                        beq.s   T0129020
                        addq.w  #4,d5
                T0129020:
                        move.b  (a6,d5.w),d5
                        addq.w  #2,d5
                        jmp     (pc,d5.w)
                        bra     T0129021
                        nop
                        nop
                        nop
                        swap    d2
                        or.w    d7,d2
                        swap    d2
                        bra     T0129021
                        or.w    d7,d2
                        bra     T0129021
                        nop
                        nop
                        or.l    d7,d2
                        bra.s   T0129021
                        nop
                        nop
                        nop
                        swap    d3
                        or.w    d7,d3
                        swap    d3
                        bra.s   T0129021
                        nop
                        move.w  d7,d6
                        swap    d6
                        or.l    d6,d2
                        or.l    d6,d3
                        bra.s   T0129021
                        or.w    d7,d2
                        swap    d3
                        or.w    d7,d3
                        swap    d3
                        bra.s   T0129021
                        or.l    d7,d2
                        swap    d3
                        or.w    d7,d3
                        swap    d3
                        bra.s   T0129021
                        or.w    d7,d3
                        bra.s   T0129021
                        nop
                        nop
                        nop
                        or.w    d7,d3
                        swap    d2
                        or.w    d7,d2
                        swap    d2
                        bra.s   T0129021
                        or.w    d7,d2
                        or.w    d7,d3
                        bra.s   T0129021
                        nop
                        nop
                        or.l    d7,d2
                        or.w    d7,d3
                        bra.s   T0129021
                        nop
                        nop
                        or.l    d7,d3
                        bra.s   T0129021
                        nop
                        nop
                        nop
                        swap    d2
                        or.w    d7,d2
                        swap    d2
                        or.l    d7,d3
                        bra.s   T0129021
                        or.w    d7,d2
                        or.l    d7,d3
                        bra.s   T0129021
                        nop
                        nop
                        or.l    d7,d2
                        or.l    d7,d3
                T0129021:
                        subq.w  #1,(sp)
                        beq.s   T0129022
                        swap    d4
                        add.l   a2,d4
                        ror.l   #1,d7
                        bcc     T0129015
                        movem.l d6-d7,-(sp)
                        move.w  -$E(a5),d6              ; L1590_i_3
                        move.w  d2,(a1,d6.w)
                        swap    d2
                        move.w  d2,(a1)
                        move.w  d6,d7
                        lsl.l   #1,d6
                        add.w   d6,d7
                        move.w  d3,(a1,d7.w)
                        swap    d3
                        move.w  d3,(a1,d6.w)
                        addq.l  #2,a1
                        movem.l (sp)+,d6-d7
                        bra     T0129014
                T0129022:
                        movem.l d6-d7,-(sp)
                        move.w  -$E(a5),d6              ; L1590_i_3
                        move.w  d2,(a1,d6.w)
                        swap    d2
                        move.w  d2,(a1)
                        move.w  d6,d7
                        lsl.l   #1,d6
                        add.w   d6,d7
                        move.w  d3,(a1,d7.w)
                        swap    d3
                        move.w  d3,(a1,d6.w)
                        addq.l  #2,a1
                        movem.l (sp)+,d6-d7
                        subq.w  #1,$16(a5)              ; P0191_i_DestinationHeight
                        beq.s   T0129023
                        move.l  a4,d2
                        move.l  d2,d3
                        add.l   -4(a5),d3               ; L1586_l_1
                        movea.l d3,a4
                        swap    d2
                        swap    d3
                        sub.w   d2,d3
                        subq.w  #1,d3
                        mulu.w  -$A(a5),d3              ; L1588_i_1
                        adda.w  d3,a0
                        move.w  $14(a5),(sp)            ; P0190_i_DestinationPixelWidth
                        bra     T0129013
                T0129023:
                        addq.w  #2,sp
                        movem.l (sp)+,d4-d7/a2-a5
        AztecCDirective_endasm
#endif
#ifdef MEDIA496_F20E_F20J_P20JA_P20JB_I34E_I34M_F31E_F31J_P31J
        unsigned int16_t L2234_ui_;
        unsigned int16_t L2233_ui_;
        int16_t L2235_i_;
        unsigned int16_t L2236_ui_;
        int16_t L2237_i_;
        unsigned int16_t L2238_i_;
#ifdef MEDIA489_F20E_F20J_P20JA_P20JB
        unsigned int16_t L2239_ui_;
#endif


        G2043_puc_BlitShrink_BitmapSource = P0186_puc_Bitmap_Source;
        G2044_puc_BlitShrink_BitmapDestination = P0187_puc_Bitmap_Destination;
#ifdef MEDIA489_F20E_F20J_P20JA_P20JB
        if (&G2304_ac_BlitShrink_PaletteChanges != NULL) {
                for (L2239_ui_ = 0; L2239_ui_ < 16; L2239_ui_++) {
                        G2304_ac_BlitShrink_PaletteChanges[L2239_ui_] = P0192_puc_PaletteChanges[L2239_ui_] / 10;
                }
        }
#endif
#ifdef MEDIA712_I34E_I34M_F31E_F31J_P31J
        G2042_puc_BlitShrink_PaletteChanges = P0192_puc_PaletteChanges;
#endif
#ifdef MEDIA463_P20JA_P20JB_I34E_I34M_P31J
        L2237_i_ = M104_EVEN_INTEGER(P0190_i_DestinationPixelWidth);
        L2238_i_ = M104_EVEN_INTEGER(P0188_i_SourcePixelWidth);
#endif
#ifdef MEDIA551_F20E_F20J_F31E_F31J
        L2237_i_ = ((int)((P0190_i_DestinationPixelWidth + 31) & 0xFFFFFFE0) >> 1) * 2;
        L2238_i_ = ((int)((P0188_i_SourcePixelWidth + 31) & 0xFFFFFFE0) >> 1) * 2;
#endif
        L2235_i_ = (P0188_i_SourcePixelWidth << 6) / P0190_i_DestinationPixelWidth;
        L2236_ui_ = (P0189_i_SourceHeight << 6) / P0191_i_DestinationHeight;
        L2234_ui_ = L2236_ui_ >> 1;
        for (L2233_ui_ = 0; L2233_ui_ < P0191_i_DestinationHeight; L2233_ui_++) {
                if (P0192_puc_PaletteChanges == NULL) {
                        F0720_ShrinkBLT_Sub1((L2234_ui_ >> 6) * L2238_i_, L2233_ui_ * L2237_i_, L2235_i_, P0190_i_DestinationPixelWidth);
                } else {
                        F0721_ShrinkBLT_Sub2((L2234_ui_ >> 6) * L2238_i_, L2233_ui_ * L2237_i_, L2235_i_, P0190_i_DestinationPixelWidth);
                }
                L2234_ui_ += L2236_ui_;
        }
#endif
#ifdef MEDIA607_X30J_X31J
#ifdef MEDIA692_X31J
        ASM_STUB_PREFIX
#endif
        asm {
                        movem.l d3-d7/a2-a5,-(sp)
                        move.l  P0192_puc_PaletteChanges(a6),d0
                        movea.l d0,a5
                        bne.s   @Tloc_50E6
                        lea     @Tbyte_51A6,a5
                @Tloc_50E6:
                        movea.l P0186_puc_Bitmap_Source(a6),a2
                        movea.l P0187_puc_Bitmap_Destination(a6),a3
                        moveq   #0,d7
                        move.w  P0188_i_SourcePixelWidth(a6),d7
                        move.w  P0190_i_DestinationPixelWidth(a6),d5
                        move.w  d7,d4
                        moveq   #0xA,d1
                        lsl.l   d1,d7
                        divu.w  d5,d7
                        andi.l  #0xFFFF,d7
                        lsl.l   #6,d7
                        moveq   #0,d6
                        move.w  P0189_i_SourceHeight(a6),d6
                        lsl.l   d1,d6
                        divu.w  P0191_i_DestinationHeight(a6),d6
                        andi.l  #0xFFFF,d6
                        lsl.l   #6,d6
                        movea.l d6,a1
                        addq.w  #1,d4
                        lsr.w   #1,d4
                        move.l  #0x7FFF,d3
                        move.l  d3,d2
                        add.l   d6,d3
                        lsr.l   #1,d3
                        move.l  d3,d0
                        swap    d0
                        mulu.w  d4,d0
                        adda.l  d0,a2
                        add.l   d7,d2
                        lsr.l   #1,d2
                        movea.l d2,a4
                        moveq   #0,d6
                @Tloc_513E:
                        moveq   #0,d1
                @Tloc_5140:
                        move.l  d2,d0
                        swap    d0
                        lsr.w   #1,d0
                        bcs.s   @Tloc_5150
                        move.b  (a2,d0.w),d1
                        lsr.b   #4,d1
                        bra.s   @Tloc_5156
                @Tloc_5150:
                        moveq   #0xF,d1
                        and.b   (a2,d0.w),d1
                @Tloc_5156:
                        move.b  (a5,d1.w),d1
                        lsl.b   #4,d1
                        subq.w  #1,d5
                        beq.s   @Tloc_51A2
                        add.l   d7,d2
                        move.l  d2,d0
                        swap    d0
                        lsr.w   #1,d0
                        bcs.s   @Tloc_5172
                        move.b  (a2,d0.w),d6
                        lsr.b   #4,d6
                        bra.s   @Tloc_5178
                @Tloc_5172:
                        moveq   #0xF,d6
                        and.b   (a2,d0.w),d6
                @Tloc_5178:
                        or.b    (a5,d6.w),d1
                        move.b  d1,(a3)+
                        add.l   d7,d2
                        subq.w  #1,d5
                        bne.s   @Tloc_5140
                @Tloc_5184:
                        subq.w  #1,P0191_i_DestinationHeight(a6)
                        beq.s   @Tloc_51B6
                        move.l  d3,d0
                        add.l   a1,d3
                        move.l  d3,d1
                        swap    d0
                        swap    d1
                        sub.w   d0,d1
                        mulu.w  d4,d1
                        adda.l  d1,a2
                        move.l  a4,d2
                        move.w  P0190_i_DestinationPixelWidth(a6),d5
                        bra.s   @Tloc_513E
                @Tloc_51A2:
                        move.b  d1,(a3)+
                        bra.s   @Tloc_5184
                @Tbyte_51A6:dc.b 0
                        dc.b 1
                        dc.b 2
                        dc.b 3
                        dc.b 4
                        dc.b 5
                        dc.b 6
                        dc.b 7
                        dc.b 8
                        dc.b 9
                        dc.b 0xA
                        dc.b 0xB
                        dc.b 0xC
                        dc.b 0xD
                        dc.b 0xE
                        dc.b 0xF
                @Tloc_51B6:
                        movem.l (sp)+,d3-d7/a2-a5
        }
#ifdef MEDIA692_X31J
        ASM_STUB_SUFFIX
#endif
#endif
#ifdef MEDIA752_A36M_A31E_A31M_A33M_A35E_A35M_AU1E_AU2E
        long L1586_l_1;
        long L1587_l_2;
        int16_t L1588_i_1;
        int16_t L1589_i_2;
        int16_t L1590_i_3;
#if (EXETYPE != C07_HINT)
        unsigned char* L2240_puc_;
#endif


#if (EXETYPE == C13_GRF1)
        ASM_STUB_PREFIX
#endif
        asm {
#if (EXETYPE == C07_HINT)
                        movem.l d4-d7/a2-a5,-(sp)
                        movea.l P0192_puc_PaletteChanges(a6),a5
#else
                        movem.l d3-d7/a2-a6,-(sp)
#endif
                        movea.l P0186_puc_Bitmap_Source(a6),a0
#if (EXETYPE != C07_HINT)
                        move.l  a0,L2240_puc_(a6)
#endif
                        movea.l P0187_puc_Bitmap_Destination(a6),a1
#if (EXETYPE != C07_HINT)
                        move.l  P0192_puc_PaletteChanges(a6),d1
                        movea.l d1,a4
                        bne.s   @Tloc_A9F2
                        lea     G3212_auc_PaletteChanges_NoChanges(a5),a4
                @Tloc_A9F2:
#endif
                        moveq   #0,d1
                        move.w  P0188_i_SourcePixelWidth(a6),d1
                        moveq   #0xF,d0
                        add.w   d1,d0
                        andi.w  #0xFFF0,d0
                        lsr.w   #3,d0
                        move.w  d0,L1588_i_1(a6)
                        move.w  P0190_i_DestinationPixelWidth(a6),d3
                        moveq   #0xA,d2
                        lsl.l   d2,d1
                        divu.w  d3,d1
                        andi.l  #0xFFFF,d1
                        lsl.l   #6,d1
                        movea.l d1,a2
                        lsr.l   #1,d1
                        addi.l  #0x7FFF,d1
                        move.l  d1,L1587_l_2(a6)
                        moveq   #0,d1
                        move.w  P0189_i_SourceHeight(a6),d1
                        lsl.l   d2,d1
                        divu.w  P0191_i_DestinationHeight(a6),d1
                        andi.l  #0xFFFF,d1
                        lsl.l   #6,d1
                        move.l  d1,L1586_l_1(a6)
                        lsr.l   #1,d1
                        addi.l  #0x7FFF,d1
#if (EXETYPE == C07_HINT)
                        movea.l d1,a4
#else
                        movea.l d1,a5
#endif
                        swap    d1
                        mulu.w  d1,d0
                        adda.w  d0,a0
                        move.w  L1588_i_1(a6),d0
                        mulu.w  P0189_i_SourceHeight(a6),d0
                        move.w  d0,L1589_i_2(a6)
                        moveq   #0,d0
                        move.w  P0190_i_DestinationPixelWidth(a6),d0
                        moveq   #0xF,d1
                        add.w   d1,d0
                        andi.w  #0xFFF0,d0
                        lsr.w   #3,d0
                        mulu.w  P0191_i_DestinationHeight(a6),d0
                        move.w  d0,L1590_i_3(a6)
                        move.w  d3,-(sp)
                @Tloc_AA74:
                        movea.w #0xFFFF,a3
                        move.l  L1587_l_2(a6),d4
                        move.l  #0x80008000,d7
                @Tloc_AA82:
                        moveq   #0,d2
                        moveq   #0,d3
                @Tloc_AA86:
                        swap    d4
                        moveq   #0xFFFFFFF0,d6
                        and.w   d4,d6
                        cmp.w   a3,d6
                        beq.s   @Tloc_AABA
                        movea.w d6,a3
                        lsr.w   #1,d6
                        movem.l d6-d7,-(sp)
                        move.w  L1589_i_2(a6),d6
                        move.w  (a0),d0
                        swap    d0
                        move.w  (a0,d6.w),d0
                        move.w  d6,d7
                        lsl.l   #1,d6
                        move.w  (a0,d6.w),d1
                        swap    d1
                        add.w   d6,d7
                        move.w  (a0,d7.w),d1
                        addq.l  #2,a0
                        movem.l (sp)+,d6-d7
                @Tloc_AABA:
                        moveq   #0xF,d6
                        and.w   d4,d6
                        neg.w   d6
                        addi.w  #0xF,d6
                        moveq   #0,d5
                        btst    d6,d0
                        beq.s   @Tloc_AACC
                        moveq   #2,d5
                @Tloc_AACC:
                        btst    d6,d1
                        beq.s   @Tloc_AAD2
                        addq.w  #8,d5
                @Tloc_AAD2:
                        addi.w  #0x10,d6
                        btst    d6,d0
                        beq.s   @Tloc_AADC
                        addq.w  #1,d5
                @Tloc_AADC:
                        btst    d6,d1
                        beq.s   @Tloc_AAE2
                        addq.w  #4,d5
                @Tloc_AAE2:
#if (EXETYPE == C07_HINT)
                        move.b  (a5,d5.w),d5
#else
                        move.b  (a4,d5.w),d5
                        mulu.w  #0xA,d5
#endif
                        addq.w  #2,d5
                        jmp     (pc,d5.w)
                        bra.w   @Tloc_AB8A
                        nop
                        nop
                        nop
                        swap    d2
                        or.w    d7,d2
                        swap    d2
                        bra.w   @Tloc_AB8A
                        or.w    d7,d2
                        bra.w   @Tloc_AB8A
                        nop
                        nop
                        or.l    d7,d2
                        bra.s   @Tloc_AB8A
                        nop
                        nop
                        nop
                        swap    d3
                        or.w    d7,d3
                        swap    d3
                        bra.s   @Tloc_AB8A
                        nop
                        move.w  d7,d6
                        swap    d6
                        or.l    d6,d2
                        or.l    d6,d3
                        bra.s   @Tloc_AB8A
                        or.w    d7,d2
                        swap    d3
                        or.w    d7,d3
                        swap    d3
                        bra.s   @Tloc_AB8A
                        or.l    d7,d2
                        swap    d3
                        or.w    d7,d3
                        swap    d3
                        bra.s   @Tloc_AB8A
                        or.w    d7,d3
                        bra.s   @Tloc_AB8A
                        nop
                        nop
                        nop
                        or.w    d7,d3
                        swap    d2
                        or.w    d7,d2
                        swap    d2
                        bra.s   @Tloc_AB8A
                        or.w    d7,d2
                        or.w    d7,d3
                        bra.s   @Tloc_AB8A
                        nop
                        nop
                        or.l    d7,d2
                        or.w    d7,d3
                        bra.s   @Tloc_AB8A
                        nop
                        nop
                        or.l    d7,d3
                        bra.s   @Tloc_AB8A
                        nop
                        nop
                        nop
                        swap    d2
                        or.w    d7,d2
                        swap    d2
                        or.l    d7,d3
                        bra.s   @Tloc_AB8A
                        or.w    d7,d2
                        or.l    d7,d3
                        bra.s   @Tloc_AB8A
                        nop
                        nop
                        or.l    d7,d2
                        or.l    d7,d3
                @Tloc_AB8A:
                        subq.w  #1,(sp)
                        beq.s   @Tloc_ABC2
                        swap    d4
                        add.l   a2,d4
                        ror.l   #1,d7
                        bcc.w   @Tloc_AA86
                        movem.l d6-d7,-(sp)
                        move.w  L1590_i_3(a6),d6
                        move.w  d2,(a1,d6.w)
                        swap    d2
                        move.w  d2,(a1)
                        move.w  d6,d7
                        lsl.l   #1,d6
                        add.w   d6,d7
                        move.w  d3,(a1,d7.w)
                        swap    d3
                        move.w  d3,(a1,d6.w)
                        addq.l  #2,a1
                        movem.l (sp)+,d6-d7
                        bra.w   @Tloc_AA82
                @Tloc_ABC2:
                        movem.l d6-d7,-(sp)
                        move.w  L1590_i_3(a6),d6
                        move.w  d2,(a1,d6.w)
                        swap    d2
                        move.w  d2,(a1)
                        move.w  d6,d7
                        lsl.l   #1,d6
                        add.w   d6,d7
                        move.w  d3,(a1,d7.w)
                        swap    d3
                        move.w  d3,(a1,d6.w)
                        addq.l  #2,a1
                        movem.l (sp)+,d6-d7
                        subq.w  #1,P0191_i_DestinationHeight(a6)
                        beq.s   @Tloc_AC12
#if (EXETYPE == C07_HINT)
                        move.l  a4,d2
#else
                        move.l  a5,d2
#endif
                        move.l  d2,d3
                        add.l   L1586_l_1(a6),d3
#if (EXETYPE == C07_HINT)
                        movea.l d3,a4
#else
                        movea.l d3,a5
#endif
                        swap    d2
                        swap    d3
                        sub.w   d2,d3
#if (EXETYPE == C07_HINT)
                        subq.w  #1,d3
#endif
                        mulu.w  L1588_i_1(a6),d3
#if (EXETYPE == C07_HINT)
                        adda.w  d3,a0
#else
                        add.l   d3,L2240_puc_(a6)
                        movea.l L2240_puc_(a6),a0
#endif
                        move.w  P0190_i_DestinationPixelWidth(a6),(sp)
                        bra.w   @Tloc_AA74
                @Tloc_AC12:
                        addq.w  #2,sp
#if (EXETYPE == C07_HINT)
                        movem.l (sp)+,d4-d7/a2-a5
#else
                        movem.l (sp)+,d3-d7/a2-a6
#endif
        }
#if (EXETYPE == C13_GRF1)
        ASM_STUB_SUFFIX
#endif
#endif
}

#ifdef MEDIA458_P20JA_P20JB /* The only difference between F1004_VIDEO_BlitShrinkWithPaletteChanges and F0129_VIDEO_BlitShrinkWithPaletteChanges is that values in P0192_puc_PaletteChanges are divided by 10 in F0129_VIDEO_BlitShrinkWithPaletteChanges and not in F1004_VIDEO_BlitShrinkWithPaletteChanges */
void F1004_VIDEO_BlitShrinkWithPaletteChanges(
unsigned char*   P0186_puc_Bitmap_Source       SEPARATOR
unsigned char*   P0187_puc_Bitmap_Destination  SEPARATOR
unsigned int16_t P0188_i_SourcePixelWidth      SEPARATOR
unsigned int16_t P0189_i_SourceHeight          SEPARATOR
int16_t          P0190_i_DestinationPixelWidth SEPARATOR
int16_t          P0191_i_DestinationHeight     SEPARATOR
unsigned char*   P0192_puc_PaletteChanges      FINAL_SEPARATOR
{
        unsigned int16_t L2241_ui_;
        unsigned int16_t L2242_ui_;
        int16_t L2243_i_;
        unsigned int16_t L2244_ui_;
        int16_t L2245_i_;
        int16_t L2246_i_;
        unsigned int16_t L2247_ui_;


        G2043_puc_BlitShrink_BitmapSource = P0186_puc_Bitmap_Source;
        G2044_puc_BlitShrink_BitmapDestination = P0187_puc_Bitmap_Destination;
        if (&G2304_ac_BlitShrink_PaletteChanges != NULL) {
                for (L2247_ui_ = 0; L2247_ui_ < 16; L2247_ui_++) {
                        G2304_ac_BlitShrink_PaletteChanges[L2247_ui_] = P0192_puc_PaletteChanges[L2247_ui_];
                }
        }
        L2245_i_ = M104_EVEN_INTEGER(P0190_i_DestinationPixelWidth);
        L2246_i_ = M104_EVEN_INTEGER(P0188_i_SourcePixelWidth);
        L2243_i_ = (P0188_i_SourcePixelWidth << 6) / P0190_i_DestinationPixelWidth;
        L2244_ui_ = (P0189_i_SourceHeight << 6) / P0191_i_DestinationHeight;
        L2242_ui_ = L2244_ui_ >> 1;
        for (L2241_ui_ = 0; L2241_ui_ < P0191_i_DestinationHeight; L2241_ui_++) {
                if (P0192_puc_PaletteChanges == NULL) {
                        F0720_ShrinkBLT_Sub1((L2242_ui_ >> 6) * L2246_i_, L2241_ui_ * L2245_i_, L2243_i_, P0190_i_DestinationPixelWidth);
                } else {
                        F0721_ShrinkBLT_Sub2((L2242_ui_ >> 6) * L2246_i_, L2241_ui_ * L2245_i_, L2243_i_, P0190_i_DestinationPixelWidth);
                }
                L2242_ui_ += L2244_ui_;
        }
}
#endif
#endif
