mirror of
https://github.com/ApacheThunder/GBA-Exploader.git
synced 2025-06-18 19:45:39 -04:00

* Add new error message for detecting if run on DSi/3DS consoles as this program isn't really compatible with those consoles for obvious reasons. * Add initial support for SuperCard Lite (and possibly other SuperCard varients). Note that saves are not currently functional though. * Add back initial support for EZ Flash 3 in 1 Plus. Note that NorFlash commands appear to not be working at the moment. RAM mode untested. New code added for detecting 3 in 1 Plus when detecting max allowed file size. This should allow writing 64MB gba roms to 3 in 1 Plus...once NorFlash stuff is fixed that is. :P * Tested as working properly with regular EZ Flash 3 in 1 carts. * Note that version 0.58 already exists but we do not have source code for it. (source was released only for 0.57. Rudolph could not find the last version's source code unfortunately. This is why 3 in 1 Plus support is incomplete. (it at least detects it now which original 0.57 could not do and will in theory allow writing 64MB GBA roms once NorFlash stuff is fixed for that cart)
142 lines
3.3 KiB
C
142 lines
3.3 KiB
C
/*---------------------------------------------------------------------------------
|
|
|
|
default ARM7 core
|
|
|
|
Copyright (C) 2005 - 2010
|
|
Michael Noland (joat)
|
|
Jason Rogers (dovoto)
|
|
Dave Murphy (WinterMute)
|
|
|
|
This software is provided 'as-is', without any express or implied
|
|
warranty. In no event will the authors be held liable for any
|
|
damages arising from the use of this software.
|
|
|
|
Permission is granted to anyone to use this software for any
|
|
purpose, including commercial applications, and to alter it and
|
|
redistribute it freely, subject to the following restrictions:
|
|
|
|
1. The origin of this software must not be misrepresented; you
|
|
must not claim that you wrote the original software. If you use
|
|
this software in a product, an acknowledgment in the product
|
|
documentation would be appreciated but is not required.
|
|
|
|
2. Altered source versions must be plainly marked as such, and
|
|
must not be misrepresented as being the original software.
|
|
|
|
3. This notice may not be removed or altered from any source
|
|
distribution.
|
|
|
|
---------------------------------------------------------------------------------*/
|
|
#include <nds.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
#include "linkreset_arm7.h"
|
|
|
|
volatile bool switchedMode = false;
|
|
|
|
extern void ret_menu7_R4(void);
|
|
extern void ret_menu7_Gen(void);
|
|
extern void ret_menu7_mse(void);
|
|
|
|
// libnds messed up the original SWI bios call ASM.
|
|
// They used r0 instead of r2. This reimplementation fixes that issue for now.
|
|
extern void swiSwitchToGBAModeFixed();
|
|
|
|
void gbaMode() {
|
|
vu32 vr;
|
|
|
|
REG_IME = IME_DISABLE;
|
|
for(vr = 0; vr < 0x1000; vr++); // Wait ARM9
|
|
|
|
if (PersonalData->gbaScreen) {
|
|
writePowerManagement(PM_CONTROL_REG, PM_BACKLIGHT_BOTTOM | PM_SOUND_AMP);
|
|
} else {
|
|
writePowerManagement(PM_CONTROL_REG, PM_BACKLIGHT_TOP | PM_SOUND_AMP);
|
|
}
|
|
swiSwitchToGBAModeFixed();
|
|
while(1);
|
|
}
|
|
|
|
static void prepairReset() {
|
|
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();
|
|
}
|
|
|
|
volatile bool exitflag = false;
|
|
|
|
void powerButtonCB() { exitflag = true; }
|
|
|
|
void fifoCheckHandler() {
|
|
if (!switchedMode) {
|
|
if(fifoCheckValue32(FIFO_USER_01)) {
|
|
switchedMode = true;
|
|
gbaMode();
|
|
} else if (fifoCheckValue32(FIFO_USER_02)) {
|
|
switchedMode = true;
|
|
ret_menu7_R4();
|
|
} else if (fifoCheckValue32(FIFO_USER_03)) {
|
|
switchedMode = true;
|
|
LinkReset_ARM7();
|
|
} else if (fifoCheckValue32(FIFO_USER_04)) {
|
|
switchedMode = true;
|
|
ret_menu7_Gen();
|
|
} else if (fifoCheckValue32(FIFO_USER_05)) {
|
|
switchedMode = true;
|
|
prepairReset();
|
|
}
|
|
}
|
|
}
|
|
|
|
void VblankHandler(void) {
|
|
fifoCheckHandler();
|
|
// Wifi_Update();
|
|
}
|
|
|
|
|
|
void VcountHandler() { inputGetAndSend(); }
|
|
|
|
int main() {
|
|
readUserSettings();
|
|
ledBlink(0);
|
|
|
|
irqInit();
|
|
// Start the RTC tracking IRQ
|
|
initClockIRQ();
|
|
fifoInit();
|
|
touchInit();
|
|
|
|
SetYtrigger(80);
|
|
|
|
installSystemFIFO();
|
|
|
|
irqSet(IRQ_VCOUNT, VcountHandler);
|
|
irqSet(IRQ_VBLANK, VblankHandler);
|
|
|
|
irqEnable(IRQ_VBLANK | IRQ_VCOUNT);
|
|
|
|
/*if (REG_SNDEXTCNT != 0) {
|
|
i2cWriteRegister(0x4A, 0x12, 0x00); // Press power-button for auto-reset
|
|
i2cWriteRegister(0x4A, 0x70, 0x01); // Bootflag = Warmboot/SkipHealthSafety
|
|
}*/
|
|
|
|
setPowerButtonCB(powerButtonCB);
|
|
|
|
// Keep the ARM7 mostly idle
|
|
while(1)swiWaitForVBlank();
|
|
return 0;
|
|
}
|
|
|