1 /* vi:set ts=8 sts=8 sw=8 noexpandtab: */
8 static u8 _oldfxparam
= 0;
10 /* move cursor left one column */
11 void act_mvleft(void){
25 /* move cursor right one column */
26 void act_mvright(void){
29 if(songx
< 15) songx
++;
32 if(trackx
< 9) trackx
++;
35 if(instrx
< 2) instrx
++;
40 /* move cursor up 1 line */
67 /* move cursor down 1 line */
68 void act_mvdown(void){
71 if(songy
< tune
->songlen
- 1){
74 songy
= tune
->songlen
- 1;
78 if(tracky
< tune
->tracklen
- 1){
81 tracky
= tune
->tracklen
- 1;
85 if(instry
< instrument
[currinstr
].length
- 1){
88 instry
= instrument
[currinstr
].length
- 1;
94 /* move cursor up 8 lines */
95 void act_bigmvup(void){
112 if(instry
>= 8) instry
-= 8;
117 /* move cursor down 8 lines */
118 void act_bigmvdown(void){
121 if(songy
< tune
->songlen
- 8){
124 songy
= tune
->songlen
- 1;
128 if(tracky
< tune
->tracklen
- 8){
131 tracky
= tune
->tracklen
- 1;
135 if(instry
< instrument
[currinstr
].length
- 8) instry
+= 8;
140 void act_mvbottom(void){
143 songy
= tune
->songlen
- 1;
146 tracky
= tune
->tracklen
- 1;
149 instry
= instrument
[currinstr
].length
- 1;
154 void act_mvtop(void){
168 void act_viewtrackinc(void){
169 if(currtrack
< 0xff){
171 }else if(currtrack
== 0xff){
175 startplaytrack(currtrack
);
179 void act_viewtrackdec(void){
182 }else if(currtrack
== 1){
186 startplaytrack(currtrack
);
190 void act_viewinstrinc(void){
191 if(currinstr
== 0xff) currinstr
= 0x01;
195 void act_viewinstrdec(void){
196 if(currinstr
== 1) currinstr
= 0xff;
200 void act_trackinc(void){
202 if(songx
>= 240 && songx
< 256){
203 tune
->sng
[songy
].track
[songx
/4] -= 240;
205 tune
->sng
[songy
].track
[songx
/4] += 16;
208 if( (tune
->sng
[songy
].track
[songx
/4] % 16) == 15){
209 tune
->sng
[songy
].track
[songx
/4] -= 15;
211 tune
->sng
[songy
].track
[songx
/4]++;
217 void act_trackdec(void){
219 if(songx
<= 15 && songx
>= 0){
220 tune
->sng
[songy
].track
[songx
/4] += 240;
222 tune
->sng
[songy
].track
[songx
/4] -= 16;
225 if( (tune
->sng
[songy
].track
[songx
/4] % 16) == 0){
226 tune
->sng
[songy
].track
[songx
/4] += 15;
228 tune
->sng
[songy
].track
[songx
/4]--;
234 void act_transpinc(void){
236 if(songx
>= 240 && songx
< 256){
237 tune
->sng
[songy
].transp
[songx
/4] -= 240;
239 tune
->sng
[songy
].transp
[songx
/4] += 16;
242 if( (tune
->sng
[songy
].transp
[songx
/4] % 16) == 15){
243 tune
->sng
[songy
].transp
[songx
/4] -= 15;
245 tune
->sng
[songy
].transp
[songx
/4]++;
251 void act_transpdec(void){
253 if(songx
<= 15 && songx
>= 0){
254 tune
->sng
[songy
].transp
[songx
/4] += 240;
256 tune
->sng
[songy
].transp
[songx
/4] -= 16;
259 if( (tune
->sng
[songy
].transp
[songx
/4] % 16) == 0){
260 tune
->sng
[songy
].transp
[songx
/4] += 15;
262 tune
->sng
[songy
].transp
[songx
/4]--;
271 void act_noteinc(void){
273 // if current note < H7
274 if( tune
->trk
[currtrack
].line
[tracky
].note
< 96 ){
275 tune
->trk
[currtrack
].line
[tracky
].note
++;
277 tune
->trk
[currtrack
].line
[tracky
].note
= 0;
279 }else if(currtab
==2){
280 if( instrument
[currinstr
].line
[instry
].param
< 96 ){
281 instrument
[currinstr
].line
[instry
].param
++;
283 instrument
[currinstr
].line
[instry
].param
= 0;
289 void act_notedec(void){
291 if( tune
->trk
[currtrack
].line
[tracky
].note
> 0 ){
292 tune
->trk
[currtrack
].line
[tracky
].note
--;
294 tune
->trk
[currtrack
].line
[tracky
].note
= 96;
296 }else if(currtab
==2){
297 if( instrument
[currinstr
].line
[instry
].param
> 0 ){
298 instrument
[currinstr
].line
[instry
].param
--;
300 instrument
[currinstr
].line
[instry
].param
= 96;
306 void act_octaveinc(void){
308 if( tune
->trk
[currtrack
].line
[tracky
].note
+12 <= 96 ){
309 tune
->trk
[currtrack
].line
[tracky
].note
+=12;
311 tune
->trk
[currtrack
].line
[tracky
].note
%= 12;
313 }else if(currtab
==2){ if(instrument
[currinstr
].line
[instry
].cmd
== '+' || instrument
[currinstr
].line
[instry
].cmd
== '='){
314 if( instrument
[currinstr
].line
[instry
].param
+12 <= 96 ){
315 instrument
[currinstr
].line
[instry
].param
+=12;
317 instrument
[currinstr
].line
[instry
].param
%= 12;
324 void act_octavedec(void){
326 if( tune
->trk
[currtrack
].line
[tracky
].note
-12 > 0 ){
327 tune
->trk
[currtrack
].line
[tracky
].note
-=12;
329 tune
->trk
[currtrack
].line
[tracky
].note
= 84 + tune
->trk
[currtrack
].line
[tracky
].note
;
331 }else if(currtab
==2){
332 if(instrument
[currinstr
].line
[instry
].cmd
== '+' || instrument
[currinstr
].line
[instry
].cmd
== '='){
333 if( instrument
[currinstr
].line
[instry
].param
-12 > 0 ){
334 instrument
[currinstr
].line
[instry
].param
-=12;
336 instrument
[currinstr
].line
[instry
].param
= 84 + instrument
[currinstr
].line
[instry
].param
;
343 void act_instrinc(void){
346 SETHI(tune
->trk
[currtrack
].line
[tracky
].instr
,
347 hexinc(tune
->trk
[currtrack
].line
[tracky
].instr
>> 4) );
350 SETLO(tune
->trk
[currtrack
].line
[tracky
].instr
,
351 hexinc(tune
->trk
[currtrack
].line
[tracky
].instr
& 0x0f) );
357 void act_instrdec(void){
360 SETHI(tune
->trk
[currtrack
].line
[tracky
].instr
,
361 hexdec(tune
->trk
[currtrack
].line
[tracky
].instr
>> 4) );
364 SETLO(tune
->trk
[currtrack
].line
[tracky
].instr
,
365 hexdec(tune
->trk
[currtrack
].line
[tracky
].instr
& 0x0f) );
371 void act_fxinc(void){
373 currcmd
= tune
->trk
[currtrack
].line
[tracky
].cmd
[trackx
% 2];
374 // there must be a better way to do this...
375 if((unsigned long)currcmd
== (unsigned long)NULL
){
376 tune
->trk
[currtrack
].line
[tracky
].cmd
[trackx
% 2] = validcmds
[0];
378 for(int z
= 0; z
< strlen(validcmds
); z
++){
379 if(currcmd
== validcmds
[z
]){
380 if(z
== (strlen(validcmds
)-1)){
381 tune
->trk
[currtrack
].line
[tracky
].cmd
[trackx
% 2] = (unsigned long)NULL
;
383 tune
->trk
[currtrack
].line
[tracky
].cmd
[trackx
% 2] = validcmds
[z
+1];
389 }else if(currtab
==2){
390 currcmd
= instrument
[currinstr
].line
[instry
].cmd
;
391 for(int z
= 0; z
< strlen(validcmds
); z
++){
392 if(currcmd
== validcmds
[z
]){
393 if(z
== (strlen(validcmds
)-1)){
394 instrument
[currinstr
].line
[instry
].cmd
= validcmds
[0];
396 instrument
[currinstr
].line
[instry
].cmd
= validcmds
[z
+1];
398 instrument
[currinstr
].line
[instry
].param
= _oldfxparam
;
401 // when switching to the note command, change to param if it's
403 if((instrument
[currinstr
].line
[instry
].cmd
== '+' || instrument
[currinstr
].line
[instry
].cmd
== '=')
405 && instrument
[currinstr
].line
[instry
].param
>96){
406 // save current param
407 _oldfxparam
= instrument
[currinstr
].line
[instry
].param
;
408 instrument
[currinstr
].line
[instry
].param
= 96; //H7
409 }else if(_oldfxparam
){
410 instrument
[currinstr
].line
[instry
].param
= _oldfxparam
;
421 void act_fxdec(void){
423 currcmd
= tune
->trk
[currtrack
].line
[tracky
].cmd
[trackx
% 2];
424 if((unsigned long)currcmd
== (unsigned long)NULL
){
425 tune
->trk
[currtrack
].line
[tracky
].cmd
[trackx
% 2] = validcmds
[strlen(validcmds
)-1];
427 for(int z
= 0; z
< strlen(validcmds
); z
++){
428 if(currcmd
== validcmds
[z
]){
430 tune
->trk
[currtrack
].line
[tracky
].cmd
[trackx
% 2] = (unsigned long)NULL
;
432 tune
->trk
[currtrack
].line
[tracky
].cmd
[trackx
% 2] = validcmds
[z
-1];
438 }else if(currtab
==2){
439 currcmd
= instrument
[currinstr
].line
[instry
].cmd
;
440 for(int z
= 0; z
< strlen(validcmds
); z
++){
441 if(currcmd
== validcmds
[z
]){
443 instrument
[currinstr
].line
[instry
].cmd
= validcmds
[strlen(validcmds
)-1];
445 instrument
[currinstr
].line
[instry
].cmd
= validcmds
[z
-1];
447 instrument
[currinstr
].line
[instry
].param
= _oldfxparam
;
450 // when switching to the note command, change to param if it's
452 if((instrument
[currinstr
].line
[instry
].cmd
== '+' || instrument
[currinstr
].line
[instry
].cmd
== '=')
454 && instrument
[currinstr
].line
[instry
].param
>96){
455 // save current param
456 _oldfxparam
= instrument
[currinstr
].line
[instry
].param
;
457 instrument
[currinstr
].line
[instry
].param
= 96; //H7
458 }else if(_oldfxparam
){
459 instrument
[currinstr
].line
[instry
].param
= _oldfxparam
;
470 void act_paraminc(void){
472 if((trackx
==5 && tune
->trk
[currtrack
].line
[tracky
].cmd
[0])
473 || (trackx
==8 && tune
->trk
[currtrack
].line
[tracky
].cmd
[1])){
474 SETHI(tune
->trk
[currtrack
].line
[tracky
].param
[(trackx
- 1) % 2],
475 hexinc(tune
->trk
[currtrack
].line
[tracky
].param
[(trackx
- 1) % 2] >> 4) );
477 }else if((trackx
==6 && tune
->trk
[currtrack
].line
[tracky
].cmd
[0])
478 || (trackx
==9 && tune
->trk
[currtrack
].line
[tracky
].cmd
[1])){
479 SETLO(tune
->trk
[currtrack
].line
[tracky
].param
[trackx
% 2],
480 hexinc(tune
->trk
[currtrack
].line
[tracky
].param
[trackx
% 2] & 0x0f) );
483 }else if(currtab
== 2){
485 SETHI(instrument
[currinstr
].line
[instry
].param
,
486 hexinc(instrument
[currinstr
].line
[instry
].param
>> 4) );
488 }else if(instrx
== 2){
489 SETLO(instrument
[currinstr
].line
[instry
].param
,
490 hexinc(instrument
[currinstr
].line
[instry
].param
& 0x0f) );
497 void act_paramdec(void){
499 if((trackx
==5 && tune
->trk
[currtrack
].line
[tracky
].cmd
[0])
500 || (trackx
==8 && tune
->trk
[currtrack
].line
[tracky
].cmd
[1])){
501 SETHI(tune
->trk
[currtrack
].line
[tracky
].param
[(trackx
-1) % 2],
502 hexdec(tune
->trk
[currtrack
].line
[tracky
].param
[(trackx
-1) % 2] >> 4) );
504 }else if((trackx
==6 && tune
->trk
[currtrack
].line
[tracky
].cmd
[0])
505 || (trackx
==9 && tune
->trk
[currtrack
].line
[tracky
].cmd
[1])){
506 SETLO(tune
->trk
[currtrack
].line
[tracky
].param
[trackx
% 2],
507 hexdec(tune
->trk
[currtrack
].line
[tracky
].param
[trackx
% 2] & 0x0f) );
510 }else if(currtab
== 2){
512 SETHI(instrument
[currinstr
].line
[instry
].param
,
513 hexdec(instrument
[currinstr
].line
[instry
].param
>> 4) );
515 }else if(instrx
== 2){
516 SETLO(instrument
[currinstr
].line
[instry
].param
,
517 hexdec(instrument
[currinstr
].line
[instry
].param
& 0x0f) );
524 void act_addline(void){
526 struct instrument
*in
= &instrument
[currinstr
];
528 if(in
->length
< 256){
529 memmove(&in
->line
[instry
+ 2], &in
->line
[instry
+ 1], sizeof(struct instrline
) * (in
->length
- instry
- 1));
532 in
->line
[instry
].cmd
= '0';
533 in
->line
[instry
].param
= 0;
535 }else if(currtab
== 0){
536 if(tune
->songlen
< 256){
537 memmove(&tune
->sng
[songy
+ 2], &tune
->sng
[songy
+ 1], sizeof(struct songline
) * (tune
->songlen
- songy
- 1));
540 memset(&tune
->sng
[songy
], 0, sizeof(struct songline
));
546 void act_delline(void){
548 struct instrument
*in
= &instrument
[currinstr
];
551 memmove(&in
->line
[instry
+ 0], &in
->line
[instry
+ 1], sizeof(struct instrline
) * (in
->length
- instry
- 1));
553 if(instry
>= in
->length
) instry
= in
->length
- 1;
555 }else if(currtab
== 0){
556 if(tune
->songlen
> 1){
557 memmove(&tune
->sng
[songy
+ 0], &tune
->sng
[songy
+ 1], sizeof(struct songline
) * (tune
->songlen
- songy
- 1));
559 if(songy
>= tune
->songlen
) songy
= tune
->songlen
- 1;
565 void act_clronething(void){
569 tune
->sng
[songy
].track
[songx
/4] = (tune
->sng
[songy
].track
[songx
/4] - tune
->sng
[songy
].track
[songx
/4]) + tune
->sng
[songy
].track
[songx
/4]%16;
571 tune
->sng
[songy
].track
[songx
/4] -= tune
->sng
[songy
].track
[songx
/4]%16;
575 tune
->sng
[songy
].transp
[songx
/4] = (tune
->sng
[songy
].transp
[songx
/4] - tune
->sng
[songy
].transp
[songx
/4]) + tune
->sng
[songy
].transp
[songx
/4]%16;
577 tune
->sng
[songy
].transp
[songx
/4] -= tune
->sng
[songy
].transp
[songx
/4]%16;
580 //memcpy(&tclip, &tune->sng[songy], sizeof(struct songline));
581 }else if(currtab
== 1){
584 memcpy(&tclip
, &tune
->trk
[currtrack
].line
[tracky
], sizeof(struct trackline
));
585 tune
->trk
[currtrack
].line
[tracky
].note
= 0;
586 tune
->trk
[currtrack
].line
[tracky
].instr
= 0;
590 memcpy(&tclip
, &tune
->trk
[currtrack
].line
[tracky
].instr
, sizeof(struct trackline
));
591 SETHI(tune
->trk
[currtrack
].line
[tracky
].instr
, 0);
594 memcpy(&tclip
, &tune
->trk
[currtrack
].line
[tracky
].instr
, sizeof(struct trackline
));
595 SETLO(tune
->trk
[currtrack
].line
[tracky
].instr
, 0);
598 tune
->trk
[currtrack
].line
[tracky
].cmd
[0] = 0;
601 SETHI(tune
->trk
[currtrack
].line
[tracky
].param
[0],0);
604 SETLO(tune
->trk
[currtrack
].line
[tracky
].param
[0],0);
607 tune
->trk
[currtrack
].line
[tracky
].cmd
[1] = 0;
610 SETHI(tune
->trk
[currtrack
].line
[tracky
].param
[1],0);
613 SETLO(tune
->trk
[currtrack
].line
[tracky
].param
[1],0);
616 setdisplay("in ACT_CLRONETHING");
619 }else if(currtab
== 2){
621 instrument
[currinstr
].line
[instry
].cmd
= '0';
622 }else if(instrx
== 1){
623 if(instrument
[currinstr
].line
[instry
].cmd
== '+' || instrument
[currinstr
].line
[instry
].cmd
== '='){
624 instrument
[currinstr
].line
[instry
].param
= 0;
626 SETHI(instrument
[currinstr
].line
[instry
].param
,0);
628 }else if(instrx
== 2){
629 if(instrument
[currinstr
].line
[instry
].cmd
== '+' || instrument
[currinstr
].line
[instry
].cmd
== '='){
630 instrument
[currinstr
].line
[instry
].param
= 0;
632 SETLO(instrument
[currinstr
].line
[instry
].param
,0);
639 void act_clritall(void){
641 for(int ci
= 0; ci
< 4; ci
++){
642 tune
->sng
[songy
].track
[ci
] = 0;
643 tune
->sng
[songy
].transp
[ci
] = 0;
645 }else if(currtab
== 1){
646 tune
->trk
[currtrack
].line
[tracky
].note
= 0;
647 tune
->trk
[currtrack
].line
[tracky
].instr
= 0;
648 SETHI(tune
->trk
[currtrack
].line
[tracky
].instr
, 0);
649 SETLO(tune
->trk
[currtrack
].line
[tracky
].instr
, 0);
650 tune
->trk
[currtrack
].line
[tracky
].cmd
[0] = 0;
651 SETHI(tune
->trk
[currtrack
].line
[tracky
].param
[0],0);
652 SETLO(tune
->trk
[currtrack
].line
[tracky
].param
[0],0);
653 tune
->trk
[currtrack
].line
[tracky
].cmd
[1] = 0;
654 SETHI(tune
->trk
[currtrack
].line
[tracky
].param
[1],0);
655 SETLO(tune
->trk
[currtrack
].line
[tracky
].param
[1],0);
656 }else if(currtab
== 2){
657 instrument
[currinstr
].line
[instry
].cmd
= '0';
658 instrument
[currinstr
].line
[instry
].param
= 0;
663 // clear line y in the song tab
664 void act_clrinsongtab(int y
){
665 for(int ci
= 0; ci
< 4; ci
++){
666 tune
->sng
[songy
].track
[ci
] = 0;
667 tune
->sng
[songy
].transp
[ci
] = 0;
672 void act_clrintracktab(int t
, int y
){
673 tune
->trk
[t
].line
[y
].note
= 0;
674 tune
->trk
[t
].line
[y
].instr
= 0;
675 SETHI(tune
->trk
[t
].line
[y
].instr
, 0);
676 SETLO(tune
->trk
[t
].line
[y
].instr
, 0);
677 tune
->trk
[t
].line
[y
].cmd
[0] = 0;
678 SETHI(tune
->trk
[t
].line
[y
].param
[0],0);
679 SETLO(tune
->trk
[t
].line
[y
].param
[0],0);
680 tune
->trk
[t
].line
[y
].cmd
[1] = 0;
681 SETHI(tune
->trk
[t
].line
[y
].param
[1],0);
682 SETLO(tune
->trk
[t
].line
[y
].param
[1],0);
686 void act_clrininstrtab(int instr
, int y
){
687 instrument
[instr
].line
[y
].cmd
= '0';
688 instrument
[instr
].line
[y
].param
= 0;