From ddab6e4b0a908648f53df018e62d8cd8ec6a2564 Mon Sep 17 00:00:00 2001 From: R Ferreira Date: Sun, 23 Nov 2025 22:19:39 +0000 Subject: [PATCH 1/3] extend inst zap dialogue --- arm9/source/main.cpp | 55 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 51 insertions(+), 4 deletions(-) diff --git a/arm9/source/main.cpp b/arm9/source/main.cpp index c7ade5b..a4cb4eb 100644 --- a/arm9/source/main.cpp +++ b/arm9/source/main.cpp @@ -753,12 +753,11 @@ void setSong(Song *newsong) updateSampleList(song->getInstrument(0)); inst = song->getInstrument(0); - if(inst != 0) - handleSampleChange(0); + handleSampleChange(0); + volEnvSetInst(song->getInstrument(0)); - inst = song->getInstrument(0); if(inst != 0) { cbvolenvenabled->setChecked(inst->getVolEnvEnabled()); @@ -1709,6 +1708,44 @@ void zapPatterns(void) updateMemoryState(true); } +void zapUnusedInstruments(void) { + u8 instList[MAX_INSTRUMENTS]; // indices of instruments that were cleared + u8 n_un = song->zapUnusedInstruments(instList); + if (n_un > 0) + for (int i = 0; i < n_un; i++) { + lbinstruments->set(instList[i], ""); + if (lbinstruments->getidx() == i) { + sampledisplay->setSample(NULL); + handleSampleChange(0); + for(u8 i=0;iset(i, ""); + } + } + } + + DC_FlushAll(); + deleteMessageBox(); + CommandSetSong(song); + updateMemoryState(true); +} + +void zapCurrentInstrument(void) { + PrintFreeMem(); + u8 inst = lbinstruments->getidx(); + song->zapInstrument(inst); + sampledisplay->setSample(NULL); + handleSampleChange(0); + DC_FlushAll(); + deleteMessageBox(); + + lbinstruments->set(inst, ""); + for(u8 i=0;iset(i, ""); + } + CommandSetSong(song); + updateMemoryState(true); +} + void zapInstruments(void) { song->zapInstruments(); @@ -1740,12 +1777,22 @@ void zapSong(void) { updateMemoryState(true); } +void zapInstrumentsChoice(void) +{ + deleteMessageBox(); + mb = new MessageBox(&sub_vram, "which instruments", 4, "selected", zapCurrentInstrument, "unused", zapUnusedInstruments, + " all ", zapInstruments, "cancel", + deleteMessageBox); + gui->registerOverlayWidget(mb, 0, SUB_SCREEN); + mb->reveal(); +} + void handleZap(void) { stopPlay(); // Safety first mb = new MessageBox(&sub_vram, "what to zap", 4, "patterns", zapPatterns, - "instruments", zapInstruments, "song", zapSong, "cancel", + "instruments", zapInstrumentsChoice, "song", zapSong, "cancel", deleteMessageBox); gui->registerOverlayWidget(mb, 0, SUB_SCREEN); mb->reveal(); From 8f30331bfd87a65e09c20ddd4bef0ebd8eaf931d Mon Sep 17 00:00:00 2001 From: prayerie Date: Mon, 24 Nov 2025 16:53:06 +0000 Subject: [PATCH 2/3] Zap confirmations --- arm9/source/main.cpp | 59 ++++++++++++++++++++++++++++++++------------ 1 file changed, 43 insertions(+), 16 deletions(-) diff --git a/arm9/source/main.cpp b/arm9/source/main.cpp index 0917761..74ce26b 100644 --- a/arm9/source/main.cpp +++ b/arm9/source/main.cpp @@ -1714,6 +1714,14 @@ void handleRestartPosChange(s32 restartpos) DC_FlushAll(); } +void confirmZap(void (*onConfirm)(void)) +{ + deleteMessageBox(); + mb = new MessageBox(&sub_vram, "are you sure", 2, "yes", onConfirm, "cancel", deleteMessageBox); + gui->registerOverlayWidget(mb, 0, SUB_SCREEN); + mb->reveal(); +} + void zapPatterns(void) { song->zapPatterns(); @@ -1742,20 +1750,23 @@ void zapPatterns(void) } void zapUnusedInstruments(void) { - u8 instList[MAX_INSTRUMENTS]; // indices of instruments that were cleared - u8 n_un = song->zapUnusedInstruments(instList); - if (n_un > 0) - for (int i = 0; i < n_un; i++) { - lbinstruments->set(instList[i], ""); - if (lbinstruments->getidx() == i) { - sampledisplay->setSample(NULL); - handleSampleChange(0); - for(u8 i=0;iset(i, ""); - } + bool used_insts[MAX_INSTRUMENTS] = { false }; + + song->zapUnusedInstruments(used_insts); + + for (int i = 0; i < MAX_INSTRUMENTS; i++) { + if (!used_insts[i]) continue; + + lbinstruments->set(i, ""); + if (lbinstruments->getidx() == i) { + sampledisplay->setSample(NULL); + handleSampleChange(0); + for(u8 i=0;iset(i, ""); } } - + } + DC_FlushAll(); deleteMessageBox(); CommandSetSong(song); @@ -1803,6 +1814,7 @@ void zapInstruments(void) setHasUnsavedChanges(true); } + void zapSong(void) { deleteMessageBox(); delete song; @@ -1810,11 +1822,26 @@ void zapSong(void) { updateMemoryState(true); } +void confirmZapSong(void) +{ + confirmZap(zapSong); +} + +void confirmZapInsts(void) +{ + confirmZap(zapInstruments); +} + +void confirmZapPatterns(void) +{ + confirmZap(zapPatterns); +} + void zapInstrumentsChoice(void) { deleteMessageBox(); mb = new MessageBox(&sub_vram, "which instruments", 4, "selected", zapCurrentInstrument, "unused", zapUnusedInstruments, - " all ", zapInstruments, "cancel", + " all ", confirmZapInsts, "cancel", deleteMessageBox); gui->registerOverlayWidget(mb, 0, SUB_SCREEN); mb->reveal(); @@ -1824,8 +1851,8 @@ void handleZap(void) { stopPlay(); // Safety first - mb = new MessageBox(&sub_vram, "what to zap", 4, "patterns", zapPatterns, - "instruments", zapInstrumentsChoice, "song", zapSong, "cancel", + mb = new MessageBox(&sub_vram, "what to zap", 4, "patterns", confirmZapPatterns, + "instruments", zapInstrumentsChoice, "song", confirmZapSong, "cancel", deleteMessageBox); gui->registerOverlayWidget(mb, 0, SUB_SCREEN); mb->reveal(); @@ -4296,4 +4323,4 @@ int main(int argc, char **argv) { if (launch_path) ntxm_free(launch_path); return 0; -} \ No newline at end of file +} From 98389c237d0e02832020cbafcf60216f14ac1865 Mon Sep 17 00:00:00 2001 From: prayerie Date: Mon, 24 Nov 2025 17:03:57 +0000 Subject: [PATCH 3/3] fix inverted zapping --- arm9/source/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arm9/source/main.cpp b/arm9/source/main.cpp index 74ce26b..ffaca98 100644 --- a/arm9/source/main.cpp +++ b/arm9/source/main.cpp @@ -1755,7 +1755,7 @@ void zapUnusedInstruments(void) { song->zapUnusedInstruments(used_insts); for (int i = 0; i < MAX_INSTRUMENTS; i++) { - if (!used_insts[i]) continue; + if (used_insts[i]) continue; lbinstruments->set(i, ""); if (lbinstruments->getidx() == i) {