summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2021-06-20 13:17:45 +0200
committerBad Diode <bd@badd10de.dev>2021-06-20 13:17:45 +0200
commitfc04cf5c36e22fa7982eb02d0aef390f29a96830 (patch)
tree9ddf9da1aa569ee73c862ccc5260de1a980f8ecd
parent4cde886bc202d0c8c0ee52279cd4c653829afc09 (diff)
downloadgba-sequencer-fc04cf5c36e22fa7982eb02d0aef390f29a96830.tar.gz
gba-sequencer-fc04cf5c36e22fa7982eb02d0aef390f29a96830.zip
Add sq shape and env drawing
-rw-r--r--src/sequencer.c373
1 files changed, 226 insertions, 147 deletions
diff --git a/src/sequencer.c b/src/sequencer.c
index 41d8ee7..2d9ca4f 100644
--- a/src/sequencer.c
+++ b/src/sequencer.c
@@ -781,166 +781,245 @@ draw_parameters_wave(void) {
781void 781void
782draw_parameters_square(ChannelSquareParams *params, bool sweep) { 782draw_parameters_square(ChannelSquareParams *params, bool sweep) {
783 // DEBUG: Bounding box. 783 // DEBUG: Bounding box.
784 { 784 // {
785 size_t x0 = PARAMS_START_X; 785 // size_t x0 = PARAMS_START_X;
786 size_t y0 = PARAMS_START_Y; 786 // size_t y0 = PARAMS_START_Y;
787 size_t x1 = PARAMS_START_X + PARAMS_W; 787 // size_t x1 = PARAMS_START_X + PARAMS_W;
788 size_t y1 = PARAMS_START_Y + PARAMS_H - 5; 788 // size_t y1 = PARAMS_START_Y + PARAMS_H - 5;
789 // draw_rect(x0, y0, x1, y1, COL_FG); 789 // draw_rect(x0, y0, x1, y1, COL_FG);
790 } 790 // }
791 791
792 // Duty cycle. 792 // Duty cycle.
793 { 793 {
794 size_t x = PARAMS_START_X; 794 // Shape drawing.
795 size_t y = PARAMS_START_Y + PARAMS_H - 25; 795 {
796 draw_line(x, y + 7, x + 2, y + 7, COL_FG); 796 size_t x = PARAMS_START_X;
797 draw_line(x + 22, y + 7, x + 24, y + 7, COL_FG); 797 size_t y = PARAMS_START_Y + PARAMS_H - 42;
798 draw_line(x, y + 8, x, y + 19, COL_FG); 798
799 draw_line(x + 24, y + 8, x + 24, y + 19, COL_FG); 799 size_t x0 = x + 2;
800 draw_line(x, y + 20, x + 24, y + 20, COL_FG); 800 size_t x1 = x0;
801 txt_drawf_small("duty", x + 3, y + 3, 4, COL_FG); 801 size_t x2 = x0;
802 802 size_t x3 = x0;
803 switch (params->duty_cycle) { 803 size_t x4 = x0;
804 case 0: { 804 size_t x5 = x0;
805 txt_drawf("0", x + 9, y + 10, 6, COL_FG); 805 size_t y0 = y + 14;
806 } break; 806 size_t y1 = y + 2;
807 case 1: { 807
808 txt_drawf("25", x + 6, y + 10, 6, COL_FG); 808 switch (params->duty_cycle) {
809 } break; 809 case 0: {
810 case 2: { 810 x1 += 4;
811 txt_drawf("50", x + 6, y + 10, 6, COL_FG); 811 x2 += 6;
812 } break; 812 x3 += 13;
813 case 3: { 813 x4 += 15;
814 txt_drawf("75", x + 6, y + 10, 6, COL_FG); 814 x5 += 20;
815 } break; 815 } break;
816 case 4: { 816 case 1: {
817 txt_drawf("100", x + 3, y + 10, 6, COL_FG); 817 x1 += 4;
818 } break; 818 x2 += 7;
819 x3 += 13;
820 x4 += 16;
821 x5 += 20;
822 } break;
823 case 2: {
824 x1 += 3;
825 x2 += 8;
826 x3 += 12;
827 x4 += 17;
828 x5 += 20;
829 } break;
830 case 3: {
831 x1 += 2;
832 x2 += 9;
833 x3 += 11;
834 x4 += 18;
835 x5 += 20;
836 } break;
837 }
838 draw_line(x0, y0, x1, y0, COL_RED);
839 draw_line(x1, y1, x1, y0, COL_RED);
840 draw_line(x1, y1, x2, y1, COL_RED);
841 draw_line(x2, y1, x2, y0, COL_RED);
842 draw_line(x2, y0, x3, y0, COL_RED);
843 draw_line(x3, y1, x3, y0, COL_RED);
844 draw_line(x3, y1, x4, y1, COL_RED);
845 draw_line(x4, y1, x4, y0, COL_RED);
846 draw_line(x4, y0, x5, y0, COL_RED);
847
848 // DEBUG: Bounding box.
849 // draw_rect(x, y - 1, x + 24, y + 17, COL_RED);
819 } 850 }
820 }
821
822 // Env. volume.
823 {
824 size_t x = PARAMS_START_X + 31;
825 size_t y = PARAMS_START_Y + PARAMS_H - 25;
826 draw_line(x, y + 7, x + 4, y + 7, COL_FG);
827 draw_line(x + 20, y + 7, x + 24, y + 7, COL_FG);
828 draw_line(x, y + 8, x, y + 19, COL_FG);
829 draw_line(x + 24, y + 8, x + 24, y + 19, COL_FG);
830 draw_line(x, y + 20, x + 24, y + 20, COL_FG);
831 txt_drawf_small("vol", x + 5, y + 3, 4, COL_FG);
832 851
833 switch (params->env_volume) { 852 // Param box.
834 case 0: { 853 {
835 txt_drawf("0", x + 9, y + 10, 6, COL_FG); 854 size_t x = PARAMS_START_X;
836 } break; 855 size_t y = PARAMS_START_Y + PARAMS_H - 25;
837 case 1: { 856 draw_line(x, y + 7, x + 2, y + 7, COL_FG);
838 txt_drawf("6", x + 9, y + 10, 6, COL_FG); 857 draw_line(x + 22, y + 7, x + 24, y + 7, COL_FG);
839 } break; 858 draw_line(x, y + 8, x, y + 19, COL_FG);
840 case 2: { 859 draw_line(x + 24, y + 8, x + 24, y + 19, COL_FG);
841 txt_drawf("13", x + 6, y + 10, 6, COL_FG); 860 draw_line(x, y + 20, x + 24, y + 20, COL_FG);
842 } break; 861 txt_drawf_small("duty", x + 3, y + 3, 4, COL_FG);
843 case 3: { 862
844 txt_drawf("20", x + 6, y + 10, 6, COL_FG); 863 switch (params->duty_cycle) {
845 } break; 864 case 0: {
846 case 4: { 865 txt_drawf("0", x + 9, y + 10, 6, COL_FG);
847 txt_drawf("26", x + 6, y + 10, 6, COL_FG); 866 } break;
848 } break; 867 case 1: {
849 case 5: { 868 txt_drawf("25", x + 6, y + 10, 6, COL_FG);
850 txt_drawf("33", x + 6, y + 10, 6, COL_FG); 869 } break;
851 } break; 870 case 2: {
852 case 6: { 871 txt_drawf("50", x + 6, y + 10, 6, COL_FG);
853 txt_drawf("40", x + 6, y + 10, 6, COL_FG); 872 } break;
854 } break; 873 case 3: {
855 case 7: { 874 txt_drawf("75", x + 6, y + 10, 6, COL_FG);
856 txt_drawf("46", x + 6, y + 10, 6, COL_FG); 875 } break;
857 } break; 876 }
858 case 8: {
859 txt_drawf("53", x + 6, y + 10, 6, COL_FG);
860 } break;
861 case 9: {
862 txt_drawf("60", x + 6, y + 10, 6, COL_FG);
863 } break;
864 case 10: {
865 txt_drawf("66", x + 6, y + 10, 6, COL_FG);
866 } break;
867 case 11: {
868 txt_drawf("73", x + 6, y + 10, 6, COL_FG);
869 } break;
870 case 12: {
871 txt_drawf("80", x + 6, y + 10, 6, COL_FG);
872 } break;
873 case 13: {
874 txt_drawf("86", x + 6, y + 10, 6, COL_FG);
875 } break;
876 case 14: {
877 txt_drawf("93", x + 6, y + 10, 6, COL_FG);
878 } break;
879 case 15: {
880 txt_drawf("100", x + 3, y + 10, 6, COL_FG);
881 } break;
882 } 877 }
883 } 878 }
884 879
885 // Env. direction 880 // Envelope.
886 { 881 {
887 size_t x = PARAMS_START_X + 59; 882 // Env. drawing.
888 size_t y = PARAMS_START_Y + PARAMS_H - 25; 883 {
889 draw_line(x, y + 7, x + 4, y + 7, COL_FG); 884 size_t x = PARAMS_START_X + 43;
890 draw_line(x + 20, y + 7, x + 24, y + 7, COL_FG); 885 size_t y = PARAMS_START_Y + PARAMS_H - 41;
891 draw_line(x, y + 8, x, y + 19, COL_FG); 886 size_t x0 = x;
892 draw_line(x + 24, y + 8, x + 24, y + 19, COL_FG); 887 size_t y0 = y + 16 - params->env_volume;
893 draw_line(x, y + 20, x + 24, y + 20, COL_FG); 888 size_t x1 = x + 8 * params->env_time;
894 txt_drawf_small("dir", x + 5, y + 3, 4, COL_FG); 889 size_t y1 = params->env_direction == 0 ? y : y + 16;
890 size_t x2 = x + 8 * 7;
891 size_t y2 = y1;
892 // Axis.
893 draw_line(x, y - 2, x, y + 16, COL_CYAN);
894 draw_line(x, y + 16, x + 8 * 7 + 2, y + 16, COL_CYAN);
895 // Env.
896 draw_line(x0, y0, x1, y1, COL_CYAN);
897 draw_line(x1, y1, x2, y2, COL_CYAN);
898 }
895 899
896 char arr_up[2] = { 0x19, 0 }; 900 // Env. volume.
897 char arr_down[2] = { 0x18, 0 }; 901 {
898 switch (params->env_direction) { 902 size_t x = PARAMS_START_X + 31;
899 case 0: { 903 size_t y = PARAMS_START_Y + PARAMS_H - 25;
900 txt_drawf(arr_down, x + 9, y + 11, 6, COL_FG); 904 draw_line(x, y + 7, x + 4, y + 7, COL_FG);
901 } break; 905 draw_line(x + 20, y + 7, x + 24, y + 7, COL_FG);
902 case 1: { 906 draw_line(x, y + 8, x, y + 19, COL_FG);
903 txt_drawf(arr_up, x + 9, y + 11, 6, COL_FG); 907 draw_line(x + 24, y + 8, x + 24, y + 19, COL_FG);
904 } break; 908 draw_line(x, y + 20, x + 24, y + 20, COL_FG);
909 txt_drawf_small("vol", x + 5, y + 3, 4, COL_FG);
910
911 switch (params->env_volume) {
912 case 0: {
913 txt_drawf("0", x + 9, y + 10, 6, COL_FG);
914 } break;
915 case 1: {
916 txt_drawf("6", x + 9, y + 10, 6, COL_FG);
917 } break;
918 case 2: {
919 txt_drawf("13", x + 6, y + 10, 6, COL_FG);
920 } break;
921 case 3: {
922 txt_drawf("20", x + 6, y + 10, 6, COL_FG);
923 } break;
924 case 4: {
925 txt_drawf("26", x + 6, y + 10, 6, COL_FG);
926 } break;
927 case 5: {
928 txt_drawf("33", x + 6, y + 10, 6, COL_FG);
929 } break;
930 case 6: {
931 txt_drawf("40", x + 6, y + 10, 6, COL_FG);
932 } break;
933 case 7: {
934 txt_drawf("46", x + 6, y + 10, 6, COL_FG);
935 } break;
936 case 8: {
937 txt_drawf("53", x + 6, y + 10, 6, COL_FG);
938 } break;
939 case 9: {
940 txt_drawf("60", x + 6, y + 10, 6, COL_FG);
941 } break;
942 case 10: {
943 txt_drawf("66", x + 6, y + 10, 6, COL_FG);
944 } break;
945 case 11: {
946 txt_drawf("73", x + 6, y + 10, 6, COL_FG);
947 } break;
948 case 12: {
949 txt_drawf("80", x + 6, y + 10, 6, COL_FG);
950 } break;
951 case 13: {
952 txt_drawf("86", x + 6, y + 10, 6, COL_FG);
953 } break;
954 case 14: {
955 txt_drawf("93", x + 6, y + 10, 6, COL_FG);
956 } break;
957 case 15: {
958 txt_drawf("100", x + 3, y + 10, 6, COL_FG);
959 } break;
960 }
905 } 961 }
906 }
907 962
908 // Env. time. 963 // Env. direction
909 { 964 {
910 size_t x = PARAMS_START_X + 87; 965 size_t x = PARAMS_START_X + 59;
911 size_t y = PARAMS_START_Y + PARAMS_H - 25; 966 size_t y = PARAMS_START_Y + PARAMS_H - 25;
912 draw_line(x, y + 7, x + 2, y + 7, COL_FG); 967 draw_line(x, y + 7, x + 4, y + 7, COL_FG);
913 draw_line(x + 22, y + 7, x + 24, y + 7, COL_FG); 968 draw_line(x + 20, y + 7, x + 24, y + 7, COL_FG);
914 draw_line(x, y + 8, x, y + 19, COL_FG); 969 draw_line(x, y + 8, x, y + 19, COL_FG);
915 draw_line(x + 24, y + 8, x + 24, y + 19, COL_FG); 970 draw_line(x + 24, y + 8, x + 24, y + 19, COL_FG);
916 draw_line(x, y + 20, x + 24, y + 20, COL_FG); 971 draw_line(x, y + 20, x + 24, y + 20, COL_FG);
917 txt_drawf_small("time", x + 3, y + 3, 4, COL_FG); 972 txt_drawf_small("dir", x + 5, y + 3, 4, COL_FG);
973
974 char arr_up[2] = { 0x19, 0 };
975 char arr_down[2] = { 0x18, 0 };
976 switch (params->env_direction) {
977 case 0: {
978 txt_drawf(arr_down, x + 9, y + 11, 6, COL_FG);
979 } break;
980 case 1: {
981 txt_drawf(arr_up, x + 9, y + 11, 6, COL_FG);
982 } break;
983 }
984 }
918 985
919 switch (params->env_time) { 986 // Env. time.
920 case 0: { 987 {
921 txt_drawf("0", x + 9, y + 10, 6, COL_FG); 988 size_t x = PARAMS_START_X + 87;
922 } break; 989 size_t y = PARAMS_START_Y + PARAMS_H - 25;
923 case 1: { 990 draw_line(x, y + 7, x + 2, y + 7, COL_FG);
924 txt_drawf("14", x + 6, y + 10, 6, COL_FG); 991 draw_line(x + 22, y + 7, x + 24, y + 7, COL_FG);
925 } break; 992 draw_line(x, y + 8, x, y + 19, COL_FG);
926 case 2: { 993 draw_line(x + 24, y + 8, x + 24, y + 19, COL_FG);
927 txt_drawf("28", x + 6, y + 10, 6, COL_FG); 994 draw_line(x, y + 20, x + 24, y + 20, COL_FG);
928 } break; 995 txt_drawf_small("time", x + 3, y + 3, 4, COL_FG);
929 case 3: { 996
930 txt_drawf("42", x + 6, y + 10, 6, COL_FG); 997 switch (params->env_time) {
931 } break; 998 case 0: {
932 case 4: { 999 txt_drawf("0", x + 9, y + 10, 6, COL_FG);
933 txt_drawf("57", x + 6, y + 10, 6, COL_FG); 1000 } break;
934 } break; 1001 case 1: {
935 case 5: { 1002 txt_drawf("14", x + 6, y + 10, 6, COL_FG);
936 txt_drawf("71", x + 6, y + 10, 6, COL_FG); 1003 } break;
937 } break; 1004 case 2: {
938 case 6: { 1005 txt_drawf("28", x + 6, y + 10, 6, COL_FG);
939 txt_drawf("85", x + 6, y + 10, 6, COL_FG); 1006 } break;
940 } break; 1007 case 3: {
941 case 7: { 1008 txt_drawf("42", x + 6, y + 10, 6, COL_FG);
942 txt_drawf("100", x + 3, y + 10, 6, COL_FG); 1009 } break;
943 } break; 1010 case 4: {
1011 txt_drawf("57", x + 6, y + 10, 6, COL_FG);
1012 } break;
1013 case 5: {
1014 txt_drawf("71", x + 6, y + 10, 6, COL_FG);
1015 } break;
1016 case 6: {
1017 txt_drawf("85", x + 6, y + 10, 6, COL_FG);
1018 } break;
1019 case 7: {
1020 txt_drawf("100", x + 3, y + 10, 6, COL_FG);
1021 } break;
1022 }
944 } 1023 }
945 } 1024 }
946 1025