diff --git a/Makefile b/Makefile index 701c78e..5c03b6d 100644 --- a/Makefile +++ b/Makefile @@ -61,7 +61,8 @@ CXXFLAGS := $(CFLAGS) ASFLAGS := -g $(ARCH) LDFLAGS = -g $(ARCH) $(RPXSPECS) -Wl,-Map,$(notdir $*.map) -LIBS := -lSDL2 -lSDL2_ttf -lfreetype -lharfbuzz -lfreetype -lpng -lbz2 -lz -lmocha -lwut +LIBS := -lSDL2_mixer -lSDL2 -lSDL2_ttf -lfreetype -lharfbuzz -lfreetype -lpng -lbz2 \ + -lz -lmodplug -lmpg123 -logg -lmocha -lwut #------------------------------------------------------------------------------- # list of directories containing libraries, this must be the top level @@ -188,13 +189,11 @@ $(OFILES_SRC) : $(HFILES_BIN) @$(bin2o) #------------------------------------------------------------------------------- -%.bdf.o %_bdf.h : %.bdf +%.ogg.o %_ogg.h : %.ogg #------------------------------------------------------------------------------- @echo $(notdir $<) @$(bin2o) --include $(DEPENDS) - #------------------------------------------------------------------------------- endif #------------------------------------------------------------------------------- \ No newline at end of file diff --git a/data/nightkingale.ogg b/data/nightkingale.ogg new file mode 100644 index 0000000..5fca1b3 Binary files /dev/null and b/data/nightkingale.ogg differ diff --git a/include/audio.hpp b/include/audio.hpp new file mode 100644 index 0000000..07db615 --- /dev/null +++ b/include/audio.hpp @@ -0,0 +1,8 @@ +#ifndef AUDIO_HPP +#define AUDIO_HPP + + +void play_easter_egg(); + + +#endif \ No newline at end of file diff --git a/source/audio.cpp b/source/audio.cpp new file mode 100644 index 0000000..3774beb --- /dev/null +++ b/source/audio.cpp @@ -0,0 +1,30 @@ +#include +#include + +#include "nightkingale_ogg.h" + + +bool play_easter_egg() { + // Initialize SDL_mixer. + if (Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 2048) < 0) { + return false; + } + + // Load the OGG file. + SDL_RWops *rw = SDL_RWFromConstMem(nightkingale_ogg, nightkingale_ogg_size); + Mix_Music *music = Mix_LoadMUS_RW(rw, 1); + + // Play the music once. + Mix_PlayMusic(music, 1); + + // Wait for the music to finish. + while (Mix_PlayingMusic()) { + SDL_Delay(100); + } + + // Clean up. + Mix_FreeMusic(music); + Mix_CloseAudio(); + + return true; +} \ No newline at end of file diff --git a/source/input.cpp b/source/input.cpp index 6134139..2016257 100644 --- a/source/input.cpp +++ b/source/input.cpp @@ -24,7 +24,8 @@ int read_input() { VPAD_BUTTON_A, VPAD_BUTTON_B, VPAD_BUTTON_UP, - VPAD_BUTTON_DOWN + VPAD_BUTTON_DOWN, + VPAD_BUTTON_SYNC }; // Wii Remote buttons. @@ -32,7 +33,8 @@ int read_input() { WPAD_BUTTON_A, WPAD_BUTTON_B, WPAD_BUTTON_UP, - WPAD_BUTTON_DOWN + WPAD_BUTTON_DOWN, + 0 // WPAD_BUTTON_SYNC does not exist. }; // Wii Classic Controller buttons. @@ -40,7 +42,8 @@ int read_input() { WPAD_CLASSIC_BUTTON_A, WPAD_CLASSIC_BUTTON_B, WPAD_CLASSIC_BUTTON_UP, - WPAD_CLASSIC_BUTTON_DOWN + WPAD_CLASSIC_BUTTON_DOWN, + 0 // WPAD_CLASSIC_BUTTON_SYNC does not exist. }; // Wii U Pro Controller buttons. @@ -48,7 +51,8 @@ int read_input() { WPAD_PRO_BUTTON_A, WPAD_PRO_BUTTON_B, WPAD_PRO_BUTTON_UP, - WPAD_PRO_BUTTON_DOWN + WPAD_PRO_BUTTON_DOWN, + 0 // WPAD_PRO_BUTTON_SYNC does not exist. }; // Iterate over all 4 KPAD channels and check for button presses. diff --git a/source/main.cpp b/source/main.cpp index cc58d03..34e0e7d 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -18,6 +18,7 @@ #include #include +#include "audio.hpp" #include "backup.hpp" #include "input.hpp" #include "main.hpp" @@ -217,6 +218,8 @@ int main() { } break; } + } else if (button == VPAD_BUTTON_SYNC) { + play_easter_egg(); } }