#define ANOMALY_CEDT030_CEDT017
#define ANOMALY_CEDT017_CEDTTXT
#define ANOMALY_CEDT017_INVERT
#ifndef COMPILE_H
#include "COMPILE.H"
#endif
#ifdef MEDIA677_F31E_F31J_X31J_P31J_AU2E_AU3E
#ifdef MEDIA670_F31E_F31J
int G7159_ScreenBufferByteCount;
int16_t G7161_ScreenPixelWidth;
int16_t G7158_ScreenPixelHeight;
char G4190_ac_Unreferenced[8];
#endif


#include "CEDTINCN.C"

#ifdef MEDIA699_X31J_AU2E_AU3E
long F7254_(unsigned int16_t P4023_i_, unsigned int16_t P4024_i_)
{
#ifdef MEDIA692_X31J
        return (unsigned int16_t)(P4023_i_ * 2) * P4024_i_;
#endif
#ifdef MEDIA768_AU2E_AU3E
        VDEO_04_GetBitmapByteCount(P4023_i_, P4024_i_);
#endif
}
#endif

long F7249_GetBitmapByteCount(unsigned int16_t P4010_i_, unsigned int16_t P4011_i_)
{
#ifdef MEDIA667_P31J
        return (((P4010_i_ + 1) & 0xFFFE) >> 1) * P4011_i_;
#endif
#ifdef MEDIA670_F31E_F31J
        return M103_BITMAP_BYTE_COUNT(P4010_i_, P4011_i_);
#endif
#ifdef MEDIA692_X31J
        return ((unsigned int16_t)(P4010_i_ + 1) >> 1) * P4011_i_;
#endif
#ifdef MEDIA768_AU2E_AU3E
        GRF1_04_GetBitmapMemorySize(P4010_i_, P4011_i_);
#endif
}

long F7250_GetBitmapByteCount_Unreferenced(unsigned int16_t P4012_i_, unsigned int16_t P4013_i_)
{
#ifdef MEDIA667_P31J
        return (((P4012_i_ + 1) & 0xFFFE) >> 1) * P4013_i_;
#endif
#ifdef MEDIA670_F31E_F31J
        return M103_BITMAP_BYTE_COUNT(P4012_i_, P4013_i_);
#endif
#ifdef MEDIA699_X31J_AU2E_AU3E
        return (((unsigned int16_t)(P4012_i_ + 15) >> 1) & 0xFFF8) * P4013_i_;
#endif
}

#include "PORTRAIT.C"

#ifdef MEDIA671_F31E_F31J_P31J
int16_t F7253_GetNormalizedPixelWidth_Unreferenced(unsigned int16_t P4022_i_)
{
#ifdef MEDIA667_P31J
        return (((P4022_i_ + 1) & 0xFFFE) >> 1) * 2;
#endif
#ifdef MEDIA670_F31E_F31J
        return ((int)((P4022_i_ + 31) & 0xFFFFFFE0) >> 1) * 2;
#endif
}

long F7254_(unsigned int16_t P4023_i_, unsigned int16_t P4024_i_)
{
        return F7332_GetPrefixedBitmapByteCount(P4023_i_, P4024_i_);
}
#endif

void F7255_(REGISTER unsigned char* P4025_puc_Bitmap, int16_t* P4026_pi_Box)
{
#ifdef MEDIA671_F31E_F31J_P31J
        F0077_MOUSE_EnableScreenUpdate_CPSE();
        F7334_BlitToScreenNoTransparency(P4025_puc_Bitmap);
        F0078_MOUSE_DisableScreenUpdate();
#endif
#ifdef MEDIA692_X31J
        register int16_t* L6001_;
        register int16_t* L6002_;
        register int16_t L6003_;
        register int16_t L6004_;
        register int16_t L6005_;
        register int16_t L6006_;
        long L6007_;


        L6001_ = P4025_puc_Bitmap;
        L6004_ = P4026_pi_Box[1] - P4026_pi_Box[0] + 1;
        L6005_ = P4026_pi_Box[3] - P4026_pi_Box[2] + 1;
        L6006_ = (G3892_ >> 1) - L6004_;
        L6002_ = G3090_X68000VideoMemoryAddress + ((long)P4026_pi_Box[2] * (long)G3892_) + (long)(P4026_pi_Box[0] * 2);
        VDEO_13_WaitVerticalBlank();
        L6007_ = F1027_Supervisor(0L);
        while (--L6005_ >= 0) {
                L6003_ = L6004_;
                while (--L6003_ >= 0) {
                        *L6002_++ = *L6001_++;
                }
                L6002_ += L6006_;
        }
        F1027_Supervisor(L6007_);
#endif
#ifdef MEDIA768_AU2E_AU3E
        int16_t L6132_ai_XYZ[4];


        F1653_ConvertCoordinates(P4026_pi_Box, L6132_ai_XYZ);
        VDEO_12_BlitToScreenNoTransparency(0, P4025_puc_Bitmap, L6132_ai_XYZ);
#endif
}

#ifdef MEDIA674_F31E_F31J_X31J_P31J
void F7256_(REGISTER int16_t* P4027_pi_, int16_t* P4028_pi_)
{
#ifdef MEDIA671_F31E_F31J_P31J
        F0077_MOUSE_EnableScreenUpdate_CPSE();
        F7333_BlitFromScreenNoTransparency(P4027_pi_, P4028_pi_[0], P4028_pi_[2], P4028_pi_[1] - P4028_pi_[0] + 1, P4028_pi_[3] - P4028_pi_[2] + 1);
        F0078_MOUSE_DisableScreenUpdate();
#endif
#ifdef MEDIA692_X31J
        register int16_t* L6008_;
        register int16_t L6009_;
        register int16_t L6010_;
        register int16_t L6011_;
        register int16_t L6012_;
        long L6013_;


        L6010_ = P4028_pi_[1] - P4028_pi_[0] + 1;
        L6011_ = P4028_pi_[3] - P4028_pi_[2] + 1;
        L6012_ = (G3892_ >> 1) - L6010_;
        L6008_ = G3090_X68000VideoMemoryAddress + ((long)P4028_pi_[2] * (long)G3892_) + (long)(P4028_pi_[0] * 2);
        L6013_ = F1027_Supervisor(0L);
        while (--L6011_ >= 0) {
                L6009_ = L6010_;
                while (--L6009_ >= 0) {
                        *P4027_pi_++ = *L6008_++;
                }
                L6008_ += L6012_;
        }
        F1027_Supervisor(L6013_);
#endif
}
#endif
#ifdef MEDIA768_AU2E_AU3E
void F7256_(int16_t* P4027_pi_, int16_t* P4028_pi_)
{
        int16_t L6133_ai_XYZ[4];


        F1653_ConvertCoordinates(P4028_pi_, L6133_ai_XYZ);
        VDEO_11_BlitFromScreenNoTransparency(0, P4027_pi_, L6133_ai_XYZ);
}
#endif

void F7257_ClearScreen(
)
{
#ifdef MEDIA671_F31E_F31J_P31J
        int16_t L4561_ai_Box[4] = { 0, 319, 0, 199 };


        F0077_MOUSE_EnableScreenUpdate_CPSE();
        F7329_FillBox(G0348_Bitmap_Screen, L4561_ai_Box, C00_COLOR_BLACK, G7161_ScreenPixelWidth, G7158_ScreenPixelHeight);
        F0078_MOUSE_DisableScreenUpdate();
#endif
#ifdef MEDIA699_X31J_AU2E_AU3E
        static int16_t G2303_ai_Box_WholeScreen[4] = { 0, 319, 0, 199 };


        F7329_FillBox(G0348_Bitmap_Screen, G2303_ai_Box_WholeScreen, C00_COLOR_BLACK, G7161_ScreenPixelWidth, G7158_ScreenPixelHeight);
#endif
}

#ifdef MEDIA695_X31J_P31J_AU2E_AU3E
void F7258_DrawScreenPixel(int16_t P4029_i_, int16_t P4030_i_, unsigned char P4031_uc_Color)
#endif
#ifdef MEDIA670_F31E_F31J
void F7258_DrawScreenPixel(register int16_t P4029_i_, register int16_t P4030_i_, unsigned char P4031_uc_Color)
#endif
{
#ifdef MEDIA671_F31E_F31J_P31J
        int16_t L4562_ai_Box[4];


        M769_BOX_RIGHT(L4562_ai_Box) = M768_BOX_LEFT(L4562_ai_Box) = P4029_i_;
        M771_BOX_BOTTOM(L4562_ai_Box) = M770_BOX_TOP(L4562_ai_Box) = P4030_i_;
        F0077_MOUSE_EnableScreenUpdate_CPSE();
        F7329_FillBox(G0348_Bitmap_Screen, L4562_ai_Box, P4031_uc_Color, G7161_ScreenPixelWidth, G7158_ScreenPixelHeight);
        F0078_MOUSE_DisableScreenUpdate();
#endif
#ifdef MEDIA692_X31J
        register unsigned int16_t* L5999_;
        long L6000_;


        L5999_ = G3090_X68000VideoMemoryAddress + ((long)P4030_i_ * (long)G3892_) + (P4029_i_ * 2);
        L6000_ = F1027_Supervisor(0L);
        *L5999_ = P4031_uc_Color;
        F1027_Supervisor(L6000_);
#endif
#ifdef MEDIA768_AU2E_AU3E
        unsigned char* L6134_;
        int16_t L6135_;
        int16_t L6136_;


        L6134_ = G9002_VDEObase->_pc_0x50[G9002_VDEObase->_w_0x4E_PhysicalScreenOrdinal - 1];
        L6135_ = G9002_VDEObase->_w_0x3C_ScreenWidth;
        L6136_ = G9002_VDEObase->_w_0x3E_ScreenHeight;
        asm {
                        move.l  d3,-(sp)
                        move.w  d7,-(sp)
                        move.w  P4030_i_(a6),d1
                        move.w  P4029_i_(a6),d0
                        move.w  L6135_(a6),d2
                        move.w  L6136_(a6),d3
                        move.b  P4031_uc_Color(a6),d7
                        movea.l L6134_(a6),a0
                        lsr.w   #3,d2
                        mulu.w  d2,d1
                        mulu.w  d2,d3
                        move.w  d0,d2
                        lsr.w   #3,d2
                        add.w   d2,d1
                        adda.w  d1,a0
                        andi.w  #7,d0
                        subq.w  #7,d0
                        neg.w   d0
                        bclr    d0,(a0)
                        btst    #0,d7
                        beq.s   @Tloc_6EA6
                        bset    d0,(a0)
                @Tloc_6EA6:
                        adda.w  d3,a0
                        bclr    d0,(a0)
                        btst    #1,d7
                        beq.s   @Tloc_6EB2
                        bset    d0,(a0)
                @Tloc_6EB2:
                        adda.w  d3,a0
                        bclr    d0,(a0)
                        btst    #2,d7
                        beq.s   @Tloc_6EBE
                        bset    d0,(a0)
                @Tloc_6EBE:
                        adda.w  d3,a0
                        bclr    d0,(a0)
                        btst    #3,d7
                        beq.s   @Tloc_6ECA
                        bset    d0,(a0)
                @Tloc_6ECA:
                        move.w  (sp)+,d7
                        move.l  (sp)+,d3
        }
#endif
}

#include "CEDTINCM.C"

void F7261_ClearBitmap(unsigned char* P4039_puc_Bitmap, int16_t P4040_i_PixelWidth, int16_t P4041_i_PixelHeight)
{
        long L4563_l_;


        L4563_l_ = F7249_GetBitmapByteCount(P4040_i_PixelWidth, P4041_i_PixelHeight);
        F0008_MAIN_ClearBytes(M772_CAST_PC(P4039_puc_Bitmap), L4563_l_);
}

#ifdef MEDIA692_X31J
void F2059_(int16_t P5991_) {
}
#endif
#endif
