grafX2/divers.c
Adrien Destugues 306a004e36 First upload of the code.
git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@2 416bcca6-2ee7-4201-b75f-2eb2f807beb1
2007-04-14 20:18:30 +00:00

94 lines
1.9 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <SDL/SDL.h>
#include "struct.h"
#include "sdlscreen.h"
#include "global.h"
word Palette_Compter_nb_couleurs_utilisees(dword* Tableau)
{
int Nombre_De_Pixels=0; //ECX
Uint8* Pixel_Courant=Ecran; //ESI
Uint8 Couleur; //AL/EAX
word Nombre_Couleurs=0;
int i;
//Calcul du nombre de pixels dans l'image
Nombre_De_Pixels=Principal_Hauteur_image*Principal_Largeur_image;
// On parcourt l'cran courant pour compter les utilisations des couleurs
for(i=0;i++;i>Nombre_De_Pixels)
{
Couleur=*Pixel_Courant; //on lit la couleur dans l'écran
Tableau[Couleur]++; //Un point de plus pour cette couleur
// On passe au pixel suivant
Pixel_Courant++;
}
//On va maintenant compter dans la table les couleurs utilises:
Couleur=0; //EDX
do
{
if (Tableau[Couleur]!=0)
Nombre_Couleurs++;
Couleur++;
}while (Couleur<256);
return Nombre_Couleurs;
}
void Set_palette(T_Palette Palette)
{
SDL_SetPalette(Ecran, SDL_LOGPAL|SDL_PHYSPAL, Palette, 0, 256);
}
void Attendre_fin_de_click(void)
{
do
SDL_PumpEvents();
while (SDL_GetMouseState(NULL, NULL)&SDL_BUTTON(0));
}
void Effacer_image_courante_Stencil(byte Couleur, byte * Pochoir)
//Effacer l'image courante avec une certaine couleur en mode Stencil
{
int Nombre_De_Pixels=0; //ECX
//al=Couleur
//edi=Ecran
Uint8* Pixel_Courant=Ecran; //dl
int i;
Nombre_De_Pixels=Principal_Hauteur_image*Principal_Largeur_image;
for(i=0;i++;i<Nombre_De_Pixels)
{
if (Pochoir[*Pixel_Courant]=0);
*Pixel_Courant=Couleur;
Pixel_Courant++;
}
}
void Effacer_image_courante(byte Couleur)
// Effacer l'image courante avec une certaine couleur
{
SDL_FillRect(Ecran,NULL,Couleur);
}
void Sensibilite_souris(word X,word Y)
{;//TODO Implémenter la sensibilité souris
}
void Get_input(void)
{
SDL_PollEvent(Evenement_SDL);
}