Add special Nightkingale easter egg

This commit is contained in:
Nightkingale 2024-05-05 20:06:41 -06:00
parent 85f5a09d0e
commit 5ddc323bd4
6 changed files with 52 additions and 8 deletions

View File

@ -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
#-------------------------------------------------------------------------------

BIN
data/nightkingale.ogg Normal file

Binary file not shown.

8
include/audio.hpp Normal file
View File

@ -0,0 +1,8 @@
#ifndef AUDIO_HPP
#define AUDIO_HPP
void play_easter_egg();
#endif

30
source/audio.cpp Normal file
View File

@ -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;
}

View File

@ -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.

View File

@ -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"
@ -217,6 +218,8 @@ int main() {
}
break;
}
} else if (button == VPAD_BUTTON_SYNC) {
play_easter_egg();
}
}