/*
    Robot server - 2005 Jason Hunt
    
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
    as published by the Free Software Foundation; either version 2
    of the License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

    Contact: huntjas2@msu.edu
*/


#include <stdio.h>
#include <sys/io.h>
#include <unistd.h>

#define lpt_data 0x378

// f a
//e   b
// d c

#define A   0x08
#define B   0x10
#define C   0x20
#define D   0x04
#define E   0x02
#define F   0x01


int fire = 0;

void *gun_control(void *threadid)
{
/*    int r = ioperm(lpt_data, 3, 255);
    
    
    if (r != 0)
    {
        printf("[Gun]: Unable to open LPT port\n");       
    }
    else
        printf("[Gun] Gun enabled (%d)\n", r);

    while(1)
    {
        // need to fire?
        if(fire)
        {
            // loop around for one cycle
            outb(A, lpt_data); usleep(40000);
            outb(B, lpt_data); usleep(40000);
            outb(C, lpt_data); usleep(40000);
            outb(D, lpt_data); usleep(40000);
            outb(E, lpt_data); usleep(40000);
            outb(F, lpt_data); usleep(40000);
            outb(0, lpt_data);
        }
    }*/
}
/* end of gun_control */


/* make sure gun is off */
void kill_gun(void)
{
    ioperm(lpt_data, 3, 255);
    outb(0x00, lpt_data);
}
/* end of kill_gun */

