1 /* vi:set ts=8 sts=8 sw=8 noexpandtab: */
7 static u8 _oldfxparam
= 0;
9 /* move cursor left one column */
10 void act_mvleft(void){
24 /* move cursor right one column */
25 void act_mvright(void){
28 if(songx
< 15) songx
++;
31 if(trackx
< 9) trackx
++;
34 if(instrx
< 2) instrx
++;
39 /* move cursor up 1 line */
66 /* move cursor down 1 line */
67 void act_mvdown(void){
70 if(songy
< songlen
- 1){
77 if(tracky
< tracklen
- 1){
80 tracky
= tracklen
- 1;
84 if(instry
< instrument
[currinstr
].length
- 1){
87 instry
= instrument
[currinstr
].length
- 1;
93 /* move cursor up 8 lines */
94 void act_bigmvup(void){
111 if(instry
>= 8) instry
-= 8;
116 /* move cursor down 8 lines */
117 void act_bigmvdown(void){
120 if(songy
< songlen
- 8){
127 if(tracky
< tracklen
- 8){
130 tracky
= tracklen
- 1;
134 if(instry
< instrument
[currinstr
].length
- 8) instry
+= 8;
139 void act_mvbottom(void){
145 tracky
= tracklen
- 1;
148 instry
= instrument
[currinstr
].length
- 1;
153 void act_mvtop(void){
167 void act_viewtrackinc(void){
168 if(currtrack
< 0xff){
170 }else if(currtrack
== 0xff){
174 startplaytrack(currtrack
);
178 void act_viewtrackdec(void){
181 }else if(currtrack
== 1){
185 startplaytrack(currtrack
);
189 void act_viewinstrinc(void){
190 if(currinstr
== 0xff) currinstr
= 0x01;
194 void act_viewinstrdec(void){
195 if(currinstr
== 1) currinstr
= 0xff;
199 void act_trackinc(void){
201 if(songx
>= 240 && songx
< 256){
202 song
[songy
].track
[songx
/4] -= 240;
204 song
[songy
].track
[songx
/4] += 16;
207 if( (song
[songy
].track
[songx
/4] % 16) == 15){
208 song
[songy
].track
[songx
/4] -= 15;
210 song
[songy
].track
[songx
/4]++;
216 void act_trackdec(void){
218 if(songx
<= 15 && songx
>= 0){
219 song
[songy
].track
[songx
/4] += 240;
221 song
[songy
].track
[songx
/4] -= 16;
224 if( (song
[songy
].track
[songx
/4] % 16) == 0){
225 song
[songy
].track
[songx
/4] += 15;
227 song
[songy
].track
[songx
/4]--;
233 void act_transpinc(void){
235 if(songx
>= 240 && songx
< 256){
236 song
[songy
].transp
[songx
/4] -= 240;
238 song
[songy
].transp
[songx
/4] += 16;
241 if( (song
[songy
].transp
[songx
/4] % 16) == 15){
242 song
[songy
].transp
[songx
/4] -= 15;
244 song
[songy
].transp
[songx
/4]++;
250 void act_transpdec(void){
252 if(songx
<= 15 && songx
>= 0){
253 song
[songy
].transp
[songx
/4] += 240;
255 song
[songy
].transp
[songx
/4] -= 16;
258 if( (song
[songy
].transp
[songx
/4] % 16) == 0){
259 song
[songy
].transp
[songx
/4] += 15;
261 song
[songy
].transp
[songx
/4]--;
270 void act_noteinc(void){
272 // if current note < H7
273 if( track
[currtrack
].line
[tracky
].note
< 96 ){
274 track
[currtrack
].line
[tracky
].note
++;
276 track
[currtrack
].line
[tracky
].note
= 0;
278 }else if(currtab
==2){
279 if( instrument
[currinstr
].line
[instry
].param
< 96 ){
280 instrument
[currinstr
].line
[instry
].param
++;
282 instrument
[currinstr
].line
[instry
].param
= 0;
288 void act_notedec(void){
290 if( track
[currtrack
].line
[tracky
].note
> 0 ){
291 track
[currtrack
].line
[tracky
].note
--;
293 track
[currtrack
].line
[tracky
].note
= 96;
295 }else if(currtab
==2){
296 if( instrument
[currinstr
].line
[instry
].param
> 0 ){
297 instrument
[currinstr
].line
[instry
].param
--;
299 instrument
[currinstr
].line
[instry
].param
= 96;
305 void act_octaveinc(void){
307 if( track
[currtrack
].line
[tracky
].note
+12 <= 96 ){
308 track
[currtrack
].line
[tracky
].note
+=12;
310 track
[currtrack
].line
[tracky
].note
%= 12;
312 }else if(currtab
==2){ if(instrument
[currinstr
].line
[instry
].cmd
== '+' || instrument
[currinstr
].line
[instry
].cmd
== '='){
313 if( instrument
[currinstr
].line
[instry
].param
+12 <= 96 ){
314 instrument
[currinstr
].line
[instry
].param
+=12;
316 instrument
[currinstr
].line
[instry
].param
%= 12;
323 void act_octavedec(void){
325 if( track
[currtrack
].line
[tracky
].note
-12 > 0 ){
326 track
[currtrack
].line
[tracky
].note
-=12;
328 track
[currtrack
].line
[tracky
].note
= 84 + track
[currtrack
].line
[tracky
].note
;
330 }else if(currtab
==2){
331 if(instrument
[currinstr
].line
[instry
].cmd
== '+' || instrument
[currinstr
].line
[instry
].cmd
== '='){
332 if( instrument
[currinstr
].line
[instry
].param
-12 > 0 ){
333 instrument
[currinstr
].line
[instry
].param
-=12;
335 instrument
[currinstr
].line
[instry
].param
= 84 + instrument
[currinstr
].line
[instry
].param
;
342 void act_instrinc(void){
345 SETHI(track
[currtrack
].line
[tracky
].instr
,
346 hexinc(track
[currtrack
].line
[tracky
].instr
>> 4) );
349 SETLO(track
[currtrack
].line
[tracky
].instr
,
350 hexinc(track
[currtrack
].line
[tracky
].instr
& 0x0f) );
356 void act_instrdec(void){
359 SETHI(track
[currtrack
].line
[tracky
].instr
,
360 hexdec(track
[currtrack
].line
[tracky
].instr
>> 4) );
363 SETLO(track
[currtrack
].line
[tracky
].instr
,
364 hexdec(track
[currtrack
].line
[tracky
].instr
& 0x0f) );
370 void act_fxinc(void){
372 currcmd
= track
[currtrack
].line
[tracky
].cmd
[trackx
% 2];
373 // there must be a better way to do this...
374 if((unsigned long)currcmd
== (unsigned long)NULL
){
375 track
[currtrack
].line
[tracky
].cmd
[trackx
% 2] = validcmds
[0];
377 for(int z
= 0; z
< strlen(validcmds
); z
++){
378 if(currcmd
== validcmds
[z
]){
379 if(z
== (strlen(validcmds
)-1)){
380 track
[currtrack
].line
[tracky
].cmd
[trackx
% 2] = (unsigned long)NULL
;
382 track
[currtrack
].line
[tracky
].cmd
[trackx
% 2] = validcmds
[z
+1];
388 }else if(currtab
==2){
389 currcmd
= instrument
[currinstr
].line
[instry
].cmd
;
390 for(int z
= 0; z
< strlen(validcmds
); z
++){
391 if(currcmd
== validcmds
[z
]){
392 if(z
== (strlen(validcmds
)-1)){
393 instrument
[currinstr
].line
[instry
].cmd
= validcmds
[0];
395 instrument
[currinstr
].line
[instry
].cmd
= validcmds
[z
+1];
397 instrument
[currinstr
].line
[instry
].param
= _oldfxparam
;
400 // when switching to the note command, change to param if it's
402 if((instrument
[currinstr
].line
[instry
].cmd
== '+' || instrument
[currinstr
].line
[instry
].cmd
== '=')
404 && instrument
[currinstr
].line
[instry
].param
>96){
405 // save current param
406 _oldfxparam
= instrument
[currinstr
].line
[instry
].param
;
407 instrument
[currinstr
].line
[instry
].param
= 96; //H7
408 }else if(_oldfxparam
){
409 instrument
[currinstr
].line
[instry
].param
= _oldfxparam
;
420 void act_fxdec(void){
422 currcmd
= track
[currtrack
].line
[tracky
].cmd
[trackx
% 2];
423 if((unsigned long)currcmd
== (unsigned long)NULL
){
424 track
[currtrack
].line
[tracky
].cmd
[trackx
% 2] = validcmds
[strlen(validcmds
)-1];
426 for(int z
= 0; z
< strlen(validcmds
); z
++){
427 if(currcmd
== validcmds
[z
]){
429 track
[currtrack
].line
[tracky
].cmd
[trackx
% 2] = (unsigned long)NULL
;
431 track
[currtrack
].line
[tracky
].cmd
[trackx
% 2] = validcmds
[z
-1];
437 }else if(currtab
==2){
438 currcmd
= instrument
[currinstr
].line
[instry
].cmd
;
439 for(int z
= 0; z
< strlen(validcmds
); z
++){
440 if(currcmd
== validcmds
[z
]){
442 instrument
[currinstr
].line
[instry
].cmd
= validcmds
[strlen(validcmds
)-1];
444 instrument
[currinstr
].line
[instry
].cmd
= validcmds
[z
-1];
446 instrument
[currinstr
].line
[instry
].param
= _oldfxparam
;
449 // when switching to the note command, change to param if it's
451 if((instrument
[currinstr
].line
[instry
].cmd
== '+' || instrument
[currinstr
].line
[instry
].cmd
== '=')
453 && instrument
[currinstr
].line
[instry
].param
>96){
454 // save current param
455 _oldfxparam
= instrument
[currinstr
].line
[instry
].param
;
456 instrument
[currinstr
].line
[instry
].param
= 96; //H7
457 }else if(_oldfxparam
){
458 instrument
[currinstr
].line
[instry
].param
= _oldfxparam
;
469 void act_paraminc(void){
471 if((trackx
==5 && track
[currtrack
].line
[tracky
].cmd
[0])
472 || (trackx
==8 && track
[currtrack
].line
[tracky
].cmd
[1])){
473 SETHI(track
[currtrack
].line
[tracky
].param
[(trackx
- 1) % 2],
474 hexinc(track
[currtrack
].line
[tracky
].param
[(trackx
- 1) % 2] >> 4) );
476 }else if((trackx
==6 && track
[currtrack
].line
[tracky
].cmd
[0])
477 || (trackx
==9 && track
[currtrack
].line
[tracky
].cmd
[1])){
478 SETLO(track
[currtrack
].line
[tracky
].param
[trackx
% 2],
479 hexinc(track
[currtrack
].line
[tracky
].param
[trackx
% 2] & 0x0f) );
482 }else if(currtab
== 2){
484 SETHI(instrument
[currinstr
].line
[instry
].param
,
485 hexinc(instrument
[currinstr
].line
[instry
].param
>> 4) );
487 }else if(instrx
== 2){
488 SETLO(instrument
[currinstr
].line
[instry
].param
,
489 hexinc(instrument
[currinstr
].line
[instry
].param
& 0x0f) );
496 void act_paramdec(void){
498 if((trackx
==5 && track
[currtrack
].line
[tracky
].cmd
[0])
499 || (trackx
==8 && track
[currtrack
].line
[tracky
].cmd
[1])){
500 SETHI(track
[currtrack
].line
[tracky
].param
[(trackx
-1) % 2],
501 hexdec(track
[currtrack
].line
[tracky
].param
[(trackx
-1) % 2] >> 4) );
503 }else if((trackx
==6 && track
[currtrack
].line
[tracky
].cmd
[0])
504 || (trackx
==9 && track
[currtrack
].line
[tracky
].cmd
[1])){
505 SETLO(track
[currtrack
].line
[tracky
].param
[trackx
% 2],
506 hexdec(track
[currtrack
].line
[tracky
].param
[trackx
% 2] & 0x0f) );
509 }else if(currtab
== 2){
511 SETHI(instrument
[currinstr
].line
[instry
].param
,
512 hexdec(instrument
[currinstr
].line
[instry
].param
>> 4) );
514 }else if(instrx
== 2){
515 SETLO(instrument
[currinstr
].line
[instry
].param
,
516 hexdec(instrument
[currinstr
].line
[instry
].param
& 0x0f) );
523 void act_addline(void){
525 struct instrument
*in
= &instrument
[currinstr
];
527 if(in
->length
< 256){
528 memmove(&in
->line
[instry
+ 2], &in
->line
[instry
+ 1], sizeof(struct instrline
) * (in
->length
- instry
- 1));
531 in
->line
[instry
].cmd
= '0';
532 in
->line
[instry
].param
= 0;
534 }else if(currtab
== 0){
536 memmove(&song
[songy
+ 2], &song
[songy
+ 1], sizeof(struct songline
) * (songlen
- songy
- 1));
539 memset(&song
[songy
], 0, sizeof(struct songline
));
545 void act_delline(void){
547 struct instrument
*in
= &instrument
[currinstr
];
550 memmove(&in
->line
[instry
+ 0], &in
->line
[instry
+ 1], sizeof(struct instrline
) * (in
->length
- instry
- 1));
552 if(instry
>= in
->length
) instry
= in
->length
- 1;
554 }else if(currtab
== 0){
556 memmove(&song
[songy
+ 0], &song
[songy
+ 1], sizeof(struct songline
) * (songlen
- songy
- 1));
558 if(songy
>= songlen
) songy
= songlen
- 1;
564 void act_clronething(void){
568 song
[songy
].track
[songx
/4] = (song
[songy
].track
[songx
/4] - song
[songy
].track
[songx
/4]) + song
[songy
].track
[songx
/4]%16;
570 song
[songy
].track
[songx
/4] -= song
[songy
].track
[songx
/4]%16;
574 song
[songy
].transp
[songx
/4] = (song
[songy
].transp
[songx
/4] - song
[songy
].transp
[songx
/4]) + song
[songy
].transp
[songx
/4]%16;
576 song
[songy
].transp
[songx
/4] -= song
[songy
].transp
[songx
/4]%16;
579 //memcpy(&tclip, &song[songy], sizeof(struct songline));
580 }else if(currtab
== 1){
583 memcpy(&tclip
, &track
[currtrack
].line
[tracky
], sizeof(struct trackline
));
584 track
[currtrack
].line
[tracky
].note
= 0;
585 track
[currtrack
].line
[tracky
].instr
= 0;
589 memcpy(&tclip
, &track
[currtrack
].line
[tracky
].instr
, sizeof(struct trackline
));
590 SETHI(track
[currtrack
].line
[tracky
].instr
, 0);
593 memcpy(&tclip
, &track
[currtrack
].line
[tracky
].instr
, sizeof(struct trackline
));
594 SETLO(track
[currtrack
].line
[tracky
].instr
, 0);
597 track
[currtrack
].line
[tracky
].cmd
[0] = 0;
600 SETHI(track
[currtrack
].line
[tracky
].param
[0],0);
603 SETLO(track
[currtrack
].line
[tracky
].param
[0],0);
606 track
[currtrack
].line
[tracky
].cmd
[1] = 0;
609 SETHI(track
[currtrack
].line
[tracky
].param
[1],0);
612 SETLO(track
[currtrack
].line
[tracky
].param
[1],0);
615 setdisplay("in ACT_CLRONETHING");
618 }else if(currtab
== 2){
620 instrument
[currinstr
].line
[instry
].cmd
= '0';
621 }else if(instrx
== 1){
622 if(instrument
[currinstr
].line
[instry
].cmd
== '+' || instrument
[currinstr
].line
[instry
].cmd
== '='){
623 instrument
[currinstr
].line
[instry
].param
= 0;
625 SETHI(instrument
[currinstr
].line
[instry
].param
,0);
627 }else if(instrx
== 2){
628 if(instrument
[currinstr
].line
[instry
].cmd
== '+' || instrument
[currinstr
].line
[instry
].cmd
== '='){
629 instrument
[currinstr
].line
[instry
].param
= 0;
631 SETLO(instrument
[currinstr
].line
[instry
].param
,0);
638 void act_clritall(void){
640 for(int ci
= 0; ci
< 4; ci
++){
641 song
[songy
].track
[ci
] = 0;
642 song
[songy
].transp
[ci
] = 0;
644 }else if(currtab
== 1){
645 track
[currtrack
].line
[tracky
].note
= 0;
646 track
[currtrack
].line
[tracky
].instr
= 0;
647 SETHI(track
[currtrack
].line
[tracky
].instr
, 0);
648 SETLO(track
[currtrack
].line
[tracky
].instr
, 0);
649 track
[currtrack
].line
[tracky
].cmd
[0] = 0;
650 SETHI(track
[currtrack
].line
[tracky
].param
[0],0);
651 SETLO(track
[currtrack
].line
[tracky
].param
[0],0);
652 track
[currtrack
].line
[tracky
].cmd
[1] = 0;
653 SETHI(track
[currtrack
].line
[tracky
].param
[1],0);
654 SETLO(track
[currtrack
].line
[tracky
].param
[1],0);
655 }else if(currtab
== 2){
656 instrument
[currinstr
].line
[instry
].cmd
= '0';
657 instrument
[currinstr
].line
[instry
].param
= 0;
662 // clear line y in the song tab
663 void act_clrinsongtab(int y
){
664 for(int ci
= 0; ci
< 4; ci
++){
665 song
[songy
].track
[ci
] = 0;
666 song
[songy
].transp
[ci
] = 0;
671 void act_clrintracktab(int t
, int y
){
672 track
[t
].line
[y
].note
= 0;
673 track
[t
].line
[y
].instr
= 0;
674 SETHI(track
[t
].line
[y
].instr
, 0);
675 SETLO(track
[t
].line
[y
].instr
, 0);
676 track
[t
].line
[y
].cmd
[0] = 0;
677 SETHI(track
[t
].line
[y
].param
[0],0);
678 SETLO(track
[t
].line
[y
].param
[0],0);
679 track
[t
].line
[y
].cmd
[1] = 0;
680 SETHI(track
[t
].line
[y
].param
[1],0);
681 SETLO(track
[t
].line
[y
].param
[1],0);
685 void act_clrininstrtab(int instr
, int y
){
686 instrument
[instr
].line
[y
].cmd
= '0';
687 instrument
[instr
].line
[y
].param
= 0;