Endianness and structure alignment fixes. Main loop running. Letsstart implementing SDL video :)
git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@20 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
		
							parent
							
								
									5dada6fc69
								
							
						
					
					
						commit
						49e7f9739d
					
				
							
								
								
									
										39
									
								
								init.c
									
									
									
									
									
								
							
							
						
						
									
										39
									
								
								init.c
									
									
									
									
									
								
							@ -21,6 +21,8 @@
 | 
			
		||||
#include "divers.h"
 | 
			
		||||
 | 
			
		||||
#include "errno.h"
 | 
			
		||||
#include <endian.h>
 | 
			
		||||
#include <byteswap.h>
 | 
			
		||||
 | 
			
		||||
//  On déclare méchamment le prototype de Erreur pour éviter de faire un
 | 
			
		||||
// fichier "main.h":
 | 
			
		||||
@ -227,7 +229,7 @@ void Decrypte(byte * Donnee,int Taille)
 | 
			
		||||
void Charger_DAT(void)
 | 
			
		||||
{
 | 
			
		||||
  int  Handle;
 | 
			
		||||
  long Taille_fichier;
 | 
			
		||||
  int  Taille_fichier;
 | 
			
		||||
  int  Indice;
 | 
			
		||||
  char Nom_du_fichier[256];
 | 
			
		||||
  byte * Fonte_temporaire;
 | 
			
		||||
@ -343,6 +345,10 @@ void Charger_DAT(void)
 | 
			
		||||
    if (read(Handle,&Mot_temporaire,2)!=2)
 | 
			
		||||
      Erreur(ERREUR_DAT_CORROMPU);
 | 
			
		||||
 | 
			
		||||
#ifdef __BIG_ENDIAN
 | 
			
		||||
	Mot_temporaire=bswap_16(Mot_temporaire);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    // On copie ce nombre de lignes dans la table:
 | 
			
		||||
    Table_d_aide[Indice].Nombre_de_lignes=Mot_temporaire;
 | 
			
		||||
 | 
			
		||||
@ -350,6 +356,10 @@ void Charger_DAT(void)
 | 
			
		||||
    if (read(Handle,&Mot_temporaire,2)!=2)
 | 
			
		||||
      Erreur(ERREUR_DAT_CORROMPU);
 | 
			
		||||
 | 
			
		||||
#ifdef __BIG_ENDIAN
 | 
			
		||||
	Mot_temporaire=bswap_16(Mot_temporaire);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    // On alloue la mémoire correspondante:
 | 
			
		||||
    if (!(Table_d_aide[Indice].Debut_de_la_liste=(byte *)malloc(Mot_temporaire)))
 | 
			
		||||
      Erreur(ERREUR_MEMOIRE);
 | 
			
		||||
@ -1782,9 +1792,12 @@ int Charger_CFG(int Tout_charger)
 | 
			
		||||
    goto Erreur_lecture_config;
 | 
			
		||||
  
 | 
			
		||||
  // - Lecture des infos contenues dans le fichier de config -
 | 
			
		||||
  while (read(Handle,&Chunk,sizeof(Chunk))==sizeof(Chunk))
 | 
			
		||||
  while (read(Handle,&(Chunk.Numero),sizeof(byte))==sizeof(byte))
 | 
			
		||||
  {
 | 
			
		||||
	  printf("CHUNK: %d %d \n",Chunk.Numero,Chunk.Taille);
 | 
			
		||||
		read(Handle,&(Chunk.Taille),sizeof(word));
 | 
			
		||||
		#ifdef __BIG_ENDIAN
 | 
			
		||||
			Chunk.Taille=bswap_16(Chunk.Taille);
 | 
			
		||||
		#endif
 | 
			
		||||
    switch (Chunk.Numero)
 | 
			
		||||
    {
 | 
			
		||||
      case CHUNK_TOUCHES: // Touches
 | 
			
		||||
@ -1798,6 +1811,11 @@ int Charger_CFG(int Tout_charger)
 | 
			
		||||
              goto Erreur_lecture_config;
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
							#ifdef __BIG_ENDIAN
 | 
			
		||||
								CFG_Infos_touche.Touche=bswap_16(CFG_Infos_touche.Touche);
 | 
			
		||||
								CFG_Infos_touche.Touche2=bswap_16(CFG_Infos_touche.Touche2);
 | 
			
		||||
								CFG_Infos_touche.Numero=bswap_16(CFG_Infos_touche.Numero);
 | 
			
		||||
							#endif
 | 
			
		||||
              for (Indice2=0;
 | 
			
		||||
                   ((Indice2<NB_TOUCHES) && (Numero_option[Indice2]!=CFG_Infos_touche.Numero));
 | 
			
		||||
                   Indice2++);
 | 
			
		||||
@ -1822,11 +1840,13 @@ int Charger_CFG(int Tout_charger)
 | 
			
		||||
        }
 | 
			
		||||
        break;
 | 
			
		||||
      case CHUNK_MODES_VIDEO: // Modes vidéo
 | 
			
		||||
        if ((Chunk.Taille/sizeof(CFG_Mode_video))!=NB_MODES_VIDEO)
 | 
			
		||||
        if ((Chunk.Taille/5/*sizeof(CFG_Mode_video)*/)!=NB_MODES_VIDEO)
 | 
			
		||||
          goto Erreur_lecture_config;
 | 
			
		||||
        for (Indice=1; Indice<=NB_MODES_VIDEO; Indice++)
 | 
			
		||||
        {
 | 
			
		||||
          if (read(Handle,&CFG_Mode_video,sizeof(CFG_Mode_video))!=sizeof(CFG_Mode_video))
 | 
			
		||||
					read(Handle,&(CFG_Mode_video.Etat),1);
 | 
			
		||||
					read(Handle,&(CFG_Mode_video.Largeur),2);
 | 
			
		||||
          if (read(Handle,&(CFG_Mode_video.Hauteur),2)!=2)
 | 
			
		||||
            goto Erreur_lecture_config;
 | 
			
		||||
          else
 | 
			
		||||
          {
 | 
			
		||||
@ -1892,8 +1912,15 @@ int Charger_CFG(int Tout_charger)
 | 
			
		||||
        {
 | 
			
		||||
          if (read(Handle,&Degrade_Courant,1)!=1)
 | 
			
		||||
            goto Erreur_lecture_config;
 | 
			
		||||
          if (read(Handle,Degrade_Tableau,sizeof(Degrade_Tableau))!=sizeof(Degrade_Tableau))
 | 
			
		||||
					for(Indice=0;Indice<16;Indice++)
 | 
			
		||||
					{
 | 
			
		||||
						read(Handle,&(Degrade_Tableau[Indice].Debut),1);
 | 
			
		||||
						read(Handle,&(Degrade_Tableau[Indice].Fin),1);
 | 
			
		||||
						read(Handle,&(Degrade_Tableau[Indice].Inverse),4);
 | 
			
		||||
						read(Handle,&(Degrade_Tableau[Indice].Melange),4);
 | 
			
		||||
          	if (read(Handle,&(Degrade_Tableau[Indice]).Technique,4)!=4)
 | 
			
		||||
            	goto Erreur_lecture_config;
 | 
			
		||||
					}
 | 
			
		||||
          Degrade_Charger_infos_du_tableau(Degrade_Courant);
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										9
									
								
								main.c
									
									
									
									
									
								
							
							
						
						
									
										9
									
								
								main.c
									
									
									
									
									
								
							@ -249,7 +249,7 @@ void Initialisation_du_programme(int argc,char * argv[])
 | 
			
		||||
  int Mode_dans_lequel_on_demarre;
 | 
			
		||||
 | 
			
		||||
  // On commence également par interdire d'appuyer sur Ctrl+Pause et Ctrl+C
 | 
			
		||||
  signal(SIGINT  ,SIG_IGN);
 | 
			
		||||
  // signal(SIGINT  ,SIG_IGN);
 | 
			
		||||
 | 
			
		||||
  printf("°±²Û GrafX 2.00 %s%s þ Copyright (c)1996-1999 Sunset Design Û²±°\n",ALPHA_BETA,POURCENTAGE_VERSION);
 | 
			
		||||
 | 
			
		||||
@ -303,7 +303,7 @@ void Initialisation_du_programme(int argc,char * argv[])
 | 
			
		||||
  Brosse_File_list_Decalage=0;
 | 
			
		||||
  Brosse_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';
 | 
			
		||||
  Brouillon_Commentaire[0]='\0';
 | 
			
		||||
  Brosse_Commentaire[0]='\0';
 | 
			
		||||
@ -415,8 +415,7 @@ void Initialisation_du_programme(int argc,char * argv[])
 | 
			
		||||
  srand(time(NULL)); // On randomize un peu tout ça...
 | 
			
		||||
	
 | 
			
		||||
  // Passer en clavier américain
 | 
			
		||||
  //Clavier_americain();
 | 
			
		||||
  //TODO: Voir à quoi ça sert vraiement ...
 | 
			
		||||
  Clavier_americain();
 | 
			
		||||
 | 
			
		||||
  // Initialisation des boutons
 | 
			
		||||
  Initialisation_des_boutons();
 | 
			
		||||
@ -475,7 +474,7 @@ void Initialisation_du_programme(int argc,char * argv[])
 | 
			
		||||
  Pinceau_Hauteur=1;
 | 
			
		||||
 | 
			
		||||
  // Détection des modes SDL en état de fonctionner:
 | 
			
		||||
  Liste_Modes_Videos_SDL= SDL_ListModes(NULL, 0);
 | 
			
		||||
  // Liste_Modes_Videos_SDL= SDL_ListModes(NULL, 0);
 | 
			
		||||
 | 
			
		||||
//Ici, trier les modes dispos ou pas dans le tableau global ...
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -346,7 +346,7 @@ int Charger_INI(struct S_Config * Conf)
 | 
			
		||||
 | 
			
		||||
  // On calcule le nom du fichier qu'on manipule:
 | 
			
		||||
  strcpy(Nom_du_fichier,Repertoire_du_programme);
 | 
			
		||||
  strcat(Nom_du_fichier,"GFX2.INI");
 | 
			
		||||
  strcat(Nom_du_fichier,"gfx2.ini");
 | 
			
		||||
 | 
			
		||||
  Fichier=fopen(Nom_du_fichier,"r");
 | 
			
		||||
  if (Fichier!=0)
 | 
			
		||||
 | 
			
		||||
@ -268,10 +268,10 @@ int Sauver_INI(struct S_Config * Conf)
 | 
			
		||||
 | 
			
		||||
  // On calcule les noms des fichiers qu'on manipule:
 | 
			
		||||
  strcpy(Nom_du_fichier,Repertoire_du_programme);
 | 
			
		||||
  strcat(Nom_du_fichier,"GFX2.INI");
 | 
			
		||||
  strcat(Nom_du_fichier,"gfx2.ini");
 | 
			
		||||
 | 
			
		||||
  strcpy(Nom_du_fichier_temporaire,Repertoire_du_programme);
 | 
			
		||||
  strcat(Nom_du_fichier_temporaire,"GFX2.$$$");
 | 
			
		||||
  strcat(Nom_du_fichier_temporaire,"gfx2.$$$");
 | 
			
		||||
 | 
			
		||||
  // On renome l'ancienne version du fichier INI vers un fichier temporaire:
 | 
			
		||||
  if (rename(Nom_du_fichier,Nom_du_fichier_temporaire)!=0)
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										6
									
								
								struct.h
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								struct.h
									
									
									
									
									
								
							@ -114,9 +114,9 @@ struct T_Degrade_Tableau
 | 
			
		||||
{
 | 
			
		||||
  byte Debut;     // PremiŠre couleur du dégradé
 | 
			
		||||
  byte Fin;       // DerniŠre couleur du dégradé
 | 
			
		||||
  int  Inverse;   // "Le dégradé va de Fin … Debut"
 | 
			
		||||
  long Melange;   // Valeur de mélange du dégradé (0-255)
 | 
			
		||||
  int  Technique; // Technique … utiliser (0-2)
 | 
			
		||||
  dword Inverse;   // "Le dégradé va de Fin … Debut" //INT
 | 
			
		||||
  dword Melange;   // Valeur de mélange du dégradé (0-255) //LONG
 | 
			
		||||
  dword Technique; // Technique … utiliser (0-2) //INT
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
// Déclaration d'une info de shade
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user