1 /* vi:set ts=4 sts=4 sw=4 noexpandtab: */
5 static u8 _oldfxparam
= 0;
7 /* move cursor left one column */
22 /* move cursor right one column */
23 void act_mvright(void){
26 if(songx
< 15) songx
++;
29 if(trackx
< 9) trackx
++;
32 if(instrx
< 2) instrx
++;
37 /* move cursor up 1 line */
64 /* move cursor down 1 line */
65 void act_mvdown(void){
68 if(songy
< songlen
- 1){
75 if(tracky
< tracklen
- 1){
78 tracky
= tracklen
- 1;
82 if(instry
< instrument
[currinstr
].length
- 1){
85 instry
= instrument
[currinstr
].length
- 1;
91 /* move cursor up 8 lines */
92 void act_bigmvup(void){
109 if(instry
>= 8) instry
-= 8;
114 /* move cursor down 8 lines */
115 void act_bigmvdown(void){
118 if(songy
< songlen
- 8){
125 if(tracky
< tracklen
- 8){
128 tracky
= tracklen
- 1;
132 if(instry
< instrument
[currinstr
].length
- 8) instry
+= 8;
137 void act_viewtrackinc(void){
138 if(currtrack
< 0xff){
140 }else if(currtrack
== 0xff){
144 startplaytrack(currtrack
);
148 void act_viewtrackdec(void){
151 }else if(currtrack
== 1){
155 startplaytrack(currtrack
);
159 void act_viewinstrinc(void){
160 if(currinstr
== 0xff) currinstr
= 0x01;
164 void act_viewinstrdec(void){
165 if(currinstr
== 1) currinstr
= 0xff;
169 void act_trackinc(void){
171 if(songx
>= 240 && songx
< 256){
172 song
[songy
].track
[songx
/4] -= 240;
174 song
[songy
].track
[songx
/4] += 16;
177 if( (song
[songy
].track
[songx
/4] % 16) == 15){
178 song
[songy
].track
[songx
/4] -= 15;
180 song
[songy
].track
[songx
/4]++;
186 void act_trackdec(void){
188 if(songx
<= 15 && songx
>= 0){
189 song
[songy
].track
[songx
/4] += 240;
191 song
[songy
].track
[songx
/4] -= 16;
194 if( (song
[songy
].track
[songx
/4] % 16) == 0){
195 song
[songy
].track
[songx
/4] += 15;
197 song
[songy
].track
[songx
/4]--;
203 void act_transpinc(void){
205 if(songx
>= 240 && songx
< 256){
206 song
[songy
].transp
[songx
/4] -= 240;
208 song
[songy
].transp
[songx
/4] += 16;
211 if( (song
[songy
].transp
[songx
/4] % 16) == 15){
212 song
[songy
].transp
[songx
/4] -= 15;
214 song
[songy
].transp
[songx
/4]++;
220 void act_transpdec(void){
222 if(songx
<= 15 && songx
>= 0){
223 song
[songy
].transp
[songx
/4] += 240;
225 song
[songy
].transp
[songx
/4] -= 16;
228 if( (song
[songy
].transp
[songx
/4] % 16) == 0){
229 song
[songy
].transp
[songx
/4] += 15;
231 song
[songy
].transp
[songx
/4]--;
240 void act_noteinc(void){
242 // if current note < H7
243 if( track
[currtrack
].line
[tracky
].note
< 96 ){
244 track
[currtrack
].line
[tracky
].note
++;
246 track
[currtrack
].line
[tracky
].note
= 0;
248 }else if(currtab
==2){
249 if( instrument
[currinstr
].line
[instry
].param
< 96 ){
250 instrument
[currinstr
].line
[instry
].param
++;
252 instrument
[currinstr
].line
[instry
].param
= 0;
258 void act_notedec(void){
260 if( track
[currtrack
].line
[tracky
].note
> 0 ){
261 track
[currtrack
].line
[tracky
].note
--;
263 track
[currtrack
].line
[tracky
].note
= 96;
265 }else if(currtab
==2){
266 if( instrument
[currinstr
].line
[instry
].param
> 0 ){
267 instrument
[currinstr
].line
[instry
].param
--;
269 instrument
[currinstr
].line
[instry
].param
= 96;
275 void act_octaveinc(void){
277 if( track
[currtrack
].line
[tracky
].note
+12 <= 96 ){
278 track
[currtrack
].line
[tracky
].note
+=12;
280 track
[currtrack
].line
[tracky
].note
%= 12;
282 }else if(currtab
==2){ if(instrument
[currinstr
].line
[instry
].cmd
== '+' || instrument
[currinstr
].line
[instry
].cmd
== '='){
283 if( instrument
[currinstr
].line
[instry
].param
+12 <= 96 ){
284 instrument
[currinstr
].line
[instry
].param
+=12;
286 instrument
[currinstr
].line
[instry
].param
%= 12;
293 void act_octavedec(void){
295 if( track
[currtrack
].line
[tracky
].note
-12 > 0 ){
296 track
[currtrack
].line
[tracky
].note
-=12;
298 track
[currtrack
].line
[tracky
].note
= 84 + track
[currtrack
].line
[tracky
].note
;
300 }else if(currtab
==2){
301 if(instrument
[currinstr
].line
[instry
].cmd
== '+' || instrument
[currinstr
].line
[instry
].cmd
== '='){
302 if( instrument
[currinstr
].line
[instry
].param
-12 > 0 ){
303 instrument
[currinstr
].line
[instry
].param
-=12;
305 instrument
[currinstr
].line
[instry
].param
= 84 + instrument
[currinstr
].line
[instry
].param
;
312 void act_instrinc(void){
315 SETHI(track
[currtrack
].line
[tracky
].instr
,
316 hexinc(track
[currtrack
].line
[tracky
].instr
>> 4) );
319 SETLO(track
[currtrack
].line
[tracky
].instr
,
320 hexinc(track
[currtrack
].line
[tracky
].instr
& 0x0f) );
326 void act_instrdec(void){
329 SETHI(track
[currtrack
].line
[tracky
].instr
,
330 hexdec(track
[currtrack
].line
[tracky
].instr
>> 4) );
333 SETLO(track
[currtrack
].line
[tracky
].instr
,
334 hexdec(track
[currtrack
].line
[tracky
].instr
& 0x0f) );
340 void act_fxinc(void){
342 currcmd
= track
[currtrack
].line
[tracky
].cmd
[trackx
% 2];
343 // there must be a better way to do this...
344 if((unsigned long)currcmd
== (unsigned long)NULL
){
345 track
[currtrack
].line
[tracky
].cmd
[trackx
% 2] = validcmds
[0];
347 for(int z
= 0; z
< strlen(validcmds
); z
++){
348 if(currcmd
== validcmds
[z
]){
349 if(z
== (strlen(validcmds
)-1)){
350 track
[currtrack
].line
[tracky
].cmd
[trackx
% 2] = (unsigned long)NULL
;
352 track
[currtrack
].line
[tracky
].cmd
[trackx
% 2] = validcmds
[z
+1];
358 }else if(currtab
==2){
359 currcmd
= instrument
[currinstr
].line
[instry
].cmd
;
360 for(int z
= 0; z
< strlen(validcmds
); z
++){
361 if(currcmd
== validcmds
[z
]){
362 if(z
== (strlen(validcmds
)-1)){
363 instrument
[currinstr
].line
[instry
].cmd
= validcmds
[0];
365 instrument
[currinstr
].line
[instry
].cmd
= validcmds
[z
+1];
367 instrument
[currinstr
].line
[instry
].param
= _oldfxparam
;
370 // when switching to the note command, change to param if it's
372 if((instrument
[currinstr
].line
[instry
].cmd
== '+' || instrument
[currinstr
].line
[instry
].cmd
== '=')
374 && instrument
[currinstr
].line
[instry
].param
>96){
375 // save current param
376 _oldfxparam
= instrument
[currinstr
].line
[instry
].param
;
377 instrument
[currinstr
].line
[instry
].param
= 96; //H7
378 }else if(_oldfxparam
){
379 instrument
[currinstr
].line
[instry
].param
= _oldfxparam
;
390 void act_fxdec(void){
392 currcmd
= track
[currtrack
].line
[tracky
].cmd
[trackx
% 2];
393 if((unsigned long)currcmd
== (unsigned long)NULL
){
394 track
[currtrack
].line
[tracky
].cmd
[trackx
% 2] = validcmds
[strlen(validcmds
)-1];
396 for(int z
= 0; z
< strlen(validcmds
); z
++){
397 if(currcmd
== validcmds
[z
]){
399 track
[currtrack
].line
[tracky
].cmd
[trackx
% 2] = (unsigned long)NULL
;
401 track
[currtrack
].line
[tracky
].cmd
[trackx
% 2] = validcmds
[z
-1];
407 }else if(currtab
==2){
408 currcmd
= instrument
[currinstr
].line
[instry
].cmd
;
409 for(int z
= 0; z
< strlen(validcmds
); z
++){
410 if(currcmd
== validcmds
[z
]){
412 instrument
[currinstr
].line
[instry
].cmd
= validcmds
[strlen(validcmds
)-1];
414 instrument
[currinstr
].line
[instry
].cmd
= validcmds
[z
-1];
416 instrument
[currinstr
].line
[instry
].param
= _oldfxparam
;
419 // when switching to the note command, change to param if it's
421 if((instrument
[currinstr
].line
[instry
].cmd
== '+' || instrument
[currinstr
].line
[instry
].cmd
== '=')
423 && instrument
[currinstr
].line
[instry
].param
>96){
424 // save current param
425 _oldfxparam
= instrument
[currinstr
].line
[instry
].param
;
426 instrument
[currinstr
].line
[instry
].param
= 96; //H7
427 }else if(_oldfxparam
){
428 instrument
[currinstr
].line
[instry
].param
= _oldfxparam
;
439 void act_paraminc(void){
441 if((trackx
==5 && track
[currtrack
].line
[tracky
].cmd
[0])
442 || (trackx
==8 && track
[currtrack
].line
[tracky
].cmd
[1])){
443 SETHI(track
[currtrack
].line
[tracky
].param
[(trackx
- 1) % 2],
444 hexinc(track
[currtrack
].line
[tracky
].param
[(trackx
- 1) % 2] >> 4) );
446 }else if((trackx
==6 && track
[currtrack
].line
[tracky
].cmd
[0])
447 || (trackx
==9 && track
[currtrack
].line
[tracky
].cmd
[1])){
448 SETLO(track
[currtrack
].line
[tracky
].param
[trackx
% 2],
449 hexinc(track
[currtrack
].line
[tracky
].param
[trackx
% 2] & 0x0f) );
452 }else if(currtab
== 2){
454 SETHI(instrument
[currinstr
].line
[instry
].param
,
455 hexinc(instrument
[currinstr
].line
[instry
].param
>> 4) );
457 }else if(instrx
== 2){
458 SETLO(instrument
[currinstr
].line
[instry
].param
,
459 hexinc(instrument
[currinstr
].line
[instry
].param
& 0x0f) );
466 void act_paramdec(void){
468 if((trackx
==5 && track
[currtrack
].line
[tracky
].cmd
[0])
469 || (trackx
==8 && track
[currtrack
].line
[tracky
].cmd
[1])){
470 SETHI(track
[currtrack
].line
[tracky
].param
[(trackx
-1) % 2],
471 hexdec(track
[currtrack
].line
[tracky
].param
[(trackx
-1) % 2] >> 4) );
473 }else if((trackx
==6 && track
[currtrack
].line
[tracky
].cmd
[0])
474 || (trackx
==9 && track
[currtrack
].line
[tracky
].cmd
[1])){
475 SETLO(track
[currtrack
].line
[tracky
].param
[trackx
% 2],
476 hexdec(track
[currtrack
].line
[tracky
].param
[trackx
% 2] & 0x0f) );
479 }else if(currtab
== 2){
481 SETHI(instrument
[currinstr
].line
[instry
].param
,
482 hexdec(instrument
[currinstr
].line
[instry
].param
>> 4) );
484 }else if(instrx
== 2){
485 SETLO(instrument
[currinstr
].line
[instry
].param
,
486 hexdec(instrument
[currinstr
].line
[instry
].param
& 0x0f) );
493 void act_addline(void){
495 struct instrument
*in
= &instrument
[currinstr
];
497 if(in
->length
< 256){
498 memmove(&in
->line
[instry
+ 2], &in
->line
[instry
+ 1], sizeof(struct instrline
) * (in
->length
- instry
- 1));
501 in
->line
[instry
].cmd
= '0';
502 in
->line
[instry
].param
= 0;
504 }else if(currtab
== 0){
506 memmove(&song
[songy
+ 2], &song
[songy
+ 1], sizeof(struct songline
) * (songlen
- songy
- 1));
509 memset(&song
[songy
], 0, sizeof(struct songline
));
515 void act_delline(void){
517 struct instrument
*in
= &instrument
[currinstr
];
520 memmove(&in
->line
[instry
+ 0], &in
->line
[instry
+ 1], sizeof(struct instrline
) * (in
->length
- instry
- 1));
522 if(instry
>= in
->length
) instry
= in
->length
- 1;
524 }else if(currtab
== 0){
526 memmove(&song
[songy
+ 0], &song
[songy
+ 1], sizeof(struct songline
) * (songlen
- songy
- 1));
528 if(songy
>= songlen
) songy
= songlen
- 1;
534 void act_clronething(void){
538 song
[songy
].track
[songx
/4] = (song
[songy
].track
[songx
/4] - song
[songy
].track
[songx
/4]) + song
[songy
].track
[songx
/4]%16;
540 song
[songy
].track
[songx
/4] -= song
[songy
].track
[songx
/4]%16;
544 song
[songy
].transp
[songx
/4] = (song
[songy
].transp
[songx
/4] - song
[songy
].transp
[songx
/4]) + song
[songy
].transp
[songx
/4]%16;
546 song
[songy
].transp
[songx
/4] -= song
[songy
].transp
[songx
/4]%16;
549 //memcpy(&tclip, &song[songy], sizeof(struct songline));
550 }else if(currtab
== 1){
553 memcpy(&tclip
, &track
[currtrack
].line
[tracky
], sizeof(struct trackline
));
554 track
[currtrack
].line
[tracky
].note
= 0;
555 track
[currtrack
].line
[tracky
].instr
= 0;
559 memcpy(&tclip
, &track
[currtrack
].line
[tracky
].instr
, sizeof(struct trackline
));
560 SETHI(track
[currtrack
].line
[tracky
].instr
, 0);
563 memcpy(&tclip
, &track
[currtrack
].line
[tracky
].instr
, sizeof(struct trackline
));
564 SETLO(track
[currtrack
].line
[tracky
].instr
, 0);
567 track
[currtrack
].line
[tracky
].cmd
[0] = 0;
570 SETHI(track
[currtrack
].line
[tracky
].param
[0],0);
573 SETLO(track
[currtrack
].line
[tracky
].param
[0],0);
576 track
[currtrack
].line
[tracky
].cmd
[1] = 0;
579 SETHI(track
[currtrack
].line
[tracky
].param
[1],0);
582 SETLO(track
[currtrack
].line
[tracky
].param
[1],0);
585 setdisplay("in ACT_CLRONETHING");
588 }else if(currtab
== 2){
590 instrument
[currinstr
].line
[instry
].cmd
= '0';
591 }else if(instrx
== 1){
592 if(instrument
[currinstr
].line
[instry
].cmd
== '+' || instrument
[currinstr
].line
[instry
].cmd
== '='){
593 instrument
[currinstr
].line
[instry
].param
= 0;
595 SETHI(instrument
[currinstr
].line
[instry
].param
,0);
597 }else if(instrx
== 2){
598 if(instrument
[currinstr
].line
[instry
].cmd
== '+' || instrument
[currinstr
].line
[instry
].cmd
== '='){
599 instrument
[currinstr
].line
[instry
].param
= 0;
601 SETLO(instrument
[currinstr
].line
[instry
].param
,0);
608 void act_clritall(void){
610 for(int ci
= 0; ci
< 4; ci
++){
611 song
[songy
].track
[ci
] = 0;
612 song
[songy
].transp
[ci
] = 0;
614 }else if(currtab
== 1){
615 track
[currtrack
].line
[tracky
].note
= 0;
616 track
[currtrack
].line
[tracky
].instr
= 0;
617 SETHI(track
[currtrack
].line
[tracky
].instr
, 0);
618 SETLO(track
[currtrack
].line
[tracky
].instr
, 0);
619 track
[currtrack
].line
[tracky
].cmd
[0] = 0;
620 SETHI(track
[currtrack
].line
[tracky
].param
[0],0);
621 SETLO(track
[currtrack
].line
[tracky
].param
[0],0);
622 track
[currtrack
].line
[tracky
].cmd
[1] = 0;
623 SETHI(track
[currtrack
].line
[tracky
].param
[1],0);
624 SETLO(track
[currtrack
].line
[tracky
].param
[1],0);
625 }else if(currtab
== 2){
626 instrument
[currinstr
].line
[instry
].cmd
= '0';
627 instrument
[currinstr
].line
[instry
].param
= 0;
632 // clear line y in the song tab
633 void act_clrinsongtab(int y
){
634 for(int ci
= 0; ci
< 4; ci
++){
635 song
[songy
].track
[ci
] = 0;
636 song
[songy
].transp
[ci
] = 0;
641 void act_clrintracktab(int t
, int y
){
642 track
[t
].line
[y
].note
= 0;
643 track
[t
].line
[y
].instr
= 0;
644 SETHI(track
[t
].line
[y
].instr
, 0);
645 SETLO(track
[t
].line
[y
].instr
, 0);
646 track
[t
].line
[y
].cmd
[0] = 0;
647 SETHI(track
[t
].line
[y
].param
[0],0);
648 SETLO(track
[t
].line
[y
].param
[0],0);
649 track
[t
].line
[y
].cmd
[1] = 0;
650 SETHI(track
[t
].line
[y
].param
[1],0);
651 SETLO(track
[t
].line
[y
].param
[1],0);
655 void act_clrininstrtab(int instr
, int y
){
656 instrument
[instr
].line
[y
].cmd
= '0';
657 instrument
[instr
].line
[y
].param
= 0;