bu da bu efekti temel almış değişik bir rutin:
çalışır halde görmek için
exe halini indirebilirsiniz.
/*
A cool prog in Borland C++. What fire would look like with no gravity!
Could be made faster by converting the pixel checking to assembly.
Also could be make neater by using a separate ASM file instead of
pseudo-assembly for the mouse checking routine, screen mode, etc.
Could easily be converted to a fire routine. Sorry almost no commenting.
Should be pretty easy to understand anyway.
By iNsAnE~aSyLuM
*/
#pragma option -mc
#include <stdlib.h>
#include <dos.h>
#include <mem.h>
#include <conio.h>
// Set this to SIDES for only checking on the sides or
// set this to DIAGONALS for only check on the diagonals or
// set this to ALL for checking of all surrounding pixels
#define SIDES
#if defined(ALL)
#define SIDES
#define DIAGONALS
#endif
const unsigned int screen_w = 320;
const unsigned int screen_h = 200;
const unsigned int offset_x = 0;
const unsigned int offset_y = 0;
const unsigned int bufsize = screen_w*screen_h;
unsigned int mouse_w = 10;
unsigned int mouse_h = 10;
unsigned int decay = 0;
unsigned far char *screen=(unsigned char far*)0xA0000000L;
unsigned far char buffera[bufsize];
unsigned far char bufferb[bufsize];
unsigned far char *buffer1=buffera;
unsigned far char *buffer2=bufferb;
unsigned far char *destline=NULL;
unsigned far char *line=NULL;
unsigned far char *lineup=NULL;
unsigned far char *linedown=NULL;
void setVGAmode(int mode)
{
_AX=mode;
_BX=0;
geninterrupt(0x10);
}
void setVESAmode(int mode)
{
_AH = 0x4f;
_AL = 2;
_BX = mode;
geninterrupt(0x10);
}
void vsync()
{
while((inportb(0x3da)&8));
while(!(inportb(0x3da)&8));
}
void set_color(unsigned char col,unsigned char r,unsigned char g,unsigned char b)
{
outportb(0x3c8,col);
outportb(0x3c9,r%64);
outportb(0x3c9,g%64);
outportb(0x3c9,b%64);
}
void mouse_status(int &x,int &y,int &b)
{
_AX = 3;
geninterrupt(0x33);
b = _BX;
x = _CX/2;
y = _DX;
}
void main()
{
unsigned int x,y;
int temp=0;
int mouse_x=20,mouse_y=20;
int mouse_b=0;
int done=0;
unsigned char resp=0;
setVESAmode(0x13);
for(x=0;x<64;x++)
{
set_color(x,0,0,0);
set_color(x+64,x,x/2,0);
set_color(x+128,63,32+x/2,0);
set_color(x+192,63,63,x);
}
while(!done)
{
mouse_status(mouse_x,mouse_y,mouse_b);
resp=0;
if(kbhit())resp=getch();
if(resp=='+'&&mouse_w<318&&mouse_h<198){mouse_w++;mouse_h++;}
if(resp=='-'&&mouse_w>1&&mouse_h>1){mouse_w--;mouse_h--;}
if(resp==27||resp=='q'||resp=='x')done=1;
if(mouse_x<1)mouse_x=1;
if(mouse_y<1)mouse_y=1;
if(mouse_x>screen_w-mouse_w-1)mouse_x=screen_w-mouse_w-1;
if(mouse_y>screen_h-mouse_h-1)mouse_y=screen_h-mouse_h-1;
for(x=0;x<mouse_w;x++)
for(y=0;y<mouse_h;y++)
*(buffer2+(mouse_x+x)+((mouse_y+y)*screen_w))=255;
for(y=1;y<screen_h-1;y++)
{
destline= (buffer1+((y ) *screen_w));
linedown= (buffer2+((y-1) *screen_w));
line= (buffer2+((y ) *screen_w));
lineup= (buffer2+((y+1) *screen_w));
for(x=1;x<screen_w-1;x++)
{
temp=0;
#if defined(DIAGONALS)
temp+=*(lineup +x+1);
temp+=*(lineup +x-1);
temp+=*(linedown+x+1);
temp+=*(linedown+x-1);
#endif
#if defined(SIDES)
temp+=*(lineup +x);
temp+=*(line +x+1);
temp+=*(line +x-1);
temp+=*(linedown+x);
#endif
#if defined(SIDES) && defined(DIAGONALS)
temp = (temp>>3);
#else
temp = (temp>>2);
#endif
if(temp>=decay)temp-=decay;
else temp=0;
*(destline+x)=temp;
}
}
//wait for vertical retrace for no flickering
//vsync();
for(y=0;y<screen_h;y++)
{
//copy buffer to screen
_fmemcpy(screen+(offset_x+(offset_y+y)*320),buffer1+(screen_w*y),screen_w);
}
//copy buffer to second buffer for later reference
_fmemcpy(buffer2,buffer1,bufsize);
}
setVESAmode(0x3);
}