begin process at 2012 05 27 15:58:47
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

Graphique

 > EFFET DE FLAMME (SOUS DOS EN 320*200) (BC++)

EFFET DE FLAMME (SOUS DOS EN 320*200) (BC++)


 Information sur la source

Note :
10 / 10 - par 1 personne
10,00 / 10

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10
Catégorie :Graphique Niveau :Initié Date de création :28/01/2002 Date de mise à jour :28/01/2002 22:49:18 Vu :4 466

Auteur : Croqmort

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

 Description

alors en fait c'est un effet de flammes tout con (avec smouth montant) mais avec une petit suptilité, on peut ecrire des lettres en flammés
bon alors quand vous allez compiler votre prog et qui va se lancer, normalement vous aller avoir un ecran noir, la il suffit d'appuyer sur une lettre pour qu'elle s'affiche tout en flammé !

Source

  • #include <math.h>
  • #include <alloc.h>
  • #include <stdlib.h>
  • #include <time.h>
  • #include <conio.h>
  • #include <mem.h>
  • void mode13h(void);
  • void modetexte(void);
  • void palette_degrader(char,char,char);
  • void wait_retrace(void);
  • void SetUpPage(void);
  • void ClosePage(void);
  • void CopyPageToScreen(void);
  • unsigned char smouth_montant(int,int);
  • void ajoute_parasite(void);
  • void BltText(char far*, int, int, unsigned char,unsigned char);
  • void BltText_parasite(char far*, int, int, unsigned char,unsigned char);
  • unsigned char far *vram;
  • void main(void){
  • randomize();
  • unsigned char res,c,c2;
  • int x,y,tx=10,ty=60,pt=1,i=0;
  • unsigned char *msg;
  • msg = (unsigned char*)malloc(100);
  • vram = (unsigned char far*)0xA0000000L;
  • mode13h();
  • palette_degrader(63,63,63);
  • SetUpPage();
  • _fmemset(vram, 0, 65300L);
  • memset(msg, 0, 100);
  • again:
  • do{
  • BltText_parasite(msg, tx, ty, 32,3);
  • for (x=0;x<320;x++)
  • for (y=50;y<150;y++)
  • vram[x+((y<<8)+(y<<6))]=smouth_montant(x,y);
  • wait_retrace();
  • CopyPageToScreen();
  • res = kbhit();
  • }while(!res);
  • c=getch();
  • if(c==0){
  • c2=getch();
  • if(c2==59){
  • _fmemset(vram, 0, 65300L);
  • goto again;
  • }
  • if(c2==60){
  • memset(msg, 0, 100);
  • i=0;
  • goto again;
  • }
  • }
  • if(c==8){
  • i--;
  • msg[i] = 0;
  • goto again;
  • }
  • if(((c >= 32)&&(c <= 125))||(c == 13)||(c==130)||(c==133)||(c==138)){
  • msg[i] = c;
  • i++;
  • goto again;
  • }
  • getch();
  • ClosePage();
  • modetexte();
  • }
  • void mode13h(void){
  • asm{
  • mov AH,0
  • mov AL,0x13
  • int 10h
  • }
  • }
  • void modetexte(void){
  • asm{
  • mov AH,0
  • mov AL,0x03
  • int 10h
  • }
  • }
  • unsigned char smouth_montant(int x,int y){
  • unsigned char m;
  • unsigned int offs;
  • offs = x+(y<<8)+(y<<6);
  • m = vram[offs-319];
  • m += vram[offs-320];
  • m += vram[offs-321];
  • m += vram[offs+320];
  • m += vram[offs+321];
  • m += vram[offs+319];
  • m += vram[offs-1];
  • m += vram[offs+1];
  • m = floor(m>>3);
  • if (vram[offs]>m) m=(m+vram[offs])>>1;
  • if(m>32) m=32;
  • return m;
  • }
  • void palette_degrader(char R, char G, char B){
  • B=0;
  • G=0;
  • R=0;
  • bool c1=false,c2=false;
  • for (int i=33;i>0;i--){
  • outp(0x3C8, i);
  • outp(0x3C9, R);
  • outp(0x3C9, G);
  • outp(0x3C9, B);
  • if ((R<60)&&(!c1)) R=R+10;
  • if ((G<60)&&(!c1)) G=G+5;
  • if ((G>=60)&&(!c1)) c1=true;
  • if ((G>0)&&(c1)&&(!c2)) G=G-10;
  • if (G<0) G=0;
  • if ((G==0)&&(c1)&&(!c2)) c2=true;
  • if ((R>0)&&(c2)) R=R-3;
  • if (R<0) R=0;
  • if ((R==0)&&(c2)) c2=true;
  • }
  • }
  • void wait_retrace(void){
  • unsigned char Status;
  • do{
  • Status = inportb(0x3DA);
  • }while((Status & 0x08));
  • do{
  • Status = inportb(0x3DA);
  • }while(!(Status & 0x08));
  • }
  • void SetUpPage()
  • {
  • vram = (unsigned char far*)farmalloc(70000L);
  • }
  • void ClosePage()
  • {
  • farfree(vram);
  • vram = (unsigned char far*)0xA0000000L;
  • }
  • void CopyPageToScreen()
  • {
  • unsigned char far* scrn = (unsigned char far *)0xA0000000L;
  • unsigned char far* virscrn = &vram[0];
  • asm{
  • push ds
  • les di, scrn
  • lds si, virscrn
  • mov cx, 35000
  • rep movsw
  • pop ds
  • }
  • }
  • void ajoute_parasite(void){
  • int x,y;
  • unsigned char col;
  • for (int i = 0;i < 26;i++){
  • x = rand() % 320;
  • y = (rand() % 2)+200;
  • col = 32;
  • vram[x+y*320]=col;
  • vram[x+y*320+1]=col;
  • }
  • }
  • void BltText_parasite(char far *text, int x, int y, unsigned char color,unsigned char G)
  • {
  • int offset = (y << 8) + (y<<6) + x, oldx=x;
  • unsigned char far *romptr;
  • unsigned char far *charset = (unsigned char far*)0xF000FA6EL;
  • romptr = charset + (*text) * 8;
  • unsigned char mask = 0x80;
  • while(*text != NULL)
  • {
  • for(int j = 0; j<8; j++)
  • {
  • mask = 0x80;
  • for(int k =0; k<G*8; k+=G)
  • {
  • if(*romptr & mask)
  • for(int xx = 0;xx<G;xx++)
  • for(int yy = 0;yy<G;yy++)
  • if(!((rand()%2)==0))
  • vram[offset + k + xx +(yy*320)] = color;
  • mask = (mask >> 1);
  • }
  • offset += 320*G;
  • romptr++;
  • }
  • x += G*8;
  • text++;
  • if (text[0] == 13){
  • text++;
  • y+=10*G;
  • x=oldx;
  • }
  • offset = (y<<8) + (y<<6) + x;
  • romptr = charset + (*text) * 8;
  • }
  • }
  • void BltText(char far *text, int x, int y, unsigned char color,unsigned char G)
  • {
  • int offset = (y << 8) + (y<<6) + x, oldx=x;
  • unsigned char far *romptr;
  • unsigned char far *charset = (unsigned char far*)0xF000FA6EL;
  • romptr = charset + (*text) * 8;
  • unsigned char mask = 0x80;
  • while(*text != NULL)
  • {
  • for(int j = 0; j<8; j++)
  • {
  • mask = 0x80;
  • for(int k =0; k<G*8; k+=G)
  • {
  • if(*romptr & mask)
  • for(int xx = 0;xx<G;xx++)
  • for(int yy = 0;yy<G;yy++)
  • vram[offset + k + xx +(yy*320)] = color;
  • mask = (mask >> 1);
  • }
  • offset += 320*G;
  • romptr++;
  • }
  • x += G*8;
  • text++;
  • if (text[0] == 13){
  • text++;
  • y+=10*G;
  • x=oldx;
  • }
  • offset = (y<<8) + (y<<6) + x;
  • romptr = charset + (*text) * 8;
  • }
  • }
#include <math.h>
#include <alloc.h>
#include <stdlib.h>
#include <time.h>
#include <conio.h>
#include <mem.h>

void mode13h(void);
void modetexte(void);
void palette_degrader(char,char,char);
void wait_retrace(void);
void SetUpPage(void);
void ClosePage(void);
void CopyPageToScreen(void);
unsigned char smouth_montant(int,int);
void ajoute_parasite(void);
void BltText(char far*, int, int, unsigned char,unsigned char);
void BltText_parasite(char far*, int, int, unsigned char,unsigned char);

unsigned char far *vram;

void main(void){
randomize();
unsigned char res,c,c2;
int x,y,tx=10,ty=60,pt=1,i=0;
unsigned char *msg;
msg = (unsigned char*)malloc(100);
vram = (unsigned char far*)0xA0000000L;

mode13h();
palette_degrader(63,63,63);
SetUpPage();
_fmemset(vram, 0, 65300L);
memset(msg, 0, 100);
again:
do{
BltText_parasite(msg, tx, ty, 32,3);
for (x=0;x<320;x++)
	for (y=50;y<150;y++)
		vram[x+((y<<8)+(y<<6))]=smouth_montant(x,y);

wait_retrace();
CopyPageToScreen();
res = kbhit();
}while(!res);
c=getch();

if(c==0){
c2=getch();

if(c2==59){
_fmemset(vram, 0, 65300L);
goto again;
}

if(c2==60){
memset(msg, 0, 100);
i=0;
goto again;
}

}

if(c==8){
i--;
msg[i] = 0;
goto again;
}

if(((c >= 32)&&(c <= 125))||(c == 13)||(c==130)||(c==133)||(c==138)){
	msg[i] = c;
	i++;
   goto again;
}

getch();
ClosePage();
modetexte();
}

void mode13h(void){
asm{
  mov AH,0
  mov AL,0x13
  int 10h
}
}

void modetexte(void){
asm{
  mov AH,0
  mov AL,0x03
  int 10h
}
}

unsigned char smouth_montant(int x,int y){
unsigned char m;
unsigned int offs;
offs = x+(y<<8)+(y<<6);
m = vram[offs-319];
m += vram[offs-320];
m += vram[offs-321];
m += vram[offs+320];
m += vram[offs+321];
m += vram[offs+319];
m += vram[offs-1];
m += vram[offs+1];
m = floor(m>>3);
if (vram[offs]>m) m=(m+vram[offs])>>1;
if(m>32) m=32;
return m;
}



void palette_degrader(char R, char G, char B){
B=0;
G=0;
R=0;
bool c1=false,c2=false;
for (int i=33;i>0;i--){
 outp(0x3C8, i);
 outp(0x3C9, R);
 outp(0x3C9, G);
 outp(0x3C9, B);

 if ((R<60)&&(!c1)) R=R+10;
 if ((G<60)&&(!c1)) G=G+5;
  if ((G>=60)&&(!c1)) c1=true;
 if ((G>0)&&(c1)&&(!c2)) G=G-10;
 if (G<0) G=0;
 if ((G==0)&&(c1)&&(!c2)) c2=true;
 if ((R>0)&&(c2)) R=R-3;
 if (R<0) R=0;
 if ((R==0)&&(c2)) c2=true;
 }
}

void wait_retrace(void){
 unsigned char Status;
 do{
   Status = inportb(0x3DA);
 }while((Status & 0x08));

 do{
   Status = inportb(0x3DA);
 }while(!(Status & 0x08));
 
}

void SetUpPage()
{
 vram = (unsigned char far*)farmalloc(70000L);
}

void ClosePage()
{
 farfree(vram);
 vram = (unsigned char far*)0xA0000000L;
}

void CopyPageToScreen()
{
 unsigned char far* scrn = (unsigned char far *)0xA0000000L;
 unsigned char far* virscrn = &vram[0];
asm{
 push ds
 les di, scrn
 lds si, virscrn
 mov cx, 35000
 rep movsw
 pop ds
 }
}

void ajoute_parasite(void){
int x,y;
unsigned char col;
for (int i = 0;i < 26;i++){
x = rand() % 320;
y = (rand() % 2)+200;
col = 32;
vram[x+y*320]=col;
vram[x+y*320+1]=col;
}

}
void BltText_parasite(char far *text, int x, int y, unsigned char color,unsigned char G)
{
 int offset = (y << 8) + (y<<6) + x, oldx=x;
 unsigned char far *romptr;
 unsigned char far *charset = (unsigned char far*)0xF000FA6EL;
 romptr = charset + (*text) * 8;
 unsigned char mask = 0x80;

 while(*text != NULL)
  {
    for(int j = 0; j<8; j++)
    {
     mask = 0x80;
     for(int k =0; k<G*8; k+=G)
     {
      if(*romptr & mask)
			for(int xx = 0;xx<G;xx++)
				for(int yy = 0;yy<G;yy++)
            	if(!((rand()%2)==0))
						vram[offset + k + xx +(yy*320)] = color;

       mask = (mask >> 1);
     }
    offset += 320*G;
    romptr++;
    }
   x += G*8;
   text++;
   if (text[0] == 13){
   text++;
   y+=10*G;
   x=oldx;
   }
   offset = (y<<8) + (y<<6) + x;
   romptr = charset + (*text) * 8;
  }
}

void BltText(char far *text, int x, int y, unsigned char color,unsigned char G)
{
 int offset = (y << 8) + (y<<6) + x, oldx=x;
 unsigned char far *romptr;
 unsigned char far *charset = (unsigned char far*)0xF000FA6EL;
 romptr = charset + (*text) * 8;
 unsigned char mask = 0x80;

 while(*text != NULL)
  {
    for(int j = 0; j<8; j++)
    {
     mask = 0x80;
     for(int k =0; k<G*8; k+=G)
     {
      if(*romptr & mask)
			for(int xx = 0;xx<G;xx++)
				for(int yy = 0;yy<G;yy++)
					vram[offset + k + xx +(yy*320)] = color;

       mask = (mask >> 1);
     }
    offset += 320*G;
    romptr++;
    }
   x += G*8;
   text++;
   if (text[0] == 13){
   text++;
   y+=10*G;
   x=oldx;
   }
   offset = (y<<8) + (y<<6) + x;
   romptr = charset + (*text) * 8;
  }
}
 

 Conclusion

niveau bug, bah si vous mettez plus de 100 lettres vous allez avoir qq problemes pasque j'ai allouer que 100 octet de memoire pour stocker les lettres !


 Sources du même auteur

LEPENWORLD : JEU AVEC LEPEN [VC++ 5.0][DIRECTX 7.0]
Source avec Zip Source avec une capture CLIENT IRC (VC++ 5.0)
Source avec Zip COMPRESSION RLE (VC++ 5.0)
Source avec Zip Source avec une capture CHIRACWORLD (VC++ 5.0)
Source avec Zip DIRECT DRAW, SOUND / HELLO WORLD (VC++ 5.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

Aucun commentaire pour le moment.

 Ajouter un commentaire




Nos sponsors


Sondage...

Comparez les prix

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 : 2,870 sec (3)

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