-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathHandler_MACROS.asm
59 lines (44 loc) · 1.89 KB
/
Handler_MACROS.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
; Copyright (C)2020 Andrew Davie
; Common macros for piece move handlers
;---------------------------------------------------------------------------------------------------
; Looks at a square offset {1} to see if piece can move to it
; Adds the square to the movelist if it can
; Keeps moving in the same direction until it's blocked/off=board
MAC MOVE_TOWARDS
SUBROUTINE
; = 76 for single square (empty/take)
lda #0
sta capture
ldx currentSquare ; 3
bne .project ; 3 unconditional
.empty jsr AddMove ; 57
.project ldy ValidSquare+{1},x ; 4
bmi .invalid ; 2/3 off board!
lda Board,y ; 4 piece @ destination
beq .empty ; 2/3
sta capture
eor currentPiece ; 3
bpl .invalid ; 2/3 same colour
jsr AddMove ; 57 and exit
.invalid
ENDM
;---------------------------------------------------------------------------------------------------
MAC MOVE_TO
SUBROUTINE
ldy ValidSquare+{1},x
bmi .invalid ; off board!
lda Board,y ; piece @ destination
sta capture
beq .squareEmpty
eor currentPiece
bpl .invalid ; same colour
.squareEmpty jsr AddMove
.invalid
ENDM
;---------------------------------------------------------------------------------------------------
MAC MOVE_TO_X
ldx currentSquare
MOVE_TO {1}
ENDM
;---------------------------------------------------------------------------------------------------
; EOF