Add music change feature

TODO: Add more music
This commit is contained in:
RocketRobz 2021-06-27 19:50:23 -06:00
parent 83d69b4885
commit c96ded54c3
15 changed files with 431 additions and 96 deletions

30
3ds/source/bgm.cpp Normal file
View File

@ -0,0 +1,30 @@
#include "common.hpp"
#include "sound.h"
#include <unistd.h>
extern sound *music;
extern sound *music_loop;
static bool music_loaded = false;
static bool music_loop_loaded = false;
void loadMusic(int num) {
if (music_loaded) {
music->stop();
delete music;
}
if (music_loop_loaded) {
music_loop->stop();
delete music_loop;
}
switch (num) {
case 0:
default:
music = new sound("romfs:/music/pkmnStadium/stadiumSel_start.wav", 0, false);
music_loop = new sound("romfs:/music/pkmnStadium/stadiumSel_loop.wav", 1, true);
break;
}
music_loaded = true;
music_loop_loaded = true;
}

View File

@ -86,6 +86,13 @@ void Play_Music(void) {
}
}
void Stop_Music(void) {
musicPlayStarted = false;
musicPlaying = false;
musicLoopPlaying = false;
musicLoopDelay = 0;
}
/*void musLogos(void) {
if (!dspfirmfound) return;
mus_logos->stop();
@ -214,8 +221,6 @@ int main()
// Load the sound effects if DSP is available.
if (dspfirmfound) {
//mus_logos = new sound("romfs:/sounds/logos.wav", 0, false);
music = new sound("romfs:/sounds/music_start.wav", 0, false);
music_loop = new sound("romfs:/sounds/music_loop.wav", 1, true);
sfx_select = new sound("romfs:/sounds/select.wav", 2, false);
sfx_back = new sound("romfs:/sounds/back.wav", 3, false);
sfx_highlight = new sound("romfs:/sounds/highlight.wav", 4, false);

View File

@ -0,0 +1,9 @@
const char* pkmnStadiumBgmNames[] = {
"Stadium Select",
"",
"",
};
int pkmnStadiumBgmNums[] = {
0,
};

View File

@ -25,6 +25,7 @@ private:
const char* import_characterFileName(void) const;
const char* import_SS2CharacterNames(int i) const;
const char* NESCharacterNames(int i) const;
const char* pkmnStadiumTitle(void) const;
const char* ss1Title(void) const;
const char* ss2Title(void) const;
const char* ss3Title(void) const;
@ -32,10 +33,13 @@ private:
const char* nesTitle(void) const;
const char* bgGameTitle(void) const;
const char* charGameTitle(void) const;
const char* bgmGameTitle(void) const;
bool charGender(int i) const;
const char* bgName(int i) const;
const char* charName(int i) const;
const char* bgmName(int i) const;
int getBgNum(void) const;
int getBgmNum(void) const;
void drawMsg(void) const;
void loadChrImage(void);
@ -50,6 +54,7 @@ private:
mutable int cursorX, cursorY;
int photo_highlightedGame = 0;
int char_highlightedGame[5] = {0};
int bgm_highlightedGame = 0;
int seasonNo[5] = {0};
int currentCharNum = 0;
int charsShown = 0;
@ -90,6 +95,10 @@ private:
int import_bgShownFirst = 0;
int bgmList_cursorPosition = 0;
int bgmList_cursorPositionOnScreen = 0;
int bgmShownFirst = 0;
int numberOfSettings = 1;
int settings_cursorPosition = 0;
int settings_cursorPositionOnScreen = 0;

View File

@ -21,15 +21,12 @@ class SoundControl {
// Refill the stream buffers
volatile void updateStream();
void loadStream(const char* path, const char* loopPath, u32 sampleRate, bool loop);
void beginStream();
void stopStream();
void fadeOutStream();
void cancelFadeOutStream();
// Sets the number of samples of silence to
// stream before continuing.
void setStreamDelay(u32 stream_delay);
private:
mm_sound_effect snd_select;
mm_sound_effect snd_back;
@ -37,6 +34,8 @@ class SoundControl {
mm_stream stream;
mm_ds_system sys;
bool stream_is_playing;
bool loopingPoint;
bool looping;
//mm_sound_effect snd_loading;
mm_sound_effect mus_startup;
FILE* stream_start_source;

View File

@ -20,6 +20,7 @@ extern "C" {
#endif
void init_streaming_buf(void);
void resetStreamSettings();
mm_word on_stream_request(mm_word length, mm_addr dest, mm_stream_formats format);
#ifdef __cplusplus

13
nds/arm9/source/bgm.cpp Normal file
View File

@ -0,0 +1,13 @@
#include "common.hpp"
#include "sound.h"
#include <unistd.h>
void loadMusic(int num) {
switch (num) {
case 0:
default:
snd().loadStream("nitro:/music/pkmnStadium/stadiumSel_start.raw", "nitro:/music/pkmnStadium/stadiumSel_loop.raw", 22050, true);
break;
}
}

View File

@ -41,6 +41,11 @@ void Play_Music(void) {
streamStarted = true;
}
void Stop_Music(void) {
snd().stopStream();
streamStarted = false;
}
void sndSelect(void) {
snd().playSelect();
}

View File

@ -91,64 +91,82 @@ SoundControl::SoundControl()
if (!dsDebugRam && !mepFound) return;
init_streaming_buf();
stream_start_source = fopen("nitro:/music/start.raw", "rb");
stream_source = fopen("nitro:/music/loop.raw", "rb");
fseek(stream_source, 0, SEEK_SET);
stream.sampling_rate = 22050; // 22050Hz
stream.buffer_length = 1600; // should be adequate
stream.callback = on_stream_request;
stream.format = MM_STREAM_16BIT_MONO; // select format
stream.timer = MM_TIMER0; // use timer0
stream.manual = false; // auto filling
fseek(stream_start_source, 0, SEEK_END);
size_t fileSize = ftell(stream_start_source);
fseek(stream_start_source, 0, SEEK_SET);
// Prep the first section of the stream
fread((void*)play_stream_buf, sizeof(s16), STREAMING_BUF_LENGTH, stream_start_source);
if (fileSize < STREAMING_BUF_LENGTH*sizeof(s16)) {
size_t fillerSize = 0;
while (fileSize+fillerSize < STREAMING_BUF_LENGTH*sizeof(s16)) {
fillerSize++;
}
fread((void*)play_stream_buf+fileSize, 1, fillerSize, stream_source);
// Fill the next section premptively
fread((void*)fill_stream_buf, sizeof(s16), STREAMING_BUF_LENGTH, stream_source);
//loopingPoint = true;
} else {
// Fill the next section premptively
fread((void*)fill_stream_buf, sizeof(s16), STREAMING_BUF_LENGTH, stream_start_source);
fileSize -= STREAMING_BUF_LENGTH*sizeof(s16);
if (fileSize < STREAMING_BUF_LENGTH*sizeof(s16)) {
size_t fillerSize = 0;
while (fileSize+fillerSize < STREAMING_BUF_LENGTH*sizeof(s16)) {
fillerSize++;
}
fread((void*)fill_stream_buf+fileSize, 1, fillerSize, stream_source);
//loopingPoint = true;
}
}
// Prep the first section of the stream
//fread((void*)play_stream_buf, sizeof(s16), STREAMING_BUF_LENGTH, stream_source);
// Fill the next section premptively
//fread((void*)fill_stream_buf, sizeof(s16), STREAMING_BUF_LENGTH, stream_source);
}
mm_sfxhand SoundControl::playSelect() { return mmEffectEx(&snd_select); }
mm_sfxhand SoundControl::playBack() { return mmEffectEx(&snd_back); }
mm_sfxhand SoundControl::playHighlight() { return mmEffectEx(&snd_highlight); }
void SoundControl::loadStream(const char* path, const char* loopPath, u32 sampleRate, bool loop) {
if (!dsDebugRam && !mepFound) return;
if (stream_source) {
stream_is_playing = false;
mmStreamClose();
fclose(stream_source);
}
resetStreamSettings();
stream_start_source = fopen(path, "rb");
stream_source = fopen(loopPath, "rb");
if (!stream_source) return;
bool loopableMusic = stream_start_source ? true : false;
fseek(stream_source, 0, SEEK_SET);
stream.sampling_rate = sampleRate; // 22050Hz
stream.buffer_length = 1600; // should be adequate
stream.callback = on_stream_request;
stream.format = MM_STREAM_16BIT_MONO; // select format
stream.timer = MM_TIMER0; // use timer0
stream.manual = false; // auto filling
looping = loop;
if (loopableMusic) {
fseek(stream_start_source, 0, SEEK_END);
size_t fileSize = ftell(stream_start_source);
fseek(stream_start_source, 0, SEEK_SET);
// Prep the first section of the stream
fread((void*)play_stream_buf, sizeof(s16), STREAMING_BUF_LENGTH, stream_start_source);
if (fileSize < STREAMING_BUF_LENGTH*sizeof(s16)) {
size_t fillerSize = 0;
while (fileSize+fillerSize < STREAMING_BUF_LENGTH*sizeof(s16)) {
fillerSize++;
}
fread((void*)play_stream_buf+fileSize, 1, fillerSize, stream_source);
// Fill the next section premptively
fread((void*)fill_stream_buf, sizeof(s16), STREAMING_BUF_LENGTH, stream_source);
loopingPoint = true;
} else {
// Fill the next section premptively
fread((void*)fill_stream_buf, sizeof(s16), STREAMING_BUF_LENGTH, stream_start_source);
fileSize -= STREAMING_BUF_LENGTH*sizeof(s16);
if (fileSize < STREAMING_BUF_LENGTH*sizeof(s16)) {
size_t fillerSize = 0;
while (fileSize+fillerSize < STREAMING_BUF_LENGTH*sizeof(s16)) {
fillerSize++;
}
fread((void*)fill_stream_buf+fileSize, 1, fillerSize, stream_source);
loopingPoint = true;
}
}
} else {
// Prep the first section of the stream
fread((void*)play_stream_buf, sizeof(s16), STREAMING_BUF_LENGTH, stream_source);
// Fill the next section premptively
fread((void*)fill_stream_buf, sizeof(s16), STREAMING_BUF_LENGTH, stream_source);
loopingPoint = true;
}
}
void SoundControl::beginStream() {
if (!stream_source) return;
@ -174,10 +192,6 @@ void SoundControl::cancelFadeOutStream() {
fade_counter = FADE_STEPS;
}
void SoundControl::setStreamDelay(u32 delay) {
sample_delay_count = delay;
}
// Samples remaining in the fill buffer.
#define SAMPLES_LEFT_TO_FILL (abs(STREAMING_BUF_LENGTH - filled_samples))
@ -210,15 +224,20 @@ volatile void SoundControl::updateStream() {
int instance_to_fill = std::min(SAMPLES_LEFT_TO_FILL, SAMPLES_TO_FILL);
// If we don't read enough samples, loop from the beginning of the file.
instance_filled = fread((s16*)fill_stream_buf + filled_samples, sizeof(s16), instance_to_fill, stream_source);
instance_filled = fread((s16*)fill_stream_buf + filled_samples, sizeof(s16), instance_to_fill, loopingPoint ? stream_source : stream_start_source);
if (instance_filled < instance_to_fill) {
fseek(stream_source, 0, SEEK_SET);
int i = fread((s16*)fill_stream_buf + filled_samples + instance_filled,
sizeof(s16), (instance_to_fill - instance_filled), stream_source);
if (i==0) {
toncset((s16*)fill_stream_buf + filled_samples + instance_filled, 0, (instance_to_fill - instance_filled)*sizeof(s16));
if (looping) {
fseek(stream_source, 0, SEEK_SET);
int i = fread((s16*)fill_stream_buf + filled_samples + instance_filled,
sizeof(s16), (instance_to_fill - instance_filled), stream_source);
if (i==0) {
toncset((s16*)fill_stream_buf + filled_samples + instance_filled, 0, (instance_to_fill - instance_filled)*sizeof(s16));
} else {
instance_filled += i;
}
loopingPoint = true;
} else {
instance_filled += i;
toncset((s16*)fill_stream_buf + filled_samples + instance_filled, 0, (instance_to_fill - instance_filled)*sizeof(s16));
}
}

View File

@ -33,6 +33,19 @@ void init_streaming_buf(void) {
fill_stream_buf = malloc(STREAMING_BUF_LENGTH*sizeof(s16));
}
void resetStreamSettings() {
streaming_buf_ptr = 0;
filled_samples = 0;
fill_requested = false;
fade_counter = FADE_STEPS;
fade_out = false;
sample_delay_count = 0;
}
/*
* The maxmod stream request handler.
*

View File

@ -30,9 +30,17 @@
#include "pdarkBgNames.h"
#include "smBgNames.h"
#include "pkmnStadiumBgmNames.h"
#include <unistd.h>
static bool musicLoaded = false;
extern void loadMusic(int num);
#ifdef NDS
extern bool mepFound;
extern bool dsDebugRam;
#define sysRegion *(u8*)0x02FFFD70
/// Configuration region values.
@ -76,7 +84,8 @@ static u8 bgPageOrder[] = {
1, // Style Savvy: Trendsetters
2, // Style Savvy: Fashion Forward
3, // Style Savvy: Styling Star
6}; // Super Mario series
6, // Super Mario series
};
static u8 charPageOrder[] = {
4, // Super Photo Studio (Original Characters)
@ -100,6 +109,10 @@ static u8 charPageOrder[] = {
0xFF, // Custom
};
static u8 bgmPageOrder[] = {
0, // Pokemon Stadium
};
static int metalXpos = 0;
#ifdef NDS
extern bool displayChars;
@ -121,7 +134,14 @@ void PhotoStudio::getList() {
}
void PhotoStudio::getMaxChars() {
if (subScreenMode == 1) {
if (subScreenMode == 3) {
// Music
switch (bgmPageOrder[bgm_highlightedGame]) {
case 0:
import_totalCharacters = 0;
break;
}
} else if (subScreenMode == 1) {
// Locations
switch (bgPageOrder[photo_highlightedGame]) {
case 0:
@ -459,6 +479,16 @@ const char* PhotoStudio::NESCharacterNames(int i) const {
}
}
const char* PhotoStudio::pkmnStadiumTitle(void) const {
switch (sysRegion) {
default:
return "Pokemon Stadium";
case CFG_REGION_JPN:
case CFG_REGION_KOR:
return "Pocket Monsters Stadium";
}
}
const char* PhotoStudio::ss1Title(void) const {
switch (sysRegion) {
default:
@ -634,6 +664,14 @@ bool PhotoStudio::charGender(int i) const {
return true;
}
const char* PhotoStudio::bgmGameTitle(void) const {
switch (bgmPageOrder[bgm_highlightedGame]) {
case 0:
return pkmnStadiumTitle();
}
return "???";
}
const char* PhotoStudio::bgName(int i) const {
switch (bgPageOrder[photo_highlightedGame]) {
case 0:
@ -698,6 +736,14 @@ const char* PhotoStudio::charName(int i) const {
return "???";
}
const char* PhotoStudio::bgmName(int i) const {
switch (bgmPageOrder[bgm_highlightedGame]) {
case 0:
return pkmnStadiumBgmNames[i];
}
return "???";
}
int PhotoStudio::getBgNum(void) const {
switch (bgPageOrder[photo_highlightedGame]) {
case 0:
@ -718,6 +764,14 @@ int PhotoStudio::getBgNum(void) const {
return 0;
}
int PhotoStudio::getBgmNum(void) const {
switch (bgmPageOrder[bgm_highlightedGame]) {
case 0:
return pkmnStadiumBgmNums[bgmList_cursorPosition];
}
return 0;
}
void PhotoStudio::drawMsg(void) const {
#ifdef _3DS
GFX::DrawSprite(sprites_msg_idx, 0, 8, 1, 1);
@ -782,6 +836,11 @@ void PhotoStudio::loadChrImage(void) {
void PhotoStudio::Draw(void) const {
if (!musicLoaded) {
loadMusic(0);
musicLoaded = true;
}
#ifdef NDS // Bottom screen only
extern void updateTitleScreen(const int metalXposBase);
updateTitleScreen(metalXpos);
@ -792,7 +851,11 @@ void PhotoStudio::Draw(void) const {
if (redrawText) {
clearText(false);
sprintf((char*)chrCounter, "%d/%d", (subScreenMode==1 ? bgList_cursorPosition : importCharacterList_cursorPosition[currentCharNum])+1, import_totalCharacters+1);
int cursorPosition = (subScreenMode==1 ? bgList_cursorPosition : importCharacterList_cursorPosition[currentCharNum]);
if (subScreenMode == 3) {
cursorPosition = bgmList_cursorPosition;
}
sprintf((char*)chrCounter, "%d/%d", cursorPosition+1, import_totalCharacters+1);
}
if (showScrollingBg) {
@ -806,7 +869,35 @@ void PhotoStudio::Draw(void) const {
}
cursorX = 200;
if (subScreenMode == 2) {
if (subScreenMode == 3) {
cursorY = 52+(40*bgmList_cursorPositionOnScreen);
if (redrawText) {
printSmall(false, 0, 6, bgmGameTitle(), Alignment::center);
printSmall(false, 6, 6, "<");
printSmall(false, 242, 6, ">");
printSmall(false, 56, 152, chrCounter);
}
if (!displayNothing) {
int i2 = 40;
int i3 = 0;
// Reset item button Y positions
for (int i = 0; i < 3; i++) {
for (int x = 0; x < 4; x++) {
oamSub.oamMemory[(2+i)+(x*3)].y = 192;
}
}
for (int i = bgmShownFirst; i < bgmShownFirst+3; i++) {
if (i >= import_totalCharacters+1) break;
for (int x = 0; x < 4; x++) {
oamSub.oamMemory[(2+i3)+(x*3)].y = i2-16;
}
if (redrawText) printSmall(false, 26, i2, bgmName(i));
i2 += 40;
i3++;
}
}
} else if (subScreenMode == 2) {
cursorY = 52+(40*importCharacterList_cursorPositionOnScreen[currentCharNum]);
if (redrawText) {
printSmall(false, 0, 6, charGameTitle(), Alignment::center);
@ -884,7 +975,7 @@ void PhotoStudio::Draw(void) const {
extern bool fatInited;
if (fatInited) {
printSmall(false, 162, 168, "Y: Take photo");
printSmall(false, 162, 168, "Y: Take Photo");
}
}
@ -898,28 +989,36 @@ void PhotoStudio::Draw(void) const {
for (int x = 0; x < 4; x++) {
oamSub.oamMemory[2+(x*3)].y = i2-16;
}
if (redrawText) printSmall(false, 26, i2, "Change location");
if (redrawText) printSmall(false, 26, i2, "Change Location");
i2 += 40;
for (int x = 0; x < 4; x++) {
oamSub.oamMemory[3+(x*3)].y = i2-16;
}
// Hide 3rd button
for (int x = 0; x < 4; x++) {
oamSub.oamMemory[4+(x*3)].y = 192;
}
if (redrawText) {
if (currentCharNum==4) {
printSmall(false, 26, i2, characterPicked[4] ? "Change character < 5 >" : "Add character < 5 >");
printSmall(false, 26, i2, characterPicked[4] ? "Change Character < 5 >" : "Add Character < 5 >");
} else if (currentCharNum==3) {
printSmall(false, 26, i2, characterPicked[3] ? "Change character < 4 >" : "Add character < 4 >");
printSmall(false, 26, i2, characterPicked[3] ? "Change Character < 4 >" : "Add Character < 4 >");
} else if (currentCharNum==2) {
printSmall(false, 26, i2, characterPicked[2] ? "Change character < 3 >" : "Add character < 3 >");
printSmall(false, 26, i2, characterPicked[2] ? "Change Character < 3 >" : "Add Character < 3 >");
} else if (currentCharNum==1) {
printSmall(false, 26, i2, characterPicked[1] ? "Change character < 2 >" : "Add character < 2 >");
printSmall(false, 26, i2, characterPicked[1] ? "Change Character < 2 >" : "Add Character < 2 >");
} else {
printSmall(false, 26, i2, characterPicked[0] ? "Change character < 1 >" : "Add character < 1 >");
printSmall(false, 26, i2, characterPicked[0] ? "Change Character < 1 >" : "Add Character < 1 >");
}
}
if (dsDebugRam || mepFound) {
i2 += 40;
for (int x = 0; x < 4; x++) {
oamSub.oamMemory[4+(x*3)].y = i2-16;
}
if (redrawText) printSmall(false, 26, i2, "Change Music");
} else {
// Hide 3rd button
for (int x = 0; x < 4; x++) {
oamSub.oamMemory[4+(x*3)].y = 192;
}
}
}
oamSub.oamMemory[0].y = (subScreenMode != 0) ? 156 : 192;
@ -996,12 +1095,33 @@ void PhotoStudio::Draw(void) const {
return;
}
Gui::ScreenDraw(Bottom);
sprintf((char*)chrCounter, "%d/%d", (subScreenMode==1 ? bgList_cursorPosition : importCharacterList_cursorPosition[currentCharNum])+1, import_totalCharacters+1);
int cursorPosition = (subScreenMode==1 ? bgList_cursorPosition : importCharacterList_cursorPosition[currentCharNum]);
if (subScreenMode == 3) {
cursorPosition = bgmList_cursorPosition;
}
sprintf((char*)chrCounter, "%d/%d", cursorPosition+1, import_totalCharacters+1);
GFX::DrawSprite(sprites_photo_bg_idx, 0, 0);
cursorX = 248;
if (subScreenMode == 10) {
SettingsDraw();
} else if (subScreenMode == 3) {
cursorY = 64+(48*bgmList_cursorPositionOnScreen);
Gui::DrawStringCentered(0, 8, 0.50, WHITE, bgmGameTitle());
Gui::DrawString(8, 8, 0.50, WHITE, "<");
Gui::DrawString(304, 8, 0.50, WHITE, ">");
Gui::DrawString(64, 184, 0.55, WHITE, chrCounter);
if (!displayNothing) {
int i2 = 48;
for (int i = bgmShownFirst; i < bgmShownFirst+3; i++) {
if (i >= import_totalCharacters+1) break;
GFX::DrawSprite(sprites_item_button_idx, 18, i2-20);
Gui::DrawString(32, i2, 0.65, WHITE, bgmName(i));
i2 += 48;
}
}
} else if (subScreenMode == 2) {
cursorY = 64+(48*importCharacterList_cursorPositionOnScreen[currentCharNum]);
@ -1062,25 +1182,28 @@ void PhotoStudio::Draw(void) const {
Gui::DrawString(8, 8, 0.50, WHITE, "What do you want to do?");
Gui::DrawString(192, 206, 0.65, WHITE, ": Take photo");
Gui::DrawString(192, 206, 0.65, WHITE, ": Take Photo");
int i2 = 0;
i2 += 48;
GFX::DrawSprite(sprites_item_button_idx, 18, i2-20);
Gui::DrawString(32, i2, 0.65, WHITE, "Change location");
Gui::DrawString(32, i2, 0.65, WHITE, "Change Location");
i2 += 48;
GFX::DrawSprite(sprites_item_button_idx, 18, i2-20);
if (currentCharNum==4) {
Gui::DrawString(32, i2, 0.65, WHITE, characterPicked[4] ? "Change character < 5 >" : "Add character < 5 >");
Gui::DrawString(32, i2, 0.65, WHITE, characterPicked[4] ? "Change Character < 5 >" : "Add Character < 5 >");
} else if (currentCharNum==3) {
Gui::DrawString(32, i2, 0.65, WHITE, characterPicked[3] ? "Change character < 4 >" : "Add character < 4 >");
Gui::DrawString(32, i2, 0.65, WHITE, characterPicked[3] ? "Change Character < 4 >" : "Add Character < 4 >");
} else if (currentCharNum==2) {
Gui::DrawString(32, i2, 0.65, WHITE, characterPicked[2] ? "Change character < 3 >" : "Add character < 3 >");
Gui::DrawString(32, i2, 0.65, WHITE, characterPicked[2] ? "Change Character < 3 >" : "Add Character < 3 >");
} else if (currentCharNum==1) {
Gui::DrawString(32, i2, 0.65, WHITE, characterPicked[1] ? "Change character < 2 >" : "Add character < 2 >");
Gui::DrawString(32, i2, 0.65, WHITE, characterPicked[1] ? "Change Character < 2 >" : "Add Character < 2 >");
} else {
Gui::DrawString(32, i2, 0.65, WHITE, characterPicked[0] ? "Change character < 1 >" : "Add character < 1 >");
Gui::DrawString(32, i2, 0.65, WHITE, characterPicked[0] ? "Change Character < 1 >" : "Add Character < 1 >");
}
i2 += 48;
GFX::DrawSprite(sprites_item_button_idx, 18, i2-20);
Gui::DrawString(32, i2, 0.65, WHITE, "Change Music");
}
if (subScreenMode != 0) {
@ -1164,6 +1287,97 @@ void PhotoStudio::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
} else if (subScreenMode == 10) {
SettingsLogic(hDown, hHeld, touch);
#endif
} else if (subScreenMode == 3) {
if (showCursor) {
if (hDown & KEY_DUP) {
sndHighlight();
bgmList_cursorPosition--;
bgmList_cursorPositionOnScreen--;
if (bgmList_cursorPosition < 0) {
bgmList_cursorPosition = 0;
bgmShownFirst = 0;
} else if (bgList_cursorPosition < bgmShownFirst) {
bgmShownFirst--;
}
if (bgmList_cursorPositionOnScreen < 0) {
bgmList_cursorPositionOnScreen = 0;
}
#ifdef NDS
redrawText = true;
Gui::DrawScreen();
#endif
}
if (hDown & KEY_DDOWN) {
sndHighlight();
bgmList_cursorPosition++;
bgmList_cursorPositionOnScreen++;
if (bgmList_cursorPosition > import_totalCharacters) {
bgmList_cursorPosition = import_totalCharacters;
bgmShownFirst = import_totalCharacters-2;
if (bgmShownFirst < 0) bgmShownFirst = 0;
if (bgmList_cursorPositionOnScreen > import_totalCharacters) {
bgmList_cursorPositionOnScreen = import_totalCharacters;
}
} else if (bgmList_cursorPosition > bgmShownFirst+2) {
bgmShownFirst++;
}
if (bgmList_cursorPositionOnScreen > 2) {
bgmList_cursorPositionOnScreen = 2;
}
#ifdef NDS
redrawText = true;
Gui::DrawScreen();
#endif
}
}
if (hDown & KEY_A) {
sndSelect();
subScreenMode = 0;
#ifdef NDS
redrawText = true;
Gui::DrawScreen();
#endif
extern void Stop_Music(void);
Stop_Music();
loadMusic(getBgmNum());
}
if (hDown & KEY_DLEFT) {
sndHighlight();
bgm_highlightedGame--;
if (bgm_highlightedGame < 0) bgm_highlightedGame = (int)sizeof(bgmPageOrder)-1;
getMaxChars();
}
if (hDown & KEY_DRIGHT) {
sndHighlight();
bgm_highlightedGame++;
if (bgm_highlightedGame > (int)sizeof(bgmPageOrder)-1) bgm_highlightedGame = 0;
getMaxChars();
}
if ((hDown & KEY_DLEFT) || (hDown & KEY_DRIGHT)) {
bgmList_cursorPosition = 0;
bgmList_cursorPositionOnScreen = 0;
bgmShownFirst = 0;
getMaxChars();
#ifdef NDS
redrawText = true;
Gui::DrawScreen();
#endif
}
if ((hDown & KEY_B) || ((hDown & KEY_TOUCH) && touchingBackButton())) {
sndBack();
subScreenMode = 0;
#ifdef NDS
redrawText = true;
Gui::DrawScreen();
#endif
}
} else if (subScreenMode == 2) {
if (showCursor) {
if (hDown & KEY_DUP) {
@ -1494,12 +1708,22 @@ void PhotoStudio::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
sndHighlight();
characterChangeMenu_cursorPosition++;
characterChangeMenu_cursorPositionOnScreen++;
if (characterChangeMenu_cursorPosition > 1) {
characterChangeMenu_cursorPosition = 1;
#ifdef NDS
int limit = (dsDebugRam || mepFound) ? 2 : 1;
if (characterChangeMenu_cursorPosition > limit) {
characterChangeMenu_cursorPosition = limit;
}
if (characterChangeMenu_cursorPositionOnScreen > 1) {
characterChangeMenu_cursorPositionOnScreen = 1;
if (characterChangeMenu_cursorPositionOnScreen > limit) {
characterChangeMenu_cursorPositionOnScreen = limit;
}
#else
if (characterChangeMenu_cursorPosition > 2) {
characterChangeMenu_cursorPosition = 2;
}
if (characterChangeMenu_cursorPositionOnScreen > 2) {
characterChangeMenu_cursorPositionOnScreen = 2;
}
#endif
}
if (characterChangeMenu_cursorPosition == 1) {
@ -1585,6 +1809,14 @@ void PhotoStudio::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
renderTop = true;
loadChrImage();
}
} else if (characterChangeMenu_cursorPosition == 2) {
sndSelect();
subScreenMode = 3;
getMaxChars();
#ifdef NDS
redrawText = true;
Gui::DrawScreen();
#endif
}
}