mirror of
https://github.com/ApacheThunder/NTR_Launcher.git
synced 2025-06-19 03:25:38 -04:00
Cleaned up some code..
It almost compiles without any warnings now. Only fix left for it that is to redo slot reset code. Original code is too much of a mess to compile with the "-Wall -Wextra -Werror" flag. That flag has been added to makefile of arm9/bootloader. Once arm7 is fixed it will be added there as well.
This commit is contained in:
parent
a14a73c7d1
commit
02b267152a
@ -26,6 +26,7 @@ ARCH := -mthumb-interwork -march=armv4t -mtune=arm7tdmi
|
||||
CFLAGS := -g -Wall -O2\
|
||||
-fomit-frame-pointer\
|
||||
-ffast-math \
|
||||
-Wall -Wextra -Werror \
|
||||
$(ARCH)
|
||||
|
||||
CFLAGS += $(INCLUDE) -DARM7
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include <nds/dma.h>
|
||||
#include <nds/arm7/audio.h>
|
||||
#include <nds/ipc.h>
|
||||
|
||||
// #include <nds/registers_alt.h>
|
||||
// #include <nds/memory.h>
|
||||
// #include <nds/card.h>
|
||||
@ -47,7 +48,7 @@
|
||||
|
||||
#include "common.h"
|
||||
#include "read_card.h"
|
||||
|
||||
|
||||
void arm7_clearmem (void* loc, size_t len);
|
||||
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
@ -217,11 +218,9 @@ void arm7_startBinary (void)
|
||||
|
||||
while(REG_VCOUNT!=191);
|
||||
while(REG_VCOUNT==191);
|
||||
|
||||
// Start ARM7
|
||||
|
||||
void (*foo)() = *(u32*)(0x27FFE34);
|
||||
|
||||
foo();
|
||||
((void (*)())(*(u32*)(0x27FFE34)))();
|
||||
}
|
||||
|
||||
|
||||
|
@ -37,8 +37,14 @@
|
||||
#include <nds/system.h>
|
||||
#include <nds/ipc.h>
|
||||
|
||||
#include <nds/dma.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#define resetCpu_arm9() \
|
||||
__asm volatile("swi 0x000000")
|
||||
|
||||
volatile int arm9_stateFlag = ARM9_BOOT;
|
||||
volatile u32 arm9_errorCode = 0xFFFFFFFF;
|
||||
volatile bool arm9_errorClearBG = false;
|
||||
@ -232,12 +238,8 @@ void arm9_main (void) {
|
||||
while(REG_VCOUNT!=191);
|
||||
while(REG_VCOUNT==191);
|
||||
|
||||
u32 first = *(u32*)(0x27FFE34);
|
||||
|
||||
// arm9_errorOutput (*(u32*)(first), true);
|
||||
|
||||
void (*newReset)() = *(u32*)(0x27FFE24);
|
||||
|
||||
newReset();
|
||||
((void (*)())(*(u32*)(0x27FFE24)))();
|
||||
}
|
||||
|
||||
|
2
Makefile
2
Makefile
@ -31,7 +31,7 @@ $(TARGET).nds : $(TARGET).arm7 $(TARGET).arm9
|
||||
-b $(CURDIR)/icon.bmp "NTR Launcher;NitroHax provided by Chishm;Modified by Apache Thunder" \
|
||||
-g KKGP 01 "NTR LAUNCHER" -z 80040000 -u 00030004
|
||||
python patch_ndsheader_dsiware.py $(CURDIR)/$(TARGET).nds --accessControl 0x00000038
|
||||
make_cia --srl=$(CURDIR)/$(TARGET).nds
|
||||
makerom -srl $(CURDIR)/$(TARGET).nds
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
$(TARGET).arm7 : arm7/$(TARGET).elf
|
||||
|
@ -14,7 +14,7 @@ int PowerOnSlot() {
|
||||
REG_ROMCTRL = 0x20000000; // wait 27ms, then set ROMCTRL=20000000h
|
||||
|
||||
while(REG_ROMCTRL&0x8000000 != 0x8000000);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int PowerOffSlot() {
|
||||
@ -23,11 +23,13 @@ int PowerOffSlot() {
|
||||
|
||||
REG_SCFG_MC = 0x0C; // set state=3
|
||||
while(REG_SCFG_MC&0x0C != 0x00); // wait until state=0
|
||||
return 0;
|
||||
}
|
||||
|
||||
void TWL_ResetSlot1() {
|
||||
int TWL_ResetSlot1() {
|
||||
PowerOffSlot();
|
||||
for (int i = 0; i < 30; i++) { swiWaitForVBlank(); }
|
||||
PowerOnSlot();
|
||||
PowerOnSlot();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@ extern "C" {
|
||||
|
||||
int PowerOnSlot(void);
|
||||
int PowerOffSlot(void);
|
||||
void TWL_ResetSlot1(void);
|
||||
int TWL_ResetSlot1(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ ARCH := -march=armv5te -mtune=arm946e-s -mthumb -mthumb-interwork
|
||||
CFLAGS := -g -Wall -O2\
|
||||
-fomit-frame-pointer\
|
||||
-ffast-math \
|
||||
-Wall -Wextra -Werror \
|
||||
$(ARCH)
|
||||
|
||||
CFLAGS += $(INCLUDE) -DARM9 -fno-strict-aliasing
|
||||
@ -106,6 +107,7 @@ $(BUILD):
|
||||
clean:
|
||||
@echo clean ...
|
||||
@rm -fr $(BUILD) *.elf *.nds* *.bin
|
||||
@rm -fr $(DATA) *.elf *.nds* *.bin
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
|
@ -20,6 +20,8 @@
|
||||
|
||||
#include "errorsplash.h"
|
||||
|
||||
#include "bootsplash.h"
|
||||
|
||||
#include "bios_decompress_callback.h"
|
||||
|
||||
#include "fade00.h"
|
||||
|
@ -21,7 +21,6 @@
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include "inifile.h"
|
||||
#include "stringtool.h"
|
||||
|
||||
static bool freadLine(FILE* f,std::string& str)
|
||||
{
|
||||
@ -104,7 +103,9 @@ void CIniFile::SetString(const std::string& Section,const std::string& Item,cons
|
||||
|
||||
void CIniFile::SetInt(const std::string& Section,const std::string& Item,int Value)
|
||||
{
|
||||
std::string strtemp=formatString("%d",Value);
|
||||
char buf[16];
|
||||
snprintf(buf, sizeof(buf), "%d", Value);
|
||||
std::string strtemp(buf);
|
||||
|
||||
if(GetFileString(Section,Item)!=strtemp)
|
||||
{
|
||||
@ -275,7 +276,7 @@ std::string CIniFile::GetFileString(const std::string& Section,const std::string
|
||||
|
||||
m_bLastResult=false;
|
||||
|
||||
if(iFileLines>=0)
|
||||
if(iFileLines>0)
|
||||
{
|
||||
while(ii<iFileLines)
|
||||
{
|
||||
@ -389,3 +390,4 @@ bool CIniFile::ReplaceLine(size_t line,const std::string& str)
|
||||
m_FileContainer[line]=str;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ class CIniFile
|
||||
{
|
||||
public:
|
||||
CIniFile();
|
||||
CIniFile(const std::string& filename);
|
||||
explicit CIniFile(const std::string& filename);
|
||||
virtual ~CIniFile();
|
||||
|
||||
public:
|
||||
|
@ -39,7 +39,7 @@
|
||||
// #define REG_SCFG_MC (*(vu32*)0x4004010)
|
||||
|
||||
|
||||
int main(int argc, const char* argv[]) {
|
||||
int main() {
|
||||
|
||||
// NTR Mode/Splash used by default
|
||||
bool UseNTRSplash = true;
|
||||
@ -59,7 +59,6 @@ int main(int argc, const char* argv[]) {
|
||||
|
||||
u32 ndsHeader[0x80];
|
||||
char gameid[4];
|
||||
uint32_t headerCRC;
|
||||
|
||||
scanKeys();
|
||||
int pressed = keysDown();
|
||||
@ -77,9 +76,9 @@ int main(int argc, const char* argv[]) {
|
||||
|
||||
if( UseNTRSplash == true ) {
|
||||
fifoSendValue32(FIFO_USER_04, 1);
|
||||
// REG_SCFG_CLK = 0x80;
|
||||
// New libnds function for going back to NTR clock speeds
|
||||
setCpuClock(false);
|
||||
// Disabled for now. Doesn't result in correct SCFG_CLK configuration during testing. Will go back to old method.
|
||||
// setCpuClock(false);
|
||||
REG_SCFG_CLK = 0x80;
|
||||
swiWaitForVBlank();
|
||||
}
|
||||
|
||||
@ -119,7 +118,6 @@ int main(int argc, const char* argv[]) {
|
||||
for (int i = 0; i < 20; i++) { swiWaitForVBlank(); }
|
||||
|
||||
memcpy (gameid, ((const char*)ndsHeader) + 12, 4);
|
||||
headerCRC = crc32((const char*)ndsHeader, sizeof(ndsHeader));
|
||||
|
||||
while(1) {
|
||||
if(REG_SCFG_MC == 0x11) {
|
||||
|
@ -1,45 +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 "stringtool.h"
|
||||
#include <cstdarg>
|
||||
#include <cstdio>
|
||||
#include <malloc.h>
|
||||
|
||||
std::string formatString( const char* fmt, ... )
|
||||
{
|
||||
const char * f = fmt;
|
||||
va_list argList;
|
||||
va_start(argList, fmt);
|
||||
char * ptempStr = NULL;
|
||||
size_t max_len = vasiprintf( &ptempStr, f, argList);
|
||||
std::string str( ptempStr );
|
||||
str.resize( max_len );
|
||||
free( ptempStr );
|
||||
va_end(argList);
|
||||
return str;
|
||||
}
|
||||
|
@ -1,44 +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 _STRINGTOOL_H_
|
||||
#define _STRINGTOOL_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
std::string formatString( const char* fmt, ... );
|
||||
|
||||
|
||||
|
||||
#endif//_STRINGTOOL_H_
|
Loading…
Reference in New Issue
Block a user