X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fmisc.c;h=0d19ff9c16eadf9844d3ada6371c35e685cb3748;hb=22f539028eb272b70d339e1f37552a2a89f37dd6;hp=1ea2a2edb823e909267815575b6eb3121ddb6dba;hpb=8e8a0eddc70d1581ecbd18ff9bad3db3485956b7;p=rocksndiamonds.git diff --git a/src/libgame/misc.c b/src/libgame/misc.c index 1ea2a2ed..0d19ff9c 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -1923,6 +1923,25 @@ struct ScreenModeInfo *get_screen_mode_from_string(char *screen_mode_string) return &screen_mode; } +void get_aspect_ratio_from_screen_mode(struct ScreenModeInfo *screen_mode, + int *x, int *y) +{ + float aspect_ratio = (float)screen_mode->width / (float)screen_mode->height; + float aspect_ratio_new; + int i = 1; + + do + { + *x = i * aspect_ratio; + *y = i; + + aspect_ratio_new = (float)*x / (float)*y; + + i++; + } + while (aspect_ratio_new != aspect_ratio && *x < screen_mode->width); +} + static void FreeCustomArtworkList(struct ArtworkListInfo *, struct ListNodeInfo ***, int *);