From 7d553daf47483e8f05e083c0fad7aa8913345914 Mon Sep 17 00:00:00 2001 From: Yves Rizoud Date: Mon, 30 Mar 2009 00:41:45 +0000 Subject: [PATCH] Pixel ratio can be set in Resolution screen git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@705 416bcca6-2ee7-4201-b75f-2eb2f807beb1 --- buttons.c | 127 ++++++++++++++++++------------- engine.c | 4 +- engine.h | 2 +- graph.c | 223 ++++++++++++++++++++++++++++++------------------------ graph.h | 2 +- main.c | 5 +- windows.c | 2 +- 7 files changed, 207 insertions(+), 158 deletions(-) diff --git a/buttons.c b/buttons.c index 8df28a44..205efb10 100644 --- a/buttons.c +++ b/buttons.c @@ -1272,6 +1272,8 @@ void Check_mode_button(short x_pos, short y_pos, byte state) Menu_factor_X*9,Menu_factor_Y*3); } +/// Number of video modes to display in the resolution menu +#define MODELIST_LINES 10 void Display_modes_list(short list_start, short cursor_position) { @@ -1281,9 +1283,9 @@ void Display_modes_list(short list_start, short cursor_position) char str[29]; char *ratio; - for (current_mode=list_start,index=0; index<12 && current_mode < Nb_video_modes ; index++,current_mode++) + for (current_mode=list_start,index=0; index=6) + if (selected_mode>=MODELIST_LINES/2) { - if (selected_mode>3; + temp=(((Mouse_Y-Window_pos_Y)/Menu_factor_Y)-86)>>3; if (temp11) - list_start-=11; + if (list_start>(MODELIST_LINES-1)) + list_start-=(MODELIST_LINES-1); else list_start=0; } @@ -1566,16 +1584,16 @@ void Button_Resolution(void) Key=0; break; case SDLK_PAGEDOWN : // PageDown - if (Nb_video_modes<12) + if (Nb_video_modes Screen_height/200) - factor=Screen_height/200; - else - factor=Screen_width/320; + // Taille des menus + if (Screen_width/320 > Screen_height/200) + factor=Screen_height/200; + else + factor=Screen_width/320; - switch (Config.Ratio) + switch (Config.Ratio) + { + case 1: // adapter tout + Menu_factor_X=factor; + Menu_factor_Y=factor; + break; + case 2: // adapter légèrement + Menu_factor_X=factor-1; + if (Menu_factor_X<1) Menu_factor_X=1; + Menu_factor_Y=factor-1; + if (Menu_factor_Y<1) Menu_factor_Y=1; + break; + default: // ne pas adapter + Menu_factor_X=1; + Menu_factor_Y=1; + } + if (Pixel_height>Pixel_width && Screen_width>=Menu_factor_X*2*320) + Menu_factor_X*=2; + else if (Pixel_width>Pixel_height && Screen_height>=Menu_factor_Y*2*200) + Menu_factor_Y*=2; + + if (Horizontal_line_buffer) + free(Horizontal_line_buffer); + Horizontal_line_buffer=(byte *)malloc(Pixel_width*((Screen_width>Main_image_width)?Screen_width:Main_image_width)); + + Set_palette(Main_palette); + + Current_resolution=0; + if (fullscreen) + { + for (index=1; indexPixel_width && Screen_width>=Menu_factor_X*2*320) - Menu_factor_X*=2; - else if (Pixel_width>Pixel_height && Screen_height>=Menu_factor_Y*2*200) - Menu_factor_Y*=2; - - if (Horizontal_line_buffer) - free(Horizontal_line_buffer); - Horizontal_line_buffer=(byte *)malloc(Pixel_width*((Screen_width>Main_image_width)?Screen_width:Main_image_width)); - - Set_palette(Main_palette); - - Current_resolution=0; - if (fullscreen) - { - for (index=1; index>=Mouse_fix_factor_X; - y_sensitivity>>=Mouse_fix_factor_Y; - Mouse_sensitivity(x_sensitivity?x_sensitivity:1,y_sensitivity?y_sensitivity:1); - - Spare_offset_X=0; // | Il faut penser à éviter les incohérences - Spare_offset_Y=0; // |- de décalage du brouillon par rapport à - Spare_magnifier_mode=0; // | la résolution. } + + Change_palette_cells(); + + Menu_Y = Screen_height; + if (Menu_is_visible) + Menu_Y -= MENU_HEIGHT * Menu_factor_Y; + Menu_status_Y = Screen_height-(Menu_factor_Y<<3); + + x_sensitivity = Config.Mouse_sensitivity_index_x; + y_sensitivity = Config.Mouse_sensitivity_index_y; + x_sensitivity>>=Mouse_fix_factor_X; + y_sensitivity>>=Mouse_fix_factor_Y; + Mouse_sensitivity(x_sensitivity?x_sensitivity:1,y_sensitivity?y_sensitivity:1); + + Spare_offset_X=0; // | Il faut penser à éviter les incohérences + Spare_offset_Y=0; // |- de décalage du brouillon par rapport à + Spare_magnifier_mode=0; // | la résolution. + if (Main_magnifier_mode) { Pixel_preview=Pixel_preview_magnifier; diff --git a/graph.h b/graph.h index c4be6798..b52f0105 100644 --- a/graph.h +++ b/graph.h @@ -26,7 +26,7 @@ void Shade_list_to_lookup_tables(word * list, short step, byte mode, byte * tabl void Transform_point(short x, short y, float cos_a, float sin_a, short * rx, short * ry); -int Init_mode_video(int width, int height, int fullscreen); +int Init_mode_video(int width, int height, int fullscreen,int pixel_ratio); byte No_effect(word x,word y,byte color); byte Effect_shade(word x,word y,byte color); diff --git a/main.c b/main.c index ed3c140d..ac6ee003 100644 --- a/main.c +++ b/main.c @@ -549,12 +549,13 @@ int Init_program(int argc,char * argv[]) Analyze_command_line(argc,argv); starting_videomode=Current_resolution; Horizontal_line_buffer=NULL; - Current_resolution=-1; // On n'était pas dans un mode graphique + Screen_width=Screen_height=Current_resolution=0; Init_mode_video( Video_mode[starting_videomode].Width, Video_mode[starting_videomode].Height, - Video_mode[starting_videomode].Fullscreen); + Video_mode[starting_videomode].Fullscreen, + Pixel_ratio); Main_image_width=Screen_width/Pixel_width; Main_image_height=Screen_height/Pixel_height; diff --git a/windows.c b/windows.c index a4a5901f..abe34d76 100644 --- a/windows.c +++ b/windows.c @@ -244,7 +244,7 @@ void Frame_menu_color(byte color) ((index)&1)?MC_White:MC_Black); // Right line for (index=1; index