Accueil > > > EFFET DE FLAMME (SOUS DOS EN 320*200) (BC++)
EFFET DE FLAMME (SOUS DOS EN 320*200) (BC++)
Information sur la source
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
Sources de la même categorie
Commentaires et avis
|
Derniers Blogs
IMAGINE CUP 2012, MAKE A SIGN EN FINALEIMAGINE CUP 2012, MAKE A SIGN EN FINALE par junarnoalg
Voilà qui est fait, la nouvelle est officielle ! L'équipe belge "Make a Sign" va au pays des kangourous défendre son projet dans la catégorie Software Design. http://www.imaginecup.com/CompetitionsContent/Competition/WorldwideFinalists.aspx V...
Cliquez pour lire la suite de l'article par junarnoalg KINECT 1.5 IS OUT !KINECT 1.5 IS OUT ! par Vko
La version 1.5 du Kinect For Microsoft vient tout juste de sortir ! Plein de nouveautés: Tracking de squelette en Near Mode Détection en position assise Détection faciale avec un SDK dédié Documentation et des guideline (enfin) Un out...
Cliquez pour lire la suite de l'article par Vko LES ACTUALITéS DE LA SEMAINE SUR C2I.FR (14 MAI - 20 MAI) LES ACTUALITéS DE LA SEMAINE SUR C2I.FR (14 MAI - 20 MAI) par richardc
Mise à jour des Web API du 14 Mai
Réservez dès maintenant votre journée du 20 juin pour le Windows Azure Dev Camp 2012 à Paris
Mise à jour de Team Foundation Service
MechCommander 2 sur Windows 8
Entity Framework 5 Release Candidate e...
Cliquez pour lire la suite de l'article par richardc REACTIVE EXTENSIONS : CONSOMMER DES SERVICES AVEC RX PARTIE 3, LES PIèGES à éVITERREACTIVE EXTENSIONS : CONSOMMER DES SERVICES AVEC RX PARTIE 3, LES PIèGES à éVITER par Groc
Une mauvaise utilisation de rx lors de l'écriture d'une couche d'accès à des services peut conduire à des cas embarassants avec des erreurs mal gérées, des appels qui ne partent lorsqu'ils le devraient, et même des résultats incorrects . le tout nuis...
Cliquez pour lire la suite de l'article par Groc SHAREPOINT BLOG SITE, PROBLèME D'ARCHIVESSHAREPOINT BLOG SITE, PROBLèME D'ARCHIVES par junarnoalg
Dernièrement, nous avons migré le site
myTIC
vers un nouveau serveur SharePoint 2010. Dans les contenus que nous vouloins récupérer, nous avions un certain nombre de blogs.
Nous avons utilisé les commandes Power...
Cliquez pour lire la suite de l'article par junarnoalg
Forum
MATRICE TEMPLATEMATRICE TEMPLATE par hjr2610
Cliquez pour lire la suite par hjr2610 RE : SAC A DOS RE : SAC A DOS par hadjkaddour
Cliquez pour lire la suite par hadjkaddour
Logiciels
sDEVIS-FACTURES vlPRO (8.1.0.3)SDEVIS-FACTURES VLPRO (8.1.0.3)sDEVIS-FACTURES vlPRO a été mis au point pour les particuliers, créateurs, entrepreneurs, artisa... Cliquez pour télécharger sDEVIS-FACTURES vlPRO 974 Application Server (12.2.4.6)974 APPLICATION SERVER (12.2.4.6)Développez de puissantes applications dans un environnement de 'cloud computing', clusterisé, séc... Cliquez pour télécharger 974 Application Server vPicture (1.4.2.1)VPICTURE (1.4.2.1)Avec vPicture, hébergez vos images facilement et rapidement.
vPicture est un utilitaire simple, ... Cliquez pour télécharger vPicture Easy-Planning (2.2.1.6)EASY-PLANNING (2.2.1.6)Easy-Planning permet de créer des plannings sous la représentation de diagrammes et est adapté au... Cliquez pour télécharger Easy-Planning COM-BACKUP (2.0)COM-BACKUP (2.0)
COM-BACKUP est un logiciel de sauvegarde qui permet de planifier les sauvegardes de vos dossiers ...
Cliquez pour télécharger COM-BACKUP
|