Save selected music, and have 3DS version require relaunch to load selected music

This commit is contained in:
RocketRobz 2024-12-24 19:04:08 -07:00
parent bf3d209e0e
commit 75f92f0d58
5 changed files with 44 additions and 10 deletions

View File

@ -6,6 +6,7 @@
extern sound *music; extern sound *music;
extern sound *music_loop; extern sound *music_loop;
extern bool dspfirmfound; extern bool dspfirmfound;
extern bool musicStartLoaded;
void loadMusic(int num) { void loadMusic(int num) {
if (!dspfirmfound) return; if (!dspfirmfound) return;
@ -225,6 +226,7 @@ void loadMusic(int num) {
if (access(startName, F_OK) == 0) { if (access(startName, F_OK) == 0) {
music = new sound(startName, 0, false); music = new sound(startName, 0, false);
musicStartLoaded = true;
} }
if (access(loopName, F_OK) == 0) { if (access(loopName, F_OK) == 0) {
music_loop = new sound(loopName, 1, true); music_loop = new sound(loopName, 1, true);

View File

@ -29,6 +29,7 @@ char verText[32];
int studioBg = 0; int studioBg = 0;
bool cinemaWide = false; bool cinemaWide = false;
int iFps = 60; int iFps = 60;
int savedMusicId = 27;
u8 consoleModel = 0; u8 consoleModel = 0;
@ -43,6 +44,7 @@ bool horiHd = true;
bool dspfirmfound = false; bool dspfirmfound = false;
bool exiting = false; bool exiting = false;
bool musicPlayStarted = false; bool musicPlayStarted = false;
bool musicStartLoaded = false;
static bool musicPlaying = false; static bool musicPlaying = false;
static bool musicLoopPlaying = false; static bool musicLoopPlaying = false;
static int musicLoopDelay = 0; static int musicLoopDelay = 0;
@ -60,6 +62,7 @@ void loadSettings(void) {
if (setting > 0) cinemaWide = true; if (setting > 0) cinemaWide = true;
iFps = settingsini.GetInt("SuperPhotoStudio", "FRAME_RATE", iFps); iFps = settingsini.GetInt("SuperPhotoStudio", "FRAME_RATE", iFps);
horiHd = settingsini.GetInt("SuperPhotoStudio", "HORI_HD", horiHd); horiHd = settingsini.GetInt("SuperPhotoStudio", "HORI_HD", horiHd);
savedMusicId = settingsini.GetInt("SuperPhotoStudio", "MUSIC_ID", savedMusicId);
} }
void saveSettings(void) { void saveSettings(void) {
@ -68,6 +71,7 @@ void saveSettings(void) {
//settingsini.SetInt("SuperPhotoStudio", "STUDIO_BG", studioBg); //settingsini.SetInt("SuperPhotoStudio", "STUDIO_BG", studioBg);
settingsini.SetInt("SuperPhotoStudio", "CINEMA_WIDE", (cinemaWide) ? true : false); settingsini.SetInt("SuperPhotoStudio", "CINEMA_WIDE", (cinemaWide) ? true : false);
settingsini.SetInt("SuperPhotoStudio", "FRAME_RATE", iFps); settingsini.SetInt("SuperPhotoStudio", "FRAME_RATE", iFps);
savedMusicId = settingsini.GetInt("SuperPhotoStudio", "MUSIC_ID", savedMusicId);
settingsini.SaveIniFileModified(settingsIni); settingsini.SaveIniFileModified(settingsIni);
} }
@ -86,16 +90,19 @@ void Play_Music(void) {
} }
} }
void Stop_Music(void) { /* void Stop_Music(void) {
if (dspfirmfound) { if (dspfirmfound) {
music->~sound(); if (musicStartLoaded) {
music->~sound();
musicStartLoaded = false;
}
music_loop->~sound(); music_loop->~sound();
} }
musicPlayStarted = false; musicPlayStarted = false;
musicPlaying = false; musicPlaying = false;
musicLoopPlaying = false; musicLoopPlaying = false;
musicLoopDelay = 0; musicLoopDelay = 0;
} } */
/*void musLogos(void) { /*void musLogos(void) {
if (!dspfirmfound) return; if (!dspfirmfound) return;
@ -337,7 +344,10 @@ int main()
saveSettings(); saveSettings();
//delete music; if (musicStartLoaded) {
delete music;
}
delete music_loop;
//delete mus_logos; //delete mus_logos;
delete sfx_select; delete sfx_select;
delete sfx_back; delete sfx_back;

View File

@ -13,6 +13,7 @@
#include "nitrofs.h" #include "nitrofs.h"
#include "sound.h" #include "sound.h"
#include "photoStudio.hpp" #include "photoStudio.hpp"
#include "inifile.h"
#include "productIdent.hpp" #include "productIdent.hpp"
#include "rocketRobz.hpp" #include "rocketRobz.hpp"
#include "screen.hpp" #include "screen.hpp"
@ -25,9 +26,12 @@ bool exiting = false;
bool rocketRobzScreen = false; bool rocketRobzScreen = false;
int delay = 0; int delay = 0;
#define settingsIni "sd:/_nds/SuperPhotoStudio/settings.ini"
char verText[32]; char verText[32];
int studioBg = 0; int studioBg = 0;
int iFps = 60; int iFps = 60;
int savedMusicId = 27;
extern int bg3Main; extern int bg3Main;
extern bool ditherlaceOnVBlank; extern bool ditherlaceOnVBlank;
@ -35,6 +39,20 @@ extern bool secondFrame;
bool renderTop = true; // Disable to prevent second character from flickering bool renderTop = true; // Disable to prevent second character from flickering
bool doScreenshot = false; bool doScreenshot = false;
void loadSettings(void) {
CIniFile settingsini(settingsIni);
savedMusicId = settingsini.GetInt("SuperPhotoStudio", "MUSIC_ID", savedMusicId);
}
void saveSettings(void) {
CIniFile settingsini(settingsIni);
savedMusicId = settingsini.GetInt("SuperPhotoStudio", "MUSIC_ID", savedMusicId);
settingsini.SaveIniFileModified(settingsIni);
}
static bool streamStarted = false; static bool streamStarted = false;
void Play_Music(void) { void Play_Music(void) {
streamStarted ? snd().updateStream() : snd().beginStream(); streamStarted ? snd().updateStream() : snd().beginStream();
@ -106,6 +124,7 @@ int main(int argc, char **argv) {
} }
mkdir("/_nds", 0777); mkdir("/_nds", 0777);
mkdir("/_nds/SuperPhotoStudio", 0777);
if (!dsiFeatures()) { if (!dsiFeatures()) {
sysSetCartOwner (BUS_OWNER_ARM9); // Allow arm9 to access GBA ROM (or in this case, the DS Memory Expansion Pak) sysSetCartOwner (BUS_OWNER_ARM9); // Allow arm9 to access GBA ROM (or in this case, the DS Memory Expansion Pak)

View File

@ -72,8 +72,6 @@ static void Screenshot_GenerateFilename(int count, char *file_name) {
int month = localtime(&t)->tm_mon + 1; int month = localtime(&t)->tm_mon + 1;
int year = localtime(&t)->tm_year + 1900; int year = localtime(&t)->tm_year + 1900;
mkdir("/_nds", 0777);
mkdir("/_nds/SuperPhotoStudio", 0777);
mkdir("/_nds/SuperPhotoStudio/photos", 0777); mkdir("/_nds/SuperPhotoStudio/photos", 0777);
sprintf(file_name, "/_nds/SuperPhotoStudio/photos/Screenshot_%02d%02d%02d-%i.bmp", year, month, day, count); sprintf(file_name, "/_nds/SuperPhotoStudio/photos/Screenshot_%02d%02d%02d-%i.bmp", year, month, day, count);

View File

@ -45,6 +45,7 @@
#include <unistd.h> #include <unistd.h>
extern int savedMusicId;
static bool musicLoaded = false; static bool musicLoaded = false;
extern void loadMusic(int num); extern void loadMusic(int num);
@ -1024,7 +1025,7 @@ void PhotoStudio::loadChrImage(void) {
void PhotoStudio::Draw(void) const { void PhotoStudio::Draw(void) const {
if (!musicLoaded) { if (!musicLoaded) {
loadMusic(27); loadMusic(savedMusicId);
musicLoaded = true; musicLoaded = true;
} }
@ -1432,7 +1433,8 @@ void PhotoStudio::Draw(void) const {
} }
i2 += 48; i2 += 48;
GFX::DrawSprite(sprites_item_button_idx, 18, i2-20); GFX::DrawSprite(sprites_item_button_idx, 18, i2-20);
Gui::DrawString(32, i2, 0.65, WHITE, "Change Music"); Gui::DrawString(32, i2-8, 0.65, WHITE, "Change Music");
Gui::DrawString(32, i2+12, 0.50, WHITE, "Relaunch to take effect.");
} }
if (subScreenMode != 0) { if (subScreenMode != 0) {
@ -1671,14 +1673,17 @@ void PhotoStudio::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
if (hDown & KEY_A) { if (hDown & KEY_A) {
sndSelect(); sndSelect();
subScreenMode = 0; subScreenMode = 0;
savedMusicId = getBgmNum();
#ifdef NDS #ifdef NDS
redrawText = true; redrawText = true;
Gui::DrawScreen(); Gui::DrawScreen();
ditherlaceOnVBlank = true; ditherlaceOnVBlank = true;
#endif
extern void Stop_Music(void); extern void Stop_Music(void);
Stop_Music(); Stop_Music();
loadMusic(getBgmNum()); loadMusic(savedMusicId);
extern void saveSettings(void);
saveSettings();
#endif
#ifdef NDS #ifdef NDS
ditherlaceOnVBlank = false; ditherlaceOnVBlank = false;
#else #else