| Close | Back |
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* Trying 2 imitate Raindrop .. Rajesh _ThE gReAt *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include<stdio.h>
#include<dos.h>
#include<conio.h>
#include<math.h>
#include<string.h>
#include<ctype.h>
#include<graphics.h>
#include<stdlib.h>
/*
#define DEBUG
*/
int rand(void); /* Function prototype */
void drop(char far *); /* Ditto */
/* This variable is used in both the functions so it is global :) */
char far *ptr; /* This points to first location in VDU memory */
/* End of this global declaration */
main()
{
char far *new_ptr;
int random_no;
ptr = (char far *)0xB0008000L; /* First location of video memory */
random_no = rand()%4000;
if(random_no%2)
{
random_no++; /* Make sure that the generated no is even */
}
new_ptr = ptr + random_no;
drop(new_ptr);
}
void drop(char far *new_ptr)
{
char hold; /* Hold the charecter pointed to by new_ptr */
char prev; /* Keep the previous charecter */
long int y;
ptr = (char far *)0xB0008000; /* Make sure */
hold = *new_ptr;
y = (long int)new_ptr;
y -= 0xB0008000L;
y = y%160;
#ifdef DEBUG
printf("\n%d",y);
getch();
#endif
/* Drop Alpha-Numeric Charecters only ;) */
if((hold >= 'a' && hold <= 'z') || (hold >= 'A' && hold <= 'Z') || (hold >= '0' && hold <='9'))
*new_ptr = ' ';
else
main();
for(;new_ptr < ((char far *)((long int)ptr+(long int)(24*160)+((long int)y*2))) &&!kbhit();new_ptr += 160)
{
prev = *new_ptr;
*new_ptr = hold;
delay(150);
*new_ptr = prev; /* Restore */
}
}