diff --git a/resources/music/floor0.raw b/resources/music/floor0.raw new file mode 100644 index 0000000..bfc2e33 Binary files /dev/null and b/resources/music/floor0.raw differ diff --git a/resources/music/floor1.raw b/resources/music/floor1.raw new file mode 100644 index 0000000..cd64fed Binary files /dev/null and b/resources/music/floor1.raw differ diff --git a/resources/music/floor2_3.raw b/resources/music/floor2_3.raw new file mode 100644 index 0000000..15b630c Binary files /dev/null and b/resources/music/floor2_3.raw differ diff --git a/resources/music/floor4.raw b/resources/music/floor4.raw new file mode 100644 index 0000000..1ea2ec9 Binary files /dev/null and b/resources/music/floor4.raw differ diff --git a/resources/music/menu.raw b/resources/music/menu.raw new file mode 100644 index 0000000..528495b Binary files /dev/null and b/resources/music/menu.raw differ diff --git a/source/Globals.c b/source/Globals.c index 9507cba..c91bb0f 100644 --- a/source/Globals.c +++ b/source/Globals.c @@ -1205,6 +1205,8 @@ void switchLevel(s8 change){ if(currentLevel == 1) sf2d_set_clear_color(0xFF6C6D82); //sf2d_set_clear_color(RGBA8(0x82, 0x6D, 0x6C, 0xFF)); else if(currentLevel > 1) sf2d_set_clear_color(0xFF666666); //sf2d_set_clear_color(RGBA8(0x66, 0x66, 0x66, 0xFF)); else sf2d_set_clear_color(0xFF007F00); //sf2d_set_clear_color(RGBA8(0x00, 0x7F, 0x00, 0xFF)); + + updateMusic(currentLevel); } bool playerIntersectsEntity(Entity* e){ diff --git a/source/Menu.c b/source/Menu.c index 3317a3d..56e46cf 100644 --- a/source/Menu.c +++ b/source/Menu.c @@ -390,6 +390,8 @@ void tickMenu(int menu){ sf2d_set_clear_color(0xFF); currentSelection = 0; currentMenu = MENU_TITLE; + + playMusic(music_menu); } else if (k_decline.clicked){ areYouSure = false; areYouSureSave = false; @@ -436,6 +438,8 @@ void tickMenu(int menu){ currentSelection = 0; currentMenu = MENU_TITLE; saveCurrentWorld(currentFileName, &eManager, &player, (u8*)map, (u8*)data); + + playMusic(music_menu); } break; case MENU_LOSE: @@ -443,6 +447,8 @@ void tickMenu(int menu){ sf2d_set_clear_color(0xFF); currentSelection = 0; currentMenu = MENU_TITLE; + + playMusic(music_menu); } break; case MENU_ABOUT: @@ -1145,8 +1151,12 @@ void renderMenu(int menu,int xscr,int yscr){ drawTextColor("Special Thanks to:",52,12,0xFF7F7FFF); drawTextColor("Smea",136,60,0xFF2020FF); drawSizedTextColor("for ctrulib",116,80,1.0,0xFF2020FF); - drawTextColor("Xerpi",130,120,0xFFFF2020); - drawSizedTextColor("for sf2dlib",116,140,1.0,0xFFFF2020); + drawTextColor("Xerpi",130,110,0xFFFF2020); + drawSizedTextColor("for sf2dlib",116,130,1.0,0xFFFF2020); + drawTextColor("Music from",100,160,0xFF20FF20); + drawSizedTextColor("opengameart.org/content/",64,180,1.0,0xFF20FF20); + drawSizedTextColor("generic-8-bit-jrpg-soundtrack",48,190,1.0,0xFF20FF20); + drawText("Press to return", 58, 220); renderButtonIcon(k_decline.input & -k_decline.input, 128, 218, 1); sf2d_end_frame(); diff --git a/source/Sound.c b/source/Sound.c index f81da06..aedd70c 100644 --- a/source/Sound.c +++ b/source/Sound.c @@ -16,6 +16,28 @@ void playSound(Sound snd){ csndPlaySound(8, SOUND_FORMAT_16BIT | SOUND_ONE_SHOT, 44100, 1, 0, snd.buffer, snd.buffer, snd.size); } +void playMusic(Sound snd){ + csndPlaySound(10, SOUND_FORMAT_16BIT | SOUND_REPEAT, 44100, 1, 0, snd.buffer, snd.buffer, snd.size); +} + +void updateMusic(int lvl) { + switch(lvl) { + case 0: + playMusic(music_floor0); + break; + case 1: + playMusic(music_floor1); + break; + case 2: + case 3: + playMusic(music_floor23); + break; + case 4: + playMusic(music_floor4); + break; + } +} + void freeSounds(){ linearFree(snd_playerHurt.buffer); linearFree(snd_playerDeath.buffer); @@ -24,4 +46,10 @@ void freeSounds(){ linearFree(snd_pickup.buffer); linearFree(snd_bossdeath.buffer); linearFree(snd_craft.buffer); + + linearFree(music_menu.buffer); + linearFree(music_floor0.buffer); + linearFree(music_floor1.buffer); + linearFree(music_floor23.buffer); + linearFree(music_floor4.buffer); } diff --git a/source/Sound.h b/source/Sound.h index 14fedae..4946cd7 100644 --- a/source/Sound.h +++ b/source/Sound.h @@ -12,6 +12,10 @@ typedef struct { void loadSound(Sound * snd, char * filename); void playSound(Sound snd); + +void playMusic(Sound snd); +void updateMusic(int lvl); + void freeSounds(); Sound snd_playerHurt; @@ -21,3 +25,9 @@ Sound snd_test; Sound snd_pickup; Sound snd_bossdeath; Sound snd_craft; + +Sound music_menu; +Sound music_floor0; +Sound music_floor1; +Sound music_floor23; +Sound music_floor4; \ No newline at end of file diff --git a/source/main.c b/source/main.c index 114dd7d..6a1e69f 100644 --- a/source/main.c +++ b/source/main.c @@ -81,6 +81,8 @@ void setupGame(bool loadUpWorld) { initPlayer(); loadWorld(currentFileName, &eManager, &player, (u8*) map, (u8*) data); } + + updateMusic(currentLevel); initMiniMap(loadUpWorld); shouldRenderMap = false; @@ -176,7 +178,15 @@ int main() { loadSound(&snd_pickup, "resources/pickup.raw"); loadSound(&snd_bossdeath, "resources/bossdeath.raw"); loadSound(&snd_craft, "resources/craft.raw"); + + loadSound(&music_menu, "resources/music/menu.raw"); + loadSound(&music_floor0, "resources/music/floor0.raw"); + loadSound(&music_floor1, "resources/music/floor1.raw"); + loadSound(&music_floor23, "resources/music/floor2_3.raw"); + loadSound(&music_floor4, "resources/music/floor4.raw"); + playMusic(music_menu); + bakeLights();