grafX2/divers.c
Adrien Destugues 47b59aa70d Checkin
git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@11 416bcca6-2ee7-4201-b75f-2eb2f807beb1
2007-08-12 14:39:24 +00:00

116 lines
2.2 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);
}
void Initialiser_chrono(dword Delai)
{// Démarrer le chrono
push ebp
mov ebp,esp
arg Delai:dword
mov eax,Delai
mov Chrono_delay,eax
xor ah,ah
int 1Ah
mov word ptr[Chrono_cmp+0],dx
mov word ptr[Chrono_cmp+2],cx
mov esp,ebp
pop ebp
return;
}