X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Ftools.c;h=2ae872b475000ea3d2f0bddca41248f332f09f1c;hb=b33f14a8bdad5e3c9547c37b3854025daba761c7;hp=8b348d0b4e335d484b24296cce775b24bd26bbe0;hpb=91a095e154530ce26758d84bbfbb11726d1bb26b;p=rocksndiamonds.git diff --git a/src/tools.c b/src/tools.c index 8b348d0b..2ae872b4 100644 --- a/src/tools.c +++ b/src/tools.c @@ -205,16 +205,16 @@ void DrawMaskedBorder_Rect(int x, int y, int width, int height) void DrawMaskedBorder_FIELD() { - if (game_status >= GAME_MODE_TITLE && - game_status <= GAME_MODE_PLAYING && - border.draw_masked[game_status]) + if (global.border_status >= GAME_MODE_TITLE && + global.border_status <= GAME_MODE_PLAYING && + border.draw_masked[global.border_status]) DrawMaskedBorder_Rect(REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE); } void DrawMaskedBorder_DOOR_1() { if (border.draw_masked[GFX_SPECIAL_ARG_DOOR] && - (game_status != GAME_MODE_EDITOR || + (global.border_status != GAME_MODE_EDITOR || border.draw_masked[GFX_SPECIAL_ARG_EDITOR])) DrawMaskedBorder_Rect(DX, DY, DXSIZE, DYSIZE); } @@ -222,7 +222,7 @@ void DrawMaskedBorder_DOOR_1() void DrawMaskedBorder_DOOR_2() { if (border.draw_masked[GFX_SPECIAL_ARG_DOOR] && - game_status != GAME_MODE_EDITOR) + global.border_status != GAME_MODE_EDITOR) DrawMaskedBorder_Rect(VX, VY, VXSIZE, VYSIZE); } @@ -620,6 +620,29 @@ void FadeExt(int fade_mask, int fade_mode) void FadeIn(int fade_mask) { + global.border_status = game_status; + +#if 0 + global.fading_status = game_status; + + if (global.fading_type == TYPE_ENTER_MENU) + fading = menu.enter_menu; + else if (global.fading_type == TYPE_LEAVE_MENU) + fading = menu.leave_menu; + else if (global.fading_type == TYPE_ENTER_SCREEN) + fading = menu.enter_screen[global.fading_status]; + else if (global.fading_type == TYPE_LEAVE_SCREEN) + fading = menu.leave_screen[global.fading_status]; + + printf("::: FadeIn: %s [0x%08x] [%d]\n", + global.fading_type == TYPE_ENTER_MENU ? "enter_menu" : + global.fading_type == TYPE_LEAVE_MENU ? "leave_menu" : + global.fading_type == TYPE_ENTER_SCREEN ? "enter_screen" : + global.fading_type == TYPE_LEAVE_SCREEN ? "leave_screen" : "(?)", + global.fading_type, + global.fading_status); +#endif + #if 1 // printf("::: now fading in...\n"); @@ -641,6 +664,25 @@ void FadeIn(int fade_mask) void FadeOut(int fade_mask) { +#if 0 + if (global.fading_type == TYPE_ENTER_MENU) + fading = menu.enter_menu; + else if (global.fading_type == TYPE_LEAVE_MENU) + fading = menu.leave_menu; + else if (global.fading_type == TYPE_ENTER_SCREEN) + fading = menu.enter_screen[global.fading_status]; + else if (global.fading_type == TYPE_LEAVE_SCREEN) + fading = menu.leave_screen[global.fading_status]; + + printf("::: FadeOut: %s [0x%08x] [%d]\n", + global.fading_type == TYPE_ENTER_MENU ? "enter_menu" : + global.fading_type == TYPE_LEAVE_MENU ? "leave_menu" : + global.fading_type == TYPE_ENTER_SCREEN ? "enter_screen" : + global.fading_type == TYPE_LEAVE_SCREEN ? "leave_screen" : "(?)", + global.fading_type, + global.fading_status); +#endif + #if 1 // printf("::: fading.fade_mode == %d\n", fading.fade_mode); @@ -670,6 +712,32 @@ void FadeCrossSaveBackbuffer() BlitBitmap(backbuffer, bitmap_db_cross, 0, 0, WIN_XSIZE, WIN_YSIZE, 0, 0); } +#if 0 +void FadeSetEnterMenu() +{ + global.fading_type = TYPE_ENTER_MENU; +} + +void FadeSetLeaveMenu() +{ + global.fading_type = TYPE_LEAVE_MENU; +} + +void FadeSetEnterScreen() +{ + global.fading_type = TYPE_ENTER_SCREEN; +} + +void FadeSetLeaveScreen() +{ + // global.fading_type = TYPE_LEAVE_SCREEN; + + global.fading_type = (global.fading_type == TYPE_ENTER_SCREEN ? + TYPE_LEAVE_SCREEN : TYPE_LEAVE_MENU); +} + +#else + static void FadeSetLeaveNext(struct TitleFadingInfo fading_leave, boolean set) { static struct TitleFadingInfo fading_leave_stored; @@ -684,6 +752,10 @@ void FadeSetEnterMenu() { fading = menu.enter_menu; +#if 0 + printf("::: storing enter_menu\n"); +#endif + FadeSetLeaveNext(fading, TRUE); /* (keep same fade mode) */ } @@ -691,6 +763,10 @@ void FadeSetLeaveMenu() { fading = menu.leave_menu; +#if 0 + printf("::: storing leave_menu\n"); +#endif + FadeSetLeaveNext(fading, TRUE); /* (keep same fade mode) */ } @@ -698,14 +774,32 @@ void FadeSetEnterScreen() { fading = menu.enter_screen[game_status]; +#if 0 + printf("::: storing leave_screen[%d]\n", game_status); +#endif + +#if 0 + printf("::: - %d, %d / %d, %d\n", + menu.enter_screen[game_status].fade_mode, + menu.enter_screen[game_status].fade_delay, + menu.leave_screen[game_status].fade_mode, + menu.leave_screen[game_status].fade_delay); +#endif + FadeSetLeaveNext(menu.leave_screen[game_status], TRUE); /* store */ } void FadeSetLeaveScreen() { +#if 0 + printf("::: recalling last stored value\n"); +#endif + FadeSetLeaveNext(menu.leave_screen[game_status], FALSE); /* recall */ } +#endif + void FadeSetFromType(int type) { if (type & TYPE_ENTER_SCREEN) @@ -920,8 +1014,8 @@ inline int getGraphicAnimationFrame(int graphic, int sync_frame) sync_frame); } -void getSizedGraphicSource(int graphic, Bitmap **bitmap, int *x, int *y, - int tilesize_raw) +void getSizedGraphicSource(int graphic, int frame, int tilesize_raw, + Bitmap **bitmap, int *x, int *y) { struct { @@ -937,27 +1031,54 @@ void getSizedGraphicSource(int graphic, Bitmap **bitmap, int *x, int *y, { 0, 1, 2, 3 }, /* 16 x 16 */ { 0, 1, 0, 1 }, /* 32 x 32 */ }; + struct GraphicInfo *g = &graphic_info[graphic]; + Bitmap *src_bitmap = g->bitmap; int tilesize = MIN(MAX(1, tilesize_raw), TILESIZE); int offset_calc_pos = log_2(tilesize); - Bitmap *src_bitmap = graphic_info[graphic].bitmap; int width_mult = offset_calc[offset_calc_pos].width_mult; int width_div = offset_calc[offset_calc_pos].width_div; int height_mult = offset_calc[offset_calc_pos].height_mult; int height_div = offset_calc[offset_calc_pos].height_div; int startx = src_bitmap->width * width_mult / width_div; int starty = src_bitmap->height * height_mult / height_div; - int src_x = startx + graphic_info[graphic].src_x * tilesize / TILESIZE; - int src_y = starty + graphic_info[graphic].src_y * tilesize / TILESIZE; + int src_x = g->src_x * tilesize / TILESIZE; + int src_y = g->src_y * tilesize / TILESIZE; + int width = g->width * tilesize / TILESIZE; + int height = g->height * tilesize / TILESIZE; + int offset_x = g->offset_x * tilesize / TILESIZE; + int offset_y = g->offset_y * tilesize / TILESIZE; + + if (g->offset_y == 0) /* frames are ordered horizontally */ + { + int max_width = g->anim_frames_per_line * width; + int pos = (src_y / height) * max_width + src_x + frame * offset_x; + + src_x = pos % max_width; + src_y = src_y % height + pos / max_width * height; + } + else if (g->offset_x == 0) /* frames are ordered vertically */ + { + int max_height = g->anim_frames_per_line * height; + int pos = (src_x / width) * max_height + src_y + frame * offset_y; + + src_x = src_x % width + pos / max_height * width; + src_y = pos % max_height; + } + else /* frames are ordered diagonally */ + { + src_x = src_x + frame * offset_x; + src_y = src_y + frame * offset_y; + } *bitmap = src_bitmap; - *x = src_x; - *y = src_y; + *x = startx + src_x; + *y = starty + src_y; } void getMiniGraphicSource(int graphic, Bitmap **bitmap, int *x, int *y) { #if 1 - getSizedGraphicSource(graphic, bitmap, x, y, MINI_TILESIZE); + getSizedGraphicSource(graphic, 0, MINI_TILESIZE, bitmap, x, y); #else struct GraphicInfo *g = &graphic_info[graphic]; int mini_startx = 0; @@ -1060,19 +1181,20 @@ void DrawGraphicThruMaskExt(DrawBuffer *d, int dst_x, int dst_y, int graphic, BlitBitmapMasked(src_bitmap, d, src_x, src_y, TILEX, TILEY, dst_x, dst_y); } -void DrawSizedGraphic(int x, int y, int graphic, int tilesize) +void DrawSizedGraphic(int x, int y, int graphic, int frame, int tilesize) { DrawSizedGraphicExt(drawto, SX + x * tilesize, SY + y * tilesize, graphic, - tilesize); + frame, tilesize); MarkTileDirty(x / tilesize, y / tilesize); } -void DrawSizedGraphicExt(DrawBuffer *d, int x, int y, int graphic, int tilesize) +void DrawSizedGraphicExt(DrawBuffer *d, int x, int y, int graphic, int frame, + int tilesize) { Bitmap *src_bitmap; int src_x, src_y; - getSizedGraphicSource(graphic, &src_bitmap, &src_x, &src_y, tilesize); + getSizedGraphicSource(graphic, frame, tilesize, &src_bitmap, &src_x, &src_y); BlitBitmap(src_bitmap, d, src_x, src_y, tilesize, tilesize, x, y); } @@ -1894,7 +2016,7 @@ void DrawPreviewElement(int dst_x, int dst_y, int element, int tilesize) int src_x, src_y; int graphic = el2preimg(element); - getSizedGraphicSource(graphic, &src_bitmap, &src_x, &src_y, tilesize); + getSizedGraphicSource(graphic, 0, tilesize, &src_bitmap, &src_x, &src_y); BlitBitmap(src_bitmap, drawto, src_x, src_y, tilesize, tilesize, dst_x,dst_y); } @@ -3000,7 +3122,6 @@ boolean Request(char *text, unsigned int req_state) if (game_status == GAME_MODE_PLAYING && local_player->LevelSolved_GameEnd) { HandleGameActions(); - BackToFront(); } else { @@ -3010,6 +3131,8 @@ boolean Request(char *text, unsigned int req_state) Delay(10); } + BackToFront(); + #else DoAnimation(); @@ -5856,7 +5979,7 @@ int getBeltDirFromBeltSwitchElement(int element) return belt_move_dir[belt_dir_nr]; } -int getBeltElementFromBeltNrAndBeltDir(int belt_nr, int belt_dir) +int getBeltElementFromBeltNrAndBeltDirNr(int belt_nr, int belt_dir_nr) { static int belt_base_element[4] = { @@ -5865,12 +5988,18 @@ int getBeltElementFromBeltNrAndBeltDir(int belt_nr, int belt_dir) EL_CONVEYOR_BELT_3_LEFT, EL_CONVEYOR_BELT_4_LEFT }; - int belt_dir_nr = (belt_dir == MV_LEFT ? 0 : belt_dir == MV_RIGHT ? 2 : 1); return belt_base_element[belt_nr] + belt_dir_nr; } -int getBeltSwitchElementFromBeltNrAndBeltDir(int belt_nr, int belt_dir) +int getBeltElementFromBeltNrAndBeltDir(int belt_nr, int belt_dir) +{ + int belt_dir_nr = (belt_dir == MV_LEFT ? 0 : belt_dir == MV_RIGHT ? 2 : 1); + + return getBeltElementFromBeltNrAndBeltDirNr(belt_nr, belt_dir_nr); +} + +int getBeltSwitchElementFromBeltNrAndBeltDirNr(int belt_nr, int belt_dir_nr) { static int belt_base_element[4] = { @@ -5879,11 +6008,17 @@ int getBeltSwitchElementFromBeltNrAndBeltDir(int belt_nr, int belt_dir) EL_CONVEYOR_BELT_3_SWITCH_LEFT, EL_CONVEYOR_BELT_4_SWITCH_LEFT }; - int belt_dir_nr = (belt_dir == MV_LEFT ? 0 : belt_dir == MV_RIGHT ? 2 : 1); return belt_base_element[belt_nr] + belt_dir_nr; } +int getBeltSwitchElementFromBeltNrAndBeltDir(int belt_nr, int belt_dir) +{ + int belt_dir_nr = (belt_dir == MV_LEFT ? 0 : belt_dir == MV_RIGHT ? 2 : 1); + + return getBeltSwitchElementFromBeltNrAndBeltDirNr(belt_nr, belt_dir_nr); +} + int getNumActivePlayers_EM() { int num_players = 0;