summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkipcode66 <kipcode66@gmail.com>2021-06-02 08:18:22 -0400
committerGitHub <noreply@github.com>2021-06-02 08:18:22 -0400
commit94c51dd196f4653364365904a18c80421cf2d222 (patch)
treebe0a972b86f3c5da8237a348fa07ae21802d467c
parente6cdc717dfaac36f40585ccbfb918d15e022424b (diff)
Added deletion feature for saved files on the card (#47)
-rw-r--r--Makefile4
m---------external/gcn_c0
-rw-r--r--include/menus/memfiles_menu.h1
-rw-r--r--include/menus/settings_menu.h1
-rw-r--r--include/utils/card.h2
-rw-r--r--src/menus/memfiles_menu.cpp18
-rw-r--r--src/menus/settings_menu.cpp14
-rw-r--r--src/utils/card.cpp30
8 files changed, 65 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index afd7fd0..15b9d0e 100644
--- a/Makefile
+++ b/Makefile
@@ -100,8 +100,8 @@ export OUTPUT := $(CURDIR)/$(TARGET)
#---------------------------------------------------------------------------------
$(BUILD):
- @external/misc/asm-inject.sh $(PLATFORM)_$(REGION)
- @external/misc/toml-inject.sh $(PLATFORM)_$(REGION)
+ @bash external/misc/asm-inject.sh $(PLATFORM)_$(REGION)
+ @bash external/misc/toml-inject.sh $(PLATFORM)_$(REGION)
@[ -d $@ ] || mkdir -p $@
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
@for i in $(MAKEFILES); do $(MAKE) --no-print-directory -C `dirname $$i` || exit 1; done;
diff --git a/external/gcn_c b/external/gcn_c
-Subproject ef13ceee12818a2b7a052068d5936ae3e3a32d2
+Subproject 65dae72e1ee0ad38bdef3186e3e5991f9166436
diff --git a/include/menus/memfiles_menu.h b/include/menus/memfiles_menu.h
index 0965435..7f3162a 100644
--- a/include/menus/memfiles_menu.h
+++ b/include/menus/memfiles_menu.h
@@ -3,6 +3,7 @@
#define MEMFILE_SLOT_INDEX 0
#define MEMFILE_SAVE_INDEX 1
#define MEMFILE_LOAD_INDEX 2
+#define MEMFILE_DELETE_INDEX 3
struct PositionData {
Vec3 link;
diff --git a/include/menus/settings_menu.h b/include/menus/settings_menu.h
index 9a14dd5..b33b49d 100644
--- a/include/menus/settings_menu.h
+++ b/include/menus/settings_menu.h
@@ -12,6 +12,7 @@ enum SettingsIndex {
SWAP_EQUIPS_INDEX,
SAVE_CARD_INDEX,
LOAD_CARD_INDEX,
+ DELETE_CARD_INDEX,
POS_SETTINGS_MENU_INDEX
};
extern bool g_drop_shadows;
diff --git a/include/utils/card.h b/include/utils/card.h
index e0a1985..22205f4 100644
--- a/include/utils/card.h
+++ b/include/utils/card.h
@@ -9,6 +9,8 @@ int32_t card_read(CardInfo* card_info, void* data, int32_t size, int32_t offset,
int32_t sector_size);
void store_mem_card(Card& card);
void store_memfile(Card& card);
+void delete_mem_card(Card& card);
+void delete_memfile(Card& card);
void load_mem_card(Card& card);
void load_memfile(Card& card);
void load_gz_card(bool& card_load);
diff --git a/src/menus/memfiles_menu.cpp b/src/menus/memfiles_menu.cpp
index 4c48057..7d18dbc 100644
--- a/src/menus/memfiles_menu.cpp
+++ b/src/menus/memfiles_menu.cpp
@@ -8,7 +8,7 @@
#include "utils/cursor.h"
#include "utils/lines.h"
-#define LINES 3
+#define LINES 4
#define MAX_SAVE_SLOTS 9
static Cursor cursor = {0, 0};
@@ -26,7 +26,8 @@ uint16_t tmpAngle = tp_gameInfo.respawn_angle;
Line lines[LINES] = {{"file slot:", MEMFILE_SLOT_INDEX, "Select memfile slot"},
{"save", MEMFILE_SAVE_INDEX, "Save memfile to slot", false},
- {"load", MEMFILE_LOAD_INDEX, "Load memfile from slot", false}};
+ {"load", MEMFILE_LOAD_INDEX, "Load memfile from slot", false},
+ {"delete", MEMFILE_DELETE_INDEX, "Delete memfile from slot", false}};
void set_memfile_position() {
// respawn pos gets overwritten by default spawn, so reinject respawn info
@@ -108,6 +109,19 @@ void MemfilesMenu::render() {
set_position_data = true;
break;
}
+ case MEMFILE_DELETE_INDEX: {
+ static Card card;
+ tp_sprintf(fileBuf, "tpgz_s%d", file_no);
+ card.file_name = fileBuf;
+ card.sector_size = SECTOR_SIZE;
+ tp_sprintf(card.file_name_buffer, card.file_name);
+ card.card_result = CARDProbeEx(0, nullptr, &card.sector_size);
+ if (card.card_result == Ready) {
+ Utilities::delete_memfile(card);
+ }
+ save_delay = 20;
+ break;
+ }
}
}
diff --git a/src/menus/settings_menu.cpp b/src/menus/settings_menu.cpp
index 1e22e93..717d2f9 100644
--- a/src/menus/settings_menu.cpp
+++ b/src/menus/settings_menu.cpp
@@ -9,7 +9,7 @@
#include "fifo_queue.h"
-#define LINES 8
+#define LINES 9
#define MAX_RELOAD_OPTIONS 2
#define MAX_CURSOR_COLOR_OPTIONS 6
#define MAX_FONT_OPTIONS 7
@@ -44,6 +44,7 @@ Line lines[LINES] = {
&g_swap_equips_flag},
{"save card", SAVE_CARD_INDEX, "Save settings to memory card"},
{"load card", LOAD_CARD_INDEX, "Load settings from memory card"},
+ {"delete card", DELETE_CARD_INDEX, "Delete settings from memory card"},
{"menu positions", POS_SETTINGS_MENU_INDEX,
"Change menu object positions (A to toggle selection, DPad to move)", false}};
@@ -93,6 +94,17 @@ void SettingsMenu::render() {
}
break;
};
+ case DELETE_CARD_INDEX: {
+ static Card card;
+ card.file_name = "tpgz01";
+ card.sector_size = SECTOR_SIZE;
+ tp_sprintf(card.file_name_buffer, card.file_name);
+ card.card_result = CARDProbeEx(0, nullptr, &card.sector_size);
+ if (card.card_result == Ready) {
+ Utilities::delete_mem_card(card);
+ }
+ break;
+ };
case SWAP_EQUIPS_INDEX: {
g_swap_equips_flag = !g_swap_equips_flag;
break;
diff --git a/src/utils/card.cpp b/src/utils/card.cpp
index fb00acb..a0e8554 100644
--- a/src/utils/card.cpp
+++ b/src/utils/card.cpp
@@ -251,6 +251,36 @@ void store_memfile(Card& card) {
#endif
}
+void delete_mem_card(Card& card) {
+#ifndef WII_PLATFORM
+ card.card_result = CARDDelete(0, card.file_name_buffer);
+ if (card.card_result == Ready) {
+ tp_osReport("deleted card!");
+ FIFOQueue::push("deleted card!", Queue);
+ } else {
+ tp_osReport("failed to delete");
+ char buff[32];
+ tp_sprintf(buff, "failed to delete: %d", card.card_result);
+ FIFOQueue::push(buff, Queue);
+ }
+#endif
+}
+
+void delete_memfile(Card& card) {
+#ifndef WII_PLATFORM
+ card.card_result = CARDDelete(0, card.file_name_buffer);
+ if (card.card_result == Ready) {
+ tp_osReport("deleted memfile!");
+ FIFOQueue::push("deleted memfile!", Queue);
+ } else {
+ tp_osReport("failed to delete");
+ char buff[32];
+ tp_sprintf(buff, "failed to delete: %d", card.card_result);
+ FIFOQueue::push(buff, Queue);
+ }
+#endif
+}
+
void load_mem_card(Card& card) {
#ifndef WII_PLATFORM
card.card_result = CARDOpen(0, card.file_name_buffer, &card.card_info);