-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmemory.asm
100 lines (94 loc) · 1.48 KB
/
memory.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
*=* "Memory"
/*
Fill memory with bytes. This is very similar to the memcopy routine
below, but just stores a single value into a range of addresses.
*/
FillMemory:
ldy #0
ldx fill_size + $01
beq !frag_fill+
!page_fill:
lda fill_value
sta (fill_to), y
iny
bne !page_fill-
inc fill_to + $01
dex
bne !page_fill-
!frag_fill:
cpy fill_size
beq !done_fill+
lda fill_value
sta (fill_to), y
iny
bne !frag_fill-
!done_fill:
rts
/*
Do the actual memory copy.
Doesn't need to be on a page boundary. Can copy fragments as well.
*/
CopyMemory:
ldy #0
ldx copy_size + $01
beq !frag+
!page:
lda (copy_from), y
sta (copy_to), y
iny
bne !page-
inc copy_from + $01
inc copy_to + $01
dex
bne !page-
!frag:
cpy copy_size
beq !done+
lda (copy_from), y
sta (copy_to), y
iny
bne !frag-
!done:
rts
/*
Flip the board
*/
FlipBoard:
PushStack()
ldx #$3f
ldy #$00
!loop:
lda BoardState, x
sta fliptmp, y
iny
dex
cpx #$ff
bne !loop-
ldx #$00
!loop2:
lda fliptmp, x
sta BoardState, x
inx
cpx #$40
bne !loop2-
PopStack()
rts
/*
Enable the flashing of the selected piece
*/
FlashPieceOn:
bfs movefromindex:!exit+
ldx movefromindex
stb BoardState, x:selectedpiece
sef flashpiece // Turn flashing on
!exit:
rts
/*
Disable the flashing of a selected piece
*/
FlashPieceOff:
clf flashpiece // Turn flashing off
ldx movefromindex // Stick it back in BoardState
stb selectedpiece:BoardState, x
!exit:
rts