From 969c97dcf5ed3e134064c462d19157a9e0140c84 Mon Sep 17 00:00:00 2001 From: Date: Mon, 12 Aug 2019 21:42:37 -0700 Subject: [PATCH] Piano fix; Added modes --- README.md | 12 +++++------- gfx/pianolayout.gbm | Bin 1416 -> 1416 bytes gfx/pianoroll2.gbr | Bin 10069 -> 10069 bytes gfx/ui.h | 21 ++++++++++++++++++++- muddygb_dsd.c | 25 ++++++++++++++++++++----- muddygb_dsd.h | 4 ++-- music.h | 5 +++++ scales.c | 8 +++++--- 8 files changed, 57 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 8b0df0f..a0b7766 100644 --- a/README.md +++ b/README.md @@ -14,14 +14,13 @@ There are currently no configuration options. Usage ----- -Usage is similar to muddyGB, but with some big changes planned. +Usage is similar to muddyGB, but with a much different method of playing. * The directional pad acts to play the notes of the chosen scale. -* The START button raises and lowers the scale by an octave. * The B button enables portamento between notes * The A button performs a fixed vibrato -* The START button raise the pitch by an octave -* The SELECT button lower the pitch by an octave +* The START button raises the pitch by an octave +* The SELECT button lowers the pitch by an octave * while SELECT + START pressed got the options mode * + RIGHT selects the current mode. * + UP or DOWN selects the scale tonic (base note). @@ -49,9 +48,8 @@ For future versions minestones for v1.0: -* add graphical options menu - * enter by pressing key combination +* Change options behavior to edit options with only the select key. +* Fix the Piano to go up and down octaves, and shift around -* fix waveform selection * add echo mode to pulse wave * add selectable envelopes (volume, pitch and pulse width) diff --git a/gfx/pianolayout.gbm b/gfx/pianolayout.gbm index 152aac7d09be2a7729e00c6165704cc458f587cd..2bc360823a74095ad37c0a395b2c74e0f5f526b0 100644 GIT binary patch delta 180 zcmeC+?%>|Q$K)*&c$M*c`Ta=@K+ru$i+Rhh3|Q$28GYqh5i5fq{jAi6P*327^a(6#K!A@5=&!G*Fmf0TTlQNM4FTmZ1PB zzop_MQwESO-SEDw7$^>sa{*!ohJ1z;Fb&ZIVuH*#!104A0LYeLWMY_c?r+(K=iix> ka=w&JX#5B?IUl5qmjNVj0VoOLZ9c@bpNTyzi3wyq0BhJP+W-In diff --git a/gfx/pianoroll2.gbr b/gfx/pianoroll2.gbr index d9421ef73337f3321f5c68e61cb4b132b4fbba08..399e60359f06f1d3b6172b916102502ffc82b6a1 100644 GIT binary patch delta 14 TcmccWchzr$zdD;R0|)>BD0>5j delta 14 VcmccWchzr$zdD;F0|UbY1^_Bw1Z)5R diff --git a/gfx/ui.h b/gfx/ui.h index 53e3cbf..4585477 100644 --- a/gfx/ui.h +++ b/gfx/ui.h @@ -3,4 +3,23 @@ const int HUDPositions[] = { 1,3, 1,5, 1,7 -}; \ No newline at end of file +}; + +const unsigned char PianoNotesDown[][4] = { + {0x65, 0x66, 0x62, 0x61 }, // C + {0x64, 0x67, 0x61, 0x61 }, // C# + {0x68, 0x6A, 0x62, 0x61 }, // D + {0x69, 0x6B, 0x61, 0x61 }, // D# + {0x6C, 0x63, 0x62, 0x61}, // E + {0x65, 0x66, 0x62, 0x61 }, // F + {0x64, 0x67, 0x61, 0x61 }, // F# + {0x68, 0x66, 0x62, 0x61 }, // G + {0x64, 0x67, 0x61, 0x61 }, // G# + {0x68, 0x6A, 0x62, 0x61 }, // A + {0x69, 0x6B, 0x61, 0x61 }, // A# + {0x6C, 0x63, 0x62, 0x61}, // B +}; + +const unsigned int PianoOffset[] = { + 0,0,1,1,2,3,3,4,4,5,5,6 +}; diff --git a/muddygb_dsd.c b/muddygb_dsd.c index 38f965d..3eaf3e7 100644 --- a/muddygb_dsd.c +++ b/muddygb_dsd.c @@ -18,6 +18,8 @@ void main() { UBYTE keys; UBYTE pos, old_pos = 0; int note = 0; + int noteInt = 0; // Used for the piano + int oldNoteMap[4] = {0,0,0,0}; int octave_min = 0; int octave_max = 3; int relative_octave = 0; @@ -86,9 +88,8 @@ void main() { keys = joypad (); pos = scale_position (keys); jp = just_pressed(keys); - //if (jp != 0) printf("%d\n", jp); - if (pos) { + if (pos) { // Check for A and B keys here. note = scale[pos - 1] + relative_octave*OCTAVE_LEN; /* Lower by semitone */ @@ -218,11 +219,19 @@ void main() { printf(note_names[note % OCTAVE_LEN]); else printf(note_names[note + OCTAVE_LEN]); + absolute_octave = note / OCTAVE_LEN + 3; printf("%d", absolute_octave); + gotoxy(0, 16); + noteInt = note % OCTAVE_LEN; + + + set_bkg_tiles(0, 16, PianoLayoutWidth, PianoLayoutHeight, PianoLayout); + set_bkg_tiles(7 + PianoOffset[noteInt],16,2,2, PianoNotesDown[noteInt]); + //printf(" "); //font_set(big_font); } else { @@ -230,6 +239,7 @@ void main() { CH1_VOL = OFF; CH2_VOL = OFF; targetNote = 0; + set_bkg_tiles(0, 16, PianoLayoutWidth, PianoLayoutHeight, PianoLayout); } } @@ -331,15 +341,20 @@ void play_note (short note, UBYTE waveform, short bend, int newNote ) { #define BUILD(TYPE) \ gotoxy(HUDPositions[4], HUDPositions[5]); \ printf ("mode %s", note_names[tonic]); \ - printf ("%s ", #TYPE); \ + printf ("%s ", #TYPE); \ build_scale (scale, tonic, TYPE); \ break; void build_scale_mode (UBYTE * scale, UBYTE tonic, UBYTE mode) { switch (mode) { case 0: BUILD (major); - case 1: BUILD (minor); - case 2: BUILD (blues); + case 1: BUILD (dorian); + case 2: BUILD (phrygian); + case 3: BUILD (lydian); + case 4: BUILD (myxolydian); + case 5: BUILD (minor); + case 6: BUILD (locrian); + case 7: BUILD (blues); } } diff --git a/muddygb_dsd.h b/muddygb_dsd.h index 6e550ed..839908b 100644 --- a/muddygb_dsd.h +++ b/muddygb_dsd.h @@ -6,13 +6,13 @@ #ifndef BOUEUX_H #define BOUEUX_H -#define MUDDYGBRVL_VERSION "0.1a" +#define MUDDYGBRVL_VERSION "0.3a" #define UINT unsigned int #define UBYTE unsigned char #define SCALE UBYTE -#define NUM_MODES 3 +#define NUM_MODES 8 #define OCTAVE_LEN 12 #define PRESSED(KEY) (keys & J_## KEY) diff --git a/music.h b/music.h index 34a21b5..1aea1da 100644 --- a/music.h +++ b/music.h @@ -15,7 +15,12 @@ const char* note_names[] = { extern SCALE major[]; +extern SCALE dorian[]; +extern SCALE phrygian[]; +extern SCALE lydian[]; +extern SCALE myxolydian[]; extern SCALE minor[]; +extern SCALE locrian[]; extern SCALE blues[]; void build_scale (UBYTE * scale, UBYTE tonic, SCALE * scale_type); diff --git a/scales.c b/scales.c index 0d21d85..ae204ef 100644 --- a/scales.c +++ b/scales.c @@ -8,15 +8,17 @@ */ SCALE major[] = { C, D, E, F, G, A, B, C2 }; +SCALE dorian[] = { C, D, Ds, F, G, A, As, C2 }; +SCALE phrygian[] = { C, Cs, Ds, F, G, Gs, As, C2 }; +SCALE lydian[] = { C, D, E, Fs, G, A, B, C2 }; +SCALE myxolydian[] = { C, D, E, F, G, A, As, C2 }; SCALE minor[] = { C, D, Ds, F, G, Gs, As, C2 }; +SCALE locrian[] = { C, Cs, Ds, F, Fs, Gs, As, C2 }; SCALE blues[] = { C, Ds, F, Fs, G, As, C2, Ds2 }; //SCALE harmonic[] = { C, D, Ds, F, G, Gs, B, C2 }; //SCALE wholetone[] = { C, D, E, Fs, Gs, As, C2, D2 }; -//SCALE dorian[] = { C, D, Ds, F, G, A, As, C2 }; -//SCALE lydian[] = { C, D, E, Fs, G, A, B, C2 }; - /* The 'blue' scale uses quarter-tones. (see music.c.) * It is equivalent to C, D, Ed, F, G, A, Bd, C2. */