Exemplo n.º 1
0
short save_settings(void)
{
  char *fname;
  fname=prepare_file_path(FGrp_Save,"settings.dat");
  LbFileSaveAt(fname, &settings, sizeof(struct GameSettings));
  return true;
}
Exemplo n.º 2
0
void generate_map_fade_ghost_table(const char *fname, unsigned char *palette, unsigned char *ghost_table)
{
    if (LbFileLoadAt(fname, ghost_table) != PALETTE_COLORS*PALETTE_COLORS)
    {
        unsigned char *out;
        out = ghost_table;
        int i;
        for (i=0; i < PALETTE_COLORS; i++)
        {
            unsigned char *bpal;
            bpal = &palette[3*i];
            int n;
            for (n=0; n < PALETTE_COLORS; n++)
            {
                unsigned char *spal;
                spal = &palette[3*n];
                unsigned char r,g,b;
                r = bpal[0] + spal[0];
                g = bpal[1] + spal[1];
                b = bpal[2] + spal[2];
                *out = LbPaletteFindColour(palette, r, g, b);
                out++;
            }
        }
        LbFileSaveAt(fname, ghost_table, PALETTE_COLORS*PALETTE_COLORS);
    }
}
Exemplo n.º 3
0
short save_continue_game(LevelNumber lvnum)
{
    char *fname;
    long fsize;
    // Update continue level number
    if (is_singleplayer_like_level(lvnum))
      set_continue_level_number(lvnum);
    SYNCDBG(6,"Continue set to level %d (loaded is %d)",(int)get_continue_level_number(),(int)get_loaded_level_number());
    fname = prepare_file_path(FGrp_Save,continue_game_filename);
    fsize = LbFileSaveAt(fname, &game, sizeof(struct Game));
    return (fsize == sizeof(struct Game));
}
Exemplo n.º 4
0
TbBool init_whitepal_table(void)
{
    char *fname;
    static const char textname[] = "white-blended color table";
    fname = prepare_file_path(FGrp_StdData,"whitepal.col");
    SYNCDBG(0,"Reading %s file \"%s\".",textname,fname);
    // Loading file data
    if (LbFileLoadAt(fname, &white_pal) != 256)
    {
        compute_shifted_palette_table(white_pal, engine_palette, engine_palette, 48, 48, 48);
        LbFileSaveAt(fname, &white_pal, 256);
    }
    return true;
}
Exemplo n.º 5
0
TbBool init_rgb2idx_table(void)
{
    char *fname;
    static const char textname[] = "rgb-to-index color table";
    fname = prepare_file_path(FGrp_StdData,"colours.col");
    SYNCDBG(0,"Reading %s file \"%s\".",textname,fname);
    // Loading file data
    if (LbFileLoadAt(fname, &colours) != sizeof(TbRGBColorTable))
    {
        compute_rgb2idx_table(colours,engine_palette);
        LbFileSaveAt(fname, &colours, sizeof(TbRGBColorTable));
    }
    return true;
}
Exemplo n.º 6
0
TbBool init_alpha_table(void)
{
    char *fname;
    static const char textname[] = "alpha color table";
    fname = prepare_file_path(FGrp_StdData,"alpha.col");
    SYNCDBG(0,"Reading %s file \"%s\".",textname,fname);
    // Loading file data
    if (LbFileLoadAt(fname, &alpha_sprite_table) != sizeof(struct TbAlphaTables))
    {
        compute_alpha_tables(&alpha_sprite_table,engine_palette,engine_palette);
        LbFileSaveAt(fname, &alpha_sprite_table, sizeof(struct TbAlphaTables));
    }
    return true;
}
Exemplo n.º 7
0
TbBool load_settings(void)
{
    SYNCDBG(6,"Starting");
    char *fname;
    long len;
    fname = prepare_file_path(FGrp_Save,"settings.dat");
    len = LbFileLengthRnc(fname);
    if (len == sizeof(struct GameSettings))
    {
      if (LbFileLoadAt(fname, &settings) == sizeof(struct GameSettings))
          return true;
    }
    setup_default_settings();
    LbFileSaveAt(fname, &settings, sizeof(struct GameSettings));
    return false;
}
Exemplo n.º 8
0
TbBool init_fades_table(void)
{
    char *fname;
    long i;
    static const char textname[] = "fade table";
    fname = prepare_file_path(FGrp_StdData,"tables.dat");
    SYNCDBG(0,"Reading %s file \"%s\".",textname,fname);
    if (LbFileLoadAt(fname, &pixmap) != sizeof(struct TbColorTables))
    {
        compute_fade_tables(&pixmap,engine_palette,engine_palette);
        LbFileSaveAt(fname, &pixmap, sizeof(struct TbColorTables));
    }
    lbDisplay.FadeTable = pixmap.fade_tables;
    TbPixel cblack = 144;
    // Update black color
    for (i=0; i < 8192; i++)
    {
        if (pixmap.fade_tables[i] == 0) {
            pixmap.fade_tables[i] = cblack;
        }
    }
    return true;
}
Exemplo n.º 9
0
TbBool cumulative_screen_shot(void)
{
    //_DK_cumulative_screen_shot();return;
    static long frame_number=0;
    char fname[255];
    const char *fext;
    int w,h;
    switch (screenshot_format)
    {
    case 1:
        fext="raw";
        break;
    case 2:
        fext="bmp";
        break;
    default:
        ERRORLOG("Screenshot format incorrectly set.");
        return false;
    }
    long i;
    unsigned char *buf;
    long ssize;
    for (i=frame_number; i<10000; i++)
    {
        sprintf(fname, "scrshots/scr%05ld.%s", i, fext);
        if (!LbFileExists(fname)) break;
    }
    frame_number = i;
    if (frame_number >= 10000)
    {
        show_onscreen_msg(game.num_fps, "No free filename for screenshot.");
        return false;
    }
    sprintf(fname, "scrshots/scr%05ld.%s", frame_number, fext);

    w=MyScreenWidth/pixel_size;
    h=MyScreenHeight/pixel_size;

    buf = LbMemoryAlloc((w+3)*h+2048);
    if (buf == NULL)
    {
        ERRORLOG("Can't allocate buffer");
        return false;
    }
    LbPaletteGet(cap_palette);
    switch (screenshot_format)
    {
    case 1:
        ssize=prepare_hsi_screenshot(buf,cap_palette);
        break;
    case 2:
        ssize=prepare_bmp_screenshot(buf,cap_palette);
        break;
    default:
        ssize=0;
        break;
    }
    if (ssize>0)
        ssize = LbFileSaveAt(fname, buf, ssize);
    LbMemoryFree(buf);
    if (ssize>0)
        show_onscreen_msg(game.num_fps, "File \"%s\" saved.", fname);
    else
        show_onscreen_msg(game.num_fps, "Cannot save \"%s\".", fname);
    frame_number++;
    return (ssize>0);
}