Monday 25 March 2013

How to use Whatsapp without changing LAST SEEN time !!



Hello Friends, Whatsapp is nowadays very popular medium for communication.
It is very handy and easy to use. It has very Great feature called Last Seen.  This feature enables user to see that when his/her friend used the Whatsapp last time.

So, Sometimes It may happen that  you wish to Use Whatsapp but you don't want that your Friend come to know about your last whatsapp access time right?
Reason Can be anything ;-)

[ For this Trick , Whole credit Goes to my friend Manas Vaishnav ]

Basic Rule is - Don't Open Whatsapp while your Data connection/Internet connection is ON.

Scenario :

In normal condition you data connection is enable.
you will receive whatsapp notifications when someone messages you.
now disable your data connection.
open whatsapp... read message... if you want to reply then type your message and press send button
Now close Whatsapp,
enable data connection !

Done...
You have read your message, replied to your friend yet your Last Seen Time will not changed !




"Relationship now a days begins with 'First seen' at Facebook & Ends after noticing 'Last seen' on Whatsapp !" - Manas Vaishnav

Thursday 21 March 2013

Mouse Programming in C

This is simple tutorial to show you How you can  use Mouse  in your C program.
I have Attached a source file. This program is not developed by me. I found it on internet somewhere, But as this program is easy to understand I am using this program.

See Source code here.


To Enable Mouse in C program you need to generate Interrupt.
The interrupt number for Mouse input related service is 33h.



Files to include -> dos.h
Function from dos.h to be use ->int int86(int intno,union REGS *input , union Regs *output)
This Function Generates Software interrupts

union - REGS is defined in dos.h file
it is defined as

union REGS{
struct WORDREGS   x;
struct BYTEREGS     y;
};

WORDREGS  & BYTEREGS are defined as

struct WORDREGS{
unsigned int ax,bx,cx,dx;
unsigned int si,di,cflag,flags;
};

struct BYTEREGS{
unsigned int al,ah,bl,bh;
unsigned int cl,ch,dl,dh;
};


You don't need to remember all this stuff. This is just for understanding.
If you have studied any  Micro Controller subject then you can easily identify that these ax,bx... indicates Registers.

So, let me first tell  what we exactly gonna do.

For every type of event there are Software interrupt number are defined.
for example using keyboard, sound, mouse.
Here for mouse interrupt number is 33h.
and for all types of operation like show mouse pointer, initialize mouse, restrict mouse pointer on screen etc.. we have different Service numbers.

Generally service number will be provided in
ax register,
so here we will write something like  i.x.ax

now all the input information will be provided in   variable of type REGS, and we will get out put in similar union varible

In our program we have declared
union i,o;
we will use
 i as input 
o as output, 

so this are some of service numbers for mouse



0~ Mouse Reset/Get Mouse Installed Flag
1~ Show Mouse Cursor
2~ Hide Mouse Cursor
3~ Get Mouse Position and Button Status
4~ Set Mouse Cursor Position
5~ Get Mouse Button Press Information
6~ Get Mouse Button Release Information
7~ Set Mouse Horizontal Min/Max Position
8~ Set Mouse Vertical Min/Max Position

This is example who you  can use this  service.

To initialize mouse

i.x.ax=0;
int86(33h,&i,&o);

done !!


to Restrict mouse pointer between square (10,10) to (20,20)

        i.x.ax=7;
 i.x.cx=10;
 i.x.dx=20;
 int86(0x33,&i,&o);

 i.x.ax=8;
 i.x.cx=10;
 i.x.dx=20;
 int86(0x33,&i,&o);

very simple right?
now Go through source code and  try your self.

Tuesday 19 March 2013

Hide files in Image


This is very popular and old trick to hide any kind of file in image ! But it is very effective :)
I have written this blog assuming that reader is novice to command prompt and all.

So Here are the steps :

Step 1. 
put all files that you want to hide in one folder.
compress that folder using winrar, winzip or 7-zip whatever you like.
If you want to hide only one file then you can directly compress it without putting it in to the folder.

Step 2.
Now make sure that your jpeg image (the one that you want to use) and compressed file (your data) are in same folder (Just to make process simpler.)

Step 3. 

open Command prompt
[click on start menu, open "Run" , type - cmd  , click ok ]


Step 4.
Open path of your image and compressed folder in command prompt.

Example:
suppose your command prompts shows
c:\abc\def>
and your image and compressed files are in  E:\new folder
then   type following commands
E:         hit enter
cd new hit enter

Step 5.
this is last step
type following command
suppose your image is  -  abc.jpg
compressed file is         -  xyz.rar

copy /b  abc.jpg+xyz.rar  pqr.jpg     hit enter

Done !!  now open pqr.jpg file.... it is image which contains your data !!
you can send to the person who know  how to retrieve data from it


Steps to retrieve data from Image :

Again open Command prompt
Go to path where your encrypted image is saved.

type following command

Rename pqr.jpg   data.rar

now your image will be changed to compressed file data.rar
extract this data.rar  and you will get your data !

Monday 18 March 2013

Facebook Chat Emoticons (Smilies) and Ascii art

Hello Friends, Facebook is now tightly bounded with our day to day life .  Facebook chat box is one of most frequently used medium of communication right? So  here,  Emoticons comes in to picture.
Emoticons (Smiles) makes conversation live and meaningful. Besides that it is fun ☺.

I am crazy after such Emoticons. I love to learn new Emoticons. So here, I will show you several  the ways to insert Emotions in the Facebook chat or comments.

Simple Emoticons :



Advance Emoticons:
type the code and hit enter. you will get image which is given below each code !!!



Ascii Symbols :

some of the Ascii Symbols are very useful.
For example :☺ ☻ ♥ ♦ ♣ ♠ ♦

To use such symbols , Press Alt key and while pressing Alt key press any number from Numpad. then release Alt key.

example :
to print ☺
hold alt key ,press 1 in num pad then release alt key. thats it..
and beauty of this Ascii symbols is that you can use this symbols anywhere in any editor. ☺. 

Reference table :
Ignore Hex code... use Decimal code. 




If you know any other way. let me know , I will add in this blog  ♥
Happy chatting ;-)



Sunday 17 March 2013

Keeper - A two player game in C

This is tutorial for creating a Two player game in C.

The name of game is keeper. It is very simple game and very easy to implement. Even if you are novice to Graphics programming in c, you will be able to grasp everything.

Download Source code from  Here





Required Structures :
  • pad : This structure will keep track of location of pad and size of pad. 
  • ball : This structure will keep track of ball size, position and direction of ball
  • limit : This structure consist the coordinates of boundary of  game area.
  • game_data : This structure will keep track of score.

struct pad
{
int x,y,l;
}pd1={100,200,30},pd2={440,200,30};

struct game_data
{
int score;
};
struct game_data p1={0},p2={0};

struct limit
{
int lx1,ly1,lx2,ly2;
};
struct limit l={90,90,450,400};

struct ball
{
int x,y;
int dir;
int size;
}ball={250,250,7,5};



There are several functions like game,draw, get_dir, mv_ball  etc.. all of them are self explainatory. comments are provided in the source code.

draw function will draw whole screen including boundaries, ball, pads.

draw(void)
{

rectangle(l.lx1,l.ly1,l.lx2,l.ly2);
circle(ball.x,ball.y,ball.size);
rectangle(pd1.x-5,pd1.y-30,pd1.x+5,pd1.y+30);
rectangle(pd2.x-5,pd2.y-30,pd2.x+5,pd2.y+30);
delay(15);
while(!kbhit()){goto e;}
k=getche();
if(k=='w' || k=='s'||k=='e'){key1=k;}
else if(k==72||k==80||k==77||k=='o'){key2=k;}
e:
cleardevice();

}


mv_ball will provide new coordinates of ball according to it's direction

void mv_ball(void)
{
switch(ball.dir)
{
case 0 : ball.y-=2; break;
case 8 : ball.y+=2; break;
case 2 : ball.x+=2; break;
case 6 : ball.x-=2; break;
case 1 : ball.x+=2; ball.y-=2; break;
case 3 : ball.x-=2; ball.y+=2; break;
case 7 : ball.x+=2; ball.y+=2; break;
case 5 : ball.x-=2; ball.y-=2; break;
}
}




game function is main function for game logic. It will check that whether ball hits boundary, pad , any key is pressed or not etc...


void game(void)
{
draw();
while(1)
{
      if(ball.y-l.ly1<=ball.size||l.ly2-ball.y<ball.size)
      {
        d=0;
        get_dir();
      }

      if((ball.x-105<=ball.size && abs(ball.y-pd1.y)<=32 )||(435-ball.x<=ball.size&& abs(ball.y-pd2.y)<=32))
      {
        d=1;
        get_dir();
      }



if(ball.x<l.lx1||l.lx2<ball.x)
{

if(ball.x<l.lx1)
{p2.score=p2.score+100;}
else
{p1.score=p1.score+100;}

ball.x=250;//+random(245);
ball.y=150;//+random(245);
pd1.y=250;
pd2.y=250;
      // ball.dir=random(7);
while(!kbhit()){ draw();}

}

sswitch(key1)
{
 case 'w':   if(pd1.y-pd1.l-l.ly1>10) pd1.y-=2;  break;
 case 's':   if(l.ly2-(pd1.y+pd1.l)>10) pd1.y+=2;  break;
 default : break;
}
switch(key2)
{
 case 72:    if(pd2.y-pd2.l-l.ly1>10) pd2.y-=2;  break;
 case 80:    if(l.ly2-(pd2.y+pd2.l)>10) pd2.y+=2;  break;
 case 'o' : gameover();
 default  : break;
}


      draw();

      mv_ball();


   }

}

When 'o' is pressed ,The game will be over and score of each player will be displayed.

If you have any query or suggestion then leave comment !





Thursday 14 March 2013

SNAKE game using concept of Linked list - Graphics in C

This is tutorial for  creating a game using graphics in c.
If you know some concept of linked list then it will be very easy to understand. This is not standard way to create this particular. But, I have made this program to implement concept of Linked list !!
This is logical right?  when you need to increase length of snake in the game you can just add one item to the linked list !! this is it.
Thi
Download source code from here
If you you are working on windows 7.then you will need DosBox to run this program.

Structures :


struct loc
{
int x,y;
};

struct snake
{
struct loc sloc;
struct snake *link;
char dir;
};

struct game_data
{
int score;
int no_food;

};
struct game_data gd={0,0};

struct limit
{
int lx1,ly1,lx2,ly2;
};
struct limit l={96,96,404,404};


struct food
{
struct loc floc;
};



  • Structure "loc" have 2 integer variables to save x and y coordinates.
  • Structure "snake" is basically a linked list , new node of this structure will be created when snake will increase in length.
  • "game_data" will store score and number of food consumed by snake
  • "limit" defines the boundary of rectangle in which snake can move. crossing this limits will result in game over.
  • "food" contains coordinates of food to be displayed
  



Functions :

  • "draw" : This function will draw whole screen. which includes,
    1. Rectangular Boundary limits
    2. snake
    3. food
    draw(struct snake *head,struct food *f)
    {
    
    struct snake *temp;
    temp=head;
    
    rectangle(96,96,404,404);
    rectangle(98,98,402,402);
    rectangle(100,100,400,400);
    setfillstyle(9,13);
    bar(temp->sloc.x-6,temp->sloc.y-6,temp->sloc.x+6,temp->sloc.y+6);
    temp=temp->link;
    setfillstyle(9,2);
    while(temp->link!=NULL)
    {
    
    bar(temp->sloc.x-5,temp->sloc.y-5,temp->sloc.x+5,temp->sloc.y+5);
    temp=temp->link;
    }
    
    bar(temp->sloc.x-5,temp->sloc.y-5,temp->sloc.x+5,temp->sloc.y+5);
    
    circle(f->floc.x-2,f->floc.y-2,5);
    circle(f->floc.x+2,f->floc.y+2,5);
    circle(f->floc.x-2,f->floc.y+2,5);
    circle(f->floc.x+2,f->floc.y-2,5);
    
    delay(20);
    while(!kbhit()){goto e;}
    key=getche();
    e:
    
          cleardevice();
    
    }
    
  • "gameover": This function will draw screen when game is over, it includes score and number of food consumed.
  • gameover(void)
    {
    cleardevice();
    outtextxy(100,100,"----------------- GAME OVER ----------------------");
    
    printf("\n\n\n\n\n\n\n\n");
    printf("\t\t# Score      - %d",gd.score);
    printf("\n\t\t# No of food - %d", gd.no_food);
    s1:
    sound(300);delay(300);sound(450);delay(150);sound(500);delay(150);
    sound(300);delay(200);sound(450);delay(100);sound(450);delay(200);
    while(!kbhit()){goto s1;}
    nosound();
    
          exit(0);
    }
    
  • "game" : This is main logic of our snake game. It does following tasks in sequence within a while loop.
    (while loop checks whether 'p' (for pause) is pressed or not.)
    1. checking condition whether snake hits boundary. if it hits boundary then call "gameover" function
    2. check whether snake consumes food or not.
      if it consumes food then generate new food at new location, increase score and food count.
      and create new node of snake structure to increase the length of snake.
    3. check whether any key is pressed to change direction of snake. according to that set the direction of snakes head.
    4. update direction and location of all node of snake body.
    void game(struct snake *head,struct food *f)
    {
         struct snake *temp,pre,nxt;
         temp=head;
    
         while(key!='p')
         {
    if(head->sloc.x==l.lx1||head->sloc.x==l.ly2||head->sloc.y==l.ly1||head->sloc.y==l.ly2)
    {gameover();}
    
    
    
    if(head->sloc.x>=f->floc.x-5&&head->sloc.x<=f->floc.x+5&&head->sloc.y>=f->floc.y-5&&head->sloc.y<=f->floc.y+5)
    {
    temp=head;
    sound(420);
    
    f->floc.x=150+random(245);
    f->floc.y=150+random(245);
    gd.score+=100;
    gd.no_food+=1;
    n=n+1;
    
    
    while(temp->link!=NULL){temp=temp->link;}
    temp->link=(struct snake *)malloc(sizeof(struct snake));
    temp->link->link=NULL;
    temp->link->sloc.x= temp->sloc.x;
    temp->link->sloc.y= temp->sloc.y;
    temp->link->dir=temp->dir;
    n=0;
    
    
      }
    
    switch(key) //this key varible is set in draw() function
    {
     case 'a': if(head->dir!='d'){head->dir='a';  head->sloc.x-=2; } else {key=head->dir;} break;
     case 'w': if(head->dir!='s'){head->dir='w';  head->sloc.y-=2; } else {key=head->dir;} break;
     case 'd': if(head->dir!='a'){head->dir='d';  head->sloc.x+=2; } else {key=head->dir;} break;
     case 's': if(head->dir!='w'){head->dir='s';  head->sloc.y+=2; } else {key=head->dir;} break;
    
    }
          draw(head,f);
          nosound();
          temp=head;
          pre=*temp;
    
          while(temp->link!=NULL)
    {
    nxt.sloc.x=temp->link->sloc.x;
    nxt.sloc.y=temp->link->sloc.y;
    nxt.dir=temp->link->dir;
    temp->link->sloc.x=pre.sloc.x;
    temp->link->sloc.y=pre.sloc.y;
    temp->link->dir=pre.dir;
    temp=temp->link;
    pre=nxt;
    }
       }
    
    }
    
Now you can download the source code of the game and run on your own pc.
make changes and try to modify this game.
If you have any query please leave a comment.






Wednesday 13 March 2013

Tower Of Hanoi - Graphics in C

Hello Friends,
This is simple Tutorial about Graphics in C with example program  "Tower of Hanoi" problem.
Hope you all know about tower of Hanoi problem. If you don't know , google it :)
or visit this wikipedia page :  Tower Of Hanoi

Here is link to source file to c program : Click here

Note : program of c graphics works on 16-bit pc.
it will work on Windows xp. If you have windows 7 then you will need Dosbox to run this program.

If you traverse the program from main() function , then it is self explanatory , if you need help go through the explanation given below.





















Structures :
  • loc    : containg to integers x, y  for storing coordinates of particular object
  • struct loc
    {
    int x;
    int y;
    };
    
  • bar   : It contains two variables of loc structure. one is for permanent location of bar called barloc, other is avloc which is to store on which location a ring can b put on bar.
  • struct bar
    {
    struct loc barloc;
    struct loc avloc;
    };
    
  • ring   : This structure have variable to store location of particular ring and the size of ring (top most ring have smaller size, bottom most ring have biggest size)
  • struct ring
    {
    struct loc rloc;
    int size;
    };
    
Functions :
  • draw : this function will draw whole screen,
     first it will put all the lables on the screen
    then it will draw all bars on the screen
    then all the rings will be drawn
    void draw(struct bar a,struct bar b,struct bar c,struct ring r[],int no)
    {    int i;
        outtextxy(250,30, "TOWER OF HANOI");
        outtextxy(60, 330, "SOURCE");
        outtextxy(240,330, "DESTINATION");
        outtextxy(470,330, "TEMPORARY");
        setfillstyle(8,13);
        bar(a.barloc.x-2, a.barloc.y-200, a.barloc.x+1, a.barloc.y);
        bar(b.barloc.x-2, b.barloc.y-200, b.barloc.x+1, b.barloc.y);
        bar(c.barloc.x-2, c.barloc.y-200, c.barloc.x+1, c.barloc.y);
    
    
    for(i=1;i<=no;i++)
    {
      setfillstyle(8+(i%2),10 /*getmaxcolor()*/);
      bar(r[i].rloc.x-r[i].size,r[i].rloc.y-20,r[i].rloc.x+r[i].size,r[i].rloc.y);
    
    }
    getch();
    cleardevice();
    
    };
  • towers : This function is recursive function. to under stand the logic go through this wikipedia page
  • void towers (int n,struct bar *from,struct bar *to,struct bar *aux,struct ring r[],int no)
    {
    int i=1;
    if(n==1)
    {
    (r[1].rloc.x)= to->avloc.x;
    (r[1].rloc.y)= to->avloc.y;
    if(from->avloc.y!=300){from->avloc.y+=20; }
    to->avloc.y-=20;
    draw(*from,*to,*aux,r,no);
    return;
    }
    
    towers(n-1,from,aux,to,r,no);
    
    while(from->avloc.x!=r[i].rloc.x){i=i+1;}
    
    (r[i].rloc.x)=to->avloc.x;
    (r[i].rloc.y)=to->avloc.y;
    if(from->avloc.y!=300){from->avloc.y+=20; }
    to->avloc.y-=20;
    
    draw(*from,*to,*aux,r,no);
    
    towers(n-1,aux,to,from,r,no);
    
    }
    
I hope this will help.
If you have any query then leave comment, and suggestions are always welcome on this blog !



Monday 11 March 2013

How to use Android Emulator to test Custom ROM


You might have a smart phone , more precisely android smart phone and you want to install a fancy customized ROM right?

Well,  before flashing any custom ROM directly on smartphone you can try it on Android virtual device.

Requirement :
Android sdk -tool should be installed on pc/laptop to create AVD (android virtual device)
system image of custom ROM


Follow the steps given below

Step 1: Open Command prompt (run > cmd  hit enter).

Step 2: change path to "tools" folder of your android sdk
it is something like  ..\Android\android-sdk\tools
[Note : if you have set your path variable for Android Sdk then skip this step   ]


Step 3: enter the command : android list target
This command will give you list of available Android targets with ID of perticular target.
Note down the Id number of target for your custom rom
for example if your custom ROM is for ICS then choose ID number of 4.0 like wise

Example Outout :

Available Android targets:
----------

id: 3 or "android-7"
     Name: Android 2.1
     Type: Platform
     API level: 7
     Revision: 3
     Skins: HVGA, QVGA, WQVGA400, WQVGA432, WVGA800 (default), WVGA854
     ABIs : armeabi

----------
id: 5 or "android-8"
     Name: Android 2.2
     Type: Platform
     API level: 8
     Revision: 3
     Skins: HVGA, QVGA, WQVGA400, WQVGA432, WVGA800 (default), WVGA854
     ABIs : armeabi
----------
id: 15 or "android-15"
     Name: Android 4.0.3
     Type: Platform
     API level: 15
     Revision: 3
     Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854,
     XGA720, WXGA800
     ABIs : armeabi-v7a, x86



Here for ICS we can chose ID- 15

Created AVD 'abc' based on Android 4.0.3, ARM (armeabi-v7a) processor,
with the following hardware config:
hw.lcd.density=240
vm.heapSize=48
hw.ramSize=512

Step 4 : now we will create avd for our target sdk
command : android create avd -n NameOfEmualtor -t TargetID
hit enter ,If you receive error message : Error: This platform has more than one ABI.

Please specify one using --abi. find out abi for your target from previous "android list target" command output and now run
command: android create avd -n Name_Of_Emulator -t TargetID --abi AbiType

Example: android create avd -n myemulator -t 15 --abi armeabi-v7a
Now it will prompt : Do you wish to create a custom hardware profile [no] :
if you dont want to create custom hardware then simply give enter, It will chose default settings. and will give you following output

Step 5:
now you can see that folder named after you avd will be created in
"C:\Users\your_user_name\.android\avd" folder
copy your all Images like user image, data image, system image to this folder.

Step 6: now you can start emulator with your custom ROM by following
command : emulator -avd Name_Of_Emulator

For the first time it may take several minutes to start your AVD.

Done !
your comments, questions and suggestions are always welcome.