/*
 * Rubik's clock.
 *
 * This file is public domain, I just hate copy[left/right]s.
 *-------------
 *the clock stuff include file
 */

#ifndef _CLOCK_H_
#define _CLOCK_H_

/* the modes for the clock (read the code to get it, good luck to you :-) ) */
#define NORMAL			0
#define SOLVER			1
#define END			2
#define SOLVER_INTERRUPTED	3

typedef struct {
  /* very simple definition - everyone should understand the structure, nope ? */
  /* the value are in 0-11 like real clocks */
  /* a face is :
   *
   *     (0,0)   (0,1)   (0,2)
   *
   *     (1,0)   (1,1)   (1,2)
   *
   *     (2,0)   (2,1)   (2,2)
   */
  /* the first index gives the face's number (to simplify the code I use an index instead of 2 arrays) */
  int face[2][3][3];
  /* the buttons' state (down = 0, up = 1) */
  /* first index gives the face number */
  /* buttons are :
   *
   *    0   1
   *
   *    2   3
   */
  int buttons[2][4];
  /* which face is shown (0 or 1) */
  int current_face;
  /* with the new event handler, we've got a state (a mode) for the clock */
  int mode;
} CLOCK;

#include "screen.h"

/* the init function (sets up the clock's state and draws ) */
void init_clock(CLOCK *, SCREEN *);

/* the possible actions (we'll have to update the clock's state and the display) */
/* push a button - gives the button's number */
void push_button(CLOCK *, int, SCREEN *);
/* turn a corner - gives which corner (corner are numbered like buttons)
 * and the direction (0=clock order, 1=counter-clock order)
 */
void turn_corner(CLOCK *, int, int, SCREEN *);
/* return the clock - to show the other side */
void return_clock(CLOCK *, SCREEN *);

void draw_all(CLOCK *, SCREEN *);
void draw_mouse(CLOCK *, SCREEN *, int, int);

void randomize_clock(CLOCK *);

int myrand(int);

#endif /* _CLOCK_H_ */
