Removed Wait_VBL. Was only used for slowing down things. Used SDL_Delay(1) instead, which let the OS handle other things. We should get about 10-20ms latency with that. Scrollbars may be slightly faster. The only place where this could be a problem is discontinuous freehand. If the current way it works isn't good, look at the "Chrono" functions (like the spray) instead.
git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@799 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
parent
7a847be4ec
commit
3c0a940301
@ -135,7 +135,7 @@ void Button_Message_initial(void)
|
|||||||
|
|
||||||
Display_cursor();
|
Display_cursor();
|
||||||
|
|
||||||
while(!Mouse_K && !Key) if(!Get_input()) Wait_VBL();
|
while(!Get_input()) SDL_Delay(1);
|
||||||
if (Mouse_K)
|
if (Mouse_K)
|
||||||
Wait_end_of_click();
|
Wait_end_of_click();
|
||||||
|
|
||||||
|
|||||||
21
engine.c
21
engine.c
@ -448,7 +448,7 @@ void Move_separator(void)
|
|||||||
Display_cursor();
|
Display_cursor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!Get_input())Wait_VBL();
|
if(!Get_input())SDL_Delay(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Effacer la barre en XOR
|
// Effacer la barre en XOR
|
||||||
@ -895,7 +895,7 @@ void Main_handler(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else Wait_VBL(); // S'il n'y a pas d'évènement, on ne gère pas tout ça et on attend un peu. La partie en dessous doit être exécutée quand
|
else SDL_Delay(1); // S'il n'y a pas d'évènement, on ne gère pas tout ça et on attend un peu. La partie en dessous doit être exécutée quand
|
||||||
// même pour les trucs asynchrones, par exemple le spray.
|
// même pour les trucs asynchrones, par exemple le spray.
|
||||||
|
|
||||||
// Gestion de la souris
|
// Gestion de la souris
|
||||||
@ -1772,7 +1772,7 @@ short Wait_click_in_palette(T_Palette_button * button)
|
|||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
while(!Get_input())Wait_VBL();
|
while(!Get_input())SDL_Delay(1);
|
||||||
|
|
||||||
if (Mouse_K==LEFT_SIDE)
|
if (Mouse_K==LEFT_SIDE)
|
||||||
{
|
{
|
||||||
@ -1858,7 +1858,7 @@ void Get_color_behind_window(byte * color, byte * click)
|
|||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if(!Get_input())Wait_VBL();
|
if(!Get_input())SDL_Delay(1);
|
||||||
|
|
||||||
if ((Mouse_X!=old_x) || (Mouse_Y!=old_y))
|
if ((Mouse_X!=old_x) || (Mouse_Y!=old_y))
|
||||||
{
|
{
|
||||||
@ -1953,7 +1953,7 @@ void Move_window(short dx, short dy)
|
|||||||
old_x=new_x;
|
old_x=new_x;
|
||||||
old_y=new_y;
|
old_y=new_y;
|
||||||
|
|
||||||
while(!Get_input() && new_x==Mouse_X-dx && new_y==Mouse_Y-dy) Wait_VBL();
|
while(!Get_input() && new_x==Mouse_X-dx && new_y==Mouse_Y-dy) SDL_Delay(1);
|
||||||
|
|
||||||
new_x=Mouse_X-dx;
|
new_x=Mouse_X-dx;
|
||||||
|
|
||||||
@ -2151,8 +2151,7 @@ short Window_dropdown_on_click(T_Dropdown_button *Button)
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
// Attente
|
// Attente
|
||||||
if(!Get_input())
|
if(!Get_input()) SDL_Delay(1);
|
||||||
Wait_VBL();
|
|
||||||
// Mise à jour du survol
|
// Mise à jour du survol
|
||||||
selected_index=Window_click_in_rectangle(2,2,Button->Dropdown_width-2,box_height-1)?
|
selected_index=Window_click_in_rectangle(2,2,Button->Dropdown_width-2,box_height-1)?
|
||||||
(((Mouse_Y-Window_pos_Y)/Menu_factor_Y-2)>>3) : -1;
|
(((Mouse_Y-Window_pos_Y)/Menu_factor_Y-2)>>3) : -1;
|
||||||
@ -2198,8 +2197,7 @@ short Window_normal_button_onclick(word x_pos, word y_pos, word width, word heig
|
|||||||
Display_cursor();
|
Display_cursor();
|
||||||
while (Window_click_in_rectangle(x_pos,y_pos,x_pos+width-1,y_pos+height-1))
|
while (Window_click_in_rectangle(x_pos,y_pos,x_pos+width-1,y_pos+height-1))
|
||||||
{
|
{
|
||||||
if(!Get_input())
|
if(!Get_input()) SDL_Delay(1);
|
||||||
Wait_VBL();
|
|
||||||
if (!Mouse_K)
|
if (!Mouse_K)
|
||||||
{
|
{
|
||||||
Hide_cursor();
|
Hide_cursor();
|
||||||
@ -2213,8 +2211,7 @@ short Window_normal_button_onclick(word x_pos, word y_pos, word width, word heig
|
|||||||
Display_cursor();
|
Display_cursor();
|
||||||
while (!(Window_click_in_rectangle(x_pos,y_pos,x_pos+width-1,y_pos+height-1)))
|
while (!(Window_click_in_rectangle(x_pos,y_pos,x_pos+width-1,y_pos+height-1)))
|
||||||
{
|
{
|
||||||
if(!Get_input())
|
if(!Get_input()) SDL_Delay(1);
|
||||||
Wait_VBL();
|
|
||||||
if (!Mouse_K)
|
if (!Mouse_K)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -2448,7 +2445,7 @@ short Window_clicked_button(void)
|
|||||||
{
|
{
|
||||||
short Button;
|
short Button;
|
||||||
|
|
||||||
if(!Get_input())Wait_VBL();
|
if(!Get_input())SDL_Delay(1);
|
||||||
|
|
||||||
// Gestion des clicks
|
// Gestion des clicks
|
||||||
if (Mouse_K)
|
if (Mouse_K)
|
||||||
|
|||||||
2
help.c
2
help.c
@ -88,7 +88,7 @@ void Redefine_control(word *shortcut, int x_pos, int y_pos)
|
|||||||
Display_cursor();
|
Display_cursor();
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
while(!Get_input())Wait_VBL();
|
while(!Get_input())SDL_Delay(1);
|
||||||
if (Key==KEY_ESC)
|
if (Key==KEY_ESC)
|
||||||
return;
|
return;
|
||||||
if (Key!=0)
|
if (Key!=0)
|
||||||
|
|||||||
23
misc.c
23
misc.c
@ -125,7 +125,7 @@ void Wait_end_of_click(void)
|
|||||||
{
|
{
|
||||||
// On désactive tous les raccourcis clavier
|
// On désactive tous les raccourcis clavier
|
||||||
|
|
||||||
while(Mouse_K) if(!Get_input()) Wait_VBL();
|
while(Mouse_K) if(!Get_input()) SDL_Delay(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hide_current_image_with_stencil(byte color, byte * stencil)
|
void Hide_current_image_with_stencil(byte color, byte * stencil)
|
||||||
@ -170,25 +170,6 @@ void Init_chrono(dword delay)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Wait_VBL(void)
|
|
||||||
// Attente de VBL. Pour avoir des scrollbars qui ont une vitesse raisonnable par exemple.
|
|
||||||
// SDL ne sait pas faire, alors on simule un timer qui a une fréquence de 100Hz,
|
|
||||||
// sans charger inutilement le CPU par du busy-wait (on n'est pas à 10ms près)
|
|
||||||
{
|
|
||||||
const int delay = 10;
|
|
||||||
|
|
||||||
Uint32 debut;
|
|
||||||
debut = SDL_GetTicks();
|
|
||||||
// Première attente : le complément de "delay" millisecondes
|
|
||||||
SDL_Delay(delay - (debut % delay));
|
|
||||||
// Si ça ne suffit pas, on complète par des attentes successives de "1ms".
|
|
||||||
// (Remarque, Windows arrondit généralement aux 10ms supérieures)
|
|
||||||
while (SDL_GetTicks() / delay <= debut / delay)
|
|
||||||
{
|
|
||||||
SDL_Delay(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Pixel_in_brush (word x,word y,byte color)
|
void Pixel_in_brush (word x,word y,byte color)
|
||||||
{
|
{
|
||||||
*(Brush+y*Brush_width+x)=color;
|
*(Brush+y*Brush_width+x)=color;
|
||||||
@ -645,7 +626,7 @@ void Slider_timer(byte speed)
|
|||||||
end = SDL_GetTicks() + speed*10;
|
end = SDL_GetTicks() + speed*10;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (!Get_input()) Wait_VBL();
|
if (!Get_input()) SDL_Delay(1);
|
||||||
} while (Mouse_K == original_mouse_k && SDL_GetTicks()<end);
|
} while (Mouse_K == original_mouse_k && SDL_GetTicks()<end);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
1
misc.h
1
misc.h
@ -34,7 +34,6 @@ void Palette_256_to_64(T_Palette palette);
|
|||||||
void Palette_64_to_256(T_Palette palette);
|
void Palette_64_to_256(T_Palette palette);
|
||||||
void Hide_current_image(byte color);
|
void Hide_current_image(byte color);
|
||||||
void Hide_current_image_with_stencil(byte color, byte * stencil);
|
void Hide_current_image_with_stencil(byte color, byte * stencil);
|
||||||
void Wait_VBL(void);
|
|
||||||
void Slider_timer(byte speed);
|
void Slider_timer(byte speed);
|
||||||
dword Round_div(dword numerator,dword divisor);
|
dword Round_div(dword numerator,dword divisor);
|
||||||
word Count_used_colors(dword * usage);
|
word Count_used_colors(dword * usage);
|
||||||
|
|||||||
@ -300,7 +300,7 @@ void Freehand_mode2_1_0(void)
|
|||||||
Operation_push(Paintbrush_X);
|
Operation_push(Paintbrush_X);
|
||||||
Operation_push(Paintbrush_Y);
|
Operation_push(Paintbrush_Y);
|
||||||
Print_coordinates();
|
Print_coordinates();
|
||||||
Wait_VBL();
|
SDL_Delay(20);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -324,7 +324,7 @@ void Freehand_mode2_1_2(void)
|
|||||||
Display_paintbrush(Paintbrush_X,Paintbrush_Y,Fore_color,0);
|
Display_paintbrush(Paintbrush_X,Paintbrush_Y,Fore_color,0);
|
||||||
Display_cursor();
|
Display_cursor();
|
||||||
Print_coordinates();
|
Print_coordinates();
|
||||||
Wait_VBL();
|
SDL_Delay(20);
|
||||||
}
|
}
|
||||||
|
|
||||||
Operation_push(Paintbrush_X);
|
Operation_push(Paintbrush_X);
|
||||||
@ -347,7 +347,7 @@ void Freehand_mode2_2_0(void)
|
|||||||
Operation_push(Paintbrush_X);
|
Operation_push(Paintbrush_X);
|
||||||
Operation_push(Paintbrush_Y);
|
Operation_push(Paintbrush_Y);
|
||||||
Print_coordinates();
|
Print_coordinates();
|
||||||
Wait_VBL();
|
SDL_Delay(20);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -371,7 +371,7 @@ void Freehand_mode2_2_2(void)
|
|||||||
Display_paintbrush(Paintbrush_X,Paintbrush_Y,Back_color,0);
|
Display_paintbrush(Paintbrush_X,Paintbrush_Y,Back_color,0);
|
||||||
Display_cursor();
|
Display_cursor();
|
||||||
Print_coordinates();
|
Print_coordinates();
|
||||||
Wait_VBL();
|
SDL_Delay(20);
|
||||||
}
|
}
|
||||||
|
|
||||||
Operation_push(Paintbrush_X);
|
Operation_push(Paintbrush_X);
|
||||||
|
|||||||
@ -181,7 +181,7 @@ byte Readline_ex(word x_pos,word y_pos,char * str,byte visible_size,byte max_siz
|
|||||||
Display_cursor();
|
Display_cursor();
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if(!Get_input()) Wait_VBL();
|
if(!Get_input()) SDL_Delay(1);
|
||||||
input_key=Key_ANSI;
|
input_key=Key_ANSI;
|
||||||
} while(input_key==0);
|
} while(input_key==0);
|
||||||
Hide_cursor();
|
Hide_cursor();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user