Added palette constraint modes: Run the program with command-line option "/rgb <N>" to force RGB components have N levels instead of 256. Ex: /rgb 16 enforces a classic Amiga 4096 color palette, 64 is PC VGA, /rgb 3 is Amstrad CPC...)

Added missing messages for /wide and /tall command-line arguments.


git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@477 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
Yves Rizoud 2009-01-13 23:48:33 +00:00
parent 0c245896c5
commit dc4abe6245
5 changed files with 87 additions and 32 deletions

View File

@ -3,11 +3,14 @@ $(OBJDIR)/aide.o: aide.c const.h struct.h global.h loadsave.h divers.h graph.h \
moteur.h tables_aide.h aide.h sdlscreen.h texte.h clavier.h windows.h
$(OBJDIR)/boutons.o: boutons.c const.h struct.h global.h loadsave.h divers.h \
graph.h moteur.h readline.h files.h init.h boutons.h operatio.h pages.h \
erreurs.h readini.h saveini.h shade.h io.h aide.h texte.h sdlscreen.h windows.h brush.h
$(OBJDIR)/brush.o: brush.c brush.h erreurs.h windows.h sdlscreen.h
erreurs.h readini.h saveini.h shade.h io.h aide.h texte.h sdlscreen.h \
windows.h brush.h
$(OBJDIR)/brush.o: brush.c global.h struct.h const.h loadsave.h graph.h divers.h \
erreurs.h windows.h sdlscreen.h
$(OBJDIR)/clavier.o: clavier.c global.h struct.h const.h loadsave.h
$(OBJDIR)/divers.o: divers.c struct.h const.h sdlscreen.h global.h loadsave.h \
graph.h erreurs.h boutons.h moteur.h divers.h clavier.h windows.h
graph.h erreurs.h boutons.h moteur.h divers.h clavier.h windows.h \
palette.h
$(OBJDIR)/files.o: files.c const.h struct.h global.h loadsave.h graph.h divers.h \
erreurs.h io.h windows.h
$(OBJDIR)/gfxcfg.o: gfxcfg.c SFont.h struct.h const.h clavier.h io.h hotkeys.h \
@ -17,19 +20,21 @@ $(OBJDIR)/graph.o: graph.c global.h struct.h const.h loadsave.h moteur.h boutons
pxwide.h windows.h
$(OBJDIR)/init.o: init.c const.h struct.h global.h loadsave.h graph.h boutons.h \
palette.h aide.h operatio.h divers.h erreurs.h clavier.h io.h hotkeys.h \
files.h setup.h windows.h
files.h setup.h windows.h mountlist.h
$(OBJDIR)/io.o: io.c struct.h const.h io.h
$(OBJDIR)/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 io.h sdlscreen.h windows.h
$(OBJDIR)/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 io.h texte.h setup.h windows.h brush.h realpath.h
readini.h saveini.h io.h texte.h setup.h windows.h brush.h palette.h
$(OBJDIR)/moteur.o: moteur.c const.h struct.h global.h loadsave.h graph.h divers.h \
special.h boutons.h operatio.h shade.h erreurs.h sdlscreen.h windows.h brush.h
$(OBJDIR)/mountlist.o: mountlist.h mountlist.c
special.h boutons.h operatio.h shade.h erreurs.h sdlscreen.h windows.h \
brush.h
$(OBJDIR)/mountlist.o: mountlist.c
$(OBJDIR)/op_c.o: op_c.c op_c.h struct.h const.h erreurs.h graph.h
$(OBJDIR)/operatio.o: operatio.c const.h struct.h global.h loadsave.h divers.h \
moteur.h graph.h operatio.h boutons.h pages.h erreurs.h sdlscreen.h brush.h windows.h
moteur.h graph.h operatio.h boutons.h pages.h erreurs.h sdlscreen.h \
brush.h windows.h
$(OBJDIR)/pages.o: pages.c global.h struct.h const.h loadsave.h pages.h graph.h \
erreurs.h divers.h windows.h
$(OBJDIR)/palette.o: palette.c const.h struct.h global.h loadsave.h divers.h \
@ -41,7 +46,8 @@ $(OBJDIR)/pxtall.o: pxtall.c global.h struct.h const.h loadsave.h sdlscreen.h \
divers.h pxsimple.h
$(OBJDIR)/pxwide.o: pxwide.c global.h struct.h const.h loadsave.h sdlscreen.h \
divers.h
$(OBJDIR)/readini.o: readini.c const.h global.h struct.h loadsave.h graph.h divers.h
$(OBJDIR)/readini.o: readini.c const.h global.h struct.h loadsave.h graph.h \
windows.h divers.h
$(OBJDIR)/readline.o: readline.c const.h struct.h global.h loadsave.h graph.h \
divers.h erreurs.h sdlscreen.h readline.h windows.h
$(OBJDIR)/realpath.o: realpath.c
@ -57,4 +63,5 @@ $(OBJDIR)/special.o: special.c const.h struct.h global.h loadsave.h graph.h \
$(OBJDIR)/texte.o: texte.c SFont.h struct.h const.h global.h loadsave.h sdlscreen.h \
io.h files.h
$(OBJDIR)/version.o: version.c
$(OBJDIR)/windows.o: windows.c windows.h graph.h moteur.h divers.h struct.h sdlscreen.h
$(OBJDIR)/windows.o: windows.c windows.h struct.h const.h global.h loadsave.h \
graph.h moteur.h divers.h sdlscreen.h erreurs.h

View File

@ -35,6 +35,7 @@
#include "clavier.h"
#include "sdlscreen.h"
#include "windows.h"
#include "palette.h"
word Palette_Compter_nb_couleurs_utilisees(dword* Tableau)
{
@ -76,9 +77,9 @@ void Set_palette(T_Palette Palette)
SDL_Color PaletteSDL[256];
for(i=0;i<256;i++)
{
PaletteSDL[i].r=Palette[i].R;
PaletteSDL[i].g=Palette[i].V;
PaletteSDL[i].b=Palette[i].B;
PaletteSDL[i].r=(Palette[i].R=Palette_Scale_Component(Palette[i].R));
PaletteSDL[i].g=(Palette[i].V=Palette_Scale_Component(Palette[i].V));
PaletteSDL[i].b=(Palette[i].B=Palette_Scale_Component(Palette[i].B));
}
SDL_SetPalette(Ecran_SDL, SDL_PHYSPAL | SDL_LOGPAL, PaletteSDL,0,256);
}

43
main.c
View File

@ -22,6 +22,15 @@
*/
#define VARIABLES_GLOBALES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <time.h>
#include <unistd.h>
#include <SDL.h>
#include <SDL_image.h>
#include "const.h"
#include "struct.h"
#include "global.h"
@ -30,14 +39,6 @@
#include "init.h"
#include "boutons.h"
#include "moteur.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <time.h>
#include <SDL.h>
#include <SDL_image.h>
#include <unistd.h>
#include "pages.h"
#include "files.h"
#include "loadsave.h"
@ -50,6 +51,7 @@
#include "setup.h"
#include "windows.h"
#include "brush.h"
#include "palette.h"
#if defined(__WIN32__)
#include <windows.h>
@ -72,6 +74,8 @@ void Afficher_syntaxe(void)
printf("Syntax: GFX2 [<arguments>] [<picture>]\n\n");
printf("<arguments> can be:]\n");
printf("\t/? /h /help for this help screen\n");
printf("\t/wide to emulate a video mode with wide pixels (2x1)\n");
printf("\t/tall to emulate a video mode with tall pixels (1x2)\n");
printf("\t/mode <videomode> to set a video mode\n\n");
printf("Available video modes:\n\n");
for (Indice_mode=0; Indice_mode<Nb_modes_video; Indice_mode++)
@ -209,6 +213,29 @@ void Analyse_de_la_ligne_de_commande(int argc,char * argv[])
{
Pixel_ratio = PIXEL_WIDE;
}
else if ( !strcmp(argv[Indice],"/rgb") )
{
// echelle des composants RGB
Indice++;
if (Indice<argc)
{
int Grad;
Grad = atoi(argv[Indice]);
if (Grad < 2 || Grad > 256)
{
Erreur(ERREUR_LIGNE_COMMANDE);
Afficher_syntaxe();
exit(0);
}
Set_Palette_RGB_Scale(Grad);
}
else
{
Erreur(ERREUR_LIGNE_COMMANDE);
Afficher_syntaxe();
exit(0);
}
}
else
{
// Si ce n'est pas un paramètre, c'est le nom du fichier à ouvrir

View File

@ -45,19 +45,31 @@ char * Libelle_reduction_palette[7]=
};
// Nombre de graduations pour une composante RGB
const int Graduations_RGB =256; // 24bit
//const int Graduations_RGB = 64; // VGA
//const int Graduations_RGB = 16; // Amiga
//const int Graduations_RGB = 3; // Amstrad CPC
int Graduations_RGB = 256; // 24bit
//int Graduations_RGB = 64; // VGA
//int Graduations_RGB = 16; // Amiga
//int Graduations_RGB = 4; // MSX2
//int Graduations_RGB = 3; // Amstrad CPC
// Nombre de graduations pour une composante dans le mode actuel
int Color_Count;
int Color_Count=256;
// Les composantes vont de 0 à (Color_Count-1)
int Color_Max;
int Color_Max=255;
// Le demi-pas est une quantité que l'on ajoute à une composante
// avant de faire un arrondi par division.
int Color_DemiPas;
int Color_DemiPas=0;
void Set_Palette_RGB_Scale(int Grad)
{
if (Grad>= 2 && Grad <= 256)
Graduations_RGB = Grad;
}
byte Palette_Scale_Component(byte Comp)
{
return ((Comp+128/Graduations_RGB)*(Graduations_RGB-1)/255*255+(Graduations_RGB&1?1:0))/(Graduations_RGB-1);
}
// Définir les unités pour les graduationss R G B ou H S V
void Unite_Composantes(int Count)
@ -93,7 +105,7 @@ void Modifier_Rouge(byte Couleur, short Nouvelle_teinte, T_Palette Palette)
if (Nouvelle_teinte>255)
Nouvelle_teinte=255;
// Arrondi
Nouvelle_teinte=255*((Nouvelle_teinte+Color_DemiPas)*Color_Max/255)/Color_Max;
Nouvelle_teinte=Palette_Scale_Component(Nouvelle_teinte);
Palette[Couleur].R=Nouvelle_teinte;
Set_color(Couleur,Palette[Couleur].R,Palette[Couleur].V,Palette[Couleur].B);
@ -107,7 +119,7 @@ void Modifier_Vert(byte Couleur, short Nouvelle_teinte, T_Palette Palette)
if (Nouvelle_teinte>255)
Nouvelle_teinte=255;
// Arrondi
Nouvelle_teinte=255*((Nouvelle_teinte+Color_DemiPas)*Color_Max/255)/Color_Max;
Nouvelle_teinte=Palette_Scale_Component(Nouvelle_teinte);
Palette[Couleur].V=Nouvelle_teinte;
Set_color(Couleur,Palette[Couleur].R,Palette[Couleur].V,Palette[Couleur].B);
@ -121,7 +133,7 @@ void Modifier_Bleu(byte Couleur, short Nouvelle_teinte, T_Palette Palette)
if (Nouvelle_teinte>255)
Nouvelle_teinte=255;
// Arrondi
Nouvelle_teinte=255*((Nouvelle_teinte+Color_DemiPas)*Color_Max/255)/Color_Max;
Nouvelle_teinte=Palette_Scale_Component(Nouvelle_teinte);
Palette[Couleur].B=Nouvelle_teinte;
Set_color(Couleur,Palette[Couleur].R,Palette[Couleur].V,Palette[Couleur].B);

View File

@ -20,3 +20,11 @@
*/
void Bouton_Palette(void);
void Bouton_Palette_secondaire(void);
// Choose the number of graduations for RGB components, from 2 to 256.
void Set_Palette_RGB_Scale(int);
// Scale a component (R, G or B) according to the current RGB graduations
// The resulting range is [0-255]
byte Palette_Scale_Component(byte Comp);