Skip to content

Commit

Permalink
Migrate changes from old Nitrohax repo...
Browse files Browse the repository at this point in the history
Migrate most changes from old NitroHax repo.

Also added faster vram setting to SCFG_EXT for arm9 if TWL clock speed
option is enabled prior to booting the game. (activated by hitting
select before starting a game as was the case in the last builds)

Also added proper DSi splash screen for the splash used for the TWL
clock speed option. Also reorganized the bootsplash code a bit to match
more closely to how it's currently configured in NTR_Launcher.
  • Loading branch information
ApacheThunder committed Feb 18, 2017
1 parent 475982a commit 5d0a33c
Show file tree
Hide file tree
Showing 149 changed files with 1,800 additions and 405 deletions.
1 change: 0 additions & 1 deletion BootLoader/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ ARCH := -mthumb-interwork -march=armv4t -mtune=arm7tdmi
CFLAGS := -g -Wall -O2\
-fomit-frame-pointer\
-ffast-math \
-Wall -Wextra -Werror \
$(ARCH)

CFLAGS += $(INCLUDE) -DARM7
Expand Down
3 changes: 2 additions & 1 deletion BootLoader/source/cheat.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
extern unsigned long cheat_engine_size;
extern unsigned long intr_orig_return_offset;

extern const u8 cheat_engine_start[];
extern const u8 cheat_engine_start[];

#define CHEAT_CODE_END 0xCF000000
#define CHEAT_ENGINE_RELOCATE 0xCF000001
#define CHEAT_ENGINE_HOOK 0xCF000002
Expand Down
5 changes: 4 additions & 1 deletion BootLoader/source/main.arm9.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ arm9_errorOutput
Displays an error code on screen.
Written by Chishm
--------------------------------------------------------------------------*/
/* Disabled for non debug version. Enable to debug card init problems
static void arm9_errorOutput (u32 code, bool clearBG) {
int i, j, k;
u16 colour;
Expand Down Expand Up @@ -129,6 +130,7 @@ static void arm9_errorOutput (u32 code, bool clearBG) {
}
}
}
*/

/*-------------------------------------------------------------------------
arm9_main
Expand Down Expand Up @@ -217,7 +219,8 @@ void arm9_main (void) {
arm9_stateFlag = ARM9_READY;
while ( arm9_stateFlag != ARM9_BOOTBIN ) {
if (arm9_stateFlag == ARM9_DISPERR) {
arm9_errorOutput (arm9_errorCode, arm9_errorClearBG);
// Re-enable to debug card init issues.
// arm9_errorOutput (arm9_errorCode, arm9_errorClearBG);
if ( arm9_stateFlag == ARM9_DISPERR) {
arm9_stateFlag = ARM9_READY;
}
Expand Down
3 changes: 2 additions & 1 deletion BootLoader/source/read_card.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,8 @@ int cardInit (tNDSHeader* ndsHeader, u32* chipID)
for (i = 0; i < 0x200; i ++) {
*secureArea++ = 0xe7ffdeff;
}
return normalChip ? ERR_SEC_NORM : ERR_SEC_OTHR;
// return normalChip ? ERR_SEC_NORM : ERR_SEC_OTHR;
return normalChip ? ERR_NONE : ERR_NONE;
}

return ERR_NONE;
Expand Down
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export TARGET := NitroHax
export TOPDIR := $(CURDIR)

export VERSION_MAJOR := 0
export VERSION_MINOR := 93
export VERSION_MINOR := 99
export VERSTRING := $(VERSION_MAJOR).$(VERSION_MINOR)


Expand All @@ -32,7 +32,8 @@ checkarm9:

$(TARGET).nds : arm7/$(TARGET).elf arm9/$(TARGET).elf
ndstool -c $(TARGET).nds -7 arm7/$(TARGET).elf -9 arm9/$(TARGET).elf \
-b $(CURDIR)/icon.bmp "Nitro Hax;DS Game Cheat Tool;Created by Chishm"
-b $(CURDIR)/icon.bmp "Nitro Hax;DS Game Cheat Tool;Created by Chishm" \
-g CHCT 01 "NTR NITROHAX" -z 80040000 -u 00030004

#---------------------------------------------------------------------------------
# Create boot loader and link raw binary into ARM9 ELF
Expand Down Expand Up @@ -81,4 +82,5 @@ clean:
$(MAKE) -C arm7 clean
$(MAKE) -C BootLoader clean
rm -f arm9/data/load.bin
rm -f arm9/source/version.h
rm -f $(TARGET).ds.gba $(TARGET).nds $(TARGET).arm7 $(TARGET).arm9
3 changes: 1 addition & 2 deletions arm7/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ ARCH := -mthumb-interwork -march=armv4t -mtune=arm7tdmi
CFLAGS := -g -Wall -O2\
-fomit-frame-pointer\
-ffast-math \
-Wall -Wextra -Werror \
$(ARCH)

CFLAGS += $(INCLUDE) -DARM7
Expand All @@ -37,7 +36,7 @@ CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -fno-rtti
ASFLAGS := -g $(ARCH) $(INCLUDE)
LDFLAGS = -specs=ds_arm7.specs -g $(ARCH) -Wl,-Map,$(notdir $*).map

LIBS := -lnds7
LIBS := -lmm7 -lnds7

#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
Expand Down
4 changes: 4 additions & 0 deletions arm7/source/cheat_engine_arm7.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ void runCheatEngineCheck (void)
{
if(*((vu32*)0x027FFE24) == (u32)0x027FFE04)
{
REG_SCFG_ROM = 0x703;
if(fifoCheckValue32(FIFO_USER_04)) { REG_SCFG_CLK=0x0180; }
REG_SCFG_EXT = 0x12A00000;

irqDisable (IRQ_ALL);
*((vu32*)0x027FFE34) = (u32)0x06000000;
swiSoftReset();
Expand Down
44 changes: 44 additions & 0 deletions arm7/source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,44 @@
#include <nds.h>
#include <nds/arm7/input.h>
#include <nds/system.h>
#include <maxmod7.h>

#include "cheat_engine_arm7.h"

void PowerOnSlot() {

// Power On Slot
while(REG_SCFG_MC&0x0C != 0x0C); // wait until state<>3
if(REG_SCFG_MC&0x0C != 0x00) return; // exit if state<>0

REG_SCFG_MC = 0x04; // wait 1ms, then set state=1
while(REG_SCFG_MC&0x0C != 0x04);

REG_SCFG_MC = 0x08; // wait 10ms, then set state=2
while(REG_SCFG_MC&0x0C != 0x08);

REG_ROMCTRL = 0x20000000; // wait 27ms, then set ROMCTRL=20000000h

while(REG_ROMCTRL&0x8000000 != 0x8000000);

}

/*
// Not used for this project yet
void PowerOffSlot() {
while(REG_SCFG_MC&0x0C != 0x0C); // wait until state<>3
if(REG_SCFG_MC&0x0C != 0x08) return 1; // exit if state<>2
REG_SCFG_MC = 0x0C; // set state=3
while(REG_SCFG_MC&0x0C != 0x00); // wait until state=0
}
void TWL_ResetSlot1() {
PowerOffSlot();
for (int i = 0; i < 30; i++) { swiWaitForVBlank(); }
PowerOnSlot();
}
*/

void VcountHandler() {
inputGetAndSend();
Expand All @@ -43,15 +78,24 @@ int main(void) {
// Start the RTC tracking IRQ
initClockIRQ();

mmInstall(FIFO_MAXMOD);

SetYtrigger(80);

installSoundFIFO();
installSystemFIFO();

irqSet(IRQ_VCOUNT, VcountHandler);
irqSet(IRQ_VBLANK, VblankHandler);

irqEnable( IRQ_VBLANK | IRQ_VCOUNT);

// Make sure Arm9 had a chance to check slot status
fifoWaitValue32(FIFO_USER_01);
// If Arm9 reported slot is powered off, have Arm7 wait for Arm9 to be ready before card reset. This makes sure arm7 doesn't try card reset too early.
if(fifoCheckValue32(FIFO_USER_02)) { PowerOnSlot(); }
fifoSendValue32(FIFO_USER_03, 1);

// Keep the ARM7 mostly idle
while (1) {
runCheatEngineCheck();
Expand Down
Loading

0 comments on commit 5d0a33c

Please sign in to comment.