diff --git a/main.cpp b/main.cpp index 33a163e..4345894 100755 --- a/main.cpp +++ b/main.cpp @@ -15,6 +15,7 @@ char note_names[12][3] = { "C ", "C#", "D ", "D#", "E ", "F ", "F#", "G ", "G#", "A ", "A#", "B " }; Uint16 pattern[4][64]; +bool muted[4] = { false, false, false, false }; int selected_channel = 0; int selected_row = 0; @@ -32,6 +33,13 @@ const char get_hex(const uint8_t num) { return hexstr[num]; } +char zero_padded[3] = "00"; +const char* get_zero_padded(const uint8_t num) { + zero_padded[0] = 48 + int(num / 10); + zero_padded[1] = 48 + (num % 10); + return zero_padded; +} + int main(int argc, char* argv[]) { pattern[0][0] = (34<<10) + (2<<8) + (7<<4) + 5; SDL_Init(SDL_INIT_EVERYTHING); @@ -91,10 +99,10 @@ int main(int argc, char* argv[]) { if (sdlEvent.type == SDL_QUIT) { exit = true; break;} if (sdlEvent.type == SDL_MOUSEBUTTONDOWN) { if (sdlEvent.button.button == SDL_BUTTON_LEFT) { - if ((sdlEvent.button.x >= 3) && (sdlEvent.button.x <= 139) && (sdlEvent.button.y >= 14) && (sdlEvent.button.y <= 239) ) { + if ((sdlEvent.button.x >= 13) && (sdlEvent.button.x <= 149) && (sdlEvent.button.y >= 14) && (sdlEvent.button.y <= 239) ) { selected_row = scroll + int((sdlEvent.button.y-14)/7); - selected_channel = (sdlEvent.button.x-3)/35; - int part_pos = (sdlEvent.button.x-3)-(selected_channel*35); + selected_channel = (sdlEvent.button.x-13)/35; + int part_pos = (sdlEvent.button.x-13)-(selected_channel*35); if (part_pos <= 10) { selected_part = 0; } else if (part_pos <= 15) { @@ -107,10 +115,15 @@ int main(int argc, char* argv[]) { selected_part = 4; } } + for (int i=0; i<4; ++i) { + if ((sdlEvent.button.x >= 12+i*35) && (sdlEvent.button.x <= 45+i*35) && (sdlEvent.button.y >= 2) && (sdlEvent.button.y <= 13) ) { + muted[i] = not muted[i]; + } + } } } if (sdlEvent.type == SDL_MOUSEWHEEL) { - scroll -= sdlEvent.wheel.y; + scroll -= sdlEvent.wheel.y*4; if (scroll < 0) scroll = 0; else if (scroll > 32) scroll = 32; } if (sdlEvent.type == SDL_KEYDOWN) { @@ -238,17 +251,20 @@ int main(int argc, char* argv[]) { } } draw_clear(color_dark_grey); - draw_fill(3, 14, 33, 225, color_black); - draw_inset(2, 13, 34, 226, color_light_peach, color_dark_blue); - draw_fill(38, 14, 33, 225, color_black); - draw_inset(37, 13, 34, 226, color_light_peach, color_dark_blue); - draw_fill(73, 14, 33, 225, color_black); - draw_inset(72, 13, 34, 226, color_light_peach, color_dark_blue); - draw_fill(108, 14, 33, 225, color_black); - draw_inset(107, 13, 34, 226, color_light_peach, color_dark_blue); + draw_fill(13, 14, 33, 225, color_black); + draw_inset(12, 13, 34, 226, color_light_peach, color_dark_blue); + draw_fill(48, 14, 33, 225, color_black); + draw_inset(47, 13, 34, 226, color_light_peach, color_dark_blue); + draw_fill(83, 14, 33, 225, color_black); + draw_inset(82, 13, 34, 226, color_light_peach, color_dark_blue); + draw_fill(118, 14, 33, 225, color_black); + draw_inset(117, 13, 34, 226, color_light_peach, color_dark_blue); //draw_dotted(4, 71, 35, color_lavender); - int xp = 4, yp = 15; + for (int y=0; y<32; ++y) { + draw_string(get_zero_padded(y+scroll), 2, 15+y*7, color_dark_blue); + } + int xp = 14, yp = 15; for (int x=0; x<4; ++x) { yp = 15; for (int y=0; y<32; ++y) { @@ -283,7 +299,7 @@ int main(int argc, char* argv[]) { } xp += 35; } - //draw_string("......", 4, 15, color_dark_blue); + //draw_string(get_zero_padded(0), 2, 15, color_dark_blue); //draw_string("......", 38, 15, color_dark_blue); /*int last_x = 0, last_y = 120; for (int x=0; x<1102; ++x) { @@ -292,8 +308,19 @@ int main(int argc, char* argv[]) { last_x = x; last_y = y; }*/ - //draw_string("HOLA", 11, 11, color_black); - //draw_string("HOLA", 10, 10, color_white); + for (int i=0; i<4; ++i) { + if (muted[i]) { + draw_inset(12+i*35, 2, 33, 11, color_light_peach, color_dark_blue); + //draw_string("MUTE", 20+i*35, 6, color_black); + draw_string("MUTE", 19+i*35, 5, color_light_grey); + } else { + draw_outset(12+i*35, 2, 33, 11, color_light_peach, color_dark_blue); + draw_string("MUTE", 20+i*35, 6, color_black); + draw_string("MUTE", 19+i*35, 5, color_white); + } + } + + draw_present(); //SDL_QueueAudio(sdlAudioDevice, &beeps[0], SOUND_SIZE_IN_BYTES*8);