From 7084d260527c6a2fdd736766e9140ebb6eee136d Mon Sep 17 00:00:00 2001 From: ApacheThunder Date: Sun, 19 May 2024 23:50:00 -0500 Subject: [PATCH] FIx Slot-2 DS mode ... * Fix mistake that caused DS mode Slot-2 booting to not work. (accidently removed needed arm7 code in previous commit after optimizing code relating to Rumble Menu softreset) --- Makefile | 8 +- arm7/source/main.c | 31 ++++++-- arm9/Makefile | 4 +- arm9/{source => include}/defaultSettings.s | 0 arm9/{source => include}/dsCard.h | 0 arm9/{source => include}/dsCard.itcm.cpp | 2 +- arm9/{source => include}/graphics.s | 0 arm9/{source => include}/io_sc_common.c | 0 arm9/{source => include}/io_sc_common.h | 0 .../bootloader => include}/nds_loader_arm9.c | 0 .../bootloader => include}/nds_loader_arm9.h | 0 .../bootloader => include}/ret_menu9_gen.c | 0 .../bootloader => include}/ret_menu9_gen.h | 0 arm9/source/gbaldr.itcm.cpp | 3 +- arm9/source/main.c | 33 ++++----- arm9/source/maindef.h | 2 +- arm9/source/memcleaner.cpp | 74 ------------------- arm9/source/memcleaner.h | 51 ------------- 18 files changed, 48 insertions(+), 160 deletions(-) rename arm9/{source => include}/defaultSettings.s (100%) rename arm9/{source => include}/dsCard.h (100%) rename arm9/{source => include}/dsCard.itcm.cpp (99%) rename arm9/{source => include}/graphics.s (100%) rename arm9/{source => include}/io_sc_common.c (100%) rename arm9/{source => include}/io_sc_common.h (100%) rename arm9/{source/bootloader => include}/nds_loader_arm9.c (100%) rename arm9/{source/bootloader => include}/nds_loader_arm9.h (100%) rename arm9/{source/bootloader => include}/ret_menu9_gen.c (100%) rename arm9/{source/bootloader => include}/ret_menu9_gen.h (100%) delete mode 100644 arm9/source/memcleaner.cpp delete mode 100644 arm9/source/memcleaner.h diff --git a/Makefile b/Makefile index 923238e..87f5005 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ export TARGET := GBA_ExpLoader export TOPDIR := $(CURDIR) export VERSION_MAJOR := 0 -export VERSION_MINOR := 61 +export VERSION_MINOR := 61b export VERSTRING := $(VERSION_MAJOR).$(VERSION_MINOR) # GMAE_ICON is the image used to create the game icon, leave blank to use default rule @@ -45,11 +45,11 @@ checkarm9: #--------------------------------------------------------------------------------- $(TARGET).nds : arm7/$(TARGET).elf arm9/$(TARGET).elf @ndstool -c $@ -7 arm7/$(TARGET).elf -9 arm9/$(TARGET).elf \ - -b $(CURDIR)/logo32.bmp "GBA ExpLoader;Version $(VERSTRING);By Rudolph;" \ + -b $(CURDIR)/logo32.bmp "GBA ExpLoader;Version $(VERSTRING);By Rudolph" \ -g #### 01 "GBAEXPLOADER" -z 80040000 -u 00030004 -a 00000138 -p 0001 \ data: - @mkdir -p data + @mkdir -p arm9/data ndsbootloader: data $(MAKE) -C ndsbootloader LOADBIN=$(CURDIR)/arm9/data/load.bin @@ -67,6 +67,6 @@ clean: $(MAKE) -C arm9 clean $(MAKE) -C arm7 clean $(MAKE) -C ndsbootloader clean - rm -rf data + rm -rf arm9/data rm -f $(TARGET).nds diff --git a/arm7/source/main.c b/arm7/source/main.c index abe8953..19ee20b 100644 --- a/arm7/source/main.c +++ b/arm7/source/main.c @@ -37,6 +37,24 @@ volatile bool switchedMode = false; // They used r0 instead of r2. This reimplementation fixes that issue for now. extern void swiSwitchToGBAModeFixed(); +static void prepareReset() { + vu32 vr; + u32 i; + + powerOn(POWER_SOUND); + + for(i = 0x040000B0; i < (0x040000B0+0x30); i+=4)*((vu32*)i) = 0; + + REG_IME = IME_DISABLE; + REG_IE = 0; + REG_IF = ~0; + + for(vr = 0; vr < 0x100; vr++); // Wait ARM9 + + swiSoftReset(); +} + + void gbaMode() { vu32 vr; @@ -57,15 +75,18 @@ volatile bool exitflag = false; void powerButtonCB() { exitflag = true; } void fifoCheckHandler() { - if (!switchedMode && fifoCheckValue32(FIFO_USER_01)) { - switchedMode = true; - gbaMode(); + if (!switchedMode) { + if (fifoCheckValue32(FIFO_USER_01)) { + switchedMode = true; + gbaMode(); + } else if (fifoCheckValue32(FIFO_USER_02)) { + switchedMode = true; + prepareReset(); + } } } void VblankHandler(void) { fifoCheckHandler(); } - - void VcountHandler() { inputGetAndSend(); } int main() { diff --git a/arm9/Makefile b/arm9/Makefile index 3127b61..0d75b06 100644 --- a/arm9/Makefile +++ b/arm9/Makefile @@ -16,8 +16,8 @@ include $(DEVKITARM)/ds_rules # all directories are relative to this makefile #--------------------------------------------------------------------------------- BUILD := build -SOURCES := source source/tarosa source/bootloader -INCLUDES := include build source/tarosa source/bootloader +SOURCES := source source/tarosa include +INCLUDES := include build source/tarosa DATA := data STATICLIBS := #--------------------------------------------------------------------------------- diff --git a/arm9/source/defaultSettings.s b/arm9/include/defaultSettings.s similarity index 100% rename from arm9/source/defaultSettings.s rename to arm9/include/defaultSettings.s diff --git a/arm9/source/dsCard.h b/arm9/include/dsCard.h similarity index 100% rename from arm9/source/dsCard.h rename to arm9/include/dsCard.h diff --git a/arm9/source/dsCard.itcm.cpp b/arm9/include/dsCard.itcm.cpp similarity index 99% rename from arm9/source/dsCard.itcm.cpp rename to arm9/include/dsCard.itcm.cpp index 7381e2b..0dca608 100644 --- a/arm9/source/dsCard.itcm.cpp +++ b/arm9/include/dsCard.itcm.cpp @@ -145,7 +145,7 @@ u32 ReadNorFlashID() { return 0x227E2218; } } - return 0x227E2220; + return 0x227E2220; // EZFlash IV or EWIN } void chip_reset() { diff --git a/arm9/source/graphics.s b/arm9/include/graphics.s similarity index 100% rename from arm9/source/graphics.s rename to arm9/include/graphics.s diff --git a/arm9/source/io_sc_common.c b/arm9/include/io_sc_common.c similarity index 100% rename from arm9/source/io_sc_common.c rename to arm9/include/io_sc_common.c diff --git a/arm9/source/io_sc_common.h b/arm9/include/io_sc_common.h similarity index 100% rename from arm9/source/io_sc_common.h rename to arm9/include/io_sc_common.h diff --git a/arm9/source/bootloader/nds_loader_arm9.c b/arm9/include/nds_loader_arm9.c similarity index 100% rename from arm9/source/bootloader/nds_loader_arm9.c rename to arm9/include/nds_loader_arm9.c diff --git a/arm9/source/bootloader/nds_loader_arm9.h b/arm9/include/nds_loader_arm9.h similarity index 100% rename from arm9/source/bootloader/nds_loader_arm9.h rename to arm9/include/nds_loader_arm9.h diff --git a/arm9/source/bootloader/ret_menu9_gen.c b/arm9/include/ret_menu9_gen.c similarity index 100% rename from arm9/source/bootloader/ret_menu9_gen.c rename to arm9/include/ret_menu9_gen.c diff --git a/arm9/source/bootloader/ret_menu9_gen.h b/arm9/include/ret_menu9_gen.h similarity index 100% rename from arm9/source/bootloader/ret_menu9_gen.h rename to arm9/include/ret_menu9_gen.h diff --git a/arm9/source/gbaldr.itcm.cpp b/arm9/source/gbaldr.itcm.cpp index c872c2b..4d4e835 100644 --- a/arm9/source/gbaldr.itcm.cpp +++ b/arm9/source/gbaldr.itcm.cpp @@ -492,8 +492,7 @@ int checkSRAM(char *name) { ctrl_get(); for(i = 0; ctrl.sign[i] != 0; i++) { - if(ctrl.sign[i] != Rudolph[i]) - break; + if(ctrl.sign[i] != Rudolph[i])break; } if(carttype < 4)OpenNorWrite(); diff --git a/arm9/source/main.c b/arm9/source/main.c index 066f1d5..856549a 100644 --- a/arm9/source/main.c +++ b/arm9/source/main.c @@ -33,27 +33,24 @@ #include #include "maindef.h" -#include "dsCard.h" -#include "GBA_ini.h" -#include "ctrl_tbl.h" - -#include "bootloader/ret_menu9_gen.h" - -#include "memcleaner.h" - -#include "skin.h" -#include "message.h" #include "tarosa/tarosa_Graphic.h" #include "tarosa/tarosa_Shinofont.h" +#include "ret_menu9_gen.h" +#include "dsCard.h" + +#include "GBA_ini.h" +#include "ctrl_tbl.h" +#include "skin.h" +#include "message.h" extern uint16* MainScreen; extern uint16* SubScreen; #define BG_256_COLOR (BIT(7)) -#define VERSTRING "v0.61" +#define VERSTRING "v0.61b" int numFiles = 0; int numGames = 0; @@ -145,8 +142,7 @@ void gba_frame() { } static void resetToSlot2() { - vu32 vr; - + vu32 vr; // make arm9 loop code *((vu32*)0x027FFE08) = (u32)0xE59FF014; // ldr pc, 0x027FFE24 *((vu32*)0x027FFE24) = (u32)0x027FFE08; // Set ARM9 Loop address @@ -154,8 +150,7 @@ static void resetToSlot2() { sysSetCartOwner(BUS_OWNER_ARM7); // ARM7 has access to GBA cart - // FIFOSend(IPC_CMD_SLOT2); - fifoSendValue32(FIFO_USER_05, 1); + fifoSendValue32(FIFO_USER_02, 1); for(vr = 0; vr < 0x20000; vr++); // Wait ARM7 @@ -166,10 +161,7 @@ static void resetToSlot2() { void gbaMode() { - if(strncmp(GBA_HEADER.gamecode, "PASS", 4) == 0) { - // resetARM9Memory(); - resetToSlot2(); - } + if(strncmp(GBA_HEADER.gamecode, "PASS", 4) == 0)resetToSlot2(); videoSetMode(0); videoSetModeSub(0); @@ -960,7 +952,8 @@ void mainloop(void) { DrawBox_SUB(SubScreen, 21, 4, 234, 26, 5, 1); DrawBox_SUB(SubScreen, 22, 5, 233, 25, 0, 0); ShinoPrint_SUB( SubScreen, 9*6, 1*12-2, (u8*)"GBA ExpLoader", 0, 0, 0); - ShinoPrint_SUB( SubScreen, 34*6-2, 12, (u8 *)VERSTRING, 0, 0, 0); + // ShinoPrint_SUB( SubScreen, 34*6-2, 12, (u8*)VERSTRING, 0, 0, 0); + ShinoPrint_SUB( SubScreen, 33*6-2, 12, (u8*)VERSTRING, 0, 0, 0); DrawBox_SUB(SubScreen, 6, 125, 249, 190, 5, 0); diff --git a/arm9/source/maindef.h b/arm9/source/maindef.h index f40220b..2faa98b 100644 --- a/arm9/source/maindef.h +++ b/arm9/source/maindef.h @@ -3,7 +3,7 @@ #define maindef_h #define ROMTITLE "GBA ExpLoader" -#define ROMVERSION "Version 0.61 by Rudolph." +#define ROMVERSION "Version 0.61b by Rudolph." #define ROMDATE ""__DATE__" "__TIME__ #endif diff --git a/arm9/source/memcleaner.cpp b/arm9/source/memcleaner.cpp deleted file mode 100644 index 36cf5d6..0000000 --- a/arm9/source/memcleaner.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/*--------------------------------------------------------------------------------- - - -Copyright (C) 2007 Acekard, www.acekard.com - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - - ----------------------------------------------------------------------------------*/ - -#include - -#include "memcleaner.h" - -void resetARM9Memory() { - // DMA - for (u8 i=0; i<4; i++) { - DMA_CR(i) = 0; - DMA_SRC(i) = 0; - DMA_DEST(i) = 0; - TIMER_CR(i) = 0; - TIMER_DATA(i) = 0; - } - - swiWaitForVBlank(); // wait for VBLANK to avoid screen picture break - //PALETTE[0] = 0xFFFF; - - // VIDEO - // trun on vram banks for clear - VRAM_CR = 0x80808080; - (*(vu32*)0x027FFE04) = 0; // temporary variable - BG_PALETTE[0] = 0xFFFF; - dmaFillWords(0, BG_PALETTE+1, (2*1024)-2); - dmaFillWords(0, OAM, 2*1024); - dmaFillWords(0, (void*)0x04000000, 0x56); //clear main display registers - dmaFillWords(0, (void*)0x04001000, 0x56); //clear sub display registers - - // clear video registers - REG_DISPCNT = 0; - REG_DISPCNT_SUB = 0; - VRAM_A_CR = 0; - VRAM_B_CR = 0; - VRAM_C_CR = 0; - VRAM_D_CR = 0; - VRAM_E_CR = 0; - VRAM_F_CR = 0; - VRAM_G_CR = 0; - VRAM_H_CR = 0; - VRAM_I_CR = 0; - VRAM_CR = 0x00000000; - REG_POWERCNT = 0x820F; // turn on all engines - - // Interrupt - REG_IME = 0; - REG_IE = 0; - REG_IF = ~0; -} - diff --git a/arm9/source/memcleaner.h b/arm9/source/memcleaner.h deleted file mode 100644 index 8450908..0000000 --- a/arm9/source/memcleaner.h +++ /dev/null @@ -1,51 +0,0 @@ -/*--------------------------------------------------------------------------------- - - -Copyright (C) 2007 Acekard, www.acekard.com - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - - ----------------------------------------------------------------------------------*/ - - - - - - - - - -#ifndef _MEMCLEANER_H_ -#define _MEMCLEANER_H_ - -#ifdef __cplusplus -extern "C" { -#endif - - -void resetARM9Memory(); - - - -#ifdef __cplusplus -} -#endif - -#endif//_MEMCLEANER_H_