2009-01-02 02:18:20 +00:00
|
|
|
#ifndef JOYSTICK_H
|
|
|
|
#define JOYSTICK_H
|
|
|
|
|
2011-06-20 21:57:30 +00:00
|
|
|
#include "../config.h"
|
|
|
|
|
2009-01-02 02:18:20 +00:00
|
|
|
extern unsigned char waitForFire;
|
|
|
|
void joy_init();
|
|
|
|
|
2009-07-09 20:08:40 +00:00
|
|
|
|
2009-01-02 02:18:20 +00:00
|
|
|
#ifdef AVR
|
|
|
|
|
2009-07-09 20:08:40 +00:00
|
|
|
# include <avr/io.h>
|
|
|
|
# ifdef NES_PAD_SUPPORT
|
|
|
|
|
|
|
|
extern volatile unsigned char fakeport;
|
|
|
|
|
|
|
|
# define JOYISUP (!! ((1<<4) & fakeport))
|
|
|
|
# define JOYISDOWN (!! ((1<<5) & fakeport))
|
|
|
|
# define JOYISLEFT (!! ((1<<6) & fakeport))
|
|
|
|
# define JOYISRIGHT (!! ((1<<7) & fakeport))
|
|
|
|
# define JOYISFIRE (!! ((1<<0) & fakeport))
|
|
|
|
|
2012-03-01 23:20:05 +00:00
|
|
|
# elif defined(RFM12_JOYSTICK_SUPPORT)
|
|
|
|
|
|
|
|
extern volatile uint8_t rfm12_joystick_val;
|
|
|
|
|
|
|
|
# define JOYISUP (!! ((1<<0) & rfm12_joystick_val))
|
|
|
|
# define JOYISDOWN (!! ((1<<1) & rfm12_joystick_val))
|
|
|
|
# define JOYISLEFT (!! ((1<<2) & rfm12_joystick_val))
|
|
|
|
# define JOYISRIGHT (!! ((1<<3) & rfm12_joystick_val))
|
|
|
|
# define JOYISFIRE (!! ((1<<4) & rfm12_joystick_val))
|
2009-07-09 20:08:40 +00:00
|
|
|
|
2012-09-13 01:19:33 +00:00
|
|
|
# elif defined(HC165_JOYSTICK_SUPPORT)
|
|
|
|
|
|
|
|
extern volatile uint8_t hc165_joystick_val;
|
|
|
|
|
|
|
|
# define JOYISUP (! ((1<<0) & hc165_joystick_val))
|
|
|
|
# define JOYISDOWN (! ((1<<1) & hc165_joystick_val))
|
|
|
|
# define JOYISLEFT (! ((1<<2) & hc165_joystick_val))
|
|
|
|
# define JOYISRIGHT (! ((1<<3) & hc165_joystick_val))
|
|
|
|
# define JOYISFIRE (! ((1<<4) & hc165_joystick_val))
|
|
|
|
|
|
|
|
|
2009-07-09 20:08:40 +00:00
|
|
|
# else
|
2009-01-02 02:18:20 +00:00
|
|
|
|
2009-07-09 20:08:40 +00:00
|
|
|
# define JOYISUP (!(JOYSTICK_PIN_UP & (1<<JOYSTICK_BIT_UP )))
|
|
|
|
# define JOYISDOWN (!(JOYSTICK_PIN_DOWN & (1<<JOYSTICK_BIT_DOWN )))
|
|
|
|
# define JOYISLEFT (!(JOYSTICK_PIN_LEFT & (1<<JOYSTICK_BIT_LEFT )))
|
|
|
|
# define JOYISRIGHT (!(JOYSTICK_PIN_RIGHT & (1<<JOYSTICK_BIT_RIGHT)))
|
|
|
|
# define JOYISFIRE (!(JOYSTICK_PIN_FIRE & (1<<JOYSTICK_BIT_FIRE )))
|
2009-01-02 02:18:20 +00:00
|
|
|
|
2009-07-09 20:08:40 +00:00
|
|
|
# endif
|
2009-01-02 02:18:20 +00:00
|
|
|
#else
|
|
|
|
|
2009-07-09 20:08:40 +00:00
|
|
|
extern volatile unsigned char fakeport;
|
2009-01-02 02:18:20 +00:00
|
|
|
|
2009-07-09 20:08:40 +00:00
|
|
|
# define JOYISUP (0x10 & fakeport)
|
|
|
|
# define JOYISDOWN (0x08 & fakeport)
|
|
|
|
# define JOYISLEFT (0x02 & fakeport)
|
|
|
|
# define JOYISRIGHT (0x04 & fakeport)
|
|
|
|
# define JOYISFIRE (0x01 & fakeport)
|
2009-01-02 02:18:20 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif // JOYSTICK_H
|