/ does white/black attack position?

.globl	battack
.globl	wattack

.globl	dir, board

uleft	= 04040;
uright	= 04004;
dleft	= 00440;
dright	= 00404;
left	= 00040;
right	= 00004;
up	= 04000;
down	= 00400;
u2r1	= 06004;
u1r2	= 04006;
d1r2	= 00406;
d2r1	= 00604;
d2l1	= 00640;
d1l2	= 00460;
u1l2	= 04060;
u2l1	= 06040;

battack:
	mov	2(sp),r0
	asl	r0
	mov	dir(r0),r1
	mov	$2,r2
	bit	$u2r1,r1
	bne	1f
	cmp	board+[-15.*2](r0),r2
	beq	2f
1:
	bit	$u1r2,r1
	bne	1f
	cmp	board+[-6.*2](r0),r2
	beq	2f
1:
	bit	$d1r2,r1
	bne	1f
	cmp	board+[+10.*2](r0),r2
	beq	2f
1:
	bit	$d2r1,r1
	bne	1f
	cmp	board+[+17.*2](r0),r2
	beq	2f
1:
	bit	$d2l1,r1
	bne	1f
	cmp	board+[+15.*2](r0),r2
	beq	2f
1:
	bit	$d1l2,r1
	bne	1f
	cmp	board+[+6.*2](r0),r2
	beq	2f
1:
	bit	$u1l2,r1
	bne	1f
	cmp	board+[-10.*2](r0),r2
	beq	2f
1:
	bit	$u2l1,r1
	bne	1f
	cmp	board+[-17.*2](r0),r2
	beq	2f
1:
	jsr	r5,badiag
	.word	uleft, -9.*2
	jsr	r5,badiag
	.word	uright, -7.*2
	jsr	r5,badiag
	.word	dleft, 7.*2
	jsr	r5,badiag
	.word	dright, 9.*2
	jsr	r5,barank
	.word	up, -8.*2
	jsr	r5,barank
	.word	left, -1.*2
	jsr	r5,barank
	.word	right, 1.*2
	jsr	r5,barank
	.word	down, 8.*2

	bit	$uleft,dir(r0)
	bne	1f
	cmp	board-18.(r0),$1		/ pawn?
	beq	2f
1:
	bit	$uright,dir(r0)
	bne	1f
	cmp	board-14.(r0),$1
	bne	1f
2:
	clr	r0
	rts	pc
1:
	mov	$1,r0
	rts	pc

badiag:
	mov	r0,r1
	mov	(r5)+,r2
	mov	(r5)+,r3
	bit	r2,dir(r1)
	bne	1f
	add	r3,r1
	mov	board(r1),r4
	beq	2f
	cmp	r4,$3
	beq	9f
	cmp	r4,$5
	beq	9f
	cmp	r4,$6
	beq	9f
1:
	rts	r5
2:
	bit	r2,dir(r1)
	bne	2f
	add	r3,r1
	mov	board(r1),r4
	beq	2b
	cmp	r4,$3
	beq	9f
	cmp	r4,$5
	beq	9f
2:
	rts	r5

barank:
	mov	r0,r1
	mov	(r5)+,r2
	mov	(r5)+,r3
	bit	r2,dir(r1)
	bne	1f
	add	r3,r1
	mov	board(r1),r4
	beq	2f
	cmp	r4,$4
	beq	9f
	cmp	r4,$5
	beq	9f
	cmp	r4,$6
	beq	9f
1:
	rts	r5
2:
	bit	r2,dir(r1)
	bne	2f
	add	r3,r1
	mov	board(r1),r4
	beq	2b
	cmp	r4,$4
	beq	9f
	cmp	r4,$5
	beq	9f
2:
	rts	r5

9:
	mov	(sp)+,r5
	clr	r0
	rts	pc

wattack:
	mov	2(sp),r0
	asl	r0
	mov	dir(r0),r1
	mov	$-2,r2
	bit	$u2r1,r1
	bne	1f
	cmp	board+[-15.*2](r0),r2
	beq	2f
1:
	bit	$u1r2,r1
	bne	1f
	cmp	board+[-6.*2](r0),r2
	beq	2f
1:
	bit	$d1r2,r1
	bne	1f
	cmp	board+[+10.*2](r0),r2
	beq	2f
1:
	bit	$d2r1,r1
	bne	1f
	cmp	board+[+17.*2](r0),r2
	beq	2f
1:
	bit	$d2l1,r1
	bne	1f
	cmp	board+[+15.*2](r0),r2
	beq	2f
1:
	bit	$d1l2,r1
	bne	1f
	cmp	board+[+6.*2](r0),r2
	beq	2f
1:
	bit	$u1l2,r1
	bne	1f
	cmp	board+[-10.*2](r0),r2
	beq	2f
1:
	bit	$u2l1,r1
	bne	1f
	cmp	board+[-17.*2](r0),r2
	beq	2f
1:
	jsr	r5,wadiag
	.word	uleft, -9.*2
	jsr	r5,wadiag
	.word	uright, -7.*2
	jsr	r5,wadiag
	.word	dleft, 7.*2
	jsr	r5,wadiag
	.word	dright, 9.*2
	jsr	r5,warank
	.word	up, -8.*2
	jsr	r5,warank
	.word	left, -1.*2
	jsr	r5,warank
	.word	right, 1.*2
	jsr	r5,warank
	.word	down, 8.*2

	bit	$dleft,dir(r0)
	bne	1f
	cmp	board+14.(r0),$-1		/ pawn?
	beq	2f
1:
	bit	$dright,dir(r0)
	bne	1f
	cmp	board+18.(r0),$-1
	bne	1f
2:
	clr	r0
	rts	pc
1:
	mov	$1,r0
	rts	pc

wadiag:
	mov	r0,r1
	mov	(r5)+,r2
	mov	(r5)+,r3
	bit	r2,dir(r1)
	bne	1f
	add	r3,r1
	mov	board(r1),r4
	beq	2f
	cmp	r4,$-3
	beq	9f
	cmp	r4,$-5
	beq	9f
	cmp	r4,$-6
	beq	9f
1:
	rts	r5
2:
	bit	r2,dir(r1)
	bne	2f
	add	r3,r1
	mov	board(r1),r4
	beq	2b
	cmp	r4,$-3
	beq	9f
	cmp	r4,$-5
	beq	9f
2:
	rts	r5

warank:
	mov	r0,r1
	mov	(r5)+,r2
	mov	(r5)+,r3
	bit	r2,dir(r1)
	bne	1f
	add	r3,r1
	mov	board(r1),r4
	beq	2f
	cmp	r4,$-4
	beq	9f
	cmp	r4,$-5
	beq	9f
	cmp	r4,$-6
	beq	9f
1:
	rts	r5
2:
	bit	r2,dir(r1)
	bne	2f
	add	r3,r1
	mov	board(r1),r4
	beq	2b
	cmp	r4,$-4
	beq	9f
	cmp	r4,$-5
	beq	9f
2:
	rts	r5

9:
	mov	(sp)+,r5
	clr	r0
	rts	pc
