Grafx2 can now read and convert gfx2.cfg from the original DOS (96.5%) format.
Older .cfg files in svn were saved incorrectly: the wrong size of chunk #5 (0x0101 instead of 0xE1) made it impossible to re-read the file in gfxcfg. gfxcfg can read and save gfx2.cfg. Upward compatibility is provided: - If new chunk types are added to the format, it only needs a re-compile. Older files can be read and saved. - If new keyboard shortcuts are added (134 currently), the older files can be read and the default shortcut will be used for missing keys. Fixed many endianness cases, hopefully Fixed LBM loading : bug in ASM->C conversion of Couleur_ILBM_line() Broke PCX loading : argh! git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@176 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
parent
11a4a488a6
commit
acfe5836ce
2
Makefile
2
Makefile
@ -15,7 +15,7 @@ endif
|
||||
.PHONY : all debug release clean depend zip
|
||||
|
||||
CC = gcc
|
||||
OBJ = main.o init.o graph.o sdlscreen.o divers.o special.o boutons.o palette.o aide.o operatio.o pages.o loadsave.o readline.o moteur.o files.o op_c.o linux.o op_asm.o readini.o saveini.o shade.o clavier.o
|
||||
OBJ = main.o init.o graph.o sdlscreen.o divers.o special.o boutons.o palette.o aide.o operatio.o pages.o loadsave.o readline.o moteur.o files.o op_c.o linux.o op_asm.o readini.o saveini.o shade.o clavier.o io.o
|
||||
|
||||
SCREEN = -D WINDOWED
|
||||
OBJDIR = obj/
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
main.o: main.c const.h struct.h global.h loadsave.h graph.h divers.h \
|
||||
init.h boutons.h moteur.h pages.h files.h sdlscreen.h erreurs.h \
|
||||
readini.h saveini.h linux.h
|
||||
init.o: init.c const.h struct.h global.h loadsave.h graph.h \
|
||||
init.o: init.c const.h struct.h global.h loadsave.h modesvdo.h graph.h \
|
||||
boutons.h palette.h aide.h operatio.h divers.h erreurs.h clavier.h
|
||||
graph.o: graph.c sdlscreen.h struct.h const.h graph.h divers.h moteur.h \
|
||||
boutons.h pages.h global.h loadsave.h erreurs.h
|
||||
@ -23,7 +23,7 @@ operatio.o: operatio.c const.h struct.h global.h loadsave.h divers.h \
|
||||
pages.o: pages.c global.h struct.h const.h loadsave.h pages.h graph.h \
|
||||
erreurs.h linux.h
|
||||
loadsave.o: loadsave.c const.h struct.h global.h loadsave.h graph.h \
|
||||
divers.h pages.h op_c.h boutons.h erreurs.h linux.h
|
||||
divers.h pages.h op_c.h boutons.h erreurs.h linux.h io.h
|
||||
readline.o: readline.c const.h struct.h global.h loadsave.h graph.h \
|
||||
divers.h erreurs.h linux.h
|
||||
moteur.o: moteur.c const.h struct.h global.h loadsave.h graph.h divers.h \
|
||||
@ -39,3 +39,4 @@ saveini.o: saveini.c const.h global.h struct.h loadsave.h readini.h \
|
||||
shade.o: shade.c global.h struct.h const.h loadsave.h graph.h moteur.h \
|
||||
divers.h readline.h
|
||||
clavier.o: clavier.c global.h struct.h const.h loadsave.h
|
||||
io.o: io.c struct.h const.h
|
||||
|
||||
@ -6,14 +6,17 @@ COPT = -c `sdl-config --cflags` -Wall -g
|
||||
LOPT = `sdl-config --libs` -lSDL_image -lSDL_gfx -g
|
||||
endif
|
||||
|
||||
gfxcfg: gfxcfg.o SFont.o ../clavier.o
|
||||
gcc gfxcfg.o ../clavier.o SFont.o -o gfxcfg $(LOPT)
|
||||
gfxcfg: gfxcfg.o SFont.o ../clavier.o ../io.o
|
||||
gcc gfxcfg.o ../clavier.o ../io.o SFont.o -o gfxcfg $(LOPT)
|
||||
|
||||
gfxcfg.o: gfxcfg.c SFont.h
|
||||
gcc -c gfxcfg.c -o gfxcfg.o $(COPT)
|
||||
|
||||
../clavier.o: ../clavier.c
|
||||
gcc -c ../clavier.c -o ../clavier.o $(COPT)
|
||||
|
||||
../io.o: ../io.c
|
||||
gcc -c ../io.c -o ../io.o $(COPT)
|
||||
|
||||
SFont.o: SFont.h SFont.c
|
||||
gcc -c SFont.c -o SFont.o $(COPT)
|
||||
|
||||
287
cfg_new/gfxcfg.c
287
cfg_new/gfxcfg.c
@ -15,20 +15,23 @@
|
||||
//mine
|
||||
#include "SFont.h"
|
||||
|
||||
typedef uint8_t byte;
|
||||
typedef uint16_t word;
|
||||
typedef uint32_t dword;
|
||||
// Modificateurs pour Touche
|
||||
#define MOD_SHIFT 0x1000
|
||||
#define MOD_CTRL 0x2000
|
||||
#define MOD_ALT 0x4000
|
||||
|
||||
#include "../struct.h"
|
||||
#include "../clavier.h"
|
||||
#include "../const.h"
|
||||
#include "../io.h"
|
||||
|
||||
|
||||
/*** Constants ***/
|
||||
#define NB_MAX_OPTIONS 134
|
||||
#define HAUTEUR_DEBUT_SETUP 7
|
||||
#define HAUTEUR_FIN_SETUP 44
|
||||
#define Header_size sizeof(struct Config_Header)
|
||||
#define Chunk_size sizeof(struct Config_Chunk)
|
||||
|
||||
/* Colors */
|
||||
#define COULEUR_SETUP 1
|
||||
@ -47,23 +50,6 @@ typedef struct{
|
||||
bool Suppr;
|
||||
} __attribute__((__packed__)) Options;
|
||||
|
||||
typedef struct{
|
||||
char Signature[3];
|
||||
uint8_t Version1;
|
||||
uint8_t Version2;
|
||||
uint8_t Beta1;
|
||||
uint8_t Beta2;
|
||||
} __attribute__((__packed__)) Type_header;
|
||||
|
||||
#define Header_size 7
|
||||
|
||||
typedef struct{
|
||||
uint8_t Numero;
|
||||
uint16_t Taille;
|
||||
} __attribute__((__packed__)) Type_chunk;
|
||||
|
||||
#define Chunk_size 3
|
||||
|
||||
/*** Global variables ***/
|
||||
SFont_Font* MyFont;
|
||||
SDL_Surface* Ecran;
|
||||
@ -74,6 +60,14 @@ uint16_t NB_OPTIONS;
|
||||
uint16_t Decalage_curseur=0;
|
||||
uint16_t Position_curseur=0;
|
||||
|
||||
byte * FichierConfig = NULL;
|
||||
byte * ChunkData[CHUNK_MAX];
|
||||
struct Config_Chunk Chunk[CHUNK_MAX];
|
||||
|
||||
|
||||
uint8_t Fenetre_choix(int Largeur, int Hauteur, const char* Titre, const char* Choix, uint8_t Choix_debut,
|
||||
uint8_t Couleur,uint8_t Couleur_choix);
|
||||
|
||||
/*** Fonctions de gestion des évènements SDL ***/
|
||||
|
||||
/* Attend qu'une touche soit pressée. Retourne le code touche. */
|
||||
@ -168,17 +162,104 @@ void Tout_ecrire()
|
||||
|
||||
/*** Configuration handling functions ***/
|
||||
|
||||
/* Generate the INI file from the CFG */
|
||||
bool Recreer_INI()
|
||||
{
|
||||
puts("RECREER INI");
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Reads the config file */
|
||||
void Interpretation_du_fichier_config()
|
||||
/* returns an error message, or NULL if everything OK */
|
||||
char * Interpretation_du_fichier_config()
|
||||
{
|
||||
puts("INTERPRETATION FICHIER CONFIG");
|
||||
|
||||
FILE* Fichier;
|
||||
long int Taille_fichier;
|
||||
byte Numero_chunk;
|
||||
word Taille_chunk;
|
||||
byte * Ptr;
|
||||
int i;
|
||||
|
||||
Fichier = fopen("gfx2.cfg","rb");
|
||||
if (!Fichier)
|
||||
{
|
||||
return "gfx2.cfg is missing! Please run the\nmain program to generate it.";
|
||||
}
|
||||
fseek(Fichier,0,SEEK_END); // Positionnement à la fin
|
||||
Taille_fichier = ftell(Fichier);
|
||||
if (!Taille_fichier)
|
||||
{
|
||||
fclose(Fichier);
|
||||
return "gfx2.cfg is empty. Please run the main\nprogram to generate it.";
|
||||
}
|
||||
FichierConfig = malloc(Taille_fichier);
|
||||
if (!Fichier)
|
||||
{
|
||||
fclose(Fichier);
|
||||
return "Out of memory when reading gfx2.cfg.";
|
||||
}
|
||||
fseek(Fichier,0,SEEK_SET); // Positionnement au début
|
||||
if (! read_bytes(Fichier, FichierConfig, Taille_fichier))
|
||||
{
|
||||
fclose(Fichier);
|
||||
return "Error while reading gfx2.cfg.";
|
||||
}
|
||||
fclose(Fichier);
|
||||
|
||||
// Initialisation des "index"
|
||||
for (i=0; i<CHUNK_MAX; i++)
|
||||
{
|
||||
Chunk[i].Taille=0;
|
||||
Chunk[i].Numero=i;
|
||||
ChunkData[i]=NULL;
|
||||
}
|
||||
|
||||
// Pour faire simple, on saute l'en-tete
|
||||
Ptr = FichierConfig + Header_size;
|
||||
while (Ptr < FichierConfig + Taille_fichier)
|
||||
{
|
||||
// Lecture chunk
|
||||
Numero_chunk = *Ptr;
|
||||
Ptr++;
|
||||
Taille_chunk = endian_magic16(*((word *)Ptr));
|
||||
Ptr+=2;
|
||||
if (Numero_chunk>= CHUNK_MAX)
|
||||
return "File gfx2.cfg invalid.";
|
||||
|
||||
ChunkData[Numero_chunk] = Ptr;
|
||||
Chunk[Numero_chunk].Taille = Taille_chunk;
|
||||
printf("%d %6X %d\n", Numero_chunk, Ptr - FichierConfig, Taille_chunk);
|
||||
Ptr+=Taille_chunk;
|
||||
}
|
||||
// Si la config contenait des touches, on les initialise:
|
||||
if (Chunk[CHUNK_TOUCHES].Taille)
|
||||
{
|
||||
int Indice_config;
|
||||
Ptr = ChunkData[CHUNK_TOUCHES];
|
||||
for (Indice_config=0; Indice_config< Chunk[CHUNK_TOUCHES].Taille / sizeof(struct Config_Infos_touche) ; Indice_config++)
|
||||
{
|
||||
word Numero;
|
||||
word Touche;
|
||||
word Touche2;
|
||||
int Indice_touche;
|
||||
|
||||
Numero = endian_magic16(*((word *)Ptr));
|
||||
Ptr+=2;
|
||||
Touche = endian_magic16(*((word *)Ptr));
|
||||
Ptr+=2;
|
||||
Touche2 = endian_magic16(*((word *)Ptr));
|
||||
Ptr+=2;
|
||||
//printf("%4d %4X %4X\t", Numero, Touche, Touche2);
|
||||
// Recherche de la touche qui porte ce numéro
|
||||
for (Indice_touche=0; Indice_touche <= NB_OPTIONS; Indice_touche ++)
|
||||
{
|
||||
if (Config[Indice_touche].Numero == Numero)
|
||||
{
|
||||
Config[Indice_touche].Touche = Touche;
|
||||
Config[Indice_touche].Touche2 = Touche2;
|
||||
//printf("%4d %s\n", Indice_touche, Nom_touche(Touche));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Defines an option */
|
||||
@ -199,8 +280,7 @@ void Definir_option(uint16_t Numero, char* Libelle, char* Explic1, char* Explic2
|
||||
/* Initialize configuration */
|
||||
bool Initialiser_config()
|
||||
{
|
||||
bool Erreur = false;
|
||||
FILE* Fichier_INI;
|
||||
char * MessageErreur = NULL;
|
||||
|
||||
Numero_definition_option = 0;
|
||||
|
||||
@ -332,12 +412,12 @@ bool Initialiser_config()
|
||||
"Allows you to replace all the pixels of the color pointed by the mouse with",
|
||||
"the fore-color or the back-color.",
|
||||
true,SDLK_f|MOD_SHIFT); /*Shift + F*/
|
||||
Definir_option(31,"Bézier""s curves",
|
||||
"Allows you to draw Bézier""s curves.",
|
||||
Definir_option(31,"Bezier""s curves",
|
||||
"Allows you to draw Bezier""s curves.",
|
||||
"",
|
||||
true,SDLK_i); /*I*/
|
||||
Definir_option(32,"Bézier""s curve with 3 or 4 points",
|
||||
"Allows you to choose whether you want to draw Bézier""s curves with 3 or 4",
|
||||
Definir_option(32,"Bezier""s curve with 3 or 4 points",
|
||||
"Allows you to choose whether you want to draw Bezier""s curves with 3 or 4",
|
||||
"points.",
|
||||
true,SDLK_i|MOD_SHIFT); /*Shift + I*/
|
||||
Definir_option(33,"Empty rectangle",
|
||||
@ -744,15 +824,14 @@ bool Initialiser_config()
|
||||
|
||||
NB_OPTIONS = Numero_definition_option - 1;
|
||||
|
||||
Fichier_INI = fopen("gfx2.ini","r");
|
||||
if(Fichier_INI == NULL)
|
||||
Erreur=Recreer_INI();
|
||||
else
|
||||
fclose(Fichier_INI);
|
||||
MessageErreur = Interpretation_du_fichier_config();
|
||||
|
||||
if(Erreur==0) Interpretation_du_fichier_config();
|
||||
|
||||
return Erreur;
|
||||
if (MessageErreur)
|
||||
{
|
||||
Fenetre_choix(30,10,MessageErreur,"Ok",0,0x2A,0x6F);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t Fenetre_choix(int Largeur, int Hauteur, const char* Titre, const char* Choix, uint8_t Choix_debut,
|
||||
@ -842,13 +921,13 @@ void Test_duplic()
|
||||
uint16_t i,j;
|
||||
bool Pas_encore_erreur;
|
||||
|
||||
for(i=0;i<NB_OPTIONS;i++)
|
||||
for(i=0;i<=NB_OPTIONS;i++)
|
||||
{
|
||||
if(Config[i].Touche!=0xFF) // FIXME
|
||||
{
|
||||
j=1;
|
||||
j=0;
|
||||
Pas_encore_erreur=true;
|
||||
while(j<NB_OPTIONS && Pas_encore_erreur)
|
||||
while(j<=NB_OPTIONS && Pas_encore_erreur)
|
||||
{
|
||||
if(i!=j && Config[i].Touche==Config[j].Touche)
|
||||
{
|
||||
@ -868,7 +947,7 @@ bool Validation()
|
||||
bool Y_a_des_erreurs = false;
|
||||
uint16_t i = 0;
|
||||
|
||||
while(i<NB_OPTIONS && !Y_a_des_erreurs)
|
||||
while(i<=NB_OPTIONS && !Y_a_des_erreurs)
|
||||
{
|
||||
Y_a_des_erreurs = Config[i].Erreur;
|
||||
i++;
|
||||
@ -924,7 +1003,6 @@ void Scroll_bas()
|
||||
}
|
||||
Ecrire_commentaire(Position_curseur + Decalage_curseur );
|
||||
}
|
||||
printf("%d %d \n",Position_curseur, Decalage_curseur);
|
||||
}
|
||||
|
||||
/* Moves one screen up */
|
||||
@ -971,7 +1049,7 @@ void Page_down()
|
||||
{
|
||||
Decalage_curseur+=HAUTEUR_FIN_SETUP-HAUTEUR_DEBUT_SETUP;
|
||||
}
|
||||
else Decalage_curseur=NB_OPTIONS-HAUTEUR_FIN_SETUP+HAUTEUR_DEBUT_SETUP-1;
|
||||
else Decalage_curseur=NB_OPTIONS-HAUTEUR_FIN_SETUP+HAUTEUR_DEBUT_SETUP;
|
||||
|
||||
Tout_ecrire();
|
||||
}
|
||||
@ -990,13 +1068,18 @@ void Select()
|
||||
{
|
||||
Touche = Lire_Touche();
|
||||
if (Touche == SDLK_ESCAPE)
|
||||
return;
|
||||
{
|
||||
Ecrire(HAUTEUR_DEBUT_SETUP + (Position_curseur) ,Position_curseur + Decalage_curseur,
|
||||
COULEUR_SETUP);
|
||||
return;
|
||||
}
|
||||
if (Touche != 0)
|
||||
{
|
||||
Config[Position_curseur+Decalage_curseur].Touche = Touche;
|
||||
Test_duplic();
|
||||
Ecrire(HAUTEUR_DEBUT_SETUP + (Position_curseur) ,Position_curseur + Decalage_curseur,
|
||||
COULEUR_SETUP);
|
||||
// Des X ont pu être ajoutés ou enlevés sur n'importe quelle ligne..
|
||||
// pour faire simple, on rafraîchit toute la page.
|
||||
Tout_ecrire();
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -1053,21 +1136,47 @@ bool Verifier_ecriture_possible()
|
||||
void Enregistrer_config()
|
||||
{
|
||||
FILE* Fichier;
|
||||
uint16_t Indice;
|
||||
struct Config_Header Header;
|
||||
int Indice_chunk;
|
||||
|
||||
if(Choix_enreg==true) // Save keys if wanted
|
||||
{
|
||||
Fichier = fopen("gfx2.cfg","ab");
|
||||
fseek(Fichier,Header_size+Chunk_size,SEEK_SET); // Positionnement sur la première touche
|
||||
Fichier = fopen("gfx2.cfg","wb");
|
||||
|
||||
// En-tete
|
||||
sprintf(Header.Signature,"CFG");
|
||||
Header.Version1 = VERSION1;
|
||||
Header.Version2 = VERSION2;
|
||||
Header.Beta1 = BETA1;
|
||||
Header.Beta2 = BETA2;
|
||||
write_bytes(Fichier, &Header, sizeof(Header));
|
||||
|
||||
for(Indice = 0;Indice < NB_OPTIONS;Indice++)
|
||||
{
|
||||
fwrite(&Config[Indice].Numero,sizeof(uint16_t),1,Fichier);
|
||||
fwrite(&Config[Indice].Touche,sizeof(uint16_t),1,Fichier);
|
||||
fwrite(&Config[Indice].Touche2,sizeof(uint16_t),1,Fichier);
|
||||
}
|
||||
Chunk[CHUNK_TOUCHES].Taille=sizeof(struct Config_Infos_touche)*(NB_OPTIONS+1);
|
||||
Chunk[CHUNK_TOUCHES].Numero=CHUNK_TOUCHES;
|
||||
|
||||
fclose(Fichier);
|
||||
for (Indice_chunk=0; Indice_chunk<CHUNK_MAX; Indice_chunk++)
|
||||
{
|
||||
// Ecriture en-tete chunk
|
||||
write_bytes(Fichier, &(Chunk[Indice_chunk].Numero), 1);
|
||||
write_word_le(Fichier, Chunk[Indice_chunk].Taille);
|
||||
|
||||
if (Indice_chunk == CHUNK_TOUCHES)
|
||||
{
|
||||
int Indice_touche;
|
||||
|
||||
for(Indice_touche=0; Indice_touche<=NB_OPTIONS;Indice_touche++)
|
||||
{
|
||||
write_word_le(Fichier,Config[Indice_touche].Numero);
|
||||
write_word_le(Fichier,Config[Indice_touche].Touche);
|
||||
write_word_le(Fichier,Config[Indice_touche].Touche2);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
write_bytes(Fichier, ChunkData[Indice_chunk], Chunk[Indice_chunk].Taille);
|
||||
}
|
||||
}
|
||||
fclose(Fichier);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1076,21 +1185,22 @@ void Enregistrer_config()
|
||||
int main(int argc, char * argv[])
|
||||
{
|
||||
|
||||
if (Verifier_ecriture_possible())
|
||||
{
|
||||
/* On initialise SDL */
|
||||
SDL_Init(SDL_INIT_VIDEO);
|
||||
Ecran = SDL_SetVideoMode(640,480,8,0);
|
||||
SDL_WM_SetCaption ("Grafx2 configuration tool","../gfx2.gif");
|
||||
SDL_EnableKeyRepeat(250, 32);
|
||||
if (Verifier_ecriture_possible())
|
||||
{
|
||||
/* On initialise SDL */
|
||||
SDL_Init(SDL_INIT_VIDEO);
|
||||
Ecran = SDL_SetVideoMode(640,480,8,0);
|
||||
SDL_WM_SetCaption ("Grafx2 configuration tool","../gfx2.gif");
|
||||
SDL_EnableKeyRepeat(250, 32);
|
||||
SDL_EnableUNICODE(SDL_ENABLE);
|
||||
|
||||
/* On initialise SFont */
|
||||
MyFont = SFont_InitFont(IMG_Load("8pxfont.png"));
|
||||
/* On initialise SFont */
|
||||
MyFont = SFont_InitFont(IMG_Load("8pxfont.png"));
|
||||
|
||||
Dessiner_ecran_principal();
|
||||
Dessiner_ecran_principal();
|
||||
|
||||
if(!Initialiser_config())
|
||||
{
|
||||
if(!Initialiser_config())
|
||||
{
|
||||
Setup();
|
||||
Enregistrer_config();
|
||||
|
||||
@ -1098,24 +1208,23 @@ int main(int argc, char * argv[])
|
||||
SFont_FreeFont(MyFont);
|
||||
SDL_Quit();
|
||||
exit(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
puts("Error reading GFX2.DAT! File is absent or corrupt.");
|
||||
}
|
||||
else
|
||||
{
|
||||
SFont_FreeFont(MyFont);
|
||||
SDL_Quit();
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
puts("Error: you mustn't run this setup program from a read-only drive!\n");
|
||||
puts("The most probable cause of this error is that you are running this program");
|
||||
puts("from a CD-Rom or a protected floppy disk.");
|
||||
puts("You should try to copy all the files of Grafx2 on a hard drive or to");
|
||||
puts("unprotect your floppy disk if you really want to run it from this outdated medium.");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
puts("Error: you mustn't run this setup program from a read-only drive!\n");
|
||||
puts("The most probable cause of this error is that you are running this program");
|
||||
puts("from a CD-Rom or a protected floppy disk.");
|
||||
puts("You should try to copy all the files of Grafx2 on a hard drive or to");
|
||||
puts("unprotect your floppy disk if you really want to run it from this outdated medium.");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
12
clavier.c
12
clavier.c
@ -298,10 +298,12 @@ word Conversion_Touche(SDL_keysym Sym)
|
||||
|
||||
// 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)
|
||||
if (Sym.sym > 0)
|
||||
if (Sym.sym != 0)
|
||||
Retour = Sym.sym;
|
||||
else if (Sym.unicode > 0)
|
||||
Retour = (Sym.unicode & 0x07FF) | 0x0800;
|
||||
else if (Sym.scancode != 0)
|
||||
{
|
||||
Retour = (Sym.scancode & 0x07FF) | 0x0800;
|
||||
}
|
||||
|
||||
if (Sym.mod & (KMOD_LSHIFT | KMOD_RSHIFT))
|
||||
Retour |= MOD_SHIFT;
|
||||
@ -309,7 +311,7 @@ word Conversion_Touche(SDL_keysym Sym)
|
||||
Retour |= MOD_CTRL;
|
||||
if (Sym.mod & (KMOD_LALT | KMOD_RALT | KMOD_MODE))
|
||||
Retour |= MOD_ALT;
|
||||
return Retour;
|
||||
return Retour;
|
||||
}
|
||||
|
||||
const char * Nom_touche(word Touche)
|
||||
@ -434,7 +436,7 @@ const char * Nom_touche(word Touche)
|
||||
}
|
||||
}
|
||||
// Autres touches inconnues
|
||||
sprintf(Buffer+strlen(Buffer), "(%d)", Touche);
|
||||
sprintf(Buffer+strlen(Buffer), "0x%X", Touche & 0x7FF);
|
||||
return Buffer;
|
||||
|
||||
}
|
||||
|
||||
19
const.h
19
const.h
@ -265,15 +265,16 @@ enum MODES_DE_SHADE
|
||||
|
||||
enum CHUNKS_CFG
|
||||
{
|
||||
CHUNK_TOUCHES,
|
||||
CHUNK_MODES_VIDEO,
|
||||
CHUNK_SHADE,
|
||||
CHUNK_MASQUE,
|
||||
CHUNK_STENCIL,
|
||||
CHUNK_DEGRADES,
|
||||
CHUNK_SMOOTH,
|
||||
CHUNK_EXCLUDE_COLORS,
|
||||
CHUNK_QUICK_SHADE
|
||||
CHUNK_TOUCHES = 0,
|
||||
CHUNK_MODES_VIDEO = 1,
|
||||
CHUNK_SHADE = 2,
|
||||
CHUNK_MASQUE = 3,
|
||||
CHUNK_STENCIL = 4,
|
||||
CHUNK_DEGRADES = 5,
|
||||
CHUNK_SMOOTH = 6,
|
||||
CHUNK_EXCLUDE_COLORS = 7,
|
||||
CHUNK_QUICK_SHADE = 8,
|
||||
CHUNK_MAX
|
||||
};
|
||||
|
||||
// Les différents types de lecteurs:
|
||||
|
||||
4
divers.c
4
divers.c
@ -611,14 +611,14 @@ long Freespace(byte Numero_de_lecteur)
|
||||
// Les images ILBM sont stockés en bitplanes donc on doit trifouiller les bits pour
|
||||
// en faire du chunky
|
||||
|
||||
byte Couleur_ILBM_line(word Pos_X, word Vraie_taille_ligne)
|
||||
byte Couleur_ILBM_line(word Pos_X, word Vraie_taille_ligne, byte HBPm1)
|
||||
{
|
||||
// CL sera le rang auquel on extrait les bits de la couleur
|
||||
byte cl = 7 - (Pos_X & 7);
|
||||
int ax,bh,dx;
|
||||
byte bl=0;
|
||||
|
||||
for(dx = HBPm1;dx>0;dx--);
|
||||
for(dx=HBPm1;dx>=0;dx--)
|
||||
{
|
||||
//CIL_Loop
|
||||
ax = (Vraie_taille_ligne * dx + Pos_X) >> 3;
|
||||
|
||||
2
divers.h
2
divers.h
@ -107,7 +107,7 @@ byte Pixel_dans_cercle(void);
|
||||
byte Bit(byte Octet, byte Rang);
|
||||
// Extrait un bit d'un certain rang à partir d'un octet.
|
||||
|
||||
byte Couleur_ILBM_line(word Pos_X, word Vraie_taille_ligne);
|
||||
byte Couleur_ILBM_line(word Pos_X, word Vraie_taille_ligne, byte HBPm1);
|
||||
// Renvoie la couleur du pixel (ILBM) en Pos_X.
|
||||
|
||||
// Gestion du chrono dans les fileselects
|
||||
|
||||
BIN
gfx2_fra.cfg
BIN
gfx2_fra.cfg
Binary file not shown.
8
init.c
8
init.c
@ -1717,8 +1717,7 @@ int Charger_CFG(int Tout_charger)
|
||||
// Version DOS de Robinson et X-Man
|
||||
if ( (CFG_Header.Version1== 2)
|
||||
&& (CFG_Header.Version2== 0)
|
||||
&& (CFG_Header.Beta1== 96)
|
||||
&& (CFG_Header.Beta2== 5) )
|
||||
&& (CFG_Header.Beta1== 96))
|
||||
{
|
||||
// Les touches (scancodes) sont à convertir)
|
||||
Conversion_touches = 1;
|
||||
@ -1792,7 +1791,7 @@ int Charger_CFG(int Tout_charger)
|
||||
}
|
||||
break;
|
||||
case CHUNK_MODES_VIDEO: // Modes vidéo
|
||||
if ((Chunk.Taille/5/*sizeof(CFG_Mode_video)*/)!=NB_MODES_VIDEO)
|
||||
if ((Chunk.Taille/sizeof(CFG_Mode_video))!=NB_MODES_VIDEO)
|
||||
goto Erreur_lecture_config;
|
||||
for (Indice=1; Indice<=NB_MODES_VIDEO; Indice++)
|
||||
{
|
||||
@ -1862,6 +1861,7 @@ int Charger_CFG(int Tout_charger)
|
||||
case CHUNK_DEGRADES: // Infos sur les dégradés
|
||||
if (Tout_charger)
|
||||
{
|
||||
// fixme endianness : Degrade_Courant est un int, enregistre en byte
|
||||
if (fread(&Degrade_Courant,1,1,Handle)!=1)
|
||||
goto Erreur_lecture_config;
|
||||
for(Indice=0;Indice<16;Indice++)
|
||||
@ -1995,7 +1995,7 @@ int Sauver_CFG(void)
|
||||
|
||||
// Sauvegarde de l'état de chaque mode vidéo
|
||||
Chunk.Numero=CHUNK_MODES_VIDEO;
|
||||
Chunk.Taille=NB_MODES_VIDEO*5 /*sizeof(CFG_Mode_video)*/;
|
||||
Chunk.Taille=NB_MODES_VIDEO * sizeof(CFG_Mode_video);
|
||||
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
|
||||
//On remet les octets dans l'ordre "normal"
|
||||
Chunk.Taille=bswap_16(Chunk.Taille);
|
||||
|
||||
118
io.c
Normal file
118
io.c
Normal file
@ -0,0 +1,118 @@
|
||||
|
||||
// Fonctions de lecture/ecriture fichier, gèrent les systèmes big-endian et
|
||||
// little-endian.
|
||||
|
||||
#include <SDL/SDL_endian.h>
|
||||
#include "struct.h"
|
||||
|
||||
word endian_magic16(word x)
|
||||
{
|
||||
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
||||
return x;
|
||||
#else
|
||||
return SDL_Swap16(x);
|
||||
#endif
|
||||
}
|
||||
word endian_magic32(word x)
|
||||
{
|
||||
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
||||
return x;
|
||||
#else
|
||||
return SDL_Swap32(x);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Lit des octets
|
||||
// Renvoie -1 si OK, 0 en cas d'erreur
|
||||
int read_bytes(FILE *Fichier, void *Dest, size_t Taille)
|
||||
{
|
||||
return fread(Dest, 1, Taille, Fichier) == Taille;
|
||||
}
|
||||
// Ecrit des octets
|
||||
// Renvoie -1 si OK, 0 en cas d'erreur
|
||||
int write_bytes(FILE *Fichier, void *Src, size_t Taille)
|
||||
{
|
||||
return fwrite(Src, 1, Taille, Fichier) == Taille;
|
||||
}
|
||||
|
||||
// Lit un word (little-endian)
|
||||
// Renvoie -1 si OK, 0 en cas d'erreur
|
||||
int read_word_le(FILE *Fichier, word *Dest)
|
||||
{
|
||||
if (fread(Dest, 1, sizeof(word), Fichier) != sizeof(word))
|
||||
return 0;
|
||||
#if SDL_BYTEORDER != SDL_LIL_ENDIAN
|
||||
*Dest = SDL_Swap16(*Dest);
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
// Ecrit un word (little-endian)
|
||||
// Renvoie -1 si OK, 0 en cas d'erreur
|
||||
int write_word_le(FILE *Fichier, word Mot)
|
||||
{
|
||||
#if SDL_BYTEORDER != SDL_LIL_ENDIAN
|
||||
Mot = SDL_Swap16(Mot);
|
||||
#endif
|
||||
return fwrite(&Mot, 1, sizeof(word), Fichier) == sizeof(word);
|
||||
}
|
||||
// Lit un word (big-endian)
|
||||
// Renvoie -1 si OK, 0 en cas d'erreur
|
||||
int read_word_be(FILE *Fichier, word *Dest)
|
||||
{
|
||||
if (fread(Dest, 1, sizeof(word), Fichier) != sizeof(word))
|
||||
return 0;
|
||||
#if SDL_BYTEORDER != SDL_BIG_ENDIAN
|
||||
*Dest = SDL_Swap16(*Dest);
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
// Ecrit un word (big-endian)
|
||||
// Renvoie -1 si OK, 0 en cas d'erreur
|
||||
int write_word_be(FILE *Fichier, word Mot)
|
||||
{
|
||||
#if SDL_BYTEORDER != SDL_BIG_ENDIAN
|
||||
Mot = SDL_Swap16(Mot);
|
||||
#endif
|
||||
return fwrite(&Mot, 1, sizeof(word), Fichier) == sizeof(word);
|
||||
}
|
||||
// Lit un dword (little-endian)
|
||||
// Renvoie -1 si OK, 0 en cas d'erreur
|
||||
int read_dword_le(FILE *Fichier, dword *Dest)
|
||||
{
|
||||
if (fread(Dest, 1, sizeof(dword), Fichier) != sizeof(dword))
|
||||
return 0;
|
||||
#if SDL_BYTEORDER != SDL_LIL_ENDIAN
|
||||
*Dest = SDL_Swap32(*Dest);
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
// Ecrit un dword (little-endian)
|
||||
// Renvoie -1 si OK, 0 en cas d'erreur
|
||||
int write_dword_le(FILE *Fichier, dword Mot)
|
||||
{
|
||||
#if SDL_BYTEORDER != SDL_LIL_ENDIAN
|
||||
Mot = SDL_Swap32(Mot);
|
||||
#endif
|
||||
return fwrite(&Mot, 1, sizeof(dword), Fichier) == sizeof(dword);
|
||||
}
|
||||
|
||||
// Lit un dword (big-endian)
|
||||
// Renvoie -1 si OK, 0 en cas d'erreur
|
||||
int read_dword_be(FILE *Fichier, dword *Dest)
|
||||
{
|
||||
if (fread(Dest, 1, sizeof(dword), Fichier) != sizeof(dword))
|
||||
return 0;
|
||||
#if SDL_BYTEORDER != SDL_BIG_ENDIAN
|
||||
*Dest = SDL_Swap32(*Dest);
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
// Ecrit un dword (big-endian)
|
||||
// Renvoie -1 si OK, 0 en cas d'erreur
|
||||
int write_dword_be(FILE *Fichier, dword Mot)
|
||||
{
|
||||
#if SDL_BYTEORDER != SDL_BIG_ENDIAN
|
||||
Mot = SDL_Swap32(Mot);
|
||||
#endif
|
||||
return fwrite(&Mot, 1, sizeof(dword), Fichier) == sizeof(dword);
|
||||
}
|
||||
16
io.h
Normal file
16
io.h
Normal file
@ -0,0 +1,16 @@
|
||||
|
||||
word endian_magic16(word x);
|
||||
dword endian_magic32(dword x);
|
||||
|
||||
int read_bytes(FILE *Fichier, void *Dest, size_t Taille);
|
||||
int write_bytes(FILE *Fichier, void *Dest, size_t Taille);
|
||||
|
||||
int read_word_le(FILE *Fichier, word *Dest);
|
||||
int write_word_le(FILE *Fichier, word Mot);
|
||||
int read_dword_le(FILE *Fichier, dword *Dest);
|
||||
int write_dword_le(FILE *Fichier, dword Mot);
|
||||
|
||||
int read_word_be(FILE *Fichier, word *Dest);
|
||||
int write_word_be(FILE *Fichier, word Mot);
|
||||
int read_dword_be(FILE *Fichier, dword *Dest);
|
||||
int write_dword_be(FILE *Fichier, dword Mot);
|
||||
564
loadsave.c
564
loadsave.c
File diff suppressed because it is too large
Load Diff
@ -19,7 +19,7 @@ void Load_LBM(void);
|
||||
void Save_LBM(void);
|
||||
|
||||
byte * LBM_Buffer;
|
||||
byte HBPm1; // Header.BitPlanes-1
|
||||
|
||||
|
||||
// -- GIF -------------------------------------------------------------------
|
||||
void Test_GIF(void);
|
||||
|
||||
10
struct.h
10
struct.h
@ -120,7 +120,7 @@ struct T_Degrade_Tableau
|
||||
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
|
||||
};
|
||||
} __attribute__((__packed__));
|
||||
|
||||
// Déclaration d'une info de shade
|
||||
struct T_Shade
|
||||
@ -139,7 +139,7 @@ struct Config_Mode_video
|
||||
byte Etat;
|
||||
word Largeur;
|
||||
word Hauteur;
|
||||
};
|
||||
} __attribute__((__packed__));
|
||||
|
||||
struct Config_Header
|
||||
{
|
||||
@ -148,20 +148,20 @@ struct Config_Header
|
||||
byte Version2;
|
||||
byte Beta1;
|
||||
byte Beta2;
|
||||
};
|
||||
} __attribute__((__packed__));
|
||||
|
||||
struct Config_Chunk
|
||||
{
|
||||
byte Numero;
|
||||
word Taille;
|
||||
};
|
||||
} __attribute__((__packed__));
|
||||
|
||||
struct Config_Infos_touche
|
||||
{
|
||||
word Numero;
|
||||
word Touche;
|
||||
word Touche2;
|
||||
};
|
||||
} __attribute__((__packed__));
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user