-
Notifications
You must be signed in to change notification settings - Fork 2
/
editTrack.asm
298 lines (258 loc) · 4.96 KB
/
editTrack.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
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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
;------------------------------------------------------------------------------
; EDIT TRACK - drum assignments and also order of tracks
;------------------------------------------------------------------------------
editTrack:
jsr checkRepeatKeyA
jsr checkRepeatKeyB
jsr checkRepeatKeyUD
jsr checkRepeatKeyLR
lda #WRAM_PATTERNS
jsr setMMC1r1
ldx editorCurrentPattern
lda patternTableLo,x
sta editorTmp0
lda patternTableHi,x
sta editorTmp1
lda editorWaitForAB
beq :+
jmp @keyWaitAB
: lda editorWaitForClone
beq :+++++
lda editorPhraseForClone
bne :++
jsr editorFindClonePhrase
bcc :+
lda #$00 ;print error
sta editorWaitForClone
ldx #MSG_CLONE_ERROR
lda #$60
jsr editorSetErrorMessage
: jmp @x
: lda editorFoundEmpty
bne :+
jsr editorFindEmptyPhrase
bcc :++
lda #$00
sta editorWaitForClone ;error
ldx #MSG_CLONE_ERROR
lda #$60
jsr editorSetErrorMessage
jmp @x
: jsr editorClonePhrase
lda #$00
sta editorWaitForClone
: jmp @x
:
jsr _holdSelect_tapDown
bcc :+
ldx #EDIT_GRID_MENU
jsr editorShowEditMenu
lda editorMode
sta editorModeBeforeMenu
lda #EDIT_MODE_GRID_MENU
sta editorMode
jmp @x
: jsr _holdSelect_tapUp
bcc :+
ldx #MSG_PASTE
jsr editorSetConfirmMessage
lda #$01
sta editorWaitForAB
jmp @x
: lda cursorY_grid
clc
adc #PATTERN_DRUM_0
adc cursorX_track
tay
lda #numberOfDrums
ldx cursorX_track
beq :+
lda #numberOfPhrases
: sta editorTmp2
lda keyReleaseA ;tap A to repeat last value
beq :++
lda PAD1_fireb
bne :++
lda editorLastDrumValue
ldx cursorX_track
beq :+
lda editorLastPhraseValue
: sta (editorTmp0),y
sta editorTrackDrum,y
jmp :+++++++++
: lda keyRepeatB
beq :++++
lda PAD1_dud
beq :++
bmi :+
lda editorMode
sta previousEditorMode
jsr editAdjustDrumSubMode
lda #EDIT_MODE_DRUM
sta editorMode
jmp @x
: lda editorMode
sta previousEditorMode
lda #EDIT_MODE_PATTERN_NUMBER
sta editorMode
jmp @x
: lda PAD1_dlr
beq :+
bmi :+
lda #EDIT_MODE_GRID
sta editorMode
jmp @x
: lda keyReleaseA ;hold B, tap A
beq :+
lda #$00
sta editorPhraseForClone
sta editorPatternToCheck
sta editorPatternToCheck+1
sta editorFoundEmpty
lda #$01
sta editorWaitForClone
jsr editClearPhraseUsedTable
jmp @x
: lda keyReleaseB
beq :+
lda cursorY_grid
clc
adc cursorX_track
tay
lda #$00
sta (editorTmp0),y
sta editorTrackDrum,y
jmp :++++
: lda keyRepeatA
bne :+
jmp :+++++++
: lda PAD1_sel
beq :+
jsr editorReorderTracks
jmp @x
: lda PAD1_dud
ora keyRepeatUD
ora PAD1_dlr
ora keyRepeatLR
beq :+++
swapSign PAD1_dud
swapSign keyRepeatUD
lda PAD1_dud
ora keyRepeatUD
asl a
asl a
asl a
asl a
sta editorTmp3
lda PAD1_dlr
ora keyRepeatLR
clc
adc editorTmp3
clc
adc (editorTmp0),y
; cmp #$FF ;BUG - allows Phrase to be set lower than 0
; beq :++++ ; because max phrase number is 192 which is negative (8-bit signed)
; cmp editorTmp2 ; but Drum assignment only goes to 127 (positive)
; bcs :++++
cmp editorTmp2 ;BUG FIX - see comment above
bcs :+++
sta (editorTmp0),y
sta editorTrackDrum,y
: ldx cursorX_track ;editing drum or phrase number?
bne :+++
cmp editorCurrentDrum ;drum, has it changed?
beq :+
sta editorCurrentDrum
sta editorLastDrumValue
jsr editorDecodeDrum
jsr editorPrintDrum
:
lda cursorY_grid
jsr editorDecodeTrackDrum
ldy cursorY_grid
lda @trackProcs,y
jsr addProcessToBuffer
: jmp @x
: sta editorLastPhraseValue
lda cursorY_grid ;phrase
jsr editorDecodePhrase
lda cursorY_grid
jsr editorDecodeTrackDrum
ldy cursorY_grid
lda @phraseProcs,y
jsr addProcessToBuffer
ldy cursorY_grid
lda @trackProcs,y
jsr addProcessToBuffer
jmp @x
: lda PAD1_dud
ora keyRepeatUD
beq :++
clc
adc cursorY_grid
bmi :++
cmp #rowsPerGrid
bcs :++
sta cursorY_grid
ldy cursorY_grid
lda editorTrackDrum,y
cmp editorCurrentDrum
beq :+
sta editorCurrentDrum
jsr editorDecodeDrum
jsr editorPrintDrum
jsr editorDecodeTriggerParameters
jsr editorPrintTriggers
: jmp @x
: lda PAD1_dlr
beq :+
lda cursorX_track
eor #$06
sta cursorX_track
:
lda cursorY_grid
clc
adc #PATTERN_DRUM_0
adc cursorX_track
tax
lda @cursorX,x
sta editorCursorX
lda @cursorY,x
sta editorCursorY
@x: lda #$02
sta editorCursorMode
jsr editorUpdateCursor
rts ;jmp editorMainLoop
@keyWaitAB:
lda editorWaitForAB
beq :++
lda keyReleaseB
bne :+
lda keyReleaseA
beq :++
jsr editorPasteGrid
: lda #$01
sta editorCopyInfoTimer
lda #$00
sta editorWaitForAB
: rts
@cursorY:
.REPEAT rowsPerGrid,i
.BYTE TRACK_CURSOR_Y_BASE + (i * 8)
.ENDREPEAT
.REPEAT rowsPerGrid,i
.BYTE TRACK_CURSOR_Y_BASE + (i * 8)
.ENDREPEAT
@cursorX:
.REPEAT rowsPerGrid,i
.BYTE TRACK_CURSOR_X_BASE + (1 * 8)
.ENDREPEAT
.REPEAT rowsPerGrid,i
.BYTE TRACK_CURSOR_X_BASE + (4 *8)
.ENDREPEAT
@trackProcs:
.BYTE procTrackDrum00,procTrackDrum01,procTrackDrum02
.BYTE procTrackDrum03,procTrackDrum04,procTrackDrum05
@phraseProcs:
.BYTE procGridRow00,procGridRow01,procGridRow02
.BYTE procGridRow03,procGridRow04,procGridRow05