Plan 9 from Bell Labs’s /usr/web/sources/contrib/akumar/igo/goban/igo.h

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


/* requires draw.h */

enum{			/* stone colors */
	Hcapplay='A',
	Emptystone='e',
	Wmarked='w',
	Bmarked='b',
	Lstone='l',		/* mark for last stone */
	Kou='k',
	Cntstone='c',	/* counting points */
	Bstone='B',
	Wstone='W',
	Nop='N',
				/* special moves */
	Chplayer='O',
	Resignmv='F',
	Chmode='C',	/* change mode, count  */
	Mdead='D',	/* mark dead, count */
};

enum{
	Bansz=19,
};

extern char *emptytype;
extern int verbose;
#define dprint if(verbose)print

typedef struct MEvent MEvent; /* Move Event */
typedef struct Move Move;

struct MEvent
{
	int m;	/* mouse */
	int k;		/* keyboard */
	int fd;
};

struct Move
{
	Point;	/* (i, j) in Go: 1 ≤ i,j ≤ 19 */
	char type;
	MEvent ev;
	Move *next;
};

/* move.c */
void	fillmov(Move *m, Point pos, char type);
void	freegrp(Move *m);
int	opgrp(Move *grp, char type, void (*op)(Move *m, char type));
Move*	clonegrp(Move *grp);
Move*	addlast(Move *g,Move *m);
Move*	pushmov(Move *g, Move *m);
Move*	popmov(Move **m, Move *g);

void	opprint(Move *m, char);
void	opdebug(Move *m,char);
void	opplace(Move *m, char type);
void	opsend(Move *mv,char);
void	opsettype(Move *m, char c);
void	opnop(Move *,char);

Move*	freelast(Move *g);
Move* 	takelast(Move **grp);

/* rules.c */
void 		cleangoban(void);
Move*	getmove(Point pos);
int		nlibert(Move *m);
int		move(Move *m, Move **mdead);
int		countpos(Move *m, Move **terr, char *type);
Move*	getgrp(Move *m, char *neightype);
void		opplace(Move *m, char type);
int		markdead(Move *m,Move **mdead);
int		trycount(int *nw, int *nb);
int		isvalidpos(Point pos);
void		cleartype(char type);

enum {
	Hcapsz=9
};

/* draw.c */
enum{
	DGobrown=0xEE9E00FF,
	DSTbord=0x303030FF,
	Cmdmaxsz=128,
	↑=61454,
	↓=128,
	DELETEKEY=0x7f,
	Stonesz=3,  //divider of Δ
	Thickln=25, //divider of Δ
	Pointsz=5,	//divider of Δ
	Countsz=5,	//divider of Δ
	Szmin=150,
	Szmax=1500
};

static int bpoints, wpoints, clk;
static Point pdr, pul;
static int visible;

static Point pul,fontcorn;
static int bdead,wdead,clk;
static Image *pixbg,*pixfg,*pixko;
static Image *pixwht,*pixst, *pixyell, *pixbl;

extern int Δx,  Δy;
extern Point hcap[Hcapsz];
extern Point hcapord[Hcapsz][Hcapsz];
extern char goban[Bansz+1][Bansz+1];
extern Move lkou;
extern Move lstone;
extern Move *moves;

void	inthread(void *);
void	ifcthread(void *);

static int drawstone(Point, char);

extern void drwlabel(int, int, int);
extern void redraw(void);
extern void drawgoban(void);
extern void initifc(void);

/* io.c */
enum{
	Noev=0,
	Click1,
	Click2,
	Click3,
};

enum{
	Akeyboard=0,
	Areshape,
	Amouse,
	Afile,
	NALT
};

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.