setup.s
3.97 KB
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
.arm
.align
.text
.global keyCheckSetup
.global displayLengthFlag
#include "defines.h"
cursorLocate: @ returns address of ^ in r5
push {r0-r4,r6-r12,lr}
ldr r5, =setupText @ Load setup bg map
cursorLocateLoop:
ldrb r0,[r5],#1
cmp r0,#94
bne cursorLocateLoop
sub r5, r5, #1
pop {r0-r4,r6-r12,lr}
bx lr
cursorJump:
push {r0-r12}
mov r0,#14
strb r0,[r5] @ erase cursor
cmp r4,#4
addeq r5,r5,#15 @redraw in proper place
moveq r2,#0x0001
subne r5,r5,#15
movne r2,#0x8000
mov r0,#94
strb r0,[r5]
strh r2,[r1]
pop {r0-r12}
b cursorMoveExit
cursorMove:
push {r0-r12,lr}
bl keySet @ marks key as down
cmp r7, #1
beq cursorMoveExit @ branch if down keeping cursor in place if key is held
@@@ Do cursor processes to move if tests are passed
bl cursorLocate @ returns cursor address in r5
ldr r1, =setupBit @ Load setupBit so se can keep track of what bit we're editing
ldrh r2, [r1] @ | and make sure we aren't exceeding bounds
cmp r4, #4 @ |
cmpeq r2, #0x8000 @ |
beq cursorJump @ |
cmp r4, #12 @ |
cmpeq r2, #0x0001 @ |
beq cursorJump @ /
mov r0, #16 @ erase current location of ^
strb r0, [r5] @ /
cmp r4, #4 @ Draw new position of ^ and keep track of current bit
subeq r5, r5, #1 @ |
moveq r2, r2, LSL #1 @ |
addne r5, r5, #1 @ |
movne r2, r2, LSR #1 @ |
mov r0, #94 @ |
strb r0, [r5] @ |
strh r2, [r1] @ /
cursorMoveExit:
pop {r0-r12,lr}
bx lr
flipBit: @ changes a 1 to a 0 and a 0 to a 1
push {r0-r12,lr}
bl keySet @ marks key as down
cmp r7, #1
beq flipBitExit @ branch if down keeping cursor in place if key is held
ldr r0, =setupBit
ldrh r0, [r0]
ldr r1, =notesettings
ldrh r2, [r1]
eor r2, r2, r0 @ isolate the bit to flip
strh r2, [r1] @ store it
flipBitExit:
pop {r0-r12,lr}
bx lr
keyClear:
push {r0-r12,lr}
ldr r6,=keystates
mov r0,#0
str r0,[r6,r4]
pop {r0-r12,lr}
bx lr
keySet: @ marks key as down
push {r0-r6,r8-r12,lr}
ldr r6,=keystates
ldr r0,[r6,r4] @@ set key used flag
cmp r0,#1
moveq r7,#1
mov r0,#1
str r0,[r6,r4]
pop {r0-r6,r8-r12,lr}
bx lr
@@@@@@@@
@
@ r4=offset for keystates and notes
@
@@@@@@@@
keyCheckSetup: @ Load keycheck routine and also call respective handlers
push {r0-r12,lr} @ Save link reg
ldr r0, =KEYINPUT
ldrh r1, [r0]
@@@ Change Settings / Move Cursor
mov r4, #4 @ keystates offset for key
ands r0, r1, #0b100000 @ AND key left
blne keyClear
bleq cursorMove
mov r4, #12 @ keystates offset for key
ands r0, r1, #0b10000 @ AND key right
blne keyClear
bleq cursorMove
mov r4, #24 @ keystates offset for key
ands r0, r1, #0b1 @ AND key A
blne keyClear
bleq flipBit
@@@ Start
mov r4, #36
ands r0, r1, #0b1000 @ key start
blne keyClear
bleq keySet
beq synth
@@@ Length Flag
mov r4, #20
ands r0, r1, #0b10 @ AND key select
blne keyClear
bleq flipLengthFlag
pop {r0-r12,lr} @ Recover link reg
bx lr
flipLengthFlag:
push {r0-r12,lr}
bleq keySet
cmp r7,#1
beq flipLengthFlagExit
ldr r0,=notesettings @ Toggle bit
ldrh r1,[r0,#4]
cmp r1,#0
moveq r3,#1
movne r3,#0
strh r3,[r0,#4]
ldr r0,=REG_SOUND1CNT_X
ldr r2,=REG_SOUND2CNT_H
ldrh r1,[r0]
orreq r1,r1,#0b100000000000000
eorne r1,r1,#0b100000000000000
strh r1,[r0]
strh r1,[r2]
bl displayLengthFlag
flipLengthFlagExit:
pop {r0-r12,lr}
bx lr
displayLengthFlag:
push {r0-r12,lr}
ldr r3,=notesettings
ldrh r3,[r3,#4]
cmp r3,#0
ldr r0,=setupText
ldr r1,=608 @ magic number for length status character in tile map
ldrneb r2,=76
ldreqb r2,=32
strb r2,[r0,r1]
pop {r0-r12,lr}
bx lr
@ vim: syntax=armasm