Skip to content

Commit

Permalink
Add special Nightkingale easter egg
Browse files Browse the repository at this point in the history
  • Loading branch information
Nightkingale committed May 6, 2024
1 parent 85f5a09 commit 5ddc323
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 8 deletions.
7 changes: 3 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
#-------------------------------------------------------------------------------
Binary file added data/nightkingale.ogg
Binary file not shown.
8 changes: 8 additions & 0 deletions include/audio.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef AUDIO_HPP
#define AUDIO_HPP


void play_easter_egg();


#endif
30 changes: 30 additions & 0 deletions source/audio.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include <SDL2/SDL.h>
#include <SDL2/SDL_mixer.h>

#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;
}
12 changes: 8 additions & 4 deletions source/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,31 +24,35 @@ int read_input() {
VPAD_BUTTON_A,
VPAD_BUTTON_B,
VPAD_BUTTON_UP,
VPAD_BUTTON_DOWN
VPAD_BUTTON_DOWN,
VPAD_BUTTON_SYNC
};

// Wii Remote buttons.
const int wpad_buttons[] = {
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.
const int wpad_classic_buttons[] = {
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.
const int wpad_pro_buttons[] = {
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.
Expand Down
3 changes: 3 additions & 0 deletions source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <whb/log_console.h>
#include <whb/proc.h>

#include "audio.hpp"
#include "backup.hpp"
#include "input.hpp"
#include "main.hpp"
Expand Down Expand Up @@ -217,6 +218,8 @@ int main() {
}
break;
}
} else if (button == VPAD_BUTTON_SYNC) {
play_easter_egg();
}
}

Expand Down

0 comments on commit 5ddc323

Please sign in to comment.