begin process at 2012 05 27 18:43:09
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

Graphique

 > MODE GRAPHIQUE VESA AVEC DJGPP EN C

MODE GRAPHIQUE VESA AVEC DJGPP EN C


 Information sur la source

Note :
Aucune note
Catégorie :Graphique Niveau :Débutant Date de création :09/02/2003 Date de mise à jour :09/02/2003 22:30:07 Vu / téléchargé :3 336 / 196

Auteur : Trillian

Ecrire un message privé
Commentaire sur cette source (2)
Ajouter un commentaire et/ou une note

 Description

Présentation de ma bibliotheque graphique VESA en utilisant DJGPP :
Gère l'affichage graphique directe, un ou plusieurs tampons graphiques, couleur en hexadecimal (0xFFFFFF), Obtenir des infos sur les différents modes VESA...

Source

  • #ifndef INCLUDE_go32
  • #define INCLUDE_go32
  • #include <go32.h>
  • #endif
  • #ifndef INCLUDE_dpmi
  • #define INCLUDE_dpmi
  • #include <dpmi.h>
  • #endif
  • #ifndef INCLUDE_farptr
  • #define INCLUDE_farptr
  • #include <sys\farptr.h>
  • #endif
  • #ifndef INCLUDE_movedata
  • #define INCLUDE_movedata
  • #include <sys\movedata.h>
  • #endif
  • #ifndef INCLUDE_pc
  • #define INCLUDE_pc
  • #include <pc.h>
  • #endif
  • typedef struct t_vesa_info//table d'information sur VESA
  • {
  • unsigned char vesa_signature[4] __attribute__ ((packed));
  • unsigned char version_secondaire __attribute__ ((packed));
  • unsigned char version_principale __attribute__ ((packed));
  • unsigned long ptr_nom_fabricant __attribute__ ((packed));
  • unsigned long performance __attribute__ ((packed));
  • unsigned long ptr_modes_video __attribute__ ((packed));
  • unsigned short memoire_64k __attribute__ ((packed));
  • char reserve[484] __attribute__ ((packed));
  • } t_vesa_info;
  • typedef struct t_vesa_info_mode//table d'information sur le mode VESA en cours
  • {
  • unsigned short attribut_du_mode __attribute__ ((packed));
  • unsigned char attribut_fenetre_A __attribute__ ((packed));
  • unsigned char attribut_fenetre_B __attribute__ ((packed));
  • unsigned short pas_fenetre __attribute__ ((packed));
  • unsigned short taille_fenetre __attribute__ ((packed));
  • unsigned short segment_fenetre_A __attribute__ ((packed));
  • unsigned short segment_fenetre_B __attribute__ ((packed));
  • unsigned long pointeur_proc_fenetre __attribute__ ((packed));
  • unsigned short octets_par_ligne __attribute__ ((packed));
  • unsigned short resolution_horizontale __attribute__ ((packed));
  • unsigned short resolution_verticale __attribute__ ((packed));
  • unsigned char taille_caractere_horizontale __attribute__ ((packed));
  • unsigned char taille_caractere_verticale __attribute__ ((packed));
  • unsigned char nombre_de_plans __attribute__ ((packed));
  • unsigned char bits_par_points __attribute__ ((packed));
  • unsigned char nombre_de_banques __attribute__ ((packed));
  • unsigned char modele_memoire __attribute__ ((packed));
  • unsigned char taille_des_banques __attribute__ ((packed));
  • unsigned char nombre_de_pages __attribute__ ((packed));
  • unsigned char reserve __attribute__ ((packed));
  • unsigned char masques_taille_rouge __attribute__ ((packed));
  • unsigned char masques_pos_rouge __attribute__ ((packed));
  • unsigned char masques_taille_vert __attribute__ ((packed));
  • unsigned char masques_pos_vert __attribute__ ((packed));
  • unsigned char masques_taille_bleu __attribute__ ((packed));
  • unsigned char masques_pos_bleu __attribute__ ((packed));
  • unsigned char masques_taille_res __attribute__ ((packed));
  • unsigned char masques_pos_res __attribute__ ((packed));
  • unsigned char info_couleur_directe __attribute__ ((packed));
  • unsigned long adresse_lineaire __attribute__ ((packed));
  • unsigned long offset __attribute__ ((packed));
  • unsigned long memoire_off __attribute__ ((packed));
  • unsigned char reserve_bis[206] __attribute__ ((packed));
  • } t_vesa_info_mode;
  • unsigned long ptr_mode_en_cours;
  • long dos_buffer;
  • t_vesa_info_mode table_mode;
  • t_vesa_info table_vesa;
  • __dpmi_regs registres;
  • char vesa_info(t_vesa_info *table)//Remplir la table d'information VESA
  • {
  • _farsetsel(_dos_ds);
  • dos_buffer=__tb & 0xFFFFF;
  • dosmemput("VESA",4,dos_buffer);
  • registres.x.ax=0x4F00;
  • registres.x.di=dos_buffer & 0xF;
  • registres.x.es=dos_buffer >> 4;
  • __dpmi_int(0x10,&registres);
  • if (registres.x.ax=0x004F)
  • dosmemget(dos_buffer,sizeof(t_vesa_info),table);
  • ptr_mode_en_cours=((table->ptr_modes_video & 0xFFFF0000) >> 12)+(table->ptr_modes_video & 0xFFFF);
  • return(registres.x.ax==0x004F);
  • }
  • char vesa_info_mode(t_vesa_info_mode *table, unsigned short mode)//Remplir la table d'information sur le mode en cours
  • {
  • registres.x.ax=0x4F01;
  • registres.x.cx=mode;
  • registres.x.di=dos_buffer & 0xF;
  • registres.x.es=dos_buffer >> 4;
  • __dpmi_int(0x10,&registres);
  • if (registres.x.ax=0x004F)
  • dosmemget(dos_buffer,sizeof(t_vesa_info_mode),table);
  • return(registres.x.ax==0x004F);
  • }
  • unsigned short vesa_first_mode(void)//Obtenir le premier mode VESA disponible
  • {
  • return(_farnspeekw(ptr_mode_en_cours));
  • }
  • unsigned short vesa_next_mode(void)//Obtenir un autre mode disponible
  • {
  • ptr_mode_en_cours+=2;
  • return(_farnspeekw(ptr_mode_en_cours));
  • }
  • char vesa_mode(unsigned short mode)//Activer le mode VESA
  • {
  • registres.x.ax=0x4F02;
  • registres.x.bx=mode;
  • __dpmi_int(0x10,&registres);
  • return(registres.x.ax==0x004F);
  • }
  • unsigned int numero_de_fenetre, taille_fenetre_octets, octets_par_point, quelle_fenetre;
  • unsigned short numero_de_fenetre_actuelle, segment_fenetre, increment_fenetre;
  • void recherche_fenetre(unsigned short mode_en_cours)//Rechercher le "port" d'écriture
  • {
  • quelle_fenetre=0;
  • if ((table_mode.attribut_fenetre_A & 5)==5 )
  • segment_fenetre=table_mode.segment_fenetre_A;
  • else if ((table_mode.attribut_fenetre_B & 5)==5)
  • {
  • segment_fenetre=table_mode.segment_fenetre_B;
  • quelle_fenetre=1;
  • }
  • else
  • if ((table_mode.attribut_du_mode & 16) == 0)
  • {
  • segment_fenetre=0xB800;
  • exit(1);
  • }
  • else
  • segment_fenetre=0xA000;
  • numero_de_fenetre_actuelle=0xFFFF;
  • octets_par_point=(table_mode.bits_par_points+7) >> 3;
  • increment_fenetre=table_mode.taille_fenetre / table_mode.pas_fenetre;
  • taille_fenetre_octets=table_mode.taille_fenetre;
  • taille_fenetre_octets=taille_fenetre_octets << 10;
  • if(!(vesa_mode(mode_en_cours)))
  • {
  • printf("Le mode n'est pas support? !\n");
  • getch();
  • exit(1);
  • }
  • }
  • void affiche_pixel(int x, int y,unsigned int couleur)//afficher un pixel directement sur l'écran
  • {
  • int i;
  • unsigned int offset_point;
  • offset_point=y*table_mode.octets_par_ligne+x*octets_par_point;
  • for (i=0;i<octets_par_point;i++)
  • {
  • numero_de_fenetre=(offset_point+i) / taille_fenetre_octets;
  • if (numero_de_fenetre!=numero_de_fenetre_actuelle)
  • {
  • numero_de_fenetre_actuelle=numero_de_fenetre;
  • registres.x.ax=0x4F05;
  • registres.x.bx=quelle_fenetre;
  • registres.x.dx=numero_de_fenetre*increment_fenetre;
  • __dpmi_int(0x10,&registres);
  • }
  • _farnspokeb((segment_fenetre << 4)+(offset_point+i) % taille_fenetre_octets,(couleur >> (i << 3)) &0xFF);
  • }
  • }
  • void affiche_pix(unsigned char * buffer,int x, int y, unsigned long int couleur)//Mettre en memoire un pixel dans un tampon
  • {
  • unsigned int offset_point;
  • offset_point = y*table_mode.octets_par_ligne + x * octets_par_point;
  • switch (octets_par_point)
  • {
  • case 2:
  • buffer[offset_point+1] = (couleur >> 8)&0x0FF;
  • buffer[offset_point] = (couleur & 0x0FF);
  • break;
  • case 3:
  • case 4:
  • buffer[offset_point+3] = (couleur >> 24) & 0x00FF;
  • buffer[offset_point+2] = (couleur >> 16) & 0x00FF;
  • buffer[offset_point+1] = (couleur >> 8) & 0x00FF;
  • buffer[offset_point] = (couleur & 0x00FF);
  • break;
  • }
  • }
  • void affiche_tampon(unsigned char * buffer)//Afficher un tampon memoire
  • {
  • int i;
  • unsigned int offset_point;
  • for(offset_point = 0; offset_point<table_mode.octets_par_ligne*table_mode.resolution_verticale; offset_point += octets_par_point)
  • {
  • for (i=0;i<octets_par_point;i++)
  • {
  • numero_de_fenetre=(offset_point+i) / taille_fenetre_octets;
  • if (numero_de_fenetre!=numero_de_fenetre_actuelle)
  • {
  • numero_de_fenetre_actuelle=numero_de_fenetre;
  • registres.x.ax=0x4F05;
  • registres.x.bx=quelle_fenetre;
  • registres.x.dx=numero_de_fenetre*increment_fenetre;
  • __dpmi_int(0x10,&registres);
  • }
  • _farnspokeb((segment_fenetre << 4)+(offset_point+i) % taille_fenetre_octets, (buffer[offset_point+i]) &0xFF);
  • }
  • }
  • }
#ifndef INCLUDE_go32
#define INCLUDE_go32
#include <go32.h>
#endif

#ifndef INCLUDE_dpmi
#define INCLUDE_dpmi
#include <dpmi.h>
#endif

#ifndef INCLUDE_farptr
#define INCLUDE_farptr
#include <sys\farptr.h>
#endif

#ifndef INCLUDE_movedata
#define INCLUDE_movedata
#include <sys\movedata.h>
#endif

#ifndef INCLUDE_pc
#define INCLUDE_pc
#include <pc.h>
#endif

typedef struct t_vesa_info//table d'information sur VESA
{
  unsigned char  vesa_signature[4]            __attribute__ ((packed));
  unsigned char  version_secondaire           __attribute__ ((packed));
  unsigned char  version_principale           __attribute__ ((packed));
  unsigned long  ptr_nom_fabricant            __attribute__ ((packed));
  unsigned long  performance                  __attribute__ ((packed));
  unsigned long  ptr_modes_video              __attribute__ ((packed));
  unsigned short memoire_64k                  __attribute__ ((packed));
  char          reserve[484]                  __attribute__ ((packed));
} t_vesa_info;

typedef struct t_vesa_info_mode//table d'information sur le mode VESA en cours
{
  unsigned short attribut_du_mode             __attribute__ ((packed));
  unsigned char  attribut_fenetre_A           __attribute__ ((packed));
  unsigned char  attribut_fenetre_B           __attribute__ ((packed));
  unsigned short pas_fenetre                  __attribute__ ((packed));
  unsigned short taille_fenetre               __attribute__ ((packed));
  unsigned short segment_fenetre_A            __attribute__ ((packed));
  unsigned short segment_fenetre_B            __attribute__ ((packed));
  unsigned long  pointeur_proc_fenetre        __attribute__ ((packed));
  unsigned short octets_par_ligne             __attribute__ ((packed));
  unsigned short resolution_horizontale       __attribute__ ((packed));
  unsigned short resolution_verticale         __attribute__ ((packed));
  unsigned char  taille_caractere_horizontale __attribute__ ((packed));
  unsigned char  taille_caractere_verticale   __attribute__ ((packed));
  unsigned char  nombre_de_plans              __attribute__ ((packed));
  unsigned char  bits_par_points              __attribute__ ((packed));
  unsigned char  nombre_de_banques            __attribute__ ((packed));
  unsigned char  modele_memoire               __attribute__ ((packed));
  unsigned char  taille_des_banques           __attribute__ ((packed));
  unsigned char  nombre_de_pages              __attribute__ ((packed));
  unsigned char  reserve                      __attribute__ ((packed));
  unsigned char  masques_taille_rouge         __attribute__ ((packed));
  unsigned char  masques_pos_rouge            __attribute__ ((packed));
  unsigned char  masques_taille_vert          __attribute__ ((packed));
  unsigned char  masques_pos_vert             __attribute__ ((packed));
  unsigned char  masques_taille_bleu          __attribute__ ((packed));
  unsigned char  masques_pos_bleu             __attribute__ ((packed));
  unsigned char  masques_taille_res           __attribute__ ((packed));
  unsigned char  masques_pos_res              __attribute__ ((packed));
  unsigned char  info_couleur_directe         __attribute__ ((packed));
  unsigned long  adresse_lineaire             __attribute__ ((packed));
  unsigned long  offset                       __attribute__ ((packed));
  unsigned long  memoire_off                  __attribute__ ((packed));
  unsigned char  reserve_bis[206]             __attribute__ ((packed));
} t_vesa_info_mode;

unsigned long ptr_mode_en_cours;
long dos_buffer;
t_vesa_info_mode table_mode;
t_vesa_info table_vesa;
__dpmi_regs registres;

char vesa_info(t_vesa_info *table)//Remplir la table d'information VESA
{
	_farsetsel(_dos_ds);
	dos_buffer=__tb & 0xFFFFF;
	dosmemput("VESA",4,dos_buffer);
	registres.x.ax=0x4F00;
	registres.x.di=dos_buffer & 0xF;
	registres.x.es=dos_buffer >> 4;
	__dpmi_int(0x10,&registres);
	if (registres.x.ax=0x004F)
		dosmemget(dos_buffer,sizeof(t_vesa_info),table);
	ptr_mode_en_cours=((table->ptr_modes_video & 0xFFFF0000) >> 12)+(table->ptr_modes_video & 0xFFFF);

	return(registres.x.ax==0x004F);
}



char vesa_info_mode(t_vesa_info_mode *table, unsigned short mode)//Remplir la table d'information sur le mode en cours
{
	registres.x.ax=0x4F01;
	registres.x.cx=mode;
	registres.x.di=dos_buffer & 0xF;
	registres.x.es=dos_buffer >> 4;
	__dpmi_int(0x10,&registres);
	if (registres.x.ax=0x004F)
		dosmemget(dos_buffer,sizeof(t_vesa_info_mode),table);

	return(registres.x.ax==0x004F);
}


unsigned short vesa_first_mode(void)//Obtenir le premier mode VESA disponible
{
	return(_farnspeekw(ptr_mode_en_cours));
}


unsigned short vesa_next_mode(void)//Obtenir un autre mode disponible
{
	ptr_mode_en_cours+=2;
	return(_farnspeekw(ptr_mode_en_cours));
}


char vesa_mode(unsigned short mode)//Activer le mode VESA
{
	registres.x.ax=0x4F02;
	registres.x.bx=mode;
	__dpmi_int(0x10,&registres);

	return(registres.x.ax==0x004F);
}

unsigned int numero_de_fenetre, taille_fenetre_octets, octets_par_point, quelle_fenetre;
unsigned short numero_de_fenetre_actuelle, segment_fenetre, increment_fenetre;

void recherche_fenetre(unsigned short mode_en_cours)//Rechercher le "port" d'écriture
{
	quelle_fenetre=0;
	if ((table_mode.attribut_fenetre_A & 5)==5 )
		segment_fenetre=table_mode.segment_fenetre_A;
	else if ((table_mode.attribut_fenetre_B & 5)==5)
	{
		segment_fenetre=table_mode.segment_fenetre_B;
		quelle_fenetre=1;
	}
	else
	if ((table_mode.attribut_du_mode & 16) == 0)
	{
		segment_fenetre=0xB800;
		exit(1);
	}
	else
		segment_fenetre=0xA000;

	numero_de_fenetre_actuelle=0xFFFF;
	octets_par_point=(table_mode.bits_par_points+7) >> 3;
	increment_fenetre=table_mode.taille_fenetre / table_mode.pas_fenetre;
	taille_fenetre_octets=table_mode.taille_fenetre;
	taille_fenetre_octets=taille_fenetre_octets << 10;
	if(!(vesa_mode(mode_en_cours)))
	{
		printf("Le mode n'est pas support? !\n");
		getch();
		exit(1);
	}
}

void affiche_pixel(int x, int y,unsigned int couleur)//afficher un pixel directement sur l'écran
{	
	int i;
	unsigned int offset_point;
	offset_point=y*table_mode.octets_par_ligne+x*octets_par_point;
	for (i=0;i<octets_par_point;i++) 
	{
          
		numero_de_fenetre=(offset_point+i) / taille_fenetre_octets;
		if (numero_de_fenetre!=numero_de_fenetre_actuelle)
		{ 
			numero_de_fenetre_actuelle=numero_de_fenetre; 
			registres.x.ax=0x4F05; 
			registres.x.bx=quelle_fenetre;
			registres.x.dx=numero_de_fenetre*increment_fenetre;
			__dpmi_int(0x10,&registres);
		}
          	_farnspokeb((segment_fenetre << 4)+(offset_point+i) % taille_fenetre_octets,(couleur >> (i << 3)) &0xFF);
	}
}

void affiche_pix(unsigned char * buffer,int x, int y, unsigned long int couleur)//Mettre en memoire un pixel dans un tampon
{
	unsigned int offset_point;
	offset_point = y*table_mode.octets_par_ligne + x * octets_par_point;
	switch (octets_par_point)
	{
		case 2:
			buffer[offset_point+1] = (couleur >> 8)&0x0FF;
			buffer[offset_point] = (couleur & 0x0FF);
			break;
		case 3:
		case 4:
			buffer[offset_point+3] = (couleur >> 24) & 0x00FF;
			buffer[offset_point+2] = (couleur >> 16) & 0x00FF;
			buffer[offset_point+1] = (couleur >> 8) & 0x00FF;
			buffer[offset_point] = (couleur & 0x00FF);
			break;
	}	
}

void affiche_tampon(unsigned char * buffer)//Afficher un tampon memoire
{	
	int i;
	unsigned int offset_point;
	for(offset_point = 0; offset_point<table_mode.octets_par_ligne*table_mode.resolution_verticale; offset_point += octets_par_point)
	{
		for (i=0;i<octets_par_point;i++) 
		{
          
			numero_de_fenetre=(offset_point+i) / taille_fenetre_octets;
			if (numero_de_fenetre!=numero_de_fenetre_actuelle)
			{ 
				numero_de_fenetre_actuelle=numero_de_fenetre; 
				registres.x.ax=0x4F05; 
				registres.x.bx=quelle_fenetre;
				registres.x.dx=numero_de_fenetre*increment_fenetre;
				__dpmi_int(0x10,&registres);
			}
        		_farnspokeb((segment_fenetre << 4)+(offset_point+i) % taille_fenetre_octets, (buffer[offset_point+i]) &0xFF);
		}
	}
}

 Conclusion

Fonctionne avec les modes 15, 16, 24, 32 bits. Le 8 bits doit etre testé !

 Fichier Zip

Les Membres Club peuvent télécharger directement un fichier contenu dans le zip sans télécharger le zip en entier !

Télécharger le zip


 Sources du même auteur

Source avec Zip GESTION DE LA PALETTE ET AFFICHAGE D'UN .PCX EN 8BITS SOUS D...
Source avec Zip BIBLIOTHEQUE GRAPHIQUE MODE VESA SOUS DJGPP (VERSION 2.0)

 Sources de la même categorie

Source avec Zip Source avec une capture PLANNING D'EQUIPE par grephit
Source avec Zip APPLICATION DE DESSIN DE QUELQUES FIGURES par laguchori
Source avec Zip Source avec une capture HDR EXPOSURE FUSION par mecrosoft
Source avec Zip Source avec une capture IRC CLIENT MULTISERVEUR EN MFC (TXIRC) par TeniX
Source avec Zip ENTETE DU FICHIER BMP (BIPMAP) par k.Lutchi

Commentaires et avis

Commentaire de trinitacs le 12/02/2003 17:21:03

Continues à rajouter des primitives de dessins et rajoutes des fonctions pour gérer les sprites.

Je te conseil de faire une structure ou une classe BITMAP car je n'en ai pas vu.

Commentaire de madhatter le 06/06/2003 10:04:49

ceci est un test

 Ajouter un commentaire




Nos sponsors


Sondage...

CalendriCode

Mai 2012
LMMJVSD
 123456
78910111213
14151617181920
21222324252627
28293031   

Consulter la suite du CalendriCode

A découvrir



 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,421 sec (4)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales