#ifndef COMPILE_H
#include "COMPILE.H"
#endif
#ifdef MEDIA763_AU1E_AU2E
extern STRUCT22B G3737_[10];


void F2014_ConvertStringToLowerCase(register char* P5934_) {
        while (*P5934_) {
                *P5934_ += ((*P5934_ < 'A') || (*P5934_ > 'Z')) ? 0 : 'a' - 'A';
        }
}

unsigned char* F2015_(
)
{
        return F2037_();
}

unsigned char* F2016_(
)
{
        unsigned char* L5828_;


        L5828_ = F2038_();
        return L5828_;
}

void F2017_(int16_t P5935_) {
        F2039_(P5935_);
}

void F2018_(
)
{
}

void F2019_(
)
{
}

void F1528_MOUSE_DisableScreenUpdate(
)
{
        F0078_MOUSE_DisableScreenUpdate();
}

void F1527_MOUSE_EnableScreenUpdate_CPSE(
)
{
        F0077_MOUSE_EnableScreenUpdate_CPSE();
}

void F1067_InitAmigaStuff(
)
{
        F1088_OpenAmigaStuff();
        F2042_InitializeScreen();
        F0575_VerticalBlank_Initialize();
        F1111_CPSX();
}

void F1068_FreeAmigaStuff(
)
{
        F0518_FLOPPY_Deinitialize_CPSX();
        F0576_VerticalBlank_Deinitialize();
        F2043_UninitializeScreen();
        F1089_CloseAmigaStuff();
}

int16_t F2022_F1889_SubForInit(
)
{
        register unsigned int16_t L5849_;
        register int16_t L5850_;
        int16_t L5851_;
        int16_t L5852_;
        long L5853_;
        char L5897_ac_Unreferenced[8];
        unsigned int16_t* L5854_;
        long L5855_;
        int16_t L5856_;
        HINT_GRAPHICS L5857_;
        char* L5858_;
#ifdef MEDIA767_AU2E
        unsigned int16_t L5910_;
#endif
        int16_t L5859_;
        int16_t L5860_;
        int16_t L5861_;


        L5859_ = 1;
        F1768_();
        F1853_(10);
        if (F1769_GetLastErrorCode()) {
                F1956_EndProgram(14, 18, 96L);
        }
        for (L5860_ = 1; L5860_ < 4; L5860_++) {
                if (F1106_IsTrackdiskDeviceOpened(L5860_)) {
                        L5859_++;
                        break;
                }
        }
        L5861_ = '0' + L5860_;
#ifdef MEDIA762_AU1E
        L5858_ = G3578_ps_InsertDiskInDriveBThenPressLoad->_pc_0x02_String;
        L5858_[94] = L5861_; /* Replace drive number in string */
        L5858_ = G3580_ps_InsertDiskInDriveB->_pc_0x02_String;
        L5858_[43] = L5861_; /* Replace drive number in string */
#endif
        G3852_ = 32000;
        F1893_ColorPalette(14, 1);
        for (L5852_ = 0; L5852_ < 3; L5852_++) {
                if (F1931_(14, 12, G3637_apc_FileNames[3], 0L) == 1) {
                        break;
                }
        }
        if (L5852_ >= 3) {
                F1956_EndProgram(14, 18, 12L);
        }
        if (L5853_ = F1872_LoadGraphics(G3637_apc_FileNames[3], &L5857_, 0L)) {
                F1956_EndProgram(14, 18, L5853_);
        }
        if (L5853_ = F1878_LoadGraphic(G3609_aui_GraphicIntegers, C0_HINT_GRAPHIC_INTEGERS)) {
                F1956_EndProgram(14, 18, L5853_);
        }
        G3611_puc_Bitmap_Oracle = (unsigned char*)F1886_Memory(6, 14, G3852_);
        F0008_MAIN_ClearBytes(G3611_puc_Bitmap_Oracle, G3852_);
        if (L5853_ = F1880_LoadBitmapFromGraphic(G3611_puc_Bitmap_Oracle, 1)) {
                F1956_EndProgram(14, 18, L5853_);
        }
#ifdef MEDIA762_AU1E
        G3613_puc_Bitmap_Font = (unsigned char*)F1886_Memory(6, 16, 3456L);
        F0008_MAIN_ClearBytes(G3613_puc_Bitmap_Font, 3456L);
#endif
#ifdef MEDIA767_AU2E
        G3613_puc_Bitmap_Font = (unsigned char*)F1886_Memory(6, 16, 9216L);
        F0008_MAIN_ClearBytes(G3613_puc_Bitmap_Font, 9216L);
#endif
        if (L5853_ = F1880_LoadBitmapFromGraphic(G3613_puc_Bitmap_Font, 2)) {
                F1956_EndProgram(14, 18, L5853_);
        }
        if (L5853_ = F1878_LoadGraphic(G3603_aui_Palette_HintOracle, C3_HINT_GRAPHIC_PALETTE)) {
                F1956_EndProgram(14, 18, 212L);
        }
        for (L5849_ = 1; L5849_ < 16; L5849_++, L5850_ = 0) { /* BUGX_XX ? D6 = L5850_ not initialized before first iteration */
                L5850_ |= ((((G3603_aui_Palette_HintOracle[L5849_] & 0x700) >> 8) * 15) / 7) << 8;
                L5850_ |= ((((G3603_aui_Palette_HintOracle[L5849_] & 0x70) >> 4) * 15) / 7) << 4;
                L5850_ |= ((G3603_aui_Palette_HintOracle[L5849_] & 0x7) * 15) / 7;
                G3603_aui_Palette_HintOracle[L5849_] = L5850_;
        }
        G3603_aui_Palette_HintOracle[0] = 0;
#ifdef MEDIA767_AU2E
        F2028_LoadHintOracleTexts();
#endif
        F1875_FreeHintGraphics_CPSX();
#ifdef MEDIA767_AU2E
        L5910_ = 0;
        for (;;) {
                L5858_ = G3737_[L5910_]._pc_0x02_String;
                if (L5858_ == NULL) {
                        break;
                }
                while (*L5858_) {
                        if (*L5858_ == '~') {
                                *L5858_ = L5861_;
                                break;
                        }
                        L5858_++;
                }
                L5910_++;
        }
#endif
        F7317_MAIN_CopyBytes_Alt(G3854_, G3609_aui_GraphicIntegers, MASK0x0400_MEMREQ, MASK0x0400_MEMREQ, 200L);
        F7317_MAIN_CopyBytes_Alt(G3855_, G3603_aui_Palette_HintOracle, MASK0x0400_MEMREQ, MASK0x0400_MEMREQ, 32L);
        F1884_Text(14, 26, (long)G3609_aui_GraphicIntegers[5], (long)G3609_aui_GraphicIntegers[4]);
        G3612_ = 0;
        F1932_(G3588_ps_DiskErrorPleaseTryAgain);
        F1905_();
        F0008_MAIN_ClearBytes(&G3623_Game, (long)sizeof(G3623_Game));
        F2053_();
        F1889_Screen_CPSX(14, 35);
        G3622_++;
        L5856_ = 13;
        L5855_ = 0;
        L5854_ = G3603_aui_Palette_HintOracle;
        F1893_ColorPalette(14, 34, &L5856_);
        F0078_MOUSE_DisableScreenUpdate();
        L5851_ = 0;
        return L5851_;
}

int16_t F2023_F1889_SubForUninit(
)
{
        int16_t L5863_;


#ifdef MEDIA767_AU2E
        F2030_FreeHintOracleTexts();
#endif
        if (G3612_) {
                F1886_Memory(8, 20, G3612_);
        }
        if (G3611_puc_Bitmap_Oracle) {
                F1886_Memory(6, 20, G3611_puc_Bitmap_Oracle);
        }
        if (G3613_puc_Bitmap_Font) {
                F1886_Memory(6, 20, G3613_puc_Bitmap_Font);
        }
        L5863_ = 0;
        return L5863_;
}

char F2024_IsLeftMouseButtonDown(
)
{
        return F1128_IsLeftMouseButtonDown();
}

void F2025_(
)
{
        asm {
                        moveq   #0,d0
                        btst    #7,(0xBFE001).l
                        bne.s   @Tlocret_97F6
                        moveq   #-1,d0
                @Tlocret_97F6:
        }
}
#endif
