Subversion Repositories Code-Repo

Compare Revisions

Ignore whitespace Rev 277 → Rev 278

/PIC Stuff/Cerebot_32MX7_LED_Cube/TRON.h
3,61 → 3,40
 
#include "CUBE.h"
 
#define TRON_PLAYER_1_COLOR GREEN
#define TRON_PLAYER_2_COLOR PURPLE
#define TRON_PLAYER_1_HEAD BLUE
#define TRON_PLAYER_2_HEAD RED
#define TRON_COLLISION ORANGE
#define TRON_MAX_PLAYERS 4
#define TRON_COLLISION WHITE
#define TRON_COLLISION_2 ORANGE
#define TRON_DELAY 800
 
typedef struct {
unsigned x :8;
unsigned y :8;
unsigned z :8;
unsigned :8;
uint8_t x;
uint8_t y;
uint8_t z;
} TRON_POINT;
 
typedef union {
struct {
unsigned up :1;
unsigned down :1;
unsigned right :1;
unsigned forward :1;
unsigned left :1;
unsigned backward :1;
unsigned :2;
};
uint8_t value;
} TRON_P1_DIRECTION;
typedef struct {
uint8_t Color_Head_R[TRON_MAX_PLAYERS];
uint8_t Color_Head_G[TRON_MAX_PLAYERS];
uint8_t Color_Head_B[TRON_MAX_PLAYERS];
 
typedef union {
struct {
unsigned up :1;
unsigned down :1;
unsigned left :1;
unsigned backward :1;
unsigned right :1;
unsigned forward :1;
unsigned :2;
};
uint8_t value;
} TRON_P2_DIRECTION;
uint8_t Color_Body_R[TRON_MAX_PLAYERS];
uint8_t Color_Body_G[TRON_MAX_PLAYERS];
uint8_t Color_Body_B[TRON_MAX_PLAYERS];
 
typedef struct {
TRON_POINT p1_body[CUBE_PIXELS];
TRON_POINT p1_direction;
uint8_t p1_last_direction;
TRON_POINT body[TRON_MAX_PLAYERS][CUBE_PIXELS];
TRON_POINT direction[TRON_MAX_PLAYERS];
uint8_t last_direction[TRON_MAX_PLAYERS];
uint8_t dead[TRON_MAX_PLAYERS];
uint32_t length[TRON_MAX_PLAYERS];
 
TRON_POINT p2_body[CUBE_PIXELS];
TRON_POINT p2_direction;
uint8_t p2_last_direction;
uint32_t length;
uint8_t players;
uint8_t players_alive;
uint32_t delay;
} TRON_DATA;
 
void Tron_Init(TRON_DATA *data);
void Tron_Main(void);
void Tron_Update_Direction(uint8_t p1, uint8_t p2);
void Tron_Update_Direction(uint8_t controller, CTRL_BTN_STATUS value);
void Tron_Update_Frame(void);
 
#endif /* TRON_H */