1 /* vi:set ts=8 sts=8 sw=8 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_mvbottom(void){
143 tracky
= tracklen
- 1;
146 instry
= instrument
[currinstr
].length
- 1;
151 void act_mvtop(void){
165 void act_viewtrackinc(void){
166 if(currtrack
< 0xff){
168 }else if(currtrack
== 0xff){
172 startplaytrack(currtrack
);
176 void act_viewtrackdec(void){
179 }else if(currtrack
== 1){
183 startplaytrack(currtrack
);
187 void act_viewinstrinc(void){
188 if(currinstr
== 0xff) currinstr
= 0x01;
192 void act_viewinstrdec(void){
193 if(currinstr
== 1) currinstr
= 0xff;
197 void act_trackinc(void){
199 if(songx
>= 240 && songx
< 256){
200 song
[songy
].track
[songx
/4] -= 240;
202 song
[songy
].track
[songx
/4] += 16;
205 if( (song
[songy
].track
[songx
/4] % 16) == 15){
206 song
[songy
].track
[songx
/4] -= 15;
208 song
[songy
].track
[songx
/4]++;
214 void act_trackdec(void){
216 if(songx
<= 15 && songx
>= 0){
217 song
[songy
].track
[songx
/4] += 240;
219 song
[songy
].track
[songx
/4] -= 16;
222 if( (song
[songy
].track
[songx
/4] % 16) == 0){
223 song
[songy
].track
[songx
/4] += 15;
225 song
[songy
].track
[songx
/4]--;
231 void act_transpinc(void){
233 if(songx
>= 240 && songx
< 256){
234 song
[songy
].transp
[songx
/4] -= 240;
236 song
[songy
].transp
[songx
/4] += 16;
239 if( (song
[songy
].transp
[songx
/4] % 16) == 15){
240 song
[songy
].transp
[songx
/4] -= 15;
242 song
[songy
].transp
[songx
/4]++;
248 void act_transpdec(void){
250 if(songx
<= 15 && songx
>= 0){
251 song
[songy
].transp
[songx
/4] += 240;
253 song
[songy
].transp
[songx
/4] -= 16;
256 if( (song
[songy
].transp
[songx
/4] % 16) == 0){
257 song
[songy
].transp
[songx
/4] += 15;
259 song
[songy
].transp
[songx
/4]--;
268 void act_noteinc(void){
270 // if current note < H7
271 if( track
[currtrack
].line
[tracky
].note
< 96 ){
272 track
[currtrack
].line
[tracky
].note
++;
274 track
[currtrack
].line
[tracky
].note
= 0;
276 }else if(currtab
==2){
277 if( instrument
[currinstr
].line
[instry
].param
< 96 ){
278 instrument
[currinstr
].line
[instry
].param
++;
280 instrument
[currinstr
].line
[instry
].param
= 0;
286 void act_notedec(void){
288 if( track
[currtrack
].line
[tracky
].note
> 0 ){
289 track
[currtrack
].line
[tracky
].note
--;
291 track
[currtrack
].line
[tracky
].note
= 96;
293 }else if(currtab
==2){
294 if( instrument
[currinstr
].line
[instry
].param
> 0 ){
295 instrument
[currinstr
].line
[instry
].param
--;
297 instrument
[currinstr
].line
[instry
].param
= 96;
303 void act_octaveinc(void){
305 if( track
[currtrack
].line
[tracky
].note
+12 <= 96 ){
306 track
[currtrack
].line
[tracky
].note
+=12;
308 track
[currtrack
].line
[tracky
].note
%= 12;
310 }else if(currtab
==2){ if(instrument
[currinstr
].line
[instry
].cmd
== '+' || instrument
[currinstr
].line
[instry
].cmd
== '='){
311 if( instrument
[currinstr
].line
[instry
].param
+12 <= 96 ){
312 instrument
[currinstr
].line
[instry
].param
+=12;
314 instrument
[currinstr
].line
[instry
].param
%= 12;
321 void act_octavedec(void){
323 if( track
[currtrack
].line
[tracky
].note
-12 > 0 ){
324 track
[currtrack
].line
[tracky
].note
-=12;
326 track
[currtrack
].line
[tracky
].note
= 84 + track
[currtrack
].line
[tracky
].note
;
328 }else if(currtab
==2){
329 if(instrument
[currinstr
].line
[instry
].cmd
== '+' || instrument
[currinstr
].line
[instry
].cmd
== '='){
330 if( instrument
[currinstr
].line
[instry
].param
-12 > 0 ){
331 instrument
[currinstr
].line
[instry
].param
-=12;
333 instrument
[currinstr
].line
[instry
].param
= 84 + instrument
[currinstr
].line
[instry
].param
;
340 void act_instrinc(void){
343 SETHI(track
[currtrack
].line
[tracky
].instr
,
344 hexinc(track
[currtrack
].line
[tracky
].instr
>> 4) );
347 SETLO(track
[currtrack
].line
[tracky
].instr
,
348 hexinc(track
[currtrack
].line
[tracky
].instr
& 0x0f) );
354 void act_instrdec(void){
357 SETHI(track
[currtrack
].line
[tracky
].instr
,
358 hexdec(track
[currtrack
].line
[tracky
].instr
>> 4) );
361 SETLO(track
[currtrack
].line
[tracky
].instr
,
362 hexdec(track
[currtrack
].line
[tracky
].instr
& 0x0f) );
368 void act_fxinc(void){
370 currcmd
= track
[currtrack
].line
[tracky
].cmd
[trackx
% 2];
371 // there must be a better way to do this...
372 if((unsigned long)currcmd
== (unsigned long)NULL
){
373 track
[currtrack
].line
[tracky
].cmd
[trackx
% 2] = validcmds
[0];
375 for(int z
= 0; z
< strlen(validcmds
); z
++){
376 if(currcmd
== validcmds
[z
]){
377 if(z
== (strlen(validcmds
)-1)){
378 track
[currtrack
].line
[tracky
].cmd
[trackx
% 2] = (unsigned long)NULL
;
380 track
[currtrack
].line
[tracky
].cmd
[trackx
% 2] = validcmds
[z
+1];
386 }else if(currtab
==2){
387 currcmd
= instrument
[currinstr
].line
[instry
].cmd
;
388 for(int z
= 0; z
< strlen(validcmds
); z
++){
389 if(currcmd
== validcmds
[z
]){
390 if(z
== (strlen(validcmds
)-1)){
391 instrument
[currinstr
].line
[instry
].cmd
= validcmds
[0];
393 instrument
[currinstr
].line
[instry
].cmd
= validcmds
[z
+1];
395 instrument
[currinstr
].line
[instry
].param
= _oldfxparam
;
398 // when switching to the note command, change to param if it's
400 if((instrument
[currinstr
].line
[instry
].cmd
== '+' || instrument
[currinstr
].line
[instry
].cmd
== '=')
402 && instrument
[currinstr
].line
[instry
].param
>96){
403 // save current param
404 _oldfxparam
= instrument
[currinstr
].line
[instry
].param
;
405 instrument
[currinstr
].line
[instry
].param
= 96; //H7
406 }else if(_oldfxparam
){
407 instrument
[currinstr
].line
[instry
].param
= _oldfxparam
;
418 void act_fxdec(void){
420 currcmd
= track
[currtrack
].line
[tracky
].cmd
[trackx
% 2];
421 if((unsigned long)currcmd
== (unsigned long)NULL
){
422 track
[currtrack
].line
[tracky
].cmd
[trackx
% 2] = validcmds
[strlen(validcmds
)-1];
424 for(int z
= 0; z
< strlen(validcmds
); z
++){
425 if(currcmd
== validcmds
[z
]){
427 track
[currtrack
].line
[tracky
].cmd
[trackx
% 2] = (unsigned long)NULL
;
429 track
[currtrack
].line
[tracky
].cmd
[trackx
% 2] = validcmds
[z
-1];
435 }else if(currtab
==2){
436 currcmd
= instrument
[currinstr
].line
[instry
].cmd
;
437 for(int z
= 0; z
< strlen(validcmds
); z
++){
438 if(currcmd
== validcmds
[z
]){
440 instrument
[currinstr
].line
[instry
].cmd
= validcmds
[strlen(validcmds
)-1];
442 instrument
[currinstr
].line
[instry
].cmd
= validcmds
[z
-1];
444 instrument
[currinstr
].line
[instry
].param
= _oldfxparam
;
447 // when switching to the note command, change to param if it's
449 if((instrument
[currinstr
].line
[instry
].cmd
== '+' || instrument
[currinstr
].line
[instry
].cmd
== '=')
451 && instrument
[currinstr
].line
[instry
].param
>96){
452 // save current param
453 _oldfxparam
= instrument
[currinstr
].line
[instry
].param
;
454 instrument
[currinstr
].line
[instry
].param
= 96; //H7
455 }else if(_oldfxparam
){
456 instrument
[currinstr
].line
[instry
].param
= _oldfxparam
;
467 void act_paraminc(void){
469 if((trackx
==5 && track
[currtrack
].line
[tracky
].cmd
[0])
470 || (trackx
==8 && track
[currtrack
].line
[tracky
].cmd
[1])){
471 SETHI(track
[currtrack
].line
[tracky
].param
[(trackx
- 1) % 2],
472 hexinc(track
[currtrack
].line
[tracky
].param
[(trackx
- 1) % 2] >> 4) );
474 }else if((trackx
==6 && track
[currtrack
].line
[tracky
].cmd
[0])
475 || (trackx
==9 && track
[currtrack
].line
[tracky
].cmd
[1])){
476 SETLO(track
[currtrack
].line
[tracky
].param
[trackx
% 2],
477 hexinc(track
[currtrack
].line
[tracky
].param
[trackx
% 2] & 0x0f) );
480 }else if(currtab
== 2){
482 SETHI(instrument
[currinstr
].line
[instry
].param
,
483 hexinc(instrument
[currinstr
].line
[instry
].param
>> 4) );
485 }else if(instrx
== 2){
486 SETLO(instrument
[currinstr
].line
[instry
].param
,
487 hexinc(instrument
[currinstr
].line
[instry
].param
& 0x0f) );
494 void act_paramdec(void){
496 if((trackx
==5 && track
[currtrack
].line
[tracky
].cmd
[0])
497 || (trackx
==8 && track
[currtrack
].line
[tracky
].cmd
[1])){
498 SETHI(track
[currtrack
].line
[tracky
].param
[(trackx
-1) % 2],
499 hexdec(track
[currtrack
].line
[tracky
].param
[(trackx
-1) % 2] >> 4) );
501 }else if((trackx
==6 && track
[currtrack
].line
[tracky
].cmd
[0])
502 || (trackx
==9 && track
[currtrack
].line
[tracky
].cmd
[1])){
503 SETLO(track
[currtrack
].line
[tracky
].param
[trackx
% 2],
504 hexdec(track
[currtrack
].line
[tracky
].param
[trackx
% 2] & 0x0f) );
507 }else if(currtab
== 2){
509 SETHI(instrument
[currinstr
].line
[instry
].param
,
510 hexdec(instrument
[currinstr
].line
[instry
].param
>> 4) );
512 }else if(instrx
== 2){
513 SETLO(instrument
[currinstr
].line
[instry
].param
,
514 hexdec(instrument
[currinstr
].line
[instry
].param
& 0x0f) );
521 void act_addline(void){
523 struct instrument
*in
= &instrument
[currinstr
];
525 if(in
->length
< 256){
526 memmove(&in
->line
[instry
+ 2], &in
->line
[instry
+ 1], sizeof(struct instrline
) * (in
->length
- instry
- 1));
529 in
->line
[instry
].cmd
= '0';
530 in
->line
[instry
].param
= 0;
532 }else if(currtab
== 0){
534 memmove(&song
[songy
+ 2], &song
[songy
+ 1], sizeof(struct songline
) * (songlen
- songy
- 1));
537 memset(&song
[songy
], 0, sizeof(struct songline
));
543 void act_delline(void){
545 struct instrument
*in
= &instrument
[currinstr
];
548 memmove(&in
->line
[instry
+ 0], &in
->line
[instry
+ 1], sizeof(struct instrline
) * (in
->length
- instry
- 1));
550 if(instry
>= in
->length
) instry
= in
->length
- 1;
552 }else if(currtab
== 0){
554 memmove(&song
[songy
+ 0], &song
[songy
+ 1], sizeof(struct songline
) * (songlen
- songy
- 1));
556 if(songy
>= songlen
) songy
= songlen
- 1;
562 void act_clronething(void){
566 song
[songy
].track
[songx
/4] = (song
[songy
].track
[songx
/4] - song
[songy
].track
[songx
/4]) + song
[songy
].track
[songx
/4]%16;
568 song
[songy
].track
[songx
/4] -= song
[songy
].track
[songx
/4]%16;
572 song
[songy
].transp
[songx
/4] = (song
[songy
].transp
[songx
/4] - song
[songy
].transp
[songx
/4]) + song
[songy
].transp
[songx
/4]%16;
574 song
[songy
].transp
[songx
/4] -= song
[songy
].transp
[songx
/4]%16;
577 //memcpy(&tclip, &song[songy], sizeof(struct songline));
578 }else if(currtab
== 1){
581 memcpy(&tclip
, &track
[currtrack
].line
[tracky
], sizeof(struct trackline
));
582 track
[currtrack
].line
[tracky
].note
= 0;
583 track
[currtrack
].line
[tracky
].instr
= 0;
587 memcpy(&tclip
, &track
[currtrack
].line
[tracky
].instr
, sizeof(struct trackline
));
588 SETHI(track
[currtrack
].line
[tracky
].instr
, 0);
591 memcpy(&tclip
, &track
[currtrack
].line
[tracky
].instr
, sizeof(struct trackline
));
592 SETLO(track
[currtrack
].line
[tracky
].instr
, 0);
595 track
[currtrack
].line
[tracky
].cmd
[0] = 0;
598 SETHI(track
[currtrack
].line
[tracky
].param
[0],0);
601 SETLO(track
[currtrack
].line
[tracky
].param
[0],0);
604 track
[currtrack
].line
[tracky
].cmd
[1] = 0;
607 SETHI(track
[currtrack
].line
[tracky
].param
[1],0);
610 SETLO(track
[currtrack
].line
[tracky
].param
[1],0);
613 setdisplay("in ACT_CLRONETHING");
616 }else if(currtab
== 2){
618 instrument
[currinstr
].line
[instry
].cmd
= '0';
619 }else if(instrx
== 1){
620 if(instrument
[currinstr
].line
[instry
].cmd
== '+' || instrument
[currinstr
].line
[instry
].cmd
== '='){
621 instrument
[currinstr
].line
[instry
].param
= 0;
623 SETHI(instrument
[currinstr
].line
[instry
].param
,0);
625 }else if(instrx
== 2){
626 if(instrument
[currinstr
].line
[instry
].cmd
== '+' || instrument
[currinstr
].line
[instry
].cmd
== '='){
627 instrument
[currinstr
].line
[instry
].param
= 0;
629 SETLO(instrument
[currinstr
].line
[instry
].param
,0);
636 void act_clritall(void){
638 for(int ci
= 0; ci
< 4; ci
++){
639 song
[songy
].track
[ci
] = 0;
640 song
[songy
].transp
[ci
] = 0;
642 }else if(currtab
== 1){
643 track
[currtrack
].line
[tracky
].note
= 0;
644 track
[currtrack
].line
[tracky
].instr
= 0;
645 SETHI(track
[currtrack
].line
[tracky
].instr
, 0);
646 SETLO(track
[currtrack
].line
[tracky
].instr
, 0);
647 track
[currtrack
].line
[tracky
].cmd
[0] = 0;
648 SETHI(track
[currtrack
].line
[tracky
].param
[0],0);
649 SETLO(track
[currtrack
].line
[tracky
].param
[0],0);
650 track
[currtrack
].line
[tracky
].cmd
[1] = 0;
651 SETHI(track
[currtrack
].line
[tracky
].param
[1],0);
652 SETLO(track
[currtrack
].line
[tracky
].param
[1],0);
653 }else if(currtab
== 2){
654 instrument
[currinstr
].line
[instry
].cmd
= '0';
655 instrument
[currinstr
].line
[instry
].param
= 0;
660 // clear line y in the song tab
661 void act_clrinsongtab(int y
){
662 for(int ci
= 0; ci
< 4; ci
++){
663 song
[songy
].track
[ci
] = 0;
664 song
[songy
].transp
[ci
] = 0;
669 void act_clrintracktab(int t
, int y
){
670 track
[t
].line
[y
].note
= 0;
671 track
[t
].line
[y
].instr
= 0;
672 SETHI(track
[t
].line
[y
].instr
, 0);
673 SETLO(track
[t
].line
[y
].instr
, 0);
674 track
[t
].line
[y
].cmd
[0] = 0;
675 SETHI(track
[t
].line
[y
].param
[0],0);
676 SETLO(track
[t
].line
[y
].param
[0],0);
677 track
[t
].line
[y
].cmd
[1] = 0;
678 SETHI(track
[t
].line
[y
].param
[1],0);
679 SETLO(track
[t
].line
[y
].param
[1],0);
683 void act_clrininstrtab(int instr
, int y
){
684 instrument
[instr
].line
[y
].cmd
= '0';
685 instrument
[instr
].line
[y
].param
= 0;