Connaitre le caractere affiche a la position xy de l'ecran [gcc]

Description

Bon voici un include avec 3 fonctions, une pour connaitre le caractere, une la couleur et une la couleur de fond de l'emplacement XY de l'ecran. C'est parfois tres utile.

Source / Exemple :


#ifndef __POSINFO_include_posinfo_h__ /*EMPECHE QUE LA COMPILATION FOIRE SI LE*/
#define __POSINFO_include_posinfo_h__/*FICHIER EST INCLUS PLUS QU'UNE FOIS*/

#include <conio.h> /*POUR gotoxy, wherex et wherey*/
#include <dos.h>   /*POUR LES INTERRUPTIONS DU BIOS*/ 

unsigned char poscara(int X,int Y);/*RENVOIE LE CARACTERE A L'EMPLACEMENT XY*/
int       poscolor(int X,int Y); /*RENVOIE LA COULEUR DE L'EMPLACEMENT XY*/
int       posbackcolor(int X,int Y);/*RENVOIE LA COULEUR DE FOND A L'EMPLACEMENT XY*/

unsigned char poscara(int X,int Y)
{
  union REGS   bios;/*DEFINIT UNE UNION REGS*/
  int          x=wherex(); /*MEMORISE LA POSITION X ACTUELLE DE L'ECRAN*/
  int          y=wherey();/*MEMORISE LA POSITION Y ACTUELLE DE L'ECRAN*/                     
    
  gotoxy(X,Y);/*VA A LA POSITION DU CARACTERE DEMANDE*/                                         
  bios.h.ah=0x0008;/*STOCKE 0x0008 DANS AH*/
  bios.h.bh=0x0000; /*STOCKE 0x0000 DANS BH*/                      
  int86(0x0010,&bios,&bios);/*GENERE L'INTERRUPTION 0x0010 DU BIOS*/ 
  gotoxy(x,y); /*RETOURNE AUX POSITION MEMORISEES PRECEDEMMENT*/
  return bios.h.al;/*RENVOIE LE CARACTERE QUI EST STOCKE DANS AL*/
}  

int poscolor(int X,int Y) 
{
  union REGS bios;/*DEFINIT UNE UNION REGS*/  
  int      x=wherex();/*MEMORISE LA POSITION X ACTUELLE DE L'ECRAN*/
  int      y=wherey();/*MEMORISE LA POSITION Y ACTUELLE DE L'ECRAN*/                         
   
  gotoxy(X,Y);//VA A LA POSITION DU CARACTERE DEMANDE                                          
  bios.h.ah=0x0008; /*STOCKE 0x0008 DANS AH*/
  bios.h.bh=0x0000; /*STOCKE 0x0000 DANS BH*/                         
  int86(0x0010,&bios,&bios); /*GENERE L'INTERRUPTION 0x0010 DU BIOS*/
  gotoxy(x,y); /*RETOURNE AUX POSITION MEMORISEES PRECEDEMMENT*/
  return bios.h.ah-(16*(bios.h.ah/16));/*RENVOIE LA COULEUR QUI EST STOCKEE DANS  LES 4 PREMIERS BITS DE AH*/ 
}    

int posbackcolor(int X,int Y) 
{
  union REGS   bios;  /*DEFINIT UNE UNION REGS*/
  int    x=wherex();/*MEMORISE LA POSITION X ACTUELLE DE L'ECRAN*/
  int    y=wherey();/*MEMORISE LA POSITION Y ACTUELLE DE L'ECRAN*/                      
    
  gotoxy(X,Y);/*VA A LA POSITION DU CARACTERE DEMANDE*/                                         
  bios.h.ah=0x0008;/*STOCKE 0x0008 DANS AH*/
  bios.h.bh=0x0000;/*STOCKE 0x0000 DANS BH*/                        
  int86(0x0010,&bios,&bios); /*GENERE L'INTERRUPTION 0x0010 DU BIOS*/
  gotoxy(x,y);/*RETOURNE AUX POSITION MEMORISEES PRECEDEMMENT*/            
  return bios.h.ah/16;/*RENVOIE LA COULEUR QUI EST STOCKEE DANS LES 4 DERNIERS BITS DE AH*/
} 

#endif

Conclusion :


excusez moi ça foire completement avec les commentaires je vous conseille de telecharger le zip

Codes Sources

A voir également

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.