Pixel ratio can be set in Resolution screen

git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@705 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
Yves Rizoud 2009-03-30 00:41:45 +00:00
parent 8ff9028eab
commit 7d553daf47
7 changed files with 207 additions and 158 deletions

127
buttons.c
View File

@ -1272,6 +1272,8 @@ void Check_mode_button(short x_pos, short y_pos, byte state)
Menu_factor_X*9,Menu_factor_Y*3); 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) 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 str[29];
char *ratio; 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<MODELIST_LINES && current_mode < Nb_video_modes ; index++,current_mode++)
{ {
y_pos=70+(index<<3); y_pos=86+(index<<3);
Check_mode_button(19,y_pos+2,Video_mode[current_mode].State); Check_mode_button(19,y_pos+2,Video_mode[current_mode].State);
if (cursor_position!=index) if (cursor_position!=index)
@ -1352,60 +1354,63 @@ void Scroll_list_of_modes(short list_start, short cursor_position, int * selecte
Display_cursor(); Display_cursor();
} }
void Button_Resolution(void) void Button_Resolution(void)
{ {
short clicked_button; short clicked_button;
int selected_mode; int selected_mode;
word chosen_width; word chosen_width;
word chosen_height; word chosen_height;
byte chosen_pixel;
short list_start; short list_start;
short cursor_position; short cursor_position;
short temp; short temp;
char str[5]; char str[5];
T_Special_button * input_width_button, * input_button_height; T_Special_button * input_width_button, * input_button_height;
T_Dropdown_button * pixel_button;
static const char *pixel_ratio_labels[] ={
"Normal (1x1)",
"Wide (2x1)",
"Tall (1x2)",
"Double (2x2)"};
Open_window(299,190,"Picture & screen sizes"); Open_window(299,190,"Picture & screen sizes");
Window_display_frame ( 8,17,195, 33);
Window_display_frame ( 8,56,283,126);
Window_display_frame_in(37,68,228,100);
Block(Window_pos_X+Menu_factor_X*38,Window_pos_Y+Menu_factor_Y*69,
Menu_factor_X*226,Menu_factor_Y*98,MC_Black);
Print_in_window( 12, 21,"Picture size:" ,MC_Dark,MC_Light); Print_in_window( 12, 21,"Picture size:" ,MC_Dark,MC_Light);
Print_in_window( 12, 37,"Width:" ,MC_Dark,MC_Light); Window_display_frame ( 8,17,195, 33);
Print_in_window(108, 37,"Height:" ,MC_Dark,MC_Light);
Print_in_window( 16, 60,"OK" ,MC_Dark,MC_Light);
Print_in_window( 55, 60,"X Y" ,MC_Dark,MC_Light);
Print_in_window(120, 60,"Win / Full" ,MC_Dark,MC_Light);
Print_in_window(219, 60,"Ratio" ,MC_Dark,MC_Light);
Print_in_window( 30,170,"\03" ,MC_Dark,MC_Light);
Print_in_window( 62,170,"OK" ,MC_Dark,MC_Light);
Print_in_window(102,170,"Imperfect" ,MC_Dark,MC_Light);
Print_in_window(196,170,"Unsupported" ,MC_Dark,MC_Light);
Window_set_normal_button(223, 18,67,14,"OK" ,0,1,SDLK_RETURN); // 1 Window_set_normal_button(223, 18,67,14,"OK" ,0,1,SDLK_RETURN); // 1
Window_set_normal_button(223, 35,67,14,"Cancel" ,0,1,KEY_ESC); // 2 Window_set_normal_button(223, 35,67,14,"Cancel" ,0,1,KEY_ESC); // 2
Print_in_window( 12, 37,"Width:" ,MC_Dark,MC_Light);
input_width_button=Window_set_input_button( 60, 35,4); // 3 input_width_button=Window_set_input_button( 60, 35,4); // 3
Print_in_window(108, 37,"Height:" ,MC_Dark,MC_Light);
input_button_height=Window_set_input_button(164, 35,4); // 4 input_button_height=Window_set_input_button(164, 35,4); // 4
Window_set_special_button(38,70,225,96); // 5 Window_display_frame ( 8,72,283,110);
Window_display_frame_in (37,84,228,84);
Window_rectangle (38,85,226,82,MC_Black);
Print_in_window( 16, 76,"OK" ,MC_Dark,MC_Light);
Print_in_window( 55, 76,"X Y" ,MC_Dark,MC_Light);
Print_in_window(120, 76,"Win / Full" ,MC_Dark,MC_Light);
Print_in_window(219, 76,"Ratio" ,MC_Dark,MC_Light);
Print_in_window( 30,170,"\03" ,MC_Dark,MC_Light);
Print_in_window( 62,170,"OK" ,MC_Dark,MC_Light);
Print_in_window(102,170,"Imperfect" ,MC_Dark,MC_Light);
Print_in_window(196,170,"Unsupported" ,MC_Dark,MC_Light);
Window_set_special_button(38,86,225,80); // 5
selected_mode=Current_resolution; selected_mode=Current_resolution;
if (selected_mode>=MODELIST_LINES/2)
if (selected_mode>=6)
{ {
if (selected_mode<Nb_video_modes-6) if (selected_mode<Nb_video_modes-MODELIST_LINES/2)
{ {
list_start=selected_mode-5; list_start=selected_mode-(MODELIST_LINES/2-1);
cursor_position=5; cursor_position=(MODELIST_LINES/2-1);
} }
else else
{ {
list_start=Nb_video_modes-12; list_start=Nb_video_modes-MODELIST_LINES;
cursor_position=selected_mode-list_start; cursor_position=selected_mode-list_start;
} }
} }
@ -1414,13 +1419,21 @@ void Button_Resolution(void)
list_start=0; list_start=0;
cursor_position=selected_mode; cursor_position=selected_mode;
} }
Window_set_scroller_button(271,85,81,Nb_video_modes,MODELIST_LINES,list_start); // 6
Window_set_scroller_button(271,69,97,Nb_video_modes,12,list_start); // 6 chosen_pixel=Pixel_ratio;
Print_in_window( 12, 57,"Pixel size:" ,MC_Dark,MC_Light);
pixel_button=Window_set_dropdown_button(108,55,14*8,11,14*8,pixel_ratio_labels[Pixel_ratio],1,0,1,LEFT_SIDE|RIGHT_SIDE); // 7
Window_dropdown_add_item(pixel_button,PIXEL_SIMPLE,pixel_ratio_labels[PIXEL_SIMPLE]);
Window_dropdown_add_item(pixel_button,PIXEL_WIDE,pixel_ratio_labels[PIXEL_WIDE]);
Window_dropdown_add_item(pixel_button,PIXEL_TALL,pixel_ratio_labels[PIXEL_TALL]);
Window_dropdown_add_item(pixel_button,PIXEL_DOUBLE,pixel_ratio_labels[PIXEL_DOUBLE]);
// Les 12 petits boutons indiquant l'état des modes // 10 little buttons for the state of each visible mode
for (temp=0; temp<12 && temp < Nb_video_modes; temp++) for (temp=0; temp<MODELIST_LINES && temp < Nb_video_modes; temp++)
Window_set_normal_button(17,70+(temp<<3),13,7,"",0,1,SDLK_LAST);// 7..18 Window_set_normal_button(17,86+(temp<<3),13,7,"",0,1,SDLK_LAST);// 8..17
// Dummy buttons as explainations of colors
Window_draw_normal_bouton( 16,170,13,7,"",0,0); Window_draw_normal_bouton( 16,170,13,7,"",0,0);
Check_mode_button( 18,172,0); Check_mode_button( 18,172,0);
Window_draw_normal_bouton( 48,170,13,7,"",0,0); Window_draw_normal_bouton( 48,170,13,7,"",0,0);
@ -1429,6 +1442,7 @@ void Button_Resolution(void)
Check_mode_button( 90,172,2); Check_mode_button( 90,172,2);
Window_draw_normal_bouton(182,170,13,7,"",0,0); Window_draw_normal_bouton(182,170,13,7,"",0,0);
Check_mode_button(184,172,3); Check_mode_button(184,172,3);
chosen_width=Main_image_width; chosen_width=Main_image_width;
Num2str(chosen_width,str,4); Num2str(chosen_width,str,4);
@ -1481,7 +1495,7 @@ void Button_Resolution(void)
break; break;
case 5: // Liste des modes case 5: // Liste des modes
temp=(((Mouse_Y-Window_pos_Y)/Menu_factor_Y)-70)>>3; temp=(((Mouse_Y-Window_pos_Y)/Menu_factor_Y)-86)>>3;
if (temp<Nb_video_modes && ((Mouse_K==2) || (temp!=cursor_position))) if (temp<Nb_video_modes && ((Mouse_K==2) || (temp!=cursor_position)))
{ {
Hide_cursor(); Hide_cursor();
@ -1514,8 +1528,12 @@ void Button_Resolution(void)
Display_modes_list(list_start,cursor_position); Display_modes_list(list_start,cursor_position);
break; break;
case 7: // Pixel size
chosen_pixel=Window_attribute2;
break;
default: // Boutons de tag des états des modes default: // Boutons de tag des états des modes
temp=list_start+clicked_button-7; temp=list_start+clicked_button-8;
if (temp && // On n'a pas le droit de cocher le mode fenêtré if (temp && // On n'a pas le droit de cocher le mode fenêtré
!(Video_mode[temp].State & 128)) // Ni ceux non détectés par SDL !(Video_mode[temp].State & 128)) // Ni ceux non détectés par SDL
{ {
@ -1525,7 +1543,7 @@ void Button_Resolution(void)
Video_mode[temp].State=((Video_mode[temp].State&0x7F)+3)&3; Video_mode[temp].State=((Video_mode[temp].State&0x7F)+3)&3;
Hide_cursor(); Hide_cursor();
Check_mode_button(19,16+(clicked_button<<3),Video_mode[temp].State); //Check_mode_button(19,16+(clicked_button<<3),Video_mode[temp].State);
Display_modes_list(list_start,cursor_position); Display_modes_list(list_start,cursor_position);
Display_cursor(); Display_cursor();
} }
@ -1544,10 +1562,10 @@ void Button_Resolution(void)
Key=0; Key=0;
break; break;
case SDLK_DOWN : // Bas case SDLK_DOWN : // Bas
if (cursor_position<11 && cursor_position<(Nb_video_modes-1)) if (cursor_position<(MODELIST_LINES-1) && cursor_position<(Nb_video_modes-1))
cursor_position++; cursor_position++;
else else
if (list_start<Nb_video_modes-12) if (list_start<Nb_video_modes-MODELIST_LINES)
list_start++; list_start++;
Scroll_list_of_modes(list_start,cursor_position,&selected_mode); Scroll_list_of_modes(list_start,cursor_position,&selected_mode);
Key=0; Key=0;
@ -1557,8 +1575,8 @@ void Button_Resolution(void)
cursor_position=0; cursor_position=0;
else else
{ {
if (list_start>11) if (list_start>(MODELIST_LINES-1))
list_start-=11; list_start-=(MODELIST_LINES-1);
else else
list_start=0; list_start=0;
} }
@ -1566,16 +1584,16 @@ void Button_Resolution(void)
Key=0; Key=0;
break; break;
case SDLK_PAGEDOWN : // PageDown case SDLK_PAGEDOWN : // PageDown
if (Nb_video_modes<12) if (Nb_video_modes<MODELIST_LINES)
cursor_position=Nb_video_modes-1; cursor_position=Nb_video_modes-1;
else if (cursor_position<11) else if (cursor_position<(MODELIST_LINES-1))
cursor_position=11; cursor_position=(MODELIST_LINES-1);
else else
{ {
if (list_start<Nb_video_modes-23) if (list_start<Nb_video_modes-(MODELIST_LINES*2-1))
list_start+=11; list_start+=(MODELIST_LINES-1);
else else
list_start=Nb_video_modes-12; list_start=Nb_video_modes-MODELIST_LINES;
} }
Scroll_list_of_modes(list_start,cursor_position,&selected_mode); Scroll_list_of_modes(list_start,cursor_position,&selected_mode);
Key=0; Key=0;
@ -1587,12 +1605,12 @@ void Button_Resolution(void)
Key=0; Key=0;
break; break;
case SDLK_END : // End case SDLK_END : // End
if (Nb_video_modes<12) if (Nb_video_modes<MODELIST_LINES)
cursor_position=Nb_video_modes-1; cursor_position=Nb_video_modes-1;
else else
{ {
list_start=Nb_video_modes-12; list_start=Nb_video_modes-MODELIST_LINES;
cursor_position=11; cursor_position=(MODELIST_LINES-1);
} }
Scroll_list_of_modes(list_start,cursor_position,&selected_mode); Scroll_list_of_modes(list_start,cursor_position,&selected_mode);
Key=0; Key=0;
@ -1619,18 +1637,21 @@ void Button_Resolution(void)
if ( (chosen_width!=Main_image_width) if ( (chosen_width!=Main_image_width)
|| (chosen_height!=Main_image_height) ) || (chosen_height!=Main_image_height) )
Resize_image(chosen_width,chosen_height); Resize_image(chosen_width,chosen_height);
if ((Video_mode[selected_mode].State & 3) == 3 || if ((Video_mode[selected_mode].State & 3) == 3 ||
Init_mode_video( Init_mode_video(
Video_mode[selected_mode].Width, Video_mode[selected_mode].Width,
Video_mode[selected_mode].Height, Video_mode[selected_mode].Height,
Video_mode[selected_mode].Fullscreen)) Video_mode[selected_mode].Fullscreen,
chosen_pixel))
{ {
Error(0); // On signale à l'utilisateur que c'est un mode invalide Error(0); // On signale à l'utilisateur que c'est un mode invalide
Pixel_ratio=PIXEL_SIMPLE;
Init_mode_video( Init_mode_video(
Video_mode[Current_resolution].Width, Video_mode[Current_resolution].Width,
Video_mode[Current_resolution].Height, Video_mode[Current_resolution].Height,
Video_mode[Current_resolution].Fullscreen); Video_mode[Current_resolution].Fullscreen,
Pixel_ratio);
} }
Display_menu(); Display_menu();
@ -1650,7 +1671,7 @@ void Button_Safety_resolution(void)
Hide_cursor(); Hide_cursor();
Unselect_bouton(BUTTON_MAGNIFIER); Unselect_bouton(BUTTON_MAGNIFIER);
Init_mode_video(640, 400, 0); Init_mode_video(640, 400, 0,PIXEL_SIMPLE);
Current_resolution=0; Current_resolution=0;
Video_mode[0].Width = Screen_width*Pixel_width; Video_mode[0].Width = Screen_width*Pixel_width;
Video_mode[0].Height = Screen_height*Pixel_height; Video_mode[0].Height = Screen_height*Pixel_height;
@ -2485,7 +2506,8 @@ void Load_picture(byte image)
Init_mode_video( Init_mode_video(
Video_mode[new_mode].Width, Video_mode[new_mode].Width,
Video_mode[new_mode].Height, Video_mode[new_mode].Height,
Video_mode[new_mode].Fullscreen); Video_mode[new_mode].Fullscreen,
Pixel_ratio);
Display_menu(); Display_menu();
} }
else else
@ -2576,7 +2598,8 @@ void Button_Reload(void)
Init_mode_video( Init_mode_video(
Video_mode[new_mode].Width, Video_mode[new_mode].Width,
Video_mode[new_mode].Height, Video_mode[new_mode].Height,
Video_mode[new_mode].Fullscreen); Video_mode[new_mode].Fullscreen,
Pixel_ratio);
Display_menu(); Display_menu();
} }
else else

View File

@ -523,7 +523,7 @@ void Main_handler(void)
if (Resize_width || Resize_height) if (Resize_width || Resize_height)
{ {
Hide_cursor(); Hide_cursor();
Init_mode_video(Resize_width, Resize_height, 0); Init_mode_video(Resize_width, Resize_height, 0, Pixel_ratio);
Video_mode[0].Width = Screen_width*Pixel_width; Video_mode[0].Width = Screen_width*Pixel_width;
Video_mode[0].Height = Screen_height*Pixel_height; Video_mode[0].Height = Screen_height*Pixel_height;
// Remise à zero des variables indiquant le Redimensionnement demandé // Remise à zero des variables indiquant le Redimensionnement demandé
@ -1575,7 +1575,7 @@ T_Special_button * Window_set_input_button(word x_pos,word y_pos,word width_in_c
return temp; return temp;
} }
T_Dropdown_button * Window_set_dropdown_button(word x_pos,word y_pos,word width,word height,word dropdown_width,char *label,byte display_choice,byte display_centered,byte display_arrow,byte active_button) T_Dropdown_button * Window_set_dropdown_button(word x_pos,word y_pos,word width,word height,word dropdown_width,const char *label,byte display_choice,byte display_centered,byte display_arrow,byte active_button)
{ {
T_Dropdown_button *temp; T_Dropdown_button *temp;

View File

@ -65,7 +65,7 @@ T_Scroller_button * Window_set_scroller_button(word x_pos, word y_pos,
word initial_position); word initial_position);
T_Special_button * Window_set_special_button(word x_pos,word y_pos,word width,word height); T_Special_button * Window_set_special_button(word x_pos,word y_pos,word width,word height);
T_Special_button * Window_set_input_button(word x_pos,word y_pos,word width_in_characters); T_Special_button * Window_set_input_button(word x_pos,word y_pos,word width_in_characters);
T_Dropdown_button * Window_set_dropdown_button(word x_pos,word y_pos,word width,word height,word dropdown_width,char *label,byte display_choice,byte display_centered,byte display_arrow,byte active_button); T_Dropdown_button * Window_set_dropdown_button(word x_pos,word y_pos,word width,word height,word dropdown_width,const char *label,byte display_choice,byte display_centered,byte display_arrow,byte active_button);
void Window_dropdown_add_item(T_Dropdown_button * dropdown, word btn_number, const char *label); void Window_dropdown_add_item(T_Dropdown_button * dropdown, word btn_number, const char *label);
void Window_dropdown_clear_items(T_Dropdown_button * dropdown); void Window_dropdown_clear_items(T_Dropdown_button * dropdown);
byte Window_click_in_rectangle(short start_x,short start_y,short end_x,short end_y); byte Window_click_in_rectangle(short start_x,short start_y,short end_x,short end_y);

223
graph.c
View File

@ -180,28 +180,79 @@ void Transform_point(short x, short y, float cos_a, float sin_a,
//--------------------- Initialisation d'un mode vidéo ----------------------- //--------------------- Initialisation d'un mode vidéo -----------------------
int Init_mode_video(int width, int height, int fullscreen) int Init_mode_video(int width, int height, int fullscreen, int pix_ratio)
{ {
int x_sensitivity; int x_sensitivity;
int y_sensitivity; int y_sensitivity;
int index; int index;
int factor; int factor;
int pix_width;
// Pour la première entrée dans cette fonction int pix_height;
if (Pixel_width<1) byte screen_changed;
Pixel_width=1; byte pixels_changed;
if (Pixel_height<1)
Pixel_height=1;
if (Screen_width!=width/Pixel_width || switch (pix_ratio)
Screen_height!=height/Pixel_height ||
Video_mode[Current_resolution].Fullscreen != fullscreen)
{ {
default:
case PIXEL_SIMPLE:
pix_width=1;
pix_height=1;
break;
case PIXEL_TALL:
pix_width=1;
pix_height=2;
break;
case PIXEL_WIDE:
pix_width=2;
pix_height=1;
break;
case PIXEL_DOUBLE:
pix_width=2;
pix_height=2;
break;
}
// Valeurs raisonnables: minimum 320x200
if (!fullscreen)
{
if (width < 320*pix_width)
width = 320*pix_width;
if (height < 200*pix_height)
height = 200*pix_height;
}
else
{
if (width < 320*pix_width || height < 200*pix_height)
return 1;
}
// La largeur doit être un multiple de 4
#ifdef __amigaos4__
// On AmigaOS the systems adds some more constraints on that ...
width = (width + 15) & 0xFFFFFFF0;
#else
width = (width + 3 ) & 0xFFFFFFFC;
#endif
screen_changed = (Screen_width*Pixel_width!=width ||
Screen_height*Pixel_height!=height ||
Video_mode[Current_resolution].Fullscreen != fullscreen);
pixels_changed = (Pixel_ratio!=pix_ratio);
if (!screen_changed && !pixels_changed)
return 0;
if (screen_changed)
{
Set_mode_SDL(&width, &height,fullscreen);
}
if (screen_changed || pixels_changed)
{
Pixel_ratio=pix_ratio;
Pixel_width=pix_width;
Pixel_height=pix_height;
switch (Pixel_ratio) switch (Pixel_ratio)
{ {
default:
case PIXEL_SIMPLE: case PIXEL_SIMPLE:
Pixel_width=1;
Pixel_height=1;
Pixel = Pixel_simple ; Pixel = Pixel_simple ;
Read_pixel= Read_pixel_simple ; Read_pixel= Read_pixel_simple ;
Display_screen = Display_part_of_screen_simple ; Display_screen = Display_part_of_screen_simple ;
@ -224,8 +275,6 @@ int Init_mode_video(int width, int height, int fullscreen)
Display_brush = Display_brush_simple ; Display_brush = Display_brush_simple ;
break; break;
case PIXEL_TALL: case PIXEL_TALL:
Pixel_width=1;
Pixel_height=2;
Pixel = Pixel_tall; Pixel = Pixel_tall;
Read_pixel= Read_pixel_tall; Read_pixel= Read_pixel_tall;
Display_screen = Display_part_of_screen_tall; Display_screen = Display_part_of_screen_tall;
@ -248,8 +297,6 @@ int Init_mode_video(int width, int height, int fullscreen)
Display_brush = Display_brush_tall; Display_brush = Display_brush_tall;
break; break;
case PIXEL_WIDE: case PIXEL_WIDE:
Pixel_width=2;
Pixel_height=1;
Pixel = Pixel_wide ; Pixel = Pixel_wide ;
Read_pixel= Read_pixel_wide ; Read_pixel= Read_pixel_wide ;
Display_screen = Display_part_of_screen_wide ; Display_screen = Display_part_of_screen_wide ;
@ -272,8 +319,6 @@ int Init_mode_video(int width, int height, int fullscreen)
Display_brush = Display_brush_wide ; Display_brush = Display_brush_wide ;
break; break;
case PIXEL_DOUBLE: case PIXEL_DOUBLE:
Pixel_width=2;
Pixel_height=2;
Pixel = Pixel_double ; Pixel = Pixel_double ;
Read_pixel= Read_pixel_double ; Read_pixel= Read_pixel_double ;
Display_screen = Display_part_of_screen_double ; Display_screen = Display_part_of_screen_double ;
@ -296,94 +341,74 @@ int Init_mode_video(int width, int height, int fullscreen)
Display_brush = Display_brush_double ; Display_brush = Display_brush_double ;
break; break;
} }
// Valeurs raisonnables: minimum 320x200 }
if (!fullscreen) Screen_width = width/Pixel_width;
{ Screen_height = height/Pixel_height;
if (width < 320*Pixel_width)
width = 320*Pixel_width;
if (height < 200*Pixel_height)
height = 200*Pixel_height;
}
else
{
if (width < 320*Pixel_width || height < 200*Pixel_height)
return 1;
}
// La largeur doit être un multiple de 4
#ifdef __amigaos4__
// On AmigaOS the systems adds some more constraints on that ...
width = (width + 15) & 0xFFFFFFF0;
#else
width = (width + 3 ) & 0xFFFFFFFC;
#endif
Set_mode_SDL(&width, &height,fullscreen);
Screen_width = width/Pixel_width;
Screen_height = height/Pixel_height;
// Taille des menus // Taille des menus
if (Screen_width/320 > Screen_height/200) if (Screen_width/320 > Screen_height/200)
factor=Screen_height/200; factor=Screen_height/200;
else else
factor=Screen_width/320; 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; index<Nb_video_modes; index++)
{ {
case 1: // adapter tout if (Video_mode[index].Width/Pixel_width==Screen_width &&
Menu_factor_X=factor; Video_mode[index].Height/Pixel_height==Screen_height)
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; index<Nb_video_modes; index++)
{ {
if (Video_mode[index].Width/Pixel_width==Screen_width && Current_resolution=index;
Video_mode[index].Height/Pixel_height==Screen_height) break;
{
Current_resolution=index;
break;
}
} }
} }
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.
} }
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) if (Main_magnifier_mode)
{ {
Pixel_preview=Pixel_preview_magnifier; Pixel_preview=Pixel_preview_magnifier;

View File

@ -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, void Transform_point(short x, short y,
float cos_a, float sin_a, short * rx, short * ry); 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 No_effect(word x,word y,byte color);
byte Effect_shade(word x,word y,byte color); byte Effect_shade(word x,word y,byte color);

5
main.c
View File

@ -549,12 +549,13 @@ int Init_program(int argc,char * argv[])
Analyze_command_line(argc,argv); Analyze_command_line(argc,argv);
starting_videomode=Current_resolution; starting_videomode=Current_resolution;
Horizontal_line_buffer=NULL; 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( Init_mode_video(
Video_mode[starting_videomode].Width, Video_mode[starting_videomode].Width,
Video_mode[starting_videomode].Height, 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_width=Screen_width/Pixel_width;
Main_image_height=Screen_height/Pixel_height; Main_image_height=Screen_height/Pixel_height;

View File

@ -244,7 +244,7 @@ void Frame_menu_color(byte color)
((index)&1)?MC_White:MC_Black); ((index)&1)?MC_White:MC_Black);
// Right line // Right line
for (index=1; index<end_y; index++) for (index=1; index<end_y; index++)
Block(start_x+end_x*Menu_factor_Y,start_y+index*Menu_factor_Y, Block(start_x+end_x*Menu_factor_X,start_y+index*Menu_factor_Y,
Menu_factor_X,Menu_factor_Y, Menu_factor_X,Menu_factor_Y,
((index+end_x)&1)?MC_White:MC_Black); ((index+end_x)&1)?MC_White:MC_Black);
// Bottom line // Bottom line