예제 #1
0
/*
 * \note A hack, but hey, it works :)
 * Adding periodic timer won't work, because we can't call av_sync from timer.
 * The only thing allowed is SDL_PushEvent, and we don't have event-driven
 * setup. So for now either this or nothing.
 */
void
av_set_fading(int type, int from, int to, int steps, int preserve)
{
    int dir = (type == AV_FADE_IN) ? 1 : -1;
    unsigned st;
    unsigned st_end;

    if (!do_fading) {
        return;
    }

    if (!steps > 0) {
        steps = 5;
    }

    st = (type == AV_FADE_IN) ? 0 : steps;
    st_end = steps - st;

    fade_info.from = from;
    fade_info.to = to;
    fade_info.steps = steps;
    fade_info.step = st;
    fade_info.force_black = !preserve;
    fade_info.inc = dir;
    fade_info.end = st_end;

    for (; fade_info.step != fade_info.end; fade_info.step += fade_info.inc) {
        av_sync();
        SDL_Delay(10);
    }

    av_sync();
}
예제 #2
0
/* 
 * \note A hack, but hey, it works :)
 * Adding periodic timer won't work, because we can't call av_sync from timer.
 * The only thing allowed is SDL_PushEvent, and we don't have event-driven
 * setup. So for now either this or nothing.
 */
void
av_set_fading(int type, int from, int to, int steps, int preserve)
{
    int dir = (type == AV_FADE_IN) ? 1 : -1;
    unsigned st;  
    unsigned st_end;
    SDL_Rect r = {0, 0, MAX_X, MAX_Y};

    if (!do_fading)
        return;

    if (!steps > 0)
        steps = 5;
    st = (type == AV_FADE_IN) ? 0 : steps;
    st_end = steps - st;

    fade_info.from = from;
    fade_info.to = to;
    fade_info.steps = steps;
    fade_info.step = st;
    fade_info.force_black = !preserve;
    fade_info.inc = dir;
    fade_info.end = st_end;

    for (;fade_info.step != fade_info.end; fade_info.step += fade_info.inc)
    {
        av_need_update(&r);
        av_sync();
        SDL_Delay(10);
    }
    av_need_update(&r);
    av_sync();
}
예제 #3
0
void Prefs(int where)
{
    int num, hum1 = 0, hum2 = 0;
    FILE *fin;
    char ch, Name[20], ksel = 0;
    int32_t size;

    if (where != 3) {
        if (where == 0) {
            plr[0] = 0;
            plr[1] = 1;
            Data->Def.Plr2 = 1;
            Data->Def.Plr1 = 0;
            hum1 = 0, hum2 = 1;
            Data->Def.Lev1 = Data->Def.Ast1 = Data->Def.Ast2 = 0;
            Data->Def.Lev2 = 2; //start computer level 3
            Data->Def.Input = 0;
            Data->Def.Sound = Data->Def.Music = 1;
            MuteChannel(AV_ALL_CHANNELS, 0);
        }

        if (Data->Def.Plr1 > 1) {
            Data->Def.Plr1 -= 2;
            hum1 = 1;
        }

        if (Data->Def.Plr2 > 1) {
            Data->Def.Plr2 -= 2;
            hum2 = 1;
        }
    }

    /* Data->Def.Sound=Data->Def.Music=1; */
    DrawPrefs(where, hum1, hum2);
    WaitForMouseUp();

    while (1) {
        key = 0;
        GetMouse();

        if (mousebuttons > 0 || key > 0) { /* Game Play */
            if (((x >= 245 && y >= 5 && x <= 314 && y <= 17) || key == K_ENTER) && !(hum1 == 1 && hum2 == 1)) {
                InBox(245, 5, 314, 17);
                WaitForMouseUp();

                if (key > 0) {
                    delay(150);
                }

                OutBox(245, 5, 314, 17);

                if (!(Data->Def.Input == 2 || Data->Def.Input == 3)) {
                    if (options.feat_eq_new_name && hum1 != 1) {
                        SetEquipName(0);
                    }

                    if (options.feat_eq_new_name && hum2 != 1) {
                        SetEquipName(1);
                    }
                } //Change Name, if basic mode and for human players

                if (Data->Def.Plr1 != Data->Def.Plr2) {
                    if (Data->Def.Plr1 == 1) {
                        int tmp;

                        strcpy(&Name[0], &Data->P[0].Name[0]);
                        strcpy(&Data->P[0].Name[0], &Data->P[1].Name[0]);
                        strcpy(&Data->P[1].Name[0], &Name[0]);
                        tmp = Data->Def.Lev1;
                        Data->Def.Lev1 = Data->Def.Lev2;
                        Data->Def.Lev2 = tmp;
                        tmp = Data->Def.Ast1;
                        Data->Def.Ast1 = Data->Def.Ast2;
                        Data->Def.Ast2 = tmp;
                    }

                    Data->Def.Plr1 += hum1 * 2;
                    Data->Def.Plr2 += hum2 * 2;

                    if (where == 0 || where == 3) {
                        FadeOut(2, 10, 0, 0);
                    }

                    key = 0;

                    if ((where == 0 || where == 3) && (Data->Def.Input == 2 || Data->Def.Input == 3)) {
                        fin = sOpen("HIST.DAT", "rb", 0);
                        fread(&Data->P[0].Probe[PROBE_HW_ORBITAL], 28 * (sizeof(Equipment)), 1, fin);
                        fread(&Data->P[1].Probe[PROBE_HW_ORBITAL], 28 * (sizeof(Equipment)), 1, fin);
                        fclose(fin);
                    }

                    ///Random Equipment
                    if ((where == 0 || where == 3) && (Data->Def.Input == 4 || Data->Def.Input == 5)) {
                        RandomizeEq();
                    }

                    int i, k;

                    for (i = 0; i < NUM_PLAYERS; i++)
                        for (k = 0; k < 7; k++) {
                            Data->P[i].Probe[k].MSF = Data->P[i].Probe[k].MaxRD;
                            Data->P[i].Rocket[k].MSF = Data->P[i].Rocket[k].MaxRD;
                            Data->P[i].Manned[k].MSF = Data->P[i].Manned[k].MaxRD;
                            Data->P[i].Misc[k].MSF = Data->P[i].Misc[k].MaxRD;
                        }

                    if (Data->Def.Input == 0 || Data->Def.Input == 2 || Data->Def.Input == 4) {
                        // Hist Crews
                        fin = sOpen("CREW.DAT", "rb", 0);
                        size = fread(buffer, 1, BUFFER_SIZE, fin);
                        fclose(fin);
                        fin = sOpen("MEN.DAT", "wb", 1);
                        fwrite(buffer, size, 1, fin);
                        fclose(fin);
                    } else if (Data->Def.Input == 1 || Data->Def.Input == 3 || Data->Def.Input == 5) {
                        // User Crews
                        fin = sOpen("USER.DAT", "rb", FT_SAVE);

                        if (!fin) {
                            fin = sOpen("USER.DAT", "rb", FT_DATA);
                        }

                        size = fread(buffer, 1, BUFFER_SIZE, fin);
                        fclose(fin);
                        fin = sOpen("MEN.DAT", "wb", 1);
                        fwrite(buffer, size, 1, fin);
                        fclose(fin);
                    }

                    music_stop();
                    return;
                }
            } else if (key == 'P' && (where == 0 || where == 3)) {
                fill_rectangle(59, 26, 68, 31, 3);
                fill_rectangle(290, 26, 298, 31, 3);

                if (ksel == 0) {
                    ksel = 1;
                    display::graphics.setForegroundColor(9);
                    draw_string(253, 30, "PLAYER 2");
                    display::graphics.setForegroundColor(34);
                    draw_string(23, 30, "PLAYER 1");
                } else {
                    ksel = 0;
                    display::graphics.setForegroundColor(34);
                    draw_string(253, 30, "PLAYER 2");
                    display::graphics.setForegroundColor(9);
                    draw_string(23, 30, "PLAYER 1");
                }
            } else if ((x >= 146 && y >= 30 && x <= 219 && y <= 61 && mousebuttons > 0) || key == 'E') {
                // Edit astronauts has been ripped out

            } else if (((x >= 96 && y >= 114 && x <= 223 && y <= 194 && mousebuttons > 0) || key == K_SPACE) && (where == 3 || where == 0)) { // Hist
                char maxHModels;
                maxHModels = options.feat_random_eq > 0 ? 5 : 3;
                WaitForMouseUp();
                Data->Def.Input++;

                if (Data->Def.Input > maxHModels) {
                    Data->Def.Input = 0;
                }

                HModel(Data->Def.Input, 0);
            } else if ((x >= 146 && y >= 70 && x <= 219 && y <= 101 && mousebuttons > 0) || key == 'A') {
                /* disable this option right now */
            } else if ((x >= 100 && y >= 30 && x <= 135 && y <= 61 && mousebuttons > 0) || key == 'M') {
                InBox(100, 30, 135, 61);
                WaitForMouseUp();
                Data->Def.Music = !Data->Def.Music;
                // SetMusicVolume((Data->Def.Music==1)?100:0);
                music_set_mute(!Data->Def.Music);
                vhptr->copyTo(display::graphics.legacyScreen(), 153 + 34 * (Data->Def.Music), 0, 101, 31, 134, 60);
                OutBox(100, 30, 135, 61);
                /* Music Level */
            } else if ((x >= 100 && y >= 70 && x <= 135 && y <= 101 && mousebuttons > 0) || key == 'S') {
                InBox(100, 70, 135, 101);
                WaitForMouseUp();
                Data->Def.Sound = !Data->Def.Sound;
                MuteChannel(AV_SOUND_CHANNEL, !Data->Def.Sound);
                vhptr->copyTo(display::graphics.legacyScreen(), 221 + 34 * (Data->Def.Sound), 0, 101, 71, 134, 100);
                OutBox(100, 70, 135, 101);
                /* Sound Level */
            }

            else if ((x >= 8 && y >= 77 && x <= 18 && y <= 85 && where == 0 && mousebuttons > 0) ||
                     (where == 0 && ksel == 0 && key == 'H')) {
                InBox(8, 77, 18, 85);
                WaitForMouseUp();
                hum1++;

                if (hum1 > 1) {
                    hum1 = 0;
                }

                CLevels(0, hum1);
                OutBox(8, 77, 18, 85);

                /* P1: Human/Computer */
                //change human to dif 1 and comp to 3
                if (hum1 == 1) {
                    Data->Def.Lev1 = 2;
                } else {
                    Data->Def.Lev1 = 0;
                }

                Levels(0, Data->Def.Lev1, 1);
            } else if ((x >= 8 && y >= 107 && x <= 81 && y <= 138 && (where == 0 || where == 3) && mousebuttons > 0) ||
                       ((where == 3 || where == 0) && ksel == 0 && key == 'G')) {
                InBox(8, 107, 81, 138);
                WaitForMouseUp();
                OutBox(8, 107, 81, 138);
                Data->Def.Lev1++;

                if (Data->Def.Lev1 > 2) {
                    Data->Def.Lev1 = 0;
                }

                Levels(0, Data->Def.Lev1, 1);
                /* P1: Game Level */
            } else if ((x >= 8 && y >= 160 && x <= 81 && y <= 191 && ((where == 0 || where == 3) && mousebuttons > 0)) ||
                       ((where == 3 || where == 0) && ksel == 0 && key == 'L')) {
                InBox(8, 160, 81, 191);
                WaitForMouseUp();
                OutBox(8, 160, 81, 191);
                Data->Def.Ast1++;

                if (Data->Def.Ast1 > 2) {
                    Data->Def.Ast1 = 0;
                }

                Levels(0, Data->Def.Ast1, 0);
                /* P1: Astro Level */
            }

            else if ((x >= 238 && y >= 77 && x <= 248 && y <= 85 && where == 0 && mousebuttons > 0) ||
                     (where == 0 && ksel == 1 && key == 'H')) {
                InBox(238, 77, 248, 85);
                WaitForMouseUp();
                hum2++;

                if (hum2 > 1) {
                    hum2 = 0;
                }

                CLevels(1, hum2);
                OutBox(238, 77, 248, 85);

                /* P2:Human/Computer */
                //change human to dif 1 and comp to 3
                if (hum2 == 1) {
                    Data->Def.Lev2 = 2;
                } else {
                    Data->Def.Lev2 = 0;
                }

                Levels(1, Data->Def.Lev2, 1);
            } else if ((x >= 238 && y >= 107 && x <= 311 && y <= 138 && (where == 0 || where == 3) && mousebuttons > 0) ||
                       ((where == 0 || where == 3) && ksel == 1 && key == 'G')) {
                InBox(238, 107, 311, 138);
                WaitForMouseUp();
                OutBox(238, 107, 311, 138);
                Data->Def.Lev2++;

                if (Data->Def.Lev2 > 2) {
                    Data->Def.Lev2 = 0;
                }

                Levels(1, Data->Def.Lev2, 1);
                /* P2: Game Level */
            } else if ((x >= 238 && y >= 160 && x <= 311 && y <= 191 && (where == 0 || where == 3) && mousebuttons > 0) ||
                       ((where == 0 || where == 3) && ksel == 1 && key == 'L')) {
                InBox(238, 160, 311, 191);
                WaitForMouseUp();
                OutBox(238, 160, 311, 191);
                Data->Def.Ast2++;

                if (Data->Def.Ast2 > 2) {
                    Data->Def.Ast2 = 0;
                }

                Levels(1, Data->Def.Ast2, 0);
                /* P2: Astro Level */
            } else if ((x >= 6 && y >= 34 && x <= 83 && y <= 42 && (where == 3 || where == 0) && mousebuttons > 0) ||
                       ((where == 3 || where == 0) && ksel == 0 && key == 'N')) {
                fill_rectangle(7, 35, 82, 41, 0);

                for (int i = 0; i < 20; i++) {
                    Data->P[0].Name[i] = 0x00;
                }

                num = 0;
                ch = 0;
                display::graphics.setForegroundColor(1);
                grMoveTo(8, 40);
                draw_character(0x14);
                av_sync();

                while (ch != K_ENTER) {
                    ch = getch();

                    if (ch != (ch & 0xff)) {
                        ch = 0x00;
                    }

                    if (ch >= 'a' && ch <= 'z') {
                        ch -= 0x20;
                    }

                    if (ch == 0x08 && num > 0) {
                        Data->P[0].Name[--num] = 0x00;
                    } else if (num < 12 && (isupper(ch) || isdigit(ch) || ch == 0x20)) {
                        Data->P[0].Name[num++] = ch;
                    }

                    fill_rectangle(7, 35, 82, 41, 0);
                    display::graphics.setForegroundColor(1);
                    draw_string(8, 40, &Data->P[0].Name[0]);
                    draw_character(0x14);
                    av_sync();
                }

                Data->P[0].Name[num] = 0x00;
                fill_rectangle(7, 35, 82, 41, 0);
                display::graphics.setForegroundColor(1);
                draw_string(8, 40, &Data->P[0].Name[0]);
                av_sync();
                /* P1: Director Name */
            } else if ((x >= 236 && y >= 34 && x <= 313 && y <= 42 && (where == 3 || where == 0) && mousebuttons > 0) ||
                       ((where == 3 || where == 0) && ksel == 1 && key == 'N')) {
                fill_rectangle(237, 35, 312, 41, 0);

                for (int i = 0; i < 20; i++) {
                    Data->P[1].Name[i] = 0x00;
                }

                num = 0;
                ch = 0;
                display::graphics.setForegroundColor(1);
                grMoveTo(238, 40);
                draw_character(0x14);
                av_sync();

                while (ch != K_ENTER) {
                    ch = getch();

                    if (ch != (ch & 0xff)) {
                        ch = 0x00;
                    }

                    if (ch >= 'a' && ch <= 'z') {
                        ch -= 0x20;
                    }

                    if (ch == 0x08 && num > 0) {
                        Data->P[1].Name[--num] = 0x00;
                    } else if (num < 12 && (isupper(ch) || isdigit(ch) || ch == 0x20)) {
                        Data->P[1].Name[num++] = ch;
                    }

                    fill_rectangle(237, 35, 312, 41, 0);
                    display::graphics.setForegroundColor(1);
                    draw_string(238, 40, &Data->P[1].Name[0]);
                    draw_character(0x14);
                    av_sync();
                }

                Data->P[1].Name[num] = 0x00;
                fill_rectangle(237, 35, 312, 41, 0);
                display::graphics.setForegroundColor(1);
                draw_string(238, 40, &Data->P[1].Name[0]);
                av_sync();
                /* P2: Director Name */
            };
        }
    };
}