commit 63f14c408e26341aa614691bb414a73c544e26c9
Author: DPS2004 <dpsophinos@gmail.com>
AuthorDate: Mon Mar 28 09:47:09 2022 -0400
Commit: DPS2004 <dpsophinos@gmail.com>
CommitDate: Mon Mar 28 09:47:09 2022 -0400
save if carts have been loaded to ini file
---
platform/3ds/Makefile | 7 ++--
source/host.h | 11 +++++
source/hostCommonFunctions.cpp | 92 +++++++++++++++++++++++++-----------------
source/logger.cpp | 2 +-
source/main.cpp | 1 -
5 files changed, 71 insertions(+), 42 deletions(-)
diff --git a/platform/3ds/Makefile b/platform/3ds/Makefile
index ba1da4c..4043116 100644
--- a/platform/3ds/Makefile
+++ b/platform/3ds/Makefile
@@ -73,7 +73,7 @@ CFLAGS := -g -Wall -Ofast -mword-relocations \
CFLAGS += $(INCLUDE) -DARM11 -D_3DS -DVER_STR=\"$(APP_VERSION)\"
# enable pack in games with this platform
-CFLAGS += -DLOAD_PACK_INS
+# CFLAGS += -DLOAD_PACK_INS
CXXFLAGS := $(CFLAGS) -fno-rtti -fexceptions -std=gnu++17
@@ -215,11 +215,12 @@ $(GFXBUILD)/%.t3x $(BUILD)/%.h : %.t3s
$(TARGET)-strip.elf: $(BUILD)
@$(STRIP) $(TARGET).elf -o $(TARGET)-strip.elf
#---------------------------------------------------------------------------------
-$(TARGET)-cia.smdh: banner/$(TARGET)-icon.png
- @bannertool makesmdh -s "$(TARGET)" -l "$(APP_TITLE)" -p "$(APP_AUTHOR)" -i banner/$(TARGET)-icon.png -o $(TARGET)-cia.smdh -r regionfree
+$(TARGET)-cia.bnr: banner/$(TARGET)-banner.png banner/$(TARGET).wav
+ @bannertool makebanner -i banner/$(TARGET)-banner.png -a banner/$(TARGET).wav -o $(TARGET)-cia.bnr
#---------------------------------------------------------------------------------
$(TARGET)-cia.smdh: banner/$(TARGET)-icon.png
@bannertool makesmdh -s "$(TARGET)" -l "$(APP_TITLE)" -p "$(APP_AUTHOR)" -i banner/$(TARGET)-icon.png -o $(TARGET)-cia.smdh -r regionfree
+
#---------------------------------------------------------------------------------
cia: $(TARGET)-strip.elf $(TARGET)-cia.bnr $(TARGET)-cia.smdh banner/$(TARGET).rsf
@makerom -f cia -elf $(TARGET)-strip.elf -icon $(TARGET)-cia.smdh -banner $(TARGET)-cia.bnr -desc app:4 -v -o $(TARGET).cia -target t -exefslogo -rsf banner/$(TARGET).rsf \
diff --git a/source/host.h b/source/host.h
index acd2ce8..a40aefb 100644
--- a/source/host.h
+++ b/source/host.h
@@ -18,13 +18,24 @@ enum StretchOption {
FourByThreeStretch
};
+#if LOAD_PACK_INS
+enum PackinLoadOption {
+ Unloaded,
+ Loaded
+};
+#endif
+
class Host {
uint8_t currKDown;
uint8_t currKHeld;
bool lDown = false;
bool rDown = false;
bool stretchKeyPressed = false;
+ #if LOAD_PACK_INS
+ PackinLoadOption packinloaded = Unloaded;
+ #endif
StretchOption stretch = PixelPerfectStretch;
+
float scaleX = 1.0;
float scaleY = 1.0;
int mouseOffsetX = 0;
diff --git a/source/hostCommonFunctions.cpp b/source/hostCommonFunctions.cpp
index e14ced1..102c304 100644
--- a/source/hostCommonFunctions.cpp
+++ b/source/hostCommonFunctions.cpp
@@ -65,45 +65,51 @@ Color* Host::GetPaletteColors(){
void Host::unpackCarts(){
#if LOAD_PACK_INS
-
- Logger_Write("unzipping pack in carts to p8carts\n");
-
- //based on https://github.com/richgel999/miniz/issues/38
-
- mz_zip_archive zip_archive;
- memset(&zip_archive, 0, sizeof(zip_archive));
+ if(packinloaded == Unloaded){
+ Logger_Write("unzipping pack in carts to p8carts\n");
+
+ //based on https://github.com/richgel999/miniz/issues/38
+
+ mz_zip_archive zip_archive;
+ memset(&zip_archive, 0, sizeof(zip_archive));
- // init zip file
- mz_zip_reader_init_mem(&zip_archive, source_carts_zip, source_carts_zip_len, 0);
-
- int fileCount = (int)mz_zip_reader_get_num_files(&zip_archive);
- if (fileCount == 0)
- {
- mz_zip_reader_end(&zip_archive);
- }
- mz_zip_archive_file_stat file_stat;
- if (!mz_zip_reader_file_stat(&zip_archive, 0, &file_stat))
- {
+ // init zip file
+ mz_zip_reader_init_mem(&zip_archive, source_carts_zip, source_carts_zip_len, 0);
+
+ int fileCount = (int)mz_zip_reader_get_num_files(&zip_archive);
+ if (fileCount == 0)
+ {
+ mz_zip_reader_end(&zip_archive);
+ }
+ mz_zip_archive_file_stat file_stat;
+ if (!mz_zip_reader_file_stat(&zip_archive, 0, &file_stat))
+ {
+ mz_zip_reader_end(&zip_archive);
+ }
+ // Get root folder
+ string base = _cartDirectory; // path delim on end
+
+ // Get and print information about each file in the archive.
+ for (int i = 0; i < fileCount; i++)
+ {
+ if (!mz_zip_reader_file_stat(&zip_archive, i, &file_stat)) continue;
+ if (mz_zip_reader_is_file_a_directory(&zip_archive, i)) continue; // skip directories for now
+ string fileName = base + file_stat.m_filename; // make path relative
+ Logger_Write(fileName.c_str());
+ Logger_Write("\n");
+ string destFile = fileName; // make full dest path
+
+ mz_zip_reader_extract_to_file(&zip_archive, i, destFile.c_str(), 0);
+ }
+
+ // Close the archive, freeing any resources it was using
mz_zip_reader_end(&zip_archive);
+
+ packinloaded = Loaded;
+
+ }else{
+ Logger_Write("packins already loaded\n");
}
- // Get root folder
- string base = _cartDirectory; // path delim on end
-
- // Get and print information about each file in the archive.
- for (int i = 0; i < fileCount; i++)
- {
- if (!mz_zip_reader_file_stat(&zip_archive, i, &file_stat)) continue;
- if (mz_zip_reader_is_file_a_directory(&zip_archive, i)) continue; // skip directories for now
- string fileName = base + file_stat.m_filename; // make path relative
- Logger_Write(fileName.c_str());
- Logger_Write("\n");
- string destFile = fileName; // make full dest path
-
- mz_zip_reader_extract_to_file(&zip_archive, i, destFile.c_str(), 0);
- }
-
- // Close the archive, freeing any resources it was using
- mz_zip_reader_end(&zip_archive);
#endif
@@ -115,7 +121,11 @@ void Host::loadSettingsIni(){
//File does not exist, fill string with defaults
if(settingsIniStr.length() == 0 ){
- settingsIniStr = "[settings]\nstretch = 1\n";
+ #if LOAD_PACK_INS
+ settingsIniStr = "[settings]\nstretch = 1\npackinloaded = 0\n";
+ #else
+ settingsIniStr = "[settings]\nstretch = 1\n";
+ #endif
}
settingsIni.LoadData(settingsIniStr);
@@ -124,11 +134,19 @@ void Host::loadSettingsIni(){
if (stretchSetting <= (int)AltScreenStretch){
stretch = (StretchOption) stretchSetting;
}
+
+ #if LOAD_PACK_INS
+ long packinloadedSetting = settingsIni.GetLongValue("settings", "packinloaded", (long)Unloaded);
+ packinloaded = (PackinLoadOption) packinloadedSetting;
+ #endif
}
void Host::saveSettingsIni(){
//write out settings to persist
settingsIni.SetLongValue("settings", "stretch", stretch);
+ #if LOAD_PACK_INS
+ settingsIni.SetLongValue("settings", "packinloaded", packinloaded);
+ #endif
std::string settingsIniStr = "";
settingsIni.Save(settingsIniStr, false);
diff --git a/source/logger.cpp b/source/logger.cpp
index c88c67c..7fca0e3 100644
--- a/source/logger.cpp
+++ b/source/logger.cpp
@@ -4,7 +4,7 @@
#include "logger.h"
-#define LOGGER_ENABLED false
+#define LOGGER_ENABLED true
#define PRINT_TO_CONSOLE false
FILE * m_file = nullptr;
diff --git a/source/main.cpp b/source/main.cpp
index 4dcebd0..7af2cae 100644
--- a/source/main.cpp
+++ b/source/main.cpp
@@ -32,7 +32,6 @@ int main(int argc, char* argv[])
host->oneTimeSetup(audio);
#if LOAD_PACK_INS
- //todo: make this only happen once, save if it has happened in settings.ini
host->unpackCarts();
#endif