Source code translated to english

git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@697 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
Yves Rizoud 2009-03-27 16:50:21 +00:00
parent 6b4a8f674e
commit efbc978e6f
68 changed files with 22766 additions and 22766 deletions

678
aide.c
View File

@ -51,21 +51,21 @@
extern char SVN_revision[]; // generated in version.c extern char SVN_revision[]; // generated in version.c
// Recherche un raccourci clavier: // Recherche un raccourci clavier:
word * Raccourci(word NumeroRaccourci) word * Shortcut(word shortcut_number)
{ {
if (NumeroRaccourci & 0x100) if (shortcut_number & 0x100)
return &(Bouton[NumeroRaccourci & 0xFF].Raccourci_gauche[0]); return &(Button[shortcut_number & 0xFF].Left_shortcut[0]);
if (NumeroRaccourci & 0x200) if (shortcut_number & 0x200)
return &(Bouton[NumeroRaccourci & 0xFF].Raccourci_droite[0]); return &(Button[shortcut_number & 0xFF].Right_shortcut[0]);
return &(Config_Touche[NumeroRaccourci & 0xFF][0]); return &(Config_Key[shortcut_number & 0xFF][0]);
} }
// Nom de la touche actuallement assignée à un raccourci d'après son numéro // Nom de la touche actuallement assignée à un raccourci d'après son numéro
// de type 0x100+BOUTON_* ou SPECIAL_* // de type 0x100+BOUTON_* ou SPECIAL_*
const char * Valeur_Raccourci_Clavier(word NumeroRaccourci) const char * Keyboard_shortcut_value(word shortcut_number)
{ {
static char Noms_raccourcis[80]; static char shortcuts_name[80];
word * pointer = Raccourci(NumeroRaccourci); word * pointer = Shortcut(shortcut_number);
if (pointer == NULL) if (pointer == NULL)
return "(Problem)"; return "(Problem)";
else else
@ -73,389 +73,389 @@ const char * Valeur_Raccourci_Clavier(word NumeroRaccourci)
if (pointer[0] == 0 && pointer[1] == 0) if (pointer[0] == 0 && pointer[1] == 0)
return "None"; return "None";
if (pointer[0] != 0 && pointer[1] == 0) if (pointer[0] != 0 && pointer[1] == 0)
return Nom_touche(pointer[0]); return Key_name(pointer[0]);
if (pointer[0] == 0 && pointer[1] != 0) if (pointer[0] == 0 && pointer[1] != 0)
return Nom_touche(pointer[1]); return Key_name(pointer[1]);
strcpy(Noms_raccourcis, Nom_touche(pointer[0])); strcpy(shortcuts_name, Key_name(pointer[0]));
strcat(Noms_raccourcis, " or "); strcat(shortcuts_name, " or ");
strcat(Noms_raccourcis, Nom_touche(pointer[1])); strcat(shortcuts_name, Key_name(pointer[1]));
return Noms_raccourcis; return shortcuts_name;
} }
} }
void Redefinir_controle(word *shortcut, int x_pos, int y_pos) void Redefine_control(word *shortcut, int x_pos, int y_pos)
{ {
Effacer_curseur(); Hide_cursor();
Print_dans_fenetre(x_pos,y_pos,"*PRESS KEY OR BUTTON*",CM_Noir,CM_Clair); Print_in_window(x_pos,y_pos,"*PRESS KEY OR BUTTON*",MC_Black,MC_Light);
Afficher_curseur(); Display_cursor();
while (1) while (1)
{ {
while(!Get_input())Wait_VBL(); while(!Get_input())Wait_VBL();
if (Touche==TOUCHE_ESC) if (Key==KEY_ESC)
return; return;
if (Touche!=0) if (Key!=0)
{ {
*shortcut=Touche; *shortcut=Key;
return; return;
} }
} }
} }
void Fenetre_controle(int NumeroControle) void Window_set_shortcut(int action_id)
{ {
short Bouton_clicke; short clicked_button;
short IndiceOrdo; short order_index;
short IndiceConfig; short config_index;
short Redessiner_controles=1; short redraw_controls=1;
word * PtrRaccourci=NULL; word * shortcut_ptr=NULL;
word Sauve_raccourci[2]; word backup_shortcut[2];
PtrRaccourci=Raccourci(NumeroControle); shortcut_ptr=Shortcut(action_id);
Sauve_raccourci[0]=PtrRaccourci[0]; backup_shortcut[0]=shortcut_ptr[0];
Sauve_raccourci[1]=PtrRaccourci[1]; backup_shortcut[1]=shortcut_ptr[1];
// Recherche dans hotkeys // Recherche dans hotkeys
IndiceOrdo=0; order_index=0;
while (Ordonnancement[IndiceOrdo]!=NumeroControle) while (Ordering[order_index]!=action_id)
{ {
IndiceOrdo++; order_index++;
if (IndiceOrdo>=134) if (order_index>=134)
{ {
Erreur(0); Error(0);
return; return;
} }
} }
/* /*
IndiceConfig=0; config_index=0;
while (ConfigTouche[IndiceConfig].Number!=IndiceOrdo) while (ConfigKey[config_index].Number!=order_index)
{ {
IndiceConfig++; config_index++;
if (IndiceConfig>=134) if (config_index>=134)
{ {
Erreur(0); Error(0);
return; return;
} }
} }
*/ */
IndiceConfig=IndiceOrdo; // Comprends pas... ça devrait pas marcher config_index=order_index; // Comprends pas... ça devrait pas marcher
Ouvrir_fenetre(302,131,"Keyboard shortcut"); Open_window(302,131,"Keyboard shortcut");
Fenetre_Definir_bouton_normal(181,111,55,14,"Cancel",0,1,TOUCHE_ESC); // 1 Window_set_normal_button(181,111,55,14,"Cancel",0,1,KEY_ESC); // 1
Fenetre_Definir_bouton_normal(241,111,55,14,"OK",0,1,SDLK_RETURN); // 2 Window_set_normal_button(241,111,55,14,"OK",0,1,SDLK_RETURN); // 2
Fenetre_Definir_bouton_normal(6,111,111,14,"Reset default",0,1,TOUCHE_AUCUNE); // 3 Window_set_normal_button(6,111,111,14,"Reset default",0,1,KEY_NONE); // 3
// Titre // Titre
Block(Fenetre_Pos_X+(Menu_Facteur_X*5), Block(Window_pos_X+(Menu_factor_X*5),
Fenetre_Pos_Y+(Menu_Facteur_Y*16), Window_pos_Y+(Menu_factor_Y*16),
Menu_Facteur_X*292,Menu_Facteur_Y*11,CM_Noir); Menu_factor_X*292,Menu_factor_Y*11,MC_Black);
Print_dans_fenetre(7,18,ConfigTouche[IndiceConfig].Label,CM_Blanc,CM_Noir); Print_in_window(7,18,ConfigKey[config_index].Label,MC_White,MC_Black);
// Zone de description // Zone de description
Fenetre_Afficher_cadre_creux(5,68,292,37); Window_display_frame_in(5,68,292,37);
Print_dans_fenetre(9,70,ConfigTouche[IndiceConfig].Explic1,CM_Noir,CM_Clair); Print_in_window(9,70,ConfigKey[config_index].Explic1,MC_Black,MC_Light);
Print_dans_fenetre(9,78,ConfigTouche[IndiceConfig].Explic2,CM_Noir,CM_Clair); Print_in_window(9,78,ConfigKey[config_index].Explic2,MC_Black,MC_Light);
Print_dans_fenetre(9,86,ConfigTouche[IndiceConfig].Explic3,CM_Noir,CM_Clair); Print_in_window(9,86,ConfigKey[config_index].Explic3,MC_Black,MC_Light);
// Raccourci 0 // Shortcut 0
Fenetre_Definir_bouton_normal(27,30,177,14,"",0,1,TOUCHE_AUCUNE); // 4 Window_set_normal_button(27,30,177,14,"",0,1,KEY_NONE); // 4
Fenetre_Definir_bouton_normal(209,30,56,14,"Remove",0,1,TOUCHE_AUCUNE); // 5 Window_set_normal_button(209,30,56,14,"Remove",0,1,KEY_NONE); // 5
// Raccourci 1 // Shortcut 1
Fenetre_Definir_bouton_normal(27,49,177,14,"",0,1,TOUCHE_AUCUNE); // 6 Window_set_normal_button(27,49,177,14,"",0,1,KEY_NONE); // 6
Fenetre_Definir_bouton_normal(209,49,56,14,"Remove",0,1,TOUCHE_AUCUNE); // 7 Window_set_normal_button(209,49,56,14,"Remove",0,1,KEY_NONE); // 7
Afficher_curseur(); Display_cursor();
do do
{ {
if (Redessiner_controles) if (redraw_controls)
{ {
Effacer_curseur(); Hide_cursor();
Block(Fenetre_Pos_X+(Menu_Facteur_X*32), Block(Window_pos_X+(Menu_factor_X*32),
Fenetre_Pos_Y+(Menu_Facteur_Y*33), Window_pos_Y+(Menu_factor_Y*33),
Menu_Facteur_X*21*8,Menu_Facteur_Y*8,CM_Clair); Menu_factor_X*21*8,Menu_factor_Y*8,MC_Light);
Print_dans_fenetre_limite(32,33,Nom_touche(PtrRaccourci[0]),21,CM_Noir,CM_Clair); Print_in_window_limited(32,33,Key_name(shortcut_ptr[0]),21,MC_Black,MC_Light);
Block(Fenetre_Pos_X+(Menu_Facteur_X*32), Block(Window_pos_X+(Menu_factor_X*32),
Fenetre_Pos_Y+(Menu_Facteur_Y*52), Window_pos_Y+(Menu_factor_Y*52),
Menu_Facteur_X*21*8,Menu_Facteur_Y*8,CM_Clair); Menu_factor_X*21*8,Menu_factor_Y*8,MC_Light);
Print_dans_fenetre_limite(32,52,Nom_touche(PtrRaccourci[1]),21,CM_Noir,CM_Clair); Print_in_window_limited(32,52,Key_name(shortcut_ptr[1]),21,MC_Black,MC_Light);
UpdateRect(Fenetre_Pos_X,Fenetre_Pos_Y,302*Menu_Facteur_X,131*Menu_Facteur_Y); Update_rect(Window_pos_X,Window_pos_Y,302*Menu_factor_X,131*Menu_factor_Y);
Afficher_curseur(); Display_cursor();
Redessiner_controles=0; redraw_controls=0;
} }
Bouton_clicke=Fenetre_Bouton_clicke(); clicked_button=Window_clicked_button();
switch (Bouton_clicke) switch (clicked_button)
{ {
case -1: case -1:
case 0: case 0:
break; break;
case 4: // Change 0 case 4: // Change 0
Redefinir_controle(&PtrRaccourci[0], 32, 33); Redefine_control(&shortcut_ptr[0], 32, 33);
Redessiner_controles=1; redraw_controls=1;
break; break;
case 6: // Change 1 case 6: // Change 1
Redefinir_controle(&PtrRaccourci[1], 32, 52); Redefine_control(&shortcut_ptr[1], 32, 52);
Redessiner_controles=1; redraw_controls=1;
break; break;
case 5: // Remove 0 case 5: // Remove 0
PtrRaccourci[0]=0; shortcut_ptr[0]=0;
Redessiner_controles=1; redraw_controls=1;
break; break;
case 7: // Remove 1 case 7: // Remove 1
PtrRaccourci[1]=0; shortcut_ptr[1]=0;
Redessiner_controles=1; redraw_controls=1;
break; break;
case 3: // Defaults case 3: // Defaults
PtrRaccourci[0]=ConfigTouche[IndiceConfig].Touche; shortcut_ptr[0]=ConfigKey[config_index].Key;
PtrRaccourci[1]=ConfigTouche[IndiceConfig].Touche2; shortcut_ptr[1]=ConfigKey[config_index].Key2;
Redessiner_controles=1; redraw_controls=1;
break; break;
case 1: // Cancel case 1: // Cancel
PtrRaccourci[0]=Sauve_raccourci[0]; shortcut_ptr[0]=backup_shortcut[0];
PtrRaccourci[1]=Sauve_raccourci[1]; shortcut_ptr[1]=backup_shortcut[1];
case 2: // OK case 2: // OK
default: default:
break; break;
} }
} }
while ((Bouton_clicke!=1) && (Bouton_clicke!=2) && (Touche!=SDLK_RETURN)); while ((clicked_button!=1) && (clicked_button!=2) && (Key!=SDLK_RETURN));
Touche=0; Key=0;
Fermer_fenetre(); Close_window();
Afficher_curseur(); Display_cursor();
} }
// -- Menu d'aide ----------------------------------------------------------- // -- Menu d'aide -----------------------------------------------------------
void Afficher_aide(void) void Display_help(void)
{ {
short x; // Indices d'affichage d'un caractère short x; // Indices d'affichage d'un caractère
short y; short y;
short Position_X; // Parcours de remplissage du buffer de ligne short x_position; // Parcours de remplissage du buffer de ligne
short Indice_de_ligne; // 0-15 (16 lignes de textes) short line_index; // 0-15 (16 lignes de textes)
short Indice_de_caractere; // Parcours des caractères d'une ligne short char_index; // Parcours des caractères d'une ligne
short Ligne_de_depart=Position_d_aide_en_cours; short start_line=Help_position;
short Repeat_Menu_Facteur_X; short repeat_menu_x_factor;
short Repeat_Menu_Facteur_Y; short repeat_menu_y_factor;
short Pos_Reel_X; short real_x_pos;
short Pos_Reel_Y; short real_y_pos;
byte * char_pixel; byte * char_pixel;
short width; // Largeur physique d'une ligne de texte short width; // Largeur physique d'une ligne de texte
char TypeLigne; // N: Normale, T: Titre, S: Sous-titre char line_type; // N: Normale, T: Titre, S: Sous-titre
// -: Ligne inférieur de sous-titre // -: Ligne inférieur de sous-titre
const char * line; const char * line;
char Buffer[45]; // Buffer texte utilisé pour formater les noms de char buffer[45]; // buffer texte utilisé pour formater les noms de
// raccourcis clavier // raccourcis clavier
short Position_lien=0; // Position du premier caractère "variable" short link_position=0; // Position du premier caractère "variable"
short Taille_lien=0; // Taille de la partie variable short link_size=0; // Taille de la partie variable
Pos_Reel_X=Fenetre_Pos_X+(13*Menu_Facteur_X); real_x_pos=Window_pos_X+(13*Menu_factor_X);
Pos_Reel_Y=Fenetre_Pos_Y+(19*Menu_Facteur_Y); real_y_pos=Window_pos_Y+(19*Menu_factor_Y);
for (Indice_de_ligne=0;Indice_de_ligne<16;Indice_de_ligne++) for (line_index=0;line_index<16;line_index++)
{ {
// Raccourci au cas ou la section fait moins de 16 lignes // Shortcut au cas ou la section fait moins de 16 lignes
if (Indice_de_ligne >= Table_d_aide[Section_d_aide_en_cours].Nombre_de_lignes) if (line_index >= Help_section[Current_help_section].Length)
{ {
Block (Pos_Reel_X, Block (real_x_pos,
Pos_Reel_Y, real_y_pos,
44*6*Menu_Facteur_X, 44*6*Menu_factor_X,
// 44 = Nb max de char (+1 pour éviter les plantages en mode X // 44 = Nb max de char (+1 pour éviter les plantages en mode X
// causés par une largeur = 0) // causés par une largeur = 0)
(Menu_Facteur_Y<<3) * (16 - Indice_de_ligne), (Menu_factor_Y<<3) * (16 - line_index),
CM_Noir); MC_Black);
break; break;
} }
// On affiche la ligne // On affiche la ligne
line = Table_d_aide[Section_d_aide_en_cours].Table_aide[Ligne_de_depart + Indice_de_ligne].Text; line = Help_section[Current_help_section].Help_table[start_line + line_index].Text;
TypeLigne = Table_d_aide[Section_d_aide_en_cours].Table_aide[Ligne_de_depart + Indice_de_ligne].Line_type; line_type = Help_section[Current_help_section].Help_table[start_line + line_index].Line_type;
// Si c'est une sous-ligne de titre, on utilise le texte de la ligne précédente // Si c'est une sous-ligne de titre, on utilise le texte de la ligne précédente
if (TypeLigne == '-' && (Ligne_de_depart + Indice_de_ligne > 0)) if (line_type == '-' && (start_line + line_index > 0))
line = Table_d_aide[Section_d_aide_en_cours].Table_aide[Ligne_de_depart + Indice_de_ligne - 1].Text; line = Help_section[Current_help_section].Help_table[start_line + line_index - 1].Text;
else if (TypeLigne == 'K') else if (line_type == 'K')
{ {
const char *Lien; const char *hyperlink;
Position_lien = strstr(line,"%s") - line; link_position = strstr(line,"%s") - line;
Lien=Valeur_Raccourci_Clavier(Table_d_aide[Section_d_aide_en_cours].Table_aide[Ligne_de_depart + Indice_de_ligne].Line_parameter); hyperlink=Keyboard_shortcut_value(Help_section[Current_help_section].Help_table[start_line + line_index].Line_parameter);
Taille_lien=strlen(Lien); link_size=strlen(hyperlink);
snprintf(Buffer, 44, line, Lien); snprintf(buffer, 44, line, hyperlink);
if (strlen(line)+Taille_lien-2>44) if (strlen(line)+link_size-2>44)
{ {
Buffer[43]=CARACTERE_SUSPENSION; buffer[43]=ELLIPSIS_CHARACTER;
Buffer[44]='\0'; buffer[44]='\0';
} }
line = Buffer; line = buffer;
} }
// Calcul de la taille // Calcul de la taille
width=strlen(line); width=strlen(line);
// Les lignes de titres prennent plus de place // Les lignes de titres prennent plus de place
if (TypeLigne == 'T' || TypeLigne == '-') if (line_type == 'T' || line_type == '-')
width = width*2; width = width*2;
// Pour chaque ligne dans la fenêtre: // Pour chaque ligne dans la fenêtre:
for (y=0;y<8;y++) for (y=0;y<8;y++)
{ {
Position_X=0; x_position=0;
// On crée une nouvelle ligne à splotcher // On crée une nouvelle ligne à splotcher
for (Indice_de_caractere=0;Indice_de_caractere<width;Indice_de_caractere++) for (char_index=0;char_index<width;char_index++)
{ {
// Recherche du caractère dans les fontes de l'aide. // Recherche du caractère dans les fontes de l'aide.
// Ligne titre : Si l'indice est impair on dessine le quart de caractère // Ligne titre : Si l'indice est impair on dessine le quart de caractère
// qui va a gauche, sinon celui qui va a droite. // qui va a gauche, sinon celui qui va a droite.
if (TypeLigne=='T') if (line_type=='T')
{ {
if (line[Indice_de_caractere/2]>'_' || line[Indice_de_caractere/2]<' ') if (line[char_index/2]>'_' || line[char_index/2]<' ')
char_pixel=&(Fonte_help_norm['!'][0][0]); // Caractère pas géré char_pixel=&(GFX_help_font_norm['!'][0][0]); // Caractère pas géré
else if (Indice_de_caractere & 1) else if (char_index & 1)
char_pixel=&(Fonte_help_t2[(unsigned char)(line[Indice_de_caractere/2])-' '][0][0]); char_pixel=&(GFX_help_font_t2[(unsigned char)(line[char_index/2])-' '][0][0]);
else else
char_pixel=&(Fonte_help_t1[(unsigned char)(line[Indice_de_caractere/2])-' '][0][0]); char_pixel=&(GFX_help_font_t1[(unsigned char)(line[char_index/2])-' '][0][0]);
} }
else if (TypeLigne=='-') else if (line_type=='-')
{ {
if (line[Indice_de_caractere/2]>'_' || line[Indice_de_caractere/2]<' ') if (line[char_index/2]>'_' || line[char_index/2]<' ')
char_pixel=&(Fonte_help_norm['!'][0][0]); // Caractère pas géré char_pixel=&(GFX_help_font_norm['!'][0][0]); // Caractère pas géré
else if (Indice_de_caractere & 1) else if (char_index & 1)
char_pixel=&(Fonte_help_t4[(unsigned char)(line[Indice_de_caractere/2])-' '][0][0]); char_pixel=&(GFX_help_font_t4[(unsigned char)(line[char_index/2])-' '][0][0]);
else else
char_pixel=&(Fonte_help_t3[(unsigned char)(line[Indice_de_caractere/2])-' '][0][0]); char_pixel=&(GFX_help_font_t3[(unsigned char)(line[char_index/2])-' '][0][0]);
} }
else if (TypeLigne=='S') else if (line_type=='S')
char_pixel=&(Fonte_help_bold[(unsigned char)(line[Indice_de_caractere])][0][0]); char_pixel=&(GFX_bold_font[(unsigned char)(line[char_index])][0][0]);
else if (TypeLigne=='N' || TypeLigne=='K') else if (line_type=='N' || line_type=='K')
char_pixel=&(Fonte_help_norm[(unsigned char)(line[Indice_de_caractere])][0][0]); char_pixel=&(GFX_help_font_norm[(unsigned char)(line[char_index])][0][0]);
else else
char_pixel=&(Fonte_help_norm['!'][0][0]); // Un garde-fou en cas de probleme char_pixel=&(GFX_help_font_norm['!'][0][0]); // Un garde-fou en cas de probleme
for (x=0;x<6;x++) for (x=0;x<6;x++)
for (Repeat_Menu_Facteur_X=0;Repeat_Menu_Facteur_X<Menu_Facteur_X;Repeat_Menu_Facteur_X++) for (repeat_menu_x_factor=0;repeat_menu_x_factor<Menu_factor_X;repeat_menu_x_factor++)
{ {
byte Couleur = *(char_pixel+x+y*6); byte color = *(char_pixel+x+y*6);
byte Repetition = Pixel_width-1; byte repetition = Pixel_width-1;
// Surlignement pour liens // Surlignement pour liens
if (TypeLigne=='K' && Indice_de_caractere>=Position_lien if (line_type=='K' && char_index>=link_position
&& Indice_de_caractere<(Position_lien+Taille_lien)) && char_index<(link_position+link_size))
{ {
if (Couleur == CM_Clair) if (color == MC_Light)
Couleur=CM_Blanc; color=MC_White;
else if (Couleur == CM_Fonce) else if (color == MC_Dark)
Couleur=CM_Clair; color=MC_Light;
else if (y<7) else if (y<7)
Couleur=CM_Fonce; color=MC_Dark;
} }
Buffer_de_ligne_horizontale[Position_X++]=Couleur; Horizontal_line_buffer[x_position++]=color;
while (Repetition--) while (repetition--)
Buffer_de_ligne_horizontale[Position_X++]=Couleur; Horizontal_line_buffer[x_position++]=color;
} }
} }
// On la splotche // On la splotche
for (Repeat_Menu_Facteur_Y=0;Repeat_Menu_Facteur_Y<Menu_Facteur_Y;Repeat_Menu_Facteur_Y++) for (repeat_menu_y_factor=0;repeat_menu_y_factor<Menu_factor_Y;repeat_menu_y_factor++)
Afficher_ligne_fast(Pos_Reel_X,Pos_Reel_Y++,width*Menu_Facteur_X*6,Buffer_de_ligne_horizontale); Display_line_fast(real_x_pos,real_y_pos++,width*Menu_factor_X*6,Horizontal_line_buffer);
} }
// On efface la fin de la ligne: // On efface la fin de la ligne:
Block (Pos_Reel_X+width*Menu_Facteur_X*6, Block (real_x_pos+width*Menu_factor_X*6,
Pos_Reel_Y-(8*Menu_Facteur_Y), real_y_pos-(8*Menu_factor_Y),
((44*6*Menu_Facteur_X)-width*Menu_Facteur_X*6)+1, ((44*6*Menu_factor_X)-width*Menu_factor_X*6)+1,
// 44 = Nb max de char (+1 pour éviter les plantages en mode X // 44 = Nb max de char (+1 pour éviter les plantages en mode X
// causés par une largeur = 0) // causés par une largeur = 0)
Menu_Facteur_Y<<3, Menu_factor_Y<<3,
CM_Noir); MC_Black);
} }
UpdateRect(Fenetre_Pos_X+13*Menu_Facteur_X,Fenetre_Pos_Y+19*Menu_Facteur_Y,44*6*Menu_Facteur_X,16*8*Menu_Facteur_Y); Update_rect(Window_pos_X+13*Menu_factor_X,Window_pos_Y+19*Menu_factor_Y,44*6*Menu_factor_X,16*8*Menu_factor_Y);
} }
void Scroller_aide(T_Bouton_scroller * scroller) void Scroll_help(T_Scroller_button * scroller)
{ {
Effacer_curseur(); Hide_cursor();
scroller->Position=Position_d_aide_en_cours; scroller->Position=Help_position;
Calculer_hauteur_curseur_jauge(scroller); Compute_slider_cursor_height(scroller);
Fenetre_Dessiner_jauge(scroller); Window_draw_slider(scroller);
Afficher_aide(); Display_help();
Afficher_curseur(); Display_cursor();
} }
void Bouton_Aide(void) void Button_Help(void)
{ {
short Numero_bouton; short btn_number;
// Aide contextuelle // Aide contextuelle
if (Touche!=0) if (Key!=0)
{ {
Numero_bouton = Numero_bouton_sous_souris(); btn_number = Button_under_mouse();
if (Numero_bouton != -1) if (btn_number != -1)
{ {
Fenetre_aide(Numero_bouton, NULL); Window_help(btn_number, NULL);
return; return;
} }
} }
Fenetre_aide(-1, NULL); Window_help(-1, NULL);
} }
// Ouvre l'ecran d'aide. Passer -1 pour la section par défaut (ou derniere,) // Ouvre l'ecran d'aide. Passer -1 pour la section par défaut (ou derniere,)
// Ou un nombre de l'enumération NUMEROS_DE_BOUTONS pour l'aide contextuelle. // Ou un nombre de l'enumération BUTTON_NUMBERS pour l'aide contextuelle.
void Fenetre_aide(int section, const char *Sous_section) void Window_help(int section, const char *sub_section)
{ {
short Bouton_clicke; short clicked_button;
short Nb_lignes; short nb_lines;
T_Bouton_scroller * scroller; T_Scroller_button * scroller;
if (section!=-1) if (section!=-1)
{ {
Section_d_aide_en_cours = 4 + section; Current_help_section = 4 + section;
Position_d_aide_en_cours = 0; Help_position = 0;
} }
Nb_lignes=Table_d_aide[Section_d_aide_en_cours].Nombre_de_lignes; nb_lines=Help_section[Current_help_section].Length;
if (section!=-1 && Sous_section!=NULL) if (section!=-1 && sub_section!=NULL)
{ {
int Indice=0; int index=0;
for (Indice=0; Indice<Nb_lignes; Indice++) for (index=0; index<nb_lines; index++)
if (Table_d_aide[Section_d_aide_en_cours].Table_aide[Indice].Line_type == 'T' && if (Help_section[Current_help_section].Help_table[index].Line_type == 'T' &&
!strcmp(Table_d_aide[Section_d_aide_en_cours].Table_aide[Indice].Text, Sous_section)) !strcmp(Help_section[Current_help_section].Help_table[index].Text, sub_section))
{ {
Position_d_aide_en_cours = Indice; Help_position = index;
break; break;
} }
} }
Ouvrir_fenetre(310,175,"Help / About..."); Open_window(310,175,"Help / About...");
// dessiner de la fenêtre où va défiler le texte // dessiner de la fenêtre où va défiler le texte
Fenetre_Afficher_cadre_creux(8,17,274,132); Window_display_frame_in(8,17,274,132);
Block(Fenetre_Pos_X+(Menu_Facteur_X*9), Block(Window_pos_X+(Menu_factor_X*9),
Fenetre_Pos_Y+(Menu_Facteur_Y*18), Window_pos_Y+(Menu_factor_Y*18),
Menu_Facteur_X*272,Menu_Facteur_Y*130,CM_Noir); Menu_factor_X*272,Menu_factor_Y*130,MC_Black);
Fenetre_Definir_bouton_normal(266,153,35,14,"Exit",0,1,TOUCHE_ESC); // 1 Window_set_normal_button(266,153,35,14,"Exit",0,1,KEY_ESC); // 1
scroller=Fenetre_Definir_bouton_scroller(290,18,130,Nb_lignes, scroller=Window_set_scroller_button(290,18,130,nb_lines,
16,Position_d_aide_en_cours); // 2 16,Help_position); // 2
Fenetre_Definir_bouton_normal( 9,154, 6*8,14,"About" ,1,1,SDLK_a); // 3 Window_set_normal_button( 9,154, 6*8,14,"About" ,1,1,SDLK_a); // 3
Fenetre_Definir_bouton_normal( 9+6*8+4,154, 8*8,14,"License",1,1,SDLK_l); // 4 Window_set_normal_button( 9+6*8+4,154, 8*8,14,"License",1,1,SDLK_l); // 4
Fenetre_Definir_bouton_normal( 9+6*8+4+8*8+4,154, 5*8,14,"Help",1,1,SDLK_h); // 5 Window_set_normal_button( 9+6*8+4+8*8+4,154, 5*8,14,"Help",1,1,SDLK_h); // 5
Fenetre_Definir_bouton_normal(9+6*8+4+8*8+4+5*8+4,154, 8*8,14,"Credits",1,1,SDLK_c); // 6 Window_set_normal_button(9+6*8+4+8*8+4+5*8+4,154, 8*8,14,"Credits",1,1,SDLK_c); // 6
Fenetre_Definir_bouton_special(9,18,272,130); // 7 Window_set_special_button(9,18,272,130); // 7
Afficher_aide(); Display_help();
UpdateRect(Fenetre_Pos_X,Fenetre_Pos_Y,310*Menu_Facteur_X,175*Menu_Facteur_Y); Update_rect(Window_pos_X,Window_pos_Y,310*Menu_factor_X,175*Menu_factor_Y);
Afficher_curseur(); Display_cursor();
do do
{ {
Bouton_clicke=Fenetre_Bouton_clicke(); clicked_button=Window_clicked_button();
switch (Bouton_clicke) switch (clicked_button)
{ {
case -1: case -1:
case 0: case 0:
@ -463,187 +463,187 @@ void Fenetre_aide(int section, const char *Sous_section)
break; break;
case 7: // Zone de texte case 7: // Zone de texte
{ {
int line = ((Mouse_Y-Fenetre_Pos_Y)/Menu_Facteur_Y - 18)/8; int line = ((Mouse_Y-Window_pos_Y)/Menu_factor_Y - 18)/8;
Attendre_fin_de_click(); Wait_end_of_click();
if (line == ((Mouse_Y-Fenetre_Pos_Y)/Menu_Facteur_Y - 18)/8) if (line == ((Mouse_Y-Window_pos_Y)/Menu_factor_Y - 18)/8)
{ {
if (Position_d_aide_en_cours+line<Nb_lignes) if (Help_position+line<nb_lines)
{ {
switch (Table_d_aide[Section_d_aide_en_cours].Table_aide[Position_d_aide_en_cours+line].Line_type) switch (Help_section[Current_help_section].Help_table[Help_position+line].Line_type)
{ {
case 'K': case 'K':
Fenetre_controle(Table_d_aide[Section_d_aide_en_cours].Table_aide[Position_d_aide_en_cours+line].Line_parameter); Window_set_shortcut(Help_section[Current_help_section].Help_table[Help_position+line].Line_parameter);
break; break;
// Ici on peut gérer un cas 'lien hypertexte' // Ici on peut gérer un cas 'lien hypertexte'
default: default:
break; break;
} }
Effacer_curseur(); Hide_cursor();
Afficher_aide(); Display_help();
Afficher_curseur(); Display_cursor();
} }
} }
break; break;
} }
default: default:
Effacer_curseur(); Hide_cursor();
if (Bouton_clicke>2) if (clicked_button>2)
{ {
Section_d_aide_en_cours=Bouton_clicke-3; Current_help_section=clicked_button-3;
Position_d_aide_en_cours=0; Help_position=0;
Nb_lignes=Table_d_aide[Section_d_aide_en_cours].Nombre_de_lignes; nb_lines=Help_section[Current_help_section].Length;
scroller->Position=0; scroller->Position=0;
scroller->Nb_elements=Nb_lignes; scroller->Nb_elements=nb_lines;
Calculer_hauteur_curseur_jauge(scroller); Compute_slider_cursor_height(scroller);
Fenetre_Dessiner_jauge(scroller); Window_draw_slider(scroller);
} }
else else
Position_d_aide_en_cours=Fenetre_Attribut2; Help_position=Window_attribute2;
Afficher_aide(); Display_help();
Afficher_curseur(); Display_cursor();
} }
// Gestion des touches de déplacement dans la liste // Gestion des touches de déplacement dans la liste
switch (Touche) switch (Key)
{ {
case SDLK_UP : // Haut case SDLK_UP : // Haut
if (Position_d_aide_en_cours>0) if (Help_position>0)
Position_d_aide_en_cours--; Help_position--;
Scroller_aide(scroller); Scroll_help(scroller);
Touche=0; Key=0;
break; break;
case SDLK_DOWN : // Bas case SDLK_DOWN : // Bas
if (Position_d_aide_en_cours<Nb_lignes-16) if (Help_position<nb_lines-16)
Position_d_aide_en_cours++; Help_position++;
Scroller_aide(scroller); Scroll_help(scroller);
Touche=0; Key=0;
break; break;
case SDLK_PAGEUP : // PageUp case SDLK_PAGEUP : // PageUp
if (Position_d_aide_en_cours>15) if (Help_position>15)
Position_d_aide_en_cours-=15; Help_position-=15;
else else
Position_d_aide_en_cours=0; Help_position=0;
Scroller_aide(scroller); Scroll_help(scroller);
Touche=0; Key=0;
break; break;
case (TOUCHE_MOUSEWHEELUP) : // WheelUp case (KEY_MOUSEWHEELUP) : // WheelUp
if (Position_d_aide_en_cours>3) if (Help_position>3)
Position_d_aide_en_cours-=3; Help_position-=3;
else else
Position_d_aide_en_cours=0; Help_position=0;
Scroller_aide(scroller); Scroll_help(scroller);
Touche=0; Key=0;
break; break;
case SDLK_PAGEDOWN : // PageDown case SDLK_PAGEDOWN : // PageDown
if (Nb_lignes>16) if (nb_lines>16)
{ {
if (Position_d_aide_en_cours<Nb_lignes-16-15) if (Help_position<nb_lines-16-15)
Position_d_aide_en_cours+=15; Help_position+=15;
else else
Position_d_aide_en_cours=Nb_lignes-16; Help_position=nb_lines-16;
Scroller_aide(scroller); Scroll_help(scroller);
Touche=0; Key=0;
} }
break; break;
case (TOUCHE_MOUSEWHEELDOWN) : // Wheeldown case (KEY_MOUSEWHEELDOWN) : // Wheeldown
if (Nb_lignes>16) if (nb_lines>16)
{ {
if (Position_d_aide_en_cours<Nb_lignes-16-3) if (Help_position<nb_lines-16-3)
Position_d_aide_en_cours+=3; Help_position+=3;
else else
Position_d_aide_en_cours=Nb_lignes-16; Help_position=nb_lines-16;
Scroller_aide(scroller); Scroll_help(scroller);
Touche=0; Key=0;
} }
break; break;
case SDLK_HOME : // Home case SDLK_HOME : // Home
Position_d_aide_en_cours=0; Help_position=0;
Scroller_aide(scroller); Scroll_help(scroller);
Touche=0; Key=0;
break; break;
case SDLK_END : // End case SDLK_END : // End
if (Nb_lignes>16) if (nb_lines>16)
{ {
Position_d_aide_en_cours=Nb_lignes-16; Help_position=nb_lines-16;
Scroller_aide(scroller); Scroll_help(scroller);
Touche=0; Key=0;
} }
break; break;
} }
} }
while ((Bouton_clicke!=1) && (Touche!=SDLK_RETURN)); while ((clicked_button!=1) && (Key!=SDLK_RETURN));
if(Touche==SDLK_RETURN) Touche=0; if(Key==SDLK_RETURN) Key=0;
Fermer_fenetre(); Close_window();
Desenclencher_bouton(BOUTON_AIDE); Unselect_bouton(BUTTON_HELP);
Afficher_curseur(); Display_cursor();
} }
#define STATS_COULEUR_TITRES CM_Blanc #define STATS_TITLE_COLOR MC_White
#define STATS_COULEUR_DONNEES CM_Clair #define STATS_DATA_COLOR MC_Light
void Bouton_Stats(void) void Button_Stats(void)
{ {
short Bouton_clicke; short clicked_button;
char Buffer[37]; char buffer[37];
dword Utilisation_couleur[256]; dword color_usage[256];
unsigned long long freeRam; unsigned long long freeRam;
qword mem_size = 0; qword mem_size = 0;
Ouvrir_fenetre(310,174,"Statistics"); Open_window(310,174,"Statistics");
// Dessin de la fenetre ou va s'afficher le texte // Dessin de la fenetre ou va s'afficher le texte
Fenetre_Afficher_cadre_creux(8,17,294,132); Window_display_frame_in(8,17,294,132);
Block(Fenetre_Pos_X+(Menu_Facteur_X*9), Block(Window_pos_X+(Menu_factor_X*9),
Fenetre_Pos_Y+(Menu_Facteur_Y*18), Window_pos_Y+(Menu_factor_Y*18),
Menu_Facteur_X*292,Menu_Facteur_Y*130,CM_Noir); Menu_factor_X*292,Menu_factor_Y*130,MC_Black);
Fenetre_Definir_bouton_normal(120,153,70,14,"OK",0,1,TOUCHE_ESC); // 1 Window_set_normal_button(120,153,70,14,"OK",0,1,KEY_ESC); // 1
// Affichage du numéro de version // Affichage du numéro de version
Print_dans_fenetre(10,19,"Program version:",STATS_COULEUR_TITRES,CM_Noir); Print_in_window(10,19,"Program version:",STATS_TITLE_COLOR,MC_Black);
sprintf(Buffer,"GrafX 2.00 %s%s",ALPHA_BETA,POURCENTAGE_VERSION); sprintf(buffer,"GrafX 2.00 %s%s",ALPHA_BETA,PERCENTAGE_VERSION);
Print_dans_fenetre(146,19,Buffer,STATS_COULEUR_DONNEES,CM_Noir); Print_in_window(146,19,buffer,STATS_DATA_COLOR,MC_Black);
Print_dans_fenetre(10,27,"SVN revision #:",STATS_COULEUR_TITRES,CM_Noir); Print_in_window(10,27,"SVN revision #:",STATS_TITLE_COLOR,MC_Black);
Print_dans_fenetre(146,27,SVN_revision,STATS_COULEUR_DONNEES,CM_Noir); Print_in_window(146,27,SVN_revision,STATS_DATA_COLOR,MC_Black);
Print_dans_fenetre(10,35,"Build options:",STATS_COULEUR_TITRES,CM_Noir); Print_in_window(10,35,"Build options:",STATS_TITLE_COLOR,MC_Black);
Print_dans_fenetre(146,35,Support_TrueType()?"TTF fonts":"no TTF fonts",STATS_COULEUR_DONNEES,CM_Noir); Print_in_window(146,35,TrueType_is_supported()?"TTF fonts":"no TTF fonts",STATS_DATA_COLOR,MC_Black);
// Affichage de la mémoire restante // Affichage de la mémoire restante
Print_dans_fenetre(10,51,"Free memory: ",STATS_COULEUR_TITRES,CM_Noir); Print_in_window(10,51,"Free memory: ",STATS_TITLE_COLOR,MC_Black);
freeRam = Memoire_libre(); freeRam = Memory_free();
if(freeRam > (100ULL*1024*1024*1024)) if(freeRam > (100ULL*1024*1024*1024))
sprintf(Buffer,"%u Gigabytes",(unsigned int)(freeRam/(1024*1024*1024))); sprintf(buffer,"%u Gigabytes",(unsigned int)(freeRam/(1024*1024*1024)));
else if(freeRam > (100*1024*1024)) else if(freeRam > (100*1024*1024))
sprintf(Buffer,"%u Megabytes",(unsigned int)(freeRam/(1024*1024))); sprintf(buffer,"%u Megabytes",(unsigned int)(freeRam/(1024*1024)));
else if(freeRam > 100*1024) else if(freeRam > 100*1024)
sprintf(Buffer,"%u Kilobytes",(unsigned int)(freeRam/1024)); sprintf(buffer,"%u Kilobytes",(unsigned int)(freeRam/1024));
else else
sprintf(Buffer,"%u bytes",(unsigned int)freeRam); sprintf(buffer,"%u bytes",(unsigned int)freeRam);
Print_dans_fenetre(114,51,Buffer,STATS_COULEUR_DONNEES,CM_Noir); Print_in_window(114,51,buffer,STATS_DATA_COLOR,MC_Black);
// Affichage de l'espace disque libre // Affichage de l'espace disque libre
sprintf(Buffer,"Free space on %c:",Principal_Repertoire_courant[0]); sprintf(buffer,"Free space on %c:",Main_current_directory[0]);
Print_dans_fenetre(10,67,Buffer,STATS_COULEUR_TITRES,CM_Noir); Print_in_window(10,67,buffer,STATS_TITLE_COLOR,MC_Black);
#if defined(__WIN32__) #if defined(__WIN32__)
{ {
ULARGE_INTEGER tailleU; ULARGE_INTEGER tailleU;
GetDiskFreeSpaceEx(Principal_Repertoire_courant,&tailleU,NULL,NULL); GetDiskFreeSpaceEx(Main_current_directory,&tailleU,NULL,NULL);
mem_size = tailleU.QuadPart; mem_size = tailleU.QuadPart;
} }
#elif defined(__linux__) || defined(__macosx__) || defined(__FreeBSD__) #elif defined(__linux__) || defined(__macosx__) || defined(__FreeBSD__)
// Note: under MacOSX, both macros are defined anyway. // Note: under MacOSX, both macros are defined anyway.
{ {
struct statfs Informations_Disque; struct statfs disk_info;
statfs(Principal_Repertoire_courant,&Informations_Disque); statfs(Main_current_directory,&disk_info);
mem_size=(qword) Informations_Disque.f_bfree * (qword) Informations_Disque.f_bsize; mem_size=(qword) disk_info.f_bfree * (qword) disk_info.f_bsize;
} }
#else #else
// Free disk space is only for shows. Other platforms can display 0. // Free disk space is only for shows. Other platforms can display 0.
@ -652,48 +652,48 @@ void Bouton_Stats(void)
#endif #endif
if(mem_size > (100ULL*1024*1024*1024)) if(mem_size > (100ULL*1024*1024*1024))
sprintf(Buffer,"%u Gigabytes",(unsigned int)(mem_size/(1024*1024*1024))); sprintf(buffer,"%u Gigabytes",(unsigned int)(mem_size/(1024*1024*1024)));
else if(mem_size > (100*1024*1024)) else if(mem_size > (100*1024*1024))
sprintf(Buffer,"%u Megabytes",(unsigned int)(mem_size/(1024*1024))); sprintf(buffer,"%u Megabytes",(unsigned int)(mem_size/(1024*1024)));
else if(mem_size > (100*1024)) else if(mem_size > (100*1024))
sprintf(Buffer,"%u Kilobytes",(unsigned int)(mem_size/1024)); sprintf(buffer,"%u Kilobytes",(unsigned int)(mem_size/1024));
else else
sprintf(Buffer,"%u bytes",(unsigned int)mem_size); sprintf(buffer,"%u bytes",(unsigned int)mem_size);
Print_dans_fenetre(146,67,Buffer,STATS_COULEUR_DONNEES,CM_Noir); Print_in_window(146,67,buffer,STATS_DATA_COLOR,MC_Black);
// Affichage des informations sur l'image // Affichage des informations sur l'image
Print_dans_fenetre(10,83,"Picture info.:",STATS_COULEUR_TITRES,CM_Noir); Print_in_window(10,83,"Picture info.:",STATS_TITLE_COLOR,MC_Black);
// Affichage des dimensions de l'image // Affichage des dimensions de l'image
Print_dans_fenetre(18,91,"Dimensions :",STATS_COULEUR_TITRES,CM_Noir); Print_in_window(18,91,"Dimensions :",STATS_TITLE_COLOR,MC_Black);
sprintf(Buffer,"%dx%d",Principal_Largeur_image,Principal_Hauteur_image); sprintf(buffer,"%dx%d",Main_image_width,Main_image_height);
Print_dans_fenetre(122,91,Buffer,STATS_COULEUR_DONNEES,CM_Noir); Print_in_window(122,91,buffer,STATS_DATA_COLOR,MC_Black);
// Affichage du nombre de couleur utilisé // Affichage du nombre de couleur utilisé
Print_dans_fenetre(18,99,"Colors used:",STATS_COULEUR_TITRES,CM_Noir); Print_in_window(18,99,"Colors used:",STATS_TITLE_COLOR,MC_Black);
memset(Utilisation_couleur,0,sizeof(Utilisation_couleur)); memset(color_usage,0,sizeof(color_usage));
sprintf(Buffer,"%d",Palette_Compter_nb_couleurs_utilisees(Utilisation_couleur)); sprintf(buffer,"%d",Count_used_colors(color_usage));
Print_dans_fenetre(122,99,Buffer,STATS_COULEUR_DONNEES,CM_Noir); Print_in_window(122,99,buffer,STATS_DATA_COLOR,MC_Black);
// Affichage des dimensions de l'écran // Affichage des dimensions de l'écran
Print_dans_fenetre(10,115,"Resolution:",STATS_COULEUR_TITRES,CM_Noir); Print_in_window(10,115,"Resolution:",STATS_TITLE_COLOR,MC_Black);
sprintf(Buffer,"%dx%d",Largeur_ecran,Hauteur_ecran); sprintf(buffer,"%dx%d",Screen_width,Screen_height);
Print_dans_fenetre(106,115,Buffer,STATS_COULEUR_DONNEES,CM_Noir); Print_in_window(106,115,buffer,STATS_DATA_COLOR,MC_Black);
UpdateRect(Fenetre_Pos_X,Fenetre_Pos_Y,Menu_Facteur_X*310,Menu_Facteur_Y*174); Update_rect(Window_pos_X,Window_pos_Y,Menu_factor_X*310,Menu_factor_Y*174);
Afficher_curseur(); Display_cursor();
do do
{ {
Bouton_clicke=Fenetre_Bouton_clicke(); clicked_button=Window_clicked_button();
} }
while ( (Bouton_clicke!=1) && (Touche!=SDLK_RETURN) ); while ( (clicked_button!=1) && (Key!=SDLK_RETURN) );
if(Touche==SDLK_RETURN)Touche=0; if(Key==SDLK_RETURN)Key=0;
Fermer_fenetre(); Close_window();
Desenclencher_bouton(BOUTON_AIDE); Unselect_bouton(BUTTON_HELP);
Afficher_curseur(); Display_cursor();
} }

8
aide.h
View File

@ -27,19 +27,19 @@
If the mouse is over a button, its contextual help will be displayed. If the mouse is over a button, its contextual help will be displayed.
Else, the default helpscreen will be shown. Else, the default helpscreen will be shown.
*/ */
void Bouton_Aide(void); void Button_Help(void);
/*! /*!
Displays and runs the "Statistics" window Displays and runs the "Statistics" window
*/ */
void Bouton_Stats(void); void Button_Stats(void);
/*! /*!
Displays and runs the "Help / About..." window Displays and runs the "Help / About..." window
@param section Number of the help section page to display (equals the button number the mouse was hovering for the contextual help), -1 for the main help page. @param section Number of the help section page to display (equals the button number the mouse was hovering for the contextual help), -1 for the main help page.
@param Sous_section Help sub-section title (the page will be scrolled so this title is at the top). @param sub_section Help sub-section title (the page will be scrolled so this title is at the top).
*/ */
void Fenetre_aide(int section, const char * Sous_section); void Window_help(int section, const char * sub_section);
#endif #endif

5884
boutons.c

File diff suppressed because it is too large Load Diff

194
boutons.h
View File

@ -26,24 +26,24 @@
Displays an error message when calling an unavailable function. Displays an error message when calling an unavailable function.
Only used in the beta versions for things we haven't coded yet. Only used in the beta versions for things we haven't coded yet.
*/ */
void Message_Non_disponible(void); void Message_not_implemented(void);
/*! /*!
Displays an error message when there is no more memory for the requested operation. Displays an error message when there is no more memory for the requested operation.
*/ */
void Message_Memoire_insuffisante(void); void Message_out_of_memory(void);
/*! /*!
Displays the splash screen at program startup. Displays the splash screen at program startup.
*/ */
void Bouton_Message_initial(void); void Button_Message_initial(void);
/*! /*!
Changes brush shape. Changes brush shape.
This function saves the current brush shape and swith to the default one (single pixel brush) for the filler and the color picker. This function saves the current brush shape and swith to the default one (single pixel brush) for the filler and the color picker.
These functions don't need (and will not work with) a custom brush. These functions don't need (and will not work with) a custom brush.
*/ */
void Changer_la_forme_du_pinceau(byte shape); void Change_paintbrush_shape(byte shape);
// Boutons relatifs aux couleurs // Boutons relatifs aux couleurs
@ -52,37 +52,37 @@ void Changer_la_forme_du_pinceau(byte shape);
Callback for the palette scroller buttons left click. Callback for the palette scroller buttons left click.
Scrolls the menubar palette one column to the left. Scrolls the menubar palette one column to the left.
*/ */
void Bouton_Pal_left(void); void Button_Pal_left(void);
/*! /*!
Callback for the palette scroller buttons right click. Callback for the palette scroller buttons right click.
Scrolls the menubar palette faster to the left. Scrolls the menubar palette faster to the left.
*/ */
void Bouton_Pal_left_fast(void); void Button_Pal_left_fast(void);
/*! /*!
Callback for the palette scroller buttons left click. Callback for the palette scroller buttons left click.
Scrolls the menubar palette one column to the right. Scrolls the menubar palette one column to the right.
*/ */
void Bouton_Pal_right(void); void Button_Pal_right(void);
/*! /*!
Callback for the palette scroller buttons right click. Callback for the palette scroller buttons right click.
Scrolls the menubar palette faster to the right. Scrolls the menubar palette faster to the right.
*/ */
void Bouton_Pal_right_fast(void); void Button_Pal_right_fast(void);
/*! /*!
Callback for the palette color buttons left click. Callback for the palette color buttons left click.
Selects the foreground drawing color when clicking on the menubar palette. Selects the foreground drawing color when clicking on the menubar palette.
*/ */
void Bouton_Choix_forecolor(void); void Button_Select_forecolor(void);
/*! /*!
Callback for the palette color buttons right click. Callback for the palette color buttons right click.
Selects the background drawing color when clicking on the menubar palette. Selects the background drawing color when clicking on the menubar palette.
*/ */
void Bouton_Choix_backcolor(void); void Button_Select_backcolor(void);
// Boutons relatifs au pinceaux // Boutons relatifs au pinceaux
@ -90,13 +90,13 @@ void Bouton_Choix_backcolor(void);
Callback for the brush button left click. Callback for the brush button left click.
Selects the monochrome brush mode when right clicking on the brush button. Selects the monochrome brush mode when right clicking on the brush button.
*/ */
void Bouton_Brosse_monochrome(void); void Button_Brush_monochrome(void);
/*! /*!
Callback for the brush button right click. Callback for the brush button right click.
Displays the "Paintbrush menu". Displays the "Paintbrush menu".
*/ */
void Bouton_Menu_pinceaux(void); void Button_Paintbrush_menu(void);
// Boutons relatifs au mode de dessin à main levée // Boutons relatifs au mode de dessin à main levée
@ -104,13 +104,13 @@ void Bouton_Menu_pinceaux(void);
Callback for the freehand draw button left click. Callback for the freehand draw button left click.
Selects freehand drawing mode, depending on the current state of the freehand button. Selects freehand drawing mode, depending on the current state of the freehand button.
*/ */
void Bouton_Dessin(void); void Button_Draw(void);
/*! /*!
Callback for the freehand draw button right click. Callback for the freehand draw button right click.
Cycles the drawing modes for the freehand tool. Cycles the drawing modes for the freehand tool.
*/ */
void Bouton_Dessin_Switch_mode(void); void Button_Draw_switch_mode(void);
// Dessin par ligne // Dessin par ligne
@ -118,34 +118,34 @@ void Bouton_Dessin_Switch_mode(void);
Callback for the lines button left click. Callback for the lines button left click.
Selects lines drawing mode, depending on the current state of the lines button. Selects lines drawing mode, depending on the current state of the lines button.
*/ */
void Bouton_Lignes(void); void Button_Lines(void);
/*! /*!
Callback for the lines button right click. Callback for the lines button right click.
Cycles the drawing modes for the lines tool. Cycles the drawing modes for the lines tool.
*/ */
void Bouton_Lignes_Switch_mode(void); void Button_Lines_switch_mode(void);
// Bouton relatif au remplissage // Button relatif au remplissage
/*! /*!
Callback for the fill button left click. Callback for the fill button left click.
Start the filling operation. Start the filling operation.
*/ */
void Bouton_Fill(void); void Button_Fill(void);
/*! /*!
Callback for the fill button right click. Callback for the fill button right click.
Start the color replace operation. Start the color replace operation.
*/ */
void Bouton_Remplacer(void); void Button_Replace(void);
/*! /*!
Disable and release the fill button. Disable and release the fill button.
Restores the cursor (custom brushes are disabled for the fill operation). Restores the cursor (custom brushes are disabled for the fill operation).
Cleans the status bar if the color replacement tool put a preview color inside it. Cleans the status bar if the color replacement tool put a preview color inside it.
*/ */
void Bouton_desenclencher_Fill(void); void Button_Unselect_fill(void);
// Spray // Spray
@ -153,13 +153,13 @@ void Bouton_desenclencher_Fill(void);
Callback for the spray button left click. Callback for the spray button left click.
Start the spray operation. Start the spray operation.
*/ */
void Bouton_Spray(void); void Button_Airbrush(void);
/*! /*!
Callback for the spray button right click. Callback for the spray button right click.
Opens the spray's setup menu. Opens the spray's setup menu.
*/ */
void Bouton_Spray_Menu(void); void Button_Airbrush_menu(void);
// Courbes de Bézier // Courbes de Bézier
@ -167,13 +167,13 @@ void Bouton_Spray_Menu(void);
Callback for the curves button left click. Callback for the curves button left click.
Start curve operation according to the selected mode. Start curve operation according to the selected mode.
*/ */
void Bouton_Courbes(void); void Button_Curves(void);
/*! /*!
Callback for the curves button right click. Callback for the curves button right click.
Select the curve mode (1-point, 2-point) Select the curve mode (1-point, 2-point)
*/ */
void Bouton_Courbes_Switch_mode(void); void Button_Curves_switch_mode(void);
// Boutons relatifs aux rectangles pleins et vides // Boutons relatifs aux rectangles pleins et vides
@ -181,13 +181,13 @@ void Bouton_Courbes_Switch_mode(void);
Callback for the empty rectangle button. Callback for the empty rectangle button.
Start the rectangle operation. Start the rectangle operation.
*/ */
void Bouton_Rectangle_vide(void); void Button_Empty_rectangle(void);
/*! /*!
Callback for the filled rectangle button. Callback for the filled rectangle button.
Start the filled rectangle operation. Start the filled rectangle operation.
*/ */
void Bouton_Rectangle_plein(void); void Button_Filled_rectangle(void);
// Boutons relatifs au texte // Boutons relatifs au texte
@ -195,7 +195,7 @@ void Bouton_Rectangle_plein(void);
Callback for the text button. Callback for the text button.
Opens the text setup window. Opens the text setup window.
*/ */
void Bouton_Texte(void); void Button_Text(void);
// Boutons relatifs aux dégradés // Boutons relatifs aux dégradés
@ -203,13 +203,13 @@ void Bouton_Texte(void);
Callback for the gradation button. Callback for the gradation button.
Opens the "Gradation menu". Opens the "Gradation menu".
*/ */
void Bouton_Degrades(void); void Button_Gradients(void);
/*! /*!
Gets the informations from the gradations table and set the global vars for the current gradation. Gets the informations from the gradations table and set the global vars for the current gradation.
@param Indice index of the selected gradation @param index index of the selected gradation
*/ */
void Degrade_Charger_infos_du_tableau(int Indice); void Load_gradient_data(int index);
// Boutons relatifs aux cercles (ellipses) dégradé(e)s // Boutons relatifs aux cercles (ellipses) dégradé(e)s
@ -217,19 +217,19 @@ void Degrade_Charger_infos_du_tableau(int Indice);
Callback for the gradation circle button left click. Callback for the gradation circle button left click.
Starts drawing a gradation circle. Starts drawing a gradation circle.
*/ */
void Bouton_Cercle_degrade(void); void Button_Grad_circle(void);
/*! /*!
Callback for the gradation circle right click. Callback for the gradation circle right click.
Starts drawing a gradation ellipsis. Starts drawing a gradation ellipsis.
*/ */
void Bouton_Ellipse_degrade(void); void Button_Grad_ellipse(void);
/*! /*!
Callback for the gradation rectangle button. Callback for the gradation rectangle button.
Starts the gradation rectangle drawing operation. Starts the gradation rectangle drawing operation.
*/ */
void Bouton_Rectangle_degrade(void); void Button_Grad_rectangle(void);
// Boutons relatifs aux cercles (ellipses) plein(e)s et vides // Boutons relatifs aux cercles (ellipses) plein(e)s et vides
@ -237,25 +237,25 @@ void Bouton_Rectangle_degrade(void);
Callback for the circle button left click. Callback for the circle button left click.
Starts drawing an empty circle Starts drawing an empty circle
*/ */
void Bouton_Cercle_vide(void); void Button_Empty_circle(void);
/*! /*!
Callback for the circle button left click. Callback for the circle button left click.
Starts drawing an empty ellipsis Starts drawing an empty ellipsis
*/ */
void Bouton_Ellipse_vide(void); void Button_Empty_ellipse(void);
/*! /*!
Callback for the filled circle button ledt click. Callback for the filled circle button ledt click.
Starts drawing a filled circle. Starts drawing a filled circle.
*/ */
void Bouton_Cercle_plein(void); void Button_Filled_circle(void);
/*! /*!
Callback for the filled circle right click. Callback for the filled circle right click.
Starts drawing a filled ellipsis. Starts drawing a filled ellipsis.
*/ */
void Bouton_Ellipse_pleine(void); void Button_Filled_ellipse(void);
// Boutons relatifs aux polygones vides et pleins // Boutons relatifs aux polygones vides et pleins
@ -263,25 +263,25 @@ void Bouton_Ellipse_pleine(void);
Callback for the polyline button left click. Callback for the polyline button left click.
Starts drawing a polygon. Starts drawing a polygon.
*/ */
void Bouton_Polygone(void); void Button_polygon(void);
/*! /*!
Callback for the polyline right click. Callback for the polyline right click.
Starts drawing a polyform. Starts drawing a polyform.
*/ */
void Bouton_Polyform(void); void Button_Polyform(void);
/*! /*!
Callback for the polyfill button left click. Callback for the polyfill button left click.
Starts drawing a filled polygon. Starts drawing a filled polygon.
*/ */
void Bouton_Polyfill(void); void Button_Polyfill(void);
/*! /*!
Callback for the polyfill button right click. Callback for the polyfill button right click.
Starts drawing a filled polyform. Starts drawing a filled polyform.
*/ */
void Bouton_Filled_polyform(void); void Button_Filled_polyform(void);
// Boutons d'ajustement de l'image // Boutons d'ajustement de l'image
@ -289,7 +289,7 @@ void Bouton_Filled_polyform(void);
Callback for the adjust picture button. Callback for the adjust picture button.
Start the adjust picture operation. Start the adjust picture operation.
*/ */
void Bouton_Ajuster(void); void Button_Adjust(void);
// Gestion du mode Shade // Gestion du mode Shade
@ -297,19 +297,19 @@ void Bouton_Ajuster(void);
Callback for the shade button (in the FX window). Callback for the shade button (in the FX window).
Toogle the shade mode. Toogle the shade mode.
*/ */
void Bouton_Shade_Mode(void); void Button_Shade_mode(void);
/*! /*!
Callback for the QSHade button (in the FX window). Callback for the QSHade button (in the FX window).
Toogle the Quick Shade effect. Toogle the Quick Shade effect.
*/ */
void Bouton_Quick_shade_Mode(void); void Button_Quick_shade_mode(void);
/*! /*!
Callback for the Shade button (in the FX window) right click. Callback for the Shade button (in the FX window) right click.
Displays the shade setup menu. Displays the shade setup menu.
*/ */
void Bouton_Shade_Menu(void); void Button_Shade_menu(void);
// Gestion du Stencil // Gestion du Stencil
@ -317,13 +317,13 @@ void Bouton_Shade_Menu(void);
Callback for the Stencil button (in the FX window) left click. Callback for the Stencil button (in the FX window) left click.
Toogle stencil mode. Toogle stencil mode.
*/ */
void Bouton_Stencil_Mode(void); void Button_Stencil_mode(void);
/*! /*!
Callback for the Stencil button (in the FX window) right click. Callback for the Stencil button (in the FX window) right click.
Displays the stencil setup menu. Displays the stencil setup menu.
*/ */
void Bouton_Menu_Stencil(void); void Button_Stencil_menu(void);
// Gestion du Masque // Gestion du Masque
@ -331,13 +331,13 @@ void Bouton_Menu_Stencil(void);
Callback for the Mask button (in the FX window) left click. Callback for the Mask button (in the FX window) left click.
Toogles the mask mode/ Toogles the mask mode/
*/ */
void Bouton_Mask_Mode(void); void Button_Mask_mode(void);
/*! /*!
Callback for the Mask button (in the FX window) right click. Callback for the Mask button (in the FX window) right click.
Displays the mask setup menu. Displays the mask setup menu.
*/ */
void Bouton_Mask_Menu(void); void Button_Mask_menu(void);
// Mode grille (Snap) // Mode grille (Snap)
@ -346,38 +346,38 @@ void Bouton_Mask_Menu(void);
Toogle the grid. Toogle the grid.
*/ */
void Bouton_Snap_Mode(void); void Button_Snap_mode(void);
/*! /*!
Callback for the Grid button (in the FX window) right click. Callback for the Grid button (in the FX window) right click.
Displays the grid setup menu. Displays the grid setup menu.
*/ */
void Bouton_Menu_Grille(void); void Button_Grid_menu(void);
// Mode trame (Sieve) // Mode trame (Sieve)
/*! /*!
In the sieve window, copy one of the presets patterns to the current one. In the sieve window, copy one of the presets patterns to the current one.
@param Indice Index of the pattern to copy @param index Index of the pattern to copy
*/ */
void Copier_trame_predefinie(byte Indice); void Copy_preset_sieve(byte index);
/*! /*!
In the sieve window, swaps black and white in the current pattern. In the sieve window, swaps black and white in the current pattern.
*/ */
void Inverser_trame(void); void Invert_trame(void);
/*! /*!
Callback for the Sieve button (in the FX window) left click. Callback for the Sieve button (in the FX window) left click.
Toogle sieve mode. Toogle sieve mode.
*/ */
void Bouton_Trame_Mode(void); void Button_Trame_mode(void);
/*! /*!
Callback for the Sieve button (in the FX window) right click. Callback for the Sieve button (in the FX window) right click.
Displays the sieve setup menu. Displays the sieve setup menu.
*/ */
void Bouton_Trame_Menu(void); void Button_Trame_menu(void);
// Mode Smooth // Mode Smooth
@ -385,13 +385,13 @@ void Bouton_Trame_Menu(void);
Callback for the smooth button (in the FX window) left click. Callback for the smooth button (in the FX window) left click.
Toogles smooth mode. Toogles smooth mode.
*/ */
void Bouton_Smooth_Mode(void); void Button_Smooth_mode(void);
/*! /*!
Callback for the Smooth button (in the FX window) right click. Callback for the Smooth button (in the FX window) right click.
Displays the smooth setup menu. Displays the smooth setup menu.
*/ */
void Bouton_Smooth_Mode(void); void Button_Smooth_mode(void);
// Boutons relatifs au mode Colorize // Boutons relatifs au mode Colorize
@ -399,19 +399,19 @@ void Bouton_Smooth_Mode(void);
Computes the tables used by the transparency/colorize mode. Computes the tables used by the transparency/colorize mode.
These tables are used to match the drawing color*picture color to the color that is painted on screen. These tables are used to match the drawing color*picture color to the color that is painted on screen.
*/ */
void Calculer_les_tables_de_Colorize(void); void Compute_colorize_table(void);
/*! /*!
Callback for the Tranparency button (in the FX window) left click. Callback for the Tranparency button (in the FX window) left click.
Toogles transparent drawing mode. Toogles transparent drawing mode.
*/ */
void Bouton_Colorize_Mode(void); void Button_Colorize_mode(void);
/*! /*!
Callback for the Transparency button (in the FX window) right click. Callback for the Transparency button (in the FX window) right click.
Displays the tranparency setup menu. Displays the tranparency setup menu.
*/ */
void Bouton_Colorize_Menu(void); void Button_Colorize_menu(void);
// Boutons relatifs au mode Tiling // Boutons relatifs au mode Tiling
@ -419,20 +419,20 @@ void Bouton_Colorize_Menu(void);
Callback for the Tiling button (in the FX window) left click. Callback for the Tiling button (in the FX window) left click.
Toogles tiling mode. Toogles tiling mode.
*/ */
void Bouton_Tiling_Mode(void); void Button_Tiling_mode(void);
/*! /*!
Callback for the Tiling button (in the FX window) right click. Callback for the Tiling button (in the FX window) right click.
Displays the tiling setup menu. Displays the tiling setup menu.
*/ */
void Bouton_Tiling_Menu(void); void Button_Tiling_menu(void);
// Menu des effets // Menu des effets
/*! /*!
Callback for the effects button click. Callback for the effects button click.
Displays the effect selection menu. Displays the effect selection menu.
*/ */
void Bouton_Effets(void); void Button_Effects(void);
// Prise de brosse // Prise de brosse
@ -440,172 +440,172 @@ void Bouton_Effets(void);
Callback for the brush button left click. Callback for the brush button left click.
Start the brush picking operation. Start the brush picking operation.
*/ */
void Bouton_Brosse(void); void Button_Brush(void);
/*! /*!
Callback for the brush button right click. Callback for the brush button right click.
Activates the last captured custom brush. Activates the last captured custom brush.
*/ */
void Bouton_Restaurer_brosse(void); void Button_Restore_brush(void);
/*! /*!
Disables the custom brush and set back a regular one. Disables the custom brush and set back a regular one.
*/ */
void Bouton_desenclencher_Brosse(void); void Button_Unselect_brush(void);
// Prise de brosse au lasso // Prise de brosse au lasso
/*! /*!
Callback for the freehand brush pick button left click. Callback for the freehand brush pick button left click.
Starts freehand brush picking operation. Starts freehand brush picking operation.
*/ */
void Bouton_Lasso(void); void Button_Lasso(void);
/*! /*!
Disables the custom freehand brush and set back a regular one. Disables the custom freehand brush and set back a regular one.
*/ */
void Bouton_desenclencher_Lasso(void); void Button_Unselect_lasso(void);
// Bouton relatifs à la pipette // Button relatifs à la pipette
/*! /*!
Starts the color picking operation. Starts the color picking operation.
*/ */
void Bouton_Pipette(void); void Button_Colorpicker(void);
/*! /*!
Disables the color picker button and get back to the previously selected drawing mode. Disables the color picker button and get back to the previously selected drawing mode.
*/ */
void Bouton_desenclencher_Pipette(void); void Button_Unselect_colorpicker(void);
/*! /*!
Swap fore- and background colors. Swap fore- and background colors.
*/ */
void Bouton_Inverser_foreback(void); void Button_Invert_foreback(void);
// Mode loupe // Mode loupe
/*! /*!
Enters magnify mode. Enters magnify mode.
*/ */
void Bouton_Loupe(void); void Button_Magnify(void);
/*! /*!
Displays magnify menu. Displays magnify menu.
*/ */
void Bouton_Menu_Loupe(void); void Button_Magnify_menu(void);
/*! /*!
Exit magnify mode. Exit magnify mode.
*/ */
void Bouton_desenclencher_Loupe(void); void Button_Unselect_magnifier(void);
// Les différents effets sur la brosse // Les différents effets sur la brosse
/*! /*!
Display the Brush effects window. Display the Brush effects window.
*/ */
void Bouton_Brush_FX(void); void Button_Brush_FX(void);
// Boutons relatifs aux différentes pages // Boutons relatifs aux différentes pages
/*! /*!
Swap main and spare drawing pages. Swap main and spare drawing pages.
*/ */
void Bouton_Page(void); void Button_Page(void);
/*! /*!
Copy main page to spare page. Copy main page to spare page.
*/ */
void Bouton_Copy_page(void); void Button_Copy_page(void);
/*! /*!
Copy only pixel data from main page to spare page (no palette copy). Copy only pixel data from main page to spare page (no palette copy).
*/ */
void Copier_image_seule(void); void Copy_image_only(void);
/*! /*!
Kill (free from memory) the current page. Kill (free from memory) the current page.
*/ */
void Bouton_Kill(void); void Button_Kill(void);
// Boutons relatifs aux changements de résolution et de taille d'image // Boutons relatifs aux changements de résolution et de taille d'image
/*! /*!
Display the screenmode menu. Display the screenmode menu.
*/ */
void Bouton_Resol(void); void Button_Resolution(void);
/*! /*!
Set the screen to the "safe resolution" (320x200 pixel window). Set the screen to the "safe resolution" (320x200 pixel window).
*/ */
void Bouton_Safety_resol(void); void Button_Safety_resolution(void);
// Boutons relatifs aux chargements et sauvegardes // Boutons relatifs aux chargements et sauvegardes
/*! /*!
Opens the load file dialog. Opens the load file dialog.
*/ */
void Bouton_Load(void); void Button_Load(void);
/*! /*!
Reload current picture from disk. Reload current picture from disk.
*/ */
void Bouton_Reload(void); void Button_Reload(void);
/*! /*!
Open the save file dialog. Open the save file dialog.
*/ */
void Bouton_Save(void); void Button_Save(void);
/*! /*!
Saves the current file without asking for a new name. Saves the current file without asking for a new name.
*/ */
void Bouton_Autosave(void); void Button_Autosave(void);
// Réglage des paramètres de l'utilisateur // Réglage des paramètres de l'utilisateur
/*! /*!
Display the setting menu. Display the setting menu.
*/ */
void Bouton_Settings(void); void Button_Settings(void);
// Annulation de la dernière modification // Annulation de la dernière modification
/*! /*!
Undo the last modification to the picture. Undo the last modification to the picture.
*/ */
void Bouton_Undo(void); void Button_Undo(void);
/*! /*!
Redo an operation that has been undone. Redo an operation that has been undone.
*/ */
void Bouton_Redo(void); void Button_Redo(void);
// Boutons relatifs aux effacements d'images // Boutons relatifs aux effacements d'images
/*! /*!
Clear the whole screen with black (color index 0). Clear the whole screen with black (color index 0).
*/ */
void Bouton_Clear(void); void Button_Clear(void);
/*! /*!
Clear the screen with the selected backcolor. Clear the screen with the selected backcolor.
*/ */
void Bouton_Clear_colore(void); void Button_Clear_with_backcolor(void);
// Quitter le programme // Quitter le programme
/*! /*!
Quits the program. Display a requester to save the changes to the picture before exiting if the pic was modified since last save. Quits the program. Display a requester to save the changes to the picture before exiting if the pic was modified since last save.
*/ */
void Bouton_Quit(void); void Button_Quit(void);
// Cacher le menu // Cacher le menu
/*! /*!
Hides the menubar. Hides the menubar.
*/ */
void Bouton_Cacher_menu(void); void Button_Hide_menu(void);
/*! /*!
@ -622,19 +622,19 @@ void Save_picture(byte image);
/*! /*!
Generic color tagging menu, for various effects. Generic color tagging menu, for various effects.
*/ */
void Menu_Tag_couleurs(char * En_tete, byte * table, byte * mode, byte can_cancel, const char *Section_aide); void Menu_tag_colors(char * window_title, byte * table, byte * mode, byte can_cancel, const char *help_section);
/*! /*!
Display the menu for the smooth effect. Display the menu for the smooth effect.
*/ */
void Bouton_Smooth_Menu(void); void Button_Smooth_menu(void);
/*! /*!
Toogles the smear mode. Toogles the smear mode.
*/ */
void Bouton_Smear_Mode(void); void Button_Smear_mode(void);
#endif #endif

1698
brush.c

File diff suppressed because it is too large Load Diff

26
brush.h
View File

@ -24,13 +24,13 @@
/*! /*!
Gets the brush from the picture. Gets the brush from the picture.
@param Debut_X left edge coordinate in the picture @param start_x left edge coordinate in the picture
@param Debut_Y upper edge coordinate in the picture @param start_y upper edge coordinate in the picture
@param Fin_X right edge coordinate in the picture @param end_x right edge coordinate in the picture
@param Fin_Y bottom edge coordinate in the picture @param end_y bottom edge coordinate in the picture
@param clear If 1, the area is also cleared from the picture. @param clear If 1, the area is also cleared from the picture.
*/ */
void Capturer_brosse(short Debut_X,short Debut_Y,short Fin_X,short Fin_Y,short clear); void Capture_brush(short start_x,short start_y,short end_x,short end_y,short clear);
/*! /*!
Rotates the brush to the right. Rotates the brush to the right.
@ -40,30 +40,30 @@ void Rotate_90_deg(void);
/*! /*!
Stretch the brush to fit the given rectangle. Stretch the brush to fit the given rectangle.
*/ */
void Etirer_brosse(short X1, short Y1, short X2, short Y2); void Stretch_brush(short x1, short y1, short x2, short y2);
/*! /*!
Stretch the brush to fit the given rectangle. Stretch the brush to fit the given rectangle.
Uses fast approximation for the preview while drawing the rectangle on screen. Uses fast approximation for the preview while drawing the rectangle on screen.
*/ */
void Etirer_brosse_preview(short X1, short Y1, short X2, short Y2); void Stretch_brush_preview(short x1, short y1, short x2, short y2);
/*! /*!
Rotates the brush to the right from the given angle. Rotates the brush to the right from the given angle.
*/ */
void Tourner_brosse(float angle); void Rotate_brush(float angle);
/*! /*!
Stretch the brush to fit the given rectangle. Stretch the brush to fit the given rectangle.
Uses fast approximation for the preview while changing the angle. Uses fast approximation for the preview while changing the angle.
*/ */
void Tourner_brosse_preview(float angle); void Rotate_brush_preview(float angle);
/*! /*!
Remap the brush palette to the nearest color in the picture one. Remap the brush palette to the nearest color in the picture one.
Used when switching to the spare page. Used when switching to the spare page.
*/ */
void Remap_brosse(void); void Remap_brush(void);
/*! /*!
Get color indexes used by the brush. Get color indexes used by the brush.
@ -84,10 +84,10 @@ void Nibble_brush(void);
/*! /*!
Get brush from picture according to a freehand form. Get brush from picture according to a freehand form.
@param Vertices number of points in the freehand form @param vertices number of points in the freehand form
@param Points array of points coordinates @param points array of points coordinates
@param clear If set to 1, the captured area is also cleared from the picture. @param clear If set to 1, the captured area is also cleared from the picture.
*/ */
void Capturer_brosse_au_lasso(int Vertices, short * Points,short clear); void Capture_brush_with_lasso(int vertices, short * points,short clear);
#endif #endif

202
clavier.c
View File

@ -27,7 +27,7 @@
// La correspondance est bonne si le clavier est QWERTY US, ou si // La correspondance est bonne si le clavier est QWERTY US, ou si
// l'utilisateur est sous Windows. // l'utilisateur est sous Windows.
// Dans l'ordre des colonnes: Normal, +Shift, +Control, +Alt // Dans l'ordre des colonnes: Normal, +Shift, +Control, +Alt
const word Scancode_to_Sym[256][4] = const word Scancode_to_sym[256][4] =
{ {
/* 00 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN }, /* 00 ??? */ { SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN ,SDLK_UNKNOWN },
/* 01 Esc */ { SDLK_ESCAPE ,SDLK_ESCAPE ,SDLK_ESCAPE ,SDLK_ESCAPE }, /* 01 Esc */ { SDLK_ESCAPE ,SDLK_ESCAPE ,SDLK_ESCAPE ,SDLK_ESCAPE },
@ -292,74 +292,74 @@ const word Scancode_to_Sym[256][4] =
// 0x0100 shift (maintenant 0x1000) // 0x0100 shift (maintenant 0x1000)
// 0x0200 control (maintenant 0x2000) // 0x0200 control (maintenant 0x2000)
// 0x0400 alt (maintenant 0x4000) // 0x0400 alt (maintenant 0x4000)
word Touche_pour_scancode(word scancode) word Key_for_scancode(word scancode)
{ {
if (scancode & 0x0400) if (scancode & 0x0400)
return Scancode_to_Sym[scancode & 0xFF][3] | return Scancode_to_sym[scancode & 0xFF][3] |
(scancode & 0x0700) << 4; (scancode & 0x0700) << 4;
else if (scancode & 0x0200) else if (scancode & 0x0200)
return Scancode_to_Sym[scancode & 0xFF][2] | return Scancode_to_sym[scancode & 0xFF][2] |
(scancode & 0x0700) << 4; (scancode & 0x0700) << 4;
else if (scancode & 0x0100) else if (scancode & 0x0100)
return Scancode_to_Sym[scancode & 0xFF][1] | return Scancode_to_sym[scancode & 0xFF][1] |
(scancode & 0x0700) << 4; (scancode & 0x0700) << 4;
else else
return Scancode_to_Sym[scancode & 0xFF][0]; return Scancode_to_sym[scancode & 0xFF][0];
} }
// Convertit des modificateurs de touches SDL en modificateurs GrafX2 // Convertit des modificateurs de touches SDL en modificateurs GrafX2
word Modificateurs_Touche(SDLMod Mod) word Key_modifiers(SDLMod mod)
{ {
word Modificateur=0; word modifiers=0;
if (Mod & KMOD_CTRL ) if (mod & KMOD_CTRL )
Modificateur|=MOD_CTRL; modifiers|=MOD_CTRL;
if (Mod & KMOD_SHIFT ) if (mod & KMOD_SHIFT )
Modificateur|=MOD_SHIFT; modifiers|=MOD_SHIFT;
if (Mod & (KMOD_ALT|KMOD_MODE)) if (mod & (KMOD_ALT|KMOD_MODE))
Modificateur|=MOD_ALT; modifiers|=MOD_ALT;
return Modificateur; return modifiers;
} }
word Conversion_Touche(SDL_keysym Sym) word Keysym_to_keycode(SDL_keysym keysym)
{ {
word key_code = 0; word key_code = 0;
word Mod; word mod;
// On ignore shift, alt et control isolés. // On ignore shift, alt et control isolés.
if (Sym.sym == SDLK_RSHIFT || Sym.sym == SDLK_LSHIFT || if (keysym.sym == SDLK_RSHIFT || keysym.sym == SDLK_LSHIFT ||
Sym.sym == SDLK_RCTRL || Sym.sym == SDLK_LCTRL || keysym.sym == SDLK_RCTRL || keysym.sym == SDLK_LCTRL ||
Sym.sym == SDLK_RALT || Sym.sym == SDLK_LALT || keysym.sym == SDLK_RALT || keysym.sym == SDLK_LALT ||
Sym.sym == SDLK_MODE) // AltGr keysym.sym == SDLK_MODE) // AltGr
return 0; return 0;
// Les touches qui n'ont qu'une valeur unicode (très rares) // Les touches qui n'ont qu'une valeur unicode (très rares)
// seront codées sur 11 bits, le 12e bit est mis à 1 (0x0800) // seront codées sur 11 bits, le 12e bit est mis à 1 (0x0800)
if (Sym.sym != 0) if (keysym.sym != 0)
key_code = Sym.sym; key_code = keysym.sym;
else if (Sym.scancode != 0) else if (keysym.scancode != 0)
{ {
key_code = (Sym.scancode & 0x07FF) | 0x0800; key_code = (keysym.scancode & 0x07FF) | 0x0800;
} }
// Normally I should test Sym.mod here, but on windows the implementation // Normally I should test keysym.mod here, but on windows the implementation
// is buggy: if you release a modifier key, the following keys (when they repeat) // is buggy: if you release a modifier key, the following keys (when they repeat)
// still name the original modifiers. // still name the original modifiers.
Mod=Modificateurs_Touche(SDL_GetModState()); mod=Key_modifiers(SDL_GetModState());
// SDL_GetModState() seems to get the right up-to-date info. // SDL_GetModState() seems to get the right up-to-date info.
key_code |= Mod; key_code |= mod;
return key_code; return key_code;
} }
const char * Nom_touche(word Touche) const char * Key_name(word Key)
{ {
typedef struct typedef struct
{ {
word Sym; word keysym;
char *Nom_touche; char *Key_name;
} S_Libelle_touche; } T_key_label;
S_Libelle_touche Table_touches[] = T_key_label key_labels[] =
{ {
{ SDLK_BACKSPACE , "Backspace" }, { SDLK_BACKSPACE , "Backspace" },
{ SDLK_TAB , "Tab" }, { SDLK_TAB , "Tab" },
@ -432,118 +432,118 @@ const char * Nom_touche(word Touche)
{ SDLK_POWER , "Power" }, { SDLK_POWER , "Power" },
{ SDLK_EURO , "Euro" }, { SDLK_EURO , "Euro" },
{ SDLK_UNDO , "Undo" }, { SDLK_UNDO , "Undo" },
{ TOUCHE_MOUSEMIDDLE, "Mouse3" }, { KEY_MOUSEMIDDLE, "Mouse3" },
{ TOUCHE_MOUSEWHEELUP, "WheelUp" }, { KEY_MOUSEWHEELUP, "WheelUp" },
{ TOUCHE_MOUSEWHEELDOWN, "WheelDown" } { KEY_MOUSEWHEELDOWN, "WheelDown" }
}; };
int Indice; int index;
static char Buffer[41]; static char buffer[41];
Buffer[0] = '\0'; buffer[0] = '\0';
if (Touche == SDLK_UNKNOWN) if (Key == SDLK_UNKNOWN)
return "None"; return "None";
if (Touche & MOD_CTRL) if (Key & MOD_CTRL)
strcat(Buffer, "Ctrl+"); strcat(buffer, "Ctrl+");
if (Touche & MOD_ALT) if (Key & MOD_ALT)
strcat(Buffer, "Alt+"); strcat(buffer, "Alt+");
if (Touche & MOD_SHIFT) if (Key & MOD_SHIFT)
strcat(Buffer, "Shift+"); strcat(buffer, "Shift+");
Touche=Touche & ~(MOD_CTRL|MOD_ALT|MOD_SHIFT); Key=Key & ~(MOD_CTRL|MOD_ALT|MOD_SHIFT);
if (Touche>=TOUCHE_BUTTON && Touche<=TOUCHE_BUTTON+18) if (Key>=KEY_JOYBUTTON && Key<=KEY_JOYBUTTON+18)
{ {
#ifdef __gp2x__ #ifdef __gp2x__
char *NomBouton; char *button_name;
switch(Touche) switch(Key)
{ {
case GP2X_BUTTON_UP: NomBouton="[UP]"; break; case GP2X_BUTTON_UP: button_name="[UP]"; break;
case GP2X_BUTTON_DOWN: NomBouton="[DOWN]"; break; case GP2X_BUTTON_DOWN: button_name="[DOWN]"; break;
case GP2X_BUTTON_LEFT: NomBouton="[LEFT]"; break; case GP2X_BUTTON_LEFT: button_name="[LEFT]"; break;
case GP2X_BUTTON_RIGHT: NomBouton="[RIGHT]"; break; case GP2X_BUTTON_RIGHT: button_name="[RIGHT]"; break;
case GP2X_BUTTON_UPLEFT: NomBouton="[UP-LEFT]"; break; case GP2X_BUTTON_UPLEFT: button_name="[UP-LEFT]"; break;
case GP2X_BUTTON_UPRIGHT: NomBouton="[UP-RIGHT]"; break; case GP2X_BUTTON_UPRIGHT: button_name="[UP-RIGHT]"; break;
case GP2X_BUTTON_DOWNLEFT: NomBouton="[DOWN-LEFT]"; break; case GP2X_BUTTON_DOWNLEFT: button_name="[DOWN-LEFT]"; break;
case GP2X_BUTTON_DOWNRIGHT: NomBouton="[DOWN-RIGHT]"; break; case GP2X_BUTTON_DOWNRIGHT: button_name="[DOWN-RIGHT]"; break;
case GP2X_BUTTON_CLICK: NomBouton="[CLICK]"; break; case GP2X_BUTTON_CLICK: button_name="[CLICK]"; break;
case GP2X_BUTTON_A: NomBouton="[A]"; break; case GP2X_BUTTON_A: button_name="[A]"; break;
case GP2X_BUTTON_B: NomBouton="[B]"; break; case GP2X_BUTTON_B: button_name="[B]"; break;
case GP2X_BUTTON_X: NomBouton="[X]"; break; case GP2X_BUTTON_X: button_name="[X]"; break;
case GP2X_BUTTON_Y: NomBouton="[Y]"; break; case GP2X_BUTTON_Y: button_name="[Y]"; break;
case GP2X_BUTTON_L: NomBouton="[L]"; break; case GP2X_BUTTON_L: button_name="[L]"; break;
case GP2X_BUTTON_R: NomBouton="[R]"; break; case GP2X_BUTTON_R: button_name="[R]"; break;
case GP2X_BUTTON_START: NomBouton="[START]"; break; case GP2X_BUTTON_START: button_name="[START]"; break;
case GP2X_BUTTON_SELECT: NomBouton="[SELECT]"; break; case GP2X_BUTTON_SELECT: button_name="[SELECT]"; break;
case GP2X_BUTTON_VOLUP: NomBouton="[VOL UP]"; break; case GP2X_BUTTON_VOLUP: button_name="[VOL UP]"; break;
case GP2X_BUTTON_VOLDOWN: NomBouton="[VOL DOWN]"; break; case GP2X_BUTTON_VOLDOWN: button_name="[VOL DOWN]"; break;
default: sprintf(Buffer+strlen(Buffer), "[B%d]", Touche);return Buffer; default: sprintf(buffer+strlen(buffer), "[B%d]", Key);return buffer;
} }
strcat(Buffer,NomBouton); strcat(buffer,button_name);
#else #else
sprintf(Buffer+strlen(Buffer), "[B%d]", Touche-TOUCHE_BUTTON); sprintf(buffer+strlen(buffer), "[B%d]", Key-KEY_JOYBUTTON);
#endif #endif
return Buffer; return buffer;
} }
if (Touche & 0x8000) if (Key & 0x8000)
{ {
sprintf(Buffer+strlen(Buffer), "[%d]", Touche & 0xFFF); sprintf(buffer+strlen(buffer), "[%d]", Key & 0xFFF);
return Buffer; return buffer;
} }
Touche = Touche & 0xFFF; Key = Key & 0xFFF;
// Touches ASCII // Touches ASCII
if (Touche>=' ' && Touche < 127) if (Key>=' ' && Key < 127)
{ {
sprintf(Buffer+strlen(Buffer), "'%c'", toupper(Touche)); sprintf(buffer+strlen(buffer), "'%c'", toupper(Key));
return Buffer; return buffer;
} }
// Touches 'World' // Touches 'World'
if (Touche>=SDLK_WORLD_0 && Touche <= SDLK_WORLD_95) if (Key>=SDLK_WORLD_0 && Key <= SDLK_WORLD_95)
{ {
sprintf(Buffer+strlen(Buffer), "w%d", Touche - SDLK_WORLD_0); sprintf(buffer+strlen(buffer), "w%d", Key - SDLK_WORLD_0);
return Buffer; return buffer;
} }
// Touches au libellé connu // Touches au libellé connu
for (Indice=0; Indice < (long)sizeof(Table_touches)/(long)sizeof(S_Libelle_touche);Indice++) for (index=0; index < (long)sizeof(key_labels)/(long)sizeof(T_key_label);index++)
{ {
if (Touche == Table_touches[Indice].Sym) if (Key == key_labels[index].keysym)
{ {
sprintf(Buffer+strlen(Buffer), "%s", Table_touches[Indice].Nom_touche); sprintf(buffer+strlen(buffer), "%s", key_labels[index].Key_name);
return Buffer; return buffer;
} }
} }
// Autres touches inconnues // Autres touches inconnues
sprintf(Buffer+strlen(Buffer), "0x%X", Touche & 0x7FF); sprintf(buffer+strlen(buffer), "0x%X", Key & 0x7FF);
return Buffer; return buffer;
} }
// Obtient le caractère ANSI tapé, à partir d'un keysym. // Obtient le caractère ANSI tapé, à partir d'un keysym.
// (Valeur 32 à 255) // (Valeur 32 à 255)
// Renvoie 0 s'il n'y a pas de caractère associé (shift, backspace, etc) // Renvoie 0 s'il n'y a pas de caractère associé (shift, backspace, etc)
word Conversion_ANSI(SDL_keysym Sym) word Keysym_to_ANSI(SDL_keysym keysym)
{ {
// This part was removed from the MacOSX port, but I put it back for others // This part was removed from the MacOSX port, but I put it back for others
// as on Linux and Windows, it's what allows editing a text line with the keys // as on Linux and Windows, it's what allows editing a text line with the keys
// SDLK_LEFT, SDLK_RIGHT, SDLK_HOME, SDLK_END etc. // SDLK_LEFT, SDLK_RIGHT, SDLK_HOME, SDLK_END etc.
#if !(defined(__macosx__) || defined(__FreeBSD__)) #if !(defined(__macosx__) || defined(__FreeBSD__))
if ( Sym.unicode == 0) if ( keysym.unicode == 0)
{ {
return Sym.sym; return keysym.sym;
} }
#endif #endif
// //
if ( Sym.unicode > 32 && Sym.unicode < 127) if ( keysym.unicode > 32 && keysym.unicode < 127)
{ {
return Sym.unicode; // Pas de souci, on est en ASCII standard return keysym.unicode; // Pas de souci, on est en ASCII standard
} }
// Quelques conversions Unicode-ANSI // Quelques conversions Unicode-ANSI
switch(Sym.unicode) switch(keysym.unicode)
{ {
case 0x8100: case 0x8100:
return 'ü'; // ü return 'ü'; // ü
@ -603,25 +603,25 @@ word Conversion_ANSI(SDL_keysym Sym)
return 'ã'; // ã return 'ã'; // ã
} }
// Touche entre 127 et 255 // Key entre 127 et 255
if (Sym.unicode<256) if (keysym.unicode<256)
{ {
#if defined(__macosx__) || defined(__FreeBSD__) #if defined(__macosx__) || defined(__FreeBSD__)
// fc: Looks like there's a mismatch with delete & backspace // fc: Looks like there's a mismatch with delete & backspace
// i don't why SDLK_DELETE was returned instead of SDLK_BACKSPACE // i don't why SDLK_DELETE was returned instead of SDLK_BACKSPACE
if(Sym.unicode == 127) if(keysym.unicode == 127)
{ {
return(SDLK_BACKSPACE); return(SDLK_BACKSPACE);
} }
// We don't make any difference between return & enter in the app context. // We don't make any difference between return & enter in the app context.
if(Sym.unicode == 3) if(keysym.unicode == 3)
{ {
return(SDLK_RETURN); return(SDLK_RETURN);
} }
#endif #endif
return Sym.unicode; return keysym.unicode;
} }
// Sinon c'est une touche spéciale, on retourne son scancode // Sinon c'est une touche spéciale, on retourne son scancode
return Sym.sym; return keysym.sym;
} }

View File

@ -22,33 +22,33 @@
/*! /*!
Convert an SDL keysym to an ANSI/ASCII character. Convert an SDL keysym to an ANSI/ASCII character.
@param Sym SDL symbol to convert @param keysym SDL symbol to convert
*/ */
word Conversion_ANSI(SDL_keysym Sym); word Keysym_to_ANSI(SDL_keysym keysym);
/*! /*!
Convert an SDL keysym to an internal keycode number. Convert an SDL keysym to an internal keycode number.
This is needed because SDL tends to split the information across the unicode sym, the regular sym, and the raw keycode. This is needed because SDL tends to split the information across the unicode sym, the regular sym, and the raw keycode.
We also need to differenciate 1 (keypad) and 1 (regular keyboard), and some other things. We also need to differenciate 1 (keypad) and 1 (regular keyboard), and some other things.
@param Sym SDL symbol to convert @param keysym SDL symbol to convert
*/ */
word Conversion_Touche(SDL_keysym Sym); word Keysym_to_keycode(SDL_keysym keysym);
/*! /*!
Helper function to convert between SDL system and old coding for keycodes. This is needed because some SDL keycode are actually unicode and won't fit in 8 bits. Helper function to convert between SDL system and old coding for keycodes. This is needed because some SDL keycode are actually unicode and won't fit in 8 bits.
@param scancode Scancode to convert @param scancode Scancode to convert
*/ */
word Touche_pour_scancode(word scancode); word Key_for_scancode(word scancode);
/*! /*!
Returns key name in a string. Used to display them in the helpscreens and in the keymapper window. Returns key name in a string. Used to display them in the helpscreens and in the keymapper window.
@param Touche keycode of the key to translate, including modifiers @param Key keycode of the key to translate, including modifiers
*/ */
const char * Nom_touche(word Touche); const char * Key_name(word Key);
/*! /*!
Gets the modifiers in our format from the SDL_Mod information. Gets the modifiers in our format from the SDL_Mod information.
@param Mod SDL modifiers state @param mod SDL modifiers state
*/ */
word Modificateurs_Touche(SDLMod Mod); word Key_modifiers(SDLMod mod);

372
const.h
View File

@ -28,58 +28,58 @@
#define M_2PI 6.28318530717958647692528676656 #define M_2PI 6.28318530717958647692528676656
#define POURCENTAGE_VERSION "98.0%" // Libellé du pourcentage de la version ß #define PERCENTAGE_VERSION "98.0%" // Libellé du pourcentage de la version ß
#define VERSION1 2 // | #define VERSION1 2 // |
#define VERSION2 0 // |_ Numéro de version découpé en #define VERSION2 0 // |_ Numéro de version découpé en
#define BETA1 98 // | plusieurs parties => 2.0 ß95.5% #define BETA1 98 // | plusieurs parties => 2.0 ß95.5%
#define BETA2 0 // | (utilisé pour le fichier de config) #define BETA2 0 // | (utilisé pour le fichier de config)
#define ALPHA_BETA "ß" // Type de la version "Þ" ou "ß" #define ALPHA_BETA "ß" // Type de la version "Þ" ou "ß"
#define MAX_MODES_VIDEO 100 // Nombre de modes vidéo maxi #define MAX_VIDEO_MODES 100 // Nombre de modes vidéo maxi
#define NB_BOUTONS 38 // Nombre de boutons à gérer #define NB_BUTTONS 38 // Nombre de boutons à gérer
#define NB_TOUCHES 134 // Nombre de combinaisons de touches #define NB_SHORTCUTS 134 // Nombre de combinaisons de touches
#define NB_TOUCHES_SPECIALES 72 // Nombre de touches spéciales #define NB_SPECIAL_SHORTCUTS 72 // Nombre de touches spéciales
#define NB_OPERATIONS 33 // Nombre d'opérations gérées par le moteur #define NB_OPERATIONS 33 // Nombre d'opérations gérées par le moteur
#define NB_FACTEURS_DE_ZOOM 12 // Nombre de facteurs de zoom #define NB_ZOOM_FACTORS 12 // Nombre de facteurs de zoom
#define LARGEUR_MENU 254 // Largeur du menu en taille réelle #define MENU_WIDTH 254 // Largeur du menu en taille réelle
#define HAUTEUR_MENU 44 // Hauteur du menu en taille réelle #define MENU_HEIGHT 44 // Hauteur du menu en taille réelle
#define NB_SPRITES_CURSEUR 8 // Nombre de sprites de curseur #define NB_CURSOR_SPRITES 8 // Nombre de sprites de curseur
#define LARGEUR_SPRITE_CURSEUR 15 // Largeur d'un sprite de curseur en pixels #define CURSOR_SPRITE_WIDTH 15 // Largeur d'un sprite de curseur en pixels
#define HAUTEUR_SPRITE_CURSEUR 15 // Hauteur d'un sprite de curseur en pixels #define CURSOR_SPRITE_HEIGHT 15 // Hauteur d'un sprite de curseur en pixels
#define NB_SPRITES_EFFETS 9 // Nombre de sprites d'effets #define NB_EFFECTS_SPRITES 9 // Nombre de sprites d'effets
#define NB_SPRITES_MENU 18 // Nombre de sprites de menu #define NB_MENU_SPRITES 18 // Nombre de sprites de menu
#define LARGEUR_SPRITE_MENU 14 // Largeur d'un sprite de menu en pixels #define MENU_SPRITE_WIDTH 14 // Largeur d'un sprite de menu en pixels
#define HAUTEUR_SPRITE_MENU 14 // Hauteur d'un sprite de menu en pixels #define MENU_SPRITE_HEIGHT 14 // Hauteur d'un sprite de menu en pixels
#define LARGEUR_PINCEAU 16 // Largeur d'un sprite de pinceau prédéfini #define PAINTBRUSH_WIDTH 16 // Largeur d'un sprite de pinceau prédéfini
#define HAUTEUR_PINCEAU 16 // Hauteur d'un sprite de pinceau prédéfini #define PAINTBRUSH_HEIGHT 16 // Hauteur d'un sprite de pinceau prédéfini
#define TAILLE_MAXI_PINCEAU 127 // Taille maxi des pinceaux #define MAX_PAINTBRUSH_SIZE 127 // Taille maxi des pinceaux
#define NB_SPRITES_DRIVES 7 // Nombre de sprites de drives #define NB_ICON_SPRITES 7 // Nombre de sprites de drives
#define LARGEUR_SPRITE_DRIVE 8 // Largeur d'un sprite de drive en pixels #define ICON_SPRITE_WIDTH 8 // Largeur d'un sprite de drive en pixels
#define HAUTEUR_SPRITE_DRIVE 8 // Hauteur d'un sprite de drive en pixels #define ICON_SPRITE_HEIGHT 8 // Hauteur d'un sprite de drive en pixels
#define NB_SPRITES_PINCEAU 48 // Nombre de sprites de pinceau #define NB_PAINTBRUSH_SPRITES 48 // Nombre de sprites de pinceau
#define NB_TRAMES_PREDEFINIES 12 // Nombre de trames prédéfinies #define NB_PRESET_SIEVE 12 // Nombre de trames prédéfinies
#define TAILLE_PILE_OPERATIONS 16 // Nombre maximum d'éléments utilisés par les opérations #define OPERATION_STACK_SIZE 16 // Nombre maximum d'éléments utilisés par les opérations
#define TAILLE_MAXI_PATH 37 // Taille maximum affichable du répertoire courant dans les fenêtres du fileselect #define MAX_DISPLAYABLE_PATH 37 // Taille maximum affichable du répertoire courant dans les fenêtres du fileselect
#define TAILLE_COMMENTAIRE 32 // Taille maxi des commentaires pour le PKM #define COMMENT_SIZE 32 // Taille maxi des commentaires pour le PKM
#define NB_PAGES_UNDO_MAX 99 // Nombre maximal de pages d'undo #define NB_MAX_PAGES_UNDO 99 // Nombre maximal de pages d'undo
#define FACTEUR_DE_ZOOM_PAR_DEFAUT 4 // Facteur de zoom initial #define DEFAULT_ZOOM_FACTOR 4 // Facteur de zoom initial
#define TAILLE_CHEMIN_FICHIER 260 // Le nombre de caractères maxi pour un nom de fichier avec chemin complet #define MAX_PATH_CHARACTERS 260 // Le nombre de caractères maxi pour un nom de fichier avec chemin complet
#define NB_BOOKMARKS 4 // Nombre de boutons "signet" dans l'ecran Save/Load #define NB_BOOKMARKS 4 // Nombre de boutons "signet" dans l'ecran Save/Load
// Caractères présents dans les deux fontes // Caractères présents dans les deux fontes
#define CARACTERE_TRIANGLE_DROIT 16 #define RIGHT_TRIANGLE_CHARACTER 16
#define CARACTERE_TRIANGLE_GAUCHE 17 #define LEFT_TRIANGLE_CHARACTER 17
#define CARACTERE_SUSPENSION '…' #define ELLIPSIS_CHARACTER '…'
// On impose à l'allocation dynamique des pages de backups de conserver un // On impose à l'allocation dynamique des pages de backups de conserver un
// minimum de 256 Ko pour que le reste du programme puisse continuer à // minimum de 256 Ko pour que le reste du programme puisse continuer à
// fonctionner. // fonctionner.
#define QUANTITE_MINIMALE_DE_MEMOIRE_A_CONSERVER (256*1024) #define MINIMAL_MEMORY_TO_RESERVE (256*1024)
#define A_GAUCHE 1 // Indique une direction (ou click) à gauche #define LEFT_SIDE 1 // Indique une direction (ou click) à gauche
#define A_DROITE 2 // Indique une direction (ou click) à droite #define RIGHT_SIDE 2 // Indique une direction (ou click) à droite
#define LARGEUR_BARRE_SPLIT 6 // [ Û±±° ] #define SEPARATOR_WIDTH 6 // [ Û±±° ]
#define PROPORTION_SPLIT 0.3 // proportion de la zone non-zoomée en largeur par rapport à l'écran #define INITIAL_SEPARATOR_PROPORTION 0.3 // proportion de la zone non-zoomée en largeur par rapport à l'écran
#define NB_PIXELS_ZOOMES_MIN 4 // Nombre minimal de pixels zoomés en largeur (Note: En dessous de 4, on ne peut plus scroller!) #define NB_ZOOMED_PIXELS_MIN 4 // Nombre minimal de pixels zoomés en largeur (Note: En dessous de 4, on ne peut plus scroller!)
#if defined(__MORPHOS__) || defined(__amigaos4__) || defined(__amigaos__) #if defined(__MORPHOS__) || defined(__amigaos4__) || defined(__amigaos__)
#define PARENT_DIR "/" #define PARENT_DIR "/"
@ -90,17 +90,17 @@
// Les différents formats de fichiers: // Les différents formats de fichiers:
#ifndef __no_pnglib__ #ifndef __no_pnglib__
#define NB_FORMATS_CONNUS 13 // Nombre de formats connus (devrait être la valeur maximale de NB_FORMATS_LOAD et NB_FORMATS_SAVE, mais plus généralement: Card({NB_FORMATS_LOAD} UNION {NB_FORMATS_SAVE})) #define NB_KNOWN_FORMATS 13 // Nombre de formats connus (devrait être la valeur maximale de NB_FORMATS_LOAD et NB_FORMATS_SAVE, mais plus généralement: Card({NB_FORMATS_LOAD} UNION {NB_FORMATS_SAVE}))
#define NB_FORMATS_LOAD 13 // Nombre de formats que l'on sait charger #define NB_FORMATS_LOAD 13 // Nombre de formats que l'on sait charger
#define NB_FORMATS_SAVE 13 // Nombre de formats que l'on sait sauver #define NB_FORMATS_SAVE 13 // Nombre de formats que l'on sait sauver
#else #else
// Without pnglib // Without pnglib
#define NB_FORMATS_CONNUS 12 // Nombre de formats connus (devrait être la valeur maximale de NB_FORMATS_LOAD et NB_FORMATS_SAVE, mais plus généralement: Card({NB_FORMATS_LOAD} UNION {NB_FORMATS_SAVE})) #define NB_KNOWN_FORMATS 12 // Nombre de formats connus (devrait être la valeur maximale de NB_FORMATS_LOAD et NB_FORMATS_SAVE, mais plus généralement: Card({NB_FORMATS_LOAD} UNION {NB_FORMATS_SAVE}))
#define NB_FORMATS_LOAD 12 // Nombre de formats que l'on sait charger #define NB_FORMATS_LOAD 12 // Nombre de formats que l'on sait charger
#define NB_FORMATS_SAVE 12 // Nombre de formats que l'on sait sauver #define NB_FORMATS_SAVE 12 // Nombre de formats que l'on sait sauver
#endif #endif
enum FORMATS_RECONNUS enum FILE_FORMATS
{ {
FORMAT_PKM=1, // | FORMAT_PKM=1, // |
FORMAT_LBM, // | FORMAT_LBM, // |
@ -117,28 +117,28 @@ enum FORMATS_RECONNUS
FORMAT_PNG // | FORMAT_PNG // |
}; };
#define FORMAT_PAR_DEFAUT FORMAT_GIF // Format par défaut (ah bon? oh!) #define DEFAULT_FILEFORMAT FORMAT_GIF // Format par défaut (ah bon? oh!)
// Les différentes erreurs: // Les différentes erreurs:
enum CODES_D_ERREURS enum ERROR_CODES
{ {
// 0 = Flash rouge de l'écran, erreur non critique // 0 = Flash rouge de l'écran, erreur non critique
ERREUR_GUI_ABSENT=1, // Le fichier gfx2gui.gif est absent ERROR_GUI_MISSING=1, // Le fichier gfx2gui.gif est absent
ERREUR_GUI_CORROMPU, // Mauvais fichier gfx2gui.gif ERROR_GUI_CORRUPTED, // Mauvais fichier gfx2gui.gif
ERREUR_INI_ABSENT, // Le fichier gfx2def.ini est absent ERROR_INI_MISSING, // Le fichier gfx2def.ini est absent
ERREUR_CFG_ABSENT, // Le fichier GFX2.CFG est absent ERROR_CFG_MISSING, // Le fichier GFX2.CFG est absent
ERREUR_CFG_CORROMPU, // Mauvais fichier GFX2.CFG ERROR_CFG_CORRUPTED, // Mauvais fichier GFX2.CFG
ERREUR_CFG_ANCIEN, // Ancienne version du fichier GFX2.CFG ERROR_CFG_OLD, // Ancienne version du fichier GFX2.CFG
ERREUR_MEMOIRE, // Plus de mémoire ERROR_MEMORY, // Plus de mémoire
ERREUR_LIGNE_COMMANDE, // Erreur sur la ligne de commande ERROR_COMMAND_LINE, // Error sur la ligne de commande
ERREUR_DRIVER_SOURIS, // Pas de driver souris installé ERROR_MOUSE_DRIVER, // Pas de driver souris installé
ERREUR_MODE_INTERDIT, // Mode demandé sur la ligne de commande interdit (coché en noir) ERROR_FORBIDDEN_MODE, // Mode demandé sur la ligne de commande interdit (coché en noir)
ERREUR_SAUVEGARDE_CFG, // Erreur en écriture pour GFX2.CFG ERROR_SAVING_CFG, // Error en écriture pour GFX2.CFG
ERREUR_REPERTOIRE_DISPARU, // Le répertoire de lancement n'existe plus ERROR_MISSING_DIRECTORY, // Le répertoire de lancement n'existe plus
ERREUR_INI_CORROMPU, // Le fichier GFX2.INI est corrompu ERROR_INI_CORRUPTED, // Le fichier GFX2.INI est corrompu
ERREUR_SAUVEGARDE_INI, // Le fichier GFX2.INI n'est pas inscriptible ERROR_SAVING_INI, // Le fichier GFX2.INI n'est pas inscriptible
ERREUR_SORRY_SORRY_SORRY // On le refera plus, promis (erreur d'allocation de page qui ne devrait JAMAIS se produire) ERROR_SORRY_SORRY_SORRY // On le refera plus, promis (erreur d'allocation de page qui ne devrait JAMAIS se produire)
}; };
// Les différents types de pixels // Les différents types de pixels
@ -153,153 +153,153 @@ enum PIXEL_RATIO
// Les différentes catégories de bouton: // Les différentes catégories de bouton:
enum FAMILLES_DE_BOUTONS enum FAMILY_OF_BUTTONS
{ {
FAMILLE_OUTIL=1, // Outils de dessin (exemple : Freehand draw) FAMILY_TOOL=1, // Outils de dessin (exemple : Freehand draw)
FAMILLE_INTERRUPTION, // Opération éphémère (exemple : changement de brosse) > Interruption de l'opération courante pour faire autre chose, puis on revient FAMILY_INTERRUPTION, // Opération éphémère (exemple : changement de brosse) > Interruption de l'opération courante pour faire autre chose, puis on revient
FAMILLE_INSTANTANE, // Pif paf (exemple : changement de couleur) > ça sera fini dès qu'on lache le bouton, pas d'utilisation de la pile d'opérations FAMILY_INSTANT, // Pif paf (exemple : changement de couleur) > ça sera fini dès qu'on lache le bouton, pas d'utilisation de la pile d'opérations
FAMILLE_TOOLBAR, // Cache/Montre la barre d'outils FAMILY_TOOLBAR, // Cache/Montre la barre d'outils
FAMILLE_EFFETS // Effets FAMILY_EFFECTS // Effets
}; };
// Les différentes formes de bouton: // Les différentes formes de bouton:
enum FORMES_DE_BOUTONS enum BUTTON_SHAPES
{ {
FORME_BOUTON_SANS_CADRE, // Ex: la palette BUTTON_SHAPE_NO_FRAME, // Ex: la palette
FORME_BOUTON_RECTANGLE, // Ex: la plupart BUTTON_SHAPE_RECTANGLE, // Ex: la plupart
FORME_BOUTON_TRIANGLE_HAUT_GAUCHE, // Ex: Rectangles vides BUTTON_SHAPE_TRIANGLE_TOP_LEFT, // Ex: Rectangles vides
FORME_BOUTON_TRIANGLE_BAS_DROITE // Ex: Rectangles pleins BUTTON_SHAPE_TRIANGLE_BOTTOM_RIGHT // Ex: Rectangles pleins
}; };
// Les différentes formes de curseur: // Les différentes formes de curseur:
enum FORMES_DE_CURSEUR enum CURSOR_SHAPES
{ {
FORME_CURSEUR_FLECHE, CURSOR_SHAPE_ARROW,
FORME_CURSEUR_CIBLE, // Utilise le pinceau CURSOR_SHAPE_TARGET, // Utilise le pinceau
FORME_CURSEUR_CIBLE_PIPETTE, // Utilise le pinceau CURSOR_SHAPE_COLORPICKER, // Utilise le pinceau
FORME_CURSEUR_SABLIER, CURSOR_SHAPE_HOURGLASS,
FORME_CURSEUR_MULTIDIRECTIONNEL, CURSOR_SHAPE_MULTIDIRECTIONNAL,
FORME_CURSEUR_HORIZONTAL, CURSOR_SHAPE_HORIZONTAL,
FORME_CURSEUR_CIBLE_FINE, // Utilise le pinceau CURSOR_SHAPE_THIN_TARGET, // Utilise le pinceau
FORME_CURSEUR_CIBLE_PIPETTE_FINE, // Utilise le pinceau CURSOR_SHAPE_THIN_COLORPICKER, // Utilise le pinceau
FORME_CURSEUR_CIBLE_XOR, CURSOR_SHAPE_XOR_TARGET,
FORME_CURSEUR_RECTANGLE_XOR, CURSOR_SHAPE_XOR_RECTANGLE,
FORME_CURSEUR_ROTATE_XOR CURSOR_SHAPE_XOR_ROTATION
}; };
// Les différentes formes de pinceaux (les types de pinceaux doivent être au début) // Les différentes formes de pinceaux (les types de pinceaux doivent être au début)
enum FORMES_DE_PINCEAUX enum PAINTBRUSH_SHAPES
{ {
FORME_PINCEAU_ROND, PAINTBRUSH_SHAPE_ROUND,
FORME_PINCEAU_CARRE, PAINTBRUSH_SHAPE_SQUARE,
FORME_PINCEAU_BARRE_HORIZONTALE, PAINTBRUSH_SHAPE_HORIZONTAL_BAR,
FORME_PINCEAU_BARRE_VERTICALE, PAINTBRUSH_SHAPE_VERTICAL_BAR,
FORME_PINCEAU_SLASH, PAINTBRUSH_SHAPE_SLASH,
FORME_PINCEAU_ANTISLASH, PAINTBRUSH_SHAPE_ANTISLASH,
FORME_PINCEAU_ALEATOIRE, PAINTBRUSH_SHAPE_RANDOM,
FORME_PINCEAU_X, PAINTBRUSH_SHAPE_CROSS,
FORME_PINCEAU_PLUS, PAINTBRUSH_SHAPE_PLUS,
FORME_PINCEAU_LOSANGE, PAINTBRUSH_SHAPE_DIAMOND,
FORME_PINCEAU_ROND_TRAME, PAINTBRUSH_SHAPE_SIEVE_ROUND,
FORME_PINCEAU_CARRE_TRAME, PAINTBRUSH_SHAPE_SIEVE_SQUARE,
FORME_PINCEAU_DIVERS,// Ce doit être le dernier des types de pinceaux, comme ça il indique le nombre de types de pinceaux (-1) PAINTBRUSH_SHAPE_MISC,// Ce doit être le dernier des types de pinceaux, comme ça il indique le nombre de types de pinceaux (-1)
FORME_PINCEAU_POINT, // Utilisé pour réduire de pinceau à 1 point dans certaines opérations PAINTBRUSH_SHAPE_POINT, // Utilisé pour réduire de pinceau à 1 point dans certaines opérations
FORME_PINCEAU_BROSSE_COULEUR, PAINTBRUSH_SHAPE_COLOR_BRUSH,
FORME_PINCEAU_BROSSE_MONOCHROME PAINTBRUSH_SHAPE_MONO_BRUSH
}; };
// Les différents états de bouton: // Les différents états de bouton:
#define BOUTON_RELACHE 0 #define BUTTON_RELEASED 0
#define BOUTON_ENFONCE 1 #define BUTTON_PRESSED 1
// Les différents modes de Shade // Les différents modes de Shade
enum MODES_DE_SHADE enum SHADE_MODES
{ {
MODE_SHADE_NORMAL, SHADE_MODE_NORMAL,
MODE_SHADE_BOUCLE, SHADE_MODE_LOOP,
MODE_SHADE_NOSAT SHADE_MODE_NOSAT
}; };
// Les différents chunks du fichier .CFG // Les différents chunks du fichier .CFG
enum CHUNKS_CFG enum CHUNKS_CFG
{ {
CHUNK_TOUCHES = 0, CHUNK_KEYS = 0,
CHUNK_MODES_VIDEO = 1, CHUNK_VIDEO_MODES = 1,
CHUNK_SHADE = 2, CHUNK_SHADE = 2,
CHUNK_MASQUE = 3, CHUNK_MASK = 3,
CHUNK_STENCIL = 4, CHUNK_STENCIL = 4,
CHUNK_DEGRADES = 5, CHUNK_GRADIENTS = 5,
CHUNK_SMOOTH = 6, CHUNK_SMOOTH = 6,
CHUNK_EXCLUDE_COLORS = 7, CHUNK_EXCLUDE_COLORS = 7,
CHUNK_QUICK_SHADE = 8, CHUNK_QUICK_SHADE = 8,
CHUNK_GRILLE = 9, CHUNK_GRID = 9,
CHUNK_MAX CHUNK_MAX
}; };
// Les différents types de lecteurs: // Les différents types de lecteurs:
enum TYPES_DE_LECTEURS enum ICON_TYPES
{ {
LECTEUR_FLOPPY_3_5, // 0: Diskette 3"« ICON_FLOPPY_3_5, // 0: Diskette 3"«
LECTEUR_FLOPPY_5_25, // 1: Diskette 5"¬ ICON_FLOPPY_5_25, // 1: Diskette 5"¬
LECTEUR_HDD, // 2: HDD ICON_HDD, // 2: HDD
LECTEUR_CDROM, // 3: CD-ROM ICON_CDROM, // 3: CD-ROM
LECTEUR_NETWORK, // 4: Logique (réseau?) ICON_NETWORK, // 4: Logique (réseau?)
}; };
// Les différents boutons: // Les différents boutons:
enum NUMEROS_DE_BOUTONS enum BUTTON_NUMBERS
{ {
BOUTON_PINCEAUX, BUTTON_PAINTBRUSHES,
BOUTON_AJUSTER, BUTTON_ADJUST,
BOUTON_DESSIN, BUTTON_DRAW,
BOUTON_COURBES, BUTTON_CURVES,
BOUTON_LIGNES, BUTTON_LINES,
BOUTON_SPRAY, BUTTON_AIRBRUSH,
BOUTON_FLOODFILL, BUTTON_FLOODFILL,
BOUTON_POLYGONES, BUTTON_POLYGONS,
BOUTON_POLYFILL, BUTTON_POLYFILL,
BOUTON_RECTANGLES, BUTTON_RECTANGLES,
BOUTON_FILLRECT, BUTTON_FILLRECT,
BOUTON_CERCLES, BUTTON_CIRCLES,
BOUTON_FILLCERC, BUTTON_FILLCIRC,
BOUTON_GRADRECT, BUTTON_GRADRECT,
BOUTON_GRADMENU, BUTTON_GRADMENU,
BOUTON_SPHERES, BUTTON_SPHERES,
BOUTON_BROSSE, BUTTON_BRUSH,
BOUTON_POLYBROSSE, BUTTON_POLYBRUSH,
BOUTON_EFFETS_BROSSE, BUTTON_BRUSH_EFFECTS,
BOUTON_EFFETS, BUTTON_EFFECTS,
BOUTON_TEXTE, BUTTON_TEXT,
BOUTON_LOUPE, BUTTON_MAGNIFIER,
BOUTON_PIPETTE, BUTTON_COLORPICKER,
BOUTON_RESOL, BUTTON_RESOL,
BOUTON_PAGE, BUTTON_PAGE,
BOUTON_SAUVER, BUTTON_SAVE,
BOUTON_CHARGER, BUTTON_LOAD,
BOUTON_PARAMETRES, BUTTON_SETTINGS,
BOUTON_CLEAR, BUTTON_CLEAR,
BOUTON_AIDE, BUTTON_HELP,
BOUTON_UNDO, BUTTON_UNDO,
BOUTON_KILL, BUTTON_KILL,
BOUTON_QUIT, BUTTON_QUIT,
BOUTON_PALETTE, BUTTON_PALETTE,
BOUTON_PAL_LEFT, BUTTON_PAL_LEFT,
BOUTON_PAL_RIGHT, BUTTON_PAL_RIGHT,
BOUTON_CHOIX_COL, BUTTON_CHOOSE_COL,
BOUTON_CACHER BUTTON_HIDE
}; };
// Les actions des touches spéciales // Les actions des touches spéciales
enum ACTIONS_SPECIALES enum SPECIAL_ACTIONS
{ {
SPECIAL_MOUSE_UP, SPECIAL_MOUSE_UP,
SPECIAL_MOUSE_DOWN, SPECIAL_MOUSE_DOWN,
@ -311,8 +311,8 @@ enum ACTIONS_SPECIALES
SPECIAL_PREVIOUS_FORECOLOR, SPECIAL_PREVIOUS_FORECOLOR,
SPECIAL_NEXT_BACKCOLOR, SPECIAL_NEXT_BACKCOLOR,
SPECIAL_PREVIOUS_BACKCOLOR, SPECIAL_PREVIOUS_BACKCOLOR,
SPECIAL_RETRECIR_PINCEAU, SPECIAL_SMALLER_PAINTBRUSH,
SPECIAL_GROSSIR_PINCEAU, SPECIAL_BIGGER_PAINTBRUSH,
SPECIAL_NEXT_USER_FORECOLOR, SPECIAL_NEXT_USER_FORECOLOR,
SPECIAL_PREVIOUS_USER_FORECOLOR, SPECIAL_PREVIOUS_USER_FORECOLOR,
SPECIAL_NEXT_USER_BACKCOLOR, SPECIAL_NEXT_USER_BACKCOLOR,
@ -330,8 +330,8 @@ enum ACTIONS_SPECIALES
SPECIAL_SCROLL_LEFT_SLOW, SPECIAL_SCROLL_LEFT_SLOW,
SPECIAL_SCROLL_RIGHT_SLOW, SPECIAL_SCROLL_RIGHT_SLOW,
SPECIAL_SHOW_HIDE_CURSOR, SPECIAL_SHOW_HIDE_CURSOR,
SPECIAL_PINCEAU_POINT, SPECIAL_DOT_PAINTBRUSH,
SPECIAL_DESSIN_CONTINU, SPECIAL_CONTINUOUS_DRAW,
SPECIAL_FLIP_X, SPECIAL_FLIP_X,
SPECIAL_FLIP_Y, SPECIAL_FLIP_Y,
SPECIAL_ROTATE_90, SPECIAL_ROTATE_90,
@ -379,41 +379,41 @@ enum ACTIONS_SPECIALES
enum OPERATIONS enum OPERATIONS
{ {
OPERATION_DESSIN_CONTINU, // Dessin à la main continu OPERATION_CONTINUOUS_DRAW, // Dessin à la main continu
OPERATION_DESSIN_DISCONTINU, // Dessin à la main discontinu OPERATION_DISCONTINUOUS_DRAW, // Dessin à la main discontinu
OPERATION_DESSIN_POINT, // Dessin à la main point par point OPERATION_POINT_DRAW, // Dessin à la main point par point
OPERATION_FILLED_CONTOUR, // Contour rempli OPERATION_FILLED_CONTOUR, // Contour rempli
OPERATION_LIGNE, // Lignes OPERATION_LINE, // Lignes
OPERATION_K_LIGNE, // Lignes reliées OPERATION_K_LIGNE, // Lignes reliées
OPERATION_LIGNES_CENTREES, // Lignes concentriques OPERATION_CENTERED_LINES, // Lignes concentriques
OPERATION_RECTANGLE_VIDE, // Rectangle vide OPERATION_EMPTY_RECTANGLE, // Rectangle vide
OPERATION_RECTANGLE_PLEIN, // Rectangle plein OPERATION_FILLED_RECTANGLE, // Rectangle plein
OPERATION_CERCLE_VIDE, // Cercle vide OPERATION_EMPTY_CIRCLE, // Cercle vide
OPERATION_CERCLE_PLEIN, // Cercle plein OPERATION_FILLED_CIRCLE, // Cercle plein
OPERATION_ELLIPSE_VIDE, // Ellipse vide OPERATION_EMPTY_ELLIPSE, // Ellipse vide
OPERATION_ELLIPSE_PLEINE, // Ellipse pleine OPERATION_FILLED_ELLIPSE, // Ellipse pleine
OPERATION_FILL, // Fill OPERATION_FILL, // Fill
OPERATION_REMPLACER, // Remplacer couleur OPERATION_REPLACE, // Replace couleur
OPERATION_PRISE_BROSSE, // Prise de brosse rectangulaire OPERATION_GRAB_BRUSH, // Prise de brosse rectangulaire
OPERATION_POLYBROSSE, // Prise d'une brosse multiforme OPERATION_POLYBRUSH, // Prise d'une brosse multiforme
OPERATION_PIPETTE, // Récupération d'une couleur OPERATION_COLORPICK, // Récupération d'une couleur
OPERATION_LOUPE, // Positionnement de la fenêtre de loupe OPERATION_MAGNIFY, // Positionnement de la fenêtre de loupe
OPERATION_COURBE_3_POINTS, // Courbe à 3 points OPERATION_3_POINTS_CURVE, // Courbe à 3 points
OPERATION_COURBE_4_POINTS, // Courbe à 4 points OPERATION_4_POINTS_CURVE, // Courbe à 4 points
OPERATION_SPRAY, // Spray OPERATION_AIRBRUSH, // Spray
OPERATION_POLYGONE, // Polygone OPERATION_POLYGON, // Polygone
OPERATION_POLYFORM, // Polyforme OPERATION_POLYFORM, // Polyforme
OPERATION_POLYFILL, // Polyfill OPERATION_POLYFILL, // Polyfill
OPERATION_FILLED_POLYFORM, // Polyforme rempli OPERATION_FILLED_POLYFORM, // Polyforme rempli
OPERATION_SCROLL, // Scroll OPERATION_SCROLL, // Scroll
OPERATION_CERCLE_DEGRADE, // Cercles dégradés OPERATION_GRAD_CIRCLE, // Cercles dégradés
OPERATION_ELLIPSE_DEGRADEE, // Ellipses dégradées OPERATION_GRAD_ELLIPSE, // Ellipses dégradées
OPERATION_TOURNER_BROSSE, // Faire tourner brosse OPERATION_ROTATE_BRUSH, // Faire tourner brosse
OPERATION_ETIRER_BROSSE, // Etirer brosse OPERATION_STRETCH_BRUSH, // Etirer brosse
OPERATION_DEFORMER_BROSSE, // Deformer brosse OPERATION_DISTORT_BRUSH, // Deformer brosse
OPERATION_RECTANGLE_DEGRADE, // Rectangle dégradé OPERATION_GRAD_RECTANGLE, // Rectangle dégradé
OPERATION_AUCUNE OPERATION_NONE
}; };

440
divers.c
View File

@ -37,25 +37,25 @@
#include "palette.h" #include "palette.h"
#include "input.h" #include "input.h"
word Palette_Compter_nb_couleurs_utilisees(dword* usage) word Count_used_colors(dword* usage)
{ {
int Nombre_De_Pixels=0; int nb_pixels=0;
Uint8* Pixel_Courant=Principal_Ecran; Uint8* Pixel_Courant=Main_screen;
Uint8 Couleur; Uint8 color;
word Nombre_Couleurs=0; word nb_colors=0;
int i; int i;
for (i=0;i<256;i++) usage[i]=0; for (i=0;i<256;i++) usage[i]=0;
//Calcul du nombre de pixels dans l'image //Calcul du nombre de pixels dans l'image
Nombre_De_Pixels=Principal_Hauteur_image*Principal_Largeur_image; nb_pixels=Main_image_height*Main_image_width;
// On parcourt l'écran courant pour compter les utilisations des couleurs // On parcourt l'écran courant pour compter les utilisations des couleurs
for(i=0;i<Nombre_De_Pixels;i++) for(i=0;i<nb_pixels;i++)
{ {
Couleur=*Pixel_Courant; //on lit la couleur dans l'écran color=*Pixel_Courant; //on lit la couleur dans l'écran
usage[Couleur]++; //Un point de plus pour cette couleur usage[color]++; //Un point de plus pour cette couleur
// On passe au pixel suivant // On passe au pixel suivant
Pixel_Courant++; Pixel_Courant++;
@ -65,10 +65,10 @@ word Palette_Compter_nb_couleurs_utilisees(dword* usage)
for(i=0;i<256;i++) for(i=0;i<256;i++)
{ {
if (usage[i]!=0) if (usage[i]!=0)
Nombre_Couleurs++; nb_colors++;
} }
return Nombre_Couleurs; return nb_colors;
} }
void Set_palette(T_Palette palette) void Set_palette(T_Palette palette)
@ -77,68 +77,68 @@ void Set_palette(T_Palette palette)
SDL_Color PaletteSDL[256]; SDL_Color PaletteSDL[256];
for(i=0;i<256;i++) for(i=0;i<256;i++)
{ {
PaletteSDL[i].r=(palette[i].R=Palette_Scale_Component(palette[i].R)); PaletteSDL[i].r=(palette[i].R=Round_palette_component(palette[i].R));
PaletteSDL[i].g=(palette[i].G=Palette_Scale_Component(palette[i].G)); PaletteSDL[i].g=(palette[i].G=Round_palette_component(palette[i].G));
PaletteSDL[i].b=(palette[i].B=Palette_Scale_Component(palette[i].B)); PaletteSDL[i].b=(palette[i].B=Round_palette_component(palette[i].B));
} }
SDL_SetPalette(Ecran_SDL, SDL_PHYSPAL | SDL_LOGPAL, PaletteSDL,0,256); SDL_SetPalette(Screen_SDL, SDL_PHYSPAL | SDL_LOGPAL, PaletteSDL,0,256);
} }
void Set_color(byte Couleur, byte Rouge, byte Vert, byte Bleu) void Set_color(byte color, byte red, byte green, byte blue)
{ {
SDL_Color comp; SDL_Color comp;
comp.r=Rouge; comp.r=red;
comp.g=Vert; comp.g=green;
comp.b=Bleu; comp.b=blue;
SDL_SetPalette(Ecran_SDL, SDL_LOGPAL, &comp, Couleur, 1); SDL_SetPalette(Screen_SDL, SDL_LOGPAL, &comp, color, 1);
} }
void Attendre_fin_de_click(void) 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()) Wait_VBL();
} }
void Effacer_image_courante_Stencil(byte Couleur, byte * Pochoir) void Hide_current_image_with_stencil(byte color, byte * stencil)
//Effacer l'image courante avec une certaine couleur en mode Stencil //Effacer l'image courante avec une certaine couleur en mode Stencil
{ {
int Nombre_De_Pixels=0; //ECX int nb_pixels=0; //ECX
//al=Couleur //al=color
//edi=Ecran //edi=Screen
byte* Pixel_Courant=Ecran; //dl byte* Pixel_Courant=Screen; //dl
int i; int i;
Nombre_De_Pixels=Principal_Hauteur_image*Principal_Largeur_image; nb_pixels=Main_image_height*Main_image_width;
for(i=0;i<Nombre_De_Pixels;i++) for(i=0;i<nb_pixels;i++)
{ {
if (Pochoir[*Pixel_Courant]==0) if (stencil[*Pixel_Courant]==0)
*Pixel_Courant=Couleur; *Pixel_Courant=color;
Pixel_Courant++; Pixel_Courant++;
} }
} }
void Effacer_image_courante(byte Couleur) void Hide_current_image(byte color)
// Effacer l'image courante avec une certaine couleur // Effacer l'image courante avec une certaine couleur
{ {
memset( memset(
Principal_Ecran , Main_screen ,
Couleur , color ,
Principal_Largeur_image * Principal_Hauteur_image Main_image_width * Main_image_height
); );
} }
void Sensibilite_souris(__attribute__((unused)) word x,__attribute__((unused)) word y) void Mouse_sensitivity(__attribute__((unused)) word x,__attribute__((unused)) word y)
{ {
} }
void Initialiser_chrono(dword Delai) void Init_chrono(dword delay)
// Démarrer le chrono // Démarrer le chrono
{ {
Chrono_delay = Delai; Timer_delay = delay;
Chrono_cmp = SDL_GetTicks()/55; Timer_start = SDL_GetTicks()/55;
return; return;
} }
@ -147,87 +147,87 @@ void Wait_VBL(void)
// SDL ne sait pas faire, alors on simule un timer qui a une fréquence de 100Hz, // 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) // sans charger inutilement le CPU par du busy-wait (on n'est pas à 10ms près)
{ {
const int Delai = 10; const int delay = 10;
Uint32 debut; Uint32 debut;
debut = SDL_GetTicks(); debut = SDL_GetTicks();
// Première attente : le complément de "Delai" millisecondes // Première attente : le complément de "delay" millisecondes
SDL_Delay(Delai - (debut % Delai)); SDL_Delay(delay - (debut % delay));
// Si ça ne suffit pas, on complète par des attentes successives de "1ms". // Si ça ne suffit pas, on complète par des attentes successives de "1ms".
// (Remarque, Windows arrondit généralement aux 10ms supérieures) // (Remarque, Windows arrondit généralement aux 10ms supérieures)
while (SDL_GetTicks() / Delai <= debut / Delai) while (SDL_GetTicks() / delay <= debut / delay)
{ {
SDL_Delay(1); SDL_Delay(1);
} }
} }
void Pixel_dans_brosse (word x,word y,byte Couleur) void Pixel_in_brush (word x,word y,byte color)
{ {
*(Brosse+y*Brosse_Largeur+x)=Couleur; *(Brush+y*Brush_width+x)=color;
} }
byte Lit_pixel_dans_brosse (word x,word y) byte Read_pixel_from_brush (word x,word y)
{ {
return *(Brosse + y * Brosse_Largeur + x); return *(Brush + y * Brush_width + x);
} }
byte Lit_pixel_dans_ecran_courant (word x,word y) byte Read_pixel_from_current_screen (word x,word y)
{ {
return *(Principal_Ecran+y*Principal_Largeur_image+x); return *(Main_screen+y*Main_image_width+x);
} }
void Pixel_dans_ecran_courant (word x,word y,byte Couleur) void Pixel_in_current_screen (word x,word y,byte color)
{ {
byte* dest=(x+y*Principal_Largeur_image+Principal_Ecran); byte* dest=(x+y*Main_image_width+Main_screen);
*dest=Couleur; *dest=color;
} }
void Remplacer_une_couleur(byte Ancienne_couleur, byte Nouvelle_couleur) void Replace_a_color(byte old_color, byte New_color)
{ {
byte* edi; byte* edi;
// pour chaque pixel : // pour chaque pixel :
for(edi = Principal_Ecran;edi < Principal_Ecran + Principal_Hauteur_image * Principal_Largeur_image;edi++) for(edi = Main_screen;edi < Main_screen + Main_image_height * Main_image_width;edi++)
if (*edi == Ancienne_couleur) if (*edi == old_color)
*edi = Nouvelle_couleur; *edi = New_color;
UpdateRect(0,0,0,0); // On peut TOUT a jour Update_rect(0,0,0,0); // On peut TOUT a jour
// C'est pas un problème car il n'y a pas de preview // C'est pas un problème car il n'y a pas de preview
} }
void Ellipse_Calculer_limites(short Rayon_horizontal,short Rayon_vertical) void Ellipse_compute_limites(short horizontal_radius,short vertical_radius)
{ {
Ellipse_Rayon_horizontal_au_carre = Ellipse_horizontal_radius_squared =
Rayon_horizontal * Rayon_horizontal; horizontal_radius * horizontal_radius;
Ellipse_Rayon_vertical_au_carre = Ellipse_vertical_radius_squared =
Rayon_vertical * Rayon_vertical; vertical_radius * vertical_radius;
Ellipse_Limite = Ellipse_Rayon_horizontal_au_carre * Ellipse_Rayon_vertical_au_carre; Ellipse_limit = Ellipse_horizontal_radius_squared * Ellipse_vertical_radius_squared;
} }
byte Pixel_dans_ellipse(void) byte Pixel_in_ellipse(void)
{ {
qword ediesi = Ellipse_Curseur_X * Ellipse_Curseur_X * Ellipse_Rayon_vertical_au_carre + qword ediesi = Ellipse_cursor_X * Ellipse_cursor_X * Ellipse_vertical_radius_squared +
Ellipse_Curseur_Y * Ellipse_Curseur_Y * Ellipse_Rayon_horizontal_au_carre; Ellipse_cursor_Y * Ellipse_cursor_Y * Ellipse_horizontal_radius_squared;
if((ediesi) <= Ellipse_Limite) return 255; if((ediesi) <= Ellipse_limit) return 255;
return 0; return 0;
} }
byte Pixel_dans_cercle(void) byte Pixel_in_circle(void)
{ {
if(Cercle_Curseur_X * Cercle_Curseur_X + if(Circle_cursor_X * Circle_cursor_X +
Cercle_Curseur_Y * Cercle_Curseur_Y <= Cercle_Limite) Circle_cursor_Y * Circle_cursor_Y <= Circle_limit)
return 255; return 255;
return 0; return 0;
} }
void Copier_une_partie_d_image_dans_une_autre(byte * Source,word S_Pos_X,word S_Pos_Y,word width,word height,word Largeur_source,byte * dest,word D_Pos_X,word D_Pos_Y,word Largeur_destination) void Copy_part_of_image_to_another(byte * source,word source_x,word source_y,word width,word height,word source_width,byte * dest,word dest_x,word dest_y,word destination_width)
{ {
// ESI = adresse de la source en (S_Pox_X,S_Pos_Y) // ESI = adresse de la source en (S_Pox_X,source_y)
byte* esi = Source + S_Pos_Y * Largeur_source + S_Pos_X; byte* esi = source + source_y * source_width + source_x;
// EDI = adresse de la destination (D_Pos_X,D_Pos_Y) // EDI = adresse de la destination (dest_x,dest_y)
byte* edi = dest + D_Pos_Y * Largeur_destination + D_Pos_X; byte* edi = dest + dest_y * destination_width + dest_x;
int line; int line;
@ -237,40 +237,40 @@ void Copier_une_partie_d_image_dans_une_autre(byte * Source,word S_Pos_X,word S_
memcpy(edi,esi,width); memcpy(edi,esi,width);
// Passe à la ligne suivante // Passe à la ligne suivante
esi+=Largeur_source; esi+=source_width;
edi+=Largeur_destination; edi+=destination_width;
} }
} }
byte Lit_pixel_dans_ecran_brouillon(word x,word y) byte Read_pixel_from_spare_screen(word x,word y)
{ {
return *(Brouillon_Ecran+y*Brouillon_Largeur_image+x); return *(Spare_screen+y*Spare_image_width+x);
} }
void Rotate_90_deg_LOWLEVEL(byte * Source,byte * dest) void Rotate_90_deg_lowlevel(byte * source,byte * dest)
{ {
byte* esi; byte* esi;
byte* edi; byte* edi;
word dx,bx,cx; word dx,bx,cx;
//ESI = Point haut droit de la source //ESI = Point haut droit de la source
byte* Debut_de_colonne = Source + Brosse_Largeur - 1; byte* Debut_de_colonne = source + Brush_width - 1;
edi = dest; edi = dest;
// Largeur de la source = hauteur de la destination // Largeur de la source = hauteur de la destination
dx = bx = Brosse_Largeur; dx = bx = Brush_width;
// Pour chaque ligne // Pour chaque ligne
for(dx = Brosse_Largeur;dx>0;dx--) for(dx = Brush_width;dx>0;dx--)
{ {
esi = Debut_de_colonne; esi = Debut_de_colonne;
// Pout chaque colonne // Pout chaque colonne
for(cx=Brosse_Hauteur;cx>0;cx--) for(cx=Brush_height;cx>0;cx--)
{ {
*edi = *esi; *edi = *esi;
esi+=Brosse_Largeur; esi+=Brush_width;
edi++; edi++;
} }
@ -278,9 +278,9 @@ void Rotate_90_deg_LOWLEVEL(byte * Source,byte * dest)
} }
} }
// Remplacer une couleur par une autre dans un buffer // Replace une couleur par une autre dans un buffer
void Remap_general_LOWLEVEL(byte * Table_conv,byte * Buffer,short width,short height,short Largeur_buffer) void Remap_general_lowlevel(byte * conversion_table,byte * buffer,short width,short height,short buffer_width)
{ {
int dx,cx; int dx,cx;
@ -290,46 +290,46 @@ void Remap_general_LOWLEVEL(byte * Table_conv,byte * Buffer,short width,short he
// Pour chaque pixel // Pour chaque pixel
for(cx=width;cx>0;cx--) for(cx=width;cx>0;cx--)
{ {
*Buffer = Table_conv[*Buffer]; *buffer = conversion_table[*buffer];
Buffer++; buffer++;
} }
Buffer += Largeur_buffer-width; buffer += buffer_width-width;
} }
} }
void Copier_image_dans_brosse(short Debut_X,short Debut_Y,short Brosse_Largeur,short Brosse_Hauteur,word image_width) void Copy_image_to_brush(short start_x,short start_y,short Brush_width,short Brush_height,word image_width)
{ {
byte* Src=Debut_Y*image_width+Debut_X+Principal_Ecran; //Adr départ image (ESI) byte* src=start_y*image_width+start_x+Main_screen; //Adr départ image (ESI)
byte* Dest=Brosse; //Adr dest brosse (EDI) byte* dest=Brush; //Adr dest brosse (EDI)
int dx; int dx;
for (dx=Brosse_Hauteur;dx!=0;dx--) for (dx=Brush_height;dx!=0;dx--)
//Pour chaque ligne //Pour chaque ligne
{ {
// On fait une copie de la ligne // On fait une copie de la ligne
memcpy(Dest,Src,Brosse_Largeur); memcpy(dest,src,Brush_width);
// On passe à la ligne suivante // On passe à la ligne suivante
Src+=image_width; src+=image_width;
Dest+=Brosse_Largeur; dest+=Brush_width;
} }
} }
byte Lit_pixel_dans_ecran_feedback (word x,word y) byte Read_pixel_from_feedback_screen (word x,word y)
{ {
return *(FX_Feedback_Ecran+y*Principal_Largeur_image+x); return *(FX_feedback_screen+y*Main_image_width+x);
} }
dword Round_div(dword Numerateur,dword Diviseur) dword Round_div(dword numerator,dword divisor)
{ {
return Numerateur/Diviseur; return numerator/divisor;
} }
byte Effet_Trame(word x,word y) byte Effect_sieve(word x,word y)
{ {
return Trame[x % Trame_Largeur][y % Trame_Hauteur]; return Sieve[x % Sieve_width][y % Sieve_height];
} }
void Set_mouse_position(void) void Set_mouse_position(void)
@ -340,30 +340,30 @@ void Set_mouse_position(void)
); );
} }
void Remplacer_toutes_les_couleurs_dans_limites(byte * Table_de_remplacement) void Replace_colors_within_limits(byte * replace_table)
{ {
int line; int line;
int counter; int counter;
byte* Adresse; byte* Adresse;
byte Ancien; byte old;
// Pour chaque ligne : // Pour chaque ligne :
for(line = Limite_Haut;line <= Limite_Bas; line++) for(line = Limit_top;line <= Limit_bottom; line++)
{ {
// Pour chaque pixel sur la ligne : // Pour chaque pixel sur la ligne :
for (counter = Limite_Gauche;counter <= Limite_Droite;counter ++) for (counter = Limit_left;counter <= Limit_right;counter ++)
{ {
Adresse = Principal_Ecran+line*Principal_Largeur_image+counter; Adresse = Main_screen+line*Main_image_width+counter;
Ancien=*Adresse; old=*Adresse;
*Adresse = Table_de_remplacement[Ancien]; *Adresse = replace_table[old];
} }
} }
} }
byte Lit_pixel_dans_ecran_backup (word x,word y) byte Read_pixel_from_backup_screen (word x,word y)
{ {
return *(Ecran_backup + x + Principal_Largeur_image * y); return *(Screen_backup + x + Main_image_width * y);
} }
void Palette_256_to_64(T_Palette palette) void Palette_256_to_64(T_Palette palette)
@ -388,87 +388,87 @@ void Palette_64_to_256(T_Palette palette)
} }
} }
byte Effet_Colorize_interpole (word x,word y,byte Couleur) byte Effect_interpolated_colorize (word x,word y,byte color)
{ {
// Facteur_A = 256*(100-Colorize_Opacite)/100 // factor_a = 256*(100-Colorize_opacity)/100
// Facteur_B = 256*( Colorize_Opacite)/100 // factor_b = 256*( Colorize_opacity)/100
// //
// (Couleur_dessous*Facteur_A+Couleur*facteur_B)/256 // (Couleur_dessous*factor_a+color*facteur_B)/256
// //
// On place dans ESI 3*Couleur_dessous ( = position de cette couleur dans la // On place dans ESI 3*Couleur_dessous ( = position de cette couleur dans la
// palette des teintes) et dans EDI, 3*Couleur. // palette des teintes) et dans EDI, 3*color.
byte Bleu_dessous=Principal_Palette[*(FX_Feedback_Ecran + y * Principal_Largeur_image + x)].B; byte blue_under=Main_palette[*(FX_feedback_screen + y * Main_image_width + x)].B;
byte Bleu=Principal_Palette[Couleur].B; byte blue=Main_palette[color].B;
byte Vert_dessous=Principal_Palette[*(FX_Feedback_Ecran + y * Principal_Largeur_image + x)].G; byte green_under=Main_palette[*(FX_feedback_screen + y * Main_image_width + x)].G;
byte Vert=Principal_Palette[Couleur].G; byte green=Main_palette[color].G;
byte Rouge_dessous=Principal_Palette[*(FX_Feedback_Ecran + y * Principal_Largeur_image + x)].R; byte red_under=Main_palette[*(FX_feedback_screen + y * Main_image_width + x)].R;
byte Rouge=Principal_Palette[Couleur].R; byte red=Main_palette[color].R;
// On récupère les 3 composantes RVB // On récupère les 3 composantes RVB
// Bleu // blue
Bleu = (Table_de_multiplication_par_Facteur_B[Bleu] blue = (Facteur_B_table[blue]
+ Table_de_multiplication_par_Facteur_A[Bleu_dessous]) / 256; + Facteur_A_table[blue_under]) / 256;
Vert = (Table_de_multiplication_par_Facteur_B[Vert] green = (Facteur_B_table[green]
+ Table_de_multiplication_par_Facteur_A[Vert_dessous]) / 256; + Facteur_A_table[green_under]) / 256;
Rouge = (Table_de_multiplication_par_Facteur_B[Rouge] red = (Facteur_B_table[red]
+ Table_de_multiplication_par_Facteur_A[Rouge_dessous]) / 256; + Facteur_A_table[red_under]) / 256;
return Meilleure_couleur(Rouge,Vert,Bleu); return Best_color(red,green,blue);
} }
byte Effet_Colorize_additif (word x,word y,byte Couleur) byte Effect_additive_colorize (word x,word y,byte color)
{ {
byte Bleu_dessous=Principal_Palette[*(FX_Feedback_Ecran + y * Principal_Largeur_image + x)].B; byte blue_under=Main_palette[*(FX_feedback_screen + y * Main_image_width + x)].B;
byte Vert_dessous=Principal_Palette[*(FX_Feedback_Ecran + y * Principal_Largeur_image + x)].G; byte green_under=Main_palette[*(FX_feedback_screen + y * Main_image_width + x)].G;
byte Rouge_dessous=Principal_Palette[*(FX_Feedback_Ecran + y * Principal_Largeur_image + x)].R; byte red_under=Main_palette[*(FX_feedback_screen + y * Main_image_width + x)].R;
byte Bleu=Principal_Palette[Couleur].B; byte blue=Main_palette[color].B;
byte Vert=Principal_Palette[Couleur].G; byte green=Main_palette[color].G;
byte Rouge=Principal_Palette[Couleur].R; byte red=Main_palette[color].R;
return Meilleure_couleur( return Best_color(
Rouge>Rouge_dessous?Rouge:Rouge_dessous, red>red_under?red:red_under,
Vert>Vert_dessous?Vert:Vert_dessous, green>green_under?green:green_under,
Bleu>Bleu_dessous?Bleu:Bleu_dessous); blue>blue_under?blue:blue_under);
} }
byte Effet_Colorize_soustractif(word x,word y,byte Couleur) byte Effect_substractive_colorize(word x,word y,byte color)
{ {
byte Bleu_dessous=Principal_Palette[*(FX_Feedback_Ecran + y * Principal_Largeur_image + x)].B; byte blue_under=Main_palette[*(FX_feedback_screen + y * Main_image_width + x)].B;
byte Vert_dessous=Principal_Palette[*(FX_Feedback_Ecran + y * Principal_Largeur_image + x)].G; byte green_under=Main_palette[*(FX_feedback_screen + y * Main_image_width + x)].G;
byte Rouge_dessous=Principal_Palette[*(FX_Feedback_Ecran + y * Principal_Largeur_image + x)].R; byte red_under=Main_palette[*(FX_feedback_screen + y * Main_image_width + x)].R;
byte Bleu=Principal_Palette[Couleur].B; byte blue=Main_palette[color].B;
byte Vert=Principal_Palette[Couleur].G; byte green=Main_palette[color].G;
byte Rouge=Principal_Palette[Couleur].R; byte red=Main_palette[color].R;
return Meilleure_couleur( return Best_color(
Rouge<Rouge_dessous?Rouge:Rouge_dessous, red<red_under?red:red_under,
Vert<Vert_dessous?Vert:Vert_dessous, green<green_under?green:green_under,
Bleu<Bleu_dessous?Bleu:Bleu_dessous); blue<blue_under?blue:blue_under);
} }
void Tester_chrono(void) void Check_timer(void)
{ {
if((SDL_GetTicks()/55)-Chrono_delay>Chrono_cmp) Etat_chrono=1; if((SDL_GetTicks()/55)-Timer_delay>Timer_start) Timer_state=1;
} }
// Effectue une inversion de la brosse selon une droite horizontale // Effectue une inversion de la brosse selon une droite horizontale
void Flip_Y_LOWLEVEL(void) void Flip_Y_lowlevel(void)
{ {
// ESI pointe sur la partie haute de la brosse // ESI pointe sur la partie haute de la brosse
// EDI sur la partie basse // EDI sur la partie basse
byte* ESI = Brosse ; byte* ESI = Brush ;
byte* EDI = Brosse + (Brosse_Hauteur - 1) *Brosse_Largeur; byte* EDI = Brush + (Brush_height - 1) *Brush_width;
byte tmp; byte tmp;
word cx; word cx;
while(ESI < EDI) while(ESI < EDI)
{ {
// Il faut inverser les lignes pointées par ESI et // Il faut inverser les lignes pointées par ESI et
// EDI ("Brosse_Largeur" octets en tout) // EDI ("Brush_width" octets en tout)
for(cx = Brosse_Largeur;cx>0;cx--) for(cx = Brush_width;cx>0;cx--)
{ {
tmp = *ESI; tmp = *ESI;
*ESI = *EDI; *ESI = *EDI;
@ -481,17 +481,17 @@ void Flip_Y_LOWLEVEL(void)
// ESI pointe déjà sur le début de la ligne suivante // ESI pointe déjà sur le début de la ligne suivante
// EDI pointe sur la fin de la ligne en cours, il // EDI pointe sur la fin de la ligne en cours, il
// doit pointer sur le début de la précédente... // doit pointer sur le début de la précédente...
EDI -= 2 * Brosse_Largeur; // On recule de 2 lignes EDI -= 2 * Brush_width; // On recule de 2 lignes
} }
} }
// Effectue une inversion de la brosse selon une droite verticale // Effectue une inversion de la brosse selon une droite verticale
void Flip_X_LOWLEVEL(void) void Flip_X_lowlevel(void)
{ {
// ESI pointe sur la partie gauche et EDI sur la partie // ESI pointe sur la partie gauche et EDI sur la partie
// droite // droite
byte* ESI = Brosse; byte* ESI = Brush;
byte* EDI = Brosse + Brosse_Largeur - 1; byte* EDI = Brush + Brush_width - 1;
byte* Debut_Ligne; byte* Debut_Ligne;
byte* Fin_Ligne; byte* Fin_Ligne;
@ -504,13 +504,13 @@ void Flip_X_LOWLEVEL(void)
Fin_Ligne = EDI; Fin_Ligne = EDI;
// On échange par colonnes // On échange par colonnes
for(cx=Brosse_Hauteur;cx>0;cx--) for(cx=Brush_height;cx>0;cx--)
{ {
tmp=*ESI; tmp=*ESI;
*ESI=*EDI; *ESI=*EDI;
*EDI=tmp; *EDI=tmp;
EDI+=Brosse_Largeur; EDI+=Brush_width;
ESI+=Brosse_Largeur; ESI+=Brush_width;
} }
// On change de colonne // On change de colonne
@ -522,12 +522,12 @@ void Flip_X_LOWLEVEL(void)
} }
// Faire une rotation de 180º de la brosse // Faire une rotation de 180º de la brosse
void Rotate_180_deg_LOWLEVEL(void) void Rotate_180_deg_lowlevel(void)
{ {
// ESI pointe sur la partie supérieure de la brosse // ESI pointe sur la partie supérieure de la brosse
// EDI pointe sur la partie basse // EDI pointe sur la partie basse
byte* ESI = Brosse; byte* ESI = Brush;
byte* EDI = Brosse + Brosse_Hauteur*Brosse_Largeur - 1; byte* EDI = Brush + Brush_height*Brush_width - 1;
// EDI pointe sur le dernier pixel de la derniere ligne // EDI pointe sur le dernier pixel de la derniere ligne
byte tmp; byte tmp;
word cx; word cx;
@ -535,11 +535,11 @@ void Rotate_180_deg_LOWLEVEL(void)
while(ESI < EDI) while(ESI < EDI)
{ {
// On échange les deux lignes pointées par EDI et // On échange les deux lignes pointées par EDI et
// ESI (Brosse_Largeur octets) // ESI (Brush_width octets)
// En même temps, on échange les pixels, donc EDI // En même temps, on échange les pixels, donc EDI
// pointe sur la FIN de sa ligne // pointe sur la FIN de sa ligne
for(cx=Brosse_Largeur;cx>0;cx--) for(cx=Brush_width;cx>0;cx--)
{ {
tmp = *ESI; tmp = *ESI;
*ESI = *EDI; *ESI = *EDI;
@ -551,51 +551,51 @@ void Rotate_180_deg_LOWLEVEL(void)
} }
} }
void Tempo_jauge(byte Vitesse) void Slider_timer(byte speed)
//Boucle d'attente pour faire bouger les scrollbars à une vitesse correcte //Boucle d'attente pour faire bouger les scrollbars à une vitesse correcte
{ {
Uint32 end; Uint32 end;
byte MouseK_Original = Mouse_K; byte original_mouse_k = Mouse_K;
end = SDL_GetTicks() + Vitesse*10; end = SDL_GetTicks() + speed*10;
do do
{ {
if (!Get_input()) Wait_VBL(); if (!Get_input()) Wait_VBL();
} while (Mouse_K == MouseK_Original && SDL_GetTicks()<end); } while (Mouse_K == original_mouse_k && SDL_GetTicks()<end);
} }
void Scroll_picture(short x_offset,short y_offset) void Scroll_picture(short x_offset,short y_offset)
{ {
byte* esi = Ecran_backup; //Source de la copie byte* esi = Screen_backup; //source de la copie
byte* edi = Principal_Ecran + y_offset * Principal_Largeur_image + x_offset; byte* edi = Main_screen + y_offset * Main_image_width + x_offset;
const word ax = Principal_Largeur_image - x_offset; // Nombre de pixels à copier à droite const word ax = Main_image_width - x_offset; // Nombre de pixels à copier à droite
word dx; word dx;
for(dx = Principal_Hauteur_image - y_offset;dx>0;dx--) for(dx = Main_image_height - y_offset;dx>0;dx--)
{ {
// Pour chaque ligne // Pour chaque ligne
memcpy(edi,esi,ax); memcpy(edi,esi,ax);
memcpy(edi - x_offset,esi+ax,x_offset); memcpy(edi - x_offset,esi+ax,x_offset);
// On passe à la ligne suivante // On passe à la ligne suivante
edi += Principal_Largeur_image; edi += Main_image_width;
esi += Principal_Largeur_image; esi += Main_image_width;
} }
// On vient de faire le traitement pour otutes les lignes au-dessous de y_offset // On vient de faire le traitement pour otutes les lignes au-dessous de y_offset
// Maintenant on traite celles au dessus // Maintenant on traite celles au dessus
edi = x_offset + Principal_Ecran; edi = x_offset + Main_screen;
for(dx = y_offset;dx>0;dx--) for(dx = y_offset;dx>0;dx--)
{ {
memcpy(edi,esi,ax); memcpy(edi,esi,ax);
memcpy(edi - x_offset,esi+ax,x_offset); memcpy(edi - x_offset,esi+ax,x_offset);
edi += Principal_Largeur_image; edi += Main_image_width;
esi += Principal_Largeur_image; esi += Main_image_width;
} }
UpdateRect(0,0,0,0); Update_rect(0,0,0,0);
} }
void Zoomer_une_ligne(byte* Ligne_originale, byte* Ligne_zoomee, void Zoom_a_line(byte* original_line, byte* zoomed_line,
word factor, word width word factor, word width
) )
{ {
@ -604,12 +604,12 @@ void Zoomer_une_ligne(byte* Ligne_originale, byte* Ligne_zoomee,
// Pour chaque pixel // Pour chaque pixel
for(x=0;x<width;x++){ for(x=0;x<width;x++){
color = *Ligne_originale; color = *original_line;
memset(Ligne_zoomee,color,factor); memset(zoomed_line,color,factor);
Ligne_zoomee+=factor; zoomed_line+=factor;
Ligne_originale++; original_line++;
} }
} }
@ -631,7 +631,7 @@ void Zoomer_une_ligne(byte* Ligne_originale, byte* Ligne_zoomee,
#endif #endif
// Indique quelle est la mémoire disponible // Indique quelle est la mémoire disponible
unsigned long Memoire_libre(void) unsigned long Memory_free(void)
{ {
// Memory is no longer relevant. If there is ANY problem or doubt here, // Memory is no longer relevant. If there is ANY problem or doubt here,
// you can simply return 10*1024*1024 (10Mb), to make the "Pages"something // you can simply return 10*1024*1024 (10Mb), to make the "Pages"something
@ -673,30 +673,30 @@ unsigned long Memoire_libre(void)
// Transformer un nombre (entier naturel) en chaîne // Transformer un nombre (entier naturel) en chaîne
void Num2str(dword number,char * Chaine,byte nb_char) void Num2str(dword number,char * str,byte nb_char)
{ {
int Indice; int index;
for (Indice=nb_char-1;Indice>=0;Indice--) for (index=nb_char-1;index>=0;index--)
{ {
Chaine[Indice]=(number%10)+'0'; str[index]=(number%10)+'0';
number/=10; number/=10;
if (number==0) if (number==0)
for (Indice--;Indice>=0;Indice--) for (index--;index>=0;index--)
Chaine[Indice]=' '; str[index]=' ';
} }
Chaine[nb_char]='\0'; str[nb_char]='\0';
} }
// Transformer une chaîne en un entier naturel (renvoie -1 si ch. invalide) // Transformer une chaîne en un entier naturel (renvoie -1 si ch. invalide)
int Str2num(char * Chaine) int Str2num(char * str)
{ {
int value=0; int value=0;
for (;*Chaine;Chaine++) for (;*str;str++)
{ {
if ( (*Chaine>='0') && (*Chaine<='9') ) if ( (*str>='0') && (*str<='9') )
value=(value*10)+(*Chaine-'0'); value=(value*10)+(*str-'0');
else else
return -1; return -1;
} }
@ -707,23 +707,23 @@ int Str2num(char * Chaine)
// Arrondir un nombre réel à la valeur entière la plus proche // Arrondir un nombre réel à la valeur entière la plus proche
short Round(float value) short Round(float value)
{ {
short Temp=value; short temp=value;
if (value>=0) if (value>=0)
{ if ((value-Temp)>= 0.5) Temp++; } { if ((value-temp)>= 0.5) temp++; }
else else
{ if ((value-Temp)<=-0.5) Temp--; } { if ((value-temp)<=-0.5) temp--; }
return Temp; return temp;
} }
// Arrondir le résultat d'une division à la valeur entière supérieure // Arrondir le résultat d'une division à la valeur entière supérieure
short Round_div_max(short Numerateur,short Diviseur) short Round_div_max(short numerator,short divisor)
{ {
if (!(Numerateur % Diviseur)) if (!(numerator % divisor))
return (Numerateur/Diviseur); return (numerator/divisor);
else else
return (Numerateur/Diviseur)+1; return (numerator/divisor)+1;
} }
// Retourne le minimum entre deux nombres // Retourne le minimum entre deux nombres
@ -741,27 +741,27 @@ int Max(int a,int b)
// Fonction retournant le libellé d'une mode (ex: " 320x200") // Fonction retournant le libellé d'une mode (ex: " 320x200")
char * Libelle_mode(int mode) char * Mode_label(int mode)
{ {
static char Chaine[24]; static char str[24];
if (! Mode_video[mode].Fullscreen) if (! Video_mode[mode].Fullscreen)
return "window"; return "window";
sprintf(Chaine, "%dx%d", Mode_video[mode].Width, Mode_video[mode].Height); sprintf(str, "%dx%d", Video_mode[mode].Width, Video_mode[mode].Height);
return Chaine; return str;
} }
// Trouve un mode video à partir d'une chaine: soit "window", // Trouve un mode video à partir d'une chaine: soit "window",
// soit de la forme "320x200" // soit de la forme "320x200"
// Renvoie -1 si la chaine n'est pas convertible // Renvoie -1 si la chaine n'est pas convertible
int Conversion_argument_mode(const char *Argument) int Convert_videomode_arg(const char *argument)
{ {
// Je suis paresseux alors je vais juste tester les libellés // Je suis paresseux alors je vais juste tester les libellés
int Indice_mode; int mode_index;
for (Indice_mode=0; Indice_mode<Nb_modes_video; Indice_mode++) for (mode_index=0; mode_index<Nb_video_modes; mode_index++)
// Attention les vieilles fonctions de lecture .ini mettent tout en MAJUSCULE. // Attention les vieilles fonctions de lecture .ini mettent tout en MAJUSCULE.
if (!strcasecmp(Libelle_mode(Indice_mode), Argument)) if (!strcasecmp(Mode_label(mode_index), argument))
return Indice_mode; return mode_index;
return -1; return -1;
} }

114
divers.h
View File

@ -20,94 +20,94 @@
*/ */
void Effacer_ecran_courant(void); void Effacer_ecran_courant(void);
void Copier_ecran_sur_brouillon(void); void Copier_ecran_sur_brouillon(void);
void Copier_image_dans_brosse(short Debut_X,short Debut_Y,short Brosse_Largeur,short Brosse_Hauteur,word image_width); void Copy_image_to_brush(short start_x,short start_y,short Brush_width,short Brush_height,word image_width);
void Permuter_dans_l_image_les_couleurs(byte Couleur_1,byte Couleur_2); void Permuter_dans_l_image_les_couleurs(byte color_1,byte color_2);
void Remap_general_LOWLEVEL(byte * Table_conv,byte * Buffer,short width,short height,short Largeur_buffer); void Remap_general_lowlevel(byte * conversion_table,byte * buffer,short width,short height,short buffer_width);
void Scroll_picture(short x_offset,short y_offset); void Scroll_picture(short x_offset,short y_offset);
void Set_mouse_video_mode_number(void); void Set_mouse_video_mode_number(void);
void Set_mouse_position(void); void Set_mouse_position(void);
void Attendre_fin_de_click(void); void Wait_end_of_click(void);
void Sensibilite_souris(word x,word y); void Mouse_sensitivity(word x,word y);
void Set_color(byte Couleur, byte Rouge, byte Vert, byte Bleu); void Set_color(byte color, byte red, byte green, byte blue);
void Set_palette(T_Palette palette); void Set_palette(T_Palette palette);
void Palette_256_to_64(T_Palette palette); 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 Effacer_image_courante(byte Couleur); void Hide_current_image(byte color);
void Effacer_image_courante_Stencil(byte Couleur, byte * Pochoir); void Hide_current_image_with_stencil(byte color, byte * stencil);
void Wait_VBL(void); void Wait_VBL(void);
void Tempo_jauge(byte Vitesse); void Slider_timer(byte speed);
dword Round_div(dword Numerateur,dword Diviseur); dword Round_div(dword numerator,dword divisor);
word Palette_Compter_nb_couleurs_utilisees(dword * usage); word Count_used_colors(dword * usage);
void Pixel_dans_ecran_courant (word x,word y,byte Couleur); void Pixel_in_current_screen (word x,word y,byte color);
void Pixel_dans_brosse (word x,word y,byte Couleur); void Pixel_in_brush (word x,word y,byte color);
byte Lit_pixel_dans_ecran_courant (word x,word y); byte Read_pixel_from_current_screen (word x,word y);
byte Lit_pixel_dans_ecran_brouillon(word x,word y); byte Read_pixel_from_spare_screen(word x,word y);
byte Lit_pixel_dans_ecran_backup (word x,word y); byte Read_pixel_from_backup_screen (word x,word y);
byte Lit_pixel_dans_ecran_feedback (word x,word y); byte Read_pixel_from_feedback_screen (word x,word y);
byte Lit_pixel_dans_brosse (word x,word y); byte Read_pixel_from_brush (word x,word y);
void Ellipse_Calculer_limites(short Rayon_horizontal,short Rayon_vertical); void Ellipse_compute_limites(short horizontal_radius,short vertical_radius);
// Calcule les valeurs suivantes en fonction des deux paramètres: // Calcule les valeurs suivantes en fonction des deux paramètres:
// //
// Ellipse_Rayon_vertical_au_carre // Ellipse_vertical_radius_squared
// Ellipse_Rayon_horizontal_au_carre // Ellipse_horizontal_radius_squared
// Ellipse_Limite_High // Ellipse_Limit_High
// Ellipse_Limite_Low // Ellipse_Limit_Low
byte Pixel_dans_ellipse(void); byte Pixel_in_ellipse(void);
// Indique si le pixel se trouvant à Ellipse_Curseur_X pixels // Indique si le pixel se trouvant à Ellipse_cursor_X pixels
// (Ellipse_Curseur_X>0 = à droite, Ellipse_Curseur_X<0 = à gauche) et à // (Ellipse_cursor_X>0 = à droite, Ellipse_cursor_X<0 = à gauche) et à
// Ellipse_Curseur_Y pixels (Ellipse_Curseur_Y>0 = en bas, // Ellipse_cursor_Y pixels (Ellipse_cursor_Y>0 = en bas,
// Ellipse_Curseur_Y<0 = en haut) du centre se trouve dans l'ellipse en // Ellipse_cursor_Y<0 = en haut) du centre se trouve dans l'ellipse en
// cours. // cours.
byte Pixel_dans_cercle(void); byte Pixel_in_circle(void);
// Indique si le pixel se trouvant à Cercle_Curseur_X pixels // Indique si le pixel se trouvant à Circle_cursor_X pixels
// (Cercle_Curseur_X>0 = à droite, Cercle_Curseur_X<0 = à gauche) et à // (Circle_cursor_X>0 = à droite, Circle_cursor_X<0 = à gauche) et à
// Cercle_Curseur_Y pixels (Cercle_Curseur_Y>0 = en bas, // Circle_cursor_Y pixels (Circle_cursor_Y>0 = en bas,
// Cercle_Curseur_Y<0 = en haut) du centre se trouve dans le cercle en // Circle_cursor_Y<0 = en haut) du centre se trouve dans le cercle en
// cours. // cours.
// Gestion du chrono dans les fileselects // Gestion du chrono dans les fileselects
void Initialiser_chrono(dword Delai); void Init_chrono(dword delay);
void Tester_chrono(void); void Check_timer(void);
void Remplacer_une_couleur(byte Ancienne_couleur, byte Nouvelle_couleur); void Replace_a_color(byte old_color, byte New_color);
void Remplacer_toutes_les_couleurs_dans_limites(byte * Table_de_remplacement); void Replace_colors_within_limits(byte * replace_table);
byte Effet_Colorize_interpole (word x,word y,byte Couleur); byte Effect_interpolated_colorize (word x,word y,byte color);
byte Effet_Colorize_additif (word x,word y,byte Couleur); byte Effect_additive_colorize (word x,word y,byte color);
byte Effet_Colorize_soustractif(word x,word y,byte Couleur); byte Effect_substractive_colorize(word x,word y,byte color);
byte Effet_Trame(word x,word y); byte Effect_sieve(word x,word y);
void Flip_Y_LOWLEVEL(void); void Flip_Y_lowlevel(void);
void Flip_X_LOWLEVEL(void); void Flip_X_lowlevel(void);
void Rotate_90_deg_LOWLEVEL(byte * Source,byte * dest); void Rotate_90_deg_lowlevel(byte * source,byte * dest);
void Rotate_180_deg_LOWLEVEL(void); void Rotate_180_deg_lowlevel(void);
void Zoomer_une_ligne(byte * Ligne_originale,byte * Ligne_zoomee,word factor,word width); void Zoom_a_line(byte * original_line,byte * zoomed_line,word factor,word width);
void Copier_une_partie_d_image_dans_une_autre(byte * Source,word S_Pos_X,word S_Pos_Y,word width,word height,word Largeur_source,byte * dest,word D_Pos_X,word D_Pos_Y,word Largeur_destination); void Copy_part_of_image_to_another(byte * source,word source_x,word source_y,word width,word height,word source_width,byte * dest,word dest_x,word dest_y,word destination_width);
// -- Gestion du chrono -- // -- Gestion du chrono --
byte Etat_chrono; // Etat du chrono: 0=Attente d'un Xème de seconde byte Timer_state; // State du chrono: 0=Attente d'un Xème de seconde
// 1=Il faut afficher la preview // 1=Il faut afficher la preview
// 2=Plus de chrono à gerer pour l'instant // 2=Plus de chrono à gerer pour l'instant
dword Chrono_delay; // Nombre de 18.2ème de secondes demandés dword Timer_delay; // Nombre de 18.2ème de secondes demandés
dword Chrono_cmp; // Heure de départ du chrono dword Timer_start; // Heure de départ du chrono
byte Nouvelle_preview; // Booléen "Il faut relancer le chrono de preview" byte New_preview_is_needed; // Booléen "Il faut relancer le chrono de preview"
unsigned long Memoire_libre(void); unsigned long Memory_free(void);
void Num2str(dword number,char * Chaine,byte nb_char); void Num2str(dword number,char * str,byte nb_char);
int Str2num(char * Chaine); int Str2num(char * str);
short Round(float value); short Round(float value);
short Round_div_max(short Numerateur,short Diviseur); short Round_div_max(short numerator,short divisor);
int Min(int a,int b); int Min(int a,int b);
int Max(int a,int b); int Max(int a,int b);
char* Libelle_mode(int mode); char* Mode_label(int mode);
int Conversion_argument_mode(const char *Argument); int Convert_videomode_arg(const char *argument);

View File

@ -27,6 +27,6 @@
#define UNTESTED printf("%s %d %s à tester !\n",__FILE__,__LINE__,__func__); #define UNTESTED printf("%s %d %s à tester !\n",__FILE__,__LINE__,__func__);
void Erreur_fonction(int error_code, const char *filename, int Numero_ligne, const char *Nom_fonction); void Error_function(int error_code, const char *filename, int line_number, const char *function_name);
#define Erreur(n) Erreur_fonction(n, __FILE__,__LINE__,__func__) #define Error(n) Error_function(n, __FILE__,__LINE__,__func__)

1388
files.c

File diff suppressed because it is too large Load Diff

View File

@ -19,4 +19,4 @@
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
byte Bouton_Load_ou_Save(byte load, byte image); byte Button_Load_or_Save(byte load, byte image);

736
global.h
View File

@ -21,7 +21,7 @@
// Dans MAIN on declare les variables // Dans MAIN on declare les variables
// Dans les autres fichiers, on ne fait que les référencer // Dans les autres fichiers, on ne fait que les référencer
#ifdef VARIABLES_GLOBALES #ifdef GLOBAL_VARIABLES
#define GFX2_GLOBAL #define GFX2_GLOBAL
#else #else
#define GFX2_GLOBAL extern #define GFX2_GLOBAL extern
@ -45,7 +45,7 @@
GFX2_GLOBAL T_Config Config; GFX2_GLOBAL T_Config Config;
// Tableau des touches spéciales // Tableau des touches spéciales
GFX2_GLOBAL word Config_Touche[NB_TOUCHES_SPECIALES][2]; GFX2_GLOBAL word Config_Key[NB_SPECIAL_SHORTCUTS][2];
typedef struct typedef struct
@ -54,37 +54,37 @@ typedef struct
short Height; short Height;
byte Mode; byte Mode;
word Fullscreen; word Fullscreen;
byte Etat; // 0:Cool 1:OK ; 2:Bof ; 3:Naze ; si on rajoute +128 => incompatible byte State; // 0:Cool 1:OK ; 2:Bof ; 3:Naze ; si on rajoute +128 => incompatible
} T_Video_mode; } T_Video_mode;
GFX2_GLOBAL T_Video_mode Mode_video[MAX_MODES_VIDEO]; GFX2_GLOBAL T_Video_mode Video_mode[MAX_VIDEO_MODES];
GFX2_GLOBAL int Nb_modes_video; // Nombre de modes réellement recensés dans Mode_video[] GFX2_GLOBAL int Nb_video_modes; // Nombre de modes réellement recensés dans Video_mode[]
// Palette par défaut // Palette par défaut
GFX2_GLOBAL T_Palette Palette_defaut; GFX2_GLOBAL T_Palette Default_palette;
// Couleurs du menu // Couleurs du menu
GFX2_GLOBAL byte CM_Noir; GFX2_GLOBAL byte MC_Black;
GFX2_GLOBAL byte CM_Fonce; GFX2_GLOBAL byte MC_Dark;
GFX2_GLOBAL byte CM_Clair; GFX2_GLOBAL byte MC_Light;
GFX2_GLOBAL byte CM_Blanc; GFX2_GLOBAL byte MC_White;
GFX2_GLOBAL byte CM_Trans; GFX2_GLOBAL byte MC_Trans;
GFX2_GLOBAL Composantes Coul_menu_pref[4]; GFX2_GLOBAL T_Components Fav_menu_colors[4];
// Etat des entrées // State des entrées
GFX2_GLOBAL word Mouse_X; // Abscisse de la souris GFX2_GLOBAL word Mouse_X; // Abscisse de la souris
GFX2_GLOBAL word Mouse_Y; // Ordonnée de la souris GFX2_GLOBAL word Mouse_Y; // Ordonnée de la souris
GFX2_GLOBAL byte Mouse_K; // Etat des boutons de la souris (tient comte des boutons appuyés simultanéments GFX2_GLOBAL byte Mouse_K; // State des boutons de la souris (tient comte des boutons appuyés simultanéments
#define Mouse_K_Unique (Mouse_K==0?0:(Mouse_K&1?1:(Mouse_K&2?2:0))) // Etat des boutons de la souris (un seul bouton à la fois, on regarde d'abord le 1, puis le 2, ...) #define Mouse_K_unique (Mouse_K==0?0:(Mouse_K&1?1:(Mouse_K&2?2:0))) // State des boutons de la souris (un seul bouton à la fois, on regarde d'abord le 1, puis le 2, ...)
GFX2_GLOBAL dword Touche; // Touche tapée GFX2_GLOBAL dword Key; // Key tapée
GFX2_GLOBAL dword Touche_ANSI; // Caractère tapé GFX2_GLOBAL dword Key_ANSI; // Caractère tapé
GFX2_GLOBAL Uint8* Etat_Du_Clavier; // Scancode de la touche en cours et etat des touches de ctrl GFX2_GLOBAL Uint8* Keyboard_state; // Scancode de la touche en cours et etat des touches de ctrl
// Modificateurs pour Touche // Modificateurs pour Key
// (Name conflict with windows.h) // (Name conflict with windows.h)
#ifdef MOD_SHIFT #ifdef MOD_SHIFT
#undef MOD_SHIFT #undef MOD_SHIFT
@ -99,244 +99,244 @@ GFX2_GLOBAL Uint8* Etat_Du_Clavier; // Scancode de la touche en cours et etat d
#define MOD_CTRL 0x2000 #define MOD_CTRL 0x2000
#define MOD_ALT 0x4000 #define MOD_ALT 0x4000
GFX2_GLOBAL byte Quit_demande; // !=0 lorsque l'utilisateur demande la fermeture de fenêtre. GFX2_GLOBAL byte Quit_is_required; // !=0 lorsque l'utilisateur demande la fermeture de fenêtre.
GFX2_GLOBAL byte Mouse_Facteur_de_correction_X; GFX2_GLOBAL byte Mouse_fix_factor_X;
GFX2_GLOBAL byte Mouse_Facteur_de_correction_Y; GFX2_GLOBAL byte Mouse_fix_factor_Y;
GFX2_GLOBAL byte Autoriser_changement_de_couleur_pendant_operation; GFX2_GLOBAL byte Allow_color_change_during_operation;
// Données sur le curseur // Données sur le curseur
GFX2_GLOBAL byte Forme_curseur; GFX2_GLOBAL byte Cursor_shape;
GFX2_GLOBAL byte Forme_curseur_avant_fenetre; // Forme du curseur avant l'ouverture d'une fenêtre GFX2_GLOBAL byte Cursor_shape_before_window; // Forme du curseur avant l'ouverture d'une fenêtre
GFX2_GLOBAL byte Cacher_curseur; GFX2_GLOBAL byte Cursor_hidden;
GFX2_GLOBAL byte Curseur_dans_menu; // Booléen "Le curseur se trouve dans le menu" GFX2_GLOBAL byte Cursor_in_menu; // Booléen "Le curseur se trouve dans le menu"
GFX2_GLOBAL byte Curseur_dans_menu_precedent; // Booléen "Le curseur se trouvait précédemment dans le menu" GFX2_GLOBAL byte Cursor_in_menu_precedent; // Booléen "Le curseur se trouvait précédemment dans le menu"
GFX2_GLOBAL word Curseur_Decalage_X[NB_SPRITES_CURSEUR]; // Coordonnées X du point sensible de curseurs en sprite GFX2_GLOBAL word Cursor_offset_X[NB_CURSOR_SPRITES]; // Coordonnées X du point sensible de curseurs en sprite
GFX2_GLOBAL word Curseur_Decalage_Y[NB_SPRITES_CURSEUR]; // Coordonnées Y du point sensible de curseurs en sprite GFX2_GLOBAL word Cursor_offset_Y[NB_CURSOR_SPRITES]; // Coordonnées Y du point sensible de curseurs en sprite
GFX2_GLOBAL byte SPRITE_CURSEUR[NB_SPRITES_CURSEUR][HAUTEUR_SPRITE_CURSEUR][LARGEUR_SPRITE_CURSEUR]; // Dessins des sprites de curseur GFX2_GLOBAL byte GFX_cursor_sprite[NB_CURSOR_SPRITES][CURSOR_SPRITE_HEIGHT][CURSOR_SPRITE_WIDTH]; // Dessins des sprites de curseur
GFX2_GLOBAL byte FOND_CURSEUR[HAUTEUR_SPRITE_CURSEUR][LARGEUR_SPRITE_CURSEUR]; // Contenu du dessous du curseur GFX2_GLOBAL byte CURSOR_BACKGROUND[CURSOR_SPRITE_HEIGHT][CURSOR_SPRITE_WIDTH]; // Contenu du dessous du curseur
// Données sur le pinceau // Données sur le pinceau
GFX2_GLOBAL byte Pinceau_Forme; GFX2_GLOBAL byte Paintbrush_shape;
GFX2_GLOBAL byte Pinceau_Forme_avant_fill; GFX2_GLOBAL byte Paintbrush_shape_before_fill;
GFX2_GLOBAL byte Pinceau_Forme_avant_pipette; GFX2_GLOBAL byte Paintbrush_shape_before_colorpicker;
GFX2_GLOBAL byte Pinceau_Forme_avant_lasso; GFX2_GLOBAL byte Paintbrush_shape_before_lasso;
GFX2_GLOBAL byte Cacher_pinceau; GFX2_GLOBAL byte Paintbrush_hidden;
GFX2_GLOBAL short Pinceau_X; GFX2_GLOBAL short Paintbrush_X;
GFX2_GLOBAL short Pinceau_Y; GFX2_GLOBAL short Paintbrush_Y;
GFX2_GLOBAL byte SPRITE_PINCEAU [NB_SPRITES_PINCEAU][HAUTEUR_PINCEAU][LARGEUR_PINCEAU]; GFX2_GLOBAL byte GFX_paintbrush_sprite [NB_PAINTBRUSH_SPRITES][PAINTBRUSH_HEIGHT][PAINTBRUSH_WIDTH];
GFX2_GLOBAL word Pinceau_predefini_Largeur[NB_SPRITES_PINCEAU]; GFX2_GLOBAL word Preset_paintbrush_width[NB_PAINTBRUSH_SPRITES];
GFX2_GLOBAL word Pinceau_predefini_Hauteur[NB_SPRITES_PINCEAU]; GFX2_GLOBAL word Preset_paintbrush_height[NB_PAINTBRUSH_SPRITES];
GFX2_GLOBAL byte Pinceau_Type[NB_SPRITES_PINCEAU]; GFX2_GLOBAL byte Paintbrush_type[NB_PAINTBRUSH_SPRITES];
GFX2_GLOBAL word Pinceau_predefini_Decalage_X[NB_SPRITES_PINCEAU]; GFX2_GLOBAL word Preset_paintbrush_offset_X[NB_PAINTBRUSH_SPRITES];
GFX2_GLOBAL word Pinceau_predefini_Decalage_Y[NB_SPRITES_PINCEAU]; GFX2_GLOBAL word Preset_paintbrush_offset_Y[NB_PAINTBRUSH_SPRITES];
GFX2_GLOBAL byte * Pinceau_Sprite; GFX2_GLOBAL byte * Paintbrush_sprite;
GFX2_GLOBAL short Pinceau_Largeur; GFX2_GLOBAL short Paintbrush_width;
GFX2_GLOBAL short Pinceau_Hauteur; GFX2_GLOBAL short Paintbrush_height;
GFX2_GLOBAL short Pinceau_Decalage_X; GFX2_GLOBAL short Paintbrush_offset_X;
GFX2_GLOBAL short Pinceau_Decalage_Y; GFX2_GLOBAL short Paintbrush_offset_Y;
// Commandes graphiques // Commandes graphiques
GFX2_GLOBAL int Pixel_ratio; GFX2_GLOBAL int Pixel_ratio;
GFX2_GLOBAL int Pixel_width; GFX2_GLOBAL int Pixel_width;
GFX2_GLOBAL int Pixel_height; GFX2_GLOBAL int Pixel_height;
GFX2_GLOBAL fonction_afficheur Pixel; // Affiche un point à l'écran GFX2_GLOBAL Func_pixel Pixel; // Affiche un point à l'écran
GFX2_GLOBAL fonction_afficheur Pixel_dans_menu;// Affiche un point dans le menu (ou pas si le menu est invisible) GFX2_GLOBAL Func_pixel Pixel_in_menu;// Affiche un point dans le menu (ou pas si le menu est invisible)
GFX2_GLOBAL fonction_lecteur Lit_pixel; // Teste la couleur d'un pixel dans l'écran GFX2_GLOBAL Func_read Read_pixel; // Teste la couleur d'un pixel dans l'écran
GFX2_GLOBAL fonction_display Display_screen; // Affiche rapidement tout l'écran (en faisant attention de ne pas effacer le menu) GFX2_GLOBAL Func_display Display_screen; // Affiche rapidement tout l'écran (en faisant attention de ne pas effacer le menu)
GFX2_GLOBAL fonction_block Block; // Affiche rapidement un bloc à l'écran GFX2_GLOBAL Func_block Block; // Affiche rapidement un bloc à l'écran
GFX2_GLOBAL fonction_afficheur Pixel_Preview_Normal; // Affiche un point de l'image à l'écran en mode normal (pas en mode loupe) GFX2_GLOBAL Func_pixel Pixel_preview_normal; // Affiche un point de l'image à l'écran en mode normal (pas en mode loupe)
GFX2_GLOBAL fonction_afficheur Pixel_Preview_Loupe; // Affiche un point de l'image à l'écran en mode loupe GFX2_GLOBAL Func_pixel Pixel_preview_magnifier; // Affiche un point de l'image à l'écran en mode loupe
GFX2_GLOBAL fonction_afficheur Pixel_Preview; // Affiche un point de l'image à l'écran en fonction de l'état du mode loupe GFX2_GLOBAL Func_pixel Pixel_preview; // Affiche un point de l'image à l'écran en fonction de l'état du mode loupe
GFX2_GLOBAL fonction_Ligne_XOR Ligne_horizontale_XOR;// Affiche une ligne horizontale en XOR (pour placer la loupe) GFX2_GLOBAL Func_line_XOR Horizontal_XOR_line;// Affiche une ligne horizontale en XOR (pour placer la loupe)
GFX2_GLOBAL fonction_Ligne_XOR Ligne_verticale_XOR; // Affiche une ligne verticale en XOR (pour placer la loupe) GFX2_GLOBAL Func_line_XOR Vertical_XOR_line; // Affiche une ligne verticale en XOR (pour placer la loupe)
GFX2_GLOBAL fonction_display_brush_Color Display_brush_Color; // Affiche une partie de la brosse en couleur GFX2_GLOBAL Func_display_brush_color Display_brush_color; // Affiche une partie de la brosse en couleur
GFX2_GLOBAL fonction_display_brush_Mono Display_brush_Mono; // Affiche une partie de la brosse en monochrome GFX2_GLOBAL Func_display_brush_mono Display_brush_mono; // Affiche une partie de la brosse en monochrome
GFX2_GLOBAL fonction_display_brush_Color Clear_brush; // Efface la partie de la brosse affichée à l'écran GFX2_GLOBAL Func_display_brush_color Clear_brush; // Efface la partie de la brosse affichée à l'écran
GFX2_GLOBAL fonction_remap Remap_screen; // Remappe une partie de l'écran avec les nouvelles couleurs du menu GFX2_GLOBAL Func_remap Remap_screen; // Remappe une partie de l'écran avec les nouvelles couleurs du menu
GFX2_GLOBAL fonction_procsline Afficher_ligne; // Afficher une ligne GFX2_GLOBAL Func_procsline Display_line; // Afficher une ligne
GFX2_GLOBAL fonction_procsline Afficher_ligne_fast; // Afficher une ligne talle quelle (sans la doubler en mode wide) GFX2_GLOBAL Func_procsline Display_line_fast; // Afficher une ligne talle quelle (sans la doubler en mode wide)
GFX2_GLOBAL fonction_procsline Lire_ligne; // Afficher ou lire une ligne GFX2_GLOBAL Func_procsline Read_line; // Afficher ou lire une ligne
GFX2_GLOBAL fonction_display_zoom Display_zoomed_screen; // Affiche rapidement toute la partie zoomée à l'écran (en faisant attention de ne pas effacer le menu) GFX2_GLOBAL Func_display_zoom Display_zoomed_screen; // Affiche rapidement toute la partie zoomée à l'écran (en faisant attention de ne pas effacer le menu)
GFX2_GLOBAL fonction_display_brush_Color_zoom Display_brush_Color_zoom; GFX2_GLOBAL Func_display_brush_color_zoom Display_brush_color_zoom;
GFX2_GLOBAL fonction_display_brush_Mono_zoom Display_brush_Mono_zoom; GFX2_GLOBAL Func_display_brush_mono_zoom Display_brush_mono_zoom;
GFX2_GLOBAL fonction_display_brush_Color_zoom Clear_brush_zoom; GFX2_GLOBAL Func_display_brush_color_zoom Clear_brush_scaled;
GFX2_GLOBAL fonction_affiche_brosse Affiche_brosse; GFX2_GLOBAL Func_draw_brush Display_brush;
// Données sur les dimensions de l'écran // Données sur les dimensions de l'écran
GFX2_GLOBAL int Resize_Largeur; // \__ Positionnées lorsque l'utilisateur tire GFX2_GLOBAL int Resize_width; // \__ Positionnées lorsque l'utilisateur tire
GFX2_GLOBAL int Resize_Hauteur; // / un bord de la fenêtre. GFX2_GLOBAL int Resize_height; // / un bord de la fenêtre.
GFX2_GLOBAL int Resolution_actuelle; // Résolution graphique courante GFX2_GLOBAL int Current_resolution; // Résolution graphique courante
GFX2_GLOBAL short Ecran_original_X; // |_ Dimensions de l'écran d'origine de GFX2_GLOBAL short Original_screen_X; // |_ Dimensions de l'écran d'origine de
GFX2_GLOBAL short Ecran_original_Y; // | l'image qui vient d'être chargée. GFX2_GLOBAL short Original_screen_Y; // | l'image qui vient d'être chargée.
GFX2_GLOBAL short Largeur_ecran; // Largeur de l'écran GFX2_GLOBAL short Screen_width; // Largeur de l'écran
GFX2_GLOBAL short Hauteur_ecran; // Hauteur de l'écran GFX2_GLOBAL short Screen_height; // Hauteur de l'écran
GFX2_GLOBAL short Limite_Haut; // | GFX2_GLOBAL short Limit_top; // |
GFX2_GLOBAL short Limite_Bas; // |_ Limites dans lesquelles GFX2_GLOBAL short Limit_bottom; // |_ Limites dans lesquelles
GFX2_GLOBAL short Limite_Gauche; // | on peut écrire GFX2_GLOBAL short Limit_left; // | on peut écrire
GFX2_GLOBAL short Limite_Droite; // | GFX2_GLOBAL short Limit_right; // |
GFX2_GLOBAL short Limite_visible_Bas; // |_ Derniers points visibles GFX2_GLOBAL short Limit_visible_bottom; // |_ Derniers points visibles
GFX2_GLOBAL short Limite_visible_Droite; // | "à l'image" GFX2_GLOBAL short Limit_visible_right; // | "à l'image"
GFX2_GLOBAL short Limite_Haut_Zoom; // | GFX2_GLOBAL short Limit_top_zoom; // |
GFX2_GLOBAL short Limite_Bas_Zoom; // |_ Limites dans lesquelles on peut GFX2_GLOBAL short Limit_bottom_zoom; // |_ Limites dans lesquelles on peut
GFX2_GLOBAL short Limite_Gauche_Zoom; // | écrire dans la partie zoomée GFX2_GLOBAL short Limit_left_zoom; // | écrire dans la partie zoomée
GFX2_GLOBAL short Limite_Droite_Zoom; // | GFX2_GLOBAL short Limit_right_zoom; // |
GFX2_GLOBAL short Limite_visible_Bas_Zoom; // |_ Derniers points visibles "à GFX2_GLOBAL short Limit_visible_bottom_zoom; // |_ Derniers points visibles "à
GFX2_GLOBAL short Limite_visible_Droite_Zoom; // | l'image" dans la partie zoomée GFX2_GLOBAL short Limit_visible_right_zoom; // | l'image" dans la partie zoomée
GFX2_GLOBAL byte * Buffer_de_ligne_horizontale; // Buffer d'affichage de lignes GFX2_GLOBAL byte * Horizontal_line_buffer; // buffer d'affichage de lignes
// Données sur l'image actuelle: // Données sur l'image actuelle:
GFX2_GLOBAL byte * Principal_Ecran; // Ecran virtuel courant GFX2_GLOBAL byte * Main_screen; // Screen virtuel courant
GFX2_GLOBAL T_Palette Principal_Palette; // Palette de l'écran en cours GFX2_GLOBAL T_Palette Main_palette; // Palette de l'écran en cours
GFX2_GLOBAL byte Principal_Image_modifiee; // L'image courante a été modifiée GFX2_GLOBAL byte Main_image_is_modified; // L'image courante a été modifiée
GFX2_GLOBAL short Principal_Largeur_image; // Largeur de l'image dans laquelle l'utilisateur désire travailler GFX2_GLOBAL short Main_image_width; // Largeur de l'image dans laquelle l'utilisateur désire travailler
GFX2_GLOBAL short Principal_Hauteur_image; // Hauteur de l'image dans laquelle l'utilisateur désire travailler GFX2_GLOBAL short Main_image_height; // Hauteur de l'image dans laquelle l'utilisateur désire travailler
GFX2_GLOBAL short Principal_Decalage_X; // Décalage en X de l'écran par rapport au début de l'image GFX2_GLOBAL short Main_offset_X; // Décalage en X de l'écran par rapport au début de l'image
GFX2_GLOBAL short Principal_Decalage_Y; // Décalage en Y de l'écran par rapport au début de l'image GFX2_GLOBAL short Main_offset_Y; // Décalage en Y de l'écran par rapport au début de l'image
GFX2_GLOBAL short Ancien_Principal_Decalage_X; GFX2_GLOBAL short Old_main_offset_X;
GFX2_GLOBAL short Ancien_Principal_Decalage_Y; GFX2_GLOBAL short Old_main_offset_Y;
GFX2_GLOBAL char Principal_Repertoire_fichier[1024]; // |_ Nom complet = GFX2_GLOBAL char Main_file_directory[1024]; // |_ Nom complet =
GFX2_GLOBAL char Principal_Nom_fichier[256]; // | Repertoire_fichier+"\"+Filename GFX2_GLOBAL char Main_filename[256]; // | File_directory+"\"+Filename
GFX2_GLOBAL byte Principal_Format_fichier; // Format auquel il faut lire et écrire le fichier GFX2_GLOBAL byte Main_fileformat; // Format auquel il faut lire et écrire le fichier
GFX2_GLOBAL byte Principal_Format; // Format du fileselect GFX2_GLOBAL byte Main_format; // Format du fileselect
GFX2_GLOBAL short Principal_File_list_Position; // Début de la partie affichée dans la liste de fichiers GFX2_GLOBAL short Main_fileselector_position; // Début de la partie affichée dans la liste de fichiers
GFX2_GLOBAL short Principal_File_list_Decalage; // Décalage de la barre de sélection dans le fileselector GFX2_GLOBAL short Main_fileselector_offset; // Décalage de la barre de sélection dans le fileselector
GFX2_GLOBAL char Principal_Repertoire_courant[1024]; // Répertoire actuel sur disque GFX2_GLOBAL char Main_current_directory[1024]; // Répertoire actuel sur disque
GFX2_GLOBAL char Principal_Commentaire[TAILLE_COMMENTAIRE+1]; // Commentaire de l'image GFX2_GLOBAL char Main_comment[COMMENT_SIZE+1]; // Commentaire de l'image
GFX2_GLOBAL short Principal_Split; // Position en X du bord gauche du split de la loupe GFX2_GLOBAL short Main_separator_position; // Position en X du bord gauche du split de la loupe
GFX2_GLOBAL short Principal_X_Zoom; // (Menu_Facteur_X) + Position en X du bord droit du split de la loupe GFX2_GLOBAL short Main_X_zoom; // (Menu_factor_X) + Position en X du bord droit du split de la loupe
GFX2_GLOBAL float Principal_Proportion_split; // Proportion de la zone non-zoomée par rapport à l'écran GFX2_GLOBAL float Main_separator_proportion; // Proportion de la zone non-zoomée par rapport à l'écran
// Données sur le brouillon: // Données sur le brouillon:
GFX2_GLOBAL byte * Brouillon_Ecran; // Ecran virtuel brouillon GFX2_GLOBAL byte * Spare_screen; // Screen virtuel brouillon
GFX2_GLOBAL T_Palette Brouillon_Palette; // Palette de l'écran de brouillon GFX2_GLOBAL T_Palette Spare_palette; // Palette de l'écran de brouillon
GFX2_GLOBAL byte Brouillon_Image_modifiee; // Le brouillon a été modifié GFX2_GLOBAL byte Spare_image_is_modified; // Le brouillon a été modifié
GFX2_GLOBAL short Brouillon_Largeur_image; // Largeur du brouillon dans laquelle l'utilisateur désire travailler GFX2_GLOBAL short Spare_image_width; // Largeur du brouillon dans laquelle l'utilisateur désire travailler
GFX2_GLOBAL short Brouillon_Hauteur_image; // Hauteur du brouillon dans laquelle l'utilisateur désire travailler GFX2_GLOBAL short Spare_image_height; // Hauteur du brouillon dans laquelle l'utilisateur désire travailler
GFX2_GLOBAL short Brouillon_Decalage_X; // Décalage en X du brouillon par rapport au début de l'image GFX2_GLOBAL short Spare_offset_X; // Décalage en X du brouillon par rapport au début de l'image
GFX2_GLOBAL short Brouillon_Decalage_Y; // Décalage en Y du brouillon par rapport au début de l'image GFX2_GLOBAL short Spare_offset_Y; // Décalage en Y du brouillon par rapport au début de l'image
GFX2_GLOBAL short Ancien_Brouillon_Decalage_X; GFX2_GLOBAL short Old_spare_offset_X;
GFX2_GLOBAL short Ancien_Brouillon_Decalage_Y; GFX2_GLOBAL short Old_spare_offset_Y;
GFX2_GLOBAL char Brouillon_Repertoire_fichier[TAILLE_CHEMIN_FICHIER]; // |_ Nom complet = GFX2_GLOBAL char Spare_file_directory[MAX_PATH_CHARACTERS]; // |_ Nom complet =
GFX2_GLOBAL char Brouillon_Nom_fichier[TAILLE_CHEMIN_FICHIER]; // | Repertoire_fichier+"\"+Filename GFX2_GLOBAL char Spare_filename[MAX_PATH_CHARACTERS]; // | File_directory+"\"+Filename
GFX2_GLOBAL byte Brouillon_Format_fichier; // Format auquel il faut lire et écrire le fichier GFX2_GLOBAL byte Spare_fileformat; // Format auquel il faut lire et écrire le fichier
GFX2_GLOBAL byte Brouillon_Format; // Format du fileselect GFX2_GLOBAL byte Spare_format; // Format du fileselect
GFX2_GLOBAL short Brouillon_File_list_Position; // Début de la partie affichée dans la liste de fichiers GFX2_GLOBAL short Spare_fileselector_position; // Début de la partie affichée dans la liste de fichiers
GFX2_GLOBAL short Brouillon_File_list_Decalage; // Décalage de la barre de sélection dans le fileselector GFX2_GLOBAL short Spare_fileselector_offset; // Décalage de la barre de sélection dans le fileselector
GFX2_GLOBAL char Brouillon_Repertoire_courant[TAILLE_CHEMIN_FICHIER]; // Répertoire actuel sur disque GFX2_GLOBAL char Spare_current_directory[MAX_PATH_CHARACTERS]; // Répertoire actuel sur disque
GFX2_GLOBAL char Brouillon_Commentaire[TAILLE_COMMENTAIRE+1]; // Commentaire de l'image GFX2_GLOBAL char Spare_comment[COMMENT_SIZE+1]; // Commentaire de l'image
GFX2_GLOBAL short Brouillon_Split; // Position en X du bord gauche du split de la loupe GFX2_GLOBAL short Spare_separator_position; // Position en X du bord gauche du split de la loupe
GFX2_GLOBAL short Brouillon_X_Zoom; // (Menu_Facteur_X) + Position en X du bord droit du split de la loupe GFX2_GLOBAL short Spare_X_zoom; // (Menu_factor_X) + Position en X du bord droit du split de la loupe
GFX2_GLOBAL float Brouillon_Proportion_split; // Proportion de la zone non-zoomée par rapport à l'écran GFX2_GLOBAL float Spare_separator_proportion; // Proportion de la zone non-zoomée par rapport à l'écran
GFX2_GLOBAL byte Brouillon_Loupe_Mode; // On est en mode loupe dans le brouillon GFX2_GLOBAL byte Spare_magnifier_mode; // On est en mode loupe dans le brouillon
GFX2_GLOBAL word Brouillon_Loupe_Facteur; // Facteur de zoom dans le brouillon GFX2_GLOBAL word Spare_magnifier_factor; // Facteur de zoom dans le brouillon
GFX2_GLOBAL word Brouillon_Loupe_Hauteur; // Largeur de la fenêtre de zoom dans le brouillon GFX2_GLOBAL word Spare_magnifier_height; // Largeur de la fenêtre de zoom dans le brouillon
GFX2_GLOBAL word Brouillon_Loupe_Largeur; // Hauteur de la fenêtre de zoom dans le brouillon GFX2_GLOBAL word Spare_magnifier_width; // Hauteur de la fenêtre de zoom dans le brouillon
GFX2_GLOBAL short Brouillon_Loupe_Decalage_X;// Decalage horizontal de la fenêtre de zoom dans le brouillon GFX2_GLOBAL short Spare_magnifier_offset_X;// Offset horizontal de la fenêtre de zoom dans le brouillon
GFX2_GLOBAL short Brouillon_Loupe_Decalage_Y;// Decalage vertical de la fenêtre de zoom dans le brouillon GFX2_GLOBAL short Spare_magnifier_offset_Y;// Offset vertical de la fenêtre de zoom dans le brouillon
GFX2_GLOBAL byte Masque_copie_couleurs[256]; // Tableau des couleurs à copier vers le brouillon GFX2_GLOBAL byte Mask_color_to_copy[256]; // Tableau des couleurs à copier vers le brouillon
// Sauvegarde de l'image: // Sauvegarde de l'image:
GFX2_GLOBAL byte * Ecran_backup; // Sauvegarde de l'écran virtuel courant GFX2_GLOBAL byte * Screen_backup; // Sauvegarde de l'écran virtuel courant
GFX2_GLOBAL S_Liste_de_pages * Principal_Backups; // Liste des pages de backup de la page principale GFX2_GLOBAL T_List_of_pages * Main_backups; // Liste des pages de backup de la page principale
GFX2_GLOBAL S_Liste_de_pages * Brouillon_Backups; // Liste des pages de backup de la page de brouillon GFX2_GLOBAL T_List_of_pages * Spare_backups; // Liste des pages de backup de la page de brouillon
// Données sur la brosse: // Données sur la brosse:
GFX2_GLOBAL byte * Brosse; // Sprite de la brosse GFX2_GLOBAL byte * Brush; // Sprite de la brosse
GFX2_GLOBAL word Brosse_Decalage_X; // Centre horizontal de la brosse GFX2_GLOBAL word Brush_offset_X; // Centre horizontal de la brosse
GFX2_GLOBAL word Brosse_Decalage_Y; // Centre vertical de la brosse GFX2_GLOBAL word Brush_offset_Y; // Centre vertical de la brosse
GFX2_GLOBAL word Brosse_Largeur; // Largeur de la brosse GFX2_GLOBAL word Brush_width; // Largeur de la brosse
GFX2_GLOBAL word Brosse_Hauteur; // Hauteur de la brosse GFX2_GLOBAL word Brush_height; // Hauteur de la brosse
GFX2_GLOBAL char Brosse_Repertoire_fichier[TAILLE_CHEMIN_FICHIER];// | GFX2_GLOBAL char Brush_file_directory[MAX_PATH_CHARACTERS];// |
GFX2_GLOBAL char Brosse_Nom_fichier[TAILLE_CHEMIN_FICHIER]; // | GFX2_GLOBAL char Brush_filename[MAX_PATH_CHARACTERS]; // |
GFX2_GLOBAL byte Brosse_Format_fichier; // | Infos sur le GFX2_GLOBAL byte Brush_fileformat; // | Infos sur le
GFX2_GLOBAL byte Brosse_Format; // |_ sélecteur de GFX2_GLOBAL byte Brush_format; // |_ sélecteur de
GFX2_GLOBAL short Brosse_File_list_Position; // | fichiers de la GFX2_GLOBAL short Brush_fileselector_position; // | fichiers de la
GFX2_GLOBAL short Brosse_File_list_Decalage; // | brosse. GFX2_GLOBAL short Brush_fileselector_offset; // | brosse.
GFX2_GLOBAL char Brosse_Repertoire_courant[256]; // | GFX2_GLOBAL char Brush_current_directory[256]; // |
GFX2_GLOBAL char Brosse_Commentaire[TAILLE_COMMENTAIRE+1]; // | GFX2_GLOBAL char Brush_comment[COMMENT_SIZE+1]; // |
GFX2_GLOBAL byte Brosse_Centre_rotation_defini; // | Infos sur le GFX2_GLOBAL byte Brush_rotation_center_is_defined; // | Infos sur le
GFX2_GLOBAL short Brosse_Centre_rotation_X; // |- centre de rotation GFX2_GLOBAL short Brush_rotation_center_X; // |- centre de rotation
GFX2_GLOBAL short Brosse_Centre_rotation_Y; // | de la brosse GFX2_GLOBAL short Brush_rotation_center_Y; // | de la brosse
// Données sur le menu // Données sur le menu
GFX2_GLOBAL byte Menu_visible; // Le menu est actif à l'écran GFX2_GLOBAL byte Menu_is_visible; // Le menu est actif à l'écran
GFX2_GLOBAL word Menu_Ordonnee; // Ordonnée où commence le menu GFX2_GLOBAL word Menu_Y; // Ordonnée où commence le menu
GFX2_GLOBAL word Menu_Ordonnee_Texte; // Ordonnée où commence le texte dans le menu GFX2_GLOBAL word Menu_status_Y; // Ordonnée où commence le texte dans le menu
GFX2_GLOBAL byte Menu_Facteur_X; // Facteur de grossissement du menu en X GFX2_GLOBAL byte Menu_factor_X; // Facteur de grossissement du menu en X
GFX2_GLOBAL byte Menu_Facteur_Y; // Facteur de grossissement du menu en Y GFX2_GLOBAL byte Menu_factor_Y; // Facteur de grossissement du menu en Y
GFX2_GLOBAL word Menu_Taille_couleur; // Taille d'une couleur de la palette du menu GFX2_GLOBAL word Menu_palette_cell_width; // Taille d'une couleur de la palette du menu
// Données sur la fenêtre de menu // Données sur la fenêtre de menu
GFX2_GLOBAL byte Fenetre; // Nombre de fenetres empilées. 0 si pas de fenetre ouverte. GFX2_GLOBAL byte Window; // Nombre de fenetres empilées. 0 si pas de fenetre ouverte.
GFX2_GLOBAL byte Menu_visible_avant_fenetre; // Le menu était visible avant d'ouvir une fenêtre GFX2_GLOBAL byte Menu_is_visible_before_window; // Le menu était visible avant d'ouvir une fenêtre
GFX2_GLOBAL word Menu_Ordonnee_avant_fenetre; // Ordonnée du menu avant d'ouvrir une fenêtre GFX2_GLOBAL word Menu_Y_before_window; // Ordonnée du menu avant d'ouvrir une fenêtre
GFX2_GLOBAL byte Cacher_pinceau_avant_fenetre;// Le pinceau étatit déjà caché avant l'ouverture de la fenetre? GFX2_GLOBAL byte Paintbrush_hidden_before_window;// Le pinceau étatit déjà caché avant l'ouverture de la fenetre?
GFX2_GLOBAL word Pile_Fenetre_Pos_X[8]; // Position du bord gauche de la fenêtre dans l'écran GFX2_GLOBAL word Window_stack_pos_X[8]; // Position du bord gauche de la fenêtre dans l'écran
#define Fenetre_Pos_X Pile_Fenetre_Pos_X[Fenetre-1] #define Window_pos_X Window_stack_pos_X[Window-1]
GFX2_GLOBAL word Pile_Fenetre_Pos_Y[8]; // Position du bord haut de la fenêtre dans l'écran GFX2_GLOBAL word Window_stack_pos_Y[8]; // Position du bord haut de la fenêtre dans l'écran
#define Fenetre_Pos_Y Pile_Fenetre_Pos_Y[Fenetre-1] #define Window_pos_Y Window_stack_pos_Y[Window-1]
GFX2_GLOBAL word Pile_Fenetre_Largeur[8]; // Largeur de la fenêtre GFX2_GLOBAL word Window_stack_width[8]; // Largeur de la fenêtre
#define Fenetre_Largeur Pile_Fenetre_Largeur[Fenetre-1] #define Window_width Window_stack_width[Window-1]
GFX2_GLOBAL word Pile_Fenetre_Hauteur[8]; // Hauteur de la fenêtre GFX2_GLOBAL word Window_stack_height[8]; // Hauteur de la fenêtre
#define Fenetre_Hauteur Pile_Fenetre_Hauteur[Fenetre-1] #define Window_height Window_stack_height[Window-1]
GFX2_GLOBAL word Pile_Nb_boutons_fenetre[8]; GFX2_GLOBAL word Window_stack_nb_buttons[8];
#define Nb_boutons_fenetre Pile_Nb_boutons_fenetre[Fenetre-1] #define Window_nb_buttons Window_stack_nb_buttons[Window-1]
GFX2_GLOBAL T_Bouton_normal * Pile_Fenetre_Liste_boutons_normal[8]; GFX2_GLOBAL T_Normal_button * Window_stack_normal_button_list[8];
#define Fenetre_Liste_boutons_normal Pile_Fenetre_Liste_boutons_normal[Fenetre-1] #define Window_normal_button_list Window_stack_normal_button_list[Window-1]
GFX2_GLOBAL T_Bouton_palette * Pile_Fenetre_Liste_boutons_palette[8]; GFX2_GLOBAL T_Palette_button * Window_stack_palette_button_list[8];
#define Fenetre_Liste_boutons_palette Pile_Fenetre_Liste_boutons_palette[Fenetre-1] #define Window_palette_button_list Window_stack_palette_button_list[Window-1]
GFX2_GLOBAL T_Bouton_scroller * Pile_Fenetre_Liste_boutons_scroller[8]; GFX2_GLOBAL T_Scroller_button * Window_stack_scroller_button_list[8];
#define Fenetre_Liste_boutons_scroller Pile_Fenetre_Liste_boutons_scroller[Fenetre-1] #define Window_scroller_button_list Window_stack_scroller_button_list[Window-1]
GFX2_GLOBAL T_Bouton_special * Pile_Fenetre_Liste_boutons_special[8]; GFX2_GLOBAL T_Special_button * Window_stack_special_button_list[8];
#define Fenetre_Liste_boutons_special Pile_Fenetre_Liste_boutons_special[Fenetre-1] #define Window_special_button_list Window_stack_special_button_list[Window-1]
GFX2_GLOBAL T_Bouton_dropdown * Pile_Fenetre_Liste_boutons_dropdown[8]; GFX2_GLOBAL T_Dropdown_button * Window_stack_dropdown_button_list[8];
#define Fenetre_Liste_boutons_dropdown Pile_Fenetre_Liste_boutons_dropdown[Fenetre-1] #define Window_dropdown_button_list Window_stack_dropdown_button_list[Window-1]
GFX2_GLOBAL int Pile_Fenetre_Attribut1[8]; GFX2_GLOBAL int Window_stack_attribute1[8];
#define Fenetre_Attribut1 Pile_Fenetre_Attribut1[Fenetre-1] #define Window_attribute1 Window_stack_attribute1[Window-1]
// Cette variable sert à stocker 2 informations: // Cette variable sert à stocker 2 informations:
// - Sur le click d'un scroller, la position active (0-n) // - Sur le click d'un scroller, la position active (0-n)
// - Sur le click d'une palette, le numero de couleur (0-255). // - Sur le click d'une palette, le numero de couleur (0-255).
GFX2_GLOBAL int Pile_Fenetre_Attribut2[8]; GFX2_GLOBAL int Window_stack_attribute2[8];
#define Fenetre_Attribut2 Pile_Fenetre_Attribut2[Fenetre-1] #define Window_attribute2 Window_stack_attribute2[Window-1]
@ -346,303 +346,303 @@ GFX2_GLOBAL int Pile_Fenetre_Attribut2[8];
GFX2_GLOBAL struct GFX2_GLOBAL struct
{ {
// Informations sur l'aspect du bouton (graphisme): // Informations sur l'aspect du bouton (graphisme):
word Decalage_X; // Décalage par rapport à la gauche du menu word X_offset; // Décalage par rapport à la gauche du menu
word Decalage_Y; // Décalage par rapport au haut du menu word Y_offset; // Décalage par rapport au haut du menu
word Width; // Largeur du bouton word Width; // Largeur du bouton
word Height; // Hauteur du bouton word Height; // Hauteur du bouton
byte Enfonce; // Le bouton est enfoncé byte Pressed; // Le bouton est enfoncé
byte Shape; // Forme du bouton byte Shape; // Forme du bouton
// Information sur les clicks de la souris: // Information sur les clicks de la souris:
fonction_action Gauche; // Action déclenchée par un click gauche sur le bouton Func_action Gauche; // Action déclenchée par un click gauche sur le bouton
fonction_action Droite; // Action déclenchée par un click droit sur le bouton Func_action Droite; // Action déclenchée par un click droit sur le bouton
word Raccourci_gauche[2]; // Raccourci clavier équivalent à un click gauche sur le bouton word Left_shortcut[2]; // Shortcut clavier équivalent à un click gauche sur le bouton
word Raccourci_droite[2]; // Raccourci clavier équivalent à un click droit sur le bouton word Right_shortcut[2]; // Shortcut clavier équivalent à un click droit sur le bouton
// Informations sur le désenclenchement du bouton géré par le moteur: // Informations sur le désenclenchement du bouton géré par le moteur:
fonction_action Desenclencher; // Action appelée lors du désenclenchement du bouton Func_action Desenclencher; // Action appelée lors du désenclenchement du bouton
byte Famille; // Ensemble de boutons auquel celui-ci appartient byte Famille; // Ensemble de boutons auquel celui-ci appartient
} Bouton[NB_BOUTONS]; } Button[NB_BUTTONS];
// Informations sur les différents modes de dessin // Informations sur les différents modes de dessin
GFX2_GLOBAL fonction_effet Fonction_effet; GFX2_GLOBAL Func_effect Effect_function;
GFX2_GLOBAL byte * FX_Feedback_Ecran; GFX2_GLOBAL byte * FX_feedback_screen;
GFX2_GLOBAL byte Exclude_color[256]; // Couleurs à exclure pour Meilleure_couleur GFX2_GLOBAL byte Exclude_color[256]; // Couleurs à exclure pour Best_color
// Mode smear: // Mode smear:
GFX2_GLOBAL byte Smear_Mode; // Le mode smear est enclenché GFX2_GLOBAL byte Smear_mode; // Le mode smear est enclenché
GFX2_GLOBAL byte Smear_Debut; // On vient juste de commencer une opération en Smear GFX2_GLOBAL byte Smear_start; // On vient juste de commencer une opération en Smear
GFX2_GLOBAL byte * Smear_Brosse; // Sprite de la brosse de Smear GFX2_GLOBAL byte * Smear_brush; // Sprite de la brosse de Smear
GFX2_GLOBAL word Smear_Brosse_Largeur; // Largeur de la brosse de Smear GFX2_GLOBAL word Smear_brush_width; // Largeur de la brosse de Smear
GFX2_GLOBAL word Smear_Brosse_Hauteur; // Hauteur de la brosse de Smear GFX2_GLOBAL word Smear_brush_height; // Hauteur de la brosse de Smear
GFX2_GLOBAL short Smear_Min_X,Smear_Max_X,Smear_Min_Y,Smear_Max_Y; // Bornes de la Brosse du smear GFX2_GLOBAL short Smear_min_X,Smear_max_X,Smear_min_Y,Smear_max_Y; // Bornes de la Brush du smear
// Mode shade: // Mode shade:
GFX2_GLOBAL T_Shade Shade_Liste[8]; // Listes de shade GFX2_GLOBAL T_Shade Shade_list[8]; // Listes de shade
GFX2_GLOBAL byte Shade_Actuel; // Numéro du shade en cours GFX2_GLOBAL byte Shade_current; // Numéro du shade en cours
GFX2_GLOBAL byte * Shade_Table; // Table de conversion de shade en cours GFX2_GLOBAL byte * Shade_table; // Table de conversion de shade en cours
GFX2_GLOBAL byte Shade_Table_gauche[256]; // Table de conversion de shade pour un clic gauche GFX2_GLOBAL byte Shade_table_left[256]; // Table de conversion de shade pour un clic gauche
GFX2_GLOBAL byte Shade_Table_droite[256]; // Table de conversion de shade pour un clic droit GFX2_GLOBAL byte Shade_table_right[256]; // Table de conversion de shade pour un clic droit
GFX2_GLOBAL byte Shade_Mode; // Le mode shade est enclenché GFX2_GLOBAL byte Shade_mode; // Le mode shade est enclenché
GFX2_GLOBAL byte Quick_shade_Mode; // Le mode quick-shade est enclenché GFX2_GLOBAL byte Quick_shade_mode; // Le mode quick-shade est enclenché
GFX2_GLOBAL byte Quick_shade_Step; // Pas du mode quick-shade GFX2_GLOBAL byte Quick_shade_step; // Pas du mode quick-shade
GFX2_GLOBAL byte Quick_shade_Loop; // Normal / Loop / No sat. GFX2_GLOBAL byte Quick_shade_loop; // Normal / Loop / No sat.
// Mode stencil: // Mode stencil:
GFX2_GLOBAL byte Stencil_Mode; // Le mode stencil est enclenché GFX2_GLOBAL byte Stencil_mode; // Le mode stencil est enclenché
GFX2_GLOBAL byte Stencil[256]; // Tableau des couleurs protégées GFX2_GLOBAL byte Stencil[256]; // Tableau des couleurs protégées
// Mode grille: // Mode grille:
GFX2_GLOBAL byte Snap_Mode; // Le mode grille est enclenché GFX2_GLOBAL byte Snap_mode; // Le mode grille est enclenché
GFX2_GLOBAL word Snap_Largeur; // Largeur entre 2 points de la grille GFX2_GLOBAL word Snap_width; // Largeur entre 2 points de la grille
GFX2_GLOBAL word Snap_Hauteur; // Hauteur entre 2 points de la grille GFX2_GLOBAL word Snap_height; // Hauteur entre 2 points de la grille
GFX2_GLOBAL word Snap_Decalage_X; // Position en X du point le + à gauche GFX2_GLOBAL word Snap_offset_X; // Position en X du point le + à gauche
GFX2_GLOBAL word Snap_Decalage_Y; // Position en Y du point le + en haut GFX2_GLOBAL word Snap_offset_Y; // Position en Y du point le + en haut
// Mode trame: // Mode trame:
GFX2_GLOBAL byte Trame_Mode; // Le mode Trame est enclenché GFX2_GLOBAL byte Sieve_mode; // Le mode Sieve est enclenché
GFX2_GLOBAL byte Trame[16][16]; // Sprite de la trame GFX2_GLOBAL byte Sieve[16][16]; // Sprite de la trame
GFX2_GLOBAL word TRAME_PREDEFINIE[12][16]; // Trames préséfinies (compactées sur 16*16 bits) GFX2_GLOBAL word GFX_sieve_pattern[12][16]; // Trames préséfinies (compactées sur 16*16 bits)
GFX2_GLOBAL short Trame_Largeur; // Largeur de la trame GFX2_GLOBAL short Sieve_width; // Largeur de la trame
GFX2_GLOBAL short Trame_Hauteur; // Hauteur de la trame GFX2_GLOBAL short Sieve_height; // Hauteur de la trame
// Mode colorize: // Mode colorize:
GFX2_GLOBAL byte Colorize_Mode; // Le mode Colorize est enclenché GFX2_GLOBAL byte Colorize_mode; // Le mode Colorize est enclenché
GFX2_GLOBAL byte Colorize_Opacite; // Intensité du Colorize GFX2_GLOBAL byte Colorize_opacity; // Intensité du Colorize
GFX2_GLOBAL byte Colorize_Mode_en_cours; // Le type de Colorize en cours (0-2) GFX2_GLOBAL byte Colorize_current_mode; // Le type de Colorize en cours (0-2)
GFX2_GLOBAL word Table_de_multiplication_par_Facteur_A[256]; GFX2_GLOBAL word Facteur_A_table[256];
GFX2_GLOBAL word Table_de_multiplication_par_Facteur_B[256]; GFX2_GLOBAL word Facteur_B_table[256];
// Mode smooth: // Mode smooth:
GFX2_GLOBAL byte Smooth_Mode; // Le mode Smooth est enclenché GFX2_GLOBAL byte Smooth_mode; // Le mode Smooth est enclenché
GFX2_GLOBAL byte Smooth_Matrice[3][3]; // La matrice du Smooth actuel GFX2_GLOBAL byte Smooth_matrix[3][3]; // La matrice du Smooth actuel
// Mode Tiling: // Mode Tiling:
GFX2_GLOBAL byte Tiling_Mode; // Le mode Tiling est enclenché GFX2_GLOBAL byte Tiling_mode; // Le mode Tiling est enclenché
GFX2_GLOBAL short Tiling_Decalage_X; // Décalage du tiling en X GFX2_GLOBAL short Tiling_offset_X; // Décalage du tiling en X
GFX2_GLOBAL short Tiling_Decalage_Y; // Décalage du tiling en Y GFX2_GLOBAL short Tiling_offset_Y; // Décalage du tiling en Y
// Mode Mask // Mode Mask
GFX2_GLOBAL byte Mask_Mode; // Le mode Masque est enclenché GFX2_GLOBAL byte Mask_mode; // Le mode Masque est enclenché
GFX2_GLOBAL byte Mask_table[256]; // Tableau des couleurs constituant le masque GFX2_GLOBAL byte Mask_table[256]; // Tableau des couleurs constituant le masque
// Mode loupe: // Mode loupe:
GFX2_GLOBAL byte Loupe_Mode; GFX2_GLOBAL byte Main_magnifier_mode;
GFX2_GLOBAL word Loupe_Facteur; GFX2_GLOBAL word Main_magnifier_factor;
GFX2_GLOBAL word Loupe_Hauteur; GFX2_GLOBAL word Main_magnifier_height;
GFX2_GLOBAL word Loupe_Largeur; GFX2_GLOBAL word Main_magnifier_width;
GFX2_GLOBAL short Loupe_Decalage_X; GFX2_GLOBAL short Main_magnifier_offset_X;
GFX2_GLOBAL short Loupe_Decalage_Y; GFX2_GLOBAL short Main_magnifier_offset_Y;
GFX2_GLOBAL word * Table_mul_facteur_zoom; GFX2_GLOBAL word * Zoom_factor_table;
GFX2_GLOBAL word TABLE_ZOOM[NB_FACTEURS_DE_ZOOM][512]; GFX2_GLOBAL word Magnify_table[NB_ZOOM_FACTORS][512];
#ifdef VARIABLES_GLOBALES #ifdef GLOBAL_VARIABLES
word FACTEUR_ZOOM[NB_FACTEURS_DE_ZOOM]={2,3,4,5,6,8,10,12,14,16,18,20}; word ZOOM_FACTOR[NB_ZOOM_FACTORS]={2,3,4,5,6,8,10,12,14,16,18,20};
#else #else
extern word FACTEUR_ZOOM[NB_FACTEURS_DE_ZOOM]; extern word ZOOM_FACTOR[NB_ZOOM_FACTORS];
#endif #endif
// Données sur les ellipses et les cercles: // Données sur les ellipses et les cercles:
GFX2_GLOBAL long Ellipse_Curseur_X; GFX2_GLOBAL long Ellipse_cursor_X;
GFX2_GLOBAL long Ellipse_Curseur_Y; GFX2_GLOBAL long Ellipse_cursor_Y;
GFX2_GLOBAL long Ellipse_Rayon_vertical_au_carre; GFX2_GLOBAL long Ellipse_vertical_radius_squared;
GFX2_GLOBAL long Ellipse_Rayon_horizontal_au_carre; GFX2_GLOBAL long Ellipse_horizontal_radius_squared;
GFX2_GLOBAL qword Ellipse_Limite; GFX2_GLOBAL qword Ellipse_limit;
GFX2_GLOBAL long Cercle_Curseur_X; GFX2_GLOBAL long Circle_cursor_X;
GFX2_GLOBAL long Cercle_Curseur_Y; GFX2_GLOBAL long Circle_cursor_Y;
GFX2_GLOBAL long Cercle_Limite; GFX2_GLOBAL long Circle_limit;
// Données sur les dégradés: // Données sur les dégradés:
GFX2_GLOBAL short Degrade_Borne_Inferieure; // Plus petite couleur englobée par le dégradé GFX2_GLOBAL short Gradient_lower_bound; // Plus petite couleur englobée par le dégradé
GFX2_GLOBAL short Degrade_Borne_Superieure; // Plus grande couleur englobée par le dégradé GFX2_GLOBAL short Gradient_upper_bound; // Plus grande couleur englobée par le dégradé
GFX2_GLOBAL int Degrade_Inverse; // Booléen "Le dégradé est en réalité inversé" GFX2_GLOBAL int Gradient_is_inverted; // Booléen "Le dégradé est en réalité inversé"
GFX2_GLOBAL long Degrade_Intervalle_bornes; // = Abs(Degrade_Borne_Inferieure-Degrade_Borne_Superieure)+1 GFX2_GLOBAL long Gradient_bounds_range; // = Abs(Gradient_lower_bound-Gradient_upper_bound)+1
GFX2_GLOBAL long Degrade_Intervalle_total; // Valeur maximum des indices passés à la fonction de dégradé (!!! >0 !!!) GFX2_GLOBAL long Gradient_total_range; // Valeur maximum des indices passés à la fonction de dégradé (!!! >0 !!!)
GFX2_GLOBAL long Degrade_Melange_aleatoire; // Facteur de mélange (1-256+) du dégradé GFX2_GLOBAL long Gradient_random_factor; // Facteur de mélange (1-256+) du dégradé
GFX2_GLOBAL fonction_degrade Traiter_degrade; // Fonction de traitement du dégradé, varie selon la méthode choisie par l'utilisateur. GFX2_GLOBAL Func_gradient Gradient_function; // Fonction de traitement du dégradé, varie selon la méthode choisie par l'utilisateur.
GFX2_GLOBAL fonction_afficheur Traiter_pixel_de_degrade; // Redirection de l'affichage GFX2_GLOBAL Func_pixel Gradient_pixel; // Redirection de l'affichage
GFX2_GLOBAL T_Degrade_Tableau Degrade_Tableau[16]; // Données de tous les dégradés GFX2_GLOBAL T_Gradient_array Gradient_array[16]; // Données de tous les dégradés
GFX2_GLOBAL byte Degrade_Courant; // Indice du tableau correspondant au dégradé courant GFX2_GLOBAL byte Current_gradient; // index du tableau correspondant au dégradé courant
// Données sur le Spray: // Données sur le Spray:
GFX2_GLOBAL byte Spray_Mode; // Mode Mono(1) ou Multicolore(0) GFX2_GLOBAL byte Airbrush_mode; // Mode Mono(1) ou Multicolore(0)
GFX2_GLOBAL short Spray_Size; // Diamètre du spray en pixels GFX2_GLOBAL short Airbrush_size; // Diamètre du spray en pixels
GFX2_GLOBAL byte Spray_Delay; // Délai en VBLs entre 2 "pschiitt" GFX2_GLOBAL byte Airbrush_delay; // Délai en VBLs entre 2 "pschiitt"
GFX2_GLOBAL byte Spray_Mono_flow; // Nombre de pixels qui sortent en même temps en mono GFX2_GLOBAL byte Airbrush_mono_flow; // Nombre de pixels qui sortent en même temps en mono
GFX2_GLOBAL byte Spray_Multi_flow[256]; // Idem pour chaque couleur GFX2_GLOBAL byte Airbrush_multi_flow[256]; // Idem pour chaque couleur
// Données diverses sur le programme: // Données diverses sur le programme:
GFX2_GLOBAL byte Sortir_du_programme; GFX2_GLOBAL byte Quitting;
GFX2_GLOBAL char Repertoire_initial[256]; // Répertoire à partir duquel à été lancé le programme GFX2_GLOBAL char Initial_directory[256]; // Répertoire à partir duquel à été lancé le programme
GFX2_GLOBAL char Repertoire_des_donnees[256]; // Répertoire contenant les fichiers lus (interface graphique, etc) GFX2_GLOBAL char Repertoire_des_donnees[256]; // Répertoire contenant les fichiers lus (interface graphique, etc)
GFX2_GLOBAL char Repertoire_de_configuration[256]; // Répertoire contenant les fichiers .ini et .cfg GFX2_GLOBAL char Config_directory[256]; // Répertoire contenant les fichiers .ini et .cfg
GFX2_GLOBAL byte Fore_color; GFX2_GLOBAL byte Fore_color;
GFX2_GLOBAL byte Back_color; GFX2_GLOBAL byte Back_color;
GFX2_GLOBAL byte Mode_de_dessin_en_cours; GFX2_GLOBAL byte Selected_operation;
GFX2_GLOBAL byte Courbe_en_cours; GFX2_GLOBAL byte Selected_curve_mode;
GFX2_GLOBAL byte Ligne_en_cours; GFX2_GLOBAL byte Selected_line_mode;
GFX2_GLOBAL byte Couleur_debut_palette; GFX2_GLOBAL byte First_color_in_palette;
GFX2_GLOBAL byte Un_fichier_a_ete_passe_en_parametre; GFX2_GLOBAL byte File_in_command_line;
GFX2_GLOBAL byte Une_resolution_a_ete_passee_en_parametre; // utilisée uniquement si la variable précédente est à 1 GFX2_GLOBAL byte Resolution_in_command_line; // utilisée uniquement si la variable précédente est à 1
// Les différents sprites: // Les différents sprites:
GFX2_GLOBAL byte BLOCK_MENU[HAUTEUR_MENU][LARGEUR_MENU]; GFX2_GLOBAL byte GFX_menu_block[MENU_HEIGHT][MENU_WIDTH];
GFX2_GLOBAL byte SPRITE_MENU[NB_SPRITES_MENU][HAUTEUR_SPRITE_MENU][LARGEUR_SPRITE_MENU]; GFX2_GLOBAL byte GFX_menu_sprite[NB_MENU_SPRITES][MENU_SPRITE_HEIGHT][MENU_SPRITE_WIDTH];
GFX2_GLOBAL byte SPRITE_EFFET[NB_SPRITES_EFFETS][HAUTEUR_SPRITE_MENU][LARGEUR_SPRITE_MENU]; GFX2_GLOBAL byte GFX_effect_sprite[NB_EFFECTS_SPRITES][MENU_SPRITE_HEIGHT][MENU_SPRITE_WIDTH];
GFX2_GLOBAL byte * Logo_GrafX2; GFX2_GLOBAL byte * GFX_logo_grafx2;
GFX2_GLOBAL byte Fonte_systeme[256*8*8]; GFX2_GLOBAL byte GFX_system_font[256*8*8];
GFX2_GLOBAL byte Fonte_fun [256*8*8]; GFX2_GLOBAL byte GFX_fun_font [256*8*8];
GFX2_GLOBAL byte Fonte_help_norm [256][6][8]; GFX2_GLOBAL byte GFX_help_font_norm [256][6][8];
GFX2_GLOBAL byte Fonte_help_bold [256][6][8]; GFX2_GLOBAL byte GFX_bold_font [256][6][8];
// 12 // 12
// 34 // 34
GFX2_GLOBAL byte Fonte_help_t1 [64][6][8]; GFX2_GLOBAL byte GFX_help_font_t1 [64][6][8];
GFX2_GLOBAL byte Fonte_help_t2 [64][6][8]; GFX2_GLOBAL byte GFX_help_font_t2 [64][6][8];
GFX2_GLOBAL byte Fonte_help_t3 [64][6][8]; GFX2_GLOBAL byte GFX_help_font_t3 [64][6][8];
GFX2_GLOBAL byte Fonte_help_t4 [64][6][8]; GFX2_GLOBAL byte GFX_help_font_t4 [64][6][8];
GFX2_GLOBAL byte * Fonte; GFX2_GLOBAL byte * Font;
// Les données de l'aide: // Les données de l'aide:
GFX2_GLOBAL byte Section_d_aide_en_cours; // Indice de la table d'aide en cours de consultation GFX2_GLOBAL byte Current_help_section; // index de la table d'aide en cours de consultation
GFX2_GLOBAL word Position_d_aide_en_cours; // Numéro de la ligne d'aide en cours de consultation GFX2_GLOBAL word Help_position; // Numéro de la ligne d'aide en cours de consultation
// Données sur les opérations // Données sur les opérations
GFX2_GLOBAL word Operation_avant_interruption; // N° de l'opération en cours avant l'utilisation d'une interruption GFX2_GLOBAL word Operation_before_interrupt; // N° de l'opération en cours avant l'utilisation d'une interruption
GFX2_GLOBAL word Operation_en_cours; // N° de l'opération en cours GFX2_GLOBAL word Current_operation; // N° de l'opération en cours
GFX2_GLOBAL word Operation_Pile[TAILLE_PILE_OPERATIONS]; // Pile simplifiée GFX2_GLOBAL word Operation_stack[OPERATION_STACK_SIZE]; // Pile simplifiée
GFX2_GLOBAL byte Operation_Taille_pile; // Taille effective de la pile (0=vide) GFX2_GLOBAL byte Operation_stack_size; // Taille effective de la pile (0=vide)
GFX2_GLOBAL byte Operation_dans_loupe; // Indique si l'opération a commencé dans la partie Zoomée ou non GFX2_GLOBAL byte Operation_in_magnifier; // Indique si l'opération a commencé dans la partie Zoomée ou non
GFX2_GLOBAL short Pipette_Couleur; GFX2_GLOBAL short Colorpicker_color;
GFX2_GLOBAL short Pipette_X; GFX2_GLOBAL short Colorpicker_X;
GFX2_GLOBAL short Pipette_Y; GFX2_GLOBAL short Colorpicker_Y;
#ifdef VARIABLES_GLOBALES #ifdef GLOBAL_VARIABLES
byte CURSEUR_D_OPERATION[NB_OPERATIONS]= byte CURSOR_FOR_OPERATION[NB_OPERATIONS]=
{ {
FORME_CURSEUR_CIBLE , // Dessin à la main continu CURSOR_SHAPE_TARGET , // Dessin à la main continu
FORME_CURSEUR_CIBLE , // Dessin à la main discontinu CURSOR_SHAPE_TARGET , // Dessin à la main discontinu
FORME_CURSEUR_CIBLE , // Dessin à la main point par point CURSOR_SHAPE_TARGET , // Dessin à la main point par point
FORME_CURSEUR_CIBLE , // Contour fill CURSOR_SHAPE_TARGET , // Contour fill
FORME_CURSEUR_CIBLE , // Lignes CURSOR_SHAPE_TARGET , // Lignes
FORME_CURSEUR_CIBLE , // Lignes reliées CURSOR_SHAPE_TARGET , // Lignes reliées
FORME_CURSEUR_CIBLE , // Lignes centrées CURSOR_SHAPE_TARGET , // Lignes centrées
FORME_CURSEUR_CIBLE_XOR , // Rectangle vide CURSOR_SHAPE_XOR_TARGET , // Rectangle vide
FORME_CURSEUR_CIBLE_XOR , // Rectangle plein CURSOR_SHAPE_XOR_TARGET , // Rectangle plein
FORME_CURSEUR_CIBLE , // Cercles vides CURSOR_SHAPE_TARGET , // Cercles vides
FORME_CURSEUR_CIBLE , // Cercles pleins CURSOR_SHAPE_TARGET , // Cercles pleins
FORME_CURSEUR_CIBLE , // Ellipses vides CURSOR_SHAPE_TARGET , // Ellipses vides
FORME_CURSEUR_CIBLE , // Ellipses pleines CURSOR_SHAPE_TARGET , // Ellipses pleines
FORME_CURSEUR_CIBLE , // Fill CURSOR_SHAPE_TARGET , // Fill
FORME_CURSEUR_CIBLE , // Remplacer CURSOR_SHAPE_TARGET , // Replace
FORME_CURSEUR_CIBLE_XOR , // Prise de brosse rectangulaire CURSOR_SHAPE_XOR_TARGET , // Prise de brosse rectangulaire
FORME_CURSEUR_CIBLE , // Prise d'une brosse multiforme CURSOR_SHAPE_TARGET , // Prise d'une brosse multiforme
FORME_CURSEUR_CIBLE_PIPETTE , // Récupération d'une couleur CURSOR_SHAPE_COLORPICKER , // Récupération d'une couleur
FORME_CURSEUR_RECTANGLE_XOR , // Positionnement de la fenêtre de loupe CURSOR_SHAPE_XOR_RECTANGLE , // Positionnement de la fenêtre de loupe
FORME_CURSEUR_CIBLE , // Courbe à 3 points CURSOR_SHAPE_TARGET , // Courbe à 3 points
FORME_CURSEUR_CIBLE , // Courbe à 4 points CURSOR_SHAPE_TARGET , // Courbe à 4 points
FORME_CURSEUR_CIBLE , // Spray CURSOR_SHAPE_TARGET , // Spray
FORME_CURSEUR_CIBLE , // Polygone CURSOR_SHAPE_TARGET , // Polygone
FORME_CURSEUR_CIBLE , // Polyforme CURSOR_SHAPE_TARGET , // Polyforme
FORME_CURSEUR_CIBLE , // Polyfill CURSOR_SHAPE_TARGET , // Polyfill
FORME_CURSEUR_CIBLE , // Polyforme rempli CURSOR_SHAPE_TARGET , // Polyforme rempli
FORME_CURSEUR_MULTIDIRECTIONNEL, // Scroll CURSOR_SHAPE_MULTIDIRECTIONNAL, // Scroll
FORME_CURSEUR_CIBLE , // Cercles dégradés CURSOR_SHAPE_TARGET , // Cercles dégradés
FORME_CURSEUR_CIBLE , // Ellipses dégradées CURSOR_SHAPE_TARGET , // Ellipses dégradées
FORME_CURSEUR_ROTATE_XOR , // Faire tourner brosse CURSOR_SHAPE_XOR_ROTATION , // Faire tourner brosse
FORME_CURSEUR_CIBLE_XOR , // Etirer brosse CURSOR_SHAPE_XOR_TARGET , // Etirer brosse
FORME_CURSEUR_CIBLE , // Deformer brosse CURSOR_SHAPE_TARGET , // Deformer brosse
FORME_CURSEUR_CIBLE_XOR , // Rectangle degrade CURSOR_SHAPE_XOR_TARGET , // Rectangle degrade
}; };
#else #else
extern byte CURSEUR_D_OPERATION[NB_OPERATIONS]; extern byte CURSOR_FOR_OPERATION[NB_OPERATIONS];
#endif #endif
// Procédures à appeler: Opération,Mouse_K,Etat de la pile // Procédures à appeler: Opération,Mouse_K,State de la pile
GFX2_GLOBAL struct GFX2_GLOBAL struct
{ {
byte Effacer_curseur; // Booléen "il faut effacer le curseur pour l'opéra." byte Hide_cursor; // Booléen "il faut effacer le curseur pour l'opéra."
fonction_action Action; // Action appelée Func_action Action; // Action appelée
} Operation[NB_OPERATIONS][3][TAILLE_PILE_OPERATIONS]; } Operation[NB_OPERATIONS][3][OPERATION_STACK_SIZE];
// Informations sur les lecteurs et autres images // Informations sur les lecteurs et autres images
GFX2_GLOBAL byte SPRITE_DRIVE[NB_SPRITES_DRIVES][HAUTEUR_SPRITE_DRIVE][LARGEUR_SPRITE_DRIVE]; GFX2_GLOBAL byte GFX_icon_sprite[NB_ICON_SPRITES][ICON_SPRITE_HEIGHT][ICON_SPRITE_WIDTH];
// -- Section des informations sur les formats de fichiers ------------------ // -- Section des informations sur les formats de fichiers ------------------
// Comptage du nb d'éléments dans la liste: // Comptage du nb d'éléments dans la liste:
GFX2_GLOBAL short Liste_Nb_elements; GFX2_GLOBAL short Filelist_nb_elements;
GFX2_GLOBAL short Liste_Nb_fichiers; GFX2_GLOBAL short Filelist_nb_files;
GFX2_GLOBAL short Liste_Nb_repertoires; GFX2_GLOBAL short Filelist_nb_directories;
// Tête de la liste chaînée: // Tête de la liste chaînée:
GFX2_GLOBAL Element_de_liste_de_fileselect * Liste_du_fileselect; GFX2_GLOBAL T_Fileselector_item * Filelist;
// ------------------- Inititialisation des formats connus ------------------- // ------------------- Inititialisation des formats connus -------------------
void Rien_du_tout(void); void Do_nothing(void);
GFX2_GLOBAL signed char Erreur_fichier; // 0: opération I/O OK GFX2_GLOBAL signed char File_error; // 0: opération I/O OK
// 1: Erreur dès le début de l'opération // 1: Error dès le début de l'opération
// 2: Erreur durant l'opération => données modifiées // 2: Error durant l'opération => données modifiées
//-1: Interruption du chargement d'une preview //-1: Interruption du chargement d'une preview
GFX2_GLOBAL int Ligne_INI; GFX2_GLOBAL int Line_number_in_INI_file;
GFX2_GLOBAL fonction_afficheur Pixel_de_chargement; GFX2_GLOBAL Func_pixel Pixel_load_function;
GFX2_GLOBAL fonction_lecteur Lit_pixel_de_sauvegarde; GFX2_GLOBAL Func_read Read_pixel_old;
/******************** /********************
* Spécifique à SDL * * Spécifique à SDL *
********************/ ********************/
GFX2_GLOBAL SDL_Surface * Ecran_SDL; GFX2_GLOBAL SDL_Surface * Screen_SDL;
GFX2_GLOBAL SDL_Joystick* joystick; GFX2_GLOBAL SDL_Joystick* Joystick;
#define TOUCHE_AUCUNE 0 #define KEY_NONE 0
#define TOUCHE_MOUSEMIDDLE (SDLK_LAST+1) #define KEY_MOUSEMIDDLE (SDLK_LAST+1)
#define TOUCHE_MOUSEWHEELUP (SDLK_LAST+2) #define KEY_MOUSEWHEELUP (SDLK_LAST+2)
#define TOUCHE_MOUSEWHEELDOWN (SDLK_LAST+3) #define KEY_MOUSEWHEELDOWN (SDLK_LAST+3)
#define TOUCHE_BUTTON (SDLK_LAST+4) #define KEY_JOYBUTTON (SDLK_LAST+4)
#ifdef __gp2x__ #ifdef __gp2x__
#define TOUCHE_ESC (TOUCHE_BUTTON+GP2X_BUTTON_X) #define KEY_ESC (KEY_JOYBUTTON+GP2X_BUTTON_X)
#else #else
#define TOUCHE_ESC SDLK_ESCAPE #define KEY_ESC SDLK_ESCAPE
#endif #endif
#endif #endif

2252
graph.c

File diff suppressed because it is too large Load Diff

126
graph.h
View File

@ -19,95 +19,95 @@
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
void Liste2tables(word * list, short step, byte mode, byte * Table_inc, void Shade_list_to_lookup_tables(word * list, short step, byte mode, byte * table_inc,
byte * Table_dec byte * table_dec
); );
void Transformer_point(short x, short y, void Transform_point(short x, short y,
float cosA, float sinA, short * Xr, short * Yr); float cos_a, float sin_a, short * rx, short * ry);
int Initialiser_mode_video(int width, int height, int fullscreen); int Init_mode_video(int width, int height, int fullscreen);
byte Aucun_effet(word x,word y,byte Couleur); byte No_effect(word x,word y,byte color);
byte Effet_Shade(word x,word y,byte Couleur); byte Effect_shade(word x,word y,byte color);
byte Effet_Quick_shade(word x,word y,byte Couleur); byte Effect_quick_shade(word x,word y,byte color);
byte Effet_Tiling(word x,word y,byte Couleur); byte Effect_tiling(word x,word y,byte color);
byte Effet_Smooth(word x,word y,byte Couleur); byte Effect_smooth(word x,word y,byte color);
void Afficher_foreback(void); void Display_foreback(void);
void Afficher_pixel(word x,word y,byte Couleur); void Display_pixel(word x,word y,byte color);
void Afficher_pinceau(short x,short y,byte Couleur,byte is_preview); void Display_paintbrush(short x,short y,byte color,byte is_preview);
void Effacer_pinceau(short x,short y); void Hide_paintbrush(short x,short y);
void Redimentionner_image(word Largeur_choisie,word Hauteur_choisie); void Resize_image(word chosen_width,word chosen_height);
void Remplir(byte Couleur_de_remplissage); void Fill_general(byte fill_color);
void Remplacer(byte Nouvelle_couleur); void Replace(byte New_color);
void Pixel_figure_Preview (word x_pos,word y_pos,byte Couleur); void Pixel_figure_preview (word x_pos,word y_pos,byte color);
void Pixel_figure_Preview_auto(word x_pos,word y_pos); void Pixel_figure_preview_auto(word x_pos,word y_pos);
void Pixel_figure_Preview_xor(word x_pos,word y_pos,byte Couleur); void Pixel_figure_preview_xor(word x_pos,word y_pos,byte color);
void Pixel_figure_Preview_xorback(word x_pos,word y_pos,byte Couleur); void Pixel_figure_preview_xorback(word x_pos,word y_pos,byte color);
void Pixel_figure_Dans_brosse(word x_pos,word y_pos,byte Couleur); void Pixel_figure_in_brush(word x_pos,word y_pos,byte color);
void Tracer_cercle_vide_Definitif(short Centre_X,short Centre_Y,short Rayon,byte Couleur); void Draw_empy_circle_permanent(short center_x,short center_y,short radius,byte color);
void Tracer_cercle_vide_Preview (short Centre_X,short Centre_Y,short Rayon,byte Couleur); void Draw_empy_circle_preview (short center_x,short center_y,short radius,byte color);
void Effacer_cercle_vide_Preview (short Centre_X,short Centre_Y,short Rayon); void Hide_empty_circle_preview (short center_x,short center_y,short radius);
void Tracer_cercle_plein (short Centre_X,short Centre_Y,short Rayon,byte Couleur); void Draw_filled_circle (short center_x,short center_y,short radius,byte color);
void Tracer_ellipse_vide_Definitif(short Centre_X,short Centre_Y,short Rayon_horizontal,short Rayon_vertical,byte Couleur); void Draw_empy_ellipse_permanent(short center_x,short center_y,short horizontal_radius,short vertical_radius,byte color);
void Tracer_ellipse_vide_Preview (short Centre_X,short Centre_Y,short Rayon_horizontal,short Rayon_vertical,byte Couleur); void Draw_empy_ellipse_preview (short center_x,short center_y,short horizontal_radius,short vertical_radius,byte color);
void Effacer_ellipse_vide_Preview (short Centre_X,short Centre_Y,short Rayon_horizontal,short Rayon_vertical); void Hide_empty_ellipse_preview (short center_x,short center_y,short horizontal_radius,short vertical_radius);
void Tracer_ellipse_pleine (short Centre_X,short Centre_Y,short Rayon_horizontal,short Rayon_vertical,byte Couleur); void Draw_filled_ellipse (short center_x,short center_y,short horizontal_radius,short vertical_radius,byte color);
void Rectifier_coordonnees_a_45_degres(short AX, short AY, short* BX, short* BY); void Clamp_coordinates_45_degrees(short ax, short ay, short* bx, short* by);
void Tracer_ligne_General(short Debut_X,short Debut_Y,short Fin_X,short Fin_Y, byte Couleur); void Draw_line_general(short start_x,short start_y,short end_x,short end_y, byte color);
void Tracer_ligne_Definitif (short Debut_X,short Debut_Y,short Fin_X,short Fin_Y,byte Couleur); void Draw_line_permanet (short start_x,short start_y,short end_x,short end_y,byte color);
void Tracer_ligne_Preview (short Debut_X,short Debut_Y,short Fin_X,short Fin_Y,byte Couleur); void Draw_line_preview (short start_x,short start_y,short end_x,short end_y,byte color);
void Tracer_ligne_Preview_xor(short Debut_X,short Debut_Y,short Fin_X,short Fin_Y,byte Couleur); void Draw_line_preview_xor(short start_x,short start_y,short end_x,short end_y,byte color);
void Tracer_ligne_Preview_xorback(short Debut_X,short Debut_Y,short Fin_X,short Fin_Y,byte Couleur); void Draw_line_preview_xorback(short start_x,short start_y,short end_x,short end_y,byte color);
void Effacer_ligne_Preview (short Debut_X,short Debut_Y,short Fin_X,short Fin_Y); void Hide_line_preview (short start_x,short start_y,short end_x,short end_y);
void Tracer_rectangle_vide(short Debut_X,short Debut_Y,short Fin_X,short Fin_Y,byte Couleur); void Draw_empty_rectangle(short start_x,short start_y,short end_x,short end_y,byte color);
void Tracer_rectangle_plein(short Debut_X,short Debut_Y,short Fin_X,short Fin_Y,byte Couleur); void Draw_filled_rectangle(short start_x,short start_y,short end_x,short end_y,byte color);
void Tracer_courbe_Definitif(short X1, short Y1, short X2, short Y2, short X3, short Y3, short X4, short Y4, byte Couleur); void Draw_curve_permanent(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4, byte color);
void Tracer_courbe_Preview (short X1, short Y1, short X2, short Y2, short X3, short Y3, short X4, short Y4, byte Couleur); void Draw_curve_preview (short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4, byte color);
void Effacer_courbe_Preview (short X1, short Y1, short X2, short Y2, short X3, short Y3, short X4, short Y4, byte Couleur); void Hide_curve_preview (short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4, byte color);
void Aerographe(short Bouton_clicke); void Airbrush(short clicked_button);
void Degrade_de_base (long Indice,short x_pos,short y_pos); void Gradient_basic (long index,short x_pos,short y_pos);
void Degrade_de_trames_simples (long Indice,short x_pos,short y_pos); void Gradient_dithered (long index,short x_pos,short y_pos);
void Degrade_de_trames_etendues(long Indice,short x_pos,short y_pos); void Gradient_extra_dithered(long index,short x_pos,short y_pos);
void Degrade_aleatoire (long Indice,short x_pos,short y_pos); void Degrade_aleatoire (long index,short x_pos,short y_pos);
void Tracer_cercle_degrade (short Centre_X,short Centre_Y,short Rayon,short Eclairage_X,short Eclairage_Y); void Draw_grad_circle (short center_x,short center_y,short radius,short spot_x,short spot_y);
void Tracer_ellipse_degradee(short Centre_X,short Centre_Y,short Rayon_horizontal,short Rayon_vertical,short Eclairage_X,short Eclairage_Y); void Draw_grad_ellipse(short center_x,short center_y,short horizontal_radius,short vertical_radius,short spot_x,short spot_y);
void Tracer_rectangle_degrade(short RAX,short RAY,short RBX,short RBY,short VAX,short VAY, short VBX, short VBY); void Draw_grad_rectangle(short rax,short ray,short rbx,short rby,short vax,short vay, short vbx, short vby);
void Polyfill_General(int Vertices, short * Points, int color); void Polyfill_general(int vertices, short * points, int color);
void Polyfill(int Vertices, short * Points, int color); void Polyfill(int vertices, short * points, int color);
// Gestion des backups: // Gestion des backups:
void Download_infos_page_principal(S_Page * Page); void Download_infos_page_main(T_Page * page);
void Download_infos_page_brouillon(S_Page * Page); void Download_infos_page_spare(T_Page * page);
void Download_infos_backup(S_Liste_de_pages * list); void Download_infos_backup(T_List_of_pages * list);
void Detruire_les_listes_de_backups_en_fin_de_programme(void); void Free_all_backup_lists(void);
int Backup_avec_nouvelles_dimensions(int Upload,int width,int height); int Backup_with_new_dimensions(int upload,int width,int height);
int Backuper_et_redimensionner_brouillon(int width,int height); int Backup_and_resize_the_spare(int width,int height);
void Undo(void); void Undo(void);
void Redo(void); void Redo(void);
void Detruire_la_page_courante(void); void Free_current_page(void);
void Interchanger_image_principale_et_brouillon(void); void Exchange_main_and_spare(void);
void Changer_facteur_loupe(byte Indice_facteur); void Change_magnifier_factor(byte factor_index);
void Remap_picture(void); void Remap_picture(void);
// Définition d'une fonction générique de traçage de figures: // Définition d'une fonction générique de traçage de figures:
fonction_afficheur Pixel_figure; Func_pixel Pixel_figure;
void Mettre_Ecran_A_Jour(short x, short y, short width, short height); void Update_part_of_screen(short x, short y, short width, short height);

144
hotkeys.c
View File

@ -23,7 +23,7 @@
#include "global.h" #include "global.h"
#include "hotkeys.h" #include "hotkeys.h"
S_ConfigTouche ConfigTouche[NB_TOUCHES] = { T_Key_config ConfigKey[NB_SHORTCUTS] = {
{0, {0,
"Scroll up", "Scroll up",
"Scrolls the picture up, both in", "Scrolls the picture up, both in",
@ -710,7 +710,7 @@ S_ConfigTouche ConfigTouche[NB_TOUCHES] = {
"pixel in the picture into the", "pixel in the picture into the",
"foreground or background color.", "foreground or background color.",
true, true,
SDLK_BACKQUOTE, // `~ (Touche sous le Esc - ² en AZERTY) SDLK_BACKQUOTE, // `~ (Key sous le Esc - ² en AZERTY)
0}, 0},
{82, {82,
"Swap foreground/background colors", "Swap foreground/background colors",
@ -727,7 +727,7 @@ S_ConfigTouche ConfigTouche[NB_TOUCHES] = {
"", "",
true, true,
SDLK_m, // M (, ? sur AZERTY) SDLK_m, // M (, ? sur AZERTY)
TOUCHE_MOUSEMIDDLE}, KEY_MOUSEMIDDLE},
{84, {84,
"Zoom factor menu", "Zoom factor menu",
"Opens a menu where you can choose a", "Opens a menu where you can choose a",
@ -743,7 +743,7 @@ S_ConfigTouche ConfigTouche[NB_TOUCHES] = {
"", "",
true, true,
SDLK_KP_PLUS, // Grey + SDLK_KP_PLUS, // Grey +
TOUCHE_MOUSEWHEELUP}, KEY_MOUSEWHEELUP},
{86, {86,
"Zoom out", "Zoom out",
"Decrease magnifying factor.", "Decrease magnifying factor.",
@ -751,7 +751,7 @@ S_ConfigTouche ConfigTouche[NB_TOUCHES] = {
"", "",
true, true,
SDLK_KP_MINUS, // Grey - SDLK_KP_MINUS, // Grey -
TOUCHE_MOUSEWHEELDOWN}, KEY_MOUSEWHEELDOWN},
{87, {87,
"Brush effects menu", "Brush effects menu",
"Opens a menu which proposes", "Opens a menu which proposes",
@ -1098,7 +1098,7 @@ S_ConfigTouche ConfigTouche[NB_TOUCHES] = {
0}, 0},
}; };
word Ordonnancement[NB_TOUCHES]= word Ordering[NB_SHORTCUTS]=
{ {
SPECIAL_SCROLL_UP, // Scroll up SPECIAL_SCROLL_UP, // Scroll up
SPECIAL_SCROLL_DOWN, // Scroll down SPECIAL_SCROLL_DOWN, // Scroll down
@ -1118,39 +1118,39 @@ word Ordonnancement[NB_TOUCHES]=
SPECIAL_MOUSE_RIGHT, // Emulate mouse right SPECIAL_MOUSE_RIGHT, // Emulate mouse right
SPECIAL_CLICK_LEFT, // Emulate mouse click left SPECIAL_CLICK_LEFT, // Emulate mouse click left
SPECIAL_CLICK_RIGHT, // Emulate mouse click right SPECIAL_CLICK_RIGHT, // Emulate mouse click right
0x100+BOUTON_CACHER, // Show / Hide menu 0x100+BUTTON_HIDE, // Show / Hide menu
SPECIAL_SHOW_HIDE_CURSOR, // Show / Hide cursor SPECIAL_SHOW_HIDE_CURSOR, // Show / Hide cursor
SPECIAL_PINCEAU_POINT, // Paintbrush = "." SPECIAL_DOT_PAINTBRUSH, // Paintbrush = "."
0x100+BOUTON_PINCEAUX, // Paintbrush choice 0x100+BUTTON_PAINTBRUSHES, // Paintbrush choice
0x200+BOUTON_PINCEAUX, // Monochrome brush 0x200+BUTTON_PAINTBRUSHES, // Monochrome brush
0x100+BOUTON_DESSIN, // Freehand drawing 0x100+BUTTON_DRAW, // Freehand drawing
0x200+BOUTON_DESSIN, // Switch freehand drawing mode 0x200+BUTTON_DRAW, // Switch freehand drawing mode
SPECIAL_DESSIN_CONTINU, // Continuous freehand drawing SPECIAL_CONTINUOUS_DRAW, // Continuous freehand drawing
0x100+BOUTON_LIGNES, // Line 0x100+BUTTON_LINES, // Line
0x200+BOUTON_LIGNES, // Knotted lines 0x200+BUTTON_LINES, // Knotted lines
0x100+BOUTON_SPRAY, // Spray 0x100+BUTTON_AIRBRUSH, // Spray
0x200+BOUTON_SPRAY, // Spray menu 0x200+BUTTON_AIRBRUSH, // Spray menu
0x100+BOUTON_FLOODFILL, // Floodfill 0x100+BUTTON_FLOODFILL, // Floodfill
0x200+BOUTON_FLOODFILL, // Replace color 0x200+BUTTON_FLOODFILL, // Replace color
0x100+BOUTON_COURBES, // Bézier's curves 0x100+BUTTON_CURVES, // Bézier's curves
0x200+BOUTON_COURBES, // Bézier's curve with 3 or 4 points 0x200+BUTTON_CURVES, // Bézier's curve with 3 or 4 points
0x100+BOUTON_RECTANGLES, // Empty rectangle 0x100+BUTTON_RECTANGLES, // Empty rectangle
0x100+BOUTON_FILLRECT, // Filled rectangle 0x100+BUTTON_FILLRECT, // Filled rectangle
0x100+BOUTON_CERCLES, // Empty circle 0x100+BUTTON_CIRCLES, // Empty circle
0x200+BOUTON_CERCLES, // Empty ellipse 0x200+BUTTON_CIRCLES, // Empty ellipse
0x100+BOUTON_FILLCERC, // Filled circle 0x100+BUTTON_FILLCIRC, // Filled circle
0x200+BOUTON_FILLCERC, // Filled ellipse 0x200+BUTTON_FILLCIRC, // Filled ellipse
0x100+BOUTON_POLYGONES, // Empty polygon 0x100+BUTTON_POLYGONS, // Empty polygon
0x200+BOUTON_POLYGONES, // Empty polyform 0x200+BUTTON_POLYGONS, // Empty polyform
0x100+BOUTON_POLYFILL, // Polyfill 0x100+BUTTON_POLYFILL, // Polyfill
0x200+BOUTON_POLYFILL, // Filled polyform 0x200+BUTTON_POLYFILL, // Filled polyform
0x100+BOUTON_GRADRECT, // Gradient rectangle 0x100+BUTTON_GRADRECT, // Gradient rectangle
0x100+BOUTON_GRADMENU, // Gradation menu 0x100+BUTTON_GRADMENU, // Gradation menu
0x100+BOUTON_SPHERES, // Spheres 0x100+BUTTON_SPHERES, // Spheres
0x200+BOUTON_SPHERES, // Gradient ellipses 0x200+BUTTON_SPHERES, // Gradient ellipses
0x100+BOUTON_AJUSTER, // Adjust picture 0x100+BUTTON_ADJUST, // Adjust picture
0x200+BOUTON_AJUSTER, // Flip picture menu 0x200+BUTTON_ADJUST, // Flip picture menu
0x100+BOUTON_EFFETS, // Menu des effets 0x100+BUTTON_EFFECTS, // Menu des effets
SPECIAL_SHADE_MODE, // Shade mode SPECIAL_SHADE_MODE, // Shade mode
SPECIAL_SHADE_MENU, // Shade menu SPECIAL_SHADE_MENU, // Shade menu
SPECIAL_QUICK_SHADE_MODE, // Quick-shade mode SPECIAL_QUICK_SHADE_MODE, // Quick-shade mode
@ -1171,9 +1171,9 @@ word Ordonnancement[NB_TOUCHES]=
SPECIAL_SMEAR_MODE, // Smear mode SPECIAL_SMEAR_MODE, // Smear mode
SPECIAL_TILING_MODE, // Tiling mode SPECIAL_TILING_MODE, // Tiling mode
SPECIAL_TILING_MENU, // Tiling menu SPECIAL_TILING_MENU, // Tiling menu
0x100+BOUTON_BROSSE, // Pick brush 0x100+BUTTON_BRUSH, // Pick brush
0x100+BOUTON_POLYBROSSE, // Pick polyform brush 0x100+BUTTON_POLYBRUSH, // Pick polyform brush
0x200+BOUTON_BROSSE, // Restore brush 0x200+BUTTON_BRUSH, // Restore brush
SPECIAL_FLIP_X, // Flip X SPECIAL_FLIP_X, // Flip X
SPECIAL_FLIP_Y, // Flip Y SPECIAL_FLIP_Y, // Flip Y
SPECIAL_ROTATE_90, // 90° brush rotation SPECIAL_ROTATE_90, // 90° brush rotation
@ -1185,40 +1185,40 @@ word Ordonnancement[NB_TOUCHES]=
SPECIAL_GET_BRUSH_COLORS, // Get colors from brush SPECIAL_GET_BRUSH_COLORS, // Get colors from brush
SPECIAL_RECOLORIZE_BRUSH, // Recolorize brush SPECIAL_RECOLORIZE_BRUSH, // Recolorize brush
SPECIAL_ROTATE_ANY_ANGLE, // Rotate brush by any angle SPECIAL_ROTATE_ANY_ANGLE, // Rotate brush by any angle
0x100+BOUTON_PIPETTE, // Pipette 0x100+BUTTON_COLORPICKER, // Pipette
0x200+BOUTON_PIPETTE, // Swap fore/back color 0x200+BUTTON_COLORPICKER, // Swap fore/back color
0x100+BOUTON_LOUPE, // Magnifier mode 0x100+BUTTON_MAGNIFIER, // Magnifier mode
0x200+BOUTON_LOUPE, // Zoom factor menu 0x200+BUTTON_MAGNIFIER, // Zoom factor menu
SPECIAL_ZOOM_IN, // Zoom in SPECIAL_ZOOM_IN, // Zoom in
SPECIAL_ZOOM_OUT, // Zoom out SPECIAL_ZOOM_OUT, // Zoom out
0x100+BOUTON_EFFETS_BROSSE, // Brush effects menu 0x100+BUTTON_BRUSH_EFFECTS, // Brush effects menu
0x100+BOUTON_TEXTE, // Text 0x100+BUTTON_TEXT, // Text
0x100+BOUTON_RESOL, // Resolution menu 0x100+BUTTON_RESOL, // Resolution menu
0x200+BOUTON_RESOL, // Safety resolution 0x200+BUTTON_RESOL, // Safety resolution
0x100+BOUTON_AIDE, // Help & credits 0x100+BUTTON_HELP, // Help & credits
0x200+BOUTON_AIDE, // Statistics 0x200+BUTTON_HELP, // Statistics
0x100+BOUTON_PAGE, // Go to spare page 0x100+BUTTON_PAGE, // Go to spare page
0x200+BOUTON_PAGE, // Copy to spare page 0x200+BUTTON_PAGE, // Copy to spare page
0x100+BOUTON_SAUVER, // Save as 0x100+BUTTON_SAVE, // Save as
0x200+BOUTON_SAUVER, // Save 0x200+BUTTON_SAVE, // Save
0x100+BOUTON_CHARGER, // Load 0x100+BUTTON_LOAD, // Load
0x200+BOUTON_CHARGER, // Re-load 0x200+BUTTON_LOAD, // Re-load
SPECIAL_SAVE_BRUSH, // Save brush SPECIAL_SAVE_BRUSH, // Save brush
SPECIAL_LOAD_BRUSH, // Load brush SPECIAL_LOAD_BRUSH, // Load brush
0x100+BOUTON_PARAMETRES, // Settings 0x100+BUTTON_SETTINGS, // Settings
0x100+BOUTON_UNDO, // Undo 0x100+BUTTON_UNDO, // Undo
0x200+BOUTON_UNDO, // Redo 0x200+BUTTON_UNDO, // Redo
0x100+BOUTON_KILL, // Kill 0x100+BUTTON_KILL, // Kill
0x100+BOUTON_CLEAR, // Clear 0x100+BUTTON_CLEAR, // Clear
0x200+BOUTON_CLEAR, // Clear with backcolor 0x200+BUTTON_CLEAR, // Clear with backcolor
0x100+BOUTON_QUIT, // Quit 0x100+BUTTON_QUIT, // Quit
0x100+BOUTON_PALETTE, // Palette menu 0x100+BUTTON_PALETTE, // Palette menu
0x200+BOUTON_PALETTE, // Palette menu secondaire 0x200+BUTTON_PALETTE, // Palette menu secondaire
SPECIAL_EXCLUDE_COLORS_MENU, // Exclude colors menu SPECIAL_EXCLUDE_COLORS_MENU, // Exclude colors menu
0x100+BOUTON_PAL_LEFT, // Scroll palette left 0x100+BUTTON_PAL_LEFT, // Scroll palette left
0x100+BOUTON_PAL_RIGHT, // Scroll palette right 0x100+BUTTON_PAL_RIGHT, // Scroll palette right
0x200+BOUTON_PAL_LEFT, // Scroll palette left faster 0x200+BUTTON_PAL_LEFT, // Scroll palette left faster
0x200+BOUTON_PAL_RIGHT, // Scroll palette right faster 0x200+BUTTON_PAL_RIGHT, // Scroll palette right faster
SPECIAL_CENTER_ATTACHMENT, // Center brush attachement SPECIAL_CENTER_ATTACHMENT, // Center brush attachement
SPECIAL_TOP_LEFT_ATTACHMENT, // Top-left brush attachement SPECIAL_TOP_LEFT_ATTACHMENT, // Top-left brush attachement
SPECIAL_TOP_RIGHT_ATTACHMENT, // Top-right brush attachement SPECIAL_TOP_RIGHT_ATTACHMENT, // Top-right brush attachement
@ -1232,6 +1232,6 @@ word Ordonnancement[NB_TOUCHES]=
SPECIAL_PREVIOUS_USER_FORECOLOR, // Previous user-defined foreground color SPECIAL_PREVIOUS_USER_FORECOLOR, // Previous user-defined foreground color
SPECIAL_NEXT_USER_BACKCOLOR, // Next user-defined background color SPECIAL_NEXT_USER_BACKCOLOR, // Next user-defined background color
SPECIAL_PREVIOUS_USER_BACKCOLOR, // Previous user-defined background color SPECIAL_PREVIOUS_USER_BACKCOLOR, // Previous user-defined background color
SPECIAL_RETRECIR_PINCEAU, // Rétrécir le pinceau SPECIAL_SMALLER_PAINTBRUSH, // Rétrécir le pinceau
SPECIAL_GROSSIR_PINCEAU // Grossir le pinceau SPECIAL_BIGGER_PAINTBRUSH // Grossir le pinceau
}; };

View File

@ -31,10 +31,10 @@ typedef struct
char Explic1[37]; char Explic1[37];
char Explic2[37]; char Explic2[37];
char Explic3[37]; char Explic3[37];
bool Suppr; // Raccourci facultatif bool Suppr; // Shortcut facultatif
word Touche; word Key;
word Touche2; word Key2;
} S_ConfigTouche; } T_Key_config;
extern S_ConfigTouche ConfigTouche[NB_TOUCHES]; extern T_Key_config ConfigKey[NB_SHORTCUTS];
extern word Ordonnancement[NB_TOUCHES]; extern word Ordering[NB_SHORTCUTS];

2454
init.c

File diff suppressed because it is too large Load Diff

18
init.h
View File

@ -18,12 +18,12 @@
write to the Free Software Foundation, Inc., write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
void Charger_DAT(void); void Load_DAT(void);
void Initialisation_des_boutons(void); void Init_buttons(void);
void Initialisation_des_operations(void); void Init_operations(void);
int Charger_CFG(int Tout_charger); int Load_CFG(int reload_all);
int Sauver_CFG(void); int Save_CFG(void);
void Initialiser_les_tables_de_multiplication(void); void Init_multiplication_tables(void);
void Definition_des_modes_video(void); void Set_all_video_modes(void);
void Config_par_defaut(void); void Set_config_defaults(void);
void Initialiser_sighandler(void); void Init_sighandler(void);

344
input.c
View File

@ -29,8 +29,8 @@
#include "divers.h" #include "divers.h"
#include "input.h" #include "input.h"
void Handle_Window_Resize(SDL_ResizeEvent event); void Handle_window_resize(SDL_ResizeEvent event);
void Handle_Window_Exit(SDL_QuitEvent event); void Handle_window_exit(SDL_QuitEvent event);
byte Directional_up; byte Directional_up;
byte Directional_up_right; byte Directional_up_right;
@ -45,41 +45,41 @@ long Directional_last_move;
long Directional_step; long Directional_step;
short Mouse_count; // Number of mouse movements received in the current Get_input() short Mouse_count; // Number of mouse movements received in the current Get_input()
word INPUT_Nouveau_Mouse_X; word Input_new_mouse_X;
word INPUT_Nouveau_Mouse_Y; word Input_new_mouse_Y;
byte INPUT_Nouveau_Mouse_K; byte Input_new_mouse_K;
// TODO: move to config // TODO: move to config
short Button_shift=-1; // Button number that serves as a "shift" modifier short Joybutton_shift=-1; // Button number that serves as a "shift" modifier
short Button_control=-1; // Button number that serves as a "ctrl" modifier short Joybutton_control=-1; // Button number that serves as a "ctrl" modifier
short Button_alt=-1; // Button number that serves as a "alt" modifier short Joybutton_alt=-1; // Button number that serves as a "alt" modifier
short Button_clic_gauche=0; // Button number that serves as left click short Joybutton_left_click=0; // Button number that serves as left click
short Button_clic_droit=0; // Button number that serves as right-click short Joybutton_right_click=0; // Button number that serves as right-click
int Est_Raccourci(word Touche, word function) int Is_shortcut(word Key, word function)
{ {
if (Touche == 0) if (Key == 0)
return 0; return 0;
if (function & 0x100) if (function & 0x100)
{ {
if (Bouton[function&0xFF].Raccourci_gauche[0]==Touche) if (Button[function&0xFF].Left_shortcut[0]==Key)
return 1; return 1;
if (Bouton[function&0xFF].Raccourci_gauche[1]==Touche) if (Button[function&0xFF].Left_shortcut[1]==Key)
return 1; return 1;
return 0; return 0;
} }
if (function & 0x200) if (function & 0x200)
{ {
if (Bouton[function&0xFF].Raccourci_droite[0]==Touche) if (Button[function&0xFF].Right_shortcut[0]==Key)
return 1; return 1;
if (Bouton[function&0xFF].Raccourci_droite[1]==Touche) if (Button[function&0xFF].Right_shortcut[1]==Key)
return 1; return 1;
return 0; return 0;
} }
if(Touche == Config_Touche[function][0]) if(Key == Config_Key[function][0])
return 1; return 1;
if(Touche == Config_Touche[function][1]) if(Key == Config_Key[function][1])
return 1; return 1;
return 0; return 0;
} }
@ -91,34 +91,34 @@ int Move_cursor_with_constraints()
//Gestion "avancée" du curseur: interdire la descente du curseur dans le //Gestion "avancée" du curseur: interdire la descente du curseur dans le
//menu lorsqu'on est en train de travailler dans l'image //menu lorsqu'on est en train de travailler dans l'image
if (Operation_Taille_pile != 0) if (Operation_stack_size != 0)
{ {
byte bl=0;//BL va indiquer si on doit corriger la position du curseur byte bl=0;//BL va indiquer si on doit corriger la position du curseur
//Si le curseur ne se trouve plus dans l'image //Si le curseur ne se trouve plus dans l'image
if(Menu_Ordonnee<=INPUT_Nouveau_Mouse_Y) if(Menu_Y<=Input_new_mouse_Y)
{ {
//On bloque le curseur en fin d'image //On bloque le curseur en fin d'image
bl++; bl++;
INPUT_Nouveau_Mouse_Y=Menu_Ordonnee-1; //La ligne !!au-dessus!! du menu Input_new_mouse_Y=Menu_Y-1; //La ligne !!au-dessus!! du menu
} }
if(Loupe_Mode) if(Main_magnifier_mode)
{ {
if(Operation_dans_loupe==0) if(Operation_in_magnifier==0)
{ {
if(INPUT_Nouveau_Mouse_X>=Principal_Split) if(Input_new_mouse_X>=Main_separator_position)
{ {
bl++; bl++;
INPUT_Nouveau_Mouse_X=Principal_Split-1; Input_new_mouse_X=Main_separator_position-1;
} }
} }
else else
{ {
if(INPUT_Nouveau_Mouse_X<Principal_X_Zoom) if(Input_new_mouse_X<Main_X_zoom)
{ {
bl++; bl++;
INPUT_Nouveau_Mouse_X=Principal_X_Zoom; Input_new_mouse_X=Main_X_zoom;
} }
} }
} }
@ -126,26 +126,26 @@ int Move_cursor_with_constraints()
if (bl) if (bl)
{ {
SDL_WarpMouse( SDL_WarpMouse(
INPUT_Nouveau_Mouse_X*Pixel_width, Input_new_mouse_X*Pixel_width,
INPUT_Nouveau_Mouse_Y*Pixel_height Input_new_mouse_Y*Pixel_height
); );
} }
} }
if ((INPUT_Nouveau_Mouse_X != Mouse_X) || if ((Input_new_mouse_X != Mouse_X) ||
(INPUT_Nouveau_Mouse_Y != Mouse_Y) || (Input_new_mouse_Y != Mouse_Y) ||
(INPUT_Nouveau_Mouse_K != Mouse_K)) (Input_new_mouse_K != Mouse_K))
{ {
if ((INPUT_Nouveau_Mouse_K != Mouse_K)) if ((Input_new_mouse_K != Mouse_K))
feedback=1; feedback=1;
Effacer_curseur(); // On efface le curseur AVANT de le déplacer... Hide_cursor(); // On efface le curseur AVANT de le déplacer...
Mouse_X=INPUT_Nouveau_Mouse_X; Mouse_X=Input_new_mouse_X;
Mouse_Y=INPUT_Nouveau_Mouse_Y; Mouse_Y=Input_new_mouse_Y;
Mouse_K=INPUT_Nouveau_Mouse_K; Mouse_K=Input_new_mouse_K;
Calculer_coordonnees_pinceau(); Compute_paintbrush_coordinates();
Afficher_curseur(); Display_cursor();
Mouse_count++; Mouse_count++;
if (Mouse_count>Config.Mouse_Merge_movement) if (Mouse_count>Config.Mouse_merge_movement)
feedback=1; feedback=1;
} }
@ -154,50 +154,50 @@ int Move_cursor_with_constraints()
// WM events management // WM events management
void Handle_Window_Resize(SDL_ResizeEvent event) void Handle_window_resize(SDL_ResizeEvent event)
{ {
Resize_Largeur = event.w; Resize_width = event.w;
Resize_Hauteur = event.h; Resize_height = event.h;
} }
void Handle_Window_Exit(__attribute__((unused)) SDL_QuitEvent event) void Handle_window_exit(__attribute__((unused)) SDL_QuitEvent event)
{ {
Quit_demande = 1; Quit_is_required = 1;
} }
// Mouse events management // Mouse events management
int Handle_Mouse_Move(SDL_MouseMotionEvent event) int Handle_mouse_move(SDL_MouseMotionEvent event)
{ {
INPUT_Nouveau_Mouse_X = event.x/Pixel_width; Input_new_mouse_X = event.x/Pixel_width;
INPUT_Nouveau_Mouse_Y = event.y/Pixel_height; Input_new_mouse_Y = event.y/Pixel_height;
return Move_cursor_with_constraints(); return Move_cursor_with_constraints();
} }
int Handle_Mouse_Click(SDL_MouseButtonEvent event) int Handle_mouse_click(SDL_MouseButtonEvent event)
{ {
switch(event.button) switch(event.button)
{ {
case SDL_BUTTON_LEFT: case SDL_BUTTON_LEFT:
INPUT_Nouveau_Mouse_K |= 1; Input_new_mouse_K |= 1;
break; break;
case SDL_BUTTON_RIGHT: case SDL_BUTTON_RIGHT:
INPUT_Nouveau_Mouse_K |= 2; Input_new_mouse_K |= 2;
break; break;
case SDL_BUTTON_MIDDLE: case SDL_BUTTON_MIDDLE:
Touche = TOUCHE_MOUSEMIDDLE|Modificateurs_Touche(SDL_GetModState()); Key = KEY_MOUSEMIDDLE|Key_modifiers(SDL_GetModState());
// TODO: systeme de répétition // TODO: systeme de répétition
return 0; return 0;
case SDL_BUTTON_WHEELUP: case SDL_BUTTON_WHEELUP:
Touche = TOUCHE_MOUSEWHEELUP|Modificateurs_Touche(SDL_GetModState()); Key = KEY_MOUSEWHEELUP|Key_modifiers(SDL_GetModState());
return 0; return 0;
case SDL_BUTTON_WHEELDOWN: case SDL_BUTTON_WHEELDOWN:
Touche = TOUCHE_MOUSEWHEELDOWN|Modificateurs_Touche(SDL_GetModState()); Key = KEY_MOUSEWHEELDOWN|Key_modifiers(SDL_GetModState());
return 0; return 0;
default: default:
return 0; return 0;
@ -205,16 +205,16 @@ int Handle_Mouse_Click(SDL_MouseButtonEvent event)
return Move_cursor_with_constraints(); return Move_cursor_with_constraints();
} }
int Handle_Mouse_Release(SDL_MouseButtonEvent event) int Handle_mouse_release(SDL_MouseButtonEvent event)
{ {
switch(event.button) switch(event.button)
{ {
case SDL_BUTTON_LEFT: case SDL_BUTTON_LEFT:
INPUT_Nouveau_Mouse_K &= ~1; Input_new_mouse_K &= ~1;
break; break;
case SDL_BUTTON_RIGHT: case SDL_BUTTON_RIGHT:
INPUT_Nouveau_Mouse_K &= ~2; Input_new_mouse_K &= ~2;
break; break;
} }
return Move_cursor_with_constraints(); return Move_cursor_with_constraints();
@ -222,108 +222,108 @@ int Handle_Mouse_Release(SDL_MouseButtonEvent event)
// Keyboard management // Keyboard management
int Handle_Key_Press(SDL_KeyboardEvent event) int Handle_key_press(SDL_KeyboardEvent event)
{ {
//Appui sur une touche du clavier //Appui sur une touche du clavier
Touche = Conversion_Touche(event.keysym); Key = Keysym_to_keycode(event.keysym);
Touche_ANSI = Conversion_ANSI(event.keysym); Key_ANSI = Keysym_to_ANSI(event.keysym);
if(Est_Raccourci(Touche,SPECIAL_MOUSE_UP)) if(Is_shortcut(Key,SPECIAL_MOUSE_UP))
{ {
Directional_up=1; Directional_up=1;
return 0; return 0;
} }
else if(Est_Raccourci(Touche,SPECIAL_MOUSE_DOWN)) else if(Is_shortcut(Key,SPECIAL_MOUSE_DOWN))
{ {
Directional_down=1; Directional_down=1;
return 0; return 0;
} }
else if(Est_Raccourci(Touche,SPECIAL_MOUSE_LEFT)) else if(Is_shortcut(Key,SPECIAL_MOUSE_LEFT))
{ {
Directional_left=1; Directional_left=1;
return 0; return 0;
} }
else if(Est_Raccourci(Touche,SPECIAL_MOUSE_RIGHT)) else if(Is_shortcut(Key,SPECIAL_MOUSE_RIGHT))
{ {
Directional_right=1; Directional_right=1;
return 0; return 0;
} }
else if(Est_Raccourci(Touche,SPECIAL_CLICK_LEFT)) else if(Is_shortcut(Key,SPECIAL_CLICK_LEFT))
{ {
INPUT_Nouveau_Mouse_K=1; Input_new_mouse_K=1;
return Move_cursor_with_constraints(); return Move_cursor_with_constraints();
} }
else if(Est_Raccourci(Touche,SPECIAL_CLICK_RIGHT)) else if(Is_shortcut(Key,SPECIAL_CLICK_RIGHT))
{ {
INPUT_Nouveau_Mouse_K=2; Input_new_mouse_K=2;
return Move_cursor_with_constraints(); return Move_cursor_with_constraints();
} }
if (Operation_Taille_pile!=0 && Touche != 0) if (Operation_stack_size!=0 && Key != 0)
{ {
//Enfin, on inhibe les touches (sauf si c'est un changement de couleur //Enfin, on inhibe les touches (sauf si c'est un changement de couleur
//ou de taille de pinceau lors d'une des operations suivantes: //ou de taille de pinceau lors d'une des operations suivantes:
//OPERATION_DESSIN_CONTINU, OPERATION_DESSIN_DISCONTINU, OPERATION_SPRAY) //OPERATION_CONTINUOUS_DRAW, OPERATION_DISCONTINUOUS_DRAW, OPERATION_AIRBRUSH)
if(Autoriser_changement_de_couleur_pendant_operation) if(Allow_color_change_during_operation)
{ {
//A ce stade là, on sait qu'on est dans une des 3 opérations //A ce stade là, on sait qu'on est dans une des 3 opérations
//supportant le changement de couleur ou de taille de pinceau. //supportant le changement de couleur ou de taille de pinceau.
if( if(
(!Est_Raccourci(Touche,SPECIAL_NEXT_FORECOLOR)) && (!Is_shortcut(Key,SPECIAL_NEXT_FORECOLOR)) &&
(!Est_Raccourci(Touche,SPECIAL_PREVIOUS_FORECOLOR)) && (!Is_shortcut(Key,SPECIAL_PREVIOUS_FORECOLOR)) &&
(!Est_Raccourci(Touche,SPECIAL_NEXT_BACKCOLOR)) && (!Is_shortcut(Key,SPECIAL_NEXT_BACKCOLOR)) &&
(!Est_Raccourci(Touche,SPECIAL_PREVIOUS_BACKCOLOR)) && (!Is_shortcut(Key,SPECIAL_PREVIOUS_BACKCOLOR)) &&
(!Est_Raccourci(Touche,SPECIAL_RETRECIR_PINCEAU)) && (!Is_shortcut(Key,SPECIAL_SMALLER_PAINTBRUSH)) &&
(!Est_Raccourci(Touche,SPECIAL_GROSSIR_PINCEAU)) && (!Is_shortcut(Key,SPECIAL_BIGGER_PAINTBRUSH)) &&
(!Est_Raccourci(Touche,SPECIAL_NEXT_USER_FORECOLOR)) && (!Is_shortcut(Key,SPECIAL_NEXT_USER_FORECOLOR)) &&
(!Est_Raccourci(Touche,SPECIAL_PREVIOUS_USER_FORECOLOR)) && (!Is_shortcut(Key,SPECIAL_PREVIOUS_USER_FORECOLOR)) &&
(!Est_Raccourci(Touche,SPECIAL_NEXT_USER_BACKCOLOR)) && (!Is_shortcut(Key,SPECIAL_NEXT_USER_BACKCOLOR)) &&
(!Est_Raccourci(Touche,SPECIAL_PREVIOUS_USER_BACKCOLOR)) (!Is_shortcut(Key,SPECIAL_PREVIOUS_USER_BACKCOLOR))
) )
{ {
Touche=0; Key=0;
} }
} }
else Touche = 0; else Key = 0;
} }
return 0; return 0;
} }
int Relache_controle(int CodeTouche, int Modifieur) int Release_control(int key_code, int modifier)
{ {
if(CodeTouche == (Config_Touche[SPECIAL_MOUSE_UP][0]&0x0FFF) || (Config_Touche[SPECIAL_MOUSE_UP][0]&Modifieur) || if(key_code == (Config_Key[SPECIAL_MOUSE_UP][0]&0x0FFF) || (Config_Key[SPECIAL_MOUSE_UP][0]&modifier) ||
CodeTouche == (Config_Touche[SPECIAL_MOUSE_UP][1]&0x0FFF) || (Config_Touche[SPECIAL_MOUSE_UP][1]&Modifieur)) key_code == (Config_Key[SPECIAL_MOUSE_UP][1]&0x0FFF) || (Config_Key[SPECIAL_MOUSE_UP][1]&modifier))
{ {
Directional_up=0; Directional_up=0;
} }
if(CodeTouche == (Config_Touche[SPECIAL_MOUSE_DOWN][0]&0x0FFF) || (Config_Touche[SPECIAL_MOUSE_DOWN][0]&Modifieur) || if(key_code == (Config_Key[SPECIAL_MOUSE_DOWN][0]&0x0FFF) || (Config_Key[SPECIAL_MOUSE_DOWN][0]&modifier) ||
CodeTouche == (Config_Touche[SPECIAL_MOUSE_DOWN][1]&0x0FFF) || (Config_Touche[SPECIAL_MOUSE_DOWN][1]&Modifieur)) key_code == (Config_Key[SPECIAL_MOUSE_DOWN][1]&0x0FFF) || (Config_Key[SPECIAL_MOUSE_DOWN][1]&modifier))
{ {
Directional_down=0; Directional_down=0;
} }
if(CodeTouche == (Config_Touche[SPECIAL_MOUSE_LEFT][0]&0x0FFF) || (Config_Touche[SPECIAL_MOUSE_LEFT][0]&Modifieur) || if(key_code == (Config_Key[SPECIAL_MOUSE_LEFT][0]&0x0FFF) || (Config_Key[SPECIAL_MOUSE_LEFT][0]&modifier) ||
CodeTouche == (Config_Touche[SPECIAL_MOUSE_LEFT][1]&0x0FFF) || (Config_Touche[SPECIAL_MOUSE_LEFT][1]&Modifieur)) key_code == (Config_Key[SPECIAL_MOUSE_LEFT][1]&0x0FFF) || (Config_Key[SPECIAL_MOUSE_LEFT][1]&modifier))
{ {
Directional_left=0; Directional_left=0;
} }
if(CodeTouche == (Config_Touche[SPECIAL_MOUSE_RIGHT][0]&0x0FFF) || (Config_Touche[SPECIAL_MOUSE_RIGHT][0]&Modifieur) || if(key_code == (Config_Key[SPECIAL_MOUSE_RIGHT][0]&0x0FFF) || (Config_Key[SPECIAL_MOUSE_RIGHT][0]&modifier) ||
CodeTouche == (Config_Touche[SPECIAL_MOUSE_RIGHT][1]&0x0FFF) || (Config_Touche[SPECIAL_MOUSE_RIGHT][1]&Modifieur)) key_code == (Config_Key[SPECIAL_MOUSE_RIGHT][1]&0x0FFF) || (Config_Key[SPECIAL_MOUSE_RIGHT][1]&modifier))
{ {
Directional_right=0; Directional_right=0;
} }
if(CodeTouche == (Config_Touche[SPECIAL_CLICK_LEFT][0]&0x0FFF) || (Config_Touche[SPECIAL_CLICK_LEFT][0]&Modifieur) || if(key_code == (Config_Key[SPECIAL_CLICK_LEFT][0]&0x0FFF) || (Config_Key[SPECIAL_CLICK_LEFT][0]&modifier) ||
CodeTouche == (Config_Touche[SPECIAL_CLICK_LEFT][1]&0x0FFF) || (Config_Touche[SPECIAL_CLICK_LEFT][1]&Modifieur)) key_code == (Config_Key[SPECIAL_CLICK_LEFT][1]&0x0FFF) || (Config_Key[SPECIAL_CLICK_LEFT][1]&modifier))
{ {
INPUT_Nouveau_Mouse_K &= ~1; Input_new_mouse_K &= ~1;
return Move_cursor_with_constraints(); return Move_cursor_with_constraints();
} }
if(CodeTouche == (Config_Touche[SPECIAL_CLICK_RIGHT][0]&0x0FFF) || (Config_Touche[SPECIAL_CLICK_RIGHT][0]&Modifieur) || if(key_code == (Config_Key[SPECIAL_CLICK_RIGHT][0]&0x0FFF) || (Config_Key[SPECIAL_CLICK_RIGHT][0]&modifier) ||
CodeTouche == (Config_Touche[SPECIAL_CLICK_RIGHT][1]&0x0FFF) || (Config_Touche[SPECIAL_CLICK_RIGHT][1]&Modifieur)) key_code == (Config_Key[SPECIAL_CLICK_RIGHT][1]&0x0FFF) || (Config_Key[SPECIAL_CLICK_RIGHT][1]&modifier))
{ {
INPUT_Nouveau_Mouse_K &= ~2; Input_new_mouse_K &= ~2;
return Move_cursor_with_constraints(); return Move_cursor_with_constraints();
} }
@ -334,62 +334,62 @@ int Relache_controle(int CodeTouche, int Modifieur)
} }
int Handle_Key_Release(SDL_KeyboardEvent event) int Handle_key_release(SDL_KeyboardEvent event)
{ {
int Modifieur; int modifier;
int ToucheR = Conversion_Touche(event.keysym) & 0x0FFF; int released_key = Keysym_to_keycode(event.keysym) & 0x0FFF;
switch(event.keysym.sym) switch(event.keysym.sym)
{ {
case SDLK_RSHIFT: case SDLK_RSHIFT:
case SDLK_LSHIFT: case SDLK_LSHIFT:
Modifieur=MOD_SHIFT; modifier=MOD_SHIFT;
break; break;
case SDLK_RCTRL: case SDLK_RCTRL:
case SDLK_LCTRL: case SDLK_LCTRL:
Modifieur=MOD_CTRL; modifier=MOD_CTRL;
break; break;
case SDLK_RALT: case SDLK_RALT:
case SDLK_LALT: case SDLK_LALT:
case SDLK_MODE: case SDLK_MODE:
Modifieur=MOD_ALT; modifier=MOD_ALT;
break; break;
default: default:
Modifieur=0; modifier=0;
} }
return Relache_controle(ToucheR, Modifieur); return Release_control(released_key, modifier);
} }
// Joystick management // Joystick management
int Handle_Joystick_Press(SDL_JoyButtonEvent event) int Handle_joystick_press(SDL_JoyButtonEvent event)
{ {
if (event.which==0) // joystick number 0 if (event.which==0) // Joystick number 0
{ {
if (event.button == Button_shift) if (event.button == Joybutton_shift)
{ {
SDL_SetModState(SDL_GetModState() | KMOD_SHIFT); SDL_SetModState(SDL_GetModState() | KMOD_SHIFT);
return 0; return 0;
} }
if (event.button == Button_control) if (event.button == Joybutton_control)
{ {
SDL_SetModState(SDL_GetModState() | KMOD_CTRL); SDL_SetModState(SDL_GetModState() | KMOD_CTRL);
return 0; return 0;
} }
if (event.button == Button_alt) if (event.button == Joybutton_alt)
{ {
SDL_SetModState(SDL_GetModState() | (KMOD_ALT|KMOD_META)); SDL_SetModState(SDL_GetModState() | (KMOD_ALT|KMOD_META));
return 0; return 0;
} }
if (event.button == Button_clic_gauche) if (event.button == Joybutton_left_click)
{ {
INPUT_Nouveau_Mouse_K=1; Input_new_mouse_K=1;
return Move_cursor_with_constraints(); return Move_cursor_with_constraints();
} }
if (event.button == Button_clic_droit) if (event.button == Joybutton_right_click)
{ {
INPUT_Nouveau_Mouse_K=2; Input_new_mouse_K=2;
return Move_cursor_with_constraints(); return Move_cursor_with_constraints();
} }
#ifdef __gp2x__ #ifdef __gp2x__
@ -424,7 +424,7 @@ int Handle_Joystick_Press(SDL_JoyButtonEvent event)
default: default:
} }
#endif #endif
Touche = (TOUCHE_BUTTON+event.button)|Modificateurs_Touche(SDL_GetModState()); Key = (KEY_JOYBUTTON+event.button)|Key_modifiers(SDL_GetModState());
// TODO: systeme de répétition // TODO: systeme de répétition
return Move_cursor_with_constraints(); return Move_cursor_with_constraints();
@ -432,24 +432,24 @@ int Handle_Joystick_Press(SDL_JoyButtonEvent event)
return 0; return 0;
} }
int Handle_Joystick_Release(SDL_JoyButtonEvent event) int Handle_joystick_release(SDL_JoyButtonEvent event)
{ {
if (event.which==0) // joystick number 0 if (event.which==0) // Joystick number 0
{ {
if (event.button == Button_shift) if (event.button == Joybutton_shift)
{ {
SDL_SetModState(SDL_GetModState() & ~KMOD_SHIFT); SDL_SetModState(SDL_GetModState() & ~KMOD_SHIFT);
return Relache_controle(0,MOD_SHIFT); return Release_control(0,MOD_SHIFT);
} }
if (event.button == Button_control) if (event.button == Joybutton_control)
{ {
SDL_SetModState(SDL_GetModState() & ~KMOD_CTRL); SDL_SetModState(SDL_GetModState() & ~KMOD_CTRL);
return Relache_controle(0,MOD_CTRL); return Release_control(0,MOD_CTRL);
} }
if (event.button == Button_alt) if (event.button == Joybutton_alt)
{ {
SDL_SetModState(SDL_GetModState() & ~(KMOD_ALT|KMOD_META)); SDL_SetModState(SDL_GetModState() & ~(KMOD_ALT|KMOD_META));
return Relache_controle(0,MOD_ALT); return Release_control(0,MOD_ALT);
} }
#ifdef __gp2x__ #ifdef __gp2x__
@ -480,20 +480,20 @@ int Handle_Joystick_Release(SDL_JoyButtonEvent event)
Directional_up_left=0; Directional_up_left=0;
break; break;
case GP2X_BUTTON_A: // A case GP2X_BUTTON_A: // A
INPUT_Nouveau_Mouse_K &= ~1; Input_new_mouse_K &= ~1;
break; break;
case GP2X_BUTTON_B: // B case GP2X_BUTTON_B: // B
INPUT_Nouveau_Mouse_K &= ~2; Input_new_mouse_K &= ~2;
break; break;
} }
#else #else
switch(event.button) switch(event.button)
{ {
case 0: // A case 0: // A
INPUT_Nouveau_Mouse_K &= ~1; Input_new_mouse_K &= ~1;
break; break;
case 1: // B case 1: // B
INPUT_Nouveau_Mouse_K &= ~2; Input_new_mouse_K &= ~2;
break; break;
} }
#endif #endif
@ -501,9 +501,9 @@ int Handle_Joystick_Release(SDL_JoyButtonEvent event)
return Move_cursor_with_constraints(); return Move_cursor_with_constraints();
} }
void Handle_Joystick_Movement(SDL_JoyAxisEvent event) void Handle_joystick_movement(SDL_JoyAxisEvent event)
{ {
if (event.which==0) // joystick number 0 if (event.which==0) // Joystick number 0
{ {
#ifndef NO_JOYCURSOR #ifndef NO_JOYCURSOR
if (event.axis==0) // X if (event.axis==0) // X
@ -531,34 +531,34 @@ void Handle_Joystick_Movement(SDL_JoyAxisEvent event)
} }
// Attempts to move the mouse cursor by the given deltas (may be more than 1 pixel at a time) // Attempts to move the mouse cursor by the given deltas (may be more than 1 pixel at a time)
int Cursor_displace(short Delta_X, short Delta_Y) int Cursor_displace(short delta_x, short delta_y)
{ {
short x=INPUT_Nouveau_Mouse_X; short x=Input_new_mouse_X;
short y=INPUT_Nouveau_Mouse_Y; short y=Input_new_mouse_Y;
if(Loupe_Mode && INPUT_Nouveau_Mouse_Y < Menu_Ordonnee && INPUT_Nouveau_Mouse_X > Principal_Split) if(Main_magnifier_mode && Input_new_mouse_Y < Menu_Y && Input_new_mouse_X > Main_separator_position)
{ {
// Cursor in zoomed area // Cursor in zoomed area
if (Delta_X<0) if (delta_x<0)
INPUT_Nouveau_Mouse_X = Max(Principal_Split, x-Loupe_Facteur); Input_new_mouse_X = Max(Main_separator_position, x-Main_magnifier_factor);
else if (Delta_X>0) else if (delta_x>0)
INPUT_Nouveau_Mouse_X = Min(Largeur_ecran-1, x+Loupe_Facteur); Input_new_mouse_X = Min(Screen_width-1, x+Main_magnifier_factor);
if (Delta_Y<0) if (delta_y<0)
INPUT_Nouveau_Mouse_Y = Max(0, y-Loupe_Facteur); Input_new_mouse_Y = Max(0, y-Main_magnifier_factor);
else if (Delta_Y>0) else if (delta_y>0)
INPUT_Nouveau_Mouse_Y = Min(Hauteur_ecran-1, y+Loupe_Facteur); Input_new_mouse_Y = Min(Screen_height-1, y+Main_magnifier_factor);
} }
else else
{ {
if (Delta_X<0) if (delta_x<0)
INPUT_Nouveau_Mouse_X = Max(0, x+Delta_X); Input_new_mouse_X = Max(0, x+delta_x);
else if (Delta_X>0) else if (delta_x>0)
INPUT_Nouveau_Mouse_X = Min(Largeur_ecran-1, x+Delta_X); Input_new_mouse_X = Min(Screen_width-1, x+delta_x);
if (Delta_Y<0) if (delta_y<0)
INPUT_Nouveau_Mouse_Y = Max(0, y+Delta_Y); Input_new_mouse_Y = Max(0, y+delta_y);
else if (Delta_Y>0) else if (delta_y>0)
INPUT_Nouveau_Mouse_Y = Min(Hauteur_ecran-1, y+Delta_Y); Input_new_mouse_Y = Min(Screen_height-1, y+delta_y);
} }
return Move_cursor_with_constraints(); return Move_cursor_with_constraints();
} }
@ -569,64 +569,64 @@ int Cursor_displace(short Delta_X, short Delta_Y)
int Get_input(void) int Get_input(void)
{ {
SDL_Event event; SDL_Event event;
int User_Feedback_Required = 0; // Flag qui indique si on doit arrêter de traiter les évènements ou si on peut enchainer int user_feedback_required = 0; // Flag qui indique si on doit arrêter de traiter les évènements ou si on peut enchainer
Touche_ANSI = 0; Key_ANSI = 0;
Touche = 0; Key = 0;
Mouse_count=0; Mouse_count=0;
// Process as much events as possible without redrawing the screen. // Process as much events as possible without redrawing the screen.
// This mostly allows us to merge mouse events for people with an high // This mostly allows us to merge mouse events for people with an high
// resolution mouse // resolution mouse
while( (!User_Feedback_Required) && SDL_PollEvent(&event)) // Try to cumulate for a full VBL except if there is a required feedback while( (!user_feedback_required) && SDL_PollEvent(&event)) // Try to cumulate for a full VBL except if there is a required feedback
{ {
switch(event.type) switch(event.type)
{ {
case SDL_VIDEORESIZE: case SDL_VIDEORESIZE:
Handle_Window_Resize(event.resize); Handle_window_resize(event.resize);
User_Feedback_Required = 1; user_feedback_required = 1;
break; break;
case SDL_QUIT: case SDL_QUIT:
Handle_Window_Exit(event.quit); Handle_window_exit(event.quit);
User_Feedback_Required = 1; user_feedback_required = 1;
break; break;
case SDL_MOUSEMOTION: case SDL_MOUSEMOTION:
User_Feedback_Required = Handle_Mouse_Move(event.motion); user_feedback_required = Handle_mouse_move(event.motion);
break; break;
case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONDOWN:
Handle_Mouse_Click(event.button); Handle_mouse_click(event.button);
User_Feedback_Required = 1; user_feedback_required = 1;
break; break;
case SDL_MOUSEBUTTONUP: case SDL_MOUSEBUTTONUP:
Handle_Mouse_Release(event.button); Handle_mouse_release(event.button);
User_Feedback_Required = 1; user_feedback_required = 1;
break; break;
case SDL_KEYDOWN: case SDL_KEYDOWN:
Handle_Key_Press(event.key); Handle_key_press(event.key);
User_Feedback_Required = 1; user_feedback_required = 1;
break; break;
case SDL_KEYUP: case SDL_KEYUP:
Handle_Key_Release(event.key); Handle_key_release(event.key);
break; break;
case SDL_JOYBUTTONUP: case SDL_JOYBUTTONUP:
Handle_Joystick_Release(event.jbutton); Handle_joystick_release(event.jbutton);
User_Feedback_Required = 1; user_feedback_required = 1;
break; break;
case SDL_JOYBUTTONDOWN: case SDL_JOYBUTTONDOWN:
Handle_Joystick_Press(event.jbutton); Handle_joystick_press(event.jbutton);
User_Feedback_Required = 1; user_feedback_required = 1;
break; break;
case SDL_JOYAXISMOTION: case SDL_JOYAXISMOTION:
Handle_Joystick_Movement(event.jaxis); Handle_joystick_movement(event.jaxis);
break; break;
default: default:
@ -694,5 +694,5 @@ int Get_input(void)
// (c'est fait ici car on est sur que cette function est apellée partout ou on a besoin d'interragir avec l'utilisateur) // (c'est fait ici car on est sur que cette function est apellée partout ou on a besoin d'interragir avec l'utilisateur)
Flush_update(); Flush_update();
return User_Feedback_Required; return user_feedback_required;
} }

View File

@ -20,4 +20,4 @@
*/ */
int Get_input(void); int Get_input(void);
int Est_Raccourci(word Touche, word function); int Is_shortcut(word Key, word function);

110
io.c
View File

@ -40,7 +40,7 @@
#include "struct.h" #include "struct.h"
#include "io.h" #include "io.h"
word endian_magic16(word x) word Endian_magic16(word x)
{ {
#if SDL_BYTEORDER == SDL_LIL_ENDIAN #if SDL_BYTEORDER == SDL_LIL_ENDIAN
return x; return x;
@ -48,7 +48,7 @@ word endian_magic16(word x)
return SDL_Swap16(x); return SDL_Swap16(x);
#endif #endif
} }
dword endian_magic32(dword x) dword Endian_magic32(dword x)
{ {
#if SDL_BYTEORDER == SDL_LIL_ENDIAN #if SDL_BYTEORDER == SDL_LIL_ENDIAN
return x; return x;
@ -59,43 +59,43 @@ dword endian_magic32(dword x)
// Lit un octet // Lit un octet
// Renvoie -1 si OK, 0 en cas d'erreur // Renvoie -1 si OK, 0 en cas d'erreur
int read_byte(FILE *file, byte *Dest) int Read_byte(FILE *file, byte *dest)
{ {
return fread(Dest, 1, 1, file) == 1; return fread(dest, 1, 1, file) == 1;
} }
// Ecrit un octet // Ecrit un octet
// Renvoie -1 si OK, 0 en cas d'erreur // Renvoie -1 si OK, 0 en cas d'erreur
int write_byte(FILE *file, byte b) int Write_byte(FILE *file, byte b)
{ {
return fwrite(&b, 1, 1, file) == 1; return fwrite(&b, 1, 1, file) == 1;
} }
// Lit des octets // Lit des octets
// Renvoie -1 si OK, 0 en cas d'erreur // Renvoie -1 si OK, 0 en cas d'erreur
int read_bytes(FILE *file, void *Dest, size_t size) int Read_bytes(FILE *file, void *dest, size_t size)
{ {
return fread(Dest, 1, size, file) == size; return fread(dest, 1, size, file) == size;
} }
// Ecrit des octets // Ecrit des octets
// Renvoie -1 si OK, 0 en cas d'erreur // Renvoie -1 si OK, 0 en cas d'erreur
int write_bytes(FILE *file, void *Src, size_t size) int Write_bytes(FILE *file, void *src, size_t size)
{ {
return fwrite(Src, 1, size, file) == size; return fwrite(src, 1, size, file) == size;
} }
// Lit un word (little-endian) // Lit un word (little-endian)
// Renvoie -1 si OK, 0 en cas d'erreur // Renvoie -1 si OK, 0 en cas d'erreur
int read_word_le(FILE *file, word *Dest) int Read_word_le(FILE *file, word *dest)
{ {
if (fread(Dest, 1, sizeof(word), file) != sizeof(word)) if (fread(dest, 1, sizeof(word), file) != sizeof(word))
return 0; return 0;
#if SDL_BYTEORDER != SDL_LIL_ENDIAN #if SDL_BYTEORDER != SDL_LIL_ENDIAN
*Dest = SDL_Swap16(*Dest); *dest = SDL_Swap16(*dest);
#endif #endif
return -1; return -1;
} }
// Ecrit un word (little-endian) // Ecrit un word (little-endian)
// Renvoie -1 si OK, 0 en cas d'erreur // Renvoie -1 si OK, 0 en cas d'erreur
int write_word_le(FILE *file, word w) int Write_word_le(FILE *file, word w)
{ {
#if SDL_BYTEORDER != SDL_LIL_ENDIAN #if SDL_BYTEORDER != SDL_LIL_ENDIAN
w = SDL_Swap16(w); w = SDL_Swap16(w);
@ -104,18 +104,18 @@ int write_word_le(FILE *file, word w)
} }
// Lit un word (big-endian) // Lit un word (big-endian)
// Renvoie -1 si OK, 0 en cas d'erreur // Renvoie -1 si OK, 0 en cas d'erreur
int read_word_be(FILE *file, word *Dest) int Read_word_be(FILE *file, word *dest)
{ {
if (fread(Dest, 1, sizeof(word), file) != sizeof(word)) if (fread(dest, 1, sizeof(word), file) != sizeof(word))
return 0; return 0;
#if SDL_BYTEORDER != SDL_BIG_ENDIAN #if SDL_BYTEORDER != SDL_BIG_ENDIAN
*Dest = SDL_Swap16(*Dest); *dest = SDL_Swap16(*dest);
#endif #endif
return -1; return -1;
} }
// Ecrit un word (big-endian) // Ecrit un word (big-endian)
// Renvoie -1 si OK, 0 en cas d'erreur // Renvoie -1 si OK, 0 en cas d'erreur
int write_word_be(FILE *file, word w) int Write_word_be(FILE *file, word w)
{ {
#if SDL_BYTEORDER != SDL_BIG_ENDIAN #if SDL_BYTEORDER != SDL_BIG_ENDIAN
w = SDL_Swap16(w); w = SDL_Swap16(w);
@ -124,18 +124,18 @@ int write_word_be(FILE *file, word w)
} }
// Lit un dword (little-endian) // Lit un dword (little-endian)
// Renvoie -1 si OK, 0 en cas d'erreur // Renvoie -1 si OK, 0 en cas d'erreur
int read_dword_le(FILE *file, dword *Dest) int Read_dword_le(FILE *file, dword *dest)
{ {
if (fread(Dest, 1, sizeof(dword), file) != sizeof(dword)) if (fread(dest, 1, sizeof(dword), file) != sizeof(dword))
return 0; return 0;
#if SDL_BYTEORDER != SDL_LIL_ENDIAN #if SDL_BYTEORDER != SDL_LIL_ENDIAN
*Dest = SDL_Swap32(*Dest); *dest = SDL_Swap32(*dest);
#endif #endif
return -1; return -1;
} }
// Ecrit un dword (little-endian) // Ecrit un dword (little-endian)
// Renvoie -1 si OK, 0 en cas d'erreur // Renvoie -1 si OK, 0 en cas d'erreur
int write_dword_le(FILE *file, dword dw) int Write_dword_le(FILE *file, dword dw)
{ {
#if SDL_BYTEORDER != SDL_LIL_ENDIAN #if SDL_BYTEORDER != SDL_LIL_ENDIAN
dw = SDL_Swap32(dw); dw = SDL_Swap32(dw);
@ -145,18 +145,18 @@ int write_dword_le(FILE *file, dword dw)
// Lit un dword (big-endian) // Lit un dword (big-endian)
// Renvoie -1 si OK, 0 en cas d'erreur // Renvoie -1 si OK, 0 en cas d'erreur
int read_dword_be(FILE *file, dword *Dest) int Read_dword_be(FILE *file, dword *dest)
{ {
if (fread(Dest, 1, sizeof(dword), file) != sizeof(dword)) if (fread(dest, 1, sizeof(dword), file) != sizeof(dword))
return 0; return 0;
#if SDL_BYTEORDER != SDL_BIG_ENDIAN #if SDL_BYTEORDER != SDL_BIG_ENDIAN
*Dest = SDL_Swap32(*Dest); *dest = SDL_Swap32(*dest);
#endif #endif
return -1; return -1;
} }
// Ecrit un dword (big-endian) // Ecrit un dword (big-endian)
// Renvoie -1 si OK, 0 en cas d'erreur // Renvoie -1 si OK, 0 en cas d'erreur
int write_dword_be(FILE *file, dword dw) int Write_dword_be(FILE *file, dword dw)
{ {
#if SDL_BYTEORDER != SDL_BIG_ENDIAN #if SDL_BYTEORDER != SDL_BIG_ENDIAN
dw = SDL_Swap32(dw); dw = SDL_Swap32(dw);
@ -169,69 +169,69 @@ int write_dword_be(FILE *file, dword dw)
// Attention, sous Windows, il faut s'attendre aux deux car // Attention, sous Windows, il faut s'attendre aux deux car
// par exemple un programme lancé sous GDB aura comme argv[0]: // par exemple un programme lancé sous GDB aura comme argv[0]:
// d:\Data\C\GFX2\grafx2/grafx2.exe // d:\Data\C\GFX2\grafx2/grafx2.exe
char * Position_dernier_slash(const char * Chaine) char * Find_last_slash(const char * str)
{ {
const char * position = NULL; const char * position = NULL;
for (; *Chaine != '\0'; Chaine++) for (; *str != '\0'; str++)
if (*Chaine == SEPARATEUR_CHEMIN[0] if (*str == PATH_SEPARATOR[0]
#ifdef __WIN32__ #ifdef __WIN32__
|| *Chaine == '/' || *str == '/'
#endif #endif
) )
position = Chaine; position = str;
return (char *)position; return (char *)position;
} }
// Récupère la partie "nom de file seul" d'un chemin // Récupère la partie "nom de file seul" d'un chemin
void Extraire_nom_fichier(char *dest, const char *Source) void Extract_filename(char *dest, const char *source)
{ {
const char * position = Position_dernier_slash(Source); const char * position = Find_last_slash(source);
if (position) if (position)
strcpy(dest,position+1); strcpy(dest,position+1);
else else
strcpy(dest,Source); strcpy(dest,source);
} }
// Récupère la partie "répertoire+/" d'un chemin. // Récupère la partie "répertoire+/" d'un chemin.
void Extraire_chemin(char *dest, const char *Source) void Extract_path(char *dest, const char *source)
{ {
char * position; char * position;
strcpy(dest,Source); strcpy(dest,source);
position = Position_dernier_slash(dest); position = Find_last_slash(dest);
if (position) if (position)
*(position+1) = '\0'; *(position+1) = '\0';
else else
strcat(dest, SEPARATEUR_CHEMIN); strcat(dest, PATH_SEPARATOR);
} }
int Fichier_existe(char * fname) int File_exists(char * fname)
// Détermine si un file passé en paramètre existe ou non dans le // Détermine si un file passé en paramètre existe ou non dans le
// répertoire courant. // répertoire courant.
{ {
struct stat buf; struct stat buf;
int Resultat; int result;
Resultat=stat(fname,&buf); result=stat(fname,&buf);
if (Resultat!=0) if (result!=0)
return(errno!=ENOENT); return(errno!=ENOENT);
else else
return 1; return 1;
} }
int Repertoire_existe(char * Repertoire) int Directory_exists(char * directory)
// Détermine si un répertoire passé en paramètre existe ou non dans le // Détermine si un répertoire passé en paramètre existe ou non dans le
// répertoire courant. // répertoire courant.
{ {
DIR* entry; // Structure de lecture des éléments DIR* entry; // Structure de lecture des éléments
if (strcmp(Repertoire,PARENT_DIR)==0) if (strcmp(directory,PARENT_DIR)==0)
return 1; return 1;
else else
{ {
// On va chercher si le répertoire existe à l'aide d'un Opendir. S'il // On va chercher si le répertoire existe à l'aide d'un Opendir. S'il
// renvoie NULL c'est que le répertoire n'est pas accessible... // renvoie NULL c'est que le répertoire n'est pas accessible...
entry=opendir(Repertoire); entry=opendir(directory);
if (entry==NULL) if (entry==NULL)
return 0; return 0;
else else
@ -243,7 +243,7 @@ int Repertoire_existe(char * Repertoire)
} }
// Taille de fichier, en octets // Taille de fichier, en octets
int FileLength(const char * fname) int File_length(const char * fname)
{ {
struct stat infos_fichier; struct stat infos_fichier;
if (stat(fname,&infos_fichier)) if (stat(fname,&infos_fichier))
@ -258,26 +258,26 @@ int File_length_file(FILE * file)
return infos_fichier.st_size; return infos_fichier.st_size;
} }
void for_each_file(const char * Nom_repertoire, void Callback(const char *)) void For_each_file(const char * directory_name, void Callback(const char *))
{ {
// Pour scan de répertoire // Pour scan de répertoire
DIR* Repertoire_Courant; //Répertoire courant DIR* Repertoire_Courant; //Répertoire courant
struct dirent* entry; // Structure de lecture des éléments struct dirent* entry; // Structure de lecture des éléments
char Nom_fichier_complet[TAILLE_CHEMIN_FICHIER]; char filename_complet[MAX_PATH_CHARACTERS];
int Position_nom_fichier; int filename_position;
strcpy(Nom_fichier_complet, Nom_repertoire); strcpy(filename_complet, directory_name);
Repertoire_Courant=opendir(Nom_repertoire); Repertoire_Courant=opendir(directory_name);
if(Repertoire_Courant == NULL) return; // Répertoire invalide ... if(Repertoire_Courant == NULL) return; // Répertoire invalide ...
strcat(Nom_fichier_complet, SEPARATEUR_CHEMIN); strcat(filename_complet, PATH_SEPARATOR);
Position_nom_fichier = strlen(Nom_fichier_complet); filename_position = strlen(filename_complet);
while ((entry=readdir(Repertoire_Courant))) while ((entry=readdir(Repertoire_Courant)))
{ {
struct stat Infos_enreg; struct stat Infos_enreg;
strcpy(&Nom_fichier_complet[Position_nom_fichier], entry->d_name); strcpy(&filename_complet[filename_position], entry->d_name);
stat(Nom_fichier_complet,&Infos_enreg); stat(filename_complet,&Infos_enreg);
if (S_ISREG(Infos_enreg.st_mode)) if (S_ISREG(Infos_enreg.st_mode))
{ {
Callback(Nom_fichier_complet); Callback(filename_complet);
} }
} }
closedir(Repertoire_Courant); closedir(Repertoire_Courant);

46
io.h
View File

@ -19,48 +19,48 @@
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
word endian_magic16(word x); word Endian_magic16(word x);
dword endian_magic32(dword x); dword Endian_magic32(dword x);
int read_byte(FILE *file, byte *Dest); int Read_byte(FILE *file, byte *dest);
int write_byte(FILE *file, byte b); int Write_byte(FILE *file, byte b);
int read_bytes(FILE *file, void *Dest, size_t size); int Read_bytes(FILE *file, void *dest, size_t size);
int write_bytes(FILE *file, void *Dest, size_t size); int Write_bytes(FILE *file, void *dest, size_t size);
int read_word_le(FILE *file, word *Dest); int Read_word_le(FILE *file, word *dest);
int write_word_le(FILE *file, word w); int Write_word_le(FILE *file, word w);
int read_dword_le(FILE *file, dword *Dest); int Read_dword_le(FILE *file, dword *dest);
int write_dword_le(FILE *file, dword dw); int Write_dword_le(FILE *file, dword dw);
int read_word_be(FILE *file, word *Dest); int Read_word_be(FILE *file, word *dest);
int write_word_be(FILE *file, word w); int Write_word_be(FILE *file, word w);
int read_dword_be(FILE *file, dword *Dest); int Read_dword_be(FILE *file, dword *dest);
int write_dword_be(FILE *file, dword dw); int Write_dword_be(FILE *file, dword dw);
void Extraire_nom_fichier(char *dest, const char *Source); void Extract_filename(char *dest, const char *source);
void Extraire_chemin(char *dest, const char *Source); void Extract_path(char *dest, const char *source);
char * Position_dernier_slash(const char * Chaine); char * Find_last_slash(const char * str);
#if defined(__WIN32__) #if defined(__WIN32__)
#define SEPARATEUR_CHEMIN "\\" #define PATH_SEPARATOR "\\"
#else #else
#define SEPARATEUR_CHEMIN "/" #define PATH_SEPARATOR "/"
#endif #endif
// Taille de fichier, en octets // Taille de fichier, en octets
int FileLength(const char *fname); int File_length(const char *fname);
// Taille de fichier, en octets // Taille de fichier, en octets
int File_length_file(FILE * file); int File_length_file(FILE * file);
// Détermine si un file passé en paramètre existe ou non dans le // Détermine si un file passé en paramètre existe ou non dans le
// répertoire courant. // répertoire courant.
int Fichier_existe(char * fname); int File_exists(char * fname);
// Détermine si un répertoire passé en paramètre existe ou non dans le // Détermine si un répertoire passé en paramètre existe ou non dans le
// répertoire courant. // répertoire courant.
int Repertoire_existe(char * Repertoire); int Directory_exists(char * directory);
// Scans a directory, calls Callback for each file in it, // Scans a directory, calls Callback for each file in it,
void for_each_file(const char * Nom_repertoire, void Callback(const char *)); void For_each_file(const char * directory_name, void Callback(const char *));

4346
loadsave.c

File diff suppressed because it is too large Load Diff

View File

@ -19,26 +19,26 @@
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
void Pixel_Chargement_dans_ecran_courant(word x_pos,word y_pos,byte Couleur); void Pixel_load_in_current_screen(word x_pos,word y_pos,byte color);
void Pixel_Chargement_dans_preview (word x_pos,word y_pos,byte Couleur); void Pixel_load_in_preview (word x_pos,word y_pos,byte color);
void Pixel_Chargement_dans_brosse (word x_pos,word y_pos,byte Couleur); void Pixel_load_in_brush (word x_pos,word y_pos,byte color);
void Nom_fichier_complet(char * Nom_du_fichier, byte Sauve_Colorix); void filename_complet(char * filename, byte is_colorix_format);
void Charger_image(byte image); void Load_image(byte image);
void Sauver_image(byte image); void Save_image(byte image);
typedef struct { typedef struct {
char *Extension; char *Extension;
fonction_action Test; Func_action Test;
fonction_action Load; Func_action Load;
fonction_action Save; Func_action Save;
byte Backup_done; // Le format enregistre toute l'image, on la considère à jour. byte Backup_done; // Le format enregistre toute l'image, on la considère à jour.
byte Commentaire; // Le format de fichier autorise un commentaire. byte Comment; // Le format de fichier autorise un commentaire.
} T_Format; } T_Format;
// Tableau des formats connus // Tableau des formats connus
extern T_Format FormatFichier[NB_FORMATS_CONNUS]; extern T_Format File_formats[NB_KNOWN_FORMATS];
// Fonction de sauvegarde en cas de probleme // Fonction de sauvegarde en cas de probleme
void Image_emergency_backup(void); void Image_emergency_backup(void);

638
main.c
View File

@ -20,7 +20,7 @@
write to the Free Software Foundation, Inc., write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#define VARIABLES_GLOBALES #define GLOBAL_VARIABLES
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -72,13 +72,13 @@
extern DECLSPEC int SDLCALL SDL_putenv(const char *variable); extern DECLSPEC int SDLCALL SDL_putenv(const char *variable);
#endif #endif
byte Ancien_nb_lignes; // Ancien nombre de lignes de l'écran byte Old_lines_number; // old nombre de lignes de l'écran
//--- Affichage de la syntaxe, et de la liste des modes vidéos disponibles --- //--- Affichage de la syntaxe, et de la liste des modes vidéos disponibles ---
void Afficher_syntaxe(void) void Display_syntax(void)
{ {
int Indice_mode; int mode_index;
printf("Syntax: GFX2 [<arguments>] [<picture>]\n\n"); printf("Syntax: GFX2 [<arguments>] [<picture>]\n\n");
printf("<arguments> can be:]\n"); printf("<arguments> can be:]\n");
printf("\t/? /h /help for this help screen\n"); printf("\t/? /h /help for this help screen\n");
@ -87,78 +87,78 @@ void Afficher_syntaxe(void)
printf("\t/double to emulate a video mode with double pixels (2x2)\n"); printf("\t/double to emulate a video mode with double pixels (2x2)\n");
printf("\t/mode <videomode> to set a video mode\n\n"); printf("\t/mode <videomode> to set a video mode\n\n");
printf("Available video modes:\n\n"); printf("Available video modes:\n\n");
for (Indice_mode=0; Indice_mode<Nb_modes_video; Indice_mode++) for (mode_index=0; mode_index<Nb_video_modes; mode_index++)
printf("\t%s\n",Libelle_mode(Indice_mode)); printf("\t%s\n",Mode_label(mode_index));
} }
// ---------------------------- Sortie impromptue ---------------------------- // ---------------------------- Sortie impromptue ----------------------------
void Erreur_fonction(int error_code, const char *filename, int Numero_ligne, const char *Nom_fonction) void Error_function(int error_code, const char *filename, int line_number, const char *function_name)
{ {
T_Palette Palette_temporaire; T_Palette temp_palette;
int Indice; int index;
printf("Error number %d occured in file %s, line %d, function %s.\n", error_code, filename,Numero_ligne,Nom_fonction); printf("Error number %d occured in file %s, line %d, function %s.\n", error_code, filename,line_number,function_name);
if (error_code==0) if (error_code==0)
{ {
// L'erreur 0 n'est pas une vraie erreur, elle fait seulement un flash rouge de l'écran pour dire qu'il y a un problème. // L'erreur 0 n'est pas une vraie erreur, elle fait seulement un flash rouge de l'écran pour dire qu'il y a un problème.
// Toutes les autres erreurs déclenchent toujours une sortie en catastrophe du programme ! // Toutes les autres erreurs déclenchent toujours une sortie en catastrophe du programme !
memcpy(Palette_temporaire,Principal_Palette,sizeof(T_Palette)); memcpy(temp_palette,Main_palette,sizeof(T_Palette));
for (Indice=0;Indice<=255;Indice++) for (index=0;index<=255;index++)
Palette_temporaire[Indice].R=255; temp_palette[index].R=255;
Set_palette(Palette_temporaire); Set_palette(temp_palette);
SDL_Delay(500); SDL_Delay(500);
Set_palette(Principal_Palette); Set_palette(Main_palette);
} }
else else
{ {
switch (error_code) switch (error_code)
{ {
case ERREUR_GUI_ABSENT : printf("Error: File gfx2gui.gif is missing!\n"); case ERROR_GUI_MISSING : printf("Error: File gfx2gui.gif is missing!\n");
printf("This program cannot run without this file.\n"); printf("This program cannot run without this file.\n");
break; break;
case ERREUR_GUI_CORROMPU : printf("Error: File gfx2gui.gif is corrupt!\n"); case ERROR_GUI_CORRUPTED : printf("Error: File gfx2gui.gif is corrupt!\n");
printf("This program cannot run without a correct version of this file.\n"); printf("This program cannot run without a correct version of this file.\n");
break; break;
case ERREUR_INI_ABSENT : printf("Error: File gfx2def.ini is missing!\n"); case ERROR_INI_MISSING : printf("Error: File gfx2def.ini is missing!\n");
printf("This program cannot run without this file.\n"); printf("This program cannot run without this file.\n");
break; break;
case ERREUR_CFG_ABSENT : printf("Error: File GFX2.CFG is missing!\n"); case ERROR_CFG_MISSING : printf("Error: File GFX2.CFG is missing!\n");
printf("Please run GFXCFG to create it.\n"); printf("Please run GFXCFG to create it.\n");
break; break;
case ERREUR_CFG_CORROMPU : printf("Error: File GFX2.CFG is corrupt!\n"); case ERROR_CFG_CORRUPTED : printf("Error: File GFX2.CFG is corrupt!\n");
printf("Please run GFXCFG to make a valid file.\n"); printf("Please run GFXCFG to make a valid file.\n");
break; break;
case ERREUR_CFG_ANCIEN : printf("Error: File GFX2.CFG is from another version of GrafX2.\n"); case ERROR_CFG_OLD : printf("Error: File GFX2.CFG is from another version of GrafX2.\n");
printf("Please run GFXCFG to update this file.\n"); printf("Please run GFXCFG to update this file.\n");
break; break;
case ERREUR_MEMOIRE : printf("Error: Not enough memory!\n\n"); case ERROR_MEMORY : printf("Error: Not enough memory!\n\n");
printf("You should try exiting other programs to free some bytes for Grafx2.\n\n"); printf("You should try exiting other programs to free some bytes for Grafx2.\n\n");
break; break;
case ERREUR_DRIVER_SOURIS : printf("Error: No mouse detected!\n"); case ERROR_MOUSE_DRIVER : printf("Error: No mouse detected!\n");
printf("Check if a mouse driver is installed and if your mouse is correctly connected.\n"); printf("Check if a mouse driver is installed and if your mouse is correctly connected.\n");
break; break;
case ERREUR_MODE_INTERDIT : printf("Error: The requested video mode has been disabled from the resolution menu!\n"); case ERROR_FORBIDDEN_MODE : printf("Error: The requested video mode has been disabled from the resolution menu!\n");
printf("If you want to run the program in this mode, you'll have to start it with an\n"); printf("If you want to run the program in this mode, you'll have to start it with an\n");
printf("enabled mode, then enter the resolution menu and enable the mode you want.\n"); printf("enabled mode, then enter the resolution menu and enable the mode you want.\n");
printf("Check also if the 'Default_video_mode' parameter in GFX2.INI is correct.\n"); printf("Check also if the 'Default_video_mode' parameter in GFX2.INI is correct.\n");
break; break;
case ERREUR_LIGNE_COMMANDE : printf("Error: Invalid parameter or file not found.\n\n"); case ERROR_COMMAND_LINE : printf("Error: Invalid parameter or file not found.\n\n");
Afficher_syntaxe(); Display_syntax();
break; break;
case ERREUR_SAUVEGARDE_CFG : printf("Error: Write error while saving settings!\n"); case ERROR_SAVING_CFG : printf("Error: Write error while saving settings!\n");
printf("Settings have not been saved correctly, and the GFX2.CFG file may have been\n"); printf("Settings have not been saved correctly, and the GFX2.CFG file may have been\n");
printf("corrupt. If so, please run GFXCFG to make a new valid file.\n"); printf("corrupt. If so, please run GFXCFG to make a new valid file.\n");
break; break;
case ERREUR_REPERTOIRE_DISPARU : printf("Error: Directory you ran the program from not found!\n"); case ERROR_MISSING_DIRECTORY : printf("Error: Directory you ran the program from not found!\n");
break; break;
case ERREUR_INI_CORROMPU : printf("Error: File GFX2.INI is corrupt!\n"); case ERROR_INI_CORRUPTED : printf("Error: File GFX2.INI is corrupt!\n");
printf("It contains bad values at line %d.\n",Ligne_INI); printf("It contains bad values at line %d.\n",Line_number_in_INI_file);
printf("You can re-generate it by deleting the file and running GrafX2 again.\n"); printf("You can re-generate it by deleting the file and running GrafX2 again.\n");
break; break;
case ERREUR_SAUVEGARDE_INI : printf("Error: Cannot rewrite file GFX2.INI!\n"); case ERROR_SAVING_INI : printf("Error: Cannot rewrite file GFX2.INI!\n");
break; break;
case ERREUR_SORRY_SORRY_SORRY : printf("Error: Sorry! Sorry! Sorry! Please forgive me!\n"); case ERROR_SORRY_SORRY_SORRY : printf("Error: Sorry! Sorry! Sorry! Please forgive me!\n");
break; break;
} }
@ -168,119 +168,119 @@ void Erreur_fonction(int error_code, const char *filename, int Numero_ligne, con
} }
// --------------------- Analyse de la ligne de commande --------------------- // --------------------- Analyse de la ligne de commande ---------------------
void Analyse_de_la_ligne_de_commande(int argc,char * argv[]) void Analyze_command_line(int argc,char * argv[])
{ {
char *Buffer ; char *buffer ;
int Indice; int index;
Un_fichier_a_ete_passe_en_parametre=0; File_in_command_line=0;
Une_resolution_a_ete_passee_en_parametre=0; Resolution_in_command_line=0;
Resolution_actuelle=Config.Resolution_par_defaut; Current_resolution=Config.Default_resolution;
for (Indice=1; Indice<argc; Indice++) for (index=1; index<argc; index++)
{ {
if ( !strcmp(argv[Indice],"/?") || if ( !strcmp(argv[index],"/?") ||
!strcmp(argv[Indice],"/h") || !strcmp(argv[index],"/h") ||
!strcmp(argv[Indice],"/H") ) !strcmp(argv[index],"/H") )
{ {
// help // help
Afficher_syntaxe(); Display_syntax();
exit(0); exit(0);
} }
else if ( !strcmp(argv[Indice],"/mode") ) else if ( !strcmp(argv[index],"/mode") )
{ {
// mode // mode
Indice++; index++;
if (Indice<argc) if (index<argc)
{ {
Une_resolution_a_ete_passee_en_parametre = 1; Resolution_in_command_line = 1;
Resolution_actuelle=Conversion_argument_mode(argv[Indice]); Current_resolution=Convert_videomode_arg(argv[index]);
if (Resolution_actuelle == -1) if (Current_resolution == -1)
{ {
Erreur(ERREUR_LIGNE_COMMANDE); Error(ERROR_COMMAND_LINE);
Afficher_syntaxe(); Display_syntax();
exit(0); exit(0);
} }
if ((Mode_video[Resolution_actuelle].Etat & 0x7F) == 3) if ((Video_mode[Current_resolution].State & 0x7F) == 3)
{ {
Erreur(ERREUR_MODE_INTERDIT); Error(ERROR_FORBIDDEN_MODE);
exit(0); exit(0);
} }
} }
else else
{ {
Erreur(ERREUR_LIGNE_COMMANDE); Error(ERROR_COMMAND_LINE);
Afficher_syntaxe(); Display_syntax();
exit(0); exit(0);
} }
} }
else if ( !strcmp(argv[Indice],"/tall") ) else if ( !strcmp(argv[index],"/tall") )
{ {
Pixel_ratio = PIXEL_TALL; Pixel_ratio = PIXEL_TALL;
} }
else if ( !strcmp(argv[Indice],"/wide") ) else if ( !strcmp(argv[index],"/wide") )
{ {
Pixel_ratio = PIXEL_WIDE; Pixel_ratio = PIXEL_WIDE;
} }
else if ( !strcmp(argv[Indice],"/double") ) else if ( !strcmp(argv[index],"/double") )
{ {
Pixel_ratio = PIXEL_DOUBLE; Pixel_ratio = PIXEL_DOUBLE;
} }
else if ( !strcmp(argv[Indice],"/rgb") ) else if ( !strcmp(argv[index],"/rgb") )
{ {
// echelle des composants RGB // echelle des composants RGB
Indice++; index++;
if (Indice<argc) if (index<argc)
{ {
int scale; int scale;
scale = atoi(argv[Indice]); scale = atoi(argv[index]);
if (scale < 2 || scale > 256) if (scale < 2 || scale > 256)
{ {
Erreur(ERREUR_LIGNE_COMMANDE); Error(ERROR_COMMAND_LINE);
Afficher_syntaxe(); Display_syntax();
exit(0); exit(0);
} }
Set_Palette_RGB_Scale(scale); Set_palette_RGB_scale(scale);
} }
else else
{ {
Erreur(ERREUR_LIGNE_COMMANDE); Error(ERROR_COMMAND_LINE);
Afficher_syntaxe(); Display_syntax();
exit(0); exit(0);
} }
} }
else else
{ {
// Si ce n'est pas un paramètre, c'est le nom du fichier à ouvrir // Si ce n'est pas un paramètre, c'est le nom du fichier à ouvrir
if (Un_fichier_a_ete_passe_en_parametre) if (File_in_command_line)
{ {
// plusieurs noms de fichier en argument // plusieurs noms de fichier en argument
Erreur(ERREUR_LIGNE_COMMANDE); Error(ERROR_COMMAND_LINE);
Afficher_syntaxe(); Display_syntax();
exit(0); exit(0);
} }
else if (Fichier_existe(argv[Indice])) else if (File_exists(argv[index]))
{ {
Un_fichier_a_ete_passe_en_parametre=1; File_in_command_line=1;
// On récupère le chemin complet du paramètre // On récupère le chemin complet du paramètre
// Et on découpe ce chemin en répertoire(path) + fichier(.ext) // Et on découpe ce chemin en répertoire(path) + fichier(.ext)
#if defined(__WIN32__) #if defined(__WIN32__)
Buffer=_fullpath(NULL,argv[Indice],TAILLE_CHEMIN_FICHIER); buffer=_fullpath(NULL,argv[index],MAX_PATH_CHARACTERS);
#else #else
Buffer=realpath(argv[Indice],NULL); buffer=realpath(argv[index],NULL);
#endif #endif
Extraire_chemin(Principal_Repertoire_fichier, Buffer); Extract_path(Main_file_directory, buffer);
Extraire_nom_fichier(Principal_Nom_fichier, Buffer); Extract_filename(Main_filename, buffer);
free(Buffer); free(buffer);
chdir(Principal_Repertoire_fichier); chdir(Main_file_directory);
} }
else else
{ {
Erreur(ERREUR_LIGNE_COMMANDE); Error(ERROR_COMMAND_LINE);
Afficher_syntaxe(); Display_syntax();
exit(0); exit(0);
} }
} }
@ -289,92 +289,92 @@ void Analyse_de_la_ligne_de_commande(int argc,char * argv[])
// ------------------------ Initialiser le programme ------------------------- // ------------------------ Initialiser le programme -------------------------
// Returns 0 on fail // Returns 0 on fail
int Initialisation_du_programme(int argc,char * argv[]) int Init_program(int argc,char * argv[])
{ {
int Temp; int temp;
int Mode_dans_lequel_on_demarre; int starting_videomode;
char Repertoire_du_programme[TAILLE_CHEMIN_FICHIER]; char program_directory[MAX_PATH_CHARACTERS];
// On crée dès maintenant les descripteurs des listes de pages pour la page // On crée dès maintenant les descripteurs des listes de pages pour la page
// principale et la page de brouillon afin que leurs champs ne soient pas // principale et la page de brouillon afin que leurs champs ne soient pas
// invalide lors des appels aux multiples fonctions manipulées à // invalide lors des appels aux multiples fonctions manipulées à
// l'initialisation du programme. // l'initialisation du programme.
Principal_Backups=(S_Liste_de_pages *)malloc(sizeof(S_Liste_de_pages)); Main_backups=(T_List_of_pages *)malloc(sizeof(T_List_of_pages));
Brouillon_Backups=(S_Liste_de_pages *)malloc(sizeof(S_Liste_de_pages)); Spare_backups=(T_List_of_pages *)malloc(sizeof(T_List_of_pages));
Initialiser_S_Liste_de_pages(Principal_Backups); Init_list_of_pages(Main_backups);
Initialiser_S_Liste_de_pages(Brouillon_Backups); Init_list_of_pages(Spare_backups);
// Determine the executable directory // Determine the executable directory
Set_Program_Directory(argv[0],Repertoire_du_programme); Set_program_directory(argv[0],program_directory);
// Choose directory for data (read only) // Choose directory for data (read only)
Set_Data_Directory(Repertoire_du_programme,Repertoire_des_donnees); Set_data_directory(program_directory,Repertoire_des_donnees);
// Choose directory for settings (read/write) // Choose directory for settings (read/write)
Set_Config_Directory(Repertoire_du_programme,Repertoire_de_configuration); Set_config_directory(program_directory,Config_directory);
// On détermine le répertoire courant: // On détermine le répertoire courant:
getcwd(Principal_Repertoire_courant,256); getcwd(Main_current_directory,256);
// On en profite pour le mémoriser dans le répertoire principal: // On en profite pour le mémoriser dans le répertoire principal:
strcpy(Repertoire_initial,Principal_Repertoire_courant); strcpy(Initial_directory,Main_current_directory);
// On initialise les données sur le nom de fichier de l'image principale: // On initialise les données sur le nom de fichier de l'image principale:
strcpy(Principal_Repertoire_fichier,Principal_Repertoire_courant); strcpy(Main_file_directory,Main_current_directory);
strcpy(Principal_Nom_fichier,"NO_NAME.GIF"); strcpy(Main_filename,"NO_NAME.GIF");
Principal_Format_fichier=FORMAT_PAR_DEFAUT; Main_fileformat=DEFAULT_FILEFORMAT;
// On initialise les données sur le nom de fichier de l'image de brouillon: // On initialise les données sur le nom de fichier de l'image de brouillon:
strcpy(Brouillon_Repertoire_courant,Principal_Repertoire_courant); strcpy(Spare_current_directory,Main_current_directory);
strcpy(Brouillon_Repertoire_fichier,Principal_Repertoire_fichier); strcpy(Spare_file_directory,Main_file_directory);
strcpy(Brouillon_Nom_fichier ,Principal_Nom_fichier); strcpy(Spare_filename ,Main_filename);
Brouillon_Format_fichier =Principal_Format_fichier; Spare_fileformat =Main_fileformat;
strcpy(Brosse_Repertoire_courant,Principal_Repertoire_courant); strcpy(Brush_current_directory,Main_current_directory);
strcpy(Brosse_Repertoire_fichier,Principal_Repertoire_fichier); strcpy(Brush_file_directory,Main_file_directory);
strcpy(Brosse_Nom_fichier ,Principal_Nom_fichier); strcpy(Brush_filename ,Main_filename);
Brosse_Format_fichier =Principal_Format_fichier; Brush_fileformat =Main_fileformat;
// On initialise ce qu'il faut pour que les fileselects ne plantent pas: // On initialise ce qu'il faut pour que les fileselects ne plantent pas:
Liste_du_fileselect=NULL; // Au début, il n'y a pas de fichiers dans la liste Filelist=NULL; // Au début, il n'y a pas de fichiers dans la liste
Principal_File_list_Position=0; // Au début, le fileselect est en haut de la liste des fichiers Main_fileselector_position=0; // Au début, le fileselect est en haut de la liste des fichiers
Principal_File_list_Decalage=0; // Au début, le fileselect est en haut de la liste des fichiers Main_fileselector_offset=0; // Au début, le fileselect est en haut de la liste des fichiers
Principal_Format=0; Main_format=0;
Brouillon_File_list_Position=0; Spare_fileselector_position=0;
Brouillon_File_list_Decalage=0; Spare_fileselector_offset=0;
Brouillon_Format=0; Spare_format=0;
Brosse_File_list_Position=0; Brush_fileselector_position=0;
Brosse_File_list_Decalage=0; Brush_fileselector_offset=0;
Brosse_Format=0; Brush_format=0;
// On initialise les commentaires des images à des chaînes vides // On initialise les commentaires des images à des chaînes vides
Principal_Commentaire[0]='\0'; Main_comment[0]='\0';
Brouillon_Commentaire[0]='\0'; Spare_comment[0]='\0';
Brosse_Commentaire[0]='\0'; Brush_comment[0]='\0';
// On initialise d'ot' trucs // On initialise d'ot' trucs
Principal_Decalage_X=0; Main_offset_X=0;
Principal_Decalage_Y=0; Main_offset_Y=0;
Ancien_Principal_Decalage_X=0; Old_main_offset_X=0;
Ancien_Principal_Decalage_Y=0; Old_main_offset_Y=0;
Principal_Split=0; Main_separator_position=0;
Principal_X_Zoom=0; Main_X_zoom=0;
Principal_Proportion_split=PROPORTION_SPLIT; Main_separator_proportion=INITIAL_SEPARATOR_PROPORTION;
Loupe_Mode=0; Main_magnifier_mode=0;
Loupe_Facteur=FACTEUR_DE_ZOOM_PAR_DEFAUT; Main_magnifier_factor=DEFAULT_ZOOM_FACTOR;
Loupe_Hauteur=0; Main_magnifier_height=0;
Loupe_Largeur=0; Main_magnifier_width=0;
Loupe_Decalage_X=0; Main_magnifier_offset_X=0;
Loupe_Decalage_Y=0; Main_magnifier_offset_Y=0;
Brouillon_Decalage_X=0; Spare_offset_X=0;
Brouillon_Decalage_Y=0; Spare_offset_Y=0;
Ancien_Brouillon_Decalage_X=0; Old_spare_offset_X=0;
Ancien_Brouillon_Decalage_Y=0; Old_spare_offset_Y=0;
Brouillon_Split=0; Spare_separator_position=0;
Brouillon_X_Zoom=0; Spare_X_zoom=0;
Brouillon_Proportion_split=PROPORTION_SPLIT; Spare_separator_proportion=INITIAL_SEPARATOR_PROPORTION;
Brouillon_Loupe_Mode=0; Spare_magnifier_mode=0;
Brouillon_Loupe_Facteur=FACTEUR_DE_ZOOM_PAR_DEFAUT; Spare_magnifier_factor=DEFAULT_ZOOM_FACTOR;
Brouillon_Loupe_Hauteur=0; Spare_magnifier_height=0;
Brouillon_Loupe_Largeur=0; Spare_magnifier_width=0;
Brouillon_Loupe_Decalage_X=0; Spare_magnifier_offset_X=0;
Brouillon_Loupe_Decalage_Y=0; Spare_magnifier_offset_Y=0;
// SDL // SDL
if(SDL_Init(SDL_INIT_TIMER|SDL_INIT_VIDEO|SDL_INIT_JOYSTICK) < 0) if(SDL_Init(SDL_INIT_TIMER|SDL_INIT_VIDEO|SDL_INIT_JOYSTICK) < 0)
@ -383,267 +383,267 @@ int Initialisation_du_programme(int argc,char * argv[])
printf("Couldn't initialize SDL.\n"); printf("Couldn't initialize SDL.\n");
return(0); return(0);
} }
joystick = SDL_JoystickOpen(0); Joystick = SDL_JoystickOpen(0);
SDL_EnableKeyRepeat(250, 32); SDL_EnableKeyRepeat(250, 32);
SDL_EnableUNICODE(SDL_ENABLE); SDL_EnableUNICODE(SDL_ENABLE);
if(ALPHA_BETA[0]=='ß') if(ALPHA_BETA[0]=='ß')
SDL_WM_SetCaption("GrafX2 beta "POURCENTAGE_VERSION""" - USE AT YOUR OWN RISK","GrafX2"); SDL_WM_SetCaption("GrafX2 beta "PERCENTAGE_VERSION""" - USE AT YOUR OWN RISK","GrafX2");
else else
SDL_WM_SetCaption("GrafX2 v2.00 final","GrafX2"); SDL_WM_SetCaption("GrafX2 v2.00 final","GrafX2");
{ {
// Routine pour définir l'icone. // Routine pour définir l'icone.
char Chemin_icone[TAILLE_CHEMIN_FICHIER]; char icon_path[MAX_PATH_CHARACTERS];
SDL_Surface * Icone; SDL_Surface * icon;
sprintf(Chemin_icone, "%s%s", Repertoire_des_donnees, "gfx2.gif"); sprintf(icon_path, "%s%s", Repertoire_des_donnees, "gfx2.gif");
Icone = IMG_Load(Chemin_icone); icon = IMG_Load(icon_path);
if (Icone) if (icon)
{ {
byte *Masque_icone; byte *icon_mask;
int x,y; int x,y;
Masque_icone=malloc(128); icon_mask=malloc(128);
memset(Masque_icone,0,128); memset(icon_mask,0,128);
for (y=0;y<32;y++) for (y=0;y<32;y++)
for (x=0;x<32;x++) for (x=0;x<32;x++)
if (((byte *)(Icone->pixels))[(y*32+x)] != 255) if (((byte *)(icon->pixels))[(y*32+x)] != 255)
Masque_icone[(y*32+x)/8] |=0x80>>(x&7); icon_mask[(y*32+x)/8] |=0x80>>(x&7);
SDL_WM_SetIcon(Icone,Masque_icone); SDL_WM_SetIcon(icon,icon_mask);
free(Masque_icone); free(icon_mask);
SDL_FreeSurface(Icone); SDL_FreeSurface(icon);
} }
} }
// Texte // Texte
Initialisation_Texte(); Init_text();
// On initialise tous les modes vidéo // On initialise tous les modes vidéo
Definition_des_modes_video(); Set_all_video_modes();
Pixel_ratio=PIXEL_SIMPLE; Pixel_ratio=PIXEL_SIMPLE;
// On initialise les données sur l'état du programme: // On initialise les données sur l'état du programme:
// Donnée sur la sortie du programme: // Donnée sur la sortie du programme:
Quit_demande=0; Quit_is_required=0;
Sortir_du_programme=0; Quitting=0;
// Données sur l'état du menu: // Données sur l'état du menu:
Pixel_dans_menu=Pixel_dans_barre_d_outil; Pixel_in_menu=Pixel_in_toolbar;
Menu_visible=1; Menu_is_visible=1;
// Données sur les couleurs et la palette: // Données sur les couleurs et la palette:
Fore_color=15; Fore_color=15;
Back_color=0; Back_color=0;
Couleur_debut_palette=0; First_color_in_palette=0;
// Données sur le curseur: // Données sur le curseur:
Forme_curseur=FORME_CURSEUR_CIBLE; Cursor_shape=CURSOR_SHAPE_TARGET;
Cacher_curseur=0; Cursor_hidden=0;
// Données sur le pinceau: // Données sur le pinceau:
Pinceau_X=0; Paintbrush_X=0;
Pinceau_Y=0; Paintbrush_Y=0;
Pinceau_Forme=FORME_PINCEAU_ROND; Paintbrush_shape=PAINTBRUSH_SHAPE_ROUND;
Cacher_pinceau=0; Paintbrush_hidden=0;
Pixel_de_chargement=Pixel_Chargement_dans_ecran_courant; Pixel_load_function=Pixel_load_in_current_screen;
// On initialise tout ce qui concerne les opérations et les effets // On initialise tout ce qui concerne les opérations et les effets
Operation_Taille_pile=0; Operation_stack_size=0;
Mode_de_dessin_en_cours=OPERATION_DESSIN_CONTINU; Selected_operation=OPERATION_CONTINUOUS_DRAW;
Ligne_en_cours =OPERATION_LIGNE; Selected_line_mode =OPERATION_LINE;
Courbe_en_cours =OPERATION_COURBE_3_POINTS; Selected_curve_mode =OPERATION_3_POINTS_CURVE;
Fonction_effet=Aucun_effet; Effect_function=No_effect;
// On initialise les infos de la loupe: // On initialise les infos de la loupe:
Loupe_Mode=0; Main_magnifier_mode=0;
Loupe_Facteur=FACTEUR_DE_ZOOM_PAR_DEFAUT; Main_magnifier_factor=DEFAULT_ZOOM_FACTOR;
Initialiser_les_tables_de_multiplication(); Init_multiplication_tables();
Table_mul_facteur_zoom=TABLE_ZOOM[2]; Zoom_factor_table=Magnify_table[2];
Principal_Proportion_split=PROPORTION_SPLIT; Main_separator_proportion=INITIAL_SEPARATOR_PROPORTION;
Brouillon_Proportion_split=PROPORTION_SPLIT; Spare_separator_proportion=INITIAL_SEPARATOR_PROPORTION;
// On initialise les infos du mode smear: // On initialise les infos du mode smear:
Smear_Mode=0; Smear_mode=0;
Smear_Brosse_Largeur=LARGEUR_PINCEAU; Smear_brush_width=PAINTBRUSH_WIDTH;
Smear_Brosse_Hauteur=HAUTEUR_PINCEAU; Smear_brush_height=PAINTBRUSH_HEIGHT;
// On initialise les infos du mode smooth: // On initialise les infos du mode smooth:
Smooth_Mode=0; Smooth_mode=0;
// On initialise les infos du mode shade: // On initialise les infos du mode shade:
Shade_Mode=0; // Les autres infos du Shade sont chargées avec la config Shade_mode=0; // Les autres infos du Shade sont chargées avec la config
Quick_shade_Mode=0; // idem Quick_shade_mode=0; // idem
// On initialise les infos sur les dégradés: // On initialise les infos sur les dégradés:
Traiter_pixel_de_degrade =Afficher_pixel; // Les autres infos sont chargées avec la config Gradient_pixel =Display_pixel; // Les autres infos sont chargées avec la config
// On initialise les infos de la grille: // On initialise les infos de la grille:
Snap_Mode=0; Snap_mode=0;
Snap_Largeur=8; Snap_width=8;
Snap_Hauteur=8; Snap_height=8;
Snap_Decalage_X=0; Snap_offset_X=0;
Snap_Decalage_Y=0; Snap_offset_Y=0;
// On initialise les infos du mode Colorize: // On initialise les infos du mode Colorize:
Colorize_Mode=0; // Mode colorize inactif par défaut Colorize_mode=0; // Mode colorize inactif par défaut
Colorize_Opacite=50; // Une interpolation de 50% par défaut Colorize_opacity=50; // Une interpolation de 50% par défaut
Colorize_Mode_en_cours=0; // Par défaut, la méthode par interpolation Colorize_current_mode=0; // Par défaut, la méthode par interpolation
Calculer_les_tables_de_Colorize(); Compute_colorize_table();
// On initialise les infos du mode Tiling: // On initialise les infos du mode Tiling:
Tiling_Mode=0; // Pas besoin d'initialiser les décalages car ça se fait Tiling_mode=0; // Pas besoin d'initialiser les décalages car ça se fait
// en prenant une brosse (toujours mis à 0). // en prenant une brosse (toujours mis à 0).
// On initialise les infos du mode Mask: // On initialise les infos du mode Mask:
Mask_Mode=0; Mask_mode=0;
// Infos du Spray // Infos du Spray
Spray_Mode=1; // Mode Mono Airbrush_mode=1; // Mode Mono
Spray_Size=31; Airbrush_size=31;
Spray_Delay=1; Airbrush_delay=1;
Spray_Mono_flow=10; Airbrush_mono_flow=10;
memset(Spray_Multi_flow,0,256); memset(Airbrush_multi_flow,0,256);
srand(time(NULL)); // On randomize un peu tout ça... srand(time(NULL)); // On randomize un peu tout ça...
// Initialisation des boutons // Initialisation des boutons
Initialisation_des_boutons(); Init_buttons();
// Initialisation des opérations // Initialisation des opérations
Initialisation_des_operations(); Init_operations();
Fenetre=0; Window=0;
// Charger les sprites et la palette // Charger les sprites et la palette
Charger_DAT(); Load_DAT();
// Charger la configuration des touches // Charger la configuration des touches
Config_par_defaut(); Set_config_defaults();
switch(Charger_CFG(1)) switch(Load_CFG(1))
{ {
case ERREUR_CFG_ABSENT: case ERROR_CFG_MISSING:
// Pas un problème, on a les valeurs par défaut. // Pas un problème, on a les valeurs par défaut.
break; break;
case ERREUR_CFG_CORROMPU: case ERROR_CFG_CORRUPTED:
DEBUG("Corrupted CFG file.",0); DEBUG("Corrupted CFG file.",0);
break; break;
case ERREUR_CFG_ANCIEN: case ERROR_CFG_OLD:
DEBUG("Unknown CFG file version, not loaded.",0); DEBUG("Unknown CFG file version, not loaded.",0);
break; break;
} }
// Charger la configuration du .INI // Charger la configuration du .INI
Temp=Charger_INI(&Config); temp=Load_INI(&Config);
if (Temp) if (temp)
Erreur(Temp); Error(temp);
// Transfert des valeurs du .INI qui ne changent pas dans des variables // Transfert des valeurs du .INI qui ne changent pas dans des variables
// plus accessibles: // plus accessibles:
Palette_defaut[CM_Noir] =Coul_menu_pref[0]=Config.Coul_menu_pref[0]; Default_palette[MC_Black] =Fav_menu_colors[0]=Config.Fav_menu_colors[0];
Palette_defaut[CM_Fonce]=Coul_menu_pref[1]=Config.Coul_menu_pref[1]; Default_palette[MC_Dark]=Fav_menu_colors[1]=Config.Fav_menu_colors[1];
Palette_defaut[CM_Clair]=Coul_menu_pref[2]=Config.Coul_menu_pref[2]; Default_palette[MC_Light]=Fav_menu_colors[2]=Config.Fav_menu_colors[2];
Palette_defaut[CM_Blanc]=Coul_menu_pref[3]=Config.Coul_menu_pref[3]; Default_palette[MC_White]=Fav_menu_colors[3]=Config.Fav_menu_colors[3];
memcpy(Principal_Palette,Palette_defaut,sizeof(T_Palette)); memcpy(Main_palette,Default_palette,sizeof(T_Palette));
Calculer_couleurs_menu_optimales(Palette_defaut); Compute_optimal_menu_colors(Default_palette);
// Infos sur les trames (Sieve) // Infos sur les trames (Sieve)
Trame_Mode=0; Sieve_mode=0;
Copier_trame_predefinie(0); Copy_preset_sieve(0);
// On sélectionne toutes les couleurs pour le masque de copie de couleurs vers le brouillon // On sélectionne toutes les couleurs pour le masque de copie de couleurs vers le brouillon
memset(Masque_copie_couleurs,1,256); memset(Mask_color_to_copy,1,256);
// Prise en compte de la fonte // Prise en compte de la fonte
if (Config.Fonte) if (Config.Font)
Fonte=Fonte_fun; Font=GFX_fun_font;
else else
Fonte=Fonte_systeme; Font=GFX_system_font;
// Allocation de mémoire pour la brosse // Allocation de mémoire pour la brosse
if (!(Brosse =(byte *)malloc( 1* 1))) Erreur(ERREUR_MEMOIRE); if (!(Brush =(byte *)malloc( 1* 1))) Error(ERROR_MEMORY);
if (!(Smear_Brosse =(byte *)malloc(TAILLE_MAXI_PINCEAU*TAILLE_MAXI_PINCEAU))) Erreur(ERREUR_MEMOIRE); if (!(Smear_brush =(byte *)malloc(MAX_PAINTBRUSH_SIZE*MAX_PAINTBRUSH_SIZE))) Error(ERROR_MEMORY);
// Pinceau // Pinceau
if (!(Pinceau_Sprite=(byte *)malloc(TAILLE_MAXI_PINCEAU*TAILLE_MAXI_PINCEAU))) Erreur(ERREUR_MEMOIRE); if (!(Paintbrush_sprite=(byte *)malloc(MAX_PAINTBRUSH_SIZE*MAX_PAINTBRUSH_SIZE))) Error(ERROR_MEMORY);
*Pinceau_Sprite=1; *Paintbrush_sprite=1;
Pinceau_Largeur=1; Paintbrush_width=1;
Pinceau_Hauteur=1; Paintbrush_height=1;
Analyse_de_la_ligne_de_commande(argc,argv); Analyze_command_line(argc,argv);
Mode_dans_lequel_on_demarre=Resolution_actuelle; starting_videomode=Current_resolution;
Buffer_de_ligne_horizontale=NULL; Horizontal_line_buffer=NULL;
Resolution_actuelle=-1; // On n'était pas dans un mode graphique Current_resolution=-1; // On n'était pas dans un mode graphique
Initialiser_mode_video( Init_mode_video(
Mode_video[Mode_dans_lequel_on_demarre].Width, Video_mode[starting_videomode].Width,
Mode_video[Mode_dans_lequel_on_demarre].Height, Video_mode[starting_videomode].Height,
Mode_video[Mode_dans_lequel_on_demarre].Fullscreen); Video_mode[starting_videomode].Fullscreen);
Principal_Largeur_image=Largeur_ecran/Pixel_width; Main_image_width=Screen_width/Pixel_width;
Principal_Hauteur_image=Hauteur_ecran/Pixel_height; Main_image_height=Screen_height/Pixel_height;
Brouillon_Largeur_image=Largeur_ecran/Pixel_width; Spare_image_width=Screen_width/Pixel_width;
Brouillon_Hauteur_image=Hauteur_ecran/Pixel_height; Spare_image_height=Screen_height/Pixel_height;
// Allocation de mémoire pour les différents écrans virtuels (et brosse) // Allocation de mémoire pour les différents écrans virtuels (et brosse)
if (Initialiser_les_listes_de_backups_en_debut_de_programme(Config.Nb_pages_Undo+1,Largeur_ecran,Hauteur_ecran)==0) if (Init_all_backup_lists(Config.Max_undo_pages+1,Screen_width,Screen_height)==0)
Erreur(ERREUR_MEMOIRE); Error(ERROR_MEMORY);
// On remet le nom par défaut pour la page de brouillon car il été modifié // On remet le nom par défaut pour la page de brouillon car il été modifié
// par le passage d'un fichier en paramètre lors du traitement précédent. // par le passage d'un fichier en paramètre lors du traitement précédent.
// Note: le fait que l'on ne modifie que les variables globales // Note: le fait que l'on ne modifie que les variables globales
// Brouillon_* et pas les infos contenues dans la page de brouillon // Brouillon_* et pas les infos contenues dans la page de brouillon
// elle-même ne m'inspire pas confiance mais ça a l'air de marcher sans // elle-même ne m'inspire pas confiance mais ça a l'air de marcher sans
// poser de problèmes, alors... // poser de problèmes, alors...
if (Un_fichier_a_ete_passe_en_parametre) if (File_in_command_line)
{ {
strcpy(Brouillon_Repertoire_fichier,Brouillon_Repertoire_courant); strcpy(Spare_file_directory,Spare_current_directory);
strcpy(Brouillon_Nom_fichier,"NO_NAME.GIF"); strcpy(Spare_filename,"NO_NAME.GIF");
Brouillon_Format_fichier=FORMAT_PAR_DEFAUT; Spare_fileformat=DEFAULT_FILEFORMAT;
} }
// Nettoyage de l'écran virtuel (les autres recevront celui-ci par copie) // Nettoyage de l'écran virtuel (les autres recevront celui-ci par copie)
memset(Principal_Ecran,0,Principal_Largeur_image*Principal_Hauteur_image); memset(Main_screen,0,Main_image_width*Main_image_height);
// Initialisation de diverses variables par calcul: // Initialisation de diverses variables par calcul:
Calculer_donnees_loupe(); Compute_magnifier_data();
Calculer_limites(); Compute_limits();
Calculer_coordonnees_pinceau(); Compute_paintbrush_coordinates();
// On affiche le menu: // On affiche le menu:
Afficher_menu(); Display_menu();
Afficher_pinceau_dans_menu(); Display_paintbrush_in_menu();
// On affiche le curseur pour débutter correctement l'état du programme: // On affiche le curseur pour débutter correctement l'état du programme:
Afficher_curseur(); Display_cursor();
Brouillon_Image_modifiee=0; Spare_image_is_modified=0;
Principal_Image_modifiee=0; Main_image_is_modified=0;
// Gestionnaire de signaux, quand il ne reste plus aucun espoir // Gestionnaire de signaux, quand il ne reste plus aucun espoir
Initialiser_sighandler(); Init_sighandler();
// Le programme débute en mode de dessin à la main // Le programme débute en mode de dessin à la main
Enclencher_bouton(BOUTON_DESSIN,A_GAUCHE); Unselect_button(BUTTON_DRAW,LEFT_SIDE);
// On initialise la brosse initiale à 1 pixel blanc: // On initialise la brosse initiale à 1 pixel blanc:
Brosse_Largeur=1; Brush_width=1;
Brosse_Hauteur=1; Brush_height=1;
Capturer_brosse(0,0,0,0,0); Capture_brush(0,0,0,0,0);
*Brosse=CM_Blanc; *Brush=MC_White;
return(1); return(1);
} }
// ------------------------- Fermeture du programme -------------------------- // ------------------------- Fermeture du programme --------------------------
void Fermeture_du_programme(void) void Program_shutdown(void)
{ {
int return_code; int return_code;
// On libère le buffer de gestion de lignes // On libère le buffer de gestion de lignes
free(Buffer_de_ligne_horizontale); free(Horizontal_line_buffer);
// On libère le pinceau spécial // On libère le pinceau spécial
free(Pinceau_Sprite); free(Paintbrush_sprite);
// On libère les différents écrans virtuels et brosse: // On libère les différents écrans virtuels et brosse:
free(Brosse); free(Brush);
Nouveau_nombre_de_backups(0); Set_number_of_backups(0);
free(Brouillon_Ecran); free(Spare_screen);
free(Principal_Ecran); free(Main_screen);
// On prend bien soin de passer dans le répertoire initial: // On prend bien soin de passer dans le répertoire initial:
if (chdir(Repertoire_initial)!=-1) if (chdir(Initial_directory)!=-1)
{ {
// On sauvegarde les données dans le .CFG et dans le .INI // On sauvegarde les données dans le .CFG et dans le .INI
if (Config.Auto_save) if (Config.Auto_save)
{ {
return_code=Sauver_CFG(); return_code=Save_CFG();
if (return_code) if (return_code)
Erreur(return_code); Error(return_code);
return_code=Sauver_INI(&Config); return_code=Save_INI(&Config);
if (return_code) if (return_code)
Erreur(return_code); Error(return_code);
} }
} }
else else
Erreur(ERREUR_REPERTOIRE_DISPARU); Error(ERROR_MISSING_DIRECTORY);
SDL_Quit(); SDL_Quit();
} }
@ -652,65 +652,65 @@ void Fermeture_du_programme(void)
// -------------------------- Procédure principale --------------------------- // -------------------------- Procédure principale ---------------------------
int main(int argc,char * argv[]) int main(int argc,char * argv[])
{ {
int PhoenixTrouve=0; int phoenix_found=0;
int Phoenix2Trouve=0; int phoenix2_found=0;
char Nom_du_fichier_Phoenix[TAILLE_CHEMIN_FICHIER]; char phoenix_filename1[MAX_PATH_CHARACTERS];
char Nom_du_fichier_Phoenix2[TAILLE_CHEMIN_FICHIER]; char phoenix_filename2[MAX_PATH_CHARACTERS];
if(!Initialisation_du_programme(argc,argv)) if(!Init_program(argc,argv))
{ {
return 0; return 0;
} }
// Test de recuperation de fichiers sauvés // Test de recuperation de fichiers sauvés
strcpy(Nom_du_fichier_Phoenix,Repertoire_de_configuration); strcpy(phoenix_filename1,Config_directory);
strcat(Nom_du_fichier_Phoenix,"phoenix.img"); strcat(phoenix_filename1,"phoenix.img");
strcpy(Nom_du_fichier_Phoenix2,Repertoire_de_configuration); strcpy(phoenix_filename2,Config_directory);
strcat(Nom_du_fichier_Phoenix2,"phoenix2.img"); strcat(phoenix_filename2,"phoenix2.img");
if (Fichier_existe(Nom_du_fichier_Phoenix)) if (File_exists(phoenix_filename1))
PhoenixTrouve=1; phoenix_found=1;
if (Fichier_existe(Nom_du_fichier_Phoenix2)) if (File_exists(phoenix_filename2))
Phoenix2Trouve=1; phoenix2_found=1;
if (PhoenixTrouve || Phoenix2Trouve) if (phoenix_found || phoenix2_found)
{ {
if (Phoenix2Trouve) if (phoenix2_found)
{ {
strcpy(Principal_Repertoire_fichier,Repertoire_de_configuration); strcpy(Main_file_directory,Config_directory);
strcpy(Principal_Nom_fichier,"phoenix2.img"); strcpy(Main_filename,"phoenix2.img");
chdir(Principal_Repertoire_fichier); chdir(Main_file_directory);
Bouton_Reload(); Button_Reload();
Principal_Image_modifiee=1; Main_image_is_modified=1;
Warning_message("Spare page recovered"); Warning_message("Spare page recovered");
// I don't really like this, but... // I don't really like this, but...
remove(Nom_du_fichier_Phoenix2); remove(phoenix_filename2);
Bouton_Page(); Button_Page();
} }
if (PhoenixTrouve) if (phoenix_found)
{ {
strcpy(Principal_Repertoire_fichier,Repertoire_de_configuration); strcpy(Main_file_directory,Config_directory);
strcpy(Principal_Nom_fichier,"phoenix.img"); strcpy(Main_filename,"phoenix.img");
chdir(Principal_Repertoire_fichier); chdir(Main_file_directory);
Bouton_Reload(); Button_Reload();
Principal_Image_modifiee=1; Main_image_is_modified=1;
Warning_message("Main page recovered"); Warning_message("Main page recovered");
// I don't really like this, but... // I don't really like this, but...
remove(Nom_du_fichier_Phoenix); remove(phoenix_filename1);
} }
} }
else else
{ {
if (Config.Opening_message && (!Un_fichier_a_ete_passe_en_parametre)) if (Config.Opening_message && (!File_in_command_line))
Bouton_Message_initial(); Button_Message_initial();
free(Logo_GrafX2); // Pas encore utilisé dans le About free(GFX_logo_grafx2); // Pas encore utilisé dans le About
if (Un_fichier_a_ete_passe_en_parametre) if (File_in_command_line)
{ {
Bouton_Reload(); Button_Reload();
Une_resolution_a_ete_passee_en_parametre=0; Resolution_in_command_line=0;
} }
} }
Gestion_principale(); Main_handler();
Fermeture_du_programme(); Program_shutdown();
return 0; return 0;
} }

2594
moteur.c

File diff suppressed because it is too large Load Diff

View File

@ -19,61 +19,61 @@
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
void Gestion_principale (void); void Main_handler (void);
void Tracer_cadre_de_bouton_du_menu(byte btn_number,byte pressed); void Draw_menu_button_frame(byte btn_number,byte pressed);
void Desenclencher_bouton (int btn_number); void Unselect_bouton (int btn_number);
void Enclencher_bouton (int btn_number,byte click); void Unselect_button (int btn_number,byte click);
void Annuler_les_effets (void); void Cancel_effects (void);
void Restaurer_les_effets (void); void Restore_effects (void);
void Ouvrir_fenetre (word width,word height, char * title); void Open_window (word width,word height, char * title);
void Fermer_fenetre (void); void Close_window (void);
void Ouvrir_popup (word x_pos, word y_pos, word width, word height); void Open_popup (word x_pos, word y_pos, word width, word height);
void Fermer_popup (void); void Close_popup (void);
void Fenetre_Dessiner_bouton_normal(word x_pos,word y_pos,word width,word height, void Window_draw_normal_bouton(word x_pos,word y_pos,word width,word height,
char * title,byte Lettre_soulignee,byte clickable); char * title,byte undersc_letter,byte clickable);
void Fenetre_Enfoncer_bouton_normal(word x_pos,word y_pos,word width,word height); void Window_select_normal_button(word x_pos,word y_pos,word width,word height);
void Fenetre_Desenfoncer_bouton_normal(word x_pos,word y_pos,word width,word height); void Window_unselect_normal_button(word x_pos,word y_pos,word width,word height);
void Fenetre_Dessiner_bouton_palette(word x_pos,word y_pos); void Window_draw_palette_bouton(word x_pos,word y_pos);
void Calculer_hauteur_curseur_jauge(T_Bouton_scroller * button); void Compute_slider_cursor_height(T_Scroller_button * button);
void Fenetre_Dessiner_jauge(T_Bouton_scroller * button); void Window_draw_slider(T_Scroller_button * button);
void Fenetre_Dessiner_bouton_scroller(T_Bouton_scroller * button); void Window_draw_scroller_bouton(T_Scroller_button * button);
void Fenetre_Contenu_bouton_saisie(T_Bouton_special * button, char * content); void Window_input_content(T_Special_button * button, char * content);
void Fenetre_Effacer_bouton_saisie(T_Bouton_special * button); void Window_clear_input_button(T_Special_button * button);
void Fenetre_Dessiner_bouton_saisie(word x_pos,word y_pos,word Largeur_en_caracteres); void Window_draw_input_bouton(word x_pos,word y_pos,word width_in_characters);
T_Bouton_normal * Fenetre_Definir_bouton_normal(word x_pos, word y_pos, T_Normal_button * Window_set_normal_button(word x_pos, word y_pos,
word width, word height, word width, word height,
char * title,byte Lettre_soulignee, char * title,byte undersc_letter,
byte clickable, word shortcut); byte clickable, word shortcut);
T_Bouton_normal * Fenetre_Definir_bouton_repetable(word x_pos, word y_pos, T_Normal_button * Window_set_repeatable_button(word x_pos, word y_pos,
word width, word height, word width, word height,
char * title,byte Lettre_soulignee, char * title,byte undersc_letter,
byte clickable, word shortcut); byte clickable, word shortcut);
T_Bouton_palette * Fenetre_Definir_bouton_palette(word x_pos, word y_pos); T_Palette_button * Window_set_palette_button(word x_pos, word y_pos);
void Fenetre_Effacer_tags(void); void Window_clear_tags(void);
void Tagger_intervalle_palette(byte start,byte end); void Tag_color_range(byte start,byte end);
T_Bouton_scroller * Fenetre_Definir_bouton_scroller(word x_pos, word y_pos, T_Scroller_button * Window_set_scroller_button(word x_pos, word y_pos,
word height, word height,
word nb_elements, word nb_elements,
word nb_elements_visible, word nb_elements_visible,
word Position_initiale); word initial_position);
T_Bouton_special * Fenetre_Definir_bouton_special(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_Bouton_special * Fenetre_Definir_bouton_saisie(word x_pos,word y_pos,word Largeur_en_caracteres); T_Special_button * Window_set_input_button(word x_pos,word y_pos,word width_in_characters);
T_Bouton_dropdown * Fenetre_Definir_bouton_dropdown(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,char *label,byte display_choice,byte display_centered,byte display_arrow,byte active_button);
void Fenetre_Dropdown_choix(T_Bouton_dropdown * dropdown, word btn_number, const char *label); void Window_dropdown_add_item(T_Dropdown_button * dropdown, word btn_number, const char *label);
void Fenetre_Dropdown_vider_choix(T_Bouton_dropdown * dropdown); void Window_dropdown_clear_items(T_Dropdown_button * dropdown);
byte Fenetre_click_dans_zone(short Debut_X,short Debut_Y,short Fin_X,short Fin_Y); byte Window_click_in_rectangle(short start_x,short start_y,short end_x,short end_y);
short Attendre_click_dans_palette(T_Bouton_palette * button); short Wait_click_in_palette(T_Palette_button * button);
void Recuperer_couleur_derriere_fenetre(byte * Couleur, byte * click); void Get_color_behind_window(byte * color, byte * click);
short Fenetre_Bouton_clicke(void); short Window_clicked_button(void);
int Numero_bouton_sous_souris(void); int Button_under_mouse(void);
short Fenetre_Numero_bouton_clicke(void); short Window_get_clicked_button(void);
void Remappe_fond_fenetres(byte * Table_de_conversion, int Min_Y, int Max_Y); void Remap_window_backgrounds(byte * conversion_table, int Min_Y, int Max_Y);
void Pixel_fond(int x_pos, int y_pos, byte Couleur); void Pixel_background(int x_pos, int y_pos, byte color);

402
op_c.c
View File

@ -29,7 +29,7 @@
#include "op_c.h" #include "op_c.h"
#include "erreurs.h" #include "erreurs.h"
void RGBtoHSL(int r,int g,int b,byte * hr,byte * sr,byte* lr) void RGB_to_HSL(int r,int g,int b,byte * hr,byte * sr,byte* lr)
{ {
double rd,gd,bd,h,s,l,max,min; double rd,gd,bd,h,s,l,max,min;
@ -98,7 +98,7 @@ void RGBtoHSL(int r,int g,int b,byte * hr,byte * sr,byte* lr)
*sr = (s*255.0); *sr = (s*255.0);
} }
void HSLtoRGB(byte h,byte s,byte l, byte* r, byte* g, byte* b) void HSL_to_RGB(byte h,byte s,byte l, byte* r, byte* g, byte* b)
{ {
float rf =0 ,gf = 0,bf = 0; float rf =0 ,gf = 0,bf = 0;
float hf,lf,sf; float hf,lf,sf;
@ -167,12 +167,12 @@ void HSLtoRGB(byte h,byte s,byte l, byte* r, byte* g, byte* b)
///////////////////////////// Méthodes de gestion des tables de conversion // ///////////////////////////// Méthodes de gestion des tables de conversion //
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
Table_conversion * TC_New(int nbb_r,int nbb_g,int nbb_b) T_Conversion_table * CT_new(int nbb_r,int nbb_g,int nbb_b)
{ {
Table_conversion * n; T_Conversion_table * n;
int size; int size;
n=(Table_conversion *)malloc(sizeof(Table_conversion)); n=(T_Conversion_table *)malloc(sizeof(T_Conversion_table));
if (n!=NULL) if (n!=NULL)
{ {
// On recopie les paramŠtres demands // On recopie les paramŠtres demands
@ -182,17 +182,17 @@ Table_conversion * TC_New(int nbb_r,int nbb_g,int nbb_b)
// On calcule les autres // On calcule les autres
n->rng_r=(1<<nbb_r); n->rng_r=(1<<nbb_r);
n->rng_v=(1<<nbb_g); n->rng_g=(1<<nbb_g);
n->rng_b=(1<<nbb_b); n->rng_b=(1<<nbb_b);
n->dec_r=nbb_g+nbb_b; n->dec_r=nbb_g+nbb_b;
n->dec_v=nbb_b; n->dec_g=nbb_b;
n->dec_b=0; n->dec_b=0;
n->red_r=8-nbb_r; n->red_r=8-nbb_r;
n->red_v=8-nbb_g; n->red_g=8-nbb_g;
n->red_b=8-nbb_b; n->red_b=8-nbb_b;
// On tente d'allouer la table // On tente d'allouer la table
size=(n->rng_r)*(n->rng_v)*(n->rng_b); size=(n->rng_r)*(n->rng_g)*(n->rng_b);
n->table=(byte *)malloc(size); n->table=(byte *)malloc(size);
if (n->table!=NULL) if (n->table!=NULL)
// C'est bon! // C'est bon!
@ -208,32 +208,32 @@ Table_conversion * TC_New(int nbb_r,int nbb_g,int nbb_b)
return n; return n;
} }
void TC_Delete(Table_conversion * t) void CT_delete(T_Conversion_table * t)
{ {
free(t->table); free(t->table);
free(t); free(t);
} }
byte TC_Get(Table_conversion * t,int r,int g,int b) byte CT_get(T_Conversion_table * t,int r,int g,int b)
{ {
int index; int index;
// On réduit le nombre de bits par couleur // On réduit le nombre de bits par couleur
r=(r>>t->red_r); r=(r>>t->red_r);
g=(g>>t->red_v); g=(g>>t->red_g);
b=(b>>t->red_b); b=(b>>t->red_b);
// On recherche la couleur la plus proche dans la table de conversion // On recherche la couleur la plus proche dans la table de conversion
index=(r<<t->dec_r) | (g<<t->dec_v) | (b<<t->dec_b); index=(r<<t->dec_r) | (g<<t->dec_g) | (b<<t->dec_b);
return t->table[index]; return t->table[index];
} }
void TC_Set(Table_conversion * t,int r,int g,int b,byte i) void CT_set(T_Conversion_table * t,int r,int g,int b,byte i)
{ {
int index; int index;
index=(r<<t->dec_r) | (g<<t->dec_v) | (b<<t->dec_b); index=(r<<t->dec_r) | (g<<t->dec_g) | (b<<t->dec_b);
t->table[index]=i; t->table[index]=i;
} }
@ -243,20 +243,20 @@ void TC_Set(Table_conversion * t,int r,int g,int b,byte i)
/////////////////////////////// Mthodes de gestion des tables d'occurence // /////////////////////////////// Mthodes de gestion des tables d'occurence //
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
void TO_Init(Table_occurence * t) void OT_init(T_Occurrence_table * t)
{ {
int size; int size;
size=(t->rng_r)*(t->rng_v)*(t->rng_b)*sizeof(int); size=(t->rng_r)*(t->rng_g)*(t->rng_b)*sizeof(int);
memset(t->table,0,size); // On initialise … 0 memset(t->table,0,size); // On initialise … 0
} }
Table_occurence * TO_New(int nbb_r,int nbb_g,int nbb_b) T_Occurrence_table * OT_new(int nbb_r,int nbb_g,int nbb_b)
{ {
Table_occurence * n; T_Occurrence_table * n;
int size; int size;
n=(Table_occurence *)malloc(sizeof(Table_occurence)); n=(T_Occurrence_table *)malloc(sizeof(T_Occurrence_table));
if (n!=0) if (n!=0)
{ {
// On recopie les paramŠtres demands // On recopie les paramŠtres demands
@ -266,21 +266,21 @@ Table_occurence * TO_New(int nbb_r,int nbb_g,int nbb_b)
// On calcule les autres // On calcule les autres
n->rng_r=(1<<nbb_r); n->rng_r=(1<<nbb_r);
n->rng_v=(1<<nbb_g); n->rng_g=(1<<nbb_g);
n->rng_b=(1<<nbb_b); n->rng_b=(1<<nbb_b);
n->dec_r=nbb_g+nbb_b; n->dec_r=nbb_g+nbb_b;
n->dec_v=nbb_b; n->dec_g=nbb_b;
n->dec_b=0; n->dec_b=0;
n->red_r=8-nbb_r; n->red_r=8-nbb_r;
n->red_v=8-nbb_g; n->red_g=8-nbb_g;
n->red_b=8-nbb_b; n->red_b=8-nbb_b;
// On tente d'allouer la table // On tente d'allouer la table
size=(n->rng_r)*(n->rng_v)*(n->rng_b)*sizeof(int); size=(n->rng_r)*(n->rng_g)*(n->rng_b)*sizeof(int);
n->table=(int *)malloc(size); n->table=(int *)malloc(size);
if (n->table!=0) if (n->table!=0)
// C'est bon! On initialise … 0 // C'est bon! On initialise … 0
TO_Init(n); OT_init(n);
else else
{ {
// Table impossible … allouer // Table impossible … allouer
@ -292,59 +292,59 @@ Table_occurence * TO_New(int nbb_r,int nbb_g,int nbb_b)
return n; return n;
} }
void TO_Delete(Table_occurence * t) void OT_delete(T_Occurrence_table * t)
{ {
free(t->table); free(t->table);
free(t); free(t);
} }
int TO_Get(Table_occurence * t,int r,int g,int b) int OT_get(T_Occurrence_table * t,int r,int g,int b)
{ {
int index; int index;
index=(r<<t->dec_r) | (g<<t->dec_v) | (b<<t->dec_b); index=(r<<t->dec_r) | (g<<t->dec_g) | (b<<t->dec_b);
return t->table[index]; return t->table[index];
} }
void TO_Set(Table_occurence * t,int r,int g,int b,int i) void OT_set(T_Occurrence_table * t,int r,int g,int b,int i)
{ {
int index; int index;
r=(r>>t->red_r); r=(r>>t->red_r);
g=(g>>t->red_v); g=(g>>t->red_g);
b=(b>>t->red_b); b=(b>>t->red_b);
index=(r<<t->dec_r) | (g<<t->dec_v) | (b<<t->dec_b); index=(r<<t->dec_r) | (g<<t->dec_g) | (b<<t->dec_b);
t->table[index]=i; t->table[index]=i;
} }
void TO_Inc(Table_occurence * t,int r,int g,int b) void OT_inc(T_Occurrence_table * t,int r,int g,int b)
{ {
int index; int index;
r=(r>>t->red_r); r=(r>>t->red_r);
g=(g>>t->red_v); g=(g>>t->red_g);
b=(b>>t->red_b); b=(b>>t->red_b);
index=(r<<t->dec_r) | (g<<t->dec_v) | (b<<t->dec_b); index=(r<<t->dec_r) | (g<<t->dec_g) | (b<<t->dec_b);
t->table[index]++; t->table[index]++;
} }
void TO_Compter_occurences(Table_occurence * t,Bitmap24B image,int size) void OT_count_occurrences(T_Occurrence_table * t,T_Bitmap24B image,int size)
{ {
Bitmap24B ptr; T_Bitmap24B ptr;
int index; int index;
for (index=size,ptr=image;index>0;index--,ptr++) for (index=size,ptr=image;index>0;index--,ptr++)
TO_Inc(t,ptr->R,ptr->G,ptr->B); OT_inc(t,ptr->R,ptr->G,ptr->B);
} }
int TO_Compter_couleurs(Table_occurence * t) int OT_count_colors(T_Occurrence_table * t)
{ {
int val; // Valeur de retour int val; // Valeur de retour
int nb; // Nombre de couleurs … tester int nb; // Nombre de couleurs … tester
int i; // Compteur de couleurs testes int i; // Compteur de couleurs testes
val=0; val=0;
nb=(t->rng_r)*(t->rng_v)*(t->rng_b); nb=(t->rng_r)*(t->rng_g)*(t->rng_b);
for (i=0;i<nb;i++) for (i=0;i<nb;i++)
if (t->table[i]>0) if (t->table[i]>0)
val++; val++;
@ -358,7 +358,7 @@ int TO_Compter_couleurs(Table_occurence * t)
///////////////////////////////////////// Mthodes de gestion des clusters // ///////////////////////////////////////// Mthodes de gestion des clusters //
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
void Cluster_Analyser(Cluster * c,Table_occurence * to) void Cluster_analyser(T_Cluster * c,T_Occurrence_table * to)
{ {
int rmin,rmax,vmin,vmax,bmin,bmax; int rmin,rmax,vmin,vmax,bmin,bmax;
int r,g,b; int r,g,b;
@ -367,7 +367,7 @@ void Cluster_Analyser(Cluster * c,Table_occurence * to)
// int nbocc; // int nbocc;
// On prédécale tout pour éviter de faire trop de bazar en se forçant à utiliser TO_Get, plus rapide // On prédécale tout pour éviter de faire trop de bazar en se forçant à utiliser OT_get, plus rapide
rmin=c->rmax <<16; rmax=c->rmin << 16; rmin=c->rmax <<16; rmax=c->rmin << 16;
vmin=c->vmax << 8; vmax=c->vmin << 8; vmin=c->vmax << 8; vmax=c->vmin << 8;
bmin=c->bmax; bmax=c->bmin; bmin=c->bmax; bmax=c->bmin;
@ -377,7 +377,7 @@ void Cluster_Analyser(Cluster * c,Table_occurence * to)
for (g=c->vmin<<8;g<=c->vmax<<8;g+=1<<8) for (g=c->vmin<<8;g<=c->vmax<<8;g+=1<<8)
for (b=c->bmin;b<=c->bmax;b++) for (b=c->bmin;b<=c->bmax;b++)
{ {
nbocc=to->table[r + g + b]; // TO_Get nbocc=to->table[r + g + b]; // OT_get
if (nbocc) if (nbocc)
{ {
if (r<rmin) rmin=r; if (r<rmin) rmin=r;
@ -399,7 +399,7 @@ void Cluster_Analyser(Cluster * c,Table_occurence * to)
for(g=c->vmin<<8;g<=c->vmax<<8;g+=1<<8) for(g=c->vmin<<8;g<=c->vmax<<8;g+=1<<8)
for(b=c->bmin;b<=c->bmax;b++) for(b=c->bmin;b<=c->bmax;b++)
{ {
if(to->table[r + g + b]) // TO_Get if(to->table[r + g + b]) // OT_get
{ {
rmin=r; rmin=r;
goto RMAX; goto RMAX;
@ -410,7 +410,7 @@ RMAX:
for(g=c->vmin<<8;g<=c->vmax<<8;g+=1<<8) for(g=c->vmin<<8;g<=c->vmax<<8;g+=1<<8)
for(b=c->bmin;b<=c->bmax;b++) for(b=c->bmin;b<=c->bmax;b++)
{ {
if(to->table[r + g + b]) // TO_Get if(to->table[r + g + b]) // OT_get
{ {
rmax=r; rmax=r;
goto VMIN; goto VMIN;
@ -421,7 +421,7 @@ VMIN:
for(r=rmin;r<=rmax;r+=1<<16) for(r=rmin;r<=rmax;r+=1<<16)
for(b=c->bmin;b<=c->bmax;b++) for(b=c->bmin;b<=c->bmax;b++)
{ {
if(to->table[r + g + b]) // TO_Get if(to->table[r + g + b]) // OT_get
{ {
vmin=g; vmin=g;
goto VMAX; goto VMAX;
@ -432,7 +432,7 @@ VMAX:
for(r=rmin;r<=rmax;r+=1<<16) for(r=rmin;r<=rmax;r+=1<<16)
for(b=c->bmin;b<=c->bmax;b++) for(b=c->bmin;b<=c->bmax;b++)
{ {
if(to->table[r + g + b]) // TO_Get if(to->table[r + g + b]) // OT_get
{ {
vmax=g; vmax=g;
goto BMIN; goto BMIN;
@ -443,7 +443,7 @@ BMIN:
for(r=rmin;r<=rmax;r+=1<<16) for(r=rmin;r<=rmax;r+=1<<16)
for(g=vmin;g<=vmax;g+=1<<8) for(g=vmin;g<=vmax;g+=1<<8)
{ {
if(to->table[r + g + b]) // TO_Get if(to->table[r + g + b]) // OT_get
{ {
bmin=b; bmin=b;
goto BMAX; goto BMAX;
@ -454,7 +454,7 @@ BMAX:
for(r=rmin;r<=rmax;r+=1<<16) for(r=rmin;r<=rmax;r+=1<<16)
for(g=vmin;g<=vmax;g+=1<<8) for(g=vmin;g<=vmax;g+=1<<8)
{ {
if(to->table[r + g + b]) // TO_Get if(to->table[r + g + b]) // OT_get
{ {
bmax=b; bmax=b;
goto ENDCRUSH; goto ENDCRUSH;
@ -466,7 +466,7 @@ ENDCRUSH:
for(g=vmin;g<=vmax;g+=1<<8) for(g=vmin;g<=vmax;g+=1<<8)
for(b=bmin;b<=bmax;b++) for(b=bmin;b<=bmax;b++)
{ {
c->occurences+=to->table[r + g + b]; // TO_Get c->occurences+=to->table[r + g + b]; // OT_get
} }
c->rmin=rmin>>16; c->rmax=rmax>>16; c->rmin=rmin>>16; c->rmax=rmax>>16;
@ -508,7 +508,7 @@ ENDCRUSH:
} }
} }
void Cluster_Split(Cluster * c,Cluster * c1,Cluster * c2,int hue,Table_occurence * to) void Cluster_split(T_Cluster * c,T_Cluster * c1,T_Cluster * c2,int hue,T_Occurrence_table * to)
{ {
int limit; int limit;
int cumul; int cumul;
@ -544,13 +544,13 @@ void Cluster_Split(Cluster * c,Cluster * c1,Cluster * c2,int hue,Table_occurence
c1->Rmin=c->Rmin; c1->Rmax=r-1; c1->Rmin=c->Rmin; c1->Rmax=r-1;
c1->rmin=c->rmin; c1->rmax=r-1; c1->rmin=c->rmin; c1->rmax=r-1;
c1->Vmin=c->Vmin; c1->Vmax=c->Vmax; c1->Gmin=c->Gmin; c1->Vmax=c->Vmax;
c1->vmin=c->vmin; c1->vmax=c->vmax; c1->vmin=c->vmin; c1->vmax=c->vmax;
c1->Bmin=c->Bmin; c1->Bmax=c->Bmax; c1->Bmin=c->Bmin; c1->Bmax=c->Bmax;
c1->bmin=c->bmin; c1->bmax=c->bmax; c1->bmin=c->bmin; c1->bmax=c->bmax;
c2->Rmin=r; c2->Rmax=c->Rmax; c2->Rmin=r; c2->Rmax=c->Rmax;
c2->rmin=r; c2->rmax=c->rmax; c2->rmin=r; c2->rmax=c->rmax;
c2->Vmin=c->Vmin; c2->Vmax=c->Vmax; c2->Gmin=c->Gmin; c2->Vmax=c->Vmax;
c2->vmin=c->vmin; c2->vmax=c->vmax; c2->vmin=c->vmin; c2->vmax=c->vmax;
c2->Bmin=c->Bmin; c2->Bmax=c->Bmax; c2->Bmin=c->Bmin; c2->Bmax=c->Bmax;
c2->bmin=c->bmin; c2->bmax=c->bmax; c2->bmin=c->bmin; c2->bmax=c->bmax;
@ -584,13 +584,13 @@ void Cluster_Split(Cluster * c,Cluster * c1,Cluster * c2,int hue,Table_occurence
c1->Rmin=c->Rmin; c1->Rmax=c->Rmax; c1->Rmin=c->Rmin; c1->Rmax=c->Rmax;
c1->rmin=c->rmin; c1->rmax=c->rmax; c1->rmin=c->rmin; c1->rmax=c->rmax;
c1->Vmin=c->Vmin; c1->Vmax=g-1; c1->Gmin=c->Gmin; c1->Vmax=g-1;
c1->vmin=c->vmin; c1->vmax=g-1; c1->vmin=c->vmin; c1->vmax=g-1;
c1->Bmin=c->Bmin; c1->Bmax=c->Bmax; c1->Bmin=c->Bmin; c1->Bmax=c->Bmax;
c1->bmin=c->bmin; c1->bmax=c->bmax; c1->bmin=c->bmin; c1->bmax=c->bmax;
c2->Rmin=c->Rmin; c2->Rmax=c->Rmax; c2->Rmin=c->Rmin; c2->Rmax=c->Rmax;
c2->rmin=c->rmin; c2->rmax=c->rmax; c2->rmin=c->rmin; c2->rmax=c->rmax;
c2->Vmin=g; c2->Vmax=c->Vmax; c2->Gmin=g; c2->Vmax=c->Vmax;
c2->vmin=g; c2->vmax=c->vmax; c2->vmin=g; c2->vmax=c->vmax;
c2->Bmin=c->Bmin; c2->Bmax=c->Bmax; c2->Bmin=c->Bmin; c2->Bmax=c->Bmax;
c2->bmin=c->bmin; c2->bmax=c->bmax; c2->bmin=c->bmin; c2->bmax=c->bmax;
@ -623,45 +623,45 @@ void Cluster_Split(Cluster * c,Cluster * c1,Cluster * c2,int hue,Table_occurence
c1->Rmin=c->Rmin; c1->Rmax=c->Rmax; c1->Rmin=c->Rmin; c1->Rmax=c->Rmax;
c1->rmin=c->rmin; c1->rmax=c->rmax; c1->rmin=c->rmin; c1->rmax=c->rmax;
c1->Vmin=c->Vmin; c1->Vmax=c->Vmax; c1->Gmin=c->Gmin; c1->Vmax=c->Vmax;
c1->vmin=c->vmin; c1->vmax=c->vmax; c1->vmin=c->vmin; c1->vmax=c->vmax;
c1->Bmin=c->Bmin; c1->Bmax=b-1; c1->Bmin=c->Bmin; c1->Bmax=b-1;
c1->bmin=c->bmin; c1->bmax=b-1; c1->bmin=c->bmin; c1->bmax=b-1;
c2->Rmin=c->Rmin; c2->Rmax=c->Rmax; c2->Rmin=c->Rmin; c2->Rmax=c->Rmax;
c2->rmin=c->rmin; c2->rmax=c->rmax; c2->rmin=c->rmin; c2->rmax=c->rmax;
c2->Vmin=c->Vmin; c2->Vmax=c->Vmax; c2->Gmin=c->Gmin; c2->Vmax=c->Vmax;
c2->vmin=c->vmin; c2->vmax=c->vmax; c2->vmin=c->vmin; c2->vmax=c->vmax;
c2->Bmin=b; c2->Bmax=c->Bmax; c2->Bmin=b; c2->Bmax=c->Bmax;
c2->bmin=b; c2->bmax=c->bmax; c2->bmin=b; c2->bmax=c->bmax;
} }
} }
void Cluster_Calculer_teinte(Cluster * c,Table_occurence * to) void Cluster_compute_hue(T_Cluster * c,T_Occurrence_table * to)
{ {
int cumulR,cumulV,cumulB; int cumul_r,cumul_g,cumul_b;
int r,g,b; int r,g,b;
int nbocc; int nbocc;
byte s=0; byte s=0;
cumulR=cumulV=cumulB=0; cumul_r=cumul_g=cumul_b=0;
for (r=c->rmin;r<=c->rmax;r++) for (r=c->rmin;r<=c->rmax;r++)
for (g=c->vmin;g<=c->vmax;g++) for (g=c->vmin;g<=c->vmax;g++)
for (b=c->bmin;b<=c->bmax;b++) for (b=c->bmin;b<=c->bmax;b++)
{ {
nbocc=TO_Get(to,r,g,b); nbocc=OT_get(to,r,g,b);
if (nbocc) if (nbocc)
{ {
cumulR+=r*nbocc; cumul_r+=r*nbocc;
cumulV+=g*nbocc; cumul_g+=g*nbocc;
cumulB+=b*nbocc; cumul_b+=b*nbocc;
} }
} }
c->r=(cumulR<<to->red_r)/c->occurences; c->r=(cumul_r<<to->red_r)/c->occurences;
c->g=(cumulV<<to->red_v)/c->occurences; c->g=(cumul_g<<to->red_g)/c->occurences;
c->b=(cumulB<<to->red_b)/c->occurences; c->b=(cumul_b<<to->red_b)/c->occurences;
RGBtoHSL(c->r,c->g,c->b,&c->h,&s,&c->l); RGB_to_HSL(c->r,c->g,c->b,&c->h,&s,&c->l);
} }
@ -670,28 +670,28 @@ void Cluster_Calculer_teinte(Cluster * c,Table_occurence * to)
//////////////////////////// Mthodes de gestion des ensembles de clusters // //////////////////////////// Mthodes de gestion des ensembles de clusters //
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
void CS_Init(ClusterSet * cs,Table_occurence * to) void CS_Init(T_Cluster_set * cs,T_Occurrence_table * to)
{ {
cs->clusters[0].Rmin=cs->clusters[0].rmin=0; cs->clusters[0].Rmin=cs->clusters[0].rmin=0;
cs->clusters[0].Vmin=cs->clusters[0].vmin=0; cs->clusters[0].Gmin=cs->clusters[0].vmin=0;
cs->clusters[0].Bmin=cs->clusters[0].bmin=0; cs->clusters[0].Bmin=cs->clusters[0].bmin=0;
cs->clusters[0].Rmax=cs->clusters[0].rmax=to->rng_r-1; cs->clusters[0].Rmax=cs->clusters[0].rmax=to->rng_r-1;
cs->clusters[0].Vmax=cs->clusters[0].vmax=to->rng_v-1; cs->clusters[0].Vmax=cs->clusters[0].vmax=to->rng_g-1;
cs->clusters[0].Bmax=cs->clusters[0].bmax=to->rng_b-1; cs->clusters[0].Bmax=cs->clusters[0].bmax=to->rng_b-1;
Cluster_Analyser(cs->clusters+0,to); Cluster_analyser(cs->clusters+0,to);
// Et hop : le 1er ensemble de couleurs est initialis // Et hop : le 1er ensemble de couleurs est initialis
cs->nb=1; cs->nb=1;
} }
ClusterSet * CS_New(int nbmax,Table_occurence * to) T_Cluster_set * CS_New(int nbmax,T_Occurrence_table * to)
{ {
ClusterSet * n; T_Cluster_set * n;
n=(ClusterSet *)malloc(sizeof(ClusterSet)); n=(T_Cluster_set *)malloc(sizeof(T_Cluster_set));
if (n!=0) if (n!=0)
{ {
// On recopie les paramŠtres demands // On recopie les paramŠtres demands
n->nb_max=TO_Compter_couleurs(to); n->nb_max=OT_count_colors(to);
// On vient de compter le nombre de couleurs existantes, s'il est plus grand que 256 on limit à 256 (nombre de couleurs voulu au final) // On vient de compter le nombre de couleurs existantes, s'il est plus grand que 256 on limit à 256 (nombre de couleurs voulu au final)
if (n->nb_max>nbmax) if (n->nb_max>nbmax)
@ -700,7 +700,7 @@ ClusterSet * CS_New(int nbmax,Table_occurence * to)
} }
// On tente d'allouer la table // On tente d'allouer la table
n->clusters=(Cluster *)malloc(nbmax*sizeof(Cluster)); n->clusters=(T_Cluster *)malloc(nbmax*sizeof(T_Cluster));
if (n->clusters!=NULL) if (n->clusters!=NULL)
// C'est bon! On initialise // C'est bon! On initialise
CS_Init(n,to); CS_Init(n,to);
@ -715,13 +715,13 @@ ClusterSet * CS_New(int nbmax,Table_occurence * to)
return n; return n;
} }
void CS_Delete(ClusterSet * cs) void CS_Delete(T_Cluster_set * cs)
{ {
free(cs->clusters); free(cs->clusters);
free(cs); free(cs);
} }
void CS_Get(ClusterSet * cs,Cluster * c) void CS_Get(T_Cluster_set * cs,T_Cluster * c)
{ {
int index; int index;
@ -740,10 +740,10 @@ void CS_Get(ClusterSet * cs,Cluster * c)
// Sachant qu'on va réinsérer juste après, il me semble que ça serait une bonne idée de gérer les clusters // Sachant qu'on va réinsérer juste après, il me semble que ça serait une bonne idée de gérer les clusters
// comme une liste chainée... on n'a aucun accès direct dedans, que des parcours ... // comme une liste chainée... on n'a aucun accès direct dedans, que des parcours ...
cs->nb--; cs->nb--;
memcpy((cs->clusters+index),(cs->clusters+index+1),(cs->nb-index)*sizeof(Cluster)); memcpy((cs->clusters+index),(cs->clusters+index+1),(cs->nb-index)*sizeof(T_Cluster));
} }
void CS_Set(ClusterSet * cs,Cluster * c) void CS_Set(T_Cluster_set * cs,T_Cluster * c)
{ {
int index; int index;
// int decalage; // int decalage;
@ -771,8 +771,8 @@ void CS_Set(ClusterSet * cs,Cluster * c)
// une place dans la liste. // une place dans la liste.
//for (decalage=cs->nb;decalage>index;decalage--) //for (decalage=cs->nb;decalage>index;decalage--)
// memcpy((cs->clusters+decalage),(cs->clusters+decalage-1),sizeof(Cluster)); // memcpy((cs->clusters+decalage),(cs->clusters+decalage-1),sizeof(T_Cluster));
memmove(cs->clusters+index+1,cs->clusters+index,(cs->nb-index)*sizeof(Cluster)); memmove(cs->clusters+index+1,cs->clusters+index,(cs->nb-index)*sizeof(T_Cluster));
} }
cs->clusters[index]=*c; cs->clusters[index]=*c;
@ -786,11 +786,11 @@ void CS_Set(ClusterSet * cs,Cluster * c)
// 4) On coupe la boîte en deux au milieu, et on compacte pour que chaque bord corresponde bien à un pixel extreme // 4) On coupe la boîte en deux au milieu, et on compacte pour que chaque bord corresponde bien à un pixel extreme
// 5) On recommence à couper selon le plus grand axe toutes boîtes confondues // 5) On recommence à couper selon le plus grand axe toutes boîtes confondues
// 6) On s'arrête quand on a le nombre de couleurs voulu // 6) On s'arrête quand on a le nombre de couleurs voulu
void CS_Generer(ClusterSet * cs,Table_occurence * to) void CS_Generate(T_Cluster_set * cs,T_Occurrence_table * to)
{ {
Cluster current; T_Cluster current;
Cluster Nouveau1; T_Cluster Nouveau1;
Cluster Nouveau2; T_Cluster Nouveau2;
// Tant qu'on a moins de 256 clusters // Tant qu'on a moins de 256 clusters
while (cs->nb<cs->nb_max) while (cs->nb<cs->nb_max)
@ -799,11 +799,11 @@ void CS_Generer(ClusterSet * cs,Table_occurence * to)
CS_Get(cs,&current); CS_Get(cs,&current);
// On le coupe en deux // On le coupe en deux
Cluster_Split(&current,&Nouveau1,&Nouveau2,current.plus_large,to); Cluster_split(&current,&Nouveau1,&Nouveau2,current.plus_large,to);
// On compacte ces deux nouveaux (il peut y avoir un espace entre l'endroit de la coupure et les premiers pixels du cluster) // On compacte ces deux nouveaux (il peut y avoir un espace entre l'endroit de la coupure et les premiers pixels du cluster)
Cluster_Analyser(&Nouveau1,to); Cluster_analyser(&Nouveau1,to);
Cluster_Analyser(&Nouveau2,to); Cluster_analyser(&Nouveau2,to);
// On met ces deux nouveaux clusters dans le clusterSet... sauf s'ils sont vides // On met ces deux nouveaux clusters dans le clusterSet... sauf s'ils sont vides
if(Nouveau1.occurences>0) if(Nouveau1.occurences>0)
@ -813,23 +813,23 @@ void CS_Generer(ClusterSet * cs,Table_occurence * to)
} }
} }
void CS_Calculer_teintes(ClusterSet * cs,Table_occurence * to) void CS_Compute_colors(T_Cluster_set * cs,T_Occurrence_table * to)
{ {
int index; int index;
Cluster * c; T_Cluster * c;
for (index=0,c=cs->clusters;index<cs->nb;index++,c++) for (index=0,c=cs->clusters;index<cs->nb;index++,c++)
Cluster_Calculer_teinte(c,to); Cluster_compute_hue(c,to);
} }
void CS_Trier_par_chrominance(ClusterSet * cs) void CS_Sort_by_chrominance(T_Cluster_set * cs)
{ {
int byte_used[256]; int byte_used[256];
int decalages[256]; int decalages[256];
int index; int index;
Cluster * nc; T_Cluster * nc;
nc=(Cluster *)malloc(cs->nb_max*sizeof(Cluster)); nc=(T_Cluster *)malloc(cs->nb_max*sizeof(T_Cluster));
// Initialisation de la table d'occurence de chaque octet // Initialisation de la table d'occurence de chaque octet
for (index=0;index<256;index++) for (index=0;index<256;index++)
@ -856,14 +856,14 @@ void CS_Trier_par_chrominance(ClusterSet * cs)
cs->clusters=nc; cs->clusters=nc;
} }
void CS_Trier_par_luminance(ClusterSet * cs) void CS_Sort_by_luminance(T_Cluster_set * cs)
{ {
int byte_used[256]; int byte_used[256];
int decalages[256]; int decalages[256];
int index; int index;
Cluster * nc; T_Cluster * nc;
nc=(Cluster *)malloc(cs->nb_max*sizeof(Cluster)); nc=(T_Cluster *)malloc(cs->nb_max*sizeof(T_Cluster));
// Initialisation de la table d'occurence de chaque octet // Initialisation de la table d'occurence de chaque octet
for (index=0;index<256;index++) for (index=0;index<256;index++)
@ -890,7 +890,7 @@ void CS_Trier_par_luminance(ClusterSet * cs)
cs->clusters=nc; cs->clusters=nc;
} }
void CS_Generer_TC_et_Palette(ClusterSet * cs,Table_conversion * tc,Composantes * palette) void CS_Generate_color_table_and_palette(T_Cluster_set * cs,T_Conversion_table * tc,T_Components * palette)
{ {
int index; int index;
int r,g,b; int r,g,b;
@ -902,9 +902,9 @@ void CS_Generer_TC_et_Palette(ClusterSet * cs,Table_conversion * tc,Composantes
palette[index].B=cs->clusters[index].b; palette[index].B=cs->clusters[index].b;
for (r=cs->clusters[index].Rmin;r<=cs->clusters[index].Rmax;r++) for (r=cs->clusters[index].Rmin;r<=cs->clusters[index].Rmax;r++)
for (g=cs->clusters[index].Vmin;g<=cs->clusters[index].Vmax;g++) for (g=cs->clusters[index].Gmin;g<=cs->clusters[index].Vmax;g++)
for (b=cs->clusters[index].Bmin;b<=cs->clusters[index].Bmax;b++) for (b=cs->clusters[index].Bmin;b<=cs->clusters[index].Bmax;b++)
TC_Set(tc,r,g,b,index); CT_set(tc,r,g,b,index);
} }
} }
@ -912,7 +912,7 @@ void CS_Generer_TC_et_Palette(ClusterSet * cs,Table_conversion * tc,Composantes
///////////////////////////////////////// Méthodes de gestion des dégradés // ///////////////////////////////////////// Méthodes de gestion des dégradés //
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
void DS_Init(DegradeSet * ds,ClusterSet * cs) void GS_Init(T_Gradient_set * ds,T_Cluster_set * cs)
{ {
ds->gradients[0].nb_colors=1; ds->gradients[0].nb_colors=1;
ds->gradients[0].min=cs->clusters[0].h; ds->gradients[0].min=cs->clusters[0].h;
@ -922,21 +922,21 @@ void DS_Init(DegradeSet * ds,ClusterSet * cs)
ds->nb=1; ds->nb=1;
} }
DegradeSet * DS_New(ClusterSet * cs) T_Gradient_set * GS_New(T_Cluster_set * cs)
{ {
DegradeSet * n; T_Gradient_set * n;
n=(DegradeSet *)malloc(sizeof(DegradeSet)); n=(T_Gradient_set *)malloc(sizeof(T_Gradient_set));
if (n!=NULL) if (n!=NULL)
{ {
// On recopie les paramŠtres demands // On recopie les paramŠtres demands
n->nb_max=cs->nb_max; n->nb_max=cs->nb_max;
// On tente d'allouer la table // On tente d'allouer la table
n->gradients=(Degrade *)malloc((n->nb_max)*sizeof(Degrade)); n->gradients=(T_Gradient *)malloc((n->nb_max)*sizeof(T_Gradient));
if (n->gradients!=0) if (n->gradients!=0)
// C'est bon! On initialise // C'est bon! On initialise
DS_Init(n,cs); GS_Init(n,cs);
else else
{ {
// Table impossible … allouer // Table impossible … allouer
@ -948,60 +948,60 @@ DegradeSet * DS_New(ClusterSet * cs)
return n; return n;
} }
void DS_Delete(DegradeSet * ds) void GS_Delete(T_Gradient_set * ds)
{ {
free(ds->gradients); free(ds->gradients);
free(ds); free(ds);
} }
void DS_Generer(DegradeSet * ds,ClusterSet * cs) void GS_Generate(T_Gradient_set * ds,T_Cluster_set * cs)
{ {
int ic,id; // Les indexs de parcours des ensembles int ic,id; // Les indexs de parcours des ensembles
int mdegr; // Meilleur dgrad int best_gradient; // Meilleur dgrad
int mdiff; // Meilleure diffrence de chrominance int best_diff; // Meilleure diffrence de chrominance
int diff; // Difference de chrominance courante int diff; // difference de chrominance courante
// Pour chacun des clusters … traiter // Pour chacun des clusters … traiter
for (ic=1;ic<cs->nb;ic++) for (ic=1;ic<cs->nb;ic++)
{ {
// On recherche le dgrad le plus proche de la chrominance du cluster // On recherche le dgrad le plus proche de la chrominance du cluster
mdegr=-1; best_gradient=-1;
mdiff=99999999; best_diff=99999999;
for (id=0;id<ds->nb;id++) for (id=0;id<ds->nb;id++)
{ {
diff=abs(cs->clusters[ic].h - ds->gradients[id].hue); diff=abs(cs->clusters[ic].h - ds->gradients[id].hue);
if ((mdiff>diff) && (diff<16)) if ((best_diff>diff) && (diff<16))
{ {
mdegr=id; best_gradient=id;
mdiff=diff; best_diff=diff;
} }
} }
// Si on a trouv un dgrad dans lequel inclure le cluster // Si on a trouv un dgrad dans lequel inclure le cluster
if (mdegr!=-1) if (best_gradient!=-1)
{ {
// On met … jour le dgrad // On met … jour le dgrad
if (cs->clusters[ic].h < ds->gradients[mdegr].min) if (cs->clusters[ic].h < ds->gradients[best_gradient].min)
ds->gradients[mdegr].min=cs->clusters[ic].h; ds->gradients[best_gradient].min=cs->clusters[ic].h;
if (cs->clusters[ic].h > ds->gradients[mdegr].max) if (cs->clusters[ic].h > ds->gradients[best_gradient].max)
ds->gradients[mdegr].max=cs->clusters[ic].h; ds->gradients[best_gradient].max=cs->clusters[ic].h;
ds->gradients[mdegr].hue=((ds->gradients[mdegr].hue* ds->gradients[best_gradient].hue=((ds->gradients[best_gradient].hue*
ds->gradients[mdegr].nb_colors) ds->gradients[best_gradient].nb_colors)
+cs->clusters[ic].h) +cs->clusters[ic].h)
/(ds->gradients[mdegr].nb_colors+1); /(ds->gradients[best_gradient].nb_colors+1);
ds->gradients[mdegr].nb_colors++; ds->gradients[best_gradient].nb_colors++;
} }
else else
{ {
// On cre un nouveau dgrad // On cre un nouveau dgrad
mdegr=ds->nb; best_gradient=ds->nb;
ds->gradients[mdegr].nb_colors=1; ds->gradients[best_gradient].nb_colors=1;
ds->gradients[mdegr].min=cs->clusters[ic].h; ds->gradients[best_gradient].min=cs->clusters[ic].h;
ds->gradients[mdegr].max=cs->clusters[ic].h; ds->gradients[best_gradient].max=cs->clusters[ic].h;
ds->gradients[mdegr].hue=cs->clusters[ic].h; ds->gradients[best_gradient].hue=cs->clusters[ic].h;
ds->nb++; ds->nb++;
} }
cs->clusters[ic].h=mdegr; cs->clusters[ic].h=best_gradient;
} }
// On redistribue les valeurs dans les clusters // On redistribue les valeurs dans les clusters
@ -1012,25 +1012,25 @@ void DS_Generer(DegradeSet * ds,ClusterSet * cs)
Table_conversion * Optimiser_palette(Bitmap24B image,int size,Composantes * palette,int r,int g,int b) T_Conversion_table * Optimize_palette(T_Bitmap24B image,int size,T_Components * palette,int r,int g,int b)
{ {
Table_occurence * to; T_Occurrence_table * to;
Table_conversion * tc; T_Conversion_table * tc;
ClusterSet * cs; T_Cluster_set * cs;
DegradeSet * ds; T_Gradient_set * ds;
// Création des éléments nécessaires au calcul de palette optimisée: // Création des éléments nécessaires au calcul de palette optimisée:
to=0; tc=0; cs=0; ds=0; to=0; tc=0; cs=0; ds=0;
to=TO_New(r,g,b); to=OT_new(r,g,b);
if (to!=0) if (to!=0)
{ {
tc=TC_New(r,g,b); tc=CT_new(r,g,b);
if (tc!=0) if (tc!=0)
{ {
// Première étape : on compte les pixels de chaque couleur pour pouvoir trier là dessus // Première étape : on compte les pixels de chaque couleur pour pouvoir trier là dessus
TO_Compter_occurences(to,image,size); OT_count_occurrences(to,image,size);
cs=CS_New(256,to); cs=CS_New(256,to);
if (cs!=0) if (cs!=0)
@ -1038,39 +1038,39 @@ Table_conversion * Optimiser_palette(Bitmap24B image,int size,Composantes * pale
// C'est bon, on a pu tout allouer // C'est bon, on a pu tout allouer
// On génère les clusters (avec l'algo du median cut) // On génère les clusters (avec l'algo du median cut)
CS_Generer(cs,to); CS_Generate(cs,to);
// On calcule la teinte de chaque pixel (Luminance et chrominance) // On calcule la teinte de chaque pixel (Luminance et chrominance)
CS_Calculer_teintes(cs,to); CS_Compute_colors(cs,to);
ds=DS_New(cs); ds=GS_New(cs);
if (ds!=0) if (ds!=0)
{ {
DS_Generer(ds,cs); GS_Generate(ds,cs);
DS_Delete(ds); GS_Delete(ds);
} }
// Enfin on trie les clusters (donc les couleurs de la palette) dans un ordre sympa : par couleur, et par luminosité pour chaque couleur // Enfin on trie les clusters (donc les couleurs de la palette) dans un ordre sympa : par couleur, et par luminosité pour chaque couleur
CS_Trier_par_luminance(cs); CS_Sort_by_luminance(cs);
CS_Trier_par_chrominance(cs); CS_Sort_by_chrominance(cs);
// Enfin on génère la palette et la table de correspondance entre chaque couleur 24b et sa couleur palette associée. // Enfin on génère la palette et la table de correspondance entre chaque couleur 24b et sa couleur palette associée.
CS_Generer_TC_et_Palette(cs,tc,palette); CS_Generate_color_table_and_palette(cs,tc,palette);
CS_Delete(cs); CS_Delete(cs);
TO_Delete(to); OT_delete(to);
return tc; return tc;
} }
TC_Delete(tc); CT_delete(tc);
} }
TO_Delete(to); OT_delete(to);
} }
// Si on arrive ici c'est que l'allocation n'a pas réussi, // Si on arrive ici c'est que l'allocation n'a pas réussi,
// l'appelant devra recommencer avec une précision plus faible (3 derniers paramètres) // l'appelant devra recommencer avec une précision plus faible (3 derniers paramètres)
return 0; return 0;
} }
int Valeur_modifiee(int value,int modif) int Modified_value(int value,int modif)
{ {
value+=modif; value+=modif;
if (value<0) if (value<0)
@ -1084,28 +1084,28 @@ int Valeur_modifiee(int value,int modif)
return value; return value;
} }
void Convert_bitmap_24B_to_256_Floyd_Steinberg(Bitmap256 Dest,Bitmap24B Source,int width,int height,Composantes * palette,Table_conversion * tc) void Convert_24b_bitmap_to_256_Floyd_Steinberg(T_Bitmap256 dest,T_Bitmap24B source,int width,int height,T_Components * palette,T_Conversion_table * tc)
// Cette fonction dégrade au fur et à mesure le bitmap source, donc soit on ne // Cette fonction dégrade au fur et à mesure le bitmap source, donc soit on ne
// s'en ressert pas, soit on passe à la fonction une copie de travail du // s'en ressert pas, soit on passe à la fonction une copie de travail du
// bitmap original. // bitmap original.
{ {
Bitmap24B current; T_Bitmap24B current;
Bitmap24B c_plus1; T_Bitmap24B c_plus1;
Bitmap24B u_minus1; T_Bitmap24B u_minus1;
Bitmap24B next; T_Bitmap24B next;
Bitmap24B u_plus1; T_Bitmap24B u_plus1;
Bitmap256 d; T_Bitmap256 d;
int x_pos,y_pos; int x_pos,y_pos;
int Rouge,Vert,Bleu; int red,green,blue;
float ERouge,EVert,EBleu; float e_red,e_green,e_blue;
// On initialise les variables de parcours: // On initialise les variables de parcours:
current =Source; // Le pixel dont on s'occupe current =source; // Le pixel dont on s'occupe
next =current+width; // Le pixel en dessous next =current+width; // Le pixel en dessous
c_plus1 =current+1; // Le pixel à droite c_plus1 =current+1; // Le pixel à droite
u_minus1=next-1; // Le pixel en bas à gauche u_minus1=next-1; // Le pixel en bas à gauche
u_plus1 =next+1; // Le pixel en bas à droite u_plus1 =next+1; // Le pixel en bas à droite
d =Dest; d =dest;
// On parcours chaque pixel: // On parcours chaque pixel:
for (y_pos=0;y_pos<height;y_pos++) for (y_pos=0;y_pos<height;y_pos++)
@ -1114,57 +1114,57 @@ void Convert_bitmap_24B_to_256_Floyd_Steinberg(Bitmap256 Dest,Bitmap24B Source,i
{ {
// On prends la meilleure couleur de la palette qui traduit la couleur // On prends la meilleure couleur de la palette qui traduit la couleur
// 24 bits de la source: // 24 bits de la source:
Rouge=current->R; red=current->R;
Vert =current->G; green =current->G;
Bleu =current->B; blue =current->B;
// Cherche la couleur correspondant dans la palette et la range dans l'image de destination // Cherche la couleur correspondant dans la palette et la range dans l'image de destination
*d=TC_Get(tc,Rouge,Vert,Bleu); *d=CT_get(tc,red,green,blue);
// Puis on calcule pour chaque composante l'erreur dûe à l'approximation // Puis on calcule pour chaque composante l'erreur dûe à l'approximation
Rouge-=palette[*d].R; red-=palette[*d].R;
Vert -=palette[*d].G; green -=palette[*d].G;
Bleu -=palette[*d].B; blue -=palette[*d].B;
// Et dans chaque pixel voisin on propage l'erreur // Et dans chaque pixel voisin on propage l'erreur
// A droite: // A droite:
ERouge=(Rouge*7)/16.0; e_red=(red*7)/16.0;
EVert =(Vert *7)/16.0; e_green =(green *7)/16.0;
EBleu =(Bleu *7)/16.0; e_blue =(blue *7)/16.0;
if (x_pos+1<width) if (x_pos+1<width)
{ {
// Valeur_modifiee fait la somme des 2 params en bornant sur [0,255] // Modified_value fait la somme des 2 params en bornant sur [0,255]
c_plus1->R=Valeur_modifiee(c_plus1->R,ERouge); c_plus1->R=Modified_value(c_plus1->R,e_red);
c_plus1->G=Valeur_modifiee(c_plus1->G,EVert ); c_plus1->G=Modified_value(c_plus1->G,e_green );
c_plus1->B=Valeur_modifiee(c_plus1->B,EBleu ); c_plus1->B=Modified_value(c_plus1->B,e_blue );
} }
// En bas à gauche: // En bas à gauche:
if (y_pos+1<height) if (y_pos+1<height)
{ {
ERouge=(Rouge*3)/16.0; e_red=(red*3)/16.0;
EVert =(Vert *3)/16.0; e_green =(green *3)/16.0;
EBleu =(Bleu *3)/16.0; e_blue =(blue *3)/16.0;
if (x_pos>0) if (x_pos>0)
{ {
u_minus1->R=Valeur_modifiee(u_minus1->R,ERouge); u_minus1->R=Modified_value(u_minus1->R,e_red);
u_minus1->G=Valeur_modifiee(u_minus1->G,EVert ); u_minus1->G=Modified_value(u_minus1->G,e_green );
u_minus1->B=Valeur_modifiee(u_minus1->B,EBleu ); u_minus1->B=Modified_value(u_minus1->B,e_blue );
} }
// En bas: // En bas:
ERouge=(Rouge*5/16.0); e_red=(red*5/16.0);
EVert =(Vert*5 /16.0); e_green =(green*5 /16.0);
EBleu =(Bleu*5 /16.0); e_blue =(blue*5 /16.0);
next->R=Valeur_modifiee(next->R,ERouge); next->R=Modified_value(next->R,e_red);
next->G=Valeur_modifiee(next->G,EVert ); next->G=Modified_value(next->G,e_green );
next->B=Valeur_modifiee(next->B,EBleu ); next->B=Modified_value(next->B,e_blue );
// En bas à droite: // En bas à droite:
if (x_pos+1<width) if (x_pos+1<width)
{ {
ERouge=(Rouge/16.0); e_red=(red/16.0);
EVert =(Vert /16.0); e_green =(green /16.0);
EBleu =(Bleu /16.0); e_blue =(blue /16.0);
u_plus1->R=Valeur_modifiee(u_plus1->R,ERouge); u_plus1->R=Modified_value(u_plus1->R,e_red);
u_plus1->G=Valeur_modifiee(u_plus1->G,EVert ); u_plus1->G=Modified_value(u_plus1->G,e_green );
u_plus1->B=Valeur_modifiee(u_plus1->B,EBleu ); u_plus1->B=Modified_value(u_plus1->B,e_blue );
} }
} }
@ -1201,18 +1201,18 @@ static const byte precision_24b[]=
// Convertie avec le plus de précision possible une image 24b en 256c // Convertie avec le plus de précision possible une image 24b en 256c
// Renvoie s'il y a eu une erreur ou pas.. // Renvoie s'il y a eu une erreur ou pas..
// Cette fonction utilise l'algorithme "median cut" (Optimiser_palette) pour trouver la palette, et diffuse les erreurs avec floyd-steinberg. // Cette fonction utilise l'algorithme "median cut" (Optimize_palette) pour trouver la palette, et diffuse les erreurs avec floyd-steinberg.
int Convert_bitmap_24B_to_256(Bitmap256 Dest,Bitmap24B Source,int width,int height,Composantes * palette) int Convert_24b_bitmap_to_256(T_Bitmap256 dest,T_Bitmap24B source,int width,int height,T_Components * palette)
{ {
Table_conversion * table; // table de conversion T_Conversion_table * table; // table de conversion
int ip; // index de précision pour la conversion int ip; // index de précision pour la conversion
// On essaye d'obtenir une table de conversion qui loge en mémoire, avec la // On essaye d'obtenir une table de conversion qui loge en mémoire, avec la
// meilleure précision possible // meilleure précision possible
for (ip=0;ip<(10*3);ip+=3) for (ip=0;ip<(10*3);ip+=3)
{ {
table=Optimiser_palette(Source,width*height,palette,precision_24b[ip+0], table=Optimize_palette(source,width*height,palette,precision_24b[ip+0],
precision_24b[ip+1],precision_24b[ip+2]); precision_24b[ip+1],precision_24b[ip+2]);
if (table!=0) if (table!=0)
break; break;
@ -1220,8 +1220,8 @@ int Convert_bitmap_24B_to_256(Bitmap256 Dest,Bitmap24B Source,int width,int heig
if (table!=0) if (table!=0)
{ {
Convert_bitmap_24B_to_256_Floyd_Steinberg(Dest,Source,width,height,palette,table); Convert_24b_bitmap_to_256_Floyd_Steinberg(dest,source,width,height,palette,table);
TC_Delete(table); CT_delete(table);
return 0; return 0;
} }
else else

96
op_c.h
View File

@ -25,8 +25,8 @@
//////////////////////////////////////////////// Définition des types de base //////////////////////////////////////////////// Définition des types de base
typedef Composantes * Bitmap24B; typedef T_Components * T_Bitmap24B;
typedef byte * Bitmap256; typedef byte * T_Bitmap256;
@ -39,19 +39,19 @@ typedef struct
int nbb_b; // Nb de bits de précision sur les bleu int nbb_b; // Nb de bits de précision sur les bleu
int rng_r; // Nb de valeurs sur les rouges (= 1<<nbb_r) int rng_r; // Nb de valeurs sur les rouges (= 1<<nbb_r)
int rng_v; // Nb de valeurs sur les verts (= 1<<nbb_g) int rng_g; // Nb de valeurs sur les verts (= 1<<nbb_g)
int rng_b; // Nb de valeurs sur les bleus (= 1<<nbb_b) int rng_b; // Nb de valeurs sur les bleus (= 1<<nbb_b)
int dec_r; // Coefficient multiplicateur d'accès dans la table (= nbb_g+nbb_b) int dec_r; // Coefficient multiplicateur d'accès dans la table (= nbb_g+nbb_b)
int dec_v; // Coefficient multiplicateur d'accès dans la table (= nbb_b) int dec_g; // Coefficient multiplicateur d'accès dans la table (= nbb_b)
int dec_b; // Coefficient multiplicateur d'accès dans la table (= 0) int dec_b; // Coefficient multiplicateur d'accès dans la table (= 0)
int red_r; // Coefficient réducteur de traduction d'une couleur rouge (= 8-nbb_r) int red_r; // Coefficient réducteur de traduction d'une couleur rouge (= 8-nbb_r)
int red_v; // Coefficient réducteur de traduction d'une couleur verte (= 8-nbb_g) int red_g; // Coefficient réducteur de traduction d'une couleur verte (= 8-nbb_g)
int red_b; // Coefficient réducteur de traduction d'une couleur bleue (= 8-nbb_b) int red_b; // Coefficient réducteur de traduction d'une couleur bleue (= 8-nbb_b)
byte * table; byte * table;
} Table_conversion; } T_Conversion_table;
@ -64,19 +64,19 @@ typedef struct
int nbb_b; // Nb de bits de précision sur les bleu int nbb_b; // Nb de bits de précision sur les bleu
int rng_r; // Nb de valeurs sur les rouges (= 1<<nbb_r) int rng_r; // Nb de valeurs sur les rouges (= 1<<nbb_r)
int rng_v; // Nb de valeurs sur les verts (= 1<<nbb_g) int rng_g; // Nb de valeurs sur les verts (= 1<<nbb_g)
int rng_b; // Nb de valeurs sur les bleus (= 1<<nbb_b) int rng_b; // Nb de valeurs sur les bleus (= 1<<nbb_b)
int dec_r; // Coefficient multiplicateur d'accès dans la table (= nbb_g+nbb_b) int dec_r; // Coefficient multiplicateur d'accès dans la table (= nbb_g+nbb_b)
int dec_v; // Coefficient multiplicateur d'accès dans la table (= nbb_b) int dec_g; // Coefficient multiplicateur d'accès dans la table (= nbb_b)
int dec_b; // Coefficient multiplicateur d'accès dans la table (= 0) int dec_b; // Coefficient multiplicateur d'accès dans la table (= 0)
int red_r; // Coefficient réducteur de traduction d'une couleur rouge (= 8-nbb_r) int red_r; // Coefficient réducteur de traduction d'une couleur rouge (= 8-nbb_r)
int red_v; // Coefficient réducteur de traduction d'une couleur verte (= 8-nbb_g) int red_g; // Coefficient réducteur de traduction d'une couleur verte (= 8-nbb_g)
int red_b; // Coefficient réducteur de traduction d'une couleur bleue (= 8-nbb_b) int red_b; // Coefficient réducteur de traduction d'une couleur bleue (= 8-nbb_b)
int * table; int * table;
} Table_occurence; } T_Occurrence_table;
@ -88,7 +88,7 @@ typedef struct
// Grande couverture // Grande couverture
byte Rmin,Rmax; byte Rmin,Rmax;
byte Vmin,Vmax; byte Gmin,Vmax;
byte Bmin,Bmax; byte Bmin,Bmax;
// Couverture minimale // Couverture minimale
@ -96,11 +96,11 @@ typedef struct
byte vmin,vmax; byte vmin,vmax;
byte bmin,bmax; byte bmin,bmax;
byte plus_large; // Composante ayant la plus grande variation (0=Rouge,1=Vert,2=Bleu) byte plus_large; // Composante ayant la plus grande variation (0=red,1=green,2=blue)
byte r,g,b; // Couleur synthétisant l'ensemble byte r,g,b; // color synthétisant l'ensemble
byte h; // Chrominance byte h; // Chrominance
byte l; // Luminosité byte l; // Luminosité
} Cluster; } T_Cluster;
@ -110,8 +110,8 @@ typedef struct
{ {
int nb; int nb;
int nb_max; int nb_max;
Cluster * clusters; T_Cluster * clusters;
} ClusterSet; } T_Cluster_set;
@ -123,7 +123,7 @@ typedef struct
float min; // Chrominance minimale du dégradé float min; // Chrominance minimale du dégradé
float max; // Chrominance maximale du dégradé float max; // Chrominance maximale du dégradé
float hue; // Chrominance moyenne du dégradé float hue; // Chrominance moyenne du dégradé
} Degrade; } T_Gradient;
@ -133,8 +133,8 @@ typedef struct
{ {
int nb; // Nombre de dégradés dans l'ensemble int nb; // Nombre de dégradés dans l'ensemble
int nb_max; // Nombre maximum de dégradés int nb_max; // Nombre maximum de dégradés
Degrade * gradients; // Les dégradés T_Gradient * gradients; // Les dégradés
} DegradeSet; } T_Gradient_set;
@ -142,26 +142,26 @@ typedef struct
///////////////////////////// Méthodes de gestion des tables de conversion // ///////////////////////////// Méthodes de gestion des tables de conversion //
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
Table_conversion * TC_New(int nbb_r,int nbb_g,int nbb_b); T_Conversion_table * CT_new(int nbb_r,int nbb_g,int nbb_b);
void TC_Delete(Table_conversion * t); void CT_delete(T_Conversion_table * t);
byte TC_Get(Table_conversion * t,int r,int g,int b); byte CT_get(T_Conversion_table * t,int r,int g,int b);
void TC_Set(Table_conversion * t,int r,int g,int b,byte i); void CT_set(T_Conversion_table * t,int r,int g,int b,byte i);
void RGBtoHSL(int r, int g,int b, byte* h, byte*s, byte* l); void RGB_to_HSL(int r, int g,int b, byte* h, byte*s, byte* l);
void HSLtoRGB(byte h, byte s, byte l, byte* r, byte* g, byte* b); void HSL_to_RGB(byte h, byte s, byte l, byte* r, byte* g, byte* b);
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
/////////////////////////////// Méthodes de gestion des tables d'occurence // /////////////////////////////// Méthodes de gestion des tables d'occurence //
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
void TO_Init(Table_occurence * t); void OT_init(T_Occurrence_table * t);
Table_occurence * TO_New(int nbb_r,int nbb_g,int nbb_b); T_Occurrence_table * OT_new(int nbb_r,int nbb_g,int nbb_b);
void TO_Delete(Table_occurence * t); void OT_delete(T_Occurrence_table * t);
int TO_Get(Table_occurence * t,int r,int g,int b); int OT_get(T_Occurrence_table * t,int r,int g,int b);
void TO_Set(Table_occurence * t,int r,int g,int b,int i); void OT_set(T_Occurrence_table * t,int r,int g,int b,int i);
void TO_Inc(Table_occurence * t,int r,int g,int b); void OT_inc(T_Occurrence_table * t,int r,int g,int b);
void TO_Compter_occurences(Table_occurence * t,Bitmap24B image,int size); void OT_count_occurrences(T_Occurrence_table * t,T_Bitmap24B image,int size);
@ -169,9 +169,9 @@ void TO_Compter_occurences(Table_occurence * t,Bitmap24B image,int size);
///////////////////////////////////////// Méthodes de gestion des clusters // ///////////////////////////////////////// Méthodes de gestion des clusters //
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
void Cluster_Analyser(Cluster * c,Table_occurence * to); void Cluster_analyser(T_Cluster * c,T_Occurrence_table * to);
void Cluster_Split(Cluster * c,Cluster * c1,Cluster * c2,int hue,Table_occurence * to); void Cluster_split(T_Cluster * c,T_Cluster * c1,T_Cluster * c2,int hue,T_Occurrence_table * to);
void Cluster_Calculer_teinte(Cluster * c,Table_occurence * to); void Cluster_compute_hue(T_Cluster * c,T_Occurrence_table * to);
@ -179,29 +179,29 @@ void Cluster_Calculer_teinte(Cluster * c,Table_occurence * to);
//////////////////////////// Méthodes de gestion des ensembles de clusters // //////////////////////////// Méthodes de gestion des ensembles de clusters //
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
void CS_Init(ClusterSet * cs,Table_occurence * to); void CS_Init(T_Cluster_set * cs,T_Occurrence_table * to);
ClusterSet * CS_New(int nbmax,Table_occurence * to); T_Cluster_set * CS_New(int nbmax,T_Occurrence_table * to);
void CS_Delete(ClusterSet * cs); void CS_Delete(T_Cluster_set * cs);
void CS_Get(ClusterSet * cs,Cluster * c); void CS_Get(T_Cluster_set * cs,T_Cluster * c);
void CS_Set(ClusterSet * cs,Cluster * c); void CS_Set(T_Cluster_set * cs,T_Cluster * c);
void CS_Generer(ClusterSet * cs,Table_occurence * to); void CS_Generate(T_Cluster_set * cs,T_Occurrence_table * to);
void CS_Calculer_teintes(ClusterSet * cs,Table_occurence * to); void CS_Compute_colors(T_Cluster_set * cs,T_Occurrence_table * to);
void CS_Generer_TC_et_Palette(ClusterSet * cs,Table_conversion * tc,Composantes * palette); void CS_Generate_color_table_and_palette(T_Cluster_set * cs,T_Conversion_table * tc,T_Components * palette);
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
//////////////////////////// Méthodes de gestion des ensembles de dégradés // //////////////////////////// Méthodes de gestion des ensembles de dégradés //
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
void DS_Init(DegradeSet * ds,ClusterSet * cs); void GS_Init(T_Gradient_set * ds,T_Cluster_set * cs);
DegradeSet * DS_New(ClusterSet * cs); T_Gradient_set * GS_New(T_Cluster_set * cs);
void DS_Delete(DegradeSet * ds); void GS_Delete(T_Gradient_set * ds);
void DS_Generer(DegradeSet * ds,ClusterSet * cs); void GS_Generate(T_Gradient_set * ds,T_Cluster_set * cs);
// Convertie avec le plus de précision possible une image 24b en 256c // Convertie avec le plus de précision possible une image 24b en 256c
// Renvoie s'il y a eu une erreur ou pas.. // Renvoie s'il y a eu une erreur ou pas..
int Convert_bitmap_24B_to_256(Bitmap256 Dest,Bitmap24B Source,int width,int height,Composantes * palette); int Convert_24b_bitmap_to_256(T_Bitmap256 dest,T_Bitmap24B source,int width,int height,T_Components * palette);

5002
operatio.c

File diff suppressed because it is too large Load Diff

View File

@ -18,134 +18,134 @@
write to the Free Software Foundation, Inc., write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
void Demarrer_pile_operation(word Operation_demandee); void Start_operation_stack(word new_operation);
void Operation_PUSH(short value); void Operation_push(short value);
void Operation_POP(short * value); void Operation_pop(short * value);
//////////////////////////////////////////////////// OPERATION_DESSIN_CONTINU //////////////////////////////////////////////////// OPERATION_CONTINUOUS_DRAW
void Freehand_Mode1_1_0(void); void Freehand_mode1_1_0(void);
void Freehand_Mode1_1_2(void); void Freehand_mode1_1_2(void);
void Freehand_Mode12_0_2(void); void Freehand_mode12_0_2(void);
void Freehand_Mode1_2_0(void); void Freehand_mode1_2_0(void);
void Freehand_Mode1_2_2(void); void Freehand_mode1_2_2(void);
///////////////////////////////////////////////// OPERATION_DESSIN_DISCONTINU ///////////////////////////////////////////////// OPERATION_DISCONTINUOUS_DRAW
void Freehand_Mode2_1_0(void); void Freehand_mode2_1_0(void);
void Freehand_Mode2_1_2(void); void Freehand_mode2_1_2(void);
void Freehand_Mode2_2_0(void); void Freehand_mode2_2_0(void);
void Freehand_Mode2_2_2(void); void Freehand_mode2_2_2(void);
////////////////////////////////////////////////////// OPERATION_DESSIN_POINT ////////////////////////////////////////////////////// OPERATION_POINT_DRAW
void Freehand_Mode3_1_0(void); void Freehand_mode3_1_0(void);
void Freehand_Mode3_2_0(void); void Freehand_Mode3_2_0(void);
void Freehand_Mode3_0_1(void); void Freehand_mode3_0_1(void);
///////////////////////////////////////////////////////////// OPERATION_LIGNE ///////////////////////////////////////////////////////////// OPERATION_LINE
void Ligne_12_0(void); void Line_12_0(void);
void Ligne_12_5(void); void Line_12_5(void);
void Ligne_0_5(void); void Line_0_5(void);
///////////////////////////////////////////////////////////// OPERATION_LOUPE ///////////////////////////////////////////////////////////// OPERATION_MAGNIFY
void Loupe_12_0(void); void Magnifier_12_0(void);
/////////////////////////////////////////////////// OPERATION_RECTANGLE_????? /////////////////////////////////////////////////// OPERATION_RECTANGLE_?????
void Rectangle_12_0(void); void Rectangle_12_0(void);
void Rectangle_12_5(void); void Rectangle_12_5(void);
void Rectangle_vide_0_5(void); void Empty_rectangle_0_5(void);
void Rectangle_plein_0_5(void); void Filled_rectangle_0_5(void);
////////////////////////////////////////////////////// OPERATION_CERCLE_????? ////////////////////////////////////////////////////// OPERATION_CERCLE_?????
void Cercle_12_0(void); void Circle_12_0(void);
void Cercle_12_5(void); void Circle_12_5(void);
void Cercle_vide_0_5(void); void Empty_circle_0_5(void);
void Cercle_plein_0_5(void); void Filled_circle_0_5(void);
///////////////////////////////////////////////////// OPERATION_ELLIPSE_????? ///////////////////////////////////////////////////// OPERATION_ELLIPSE_?????
void Ellipse_12_0(void); void Ellipse_12_0(void);
void Ellipse_12_5(void); void Ellipse_12_5(void);
void Ellipse_vide_0_5(void); void Empty_ellipse_0_5(void);
void Ellipse_pleine_0_5(void); void Filled_ellipse_0_5(void);
////////////////////////////////////////////////////// OPERATION_PRISE_BROSSE ////////////////////////////////////////////////////// OPERATION_GRAB_BRUSH
void Brosse_12_0(void); void Brush_12_0(void);
void Brosse_12_5(void); void Brush_12_5(void);
void Brosse_0_5(void); void Brush_0_5(void);
///////////////////////////////////////////////////// OPERATION_ETIRER_BROSSE ///////////////////////////////////////////////////// OPERATION_STRETCH_BRUSH
void Etirer_brosse_12_0(void); void Stretch_brush_12_0(void);
void Etirer_brosse_1_7(void); void Stretch_brush_1_7(void);
void Etirer_brosse_0_7(void); void Stretch_brush_0_7(void);
void Etirer_brosse_2_7(void); void Stretch_brush_2_7(void);
//////////////////////////////////////////////////// OPERATION_TOURNER_BROSSE //////////////////////////////////////////////////// OPERATION_ROTATE_BRUSH
void Tourner_brosse_12_0(void); void Rotate_brush_12_0(void);
void Tourner_brosse_1_5(void); void Rotate_brush_1_5(void);
void Tourner_brosse_0_5(void); void Rotate_brush_0_5(void);
void Tourner_brosse_2_5(void); void Rotate_brush_2_5(void);
//////////////////////////////////////////////////////// OPERATION_POLYBROSSE //////////////////////////////////////////////////////// OPERATION_POLYBRUSH
void Polybrosse_12_8(void); void Polybrush_12_8(void);
////////////////////////////////////////////////////////////// OPERATION_FILL ////////////////////////////////////////////////////////////// OPERATION_FILL
void Fill_1_0(void); void Fill_1_0(void);
void Fill_2_0(void); void Fill_2_0(void);
///////////////////////////////////////////////////////// OPERATION_REMPLACER ///////////////////////////////////////////////////////// OPERATION_REPLACE
void Remplacer_1_0(void); void Replace_1_0(void);
void Remplacer_2_0(void); void Replace_2_0(void);
/////////////////////////////////////////////////////////// OPERATION_PIPETTE /////////////////////////////////////////////////////////// OPERATION_COLORPICK
void Pipette_0_0(void); void Pipette_0_0(void);
void Pipette_12_0(void); void Colorpicker_12_0(void);
void Pipette_1_1(void); void Colorpicker_1_1(void);
void Pipette_2_1(void); void Colorpicker_2_1(void);
void Pipette_0_1(void); void Colorpicker_0_1(void);
/////////////////////////////////////////////////////////// OPERATION_K_LIGNE /////////////////////////////////////////////////////////// OPERATION_K_LIGNE
void K_Ligne_12_0(void); void K_line_12_0(void);
void K_Ligne_12_6(void); void K_line_12_6(void);
void K_Ligne_0_6(void); void K_line_0_6(void);
void K_Ligne_12_7(void); void K_line_12_7(void);
/////////////////////////////////////////////////// OPERATION_COURBE_?_POINTS /////////////////////////////////////////////////// OPERATION_COURBE_?_POINTS
void Courbe_34_points_1_0(void); void Curve_34_points_1_0(void);
void Courbe_34_points_2_0(void); void Curve_34_points_2_0(void);
void Courbe_34_points_1_5(void); void Curve_34_points_1_5(void);
void Courbe_34_points_2_5(void); void Curve_34_points_2_5(void);
void Courbe_4_points_0_5(void); void Curve_4_points_0_5(void);
void Courbe_4_points_1_9(void); void Curve_4_points_1_9(void);
void Courbe_4_points_2_9(void); void Curve_4_points_2_9(void);
void Courbe_3_points_0_5(void); void Curve_3_points_0_5(void);
void Courbe_3_points_0_11(void); void Curve_3_points_0_11(void);
void Courbe_3_points_12_11(void); void Curve_3_points_12_11(void);
///////////////////////////////////////////////////////////// OPERATION_SPRAY ///////////////////////////////////////////////////////////// OPERATION_AIRBRUSH
void Spray_1_0(void); void Airbrush_1_0(void);
void Spray_2_0(void); void Airbrush_2_0(void);
void Spray_12_2(void); void Airbrush_12_2(void);
void Spray_0_2(void); void Airbrush_0_2(void);
//////////////////////////////////////////////////////////// OPERATION_*POLY* //////////////////////////////////////////////////////////// OPERATION_*POLY*
void Polygone_12_0(void); void Polygon_12_0(void);
void Polygone_12_9(void); void Polygon_12_9(void);
void Polyfill_12_0(void); void Polyfill_12_0(void);
void Polyfill_0_8(void); void Polyfill_0_8(void);
@ -167,36 +167,36 @@ void Scroll_12_0(void);
void Scroll_12_4(void); void Scroll_12_4(void);
void Scroll_0_4(void); void Scroll_0_4(void);
//////////////////////////////////////////////////// OPERATION_CERCLE_DEGRADE //////////////////////////////////////////////////// OPERATION_GRAD_CIRCLE
void Cercle_degrade_12_0(void); void Grad_circle_12_0(void);
void Cercle_degrade_12_6(void); void Grad_circle_12_6(void);
void Cercle_degrade_0_6(void); void Grad_circle_0_6(void);
void Cercle_degrade_12_8(void); void Grad_circle_12_8(void);
void Cercle_ou_ellipse_degrade_0_8(void); void Grad_circle_or_ellipse_0_8(void);
////////////////////////////////////////////////// OPERATION_ELLIPSE_DEGRADEE ////////////////////////////////////////////////// OPERATION_GRAD_ELLIPSE
void Ellipse_degradee_12_0(void); void Grad_ellipse_12_0(void);
void Ellipse_degradee_12_6(void); void Grad_ellipse_12_6(void);
void Ellipse_degradee_0_6(void); void Grad_ellipse_0_6(void);
void Ellipse_degradee_12_8(void); void Grad_ellipse_12_8(void);
///////////////////////////////////////////////// OPERATION_RECTANGLE_DEGRADE ///////////////////////////////////////////////// OPERATION_GRAD_RECTANGLE
void Rectangle_Degrade_12_0(void); void Grad_rectangle_12_0(void);
void Rectangle_Degrade_12_5(void); void Grad_rectangle_12_5(void);
void Rectangle_Degrade_0_5(void); void Grad_rectangle_0_5(void);
void Rectangle_Degrade_0_7(void); void Grad_rectangle_0_7(void);
void Rectangle_Degrade_12_7(void); void Grad_rectangle_12_7(void);
void Rectangle_Degrade_12_9(void); void Grad_rectangle_12_9(void);
void Rectangle_Degrade_0_9(void); void Grad_rectangle_0_9(void);
/////////////////////////////////////////////////// OPERATION_LIGNES_CENTREES /////////////////////////////////////////////////// OPERATION_CENTERED_LINES
void Lignes_centrees_12_0(void); void Centered_lines_12_0(void);
void Lignes_centrees_12_3(void); void Centered_lines_12_3(void);
void Lignes_centrees_0_3(void); void Centered_lines_0_3(void);
void Lignes_centrees_12_7(void); void Centered_lines_12_7(void);
void Lignes_centrees_0_7(void); void Centered_lines_0_7(void);

872
pages.c

File diff suppressed because it is too large Load Diff

60
pages.h
View File

@ -31,16 +31,16 @@
/// GESTION DES PAGES /// GESTION DES PAGES
/// ///
void Initialiser_S_Page(S_Page * Page); void Init_page(T_Page * page);
void Download_infos_page_principal(S_Page * Page); void Download_infos_page_main(T_Page * page);
void Upload_infos_page_principal(S_Page * Page); void Upload_infos_page_main(T_Page * page);
void Download_infos_page_brouillon(S_Page * Page); void Download_infos_page_spare(T_Page * page);
void Upload_infos_page_brouillon(S_Page * Page); void Upload_infos_page_spare(T_Page * page);
void Download_infos_backup(S_Liste_de_pages * list); void Download_infos_backup(T_List_of_pages * list);
int Allouer_une_page(S_Page * Page,int width,int height); int Allocate_page(T_Page * page,int width,int height);
void Liberer_une_page(S_Page * Page); void Free_a_page(T_Page * page);
void Copier_S_page(S_Page * dest,S_Page * Source); void Copy_S_page(T_Page * dest,T_Page * source);
int Taille_d_une_page(S_Page * Page); int Size_of_a_page(T_Page * page);
@ -48,17 +48,17 @@ int Taille_d_une_page(S_Page * Page);
/// GESTION DES LISTES DE PAGES /// GESTION DES LISTES DE PAGES
/// ///
void Initialiser_S_Liste_de_pages(S_Liste_de_pages * list); void Init_list_of_pages(T_List_of_pages * list);
int Allouer_une_liste_de_pages(S_Liste_de_pages * list,int size); int Allocate_list_of_pages(T_List_of_pages * list,int size);
void Liberer_une_liste_de_pages(S_Liste_de_pages * list); void Free_a_list_of_pages(T_List_of_pages * list);
int Taille_d_une_liste_de_pages(S_Liste_de_pages * list); int Size_of_a_list_of_pages(T_List_of_pages * list);
void Reculer_dans_une_liste_de_pages(S_Liste_de_pages * list); void Backward_in_list_of_pages(T_List_of_pages * list);
void Avancer_dans_une_liste_de_pages(S_Liste_de_pages * list); void Advance_in_list_of_pages(T_List_of_pages * list);
int Nouvelle_page_possible(S_Page * Nouvelle_page,S_Liste_de_pages * Liste_courante,S_Liste_de_pages * Liste_secondaire); int New_page_is_possible(T_Page * new_page,T_List_of_pages * current_list,T_List_of_pages * secondary_list);
void Detruire_derniere_page_allouee_de_la_liste(S_Liste_de_pages * list); void Free_last_page_of_list(T_List_of_pages * list);
void Creer_nouvelle_page(S_Page * Nouvelle_page,S_Liste_de_pages * Liste_courante,S_Liste_de_pages * Liste_secondaire); void Create_new_page(T_Page * new_page,T_List_of_pages * current_list,T_List_of_pages * secondary_list);
void Changer_nombre_de_pages_d_une_liste(S_Liste_de_pages * list,int number); void Change_page_number_of_list(T_List_of_pages * list,int number);
void Detruire_la_page_courante_d_une_liste(S_Liste_de_pages * list); void Free_page_of_a_list(T_List_of_pages * list);
@ -66,16 +66,16 @@ void Detruire_la_page_courante_d_une_liste(S_Liste_de_pages * list);
/// GESTION DES BACKUPS /// GESTION DES BACKUPS
/// ///
int Initialiser_les_listes_de_backups_en_debut_de_programme(int size,int width,int height); int Init_all_backup_lists(int size,int width,int height);
void Detruire_les_listes_de_backups_en_fin_de_programme(void); void Free_all_backup_lists(void);
void Nouveau_nombre_de_backups(int nb_backups); void Set_number_of_backups(int nb_backups);
int Backup_avec_nouvelles_dimensions(int Upload,int width,int height); int Backup_with_new_dimensions(int upload,int width,int height);
int Backuper_et_redimensionner_brouillon(int width,int height); int Backup_and_resize_the_spare(int width,int height);
void Backup(void); void Backup(void);
void Undo(void); void Undo(void);
void Redo(void); void Redo(void);
void Detruire_la_page_courante(void); void Free_current_page(void);
void Interchanger_image_principale_et_brouillon(void); void Exchange_main_and_spare(void);
@ -83,8 +83,8 @@ void Interchanger_image_principale_et_brouillon(void);
/// GESTION DES EMPRUNTS DE MEMOIRE DE PAGE /// GESTION DES EMPRUNTS DE MEMOIRE DE PAGE
/// ///
int Emprunt_memoire_de_page_possible(int size); int Can_borrow_memory_from_page(int size);
void * Emprunter_memoire_de_page(int size); void * Borrow_memory_from_page(int size);

2216
palette.c

File diff suppressed because it is too large Load Diff

View File

@ -18,13 +18,13 @@
write to the Free Software Foundation, Inc., write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
void Bouton_Palette(void); void Button_Palette(void);
void Bouton_Palette_secondaire(void); void Button_Pecondary_palette(void);
// Choose the number of graduations for RGB components, from 2 to 256. // Choose the number of graduations for RGB components, from 2 to 256.
void Set_Palette_RGB_Scale(int); void Set_palette_RGB_scale(int);
// Scale a component (R, G or B) according to the current RGB graduations // Scale a component (R, G or B) according to the current RGB graduations
// The resulting range is [0-255] // The resulting range is [0-255]
byte Palette_Scale_Component(byte comp); byte Round_palette_component(byte comp);

View File

@ -27,42 +27,42 @@
#include "global.h" #include "global.h"
#include "sdlscreen.h" #include "sdlscreen.h"
#include "divers.h" #include "divers.h"
#include "pxwide.h" // for Afficher_une_ligne_transparente_a_l_ecran_Wide() #include "pxwide.h" // for Display_transparent_line_on_screen_wide()
#define ZOOMX 2 #define ZOOMX 2
#define ZOOMY 2 #define ZOOMY 2
void Pixel_Double (word x,word y,byte Couleur) void Pixel_double (word x,word y,byte color)
/* Affiche un pixel de la Couleur aux coords x;y à l'écran */ /* Affiche un pixel de la color aux coords x;y à l'écran */
{ {
*(Ecran + x * 2 + y * 4 * Largeur_ecran)=Couleur; *(Screen + x * 2 + y * 4 * Screen_width)=color;
*(Ecran + x * 2 + y * 4 * Largeur_ecran + 1)=Couleur; *(Screen + x * 2 + y * 4 * Screen_width + 1)=color;
*(Ecran + x * 2 + (y * 4 + 2 )* Largeur_ecran)=Couleur; *(Screen + x * 2 + (y * 4 + 2 )* Screen_width)=color;
*(Ecran + x * 2 + (y * 4 + 2 )* Largeur_ecran + 1)=Couleur; *(Screen + x * 2 + (y * 4 + 2 )* Screen_width + 1)=color;
} }
byte Lit_Pixel_Double (word x,word y) byte Read_pixel_double (word x,word y)
/* On retourne la couleur du pixel aux coords données */ /* On retourne la couleur du pixel aux coords données */
{ {
return *( Ecran + y * 4 * Largeur_ecran + x * 2); return *( Screen + y * 4 * Screen_width + x * 2);
} }
void Block_Double (word Debut_X,word Debut_Y,word width,word height,byte Couleur) void Block_double (word start_x,word start_y,word width,word height,byte color)
/* On affiche un rectangle de la couleur donnée */ /* On affiche un rectangle de la couleur donnée */
{ {
SDL_Rect rectangle; SDL_Rect rectangle;
rectangle.x=Debut_X*2; rectangle.x=start_x*2;
rectangle.y=Debut_Y*2; rectangle.y=start_y*2;
rectangle.w=width*2; rectangle.w=width*2;
rectangle.h=height*2; rectangle.h=height*2;
SDL_FillRect(Ecran_SDL,&rectangle,Couleur); SDL_FillRect(Screen_SDL,&rectangle,color);
} }
void Afficher_partie_de_l_ecran_Double (word width,word height,word image_width) void Display_part_of_screen_double (word width,word height,word image_width)
/* Afficher une partie de l'image telle quelle sur l'écran */ /* Afficher une partie de l'image telle quelle sur l'écran */
{ {
byte* Dest=Ecran; //On va se mettre en 0,0 dans l'écran (Dest) byte* dest=Screen; //On va se mettre en 0,0 dans l'écran (dest)
byte* Src=Principal_Decalage_Y*image_width+Principal_Decalage_X+Principal_Ecran; //Coords de départ ds la source (Src) byte* src=Main_offset_Y*image_width+Main_offset_X+Main_screen; //Coords de départ ds la source (src)
int y; int y;
int dy; int dy;
@ -72,85 +72,85 @@ void Afficher_partie_de_l_ecran_Double (word width,word height,word image_width)
// On fait une copie de la ligne // On fait une copie de la ligne
for (dy=width;dy>0;dy--) for (dy=width;dy>0;dy--)
{ {
*(Dest+1)=*Dest=*Src; *(dest+1)=*dest=*src;
Src++; src++;
Dest+=2; dest+=2;
} }
// On double la ligne qu'on vient de copier // On double la ligne qu'on vient de copier
memcpy(Dest-width*ZOOMX+Largeur_ecran*ZOOMX,Dest-width*ZOOMX,width*ZOOMX); memcpy(dest-width*ZOOMX+Screen_width*ZOOMX,dest-width*ZOOMX,width*ZOOMX);
// On passe à la ligne suivante // On passe à la ligne suivante
Src+=image_width-width; src+=image_width-width;
Dest+=Largeur_ecran*4 - width*2; dest+=Screen_width*4 - width*2;
} }
//UpdateRect(0,0,width,height); //Update_rect(0,0,width,height);
} }
void Pixel_Preview_Normal_Double (word x,word y,byte Couleur) void Pixel_preview_normal_double (word x,word y,byte color)
/* Affichage d'un pixel dans l'écran, par rapport au décalage de l'image /* Affichage d'un pixel dans l'écran, par rapport au décalage de l'image
* dans l'écran, en mode normal (pas en mode loupe) * dans l'écran, en mode normal (pas en mode loupe)
* Note: si on modifie cette procédure, il faudra penser à faire également * Note: si on modifie cette procédure, il faudra penser à faire également
* la modif dans la procédure Pixel_Preview_Loupe_SDL. */ * la modif dans la procédure Pixel_Preview_Loupe_SDL. */
{ {
// if(x-Principal_Decalage_X >= 0 && y - Principal_Decalage_Y >= 0) // if(x-Main_offset_X >= 0 && y - Main_offset_Y >= 0)
Pixel_Double(x-Principal_Decalage_X,y-Principal_Decalage_Y,Couleur); Pixel_double(x-Main_offset_X,y-Main_offset_Y,color);
} }
void Pixel_Preview_Loupe_Double (word x,word y,byte Couleur) void Pixel_preview_magnifier_double (word x,word y,byte color)
{ {
// Affiche le pixel dans la partie non zoomée // Affiche le pixel dans la partie non zoomée
Pixel_Double(x-Principal_Decalage_X,y-Principal_Decalage_Y,Couleur); Pixel_double(x-Main_offset_X,y-Main_offset_Y,color);
// Regarde si on doit aussi l'afficher dans la partie zoomée // Regarde si on doit aussi l'afficher dans la partie zoomée
if (y >= Limite_Haut_Zoom && y <= Limite_visible_Bas_Zoom if (y >= Limit_top_zoom && y <= Limit_visible_bottom_zoom
&& x >= Limite_Gauche_Zoom && x <= Limite_visible_Droite_Zoom) && x >= Limit_left_zoom && x <= Limit_visible_right_zoom)
{ {
// On est dedans // On est dedans
int height; int height;
int Y_Zoom = Table_mul_facteur_zoom[y-Loupe_Decalage_Y]; int y_zoom = Zoom_factor_table[y-Main_magnifier_offset_Y];
if (Menu_Ordonnee - Y_Zoom < Loupe_Facteur) if (Menu_Y - y_zoom < Main_magnifier_factor)
// On ne doit dessiner qu'un morceau du pixel // On ne doit dessiner qu'un morceau du pixel
// sinon on dépasse sur le menu // sinon on dépasse sur le menu
height = Menu_Ordonnee - Y_Zoom; height = Menu_Y - y_zoom;
else else
height = Loupe_Facteur; height = Main_magnifier_factor;
Block_Double( Block_double(
Table_mul_facteur_zoom[x-Loupe_Decalage_X]+Principal_X_Zoom, Zoom_factor_table[x-Main_magnifier_offset_X]+Main_X_zoom,
Y_Zoom, Loupe_Facteur, height, Couleur y_zoom, Main_magnifier_factor, height, color
); );
} }
} }
void Ligne_horizontale_XOR_Double(word x_pos,word y_pos,word width) void Horizontal_XOR_line_double(word x_pos,word y_pos,word width)
{ {
//On calcule la valeur initiale de Dest: //On calcule la valeur initiale de dest:
byte* Dest=y_pos*4*Largeur_ecran+x_pos*2+Ecran; byte* dest=y_pos*4*Screen_width+x_pos*2+Screen;
int x; int x;
for (x=0;x<width*2;x+=2) for (x=0;x<width*2;x+=2)
*(Dest+x+2*Largeur_ecran+1)=*(Dest+x+2*Largeur_ecran)=*(Dest+x+1)=*(Dest+x)=~*(Dest+x); *(dest+x+2*Screen_width+1)=*(dest+x+2*Screen_width)=*(dest+x+1)=*(dest+x)=~*(dest+x);
} }
void Ligne_verticale_XOR_Double(word x_pos,word y_pos,word height) void Vertical_XOR_line_double(word x_pos,word y_pos,word height)
{ {
int i; int i;
byte *Dest=Ecran+x_pos*2+y_pos*Largeur_ecran*4; byte *dest=Screen+x_pos*2+y_pos*Screen_width*4;
for (i=height;i>0;i--) for (i=height;i>0;i--)
{ {
*Dest=*(Dest+1)=*(Dest+Largeur_ecran*2)=*(Dest+Largeur_ecran*2+1)=~*Dest; *dest=*(dest+1)=*(dest+Screen_width*2)=*(dest+Screen_width*2+1)=~*dest;
Dest+=Largeur_ecran*4; dest+=Screen_width*4;
} }
} }
void Display_brush_Color_Double(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte Couleur_de_transparence,word Largeur_brosse) void Display_brush_color_double(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)
{ {
// Dest = Position à l'écran // dest = Position à l'écran
byte* Dest = Ecran + y_pos * 4 * Largeur_ecran + x_pos * 2; byte* dest = Screen + y_pos * 4 * Screen_width + x_pos * 2;
// Src = Position dans la brosse // src = Position dans la brosse
byte* Src = Brosse + y_offset * Largeur_brosse + x_offset; byte* src = Brush + y_offset * brush_width + x_offset;
word x,y; word x,y;
@ -161,31 +161,31 @@ void Display_brush_Color_Double(word x_pos,word y_pos,word x_offset,word y_offse
for(x = width;x > 0; x--) for(x = width;x > 0; x--)
{ {
// On vérifie que ce n'est pas la transparence // On vérifie que ce n'est pas la transparence
if(*Src != Couleur_de_transparence) if(*src != transp_color)
{ {
*(Dest+Largeur_ecran*2+1) = *(Dest+Largeur_ecran*2) = *(Dest+1) = *Dest = *Src; *(dest+Screen_width*2+1) = *(dest+Screen_width*2) = *(dest+1) = *dest = *src;
} }
// Pixel suivant // Pixel suivant
Src++; src++;
Dest+=2; dest+=2;
} }
// On passe à la ligne suivante // On passe à la ligne suivante
Dest = Dest + Largeur_ecran*4 - width*2; dest = dest + Screen_width*4 - width*2;
Src = Src + Largeur_brosse - width; src = src + brush_width - width;
} }
UpdateRect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
} }
void Display_brush_Mono_Double(word x_pos, word y_pos, void Display_brush_mono_double(word x_pos, word y_pos,
word x_offset, word y_offset, word width, word height, word x_offset, word y_offset, word width, word height,
byte Couleur_de_transparence, byte Couleur, word Largeur_brosse) byte transp_color, byte color, word brush_width)
/* On affiche la brosse en monochrome */ /* On affiche la brosse en monochrome */
{ {
byte* Dest=y_pos*4*Largeur_ecran+x_pos*2+Ecran; // Dest = adr destination à byte* dest=y_pos*4*Screen_width+x_pos*2+Screen; // dest = adr destination à
// l'écran // l'écran
byte* Src=Largeur_brosse*y_offset+x_offset+Brosse; // Src = adr ds byte* src=brush_width*y_offset+x_offset+Brush; // src = adr ds
// la brosse // la brosse
int x,y; int x,y;
@ -195,25 +195,25 @@ void Display_brush_Mono_Double(word x_pos, word y_pos,
for(x=width;x!=0;x--) for(x=width;x!=0;x--)
//Pour chaque pixel //Pour chaque pixel
{ {
if (*Src!=Couleur_de_transparence) if (*src!=transp_color)
*(Dest+Largeur_ecran*2+1)=*(Dest+Largeur_ecran*2)=*(Dest+1)=*Dest=Couleur; *(dest+Screen_width*2+1)=*(dest+Screen_width*2)=*(dest+1)=*dest=color;
// On passe au pixel suivant // On passe au pixel suivant
Src++; src++;
Dest+=2; dest+=2;
} }
// On passe à la ligne suivante // On passe à la ligne suivante
Src+=Largeur_brosse-width; src+=brush_width-width;
Dest+=Largeur_ecran*4-width*2; dest+=Screen_width*4-width*2;
} }
UpdateRect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
} }
void Clear_brush_Double(word x_pos,word y_pos,__attribute__((unused)) word x_offset,__attribute__((unused)) word y_offset,word width,word height,__attribute__((unused))byte Couleur_de_transparence,word image_width) void Clear_brush_double(word x_pos,word y_pos,__attribute__((unused)) word x_offset,__attribute__((unused)) word y_offset,word width,word height,__attribute__((unused))byte transp_color,word image_width)
{ {
byte* Dest=Ecran+x_pos*2+y_pos*4*Largeur_ecran; //On va se mettre en 0,0 dans l'écran (Dest) byte* dest=Screen+x_pos*2+y_pos*4*Screen_width; //On va se mettre en 0,0 dans l'écran (dest)
byte* Src = ( y_pos + Principal_Decalage_Y ) * image_width + x_pos + Principal_Decalage_X + Principal_Ecran; //Coords de départ ds la source (Src) byte* src = ( y_pos + Main_offset_Y ) * image_width + x_pos + Main_offset_X + Main_screen; //Coords de départ ds la source (src)
int y; int y;
int x; int x;
@ -223,27 +223,27 @@ void Clear_brush_Double(word x_pos,word y_pos,__attribute__((unused)) word x_off
for(x=width;x!=0;x--) for(x=width;x!=0;x--)
//Pour chaque pixel //Pour chaque pixel
{ {
*(Dest+Largeur_ecran*2+1)=*(Dest+Largeur_ecran*2)=*(Dest+1)=*Dest=*Src; *(dest+Screen_width*2+1)=*(dest+Screen_width*2)=*(dest+1)=*dest=*src;
// On passe au pixel suivant // On passe au pixel suivant
Src++; src++;
Dest+=2; dest+=2;
} }
// On passe à la ligne suivante // On passe à la ligne suivante
Src+=image_width-width; src+=image_width-width;
Dest+=Largeur_ecran*4-width*2; dest+=Screen_width*4-width*2;
} }
UpdateRect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
} }
// Affiche une brosse (arbitraire) à l'écran // Affiche une brosse (arbitraire) à l'écran
void Affiche_brosse_Double(byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte Couleur_de_transparence,word Largeur_brosse) void Display_brush_double(byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)
{ {
// Dest = Position à l'écran // dest = Position à l'écran
byte* Dest = Ecran + y_pos * 4 * Largeur_ecran + x_pos * 2; byte* dest = Screen + y_pos * 4 * Screen_width + x_pos * 2;
// Src = Position dans la brosse // src = Position dans la brosse
byte* Src = brush + y_offset * Largeur_brosse + x_offset; byte* src = brush + y_offset * brush_width + x_offset;
word x,y; word x,y;
@ -254,25 +254,25 @@ void Affiche_brosse_Double(byte * brush, word x_pos,word y_pos,word x_offset,wor
for(x = width;x > 0; x--) for(x = width;x > 0; x--)
{ {
// On vérifie que ce n'est pas la transparence // On vérifie que ce n'est pas la transparence
if(*Src != Couleur_de_transparence) if(*src != transp_color)
{ {
*(Dest+Largeur_ecran*2+1)=*(Dest+Largeur_ecran*2)=*(Dest+1)=*Dest=*Src; *(dest+Screen_width*2+1)=*(dest+Screen_width*2)=*(dest+1)=*dest=*src;
} }
// Pixel suivant // Pixel suivant
Src++; Dest+=2; src++; dest+=2;
} }
// On passe à la ligne suivante // On passe à la ligne suivante
Dest = Dest + Largeur_ecran*4 - width*2; dest = dest + Screen_width*4 - width*2;
Src = Src + Largeur_brosse - width; src = src + brush_width - width;
} }
} }
void Remap_screen_Double(word x_pos,word y_pos,word width,word height,byte * Table_de_conversion) void Remap_screen_double(word x_pos,word y_pos,word width,word height,byte * conversion_table)
{ {
// Dest = coords a l'écran // dest = coords a l'écran
byte* Dest = Ecran + y_pos * 4 * Largeur_ecran + x_pos * 2; byte* dest = Screen + y_pos * 4 * Screen_width + x_pos * 2;
int x,y; int x,y;
// Pour chaque ligne // Pour chaque ligne
@ -281,70 +281,70 @@ void Remap_screen_Double(word x_pos,word y_pos,word width,word height,byte * Tab
// Pour chaque pixel // Pour chaque pixel
for(x=width;x>0;x--) for(x=width;x>0;x--)
{ {
*(Dest+Largeur_ecran*2+1)=*(Dest+Largeur_ecran*2)=*(Dest+1)=*Dest= *(dest+Screen_width*2+1)=*(dest+Screen_width*2)=*(dest+1)=*dest=
Table_de_conversion[*Dest]; conversion_table[*dest];
Dest +=2; dest +=2;
} }
Dest = Dest + Largeur_ecran*4 - width*2; dest = dest + Screen_width*4 - width*2;
} }
UpdateRect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
} }
void Afficher_une_ligne_ecran_fast_Double(word x_pos,word y_pos,word width,byte * line) void Display_line_on_screen_fast_double(word x_pos,word y_pos,word width,byte * line)
/* On affiche toute une ligne de pixels telle quelle. */ /* On affiche toute une ligne de pixels telle quelle. */
/* Utilisée si le buffer contient déja des pixel doublés. */ /* Utilisée si le buffer contient déja des pixel doublés. */
{ {
memcpy(Ecran+x_pos*2+y_pos*4*Largeur_ecran,line,width*2); memcpy(Screen+x_pos*2+y_pos*4*Screen_width,line,width*2);
memcpy(Ecran+x_pos*2+(y_pos*4+2)*Largeur_ecran,line,width*2); memcpy(Screen+x_pos*2+(y_pos*4+2)*Screen_width,line,width*2);
} }
void Afficher_une_ligne_ecran_Double(word x_pos,word y_pos,word width,byte * line) void Display_line_on_screen_double(word x_pos,word y_pos,word width,byte * line)
/* On affiche une ligne de pixels en les doublant. */ /* On affiche une ligne de pixels en les doublant. */
{ {
int x; int x;
byte *Dest; byte *dest;
Dest=Ecran+x_pos*2+y_pos*4*Largeur_ecran; dest=Screen+x_pos*2+y_pos*4*Screen_width;
for(x=width;x>0;x--) for(x=width;x>0;x--)
{ {
*(Dest+Largeur_ecran*2+1)=*(Dest+Largeur_ecran*2)=*(Dest+1)=*Dest=*line; *(dest+Screen_width*2+1)=*(dest+Screen_width*2)=*(dest+1)=*dest=*line;
Dest+=2; dest+=2;
line++; line++;
} }
} }
void Afficher_une_ligne_transparente_mono_a_l_ecran_Double( void Display_transparent_mono_line_on_screen_double(
word x_pos, word y_pos, word width, byte* line, word x_pos, word y_pos, word width, byte* line,
byte Couleur_transparence, byte Couleur) byte transp_color, byte color)
// Affiche une ligne à l'écran avec une couleur + transparence. // Affiche une ligne à l'écran avec une couleur + transparence.
// Utilisé par les brosses en mode zoom // Utilisé par les brosses en mode zoom
{ {
byte* Dest = Ecran+ y_pos*ZOOMX*Largeur_ecran + x_pos*ZOOMX; byte* dest = Screen+ y_pos*ZOOMX*Screen_width + x_pos*ZOOMX;
int x; int x;
// Pour chaque pixel // Pour chaque pixel
for(x=0;x<width;x++) for(x=0;x<width;x++)
{ {
if (Couleur_transparence!=*line) if (transp_color!=*line)
{ {
*(Dest+1)=*Dest=Couleur; *(dest+1)=*dest=color;
} }
line ++; // Pixel suivant line ++; // Pixel suivant
Dest+=2; dest+=2;
} }
} }
void Lire_une_ligne_ecran_Double(word x_pos,word y_pos,word width,byte * line) void Read_line_screen_double(word x_pos,word y_pos,word width,byte * line)
{ {
memcpy(line,Largeur_ecran * 4 * y_pos + x_pos * 2 + Ecran,width*2); memcpy(line,Screen_width * 4 * y_pos + x_pos * 2 + Screen,width*2);
} }
void Afficher_partie_de_l_ecran_zoomee_Double( void Display_part_of_screen_scaled_double(
word width, // width non zoomée word width, // width non zoomée
word height, // height zoomée word height, // height zoomée
word image_width,byte * Buffer) word image_width,byte * buffer)
{ {
byte* Src = Principal_Ecran + Loupe_Decalage_Y * image_width byte* src = Main_screen + Main_magnifier_offset_Y * image_width
+ Loupe_Decalage_X; + Main_magnifier_offset_X;
int y = 0; // Ligne en cours de traitement int y = 0; // Ligne en cours de traitement
// Pour chaque ligne à zoomer // Pour chaque ligne à zoomer
@ -353,147 +353,147 @@ void Afficher_partie_de_l_ecran_zoomee_Double(
int x; int x;
// On éclate la ligne // On éclate la ligne
Zoomer_une_ligne(Src,Buffer,Loupe_Facteur*ZOOMX,width); Zoom_a_line(src,buffer,Main_magnifier_factor*ZOOMX,width);
// On l'affiche Facteur fois, sur des lignes consécutives // On l'affiche Facteur fois, sur des lignes consécutives
x = Loupe_Facteur/**ZOOMY*/; x = Main_magnifier_factor/**ZOOMY*/;
// Pour chaque ligne // Pour chaque ligne
do{ do{
// On affiche la ligne zoomée // On affiche la ligne zoomée
Afficher_une_ligne_ecran_fast_Double( Display_line_on_screen_fast_double(
Principal_X_Zoom, y, width*Loupe_Facteur, Main_X_zoom, y, width*Main_magnifier_factor,
Buffer buffer
); );
// On passe à la suivante // On passe à la suivante
y++; y++;
if(y==height/**ZOOMY*/) if(y==height/**ZOOMY*/)
{ {
UpdateRect(Principal_X_Zoom,0, Update_rect(Main_X_zoom,0,
width*Loupe_Facteur,height); width*Main_magnifier_factor,height);
return; return;
} }
x--; x--;
}while (x > 0); }while (x > 0);
Src += image_width; src += image_width;
} }
// ATTENTION on n'arrive jamais ici ! // ATTENTION on n'arrive jamais ici !
} }
// Affiche une partie de la brosse couleur zoomée // Affiche une partie de la brosse couleur zoomée
void Display_brush_Color_zoom_Double(word x_pos,word y_pos, void Display_brush_color_zoom_double(word x_pos,word y_pos,
word x_offset,word y_offset, word x_offset,word y_offset,
word width, // width non zoomée word width, // width non zoomée
word Pos_Y_Fin,byte Couleur_de_transparence, word end_y_pos,byte transp_color,
word Largeur_brosse, // width réelle de la brosse word brush_width, // width réelle de la brosse
byte * Buffer) byte * buffer)
{ {
byte* Src = Brosse+y_offset*Largeur_brosse + x_offset; byte* src = Brush+y_offset*brush_width + x_offset;
word y = y_pos; word y = y_pos;
byte bx; byte bx;
// Pour chaque ligne // Pour chaque ligne
while(1) while(1)
{ {
Zoomer_une_ligne(Src,Buffer,Loupe_Facteur,width); Zoom_a_line(src,buffer,Main_magnifier_factor,width);
// On affiche facteur fois la ligne zoomée // On affiche facteur fois la ligne zoomée
for(bx=Loupe_Facteur;bx>0;bx--) for(bx=Main_magnifier_factor;bx>0;bx--)
{ {
Afficher_une_ligne_transparente_a_l_ecran_Wide(x_pos,y*ZOOMX,width*Loupe_Facteur,Buffer,Couleur_de_transparence); Display_transparent_line_on_screen_wide(x_pos,y*ZOOMX,width*Main_magnifier_factor,buffer,transp_color);
// TODO: pas clair ici // TODO: pas clair ici
memcpy(Ecran + (y*ZOOMY+1)*ZOOMX*Largeur_ecran + x_pos*ZOOMX, Ecran + y*ZOOMX*ZOOMY*Largeur_ecran + x_pos*ZOOMX, width*ZOOMX*Loupe_Facteur); memcpy(Screen + (y*ZOOMY+1)*ZOOMX*Screen_width + x_pos*ZOOMX, Screen + y*ZOOMX*ZOOMY*Screen_width + x_pos*ZOOMX, width*ZOOMX*Main_magnifier_factor);
y++; y++;
if(y==Pos_Y_Fin) if(y==end_y_pos)
{ {
return; return;
} }
} }
Src += Largeur_brosse; src += brush_width;
} }
// ATTENTION zone jamais atteinte // ATTENTION zone jamais atteinte
} }
void Display_brush_Mono_zoom_Double(word x_pos, word y_pos, void Display_brush_mono_zoom_double(word x_pos, word y_pos,
word x_offset, word y_offset, word x_offset, word y_offset,
word width, // width non zoomée word width, // width non zoomée
word Pos_Y_Fin, word end_y_pos,
byte Couleur_de_transparence, byte Couleur, byte transp_color, byte color,
word Largeur_brosse, // width réelle de la brosse word brush_width, // width réelle de la brosse
byte * Buffer byte * buffer
) )
{ {
byte* Src = Brosse + y_offset * Largeur_brosse + x_offset; byte* src = Brush + y_offset * brush_width + x_offset;
int y=y_pos*ZOOMY; int y=y_pos*ZOOMY;
//Pour chaque ligne à zoomer : //Pour chaque ligne à zoomer :
while(1) while(1)
{ {
int BX; int bx;
// Src = Ligne originale // src = Ligne originale
// On éclate la ligne // On éclate la ligne
Zoomer_une_ligne(Src,Buffer,Loupe_Facteur,width); Zoom_a_line(src,buffer,Main_magnifier_factor,width);
// On affiche la ligne Facteur fois à l'écran (sur des // On affiche la ligne Facteur fois à l'écran (sur des
// lignes consécutives) // lignes consécutives)
BX = Loupe_Facteur*ZOOMX; bx = Main_magnifier_factor*ZOOMX;
// Pour chaque ligne écran // Pour chaque ligne écran
do do
{ {
// On affiche la ligne zoomée // On affiche la ligne zoomée
Afficher_une_ligne_transparente_mono_a_l_ecran_Double( Display_transparent_mono_line_on_screen_double(
x_pos, y, width * Loupe_Facteur, x_pos, y, width * Main_magnifier_factor,
Buffer, Couleur_de_transparence, Couleur buffer, transp_color, color
); );
// On passe à la ligne suivante // On passe à la ligne suivante
y++; y++;
// On vérifie qu'on est pas à la ligne finale // On vérifie qu'on est pas à la ligne finale
if(y == Pos_Y_Fin*ZOOMX) if(y == end_y_pos*ZOOMX)
{ {
UpdateRect( x_pos, y_pos, Update_rect( x_pos, y_pos,
width * Loupe_Facteur, Pos_Y_Fin - y_pos ); width * Main_magnifier_factor, end_y_pos - y_pos );
return; return;
} }
BX --; bx --;
} }
while (BX > 0); while (bx > 0);
// Passage à la ligne suivante dans la brosse aussi // Passage à la ligne suivante dans la brosse aussi
Src+=Largeur_brosse; src+=brush_width;
} }
} }
void Clear_brush_zoom_Double(word x_pos,word y_pos,word x_offset,word y_offset,word width,word Pos_Y_Fin,__attribute__((unused)) byte Couleur_de_transparence,word image_width,byte * Buffer) void Clear_brush_scaled_double(word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,__attribute__((unused)) byte transp_color,word image_width,byte * buffer)
{ {
// En fait on va recopier l'image non zoomée dans la partie zoomée ! // En fait on va recopier l'image non zoomée dans la partie zoomée !
byte* Src = Principal_Ecran + y_offset * image_width + x_offset; byte* src = Main_screen + y_offset * image_width + x_offset;
int y = y_pos; int y = y_pos;
int bx; int bx;
// Pour chaque ligne à zoomer // Pour chaque ligne à zoomer
while(1){ while(1){
Zoomer_une_ligne(Src,Buffer,Loupe_Facteur*2,width); Zoom_a_line(src,buffer,Main_magnifier_factor*2,width);
bx=Loupe_Facteur; bx=Main_magnifier_factor;
// Pour chaque ligne // Pour chaque ligne
do{ do{
// TODO a verifier // TODO a verifier
Afficher_une_ligne_ecran_fast_Double(x_pos,y, Display_line_on_screen_fast_double(x_pos,y,
width * Loupe_Facteur,Buffer); width * Main_magnifier_factor,buffer);
// Ligne suivante // Ligne suivante
y++; y++;
if(y==Pos_Y_Fin) if(y==end_y_pos)
{ {
UpdateRect(x_pos,y_pos, Update_rect(x_pos,y_pos,
width*Loupe_Facteur,Pos_Y_Fin-y_pos); width*Main_magnifier_factor,end_y_pos-y_pos);
return; return;
} }
bx--; bx--;
}while(bx!=0); }while(bx!=0);
Src+= image_width; src+= image_width;
} }
} }

View File

@ -21,24 +21,24 @@
*/ */
#include "struct.h" #include "struct.h"
void Pixel_Double (word x,word y,byte Couleur); void Pixel_double (word x,word y,byte color);
byte Lit_Pixel_Double (word x,word y); byte Read_pixel_double (word x,word y);
void Block_Double (word Debut_X,word Debut_Y,word width,word height,byte Couleur); void Block_double (word start_x,word start_y,word width,word height,byte color);
void Pixel_Preview_Normal_Double (word x,word y,byte Couleur); void Pixel_preview_normal_double (word x,word y,byte color);
void Pixel_Preview_Loupe_Double (word x,word y,byte Couleur); void Pixel_preview_magnifier_double (word x,word y,byte color);
void Ligne_horizontale_XOR_Double (word x_pos,word y_pos,word width); void Horizontal_XOR_line_double (word x_pos,word y_pos,word width);
void Ligne_verticale_XOR_Double (word x_pos,word y_pos,word height); void Vertical_XOR_line_double (word x_pos,word y_pos,word height);
void Display_brush_Color_Double (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte Couleur_de_transparence,word Largeur_brosse); void Display_brush_color_double (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width);
void Display_brush_Mono_Double (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte Couleur_de_transparence,byte Couleur,word Largeur_brosse); void Display_brush_mono_double (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,byte color,word brush_width);
void Clear_brush_Double (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte Couleur_de_transparence,word image_width); void Clear_brush_double (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width);
void Remap_screen_Double (word x_pos,word y_pos,word width,word height,byte * Table_de_conversion); void Remap_screen_double (word x_pos,word y_pos,word width,word height,byte * conversion_table);
void Afficher_partie_de_l_ecran_Double (word width,word height,word image_width); void Display_part_of_screen_double (word width,word height,word image_width);
void Afficher_une_ligne_ecran_Double (word x_pos,word y_pos,word width,byte * line); void Display_line_on_screen_double (word x_pos,word y_pos,word width,byte * line);
void Lire_une_ligne_ecran_Double (word x_pos,word y_pos,word width,byte * line); void Read_line_screen_double (word x_pos,word y_pos,word width,byte * line);
void Afficher_partie_de_l_ecran_zoomee_Double(word width,word height,word image_width,byte * Buffer); void Display_part_of_screen_scaled_double(word width,word height,word image_width,byte * buffer);
void Display_brush_Color_zoom_Double (word x_pos,word y_pos,word x_offset,word y_offset,word width,word Pos_Y_Fin,byte Couleur_de_transparence,word Largeur_brosse,byte * Buffer); void Display_brush_color_zoom_double (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word brush_width,byte * buffer);
void Display_brush_Mono_zoom_Double (word x_pos,word y_pos,word x_offset,word y_offset,word width,word Pos_Y_Fin,byte Couleur_de_transparence,byte Couleur,word Largeur_brosse,byte * Buffer); void Display_brush_mono_zoom_double (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,byte color,word brush_width,byte * buffer);
void Clear_brush_zoom_Double (word x_pos,word y_pos,word x_offset,word y_offset,word width,word Pos_Y_Fin,byte Couleur_de_transparence,word image_width,byte * Buffer); void Clear_brush_scaled_double (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word image_width,byte * buffer);
void Affiche_brosse_Double (byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte Couleur_de_transparence,word Largeur_brosse); void Display_brush_double (byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width);
void Afficher_une_ligne_ecran_fast_Double (word x_pos,word y_pos,word width,byte * line); void Display_line_on_screen_fast_double (word x_pos,word y_pos,word width,byte * line);

View File

@ -28,114 +28,114 @@
#include "sdlscreen.h" #include "sdlscreen.h"
#include "divers.h" #include "divers.h"
void Pixel_Simple (word x,word y,byte Couleur) void Pixel_simple (word x,word y,byte color)
/* Affiche un pixel de la Couleur aux coords x;y à l'écran */ /* Affiche un pixel de la color aux coords x;y à l'écran */
{ {
*(Ecran + x + y * Largeur_ecran)=Couleur; *(Screen + x + y * Screen_width)=color;
} }
byte Lit_Pixel_Simple (word x,word y) byte Read_pixel_simple (word x,word y)
/* On retourne la couleur du pixel aux coords données */ /* On retourne la couleur du pixel aux coords données */
{ {
return *( Ecran + y * Largeur_ecran + x ); return *( Screen + y * Screen_width + x );
} }
void Block_Simple (word Debut_X,word Debut_Y,word width,word height,byte Couleur) void Block_simple (word start_x,word start_y,word width,word height,byte color)
/* On affiche un rectangle de la couleur donnée */ /* On affiche un rectangle de la couleur donnée */
{ {
SDL_Rect rectangle; SDL_Rect rectangle;
rectangle.x=Debut_X; rectangle.x=start_x;
rectangle.y=Debut_Y; rectangle.y=start_y;
rectangle.w=width; rectangle.w=width;
rectangle.h=height; rectangle.h=height;
SDL_FillRect(Ecran_SDL,&rectangle,Couleur); SDL_FillRect(Screen_SDL,&rectangle,color);
} }
void Afficher_partie_de_l_ecran_Simple (word width,word height,word image_width) void Display_part_of_screen_simple (word width,word height,word image_width)
/* Afficher une partie de l'image telle quelle sur l'écran */ /* Afficher une partie de l'image telle quelle sur l'écran */
{ {
byte* Dest=Ecran; //On va se mettre en 0,0 dans l'écran (Dest) byte* dest=Screen; //On va se mettre en 0,0 dans l'écran (dest)
byte* Src=Principal_Decalage_Y*image_width+Principal_Decalage_X+Principal_Ecran; //Coords de départ ds la source (Src) byte* src=Main_offset_Y*image_width+Main_offset_X+Main_screen; //Coords de départ ds la source (src)
int y; int y;
for(y=height;y!=0;y--) for(y=height;y!=0;y--)
// Pour chaque ligne // Pour chaque ligne
{ {
// On fait une copie de la ligne // On fait une copie de la ligne
memcpy(Dest,Src,width); memcpy(dest,src,width);
// On passe à la ligne suivante // On passe à la ligne suivante
Src+=image_width; src+=image_width;
Dest+=Largeur_ecran; dest+=Screen_width;
} }
//UpdateRect(0,0,width,height); //Update_rect(0,0,width,height);
} }
void Pixel_Preview_Normal_Simple (word x,word y,byte Couleur) void Pixel_preview_normal_simple (word x,word y,byte color)
/* Affichage d'un pixel dans l'écran, par rapport au décalage de l'image /* Affichage d'un pixel dans l'écran, par rapport au décalage de l'image
* dans l'écran, en mode normal (pas en mode loupe) * dans l'écran, en mode normal (pas en mode loupe)
* Note: si on modifie cette procédure, il faudra penser à faire également * Note: si on modifie cette procédure, il faudra penser à faire également
* la modif dans la procédure Pixel_Preview_Loupe_SDL. */ * la modif dans la procédure Pixel_Preview_Loupe_SDL. */
{ {
// if(x-Principal_Decalage_X >= 0 && y - Principal_Decalage_Y >= 0) // if(x-Main_offset_X >= 0 && y - Main_offset_Y >= 0)
Pixel_Simple(x-Principal_Decalage_X,y-Principal_Decalage_Y,Couleur); Pixel_simple(x-Main_offset_X,y-Main_offset_Y,color);
} }
void Pixel_Preview_Loupe_Simple (word x,word y,byte Couleur) void Pixel_preview_magnifier_simple (word x,word y,byte color)
{ {
// Affiche le pixel dans la partie non zoomée // Affiche le pixel dans la partie non zoomée
Pixel_Simple(x-Principal_Decalage_X,y-Principal_Decalage_Y,Couleur); Pixel_simple(x-Main_offset_X,y-Main_offset_Y,color);
// Regarde si on doit aussi l'afficher dans la partie zoomée // Regarde si on doit aussi l'afficher dans la partie zoomée
if (y >= Limite_Haut_Zoom && y <= Limite_visible_Bas_Zoom if (y >= Limit_top_zoom && y <= Limit_visible_bottom_zoom
&& x >= Limite_Gauche_Zoom && x <= Limite_visible_Droite_Zoom) && x >= Limit_left_zoom && x <= Limit_visible_right_zoom)
{ {
// On est dedans // On est dedans
int height; int height;
int Y_Zoom = Table_mul_facteur_zoom[y-Loupe_Decalage_Y]; int y_zoom = Zoom_factor_table[y-Main_magnifier_offset_Y];
if (Menu_Ordonnee - Y_Zoom < Loupe_Facteur) if (Menu_Y - y_zoom < Main_magnifier_factor)
// On ne doit dessiner qu'un morceau du pixel // On ne doit dessiner qu'un morceau du pixel
// sinon on dépasse sur le menu // sinon on dépasse sur le menu
height = Menu_Ordonnee - Y_Zoom; height = Menu_Y - y_zoom;
else else
height = Loupe_Facteur; height = Main_magnifier_factor;
Block_Simple( Block_simple(
Table_mul_facteur_zoom[x-Loupe_Decalage_X]+Principal_X_Zoom, Zoom_factor_table[x-Main_magnifier_offset_X]+Main_X_zoom,
Y_Zoom, Loupe_Facteur, height, Couleur y_zoom, Main_magnifier_factor, height, color
); );
} }
} }
void Ligne_horizontale_XOR_Simple(word x_pos,word y_pos,word width) void Horizontal_XOR_line_simple(word x_pos,word y_pos,word width)
{ {
//On calcule la valeur initiale de Dest: //On calcule la valeur initiale de dest:
byte* Dest=y_pos*Largeur_ecran+x_pos+Ecran; byte* dest=y_pos*Screen_width+x_pos+Screen;
int x; int x;
for (x=0;x<width;x++) for (x=0;x<width;x++)
*(Dest+x)=~*(Dest+x); *(dest+x)=~*(dest+x);
} }
void Ligne_verticale_XOR_Simple(word x_pos,word y_pos,word height) void Vertical_XOR_line_simple(word x_pos,word y_pos,word height)
{ {
int i; int i;
byte color; byte color;
for (i=y_pos;i<y_pos+height;i++) for (i=y_pos;i<y_pos+height;i++)
{ {
color=*(Ecran+x_pos+i*Largeur_ecran); color=*(Screen+x_pos+i*Screen_width);
*(Ecran+x_pos+i*Largeur_ecran)=~color; *(Screen+x_pos+i*Screen_width)=~color;
} }
} }
void Display_brush_Color_Simple(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte Couleur_de_transparence,word Largeur_brosse) void Display_brush_color_simple(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)
{ {
// Dest = Position à l'écran // dest = Position à l'écran
byte* Dest = Ecran + y_pos * Largeur_ecran + x_pos; byte* dest = Screen + y_pos * Screen_width + x_pos;
// Src = Position dans la brosse // src = Position dans la brosse
byte* Src = Brosse + y_offset * Largeur_brosse + x_offset; byte* src = Brush + y_offset * brush_width + x_offset;
word x,y; word x,y;
@ -146,30 +146,30 @@ void Display_brush_Color_Simple(word x_pos,word y_pos,word x_offset,word y_offse
for(x = width;x > 0; x--) for(x = width;x > 0; x--)
{ {
// On vérifie que ce n'est pas la transparence // On vérifie que ce n'est pas la transparence
if(*Src != Couleur_de_transparence) if(*src != transp_color)
{ {
*Dest = *Src; *dest = *src;
} }
// Pixel suivant // Pixel suivant
Src++; Dest++; src++; dest++;
} }
// On passe à la ligne suivante // On passe à la ligne suivante
Dest = Dest + Largeur_ecran - width; dest = dest + Screen_width - width;
Src = Src + Largeur_brosse - width; src = src + brush_width - width;
} }
UpdateRect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
} }
void Display_brush_Mono_Simple(word x_pos, word y_pos, void Display_brush_mono_simple(word x_pos, word y_pos,
word x_offset, word y_offset, word width, word height, word x_offset, word y_offset, word width, word height,
byte Couleur_de_transparence, byte Couleur, word Largeur_brosse) byte transp_color, byte color, word brush_width)
/* On affiche la brosse en monochrome */ /* On affiche la brosse en monochrome */
{ {
byte* Dest=y_pos*Largeur_ecran+x_pos+Ecran; // Dest = adr Destination à byte* dest=y_pos*Screen_width+x_pos+Screen; // dest = adr Destination à
// l'écran // l'écran
byte* Src=Largeur_brosse*y_offset+x_offset+Brosse; // Src = adr ds byte* src=brush_width*y_offset+x_offset+Brush; // src = adr ds
// la brosse // la brosse
int x,y; int x,y;
@ -179,47 +179,47 @@ void Display_brush_Mono_Simple(word x_pos, word y_pos,
for(x=width;x!=0;x--) for(x=width;x!=0;x--)
//Pour chaque pixel //Pour chaque pixel
{ {
if (*Src!=Couleur_de_transparence) if (*src!=transp_color)
*Dest=Couleur; *dest=color;
// On passe au pixel suivant // On passe au pixel suivant
Src++; src++;
Dest++; dest++;
} }
// On passe à la ligne suivante // On passe à la ligne suivante
Src+=Largeur_brosse-width; src+=brush_width-width;
Dest+=Largeur_ecran-width; dest+=Screen_width-width;
} }
UpdateRect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
} }
void Clear_brush_Simple(word x_pos,word y_pos,__attribute__((unused)) word x_offset,__attribute__((unused)) word y_offset,word width,word height,__attribute__((unused))byte Couleur_de_transparence,word image_width) void Clear_brush_simple(word x_pos,word y_pos,__attribute__((unused)) word x_offset,__attribute__((unused)) word y_offset,word width,word height,__attribute__((unused))byte transp_color,word image_width)
{ {
byte* Dest=Ecran+x_pos+y_pos*Largeur_ecran; //On va se mettre en 0,0 dans l'écran (Dest) byte* dest=Screen+x_pos+y_pos*Screen_width; //On va se mettre en 0,0 dans l'écran (dest)
byte* Src = ( y_pos + Principal_Decalage_Y ) * image_width + x_pos + Principal_Decalage_X + Principal_Ecran; //Coords de départ ds la source (Src) byte* src = ( y_pos + Main_offset_Y ) * image_width + x_pos + Main_offset_X + Main_screen; //Coords de départ ds la source (src)
int y; int y;
for(y=height;y!=0;y--) for(y=height;y!=0;y--)
// Pour chaque ligne // Pour chaque ligne
{ {
// On fait une copie de la ligne // On fait une copie de la ligne
memcpy(Dest,Src,width); memcpy(dest,src,width);
// On passe à la ligne suivante // On passe à la ligne suivante
Src+=image_width; src+=image_width;
Dest+=Largeur_ecran; dest+=Screen_width;
} }
UpdateRect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
} }
// Affiche une brosse (arbitraire) à l'écran // Affiche une brosse (arbitraire) à l'écran
void Affiche_brosse_Simple(byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte Couleur_de_transparence,word Largeur_brosse) void Display_brush_simple(byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)
{ {
// Dest = Position à l'écran // dest = Position à l'écran
byte* Dest = Ecran + y_pos * Largeur_ecran + x_pos; byte* dest = Screen + y_pos * Screen_width + x_pos;
// Src = Position dans la brosse // src = Position dans la brosse
byte* Src = brush + y_offset * Largeur_brosse + x_offset; byte* src = brush + y_offset * brush_width + x_offset;
word x,y; word x,y;
@ -230,25 +230,25 @@ void Affiche_brosse_Simple(byte * brush, word x_pos,word y_pos,word x_offset,wor
for(x = width;x > 0; x--) for(x = width;x > 0; x--)
{ {
// On vérifie que ce n'est pas la transparence // On vérifie que ce n'est pas la transparence
if(*Src != Couleur_de_transparence) if(*src != transp_color)
{ {
*Dest = *Src; *dest = *src;
} }
// Pixel suivant // Pixel suivant
Src++; Dest++; src++; dest++;
} }
// On passe à la ligne suivante // On passe à la ligne suivante
Dest = Dest + Largeur_ecran - width; dest = dest + Screen_width - width;
Src = Src + Largeur_brosse - width; src = src + brush_width - width;
} }
} }
void Remap_screen_Simple(word x_pos,word y_pos,word width,word height,byte * Table_de_conversion) void Remap_screen_simple(word x_pos,word y_pos,word width,word height,byte * conversion_table)
{ {
// Dest = coords a l'écran // dest = coords a l'écran
byte* Dest = Ecran + y_pos * Largeur_ecran + x_pos; byte* dest = Screen + y_pos * Screen_width + x_pos;
int x,y; int x,y;
// Pour chaque ligne // Pour chaque ligne
@ -257,52 +257,52 @@ void Remap_screen_Simple(word x_pos,word y_pos,word width,word height,byte * Tab
// Pour chaque pixel // Pour chaque pixel
for(x=width;x>0;x--) for(x=width;x>0;x--)
{ {
*Dest = Table_de_conversion[*Dest]; *dest = conversion_table[*dest];
Dest ++; dest ++;
} }
Dest = Dest + Largeur_ecran - width; dest = dest + Screen_width - width;
} }
UpdateRect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
} }
void Afficher_une_ligne_ecran_Simple(word x_pos,word y_pos,word width,byte * line) void Display_line_on_screen_simple(word x_pos,word y_pos,word width,byte * line)
/* On affiche toute une ligne de pixels. Utilisé pour les textes. */ /* On affiche toute une ligne de pixels. Utilisé pour les textes. */
{ {
memcpy(Ecran+x_pos+y_pos*Largeur_ecran,line,width); memcpy(Screen+x_pos+y_pos*Screen_width,line,width);
} }
void Afficher_une_ligne_transparente_mono_a_l_ecran_Simple( void Display_transparent_mono_line_on_screen_simple(
word x_pos, word y_pos, word width, byte* line, word x_pos, word y_pos, word width, byte* line,
byte Couleur_transparence, byte Couleur) byte transp_color, byte color)
// Affiche une ligne à l'écran avec une couleur + transparence. // Affiche une ligne à l'écran avec une couleur + transparence.
// Utilisé par les brosses en mode zoom // Utilisé par les brosses en mode zoom
{ {
byte* Dest = Ecran+ y_pos * Largeur_ecran + x_pos; byte* dest = Screen+ y_pos * Screen_width + x_pos;
int x; int x;
// Pour chaque pixel // Pour chaque pixel
for(x=0;x<width;x++) for(x=0;x<width;x++)
{ {
if (Couleur_transparence!=*line) if (transp_color!=*line)
*Dest = Couleur; *dest = color;
line ++; // Pixel suivant line ++; // Pixel suivant
Dest++; dest++;
} }
} }
void Lire_une_ligne_ecran_Simple(word x_pos,word y_pos,word width,byte * line) void Read_line_screen_simple(word x_pos,word y_pos,word width,byte * line)
{ {
memcpy(line,Largeur_ecran * y_pos + x_pos + Ecran,width); memcpy(line,Screen_width * y_pos + x_pos + Screen,width);
} }
void Afficher_partie_de_l_ecran_zoomee_Simple( void Display_part_of_screen_scaled_simple(
word width, // width non zoomée word width, // width non zoomée
word height, // height zoomée word height, // height zoomée
word image_width,byte * Buffer) word image_width,byte * buffer)
{ {
byte* Src = Principal_Ecran + Loupe_Decalage_Y * image_width byte* src = Main_screen + Main_magnifier_offset_Y * image_width
+ Loupe_Decalage_X; + Main_magnifier_offset_X;
int y = 0; // Ligne en cours de traitement int y = 0; // Ligne en cours de traitement
// Pour chaque ligne à zoomer // Pour chaque ligne à zoomer
@ -311,160 +311,160 @@ void Afficher_partie_de_l_ecran_zoomee_Simple(
int x; int x;
// On éclate la ligne // On éclate la ligne
Zoomer_une_ligne(Src,Buffer,Loupe_Facteur,width); Zoom_a_line(src,buffer,Main_magnifier_factor,width);
// On l'affiche Facteur fois, sur des lignes consécutives // On l'affiche Facteur fois, sur des lignes consécutives
x = Loupe_Facteur; x = Main_magnifier_factor;
// Pour chaque ligne // Pour chaque ligne
do{ do{
// On affiche la ligne zoomée // On affiche la ligne zoomée
Afficher_une_ligne_ecran_Simple( Display_line_on_screen_simple(
Principal_X_Zoom, y, width*Loupe_Facteur, Main_X_zoom, y, width*Main_magnifier_factor,
Buffer buffer
); );
// On passe à la suivante // On passe à la suivante
y++; y++;
if(y==height) if(y==height)
{ {
UpdateRect(Principal_X_Zoom,0, Update_rect(Main_X_zoom,0,
width*Loupe_Facteur,height); width*Main_magnifier_factor,height);
return; return;
} }
x--; x--;
}while (x > 0); }while (x > 0);
Src += image_width; src += image_width;
} }
// ATTENTION on n'arrive jamais ici ! // ATTENTION on n'arrive jamais ici !
} }
void Afficher_une_ligne_transparente_a_l_ecran_Simple(word x_pos,word y_pos,word width,byte* line,byte Couleur_transparence) void Display_transparent_line_on_screen_simple(word x_pos,word y_pos,word width,byte* line,byte transp_color)
{ {
byte* Src = line; byte* src = line;
byte* Dest = Ecran + y_pos * Largeur_ecran + x_pos; byte* dest = Screen + y_pos * Screen_width + x_pos;
word x; word x;
// Pour chaque pixel de la ligne // Pour chaque pixel de la ligne
for(x = width;x > 0;x--) for(x = width;x > 0;x--)
{ {
if(*Src!=Couleur_transparence) if(*src!=transp_color)
*Dest = *Src; *dest = *src;
Src++; src++;
Dest++; dest++;
} }
} }
// Affiche une partie de la brosse couleur zoomée // Affiche une partie de la brosse couleur zoomée
void Display_brush_Color_zoom_Simple(word x_pos,word y_pos, void Display_brush_color_zoom_simple(word x_pos,word y_pos,
word x_offset,word y_offset, word x_offset,word y_offset,
word width, // width non zoomée word width, // width non zoomée
word Pos_Y_Fin,byte Couleur_de_transparence, word end_y_pos,byte transp_color,
word Largeur_brosse, // width réelle de la brosse word brush_width, // width réelle de la brosse
byte * Buffer) byte * buffer)
{ {
byte* Src = Brosse+y_offset*Largeur_brosse + x_offset; byte* src = Brush+y_offset*brush_width + x_offset;
word y = y_pos; word y = y_pos;
byte bx; byte bx;
// Pour chaque ligne // Pour chaque ligne
while(1) while(1)
{ {
Zoomer_une_ligne(Src,Buffer,Loupe_Facteur,width); Zoom_a_line(src,buffer,Main_magnifier_factor,width);
// On affiche facteur fois la ligne zoomée // On affiche facteur fois la ligne zoomée
for(bx=Loupe_Facteur;bx>0;bx--) for(bx=Main_magnifier_factor;bx>0;bx--)
{ {
Afficher_une_ligne_transparente_a_l_ecran_Simple(x_pos,y,width*Loupe_Facteur,Buffer,Couleur_de_transparence); Display_transparent_line_on_screen_simple(x_pos,y,width*Main_magnifier_factor,buffer,transp_color);
y++; y++;
if(y==Pos_Y_Fin) if(y==end_y_pos)
{ {
return; return;
} }
} }
Src += Largeur_brosse; src += brush_width;
} }
// ATTENTION zone jamais atteinte // ATTENTION zone jamais atteinte
} }
void Display_brush_Mono_zoom_Simple(word x_pos, word y_pos, void Display_brush_mono_zoom_simple(word x_pos, word y_pos,
word x_offset, word y_offset, word x_offset, word y_offset,
word width, // width non zoomée word width, // width non zoomée
word Pos_Y_Fin, word end_y_pos,
byte Couleur_de_transparence, byte Couleur, byte transp_color, byte color,
word Largeur_brosse, // width réelle de la brosse word brush_width, // width réelle de la brosse
byte * Buffer byte * buffer
) )
{ {
byte* Src = Brosse + y_offset * Largeur_brosse + x_offset; byte* src = Brush + y_offset * brush_width + x_offset;
int y=y_pos; int y=y_pos;
//Pour chaque ligne à zoomer : //Pour chaque ligne à zoomer :
while(1) while(1)
{ {
int BX; int bx;
// Src = Ligne originale // src = Ligne originale
// On éclate la ligne // On éclate la ligne
Zoomer_une_ligne(Src,Buffer,Loupe_Facteur,width); Zoom_a_line(src,buffer,Main_magnifier_factor,width);
// On affiche la ligne Facteur fois à l'écran (sur des // On affiche la ligne Facteur fois à l'écran (sur des
// lignes consécutives) // lignes consécutives)
BX = Loupe_Facteur; bx = Main_magnifier_factor;
// Pour chaque ligne écran // Pour chaque ligne écran
do do
{ {
// On affiche la ligne zoomée // On affiche la ligne zoomée
Afficher_une_ligne_transparente_mono_a_l_ecran_Simple( Display_transparent_mono_line_on_screen_simple(
x_pos, y, width * Loupe_Facteur, x_pos, y, width * Main_magnifier_factor,
Buffer, Couleur_de_transparence, Couleur buffer, transp_color, color
); );
// On passe à la ligne suivante // On passe à la ligne suivante
y++; y++;
// On vérifie qu'on est pas à la ligne finale // On vérifie qu'on est pas à la ligne finale
if(y == Pos_Y_Fin) if(y == end_y_pos)
{ {
UpdateRect( x_pos, y_pos, Update_rect( x_pos, y_pos,
width * Loupe_Facteur, Pos_Y_Fin - y_pos ); width * Main_magnifier_factor, end_y_pos - y_pos );
return; return;
} }
BX --; bx --;
} }
while (BX > 0); while (bx > 0);
// Passage à la ligne suivante dans la brosse aussi // Passage à la ligne suivante dans la brosse aussi
Src+=Largeur_brosse; src+=brush_width;
} }
} }
void Clear_brush_zoom_Simple(word x_pos,word y_pos,word x_offset,word y_offset,word width,word Pos_Y_Fin,__attribute__((unused)) byte Couleur_de_transparence,word image_width,byte * Buffer) void Clear_brush_scaled_simple(word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,__attribute__((unused)) byte transp_color,word image_width,byte * buffer)
{ {
// En fait on va recopier l'image non zoomée dans la partie zoomée ! // En fait on va recopier l'image non zoomée dans la partie zoomée !
byte* Src = Principal_Ecran + y_offset * image_width + x_offset; byte* src = Main_screen + y_offset * image_width + x_offset;
int y = y_pos; int y = y_pos;
int bx; int bx;
// Pour chaque ligne à zoomer // Pour chaque ligne à zoomer
while(1){ while(1){
Zoomer_une_ligne(Src,Buffer,Loupe_Facteur,width); Zoom_a_line(src,buffer,Main_magnifier_factor,width);
bx=Loupe_Facteur; bx=Main_magnifier_factor;
// Pour chaque ligne // Pour chaque ligne
do{ do{
Afficher_une_ligne_ecran_Simple(x_pos,y, Display_line_on_screen_simple(x_pos,y,
width * Loupe_Facteur,Buffer); width * Main_magnifier_factor,buffer);
// Ligne suivante // Ligne suivante
y++; y++;
if(y==Pos_Y_Fin) if(y==end_y_pos)
{ {
UpdateRect(x_pos,y_pos, Update_rect(x_pos,y_pos,
width*Loupe_Facteur,Pos_Y_Fin-y_pos); width*Main_magnifier_factor,end_y_pos-y_pos);
return; return;
} }
bx--; bx--;
}while(bx!=0); }while(bx!=0);
Src+= image_width; src+= image_width;
} }
} }

View File

@ -21,27 +21,27 @@
*/ */
#include "struct.h" #include "struct.h"
void Pixel_Simple (word x,word y,byte Couleur); void Pixel_simple (word x,word y,byte color);
byte Lit_Pixel_Simple (word x,word y); byte Read_pixel_simple (word x,word y);
void Block_Simple (word Debut_X,word Debut_Y,word width,word height,byte Couleur); void Block_simple (word start_x,word start_y,word width,word height,byte color);
void Pixel_Preview_Normal_Simple (word x,word y,byte Couleur); void Pixel_preview_normal_simple (word x,word y,byte color);
void Pixel_Preview_Loupe_Simple (word x,word y,byte Couleur); void Pixel_preview_magnifier_simple (word x,word y,byte color);
void Ligne_horizontale_XOR_Simple (word x_pos,word y_pos,word width); void Horizontal_XOR_line_simple (word x_pos,word y_pos,word width);
void Ligne_verticale_XOR_Simple (word x_pos,word y_pos,word height); void Vertical_XOR_line_simple (word x_pos,word y_pos,word height);
void Display_brush_Color_Simple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte Couleur_de_transparence,word Largeur_brosse); void Display_brush_color_simple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width);
void Display_brush_Mono_Simple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte Couleur_de_transparence,byte Couleur,word Largeur_brosse); void Display_brush_mono_simple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,byte color,word brush_width);
void Clear_brush_Simple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte Couleur_de_transparence,word image_width); void Clear_brush_simple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width);
void Remap_screen_Simple (word x_pos,word y_pos,word width,word height,byte * Table_de_conversion); void Remap_screen_simple (word x_pos,word y_pos,word width,word height,byte * conversion_table);
void Afficher_partie_de_l_ecran_Simple (word width,word height,word image_width); void Display_part_of_screen_simple (word width,word height,word image_width);
void Afficher_une_ligne_ecran_Simple (word x_pos,word y_pos,word width,byte * line); void Display_line_on_screen_simple (word x_pos,word y_pos,word width,byte * line);
void Lire_une_ligne_ecran_Simple (word x_pos,word y_pos,word width,byte * line); void Read_line_screen_simple (word x_pos,word y_pos,word width,byte * line);
void Afficher_partie_de_l_ecran_zoomee_Simple(word width,word height,word image_width,byte * Buffer); void Display_part_of_screen_scaled_simple(word width,word height,word image_width,byte * buffer);
void Display_brush_Color_zoom_Simple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word Pos_Y_Fin,byte Couleur_de_transparence,word Largeur_brosse,byte * Buffer); void Display_brush_color_zoom_simple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word brush_width,byte * buffer);
void Display_brush_Mono_zoom_Simple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word Pos_Y_Fin,byte Couleur_de_transparence,byte Couleur,word Largeur_brosse,byte * Buffer); void Display_brush_mono_zoom_simple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,byte color,word brush_width,byte * buffer);
void Clear_brush_zoom_Simple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word Pos_Y_Fin,byte Couleur_de_transparence,word image_width,byte * Buffer); void Clear_brush_scaled_simple (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word image_width,byte * buffer);
void Affiche_brosse_Simple (byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte Couleur_de_transparence,word Largeur_brosse); void Display_brush_simple (byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width);
void Afficher_une_ligne_transparente_mono_a_l_ecran_Simple( void Display_transparent_mono_line_on_screen_simple(
word x_pos, word y_pos, word width, byte* line, word x_pos, word y_pos, word width, byte* line,
byte Couleur_transparence, byte Couleur); byte transp_color, byte color);
void Afficher_une_ligne_transparente_a_l_ecran_Simple(word x_pos,word y_pos,word width,byte* line,byte Couleur_transparence); void Display_transparent_line_on_screen_simple(word x_pos,word y_pos,word width,byte* line,byte transp_color);

300
pxtall.c
View File

@ -29,121 +29,121 @@
#include "divers.h" #include "divers.h"
#include "pxsimple.h" #include "pxsimple.h"
void Pixel_Tall (word x,word y,byte Couleur) void Pixel_tall (word x,word y,byte color)
/* Affiche un pixel de la Couleur aux coords x;y à l'écran */ /* Affiche un pixel de la color aux coords x;y à l'écran */
{ {
*(Ecran + x + y * 2 * Largeur_ecran)=Couleur; *(Screen + x + y * 2 * Screen_width)=color;
*(Ecran + x + (y * 2 + 1) * Largeur_ecran)=Couleur; *(Screen + x + (y * 2 + 1) * Screen_width)=color;
} }
byte Lit_Pixel_Tall (word x,word y) byte Read_pixel_tall (word x,word y)
/* On retourne la couleur du pixel aux coords données */ /* On retourne la couleur du pixel aux coords données */
{ {
return *( Ecran + y * 2 * Largeur_ecran + x ); return *( Screen + y * 2 * Screen_width + x );
} }
void Block_Tall (word Debut_X,word Debut_Y,word width,word height,byte Couleur) void Block_tall (word start_x,word start_y,word width,word height,byte color)
/* On affiche un rectangle de la couleur donnée */ /* On affiche un rectangle de la couleur donnée */
{ {
SDL_Rect rectangle; SDL_Rect rectangle;
rectangle.x=Debut_X; rectangle.x=start_x;
rectangle.y=Debut_Y*2; rectangle.y=start_y*2;
rectangle.w=width; rectangle.w=width;
rectangle.h=height*2; rectangle.h=height*2;
SDL_FillRect(Ecran_SDL,&rectangle,Couleur); SDL_FillRect(Screen_SDL,&rectangle,color);
} }
void Afficher_partie_de_l_ecran_Tall (word width,word height,word image_width) void Display_part_of_screen_tall (word width,word height,word image_width)
/* Afficher une partie de l'image telle quelle sur l'écran */ /* Afficher une partie de l'image telle quelle sur l'écran */
{ {
byte* Dest=Ecran; //On va se mettre en 0,0 dans l'écran (Dest) byte* dest=Screen; //On va se mettre en 0,0 dans l'écran (dest)
byte* Src=Principal_Decalage_Y*image_width+Principal_Decalage_X+Principal_Ecran; //Coords de départ ds la source (Src) byte* src=Main_offset_Y*image_width+Main_offset_X+Main_screen; //Coords de départ ds la source (src)
int y; int y;
for(y=height;y!=0;y--) for(y=height;y!=0;y--)
// Pour chaque ligne // Pour chaque ligne
{ {
// On fait une copie de la ligne // On fait une copie de la ligne
memcpy(Dest,Src,width); memcpy(dest,src,width);
Dest+=Largeur_ecran; dest+=Screen_width;
memcpy(Dest,Src,width); memcpy(dest,src,width);
// On passe à la ligne suivante // On passe à la ligne suivante
Src+=image_width; src+=image_width;
Dest+=Largeur_ecran; dest+=Screen_width;
} }
//UpdateRect(0,0,width,height); //Update_rect(0,0,width,height);
} }
void Pixel_Preview_Normal_Tall (word x,word y,byte Couleur) void Pixel_preview_normal_tall (word x,word y,byte color)
/* Affichage d'un pixel dans l'écran, par rapport au décalage de l'image /* Affichage d'un pixel dans l'écran, par rapport au décalage de l'image
* dans l'écran, en mode normal (pas en mode loupe) * dans l'écran, en mode normal (pas en mode loupe)
* Note: si on modifie cette procédure, il faudra penser à faire également * Note: si on modifie cette procédure, il faudra penser à faire également
* la modif dans la procédure Pixel_Preview_Loupe_SDL. */ * la modif dans la procédure Pixel_Preview_Loupe_SDL. */
{ {
// if(x-Principal_Decalage_X >= 0 && y - Principal_Decalage_Y >= 0) // if(x-Main_offset_X >= 0 && y - Main_offset_Y >= 0)
Pixel_Tall(x-Principal_Decalage_X,y-Principal_Decalage_Y,Couleur); Pixel_tall(x-Main_offset_X,y-Main_offset_Y,color);
} }
void Pixel_Preview_Loupe_Tall (word x,word y,byte Couleur) void Pixel_preview_magnifier_tall (word x,word y,byte color)
{ {
// Affiche le pixel dans la partie non zoomée // Affiche le pixel dans la partie non zoomée
Pixel_Tall(x-Principal_Decalage_X,y-Principal_Decalage_Y,Couleur); Pixel_tall(x-Main_offset_X,y-Main_offset_Y,color);
// Regarde si on doit aussi l'afficher dans la partie zoomée // Regarde si on doit aussi l'afficher dans la partie zoomée
if (y >= Limite_Haut_Zoom && y <= Limite_visible_Bas_Zoom if (y >= Limit_top_zoom && y <= Limit_visible_bottom_zoom
&& x >= Limite_Gauche_Zoom && x <= Limite_visible_Droite_Zoom) && x >= Limit_left_zoom && x <= Limit_visible_right_zoom)
{ {
// On est dedans // On est dedans
int height; int height;
int Y_Zoom = Table_mul_facteur_zoom[y-Loupe_Decalage_Y]; int y_zoom = Zoom_factor_table[y-Main_magnifier_offset_Y];
if (Menu_Ordonnee - Y_Zoom < Loupe_Facteur) if (Menu_Y - y_zoom < Main_magnifier_factor)
// On ne doit dessiner qu'un morceau du pixel // On ne doit dessiner qu'un morceau du pixel
// sinon on dépasse sur le menu // sinon on dépasse sur le menu
height = Menu_Ordonnee - Y_Zoom; height = Menu_Y - y_zoom;
else else
height = Loupe_Facteur; height = Main_magnifier_factor;
Block_Tall( Block_tall(
Table_mul_facteur_zoom[x-Loupe_Decalage_X]+Principal_X_Zoom, Zoom_factor_table[x-Main_magnifier_offset_X]+Main_X_zoom,
Y_Zoom, Loupe_Facteur, height, Couleur y_zoom, Main_magnifier_factor, height, color
); );
} }
} }
void Ligne_horizontale_XOR_Tall(word x_pos,word y_pos,word width) void Horizontal_XOR_line_tall(word x_pos,word y_pos,word width)
{ {
//On calcule la valeur initiale de Dest: //On calcule la valeur initiale de dest:
byte* Dest=y_pos*2*Largeur_ecran+x_pos+Ecran; byte* dest=y_pos*2*Screen_width+x_pos+Screen;
int x; int x;
for (x=0;x<width;x++) for (x=0;x<width;x++)
*(Dest+x)=~*(Dest+x); *(dest+x)=~*(dest+x);
Dest=(y_pos*2+1)*Largeur_ecran+x_pos+Ecran; dest=(y_pos*2+1)*Screen_width+x_pos+Screen;
for (x=0;x<width;x++) for (x=0;x<width;x++)
*(Dest+x)=~*(Dest+x); *(dest+x)=~*(dest+x);
} }
void Ligne_verticale_XOR_Tall(word x_pos,word y_pos,word height) void Vertical_XOR_line_tall(word x_pos,word y_pos,word height)
{ {
int i; int i;
byte color; byte color;
for (i=y_pos*2;i<(y_pos+height)*2;i++) for (i=y_pos*2;i<(y_pos+height)*2;i++)
{ {
color=*(Ecran+x_pos+i*Largeur_ecran); color=*(Screen+x_pos+i*Screen_width);
*(Ecran+x_pos+i*Largeur_ecran)=~color; *(Screen+x_pos+i*Screen_width)=~color;
} }
} }
void Display_brush_Color_Tall(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte Couleur_de_transparence,word Largeur_brosse) void Display_brush_color_tall(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)
{ {
// Dest = Position à l'écran // dest = Position à l'écran
byte* Dest = Ecran + y_pos * 2 * Largeur_ecran + x_pos; byte* dest = Screen + y_pos * 2 * Screen_width + x_pos;
// Src = Position dans la brosse // src = Position dans la brosse
byte* Src = Brosse + y_offset * Largeur_brosse + x_offset; byte* src = Brush + y_offset * brush_width + x_offset;
word x,y; word x,y;
@ -154,31 +154,31 @@ void Display_brush_Color_Tall(word x_pos,word y_pos,word x_offset,word y_offset,
for(x = width;x > 0; x--) for(x = width;x > 0; x--)
{ {
// On vérifie que ce n'est pas la transparence // On vérifie que ce n'est pas la transparence
if(*Src != Couleur_de_transparence) if(*src != transp_color)
{ {
*Dest = *Src; *dest = *src;
*(Dest+Largeur_ecran) = *Src; *(dest+Screen_width) = *src;
} }
// Pixel suivant // Pixel suivant
Src++; Dest++; src++; dest++;
} }
// On passe à la ligne suivante // On passe à la ligne suivante
Dest = Dest + 2 * Largeur_ecran - width; dest = dest + 2 * Screen_width - width;
Src = Src + Largeur_brosse - width; src = src + brush_width - width;
} }
UpdateRect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
} }
void Display_brush_Mono_Tall(word x_pos, word y_pos, void Display_brush_mono_tall(word x_pos, word y_pos,
word x_offset, word y_offset, word width, word height, word x_offset, word y_offset, word width, word height,
byte Couleur_de_transparence, byte Couleur, word Largeur_brosse) byte transp_color, byte color, word brush_width)
/* On affiche la brosse en monochrome */ /* On affiche la brosse en monochrome */
{ {
byte* Dest=y_pos*2*Largeur_ecran+x_pos+Ecran; // Dest = adr Destination à byte* dest=y_pos*2*Screen_width+x_pos+Screen; // dest = adr Destination à
// l'écran // l'écran
byte* Src=Largeur_brosse*y_offset+x_offset+Brosse; // Src = adr ds byte* src=brush_width*y_offset+x_offset+Brush; // src = adr ds
// la brosse // la brosse
int x,y; int x,y;
@ -188,52 +188,52 @@ void Display_brush_Mono_Tall(word x_pos, word y_pos,
for(x=width;x!=0;x--) for(x=width;x!=0;x--)
//Pour chaque pixel //Pour chaque pixel
{ {
if (*Src!=Couleur_de_transparence) if (*src!=transp_color)
{ {
*Dest=Couleur; *dest=color;
*(Dest+Largeur_ecran)=Couleur; *(dest+Screen_width)=color;
} }
// On passe au pixel suivant // On passe au pixel suivant
Src++; src++;
Dest++; dest++;
} }
// On passe à la ligne suivante // On passe à la ligne suivante
Src+=Largeur_brosse-width; src+=brush_width-width;
Dest+=2*Largeur_ecran-width; dest+=2*Screen_width-width;
} }
UpdateRect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
} }
void Clear_brush_Tall(word x_pos,word y_pos,__attribute__((unused)) word x_offset,__attribute__((unused)) word y_offset,word width,word height,__attribute__((unused))byte Couleur_de_transparence,word image_width) void Clear_brush_tall(word x_pos,word y_pos,__attribute__((unused)) word x_offset,__attribute__((unused)) word y_offset,word width,word height,__attribute__((unused))byte transp_color,word image_width)
{ {
byte* Dest=Ecran+x_pos+y_pos*2*Largeur_ecran; //On va se mettre en 0,0 dans l'écran (Dest) byte* dest=Screen+x_pos+y_pos*2*Screen_width; //On va se mettre en 0,0 dans l'écran (dest)
byte* Src = ( y_pos + Principal_Decalage_Y ) * image_width + x_pos + Principal_Decalage_X + Principal_Ecran; //Coords de départ ds la source (Src) byte* src = ( y_pos + Main_offset_Y ) * image_width + x_pos + Main_offset_X + Main_screen; //Coords de départ ds la source (src)
int y; int y;
for(y=height;y!=0;y--) for(y=height;y!=0;y--)
// Pour chaque ligne // Pour chaque ligne
{ {
// On fait une copie de la ligne // On fait une copie de la ligne
memcpy(Dest,Src,width); memcpy(dest,src,width);
Dest+=Largeur_ecran; dest+=Screen_width;
memcpy(Dest,Src,width); memcpy(dest,src,width);
// On passe à la ligne suivante // On passe à la ligne suivante
Src+=image_width; src+=image_width;
Dest+=Largeur_ecran; dest+=Screen_width;
} }
UpdateRect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
} }
// Affiche une brosse (arbitraire) à l'écran // Affiche une brosse (arbitraire) à l'écran
void Affiche_brosse_Tall(byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte Couleur_de_transparence,word Largeur_brosse) void Display_brush_tall(byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)
{ {
// Dest = Position à l'écran // dest = Position à l'écran
byte* Dest = Ecran + y_pos * 2 * Largeur_ecran + x_pos; byte* dest = Screen + y_pos * 2 * Screen_width + x_pos;
// Src = Position dans la brosse // src = Position dans la brosse
byte* Src = brush + y_offset * Largeur_brosse + x_offset; byte* src = brush + y_offset * brush_width + x_offset;
word x,y; word x,y;
@ -244,26 +244,26 @@ void Affiche_brosse_Tall(byte * brush, word x_pos,word y_pos,word x_offset,word
for(x = width;x > 0; x--) for(x = width;x > 0; x--)
{ {
// On vérifie que ce n'est pas la transparence // On vérifie que ce n'est pas la transparence
if(*Src != Couleur_de_transparence) if(*src != transp_color)
{ {
*Dest = *Src; *dest = *src;
*(Dest+Largeur_ecran) = *Src; *(dest+Screen_width) = *src;
} }
// Pixel suivant // Pixel suivant
Src++; Dest++; src++; dest++;
} }
// On passe à la ligne suivante // On passe à la ligne suivante
Dest = Dest + Largeur_ecran * 2 - width; dest = dest + Screen_width * 2 - width;
Src = Src + Largeur_brosse - width; src = src + brush_width - width;
} }
} }
void Remap_screen_Tall(word x_pos,word y_pos,word width,word height,byte * Table_de_conversion) void Remap_screen_tall(word x_pos,word y_pos,word width,word height,byte * conversion_table)
{ {
// Dest = coords a l'écran // dest = coords a l'écran
byte* Dest = Ecran + y_pos * 2 * Largeur_ecran + x_pos; byte* dest = Screen + y_pos * 2 * Screen_width + x_pos;
int x,y; int x,y;
// Pour chaque ligne // Pour chaque ligne
@ -272,35 +272,35 @@ void Remap_screen_Tall(word x_pos,word y_pos,word width,word height,byte * Table
// Pour chaque pixel // Pour chaque pixel
for(x=width;x>0;x--) for(x=width;x>0;x--)
{ {
*Dest = Table_de_conversion[*Dest]; *dest = conversion_table[*dest];
Dest ++; dest ++;
} }
Dest = Dest + Largeur_ecran - width; dest = dest + Screen_width - width;
} }
UpdateRect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
} }
void Afficher_une_ligne_ecran_Tall(word x_pos,word y_pos,word width,byte * line) void Display_line_on_screen_tall(word x_pos,word y_pos,word width,byte * line)
/* On affiche toute une ligne de pixels. Utilisé pour les textes. */ /* On affiche toute une ligne de pixels. Utilisé pour les textes. */
{ {
memcpy(Ecran+x_pos+y_pos*2*Largeur_ecran,line,width); memcpy(Screen+x_pos+y_pos*2*Screen_width,line,width);
memcpy(Ecran+x_pos+(y_pos*2+1)*Largeur_ecran,line,width); memcpy(Screen+x_pos+(y_pos*2+1)*Screen_width,line,width);
} }
void Lire_une_ligne_ecran_Tall(word x_pos,word y_pos,word width,byte * line) void Read_line_screen_tall(word x_pos,word y_pos,word width,byte * line)
{ {
memcpy(line,Largeur_ecran * 2 * y_pos + x_pos + Ecran,width); memcpy(line,Screen_width * 2 * y_pos + x_pos + Screen,width);
} }
void Afficher_partie_de_l_ecran_zoomee_Tall( void Display_part_of_screen_scaled_tall(
word width, // width non zoomée word width, // width non zoomée
word height, // height zoomée word height, // height zoomée
word image_width,byte * Buffer) word image_width,byte * buffer)
{ {
byte* Src = Principal_Ecran + Loupe_Decalage_Y * image_width byte* src = Main_screen + Main_magnifier_offset_Y * image_width
+ Loupe_Decalage_X; + Main_magnifier_offset_X;
int y = 0; // Ligne en cours de traitement int y = 0; // Ligne en cours de traitement
// Pour chaque ligne à zoomer // Pour chaque ligne à zoomer
@ -309,143 +309,143 @@ void Afficher_partie_de_l_ecran_zoomee_Tall(
int x; int x;
// On éclate la ligne // On éclate la ligne
Zoomer_une_ligne(Src,Buffer,Loupe_Facteur,width); Zoom_a_line(src,buffer,Main_magnifier_factor,width);
// On l'affiche Facteur fois, sur des lignes consécutives // On l'affiche Facteur fois, sur des lignes consécutives
x = Loupe_Facteur*2; x = Main_magnifier_factor*2;
// Pour chaque ligne // Pour chaque ligne
do{ do{
// On affiche la ligne zoomée // On affiche la ligne zoomée
Afficher_une_ligne_ecran_Simple( Display_line_on_screen_simple(
Principal_X_Zoom, y, width*Loupe_Facteur, Main_X_zoom, y, width*Main_magnifier_factor,
Buffer buffer
); );
// On passe à la suivante // On passe à la suivante
y++; y++;
if(y==height*2) if(y==height*2)
{ {
UpdateRect(Principal_X_Zoom,0, Update_rect(Main_X_zoom,0,
width*Loupe_Facteur,height); width*Main_magnifier_factor,height);
return; return;
} }
x--; x--;
}while (x > 0); }while (x > 0);
Src += image_width; src += image_width;
} }
// ATTENTION on n'arrive jamais ici ! // ATTENTION on n'arrive jamais ici !
} }
// Affiche une partie de la brosse couleur zoomée // Affiche une partie de la brosse couleur zoomée
void Display_brush_Color_zoom_Tall(word x_pos,word y_pos, void Display_brush_color_zoom_tall(word x_pos,word y_pos,
word x_offset,word y_offset, word x_offset,word y_offset,
word width, // width non zoomée word width, // width non zoomée
word Pos_Y_Fin,byte Couleur_de_transparence, word end_y_pos,byte transp_color,
word Largeur_brosse, // width réelle de la brosse word brush_width, // width réelle de la brosse
byte * Buffer) byte * buffer)
{ {
byte* Src = Brosse+y_offset*Largeur_brosse + x_offset; byte* src = Brush+y_offset*brush_width + x_offset;
word y = y_pos; word y = y_pos;
byte bx; byte bx;
// Pour chaque ligne // Pour chaque ligne
while(1) while(1)
{ {
Zoomer_une_ligne(Src,Buffer,Loupe_Facteur,width); Zoom_a_line(src,buffer,Main_magnifier_factor,width);
// On affiche facteur fois la ligne zoomée // On affiche facteur fois la ligne zoomée
for(bx=Loupe_Facteur;bx>0;bx--) for(bx=Main_magnifier_factor;bx>0;bx--)
{ {
Afficher_une_ligne_transparente_a_l_ecran_Simple(x_pos,y*2,width*Loupe_Facteur,Buffer,Couleur_de_transparence); Display_transparent_line_on_screen_simple(x_pos,y*2,width*Main_magnifier_factor,buffer,transp_color);
memcpy(Ecran + (y*2 +1) * Largeur_ecran + x_pos, Ecran + y*2* Largeur_ecran + x_pos, width*Loupe_Facteur); memcpy(Screen + (y*2 +1) * Screen_width + x_pos, Screen + y*2* Screen_width + x_pos, width*Main_magnifier_factor);
y++; y++;
if(y==Pos_Y_Fin) if(y==end_y_pos)
{ {
return; return;
} }
} }
Src += Largeur_brosse; src += brush_width;
} }
// ATTENTION zone jamais atteinte // ATTENTION zone jamais atteinte
} }
void Display_brush_Mono_zoom_Tall(word x_pos, word y_pos, void Display_brush_mono_zoom_tall(word x_pos, word y_pos,
word x_offset, word y_offset, word x_offset, word y_offset,
word width, // width non zoomée word width, // width non zoomée
word Pos_Y_Fin, word end_y_pos,
byte Couleur_de_transparence, byte Couleur, byte transp_color, byte color,
word Largeur_brosse, // width réelle de la brosse word brush_width, // width réelle de la brosse
byte * Buffer byte * buffer
) )
{ {
byte* Src = Brosse + y_offset * Largeur_brosse + x_offset; byte* src = Brush + y_offset * brush_width + x_offset;
int y=y_pos*2; int y=y_pos*2;
//Pour chaque ligne à zoomer : //Pour chaque ligne à zoomer :
while(1) while(1)
{ {
int BX; int bx;
// Src = Ligne originale // src = Ligne originale
// On éclate la ligne // On éclate la ligne
Zoomer_une_ligne(Src,Buffer,Loupe_Facteur,width); Zoom_a_line(src,buffer,Main_magnifier_factor,width);
// On affiche la ligne Facteur fois à l'écran (sur des // On affiche la ligne Facteur fois à l'écran (sur des
// lignes consécutives) // lignes consécutives)
BX = Loupe_Facteur*2; bx = Main_magnifier_factor*2;
// Pour chaque ligne écran // Pour chaque ligne écran
do do
{ {
// On affiche la ligne zoomée // On affiche la ligne zoomée
Afficher_une_ligne_transparente_mono_a_l_ecran_Simple( Display_transparent_mono_line_on_screen_simple(
x_pos, y, width * Loupe_Facteur, x_pos, y, width * Main_magnifier_factor,
Buffer, Couleur_de_transparence, Couleur buffer, transp_color, color
); );
// On passe à la ligne suivante // On passe à la ligne suivante
y++; y++;
// On vérifie qu'on est pas à la ligne finale // On vérifie qu'on est pas à la ligne finale
if(y == Pos_Y_Fin*2) if(y == end_y_pos*2)
{ {
UpdateRect( x_pos, y_pos, Update_rect( x_pos, y_pos,
width * Loupe_Facteur, Pos_Y_Fin - y_pos ); width * Main_magnifier_factor, end_y_pos - y_pos );
return; return;
} }
BX --; bx --;
} }
while (BX > 0); while (bx > 0);
// Passage à la ligne suivante dans la brosse aussi // Passage à la ligne suivante dans la brosse aussi
Src+=Largeur_brosse; src+=brush_width;
} }
} }
void Clear_brush_zoom_Tall(word x_pos,word y_pos,word x_offset,word y_offset,word width,word Pos_Y_Fin,__attribute__((unused)) byte Couleur_de_transparence,word image_width,byte * Buffer) void Clear_brush_scaled_tall(word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,__attribute__((unused)) byte transp_color,word image_width,byte * buffer)
{ {
// En fait on va recopier l'image non zoomée dans la partie zoomée ! // En fait on va recopier l'image non zoomée dans la partie zoomée !
byte* Src = Principal_Ecran + y_offset * image_width + x_offset; byte* src = Main_screen + y_offset * image_width + x_offset;
int y = y_pos; int y = y_pos;
int bx; int bx;
// Pour chaque ligne à zoomer // Pour chaque ligne à zoomer
while(1){ while(1){
Zoomer_une_ligne(Src,Buffer,Loupe_Facteur,width); Zoom_a_line(src,buffer,Main_magnifier_factor,width);
bx=Loupe_Facteur; bx=Main_magnifier_factor;
// Pour chaque ligne // Pour chaque ligne
do{ do{
Afficher_une_ligne_ecran_Tall(x_pos,y, Display_line_on_screen_tall(x_pos,y,
width * Loupe_Facteur,Buffer); width * Main_magnifier_factor,buffer);
// Ligne suivante // Ligne suivante
y++; y++;
if(y==Pos_Y_Fin) if(y==end_y_pos)
{ {
UpdateRect(x_pos,y_pos, Update_rect(x_pos,y_pos,
width*Loupe_Facteur,Pos_Y_Fin-y_pos); width*Main_magnifier_factor,end_y_pos-y_pos);
return; return;
} }
bx--; bx--;
}while(bx!=0); }while(bx!=0);
Src+= image_width; src+= image_width;
} }
} }

View File

@ -21,22 +21,22 @@
*/ */
#include "struct.h" #include "struct.h"
void Pixel_Tall (word x,word y,byte Couleur); void Pixel_tall (word x,word y,byte color);
byte Lit_Pixel_Tall (word x,word y); byte Read_pixel_tall (word x,word y);
void Block_Tall (word Debut_X,word Debut_Y,word width,word height,byte Couleur); void Block_tall (word start_x,word start_y,word width,word height,byte color);
void Pixel_Preview_Normal_Tall (word x,word y,byte Couleur); void Pixel_preview_normal_tall (word x,word y,byte color);
void Pixel_Preview_Loupe_Tall (word x,word y,byte Couleur); void Pixel_preview_magnifier_tall (word x,word y,byte color);
void Ligne_horizontale_XOR_Tall (word x_pos,word y_pos,word width); void Horizontal_XOR_line_tall (word x_pos,word y_pos,word width);
void Ligne_verticale_XOR_Tall (word x_pos,word y_pos,word height); void Vertical_XOR_line_tall (word x_pos,word y_pos,word height);
void Display_brush_Color_Tall (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte Couleur_de_transparence,word Largeur_brosse); void Display_brush_color_tall (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width);
void Display_brush_Mono_Tall (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte Couleur_de_transparence,byte Couleur,word Largeur_brosse); void Display_brush_mono_tall (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,byte color,word brush_width);
void Clear_brush_Tall (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte Couleur_de_transparence,word image_width); void Clear_brush_tall (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width);
void Remap_screen_Tall (word x_pos,word y_pos,word width,word height,byte * Table_de_conversion); void Remap_screen_tall (word x_pos,word y_pos,word width,word height,byte * conversion_table);
void Afficher_partie_de_l_ecran_Tall (word width,word height,word image_width); void Display_part_of_screen_tall (word width,word height,word image_width);
void Afficher_une_ligne_ecran_Tall (word x_pos,word y_pos,word width,byte * line); void Display_line_on_screen_tall (word x_pos,word y_pos,word width,byte * line);
void Lire_une_ligne_ecran_Tall (word x_pos,word y_pos,word width,byte * line); void Read_line_screen_tall (word x_pos,word y_pos,word width,byte * line);
void Afficher_partie_de_l_ecran_zoomee_Tall(word width,word height,word image_width,byte * Buffer); void Display_part_of_screen_scaled_tall(word width,word height,word image_width,byte * buffer);
void Display_brush_Color_zoom_Tall (word x_pos,word y_pos,word x_offset,word y_offset,word width,word Pos_Y_Fin,byte Couleur_de_transparence,word Largeur_brosse,byte * Buffer); void Display_brush_color_zoom_tall (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word brush_width,byte * buffer);
void Display_brush_Mono_zoom_Tall (word x_pos,word y_pos,word x_offset,word y_offset,word width,word Pos_Y_Fin,byte Couleur_de_transparence,byte Couleur,word Largeur_brosse,byte * Buffer); void Display_brush_mono_zoom_tall (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,byte color,word brush_width,byte * buffer);
void Clear_brush_zoom_Tall (word x_pos,word y_pos,word x_offset,word y_offset,word width,word Pos_Y_Fin,byte Couleur_de_transparence,word image_width,byte * Buffer); void Clear_brush_scaled_tall (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word image_width,byte * buffer);
void Affiche_brosse_Tall (byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte Couleur_de_transparence,word Largeur_brosse); void Display_brush_tall (byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width);

338
pxwide.c
View File

@ -28,35 +28,35 @@
#include "sdlscreen.h" #include "sdlscreen.h"
#include "divers.h" #include "divers.h"
void Pixel_Wide (word x,word y,byte Couleur) void Pixel_wide (word x,word y,byte color)
/* Affiche un pixel de la Couleur aux coords x;y à l'écran */ /* Affiche un pixel de la color aux coords x;y à l'écran */
{ {
*(Ecran + x * 2 + y * 2 * Largeur_ecran)=Couleur; *(Screen + x * 2 + y * 2 * Screen_width)=color;
*(Ecran + x * 2 + y * 2 * Largeur_ecran + 1)=Couleur; *(Screen + x * 2 + y * 2 * Screen_width + 1)=color;
} }
byte Lit_Pixel_Wide (word x,word y) byte Read_pixel_wide (word x,word y)
/* On retourne la couleur du pixel aux coords données */ /* On retourne la couleur du pixel aux coords données */
{ {
return *( Ecran + y * 2 * Largeur_ecran + x * 2); return *( Screen + y * 2 * Screen_width + x * 2);
} }
void Block_Wide (word Debut_X,word Debut_Y,word width,word height,byte Couleur) void Block_wide (word start_x,word start_y,word width,word height,byte color)
/* On affiche un rectangle de la couleur donnée */ /* On affiche un rectangle de la couleur donnée */
{ {
SDL_Rect rectangle; SDL_Rect rectangle;
rectangle.x=Debut_X*2; rectangle.x=start_x*2;
rectangle.y=Debut_Y; rectangle.y=start_y;
rectangle.w=width*2; rectangle.w=width*2;
rectangle.h=height; rectangle.h=height;
SDL_FillRect(Ecran_SDL,&rectangle,Couleur); SDL_FillRect(Screen_SDL,&rectangle,color);
} }
void Afficher_partie_de_l_ecran_Wide (word width,word height,word image_width) void Display_part_of_screen_wide (word width,word height,word image_width)
/* Afficher une partie de l'image telle quelle sur l'écran */ /* Afficher une partie de l'image telle quelle sur l'écran */
{ {
byte* Dest=Ecran; //On va se mettre en 0,0 dans l'écran (Dest) byte* dest=Screen; //On va se mettre en 0,0 dans l'écran (dest)
byte* Src=Principal_Decalage_Y*image_width+Principal_Decalage_X+Principal_Ecran; //Coords de départ ds la source (Src) byte* src=Main_offset_Y*image_width+Main_offset_X+Main_screen; //Coords de départ ds la source (src)
int y; int y;
int dy; int dy;
@ -66,86 +66,86 @@ void Afficher_partie_de_l_ecran_Wide (word width,word height,word image_width)
// On fait une copie de la ligne // On fait une copie de la ligne
for (dy=width;dy>0;dy--) for (dy=width;dy>0;dy--)
{ {
*(Dest+1)=*Dest=*Src; *(dest+1)=*dest=*src;
Src++; src++;
Dest+=2; dest+=2;
} }
// On passe à la ligne suivante // On passe à la ligne suivante
Src+=image_width-width; src+=image_width-width;
Dest+=(Largeur_ecran - width)*2; dest+=(Screen_width - width)*2;
} }
//UpdateRect(0,0,width,height); //Update_rect(0,0,width,height);
} }
void Pixel_Preview_Normal_Wide (word x,word y,byte Couleur) void Pixel_preview_normal_wide (word x,word y,byte color)
/* Affichage d'un pixel dans l'écran, par rapport au décalage de l'image /* Affichage d'un pixel dans l'écran, par rapport au décalage de l'image
* dans l'écran, en mode normal (pas en mode loupe) * dans l'écran, en mode normal (pas en mode loupe)
* Note: si on modifie cette procédure, il faudra penser à faire également * Note: si on modifie cette procédure, il faudra penser à faire également
* la modif dans la procédure Pixel_Preview_Loupe_SDL. */ * la modif dans la procédure Pixel_Preview_Loupe_SDL. */
{ {
// if(x-Principal_Decalage_X >= 0 && y - Principal_Decalage_Y >= 0) // if(x-Main_offset_X >= 0 && y - Main_offset_Y >= 0)
Pixel_Wide(x-Principal_Decalage_X,y-Principal_Decalage_Y,Couleur); Pixel_wide(x-Main_offset_X,y-Main_offset_Y,color);
} }
void Pixel_Preview_Loupe_Wide (word x,word y,byte Couleur) void Pixel_preview_magnifier_wide (word x,word y,byte color)
{ {
// Affiche le pixel dans la partie non zoomée // Affiche le pixel dans la partie non zoomée
Pixel_Wide(x-Principal_Decalage_X,y-Principal_Decalage_Y,Couleur); Pixel_wide(x-Main_offset_X,y-Main_offset_Y,color);
// Regarde si on doit aussi l'afficher dans la partie zoomée // Regarde si on doit aussi l'afficher dans la partie zoomée
if (y >= Limite_Haut_Zoom && y <= Limite_visible_Bas_Zoom if (y >= Limit_top_zoom && y <= Limit_visible_bottom_zoom
&& x >= Limite_Gauche_Zoom && x <= Limite_visible_Droite_Zoom) && x >= Limit_left_zoom && x <= Limit_visible_right_zoom)
{ {
// On est dedans // On est dedans
int height; int height;
int Y_Zoom = Table_mul_facteur_zoom[y-Loupe_Decalage_Y]; int y_zoom = Zoom_factor_table[y-Main_magnifier_offset_Y];
if (Menu_Ordonnee - Y_Zoom < Loupe_Facteur) if (Menu_Y - y_zoom < Main_magnifier_factor)
// On ne doit dessiner qu'un morceau du pixel // On ne doit dessiner qu'un morceau du pixel
// sinon on dépasse sur le menu // sinon on dépasse sur le menu
height = Menu_Ordonnee - Y_Zoom; height = Menu_Y - y_zoom;
else else
height = Loupe_Facteur; height = Main_magnifier_factor;
Block_Wide( Block_wide(
Table_mul_facteur_zoom[x-Loupe_Decalage_X]+Principal_X_Zoom, Zoom_factor_table[x-Main_magnifier_offset_X]+Main_X_zoom,
Y_Zoom, Loupe_Facteur, height, Couleur y_zoom, Main_magnifier_factor, height, color
); );
} }
} }
void Ligne_horizontale_XOR_Wide(word x_pos,word y_pos,word width) void Horizontal_XOR_line_wide(word x_pos,word y_pos,word width)
{ {
//On calcule la valeur initiale de Dest: //On calcule la valeur initiale de dest:
byte* Dest=y_pos*2*Largeur_ecran+x_pos*2+Ecran; byte* dest=y_pos*2*Screen_width+x_pos*2+Screen;
int x; int x;
for (x=0;x<width*2;x+=2) for (x=0;x<width*2;x+=2)
*(Dest+x+1)=*(Dest+x)=~*(Dest+x); *(dest+x+1)=*(dest+x)=~*(dest+x);
} }
void Ligne_verticale_XOR_Wide(word x_pos,word y_pos,word height) void Vertical_XOR_line_wide(word x_pos,word y_pos,word height)
{ {
int i; int i;
byte color; byte color;
byte *Dest=Ecran+x_pos*2+y_pos*Largeur_ecran*2; byte *dest=Screen+x_pos*2+y_pos*Screen_width*2;
for (i=height;i>0;i--) for (i=height;i>0;i--)
{ {
color=~*Dest; color=~*dest;
*Dest=color; *dest=color;
*(Dest+1)=color; *(dest+1)=color;
Dest+=Largeur_ecran*2; dest+=Screen_width*2;
} }
} }
void Display_brush_Color_Wide(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte Couleur_de_transparence,word Largeur_brosse) void Display_brush_color_wide(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)
{ {
// Dest = Position à l'écran // dest = Position à l'écran
byte* Dest = Ecran + y_pos * 2 * Largeur_ecran + x_pos * 2; byte* dest = Screen + y_pos * 2 * Screen_width + x_pos * 2;
// Src = Position dans la brosse // src = Position dans la brosse
byte* Src = Brosse + y_offset * Largeur_brosse + x_offset; byte* src = Brush + y_offset * brush_width + x_offset;
word x,y; word x,y;
@ -156,31 +156,31 @@ void Display_brush_Color_Wide(word x_pos,word y_pos,word x_offset,word y_offset,
for(x = width;x > 0; x--) for(x = width;x > 0; x--)
{ {
// On vérifie que ce n'est pas la transparence // On vérifie que ce n'est pas la transparence
if(*Src != Couleur_de_transparence) if(*src != transp_color)
{ {
*(Dest+1) = *Dest = *Src; *(dest+1) = *dest = *src;
} }
// Pixel suivant // Pixel suivant
Src++; src++;
Dest+=2; dest+=2;
} }
// On passe à la ligne suivante // On passe à la ligne suivante
Dest = Dest + (Largeur_ecran - width)*2; dest = dest + (Screen_width - width)*2;
Src = Src + Largeur_brosse - width; src = src + brush_width - width;
} }
UpdateRect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
} }
void Display_brush_Mono_Wide(word x_pos, word y_pos, void Display_brush_mono_wide(word x_pos, word y_pos,
word x_offset, word y_offset, word width, word height, word x_offset, word y_offset, word width, word height,
byte Couleur_de_transparence, byte Couleur, word Largeur_brosse) byte transp_color, byte color, word brush_width)
/* On affiche la brosse en monochrome */ /* On affiche la brosse en monochrome */
{ {
byte* Dest=y_pos*2*Largeur_ecran+x_pos*2+Ecran; // Dest = adr Destination à byte* dest=y_pos*2*Screen_width+x_pos*2+Screen; // dest = adr Destination à
// l'écran // l'écran
byte* Src=Largeur_brosse*y_offset+x_offset+Brosse; // Src = adr ds byte* src=brush_width*y_offset+x_offset+Brush; // src = adr ds
// la brosse // la brosse
int x,y; int x,y;
@ -190,25 +190,25 @@ void Display_brush_Mono_Wide(word x_pos, word y_pos,
for(x=width;x!=0;x--) for(x=width;x!=0;x--)
//Pour chaque pixel //Pour chaque pixel
{ {
if (*Src!=Couleur_de_transparence) if (*src!=transp_color)
*(Dest+1)=*Dest=Couleur; *(dest+1)=*dest=color;
// On passe au pixel suivant // On passe au pixel suivant
Src++; src++;
Dest+=2; dest+=2;
} }
// On passe à la ligne suivante // On passe à la ligne suivante
Src+=Largeur_brosse-width; src+=brush_width-width;
Dest+=(Largeur_ecran-width)*2; dest+=(Screen_width-width)*2;
} }
UpdateRect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
} }
void Clear_brush_Wide(word x_pos,word y_pos,__attribute__((unused)) word x_offset,__attribute__((unused)) word y_offset,word width,word height,__attribute__((unused))byte Couleur_de_transparence,word image_width) void Clear_brush_wide(word x_pos,word y_pos,__attribute__((unused)) word x_offset,__attribute__((unused)) word y_offset,word width,word height,__attribute__((unused))byte transp_color,word image_width)
{ {
byte* Dest=Ecran+x_pos*2+y_pos*2*Largeur_ecran; //On va se mettre en 0,0 dans l'écran (Dest) byte* dest=Screen+x_pos*2+y_pos*2*Screen_width; //On va se mettre en 0,0 dans l'écran (dest)
byte* Src = ( y_pos + Principal_Decalage_Y ) * image_width + x_pos + Principal_Decalage_X + Principal_Ecran; //Coords de départ ds la source (Src) byte* src = ( y_pos + Main_offset_Y ) * image_width + x_pos + Main_offset_X + Main_screen; //Coords de départ ds la source (src)
int y; int y;
int x; int x;
@ -218,27 +218,27 @@ void Clear_brush_Wide(word x_pos,word y_pos,__attribute__((unused)) word x_offse
for(x=width;x!=0;x--) for(x=width;x!=0;x--)
//Pour chaque pixel //Pour chaque pixel
{ {
*(Dest+1)=*Dest=*Src; *(dest+1)=*dest=*src;
// On passe au pixel suivant // On passe au pixel suivant
Src++; src++;
Dest+=2; dest+=2;
} }
// On passe à la ligne suivante // On passe à la ligne suivante
Src+=image_width-width; src+=image_width-width;
Dest+=(Largeur_ecran-width)*2; dest+=(Screen_width-width)*2;
} }
UpdateRect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
} }
// Affiche une brosse (arbitraire) à l'écran // Affiche une brosse (arbitraire) à l'écran
void Affiche_brosse_Wide(byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte Couleur_de_transparence,word Largeur_brosse) void Display_brush_wide(byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)
{ {
// Dest = Position à l'écran // dest = Position à l'écran
byte* Dest = Ecran + y_pos * 2 * Largeur_ecran + x_pos * 2; byte* dest = Screen + y_pos * 2 * Screen_width + x_pos * 2;
// Src = Position dans la brosse // src = Position dans la brosse
byte* Src = brush + y_offset * Largeur_brosse + x_offset; byte* src = brush + y_offset * brush_width + x_offset;
word x,y; word x,y;
@ -249,25 +249,25 @@ void Affiche_brosse_Wide(byte * brush, word x_pos,word y_pos,word x_offset,word
for(x = width;x > 0; x--) for(x = width;x > 0; x--)
{ {
// On vérifie que ce n'est pas la transparence // On vérifie que ce n'est pas la transparence
if(*Src != Couleur_de_transparence) if(*src != transp_color)
{ {
*(Dest+1) = *Dest = *Src; *(dest+1) = *dest = *src;
} }
// Pixel suivant // Pixel suivant
Src++; Dest+=2; src++; dest+=2;
} }
// On passe à la ligne suivante // On passe à la ligne suivante
Dest = Dest + (Largeur_ecran - width)*2; dest = dest + (Screen_width - width)*2;
Src = Src + Largeur_brosse - width; src = src + brush_width - width;
} }
} }
void Remap_screen_Wide(word x_pos,word y_pos,word width,word height,byte * Table_de_conversion) void Remap_screen_wide(word x_pos,word y_pos,word width,word height,byte * conversion_table)
{ {
// Dest = coords a l'écran // dest = coords a l'écran
byte* Dest = Ecran + y_pos * 2 * Largeur_ecran + x_pos * 2; byte* dest = Screen + y_pos * 2 * Screen_width + x_pos * 2;
int x,y; int x,y;
// Pour chaque ligne // Pour chaque ligne
@ -276,71 +276,71 @@ void Remap_screen_Wide(word x_pos,word y_pos,word width,word height,byte * Table
// Pour chaque pixel // Pour chaque pixel
for(x=width;x>0;x--) for(x=width;x>0;x--)
{ {
*(Dest+1) = *Dest = Table_de_conversion[*Dest]; *(dest+1) = *dest = conversion_table[*dest];
Dest +=2; dest +=2;
} }
Dest = Dest + (Largeur_ecran - width)*2; dest = dest + (Screen_width - width)*2;
} }
UpdateRect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
} }
void Afficher_une_ligne_ecran_fast_Wide(word x_pos,word y_pos,word width,byte * line) void Display_line_on_screen_fast_wide(word x_pos,word y_pos,word width,byte * line)
/* On affiche toute une ligne de pixels telle quelle. */ /* On affiche toute une ligne de pixels telle quelle. */
/* Utilisée si le buffer contient déja des pixel doublés. */ /* Utilisée si le buffer contient déja des pixel doublés. */
{ {
memcpy(Ecran+x_pos*2+y_pos*2*Largeur_ecran,line,width*2); memcpy(Screen+x_pos*2+y_pos*2*Screen_width,line,width*2);
} }
void Afficher_une_ligne_ecran_Wide(word x_pos,word y_pos,word width,byte * line) void Display_line_on_screen_wide(word x_pos,word y_pos,word width,byte * line)
/* On affiche une ligne de pixels en les doublant. */ /* On affiche une ligne de pixels en les doublant. */
{ {
int x; int x;
byte *Dest; byte *dest;
Dest=Ecran+x_pos*2+y_pos*2*Largeur_ecran; dest=Screen+x_pos*2+y_pos*2*Screen_width;
for(x=width;x>0;x--) for(x=width;x>0;x--)
{ {
*Dest=*line; *dest=*line;
Dest++; dest++;
*Dest=*line; *dest=*line;
Dest++; dest++;
line++; line++;
} }
} }
void Afficher_une_ligne_transparente_mono_a_l_ecran_Wide( void Display_transparent_mono_line_on_screen_wide(
word x_pos, word y_pos, word width, byte* line, word x_pos, word y_pos, word width, byte* line,
byte Couleur_transparence, byte Couleur) byte transp_color, byte color)
// Affiche une ligne à l'écran avec une couleur + transparence. // Affiche une ligne à l'écran avec une couleur + transparence.
// Utilisé par les brosses en mode zoom // Utilisé par les brosses en mode zoom
{ {
byte* Dest = Ecran+ y_pos*2 * Largeur_ecran + x_pos*2; byte* dest = Screen+ y_pos*2 * Screen_width + x_pos*2;
int x; int x;
// Pour chaque pixel // Pour chaque pixel
for(x=0;x<width;x++) for(x=0;x<width;x++)
{ {
if (Couleur_transparence!=*line) if (transp_color!=*line)
{ {
*Dest = Couleur; *dest = color;
*(Dest+1) = Couleur; *(dest+1) = color;
} }
line ++; // Pixel suivant line ++; // Pixel suivant
Dest+=2; dest+=2;
} }
} }
void Lire_une_ligne_ecran_Wide(word x_pos,word y_pos,word width,byte * line) void Read_line_screen_wide(word x_pos,word y_pos,word width,byte * line)
{ {
memcpy(line,Largeur_ecran * 2 * y_pos + x_pos * 2 + Ecran,width*2); memcpy(line,Screen_width * 2 * y_pos + x_pos * 2 + Screen,width*2);
} }
void Afficher_partie_de_l_ecran_zoomee_Wide( void Display_part_of_screen_scaled_wide(
word width, // width non zoomée word width, // width non zoomée
word height, // height zoomée word height, // height zoomée
word image_width,byte * Buffer) word image_width,byte * buffer)
{ {
byte* Src = Principal_Ecran + Loupe_Decalage_Y * image_width byte* src = Main_screen + Main_magnifier_offset_Y * image_width
+ Loupe_Decalage_X; + Main_magnifier_offset_X;
int y = 0; // Ligne en cours de traitement int y = 0; // Ligne en cours de traitement
// Pour chaque ligne à zoomer // Pour chaque ligne à zoomer
@ -349,163 +349,163 @@ void Afficher_partie_de_l_ecran_zoomee_Wide(
int x; int x;
// On éclate la ligne // On éclate la ligne
Zoomer_une_ligne(Src,Buffer,Loupe_Facteur*2,width); Zoom_a_line(src,buffer,Main_magnifier_factor*2,width);
// On l'affiche Facteur fois, sur des lignes consécutives // On l'affiche Facteur fois, sur des lignes consécutives
x = Loupe_Facteur; x = Main_magnifier_factor;
// Pour chaque ligne // Pour chaque ligne
do{ do{
// On affiche la ligne zoomée // On affiche la ligne zoomée
Afficher_une_ligne_ecran_fast_Wide( Display_line_on_screen_fast_wide(
Principal_X_Zoom, y, width*Loupe_Facteur, Main_X_zoom, y, width*Main_magnifier_factor,
Buffer buffer
); );
// On passe à la suivante // On passe à la suivante
y++; y++;
if(y==height) if(y==height)
{ {
UpdateRect(Principal_X_Zoom,0, Update_rect(Main_X_zoom,0,
width*Loupe_Facteur,height); width*Main_magnifier_factor,height);
return; return;
} }
x--; x--;
}while (x > 0); }while (x > 0);
Src += image_width; src += image_width;
} }
// ATTENTION on n'arrive jamais ici ! // ATTENTION on n'arrive jamais ici !
} }
void Afficher_une_ligne_transparente_a_l_ecran_Wide(word x_pos,word y_pos,word width,byte* line,byte Couleur_transparence) void Display_transparent_line_on_screen_wide(word x_pos,word y_pos,word width,byte* line,byte transp_color)
{ {
byte* Src = line; byte* src = line;
byte* Dest = Ecran + y_pos * 2 * Largeur_ecran + x_pos * 2; byte* dest = Screen + y_pos * 2 * Screen_width + x_pos * 2;
word x; word x;
// Pour chaque pixel de la ligne // Pour chaque pixel de la ligne
for(x = width;x > 0;x--) for(x = width;x > 0;x--)
{ {
if(*Src!=Couleur_transparence) if(*src!=transp_color)
{ {
*Dest = *Src; *dest = *src;
*(Dest+1) = *Src; *(dest+1) = *src;
} }
Src++; src++;
Dest+=2; dest+=2;
} }
} }
// Affiche une partie de la brosse couleur zoomée // Affiche une partie de la brosse couleur zoomée
void Display_brush_Color_zoom_Wide(word x_pos,word y_pos, void Display_brush_color_zoom_wide(word x_pos,word y_pos,
word x_offset,word y_offset, word x_offset,word y_offset,
word width, // width non zoomée word width, // width non zoomée
word Pos_Y_Fin,byte Couleur_de_transparence, word end_y_pos,byte transp_color,
word Largeur_brosse, // width réelle de la brosse word brush_width, // width réelle de la brosse
byte * Buffer) byte * buffer)
{ {
byte* Src = Brosse+y_offset*Largeur_brosse + x_offset; byte* src = Brush+y_offset*brush_width + x_offset;
word y = y_pos; word y = y_pos;
byte bx; byte bx;
// Pour chaque ligne // Pour chaque ligne
while(1) while(1)
{ {
Zoomer_une_ligne(Src,Buffer,Loupe_Facteur,width); Zoom_a_line(src,buffer,Main_magnifier_factor,width);
// On affiche facteur fois la ligne zoomée // On affiche facteur fois la ligne zoomée
for(bx=Loupe_Facteur;bx>0;bx--) for(bx=Main_magnifier_factor;bx>0;bx--)
{ {
Afficher_une_ligne_transparente_a_l_ecran_Wide(x_pos,y,width*Loupe_Facteur,Buffer,Couleur_de_transparence); Display_transparent_line_on_screen_wide(x_pos,y,width*Main_magnifier_factor,buffer,transp_color);
y++; y++;
if(y==Pos_Y_Fin) if(y==end_y_pos)
{ {
return; return;
} }
} }
Src += Largeur_brosse; src += brush_width;
} }
// ATTENTION zone jamais atteinte // ATTENTION zone jamais atteinte
} }
void Display_brush_Mono_zoom_Wide(word x_pos, word y_pos, void Display_brush_mono_zoom_wide(word x_pos, word y_pos,
word x_offset, word y_offset, word x_offset, word y_offset,
word width, // width non zoomée word width, // width non zoomée
word Pos_Y_Fin, word end_y_pos,
byte Couleur_de_transparence, byte Couleur, byte transp_color, byte color,
word Largeur_brosse, // width réelle de la brosse word brush_width, // width réelle de la brosse
byte * Buffer byte * buffer
) )
{ {
byte* Src = Brosse + y_offset * Largeur_brosse + x_offset; byte* src = Brush + y_offset * brush_width + x_offset;
int y=y_pos; int y=y_pos;
//Pour chaque ligne à zoomer : //Pour chaque ligne à zoomer :
while(1) while(1)
{ {
int BX; int bx;
// Src = Ligne originale // src = Ligne originale
// On éclate la ligne // On éclate la ligne
Zoomer_une_ligne(Src,Buffer,Loupe_Facteur,width); Zoom_a_line(src,buffer,Main_magnifier_factor,width);
// On affiche la ligne Facteur fois à l'écran (sur des // On affiche la ligne Facteur fois à l'écran (sur des
// lignes consécutives) // lignes consécutives)
BX = Loupe_Facteur; bx = Main_magnifier_factor;
// Pour chaque ligne écran // Pour chaque ligne écran
do do
{ {
// On affiche la ligne zoomée // On affiche la ligne zoomée
Afficher_une_ligne_transparente_mono_a_l_ecran_Wide( Display_transparent_mono_line_on_screen_wide(
x_pos, y, width * Loupe_Facteur, x_pos, y, width * Main_magnifier_factor,
Buffer, Couleur_de_transparence, Couleur buffer, transp_color, color
); );
// On passe à la ligne suivante // On passe à la ligne suivante
y++; y++;
// On vérifie qu'on est pas à la ligne finale // On vérifie qu'on est pas à la ligne finale
if(y == Pos_Y_Fin) if(y == end_y_pos)
{ {
UpdateRect( x_pos, y_pos, Update_rect( x_pos, y_pos,
width * Loupe_Facteur, Pos_Y_Fin - y_pos ); width * Main_magnifier_factor, end_y_pos - y_pos );
return; return;
} }
BX --; bx --;
} }
while (BX > 0); while (bx > 0);
// Passage à la ligne suivante dans la brosse aussi // Passage à la ligne suivante dans la brosse aussi
Src+=Largeur_brosse; src+=brush_width;
} }
} }
void Clear_brush_zoom_Wide(word x_pos,word y_pos,word x_offset,word y_offset,word width,word Pos_Y_Fin,__attribute__((unused)) byte Couleur_de_transparence,word image_width,byte * Buffer) void Clear_brush_scaled_wide(word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,__attribute__((unused)) byte transp_color,word image_width,byte * buffer)
{ {
// En fait on va recopier l'image non zoomée dans la partie zoomée ! // En fait on va recopier l'image non zoomée dans la partie zoomée !
byte* Src = Principal_Ecran + y_offset * image_width + x_offset; byte* src = Main_screen + y_offset * image_width + x_offset;
int y = y_pos; int y = y_pos;
int bx; int bx;
// Pour chaque ligne à zoomer // Pour chaque ligne à zoomer
while(1){ while(1){
Zoomer_une_ligne(Src,Buffer,Loupe_Facteur*2,width); Zoom_a_line(src,buffer,Main_magnifier_factor*2,width);
bx=Loupe_Facteur; bx=Main_magnifier_factor;
// Pour chaque ligne // Pour chaque ligne
do{ do{
Afficher_une_ligne_ecran_fast_Wide(x_pos,y, Display_line_on_screen_fast_wide(x_pos,y,
width * Loupe_Facteur,Buffer); width * Main_magnifier_factor,buffer);
// Ligne suivante // Ligne suivante
y++; y++;
if(y==Pos_Y_Fin) if(y==end_y_pos)
{ {
UpdateRect(x_pos,y_pos, Update_rect(x_pos,y_pos,
width*Loupe_Facteur,Pos_Y_Fin-y_pos); width*Main_magnifier_factor,end_y_pos-y_pos);
return; return;
} }
bx--; bx--;
}while(bx!=0); }while(bx!=0);
Src+= image_width; src+= image_width;
} }
} }

View File

@ -21,25 +21,25 @@
*/ */
#include "struct.h" #include "struct.h"
void Pixel_Wide (word x,word y,byte Couleur); void Pixel_wide (word x,word y,byte color);
byte Lit_Pixel_Wide (word x,word y); byte Read_pixel_wide (word x,word y);
void Block_Wide (word Debut_X,word Debut_Y,word width,word height,byte Couleur); void Block_wide (word start_x,word start_y,word width,word height,byte color);
void Pixel_Preview_Normal_Wide (word x,word y,byte Couleur); void Pixel_preview_normal_wide (word x,word y,byte color);
void Pixel_Preview_Loupe_Wide (word x,word y,byte Couleur); void Pixel_preview_magnifier_wide (word x,word y,byte color);
void Ligne_horizontale_XOR_Wide (word x_pos,word y_pos,word width); void Horizontal_XOR_line_wide (word x_pos,word y_pos,word width);
void Ligne_verticale_XOR_Wide (word x_pos,word y_pos,word height); void Vertical_XOR_line_wide (word x_pos,word y_pos,word height);
void Display_brush_Color_Wide (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte Couleur_de_transparence,word Largeur_brosse); void Display_brush_color_wide (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width);
void Display_brush_Mono_Wide (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte Couleur_de_transparence,byte Couleur,word Largeur_brosse); void Display_brush_mono_wide (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,byte color,word brush_width);
void Clear_brush_Wide (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte Couleur_de_transparence,word image_width); void Clear_brush_wide (word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width);
void Remap_screen_Wide (word x_pos,word y_pos,word width,word height,byte * Table_de_conversion); void Remap_screen_wide (word x_pos,word y_pos,word width,word height,byte * conversion_table);
void Afficher_partie_de_l_ecran_Wide (word width,word height,word image_width); void Display_part_of_screen_wide (word width,word height,word image_width);
void Afficher_une_ligne_ecran_Wide (word x_pos,word y_pos,word width,byte * line); void Display_line_on_screen_wide (word x_pos,word y_pos,word width,byte * line);
void Lire_une_ligne_ecran_Wide (word x_pos,word y_pos,word width,byte * line); void Read_line_screen_wide (word x_pos,word y_pos,word width,byte * line);
void Afficher_partie_de_l_ecran_zoomee_Wide(word width,word height,word image_width,byte * Buffer); void Display_part_of_screen_scaled_wide(word width,word height,word image_width,byte * buffer);
void Display_brush_Color_zoom_Wide (word x_pos,word y_pos,word x_offset,word y_offset,word width,word Pos_Y_Fin,byte Couleur_de_transparence,word Largeur_brosse,byte * Buffer); void Display_brush_color_zoom_wide (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word brush_width,byte * buffer);
void Display_brush_Mono_zoom_Wide (word x_pos,word y_pos,word x_offset,word y_offset,word width,word Pos_Y_Fin,byte Couleur_de_transparence,byte Couleur,word Largeur_brosse,byte * Buffer); void Display_brush_mono_zoom_wide (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,byte color,word brush_width,byte * buffer);
void Clear_brush_zoom_Wide (word x_pos,word y_pos,word x_offset,word y_offset,word width,word Pos_Y_Fin,byte Couleur_de_transparence,word image_width,byte * Buffer); void Clear_brush_scaled_wide (word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word image_width,byte * buffer);
void Affiche_brosse_Wide (byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte Couleur_de_transparence,word Largeur_brosse); void Display_brush_wide (byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width);
void Afficher_une_ligne_ecran_fast_Wide (word x_pos,word y_pos,word width,byte * line); void Display_line_on_screen_fast_wide (word x_pos,word y_pos,word width,byte * line);
void Afficher_une_ligne_transparente_a_l_ecran_Wide(word x_pos,word y_pos,word width,byte* line,byte Couleur_transparence); void Display_transparent_line_on_screen_wide(word x_pos,word y_pos,word width,byte* line,byte transp_color);

584
readini.c

File diff suppressed because it is too large Load Diff

View File

@ -18,6 +18,6 @@
write to the Free Software Foundation, Inc., write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
int Charger_INI(T_Config * Conf); int Load_INI(T_Config * conf);
int Charger_INI_Seek_pattern(char * Buffer,char * Pattern); int Load_INI_seek_pattern(char * buffer,char * pattern);
void Charger_INI_Clear_string(char * String); void Load_INI_clear_string(char * str);

View File

@ -39,165 +39,165 @@
#include "windows.h" #include "windows.h"
#include "input.h" #include "input.h"
#define COULEUR_TEXTE CM_Noir #define TEXT_COLOR MC_Black
#define COULEUR_FOND CM_Clair #define BACKGROUND_COLOR MC_Light
#define COULEUR_TEXTE_CURSEUR CM_Noir #define CURSOR_COLOR MC_Black
#define COULEUR_FOND_CURSEUR CM_Fonce #define CURSOR_BACKGROUND_COLOR MC_Dark
// Suppresion d'un caractère à une certaine POSITION dans une CHAINE. // Suppresion d'un caractère à une certaine POSITION dans une CHAINE.
void Supprimer_caractere(char * Chaine, byte position) void Remove_character(char * str, byte position)
{ {
for (;Chaine[position]!='\0';position++) for (;str[position]!='\0';position++)
Chaine[position]=Chaine[position+1]; str[position]=str[position+1];
} }
void Inserer_caractere(char * Chaine, char letter, byte position) void Insert_character(char * str, char letter, byte position)
// Insertion d'une LETTRE à une certaine POSITION // Insertion d'une LETTRE à une certaine POSITION
// dans une CHAINE d'une certaine TAILLE. // dans une CHAINE d'une certaine TAILLE.
{ {
char Char_tempo; char temp_char;
for (;letter!='\0';position++) for (;letter!='\0';position++)
{ {
// On mémorise le caractère qui se trouve en "position" // On mémorise le caractère qui se trouve en "position"
Char_tempo=Chaine[position]; temp_char=str[position];
// On splotch la lettre à insérer // On splotch la lettre à insérer
Chaine[position]=letter; str[position]=letter;
// On place le caractère mémorisé dans "letter" comme nouvelle lettre à insérer // On place le caractère mémorisé dans "letter" comme nouvelle lettre à insérer
letter=Char_tempo; letter=temp_char;
} }
// On termine la chaine // On termine la chaine
Chaine[position]='\0'; str[position]='\0';
} }
int CaractereValide(int c) int Valid_character(int c)
{ {
// Sous Linux: Seul le / est strictement interdit, mais beaucoup // Sous Linux: Seul le / est strictement interdit, mais beaucoup
// d'autres poseront des problèmes au shell, alors on évite. // d'autres poseront des problèmes au shell, alors on évite.
// Sous Windows : c'est moins grave car le fopen() échouerait de toutes façons. // Sous Windows : c'est moins grave car le fopen() échouerait de toutes façons.
// AmigaOS4: Pas de ':' car utilisé pour les volumes. // AmigaOS4: Pas de ':' car utilisé pour les volumes.
#if defined(__WIN32__) #if defined(__WIN32__)
char CaracteresInterdits[] = {'/', '|', '?', '*', '<', '>', ':', '\\'}; char forbidden_char[] = {'/', '|', '?', '*', '<', '>', ':', '\\'};
#elif defined (__amigaos4__) #elif defined (__amigaos4__)
char CaracteresInterdits[] = {'/', '|', '?', '*', '<', '>', ':'}; char forbidden_char[] = {'/', '|', '?', '*', '<', '>', ':'};
#else #else
char CaracteresInterdits[] = {'/', '|', '?', '*', '<', '>'}; char forbidden_char[] = {'/', '|', '?', '*', '<', '>'};
#endif #endif
int position; int position;
if (c < ' ' || c > 255) if (c < ' ' || c > 255)
return 0; return 0;
for (position=0; position<(long)sizeof(CaracteresInterdits); position++) for (position=0; position<(long)sizeof(forbidden_char); position++)
if (c == CaracteresInterdits[position]) if (c == forbidden_char[position])
return 0; return 0;
return 1; return 1;
} }
void Rafficher_toute_la_chaine(word x_pos,word y_pos,char * Chaine,byte position) void Display_whole_string(word x_pos,word y_pos,char * str,byte position)
{ {
Print_dans_fenetre(x_pos,y_pos,Chaine,COULEUR_TEXTE,COULEUR_FOND); Print_in_window(x_pos,y_pos,str,TEXT_COLOR,BACKGROUND_COLOR);
Print_char_dans_fenetre(x_pos+(position<<3),y_pos,Chaine[position],COULEUR_TEXTE_CURSEUR,COULEUR_FOND_CURSEUR); Print_char_in_window(x_pos+(position<<3),y_pos,str[position],CURSOR_COLOR,CURSOR_BACKGROUND_COLOR);
} }
/**************************************************************************** /****************************************************************************
* Enhanced super scanf deluxe pro plus giga mieux :-) * * Enhanced super scanf deluxe pro plus giga mieux :-) *
****************************************************************************/ ****************************************************************************/
byte Readline(word x_pos,word y_pos,char * Chaine,byte Taille_affichee,byte Type_saisie) byte Readline(word x_pos,word y_pos,char * str,byte visible_size,byte input_type)
// Paramètres: // Paramètres:
// x_pos, y_pos : Coordonnées de la saisie dans la fenêtre // x_pos, y_pos : Coordonnées de la saisie dans la fenêtre
// Chaine : Chaîne recevant la saisie (et contenant éventuellement une valeur initiale) // str : Chaîne recevant la saisie (et contenant éventuellement une valeur initiale)
// Taille_maxi : Nombre de caractères logeant dans la zone de saisie // max_size : Nombre de caractères logeant dans la zone de saisie
// Type_saisie : 0=Chaîne, 1=Nombre, 2=Nom de fichier // input_type : 0=Chaîne, 1=Nombre, 2=Nom de fichier
// Sortie: // Sortie:
// 0: Sortie par annulation (Esc.) / 1: sortie par acceptation (Return) // 0: Sortie par annulation (Esc.) / 1: sortie par acceptation (Return)
{ {
byte Taille_maxi; byte max_size;
// Grosse astuce pour les noms de fichiers: La taille affichée est différente // Grosse astuce pour les noms de fichiers: La taille affichée est différente
// de la taille maximum gérée. // de la taille maximum gérée.
if (Type_saisie == 2) if (input_type == 2)
Taille_maxi = 255; max_size = 255;
else else
Taille_maxi = Taille_affichee; max_size = visible_size;
return Readline_ex(x_pos,y_pos,Chaine,Taille_affichee,Taille_maxi,Type_saisie); return Readline_ex(x_pos,y_pos,str,visible_size,max_size,input_type);
} }
/**************************************************************************** /****************************************************************************
* Enhanced super scanf deluxe pro plus giga mieux :-) * * Enhanced super scanf deluxe pro plus giga mieux :-) *
****************************************************************************/ ****************************************************************************/
byte Readline_ex(word x_pos,word y_pos,char * Chaine,byte Taille_affichee,byte Taille_maxi, byte Type_saisie) byte Readline_ex(word x_pos,word y_pos,char * str,byte visible_size,byte max_size, byte input_type)
// Paramètres: // Paramètres:
// x_pos, y_pos : Coordonnées de la saisie dans la fenêtre // x_pos, y_pos : Coordonnées de la saisie dans la fenêtre
// Chaine : Chaîne recevant la saisie (et contenant éventuellement une valeur initiale) // str : Chaîne recevant la saisie (et contenant éventuellement une valeur initiale)
// Taille_maxi : Nombre de caractères logeant dans la zone de saisie // max_size : Nombre de caractères logeant dans la zone de saisie
// Type_saisie : 0=Chaîne, 1=Nombre, 2=Nom de fichier // input_type : 0=Chaîne, 1=Nombre, 2=Nom de fichier
// Sortie: // Sortie:
// 0: Sortie par annulation (Esc.) / 1: sortie par acceptation (Return) // 0: Sortie par annulation (Esc.) / 1: sortie par acceptation (Return)
{ {
char Chaine_initiale[256]; char initial_string[256];
char Chaine_affichee[256]; char display_string[256];
byte position; byte position;
byte size; byte size;
word Touche_lue=0; word input_key=0;
byte Touche_autorisee; byte is_authorized;
byte offset=0; // Indice du premier caractère affiché byte offset=0; // index du premier caractère affiché
Effacer_curseur(); Hide_cursor();
// Effacement de la chaîne // Effacement de la chaîne
Block(Fenetre_Pos_X+(x_pos*Menu_Facteur_X),Fenetre_Pos_Y+(y_pos*Menu_Facteur_Y), Block(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y),
Taille_affichee*(Menu_Facteur_X<<3),(Menu_Facteur_Y<<3),COULEUR_FOND); visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3),BACKGROUND_COLOR);
UpdateRect(Fenetre_Pos_X+(x_pos*Menu_Facteur_X),Fenetre_Pos_Y+(y_pos*Menu_Facteur_Y), Update_rect(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y),
Taille_affichee*(Menu_Facteur_X<<3),(Menu_Facteur_Y<<3)); visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3));
// Mise à jour des variables se rapportant à la chaîne en fonction de la chaîne initiale // Mise à jour des variables se rapportant à la chaîne en fonction de la chaîne initiale
strcpy(Chaine_initiale,Chaine); strcpy(initial_string,str);
// Si on a commencé à editer par un clic-droit, on vide la chaine. // Si on a commencé à editer par un clic-droit, on vide la chaine.
if (Mouse_K==A_DROITE) if (Mouse_K==RIGHT_SIDE)
Chaine[0]='\0'; str[0]='\0';
else if (Type_saisie==1) else if (input_type==1)
snprintf(Chaine,10,"%d",atoi(Chaine)); // On tasse la chaine à gauche snprintf(str,10,"%d",atoi(str)); // On tasse la chaine à gauche
size=strlen(Chaine); size=strlen(str);
position=(size<Taille_maxi)? size:size-1; position=(size<max_size)? size:size-1;
if (position-offset>Taille_affichee) if (position-offset>visible_size)
offset=position-Taille_affichee+1; offset=position-visible_size+1;
// Formatage d'une partie de la chaine (si trop longue pour tenir) // Formatage d'une partie de la chaine (si trop longue pour tenir)
strncpy(Chaine_affichee, Chaine + offset, Taille_affichee); strncpy(display_string, str + offset, visible_size);
Chaine_affichee[Taille_affichee]='\0'; display_string[visible_size]='\0';
if (offset>0) if (offset>0)
Chaine_affichee[0]=CARACTERE_TRIANGLE_GAUCHE; display_string[0]=LEFT_TRIANGLE_CHARACTER;
if (Taille_affichee + offset + 1 < size ) if (visible_size + offset + 1 < size )
Chaine_affichee[Taille_affichee-1]=CARACTERE_TRIANGLE_DROIT; display_string[visible_size-1]=RIGHT_TRIANGLE_CHARACTER;
Rafficher_toute_la_chaine(x_pos,y_pos,Chaine_affichee,position - offset); Display_whole_string(x_pos,y_pos,display_string,position - offset);
UpdateRect(Fenetre_Pos_X+(x_pos*Menu_Facteur_X),Fenetre_Pos_Y+(y_pos*Menu_Facteur_Y), Update_rect(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y),
Taille_affichee*(Menu_Facteur_X<<3),(Menu_Facteur_Y<<3)); visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3));
Flush_update(); Flush_update();
while ((Touche_lue!=SDLK_RETURN) && (Touche_lue!=TOUCHE_ESC)) while ((input_key!=SDLK_RETURN) && (input_key!=KEY_ESC))
{ {
Afficher_curseur(); Display_cursor();
do do
{ {
if(!Get_input()) Wait_VBL(); if(!Get_input()) Wait_VBL();
Touche_lue=Touche_ANSI; input_key=Key_ANSI;
} while(Touche_lue==0); } while(input_key==0);
Effacer_curseur(); Hide_cursor();
switch (Touche_lue) switch (input_key)
{ {
case SDLK_DELETE : // Suppr. case SDLK_DELETE : // Suppr.
if (position<size) if (position<size)
{ {
Supprimer_caractere(Chaine,position); Remove_character(str,position);
size--; size--;
// Effacement de la chaîne // Effacement de la chaîne
Block(Fenetre_Pos_X+(x_pos*Menu_Facteur_X),Fenetre_Pos_Y+(y_pos*Menu_Facteur_Y), Block(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y),
Taille_affichee*(Menu_Facteur_X<<3),(Menu_Facteur_Y<<3),COULEUR_FOND); visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3),BACKGROUND_COLOR);
goto affichage; goto affichage;
} }
break; break;
@ -206,8 +206,8 @@ byte Readline_ex(word x_pos,word y_pos,char * Chaine,byte Taille_affichee,byte T
{ {
// Effacement de la chaîne // Effacement de la chaîne
if (position==size) if (position==size)
Block(Fenetre_Pos_X+(x_pos*Menu_Facteur_X),Fenetre_Pos_Y+(y_pos*Menu_Facteur_Y), Block(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y),
Taille_affichee*(Menu_Facteur_X<<3),(Menu_Facteur_Y<<3),COULEUR_FOND); visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3),BACKGROUND_COLOR);
position--; position--;
if (offset > 0 && (position == 0 || position < (offset + 1))) if (offset > 0 && (position == 0 || position < (offset + 1)))
offset--; offset--;
@ -215,12 +215,12 @@ byte Readline_ex(word x_pos,word y_pos,char * Chaine,byte Taille_affichee,byte T
} }
break; break;
case SDLK_RIGHT : // Droite case SDLK_RIGHT : // Droite
if ((position<size) && (position<Taille_maxi-1)) if ((position<size) && (position<max_size-1))
{ {
position++; position++;
//if (position > Taille_affichee + offset - 2) //if (position > visible_size + offset - 2)
//if (offset + Taille_affichee < Taille_maxi && (position == size || (position > Taille_affichee + offset - 2))) //if (offset + visible_size < max_size && (position == size || (position > visible_size + offset - 2)))
if (Chaine_affichee[position-offset]==CARACTERE_TRIANGLE_DROIT || position-offset>=Taille_affichee) if (display_string[position-offset]==RIGHT_TRIANGLE_CHARACTER || position-offset>=visible_size)
offset++; offset++;
goto affichage; goto affichage;
} }
@ -230,19 +230,19 @@ byte Readline_ex(word x_pos,word y_pos,char * Chaine,byte Taille_affichee,byte T
{ {
// Effacement de la chaîne // Effacement de la chaîne
if (position==size) if (position==size)
Block(Fenetre_Pos_X+(x_pos*Menu_Facteur_X),Fenetre_Pos_Y+(y_pos*Menu_Facteur_Y), Block(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y),
Taille_affichee*(Menu_Facteur_X<<3),(Menu_Facteur_Y<<3),COULEUR_FOND); visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3),BACKGROUND_COLOR);
position = 0; position = 0;
offset = 0; offset = 0;
goto affichage; goto affichage;
} }
break; break;
case SDLK_END : // End case SDLK_END : // End
if ((position<size) && (position<Taille_maxi-1)) if ((position<size) && (position<max_size-1))
{ {
position=(size<Taille_maxi)?size:size-1; position=(size<max_size)?size:size-1;
if (position-offset>Taille_affichee) if (position-offset>visible_size)
offset=position-Taille_affichee+1; offset=position-visible_size+1;
goto affichage; goto affichage;
} }
break; break;
@ -253,100 +253,100 @@ byte Readline_ex(word x_pos,word y_pos,char * Chaine,byte Taille_affichee,byte T
position--; position--;
if (offset > 0 && (position == 0 || position < (offset + 1))) if (offset > 0 && (position == 0 || position < (offset + 1)))
offset--; offset--;
Supprimer_caractere(Chaine,position); Remove_character(str,position);
size--; size--;
// Effacement de la chaîne // Effacement de la chaîne
Block(Fenetre_Pos_X+(x_pos*Menu_Facteur_X),Fenetre_Pos_Y+(y_pos*Menu_Facteur_Y), Block(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y),
Taille_affichee*(Menu_Facteur_X<<3),(Menu_Facteur_Y<<3),COULEUR_FOND); visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3),BACKGROUND_COLOR);
goto affichage; goto affichage;
} }
break; break;
case SDLK_RETURN : case SDLK_RETURN :
break; break;
case TOUCHE_ESC : case KEY_ESC :
// On restaure la chaine initiale // On restaure la chaine initiale
strcpy(Chaine,Chaine_initiale); strcpy(str,initial_string);
size=strlen(Chaine); size=strlen(str);
break; break;
default : default :
if (size<Taille_maxi) if (size<max_size)
{ {
// On va regarder si l'utilisateur le droit de se servir de cette touche // On va regarder si l'utilisateur le droit de se servir de cette touche
Touche_autorisee=0; // On commence par supposer qu'elle est interdite is_authorized=0; // On commence par supposer qu'elle est interdite
switch(Type_saisie) switch(input_type)
{ {
case 0 : // N'importe quelle chaîne: case 0 : // N'importe quelle chaîne:
if (Touche_lue>=' ' && Touche_lue<= 255) if (input_key>=' ' && input_key<= 255)
Touche_autorisee=1; is_authorized=1;
break; break;
case 1 : // Nombre case 1 : // Nombre
if ( (Touche_lue>='0') && (Touche_lue<='9') ) if ( (input_key>='0') && (input_key<='9') )
Touche_autorisee=1; is_authorized=1;
break; break;
default : // Nom de fichier default : // Nom de fichier
// On regarde si la touche est autorisée // On regarde si la touche est autorisée
if ( CaractereValide(Touche_lue)) if ( Valid_character(input_key))
Touche_autorisee=1; is_authorized=1;
} // Fin du "switch(Type_saisie)" } // End du "switch(input_type)"
// Si la touche était autorisée... // Si la touche était autorisée...
if (Touche_autorisee) if (is_authorized)
{ {
// ... alors on l'insère ... // ... alors on l'insère ...
Inserer_caractere(Chaine,Touche_lue,position/*,size*/); Insert_character(str,input_key,position/*,size*/);
// ce qui augmente la taille de la chaine // ce qui augmente la taille de la chaine
size++; size++;
// et qui risque de déplacer le curseur vers la droite // et qui risque de déplacer le curseur vers la droite
if (size<Taille_maxi) if (size<max_size)
{ {
position++; position++;
if (Chaine_affichee[position-offset]==CARACTERE_TRIANGLE_DROIT || position-offset>=Taille_affichee) if (display_string[position-offset]==RIGHT_TRIANGLE_CHARACTER || position-offset>=visible_size)
offset++; offset++;
} }
// Enfin, on raffiche la chaine // Enfin, on raffiche la chaine
goto affichage; goto affichage;
} // Fin du test d'autorisation de touche } // End du test d'autorisation de touche
} // Fin du test de place libre } // End du test de place libre
break; break;
affichage: affichage:
size=strlen(Chaine); size=strlen(str);
// Formatage d'une partie de la chaine (si trop longue pour tenir) // Formatage d'une partie de la chaine (si trop longue pour tenir)
strncpy(Chaine_affichee, Chaine + offset, Taille_affichee); strncpy(display_string, str + offset, visible_size);
Chaine_affichee[Taille_affichee]='\0'; display_string[visible_size]='\0';
if (offset>0) if (offset>0)
Chaine_affichee[0]=CARACTERE_TRIANGLE_GAUCHE; display_string[0]=LEFT_TRIANGLE_CHARACTER;
if (Taille_affichee + offset + 0 < size ) if (visible_size + offset + 0 < size )
Chaine_affichee[Taille_affichee-1]=CARACTERE_TRIANGLE_DROIT; display_string[visible_size-1]=RIGHT_TRIANGLE_CHARACTER;
Rafficher_toute_la_chaine(x_pos,y_pos,Chaine_affichee,position - offset); Display_whole_string(x_pos,y_pos,display_string,position - offset);
UpdateRect(Fenetre_Pos_X+(x_pos*Menu_Facteur_X),Fenetre_Pos_Y+(y_pos*Menu_Facteur_Y), Update_rect(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y),
Taille_affichee*(Menu_Facteur_X<<3),(Menu_Facteur_Y<<3)); visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3));
} // Fin du "switch(Touche_lue)" } // End du "switch(input_key)"
Flush_update(); Flush_update();
} // Fin du "while" } // End du "while"
// Effacement de la chaîne // Effacement de la chaîne
Block(Fenetre_Pos_X+(x_pos*Menu_Facteur_X),Fenetre_Pos_Y+(y_pos*Menu_Facteur_Y), Block(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y),
Taille_affichee*(Menu_Facteur_X<<3),(Menu_Facteur_Y<<3),COULEUR_FOND); visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3),BACKGROUND_COLOR);
// On raffiche la chaine correctement // On raffiche la chaine correctement
if (Type_saisie==1) if (input_type==1)
{ {
if (Chaine[0]=='\0') if (str[0]=='\0')
{ {
strcpy(Chaine,"0"); strcpy(str,"0");
size=1; size=1;
} }
Print_dans_fenetre(x_pos+((Taille_maxi-size)<<3),y_pos,Chaine,COULEUR_TEXTE,COULEUR_FOND); Print_in_window(x_pos+((max_size-size)<<3),y_pos,str,TEXT_COLOR,BACKGROUND_COLOR);
} }
else else
{ {
Print_dans_fenetre_limite(x_pos,y_pos,Chaine,Taille_affichee,COULEUR_TEXTE,COULEUR_FOND); Print_in_window_limited(x_pos,y_pos,str,visible_size,TEXT_COLOR,BACKGROUND_COLOR);
} }
UpdateRect(Fenetre_Pos_X+(x_pos*Menu_Facteur_X),Fenetre_Pos_Y+(y_pos*Menu_Facteur_Y), Update_rect(Window_pos_X+(x_pos*Menu_factor_X),Window_pos_Y+(y_pos*Menu_factor_Y),
Taille_affichee*(Menu_Facteur_X<<3),(Menu_Facteur_Y<<3)); visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3));
return (Touche_lue==SDLK_RETURN); return (input_key==SDLK_RETURN);
} }

View File

@ -19,21 +19,21 @@
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
byte Readline(word x_pos,word y_pos,char * Chaine,byte Taille_affichee,byte Type_saisie); byte Readline(word x_pos,word y_pos,char * str,byte visible_size,byte input_type);
// Paramètres: // Paramètres:
// x_pos, y_pos : Coordonnées de la saisie dans la fenêtre // x_pos, y_pos : Coordonnées de la saisie dans la fenêtre
// Chaine : Chaîne recevant la saisie (et contenant éventuellement une valeur initiale) // str : Chaîne recevant la saisie (et contenant éventuellement une valeur initiale)
// Taille_affichee : Nombre de caractères logeant dans la zone de saisie // visible_size : Nombre de caractères logeant dans la zone de saisie
// Type_saisie : 0=Chaîne, 1=Nombre, 2=Nom de fichier (255 caractères réels) // input_type : 0=Chaîne, 1=Nombre, 2=Nom de fichier (255 caractères réels)
// Sortie: // Sortie:
// 0: Sortie par annulation (Esc.) / 1: sortie par acceptation (Return) // 0: Sortie par annulation (Esc.) / 1: sortie par acceptation (Return)
byte Readline_ex(word x_pos,word y_pos,char * Chaine,byte Taille_affichee,byte Taille_maxi, byte Type_saisie); byte Readline_ex(word x_pos,word y_pos,char * str,byte visible_size,byte max_size, byte input_type);
// Paramètres: // Paramètres:
// x_pos, y_pos : Coordonnées de la saisie dans la fenêtre // x_pos, y_pos : Coordonnées de la saisie dans la fenêtre
// Chaine : Chaîne recevant la saisie (et contenant éventuellement une valeur initiale) // str : Chaîne recevant la saisie (et contenant éventuellement une valeur initiale)
// Taille_affichee : Nombre de caractères logeant dans la zone de saisie // visible_size : Nombre de caractères logeant dans la zone de saisie
// Taille_maxi : Nombre de caractères logeant dans la zone de saisie // max_size : Nombre de caractères logeant dans la zone de saisie
// Type_saisie : 0=Chaîne, 1=Nombre, 2=Nom de fichier (255 caractères réels) // input_type : 0=Chaîne, 1=Nombre, 2=Nom de fichier (255 caractères réels)
// Sortie: // Sortie:
// 0: Sortie par annulation (Esc.) / 1: sortie par acceptation (Return) // 0: Sortie par annulation (Esc.) / 1: sortie par acceptation (Return)

554
saveini.c
View File

@ -30,70 +30,70 @@
#include "erreurs.h" #include "erreurs.h"
#include "divers.h" #include "divers.h"
int Sauver_INI_Reach_group(FILE * Old_file,FILE * New_file,char * Buffer,char * Group) int Save_INI_reach_group(FILE * old_file,FILE * new_file,char * buffer,char * group)
{ {
int Arret; int stop_seek;
char * Group_upper; char * group_upper;
char * Buffer_upper; char * upper_buffer;
// On alloue les zones de mémoire: // On alloue les zones de mémoire:
Group_upper =(char *)malloc(1024); group_upper =(char *)malloc(1024);
Buffer_upper=(char *)malloc(1024); upper_buffer=(char *)malloc(1024);
// On commence par se faire une version majuscule du groupe à rechercher: // On commence par se faire une version majuscule du groupe à rechercher:
strcpy(Group_upper,Group); strcpy(group_upper,group);
Charger_INI_Clear_string(Group_upper); Load_INI_clear_string(group_upper);
Arret=0; stop_seek=0;
do do
{ {
// On lit une ligne dans le fichier: // On lit une ligne dans le fichier:
if (fgets(Buffer,1024,Old_file)==0) if (fgets(buffer,1024,old_file)==0)
{ {
free(Buffer_upper); free(upper_buffer);
free(Group_upper); free(group_upper);
return ERREUR_INI_CORROMPU; return ERROR_INI_CORRUPTED;
} }
// On s'en fait une version en majuscule: // On s'en fait une version en majuscule:
strcpy(Buffer_upper,Buffer); strcpy(upper_buffer,buffer);
Charger_INI_Clear_string(Buffer_upper); Load_INI_clear_string(upper_buffer);
// On compare la chaîne avec le groupe recherché: // On compare la chaîne avec le groupe recherché:
Arret=Charger_INI_Seek_pattern(Buffer_upper,Group_upper); stop_seek=Load_INI_seek_pattern(upper_buffer,group_upper);
if (fprintf(New_file,"%s",Buffer)<0) if (fprintf(new_file,"%s",buffer)<0)
{ {
free(Buffer_upper); free(upper_buffer);
free(Group_upper); free(group_upper);
return ERREUR_SAUVEGARDE_INI; return ERROR_SAVING_INI;
} }
} }
while (Arret==0); while (stop_seek==0);
free(Buffer_upper); free(upper_buffer);
free(Group_upper); free(group_upper);
return 0; return 0;
} }
int Sauver_INI_char_in_value_alphabet(char Char) int Save_INI_char_in_value_alphabet(char c)
{ {
if ( if (
( // Chiffre ( // Chiffre
(Char>='0') && (c>='0') &&
(Char<='9') (c<='9')
) || ) ||
( // Lettre majuscule ( // Lettre majuscule
(Char>='A') && (c>='A') &&
(Char<='Z') (c<='Z')
) || ) ||
( // Lettre minuscule ( // Lettre minuscule
(Char>='a') && (c>='a') &&
(Char<='z') (c<='z')
) || ) ||
(Char == '$') // Symbole d'hexadécimal (c == '$') // Symbole d'hexadécimal
) )
return 1; return 1;
else else
@ -102,541 +102,541 @@ int Sauver_INI_char_in_value_alphabet(char Char)
void Sauver_INI_Set_value(char * dest,char * Source,int Nb_values_to_set,int * Values,int Litteral) void Save_INI_set_value(char * dest,char * source,int nb_values_to_set,int * values,int litteral)
{ {
int Indice_destination; int dest_index;
int Indice_source; int source_index;
int Indice_valeur; int value_index;
// On commence par recopier tout jusqu'au symbole '=': // On commence par recopier tout jusqu'au symbole '=':
for (Indice_source=0;Source[Indice_source]!='=';Indice_source++) for (source_index=0;source[source_index]!='=';source_index++)
dest[Indice_source]=Source[Indice_source]; dest[source_index]=source[source_index];
// Puis on recopie le symbole '=': // Puis on recopie le symbole '=':
dest[Indice_source]=Source[Indice_source]; dest[source_index]=source[source_index];
Indice_source++; source_index++;
// Puis on recopie tous les espaces qui suivent: // Puis on recopie tous les espaces qui suivent:
for (;Source[Indice_source]==' ';Indice_source++) for (;source[source_index]==' ';source_index++)
dest[Indice_source]=Source[Indice_source]; dest[source_index]=source[source_index];
// Pour l'instant, la source et la destination en sont au même point: // Pour l'instant, la source et la destination en sont au même point:
Indice_destination=Indice_source; dest_index=source_index;
// Puis pour chaque valeur à recopier: // Puis pour chaque valeur à recopier:
for (Indice_valeur=0;Indice_valeur<Nb_values_to_set;Indice_valeur++) for (value_index=0;value_index<nb_values_to_set;value_index++)
{ {
// Dans la destination, on écrit la valeur: // Dans la destination, on écrit la valeur:
if (Litteral) if (litteral)
{ {
// La valeur doit être écrite sous la forme Yes/No // La valeur doit être écrite sous la forme Yes/No
if (Values[Indice_valeur]) if (values[value_index])
{ {
// La valeur <=> Yes // La valeur <=> Yes
memcpy(dest+Indice_destination,"yes",3); memcpy(dest+dest_index,"yes",3);
Indice_destination+=3; dest_index+=3;
} }
else else
{ {
// La valeur <=> No // La valeur <=> No
memcpy(dest+Indice_destination,"no",2); memcpy(dest+dest_index,"no",2);
Indice_destination+=2; dest_index+=2;
} }
} }
else else
{ {
// La valeur doit être écrite sous forme numérique // La valeur doit être écrite sous forme numérique
if (Source[Indice_source]=='$') if (source[source_index]=='$')
{ {
// On va écrire la valeur sous forme hexadécimale: // On va écrire la valeur sous forme hexadécimale:
// On commence par inscrire le symbole '$': // On commence par inscrire le symbole '$':
dest[Indice_destination]='$'; dest[dest_index]='$';
// Puis on y concatène la valeur: // Puis on y concatène la valeur:
sprintf(dest+Indice_destination+1,"%x",Values[Indice_valeur]); sprintf(dest+dest_index+1,"%x",values[value_index]);
Indice_destination+=strlen(dest+Indice_destination); dest_index+=strlen(dest+dest_index);
} }
else else
{ {
// On va écrire la valeur sous forme décimale: // On va écrire la valeur sous forme décimale:
sprintf(dest+Indice_destination,"%d",Values[Indice_valeur]); sprintf(dest+dest_index,"%d",values[value_index]);
Indice_destination+=strlen(dest+Indice_destination); dest_index+=strlen(dest+dest_index);
} }
} }
// Dans la source, on saute la valeur: // Dans la source, on saute la valeur:
for (;Sauver_INI_char_in_value_alphabet(Source[Indice_source]) && (Source[Indice_source]!='\0');Indice_source++); for (;Save_INI_char_in_value_alphabet(source[source_index]) && (source[source_index]!='\0');source_index++);
if (Indice_valeur!=(Nb_values_to_set-1)) if (value_index!=(nb_values_to_set-1))
{ {
// Il reste d'autres valeurs à écrire // Il reste d'autres valeurs à écrire
// On recopie tous les caractères de la source jusqu'au suivant qui // On recopie tous les caractères de la source jusqu'au suivant qui
// désigne une valeur: // désigne une valeur:
for (;(!Sauver_INI_char_in_value_alphabet(Source[Indice_source])) && (Source[Indice_source]!='\0');Indice_source++,Indice_destination++) for (;(!Save_INI_char_in_value_alphabet(source[source_index])) && (source[source_index]!='\0');source_index++,dest_index++)
dest[Indice_destination]=Source[Indice_source]; dest[dest_index]=source[source_index];
} }
else else
{ {
// C'est la dernière valeur à initialiser // C'est la dernière valeur à initialiser
// On recopie toute la fin de la ligne: // On recopie toute la fin de la ligne:
for (;Source[Indice_source]!='\0';Indice_source++,Indice_destination++) for (;source[source_index]!='\0';source_index++,dest_index++)
dest[Indice_destination]=Source[Indice_source]; dest[dest_index]=source[source_index];
// Et on n'oublie pas d'y mettre l''\0': // Et on n'oublie pas d'y mettre l''\0':
dest[Indice_destination]='\0'; dest[dest_index]='\0';
} }
} }
} }
void Sauver_INI_Set_string(char * dest,char * Source,char * Value) void Save_INI_set_string(char * dest,char * source,char * value)
{ {
int Indice_destination; int dest_index;
int Indice_source; int source_index;
// On commence par recopier tout jusqu'au symbole '=': // On commence par recopier tout jusqu'au symbole '=':
for (Indice_source=0;Source[Indice_source]!='=';Indice_source++) for (source_index=0;source[source_index]!='=';source_index++)
dest[Indice_source]=Source[Indice_source]; dest[source_index]=source[source_index];
// Puis on recopie le symbole '=': // Puis on recopie le symbole '=':
dest[Indice_source]=Source[Indice_source]; dest[source_index]=source[source_index];
Indice_source++; source_index++;
// Puis on recopie tous les espaces qui suivent: // Puis on recopie tous les espaces qui suivent:
for (;Source[Indice_source]==' ';Indice_source++) for (;source[source_index]==' ';source_index++)
dest[Indice_source]=Source[Indice_source]; dest[source_index]=source[source_index];
// Pour l'instant, la source et la destination en sont au même point: // Pour l'instant, la source et la destination en sont au même point:
Indice_destination=Indice_source; dest_index=source_index;
// Dans la destination, on écrit la valeur: // Dans la destination, on écrit la valeur:
strcpy(dest+Indice_destination,Value); strcpy(dest+dest_index,value);
Indice_destination+=strlen(Value); dest_index+=strlen(value);
// Dans la source, on saute la valeur: // Dans la source, on saute la valeur:
for (;Sauver_INI_char_in_value_alphabet(Source[Indice_source]) && (Source[Indice_source]!='\0');Indice_source++); for (;Save_INI_char_in_value_alphabet(source[source_index]) && (source[source_index]!='\0');source_index++);
// On recopie toute la fin de la ligne: // On recopie toute la fin de la ligne:
for (;Source[Indice_source]!='\0';Indice_source++,Indice_destination++) for (;source[source_index]!='\0';source_index++,dest_index++)
dest[Indice_destination]=Source[Indice_source]; dest[dest_index]=source[source_index];
// Et on n'oublie pas d'y mettre l''\0': // Et on n'oublie pas d'y mettre l''\0':
dest[Indice_destination]='\0'; dest[dest_index]='\0';
} }
int Sauver_INI_Set_strings(FILE * Old_file,FILE * New_file,char * Buffer,char * Option,char * Value) int Save_INI_set_strings(FILE * old_file,FILE * new_file,char * buffer,char * option_name,char * value)
{ {
int Arret; int stop_seek;
char * Option_upper; char * option_upper;
char * Buffer_upper; char * upper_buffer;
char * Buffer_resultat; char * result_buffer;
//int Indice_buffer; //int buffer_index;
// On alloue les zones de mémoire: // On alloue les zones de mémoire:
Option_upper=(char *)malloc(1024); option_upper=(char *)malloc(1024);
Buffer_upper=(char *)malloc(1024); upper_buffer=(char *)malloc(1024);
Buffer_resultat=(char *)malloc(1024); result_buffer=(char *)malloc(1024);
// On convertit un eventuel argument NULL en chaine vide. // On convertit un eventuel argument NULL en chaine vide.
if (Value == NULL) if (value == NULL)
Value=""; value="";
// On commence par se faire une version majuscule de l'option à rechercher: // On commence par se faire une version majuscule de l'option à rechercher:
strcpy(Option_upper,Option); strcpy(option_upper,option_name);
Charger_INI_Clear_string(Option_upper); Load_INI_clear_string(option_upper);
Arret=0; stop_seek=0;
do do
{ {
// On lit une ligne dans le fichier: // On lit une ligne dans le fichier:
if (fgets(Buffer,1024,Old_file)==0) if (fgets(buffer,1024,old_file)==0)
{ {
free(Buffer_resultat); free(result_buffer);
free(Buffer_upper); free(upper_buffer);
free(Option_upper); free(option_upper);
return ERREUR_INI_CORROMPU; return ERROR_INI_CORRUPTED;
} }
// On s'en fait une version en majuscule: // On s'en fait une version en majuscule:
strcpy(Buffer_upper,Buffer); strcpy(upper_buffer,buffer);
Charger_INI_Clear_string(Buffer_upper); Load_INI_clear_string(upper_buffer);
// On compare la chaîne avec l'option recherchée: // On compare la chaîne avec l'option recherchée:
Arret=Charger_INI_Seek_pattern(Buffer_upper,Option_upper); stop_seek=Load_INI_seek_pattern(upper_buffer,option_upper);
if (Arret) if (stop_seek)
{ {
// On l'a trouvée: // On l'a trouvée:
Sauver_INI_Set_string(Buffer_resultat,Buffer,Value); Save_INI_set_string(result_buffer,buffer,value);
if (fprintf(New_file,"%s",Buffer_resultat)<0) if (fprintf(new_file,"%s",result_buffer)<0)
{ {
free(Buffer_resultat); free(result_buffer);
free(Buffer_upper); free(upper_buffer);
free(Option_upper); free(option_upper);
return ERREUR_SAUVEGARDE_INI; return ERROR_SAVING_INI;
} }
} }
else else
{ {
// On l'a pas trouvée: // On l'a pas trouvée:
if (fprintf(New_file,"%s",Buffer)<0) if (fprintf(new_file,"%s",buffer)<0)
{ {
free(Buffer_resultat); free(result_buffer);
free(Buffer_upper); free(upper_buffer);
free(Option_upper); free(option_upper);
return ERREUR_SAUVEGARDE_INI; return ERROR_SAVING_INI;
} }
} }
} }
while (Arret==0); while (stop_seek==0);
free(Buffer_resultat); free(result_buffer);
free(Buffer_upper); free(upper_buffer);
free(Option_upper); free(option_upper);
return 0; return 0;
} }
int Sauver_INI_Set_values(FILE * Old_file,FILE * New_file,char * Buffer,char * Option,int Nb_values_to_set,int * Values,int Litteral) int Save_INI_set_values(FILE * old_file,FILE * new_file,char * buffer,char * option_name,int nb_values_to_set,int * values,int litteral)
{ {
int Arret; int stop_seek;
char * Option_upper; char * option_upper;
char * Buffer_upper; char * upper_buffer;
char * Buffer_resultat; char * result_buffer;
//int Indice_buffer; //int buffer_index;
// On alloue les zones de mémoire: // On alloue les zones de mémoire:
Option_upper=(char *)malloc(1024); option_upper=(char *)malloc(1024);
Buffer_upper=(char *)malloc(1024); upper_buffer=(char *)malloc(1024);
Buffer_resultat=(char *)malloc(1024); result_buffer=(char *)malloc(1024);
// On commence par se faire une version majuscule de l'option à rechercher: // On commence par se faire une version majuscule de l'option à rechercher:
strcpy(Option_upper,Option); strcpy(option_upper,option_name);
Charger_INI_Clear_string(Option_upper); Load_INI_clear_string(option_upper);
Arret=0; stop_seek=0;
do do
{ {
// On lit une ligne dans le fichier: // On lit une ligne dans le fichier:
if (fgets(Buffer,1024,Old_file)==0) if (fgets(buffer,1024,old_file)==0)
{ {
free(Buffer_resultat); free(result_buffer);
free(Buffer_upper); free(upper_buffer);
free(Option_upper); free(option_upper);
return ERREUR_INI_CORROMPU; return ERROR_INI_CORRUPTED;
} }
// On s'en fait une version en majuscule: // On s'en fait une version en majuscule:
strcpy(Buffer_upper,Buffer); strcpy(upper_buffer,buffer);
Charger_INI_Clear_string(Buffer_upper); Load_INI_clear_string(upper_buffer);
// On compare la chaîne avec l'option recherchée: // On compare la chaîne avec l'option recherchée:
Arret=Charger_INI_Seek_pattern(Buffer_upper,Option_upper); stop_seek=Load_INI_seek_pattern(upper_buffer,option_upper);
if (Arret) if (stop_seek)
{ {
// On l'a trouvée: // On l'a trouvée:
Sauver_INI_Set_value(Buffer_resultat,Buffer,Nb_values_to_set,Values,Litteral); Save_INI_set_value(result_buffer,buffer,nb_values_to_set,values,litteral);
if (fprintf(New_file,"%s",Buffer_resultat)<0) if (fprintf(new_file,"%s",result_buffer)<0)
{ {
free(Buffer_resultat); free(result_buffer);
free(Buffer_upper); free(upper_buffer);
free(Option_upper); free(option_upper);
return ERREUR_SAUVEGARDE_INI; return ERROR_SAVING_INI;
} }
} }
else else
{ {
// On l'a pas trouvée: // On l'a pas trouvée:
if (fprintf(New_file,"%s",Buffer)<0) if (fprintf(new_file,"%s",buffer)<0)
{ {
free(Buffer_resultat); free(result_buffer);
free(Buffer_upper); free(upper_buffer);
free(Option_upper); free(option_upper);
return ERREUR_SAUVEGARDE_INI; return ERROR_SAVING_INI;
} }
} }
} }
while (Arret==0); while (stop_seek==0);
free(Buffer_resultat); free(result_buffer);
free(Buffer_upper); free(upper_buffer);
free(Option_upper); free(option_upper);
return 0; return 0;
} }
void Sauver_INI_Flush(FILE * Old_file,FILE * New_file,char * Buffer) void Save_INI_flush(FILE * old_file,FILE * new_file,char * buffer)
{ {
while (fgets(Buffer,1024,Old_file)!=0) while (fgets(buffer,1024,old_file)!=0)
fprintf(New_file,"%s",Buffer); fprintf(new_file,"%s",buffer);
} }
int Sauver_INI(T_Config * Conf) int Save_INI(T_Config * conf)
{ {
FILE * Ancien_fichier; FILE * Ancien_fichier;
FILE * Nouveau_fichier; FILE * Nouveau_fichier;
char * Buffer; char * buffer;
int values[3]; int values[3];
char Nom_du_fichier[TAILLE_CHEMIN_FICHIER]; char filename[MAX_PATH_CHARACTERS];
char Nom_du_fichier_temporaire[TAILLE_CHEMIN_FICHIER]; char temp_filename[MAX_PATH_CHARACTERS];
int return_code; int return_code;
char Nom_du_fichier_DAT[TAILLE_CHEMIN_FICHIER]; char ref_ini_file[MAX_PATH_CHARACTERS];
int Ini_existe; int ini_file_exists;
int Indice; int index;
// On alloue les zones de mémoire: // On alloue les zones de mémoire:
Buffer=(char *)malloc(1024); buffer=(char *)malloc(1024);
// On calcule les noms des fichiers qu'on manipule: // On calcule les noms des fichiers qu'on manipule:
strcpy(Nom_du_fichier,Repertoire_de_configuration); strcpy(filename,Config_directory);
strcat(Nom_du_fichier,"gfx2.ini"); strcat(filename,"gfx2.ini");
// On vérifie si le fichier INI existe // On vérifie si le fichier INI existe
if ((Ini_existe = Fichier_existe(Nom_du_fichier))) if ((ini_file_exists = File_exists(filename)))
{ {
strcpy(Nom_du_fichier_temporaire,Repertoire_de_configuration); strcpy(temp_filename,Config_directory);
strcat(Nom_du_fichier_temporaire,"gfx2.$$$"); strcat(temp_filename,"gfx2.$$$");
// On renome l'ancienne version du fichier INI vers un fichier temporaire: // On renome l'ancienne version du fichier INI vers un fichier temporaire:
if (rename(Nom_du_fichier,Nom_du_fichier_temporaire)!=0) if (rename(filename,temp_filename)!=0)
{ {
goto Erreur_ERREUR_SAUVEGARDE_INI; goto Erreur_ERREUR_SAUVEGARDE_INI;
} }
} }
// On récupère un fichier INI "propre" à partir de gfx2def.ini // On récupère un fichier INI "propre" à partir de gfx2def.ini
strcpy(Nom_du_fichier_DAT,Repertoire_des_donnees); strcpy(ref_ini_file,Repertoire_des_donnees);
strcat(Nom_du_fichier_DAT,"gfx2def.ini"); strcat(ref_ini_file,"gfx2def.ini");
Ancien_fichier=fopen(Nom_du_fichier_DAT,"rb"); Ancien_fichier=fopen(ref_ini_file,"rb");
if (Ancien_fichier==0) if (Ancien_fichier==0)
{ {
fclose(Ancien_fichier); fclose(Ancien_fichier);
return ERREUR_INI_ABSENT; return ERROR_INI_MISSING;
} }
Nouveau_fichier=fopen(Nom_du_fichier,"wb"); Nouveau_fichier=fopen(filename,"wb");
if (Nouveau_fichier==0) if (Nouveau_fichier==0)
{ {
free(Buffer); free(buffer);
return ERREUR_SAUVEGARDE_INI; return ERROR_SAVING_INI;
} }
if ((return_code=Sauver_INI_Reach_group(Ancien_fichier,Nouveau_fichier,Buffer,"[MOUSE]"))) if ((return_code=Save_INI_reach_group(Ancien_fichier,Nouveau_fichier,buffer,"[MOUSE]")))
goto Erreur_Retour; goto Erreur_Retour;
values[0]=Conf->Indice_Sensibilite_souris_X; values[0]=conf->Mouse_sensitivity_index_x;
if ((return_code=Sauver_INI_Set_values (Ancien_fichier,Nouveau_fichier,Buffer,"X_sensitivity",1,values,0))) if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"X_sensitivity",1,values,0)))
goto Erreur_Retour; goto Erreur_Retour;
values[0]=Conf->Indice_Sensibilite_souris_Y; values[0]=conf->Mouse_sensitivity_index_y;
if ((return_code=Sauver_INI_Set_values (Ancien_fichier,Nouveau_fichier,Buffer,"Y_sensitivity",1,values,0))) if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Y_sensitivity",1,values,0)))
goto Erreur_Retour; goto Erreur_Retour;
values[0]=Conf->Mouse_Facteur_de_correction_X; values[0]=conf->Mouse_fix_factor_X;
if ((return_code=Sauver_INI_Set_values (Ancien_fichier,Nouveau_fichier,Buffer,"X_correction_factor",1,values,0))) if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"X_correction_factor",1,values,0)))
goto Erreur_Retour; goto Erreur_Retour;
values[0]=Conf->Mouse_Facteur_de_correction_Y; values[0]=conf->Mouse_fix_factor_Y;
if ((return_code=Sauver_INI_Set_values (Ancien_fichier,Nouveau_fichier,Buffer,"Y_correction_factor",1,values,0))) if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Y_correction_factor",1,values,0)))
goto Erreur_Retour; goto Erreur_Retour;
values[0]=(Conf->Curseur)+1; values[0]=(conf->Cursor)+1;
if ((return_code=Sauver_INI_Set_values (Ancien_fichier,Nouveau_fichier,Buffer,"Cursor_aspect",1,values,0))) if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Cursor_aspect",1,values,0)))
goto Erreur_Retour; goto Erreur_Retour;
if ((return_code=Sauver_INI_Reach_group(Ancien_fichier,Nouveau_fichier,Buffer,"[MENU]"))) if ((return_code=Save_INI_reach_group(Ancien_fichier,Nouveau_fichier,buffer,"[MENU]")))
goto Erreur_Retour; goto Erreur_Retour;
values[0]=Conf->Coul_menu_pref[2].R>>2; values[0]=conf->Fav_menu_colors[2].R>>2;
values[1]=Conf->Coul_menu_pref[2].G>>2; values[1]=conf->Fav_menu_colors[2].G>>2;
values[2]=Conf->Coul_menu_pref[2].B>>2; values[2]=conf->Fav_menu_colors[2].B>>2;
if ((return_code=Sauver_INI_Set_values (Ancien_fichier,Nouveau_fichier,Buffer,"Light_color",3,values,0))) if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Light_color",3,values,0)))
goto Erreur_Retour; goto Erreur_Retour;
values[0]=Conf->Coul_menu_pref[1].R>>2; values[0]=conf->Fav_menu_colors[1].R>>2;
values[1]=Conf->Coul_menu_pref[1].G>>2; values[1]=conf->Fav_menu_colors[1].G>>2;
values[2]=Conf->Coul_menu_pref[1].B>>2; values[2]=conf->Fav_menu_colors[1].B>>2;
if ((return_code=Sauver_INI_Set_values (Ancien_fichier,Nouveau_fichier,Buffer,"Dark_color",3,values,0))) if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Dark_color",3,values,0)))
goto Erreur_Retour; goto Erreur_Retour;
values[0]=Conf->Ratio; values[0]=conf->Ratio;
if ((return_code=Sauver_INI_Set_values (Ancien_fichier,Nouveau_fichier,Buffer,"Menu_ratio",1,values,0))) if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Menu_ratio",1,values,0)))
goto Erreur_Retour; goto Erreur_Retour;
values[0]=(Conf->Fonte)+1; values[0]=(conf->Font)+1;
if ((return_code=Sauver_INI_Set_values (Ancien_fichier,Nouveau_fichier,Buffer,"Font",1,values,0))) if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Font",1,values,0)))
goto Erreur_Retour; goto Erreur_Retour;
if ((return_code=Sauver_INI_Reach_group(Ancien_fichier,Nouveau_fichier,Buffer,"[FILE_SELECTOR]"))) if ((return_code=Save_INI_reach_group(Ancien_fichier,Nouveau_fichier,buffer,"[FILE_SELECTOR]")))
goto Erreur_Retour; goto Erreur_Retour;
values[0]=Conf->Lire_les_fichiers_caches?1:0; values[0]=conf->Show_hidden_files?1:0;
if ((return_code=Sauver_INI_Set_values (Ancien_fichier,Nouveau_fichier,Buffer,"Show_hidden_files",1,values,1))) if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Show_hidden_files",1,values,1)))
goto Erreur_Retour; goto Erreur_Retour;
values[0]=Conf->Lire_les_repertoires_caches?1:0; values[0]=conf->Show_hidden_directories?1:0;
if ((return_code=Sauver_INI_Set_values (Ancien_fichier,Nouveau_fichier,Buffer,"Show_hidden_directories",1,values,1))) if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Show_hidden_directories",1,values,1)))
goto Erreur_Retour; goto Erreur_Retour;
/* values[0]=Conf->Lire_les_repertoires_systemes?1:0; /* values[0]=conf->Show_system_directories?1:0;
if ((return_code=Sauver_INI_Set_values (Ancien_fichier,Nouveau_fichier,Buffer,"Show_system_directories",1,values,1))) if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Show_system_directories",1,values,1)))
goto Erreur_Retour; goto Erreur_Retour;
*/ */
values[0]=Conf->Chrono_delay; values[0]=conf->Timer_delay;
if ((return_code=Sauver_INI_Set_values (Ancien_fichier,Nouveau_fichier,Buffer,"Preview_delay",1,values,0))) if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Preview_delay",1,values,0)))
goto Erreur_Retour; goto Erreur_Retour;
values[0]=Conf->Maximize_preview; values[0]=conf->Maximize_preview;
if ((return_code=Sauver_INI_Set_values (Ancien_fichier,Nouveau_fichier,Buffer,"Maximize_preview",1,values,1))) if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Maximize_preview",1,values,1)))
goto Erreur_Retour; goto Erreur_Retour;
values[0]=Conf->Find_file_fast; values[0]=conf->Find_file_fast;
if ((return_code=Sauver_INI_Set_values (Ancien_fichier,Nouveau_fichier,Buffer,"Find_file_fast",1,values,0))) if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Find_file_fast",1,values,0)))
goto Erreur_Retour; goto Erreur_Retour;
if ((return_code=Sauver_INI_Reach_group(Ancien_fichier,Nouveau_fichier,Buffer,"[LOADING]"))) if ((return_code=Save_INI_reach_group(Ancien_fichier,Nouveau_fichier,buffer,"[LOADING]")))
goto Erreur_Retour; goto Erreur_Retour;
values[0]=Conf->Auto_set_res; values[0]=conf->Auto_set_res;
if ((return_code=Sauver_INI_Set_values (Ancien_fichier,Nouveau_fichier,Buffer,"Auto_set_resolution",1,values,1))) if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Auto_set_resolution",1,values,1)))
goto Erreur_Retour; goto Erreur_Retour;
values[0]=Conf->Set_resolution_according_to; values[0]=conf->Set_resolution_according_to;
if ((return_code=Sauver_INI_Set_values (Ancien_fichier,Nouveau_fichier,Buffer,"Set_resolution_according_to",1,values,0))) if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Set_resolution_according_to",1,values,0)))
goto Erreur_Retour; goto Erreur_Retour;
values[0]=Conf->Clear_palette; values[0]=conf->Clear_palette;
if ((return_code=Sauver_INI_Set_values (Ancien_fichier,Nouveau_fichier,Buffer,"Clear_palette",1,values,1))) if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Clear_palette",1,values,1)))
goto Erreur_Retour; goto Erreur_Retour;
if ((return_code=Sauver_INI_Reach_group(Ancien_fichier,Nouveau_fichier,Buffer,"[MISCELLANEOUS]"))) if ((return_code=Save_INI_reach_group(Ancien_fichier,Nouveau_fichier,buffer,"[MISCELLANEOUS]")))
goto Erreur_Retour; goto Erreur_Retour;
values[0]=Conf->Afficher_limites_image; values[0]=conf->Display_image_limits;
if ((return_code=Sauver_INI_Set_values (Ancien_fichier,Nouveau_fichier,Buffer,"Draw_limits",1,values,1))) if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Draw_limits",1,values,1)))
goto Erreur_Retour; goto Erreur_Retour;
values[0]=Conf->Adjust_brush_pick; values[0]=conf->Adjust_brush_pick;
if ((return_code=Sauver_INI_Set_values (Ancien_fichier,Nouveau_fichier,Buffer,"Adjust_brush_pick",1,values,1))) if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Adjust_brush_pick",1,values,1)))
goto Erreur_Retour; goto Erreur_Retour;
values[0]=2-Conf->Coords_rel; values[0]=2-conf->Coords_rel;
if ((return_code=Sauver_INI_Set_values (Ancien_fichier,Nouveau_fichier,Buffer,"Coordinates",1,values,0))) if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Coordinates",1,values,0)))
goto Erreur_Retour; goto Erreur_Retour;
values[0]=Conf->Backup; values[0]=conf->Backup;
if ((return_code=Sauver_INI_Set_values (Ancien_fichier,Nouveau_fichier,Buffer,"Backup",1,values,1))) if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Backup",1,values,1)))
goto Erreur_Retour; goto Erreur_Retour;
values[0]=Conf->Nb_pages_Undo; values[0]=conf->Max_undo_pages;
if ((return_code=Sauver_INI_Set_values (Ancien_fichier,Nouveau_fichier,Buffer,"Undo_pages",1,values,0))) if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Undo_pages",1,values,0)))
goto Erreur_Retour; goto Erreur_Retour;
values[0]=Conf->Valeur_tempo_jauge_gauche; values[0]=conf->Delay_left_click_on_slider;
if ((return_code=Sauver_INI_Set_values (Ancien_fichier,Nouveau_fichier,Buffer,"Gauges_scrolling_speed_Left",1,values,0))) if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Gauges_scrolling_speed_Left",1,values,0)))
goto Erreur_Retour; goto Erreur_Retour;
values[0]=Conf->Valeur_tempo_jauge_droite; values[0]=conf->Delay_right_click_on_slider;
if ((return_code=Sauver_INI_Set_values (Ancien_fichier,Nouveau_fichier,Buffer,"Gauges_scrolling_speed_Right",1,values,0))) if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Gauges_scrolling_speed_Right",1,values,0)))
goto Erreur_Retour; goto Erreur_Retour;
values[0]=Conf->Auto_save; values[0]=conf->Auto_save;
if ((return_code=Sauver_INI_Set_values (Ancien_fichier,Nouveau_fichier,Buffer,"Auto_save",1,values,1))) if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Auto_save",1,values,1)))
goto Erreur_Retour; goto Erreur_Retour;
values[0]=Conf->Nb_max_de_vertex_par_polygon; values[0]=conf->Nb_max_vertices_per_polygon;
if ((return_code=Sauver_INI_Set_values (Ancien_fichier,Nouveau_fichier,Buffer,"Vertices_per_polygon",1,values,0))) if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Vertices_per_polygon",1,values,0)))
goto Erreur_Retour; goto Erreur_Retour;
values[0]=Conf->Fast_zoom; values[0]=conf->Fast_zoom;
if ((return_code=Sauver_INI_Set_values (Ancien_fichier,Nouveau_fichier,Buffer,"Fast_zoom",1,values,1))) if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Fast_zoom",1,values,1)))
goto Erreur_Retour; goto Erreur_Retour;
values[0]=Conf->Couleurs_separees; values[0]=conf->Couleurs_separees;
if ((return_code=Sauver_INI_Set_values (Ancien_fichier,Nouveau_fichier,Buffer,"Separate_colors",1,values,1))) if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Separate_colors",1,values,1)))
goto Erreur_Retour; goto Erreur_Retour;
values[0]=Conf->FX_Feedback; values[0]=conf->FX_Feedback;
if ((return_code=Sauver_INI_Set_values (Ancien_fichier,Nouveau_fichier,Buffer,"FX_feedback",1,values,1))) if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"FX_feedback",1,values,1)))
goto Erreur_Retour; goto Erreur_Retour;
values[0]=Conf->Safety_colors; values[0]=conf->Safety_colors;
if ((return_code=Sauver_INI_Set_values (Ancien_fichier,Nouveau_fichier,Buffer,"Safety_colors",1,values,1))) if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Safety_colors",1,values,1)))
goto Erreur_Retour; goto Erreur_Retour;
values[0]=Conf->Opening_message; values[0]=conf->Opening_message;
if ((return_code=Sauver_INI_Set_values (Ancien_fichier,Nouveau_fichier,Buffer,"Opening_message",1,values,1))) if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Opening_message",1,values,1)))
goto Erreur_Retour; goto Erreur_Retour;
values[0]=Conf->Clear_with_stencil; values[0]=conf->Clear_with_stencil;
if ((return_code=Sauver_INI_Set_values (Ancien_fichier,Nouveau_fichier,Buffer,"Clear_with_stencil",1,values,1))) if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Clear_with_stencil",1,values,1)))
goto Erreur_Retour; goto Erreur_Retour;
values[0]=Conf->Auto_discontinuous; values[0]=conf->Auto_discontinuous;
if ((return_code=Sauver_INI_Set_values (Ancien_fichier,Nouveau_fichier,Buffer,"Auto_discontinuous",1,values,1))) if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Auto_discontinuous",1,values,1)))
goto Erreur_Retour; goto Erreur_Retour;
values[0]=Conf->Taille_ecran_dans_GIF; values[0]=conf->Screen_size_in_GIF;
if ((return_code=Sauver_INI_Set_values (Ancien_fichier,Nouveau_fichier,Buffer,"Save_screen_size_in_GIF",1,values,1))) if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Save_screen_size_in_GIF",1,values,1)))
goto Erreur_Retour; goto Erreur_Retour;
values[0]=Conf->Auto_nb_used; values[0]=conf->Auto_nb_used;
if ((return_code=Sauver_INI_Set_values (Ancien_fichier,Nouveau_fichier,Buffer,"Auto_nb_colors_used",1,values,1))) if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Auto_nb_colors_used",1,values,1)))
goto Erreur_Retour; goto Erreur_Retour;
if ((return_code=Sauver_INI_Set_strings (Ancien_fichier,Nouveau_fichier,Buffer,"Default_video_mode",Libelle_mode(Conf->Resolution_par_defaut)))) if ((return_code=Save_INI_set_strings (Ancien_fichier,Nouveau_fichier,buffer,"Default_video_mode",Mode_label(conf->Default_resolution))))
goto Erreur_Retour; goto Erreur_Retour;
values[0]=Mode_video[0].Width; values[0]=Video_mode[0].Width;
values[1]=Mode_video[0].Height; values[1]=Video_mode[0].Height;
if ((return_code=Sauver_INI_Set_values (Ancien_fichier,Nouveau_fichier,Buffer,"Default_window_size",2,values,0))) if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Default_window_size",2,values,0)))
goto Erreur_Retour; goto Erreur_Retour;
values[0]=(Conf->Mouse_Merge_movement); values[0]=(conf->Mouse_merge_movement);
if ((return_code=Sauver_INI_Set_values (Ancien_fichier,Nouveau_fichier,Buffer,"Merge_movement",1,values,0))) if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Merge_movement",1,values,0)))
goto Erreur_Retour; goto Erreur_Retour;
values[0]=(Conf->Palette_Cells_X); values[0]=(conf->Palette_cells_X);
if ((return_code=Sauver_INI_Set_values (Ancien_fichier,Nouveau_fichier,Buffer,"Palette_Cells_X",1,values,0))) if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Palette_cells_X",1,values,0)))
goto Erreur_Retour; goto Erreur_Retour;
values[0]=(Conf->Palette_Cells_Y); values[0]=(conf->Palette_cells_Y);
if ((return_code=Sauver_INI_Set_values (Ancien_fichier,Nouveau_fichier,Buffer,"Palette_Cells_Y",1,values,0))) if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Palette_cells_Y",1,values,0)))
goto Erreur_Retour; goto Erreur_Retour;
for (Indice=0;Indice<NB_BOOKMARKS;Indice++) for (index=0;index<NB_BOOKMARKS;index++)
{ {
if ((return_code=Sauver_INI_Set_strings (Ancien_fichier,Nouveau_fichier,Buffer,"Bookmark_label",Conf->Bookmark_label[Indice]))) if ((return_code=Save_INI_set_strings (Ancien_fichier,Nouveau_fichier,buffer,"Bookmark_label",conf->Bookmark_label[index])))
goto Erreur_Retour; goto Erreur_Retour;
if ((return_code=Sauver_INI_Set_strings (Ancien_fichier,Nouveau_fichier,Buffer,"Bookmark_directory",Conf->Bookmark_directory[Indice]))) if ((return_code=Save_INI_set_strings (Ancien_fichier,Nouveau_fichier,buffer,"Bookmark_directory",conf->Bookmark_directory[index])))
goto Erreur_Retour; goto Erreur_Retour;
} }
Sauver_INI_Flush(Ancien_fichier,Nouveau_fichier,Buffer); Save_INI_flush(Ancien_fichier,Nouveau_fichier,buffer);
fclose(Nouveau_fichier); fclose(Nouveau_fichier);
fclose(Ancien_fichier); fclose(Ancien_fichier);
// On efface le fichier temporaire <=> Ancienne version du .INI // On efface le fichier temporaire <=> Ancienne version du .INI
if (Ini_existe) if (ini_file_exists)
remove(Nom_du_fichier_temporaire); remove(temp_filename);
free(Buffer); free(buffer);
return 0; return 0;
// Gestion des erreurs: // Gestion des erreurs:
@ -645,11 +645,11 @@ int Sauver_INI(T_Config * Conf)
fclose(Nouveau_fichier); fclose(Nouveau_fichier);
fclose(Ancien_fichier); fclose(Ancien_fichier);
free(Buffer); free(buffer);
return return_code; return return_code;
Erreur_ERREUR_SAUVEGARDE_INI: Erreur_ERREUR_SAUVEGARDE_INI:
free(Buffer); free(buffer);
return ERREUR_SAUVEGARDE_INI; return ERROR_SAVING_INI;
} }

View File

@ -18,4 +18,4 @@
write to the Free Software Foundation, Inc., write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
int Sauver_INI(T_Config * Conf); int Save_INI(T_Config * conf);

View File

@ -29,64 +29,64 @@
#include "divers.h" #include "divers.h"
// Mise à jour minimaliste en nombre de pixels // Mise à jour minimaliste en nombre de pixels
#define METHODE_UPDATE_MULTI_RECTANGLE 1 #define UPDATE_METHOD_MULTI_RECTANGLE 1
// Mise à jour intermédiaire, par rectangle inclusif. // Mise à jour intermédiaire, par rectangle inclusif.
#define METHODE_UPDATE_PAR_CUMUL 2 #define UPDATE_METHOD_CUMULATED 2
// Mise à jour totale, pour les plate-formes qui imposent un Vsync à chaque mise à jour écran. // Mise à jour totale, pour les plate-formes qui imposent un Vsync à chaque mise à jour écran.
#define METHODE_UPDATE_PLEINE_PAGE 3 #define UPDATE_METHOD_FULL_PAGE 3
// METHODE_UPDATE peut être fixé depuis le makefile, sinon c'est ici: // UPDATE_METHOD peut être fixé depuis le makefile, sinon c'est ici:
#ifndef METHODE_UPDATE #ifndef UPDATE_METHOD
#if defined(__macosx__) || defined(__FreeBSD__) #if defined(__macosx__) || defined(__FreeBSD__)
#define METHODE_UPDATE METHODE_UPDATE_PLEINE_PAGE #define UPDATE_METHOD UPDATE_METHOD_FULL_PAGE
#else #else
#define METHODE_UPDATE METHODE_UPDATE_PAR_CUMUL #define UPDATE_METHOD UPDATE_METHOD_CUMULATED
#endif #endif
#endif #endif
void Set_Mode_SDL(int *width, int *height, int fullscreen) void Set_mode_SDL(int *width, int *height, int fullscreen)
/* On règle la résolution de l'écran */ /* On règle la résolution de l'écran */
{ {
Ecran_SDL=SDL_SetVideoMode(*width,*height,8,(fullscreen?SDL_FULLSCREEN:0)|SDL_RESIZABLE); Screen_SDL=SDL_SetVideoMode(*width,*height,8,(fullscreen?SDL_FULLSCREEN:0)|SDL_RESIZABLE);
if(Ecran_SDL != NULL) if(Screen_SDL != NULL)
{ {
// Vérification du mode obtenu (ce n'est pas toujours celui demandé) // Vérification du mode obtenu (ce n'est pas toujours celui demandé)
if (Ecran_SDL->w != *width || Ecran_SDL->h != *height) if (Screen_SDL->w != *width || Screen_SDL->h != *height)
{ {
DEBUG("Erreur mode video obtenu différent de celui demandé !!",0); DEBUG("Error mode video obtenu différent de celui demandé !!",0);
*width = Ecran_SDL->w; *width = Screen_SDL->w;
*height = Ecran_SDL->h; *height = Screen_SDL->h;
} }
Ecran=Ecran_SDL->pixels; Screen=Screen_SDL->pixels;
} }
else else
DEBUG("Erreur changement de mode video !!",0); DEBUG("Error changement de mode video !!",0);
SDL_ShowCursor(0); // Cache le curseur SDL, on le gère en soft SDL_ShowCursor(0); // Cache le curseur SDL, on le gère en soft
} }
#if (METHODE_UPDATE == METHODE_UPDATE_PAR_CUMUL) #if (UPDATE_METHOD == UPDATE_METHOD_CUMULATED)
short Min_X=0; short Min_X=0;
short Min_Y=0; short Min_Y=0;
short Max_X=10000; short Max_X=10000;
short Max_Y=10000; short Max_Y=10000;
#endif #endif
#if (METHODE_UPDATE == METHODE_UPDATE_PLEINE_PAGE) #if (UPDATE_METHOD == UPDATE_METHOD_FULL_PAGE)
int Update_necessaire=0; int update_is_required=0;
#endif #endif
void Flush_update(void) void Flush_update(void)
{ {
#if (METHODE_UPDATE == METHODE_UPDATE_PLEINE_PAGE) #if (UPDATE_METHOD == UPDATE_METHOD_FULL_PAGE)
// Mise à jour de la totalité de l'écran // Mise à jour de la totalité de l'écran
if (Update_necessaire) if (update_is_required)
{ {
SDL_UpdateRect(Ecran_SDL, 0, 0, 0, 0); SDL_UpdateRect(Screen_SDL, 0, 0, 0, 0);
Update_necessaire=0; update_is_required=0;
} }
#endif #endif
#if (METHODE_UPDATE == METHODE_UPDATE_PAR_CUMUL) #if (UPDATE_METHOD == UPDATE_METHOD_CUMULATED)
if (Min_X>=Max_X || Min_Y>=Max_Y) if (Min_X>=Max_X || Min_Y>=Max_Y)
{ {
; // Rien a faire ; // Rien a faire
@ -97,7 +97,7 @@ void Flush_update(void)
Min_X=0; Min_X=0;
if (Min_Y<0) if (Min_Y<0)
Min_Y=0; Min_Y=0;
SDL_UpdateRect(Ecran_SDL, Min_X*Pixel_width, Min_Y*Pixel_height, Min(Largeur_ecran-Min_X, Max_X-Min_X)*Pixel_width, Min(Hauteur_ecran-Min_Y, Max_Y-Min_Y)*Pixel_height); SDL_UpdateRect(Screen_SDL, Min_X*Pixel_width, Min_Y*Pixel_height, Min(Screen_width-Min_X, Max_X-Min_X)*Pixel_width, Min(Screen_height-Min_Y, Max_Y-Min_Y)*Pixel_height);
Min_X=Min_Y=10000; Min_X=Min_Y=10000;
Max_X=Max_Y=0; Max_X=Max_Y=0;
@ -106,13 +106,13 @@ void Flush_update(void)
} }
void UpdateRect(short x, short y, unsigned short width, unsigned short height) void Update_rect(short x, short y, unsigned short width, unsigned short height)
{ {
#if (METHODE_UPDATE == METHODE_UPDATE_MULTI_RECTANGLE) #if (UPDATE_METHOD == UPDATE_METHOD_MULTI_RECTANGLE)
SDL_UpdateRect(Ecran_SDL, x*Pixel_width, y*Pixel_height, width*Pixel_width, height*Pixel_height); SDL_UpdateRect(Screen_SDL, x*Pixel_width, y*Pixel_height, width*Pixel_width, height*Pixel_height);
#endif #endif
#if (METHODE_UPDATE == METHODE_UPDATE_PAR_CUMUL) #if (UPDATE_METHOD == UPDATE_METHOD_CUMULATED)
if (width==0 || height==0) if (width==0 || height==0)
{ {
Min_X=Min_Y=0; Min_X=Min_Y=0;
@ -131,8 +131,8 @@ void UpdateRect(short x, short y, unsigned short width, unsigned short height)
} }
#endif #endif
#if (METHODE_UPDATE == METHODE_UPDATE_PLEINE_PAGE) #if (UPDATE_METHOD == UPDATE_METHOD_FULL_PAGE)
Update_necessaire=1; update_is_required=1;
#endif #endif
} }
@ -140,51 +140,51 @@ void UpdateRect(short x, short y, unsigned short width, unsigned short height)
// Convertit une SDL_Surface (couleurs indexées ou RGB) en tableau de bytes (couleurs indexées) // Convertit une SDL_Surface (couleurs indexées ou RGB) en tableau de bytes (couleurs indexées)
// Si on passe NULL comme destination, elle est allouée par malloc(). Sinon, // Si on passe NULL comme destination, elle est allouée par malloc(). Sinon,
// attention aux dimensions! // attention aux dimensions!
byte * Surface_en_bytefield(SDL_Surface *Source, byte * dest) byte * Surface_to_bytefield(SDL_Surface *source, byte * dest)
{ {
byte *Src; byte *src;
byte *dest_ptr; byte *dest_ptr;
int y; int y;
int remainder; int remainder;
// Support seulement des images 256 couleurs // Support seulement des images 256 couleurs
if (Source->format->BytesPerPixel != 1) if (source->format->BytesPerPixel != 1)
return NULL; return NULL;
if (Source->w & 3) if (source->w & 3)
remainder=4-(Source->w&3); remainder=4-(source->w&3);
else else
remainder=0; remainder=0;
if (dest==NULL) if (dest==NULL)
dest=(byte *)malloc(Source->w*Source->h); dest=(byte *)malloc(source->w*source->h);
dest_ptr=dest; dest_ptr=dest;
Src=(byte *)(Source->pixels); src=(byte *)(source->pixels);
for(y=0; y < Source->h; y++) for(y=0; y < source->h; y++)
{ {
memcpy(dest_ptr, Src,Source->w); memcpy(dest_ptr, src,source->w);
dest_ptr += Source->w; dest_ptr += source->w;
Src += Source->w + remainder; src += source->w + remainder;
} }
return dest; return dest;
} }
// Convertit un index de palette en couleur RGB 24 bits // Convertit un index de palette en couleur RGB 24 bits
SDL_Color Conversion_couleur_SDL(byte index) SDL_Color Color_to_SDL_color(byte index)
{ {
SDL_Color Couleur; SDL_Color color;
Couleur.r = Principal_Palette[index].R; color.r = Main_palette[index].R;
Couleur.g = Principal_Palette[index].G; color.g = Main_palette[index].G;
Couleur.b = Principal_Palette[index].B; color.b = Main_palette[index].B;
Couleur.unused = 255; color.unused = 255;
return Couleur; return color;
} }
// Lecture d'un pixel pour une surface SDL. // Lecture d'un pixel pour une surface SDL.
// Attention, ne fonctionne que pour les surfaces 8-bit // Attention, ne fonctionne que pour les surfaces 8-bit
byte Sdl_Get_pixel_8(SDL_Surface *Bmp, int x, int y) byte Get_SDL_pixel_8(SDL_Surface *bmp, int x, int y)
{ {
return ((byte *)(Bmp->pixels))[(y*Bmp->pitch+x)]; return ((byte *)(bmp->pixels))[(y*bmp->pitch+x)];
} }

View File

@ -25,15 +25,15 @@
#include <SDL.h> #include <SDL.h>
#include "struct.h" #include "struct.h"
void Set_Mode_SDL(int *,int *,int); void Set_mode_SDL(int *,int *,int);
SDL_Rect ** Liste_Modes_Videos_SDL; SDL_Rect ** List_SDL_video_modes;
byte* Ecran; byte* Screen;
void UpdateRect(short x, short y, unsigned short width, unsigned short height); void Update_rect(short x, short y, unsigned short width, unsigned short height);
void Flush_update(void); void Flush_update(void);
byte * Surface_en_bytefield(SDL_Surface *Source, byte * dest); byte * Surface_to_bytefield(SDL_Surface *source, byte * dest);
SDL_Color Conversion_couleur_SDL(byte); SDL_Color Color_to_SDL_color(byte);
byte Sdl_Get_pixel_8(SDL_Surface *Bmp, int x, int y); byte Get_SDL_pixel_8(SDL_Surface *bmp, int x, int y);
#endif // SDLSCREEN_H_INCLUDED #endif // SDLSCREEN_H_INCLUDED

78
setup.c
View File

@ -40,13 +40,13 @@
#include "struct.h" #include "struct.h"
#include "io.h" #include "io.h"
int Create_ConfigDirectory(char * Config_Dir) int Create_ConfigDirectory(char * config_dir)
{ {
#ifdef __WIN32__ #ifdef __WIN32__
// Mingw's mkdir has a weird name and only one argument // Mingw's mkdir has a weird name and only one argument
return _mkdir(Config_Dir); return _mkdir(config_dir);
#else #else
return mkdir(Config_Dir,S_IRUSR|S_IWUSR|S_IXUSR); return mkdir(config_dir,S_IRUSR|S_IWUSR|S_IXUSR);
#endif #endif
} }
@ -57,23 +57,23 @@ int Create_ConfigDirectory(char * Config_Dir)
#endif #endif
// Determine which directory contains the executable. // Determine which directory contains the executable.
// IN: Main's argv[0], some platforms need it, some don't. // IN: Main's argv[0], some platforms need it, some don't.
// OUT: Write into Program_Dir. Trailing / or \ is kept. // OUT: Write into program_dir. Trailing / or \ is kept.
// Note : in fact this is only used to check for the datafiles and fonts in this same directory. // Note : in fact this is only used to check for the datafiles and fonts in this same directory.
void Set_Program_Directory(ARG_UNUSED const char * argv0,char * Program_Dir) void Set_program_directory(ARG_UNUSED const char * argv0,char * program_dir)
{ {
#undef ARG_UNUSED #undef ARG_UNUSED
// MacOSX // MacOSX
#if defined(__macosx__) #if defined(__macosx__)
CFURLRef url = CFBundleCopyBundleURL(CFBundleGetMainBundle()); CFURLRef url = CFBundleCopyBundleURL(CFBundleGetMainBundle());
CFURLGetFileSystemRepresentation(url,true,(UInt8*)Program_Dir,MAXPATHLEN); CFURLGetFileSystemRepresentation(url,true,(UInt8*)program_dir,MAXPATHLEN);
CFRelease(url); CFRelease(url);
// Append trailing slash // Append trailing slash
strcat(Program_Dir ,"/"); strcat(program_dir ,"/");
// AmigaOS4: hard-coded volume name. // AmigaOS4: hard-coded volume name.
#elif defined(__amigaos4__) || defined(__AROS__) || defined(__MORPHOS__) #elif defined(__amigaos4__) || defined(__AROS__) || defined(__MORPHOS__)
strcpy(Program_Dir,"PROGDIR:"); strcpy(program_dir,"PROGDIR:");
// Others: The part of argv[0] before the executable name. // Others: The part of argv[0] before the executable name.
// Keep the last \ or /. // Keep the last \ or /.
@ -81,91 +81,91 @@ void Set_Program_Directory(ARG_UNUSED const char * argv0,char * Program_Dir)
// sitting in /usr/local/bin/, this allows argv[0] to contain the full path. // sitting in /usr/local/bin/, this allows argv[0] to contain the full path.
// On Windows, Mingw32 already provides the full path in all cases. // On Windows, Mingw32 already provides the full path in all cases.
#else #else
Extraire_chemin(Program_Dir, argv0); Extract_path(program_dir, argv0);
#endif #endif
} }
// Determine which directory contains the read-only data. // Determine which directory contains the read-only data.
// IN: The directory containing the executable // IN: The directory containing the executable
// OUT: Write into Data_Dir. Trailing / or \ is kept. // OUT: Write into data_dir. Trailing / or \ is kept.
void Set_Data_Directory(const char * Program_Dir, char * Data_Dir) void Set_data_directory(const char * program_dir, char * data_dir)
{ {
// On all platforms, data is in the executable's directory // On all platforms, data is in the executable's directory
strcpy(Data_Dir,Program_Dir); strcpy(data_dir,program_dir);
// Except MacOSX: // Except MacOSX:
#if defined(__macosx__) #if defined(__macosx__)
strcat(Data_Dir,"Contents/Resources/"); strcat(data_dir,"Contents/Resources/");
#endif #endif
} }
// Determine which directory should store the user's configuration. // Determine which directory should store the user's configuration.
// //
// For most Unix and Windows platforms: // For most Unix and Windows platforms:
// If a config file already exists in Program_Dir, it will return it in priority // If a config file already exists in program_dir, it will return it in priority
// (Useful for development, and possibly for upgrading from DOS version) // (Useful for development, and possibly for upgrading from DOS version)
// If the standard directory doesn't exist yet, this function will attempt // If the standard directory doesn't exist yet, this function will attempt
// to create it ($(HOME)/.grafx2, or %APPDATA%\GrafX2) // to create it ($(HOME)/.grafx2, or %APPDATA%\GrafX2)
// If it cannot be created, this function will return the executable's // If it cannot be created, this function will return the executable's
// own directory. // own directory.
// IN: The directory containing the executable // IN: The directory containing the executable
// OUT: Write into Config_Dir. Trailing / or \ is kept. // OUT: Write into config_dir. Trailing / or \ is kept.
void Set_Config_Directory(const char * Program_Dir, char * Config_Dir) void Set_config_directory(const char * program_dir, char * config_dir)
{ {
// MacOSX // MacOSX
#if defined(__macosx__) #if defined(__macosx__)
strcpy(Config_Dir,Program_Dir); strcpy(config_dir,program_dir);
strcat(Config_Dir,"Contents/Resources/"); strcat(config_dir,"Contents/Resources/");
// AmigaOS4 // AmigaOS4
#elif defined(__amigaos4__) || defined(__AROS__) #elif defined(__amigaos4__) || defined(__AROS__)
strcpy(Config_Dir,"PROGDIR:"); strcpy(config_dir,"PROGDIR:");
#else #else
char FileName[TAILLE_CHEMIN_FICHIER]; char filename[MAX_PATH_CHARACTERS];
// In priority: check own directory // In priority: check own directory
strcpy(Config_Dir, Program_Dir); strcpy(config_dir, program_dir);
strcpy(FileName, Config_Dir); strcpy(filename, config_dir);
strcat(FileName, "gfx2.cfg"); strcat(filename, "gfx2.cfg");
if (!Fichier_existe(FileName)) if (!File_exists(filename))
{ {
char *Config_ParentDir; char *config_parent_dir;
#if defined(__WIN32__) #if defined(__WIN32__)
// "%APPDATA%\GrafX2" // "%APPDATA%\GrafX2"
const char* Config_SubDir = "GrafX2"; const char* Config_SubDir = "GrafX2";
Config_ParentDir = getenv("APPDATA"); config_parent_dir = getenv("APPDATA");
#elif defined(__BEOS__) || defined(__HAIKU__) #elif defined(__BEOS__) || defined(__HAIKU__)
// "~/.grafx2" // "~/.grafx2"
const char* Config_SubDir = ".grafx2"; const char* Config_SubDir = ".grafx2";
Config_ParentDir = getenv("$HOME"); config_parent_dir = getenv("$HOME");
#else #else
// "~/.grafx2" // "~/.grafx2"
const char* Config_SubDir = ".grafx2"; const char* Config_SubDir = ".grafx2";
Config_ParentDir = getenv("HOME"); config_parent_dir = getenv("HOME");
#endif #endif
if (Config_ParentDir && Config_ParentDir[0]!='\0') if (config_parent_dir && config_parent_dir[0]!='\0')
{ {
int size = strlen(Config_ParentDir); int size = strlen(config_parent_dir);
strcpy(Config_Dir, Config_ParentDir); strcpy(config_dir, config_parent_dir);
if (Config_ParentDir[size-1] != '\\' && Config_ParentDir[size-1] != '/') if (config_parent_dir[size-1] != '\\' && config_parent_dir[size-1] != '/')
{ {
strcat(Config_Dir,SEPARATEUR_CHEMIN); strcat(config_dir,PATH_SEPARATOR);
} }
strcat(Config_Dir,Config_SubDir); strcat(config_dir,Config_SubDir);
if (Repertoire_existe(Config_Dir)) if (Directory_exists(config_dir))
{ {
// Répertoire trouvé, ok // Répertoire trouvé, ok
strcat(Config_Dir,SEPARATEUR_CHEMIN); strcat(config_dir,PATH_SEPARATOR);
} }
else else
{ {
// Tentative de création // Tentative de création
if (!Create_ConfigDirectory(Config_Dir)) if (!Create_ConfigDirectory(config_dir))
{ {
// Réussi // Réussi
strcat(Config_Dir,SEPARATEUR_CHEMIN); strcat(config_dir,PATH_SEPARATOR);
} }
else else
{ {
// Echec: on se rabat sur le repertoire de l'executable. // Echec: on se rabat sur le repertoire de l'executable.
strcpy(Config_Dir,Program_Dir); strcpy(config_dir,program_dir);
} }
} }
} }

View File

@ -21,7 +21,7 @@
write to the Free Software Foundation, Inc., write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
void Set_Program_Directory(const char * argv0,char * Program_Dir); void Set_program_directory(const char * argv0,char * program_dir);
void Set_Data_Directory(const char * Program_Dir, char * Data_Dir); void Set_data_directory(const char * program_dir, char * data_dir);
void Set_Config_Directory(const char * Program_Dir, char * Config_Dir); void Set_config_directory(const char * program_dir, char * config_dir);

1114
shade.c

File diff suppressed because it is too large Load Diff

View File

@ -21,6 +21,6 @@
#ifndef SHADE_H_INCLUDED #ifndef SHADE_H_INCLUDED
#define SHADE_H_INCLUDED #define SHADE_H_INCLUDED
void Bouton_Quick_shade_Menu(void); void Button_Quick_shade_menu(void);
#endif // SHADE_H_INCLUDED #endif // SHADE_H_INCLUDED

396
special.c
View File

@ -31,88 +31,88 @@
//---------------------- Modifier le pinceau spécial ------------------------- //---------------------- Modifier le pinceau spécial -------------------------
void Modifier_pinceau(int width, int height) void Set_paintbrush_size(int width, int height)
{ {
int x_pos,y_pos; int x_pos,y_pos;
int x,y; int x,y;
float Rayon2; float radius2;
if (width<1) width=1; if (width<1) width=1;
if (height<1) height=1; if (height<1) height=1;
if (width>TAILLE_MAXI_PINCEAU) width=TAILLE_MAXI_PINCEAU; if (width>MAX_PAINTBRUSH_SIZE) width=MAX_PAINTBRUSH_SIZE;
if (height>TAILLE_MAXI_PINCEAU) height=TAILLE_MAXI_PINCEAU; if (height>MAX_PAINTBRUSH_SIZE) height=MAX_PAINTBRUSH_SIZE;
Pinceau_Largeur=width; Paintbrush_width=width;
Pinceau_Hauteur=height; Paintbrush_height=height;
Pinceau_Decalage_X=Pinceau_Largeur>>1; Paintbrush_offset_X=Paintbrush_width>>1;
Pinceau_Decalage_Y=Pinceau_Hauteur>>1; Paintbrush_offset_Y=Paintbrush_height>>1;
switch (Pinceau_Forme) switch (Paintbrush_shape)
{ {
case FORME_PINCEAU_ROND : case PAINTBRUSH_SHAPE_ROUND :
Rayon2=Pinceau_Decalage_X+0.414213562; // [0.410..0.415[ radius2=Paintbrush_offset_X+0.414213562; // [0.410..0.415[
Rayon2*=Rayon2; radius2*=radius2;
for (y_pos=0; y_pos<Pinceau_Hauteur; y_pos++) for (y_pos=0; y_pos<Paintbrush_height; y_pos++)
for (x_pos=0; x_pos<Pinceau_Largeur; x_pos++) for (x_pos=0; x_pos<Paintbrush_width; x_pos++)
{ {
x=x_pos-Pinceau_Decalage_X; x=x_pos-Paintbrush_offset_X;
y=y_pos-Pinceau_Decalage_Y; y=y_pos-Paintbrush_offset_Y;
Pinceau_Sprite[(y_pos*TAILLE_MAXI_PINCEAU)+x_pos]=( ((x*x)+(y*y)) < Rayon2 ); Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=( ((x*x)+(y*y)) < radius2 );
} }
break; break;
case FORME_PINCEAU_CARRE : case PAINTBRUSH_SHAPE_SQUARE :
for (x_pos=0,y_pos=0; x_pos<Pinceau_Hauteur; x_pos++,y_pos+=TAILLE_MAXI_PINCEAU) for (x_pos=0,y_pos=0; x_pos<Paintbrush_height; x_pos++,y_pos+=MAX_PAINTBRUSH_SIZE)
memset(Pinceau_Sprite+y_pos,1,Pinceau_Largeur); memset(Paintbrush_sprite+y_pos,1,Paintbrush_width);
break; break;
case FORME_PINCEAU_ROND_TRAME : case PAINTBRUSH_SHAPE_SIEVE_ROUND :
Rayon2=Pinceau_Decalage_X+0.414213562; // [0.410..0.415[ radius2=Paintbrush_offset_X+0.414213562; // [0.410..0.415[
Rayon2*=Rayon2; radius2*=radius2;
for (y_pos=0; y_pos<Pinceau_Hauteur; y_pos++) for (y_pos=0; y_pos<Paintbrush_height; y_pos++)
for (x_pos=0; x_pos<Pinceau_Largeur; x_pos++) for (x_pos=0; x_pos<Paintbrush_width; x_pos++)
{ {
x=x_pos-Pinceau_Decalage_X; x=x_pos-Paintbrush_offset_X;
y=y_pos-Pinceau_Decalage_Y; y=y_pos-Paintbrush_offset_Y;
Pinceau_Sprite[(y_pos*TAILLE_MAXI_PINCEAU)+x_pos]=( (!((x_pos+y_pos)&1)) && (((x*x)+(y*y)) < Rayon2)); Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=( (!((x_pos+y_pos)&1)) && (((x*x)+(y*y)) < radius2));
} }
break; break;
case FORME_PINCEAU_CARRE_TRAME: case PAINTBRUSH_SHAPE_SIEVE_SQUARE:
for (y_pos=0; y_pos<Pinceau_Hauteur; y_pos++) for (y_pos=0; y_pos<Paintbrush_height; y_pos++)
for (x_pos=0; x_pos<Pinceau_Largeur; x_pos++) for (x_pos=0; x_pos<Paintbrush_width; x_pos++)
Pinceau_Sprite[(y_pos*TAILLE_MAXI_PINCEAU)+x_pos]=!((x_pos+y_pos)&1); Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=!((x_pos+y_pos)&1);
break; break;
case FORME_PINCEAU_PLUS: case PAINTBRUSH_SHAPE_PLUS:
x=Pinceau_Largeur>>1; x=Paintbrush_width>>1;
for (y_pos=0; y_pos<Pinceau_Hauteur; y_pos++) for (y_pos=0; y_pos<Paintbrush_height; y_pos++)
for (x_pos=0; x_pos<Pinceau_Largeur; x_pos++) for (x_pos=0; x_pos<Paintbrush_width; x_pos++)
Pinceau_Sprite[(y_pos*TAILLE_MAXI_PINCEAU)+x_pos]=((x_pos==x) || (y_pos==x)); Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=((x_pos==x) || (y_pos==x));
break; break;
case FORME_PINCEAU_SLASH: case PAINTBRUSH_SHAPE_SLASH:
x=Pinceau_Largeur>>1; x=Paintbrush_width>>1;
for (y_pos=0; y_pos<Pinceau_Hauteur; y_pos++) for (y_pos=0; y_pos<Paintbrush_height; y_pos++)
for (x_pos=0; x_pos<Pinceau_Largeur; x_pos++) for (x_pos=0; x_pos<Paintbrush_width; x_pos++)
Pinceau_Sprite[(y_pos*TAILLE_MAXI_PINCEAU)+x_pos]=(x_pos==(Pinceau_Largeur-(y_pos+1))); Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=(x_pos==(Paintbrush_width-(y_pos+1)));
break; break;
case FORME_PINCEAU_ANTISLASH: case PAINTBRUSH_SHAPE_ANTISLASH:
x=Pinceau_Largeur>>1; x=Paintbrush_width>>1;
for (y_pos=0; y_pos<Pinceau_Hauteur; y_pos++) for (y_pos=0; y_pos<Paintbrush_height; y_pos++)
for (x_pos=0; x_pos<Pinceau_Largeur; x_pos++) for (x_pos=0; x_pos<Paintbrush_width; x_pos++)
Pinceau_Sprite[(y_pos*TAILLE_MAXI_PINCEAU)+x_pos]=(x_pos==y_pos); Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=(x_pos==y_pos);
break; break;
case FORME_PINCEAU_BARRE_HORIZONTALE: case PAINTBRUSH_SHAPE_HORIZONTAL_BAR:
memset(Pinceau_Sprite,1,Pinceau_Largeur); memset(Paintbrush_sprite,1,Paintbrush_width);
break; break;
case FORME_PINCEAU_BARRE_VERTICALE: case PAINTBRUSH_SHAPE_VERTICAL_BAR:
for (y_pos=0; y_pos<Pinceau_Hauteur; y_pos++) for (y_pos=0; y_pos<Paintbrush_height; y_pos++)
Pinceau_Sprite[(y_pos*TAILLE_MAXI_PINCEAU)]=1; Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)]=1;
break; break;
case FORME_PINCEAU_X: case PAINTBRUSH_SHAPE_CROSS:
x=Pinceau_Largeur>>1; x=Paintbrush_width>>1;
for (y_pos=0; y_pos<Pinceau_Hauteur; y_pos++) for (y_pos=0; y_pos<Paintbrush_height; y_pos++)
for (x_pos=0; x_pos<Pinceau_Largeur; x_pos++) for (x_pos=0; x_pos<Paintbrush_width; x_pos++)
Pinceau_Sprite[(y_pos*TAILLE_MAXI_PINCEAU)+x_pos]=( (x_pos==y_pos) || (x_pos==(Pinceau_Hauteur-(y_pos+1))) ); Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=( (x_pos==y_pos) || (x_pos==(Paintbrush_height-(y_pos+1))) );
break; break;
case FORME_PINCEAU_LOSANGE: case PAINTBRUSH_SHAPE_DIAMOND:
x=Pinceau_Largeur>>1; x=Paintbrush_width>>1;
for (y_pos=0; y_pos<Pinceau_Hauteur; y_pos++) for (y_pos=0; y_pos<Paintbrush_height; y_pos++)
for (x_pos=0; x_pos<Pinceau_Largeur; x_pos++) for (x_pos=0; x_pos<Paintbrush_width; x_pos++)
{ {
if (x_pos<=x) if (x_pos<=x)
y=x-x_pos; y=x-x_pos;
@ -122,212 +122,212 @@ void Modifier_pinceau(int width, int height)
y+=x-y_pos; y+=x-y_pos;
else else
y+=y_pos-x; y+=y_pos-x;
Pinceau_Sprite[(y_pos*TAILLE_MAXI_PINCEAU)+x_pos]=(y<=x); Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=(y<=x);
} }
break; break;
case FORME_PINCEAU_ALEATOIRE: case PAINTBRUSH_SHAPE_RANDOM:
Rayon2=Pinceau_Decalage_X+0.414213562; // [0.410..0.415[ radius2=Paintbrush_offset_X+0.414213562; // [0.410..0.415[
Rayon2*=Rayon2; radius2*=radius2;
for (y_pos=0; y_pos<Pinceau_Hauteur; y_pos++) for (y_pos=0; y_pos<Paintbrush_height; y_pos++)
for (x_pos=0; x_pos<Pinceau_Largeur; x_pos++) for (x_pos=0; x_pos<Paintbrush_width; x_pos++)
{ {
x=x_pos-Pinceau_Decalage_X; x=x_pos-Paintbrush_offset_X;
y=y_pos-Pinceau_Decalage_Y; y=y_pos-Paintbrush_offset_Y;
Pinceau_Sprite[(y_pos*TAILLE_MAXI_PINCEAU)+x_pos]=( (((x*x)+(y*y)) < Rayon2) && (!(rand()&7)) ); Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=( (((x*x)+(y*y)) < radius2) && (!(rand()&7)) );
} }
} }
} }
void Retrecir_pinceau(void) void Smaller_paintbrush(void)
{ {
if ( (Pinceau_Forme<FORME_PINCEAU_DIVERS) if ( (Paintbrush_shape<PAINTBRUSH_SHAPE_MISC)
&& ( (Pinceau_Largeur>1) && ( (Paintbrush_width>1)
|| (Pinceau_Hauteur>1) ) ) || (Paintbrush_height>1) ) )
{ {
Effacer_curseur(); Hide_cursor();
switch (Pinceau_Forme) switch (Paintbrush_shape)
{ {
case FORME_PINCEAU_ROND: case PAINTBRUSH_SHAPE_ROUND:
case FORME_PINCEAU_ROND_TRAME: case PAINTBRUSH_SHAPE_SIEVE_ROUND:
case FORME_PINCEAU_X: case PAINTBRUSH_SHAPE_CROSS:
case FORME_PINCEAU_PLUS: case PAINTBRUSH_SHAPE_PLUS:
case FORME_PINCEAU_LOSANGE: case PAINTBRUSH_SHAPE_DIAMOND:
case FORME_PINCEAU_ALEATOIRE: case PAINTBRUSH_SHAPE_RANDOM:
if (Pinceau_Largeur&1) if (Paintbrush_width&1)
Modifier_pinceau(Pinceau_Largeur-2,Pinceau_Hauteur-2); Set_paintbrush_size(Paintbrush_width-2,Paintbrush_height-2);
else else
Modifier_pinceau(Pinceau_Largeur-1,Pinceau_Hauteur-1); Set_paintbrush_size(Paintbrush_width-1,Paintbrush_height-1);
break; break;
case FORME_PINCEAU_CARRE: case PAINTBRUSH_SHAPE_SQUARE:
case FORME_PINCEAU_SLASH: case PAINTBRUSH_SHAPE_SLASH:
case FORME_PINCEAU_ANTISLASH: case PAINTBRUSH_SHAPE_ANTISLASH:
case FORME_PINCEAU_CARRE_TRAME: case PAINTBRUSH_SHAPE_SIEVE_SQUARE:
Modifier_pinceau(Pinceau_Largeur-1,Pinceau_Hauteur-1); Set_paintbrush_size(Paintbrush_width-1,Paintbrush_height-1);
break; break;
case FORME_PINCEAU_BARRE_HORIZONTALE: case PAINTBRUSH_SHAPE_HORIZONTAL_BAR:
Modifier_pinceau(Pinceau_Largeur-1,1); Set_paintbrush_size(Paintbrush_width-1,1);
break; break;
case FORME_PINCEAU_BARRE_VERTICALE: case PAINTBRUSH_SHAPE_VERTICAL_BAR:
Modifier_pinceau(1,Pinceau_Hauteur-1); Set_paintbrush_size(1,Paintbrush_height-1);
} }
Afficher_pinceau_dans_menu(); Display_paintbrush_in_menu();
Afficher_curseur(); Display_cursor();
} }
} }
void Grossir_pinceau(void) void Bigger_paintbrush(void)
{ {
if ( (Pinceau_Forme<FORME_PINCEAU_DIVERS) if ( (Paintbrush_shape<PAINTBRUSH_SHAPE_MISC)
&& ( (Pinceau_Largeur<TAILLE_MAXI_PINCEAU) && ( (Paintbrush_width<MAX_PAINTBRUSH_SIZE)
|| (Pinceau_Hauteur<TAILLE_MAXI_PINCEAU) ) ) || (Paintbrush_height<MAX_PAINTBRUSH_SIZE) ) )
{ {
Effacer_curseur(); Hide_cursor();
switch (Pinceau_Forme) switch (Paintbrush_shape)
{ {
case FORME_PINCEAU_ROND: case PAINTBRUSH_SHAPE_ROUND:
case FORME_PINCEAU_ROND_TRAME: case PAINTBRUSH_SHAPE_SIEVE_ROUND:
case FORME_PINCEAU_ALEATOIRE: case PAINTBRUSH_SHAPE_RANDOM:
case FORME_PINCEAU_X: case PAINTBRUSH_SHAPE_CROSS:
case FORME_PINCEAU_PLUS: case PAINTBRUSH_SHAPE_PLUS:
case FORME_PINCEAU_LOSANGE: case PAINTBRUSH_SHAPE_DIAMOND:
if (Pinceau_Largeur&1) if (Paintbrush_width&1)
Modifier_pinceau(Pinceau_Largeur+2,Pinceau_Hauteur+2); Set_paintbrush_size(Paintbrush_width+2,Paintbrush_height+2);
else else
Modifier_pinceau(Pinceau_Largeur+1,Pinceau_Hauteur+1); Set_paintbrush_size(Paintbrush_width+1,Paintbrush_height+1);
break; break;
case FORME_PINCEAU_CARRE: case PAINTBRUSH_SHAPE_SQUARE:
case FORME_PINCEAU_SLASH: case PAINTBRUSH_SHAPE_SLASH:
case FORME_PINCEAU_ANTISLASH: case PAINTBRUSH_SHAPE_ANTISLASH:
case FORME_PINCEAU_CARRE_TRAME: case PAINTBRUSH_SHAPE_SIEVE_SQUARE:
Modifier_pinceau(Pinceau_Largeur+1,Pinceau_Hauteur+1); Set_paintbrush_size(Paintbrush_width+1,Paintbrush_height+1);
break; break;
case FORME_PINCEAU_BARRE_HORIZONTALE: case PAINTBRUSH_SHAPE_HORIZONTAL_BAR:
Modifier_pinceau(Pinceau_Largeur+1,1); Set_paintbrush_size(Paintbrush_width+1,1);
break; break;
case FORME_PINCEAU_BARRE_VERTICALE: case PAINTBRUSH_SHAPE_VERTICAL_BAR:
Modifier_pinceau(1,Pinceau_Hauteur+1); Set_paintbrush_size(1,Paintbrush_height+1);
} }
Afficher_pinceau_dans_menu(); Display_paintbrush_in_menu();
Afficher_curseur(); Display_cursor();
} }
} }
//--------------------- Passer à la ForeColor suivante ----------------------- //--------------------- Passer à la ForeColor suivante -----------------------
void Special_Next_forecolor(void) void Special_next_forecolor(void)
{ {
Effacer_curseur(); Hide_cursor();
Encadrer_couleur_menu(CM_Noir); Frame_menu_color(MC_Black);
Fore_color++; Fore_color++;
Recadrer_palette(); Reposition_palette();
Afficher_foreback(); Display_foreback();
Encadrer_couleur_menu(CM_Blanc); Frame_menu_color(MC_White);
Afficher_curseur(); Display_cursor();
} }
//-------------------- Passer à la ForeColor précédente ---------------------- //-------------------- Passer à la ForeColor précédente ----------------------
void Special_Previous_forecolor(void) void Special_previous_forecolor(void)
{ {
Effacer_curseur(); Hide_cursor();
Encadrer_couleur_menu(CM_Noir); Frame_menu_color(MC_Black);
Fore_color--; Fore_color--;
Recadrer_palette(); Reposition_palette();
Afficher_foreback(); Display_foreback();
Encadrer_couleur_menu(CM_Blanc); Frame_menu_color(MC_White);
Afficher_curseur(); Display_cursor();
} }
//--------------------- Passer à la BackColor suivante ----------------------- //--------------------- Passer à la BackColor suivante -----------------------
void Special_Next_backcolor(void) void Special_next_backcolor(void)
{ {
Effacer_curseur(); Hide_cursor();
Back_color++; Back_color++;
Afficher_foreback(); Display_foreback();
Afficher_curseur(); Display_cursor();
} }
//-------------------- Passer à la BackColor précédente ---------------------- //-------------------- Passer à la BackColor précédente ----------------------
void Special_Previous_backcolor(void) void Special_previous_backcolor(void)
{ {
Effacer_curseur(); Hide_cursor();
Back_color--; Back_color--;
Afficher_foreback(); Display_foreback();
Afficher_curseur(); Display_cursor();
} }
// ------------------- Scroller l'écran (pas en mode loupe) ------------------ // ------------------- Scroller l'écran (pas en mode loupe) ------------------
void Scroller_ecran(short Decalage_en_X,short Decalage_en_Y) void Scroll_screen(short delta_x,short delta_y)
{ {
short Decalage_temporaire_X; short temp_x_offset;
short Decalage_temporaire_Y; short temp_y_offset;
Decalage_temporaire_X=Principal_Decalage_X+Decalage_en_X; temp_x_offset=Main_offset_X+delta_x;
Decalage_temporaire_Y=Principal_Decalage_Y+Decalage_en_Y; temp_y_offset=Main_offset_Y+delta_y;
if (Decalage_temporaire_X+Largeur_ecran>Principal_Largeur_image) if (temp_x_offset+Screen_width>Main_image_width)
Decalage_temporaire_X=Principal_Largeur_image-Largeur_ecran; temp_x_offset=Main_image_width-Screen_width;
if (Decalage_temporaire_Y+Menu_Ordonnee>Principal_Hauteur_image) if (temp_y_offset+Menu_Y>Main_image_height)
Decalage_temporaire_Y=Principal_Hauteur_image-Menu_Ordonnee; temp_y_offset=Main_image_height-Menu_Y;
if (Decalage_temporaire_X<0) if (temp_x_offset<0)
Decalage_temporaire_X=0; temp_x_offset=0;
if (Decalage_temporaire_Y<0) if (temp_y_offset<0)
Decalage_temporaire_Y=0; temp_y_offset=0;
if ( (Principal_Decalage_X!=Decalage_temporaire_X) || if ( (Main_offset_X!=temp_x_offset) ||
(Principal_Decalage_Y!=Decalage_temporaire_Y) ) (Main_offset_Y!=temp_y_offset) )
{ {
Effacer_curseur(); Hide_cursor();
Principal_Decalage_X=Decalage_temporaire_X; Main_offset_X=temp_x_offset;
Principal_Decalage_Y=Decalage_temporaire_Y; Main_offset_Y=temp_y_offset;
Calculer_limites(); Compute_limits();
Calculer_coordonnees_pinceau(); Compute_paintbrush_coordinates();
Afficher_ecran(); // <=> Display_screen + Afficher_limites_de_l_image Display_all_screen(); // <=> Display_screen + Display_image_limits
Afficher_curseur(); Display_cursor();
} }
} }
// ---------------------- Scroller la fenêtre de la loupe -------------------- // ---------------------- Scroller la fenêtre de la loupe --------------------
void Scroller_loupe(short Decalage_en_X,short Decalage_en_Y) void Scroll_magnifier(short delta_x,short delta_y)
{ {
short Decalage_temporaire_X; short temp_x_offset;
short Decalage_temporaire_Y; short temp_y_offset;
Decalage_temporaire_X=Loupe_Decalage_X+Decalage_en_X; temp_x_offset=Main_magnifier_offset_X+delta_x;
Decalage_temporaire_Y=Loupe_Decalage_Y+Decalage_en_Y; temp_y_offset=Main_magnifier_offset_Y+delta_y;
if (Decalage_temporaire_X+Loupe_Largeur>Principal_Largeur_image) if (temp_x_offset+Main_magnifier_width>Main_image_width)
Decalage_temporaire_X=Principal_Largeur_image-Loupe_Largeur; temp_x_offset=Main_image_width-Main_magnifier_width;
if (Decalage_temporaire_Y+Loupe_Hauteur>Principal_Hauteur_image) if (temp_y_offset+Main_magnifier_height>Main_image_height)
Decalage_temporaire_Y=Principal_Hauteur_image-Loupe_Hauteur; temp_y_offset=Main_image_height-Main_magnifier_height;
if (Decalage_temporaire_X<0) if (temp_x_offset<0)
Decalage_temporaire_X=0; temp_x_offset=0;
if (Decalage_temporaire_Y<0) if (temp_y_offset<0)
Decalage_temporaire_Y=0; temp_y_offset=0;
if ( (Loupe_Decalage_X!=Decalage_temporaire_X) || if ( (Main_magnifier_offset_X!=temp_x_offset) ||
(Loupe_Decalage_Y!=Decalage_temporaire_Y) ) (Main_magnifier_offset_Y!=temp_y_offset) )
{ {
Effacer_curseur(); Hide_cursor();
Loupe_Decalage_X=Decalage_temporaire_X; Main_magnifier_offset_X=temp_x_offset;
Loupe_Decalage_Y=Decalage_temporaire_Y; Main_magnifier_offset_Y=temp_y_offset;
Recadrer_ecran_par_rapport_au_zoom(); Position_screen_according_to_zoom();
Calculer_limites(); Compute_limits();
Calculer_coordonnees_pinceau(); Compute_paintbrush_coordinates();
Afficher_ecran(); Display_all_screen();
Afficher_curseur(); Display_cursor();
} }
} }
@ -335,16 +335,16 @@ void Scroller_loupe(short Decalage_en_X,short Decalage_en_Y)
// -------------- Changer le Zoom (grâce aux touches [+] et [-]) ------------- // -------------- Changer le Zoom (grâce aux touches [+] et [-]) -------------
void Zoom(short delta) void Zoom(short delta)
{ {
short Indice; short index;
for (Indice=0; FACTEUR_ZOOM[Indice]!=Loupe_Facteur; Indice++); for (index=0; ZOOM_FACTOR[index]!=Main_magnifier_factor; index++);
Indice+=delta; index+=delta;
if ( (Indice>=0) && (Indice<NB_FACTEURS_DE_ZOOM) ) if ( (index>=0) && (index<NB_ZOOM_FACTORS) )
{ {
Effacer_curseur(); Hide_cursor();
Changer_facteur_loupe(Indice); Change_magnifier_factor(index);
if (Loupe_Mode) if (Main_magnifier_mode)
Afficher_ecran(); Display_all_screen();
Afficher_curseur(); Display_cursor();
} }
} }

View File

@ -18,16 +18,16 @@
write to the Free Software Foundation, Inc., write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
void Modifier_pinceau(int width, int height); void Set_paintbrush_size(int width, int height);
void Retrecir_pinceau(void); void Smaller_paintbrush(void);
void Grossir_pinceau(void); void Bigger_paintbrush(void);
void Special_Next_forecolor(void); void Special_next_forecolor(void);
void Special_Previous_forecolor(void); void Special_previous_forecolor(void);
void Special_Next_backcolor(void); void Special_next_backcolor(void);
void Special_Previous_backcolor(void); void Special_previous_backcolor(void);
void Scroller_ecran(short Decalage_en_X,short Decalage_en_Y); void Scroll_screen(short delta_x,short delta_y);
void Scroller_loupe(short Decalage_en_X,short Decalage_en_Y); void Scroll_magnifier(short delta_x,short delta_y);
void Zoom(short delta); void Zoom(short delta);

218
struct.h
View File

@ -37,32 +37,32 @@
#define dword uint32_t #define dword uint32_t
#define qword uint64_t #define qword uint64_t
typedef void (* fonction_action) (void); typedef void (* Func_action) (void);
typedef void (* fonction_afficheur) (word,word,byte); typedef void (* Func_pixel) (word,word,byte);
typedef byte (* fonction_lecteur) (word,word); typedef byte (* Func_read) (word,word);
typedef void (* fonction_effaceur) (byte); typedef void (* Func_clear) (byte);
typedef void (* fonction_display) (word,word,word); typedef void (* Func_display) (word,word,word);
typedef byte (* fonction_effet) (word,word,byte); typedef byte (* Func_effect) (word,word,byte);
typedef void (* fonction_block) (word,word,word,word,byte); typedef void (* Func_block) (word,word,word,word,byte);
typedef void (* fonction_Ligne_XOR) (word,word,word); typedef void (* Func_line_XOR) (word,word,word);
typedef void (* fonction_display_brush_Color) (word,word,word,word,word,word,byte,word); typedef void (* Func_display_brush_color) (word,word,word,word,word,word,byte,word);
typedef void (* fonction_display_brush_Mono) (word,word,word,word,word,word,byte,byte,word); typedef void (* Func_display_brush_mono) (word,word,word,word,word,word,byte,byte,word);
typedef void (* fonction_degrade) (long,short,short); typedef void (* Func_gradient) (long,short,short);
typedef void (* fonction_remap) (word,word,word,word,byte *); typedef void (* Func_remap) (word,word,word,word,byte *);
typedef void (* fonction_procsline) (word,word,word,byte *); typedef void (* Func_procsline) (word,word,word,byte *);
typedef void (* fonction_display_zoom) (word,word,word,byte *); typedef void (* Func_display_zoom) (word,word,word,byte *);
typedef void (* fonction_display_brush_Color_zoom) (word,word,word,word,word,word,byte,word,byte *); typedef void (* Func_display_brush_color_zoom) (word,word,word,word,word,word,byte,word,byte *);
typedef void (* fonction_display_brush_Mono_zoom) (word,word,word,word,word,word,byte,byte,word,byte *); typedef void (* Func_display_brush_mono_zoom) (word,word,word,word,word,word,byte,byte,word,byte *);
typedef void (* fonction_affiche_brosse) (byte *,word,word,word,word,word,word,byte,word); typedef void (* Func_draw_brush) (byte *,word,word,word,word,word,word,byte,word);
typedef struct typedef struct
{ {
byte R; byte R;
byte G; byte G;
byte B; byte B;
}__attribute__ ((__packed__)) Composantes, T_Palette[256]; }__attribute__ ((__packed__)) T_Components, T_Palette[256];
typedef struct T_Bouton_normal typedef struct T_Normal_button
{ {
short Number; short Number;
word Pos_X; word Pos_X;
@ -70,20 +70,20 @@ typedef struct T_Bouton_normal
word Width; word Width;
word Height; word Height;
byte Clickable; byte Clickable;
byte Repetable; byte Repeatable;
word Raccourci; word Shortcut;
struct T_Bouton_normal * Next; struct T_Normal_button * Next;
} T_Bouton_normal; } T_Normal_button;
typedef struct T_Bouton_palette typedef struct T_Palette_button
{ {
short Number; short Number;
word Pos_X; word Pos_X;
word Pos_Y; word Pos_Y;
struct T_Bouton_palette * Next; struct T_Palette_button * Next;
} T_Bouton_palette; } T_Palette_button;
typedef struct T_Bouton_scroller typedef struct T_Scroller_button
{ {
short Number; short Number;
word Pos_X; word Pos_X;
@ -92,77 +92,77 @@ typedef struct T_Bouton_scroller
word Nb_elements; word Nb_elements;
word Nb_visibles; word Nb_visibles;
word Position; word Position;
word Hauteur_curseur; word Cursor_height;
struct T_Bouton_scroller * Next; struct T_Scroller_button * Next;
} T_Bouton_scroller; } T_Scroller_button;
typedef struct T_Bouton_special typedef struct T_Special_button
{ {
short Number; short Number;
word Pos_X; word Pos_X;
word Pos_Y; word Pos_Y;
word Width; word Width;
word Height; word Height;
struct T_Bouton_special * Next; struct T_Special_button * Next;
} T_Bouton_special; } T_Special_button;
typedef struct T_Dropdown_choix typedef struct T_Dropdown_choice
{ {
short Number; short Number;
const char * Label; const char * Label;
struct T_Dropdown_choix * Next; struct T_Dropdown_choice * Next;
} T_Dropdown_choix; } T_Dropdown_choice;
typedef struct T_Bouton_dropdown typedef struct T_Dropdown_button
{ {
short Number; short Number;
word Pos_X; word Pos_X;
word Pos_Y; word Pos_Y;
word Width; word Width;
word Height; word Height;
byte Affiche_choix; // The selected item's label is printed in the dropdown area byte Display_choice; // The selected item's label is printed in the dropdown area
byte Affiche_centre; // Center labels (otherwise, align left) byte Display_centered; // Center labels (otherwise, align left)
byte Affiche_fleche; // Display a "down" arrow box in top right byte Display_arrow; // Display a "down" arrow box in top right
byte Bouton_actif; // Mouse button: A_GAUCHE || A_DROITE || (A_GAUCHE|A_DROITE) byte Active_button; // Mouse button: LEFT_SIDE || RIGHT_SIDE || (LEFT_SIDE|RIGHT_SIDE)
word Largeur_choix; // 0 for "same as control" word Dropdown_width; // 0 for "same as control"
T_Dropdown_choix * Premier_choix; T_Dropdown_choice * First_item;
struct T_Bouton_dropdown * Next; struct T_Dropdown_button * Next;
} T_Bouton_dropdown; } T_Dropdown_button;
// Déclaration du type d'élément qu'on va mémoriser dans la liste: // Déclaration du type d'élément qu'on va mémoriser dans la liste:
typedef struct Element_de_liste_de_fileselect typedef struct T_Fileselector_item
{ {
char NomAbrege[19]; // Le nom tel qu'affiché dans le fileselector char Short_name[19]; // Le nom tel qu'affiché dans le fileselector
char NomComplet[256]; // Le nom du fichier ou du répertoire char Full_name[256]; // Le nom du fichier ou du répertoire
byte Type; // Type d'élément : 0 = Fichier, 1 = Répertoire, 2 = Lecteur byte Type; // Type d'élément : 0 = Fichier, 1 = Répertoire, 2 = Lecteur
// données de chaînage de la liste // données de chaînage de la liste
struct Element_de_liste_de_fileselect * Suivant; struct T_Fileselector_item * Next;
struct Element_de_liste_de_fileselect * Precedent; struct T_Fileselector_item * Previous;
} Element_de_liste_de_fileselect; } T_Fileselector_item;
typedef struct { typedef struct {
char Line_type; char Line_type;
char * Text; char * Text;
int Line_parameter; int Line_parameter;
} T_TABLEAIDE; } T_Help_table;
// Déclaration d'une section d'aide: // Déclaration d'une section d'aide:
typedef struct typedef struct
{ {
const T_TABLEAIDE* Table_aide; // Pointeur sur le début de la table d'aide const T_Help_table* Help_table; // Pointeur sur le début de la table d'aide
word Nombre_de_lignes; word Length;
} Section_d_aide; } T_Help_section;
// Déclaration d'une info sur un dégradé // Déclaration d'une info sur un dégradé
typedef struct typedef struct
{ {
byte Debut; // Première couleur du dégradé byte Start; // Première couleur du dégradé
byte Fin; // Dernière couleur du dégradé byte End; // Dernière couleur du dégradé
dword Inverse; // "Le dégradé va de Fin à Debut" //INT dword Inverse; // "Le dégradé va de End à Start" //INT
dword Melange; // Valeur de mélange du dégradé (0-255) //LONG dword Mix; // Valeur de mélange du dégradé (0-255) //LONG
dword Technique; // Technique à utiliser (0-2) //INT dword Technique; // Technique à utiliser (0-2) //INT
} __attribute__((__packed__)) T_Degrade_Tableau; } __attribute__((__packed__)) T_Gradient_array;
// Déclaration d'une info de shade // Déclaration d'une info de shade
typedef struct typedef struct
@ -178,10 +178,10 @@ typedef struct
typedef struct typedef struct
{ {
byte Etat; byte State;
word Width; word Width;
word Height; word Height;
} __attribute__((__packed__)) Config_Mode_video; } __attribute__((__packed__)) T_Config_video_mode;
typedef struct typedef struct
{ {
@ -190,62 +190,62 @@ typedef struct
byte Version2; byte Version2;
byte Beta1; byte Beta1;
byte Beta2; byte Beta2;
} __attribute__((__packed__)) Config_Header; } __attribute__((__packed__)) T_Config_header;
typedef struct typedef struct
{ {
byte Number; byte Number;
word Size; word Size;
} __attribute__((__packed__)) Config_Chunk; } __attribute__((__packed__)) T_Config_chunk;
typedef struct typedef struct
{ {
word Number; word Number;
word Touche; word Key;
word Touche2; word Key2;
} __attribute__((__packed__)) Config_Infos_touche; } __attribute__((__packed__)) T_Config_shortcut_info;
typedef struct typedef struct
{ {
byte Fonte; byte Font;
int Lire_les_fichiers_caches; int Show_hidden_files;
int Lire_les_repertoires_caches; int Show_hidden_directories;
// int Lire_les_repertoires_systemes; // int Show_system_directories;
byte Afficher_limites_image; byte Display_image_limits;
byte Curseur; byte Cursor;
byte Maximize_preview; byte Maximize_preview;
byte Auto_set_res; byte Auto_set_res;
byte Coords_rel; byte Coords_rel;
byte Backup; byte Backup;
byte Adjust_brush_pick; byte Adjust_brush_pick;
byte Auto_save; byte Auto_save;
byte Nb_pages_Undo; byte Max_undo_pages;
byte Indice_Sensibilite_souris_X; byte Mouse_sensitivity_index_x;
byte Indice_Sensibilite_souris_Y; byte Mouse_sensitivity_index_y;
byte Mouse_Facteur_de_correction_X; byte Mouse_fix_factor_X;
byte Mouse_Facteur_de_correction_Y; byte Mouse_fix_factor_Y;
byte Mouse_Merge_movement; byte Mouse_merge_movement;
byte Valeur_tempo_jauge_gauche; byte Delay_left_click_on_slider;
byte Valeur_tempo_jauge_droite; byte Delay_right_click_on_slider;
long Chrono_delay; long Timer_delay;
Composantes Coul_menu_pref[4]; T_Components Fav_menu_colors[4];
int Nb_max_de_vertex_par_polygon; int Nb_max_vertices_per_polygon;
byte Clear_palette; byte Clear_palette;
byte Set_resolution_according_to; byte Set_resolution_according_to;
byte Ratio; byte Ratio;
byte Fast_zoom; byte Fast_zoom;
byte Find_file_fast; byte Find_file_fast;
byte Couleurs_separees; byte Couleurs_separees;
word Palette_Cells_X; word Palette_cells_X;
word Palette_Cells_Y; word Palette_cells_Y;
byte FX_Feedback; byte FX_Feedback;
byte Safety_colors; byte Safety_colors;
byte Opening_message; byte Opening_message;
byte Clear_with_stencil; byte Clear_with_stencil;
byte Auto_discontinuous; byte Auto_discontinuous;
byte Taille_ecran_dans_GIF; byte Screen_size_in_GIF;
byte Auto_nb_used; byte Auto_nb_used;
byte Resolution_par_defaut; byte Default_resolution;
char *Bookmark_directory[NB_BOOKMARKS]; // independant malloc of adaptive size char *Bookmark_directory[NB_BOOKMARKS]; // independant malloc of adaptive size
char Bookmark_label[NB_BOOKMARKS][8+1]; char Bookmark_label[NB_BOOKMARKS][8+1];
} T_Config; } T_Config;
@ -264,37 +264,37 @@ typedef struct
int Height; // Hauteur du bitmap int Height; // Hauteur du bitmap
T_Palette Palette; // Palette de l'image T_Palette Palette; // Palette de l'image
char Commentaire[TAILLE_COMMENTAIRE+1]; // Commentaire de l'image char Comment[COMMENT_SIZE+1]; // Commentaire de l'image
char Repertoire_fichier[TAILLE_CHEMIN_FICHIER]; // |_ Nom complet = char File_directory[MAX_PATH_CHARACTERS]; // |_ Nom complet =
char Filename[TAILLE_CHEMIN_FICHIER]; // | Repertoire_fichier+"\"+Nom_fichier char Filename[MAX_PATH_CHARACTERS]; // | File_directory+"\"+Nom_fichier
byte Format_fichier; // Format auquel il faut lire et écrire le fichier byte File_format; // Format auquel il faut lire et écrire le fichier
/* /*
short Decalage_X; // Décalage en X de l'écran par rapport au début de l'image short X_offset; // Décalage en X de l'écran par rapport au début de l'image
short Decalage_Y; // Décalage en Y de l'écran par rapport au début de l'image short Y_offset; // Décalage en Y de l'écran par rapport au début de l'image
short Ancien_Decalage_X; // Le même avant le passage en mode loupe short old_offset_x; // Le même avant le passage en mode loupe
short Ancien_Decalage_Y; // Le même avant le passage en mode loupe short old_offset_y; // Le même avant le passage en mode loupe
short Split; // Position en X du bord gauche du split de la loupe short Split; // Position en X du bord gauche du split de la loupe
short X_Zoom; // (Menu_Facteur_X) + Position en X du bord droit du split de la loupe short X_zoom; // (Menu_factor_X) + Position en X du bord droit du split de la loupe
float Proportion_split; // Proportion de la zone non-zoomée par rapport à l'écran float Separator_proportion; // Proportion de la zone non-zoomée par rapport à l'écran
byte Loupe_Mode; // On est en mode loupe byte Main_magnifier_mode; // On est en mode loupe
word Loupe_Facteur; // Facteur de zoom word Main_magnifier_factor; // Facteur de zoom
word Loupe_Hauteur; // Largeur de la fenêtre de zoom word Main_magnifier_height; // Largeur de la fenêtre de zoom
word Loupe_Largeur; // Hauteur de la fenêtre de zoom word Main_magnifier_width; // Hauteur de la fenêtre de zoom
short Loupe_Decalage_X; // Decalage horizontal de la fenêtre de zoom short Main_magnifier_offset_X; // Offset horizontal de la fenêtre de zoom
short Loupe_Decalage_Y; // Decalage vertical de la fenêtre de zoom short Main_magnifier_offset_Y; // Offset vertical de la fenêtre de zoom
*/ */
} S_Page; } T_Page;
typedef struct typedef struct
{ {
int Taille_liste; // Nb de S_Page dans le vecteur "Pages" int List_size; // Nb de T_Page dans le vecteur "Pages"
int Nb_pages_allouees; // Nb de S_Page désignant des pages allouées int Nb_pages_allocated; // Nb de T_Page désignant des pages allouées
S_Page * Pages; // Liste de pages (Taille_liste éléments) T_Page * Pages; // Liste de pages (List_size éléments)
} S_Liste_de_pages; } T_List_of_pages;

File diff suppressed because it is too large Load Diff

286
texte.c
View File

@ -56,41 +56,41 @@
#include "sdlscreen.h" #include "sdlscreen.h"
#include "io.h" #include "io.h"
typedef struct T_FONTE typedef struct T_Font
{ {
char * Name; char * Name;
int EstTrueType; int Is_truetype;
int EstImage; int Is_bitmap;
char Label[22]; char Label[22];
// Liste chainée simple // Liste chainée simple
struct T_FONTE * Suivante; struct T_Font * Next;
struct T_FONTE * Precedente; struct T_Font * Previous;
} T_FONTE; } T_Font;
// Liste chainée des polices de texte // Liste chainée des polices de texte
T_FONTE * Liste_fontes_debut; T_Font * Font_list_start;
int Fonte_nombre; int Nb_fonts;
// Inspiré par Allegro // Inspiré par Allegro
#define EXTID(a,b,c) ((((a)&255)<<16) | (((b)&255)<<8) | (((c)&255))) #define EXTID(a,b,c) ((((a)&255)<<16) | (((b)&255)<<8) | (((c)&255)))
#define EXTID4(a,b,c,d) ((((a)&255)<<24) | (((b)&255)<<16) | (((c)&255)<<8) | (((d)&255))) #define EXTID4(a,b,c,d) ((((a)&255)<<24) | (((b)&255)<<16) | (((c)&255)<<8) | (((d)&255)))
int Compare_fontes(T_FONTE * Fonte1, T_FONTE * Fonte2) int Compare_fonts(T_Font * font_1, T_Font * font_2)
{ {
if (Fonte1->EstImage && !Fonte2->EstImage) if (font_1->Is_bitmap && !font_2->Is_bitmap)
return -1; return -1;
if (Fonte2->EstImage && !Fonte1->EstImage) if (font_2->Is_bitmap && !font_1->Is_bitmap)
return 1; return 1;
return strcmp(Fonte1->Label, Fonte2->Label); return strcmp(font_1->Label, font_2->Label);
} }
// Ajout d'une fonte à la liste. // Ajout d'une fonte à la liste.
void Ajout_fonte(const char *name) void Add_font(const char *name)
{ {
char * Nom_fonte; char * Font_name;
T_FONTE * Fonte; T_Font * Font;
int size=strlen(name)+1; int size=strlen(name)+1;
int Indice; int index;
// Détermination du type: // Détermination du type:
@ -114,7 +114,7 @@ void Ajout_fonte(const char *name)
return; return;
#endif #endif
Fonte = (T_FONTE *)malloc(sizeof(T_FONTE)); Font = (T_Font *)malloc(sizeof(T_Font));
switch (EXTID(tolower(name[size-4]), tolower(name[size-3]), tolower(name[size-2]))) switch (EXTID(tolower(name[size-4]), tolower(name[size-3]), tolower(name[size-2])))
{ {
@ -122,8 +122,8 @@ void Ajout_fonte(const char *name)
case EXTID('f','o','n'): case EXTID('f','o','n'):
case EXTID('o','t','f'): case EXTID('o','t','f'):
case EXTID('p','f','b'): case EXTID('p','f','b'):
Fonte->EstTrueType = 1; Font->Is_truetype = 1;
Fonte->EstImage = 0; Font->Is_bitmap = 0;
break; break;
case EXTID('b','m','p'): case EXTID('b','m','p'):
case EXTID('g','i','f'): case EXTID('g','i','f'):
@ -136,153 +136,153 @@ void Ajout_fonte(const char *name)
case EXTID('x','c','f'): case EXTID('x','c','f'):
case EXTID('x','p','m'): case EXTID('x','p','m'):
case EXTID('.','x','v'): case EXTID('.','x','v'):
Fonte->EstTrueType = 0; Font->Is_truetype = 0;
Fonte->EstImage = 1; Font->Is_bitmap = 1;
break; break;
default: default:
#ifdef __macosx__ #ifdef __macosx__
if(strcasecmp(&name[size-6], "dfont") == 0) if(strcasecmp(&name[size-6], "dfont") == 0)
{ {
Fonte->EstTrueType = 1; Font->Is_truetype = 1;
Fonte->EstImage = 0; Font->Is_bitmap = 0;
} }
else else
{ {
free(Fonte); free(Font);
return; return;
} }
#else #else
free(Fonte); free(Font);
return; return;
#endif #endif
} }
Fonte->Name = (char *)malloc(size); Font->Name = (char *)malloc(size);
strcpy(Fonte->Name, name); strcpy(Font->Name, name);
// Label // Label
strcpy(Fonte->Label, " "); strcpy(Font->Label, " ");
if (Fonte->EstTrueType) if (Font->Is_truetype)
Fonte->Label[17]=Fonte->Label[18]='T'; // Logo TT Font->Label[17]=Font->Label[18]='T'; // Logo TT
Nom_fonte=Position_dernier_slash(Fonte->Name); Font_name=Find_last_slash(Font->Name);
if (Nom_fonte==NULL) if (Font_name==NULL)
Nom_fonte=Fonte->Name; Font_name=Font->Name;
else else
Nom_fonte++; Font_name++;
for (Indice=0; Indice < 17 && Nom_fonte[Indice]!='\0' && Nom_fonte[Indice]!='.'; Indice++) for (index=0; index < 17 && Font_name[index]!='\0' && Font_name[index]!='.'; index++)
Fonte->Label[Indice]=Nom_fonte[Indice]; Font->Label[index]=Font_name[index];
// Gestion Liste // Gestion Liste
Fonte->Suivante = NULL; Font->Next = NULL;
Fonte->Precedente = NULL; Font->Previous = NULL;
if (Liste_fontes_debut==NULL) if (Font_list_start==NULL)
{ {
// Premiere (liste vide) // Premiere (liste vide)
Liste_fontes_debut = Fonte; Font_list_start = Font;
Fonte_nombre++; Nb_fonts++;
} }
else else
{ {
int Compare; int compare;
Compare = Compare_fontes(Fonte, Liste_fontes_debut); compare = Compare_fonts(Font, Font_list_start);
if (Compare<=0) if (compare<=0)
{ {
if (Compare==0 && !strcmp(Fonte->Name, Liste_fontes_debut->Name)) if (compare==0 && !strcmp(Font->Name, Font_list_start->Name))
{ {
// Doublon // Doublon
free(Fonte->Name); free(Font->Name);
free(Fonte); free(Font);
return; return;
} }
// Avant la premiere // Avant la premiere
Fonte->Suivante=Liste_fontes_debut; Font->Next=Font_list_start;
Liste_fontes_debut=Fonte; Font_list_start=Font;
Fonte_nombre++; Nb_fonts++;
} }
else else
{ {
T_FONTE *Fonte_cherchee; T_Font *searched_font;
Fonte_cherchee=Liste_fontes_debut; searched_font=Font_list_start;
while (Fonte_cherchee->Suivante && (Compare=Compare_fontes(Fonte, Fonte_cherchee->Suivante))>0) while (searched_font->Next && (compare=Compare_fonts(Font, searched_font->Next))>0)
Fonte_cherchee=Fonte_cherchee->Suivante; searched_font=searched_font->Next;
// Après Fonte_cherchee // Après searched_font
if (Compare==0 && strcmp(Fonte->Name, Fonte_cherchee->Suivante->Name)==0) if (compare==0 && strcmp(Font->Name, searched_font->Next->Name)==0)
{ {
// Doublon // Doublon
free(Fonte->Name); free(Font->Name);
free(Fonte); free(Font);
return; return;
} }
Fonte->Suivante=Fonte_cherchee->Suivante; Font->Next=searched_font->Next;
Fonte_cherchee->Suivante=Fonte; searched_font->Next=Font;
Fonte_nombre++; Nb_fonts++;
} }
} }
} }
// Trouve le nom d'une fonte par son numéro // Trouve le nom d'une fonte par son numéro
char * Nom_fonte(int Indice) char * Font_name(int index)
{ {
T_FONTE *Fonte = Liste_fontes_debut; T_Font *Font = Font_list_start;
if (Indice<0 ||Indice>=Fonte_nombre) if (index<0 ||index>=Nb_fonts)
return ""; return "";
while (Indice--) while (index--)
Fonte = Fonte->Suivante; Font = Font->Next;
return Fonte->Name; return Font->Name;
} }
// Trouve le libellé d'affichage d'une fonte par son numéro // Trouve le libellé d'affichage d'une fonte par son numéro
// Renvoie un pointeur sur un buffer statique de 20 caracteres. // Renvoie un pointeur sur un buffer statique de 20 caracteres.
char * Libelle_fonte(int Indice) char * Font_label(int index)
{ {
T_FONTE *Fonte; T_Font *Font;
static char label[20]; static char label[20];
strcpy(label, " "); strcpy(label, " ");
// Recherche de la fonte // Recherche de la fonte
Fonte = Liste_fontes_debut; Font = Font_list_start;
if (Indice<0 ||Indice>=Fonte_nombre) if (index<0 ||index>=Nb_fonts)
return label; return label;
while (Indice--) while (index--)
Fonte = Fonte->Suivante; Font = Font->Next;
// Libellé // Libellé
strcpy(label, Fonte->Label); strcpy(label, Font->Label);
return label; return label;
} }
// Vérifie si une fonte donnée est TrueType // Vérifie si une fonte donnée est TrueType
int TrueType_fonte(int Indice) int TrueType_font(int index)
{ {
T_FONTE *Fonte = Liste_fontes_debut; T_Font *Font = Font_list_start;
if (Indice<0 ||Indice>=Fonte_nombre) if (index<0 ||index>=Nb_fonts)
return 0; return 0;
while (Indice--) while (index--)
Fonte = Fonte->Suivante; Font = Font->Next;
return Fonte->EstTrueType; return Font->Is_truetype;
} }
// Initialisation à faire une fois au début du programme // Initialisation à faire une fois au début du programme
void Initialisation_Texte(void) void Init_text(void)
{ {
char Nom_repertoire[TAILLE_CHEMIN_FICHIER]; char directory_name[MAX_PATH_CHARACTERS];
#ifndef NOTTF #ifndef NOTTF
// Initialisation de TTF // Initialisation de TTF
TTF_Init(); TTF_Init();
#endif #endif
// Initialisation des fontes // Initialisation des fontes
Liste_fontes_debut = NULL; Font_list_start = NULL;
Fonte_nombre=0; Nb_fonts=0;
// Parcours du répertoire "fonts" // Parcours du répertoire "fonts"
strcpy(Nom_repertoire, Repertoire_des_donnees); strcpy(directory_name, Repertoire_des_donnees);
strcat(Nom_repertoire, "fonts"); strcat(directory_name, "fonts");
for_each_file(Nom_repertoire, Ajout_fonte); For_each_file(directory_name, Add_font);
#ifdef __WIN32__ #ifdef __WIN32__
// Parcours du répertoire systeme windows "fonts" // Parcours du répertoire systeme windows "fonts"
@ -291,8 +291,8 @@ void Initialisation_Texte(void)
char * WindowsPath=getenv("windir"); char * WindowsPath=getenv("windir");
if (WindowsPath) if (WindowsPath)
{ {
sprintf(Nom_repertoire, "%s\\FONTS", WindowsPath); sprintf(directory_name, "%s\\FONTS", WindowsPath);
for_each_file(Nom_repertoire, Ajout_fonte); For_each_file(directory_name, Add_font);
} }
} }
#endif #endif
@ -315,7 +315,7 @@ void Initialisation_Texte(void)
font_path_list[2] = home_dir; font_path_list[2] = home_dir;
for(i=0;i<number;i++) for(i=0;i<number;i++)
for_each_file(*(font_path_list+i),Ajout_fonte); For_each_file(*(font_path_list+i),Add_font);
CFRelease(url); CFRelease(url);
#endif #endif
@ -332,7 +332,7 @@ void Initialisation_Texte(void)
XCloseDisplay(dpy); XCloseDisplay(dpy);
for(i=0;i<number;i++) for(i=0;i<number;i++)
for_each_file(*(font_path_list+i),Ajout_fonte); For_each_file(*(font_path_list+i),Add_font);
XFreeFontPath(font_path_list); XFreeFontPath(font_path_list);
} }
@ -340,23 +340,23 @@ void Initialisation_Texte(void)
#endif #endif
#elif defined(__amigaos4__) #elif defined(__amigaos4__)
#ifndef NOTTF #ifndef NOTTF
for_each_file( "FONTS:_TrueType", Ajout_fonte ); For_each_file( "FONTS:_TrueType", Add_font );
#endif #endif
#elif defined(__BEOS__) || defined(__HAIKU__) #elif defined(__BEOS__) || defined(__HAIKU__)
#ifndef NOTTF #ifndef NOTTF
for_each_file("/etc/fonts/ttfonts", Ajout_fonte); For_each_file("/etc/fonts/ttfonts", Add_font);
#endif #endif
#elif defined(__SKYOS__) #elif defined(__SKYOS__)
#ifndef NOTTF #ifndef NOTTF
for_each_file("/boot/system/fonts", Ajout_fonte); For_each_file("/boot/system/fonts", Add_font);
#endif #endif
#endif #endif
} }
// Informe si texte.c a été compilé avec l'option de support TrueType ou pas. // Informe si texte.c a été compilé avec l'option de support TrueType ou pas.
int Support_TrueType() int TrueType_is_supported()
{ {
#ifdef NOTTF #ifdef NOTTF
return 0; return 0;
@ -367,21 +367,21 @@ int Support_TrueType()
#ifndef NOTTF #ifndef NOTTF
byte *Rendu_Texte_TTF(const char *Chaine, int Numero_fonte, int size, int antialias, int bold, int italic, int *width, int *height) byte *Render_text_TTF(const char *str, int font_number, int size, int antialias, int bold, int italic, int *width, int *height)
{ {
TTF_Font *Fonte; TTF_Font *Font;
SDL_Surface * TexteColore; SDL_Surface * TexteColore;
SDL_Surface * Texte8Bit; SDL_Surface * Texte8Bit;
byte * BrosseRetour; byte * new_brush;
int Indice; int index;
int style; int style;
SDL_Color Couleur_Avant; SDL_Color Couleur_Avant;
SDL_Color Couleur_Arriere; SDL_Color Couleur_Arriere;
// Chargement de la fonte // Chargement de la fonte
Fonte=TTF_OpenFont(Nom_fonte(Numero_fonte), size); Font=TTF_OpenFont(Font_name(font_number), size);
if (!Fonte) if (!Font)
{ {
return NULL; return NULL;
} }
@ -391,28 +391,28 @@ byte *Rendu_Texte_TTF(const char *Chaine, int Numero_fonte, int size, int antial
style|=TTF_STYLE_ITALIC; style|=TTF_STYLE_ITALIC;
if (bold) if (bold)
style|=TTF_STYLE_BOLD; style|=TTF_STYLE_BOLD;
TTF_SetFontStyle(Fonte, style); TTF_SetFontStyle(Font, style);
// Couleurs // Couleurs
if (antialias) if (antialias)
{ {
Couleur_Avant = Conversion_couleur_SDL(Fore_color); Couleur_Avant = Color_to_SDL_color(Fore_color);
Couleur_Arriere = Conversion_couleur_SDL(Back_color); Couleur_Arriere = Color_to_SDL_color(Back_color);
} }
else else
{ {
Couleur_Avant = Conversion_couleur_SDL(CM_Blanc); Couleur_Avant = Color_to_SDL_color(MC_White);
Couleur_Arriere = Conversion_couleur_SDL(CM_Noir); Couleur_Arriere = Color_to_SDL_color(MC_Black);
} }
// Rendu du texte: crée une surface SDL RGB 24bits // Rendu du texte: crée une surface SDL RGB 24bits
if (antialias) if (antialias)
TexteColore=TTF_RenderText_Shaded(Fonte, Chaine, Couleur_Avant, Couleur_Arriere ); TexteColore=TTF_RenderText_Shaded(Font, str, Couleur_Avant, Couleur_Arriere );
else else
TexteColore=TTF_RenderText_Solid(Fonte, Chaine, Couleur_Avant); TexteColore=TTF_RenderText_Solid(Font, str, Couleur_Avant);
if (!TexteColore) if (!TexteColore)
{ {
TTF_CloseFont(Fonte); TTF_CloseFont(Font);
return NULL; return NULL;
} }
@ -420,108 +420,108 @@ byte *Rendu_Texte_TTF(const char *Chaine, int Numero_fonte, int size, int antial
SDL_FreeSurface(TexteColore); SDL_FreeSurface(TexteColore);
BrosseRetour=Surface_en_bytefield(Texte8Bit, NULL); new_brush=Surface_to_bytefield(Texte8Bit, NULL);
if (!BrosseRetour) if (!new_brush)
{ {
SDL_FreeSurface(TexteColore); SDL_FreeSurface(TexteColore);
SDL_FreeSurface(Texte8Bit); SDL_FreeSurface(Texte8Bit);
TTF_CloseFont(Fonte); TTF_CloseFont(Font);
return NULL; return NULL;
} }
if (!antialias) if (!antialias)
{ {
// Mappage des couleurs // Mappage des couleurs
for (Indice=0; Indice < Texte8Bit->w * Texte8Bit->h; Indice++) for (index=0; index < Texte8Bit->w * Texte8Bit->h; index++)
{ {
if (*(BrosseRetour+Indice) == CM_Noir) if (*(new_brush+index) == MC_Black)
*(BrosseRetour+Indice)=Back_color; *(new_brush+index)=Back_color;
else if (*(BrosseRetour+Indice) == CM_Blanc) else if (*(new_brush+index) == MC_White)
*(BrosseRetour+Indice)=Fore_color; *(new_brush+index)=Fore_color;
} }
} }
*width=Texte8Bit->w; *width=Texte8Bit->w;
*height=Texte8Bit->h; *height=Texte8Bit->h;
SDL_FreeSurface(Texte8Bit); SDL_FreeSurface(Texte8Bit);
TTF_CloseFont(Fonte); TTF_CloseFont(Font);
return BrosseRetour; return new_brush;
} }
#endif #endif
byte *Rendu_Texte_SFont(const char *Chaine, int Numero_fonte, int *width, int *height) byte *Render_text_SFont(const char *str, int font_number, int *width, int *height)
{ {
SFont_Font *Fonte; SFont_Font *Font;
SDL_Surface * TexteColore; SDL_Surface * TexteColore;
SDL_Surface * Texte8Bit; SDL_Surface * Texte8Bit;
SDL_Surface *Surface_fonte; SDL_Surface *Surface_fonte;
byte * BrosseRetour; byte * new_brush;
// Chargement de la fonte // Chargement de la fonte
Surface_fonte=IMG_Load(Nom_fonte(Numero_fonte)); Surface_fonte=IMG_Load(Font_name(font_number));
if (!Surface_fonte) if (!Surface_fonte)
return NULL; return NULL;
Fonte=SFont_InitFont(Surface_fonte); Font=SFont_InitFont(Surface_fonte);
if (!Fonte) if (!Font)
{ {
return NULL; return NULL;
} }
// Calcul des dimensions // Calcul des dimensions
*height=SFont_TextHeight(Fonte); *height=SFont_TextHeight(Font);
*width=SFont_TextWidth(Fonte, Chaine); *width=SFont_TextWidth(Font, str);
// Allocation d'une surface SDL // Allocation d'une surface SDL
TexteColore=SDL_CreateRGBSurface(SDL_SWSURFACE, *width, *height, 24, 0, 0, 0, 0); TexteColore=SDL_CreateRGBSurface(SDL_SWSURFACE, *width, *height, 24, 0, 0, 0, 0);
// Rendu du texte // Rendu du texte
SFont_Write(TexteColore, Fonte, 0, 0, Chaine); SFont_Write(TexteColore, Font, 0, 0, str);
if (!TexteColore) if (!TexteColore)
{ {
SFont_FreeFont(Fonte); SFont_FreeFont(Font);
return NULL; return NULL;
} }
Texte8Bit=SDL_DisplayFormat(TexteColore); Texte8Bit=SDL_DisplayFormat(TexteColore);
SDL_FreeSurface(TexteColore); SDL_FreeSurface(TexteColore);
BrosseRetour=Surface_en_bytefield(Texte8Bit, NULL); new_brush=Surface_to_bytefield(Texte8Bit, NULL);
if (!BrosseRetour) if (!new_brush)
{ {
SDL_FreeSurface(TexteColore); SDL_FreeSurface(TexteColore);
SDL_FreeSurface(Texte8Bit); SDL_FreeSurface(Texte8Bit);
SFont_FreeFont(Fonte); SFont_FreeFont(Font);
return NULL; return NULL;
} }
SDL_FreeSurface(Texte8Bit); SDL_FreeSurface(Texte8Bit);
SFont_FreeFont(Fonte); SFont_FreeFont(Font);
return BrosseRetour; return new_brush;
} }
// Crée une brosse à partir des paramètres de texte demandés. // Crée une brosse à partir des paramètres de texte demandés.
// Si cela réussit, la fonction place les dimensions dans width et height, // Si cela réussit, la fonction place les dimensions dans width et height,
// et retourne l'adresse du bloc d'octets. // et retourne l'adresse du bloc d'octets.
byte *Rendu_Texte(const char *Chaine, int Numero_fonte, int size, int antialias, int bold, int italic, int *width, int *height) byte *Render_text(const char *str, int font_number, int size, int antialias, int bold, int italic, int *width, int *height)
{ {
T_FONTE *Fonte = Liste_fontes_debut; T_Font *Font = Font_list_start;
int Indice=Numero_fonte; int index=font_number;
// Verification type de la fonte // Verification type de la fonte
if (Numero_fonte<0 ||Numero_fonte>=Fonte_nombre) if (font_number<0 ||font_number>=Nb_fonts)
return NULL; return NULL;
while (Indice--) while (index--)
Fonte = Fonte->Suivante; Font = Font->Next;
if (Fonte->EstTrueType) if (Font->Is_truetype)
{ {
#ifndef NOTTF #ifndef NOTTF
return Rendu_Texte_TTF(Chaine, Numero_fonte, size, antialias, bold, italic, width, height); return Render_text_TTF(str, font_number, size, antialias, bold, italic, width, height);
#else #else
return NULL; return NULL;
#endif #endif
} }
else else
{ {
return Rendu_Texte_SFont(Chaine, Numero_fonte, width, height); return Render_text_SFont(str, font_number, width, height);
} }
} }

16
texte.h
View File

@ -21,18 +21,18 @@
*/ */
// Initialisation à faire une fois au début du programme // Initialisation à faire une fois au début du programme
void Initialisation_Texte(void); void Init_text(void);
// Informe si texte.c a été compilé avec l'option de support TrueType ou pas. // Informe si texte.c a été compilé avec l'option de support TrueType ou pas.
int Support_TrueType(void); int TrueType_is_supported(void);
// Ajout d'une fonte à la liste. // Ajout d'une fonte à la liste.
void Ajout_fonte(char *name); void Add_font(char *name);
// Crée une brosse à partir des paramètres de texte demandés. // Crée une brosse à partir des paramètres de texte demandés.
byte *Rendu_Texte(const char *Chaine, int Numero_fonte, int size, int antialias, int bold, int italic, int *width, int *height); byte *Render_text(const char *str, int font_number, int size, int antialias, int bold, int italic, int *width, int *height);
// Trouve le libellé d'affichage d'une fonte par son numéro // Trouve le libellé d'affichage d'une fonte par son numéro
char * Libelle_fonte(int Indice); char * Font_label(int index);
// Trouve le nom d'une fonte par son numéro // Trouve le nom d'une fonte par son numéro
char * Nom_fonte(int Indice); char * Font_name(int index);
// Vérifie si une fonte donnée est TrueType // Vérifie si une fonte donnée est TrueType
char * TrueType_fonte(int Indice); char * TrueType_font(int index);
// Nombre de fontes déclarées // Nombre de fontes déclarées
extern int Fonte_nombre; extern int Nb_fonts;

View File

@ -1505,7 +1505,7 @@ Color_map_entry_size
Color_map_length Color_map_length
Color_map_origin Color_map_origin
Color_map_type Color_map_type
Commentaire Comment
initial_comment initial_comment
Comp Comp
compare compare

Binary file not shown.

2380
windows.c

File diff suppressed because it is too large Load Diff

106
windows.h
View File

@ -24,71 +24,71 @@
#include "struct.h" #include "struct.h"
#define ToWinX(x) (((x)*Menu_Facteur_X)+Fenetre_Pos_X) #define ToWinX(x) (((x)*Menu_factor_X)+Window_pos_X)
#define ToWinY(y) (((y)*Menu_Facteur_Y)+Fenetre_Pos_Y) #define ToWinY(y) (((y)*Menu_factor_Y)+Window_pos_Y)
#define ToWinL(l) ((l)*Menu_Facteur_X) #define ToWinL(l) ((l)*Menu_factor_X)
#define ToWinH(h) ((h)*Menu_Facteur_Y) #define ToWinH(h) ((h)*Menu_factor_Y)
#define Display_Window(x,y,w,h) UpdateRect(Fenetre_Pos_X+(x)*Menu_Facteur_X,Fenetre_Pos_Y+(y)*Menu_Facteur_Y,(w)*Menu_Facteur_X,(h)*Menu_Facteur_Y); #define Update_window_area(x,y,w,h) Update_rect(Window_pos_X+(x)*Menu_factor_X,Window_pos_Y+(y)*Menu_factor_Y,(w)*Menu_factor_X,(h)*Menu_factor_Y);
void Afficher_curseur(void); void Display_cursor(void);
void Effacer_curseur(void); void Hide_cursor(void);
void Remapper_ecran_apres_changement_couleurs_menu(void); void Remap_screen_after_menu_colors_change(void);
void Calculer_couleurs_menu_optimales(Composantes * palette); void Compute_optimal_menu_colors(T_Components * palette);
void Recadrer_ecran_par_rapport_au_zoom(void); void Position_screen_according_to_zoom(void);
void Calculer_split(void); void Compute_separator_data(void);
void Calculer_donnees_loupe(void); void Compute_magnifier_data(void);
void Calculer_limites(void); void Compute_limits(void);
void Calculer_coordonnees_pinceau(void); void Compute_paintbrush_coordinates(void);
void Pixel_dans_barre_d_outil(word x,word y,byte Couleur); void Pixel_in_toolbar(word x,word y,byte color);
void Pixel_dans_fenetre(word x,word y,byte Couleur); void Pixel_in_window(word x,word y,byte color);
void Encadrer_couleur_menu(byte Couleur); void Frame_menu_color(byte color);
void Afficher_palette_du_menu(void); void Display_menu_palette(void);
void Afficher_menu(void); void Display_menu(void);
void Recadrer_palette(void); void Reposition_palette(void);
void Changer_cellules_palette(void); void Change_palette_cells(void);
int Couleur_palette(void); int Pick_color_in_palette(void);
word Palette_Cells_X(void); word Palette_cells_X(void);
word Palette_Cells_Y(void); word Palette_cells_Y(void);
void Print_general(short x,short y,const char * Chaine,byte Couleur_texte,byte Couleur_fond); void Print_general(short x,short y,const char * str,byte text_color,byte background_color);
void Print_dans_fenetre(short x,short y,const char * Chaine,byte Couleur_texte,byte Couleur_fond); void Print_in_window(short x,short y,const char * str,byte text_color,byte background_color);
void Print_dans_fenetre_limite(short x,short y,const char * Chaine,byte size,byte Couleur_texte,byte Couleur_fond); void Print_in_window_limited(short x,short y,const char * str,byte size,byte text_color,byte background_color);
void Print_char_dans_fenetre(short x_pos,short y_pos,const unsigned char c,byte Couleur_texte,byte Couleur_fond); void Print_char_in_window(short x_pos,short y_pos,const unsigned char c,byte text_color,byte background_color);
void Print_char_transparent_dans_fenetre(short x_pos,short y_pos,const unsigned char c,byte Couleur); void Print_transparent_char_in_window(short x_pos,short y_pos,const unsigned char c,byte color);
void Print_dans_menu(const char * Chaine, short position); void Print_in_menu(const char * str, short position);
void Print_coordonnees(void); void Print_coordinates(void);
void Print_nom_fichier(void); void Print_filename(void);
void Print_compteur(short x,short y,const char * Chaine,byte Couleur_texte,byte Couleur_fond); void Print_counter(short x,short y,const char * str,byte text_color,byte background_color);
byte Demande_de_confirmation(char * Message); byte Confirmation_box(char * message);
void Warning_message(char * Message); void Warning_message(char * message);
void Afficher_limites_de_l_image(void); void Display_image_limits(void);
void Afficher_ecran(void); void Display_all_screen(void);
void Window_rectangle(word x_pos,word y_pos,word width,word height,byte color); void Window_rectangle(word x_pos,word y_pos,word width,word height,byte color);
void Fenetre_Afficher_cadre_general(word x_pos,word y_pos,word width,word height, void Window_display_frame_generic(word x_pos,word y_pos,word width,word height,
byte Couleur_HG,byte Couleur_BD,byte Couleur_S,byte Couleur_CHG,byte Couleur_CBD); byte color_tl,byte color_br,byte color_s,byte color_tlc,byte color_brc);
void Fenetre_Afficher_cadre_mono(word x_pos,word y_pos,word width,word height,byte Couleur); void Window_display_frame_mono(word x_pos,word y_pos,word width,word height,byte color);
void Fenetre_Afficher_cadre_creux(word x_pos,word y_pos,word width,word height); void Window_display_frame_in(word x_pos,word y_pos,word width,word height);
void Fenetre_Afficher_cadre_bombe(word x_pos,word y_pos,word width,word height); void Window_display_frame_out(word x_pos,word y_pos,word width,word height);
void Fenetre_Afficher_cadre(word x_pos,word y_pos,word width,word height); void Window_display_frame(word x_pos,word y_pos,word width,word height);
void Afficher_sprite_dans_menu(int Numero_bouton,int Numero_sprite); void Display_sprite_in_menu(int btn_number,int sprite_number);
void Afficher_pinceau_dans_menu(void); void Display_paintbrush_in_menu(void);
void Afficher_pinceau_dans_fenetre(word x,word y,int number); void Display_paintbrush_in_window(word x,word y,int number);
void Dessiner_zigouigoui(word x,word y, byte Couleur, short direction); void Draw_thingumajig(word x,word y, byte color, short direction);
void Bloc_degrade_dans_fenetre(word x_pos,word y_pos,word Debut_block,word Fin_block); void Display_grad_block_in_window(word x_pos,word y_pos,word block_start,word block_end);
void Fenetre_Afficher_sprite_drive(word x_pos,word y_pos,byte type); void Window_display_icon_sprite(word x_pos,word y_pos,byte type);
byte Meilleure_couleur(byte Rouge,byte Vert,byte Bleu); byte Best_color(byte red,byte green,byte blue);
byte Meilleure_couleur_sans_exclusion(byte Rouge,byte Vert,byte Bleu); byte Best_color_nonexcluded(byte red,byte green,byte blue);
void Ligne_horizontale_XOR_Zoom(short x_pos, short y_pos, short width); void Horizontal_XOR_line_zoom(short x_pos, short y_pos, short width);
void Ligne_verticale_XOR_Zoom(short x_pos, short y_pos, short height); void Vertical_XOR_line_zoom(short x_pos, short y_pos, short height);
#endif #endif