// SOLGLOB.H

#ifndef SOLGLOB_H
    #define SOLGLOB_H

GLREF_D PR_APPMAN * const       w_am ;          // ptr to application manager
GLREF_D PR_WSERV *              w_ws ;          // ptr to window server client
GLREF_D PR_DLGBOX *             DatDialogPtr ;  // ptr to dialog object
GLREF_D TEXT *                  DatCommandPtr ; //
GLREF_D WSERV_SPEC *            wserv_channel ; // Channel to WSERVER
GLREF_D TEXT *                  DatApp1 ;       // reserved application ptr

GLREF_D PR_SOLENG *             soleng ;        // external ptr to engine

typedef struct {
    UWORD       shape ;
    UWORD       rules ;
    UWORD       show ;
    UWORD       sound ;
    UWORD       winpos ;
    UBYTE       results[5] ;
    ULONG       pegs ;
    ULONG       games ;
    WORD        ridLast ;
} OPTIONS_tag ;

GLREF_D OPTIONS_tag     options ;

#define X(xy)           (xy & 0x00FF)
#define Y(xy)           (xy >> 8)
#define XY(x,y)         (((UWORD) x) | (((UWORD) y) << 8))

#define N_VECTORS           8       // directions of movement
#define BORDER_WIDTH        6
#define DESIGN_SIZE         22      // size in pixels of design
#define DESIGN_OFFSET       21      // size of design offsets

// Categories of pieces
enum {  S_UNUSABLE = 'a',
        S_EMPTY,
        S_FULL,
        S_MOVABLE } ;

// Offsets from tl of window
#define BOARD_X(x)          ((x) * (DESIGN_SIZE - 1))
#define BOARD_Y(y)          ((y) * (DESIGN_SIZE - 1))

// Directions
enum {  DIR_NONE = -1,
        DIR_W = 0,
        DIR_NW,
        DIR_N,
        DIR_NE,
        DIR_E,
        DIR_SE,
        DIR_S,
        DIR_SW } ;

typedef struct {
    BYTE        x ;
    BYTE        y ;
} VECTOR ;

GLREF_D VECTOR          vectors[] ;

#endif
