Skip to content

Commit

Permalink
Some minor refractoring...
Browse files Browse the repository at this point in the history
Uses new ndstool commands. No longer needs old python script to make a
HiyaCFW or CIA friendly SRL.

Note however latest commit of ndstool is required for icon to show up
properly on DSi's menu. This is not an issue for 3DS however.

This should now operate correctly on DSi as well once
HiyaCFW/RocketLauncher is released.

A template title.tmd file is provided.
  • Loading branch information
ApacheThunder committed Apr 4, 2018
1 parent 8796775 commit 702fd14
Show file tree
Hide file tree
Showing 10 changed files with 145 additions and 591 deletions.
4 changes: 2 additions & 2 deletions BootLoader/source/main.arm7.c
Expand Up @@ -228,7 +228,7 @@ void arm7_startBinary (void)

void arm7_main (void) {
int errorCode;

// Wait for ARM9 to at least start
while (arm9_stateFlag < ARM9_START);

Expand All @@ -254,7 +254,7 @@ void arm7_main (void) {
}

debugOutput (ERR_STS_START);

arm7_startBinary();

return;
Expand Down
3 changes: 1 addition & 2 deletions Makefile
Expand Up @@ -33,8 +33,7 @@ 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" \
-g CHCT 01 "NTR NITROHAX" -z 80040000 -u 00030004
python patch_ndsheader_dsiware.py $(CURDIR)/$(TARGET).nds --accessControl 0x00000038
-g CHCT 01 "NTR NITROHAX" -z 80040000 -u 00030004 -a 00000038 -p 0000

#---------------------------------------------------------------------------------
# Create boot loader and link raw binary into ARM9 ELF
Expand Down
39 changes: 4 additions & 35 deletions arm7/source/main.c
Expand Up @@ -22,41 +22,7 @@
#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();
}
*/
#include "resetslot.h"

void VcountHandler() {
inputGetAndSend();
Expand Down Expand Up @@ -90,6 +56,9 @@ int main(void) {

irqEnable( IRQ_VBLANK | IRQ_VCOUNT);

i2cWriteRegister(0x4A, 0x12, 0x00); // Press power-button for auto-reset
i2cWriteRegister(0x4A, 0x70, 0x01); // Bootflag = Warmboot/SkipHealthSafety

// 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.
Expand Down
30 changes: 30 additions & 0 deletions arm7/source/resetslot.c
@@ -0,0 +1,30 @@
#include <nds.h>

int PowerOnSlot() {
REG_SCFG_MC = 0x04; // set state=1
while(REG_SCFG_MC&1);

REG_SCFG_MC = 0x08; // set state=2
while(REG_SCFG_MC&1);

REG_ROMCTRL = 0x20000000; // set ROMCTRL=20000000h
return 0;
}

/* Unused for now
int PowerOffSlot() {
if(REG_SCFG_MC&1) return 1;
REG_SCFG_MC = 0x0C; // set state=3
while(REG_SCFG_MC&1);
return 0;
}
int TWL_ResetSlot1() {
PowerOffSlot();
for (int i = 0; i < 30; i++) { swiWaitForVBlank(); }
PowerOnSlot();
return 0;
}
*/

18 changes: 18 additions & 0 deletions arm7/source/resetslot.h
@@ -0,0 +1,18 @@
#ifndef RESETSLOT_H
#define RESETSLOT_H


#ifdef __cplusplus
extern "C" {
#endif

int PowerOnSlot(void);
int PowerOffSlot(void);
int TWL_ResetSlot1(void);

#ifdef __cplusplus
}
#endif

#endif

0 comments on commit 702fd14

Please sign in to comment.