Fixed the memory corruption that happened only in 320x200 mode
(ie: after loading a small picture) Windows taller than the screen are not supported, and there's no safety. git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@178 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
parent
6cafa8a7d4
commit
58b553b511
24
boutons.c
24
boutons.c
@ -30,7 +30,7 @@
|
||||
#define rmdir(x) DeleteFile(x)
|
||||
#endif
|
||||
|
||||
#define FILENAMESPACE 16
|
||||
#define FILENAMESPACE 13
|
||||
|
||||
//-- MODELE DE BOUTON DE MENU ------------------------------------------------
|
||||
/*
|
||||
@ -2312,17 +2312,17 @@ byte Bouton_Load_ou_Save(byte Load, byte Image)
|
||||
if (Load)
|
||||
{
|
||||
if (Image)
|
||||
Ouvrir_fenetre(310,190+FILENAMESPACE,"Load picture");
|
||||
Ouvrir_fenetre(310,187+FILENAMESPACE,"Load picture");
|
||||
else
|
||||
Ouvrir_fenetre(310,190+FILENAMESPACE,"Load brush");
|
||||
Ouvrir_fenetre(310,187+FILENAMESPACE,"Load brush");
|
||||
Fenetre_Definir_bouton_normal(125,157+FILENAMESPACE,51,14,"Load",0,1,SDLK_RETURN); // 1
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Image)
|
||||
Ouvrir_fenetre(310,190+FILENAMESPACE,"Save picture");
|
||||
Ouvrir_fenetre(310,187+FILENAMESPACE,"Save picture");
|
||||
else
|
||||
Ouvrir_fenetre(310,190+FILENAMESPACE,"Save brush");
|
||||
Ouvrir_fenetre(310,187+FILENAMESPACE,"Save brush");
|
||||
Fenetre_Definir_bouton_normal(125,157+FILENAMESPACE,51,14,"Save",0,1,SDLK_RETURN); // 1
|
||||
if (Principal_Format==0) // Correction du *.*
|
||||
{
|
||||
@ -2339,7 +2339,7 @@ byte Bouton_Load_ou_Save(byte Load, byte Image)
|
||||
}
|
||||
// Affichage du commentaire
|
||||
if (Format_Commentaire[Principal_Format-1])
|
||||
Print_dans_fenetre(46,176+FILENAMESPACE,Principal_Commentaire,CM_Noir,CM_Clair);
|
||||
Print_dans_fenetre(46,175+FILENAMESPACE,Principal_Commentaire,CM_Noir,CM_Clair);
|
||||
}
|
||||
|
||||
Fenetre_Definir_bouton_normal(125,139+FILENAMESPACE,51,14,"Cancel",0,1,SDLK_ESCAPE); // 2
|
||||
@ -2364,8 +2364,8 @@ byte Bouton_Load_ou_Save(byte Load, byte Image)
|
||||
Fenetre_Definir_bouton_scroller(12,55,27,(Load)?NB_FORMATS_LOAD+1:NB_FORMATS_SAVE,1,(Load)?Principal_Format:Principal_Format-1); // 6
|
||||
|
||||
// Texte de commentaire des dessins
|
||||
Print_dans_fenetre(7,176+FILENAMESPACE,"Txt:",CM_Fonce,CM_Clair);
|
||||
Fenetre_Definir_bouton_saisie(44,174+FILENAMESPACE,TAILLE_COMMENTAIRE); // 7
|
||||
Print_dans_fenetre(7,174+FILENAMESPACE,"Txt:",CM_Fonce,CM_Clair);
|
||||
Fenetre_Definir_bouton_saisie(44,173+FILENAMESPACE,TAILLE_COMMENTAIRE); // 7
|
||||
|
||||
// Cadre autour du nom de fichier
|
||||
//Fenetre_Afficher_cadre_creux( 7,87,296,15);
|
||||
@ -2580,7 +2580,7 @@ byte Bouton_Load_ou_Save(byte Load, byte Image)
|
||||
if ( (!Load) && (Format_Commentaire[Principal_Format-1]) )
|
||||
{
|
||||
Effacer_curseur();
|
||||
Readline(46,176+FILENAMESPACE,Principal_Commentaire,32,0);
|
||||
Readline(46,175+FILENAMESPACE,Principal_Commentaire,32,0);
|
||||
Afficher_curseur();
|
||||
}
|
||||
break;
|
||||
@ -2753,9 +2753,9 @@ byte Bouton_Load_ou_Save(byte Load, byte Image)
|
||||
{
|
||||
Effacer_curseur();
|
||||
// On efface le commentaire précédent
|
||||
Block(Fenetre_Pos_X+ 46*Menu_Facteur_X,Fenetre_Pos_Y+(176+FILENAMESPACE)*Menu_Facteur_Y,
|
||||
Block(Fenetre_Pos_X+ 46*Menu_Facteur_X,Fenetre_Pos_Y+(175+FILENAMESPACE)*Menu_Facteur_Y,
|
||||
Menu_Facteur_X<<8,Menu_Facteur_Y<<3,CM_Clair);
|
||||
// On néttoie la zone où va s'afficher la preview:
|
||||
// On nettoie la zone où va s'afficher la preview:
|
||||
Block(Fenetre_Pos_X+180*Menu_Facteur_X,Fenetre_Pos_Y+ (89+FILENAMESPACE)*Menu_Facteur_Y,
|
||||
Menu_Facteur_X*122,Menu_Facteur_Y*82,CM_Clair);
|
||||
// On efface les dimensions de l'image
|
||||
@ -2769,7 +2769,7 @@ byte Bouton_Load_ou_Save(byte Load, byte Image)
|
||||
Menu_Facteur_X*72,Menu_Facteur_Y<<3,CM_Clair);
|
||||
// Affichage du commentaire
|
||||
if ( (!Load) && (Format_Commentaire[Principal_Format-1]) )
|
||||
Print_dans_fenetre(46,176+FILENAMESPACE,Principal_Commentaire,CM_Noir,CM_Clair);
|
||||
Print_dans_fenetre(46,175+FILENAMESPACE,Principal_Commentaire,CM_Noir,CM_Clair);
|
||||
Afficher_curseur();
|
||||
|
||||
SDL_UpdateRect(Ecran_SDL,Fenetre_Pos_X+27*Menu_Facteur_X,Fenetre_Pos_Y+(55+FILENAMESPACE)*Menu_Facteur_Y,Menu_Facteur_X<<9,Menu_Facteur_Y<<4);
|
||||
|
||||
2
files.c
2
files.c
@ -35,7 +35,7 @@
|
||||
#define COULEUR_REPERTOIRE_SELECT CM_Clair // Couleur du texte pour une ligne de repértoire sélectionnée
|
||||
#define COULEUR_FOND_SELECT CM_Fonce // Couleur du fond pour une ligne sélectionnée
|
||||
|
||||
#define FILENAMESPACE 16
|
||||
#define FILENAMESPACE 13
|
||||
|
||||
int Determiner_repertoire_courant(void)
|
||||
// Modifie Principal_Repertoire_courant en y mettant sa nouvelle valeur (avec le nom du
|
||||
|
||||
59
loadsave.c
59
loadsave.c
@ -20,7 +20,7 @@
|
||||
#include "linux.h"
|
||||
#include "io.h"
|
||||
|
||||
#define FILENAMESPACE 16
|
||||
#define FILENAMESPACE 13
|
||||
|
||||
// Chargement des pixels dans l'écran principal
|
||||
void Pixel_Chargement_dans_ecran_courant(word Pos_X,word Pos_Y,byte Couleur)
|
||||
@ -226,11 +226,11 @@ void Initialiser_preview(short Largeur,short Hauteur,long Taille,int Format)
|
||||
}
|
||||
|
||||
// On efface le commentaire précédent
|
||||
Block(Fenetre_Pos_X+46*Menu_Facteur_X,Fenetre_Pos_Y+(176+FILENAMESPACE)*Menu_Facteur_Y,
|
||||
Block(Fenetre_Pos_X+46*Menu_Facteur_X,Fenetre_Pos_Y+(175+FILENAMESPACE)*Menu_Facteur_Y,
|
||||
Menu_Facteur_X<<8,Menu_Facteur_Y<<3,CM_Clair);
|
||||
// Affichage du commentaire
|
||||
if (Format_Commentaire[Format-1])
|
||||
Print_dans_fenetre(46,176+FILENAMESPACE,Principal_Commentaire,CM_Noir,CM_Clair);
|
||||
Print_dans_fenetre(46,175+FILENAMESPACE,Principal_Commentaire,CM_Noir,CM_Clair);
|
||||
|
||||
// Calculs des données nécessaires à l'affichage de la preview:
|
||||
Preview_Facteur_X=Round_div_max(Largeur,122*Menu_Facteur_X);
|
||||
@ -739,7 +739,7 @@ void Load_IMG(void)
|
||||
long Largeur_lue;
|
||||
long Taille_du_fichier;
|
||||
T_Header_IMG IMG_Header;
|
||||
struct stat* Informations_Fichier=NULL;
|
||||
struct stat Informations_Fichier;
|
||||
|
||||
|
||||
Nom_fichier_complet(Nom_du_fichier,0);
|
||||
@ -748,8 +748,8 @@ void Load_IMG(void)
|
||||
|
||||
if ((Fichier=fopen(Nom_du_fichier, "rb")))
|
||||
{
|
||||
stat(Nom_du_fichier,Informations_Fichier);
|
||||
Taille_du_fichier=Informations_Fichier->st_size;
|
||||
stat(Nom_du_fichier,&Informations_Fichier);
|
||||
Taille_du_fichier=Informations_Fichier.st_size;
|
||||
|
||||
if (read_bytes(Fichier,&IMG_Header,sizeof(T_Header_IMG)))
|
||||
{
|
||||
@ -1907,7 +1907,7 @@ void Save_LBM(void)
|
||||
word Pos_Y;
|
||||
byte Octet;
|
||||
word Vraie_largeur;
|
||||
struct stat* Informations_Fichier=NULL;
|
||||
struct stat Informations_Fichier;
|
||||
|
||||
|
||||
Erreur_fichier=0;
|
||||
@ -1926,11 +1926,8 @@ void Save_LBM(void)
|
||||
Vraie_largeur=Principal_Largeur_image+(Principal_Largeur_image&1);
|
||||
|
||||
//swab((byte *)&Vraie_largeur,(byte *)&Header.Width,2);
|
||||
swab((byte *)&Principal_Largeur_image,(byte *)&Header.Width,2);
|
||||
swab((byte *)&Principal_Hauteur_image,(byte *)&Header.Height,2);
|
||||
//Header.Width=Principal_Largeur_image;
|
||||
//Header.Height=Principal_Hauteur_image;
|
||||
|
||||
Header.Width=Principal_Largeur_image;
|
||||
Header.Height=Principal_Hauteur_image;
|
||||
Header.Xorg=0;
|
||||
Header.Yorg=0;
|
||||
Header.BitPlanes=8;
|
||||
@ -1940,12 +1937,22 @@ void Save_LBM(void)
|
||||
Header.Transp_col=Back_color;
|
||||
Header.Xaspect=1;
|
||||
Header.Yaspect=1;
|
||||
swab((byte *)&Largeur_ecran,(byte *)&Header.Xscreen,2);
|
||||
swab((byte *)&Hauteur_ecran,(byte *)&Header.Yscreen,2);
|
||||
//Header.Xscreen = Largeur_ecran;
|
||||
//Header.Yscreen = Hauteur_ecran;
|
||||
Header.Xscreen = Largeur_ecran;
|
||||
Header.Yscreen = Hauteur_ecran;
|
||||
|
||||
write_bytes(LBM_Fichier,&Header,sizeof(T_Header_LBM));
|
||||
write_word_be(LBM_Fichier,Header.Width);
|
||||
write_word_be(LBM_Fichier,Header.Height);
|
||||
write_word_be(LBM_Fichier,Header.Xorg);
|
||||
write_word_be(LBM_Fichier,Header.Yorg);
|
||||
write_bytes(LBM_Fichier,&Header.BitPlanes,1);
|
||||
write_bytes(LBM_Fichier,&Header.Mask,1);
|
||||
write_bytes(LBM_Fichier,&Header.Compression,1);
|
||||
write_bytes(LBM_Fichier,&Header.Pad1,1);
|
||||
write_word_be(LBM_Fichier,Header.Transp_col);
|
||||
write_bytes(LBM_Fichier,&Header.Xaspect,1);
|
||||
write_bytes(LBM_Fichier,&Header.Yaspect,1);
|
||||
write_word_be(LBM_Fichier,Header.Xscreen);
|
||||
write_word_be(LBM_Fichier,Header.Yscreen);
|
||||
|
||||
write_bytes(LBM_Fichier,"CMAP",4);
|
||||
write_dword_be(LBM_Fichier,sizeof(T_Palette));
|
||||
@ -1975,11 +1982,11 @@ void Save_LBM(void)
|
||||
|
||||
if (!Erreur_fichier)
|
||||
{
|
||||
LBM_Fichier=fopen(Nom_du_fichier,"rb+");
|
||||
stat(Nom_du_fichier,&Informations_Fichier);
|
||||
|
||||
LBM_Fichier=fopen(Nom_du_fichier,"rb+");
|
||||
fseek(LBM_Fichier,820,SEEK_SET);
|
||||
stat(Nom_du_fichier,Informations_Fichier);
|
||||
write_dword_be(LBM_Fichier,Informations_Fichier->st_size-824);
|
||||
write_dword_be(LBM_Fichier,Informations_Fichier.st_size-824);
|
||||
|
||||
if (!Erreur_fichier)
|
||||
{
|
||||
@ -1987,16 +1994,16 @@ void Save_LBM(void)
|
||||
|
||||
// Si la taille de la section de l'image (taille fichier-8) est
|
||||
// impaire, on rajoute un 0 (Padding) à la fin.
|
||||
if ((Informations_Fichier->st_size) & 1)
|
||||
if ((Informations_Fichier.st_size) & 1)
|
||||
{
|
||||
write_dword_be(LBM_Fichier,Informations_Fichier->st_size-7);
|
||||
write_dword_be(LBM_Fichier,Informations_Fichier.st_size-7);
|
||||
fseek(LBM_Fichier,0,SEEK_END);
|
||||
Octet=0;
|
||||
if (! write_bytes(LBM_Fichier,&Octet,1))
|
||||
Erreur_fichier=1;
|
||||
}
|
||||
else
|
||||
write_dword_be(LBM_Fichier,Informations_Fichier->st_size-8);
|
||||
write_dword_be(LBM_Fichier,Informations_Fichier.st_size-8);
|
||||
|
||||
fclose(LBM_Fichier);
|
||||
|
||||
@ -3894,7 +3901,7 @@ void Load_CEL(void)
|
||||
short Pos_Y;
|
||||
byte Dernier_octet=0;
|
||||
long Taille_du_fichier;
|
||||
struct stat* Informations_Fichier=NULL;
|
||||
struct stat Informations_Fichier;
|
||||
|
||||
|
||||
Erreur_fichier=0;
|
||||
@ -3903,8 +3910,8 @@ void Load_CEL(void)
|
||||
{
|
||||
if (read_bytes(Fichier,&Header1,sizeof(T_CEL_Header1)))
|
||||
{
|
||||
stat(Nom_du_fichier,Informations_Fichier);
|
||||
Taille_du_fichier=Informations_Fichier->st_size;
|
||||
stat(Nom_du_fichier,&Informations_Fichier);
|
||||
Taille_du_fichier=Informations_Fichier.st_size;
|
||||
if ( (Taille_du_fichier>sizeof(T_CEL_Header1))
|
||||
&& ( (((Header1.Width+1)>>1)*Header1.Height)==(Taille_du_fichier-sizeof(T_CEL_Header1)) ) )
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user