#ifndef COMPILE_H
#include "COMPILE.H"
#endif
#ifdef MEDIA773_SU1E_AU1E
void F7001_SaveChampions(
void)
{
        register char* L3811_pc_;
        register char L3812_uc_;
#ifdef MEDIA772_SU1E
        int16_t L3814_i_;
#endif
#ifdef MEDIA762_AU1E
        FILE_HANDLE L3814_;
#endif
        char L3813_ac_FileName[50];
#ifdef MEDIA772_SU1E
        char L5791_ac_Unreferenced[100];
#endif
        register int16_t L3817_i_;
        register char* L5790_;


        if (!G7111_Games[C0_GAME_SOURCE].GameLoaded || !G7114_LoadedChampionCount) {
                return;
        }
#ifdef MEDIA772_SU1E
        if (!G2246_CMPData.Name[0]) {
                F7072_GetDialogChoiceOrdinal(G7081_EACH_CHAMPION_MUST_HAVE_A_UNIQUE_FIRST_NAME, C08_COLOR_RED, G7060_OK, &G2263_s_Input_Dialog1Choice);
#endif
#ifdef MEDIA762_AU1E
        if (G2246_CMPData.Name[0] == '\0') {
                F7074_DrawDialogErrorMessage(G7081_EACH_CHAMPION_MUST_HAVE_A_UNIQUE_FIRST_NAME, C08_COLOR_RED);
#endif
                return;
        }
        L3817_i_ = F7072_GetDialogChoiceOrdinal(G7069_YOU_MAY_SAVE_EITHER_THE_WHOLE_GAME_OR_THE_SELECTED_CHAMPIONS_PORTRAIT, C15_COLOR_WHITE | MASK0x8000_INVERT_BOX, G7064_GAME_PORTRAIT_CANCEL, &G2254_s_Input_Dialog3ChoicesB);
        if (L3817_i_ == 1) {
                F7052_SaveGame(0);
                return;
        }
        if (L3817_i_ == 2) {
#ifdef MEDIA762_AU1E
                F2105_CHAMPION_ConvertBitmapFromAtariSTPlanar(G2246_CMPData.Portrait, 32, 29);
#endif
                F0088_strcpy(L3813_ac_FileName, G3802_pc_SaveFloppyDriveRootPath);
                L5790_ = L3813_ac_FileName;
                while (*L5790_) {
                        L5790_++;
                }
                L3811_pc_ = G2246_CMPData.Name;
                L3817_i_ = 0;
                while (L3812_uc_ = *L3811_pc_) {
                        if ((L3812_uc_ >= 'A') && (L3812_uc_ <= 'Z')) {
                                L3817_i_++;
                                *L5790_++ = L3812_uc_;
                        }
                        L3811_pc_++;
                }
                if (L3817_i_ == 0) {
                        F0086_strcat(L3813_ac_FileName, G7020_PORTRAIT);
                } else {
                        *L5790_ = '\0';
                }
                F0086_strcat(L3813_ac_FileName, G3803_);
#ifdef MEDIA772_SU1E
                if (F1994_(2, L3813_ac_FileName)) {
                        if ((L3814_i_ = Fcreate(L3813_ac_FileName, C0_FILE_ATTRIBUTES)) >= 0) {
                                L3817_i_ = (Fwrite(L3814_i_, (long)sizeof(CMP), &G2246_CMPData) == (long)sizeof(CMP));
                                Fclose(L3814_i_);
                                if (L3817_i_) {
                                        goto loc_1F48;
                                }
                                Fdelete(L3813_ac_FileName);
                        }
                        F7072_GetDialogChoiceOrdinal(G7077_ERROR_WHILE_SAVING_CHAMPION, C08_COLOR_RED, G7060_OK, &G2263_s_Input_Dialog1Choice);
                        return;
                }
#endif
#ifdef MEDIA762_AU1E
                if (!F1994_(2, L3813_ac_FileName)) {
                        goto loc_1F48;
                }
                if ((L3814_ = F0776_FILE_Create(L3813_ac_FileName)) != NULL) {
                        L3817_i_ = F0773_FILE_Write(L3814_, (long)sizeof(CMP), &G2246_CMPData);
                        F0771_FILE_Close(L3814_);
                        if (L3817_i_) {
                                goto loc_52C8;
                        }
                        F0777_FILE_Delete(L3813_ac_FileName);
                        Delay(250L);
                }
                F7074_DrawDialogErrorMessage(G7077_ERROR_WHILE_SAVING_CHAMPION, C08_COLOR_RED);
                return;
                loc_52C8:
                Delay(250L);
#endif
        }
        loc_1F48:
        F7071_();
}
#endif
