Effet de flamme (sous dos en 320*200) (bc++)

Contenu du snippet

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 / Exemple :


#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 !

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.