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)
This commit is contained in:
ApacheThunder 2024-05-19 23:50:00 -05:00
parent de53d7252d
commit 7084d26052
18 changed files with 48 additions and 160 deletions

View File

@ -9,7 +9,7 @@ export TARGET := GBA_ExpLoader
export TOPDIR := $(CURDIR) export TOPDIR := $(CURDIR)
export VERSION_MAJOR := 0 export VERSION_MAJOR := 0
export VERSION_MINOR := 61 export VERSION_MINOR := 61b
export VERSTRING := $(VERSION_MAJOR).$(VERSION_MINOR) export VERSTRING := $(VERSION_MAJOR).$(VERSION_MINOR)
# GMAE_ICON is the image used to create the game icon, leave blank to use default rule # 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 $(TARGET).nds : arm7/$(TARGET).elf arm9/$(TARGET).elf
@ndstool -c $@ -7 arm7/$(TARGET).elf -9 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 \ -g #### 01 "GBAEXPLOADER" -z 80040000 -u 00030004 -a 00000138 -p 0001 \
data: data:
@mkdir -p data @mkdir -p arm9/data
ndsbootloader: data ndsbootloader: data
$(MAKE) -C ndsbootloader LOADBIN=$(CURDIR)/arm9/data/load.bin $(MAKE) -C ndsbootloader LOADBIN=$(CURDIR)/arm9/data/load.bin
@ -67,6 +67,6 @@ clean:
$(MAKE) -C arm9 clean $(MAKE) -C arm9 clean
$(MAKE) -C arm7 clean $(MAKE) -C arm7 clean
$(MAKE) -C ndsbootloader clean $(MAKE) -C ndsbootloader clean
rm -rf data rm -rf arm9/data
rm -f $(TARGET).nds rm -f $(TARGET).nds

View File

@ -37,6 +37,24 @@ volatile bool switchedMode = false;
// They used r0 instead of r2. This reimplementation fixes that issue for now. // They used r0 instead of r2. This reimplementation fixes that issue for now.
extern void swiSwitchToGBAModeFixed(); 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() { void gbaMode() {
vu32 vr; vu32 vr;
@ -57,15 +75,18 @@ volatile bool exitflag = false;
void powerButtonCB() { exitflag = true; } void powerButtonCB() { exitflag = true; }
void fifoCheckHandler() { void fifoCheckHandler() {
if (!switchedMode && fifoCheckValue32(FIFO_USER_01)) { if (!switchedMode) {
if (fifoCheckValue32(FIFO_USER_01)) {
switchedMode = true; switchedMode = true;
gbaMode(); gbaMode();
} else if (fifoCheckValue32(FIFO_USER_02)) {
switchedMode = true;
prepareReset();
}
} }
} }
void VblankHandler(void) { fifoCheckHandler(); } void VblankHandler(void) { fifoCheckHandler(); }
void VcountHandler() { inputGetAndSend(); } void VcountHandler() { inputGetAndSend(); }
int main() { int main() {

View File

@ -16,8 +16,8 @@ include $(DEVKITARM)/ds_rules
# all directories are relative to this makefile # all directories are relative to this makefile
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
BUILD := build BUILD := build
SOURCES := source source/tarosa source/bootloader SOURCES := source source/tarosa include
INCLUDES := include build source/tarosa source/bootloader INCLUDES := include build source/tarosa
DATA := data DATA := data
STATICLIBS := STATICLIBS :=
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------

View File

@ -145,7 +145,7 @@ u32 ReadNorFlashID() {
return 0x227E2218; return 0x227E2218;
} }
} }
return 0x227E2220; return 0x227E2220; // EZFlash IV or EWIN
} }
void chip_reset() { void chip_reset() {

View File

@ -492,8 +492,7 @@ int checkSRAM(char *name) {
ctrl_get(); ctrl_get();
for(i = 0; ctrl.sign[i] != 0; i++) { for(i = 0; ctrl.sign[i] != 0; i++) {
if(ctrl.sign[i] != Rudolph[i]) if(ctrl.sign[i] != Rudolph[i])break;
break;
} }
if(carttype < 4)OpenNorWrite(); if(carttype < 4)OpenNorWrite();

View File

@ -33,27 +33,24 @@
#include <string.h> #include <string.h>
#include "maindef.h" #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_Graphic.h"
#include "tarosa/tarosa_Shinofont.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* MainScreen;
extern uint16* SubScreen; extern uint16* SubScreen;
#define BG_256_COLOR (BIT(7)) #define BG_256_COLOR (BIT(7))
#define VERSTRING "v0.61" #define VERSTRING "v0.61b"
int numFiles = 0; int numFiles = 0;
int numGames = 0; int numGames = 0;
@ -146,7 +143,6 @@ void gba_frame() {
static void resetToSlot2() { static void resetToSlot2() {
vu32 vr; vu32 vr;
// make arm9 loop code // make arm9 loop code
*((vu32*)0x027FFE08) = (u32)0xE59FF014; // ldr pc, 0x027FFE24 *((vu32*)0x027FFE08) = (u32)0xE59FF014; // ldr pc, 0x027FFE24
*((vu32*)0x027FFE24) = (u32)0x027FFE08; // Set ARM9 Loop address *((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 sysSetCartOwner(BUS_OWNER_ARM7); // ARM7 has access to GBA cart
// FIFOSend(IPC_CMD_SLOT2); fifoSendValue32(FIFO_USER_02, 1);
fifoSendValue32(FIFO_USER_05, 1);
for(vr = 0; vr < 0x20000; vr++); // Wait ARM7 for(vr = 0; vr < 0x20000; vr++); // Wait ARM7
@ -166,10 +161,7 @@ static void resetToSlot2() {
void gbaMode() { void gbaMode() {
if(strncmp(GBA_HEADER.gamecode, "PASS", 4) == 0) { if(strncmp(GBA_HEADER.gamecode, "PASS", 4) == 0)resetToSlot2();
// resetARM9Memory();
resetToSlot2();
}
videoSetMode(0); videoSetMode(0);
videoSetModeSub(0); videoSetModeSub(0);
@ -960,7 +952,8 @@ void mainloop(void) {
DrawBox_SUB(SubScreen, 21, 4, 234, 26, 5, 1); DrawBox_SUB(SubScreen, 21, 4, 234, 26, 5, 1);
DrawBox_SUB(SubScreen, 22, 5, 233, 25, 0, 0); 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, 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); DrawBox_SUB(SubScreen, 6, 125, 249, 190, 5, 0);

View File

@ -3,7 +3,7 @@
#define maindef_h #define maindef_h
#define ROMTITLE "GBA ExpLoader" #define ROMTITLE "GBA ExpLoader"
#define ROMVERSION "Version 0.61 by Rudolph." #define ROMVERSION "Version 0.61b by Rudolph."
#define ROMDATE ""__DATE__" "__TIME__ #define ROMDATE ""__DATE__" "__TIME__
#endif #endif

View File

@ -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 <nds.h>
#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;
}

View File

@ -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_