X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Finit.c;h=f85660d1e6a5898b67b8ba6d3f3b756125b29f31;hp=4808f114f691548193de8e85fb10d747bf0b30ad;hb=adab6bbf3e2b3b78b7b51f18379e6db399b62b5c;hpb=4dad971280a07058d01449d5e6db2b036470015d diff --git a/src/init.c b/src/init.c index 4808f114..f85660d1 100644 --- a/src/init.c +++ b/src/init.c @@ -102,6 +102,11 @@ void DrawInitAnim() if (!DelayReached(&action_delay, action_delay_value)) return; + if (init_last.busy.x == -1) + init_last.busy.x = WIN_XSIZE / 2; + if (init_last.busy.y == -1) + init_last.busy.y = WIN_YSIZE / 2; + x = ALIGNED_TEXT_XPOS(&init_last.busy); y = ALIGNED_TEXT_YPOS(&init_last.busy); @@ -151,7 +156,7 @@ void InitGadgets() gadgets_initialized = TRUE; } -inline void InitElementSmallImagesScaledUp(int graphic) +inline static void InitElementSmallImagesScaledUp(int graphic) { struct GraphicInfo *g = &graphic_info[graphic]; @@ -221,6 +226,28 @@ void InitBitmapPointers() graphic_info[i].bitmap = graphic_info[i].bitmaps[IMG_BITMAP_STANDARD]; } +static void InitGlobalAnimImages() +{ + int i, j, k; + + for (i = 0; i < NUM_GLOBAL_ANIMS; i++) + { + for (j = 0; j < NUM_GLOBAL_ANIM_PARTS_ALL; j++) + { + for (k = 0; k < NUM_SPECIAL_GFX_ARGS; k++) + { + int graphic = global_anim_info[i].graphic[j][k]; + + if (graphic == IMG_UNDEFINED) + continue; + + // create textures from images for fast GPU blitting, if possible + CreateImageTextures(graphic); + } + } + } +} + #if 1 /* !!! FIX THIS (CHANGE TO USING NORMAL ELEMENT GRAPHIC DEFINITIONS) !!! */ void SetBitmaps_EM(Bitmap **em_bitmap) @@ -500,6 +527,65 @@ void InitFontGraphicInfo() getFontBitmapID, getFontFromToken); } +void InitGlobalAnimGraphicInfo() +{ + struct PropertyMapping *property_mapping = getImageListPropertyMapping(); + int num_property_mappings = getImageListPropertyMappingSize(); + int i, j, k; + + if (graphic_info == NULL) /* still at startup phase */ + return; + + /* always start with reliable default values (no global animations) */ + for (i = 0; i < NUM_GLOBAL_ANIM_TOKENS; i++) + for (j = 0; j < NUM_GLOBAL_ANIM_PARTS_ALL; j++) + for (k = 0; k < NUM_SPECIAL_GFX_ARGS; k++) + global_anim_info[i].graphic[j][k] = IMG_UNDEFINED; + + /* initialize global animation definitions from static configuration */ + for (i = 0; i < NUM_GLOBAL_ANIM_TOKENS; i++) + { + int j = GLOBAL_ANIM_ID_PART_BASE; + int k = GFX_SPECIAL_ARG_DEFAULT; + + global_anim_info[i].graphic[j][k] = IMG_GLOBAL_ANIM_1_GFX + i; + } + + /* initialize global animation definitions from dynamic configuration */ + for (i = 0; i < num_property_mappings; i++) + { + int anim_nr = property_mapping[i].base_index - MAX_NUM_ELEMENTS - NUM_FONTS; + int part_nr = property_mapping[i].ext1_index - ACTION_PART_1; + int special = property_mapping[i].ext3_index; + int graphic = property_mapping[i].artwork_index; + + if (anim_nr < 0 || anim_nr >= NUM_GLOBAL_ANIM_TOKENS) + continue; + + /* set animation part to base part, if not specified */ + if (!IS_GLOBAL_ANIM_PART(part_nr)) + part_nr = GLOBAL_ANIM_ID_PART_BASE; + + /* set animation screen to default, if not specified */ + if (!IS_SPECIAL_GFX_ARG(special)) + special = GFX_SPECIAL_ARG_DEFAULT; + + global_anim_info[anim_nr].graphic[part_nr][special] = graphic; + } + +#if 0 + printf("::: InitGlobalAnimGraphicInfo\n"); + + for (i = 0; i < NUM_GLOBAL_ANIMS; i++) + for (j = 0; j < NUM_GLOBAL_ANIM_PARTS_ALL; j++) + for (k = 0; k < NUM_SPECIAL_GFX_ARGS; k++) + if (global_anim_info[i].graphic[j][k] != IMG_UNDEFINED && + graphic_info[global_anim_info[i].graphic[j][k]].bitmap != NULL) + printf("::: - anim %d, part %d, mode %d => %d\n", + i, j, k, global_anim_info[i].graphic[j][k]); +#endif +} + void InitElementGraphicInfo() { struct PropertyMapping *property_mapping = getImageListPropertyMapping(); @@ -1071,11 +1157,9 @@ static void set_graphic_parameters_ext(int graphic, int *parameter, g->tile_size = TILESIZE; /* standard tile size */ #endif -#if 0 - // CHECK: when setting tile size, should this set width and height? + // when setting tile size, also set width and height accordingly g->width = g->tile_size; g->height = g->tile_size; -#endif } if (g->use_image_size) @@ -1255,8 +1339,13 @@ static void set_graphic_parameters_ext(int graphic, int *parameter, g->post_delay_random = parameter[GFX_ARG_POST_DELAY_RANDOM]; /* this is only used for toon animations */ - g->step_offset = parameter[GFX_ARG_STEP_OFFSET]; - g->step_delay = parameter[GFX_ARG_STEP_DELAY]; + g->step_offset = parameter[GFX_ARG_STEP_OFFSET]; + g->step_xoffset = parameter[GFX_ARG_STEP_XOFFSET]; + g->step_yoffset = parameter[GFX_ARG_STEP_YOFFSET]; + g->step_frames = parameter[GFX_ARG_STEP_FRAMES]; + g->step_delay = parameter[GFX_ARG_STEP_DELAY]; + g->direction = parameter[GFX_ARG_DIRECTION]; + g->position = parameter[GFX_ARG_POSITION]; /* this is only used for drawing font characters */ g->draw_xoffset = parameter[GFX_ARG_DRAW_XOFFSET]; @@ -1369,6 +1458,10 @@ static void InitGraphicInfo() static int full_size_graphics[] = { IMG_GLOBAL_BORDER, + IMG_GLOBAL_BORDER_MAIN, + IMG_GLOBAL_BORDER_SCORES, + IMG_GLOBAL_BORDER_EDITOR, + IMG_GLOBAL_BORDER_PLAYING, IMG_GLOBAL_DOOR, IMG_BACKGROUND_ENVELOPE_1, @@ -1929,6 +2022,10 @@ static void ReinitializeGraphics() print_timestamp_time("InitBitmapPointers"); InitFontGraphicInfo(); /* initialize text drawing functions */ print_timestamp_time("InitFontGraphicInfo"); + InitGlobalAnimGraphicInfo(); /* initialize global animation config */ + print_timestamp_time("InitGlobalAnimGraphicInfo"); + InitGlobalAnimImages(); /* initialize global animation images */ + print_timestamp_time("InitGlobalAnimImages"); InitGraphicInfo_EM(); /* graphic mapping for EM engine */ print_timestamp_time("InitGraphicInfo_EM"); @@ -4549,8 +4646,6 @@ static void InitGlobal() global.create_images_dir = NULL; global.frames_per_second = 0; - global.fps_slowdown = FALSE; - global.fps_slowdown_factor = 1; global.border_status = GAME_MODE_MAIN; @@ -4676,10 +4771,16 @@ void Execute_Command(char *command) exit(0); } - else if (strPrefix(command, "autoplay ")) + else if (strPrefix(command, "autotest ") || + strPrefix(command, "autoplay ") || + strPrefix(command, "autoffwd ")) { char *str_ptr = getStringCopy(&command[9]); /* read command parameters */ + global.autoplay_mode = (strPrefix(command, "autotest") ? AUTOPLAY_TEST : + strPrefix(command, "autoplay") ? AUTOPLAY_PLAY : + strPrefix(command, "autoffwd") ? AUTOPLAY_FFWD : 0); + while (*str_ptr != '\0') /* continue parsing string */ { /* cut leading whitespace from string, replace it by string terminator */ @@ -4890,7 +4991,9 @@ static char *get_level_id_suffix(int id_nr) static void InitArtworkConfig() { - static char *image_id_prefix[MAX_NUM_ELEMENTS + NUM_FONTS + 1]; + static char *image_id_prefix[MAX_NUM_ELEMENTS + + NUM_FONTS + + NUM_GLOBAL_ANIM_TOKENS + 1]; static char *sound_id_prefix[2 * MAX_NUM_ELEMENTS + 1]; static char *music_id_prefix[NUM_MUSIC_PREFIXES + 1]; static char *action_id_suffix[NUM_ACTIONS + 1]; @@ -4951,7 +5054,10 @@ static void InitArtworkConfig() image_id_prefix[i] = element_info[i].token_name; for (i = 0; i < NUM_FONTS; i++) image_id_prefix[MAX_NUM_ELEMENTS + i] = font_info[i].token_name; - image_id_prefix[MAX_NUM_ELEMENTS + NUM_FONTS] = NULL; + for (i = 0; i < NUM_GLOBAL_ANIM_TOKENS; i++) + image_id_prefix[MAX_NUM_ELEMENTS + NUM_FONTS + i] = + global_anim_info[i].token_name; + image_id_prefix[MAX_NUM_ELEMENTS + NUM_FONTS + NUM_GLOBAL_ANIM_TOKENS] = NULL; for (i = 0; i < MAX_NUM_ELEMENTS; i++) sound_id_prefix[i] = element_info[i].token_name; @@ -5000,9 +5106,21 @@ static void InitMixer() void InitGfxBuffers() { + static int win_xsize_last = -1; + static int win_ysize_last = -1; + /* create additional image buffers for double-buffering and cross-fading */ - ReCreateBitmap(&bitmap_db_store, WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH); - ReCreateBitmap(&bitmap_db_cross, WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH); + + if (WIN_XSIZE != win_xsize_last || WIN_YSIZE != win_ysize_last) + { + /* may contain content for cross-fading -- only re-create if changed */ + ReCreateBitmap(&bitmap_db_store, WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH); + ReCreateBitmap(&bitmap_db_cross, WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH); + + win_xsize_last = WIN_XSIZE; + win_ysize_last = WIN_YSIZE; + } + ReCreateBitmap(&bitmap_db_field, FXSIZE, FYSIZE, DEFAULT_DEPTH); ReCreateBitmap(&bitmap_db_panel, DXSIZE, DYSIZE, DEFAULT_DEPTH); ReCreateBitmap(&bitmap_db_door_1, 3 * DXSIZE, DYSIZE, DEFAULT_DEPTH); @@ -5182,33 +5300,21 @@ void InitGfx() init.busy.height = anim_initial.height; InitMenuDesignSettings_Static(); + InitGfxDrawBusyAnimFunction(DrawInitAnim); + InitGfxDrawGlobalAnimFunction(DrawGlobalAnim); /* use copy of busy animation to prevent change while reloading artwork */ init_last = init; } -void RedrawGlobalBorder() -{ - BlitBitmap(graphic_info[IMG_GLOBAL_BORDER].bitmap, backbuffer, - 0, 0, WIN_XSIZE, WIN_YSIZE, 0, 0); - - redraw_mask = REDRAW_ALL; -} - void InitGfxBackground() { - int x, y; - fieldbuffer = bitmap_db_field; SetDrawtoField(DRAW_BACKBUFFER); ClearRectangle(backbuffer, 0, 0, WIN_XSIZE, WIN_YSIZE); - for (x = 0; x < MAX_BUF_XSIZE; x++) - for (y = 0; y < MAX_BUF_YSIZE; y++) - redraw[x][y] = 0; - redraw_tiles = 0; redraw_mask = REDRAW_ALL; } @@ -5217,6 +5323,15 @@ static void InitLevelInfo() LoadLevelInfo(); /* global level info */ LoadLevelSetup_LastSeries(); /* last played series info */ LoadLevelSetup_SeriesInfo(); /* last played level info */ + + if (global.autoplay_leveldir && + global.autoplay_mode != AUTOPLAY_TEST) + { + leveldir_current = getTreeInfoFromIdentifier(leveldir_first, + global.autoplay_leveldir); + if (leveldir_current == NULL) + leveldir_current = getFirstValidTreeInfoEntry(leveldir_first); + } } static void InitLevelArtworkInfo()